minor optimizations
This commit is contained in:
parent
bb5a90b390
commit
bcdad0739d
@ -32,7 +32,10 @@ public class HubThat extends JavaPlugin
|
||||
public UpdateChecker updateChecker;
|
||||
private static HubThat instance;
|
||||
|
||||
public HubThat() { instance = this; }
|
||||
public HubThat()
|
||||
{
|
||||
instance = this;
|
||||
}
|
||||
|
||||
// Method called when the plugin is being loaded.
|
||||
@Override
|
||||
@ -72,7 +75,6 @@ public class HubThat extends JavaPlugin
|
||||
pluginManager.registerEvents(new PlayerRespawnListener(this), this);
|
||||
|
||||
|
||||
|
||||
debugger.sendDebugMessage(Level.INFO, "Done registering listeners!");
|
||||
|
||||
// Register Commands
|
||||
@ -112,9 +114,9 @@ public class HubThat extends JavaPlugin
|
||||
FileUtils.reloadYamls();
|
||||
debugger.sendDebugMessage(Level.INFO, "Done!");
|
||||
|
||||
debugger.sendDebugMessage(Level.INFO,"Setting up Metrics...");
|
||||
debugger.sendDebugMessage(Level.INFO, "Setting up Metrics...");
|
||||
setupMetrics();
|
||||
debugger.sendDebugMessage(Level.INFO,"Done setting up Metrics!");
|
||||
debugger.sendDebugMessage(Level.INFO, "Done setting up Metrics!");
|
||||
|
||||
// Send success output message to console.
|
||||
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.
|
||||
@Override
|
||||
public void onDisable() {
|
||||
public void onDisable()
|
||||
{
|
||||
debugger.sendDebugMessage(Level.WARNING, "---[ DEBUGGER IS ENABLED! ]---");
|
||||
debugger.sendDebugMessage(Level.WARNING, "---[ DISABLING PLUGIN ]---");
|
||||
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-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)));
|
||||
}
|
||||
|
@ -137,15 +137,13 @@ public class HubCommand implements CommandExecutor
|
||||
}
|
||||
|
||||
// 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();
|
||||
|
||||
// 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.
|
||||
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.
|
||||
CommonValues.teleporting.remove(username);
|
||||
}
|
||||
|
@ -120,7 +120,7 @@ public class TeleportUtils
|
||||
}
|
||||
|
||||
// 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);
|
||||
|
||||
// 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