From fc5141a197f61333eaf49683f7b4895a72bf08b5 Mon Sep 17 00:00:00 2001 From: alisolarflare Date: Thu, 3 Nov 2016 23:01:12 -0400 Subject: [PATCH] Digested Townylearn, and refactored more --- src/alisolarflare/AliPresents.java | 10 +- .../flairdoor/listeners/PortalListener.java | 27 +++--- .../CreativeBoundariesModule.java | 23 +++++ .../PlotChangeListener.java | 94 +++++++++---------- .../creativeboundaries/commands/Cbgm0.java | 41 ++++++++ .../creativeboundaries/commands/Cbgm1.java | 74 +++++++++++++++ .../commands/SetDickmode.java | 54 +++++++++++ src/alisolarflare/magic/MagicModule.java | 4 +- .../AliArrowListener.java | 2 +- .../{aliarrow => tricks}/AliArrowTask.java | 2 +- .../{boombow => tricks}/BoomBowListener.java | 2 +- .../{boombow => tricks}/BoomBowRule.java | 2 +- .../minigames/MinigameModule.java | 33 +++++++ .../minigames/commands/JoinMinigame.java | 53 +++++++++++ .../minigames/commands/LeaveMinigame.java | 53 +++++++++++ .../{lobby => }/commands/ListFighters.java | 8 +- .../SetColourSpawn.java} | 13 +-- .../{freeforall => }/data/SpawnSet.java | 2 +- .../minigames/entities/Fighter.java | 11 +++ .../freeforall/FreeForAllModule.java | 24 ----- .../minigames/freeforall/data/Data.java | 8 -- .../freeforall/entities/Fighter.java | 17 ---- .../minigames/lobby/LobbyModule.java | 20 ---- .../minigames/lobby/commands/ButtonFight.java | 51 ---------- .../minigames/lobby/commands/ButtonLeave.java | 48 ---------- src/alisolarflare/townylearn/MainPlugin.java | 34 ------- .../townylearn/commands/Cbgm0.java | 23 ----- .../townylearn/commands/Cbgm1.java | 53 ----------- .../townylearn/commands/SetDickmode.java | 37 -------- .../{events => }/uhc/UHCModule.java | 12 ++- .../{events => }/uhc/commands/AddToUHC.java | 4 +- .../{events => }/uhc/commands/StartMatch.java | 4 +- .../uhc/listeners/MatchCyclingListener.java | 2 +- .../uhc/listeners/MatchMainLoop.java | 2 +- .../{events => }/uhc/memory/MatchState.java | 2 +- .../{events => }/uhc/memory/UHCMatch.java | 2 +- 36 files changed, 437 insertions(+), 414 deletions(-) create mode 100644 src/alisolarflare/creativeboundaries/CreativeBoundariesModule.java rename src/alisolarflare/{townylearn => creativeboundaries}/PlotChangeListener.java (86%) create mode 100644 src/alisolarflare/creativeboundaries/commands/Cbgm0.java create mode 100644 src/alisolarflare/creativeboundaries/commands/Cbgm1.java create mode 100644 src/alisolarflare/creativeboundaries/commands/SetDickmode.java rename src/alisolarflare/magic/{aliarrow => tricks}/AliArrowListener.java (92%) rename src/alisolarflare/magic/{aliarrow => tricks}/AliArrowTask.java (92%) rename src/alisolarflare/magic/{boombow => tricks}/BoomBowListener.java (95%) rename src/alisolarflare/magic/{boombow => tricks}/BoomBowRule.java (94%) create mode 100644 src/alisolarflare/minigames/MinigameModule.java create mode 100644 src/alisolarflare/minigames/commands/JoinMinigame.java create mode 100644 src/alisolarflare/minigames/commands/LeaveMinigame.java rename src/alisolarflare/minigames/{lobby => }/commands/ListFighters.java (76%) rename src/alisolarflare/minigames/{freeforall/commands/SetFFAS.java => commands/SetColourSpawn.java} (84%) rename src/alisolarflare/minigames/{freeforall => }/data/SpawnSet.java (92%) create mode 100644 src/alisolarflare/minigames/entities/Fighter.java delete mode 100644 src/alisolarflare/minigames/freeforall/FreeForAllModule.java delete mode 100644 src/alisolarflare/minigames/freeforall/data/Data.java delete mode 100644 src/alisolarflare/minigames/freeforall/entities/Fighter.java delete mode 100644 src/alisolarflare/minigames/lobby/LobbyModule.java delete mode 100644 src/alisolarflare/minigames/lobby/commands/ButtonFight.java delete mode 100644 src/alisolarflare/minigames/lobby/commands/ButtonLeave.java delete mode 100644 src/alisolarflare/townylearn/MainPlugin.java delete mode 100644 src/alisolarflare/townylearn/commands/Cbgm0.java delete mode 100644 src/alisolarflare/townylearn/commands/Cbgm1.java delete mode 100644 src/alisolarflare/townylearn/commands/SetDickmode.java rename src/alisolarflare/{events => }/uhc/UHCModule.java (66%) rename src/alisolarflare/{events => }/uhc/commands/AddToUHC.java (89%) rename src/alisolarflare/{events => }/uhc/commands/StartMatch.java (89%) rename src/alisolarflare/{events => }/uhc/listeners/MatchCyclingListener.java (89%) rename src/alisolarflare/{events => }/uhc/listeners/MatchMainLoop.java (71%) rename src/alisolarflare/{events => }/uhc/memory/MatchState.java (64%) rename src/alisolarflare/{events => }/uhc/memory/UHCMatch.java (90%) diff --git a/src/alisolarflare/AliPresents.java b/src/alisolarflare/AliPresents.java index ab28777..14da8b4 100644 --- a/src/alisolarflare/AliPresents.java +++ b/src/alisolarflare/AliPresents.java @@ -9,10 +9,10 @@ import org.bukkit.plugin.java.JavaPlugin; import alisolarflare.components.flairdoor.FlairDoorModule; import alisolarflare.components.gpowers.GPowerModule; import alisolarflare.components.links.AliLinkModule; -import alisolarflare.events.uhc.UHCModule; +import alisolarflare.creativeboundaries.CreativeBoundariesModule; import alisolarflare.magic.MagicModule; -import alisolarflare.minigames.freeforall.FreeForAllModule; -import alisolarflare.minigames.lobby.LobbyModule; +import alisolarflare.minigames.MinigameModule; +import alisolarflare.uhc.UHCModule; public class AliPresents extends JavaPlugin{ public void onEnable(){ @@ -27,8 +27,8 @@ public class AliPresents extends JavaPlugin{ new AliLinkModule().register(this); new UHCModule().register(this); new MagicModule().register(this); - new FreeForAllModule().register(this); - new LobbyModule().register(this); + new MinigameModule().register(this); + new CreativeBoundariesModule().register(this); logger.info(pdfFile.getName() + " has fully registered (V." + pdfFile.getVersion()+ ")."); diff --git a/src/alisolarflare/components/flairdoor/listeners/PortalListener.java b/src/alisolarflare/components/flairdoor/listeners/PortalListener.java index 4e86f74..a41d3bb 100644 --- a/src/alisolarflare/components/flairdoor/listeners/PortalListener.java +++ b/src/alisolarflare/components/flairdoor/listeners/PortalListener.java @@ -37,7 +37,6 @@ public class PortalListener implements Listener{ //INIT - Player Player player = event.getPlayer(); - player.sendMessage("MAY THE FLAIRING COMMENCE"); //SANITATION - PlayersToBeFlaired if(!(playersToBeFlaired.contains(player.getName()))){ @@ -53,31 +52,31 @@ public class PortalListener implements Listener{ int z = player.getLocation().getBlockZ(); //INIT - Blocks Under Portal - Block blockTopper = player.getWorld().getBlockAt(x,y-1,z); - Block blockMiddle = player.getWorld().getBlockAt(x,y-2,z); - Block blockBottom = player.getWorld().getBlockAt(x,y-3,z); + Block HigherBlock = player.getWorld().getBlockAt(x,y-1,z); + Block MiddleBlock = player.getWorld().getBlockAt(x,y-2,z); + Block BottomBlock = player.getWorld().getBlockAt(x,y-3,z); player.sendMessage("Blocks being inspected:"); - player.sendMessage(blockTopper.toString()); - player.sendMessage(blockMiddle.toString()); - player.sendMessage(blockBottom.toString()); + player.sendMessage(HigherBlock.toString()); + player.sendMessage(MiddleBlock.toString()); + player.sendMessage(BottomBlock.toString()); //RECOLOUR PLAYER - if(blockTopper.getType() == Material.STONE){ + if(HigherBlock.getType() == Material.STONE){ player.sendMessage("STONE DETECTED"); recolourPlayer(player, DyeColor.GRAY); //TOP BLOCK IS WOOL? - }else if(blockTopper.getType() == Material.WOOL){ + }else if(HigherBlock.getType() == Material.WOOL){ player.sendMessage("WOOL DETECTED T"); - Wool wool = (Wool) blockTopper.getState().getData(); + Wool wool = (Wool) HigherBlock.getState().getData(); recolourPlayer(player, wool.getColor()); //MIDDLE BLOCK IS WOOL? - }else if(blockMiddle.getType() == Material.WOOL){ + }else if(MiddleBlock.getType() == Material.WOOL){ player.sendMessage("WOOL DETECTED M"); - MaterialData mData = blockMiddle.getState().getData(); + MaterialData mData = MiddleBlock.getState().getData(); player.sendMessage("MATERIAL DATA COLLECTED: "+ mData.toString()); Wool wool = (Wool) mData; player.sendMessage("WOOL DATA CONVERTED: "+ wool.toString()); @@ -85,9 +84,9 @@ public class PortalListener implements Listener{ recolourPlayer(player, wool.getColor()); //BOTTOM BLOCK IS WOOL? - }else if (blockBottom.getType() == Material.WOOL){ + }else if (BottomBlock.getType() == Material.WOOL){ player.sendMessage("WOOL DETECTED B"); - Wool wool = (Wool) blockBottom.getState().getData(); + Wool wool = (Wool) BottomBlock.getState().getData(); recolourPlayer(player, wool.getColor()); } diff --git a/src/alisolarflare/creativeboundaries/CreativeBoundariesModule.java b/src/alisolarflare/creativeboundaries/CreativeBoundariesModule.java new file mode 100644 index 0000000..09b6639 --- /dev/null +++ b/src/alisolarflare/creativeboundaries/CreativeBoundariesModule.java @@ -0,0 +1,23 @@ +package alisolarflare.creativeboundaries; + +import org.bukkit.plugin.java.JavaPlugin; + +import alisolarflare.Module; +import alisolarflare.creativeboundaries.commands.Cbgm0; +import alisolarflare.creativeboundaries.commands.Cbgm1; +import alisolarflare.creativeboundaries.commands.SetDickmode; + + +public class CreativeBoundariesModule extends Module{ + public boolean dickmode; + @Override + public void register(JavaPlugin plugin) { + registerCommand(plugin, new Cbgm1()); + registerCommand(plugin, new Cbgm0()); + registerCommand(plugin, new SetDickmode(this)); + + + registerListener(plugin, new PlotChangeListener(this)); + } + +} diff --git a/src/alisolarflare/townylearn/PlotChangeListener.java b/src/alisolarflare/creativeboundaries/PlotChangeListener.java similarity index 86% rename from src/alisolarflare/townylearn/PlotChangeListener.java rename to src/alisolarflare/creativeboundaries/PlotChangeListener.java index 3e9421b..e815539 100644 --- a/src/alisolarflare/townylearn/PlotChangeListener.java +++ b/src/alisolarflare/creativeboundaries/PlotChangeListener.java @@ -1,47 +1,47 @@ -package alisolarflare.townylearn; - -import org.bukkit.GameMode; -import org.bukkit.event.EventHandler; -import org.bukkit.event.Listener; - -import com.palmergames.bukkit.towny.event.PlayerChangePlotEvent; -import com.palmergames.bukkit.towny.exceptions.NotRegisteredException; -import com.palmergames.bukkit.towny.object.Resident; -import com.palmergames.bukkit.towny.object.Town; -import com.palmergames.bukkit.towny.object.TownBlock; - -public class PlotChangeListener implements Listener{ - public boolean isInTown; - public MainPlugin plugin; - public PlotChangeListener(MainPlugin plugin){ - this.plugin = plugin; - } - @EventHandler - public void onPlayerPlotChange(PlayerChangePlotEvent plotEvent){ - if (plugin.dickmode == false){ - return; - } - try{ - Resident currentResident = new Resident(plotEvent.getPlayer().getName().toLowerCase()); - TownBlock plot = plotEvent.getTo().getTownBlock(); - - if(plot.hasTown()){ - Town plotTown = plot.getTown(); - - if(!(plotTown.hasResident(currentResident))){ - plotEvent.getPlayer().setGameMode(GameMode.SURVIVAL); - - } - - } else { - plotEvent.getPlayer().setGameMode(GameMode.SURVIVAL); - } - - }catch(NotRegisteredException e){ - //thrown by plotEvent.getTo().getTownBlock() - //thrown by plotEvent.getTo().getTownBlock().getTown(); - plotEvent.getPlayer().setGameMode(GameMode.SURVIVAL); - - } - } -} +package alisolarflare.creativeboundaries; + +import org.bukkit.GameMode; +import org.bukkit.event.EventHandler; +import org.bukkit.event.Listener; + +import com.palmergames.bukkit.towny.event.PlayerChangePlotEvent; +import com.palmergames.bukkit.towny.exceptions.NotRegisteredException; +import com.palmergames.bukkit.towny.object.Resident; +import com.palmergames.bukkit.towny.object.Town; +import com.palmergames.bukkit.towny.object.TownBlock; + +public class PlotChangeListener implements Listener{ + public boolean isInTown; + public CreativeBoundariesModule plugin; + public PlotChangeListener(CreativeBoundariesModule plugin){ + this.plugin = plugin; + } + @EventHandler + public void onPlayerPlotChange(PlayerChangePlotEvent plotEvent){ + if (plugin.dickmode == false){ + return; + } + try{ + Resident currentResident = new Resident(plotEvent.getPlayer().getName().toLowerCase()); + TownBlock plot = plotEvent.getTo().getTownBlock(); + + if(plot.hasTown()){ + Town plotTown = plot.getTown(); + + if(!(plotTown.hasResident(currentResident))){ + plotEvent.getPlayer().setGameMode(GameMode.SURVIVAL); + + } + + } else { + plotEvent.getPlayer().setGameMode(GameMode.SURVIVAL); + } + + }catch(NotRegisteredException e){ + //thrown by plotEvent.getTo().getTownBlock() + //thrown by plotEvent.getTo().getTownBlock().getTown(); + plotEvent.getPlayer().setGameMode(GameMode.SURVIVAL); + + } + } +} diff --git a/src/alisolarflare/creativeboundaries/commands/Cbgm0.java b/src/alisolarflare/creativeboundaries/commands/Cbgm0.java new file mode 100644 index 0000000..88ba03a --- /dev/null +++ b/src/alisolarflare/creativeboundaries/commands/Cbgm0.java @@ -0,0 +1,41 @@ +package alisolarflare.creativeboundaries.commands; + +import org.bukkit.GameMode; +import org.bukkit.command.CommandSender; +import org.bukkit.entity.Player; + +import buttondevteam.lib.chat.TBMCCommandBase; + +public class Cbgm0 extends TBMCCommandBase{ + + @Override + public boolean OnCommand(CommandSender sender, String arg2, String[] arg3) { + if (!(sender instanceof Player)){ + sender.sendMessage("You must be a player to use this command!"); + return false; + } + + Player player = (Player) sender; + player.setGameMode(GameMode.SURVIVAL); + return false; + } + + @Override + public String[] GetHelpText(String alias) { + // TODO Auto-generated method stub + return null; + } + + @Override + public boolean GetPlayerOnly() { + // TODO Auto-generated method stub + return false; + } + + @Override + public boolean GetModOnly() { + // TODO Auto-generated method stub + return false; + } + +} diff --git a/src/alisolarflare/creativeboundaries/commands/Cbgm1.java b/src/alisolarflare/creativeboundaries/commands/Cbgm1.java new file mode 100644 index 0000000..09753cc --- /dev/null +++ b/src/alisolarflare/creativeboundaries/commands/Cbgm1.java @@ -0,0 +1,74 @@ +package alisolarflare.creativeboundaries.commands; + +import org.bukkit.GameMode; +import org.bukkit.command.CommandSender; +import org.bukkit.entity.Player; + +import com.palmergames.bukkit.towny.exceptions.NotRegisteredException; +import com.palmergames.bukkit.towny.object.Resident; +import com.palmergames.bukkit.towny.object.Town; +import com.palmergames.bukkit.towny.object.TownBlock; +import com.palmergames.bukkit.towny.object.TownyUniverse; + +import buttondevteam.lib.chat.TBMCCommandBase; + +public class Cbgm1 extends TBMCCommandBase { + + @Override + public boolean OnCommand(CommandSender sender, String arg2, String[] arg3) { + + if (!(sender instanceof Player)) { + sender.sendMessage("You must be a player to use this command!"); + return false; + } + + Player player = (Player) sender; + + TownBlock tb = TownyUniverse.getTownBlock(player.getLocation()); + if (tb == null) { + player.sendMessage("�cYou aren't standing in a town or some other error occured."); + player.sendMessage("�cTownBlock is null."); + return false; + } + Town town; + try { + town = tb.getTown(); + } catch (NotRegisteredException e) { + player.sendMessage("�cYou aren't standing in a town or some other error occured."); + player.sendMessage("�cTownBlock's town is not registered."); + return false; + } + if (town == null) { + player.sendMessage("�cERROR: The town you're standing in is Null."); + return false; + } + + for(Resident res : town.getResidents()){ + if (res.getName().toString().equals(player.getName().toString())){ + player.setGameMode(GameMode.CREATIVE); + return true; + } + } + player.sendMessage("Sorry, you're not part of this town"); + return false; + } + + @Override + public String[] GetHelpText(String alias) { + // TODO Auto-generated method stub + return null; + } + + @Override + public boolean GetPlayerOnly() { + // TODO Auto-generated method stub + return false; + } + + @Override + public boolean GetModOnly() { + // TODO Auto-generated method stub + return false; + } + +} diff --git a/src/alisolarflare/creativeboundaries/commands/SetDickmode.java b/src/alisolarflare/creativeboundaries/commands/SetDickmode.java new file mode 100644 index 0000000..5cb3b14 --- /dev/null +++ b/src/alisolarflare/creativeboundaries/commands/SetDickmode.java @@ -0,0 +1,54 @@ +package alisolarflare.creativeboundaries.commands; + +import org.bukkit.command.CommandSender; + +import alisolarflare.creativeboundaries.CreativeBoundariesModule; +import buttondevteam.lib.chat.TBMCCommandBase; + +public class SetDickmode extends TBMCCommandBase{ + private CreativeBoundariesModule plugin; + + public SetDickmode(CreativeBoundariesModule plugin){ + this.plugin = plugin; + } + + @Override + public boolean OnCommand(CommandSender sender, String label, String[] args) { + if (sender.getName().equals("Alisolarflare") || sender.getName().equals("iie")){ + if(args[0] == null){ + sender.sendMessage("You must use True, False, 1, or 0 as arguments!"); + return false; + } + if(args[0].equalsIgnoreCase("TRUE") || args[0].equalsIgnoreCase("1")){ + sender.sendMessage("Dickmode has been turned on!"); + plugin.dickmode=(true); + return true; + } + if(args[0].equalsIgnoreCase("FALSE") || args[0].equalsIgnoreCase("0")){ + sender.sendMessage("Dickmode has been turned off!"); + plugin.dickmode=(false); + return true; + } + return false; + } + return false; + } + + @Override + public String[] GetHelpText(String alias) { + // TODO Auto-generated method stub + return null; + } + + @Override + public boolean GetPlayerOnly() { + // TODO Auto-generated method stub + return false; + } + + @Override + public boolean GetModOnly() { + // TODO Auto-generated method stub + return false; + } +} diff --git a/src/alisolarflare/magic/MagicModule.java b/src/alisolarflare/magic/MagicModule.java index 6b77bb1..2b37e22 100644 --- a/src/alisolarflare/magic/MagicModule.java +++ b/src/alisolarflare/magic/MagicModule.java @@ -3,8 +3,8 @@ package alisolarflare.magic; import org.bukkit.plugin.java.JavaPlugin; import alisolarflare.Module; -import alisolarflare.magic.aliarrow.AliArrowListener; -import alisolarflare.magic.boombow.BoomBowListener; +import alisolarflare.magic.tricks.AliArrowListener; +import alisolarflare.magic.tricks.BoomBowListener; public class MagicModule extends Module{ diff --git a/src/alisolarflare/magic/aliarrow/AliArrowListener.java b/src/alisolarflare/magic/tricks/AliArrowListener.java similarity index 92% rename from src/alisolarflare/magic/aliarrow/AliArrowListener.java rename to src/alisolarflare/magic/tricks/AliArrowListener.java index a7617a8..36b8e12 100644 --- a/src/alisolarflare/magic/aliarrow/AliArrowListener.java +++ b/src/alisolarflare/magic/tricks/AliArrowListener.java @@ -1,4 +1,4 @@ -package alisolarflare.magic.aliarrow; +package alisolarflare.magic.tricks; import org.bukkit.entity.Arrow; import org.bukkit.entity.EntityType; diff --git a/src/alisolarflare/magic/aliarrow/AliArrowTask.java b/src/alisolarflare/magic/tricks/AliArrowTask.java similarity index 92% rename from src/alisolarflare/magic/aliarrow/AliArrowTask.java rename to src/alisolarflare/magic/tricks/AliArrowTask.java index f131ace..10252b8 100644 --- a/src/alisolarflare/magic/aliarrow/AliArrowTask.java +++ b/src/alisolarflare/magic/tricks/AliArrowTask.java @@ -1,4 +1,4 @@ -package alisolarflare.magic.aliarrow; +package alisolarflare.magic.tricks; import org.bukkit.Particle; import org.bukkit.entity.Arrow; diff --git a/src/alisolarflare/magic/boombow/BoomBowListener.java b/src/alisolarflare/magic/tricks/BoomBowListener.java similarity index 95% rename from src/alisolarflare/magic/boombow/BoomBowListener.java rename to src/alisolarflare/magic/tricks/BoomBowListener.java index 9b5ad69..a7f6a3b 100644 --- a/src/alisolarflare/magic/boombow/BoomBowListener.java +++ b/src/alisolarflare/magic/tricks/BoomBowListener.java @@ -1,4 +1,4 @@ -package alisolarflare.magic.boombow; +package alisolarflare.magic.tricks; import org.bukkit.GameMode; import org.bukkit.Location; diff --git a/src/alisolarflare/magic/boombow/BoomBowRule.java b/src/alisolarflare/magic/tricks/BoomBowRule.java similarity index 94% rename from src/alisolarflare/magic/boombow/BoomBowRule.java rename to src/alisolarflare/magic/tricks/BoomBowRule.java index aae9a76..b1131c6 100644 --- a/src/alisolarflare/magic/boombow/BoomBowRule.java +++ b/src/alisolarflare/magic/tricks/BoomBowRule.java @@ -1,4 +1,4 @@ -package alisolarflare.magic.boombow; +package alisolarflare.magic.tricks; import org.bukkit.command.CommandSender; import org.bukkit.entity.Player; diff --git a/src/alisolarflare/minigames/MinigameModule.java b/src/alisolarflare/minigames/MinigameModule.java new file mode 100644 index 0000000..72827b3 --- /dev/null +++ b/src/alisolarflare/minigames/MinigameModule.java @@ -0,0 +1,33 @@ +package alisolarflare.minigames; + +import java.util.List; + +import org.bukkit.plugin.java.JavaPlugin; + +import alisolarflare.Module; +import alisolarflare.minigames.commands.JoinMinigame; +import alisolarflare.minigames.commands.LeaveMinigame; +import alisolarflare.minigames.commands.ListFighters; +import alisolarflare.minigames.commands.SetColourSpawn; +import alisolarflare.minigames.data.SpawnSet; + +public class MinigameModule extends Module{ + public SpawnSet spawnSet; + private int GameState; + public List fighters; + + @Override + public void register(JavaPlugin plugin) { + this.spawnSet = new SpawnSet(); + registerCommand(plugin, new SetColourSpawn(spawnSet)); + registerCommand(plugin, new JoinMinigame(this)); + registerCommand(plugin, new LeaveMinigame(this)); + registerCommand(plugin, new ListFighters(this)); + + } + + public int getGameState() {return GameState;} + public void setGameState(int gameState) {GameState = gameState;} + + +} diff --git a/src/alisolarflare/minigames/commands/JoinMinigame.java b/src/alisolarflare/minigames/commands/JoinMinigame.java new file mode 100644 index 0000000..f0afa6f --- /dev/null +++ b/src/alisolarflare/minigames/commands/JoinMinigame.java @@ -0,0 +1,53 @@ +package alisolarflare.minigames.commands; + +import org.bukkit.command.CommandSender; +import org.bukkit.entity.Player; + +import alisolarflare.minigames.MinigameModule; +import buttondevteam.lib.chat.TBMCCommandBase; + +public class JoinMinigame extends TBMCCommandBase { + private MinigameModule minigame; + + public JoinMinigame(MinigameModule minigame) { + this.minigame = minigame; + } + + @Override + public boolean OnCommand(CommandSender sender, String arg2, String[] arg3) { + if (!(sender instanceof Player)){ + sender.sendMessage("You must be a player to use this command!"); + return false; + } + + String name = sender.getName(); + if (minigame.fighters.contains(name)) { + sender.sendMessage("You are already in the minigame!"); + return false; + } + + minigame.fighters.add(name); + + if (minigame.fighters.contains(name)) { + sender.sendMessage("You have joined the minigame!"); + } + return false; + } + + @Override + public String[] GetHelpText(String alias) { + // TODO Auto-generated method stub + return null; + } + + @Override + public boolean GetPlayerOnly() { + return true; + } + + @Override + public boolean GetModOnly() { + return false; + } + +} diff --git a/src/alisolarflare/minigames/commands/LeaveMinigame.java b/src/alisolarflare/minigames/commands/LeaveMinigame.java new file mode 100644 index 0000000..844ed07 --- /dev/null +++ b/src/alisolarflare/minigames/commands/LeaveMinigame.java @@ -0,0 +1,53 @@ +package alisolarflare.minigames.commands; + +import org.bukkit.command.CommandSender; +import org.bukkit.entity.Player; + +import alisolarflare.minigames.MinigameModule; +import buttondevteam.lib.chat.TBMCCommandBase; + +public class LeaveMinigame extends TBMCCommandBase { + + private MinigameModule lobby; + + public LeaveMinigame(MinigameModule lobby) { + this.lobby = lobby; + } + + @Override + public boolean OnCommand(CommandSender sender, String arg2, String[] arg3) { + if(!(sender instanceof Player)){ + sender.sendMessage("You must be a player to use this command!"); + } + + String name = sender.getName(); + if (!(lobby.fighters.contains(name))) { + sender.sendMessage("You are not fighting!"); + return false; + } + + while(lobby.fighters.contains(name)){ + lobby.fighters.remove(name); + } + sender.sendMessage("You have left the fighters category!"); + + return false; + } + + @Override + public String[] GetHelpText(String alias) { + // TODO Auto-generated method stub + return null; + } + + @Override + public boolean GetPlayerOnly() { + return true; + } + + @Override + public boolean GetModOnly() { + return false; + } + +} diff --git a/src/alisolarflare/minigames/lobby/commands/ListFighters.java b/src/alisolarflare/minigames/commands/ListFighters.java similarity index 76% rename from src/alisolarflare/minigames/lobby/commands/ListFighters.java rename to src/alisolarflare/minigames/commands/ListFighters.java index 8024727..209d9f8 100644 --- a/src/alisolarflare/minigames/lobby/commands/ListFighters.java +++ b/src/alisolarflare/minigames/commands/ListFighters.java @@ -1,16 +1,16 @@ -package alisolarflare.minigames.lobby.commands; +package alisolarflare.minigames.commands; import java.util.stream.Collectors; import org.bukkit.command.CommandSender; -import alisolarflare.minigames.lobby.LobbyModule; +import alisolarflare.minigames.MinigameModule; import buttondevteam.lib.chat.TBMCCommandBase; public class ListFighters extends TBMCCommandBase { - private LobbyModule lobby; + private MinigameModule lobby; - public ListFighters(LobbyModule lobby) { + public ListFighters(MinigameModule lobby) { this.lobby = lobby; } diff --git a/src/alisolarflare/minigames/freeforall/commands/SetFFAS.java b/src/alisolarflare/minigames/commands/SetColourSpawn.java similarity index 84% rename from src/alisolarflare/minigames/freeforall/commands/SetFFAS.java rename to src/alisolarflare/minigames/commands/SetColourSpawn.java index 56e7a17..ca9501f 100644 --- a/src/alisolarflare/minigames/freeforall/commands/SetFFAS.java +++ b/src/alisolarflare/minigames/commands/SetColourSpawn.java @@ -1,15 +1,15 @@ -package alisolarflare.minigames.freeforall.commands; +package alisolarflare.minigames.commands; import org.bukkit.command.CommandSender; import org.bukkit.entity.Player; -import alisolarflare.minigames.freeforall.data.SpawnSet; +import alisolarflare.minigames.data.SpawnSet; import buttondevteam.lib.chat.TBMCCommandBase; -public class SetFFAS extends TBMCCommandBase{ +public class SetColourSpawn extends TBMCCommandBase{ private SpawnSet spawnSet; - public SetFFAS(SpawnSet spawnSet){ + public SetColourSpawn(SpawnSet spawnSet){ this.spawnSet = spawnSet; } @Override @@ -66,11 +66,6 @@ public class SetFFAS extends TBMCCommandBase{ return false; } @Override - public String GetCommandPath() { - // TODO Auto-generated method stub - return "setFFAS"; - } - @Override public String[] GetHelpText(String arg0) { // TODO Auto-generated method stub return null; diff --git a/src/alisolarflare/minigames/freeforall/data/SpawnSet.java b/src/alisolarflare/minigames/data/SpawnSet.java similarity index 92% rename from src/alisolarflare/minigames/freeforall/data/SpawnSet.java rename to src/alisolarflare/minigames/data/SpawnSet.java index 79d29de..40fd0ae 100644 --- a/src/alisolarflare/minigames/freeforall/data/SpawnSet.java +++ b/src/alisolarflare/minigames/data/SpawnSet.java @@ -1,4 +1,4 @@ -package alisolarflare.minigames.freeforall.data; +package alisolarflare.minigames.data; import org.bukkit.Location; diff --git a/src/alisolarflare/minigames/entities/Fighter.java b/src/alisolarflare/minigames/entities/Fighter.java new file mode 100644 index 0000000..557c1ae --- /dev/null +++ b/src/alisolarflare/minigames/entities/Fighter.java @@ -0,0 +1,11 @@ +package alisolarflare.minigames.entities; + +import org.bukkit.entity.Player; + +public class Fighter { + public Player player; + public String colour; + public Fighter(Player player, String colour){ + this.colour = colour; + } +} diff --git a/src/alisolarflare/minigames/freeforall/FreeForAllModule.java b/src/alisolarflare/minigames/freeforall/FreeForAllModule.java deleted file mode 100644 index 5560929..0000000 --- a/src/alisolarflare/minigames/freeforall/FreeForAllModule.java +++ /dev/null @@ -1,24 +0,0 @@ -package alisolarflare.minigames.freeforall; - -import org.bukkit.plugin.java.JavaPlugin; - -import alisolarflare.Module; -import alisolarflare.minigames.freeforall.commands.SetFFAS; -import alisolarflare.minigames.freeforall.data.SpawnSet; - -public class FreeForAllModule extends Module{ - public SpawnSet spawnSet; - private int GameState; - - @Override - public void register(JavaPlugin plugin) { - this.spawnSet = new SpawnSet(); - registerCommand(plugin, new SetFFAS(spawnSet)); - - } - - public int getGameState() {return GameState;} - public void setGameState(int gameState) {GameState = gameState;} - - -} diff --git a/src/alisolarflare/minigames/freeforall/data/Data.java b/src/alisolarflare/minigames/freeforall/data/Data.java deleted file mode 100644 index 29ad380..0000000 --- a/src/alisolarflare/minigames/freeforall/data/Data.java +++ /dev/null @@ -1,8 +0,0 @@ -package alisolarflare.minigames.freeforall.data; - -public class Data { - public SpawnSet spawnset; - public Data(){ - spawnset = new SpawnSet(); - } -} diff --git a/src/alisolarflare/minigames/freeforall/entities/Fighter.java b/src/alisolarflare/minigames/freeforall/entities/Fighter.java deleted file mode 100644 index 98aea3a..0000000 --- a/src/alisolarflare/minigames/freeforall/entities/Fighter.java +++ /dev/null @@ -1,17 +0,0 @@ -package alisolarflare.minigames.freeforall.entities; - -import org.bukkit.entity.Player; - -public class Fighter { - public Player player; - public String colour; - public Fighter(Player player){ - this.player = player; - } - public Fighter(Player player, String colour){ - this.colour = colour; - } - public String ToString(){ - return player.toString() +": " + colour.toString(); - } -} diff --git a/src/alisolarflare/minigames/lobby/LobbyModule.java b/src/alisolarflare/minigames/lobby/LobbyModule.java deleted file mode 100644 index 63f74e6..0000000 --- a/src/alisolarflare/minigames/lobby/LobbyModule.java +++ /dev/null @@ -1,20 +0,0 @@ -package alisolarflare.minigames.lobby; - -import java.util.List; - -import org.bukkit.plugin.java.JavaPlugin; - -import alisolarflare.Module; -import alisolarflare.minigames.lobby.commands.ButtonFight; -import alisolarflare.minigames.lobby.commands.ButtonLeave; -import alisolarflare.minigames.lobby.commands.ListFighters; - -public class LobbyModule extends Module{ - public List fighters; - - public void register(JavaPlugin plugin){ - registerCommand(plugin, new ButtonFight(this)); - registerCommand(plugin, new ButtonLeave(this)); - registerCommand(plugin, new ListFighters(this)); - } -} diff --git a/src/alisolarflare/minigames/lobby/commands/ButtonFight.java b/src/alisolarflare/minigames/lobby/commands/ButtonFight.java deleted file mode 100644 index 25fdb44..0000000 --- a/src/alisolarflare/minigames/lobby/commands/ButtonFight.java +++ /dev/null @@ -1,51 +0,0 @@ -package alisolarflare.minigames.lobby.commands; - -import org.bukkit.command.CommandSender; -import org.bukkit.entity.Player; - -import alisolarflare.minigames.lobby.LobbyModule; -import buttondevteam.lib.chat.TBMCCommandBase; - -public class ButtonFight extends TBMCCommandBase { - private LobbyModule lobby; - - public ButtonFight(LobbyModule lobby) { - this.lobby = lobby; - } - - @Override - public boolean OnCommand(CommandSender sender, String arg2, String[] arg3) { - - Player player = (Player) sender; - player.sendMessage(player.toString()); - String name = player.getName(); - if (lobby.fighters.contains(name)) { - player.sendMessage("You are already in the button fight!"); - return false; - } - - lobby.fighters.add(name); - - if (lobby.fighters.contains(name)) { - player.sendMessage("You have joined the fighters category!"); - } - return false; - } - - @Override - public String[] GetHelpText(String alias) { - // TODO Auto-generated method stub - return null; - } - - @Override - public boolean GetPlayerOnly() { - return true; - } - - @Override - public boolean GetModOnly() { - return false; - } - -} diff --git a/src/alisolarflare/minigames/lobby/commands/ButtonLeave.java b/src/alisolarflare/minigames/lobby/commands/ButtonLeave.java deleted file mode 100644 index 2882075..0000000 --- a/src/alisolarflare/minigames/lobby/commands/ButtonLeave.java +++ /dev/null @@ -1,48 +0,0 @@ -package alisolarflare.minigames.lobby.commands; - -import org.bukkit.command.CommandSender; -import org.bukkit.entity.Player; - -import alisolarflare.minigames.lobby.LobbyModule; -import buttondevteam.lib.chat.TBMCCommandBase; - -public class ButtonLeave extends TBMCCommandBase { - - private LobbyModule lobby; - - public ButtonLeave(LobbyModule lobby) { - this.lobby = lobby; - } - - @Override - public boolean OnCommand(CommandSender sender, String arg2, String[] arg3) { - Player player = (Player) sender; - String name = player.getName(); - if (!(lobby.fighters.contains(name))) { - player.sendMessage("You are not fighting!"); - return false; - } - lobby.fighters.remove(name); - if (!(lobby.fighters.contains(name))) { - player.sendMessage("You have left the fighters category!"); - } - return false; - } - - @Override - public String[] GetHelpText(String alias) { - // TODO Auto-generated method stub - return null; - } - - @Override - public boolean GetPlayerOnly() { - return true; - } - - @Override - public boolean GetModOnly() { - return false; - } - -} diff --git a/src/alisolarflare/townylearn/MainPlugin.java b/src/alisolarflare/townylearn/MainPlugin.java deleted file mode 100644 index 1adf4dd..0000000 --- a/src/alisolarflare/townylearn/MainPlugin.java +++ /dev/null @@ -1,34 +0,0 @@ -package alisolarflare.townylearn; - -import org.bukkit.plugin.java.JavaPlugin; -import alisolarflare.townylearn.commands.Cbgm0; -import alisolarflare.townylearn.commands.Cbgm1; -import alisolarflare.townylearn.commands.SetDickmode; - - -public class MainPlugin extends JavaPlugin{ - public boolean dickmode; - public void onEnable(){ - registerCommands(); - registerEvents(); - } - public void registerCommands(){ - getCommand("cbgm1").setExecutor(new Cbgm1()); - getCommand("cbgm0").setExecutor(new Cbgm0()); - getCommand("setdickmode").setExecutor(new SetDickmode(this)); - } - public void registerEvents(){ - PlotChangeListener plotChangeListener = new PlotChangeListener(this); - - getServer().getPluginManager().registerEvents(plotChangeListener, this); - } - public void setDickmode(boolean YES){ - dickmode = YES; - this.getConfig().set("dickmode", YES); - } - public boolean getDickmode(){ - boolean dickmode = this.getConfig().getBoolean("dickmode"); - this.dickmode = dickmode; - return dickmode; - } -} diff --git a/src/alisolarflare/townylearn/commands/Cbgm0.java b/src/alisolarflare/townylearn/commands/Cbgm0.java deleted file mode 100644 index 12a0bc1..0000000 --- a/src/alisolarflare/townylearn/commands/Cbgm0.java +++ /dev/null @@ -1,23 +0,0 @@ -package alisolarflare.townylearn.commands; - -import org.bukkit.GameMode; -import org.bukkit.command.Command; -import org.bukkit.command.CommandExecutor; -import org.bukkit.command.CommandSender; -import org.bukkit.entity.Player; - -public class Cbgm0 implements CommandExecutor{ - - @Override - public boolean onCommand(CommandSender sender, Command arg1, String arg2, String[] arg3) { - if (!(sender instanceof Player)){ - sender.sendMessage("You must be a player to use this command!"); - return false; - } - - Player player = (Player) sender; - player.setGameMode(GameMode.SURVIVAL); - return false; - } - -} diff --git a/src/alisolarflare/townylearn/commands/Cbgm1.java b/src/alisolarflare/townylearn/commands/Cbgm1.java deleted file mode 100644 index 4a3f2ac..0000000 --- a/src/alisolarflare/townylearn/commands/Cbgm1.java +++ /dev/null @@ -1,53 +0,0 @@ -package alisolarflare.townylearn.commands; - -import org.bukkit.GameMode; -import org.bukkit.command.Command; -import org.bukkit.command.CommandExecutor; -import org.bukkit.command.CommandSender; -import org.bukkit.entity.Player; - -import com.palmergames.bukkit.towny.exceptions.NotRegisteredException; -import com.palmergames.bukkit.towny.object.*; - -public class Cbgm1 implements CommandExecutor { - - @Override - public boolean onCommand(CommandSender sender, Command arg1, String arg2, String[] arg3) { - - if (!(sender instanceof Player)) { - sender.sendMessage("You must be a player to use this command!"); - return false; - } - - Player player = (Player) sender; - - TownBlock tb = TownyUniverse.getTownBlock(player.getLocation()); - if (tb == null) { - player.sendMessage("§cYou aren't standing in a town or some other error occured."); - player.sendMessage("§cTownBlock is null."); - return false; - } - Town town; - try { - town = tb.getTown(); - } catch (NotRegisteredException e) { - player.sendMessage("§cYou aren't standing in a town or some other error occured."); - player.sendMessage("§cTownBlock's town is not registered."); - return false; - } - if (town == null) { - player.sendMessage("§cERROR: The town you're standing in is Null."); - return false; - } - - for(Resident res : town.getResidents()){ - if (res.getName().toString().equals(player.getName().toString())){ - player.setGameMode(GameMode.CREATIVE); - return true; - } - } - player.sendMessage("Sorry, you're not part of this town"); - return false; - } - -} diff --git a/src/alisolarflare/townylearn/commands/SetDickmode.java b/src/alisolarflare/townylearn/commands/SetDickmode.java deleted file mode 100644 index a83a019..0000000 --- a/src/alisolarflare/townylearn/commands/SetDickmode.java +++ /dev/null @@ -1,37 +0,0 @@ -package alisolarflare.townylearn.commands; - -import org.bukkit.command.Command; -import org.bukkit.command.CommandExecutor; -import org.bukkit.command.CommandSender; - -import alisolarflare.townylearn.MainPlugin; - -public class SetDickmode implements CommandExecutor{ - private MainPlugin plugin; - - public SetDickmode(MainPlugin plugin){ - this.plugin = plugin; - } - - @Override - public boolean onCommand(CommandSender sender, Command command, String label, String[] args) { - if (sender.getName().equals("Alisolarflare") || sender.getName().equals("iie")){ - if(args[0] == null){ - sender.sendMessage("You must use True, False, 1, or 0 as arguments!"); - return false; - } - if(args[0].equalsIgnoreCase("TRUE") || args[0].equalsIgnoreCase("1")){ - sender.sendMessage("Dickmode has been turned on!"); - plugin.setDickmode(true); - return true; - } - if(args[0].equalsIgnoreCase("FALSE") || args[0].equalsIgnoreCase("0")){ - sender.sendMessage("Dickmode has been turned off!"); - plugin.setDickmode(false); - return true; - } - return false; - } - return false; - } -} diff --git a/src/alisolarflare/events/uhc/UHCModule.java b/src/alisolarflare/uhc/UHCModule.java similarity index 66% rename from src/alisolarflare/events/uhc/UHCModule.java rename to src/alisolarflare/uhc/UHCModule.java index 51f6891..db50588 100644 --- a/src/alisolarflare/events/uhc/UHCModule.java +++ b/src/alisolarflare/uhc/UHCModule.java @@ -1,17 +1,19 @@ -package alisolarflare.events.uhc; +package alisolarflare.uhc; import org.bukkit.plugin.java.JavaPlugin; import alisolarflare.Module; -import alisolarflare.events.uhc.commands.AddToUHC; -import alisolarflare.events.uhc.commands.StartMatch; -import alisolarflare.events.uhc.memory.MatchState; -import alisolarflare.events.uhc.memory.UHCMatch; +import alisolarflare.uhc.commands.AddToUHC; +import alisolarflare.uhc.commands.StartMatch; +import alisolarflare.uhc.memory.MatchState; +import alisolarflare.uhc.memory.UHCMatch; public class UHCModule extends Module { public UHCMatch match; public void register(JavaPlugin plugin) { + + if (plugin.getConfig().contains("UHCMatchState")){ match = new UHCMatch(plugin.getConfig(), MatchState.valueOf(plugin.getConfig().getString("UHCMatchState"))); }else{ diff --git a/src/alisolarflare/events/uhc/commands/AddToUHC.java b/src/alisolarflare/uhc/commands/AddToUHC.java similarity index 89% rename from src/alisolarflare/events/uhc/commands/AddToUHC.java rename to src/alisolarflare/uhc/commands/AddToUHC.java index ba51a83..ab31de7 100644 --- a/src/alisolarflare/events/uhc/commands/AddToUHC.java +++ b/src/alisolarflare/uhc/commands/AddToUHC.java @@ -1,9 +1,9 @@ -package alisolarflare.events.uhc.commands; +package alisolarflare.uhc.commands; import org.bukkit.command.CommandSender; import org.bukkit.entity.Player; -import alisolarflare.events.uhc.memory.UHCMatch; +import alisolarflare.uhc.memory.UHCMatch; import buttondevteam.lib.chat.TBMCCommandBase; /** diff --git a/src/alisolarflare/events/uhc/commands/StartMatch.java b/src/alisolarflare/uhc/commands/StartMatch.java similarity index 89% rename from src/alisolarflare/events/uhc/commands/StartMatch.java rename to src/alisolarflare/uhc/commands/StartMatch.java index 29f8a54..901fccf 100644 --- a/src/alisolarflare/events/uhc/commands/StartMatch.java +++ b/src/alisolarflare/uhc/commands/StartMatch.java @@ -1,8 +1,8 @@ -package alisolarflare.events.uhc.commands; +package alisolarflare.uhc.commands; import org.bukkit.command.CommandSender; -import alisolarflare.events.uhc.memory.UHCMatch; +import alisolarflare.uhc.memory.UHCMatch; import buttondevteam.lib.chat.TBMCCommandBase; public class StartMatch extends TBMCCommandBase { diff --git a/src/alisolarflare/events/uhc/listeners/MatchCyclingListener.java b/src/alisolarflare/uhc/listeners/MatchCyclingListener.java similarity index 89% rename from src/alisolarflare/events/uhc/listeners/MatchCyclingListener.java rename to src/alisolarflare/uhc/listeners/MatchCyclingListener.java index 892eb07..62265c2 100644 --- a/src/alisolarflare/events/uhc/listeners/MatchCyclingListener.java +++ b/src/alisolarflare/uhc/listeners/MatchCyclingListener.java @@ -1,4 +1,4 @@ -package alisolarflare.events.uhc.listeners; +package alisolarflare.uhc.listeners; import org.bukkit.event.Listener; import org.bukkit.plugin.java.JavaPlugin; diff --git a/src/alisolarflare/events/uhc/listeners/MatchMainLoop.java b/src/alisolarflare/uhc/listeners/MatchMainLoop.java similarity index 71% rename from src/alisolarflare/events/uhc/listeners/MatchMainLoop.java rename to src/alisolarflare/uhc/listeners/MatchMainLoop.java index 5fc3887..2e42cae 100644 --- a/src/alisolarflare/events/uhc/listeners/MatchMainLoop.java +++ b/src/alisolarflare/uhc/listeners/MatchMainLoop.java @@ -1,4 +1,4 @@ -package alisolarflare.events.uhc.listeners; +package alisolarflare.uhc.listeners; import org.bukkit.scheduler.BukkitRunnable; diff --git a/src/alisolarflare/events/uhc/memory/MatchState.java b/src/alisolarflare/uhc/memory/MatchState.java similarity index 64% rename from src/alisolarflare/events/uhc/memory/MatchState.java rename to src/alisolarflare/uhc/memory/MatchState.java index 0838048..83aadaf 100644 --- a/src/alisolarflare/events/uhc/memory/MatchState.java +++ b/src/alisolarflare/uhc/memory/MatchState.java @@ -1,4 +1,4 @@ -package alisolarflare.events.uhc.memory; +package alisolarflare.uhc.memory; public enum MatchState { IDLE, WAITING, SETUP, INTRO, PEACE, TENSION, POWER, END diff --git a/src/alisolarflare/events/uhc/memory/UHCMatch.java b/src/alisolarflare/uhc/memory/UHCMatch.java similarity index 90% rename from src/alisolarflare/events/uhc/memory/UHCMatch.java rename to src/alisolarflare/uhc/memory/UHCMatch.java index 0461d3f..8338edd 100644 --- a/src/alisolarflare/events/uhc/memory/UHCMatch.java +++ b/src/alisolarflare/uhc/memory/UHCMatch.java @@ -1,4 +1,4 @@ -package alisolarflare.events.uhc.memory; +package alisolarflare.uhc.memory; import java.util.ArrayList; import java.util.List;