From 1d3471f09909a3e459df2090c4725b158a5503e9 Mon Sep 17 00:00:00 2001 From: alisolarflare Date: Thu, 22 Dec 2016 21:31:36 -0500 Subject: [PATCH] Got Dungeon teleporting set up and working --- config.yml | 5 ---- plugin.yml | 2 ++ .../components/dungeons/DungeonComponent.java | 8 ++++- .../dungeons/commands/DisplayDebug.java | 28 ++++++++++++++++++ .../components/dungeons/commands/Enter.java | 4 +-- .../components/dungeons/commands/Exit.java | 7 +++-- .../dungeons/commands/SetEntrance.java | 25 ++++++++++++++++ .../components/dungeons/commands/SetExit.java | 28 ++++++++++++++++++ .../components/dungeons/dungeons/Dungeon.java | 2 ++ .../dungeons/dungeons/GenericDungeonA1.java | 29 ++++++++++++------- 10 files changed, 116 insertions(+), 22 deletions(-) create mode 100644 src/buttondevteam/alipresents/components/dungeons/commands/DisplayDebug.java create mode 100644 src/buttondevteam/alipresents/components/dungeons/commands/SetEntrance.java create mode 100644 src/buttondevteam/alipresents/components/dungeons/commands/SetExit.java diff --git a/config.yml b/config.yml index 9fd8419..e69de29 100644 --- a/config.yml +++ b/config.yml @@ -1,5 +0,0 @@ -UHCMatchState: "IDLE" -magic: - cannonbow: - speedmultiplier: 1.5 - minforce: 0.2 \ No newline at end of file diff --git a/plugin.yml b/plugin.yml index 32b153e..4860aeb 100644 --- a/plugin.yml +++ b/plugin.yml @@ -7,6 +7,8 @@ commands: description: creates wireless redstone cb: description: creates creative boundaries + dungeons: + description: handles the resource dungeons scattered around the map debug: description: debug commands flaircolour: diff --git a/src/buttondevteam/alipresents/components/dungeons/DungeonComponent.java b/src/buttondevteam/alipresents/components/dungeons/DungeonComponent.java index 439f60c..d9e0b1d 100644 --- a/src/buttondevteam/alipresents/components/dungeons/DungeonComponent.java +++ b/src/buttondevteam/alipresents/components/dungeons/DungeonComponent.java @@ -3,8 +3,11 @@ package buttondevteam.alipresents.components.dungeons; import org.bukkit.plugin.java.JavaPlugin; import buttondevteam.alipresents.architecture.Component; +import buttondevteam.alipresents.components.dungeons.commands.DisplayDebug; import buttondevteam.alipresents.components.dungeons.commands.Enter; import buttondevteam.alipresents.components.dungeons.commands.Exit; +import buttondevteam.alipresents.components.dungeons.commands.SetEntrance; +import buttondevteam.alipresents.components.dungeons.commands.SetExit; import buttondevteam.alipresents.components.dungeons.dungeons.GenericDungeonA1; public class DungeonComponent extends Component { @@ -12,9 +15,12 @@ public class DungeonComponent extends Component { @Override public void register(JavaPlugin plugin) { dungeonA1 = new GenericDungeonA1(plugin); + + registerCommand(plugin, new DisplayDebug(this)); registerCommand(plugin, new Enter(this)); registerCommand(plugin, new Exit(this)); - + registerCommand(plugin, new SetEntrance(this)); + registerCommand(plugin, new SetExit(this)); } } diff --git a/src/buttondevteam/alipresents/components/dungeons/commands/DisplayDebug.java b/src/buttondevteam/alipresents/components/dungeons/commands/DisplayDebug.java new file mode 100644 index 0000000..88803c3 --- /dev/null +++ b/src/buttondevteam/alipresents/components/dungeons/commands/DisplayDebug.java @@ -0,0 +1,28 @@ +package buttondevteam.alipresents.components.dungeons.commands; + +import org.bukkit.entity.Player; + +import buttondevteam.alipresents.architecture.commands.ModCommand; +import buttondevteam.alipresents.components.dungeons.DungeonComponent; + +public class DisplayDebug extends ModCommand { + + private DungeonComponent component; + + public DisplayDebug(DungeonComponent component) { + this.component = component; + } + + @Override + public boolean OnCommand(Player player, String alias, String[] args) { + player.sendMessage("Entrance Location: "+component.dungeonA1.getDungeonEntrance().toString()); + player.sendMessage("Exit Location: "+component.dungeonA1.getDungeonExit().toString()); + return true; + } + + @Override + public String GetCommandPath(){ + return "dungeons display debug"; + } + +} diff --git a/src/buttondevteam/alipresents/components/dungeons/commands/Enter.java b/src/buttondevteam/alipresents/components/dungeons/commands/Enter.java index d93b8d7..45317f4 100644 --- a/src/buttondevteam/alipresents/components/dungeons/commands/Enter.java +++ b/src/buttondevteam/alipresents/components/dungeons/commands/Enter.java @@ -13,11 +13,11 @@ public class Enter extends ModCommand{ @Override public boolean OnCommand(Player player, String alias, String[] args) { component.dungeonA1.enterDungeon(player); - return false; + return true; } @Override public String GetCommandPath(){ - return "dungeon enter"; + return "dungeons enter"; } } diff --git a/src/buttondevteam/alipresents/components/dungeons/commands/Exit.java b/src/buttondevteam/alipresents/components/dungeons/commands/Exit.java index 88b2f74..17c5dd2 100644 --- a/src/buttondevteam/alipresents/components/dungeons/commands/Exit.java +++ b/src/buttondevteam/alipresents/components/dungeons/commands/Exit.java @@ -14,10 +14,11 @@ public class Exit extends PlayerCommand { @Override public boolean OnCommand(Player player, String alias, String[] args) { component.dungeonA1.exitDungeon(player); - return false; + return true; } - public String getCommandPath(){ - return "dungeon exit"; + @Override + public String GetCommandPath(){ + return "dungeons exit"; } } diff --git a/src/buttondevteam/alipresents/components/dungeons/commands/SetEntrance.java b/src/buttondevteam/alipresents/components/dungeons/commands/SetEntrance.java new file mode 100644 index 0000000..3d9a25b --- /dev/null +++ b/src/buttondevteam/alipresents/components/dungeons/commands/SetEntrance.java @@ -0,0 +1,25 @@ +package buttondevteam.alipresents.components.dungeons.commands; + +import org.bukkit.entity.Player; + +import buttondevteam.alipresents.architecture.commands.ModCommand; +import buttondevteam.alipresents.components.dungeons.DungeonComponent; + +public class SetEntrance extends ModCommand { + + private DungeonComponent component; + public SetEntrance(DungeonComponent component) { + this.component = component; + } + @Override + public boolean OnCommand(Player player, String alias, String[] args) { + player.sendMessage("Setting DungeonA1's Entrance!"); + component.dungeonA1.setEntrance(player.getLocation()); + player.sendMessage("Entrance Set!"); + return true; + } + public String GetCommandPath(){ + return "dungeons set entrance"; + } + +} diff --git a/src/buttondevteam/alipresents/components/dungeons/commands/SetExit.java b/src/buttondevteam/alipresents/components/dungeons/commands/SetExit.java new file mode 100644 index 0000000..b7d356d --- /dev/null +++ b/src/buttondevteam/alipresents/components/dungeons/commands/SetExit.java @@ -0,0 +1,28 @@ +package buttondevteam.alipresents.components.dungeons.commands; + +import org.bukkit.entity.Player; + +import buttondevteam.alipresents.architecture.commands.ModCommand; +import buttondevteam.alipresents.components.dungeons.DungeonComponent; + +public class SetExit extends ModCommand { + + private DungeonComponent component; + + public SetExit(DungeonComponent component) { + this.component = component; + } + + @Override + public boolean OnCommand(Player player, String alias, String[] args) { + player.sendMessage("Setting DungeonA1's Exit!"); + component.dungeonA1.setExit(player.getLocation()); + player.sendMessage("DungeonA1's Exit Set!"); + return true; + } + @Override + public String GetCommandPath(){ + return "dungeons set exit"; + } + +} diff --git a/src/buttondevteam/alipresents/components/dungeons/dungeons/Dungeon.java b/src/buttondevteam/alipresents/components/dungeons/dungeons/Dungeon.java index 520c36a..f2f9453 100644 --- a/src/buttondevteam/alipresents/components/dungeons/dungeons/Dungeon.java +++ b/src/buttondevteam/alipresents/components/dungeons/dungeons/Dungeon.java @@ -8,6 +8,8 @@ import org.bukkit.entity.Player; public abstract class Dungeon { public abstract Location getDungeonEntrance(); public abstract Location getDungeonExit(); + public abstract void setEntrance(Location location); + public abstract void setExit(Location location); public boolean enterDungeon(Player player){ if (getDungeonEntrance() == null){ diff --git a/src/buttondevteam/alipresents/components/dungeons/dungeons/GenericDungeonA1.java b/src/buttondevteam/alipresents/components/dungeons/dungeons/GenericDungeonA1.java index 55ca9b6..b4c13f5 100644 --- a/src/buttondevteam/alipresents/components/dungeons/dungeons/GenericDungeonA1.java +++ b/src/buttondevteam/alipresents/components/dungeons/dungeons/GenericDungeonA1.java @@ -4,13 +4,15 @@ import org.bukkit.Location; import org.bukkit.plugin.java.JavaPlugin; public class GenericDungeonA1 extends Dungeon{ - private Location dungeonEntrance; - private Location dungeonExit; + private Location entrance; + private Location exit; + private JavaPlugin plugin; public GenericDungeonA1(JavaPlugin plugin){ if(!initDungeon(plugin)){ plugin.getServer().broadcastMessage("DungeonA1 cant be initialized!"); } + this.plugin = plugin; } private boolean initDungeon(JavaPlugin plugin){ if (plugin.getServer().getWorld("Dungeons") == null || plugin.getServer().getWorld("world") == null){ @@ -19,27 +21,32 @@ public class GenericDungeonA1 extends Dungeon{ return false; } - dungeonEntrance = new Location(plugin.getServer().getWorld("Dungeons"), -7.5, 138.0, -91.5); - dungeonExit = plugin.getServer().getWorld("world").getSpawnLocation().clone(); + entrance = new Location(plugin.getServer().getWorld("Dungeons"), -7.5, 138.0, -91.5); + exit = plugin.getServer().getWorld("world").getSpawnLocation().clone(); - if (dungeonEntrance == null || dungeonExit == null){ + if (entrance == null || exit == null){ plugin.getServer().broadcastMessage("DungeonA1Error! Dungeon Entrance or Exit is null!"); - plugin.getServer().broadcastMessage("DungeonEnterance: " + dungeonEntrance.toString()); - plugin.getServer().broadcastMessage("Dungeon Exit: " + dungeonExit.toString()); + plugin.getServer().broadcastMessage("Dungeon Entrance: " + entrance.toString()); + plugin.getServer().broadcastMessage("Dungeon Exit: " + exit.toString()); return false; } return true; } - public void setDungeonEnterance(Location location){ - dungeonEntrance = location; + public void setEntrance(Location location){ + plugin.getConfig().set("dungeons.dungeona1.entrance", entrance); + plugin.saveConfig(); + entrance = location; + } + public void setExit(Location location){ + exit = location; } @Override public Location getDungeonEntrance() { - return dungeonEntrance; + return entrance; } @Override public Location getDungeonExit() { - return dungeonExit; + return exit; } }