Spectators can use /tp
This commit is contained in:
parent
82dd94de9b
commit
bea6902198
@ -899,7 +899,7 @@ public class GameLobbyManager implements IPacketRunnable, Listener
|
|||||||
objective.setDisplayName(ChatColor.GREEN + "§l" + "Waiting for Players");
|
objective.setDisplayName(ChatColor.GREEN + "§l" + "Waiting for Players");
|
||||||
}
|
}
|
||||||
|
|
||||||
int line = 9;
|
int line = 15;
|
||||||
|
|
||||||
objective.getScore(" ").setScore(line--);
|
objective.getScore(" ").setScore(line--);
|
||||||
|
|
||||||
|
@ -36,6 +36,7 @@ import org.bukkit.event.EventHandler;
|
|||||||
import org.bukkit.event.EventPriority;
|
import org.bukkit.event.EventPriority;
|
||||||
import org.bukkit.event.Listener;
|
import org.bukkit.event.Listener;
|
||||||
import org.bukkit.event.entity.EntityDamageEvent.DamageCause;
|
import org.bukkit.event.entity.EntityDamageEvent.DamageCause;
|
||||||
|
import org.bukkit.event.player.PlayerCommandPreprocessEvent;
|
||||||
import org.bukkit.event.player.PlayerInteractEntityEvent;
|
import org.bukkit.event.player.PlayerInteractEntityEvent;
|
||||||
import org.bukkit.event.player.PlayerJoinEvent;
|
import org.bukkit.event.player.PlayerJoinEvent;
|
||||||
import org.bukkit.event.player.PlayerRespawnEvent;
|
import org.bukkit.event.player.PlayerRespawnEvent;
|
||||||
@ -338,4 +339,42 @@ public class GamePlayerManager implements Listener
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@EventHandler(priority = EventPriority.LOWEST)
|
||||||
|
public void TeleportCommand(PlayerCommandPreprocessEvent event)
|
||||||
|
{
|
||||||
|
if (!event.getMessage().toLowerCase().startsWith("/tp"))
|
||||||
|
return;
|
||||||
|
|
||||||
|
Game game = Manager.GetGame();
|
||||||
|
if (game == null)
|
||||||
|
return;
|
||||||
|
|
||||||
|
Player player = event.getPlayer();
|
||||||
|
|
||||||
|
if (game.IsAlive(player) || player.getGameMode() != GameMode.CREATIVE)
|
||||||
|
{
|
||||||
|
UtilPlayer.message(player, F.main("Game", "Only Spectators can use teleport."));
|
||||||
|
event.setCancelled(true);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
String[] tokens = event.getMessage().split(" ");
|
||||||
|
|
||||||
|
if (tokens.length != 2)
|
||||||
|
{
|
||||||
|
UtilPlayer.message(player, F.main("Game", "Invalid Input. " + F.elem("/tp <Name>") + "."));
|
||||||
|
event.setCancelled(true);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
Player target = UtilPlayer.searchOnline(player, tokens[1], true);
|
||||||
|
if (target != null)
|
||||||
|
{
|
||||||
|
UtilPlayer.message(player, F.main("Game", "You teleported to " + F.name(target.getName()) + "."));
|
||||||
|
player.teleport(target);
|
||||||
|
event.setCancelled(true);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user