From 820c3260c87bf83f5e3eb535a4a0b328cfa8777e Mon Sep 17 00:00:00 2001 From: nossr50 Date: Wed, 17 Apr 2019 11:51:13 -0700 Subject: [PATCH 01/22] 2.1.45 - mcMMO will check for outdated software and provide tips --- Changelog.txt | 3 + pom.xml | 2 +- src/main/java/com/gmail/nossr50/mcMMO.java | 111 ++++++++++++++++----- 3 files changed, 92 insertions(+), 24 deletions(-) diff --git a/Changelog.txt b/Changelog.txt index 4ef569259..08872a65f 100644 --- a/Changelog.txt +++ b/Changelog.txt @@ -7,6 +7,9 @@ Key: ! Change - Removal +Version 2.1.45 + mcMMO will now check to see if the server version is incompatible and inform server admins on how to fix the problem. + Version 2.1.44 Fixed a NPE with Alchemy brewing diff --git a/pom.xml b/pom.xml index 1ac897472..8152abcf7 100755 --- a/pom.xml +++ b/pom.xml @@ -2,7 +2,7 @@ 4.0.0 com.gmail.nossr50.mcMMO mcMMO - 2.1.44 + 2.1.45 mcMMO https://github.com/mcMMO-Dev/mcMMO diff --git a/src/main/java/com/gmail/nossr50/mcMMO.java b/src/main/java/com/gmail/nossr50/mcMMO.java index 79f8999ab..1463f6e59 100644 --- a/src/main/java/com/gmail/nossr50/mcMMO.java +++ b/src/main/java/com/gmail/nossr50/mcMMO.java @@ -47,6 +47,7 @@ import com.gmail.nossr50.worldguard.WorldGuardManager; import com.google.common.base.Charsets; import net.shatteredlands.shatt.backup.ZipLibrary; import org.bstats.bukkit.Metrics; +import org.bukkit.Bukkit; import org.bukkit.entity.Player; import org.bukkit.event.HandlerList; import org.bukkit.metadata.FixedMetadataValue; @@ -57,6 +58,7 @@ import java.io.File; import java.io.IOException; import java.io.InputStream; import java.io.InputStreamReader; +import java.lang.reflect.Method; import java.util.ArrayList; import java.util.List; @@ -88,6 +90,9 @@ public class mcMMO extends JavaPlugin { /* Plugin Checks */ private static boolean healthBarPluginEnabled; + // API checks + private static boolean serverAPIOutdated = false; + // Config Validation Check public boolean noErrorsInConfigFiles = true; @@ -165,35 +170,54 @@ public class mcMMO extends JavaPlugin { databaseManager = DatabaseManagerFactory.getDatabaseManager(); - registerEvents(); - registerCoreSkills(); - registerCustomRecipes(); + //Check for the newer API and tell them what to do if its missing + checkForOutdatedAPI(); - PartyManager.loadParties(); + if(serverAPIOutdated) + { + Bukkit + .getScheduler() + .scheduleSyncRepeatingTask(this, + () -> getLogger().severe("You are running an outdated version of "+getServerSoftware()+", mcMMO will not work unless you update to a newer version!"), + 20, 20*60*30); - formulaManager = new FormulaManager(); - holidayManager = new HolidayManager(); + if(getServerSoftware() == ServerSoftwareType.CRAFTBUKKIT) + { + Bukkit.getScheduler() + .scheduleSyncRepeatingTask(this, + () -> getLogger().severe("We have detected you are using incompatible server software, our best guess is that you are using CraftBukkit. mcMMO requires Spigot or Paper, if you are not using CraftBukkit, you will still need to update your custom server software before mcMMO will work."), + 20, 20*60*30); + } + } else { + registerEvents(); + registerCoreSkills(); + registerCustomRecipes(); - for (Player player : getServer().getOnlinePlayers()) { - new PlayerProfileLoadingTask(player).runTaskLaterAsynchronously(mcMMO.p, 1); // 1 Tick delay to ensure the player is marked as online before we begin loading + PartyManager.loadParties(); + + formulaManager = new FormulaManager(); + holidayManager = new HolidayManager(); + + for (Player player : getServer().getOnlinePlayers()) { + new PlayerProfileLoadingTask(player).runTaskLaterAsynchronously(mcMMO.p, 1); // 1 Tick delay to ensure the player is marked as online before we begin loading + } + + debug("Version " + getDescription().getVersion() + " is enabled!"); + + scheduleTasks(); + CommandRegistrationManager.registerCommands(); + + placeStore = ChunkManagerFactory.getChunkManager(); // Get our ChunkletManager + + if (Config.getInstance().getPTPCommandWorldPermissions()) { + Permissions.generateWorldTeleportPermissions(); + } + + //Populate Ranked Skill Maps (DO THIS LAST) + RankUtils.populateRanks(); } - debug("Version " + getDescription().getVersion() + " is enabled!"); - - scheduleTasks(); - CommandRegistrationManager.registerCommands(); - - placeStore = ChunkManagerFactory.getChunkManager(); // Get our ChunkletManager - - if (Config.getInstance().getPTPCommandWorldPermissions()) { - Permissions.generateWorldTeleportPermissions(); - } - - //Populate Ranked Skill Maps (DO THIS LAST) - RankUtils.populateRanks(); - //If anonymous statistics are enabled then use them - Metrics metrics; if(Config.getInstance().getIsMetricsEnabled()) { @@ -223,6 +247,47 @@ public class mcMMO extends JavaPlugin { worldBlacklist = new WorldBlacklist(this); } + private void checkForOutdatedAPI() { + try { + Class checkForClass = Class.forName("org.bukkit.event.block.BlockDropItemEvent"); + Method newerAPIMethod = checkForClass.getMethod("getItems"); + Class checkForClassBaseComponent = Class.forName("net.md_5.bungee.api.chat.BaseComponent"); + } catch (ClassNotFoundException | NoSuchMethodException e) { + serverAPIOutdated = true; + String software = getServerSoftwareStr(); + getLogger().severe("You are running an older version of " + software + " that is not compatible with mcMMO, update your server software!"); + } + } + + private enum ServerSoftwareType { + PAPER, + SPIGOT, + CRAFTBUKKIT + } + + private ServerSoftwareType getServerSoftware() + { + if(Bukkit.getVersion().toLowerCase().contains("paper")) + return ServerSoftwareType.PAPER; + else if(Bukkit.getVersion().toLowerCase().contains("spigot")) + return ServerSoftwareType.SPIGOT; + else + return ServerSoftwareType.CRAFTBUKKIT; + } + + private String getServerSoftwareStr() + { + switch(getServerSoftware()) + { + case PAPER: + return "Paper"; + case SPIGOT: + return "Spigot"; + default: + return "CraftBukkit"; + } + } + @Override public void onLoad() { From 817b5364cfa9b77858d152ef05943af65ca81113 Mon Sep 17 00:00:00 2001 From: OverCrave Date: Thu, 18 Apr 2019 22:58:50 +0200 Subject: [PATCH 02/22] fix adminchat returning too early if send by console --- .../com/gmail/nossr50/commands/chat/ChatCommand.java | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) diff --git a/src/main/java/com/gmail/nossr50/commands/chat/ChatCommand.java b/src/main/java/com/gmail/nossr50/commands/chat/ChatCommand.java index 0d9b8fcd0..836835828 100644 --- a/src/main/java/com/gmail/nossr50/commands/chat/ChatCommand.java +++ b/src/main/java/com/gmail/nossr50/commands/chat/ChatCommand.java @@ -55,11 +55,10 @@ public abstract class ChatCommand implements TabExecutor { return true; case 1: - if (!CommandUtils.hasPlayerDataKey(sender)) { - return true; - } - if (CommandUtils.shouldEnableToggle(args[0])) { + if (!CommandUtils.hasPlayerDataKey(sender)) { + return true; + } if (CommandUtils.noConsoleUsage(sender)) { return true; } @@ -69,6 +68,9 @@ public abstract class ChatCommand implements TabExecutor { } if (CommandUtils.shouldDisableToggle(args[0])) { + if (!CommandUtils.hasPlayerDataKey(sender)) { + return true; + } if (CommandUtils.noConsoleUsage(sender)) { return true; } From ce9232970538d7b581e7d9308784ba02bc9b26bd Mon Sep 17 00:00:00 2001 From: OverCrave Date: Thu, 18 Apr 2019 22:59:52 +0200 Subject: [PATCH 03/22] fix it for real now --- .../java/com/gmail/nossr50/commands/chat/ChatCommand.java | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/src/main/java/com/gmail/nossr50/commands/chat/ChatCommand.java b/src/main/java/com/gmail/nossr50/commands/chat/ChatCommand.java index 836835828..b1d93685a 100644 --- a/src/main/java/com/gmail/nossr50/commands/chat/ChatCommand.java +++ b/src/main/java/com/gmail/nossr50/commands/chat/ChatCommand.java @@ -56,10 +56,10 @@ public abstract class ChatCommand implements TabExecutor { case 1: if (CommandUtils.shouldEnableToggle(args[0])) { - if (!CommandUtils.hasPlayerDataKey(sender)) { + if (CommandUtils.noConsoleUsage(sender)) { return true; } - if (CommandUtils.noConsoleUsage(sender)) { + if (!CommandUtils.hasPlayerDataKey(sender)) { return true; } @@ -68,10 +68,10 @@ public abstract class ChatCommand implements TabExecutor { } if (CommandUtils.shouldDisableToggle(args[0])) { - if (!CommandUtils.hasPlayerDataKey(sender)) { + if (CommandUtils.noConsoleUsage(sender)) { return true; } - if (CommandUtils.noConsoleUsage(sender)) { + if (!CommandUtils.hasPlayerDataKey(sender)) { return true; } From 45841218e6b38fb7355d55bb2b632c8bdbbc443f Mon Sep 17 00:00:00 2001 From: nossr50 Date: Thu, 18 Apr 2019 16:34:19 -0700 Subject: [PATCH 04/22] dev mode --- Changelog.txt | 4 ++++ pom.xml | 2 +- 2 files changed, 5 insertions(+), 1 deletion(-) diff --git a/Changelog.txt b/Changelog.txt index 08872a65f..73682f0d8 100644 --- a/Changelog.txt +++ b/Changelog.txt @@ -7,6 +7,10 @@ Key: ! Change - Removal +Version 2.1.46 + Fixed a bug where admin chat from console would fail to send (thanks OverCrave) + Updated hu_HU locale (thanks andris155) + Version 2.1.45 mcMMO will now check to see if the server version is incompatible and inform server admins on how to fix the problem. diff --git a/pom.xml b/pom.xml index 8152abcf7..60c5f2f51 100755 --- a/pom.xml +++ b/pom.xml @@ -2,7 +2,7 @@ 4.0.0 com.gmail.nossr50.mcMMO mcMMO - 2.1.45 + 2.1.46-SNAPSHOT mcMMO https://github.com/mcMMO-Dev/mcMMO From 4b34299648cf7567016e3f3be5677981c024334b Mon Sep 17 00:00:00 2001 From: Zed-I <47507923+Zed-I@users.noreply.github.com> Date: Fri, 19 Apr 2019 14:36:29 +0200 Subject: [PATCH 05/22] Fixed axe salvage bug Changes max quantity to 3 from 2 on all axes since they are crafted with 3 resources not 2 --- src/main/resources/salvage.vanilla.yml | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/src/main/resources/salvage.vanilla.yml b/src/main/resources/salvage.vanilla.yml index 73a853ecc..4f39ce75f 100644 --- a/src/main/resources/salvage.vanilla.yml +++ b/src/main/resources/salvage.vanilla.yml @@ -61,7 +61,7 @@ Salvageables: WOODEN_AXE: MinimumLevel: 0 XpMultiplier: .5 - MaximumQuantity: 2 + MaximumQuantity: 3 WOODEN_HOE: MinimumLevel: 0 XpMultiplier: .25 @@ -85,7 +85,7 @@ Salvageables: STONE_AXE: MinimumLevel: 0 XpMultiplier: .5 - MaximumQuantity: 2 + MaximumQuantity: 3 STONE_HOE: MinimumLevel: 0 XpMultiplier: .25 @@ -109,7 +109,7 @@ Salvageables: IRON_AXE: MinimumLevel: 0 XpMultiplier: 1 - MaximumQuantity: 2 + MaximumQuantity: 3 IRON_HOE: MinimumLevel: 0 XpMultiplier: .5 @@ -156,7 +156,7 @@ Salvageables: GOLDEN_AXE: MinimumLevel: 0 XpMultiplier: 8 - MaximumQuantity: 2 + MaximumQuantity: 3 GOLDEN_HOE: MinimumLevel: 0 XpMultiplier: 4 @@ -197,7 +197,7 @@ Salvageables: DIAMOND_AXE: MinimumLevel: 50 XpMultiplier: 1 - MaximumQuantity: 2 + MaximumQuantity: 3 DIAMOND_HOE: MinimumLevel: 50 XpMultiplier: .5 From bbf7ce9c57df730a02ee9d13c6cd896b495ee0ae Mon Sep 17 00:00:00 2001 From: Zed-I <47507923+Zed-I@users.noreply.github.com> Date: Fri, 19 Apr 2019 20:35:06 +0200 Subject: [PATCH 06/22] Fixed bug where skeleton heads would drop in instead of zombie/creeper heads on successful shake Creeper/zombie heads are now their own items and data is no longer used --- src/main/resources/treasures.yml | 10 +++------- 1 file changed, 3 insertions(+), 7 deletions(-) diff --git a/src/main/resources/treasures.yml b/src/main/resources/treasures.yml index 315b5f6b4..314bceff2 100755 --- a/src/main/resources/treasures.yml +++ b/src/main/resources/treasures.yml @@ -695,8 +695,7 @@ Shake: Drop_Chance: 49.0 Drop_Level: 0 CREEPER: - SKELETON_SKULL: - Data: 4 + CREEPER_HEAD: Amount: 1 XP: 0 Drop_Chance: 1.0 @@ -828,7 +827,6 @@ Shake: Drop_Level: 0 SKELETON: SKELETON_SKULL: - Data: 0 Amount: 1 XP: 0 Drop_Chance: 2.0 @@ -936,7 +934,6 @@ Shake: Drop_Level: 0 WITHER_SKELETON: WITHER_SKELETON_SKULL: - Data: 0 Amount: 1 XP: 0 Drop_Chance: 2.0 @@ -952,8 +949,7 @@ Shake: Drop_Chance: 49.0 Drop_Level: 0 ZOMBIE: - SKELETON_SKULL: - Data: 2 + ZOMBIE_HEAD: Amount: 1 XP: 0 Drop_Chance: 2.0 @@ -962,4 +958,4 @@ Shake: Amount: 1 XP: 0 Drop_Chance: 98.0 - Drop_Level: 0 \ No newline at end of file + Drop_Level: 0 From cae722e8c702ae47a84b8a3c0c3e97e53f54ebce Mon Sep 17 00:00:00 2001 From: nossr50 Date: Fri, 19 Apr 2019 14:34:18 -0700 Subject: [PATCH 07/22] Changelog upd --- Changelog.txt | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Changelog.txt b/Changelog.txt index 73682f0d8..bd6c87ea1 100644 --- a/Changelog.txt +++ b/Changelog.txt @@ -10,7 +10,7 @@ Key: Version 2.1.46 Fixed a bug where admin chat from console would fail to send (thanks OverCrave) Updated hu_HU locale (thanks andris155) - + Version 2.1.45 mcMMO will now check to see if the server version is incompatible and inform server admins on how to fix the problem. From 0b26d6c72cfb6bccf16967cfaa0b545f24085aa2 Mon Sep 17 00:00:00 2001 From: nossr50 Date: Fri, 19 Apr 2019 14:55:07 -0700 Subject: [PATCH 08/22] Fixed error related to Bleed, fixed missing default XP values for Herbalism and Woodcutting --- Changelog.txt | 12 ++++++ .../nossr50/listeners/EntityListener.java | 2 +- .../nossr50/util/skills/CombatUtils.java | 3 -- src/main/resources/experience.yml | 38 ++++++++++++++++--- 4 files changed, 45 insertions(+), 10 deletions(-) diff --git a/Changelog.txt b/Changelog.txt index bd6c87ea1..649dd1d29 100644 --- a/Changelog.txt +++ b/Changelog.txt @@ -8,9 +8,21 @@ Key: - Removal Version 2.1.46 + Fixed an error where bleed was setting health outside minimum values + [See NOTE] Fixed a bug where Creepers and Zombies were not dropping the correct heads from Shake (thanks Zed-I) + [See NOTE] Fixed a bug where salvage was not returning the correct amount of materials for AXE items (thanks Zed-I) + [See NOTE] Added missing STRIPPED_WOOD entries to experience.yml for Woodcutting + [See NOTE] Added about 15-20 missing entries to experience.yml for coral to Herbalism Fixed a bug where admin chat from console would fail to send (thanks OverCrave) + Reduced default XP values for DEAD_* coral plants from 30 -> 10 Updated hu_HU locale (thanks andris155) + NOTE: These bugfixes were related to default config values, to receive these changes you can either delete experience.yml, treasures.yml and salvage.vanilla.yml to generate new ones or make the necessary edits. + This is what the files should look like after being edited. + Experience Correct Default Config - https://paste.gg/p/anonymous/ff695df1417e4232957a3d176fd14ed4 + Salvage Correct Default Config - https://paste.gg/p/anonymous/c4eb2f4e66ed444e872021051760f3be + Treasures Correct Default Config - https://paste.gg/p/anonymous/b0120210f8c149958ca0303c68c19ebd + Version 2.1.45 mcMMO will now check to see if the server version is incompatible and inform server admins on how to fix the problem. diff --git a/src/main/java/com/gmail/nossr50/listeners/EntityListener.java b/src/main/java/com/gmail/nossr50/listeners/EntityListener.java index 649fcfa28..3dd490f38 100644 --- a/src/main/java/com/gmail/nossr50/listeners/EntityListener.java +++ b/src/main/java/com/gmail/nossr50/listeners/EntityListener.java @@ -246,7 +246,7 @@ public class EntityListener implements Listener { if(defender instanceof Player) { LivingEntity defLive = (LivingEntity) defender; - defLive.setHealth(defLive.getHealth() - event.getFinalDamage()); + defLive.setHealth(Math.max(0, (defLive.getHealth() - event.getFinalDamage()))); event.setCancelled(true); } diff --git a/src/main/java/com/gmail/nossr50/util/skills/CombatUtils.java b/src/main/java/com/gmail/nossr50/util/skills/CombatUtils.java index fbd9e8a13..5d42b0a12 100644 --- a/src/main/java/com/gmail/nossr50/util/skills/CombatUtils.java +++ b/src/main/java/com/gmail/nossr50/util/skills/CombatUtils.java @@ -451,9 +451,6 @@ public final class CombatUtils { } target.setMetadata(mcMMO.CUSTOM_DAMAGE_METAKEY, mcMMO.metadataValue); - - - target.damage(damage, attacker); // //IFrame storage diff --git a/src/main/resources/experience.yml b/src/main/resources/experience.yml index f668c5d34..837544069 100644 --- a/src/main/resources/experience.yml +++ b/src/main/resources/experience.yml @@ -252,6 +252,12 @@ Experience: Stripped_Jungle_Log: 100 Stripped_Acacia_Log: 90 Stripped_Dark_Oak_Log: 90 + Stripped_Oak_Wood: 70 + Stripped_Spruce_Wood: 80 + Stripped_Birch_Wood: 90 + Stripped_Jungle_Wood: 100 + Stripped_Acacia_Wood: 90 + Stripped_Dark_Oak_Wood: 90 Oak_Wood: 70 Spruce_Wood: 70 Birch_Wood: 70 @@ -266,16 +272,36 @@ Experience: Tall_Seagrass: 10 Kelp: 3 Kelp_Plant: 3 - Tube_Coral_Fan: 80 + Tube_Coral: 80 Brain_Coral: 90 Bubble_Coral: 75 Fire_Coral: 120 Horn_Coral: 175 - Dead_Tube_Coral: 30 - Dead_Brain_Coral: 30 - Dead_Bubble_Coral: 30 - Dead_Fire_Coral: 30 - Dead_Horn_Coral: 30 + Tube_Coral_Fan: 80 + Brain_Coral_Fan: 90 + Bubble_Coral_Fan: 75 + Fire_Coral_Fan: 120 + Horn_Coral_Fan: 175 + Tube_Coral_Wall_Fan: 80 + Brain_Coral_Wall_Fan: 90 + Bubble_Coral_Wall_Fan: 75 + Fire_Coral_Wall_Fan: 120 + Horn_Coral_Wall_Fan: 175 + Dead_Tube_Coral: 10 + Dead_Brain_Coral: 10 + Dead_Bubble_Coral: 10 + Dead_Fire_Coral: 10 + Dead_Horn_Coral: 10 + Dead_Tube_Coral_Fan: 10 + Dead_Brain_Coral_Fan: 10 + Dead_Bubble_Coral_Fan: 10 + Dead_Fire_Coral_Fan: 10 + Dead_Horn_Coral_Fan: 10 + Dead_Tube_Coral_Wall_Fan: 10 + Dead_Brain_Coral_Wall_Fan: 10 + Dead_Bubble_Coral_Wall_Fan: 10 + Dead_Fire_Coral_Wall_Fan: 10 + Dead_Horn_Coral_Wall_Fan: 10 Allium: 300 Azure_Bluet: 150 Beetroots_Ripe: 50 From 78fdfc1c35c1c74d046f49a69601db42cbae6ef2 Mon Sep 17 00:00:00 2001 From: nossr50 Date: Fri, 19 Apr 2019 17:56:59 -0700 Subject: [PATCH 09/22] Made improvements to the Party member list from /party --- Changelog.txt | 2 + .../commands/party/PartyInfoCommand.java | 2 + .../gmail/nossr50/datatypes/party/Party.java | 211 ++++++++++++++++-- 3 files changed, 197 insertions(+), 18 deletions(-) diff --git a/Changelog.txt b/Changelog.txt index 649dd1d29..5b68abb2c 100644 --- a/Changelog.txt +++ b/Changelog.txt @@ -8,6 +8,8 @@ Key: - Removal Version 2.1.46 + Party member lists now show the whole party, including offline players again. + Party lists now have special markers for players who are in shared XP range Fixed an error where bleed was setting health outside minimum values [See NOTE] Fixed a bug where Creepers and Zombies were not dropping the correct heads from Shake (thanks Zed-I) [See NOTE] Fixed a bug where salvage was not returning the correct amount of materials for AXE items (thanks Zed-I) diff --git a/src/main/java/com/gmail/nossr50/commands/party/PartyInfoCommand.java b/src/main/java/com/gmail/nossr50/commands/party/PartyInfoCommand.java index 0a8ddda48..ee9160676 100644 --- a/src/main/java/com/gmail/nossr50/commands/party/PartyInfoCommand.java +++ b/src/main/java/com/gmail/nossr50/commands/party/PartyInfoCommand.java @@ -130,5 +130,7 @@ public class PartyInfoCommand implements CommandExecutor { player.sendMessage(LocaleLoader.getString("Commands.Party.Members.Header")); player.sendMessage(LocaleLoader.getString("Commands.Party.MembersNear", nearMembers.size()+1, membersOnline)); player.sendMessage(party.createMembersList(player)); + + } } diff --git a/src/main/java/com/gmail/nossr50/datatypes/party/Party.java b/src/main/java/com/gmail/nossr50/datatypes/party/Party.java index 0c2ad94a4..98f90d4e2 100644 --- a/src/main/java/com/gmail/nossr50/datatypes/party/Party.java +++ b/src/main/java/com/gmail/nossr50/datatypes/party/Party.java @@ -3,12 +3,16 @@ package com.gmail.nossr50.datatypes.party; import com.gmail.nossr50.config.Config; import com.gmail.nossr50.config.experience.ExperienceConfig; import com.gmail.nossr50.datatypes.experience.FormulaType; +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; +import com.gmail.nossr50.util.player.UserManager; import com.gmail.nossr50.util.sounds.SoundManager; import com.gmail.nossr50.util.sounds.SoundType; +import org.bukkit.Bukkit; import org.bukkit.ChatColor; import org.bukkit.command.CommandSender; import org.bukkit.entity.Player; @@ -18,8 +22,15 @@ import java.util.ArrayList; import java.util.LinkedHashMap; import java.util.List; import java.util.UUID; +import java.util.stream.Collectors; public class Party { +// private static final String ONLINE_PLAYER_PREFIX = "★"; +// private static final String ONLINE_PLAYER_PREFIX = "●" + ChatColor.RESET; + private static final String ONLINE_PLAYER_PREFIX = "⬤"; +// private static final String OFFLINE_PLAYER_PREFIX = "☆"; + private static final String OFFLINE_PLAYER_PREFIX = "○"; +// private static final String OFFLINE_PLAYER_PREFIX = "⭕" + ChatColor.RESET; private final LinkedHashMap members = new LinkedHashMap(); private final List onlineMembers = new ArrayList(); @@ -324,36 +335,200 @@ public class Party { return this.getMembers().keySet().contains(uuid); } + /** + * Makes a formatted list of party members based on the perspective of a target player + * Players that are hidden will be shown as offline (formatted in the same way) + * Party leader will be formatted a specific way as well + * @param player target player to use as POV + * @return formatted list of party members from the POV of a player + */ public String createMembersList(Player player) { StringBuilder memberList = new StringBuilder(); - for (Player otherPlayer : this.getVisibleMembers(player)) { - String memberName = otherPlayer.getName(); + List onlineMembers = members.keySet().stream() + .filter(x -> Bukkit.getOfflinePlayer(x).isOnline()) + .collect(Collectors.toList()); - if (this.getLeader().getUniqueId().equals(otherPlayer.getUniqueId())) { - memberList.append(ChatColor.GOLD); + List offlineMembers = members.keySet().stream() + .filter(x -> !Bukkit.getOfflinePlayer(x).isOnline()) + .collect(Collectors.toList()); - if (otherPlayer == null) { - memberName = memberName.substring(0, 1) + ChatColor.GRAY + ChatColor.ITALIC + "" + memberName.substring(1); - } - } - else if (otherPlayer != null) { - memberList.append(ChatColor.WHITE); - } - else { - memberList.append(ChatColor.GRAY); - } + ArrayList visiblePartyList = new ArrayList<>(); + boolean isPartyLeaderOfflineOrHidden = false; + ArrayList offlineOrHiddenPartyList = new ArrayList<>(); - if (player.getName().equalsIgnoreCase(otherPlayer.getName())) { - memberList.append(ChatColor.ITALIC); - } + for(UUID onlineMember : onlineMembers) + { + Player onlinePlayer = Bukkit.getPlayer(onlineMember); - memberList.append(memberName).append(ChatColor.RESET).append(" "); + if(!isNotSamePerson(player.getUniqueId(), onlineMember) || player.canSee(onlinePlayer)) + { + visiblePartyList.add(onlineMember); + } else { + //Party leader and cannot be seen by this player + if(isNotSamePerson(leader.getUniqueId(), player.getUniqueId()) && onlineMember == leader.getUniqueId()) + isPartyLeaderOfflineOrHidden = true; + + offlineOrHiddenPartyList.add(onlineMember); + } } + //Add all the actually offline members + offlineOrHiddenPartyList.addAll(offlineMembers); + + /* BUILD THE PARTY LIST WITH FORMATTING */ + + String partyLeaderPrefix = + /*ChatColor.WHITE + + "[" + +*/ ChatColor.GOLD + + "♕" + /*+ ChatColor.WHITE + + "]"*/ + + ChatColor.RESET; + + //First add the party leader + memberList.append(partyLeaderPrefix); + + List nearbyPlayerList = getNearMembers(UserManager.getPlayer(player)); + + boolean useDisplayNames = Config.getInstance().getPartyDisplayNames(); + + if(isPartyLeaderOfflineOrHidden) + { + if(isNotSamePerson(player.getUniqueId(), leader.getUniqueId())) + applyOnlineAndRangeFormatting(memberList, false, false); + + memberList.append(ChatColor.GRAY) + .append(leader.getPlayerName()); + } + else { + if(isNotSamePerson(leader.getUniqueId(), player.getUniqueId())) + applyOnlineAndRangeFormatting(memberList, true, nearbyPlayerList.contains(Bukkit.getPlayer(leader.getUniqueId()))); + + if(useDisplayNames) { + memberList.append(Bukkit.getPlayer(leader.getUniqueId()).getDisplayName()); + } else { + memberList.append(ChatColor.GOLD) + .append(Bukkit.getPlayer(leader.getUniqueId()).getName()); + } + } + + //Space + memberList.append(" "); + + //Now do online members + for(UUID onlinePlayerUUID : visiblePartyList) + { + if(onlinePlayerUUID == leader.getUniqueId()) + continue; + + if(isNotSamePerson(onlinePlayerUUID, player.getUniqueId())) + applyOnlineAndRangeFormatting(memberList, true, nearbyPlayerList.contains(Bukkit.getPlayer(onlinePlayerUUID))); + + if(useDisplayNames) + { + memberList.append(Bukkit.getPlayer(onlinePlayerUUID).getDisplayName()); + } + else + { + //Color allies green, players dark aqua + memberList.append(ChatColor.GREEN) + .append(Bukkit.getPlayer(onlinePlayerUUID).getName()); + } + + memberList.append(" ").append(ChatColor.RESET); + } + + for(UUID offlineOrHiddenPlayer : offlineOrHiddenPartyList) + { + if(offlineOrHiddenPlayer == leader.getUniqueId()) + continue; + + applyOnlineAndRangeFormatting(memberList, false, false); + + memberList.append(ChatColor.GRAY) + .append(Bukkit.getOfflinePlayer(offlineOrHiddenPlayer).getName()) + .append(" ").append(ChatColor.RESET); + } + + +// for (Player otherPlayer : this.getVisibleMembers(player)) { +// String memberName = otherPlayer.getName(); +// +// if (this.getLeader().getUniqueId().equals(otherPlayer.getUniqueId())) { +// memberList.append(ChatColor.GOLD); +// +// if (otherPlayer == null) { +// memberName = memberName.substring(0, 1) + ChatColor.GRAY + ChatColor.ITALIC + "" + memberName.substring(1); +// } +// } +// else if (otherPlayer != null) { +// memberList.append(ChatColor.WHITE); +// } +// else { +// memberList.append(ChatColor.GRAY); +// } +// +// if (player.getName().equalsIgnoreCase(otherPlayer.getName())) { +// memberList.append(ChatColor.ITALIC); +// } +// +// memberList.append(memberName).append(ChatColor.RESET).append(" "); +// } + return memberList.toString(); } + private boolean isNotSamePerson(UUID onlinePlayerUUID, UUID uniqueId) { + return onlinePlayerUUID != uniqueId; + } + + private void applyOnlineAndRangeFormatting(StringBuilder stringBuilder, boolean isVisibleOrOnline, boolean isNear) + { + if(isVisibleOrOnline) + { + if(isNear) + { + stringBuilder.append(ChatColor.GREEN); + } else { + stringBuilder.append(ChatColor.GRAY); + } + +// stringBuilder.append(ChatColor.BOLD); + stringBuilder.append(ONLINE_PLAYER_PREFIX); + } else { + stringBuilder.append(ChatColor.GRAY); + stringBuilder.append(OFFLINE_PLAYER_PREFIX); + } + + stringBuilder.append(ChatColor.RESET); + } + + /** + * Get the near party members. + * + * @param mcMMOPlayer The player to check + * @return the near party members + */ + public List getNearMembers(McMMOPlayer mcMMOPlayer) { + List nearMembers = new ArrayList(); + Party party = mcMMOPlayer.getParty(); + + if (party != null) { + Player player = mcMMOPlayer.getPlayer(); + double range = Config.getInstance().getPartyShareRange(); + + for (Player member : party.getOnlineMembers()) { + if (!player.equals(member) && member.isValid() && Misc.isNear(player.getLocation(), member.getLocation(), range)) { + nearMembers.add(member); + } + } + } + + return nearMembers; + } + @Override public boolean equals(Object obj) { if (obj == null) { From 227fb49decb961dfef552ba84a416ab19d2069a3 Mon Sep 17 00:00:00 2001 From: nossr50 Date: Fri, 19 Apr 2019 17:59:00 -0700 Subject: [PATCH 10/22] 2.1.46 --- Changelog.txt | 2 ++ pom.xml | 2 +- 2 files changed, 3 insertions(+), 1 deletion(-) diff --git a/Changelog.txt b/Changelog.txt index 5b68abb2c..54b82584b 100644 --- a/Changelog.txt +++ b/Changelog.txt @@ -10,6 +10,8 @@ Key: Version 2.1.46 Party member lists now show the whole party, including offline players again. Party lists now have special markers for players who are in shared XP range + Party lists now have special markers for players who are offline + Party lists now have special markers for the party leader Fixed an error where bleed was setting health outside minimum values [See NOTE] Fixed a bug where Creepers and Zombies were not dropping the correct heads from Shake (thanks Zed-I) [See NOTE] Fixed a bug where salvage was not returning the correct amount of materials for AXE items (thanks Zed-I) diff --git a/pom.xml b/pom.xml index 60c5f2f51..59649853a 100755 --- a/pom.xml +++ b/pom.xml @@ -2,7 +2,7 @@ 4.0.0 com.gmail.nossr50.mcMMO mcMMO - 2.1.46-SNAPSHOT + 2.1.46 mcMMO https://github.com/mcMMO-Dev/mcMMO From 7506646862da1a2916273098c389e90f98930e46 Mon Sep 17 00:00:00 2001 From: nossr50 Date: Sun, 21 Apr 2019 16:56:26 -0700 Subject: [PATCH 11/22] Party NPE fix --- Changelog.txt | 3 +++ pom.xml | 2 +- .../com/gmail/nossr50/commands/party/PartyInfoCommand.java | 2 -- src/main/java/com/gmail/nossr50/datatypes/party/Party.java | 7 +++++-- .../com/gmail/nossr50/skills/mining/MiningManager.java | 2 +- 5 files changed, 10 insertions(+), 6 deletions(-) diff --git a/Changelog.txt b/Changelog.txt index 54b82584b..c2263ae74 100644 --- a/Changelog.txt +++ b/Changelog.txt @@ -7,6 +7,9 @@ Key: ! Change - Removal +Version 2.1.47 + Fix NPE when party leader is offline and players grab a party list + Version 2.1.46 Party member lists now show the whole party, including offline players again. Party lists now have special markers for players who are in shared XP range diff --git a/pom.xml b/pom.xml index 59649853a..b01836b52 100755 --- a/pom.xml +++ b/pom.xml @@ -2,7 +2,7 @@ 4.0.0 com.gmail.nossr50.mcMMO mcMMO - 2.1.46 + 2.1.47-SNAPSHOT mcMMO https://github.com/mcMMO-Dev/mcMMO diff --git a/src/main/java/com/gmail/nossr50/commands/party/PartyInfoCommand.java b/src/main/java/com/gmail/nossr50/commands/party/PartyInfoCommand.java index ee9160676..0a8ddda48 100644 --- a/src/main/java/com/gmail/nossr50/commands/party/PartyInfoCommand.java +++ b/src/main/java/com/gmail/nossr50/commands/party/PartyInfoCommand.java @@ -130,7 +130,5 @@ public class PartyInfoCommand implements CommandExecutor { player.sendMessage(LocaleLoader.getString("Commands.Party.Members.Header")); player.sendMessage(LocaleLoader.getString("Commands.Party.MembersNear", nearMembers.size()+1, membersOnline)); player.sendMessage(party.createMembersList(player)); - - } } diff --git a/src/main/java/com/gmail/nossr50/datatypes/party/Party.java b/src/main/java/com/gmail/nossr50/datatypes/party/Party.java index 98f90d4e2..f30d8b0a1 100644 --- a/src/main/java/com/gmail/nossr50/datatypes/party/Party.java +++ b/src/main/java/com/gmail/nossr50/datatypes/party/Party.java @@ -373,6 +373,9 @@ public class Party { } } + if(offlineMembers.contains(leader.getUniqueId())) + isPartyLeaderOfflineOrHidden = true; + //Add all the actually offline members offlineOrHiddenPartyList.addAll(offlineMembers); @@ -407,10 +410,10 @@ public class Party { applyOnlineAndRangeFormatting(memberList, true, nearbyPlayerList.contains(Bukkit.getPlayer(leader.getUniqueId()))); if(useDisplayNames) { - memberList.append(Bukkit.getPlayer(leader.getUniqueId()).getDisplayName()); + memberList.append(leader.getPlayerName()); } else { memberList.append(ChatColor.GOLD) - .append(Bukkit.getPlayer(leader.getUniqueId()).getName()); + .append(Bukkit.getOfflinePlayer(leader.getUniqueId())); } } diff --git a/src/main/java/com/gmail/nossr50/skills/mining/MiningManager.java b/src/main/java/com/gmail/nossr50/skills/mining/MiningManager.java index 3ab7d8bc4..cbec5563b 100644 --- a/src/main/java/com/gmail/nossr50/skills/mining/MiningManager.java +++ b/src/main/java/com/gmail/nossr50/skills/mining/MiningManager.java @@ -79,7 +79,7 @@ public class MiningManager extends SkillManager { SkillUtils.handleDurabilityChange(getPlayer().getInventory().getItemInMainHand(), Config.getInstance().getAbilityToolDamage()); } - if ((mcMMO.getModManager().isCustomMiningBlock(blockState) && !mcMMO.getModManager().getBlock(blockState).isDoubleDropEnabled()) || !Config.getInstance().getDoubleDropsEnabled(skill, material)) { + if ((mcMMO.getModManager().isCustomMiningBlock(blockState) && !mcMMO.getModManager().getBlock(blockState).isDoubleDropEnabled())) { return; } From b41637fbf88b2ec86809cc302ec1c957ac7aeb2c Mon Sep 17 00:00:00 2001 From: nossr50 Date: Sun, 21 Apr 2019 17:08:58 -0700 Subject: [PATCH 12/22] 2.1.47 --- pom.xml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pom.xml b/pom.xml index b01836b52..31f33958d 100755 --- a/pom.xml +++ b/pom.xml @@ -2,7 +2,7 @@ 4.0.0 com.gmail.nossr50.mcMMO mcMMO - 2.1.47-SNAPSHOT + 2.1.47 mcMMO https://github.com/mcMMO-Dev/mcMMO From 1c490cd4635d2bc83a014ae0b83cea9426dab494 Mon Sep 17 00:00:00 2001 From: nossr50 Date: Mon, 22 Apr 2019 23:54:02 -0700 Subject: [PATCH 13/22] 1.14 Compatibility (this build won't run on 1.13 anymore) --- Changelog.txt | 3 +++ pom.xml | 4 ++-- .../java/com/gmail/nossr50/util/BlockUtils.java | 14 ++++++++++++-- .../java/com/gmail/nossr50/util/ItemUtils.java | 9 ++++++--- 4 files changed, 23 insertions(+), 7 deletions(-) diff --git a/Changelog.txt b/Changelog.txt index c2263ae74..0591d2583 100644 --- a/Changelog.txt +++ b/Changelog.txt @@ -7,6 +7,9 @@ Key: ! Change - Removal +Version 2.1.48 + 1.14 Support + Version 2.1.47 Fix NPE when party leader is offline and players grab a party list diff --git a/pom.xml b/pom.xml index 31f33958d..bf6f5abb2 100755 --- a/pom.xml +++ b/pom.xml @@ -2,7 +2,7 @@ 4.0.0 com.gmail.nossr50.mcMMO mcMMO - 2.1.47 + 2.1.48-SNAPSHOT mcMMO https://github.com/mcMMO-Dev/mcMMO @@ -167,7 +167,7 @@ org.spigotmc spigot-api - 1.13.2-R0.1-SNAPSHOT + 1.14-pre5-SNAPSHOT provided diff --git a/src/main/java/com/gmail/nossr50/util/BlockUtils.java b/src/main/java/com/gmail/nossr50/util/BlockUtils.java index 66cef68f3..2ca26ee56 100644 --- a/src/main/java/com/gmail/nossr50/util/BlockUtils.java +++ b/src/main/java/com/gmail/nossr50/util/BlockUtils.java @@ -116,7 +116,18 @@ public final class BlockUtils { case JUNGLE_TRAPDOOR: case OAK_TRAPDOOR: case SPRUCE_TRAPDOOR: - case WALL_SIGN : + case ACACIA_SIGN: + case ACACIA_WALL_SIGN: + case BIRCH_SIGN: + case BIRCH_WALL_SIGN: + case DARK_OAK_SIGN: + case DARK_OAK_WALL_SIGN: + case JUNGLE_SIGN: + case JUNGLE_WALL_SIGN: + case SPRUCE_SIGN: + case SPRUCE_WALL_SIGN: + case OAK_SIGN: + case OAK_WALL_SIGN: case CRAFTING_TABLE: case BEACON : case ANVIL : @@ -218,7 +229,6 @@ public final class BlockUtils { case JUNGLE_TRAPDOOR: case OAK_TRAPDOOR: case SPRUCE_TRAPDOOR: - case WALL_SIGN : case CRAFTING_TABLE: case BEACON : case ANVIL : diff --git a/src/main/java/com/gmail/nossr50/util/ItemUtils.java b/src/main/java/com/gmail/nossr50/util/ItemUtils.java index 2ee2f1936..ca1aff840 100644 --- a/src/main/java/com/gmail/nossr50/util/ItemUtils.java +++ b/src/main/java/com/gmail/nossr50/util/ItemUtils.java @@ -552,6 +552,7 @@ public final class ItemUtils { * @return true if the item is a mining drop, false otherwise */ public static boolean isMiningDrop(ItemStack item) { + //TODO: 1.14 This needs to be updated switch (item.getType()) { case COAL: case COAL_ORE: @@ -582,6 +583,7 @@ public final class ItemUtils { * @return true if the item is a herbalism drop, false otherwise */ public static boolean isHerbalismDrop(ItemStack item) { + //TODO: 1.14 This needs to be updated switch (item.getType()) { case WHEAT: case WHEAT_SEEDS: @@ -594,8 +596,8 @@ public final class ItemUtils { case NETHER_WART: case BROWN_MUSHROOM: case RED_MUSHROOM: - case ROSE_RED: - case DANDELION_YELLOW: + case ROSE_BUSH: + case DANDELION: case CACTUS: case SUGAR_CANE: case MELON: @@ -620,6 +622,7 @@ public final class ItemUtils { * @return true if the item is a mob drop, false otherwise */ public static boolean isMobDrop(ItemStack item) { + //TODO: 1.14 This needs to be updated switch (item.getType()) { case STRING: case FEATHER: @@ -661,7 +664,7 @@ public final class ItemUtils { case ROTTEN_FLESH: case GOLD_NUGGET: case EGG: - case ROSE_RED: + case ROSE_BUSH: case COAL: return true; From 432a4aa3302c84fb042f310c73c0f914ff4324fd Mon Sep 17 00:00:00 2001 From: nossr50 Date: Tue, 23 Apr 2019 00:54:49 -0700 Subject: [PATCH 14/22] 1.14 is required for this version of mcMMO --- src/main/resources/plugin.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/main/resources/plugin.yml b/src/main/resources/plugin.yml index a42dbfbfd..019b0d191 100644 --- a/src/main/resources/plugin.yml +++ b/src/main/resources/plugin.yml @@ -16,7 +16,7 @@ website: https://www.mcmmo.org main: com.gmail.nossr50.mcMMO softdepend: [WorldGuard, CombatTag, HealthBar] load: STARTUP -api-version: 1.13 +api-version: 1.14 commands: mmoinfo: From 0adaa0ba6634b16c6d190cc1346cbb416dbc59be Mon Sep 17 00:00:00 2001 From: nossr50 Date: Tue, 23 Apr 2019 01:10:09 -0700 Subject: [PATCH 15/22] PlayerNotification now marked async --- Changelog.txt | 1 + .../nossr50/events/skills/McMMOPlayerNotificationEvent.java | 5 +++-- 2 files changed, 4 insertions(+), 2 deletions(-) diff --git a/Changelog.txt b/Changelog.txt index 0591d2583..86e46dec5 100644 --- a/Changelog.txt +++ b/Changelog.txt @@ -9,6 +9,7 @@ Key: Version 2.1.48 1.14 Support + (API) Player notification events are now marked async Version 2.1.47 Fix NPE when party leader is offline and players grab a party list diff --git a/src/main/java/com/gmail/nossr50/events/skills/McMMOPlayerNotificationEvent.java b/src/main/java/com/gmail/nossr50/events/skills/McMMOPlayerNotificationEvent.java index 1cb182dcc..ff354e233 100644 --- a/src/main/java/com/gmail/nossr50/events/skills/McMMOPlayerNotificationEvent.java +++ b/src/main/java/com/gmail/nossr50/events/skills/McMMOPlayerNotificationEvent.java @@ -5,13 +5,14 @@ import net.md_5.bungee.api.ChatMessageType; import net.md_5.bungee.api.chat.TextComponent; import org.bukkit.entity.Player; import org.bukkit.event.Cancellable; +import org.bukkit.event.Event; import org.bukkit.event.HandlerList; import org.bukkit.event.player.PlayerEvent; /** * This event is sent for when mcMMO informs a player about various important information */ -public class McMMOPlayerNotificationEvent extends PlayerEvent implements Cancellable { +public class McMMOPlayerNotificationEvent extends Event implements Cancellable { private boolean isCancelled; /* * Messages can be sent to both places, as configured in advanced.yml @@ -27,7 +28,7 @@ public class McMMOPlayerNotificationEvent extends PlayerEvent implements Cancell protected final NotificationType notificationType; public McMMOPlayerNotificationEvent(Player who, NotificationType notificationType, TextComponent notificationTextComponent, ChatMessageType chatMessageType, boolean isMessageAlsoBeingSentToChat) { - super(who); + super(true); this.notificationType = notificationType; this.notificationTextComponent = notificationTextComponent; this.chatMessageType = chatMessageType; From d862f7f7798e9134e923c57b373b8d6e852b1434 Mon Sep 17 00:00:00 2001 From: nossr50 Date: Tue, 23 Apr 2019 01:13:21 -0700 Subject: [PATCH 16/22] Tool lower task sync --- Changelog.txt | 1 - .../java/com/gmail/nossr50/datatypes/player/McMMOPlayer.java | 2 +- .../nossr50/events/skills/McMMOPlayerNotificationEvent.java | 2 +- 3 files changed, 2 insertions(+), 3 deletions(-) diff --git a/Changelog.txt b/Changelog.txt index 86e46dec5..0591d2583 100644 --- a/Changelog.txt +++ b/Changelog.txt @@ -9,7 +9,6 @@ Key: Version 2.1.48 1.14 Support - (API) Player notification events are now marked async Version 2.1.47 Fix NPE when party leader is offline and players grab a party list diff --git a/src/main/java/com/gmail/nossr50/datatypes/player/McMMOPlayer.java b/src/main/java/com/gmail/nossr50/datatypes/player/McMMOPlayer.java index cd89f8fd0..7cc518a51 100644 --- a/src/main/java/com/gmail/nossr50/datatypes/player/McMMOPlayer.java +++ b/src/main/java/com/gmail/nossr50/datatypes/player/McMMOPlayer.java @@ -910,7 +910,7 @@ public class McMMOPlayer { } setToolPreparationMode(tool, true); - new ToolLowerTask(this, tool).runTaskLaterAsynchronously(mcMMO.p, 4 * Misc.TICK_CONVERSION_FACTOR); + new ToolLowerTask(this, tool).runTaskLater(mcMMO.p, 4 * Misc.TICK_CONVERSION_FACTOR); } } diff --git a/src/main/java/com/gmail/nossr50/events/skills/McMMOPlayerNotificationEvent.java b/src/main/java/com/gmail/nossr50/events/skills/McMMOPlayerNotificationEvent.java index ff354e233..59114fc28 100644 --- a/src/main/java/com/gmail/nossr50/events/skills/McMMOPlayerNotificationEvent.java +++ b/src/main/java/com/gmail/nossr50/events/skills/McMMOPlayerNotificationEvent.java @@ -28,7 +28,7 @@ public class McMMOPlayerNotificationEvent extends Event implements Cancellable { protected final NotificationType notificationType; public McMMOPlayerNotificationEvent(Player who, NotificationType notificationType, TextComponent notificationTextComponent, ChatMessageType chatMessageType, boolean isMessageAlsoBeingSentToChat) { - super(true); + super(false); this.notificationType = notificationType; this.notificationTextComponent = notificationTextComponent; this.chatMessageType = chatMessageType; From 09cba965d3c7bbfb831fdf222f553b628117ff42 Mon Sep 17 00:00:00 2001 From: nossr50 Date: Tue, 23 Apr 2019 02:12:22 -0700 Subject: [PATCH 17/22] Switch to GSON since mojang lib does not exist in 1.14 --- .../gmail/nossr50/util/uuid/UUIDFetcher.java | 27 ++++++++++++------- 1 file changed, 17 insertions(+), 10 deletions(-) diff --git a/src/main/java/com/gmail/nossr50/util/uuid/UUIDFetcher.java b/src/main/java/com/gmail/nossr50/util/uuid/UUIDFetcher.java index 90bef4122..7bb023707 100644 --- a/src/main/java/com/gmail/nossr50/util/uuid/UUIDFetcher.java +++ b/src/main/java/com/gmail/nossr50/util/uuid/UUIDFetcher.java @@ -1,11 +1,10 @@ package com.gmail.nossr50.util.uuid; import com.google.common.collect.ImmutableList; -import org.json.simple.JSONArray; -import org.json.simple.JSONObject; -import org.json.simple.parser.JSONParser; +import com.google.gson.JsonArray; +import com.google.gson.JsonObject; +import com.google.gson.JsonPrimitive; -import java.io.InputStreamReader; import java.io.OutputStream; import java.net.HttpURLConnection; import java.net.URL; @@ -17,7 +16,6 @@ public class UUIDFetcher implements Callable> { private static final int PROFILES_PER_REQUEST = 50; private static final long RATE_LIMIT = 100L; private static final String PROFILE_URL = "https://api.mojang.com/profiles/minecraft"; - private final JSONParser jsonParser = new JSONParser(); private final List names; private final boolean rateLimiting; @@ -35,13 +33,22 @@ public class UUIDFetcher implements Callable> { int requests = (int) Math.ceil(names.size() / PROFILES_PER_REQUEST); for (int i = 0; i < requests; i++) { HttpURLConnection connection = createConnection(); - String body = JSONArray.toJSONString(names.subList(i * PROFILES_PER_REQUEST, Math.min((i + 1) * PROFILES_PER_REQUEST, names.size()))); + + List nameSubList = names.subList(i * PROFILES_PER_REQUEST, Math.min((i + 1) * PROFILES_PER_REQUEST, names.size())); + JsonArray array = new JsonArray(); + + for(String name : nameSubList) + { + JsonPrimitive element = new JsonPrimitive(name); + array.add(element); + } + + String body = array.getAsString(); writeBody(connection, body); - JSONArray array = (JSONArray) jsonParser.parse(new InputStreamReader(connection.getInputStream())); for (Object profile : array) { - JSONObject jsonProfile = (JSONObject) profile; - String id = (String) jsonProfile.get("id"); - String name = (String) jsonProfile.get("name"); + JsonObject jsonProfile = (JsonObject) profile; + String id = jsonProfile.get("id").getAsString(); + String name = jsonProfile.get("name").getAsString(); UUID uuid = UUIDFetcher.getUUID(id); uuidMap.put(name, uuid); } From 372ad1fac3f64ad6442b8e7a70f65c55fc681a78 Mon Sep 17 00:00:00 2001 From: nossr50 Date: Tue, 23 Apr 2019 03:37:43 -0700 Subject: [PATCH 18/22] Experience settings for 114 are now under Experience_114 in experience.yml --- Changelog.txt | 28 ++++++---- .../config/experience/ExperienceConfig.java | 53 ++++++++++--------- src/main/resources/experience.yml | 18 +++++-- 3 files changed, 59 insertions(+), 40 deletions(-) diff --git a/Changelog.txt b/Changelog.txt index 0591d2583..5c2fcbbba 100644 --- a/Changelog.txt +++ b/Changelog.txt @@ -1,14 +1,22 @@ -Changelog: -Versions without changelogs probably had very small misc fixes, like tweaks to the source code - -Key: - + Addition - = Fix - ! Change - - Removal - Version 2.1.48 - 1.14 Support + (1.14 Only) + 1.14 Support + Added Cats, Foxes, and Pandas to Taming XP rewards + Added Cats, Foxes, Pandas, Trader Llamas, Pillagers, and Ravagers to Combat XP rewards + "Experience" section of experience.yml has been renamed to "Experience_114" + + Dodge now gives 800 XP + Roll now gives 600 XP + Fall now gives 600 XP + + Dev Notes: + I will be making a write up soon explaining near future plans for mcMMO and what is going on with the config update, abstraction update, etc... + Due to some changes in 1.14, you will not be able to play the 1.14 version of mcMMO on a 1.13 server + I plan to support 1.13 for the time being, in the abstraction update I will expand compatible versions of mcMMO to include: 1.14 / 1.13.2 / 1.12.2 / 1.8.8 / Sponge 1.14 + It is not necessary to update your configs if you are upgrading from 1.13 -> 1.14, however if you had custom XP values in your experience.yml you will want to update your config. + Acrobatics XP was buffed since many AFK counter-measures were put into place to prevent repetitive grinding. + Experience node in experience.yml was renamed to "automatically" update configs for 1.14 + There are 4 updates planned for mcMMO, including a patreon rewards update, a large content update, a config update, and backwards compatibility for 1.13/1.12/1.8.8 and support for Sponge Version 2.1.47 Fix NPE when party leader is offline and players grab a party list diff --git a/src/main/java/com/gmail/nossr50/config/experience/ExperienceConfig.java b/src/main/java/com/gmail/nossr50/config/experience/ExperienceConfig.java index fdcb25198..972000808 100644 --- a/src/main/java/com/gmail/nossr50/config/experience/ExperienceConfig.java +++ b/src/main/java/com/gmail/nossr50/config/experience/ExperienceConfig.java @@ -87,18 +87,18 @@ public class ExperienceConfig extends AutoUpdateConfigLoader { /* Alchemy */ for (PotionStage potionStage : PotionStage.values()) { if (getPotionXP(potionStage) < 0) { - reason.add("Experience.Alchemy.Potion_Stage_" + potionStage.toNumerical() + " should be at least 0!"); + reason.add("Experience_114.Alchemy.Potion_Stage_" + potionStage.toNumerical() + " should be at least 0!"); } } /* Archery */ if (getArcheryDistanceMultiplier() < 0) { - reason.add("Experience.Archery.Distance_Multiplier should be at least 0!"); + reason.add("Experience_114.Archery.Distance_Multiplier should be at least 0!"); } /* Combat XP Multipliers */ if (getAnimalsXP() < 0) { - reason.add("Experience.Combat.Multiplier.Animals should be at least 0!"); + reason.add("Experience_114.Combat.Multiplier.Animals should be at least 0!"); } if (getDodgeXPModifier() < 0) { @@ -117,21 +117,21 @@ public class ExperienceConfig extends AutoUpdateConfigLoader { // TODO: Add validation for each fish type once enum is available. if (getFishingShakeXP() <= 0) { - reason.add("Experience.Fishing.Shake should be greater than 0!"); + reason.add("Experience_114.Fishing.Shake should be greater than 0!"); } /* Repair */ if (getRepairXPBase() <= 0) { - reason.add("Experience.Repair.Base should be greater than 0!"); + reason.add("Experience_114.Repair.Base should be greater than 0!"); } /* Taming */ if (getTamingXP(EntityType.WOLF) <= 0) { - reason.add("Experience.Taming.Animal_Taming.Wolf should be greater than 0!"); + reason.add("Experience_114.Taming.Animal_Taming.Wolf should be greater than 0!"); } if (getTamingXP(EntityType.OCELOT) <= 0) { - reason.add("Experience.Taming.Animal_Taming.Ocelot should be greater than 0!"); + reason.add("Experience_114.Taming.Animal_Taming.Ocelot should be greater than 0!"); } return noErrorsInConfig(reason); @@ -143,6 +143,7 @@ public class ExperienceConfig extends AutoUpdateConfigLoader { /* EXPLOIT TOGGLES */ public boolean isEndermanEndermiteFarmingPrevented() { return config.getBoolean("ExploitFix.EndermanEndermiteFarms", true); } + public boolean isPistonExploitPrevented() { return config.getBoolean("ExploitFix.Pistons", false); } public boolean isFishingExploitingPrevented() { return config.getBoolean("ExploitFix.Fishing", true); } public boolean isAcrobaticsExploitingPrevented() { return config.getBoolean("ExploitFix.Acrobatics", true); } @@ -187,18 +188,18 @@ public class ExperienceConfig extends AutoUpdateConfigLoader { */ /* General Settings */ - public boolean getExperienceGainsPlayerVersusPlayerEnabled() { return config.getBoolean("Experience.PVP.Rewards", true); } + public boolean getExperienceGainsPlayerVersusPlayerEnabled() { return config.getBoolean("Experience_114.PVP.Rewards", true); } /* Combat XP Multipliers */ - public double getCombatXP(EntityType entity) { return config.getDouble("Experience.Combat.Multiplier." + StringUtils.getPrettyEntityTypeString(entity).replace(" ", "_")); } - public double getAnimalsXP(EntityType entity) { return config.getDouble("Experience.Combat.Multiplier." + StringUtils.getPrettyEntityTypeString(entity).replace(" ", "_"), getAnimalsXP()); } - public double getAnimalsXP() { return config.getDouble("Experience.Combat.Multiplier.Animals", 1.0); } - public boolean hasCombatXP(EntityType entity) {return config.contains("Experience.Combat.Multiplier." + StringUtils.getPrettyEntityTypeString(entity).replace(" ", "_")); } + public double getCombatXP(EntityType entity) { return config.getDouble("Experience_114.Combat.Multiplier." + StringUtils.getPrettyEntityTypeString(entity).replace(" ", "_")); } + public double getAnimalsXP(EntityType entity) { return config.getDouble("Experience_114.Combat.Multiplier." + StringUtils.getPrettyEntityTypeString(entity).replace(" ", "_"), getAnimalsXP()); } + public double getAnimalsXP() { return config.getDouble("Experience_114.Combat.Multiplier.Animals", 1.0); } + public boolean hasCombatXP(EntityType entity) {return config.contains("Experience_114.Combat.Multiplier." + StringUtils.getPrettyEntityTypeString(entity).replace(" ", "_")); } /* Materials */ public int getXp(PrimarySkillType skill, Material data) { - String baseString = "Experience." + StringUtils.getCapitalized(skill.toString()) + "."; + String baseString = "Experience_114." + StringUtils.getCapitalized(skill.toString()) + "."; String explicitString = baseString + StringUtils.getExplicitConfigMaterialString(data); if (config.contains(explicitString)) return config.getInt(explicitString); @@ -214,7 +215,7 @@ public class ExperienceConfig extends AutoUpdateConfigLoader { /* Materials */ public int getXp(PrimarySkillType skill, BlockData data) { - String baseString = "Experience." + StringUtils.getCapitalized(skill.toString()) + "."; + String baseString = "Experience_114." + StringUtils.getCapitalized(skill.toString()) + "."; String explicitString = baseString + StringUtils.getExplicitConfigBlockDataString(data); if (config.contains(explicitString)) return config.getInt(explicitString); @@ -229,7 +230,7 @@ public class ExperienceConfig extends AutoUpdateConfigLoader { public boolean doesBlockGiveSkillXP(PrimarySkillType skill, Material data) { - String baseString = "Experience." + StringUtils.getCapitalized(skill.toString()) + "."; + String baseString = "Experience_114." + StringUtils.getCapitalized(skill.toString()) + "."; String explicitString = baseString + StringUtils.getExplicitConfigMaterialString(data); if (config.contains(explicitString)) return true; @@ -242,7 +243,7 @@ public class ExperienceConfig extends AutoUpdateConfigLoader { public boolean doesBlockGiveSkillXP(PrimarySkillType skill, BlockData data) { - String baseString = "Experience." + StringUtils.getCapitalized(skill.toString()) + "."; + String baseString = "Experience_114." + StringUtils.getCapitalized(skill.toString()) + "."; String explicitString = baseString + StringUtils.getExplicitConfigBlockDataString(data); if (config.contains(explicitString)) return true; @@ -305,27 +306,27 @@ public class ExperienceConfig extends AutoUpdateConfigLoader { } /* Acrobatics */ - public int getDodgeXPModifier() { return config.getInt("Experience.Acrobatics.Dodge", 120); } - public int getRollXPModifier() { return config.getInt("Experience.Acrobatics.Roll", 80); } - public int getFallXPModifier() { return config.getInt("Experience.Acrobatics.Fall", 120); } + public int getDodgeXPModifier() { return config.getInt("Experience_114.Acrobatics.Dodge", 120); } + public int getRollXPModifier() { return config.getInt("Experience_114.Acrobatics.Roll", 80); } + public int getFallXPModifier() { return config.getInt("Experience_114.Acrobatics.Fall", 120); } - public double getFeatherFallXPModifier() { return config.getDouble("Experience.Acrobatics.FeatherFall_Multiplier", 2.0); } + public double getFeatherFallXPModifier() { return config.getDouble("Experience_114.Acrobatics.FeatherFall_Multiplier", 2.0); } /* Alchemy */ - public double getPotionXP(PotionStage stage) { return config.getDouble("Experience.Alchemy.Potion_Stage_" + stage.toNumerical(), 10D); } + public double getPotionXP(PotionStage stage) { return config.getDouble("Experience_114.Alchemy.Potion_Stage_" + stage.toNumerical(), 10D); } /* Archery */ - public double getArcheryDistanceMultiplier() { return config.getDouble("Experience.Archery.Distance_Multiplier", 0.025); } + public double getArcheryDistanceMultiplier() { return config.getDouble("Experience_114.Archery.Distance_Multiplier", 0.025); } - public int getFishingShakeXP() { return config.getInt("Experience.Fishing.Shake", 50); } + public int getFishingShakeXP() { return config.getInt("Experience_114.Fishing.Shake", 50); } /* Repair */ - public double getRepairXPBase() { return config.getDouble("Experience.Repair.Base", 1000.0); } - public double getRepairXP(MaterialType repairMaterialType) { return config.getDouble("Experience.Repair." + StringUtils.getCapitalized(repairMaterialType.toString())); } + public double getRepairXPBase() { return config.getDouble("Experience_114.Repair.Base", 1000.0); } + public double getRepairXP(MaterialType repairMaterialType) { return config.getDouble("Experience_114.Repair." + StringUtils.getCapitalized(repairMaterialType.toString())); } /* Taming */ public int getTamingXP(EntityType type) { - return config.getInt("Experience.Taming.Animal_Taming." + StringUtils.getPrettyEntityTypeString(type)); + return config.getInt("Experience_114.Taming.Animal_Taming." + StringUtils.getPrettyEntityTypeString(type)); } } diff --git a/src/main/resources/experience.yml b/src/main/resources/experience.yml index 837544069..3df488eec 100644 --- a/src/main/resources/experience.yml +++ b/src/main/resources/experience.yml @@ -196,13 +196,13 @@ Conversion: # # Settings for XP distribution ### -Experience: +Experience_114: PVP: Rewards: true Acrobatics: - Dodge: 120 - Roll: 80 - Fall: 120 + Dodge: 800 + Roll: 600 + Fall: 600 # FeatherFall_Multiplier: Multiply Acrobatics XP by this value when wearing boots with the Feather Fall enchant FeatherFall_Multiplier: 2.0 @@ -418,6 +418,9 @@ Experience: Skeleton_Horse: 1000 Zombie_Horse: 1000 Parrot: 1100 + Cat: 500 + Fox: 1000 + Panda: 1000 Combat: Multiplier: Animals: 1.0 @@ -472,3 +475,10 @@ Experience: Drowned: 1.0 Dolphin: 1.3 Phantom: 4.0 + Cat: 1.0 + Fox: 1.0 + Panda: 1.0 + Pillager: 2.0 + Ravager: 4.0 + Trader_Llama: 1.0 + From cee0025147022cc976dddce9819e73317cf18989 Mon Sep 17 00:00:00 2001 From: nossr50 Date: Tue, 23 Apr 2019 03:52:48 -0700 Subject: [PATCH 19/22] Bonus XP for early combat levels --- Changelog.txt | 2 ++ .../java/com/gmail/nossr50/util/skills/CombatUtils.java | 9 +++++++++ 2 files changed, 11 insertions(+) diff --git a/Changelog.txt b/Changelog.txt index 5c2fcbbba..bbe5d7f9c 100644 --- a/Changelog.txt +++ b/Changelog.txt @@ -8,6 +8,8 @@ Version 2.1.48 Dodge now gives 800 XP Roll now gives 600 XP Fall now gives 600 XP + The first 10/100 levels of Combat skills now gives a small amount of bonus XP (this amount is not multiplied by any modifiers other than XP rate) + Note: First 10 in Standard, first 100 in Retro Dev Notes: I will be making a write up soon explaining near future plans for mcMMO and what is going on with the config update, abstraction update, etc... diff --git a/src/main/java/com/gmail/nossr50/util/skills/CombatUtils.java b/src/main/java/com/gmail/nossr50/util/skills/CombatUtils.java index 5d42b0a12..d6c781bb3 100644 --- a/src/main/java/com/gmail/nossr50/util/skills/CombatUtils.java +++ b/src/main/java/com/gmail/nossr50/util/skills/CombatUtils.java @@ -609,6 +609,15 @@ public final class CombatUtils { baseXP *= multiplier; + int earlyLevelBonusXPCap = mcMMO.isRetroModeEnabled() ? 100 : 10; + + //Give some bonus XP for low levels + if(baseXP != 0 && mcMMOPlayer.getSkillLevel(primarySkillType) < earlyLevelBonusXPCap) + { + baseXP += 50; + } + + if (baseXP != 0) { new AwardCombatXpTask(mcMMOPlayer, primarySkillType, baseXP, target, xpGainReason).runTaskLater(mcMMO.p, 0); } From b36c4b56c334c197f0f71329a41f5c2abc73da01 Mon Sep 17 00:00:00 2001 From: nossr50 Date: Tue, 23 Apr 2019 04:21:25 -0700 Subject: [PATCH 20/22] first 5 levels in all skills are now much easier to level --- Changelog.txt | 5 +++-- .../gmail/nossr50/listeners/SelfListener.java | 17 +++++++++++++++-- .../gmail/nossr50/util/skills/CombatUtils.java | 9 --------- 3 files changed, 18 insertions(+), 13 deletions(-) diff --git a/Changelog.txt b/Changelog.txt index bbe5d7f9c..ac9c51473 100644 --- a/Changelog.txt +++ b/Changelog.txt @@ -8,8 +8,9 @@ Version 2.1.48 Dodge now gives 800 XP Roll now gives 600 XP Fall now gives 600 XP - The first 10/100 levels of Combat skills now gives a small amount of bonus XP (this amount is not multiplied by any modifiers other than XP rate) - Note: First 10 in Standard, first 100 in Retro + + The first 5/50 levels of skills now give large amounts of XP so players get key early skills much faster + Note: First 50 in Standard, first 50 in Retro Dev Notes: I will be making a write up soon explaining near future plans for mcMMO and what is going on with the config update, abstraction update, etc... diff --git a/src/main/java/com/gmail/nossr50/listeners/SelfListener.java b/src/main/java/com/gmail/nossr50/listeners/SelfListener.java index dced8a07a..8c995bd48 100644 --- a/src/main/java/com/gmail/nossr50/listeners/SelfListener.java +++ b/src/main/java/com/gmail/nossr50/listeners/SelfListener.java @@ -102,8 +102,8 @@ public class SelfListener implements Listener { return; } - final float rawXp = event.getRawXpGained(); - if (rawXp < 0) { + + if (event.getRawXpGained() <= 0) { // Don't calculate for XP subtraction return; } @@ -112,6 +112,19 @@ public class SelfListener implements Listener { return; } + int earlyLevelBonusXPCap = mcMMO.isRetroModeEnabled() ? 50 : 5; + + int earlyGameBonusXP = 0; + + //Give some bonus XP for low levels + if(mcMMOPlayer.getSkillLevel(primarySkillType) < earlyLevelBonusXPCap) + { + earlyGameBonusXP += (mcMMOPlayer.getXpToLevel(primarySkillType) * 0.05); + event.setRawXpGained(event.getRawXpGained() + earlyGameBonusXP); + } + + final float rawXp = event.getRawXpGained(); + float guaranteedMinimum = ExperienceConfig.getInstance().getDiminishedReturnsCap() * rawXp; float modifiedThreshold = (float) (threshold / primarySkillType.getXpModifier() * ExperienceConfig.getInstance().getExperienceGainsGlobalMultiplier()); diff --git a/src/main/java/com/gmail/nossr50/util/skills/CombatUtils.java b/src/main/java/com/gmail/nossr50/util/skills/CombatUtils.java index d6c781bb3..5d42b0a12 100644 --- a/src/main/java/com/gmail/nossr50/util/skills/CombatUtils.java +++ b/src/main/java/com/gmail/nossr50/util/skills/CombatUtils.java @@ -609,15 +609,6 @@ public final class CombatUtils { baseXP *= multiplier; - int earlyLevelBonusXPCap = mcMMO.isRetroModeEnabled() ? 100 : 10; - - //Give some bonus XP for low levels - if(baseXP != 0 && mcMMOPlayer.getSkillLevel(primarySkillType) < earlyLevelBonusXPCap) - { - baseXP += 50; - } - - if (baseXP != 0) { new AwardCombatXpTask(mcMMOPlayer, primarySkillType, baseXP, target, xpGainReason).runTaskLater(mcMMO.p, 0); } From c07a29ba868a9f945df6d910f7ff2960e6b819e5 Mon Sep 17 00:00:00 2001 From: nossr50 Date: Tue, 23 Apr 2019 08:20:00 -0700 Subject: [PATCH 21/22] mcMMO should work on both 1.13 and 1.14 now --- Changelog.txt | 17 +- .../config/experience/ExperienceConfig.java | 52 +-- src/main/java/com/gmail/nossr50/mcMMO.java | 8 + .../com/gmail/nossr50/util/BlockUtils.java | 358 ++---------------- .../gmail/nossr50/util/MaterialMapStore.java | 351 +++++++++++++++++ src/main/resources/experience.yml | 2 +- src/main/resources/plugin.yml | 2 +- 7 files changed, 435 insertions(+), 355 deletions(-) create mode 100644 src/main/java/com/gmail/nossr50/util/MaterialMapStore.java diff --git a/Changelog.txt b/Changelog.txt index ac9c51473..95600d065 100644 --- a/Changelog.txt +++ b/Changelog.txt @@ -1,24 +1,21 @@ Version 2.1.48 - (1.14 Only) - 1.14 Support - Added Cats, Foxes, and Pandas to Taming XP rewards - Added Cats, Foxes, Pandas, Trader Llamas, Pillagers, and Ravagers to Combat XP rewards - "Experience" section of experience.yml has been renamed to "Experience_114" - + 1.14 Support + Added Cats, Foxes, and Pandas to Taming XP rewards + Added Cats, Foxes, Pandas, Trader Llamas, Pillagers, and Ravagers to Combat XP rewards + "Experience" section of experience.yml has been renamed to "Experience_Values" Dodge now gives 800 XP Roll now gives 600 XP Fall now gives 600 XP The first 5/50 levels of skills now give large amounts of XP so players get key early skills much faster - Note: First 50 in Standard, first 50 in Retro + Note: First 5 in Standard, first 50 in Retro Dev Notes: I will be making a write up soon explaining near future plans for mcMMO and what is going on with the config update, abstraction update, etc... - Due to some changes in 1.14, you will not be able to play the 1.14 version of mcMMO on a 1.13 server - I plan to support 1.13 for the time being, in the abstraction update I will expand compatible versions of mcMMO to include: 1.14 / 1.13.2 / 1.12.2 / 1.8.8 / Sponge 1.14 + Currently this version of mcMMO will work on both 1.13 and 1.14, in the abstraction update I will expand compatible versions of mcMMO to include: 1.14 / 1.13.2 / 1.12.2 / 1.8.8 / Sponge 1.14 It is not necessary to update your configs if you are upgrading from 1.13 -> 1.14, however if you had custom XP values in your experience.yml you will want to update your config. Acrobatics XP was buffed since many AFK counter-measures were put into place to prevent repetitive grinding. - Experience node in experience.yml was renamed to "automatically" update configs for 1.14 + Experience node in experience.yml was renamed to "automatically" update configs for the new stuff 1.14 There are 4 updates planned for mcMMO, including a patreon rewards update, a large content update, a config update, and backwards compatibility for 1.13/1.12/1.8.8 and support for Sponge Version 2.1.47 diff --git a/src/main/java/com/gmail/nossr50/config/experience/ExperienceConfig.java b/src/main/java/com/gmail/nossr50/config/experience/ExperienceConfig.java index 972000808..f0797ab62 100644 --- a/src/main/java/com/gmail/nossr50/config/experience/ExperienceConfig.java +++ b/src/main/java/com/gmail/nossr50/config/experience/ExperienceConfig.java @@ -87,18 +87,18 @@ public class ExperienceConfig extends AutoUpdateConfigLoader { /* Alchemy */ for (PotionStage potionStage : PotionStage.values()) { if (getPotionXP(potionStage) < 0) { - reason.add("Experience_114.Alchemy.Potion_Stage_" + potionStage.toNumerical() + " should be at least 0!"); + reason.add("Experience_Values.Alchemy.Potion_Stage_" + potionStage.toNumerical() + " should be at least 0!"); } } /* Archery */ if (getArcheryDistanceMultiplier() < 0) { - reason.add("Experience_114.Archery.Distance_Multiplier should be at least 0!"); + reason.add("Experience_Values.Archery.Distance_Multiplier should be at least 0!"); } /* Combat XP Multipliers */ if (getAnimalsXP() < 0) { - reason.add("Experience_114.Combat.Multiplier.Animals should be at least 0!"); + reason.add("Experience_Values.Combat.Multiplier.Animals should be at least 0!"); } if (getDodgeXPModifier() < 0) { @@ -117,21 +117,21 @@ public class ExperienceConfig extends AutoUpdateConfigLoader { // TODO: Add validation for each fish type once enum is available. if (getFishingShakeXP() <= 0) { - reason.add("Experience_114.Fishing.Shake should be greater than 0!"); + reason.add("Experience_Values.Fishing.Shake should be greater than 0!"); } /* Repair */ if (getRepairXPBase() <= 0) { - reason.add("Experience_114.Repair.Base should be greater than 0!"); + reason.add("Experience_Values.Repair.Base should be greater than 0!"); } /* Taming */ if (getTamingXP(EntityType.WOLF) <= 0) { - reason.add("Experience_114.Taming.Animal_Taming.Wolf should be greater than 0!"); + reason.add("Experience_Values.Taming.Animal_Taming.Wolf should be greater than 0!"); } if (getTamingXP(EntityType.OCELOT) <= 0) { - reason.add("Experience_114.Taming.Animal_Taming.Ocelot should be greater than 0!"); + reason.add("Experience_Values.Taming.Animal_Taming.Ocelot should be greater than 0!"); } return noErrorsInConfig(reason); @@ -188,18 +188,18 @@ public class ExperienceConfig extends AutoUpdateConfigLoader { */ /* General Settings */ - public boolean getExperienceGainsPlayerVersusPlayerEnabled() { return config.getBoolean("Experience_114.PVP.Rewards", true); } + public boolean getExperienceGainsPlayerVersusPlayerEnabled() { return config.getBoolean("Experience_Values.PVP.Rewards", true); } /* Combat XP Multipliers */ - public double getCombatXP(EntityType entity) { return config.getDouble("Experience_114.Combat.Multiplier." + StringUtils.getPrettyEntityTypeString(entity).replace(" ", "_")); } - public double getAnimalsXP(EntityType entity) { return config.getDouble("Experience_114.Combat.Multiplier." + StringUtils.getPrettyEntityTypeString(entity).replace(" ", "_"), getAnimalsXP()); } - public double getAnimalsXP() { return config.getDouble("Experience_114.Combat.Multiplier.Animals", 1.0); } - public boolean hasCombatXP(EntityType entity) {return config.contains("Experience_114.Combat.Multiplier." + StringUtils.getPrettyEntityTypeString(entity).replace(" ", "_")); } + public double getCombatXP(EntityType entity) { return config.getDouble("Experience_Values.Combat.Multiplier." + StringUtils.getPrettyEntityTypeString(entity).replace(" ", "_")); } + public double getAnimalsXP(EntityType entity) { return config.getDouble("Experience_Values.Combat.Multiplier." + StringUtils.getPrettyEntityTypeString(entity).replace(" ", "_"), getAnimalsXP()); } + public double getAnimalsXP() { return config.getDouble("Experience_Values.Combat.Multiplier.Animals", 1.0); } + public boolean hasCombatXP(EntityType entity) {return config.contains("Experience_Values.Combat.Multiplier." + StringUtils.getPrettyEntityTypeString(entity).replace(" ", "_")); } /* Materials */ public int getXp(PrimarySkillType skill, Material data) { - String baseString = "Experience_114." + StringUtils.getCapitalized(skill.toString()) + "."; + String baseString = "Experience_Values." + StringUtils.getCapitalized(skill.toString()) + "."; String explicitString = baseString + StringUtils.getExplicitConfigMaterialString(data); if (config.contains(explicitString)) return config.getInt(explicitString); @@ -215,7 +215,7 @@ public class ExperienceConfig extends AutoUpdateConfigLoader { /* Materials */ public int getXp(PrimarySkillType skill, BlockData data) { - String baseString = "Experience_114." + StringUtils.getCapitalized(skill.toString()) + "."; + String baseString = "Experience_Values." + StringUtils.getCapitalized(skill.toString()) + "."; String explicitString = baseString + StringUtils.getExplicitConfigBlockDataString(data); if (config.contains(explicitString)) return config.getInt(explicitString); @@ -230,7 +230,7 @@ public class ExperienceConfig extends AutoUpdateConfigLoader { public boolean doesBlockGiveSkillXP(PrimarySkillType skill, Material data) { - String baseString = "Experience_114." + StringUtils.getCapitalized(skill.toString()) + "."; + String baseString = "Experience_Values." + StringUtils.getCapitalized(skill.toString()) + "."; String explicitString = baseString + StringUtils.getExplicitConfigMaterialString(data); if (config.contains(explicitString)) return true; @@ -243,7 +243,7 @@ public class ExperienceConfig extends AutoUpdateConfigLoader { public boolean doesBlockGiveSkillXP(PrimarySkillType skill, BlockData data) { - String baseString = "Experience_114." + StringUtils.getCapitalized(skill.toString()) + "."; + String baseString = "Experience_Values." + StringUtils.getCapitalized(skill.toString()) + "."; String explicitString = baseString + StringUtils.getExplicitConfigBlockDataString(data); if (config.contains(explicitString)) return true; @@ -306,27 +306,27 @@ public class ExperienceConfig extends AutoUpdateConfigLoader { } /* Acrobatics */ - public int getDodgeXPModifier() { return config.getInt("Experience_114.Acrobatics.Dodge", 120); } - public int getRollXPModifier() { return config.getInt("Experience_114.Acrobatics.Roll", 80); } - public int getFallXPModifier() { return config.getInt("Experience_114.Acrobatics.Fall", 120); } + public int getDodgeXPModifier() { return config.getInt("Experience_Values.Acrobatics.Dodge", 120); } + public int getRollXPModifier() { return config.getInt("Experience_Values.Acrobatics.Roll", 80); } + public int getFallXPModifier() { return config.getInt("Experience_Values.Acrobatics.Fall", 120); } - public double getFeatherFallXPModifier() { return config.getDouble("Experience_114.Acrobatics.FeatherFall_Multiplier", 2.0); } + public double getFeatherFallXPModifier() { return config.getDouble("Experience_Values.Acrobatics.FeatherFall_Multiplier", 2.0); } /* Alchemy */ - public double getPotionXP(PotionStage stage) { return config.getDouble("Experience_114.Alchemy.Potion_Stage_" + stage.toNumerical(), 10D); } + public double getPotionXP(PotionStage stage) { return config.getDouble("Experience_Values.Alchemy.Potion_Stage_" + stage.toNumerical(), 10D); } /* Archery */ - public double getArcheryDistanceMultiplier() { return config.getDouble("Experience_114.Archery.Distance_Multiplier", 0.025); } + public double getArcheryDistanceMultiplier() { return config.getDouble("Experience_Values.Archery.Distance_Multiplier", 0.025); } - public int getFishingShakeXP() { return config.getInt("Experience_114.Fishing.Shake", 50); } + public int getFishingShakeXP() { return config.getInt("Experience_Values.Fishing.Shake", 50); } /* Repair */ - public double getRepairXPBase() { return config.getDouble("Experience_114.Repair.Base", 1000.0); } - public double getRepairXP(MaterialType repairMaterialType) { return config.getDouble("Experience_114.Repair." + StringUtils.getCapitalized(repairMaterialType.toString())); } + public double getRepairXPBase() { return config.getDouble("Experience_Values.Repair.Base", 1000.0); } + public double getRepairXP(MaterialType repairMaterialType) { return config.getDouble("Experience_Values.Repair." + StringUtils.getCapitalized(repairMaterialType.toString())); } /* Taming */ public int getTamingXP(EntityType type) { - return config.getInt("Experience_114.Taming.Animal_Taming." + StringUtils.getPrettyEntityTypeString(type)); + return config.getInt("Experience_Values.Taming.Animal_Taming." + StringUtils.getPrettyEntityTypeString(type)); } } diff --git a/src/main/java/com/gmail/nossr50/mcMMO.java b/src/main/java/com/gmail/nossr50/mcMMO.java index 1463f6e59..644ad1bce 100644 --- a/src/main/java/com/gmail/nossr50/mcMMO.java +++ b/src/main/java/com/gmail/nossr50/mcMMO.java @@ -72,6 +72,7 @@ public class mcMMO extends JavaPlugin { private static FormulaManager formulaManager; private static HolidayManager holidayManager; private static UpgradeManager upgradeManager; + private static MaterialMapStore materialMapStore; /* Blacklist */ private static WorldBlacklist worldBlacklist; @@ -243,10 +244,17 @@ public class mcMMO extends JavaPlugin { getServer().getPluginManager().disablePlugin(this); } + //Init Material Maps + materialMapStore = new MaterialMapStore(); + //Init the blacklist worldBlacklist = new WorldBlacklist(this); } + public static MaterialMapStore getMaterialMapStore() { + return materialMapStore; + } + private void checkForOutdatedAPI() { try { Class checkForClass = Class.forName("org.bukkit.event.block.BlockDropItemEvent"); diff --git a/src/main/java/com/gmail/nossr50/util/BlockUtils.java b/src/main/java/com/gmail/nossr50/util/BlockUtils.java index 2ca26ee56..61007bb07 100644 --- a/src/main/java/com/gmail/nossr50/util/BlockUtils.java +++ b/src/main/java/com/gmail/nossr50/util/BlockUtils.java @@ -19,16 +19,17 @@ import java.util.HashSet; public final class BlockUtils { - private BlockUtils() {} + private BlockUtils() { + } /** * Mark a block for giving bonus drops, double drops are used if triple is false + * * @param blockState target blockstate - * @param triple marks the block to give triple drops + * @param triple marks the block to give triple drops */ - public static void markDropsAsBonus(BlockState blockState, boolean triple) - { - if(triple) + public static void markDropsAsBonus(BlockState blockState, boolean triple) { + if (triple) blockState.setMetadata(mcMMO.tripleDrops, mcMMO.metadataValue); else blockState.setMetadata(mcMMO.doubleDrops, mcMMO.metadataValue); @@ -36,13 +37,12 @@ public final class BlockUtils { /** * Checks if a player successfully passed the double drop check + * * @param blockState the blockstate * @return true if the player succeeded in the check */ - public static boolean checkDoubleDrops(Player player, BlockState blockState, PrimarySkillType skillType, SubSkillType subSkillType) - { - if(Config.getInstance().getDoubleDropsEnabled(skillType, blockState.getType()) && Permissions.isSubSkillEnabled(player, subSkillType)) - { + public static boolean checkDoubleDrops(Player player, BlockState blockState, PrimarySkillType skillType, SubSkillType subSkillType) { + if (Config.getInstance().getDoubleDropsEnabled(skillType, blockState.getType()) && Permissions.isSubSkillEnabled(player, subSkillType)) { return RandomChanceUtil.checkRandomChanceExecutionSuccess(new RandomChanceSkill(player, subSkillType, true)); } @@ -52,8 +52,7 @@ public final class BlockUtils { /** * Checks to see if a given block awards XP. * - * @param blockState - * The {@link BlockState} of the block to check + * @param blockState The {@link BlockState} of the block to check * @return true if the block awards XP, false otherwise */ public static boolean shouldBeWatched(BlockState blockState) { @@ -63,245 +62,30 @@ public final class BlockUtils { /** * Check if a given block should allow for the activation of abilities * - * @param blockState - * The {@link BlockState} of the block to check + * @param blockState The {@link BlockState} of the block to check * @return true if the block should allow ability activation, false - * otherwise + * otherwise */ public static boolean canActivateAbilities(BlockState blockState) { - switch (blockState.getType()) { - case BLACK_BED: - case BLUE_BED: - case BROWN_BED: - case CYAN_BED: - case GRAY_BED: - case GREEN_BED: - case LIGHT_BLUE_BED: - case LIGHT_GRAY_BED: - case LIME_BED: - case MAGENTA_BED: - case ORANGE_BED: - case PINK_BED: - case PURPLE_BED: - case RED_BED: - case WHITE_BED: - case YELLOW_BED: - case BREWING_STAND : - case BOOKSHELF : - case CAKE: - case CHEST : - case DISPENSER : - case ENCHANTING_TABLE: - case ENDER_CHEST : - case OAK_FENCE_GATE: - case ACACIA_FENCE_GATE : - case DARK_OAK_FENCE_GATE : - case SPRUCE_FENCE_GATE : - case BIRCH_FENCE_GATE : - case JUNGLE_FENCE_GATE : - case FURNACE : - case JUKEBOX : - case LEVER : - case NOTE_BLOCK : - case STONE_BUTTON : - case OAK_BUTTON: - case BIRCH_BUTTON: - case ACACIA_BUTTON: - case DARK_OAK_BUTTON: - case JUNGLE_BUTTON: - case SPRUCE_BUTTON: - case ACACIA_TRAPDOOR: - case BIRCH_TRAPDOOR: - case DARK_OAK_TRAPDOOR: - case JUNGLE_TRAPDOOR: - case OAK_TRAPDOOR: - case SPRUCE_TRAPDOOR: - case ACACIA_SIGN: - case ACACIA_WALL_SIGN: - case BIRCH_SIGN: - case BIRCH_WALL_SIGN: - case DARK_OAK_SIGN: - case DARK_OAK_WALL_SIGN: - case JUNGLE_SIGN: - case JUNGLE_WALL_SIGN: - case SPRUCE_SIGN: - case SPRUCE_WALL_SIGN: - case OAK_SIGN: - case OAK_WALL_SIGN: - case CRAFTING_TABLE: - case BEACON : - case ANVIL : - case DROPPER : - case HOPPER : - case TRAPPED_CHEST : - case IRON_DOOR : - case IRON_TRAPDOOR : - case OAK_DOOR: - case ACACIA_DOOR : - case SPRUCE_DOOR : - case BIRCH_DOOR : - case JUNGLE_DOOR : - case DARK_OAK_DOOR : - case OAK_FENCE: - case ACACIA_FENCE : - case DARK_OAK_FENCE : - case BIRCH_FENCE : - case JUNGLE_FENCE : - case SPRUCE_FENCE : - case ARMOR_STAND : - case BLACK_SHULKER_BOX : - case BLUE_SHULKER_BOX : - case BROWN_SHULKER_BOX : - case CYAN_SHULKER_BOX : - case GRAY_SHULKER_BOX : - case GREEN_SHULKER_BOX : - case LIGHT_BLUE_SHULKER_BOX : - case LIME_SHULKER_BOX : - case MAGENTA_SHULKER_BOX : - case ORANGE_SHULKER_BOX : - case PINK_SHULKER_BOX : - case PURPLE_SHULKER_BOX : - case RED_SHULKER_BOX : - case LIGHT_GRAY_SHULKER_BOX: - case WHITE_SHULKER_BOX : - case YELLOW_SHULKER_BOX : - return false; - - default : - return !isMcMMOAnvil(blockState) && !mcMMO.getModManager().isCustomAbilityBlock(blockState); - } + return !mcMMO.getMaterialMapStore().isAbilityActivationBlackListed(blockState.getType()); } /** * Check if a given block should allow for the activation of tools * Activating a tool is step 1 of a 2 step process for super ability activation * - * @param blockState - * The {@link BlockState} of the block to check + * @param blockState The {@link BlockState} of the block to check * @return true if the block should allow ability activation, false - * otherwise + * otherwise */ public static boolean canActivateTools(BlockState blockState) { - switch (blockState.getType()) { - case BLACK_BED: - case BLUE_BED: - case BROWN_BED: - case CYAN_BED: - case GRAY_BED: - case GREEN_BED: - case LIGHT_BLUE_BED: - case LIGHT_GRAY_BED: - case LIME_BED: - case MAGENTA_BED: - case ORANGE_BED: - case PINK_BED: - case PURPLE_BED: - case RED_BED: - case WHITE_BED: - case YELLOW_BED: - case BREWING_STAND : - case BOOKSHELF : - case CAKE: - case CHEST : - case DISPENSER : - case ENCHANTING_TABLE: - case ENDER_CHEST : - case OAK_FENCE_GATE: - case ACACIA_FENCE_GATE : - case DARK_OAK_FENCE_GATE : - case SPRUCE_FENCE_GATE : - case BIRCH_FENCE_GATE : - case JUNGLE_FENCE_GATE : - case FURNACE : - case JUKEBOX : - case LEVER : - case NOTE_BLOCK : - case STONE_BUTTON : - case OAK_BUTTON: - case BIRCH_BUTTON: - case ACACIA_BUTTON: - case DARK_OAK_BUTTON: - case JUNGLE_BUTTON: - case SPRUCE_BUTTON: - case ACACIA_TRAPDOOR: - case BIRCH_TRAPDOOR: - case DARK_OAK_TRAPDOOR: - case JUNGLE_TRAPDOOR: - case OAK_TRAPDOOR: - case SPRUCE_TRAPDOOR: - case CRAFTING_TABLE: - case BEACON : - case ANVIL : - case DROPPER : - case HOPPER : - case TRAPPED_CHEST : - case IRON_DOOR : - case IRON_TRAPDOOR : - case OAK_DOOR: - case ACACIA_DOOR : - case SPRUCE_DOOR : - case BIRCH_DOOR : - case JUNGLE_DOOR : - case DARK_OAK_DOOR : - case OAK_FENCE: - case ACACIA_FENCE : - case DARK_OAK_FENCE : - case BIRCH_FENCE : - case JUNGLE_FENCE : - case SPRUCE_FENCE : - case ARMOR_STAND : - case BLACK_SHULKER_BOX : - case BLUE_SHULKER_BOX : - case BROWN_SHULKER_BOX : - case CYAN_SHULKER_BOX : - case GRAY_SHULKER_BOX : - case GREEN_SHULKER_BOX : - case LIGHT_BLUE_SHULKER_BOX : - case LIME_SHULKER_BOX : - case MAGENTA_SHULKER_BOX : - case ORANGE_SHULKER_BOX : - case PINK_SHULKER_BOX : - case PURPLE_SHULKER_BOX : - case RED_SHULKER_BOX : - case LIGHT_GRAY_SHULKER_BOX: - case WHITE_SHULKER_BOX : - case YELLOW_SHULKER_BOX : - case STRIPPED_ACACIA_LOG: - case STRIPPED_ACACIA_WOOD: - case STRIPPED_BIRCH_LOG: - case STRIPPED_BIRCH_WOOD: - case STRIPPED_DARK_OAK_LOG: - case STRIPPED_DARK_OAK_WOOD: - case STRIPPED_JUNGLE_LOG: - case STRIPPED_JUNGLE_WOOD: - case STRIPPED_OAK_LOG: - case STRIPPED_OAK_WOOD: - case STRIPPED_SPRUCE_LOG: - case STRIPPED_SPRUCE_WOOD: - case ACACIA_LOG: - case ACACIA_WOOD: - case BIRCH_LOG: - case BIRCH_WOOD: - case DARK_OAK_LOG: - case DARK_OAK_WOOD: - case JUNGLE_LOG: - case JUNGLE_WOOD: - case OAK_LOG: - case OAK_WOOD: - case SPRUCE_LOG: - case SPRUCE_WOOD: - return false; - - default : - return !isMcMMOAnvil(blockState) && !mcMMO.getModManager().isCustomAbilityBlock(blockState); - } + return !mcMMO.getMaterialMapStore().isToolActivationBlackListed(blockState.getType()); } /** * Check if a given block is an ore * - * @param blockState - * The {@link BlockState} of the block to check + * @param blockState The {@link BlockState} of the block to check * @return true if the block is an ore, false otherwise */ public static boolean isOre(BlockState blockState) { @@ -311,33 +95,17 @@ public final class BlockUtils { /** * Determine if a given block can be made mossy * - * @param blockState - * The {@link BlockState} of the block to check + * @param blockState The {@link BlockState} of the block to check * @return true if the block can be made mossy, false otherwise */ public static boolean canMakeMossy(BlockState blockState) { - switch (blockState.getType()) { - case COBBLESTONE : - case DIRT : - case GRASS_PATH : - return true; - - case STONE_BRICKS: - return true; - - case COBBLESTONE_WALL: - return true; - - default : - return false; - } + return mcMMO.getMaterialMapStore().isMossyWhiteListed(blockState.getType()); } /** * Determine if a given block should be affected by Green Terra * - * @param blockState - * The {@link BlockState} of the block to check + * @param blockState The {@link BlockState} of the block to check * @return true if the block should affected by Green Terra, false otherwise */ public static boolean affectedByGreenTerra(BlockState blockState) { @@ -351,10 +119,9 @@ public final class BlockUtils { /** * Determine if a given block should be affected by Super Breaker * - * @param blockState - * The {@link BlockState} of the block to check + * @param blockState The {@link BlockState} of the block to check * @return true if the block should affected by Super Breaker, false - * otherwise + * otherwise */ public static Boolean affectedBySuperBreaker(BlockState blockState) { if (ExperienceConfig.getInstance().doesBlockGiveSkillXP(PrimarySkillType.MINING, blockState.getBlockData())) @@ -366,10 +133,9 @@ public final class BlockUtils { /** * Determine if a given block should be affected by Giga Drill Breaker * - * @param blockState - * The {@link BlockState} of the block to check + * @param blockState The {@link BlockState} of the block to check * @return true if the block should affected by Giga Drill Breaker, false - * otherwise + * otherwise */ public static boolean affectedByGigaDrillBreaker(BlockState blockState) { if (ExperienceConfig.getInstance().doesBlockGiveSkillXP(PrimarySkillType.EXCAVATION, blockState.getBlockData())) @@ -380,8 +146,7 @@ public final class BlockUtils { /** * Check if a given block is a log * - * @param blockState - * The {@link BlockState} of the block to check + * @param blockState The {@link BlockState} of the block to check * @return true if the block is a log, false otherwise */ public static boolean isLog(BlockState blockState) { @@ -393,39 +158,26 @@ public final class BlockUtils { /** * Check if a given block is a leaf * - * @param blockState - * The {@link BlockState} of the block to check + * @param blockState The {@link BlockState} of the block to check * @return true if the block is a leaf, false otherwise */ public static boolean isLeaves(BlockState blockState) { - switch (blockState.getType()) { - case OAK_LEAVES: - case ACACIA_LEAVES: - case BIRCH_LEAVES: - case DARK_OAK_LEAVES: - case JUNGLE_LEAVES: - case SPRUCE_LEAVES: - return true; - - default : - return mcMMO.getModManager().isCustomLeaf(blockState); - } + return mcMMO.getMaterialMapStore().isLeavesWhiteListed(blockState.getType()); } /** * Determine if a given block should be affected by Flux Mining * - * @param blockState - * The {@link BlockState} of the block to check + * @param blockState The {@link BlockState} of the block to check * @return true if the block should affected by Flux Mining, false otherwise */ public static boolean affectedByFluxMining(BlockState blockState) { switch (blockState.getType()) { - case IRON_ORE : - case GOLD_ORE : + case IRON_ORE: + case GOLD_ORE: return true; - default : + default: return false; } } @@ -433,66 +185,39 @@ public final class BlockUtils { /** * Determine if a given block can activate Herbalism abilities * - * @param blockState - * The {@link BlockState} of the block to check + * @param blockState The {@link BlockState} of the block to check * @return true if the block can be activate Herbalism abilities, false - * otherwise + * otherwise */ public static boolean canActivateHerbalism(BlockState blockState) { - switch (blockState.getType()) { - case DIRT : - case GRASS : - case GRASS_PATH : - case FARMLAND: - return false; - - default : - return true; - } + return mcMMO.getMaterialMapStore().isHerbalismAbilityWhiteListed(blockState.getType()); } /** * Determine if a given block should be affected by Block Cracker * - * @param blockState - * The {@link BlockState} of the block to check + * @param blockState The {@link BlockState} of the block to check * @return true if the block should affected by Block Cracker, false - * otherwise + * otherwise */ public static boolean affectedByBlockCracker(BlockState blockState) { - switch (blockState.getType()) { - case STONE_BRICKS: - return true; - - default : - return false; - } + return mcMMO.getMaterialMapStore().isBlockCrackerWhiteListed(blockState.getType()); } /** * Determine if a given block can be made into Mycelium * - * @param blockState - * The {@link BlockState} of the block to check + * @param blockState The {@link BlockState} of the block to check * @return true if the block can be made into Mycelium, false otherwise */ public static boolean canMakeShroomy(BlockState blockState) { - switch (blockState.getType()) { - case DIRT : - case GRASS : - case GRASS_PATH : - return true; - - default : - return false; - } + return mcMMO.getMaterialMapStore().isShroomyWhiteListed(blockState.getType()); } /** * Determine if a given block is an mcMMO anvil * - * @param blockState - * The {@link BlockState} of the block to check + * @param blockState The {@link BlockState} of the block to check * @return true if the block is an mcMMO anvil, false otherwise */ public static boolean isMcMMOAnvil(BlockState blockState) { @@ -528,8 +253,7 @@ public final class BlockUtils { BlockData data = blockState.getBlockData(); if (data.getMaterial() == Material.CACTUS || data.getMaterial() == Material.SUGAR_CANE) return true; - if (data instanceof Ageable) - { + if (data instanceof Ageable) { Ageable ageable = (Ageable) data; return ageable.getAge() == ageable.getMaximumAge(); } diff --git a/src/main/java/com/gmail/nossr50/util/MaterialMapStore.java b/src/main/java/com/gmail/nossr50/util/MaterialMapStore.java new file mode 100644 index 000000000..e9a30066e --- /dev/null +++ b/src/main/java/com/gmail/nossr50/util/MaterialMapStore.java @@ -0,0 +1,351 @@ +package com.gmail.nossr50.util; + +import org.bukkit.Material; + +import java.util.HashSet; + +/** + * Stores hash tables for item and block names + * This allows for better support across multiple versions of Minecraft + * + * This is a temporary class, mcMMO is spaghetti and I'l clean it up later + * + */ +public class MaterialMapStore { + + private HashSet abilityBlackList; + private HashSet toolBlackList; + private HashSet mossyWhiteList; + private HashSet leavesWhiteList; + private HashSet herbalismAbilityBlackList; + private HashSet blockCrackerWhiteList; + private HashSet canMakeShroomyWhiteList; + + public MaterialMapStore() + { + abilityBlackList = new HashSet<>(); + toolBlackList = new HashSet<>(); + mossyWhiteList = new HashSet<>(); + leavesWhiteList = new HashSet<>(); + herbalismAbilityBlackList = new HashSet<>(); + blockCrackerWhiteList = new HashSet<>(); + canMakeShroomyWhiteList = new HashSet<>(); + + fillHardcodedHashSets(); + } + + public boolean isAbilityActivationBlackListed(Material material) + { + return abilityBlackList.contains(material.getKey().getKey()); + } + + public boolean isToolActivationBlackListed(Material material) + { + return toolBlackList.contains(material.getKey().getKey()); + } + + public boolean isMossyWhiteListed(Material material) + { + return mossyWhiteList.contains(material.getKey().getKey()); + } + + public boolean isLeavesWhiteListed(Material material) + { + return leavesWhiteList.contains(material.getKey().getKey()); + } + + public boolean isHerbalismAbilityWhiteListed(Material material) + { + return herbalismAbilityBlackList.contains(material.getKey().getKey()); + } + + public boolean isBlockCrackerWhiteListed(Material material) + { + return blockCrackerWhiteList.contains(material.getKey().getKey()); + } + + public boolean isShroomyWhiteListed(Material material) + { + return canMakeShroomyWhiteList.contains(material.getKey().getKey()); + } + + private void fillHardcodedHashSets() + { + fillAbilityBlackList(); + filltoolBlackList(); + fillMossyWhiteList(); + fillLeavesWhiteList(); + fillHerbalismAbilityBlackList(); + fillBlockCrackerWhiteList(); + fillShroomyWhiteList(); + } + + private void fillShroomyWhiteList() + { + canMakeShroomyWhiteList.add("dirt"); + canMakeShroomyWhiteList.add("grass"); + canMakeShroomyWhiteList.add("grass_path"); + } + + private void fillBlockCrackerWhiteList() + { + blockCrackerWhiteList.add("stone_bricks"); + } + + private void fillHerbalismAbilityBlackList() + { + herbalismAbilityBlackList.add("dirt"); + herbalismAbilityBlackList.add("grass"); + herbalismAbilityBlackList.add("grass_path"); + herbalismAbilityBlackList.add("farmland"); + } + + private void fillLeavesWhiteList() + { + leavesWhiteList.add("oak_leaves"); + leavesWhiteList.add("acacia_leaves"); + leavesWhiteList.add("birch_leaves"); + leavesWhiteList.add("dark_oak_leaves"); + leavesWhiteList.add("jungle_leaves"); + leavesWhiteList.add("spruce_leaves"); + } + + private void fillMossyWhiteList() + { + mossyWhiteList.add("cobblestone"); + mossyWhiteList.add("dirt"); + mossyWhiteList.add("grass_path"); + mossyWhiteList.add("stone_bricks"); + mossyWhiteList.add("cobblestone_wall"); + } + + private void fillAbilityBlackList() + { + abilityBlackList.add("black_bed"); + abilityBlackList.add("blue_bed"); + abilityBlackList.add("brown_bed"); + abilityBlackList.add("cyan_bed"); + abilityBlackList.add("gray_bed"); + abilityBlackList.add("green_bed"); + abilityBlackList.add("light_blue_bed"); + abilityBlackList.add("light_gray_bed"); + abilityBlackList.add("lime_bed"); + abilityBlackList.add("magenta_bed"); + abilityBlackList.add("orange_bed"); + abilityBlackList.add("pink_bed"); + abilityBlackList.add("purple_bed"); + abilityBlackList.add("red_bed"); + abilityBlackList.add("white_bed"); + abilityBlackList.add("yellow_bed"); + abilityBlackList.add("brewing_stand"); + abilityBlackList.add("bookshelf"); + abilityBlackList.add("cake"); + abilityBlackList.add("chest"); + abilityBlackList.add("dispenser"); + abilityBlackList.add("enchanting_table"); + abilityBlackList.add("ender_chest"); + abilityBlackList.add("oak_fence_gate"); + abilityBlackList.add("acacia_fence_gate"); + abilityBlackList.add("dark_oak_fence_gate"); + abilityBlackList.add("spruce_fence_gate"); + abilityBlackList.add("birch_fence_gate"); + abilityBlackList.add("jungle_fence_gate"); + abilityBlackList.add("furnace"); + abilityBlackList.add("jukebox"); + abilityBlackList.add("lever"); + abilityBlackList.add("note_block"); + abilityBlackList.add("stone_button"); + abilityBlackList.add("oak_button"); + abilityBlackList.add("birch_button"); + abilityBlackList.add("acacia_button"); + abilityBlackList.add("dark_oak_button"); + abilityBlackList.add("jungle_button"); + abilityBlackList.add("spruce_button"); + abilityBlackList.add("acacia_trapdoor"); + abilityBlackList.add("birch_trapdoor"); + abilityBlackList.add("dark_oak_trapdoor"); + abilityBlackList.add("jungle_trapdoor"); + abilityBlackList.add("oak_trapdoor"); + abilityBlackList.add("spruce_trapdoor"); + abilityBlackList.add("acacia_sign"); + abilityBlackList.add("acacia_wall_sign"); + abilityBlackList.add("birch_sign"); + abilityBlackList.add("birch_wall_sign"); + abilityBlackList.add("dark_oak_sign"); + abilityBlackList.add("dark_oak_wall_sign"); + abilityBlackList.add("jungle_sign"); + abilityBlackList.add("jungle_wall_sign"); + abilityBlackList.add("spruce_sign"); + abilityBlackList.add("spruce_wall_sign"); + abilityBlackList.add("oak_sign"); + abilityBlackList.add("oak_wall_sign"); + abilityBlackList.add("crafting_table"); + abilityBlackList.add("beacon"); + abilityBlackList.add("anvil"); + abilityBlackList.add("dropper"); + abilityBlackList.add("hopper"); + abilityBlackList.add("trapped_chest"); + abilityBlackList.add("iron_door"); + abilityBlackList.add("iron_trapdoor"); + abilityBlackList.add("oak_door"); + abilityBlackList.add("acacia_door"); + abilityBlackList.add("spruce_door"); + abilityBlackList.add("birch_door"); + abilityBlackList.add("jungle_door"); + abilityBlackList.add("dark_oak_door"); + abilityBlackList.add("oak_fence"); + abilityBlackList.add("acacia_fence"); + abilityBlackList.add("dark_oak_fence"); + abilityBlackList.add("birch_fence"); + abilityBlackList.add("jungle_fence"); + abilityBlackList.add("spruce_fence"); + abilityBlackList.add("armor_stand"); + abilityBlackList.add("black_shulker_box"); + abilityBlackList.add("blue_shulker_box"); + abilityBlackList.add("brown_shulker_box"); + abilityBlackList.add("cyan_shulker_box"); + abilityBlackList.add("gray_shulker_box"); + abilityBlackList.add("green_shulker_box"); + abilityBlackList.add("light_blue_shulker_box"); + abilityBlackList.add("lime_shulker_box"); + abilityBlackList.add("magenta_shulker_box"); + abilityBlackList.add("orange_shulker_box"); + abilityBlackList.add("pink_shulker_box"); + abilityBlackList.add("purple_shulker_box"); + abilityBlackList.add("red_shulker_box"); + abilityBlackList.add("light_gray_shulker_box"); + abilityBlackList.add("white_shulker_box"); + abilityBlackList.add("yellow_shulker_box"); + abilityBlackList.add("wall_sign"); //1.13 and lower? + abilityBlackList.add("sign"); //1.13 and lower? + } + + private void filltoolBlackList() + { + //TODO: Add anvils / missing logs + toolBlackList.add("black_bed"); + toolBlackList.add("blue_bed"); + toolBlackList.add("brown_bed"); + toolBlackList.add("cyan_bed"); + toolBlackList.add("gray_bed"); + toolBlackList.add("green_bed"); + toolBlackList.add("light_blue_bed"); + toolBlackList.add("light_gray_bed"); + toolBlackList.add("lime_bed"); + toolBlackList.add("magenta_bed"); + toolBlackList.add("orange_bed"); + toolBlackList.add("pink_bed"); + toolBlackList.add("purple_bed"); + toolBlackList.add("red_bed"); + toolBlackList.add("white_bed"); + toolBlackList.add("yellow_bed"); + toolBlackList.add("brewing_stand"); + toolBlackList.add("bookshelf"); + toolBlackList.add("cake"); + toolBlackList.add("chest"); + toolBlackList.add("dispenser"); + toolBlackList.add("enchanting_table"); + toolBlackList.add("ender_chest"); + toolBlackList.add("oak_fence_gate"); + toolBlackList.add("acacia_fence_gate"); + toolBlackList.add("dark_oak_fence_gate"); + toolBlackList.add("spruce_fence_gate"); + toolBlackList.add("birch_fence_gate"); + toolBlackList.add("jungle_fence_gate"); + toolBlackList.add("furnace"); + toolBlackList.add("jukebox"); + toolBlackList.add("lever"); + toolBlackList.add("note_block"); + toolBlackList.add("stone_button"); + toolBlackList.add("oak_button"); + toolBlackList.add("birch_button"); + toolBlackList.add("acacia_button"); + toolBlackList.add("dark_oak_button"); + toolBlackList.add("jungle_button"); + toolBlackList.add("spruce_button"); + toolBlackList.add("acacia_trapdoor"); + toolBlackList.add("birch_trapdoor"); + toolBlackList.add("dark_oak_trapdoor"); + toolBlackList.add("jungle_trapdoor"); + toolBlackList.add("oak_trapdoor"); + toolBlackList.add("spruce_trapdoor"); + toolBlackList.add("crafting_table"); + toolBlackList.add("beacon"); + toolBlackList.add("anvil"); + toolBlackList.add("dropper"); + toolBlackList.add("hopper"); + toolBlackList.add("trapped_chest"); + toolBlackList.add("iron_door"); + toolBlackList.add("iron_trapdoor"); + toolBlackList.add("oak_door"); + toolBlackList.add("acacia_door"); + toolBlackList.add("spruce_door"); + toolBlackList.add("birch_door"); + toolBlackList.add("jungle_door"); + toolBlackList.add("dark_oak_door"); + toolBlackList.add("oak_fence"); + toolBlackList.add("acacia_fence"); + toolBlackList.add("dark_oak_fence"); + toolBlackList.add("birch_fence"); + toolBlackList.add("jungle_fence"); + toolBlackList.add("spruce_fence"); + toolBlackList.add("armor_stand"); + toolBlackList.add("black_shulker_box"); + toolBlackList.add("blue_shulker_box"); + toolBlackList.add("brown_shulker_box"); + toolBlackList.add("cyan_shulker_box"); + toolBlackList.add("gray_shulker_box"); + toolBlackList.add("green_shulker_box"); + toolBlackList.add("light_blue_shulker_box"); + toolBlackList.add("lime_shulker_box"); + toolBlackList.add("magenta_shulker_box"); + toolBlackList.add("orange_shulker_box"); + toolBlackList.add("pink_shulker_box"); + toolBlackList.add("purple_shulker_box"); + toolBlackList.add("red_shulker_box"); + toolBlackList.add("light_gray_shulker_box"); + toolBlackList.add("white_shulker_box"); + toolBlackList.add("yellow_shulker_box"); + toolBlackList.add("acacia_sign"); + toolBlackList.add("acacia_wall_sign"); + toolBlackList.add("birch_sign"); + toolBlackList.add("birch_wall_sign"); + toolBlackList.add("dark_oak_sign"); + toolBlackList.add("dark_oak_wall_sign"); + toolBlackList.add("jungle_sign"); + toolBlackList.add("jungle_wall_sign"); + toolBlackList.add("spruce_sign"); + toolBlackList.add("spruce_wall_sign"); + toolBlackList.add("oak_sign"); + toolBlackList.add("oak_wall_sign"); + toolBlackList.add("stripped_acacia_log"); + toolBlackList.add("stripped_acacia_wood"); + toolBlackList.add("stripped_birch_log"); + toolBlackList.add("stripped_birch_wood"); + toolBlackList.add("stripped_dark_oak_log"); + toolBlackList.add("stripped_dark_oak_wood"); + toolBlackList.add("stripped_jungle_log"); + toolBlackList.add("stripped_jungle_wood"); + toolBlackList.add("stripped_oak_log"); + toolBlackList.add("stripped_oak_wood"); + toolBlackList.add("stripped_spruce_log"); + toolBlackList.add("stripped_spruce_wood"); + toolBlackList.add("acacia_log"); + toolBlackList.add("acacia_wood"); + toolBlackList.add("birch_log"); + toolBlackList.add("birch_wood"); + toolBlackList.add("dark_oak_log"); + toolBlackList.add("dark_oak_wood"); + toolBlackList.add("jungle_log"); + toolBlackList.add("jungle_wood"); + toolBlackList.add("oak_log"); + toolBlackList.add("oak_wood"); + toolBlackList.add("spruce_log"); + toolBlackList.add("spruce_wood"); + } + + private void addToHashSet(String string, HashSet stringHashSet) + { + stringHashSet.add(string.toLowerCase()); + } +} diff --git a/src/main/resources/experience.yml b/src/main/resources/experience.yml index 3df488eec..78854d081 100644 --- a/src/main/resources/experience.yml +++ b/src/main/resources/experience.yml @@ -196,7 +196,7 @@ Conversion: # # Settings for XP distribution ### -Experience_114: +Experience_Values: PVP: Rewards: true Acrobatics: diff --git a/src/main/resources/plugin.yml b/src/main/resources/plugin.yml index 019b0d191..a42dbfbfd 100644 --- a/src/main/resources/plugin.yml +++ b/src/main/resources/plugin.yml @@ -16,7 +16,7 @@ website: https://www.mcmmo.org main: com.gmail.nossr50.mcMMO softdepend: [WorldGuard, CombatTag, HealthBar] load: STARTUP -api-version: 1.14 +api-version: 1.13 commands: mmoinfo: From 18d698aad27ce2e4aa6b82c9bd38273ee3c0585a Mon Sep 17 00:00:00 2001 From: nossr50 Date: Wed, 24 Apr 2019 16:40:28 -0700 Subject: [PATCH 22/22] 2.1.48 --- pom.xml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pom.xml b/pom.xml index bf6f5abb2..7487d88b3 100755 --- a/pom.xml +++ b/pom.xml @@ -2,7 +2,7 @@ 4.0.0 com.gmail.nossr50.mcMMO mcMMO - 2.1.48-SNAPSHOT + 2.1.48 mcMMO https://github.com/mcMMO-Dev/mcMMO