From fcc76ae55920323314fd5d5d9c5edec551bb8094 Mon Sep 17 00:00:00 2001 From: Lixfel Date: Sun, 14 Jul 2019 20:07:46 +0200 Subject: [PATCH] Skull + colored Signs --- src/de/steamwar/bausystem/BauSystem.java | 1 + .../bausystem/commands/CommandSkull.java | 34 +++++++++++++++++++ .../bausystem/world/RegionListener.java | 15 +++++--- src/plugin.yml | 1 + 4 files changed, 47 insertions(+), 4 deletions(-) create mode 100644 src/de/steamwar/bausystem/commands/CommandSkull.java diff --git a/src/de/steamwar/bausystem/BauSystem.java b/src/de/steamwar/bausystem/BauSystem.java index 69eb984..d7cf605 100644 --- a/src/de/steamwar/bausystem/BauSystem.java +++ b/src/de/steamwar/bausystem/BauSystem.java @@ -76,6 +76,7 @@ public class BauSystem extends JavaPlugin implements Listener { getCommand("bau").setExecutor(new CommandBau()); getCommand("bauinfo").setExecutor(new CommandInfo()); getCommand("protect").setExecutor(new CommandProtect()); + getCommand("skull").setExecutor(new CommandSkull()); Bukkit.getPluginManager().registerEvents(this, this); Bukkit.getPluginManager().registerEvents(new RegionListener(), this); diff --git a/src/de/steamwar/bausystem/commands/CommandSkull.java b/src/de/steamwar/bausystem/commands/CommandSkull.java new file mode 100644 index 0000000..8540d2a --- /dev/null +++ b/src/de/steamwar/bausystem/commands/CommandSkull.java @@ -0,0 +1,34 @@ +package de.steamwar.bausystem.commands; + +import de.steamwar.bausystem.BauSystem; +import org.bukkit.Material; +import org.bukkit.command.Command; +import org.bukkit.command.CommandExecutor; +import org.bukkit.command.CommandSender; +import org.bukkit.entity.Player; +import org.bukkit.inventory.ItemStack; +import org.bukkit.inventory.meta.SkullMeta; + +public class CommandSkull implements CommandExecutor { + + @Override + public boolean onCommand(CommandSender commandSender, Command command, String s, String[] args) { + if(!(commandSender instanceof Player)) + return false; + Player p = (Player) commandSender; + + if(args.length != 1){ + p.sendMessage(BauSystem.PREFIX + "§8/§eskull §8[§eSpieler§8]"); + return false; + } + + ItemStack is = new ItemStack(Material.SKULL_ITEM, 1, (short)0, (byte)3); + SkullMeta sm = (SkullMeta)is.getItemMeta(); + sm.setOwner(args[0]); + sm.setDisplayName("§e" + args[0] + "§8s Kopf"); + is.setItemMeta(sm); + p.getInventory().setItemInMainHand(is); + + return false; + } +} diff --git a/src/de/steamwar/bausystem/world/RegionListener.java b/src/de/steamwar/bausystem/world/RegionListener.java index c06dbcd..0443d27 100644 --- a/src/de/steamwar/bausystem/world/RegionListener.java +++ b/src/de/steamwar/bausystem/world/RegionListener.java @@ -5,14 +5,12 @@ import com.sk89q.worldedit.bukkit.WorldEditPlugin; import de.steamwar.bausystem.BauSystem; import de.steamwar.bausystem.Permission; import org.bukkit.Bukkit; +import org.bukkit.ChatColor; 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.BlockBreakEvent; -import org.bukkit.event.block.BlockBurnEvent; -import org.bukkit.event.block.BlockPlaceEvent; -import org.bukkit.event.block.BlockSpreadEvent; +import org.bukkit.event.block.*; import org.bukkit.event.entity.EntityExplodeEvent; import org.bukkit.event.player.PlayerCommandPreprocessEvent; @@ -77,4 +75,13 @@ public class RegionListener implements Listener { if(!BauSystem.getWelt().isFireDmg()) e.setCancelled(true); } + + @EventHandler + public void onSignChange(SignChangeEvent event) { + for(int i = 0; i <= 3; ++i) { + String line = event.getLine(i); + line = ChatColor.translateAlternateColorCodes('&', line); + event.setLine(i, line); + } + } } diff --git a/src/plugin.yml b/src/plugin.yml index 898a8a6..a5cf254 100644 --- a/src/plugin.yml +++ b/src/plugin.yml @@ -14,5 +14,6 @@ commands: protect: bauinfo: speed: + skull: nightvision: aliases: nv \ No newline at end of file