Skip to content

Commit

Permalink
feat(forge20): update to 1.20.2
Browse files Browse the repository at this point in the history
  • Loading branch information
danorris709 committed Oct 19, 2023
1 parent 67f93a8 commit 9aeefbf
Show file tree
Hide file tree
Showing 9 changed files with 44 additions and 45 deletions.
22 changes: 10 additions & 12 deletions forge20/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -5,28 +5,28 @@ plugins {

java.toolchain.languageVersion = JavaLanguageVersion.of(17)

forgeVersion = "1.20.1"
forgeVersion = "1.20.2"

minecraft {
mappings channel: 'official', version: '1.20.1'
mappings channel: 'official', version: "1.20.2"
}

sourceSets.main.resources { srcDir 'src/generated/resources' }

repositories {}

dependencies {
minecraft "net.minecraftforge:forge:1.20.1-47.1.44"
minecraft 'net.minecraftforge:forge:1.20.2-48.0.30'

implementation 'pixelmon:Pixelmon-1.20.1-9.2.1-server:9.2.1'
implementation 'pixelmon:Pixelmon-1.20.2-9.2.4-server:9.2.4'

implementation group: 'org.spongepowered', name: 'configurate-yaml', version: '4.0.0'
implementation group: 'org.spongepowered', name: 'configurate-yaml', version: '4.2.0-COMMENTS'

shadow group: 'com.envyful.api', name: 'commons', version: '5.0.2'
shadow (group: 'com.envyful.api', name: 'forge20', version: '5.0.2') {
shadow group: 'com.envyful.api', name: 'commons', version: '5.5.2'
shadow (group: 'com.envyful.api', name: 'forge20', version: '5.5.2') {
transitive = false;
}
shadow (group: 'com.envyful.api', name: 'reforged20', version: '5.0.2') {
shadow (group: 'com.envyful.api', name: 'reforged20', version: '5.5.2') {
transitive = false;
}
}
Expand All @@ -39,23 +39,21 @@ shadowJar {
relocate('org.spongepowered.configurate', 'com.envyful.sts.forge.shade.configurate')
relocate('org.yaml.snakeyaml', 'com.envyful.sts.forge.shade.snakeyaml')
relocate('io.leangen.geantyref', 'com.envyful.sts.forge.shade.geantyref')
relocate('com.google.gson', 'com.envyful.sts.forge.shade.gson')
relocate('com.zaxxer', 'com.envyful.sts.forge.shade.hikari')
relocate('org.slf4j', 'com.envyful.sts.forge.shade.slf4j')
relocate('com.envyful.api', 'com.envyful.sts.forge.shade.envy.api')
relocate('org.bstats', 'com.envyful.sts.forge.shade.bstats')
relocate('com.google.common', 'com.envyful.sts.forge.shade.guava')
relocate('org.apache.logging', 'com.envyful.sts.forge.shade.log4j')
relocate('io.netty', 'com.envyful.sts.forge.shade.netty')
relocate('io.lettuce', 'com.envyful.sts.forge.shade.lettuce')
relocate('com.cronutils', 'com.envyful.sts.forge.shade.cronutils')
relocate('com.cronutils', 'com.envyful.sts.forge.shade.cronutils')
relocate('com.sun.el', 'com.envyful.sts.forge.shade.sun.el')
relocate('javax', 'com.envyful.sts.forge.shade.javax')
relocate('javax', 'com.envyful.sts.forge.shade.javax')
relocate('org.reactivestreams', 'com.envyful.sts.forge.shade.reactivestreams')
relocate('reactor', 'com.envyful.sts.forge.shade.reactor')

exclude "com/google/**"
exclude "javax/**"
exclude "**/module-info.class"
exclude "**/*.properties"
exclude "**/*.xml"
Expand Down
11 changes: 8 additions & 3 deletions forge20/src/main/java/com/envyful/sts/forge/EnvySTSForge.java
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
import com.envyful.api.database.Database;
import com.envyful.api.database.impl.SimpleHikariDatabase;
import com.envyful.api.forge.command.ForgeCommandFactory;
import com.envyful.api.forge.command.parser.ForgeAnnotationCommandParser;
import com.envyful.api.forge.gui.factory.ForgeGuiFactory;
import com.envyful.api.forge.player.ForgePlayerManager;
import com.envyful.api.gui.factory.GuiFactory;
Expand Down Expand Up @@ -33,7 +34,7 @@ public class EnvySTSForge {
private static EnvySTSForge instance;

private final ForgePlayerManager playerManager = new ForgePlayerManager();
private final ForgeCommandFactory commandFactory = new ForgeCommandFactory();
private final ForgeCommandFactory commandFactory = new ForgeCommandFactory(ForgeAnnotationCommandParser::new, playerManager);

private STSConfig config;
private STSLocale locale;
Expand All @@ -54,7 +55,7 @@ public void onServerStarting(ServerAboutToStartEvent event) {
this.playerManager.setSaveManager(new JsonSaveManager<>(this.playerManager));
}

this.playerManager.registerAttribute(this, STSAttribute.class);
this.playerManager.registerAttribute(STSAttribute.class);


if (this.config.getSaveMode() == SaveMode.MYSQL) {
Expand Down Expand Up @@ -84,7 +85,7 @@ public static void loadConfig() {
@SubscribeEvent
public void onServerStarting(RegisterCommandsEvent event) {

this.commandFactory.registerCommand(event.getDispatcher(), new STSCommand());
this.commandFactory.registerCommand(event.getDispatcher(), this.commandFactory.parseCommand(new STSCommand()));
}

public static ForgePlayerManager getPlayerManager() {
Expand All @@ -106,4 +107,8 @@ public static STSGui getGuis() {
public static Database getDatabase() {
return instance.database;
}

public static EnvySTSForge getInstance() {
return instance;
}
}
Original file line number Diff line number Diff line change
@@ -1,19 +1,16 @@
package com.envyful.sts.forge.command;

import com.envyful.api.command.annotate.Child;
import com.envyful.api.command.annotate.Command;
import com.envyful.api.command.annotate.Permissible;
import com.envyful.api.command.annotate.executor.CommandProcessor;
import com.envyful.api.command.annotate.executor.Sender;
import com.envyful.api.command.annotate.permission.Permissible;
import com.envyful.api.forge.chat.UtilChatColour;
import com.envyful.sts.forge.EnvySTSForge;
import net.minecraft.commands.CommandSource;

@Command(
value = "reload",
description = "Reloads the server configs"
value = "reload"
)
@Child
@Permissible("com.envyful.sts.command.reload")
public class ReloadCommand {

Expand Down
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
package com.envyful.sts.forge.command;

import com.envyful.api.command.annotate.Command;
import com.envyful.api.command.annotate.Permissible;
import com.envyful.api.command.annotate.SubCommands;
import com.envyful.api.command.annotate.executor.CommandProcessor;
import com.envyful.api.command.annotate.executor.Sender;
import com.envyful.api.command.annotate.permission.Permissible;
import com.envyful.api.forge.chat.UtilChatColour;
import com.envyful.api.forge.player.ForgeEnvyPlayer;
import com.envyful.sts.forge.EnvySTSForge;
Expand All @@ -14,9 +14,8 @@
import net.minecraft.server.level.ServerPlayer;

@Command(
value = "sts",
description = "Opens the STS GUI",
aliases = {
value = {
"sts",
"envysts",
"ests",
"selltoserver"
Expand All @@ -31,14 +30,14 @@ public class STSCommand {
@CommandProcessor
public void onCommand(@Sender ServerPlayer player, String[] args) {
ForgeEnvyPlayer sender = EnvySTSForge.getPlayerManager().getPlayer(player);
STSAttribute attribute = sender.getAttribute(EnvySTSForge.class);
STSAttribute attribute = sender.getAttribute(STSAttribute.class);

if (attribute.onCooldown()) {
sender.message(EnvySTSForge.getLocale().getCooldown().replace("%cooldown%", attribute.getRemainingTime()));
return;
}

if (StorageProxy.getParty(player).countAblePokemon() <= 1) {
if (StorageProxy.getPartyNow(player).countAblePokemon() <= 1) {
player.sendSystemMessage(UtilChatColour.colour(EnvySTSForge.getLocale().getMinPartySize()));
return;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -68,7 +68,7 @@ public List<PokemonSpecification> getBlacklist() {
List<PokemonSpecification> blackList = Lists.newArrayList();

for (String blacklistSpec : this.blacklistSpecs) {
blackList.add(PokemonSpecificationProxy.create(blacklistSpec));
blackList.add(PokemonSpecificationProxy.create(blacklistSpec).get());
}

this.blacklist = blackList;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,8 +10,6 @@
import com.envyful.api.type.Pair;
import com.google.common.collect.ImmutableMap;
import com.google.common.collect.Lists;
import com.google.common.collect.Maps;
import org.lwjgl.system.CallbackI;
import org.spongepowered.configurate.objectmapping.ConfigSerializable;

import java.util.List;
Expand Down Expand Up @@ -53,6 +51,7 @@ public static class PartyUI {
.amount(1)
.name("&a&lCONFIRM")
.positions(Pair.of(4, 2))
.nbt("PokeBallID", new ConfigItem.NBTValue("string", "poke_ball"))
.build();

private ConfigItem noPokemonItem = ConfigItem.builder()
Expand Down Expand Up @@ -121,7 +120,7 @@ public ExtendedConfigItem getPcItem() {
@ConfigSerializable
public static class PcUI {

private PaginatedConfigInterface guiSettings = PaginatedConfigInterface.builder()
private PaginatedConfigInterface guiSettings = PaginatedConfigInterface.paginatedBuilder()
.title("Bulk Sell PC")
.height(6)
.displayPageButtonsAtLimits()
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
package com.envyful.sts.forge.player;

import com.envyful.api.forge.player.ForgePlayerManager;
import com.envyful.api.forge.player.attribute.AbstractForgeAttribute;
import com.envyful.api.forge.player.attribute.ManagedForgeAttribute;
import com.envyful.api.player.save.attribute.DataDirectory;
import com.envyful.api.time.UtilTimeFormat;
import com.envyful.sts.forge.EnvySTSForge;
Expand All @@ -15,14 +15,14 @@
import java.util.concurrent.TimeUnit;

@DataDirectory("config/players/EnvySTS/")
public class STSAttribute extends AbstractForgeAttribute<EnvySTSForge> {
public class STSAttribute extends ManagedForgeAttribute<EnvySTSForge> {

private transient int selectedSlot = -1;

private long lastUse = -1L;

public STSAttribute(EnvySTSForge manager, ForgePlayerManager playerManager) {
super(manager, playerManager);
public STSAttribute(ForgePlayerManager playerManager) {
super(EnvySTSForge.getInstance(), playerManager);
}

public int getSelectedSlot() {
Expand Down
19 changes: 10 additions & 9 deletions forge20/src/main/java/com/envyful/sts/forge/ui/STSPartyUI.java
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@
import com.pixelmonmod.pixelmon.api.pokemon.Pokemon;
import com.pixelmonmod.pixelmon.api.storage.PlayerPartyStorage;
import com.pixelmonmod.pixelmon.api.storage.StorageProxy;
import net.minecraft.network.chat.Component;
import net.minecraft.server.level.ServerPlayer;
import net.minecraft.world.item.enchantment.Enchantments;

Expand All @@ -37,8 +38,8 @@ private STSPartyUI() {

public static void open(ForgeEnvyPlayer player) {
STSGui.PartyUI config = EnvySTSForge.getGuis().getPartyUI();
STSAttribute attribute = player.getAttribute(EnvySTSForge.class);
PlayerPartyStorage party = StorageProxy.getParty(player.getParent());
STSAttribute attribute = player.getAttribute(STSAttribute.class);
PlayerPartyStorage party = StorageProxy.getPartyNow(player.getParent());

Pane pane = GuiFactory.paneBuilder()
.topLeftX(0)
Expand Down Expand Up @@ -98,7 +99,7 @@ public static void open(ForgeEnvyPlayer player) {
attribute.setSelectedSlot(-1);
attribute.setLastUse(System.currentTimeMillis());

BankAccount bank = BankAccountProxy.getBankAccountUnsafe(player.getParent());
BankAccount bank = BankAccountProxy.getBankAccountNow(player.getParent());
bank.add((int)worth);

player.message(UtilChatColour.colour(
Expand All @@ -119,7 +120,7 @@ public static void open(ForgeEnvyPlayer player) {
}

private static void setPokemon(ForgeEnvyPlayer player, Pane pane) {
PlayerPartyStorage party = StorageProxy.getParty(player.getParent());
PlayerPartyStorage party = StorageProxy.getPartyNow(player.getParent());
Pokemon[] all = party.getAll();
STSGui.PartyUI config = EnvySTSForge.getGuis().getPartyUI();

Expand Down Expand Up @@ -148,7 +149,7 @@ private static void setPokemon(ForgeEnvyPlayer player, Pane pane) {
EnvySTSForge.getGuis().getPartyUI().getSpriteConfig()
)).addLore(getPriceLore(player.getParent(), config, worth, all[slot], Lists.newArrayList(EnvySTSForge.getConfig().getMinPriceModifiers().values()))).build())
.clickHandler((envyPlayer, clickType) -> {
STSAttribute attribute = envyPlayer.getAttribute(EnvySTSForge.class);
STSAttribute attribute = envyPlayer.getAttribute(STSAttribute.class);
attribute.setSelectedSlot(slot);
pane.set(config.getConfirmDisplay() % 9, config.getConfirmDisplay() / 9,
GuiFactory.displayableBuilder(new ItemBuilder(UtilSprite.getPokemonElement(
Expand All @@ -166,15 +167,15 @@ private static void setPokemon(ForgeEnvyPlayer player, Pane pane) {
}
}

private static String[] getPriceLore(ServerPlayer player, STSGui.PartyUI config, double worth, Pokemon pokemon, List<DisplayablePokeSpecPricing> pricing) {
private static Component[] getPriceLore(ServerPlayer player, STSGui.PartyUI config, double worth, Pokemon pokemon, List<DisplayablePokeSpecPricing> pricing) {
List<String> lore = config.getPriceLore();
lore = PlaceholderFactory.handlePlaceholders(lore, new PriceBreakdownPlaceholder(player, pokemon, pricing));
List<String> newLore = Lists.newArrayList();
List<Component> newLore = Lists.newArrayList();

for (String s : lore) {
newLore.add(UtilChatColour.translateColourCodes('&', s.replace("%cost%", String.format(EnvySTSForge.getLocale().getEconomyFormat(), worth))));
newLore.add(UtilChatColour.colour(s.replace("%cost%", String.format(EnvySTSForge.getLocale().getEconomyFormat(), worth))));
}

return newLore.toArray(new String[0]);
return newLore.toArray(new Component[0]);
}
}
4 changes: 2 additions & 2 deletions forge20/src/main/resources/META-INF/mods.toml
Original file line number Diff line number Diff line change
Expand Up @@ -17,13 +17,13 @@ EnvySTS
[[dependencies.envysts]]
modId="forge"
mandatory=true
versionRange="[47.1.28,)"
versionRange="[48.0.30,)"
ordering="NONE"
side="BOTH"

[[dependencies.envysts]]
modId="minecraft"
mandatory=true
versionRange="[1.20.1,1.21)"
versionRange="[1.20.2,1.21)"
ordering="NONE"
side="BOTH"

0 comments on commit 9aeefbf

Please sign in to comment.