Merge pull request 'Lazyly load owner to improve startup time' (#100) from lazy-loading into master
Reviewed-by: Chaoscaot <chaoscaot444@gmail.com>
Dieser Commit ist enthalten in:
Commit
c2e4306577
@ -20,9 +20,9 @@
|
||||
package de.steamwar.bausystem;
|
||||
|
||||
import de.steamwar.bausystem.commands.*;
|
||||
import de.steamwar.bausystem.tracer.TraceListener;
|
||||
import de.steamwar.bausystem.tracer.TNTTracer;
|
||||
import de.steamwar.bausystem.tracer.ShowManager;
|
||||
import de.steamwar.bausystem.tracer.TNTTracer;
|
||||
import de.steamwar.bausystem.tracer.TraceListener;
|
||||
import de.steamwar.bausystem.world.*;
|
||||
import de.steamwar.core.CommandRemover;
|
||||
import de.steamwar.core.Core;
|
||||
@ -68,13 +68,12 @@ public class BauSystem extends JavaPlugin implements Listener {
|
||||
String worldName = Bukkit.getWorlds().get(0).getName();
|
||||
try{
|
||||
owner = UUID.fromString(worldName);
|
||||
sections = ArenaSection.loadFromFile(new File(Bukkit.getWorldContainer().getPath() + '/' + owner.toString() + "/sections.yml"));
|
||||
sections = ArenaSection.loadFromFile(new File(Bukkit.getWorldContainer().getPath() + '/' + getOwner().toString() + "/sections.yml"));
|
||||
}catch(IllegalArgumentException e){
|
||||
try{
|
||||
int ownerID = Integer.parseInt(worldName);
|
||||
owner = SteamwarUser.get(ownerID).getUUID();
|
||||
sections = ArenaSection.loadFromFile(new File(Bukkit.getWorldContainer().getPath() + '/' + ownerID + "/sections.yml"));
|
||||
}catch(NumberFormatException | IOException | InvalidConfigurationException ex){
|
||||
owner = null;
|
||||
sections = ArenaSection.loadFromFile(new File(Bukkit.getWorldContainer().getPath() + '/' + worldName + "/sections.yml"));
|
||||
}catch(IOException | InvalidConfigurationException ex){
|
||||
getLogger().log(Level.SEVERE, "owner is no UUID / failed to load sections.yml", e);
|
||||
Bukkit.shutdown();
|
||||
return;
|
||||
@ -132,13 +131,22 @@ public class BauSystem extends JavaPlugin implements Listener {
|
||||
return plugin;
|
||||
}
|
||||
public static UUID getOwner(){
|
||||
//Lazy loading to improve startup time of the server in 1.15
|
||||
if(owner == null){
|
||||
try{
|
||||
owner = SteamwarUser.get(Integer.parseInt(Bukkit.getWorlds().get(0).getName())).getUUID();
|
||||
}catch(NumberFormatException e){
|
||||
Bukkit.shutdown();
|
||||
throw new SecurityException("owner is not a UserID", e);
|
||||
}
|
||||
}
|
||||
return owner;
|
||||
}
|
||||
public static List<ArenaSection> getSections(){
|
||||
return sections;
|
||||
}
|
||||
public static int getOwnerID(){
|
||||
return SteamwarUser.get(owner).getId();
|
||||
return SteamwarUser.get(getOwner()).getId();
|
||||
}
|
||||
|
||||
@EventHandler
|
||||
|
In neuem Issue referenzieren
Einen Benutzer sperren