Add world capability check for setspawn
All checks were successful
continuous-integration/drone/push Build is passing
All checks were successful
continuous-integration/drone/push Build is passing
This commit is contained in:
parent
0783505dce
commit
34730ec881
@ -1,12 +1,14 @@
|
|||||||
package wtf.beatrice.uhccore.commands.uhccommands;
|
package wtf.beatrice.uhccore.commands.uhccommands;
|
||||||
|
|
||||||
import wtf.beatrice.uhccore.utils.Cache;
|
import wtf.beatrice.uhccore.utils.Cache;
|
||||||
|
import wtf.beatrice.uhccore.utils.MessageUtils;
|
||||||
import wtf.beatrice.uhccore.utils.configuration.ConfigEntry;
|
import wtf.beatrice.uhccore.utils.configuration.ConfigEntry;
|
||||||
import wtf.beatrice.uhccore.utils.configuration.FileUtils;
|
import wtf.beatrice.uhccore.utils.configuration.FileUtils;
|
||||||
import org.bukkit.Location;
|
import org.bukkit.Location;
|
||||||
import org.bukkit.command.CommandSender;
|
import org.bukkit.command.CommandSender;
|
||||||
import org.bukkit.configuration.file.YamlConfiguration;
|
import org.bukkit.configuration.file.YamlConfiguration;
|
||||||
import org.bukkit.entity.Player;
|
import org.bukkit.entity.Player;
|
||||||
|
import wtf.beatrice.uhccore.utils.configuration.LocalizedMessage;
|
||||||
|
|
||||||
public class SetSpawnCommand
|
public class SetSpawnCommand
|
||||||
{
|
{
|
||||||
@ -16,9 +18,17 @@ public class SetSpawnCommand
|
|||||||
Player player = (Player) sender;
|
Player player = (Player) sender;
|
||||||
Location playerLoc = player.getLocation();
|
Location playerLoc = player.getLocation();
|
||||||
|
|
||||||
|
String worldName = playerLoc.getWorld().getName();
|
||||||
|
|
||||||
|
if(!Cache.lobbyWorlds.contains(worldName))
|
||||||
|
{
|
||||||
|
MessageUtils.sendLocalizedMessage(sender, LocalizedMessage.ERROR_NOT_IN_LOBBY_WORLD);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
Cache.spawn = playerLoc;
|
Cache.spawn = playerLoc;
|
||||||
YamlConfiguration config = FileUtils.FileType.CONFIG_YAML.yaml;
|
YamlConfiguration config = FileUtils.FileType.CONFIG_YAML.yaml;
|
||||||
config.set(ConfigEntry.SPAWN_WORLD.path, playerLoc.getWorld().getName());
|
config.set(ConfigEntry.SPAWN_WORLD.path, worldName);
|
||||||
config.set(ConfigEntry.SPAWN_X.path, playerLoc.getX());
|
config.set(ConfigEntry.SPAWN_X.path, playerLoc.getX());
|
||||||
config.set(ConfigEntry.SPAWN_Y.path, playerLoc.getY());
|
config.set(ConfigEntry.SPAWN_Y.path, playerLoc.getY());
|
||||||
config.set(ConfigEntry.SPAWN_Z.path, playerLoc.getZ());
|
config.set(ConfigEntry.SPAWN_Z.path, playerLoc.getZ());
|
||||||
|
@ -9,6 +9,7 @@ public enum LocalizedMessage {
|
|||||||
|
|
||||||
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"),
|
ERROR_SERVER_NOT_SET_UP("error.server_not_set_up"),
|
||||||
|
ERROR_NOT_IN_LOBBY_WORLD("error.not_in_lobby_world"),
|
||||||
|
|
||||||
|
|
||||||
;
|
;
|
||||||
|
@ -2,5 +2,6 @@ error:
|
|||||||
console_access: '&eWarning! You are accessing the plugin command from console.'
|
console_access: '&eWarning! You are accessing the plugin command from console.'
|
||||||
console_access_blocked: '&cSorry, but this command is not available via console.'
|
console_access_blocked: '&cSorry, but this command is not available via console.'
|
||||||
server_not_set_up: '&cThis server has no been set up!'
|
server_not_set_up: '&cThis server has no been set up!'
|
||||||
|
not_in_lobby_world: '&cYou can only do this in lobby worlds!'
|
||||||
info: '&bThis is a colored and localized message!'
|
info: '&bThis is a colored and localized message!'
|
||||||
player_position: '&bYour position is: &e%pos%'
|
player_position: '&bYour position is: &e%pos%'
|
Loading…
Reference in New Issue
Block a user