From 4a4ee986d57bb8dd2df2be48e3a2bb80571a2e63 Mon Sep 17 00:00:00 2001 From: alisolarflare Date: Thu, 22 Dec 2016 09:33:31 -0500 Subject: [PATCH 1/8] Changed Filepaths --- .../components/metrics/MetricsComponent.java | 11 ++++++++--- 1 file changed, 8 insertions(+), 3 deletions(-) diff --git a/src/buttondevteam/alipresents/components/metrics/MetricsComponent.java b/src/buttondevteam/alipresents/components/metrics/MetricsComponent.java index ea57a09..0e561a6 100644 --- a/src/buttondevteam/alipresents/components/metrics/MetricsComponent.java +++ b/src/buttondevteam/alipresents/components/metrics/MetricsComponent.java @@ -11,15 +11,20 @@ import buttondevteam.alipresents.components.metrics.files.MetricsFile; import buttondevteam.alipresents.components.metrics.output.GetLoginMetrics; public class MetricsComponent extends Component{ - String defaultPath = "src/alisolarflare/resources"; - String defaultFilePath = (defaultPath + "/metrics.txt"); - String playerLoginsFilePath = (defaultPath + "/playerLogins.txt"); + String defaultPath; + String defaultFilePath; + String playerLoginsFilePath; public MetricsFile playerLoginsFile; // DATA - STRING public List metricsList; @Override public void register(JavaPlugin plugin){ + + defaultPath = plugin.getDataFolder().getAbsolutePath(); + defaultFilePath = defaultPath + "/metrics.txt"; + playerLoginsFilePath = defaultPath + "/playerLogins.txt"; + playerLoginsFile = new MetricsFile(playerLoginsFilePath); registerCommand(plugin, new GetLoginMetrics(this)); registerListener(plugin, new PlayerJoinListener(this, playerLoginsFile)); -- 2.30.2 From 67aab381686c2b3be911b0c56b4aa39787cfb580 Mon Sep 17 00:00:00 2001 From: alisolarflare Date: Thu, 22 Dec 2016 19:58:29 -0500 Subject: [PATCH 2/8] ok <@126012419792306177> --- src/buttondevteam/alipresents/AliPresents.java | 2 ++ 1 file changed, 2 insertions(+) diff --git a/src/buttondevteam/alipresents/AliPresents.java b/src/buttondevteam/alipresents/AliPresents.java index d8ad8bc..584d194 100644 --- a/src/buttondevteam/alipresents/AliPresents.java +++ b/src/buttondevteam/alipresents/AliPresents.java @@ -8,6 +8,7 @@ import org.bukkit.plugin.java.JavaPlugin; import buttondevteam.alipresents.components.alilinks.AliLinkComponent; import buttondevteam.alipresents.components.creativeboundaries.CreativeBoundariesComponent; +import buttondevteam.alipresents.components.dungeons.DungeonComponent; import buttondevteam.alipresents.components.flaircolour.FlairColourComponent; import buttondevteam.alipresents.components.gpower.GPowerComponent; import buttondevteam.alipresents.components.hotfix.HotfixComponent; @@ -24,6 +25,7 @@ public class AliPresents extends JavaPlugin{ new AliLinkComponent().register(this); new CreativeBoundariesComponent().register(this); + new DungeonComponent().register(this); new FlairColourComponent().register(this); new GPowerComponent().register(this); new HotfixComponent().register(this); -- 2.30.2 From d839fd9dd163a8a4a81efcb44af9acedfc381b26 Mon Sep 17 00:00:00 2001 From: alisolarflare Date: Thu, 22 Dec 2016 19:58:43 -0500 Subject: [PATCH 3/8] Started work on Dungeons --- .../components/dungeons/DungeonComponent.java | 20 +++++++++ .../components/dungeons/commands/Enter.java | 23 ++++++++++ .../components/dungeons/commands/Exit.java | 23 ++++++++++ .../components/dungeons/dungeons/Dungeon.java | 30 +++++++++++++ .../dungeons/dungeons/GenericDungeonA1.java | 45 +++++++++++++++++++ 5 files changed, 141 insertions(+) create mode 100644 src/buttondevteam/alipresents/components/dungeons/DungeonComponent.java create mode 100644 src/buttondevteam/alipresents/components/dungeons/commands/Enter.java create mode 100644 src/buttondevteam/alipresents/components/dungeons/commands/Exit.java create mode 100644 src/buttondevteam/alipresents/components/dungeons/dungeons/Dungeon.java create mode 100644 src/buttondevteam/alipresents/components/dungeons/dungeons/GenericDungeonA1.java diff --git a/src/buttondevteam/alipresents/components/dungeons/DungeonComponent.java b/src/buttondevteam/alipresents/components/dungeons/DungeonComponent.java new file mode 100644 index 0000000..439f60c --- /dev/null +++ b/src/buttondevteam/alipresents/components/dungeons/DungeonComponent.java @@ -0,0 +1,20 @@ +package buttondevteam.alipresents.components.dungeons; + +import org.bukkit.plugin.java.JavaPlugin; + +import buttondevteam.alipresents.architecture.Component; +import buttondevteam.alipresents.components.dungeons.commands.Enter; +import buttondevteam.alipresents.components.dungeons.commands.Exit; +import buttondevteam.alipresents.components.dungeons.dungeons.GenericDungeonA1; + +public class DungeonComponent extends Component { + public GenericDungeonA1 dungeonA1; + @Override + public void register(JavaPlugin plugin) { + dungeonA1 = new GenericDungeonA1(plugin); + registerCommand(plugin, new Enter(this)); + registerCommand(plugin, new Exit(this)); + + } + +} diff --git a/src/buttondevteam/alipresents/components/dungeons/commands/Enter.java b/src/buttondevteam/alipresents/components/dungeons/commands/Enter.java new file mode 100644 index 0000000..d93b8d7 --- /dev/null +++ b/src/buttondevteam/alipresents/components/dungeons/commands/Enter.java @@ -0,0 +1,23 @@ +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 Enter extends ModCommand{ + private DungeonComponent component; + public Enter(DungeonComponent component) { + this.component = component; + } + @Override + public boolean OnCommand(Player player, String alias, String[] args) { + component.dungeonA1.enterDungeon(player); + return false; + } + @Override + public String GetCommandPath(){ + return "dungeon enter"; + } + +} diff --git a/src/buttondevteam/alipresents/components/dungeons/commands/Exit.java b/src/buttondevteam/alipresents/components/dungeons/commands/Exit.java new file mode 100644 index 0000000..88b2f74 --- /dev/null +++ b/src/buttondevteam/alipresents/components/dungeons/commands/Exit.java @@ -0,0 +1,23 @@ +package buttondevteam.alipresents.components.dungeons.commands; + +import org.bukkit.entity.Player; + +import buttondevteam.alipresents.architecture.commands.PlayerCommand; +import buttondevteam.alipresents.components.dungeons.DungeonComponent; + +public class Exit extends PlayerCommand { + + private DungeonComponent component; + public Exit(DungeonComponent component) { + this.component = component; + } + @Override + public boolean OnCommand(Player player, String alias, String[] args) { + component.dungeonA1.exitDungeon(player); + return false; + } + public String getCommandPath(){ + return "dungeon exit"; + } + +} diff --git a/src/buttondevteam/alipresents/components/dungeons/dungeons/Dungeon.java b/src/buttondevteam/alipresents/components/dungeons/dungeons/Dungeon.java new file mode 100644 index 0000000..520c36a --- /dev/null +++ b/src/buttondevteam/alipresents/components/dungeons/dungeons/Dungeon.java @@ -0,0 +1,30 @@ +package buttondevteam.alipresents.components.dungeons.dungeons; + +import org.bukkit.GameMode; +import org.bukkit.Location; +import org.bukkit.entity.Player; + +/**Dungeon Object that represents a dungeon*/ +public abstract class Dungeon { + public abstract Location getDungeonEntrance(); + public abstract Location getDungeonExit(); + public boolean enterDungeon(Player player){ + + if (getDungeonEntrance() == null){ + player.sendMessage("There has been a collapse! You may not enter the dungeon now."); + return false; + } + player.teleport(getDungeonEntrance()); + player.setGameMode(GameMode.ADVENTURE); + return true; + } + public boolean exitDungeon(Player player){ + if (getDungeonExit() == null){ + player.sendMessage("Oh god, something went horribly wrong with exiting... Yell for help!"); + return false; + } + player.teleport(getDungeonExit()); + player.setGameMode(GameMode.SURVIVAL); + return true; + } +} diff --git a/src/buttondevteam/alipresents/components/dungeons/dungeons/GenericDungeonA1.java b/src/buttondevteam/alipresents/components/dungeons/dungeons/GenericDungeonA1.java new file mode 100644 index 0000000..d262f56 --- /dev/null +++ b/src/buttondevteam/alipresents/components/dungeons/dungeons/GenericDungeonA1.java @@ -0,0 +1,45 @@ +package buttondevteam.alipresents.components.dungeons.dungeons; + +import org.bukkit.Location; +import org.bukkit.plugin.java.JavaPlugin; + +public class GenericDungeonA1 extends Dungeon{ + private Location dungeonEntrance; + private Location dungeonExit; + + public GenericDungeonA1(JavaPlugin plugin){ + if(!initDungeon(plugin)){ + plugin.getServer().broadcastMessage("DungeonA1 can't be initialized!"); + } + } + private boolean initDungeon(JavaPlugin plugin){ + if (plugin.getServer().getWorld("Dungeons") == null || plugin.getServer().getWorld("world") == null){ + plugin.getServer().broadcastMessage("GenericDungeonA1Error! One of the worlds is null!"); + plugin.getServer().broadcastMessage("Available Worlds... " + plugin.getServer().getWorlds().toString()); + return false; + } + + dungeonEntrance = new Location(plugin.getServer().getWorld("Dungeons"), -7.5, 138.0, -91.5); + dungeonExit = plugin.getServer().getWorld("world").getSpawnLocation().clone(); + + if (dungeonEntrance == null || dungeonExit == null){ + plugin.getServer().broadcastMessage("DungeonA1Error! Dungeon Entrance or Exit is null!"); + plugin.getServer().broadcastMessage("DungeonEnterance: " + dungeonEntrance.toString()); + plugin.getServer().broadcastMessage("Dungeon Exit: " + dungeonExit.toString()); + return false; + } + return true; + } + public void setDungeonEnterance(Location location){ + dungeonEntrance = location; + } + @Override + public Location getDungeonEntrance() { + return dungeonEntrance; + } + @Override + public Location getDungeonExit() { + return dungeonExit; + } + +} -- 2.30.2 From c06f19d6e448e9f80ed5affbc4f0779a672c1f3e Mon Sep 17 00:00:00 2001 From: alisolarflare Date: Thu, 22 Dec 2016 20:02:04 -0500 Subject: [PATCH 4/8] Corrected grammar <@126012419792306177> --- .../components/dungeons/dungeons/GenericDungeonA1.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/buttondevteam/alipresents/components/dungeons/dungeons/GenericDungeonA1.java b/src/buttondevteam/alipresents/components/dungeons/dungeons/GenericDungeonA1.java index d262f56..55ca9b6 100644 --- a/src/buttondevteam/alipresents/components/dungeons/dungeons/GenericDungeonA1.java +++ b/src/buttondevteam/alipresents/components/dungeons/dungeons/GenericDungeonA1.java @@ -9,7 +9,7 @@ public class GenericDungeonA1 extends Dungeon{ public GenericDungeonA1(JavaPlugin plugin){ if(!initDungeon(plugin)){ - plugin.getServer().broadcastMessage("DungeonA1 can't be initialized!"); + plugin.getServer().broadcastMessage("DungeonA1 cant be initialized!"); } } private boolean initDungeon(JavaPlugin plugin){ -- 2.30.2 From 1d3471f09909a3e459df2090c4725b158a5503e9 Mon Sep 17 00:00:00 2001 From: alisolarflare Date: Thu, 22 Dec 2016 21:31:36 -0500 Subject: [PATCH 5/8] 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; } } -- 2.30.2 From 6aa87119a0fc951a6e86da2cc83c43ea2ee842cb Mon Sep 17 00:00:00 2001 From: alisolarflare Date: Fri, 23 Dec 2016 01:30:31 -0500 Subject: [PATCH 6/8] Oh god this is the ugliest code I've written in a while --- .../dungeons/dungeons/GenericDungeonA1.java | 41 ++++++++++++++++--- 1 file changed, 35 insertions(+), 6 deletions(-) diff --git a/src/buttondevteam/alipresents/components/dungeons/dungeons/GenericDungeonA1.java b/src/buttondevteam/alipresents/components/dungeons/dungeons/GenericDungeonA1.java index b4c13f5..4f70d62 100644 --- a/src/buttondevteam/alipresents/components/dungeons/dungeons/GenericDungeonA1.java +++ b/src/buttondevteam/alipresents/components/dungeons/dungeons/GenericDungeonA1.java @@ -1,6 +1,7 @@ package buttondevteam.alipresents.components.dungeons.dungeons; import org.bukkit.Location; +import org.bukkit.World; import org.bukkit.plugin.java.JavaPlugin; public class GenericDungeonA1 extends Dungeon{ @@ -15,14 +16,22 @@ public class GenericDungeonA1 extends Dungeon{ this.plugin = plugin; } private boolean initDungeon(JavaPlugin plugin){ + /* if (plugin.getServer().getWorld("Dungeons") == null || plugin.getServer().getWorld("world") == null){ plugin.getServer().broadcastMessage("GenericDungeonA1Error! One of the worlds is null!"); plugin.getServer().broadcastMessage("Available Worlds... " + plugin.getServer().getWorlds().toString()); return false; + }*/ + if ((entrance = loadLocation(plugin, "dungeons.dungeona1.enter")) == null){ + if(plugin.getServer().getWorld("Dungeons") != null){ + entrance = new Location(plugin.getServer().getWorld("Dungeons"), -7.5, 138.0, -91.5); + } + } + if ((exit = loadLocation(plugin, "dungeons.dungeona1.exit")) == null){ + if (plugin.getServer().getWorld("world") != null){ + exit = 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 (entrance == null || exit == null){ plugin.getServer().broadcastMessage("DungeonA1Error! Dungeon Entrance or Exit is null!"); @@ -32,12 +41,14 @@ public class GenericDungeonA1 extends Dungeon{ } return true; } + @Override public void setEntrance(Location location){ - plugin.getConfig().set("dungeons.dungeona1.entrance", entrance); - plugin.saveConfig(); + saveLocation(plugin, "dungeons.dungeona1.enter", location); entrance = location; } + @Override public void setExit(Location location){ + saveLocation(plugin, "dungeons.dungeona1.exit", location); exit = location; } @Override @@ -48,5 +59,23 @@ public class GenericDungeonA1 extends Dungeon{ public Location getDungeonExit() { return exit; } - + private void saveLocation(JavaPlugin plugin, String path, Location location){ + plugin.getConfig().set(path+".world", location.getWorld().getName()); + plugin.getConfig().set(path+".x", location.getX()); + plugin.getConfig().set(path+".y", location.getY()); + plugin.getConfig().set(path+".z", location.getZ()); + plugin.saveConfig(); + } + private Location loadLocation(JavaPlugin plugin, String path){ + try{ + World world = plugin.getServer().getWorld(plugin.getConfig().getString(path+".world")); + double x = plugin.getConfig().getDouble(path+".x"); + double y = plugin.getConfig().getDouble(path+".y"); + double z = plugin.getConfig().getDouble(path+".z"); + return new Location(world, x, y, z); + }catch(Exception e){ + e.printStackTrace(); + return null; + } + } } -- 2.30.2 From b9219413f6247d50898f9cdbf9d2b29587176f8e Mon Sep 17 00:00:00 2001 From: alisolarflare Date: Fri, 23 Dec 2016 22:50:49 -0500 Subject: [PATCH 7/8] Adjusted Dungeons --- .../dungeons/dungeons/GenericDungeonA1.java | 26 +++++++++++++------ 1 file changed, 18 insertions(+), 8 deletions(-) diff --git a/src/buttondevteam/alipresents/components/dungeons/dungeons/GenericDungeonA1.java b/src/buttondevteam/alipresents/components/dungeons/dungeons/GenericDungeonA1.java index 4f70d62..b8ad2bd 100644 --- a/src/buttondevteam/alipresents/components/dungeons/dungeons/GenericDungeonA1.java +++ b/src/buttondevteam/alipresents/components/dungeons/dungeons/GenericDungeonA1.java @@ -22,15 +22,24 @@ public class GenericDungeonA1 extends Dungeon{ plugin.getServer().broadcastMessage("Available Worlds... " + plugin.getServer().getWorlds().toString()); return false; }*/ - if ((entrance = loadLocation(plugin, "dungeons.dungeona1.enter")) == null){ - if(plugin.getServer().getWorld("Dungeons") != null){ - entrance = new Location(plugin.getServer().getWorld("Dungeons"), -7.5, 138.0, -91.5); - } + Location temp; + if ((temp = loadLocation(plugin, "dungeons.dungeona1.enter")) != null){ + entrance = temp; + }else if(plugin.getServer().getWorld("Dungeons") != null){ + entrance = new Location(plugin.getServer().getWorld("Dungeons"), -7.5, 138.0, -91.5); + }else{ + plugin.getServer().broadcastMessage("There is no working default dungeon entrance for A1, setting to null"); + entrance = null; } - if ((exit = loadLocation(plugin, "dungeons.dungeona1.exit")) == null){ - if (plugin.getServer().getWorld("world") != null){ - exit = plugin.getServer().getWorld("world").getSpawnLocation().clone(); - } + + temp = null; + if ((temp = loadLocation(plugin, "dungeons.dungeona1.exit")) != null){ + exit = temp; + }else if (plugin.getServer().getWorld("world") != null){ + exit = plugin.getServer().getWorld("world").getSpawnLocation().clone(); + }else{ + plugin.getServer().broadcastMessage("There is no working default dungeon exit for A1, setting to null"); + exit = null; } if (entrance == null || exit == null){ @@ -72,6 +81,7 @@ public class GenericDungeonA1 extends Dungeon{ double x = plugin.getConfig().getDouble(path+".x"); double y = plugin.getConfig().getDouble(path+".y"); double z = plugin.getConfig().getDouble(path+".z"); + return new Location(world, x, y, z); }catch(Exception e){ e.printStackTrace(); -- 2.30.2 From 7d012bb9ec1a8a746465fe18cda6d6ee5acfad7f Mon Sep 17 00:00:00 2001 From: alisolarflare Date: Sat, 24 Dec 2016 02:15:02 -0500 Subject: [PATCH 8/8] Added isDestructive setting --- .../magic/tricks/CannonBowListener.java | 214 +++++++++++++----- .../magic/tricks/CannonBowSettings.java | 11 +- 2 files changed, 164 insertions(+), 61 deletions(-) diff --git a/src/buttondevteam/alipresents/components/magic/tricks/CannonBowListener.java b/src/buttondevteam/alipresents/components/magic/tricks/CannonBowListener.java index 3bf6f60..85dbd81 100644 --- a/src/buttondevteam/alipresents/components/magic/tricks/CannonBowListener.java +++ b/src/buttondevteam/alipresents/components/magic/tricks/CannonBowListener.java @@ -4,6 +4,7 @@ import org.bukkit.Location; import org.bukkit.Material; import org.bukkit.Particle; import org.bukkit.Sound; +import org.bukkit.command.CommandSender; import org.bukkit.configuration.file.FileConfiguration; import org.bukkit.enchantments.Enchantment; import org.bukkit.entity.Arrow; @@ -19,55 +20,87 @@ import org.bukkit.plugin.java.JavaPlugin; import org.bukkit.util.Vector; public class CannonBowListener implements Listener { - private static double SpeedMultiplier = 1.5; - private static double minforce = 0.2; - private static int fuseticks = 40; - private static double recoil = 1; + + private static double maxSpeedMultiplier = 4; + private static double minSpeedMultiplier = 0; + private static double defaultSpeedMultiplier = 1; + private static String speedMultiplierPath = "magic.cannonbow.speedmultiplier"; + + private static int maxFuseTicks = 400; + private static int minFuseTicks = 0; + private static int defaultFuseTicks = 30; + private static String fuseTicksPath = "magic.cannonbow.fuseticks"; + + private static double maxMinForce = 1; + private static double minMinForce = 0; + private static double defaultMinForce = 0.2; + private static String minForcePath = "magic.cannonbow.minforce"; + + private static double maxRecoil = 20; + private static double minRecoil = -5; + private static double defaultRecoil = 1; + private static String recoilPath = "magic.cannonbow.recoil"; + + private static boolean defaultIsDestructive = false; + private static String isDestructivePath = "magic.cannonbow.isdestructive"; + + private static double speedMultiplier = defaultSpeedMultiplier; + private static double minForce = defaultMinForce; + private static int fuseTicks = defaultFuseTicks; + private static double recoil = defaultRecoil; + private static boolean isDestructive = defaultIsDestructive; + public final static String launchedTNTName = "CANNON BOW TNT:42170"; + + static FileConfiguration config; public CannonBowListener(JavaPlugin plugin){ - FileConfiguration config = plugin.getConfig(); - - if (config.isDouble("magic.cannonbow.speedmultiplier")) - setSpeedMultiplier(config.getDouble("magic.cannonbow.speedmultiplier")); - - if (config.isDouble("magic.cannonbow.minforce")) - setMinforce(config.getDouble("magic.cannonbow.minforce")); - - if (config.isInt("magic.cannonbow.fuseticks")) - setFuseticks(config.getInt("magic.cannonbow.fuseticks")); - - if (config.isDouble("magic.cannonbow.recoil")) - setRecoil(config.getDouble("magic.cannonbow.recoil")); + config = plugin.getConfig(); + + if (config.isDouble(speedMultiplierPath)) + setSpeedMultiplier(config.getDouble(speedMultiplierPath)); + + if (config.isDouble(minForcePath)) + setMinforce(config.getDouble(minForcePath)); + + if (config.isInt(fuseTicksPath)) + setFuseticks(config.getInt(fuseTicksPath)); + + if (config.isDouble(recoilPath)) + setRecoil(config.getDouble(recoilPath)); + + if (config.isBoolean(isDestructivePath)) + setIsDestructive(config.getBoolean(isDestructivePath)); } - + @EventHandler public void onProjectileLaunch(EntityShootBowEvent event){ //Entity Sanitation if(event.getProjectile().getType() != EntityType.ARROW)return; - + //Arrow Sanitation Arrow arrow = (Arrow) event.getProjectile(); if (!(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; - + //TNT Spawning Vector playerVector = player.getEyeLocation().getDirection().normalize(); + Location playerLocation = player.getLocation(); if (event.getForce() < getMinforce()){ - + //Smoke cloud if draw is too low - arrow.getWorld().spawnParticle(Particle.SMOKE_NORMAL, player.getLocation(), 30); - arrow.getWorld().playSound(player.getLocation(), Sound.BLOCK_LADDER_BREAK, 1.0F, -7); - + arrow.getWorld().spawnParticle(Particle.SMOKE_NORMAL, playerLocation, 30); + arrow.getWorld().playSound(playerLocation, Sound.BLOCK_LADDER_BREAK, 1.0F, -7); + }else{ //Spawn TNT TNTPrimed tnt = (TNTPrimed) arrow.getWorld().spawnEntity(arrow.getLocation(), EntityType.PRIMED_TNT); @@ -82,74 +115,135 @@ public class CannonBowListener implements Listener { } catch (Exception ex) { ex.printStackTrace(); }*/ - + // tnt.setVelocity(playerVector.multiply(getSpeedMultiplier()).multiply(event.getForce())); tnt.setCustomName(launchedTNTName); tnt.setFuseTicks(getFuseticks()); - + //Player Recoil - player.setVelocity(player.getEyeLocation().getDirection().normalize().multiply(-1).multiply(getRecoil())); - player.getWorld().playSound(player.getLocation(), Sound.ENTITY_GENERIC_EXPLODE, 1.0F, 0); - player.getWorld().spawnParticle(Particle.EXPLOSION_NORMAL, player.getLocation(), 2); - + player.setVelocity(playerVector.multiply(-1).multiply(getRecoil())); + player.getWorld().playSound(playerLocation, Sound.ENTITY_GENERIC_EXPLODE, 1.0F, 0); + player.getWorld().spawnParticle(Particle.EXPLOSION_NORMAL, playerLocation, 2); + } arrow.remove(); - - + + return; - + } @EventHandler public void onTnTExplode(EntityExplodeEvent event) { if (event.getEntityType() != EntityType.PRIMED_TNT) return; if (event.getEntity().getCustomName() != "CANNON BOW TNT:42170") return; - - Location loc = event.getEntity().getLocation(); - event.getEntity().getWorld().createExplosion(loc.getX(), loc.getY(), loc.getZ(), 3, false, false); - event.setCancelled(true); - - + + if (isDestructive == true){ + Location loc = event.getEntity().getLocation(); + event.getEntity().getWorld().createExplosion(loc.getX(), loc.getY(), loc.getZ(), 3, false, false); + event.setCancelled(true); + } + + } + public static double getSpeedMultiplier() { - return SpeedMultiplier; + return speedMultiplier; } - public static void setSpeedMultiplier(double speedMultiplier) { - if (speedMultiplier > 4) speedMultiplier = 4; - if (speedMultiplier < 0) speedMultiplier = 0; - SpeedMultiplier = speedMultiplier; + public static void setSpeedMultiplier(double multiplier, CommandSender sender){ + + if (multiplier > maxSpeedMultiplier) sender.sendMessage("SpeedMultiplier is too Large! Setting multiplier to "+ maxSpeedMultiplier); + if (multiplier < maxSpeedMultiplier) sender.sendMessage("SpeedMultiplier is too Small! Setting multiplier to "+ minSpeedMultiplier); + + setSpeedMultiplier(multiplier, sender); + sender.sendMessage("SpeedMultiplier set to " + getSpeedMultiplier()); } + public static void setSpeedMultiplier(double multiplier) { + + if (multiplier > maxSpeedMultiplier) multiplier = maxSpeedMultiplier; + if (multiplier < minSpeedMultiplier) multiplier = minSpeedMultiplier; + config.set(speedMultiplierPath, multiplier); + speedMultiplier = multiplier; + + } + + public static double getMinforce() { - return minforce; + return minForce; + } + public static void setMinForce(double minforce, CommandSender sender){ + + if (minforce > maxMinForce) sender.sendMessage("MinForce is too large! Setting it to " + maxMinForce); + if (minforce < minMinForce) sender.sendMessage("MinForce is too small! Setting it to " + minMinForce); + setMinforce(minforce); + sender.sendMessage("MinForce set to " + getMinforce()); + + } + public static void setMinforce(double minforce) { + + if (minforce > maxMinForce) minforce = maxMinForce; + if (minforce < minMinForce) minforce = minMinForce; + config.set(minForcePath, minforce); + CannonBowListener.minForce = minforce; } - public static void setMinforce(double minforce) { - if (minforce > 1) minforce = 1; - if (minforce < 0) minforce = 0; - CannonBowListener.minforce = minforce; - } public static int getFuseticks() { - return fuseticks; + return fuseTicks; + } + public static void setFuseticks(int fuseticks, CommandSender sender){ + + if (fuseticks > maxFuseTicks) sender.sendMessage("Fuseticks is too large! Setting it to " + maxFuseTicks); + if (fuseticks < minFuseTicks) sender.sendMessage("Fuseticks is too small! Setting it to " + minFuseTicks); + setFuseticks(fuseticks); + sender.sendMessage("FuseTicks set to " + getFuseticks()); + + } + public static void setFuseticks(int fuseticks) { + + if (fuseticks > maxFuseTicks) fuseticks = maxFuseTicks; + if (fuseticks < minFuseTicks) fuseticks = minFuseTicks; + config.set(fuseTicksPath, fuseticks); + CannonBowListener.fuseTicks = fuseticks; + } - public static void setFuseticks(int fuseticks) { - if (fuseticks > 400) fuseticks = 400; - if (fuseticks < 0) fuseticks = 0; - CannonBowListener.fuseticks = fuseticks; - } public static double getRecoil() { return recoil; } + public static void setRecoil(double recoil, CommandSender sender){ + if (recoil > maxRecoil) sender.sendMessage("Recoil is too large! Setting it to " + maxRecoil); + if (recoil < maxRecoil) sender.sendMessage("Recoil is too small! Setting it to " + minRecoil); + setRecoil(recoil); + sender.sendMessage("Recoil set to " + getRecoil()); + + } public static void setRecoil(double recoil) { - if (recoil > 20) recoil = 20; - if (recoil < 0) recoil = 0; + + if (recoil > maxRecoil) recoil = maxRecoil; + if (recoil < minRecoil) recoil = minRecoil; + config.set(recoilPath, recoil); CannonBowListener.recoil = recoil; + + } + + + public static boolean getIsDestructive(){ + return isDestructive; + } + public static void setIsDestructive(String input){ + if(input.startsWith("T") || input.startsWith("t")) setIsDestructive(true); + if(input.startsWith("F") || input.startsWith("f")) setIsDestructive(false); + + } + public static void setIsDestructive(boolean isDestructive){ + CannonBowListener.isDestructive = isDestructive; + config.set(speedMultiplierPath, isDestructive); } } \ No newline at end of file diff --git a/src/buttondevteam/alipresents/components/magic/tricks/CannonBowSettings.java b/src/buttondevteam/alipresents/components/magic/tricks/CannonBowSettings.java index 8aa8655..cbd7df4 100644 --- a/src/buttondevteam/alipresents/components/magic/tricks/CannonBowSettings.java +++ b/src/buttondevteam/alipresents/components/magic/tricks/CannonBowSettings.java @@ -9,25 +9,34 @@ public class CannonBowSettings extends ModCommand { @Override public boolean OnCommand(Player player, String alias, String[] args) { - if (args.length > 1){ + if (args.length > 1 && args[0] == "display"){ switch(args[0].toLowerCase()){ + case "force": case "speedmultiplier": CannonBowListener.setSpeedMultiplier(NumberUtils.toDouble(args[1], CannonBowListener.getSpeedMultiplier())); break; + case "minimumforce": case "minforce": + case "minimumdraw": + case "mindraw": CannonBowListener.setMinforce(NumberUtils.toDouble(args[1], CannonBowListener.getMinforce())); break; + case "fuse": + case "fusetick": case "fuseticks": CannonBowListener.setFuseticks(NumberUtils.toInt(args[1], CannonBowListener.getFuseticks())); break; case "recoil": CannonBowListener.setRecoil(NumberUtils.toDouble((args[1]), CannonBowListener.getRecoil())); break; + case "isDestructive": + CannonBowListener.setIsDestructive(args[1]); case "display": player.sendMessage("Speed Multiplier: "+CannonBowListener.getSpeedMultiplier()); player.sendMessage("Minimum Force: "+CannonBowListener.getMinforce()); player.sendMessage("Fuseticks: " + CannonBowListener.getFuseticks()); player.sendMessage("Recoil: " + CannonBowListener.getRecoil()); + player.sendMessage("isDestructive: " + CannonBowListener.getIsDestructive()); break; default: player.sendMessage("That isn't a valid setting!"); -- 2.30.2