From 9f8b119fb7a631a01dd8b3d1b35f2080272e8b6f Mon Sep 17 00:00:00 2001 From: CoderTim Date: Mon, 27 Oct 2014 18:09:23 -0400 Subject: [PATCH 1/5] Bug fixes --- .../src/mineplex/core/npc/Npc.java | 22 ++++++++++++------- .../src/mineplex/core/npc/NpcManager.java | 6 ++--- .../mineplex/hub/server/ui/ServerNpcPage.java | 2 +- .../games/baconbrawl/kits/KitSheepPig.java | 2 +- .../game/arcade/kit/perks/PerkBomber.java | 15 ++++--------- .../game/arcade/stats/KaboomStatTracker.java | 2 +- 6 files changed, 24 insertions(+), 25 deletions(-) diff --git a/Plugins/Mineplex.Core/src/mineplex/core/npc/Npc.java b/Plugins/Mineplex.Core/src/mineplex/core/npc/Npc.java index 01590e771..a8b3a2a78 100644 --- a/Plugins/Mineplex.Core/src/mineplex/core/npc/Npc.java +++ b/Plugins/Mineplex.Core/src/mineplex/core/npc/Npc.java @@ -83,11 +83,14 @@ public class Npc public void returnToPost() { - EntityCreature ec = ((CraftCreature) _entity).getHandle(); + if (_entity instanceof CraftCreature) + { + EntityCreature ec = ((CraftCreature) _entity).getHandle(); - ec.getNavigation().a(getLocation().getX(), getLocation().getY(), getLocation().getZ(), .8f); + ec.getNavigation().a(getLocation().getX(), getLocation().getY(), getLocation().getZ(), .8f); - _returning = true; + _returning = true; + } } public boolean isReturning() @@ -95,13 +98,16 @@ public class Npc return _returning; } - public void clearGoals(Entity entity) + public void clearGoals() { - _returning = false; + if (_entity instanceof CraftCreature) + { + _returning = false; - Location entityLocation = entity.getLocation(); - EntityCreature ec = ((CraftCreature) entity).getHandle(); - ec.getNavigation().a(entityLocation.getX(), entityLocation.getY(), entityLocation.getZ(), .8f); + Location entityLocation = _entity.getLocation(); + EntityCreature ec = ((CraftCreature) _entity).getHandle(); + ec.getNavigation().a(entityLocation.getX(), entityLocation.getY(), entityLocation.getZ(), .8f); + } } public NpcManager getNpcManager() diff --git a/Plugins/Mineplex.Core/src/mineplex/core/npc/NpcManager.java b/Plugins/Mineplex.Core/src/mineplex/core/npc/NpcManager.java index d33ff369e..1474de40c 100644 --- a/Plugins/Mineplex.Core/src/mineplex/core/npc/NpcManager.java +++ b/Plugins/Mineplex.Core/src/mineplex/core/npc/NpcManager.java @@ -430,15 +430,15 @@ public class NpcManager extends MiniPlugin entity.setVelocity(new Vector(0, 0, 0)); npc.setFailedAttempts(0); } - else if (!npc.isInRadius(entity.getLocation())) + else if (!npc.isInRadius(entity.getLocation()) && npc.getEntity() instanceof CraftCreature) { npc.returnToPost(); npc.incrementFailedAttempts(); } - else + else if (npc.getEntity() instanceof CraftCreature) { if (npc.isReturning()) - npc.clearGoals(entity); + npc.clearGoals(); npc.setFailedAttempts(0); } diff --git a/Plugins/Mineplex.Hub/src/mineplex/hub/server/ui/ServerNpcPage.java b/Plugins/Mineplex.Hub/src/mineplex/hub/server/ui/ServerNpcPage.java index ba35f2d1c..bfe67e8bf 100644 --- a/Plugins/Mineplex.Hub/src/mineplex/hub/server/ui/ServerNpcPage.java +++ b/Plugins/Mineplex.Hub/src/mineplex/hub/server/ui/ServerNpcPage.java @@ -245,7 +245,7 @@ public class ServerNpcPage extends ShopPageBase im } } - AddButton(40, new ShopItem(Material.GOLD_BLOCK, C.cAqua + yellowCount++ + " Games In Progress", new String[]{MESSAGE_SPECTATE}, yellowCount > 64 ? 1 : yellowCount, false), new SingleButton() + AddButton(40, new ShopItem(Material.GOLD_BLOCK, C.cAqua + yellowCount + " Game" + (yellowCount == 1 ? "" : "s") + " In Progress", new String[]{MESSAGE_SPECTATE}, yellowCount > 64 ? 1 : yellowCount, false), new SingleButton() { @Override public void Clicked(Player player) diff --git a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/baconbrawl/kits/KitSheepPig.java b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/baconbrawl/kits/KitSheepPig.java index 6ca35322f..8028462f2 100644 --- a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/baconbrawl/kits/KitSheepPig.java +++ b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/baconbrawl/kits/KitSheepPig.java @@ -26,7 +26,7 @@ public class KitSheepPig extends Kit { public KitSheepPig(ArcadeManager manager) { - super(manager, "'Pig'", KitAvailability.Green, 5000, + super(manager, "Pig", KitAvailability.Green, 5000, new String[] { diff --git a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/kit/perks/PerkBomber.java b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/kit/perks/PerkBomber.java index 1aacd9982..5f5cd35e2 100644 --- a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/kit/perks/PerkBomber.java +++ b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/kit/perks/PerkBomber.java @@ -175,7 +175,7 @@ public class PerkBomber extends Perk @EventHandler public void ExplosionPrime(ExplosionPrimeEvent event) { - Player player = _tntMap.remove(event.getEntity()); + Player player = _tntMap.get(event.getEntity()); if (player != null) { for (Player other : UtilPlayer.getNearby(event.getEntity().getLocation(), 14)) @@ -185,7 +185,7 @@ public class PerkBomber extends Perk } } - @EventHandler(priority = EventPriority.MONITOR, ignoreCancelled = true) + @EventHandler(priority = EventPriority.LOWEST, ignoreCancelled = true) public void onEntityExplode(EntityExplodeEvent event) { Player player = _tntMap.remove(event.getEntity()); @@ -198,16 +198,9 @@ public class PerkBomber extends Perk if (block.getType() == Material.DIAMOND_ORE) { + Bukkit.getPluginManager().callEvent(new BomberExplodeDiamondBlock(player, block)); + block.breakNaturally(); it.remove(); - - if (Math.random() < event.getYield()) - { - block.breakNaturally(); - - Bukkit.getPluginManager().callEvent(new BomberExplodeDiamondBlock(player, block)); - } - else - block.setType(Material.AIR); } } } diff --git a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/stats/KaboomStatTracker.java b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/stats/KaboomStatTracker.java index 38f4dc114..7f4387d6b 100644 --- a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/stats/KaboomStatTracker.java +++ b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/stats/KaboomStatTracker.java @@ -24,7 +24,7 @@ public class KaboomStatTracker extends StatTracker { for (Player player : event.getDamagedPlayers()) { - if (!player.isDead()) + if (player.getHealth() != player.getMaxHealth()) return; } From cd5e4234b7b44ededf6d97b1f146e00f356d1d37 Mon Sep 17 00:00:00 2001 From: CoderTim Date: Mon, 27 Oct 2014 19:00:34 -0400 Subject: [PATCH 2/5] Fixed a couple more achievement bugs Track damage mods in combat log --- .../game/core/combat/CombatComponent.java | 6 +++-- .../game/core/combat/CombatDamage.java | 14 ++++++++++- .../minecraft/game/core/combat/CombatLog.java | 6 +++-- .../game/core/combat/CombatManager.java | 8 +++---- .../arcade/stats/KillReasonStatTracker.java | 24 +++++++++++++++++++ 5 files changed, 49 insertions(+), 9 deletions(-) diff --git a/Plugins/Mineplex.Minecraft.Game.Core/src/mineplex/minecraft/game/core/combat/CombatComponent.java b/Plugins/Mineplex.Minecraft.Game.Core/src/mineplex/minecraft/game/core/combat/CombatComponent.java index 55c0eed5c..6dda3daa5 100644 --- a/Plugins/Mineplex.Minecraft.Game.Core/src/mineplex/minecraft/game/core/combat/CombatComponent.java +++ b/Plugins/Mineplex.Minecraft.Game.Core/src/mineplex/minecraft/game/core/combat/CombatComponent.java @@ -2,10 +2,12 @@ package mineplex.minecraft.game.core.combat; import java.util.HashMap; import java.util.LinkedList; +import java.util.List; import mineplex.core.common.util.F; import mineplex.core.common.util.UtilTime; import mineplex.core.common.util.UtilTime.TimeUnit; +import mineplex.minecraft.game.core.damage.DamageChange; import org.bukkit.entity.LivingEntity; import org.bukkit.entity.Player; @@ -32,12 +34,12 @@ public class CombatComponent } } - public void AddDamage(String source, double dmg) + public void AddDamage(String source, double dmg, List mod) { if (source == null) source = "-"; - GetDamage().addFirst(new CombatDamage(source, dmg)); + GetDamage().addFirst(new CombatDamage(source, dmg, mod)); LastDamage = System.currentTimeMillis(); } diff --git a/Plugins/Mineplex.Minecraft.Game.Core/src/mineplex/minecraft/game/core/combat/CombatDamage.java b/Plugins/Mineplex.Minecraft.Game.Core/src/mineplex/minecraft/game/core/combat/CombatDamage.java index 8634b8e8b..c0dedb230 100644 --- a/Plugins/Mineplex.Minecraft.Game.Core/src/mineplex/minecraft/game/core/combat/CombatDamage.java +++ b/Plugins/Mineplex.Minecraft.Game.Core/src/mineplex/minecraft/game/core/combat/CombatDamage.java @@ -1,16 +1,23 @@ package mineplex.minecraft.game.core.combat; +import java.util.ArrayList; +import java.util.List; + +import mineplex.minecraft.game.core.damage.DamageChange; + public class CombatDamage { private String _name; private double _dmg; private long _time; + private List _mod = new ArrayList<>(); - public CombatDamage(String name, double dmg) + public CombatDamage(String name, double dmg, List mod) { _name = name; _dmg = dmg; _time = System.currentTimeMillis(); + _mod = mod; } public String GetName() @@ -27,4 +34,9 @@ public class CombatDamage { return _time; } + + public List getDamageMod() + { + return _mod; + } } diff --git a/Plugins/Mineplex.Minecraft.Game.Core/src/mineplex/minecraft/game/core/combat/CombatLog.java b/Plugins/Mineplex.Minecraft.Game.Core/src/mineplex/minecraft/game/core/combat/CombatLog.java index 370d13997..e6630c8fe 100644 --- a/Plugins/Mineplex.Minecraft.Game.Core/src/mineplex/minecraft/game/core/combat/CombatLog.java +++ b/Plugins/Mineplex.Minecraft.Game.Core/src/mineplex/minecraft/game/core/combat/CombatLog.java @@ -3,9 +3,11 @@ package mineplex.minecraft.game.core.combat; import java.util.ArrayList; import java.util.HashMap; import java.util.LinkedList; +import java.util.List; import mineplex.core.common.util.F; import mineplex.core.common.util.UtilTime; +import mineplex.minecraft.game.core.damage.DamageChange; import org.bukkit.ChatColor; import org.bukkit.entity.LivingEntity; @@ -45,12 +47,12 @@ public class CombatLog } public void Attacked(String damagerName, double damage, - LivingEntity damagerEnt, String attackName) + LivingEntity damagerEnt, String attackName, List mod) { // Add Attacked CombatComponent comp = GetEnemy(damagerName, damagerEnt); - comp.AddDamage(attackName, damage); + comp.AddDamage(attackName, damage, mod); // Set Last LastDamager = comp; diff --git a/Plugins/Mineplex.Minecraft.Game.Core/src/mineplex/minecraft/game/core/combat/CombatManager.java b/Plugins/Mineplex.Minecraft.Game.Core/src/mineplex/minecraft/game/core/combat/CombatManager.java index 86363fc9d..ef5fd3b0e 100644 --- a/Plugins/Mineplex.Minecraft.Game.Core/src/mineplex/minecraft/game/core/combat/CombatManager.java +++ b/Plugins/Mineplex.Minecraft.Game.Core/src/mineplex/minecraft/game/core/combat/CombatManager.java @@ -84,7 +84,7 @@ public class CombatManager extends MiniPlugin Get(damagee).Attacked( UtilEnt.getName(damagerEnt), event.getDamage(), damagerEnt, - event.getCause() + ""); + event.getCause() + "", null); } // Damager is WORLD else @@ -181,7 +181,7 @@ public class CombatManager extends MiniPlugin } Get(damagee).Attacked(source, - event.getDamage(), null, reason); + event.getDamage(), null, reason, null); } } @@ -231,7 +231,7 @@ public class CombatManager extends MiniPlugin Get(event.GetDamageePlayer()).Attacked( UtilEnt.getName(event.GetDamagerEntity(true)), (int) event.GetDamage(), event.GetDamagerEntity(true), - reason); + reason, event.GetDamageMod()); } // Damager is WORLD else @@ -331,7 +331,7 @@ public class CombatManager extends MiniPlugin reason = event.GetReason(); Get(event.GetDamageePlayer()).Attacked(source, - (int) event.GetDamage(), null, reason); + (int) event.GetDamage(), null, reason, event.GetDamageMod()); } } diff --git a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/stats/KillReasonStatTracker.java b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/stats/KillReasonStatTracker.java index 2d89ce679..291951292 100644 --- a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/stats/KillReasonStatTracker.java +++ b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/stats/KillReasonStatTracker.java @@ -5,7 +5,10 @@ import org.bukkit.event.EventHandler; import org.bukkit.event.EventPriority; import mineplex.core.common.util.UtilPlayer; +import mineplex.minecraft.game.core.combat.CombatComponent; +import mineplex.minecraft.game.core.combat.CombatDamage; import mineplex.minecraft.game.core.combat.event.CombatDeathEvent; +import mineplex.minecraft.game.core.damage.DamageChange; import nautilus.game.arcade.game.Game; public class KillReasonStatTracker extends StatTracker @@ -49,6 +52,27 @@ public class KillReasonStatTracker extends StatTracker if (event.GetLog().GetLastDamager() != null && event.GetLog().GetLastDamager().GetReason() != null && event.GetLog().GetLastDamager().GetReason().contains(getReason())) addStat(killer, getStatName(), 1, false, false); + else + { + for (CombatComponent component : event.GetLog().GetAttackers()) + { + for (CombatDamage damage : component.GetDamage()) + { + if (damage.getDamageMod() != null) + { + for (DamageChange mod : damage.getDamageMod()) + { + if (mod.GetReason() != null && mod.GetReason().contains(getReason())) + { + addStat(killer, getStatName(), 1, false, false); + + return; + } + } + } + } + } + } } public String getStatName() From 01d44cd25007217c76da32ca11ba11f3339895a1 Mon Sep 17 00:00:00 2001 From: Shaun Bennett Date: Mon, 27 Oct 2014 19:25:59 -0500 Subject: [PATCH 3/5] Give Item Command --- .../core/inventory/InventoryManager.java | 7 ++ .../inventory/command/GiveItemCommand.java | 70 +++++++++++++++++++ 2 files changed, 77 insertions(+) create mode 100644 Plugins/Mineplex.Core/src/mineplex/core/inventory/command/GiveItemCommand.java diff --git a/Plugins/Mineplex.Core/src/mineplex/core/inventory/InventoryManager.java b/Plugins/Mineplex.Core/src/mineplex/core/inventory/InventoryManager.java index 09d37e81b..2bddb80eb 100644 --- a/Plugins/Mineplex.Core/src/mineplex/core/inventory/InventoryManager.java +++ b/Plugins/Mineplex.Core/src/mineplex/core/inventory/InventoryManager.java @@ -9,6 +9,7 @@ import org.bukkit.plugin.java.JavaPlugin; import mineplex.core.MiniClientPlugin; import mineplex.core.account.event.RetrieveClientInformationEvent; import mineplex.core.common.util.NautHashMap; +import mineplex.core.inventory.command.GiveItemCommand; import mineplex.core.inventory.data.Category; import mineplex.core.inventory.data.InventoryRepository; import mineplex.core.inventory.data.Item; @@ -129,4 +130,10 @@ public class InventoryManager extends MiniClientPlugin } }); } + + @Override + public void AddCommands() + { + AddCommand(new GiveItemCommand(this)); + } } diff --git a/Plugins/Mineplex.Core/src/mineplex/core/inventory/command/GiveItemCommand.java b/Plugins/Mineplex.Core/src/mineplex/core/inventory/command/GiveItemCommand.java new file mode 100644 index 000000000..bf6303d14 --- /dev/null +++ b/Plugins/Mineplex.Core/src/mineplex/core/inventory/command/GiveItemCommand.java @@ -0,0 +1,70 @@ +package mineplex.core.inventory.command; + +import java.util.UUID; + +import org.bukkit.entity.Player; + +import mineplex.core.account.CoreClientManager; +import mineplex.core.command.CommandBase; +import mineplex.core.common.Rank; +import mineplex.core.common.util.F; +import mineplex.core.common.util.UUIDFetcher; +import mineplex.core.common.util.UtilPlayer; +import mineplex.core.inventory.InventoryManager; + +/** + * Created by Shaun on 10/26/2014. + */ +public class GiveItemCommand extends CommandBase +{ + public GiveItemCommand(InventoryManager plugin) + { + super(plugin, Rank.ADMIN, "giveitem"); + } + + @Override + public void Execute(Player caller, String[] args) + { + if (args == null || args.length < 3) + { + displayUsage(caller); + return; + } + + final String playerName = args[0]; + final int amount = Integer.parseInt(args[1]); + String tempItemName = ""; + for (int i = 2; i < args.length; i++) + { + tempItemName += args[i] + " "; + } + final String itemName = tempItemName.trim(); + + Player player = UtilPlayer.searchExact(playerName); + + if (player != null) + { + Plugin.addItemToInventory(player, "Item", itemName, amount); + UtilPlayer.message(caller, F.main("Item", "You gave " + F.elem(amount + " " + itemName) + " to player " + F.name(playerName))); + UtilPlayer.message(player, F.main("Item", F.name(caller.getName()) + " gave you " + F.elem(amount + " " + itemName))); + } + else + { + UUID uuid = UUIDFetcher.getUUIDOf(playerName); + if (uuid != null) + { + Plugin.addItemToInventoryForOffline(uuid.toString(), "Item", itemName, amount); + UtilPlayer.message(caller, F.main("Item", "You gave " + F.elem(amount + " " + itemName) + " to offline player " + F.name(playerName))); + } + else + { + UtilPlayer.message(caller, F.main("Item", "Player " + F.name(playerName) + " does not exist!")); + } + } + } + + public void displayUsage(Player caller) + { + UtilPlayer.message(caller, F.main("Item", "Usage: " + F.elem("/giveitem "))); + } +} \ No newline at end of file From 054c26dfbcc97c98bd56f601fb2fa7d21e048205 Mon Sep 17 00:00:00 2001 From: Shaun Bennett Date: Mon, 27 Oct 2014 19:59:30 -0500 Subject: [PATCH 4/5] New Coin/Gem Command --- .../mineplex/core/donation/CoinCommand.java | 57 ++++++++++++---- .../mineplex/core/donation/GemCommand.java | 67 +++++++++++++------ .../inventory/command/GiveItemCommand.java | 3 +- 3 files changed, 92 insertions(+), 35 deletions(-) diff --git a/Plugins/Mineplex.Core/src/mineplex/core/donation/CoinCommand.java b/Plugins/Mineplex.Core/src/mineplex/core/donation/CoinCommand.java index 3f151a3ac..15219684c 100644 --- a/Plugins/Mineplex.Core/src/mineplex/core/donation/CoinCommand.java +++ b/Plugins/Mineplex.Core/src/mineplex/core/donation/CoinCommand.java @@ -1,11 +1,14 @@ package mineplex.core.donation; +import java.util.UUID; + import org.bukkit.entity.Player; import mineplex.core.command.CommandBase; import mineplex.core.common.Rank; import mineplex.core.common.util.Callback; import mineplex.core.common.util.F; +import mineplex.core.common.util.UUIDFetcher; import mineplex.core.common.util.UtilPlayer; public class CoinCommand extends CommandBase @@ -20,32 +23,58 @@ public class CoinCommand extends CommandBase { if (args.length < 2) { - UtilPlayer.message(caller, F.main("Coin", "Missing Args")); + UtilPlayer.message(caller, F.main("Coin", "Missing Args: " + F.elem("/coin "))); return; } - //Try Online - final Player target = UtilPlayer.searchOnline(caller, args[0], true); + String targetName = args[0]; + String coinsString = args[1]; + Player target = UtilPlayer.searchExact(targetName); if (target == null) - return; + { + UUID uuid = UUIDFetcher.getUUIDOf(targetName); + if (uuid != null) + { + rewardCoins(caller, null, targetName, uuid, coinsString); + } + else + { + UtilPlayer.message(caller, F.main("Coin", "Could not find player " + F.name(targetName))); + } + } + else + { + rewardCoins(caller, target, target.getName(), target.getUniqueId(), coinsString); + } + } - //Give Coins to Target + private void rewardCoins(final Player caller, final Player target, final String targetName, final UUID uuid, String coinsString) + { try { - final int coins = Integer.parseInt(args[1]); - Plugin.RewardCoins(new Callback() - { - public void run(Boolean completed) - { - UtilPlayer.message(caller, F.main("Coin", "You gave " + F.elem(coins + " Coins") + " to " + F.name(target.getName()) + ".")); - UtilPlayer.message(target, F.main("Coin", F.name(caller.getName()) + " gave you " + F.elem(coins + " Coins") + ".")); - } - }, caller.getName(), target.getName(), target.getUniqueId(), coins); + int coins = Integer.parseInt(coinsString); + rewardCoins(caller, target, targetName, uuid, coins); } catch (Exception e) { UtilPlayer.message(caller, F.main("Coin", "Invalid Coins Amount")); } } + + private void rewardCoins(final Player caller, final Player target, final String targetName, final UUID uuid, final int coins) + { + Plugin.RewardCoins(new Callback() + { + public void run(Boolean completed) + { + UtilPlayer.message(caller, F.main("Coin", "You gave " + F.elem(coins + " Coins") + " to " + F.name(targetName) + ".")); + + if (target != null) + { + UtilPlayer.message(target, F.main("Coin", F.name(caller.getName()) + " gave you " + F.elem(coins + " Coins") + ".")); + } + } + }, caller.getName(), targetName, uuid, coins); + } } diff --git a/Plugins/Mineplex.Core/src/mineplex/core/donation/GemCommand.java b/Plugins/Mineplex.Core/src/mineplex/core/donation/GemCommand.java index cffda7ad9..302d7b2d2 100644 --- a/Plugins/Mineplex.Core/src/mineplex/core/donation/GemCommand.java +++ b/Plugins/Mineplex.Core/src/mineplex/core/donation/GemCommand.java @@ -1,11 +1,14 @@ package mineplex.core.donation; +import java.util.UUID; + import org.bukkit.entity.Player; import mineplex.core.command.CommandBase; import mineplex.core.common.Rank; import mineplex.core.common.util.Callback; import mineplex.core.common.util.F; +import mineplex.core.common.util.UUIDFetcher; import mineplex.core.common.util.UtilPlayer; public class GemCommand extends CommandBase @@ -20,32 +23,58 @@ public class GemCommand extends CommandBase { if (args.length < 2) { - UtilPlayer.message(caller, F.main("Gem", "Missing Args")); + UtilPlayer.message(caller, F.main("gem", "Missing Args: " + F.elem("/gem "))); return; } - - //Try Online - final Player target = UtilPlayer.searchOnline(caller, args[0], true); - - if (target == null) - return; - - //Give Gems to Target + + String targetName = args[0]; + String gemsString = args[1]; + Player target = UtilPlayer.searchExact(targetName); + + if (target == null) + { + UUID uuid = UUIDFetcher.getUUIDOf(targetName); + if (uuid != null) + { + rewardGems(caller, null, targetName, uuid, gemsString); + } + else + { + UtilPlayer.message(caller, F.main("Gem", "Could not find player " + F.name(targetName))); + } + } + else + { + rewardGems(caller, target, target.getName(), target.getUniqueId(), gemsString); + } + } + + private void rewardGems(final Player caller, final Player target, final String targetName, final UUID uuid, String gemsString) + { try { - final int gems = Integer.parseInt(args[1]); - Plugin.RewardGems(new Callback() - { - public void run(Boolean completed) - { - UtilPlayer.message(caller, F.main("Gem", "You gave " + F.elem(gems + " Gems") + " to " + F.name(target.getName()) + ".")); - UtilPlayer.message(target, F.main("Gem", F.name(caller.getName()) + " gave you " + F.elem(gems + " Gems") + ".")); - } - }, caller.getName(), target.getName(), target.getUniqueId(), gems); + int gems = Integer.parseInt(gemsString); + rewardGems(caller, target, targetName, uuid, gems); } catch (Exception e) { - UtilPlayer.message(caller, F.main("Gem", "Invalid Gem Amount")); + UtilPlayer.message(caller, F.main("gem", "Invalid gems Amount")); } } + + private void rewardGems(final Player caller, final Player target, final String targetName, final UUID uuid, final int gems) + { + Plugin.RewardGems(new Callback() + { + public void run(Boolean completed) + { + UtilPlayer.message(caller, F.main("gem", "You gave " + F.elem(gems + " gems") + " to " + F.name(targetName) + ".")); + + if (target != null) + { + UtilPlayer.message(target, F.main("gem", F.name(caller.getName()) + " gave you " + F.elem(gems + " gems") + ".")); + } + } + }, caller.getName(), targetName, uuid, gems); + } } diff --git a/Plugins/Mineplex.Core/src/mineplex/core/inventory/command/GiveItemCommand.java b/Plugins/Mineplex.Core/src/mineplex/core/inventory/command/GiveItemCommand.java index bf6303d14..c3901cbe6 100644 --- a/Plugins/Mineplex.Core/src/mineplex/core/inventory/command/GiveItemCommand.java +++ b/Plugins/Mineplex.Core/src/mineplex/core/inventory/command/GiveItemCommand.java @@ -4,7 +4,6 @@ import java.util.UUID; import org.bukkit.entity.Player; -import mineplex.core.account.CoreClientManager; import mineplex.core.command.CommandBase; import mineplex.core.common.Rank; import mineplex.core.common.util.F; @@ -63,7 +62,7 @@ public class GiveItemCommand extends CommandBase } } - public void displayUsage(Player caller) + private void displayUsage(Player caller) { UtilPlayer.message(caller, F.main("Item", "Usage: " + F.elem("/giveitem "))); } From 08f0eb92520130b43bca0e575eb8963033782eed Mon Sep 17 00:00:00 2001 From: CoderTim Date: Wed, 29 Oct 2014 01:40:34 -0400 Subject: [PATCH 5/5] Achievement bug fixes --- .../game/arcade/game/games/snake/Snake.java | 36 +----------------- .../arcade/stats/CannibalStatTracker.java | 37 ------------------- .../stats/KillsWithConditionStatTracker.java | 2 +- .../stats/KillsWithinGameStatTracker.java | 12 +++--- .../arcade/stats/SlimySheepStatTracker.java | 2 +- 5 files changed, 10 insertions(+), 79 deletions(-) delete mode 100644 Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/stats/CannibalStatTracker.java diff --git a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/snake/Snake.java b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/snake/Snake.java index b8c0d0000..207af1c7a 100644 --- a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/snake/Snake.java +++ b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/snake/Snake.java @@ -51,42 +51,12 @@ import nautilus.game.arcade.game.SoloGame; import nautilus.game.arcade.game.games.snake.kits.KitInvulnerable; import nautilus.game.arcade.game.games.snake.kits.KitSpeed; import nautilus.game.arcade.kit.Kit; -import nautilus.game.arcade.stats.CannibalStatTracker; import nautilus.game.arcade.stats.ChooChooStatTracker; +import nautilus.game.arcade.stats.KillsWithinGameStatTracker; import nautilus.game.arcade.stats.SlimySheepStatTracker; public class Snake extends SoloGame { - public static class TailCollisionEvent extends PlayerEvent - { - private static final HandlerList handlers = new HandlerList(); - - public static HandlerList getHandlerList() - { - return handlers; - } - - @Override - public HandlerList getHandlers() - { - return getHandlerList(); - } - - private final Player _killer; - - public TailCollisionEvent(Player who, Player killer) - { - super(who); - - _killer = killer; - } - - public Player getKiller() - { - return _killer; - } - } - public static class TailGrowEvent extends PlayerEvent { private static final HandlerList handlers = new HandlerList(); @@ -177,7 +147,7 @@ public class Snake extends SoloGame this.GemMultiplier = 0.5; registerStatTrackers( - new CannibalStatTracker(this), + new KillsWithinGameStatTracker(this, 8, "Cannibal"), new ChooChooStatTracker(this), new SlimySheepStatTracker(this) ); @@ -395,8 +365,6 @@ public class Snake extends SoloGame Manager.GetDamage().NewDamageEvent(player, killer, null, DamageCause.CUSTOM, 500, false, true, false, killer.getName(), "Snake Tail"); - - Bukkit.getPluginManager().callEvent(new TailCollisionEvent(player, killer)); } else { diff --git a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/stats/CannibalStatTracker.java b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/stats/CannibalStatTracker.java deleted file mode 100644 index f6287e5a0..000000000 --- a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/stats/CannibalStatTracker.java +++ /dev/null @@ -1,37 +0,0 @@ -package nautilus.game.arcade.stats; - -import java.util.HashMap; -import java.util.Map; -import java.util.UUID; - -import org.bukkit.event.EventHandler; -import org.bukkit.event.EventPriority; - -import nautilus.game.arcade.game.Game; -import nautilus.game.arcade.game.games.snake.Snake; - -public class CannibalStatTracker extends StatTracker -{ - private final Map _kills = new HashMap<>(); - - public CannibalStatTracker(Game game) - { - super(game); - } - - @EventHandler(ignoreCancelled = true, priority = EventPriority.MONITOR) - public void onTailCollision(Snake.TailCollisionEvent event) - { - if (getGame().GetState() != Game.GameState.Live) - return; - - Integer killCount = _kills.get(event.getKiller().getUniqueId()); - - killCount = (killCount == null ? 0 : killCount) + 1; - - _kills.put(event.getKiller().getUniqueId(), killCount); - - if (killCount >= 8) - addStat(event.getKiller(), "Cannibal", 1, true, false); - } -} diff --git a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/stats/KillsWithConditionStatTracker.java b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/stats/KillsWithConditionStatTracker.java index 342e19df1..87ed95003 100644 --- a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/stats/KillsWithConditionStatTracker.java +++ b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/stats/KillsWithConditionStatTracker.java @@ -69,7 +69,7 @@ public class KillsWithConditionStatTracker extends StatTracker return; Condition condition = getGame().Manager.GetCondition().GetActiveCondition(player, getConditionType()); - if (condition != null && condition.GetType() == getConditionType() && condition.GetReason() != null && condition.GetReason().contains("Flash Bang")) + if (condition != null && condition.GetType() == getConditionType() && condition.GetReason() != null && condition.GetReason().contains(getConditionReason())) { Integer kills = _kills.get(player.getUniqueId()); kills = (kills == null ? 0 : kills) + 1; diff --git a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/stats/KillsWithinGameStatTracker.java b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/stats/KillsWithinGameStatTracker.java index 586337cdc..c296c4cc6 100644 --- a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/stats/KillsWithinGameStatTracker.java +++ b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/stats/KillsWithinGameStatTracker.java @@ -14,15 +14,15 @@ import nautilus.game.arcade.game.Game; public class KillsWithinGameStatTracker extends StatTracker { - private final int _necessarykillCount; + private final int _necessaryKillCount; private final String _statName; private final Map _kills = new HashMap<>(); - public KillsWithinGameStatTracker(Game game, int necessarykillCount, String statName) + public KillsWithinGameStatTracker(Game game, int necessaryKillCount, String statName) { super(game); - _necessarykillCount = necessarykillCount; + _necessaryKillCount = necessaryKillCount; _statName = statName; } @@ -31,9 +31,9 @@ public class KillsWithinGameStatTracker extends StatTracker return _statName; } - public int getNecessarykillCount() + public int getNecessaryKillCount() { - return _necessarykillCount; + return _necessaryKillCount; } @EventHandler(ignoreCancelled = true, priority = EventPriority.MONITOR) @@ -56,7 +56,7 @@ public class KillsWithinGameStatTracker extends StatTracker killCount = (killCount == null ? 0 : killCount) + 1; _kills.put(player.getUniqueId(), killCount); - if (killCount == 12) + if (killCount == getNecessaryKillCount()) addStat(player, getStatName(), 1, true, false); } } diff --git a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/stats/SlimySheepStatTracker.java b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/stats/SlimySheepStatTracker.java index 8e0962dd9..5d64b37ef 100644 --- a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/stats/SlimySheepStatTracker.java +++ b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/stats/SlimySheepStatTracker.java @@ -20,7 +20,7 @@ public class SlimySheepStatTracker extends StatTracker } @EventHandler(ignoreCancelled = true, priority = EventPriority.MONITOR) - public void onTailCollision(Snake.SlimeUpgradeEvent event) + public void onSlimeUpgrade(Snake.SlimeUpgradeEvent event) { if (getGame().GetState() != Game.GameState.Live) return;