diff --git a/Changelog.txt b/Changelog.txt index 6cdf1d6a1..0eec68e12 100644 --- a/Changelog.txt +++ b/Changelog.txt @@ -55,8 +55,16 @@ Version 2.2.000 New Power Level Command This power level command gives you a view of all your current masteries, it also provides a summary of your power level. +Version 2.1.220 + Config files update automatically again + Default configs are now copied to plugins/mcMMO/defaults for easy reference, these configs will always match the default values of the config in the JAR + Version 2.1.219 + Fixed Fishing exploit protection being triggered inappropriately by other plugins (Thanks smudgge) Fixed wiki url being incorrect in commands + Party loading is more resilient (Thanks Wariorrrr) + Fixed periods not being replaced whe nrenaming party (Thanks Wariorrrr) + Fixed Party Teleport NPE (Thanks Wariorrrr) Added support for various new things from Minecraft 1.20 Fixed double drop issue with Beetroots Added 'Camel' to taming experience in experience.yml diff --git a/src/main/java/com/gmail/nossr50/commands/party/PartyCommand.java b/src/main/java/com/gmail/nossr50/commands/party/PartyCommand.java index f3523445c..752552747 100644 --- a/src/main/java/com/gmail/nossr50/commands/party/PartyCommand.java +++ b/src/main/java/com/gmail/nossr50/commands/party/PartyCommand.java @@ -200,15 +200,19 @@ public class PartyCommand implements TabExecutor { if (matches.size() == 0) { Player player = (Player) sender; + final McMMOPlayer mcMMOPlayer = UserManager.getPlayer(player); //Not Loaded - if(UserManager.getPlayer(player) == null) + if(mcMMOPlayer == null) { sender.sendMessage(LocaleLoader.getString("Profile.PendingLoad")); return ImmutableList.of(); } - Party party = UserManager.getPlayer(player).getParty(); + if (mcMMOPlayer.getParty() == null) + return ImmutableList.of(); + + final Party party = mcMMOPlayer.getParty(); playerNames = party.getOnlinePlayerNames(player); return StringUtil.copyPartialMatches(args[1], playerNames, new ArrayList<>(playerNames.size())); diff --git a/src/main/java/com/gmail/nossr50/commands/party/PartyRenameCommand.java b/src/main/java/com/gmail/nossr50/commands/party/PartyRenameCommand.java index 2ab6f0621..29e35cd4a 100644 --- a/src/main/java/com/gmail/nossr50/commands/party/PartyRenameCommand.java +++ b/src/main/java/com/gmail/nossr50/commands/party/PartyRenameCommand.java @@ -25,7 +25,7 @@ public class PartyRenameCommand implements CommandExecutor { Party playerParty = mcMMOPlayer.getParty(); String oldPartyName = playerParty.getName(); - String newPartyName = args[1]; + String newPartyName = args[1].replace(".", ""); // This is to prevent party leaders from spamming other players with the rename message if (oldPartyName.equalsIgnoreCase(newPartyName)) { diff --git a/src/main/java/com/gmail/nossr50/config/AutoUpdateConfigLoader.java b/src/main/java/com/gmail/nossr50/config/AutoUpdateLegacyConfigLoader.java similarity index 88% rename from src/main/java/com/gmail/nossr50/config/AutoUpdateConfigLoader.java rename to src/main/java/com/gmail/nossr50/config/AutoUpdateLegacyConfigLoader.java index 710534e36..b021a7bac 100644 --- a/src/main/java/com/gmail/nossr50/config/AutoUpdateConfigLoader.java +++ b/src/main/java/com/gmail/nossr50/config/AutoUpdateLegacyConfigLoader.java @@ -10,22 +10,22 @@ import java.io.IOException; import java.util.HashSet; import java.util.Set; -public abstract class AutoUpdateConfigLoader extends ConfigLoader { - public AutoUpdateConfigLoader(String relativePath, String fileName, File dataFolder) { +public abstract class AutoUpdateLegacyConfigLoader extends LegacyConfigLoader { + public AutoUpdateLegacyConfigLoader(String relativePath, String fileName, File dataFolder) { super(relativePath, fileName, dataFolder); } - public AutoUpdateConfigLoader(String fileName, File dataFolder) { + public AutoUpdateLegacyConfigLoader(String fileName, File dataFolder) { super(fileName, dataFolder); } @Deprecated - public AutoUpdateConfigLoader(String relativePath, String fileName) { + public AutoUpdateLegacyConfigLoader(String relativePath, String fileName) { super(relativePath, fileName); } @Deprecated - public AutoUpdateConfigLoader(String fileName) { + public AutoUpdateLegacyConfigLoader(String fileName) { super(fileName); } diff --git a/src/main/java/com/gmail/nossr50/config/BukkitConfig.java b/src/main/java/com/gmail/nossr50/config/BukkitConfig.java index 4a0f02e69..35c598e36 100644 --- a/src/main/java/com/gmail/nossr50/config/BukkitConfig.java +++ b/src/main/java/com/gmail/nossr50/config/BukkitConfig.java @@ -19,17 +19,7 @@ public abstract class BukkitConfig { protected YamlConfiguration defaultYamlConfig; protected YamlConfiguration config; protected @NotNull final File dataFolder; - - public BukkitConfig(@NotNull String fileName, @NotNull File dataFolder) { - mcMMO.p.getLogger().info("[config] Initializing config: " + fileName); - this.fileName = fileName; - this.dataFolder = dataFolder; - configFile = new File(dataFolder, fileName); - this.defaultYamlConfig = copyDefaultConfig(); - this.config = initConfig(); - updateFile(); - mcMMO.p.getLogger().info("[config] Config initialized: " + fileName); - } + private boolean savedDefaults = false; public BukkitConfig(@NotNull String fileName, @NotNull File dataFolder, boolean copyDefaults) { mcMMO.p.getLogger().info("[config] Initializing config: " + fileName); @@ -37,12 +27,16 @@ public abstract class BukkitConfig { this.fileName = fileName; this.dataFolder = dataFolder; configFile = new File(dataFolder, fileName); - this.defaultYamlConfig = copyDefaultConfig(); + this.defaultYamlConfig = saveDefaultConfigToDisk(); this.config = initConfig(); updateFile(); mcMMO.p.getLogger().info("[config] Config initialized: " + fileName); } + public BukkitConfig(@NotNull String fileName, @NotNull File dataFolder) { + this(fileName, dataFolder, true); + } + public BukkitConfig(@NotNull String fileName) { this(fileName, mcMMO.p.getDataFolder()); } @@ -55,10 +49,12 @@ public abstract class BukkitConfig { */ public void updateFile() { try { - if(copyDefaults) { - copyMissingDefaultsFromResource(); - } config.save(configFile); + + if(copyDefaults && !savedDefaults) { + copyMissingDefaultsFromResource(); + savedDefaults = true; + } } catch (IOException e) { e.printStackTrace(); } @@ -84,7 +80,7 @@ public abstract class BukkitConfig { /** * Copies the config from the JAR to defaults/ */ - YamlConfiguration copyDefaultConfig() { + YamlConfiguration saveDefaultConfigToDisk() { mcMMO.p.getLogger().info("[config] Copying default config to disk: " + fileName + " to defaults/" + fileName); try(InputStream inputStream = mcMMO.p.getResource(fileName)) { if(inputStream == null) { diff --git a/src/main/java/com/gmail/nossr50/config/ConfigLoader.java b/src/main/java/com/gmail/nossr50/config/LegacyConfigLoader.java similarity index 89% rename from src/main/java/com/gmail/nossr50/config/ConfigLoader.java rename to src/main/java/com/gmail/nossr50/config/LegacyConfigLoader.java index 972bd697e..ebd82c237 100644 --- a/src/main/java/com/gmail/nossr50/config/ConfigLoader.java +++ b/src/main/java/com/gmail/nossr50/config/LegacyConfigLoader.java @@ -7,20 +7,21 @@ import org.jetbrains.annotations.NotNull; import java.io.File; import java.util.List; -public abstract class ConfigLoader { +@Deprecated +public abstract class LegacyConfigLoader { protected final File configFile; protected final @NotNull File dataFolder; protected String fileName; protected YamlConfiguration config; - public ConfigLoader(String relativePath, String fileName, @NotNull File dataFolder) { + public LegacyConfigLoader(String relativePath, String fileName, @NotNull File dataFolder) { this.fileName = fileName; this.dataFolder = dataFolder; configFile = new File(dataFolder, relativePath + File.separator + fileName); loadFile(); } - public ConfigLoader(String fileName, @NotNull File dataFolder) { + public LegacyConfigLoader(String fileName, @NotNull File dataFolder) { this.fileName = fileName; this.dataFolder = dataFolder; configFile = new File(dataFolder, fileName); @@ -28,7 +29,7 @@ public abstract class ConfigLoader { } @Deprecated - public ConfigLoader(String relativePath, String fileName) { + public LegacyConfigLoader(String relativePath, String fileName) { this.fileName = fileName; configFile = new File(mcMMO.p.getDataFolder(), relativePath + File.separator + fileName); this.dataFolder = mcMMO.p.getDataFolder(); @@ -36,7 +37,7 @@ public abstract class ConfigLoader { } @Deprecated - public ConfigLoader(String fileName) { + public LegacyConfigLoader(String fileName) { this.fileName = fileName; configFile = new File(mcMMO.p.getDataFolder(), fileName); this.dataFolder = mcMMO.p.getDataFolder(); diff --git a/src/main/java/com/gmail/nossr50/config/RankConfig.java b/src/main/java/com/gmail/nossr50/config/RankConfig.java index 003b27a4d..6b125c204 100644 --- a/src/main/java/com/gmail/nossr50/config/RankConfig.java +++ b/src/main/java/com/gmail/nossr50/config/RankConfig.java @@ -9,7 +9,7 @@ import java.util.ArrayList; import java.util.HashSet; import java.util.List; -public class RankConfig extends AutoUpdateConfigLoader { +public class RankConfig extends BukkitConfig { private static RankConfig instance; public RankConfig() { @@ -66,7 +66,7 @@ public class RankConfig extends AutoUpdateConfigLoader { */ public int getSubSkillUnlockLevel(SubSkillType subSkillType, int rank, boolean retroMode) { String key = getRankAddressKey(subSkillType, rank, retroMode); - return config.getInt(key, getInternalConfig().getInt(key)); + return config.getInt(key, defaultYamlConfig.getInt(key)); } /** @@ -128,7 +128,7 @@ public class RankConfig extends AutoUpdateConfigLoader { private void resetRankValue(@NotNull SubSkillType subSkillType, int rank, boolean retroMode) { String key = getRankAddressKey(subSkillType, rank, retroMode); - int defaultValue = getInternalConfig().getInt(key); + int defaultValue = defaultYamlConfig.getInt(key); config.set(key, defaultValue); mcMMO.p.getLogger().info(key + " SET -> " + defaultValue); } diff --git a/src/main/java/com/gmail/nossr50/config/mods/ArmorConfigManager.java b/src/main/java/com/gmail/nossr50/config/mods/ArmorConfigManager.java index 95f979e59..66d220d9a 100644 --- a/src/main/java/com/gmail/nossr50/config/mods/ArmorConfigManager.java +++ b/src/main/java/com/gmail/nossr50/config/mods/ArmorConfigManager.java @@ -29,7 +29,7 @@ public class ArmorConfigManager { continue; } - modManager.registerCustomArmor(new CustomArmorConfig(fileName)); + modManager.registerCustomArmor(new CustomArmorLegacyConfig(fileName)); } } } diff --git a/src/main/java/com/gmail/nossr50/config/mods/BlockConfigManager.java b/src/main/java/com/gmail/nossr50/config/mods/BlockConfigManager.java index 2b3c397ff..c6df0a1a0 100644 --- a/src/main/java/com/gmail/nossr50/config/mods/BlockConfigManager.java +++ b/src/main/java/com/gmail/nossr50/config/mods/BlockConfigManager.java @@ -29,7 +29,7 @@ public class BlockConfigManager { continue; } - modManager.registerCustomBlocks(new CustomBlockConfig(fileName)); + modManager.registerCustomBlocks(new CustomBlockLegacyConfig(fileName)); } } } diff --git a/src/main/java/com/gmail/nossr50/config/mods/CustomArmorConfig.java b/src/main/java/com/gmail/nossr50/config/mods/CustomArmorLegacyConfig.java similarity index 95% rename from src/main/java/com/gmail/nossr50/config/mods/CustomArmorConfig.java rename to src/main/java/com/gmail/nossr50/config/mods/CustomArmorLegacyConfig.java index 0d456b588..1369d3026 100644 --- a/src/main/java/com/gmail/nossr50/config/mods/CustomArmorConfig.java +++ b/src/main/java/com/gmail/nossr50/config/mods/CustomArmorLegacyConfig.java @@ -1,6 +1,6 @@ package com.gmail.nossr50.config.mods; -import com.gmail.nossr50.config.ConfigLoader; +import com.gmail.nossr50.config.LegacyConfigLoader; import com.gmail.nossr50.datatypes.skills.ItemType; import com.gmail.nossr50.datatypes.skills.MaterialType; import com.gmail.nossr50.mcMMO; @@ -13,7 +13,7 @@ import java.util.ArrayList; import java.util.List; import java.util.Set; -public class CustomArmorConfig extends ConfigLoader { +public class CustomArmorLegacyConfig extends LegacyConfigLoader { public List customBoots = new ArrayList<>(); public List customChestplates = new ArrayList<>(); public List customHelmets = new ArrayList<>(); @@ -21,7 +21,7 @@ public class CustomArmorConfig extends ConfigLoader { public List repairables = new ArrayList<>(); private boolean needsUpdate = false; - protected CustomArmorConfig(String fileName) { + protected CustomArmorLegacyConfig(String fileName) { super("mods", fileName); loadKeys(); } diff --git a/src/main/java/com/gmail/nossr50/config/mods/CustomBlockConfig.java b/src/main/java/com/gmail/nossr50/config/mods/CustomBlockLegacyConfig.java similarity index 94% rename from src/main/java/com/gmail/nossr50/config/mods/CustomBlockConfig.java rename to src/main/java/com/gmail/nossr50/config/mods/CustomBlockLegacyConfig.java index 3d96ba7f9..4be1ef44a 100644 --- a/src/main/java/com/gmail/nossr50/config/mods/CustomBlockConfig.java +++ b/src/main/java/com/gmail/nossr50/config/mods/CustomBlockLegacyConfig.java @@ -1,6 +1,6 @@ package com.gmail.nossr50.config.mods; -import com.gmail.nossr50.config.ConfigLoader; +import com.gmail.nossr50.config.LegacyConfigLoader; import com.gmail.nossr50.datatypes.mods.CustomBlock; import com.gmail.nossr50.mcMMO; import org.bukkit.Material; @@ -11,7 +11,7 @@ import java.util.HashMap; import java.util.List; import java.util.Set; -public class CustomBlockConfig extends ConfigLoader { +public class CustomBlockLegacyConfig extends LegacyConfigLoader { public List customExcavationBlocks = new ArrayList<>(); public List customHerbalismBlocks = new ArrayList<>(); public List customMiningBlocks = new ArrayList<>(); @@ -22,7 +22,7 @@ public class CustomBlockConfig extends ConfigLoader { public HashMap customBlockMap = new HashMap<>(); private boolean needsUpdate = false; - protected CustomBlockConfig(String fileName) { + protected CustomBlockLegacyConfig(String fileName) { super("mods", fileName); loadKeys(); } diff --git a/src/main/java/com/gmail/nossr50/config/mods/CustomEntityConfig.java b/src/main/java/com/gmail/nossr50/config/mods/CustomEntityLegacyConfig.java similarity index 93% rename from src/main/java/com/gmail/nossr50/config/mods/CustomEntityConfig.java rename to src/main/java/com/gmail/nossr50/config/mods/CustomEntityLegacyConfig.java index 27cfb1fd9..37244835c 100644 --- a/src/main/java/com/gmail/nossr50/config/mods/CustomEntityConfig.java +++ b/src/main/java/com/gmail/nossr50/config/mods/CustomEntityLegacyConfig.java @@ -1,6 +1,6 @@ package com.gmail.nossr50.config.mods; -import com.gmail.nossr50.config.ConfigLoader; +import com.gmail.nossr50.config.LegacyConfigLoader; import com.gmail.nossr50.datatypes.mods.CustomEntity; import com.gmail.nossr50.mcMMO; import org.apache.commons.lang.ClassUtils; @@ -9,11 +9,11 @@ import org.bukkit.inventory.ItemStack; import java.util.HashMap; -public class CustomEntityConfig extends ConfigLoader { +public class CustomEntityLegacyConfig extends LegacyConfigLoader { public HashMap customEntityClassMap = new HashMap<>(); public HashMap customEntityTypeMap = new HashMap<>(); - protected CustomEntityConfig(String fileName) { + protected CustomEntityLegacyConfig(String fileName) { super("mods", fileName); loadKeys(); } diff --git a/src/main/java/com/gmail/nossr50/config/mods/CustomToolConfig.java b/src/main/java/com/gmail/nossr50/config/mods/CustomToolLegacyConfig.java similarity index 95% rename from src/main/java/com/gmail/nossr50/config/mods/CustomToolConfig.java rename to src/main/java/com/gmail/nossr50/config/mods/CustomToolLegacyConfig.java index 4ec07e220..ab6630cc7 100644 --- a/src/main/java/com/gmail/nossr50/config/mods/CustomToolConfig.java +++ b/src/main/java/com/gmail/nossr50/config/mods/CustomToolLegacyConfig.java @@ -1,6 +1,6 @@ package com.gmail.nossr50.config.mods; -import com.gmail.nossr50.config.ConfigLoader; +import com.gmail.nossr50.config.LegacyConfigLoader; import com.gmail.nossr50.datatypes.mods.CustomTool; import com.gmail.nossr50.datatypes.skills.ItemType; import com.gmail.nossr50.datatypes.skills.MaterialType; @@ -15,7 +15,7 @@ import java.util.HashMap; import java.util.List; import java.util.Set; -public class CustomToolConfig extends ConfigLoader { +public class CustomToolLegacyConfig extends LegacyConfigLoader { public List customAxes = new ArrayList<>(); public List customBows = new ArrayList<>(); public List customHoes = new ArrayList<>(); @@ -26,7 +26,7 @@ public class CustomToolConfig extends ConfigLoader { public List repairables = new ArrayList<>(); private boolean needsUpdate = false; - protected CustomToolConfig(String fileName) { + protected CustomToolLegacyConfig(String fileName) { super("mods", fileName); loadKeys(); } diff --git a/src/main/java/com/gmail/nossr50/config/mods/EntityConfigManager.java b/src/main/java/com/gmail/nossr50/config/mods/EntityConfigManager.java index 1ccedadea..85977bc67 100644 --- a/src/main/java/com/gmail/nossr50/config/mods/EntityConfigManager.java +++ b/src/main/java/com/gmail/nossr50/config/mods/EntityConfigManager.java @@ -29,7 +29,7 @@ public class EntityConfigManager { continue; } - modManager.registerCustomEntities(new CustomEntityConfig(fileName)); + modManager.registerCustomEntities(new CustomEntityLegacyConfig(fileName)); } } } diff --git a/src/main/java/com/gmail/nossr50/config/mods/ToolConfigManager.java b/src/main/java/com/gmail/nossr50/config/mods/ToolConfigManager.java index 0a4873056..9b0ac1b87 100644 --- a/src/main/java/com/gmail/nossr50/config/mods/ToolConfigManager.java +++ b/src/main/java/com/gmail/nossr50/config/mods/ToolConfigManager.java @@ -29,7 +29,7 @@ public class ToolConfigManager { continue; } - modManager.registerCustomTools(new CustomToolConfig(fileName)); + modManager.registerCustomTools(new CustomToolLegacyConfig(fileName)); } } } diff --git a/src/main/java/com/gmail/nossr50/config/skills/alchemy/PotionConfig.java b/src/main/java/com/gmail/nossr50/config/skills/alchemy/PotionConfig.java index fae1b3eb8..e8dd1a41c 100644 --- a/src/main/java/com/gmail/nossr50/config/skills/alchemy/PotionConfig.java +++ b/src/main/java/com/gmail/nossr50/config/skills/alchemy/PotionConfig.java @@ -1,6 +1,6 @@ package com.gmail.nossr50.config.skills.alchemy; -import com.gmail.nossr50.config.ConfigLoader; +import com.gmail.nossr50.config.LegacyConfigLoader; import com.gmail.nossr50.datatypes.skills.alchemy.AlchemyPotion; import com.gmail.nossr50.mcMMO; import org.bukkit.ChatColor; @@ -15,7 +15,7 @@ import java.util.HashMap; import java.util.List; import java.util.Map; -public class PotionConfig extends ConfigLoader { +public class PotionConfig extends LegacyConfigLoader { private static PotionConfig instance; private final List concoctionsIngredientsTierOne = new ArrayList<>(); diff --git a/src/main/java/com/gmail/nossr50/config/skills/repair/RepairConfig.java b/src/main/java/com/gmail/nossr50/config/skills/repair/RepairConfig.java index 14dafd766..85e8c9431 100644 --- a/src/main/java/com/gmail/nossr50/config/skills/repair/RepairConfig.java +++ b/src/main/java/com/gmail/nossr50/config/skills/repair/RepairConfig.java @@ -17,8 +17,8 @@ public class RepairConfig extends BukkitConfig { private final HashSet notSupported; private List repairables; - public RepairConfig(String fileName) { - super(fileName, false); + public RepairConfig(String fileName, boolean copyDefaults) { + super(fileName, copyDefaults); notSupported = new HashSet<>(); loadKeys(); } diff --git a/src/main/java/com/gmail/nossr50/config/skills/repair/RepairConfigManager.java b/src/main/java/com/gmail/nossr50/config/skills/repair/RepairConfigManager.java index 28ba2a746..1a54906a7 100644 --- a/src/main/java/com/gmail/nossr50/config/skills/repair/RepairConfigManager.java +++ b/src/main/java/com/gmail/nossr50/config/skills/repair/RepairConfigManager.java @@ -16,7 +16,7 @@ public class RepairConfigManager { Pattern pattern = Pattern.compile("repair\\.(?:.+)\\.yml"); File dataFolder = plugin.getDataFolder(); - RepairConfig mainRepairConfig = new RepairConfig(REPAIR_VANILLA_YML); + RepairConfig mainRepairConfig = new RepairConfig(REPAIR_VANILLA_YML, true); repairables.addAll(mainRepairConfig.getLoadedRepairables()); for (String fileName : dataFolder.list()) { @@ -33,7 +33,7 @@ public class RepairConfigManager { continue; } - RepairConfig rConfig = new RepairConfig(fileName); + RepairConfig rConfig = new RepairConfig(fileName, false); repairables.addAll(rConfig.getLoadedRepairables()); } } diff --git a/src/main/java/com/gmail/nossr50/config/skills/salvage/SalvageConfig.java b/src/main/java/com/gmail/nossr50/config/skills/salvage/SalvageConfig.java index c8700274d..0900cebcc 100644 --- a/src/main/java/com/gmail/nossr50/config/skills/salvage/SalvageConfig.java +++ b/src/main/java/com/gmail/nossr50/config/skills/salvage/SalvageConfig.java @@ -20,8 +20,8 @@ public class SalvageConfig extends BukkitConfig { private final HashSet notSupported; private Set salvageables; - public SalvageConfig(String fileName) { - super(fileName); + public SalvageConfig(String fileName, boolean copyDefaults) { + super(fileName, copyDefaults); notSupported = new HashSet<>(); loadKeys(); } diff --git a/src/main/java/com/gmail/nossr50/config/skills/salvage/SalvageConfigManager.java b/src/main/java/com/gmail/nossr50/config/skills/salvage/SalvageConfigManager.java index 1e6617034..77348e8d3 100644 --- a/src/main/java/com/gmail/nossr50/config/skills/salvage/SalvageConfigManager.java +++ b/src/main/java/com/gmail/nossr50/config/skills/salvage/SalvageConfigManager.java @@ -17,7 +17,7 @@ public class SalvageConfigManager { Pattern pattern = Pattern.compile("salvage\\.(?:.+)\\.yml"); File dataFolder = plugin.getDataFolder(); - SalvageConfig mainSalvageConfig = new SalvageConfig(SALVAGE_VANILLA_YML); + SalvageConfig mainSalvageConfig = new SalvageConfig(SALVAGE_VANILLA_YML, true); salvageables.addAll(mainSalvageConfig.getLoadedSalvageables()); for (String fileName : dataFolder.list()) { @@ -34,7 +34,7 @@ public class SalvageConfigManager { continue; } - SalvageConfig salvageConfig = new SalvageConfig(fileName); + SalvageConfig salvageConfig = new SalvageConfig(fileName, false); salvageables.addAll(salvageConfig.getLoadedSalvageables()); } } diff --git a/src/main/java/com/gmail/nossr50/listeners/PlayerListener.java b/src/main/java/com/gmail/nossr50/listeners/PlayerListener.java index fb906ad1d..3a3900dd4 100644 --- a/src/main/java/com/gmail/nossr50/listeners/PlayerListener.java +++ b/src/main/java/com/gmail/nossr50/listeners/PlayerListener.java @@ -450,6 +450,9 @@ public class PlayerListener implements Listener { case CAUGHT_FISH: if(caught instanceof Item) { if(ExperienceConfig.getInstance().isFishingExploitingPrevented()) { + + fishingManager.processExploiting(event.getHook().getLocation().toVector()); + if (fishingManager.isExploitingFishing(event.getHook().getLocation().toVector())) { player.sendMessage(LocaleLoader.getString("Fishing.ScarcityTip", ExperienceConfig.getInstance().getFishingExploitingOptionMoveRange())); event.setExpToDrop(0); diff --git a/src/main/java/com/gmail/nossr50/party/PartyManager.java b/src/main/java/com/gmail/nossr50/party/PartyManager.java index 16965629f..c723dbd50 100644 --- a/src/main/java/com/gmail/nossr50/party/PartyManager.java +++ b/src/main/java/com/gmail/nossr50/party/PartyManager.java @@ -28,6 +28,7 @@ import java.util.LinkedHashMap; import java.util.List; import java.util.Map.Entry; import java.util.UUID; +import java.util.logging.Level; public final class PartyManager { private static final String partiesFilePath = mcMMO.getFlatFileDirectory() + "parties.yml"; @@ -609,34 +610,38 @@ public final class PartyManager { ArrayList hasAlly = new ArrayList<>(); for (String partyName : partiesFile.getConfigurationSection("").getKeys(false)) { - Party party = new Party(partyName); + try { + Party party = new Party(partyName); - String[] leaderSplit = partiesFile.getString(partyName + ".Leader").split("[|]"); - party.setLeader(new PartyLeader(UUID.fromString(leaderSplit[0]), leaderSplit[1])); - party.setPassword(partiesFile.getString(partyName + ".Password")); - party.setLocked(partiesFile.getBoolean(partyName + ".Locked")); - party.setLevel(partiesFile.getInt(partyName + ".Level")); - party.setXp(partiesFile.getInt(partyName + ".Xp")); + String[] leaderSplit = partiesFile.getString(partyName + ".Leader").split("[|]"); + party.setLeader(new PartyLeader(UUID.fromString(leaderSplit[0]), leaderSplit[1])); + party.setPassword(partiesFile.getString(partyName + ".Password")); + party.setLocked(partiesFile.getBoolean(partyName + ".Locked")); + party.setLevel(partiesFile.getInt(partyName + ".Level")); + party.setXp(partiesFile.getInt(partyName + ".Xp")); - if (partiesFile.getString(partyName + ".Ally") != null) { - hasAlly.add(party); + if (partiesFile.getString(partyName + ".Ally") != null) { + hasAlly.add(party); + } + + party.setXpShareMode(ShareMode.getShareMode(partiesFile.getString(partyName + ".ExpShareMode", "NONE"))); + party.setItemShareMode(ShareMode.getShareMode(partiesFile.getString(partyName + ".ItemShareMode", "NONE"))); + + for (ItemShareType itemShareType : ItemShareType.values()) { + party.setSharingDrops(itemShareType, partiesFile.getBoolean(partyName + ".ItemShareType." + itemShareType.toString(), true)); + } + + LinkedHashMap members = party.getMembers(); + + for (String memberEntry : partiesFile.getStringList(partyName + ".Members")) { + String[] memberSplit = memberEntry.split("[|]"); + members.put(UUID.fromString(memberSplit[0]), memberSplit[1]); + } + + parties.add(party); + } catch (Exception e) { + mcMMO.p.getLogger().log(Level.WARNING, "An exception occurred while loading a party with name '" + partyName + "'. Skipped loading party.", e); } - - party.setXpShareMode(ShareMode.getShareMode(partiesFile.getString(partyName + ".ExpShareMode", "NONE"))); - party.setItemShareMode(ShareMode.getShareMode(partiesFile.getString(partyName + ".ItemShareMode", "NONE"))); - - for (ItemShareType itemShareType : ItemShareType.values()) { - party.setSharingDrops(itemShareType, partiesFile.getBoolean(partyName + ".ItemShareType." + itemShareType.toString(), true)); - } - - LinkedHashMap members = party.getMembers(); - - for (String memberEntry : partiesFile.getStringList(partyName + ".Members")) { - String[] memberSplit = memberEntry.split("[|]"); - members.put(UUID.fromString(memberSplit[0]), memberSplit[1]); - } - - parties.add(party); } mcMMO.p.debug("Loaded (" + parties.size() + ") Parties..."); diff --git a/src/main/java/com/gmail/nossr50/skills/fishing/FishingManager.java b/src/main/java/com/gmail/nossr50/skills/fishing/FishingManager.java index bc9e73c4a..fa668a6f1 100644 --- a/src/main/java/com/gmail/nossr50/skills/fishing/FishingManager.java +++ b/src/main/java/com/gmail/nossr50/skills/fishing/FishingManager.java @@ -50,6 +50,7 @@ public class FishingManager extends SkillManager { private long lastWarnedExhaust = 0L; private FishHook fishHookReference; private BoundingBox lastFishingBoundingBox; + private boolean sameTarget; private Item fishingCatch; private Location hookLocation; private int fishCaughtCounter = 1; @@ -127,6 +128,25 @@ public class FishingManager extends SkillManager { return hasFished; } + public void processExploiting(Vector centerOfCastVector) { + BoundingBox newCastBoundingBox = makeBoundingBox(centerOfCastVector); + this.sameTarget = lastFishingBoundingBox != null && lastFishingBoundingBox.overlaps(newCastBoundingBox); + + if (this.sameTarget) { + fishCaughtCounter++; + } + else { + fishCaughtCounter = 1; + } + + //If the new bounding box does not intersect with the old one, then update our bounding box reference + if (!this.sameTarget) lastFishingBoundingBox = newCastBoundingBox; + + if (fishCaughtCounter + 1 == ExperienceConfig.getInstance().getFishingExploitingOptionOverFishLimit()) { + getPlayer().sendMessage(LocaleLoader.getString("Fishing.LowResourcesTip", ExperienceConfig.getInstance().getFishingExploitingOptionMoveRange())); + } + } + public boolean isExploitingFishing(Vector centerOfCastVector) { /*Block targetBlock = getPlayer().getTargetBlock(BlockUtils.getTransparentBlocks(), 100); @@ -135,25 +155,7 @@ public class FishingManager extends SkillManager { return false; }*/ - BoundingBox newCastBoundingBox = makeBoundingBox(centerOfCastVector); - - boolean sameTarget = lastFishingBoundingBox != null && lastFishingBoundingBox.overlaps(newCastBoundingBox); - - if(sameTarget) - fishCaughtCounter++; - else - fishCaughtCounter = 1; - - if(fishCaughtCounter + 1 == ExperienceConfig.getInstance().getFishingExploitingOptionOverFishLimit()) - { - getPlayer().sendMessage(LocaleLoader.getString("Fishing.LowResourcesTip", ExperienceConfig.getInstance().getFishingExploitingOptionMoveRange())); - } - - //If the new bounding box does not intersect with the old one, then update our bounding box reference - if(!sameTarget) - lastFishingBoundingBox = newCastBoundingBox; - - return sameTarget && fishCaughtCounter >= ExperienceConfig.getInstance().getFishingExploitingOptionOverFishLimit(); + return this.sameTarget && fishCaughtCounter >= ExperienceConfig.getInstance().getFishingExploitingOptionOverFishLimit(); } public static BoundingBox makeBoundingBox(Vector centerOfCastVector) { diff --git a/src/main/java/com/gmail/nossr50/util/ModManager.java b/src/main/java/com/gmail/nossr50/util/ModManager.java index 62646466a..4ec27d192 100644 --- a/src/main/java/com/gmail/nossr50/util/ModManager.java +++ b/src/main/java/com/gmail/nossr50/util/ModManager.java @@ -1,9 +1,9 @@ package com.gmail.nossr50.util; -import com.gmail.nossr50.config.mods.CustomArmorConfig; -import com.gmail.nossr50.config.mods.CustomBlockConfig; -import com.gmail.nossr50.config.mods.CustomEntityConfig; -import com.gmail.nossr50.config.mods.CustomToolConfig; +import com.gmail.nossr50.config.mods.CustomArmorLegacyConfig; +import com.gmail.nossr50.config.mods.CustomBlockLegacyConfig; +import com.gmail.nossr50.config.mods.CustomEntityLegacyConfig; +import com.gmail.nossr50.config.mods.CustomToolLegacyConfig; import com.gmail.nossr50.datatypes.mods.CustomBlock; import com.gmail.nossr50.datatypes.mods.CustomEntity; import com.gmail.nossr50.datatypes.mods.CustomTool; @@ -52,7 +52,7 @@ public class ModManager { private final List customSwords = new ArrayList<>(); private final HashMap customToolMap = new HashMap<>(); - public void registerCustomArmor(CustomArmorConfig config) { + public void registerCustomArmor(CustomArmorLegacyConfig config) { customBoots.addAll(config.customBoots); customChestplates.addAll(config.customChestplates); customHelmets.addAll(config.customHelmets); @@ -60,7 +60,7 @@ public class ModManager { repairables.addAll(config.repairables); } - public void registerCustomBlocks(CustomBlockConfig config) { + public void registerCustomBlocks(CustomBlockLegacyConfig config) { customExcavationBlocks.addAll(config.customExcavationBlocks); customHerbalismBlocks.addAll(config.customHerbalismBlocks); customMiningBlocks.addAll(config.customMiningBlocks); @@ -71,12 +71,12 @@ public class ModManager { customBlockMap.putAll(config.customBlockMap); } - public void registerCustomEntities(CustomEntityConfig config) { + public void registerCustomEntities(CustomEntityLegacyConfig config) { customEntityClassMap.putAll(config.customEntityClassMap); customEntityTypeMap.putAll(config.customEntityTypeMap); } - public void registerCustomTools(CustomToolConfig config) { + public void registerCustomTools(CustomToolLegacyConfig config) { customAxes.addAll(config.customAxes); customBows.addAll(config.customBows); customHoes.addAll(config.customHoes);