minor optimizations
This commit is contained in:
parent
bb5a90b390
commit
bcdad0739d
@ -32,7 +32,10 @@ public class HubThat extends JavaPlugin
|
|||||||
public UpdateChecker updateChecker;
|
public UpdateChecker updateChecker;
|
||||||
private static HubThat instance;
|
private static HubThat instance;
|
||||||
|
|
||||||
public HubThat() { instance = this; }
|
public HubThat()
|
||||||
|
{
|
||||||
|
instance = this;
|
||||||
|
}
|
||||||
|
|
||||||
// Method called when the plugin is being loaded.
|
// Method called when the plugin is being loaded.
|
||||||
@Override
|
@Override
|
||||||
@ -57,7 +60,7 @@ public class HubThat extends JavaPlugin
|
|||||||
SetSpawnCommand setSpawnCommandInstance = new SetSpawnCommand(this);
|
SetSpawnCommand setSpawnCommandInstance = new SetSpawnCommand(this);
|
||||||
WorldListCommand worldListCommandInstance = new WorldListCommand(this);
|
WorldListCommand worldListCommandInstance = new WorldListCommand(this);
|
||||||
WorldTpCommand worldTpCommandInstance = new WorldTpCommand(this);
|
WorldTpCommand worldTpCommandInstance = new WorldTpCommand(this);
|
||||||
|
|
||||||
// We need to instantiate Utils classes because they need to access plugin data and server.
|
// We need to instantiate Utils classes because they need to access plugin data and server.
|
||||||
TeleportUtils teleportUtilsInstance = new TeleportUtils(this);
|
TeleportUtils teleportUtilsInstance = new TeleportUtils(this);
|
||||||
UpdateChecker updateCheckerInstance = new UpdateChecker(this);
|
UpdateChecker updateCheckerInstance = new UpdateChecker(this);
|
||||||
@ -72,7 +75,6 @@ public class HubThat extends JavaPlugin
|
|||||||
pluginManager.registerEvents(new PlayerRespawnListener(this), this);
|
pluginManager.registerEvents(new PlayerRespawnListener(this), this);
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
debugger.sendDebugMessage(Level.INFO, "Done registering listeners!");
|
debugger.sendDebugMessage(Level.INFO, "Done registering listeners!");
|
||||||
|
|
||||||
// Register Commands
|
// Register Commands
|
||||||
@ -112,9 +114,9 @@ public class HubThat extends JavaPlugin
|
|||||||
FileUtils.reloadYamls();
|
FileUtils.reloadYamls();
|
||||||
debugger.sendDebugMessage(Level.INFO, "Done!");
|
debugger.sendDebugMessage(Level.INFO, "Done!");
|
||||||
|
|
||||||
debugger.sendDebugMessage(Level.INFO,"Setting up Metrics...");
|
debugger.sendDebugMessage(Level.INFO, "Setting up Metrics...");
|
||||||
setupMetrics();
|
setupMetrics();
|
||||||
debugger.sendDebugMessage(Level.INFO,"Done setting up Metrics!");
|
debugger.sendDebugMessage(Level.INFO, "Done setting up Metrics!");
|
||||||
|
|
||||||
// Send success output message to console.
|
// Send success output message to console.
|
||||||
logger.log(Level.INFO, "Plugin " + getDescription().getName() + " Successfully Loaded!");
|
logger.log(Level.INFO, "Plugin " + getDescription().getName() + " Successfully Loaded!");
|
||||||
@ -124,7 +126,8 @@ public class HubThat extends JavaPlugin
|
|||||||
|
|
||||||
// Method called when the plugin is being unloaded.
|
// Method called when the plugin is being unloaded.
|
||||||
@Override
|
@Override
|
||||||
public void onDisable() {
|
public void onDisable()
|
||||||
|
{
|
||||||
debugger.sendDebugMessage(Level.WARNING, "---[ DEBUGGER IS ENABLED! ]---");
|
debugger.sendDebugMessage(Level.WARNING, "---[ DEBUGGER IS ENABLED! ]---");
|
||||||
debugger.sendDebugMessage(Level.WARNING, "---[ DISABLING PLUGIN ]---");
|
debugger.sendDebugMessage(Level.WARNING, "---[ DISABLING PLUGIN ]---");
|
||||||
getServer().getScheduler().cancelTasks(this);
|
getServer().getScheduler().cancelTasks(this);
|
||||||
@ -145,7 +148,7 @@ public class HubThat extends JavaPlugin
|
|||||||
metrics.addCustomChart(new Metrics.SimplePie("tp-hub-on-join", () -> config.getString(ConfigEntries.TELEPORTATION_TP_HUB_ON_JOIN.path)));
|
metrics.addCustomChart(new Metrics.SimplePie("tp-hub-on-join", () -> config.getString(ConfigEntries.TELEPORTATION_TP_HUB_ON_JOIN.path)));
|
||||||
metrics.addCustomChart(new Metrics.SimplePie("tp-hub-on-respawn", () -> config.getString(ConfigEntries.TELEPORTATION_TP_HUB_ON_RESPAWN.path)));
|
metrics.addCustomChart(new Metrics.SimplePie("tp-hub-on-respawn", () -> config.getString(ConfigEntries.TELEPORTATION_TP_HUB_ON_RESPAWN.path)));
|
||||||
|
|
||||||
if(config.getBoolean(ConfigEntries.GAMEMODE_SET_ON_JOIN.path))
|
if (config.getBoolean(ConfigEntries.GAMEMODE_SET_ON_JOIN.path))
|
||||||
{
|
{
|
||||||
metrics.addCustomChart(new Metrics.SimplePie("join-gamemode", () -> config.getString(ConfigEntries.GAMEMODE.path)));
|
metrics.addCustomChart(new Metrics.SimplePie("join-gamemode", () -> config.getString(ConfigEntries.GAMEMODE.path)));
|
||||||
}
|
}
|
||||||
|
@ -137,15 +137,13 @@ public class HubCommand implements CommandExecutor
|
|||||||
}
|
}
|
||||||
|
|
||||||
// Method to teleport the player to the hub.
|
// Method to teleport the player to the hub.
|
||||||
public static void teleportToHub(CommandSender sender, Player player)
|
public static void teleportToHub(CommandSender actor, Player player)
|
||||||
{
|
{
|
||||||
String username = player.getName();
|
String username = player.getName();
|
||||||
|
|
||||||
// Require the world to be Non Null
|
|
||||||
String worldName = Objects.requireNonNull(player.getWorld().getName());
|
|
||||||
debugger.sendDebugMessage(Level.INFO, "Player name: " + username + "; World name: " + worldName);
|
|
||||||
// Teleport the player to the destination.
|
// Teleport the player to the destination.
|
||||||
TeleportUtils.teleportPlayer(sender, player, FileUtils.FileType.HUB_YAML, worldName);
|
TeleportUtils.teleportPlayer(actor, player, FileUtils.FileType.HUB_YAML);
|
||||||
|
|
||||||
// Remove it from the "teleporting" list - so it won't get teleported if it's waiting the spawn delay.
|
// Remove it from the "teleporting" list - so it won't get teleported if it's waiting the spawn delay.
|
||||||
CommonValues.teleporting.remove(username);
|
CommonValues.teleporting.remove(username);
|
||||||
}
|
}
|
||||||
|
@ -120,7 +120,7 @@ public class TeleportUtils
|
|||||||
}
|
}
|
||||||
|
|
||||||
// Store the location in a variable and teleport the player to it.
|
// Store the location in a variable and teleport the player to it.
|
||||||
Location finalLocation = new Location(destinationWorld, x, y, z, (float)yaw, (float)pitch);
|
final Location finalLocation = new Location(destinationWorld, x, y, z, (float)yaw, (float)pitch);
|
||||||
player.teleport(finalLocation);
|
player.teleport(finalLocation);
|
||||||
|
|
||||||
// Check if the player is teleporting to the hub.
|
// Check if the player is teleporting to the hub.
|
||||||
@ -146,4 +146,8 @@ public class TeleportUtils
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
public static void teleportPlayer(CommandSender sender, Player player, FileUtils.FileType type)
|
||||||
|
{
|
||||||
|
teleportPlayer(sender, player, type, null);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user