minor optimizations

This commit is contained in:
Bea 2020-06-12 13:23:27 +02:00
parent bb5a90b390
commit bcdad0739d
3 changed files with 18 additions and 13 deletions

View File

@ -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
@ -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
@ -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);

View File

@ -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);
} }

View File

@ -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);
}
} }