New Check System Implemented!

Massive Overhaul
This commit is contained in:
Driftay 2019-09-08 01:25:19 -04:00
parent 9f2f491dc9
commit ed5394565d
14 changed files with 617 additions and 108 deletions

View File

@ -23,11 +23,25 @@ import java.util.concurrent.ConcurrentHashMap;
public interface Faction extends EconomyParticipator {
long getCheckNotifier();
void setCheckNotifier(long minutes);
void sendCheckNotify();
int getWallCheckMinutes();
void setWallCheckMinutes(int minutes);
int getBufferCheckMinutes();
void setBufferCheckMinutes(int minutes);
Map<Long, String> getChecks();
Map<UUID, Integer> getPlayerBufferCheckCount();
Map<UUID, Integer> getPlayerWallCheckCount();
boolean isWeeWoo();
void setWeeWoo(boolean weeWoo);
boolean altInvited(FPlayer fplayer);

View File

@ -6,6 +6,8 @@ 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.check.CheckTask;
import com.massivecraft.factions.cmd.check.WeeWooTask;
import com.massivecraft.factions.cmd.chest.ChestLogsHandler;
import com.massivecraft.factions.integration.Econ;
import com.massivecraft.factions.integration.Worldguard;
@ -193,10 +195,6 @@ public class P extends MPlugin {
faction.addFPlayer(fPlayer);
}
}
if (Conf.useCheckSystem) {
new CheckWallTask().runTaskTimerAsynchronously(this, 0L, 1200L);
this.log(Level.INFO, "Enabling Check Wall Timers!");
}
if (getConfig().getBoolean("enable-faction-flight", true)) {
UtilFly.run();
@ -241,7 +239,16 @@ public class P extends MPlugin {
}
log("Skript addon registered!");
}
if(Conf.useCheckSystem) {
int minute = 1200;
this.getServer().getScheduler().runTaskTimerAsynchronously(this, new CheckTask(this, 3), 0L, (long) (minute * 3));
this.getServer().getScheduler().runTaskTimerAsynchronously(this, new CheckTask(this, 5), 0L, (long) (minute * 5));
this.getServer().getScheduler().runTaskTimerAsynchronously(this, new CheckTask(this, 10), 0L, (long) (minute * 10));
this.getServer().getScheduler().runTaskTimerAsynchronously(this, new CheckTask(this, 15), 0L, (long) (minute * 15));
this.getServer().getScheduler().runTaskTimerAsynchronously(this, new CheckTask(this, 30), 0L, (long) (minute * 30));
this.getServer().getScheduler().runTaskTimer(this, CheckTask::cleanupTask, 0L, 1200L);
this.getServer().getScheduler().runTaskTimerAsynchronously(this, new WeeWooTask(this), 600L, 600L);
}
ShopConfig.setup();
getServer().getPluginManager().registerEvents(factionsPlayerListener = new FactionsPlayerListener(), this);

View File

@ -1,56 +0,0 @@
package com.massivecraft.factions.cmd;
import com.massivecraft.factions.Conf;
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;
public class CmdCheck extends FCommand {
public CmdCheck() {
this.aliases.add("check");
this.requiredArgs.add("minutes");
this.permission = Permission.CHECK.node;
this.disableOnLock = true;
this.disableOnSpam = false;
this.senderMustBePlayer = true;
this.senderMustBeMember = true;
this.senderMustBeModerator = false;
this.senderMustBeColeader = false;
this.senderMustBeAdmin = false;
}
@Override
public void perform() {
if (!Conf.useCheckSystem) {
msg(TL.GENERIC_DISABLED);
return;
}
Access access = myFaction.getAccess(fme, PermissableAction.CHECK);
if ((access == Access.DENY || (access == Access.UNDEFINED && !assertMinRole(Role.LEADER))) && !fme.isAdminBypassing()) {
fme.msg(TL.GENERIC_NOPERMISSION, "check");
return;
}
int minutes = this.argAsInt(0);
if (minutes <= 0) {
msg(TL.COMMAND_CHECK_INVALID_NUMBER);
} else {
myFaction.setCheckNotifier(minutes);
msg(TL.COMMAND_CHECK_SUCCESSFUL.format(minutes));
}
}
@Override
public TL getUsageTranslation() {
return TL.COMMAND_CHECK_DESCRIPTION;
}
}

