From c120f2e46f7061491740c5c9140e53784b2977f7 Mon Sep 17 00:00:00 2001 From: alisolarflare Date: Mon, 28 Nov 2016 13:59:25 -0500 Subject: [PATCH] A whole bunch of assorted changes --- .settings/org.eclipse.core.resources.prefs | 7 +- plugin.yml | 6 +- .../commands/subcommands/ModSubCommand.java | 15 ++ .../subcommands/PlayerSubCommand.java | 16 ++ .../commands/subcommands/SubCommand.java | 10 + .../components/alilinks/AliLinkComponent.java | 10 +- .../{SetAliLink.java => AliLink.java} | 151 ++++++------ .../alilinks/commands/PressAliLink.java | 43 ---- .../components/alilinks/entities/Link.java | 1 + .../creativeboundaries/commands/Cbgm0.java | 4 +- .../listeners/ItemRestrictionListener.java | 6 - .../components/easyuhc/EasyUHCComponent.java | 25 +- .../easyuhc/commands/ActivatePowers.java | 13 -- .../easyuhc/commands/SetUHCLobby.java | 20 -- .../easyuhc/commands/SetWorldBorders.java | 14 -- .../easyuhc/commands/ShrinkWorldBorders.java | 14 -- .../easyuhc/commands/SpreadPlayers.java | 15 -- .../easyuhc/commands/StartTimer.java | 14 -- .../components/easyuhc/commands/StartUHC.java | 14 -- .../easyuhc/commands/TeleportToUHC.java | 14 -- .../PlayerProximityLoop.java | 48 ++-- .../magic/tricks/BoomBowListener.java | 221 +++++++++--------- .../magic/tricks/CannonBowListener.java | 41 ++-- .../minigames/MinigameComponent.java | 15 +- .../minigames/commands/JoinMinigame.java | 21 +- .../minigames/commands/LeaveMinigame.java | 16 +- .../minigames/commands/ListFighters.java | 8 +- .../minigames/commands/SetColourSpawn.java | 20 +- .../components/minigames/data/SpawnSet.java | 26 +-- .../minigames/entities/Fighter.java | 11 - 30 files changed, 359 insertions(+), 480 deletions(-) create mode 100644 src/alisolarflare/architecture/commands/subcommands/ModSubCommand.java create mode 100644 src/alisolarflare/architecture/commands/subcommands/PlayerSubCommand.java create mode 100644 src/alisolarflare/architecture/commands/subcommands/SubCommand.java rename src/alisolarflare/components/alilinks/commands/{SetAliLink.java => AliLink.java} (51%) delete mode 100644 src/alisolarflare/components/alilinks/commands/PressAliLink.java delete mode 100644 src/alisolarflare/components/creativeboundaries/listeners/ItemRestrictionListener.java delete mode 100644 src/alisolarflare/components/easyuhc/commands/ActivatePowers.java delete mode 100644 src/alisolarflare/components/easyuhc/commands/SetUHCLobby.java delete mode 100644 src/alisolarflare/components/easyuhc/commands/SetWorldBorders.java delete mode 100644 src/alisolarflare/components/easyuhc/commands/ShrinkWorldBorders.java delete mode 100644 src/alisolarflare/components/easyuhc/commands/SpreadPlayers.java delete mode 100644 src/alisolarflare/components/easyuhc/commands/StartTimer.java delete mode 100644 src/alisolarflare/components/easyuhc/commands/StartUHC.java delete mode 100644 src/alisolarflare/components/easyuhc/commands/TeleportToUHC.java delete mode 100644 src/alisolarflare/components/minigames/entities/Fighter.java diff --git a/.settings/org.eclipse.core.resources.prefs b/.settings/org.eclipse.core.resources.prefs index 7a53139..e18f795 100644 --- a/.settings/org.eclipse.core.resources.prefs +++ b/.settings/org.eclipse.core.resources.prefs @@ -1,3 +1,4 @@ -eclipse.preferences.version=1 -encoding/=UTF-8 -encoding/src=UTF-8 +eclipse.preferences.version=1 +encoding/=UTF-8 +encoding/metrics=UTF-8 +encoding/src=UTF-8 diff --git a/plugin.yml b/plugin.yml index 83f16c2..3bc12b6 100644 --- a/plugin.yml +++ b/plugin.yml @@ -11,10 +11,8 @@ commands: description: Official g-power command that activates the ghostie powerups powerdown: description: Offical g-power command that deactivates the ghostie powerups - pressalilink: - description: Presses an Ali Link pressalilink frequency - setalilink: - description: Creates an Ali Link setalilink frequency + alilink: + description: Arguments: cbgm0: description: Creative Boundaries Gamemode 0 - allows players to return to survival cbgm1: diff --git a/src/alisolarflare/architecture/commands/subcommands/ModSubCommand.java b/src/alisolarflare/architecture/commands/subcommands/ModSubCommand.java new file mode 100644 index 0000000..ec3ee25 --- /dev/null +++ b/src/alisolarflare/architecture/commands/subcommands/ModSubCommand.java @@ -0,0 +1,15 @@ +package alisolarflare.architecture.commands.subcommands; + +public abstract class ModSubCommand extends SubCommand{ + @Override + public boolean getPlayerOnly() { + // TODO Auto-generated method stub + return true; + } + + @Override + public boolean getModOnly() { + // TODO Auto-generated method stub + return true; + } +} diff --git a/src/alisolarflare/architecture/commands/subcommands/PlayerSubCommand.java b/src/alisolarflare/architecture/commands/subcommands/PlayerSubCommand.java new file mode 100644 index 0000000..c71665e --- /dev/null +++ b/src/alisolarflare/architecture/commands/subcommands/PlayerSubCommand.java @@ -0,0 +1,16 @@ +package alisolarflare.architecture.commands.subcommands; + +public abstract class PlayerSubCommand extends SubCommand{ + @Override + public boolean getModOnly() { + // TODO Auto-generated method stub + return false; + } + + @Override + public boolean getPlayerOnly() { + // TODO Auto-generated method stub + return true; + } + +} diff --git a/src/alisolarflare/architecture/commands/subcommands/SubCommand.java b/src/alisolarflare/architecture/commands/subcommands/SubCommand.java new file mode 100644 index 0000000..119fb70 --- /dev/null +++ b/src/alisolarflare/architecture/commands/subcommands/SubCommand.java @@ -0,0 +1,10 @@ +package alisolarflare.architecture.commands.subcommands; + +import org.bukkit.entity.Player; + +public abstract class SubCommand { + public abstract boolean run(Player player, String label, String[] args); + public abstract boolean getPlayerOnly(); + public abstract boolean getModOnly(); + public abstract String[] GetHelpText(String alias); +} diff --git a/src/alisolarflare/components/alilinks/AliLinkComponent.java b/src/alisolarflare/components/alilinks/AliLinkComponent.java index 8812dbf..78095d6 100644 --- a/src/alisolarflare/components/alilinks/AliLinkComponent.java +++ b/src/alisolarflare/components/alilinks/AliLinkComponent.java @@ -8,23 +8,21 @@ import org.bukkit.Server; import org.bukkit.plugin.java.JavaPlugin; import alisolarflare.architecture.Component; -import alisolarflare.components.alilinks.commands.PressAliLink; -import alisolarflare.components.alilinks.commands.SetAliLink; +import alisolarflare.components.alilinks.commands.AliLink; import alisolarflare.components.alilinks.entities.Link; public class AliLinkComponent extends Component { private List linkList; - private List> linkData; + private List> linkMap; @Override public void register(JavaPlugin plugin) { this.linkList = MapToLinkList(plugin.getConfig().getMapList("aliLinkList"), plugin.getServer()); for (Link link: linkList){ - linkData.add(link.toMap()); + linkMap.add(link.toMap()); } - registerCommand(plugin, new PressAliLink(plugin, linkList)); - registerCommand(plugin, new SetAliLink(plugin.getConfig(), linkList, linkData)); + registerCommand(plugin, new AliLink(plugin, linkList)); } @SuppressWarnings("unchecked") diff --git a/src/alisolarflare/components/alilinks/commands/SetAliLink.java b/src/alisolarflare/components/alilinks/commands/AliLink.java similarity index 51% rename from src/alisolarflare/components/alilinks/commands/SetAliLink.java rename to src/alisolarflare/components/alilinks/commands/AliLink.java index a7eda06..362a8ab 100644 --- a/src/alisolarflare/components/alilinks/commands/SetAliLink.java +++ b/src/alisolarflare/components/alilinks/commands/AliLink.java @@ -1,65 +1,86 @@ -package alisolarflare.components.alilinks.commands; - -import java.util.List; -import java.util.Map; - -import org.apache.commons.lang3.StringUtils; -import org.bukkit.World; -import org.bukkit.configuration.file.FileConfiguration; -import org.bukkit.entity.Player; - -import alisolarflare.architecture.commands.PlayerCommand; -import alisolarflare.components.alilinks.entities.Link; - -public class SetAliLink extends PlayerCommand { - public List linkList; - public List> linkData; - private FileConfiguration config; - - public SetAliLink(FileConfiguration config, List linkList, List> linkData) { - this.linkList = linkList; - this.linkData = linkData; - this.config = config; - } - - @Override - public boolean OnCommand(Player player, String label, String[] args) { - if (args == null || args.length < 1) { - player.sendMessage("You must specify a link frequency"); - player.sendMessage("/pressalilink [name]"); - return false; - } - - String frequency = args[0]; - World world = player.getWorld(); - int x = player.getLocation().getBlockX(); - int y = player.getLocation().getBlockY(); - int z = player.getLocation().getBlockZ(); - - if (args.length > 4) { - boolean arg1isNumber = StringUtils.isNumericSpace(args[1]); - boolean arg2isNumber = StringUtils.isNumericSpace(args[2]); - boolean arg3isNumber = StringUtils.isNumericSpace(args[3]); - if (arg1isNumber && arg2isNumber && arg3isNumber) { - x = Integer.parseInt(args[1]); - y = Integer.parseInt(args[2]); - z = Integer.parseInt(args[3]); - } - } - - Link link = new Link(frequency, world, x, y, z); - linkList.add(link); - linkData.add(link.toMap()); - saveLinkList(); - return true; - } - private void saveLinkList(){ - config.set("aliLinkList", linkData); - } - @Override - public String[] GetHelpText(String alias){ - return new String[]{ - "Usage: /setalilink [x] [y] [z]" - }; - } -} +package alisolarflare.components.alilinks.commands; + +import java.util.Arrays; +import java.util.List; + +import org.apache.commons.lang3.StringUtils; +import org.bukkit.World; +import org.bukkit.entity.Player; +import org.bukkit.plugin.java.JavaPlugin; + +import alisolarflare.architecture.commands.PlayerCommand; +import alisolarflare.components.alilinks.entities.Link; + +public class AliLink extends PlayerCommand{ + private JavaPlugin plugin; + private List linkList; + + public AliLink(JavaPlugin plugin, List linkList) { + this.plugin = plugin; + this.linkList = linkList; + } + @Override + public boolean OnCommand(Player player, String alias, String[] args) { + if(args.length < 1) + return false; + + switch (args[0].toLowerCase()){ + case "press": + return press(player, alias, args); + case "set": + return set(player, alias, args); + default: + return false; + } + + } + /**"Usage: /pressalilink "*/ + private boolean press(Player player, String alias, String[] inputFrequencies) { + if (inputFrequencies.length == 0) { + player.sendMessage("You must specify a link frequency"); + return false; + } + + List inputFrequencyList= Arrays.asList(inputFrequencies); + for (Link link : linkList) { + if(inputFrequencyList.contains(link.frequency)){ + link.press(plugin); + } + } + + player.sendMessage("Link pressed!"); + + return true; + } + + /**Usage: /setalilink [x] [y] [z]*/ + public boolean set(Player player, String label, String[] args) { + if (args == null || args.length < 1) { + player.sendMessage("You must specify a link frequency"); + player.sendMessage("/pressalilink [name]"); + return false; + } + + String frequency = args[0]; + World world = player.getWorld(); + int x = player.getLocation().getBlockX(); + int y = player.getLocation().getBlockY(); + int z = player.getLocation().getBlockZ(); + + if (args.length > 4) { + boolean arg1isNumber = StringUtils.isNumericSpace(args[1]); + boolean arg2isNumber = StringUtils.isNumericSpace(args[2]); + boolean arg3isNumber = StringUtils.isNumericSpace(args[3]); + if (arg1isNumber && arg2isNumber && arg3isNumber) { + x = Integer.parseInt(args[1]); + y = Integer.parseInt(args[2]); + z = Integer.parseInt(args[3]); + } + } + + Link link = new Link(frequency, world, x, y, z); + linkList.add(link); + return true; + } + +} diff --git a/src/alisolarflare/components/alilinks/commands/PressAliLink.java b/src/alisolarflare/components/alilinks/commands/PressAliLink.java deleted file mode 100644 index 8f9486a..0000000 --- a/src/alisolarflare/components/alilinks/commands/PressAliLink.java +++ /dev/null @@ -1,43 +0,0 @@ -package alisolarflare.components.alilinks.commands; - -import java.util.List; - -import org.bukkit.entity.Player; -import org.bukkit.plugin.java.JavaPlugin; - -import alisolarflare.architecture.commands.PlayerCommand; -import alisolarflare.components.alilinks.entities.Link; - -public class PressAliLink extends PlayerCommand { - private JavaPlugin plugin; - private List linkList; - - public PressAliLink(JavaPlugin plugin, List linkList) { - this.plugin = plugin; - this.linkList = linkList; - } - - @Override - public boolean OnCommand(Player player, String label, String[] inputFrequencies) { - if (inputFrequencies.length < 1) { - player.sendMessage("You must specify a link frequency"); - return false; - } - - for (Link link : linkList) { - for (String frequency : inputFrequencies) { - if (frequency.equals(link.frequency)) { - link.press(plugin); - } - } - } - player.sendMessage("Link pressed!"); - return true; - } - @Override - public String[] GetHelpText(String alias){ - return new String[]{ - "Usage: /pressalilink " - }; - } -} diff --git a/src/alisolarflare/components/alilinks/entities/Link.java b/src/alisolarflare/components/alilinks/entities/Link.java index 546f116..a2ea8f1 100644 --- a/src/alisolarflare/components/alilinks/entities/Link.java +++ b/src/alisolarflare/components/alilinks/entities/Link.java @@ -12,6 +12,7 @@ import org.bukkit.plugin.java.JavaPlugin; import alisolarflare.components.alilinks.tasks.UnpressTask; public class Link{ + public String frequency; public World world; public int x; diff --git a/src/alisolarflare/components/creativeboundaries/commands/Cbgm0.java b/src/alisolarflare/components/creativeboundaries/commands/Cbgm0.java index eba221e..7ef2fb8 100644 --- a/src/alisolarflare/components/creativeboundaries/commands/Cbgm0.java +++ b/src/alisolarflare/components/creativeboundaries/commands/Cbgm0.java @@ -23,8 +23,6 @@ public class Cbgm0 extends PlayerCommand{ return true; } public String[] GetHelpText(String alias){ - return new String[]{ - "Creative Boundaries Usage: /cbgm0" - }; + return new String[]{"Creative Boundaries Usage: /cbgm0"}; } } diff --git a/src/alisolarflare/components/creativeboundaries/listeners/ItemRestrictionListener.java b/src/alisolarflare/components/creativeboundaries/listeners/ItemRestrictionListener.java deleted file mode 100644 index ffb9a3d..0000000 --- a/src/alisolarflare/components/creativeboundaries/listeners/ItemRestrictionListener.java +++ /dev/null @@ -1,6 +0,0 @@ -package alisolarflare.components.creativeboundaries.listeners; - -import org.bukkit.event.Listener; - -public class ItemRestrictionListener implements Listener { -} diff --git a/src/alisolarflare/components/easyuhc/EasyUHCComponent.java b/src/alisolarflare/components/easyuhc/EasyUHCComponent.java index 15d0e3d..1eeae35 100644 --- a/src/alisolarflare/components/easyuhc/EasyUHCComponent.java +++ b/src/alisolarflare/components/easyuhc/EasyUHCComponent.java @@ -4,13 +4,6 @@ import org.bukkit.Location; import org.bukkit.plugin.java.JavaPlugin; import alisolarflare.architecture.Component; -import alisolarflare.components.easyuhc.commands.ActivatePowers; -import alisolarflare.components.easyuhc.commands.SetUHCLobby; -import alisolarflare.components.easyuhc.commands.SetWorldBorders; -import alisolarflare.components.easyuhc.commands.SpreadPlayers; -import alisolarflare.components.easyuhc.commands.StartTimer; -import alisolarflare.components.easyuhc.commands.StartUHC; -import alisolarflare.components.easyuhc.commands.TeleportToUHC; public class EasyUHCComponent extends Component{ public Location lobbyLocation; @@ -19,14 +12,14 @@ public class EasyUHCComponent extends Component{ - registerCommand(plugin, new ActivatePowers()); - registerCommand(plugin, new SetUHCLobby(this)); - registerCommand(plugin, new SetWorldBorders()); - registerCommand(plugin, new SetWorldBorders()); - registerCommand(plugin, new SpreadPlayers()); - registerCommand(plugin, new StartTimer()); - registerCommand(plugin, new StartUHC()); - registerCommand(plugin, new TeleportToUHC()); - +// registerCommand(plugin, new ActivatePowers()); +// registerCommand(plugin, new SetUHCLobby(this)); +// registerCommand(plugin, new SetWorldBorders()); +// registerCommand(plugin, new SetWorldBorders()); +// registerCommand(plugin, new SpreadPlayers()); +// registerCommand(plugin, new StartTimer()); +// registerCommand(plugin, new StartUHC()); +// registerCommand(plugin, new TeleportToUHC()); + } } diff --git a/src/alisolarflare/components/easyuhc/commands/ActivatePowers.java b/src/alisolarflare/components/easyuhc/commands/ActivatePowers.java deleted file mode 100644 index 7af36e2..0000000 --- a/src/alisolarflare/components/easyuhc/commands/ActivatePowers.java +++ /dev/null @@ -1,13 +0,0 @@ -package alisolarflare.components.easyuhc.commands; - -import org.bukkit.entity.Player; - -import alisolarflare.architecture.commands.ModCommand; - -public class ActivatePowers extends ModCommand{ - - @Override - public boolean OnCommand(Player player, String alias, String[] args) { - return false; - } -} diff --git a/src/alisolarflare/components/easyuhc/commands/SetUHCLobby.java b/src/alisolarflare/components/easyuhc/commands/SetUHCLobby.java deleted file mode 100644 index 0a56438..0000000 --- a/src/alisolarflare/components/easyuhc/commands/SetUHCLobby.java +++ /dev/null @@ -1,20 +0,0 @@ -package alisolarflare.components.easyuhc.commands; - -import org.bukkit.entity.Player; - -import alisolarflare.architecture.commands.ModCommand; -import alisolarflare.components.easyuhc.EasyUHCComponent; - -public class SetUHCLobby extends ModCommand{ - EasyUHCComponent module; - public SetUHCLobby(EasyUHCComponent easyUHCModule) { - this.module = easyUHCModule; - } - - @Override - public boolean OnCommand(Player player, String alias, String[] args) { - module.lobbyLocation = player.getLocation(); - return false; - } - -} diff --git a/src/alisolarflare/components/easyuhc/commands/SetWorldBorders.java b/src/alisolarflare/components/easyuhc/commands/SetWorldBorders.java deleted file mode 100644 index bfc52d9..0000000 --- a/src/alisolarflare/components/easyuhc/commands/SetWorldBorders.java +++ /dev/null @@ -1,14 +0,0 @@ -package alisolarflare.components.easyuhc.commands; - -import org.bukkit.entity.Player; - -import alisolarflare.architecture.commands.ModCommand; - -public class SetWorldBorders extends ModCommand { - - @Override - public boolean OnCommand(Player player, String alias, String[] args) { - - return false; - } -} diff --git a/src/alisolarflare/components/easyuhc/commands/ShrinkWorldBorders.java b/src/alisolarflare/components/easyuhc/commands/ShrinkWorldBorders.java deleted file mode 100644 index af993f2..0000000 --- a/src/alisolarflare/components/easyuhc/commands/ShrinkWorldBorders.java +++ /dev/null @@ -1,14 +0,0 @@ -package alisolarflare.components.easyuhc.commands; - -import org.bukkit.entity.Player; - -import alisolarflare.architecture.commands.ModCommand; - -public class ShrinkWorldBorders extends ModCommand { - - @Override - public boolean OnCommand(Player player, String alias, String[] args) { - // TODO Auto-generated method stub - return false; - } -} diff --git a/src/alisolarflare/components/easyuhc/commands/SpreadPlayers.java b/src/alisolarflare/components/easyuhc/commands/SpreadPlayers.java deleted file mode 100644 index 6e402c2..0000000 --- a/src/alisolarflare/components/easyuhc/commands/SpreadPlayers.java +++ /dev/null @@ -1,15 +0,0 @@ -package alisolarflare.components.easyuhc.commands; - -import org.bukkit.entity.Player; - -import alisolarflare.architecture.commands.ModCommand; - -public class SpreadPlayers extends ModCommand{ - - @Override - public boolean OnCommand(Player player, String alias, String[] args) { - // TODO Auto-generated method stub - return false; - } - -} diff --git a/src/alisolarflare/components/easyuhc/commands/StartTimer.java b/src/alisolarflare/components/easyuhc/commands/StartTimer.java deleted file mode 100644 index 2859935..0000000 --- a/src/alisolarflare/components/easyuhc/commands/StartTimer.java +++ /dev/null @@ -1,14 +0,0 @@ -package alisolarflare.components.easyuhc.commands; - -import org.bukkit.entity.Player; - -import alisolarflare.architecture.commands.ModCommand; - -public class StartTimer extends ModCommand{ - - @Override - public boolean OnCommand(Player player, String alias, String[] args) { - // TODO Auto-generated method stub - return false; - } -} diff --git a/src/alisolarflare/components/easyuhc/commands/StartUHC.java b/src/alisolarflare/components/easyuhc/commands/StartUHC.java deleted file mode 100644 index 4f5dff4..0000000 --- a/src/alisolarflare/components/easyuhc/commands/StartUHC.java +++ /dev/null @@ -1,14 +0,0 @@ -package alisolarflare.components.easyuhc.commands; - -import org.bukkit.entity.Player; - -import alisolarflare.architecture.commands.ModCommand; - -public class StartUHC extends ModCommand{ - - @Override - public boolean OnCommand(Player player, String alias, String[] args) { - // TODO Auto-generated method stub - return false; - } -} diff --git a/src/alisolarflare/components/easyuhc/commands/TeleportToUHC.java b/src/alisolarflare/components/easyuhc/commands/TeleportToUHC.java deleted file mode 100644 index 3b64c82..0000000 --- a/src/alisolarflare/components/easyuhc/commands/TeleportToUHC.java +++ /dev/null @@ -1,14 +0,0 @@ -package alisolarflare.components.easyuhc.commands; - -import org.bukkit.entity.Player; - -import alisolarflare.architecture.commands.PlayerCommand; - -public class TeleportToUHC extends PlayerCommand{ - - @Override - public boolean OnCommand(Player player, String alias, String[] args) { - // TODO Auto-generated method stub - return false; - } -} diff --git a/src/alisolarflare/components/flairdoor/proximitydetector/PlayerProximityLoop.java b/src/alisolarflare/components/flairdoor/proximitydetector/PlayerProximityLoop.java index b8a3a8a..a1727a6 100644 --- a/src/alisolarflare/components/flairdoor/proximitydetector/PlayerProximityLoop.java +++ b/src/alisolarflare/components/flairdoor/proximitydetector/PlayerProximityLoop.java @@ -14,39 +14,57 @@ public class PlayerProximityLoop extends BukkitRunnable implements Listener{ private Location startLocation; private Location endLocation; + private int sX; + private int sY; + private int sZ; + private int eX; + private int eY; + private int eZ; + public PlayerProximityLoop(JavaPlugin plugin, FlairDoorComponent component) { this.plugin = plugin; this.component = component; - this.startLocation = component.startLocation; - this.endLocation = component.endLocation; + setStartLocation(component.startLocation); + setEndLocation(component.endLocation); this.runTaskTimer(plugin, 0, 20); } + public void setStartLocation(Location location){ + this.sX = startLocation.getBlockX(); + this.sY = startLocation.getBlockY(); + this.sZ = startLocation.getBlockZ(); + this.startLocation = location; + this.endLocation.setWorld(location.getWorld()); + } + public void setEndLocation(Location location){ + this.eX = startLocation.getBlockX(); + this.eY = startLocation.getBlockY(); + this.eZ = startLocation.getBlockZ(); + this.endLocation = location; + this.startLocation.setWorld(location.getWorld()); + } @Override public void run() { if (startLocation == null || endLocation == null){ return; } - int sX = startLocation.getBlockX(); - int sY = startLocation.getBlockY(); - int sZ = startLocation.getBlockZ(); - int eX = endLocation.getBlockX(); - int eY = endLocation.getBlockY(); - int eZ = endLocation.getBlockZ(); int playerX; int playerY; int playerZ; + Location playerLocation; for (Player player : plugin.getServer().getOnlinePlayers()){ - playerX = player.getLocation().getBlockX(); - playerY = player.getLocation().getBlockY(); - playerZ = player.getLocation().getBlockZ(); - if(player.getLocation().getWorld() != startLocation.getWorld()) + playerLocation = player.getLocation(); + if(playerLocation.getWorld() != startLocation.getWorld()) continue; - if((playerX < sX && playerX < eX) ||(playerX > sX && playerX > eX)) + + playerX = playerLocation.getBlockX(); + if((playerX < sX && playerX < eX) || (playerX > sX && playerX > eX)) continue; - if((playerY < sY && playerY < eY) ||(playerY > sY && playerY > eY)) + playerY = playerLocation.getBlockY(); + if((playerY < sY && playerY < eY) || (playerY > sY && playerY > eY)) continue; - if((playerZ < sZ && playerZ < eZ) ||(playerZ > sZ && playerZ > eZ)) + playerZ = playerLocation.getBlockZ(); + if((playerZ < sZ && playerZ < eZ) || (playerZ > sZ && playerZ > eZ)) continue; component.playersToBeFlaired.add(player); diff --git a/src/alisolarflare/components/magic/tricks/BoomBowListener.java b/src/alisolarflare/components/magic/tricks/BoomBowListener.java index ef79278..bdb5b02 100644 --- a/src/alisolarflare/components/magic/tricks/BoomBowListener.java +++ b/src/alisolarflare/components/magic/tricks/BoomBowListener.java @@ -1,110 +1,111 @@ -package alisolarflare.components.magic.tricks; - -import org.bukkit.GameMode; -import org.bukkit.Location; -import org.bukkit.Material; -import org.bukkit.Particle; -import org.bukkit.Sound; -import org.bukkit.enchantments.Enchantment; -import org.bukkit.entity.Player; -import org.bukkit.event.EventHandler; -import org.bukkit.event.Listener; -import org.bukkit.event.block.Action; -import org.bukkit.event.player.PlayerInteractEvent; -import org.bukkit.inventory.ItemStack; -import org.bukkit.plugin.java.JavaPlugin; -import org.bukkit.potion.PotionEffect; -import org.bukkit.potion.PotionEffectType; - -public class BoomBowListener implements Listener { - JavaPlugin plugin; - public BoomBowListener(JavaPlugin plugin){ - this.plugin = plugin; - } - @EventHandler - public void ClickEvent(PlayerInteractEvent event){ - FlyBowBoost(event); - - } - public void FlyBowBoost(PlayerInteractEvent event){ - - //ACTION SANITATION - if(!(event.getAction() == Action.LEFT_CLICK_AIR || event.getAction() == Action.LEFT_CLICK_BLOCK)) return; - if(!(event.getPlayer().isGliding())) return; - if(!(event.getMaterial() == Material.BOW)) return; - - //BOW SANITATION - ItemStack bow = event.getItem(); - if(!(bow.containsEnchantment(Enchantment.ARROW_KNOCKBACK))) return; - if(!(bow.getEnchantmentLevel(Enchantment.ARROW_KNOCKBACK) == 3)) return; - if(!(bow.getItemMeta().getDisplayName().contains("BOOM BOW"))) return; - - //PLAYER SANITATION - Player player = event.getPlayer(); - if(player.getGameMode().equals(GameMode.CREATIVE))return; - - if(bow.containsEnchantment(Enchantment.ARROW_INFINITE)){ - //HAS INIFINITY - Activate(event); - - }else if((player.getInventory().contains(Material.TNT))){ - //HAS TNT - Activate(event); - - //Reduce tnt by 1 - int tntSlot = player.getInventory().first(Material.TNT); - ItemStack tntStack = player.getInventory().getItem(tntSlot); - if(tntStack.getAmount() > 3){ - tntStack.setAmount(tntStack.getAmount()-3); - }else{ - player.getInventory().remove(tntStack); - } - if (bow.getDurability() < 0){ - player.getInventory().clear(player.getInventory().getHeldItemSlot()); - } - - }else{ - return; - } - } - - - - public void Activate(PlayerInteractEvent event){ - //INIT - Player variables - Player player = event.getPlayer(); - Location playerLocation = player.getLocation(); - ItemStack boomBow = player.getInventory().getItemInMainHand(); - - //TODO: NERF - boomDecay - //TODO: NERF - endCrystal - //TODO: NERF - healthReduction - //TODO: NERF - localized - - if(BoomBowRule.boomDecay) - new BoomDecayTask(player).runTaskTimer(plugin, 1, 1); - if(BoomBowRule.endCrystal){ - //BoomBowCyrstalSpawn - } - if(BoomBowRule.healthReduction){ - player.addPotionEffect(new PotionEffect(PotionEffectType.HEALTH_BOOST, 400, -1)); - } - if(BoomBowRule.localized); - - - //SET - Player Velocity - player.setVelocity(playerLocation.getDirection().normalize().multiply(3.0)); - - //CREATE - Explosion + damage - player.getWorld().playSound(playerLocation, Sound.ENTITY_GENERIC_EXPLODE, 10, -20); - player.getWorld().spawnParticle(Particle.EXPLOSION_HUGE, playerLocation, 2); - player.damage(7.42425, player); - boomBow.setDurability((short) (boomBow.getDurability() + 3)); - if(boomBow.getDurability() < 0){ - player.getInventory().setItemInMainHand(null); - player.getWorld().playSound(playerLocation, Sound.ENTITY_ITEM_BREAK, 0, 0) - ; - } - - } -} +package alisolarflare.components.magic.tricks; + +import org.bukkit.GameMode; +import org.bukkit.Location; +import org.bukkit.Material; +import org.bukkit.Particle; +import org.bukkit.Sound; +import org.bukkit.enchantments.Enchantment; +import org.bukkit.entity.Player; +import org.bukkit.event.EventHandler; +import org.bukkit.event.Listener; +import org.bukkit.event.block.Action; +import org.bukkit.event.player.PlayerInteractEvent; +import org.bukkit.inventory.ItemStack; +import org.bukkit.inventory.PlayerInventory; +import org.bukkit.plugin.java.JavaPlugin; +import org.bukkit.potion.PotionEffect; +import org.bukkit.potion.PotionEffectType; + +public class BoomBowListener implements Listener { + JavaPlugin plugin; + public BoomBowListener(JavaPlugin plugin){ + this.plugin = plugin; + } + @EventHandler + public void ClickEvent(PlayerInteractEvent event){ + FlyBowBoost(event); + + } + public void FlyBowBoost(PlayerInteractEvent event){ + + //ACTION SANITATION + if(!(event.getAction() == Action.LEFT_CLICK_AIR || event.getAction() == Action.LEFT_CLICK_BLOCK)) return; + if(!(event.getPlayer().isGliding())) return; + if(!(event.getMaterial() == Material.BOW)) return; + + //BOW SANITATION + ItemStack bow = event.getItem(); + if(!(bow.containsEnchantment(Enchantment.ARROW_KNOCKBACK))) return; + if(!(bow.getEnchantmentLevel(Enchantment.ARROW_KNOCKBACK) == 3)) return; + if(!(bow.getItemMeta().getDisplayName().contains("BOOM BOW"))) return; + + //PLAYER SANITATION + Player player = event.getPlayer(); + PlayerInventory inventory = player.getInventory(); + if(player.getGameMode().equals(GameMode.SPECTATOR))return; + + if(bow.containsEnchantment(Enchantment.ARROW_INFINITE)){ + //HAS INIFINITY + Activate(event); + + }else if((inventory.contains(Material.TNT))){ + //HAS TNT + Activate(event); + + //Reduce TNT + ItemStack tnt = inventory.getItem(inventory.first(Material.TNT)); + + if(tnt.getAmount() > 3){ + tnt.setAmount(tnt.getAmount()-3); + }else{ + inventory.remove(tnt); + } + if (bow.getDurability() < 0){ + inventory.clear(inventory.getHeldItemSlot()); + } + + }else{ + return; + } + } + + + + public void Activate(PlayerInteractEvent event){ + //INIT - Player variables + Player player = event.getPlayer(); + Location playerLocation = player.getLocation(); + ItemStack boomBow = player.getInventory().getItemInMainHand(); + + //TODO: NERF - boomDecay + //TODO: NERF - endCrystal + //TODO: NERF - healthReduction + //TODO: NERF - localized + + if(BoomBowRule.boomDecay) + new BoomDecayTask(player).runTaskTimer(plugin, 1, 1); + if(BoomBowRule.endCrystal){ + //BoomBowCyrstalSpawn + } + if(BoomBowRule.healthReduction){ + player.addPotionEffect(new PotionEffect(PotionEffectType.HEALTH_BOOST, 400, -1)); + } + if(BoomBowRule.localized); + + + //SET - Player Velocity + player.setVelocity(playerLocation.getDirection().normalize().multiply(3.0)); + + //CREATE - Explosion + damage + player.getWorld().playSound(playerLocation, Sound.ENTITY_GENERIC_EXPLODE, 10, -20); + player.getWorld().spawnParticle(Particle.EXPLOSION_HUGE, playerLocation, 2); + player.damage(7.42425, player); + boomBow.setDurability((short) (boomBow.getDurability() + 3)); + if(boomBow.getDurability() > 385){ + player.getInventory().setItemInMainHand(null); + player.getWorld().playSound(playerLocation, Sound.ENTITY_ITEM_BREAK, 0, 0); + } + + } +} diff --git a/src/alisolarflare/components/magic/tricks/CannonBowListener.java b/src/alisolarflare/components/magic/tricks/CannonBowListener.java index 097f685..9eb0515 100644 --- a/src/alisolarflare/components/magic/tricks/CannonBowListener.java +++ b/src/alisolarflare/components/magic/tricks/CannonBowListener.java @@ -17,6 +17,7 @@ import org.bukkit.inventory.ItemStack; import org.bukkit.plugin.java.JavaPlugin; public class CannonBowListener implements Listener { + public final static String launchedTNTName = "CANNON BOW TNT:42170"; JavaPlugin plugin; public CannonBowListener(JavaPlugin plugin){ this.plugin = plugin; @@ -24,32 +25,33 @@ public class CannonBowListener implements Listener { @EventHandler public void onProjectileLaunch(ProjectileLaunchEvent event){ - if(event.getEntity().getType() != EntityType.ARROW) - return; + //ENTITY SANITATION + if(event.getEntity().getType() != EntityType.ARROW)return; + + //ARROW SANITATION Arrow arrow = (Arrow) event.getEntity(); - if (!(arrow.isCritical()) || !(arrow.getShooter() instanceof Player)) - return; + if (!(arrow.isCritical()) || !(arrow.getShooter() instanceof Player))return; + + //PLAYER SANITATION Player player = (Player) arrow.getShooter(); + if (!player.getInventory().contains(Material.TNT))return; + + //BOW SANITATION ItemStack bow; - if ((bow = player.getInventory().getItemInMainHand()).getType() != Material.BOW) - return; - if (!bow.containsEnchantment(Enchantment.PROTECTION_EXPLOSIONS)) - return; - if(!(bow.getEnchantmentLevel(Enchantment.PROTECTION_EXPLOSIONS) == 10)) - return; - if (!bow.getItemMeta().getDisplayName().toUpperCase().contains("CANNON BOW")) - return; - if (!player.getInventory().contains(Material.TNT)) - return; + if (!((bow = player.getInventory().getItemInMainHand()).getType() == Material.BOW))return; + if (!(bow.containsEnchantment(Enchantment.PROTECTION_EXPLOSIONS)))return; + if (!(bow.getEnchantmentLevel(Enchantment.PROTECTION_EXPLOSIONS) == 10))return; + if (!(bow.getItemMeta().getDisplayName().toUpperCase().contains("CANNON BOW")))return; TNTPrimed tnt = (TNTPrimed) arrow.getWorld().spawnEntity(arrow.getLocation(), EntityType.PRIMED_TNT); tnt.setVelocity(player.getEyeLocation().getDirection().normalize().multiply(1.0)); - tnt.setCustomName("CANNON BOW TNT"); + tnt.setCustomName(launchedTNTName); tnt.setFuseTicks(40); player.setVelocity(player.getEyeLocation().getDirection().normalize().multiply(-1)); player.getWorld().playSound(player.getLocation(), Sound.ENTITY_GENERIC_EXPLODE, 2.0F, 0); - player.getWorld().spawnParticle(Particle.EXPLOSION_NORMAL, player.getLocation(), 1); + player.getWorld().spawnParticle(Particle.EXPLOSION_HUGE, player.getLocation(), 2); + arrow.remove(); return; @@ -57,10 +59,9 @@ public class CannonBowListener implements Listener { @EventHandler public void onTnTExplode(EntityExplodeEvent event) { - if (event.getEntityType() != EntityType.PRIMED_TNT) - return; - if (!event.getEntity().getCustomName().equals("CANNON BOW TNT")) - return; + if (event.getEntityType() != EntityType.PRIMED_TNT) return; + if (!event.getEntity().getCustomName().equals(launchedTNTName)) return; + Location loc = event.getEntity().getLocation(); event.getEntity().getWorld().createExplosion(loc.getX(), loc.getY(), loc.getZ(), 3, false, false); event.setCancelled(true); diff --git a/src/alisolarflare/components/minigames/MinigameComponent.java b/src/alisolarflare/components/minigames/MinigameComponent.java index a4f8322..5b662e1 100644 --- a/src/alisolarflare/components/minigames/MinigameComponent.java +++ b/src/alisolarflare/components/minigames/MinigameComponent.java @@ -2,6 +2,7 @@ package alisolarflare.components.minigames; import java.util.List; +import org.bukkit.entity.Player; import org.bukkit.plugin.java.JavaPlugin; import alisolarflare.architecture.Component; @@ -14,7 +15,7 @@ import alisolarflare.components.minigames.data.SpawnSet; public class MinigameComponent extends Component{ public SpawnSet spawnSet; public List fighters; - private GameState gameState; + public GameState gameState; @Override public void register(JavaPlugin plugin) { @@ -25,9 +26,11 @@ public class MinigameComponent extends Component{ registerCommand(plugin, new ListFighters(this)); } - - public GameState getGameState() {return gameState;} - public void setGameState(GameState gameState) {this.gameState = gameState;} - - + public class Fighter { + public Player player; + public String colour; + public Fighter(Player player, String colour){ + this.colour = colour; + } + } } diff --git a/src/alisolarflare/components/minigames/commands/JoinMinigame.java b/src/alisolarflare/components/minigames/commands/JoinMinigame.java index 6eea609..8dc07d2 100644 --- a/src/alisolarflare/components/minigames/commands/JoinMinigame.java +++ b/src/alisolarflare/components/minigames/commands/JoinMinigame.java @@ -1,28 +1,25 @@ package alisolarflare.components.minigames.commands; +import java.util.List; + import org.bukkit.entity.Player; import alisolarflare.architecture.commands.PlayerCommand; import alisolarflare.components.minigames.MinigameComponent; public class JoinMinigame extends PlayerCommand { - private MinigameComponent module; + private List fighterList; - public JoinMinigame(MinigameComponent module) { - this.module = module; + public JoinMinigame(MinigameComponent component) { + this.fighterList = component.fighters; } @Override - public boolean OnCommand(Player player, String arg2, String[] arg3) { - String name = player.getName(); - if (module.fighters.contains(name)) { + public boolean OnCommand(Player player, String arg2, String[] arg3) { + if (fighterList.contains(player.getName())) { player.sendMessage("You are already in the minigame!"); - return true; - } - - module.fighters.add(name); - - if (module.fighters.contains(name)) { + }else{ + fighterList.add(player.getName()); player.sendMessage("You have joined the minigame!"); } return true; diff --git a/src/alisolarflare/components/minigames/commands/LeaveMinigame.java b/src/alisolarflare/components/minigames/commands/LeaveMinigame.java index d1e4345..c7c5f9c 100644 --- a/src/alisolarflare/components/minigames/commands/LeaveMinigame.java +++ b/src/alisolarflare/components/minigames/commands/LeaveMinigame.java @@ -1,16 +1,17 @@ package alisolarflare.components.minigames.commands; +import java.util.List; + import org.bukkit.entity.Player; import alisolarflare.architecture.commands.PlayerCommand; import alisolarflare.components.minigames.MinigameComponent; public class LeaveMinigame extends PlayerCommand { + private List fighters; - private MinigameComponent module; - - public LeaveMinigame(MinigameComponent module) { - this.module = module; + public LeaveMinigame(MinigameComponent components) { + this.fighters = components.fighters; } @Override @@ -18,15 +19,14 @@ public class LeaveMinigame extends PlayerCommand { if(!(player instanceof Player)) player.sendMessage("You must be a player to use this command!"); - String name = player.getName(); - if (!(module.fighters.contains(name))) { + if (!(fighters.contains(name))) { player.sendMessage("You are not fighting!"); return true; } - while(module.fighters.contains(name)){ - module.fighters.remove(name); + while(fighters.contains(name)){ + fighters.remove(name); } player.sendMessage("You have left the fighters category!"); diff --git a/src/alisolarflare/components/minigames/commands/ListFighters.java b/src/alisolarflare/components/minigames/commands/ListFighters.java index c5a9f10..6904914 100644 --- a/src/alisolarflare/components/minigames/commands/ListFighters.java +++ b/src/alisolarflare/components/minigames/commands/ListFighters.java @@ -6,15 +6,15 @@ import alisolarflare.architecture.commands.PlayerCommand; import alisolarflare.components.minigames.MinigameComponent; public class ListFighters extends PlayerCommand { - private MinigameComponent lobby; + private MinigameComponent component; - public ListFighters(MinigameComponent lobby) { - this.lobby = lobby; + public ListFighters(MinigameComponent component) { + this.component = component; } @Override public boolean OnCommand(Player player, String arg2, String[] arg3) { - player.sendMessage(lobby.fighters.toString()); + player.sendMessage(component.fighters.toString()); return true; } @Override diff --git a/src/alisolarflare/components/minigames/commands/SetColourSpawn.java b/src/alisolarflare/components/minigames/commands/SetColourSpawn.java index 24a23d4..bb29f3e 100644 --- a/src/alisolarflare/components/minigames/commands/SetColourSpawn.java +++ b/src/alisolarflare/components/minigames/commands/SetColourSpawn.java @@ -7,7 +7,7 @@ import alisolarflare.components.minigames.data.SpawnSet; public class SetColourSpawn extends ModCommand{ private SpawnSet spawnSet; - + public SetColourSpawn(SpawnSet spawnSet){ this.spawnSet = spawnSet; } @@ -17,41 +17,41 @@ public class SetColourSpawn extends ModCommand{ player.sendMessage("ERROR: Arguments required."); return false; } - + String input = args[0]; - + input.toLowerCase(); switch(input){ case ("r"): player.sendMessage("Setting Red Spawn..."); - spawnSet.setRSpawn(player.getLocation()); + spawnSet.RSpawn = player.getLocation(); player.sendMessage("Red Spawn Set!"); break; case ("o"): player.sendMessage("Setting Orange Spawn..."); - spawnSet.setRSpawn(player.getLocation()); + spawnSet.OSpawn = player.getLocation(); player.sendMessage("Orange Spawn Set!"); break; case ("y"): player.sendMessage("Setting Yellow Spawn..."); - spawnSet.setRSpawn(player.getLocation()); + spawnSet.YSpawn = player.getLocation(); player.sendMessage("Yellow Spawn Set!"); break; case ("g"): player.sendMessage("Setting Green Spawn..."); - spawnSet.setRSpawn(player.getLocation()); + spawnSet.GSpawn = player.getLocation(); player.sendMessage("Green Spawn Set!"); break; case ("b"): player.sendMessage("Setting Blue Spawn..."); - spawnSet.setRSpawn(player.getLocation()); + spawnSet.BSpawn = player.getLocation(); player.sendMessage("Blue Spawn Set!"); break; case ("p"): player.sendMessage("Setting Purple Spawn..."); - spawnSet.setRSpawn(player.getLocation()); + spawnSet.PSpawn = player.getLocation(); player.sendMessage("Purple Spawn Set!"); - break; + break; } return true; } diff --git a/src/alisolarflare/components/minigames/data/SpawnSet.java b/src/alisolarflare/components/minigames/data/SpawnSet.java index dfd2ba9..be34825 100644 --- a/src/alisolarflare/components/minigames/data/SpawnSet.java +++ b/src/alisolarflare/components/minigames/data/SpawnSet.java @@ -3,25 +3,11 @@ package alisolarflare.components.minigames.data; import org.bukkit.Location; public class SpawnSet { - private Location RSpawn; - private Location OSpawn; - private Location YSpawn; - private Location GSpawn; - private Location BSpawn; - private Location PSpawn; - - public Location getRSpawn(){return RSpawn;} - public Location getOSpawn(){return OSpawn;} - public Location getYSpawn(){return YSpawn;} - public Location getGSpawn(){return GSpawn;} - public Location getBSpawn(){return BSpawn;} - public Location getPSpawn(){return PSpawn;} - - public void setRSpawn(Location RSpawn){this.RSpawn = RSpawn; return;} - public void setOSpawn(Location OSpawn){this.OSpawn = OSpawn; return;} - public void setYSpawn(Location YSpawn){this.YSpawn = YSpawn; return;} - public void setGSpawn(Location GSpawn){this.GSpawn = GSpawn; return;} - public void setBSpawn(Location BSpawn){this.BSpawn = BSpawn; return;} - public void setPSpawn(Location PSpawn){this.PSpawn = PSpawn; return;} + public Location RSpawn; + public Location OSpawn; + public Location YSpawn; + public Location GSpawn; + public Location BSpawn; + public Location PSpawn; } diff --git a/src/alisolarflare/components/minigames/entities/Fighter.java b/src/alisolarflare/components/minigames/entities/Fighter.java deleted file mode 100644 index 79fc62a..0000000 --- a/src/alisolarflare/components/minigames/entities/Fighter.java +++ /dev/null @@ -1,11 +0,0 @@ -package alisolarflare.components.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; - } -}