mirror of
https://github.com/trainerlord/WorldSystem.git
synced 2025-01-05 18:37:48 +01:00
See 2.2.0.4
This commit is contained in:
parent
e48b5b255b
commit
22541d1fdf
@ -1,5 +1,5 @@
|
||||
name: WorldSystem
|
||||
version: 2.2.0.3
|
||||
version: 2.2.0.4
|
||||
author: Butzlabben
|
||||
main: de.butzlabben.world.WorldSystem
|
||||
loadbefore: [FastAsyncWorldEdit, WorldEdit]
|
||||
|
@ -137,13 +137,14 @@ public class WorldSystem extends JavaPlugin {
|
||||
creator = (c, sw) -> {
|
||||
Bukkit.getWorlds().add(c.createWorld());
|
||||
if (sw != null)
|
||||
sw.stopCreating();
|
||||
sw.setCreating(false);
|
||||
};
|
||||
}
|
||||
|
||||
|
||||
// Starting for #28
|
||||
if (PluginConfig.shouldDelete()) {
|
||||
Bukkit.getConsoleSender().sendMessage(PluginConfig.getPrefix() + "Searching for old worlds to delete if not loaded for " + PluginConfig.deleteAfter() + " days");
|
||||
Bukkit.getConsoleSender().sendMessage(PluginConfig.getPrefix()
|
||||
+ "Searching for old worlds to delete if not loaded for " + PluginConfig.deleteAfter() + " days");
|
||||
DependenceConfig.checkWorlds();
|
||||
}
|
||||
|
||||
|
@ -6,6 +6,9 @@ import java.util.ArrayList;
|
||||
|
||||
import org.apache.commons.io.FileUtils;
|
||||
import org.bukkit.Bukkit;
|
||||
import org.bukkit.World.Environment;
|
||||
import org.bukkit.WorldCreator;
|
||||
import org.bukkit.WorldType;
|
||||
import org.bukkit.command.Command;
|
||||
import org.bukkit.command.CommandExecutor;
|
||||
import org.bukkit.command.CommandSender;
|
||||
@ -21,14 +24,15 @@ import de.butzlabben.world.wrapper.SystemWorld;
|
||||
public class WSResetCommand implements CommandExecutor {
|
||||
|
||||
private ArrayList<Player> toConfirm = new ArrayList<>();
|
||||
|
||||
|
||||
@Override
|
||||
public boolean onCommand(CommandSender cs, Command cmd, String label, String[] args) {
|
||||
Player p = (Player) cs;
|
||||
if(args.length > 2) {
|
||||
p.sendMessage(MessageConfig.getWrongUsage().replaceAll("%usage", WorldSystem.getInstance().getCommand("ws reset").getUsage()));
|
||||
if (args.length > 2) {
|
||||
p.sendMessage(MessageConfig.getWrongUsage().replaceAll("%usage",
|
||||
WorldSystem.getInstance().getCommand("ws reset").getUsage()));
|
||||
return true;
|
||||
}
|
||||
}
|
||||
DependenceConfig dc = new DependenceConfig(p);
|
||||
String worldname = dc.getWorldname();
|
||||
SystemWorld sw = SystemWorld.getSystemWorld(worldname);
|
||||
@ -38,10 +42,9 @@ public class WSResetCommand implements CommandExecutor {
|
||||
}
|
||||
if (args.length > 1) {
|
||||
if (args[1].equals("confirm")) {
|
||||
if(sw.isLoaded()) {
|
||||
p.sendMessage(MessageConfig.getWorldStillLoaded());
|
||||
return true;
|
||||
}
|
||||
if (sw.isLoaded())
|
||||
sw.directUnload(Bukkit.getWorld(worldname));
|
||||
|
||||
if (!toConfirm.contains(p)) {
|
||||
p.sendMessage(MessageConfig.getNoRequestSend());
|
||||
return true;
|
||||
@ -62,24 +65,28 @@ public class WSResetCommand implements CommandExecutor {
|
||||
try {
|
||||
FileUtils.copyDirectory(exampleworld, f);
|
||||
toConfirm.remove(p);
|
||||
|
||||
FileUtils.moveDirectoryToDirectory(f, Bukkit.getWorldContainer(), false);
|
||||
|
||||
p.sendMessage(MessageConfig.getWorldReseted());
|
||||
|
||||
//Currently problems with
|
||||
/*WorldCreator creator = new WorldCreator(worldname);
|
||||
|
||||
// For fast worldcreating after reset
|
||||
WorldCreator creator = new WorldCreator(worldname);
|
||||
long seed = PluginConfig.getSeed();
|
||||
Environment env = PluginConfig.getEnvironment();
|
||||
WorldType type = PluginConfig.getWorldType();
|
||||
if(seed != 0)
|
||||
if (seed != 0)
|
||||
creator.seed(seed);
|
||||
creator.type(type);
|
||||
creator.environment(env);
|
||||
String generator = PluginConfig.getGenerator();
|
||||
if(!generator.trim().isEmpty())
|
||||
if (!generator.trim().isEmpty())
|
||||
creator.generator(generator);
|
||||
|
||||
|
||||
sw.setCreating(true);
|
||||
// For #16
|
||||
WorldSystem.creator.create(creator, sw);*/
|
||||
|
||||
WorldSystem.creator.create(creator, sw);
|
||||
|
||||
} catch (IOException e) {
|
||||
e.printStackTrace();
|
||||
p.sendMessage(MessageConfig.getUnknownError());
|
||||
@ -90,14 +97,14 @@ public class WSResetCommand implements CommandExecutor {
|
||||
return true;
|
||||
}
|
||||
} else if (args.length == 1) {
|
||||
if (sw.isLoaded()) {
|
||||
p.sendMessage(MessageConfig.getWorldStillLoaded());
|
||||
return true;
|
||||
}
|
||||
if (sw.isLoaded())
|
||||
sw.directUnload(Bukkit.getWorld(worldname));
|
||||
|
||||
if (toConfirm.contains(p)) {
|
||||
p.sendMessage(MessageConfig.getRequestAlreadySent());
|
||||
return true;
|
||||
}
|
||||
|
||||
int time = PluginConfig.getRequestExpire();
|
||||
p.sendMessage(MessageConfig.getConfirmRequest().replaceAll("%command", "/ws reset confirm"));
|
||||
p.sendMessage(MessageConfig.getTimeUntilExpires().replaceAll("%time", String.valueOf(time)));
|
||||
|
@ -10,6 +10,7 @@ import org.bukkit.entity.Player;
|
||||
import de.butzlabben.world.WorldSystem;
|
||||
import de.butzlabben.world.config.DependenceConfig;
|
||||
import de.butzlabben.world.config.MessageConfig;
|
||||
import de.butzlabben.world.config.PluginConfig;
|
||||
import de.butzlabben.world.config.WorldConfig;
|
||||
import de.butzlabben.world.wrapper.WorldPlayer;
|
||||
|
||||
@ -38,6 +39,10 @@ public class WSToggleBuildCommand implements CommandExecutor {
|
||||
return true;
|
||||
}
|
||||
WorldPlayer wp = new WorldPlayer(a, dc.getWorldname());
|
||||
if (wp.isOwnerofWorld()) {
|
||||
p.sendMessage(PluginConfig.getPrefix() + "§cYou are the owner");
|
||||
return true;
|
||||
}
|
||||
if (wp.toggleBuild()) {
|
||||
p.sendMessage(MessageConfig.getToggleBuildEnabled().replaceAll("%player", a.getName()));
|
||||
} else {
|
||||
|
@ -10,6 +10,7 @@ import org.bukkit.entity.Player;
|
||||
import de.butzlabben.world.WorldSystem;
|
||||
import de.butzlabben.world.config.DependenceConfig;
|
||||
import de.butzlabben.world.config.MessageConfig;
|
||||
import de.butzlabben.world.config.PluginConfig;
|
||||
import de.butzlabben.world.config.WorldConfig;
|
||||
import de.butzlabben.world.wrapper.WorldPlayer;
|
||||
|
||||
@ -38,6 +39,10 @@ public class WSToggleGMCommand implements CommandExecutor {
|
||||
return true;
|
||||
}
|
||||
WorldPlayer wp = new WorldPlayer(a, dc.getWorldname());
|
||||
if (wp.isOwnerofWorld()) {
|
||||
p.sendMessage(PluginConfig.getPrefix() + "§cYou are the owner");
|
||||
return true;
|
||||
}
|
||||
if (wp.toggleGamemode()) {
|
||||
p.sendMessage(MessageConfig.getToggleGameModeEnabled().replaceAll("%player", a.getName()));
|
||||
} else {
|
||||
|
@ -10,6 +10,7 @@ import org.bukkit.entity.Player;
|
||||
import de.butzlabben.world.WorldSystem;
|
||||
import de.butzlabben.world.config.DependenceConfig;
|
||||
import de.butzlabben.world.config.MessageConfig;
|
||||
import de.butzlabben.world.config.PluginConfig;
|
||||
import de.butzlabben.world.config.WorldConfig;
|
||||
import de.butzlabben.world.wrapper.WorldPlayer;
|
||||
|
||||
@ -38,6 +39,10 @@ public class WSToggleTPCommand implements CommandExecutor {
|
||||
return true;
|
||||
}
|
||||
WorldPlayer wp = new WorldPlayer(a, dc.getWorldname());
|
||||
if (wp.isOwnerofWorld()) {
|
||||
p.sendMessage(PluginConfig.getPrefix() + "§cYou are the owner");
|
||||
return true;
|
||||
}
|
||||
if (wp.toggleTeleport()) {
|
||||
p.sendMessage(MessageConfig.getToggleTeleportEnabled().replaceAll("%player", a.getName()));
|
||||
} else {
|
||||
|
@ -19,11 +19,16 @@ public class DependenceConfig {
|
||||
|
||||
@SuppressWarnings("deprecation")
|
||||
public DependenceConfig(String s) {
|
||||
OfflinePlayer op = Bukkit.getOfflinePlayer(UUID.fromString(s));
|
||||
OfflinePlayer op = null;
|
||||
try {
|
||||
op = Bukkit.getOfflinePlayer(UUID.fromString(s));
|
||||
} catch (Exception e) {
|
||||
}
|
||||
if (op == null) {
|
||||
op = Bukkit.getOfflinePlayer(s);
|
||||
if (op == null)
|
||||
return;
|
||||
|
||||
}
|
||||
this.op = op;
|
||||
}
|
||||
@ -135,7 +140,7 @@ public class DependenceConfig {
|
||||
YamlConfiguration dcfg = YamlConfiguration.loadConfiguration(dconfig);
|
||||
return dcfg.getInt("Dependences." + op.getUniqueId().toString() + ".ID");
|
||||
}
|
||||
|
||||
|
||||
public OfflinePlayer getOwner() {
|
||||
return op;
|
||||
}
|
||||
|
@ -14,7 +14,6 @@ import de.butzlabben.world.gui.clicklistener.ComingSoonClickListener;
|
||||
import de.butzlabben.world.gui.clicklistener.CommandExecutorClickListener;
|
||||
import de.butzlabben.world.gui.worldoption.FireStatus;
|
||||
import de.butzlabben.world.gui.worldoption.TntStatus;
|
||||
import de.butzlabben.world.wrapper.SystemWorld;
|
||||
import de.butzlabben.world.wrapper.WorldPlayer;
|
||||
|
||||
public class WorldOptionsGUI extends OrcInventory {
|
||||
@ -38,11 +37,7 @@ public class WorldOptionsGUI extends OrcInventory {
|
||||
if (item != null) {
|
||||
item.setOnClick((p, inv, i) -> {
|
||||
p.closeInventory();
|
||||
SystemWorld sw = SystemWorld.getSystemWorld(p.getWorld().getName());
|
||||
if(sw != null && sw.isLoaded()) {
|
||||
sw.directUnload(p.getWorld());
|
||||
p.chat("/ws reset");
|
||||
}
|
||||
p.chat("/ws reset");
|
||||
});
|
||||
addItem(GuiConfig.getSlot(path + "reset"), item);
|
||||
}
|
||||
|
@ -32,7 +32,7 @@ public class AsyncCreatorAdapter implements CreatorAdapter {
|
||||
world.commit();
|
||||
Bukkit.getWorlds().add(world);
|
||||
if (sw != null)
|
||||
sw.stopCreating();
|
||||
sw.setCreating(false);
|
||||
}
|
||||
});
|
||||
return;
|
||||
|
@ -180,9 +180,10 @@ public class SystemWorld {
|
||||
Preconditions.checkNotNull(p, "player must not be null");
|
||||
Preconditions.checkArgument(p.isOnline(), "player must be online");
|
||||
|
||||
if (creating)
|
||||
if (creating) {
|
||||
p.sendMessage(PluginConfig.getPrefix() + "§cWorld is still creating...");
|
||||
return;
|
||||
|
||||
}
|
||||
|
||||
WorldLoadEvent event = new WorldLoadEvent(p, this);
|
||||
Bukkit.getPluginManager().callEvent(event);
|
||||
@ -310,6 +311,9 @@ public class SystemWorld {
|
||||
e.printStackTrace();
|
||||
}
|
||||
}
|
||||
|
||||
SystemWorld sw = SystemWorld.getSystemWorld(worldname);
|
||||
sw.setCreating(true);
|
||||
// For #16
|
||||
WorldSystem.creator.create(event.getWorldCreator(), null);
|
||||
}
|
||||
@ -375,8 +379,8 @@ public class SystemWorld {
|
||||
return w;
|
||||
}
|
||||
|
||||
public void stopCreating() {
|
||||
creating = false;
|
||||
public void setCreating(boolean creating) {
|
||||
this.creating = creating;
|
||||
}
|
||||
|
||||
public boolean isCreating() {
|
||||
|
@ -171,6 +171,8 @@ public class WorldPlayer {
|
||||
* @return if he ist the owner
|
||||
*/
|
||||
public boolean isOwnerofWorld() {
|
||||
if(!isOnSystemWorld())
|
||||
return false;
|
||||
WorldConfig wc = WorldConfig.getWorldConfig(worldname);
|
||||
return wc.getOwner().equals(p.getUniqueId());
|
||||
}
|
||||
|
@ -1,5 +1,5 @@
|
||||
name: WorldSystem
|
||||
version: 2.2.0.3
|
||||
version: 2.2.0.4
|
||||
author: Butzlabben
|
||||
main: de.butzlabben.world.WorldSystem
|
||||
loadbefore: [FastAsyncWorldEdit, WorldEdit]
|
||||
|
Loading…
Reference in New Issue
Block a user