mirror of
https://github.com/EngineHub/WorldGuard.git
synced 2025-01-12 03:13:40 +01:00
Split the region greeting with \n
Improve input handling of EnumFlag Don't block gamemode changing after the gamemode flag is no longer in effect but while the move event is still firing
This commit is contained in:
parent
f2bd5961d0
commit
166831447c
@ -167,14 +167,18 @@ public void onPlayerMove(PlayerMoveEvent event) {
|
||||
|| !state.lastFarewell.equals(farewell))) {
|
||||
String replacedFarewell = plugin.replaceMacros(
|
||||
player, BukkitUtil.replaceColorMacros(state.lastFarewell));
|
||||
player.sendMessage(ChatColor.AQUA + " ** " + replacedFarewell);
|
||||
for (String line : replacedFarewell.split("\n")) {
|
||||
player.sendMessage(ChatColor.AQUA + " ** " + line);
|
||||
}
|
||||
}
|
||||
|
||||
if (greeting != null && (state.lastGreeting == null
|
||||
|| !state.lastGreeting.equals(greeting))) {
|
||||
String replacedGreeting = plugin.replaceMacros(
|
||||
player, BukkitUtil.replaceColorMacros(greeting));
|
||||
player.sendMessage(ChatColor.AQUA + " ** " + replacedGreeting);
|
||||
for (String line : replacedGreeting.split("\n")) {
|
||||
player.sendMessage(ChatColor.AQUA + " ** " + line);
|
||||
}
|
||||
}
|
||||
|
||||
if ((notifyLeave == null || !notifyLeave)
|
||||
@ -202,12 +206,16 @@ public void onPlayerMove(PlayerMoveEvent event) {
|
||||
+ regionList);
|
||||
}
|
||||
|
||||
if (gameMode != null && player.getGameMode() != gameMode) {
|
||||
player.setGameMode(gameMode);
|
||||
if (gameMode != null) {
|
||||
if (player.getGameMode() != gameMode) {
|
||||
state.lastGameMode = player.getGameMode();
|
||||
player.setGameMode(gameMode);
|
||||
}
|
||||
} else {
|
||||
if (state.lastGameMode != null) {
|
||||
player.setGameMode(state.lastGameMode);
|
||||
GameMode mode = state.lastGameMode;
|
||||
state.lastGameMode = null;
|
||||
player.setGameMode(mode);
|
||||
}
|
||||
}
|
||||
|
||||
@ -232,7 +240,8 @@ public void onPlayerGameModeChange(PlayerGameModeChangeEvent event) {
|
||||
if (wcfg.useRegions) {
|
||||
GameMode gameMode = plugin.getGlobalRegionManager().get(player.getWorld())
|
||||
.getApplicableRegions(player.getLocation()).getFlag(DefaultFlag.GAME_MODE);
|
||||
if (gameMode != null && event.getNewGameMode() != gameMode) {
|
||||
if (plugin.getFlagStateManager().getState(player).lastGameMode != null
|
||||
&& gameMode != null && event.getNewGameMode() != gameMode) {
|
||||
event.setCancelled(true);
|
||||
player.sendMessage(ChatColor.RED + "Your game mode is locked to "
|
||||
+ gameMode + "in this region!");
|
||||
@ -1037,7 +1046,8 @@ public void onPlayerCommandPreprocess(PlayerCommandPreprocessEvent event) {
|
||||
Set<String> allowedCommands = set.getFlag(DefaultFlag.ALLOWED_CMDS, localPlayer);
|
||||
Set<String> blockedCommands = set.getFlag(DefaultFlag.BLOCKED_CMDS, localPlayer);
|
||||
|
||||
if (allowedCommands != null && !allowedCommands.contains(lowerCommand) && (blockedCommands == null || blockedCommands.contains(lowerCommand))) {
|
||||
if (allowedCommands != null && !allowedCommands.contains(lowerCommand)
|
||||
&& (blockedCommands == null || blockedCommands.contains(lowerCommand))) {
|
||||
player.sendMessage(ChatColor.RED + lowerCommand + " is not allowed in this area.");
|
||||
event.setCancelled(true);
|
||||
return;
|
||||
|
@ -41,6 +41,10 @@ public EnumFlag(String name, Class<T> enumClass) {
|
||||
}
|
||||
|
||||
private T findValue(String input) throws IllegalArgumentException {
|
||||
if (input != null) {
|
||||
input = input.toUpperCase();
|
||||
}
|
||||
|
||||
try {
|
||||
return Enum.valueOf(enumClass, input);
|
||||
} catch (IllegalArgumentException e) {
|
||||
@ -88,5 +92,5 @@ public T unmarshal(Object o) {
|
||||
public Object marshal(T o) {
|
||||
return o.name();
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user