mirror of
https://github.com/Phoenix616/RandomTeleport.git
synced 2024-11-26 20:48:12 +01:00
Made preset signs work and added some messages.
This commit is contained in:
parent
066c5f2274
commit
6cc4c8888f
@ -23,31 +23,39 @@ public class SignListener implements Listener {
|
|||||||
if(!event.getPlayer().hasPermission("randomteleport.sign.create")){
|
if(!event.getPlayer().hasPermission("randomteleport.sign.create")){
|
||||||
event.getBlock().breakNaturally();
|
event.getBlock().breakNaturally();
|
||||||
event.getPlayer().sendMessage(ChatColor.RED + "You don't have permission to create RandomTeleport preset signs! " + ChatColor.ITALIC + " (randomteleport.sign.create)");
|
event.getPlayer().sendMessage(ChatColor.RED + "You don't have permission to create RandomTeleport preset signs! " + ChatColor.ITALIC + " (randomteleport.sign.create)");
|
||||||
|
} else {
|
||||||
|
event.getPlayer().sendMessage(ChatColor.GREEN + "RandomTeleport preset sign created!");
|
||||||
|
if (RandomTeleport.getPlugin().getConfig().getString("presets." + event.getLine(2).toLowerCase()) == null) {
|
||||||
|
event.getPlayer().sendMessage(ChatColor.DARK_RED + "Warning: " + ChatColor.RED + "The RandomTeleport preset " + ChatColor.GOLD + event.getLine(2).toLowerCase() + ChatColor.RED + " does not exist!");
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@EventHandler
|
@EventHandler
|
||||||
public void onSignDestroy(BlockBreakEvent event){
|
public void onSignDestroy(BlockBreakEvent event){
|
||||||
if(event.getBlock().getType() == Material.SIGN) {
|
if(event.getBlock().getType() == Material.WALL_SIGN || event.getBlock().getType() == Material.SIGN_POST) {
|
||||||
Sign sign = (Sign) event.getBlock();
|
Sign sign = (Sign) event.getBlock().getState();
|
||||||
if((sign.getLine(1).equalsIgnoreCase("[rtp]") || sign.getLine(1).equalsIgnoreCase("[RandomTP]")) && !event.getPlayer().hasPermission("randomteleport.sign.create")) {
|
if(sign.getLine(1).equalsIgnoreCase("[rtp]") || sign.getLine(1).equalsIgnoreCase("[RandomTP]")){
|
||||||
event.setCancelled(true);
|
if (!event.getPlayer().hasPermission("randomteleport.sign.create")){
|
||||||
event.getPlayer().sendMessage(ChatColor.RED + "You don't have permission to break RandomTeleport preset signs! " + ChatColor.ITALIC + " (randomteleport.sign.create)");
|
event.setCancelled(true);
|
||||||
|
event.getPlayer().sendMessage(ChatColor.RED + "You don't have permission to break RandomTeleport signs! " + ChatColor.ITALIC + " (randomteleport.sign.create)");
|
||||||
|
} else {
|
||||||
|
event.getPlayer().sendMessage(ChatColor.RED + "RandomTeleport sign destroyed!");
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@EventHandler
|
@EventHandler
|
||||||
public void onSignClick(PlayerInteractEvent event) {
|
public void onSignClick(PlayerInteractEvent event) {
|
||||||
if(event.getAction() == Action.LEFT_CLICK_BLOCK || event.getAction() == Action.RIGHT_CLICK_BLOCK) {
|
if(event.getAction() == Action.RIGHT_CLICK_BLOCK && !event.isCancelled() && (event.getClickedBlock().getType() == Material.WALL_SIGN || event.getClickedBlock().getType() == Material.SIGN_POST)) {
|
||||||
if (event.getClickedBlock().getType() != Material.SIGN) return;
|
|
||||||
Sign sign = (Sign) event.getClickedBlock().getState();
|
Sign sign = (Sign) event.getClickedBlock().getState();
|
||||||
if(!(sign.getLine(1).equalsIgnoreCase("[rtp]") || sign.getLine(1).equalsIgnoreCase("[RandomTP]"))) return;
|
if(!(sign.getLine(1).equalsIgnoreCase("[rtp]") || sign.getLine(1).equalsIgnoreCase("[RandomTP]"))) return;
|
||||||
String preset = sign.getLine(2);
|
String preset = sign.getLine(2).toLowerCase();
|
||||||
if (event.getPlayer().hasPermission("randomteleport.sign.preset." + preset)) {
|
if (event.getPlayer().hasPermission("randomteleport.sign.preset." + preset)) {
|
||||||
if (RandomTeleport.getPlugin().getConfig().getString("presets." + preset) == null) {
|
if (RandomTeleport.getPlugin().getConfig().getString("presets." + preset) == null) {
|
||||||
event.getPlayer().sendMessage(ChatColor.RED + "The Random Teleport " + preset + " does not exist!");
|
event.getPlayer().sendMessage(ChatColor.RED + "The RandomTeleport preset " + ChatColor.GOLD + preset + ChatColor.RED + " does not exist!");
|
||||||
} else {
|
} else {
|
||||||
String cmd = "rtp " + preset + " " + event.getPlayer().getName();
|
String cmd = "rtp " + preset + " " + event.getPlayer().getName();
|
||||||
RandomTeleport.getPlugin().getServer().dispatchCommand(RandomTeleport.getPlugin().getServer().getConsoleSender(), cmd);
|
RandomTeleport.getPlugin().getServer().dispatchCommand(RandomTeleport.getPlugin().getServer().getConsoleSender(), cmd);
|
||||||
|
Loading…
Reference in New Issue
Block a user