mirror of
https://github.com/DRE2N/DungeonsXL.git
synced 2025-02-17 21:02:12 +01:00
Fixed: Closed file streams after reading
This commit is contained in:
parent
e8fa5b2ee7
commit
3cf96c5f25
@ -39,65 +39,65 @@ import com.dre.dungeonsxl.listener.PlayerListener;
|
|||||||
|
|
||||||
public class DungeonsXL extends JavaPlugin{
|
public class DungeonsXL extends JavaPlugin{
|
||||||
public static DungeonsXL p;
|
public static DungeonsXL p;
|
||||||
|
|
||||||
//Listener
|
//Listener
|
||||||
private static Listener entitylistener;
|
private static Listener entitylistener;
|
||||||
private static Listener playerlistener;
|
private static Listener playerlistener;
|
||||||
private static Listener blocklistener;
|
private static Listener blocklistener;
|
||||||
|
|
||||||
//Main Config Reader
|
//Main Config Reader
|
||||||
public ConfigReader mainConfig;
|
public ConfigReader mainConfig;
|
||||||
|
|
||||||
//Tutorial
|
//Tutorial
|
||||||
public String tutorialDungeon;
|
public String tutorialDungeon;
|
||||||
public String tutorialStartGroup;
|
public String tutorialStartGroup;
|
||||||
public String tutorialEndGroup;
|
public String tutorialEndGroup;
|
||||||
|
|
||||||
//Chatspyer
|
//Chatspyer
|
||||||
public CopyOnWriteArrayList<Player> chatSpyer=new CopyOnWriteArrayList<Player>();
|
public CopyOnWriteArrayList<Player> chatSpyer=new CopyOnWriteArrayList<Player>();
|
||||||
|
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void onEnable(){
|
public void onEnable(){
|
||||||
p=this;
|
p=this;
|
||||||
|
|
||||||
//Commands
|
//Commands
|
||||||
getCommand("dungeonsxl").setExecutor(new CommandListener());
|
getCommand("dungeonsxl").setExecutor(new CommandListener());
|
||||||
|
|
||||||
//MSG
|
//MSG
|
||||||
this.log(this.getDescription().getName()+" enabled!");
|
this.log(this.getDescription().getName()+" enabled!");
|
||||||
|
|
||||||
//Init Classes
|
//Init Classes
|
||||||
new DCommandRoot();
|
new DCommandRoot();
|
||||||
|
|
||||||
//InitFolders
|
//InitFolders
|
||||||
this.initFolders();
|
this.initFolders();
|
||||||
|
|
||||||
//Setup Permissions
|
//Setup Permissions
|
||||||
this.setupPermissions();
|
this.setupPermissions();
|
||||||
|
|
||||||
//Listener
|
//Listener
|
||||||
entitylistener=new EntityListener();
|
entitylistener=new EntityListener();
|
||||||
playerlistener=new PlayerListener();
|
playerlistener=new PlayerListener();
|
||||||
blocklistener=new BlockListener();
|
blocklistener=new BlockListener();
|
||||||
|
|
||||||
Bukkit.getServer().getPluginManager().registerEvents(entitylistener,this);
|
Bukkit.getServer().getPluginManager().registerEvents(entitylistener,this);
|
||||||
Bukkit.getServer().getPluginManager().registerEvents(playerlistener,this);
|
Bukkit.getServer().getPluginManager().registerEvents(playerlistener,this);
|
||||||
Bukkit.getServer().getPluginManager().registerEvents(blocklistener,this);
|
Bukkit.getServer().getPluginManager().registerEvents(blocklistener,this);
|
||||||
|
|
||||||
//Load All
|
//Load All
|
||||||
this.loadAll();
|
this.loadAll();
|
||||||
|
|
||||||
//Load Config
|
//Load Config
|
||||||
mainConfig=new ConfigReader(new File(p.getDataFolder(), "config.yml"));
|
mainConfig=new ConfigReader(new File(p.getDataFolder(), "config.yml"));
|
||||||
|
|
||||||
//Load MobTypes
|
//Load MobTypes
|
||||||
DMobType.load(new File(p.getDataFolder(), "mobs.yml"));
|
DMobType.load(new File(p.getDataFolder(), "mobs.yml"));
|
||||||
|
|
||||||
// -------------------------------------------- //
|
// -------------------------------------------- //
|
||||||
// Update Sheduler
|
// Update Sheduler
|
||||||
// -------------------------------------------- //
|
// -------------------------------------------- //
|
||||||
|
|
||||||
p.getServer().getScheduler().scheduleSyncRepeatingTask(p, new Runnable() {
|
p.getServer().getScheduler().scheduleSyncRepeatingTask(p, new Runnable() {
|
||||||
public void run() {
|
public void run() {
|
||||||
for(GameWorld gworld:GameWorld.gworlds){
|
for(GameWorld gworld:GameWorld.gworlds){
|
||||||
@ -109,13 +109,13 @@ public class DungeonsXL extends JavaPlugin{
|
|||||||
}
|
}
|
||||||
for(EditWorld eworld:EditWorld.eworlds){
|
for(EditWorld eworld:EditWorld.eworlds){
|
||||||
if(eworld.world.getPlayers().isEmpty()){
|
if(eworld.world.getPlayers().isEmpty()){
|
||||||
|
|
||||||
eworld.delete();
|
eworld.delete();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}, 0L, 1200L);
|
}, 0L, 1200L);
|
||||||
|
|
||||||
p.getServer().getScheduler().scheduleSyncRepeatingTask(p, new Runnable() {
|
p.getServer().getScheduler().scheduleSyncRepeatingTask(p, new Runnable() {
|
||||||
public void run() {
|
public void run() {
|
||||||
MobSpawner.updateAll();
|
MobSpawner.updateAll();
|
||||||
@ -123,7 +123,7 @@ public class DungeonsXL extends JavaPlugin{
|
|||||||
GameMessage.updateAll();
|
GameMessage.updateAll();
|
||||||
GameCheckpoint.update();
|
GameCheckpoint.update();
|
||||||
DPlayer.update(true);
|
DPlayer.update(true);
|
||||||
|
|
||||||
//Tutorial Mode
|
//Tutorial Mode
|
||||||
for(Player player:p.getServer().getOnlinePlayers()){
|
for(Player player:p.getServer().getOnlinePlayers()){
|
||||||
if(DPlayer.get(player)==null){
|
if(DPlayer.get(player)==null){
|
||||||
@ -151,39 +151,39 @@ public class DungeonsXL extends JavaPlugin{
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
}, 0L, 20L);
|
}, 0L, 20L);
|
||||||
|
|
||||||
p.getServer().getScheduler().scheduleSyncRepeatingTask(p, new Runnable() {
|
p.getServer().getScheduler().scheduleSyncRepeatingTask(p, new Runnable() {
|
||||||
public void run() {
|
public void run() {
|
||||||
DPlayer.update(false);
|
DPlayer.update(false);
|
||||||
}
|
}
|
||||||
}, 0L, 2L);
|
}, 0L, 2L);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void onDisable(){
|
public void onDisable(){
|
||||||
//Save
|
//Save
|
||||||
this.saveAll();
|
this.saveAll();
|
||||||
|
|
||||||
//MSG
|
//MSG
|
||||||
this.log(this.getDescription().getName()+" disabled!");
|
this.log(this.getDescription().getName()+" disabled!");
|
||||||
|
|
||||||
//DPlayer leaves World
|
//DPlayer leaves World
|
||||||
for(DPlayer dplayer:DPlayer.players){
|
for(DPlayer dplayer:DPlayer.players){
|
||||||
dplayer.leave();
|
dplayer.leave();
|
||||||
}
|
}
|
||||||
|
|
||||||
//Delete all Data
|
//Delete all Data
|
||||||
DPortal.portals.clear();
|
DPortal.portals.clear();
|
||||||
DGSign.dgsigns.clear();
|
DGSign.dgsigns.clear();
|
||||||
LeaveSign.lsigns.clear();
|
LeaveSign.lsigns.clear();
|
||||||
|
|
||||||
//Delete Worlds
|
//Delete Worlds
|
||||||
GameWorld.deleteAll();
|
GameWorld.deleteAll();
|
||||||
EditWorld.deleteAll();
|
EditWorld.deleteAll();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
//Init.
|
//Init.
|
||||||
public void initFolders(){
|
public void initFolders(){
|
||||||
//Check Folder
|
//Check Folder
|
||||||
@ -191,14 +191,14 @@ public class DungeonsXL extends JavaPlugin{
|
|||||||
if(!folder.exists()){
|
if(!folder.exists()){
|
||||||
folder.mkdir();
|
folder.mkdir();
|
||||||
}
|
}
|
||||||
|
|
||||||
folder = new File(this.getDataFolder()+File.separator+"dungeons");
|
folder = new File(this.getDataFolder()+File.separator+"dungeons");
|
||||||
if(!folder.exists()){
|
if(!folder.exists()){
|
||||||
folder.mkdir();
|
folder.mkdir();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
//Permissions
|
//Permissions
|
||||||
public Permission permission = null;
|
public Permission permission = null;
|
||||||
|
|
||||||
@ -210,28 +210,28 @@ public class DungeonsXL extends JavaPlugin{
|
|||||||
}
|
}
|
||||||
return (permission != null);
|
return (permission != null);
|
||||||
}
|
}
|
||||||
|
|
||||||
public Boolean GroupEnabled(String group){
|
public Boolean GroupEnabled(String group){
|
||||||
|
|
||||||
for(String agroup:permission.getGroups()){
|
for(String agroup:permission.getGroups()){
|
||||||
if(agroup.equalsIgnoreCase(group)){
|
if(agroup.equalsIgnoreCase(group)){
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
//Save and Load
|
//Save and Load
|
||||||
public void saveAll(){
|
public void saveAll(){
|
||||||
File file = new File(this.getDataFolder(), "data.yml");
|
File file = new File(this.getDataFolder(), "data.yml");
|
||||||
FileConfiguration configFile = new YamlConfiguration();
|
FileConfiguration configFile = new YamlConfiguration();
|
||||||
|
|
||||||
DPortal.save(configFile);
|
DPortal.save(configFile);
|
||||||
DGSign.save(configFile);
|
DGSign.save(configFile);
|
||||||
LeaveSign.save(configFile);
|
LeaveSign.save(configFile);
|
||||||
|
|
||||||
try {
|
try {
|
||||||
configFile.save(file);
|
configFile.save(file);
|
||||||
} catch (IOException e) {
|
} catch (IOException e) {
|
||||||
@ -239,18 +239,18 @@ public class DungeonsXL extends JavaPlugin{
|
|||||||
e.printStackTrace();
|
e.printStackTrace();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
public void loadAll(){
|
public void loadAll(){
|
||||||
File file = new File(this.getDataFolder(), "data.yml");
|
File file = new File(this.getDataFolder(), "data.yml");
|
||||||
FileConfiguration configFile = YamlConfiguration.loadConfiguration(file);
|
FileConfiguration configFile = YamlConfiguration.loadConfiguration(file);
|
||||||
|
|
||||||
DPortal.load(configFile);
|
DPortal.load(configFile);
|
||||||
DGSign.load(configFile);
|
DGSign.load(configFile);
|
||||||
LeaveSign.load(configFile);
|
LeaveSign.load(configFile);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
//File Control
|
//File Control
|
||||||
public boolean removeDirectory(File directory) {
|
public boolean removeDirectory(File directory) {
|
||||||
if (directory.isDirectory()) {
|
if (directory.isDirectory()) {
|
||||||
@ -260,32 +260,34 @@ public class DungeonsXL extends JavaPlugin{
|
|||||||
}
|
}
|
||||||
return directory.delete();
|
return directory.delete();
|
||||||
}
|
}
|
||||||
|
|
||||||
public void copyFile(File in, File out) throws IOException {
|
public void copyFile(File in, File out) throws IOException {
|
||||||
FileChannel inChannel = new FileInputStream(in).getChannel();
|
FileChannel inChannel=null;
|
||||||
FileChannel outChannel = new FileOutputStream(out).getChannel();
|
FileChannel outChannel=null;
|
||||||
try {
|
try {
|
||||||
inChannel.transferTo(0, inChannel.size(), outChannel);
|
inChannel = new FileInputStream(in).getChannel();
|
||||||
} catch (IOException e) {
|
outChannel = new FileOutputStream(out).getChannel();
|
||||||
throw e;
|
inChannel.transferTo(0, inChannel.size(), outChannel);
|
||||||
} finally {
|
} catch (IOException e) {
|
||||||
if (inChannel != null)
|
throw e;
|
||||||
inChannel.close();
|
} finally {
|
||||||
if (outChannel != null)
|
if (inChannel != null)
|
||||||
outChannel.close();
|
inChannel.close();
|
||||||
}
|
if (outChannel != null)
|
||||||
}
|
outChannel.close();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
public String[] excludedFiles={"config.yml"};
|
public String[] excludedFiles={"config.yml"};
|
||||||
|
|
||||||
public void copyDirectory(File sourceLocation, File targetLocation) {
|
public void copyDirectory(File sourceLocation, File targetLocation) {
|
||||||
|
|
||||||
if (sourceLocation.isDirectory()) {
|
if (sourceLocation.isDirectory()) {
|
||||||
|
|
||||||
if (!targetLocation.exists()) {
|
if (!targetLocation.exists()) {
|
||||||
targetLocation.mkdir();
|
targetLocation.mkdir();
|
||||||
}
|
}
|
||||||
|
|
||||||
String[] children = sourceLocation.list();
|
String[] children = sourceLocation.list();
|
||||||
for (int i = 0; i < children.length; i++) {
|
for (int i = 0; i < children.length; i++) {
|
||||||
boolean isOk=true;
|
boolean isOk=true;
|
||||||
@ -299,25 +301,25 @@ public class DungeonsXL extends JavaPlugin{
|
|||||||
copyDirectory(new File(sourceLocation, children[i]), new File(
|
copyDirectory(new File(sourceLocation, children[i]), new File(
|
||||||
targetLocation, children[i]));
|
targetLocation, children[i]));
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
|
|
||||||
try {
|
try {
|
||||||
|
|
||||||
if (!targetLocation.getParentFile().exists()) {
|
if (!targetLocation.getParentFile().exists()) {
|
||||||
|
|
||||||
createDirectory(targetLocation.getParentFile().getAbsolutePath());
|
createDirectory(targetLocation.getParentFile().getAbsolutePath());
|
||||||
targetLocation.createNewFile();
|
targetLocation.createNewFile();
|
||||||
|
|
||||||
} else if (!targetLocation.exists()) {
|
} else if (!targetLocation.exists()) {
|
||||||
|
|
||||||
targetLocation.createNewFile();
|
targetLocation.createNewFile();
|
||||||
}
|
}
|
||||||
|
|
||||||
InputStream in = new FileInputStream(sourceLocation);
|
InputStream in = new FileInputStream(sourceLocation);
|
||||||
OutputStream out = new FileOutputStream(targetLocation);
|
OutputStream out = new FileOutputStream(targetLocation);
|
||||||
|
|
||||||
byte[] buf = new byte[1024];
|
byte[] buf = new byte[1024];
|
||||||
int len;
|
int len;
|
||||||
while ((len = in.read(buf)) > 0) {
|
while ((len = in.read(buf)) > 0) {
|
||||||
@ -325,9 +327,9 @@ public class DungeonsXL extends JavaPlugin{
|
|||||||
}
|
}
|
||||||
in.close();
|
in.close();
|
||||||
out.close();
|
out.close();
|
||||||
|
|
||||||
} catch (Exception e) {
|
} catch (Exception e) {
|
||||||
|
|
||||||
if (e.getMessage().contains("Zugriff")
|
if (e.getMessage().contains("Zugriff")
|
||||||
|| e.getMessage().contains("Access"))
|
|| e.getMessage().contains("Access"))
|
||||||
DungeonsXL.p.log("Error: " + e.getMessage() + " // Access denied");
|
DungeonsXL.p.log("Error: " + e.getMessage() + " // Access denied");
|
||||||
@ -336,17 +338,17 @@ public class DungeonsXL extends JavaPlugin{
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public void createDirectory(String s) {
|
public void createDirectory(String s) {
|
||||||
|
|
||||||
if (!new File(s).getParentFile().exists()) {
|
if (!new File(s).getParentFile().exists()) {
|
||||||
|
|
||||||
createDirectory(new File(s).getParent());
|
createDirectory(new File(s).getParent());
|
||||||
}
|
}
|
||||||
|
|
||||||
new File(s).mkdir();
|
new File(s).mkdir();
|
||||||
}
|
}
|
||||||
|
|
||||||
public void deletenotusingfiles(File directory){
|
public void deletenotusingfiles(File directory){
|
||||||
File[] files=directory.listFiles();
|
File[] files=directory.listFiles();
|
||||||
for(File file:files){
|
for(File file:files){
|
||||||
@ -355,7 +357,7 @@ public class DungeonsXL extends JavaPlugin{
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
//Misc
|
//Misc
|
||||||
public void updateInventory(Player p) {
|
public void updateInventory(Player p) {
|
||||||
CraftPlayer c = (CraftPlayer) p;
|
CraftPlayer c = (CraftPlayer) p;
|
||||||
@ -378,34 +380,34 @@ public class DungeonsXL extends JavaPlugin{
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
//Msg
|
//Msg
|
||||||
|
|
||||||
public void msg(Player player,String msg){
|
public void msg(Player player,String msg){
|
||||||
player.sendMessage(ChatColor.DARK_GREEN+"[DXL] "+ChatColor.WHITE+msg);
|
player.sendMessage(ChatColor.DARK_GREEN+"[DXL] "+ChatColor.WHITE+msg);
|
||||||
}
|
}
|
||||||
|
|
||||||
public void msg(Player player,String msg, boolean zusatz){
|
public void msg(Player player,String msg, boolean zusatz){
|
||||||
if(zusatz){
|
if(zusatz){
|
||||||
player.sendMessage(ChatColor.DARK_GREEN+"[DXL]"+ChatColor.WHITE+msg);
|
player.sendMessage(ChatColor.DARK_GREEN+"[DXL]"+ChatColor.WHITE+msg);
|
||||||
}else{
|
}else{
|
||||||
player.sendMessage(ChatColor.WHITE+msg);
|
player.sendMessage(ChatColor.WHITE+msg);
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
//Misc.
|
//Misc.
|
||||||
|
|
||||||
public EntityType getEntitiyType(String name){
|
public EntityType getEntitiyType(String name){
|
||||||
for(EntityType type:EntityType.values()){
|
for(EntityType type:EntityType.values()){
|
||||||
if(name.equalsIgnoreCase(type.getName())){
|
if(name.equalsIgnoreCase(type.getName())){
|
||||||
return type;
|
return type;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
|
||||||
// -------------------------------------------- //
|
// -------------------------------------------- //
|
||||||
// LOGGING
|
// LOGGING
|
||||||
// -------------------------------------------- //
|
// -------------------------------------------- //
|
||||||
@ -418,5 +420,5 @@ public class DungeonsXL extends JavaPlugin{
|
|||||||
{
|
{
|
||||||
Logger.getLogger("Minecraft").log(level, "["+this.getDescription().getFullName()+"] "+msg);
|
Logger.getLogger("Minecraft").log(level, "["+this.getDescription().getFullName()+"] "+msg);
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
@ -20,7 +20,7 @@ import org.bukkit.entity.Player;
|
|||||||
public class EditWorld {
|
public class EditWorld {
|
||||||
private static DungeonsXL p=DungeonsXL.p;
|
private static DungeonsXL p=DungeonsXL.p;
|
||||||
public static CopyOnWriteArrayList<EditWorld> eworlds=new CopyOnWriteArrayList<EditWorld>();
|
public static CopyOnWriteArrayList<EditWorld> eworlds=new CopyOnWriteArrayList<EditWorld>();
|
||||||
|
|
||||||
//Variables
|
//Variables
|
||||||
public World world;
|
public World world;
|
||||||
public String owner;
|
public String owner;
|
||||||
@ -30,10 +30,10 @@ public class EditWorld {
|
|||||||
public Location lobby;
|
public Location lobby;
|
||||||
public CopyOnWriteArrayList<String> invitedPlayers=new CopyOnWriteArrayList<String>();
|
public CopyOnWriteArrayList<String> invitedPlayers=new CopyOnWriteArrayList<String>();
|
||||||
public CopyOnWriteArrayList<Block> sign=new CopyOnWriteArrayList<Block>();
|
public CopyOnWriteArrayList<Block> sign=new CopyOnWriteArrayList<Block>();
|
||||||
|
|
||||||
public EditWorld(){
|
public EditWorld(){
|
||||||
eworlds.add(this);
|
eworlds.add(this);
|
||||||
|
|
||||||
//ID
|
//ID
|
||||||
this.id=-1;
|
this.id=-1;
|
||||||
int i=-1;
|
int i=-1;
|
||||||
@ -48,7 +48,7 @@ public class EditWorld {
|
|||||||
}
|
}
|
||||||
if(!exist) this.id=i;
|
if(!exist) this.id=i;
|
||||||
}
|
}
|
||||||
|
|
||||||
name="DXL_Edit_"+this.id;
|
name="DXL_Edit_"+this.id;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -56,7 +56,7 @@ public class EditWorld {
|
|||||||
WorldCreator creator=WorldCreator.name(name);
|
WorldCreator creator=WorldCreator.name(name);
|
||||||
creator.type(WorldType.FLAT);
|
creator.type(WorldType.FLAT);
|
||||||
creator.generateStructures(false);
|
creator.generateStructures(false);
|
||||||
|
|
||||||
this.world=p.getServer().createWorld(creator);
|
this.world=p.getServer().createWorld(creator);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -73,7 +73,7 @@ public class EditWorld {
|
|||||||
out.writeInt(sign.getZ());
|
out.writeInt(sign.getZ());
|
||||||
}
|
}
|
||||||
out.close();
|
out.close();
|
||||||
|
|
||||||
} catch (FileNotFoundException e) {
|
} catch (FileNotFoundException e) {
|
||||||
// TODO Auto-generated catch block
|
// TODO Auto-generated catch block
|
||||||
e.printStackTrace();
|
e.printStackTrace();
|
||||||
@ -81,7 +81,7 @@ public class EditWorld {
|
|||||||
// TODO Auto-generated catch block
|
// TODO Auto-generated catch block
|
||||||
e.printStackTrace();
|
e.printStackTrace();
|
||||||
}
|
}
|
||||||
|
|
||||||
//Check Configuration
|
//Check Configuration
|
||||||
/*File file=new File("plugins/DungeonsXL/dungeons/"+this.dungeonname+"/config.yml");
|
/*File file=new File("plugins/DungeonsXL/dungeons/"+this.dungeonname+"/config.yml");
|
||||||
if(!file.exists()){
|
if(!file.exists()){
|
||||||
@ -100,32 +100,32 @@ public class EditWorld {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
}*/
|
}*/
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public void checkSign(Block block){
|
public void checkSign(Block block){
|
||||||
if((block.getState() instanceof Sign)){
|
if((block.getState() instanceof Sign)){
|
||||||
Sign sign = (Sign) block.getState();
|
Sign sign = (Sign) block.getState();
|
||||||
String[] lines=sign.getLines();
|
String[] lines=sign.getLines();
|
||||||
|
|
||||||
if(lines[1].equalsIgnoreCase("lobby")){
|
if(lines[1].equalsIgnoreCase("lobby")){
|
||||||
this.lobby=block.getLocation();
|
this.lobby=block.getLocation();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public void delete(){
|
public void delete(){
|
||||||
eworlds.remove(this);
|
eworlds.remove(this);
|
||||||
for(Player player:this.world.getPlayers()){
|
for(Player player:this.world.getPlayers()){
|
||||||
DPlayer dplayer=DPlayer.get(player);
|
DPlayer dplayer=DPlayer.get(player);
|
||||||
dplayer.leave();
|
dplayer.leave();
|
||||||
}
|
}
|
||||||
|
|
||||||
p.getServer().unloadWorld(this.world,true);
|
p.getServer().unloadWorld(this.world,true);
|
||||||
File dir = new File("DXL_Edit_"+this.id);
|
File dir = new File("DXL_Edit_"+this.id);
|
||||||
p.removeDirectory(dir);
|
p.removeDirectory(dir);
|
||||||
}
|
}
|
||||||
|
|
||||||
//Static
|
//Static
|
||||||
public static EditWorld get(World world){
|
public static EditWorld get(World world){
|
||||||
for(EditWorld eworld:eworlds){
|
for(EditWorld eworld:eworlds){
|
||||||
@ -133,20 +133,20 @@ public class EditWorld {
|
|||||||
return eworld;
|
return eworld;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
|
||||||
public static EditWorld get(String name){
|
public static EditWorld get(String name){
|
||||||
for(EditWorld eworld:eworlds){
|
for(EditWorld eworld:eworlds){
|
||||||
if(eworld.name.equalsIgnoreCase(name)){
|
if(eworld.name.equalsIgnoreCase(name)){
|
||||||
return eworld;
|
return eworld;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
|
||||||
public static void deleteAll(){
|
public static void deleteAll(){
|
||||||
for(EditWorld eworld:eworlds){
|
for(EditWorld eworld:eworlds){
|
||||||
eworlds.remove(eworld);
|
eworlds.remove(eworld);
|
||||||
@ -154,31 +154,31 @@ public class EditWorld {
|
|||||||
DPlayer dplayer=DPlayer.get(player);
|
DPlayer dplayer=DPlayer.get(player);
|
||||||
dplayer.leave();
|
dplayer.leave();
|
||||||
}
|
}
|
||||||
|
|
||||||
p.getServer().unloadWorld(eworld.world,true);
|
p.getServer().unloadWorld(eworld.world,true);
|
||||||
File dir = new File("DXL_Edit_"+eworld.id);
|
File dir = new File("DXL_Edit_"+eworld.id);
|
||||||
p.removeDirectory(dir);
|
p.removeDirectory(dir);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public static EditWorld load(String name){
|
public static EditWorld load(String name){
|
||||||
for(EditWorld eworld:eworlds){
|
for(EditWorld eworld:eworlds){
|
||||||
|
|
||||||
if(eworld.dungeonname.equalsIgnoreCase(name)){
|
if(eworld.dungeonname.equalsIgnoreCase(name)){
|
||||||
return eworld;
|
return eworld;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
File file=new File("plugins/DungeonsXL/dungeons/"+name);
|
File file=new File("plugins/DungeonsXL/dungeons/"+name);
|
||||||
|
|
||||||
if(file.exists()){
|
if(file.exists()){
|
||||||
EditWorld eworld = new EditWorld();
|
EditWorld eworld = new EditWorld();
|
||||||
eworld.dungeonname=name;
|
eworld.dungeonname=name;
|
||||||
//World
|
//World
|
||||||
p.copyDirectory(file,new File("DXL_Edit_"+eworld.id));
|
p.copyDirectory(file,new File("DXL_Edit_"+eworld.id));
|
||||||
|
|
||||||
eworld.world=p.getServer().createWorld(WorldCreator.name("DXL_Edit_"+eworld.id));
|
eworld.world=p.getServer().createWorld(WorldCreator.name("DXL_Edit_"+eworld.id));
|
||||||
|
|
||||||
try {
|
try {
|
||||||
ObjectInputStream os=new ObjectInputStream(new FileInputStream(new File("plugins/DungeonsXL/dungeons/"+eworld.dungeonname+"/DXLData.data")));
|
ObjectInputStream os=new ObjectInputStream(new FileInputStream(new File("plugins/DungeonsXL/dungeons/"+eworld.dungeonname+"/DXLData.data")));
|
||||||
int length=os.readInt();
|
int length=os.readInt();
|
||||||
@ -190,7 +190,8 @@ public class EditWorld {
|
|||||||
eworld.checkSign(block);
|
eworld.checkSign(block);
|
||||||
eworld.sign.add(block);
|
eworld.sign.add(block);
|
||||||
}
|
}
|
||||||
|
os.close();
|
||||||
|
|
||||||
} catch (FileNotFoundException e) {
|
} catch (FileNotFoundException e) {
|
||||||
// TODO Auto-generated catch block
|
// TODO Auto-generated catch block
|
||||||
e.printStackTrace();
|
e.printStackTrace();
|
||||||
@ -198,13 +199,13 @@ public class EditWorld {
|
|||||||
// TODO Auto-generated catch block
|
// TODO Auto-generated catch block
|
||||||
e.printStackTrace();
|
e.printStackTrace();
|
||||||
}
|
}
|
||||||
|
|
||||||
return eworld;
|
return eworld;
|
||||||
}
|
}
|
||||||
|
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
|
||||||
public static boolean exist(String name){
|
public static boolean exist(String name){
|
||||||
//Cheack Loaded EditWorlds
|
//Cheack Loaded EditWorlds
|
||||||
for(EditWorld eworld:eworlds){
|
for(EditWorld eworld:eworlds){
|
||||||
@ -212,14 +213,14 @@ public class EditWorld {
|
|||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
//Cheack Unloaded Worlds
|
//Cheack Unloaded Worlds
|
||||||
File file=new File("plugins/DungeonsXL/dungeons/"+name);
|
File file=new File("plugins/DungeonsXL/dungeons/"+name);
|
||||||
|
|
||||||
if(file.exists()){
|
if(file.exists()){
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -228,14 +229,14 @@ public class EditWorld {
|
|||||||
p.msg(dplayer.player, msg);
|
p.msg(dplayer.player, msg);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
//Invite
|
//Invite
|
||||||
public static boolean addInvitedPlayer(String eworldname,String player){
|
public static boolean addInvitedPlayer(String eworldname,String player){
|
||||||
|
|
||||||
EditWorld eworld=EditWorld.get(eworldname);
|
EditWorld eworld=EditWorld.get(eworldname);
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
if(eworld!=null){
|
if(eworld!=null){
|
||||||
eworld.invitedPlayers.add(player.toLowerCase());
|
eworld.invitedPlayers.add(player.toLowerCase());
|
||||||
}else{
|
}else{
|
||||||
@ -246,15 +247,15 @@ public class EditWorld {
|
|||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
return false;
|
return false;
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public static boolean removeInvitedPlayer(String eworldname,String player){
|
public static boolean removeInvitedPlayer(String eworldname,String player){
|
||||||
|
|
||||||
EditWorld eworld=EditWorld.get(eworldname);
|
EditWorld eworld=EditWorld.get(eworldname);
|
||||||
|
|
||||||
if(eworld!=null){
|
if(eworld!=null){
|
||||||
eworld.invitedPlayers.remove(player.toLowerCase());
|
eworld.invitedPlayers.remove(player.toLowerCase());
|
||||||
}else{
|
}else{
|
||||||
@ -265,15 +266,15 @@ public class EditWorld {
|
|||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
return false;
|
return false;
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public static boolean isInvitedPlayer(String eworldname,String player){
|
public static boolean isInvitedPlayer(String eworldname,String player){
|
||||||
|
|
||||||
EditWorld eworld=EditWorld.get(eworldname);
|
EditWorld eworld=EditWorld.get(eworldname);
|
||||||
|
|
||||||
if(eworld!=null){
|
if(eworld!=null){
|
||||||
return eworld.invitedPlayers.contains(player.toLowerCase());
|
return eworld.invitedPlayers.contains(player.toLowerCase());
|
||||||
}else{
|
}else{
|
||||||
@ -282,8 +283,8 @@ public class EditWorld {
|
|||||||
return confreader.invitedPlayer.contains(player.toLowerCase());
|
return confreader.invitedPlayer.contains(player.toLowerCase());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
return false;
|
return false;
|
||||||
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -31,10 +31,10 @@ import com.dre.dungeonsxl.DungeonsXL;
|
|||||||
public class GameWorld {
|
public class GameWorld {
|
||||||
private static DungeonsXL p=DungeonsXL.p;
|
private static DungeonsXL p=DungeonsXL.p;
|
||||||
public static CopyOnWriteArrayList<GameWorld> gworlds=new CopyOnWriteArrayList<GameWorld>();
|
public static CopyOnWriteArrayList<GameWorld> gworlds=new CopyOnWriteArrayList<GameWorld>();
|
||||||
|
|
||||||
//Variables placeable
|
//Variables placeable
|
||||||
public boolean isTutorial;
|
public boolean isTutorial;
|
||||||
|
|
||||||
public CopyOnWriteArrayList<Block> placeableBlocks=new CopyOnWriteArrayList<Block>();
|
public CopyOnWriteArrayList<Block> placeableBlocks=new CopyOnWriteArrayList<Block>();
|
||||||
public World world;
|
public World world;
|
||||||
public String dungeonname;
|
public String dungeonname;
|
||||||
@ -46,15 +46,15 @@ public class GameWorld {
|
|||||||
public boolean isPlaying=false;
|
public boolean isPlaying=false;
|
||||||
public int id;
|
public int id;
|
||||||
public CopyOnWriteArrayList<Material> secureobjects = new CopyOnWriteArrayList<Material>();
|
public CopyOnWriteArrayList<Material> secureobjects = new CopyOnWriteArrayList<Material>();
|
||||||
|
|
||||||
public CopyOnWriteArrayList<Sign> signClass=new CopyOnWriteArrayList<Sign>();
|
public CopyOnWriteArrayList<Sign> signClass=new CopyOnWriteArrayList<Sign>();
|
||||||
public CopyOnWriteArrayList<DMob> dmobs = new CopyOnWriteArrayList<DMob>();
|
public CopyOnWriteArrayList<DMob> dmobs = new CopyOnWriteArrayList<DMob>();
|
||||||
public CopyOnWriteArrayList<GameChest> gchests = new CopyOnWriteArrayList<GameChest>();
|
public CopyOnWriteArrayList<GameChest> gchests = new CopyOnWriteArrayList<GameChest>();
|
||||||
public ConfigReader confReader;
|
public ConfigReader confReader;
|
||||||
|
|
||||||
public GameWorld(){
|
public GameWorld(){
|
||||||
gworlds.add(this);
|
gworlds.add(this);
|
||||||
|
|
||||||
//ID
|
//ID
|
||||||
this.id=-1;
|
this.id=-1;
|
||||||
int i=-1;
|
int i=-1;
|
||||||
@ -70,12 +70,12 @@ public class GameWorld {
|
|||||||
if(!exist) this.id=i;
|
if(!exist) this.id=i;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public void checkSign(Block block){
|
public void checkSign(Block block){
|
||||||
if((block.getState() instanceof Sign)){
|
if((block.getState() instanceof Sign)){
|
||||||
Sign sign = (Sign) block.getState();
|
Sign sign = (Sign) block.getState();
|
||||||
String[] lines=sign.getLines();
|
String[] lines=sign.getLines();
|
||||||
|
|
||||||
if(!isPlaying){
|
if(!isPlaying){
|
||||||
if(lines[1].equalsIgnoreCase("lobby")){
|
if(lines[1].equalsIgnoreCase("lobby")){
|
||||||
this.locLobby=block.getLocation();
|
this.locLobby=block.getLocation();
|
||||||
@ -114,10 +114,10 @@ public class GameWorld {
|
|||||||
int[] direction=DGSign.getDirection(block.getData());
|
int[] direction=DGSign.getDirection(block.getData());
|
||||||
int directionX=direction[0];
|
int directionX=direction[0];
|
||||||
int directionZ=direction[1];
|
int directionZ=direction[1];
|
||||||
|
|
||||||
int xx=0,zz=0;
|
int xx=0,zz=0;
|
||||||
for(DClass dclass:this.confReader.getClasses()){
|
for(DClass dclass:this.confReader.getClasses()){
|
||||||
|
|
||||||
//Check existing signs
|
//Check existing signs
|
||||||
boolean isContinued=true;
|
boolean isContinued=true;
|
||||||
for(Sign isusedsign:this.signClass){
|
for(Sign isusedsign:this.signClass){
|
||||||
@ -125,13 +125,13 @@ public class GameWorld {
|
|||||||
isContinued=false;
|
isContinued=false;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if(isContinued){
|
if(isContinued){
|
||||||
Block classBlock=block.getRelative(xx,0,zz);
|
Block classBlock=block.getRelative(xx,0,zz);
|
||||||
|
|
||||||
if(classBlock.getData()==sign.getData().getData()&&classBlock.getTypeId()==68&&(classBlock.getState() instanceof Sign)){
|
if(classBlock.getData()==sign.getData().getData()&&classBlock.getTypeId()==68&&(classBlock.getState() instanceof Sign)){
|
||||||
Sign classSign = (Sign) classBlock.getState();
|
Sign classSign = (Sign) classBlock.getState();
|
||||||
|
|
||||||
classSign.setLine(0, ChatColor.DARK_BLUE+"############");
|
classSign.setLine(0, ChatColor.DARK_BLUE+"############");
|
||||||
classSign.setLine(1, ChatColor.DARK_GREEN+dclass.name);
|
classSign.setLine(1, ChatColor.DARK_GREEN+dclass.name);
|
||||||
classSign.setLine(2, "");
|
classSign.setLine(2, "");
|
||||||
@ -149,9 +149,9 @@ public class GameWorld {
|
|||||||
else{
|
else{
|
||||||
block.setTypeId(0);
|
block.setTypeId(0);
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
}else{
|
}else{
|
||||||
if(lines[1].equalsIgnoreCase("mob")){
|
if(lines[1].equalsIgnoreCase("mob")){
|
||||||
if(lines[2]!=""&&lines[3]!=""){
|
if(lines[2]!=""&&lines[3]!=""){
|
||||||
@ -180,14 +180,14 @@ public class GameWorld {
|
|||||||
}
|
}
|
||||||
if(lines[1].equalsIgnoreCase("checkpoint")){
|
if(lines[1].equalsIgnoreCase("checkpoint")){
|
||||||
int radius=0;
|
int radius=0;
|
||||||
|
|
||||||
|
|
||||||
if(lines[2]!=null ){
|
if(lines[2]!=null ){
|
||||||
if(lines[2].length()>0){
|
if(lines[2].length()>0){
|
||||||
radius=Integer.parseInt(lines[2]);
|
radius=Integer.parseInt(lines[2]);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
new GameCheckpoint(this,block.getLocation(),radius);
|
new GameCheckpoint(this,block.getLocation(),radius);
|
||||||
block.setTypeId(0);
|
block.setTypeId(0);
|
||||||
}
|
}
|
||||||
@ -211,13 +211,13 @@ public class GameWorld {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public void startGame() {
|
public void startGame() {
|
||||||
this.isPlaying=true;
|
this.isPlaying=true;
|
||||||
ObjectInputStream os;
|
ObjectInputStream os;
|
||||||
try {
|
try {
|
||||||
os = new ObjectInputStream(new FileInputStream(new File("DXL_Game_"+this.id+"/DXLData.data")));
|
os = new ObjectInputStream(new FileInputStream(new File("DXL_Game_"+this.id+"/DXLData.data")));
|
||||||
|
|
||||||
int length=os.readInt();
|
int length=os.readInt();
|
||||||
for(int i=0; i<length; i++){
|
for(int i=0; i<length; i++){
|
||||||
int x=os.readInt();
|
int x=os.readInt();
|
||||||
@ -234,7 +234,7 @@ public class GameWorld {
|
|||||||
e.printStackTrace();
|
e.printStackTrace();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public boolean canBuild(Block block){
|
public boolean canBuild(Block block){
|
||||||
for(Block placeableBlock:placeableBlocks){
|
for(Block placeableBlock:placeableBlocks){
|
||||||
if(placeableBlock.getLocation().distance(block.getLocation())<1){
|
if(placeableBlock.getLocation().distance(block.getLocation())<1){
|
||||||
@ -243,13 +243,13 @@ public class GameWorld {
|
|||||||
}
|
}
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
public void msg(String msg) {
|
public void msg(String msg) {
|
||||||
for(DPlayer dplayer:DPlayer.get(this.world)){
|
for(DPlayer dplayer:DPlayer.get(this.world)){
|
||||||
p.msg(dplayer.player, msg);
|
p.msg(dplayer.player, msg);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
//Static
|
//Static
|
||||||
public static GameWorld get(World world){
|
public static GameWorld get(World world){
|
||||||
for(GameWorld gworld:gworlds){
|
for(GameWorld gworld:gworlds){
|
||||||
@ -257,34 +257,34 @@ public class GameWorld {
|
|||||||
return gworld;
|
return gworld;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
|
||||||
public static void deleteAll(){
|
public static void deleteAll(){
|
||||||
for(GameWorld gworld:gworlds){
|
for(GameWorld gworld:gworlds){
|
||||||
gworlds.remove(gworld);
|
gworlds.remove(gworld);
|
||||||
|
|
||||||
p.getServer().unloadWorld(gworld.world,true);
|
p.getServer().unloadWorld(gworld.world,true);
|
||||||
File dir = new File("DXL_Game_"+gworld.id);
|
File dir = new File("DXL_Game_"+gworld.id);
|
||||||
p.removeDirectory(dir);
|
p.removeDirectory(dir);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public static boolean canPlayDungeon(String dungeon, Player player){
|
public static boolean canPlayDungeon(String dungeon, Player player){
|
||||||
|
|
||||||
if(p.permission.has(player, "dungeonsxl.ignoretimelimit")||player.isOp()){
|
if(p.permission.has(player, "dungeonsxl.ignoretimelimit")||player.isOp()){
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
File dungeonFolder=new File(p.getDataFolder()+"/dungeons/"+dungeon);
|
File dungeonFolder=new File(p.getDataFolder()+"/dungeons/"+dungeon);
|
||||||
if(dungeonFolder.isDirectory()){
|
if(dungeonFolder.isDirectory()){
|
||||||
ConfigReader confReader=new ConfigReader(new File(p.getDataFolder()+"/dungeons/"+dungeon, "config.yml"));
|
ConfigReader confReader=new ConfigReader(new File(p.getDataFolder()+"/dungeons/"+dungeon, "config.yml"));
|
||||||
|
|
||||||
if(confReader.timeToNextPlay!=0){
|
if(confReader.timeToNextPlay!=0){
|
||||||
//read PlayerConfig
|
//read PlayerConfig
|
||||||
File file=new File(p.getDataFolder()+"/dungeons/"+dungeon, "players.yml");
|
File file=new File(p.getDataFolder()+"/dungeons/"+dungeon, "players.yml");
|
||||||
|
|
||||||
if(!file.exists()){
|
if(!file.exists()){
|
||||||
try {
|
try {
|
||||||
file.createNewFile();
|
file.createNewFile();
|
||||||
@ -293,9 +293,9 @@ public class GameWorld {
|
|||||||
e.printStackTrace();
|
e.printStackTrace();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
FileConfiguration playerConfig = YamlConfiguration.loadConfiguration(file);
|
FileConfiguration playerConfig = YamlConfiguration.loadConfiguration(file);
|
||||||
|
|
||||||
if(playerConfig.contains(player.getName())){
|
if(playerConfig.contains(player.getName())){
|
||||||
Long time=playerConfig.getLong(player.getName());
|
Long time=playerConfig.getLong(player.getName());
|
||||||
if(time+(confReader.timeToNextPlay*1000*60*60)>System.currentTimeMillis()){
|
if(time+(confReader.timeToNextPlay*1000*60*60)>System.currentTimeMillis()){
|
||||||
@ -306,44 +306,44 @@ public class GameWorld {
|
|||||||
}else{
|
}else{
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
public void delete(){
|
public void delete(){
|
||||||
//for(GameWorld gworld:gworlds){
|
//for(GameWorld gworld:gworlds){
|
||||||
gworlds.remove(this);
|
gworlds.remove(this);
|
||||||
|
|
||||||
p.getServer().unloadWorld(this.world,true);
|
p.getServer().unloadWorld(this.world,true);
|
||||||
File dir = new File("DXL_Game_"+this.id);
|
File dir = new File("DXL_Game_"+this.id);
|
||||||
p.removeDirectory(dir);
|
p.removeDirectory(dir);
|
||||||
//}
|
//}
|
||||||
}
|
}
|
||||||
|
|
||||||
public static GameWorld load(String name){
|
public static GameWorld load(String name){
|
||||||
|
|
||||||
File file=new File("plugins/DungeonsXL/dungeons/"+name);
|
File file=new File("plugins/DungeonsXL/dungeons/"+name);
|
||||||
|
|
||||||
if(file.exists()){
|
if(file.exists()){
|
||||||
GameWorld gworld = new GameWorld();
|
GameWorld gworld = new GameWorld();
|
||||||
gworld.dungeonname=name;
|
gworld.dungeonname=name;
|
||||||
|
|
||||||
|
|
||||||
//Config einlesen
|
//Config einlesen
|
||||||
gworld.confReader=new ConfigReader(new File(p.getDataFolder()+"/dungeons/"+gworld.dungeonname, "config.yml"));
|
gworld.confReader=new ConfigReader(new File(p.getDataFolder()+"/dungeons/"+gworld.dungeonname, "config.yml"));
|
||||||
|
|
||||||
//Secure Objects
|
//Secure Objects
|
||||||
gworld.secureobjects=gworld.confReader.secureobjects;
|
gworld.secureobjects=gworld.confReader.secureobjects;
|
||||||
|
|
||||||
//World
|
//World
|
||||||
p.copyDirectory(file,new File("DXL_Game_"+gworld.id));
|
p.copyDirectory(file,new File("DXL_Game_"+gworld.id));
|
||||||
|
|
||||||
gworld.world=p.getServer().createWorld(WorldCreator.name("DXL_Game_"+gworld.id));
|
gworld.world=p.getServer().createWorld(WorldCreator.name("DXL_Game_"+gworld.id));
|
||||||
|
|
||||||
ObjectInputStream os;
|
ObjectInputStream os;
|
||||||
try {
|
try {
|
||||||
os = new ObjectInputStream(new FileInputStream(new File("DXL_Game_"+gworld.id+"/DXLData.data")));
|
os = new ObjectInputStream(new FileInputStream(new File("DXL_Game_"+gworld.id+"/DXLData.data")));
|
||||||
|
|
||||||
int length=os.readInt();
|
int length=os.readInt();
|
||||||
for(int i=0; i<length; i++){
|
for(int i=0; i<length; i++){
|
||||||
int x=os.readInt();
|
int x=os.readInt();
|
||||||
@ -351,8 +351,10 @@ public class GameWorld {
|
|||||||
int z=os.readInt();
|
int z=os.readInt();
|
||||||
Block block=gworld.world.getBlockAt(x, y, z);
|
Block block=gworld.world.getBlockAt(x, y, z);
|
||||||
gworld.checkSign(block);
|
gworld.checkSign(block);
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
os.close();
|
||||||
} catch (FileNotFoundException e) {
|
} catch (FileNotFoundException e) {
|
||||||
// TODO Auto-generated catch block
|
// TODO Auto-generated catch block
|
||||||
e.printStackTrace();
|
e.printStackTrace();
|
||||||
@ -360,15 +362,15 @@ public class GameWorld {
|
|||||||
// TODO Auto-generated catch block
|
// TODO Auto-generated catch block
|
||||||
e.printStackTrace();
|
e.printStackTrace();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
//if(gworld.confReader.isLobbyDisabled){
|
//if(gworld.confReader.isLobbyDisabled){
|
||||||
// gworld.startGame();
|
// gworld.startGame();
|
||||||
//}
|
//}
|
||||||
|
|
||||||
return gworld;
|
return gworld;
|
||||||
}
|
}
|
||||||
|
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -392,6 +394,6 @@ public class GameWorld {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user