diff --git a/src/main/java/com/gmail/nossr50/chat/PartyChatManager.java b/src/main/java/com/gmail/nossr50/chat/PartyChatManager.java index 35443e292..242ddee90 100644 --- a/src/main/java/com/gmail/nossr50/chat/PartyChatManager.java +++ b/src/main/java/com/gmail/nossr50/chat/PartyChatManager.java @@ -1,8 +1,8 @@ package com.gmail.nossr50.chat; -import com.gmail.nossr50.config.MainConfig; import com.gmail.nossr50.datatypes.party.Party; import com.gmail.nossr50.events.chat.McMMOPartyChatEvent; +import com.gmail.nossr50.mcMMO; import com.gmail.nossr50.runnables.party.PartyChatTask; import org.bukkit.plugin.Plugin; @@ -10,7 +10,8 @@ public class PartyChatManager extends ChatManager { private Party party; protected PartyChatManager(Plugin plugin) { - super(plugin, MainConfig.getInstance().getPartyDisplayNames(), MainConfig.getInstance().getPartyChatPrefix()); + super(plugin, mcMMO.getConfigManager().getConfigParty().isPartyDisplayNamesEnabled(), + mcMMO.getConfigManager().getConfigParty().getPartyChat().getPartyChatPrefixFormat()); } public void setParty(Party party) { diff --git a/src/main/java/com/gmail/nossr50/commands/party/teleport/PtpAcceptCommand.java b/src/main/java/com/gmail/nossr50/commands/party/teleport/PtpAcceptCommand.java index c07768708..b9026d3dc 100644 --- a/src/main/java/com/gmail/nossr50/commands/party/teleport/PtpAcceptCommand.java +++ b/src/main/java/com/gmail/nossr50/commands/party/teleport/PtpAcceptCommand.java @@ -1,8 +1,8 @@ package com.gmail.nossr50.commands.party.teleport; -import com.gmail.nossr50.config.MainConfig; import com.gmail.nossr50.datatypes.party.PartyTeleportRecord; import com.gmail.nossr50.locale.LocaleLoader; +import com.gmail.nossr50.mcMMO; import com.gmail.nossr50.util.Permissions; import com.gmail.nossr50.util.player.UserManager; import com.gmail.nossr50.util.skills.SkillUtils; @@ -28,7 +28,7 @@ public class PtpAcceptCommand implements CommandExecutor { return true; } - if (SkillUtils.cooldownExpired(ptpRecord.getTimeout(), MainConfig.getInstance().getPTPCommandTimeout())) { + if (SkillUtils.cooldownExpired(ptpRecord.getTimeout(), mcMMO.getConfigManager().getConfigParty().getPTP().getPtpRequestTimeout())) { ptpRecord.removeRequest(); player.sendMessage(LocaleLoader.getString("Commands.ptp.RequestExpired")); return true; @@ -41,7 +41,7 @@ public class PtpAcceptCommand implements CommandExecutor { return true; } - if (MainConfig.getInstance().getPTPCommandWorldPermissions()) { + if (mcMMO.getConfigManager().getConfigParty().getPTP().isPtpWorldBasedPermissions()) { World targetWorld = target.getWorld(); World playerWorld = player.getWorld(); diff --git a/src/main/java/com/gmail/nossr50/commands/party/teleport/PtpCommand.java b/src/main/java/com/gmail/nossr50/commands/party/teleport/PtpCommand.java index 4f5d97105..a510af078 100644 --- a/src/main/java/com/gmail/nossr50/commands/party/teleport/PtpCommand.java +++ b/src/main/java/com/gmail/nossr50/commands/party/teleport/PtpCommand.java @@ -1,6 +1,5 @@ package com.gmail.nossr50.commands.party.teleport; -import com.gmail.nossr50.config.MainConfig; import com.gmail.nossr50.config.WorldBlacklist; import com.gmail.nossr50.datatypes.party.Party; import com.gmail.nossr50.datatypes.party.PartyFeature; @@ -84,7 +83,7 @@ public class PtpCommand implements TabExecutor { } long recentlyHurt = mcMMOPlayer.getRecentlyHurt(); - int hurtCooldown = MainConfig.getInstance().getPTPCommandRecentlyHurtCooldown(); + int hurtCooldown = mcMMO.getConfigManager().getConfigParty().getPTP().getPtpRecentlyHurtCooldown(); if (hurtCooldown > 0) { int timeRemaining = SkillUtils.calculateTimeLeft(recentlyHurt * Misc.TIME_CONVERSION_FACTOR, hurtCooldown, player); @@ -104,7 +103,7 @@ public class PtpCommand implements TabExecutor { return true; } - int ptpCooldown = MainConfig.getInstance().getPTPCommandCooldown(); + int ptpCooldown = mcMMO.getConfigManager().getConfigParty().getPTP().getPtpCooldown(); long ptpLastUse = mcMMOPlayer.getPartyTeleportRecord().getLastUse(); if (ptpCooldown > 0) { @@ -169,7 +168,7 @@ public class PtpCommand implements TabExecutor { player.sendMessage(LocaleLoader.getString("Commands.Invite.Success")); target.sendMessage(LocaleLoader.getString("Commands.ptp.Request1", player.getName())); - target.sendMessage(LocaleLoader.getString("Commands.ptp.Request2", MainConfig.getInstance().getPTPCommandTimeout())); + target.sendMessage(LocaleLoader.getString("Commands.ptp.Request2", mcMMO.getConfigManager().getConfigParty().getPTP().getPtpRequestTimeout())); } protected static boolean canTeleport(CommandSender sender, Player player, String targetName) { @@ -208,7 +207,7 @@ public class PtpCommand implements TabExecutor { McMMOPlayer mcMMOPlayer = UserManager.getPlayer(teleportingPlayer); McMMOPlayer mcMMOTarget = UserManager.getPlayer(targetPlayer); - long warmup = MainConfig.getInstance().getPTPCommandWarmup(); + long warmup = mcMMO.getConfigManager().getConfigParty().getPTP().getPtpWarmup(); mcMMOPlayer.actualizeTeleportCommenceLocation(teleportingPlayer); diff --git a/src/main/java/com/gmail/nossr50/config/ConfigManager.java b/src/main/java/com/gmail/nossr50/config/ConfigManager.java index 54e37dfeb..82dcb7dee 100644 --- a/src/main/java/com/gmail/nossr50/config/ConfigManager.java +++ b/src/main/java/com/gmail/nossr50/config/ConfigManager.java @@ -23,7 +23,6 @@ import com.gmail.nossr50.config.hocon.playerleveling.ConfigLeveling; import com.gmail.nossr50.config.hocon.scoreboard.ConfigScoreboard; import com.gmail.nossr50.config.hocon.superabilities.ConfigSuperAbilities; import com.gmail.nossr50.config.hocon.worldblacklist.ConfigWorldBlacklist; -import com.gmail.nossr50.config.party.ItemWeightConfig; import com.gmail.nossr50.config.skills.alchemy.PotionConfig; import com.gmail.nossr50.config.treasure.ExcavationTreasureConfig; import com.gmail.nossr50.config.treasure.FishingTreasureConfig; @@ -114,7 +113,6 @@ public final class ConfigManager { private CoreSkillsConfig coreSkillsConfig; private SoundConfig soundConfig; private RankConfig rankConfig; - private ItemWeightConfig itemWeightConfig; private RepairConfig repairConfig; private SalvageConfig salvageConfig; @@ -190,8 +188,6 @@ public final class ConfigManager { rankConfig = new RankConfig(); - itemWeightConfig = new ItemWeightConfig(); - repairConfig = new RepairConfig(); salvageConfig = new SalvageConfig(); @@ -356,10 +352,6 @@ public final class ConfigManager { return experienceConfig; } - public ItemWeightConfig getItemWeightConfig() { - return itemWeightConfig; - } - public ExperienceMapManager getExperienceMapManager() { return experienceMapManager; } diff --git a/src/main/java/com/gmail/nossr50/config/MainConfig.java b/src/main/java/com/gmail/nossr50/config/MainConfig.java index 55804efae..ca082feac 100644 --- a/src/main/java/com/gmail/nossr50/config/MainConfig.java +++ b/src/main/java/com/gmail/nossr50/config/MainConfig.java @@ -446,30 +446,10 @@ public class MainConfig extends ConfigValidated { return getBooleanValue(GENERAL, SHOW_PROFILE_LOADED); } - public boolean getDonateMessageEnabled() { - return getBooleanValue(COMMANDS, MCMMO, DONATE_MESSAGE); - } - public int getSaveInterval() { return getIntValue(GENERAL, SAVE_INTERVAL); } - public String getPartyChatPrefix() { - return getStringValue(COMMANDS, PARTYCHAT, CHAT_PREFIX_FORMAT); - } - - public boolean getPartyChatColorLeaderName() { - return getBooleanValue(COMMANDS, PARTYCHAT, GOLD_LEADER_NAME); - } - - public boolean getPartyDisplayNames() { - return getBooleanValue(COMMANDS, PARTYCHAT, USE_DISPLAY_NAMES); - } - - public String getPartyChatPrefixAlly() { - return getStringValue(COMMANDS, PARTYCHAT, CHAT_PREFIX_FORMAT + ALLY); - } - public String getAdminChatPrefix() { return getStringValue(COMMANDS, ADMINCHAT, CHAT_PREFIX_FORMAT); } @@ -694,33 +674,6 @@ public class MainConfig extends ConfigValidated { return getBooleanValue(PARTICLES, LARGE_FIREWORKS); } - /* PARTY SETTINGS */ - - /* Party Teleport Settings */ - public int getPTPCommandCooldown() { - return getIntValue(COMMANDS, PTP, COOLDOWN); - } - - public int getPTPCommandWarmup() { - return getIntValue(COMMANDS, PTP, WARMUP); - } - - public int getPTPCommandRecentlyHurtCooldown() { - return getIntValue(COMMANDS, PTP, RECENTLY_HURT + COOLDOWN); - } - - public int getPTPCommandTimeout() { - return getIntValue(COMMANDS, PTP, REQUEST_TIMEOUT); - } - - public boolean getPTPCommandConfirmRequired() { - return getBooleanValue(COMMANDS, PTP, ACCEPT_REQUIRED); - } - - public boolean getPTPCommandWorldPermissions() { - return getBooleanValue(COMMANDS, PTP, WORLD_BASED_PERMISSIONS); - } - /* Inspect command distance */ public double getInspectDistance() { return getDoubleValue(COMMANDS, INSPECT1, MAX_DISTANCE); diff --git a/src/main/java/com/gmail/nossr50/config/hocon/party/ConfigParty.java b/src/main/java/com/gmail/nossr50/config/hocon/party/ConfigParty.java index 2562483e6..ab0850086 100644 --- a/src/main/java/com/gmail/nossr50/config/hocon/party/ConfigParty.java +++ b/src/main/java/com/gmail/nossr50/config/hocon/party/ConfigParty.java @@ -39,6 +39,10 @@ public class ConfigParty { return partyGeneral.isPartySizeCapped(); } + public ConfigSectionPartyTeleportCommand getPTP() { + return partyCommands.getPartyTeleportCommand(); + } + public ConfigSectionPartyCleanup getPartyCleanup() { return partyCleanup; } @@ -63,6 +67,10 @@ public class ConfigParty { return partyItemShare; } + public ConfigSectionPartyCommands getPartyCommands() { + return partyCommands; + } + public String getPartyChatPrefixFormat() { return partyChat.getPartyChatPrefixFormat(); } diff --git a/src/main/java/com/gmail/nossr50/config/party/ItemWeightConfig.java b/src/main/java/com/gmail/nossr50/config/party/ItemWeightConfig.java deleted file mode 100644 index cff981754..000000000 --- a/src/main/java/com/gmail/nossr50/config/party/ItemWeightConfig.java +++ /dev/null @@ -1,82 +0,0 @@ -package com.gmail.nossr50.config.party; - -import com.gmail.nossr50.config.Config; -import com.gmail.nossr50.config.ConfigConstants; -import com.gmail.nossr50.mcMMO; -import com.gmail.nossr50.util.StringUtils; -import ninja.leaping.configurate.objectmapping.ObjectMappingException; -import org.bukkit.Material; - -import java.util.HashSet; - -public class ItemWeightConfig extends Config { - public static final String ITEM_WEIGHTS = "Item_Weights"; - public static final String DEFAULT = "Default"; - public static final String PARTY_SHAREABLES = "Party_Shareables"; - public static final String MISC_ITEMS = "Misc_Items"; - - public ItemWeightConfig() { - //super(McmmoCore.getDataFolderPath().getAbsoluteFile(), "itemweights.yml"); - super("itemweights", mcMMO.p.getDataFolder().getAbsoluteFile(), ConfigConstants.RELATIVE_PATH_CONFIG_DIR, true, true, true, false); - } - - /** - * This grabs an instance of this config class from the Config Manager - * This method is deprecated and will be removed in the future - * @see mcMMO#getConfigManager() - * @return the instance of this config - * @deprecated Please use mcMMO.getConfigManager() to grab a specific config instead - */ - @Deprecated - public static ItemWeightConfig getInstance() { - return mcMMO.getConfigManager().getItemWeightConfig(); - } - - @Override - public void unload() { - //do nothing - } - - /** - * The version of this config - * - * @return - */ - @Override - public double getConfigVersion() { - return 1; - } - - /*public static ItemWeightConfig getInstance() { - if (instance == null) { - instance = new ItemWeightConfig(); - } - - return instance; - }*/ - - public int getItemWeight(Material material) { - String[] keyPath = {ITEM_WEIGHTS, StringUtils.getPrettyItemString(material).replace(" ", "_")}; - if(hasNode(keyPath)) - return getIntValue(keyPath); - else - return getIntValue(ITEM_WEIGHTS, DEFAULT); - } - - public HashSet getMiscItems() { - HashSet miscItems = new HashSet(); - - try { - for (String item : getListFromNode(PARTY_SHAREABLES, MISC_ITEMS)) { - Material material = Material.getMaterial(item.toUpperCase()); - - if (material != null) { - miscItems.add(material); - } - } - } catch (ObjectMappingException e) { - e.printStackTrace(); - } - return miscItems; - } -} diff --git a/src/main/java/com/gmail/nossr50/datatypes/party/PartyTeleportRecord.java b/src/main/java/com/gmail/nossr50/datatypes/party/PartyTeleportRecord.java index f3f49af6f..b3fa920c7 100644 --- a/src/main/java/com/gmail/nossr50/datatypes/party/PartyTeleportRecord.java +++ b/src/main/java/com/gmail/nossr50/datatypes/party/PartyTeleportRecord.java @@ -1,6 +1,6 @@ package com.gmail.nossr50.datatypes.party; -import com.gmail.nossr50.config.MainConfig; +import com.gmail.nossr50.mcMMO; import com.gmail.nossr50.util.Misc; import org.bukkit.entity.Player; @@ -12,7 +12,7 @@ public class PartyTeleportRecord { public PartyTeleportRecord() { requestor = null; enabled = true; - confirmRequired = MainConfig.getInstance().getPTPCommandConfirmRequired(); + confirmRequired = mcMMO.getConfigManager().getConfigParty().getPTP().isPtpAcceptRequired(); timeout = 0; lastUse = 0; } diff --git a/src/main/java/com/gmail/nossr50/mcMMO.java b/src/main/java/com/gmail/nossr50/mcMMO.java index 24594b87f..c878cc822 100644 --- a/src/main/java/com/gmail/nossr50/mcMMO.java +++ b/src/main/java/com/gmail/nossr50/mcMMO.java @@ -154,7 +154,7 @@ public class mcMMO extends JavaPlugin { placeStore = ChunkManagerFactory.getChunkManager(); // Get our ChunkletManager - if (MainConfig.getInstance().getPTPCommandWorldPermissions()) { + if (mcMMO.getConfigManager().getConfigParty().getPTP().isPtpWorldBasedPermissions()) { Permissions.generateWorldTeleportPermissions(); } diff --git a/src/main/java/com/gmail/nossr50/party/ShareHandler.java b/src/main/java/com/gmail/nossr50/party/ShareHandler.java index 421468766..49fa0277a 100644 --- a/src/main/java/com/gmail/nossr50/party/ShareHandler.java +++ b/src/main/java/com/gmail/nossr50/party/ShareHandler.java @@ -1,6 +1,5 @@ package com.gmail.nossr50.party; -import com.gmail.nossr50.config.party.ItemWeightConfig; import com.gmail.nossr50.datatypes.experience.XPGainReason; import com.gmail.nossr50.datatypes.experience.XPGainSource; import com.gmail.nossr50.datatypes.party.ItemShareType; @@ -11,6 +10,7 @@ import com.gmail.nossr50.datatypes.skills.PrimarySkillType; import com.gmail.nossr50.mcMMO; import com.gmail.nossr50.util.Misc; import com.gmail.nossr50.util.player.UserManager; +import org.bukkit.Material; import org.bukkit.entity.Item; import org.bukkit.entity.Player; import org.bukkit.inventory.ItemStack; @@ -100,7 +100,7 @@ public final class ShareHandler { switch (shareMode) { case EQUAL: - int itemWeight = ItemWeightConfig.getInstance().getItemWeight(itemStack.getType()); + int itemWeight = getItemWeight(itemStack.getType()); for (int i = 0; i < itemStack.getAmount(); i++) { int highestRoll = 0; @@ -145,6 +145,13 @@ public final class ShareHandler { } } + public static int getItemWeight(Material material) { + if(mcMMO.getConfigManager().getConfigParty().getPartyItemShare().getItemShareMap().get(material) == null) + return 5; + else + return mcMMO.getConfigManager().getConfigParty().getPartyItemShare().getItemShareMap().get(material); + } + public static XPGainReason getSharedXpGainReason(XPGainReason xpGainReason) { if (xpGainReason == XPGainReason.PVE) { return XPGainReason.SHARED_PVE; diff --git a/src/main/java/com/gmail/nossr50/runnables/items/TeleportationWarmup.java b/src/main/java/com/gmail/nossr50/runnables/items/TeleportationWarmup.java index 9d264ad93..c586b5780 100644 --- a/src/main/java/com/gmail/nossr50/runnables/items/TeleportationWarmup.java +++ b/src/main/java/com/gmail/nossr50/runnables/items/TeleportationWarmup.java @@ -1,8 +1,8 @@ package com.gmail.nossr50.runnables.items; -import com.gmail.nossr50.config.MainConfig; import com.gmail.nossr50.datatypes.player.McMMOPlayer; import com.gmail.nossr50.locale.LocaleLoader; +import com.gmail.nossr50.mcMMO; import com.gmail.nossr50.party.PartyManager; import com.gmail.nossr50.util.EventUtils; import com.gmail.nossr50.util.Misc; @@ -40,7 +40,7 @@ public class TeleportationWarmup extends BukkitRunnable { return; } - int hurtCooldown = MainConfig.getInstance().getPTPCommandRecentlyHurtCooldown(); + int hurtCooldown = mcMMO.getConfigManager().getConfigParty().getPTP().getPtpRecentlyHurtCooldown(); if (hurtCooldown > 0) { int timeRemaining = SkillUtils.calculateTimeLeft(recentlyHurt * Misc.TIME_CONVERSION_FACTOR, hurtCooldown, teleportingPlayer); diff --git a/src/main/java/com/gmail/nossr50/runnables/party/PartyChatTask.java b/src/main/java/com/gmail/nossr50/runnables/party/PartyChatTask.java index 196731388..94543d4ba 100644 --- a/src/main/java/com/gmail/nossr50/runnables/party/PartyChatTask.java +++ b/src/main/java/com/gmail/nossr50/runnables/party/PartyChatTask.java @@ -1,8 +1,8 @@ package com.gmail.nossr50.runnables.party; -import com.gmail.nossr50.config.MainConfig; import com.gmail.nossr50.datatypes.party.Party; import com.gmail.nossr50.locale.LocaleLoader; +import com.gmail.nossr50.mcMMO; import org.bukkit.ChatColor; import org.bukkit.entity.Player; import org.bukkit.plugin.Plugin; @@ -30,7 +30,8 @@ public class PartyChatTask extends BukkitRunnable { @Override public void run() { - if (MainConfig.getInstance().getPartyChatColorLeaderName() && senderName.equalsIgnoreCase(party.getLeader().getPlayerName())) { + if (mcMMO.getConfigManager().getConfigParty().isPartyLeaderColoredGold() + && senderName.equalsIgnoreCase(party.getLeader().getPlayerName())) { message = message.replaceFirst(Pattern.quote(displayName), ChatColor.GOLD + Matcher.quoteReplacement(displayName) + ChatColor.RESET); } @@ -40,7 +41,7 @@ public class PartyChatTask extends BukkitRunnable { if (party.getAlly() != null) { for (Player member : party.getAlly().getOnlineMembers()) { - String allyPrefix = LocaleLoader.formatString(MainConfig.getInstance().getPartyChatPrefixAlly()); + String allyPrefix = LocaleLoader.formatString(mcMMO.getConfigManager().getConfigParty().getPartyChatPrefixAlly()); member.sendMessage(allyPrefix + message); } } diff --git a/src/main/resources/itemweights.yml b/src/main/resources/itemweights.yml deleted file mode 100644 index 7277c120a..000000000 --- a/src/main/resources/itemweights.yml +++ /dev/null @@ -1,96 +0,0 @@ -# -# Item Weights configuration -# -# This file is used to determine the value of an item. This will only -# happen when users are sharing items in a party using the EQUAL item share mode. -# -# Rare items should have a higher value than common items. If an item is not listed -# here, the value from "Default" will be used instead. -# -##### -Item_Weights: - Default: 5 - Quartz: 200 - Nether_Quartz_Ore: 200 - Emerald: 150 - Emerald_Ore: 150 - Diamond: 100 - Diamond_Ore: 100 - Gold_Ingot: 50 - Gold_Ore: 50 - Iron_Ingot: 40 - Iron_Ore: 40 - Lapis_Ore: 30 - Redstone: 30 - Redstone_Ore: 30 - Glowstone_Dust: 20 - Coal: 10 - Coal_Ore: 10 - - # Item weights for armor and tools - Diamond_Sword: 150 - Diamond_Shovel: 150 - Diamond_Pickaxe: 150 - Diamond_Axe: 150 - Diamond_Helmet: 150 - Diamond_Chestplate: 150 - Diamond_Leggings: 150 - Diamond_Boots: 150 - Golden_Sword: 75 - Golden_Shovel: 75 - Golden_Pickaxe: 75 - Golden_Axe: 75 - Golden_Helmet: 75 - Golden_Chestplate: 75 - Golden_Leggings: 75 - Golden_Boots: 75 - Iron_Sword: 60 - Iron_Shovel: 60 - Iron_Pickaxe: 60 - Iron_Axe: 60 - Iron_Helmet: 60 - Iron_Chestplate: 60 - Iron_Leggings: 60 - Iron_Boots: 60 - -# Items in this section will get added to the Misc share category. -# Case insensitive, though the name must be exactly the same as set in the Bukkit Material enum. -Party_Shareables: - Misc_Items: - - Diamond_Sword - - Diamond_Shovel - - Diamond_Pickaxe - - Diamond_Axe - - Golden_Sword - - Golden_Shovel - - Golden_Pickaxe - - Golden_Axe - - Iron_Sword - - Iron_Shovel - - Iron_Pickaxe - - Iron_Axe - - Stone_Sword - - Stone_Shovel - - Stone_Pickaxe - - Stone_Axe - - Wooden_Sword - - Wooden_Shovel - - Wooden_Pickaxe - - Wooden_Axe - - Bow - - Diamond_Helmet - - Diamond_Chestplate - - Diamond_Leggings - - Diamond_Boots - - Golden_Helmet - - Golden_Chestplate - - Golden_Leggings - - Golden_Boots - - Iron_Helmet - - Iron_Chestplate - - Iron_Leggings - - Iron_Boots - - Leather_Helmet - - Leather_Chestplate - - Leather_Leggings - - Leather_Boots