Move in vault and set sign hashmaps to main class
This commit is contained in:
@@ -25,7 +25,6 @@ import org.bukkit.event.player.PlayerQuitEvent;
|
||||
import org.bukkit.event.player.PlayerTeleportEvent;
|
||||
import org.bukkit.inventory.Inventory;
|
||||
|
||||
import com.drtshock.playervaults.commands.Commands;
|
||||
import com.drtshock.playervaults.commands.VaultViewInfo;
|
||||
import com.drtshock.playervaults.util.DropOnDeath;
|
||||
import com.drtshock.playervaults.util.Lang;
|
||||
@@ -47,15 +46,15 @@ public class Listeners implements Listener {
|
||||
* @param Player p
|
||||
*/
|
||||
public void saveVault(Player p) {
|
||||
if(Commands.IN_VAULT.containsKey(p.getName())) {
|
||||
if(PlayerVaults.IN_VAULT.containsKey(p.getName())) {
|
||||
Inventory inv = p.getOpenInventory().getTopInventory();
|
||||
VaultViewInfo info = Commands.IN_VAULT.get(p.getName());
|
||||
VaultViewInfo info = PlayerVaults.IN_VAULT.get(p.getName());
|
||||
try {
|
||||
vm.saveVault(inv, info.getHolder(), info.getNumber());
|
||||
} catch(IOException e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
Commands.IN_VAULT.remove(p.getName());
|
||||
PlayerVaults.IN_VAULT.remove(p.getName());
|
||||
}
|
||||
}
|
||||
|
||||
@@ -108,7 +107,7 @@ public class Listeners implements Listener {
|
||||
public void onInteract(PlayerInteractEvent event) {
|
||||
Player player = event.getPlayer();
|
||||
if(event.getAction() == Action.RIGHT_CLICK_BLOCK) {
|
||||
if(Commands.IN_VAULT.containsKey(player.getName())) {
|
||||
if(PlayerVaults.IN_VAULT.containsKey(player.getName())) {
|
||||
Block block = event.getClickedBlock();
|
||||
|
||||
/**
|
||||
@@ -125,14 +124,14 @@ public class Listeners implements Listener {
|
||||
}
|
||||
}
|
||||
}
|
||||
if(Commands.SET_SIGN.containsKey(player.getName())) {
|
||||
int i = Commands.SET_SIGN.get(player.getName()).getChest();
|
||||
boolean self = Commands.SET_SIGN.get(player.getName()).isSelf();
|
||||
if(PlayerVaults.SET_SIGN.containsKey(player.getName())) {
|
||||
int i = PlayerVaults.SET_SIGN.get(player.getName()).getChest();
|
||||
boolean self = PlayerVaults.SET_SIGN.get(player.getName()).isSelf();
|
||||
String owner = null;
|
||||
if(!self) {
|
||||
owner = Commands.SET_SIGN.get(player.getName()).getOwner();
|
||||
owner = PlayerVaults.SET_SIGN.get(player.getName()).getOwner();
|
||||
}
|
||||
Commands.SET_SIGN.remove(player.getName());
|
||||
PlayerVaults.SET_SIGN.remove(player.getName());
|
||||
event.setCancelled(true);
|
||||
if(event.getAction() == Action.RIGHT_CLICK_BLOCK) {
|
||||
if(event.getClickedBlock().getType() == Material.WALL_SIGN || event.getClickedBlock().getType() == Material.SIGN_POST) {
|
||||
@@ -175,7 +174,7 @@ public class Listeners implements Listener {
|
||||
}
|
||||
int num = PlayerVaults.SIGNS.getInt(world + ";;" + x + ";;" + y + ";;" + z + ".chest");
|
||||
PlayerVaults.VM.loadVault(player, (self) ? player.getName() : owner, num);
|
||||
Commands.IN_VAULT.put(player.getName(), new VaultViewInfo((self) ? player.getName() : owner, num));
|
||||
PlayerVaults.IN_VAULT.put(player.getName(), new VaultViewInfo((self) ? player.getName() : owner, num));
|
||||
event.setCancelled(true);
|
||||
player.sendMessage(Lang.TITLE.toString() + Lang.OPEN_WITH_SIGN.toString().replace("%v", String.valueOf(num)).replace("%p", (self) ? player.getName() : owner));
|
||||
} else {
|
||||
@@ -220,7 +219,7 @@ public class Listeners implements Listener {
|
||||
public void onInteractEntity(PlayerInteractEntityEvent event) {
|
||||
Player player = event.getPlayer();
|
||||
EntityType type = event.getRightClicked().getType();
|
||||
if((type == EntityType.VILLAGER || type == EntityType.MINECART) && Commands.IN_VAULT.containsKey(player.getName())) {
|
||||
if((type == EntityType.VILLAGER || type == EntityType.MINECART) && PlayerVaults.IN_VAULT.containsKey(player.getName())) {
|
||||
event.setCancelled(true);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -3,6 +3,7 @@ package com.drtshock.playervaults;
|
||||
import java.io.File;
|
||||
import java.io.IOException;
|
||||
import java.io.InputStream;
|
||||
import java.util.HashMap;
|
||||
import java.util.logging.Level;
|
||||
import java.util.logging.Logger;
|
||||
|
||||
@@ -13,6 +14,8 @@ import org.bukkit.plugin.RegisteredServiceProvider;
|
||||
import org.bukkit.plugin.java.JavaPlugin;
|
||||
|
||||
import com.drtshock.playervaults.commands.Commands;
|
||||
import com.drtshock.playervaults.commands.SignSetInfo;
|
||||
import com.drtshock.playervaults.commands.VaultViewInfo;
|
||||
import com.drtshock.playervaults.util.Lang;
|
||||
import com.drtshock.playervaults.util.Metrics;
|
||||
import com.drtshock.playervaults.util.Updater;
|
||||
@@ -26,6 +29,8 @@ public class PlayerVaults extends JavaPlugin {
|
||||
public static String NEWVERSION = "";
|
||||
public static String LINK = "";
|
||||
Commands commands;
|
||||
public static HashMap<String, SignSetInfo> SET_SIGN = new HashMap<String, SignSetInfo>();
|
||||
public static HashMap<String, VaultViewInfo> IN_VAULT = new HashMap<String, VaultViewInfo>();
|
||||
public static Economy ECON = null;
|
||||
public static boolean DROP_ON_DEATH = false;
|
||||
public static int INVENTORIES_TO_DROP = 0;
|
||||
|
||||
@@ -1,6 +1,5 @@
|
||||
package com.drtshock.playervaults.commands;
|
||||
|
||||
import java.util.HashMap;
|
||||
|
||||
import org.bukkit.Bukkit;
|
||||
import org.bukkit.ChatColor;
|
||||
@@ -11,13 +10,11 @@ import org.bukkit.entity.Player;
|
||||
import org.bukkit.event.inventory.InventoryType;
|
||||
import org.bukkit.inventory.Inventory;
|
||||
|
||||
import com.drtshock.playervaults.PlayerVaults;
|
||||
import com.drtshock.playervaults.util.Lang;
|
||||
|
||||
public class Commands implements CommandExecutor {
|
||||
|
||||
public static HashMap<String, VaultViewInfo> IN_VAULT = new HashMap<String, VaultViewInfo>();
|
||||
public static HashMap<String, SignSetInfo> SET_SIGN = new HashMap<String, SignSetInfo>();
|
||||
|
||||
@Override
|
||||
public boolean onCommand(CommandSender sender, Command cmd, String label, String[] args) {
|
||||
if(cmd.getName().equalsIgnoreCase("pv")) {
|
||||
@@ -26,11 +23,11 @@ public class Commands implements CommandExecutor {
|
||||
switch (args.length) {
|
||||
case 1:
|
||||
if(VaultOperations.openOwnVault(p, args[0]))
|
||||
IN_VAULT.put(sender.getName(), new VaultViewInfo(sender.getName(), Integer.parseInt(args[0])));
|
||||
PlayerVaults.IN_VAULT.put(sender.getName(), new VaultViewInfo(sender.getName(), Integer.parseInt(args[0])));
|
||||
break;
|
||||
case 2:
|
||||
if(VaultOperations.openOtherVault(p, args[0], args[1]))
|
||||
IN_VAULT.put(sender.getName(), new VaultViewInfo(args[0], Integer.parseInt(args[1])));
|
||||
PlayerVaults.IN_VAULT.put(sender.getName(), new VaultViewInfo(args[0], Integer.parseInt(args[1])));
|
||||
break;
|
||||
default:
|
||||
Feedback.showHelp(sender, Feedback.Type.OPEN);
|
||||
@@ -78,7 +75,7 @@ public class Commands implements CommandExecutor {
|
||||
sender.sendMessage(Lang.TITLE.toString() + "Usage: /" + label + " <owner> <#>");
|
||||
return true;
|
||||
}
|
||||
SET_SIGN.put(sender.getName(), new SignSetInfo(i));
|
||||
PlayerVaults.SET_SIGN.put(sender.getName(), new SignSetInfo(i));
|
||||
sender.sendMessage(Lang.TITLE.toString() + Lang.CLICK_A_SIGN);
|
||||
}
|
||||
else if(args.length >= 2) {
|
||||
@@ -90,7 +87,7 @@ public class Commands implements CommandExecutor {
|
||||
sender.sendMessage(Lang.TITLE.toString() + "Usage: /" + label + " <owner> <#>");
|
||||
return true;
|
||||
}
|
||||
SET_SIGN.put(sender.getName(), new SignSetInfo(args[0].toLowerCase(), i));
|
||||
PlayerVaults.SET_SIGN.put(sender.getName(), new SignSetInfo(args[0].toLowerCase(), i));
|
||||
sender.sendMessage(Lang.TITLE.toString() + Lang.CLICK_A_SIGN);
|
||||
} else {
|
||||
sender.sendMessage(Lang.TITLE.toString() + Lang.INVALID_ARGS);
|
||||
|
||||
Reference in New Issue
Block a user