mirror of
https://github.com/trainerlord/WorldSystem.git
synced 2025-02-15 01:01:26 +01:00
v2.2.0.1 - Added config option for spawn teleportation, maybe fixed a
bug whilst world loading
This commit is contained in:
parent
78357c75dd
commit
87ebe844de
@ -25,6 +25,9 @@ unloadingtime: 20
|
||||
# Except for players with the permissions: ws.gamemode | ws.tp.*
|
||||
survival: false
|
||||
|
||||
# If true players will teleported to the spawn on join
|
||||
spawn_teleportation: true
|
||||
|
||||
# Time in seconds until a request expires
|
||||
request_expires: 20
|
||||
|
||||
|
@ -1,5 +1,5 @@
|
||||
name: WorldSystem
|
||||
version: 2.2.0
|
||||
version: 2.2.0.1
|
||||
author: Butzlabben
|
||||
main: de.butzlabben.world.WorldSystem
|
||||
loadbefore: [FastAsyncWorldEdit, WorldEdit]
|
||||
|
@ -25,6 +25,9 @@ unloadingtime: 20
|
||||
# Except for players with the permissions: ws.gamemode | ws.tp.*
|
||||
survival: false
|
||||
|
||||
# If true players will teleported to the spawn on join
|
||||
spawn_teleportation: true
|
||||
|
||||
# Time in seconds until a request expires
|
||||
request_expires: 20
|
||||
|
||||
|
@ -43,7 +43,7 @@ import de.butzlabben.world.gui.WorldSystemGUI;
|
||||
import de.butzlabben.world.listener.BlockListener;
|
||||
import de.butzlabben.world.listener.CommandListener;
|
||||
import de.butzlabben.world.listener.PlayerDeathListener;
|
||||
import de.butzlabben.world.listener.PlayerLeaveListener;
|
||||
import de.butzlabben.world.listener.PlayerListener;
|
||||
import de.butzlabben.world.wrapper.AsyncCreatorAdapter;
|
||||
import de.butzlabben.world.wrapper.CreatorAdapter;
|
||||
import de.butzlabben.world.wrapper.SystemWorld;
|
||||
@ -52,7 +52,7 @@ import de.butzlabben.world.wrapper.SystemWorld;
|
||||
* @author Butzlabben
|
||||
* @author Jubeki
|
||||
* @since 10.07.2017
|
||||
* @version 1.0
|
||||
* @version 2.2.0.1
|
||||
*/
|
||||
public class WorldSystem extends JavaPlugin {
|
||||
|
||||
@ -68,7 +68,7 @@ public class WorldSystem extends JavaPlugin {
|
||||
createConfigs();
|
||||
|
||||
PluginManager pm = Bukkit.getPluginManager();
|
||||
pm.registerEvents(new PlayerLeaveListener(), this);
|
||||
pm.registerEvents(new PlayerListener(), this);
|
||||
pm.registerEvents(new BlockListener(), this);
|
||||
pm.registerEvents(new PlayerDeathListener(), this);
|
||||
pm.registerEvents(new CommandListener(), this);
|
||||
|
@ -38,7 +38,7 @@ public class PluginConfig {
|
||||
if (false == (cfg.isString("worldfolder") && cfg.isString("worldsource") && cfg.isInt("unloadingtime")
|
||||
&& cfg.isBoolean("survival") && cfg.isString("language") && cfg.isString("prefix")
|
||||
&& cfg.isInt("request_expires") && cfg.isBoolean("need_confirm")
|
||||
&& cfg.isBoolean("contact_authserver") &&
|
||||
&& cfg.isBoolean("contact_authserver") && cfg.isBoolean("spawn_teleportation") &&
|
||||
|
||||
cfg.isInt("lagsystem.period_in_seconds") && cfg.isInt("lagsystem.entities_per_world")
|
||||
&& cfg.isBoolean("lagsystem.garbagecollector.use")
|
||||
@ -189,7 +189,7 @@ public class PluginConfig {
|
||||
try {
|
||||
wt = WorldType.valueOf(t.toUpperCase());
|
||||
} catch (Exception e) {
|
||||
System.out.println("'" + t + "' is not a valid worldtype");
|
||||
System.err.println("'" + t + "' is not a valid worldtype");
|
||||
}
|
||||
return wt;
|
||||
}
|
||||
@ -208,7 +208,11 @@ public class PluginConfig {
|
||||
return getConfig().getBoolean("need_confirm", true);
|
||||
}
|
||||
|
||||
public static boolean contact_auth() {
|
||||
public static boolean contactAuth() {
|
||||
return getConfig().getBoolean("contact_authserver", true);
|
||||
}
|
||||
|
||||
public static boolean spawnTeleportation() {
|
||||
return getConfig().getBoolean("spawn_teleportation", true);
|
||||
}
|
||||
}
|
||||
|
@ -37,6 +37,16 @@ public class WorldConfig {
|
||||
}
|
||||
return worldconfig;
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns wether a worldconfig exists for this worldname
|
||||
*
|
||||
* @param worldname name of the world
|
||||
* @return Wether this world has a worldconfig
|
||||
*/
|
||||
public static boolean exists(String worldname) {
|
||||
return getWorldFile(worldname).exists();
|
||||
}
|
||||
|
||||
private static HashMap<String, WorldConfig> instances = new HashMap<>();
|
||||
|
||||
@ -63,8 +73,7 @@ public class WorldConfig {
|
||||
private boolean fire, tnt;
|
||||
|
||||
private WorldConfig(String worldname) {
|
||||
File file = getWorldFile(worldname);
|
||||
if (file.exists() == false)
|
||||
if (exists(worldname) == false)
|
||||
throw new IllegalArgumentException("WorldConfig doesn't exist");
|
||||
owner = UUID.fromString(worldname.substring(worldname.length() - 36));
|
||||
id = Integer.parseInt(worldname.split("-")[0].substring(2));
|
||||
@ -395,7 +404,7 @@ public class WorldConfig {
|
||||
for (UUID uuid : permissions.keySet()) {
|
||||
OfflinePlayer op = Bukkit.getOfflinePlayer(uuid);
|
||||
if (op == null || op.getName() == null) {
|
||||
if (PluginConfig.contact_auth()) {
|
||||
if (PluginConfig.contactAuth()) {
|
||||
try {
|
||||
GameProfile prof = GameProfileBuilder.fetch(uuid);
|
||||
map.put(uuid, prof.getName());
|
||||
|
@ -1,19 +0,0 @@
|
||||
package de.butzlabben.world.listener;
|
||||
|
||||
import org.bukkit.World;
|
||||
import org.bukkit.entity.Player;
|
||||
import org.bukkit.event.EventHandler;
|
||||
import org.bukkit.event.Listener;
|
||||
import org.bukkit.event.player.PlayerQuitEvent;
|
||||
|
||||
import de.butzlabben.world.wrapper.SystemWorld;
|
||||
|
||||
public class PlayerLeaveListener implements Listener {
|
||||
|
||||
@EventHandler
|
||||
public void onLeave(PlayerQuitEvent e) {
|
||||
Player p = e.getPlayer();
|
||||
World w = p.getWorld();
|
||||
SystemWorld.tryUnloadLater(w);
|
||||
}
|
||||
}
|
@ -0,0 +1,38 @@
|
||||
package de.butzlabben.world.listener;
|
||||
|
||||
import org.bukkit.World;
|
||||
import org.bukkit.entity.Player;
|
||||
import org.bukkit.event.EventHandler;
|
||||
import org.bukkit.event.EventPriority;
|
||||
import org.bukkit.event.Listener;
|
||||
import org.bukkit.event.player.PlayerJoinEvent;
|
||||
import org.bukkit.event.player.PlayerQuitEvent;
|
||||
|
||||
import de.butzlabben.world.config.DependenceConfig;
|
||||
import de.butzlabben.world.config.PluginConfig;
|
||||
import de.butzlabben.world.wrapper.SystemWorld;
|
||||
|
||||
public class PlayerListener implements Listener {
|
||||
|
||||
//#17
|
||||
@EventHandler(priority = EventPriority.HIGHEST)
|
||||
public void onJoin(PlayerJoinEvent e) {
|
||||
if (PluginConfig.spawnTeleportation()) {
|
||||
Player p = e.getPlayer();
|
||||
DependenceConfig dc = new DependenceConfig(p);
|
||||
if (dc.hasWorld()) {
|
||||
SystemWorld sw = SystemWorld.getSystemWorld(dc.getWorldname());
|
||||
if (sw != null && !sw.isLoaded()) {
|
||||
e.getPlayer().teleport(PluginConfig.getSpawn());
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@EventHandler
|
||||
public void onLeave(PlayerQuitEvent e) {
|
||||
Player p = e.getPlayer();
|
||||
World w = p.getWorld();
|
||||
SystemWorld.tryUnloadLater(w);
|
||||
}
|
||||
}
|
@ -132,6 +132,7 @@ public class SystemWorld {
|
||||
Bukkit.getPluginManager().callEvent(event);
|
||||
if (event.isCancelled())
|
||||
return;
|
||||
//Set unloading to true
|
||||
unloading = true;
|
||||
w.save();
|
||||
Chunk[] arrayOfChunk;
|
||||
@ -144,9 +145,11 @@ public class SystemWorld {
|
||||
a.teleport(PluginConfig.getSpawn());
|
||||
a.setGameMode(PluginConfig.getSpawnGamemode());
|
||||
}
|
||||
Bukkit.getScheduler().runTaskLater(Bukkit.getPluginManager().getPlugin("WorldSystem"), new Runnable() {
|
||||
|
||||
Bukkit.getScheduler().runTaskLater(WorldSystem.getInstance(), new Runnable() {
|
||||
@Override
|
||||
public void run() {
|
||||
// Still in world unloading process?
|
||||
if (unloading) {
|
||||
if (Bukkit.unloadWorld(w, true)) {
|
||||
File worldinserver = new File(Bukkit.getWorldContainer(), worldname);
|
||||
@ -181,27 +184,30 @@ public class SystemWorld {
|
||||
if (creating)
|
||||
return;
|
||||
|
||||
unloading = false;
|
||||
|
||||
WorldLoadEvent event = new WorldLoadEvent(p, this);
|
||||
Bukkit.getPluginManager().callEvent(event);
|
||||
if (event.isCancelled())
|
||||
return;
|
||||
|
||||
unloading = false;
|
||||
|
||||
p.sendMessage(MessageConfig.getSettingUpWorld());
|
||||
// Move World into Server dir
|
||||
String worlddir = PluginConfig.getWorlddir();
|
||||
File world = new File(worlddir + "/" + worldname);
|
||||
world = new File(worlddir + "/" + worldname);
|
||||
if (!world.exists()) {
|
||||
world = new File(Bukkit.getWorldContainer(), worldname);
|
||||
} else {
|
||||
if (new File(Bukkit.getWorldContainer(), worldname).exists()
|
||||
&& new File(PluginConfig.getWorlddir() + "/" + worldname).exists()) {
|
||||
try {
|
||||
FileUtils.deleteDirectory(new File(Bukkit.getWorldContainer(), worldname));
|
||||
} catch (IOException e) {
|
||||
p.sendMessage(PluginConfig.getPrefix() + "§cError");
|
||||
e.printStackTrace();
|
||||
}
|
||||
System.err.println("World " + worldname + " exists twice!");
|
||||
// try {
|
||||
// FileUtils.deleteDirectory(new File(Bukkit.getWorldContainer(), worldname));
|
||||
// } catch (IOException e) {
|
||||
// p.sendMessage(PluginConfig.getPrefix() + "§cError");
|
||||
// e.printStackTrace();
|
||||
// }
|
||||
}
|
||||
try {
|
||||
FileUtils.moveDirectoryToDirectory(world, Bukkit.getWorldContainer(), false);
|
||||
@ -211,6 +217,7 @@ public class SystemWorld {
|
||||
e.printStackTrace();
|
||||
}
|
||||
}
|
||||
|
||||
if (worldname.charAt(worldname.length() - 37) == ' ') {
|
||||
StringBuilder myName = new StringBuilder(worldname);
|
||||
myName.setCharAt(worldname.length() - 37, '-');
|
||||
|
@ -1,5 +1,5 @@
|
||||
name: WorldSystem
|
||||
version: 2.2.0
|
||||
version: 2.2.0.1
|
||||
author: Butzlabben
|
||||
main: de.butzlabben.world.WorldSystem
|
||||
loadbefore: [FastAsyncWorldEdit, WorldEdit]
|
||||
|
Loading…
Reference in New Issue
Block a user