View File

@ -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.check.CmdCheck;
import com.massivecraft.factions.cmd.check.CmdWeeWoo;
import com.massivecraft.factions.cmd.chest.CmdChest;
import com.massivecraft.factions.cmd.claim.*;
import com.massivecraft.factions.cmd.econ.CmdMoney;
@ -136,6 +138,7 @@ public class FCmdRoot extends FCommand {
public CmdShop cmdShop = new CmdShop();
public CmdMissions cmdMissions = new CmdMissions();
public CmdCheck cmdCheck = new CmdCheck();
public CmdWeeWoo cmdWeeWoo = new CmdWeeWoo();
public FCmdRoot() {
@ -258,6 +261,7 @@ public class FCmdRoot extends FCommand {
if (Conf.useCheckSystem) {
this.addSubCommand(this.cmdCheck);
this.addSubCommand(this.cmdWeeWoo);
}
if (P.p.getConfig().getBoolean("Missions-Enabled")) {

View File

@ -0,0 +1,89 @@
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.util.FactionGUI;
import com.massivecraft.factions.util.XMaterial;
import com.massivecraft.factions.zcore.util.TL;
import org.bukkit.DyeColor;
import org.bukkit.event.inventory.ClickType;
import org.bukkit.inventory.Inventory;
import org.bukkit.inventory.ItemStack;
import org.bukkit.inventory.meta.ItemMeta;
import org.bukkit.material.MaterialData;
import java.text.SimpleDateFormat;
import java.util.*;
public class CheckHistoryFrame implements FactionGUI {
private P plugin;
private Faction faction;
private Inventory inventory;
private SimpleDateFormat simpleDateFormat;
public CheckHistoryFrame(P plugin, Faction faction) {
this.simpleDateFormat = new SimpleDateFormat(Conf.dateFormat);
this.plugin = plugin;
this.faction = faction;
this.inventory = plugin.getServer().createInventory(this, 54, TL.CHECK_HISTORY_GUI_TITLE.toString());
}
public void onClick(int slot, ClickType action) {
}
public void build() {
int currentSlot = 0;
for (Map.Entry<Long, String> entry : Lists.reverse(new ArrayList<>(faction.getChecks().entrySet()))) {
if (currentSlot >= 54) {
continue;
}
ItemStack itemStack = new ItemStack(XMaterial.MAGENTA_STAINED_GLASS_PANE.parseItem());
if (entry.getValue().startsWith("U")) {
itemStack.setDurability((short) 2);
MaterialData data = itemStack.getData();
data.setData(DyeColor.MAGENTA.getWoolData());
itemStack.setData(data);
ItemMeta itemMeta = itemStack.getItemMeta();
itemMeta.setDisplayName(TL.CHECK_WALLS_CHECKED_GUI_ICON.toString());
itemMeta.setLore(Arrays.asList(TL.CHECK_TIME_LORE_LINE.format(simpleDateFormat.format(new Date(entry.getKey()))), TL.CHECK_PLAYER_LORE_LINE.format(entry.getValue().substring(1))));
itemStack.setItemMeta(itemMeta);
} else if (entry.getValue().startsWith("Y")) {
itemStack.setDurability((short) 2);
MaterialData data = itemStack.getData();
data.setData(DyeColor.MAGENTA.getWoolData());
itemStack.setData(data);
ItemMeta itemMeta = itemStack.getItemMeta();
itemMeta.setDisplayName(TL.CHECK_BUFFERS_CHECKED_GUI_ICON.toString());
itemMeta.setLore(Arrays.asList(TL.CHECK_TIME_LORE_LINE.format(simpleDateFormat.format(new Date(entry.getKey()))), TL.CHECK_PLAYER_LORE_LINE.format(entry.getValue().substring(1))));
itemStack.setItemMeta(itemMeta);
} else if (entry.getValue().startsWith("J")) {
itemStack.setDurability((short) 0);
MaterialData data = itemStack.getData();
data.setData(DyeColor.WHITE.getWoolData());
itemStack.setData(data);
ItemMeta itemMeta = itemStack.getItemMeta();
itemMeta.setDisplayName(TL.CHECK_WALLS_UNCHECKED_GUI_ICON.toString());
itemMeta.setLore(Collections.singletonList(TL.CHECK_TIME_LORE_LINE.format(simpleDateFormat.format(new Date(entry.getKey())))));
itemStack.setItemMeta(itemMeta);
} else if (entry.getValue().startsWith("H")) {
itemStack.setDurability((short) 0);
MaterialData data = itemStack.getData();
data.setData(DyeColor.WHITE.getWoolData());
itemStack.setData(data);
ItemMeta itemMeta = itemStack.getItemMeta();
itemMeta.setDisplayName(TL.CHECK_BUFFERS_UNCHECKED_GUI_ICON.toString());
itemMeta.setLore(Collections.singletonList(TL.CHECK_TIME_LORE_LINE.format(simpleDateFormat.format(new Date(entry.getKey())))));
itemStack.setItemMeta(itemMeta);
}
inventory.setItem(currentSlot, itemStack);
++currentSlot;
}
}
public Inventory getInventory() {
return inventory;
}
}

View File

@ -0,0 +1,110 @@
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.util.FactionGUI;
import com.massivecraft.factions.util.XMaterial;
import com.massivecraft.factions.zcore.util.TL;
import org.bukkit.ChatColor;
import org.bukkit.event.inventory.ClickType;
import org.bukkit.inventory.Inventory;
import org.bukkit.inventory.InventoryHolder;
import org.bukkit.inventory.ItemStack;
import org.bukkit.inventory.meta.ItemMeta;
import java.util.Collections;
public class CheckSettingsFrame implements InventoryHolder, FactionGUI {
private P plugin;
private FPlayer fPlayer;
private Inventory inventory;
public CheckSettingsFrame(P 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());
}
public void onClick(int slot, ClickType action) {
Faction faction = this.fPlayer.getFaction();
if (slot == P.p.getConfig().getInt("f-check.wall-check.slot")) {
faction.setWallCheckMinutes(getNext(faction.getWallCheckMinutes()));
} else {
if (slot == P.p.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")) {
faction.setBufferCheckMinutes(getNext(faction.getBufferCheckMinutes()));
}
}
build();
fPlayer.getPlayer().openInventory(inventory);
}
public void build() {
Faction faction = fPlayer.getFaction();
ItemStack wallsStack = XMaterial.matchXMaterial(P.p.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();
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();
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);
}
public Inventory getInventory() {
return this.inventory;
}
private int getNext(int current) {
switch (current) {
case 0: {
return 3;
}
case 3: {
return 5;
}
case 5: {
return 10;
}
case 10: {
return 15;
}
case 15: {
return 30;
}
case 30: {
return 0;
}
default: {
return 0;
}
}
}
private String getFormatted(int minutes) {
if (minutes == 0) {
return "Offline";
}
return minutes + " Minutes";
}
public String color(String message){
return ChatColor.translateAlternateColorCodes('&', message);
}
}

View File

@ -0,0 +1,96 @@
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.Factions;
import com.massivecraft.factions.P;
import com.massivecraft.factions.zcore.util.TL;
import java.text.SimpleDateFormat;
import java.util.ArrayList;
import java.util.List;
import java.util.concurrent.CopyOnWriteArrayList;
public class CheckTask implements Runnable {
private SimpleDateFormat simpleDateFormat = new SimpleDateFormat(Conf.dateFormat);
private static List<String> wallChecks = new CopyOnWriteArrayList<>();
private static List<String> bufferChecks = new CopyOnWriteArrayList<>();
private P plugin;
private int minute;
public CheckTask(P plugin, int minute) {
this.plugin = plugin;
this.minute = minute;
}
public static void cleanupTask() {
for (Faction faction : Factions.getInstance().getAllFactions()) {
if (!faction.isNormal()) {
continue;
}
List<Long> remove = new ArrayList<>();
int i = 0;
for (Long key : Lists.reverse(new ArrayList<>(faction.getChecks().keySet()))) {
if (i >= 54) {
remove.add(key);
}
++i;
}
remove.forEach(r -> faction.getChecks().remove(r));
}
}
@Override
public void run() {
long currentTime = System.currentTimeMillis();
for (Faction faction : Factions.getInstance().getAllFactions()) {
if (!faction.isNormal()) {
continue;
}
if (faction.getWallCheckMinutes() != minute) {
continue;
}
long CurrentTime = currentTime;
if (CheckTask.wallChecks.contains(faction.getId())) {
plugin.getServer().getScheduler().runTask(plugin, () -> faction.getChecks().put(CurrentTime, "J"));
} else {
CheckTask.wallChecks.add(faction.getId());
}
faction.msg(TL.CHECK_WALLS_CHECK);
}
++currentTime;
for (Faction faction : Factions.getInstance().getAllFactions()) {
if (!faction.isNormal()) {
continue;
}
if (faction.getBufferCheckMinutes() != minute) {
continue;
}
if (CheckTask.bufferChecks.contains(faction.getId())) {
Faction faction2 = null;
long CurrentTime2 = 0;
plugin.getServer().getScheduler().runTask(plugin, () -> {
if (faction2 != null) {
faction2.getChecks().put(CurrentTime2, "H");
}
});
} else {
CheckTask.bufferChecks.add(faction.getId());
}
faction.msg(TL.CHECK_BUFFERS_CHECK);
}
}
public static boolean wallCheck(String factionId) {
return CheckTask.wallChecks.remove(factionId);
}
public static boolean bufferCheck(String factionId) {
return CheckTask.bufferChecks.remove(factionId);
}
}

View File

@ -0,0 +1,114 @@
package com.massivecraft.factions.cmd.check;
import com.massivecraft.factions.Conf;
import com.massivecraft.factions.cmd.FCommand;
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;
import java.text.SimpleDateFormat;
import java.util.*;
import java.util.stream.Collectors;
public class CmdCheck extends FCommand {
private SimpleDateFormat simpleDateFormat;
public CmdCheck() {
this.simpleDateFormat = new SimpleDateFormat(Conf.dateFormat);
this.aliases.add("check");
this.requiredArgs.add("walls/buffers/settings/leaderboard");
this.disableOnLock = true;
senderMustBePlayer = true;
senderMustBeMember = true;
senderMustBeModerator = false;
senderMustBeColeader = false;
senderMustBeAdmin = false;
}
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");
return;
}
long currentTime = System.currentTimeMillis();
if (subCommand.equalsIgnoreCase("leaderboard")) {
msg(TL.CHECK_LEADERBOARD_HEADER);
Map<UUID, Integer> players = new HashMap<>();
for (Map.Entry<UUID, Integer> entry : myFaction.getPlayerWallCheckCount().entrySet()) {
players.put(entry.getKey(), entry.getValue());
}
for (Map.Entry<UUID, Integer> entry : myFaction.getPlayerBufferCheckCount().entrySet()) {
if (players.containsKey(entry.getKey())) {
players.replace(entry.getKey(), players.get(entry.getKey()) + entry.getValue());
} else {
players.put(entry.getKey(), entry.getValue());
}
}
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)));
}
if (entryList.isEmpty()) {
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);
return;
}
msg(TL.CHECK_ALREADY_CHECKED);
} else {
int current = myFaction.getPlayerWallCheckCount().getOrDefault(me.getUniqueId(), 0);
if (current == 0) {
myFaction.getPlayerWallCheckCount().put(me.getUniqueId(), 1);
} else {
myFaction.getPlayerWallCheckCount().replace(me.getUniqueId(), current + 1);
}
myFaction.getChecks().put(currentTime, "U" + fme.getNameAndTag());
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);
return;
}
msg(TL.CHECK_ALREADY_CHECKED);
} else {
int current = myFaction.getPlayerBufferCheckCount().getOrDefault(me.getUniqueId(), 0);
if (current == 0) {
myFaction.getPlayerBufferCheckCount().put(me.getUniqueId(), 1);
} else {
myFaction.getPlayerBufferCheckCount().replace(me.getUniqueId(), current + 1);
}
myFaction.getChecks().put(System.currentTimeMillis(), "Y" + fme.getNameAndTag());
msg(TL.CHECK_BUFFERS_MARKED_CHECKED);
}
} else if (subCommand.equalsIgnoreCase("settings")) {
if (!fme.getRole().isAtLeast(Role.COLEADER)) {
msg(TL.CHECK_MUST_BE_ATLEAST_COLEADER);
return;
}
CheckSettingsFrame checkGUI = new CheckSettingsFrame(p, fme);
checkGUI.build();
fme.getPlayer().openInventory(checkGUI.getInventory());
}
}
public TL getUsageTranslation() {
return TL.COMMAND_CHECK_DESCRIPTION;
}
}

