Finish sign support

This commit is contained in:
gomeow
2013-05-05 22:03:13 -07:00
parent bb7c27412a
commit bb0183e6c7
4 changed files with 51 additions and 13 deletions
@@ -127,7 +127,11 @@ public class Listeners implements Listener {
} }
if(Commands.SET_SIGN.containsKey(player.getName())) { if(Commands.SET_SIGN.containsKey(player.getName())) {
int i = Commands.SET_SIGN.get(player.getName()).getChest(); int i = Commands.SET_SIGN.get(player.getName()).getChest();
String owner = Commands.SET_SIGN.get(player.getName()).getOwner(); boolean self = Commands.SET_SIGN.get(player.getName()).isSelf();
String owner = null;
if(!self) {
owner = Commands.SET_SIGN.get(player.getName()).getOwner();
}
Commands.SET_SIGN.remove(player.getName()); Commands.SET_SIGN.remove(player.getName());
event.setCancelled(true); event.setCancelled(true);
if(event.getAction() == Action.RIGHT_CLICK_BLOCK) { if(event.getAction() == Action.RIGHT_CLICK_BLOCK) {
@@ -138,7 +142,11 @@ public class Listeners implements Listener {
int x = l.getBlockX(); int x = l.getBlockX();
int y = l.getBlockY(); int y = l.getBlockY();
int z = l.getBlockZ(); int z = l.getBlockZ();
if(self) {
plugin.getSigns().set(world + ";;" + x + ";;" + y + ";;" + z + ".self", self);
} else {
plugin.getSigns().set(world + ";;" + x + ";;" + y + ";;" + z + ".owner", owner); plugin.getSigns().set(world + ";;" + x + ";;" + y + ";;" + z + ".owner", owner);
}
plugin.getSigns().set(world + ";;" + x + ";;" + y + ";;" + z + ".chest", i); plugin.getSigns().set(world + ";;" + x + ";;" + y + ";;" + z + ".chest", i);
plugin.saveSigns(); plugin.saveSigns();
player.sendMessage(Lang.TITLE.toString() + Lang.SET_SIGN); player.sendMessage(Lang.TITLE.toString() + Lang.SET_SIGN);
@@ -159,11 +167,19 @@ public class Listeners implements Listener {
int y = l.getBlockY(); int y = l.getBlockY();
int z = l.getBlockZ(); int z = l.getBlockZ();
if(plugin.getSigns().getKeys(false).contains(world + ";;" + x + ";;" + y + ";;" + z)) { if(plugin.getSigns().getKeys(false).contains(world + ";;" + x + ";;" + y + ";;" + z)) {
String owner = PlayerVaults.SIGNS.getString(world + ";;" + x + ";;" + y + ";;" + z + ".owner"); if(player.hasPermission("playervaults.signs.use")) {
boolean self = PlayerVaults.SIGNS.getBoolean(world + ";;" + x + ";;" + y + ";;" + z + ".self", false);
String owner = null;
if(!self) {
owner = PlayerVaults.SIGNS.getString(world + ";;" + x + ";;" + y + ";;" + z + ".owner");
}
int num = PlayerVaults.SIGNS.getInt(world + ";;" + x + ";;" + y + ";;" + z + ".chest"); int num = PlayerVaults.SIGNS.getInt(world + ";;" + x + ";;" + y + ";;" + z + ".chest");
PlayerVaults.VM.loadVault(player, owner, num); PlayerVaults.VM.loadVault(player, (self) ? player.getName() : owner, num);
event.setCancelled(true); event.setCancelled(true);
player.sendMessage(Lang.TITLE.toString() + Lang.OPEN_WITH_SIGN.toString().replace("%v", String.valueOf(num)).replace("%p", owner)); player.sendMessage(Lang.TITLE.toString() + Lang.OPEN_WITH_SIGN.toString().replace("%v", String.valueOf(num)).replace("%p", (self) ? player.getName() : owner));
} else {
player.sendMessage(Lang.TITLE.toString() + Lang.NO_PERMS);
}
} }
} }
} }
@@ -48,7 +48,7 @@ public class PlayerVaults extends JavaPlugin {
Updater u = new Updater(); Updater u = new Updater();
if(getConfig().getBoolean("check-update")) { if(getConfig().getBoolean("check-update")) {
try { try {
if(u.getUpdate()) { if(u.getUpdate(getDescription().getVersion())) {
UPDATE = true; UPDATE = true;
} }
} catch(IOException e) { } catch(IOException e) {
@@ -67,9 +67,21 @@ public class Commands implements CommandExecutor {
sender.sendMessage(Lang.TITLE.toString() + Lang.NO_PERMS); sender.sendMessage(Lang.TITLE.toString() + Lang.NO_PERMS);
} }
} else if(cmd.getName().equalsIgnoreCase("pvsign")) { } else if(cmd.getName().equalsIgnoreCase("pvsign")) {
if(sender.hasPermission("playervaults.setsign")) { if(sender.hasPermission("playervaults.signs.set")) {
if(sender instanceof Player) { if(sender instanceof Player) {
if(args.length >= 2) { if(args.length == 1) {
int i = 0;
try {
i = Integer.parseInt(args[0]);
} catch(NumberFormatException nfe) {
sender.sendMessage(Lang.TITLE.toString() + Lang.MUST_BE_NUMBER);
sender.sendMessage(Lang.TITLE.toString() + "Usage: /" + label + " <owner> <#>");
return true;
}
SET_SIGN.put(sender.getName(), new SignSetInfo(i));
sender.sendMessage(Lang.TITLE.toString() + Lang.CLICK_A_SIGN);
}
else if(args.length >= 2) {
int i = 0; int i = 0;
try { try {
i = Integer.parseInt(args[1]); i = Integer.parseInt(args[1]);
@@ -4,12 +4,22 @@ public class SignSetInfo {
private String o; private String o;
private int i; private int i;
private boolean self = false;
public SignSetInfo(String o, int i) { public SignSetInfo(String o, int i) {
this.o = o; this.o = o;
this.i = i; this.i = i;
} }
public SignSetInfo(int i) {
this.i = i;
this.self = true;
}
public boolean isSelf() {
return this.self;
}
public String getOwner() { public String getOwner() {
return this.o; return this.o;
} }