From f2f429f21d2f3050d78b45e5c7bfeef315ec5dde Mon Sep 17 00:00:00 2001 From: Charlie Wang Date: Sun, 30 Jun 2013 20:52:49 -0400 Subject: [PATCH] only allow one party per player --- .../bukkit/discosheep/DiscoSheep.java | 34 ++++++++++--------- .../discosheep/DiscoSheepCommandExecutor.java | 2 +- 2 files changed, 19 insertions(+), 17 deletions(-) diff --git a/src/gibstick/bukkit/discosheep/DiscoSheep.java b/src/gibstick/bukkit/discosheep/DiscoSheep.java index 9b9fb7b..c02e9fc 100644 --- a/src/gibstick/bukkit/discosheep/DiscoSheep.java +++ b/src/gibstick/bukkit/discosheep/DiscoSheep.java @@ -9,7 +9,7 @@ import org.bukkit.plugin.java.JavaPlugin; public final class DiscoSheep extends JavaPlugin { - Map parties = new HashMap(); + Map parties = new HashMap(); private SheepDeshearer deshear = new SheepDeshearer(this); // array of accetable disco colours (order not important) @@ -23,35 +23,37 @@ public final class DiscoSheep extends JavaPlugin { public void onDisable() { } - public Map getPartyMap() { + public Map getPartyMap() { return this.parties; } - - public List getParties(){ + + public List getParties() { return new ArrayList(this.parties.values()); } - - public void stopParty(String name){ - if(this.hasParty(name)){ + + public void stopParty(String name) { + if (this.hasParty(name)) { this.getParty(name).stopDisco(); } } - - public boolean hasParty(String name){ + + public boolean hasParty(String name) { return this.parties.containsKey(name); } - - public DiscoParty getParty(String name){ + + public DiscoParty getParty(String name) { return this.parties.get(name); } - - public void removeParty(String name){ - if(this.hasParty(name)){ + + public void removeParty(String name) { + if (this.hasParty(name)) { this.parties.remove(name); } } - public void startDisco(Player player) { - new DiscoParty(this, player).startDisco(); + public void startParty(Player player) { + if (!hasParty(player.getName())) { + new DiscoParty(this, player).startDisco(); + } } } diff --git a/src/gibstick/bukkit/discosheep/DiscoSheepCommandExecutor.java b/src/gibstick/bukkit/discosheep/DiscoSheepCommandExecutor.java index 9a0b746..d56a8b1 100644 --- a/src/gibstick/bukkit/discosheep/DiscoSheepCommandExecutor.java +++ b/src/gibstick/bukkit/discosheep/DiscoSheepCommandExecutor.java @@ -16,7 +16,7 @@ public class DiscoSheepCommandExecutor implements CommandExecutor { @Override public boolean onCommand(CommandSender sender, Command cmd, String label, String[] args) { if (sender instanceof Player) { - parent.startDisco((Player)sender); + parent.startParty((Player)sender); } return true; }