View File

@ -0,0 +1,49 @@
package com.massivecraft.factions.cmd.check;
import com.massivecraft.factions.cmd.FCommand;
import com.massivecraft.factions.zcore.util.TL;
public class CmdWeeWoo extends FCommand {
public CmdWeeWoo() {
this.aliases.add("weewoo");
this.requiredArgs.add("start/stop");
this.disableOnLock = true;
senderMustBePlayer = true;
senderMustBeMember = true;
senderMustBeModerator = false;
senderMustBeColeader = false;
senderMustBeAdmin = false;
}
public void perform() {
if (myFaction == null || !myFaction.isNormal()) {
return;
}
String argument = argAsString(0);
boolean weewoo = myFaction.isWeeWoo();
if (argument.equalsIgnoreCase("start")) {
if (weewoo) {
msg(TL.COMMAND_WEEWOO_ALREADY_STARTED);
return;
}
myFaction.setWeeWoo(true);
msg(TL.COMMAND_WEEWOO_STARTED, fme.getNameAndTag());
} else if (argument.equalsIgnoreCase("stop")) {
if (!weewoo) {
msg(TL.COMMAND_WEEWOO_ALREADY_STOPPED);
return;
}
myFaction.setWeeWoo(false);
msg(TL.COMMAND_WEEWOO_STOPPED, fme.getNameAndTag());
} else {
msg("/f weewoo <start/stop>");
}
}
public TL getUsageTranslation() {
return TL.COMMAND_WEEWOO_DESCRIPTION;
}
}

