Add script item #131
@ -23,15 +23,23 @@ package de.steamwar.bausystem.world;
|
||||
import de.steamwar.bausystem.BauSystem;
|
||||
import de.steamwar.bausystem.Permission;
|
||||
import de.steamwar.core.Core;
|
||||
import org.bukkit.Bukkit;
|
||||
import org.bukkit.ChatColor;
|
||||
import org.bukkit.Material;
|
||||
import org.bukkit.entity.Player;
|
||||
import org.bukkit.event.EventHandler;
|
||||
import org.bukkit.event.EventPriority;
|
||||
import org.bukkit.event.Listener;
|
||||
import org.bukkit.event.block.Action;
|
||||
import org.bukkit.event.block.BlockBreakEvent;
|
||||
import org.bukkit.event.block.BlockPlaceEvent;
|
||||
import org.bukkit.event.block.SignChangeEvent;
|
||||
import org.bukkit.event.player.PlayerCommandPreprocessEvent;
|
||||
import org.bukkit.event.player.PlayerInteractEvent;
|
||||
import org.bukkit.inventory.ItemStack;
|
||||
import org.bukkit.inventory.meta.BookMeta;
|
||||
|
||||
import java.util.logging.Level;
|
||||
|
||||
public class RegionListener implements Listener {
|
||||
|
||||
@ -97,4 +105,24 @@ public class RegionListener implements Listener {
|
||||
event.setLine(i, line);
|
||||
}
|
||||
}
|
||||
|
||||
@EventHandler
|
||||
public void onLeftClick(PlayerInteractEvent event) {
|
||||
if(event.getAction() != Action.LEFT_CLICK_AIR && event.getAction() != Action.LEFT_CLICK_BLOCK)
|
||||
return;
|
||||
|
||||
ItemStack item = event.getItem();
|
||||
if(item == null || (item.getType() != Material.WRITABLE_BOOK && item.getType() != Material.WRITTEN_BOOK) || item.getItemMeta() == null)
|
||||
return;
|
||||
|
||||
event.setCancelled(true);
|
||||
Player player = event.getPlayer();
|
||||
BookMeta meta = (BookMeta) item.getItemMeta();
|
||||
for(String page : meta.getPages()){
|
||||
for(String command : page.split("\n")){
|
||||
Bukkit.getLogger().log(Level.INFO, player.getName() + " dispatched command: " + command);
|
||||
Bukkit.getServer().dispatchCommand(player, command);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
In neuem Issue referenzieren
Einen Benutzer sperren