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.File;
|
||||
import java.io.FileWriter;
|
||||
import java.util.ArrayList;
|
||||
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.*;
|
||||
import java.util.logging.Level;
|
||||
|
||||
import net.TheDgtl.Stargate.event.StargateActivateEvent;
|
||||
@ -1244,9 +1238,7 @@ public class Portal {
|
||||
}
|
||||
|
||||
public static void saveAllGates(World world) {
|
||||
if(!Stargate.managedWorlds.contains(world.getName())) {
|
||||
Stargate.managedWorlds.add(world.getName());
|
||||
}
|
||||
String loc = Stargate.getSaveLocation() + "/" + world.getName() + ".db";
|
||||
|
||||
try {
|
||||
@ -1320,7 +1312,7 @@ public class Portal {
|
||||
allPortalsNet.clear();
|
||||
}
|
||||
|
||||
public static void loadAllGates(World world) {
|
||||
public static boolean loadAllGates(World world) {
|
||||
String location = Stargate.getSaveLocation();
|
||||
|
||||
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");
|
||||
return true;
|
||||
} catch (Exception e) {
|
||||
Stargate.log.log(Level.SEVERE, "Exception while reading stargates from " + db.getName() + ": " + l);
|
||||
e.printStackTrace();
|
||||
@ -1411,6 +1404,7 @@ public class Portal {
|
||||
} else {
|
||||
Stargate.log.info("[Stargate] {" + world.getName() + "} No stargates for world ");
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
public static void closeAllGates() {
|
||||
|
@ -122,11 +122,13 @@ public class Stargate extends JavaPlugin {
|
||||
// HashMap of player names for Bungee support
|
||||
public static Map<String, String> bungeeQueue = new HashMap<>();
|
||||
|
||||
// World names that contain stargates
|
||||
public static HashSet<String> managedWorlds = new HashSet<>();
|
||||
|
||||
public void onDisable() {
|
||||
Portal.closeAllGates();
|
||||
Portal.clearGates();
|
||||
managedWorlds.clear();
|
||||
getServer().getScheduler().cancelTasks(this);
|
||||
}
|
||||
|
||||
@ -1054,8 +1056,8 @@ public class Stargate extends JavaPlugin {
|
||||
private class wListener implements Listener {
|
||||
@EventHandler
|
||||
public void onWorldLoad(WorldLoadEvent event) {
|
||||
if(!managedWorlds.contains(event.getWorld().getName())) {
|
||||
Portal.loadAllGates(event.getWorld());
|
||||
if(!managedWorlds.contains(event.getWorld().getName())
|
||||
&& Portal.loadAllGates(event.getWorld())) {
|
||||
managedWorlds.add(event.getWorld().getName());
|
||||
}
|
||||
}
|
||||
@ -1117,7 +1119,7 @@ public class Stargate extends JavaPlugin {
|
||||
BloxPopulator b = Stargate.blockPopulatorQueue.poll();
|
||||
if (b == null) return;
|
||||
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) {
|
||||
// force a location to prevent exit gateway generation
|
||||
EndGateway gateway = (EndGateway) blk.getState();
|
||||
|
Loading…
x
Reference in New Issue
Block a user