From 7ca6f581082eea9e1c50bb2bd6ef609cf49246b0 Mon Sep 17 00:00:00 2001 From: Sarah Date: Sun, 13 Sep 2015 10:25:44 +0200 Subject: [PATCH] Adding Gem signs. --- .../arcade/game/games/event/EventGame.java | 48 +++++++++++++++++++ .../arcade/game/games/event/EventModule.java | 6 +++ 2 files changed, 54 insertions(+) diff --git a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/event/EventGame.java b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/event/EventGame.java index 0957549dd..20caa6877 100644 --- a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/event/EventGame.java +++ b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/event/EventGame.java @@ -7,6 +7,7 @@ import java.util.HashSet; import java.util.Iterator; import java.util.List; +import mineplex.core.common.util.Callback; import mineplex.core.common.util.F; import mineplex.core.common.util.NautHashMap; import mineplex.core.common.util.UtilAction; @@ -58,6 +59,7 @@ import org.bukkit.entity.Entity; import org.bukkit.entity.Player; import org.bukkit.event.EventHandler; import org.bukkit.event.EventPriority; +import org.bukkit.event.block.Action; import org.bukkit.event.block.BlockBreakEvent; import org.bukkit.event.block.BlockRedstoneEvent; import org.bukkit.event.block.SignChangeEvent; @@ -68,6 +70,7 @@ import org.bukkit.event.entity.EntityDeathEvent; import org.bukkit.event.entity.EntityExplodeEvent; import org.bukkit.event.player.PlayerDropItemEvent; import org.bukkit.event.player.PlayerInteractEntityEvent; +import org.bukkit.event.player.PlayerInteractEvent; import org.bukkit.event.player.PlayerJoinEvent; import org.bukkit.event.player.PlayerToggleFlightEvent; import org.bukkit.inventory.ItemStack; @@ -1221,6 +1224,51 @@ public class EventGame extends Game event.setCancelled(true); } + @EventHandler + public void gemSign(final PlayerInteractEvent event) + { + if(event.getAction() != Action.RIGHT_CLICK_BLOCK) + return; + + if(!(event.getClickedBlock() instanceof Sign)) + return; + + Sign sign = (Sign) event.getClickedBlock().getState(); + if(!sign.getLine(0).contentEquals("[GEM]")) + return; + + final Material mat = Material.getMaterial(Integer.parseInt(sign.getLine(1))); + Integer price = Integer.parseInt(sign.getLine(2)); + if(price > 500) + price = 500; + + if(price <= 0) + { + UtilPlayer.message(event.getPlayer(), F.main("Event", "You got an item for free.")); + event.getPlayer().getInventory().addItem(new ItemStack(mat)); + return; + } + + if(Manager.GetDonation().Get(event.getPlayer()).GetGems() < price) + { + UtilPlayer.message(event.getPlayer(), F.main("Event", "You dont have enough Gems.")); + return; + } + + final int gems = price; + Manager.GetDonation().RewardGems(new Callback() + { + public void run(Boolean completed) + { + if (completed) + { + UtilPlayer.message(event.getPlayer(), F.main("Event", "You bought an item for " + gems + " Gems.")); + event.getPlayer().getInventory().addItem(new ItemStack(mat)); + } + } + }, "Gem Sign", event.getPlayer().getName(), event.getPlayer().getUniqueId(), -price); + } + public class EventArea { diff --git a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/event/EventModule.java b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/event/EventModule.java index 9e980a32f..9dc6de524 100644 --- a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/event/EventModule.java +++ b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/event/EventModule.java @@ -159,6 +159,12 @@ public class EventModule extends MiniPlugin UtilPlayer.message(player, F.value("/e give [e:#,e:#...]", "Give Item")); UtilPlayer.message(player, F.value("/e doublejump", "Toggles Double Jump")); + UtilPlayer.message(player, F.value("/e bc", "Broadcast a message with colorcodes")); + UtilPlayer.message(player, F.value("/e tempgadget", "Activates gadget for all player")); + UtilPlayer.message(player, F.value("/e playerdamage", "Toggles damage fpr player")); + UtilPlayer.message(player, F.value("/e stacker [Player]", "toggles stacker global or for Players")); + UtilPlayer.message(player, F.value("/e kick", "Remove a player from the event")); + UtilPlayer.message(player, F.value("/e area PVP|ALL|PVE|EVP|Gadget|Effect / add", "Create and edit areas")); UtilPlayer.message(player, F.value("/e scoreboard [Text]", "Sets Scoreboard Text"));