Got Dungeon teleporting set up and working

This commit is contained in:
alisolarflare 2016-12-22 21:31:36 -05:00
parent c06f19d6e4
commit 1d3471f099
10 changed files with 116 additions and 22 deletions

View file

@ -1,5 +0,0 @@
UHCMatchState: "IDLE"
magic:
cannonbow:
speedmultiplier: 1.5
minforce: 0.2

View file

@ -7,6 +7,8 @@ commands:
description: creates wireless redstone description: creates wireless redstone
cb: cb:
description: creates creative boundaries description: creates creative boundaries
dungeons:
description: handles the resource dungeons scattered around the map
debug: debug:
description: debug commands description: debug commands
flaircolour: flaircolour:

View file

@ -3,8 +3,11 @@ package buttondevteam.alipresents.components.dungeons;
import org.bukkit.plugin.java.JavaPlugin; import org.bukkit.plugin.java.JavaPlugin;
import buttondevteam.alipresents.architecture.Component; 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.Enter;
import buttondevteam.alipresents.components.dungeons.commands.Exit; 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; import buttondevteam.alipresents.components.dungeons.dungeons.GenericDungeonA1;
public class DungeonComponent extends Component { public class DungeonComponent extends Component {
@ -12,9 +15,12 @@ public class DungeonComponent extends Component {
@Override @Override
public void register(JavaPlugin plugin) { public void register(JavaPlugin plugin) {
dungeonA1 = new GenericDungeonA1(plugin); dungeonA1 = new GenericDungeonA1(plugin);
registerCommand(plugin, new DisplayDebug(this));
registerCommand(plugin, new Enter(this)); registerCommand(plugin, new Enter(this));
registerCommand(plugin, new Exit(this)); registerCommand(plugin, new Exit(this));
registerCommand(plugin, new SetEntrance(this));
registerCommand(plugin, new SetExit(this));
} }
} }

View file

@ -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";
}
}

View file

@ -13,11 +13,11 @@ public class Enter extends ModCommand{
@Override @Override
public boolean OnCommand(Player player, String alias, String[] args) { public boolean OnCommand(Player player, String alias, String[] args) {
component.dungeonA1.enterDungeon(player); component.dungeonA1.enterDungeon(player);
return false; return true;
} }
@Override @Override
public String GetCommandPath(){ public String GetCommandPath(){
return "dungeon enter"; return "dungeons enter";
} }
} }

View file

@ -14,10 +14,11 @@ public class Exit extends PlayerCommand {
@Override @Override
public boolean OnCommand(Player player, String alias, String[] args) { public boolean OnCommand(Player player, String alias, String[] args) {
component.dungeonA1.exitDungeon(player); component.dungeonA1.exitDungeon(player);
return false; return true;
} }
public String getCommandPath(){ @Override
return "dungeon exit"; public String GetCommandPath(){
return "dungeons exit";
} }
} }

View file

@ -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";
}
}

View file

@ -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";
}
}

View file

@ -8,6 +8,8 @@ import org.bukkit.entity.Player;
public abstract class Dungeon { public abstract class Dungeon {
public abstract Location getDungeonEntrance(); public abstract Location getDungeonEntrance();
public abstract Location getDungeonExit(); public abstract Location getDungeonExit();
public abstract void setEntrance(Location location);
public abstract void setExit(Location location);
public boolean enterDungeon(Player player){ public boolean enterDungeon(Player player){
if (getDungeonEntrance() == null){ if (getDungeonEntrance() == null){

View file

@ -4,13 +4,15 @@ import org.bukkit.Location;
import org.bukkit.plugin.java.JavaPlugin; import org.bukkit.plugin.java.JavaPlugin;
public class GenericDungeonA1 extends Dungeon{ public class GenericDungeonA1 extends Dungeon{
private Location dungeonEntrance; private Location entrance;
private Location dungeonExit; private Location exit;
private JavaPlugin plugin;
public GenericDungeonA1(JavaPlugin plugin){ public GenericDungeonA1(JavaPlugin plugin){
if(!initDungeon(plugin)){ if(!initDungeon(plugin)){
plugin.getServer().broadcastMessage("DungeonA1 cant be initialized!"); plugin.getServer().broadcastMessage("DungeonA1 cant be initialized!");
} }
this.plugin = plugin;
} }
private boolean initDungeon(JavaPlugin plugin){ private boolean initDungeon(JavaPlugin plugin){
if (plugin.getServer().getWorld("Dungeons") == null || plugin.getServer().getWorld("world") == null){ if (plugin.getServer().getWorld("Dungeons") == null || plugin.getServer().getWorld("world") == null){
@ -19,27 +21,32 @@ public class GenericDungeonA1 extends Dungeon{
return false; return false;
} }
dungeonEntrance = new Location(plugin.getServer().getWorld("Dungeons"), -7.5, 138.0, -91.5); entrance = new Location(plugin.getServer().getWorld("Dungeons"), -7.5, 138.0, -91.5);
dungeonExit = plugin.getServer().getWorld("world").getSpawnLocation().clone(); 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("DungeonA1Error! Dungeon Entrance or Exit is null!");
plugin.getServer().broadcastMessage("DungeonEnterance: " + dungeonEntrance.toString()); plugin.getServer().broadcastMessage("Dungeon Entrance: " + entrance.toString());
plugin.getServer().broadcastMessage("Dungeon Exit: " + dungeonExit.toString()); plugin.getServer().broadcastMessage("Dungeon Exit: " + exit.toString());
return false; return false;
} }
return true; return true;
} }
public void setDungeonEnterance(Location location){ public void setEntrance(Location location){
dungeonEntrance = location; plugin.getConfig().set("dungeons.dungeona1.entrance", entrance);
plugin.saveConfig();
entrance = location;
}
public void setExit(Location location){
exit = location;
} }
@Override @Override
public Location getDungeonEntrance() { public Location getDungeonEntrance() {
return dungeonEntrance; return entrance;
} }
@Override @Override
public Location getDungeonExit() { public Location getDungeonExit() {
return dungeonExit; return exit;
} }
} }