Begun Adding ChestLogs
//TODO flat file, shift click registry
This commit is contained in:
parent
49ec990c2f
commit
fdb76f39f5
@ -6,6 +6,7 @@ import com.google.gson.GsonBuilder;
|
||||
import com.google.gson.reflect.TypeToken;
|
||||
import com.massivecraft.factions.cmd.CmdAutoHelp;
|
||||
import com.massivecraft.factions.cmd.FCmdRoot;
|
||||
import com.massivecraft.factions.cmd.chest.ChestLogsHandler;
|
||||
import com.massivecraft.factions.integration.Econ;
|
||||
import com.massivecraft.factions.integration.Worldguard;
|
||||
import com.massivecraft.factions.integration.dynmap.EngineDynmap;
|
||||
@ -255,6 +256,7 @@ public class P extends MPlugin {
|
||||
new RedstoneUpgrade(),
|
||||
new ShopClickPersistence(),
|
||||
new MissionHandler(this),
|
||||
new ChestLogsHandler(),
|
||||
new SpawnerUpgrades()
|
||||
};
|
||||
|
||||
|
@ -3,6 +3,8 @@ package com.massivecraft.factions.cmd;
|
||||
import com.massivecraft.factions.Conf;
|
||||
import com.massivecraft.factions.P;
|
||||
import com.massivecraft.factions.cmd.alts.CmdAlts;
|
||||
import com.massivecraft.factions.cmd.chest.CmdChest;
|
||||
import com.massivecraft.factions.cmd.chest.CmdChestLogs;
|
||||
import com.massivecraft.factions.cmd.claim.*;
|
||||
import com.massivecraft.factions.cmd.econ.CmdMoney;
|
||||
import com.massivecraft.factions.cmd.logout.CmdLogout;
|
||||
@ -133,6 +135,7 @@ public class FCmdRoot extends FCommand {
|
||||
public CmdNotifications cmdNotifications = new CmdNotifications();
|
||||
public CmdShop cmdShop = new CmdShop();
|
||||
public CmdMissions cmdMissions = new CmdMissions();
|
||||
public CmdChestLogs cmdChestLogs = new CmdChestLogs();
|
||||
|
||||
public FCmdRoot() {
|
||||
super();
|
||||
@ -245,6 +248,7 @@ public class FCmdRoot extends FCommand {
|
||||
this.addSubCommand(this.cmdLowPower);
|
||||
this.addSubCommand(this.cmdTntFill);
|
||||
this.addSubCommand(this.cmdChest);
|
||||
this.addSubCommand(this.cmdChestLogs);
|
||||
this.addSubCommand(this.cmdSetBanner);
|
||||
this.addSubCommand(this.cmdStrikeSet);
|
||||
this.addSubCommand(this.cmdSpam);
|
||||
|
@ -0,0 +1,123 @@
|
||||
package com.massivecraft.factions.cmd.chest;
|
||||
|
||||
import com.massivecraft.factions.FPlayers;
|
||||
import org.bukkit.Material;
|
||||
import org.bukkit.entity.Player;
|
||||
import org.bukkit.event.EventHandler;
|
||||
import org.bukkit.event.Listener;
|
||||
import org.bukkit.event.inventory.InventoryClickEvent;
|
||||
import org.bukkit.inventory.Inventory;
|
||||
import org.bukkit.inventory.ItemStack;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.HashMap;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
|
||||
public class ChestLogsHandler implements Listener {
|
||||
|
||||
|
||||
public static HashMap<String, List<String>> removeMap = new HashMap<>();
|
||||
public static HashMap<String, List<String>> addMap = new HashMap<>();
|
||||
public static HashMap<String, Integer> totalMap = new HashMap<>();
|
||||
|
||||
public static int getAll(String uuid) {
|
||||
int t = 0;
|
||||
t = t + removeMap.get(uuid).size();
|
||||
t = t + addMap.get(uuid).size();
|
||||
return t;
|
||||
}
|
||||
|
||||
public static int getAll() {
|
||||
int t = 0;
|
||||
for (Map.Entry<String, List<String>> entry : removeMap.entrySet()) {
|
||||
t = t + entry.getValue().size();
|
||||
}
|
||||
for (Map.Entry<String, List<String>> entry : addMap.entrySet()) {
|
||||
t = t + entry.getValue().size();
|
||||
}
|
||||
return t;
|
||||
}
|
||||
|
||||
public void mapAdd(String uuid, String string) {
|
||||
List<String> list = new ArrayList<>();
|
||||
if (addMap.get(uuid) != null) {
|
||||
list = addMap.get(uuid);
|
||||
}
|
||||
list.add(string);
|
||||
addMap.remove(uuid);
|
||||
addMap.put(uuid, list);
|
||||
|
||||
if (totalMap.get(uuid) == null) {
|
||||
totalMap.put(uuid, 1);
|
||||
} else {
|
||||
int t = totalMap.get(uuid);
|
||||
totalMap.remove(uuid);
|
||||
totalMap.put(uuid, t + 1);
|
||||
}
|
||||
}
|
||||
|
||||
public void mapRemove(String uuid, String string) {
|
||||
List<String> list = new ArrayList<>();
|
||||
if (removeMap.get(uuid) != null) {
|
||||
list = removeMap.get(uuid);
|
||||
}
|
||||
list.add(string);
|
||||
removeMap.remove(uuid);
|
||||
removeMap.put(uuid, list);
|
||||
if (totalMap.get(uuid) == null) {
|
||||
totalMap.put(uuid, 1);
|
||||
} else {
|
||||
int t = totalMap.get(uuid);
|
||||
totalMap.remove(uuid);
|
||||
totalMap.put(uuid, t + 1);
|
||||
}
|
||||
}
|
||||
|
||||
public String itemString(ItemStack itemStack) {
|
||||
String s = "x" + itemStack.getAmount() + " " + itemStack.getType().name().toLowerCase();
|
||||
if (itemStack.hasItemMeta() && itemStack.getItemMeta().hasDisplayName()) {
|
||||
s = s + " (" + itemStack.getItemMeta().getDisplayName() + ")";
|
||||
}
|
||||
return s.replace("_", " ");
|
||||
}
|
||||
|
||||
@EventHandler
|
||||
public void fChestInventoryClick(InventoryClickEvent e) {
|
||||
Player p = (Player) e.getWhoClicked();
|
||||
|
||||
Inventory topInventory = p.getOpenInventory().getTopInventory();
|
||||
Inventory bottomInventory = p.getOpenInventory().getBottomInventory();
|
||||
if (topInventory != null) {
|
||||
if (topInventory.equals(FPlayers.getInstance().getByPlayer(p).getFaction().getChestInventory())) {
|
||||
|
||||
if (e.getClickedInventory() != null) {
|
||||
if (e.getClickedInventory().equals(topInventory)) {
|
||||
ItemStack current = e.getCurrentItem();
|
||||
if(current == null) return;
|
||||
ItemStack cursor = e.getCursor();
|
||||
if (e.getClick().isShiftClick()) return;
|
||||
if (cursor != null) {
|
||||
if (current.getType().equals(Material.AIR)) {
|
||||
if (!cursor.getType().equals(Material.AIR)) {
|
||||
mapAdd(p.getName(), itemString(cursor));
|
||||
}
|
||||
} else {
|
||||
if (!current.getType().equals(Material.AIR)) {
|
||||
mapRemove(p.getName(), itemString(current));
|
||||
}
|
||||
}
|
||||
}
|
||||
} else {
|
||||
if (e.getClickedInventory().equals(bottomInventory)) {
|
||||
//clicking from bottom inventory
|
||||
if (e.getClick().isShiftClick()) {
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -1,6 +1,7 @@
|
||||
package com.massivecraft.factions.cmd;
|
||||
package com.massivecraft.factions.cmd.chest;
|
||||
|
||||
import com.massivecraft.factions.P;
|
||||
import com.massivecraft.factions.cmd.FCommand;
|
||||
import com.massivecraft.factions.struct.Permission;
|
||||
import com.massivecraft.factions.struct.Role;
|
||||
import com.massivecraft.factions.zcore.fperms.Access;
|
||||
@ -42,10 +43,7 @@ public class CmdChest extends FCommand {
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
me.openInventory(fme.getFaction().getChestInventory());
|
||||
|
||||
|
||||
}
|
||||
|
||||
@Override
|
Loading…
Reference in New Issue
Block a user