This commit is contained in:
Butzlabben 2019-02-25 15:14:34 +01:00
parent b5faa1d836
commit 3a5ebb7346

View File

@ -1,6 +1,12 @@
package de.butzlabben.world.listener; package de.butzlabben.world.listener;
import de.butzlabben.world.config.MessageConfig;
import de.butzlabben.world.config.PluginConfig;
import de.butzlabben.world.config.WorldConfig;
import de.butzlabben.world.wrapper.SystemWorld;
import de.butzlabben.world.wrapper.WorldPlayer;
import org.bukkit.Bukkit; import org.bukkit.Bukkit;
import org.bukkit.GameMode;
import org.bukkit.World; import org.bukkit.World;
import org.bukkit.entity.Player; import org.bukkit.entity.Player;
import org.bukkit.event.EventHandler; import org.bukkit.event.EventHandler;
@ -10,12 +16,6 @@ import org.bukkit.event.player.PlayerCommandPreprocessEvent;
import org.bukkit.event.player.PlayerTeleportEvent; import org.bukkit.event.player.PlayerTeleportEvent;
import org.bukkit.event.player.PlayerTeleportEvent.TeleportCause; import org.bukkit.event.player.PlayerTeleportEvent.TeleportCause;
import de.butzlabben.world.config.MessageConfig;
import de.butzlabben.world.config.PluginConfig;
import de.butzlabben.world.config.WorldConfig;
import de.butzlabben.world.wrapper.SystemWorld;
import de.butzlabben.world.wrapper.WorldPlayer;
public class CommandListener implements Listener { public class CommandListener implements Listener {
@EventHandler(priority = EventPriority.HIGH) @EventHandler(priority = EventPriority.HIGH)
@ -39,6 +39,7 @@ public class CommandListener implements Listener {
if (!wp.isOnSystemWorld() || wp.isOwnerofWorld() || wp.canTeleport() || p.hasPermission("ws.tp.toother")) if (!wp.isOnSystemWorld() || wp.isOwnerofWorld() || wp.canTeleport() || p.hasPermission("ws.tp.toother"))
return; return;
e.setCancelled(true); e.setCancelled(true);
p.sendMessage(MessageConfig.getNoPermission()); p.sendMessage(MessageConfig.getNoPermission());
} else if (e.getCause() == TeleportCause.COMMAND) { } else if (e.getCause() == TeleportCause.COMMAND) {
@ -52,10 +53,24 @@ public class CommandListener implements Listener {
if (!wp.isOnSystemWorld() || wp.isOwnerofWorld() || wp.canTeleport() || p.hasPermission("ws.tp.toother")) if (!wp.isOnSystemWorld() || wp.isOwnerofWorld() || wp.canTeleport() || p.hasPermission("ws.tp.toother"))
return; return;
e.setCancelled(true); e.setCancelled(true);
p.sendMessage(MessageConfig.getNoPermission()); p.sendMessage(MessageConfig.getNoPermission());
} }
// Fix for #18
if (from != to || WorldConfig.exists(from.getName())) {
GameMode gameMode = PluginConfig.getSpawnGamemode();
if (WorldConfig.exists(to.getName())) {
if (PluginConfig.isSurvival()) {
gameMode = GameMode.SURVIVAL;
} else {
gameMode = GameMode.CREATIVE;
}
}
p.setGameMode(gameMode);
}
} }
@EventHandler(priority = EventPriority.HIGH) @EventHandler(priority = EventPriority.HIGH)