From d67cbe28617625af389d3f7889909f2a186125b1 Mon Sep 17 00:00:00 2001 From: 89009332 <42133875+89009332@users.noreply.github.com> Date: Sun, 16 Jun 2019 21:09:34 +0800 Subject: [PATCH 1/6] Update locale_zh_CN.properties --- src/main/resources/locale/locale_zh_CN.properties | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/src/main/resources/locale/locale_zh_CN.properties b/src/main/resources/locale/locale_zh_CN.properties index 32a9c59da..d47d28954 100644 --- a/src/main/resources/locale/locale_zh_CN.properties +++ b/src/main/resources/locale/locale_zh_CN.properties @@ -226,7 +226,7 @@ Excavation.Skills.GigaDrillBreaker.Refresh=[[GREEN]]\u4f60\u7684 [[YELLOW]]\u66b Excavation.Skills.GigaDrillBreaker.Other.Off=\u66b4\u8d70\u94bb\u5934[[GREEN]] \u7ed3\u675f\u4e86,\u8fdb\u5165\u51b7\u5374 [[YELLOW]]{0} Excavation.Skills.GigaDrillBreaker.Other.On=[[GREEN]]{0}[[DARK_GREEN]] \u4f7f\u7528\u4e86 [[RED]]\u66b4\u8d70\u94bb\u5934! #\u9493\u9c7c -Fishing.Scarcity=[[YELLOW]]&o\u8be5\u533a\u57df\u5df2\u7ecf\u8fc7\u5ea6\u6355\u635e, \u8bf7\u6362\u4e00\u4e2a\u65b0\u533a\u57df\u518d\u5c1d\u8bd5. +Fishing.ScarcityTip=[[YELLOW]]&o\u8be5\u533a\u57df\u5df2\u7ecf\u8fc7\u5ea6\u6355\u635e, \u8bf7\u6362\u4e00\u4e2a\u65b0\u533a\u57df\u518d\u5c1d\u8bd5,\u8bf7\u5230\u81f3\u5c11 {0} \u7684\u65b9\u5757\u4ee5\u5916. Fishing.Scared=[[GRAY]]&o\u4e71\u52a8\u4f1a\u5413\u8dd1\u9c7c! Fishing.Exhausting=[[RED]]&o\u4e0d\u6b63\u5f53\u4f7f\u7528\u9c7c\u7aff\u4f1a\u52a0\u5267\u8010\u4e45\u7684\u635f\u8017! Fishing.LowResources=[[GRAY]]\u4f60\u89c9\u5f97\u8fd9\u5757\u533a\u57df\u4f3c\u4e4e\u6ca1\u6709\u591a\u5c11\u9c7c\u4e86. @@ -373,6 +373,9 @@ Repair.Arcane.Perfect=[[GREEN]]\u4f60\u6210\u529f\u5730\u4fdd\u7559\u4e86\u8fd9\ Salvage.Pretty.Name=\u5206\u89e3 Salvage.SubSkill.UnderstandingTheArt.Name=\u5206\u89e3\u7cbe\u901a Salvage.SubSkill.UnderstandingTheArt.Description=\u4f60\u4e0d\u53ea\u662f\u518d\u7ffb\u90bb\u5c45\u7684\u5783\u573e, \u4f60\u662f\u5728\u4fdd\u62a4\u73af\u5883.\n\u589e\u5f3a\u5206\u89e3\u7684\u5404\u79cd\u5c5e\u6027. +Salvage.SubSkill.ScrapCollector.Name=\u5e9f\u6599\u56de\u6536 +Salvage.SubSkill.ScrapCollector.Description=\u4ece\u7269\u54c1\u4e2d\u5206\u89e3\u51fa\u6750\u6599, \u5b8c\u7f8e\u5206\u89e3\u53d6\u51b3\u4e8e\u6280\u80fd\u548c\u8fd0\u6c14. +Salvage.SubSkill.ScrapCollector.Stat=\u5e9f\u6599\u56de\u6536: [[GREEN]]\u6700\u591a\u5206\u89e3\u51fa [[YELLOW]]{0}[[GREEN]] \u4e2a\u7269\u54c1. \u5360\u4e00\u4e9b\u8fd0\u6c14\u6210\u5206. Salvage.SubSkill.AdvancedSalvage.Name=\u8fdb\u9636\u5206\u89e3 Salvage.SubSkill.AdvancedSalvage.Description=\u5206\u89e3\u635f\u574f\u7684\u7269\u54c1 Salvage.SubSkill.ArcaneSalvage.Name=\u5965\u6570\u5206\u89e3 From 218b2a1a75338b9f76568e99ea44e936a8ae8fab Mon Sep 17 00:00:00 2001 From: nossr50 Date: Mon, 17 Jun 2019 07:00:39 -0700 Subject: [PATCH 2/6] Double check that a Player is not an NPC when loading profiles --- .../com/gmail/nossr50/listeners/EntityListener.java | 12 ++++++------ .../com/gmail/nossr50/listeners/PlayerListener.java | 6 +----- .../runnables/player/PlayerProfileLoadingTask.java | 5 +++++ .../nossr50/runnables/skills/AlchemyBrewTask.java | 2 +- .../gmail/nossr50/skills/unarmed/UnarmedManager.java | 2 +- src/main/java/com/gmail/nossr50/util/EventUtils.java | 2 +- src/main/java/com/gmail/nossr50/util/Misc.java | 9 ++++++++- .../com/gmail/nossr50/util/skills/CombatUtils.java | 12 ++++++------ 8 files changed, 29 insertions(+), 21 deletions(-) diff --git a/src/main/java/com/gmail/nossr50/listeners/EntityListener.java b/src/main/java/com/gmail/nossr50/listeners/EntityListener.java index c7f26431c..f771cc1f2 100644 --- a/src/main/java/com/gmail/nossr50/listeners/EntityListener.java +++ b/src/main/java/com/gmail/nossr50/listeners/EntityListener.java @@ -327,7 +327,7 @@ public class EntityListener implements Listener { } */ - if (Misc.isNPCEntity(defender) || !defender.isValid() || !(defender instanceof LivingEntity)) { + if (Misc.isNPCEntityExcludingVillagers(defender) || !defender.isValid() || !(defender instanceof LivingEntity)) { return; } @@ -337,7 +337,7 @@ public class EntityListener implements Listener { return; } - if (Misc.isNPCEntity(attacker)) { + if (Misc.isNPCEntityExcludingVillagers(attacker)) { return; } @@ -466,7 +466,7 @@ public class EntityListener implements Listener { } */ - if (Misc.isNPCEntity(entity) || !entity.isValid() || !(entity instanceof LivingEntity)) { + if (Misc.isNPCEntityExcludingVillagers(entity) || !entity.isValid() || !(entity instanceof LivingEntity)) { return; } @@ -603,7 +603,7 @@ public class EntityListener implements Listener { LivingEntity entity = event.getEntity(); - if (Misc.isNPCEntity(entity)) { + if (Misc.isNPCEntityExcludingVillagers(entity)) { return; } @@ -636,7 +636,7 @@ public class EntityListener implements Listener { LivingEntity entity = event.getEntity(); - if (Misc.isNPCEntity(entity)) { + if (Misc.isNPCEntityExcludingVillagers(entity)) { return; } @@ -937,7 +937,7 @@ public class EntityListener implements Listener { LivingEntity entity = event.getEntity(); - if (!UserManager.hasPlayerDataKey(player) || Misc.isNPCEntity(entity) || entity.hasMetadata(mcMMO.entityMetadataKey)) { + if (!UserManager.hasPlayerDataKey(player) || Misc.isNPCEntityExcludingVillagers(entity) || entity.hasMetadata(mcMMO.entityMetadataKey)) { return; } diff --git a/src/main/java/com/gmail/nossr50/listeners/PlayerListener.java b/src/main/java/com/gmail/nossr50/listeners/PlayerListener.java index 8f1f91f0d..ea13ab98d 100644 --- a/src/main/java/com/gmail/nossr50/listeners/PlayerListener.java +++ b/src/main/java/com/gmail/nossr50/listeners/PlayerListener.java @@ -522,10 +522,6 @@ public class PlayerListener implements Listener { public void onPlayerJoin(PlayerJoinEvent event) { Player player = event.getPlayer(); - if (Misc.isNPCEntity(player)) { - return; - } - //Delay loading for 3 seconds in case the player has a save task running, its hacky but it should do the trick new PlayerProfileLoadingTask(player).runTaskLaterAsynchronously(mcMMO.p, 60); @@ -852,7 +848,7 @@ public class PlayerListener implements Listener { public void onPlayerChat(AsyncPlayerChatEvent event) { Player player = event.getPlayer(); - if (Misc.isNPCEntity(player) || !UserManager.hasPlayerDataKey(player)) { + if (Misc.isNPCEntityExcludingVillagers(player) || !UserManager.hasPlayerDataKey(player)) { return; } diff --git a/src/main/java/com/gmail/nossr50/runnables/player/PlayerProfileLoadingTask.java b/src/main/java/com/gmail/nossr50/runnables/player/PlayerProfileLoadingTask.java index 4736ce5cd..5ec5f1dd2 100644 --- a/src/main/java/com/gmail/nossr50/runnables/player/PlayerProfileLoadingTask.java +++ b/src/main/java/com/gmail/nossr50/runnables/player/PlayerProfileLoadingTask.java @@ -30,6 +30,11 @@ public class PlayerProfileLoadingTask extends BukkitRunnable { // DO NOT MODIFY THE McMMOPLAYER FROM THIS CODE @Override public void run() { + + if (Misc.isNPCIncludingVillagers(player)) { + return; + } + // Quit if they logged out if (!player.isOnline()) { mcMMO.p.getLogger().info("Aborting profile loading recovery for " + player.getName() + " - player logged out"); diff --git a/src/main/java/com/gmail/nossr50/runnables/skills/AlchemyBrewTask.java b/src/main/java/com/gmail/nossr50/runnables/skills/AlchemyBrewTask.java index 076cef3e2..8bd1d8c7e 100644 --- a/src/main/java/com/gmail/nossr50/runnables/skills/AlchemyBrewTask.java +++ b/src/main/java/com/gmail/nossr50/runnables/skills/AlchemyBrewTask.java @@ -38,7 +38,7 @@ public class AlchemyBrewTask extends BukkitRunnable { brewTimer = DEFAULT_BREW_TICKS; if (player != null - && !Misc.isNPCEntity(player) + && !Misc.isNPCEntityExcludingVillagers(player) && Permissions.isSubSkillEnabled(player, SubSkillType.ALCHEMY_CATALYSIS) && UserManager.getPlayer(player) != null) { diff --git a/src/main/java/com/gmail/nossr50/skills/unarmed/UnarmedManager.java b/src/main/java/com/gmail/nossr50/skills/unarmed/UnarmedManager.java index 1ce5733f9..44a7b1047 100644 --- a/src/main/java/com/gmail/nossr50/skills/unarmed/UnarmedManager.java +++ b/src/main/java/com/gmail/nossr50/skills/unarmed/UnarmedManager.java @@ -171,7 +171,7 @@ public class UnarmedManager extends SkillManager { * @return true if the defender was not disarmed, false otherwise */ private boolean hasIronGrip(Player defender) { - if (!Misc.isNPCEntity(defender) && Permissions.isSubSkillEnabled(defender, SubSkillType.UNARMED_IRON_GRIP) + if (!Misc.isNPCEntityExcludingVillagers(defender) && Permissions.isSubSkillEnabled(defender, SubSkillType.UNARMED_IRON_GRIP) && RandomChanceUtil.isActivationSuccessful(SkillActivationType.RANDOM_LINEAR_100_SCALE_WITH_CAP, SubSkillType.UNARMED_IRON_GRIP, getPlayer())) { NotificationManager.sendPlayerInformation(defender, NotificationType.SUBSKILL_MESSAGE, "Unarmed.Ability.IronGrip.Defender"); NotificationManager.sendPlayerInformation(getPlayer(), NotificationType.SUBSKILL_MESSAGE, "Unarmed.Ability.IronGrip.Attacker"); diff --git a/src/main/java/com/gmail/nossr50/util/EventUtils.java b/src/main/java/com/gmail/nossr50/util/EventUtils.java index 3f8b5a5a3..b88958206 100644 --- a/src/main/java/com/gmail/nossr50/util/EventUtils.java +++ b/src/main/java/com/gmail/nossr50/util/EventUtils.java @@ -103,7 +103,7 @@ public class EventUtils { Entity entity = entityDamageEvent.getEntity(); //Check to make sure the entity is not an NPC - if(Misc.isNPCEntity(entity)) + if(Misc.isNPCEntityExcludingVillagers(entity)) return false; if (!entity.isValid() || !(entity instanceof LivingEntity)) { diff --git a/src/main/java/com/gmail/nossr50/util/Misc.java b/src/main/java/com/gmail/nossr50/util/Misc.java index e2e680e2e..c3a69c65e 100644 --- a/src/main/java/com/gmail/nossr50/util/Misc.java +++ b/src/main/java/com/gmail/nossr50/util/Misc.java @@ -39,13 +39,20 @@ public final class Misc { private Misc() {}; - public static boolean isNPCEntity(Entity entity) { + public static boolean isNPCEntityExcludingVillagers(Entity entity) { return (entity == null || (entity.hasMetadata("NPC") && !(entity instanceof Villager)) || (entity instanceof NPC && !(entity instanceof Villager)) || entity.getClass().getName().equalsIgnoreCase("cofh.entity.PlayerFake")); } + public static boolean isNPCIncludingVillagers(Player entity) { + return (entity == null + || (entity.hasMetadata("NPC")) + || (entity instanceof NPC) + || entity.getClass().getName().equalsIgnoreCase("cofh.entity.PlayerFake")); + } + /** * Determine if two locations are near each other. * 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 6a8d1e755..26cd72431 100644 --- a/src/main/java/com/gmail/nossr50/util/skills/CombatUtils.java +++ b/src/main/java/com/gmail/nossr50/util/skills/CombatUtils.java @@ -247,7 +247,7 @@ public final class CombatUtils { EntityType entityType = damager.getType(); if (target instanceof Player) { - if (Misc.isNPCEntity(target)) { + if (Misc.isNPCEntityExcludingVillagers(target)) { return; } @@ -336,7 +336,7 @@ public final class CombatUtils { if (tamer != null && tamer instanceof Player && PrimarySkillType.TAMING.shouldProcess(target)) { Player master = (Player) tamer; - if (!Misc.isNPCEntity(master) && PrimarySkillType.TAMING.getPermissions(master)) { + if (!Misc.isNPCEntityExcludingVillagers(master) && PrimarySkillType.TAMING.getPermissions(master)) { processTamingCombat(target, master, wolf, event); } } @@ -348,11 +348,11 @@ public final class CombatUtils { if (projectileSource != null && projectileSource instanceof Player && PrimarySkillType.ARCHERY.shouldProcess(target)) { Player player = (Player) projectileSource; - if (!Misc.isNPCEntity(player) && PrimarySkillType.ARCHERY.getPermissions(player)) { + if (!Misc.isNPCEntityExcludingVillagers(player) && PrimarySkillType.ARCHERY.getPermissions(player)) { processArcheryCombat(target, player, event, arrow); } - if (target.getType() != EntityType.CREEPER && !Misc.isNPCEntity(player) && PrimarySkillType.TAMING.getPermissions(player)) { + if (target.getType() != EntityType.CREEPER && !Misc.isNPCEntityExcludingVillagers(player) && PrimarySkillType.TAMING.getPermissions(player)) { McMMOPlayer mcMMOPlayer = UserManager.getPlayer(player); TamingManager tamingManager = mcMMOPlayer.getTamingManager(); tamingManager.attackTarget(target); @@ -522,7 +522,7 @@ public final class CombatUtils { break; } - if (Misc.isNPCEntity(entity) || !(entity instanceof LivingEntity) || !shouldBeAffected(attacker, entity)) { + if (Misc.isNPCEntityExcludingVillagers(entity) || !(entity instanceof LivingEntity) || !shouldBeAffected(attacker, entity)) { continue; } @@ -859,7 +859,7 @@ public final class CombatUtils { Player player = (Player) attacker; - if (Misc.isNPCEntity(player) || Misc.isNPCEntity(target)) { + if (Misc.isNPCEntityExcludingVillagers(player) || Misc.isNPCEntityExcludingVillagers(target)) { return; } From 4e4d798b1d3a169c4ad7096ab983ba4c0314d5b5 Mon Sep 17 00:00:00 2001 From: nossr50 Date: Mon, 17 Jun 2019 07:38:30 -0700 Subject: [PATCH 3/6] Add proper error handling to file loading --- Changelog.txt | 5 ++ pom.xml | 2 +- .../com/gmail/nossr50/party/PartyManager.java | 64 +++++++++++-------- 3 files changed, 42 insertions(+), 29 deletions(-) diff --git a/Changelog.txt b/Changelog.txt index 0696b54d7..2cb3b1d80 100644 --- a/Changelog.txt +++ b/Changelog.txt @@ -1,3 +1,8 @@ +Version 2.1.82 + Added proper error handling when loading parties file + Updated Chinese locale (thanks to the user named 89009332 from github) + Added some redundancy checks when loading profiles (NPC checks to be specific) + Version 2.1.81 Fixed a bug where Arrow Deflect would never trigger outside of PVP Fixed a bug where failing to salvage enchantments incorrectly colored the text diff --git a/pom.xml b/pom.xml index 65095a77f..91db71530 100755 --- a/pom.xml +++ b/pom.xml @@ -2,7 +2,7 @@ 4.0.0 com.gmail.nossr50.mcMMO mcMMO - 2.1.81 + 2.1.82-SNAPSHOT mcMMO https://github.com/mcMMO-Dev/mcMMO diff --git a/src/main/java/com/gmail/nossr50/party/PartyManager.java b/src/main/java/com/gmail/nossr50/party/PartyManager.java index 33913f13c..f27390613 100644 --- a/src/main/java/com/gmail/nossr50/party/PartyManager.java +++ b/src/main/java/com/gmail/nossr50/party/PartyManager.java @@ -591,45 +591,53 @@ public final class PartyManager { return; } - YamlConfiguration partiesFile = YamlConfiguration.loadConfiguration(partyFile); + try { + YamlConfiguration partiesFile; + partiesFile = YamlConfiguration.loadConfiguration(partyFile); - ArrayList hasAlly = new ArrayList(); + ArrayList hasAlly = new ArrayList(); - for (String partyName : partiesFile.getConfigurationSection("").getKeys(false)) { - Party party = new Party(partyName); + for (String partyName : partiesFile.getConfigurationSection("").getKeys(false)) { + Party party = new Party(partyName); - String[] leaderSplit = partiesFile.getString(partyName + ".Leader").split("[|]"); - party.setLeader(new PartyLeader(UUID.fromString(leaderSplit[0]), leaderSplit[1])); - party.setPassword(partiesFile.getString(partyName + ".Password")); - party.setLocked(partiesFile.getBoolean(partyName + ".Locked")); - party.setLevel(partiesFile.getInt(partyName + ".Level")); - party.setXp(partiesFile.getInt(partyName + ".Xp")); + String[] leaderSplit = partiesFile.getString(partyName + ".Leader").split("[|]"); + party.setLeader(new PartyLeader(UUID.fromString(leaderSplit[0]), leaderSplit[1])); + party.setPassword(partiesFile.getString(partyName + ".Password")); + party.setLocked(partiesFile.getBoolean(partyName + ".Locked")); + party.setLevel(partiesFile.getInt(partyName + ".Level")); + party.setXp(partiesFile.getInt(partyName + ".Xp")); - if (partiesFile.getString(partyName + ".Ally") != null) { - hasAlly.add(party); + if (partiesFile.getString(partyName + ".Ally") != null) { + hasAlly.add(party); + } + + party.setXpShareMode(ShareMode.getShareMode(partiesFile.getString(partyName + ".ExpShareMode", "NONE"))); + party.setItemShareMode(ShareMode.getShareMode(partiesFile.getString(partyName + ".ItemShareMode", "NONE"))); + + for (ItemShareType itemShareType : ItemShareType.values()) { + party.setSharingDrops(itemShareType, partiesFile.getBoolean(partyName + ".ItemShareType." + itemShareType.toString(), true)); + } + + LinkedHashMap members = party.getMembers(); + + for (String memberEntry : partiesFile.getStringList(partyName + ".Members")) { + String[] memberSplit = memberEntry.split("[|]"); + members.put(UUID.fromString(memberSplit[0]), memberSplit[1]); + } + + parties.add(party); } - party.setXpShareMode(ShareMode.getShareMode(partiesFile.getString(partyName + ".ExpShareMode", "NONE"))); - party.setItemShareMode(ShareMode.getShareMode(partiesFile.getString(partyName + ".ItemShareMode", "NONE"))); + mcMMO.p.debug("Loaded (" + parties.size() + ") Parties..."); - for (ItemShareType itemShareType : ItemShareType.values()) { - party.setSharingDrops(itemShareType, partiesFile.getBoolean(partyName + ".ItemShareType." + itemShareType.toString(), true)); + for (Party party : hasAlly) { + party.setAlly(PartyManager.getParty(partiesFile.getString(party.getName() + ".Ally"))); } - LinkedHashMap members = party.getMembers(); - - for (String memberEntry : partiesFile.getStringList(partyName + ".Members")) { - String[] memberSplit = memberEntry.split("[|]"); - members.put(UUID.fromString(memberSplit[0]), memberSplit[1]); - } - - parties.add(party); + } catch (Exception e) { + e.printStackTrace(); } - mcMMO.p.debug("Loaded (" + parties.size() + ") Parties..."); - for (Party party : hasAlly) { - party.setAlly(PartyManager.getParty(partiesFile.getString(party.getName() + ".Ally"))); - } } /** From 38bc60ba86219f3772cc35f63be71629fa4d5e4a Mon Sep 17 00:00:00 2001 From: nossr50 Date: Mon, 17 Jun 2019 08:19:15 -0700 Subject: [PATCH 4/6] Inspecting offline players no longer requires permissions + fixing errors when using mcrank on an offline player --- Changelog.txt | 7 +++++++ .../nossr50/commands/player/InspectCommand.java | 4 ---- .../nossr50/commands/player/McrankCommand.java | 3 --- .../nossr50/datatypes/skills/PrimarySkillType.java | 1 + .../commands/McrankCommandDisplayTask.java | 8 ++++---- .../gmail/nossr50/util/commands/CommandUtils.java | 13 ------------- src/main/resources/plugin.yml | 8 -------- 7 files changed, 12 insertions(+), 32 deletions(-) diff --git a/Changelog.txt b/Changelog.txt index 2cb3b1d80..a78094909 100644 --- a/Changelog.txt +++ b/Changelog.txt @@ -1,8 +1,15 @@ Version 2.1.82 Added proper error handling when loading parties file + Fixed an error that could occur when using mcrank on an offline player + You can now use mcrank on offline players by default + You can now use inspect on offline players by default + Removed the offline inspect/mcrank permissions Updated Chinese locale (thanks to the user named 89009332 from github) Added some redundancy checks when loading profiles (NPC checks to be specific) + NOTES: + There were reasons to prevent inspecting offline players in the past, I don't see any reason for them anymore so I've removed the restriction. + Version 2.1.81 Fixed a bug where Arrow Deflect would never trigger outside of PVP Fixed a bug where failing to salvage enchantments incorrectly colored the text diff --git a/src/main/java/com/gmail/nossr50/commands/player/InspectCommand.java b/src/main/java/com/gmail/nossr50/commands/player/InspectCommand.java index bcdf611c0..f8f4e5e49 100644 --- a/src/main/java/com/gmail/nossr50/commands/player/InspectCommand.java +++ b/src/main/java/com/gmail/nossr50/commands/player/InspectCommand.java @@ -36,10 +36,6 @@ public class InspectCommand implements TabExecutor { return true; } - if (CommandUtils.inspectOffline(sender, profile, Permissions.inspectOffline(sender))) { - return true; - } - if (Config.getInstance().getScoreboardsEnabled() && sender instanceof Player && Config.getInstance().getInspectUseBoard()) { ScoreboardManager.enablePlayerInspectScoreboard((Player) sender, profile); diff --git a/src/main/java/com/gmail/nossr50/commands/player/McrankCommand.java b/src/main/java/com/gmail/nossr50/commands/player/McrankCommand.java index dc4150afd..c973b0608 100644 --- a/src/main/java/com/gmail/nossr50/commands/player/McrankCommand.java +++ b/src/main/java/com/gmail/nossr50/commands/player/McrankCommand.java @@ -62,9 +62,6 @@ public class McrankCommand implements TabExecutor { return true; } } - else if (CommandUtils.inspectOffline(sender, mcMMO.getDatabaseManager().loadPlayerProfile(playerName, false), Permissions.mcrankOffline(sender))) { - return true; - } display(sender, playerName); return true; diff --git a/src/main/java/com/gmail/nossr50/datatypes/skills/PrimarySkillType.java b/src/main/java/com/gmail/nossr50/datatypes/skills/PrimarySkillType.java index 24d21e972..0def74ef8 100644 --- a/src/main/java/com/gmail/nossr50/datatypes/skills/PrimarySkillType.java +++ b/src/main/java/com/gmail/nossr50/datatypes/skills/PrimarySkillType.java @@ -25,6 +25,7 @@ import com.gmail.nossr50.util.StringUtils; import com.gmail.nossr50.util.skills.RankUtils; import com.google.common.collect.ImmutableList; import org.bukkit.Color; +import org.bukkit.OfflinePlayer; import org.bukkit.entity.Entity; import org.bukkit.entity.Player; import org.bukkit.entity.Tameable; diff --git a/src/main/java/com/gmail/nossr50/runnables/commands/McrankCommandDisplayTask.java b/src/main/java/com/gmail/nossr50/runnables/commands/McrankCommandDisplayTask.java index 333aa166d..353e0ea04 100644 --- a/src/main/java/com/gmail/nossr50/runnables/commands/McrankCommandDisplayTask.java +++ b/src/main/java/com/gmail/nossr50/runnables/commands/McrankCommandDisplayTask.java @@ -41,16 +41,16 @@ public class McrankCommandDisplayTask extends BukkitRunnable { } private void displayChat() { - Player player = mcMMO.p.getServer().getPlayerExact(playerName); +// Player player = mcMMO.p.getServer().getPlayerExact(playerName); Integer rank; sender.sendMessage(LocaleLoader.getString("Commands.mcrank.Heading")); sender.sendMessage(LocaleLoader.getString("Commands.mcrank.Player", playerName)); for (PrimarySkillType skill : PrimarySkillType.NON_CHILD_SKILLS) { - if (!skill.getPermissions(player)) { - continue; - } +// if (!skill.getPermissions(player)) { +// continue; +// } rank = skills.get(skill); sender.sendMessage(LocaleLoader.getString("Commands.mcrank.Skill", skill.getName(), (rank == null ? LocaleLoader.getString("Commands.mcrank.Unranked") : rank))); diff --git a/src/main/java/com/gmail/nossr50/util/commands/CommandUtils.java b/src/main/java/com/gmail/nossr50/util/commands/CommandUtils.java index e5dc13558..b9568a1b2 100644 --- a/src/main/java/com/gmail/nossr50/util/commands/CommandUtils.java +++ b/src/main/java/com/gmail/nossr50/util/commands/CommandUtils.java @@ -33,19 +33,6 @@ public final class CommandUtils { return true; } - public static boolean inspectOffline(CommandSender sender, PlayerProfile profile, boolean hasPermission) { - if (unloadedProfile(sender, profile)) { - return true; - } - - if (!hasPermission) { - sender.sendMessage(LocaleLoader.getString("Inspect.Offline")); - return true; - } - - return false; - } - public static boolean tooFar(CommandSender sender, Player target, boolean hasPermission) { if (sender instanceof Player && !Misc.isNear(((Player) sender).getLocation(), target.getLocation(), Config.getInstance().getInspectDistance()) && !hasPermission) { sender.sendMessage(LocaleLoader.getString("Inspect.TooFar")); diff --git a/src/main/resources/plugin.yml b/src/main/resources/plugin.yml index 58e9b6584..323a68f54 100644 --- a/src/main/resources/plugin.yml +++ b/src/main/resources/plugin.yml @@ -716,7 +716,6 @@ permissions: mcmmo.bypass.hardcoremode: true mcmmo.commands.inspect.far: true mcmmo.commands.inspect.hidden: true - mcmmo.commands.inspect.offline: true mcmmo.bypass.partylimit: default: false description: Allows user to bypass party size limitations if present on the server @@ -794,7 +793,6 @@ permissions: mcmmo.commands.hardcore.all: true mcmmo.commands.inspect.far: true mcmmo.commands.inspect.hidden: true - mcmmo.commands.inspect.offline: true mcmmo.commands.mcability.others: true mcmmo.commands.mcconvert.all: true mcmmo.commands.mcchatspy: true @@ -866,15 +864,12 @@ permissions: mcmmo.commands.inspect: true mcmmo.commands.inspect.far: true mcmmo.commands.inspect.hidden: true - mcmmo.commands.inspect.offline: true mcmmo.commands.inspect: description: Allows access to the inspect command mcmmo.commands.inspect.far: description: Allows access to the inspect command for far players mcmmo.commands.inspect.hidden: description: Allows access to the inspect command for hidden players - mcmmo.commands.inspect.offline: - description: Allows access to the inspect command for offline players mcmmo.commands.mcability: description: Allows access to the mcability command mcmmo.commands.mcability.others: @@ -935,13 +930,10 @@ permissions: children: mcmmo.commands.mcrank.others: true mcmmo.commands.mcrank.others.far: true - mcmmo.commands.mcrank.others.offline: true mcmmo.commands.mcrank.others: description: Allows access to the mcrank command for other players mcmmo.commands.mcrank.others.far: description: Allows access to the mcrank command for far players - mcmmo.commands.mcrank.others.offline: - description: Allows access to the mcrank command for offline players mcmmo.commands.mcrefresh: description: Allows access to the mcrefresh command mcmmo.commands.mcrefresh.others: From 2cecc910262982fb43dc469c03b8fe1fde0d98e5 Mon Sep 17 00:00:00 2001 From: nossr50 Date: Mon, 17 Jun 2019 08:25:37 -0700 Subject: [PATCH 5/6] WG Hardcore penalty flag 'mcmmo-hardcore' --- Changelog.txt | 1 + .../gmail/nossr50/util/HardcoreManager.java | 14 ++++++++++++++ .../nossr50/worldguard/WorldGuardFlags.java | 1 + .../nossr50/worldguard/WorldGuardManager.java | 18 ++++++++++++++++++ 4 files changed, 34 insertions(+) diff --git a/Changelog.txt b/Changelog.txt index a78094909..33151e218 100644 --- a/Changelog.txt +++ b/Changelog.txt @@ -1,4 +1,5 @@ Version 2.1.82 + Added new WG flag 'mcmmo-hardcore' if set to negative players will not be penalized by hardcore mode (if hardcore mode is enabled) it defaults to true Added proper error handling when loading parties file Fixed an error that could occur when using mcrank on an offline player You can now use mcrank on offline players by default diff --git a/src/main/java/com/gmail/nossr50/util/HardcoreManager.java b/src/main/java/com/gmail/nossr50/util/HardcoreManager.java index 1ad92f15a..ee2ad8092 100644 --- a/src/main/java/com/gmail/nossr50/util/HardcoreManager.java +++ b/src/main/java/com/gmail/nossr50/util/HardcoreManager.java @@ -6,6 +6,8 @@ import com.gmail.nossr50.datatypes.player.PlayerProfile; import com.gmail.nossr50.datatypes.skills.PrimarySkillType; import com.gmail.nossr50.util.player.NotificationManager; import com.gmail.nossr50.util.player.UserManager; +import com.gmail.nossr50.worldguard.WorldGuardManager; +import com.gmail.nossr50.worldguard.WorldGuardUtils; import org.bukkit.entity.Player; import java.util.HashMap; @@ -14,6 +16,12 @@ public final class HardcoreManager { private HardcoreManager() {} public static void invokeStatPenalty(Player player) { + + if(WorldGuardUtils.isWorldGuardLoaded()) { + if(!WorldGuardManager.getInstance().hasHardcoreFlag(player)) + return; + } + double statLossPercentage = Config.getInstance().getHardcoreDeathStatPenaltyPercentage(); int levelThreshold = Config.getInstance().getHardcoreDeathStatPenaltyLevelThreshold(); @@ -59,6 +67,12 @@ public final class HardcoreManager { } public static void invokeVampirism(Player killer, Player victim) { + + if(WorldGuardUtils.isWorldGuardLoaded()) { + if(!WorldGuardManager.getInstance().hasHardcoreFlag(killer) || !WorldGuardManager.getInstance().hasHardcoreFlag(victim)) + return; + } + double vampirismStatLeechPercentage = Config.getInstance().getHardcoreVampirismStatLeechPercentage(); int levelThreshold = Config.getInstance().getHardcoreVampirismLevelThreshold(); diff --git a/src/main/java/com/gmail/nossr50/worldguard/WorldGuardFlags.java b/src/main/java/com/gmail/nossr50/worldguard/WorldGuardFlags.java index c61f384c6..0d1c54f6c 100644 --- a/src/main/java/com/gmail/nossr50/worldguard/WorldGuardFlags.java +++ b/src/main/java/com/gmail/nossr50/worldguard/WorldGuardFlags.java @@ -6,4 +6,5 @@ public class WorldGuardFlags { // StateFlag with the name "my-custom-flag", which defaults to "allow" public static final StateFlag MCMMO_ENABLE_WG_FLAG = new StateFlag("mcmmo", true); public static final StateFlag MCMMO_XP_WG_FLAG = new StateFlag("mcmmo-xp", true); + public static final StateFlag MCMMO_HARDCORE_WG_FLAG = new StateFlag("mcmmo-hardcore", true); } diff --git a/src/main/java/com/gmail/nossr50/worldguard/WorldGuardManager.java b/src/main/java/com/gmail/nossr50/worldguard/WorldGuardManager.java index 25cd6291a..896aad675 100644 --- a/src/main/java/com/gmail/nossr50/worldguard/WorldGuardManager.java +++ b/src/main/java/com/gmail/nossr50/worldguard/WorldGuardManager.java @@ -64,6 +64,23 @@ public class WorldGuardManager { return query.testState(loc, WorldGuardPlugin.inst().wrapPlayer(player), WorldGuardFlags.MCMMO_XP_WG_FLAG); } + public boolean hasHardcoreFlag(Player player) + { + if(player == null) + return false; + + BukkitPlayer localPlayer = BukkitAdapter.adapt(player); + com.sk89q.worldedit.util.Location loc = localPlayer.getLocation(); + + //WorldGuardPlugin worldGuard = getWorldGuard(); + RegionContainer container = WorldGuard.getInstance().getPlatform().getRegionContainer(); + RegionQuery query = container.createQuery(); + + //ApplicableRegionSet set = query.getApplicableRegions(loc); + + return query.testState(loc, WorldGuardPlugin.inst().wrapPlayer(player), WorldGuardFlags.MCMMO_HARDCORE_WG_FLAG); + } + private WorldGuardPlugin getWorldGuard() { Plugin plugin = getServer().getPluginManager().getPlugin("WorldGuard"); @@ -88,6 +105,7 @@ public class WorldGuardManager { registry.register(WorldGuardFlags.MCMMO_XP_WG_FLAG);*/ registry.register(WorldGuardFlags.MCMMO_ENABLE_WG_FLAG); registry.register(WorldGuardFlags.MCMMO_XP_WG_FLAG); + registry.register(WorldGuardFlags.MCMMO_HARDCORE_WG_FLAG); System.out.println("mcMMO has registered WG flags successfully!"); } catch (FlagConflictException e) { e.printStackTrace(); From b612a599de2aaa821f1f0174386dbcab3269cdfd Mon Sep 17 00:00:00 2001 From: nossr50 Date: Mon, 17 Jun 2019 08:26:21 -0700 Subject: [PATCH 6/6] 2.1.82 --- pom.xml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pom.xml b/pom.xml index 91db71530..dc655be5d 100755 --- a/pom.xml +++ b/pom.xml @@ -2,7 +2,7 @@ 4.0.0 com.gmail.nossr50.mcMMO mcMMO - 2.1.82-SNAPSHOT + 2.1.82 mcMMO https://github.com/mcMMO-Dev/mcMMO