Sign-Copy/Block-Info Tool

This commit is contained in:
Sn0wStorm 2013-05-25 18:48:17 +02:00
parent 021026febd
commit 3d8dceec87
3 changed files with 48 additions and 0 deletions

View File

@ -9,6 +9,9 @@ import org.bukkit.GameMode;
import org.bukkit.Location; import org.bukkit.Location;
import org.bukkit.Material; import org.bukkit.Material;
import org.bukkit.World; import org.bukkit.World;
import org.bukkit.block.Sign;
import org.bukkit.block.Block;
import org.bukkit.event.block.SignChangeEvent;
import org.bukkit.configuration.file.FileConfiguration; import org.bukkit.configuration.file.FileConfiguration;
import org.bukkit.configuration.file.YamlConfiguration; import org.bukkit.configuration.file.YamlConfiguration;
import org.bukkit.entity.EntityType; import org.bukkit.entity.EntityType;
@ -48,6 +51,7 @@ public class DPlayer {
public long offlineTime; public long offlineTime;
public ItemStack[] respawnInventory; public ItemStack[] respawnInventory;
public ItemStack[] respawnArmor; public ItemStack[] respawnArmor;
public String[] linesCopy;
public Inventory treasureInv = P.p.getServer().createInventory(player, 45, "Belohnungen"); public Inventory treasureInv = P.p.getServer().createInventory(player, 45, "Belohnungen");
@ -265,6 +269,35 @@ public class DPlayer {
} }
} }
public void poke(Block block) {
if (block.getState() instanceof Sign) {
Sign sign = (Sign) block.getState();
String[] lines = sign.getLines();
if (lines[0].equals("") && lines[1].equals("") && lines[2].equals("") && lines[3].equals("")) {
if (linesCopy != null) {
SignChangeEvent event = new SignChangeEvent(block, player, linesCopy);
p.getServer().getPluginManager().callEvent(event);
if (!event.isCancelled()) {
sign.setLine(0, event.getLine(0));
sign.setLine(1, event.getLine(1));
sign.setLine(2, event.getLine(2));
sign.setLine(3, event.getLine(3));
sign.update();
}
}
} else {
linesCopy = lines;
p.msg(player, p.language.get("Player_SignCopied"));
}
} else {
String info = "" + block.getTypeId();
if (block.getData() != 0) {
info = info + "," + block.getData();
}
p.msg(player, p.language.get("Player_BlockInfo", info));
}
}
public void setClass(String classname) { public void setClass(String classname) {
GameWorld gworld = GameWorld.get(this.player.getWorld()); GameWorld gworld = GameWorld.get(this.player.getWorld());
if (gworld == null) if (gworld == null)

View File

@ -62,6 +62,8 @@ public class LanguageReader {
defaults.put("Player_PortalProgress", "&6Erster Block gewählt, nun der zweite!"); defaults.put("Player_PortalProgress", "&6Erster Block gewählt, nun der zweite!");
defaults.put("Player_PortalCreated", "&6Portal erstellt!"); defaults.put("Player_PortalCreated", "&6Portal erstellt!");
defaults.put("Player_SignCreated", "&6Schild erstellt!"); defaults.put("Player_SignCreated", "&6Schild erstellt!");
defaults.put("Player_SignCopied", "&6Kopiert!");
defaults.put("Player_BlockInfo", "&6Block-ID: &2&v1");
/* Cmds */ /* Cmds */
defaults.put("Cmd_Chat_DungeonChat", "&6Du bist nun im Dungeon-Chat"); defaults.put("Cmd_Chat_DungeonChat", "&6Du bist nun im Dungeon-Chat");

View File

@ -91,6 +91,19 @@ public class PlayerListener implements Listener {
} }
} }
} }
// Copy/Paste a Sign and Block-info
if (EditWorld.get(player.getWorld()) != null) {
if (event.getAction() == Action.RIGHT_CLICK_BLOCK) {
if (event.getItem().getType() == Material.STICK) {
DPlayer dplayer = DPlayer.get(player);
if (dplayer != null) {
dplayer.poke(clickedBlock);
event.setCancelled(true);
}
}
}
}
} }
// Check Signs // Check Signs