Started Work on Dungeons #43
1 changed files with 35 additions and 6 deletions
|
@ -1,6 +1,7 @@
|
||||||
package buttondevteam.alipresents.components.dungeons.dungeons;
|
package buttondevteam.alipresents.components.dungeons.dungeons;
|
||||||
|
|
||||||
import org.bukkit.Location;
|
import org.bukkit.Location;
|
||||||
|
import org.bukkit.World;
|
||||||
import org.bukkit.plugin.java.JavaPlugin;
|
import org.bukkit.plugin.java.JavaPlugin;
|
||||||
|
|
||||||
public class GenericDungeonA1 extends Dungeon{
|
public class GenericDungeonA1 extends Dungeon{
|
||||||
|
@ -15,14 +16,22 @@ public class GenericDungeonA1 extends Dungeon{
|
||||||
this.plugin = plugin;
|
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){
|
||||||
plugin.getServer().broadcastMessage("GenericDungeonA1Error! One of the worlds is null!");
|
plugin.getServer().broadcastMessage("GenericDungeonA1Error! One of the worlds is null!");
|
||||||
plugin.getServer().broadcastMessage("Available Worlds... " + plugin.getServer().getWorlds().toString());
|
plugin.getServer().broadcastMessage("Available Worlds... " + plugin.getServer().getWorlds().toString());
|
||||||
return false;
|
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);
|
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();
|
exit = plugin.getServer().getWorld("world").getSpawnLocation().clone();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
if (entrance == null || exit == 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!");
|
||||||
|
@ -32,12 +41,14 @@ public class GenericDungeonA1 extends Dungeon{
|
||||||
}
|
}
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
@Override
|
||||||
public void setEntrance(Location location){
|
public void setEntrance(Location location){
|
||||||
plugin.getConfig().set("dungeons.dungeona1.entrance", entrance);
|
saveLocation(plugin, "dungeons.dungeona1.enter", location);
|
||||||
plugin.saveConfig();
|
|
||||||
entrance = location;
|
entrance = location;
|
||||||
}
|
}
|
||||||
|
@Override
|
||||||
public void setExit(Location location){
|
public void setExit(Location location){
|
||||||
|
saveLocation(plugin, "dungeons.dungeona1.exit", location);
|
||||||
exit = location;
|
exit = location;
|
||||||
}
|
}
|
||||||
@Override
|
@Override
|
||||||
|
@ -48,5 +59,23 @@ public class GenericDungeonA1 extends Dungeon{
|
||||||
public Location getDungeonExit() {
|
public Location getDungeonExit() {
|
||||||
return exit;
|
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;
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue