Fix console error on join in case the spawn is not set

This commit is contained in:
Bea 2022-08-11 18:14:34 +02:00
parent 71716710af
commit c0fa56fea2
6 changed files with 28 additions and 5 deletions

View File

@ -21,8 +21,8 @@
</plugins>
</build>
<properties>
<maven.compiler.source>1.8</maven.compiler.source>
<maven.compiler.target>1.8</maven.compiler.target>
<maven.compiler.source>17</maven.compiler.source>
<maven.compiler.target>17</maven.compiler.target>
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
<versionName>${project.version}</versionName>
</properties>
@ -39,7 +39,7 @@
<dependency>
<groupId>org.spigotmc</groupId>
<artifactId>spigot-api</artifactId>
<version>1.16.1-R0.1-SNAPSHOT</version>
<version>1.19.2-R0.1-SNAPSHOT</version>
<scope>provided</scope>
</dependency>

View File

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

View File

@ -0,0 +1,5 @@
package wtf.beatrice.uhccore.utils;
public class QuickLogger {
}

View File

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

View File

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

View File

@ -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%'