mirror of
https://github.com/trainerlord/WorldSystem.git
synced 2024-12-02 13:23:21 +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.autoupdater.AutoUpdater;
|
||||||
import de.butzlabben.world.command.CommandRegistry;
|
import de.butzlabben.world.command.CommandRegistry;
|
||||||
import de.butzlabben.world.config.DependenceConfig;
|
import de.butzlabben.world.config.*;
|
||||||
import de.butzlabben.world.config.GuiConfig;
|
import de.butzlabben.world.listener.*;
|
||||||
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.util.PapiExtension;
|
import de.butzlabben.world.util.PapiExtension;
|
||||||
import de.butzlabben.world.util.PlayerPositions;
|
import de.butzlabben.world.util.PlayerPositions;
|
||||||
import de.butzlabben.world.util.VersionUtil;
|
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.AsyncCreatorAdapter;
|
||||||
import de.butzlabben.world.wrapper.CreatorAdapter;
|
import de.butzlabben.world.wrapper.CreatorAdapter;
|
||||||
import de.butzlabben.world.wrapper.SystemWorld;
|
import de.butzlabben.world.wrapper.SystemWorld;
|
||||||
import java.io.File;
|
|
||||||
import java.io.IOException;
|
|
||||||
import org.bstats.bukkit.Metrics;
|
import org.bstats.bukkit.Metrics;
|
||||||
import org.bukkit.Bukkit;
|
import org.bukkit.Bukkit;
|
||||||
import org.bukkit.World;
|
import org.bukkit.World;
|
||||||
|
|
||||||
import org.bukkit.configuration.file.YamlConfiguration;
|
import org.bukkit.configuration.file.YamlConfiguration;
|
||||||
import org.bukkit.plugin.PluginManager;
|
import org.bukkit.plugin.PluginManager;
|
||||||
import org.bukkit.plugin.java.JavaPlugin;
|
import org.bukkit.plugin.java.JavaPlugin;
|
||||||
|
|
||||||
|
import java.io.File;
|
||||||
|
import java.io.IOException;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @author Butzlabben
|
* @author Butzlabben
|
||||||
* @author Jubeki
|
* @author Jubeki
|
||||||
@ -38,6 +31,7 @@ public class WorldSystem extends JavaPlugin {
|
|||||||
private static boolean is1_13Plus = false;
|
private static boolean is1_13Plus = false;
|
||||||
final private String version = this.getDescription().getVersion();
|
final private String version = this.getDescription().getVersion();
|
||||||
private CreatorAdapter creator;
|
private CreatorAdapter creator;
|
||||||
|
|
||||||
public static void createConfigs() {
|
public static void createConfigs() {
|
||||||
File folder = getInstance().getDataFolder();
|
File folder = getInstance().getDataFolder();
|
||||||
File dir = new File(folder + "/worldsources");
|
File dir = new File(folder + "/worldsources");
|
||||||
@ -120,6 +114,7 @@ public class WorldSystem extends JavaPlugin {
|
|||||||
pm.registerEvents(new PlayerListener(), this);
|
pm.registerEvents(new PlayerListener(), this);
|
||||||
pm.registerEvents(new BlockListener(), this);
|
pm.registerEvents(new BlockListener(), this);
|
||||||
pm.registerEvents(new CommandListener(), this);
|
pm.registerEvents(new CommandListener(), this);
|
||||||
|
pm.registerEvents(new WorldInitSkipSpawn(), this);
|
||||||
if (pm.getPlugin("WorldEdit") != null)
|
if (pm.getPlugin("WorldEdit") != null)
|
||||||
pm.registerEvents(new WorldEditListener(), this);
|
pm.registerEvents(new WorldEditListener(), this);
|
||||||
|
|
||||||
@ -159,11 +154,6 @@ public class WorldSystem extends JavaPlugin {
|
|||||||
//this.getCommand("ws fire").setExecutor(new WorldFire());
|
//this.getCommand("ws fire").setExecutor(new WorldFire());
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
System.setProperty("bstats.relocatecheck", "false");
|
System.setProperty("bstats.relocatecheck", "false");
|
||||||
Metrics m = new Metrics(this);
|
Metrics m = new Metrics(this);
|
||||||
m.addCustomChart(new Metrics.SingleLineChart("worlds", DependenceConfig::getHighestID));
|
m.addCustomChart(new Metrics.SingleLineChart("worlds", DependenceConfig::getHighestID));
|
||||||
@ -171,15 +161,15 @@ 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
|
||||||
&& PluginConfig.loadWorldsASync()
|
&& PluginConfig.loadWorldsASync()
|
||||||
&& !is1_13Plus) {*/
|
&& !is1_13Plus) {
|
||||||
try{
|
|
||||||
creator = new AsyncCreatorAdapter();
|
creator = new AsyncCreatorAdapter();
|
||||||
Bukkit.getConsoleSender()
|
Bukkit.getConsoleSender()
|
||||||
.sendMessage(PluginConfig.getPrefix() + "Found FAWE! Worlds now will be created asynchronously");
|
.sendMessage(PluginConfig.getPrefix() + "Found FAWE! Worlds now will be created asynchronously");
|
||||||
}catch(Exception e) {
|
} else {
|
||||||
creator = (c, sw, r) -> {
|
creator = (c, sw, r) -> {
|
||||||
Bukkit.getWorlds().add(c.createWorld());
|
Bukkit.getWorlds().add(c.createWorld());
|
||||||
if (sw != null)
|
if (sw != null)
|
||||||
|
@ -79,7 +79,8 @@ public class CommandRegistry implements CommandExecutor {
|
|||||||
case "fire":
|
case "fire":
|
||||||
return settings.fireCommand(sender, command, label, args);
|
return settings.fireCommand(sender, command, label, args);
|
||||||
default:
|
default:
|
||||||
return false;
|
//default command is better than the other one
|
||||||
|
return ws.mainCommand(sender, command, label, args);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -140,7 +140,10 @@ public class WorldAdministrateCommand {
|
|||||||
}
|
}
|
||||||
|
|
||||||
public boolean addMemberCommand(CommandSender sender, Command command, String label, String[] args) {
|
public boolean addMemberCommand(CommandSender sender, Command command, String label, String[] args) {
|
||||||
if (sender instanceof Player) {
|
if (!(sender instanceof Player)) {
|
||||||
|
sender.sendMessage("No Console"); //TODO Get Config
|
||||||
|
return false;
|
||||||
|
}
|
||||||
Player p = (Player) sender;
|
Player p = (Player) sender;
|
||||||
if (args.length < 2) {
|
if (args.length < 2) {
|
||||||
p.sendMessage(MessageConfig.getWrongUsage().replaceAll("%usage", "/ws addmember <Player>"));
|
p.sendMessage(MessageConfig.getWrongUsage().replaceAll("%usage", "/ws addmember <Player>"));
|
||||||
@ -177,10 +180,7 @@ public class WorldAdministrateCommand {
|
|||||||
}
|
}
|
||||||
p.sendMessage(MessageConfig.getMemberAdded().replaceAll("%player", a.getName()));
|
p.sendMessage(MessageConfig.getMemberAdded().replaceAll("%player", a.getName()));
|
||||||
return true;
|
return true;
|
||||||
} else {
|
|
||||||
sender.sendMessage("No Console"); //TODO Get Config
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public boolean toggleTeleportCommand(CommandSender sender, Command command, String label, String[] args) {
|
public boolean toggleTeleportCommand(CommandSender sender, Command command, String label, String[] args) {
|
||||||
@ -196,7 +196,6 @@ public class WorldAdministrateCommand {
|
|||||||
p.sendMessage(MessageConfig.getNoWorldOwn());
|
p.sendMessage(MessageConfig.getNoWorldOwn());
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
@SuppressWarnings("deprecation")
|
|
||||||
OfflinePlayer a = PlayerWrapper.getOfflinePlayer(args[1]);
|
OfflinePlayer a = PlayerWrapper.getOfflinePlayer(args[1]);
|
||||||
WorldConfig wc = WorldConfig.getWorldConfig(dc.getWorldname());
|
WorldConfig wc = WorldConfig.getWorldConfig(dc.getWorldname());
|
||||||
if (!wc.isMember(a.getUniqueId())) {
|
if (!wc.isMember(a.getUniqueId())) {
|
||||||
|
@ -1,5 +1,6 @@
|
|||||||
package de.butzlabben.world.config;
|
package de.butzlabben.world.config;
|
||||||
|
|
||||||
|
import de.butzlabben.world.util.PlayerWrapper;
|
||||||
import org.bukkit.Bukkit;
|
import org.bukkit.Bukkit;
|
||||||
import org.bukkit.OfflinePlayer;
|
import org.bukkit.OfflinePlayer;
|
||||||
import org.bukkit.configuration.file.YamlConfiguration;
|
import org.bukkit.configuration.file.YamlConfiguration;
|
||||||
@ -17,7 +18,6 @@ public class DependenceConfig {
|
|||||||
setConfig();
|
setConfig();
|
||||||
}
|
}
|
||||||
|
|
||||||
@SuppressWarnings("deprecation")
|
|
||||||
public DependenceConfig(String s) {
|
public DependenceConfig(String s) {
|
||||||
OfflinePlayer op = null;
|
OfflinePlayer op = null;
|
||||||
try {
|
try {
|
||||||
|
@ -3,6 +3,7 @@ package de.butzlabben.world.config;
|
|||||||
import com.google.common.collect.Sets;
|
import com.google.common.collect.Sets;
|
||||||
import com.mojang.authlib.GameProfile;
|
import com.mojang.authlib.GameProfile;
|
||||||
import de.butzlabben.world.GameProfileBuilder;
|
import de.butzlabben.world.GameProfileBuilder;
|
||||||
|
import de.butzlabben.world.util.PlayerWrapper;
|
||||||
import de.butzlabben.world.wrapper.WorldTemplate;
|
import de.butzlabben.world.wrapper.WorldTemplate;
|
||||||
import java.io.File;
|
import java.io.File;
|
||||||
import java.io.IOException;
|
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.GamemodeStatus;
|
||||||
import de.butzlabben.world.gui.playeroption.TeleportStatus;
|
import de.butzlabben.world.gui.playeroption.TeleportStatus;
|
||||||
import de.butzlabben.world.gui.playeroption.WorldEditStatus;
|
import de.butzlabben.world.gui.playeroption.WorldEditStatus;
|
||||||
|
import de.butzlabben.world.util.PlayerWrapper;
|
||||||
import de.butzlabben.world.wrapper.WorldPlayer;
|
import de.butzlabben.world.wrapper.WorldPlayer;
|
||||||
import org.bukkit.Bukkit;
|
import org.bukkit.Bukkit;
|
||||||
import org.bukkit.entity.Player;
|
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.PluginConfig;
|
||||||
import de.butzlabben.world.config.WorldConfig;
|
import de.butzlabben.world.config.WorldConfig;
|
||||||
import de.butzlabben.world.util.PlayerPositions;
|
import de.butzlabben.world.util.PlayerPositions;
|
||||||
|
import de.butzlabben.world.util.PlayerWrapper;
|
||||||
import de.butzlabben.world.wrapper.SystemWorld;
|
import de.butzlabben.world.wrapper.SystemWorld;
|
||||||
import de.butzlabben.world.wrapper.WorldPlayer;
|
import de.butzlabben.world.wrapper.WorldPlayer;
|
||||||
import java.util.HashMap;
|
import java.util.HashMap;
|
||||||
@ -25,6 +26,7 @@ public class PlayerListener implements Listener {
|
|||||||
//#17
|
//#17
|
||||||
@EventHandler(priority = EventPriority.HIGHEST)
|
@EventHandler(priority = EventPriority.HIGHEST)
|
||||||
public void onJoin(PlayerJoinEvent e) {
|
public void onJoin(PlayerJoinEvent e) {
|
||||||
|
PlayerWrapper.updateDatabase(e.getPlayer());
|
||||||
if (PluginConfig.spawnTeleportation()) {
|
if (PluginConfig.spawnTeleportation()) {
|
||||||
Player p = e.getPlayer();
|
Player p = e.getPlayer();
|
||||||
DependenceConfig dc = new DependenceConfig(p);
|
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;
|
package de.butzlabben.world.util;
|
||||||
|
|
||||||
import com.google.common.base.Preconditions;
|
import com.google.common.base.Preconditions;
|
||||||
|
import com.sk89q.worldedit.bukkit.BukkitPlayer;
|
||||||
import de.butzlabben.world.config.PluginConfig;
|
import de.butzlabben.world.config.PluginConfig;
|
||||||
import de.butzlabben.world.util.database.DatabaseProvider;
|
import de.butzlabben.world.util.database.DatabaseProvider;
|
||||||
import de.butzlabben.world.util.database.DatabaseUtil;
|
import de.butzlabben.world.util.database.DatabaseUtil;
|
||||||
@ -80,17 +81,17 @@ public class PlayerWrapper {
|
|||||||
public static OfflinePlayer getOfflinePlayer(String name) {
|
public static OfflinePlayer getOfflinePlayer(String name) {
|
||||||
Player player = Bukkit.getPlayer(name);
|
Player player = Bukkit.getPlayer(name);
|
||||||
if(player != null)
|
if(player != null)
|
||||||
return PlayerWrapper.getOfflinePlayer(player.getUniqueId());
|
return Bukkit.getOfflinePlayer(player.getUniqueId());
|
||||||
|
|
||||||
UUID uuid = PlayerWrapper.getUUID(name);
|
UUID uuid = PlayerWrapper.getUUID(name);
|
||||||
if(uuid != null)
|
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) {
|
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
|
// Create worlds async to close #16
|
||||||
@Override
|
@Override
|
||||||
public void create(WorldCreator creator, SystemWorld sw, Runnable r) {
|
public void create(WorldCreator creator, SystemWorld sw, Runnable r) {
|
||||||
|
|
||||||
|
|
||||||
TaskManager.IMP.async(() -> {
|
TaskManager.IMP.async(() -> {
|
||||||
AsyncWorld world;
|
AsyncWorld world;
|
||||||
if (Bukkit.getWorld(creator.name()) == null)
|
if (Bukkit.getWorld(creator.name()) == null)
|
||||||
|
@ -63,6 +63,9 @@ database:
|
|||||||
worlds_table_name: worlds_positions
|
worlds_table_name: worlds_positions
|
||||||
# How the table with the saved player positions on the normal worlds should be named
|
# How the table with the saved player positions on the normal worlds should be named
|
||||||
players_table_name: player_positions
|
players_table_name: player_positions
|
||||||
|
# how should the uuid cache be stored
|
||||||
|
players_uuids: players_uuids
|
||||||
|
|
||||||
# Configure here your mysql connection
|
# Configure here your mysql connection
|
||||||
mysql_settings:
|
mysql_settings:
|
||||||
host: 127.0.0.1
|
host: 127.0.0.1
|
||||||
|
Loading…
Reference in New Issue
Block a user