Only manage a world if it has Stargates
This commit is contained in:
parent
02f9b293c0
commit
8b6b6d3aa1
@ -3,13 +3,7 @@ package net.TheDgtl.Stargate;
|
|||||||
import java.io.BufferedWriter;
|
import java.io.BufferedWriter;
|
||||||
import java.io.File;
|
import java.io.File;
|
||||||
import java.io.FileWriter;
|
import java.io.FileWriter;
|
||||||
import java.util.ArrayList;
|
import java.util.*;
|
||||||
import java.util.Collections;
|
|
||||||
import java.util.HashMap;
|
|
||||||
import java.util.Iterator;
|
|
||||||
import java.util.List;
|
|
||||||
import java.util.Random;
|
|
||||||
import java.util.Scanner;
|
|
||||||
import java.util.logging.Level;
|
import java.util.logging.Level;
|
||||||
|
|
||||||
import net.TheDgtl.Stargate.event.StargateActivateEvent;
|
import net.TheDgtl.Stargate.event.StargateActivateEvent;
|
||||||
@ -1244,9 +1238,7 @@ public class Portal {
|
|||||||
}
|
}
|
||||||
|
|
||||||
public static void saveAllGates(World world) {
|
public static void saveAllGates(World world) {
|
||||||
if(!Stargate.managedWorlds.contains(world.getName())) {
|
|
||||||
Stargate.managedWorlds.add(world.getName());
|
Stargate.managedWorlds.add(world.getName());
|
||||||
}
|
|
||||||
String loc = Stargate.getSaveLocation() + "/" + world.getName() + ".db";
|
String loc = Stargate.getSaveLocation() + "/" + world.getName() + ".db";
|
||||||
|
|
||||||
try {
|
try {
|
||||||
@ -1320,7 +1312,7 @@ public class Portal {
|
|||||||
allPortalsNet.clear();
|
allPortalsNet.clear();
|
||||||
}
|
}
|
||||||
|
|
||||||
public static void loadAllGates(World world) {
|
public static boolean loadAllGates(World world) {
|
||||||
String location = Stargate.getSaveLocation();
|
String location = Stargate.getSaveLocation();
|
||||||
|
|
||||||
File db = new File(location, world.getName() + ".db");
|
File db = new File(location, world.getName() + ".db");
|
||||||
@ -1404,6 +1396,7 @@ public class Portal {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
Stargate.log.info("[Stargate] {" + world.getName() + "} Loaded " + portalCount + " stargates with " + OpenCount + " set as always-on");
|
Stargate.log.info("[Stargate] {" + world.getName() + "} Loaded " + portalCount + " stargates with " + OpenCount + " set as always-on");
|
||||||
|
return true;
|
||||||
} catch (Exception e) {
|
} catch (Exception e) {
|
||||||
Stargate.log.log(Level.SEVERE, "Exception while reading stargates from " + db.getName() + ": " + l);
|
Stargate.log.log(Level.SEVERE, "Exception while reading stargates from " + db.getName() + ": " + l);
|
||||||
e.printStackTrace();
|
e.printStackTrace();
|
||||||
@ -1411,6 +1404,7 @@ public class Portal {
|
|||||||
} else {
|
} else {
|
||||||
Stargate.log.info("[Stargate] {" + world.getName() + "} No stargates for world ");
|
Stargate.log.info("[Stargate] {" + world.getName() + "} No stargates for world ");
|
||||||
}
|
}
|
||||||
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
public static void closeAllGates() {
|
public static void closeAllGates() {
|
||||||
|
@ -122,11 +122,13 @@ public class Stargate extends JavaPlugin {
|
|||||||
// HashMap of player names for Bungee support
|
// HashMap of player names for Bungee support
|
||||||
public static Map<String, String> bungeeQueue = new HashMap<>();
|
public static Map<String, String> bungeeQueue = new HashMap<>();
|
||||||
|
|
||||||
|
// World names that contain stargates
|
||||||
public static HashSet<String> managedWorlds = new HashSet<>();
|
public static HashSet<String> managedWorlds = new HashSet<>();
|
||||||
|
|
||||||
public void onDisable() {
|
public void onDisable() {
|
||||||
Portal.closeAllGates();
|
Portal.closeAllGates();
|
||||||
Portal.clearGates();
|
Portal.clearGates();
|
||||||
|
managedWorlds.clear();
|
||||||
getServer().getScheduler().cancelTasks(this);
|
getServer().getScheduler().cancelTasks(this);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -1054,8 +1056,8 @@ public class Stargate extends JavaPlugin {
|
|||||||
private class wListener implements Listener {
|
private class wListener implements Listener {
|
||||||
@EventHandler
|
@EventHandler
|
||||||
public void onWorldLoad(WorldLoadEvent event) {
|
public void onWorldLoad(WorldLoadEvent event) {
|
||||||
if(!managedWorlds.contains(event.getWorld().getName())) {
|
if(!managedWorlds.contains(event.getWorld().getName())
|
||||||
Portal.loadAllGates(event.getWorld());
|
&& Portal.loadAllGates(event.getWorld())) {
|
||||||
managedWorlds.add(event.getWorld().getName());
|
managedWorlds.add(event.getWorld().getName());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -1117,7 +1119,7 @@ public class Stargate extends JavaPlugin {
|
|||||||
BloxPopulator b = Stargate.blockPopulatorQueue.poll();
|
BloxPopulator b = Stargate.blockPopulatorQueue.poll();
|
||||||
if (b == null) return;
|
if (b == null) return;
|
||||||
Block blk = b.getBlox().getBlock();
|
Block blk = b.getBlox().getBlock();
|
||||||
blk.setType(b.getMat());
|
blk.setType(b.getMat(), false);
|
||||||
if(b.getMat() == Material.END_GATEWAY && blk.getWorld().getEnvironment() == World.Environment.THE_END) {
|
if(b.getMat() == Material.END_GATEWAY && blk.getWorld().getEnvironment() == World.Environment.THE_END) {
|
||||||
// force a location to prevent exit gateway generation
|
// force a location to prevent exit gateway generation
|
||||||
EndGateway gateway = (EndGateway) blk.getState();
|
EndGateway gateway = (EndGateway) blk.getState();
|
||||||
|
Loading…
x
Reference in New Issue
Block a user