Fix console error on join in case the spawn is not set
This commit is contained in:
@@ -36,9 +36,15 @@ public class MessageUtils
|
||||
sender = plugin.getServer().getPlayer(senderName);
|
||||
}
|
||||
|
||||
sendLocalizedMessage(sender, messageEnum);
|
||||
}
|
||||
|
||||
public static void sendLocalizedMessage(CommandSender sender, LocalizedMessages messageEnum)
|
||||
{
|
||||
|
||||
// If we actually have a sender, send it the message and color it!
|
||||
if(sender != null) sender.sendMessage(getLocalizedMessage(messageEnum, true));
|
||||
// If the sender is null, report it to the debugger.
|
||||
// If the sender is null, report it to the debugger.
|
||||
else debugger.sendDebugMessage(Level.SEVERE, "Sender is null!");
|
||||
}
|
||||
|
||||
|
||||
@@ -0,0 +1,5 @@
|
||||
package wtf.beatrice.uhccore.utils;
|
||||
|
||||
public class QuickLogger {
|
||||
|
||||
}
|
||||
@@ -8,6 +8,7 @@ import org.bukkit.entity.EntityType;
|
||||
import org.bukkit.entity.Firework;
|
||||
import org.bukkit.entity.Player;
|
||||
import org.bukkit.inventory.meta.FireworkMeta;
|
||||
import wtf.beatrice.uhccore.utils.configuration.LocalizedMessages;
|
||||
|
||||
public class UhcUtils {
|
||||
|
||||
@@ -69,6 +70,12 @@ public class UhcUtils {
|
||||
|
||||
public static void tpSpawnAndGiveItem(Player player)
|
||||
{
|
||||
if(Cache.spawn == null)
|
||||
{
|
||||
MessageUtils.sendLocalizedMessage(player, LocalizedMessages.ERROR_SERVER_NOT_SET_UP);
|
||||
return;
|
||||
}
|
||||
|
||||
|
||||
player.teleport(Cache.spawn);
|
||||
|
||||
|
||||
@@ -7,7 +7,11 @@ public enum LocalizedMessages {
|
||||
|
||||
WARNING_CONSOLE_ACCESS("error.console_access"),
|
||||
|
||||
ERROR_CONSOLE_ACCESS_BLOCKED("error.console_access_blocked");
|
||||
ERROR_CONSOLE_ACCESS_BLOCKED("error.console_access_blocked"),
|
||||
ERROR_SERVER_NOT_SET_UP("error.server_not_set_up"),
|
||||
|
||||
|
||||
;
|
||||
|
||||
public String path;
|
||||
|
||||
|
||||
@@ -1,5 +1,6 @@
|
||||
error:
|
||||
console_access: '&eWarning! You are accessing the plugin command from console.'
|
||||
console_access_blocked: '&cSorry, but this command is not available via console.'
|
||||
server_not_set_up: '&cThis server has no been set up!'
|
||||
info: '&bThis is a colored and localized message!'
|
||||
player_position: '&bYour position is: &e%pos%'
|
||||
Reference in New Issue
Block a user