Pull master

This commit is contained in:
nossr50 2023-04-17 12:16:06 -07:00
commit f88dfe479e
24 changed files with 129 additions and 110 deletions

View File

@ -55,8 +55,16 @@ Version 2.2.000
New Power Level Command 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. 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 Version 2.1.219
Fixed Fishing exploit protection being triggered inappropriately by other plugins (Thanks smudgge)
Fixed wiki url being incorrect in commands 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 Added support for various new things from Minecraft 1.20
Fixed double drop issue with Beetroots Fixed double drop issue with Beetroots
Added 'Camel' to taming experience in experience.yml Added 'Camel' to taming experience in experience.yml

View File

@ -200,15 +200,19 @@ public class PartyCommand implements TabExecutor {
if (matches.size() == 0) { if (matches.size() == 0) {
Player player = (Player) sender; Player player = (Player) sender;
final McMMOPlayer mcMMOPlayer = UserManager.getPlayer(player);
//Not Loaded //Not Loaded
if(UserManager.getPlayer(player) == null) if(mcMMOPlayer == null)
{ {
sender.sendMessage(LocaleLoader.getString("Profile.PendingLoad")); sender.sendMessage(LocaleLoader.getString("Profile.PendingLoad"));
return ImmutableList.of(); 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); playerNames = party.getOnlinePlayerNames(player);
return StringUtil.copyPartialMatches(args[1], playerNames, new ArrayList<>(playerNames.size())); return StringUtil.copyPartialMatches(args[1], playerNames, new ArrayList<>(playerNames.size()));

View File

@ -25,7 +25,7 @@ public class PartyRenameCommand implements CommandExecutor {
Party playerParty = mcMMOPlayer.getParty(); Party playerParty = mcMMOPlayer.getParty();
String oldPartyName = playerParty.getName(); 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 // This is to prevent party leaders from spamming other players with the rename message
if (oldPartyName.equalsIgnoreCase(newPartyName)) { if (oldPartyName.equalsIgnoreCase(newPartyName)) {

View File

@ -10,22 +10,22 @@ import java.io.IOException;
import java.util.HashSet; import java.util.HashSet;
import java.util.Set; import java.util.Set;
public abstract class AutoUpdateConfigLoader extends ConfigLoader { public abstract class AutoUpdateLegacyConfigLoader extends LegacyConfigLoader {
public AutoUpdateConfigLoader(String relativePath, String fileName, File dataFolder) { public AutoUpdateLegacyConfigLoader(String relativePath, String fileName, File dataFolder) {
super(relativePath, fileName, dataFolder); super(relativePath, fileName, dataFolder);
} }
public AutoUpdateConfigLoader(String fileName, File dataFolder) { public AutoUpdateLegacyConfigLoader(String fileName, File dataFolder) {
super(fileName, dataFolder); super(fileName, dataFolder);
} }
@Deprecated @Deprecated
public AutoUpdateConfigLoader(String relativePath, String fileName) { public AutoUpdateLegacyConfigLoader(String relativePath, String fileName) {
super(relativePath, fileName); super(relativePath, fileName);
} }
@Deprecated @Deprecated
public AutoUpdateConfigLoader(String fileName) { public AutoUpdateLegacyConfigLoader(String fileName) {
super(fileName); super(fileName);
} }

View File

@ -19,17 +19,7 @@ public abstract class BukkitConfig {
protected YamlConfiguration defaultYamlConfig; protected YamlConfiguration defaultYamlConfig;
protected YamlConfiguration config; protected YamlConfiguration config;
protected @NotNull final File dataFolder; protected @NotNull final File dataFolder;
private boolean savedDefaults = false;
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);
}
public BukkitConfig(@NotNull String fileName, @NotNull File dataFolder, boolean copyDefaults) { public BukkitConfig(@NotNull String fileName, @NotNull File dataFolder, boolean copyDefaults) {
mcMMO.p.getLogger().info("[config] Initializing config: " + fileName); mcMMO.p.getLogger().info("[config] Initializing config: " + fileName);
@ -37,12 +27,16 @@ public abstract class BukkitConfig {
this.fileName = fileName; this.fileName = fileName;
this.dataFolder = dataFolder; this.dataFolder = dataFolder;
configFile = new File(dataFolder, fileName); configFile = new File(dataFolder, fileName);
this.defaultYamlConfig = copyDefaultConfig(); this.defaultYamlConfig = saveDefaultConfigToDisk();
this.config = initConfig(); this.config = initConfig();
updateFile(); updateFile();
mcMMO.p.getLogger().info("[config] Config initialized: " + fileName); 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) { public BukkitConfig(@NotNull String fileName) {
this(fileName, mcMMO.p.getDataFolder()); this(fileName, mcMMO.p.getDataFolder());
} }
@ -55,10 +49,12 @@ public abstract class BukkitConfig {
*/ */
public void updateFile() { public void updateFile() {
try { try {
if(copyDefaults) {
copyMissingDefaultsFromResource();
}
config.save(configFile); config.save(configFile);
if(copyDefaults && !savedDefaults) {
copyMissingDefaultsFromResource();
savedDefaults = true;
}
} catch (IOException e) { } catch (IOException e) {
e.printStackTrace(); e.printStackTrace();
} }
@ -84,7 +80,7 @@ public abstract class BukkitConfig {
/** /**
* Copies the config from the JAR to defaults/<fileName> * Copies the config from the JAR to defaults/<fileName>
*/ */
YamlConfiguration copyDefaultConfig() { YamlConfiguration saveDefaultConfigToDisk() {
mcMMO.p.getLogger().info("[config] Copying default config to disk: " + fileName + " to defaults/" + fileName); mcMMO.p.getLogger().info("[config] Copying default config to disk: " + fileName + " to defaults/" + fileName);
try(InputStream inputStream = mcMMO.p.getResource(fileName)) { try(InputStream inputStream = mcMMO.p.getResource(fileName)) {
if(inputStream == null) { if(inputStream == null) {

View File

@ -7,20 +7,21 @@ import org.jetbrains.annotations.NotNull;
import java.io.File; import java.io.File;
import java.util.List; import java.util.List;
public abstract class ConfigLoader { @Deprecated
public abstract class LegacyConfigLoader {
protected final File configFile; protected final File configFile;
protected final @NotNull File dataFolder; protected final @NotNull File dataFolder;
protected String fileName; protected String fileName;
protected YamlConfiguration config; 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.fileName = fileName;
this.dataFolder = dataFolder; this.dataFolder = dataFolder;
configFile = new File(dataFolder, relativePath + File.separator + fileName); configFile = new File(dataFolder, relativePath + File.separator + fileName);
loadFile(); loadFile();
} }
public ConfigLoader(String fileName, @NotNull File dataFolder) { public LegacyConfigLoader(String fileName, @NotNull File dataFolder) {
this.fileName = fileName; this.fileName = fileName;
this.dataFolder = dataFolder; this.dataFolder = dataFolder;
configFile = new File(dataFolder, fileName); configFile = new File(dataFolder, fileName);
@ -28,7 +29,7 @@ public abstract class ConfigLoader {
} }
@Deprecated @Deprecated
public ConfigLoader(String relativePath, String fileName) { public LegacyConfigLoader(String relativePath, String fileName) {
this.fileName = fileName; this.fileName = fileName;
configFile = new File(mcMMO.p.getDataFolder(), relativePath + File.separator + fileName); configFile = new File(mcMMO.p.getDataFolder(), relativePath + File.separator + fileName);
this.dataFolder = mcMMO.p.getDataFolder(); this.dataFolder = mcMMO.p.getDataFolder();
@ -36,7 +37,7 @@ public abstract class ConfigLoader {
} }
@Deprecated @Deprecated
public ConfigLoader(String fileName) { public LegacyConfigLoader(String fileName) {
this.fileName = fileName; this.fileName = fileName;
configFile = new File(mcMMO.p.getDataFolder(), fileName); configFile = new File(mcMMO.p.getDataFolder(), fileName);
this.dataFolder = mcMMO.p.getDataFolder(); this.dataFolder = mcMMO.p.getDataFolder();

View File

@ -9,7 +9,7 @@ import java.util.ArrayList;
import java.util.HashSet; import java.util.HashSet;
import java.util.List; import java.util.List;
public class RankConfig extends AutoUpdateConfigLoader { public class RankConfig extends BukkitConfig {
private static RankConfig instance; private static RankConfig instance;
public RankConfig() { public RankConfig() {
@ -66,7 +66,7 @@ public class RankConfig extends AutoUpdateConfigLoader {
*/ */
public int getSubSkillUnlockLevel(SubSkillType subSkillType, int rank, boolean retroMode) { public int getSubSkillUnlockLevel(SubSkillType subSkillType, int rank, boolean retroMode) {
String key = getRankAddressKey(subSkillType, rank, 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) { private void resetRankValue(@NotNull SubSkillType subSkillType, int rank, boolean retroMode) {
String key = getRankAddressKey(subSkillType, rank, retroMode); String key = getRankAddressKey(subSkillType, rank, retroMode);
int defaultValue = getInternalConfig().getInt(key); int defaultValue = defaultYamlConfig.getInt(key);
config.set(key, defaultValue); config.set(key, defaultValue);
mcMMO.p.getLogger().info(key + " SET -> " + defaultValue); mcMMO.p.getLogger().info(key + " SET -> " + defaultValue);
} }

View File

@ -29,7 +29,7 @@ public class ArmorConfigManager {
continue; continue;
} }
modManager.registerCustomArmor(new CustomArmorConfig(fileName)); modManager.registerCustomArmor(new CustomArmorLegacyConfig(fileName));
} }
} }
} }

View File

@ -29,7 +29,7 @@ public class BlockConfigManager {
continue; continue;
} }
modManager.registerCustomBlocks(new CustomBlockConfig(fileName)); modManager.registerCustomBlocks(new CustomBlockLegacyConfig(fileName));
} }
} }
} }

View File

@ -1,6 +1,6 @@
package com.gmail.nossr50.config.mods; 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.ItemType;
import com.gmail.nossr50.datatypes.skills.MaterialType; import com.gmail.nossr50.datatypes.skills.MaterialType;
import com.gmail.nossr50.mcMMO; import com.gmail.nossr50.mcMMO;
@ -13,7 +13,7 @@ import java.util.ArrayList;
import java.util.List; import java.util.List;
import java.util.Set; import java.util.Set;
public class CustomArmorConfig extends ConfigLoader { public class CustomArmorLegacyConfig extends LegacyConfigLoader {
public List<Material> customBoots = new ArrayList<>(); public List<Material> customBoots = new ArrayList<>();
public List<Material> customChestplates = new ArrayList<>(); public List<Material> customChestplates = new ArrayList<>();
public List<Material> customHelmets = new ArrayList<>(); public List<Material> customHelmets = new ArrayList<>();
@ -21,7 +21,7 @@ public class CustomArmorConfig extends ConfigLoader {
public List<Repairable> repairables = new ArrayList<>(); public List<Repairable> repairables = new ArrayList<>();
private boolean needsUpdate = false; private boolean needsUpdate = false;
protected CustomArmorConfig(String fileName) { protected CustomArmorLegacyConfig(String fileName) {
super("mods", fileName); super("mods", fileName);
loadKeys(); loadKeys();
} }

View File

@ -1,6 +1,6 @@
package com.gmail.nossr50.config.mods; 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.datatypes.mods.CustomBlock;
import com.gmail.nossr50.mcMMO; import com.gmail.nossr50.mcMMO;
import org.bukkit.Material; import org.bukkit.Material;
@ -11,7 +11,7 @@ import java.util.HashMap;
import java.util.List; import java.util.List;
import java.util.Set; import java.util.Set;
public class CustomBlockConfig extends ConfigLoader { public class CustomBlockLegacyConfig extends LegacyConfigLoader {
public List<Material> customExcavationBlocks = new ArrayList<>(); public List<Material> customExcavationBlocks = new ArrayList<>();
public List<Material> customHerbalismBlocks = new ArrayList<>(); public List<Material> customHerbalismBlocks = new ArrayList<>();
public List<Material> customMiningBlocks = new ArrayList<>(); public List<Material> customMiningBlocks = new ArrayList<>();
@ -22,7 +22,7 @@ public class CustomBlockConfig extends ConfigLoader {
public HashMap<Material, CustomBlock> customBlockMap = new HashMap<>(); public HashMap<Material, CustomBlock> customBlockMap = new HashMap<>();
private boolean needsUpdate = false; private boolean needsUpdate = false;
protected CustomBlockConfig(String fileName) { protected CustomBlockLegacyConfig(String fileName) {
super("mods", fileName); super("mods", fileName);
loadKeys(); loadKeys();
} }

View File

@ -1,6 +1,6 @@
package com.gmail.nossr50.config.mods; 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.datatypes.mods.CustomEntity;
import com.gmail.nossr50.mcMMO; import com.gmail.nossr50.mcMMO;
import org.apache.commons.lang.ClassUtils; import org.apache.commons.lang.ClassUtils;
@ -9,11 +9,11 @@ import org.bukkit.inventory.ItemStack;
import java.util.HashMap; import java.util.HashMap;
public class CustomEntityConfig extends ConfigLoader { public class CustomEntityLegacyConfig extends LegacyConfigLoader {
public HashMap<String, CustomEntity> customEntityClassMap = new HashMap<>(); public HashMap<String, CustomEntity> customEntityClassMap = new HashMap<>();
public HashMap<String, CustomEntity> customEntityTypeMap = new HashMap<>(); public HashMap<String, CustomEntity> customEntityTypeMap = new HashMap<>();
protected CustomEntityConfig(String fileName) { protected CustomEntityLegacyConfig(String fileName) {
super("mods", fileName); super("mods", fileName);
loadKeys(); loadKeys();
} }

View File

@ -1,6 +1,6 @@
package com.gmail.nossr50.config.mods; 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.mods.CustomTool;
import com.gmail.nossr50.datatypes.skills.ItemType; import com.gmail.nossr50.datatypes.skills.ItemType;
import com.gmail.nossr50.datatypes.skills.MaterialType; import com.gmail.nossr50.datatypes.skills.MaterialType;
@ -15,7 +15,7 @@ import java.util.HashMap;
import java.util.List; import java.util.List;
import java.util.Set; import java.util.Set;
public class CustomToolConfig extends ConfigLoader { public class CustomToolLegacyConfig extends LegacyConfigLoader {
public List<Material> customAxes = new ArrayList<>(); public List<Material> customAxes = new ArrayList<>();
public List<Material> customBows = new ArrayList<>(); public List<Material> customBows = new ArrayList<>();
public List<Material> customHoes = new ArrayList<>(); public List<Material> customHoes = new ArrayList<>();
@ -26,7 +26,7 @@ public class CustomToolConfig extends ConfigLoader {
public List<Repairable> repairables = new ArrayList<>(); public List<Repairable> repairables = new ArrayList<>();
private boolean needsUpdate = false; private boolean needsUpdate = false;
protected CustomToolConfig(String fileName) { protected CustomToolLegacyConfig(String fileName) {
super("mods", fileName); super("mods", fileName);
loadKeys(); loadKeys();
} }

View File

@ -29,7 +29,7 @@ public class EntityConfigManager {
continue; continue;
} }
modManager.registerCustomEntities(new CustomEntityConfig(fileName)); modManager.registerCustomEntities(new CustomEntityLegacyConfig(fileName));
} }
} }
} }

View File

@ -29,7 +29,7 @@ public class ToolConfigManager {
continue; continue;
} }
modManager.registerCustomTools(new CustomToolConfig(fileName)); modManager.registerCustomTools(new CustomToolLegacyConfig(fileName));
} }
} }
} }

View File

@ -1,6 +1,6 @@
package com.gmail.nossr50.config.skills.alchemy; 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.datatypes.skills.alchemy.AlchemyPotion;
import com.gmail.nossr50.mcMMO; import com.gmail.nossr50.mcMMO;
import org.bukkit.ChatColor; import org.bukkit.ChatColor;
@ -15,7 +15,7 @@ import java.util.HashMap;
import java.util.List; import java.util.List;
import java.util.Map; import java.util.Map;
public class PotionConfig extends ConfigLoader { public class PotionConfig extends LegacyConfigLoader {
private static PotionConfig instance; private static PotionConfig instance;
private final List<ItemStack> concoctionsIngredientsTierOne = new ArrayList<>(); private final List<ItemStack> concoctionsIngredientsTierOne = new ArrayList<>();

View File

@ -17,8 +17,8 @@ public class RepairConfig extends BukkitConfig {
private final HashSet<String> notSupported; private final HashSet<String> notSupported;
private List<Repairable> repairables; private List<Repairable> repairables;
public RepairConfig(String fileName) { public RepairConfig(String fileName, boolean copyDefaults) {
super(fileName, false); super(fileName, copyDefaults);
notSupported = new HashSet<>(); notSupported = new HashSet<>();
loadKeys(); loadKeys();
} }

View File

@ -16,7 +16,7 @@ public class RepairConfigManager {
Pattern pattern = Pattern.compile("repair\\.(?:.+)\\.yml"); Pattern pattern = Pattern.compile("repair\\.(?:.+)\\.yml");
File dataFolder = plugin.getDataFolder(); File dataFolder = plugin.getDataFolder();
RepairConfig mainRepairConfig = new RepairConfig(REPAIR_VANILLA_YML); RepairConfig mainRepairConfig = new RepairConfig(REPAIR_VANILLA_YML, true);
repairables.addAll(mainRepairConfig.getLoadedRepairables()); repairables.addAll(mainRepairConfig.getLoadedRepairables());
for (String fileName : dataFolder.list()) { for (String fileName : dataFolder.list()) {
@ -33,7 +33,7 @@ public class RepairConfigManager {
continue; continue;
} }
RepairConfig rConfig = new RepairConfig(fileName); RepairConfig rConfig = new RepairConfig(fileName, false);
repairables.addAll(rConfig.getLoadedRepairables()); repairables.addAll(rConfig.getLoadedRepairables());
} }
} }

View File

@ -20,8 +20,8 @@ public class SalvageConfig extends BukkitConfig {
private final HashSet<String> notSupported; private final HashSet<String> notSupported;
private Set<Salvageable> salvageables; private Set<Salvageable> salvageables;
public SalvageConfig(String fileName) { public SalvageConfig(String fileName, boolean copyDefaults) {
super(fileName); super(fileName, copyDefaults);
notSupported = new HashSet<>(); notSupported = new HashSet<>();
loadKeys(); loadKeys();
} }

View File

@ -17,7 +17,7 @@ public class SalvageConfigManager {
Pattern pattern = Pattern.compile("salvage\\.(?:.+)\\.yml"); Pattern pattern = Pattern.compile("salvage\\.(?:.+)\\.yml");
File dataFolder = plugin.getDataFolder(); File dataFolder = plugin.getDataFolder();
SalvageConfig mainSalvageConfig = new SalvageConfig(SALVAGE_VANILLA_YML); SalvageConfig mainSalvageConfig = new SalvageConfig(SALVAGE_VANILLA_YML, true);
salvageables.addAll(mainSalvageConfig.getLoadedSalvageables()); salvageables.addAll(mainSalvageConfig.getLoadedSalvageables());
for (String fileName : dataFolder.list()) { for (String fileName : dataFolder.list()) {
@ -34,7 +34,7 @@ public class SalvageConfigManager {
continue; continue;
} }
SalvageConfig salvageConfig = new SalvageConfig(fileName); SalvageConfig salvageConfig = new SalvageConfig(fileName, false);
salvageables.addAll(salvageConfig.getLoadedSalvageables()); salvageables.addAll(salvageConfig.getLoadedSalvageables());
} }
} }

View File

@ -450,6 +450,9 @@ public class PlayerListener implements Listener {
case CAUGHT_FISH: case CAUGHT_FISH:
if(caught instanceof Item) { if(caught instanceof Item) {
if(ExperienceConfig.getInstance().isFishingExploitingPrevented()) { if(ExperienceConfig.getInstance().isFishingExploitingPrevented()) {
fishingManager.processExploiting(event.getHook().getLocation().toVector());
if (fishingManager.isExploitingFishing(event.getHook().getLocation().toVector())) { if (fishingManager.isExploitingFishing(event.getHook().getLocation().toVector())) {
player.sendMessage(LocaleLoader.getString("Fishing.ScarcityTip", ExperienceConfig.getInstance().getFishingExploitingOptionMoveRange())); player.sendMessage(LocaleLoader.getString("Fishing.ScarcityTip", ExperienceConfig.getInstance().getFishingExploitingOptionMoveRange()));
event.setExpToDrop(0); event.setExpToDrop(0);

View File

@ -28,6 +28,7 @@ import java.util.LinkedHashMap;
import java.util.List; import java.util.List;
import java.util.Map.Entry; import java.util.Map.Entry;
import java.util.UUID; import java.util.UUID;
import java.util.logging.Level;
public final class PartyManager { public final class PartyManager {
private static final String partiesFilePath = mcMMO.getFlatFileDirectory() + "parties.yml"; private static final String partiesFilePath = mcMMO.getFlatFileDirectory() + "parties.yml";
@ -609,6 +610,7 @@ public final class PartyManager {
ArrayList<Party> hasAlly = new ArrayList<>(); ArrayList<Party> hasAlly = new ArrayList<>();
for (String partyName : partiesFile.getConfigurationSection("").getKeys(false)) { for (String partyName : partiesFile.getConfigurationSection("").getKeys(false)) {
try {
Party party = new Party(partyName); Party party = new Party(partyName);
String[] leaderSplit = partiesFile.getString(partyName + ".Leader").split("[|]"); String[] leaderSplit = partiesFile.getString(partyName + ".Leader").split("[|]");
@ -637,6 +639,9 @@ public final class PartyManager {
} }
parties.add(party); 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);
}
} }
mcMMO.p.debug("Loaded (" + parties.size() + ") Parties..."); mcMMO.p.debug("Loaded (" + parties.size() + ") Parties...");

View File

@ -50,6 +50,7 @@ public class FishingManager extends SkillManager {
private long lastWarnedExhaust = 0L; private long lastWarnedExhaust = 0L;
private FishHook fishHookReference; private FishHook fishHookReference;
private BoundingBox lastFishingBoundingBox; private BoundingBox lastFishingBoundingBox;
private boolean sameTarget;
private Item fishingCatch; private Item fishingCatch;
private Location hookLocation; private Location hookLocation;
private int fishCaughtCounter = 1; private int fishCaughtCounter = 1;
@ -127,6 +128,25 @@ public class FishingManager extends SkillManager {
return hasFished; 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) { public boolean isExploitingFishing(Vector centerOfCastVector) {
/*Block targetBlock = getPlayer().getTargetBlock(BlockUtils.getTransparentBlocks(), 100); /*Block targetBlock = getPlayer().getTargetBlock(BlockUtils.getTransparentBlocks(), 100);
@ -135,25 +155,7 @@ public class FishingManager extends SkillManager {
return false; return false;
}*/ }*/
BoundingBox newCastBoundingBox = makeBoundingBox(centerOfCastVector); return this.sameTarget && fishCaughtCounter >= ExperienceConfig.getInstance().getFishingExploitingOptionOverFishLimit();
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();
} }
public static BoundingBox makeBoundingBox(Vector centerOfCastVector) { public static BoundingBox makeBoundingBox(Vector centerOfCastVector) {

View File

@ -1,9 +1,9 @@
package com.gmail.nossr50.util; package com.gmail.nossr50.util;
import com.gmail.nossr50.config.mods.CustomArmorConfig; import com.gmail.nossr50.config.mods.CustomArmorLegacyConfig;
import com.gmail.nossr50.config.mods.CustomBlockConfig; import com.gmail.nossr50.config.mods.CustomBlockLegacyConfig;
import com.gmail.nossr50.config.mods.CustomEntityConfig; import com.gmail.nossr50.config.mods.CustomEntityLegacyConfig;
import com.gmail.nossr50.config.mods.CustomToolConfig; import com.gmail.nossr50.config.mods.CustomToolLegacyConfig;
import com.gmail.nossr50.datatypes.mods.CustomBlock; import com.gmail.nossr50.datatypes.mods.CustomBlock;
import com.gmail.nossr50.datatypes.mods.CustomEntity; import com.gmail.nossr50.datatypes.mods.CustomEntity;
import com.gmail.nossr50.datatypes.mods.CustomTool; import com.gmail.nossr50.datatypes.mods.CustomTool;
@ -52,7 +52,7 @@ public class ModManager {
private final List<Material> customSwords = new ArrayList<>(); private final List<Material> customSwords = new ArrayList<>();
private final HashMap<Material, CustomTool> customToolMap = new HashMap<>(); private final HashMap<Material, CustomTool> customToolMap = new HashMap<>();
public void registerCustomArmor(CustomArmorConfig config) { public void registerCustomArmor(CustomArmorLegacyConfig config) {
customBoots.addAll(config.customBoots); customBoots.addAll(config.customBoots);
customChestplates.addAll(config.customChestplates); customChestplates.addAll(config.customChestplates);
customHelmets.addAll(config.customHelmets); customHelmets.addAll(config.customHelmets);
@ -60,7 +60,7 @@ public class ModManager {
repairables.addAll(config.repairables); repairables.addAll(config.repairables);
} }
public void registerCustomBlocks(CustomBlockConfig config) { public void registerCustomBlocks(CustomBlockLegacyConfig config) {
customExcavationBlocks.addAll(config.customExcavationBlocks); customExcavationBlocks.addAll(config.customExcavationBlocks);
customHerbalismBlocks.addAll(config.customHerbalismBlocks); customHerbalismBlocks.addAll(config.customHerbalismBlocks);
customMiningBlocks.addAll(config.customMiningBlocks); customMiningBlocks.addAll(config.customMiningBlocks);
@ -71,12 +71,12 @@ public class ModManager {
customBlockMap.putAll(config.customBlockMap); customBlockMap.putAll(config.customBlockMap);
} }
public void registerCustomEntities(CustomEntityConfig config) { public void registerCustomEntities(CustomEntityLegacyConfig config) {
customEntityClassMap.putAll(config.customEntityClassMap); customEntityClassMap.putAll(config.customEntityClassMap);
customEntityTypeMap.putAll(config.customEntityTypeMap); customEntityTypeMap.putAll(config.customEntityTypeMap);
} }
public void registerCustomTools(CustomToolConfig config) { public void registerCustomTools(CustomToolLegacyConfig config) {
customAxes.addAll(config.customAxes); customAxes.addAll(config.customAxes);
customBows.addAll(config.customBows); customBows.addAll(config.customBows);
customHoes.addAll(config.customHoes); customHoes.addAll(config.customHoes);