Introduced Brigadier Command System. More Formatting Coming in next commit.

This commit is contained in:
Driftay
2019-09-14 15:13:01 -04:00
parent b06e6e0f04
commit 3c9b606bb9
207 changed files with 4465 additions and 4017 deletions

View File

@@ -3,7 +3,7 @@ package com.massivecraft.factions.cmd.check;
import com.google.common.collect.Lists;
import com.massivecraft.factions.Conf;
import com.massivecraft.factions.Faction;
import com.massivecraft.factions.P;
import com.massivecraft.factions.FactionsPlugin;
import com.massivecraft.factions.util.FactionGUI;
import com.massivecraft.factions.util.XMaterial;
import com.massivecraft.factions.zcore.util.TL;
@@ -18,12 +18,12 @@ import java.text.SimpleDateFormat;
import java.util.*;
public class CheckHistoryFrame implements FactionGUI {
private P plugin;
private FactionsPlugin plugin;
private Faction faction;
private Inventory inventory;
private SimpleDateFormat simpleDateFormat;
public CheckHistoryFrame(P plugin, Faction faction) {
public CheckHistoryFrame(FactionsPlugin plugin, Faction faction) {
this.simpleDateFormat = new SimpleDateFormat(Conf.dateFormat);
this.plugin = plugin;
this.faction = faction;

View File

@@ -2,7 +2,7 @@ package com.massivecraft.factions.cmd.check;
import com.massivecraft.factions.FPlayer;
import com.massivecraft.factions.Faction;
import com.massivecraft.factions.P;
import com.massivecraft.factions.FactionsPlugin;
import com.massivecraft.factions.util.FactionGUI;
import com.massivecraft.factions.util.XMaterial;
import com.massivecraft.factions.zcore.util.TL;
@@ -16,11 +16,11 @@ import org.bukkit.inventory.meta.ItemMeta;
import java.util.Collections;
public class CheckSettingsFrame implements InventoryHolder, FactionGUI {
private P plugin;
private FactionsPlugin plugin;
private FPlayer fPlayer;
private Inventory inventory;
public CheckSettingsFrame(P plugin, FPlayer fPlayer) {
public CheckSettingsFrame(FactionsPlugin plugin, FPlayer fPlayer) {
this.plugin = plugin;
this.fPlayer = fPlayer;
this.inventory = plugin.getServer().createInventory(this, plugin.getConfig().getInt("f-check.gui-rows") * 9, TL.CHECK_SETTINGS_GUI_TITLE.toString());
@@ -28,16 +28,16 @@ public class CheckSettingsFrame implements InventoryHolder, FactionGUI {
public void onClick(int slot, ClickType action) {
Faction faction = this.fPlayer.getFaction();
if (slot == P.p.getConfig().getInt("f-check.wall-check.slot")) {
if (slot == FactionsPlugin.getInstance().getConfig().getInt("f-check.wall-check.slot")) {
faction.setWallCheckMinutes(getNext(faction.getWallCheckMinutes()));
} else {
if (slot == P.p.getConfig().getInt("f-check.history.slot")) {
if (slot == FactionsPlugin.getInstance().getConfig().getInt("f-check.history.slot")) {
CheckHistoryFrame checkHistoryFrame = new CheckHistoryFrame(plugin, fPlayer.getFaction());
checkHistoryFrame.build();
fPlayer.getPlayer().openInventory(checkHistoryFrame.getInventory());
return;
}
if (slot == P.p.getConfig().getInt("f-check.buffer-check.slot")) {
if (slot == FactionsPlugin.getInstance().getConfig().getInt("f-check.buffer-check.slot")) {
faction.setBufferCheckMinutes(getNext(faction.getBufferCheckMinutes()));
}
}
@@ -47,23 +47,23 @@ public class CheckSettingsFrame implements InventoryHolder, FactionGUI {
public void build() {
Faction faction = fPlayer.getFaction();
ItemStack wallsStack = XMaterial.matchXMaterial(P.p.getConfig().getString("f-check.wall-check.Type")).parseItem();
ItemStack wallsStack = XMaterial.matchXMaterial(FactionsPlugin.getInstance().getConfig().getString("f-check.wall-check.Type")).parseItem();
ItemMeta wallsMeta = wallsStack.getItemMeta();
wallsMeta.setDisplayName(TL.CHECK_WALL_CHECK_GUI_ICON.toString());
wallsMeta.setLore(Collections.singletonList(TL.CHECK_CHECK_LORE_LINE.format(getFormatted(faction.getWallCheckMinutes()))));
wallsStack.setItemMeta(wallsMeta);
inventory.setItem(P.p.getConfig().getInt("f-check.wall-check.slot"), wallsStack);
ItemStack bufferStack = XMaterial.matchXMaterial(P.p.getConfig().getString("f-check.buffer-check.Type")).parseItem();
inventory.setItem(FactionsPlugin.getInstance().getConfig().getInt("f-check.wall-check.slot"), wallsStack);
ItemStack bufferStack = XMaterial.matchXMaterial(FactionsPlugin.getInstance().getConfig().getString("f-check.buffer-check.Type")).parseItem();
ItemMeta bufferMeta = bufferStack.getItemMeta();
bufferMeta.setDisplayName(TL.CHECK_BUFFER_CHECK_GUI_ICON.toString());
bufferMeta.setLore(Collections.singletonList(TL.CHECK_CHECK_LORE_LINE.format(getFormatted(faction.getBufferCheckMinutes()))));
bufferStack.setItemMeta(bufferMeta);
inventory.setItem(P.p.getConfig().getInt("f-check.buffer-check.slot"), bufferStack);
ItemStack historyStack = XMaterial.matchXMaterial(P.p.getConfig().getString("f-check.history.Type")).parseItem();
inventory.setItem(FactionsPlugin.getInstance().getConfig().getInt("f-check.buffer-check.slot"), bufferStack);
ItemStack historyStack = XMaterial.matchXMaterial(FactionsPlugin.getInstance().getConfig().getString("f-check.history.Type")).parseItem();
ItemMeta historyMeta = historyStack.getItemMeta();
historyMeta.setDisplayName(TL.CHECK_HISTORY_GUI_ICON.toString());
historyStack.setItemMeta(historyMeta);
inventory.setItem(P.p.getConfig().getInt("f-check.history.slot"), historyStack);
inventory.setItem(FactionsPlugin.getInstance().getConfig().getInt("f-check.history.slot"), historyStack);
}
public Inventory getInventory() {

View File

@@ -4,7 +4,7 @@ import com.google.common.collect.Lists;
import com.massivecraft.factions.Conf;
import com.massivecraft.factions.Faction;
import com.massivecraft.factions.Factions;
import com.massivecraft.factions.P;
import com.massivecraft.factions.FactionsPlugin;
import com.massivecraft.factions.zcore.util.TL;
import java.text.SimpleDateFormat;
@@ -16,10 +16,10 @@ public class CheckTask implements Runnable {
private static List<String> wallChecks = new CopyOnWriteArrayList<>();
private static List<String> bufferChecks = new CopyOnWriteArrayList<>();
private SimpleDateFormat simpleDateFormat = new SimpleDateFormat(Conf.dateFormat);
private P plugin;
private FactionsPlugin plugin;
private int minute;
public CheckTask(P plugin, int minute) {
public CheckTask(FactionsPlugin plugin, int minute) {
this.plugin = plugin;
this.minute = minute;
}

View File

@@ -1,9 +1,12 @@
package com.massivecraft.factions.cmd.check;
import com.massivecraft.factions.Conf;
import com.massivecraft.factions.FactionsPlugin;
import com.massivecraft.factions.cmd.CommandContext;
import com.massivecraft.factions.cmd.CommandRequirements;
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;
import com.massivecraft.factions.zcore.fperms.PermissableAction;
import com.massivecraft.factions.zcore.util.TL;
import org.bukkit.OfflinePlayer;
@@ -20,34 +23,28 @@ public class CmdCheck extends FCommand {
this.aliases.add("check");
this.requiredArgs.add("walls/buffers/settings/leaderboard");
this.disableOnLock = true;
senderMustBePlayer = true;
senderMustBeMember = true;
senderMustBeModerator = false;
senderMustBeColeader = false;
senderMustBeAdmin = false;
this.requirements = new CommandRequirements.Builder(Permission.CHECK)
.playerOnly()
.withAction(PermissableAction.CHECK)
.memberOnly()
.build();
}
public void perform() {
if (myFaction == null || !myFaction.isNormal()) {
return;
}
String subCommand = argAsString(0, null);
Access access = myFaction.getAccess(fme, PermissableAction.CHECK);
if (access != Access.ALLOW && fme.getRole() != Role.LEADER) {
fme.msg(TL.GENERIC_NOPERMISSION, "check");
public void perform(CommandContext context) {
if (context.faction == null || !context.faction.isNormal()) {
return;
}
String subCommand = context.argAsString(0, null);
long currentTime = System.currentTimeMillis();
if (subCommand.equalsIgnoreCase("leaderboard")) {
msg(TL.CHECK_LEADERBOARD_HEADER);
context.msg(TL.CHECK_LEADERBOARD_HEADER);
Map<UUID, Integer> players = new HashMap<>();
for (Map.Entry<UUID, Integer> entry : myFaction.getPlayerWallCheckCount().entrySet()) {
for (Map.Entry<UUID, Integer> entry : context.faction.getPlayerWallCheckCount().entrySet()) {
players.put(entry.getKey(), entry.getValue());
}
for (Map.Entry<UUID, Integer> entry : myFaction.getPlayerBufferCheckCount().entrySet()) {
for (Map.Entry<UUID, Integer> entry : context.faction.getPlayerBufferCheckCount().entrySet()) {
if (players.containsKey(entry.getKey())) {
players.replace(entry.getKey(), players.get(entry.getKey()) + entry.getValue());
} else {
@@ -57,54 +54,54 @@ public class CmdCheck extends FCommand {
List<Map.Entry<UUID, Integer>> entryList = players.entrySet().stream().sorted(Comparator.comparingInt(Map.Entry::getValue)).collect(Collectors.toList());
for (int max = (entryList.size() > 10) ? 10 : entryList.size(), current = 0; current < max; ++current) {
Map.Entry<UUID, Integer> entry = entryList.get(current);
OfflinePlayer offlinePlayer = p.getServer().getOfflinePlayer(entry.getKey());
msg(TL.CHECK_LEADERBOARD_LINE.format(current + 1, offlinePlayer.getName(), entry.getValue(), myFaction.getPlayerBufferCheckCount().getOrDefault(entry.getKey(), 0), myFaction.getPlayerWallCheckCount().getOrDefault(entry.getKey(), 0)));
OfflinePlayer offlinePlayer = FactionsPlugin.getInstance().getServer().getOfflinePlayer(entry.getKey());
context.msg(TL.CHECK_LEADERBOARD_LINE.format(current + 1, offlinePlayer.getName(), entry.getValue(), context.faction.getPlayerBufferCheckCount().getOrDefault(entry.getKey(), 0), context.faction.getPlayerWallCheckCount().getOrDefault(entry.getKey(), 0)));
}
if (entryList.isEmpty()) {
msg(TL.CHECK_LEADERBOARD_NO_DATA);
context.msg(TL.CHECK_LEADERBOARD_NO_DATA);
}
} else if (subCommand.equalsIgnoreCase("walls")) {
if (!CheckTask.wallCheck(myFaction.getId())) {
if (myFaction.getChecks().isEmpty()) {
msg(TL.CHECK_NO_CHECKS);
if (!CheckTask.wallCheck(context.faction.getId())) {
if (context.faction.getChecks().isEmpty()) {
context.msg(TL.CHECK_NO_CHECKS);
return;
}
msg(TL.CHECK_ALREADY_CHECKED);
context.msg(TL.CHECK_ALREADY_CHECKED);
} else {
int current = myFaction.getPlayerWallCheckCount().getOrDefault(me.getUniqueId(), 0);
int current = context.faction.getPlayerWallCheckCount().getOrDefault(context.player.getUniqueId(), 0);
if (current == 0) {
myFaction.getPlayerWallCheckCount().put(me.getUniqueId(), 1);
context.faction.getPlayerWallCheckCount().put(context.player.getUniqueId(), 1);
} else {
myFaction.getPlayerWallCheckCount().replace(me.getUniqueId(), current + 1);
context.faction.getPlayerWallCheckCount().replace(context.player.getUniqueId(), current + 1);
}
myFaction.getChecks().put(currentTime, "U" + fme.getNameAndTag());
msg(TL.CHECK_WALLS_MARKED_CHECKED);
context.faction.getChecks().put(currentTime, "U" + context.fPlayer.getNameAndTag());
context.msg(TL.CHECK_WALLS_MARKED_CHECKED);
}
} else if (subCommand.equalsIgnoreCase("buffers")) {
if (!CheckTask.bufferCheck(myFaction.getId())) {
if (myFaction.getChecks().isEmpty()) {
msg(TL.CHECK_NO_CHECKS);
if (!CheckTask.bufferCheck(context.faction.getId())) {
if (context.faction.getChecks().isEmpty()) {
context.msg(TL.CHECK_NO_CHECKS);
return;
}
msg(TL.CHECK_ALREADY_CHECKED);
context.msg(TL.CHECK_ALREADY_CHECKED);
} else {
int current = myFaction.getPlayerBufferCheckCount().getOrDefault(me.getUniqueId(), 0);
int current = context.faction.getPlayerBufferCheckCount().getOrDefault(context.player.getUniqueId(), 0);
if (current == 0) {
myFaction.getPlayerBufferCheckCount().put(me.getUniqueId(), 1);
context.faction.getPlayerBufferCheckCount().put(context.player.getUniqueId(), 1);
} else {
myFaction.getPlayerBufferCheckCount().replace(me.getUniqueId(), current + 1);
context.faction.getPlayerBufferCheckCount().replace(context.player.getUniqueId(), current + 1);
}
myFaction.getChecks().put(System.currentTimeMillis(), "Y" + fme.getNameAndTag());
msg(TL.CHECK_BUFFERS_MARKED_CHECKED);
context.faction.getChecks().put(System.currentTimeMillis(), "Y" + context.fPlayer.getNameAndTag());
context.msg(TL.CHECK_BUFFERS_MARKED_CHECKED);
}
} else if (subCommand.equalsIgnoreCase("settings")) {
if (!fme.getRole().isAtLeast(Role.COLEADER)) {
msg(TL.CHECK_MUST_BE_ATLEAST_COLEADER);
if (!context.fPlayer.getRole().isAtLeast(Role.COLEADER)) {
context.msg(TL.CHECK_MUST_BE_ATLEAST_COLEADER);
return;
}
CheckSettingsFrame checkGUI = new CheckSettingsFrame(p, fme);
CheckSettingsFrame checkGUI = new CheckSettingsFrame(FactionsPlugin.getInstance(), context.fPlayer);
checkGUI.build();
fme.getPlayer().openInventory(checkGUI.getInventory());
context.fPlayer.getPlayer().openInventory(checkGUI.getInventory());
}
}

View File

@@ -1,6 +1,9 @@
package com.massivecraft.factions.cmd.check;
import com.massivecraft.factions.cmd.CommandContext;
import com.massivecraft.factions.cmd.CommandRequirements;
import com.massivecraft.factions.cmd.FCommand;
import com.massivecraft.factions.struct.Permission;
import com.massivecraft.factions.zcore.util.TL;
public class CmdWeeWoo extends FCommand {
@@ -8,38 +11,35 @@ public class CmdWeeWoo extends FCommand {
this.aliases.add("weewoo");
this.requiredArgs.add("start/stop");
this.disableOnLock = true;
senderMustBePlayer = true;
senderMustBeMember = true;
senderMustBeModerator = false;
senderMustBeColeader = false;
senderMustBeAdmin = false;
this.requirements = new CommandRequirements.Builder(Permission.CHECK)
.playerOnly()
.memberOnly()
.build();
}
public void perform() {
if (myFaction == null || !myFaction.isNormal()) {
public void perform(CommandContext context) {
if (context.faction == null || !context.faction.isNormal()) {
return;
}
String argument = argAsString(0);
boolean weewoo = myFaction.isWeeWoo();
String argument = context.argAsString(0);
boolean weewoo = context.faction.isWeeWoo();
if (argument.equalsIgnoreCase("start")) {
if (weewoo) {
msg(TL.COMMAND_WEEWOO_ALREADY_STARTED);
context.msg(TL.COMMAND_WEEWOO_ALREADY_STARTED);
return;
}
myFaction.setWeeWoo(true);
msg(TL.COMMAND_WEEWOO_STARTED, fme.getNameAndTag());
context.faction.setWeeWoo(true);
context.msg(TL.COMMAND_WEEWOO_STARTED, context.fPlayer.getNameAndTag());
} else if (argument.equalsIgnoreCase("stop")) {
if (!weewoo) {
msg(TL.COMMAND_WEEWOO_ALREADY_STOPPED);
context.msg(TL.COMMAND_WEEWOO_ALREADY_STOPPED);
return;
}
myFaction.setWeeWoo(false);
msg(TL.COMMAND_WEEWOO_STOPPED, fme.getNameAndTag());
context.faction.setWeeWoo(false);
context.msg(TL.COMMAND_WEEWOO_STOPPED, context.fPlayer.getNameAndTag());
} else {
msg("/f weewoo <start/stop>");
context.msg("/f weewoo <start/stop>");
}
}

View File

@@ -2,14 +2,14 @@ package com.massivecraft.factions.cmd.check;
import com.massivecraft.factions.Faction;
import com.massivecraft.factions.Factions;
import com.massivecraft.factions.P;
import com.massivecraft.factions.FactionsPlugin;
import com.massivecraft.factions.zcore.util.TL;
public class WeeWooTask implements Runnable {
private P plugin;
private FactionsPlugin plugin;
public WeeWooTask(P plugin) {
public WeeWooTask(FactionsPlugin plugin) {
this.plugin = plugin;
}