Compare commits

...

1 Commits
1.6.x ... beta

Author SHA1 Message Date
Driftay
ce9038742f Code Optimizations 2020-06-09 06:28:34 -04:00
65 changed files with 333 additions and 496 deletions

View File

@ -268,7 +268,6 @@ public class Conf {
public static boolean ownedMessageInsideTerritory = true; public static boolean ownedMessageInsideTerritory = true;
public static boolean ownedMessageByChunk = false; public static boolean ownedMessageByChunk = false;
public static boolean pistonProtectionThroughDenyBuild = true; public static boolean pistonProtectionThroughDenyBuild = true;
public static Set<Material> loggableMaterials = EnumSet.noneOf(Material.class);
public static Set<Material> territoryProtectedMaterials = EnumSet.noneOf(Material.class); public static Set<Material> territoryProtectedMaterials = EnumSet.noneOf(Material.class);
public static Set<Material> territoryDenyUsageMaterials = EnumSet.noneOf(Material.class); public static Set<Material> territoryDenyUsageMaterials = EnumSet.noneOf(Material.class);
public static Set<Material> territoryProtectedMaterialsWhenOffline = EnumSet.noneOf(Material.class); public static Set<Material> territoryProtectedMaterialsWhenOffline = EnumSet.noneOf(Material.class);

View File

@ -167,12 +167,14 @@ public class FactionsPlugin extends MPlugin {
FactionsPlugin.instance.log("Minecraft Version 1.15 found."); FactionsPlugin.instance.log("Minecraft Version 1.15 found.");
mc115 = true; mc115 = true;
break; break;
default:
throw new IllegalStateException("Unexpected value: " + version);
} }
migrateFPlayerLeaders(); migrateFPlayerLeaders();
log("==== End Setup ===="); log("==== End Setup ====");
int pluginId = 7013; int pluginId = 7013;
Metrics metrics = new Metrics(this, pluginId); new Metrics(this, pluginId);
if (!preEnable()) { if (!preEnable()) {
this.loadSuccessful = false; this.loadSuccessful = false;
@ -394,14 +396,12 @@ public class FactionsPlugin extends MPlugin {
return this.mvdwPlaceholderAPIManager; return this.mvdwPlaceholderAPIManager;
} }
private boolean setupPermissions() { private void setupPermissions() {
try { try {
RegisteredServiceProvider<Permission> rsp = getServer().getServicesManager().getRegistration(Permission.class); RegisteredServiceProvider<Permission> rsp = getServer().getServicesManager().getRegistration(Permission.class);
if (rsp != null) perms = rsp.getProvider(); if (rsp != null) perms = rsp.getProvider();
} catch (NoClassDefFoundError ex) { } catch (NoClassDefFoundError ignored) {
return false;
} }
return perms != null;
} }
private boolean setupPlayervaults() { private boolean setupPlayervaults() {

View File

@ -50,7 +50,7 @@ public class CmdAnnounce extends FCommand {
return TL.COMMAND_ANNOUNCE_DESCRIPTION; return TL.COMMAND_ANNOUNCE_DESCRIPTION;
} }
protected class AnnounceBrigadier implements BrigadierProvider { protected static class AnnounceBrigadier implements BrigadierProvider {
@Override @Override
public ArgumentBuilder<Object, ?> get(ArgumentBuilder<Object, ?> parent) { public ArgumentBuilder<Object, ?> get(ArgumentBuilder<Object, ?> parent) {
return parent.then(RequiredArgumentBuilder.argument("message", StringArgumentType.greedyString())); return parent.then(RequiredArgumentBuilder.argument("message", StringArgumentType.greedyString()));

View File

@ -60,7 +60,6 @@ public class CmdBanner extends FCommand {
@Deprecated @Deprecated
public void takeMoney(FPlayer fme, int amt) { public void takeMoney(FPlayer fme, int amt) {
if (this.hasMoney(fme, amt)) { if (this.hasMoney(fme, amt)) {
Economy econ = FactionsPlugin.getInstance().getEcon();
fme.sendMessage(TL.COMMAND_BANNER_MONEYTAKE.toString().replace("{amount}", amt + "")); fme.sendMessage(TL.COMMAND_BANNER_MONEYTAKE.toString().replace("{amount}", amt + ""));
} }
} }

View File

@ -14,7 +14,6 @@ public class CmdBoom extends FCommand {
super(); super();
this.aliases.addAll(Aliases.boom); this.aliases.addAll(Aliases.boom);
//this.requiredArgs.add("");
this.optionalArgs.put("on/off", "flip"); this.optionalArgs.put("on/off", "flip");
this.requirements = new CommandRequirements.Builder(Permission.NO_BOOM) this.requirements = new CommandRequirements.Builder(Permission.NO_BOOM)

View File

@ -14,7 +14,6 @@ public class CmdBypass extends FCommand {
super(); super();
this.aliases.addAll(Aliases.bypass); this.aliases.addAll(Aliases.bypass);
//this.requiredArgs.add("");
this.optionalArgs.put("on/off", "flip"); this.optionalArgs.put("on/off", "flip");
this.requirements = new CommandRequirements.Builder(Permission.BYPASS) this.requirements = new CommandRequirements.Builder(Permission.BYPASS)

View File

@ -18,7 +18,6 @@ public class CmdChat extends FCommand {
super(); super();
this.aliases.addAll(Aliases.chat); this.aliases.addAll(Aliases.chat);
//this.requiredArgs.add("");
this.optionalArgs.put("mode", "next"); this.optionalArgs.put("mode", "next");
this.requirements = new CommandRequirements.Builder(Permission.CHAT) this.requirements = new CommandRequirements.Builder(Permission.CHAT)
@ -86,7 +85,7 @@ public class CmdChat extends FCommand {
return TL.COMMAND_CHAT_DESCRIPTION; return TL.COMMAND_CHAT_DESCRIPTION;
} }
protected class ChatBrigadier implements BrigadierProvider { protected static class ChatBrigadier implements BrigadierProvider {
@Override @Override
public ArgumentBuilder<Object, ?> get(ArgumentBuilder<Object, ?> parent) { public ArgumentBuilder<Object, ?> get(ArgumentBuilder<Object, ?> parent) {
return parent.then(LiteralArgumentBuilder.literal("public")) return parent.then(LiteralArgumentBuilder.literal("public"))

View File

@ -35,11 +35,10 @@ public class CmdCheckpoint extends FCommand {
if (myLocFaction == Factions.getInstance().getWilderness() || myLocFaction == context.faction) { if (myLocFaction == Factions.getInstance().getWilderness() || myLocFaction == context.faction) {
context.faction.setCheckpoint(context.player.getLocation()); context.faction.setCheckpoint(context.player.getLocation());
context.msg(TL.COMMAND_CHECKPOINT_SET); context.msg(TL.COMMAND_CHECKPOINT_SET);
return;
} else { } else {
context.msg(TL.COMMAND_CHECKPOINT_INVALIDLOCATION); context.msg(TL.COMMAND_CHECKPOINT_INVALIDLOCATION);
return;
} }
return;
} }
if (context.faction.getCheckpoint() == null) { if (context.faction.getCheckpoint() == null) {
context.msg(TL.COMMAND_CHECKPOINT_NOT_SET); context.msg(TL.COMMAND_CHECKPOINT_NOT_SET);

View File

@ -66,7 +66,7 @@ public class CmdCreate extends FCommand {
} }
ArrayList<String> tagValidationErrors = MiscUtil.validateTag(tag); ArrayList<String> tagValidationErrors = MiscUtil.validateTag(tag);
if (tagValidationErrors.size() > 0) { if (tagValidationErrors.isEmpty()) {
context.sendMessage(tagValidationErrors); context.sendMessage(tagValidationErrors);
return; return;
} }

View File

@ -39,7 +39,7 @@ public class CmdDescription extends FCommand {
// since "&" color tags seem to work even through plain old FPlayer.sendMessage() for some reason, we need to break those up // since "&" color tags seem to work even through plain old FPlayer.sendMessage() for some reason, we need to break those up
// And replace all the % because it messes with string formatting and this is easy way around that. // And replace all the % because it messes with string formatting and this is easy way around that.
String desc = TextUtil.implode(context.args, " ").replaceAll("%", "").replaceAll("(&([a-f0-9klmnor]))", "& $2"); String desc = TextUtil.implode(context.args, " ").replace("%", "").replaceAll("(&([a-f0-9klmnor]))", "& $2");
context.faction.setDescription(desc); context.faction.setDescription(desc);
Bukkit.getScheduler().scheduleSyncDelayedTask(FactionsPlugin.instance, () -> FactionsPlugin.instance.logFactionEvent(context.faction, FLogType.FDESC_EDIT, context.fPlayer.getName(), desc)); Bukkit.getScheduler().scheduleSyncDelayedTask(FactionsPlugin.instance, () -> FactionsPlugin.instance.logFactionEvent(context.faction, FLogType.FDESC_EDIT, context.fPlayer.getName(), desc));
if (!Conf.broadcastDescriptionChanges) { if (!Conf.broadcastDescriptionChanges) {

View File

@ -42,8 +42,8 @@ public class CmdDisband extends FCommand {
boolean isMyFaction = context.fPlayer != null && faction == context.faction; boolean isMyFaction = context.fPlayer != null && faction == context.faction;
if (!isMyFaction) { if (!isMyFaction && !Permission.DISBAND_ANY.has(context.sender, true)) {
if (!Permission.DISBAND_ANY.has(context.sender, true)) return; return;
} }
@ -70,7 +70,7 @@ public class CmdDisband extends FCommand {
return; return;
} }
if(Cooldown.isOnCooldown(context.fPlayer.getPlayer(), "disbandCooldown") && !context.fPlayer.isAdminBypassing()){ if (Cooldown.isOnCooldown(context.fPlayer.getPlayer(), "disbandCooldown") && !context.fPlayer.isAdminBypassing()) {
context.msg(TL.COMMAND_COOLDOWN); context.msg(TL.COMMAND_COOLDOWN);
return; return;
} }
@ -81,14 +81,10 @@ public class CmdDisband extends FCommand {
access = true; access = true;
} }
if (!access) { if (!access && Conf.useDisbandGUI && (!context.fPlayer.isAdminBypassing() || !context.player.isOp()) && !disbandMap.containsKey(context.player.getUniqueId().toString())) {
if (Conf.useDisbandGUI && (!context.fPlayer.isAdminBypassing() || !context.player.isOp())) {
if (!disbandMap.containsKey(context.player.getUniqueId().toString())) {
new FDisbandFrame(context.faction).buildGUI(context.fPlayer); new FDisbandFrame(context.faction).buildGUI(context.fPlayer);
return; return;
} }
}
}
// check for tnt before disbanding. // check for tnt before disbanding.
if (!disbandMap.containsKey(context.player.getUniqueId().toString()) && faction.getTnt() > 0) { if (!disbandMap.containsKey(context.player.getUniqueId().toString()) && faction.getTnt() > 0) {

View File

@ -88,11 +88,7 @@ public class CmdHome extends FCommand {
final Location loc = context.player.getLocation().clone(); final Location loc = context.player.getLocation().clone();
// if player is not in a safe zone or their own faction territory, only allow teleport if no enemies are nearby // if player is not in a safe zone or their own faction territory, only allow teleport if no enemies are nearby
if (Conf.homesTeleportAllowedEnemyDistance > 0 if (Conf.homesTeleportAllowedEnemyDistance > 0 && !faction.isSafeZone() && (!context.fPlayer.isInOwnTerritory() || !Conf.homesTeleportIgnoreEnemiesIfInOwnTerritory)) {
&& !faction.isSafeZone()
&& (!context.fPlayer.isInOwnTerritory()
|| (context.fPlayer.isInOwnTerritory()
&& !Conf.homesTeleportIgnoreEnemiesIfInOwnTerritory))) {
World w = loc.getWorld(); World w = loc.getWorld();
double x = loc.getX(); double x = loc.getX();

View File

@ -49,6 +49,7 @@ public class CmdInventorySee extends FCommand {
FPlayer targetInv = context.argAsFPlayer(0); FPlayer targetInv = context.argAsFPlayer(0);
if (targetInv == null || !fplayers.contains(targetInv.getPlayer())) { if (targetInv == null || !fplayers.contains(targetInv.getPlayer())) {
assert targetInv != null;
context.msg(TL.PLAYER_NOT_FOUND, Objects.requireNonNull(targetInv.getName())); context.msg(TL.PLAYER_NOT_FOUND, Objects.requireNonNull(targetInv.getName()));
return; return;
} }

View File

@ -63,7 +63,7 @@ public class CmdInvite extends FCommand {
FancyMessage message = new FancyMessage(TL.COMMAND_INVITE_INVITEDYOU.toString() FancyMessage message = new FancyMessage(TL.COMMAND_INVITE_INVITEDYOU.toString()
.replace("%1$s", context.fPlayer.describeTo(target, true)) .replace("%1$s", context.fPlayer.describeTo(target, true))
.replace("%2$s", context.faction.getTag()) .replace("%2$s", context.faction.getTag())
.replaceAll("&", "§")) .replace("&", "§"))
.tooltip(TL.COMMAND_INVITE_CLICKTOJOIN.toString()) .tooltip(TL.COMMAND_INVITE_CLICKTOJOIN.toString())
.command("/" + Conf.baseCommandAliases.get(0) + " join " + context.faction.getTag()); .command("/" + Conf.baseCommandAliases.get(0) + " join " + context.faction.getTag());
message.send(target.getPlayer()); message.send(target.getPlayer());

View File

@ -66,19 +66,17 @@ public class CmdRules extends FCommand {
String message = ""; String message = "";
StringBuilder string = new StringBuilder(message); StringBuilder string = new StringBuilder(message);
for (int i = 1; i <= context.args.size() - 1; i++) { for (int i = 1; i <= context.args.size() - 1; i++) {
string.append(" " + context.args.get(i)); string.append(" ").append(context.args.get(i));
} }
context.faction.addRule(string.toString()); context.faction.addRule(string.toString());
context.msg(TL.COMMAND_RULES_ADD_SUCCESS); context.msg(TL.COMMAND_RULES_ADD_SUCCESS);
} }
if (context.args.size() == 2) { if (context.args.size() == 2 && context.args.get(0).equalsIgnoreCase("remove")) {
if (context.args.get(0).equalsIgnoreCase("remove")) {
int index = context.argAsInt(1); int index = context.argAsInt(1);
context.faction.removeRule(index - 1); context.faction.removeRule(index - 1);
context.msg(TL.COMMAND_RULES_REMOVE_SUCCESS); context.msg(TL.COMMAND_RULES_REMOVE_SUCCESS);
} }
}
} }
} }

View File

@ -110,7 +110,7 @@ public class CmdShow extends FCommand {
parsed = parsed.substring(0, parsed.indexOf("{ig}")) + TL.COMMAND_SHOW_NOHOME.toString(); parsed = parsed.substring(0, parsed.indexOf("{ig}")) + TL.COMMAND_SHOW_NOHOME.toString();
} }
if (parsed.contains("%")) { if (parsed.contains("%")) {
parsed = parsed.replaceAll("%", ""); // Just in case it got in there before we disallowed it. parsed = parsed.replace("%", ""); // Just in case it got in there before we disallowed it.
} }
parsed = FactionsPlugin.getInstance().txt.parse(parsed); parsed = FactionsPlugin.getInstance().txt.parse(parsed);
FancyMessage localFancy = instance.txt.parseFancy(parsed); FancyMessage localFancy = instance.txt.parseFancy(parsed);

View File

@ -30,9 +30,7 @@ public class CmdTpBanner extends FCommand {
if (FactionsBlockListener.bannerLocations.containsKey(context.fPlayer.getTag())) { if (FactionsBlockListener.bannerLocations.containsKey(context.fPlayer.getTag())) {
context.msg(TL.COMMAND_TPBANNER_SUCCESS); context.msg(TL.COMMAND_TPBANNER_SUCCESS);
context.doWarmUp(WarmUpUtil.Warmup.BANNER, TL.WARMUPS_NOTIFY_TELEPORT, "Banner", () -> { context.doWarmUp(WarmUpUtil.Warmup.BANNER, TL.WARMUPS_NOTIFY_TELEPORT, "Banner", () -> context.player.teleport(FactionsBlockListener.bannerLocations.get(context.fPlayer.getTag())), FactionsPlugin.getInstance().getConfig().getLong("warmups.f-banner", 0));
context.player.teleport(FactionsBlockListener.bannerLocations.get(context.fPlayer.getTag()));
}, FactionsPlugin.getInstance().getConfig().getLong("warmups.f-banner", 0));
} else { } else {
context.msg(TL.COMMAND_TPBANNER_NOTSET); context.msg(TL.COMMAND_TPBANNER_NOTSET);
} }

View File

@ -33,13 +33,9 @@ public class CmdUnban extends FCommand {
return; // the above method sends a message if fails to find someone. return; // the above method sends a message if fails to find someone.
} }
if (target.getFaction() != context.fPlayer.getFaction()) { if (target.getFaction() != context.fPlayer.getFaction() && target.getFaction().getAccess(context.fPlayer, PermissableAction.BAN) != Access.ALLOW && !context.fPlayer.isAdminBypassing()) {
if (target.getFaction().getAccess(context.fPlayer, PermissableAction.BAN) != Access.ALLOW) {
if (!context.fPlayer.isAdminBypassing()) {
context.fPlayer.msg(TL.COMMAND_UNBAN_TARGET_IN_OTHER_FACTION, target.getName()); context.fPlayer.msg(TL.COMMAND_UNBAN_TARGET_IN_OTHER_FACTION, target.getName());
} }
}
}
if (!context.faction.isBanned(target)) { if (!context.faction.isBanned(target)) {
context.msg(TL.COMMAND_UNBAN_NOTBANNED, target.getName()); context.msg(TL.COMMAND_UNBAN_NOTBANNED, target.getName());

View File

@ -70,14 +70,10 @@ public class CommandRequirements {
return false; return false;
} }
if (access != Access.ALLOW) { if (access != Access.ALLOW && role != null && !context.fPlayer.getRole().isAtLeast(role)) {
// They have undefined assert their role
if (role != null && !context.fPlayer.getRole().isAtLeast(role)) {
// They do not fullfill the role
if (informIfNot) context.msg(TL.GENERIC_YOUMUSTBE, role.translation); if (informIfNot) context.msg(TL.GENERIC_YOUMUSTBE, role.translation);
return false; return false;
} }
}
// They have been explicitly allowed // They have been explicitly allowed
return true; return true;
} else { } else {

View File

@ -44,7 +44,7 @@ public class CmdAltsList extends FCommand {
return; return;
} }
if (faction.getAltPlayers().size() == 0) { if (faction.getAltPlayers().isEmpty()) {
context.msg(TL.COMMAND_ALTS_LIST_NOALTS, faction.getTag()); context.msg(TL.COMMAND_ALTS_LIST_NOALTS, faction.getTag());
return; return;
} }

View File

@ -114,7 +114,7 @@ public class FAuditMenu extends GUIMenu {
} }
lore.add(""); lore.add("");
lore.add(CC.Gray + "Click to toggle timestamp"); lore.add(CC.Gray + "Click to toggle timestamp");
setItem(slot++, (new ClickableItemStack((new ItemBuilder(Material.PAPER)).name(CC.GreenB + "Log #" + page).lore(lore).build())).setClickCallback((e) -> { setItem(slot++, (new ClickableItemStack((new ItemBuilder(Material.PAPER)).name(CC.GreenB + "Log #" + page).lore(lore).build())).setClickCallback(e -> {
e.setCancelled(true); e.setCancelled(true);
timeStamp = !timeStamp; timeStamp = !timeStamp;
drawItems(); drawItems();
@ -122,7 +122,7 @@ public class FAuditMenu extends GUIMenu {
} }
} }
} }
setItem(getSize() - 1, (new ClickableItemStack((new ItemBuilder(Material.ARROW)).name(CC.Green + "Previous Page").lore("", CC.Gray + "Click to view previous page!").build())).setClickCallback((event) -> { setItem(getSize() - 1, (new ClickableItemStack((new ItemBuilder(Material.ARROW)).name(CC.Green + "Previous Page").lore("", CC.Gray + "Click to view previous page!").build())).setClickCallback(event -> {
event.setCancelled(true); event.setCancelled(true);
Bukkit.getScheduler().scheduleSyncDelayedTask(FactionsPlugin.instance, () -> (new FAuditMenu(player, faction)).open(player)); Bukkit.getScheduler().scheduleSyncDelayedTask(FactionsPlugin.instance, () -> (new FAuditMenu(player, faction)).open(player));
})); }));

View File

@ -25,8 +25,6 @@ public class FLogManager {
private Map<UUID, LogTimer> logTimers = new ConcurrentHashMap<>(); private Map<UUID, LogTimer> logTimers = new ConcurrentHashMap<>();
private boolean saving = false; private boolean saving = false;
public FLogManager() {
}
public void log(Faction faction, FLogType type, String... arguments) { public void log(Faction faction, FLogType type, String... arguments) {
FactionLogs logs = factionLogMap.computeIfAbsent(faction.getId(), (n) -> new FactionLogs()); FactionLogs logs = factionLogMap.computeIfAbsent(faction.getId(), (n) -> new FactionLogs());
@ -90,8 +88,7 @@ public class FLogManager {
Faction faction = null; Faction faction = null;
for (Map.Entry<UUID, LogTimer> uuidLogTimerEntry : getLogTimers().entrySet()) { for (Map.Entry<UUID, LogTimer> uuidLogTimerEntry : getLogTimers().entrySet()) {
Map.Entry<UUID, LogTimer> timer = uuidLogTimerEntry; LogTimer logTimer = uuidLogTimerEntry.getValue();
LogTimer logTimer = timer.getValue();
if (faction == null) { if (faction == null) {
faction = Factions.getInstance().getFactionById(logTimer.getFactionId()); faction = Factions.getInstance().getFactionById(logTimer.getFactionId());
} }

View File

@ -65,11 +65,11 @@ public class FactionLogs {
} }
} }
} }
if (logs.size() <= 0) if (logs.isEmpty())
toRemove.add(logType); toRemove.add(logType);
} }
}); });
toRemove.forEach((rem) -> mostRecentLogs.remove(rem)); toRemove.forEach(rem -> mostRecentLogs.remove(rem));
} }
public Map<FLogType, LinkedList<FactionLog>> getMostRecentLogs() { public Map<FLogType, LinkedList<FactionLog>> getMostRecentLogs() {

View File

@ -26,11 +26,11 @@ public class LogTimer extends ConcurrentHashMap<LogTimer.TimerType, Map<LogTimer
} }
public Map<LogTimer.TimerSubType, LogTimer.Timer> getCurrentTimersOrCreate(LogTimer.TimerType type) { public Map<LogTimer.TimerSubType, LogTimer.Timer> getCurrentTimersOrCreate(LogTimer.TimerType type) {
return this.computeIfAbsent(type, (m) -> new ConcurrentHashMap<>()); return this.computeIfAbsent(type, m -> new ConcurrentHashMap<>());
} }
public LogTimer.Timer attemptLog(LogTimer.TimerType type, LogTimer.TimerSubType subType, long increment) { public LogTimer.Timer attemptLog(LogTimer.TimerType type, LogTimer.TimerSubType subType, long increment) {
return this.getCurrentTimersOrCreate(type).computeIfAbsent(subType, (e) -> new Timer(System.currentTimeMillis(), 0L, null)).increment(increment); return this.getCurrentTimersOrCreate(type).computeIfAbsent(subType, e -> new Timer(System.currentTimeMillis(), 0L, null)).increment(increment);
} }
public void pushLogs(Faction faction, LogTimer.TimerType type) { public void pushLogs(Faction faction, LogTimer.TimerType type) {

View File

@ -13,24 +13,19 @@ import org.bukkit.inventory.Inventory;
import org.bukkit.inventory.ItemStack; import org.bukkit.inventory.ItemStack;
import org.bukkit.inventory.meta.ItemMeta; import org.bukkit.inventory.meta.ItemMeta;
import org.bukkit.material.MaterialData; import org.bukkit.material.MaterialData;
import org.jetbrains.annotations.NotNull;
import java.text.SimpleDateFormat; import java.text.SimpleDateFormat;
import java.util.*; import java.util.*;
public class CheckHistoryFrame implements FactionGUI { public class CheckHistoryFrame implements FactionGUI {
/**
* @author Driftay
*/
private FactionsPlugin plugin;
private Faction faction; private Faction faction;
private Inventory inventory; private Inventory inventory;
private SimpleDateFormat simpleDateFormat; private SimpleDateFormat simpleDateFormat;
public CheckHistoryFrame(FactionsPlugin plugin, Faction faction) { public CheckHistoryFrame(FactionsPlugin plugin, Faction faction) {
this.simpleDateFormat = new SimpleDateFormat(Conf.dateFormat); this.simpleDateFormat = new SimpleDateFormat(Conf.dateFormat);
this.plugin = plugin;
this.faction = faction; this.faction = faction;
this.inventory = plugin.getServer().createInventory(this, 54, TL.CHECK_HISTORY_GUI_TITLE.toString()); this.inventory = plugin.getServer().createInventory(this, 54, TL.CHECK_HISTORY_GUI_TITLE.toString());
} }
@ -88,6 +83,7 @@ public class CheckHistoryFrame implements FactionGUI {
} }
} }
@NotNull
public Inventory getInventory() { public Inventory getInventory() {
return inventory; return inventory;
} }

View File

@ -12,6 +12,7 @@ import org.bukkit.inventory.Inventory;
import org.bukkit.inventory.InventoryHolder; import org.bukkit.inventory.InventoryHolder;
import org.bukkit.inventory.ItemStack; import org.bukkit.inventory.ItemStack;
import org.bukkit.inventory.meta.ItemMeta; import org.bukkit.inventory.meta.ItemMeta;
import org.jetbrains.annotations.NotNull;
import java.util.Collections; import java.util.Collections;
@ -71,6 +72,7 @@ public class CheckSettingsFrame implements InventoryHolder, FactionGUI {
inventory.setItem(FactionsPlugin.getInstance().getConfig().getInt("f-check.history.slot"), historyStack); inventory.setItem(FactionsPlugin.getInstance().getConfig().getInt("f-check.history.slot"), historyStack);
} }
@NotNull
public Inventory getInventory() { public Inventory getInventory() {
return this.inventory; return this.inventory;
} }
@ -92,9 +94,6 @@ public class CheckSettingsFrame implements InventoryHolder, FactionGUI {
case 15: { case 15: {
return 30; return 30;
} }
case 30: {
return 0;
}
default: { default: {
return 0; return 0;
} }

View File

@ -11,14 +11,7 @@ import net.dv8tion.jda.core.entities.TextChannel;
public class WeeWooTask implements Runnable { public class WeeWooTask implements Runnable {
/**
* @author Driftay
*/
private FactionsPlugin plugin;
public WeeWooTask(FactionsPlugin plugin) { public WeeWooTask(FactionsPlugin plugin) {
this.plugin = plugin;
} }
@Override @Override

View File

@ -29,15 +29,13 @@ public class AntiChestListener implements Listener {
Inventory clicked = e.getClickedInventory(); Inventory clicked = e.getClickedInventory();
Inventory clicker = e.getWhoClicked().getInventory(); Inventory clicker = e.getWhoClicked().getInventory();
if (e.getClick().isShiftClick()) { if (e.getClick().isShiftClick() && clicked == clicker) {
if (clicked == clicker) {
ItemStack clickedOn = e.getCurrentItem(); ItemStack clickedOn = e.getCurrentItem();
if (clickedOn != null && FactionsPlugin.getInstance().itemList.contains(clickedOn.getType().toString())) { if (clickedOn != null && FactionsPlugin.getInstance().itemList.contains(clickedOn.getType().toString())) {
fPlayer.msg(TL.CHEST_ITEM_DENIED_TRANSFER, clickedOn.getType().toString()); fPlayer.msg(TL.CHEST_ITEM_DENIED_TRANSFER, clickedOn.getType().toString());
e.setCancelled(true); e.setCancelled(true);
} }
} }
}
if (clicked != clicker) { if (clicked != clicker) {
ItemStack onCursor = e.getCursor(); ItemStack onCursor = e.getCursor();

View File

@ -26,7 +26,6 @@ public class CmdAutoClaim extends FCommand {
super(); super();
this.aliases.addAll(Aliases.claim_auto); this.aliases.addAll(Aliases.claim_auto);
//this.requiredArgs.add("");
this.optionalArgs.put("faction", "your"); this.optionalArgs.put("faction", "your");
this.requirements = new CommandRequirements.Builder(Permission.AUTOCLAIM) this.requirements = new CommandRequirements.Builder(Permission.AUTOCLAIM)
@ -39,14 +38,10 @@ public class CmdAutoClaim extends FCommand {
public void perform(CommandContext context) { public void perform(CommandContext context) {
Faction forFaction = context.argAsFaction(0, context.faction); Faction forFaction = context.argAsFaction(0, context.faction);
if (forFaction != context.fPlayer.getFaction()) { if (forFaction != context.fPlayer.getFaction() && !context.fPlayer.isAdminBypassing() && forFaction.getAccess(context.fPlayer, PermissableAction.TERRITORY) != Access.ALLOW) {
if (!context.fPlayer.isAdminBypassing()) {
if (forFaction.getAccess(context.fPlayer, PermissableAction.TERRITORY) != Access.ALLOW) {
context.msg(TL.COMMAND_CLAIM_DENIED); context.msg(TL.COMMAND_CLAIM_DENIED);
return; return;
} }
}
}
if (forFaction == null || forFaction == context.fPlayer.getAutoClaimFor()) { if (forFaction == null || forFaction == context.fPlayer.getAutoClaimFor()) {
context.fPlayer.setAutoClaimFor(null); context.fPlayer.setAutoClaimFor(null);

View File

@ -41,14 +41,10 @@ public class CmdClaim extends FCommand {
int radius = context.argAsInt(0, 1); // Default to 1 int radius = context.argAsInt(0, 1); // Default to 1
final Faction forFaction = context.argAsFaction(1, context.faction); // Default to own final Faction forFaction = context.argAsFaction(1, context.faction); // Default to own
if (!context.fPlayer.isAdminBypassing()) { if (!context.fPlayer.isAdminBypassing() && !(context.fPlayer.getFaction().equals(forFaction) && context.fPlayer.getRole() == Role.LEADER) && forFaction.getAccess(context.fPlayer, PermissableAction.TERRITORY) != Access.ALLOW) {
if (!(context.fPlayer.getFaction().equals(forFaction) && context.fPlayer.getRole() == Role.LEADER)) {
if (forFaction.getAccess(context.fPlayer, PermissableAction.TERRITORY) != Access.ALLOW) {
context.msg(TL.COMMAND_CLAIM_DENIED); context.msg(TL.COMMAND_CLAIM_DENIED);
return; return;
} }
}
}
if (radius < 1) { if (radius < 1) {
@ -90,14 +86,13 @@ public class CmdClaim extends FCommand {
return true; return true;
} }
@Override
public void finish() { public void finish() {
if (FactionsPlugin.cachedRadiusClaim) { if (FactionsPlugin.cachedRadiusClaim && successfulClaims > 0) {
if (successfulClaims > 0) {
context.fPlayer.getFaction().getFPlayersWhereOnline(true).forEach(f -> f.msg(TL.CLAIM_RADIUS_CLAIM, context.fPlayer.describeTo(f, true), String.valueOf(successfulClaims), context.fPlayer.getPlayer().getLocation().getChunk().getX(), context.fPlayer.getPlayer().getLocation().getChunk().getZ())); context.fPlayer.getFaction().getFPlayersWhereOnline(true).forEach(f -> f.msg(TL.CLAIM_RADIUS_CLAIM, context.fPlayer.describeTo(f, true), String.valueOf(successfulClaims), context.fPlayer.getPlayer().getLocation().getChunk().getX(), context.fPlayer.getPlayer().getLocation().getChunk().getZ()));
stop(); stop();
} }
} }
}
}; };
} }
} }

View File

@ -68,16 +68,11 @@ public class CmdClaimLine extends FCommand {
} }
final Faction forFaction = context.argAsFaction(2, context.faction); final Faction forFaction = context.argAsFaction(2, context.faction);
Faction at = Board.getInstance().getFactionAt(new FLocation(context.fPlayer.getPlayer().getLocation()));
if (forFaction != context.fPlayer.getFaction()) { if (forFaction != context.fPlayer.getFaction() && !context.fPlayer.isAdminBypassing() && forFaction.getAccess(context.fPlayer, PermissableAction.TERRITORY) != Access.ALLOW) {
if (!context.fPlayer.isAdminBypassing()) {
if (forFaction.getAccess(context.fPlayer, PermissableAction.TERRITORY) != Access.ALLOW) {
context.msg(TL.COMMAND_CLAIM_DENIED); context.msg(TL.COMMAND_CLAIM_DENIED);
return; return;
} }
}
}
Location location = context.player.getLocation(); Location location = context.player.getLocation();
@ -85,13 +80,11 @@ public class CmdClaimLine extends FCommand {
int claims = 0; int claims = 0;
for (int i = 0; i < amount; i++) { for (int i = 0; i < amount; i++) {
if (FactionsPlugin.cachedRadiusClaim && context.fPlayer.attemptClaim(forFaction, context.player.getLocation(), false)) { if (!FactionsPlugin.cachedRadiusClaim || !context.fPlayer.attemptClaim(forFaction, context.player.getLocation(), false)) {
claims++;
} else {
context.fPlayer.attemptClaim(forFaction, location, true); context.fPlayer.attemptClaim(forFaction, location, true);
claims++;
} }
location = location.add(blockFace.getModX() * 16, 0, blockFace.getModZ() * 16); claims++;
location = location.add(blockFace.getModX() * 16D, 0, blockFace.getModZ() * 16D);
FactionsPlugin.instance.logFactionEvent(forFaction, FLogType.CHUNK_CLAIMS, context.fPlayer.getName(), CC.GreenB + "CLAIMED", String.valueOf(i), new FLocation(context.player.getLocation()).formatXAndZ(",")); FactionsPlugin.instance.logFactionEvent(forFaction, FLogType.CHUNK_CLAIMS, context.fPlayer.getName(), CC.GreenB + "CLAIMED", String.valueOf(i), new FLocation(context.player.getLocation()).formatXAndZ(","));
} }
int cachedClaims = claims; int cachedClaims = claims;

View File

@ -8,7 +8,6 @@ import com.massivecraft.factions.cmd.CommandContext;
import com.massivecraft.factions.cmd.CommandRequirements; import com.massivecraft.factions.cmd.CommandRequirements;
import com.massivecraft.factions.cmd.FCommand; import com.massivecraft.factions.cmd.FCommand;
import com.massivecraft.factions.cmd.audit.FLogType; import com.massivecraft.factions.cmd.audit.FLogType;
import com.massivecraft.factions.iface.EconomyParticipator;
import com.massivecraft.factions.integration.Econ; import com.massivecraft.factions.integration.Econ;
import com.massivecraft.factions.struct.Permission; import com.massivecraft.factions.struct.Permission;
import com.massivecraft.factions.struct.Role; import com.massivecraft.factions.struct.Role;
@ -44,23 +43,21 @@ public class CmdMoneyWithdraw extends FCommand {
return; return;
} }
EconomyParticipator faction = context.argAsFaction(1, context.faction); Faction faction = context.argAsFaction(1, context.faction);
if (faction == null) { if (faction == null) {
return; return;
} }
Access access = context.faction.getAccess(context.fPlayer, PermissableAction.WITHDRAW); Access access = context.faction.getAccess(context.fPlayer, PermissableAction.WITHDRAW);
if (context.fPlayer.getRole() != Role.LEADER) { if (context.fPlayer.getRole() != Role.LEADER && access == Access.DENY) {
if (access == Access.DENY) {
context.msg(TL.GENERIC_NOPERMISSION, "withdraw", "withdraw money from the bank"); context.msg(TL.GENERIC_NOPERMISSION, "withdraw", "withdraw money from the bank");
return; return;
} }
}
boolean success = Econ.transferMoney(context.fPlayer, faction, context.fPlayer, amount); boolean success = Econ.transferMoney(context.fPlayer, faction, context.fPlayer, amount);
if (success && Conf.logMoneyTransactions) { if (success && Conf.logMoneyTransactions) {
FactionsPlugin.getInstance().log(ChatColor.stripColor(FactionsPlugin.getInstance().txt.parse(TL.COMMAND_MONEYWITHDRAW_WITHDRAW.toString(), context.fPlayer.getName(), Econ.moneyString(amount), faction.describeTo(null)))); FactionsPlugin.getInstance().log(ChatColor.stripColor(FactionsPlugin.getInstance().txt.parse(TL.COMMAND_MONEYWITHDRAW_WITHDRAW.toString(), context.fPlayer.getName(), Econ.moneyString(amount), faction.describeTo(null))));
FactionsPlugin.instance.logFactionEvent((Faction) faction, FLogType.BANK_EDIT, context.fPlayer.getName(), CC.RedB + "WITHDREW", amount + ""); FactionsPlugin.instance.logFactionEvent(faction, FLogType.BANK_EDIT, context.fPlayer.getName(), CC.RedB + "WITHDREW", amount + "");
} }
} }

View File

@ -37,8 +37,7 @@ public class CmdGrace extends FCommand {
return; return;
} }
if(context.args.size() == 1) { if (context.args.size() == 1 && context.sender.hasPermission(String.valueOf(Permission.GRACETOGGLE))) {
if (context.sender.hasPermission(String.valueOf(Permission.GRACETOGGLE))) {
if (context.argAsString(0).equalsIgnoreCase("on") || context.argAsString(0).equalsIgnoreCase("start")) { if (context.argAsString(0).equalsIgnoreCase("on") || context.argAsString(0).equalsIgnoreCase("start")) {
FactionsPlugin.getInstance().getTimerManager().graceTimer.setPaused(false); FactionsPlugin.getInstance().getTimerManager().graceTimer.setPaused(false);
FactionsPlugin.getInstance().getTimerManager().graceTimer.setRemaining(TimeUnit.DAYS.toMillis(Conf.gracePeriodTimeDays), true); FactionsPlugin.getInstance().getTimerManager().graceTimer.setRemaining(TimeUnit.DAYS.toMillis(Conf.gracePeriodTimeDays), true);
@ -59,9 +58,8 @@ public class CmdGrace extends FCommand {
return; return;
} }
} }
}
if(FactionsPlugin.getInstance().getTimerManager().graceTimer.getRemaining() <= 0L) { if (FactionsPlugin.getInstance().getTimerManager().graceTimer.getRemaining() <= 0L) {
context.fPlayer.msg(TL.COMMAND_GRACE_DISABLED_NO_FORMAT.toString()); context.fPlayer.msg(TL.COMMAND_GRACE_DISABLED_NO_FORMAT.toString());
} else { } else {
context.fPlayer.msg(TL.COMMAND_GRACE_TIME_REMAINING, String.valueOf(TimerManager.getRemaining(FactionsPlugin.getInstance().getTimerManager().graceTimer.getRemaining(), true))); context.fPlayer.msg(TL.COMMAND_GRACE_TIME_REMAINING, String.valueOf(TimerManager.getRemaining(FactionsPlugin.getInstance().getTimerManager().graceTimer.getRemaining(), true)));

View File

@ -15,10 +15,8 @@ public class LogoutHandler {
public static Map<String, LogoutHandler> factionDatas = new HashMap<>(); public static Map<String, LogoutHandler> factionDatas = new HashMap<>();
private Map<UUID, Long> logoutCooldown = new HashMap<>(); private Map<UUID, Long> logoutCooldown = new HashMap<>();
private String name;
public LogoutHandler(String name) { public LogoutHandler(String name) {
this.name = name;
factionDatas.put(name, this); factionDatas.put(name, this);
} }

View File

@ -41,7 +41,7 @@ public abstract class FRelationCommand extends FCommand {
Faction them = context.argAsFaction(0); Faction them = context.argAsFaction(0);
if (them == null) return; if (them == null) return;
if(!context.faction.isNormal()) return; if (!context.faction.isNormal()) return;
if (!them.isNormal()) { if (!them.isNormal()) {
context.msg(TL.COMMAND_RELATIONS_ALLTHENOPE); context.msg(TL.COMMAND_RELATIONS_ALLTHENOPE);
@ -112,8 +112,7 @@ public abstract class FRelationCommand extends FCommand {
private boolean hasMaxRelations(Faction us, Faction them, Relation targetRelation) { private boolean hasMaxRelations(Faction us, Faction them, Relation targetRelation) {
int max = FactionsPlugin.getInstance().getConfig().getInt("max-relations." + targetRelation.toString(), -1); int max = FactionsPlugin.getInstance().getConfig().getInt("max-relations." + targetRelation.toString(), -1);
if (FactionsPlugin.getInstance().getConfig().getBoolean("max-relations.enabled", false)) { if (FactionsPlugin.getInstance().getConfig().getBoolean("max-relations.enabled", false) && max != -1) {
if (max != -1) {
if (us.getRelationCount(targetRelation) >= max) { if (us.getRelationCount(targetRelation) >= max) {
us.msg(TL.COMMAND_RELATIONS_EXCEEDS_ME, max, targetRelation.getPluralTranslation()); us.msg(TL.COMMAND_RELATIONS_EXCEEDS_ME, max, targetRelation.getPluralTranslation());
return true; return true;
@ -123,7 +122,6 @@ public abstract class FRelationCommand extends FCommand {
return true; return true;
} }
} }
}
return false; return false;
} }

View File

@ -26,8 +26,8 @@ import java.util.Random;
* @author DroppingAnvil * @author DroppingAnvil
*/ */
public class CmdWild extends FCommand implements WaitedTask { public class CmdWild extends FCommand implements WaitedTask {
public static HashMap<Player, String> teleportRange; public static HashMap<Player, String> teleportRange = new HashMap<>();
public static HashSet<Player> teleporting; public static HashSet<Player> teleporting = new HashSet<>();
public static CmdWild instance; public static CmdWild instance;
public CmdWild() { public CmdWild() {
@ -37,8 +37,6 @@ public class CmdWild extends FCommand implements WaitedTask {
this.requirements = new CommandRequirements.Builder(Permission.WILD) this.requirements = new CommandRequirements.Builder(Permission.WILD)
.playerOnly() .playerOnly()
.build(); .build();
teleporting = new HashSet<>();
teleportRange = new HashMap<>();
} }
@Override @Override

View File

@ -60,17 +60,17 @@ public class CmdSetGuild extends FCommand {
if (guild == null) { if (guild == null) {
context.msg(TL.SET_GUILD_ID_INVALID_ID); context.msg(TL.SET_GUILD_ID_INVALID_ID);
} else if (Factions.getInstance().getAllFactions().stream().anyMatch((f) -> guildId.equals(f.getGuildId()))) { } else if (Factions.getInstance().getAllFactions().stream().anyMatch(f -> guildId.equals(f.getGuildId()))) {
context.msg(TL.SET_GUILD_ID_GUILD_ALREADY_LINKED); context.msg(TL.SET_GUILD_ID_GUILD_ALREADY_LINKED);
} else { } else {
context.msg(TL.SET_GUILD_ID_PMING_OWNER); context.msg(TL.SET_GUILD_ID_PMING_OWNER);
User user = guild.getOwner().getUser(); User user = guild.getOwner().getUser();
Guild finalGuild = guild; Guild finalGuild = guild;
Guild finalGuild1 = guild; Guild finalGuild1 = guild;
user.openPrivateChannel().queue((privateChannel) -> privateChannel.sendMessage("Link guild **" + finalGuild1.getName() + "** to faction **" + ChatColor.stripColor(faction.getTag()) + "**?").queue((message) -> { user.openPrivateChannel().queue(privateChannel -> privateChannel.sendMessage("Link guild **" + finalGuild1.getName() + "** to faction **" + ChatColor.stripColor(faction.getTag()) + "**?").queue(message -> {
String checkMark = "âś…"; String checkMark = "âś…";
message.addReaction(checkMark).queue(); message.addReaction(checkMark).queue();
this.eventWaiter.waitForEvent(PrivateMessageReactionAddEvent.class, (event) -> event.getReactionEmote().getName().equals(checkMark) && event.getUser().getId().equals(user.getId()) && event.getMessageId().equals(message.getId()), (event) -> { this.eventWaiter.waitForEvent(PrivateMessageReactionAddEvent.class, event -> event.getReactionEmote().getName().equals(checkMark) && event.getUser().getId().equals(user.getId()) && event.getMessageId().equals(message.getId()), event -> {
faction.setGuildId(context.argAsString(0)); faction.setGuildId(context.argAsString(0));
context.msg(TL.SET_GUILD_ID_SUCCESS); context.msg(TL.SET_GUILD_ID_SUCCESS);
privateChannel.sendMessage("Successfully linked **" + finalGuild.getName() + " & " + ChatColor.stripColor(faction.getTag()) + "**").queue(); privateChannel.sendMessage("Successfully linked **" + finalGuild.getName() + " & " + ChatColor.stripColor(faction.getTag()) + "**").queue();
@ -78,9 +78,7 @@ public class CmdSetGuild extends FCommand {
privateChannel.sendMessage(TL.SET_GUILD_ID_TIMED_OUT_DISCORD.toString()).queue(); privateChannel.sendMessage(TL.SET_GUILD_ID_TIMED_OUT_DISCORD.toString()).queue();
context.msg(TL.SET_GUILD_ID_TIMED_OUT_MINECRAFT); context.msg(TL.SET_GUILD_ID_TIMED_OUT_MINECRAFT);
}); });
}, (t) -> { }, t -> context.msg(TL.SET_GUILD_ID_UNABLE_TO_MESSAGE_GUILD_OWNER)), t -> context.msg(TL.SET_GUILD_ID_UNABLE_TO_MESSAGE_GUILD_OWNER));
context.msg(TL.SET_GUILD_ID_UNABLE_TO_MESSAGE_GUILD_OWNER);
}), (t) -> context.msg(TL.SET_GUILD_ID_UNABLE_TO_MESSAGE_GUILD_OWNER));
} }
} else { } else {
faction.setGuildId(null); faction.setGuildId(null);

View File

@ -31,7 +31,7 @@ public class Discord {
public static Boolean confUseDiscord; public static Boolean confUseDiscord;
public static String botToken; public static String botToken;
public static String mainGuildID; public static String mainGuildID;
public static Boolean useDiscord; public static boolean useDiscord;
public static java.awt.Color roleColor; public static java.awt.Color roleColor;
public static Guild mainGuild; public static Guild mainGuild;
public static Role leader; public static Role leader;
@ -53,14 +53,12 @@ public class Discord {
* Called to reload variables and if needed start JDA * Called to reload variables and if needed start JDA
*/ */
public static void setupDiscord() { public static void setupDiscord() {
if (jda == null) { if (jda == null && startBot()) {
if (startBot()) {
varSetup(); varSetup();
jda.addEventListener(new FactionChatHandler(plugin)); jda.addEventListener(new FactionChatHandler(plugin));
jda.addEventListener(new DiscordListener(plugin)); jda.addEventListener(new DiscordListener(plugin));
return; return;
} }
}
varSetup(); varSetup();
} }
@ -84,6 +82,7 @@ public class Discord {
confUseDiscord = Conf.useDiscordSystem; confUseDiscord = Conf.useDiscordSystem;
botToken = Conf.discordBotToken; botToken = Conf.discordBotToken;
if (jda != null && Conf.leaderRoles || Conf.factionDiscordTags) { if (jda != null && Conf.leaderRoles || Conf.factionDiscordTags) {
assert jda != null;
mainGuild = jda.getGuildById(Conf.mainGuildID); mainGuild = jda.getGuildById(Conf.mainGuildID);
} else { } else {
mainGuild = null; mainGuild = null;
@ -151,12 +150,9 @@ public class Discord {
* @param s String target Faction tag * @param s String target Faction tag
* @return * @return
*/ */
public static Boolean doesFactionRoleExist(String s) { public static boolean doesFactionRoleExist(String s) {
StringBuilder sb = new StringBuilder(); String sb = Conf.factionRolePrefix + s + Conf.factionRoleSuffix;
sb.append(Conf.factionRolePrefix); return getRoleFromName(sb) != null;
sb.append(s);
sb.append(Conf.factionRoleSuffix);
return getRoleFromName(sb.toString()) != null;
} }
public static Role getRoleFromName(String s) { public static Role getRoleFromName(String s) {
@ -189,7 +185,8 @@ public class Discord {
sb.append(Conf.factionRoleSuffix); sb.append(Conf.factionRoleSuffix);
if (!doesFactionRoleExist(sb.toString())) { if (!doesFactionRoleExist(sb.toString())) {
try { try {
Role newRole = mainGuild.getController().createRole() Role newRole;
newRole = mainGuild.getController().createRole()
.setName(sb.toString()) .setName(sb.toString())
.setColor(roleColor) .setColor(roleColor)
.setPermissions(Permission.EMPTY_PERMISSIONS) .setPermissions(Permission.EMPTY_PERMISSIONS)
@ -211,11 +208,7 @@ public class Discord {
* @return Name of would be Role * @return Name of would be Role
*/ */
public static String getFactionRoleName(String tag) { public static String getFactionRoleName(String tag) {
StringBuilder sb = new StringBuilder(); return Conf.factionRolePrefix + tag + Conf.factionRoleSuffix;
sb.append(Conf.factionRolePrefix);
sb.append(tag);
sb.append(Conf.factionRoleSuffix);
return sb.toString();
} }
/** /**
@ -224,7 +217,7 @@ public class Discord {
* @param u User * @param u User
* @return Boolean * @return Boolean
*/ */
public static Boolean isInMainGuild(User u) { public static boolean isInMainGuild(User u) {
if (mainGuild == null) return false; if (mainGuild == null) return false;
return mainGuild.getMember(u) == null ? Boolean.FALSE : Boolean.TRUE; return mainGuild.getMember(u) == null ? Boolean.FALSE : Boolean.TRUE;
} }
@ -252,10 +245,12 @@ public class Discord {
if (fp.discordSetup() && isInMainGuild(fp.discordUser())) { if (fp.discordSetup() && isInMainGuild(fp.discordUser())) {
try { try {
Member m = mainGuild.getMember(fp.discordUser()); Member m = mainGuild.getMember(fp.discordUser());
if (Conf.factionDiscordTags) { boolean discordTags = Conf.factionDiscordTags;
boolean factionRoles = Conf.factionRoles;
if (discordTags) {
mainGuild.getController().setNickname(m, Discord.getNicknameString(fp)).queue(); mainGuild.getController().setNickname(m, Discord.getNicknameString(fp)).queue();
} }
if (Conf.factionRoles) { if (factionRoles) {
mainGuild.getController().removeSingleRoleFromMember(m, Objects.requireNonNull(getRoleFromName(oldTag))).queue(); mainGuild.getController().removeSingleRoleFromMember(m, Objects.requireNonNull(getRoleFromName(oldTag))).queue();
mainGuild.getController().addSingleRoleToMember(m, Objects.requireNonNull(createFactionRole(f.getTag()))).queue(); mainGuild.getController().addSingleRoleToMember(m, Objects.requireNonNull(createFactionRole(f.getTag()))).queue();
} }

View File

@ -37,7 +37,7 @@ public class DiscordListener extends ListenerAdapter {
this.decimalFormat = new DecimalFormat("$#,###.##"); this.decimalFormat = new DecimalFormat("$#,###.##");
this.plugin = plugin; this.plugin = plugin;
int minute = 3600; int minute = 3600;
plugin.getServer().getScheduler().runTaskTimerAsynchronously(plugin, DiscordListener::saveGuilds, minute * 15, minute * 15); plugin.getServer().getScheduler().runTaskTimerAsynchronously(plugin, DiscordListener::saveGuilds, minute * 15L, minute * 15L);
} }
private static JSONGuilds loadGuilds() { private static JSONGuilds loadGuilds() {
@ -64,6 +64,7 @@ public class DiscordListener extends ListenerAdapter {
} }
} }
@Override
public void onPrivateMessageReceived(PrivateMessageReceivedEvent e) { public void onPrivateMessageReceived(PrivateMessageReceivedEvent e) {
Integer i; Integer i;
if (e.getAuthor().isBot()) return; if (e.getAuthor().isBot()) return;
@ -85,6 +86,7 @@ public class DiscordListener extends ListenerAdapter {
} }
} }
@Override
public void onGuildMessageReceived(GuildMessageReceivedEvent event) { public void onGuildMessageReceived(GuildMessageReceivedEvent event) {
try { try {
if (event.getMessage().isWebhookMessage() || event.getAuthor().isBot()) return; if (event.getMessage().isWebhookMessage() || event.getAuthor().isBot()) return;

View File

@ -109,7 +109,7 @@ public class DiscordSetupAttempt {
sb.append(inProcessTime); sb.append(inProcessTime);
//Just a separator for looks //Just a separator for looks
sb.append(" "); sb.append(" ");
String s = ""; String s;
switch (timeIndex) { switch (timeIndex) {
case 0: case 0:
s = "MS"; s = "MS";
@ -129,6 +129,8 @@ public class DiscordSetupAttempt {
case 5: case 5:
s = "Years"; s = "Years";
break; break;
default:
throw new IllegalStateException("Unexpected value: " + timeIndex);
} }
sb.append(s); sb.append(s);
sb.append(" ago"); sb.append(" ago");

View File

@ -35,7 +35,7 @@ public class FactionChatHandler extends ListenerAdapter {
this.plugin = plugin; this.plugin = plugin;
} }
public static void sendMessage(FactionsPlugin plugin, Faction faction, UUID uuid, String username, String message) { public static void sendMessage(Faction faction, UUID uuid, String username, String message) {
String factionsChatChannelId = faction.getFactionChatChannelId(); String factionsChatChannelId = faction.getFactionChatChannelId();
String messageWithMentions = null; String messageWithMentions = null;
if (factionsChatChannelId == null || factionsChatChannelId.isEmpty()) return; if (factionsChatChannelId == null || factionsChatChannelId.isEmpty()) return;

View File

@ -49,7 +49,6 @@ public class Econ {
econ = rsp.getProvider(); econ = rsp.getProvider();
FactionsPlugin.getInstance().log("Economy integration through Vault plugin successful."); FactionsPlugin.getInstance().log("Economy integration through Vault plugin successful.");
if (!Conf.econEnabled) FactionsPlugin.getInstance().log("NOTE: Economy is disabled. You can enable it with the command: f config econEnabled true"); if (!Conf.econEnabled) FactionsPlugin.getInstance().log("NOTE: Economy is disabled. You can enable it with the command: f config econEnabled true");
//FactionsPlugin.getInstance().cmdBase.cmdHelp.updateHelp();
} }
public static boolean shouldBeUsed() { public static boolean shouldBeUsed() {
@ -103,7 +102,6 @@ public class Econ {
// Factions can be controlled by members that are moderators... or any member if any member can withdraw. // Factions can be controlled by members that are moderators... or any member if any member can withdraw.
if (you instanceof Faction && fI == fYou && (Conf.bankMembersCanWithdraw || (i instanceof FPlayer && ((FPlayer) i).getRole().value >= Role.MODERATOR.value))) if (you instanceof Faction && fI == fYou && (Conf.bankMembersCanWithdraw || (i instanceof FPlayer && ((FPlayer) i).getRole().value >= Role.MODERATOR.value)))
return true; return true;
// Otherwise you may not!;,,;
i.msg(TL.ECON_CANTCONTROLMONEY, i.describeTo(i, true), you.describeTo(i)); i.msg(TL.ECON_CANTCONTROLMONEY, i.describeTo(i, true), you.describeTo(i));
return false; return false;
} }
@ -237,7 +235,7 @@ public class Econ {
acc = Bukkit.getOfflinePlayer(UUID.fromString(ep.getAccountId())); acc = Bukkit.getOfflinePlayer(UUID.fromString(ep.getAccountId()));
if (acc.getName() == null) return false; if (acc.getName() == null) return false;
} else acc = Bukkit.getOfflinePlayer(ep.getAccountId()); } else acc = Bukkit.getOfflinePlayer(ep.getAccountId());
String You = ep.describeTo(ep, true); String you = ep.describeTo(ep, true);
if (delta == 0) return true; if (delta == 0) return true;
else if (delta > 0) { else if (delta > 0) {
@ -247,12 +245,12 @@ public class Econ {
if (er.transactionSuccess()) { if (er.transactionSuccess()) {
modifyUniverseMoney(-delta); modifyUniverseMoney(-delta);
if (forDoingThis != null && !forDoingThis.isEmpty()) if (forDoingThis != null && !forDoingThis.isEmpty())
ep.msg(TL.COMMAND_MONEY_GAINED, You, moneyString(delta), forDoingThis); ep.msg(TL.COMMAND_MONEY_GAINED, you, moneyString(delta), forDoingThis);
return true; return true;
} else { } else {
// transfer to account failed // transfer to account failed
if (forDoingThis != null && !forDoingThis.isEmpty()) if (forDoingThis != null && !forDoingThis.isEmpty())
ep.msg(TL.ECON_DEPOSITFAILED, You, moneyString(delta), forDoingThis); ep.msg(TL.ECON_DEPOSITFAILED, you, moneyString(delta), forDoingThis);
return false; return false;
} }
} else { } else {
@ -262,12 +260,12 @@ public class Econ {
// There is enough money to pay // There is enough money to pay
modifyUniverseMoney(-delta); modifyUniverseMoney(-delta);
if (forDoingThis != null && !forDoingThis.isEmpty()) if (forDoingThis != null && !forDoingThis.isEmpty())
ep.msg(TL.ECON_MONEYLOST, You, moneyString(-delta), forDoingThis); ep.msg(TL.ECON_MONEYLOST, you, moneyString(-delta), forDoingThis);
return true; return true;
} else { } else {
// There was not enough money to pay // There was not enough money to pay
if (toDoThis != null && !toDoThis.isEmpty()) if (toDoThis != null && !toDoThis.isEmpty())
ep.msg(TL.ECON_CANTAFFORD, You, moneyString(-delta), toDoThis); ep.msg(TL.ECON_CANTAFFORD, you, moneyString(-delta), toDoThis);
return false; return false;
} }
} }

View File

@ -159,7 +159,6 @@ public class Worldguard {
FactionsPlugin.getInstance().log("We failed to load Vector Classes from WorldGuard! Support will be removed!"); FactionsPlugin.getInstance().log("We failed to load Vector Classes from WorldGuard! Support will be removed!");
FactionsPlugin.getInstance().log("WorldGuard 7.0.0 support is currently in BETA. Please be careful!"); FactionsPlugin.getInstance().log("WorldGuard 7.0.0 support is currently in BETA. Please be careful!");
regionContainer = null; regionContainer = null;
return;
} }
} }
} }

View File

@ -26,20 +26,17 @@ public class EngineDynmap {
// CONSTANTS // CONSTANTS
// -------------------------------------------- // // -------------------------------------------- //
public final static int BLOCKS_PER_CHUNK = 16; public static final int BLOCKS_PER_CHUNK = 16;
public final static String DYNMAP_INTEGRATION = "\u00A7dDynmap Integration: \u00A7e"; public static final String DYNMAP_INTEGRATION = "\u00A7dDynmap Integration: \u00A7e";
public final static String FACTIONS = "factions"; public static final String FACTIONS = "factions";
public final static String FACTIONS_ = FACTIONS + "_"; public static final String FACTIONS_ = FACTIONS + "_";
public static final String FACTIONS_MARKERSET = FACTIONS_ + "markerset";
public final static String FACTIONS_MARKERSET = FACTIONS_ + "markerset"; public static final String FACTIONS_HOME = FACTIONS_ + "home";
public static final String FACTIONS_HOME_ = FACTIONS_HOME + "_";
public final static String FACTIONS_HOME = FACTIONS_ + "home"; public static final String FACTIONS_PLAYERSET = FACTIONS_ + "playerset";
public final static String FACTIONS_HOME_ = FACTIONS_HOME + "_"; public static final String FACTIONS_PLAYERSET_ = FACTIONS_PLAYERSET + "_";
public final static String FACTIONS_PLAYERSET = FACTIONS_ + "playerset";
public final static String FACTIONS_PLAYERSET_ = FACTIONS_PLAYERSET + "_";
// -------------------------------------------- // // -------------------------------------------- //
// INSTANCE & CONSTRUCT // INSTANCE & CONSTRUCT
@ -277,13 +274,13 @@ public class EngineDynmap {
String world = entry.getKey().getWorldName(); String world = entry.getKey().getWorldName();
Faction chunkOwner = Factions.getInstance().getFactionById(entry.getValue()); Faction chunkOwner = Factions.getInstance().getFactionById(entry.getValue());
Map<Faction, Set<FLocation>> factionChunks = worldFactionChunks.get(world); Map<Faction, Set<FLocation>> factionChunks = worldFactionChunks.computeIfAbsent(world, s -> null);
if (factionChunks == null) { if (factionChunks == null) {
factionChunks = new HashMap<>(); factionChunks = new HashMap<>();
worldFactionChunks.put(world, factionChunks); worldFactionChunks.put(world, factionChunks);
} }
Set<FLocation> factionTerritory = factionChunks.get(chunkOwner); Set<FLocation> factionTerritory = factionChunks.computeIfAbsent(chunkOwner, s -> null);
if (factionTerritory == null) { if (factionTerritory == null) {
factionTerritory = new HashSet<>(); factionTerritory = new HashSet<>();
factionChunks.put(chunkOwner, factionTerritory); factionChunks.put(chunkOwner, factionTerritory);
@ -735,8 +732,7 @@ public class EngineDynmap {
} }
// Find all contiguous blocks, set in target and clear in source // Find all contiguous blocks, set in target and clear in source
private int floodFillTarget(TileFlags source, TileFlags destination, int x, int y) { private void floodFillTarget(TileFlags source, TileFlags destination, int x, int y) {
int cnt = 0;
ArrayDeque<int[]> stack = new ArrayDeque<>(); ArrayDeque<int[]> stack = new ArrayDeque<>();
stack.push(new int[]{x, y}); stack.push(new int[]{x, y});
@ -747,7 +743,6 @@ public class EngineDynmap {
if (source.getFlag(x, y)) { // Set in src if (source.getFlag(x, y)) { // Set in src
source.setFlag(x, y, false); // Clear source source.setFlag(x, y, false); // Clear source
destination.setFlag(x, y, true); // Set in destination destination.setFlag(x, y, true); // Set in destination
cnt++;
if (source.getFlag(x + 1, y)) { if (source.getFlag(x + 1, y)) {
stack.push(new int[]{x + 1, y}); stack.push(new int[]{x + 1, y});
} }
@ -762,7 +757,6 @@ public class EngineDynmap {
} }
} }
} }
return cnt;
} }
enum Direction { enum Direction {

View File

@ -15,7 +15,7 @@ public class TempMarkerSet {
public boolean hideByDefault; public boolean hideByDefault;
public MarkerSet create(MarkerAPI markerApi, String id) { public MarkerSet create(MarkerAPI markerApi, String id) {
MarkerSet ret = markerApi.createMarkerSet(id, this.label, null, false); // ("null, false" at the end means "all icons allowed, not perisistent") MarkerSet ret = markerApi.createMarkerSet(id, this.label, null, false); // ("null, false" at the end means "all icons allowed, not persistent")
if (ret == null) { if (ret == null) {
return null; return null;
@ -41,11 +41,9 @@ public class TempMarkerSet {
markerset.setMarkerSetLabel(this.label); markerset.setMarkerSetLabel(this.label);
} }
if (this.minimumZoom > 0) { if (this.minimumZoom > 0 && markerset.getMinZoom() != this.minimumZoom) {
if (markerset.getMinZoom() != this.minimumZoom) {
markerset.setMinZoom(this.minimumZoom); markerset.setMinZoom(this.minimumZoom);
} }
}
if (markerset.getLayerPriority() != this.priority) { if (markerset.getLayerPriority() != this.priority) {
markerset.setLayerPriority(this.priority); markerset.setLayerPriority(this.priority);

View File

@ -47,6 +47,8 @@ public class FactionsBlockListener implements Listener {
public static HashMap<String, Location> bannerLocations = new HashMap<>(); public static HashMap<String, Location> bannerLocations = new HashMap<>();
private HashMap<String, Boolean> bannerCooldownMap = new HashMap<>(); private HashMap<String, Boolean> bannerCooldownMap = new HashMap<>();
private long placeTimer = TimeUnit.SECONDS.toMillis(15L); private long placeTimer = TimeUnit.SECONDS.toMillis(15L);
private static final String varFac = "{faction}";
private static final String varAction = "{action}";
public static boolean playerCanBuildDestroyBlock(Player player, Location location, String action, boolean justCheck) { public static boolean playerCanBuildDestroyBlock(Player player, Location location, String action, boolean justCheck) {
@ -61,8 +63,7 @@ public class FactionsBlockListener implements Listener {
if (otherFaction.isWilderness()) { if (otherFaction.isWilderness()) {
if (Conf.worldGuardBuildPriority && Worldguard.getInstance().playerCanBuild(player, location)) return true; if (Conf.worldGuardBuildPriority && Worldguard.getInstance().playerCanBuild(player, location)) return true;
if (location.getWorld() != null) { if (location.getWorld() != null && !Conf.wildernessDenyBuild || Conf.worldsNoWildernessProtection.contains(location.getWorld().getName())) {
if (!Conf.wildernessDenyBuild || Conf.worldsNoWildernessProtection.contains(location.getWorld().getName()))
return true; return true;
} }
if (!justCheck) me.msg(TL.ACTION_DENIED_WILDERNESS, action); if (!justCheck) me.msg(TL.ACTION_DENIED_WILDERNESS, action);
@ -93,24 +94,27 @@ public class FactionsBlockListener implements Listener {
boolean landOwned = (myFaction.doesLocationHaveOwnersSet(loc) && !myFaction.getOwnerList(loc).isEmpty()); boolean landOwned = (myFaction.doesLocationHaveOwnersSet(loc) && !myFaction.getOwnerList(loc).isEmpty());
if ((landOwned && myFaction.getOwnerListString(loc).contains(player.getName())) || (me.getRole() == Role.LEADER && me.getFactionId().equals(myFaction.getId()))) if ((landOwned && myFaction.getOwnerListString(loc).contains(player.getName())) || (me.getRole() == Role.LEADER && me.getFactionId().equals(myFaction.getId())))
return true; return true;
else if (landOwned && !myFaction.getOwnerListString(loc).contains(player.getName())) { else {
String replace = TL.ACTIONS_NOPERMISSIONPAIN.toString().replace(varAction, action.toString());
if (landOwned && !myFaction.getOwnerListString(loc).contains(player.getName())) {
me.msg(TL.ACTIONS_OWNEDTERRITORYDENY.toString().replace("{owners}", myFaction.getOwnerListString(loc))); me.msg(TL.ACTIONS_OWNEDTERRITORYDENY.toString().replace("{owners}", myFaction.getOwnerListString(loc)));
if (shouldHurt) { if (shouldHurt) {
player.damage(Conf.actionDeniedPainAmount); player.damage(Conf.actionDeniedPainAmount);
me.msg(TL.ACTIONS_NOPERMISSIONPAIN.toString().replace("{action}", action.toString()).replace("{faction}", Board.getInstance().getFactionAt(loc).getTag(myFaction))); me.msg(replace.replace(varFac, Board.getInstance().getFactionAt(loc).getTag(myFaction)));
} }
return false; return false;
} else if (!landOwned && access == Access.DENY) { // If land is not owned but access is set to DENY anyway } else if (!landOwned && access == Access.DENY) { // If land is not owned but access is set to DENY anyway
if (shouldHurt) { if (shouldHurt) {
player.damage(Conf.actionDeniedPainAmount); player.damage(Conf.actionDeniedPainAmount);
if ((Board.getInstance().getFactionAt(loc).getTag(myFaction)) != null) if ((Board.getInstance().getFactionAt(loc).getTag(myFaction)) != null)
me.msg(TL.ACTIONS_NOPERMISSIONPAIN.toString().replace("{action}", action.toString()).replace("{faction}", Board.getInstance().getFactionAt(loc).getTag(myFaction))); me.msg(replace.replace(varFac, Board.getInstance().getFactionAt(loc).getTag(myFaction)));
} }
if (myFaction.getTag(me.getFaction()) != null && action != null) if (myFaction.getTag(me.getFaction()) != null && action != null)
me.msg(TL.ACTIONS_NOPERMISSION.toString().replace("{faction}", myFaction.getTag(me.getFaction())).replace("{action}", action.toString())); me.msg(TL.ACTIONS_NOPERMISSION.toString().replace(varFac, myFaction.getTag(me.getFaction())).replace(varAction, action.toString()));
return false; return false;
} else if (access == Access.ALLOW) return true; } else if (access == Access.ALLOW) return true;
me.msg(TL.ACTIONS_NOPERMISSION.toString().replace("{faction}", myFaction.getTag(me.getFaction())).replace("{action}", action.toString())); }
me.msg(TL.ACTIONS_NOPERMISSION.toString().replace(varFac, myFaction.getTag(me.getFaction())).replace(varAction, action.toString()));
return false; return false;
} }
@ -118,10 +122,10 @@ public class FactionsBlockListener implements Listener {
if (Conf.ownedAreasEnabled && target.doesLocationHaveOwnersSet(location) && !target.playerHasOwnershipRights(me, location)) { if (Conf.ownedAreasEnabled && target.doesLocationHaveOwnersSet(location) && !target.playerHasOwnershipRights(me, location)) {
// If pain should be applied // If pain should be applied
if (pain && Conf.ownedAreaPainBuild) if (pain && Conf.ownedAreaPainBuild)
me.msg(TL.ACTIONS_OWNEDTERRITORYPAINDENY.toString().replace("{action}", action.toString()).replace("{faction}", target.getOwnerListString(location))); me.msg(TL.ACTIONS_OWNEDTERRITORYPAINDENY.toString().replace(varAction, action.toString()).replace(varFac, target.getOwnerListString(location)));
if (Conf.ownedAreaDenyBuild && pain) return false; if (Conf.ownedAreaDenyBuild && pain) return false;
else if (Conf.ownedAreaDenyBuild) { else if (Conf.ownedAreaDenyBuild) {
me.msg(TL.ACTIONS_NOPERMISSION.toString().replace("{faction}", target.getTag(me.getFaction())).replace("{action}", action.toString())); me.msg(TL.ACTIONS_NOPERMISSION.toString().replace(varFac, target.getTag(me.getFaction())).replace(varAction, action.toString()));
return false; return false;
} }
} }
@ -168,25 +172,22 @@ public class FactionsBlockListener implements Listener {
return; return;
} }
if (isSpawner) { if (isSpawner && Conf.spawnerLock) {
if (Conf.spawnerLock) {
event.setCancelled(true); event.setCancelled(true);
event.getPlayer().sendMessage(FactionsPlugin.getInstance().color(TL.COMMAND_SPAWNER_LOCK_CANNOT_PLACE.toString())); event.getPlayer().sendMessage(FactionsPlugin.getInstance().color(TL.COMMAND_SPAWNER_LOCK_CANNOT_PLACE.toString()));
} }
} }
}
@EventHandler(priority = EventPriority.NORMAL, ignoreCancelled = true) @EventHandler(priority = EventPriority.NORMAL, ignoreCancelled = true)
public void onBlockFromTo(BlockFromToEvent event) { public void onBlockFromTo(BlockFromToEvent event) {
if (!Conf.handleExploitLiquidFlow) return; if (!Conf.handleExploitLiquidFlow) return;
if (event.getBlock().isLiquid()) { if (event.getBlock().isLiquid() && event.getToBlock().isEmpty()) {
if (event.getToBlock().isEmpty()) {
Faction from = Board.getInstance().getFactionAt(new FLocation(event.getBlock())); Faction from = Board.getInstance().getFactionAt(new FLocation(event.getBlock()));
Faction to = Board.getInstance().getFactionAt(new FLocation(event.getToBlock())); Faction to = Board.getInstance().getFactionAt(new FLocation(event.getToBlock()));
if (from == to) return; if (from == to) return;
// from faction != to faction // from faction != to faction
if(to.isSystemFaction()) { if (to.isSystemFaction()) {
event.setCancelled(true); event.setCancelled(true);
return; return;
} }
@ -199,7 +200,6 @@ public class FactionsBlockListener implements Listener {
} }
} }
} }
}
@EventHandler(priority = EventPriority.NORMAL, ignoreCancelled = true) @EventHandler(priority = EventPriority.NORMAL, ignoreCancelled = true)
public void onBlockDamage(BlockDamageEvent event) { public void onBlockDamage(BlockDamageEvent event) {
@ -217,7 +217,7 @@ public class FactionsBlockListener implements Listener {
Block targetBlock = event.getBlock().getRelative(event.getDirection(), event.getLength() + 1); Block targetBlock = event.getBlock().getRelative(event.getDirection(), event.getLength() + 1);
// if potentially pushing into air/water/lava in another territory, we need to check it out // if potentially pushing into air/water/lava in another territory, we need to check it out
if ((targetBlock.isEmpty() || targetBlock.isLiquid()) && !canPistonMoveBlock(pistonFaction, targetBlock.getLocation())) if ((targetBlock.isEmpty() || targetBlock.isLiquid()) && canPistonMoveBlock(pistonFaction, targetBlock.getLocation()))
event.setCancelled(true); event.setCancelled(true);
} }
@ -286,8 +286,7 @@ public class FactionsBlockListener implements Listener {
continue; continue;
} }
if (blockLoc.getBlock().getType() == XMaterial.CHEST.parseMaterial()) { if (blockLoc.getBlock().getType() == XMaterial.CHEST.parseMaterial() && factionAt.getVault().equals(blockLoc)) {
if (factionAt.getVault().equals(blockLoc)) {
e.setCancelled(true); e.setCancelled(true);
fme.msg(TL.COMMAND_VAULT_NO_HOPPER); fme.msg(TL.COMMAND_VAULT_NO_HOPPER);
return; return;
@ -295,7 +294,6 @@ public class FactionsBlockListener implements Listener {
} }
} }
} }
}
} }
@ -316,7 +314,7 @@ public class FactionsBlockListener implements Listener {
// if potentially retracted block is just air/water/lava, no worries // if potentially retracted block is just air/water/lava, no worries
if (targetLoc.getBlock().isEmpty() || targetLoc.getBlock().isLiquid()) return; if (targetLoc.getBlock().isEmpty() || targetLoc.getBlock().isLiquid()) return;
Faction pistonFaction = Board.getInstance().getFactionAt(new FLocation(event.getBlock())); Faction pistonFaction = Board.getInstance().getFactionAt(new FLocation(event.getBlock()));
if (!canPistonMoveBlock(pistonFaction, targetLoc)) event.setCancelled(true); if (canPistonMoveBlock(pistonFaction, targetLoc)) event.setCancelled(true);
} }
@EventHandler @EventHandler
@ -326,13 +324,11 @@ public class FactionsBlockListener implements Listener {
return; return;
} }
if (bannerLocations.containsValue(e.getBlock().getLocation())) { if (bannerLocations.containsValue(e.getBlock().getLocation()) && e.getBlock().getType().name().contains("BANNER")) {
if (e.getBlock().getType().name().contains("BANNER")) {
e.setCancelled(true); e.setCancelled(true);
fme.msg(TL.BANNER_CANNOT_BREAK); fme.msg(TL.BANNER_CANNOT_BREAK);
} }
} }
}
@EventHandler @EventHandler
public void onBannerPlace(BlockPlaceEvent e) { public void onBannerPlace(BlockPlaceEvent e) {
@ -430,7 +426,8 @@ public class FactionsBlockListener implements Listener {
if (!justCheck) fPlayer.setLastFrostwalkerMessage(); if (!justCheck) fPlayer.setLastFrostwalkerMessage();
// Check if they have build permissions here. If not, block this from happening. // Check if they have build permissions here. If not, block this from happening.
if (!playerCanBuildDestroyBlock(player, location, PermissableAction.FROST_WALK.toString(), justCheck)) event.setCancelled(true); if (!playerCanBuildDestroyBlock(player, location, PermissableAction.FROST_WALK.toString(), justCheck))
event.setCancelled(true);
} }
@EventHandler @EventHandler
@ -448,15 +445,15 @@ public class FactionsBlockListener implements Listener {
private boolean canPistonMoveBlock(Faction pistonFaction, Location target) { private boolean canPistonMoveBlock(Faction pistonFaction, Location target) {
Faction otherFaction = Board.getInstance().getFactionAt(new FLocation(target)); Faction otherFaction = Board.getInstance().getFactionAt(new FLocation(target));
if (pistonFaction == otherFaction) return true; if (pistonFaction == otherFaction) return false;
if (otherFaction.isWilderness()) if (otherFaction.isWilderness())
return !Conf.wildernessDenyBuild || Conf.worldsNoWildernessProtection.contains(target.getWorld().getName()); return Conf.wildernessDenyBuild && !Conf.worldsNoWildernessProtection.contains(target.getWorld().getName());
else if (otherFaction.isSafeZone()) return !Conf.safeZoneDenyBuild; else if (otherFaction.isSafeZone()) return Conf.safeZoneDenyBuild;
else if (otherFaction.isWarZone()) return !Conf.warZoneDenyBuild; else if (otherFaction.isWarZone()) return Conf.warZoneDenyBuild;
Relation rel = pistonFaction.getRelationTo(otherFaction); Relation rel = pistonFaction.getRelationTo(otherFaction);
return !rel.confDenyBuild(otherFaction.hasPlayersOnline()); return rel.confDenyBuild(otherFaction.hasPlayersOnline());
} }
@EventHandler(priority = EventPriority.NORMAL, ignoreCancelled = true) @EventHandler(priority = EventPriority.NORMAL, ignoreCancelled = true)
@ -504,15 +501,12 @@ public class FactionsBlockListener implements Listener {
@EventHandler(priority = EventPriority.HIGHEST) @EventHandler(priority = EventPriority.HIGHEST)
public void FrameRemove(HangingBreakByEntityEvent event) { public void frameRemove(HangingBreakByEntityEvent event) {
if (event.getRemover() == null) return; if (event.getRemover() == null) return;
if ((event.getRemover() instanceof Player)) { if ((event.getRemover() instanceof Player) && event.getEntity().getType().equals(EntityType.ITEM_FRAME)) {
if (event.getEntity().getType().equals(EntityType.ITEM_FRAME)) {
Player p = (Player) event.getRemover(); Player p = (Player) event.getRemover();
if (!playerCanBuildDestroyBlock(p, event.getEntity().getLocation(), "destroy", true)) { if (!playerCanBuildDestroyBlock(p, event.getEntity().getLocation(), "destroy", true)) {
event.setCancelled(true); event.setCancelled(true);
return;
}
} }
} }
} }

View File

@ -87,7 +87,7 @@ public class FactionsChatListener implements Listener {
fplayer.sendMessage("[FCspy] " + myFaction.getTag() + ": " + message); fplayer.sendMessage("[FCspy] " + myFaction.getTag() + ": " + message);
} }
} }
FactionChatHandler.sendMessage(FactionsPlugin.getInstance(), myFaction, me.getPlayer().getUniqueId(), me.getPlayer().getName(), event.getMessage()); FactionChatHandler.sendMessage(myFaction, me.getPlayer().getUniqueId(), me.getPlayer().getName(), event.getMessage());
event.setCancelled(true); event.setCancelled(true);
} else if (chat == ChatMode.ALLIANCE) { } else if (chat == ChatMode.ALLIANCE) {
Faction myFaction = me.getFaction(); Faction myFaction = me.getFaction();

View File

@ -4,7 +4,6 @@ import com.massivecraft.factions.*;
import com.massivecraft.factions.event.PowerLossEvent; import com.massivecraft.factions.event.PowerLossEvent;
import com.massivecraft.factions.struct.Relation; import com.massivecraft.factions.struct.Relation;
import com.massivecraft.factions.util.MiscUtil; import com.massivecraft.factions.util.MiscUtil;
import com.massivecraft.factions.util.timer.type.GraceTimer;
import com.massivecraft.factions.zcore.util.TL; import com.massivecraft.factions.zcore.util.TL;
import org.bukkit.Bukkit; import org.bukkit.Bukkit;
import org.bukkit.Location; import org.bukkit.Location;
@ -144,7 +143,7 @@ public class FactionsEntityListener implements Listener {
} else { } else {
// we don't want to let mobs/arrows destroy item frames/armor stands // we don't want to let mobs/arrows destroy item frames/armor stands
// so we only have to run the check as if there had been an explosion at the damager location // so we only have to run the check as if there had been an explosion at the damager location
if (!this.checkExplosionForBlock(damager, damagee.getLocation().getBlock())) if (this.checkExplosionForBlock(damager, damagee.getLocation().getBlock()))
event.setCancelled(true); event.setCancelled(true);
} }
// we don't need to go after // we don't need to go after
@ -217,7 +216,7 @@ public class FactionsEntityListener implements Listener {
Entity boomer = event.getEntity(); Entity boomer = event.getEntity();
// Before we need to check the location where the block is placed // Before we need to check the location where the block is placed
if (!this.checkExplosionForBlock(boomer, event.getLocation().getBlock())) { if (this.checkExplosionForBlock(boomer, event.getLocation().getBlock())) {
event.setCancelled(true); event.setCancelled(true);
return; return;
} }
@ -225,7 +224,7 @@ public class FactionsEntityListener implements Listener {
// Loop the blocklist to run checks on each aimed block // Loop the blocklist to run checks on each aimed block
// The block don't have to explode // The block don't have to explode
event.blockList().removeIf(block -> !this.checkExplosionForBlock(boomer, block)); event.blockList().removeIf(block -> this.checkExplosionForBlock(boomer, block));
// Cancel the event if no block will explode // Cancel the event if no block will explode
if (!event.blockList().isEmpty() && (boomer instanceof TNTPrimed || boomer instanceof ExplosiveMinecart) && Conf.handleExploitTNTWaterlog) { if (!event.blockList().isEmpty() && (boomer instanceof TNTPrimed || boomer instanceof ExplosiveMinecart) && Conf.handleExploitTNTWaterlog) {
@ -260,7 +259,7 @@ public class FactionsEntityListener implements Listener {
Faction faction = Board.getInstance().getFactionAt(new FLocation(block.getLocation())); Faction faction = Board.getInstance().getFactionAt(new FLocation(block.getLocation()));
if (faction.noExplosionsInTerritory() || (faction.isPeaceful() && Conf.peacefulTerritoryDisableBoom)) if (faction.noExplosionsInTerritory() || (faction.isPeaceful() && Conf.peacefulTerritoryDisableBoom))
return false; return true;
// faction is peaceful and has explosions set to disabled // faction is peaceful and has explosions set to disabled
boolean online = faction.hasPlayersOnline(); boolean online = faction.hasPlayersOnline();
@ -270,17 +269,17 @@ public class FactionsEntityListener implements Listener {
(faction.isWarZone() && Conf.warZoneBlockCreepers) || (faction.isWarZone() && Conf.warZoneBlockCreepers) ||
faction.isSafeZone())) { faction.isSafeZone())) {
// creeper which needs prevention // creeper which needs prevention
return false; return true;
} else if ( } else if (
// it's a bit crude just using fireball protection for Wither boss too, but I'd rather not add in a whole new set of xxxBlockWitherExplosion or whatever // it's a bit crude just using fireball protection for Wither boss too, but I'd rather not add in a whole new set of xxxBlockWitherExplosion or whatever
(boomer instanceof Fireball || boomer instanceof Wither) && (faction.isWilderness() && Conf.wildernessBlockFireballs && !Conf.worldsNoWildernessProtection.contains(block.getWorld().getName()) || faction.isNormal() && (online ? Conf.territoryBlockFireballs : Conf.territoryBlockFireballsWhenOffline) || faction.isWarZone() && Conf.warZoneBlockFireballs || faction.isSafeZone())) { (boomer instanceof Fireball || boomer instanceof Wither) && (faction.isWilderness() && Conf.wildernessBlockFireballs && !Conf.worldsNoWildernessProtection.contains(block.getWorld().getName()) || faction.isNormal() && (online ? Conf.territoryBlockFireballs : Conf.territoryBlockFireballsWhenOffline) || faction.isWarZone() && Conf.warZoneBlockFireballs || faction.isSafeZone())) {
// ghast fireball which needs prevention // ghast fireball which needs prevention
return false; return true;
} else } else
return (!(boomer instanceof TNTPrimed) && !(boomer instanceof ExplosiveMinecart)) || ((!faction.isWilderness() || !Conf.wildernessBlockTNT || Conf.worldsNoWildernessProtection.contains(block.getWorld().getName())) && return (boomer instanceof TNTPrimed || boomer instanceof ExplosiveMinecart) && ((faction.isWilderness() && Conf.wildernessBlockTNT && !Conf.worldsNoWildernessProtection.contains(block.getWorld().getName())) ||
(!faction.isNormal() || (online ? !Conf.territoryBlockTNT : !Conf.territoryBlockTNTWhenOffline)) && (faction.isNormal() && (online ? Conf.territoryBlockTNT : Conf.territoryBlockTNTWhenOffline)) ||
(!faction.isWarZone() || !Conf.warZoneBlockTNT) && (faction.isWarZone() && Conf.warZoneBlockTNT) ||
(!faction.isSafeZone() || !Conf.safeZoneBlockTNT)); (faction.isSafeZone() && Conf.safeZoneBlockTNT));
// No condition retained, destroy the block! // No condition retained, destroy the block!
} }
@ -312,7 +311,7 @@ public class FactionsEntityListener implements Listener {
if (thrower instanceof Player) { if (thrower instanceof Player) {
Player player = (Player) thrower; Player player = (Player) thrower;
FPlayer fPlayer = FPlayers.getInstance().getByPlayer(player); FPlayer fPlayer = FPlayers.getInstance().getByPlayer(player);
if (badjuju && fPlayer.getFaction().isPeaceful()) { if (fPlayer.getFaction().isPeaceful()) {
event.setCancelled(true); event.setCancelled(true);
return; return;
} }
@ -507,24 +506,20 @@ public class FactionsEntityListener implements Listener {
if (!(e.getRemover() instanceof Player)) return; if (!(e.getRemover() instanceof Player)) return;
Player p = (Player) e.getRemover(); Player p = (Player) e.getRemover();
if (e.getEntity().getType() == EntityType.PAINTING || e.getEntity().getType() == EntityType.ITEM_FRAME) { if (e.getEntity().getType() == EntityType.PAINTING || e.getEntity().getType() == EntityType.ITEM_FRAME && !FactionsBlockListener.playerCanBuildDestroyBlock(p, e.getEntity().getLocation(), "destroy", false)) {
if (!FactionsBlockListener.playerCanBuildDestroyBlock(p, e.getEntity().getLocation(), "destroy", false)) {
e.setCancelled(true); e.setCancelled(true);
} }
} }
}
@EventHandler(priority = EventPriority.NORMAL, ignoreCancelled = true) @EventHandler(priority = EventPriority.NORMAL, ignoreCancelled = true)
public void onPaintingPlace(HangingPlaceEvent e) { public void onPaintingPlace(HangingPlaceEvent e) {
if (e.getPlayer() == null) return; if (e.getPlayer() == null) return;
if (e.getEntity().getType() == EntityType.PAINTING || e.getEntity().getType() == EntityType.ITEM_FRAME) { if (e.getEntity().getType() == EntityType.PAINTING || e.getEntity().getType() == EntityType.ITEM_FRAME && !FactionsBlockListener.playerCanBuildDestroyBlock(e.getPlayer(), e.getBlock().getLocation(), "build", false)) {
if (!FactionsBlockListener.playerCanBuildDestroyBlock(e.getPlayer(), e.getBlock().getLocation(), "build", false)) {
e.setCancelled(true); e.setCancelled(true);
e.getPlayer().updateInventory(); e.getPlayer().updateInventory();
} }
} }
}
@EventHandler(priority = EventPriority.NORMAL, ignoreCancelled = true) @EventHandler(priority = EventPriority.NORMAL, ignoreCancelled = true)
public void onEntityChangeBlock(EntityChangeBlockEvent e) { public void onEntityChangeBlock(EntityChangeBlockEvent e) {
@ -547,40 +542,9 @@ public class FactionsEntityListener implements Listener {
} }
/*
@EventHandler
public void onTravel(PlayerPortalEvent event) {
if (!FactionsPlugin.getInstance().getConfig().getBoolean("portals.limit", false))
return; // Don't do anything if they don't want us to.
TravelAgent agent = event.getPortalTravelAgent();
// If they aren't able to find a portal, it'll try to create one.
if (event.useTravelAgent() && agent.getCanCreatePortal() && agent.findPortal(event.getTo()) == null) {
FLocation loc = new FLocation(event.getTo());
Faction faction = Board.getInstance().getFactionAt(loc);
if (faction.isWilderness()) {
return; // We don't care about wilderness.
} else if (!faction.isNormal() && !event.getPlayer().isOp()) {
// Don't let non ops make portals in safezone or warzone.
event.setCancelled(true);
return;
}
FPlayer fp = FPlayers.getInstance().getByPlayer(event.getPlayer());
String mininumRelation = FactionsPlugin.getInstance().getConfig().getString("portals.minimum-relation", "MEMBER"); // Defaults to Neutral if typed wrong.
if (!fp.getFaction().getRelationTo(faction).isAtLeast(Relation.fromString(mininumRelation))) {
event.setCancelled(true);
}
}
}
*/
@EventHandler @EventHandler
public void onHit(EntityDamageByEntityEvent e) { public void onHit(EntityDamageByEntityEvent e) {
if (e.getDamager() instanceof Player) { if (e.getDamager() instanceof Player && e.getEntity() instanceof Player) {
if (e.getEntity() instanceof Player) {
Player victim = (Player) e.getEntity(); Player victim = (Player) e.getEntity();
Player attacker = (Player) e.getDamager(); Player attacker = (Player) e.getDamager();
FPlayer fvictim = FPlayers.getInstance().getByPlayer(victim); FPlayer fvictim = FPlayers.getInstance().getByPlayer(victim);
@ -591,12 +555,10 @@ public class FactionsEntityListener implements Listener {
} }
} }
} }
}
@EventHandler @EventHandler
public void onBowHit(EntityDamageByEntityEvent e) { public void onBowHit(EntityDamageByEntityEvent e) {
if (e.getDamager() instanceof Projectile) { if (e.getDamager() instanceof Projectile && e.getEntity() instanceof Player) {
if (e.getEntity() instanceof Player) {
Projectile arrow = ((Projectile) e.getDamager()); Projectile arrow = ((Projectile) e.getDamager());
if (arrow.getShooter() instanceof Player) { if (arrow.getShooter() instanceof Player) {
Player damager = (Player) ((Projectile) e.getDamager()).getShooter(); Player damager = (Player) ((Projectile) e.getDamager()).getShooter();
@ -609,15 +571,12 @@ public class FactionsEntityListener implements Listener {
fdamager.msg(TL.PLAYER_PVP_CANTHURT, fvictim.describeTo(fdamager)); fdamager.msg(TL.PLAYER_PVP_CANTHURT, fvictim.describeTo(fdamager));
e.setCancelled(true); e.setCancelled(true);
} }
if (fvictim.getRelationTo(fdamager) == Relation.ENEMY) { if (fvictim.getRelationTo(fdamager) == Relation.ENEMY && fvictim.isFlying()) {
if (fvictim.isFlying()) {
fvictim.setFFlying(false, true); fvictim.setFFlying(false, true);
} }
} }
} }
} }
}
}
// For disabling interactions with item frames in another faction's territory // For disabling interactions with item frames in another faction's territory
@EventHandler(priority = EventPriority.NORMAL, ignoreCancelled = true) @EventHandler(priority = EventPriority.NORMAL, ignoreCancelled = true)

View File

@ -4,7 +4,6 @@ import com.massivecraft.factions.*;
import com.massivecraft.factions.cmd.CmdFGlobal; import com.massivecraft.factions.cmd.CmdFGlobal;
import com.massivecraft.factions.cmd.CmdFly; import com.massivecraft.factions.cmd.CmdFly;
import com.massivecraft.factions.cmd.CmdSeeChunk; import com.massivecraft.factions.cmd.CmdSeeChunk;
import com.massivecraft.factions.cmd.FCmdRoot;
import com.massivecraft.factions.cmd.audit.FLogType; import com.massivecraft.factions.cmd.audit.FLogType;
import com.massivecraft.factions.cmd.logout.LogoutHandler; import com.massivecraft.factions.cmd.logout.LogoutHandler;
import com.massivecraft.factions.cmd.wild.CmdWild; import com.massivecraft.factions.cmd.wild.CmdWild;
@ -36,8 +35,6 @@ import net.dv8tion.jda.core.entities.Member;
import net.dv8tion.jda.core.entities.TextChannel; import net.dv8tion.jda.core.entities.TextChannel;
import org.bukkit.*; import org.bukkit.*;
import org.bukkit.block.Block; import org.bukkit.block.Block;
import org.bukkit.entity.Boat;
import org.bukkit.entity.Minecart;
import org.bukkit.entity.Player; import org.bukkit.entity.Player;
import org.bukkit.event.Event; import org.bukkit.event.Event;
import org.bukkit.event.EventHandler; import org.bukkit.event.EventHandler;
@ -191,7 +188,6 @@ public class FactionsPlayerListener implements Listener {
FLocation loc = new FLocation(block); FLocation loc = new FLocation(block);
Faction otherFaction = Board.getInstance().getFactionAt(loc); Faction otherFaction = Board.getInstance().getFactionAt(loc);
Faction myFaction = me.getFaction(); Faction myFaction = me.getFaction();
Relation rel = myFaction.getRelationTo(otherFaction);
// no door/chest/whatever protection in wilderness, war zones, or safe zones // no door/chest/whatever protection in wilderness, war zones, or safe zones
if (otherFaction.isSystemFaction()) return true; if (otherFaction.isSystemFaction()) return true;
@ -522,8 +518,7 @@ public class FactionsPlayerListener implements Listener {
@EventHandler @EventHandler
public void onPlayerFall(EntityDamageEvent e) { public void onPlayerFall(EntityDamageEvent e) {
if (e.getEntity() instanceof Player) { if (e.getEntity() instanceof Player && e.getCause() == EntityDamageEvent.DamageCause.FALL) {
if (e.getCause() == EntityDamageEvent.DamageCause.FALL) {
Player player = (Player) e.getEntity(); Player player = (Player) e.getEntity();
if (fallMap.containsKey(player)) { if (fallMap.containsKey(player)) {
e.setCancelled(true); e.setCancelled(true);
@ -531,7 +526,6 @@ public class FactionsPlayerListener implements Listener {
} }
} }
} }
}
@EventHandler(priority = EventPriority.NORMAL) @EventHandler(priority = EventPriority.NORMAL)
public void onPlayerQuit(PlayerQuitEvent event) { public void onPlayerQuit(PlayerQuitEvent event) {
@ -616,7 +610,7 @@ public class FactionsPlayerListener implements Listener {
fplayer.msg(TL.COMMAND_INSPECT_BYPASS); fplayer.msg(TL.COMMAND_INSPECT_BYPASS);
} }
List<String[]> info = CoreProtect.getInstance().getAPI().blockLookup(e.getClickedBlock(), 0); List<String[]> info = CoreProtect.getInstance().getAPI().blockLookup(e.getClickedBlock(), 0);
if (info.size() == 0) { if (info.isEmpty()) {
e.getPlayer().sendMessage(TL.COMMAND_INSPECT_NODATA.toString()); e.getPlayer().sendMessage(TL.COMMAND_INSPECT_NODATA.toString());
return; return;
} }
@ -656,7 +650,7 @@ public class FactionsPlayerListener implements Listener {
} }
public static BukkitTask positionTask = null; public static BukkitTask positionTask = null;
public final static Map<UUID, Location> lastLocations = new HashMap<>(); public final Map<UUID, Location> lastLocations = new HashMap<>();
public void startPositionCheck() { public void startPositionCheck() {
positionTask = Bukkit.getScheduler().runTaskTimer(FactionsPlugin.getInstance(), () -> { positionTask = Bukkit.getScheduler().runTaskTimer(FactionsPlugin.getInstance(), () -> {
@ -830,19 +824,15 @@ public class FactionsPlayerListener implements Listener {
// Do type null checks so if XMaterial has a parsing issue and fills null as a value it will not bypass. // Do type null checks so if XMaterial has a parsing issue and fills null as a value it will not bypass.
// territoryCancelAndAllowItemUseMaterial bypass the protection system but only if they're not clicking on territoryDenySwitchMaterials // territoryCancelAndAllowItemUseMaterial bypass the protection system but only if they're not clicking on territoryDenySwitchMaterials
// if they're clicking on territoryDenySwitchMaterials, let the protection system handle the permissions // if they're clicking on territoryDenySwitchMaterials, let the protection system handle the permissions
if (type != null && !Conf.territoryDenySwitchMaterials.contains(block.getType())) { if (type != null && !Conf.territoryDenySwitchMaterials.contains(block.getType()) && Conf.territoryCancelAndAllowItemUseMaterial.contains(type)) {
if (Conf.territoryCancelAndAllowItemUseMaterial.contains(type)) {
return; return;
} }
}
if (GetPermissionFromUsableBlock(block.getType()) != null) { if (GetPermissionFromUsableBlock(block.getType()) != null && !canPlayerUseBlock(player, block, false)) {
if (!canPlayerUseBlock(player, block, false)) {
event.setCancelled(true); event.setCancelled(true);
event.setUseInteractedBlock(Event.Result.DENY); event.setUseInteractedBlock(Event.Result.DENY);
return; return;
} }
}
if (type != null && !playerCanUseItemHere(player, block.getLocation(), event.getItem().getType(), false, PermissableAction.ITEM)) { if (type != null && !playerCanUseItemHere(player, block.getLocation(), event.getItem().getType(), false, PermissableAction.ITEM)) {
event.setCancelled(true); event.setCancelled(true);
@ -862,8 +852,8 @@ public class FactionsPlayerListener implements Listener {
public void onPlayerBoneMeal(PlayerInteractEvent event) { public void onPlayerBoneMeal(PlayerInteractEvent event) {
Block block = event.getClickedBlock(); Block block = event.getClickedBlock();
if (event.getAction() == Action.RIGHT_CLICK_BLOCK && block.getType() == XMaterial.GRASS_BLOCK.parseMaterial() if (event.getAction() == Action.RIGHT_CLICK_BLOCK && block.getType() == XMaterial.GRASS_BLOCK.parseMaterial()
&& event.hasItem() && event.getItem().getType() == XMaterial.BONE_MEAL.parseMaterial()) { && event.hasItem() && event.getItem().getType() == XMaterial.BONE_MEAL.parseMaterial()
if (!FactionsBlockListener.playerCanBuildDestroyBlock(event.getPlayer(), block.getLocation(), PermissableAction.BUILD.name(), true)) { && !FactionsBlockListener.playerCanBuildDestroyBlock(event.getPlayer(), block.getLocation(), PermissableAction.BUILD.name(), true)) {
FPlayer me = FPlayers.getInstance().getById(event.getPlayer().getUniqueId().toString()); FPlayer me = FPlayers.getInstance().getById(event.getPlayer().getUniqueId().toString());
Faction myFaction = me.getFaction(); Faction myFaction = me.getFaction();
@ -871,7 +861,6 @@ public class FactionsPlayerListener implements Listener {
event.setCancelled(true); event.setCancelled(true);
} }
} }
}
@EventHandler(priority = EventPriority.HIGH) @EventHandler(priority = EventPriority.HIGH)
public void onPlayerRespawn(PlayerRespawnEvent event) { public void onPlayerRespawn(PlayerRespawnEvent event) {
@ -937,19 +926,16 @@ public class FactionsPlayerListener implements Listener {
player.sendMessage(String.valueOf(TL.COMMAND_LOGOUT_DAMAGE_TAKEN)); player.sendMessage(String.valueOf(TL.COMMAND_LOGOUT_DAMAGE_TAKEN));
} }
WaitExecutor.handleAction(player); WaitExecutor.handleAction(player);
if (CmdWild.teleporting.contains(player)) { if (CmdWild.teleporting.contains(player) && !FactionsPlugin.getInstance().getConfig().getBoolean("Wild.FallDamage") && e.getCause() == EntityDamageEvent.DamageCause.FALL) {
if (!FactionsPlugin.getInstance().getConfig().getBoolean("Wild.FallDamage") && e.getCause() == EntityDamageEvent.DamageCause.FALL) {
e.setCancelled(true); e.setCancelled(true);
} }
} }
} }
}
@EventHandler @EventHandler
public void onTeleport(PlayerTeleportEvent e) { public void onTeleport(PlayerTeleportEvent e) {
Player player = e.getPlayer(); Player player = e.getPlayer();
if (player == null) return;
LogoutHandler handler = LogoutHandler.getByName(player.getName()); LogoutHandler handler = LogoutHandler.getByName(player.getName());
if (handler.isLogoutActive(player)) { if (handler.isLogoutActive(player)) {
handler.cancelLogout(player); handler.cancelLogout(player);
@ -987,7 +973,7 @@ public class FactionsPlayerListener implements Listener {
} }
@EventHandler(priority = EventPriority.MONITOR, ignoreCancelled = true) @EventHandler(priority = EventPriority.MONITOR, ignoreCancelled = true)
final public void onFactionJoin(FPlayerJoinEvent event) { final void onFactionJoin(FPlayerJoinEvent event) {
FTeamWrapper.applyUpdatesLater(event.getFaction()); FTeamWrapper.applyUpdatesLater(event.getFaction());
} }
@ -1001,7 +987,7 @@ public class FactionsPlayerListener implements Listener {
} }
@EventHandler @EventHandler
public void AsyncPlayerChatEvent(AsyncPlayerChatEvent e) { public void asyncPlayerChatEvent(AsyncPlayerChatEvent e) {
Player p = e.getPlayer(); Player p = e.getPlayer();
if (CmdFGlobal.toggled.contains(p.getUniqueId())) { if (CmdFGlobal.toggled.contains(p.getUniqueId())) {
@ -1027,13 +1013,11 @@ public class FactionsPlayerListener implements Listener {
for (int i = l.size() - 1; i >= 0; i--) { // going backwards in the list to prevent a ConcurrentModificationException for (int i = l.size() - 1; i >= 0; i--) { // going backwards in the list to prevent a ConcurrentModificationException
Player recipient = l.get(i); Player recipient = l.get(i);
if (recipient != null) { if (recipient != null && CmdFGlobal.toggled.contains(recipient.getUniqueId())) {
if (CmdFGlobal.toggled.contains(recipient.getUniqueId())) {
e.getRecipients().remove(recipient); e.getRecipients().remove(recipient);
} }
} }
} }
}
@EventHandler @EventHandler
public void onDisconnect(PlayerQuitEvent e) { public void onDisconnect(PlayerQuitEvent e) {

View File

@ -15,9 +15,6 @@ import org.bukkit.inventory.ItemStack;
*/ */
public class MenuListener implements Listener { public class MenuListener implements Listener {
public MenuListener() {
}
@EventHandler @EventHandler
public void onInventoryClick(InventoryClickEvent event) { public void onInventoryClick(InventoryClickEvent event) {
if (event.getView().getTitle().equals("Faction Logs")) { if (event.getView().getTitle().equals("Faction Logs")) {

View File

@ -137,7 +137,7 @@ public class FScoreboard {
updateObjective(); updateObjective();
} }
} }
}.runTaskLater(FactionsPlugin.getInstance(), FactionsPlugin.getInstance().getConfig().getInt("scoreboard.expiration", 7) * 20); }.runTaskLater(FactionsPlugin.getInstance(), FactionsPlugin.getInstance().getConfig().getInt("scoreboard.expiration", 7) * 20L);
} }
private void updateObjective() { private void updateObjective() {

View File

@ -25,6 +25,8 @@ public class FTeamWrapper {
private final String teamName; private final String teamName;
private final Faction faction; private final Faction faction;
private final Set<OfflinePlayer> members = new HashSet<>(); private final Set<OfflinePlayer> members = new HashSet<>();
private static final String defaultPrefixes = "scoreboard.default-prefixes";
private static final String invisFactionMembers = "See-Invisible-Faction-Members";
private FTeamWrapper(Faction faction) { private FTeamWrapper(Faction faction) {
this.teamName = "faction_" + (factionTeamPtr++); this.teamName = "faction_" + (factionTeamPtr++);
@ -44,7 +46,7 @@ public class FTeamWrapper {
return; return;
} }
if (!FactionsPlugin.getInstance().getConfig().getBoolean("scoreboard.default-prefixes", false) || FactionsPlugin.getInstance().getConfig().getBoolean("See-Invisible-Faction-Members")) { if (!FactionsPlugin.getInstance().getConfig().getBoolean(defaultPrefixes, false) || FactionsPlugin.getInstance().getConfig().getBoolean(invisFactionMembers)) {
return; return;
} }
@ -66,7 +68,7 @@ public class FTeamWrapper {
return; return;
} }
if (!FactionsPlugin.getInstance().getConfig().getBoolean("scoreboard.default-prefixes", false) || FactionsPlugin.getInstance().getConfig().getBoolean("See-Invisible-Faction-Members")) { if (!FactionsPlugin.getInstance().getConfig().getBoolean(defaultPrefixes, false) || FactionsPlugin.getInstance().getConfig().getBoolean(invisFactionMembers)) {
return; return;
} }
@ -158,7 +160,7 @@ public class FTeamWrapper {
} }
private void updatePrefixes() { private void updatePrefixes() {
if (FactionsPlugin.getInstance().getConfig().getBoolean("scoreboard.default-prefixes", false)) { if (FactionsPlugin.getInstance().getConfig().getBoolean(defaultPrefixes, false)) {
for (FScoreboard fboard : teams.keySet()) { for (FScoreboard fboard : teams.keySet()) {
updatePrefix(fboard); updatePrefix(fboard);
} }
@ -166,19 +168,19 @@ public class FTeamWrapper {
} }
private void updatePrefix(FScoreboard fboard) { private void updatePrefix(FScoreboard fboard) {
if (FactionsPlugin.getInstance().getConfig().getBoolean("scoreboard.default-prefixes", false)) { if (FactionsPlugin.getInstance().getConfig().getBoolean(defaultPrefixes, false)) {
FPlayer fplayer = fboard.getFPlayer(); FPlayer fplayer = fboard.getFPlayer();
Team team = teams.get(fboard); Team team = teams.get(fboard);
boolean focused = false; boolean focused = false;
if (FactionsPlugin.getInstance().getConfig().getBoolean("See-Invisible-Faction-Members", false)) { if (FactionsPlugin.getInstance().getConfig().getBoolean(invisFactionMembers, false)) {
team.setCanSeeFriendlyInvisibles(true); team.setCanSeeFriendlyInvisibles(true);
} }
if ((FactionsPlugin.getInstance().getConfig().getBoolean("ffocus.Enabled")) && (fplayer.getFaction() != null) && (fplayer.getFaction().getFocused() != null)) { if ((FactionsPlugin.getInstance().getConfig().getBoolean("ffocus.Enabled")) && (fplayer.getFaction() != null) && (fplayer.getFaction().getFocused() != null)) {
for (FPlayer fp : faction.getFPlayersWhereOnline(true)) { for (FPlayer fp : faction.getFPlayersWhereOnline(true)) {
if (fplayer.getFaction().getFocused().equalsIgnoreCase(fp.getName())) { if (fplayer.getFaction().getFocused().equalsIgnoreCase(fp.getName())) {
team.setPrefix(ChatColor.translateAlternateColorCodes('&', FactionsPlugin.getInstance().getConfig().getString("ffocus.Prefix", "&7»&b"))); team.setPrefix(ChatColor.translateAlternateColorCodes('&', Objects.requireNonNull(FactionsPlugin.getInstance().getConfig().getString("ffocus.Prefix", "&7»&b"))));
focused = true; focused = true;
} }
} }
@ -191,7 +193,8 @@ public class FTeamWrapper {
prefix = prefix.replace("{relationcolor}", faction.getRelationTo(fplayer).getColor().toString()); prefix = prefix.replace("{relationcolor}", faction.getRelationTo(fplayer).getColor().toString());
prefix = prefix.replace("{faction}", prefix = prefix.replace("{faction}",
faction.getTag().substring(0, Math.min("{faction}".length() + 16 - prefix.length(), faction.getTag().length()))); faction.getTag().substring(0, Math.min("{faction}".length() + 16 - prefix.length(), faction.getTag().length())));
if ((team.getPrefix() == null) || (!team.getPrefix().equals(prefix))) { team.getPrefix();
if (!team.getPrefix().equals(prefix)) {
team.setPrefix(prefix); team.setPrefix(prefix);
} }
} }

View File

@ -45,12 +45,13 @@ public class ShopGUIFrame {
int items = FactionsPlugin.getInstance().getFileManager().getShop().getConfig().getConfigurationSection("items").getKeys(false).size(); int items = FactionsPlugin.getInstance().getFileManager().getShop().getConfig().getConfigurationSection("items").getKeys(false).size();
for (int a = 1; a <= items; a++) { for (int a = 1; a <= items; a++) {
String s = a + ""; String s = a + "";
int slot = FactionsPlugin.getInstance().getFileManager().getShop().fetchInt("items." + s + ".slot"); String varItems = "items.";
ItemStack item = XMaterial.matchXMaterial(FactionsPlugin.getInstance().getFileManager().getShop().fetchString("items." + s + ".block")).get().parseItem(); int slot = FactionsPlugin.getInstance().getFileManager().getShop().fetchInt(varItems + s + ".slot");
int cost = FactionsPlugin.getInstance().getFileManager().getShop().fetchInt("items." + s + ".cost"); ItemStack item = XMaterial.matchXMaterial(FactionsPlugin.getInstance().getFileManager().getShop().fetchString(varItems + s + ".block")).get().parseItem();
String name = FactionsPlugin.getInstance().getFileManager().getShop().fetchString("items." + s + ".name"); int cost = FactionsPlugin.getInstance().getFileManager().getShop().fetchInt(varItems + s + ".cost");
boolean glowing = FactionsPlugin.getInstance().getFileManager().getShop().fetchBoolean("items." + s + ".glowing"); String name = FactionsPlugin.getInstance().getFileManager().getShop().fetchString(varItems + s + ".name");
List<String> lore = FactionsPlugin.getInstance().getFileManager().getShop().fetchStringList("items." + s + ".lore"); boolean glowing = FactionsPlugin.getInstance().getFileManager().getShop().fetchBoolean(varItems + s + ".glowing");
List<String> lore = FactionsPlugin.getInstance().getFileManager().getShop().fetchStringList(varItems + s + ".lore");
assert item != null; assert item != null;

View File

@ -55,9 +55,9 @@ public enum Role implements Permissable {
return COLEADER; return COLEADER;
case 4: case 4:
return LEADER; return LEADER;
default:
throw new IllegalStateException("Unexpected value: " + value);
} }
return null;
} }
public static Role fromString(String check) { public static Role fromString(String check) {
@ -76,9 +76,9 @@ public enum Role implements Permissable {
case "recruit": case "recruit":
case "rec": case "rec":
return RECRUIT; return RECRUIT;
default:
throw new IllegalStateException("Unexpected value: " + check.toLowerCase());
} }
return null;
} }
public boolean isAtLeast(Role role) { public boolean isAtLeast(Role role) {

View File

@ -17,27 +17,27 @@ public enum FactionTag implements Tag {
* @author FactionsUUID Team * @author FactionsUUID Team
*/ */
HOME_X("{x}", (fac) -> fac.hasHome() ? String.valueOf(fac.getHome().getBlockX()) : Tag.isMinimalShow() ? null : "{ig}"), HOME_X("{x}", fac -> fac.hasHome() ? String.valueOf(fac.getHome().getBlockX()) : Tag.isMinimalShow() ? null : "{ig}"),
HOME_Y("{y}", (fac) -> fac.hasHome() ? String.valueOf(fac.getHome().getBlockY()) : Tag.isMinimalShow() ? null : "{ig}"), HOME_Y("{y}", fac -> fac.hasHome() ? String.valueOf(fac.getHome().getBlockY()) : Tag.isMinimalShow() ? null : "{ig}"),
HOME_Z("{z}", (fac) -> fac.hasHome() ? String.valueOf(fac.getHome().getBlockZ()) : Tag.isMinimalShow() ? null : "{ig}"), HOME_Z("{z}", fac -> fac.hasHome() ? String.valueOf(fac.getHome().getBlockZ()) : Tag.isMinimalShow() ? null : "{ig}"),
CHUNKS("{chunks}", (fac) -> String.valueOf(fac.getLandRounded())), CHUNKS("{chunks}", fac -> String.valueOf(fac.getLandRounded())),
WARPS("{warps}", (fac) -> String.valueOf(fac.getWarps().size())), WARPS("{warps}", fac -> String.valueOf(fac.getWarps().size())),
HEADER("{header}", (fac, fp) -> FactionsPlugin.getInstance().txt.titleize(fac.getTag(fp))), HEADER("{header}", (fac, fp) -> FactionsPlugin.getInstance().txt.titleize(fac.getTag(fp))),
POWER("{power}", (fac) -> String.valueOf(fac.getPowerRounded())), POWER("{power}", fac -> String.valueOf(fac.getPowerRounded())),
MAX_POWER("{maxPower}", (fac) -> String.valueOf(fac.getPowerMaxRounded())), MAX_POWER("{maxPower}", fac -> String.valueOf(fac.getPowerMaxRounded())),
POWER_BOOST("{power-boost}", (fac) -> { POWER_BOOST("{power-boost}", fac -> {
double powerBoost = fac.getPowerBoost(); double powerBoost = fac.getPowerBoost();
return (powerBoost == 0.0) ? "" : (powerBoost > 0.0 ? TL.COMMAND_SHOW_BONUS.toString() : TL.COMMAND_SHOW_PENALTY.toString() + powerBoost + ")"); return (powerBoost == 0.0) ? "" : (powerBoost > 0.0 ? TL.COMMAND_SHOW_BONUS.toString() : TL.COMMAND_SHOW_PENALTY.toString() + powerBoost + ")");
}), }),
LEADER("{leader}", (fac) -> { LEADER("{leader}", fac -> {
FPlayer fAdmin = fac.getFPlayerAdmin(); FPlayer fAdmin = fac.getFPlayerAdmin();
return fAdmin == null ? "Server" : fAdmin.getName().substring(0, fAdmin.getName().length() > 14 ? 13 : fAdmin.getName().length()); return fAdmin == null ? "Server" : fAdmin.getName().substring(0, fAdmin.getName().length() > 14 ? 13 : fAdmin.getName().length());
}), }),
JOINING("{joining}", (fac) -> (fac.getOpen() ? TL.COMMAND_SHOW_UNINVITED.toString() : TL.COMMAND_SHOW_INVITATION.toString())), JOINING("{joining}", fac -> (fac.getOpen() ? TL.COMMAND_SHOW_UNINVITED.toString() : TL.COMMAND_SHOW_INVITATION.toString())),
FACTION("{faction}", (Function<Faction, String>) Faction::getTag), FACTION("{faction}", (Function<Faction, String>) Faction::getTag),
FACTION_RELATION_COLOR("{faction-relation-color}", (fac, fp) -> fp == null ? "" : fp.getColorTo(fac).toString()), FACTION_RELATION_COLOR("{faction-relation-color}", (fac, fp) -> fp == null ? "" : fp.getColorTo(fac).toString()),
HOME_WORLD("{world}", (fac) -> fac.hasHome() ? fac.getHome().getWorld().getName() : Tag.isMinimalShow() ? null : "{ig}"), HOME_WORLD("{world}", fac -> fac.hasHome() ? fac.getHome().getWorld().getName() : Tag.isMinimalShow() ? null : "{ig}"),
RAIDABLE("{raidable}", (fac) -> { RAIDABLE("{raidable}", fac -> {
if (FactionsPlugin.getInstance().getConfig().getBoolean("hcf.raidable", false)) { if (FactionsPlugin.getInstance().getConfig().getBoolean("hcf.raidable", false)) {
boolean raidable = fac.getLandRounded() >= fac.getPowerRounded(); boolean raidable = fac.getLandRounded() >= fac.getPowerRounded();
String str = raidable ? TL.RAIDABLE_TRUE.toString() : TL.RAIDABLE_FALSE.toString(); String str = raidable ? TL.RAIDABLE_TRUE.toString() : TL.RAIDABLE_FALSE.toString();
@ -50,37 +50,35 @@ public enum FactionTag implements Tag {
return null; return null;
}), }),
ANNOUNCEMENT("{announcement}", (fac) -> { ANNOUNCEMENT("{announcement}", fac -> String.valueOf(fac.getAnnouncements())),
return String.valueOf(fac.getAnnouncements()); PEACEFUL("{peaceful}", fac -> fac.isPeaceful() ? Conf.colorNeutral + TL.COMMAND_SHOW_PEACEFUL.toString() : ""),
}), PERMANENT("permanent", fac -> fac.isPermanent() ? "permanent" : "{notPermanent}"), // no braces needed
PEACEFUL("{peaceful}", (fac) -> fac.isPeaceful() ? Conf.colorNeutral + TL.COMMAND_SHOW_PEACEFUL.toString() : ""), LAND_VALUE("{land-value}", fac -> Econ.shouldBeUsed() ? Econ.moneyString(Econ.calculateTotalLandValue(fac.getLandRounded())) : Tag.isMinimalShow() ? null : TL.ECON_OFF.format("value")),
PERMANENT("permanent", (fac) -> fac.isPermanent() ? "permanent" : "{notPermanent}"), // no braces needed
LAND_VALUE("{land-value}", (fac) -> Econ.shouldBeUsed() ? Econ.moneyString(Econ.calculateTotalLandValue(fac.getLandRounded())) : Tag.isMinimalShow() ? null : TL.ECON_OFF.format("value")),
DESCRIPTION("{description}", Faction::getDescription), DESCRIPTION("{description}", Faction::getDescription),
CREATE_DATE("{create-date}", (fac) -> TL.sdf.format(fac.getFoundedDate())), CREATE_DATE("{create-date}", fac -> TL.sdf.format(fac.getFoundedDate())),
LAND_REFUND("{land-refund}", (fac) -> Econ.shouldBeUsed() ? Econ.moneyString(Econ.calculateTotalLandRefund(fac.getLandRounded())) : Tag.isMinimalShow() ? null : TL.ECON_OFF.format("refund")), LAND_REFUND("{land-refund}", fac -> Econ.shouldBeUsed() ? Econ.moneyString(Econ.calculateTotalLandRefund(fac.getLandRounded())) : Tag.isMinimalShow() ? null : TL.ECON_OFF.format("refund")),
BANK_BALANCE("{faction-balance}", (fac) -> { BANK_BALANCE("{faction-balance}", fac -> {
if (Econ.shouldBeUsed()) { if (Econ.shouldBeUsed()) {
return Conf.bankEnabled ? Econ.moneyString(Econ.getBalance(fac.getAccountId())) : Tag.isMinimalShow() ? null : TL.ECON_OFF.format("balance"); return Conf.bankEnabled ? Econ.moneyString(Econ.getBalance(fac.getAccountId())) : Tag.isMinimalShow() ? null : TL.ECON_OFF.format("balance");
} }
return Tag.isMinimalShow() ? null : TL.ECON_OFF.format("balance"); return Tag.isMinimalShow() ? null : TL.ECON_OFF.format("balance");
}), }),
TNT_BALANCE("{tnt-balance}", (fac) -> { TNT_BALANCE("{tnt-balance}", fac -> {
if (FactionsPlugin.instance.getConfig().getBoolean("ftnt.Enabled")) { if (FactionsPlugin.instance.getConfig().getBoolean("ftnt.Enabled")) {
return String.valueOf(fac.getTnt()); return String.valueOf(fac.getTnt());
} }
return Tag.isMinimalShow() ? null : ""; return Tag.isMinimalShow() ? null : "";
}), }),
TNT_MAX("{tnt-max-balance}", (fac) -> { TNT_MAX("{tnt-max-balance}", fac -> {
if (FactionsPlugin.instance.getConfig().getBoolean("ftnt.Enabled")) { if (FactionsPlugin.instance.getConfig().getBoolean("ftnt.Enabled")) {
return String.valueOf(fac.getTntBankLimit()); return String.valueOf(fac.getTntBankLimit());
} }
return Tag.isMinimalShow() ? null : ""; return Tag.isMinimalShow() ? null : "";
}), }),
ALLIES_COUNT("{allies}", (fac) -> String.valueOf(fac.getRelationCount(Relation.ALLY))), ALLIES_COUNT("{allies}", fac -> String.valueOf(fac.getRelationCount(Relation.ALLY))),
ENEMIES_COUNT("{enemies}", (fac) -> String.valueOf(fac.getRelationCount(Relation.ENEMY))), ENEMIES_COUNT("{enemies}", fac -> String.valueOf(fac.getRelationCount(Relation.ENEMY))),
TRUCES_COUNT("{truces}", (fac) -> String.valueOf(fac.getRelationCount(Relation.TRUCE))), TRUCES_COUNT("{truces}", fac -> String.valueOf(fac.getRelationCount(Relation.TRUCE))),
ONLINE_COUNT("{online}", (fac, fp) -> { ONLINE_COUNT("{online}", (fac, fp) -> {
if (fp != null && fp.isOnline()) { if (fp != null && fp.isOnline()) {
return String.valueOf(fac.getFPlayersWhereOnline(true, fp).size()); return String.valueOf(fac.getFPlayersWhereOnline(true, fp).size());
@ -97,12 +95,12 @@ public enum FactionTag implements Tag {
return String.valueOf(fac.getFPlayersWhereOnline(false).size()); return String.valueOf(fac.getFPlayersWhereOnline(false).size());
} }
}), }),
FACTION_STRIKES("{faction-strikes}", (fac) -> String.valueOf(fac.getStrikes())), FACTION_STRIKES("{faction-strikes}", fac -> String.valueOf(fac.getStrikes())),
FACTION_POINTS("{faction-points}", (fac) -> String.valueOf(fac.getPoints())), FACTION_POINTS("{faction-points}", fac -> String.valueOf(fac.getPoints())),
FACTION_SIZE("{members}", (fac) -> String.valueOf(fac.getFPlayers().size())), FACTION_SIZE("{members}", fac -> String.valueOf(fac.getFPlayers().size())),
FACTION_KILLS("{faction-kills}", (fac) -> String.valueOf(fac.getKills())), FACTION_KILLS("{faction-kills}", fac -> String.valueOf(fac.getKills())),
FACTION_DEATHS("{faction-deaths}", (fac) -> String.valueOf(fac.getDeaths())), FACTION_DEATHS("{faction-deaths}", fac -> String.valueOf(fac.getDeaths())),
FACTION_BANCOUNT("{faction-bancount}", (fac) -> String.valueOf(fac.getBannedPlayers().size())), FACTION_BANCOUNT("{faction-bancount}", fac -> String.valueOf(fac.getBannedPlayers().size())),
; ;
private final String tag; private final String tag;

View File

@ -177,7 +177,7 @@ public enum FancyTag implements Tag {
public List getMessage(String text, Faction faction, FPlayer player, Map<UUID, String> groupMap) { public List getMessage(String text, Faction faction, FPlayer player, Map<UUID, String> groupMap) {
if (!this.foundInString(text)) { if (!this.foundInString(text)) {
return Collections.EMPTY_LIST; // We really, really shouldn't be here. return Collections.emptyList(); // We really, really shouldn't be here.
} }
return this.function.apply(faction, player, text.replace(this.getTag(), ""), groupMap); return this.function.apply(faction, player, text.replace(this.getTag(), ""), groupMap);
} }

View File

@ -10,8 +10,8 @@ import java.util.logging.Level;
public class AutoLeaveProcessTask extends BukkitRunnable { public class AutoLeaveProcessTask extends BukkitRunnable {
private transient boolean readyToGo = false; private transient boolean readyToGo;
private transient boolean finished = false; private transient boolean finished;
private transient ListIterator<FPlayer> iterator; private transient ListIterator<FPlayer> iterator;
private transient double toleranceMillis; private transient double toleranceMillis;

View File

@ -19,7 +19,7 @@ public class Cooldown {
} }
public static boolean isOnCooldown(Player player, String name) { public static boolean isOnCooldown(Player player, String name) {
if (!player.hasMetadata(name) || player.getMetadata(name).size() <= 0) return false; if (!player.hasMetadata(name) || player.getMetadata(name).isEmpty()) return false;
long time = player.getMetadata(name).get(0).asLong(); long time = player.getMetadata(name).get(0).asLong();
return (time > System.currentTimeMillis()); return (time > System.currentTimeMillis());
} }

View File

@ -15,7 +15,7 @@ import java.io.IOException;
public class InventoryUtil { public class InventoryUtil {
public static String InventoryToString(ItemStack[] items) throws IllegalStateException { public static String InventoryToString(ItemStack[] items) {
try { try {
ByteArrayOutputStream outputStream = new ByteArrayOutputStream(); ByteArrayOutputStream outputStream = new ByteArrayOutputStream();
BukkitObjectOutputStream dataOutput = new BukkitObjectOutputStream(outputStream); BukkitObjectOutputStream dataOutput = new BukkitObjectOutputStream(outputStream);

View File

@ -109,8 +109,6 @@ public class MiscUtil {
switch (player.getRole()) { switch (player.getRole()) {
case LEADER: case LEADER:
admins.add(player);
break;
case COLEADER: case COLEADER:
admins.add(player); admins.add(player);
break; break;

View File

@ -20,8 +20,6 @@ public class RelationUtil {
} }
Faction myFaction = getFaction(me); Faction myFaction = getFaction(me);
// if (myFaction == null) return that.describeTo(null); // no relation, but can show basic name or tag
if (that instanceof Faction) { if (that instanceof Faction) {
if (me instanceof FPlayer && myFaction == thatFaction) { if (me instanceof FPlayer && myFaction == thatFaction) {
ret = TL.GENERIC_YOURFACTION.toString(); ret = TL.GENERIC_YOURFACTION.toString();

View File

@ -187,7 +187,6 @@ public abstract class SpiralTask implements Runnable {
// for successful completion // for successful completion
public void finish() { public void finish() {
// FactionsPlugin.getInstance().log("SpiralTask successfully completed!");
this.stop(); this.stop();
} }

View File

@ -16,8 +16,7 @@ public class VisualizeUtil {
} }
public static Set<Location> getPlayerLocations(UUID uuid) { public static Set<Location> getPlayerLocations(UUID uuid) {
Set<Location> ret = playerLocations.computeIfAbsent(uuid, k -> new HashSet<>()); return playerLocations.computeIfAbsent(uuid, k -> new HashSet<>());
return ret;
} }
@SuppressWarnings("deprecation") @SuppressWarnings("deprecation")

View File

@ -25,13 +25,6 @@ public class TimerRunnable {
} }
public TimerRunnable(UUID playerUUID, Timer timer, long duration) {
this.timer = timer;
setRemaining(duration);
FactionsPlugin plugin = FactionsPlugin.getInstance();
plugin.getTimerManager().getTimerRunnableList().add(this);
}
public boolean isCancelled() { public boolean isCancelled() {
return cancelled; return cancelled;
} }

View File

@ -26,21 +26,19 @@ public class GraceTimer extends GlobalTimer implements Listener {
@EventHandler @EventHandler
public void onBreak(EntityExplodeEvent e) { public void onBreak(EntityExplodeEvent e) {
if(getRemaining() > 0) if (getRemaining() > 0) {
e.setCancelled(true); e.setCancelled(true);
} }
}
@EventHandler @EventHandler
public void onTNTPlace(BlockPlaceEvent event) { public void onTNTPlace(BlockPlaceEvent event) {
FPlayer fp = FPlayers.getInstance().getByPlayer(event.getPlayer()); FPlayer fp = FPlayers.getInstance().getByPlayer(event.getPlayer());
if(getRemaining() > 0) { if (getRemaining() > 0 && !fp.isAdminBypassing() && event.getBlock().getType().equals(Material.TNT)) {
if (!fp.isAdminBypassing()) {
if (event.getBlock().getType().equals(Material.TNT)) {
event.setCancelled(true); event.setCancelled(true);
} }
} }
}
}
@Override @Override
public void load(Config config) { public void load(Config config) {