View File

@ -0,0 +1,25 @@
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.zcore.util.TL;
public class WeeWooTask implements Runnable {
private P plugin;
public WeeWooTask(P plugin) {
this.plugin = plugin;
}
@Override
public void run() {
for (Faction faction : Factions.getInstance().getAllFactions()) {
if (!faction.isWeeWoo()) {
continue;
}
faction.msg(TL.WEE_WOO_MESSAGE);
}
}
}

View File

@ -1,23 +0,0 @@
package com.massivecraft.factions.util;
import com.massivecraft.factions.Faction;
import com.massivecraft.factions.Factions;
import org.bukkit.scheduler.BukkitRunnable;
public class CheckWallTask extends BukkitRunnable {
private int overtime;
public CheckWallTask() {
overtime = 0;
}
public void run() {
++overtime;
for (Faction faction : Factions.getInstance().getAllFactions()) {
if (faction.getCheckNotifier() != 0L && overtime % faction.getCheckNotifier() == 0L) {
faction.sendCheckNotify();
}
}
}
}

View File

@ -67,7 +67,6 @@ public abstract class MemoryFaction implements Faction, EconomyParticipator {
protected Role defaultRole;
protected Map<Permissable, Map<PermissableAction, Access>> permissions = new HashMap<>();
protected Set<BanInfo> bans = new HashSet<>();
protected long checkNotifier = 0;
protected String player;
Inventory chest;
Map<String, Object> bannerSerialized;
@ -75,6 +74,12 @@ public abstract class MemoryFaction implements Faction, EconomyParticipator {
private int strikes = 0;
private int points = 0;
private Map<String, Mission> missions = new ConcurrentHashMap<>();
private int wallCheckMinutes;
private int bufferCheckMinutes;
private Map<Long, String> checks;
private Map<UUID, Integer> playerWallCheckCount;
private Map<UUID, Integer> playerBufferCheckCount;
private boolean weeWoo;
// -------------------------------------------- //
@ -98,7 +103,12 @@ public abstract class MemoryFaction implements Faction, EconomyParticipator {
this.foundedDate = System.currentTimeMillis();
this.maxVaults = Conf.defaultMaxVaults;
this.defaultRole = Role.RECRUIT;
this.checkNotifier = 0;
this.wallCheckMinutes = 0;
this.bufferCheckMinutes = 0;
this.weeWoo = false;
this.checks = new ConcurrentHashMap<>();
this.playerWallCheckCount = new ConcurrentHashMap<>();
this.playerBufferCheckCount = new ConcurrentHashMap<>();
resetPerms(); // Reset on new Faction so it has default values.
}
@ -124,7 +134,12 @@ public abstract class MemoryFaction implements Faction, EconomyParticipator {
invites = old.invites;
announcements = old.announcements;
this.defaultRole = Role.NORMAL;
this.checkNotifier = 0;
this.wallCheckMinutes = 0;
this.bufferCheckMinutes = 0;
this.weeWoo = false;
this.checks = new ConcurrentHashMap<>();
this.playerWallCheckCount = new ConcurrentHashMap<>();
this.playerBufferCheckCount = new ConcurrentHashMap<>();
resetPerms(); // Reset on new Faction so it has default values.
}
@ -345,20 +360,6 @@ public abstract class MemoryFaction implements Faction, EconomyParticipator {
return false;
}
@Override
public long getCheckNotifier() {
return this.checkNotifier;
}
@Override
public void setCheckNotifier(final long minutes) {
this.checkNotifier = minutes;
}
@Override
public void sendCheckNotify() {
this.sendMessage(TL.CHECK_NOTIFY_MESSAGE.toString());
}
public Set<BanInfo> getBannedPlayers() {
return this.bans;
@ -463,6 +464,42 @@ public abstract class MemoryFaction implements Faction, EconomyParticipator {
upgrades.put(upgrade.toString(), level);
}
public int getWallCheckMinutes() {
return this.wallCheckMinutes;
}
public void setWallCheckMinutes(final int wallCheckMinutes) {
this.wallCheckMinutes = wallCheckMinutes;
}
public int getBufferCheckMinutes() {
return this.bufferCheckMinutes;
}
public void setBufferCheckMinutes(final int bufferCheckMinutes) {
this.bufferCheckMinutes = bufferCheckMinutes;
}
public Map<Long, String> getChecks() {
return this.checks;
}
public Map<UUID, Integer> getPlayerBufferCheckCount() {
return this.playerBufferCheckCount;
}
public Map<UUID, Integer> getPlayerWallCheckCount() {
return this.playerWallCheckCount;
}
public boolean isWeeWoo() {
return this.weeWoo;
}
public void setWeeWoo(final boolean weeWoo) {
this.weeWoo = weeWoo;
}
public Location getCheckpoint() {
return checkpoint;
}

View File

@ -280,10 +280,35 @@ public enum TL {
COMMAND_CREATE_CREATEDLOG(" created a new faction: "),
COMMAND_CREATE_DESCRIPTION("Create a new faction"),
COMMAND_CHECK_INVALID_NUMBER("&c&l[!] &7You may not set your factions wall check timer to that number!"),
COMMAND_CHECK_SUCCESSFUL("&c&l[!] &7You have set your factions wall check timer to &b%1$d &7minutes!"),
COMMAND_CHECK_DESCRIPTION("Check your factions walls!"),
CHECK_NOTIFY_MESSAGE("\n &c&lFaction Walls&7» &bCheck Your Walls! \n"),
COMMAND_CHECK_DESCRIPTION("manage your factions check system!"),
CHECK_BUFFERS_CHECK("\n &c&lFaction Walls&7» &bCheck Your Buffers! \n"),
CHECK_WALLS_CHECK("\n &c&lFaction Walls&7» &bCheck Your Walls! \n"),
CHECK_ALREADY_CHECKED("&c&lFaction Settings&7» &bWalls have already been checked"),
CHECK_NO_CHECKS("&c&lFaction Walls&7» &bNothing to Check!"),
CHECK_WALLS_MARKED_CHECKED("&c&lFaction Walls&7» &aMarked walls as checked"),
CHECK_BUFFERS_MARKED_CHECKED("&c&lFaction Walls&7» &aMarked buffers as checked"),
CHECK_HISTORY_GUI_TITLE("&aCheck History"),
CHECK_SETTINGS_GUI_TITLE("&a&lManage Check Settings"),
CHECK_WALL_CHECK_GUI_ICON("&a&lWall Check Settings"),
CHECK_BUFFER_CHECK_GUI_ICON("&a&lBuffer Check Settings"),
CHECK_CHECK_LORE_LINE("&bCheck: &a%1$s"),
CHECK_WALLS_CHECKED_GUI_ICON("&aWalls checked"),
CHECK_BUFFERS_CHECKED_GUI_ICON("&aBuffers checked"),
CHECK_WALLS_UNCHECKED_GUI_ICON("&cWalls unchecked"),
CHECK_BUFFERS_UNCHECKED_GUI_ICON("&cBuffers unchecked"),
CHECK_TIME_LORE_LINE("&bTime: &f%1$s"),
CHECK_PLAYER_LORE_LINE("&bPlayer: &f%1$s"),
CHECK_HISTORY_GUI_ICON("&bCheck history"),
CHECK_MUST_BE_ATLEAST_COLEADER("&cYou must be atleast &dCo Leader &cto access &fcheck settings"),
WEE_WOO_MESSAGE("&c&lFaction WeeWoo&7» We Are Being Raided!"),
COMMAND_WEEWOO_STARTED("&c&lFaction WeeWoo&7» &aWeewoo started by %1$s"),
COMMAND_WEEWOO_STOPPED("&c&lFaction WeeWoo&7» &aWeewoo stopped by %1$s"),
COMMAND_WEEWOO_ALREADY_STARTED("&cWeewoo already started"),
COMMAND_WEEWOO_ALREADY_STOPPED("&cWeewoo already stopped"),
COMMAND_WEEWOO_DESCRIPTION("notifies all faction members you are being raided"),
CHECK_LEADERBOARD_HEADER("&8---- Check Leaderboard ----"),
CHECK_LEADERBOARD_LINE("&f%1$s. &d%2$s: &f%3$s (%4$s Buffer, %5$s Walls)"),
CHECK_LEADERBOARD_NO_DATA("&8No data"),
COMMAND_DEINVITE_CANDEINVITE("&c&l[!]&7 Players you can &cdeinvite: "),
COMMAND_DEINVITE_CLICKTODEINVITE("&c&l[!]&7 Click to &crevoke&7 invite for &c%1$s"),

View File

@ -576,6 +576,24 @@ fwarp-gui:
faction-creation-broadcast: true
faction-disband-broadcast: true
############################################################
# +------------------------------------------------------+ #
# | Faction Check System |#
# +------------------------------------------------------+ #
############################################################
#Everything else from display names to lores, is managed by lang.yml, so edit it there
f-check:
gui-rows: 3
wall-check:
Type: COBBLESTONE
slot: 10
buffer-check:
Type: OBSIDIAN
slot: 16
history:
Type: BOOK
slot: 13
############################################################
# +------------------------------------------------------+ #
# | Faction Invisibility | #