From 36285ee101b0e097be45c471b0a11adf320bca0b Mon Sep 17 00:00:00 2001 From: xXVevzZXx Date: Wed, 6 Jul 2016 18:55:13 +0200 Subject: [PATCH] Improve GunModule with editable variables --- .../game/games/minestrike/GunModule.java | 43 ++++++++++--------- .../game/games/minestrike/items/guns/Gun.java | 7 ++- .../survivalgames/modes/StrikeGames.java | 11 +++-- 3 files changed, 35 insertions(+), 26 deletions(-) diff --git a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/minestrike/GunModule.java b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/minestrike/GunModule.java index f975d28be..f9bac4828 100644 --- a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/minestrike/GunModule.java +++ b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/minestrike/GunModule.java @@ -101,10 +101,6 @@ public class GunModule implements Listener { public ArcadeManager Manager; private Game _host; - - public static float RECOIL = 0.8f; - public static float CONE = 0.7f; - public static float MOVE_PENALTY = 0.8f; public static class RoundOverEvent extends Event { @@ -134,18 +130,23 @@ public class GunModule implements Listener } } + + public static float RECOIL = 0.8f; + public static float CONE = 0.7f; + public static float MOVE_PENALTY = 0.8f; + public boolean Debug = false; public int BulletInstant = 2; //0 = Slow, 1 = Instant, 2 = Mix public boolean CustomHitbox = true; public boolean BulletAlternate = false; + + public boolean EnablePickup = true; + public boolean EnableDrop = true; + public boolean EnableCleaning = true; private long _freezeTime = -1; private int _round; - - private boolean _enablePickup = true; - private boolean _enableDrop = true; - private boolean _enableCleaning = true; //Ongoing Data private HashMap _gunsEquipped = new HashMap(); @@ -171,7 +172,7 @@ public class GunModule implements Listener private long _bombHolderLastMove = 0; private HashMap _scoped = new HashMap(); - + public GunModule(Game host) { _host = host; @@ -428,7 +429,7 @@ public class GunModule implements Listener @EventHandler public void triggerDrop(PlayerDropItemEvent event) { - if(!_enableDrop) + if(!EnableDrop) return; if (!_host.InProgress()) @@ -574,7 +575,7 @@ public class GunModule implements Listener @EventHandler public void triggerPickup(PlayerPickupItemEvent event) { - if (!_enablePickup) + if (!EnablePickup) return; if (!_host.InProgress()) @@ -1476,7 +1477,7 @@ public class GunModule implements Listener @EventHandler public void clean(UpdateEvent event) { - if(!_enableCleaning) + if(!EnableCleaning) return; if (!_host.IsLive()) @@ -1666,8 +1667,8 @@ public class GunModule implements Listener { try { - GunModule.RECOIL = Float.parseFloat(event.getMessage().split(" ")[1]); - _host.Announce(C.cPurple + C.Bold + "Recoil Bloom: " + ChatColor.RESET + (int)(GunModule.RECOIL * 100) + "%"); + RECOIL = Float.parseFloat(event.getMessage().split(" ")[1]); + _host.Announce(C.cPurple + C.Bold + "Recoil Bloom: " + ChatColor.RESET + (int)(RECOIL * 100) + "%"); } catch (Exception e) { @@ -1680,8 +1681,8 @@ public class GunModule implements Listener { try { - GunModule.CONE = Float.parseFloat(event.getMessage().split(" ")[1]); - _host.Announce(C.cPurple + C.Bold + "Cone of Fire: " + ChatColor.RESET + (int)(GunModule.CONE * 100) + "%"); + CONE = Float.parseFloat(event.getMessage().split(" ")[1]); + _host.Announce(C.cPurple + C.Bold + "Cone of Fire: " + ChatColor.RESET + (int)(CONE * 100) + "%"); } catch (Exception e) { @@ -1694,8 +1695,8 @@ public class GunModule implements Listener { try { - GunModule.MOVE_PENALTY = Float.parseFloat(event.getMessage().split(" ")[1]); - _host.Announce(C.cPurple + C.Bold + "Move/Sprint/Jump Penalties: " + ChatColor.RESET + (int)(GunModule.MOVE_PENALTY * 100) + "%"); + MOVE_PENALTY = Float.parseFloat(event.getMessage().split(" ")[1]); + _host.Announce(C.cPurple + C.Bold + "Move/Sprint/Jump Penalties: " + ChatColor.RESET + (int)(MOVE_PENALTY * 100) + "%"); } catch (Exception e) { @@ -1997,17 +1998,17 @@ public class GunModule implements Listener public void setEnablePickup(boolean pickup) { - _enablePickup = pickup; + EnablePickup = pickup; } public void setEnableDrop(boolean drop) { - _enableDrop = drop; + EnableDrop = drop; } public void setEnableCleaning(boolean cleaning) { - _enableCleaning = cleaning; + EnableCleaning = cleaning; } public Game getHost() diff --git a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/minestrike/items/guns/Gun.java b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/minestrike/items/guns/Gun.java index 377253133..dea461fff 100644 --- a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/minestrike/items/guns/Gun.java +++ b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/minestrike/items/guns/Gun.java @@ -1,5 +1,6 @@ package nautilus.game.arcade.game.games.minestrike.items.guns; +import java.util.Arrays; import java.util.HashMap; import org.bukkit.ChatColor; @@ -81,6 +82,10 @@ public class Gun extends StrikeItem _loadedAmmo = gunStats.getClipSize(); _reserveAmmo = gunStats.getClipReserve() * gunStats.getClipSize(); + ItemMeta meta = getStack().getItemMeta(); + meta.setLore(Arrays.asList(ChatColor.RED + "" + ChatColor.BOLD + "Identifier: " + UtilMath.r(1000) + 1)); + getStack().setItemMeta(meta); + updateWeaponName(null, null); } @@ -191,7 +196,7 @@ public class Gun extends StrikeItem Vector cof = new Vector(Math.random() - 0.5, (Math.random() - 0.2) * (5d/8d), Math.random() - 0.5); cof.normalize(); cof.multiply(cone); - cof.multiply(GunModule.CONE); + cof.multiply(_module.CONE); cof.add(player.getLocation().getDirection()); cof.normalize(); diff --git a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/survivalgames/modes/StrikeGames.java b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/survivalgames/modes/StrikeGames.java index cbaf46847..38581ad8f 100644 --- a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/survivalgames/modes/StrikeGames.java +++ b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/survivalgames/modes/StrikeGames.java @@ -83,9 +83,9 @@ public class StrikeGames extends SoloSurvivalGames _peacePhase = 20000; _gunModule = new GunModule(this); - _gunModule.setEnablePickup(false); - _gunModule.setEnableDrop(false); - _gunModule.setEnableCleaning(false); + _gunModule.EnableCleaning = false; + _gunModule.EnableDrop = false; + _gunModule.EnablePickup = false; } @EventHandler @@ -403,7 +403,10 @@ public class StrikeGames extends SoloSurvivalGames { Gun gun = new Gun(stat, _gunModule); ItemMeta meta = stack.getItemMeta(); - meta.setLore(Arrays.asList(ChatColor.RED + "" + ChatColor.BOLD + "Identifier: " + UtilMath.r(1000) + 1)); + + if (gun.getStack().hasItemMeta() && gun.getStack().getItemMeta().hasLore()) + meta.setLore(gun.getStack().getItemMeta().getLore()); + stack.setItemMeta(meta); gun.setStack(stack); gun.updateWeaponName(player, null, false);