mirror of
https://github.com/trainerlord/WorldSystem.git
synced 2024-10-31 08:28:52 +01:00
+ added player uuid caching
+ added extreme paper speedup on sync mode, by disabling the chunk loading
This commit is contained in:
parent
27b90b7343
commit
0e180a0d50
@ -2,15 +2,8 @@ package de.butzlabben.world;
|
||||
|
||||
import de.butzlabben.world.autoupdater.AutoUpdater;
|
||||
import de.butzlabben.world.command.CommandRegistry;
|
||||
import de.butzlabben.world.config.DependenceConfig;
|
||||
import de.butzlabben.world.config.GuiConfig;
|
||||
import de.butzlabben.world.config.MessageConfig;
|
||||
import de.butzlabben.world.config.PluginConfig;
|
||||
import de.butzlabben.world.config.SettingsConfig;
|
||||
import de.butzlabben.world.listener.BlockListener;
|
||||
import de.butzlabben.world.listener.CommandListener;
|
||||
import de.butzlabben.world.listener.PlayerListener;
|
||||
import de.butzlabben.world.listener.WorldEditListener;
|
||||
import de.butzlabben.world.config.*;
|
||||
import de.butzlabben.world.listener.*;
|
||||
import de.butzlabben.world.util.PapiExtension;
|
||||
import de.butzlabben.world.util.PlayerPositions;
|
||||
import de.butzlabben.world.util.VersionUtil;
|
||||
@ -18,16 +11,16 @@ import de.butzlabben.world.util.database.DatabaseProvider;
|
||||
import de.butzlabben.world.wrapper.AsyncCreatorAdapter;
|
||||
import de.butzlabben.world.wrapper.CreatorAdapter;
|
||||
import de.butzlabben.world.wrapper.SystemWorld;
|
||||
import java.io.File;
|
||||
import java.io.IOException;
|
||||
import org.bstats.bukkit.Metrics;
|
||||
import org.bukkit.Bukkit;
|
||||
import org.bukkit.World;
|
||||
|
||||
import org.bukkit.configuration.file.YamlConfiguration;
|
||||
import org.bukkit.plugin.PluginManager;
|
||||
import org.bukkit.plugin.java.JavaPlugin;
|
||||
|
||||
import java.io.File;
|
||||
import java.io.IOException;
|
||||
|
||||
/**
|
||||
* @author Butzlabben
|
||||
* @author Jubeki
|
||||
@ -38,6 +31,7 @@ public class WorldSystem extends JavaPlugin {
|
||||
private static boolean is1_13Plus = false;
|
||||
final private String version = this.getDescription().getVersion();
|
||||
private CreatorAdapter creator;
|
||||
|
||||
public static void createConfigs() {
|
||||
File folder = getInstance().getDataFolder();
|
||||
File dir = new File(folder + "/worldsources");
|
||||
@ -120,6 +114,7 @@ public class WorldSystem extends JavaPlugin {
|
||||
pm.registerEvents(new PlayerListener(), this);
|
||||
pm.registerEvents(new BlockListener(), this);
|
||||
pm.registerEvents(new CommandListener(), this);
|
||||
pm.registerEvents(new WorldInitSkipSpawn(), this);
|
||||
if (pm.getPlugin("WorldEdit") != null)
|
||||
pm.registerEvents(new WorldEditListener(), this);
|
||||
|
||||
@ -159,11 +154,6 @@ public class WorldSystem extends JavaPlugin {
|
||||
//this.getCommand("ws fire").setExecutor(new WorldFire());
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
System.setProperty("bstats.relocatecheck", "false");
|
||||
Metrics m = new Metrics(this);
|
||||
m.addCustomChart(new Metrics.SingleLineChart("worlds", DependenceConfig::getHighestID));
|
||||
@ -171,15 +161,15 @@ public class WorldSystem extends JavaPlugin {
|
||||
AutoUpdater.startAsync();
|
||||
|
||||
// Choose right creatoradapter for #16
|
||||
/*if (Bukkit.getPluginManager().getPlugin("FastAsyncWorldEdit") != null
|
||||
if (Bukkit.getPluginManager().getPlugin("FastAsyncWorldEdit") != null
|
||||
&& Bukkit.getPluginManager().getPlugin("WorldEdit") != null
|
||||
&& PluginConfig.loadWorldsASync()
|
||||
&& !is1_13Plus) {*/
|
||||
try{
|
||||
&& !is1_13Plus) {
|
||||
|
||||
creator = new AsyncCreatorAdapter();
|
||||
Bukkit.getConsoleSender()
|
||||
.sendMessage(PluginConfig.getPrefix() + "Found FAWE! Worlds now will be created asynchronously");
|
||||
}catch(Exception e) {
|
||||
} else {
|
||||
creator = (c, sw, r) -> {
|
||||
Bukkit.getWorlds().add(c.createWorld());
|
||||
if (sw != null)
|
||||
|
@ -79,7 +79,8 @@ public class CommandRegistry implements CommandExecutor {
|
||||
case "fire":
|
||||
return settings.fireCommand(sender, command, label, args);
|
||||
default:
|
||||
return false;
|
||||
//default command is better than the other one
|
||||
return ws.mainCommand(sender, command, label, args);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -28,48 +28,48 @@ public class WorldAdministrateCommand {
|
||||
public boolean delMemberCommand(CommandSender sender, Command command, String label, String[] args) {
|
||||
if (sender instanceof Player) {
|
||||
Player p = (Player) sender;
|
||||
if (args.length < 2) {
|
||||
p.sendMessage(MessageConfig.getWrongUsage().replaceAll("%usage", "/ws delmember <Player>"));
|
||||
return false;
|
||||
}
|
||||
|
||||
DependenceConfig dc = new DependenceConfig(p);
|
||||
if (!dc.hasWorld()) {
|
||||
p.sendMessage(MessageConfig.getNoWorldOwn());
|
||||
return false;
|
||||
}
|
||||
|
||||
@SuppressWarnings("deprecation")
|
||||
OfflinePlayer a = PlayerWrapper.getOfflinePlayer(args[1]);
|
||||
WorldConfig wc = WorldConfig.getWorldConfig(dc.getWorldname());
|
||||
if (a == null) {
|
||||
p.sendMessage(MessageConfig.getNotRegistered().replaceAll("%player", args[1]));
|
||||
return false;
|
||||
} else if (!wc.isMember(a.getUniqueId())) {
|
||||
p.sendMessage(MessageConfig.getNoMemberOwn());
|
||||
return false;
|
||||
}
|
||||
WorldRemovememberEvent event = new WorldRemovememberEvent(a.getUniqueId(), dc.getWorldname(), p);
|
||||
Bukkit.getPluginManager().callEvent(event);
|
||||
if (event.isCancelled())
|
||||
return false;
|
||||
|
||||
if (a.isOnline()) {
|
||||
Player t = (Player) a;
|
||||
if (t.getWorld().getName().equals(new DependenceConfig(p).getWorldname())) {
|
||||
t.teleport(PluginConfig.getSpawn(t));
|
||||
t.setGameMode(PluginConfig.getSpawnGamemode());
|
||||
if (args.length < 2) {
|
||||
p.sendMessage(MessageConfig.getWrongUsage().replaceAll("%usage", "/ws delmember <Player>"));
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
wc.removeMember(a.getUniqueId());
|
||||
try {
|
||||
wc.save();
|
||||
} catch (IOException e) {
|
||||
p.sendMessage(MessageConfig.getUnknownError());
|
||||
e.printStackTrace();
|
||||
}
|
||||
p.sendMessage(MessageConfig.getMemberRemoved().replaceAll("%player", a.getName()));
|
||||
DependenceConfig dc = new DependenceConfig(p);
|
||||
if (!dc.hasWorld()) {
|
||||
p.sendMessage(MessageConfig.getNoWorldOwn());
|
||||
return false;
|
||||
}
|
||||
|
||||
@SuppressWarnings("deprecation")
|
||||
OfflinePlayer a = PlayerWrapper.getOfflinePlayer(args[1]);
|
||||
WorldConfig wc = WorldConfig.getWorldConfig(dc.getWorldname());
|
||||
if (a == null) {
|
||||
p.sendMessage(MessageConfig.getNotRegistered().replaceAll("%player", args[1]));
|
||||
return false;
|
||||
} else if (!wc.isMember(a.getUniqueId())) {
|
||||
p.sendMessage(MessageConfig.getNoMemberOwn());
|
||||
return false;
|
||||
}
|
||||
WorldRemovememberEvent event = new WorldRemovememberEvent(a.getUniqueId(), dc.getWorldname(), p);
|
||||
Bukkit.getPluginManager().callEvent(event);
|
||||
if (event.isCancelled())
|
||||
return false;
|
||||
|
||||
if (a.isOnline()) {
|
||||
Player t = (Player) a;
|
||||
if (t.getWorld().getName().equals(new DependenceConfig(p).getWorldname())) {
|
||||
t.teleport(PluginConfig.getSpawn(t));
|
||||
t.setGameMode(PluginConfig.getSpawnGamemode());
|
||||
}
|
||||
}
|
||||
|
||||
wc.removeMember(a.getUniqueId());
|
||||
try {
|
||||
wc.save();
|
||||
} catch (IOException e) {
|
||||
p.sendMessage(MessageConfig.getUnknownError());
|
||||
e.printStackTrace();
|
||||
}
|
||||
p.sendMessage(MessageConfig.getMemberRemoved().replaceAll("%player", a.getName()));
|
||||
return true;
|
||||
} else {
|
||||
sender.sendMessage("No Console"); //TODO Get Config
|
||||
@ -140,8 +140,11 @@ public class WorldAdministrateCommand {
|
||||
}
|
||||
|
||||
public boolean addMemberCommand(CommandSender sender, Command command, String label, String[] args) {
|
||||
if (sender instanceof Player) {
|
||||
Player p = (Player) sender;
|
||||
if (!(sender instanceof Player)) {
|
||||
sender.sendMessage("No Console"); //TODO Get Config
|
||||
return false;
|
||||
}
|
||||
Player p = (Player) sender;
|
||||
if (args.length < 2) {
|
||||
p.sendMessage(MessageConfig.getWrongUsage().replaceAll("%usage", "/ws addmember <Player>"));
|
||||
return false;
|
||||
@ -176,11 +179,8 @@ public class WorldAdministrateCommand {
|
||||
e.printStackTrace();
|
||||
}
|
||||
p.sendMessage(MessageConfig.getMemberAdded().replaceAll("%player", a.getName()));
|
||||
return true;
|
||||
} else {
|
||||
sender.sendMessage("No Console"); //TODO Get Config
|
||||
return false;
|
||||
}
|
||||
return true;
|
||||
|
||||
}
|
||||
|
||||
public boolean toggleTeleportCommand(CommandSender sender, Command command, String label, String[] args) {
|
||||
@ -196,7 +196,6 @@ public class WorldAdministrateCommand {
|
||||
p.sendMessage(MessageConfig.getNoWorldOwn());
|
||||
return false;
|
||||
}
|
||||
@SuppressWarnings("deprecation")
|
||||
OfflinePlayer a = PlayerWrapper.getOfflinePlayer(args[1]);
|
||||
WorldConfig wc = WorldConfig.getWorldConfig(dc.getWorldname());
|
||||
if (!wc.isMember(a.getUniqueId())) {
|
||||
@ -223,33 +222,33 @@ public class WorldAdministrateCommand {
|
||||
public boolean toggleGamemodeCommand(CommandSender sender, Command command, String label, String[] args) {
|
||||
if (sender instanceof Player) {
|
||||
Player p = (Player) sender;
|
||||
if (args.length < 2) {
|
||||
p.sendMessage(MessageConfig.getWrongUsage().replaceAll("%usage", "/ws togglegm <Player>"));
|
||||
return false;
|
||||
}
|
||||
if (args.length < 2) {
|
||||
p.sendMessage(MessageConfig.getWrongUsage().replaceAll("%usage", "/ws togglegm <Player>"));
|
||||
return false;
|
||||
}
|
||||
|
||||
DependenceConfig dc = new DependenceConfig(p);
|
||||
if (!dc.hasWorld()) {
|
||||
p.sendMessage(MessageConfig.getNoWorldOwn());
|
||||
return false;
|
||||
}
|
||||
@SuppressWarnings("deprecation")
|
||||
OfflinePlayer a = PlayerWrapper.getOfflinePlayer(args[1]);
|
||||
WorldConfig wc = WorldConfig.getWorldConfig(dc.getWorldname());
|
||||
if (!wc.isMember(a.getUniqueId())) {
|
||||
p.sendMessage(MessageConfig.getNoMemberOwn());
|
||||
return false;
|
||||
}
|
||||
WorldPlayer wp = new WorldPlayer(a, dc.getWorldname());
|
||||
if (wp.isOwnerofWorld()) {
|
||||
p.sendMessage(PluginConfig.getPrefix() + "§cYou are the owner");
|
||||
return false;
|
||||
}
|
||||
if (wp.toggleGamemode()) {
|
||||
p.sendMessage(MessageConfig.getToggleGameModeEnabled().replaceAll("%player", a.getName()));
|
||||
} else {
|
||||
p.sendMessage(MessageConfig.getToggleGameModeDisabled().replaceAll("%player", a.getName()));
|
||||
}
|
||||
DependenceConfig dc = new DependenceConfig(p);
|
||||
if (!dc.hasWorld()) {
|
||||
p.sendMessage(MessageConfig.getNoWorldOwn());
|
||||
return false;
|
||||
}
|
||||
@SuppressWarnings("deprecation")
|
||||
OfflinePlayer a = PlayerWrapper.getOfflinePlayer(args[1]);
|
||||
WorldConfig wc = WorldConfig.getWorldConfig(dc.getWorldname());
|
||||
if (!wc.isMember(a.getUniqueId())) {
|
||||
p.sendMessage(MessageConfig.getNoMemberOwn());
|
||||
return false;
|
||||
}
|
||||
WorldPlayer wp = new WorldPlayer(a, dc.getWorldname());
|
||||
if (wp.isOwnerofWorld()) {
|
||||
p.sendMessage(PluginConfig.getPrefix() + "§cYou are the owner");
|
||||
return false;
|
||||
}
|
||||
if (wp.toggleGamemode()) {
|
||||
p.sendMessage(MessageConfig.getToggleGameModeEnabled().replaceAll("%player", a.getName()));
|
||||
} else {
|
||||
p.sendMessage(MessageConfig.getToggleGameModeDisabled().replaceAll("%player", a.getName()));
|
||||
}
|
||||
return true;
|
||||
} else {
|
||||
sender.sendMessage("No Console"); //TODO Get Config
|
||||
@ -295,8 +294,8 @@ public class WorldAdministrateCommand {
|
||||
}
|
||||
|
||||
public boolean toggleBuildCommand(CommandSender sender, Command command, String label, String[] args) {
|
||||
if (sender instanceof Player) {
|
||||
Player p = (Player) sender;
|
||||
if (sender instanceof Player) {
|
||||
Player p = (Player) sender;
|
||||
if (args.length < 2) {
|
||||
p.sendMessage(MessageConfig.getWrongUsage().replaceAll("%usage", "/ws togglebuild <Player>"));
|
||||
return false;
|
||||
@ -324,10 +323,10 @@ public class WorldAdministrateCommand {
|
||||
} else {
|
||||
p.sendMessage(MessageConfig.getToggleBuildDisabled().replaceAll("%player", a.getName()));
|
||||
}
|
||||
return true;
|
||||
} else {
|
||||
sender.sendMessage("No Console"); //TODO Get Config
|
||||
return false;
|
||||
}
|
||||
return true;
|
||||
} else {
|
||||
sender.sendMessage("No Console"); //TODO Get Config
|
||||
return false;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -1,5 +1,6 @@
|
||||
package de.butzlabben.world.config;
|
||||
|
||||
import de.butzlabben.world.util.PlayerWrapper;
|
||||
import org.bukkit.Bukkit;
|
||||
import org.bukkit.OfflinePlayer;
|
||||
import org.bukkit.configuration.file.YamlConfiguration;
|
||||
@ -17,7 +18,6 @@ public class DependenceConfig {
|
||||
setConfig();
|
||||
}
|
||||
|
||||
@SuppressWarnings("deprecation")
|
||||
public DependenceConfig(String s) {
|
||||
OfflinePlayer op = null;
|
||||
try {
|
||||
|
@ -3,6 +3,7 @@ package de.butzlabben.world.config;
|
||||
import com.google.common.collect.Sets;
|
||||
import com.mojang.authlib.GameProfile;
|
||||
import de.butzlabben.world.GameProfileBuilder;
|
||||
import de.butzlabben.world.util.PlayerWrapper;
|
||||
import de.butzlabben.world.wrapper.WorldTemplate;
|
||||
import java.io.File;
|
||||
import java.io.IOException;
|
||||
|
@ -10,6 +10,7 @@ import de.butzlabben.world.gui.playeroption.BuildStatus;
|
||||
import de.butzlabben.world.gui.playeroption.GamemodeStatus;
|
||||
import de.butzlabben.world.gui.playeroption.TeleportStatus;
|
||||
import de.butzlabben.world.gui.playeroption.WorldEditStatus;
|
||||
import de.butzlabben.world.util.PlayerWrapper;
|
||||
import de.butzlabben.world.wrapper.WorldPlayer;
|
||||
import org.bukkit.Bukkit;
|
||||
import org.bukkit.entity.Player;
|
||||
|
@ -4,6 +4,7 @@ import de.butzlabben.world.config.DependenceConfig;
|
||||
import de.butzlabben.world.config.PluginConfig;
|
||||
import de.butzlabben.world.config.WorldConfig;
|
||||
import de.butzlabben.world.util.PlayerPositions;
|
||||
import de.butzlabben.world.util.PlayerWrapper;
|
||||
import de.butzlabben.world.wrapper.SystemWorld;
|
||||
import de.butzlabben.world.wrapper.WorldPlayer;
|
||||
import java.util.HashMap;
|
||||
@ -25,6 +26,7 @@ public class PlayerListener implements Listener {
|
||||
//#17
|
||||
@EventHandler(priority = EventPriority.HIGHEST)
|
||||
public void onJoin(PlayerJoinEvent e) {
|
||||
PlayerWrapper.updateDatabase(e.getPlayer());
|
||||
if (PluginConfig.spawnTeleportation()) {
|
||||
Player p = e.getPlayer();
|
||||
DependenceConfig dc = new DependenceConfig(p);
|
||||
|
@ -0,0 +1,26 @@
|
||||
package de.butzlabben.world.listener;
|
||||
|
||||
import de.butzlabben.world.config.WorldConfig;
|
||||
import de.butzlabben.world.wrapper.WorldPlayer;
|
||||
import org.bukkit.entity.Player;
|
||||
import org.bukkit.event.EventHandler;
|
||||
import org.bukkit.event.Listener;
|
||||
import org.bukkit.event.block.BlockBreakEvent;
|
||||
import org.bukkit.event.block.BlockBurnEvent;
|
||||
import org.bukkit.event.block.BlockIgniteEvent;
|
||||
import org.bukkit.event.block.BlockPlaceEvent;
|
||||
import org.bukkit.event.entity.EntityExplodeEvent;
|
||||
import org.bukkit.event.player.PlayerBucketEmptyEvent;
|
||||
import org.bukkit.event.world.WorldInitEvent;
|
||||
|
||||
import java.io.File;
|
||||
import java.util.Objects;
|
||||
|
||||
public class WorldInitSkipSpawn implements Listener {
|
||||
|
||||
@EventHandler
|
||||
public void worldInit(WorldInitEvent e) {
|
||||
e.getWorld().setKeepSpawnInMemory(false);
|
||||
}
|
||||
|
||||
}
|
@ -1,6 +1,7 @@
|
||||
package de.butzlabben.world.util;
|
||||
|
||||
import com.google.common.base.Preconditions;
|
||||
import com.sk89q.worldedit.bukkit.BukkitPlayer;
|
||||
import de.butzlabben.world.config.PluginConfig;
|
||||
import de.butzlabben.world.util.database.DatabaseProvider;
|
||||
import de.butzlabben.world.util.database.DatabaseUtil;
|
||||
@ -80,17 +81,17 @@ public class PlayerWrapper {
|
||||
public static OfflinePlayer getOfflinePlayer(String name) {
|
||||
Player player = Bukkit.getPlayer(name);
|
||||
if(player != null)
|
||||
return PlayerWrapper.getOfflinePlayer(player.getUniqueId());
|
||||
return Bukkit.getOfflinePlayer(player.getUniqueId());
|
||||
|
||||
UUID uuid = PlayerWrapper.getUUID(name);
|
||||
if(uuid != null)
|
||||
return PlayerWrapper.getOfflinePlayer(uuid);
|
||||
return Bukkit.getOfflinePlayer(uuid);
|
||||
|
||||
return PlayerWrapper.getOfflinePlayer(name);
|
||||
return Bukkit.getOfflinePlayer(name);
|
||||
}
|
||||
|
||||
public static OfflinePlayer getOfflinePlayer(UUID uuid) {
|
||||
return PlayerWrapper.getOfflinePlayer(uuid);
|
||||
return Bukkit.getOfflinePlayer(uuid);
|
||||
}
|
||||
|
||||
|
||||
|
@ -18,6 +18,8 @@ public class AsyncCreatorAdapter implements CreatorAdapter {
|
||||
// Create worlds async to close #16
|
||||
@Override
|
||||
public void create(WorldCreator creator, SystemWorld sw, Runnable r) {
|
||||
|
||||
|
||||
TaskManager.IMP.async(() -> {
|
||||
AsyncWorld world;
|
||||
if (Bukkit.getWorld(creator.name()) == null)
|
||||
|
@ -63,6 +63,9 @@ database:
|
||||
worlds_table_name: worlds_positions
|
||||
# How the table with the saved player positions on the normal worlds should be named
|
||||
players_table_name: player_positions
|
||||
# how should the uuid cache be stored
|
||||
players_uuids: players_uuids
|
||||
|
||||
# Configure here your mysql connection
|
||||
mysql_settings:
|
||||
host: 127.0.0.1
|
||||
|
Loading…
Reference in New Issue
Block a user