Code Optimizations

This commit is contained in:
Driftay 2020-06-09 06:28:34 -04:00
parent 7f927189ea
commit ce9038742f
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 ownedMessageByChunk = false;
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> territoryDenyUsageMaterials = 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.");
mc115 = true;
break;
default:
throw new IllegalStateException("Unexpected value: " + version);
}
migrateFPlayerLeaders();
log("==== End Setup ====");
int pluginId = 7013;
Metrics metrics = new Metrics(this, pluginId);
new Metrics(this, pluginId);
if (!preEnable()) {
this.loadSuccessful = false;
@ -394,14 +396,12 @@ public class FactionsPlugin extends MPlugin {
return this.mvdwPlaceholderAPIManager;
}
private boolean setupPermissions() {
private void setupPermissions() {
try {
RegisteredServiceProvider<Permission> rsp = getServer().getServicesManager().getRegistration(Permission.class);
if (rsp != null) perms = rsp.getProvider();
} catch (NoClassDefFoundError ex) {
return false;
} catch (NoClassDefFoundError ignored) {
}
return perms != null;
}
private boolean setupPlayervaults() {

View File

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

View File

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

View File

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

View File

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

View File

@ -18,7 +18,6 @@ public class CmdChat extends FCommand {
super();
this.aliases.addAll(Aliases.chat);
//this.requiredArgs.add("");
this.optionalArgs.put("mode", "next");
this.requirements = new CommandRequirements.Builder(Permission.CHAT)
@ -86,7 +85,7 @@ public class CmdChat extends FCommand {
return TL.COMMAND_CHAT_DESCRIPTION;
}
protected class ChatBrigadier implements BrigadierProvider {
protected static class ChatBrigadier implements BrigadierProvider {
@Override
public ArgumentBuilder<Object, ?> get(ArgumentBuilder<Object, ?> parent) {
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) {
context.faction.setCheckpoint(context.player.getLocation());
context.msg(TL.COMMAND_CHECKPOINT_SET);
return;
} else {
context.msg(TL.COMMAND_CHECKPOINT_INVALIDLOCATION);
return;
}
return;
}
if (context.faction.getCheckpoint() == null) {
context.msg(TL.COMMAND_CHECKPOINT_NOT_SET);

View File

@ -66,7 +66,7 @@ public class CmdCreate extends FCommand {
}
ArrayList<String> tagValidationErrors = MiscUtil.validateTag(tag);
if (tagValidationErrors.size() > 0) {
if (tagValidationErrors.isEmpty()) {
context.sendMessage(tagValidationErrors);
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
// 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);
Bukkit.getScheduler().scheduleSyncDelayedTask(FactionsPlugin.instance, () -> FactionsPlugin.instance.logFactionEvent(context.faction, FLogType.FDESC_EDIT, context.fPlayer.getName(), desc));
if (!Conf.broadcastDescriptionChanges) {

View File

@ -42,8 +42,8 @@ public class CmdDisband extends FCommand {
boolean isMyFaction = context.fPlayer != null && faction == context.faction;
if (!isMyFaction) {
if (!Permission.DISBAND_ANY.has(context.sender, true)) return;
if (!isMyFaction && !Permission.DISBAND_ANY.has(context.sender, true)) {
return;
}
@ -70,7 +70,7 @@ public class CmdDisband extends FCommand {
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);
return;
}
@ -81,13 +81,9 @@ public class CmdDisband extends FCommand {
access = true;
}
if (!access) {
if (Conf.useDisbandGUI && (!context.fPlayer.isAdminBypassing() || !context.player.isOp())) {
if (!disbandMap.containsKey(context.player.getUniqueId().toString())) {
new FDisbandFrame(context.faction).buildGUI(context.fPlayer);
return;
}
}
if (!access && Conf.useDisbandGUI && (!context.fPlayer.isAdminBypassing() || !context.player.isOp()) && !disbandMap.containsKey(context.player.getUniqueId().toString())) {
new FDisbandFrame(context.faction).buildGUI(context.fPlayer);
return;
}
// check for tnt before disbanding.

View File

@ -88,11 +88,7 @@ public class CmdHome extends FCommand {
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 (Conf.homesTeleportAllowedEnemyDistance > 0
&& !faction.isSafeZone()
&& (!context.fPlayer.isInOwnTerritory()
|| (context.fPlayer.isInOwnTerritory()
&& !Conf.homesTeleportIgnoreEnemiesIfInOwnTerritory))) {
if (Conf.homesTeleportAllowedEnemyDistance > 0 && !faction.isSafeZone() && (!context.fPlayer.isInOwnTerritory() || !Conf.homesTeleportIgnoreEnemiesIfInOwnTerritory)) {
World w = loc.getWorld();
double x = loc.getX();

View File

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

View File

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

View File

@ -66,18 +66,16 @@ public class CmdRules extends FCommand {
String message = "";
StringBuilder string = new StringBuilder(message);
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.msg(TL.COMMAND_RULES_ADD_SUCCESS);
}
if (context.args.size() == 2) {
if (context.args.get(0).equalsIgnoreCase("remove")) {
if (context.args.size() == 2 && context.args.get(0).equalsIgnoreCase("remove")) {
int index = context.argAsInt(1);
context.faction.removeRule(index - 1);
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();
}
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);
FancyMessage localFancy = instance.txt.parseFancy(parsed);

View File

@ -30,9 +30,7 @@ public class CmdTpBanner extends FCommand {
if (FactionsBlockListener.bannerLocations.containsKey(context.fPlayer.getTag())) {
context.msg(TL.COMMAND_TPBANNER_SUCCESS);
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.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));
} else {
context.msg(TL.COMMAND_TPBANNER_NOTSET);
}

View File

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

View File

@ -70,13 +70,9 @@ public class CommandRequirements {
return false;
}
if (access != Access.ALLOW) {
// 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);
return false;
}
if (access != Access.ALLOW && role != null && !context.fPlayer.getRole().isAtLeast(role)) {
if (informIfNot) context.msg(TL.GENERIC_YOUMUSTBE, role.translation);
return false;
}
// They have been explicitly allowed
return true;

View File

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

View File

@ -114,7 +114,7 @@ public class FAuditMenu extends GUIMenu {
}
lore.add("");
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);
timeStamp = !timeStamp;
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);
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 boolean saving = false;
public FLogManager() {
}
public void log(Faction faction, FLogType type, String... arguments) {
FactionLogs logs = factionLogMap.computeIfAbsent(faction.getId(), (n) -> new FactionLogs());
@ -90,8 +88,7 @@ public class FLogManager {
Faction faction = null;
for (Map.Entry<UUID, LogTimer> uuidLogTimerEntry : getLogTimers().entrySet()) {
Map.Entry<UUID, LogTimer> timer = uuidLogTimerEntry;
LogTimer logTimer = timer.getValue();
LogTimer logTimer = uuidLogTimerEntry.getValue();
if (faction == null) {
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.forEach((rem) -> mostRecentLogs.remove(rem));
toRemove.forEach(rem -> mostRecentLogs.remove(rem));
}
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) {
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) {
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) {

View File

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

View File

@ -12,6 +12,7 @@ import org.bukkit.inventory.Inventory;
import org.bukkit.inventory.InventoryHolder;
import org.bukkit.inventory.ItemStack;
import org.bukkit.inventory.meta.ItemMeta;
import org.jetbrains.annotations.NotNull;
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);
}
@NotNull
public Inventory getInventory() {
return this.inventory;
}
@ -92,9 +94,6 @@ public class CheckSettingsFrame implements InventoryHolder, FactionGUI {
case 15: {
return 30;
}
case 30: {
return 0;
}
default: {
return 0;
}

View File

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

View File

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

View File

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

View File

@ -41,13 +41,9 @@ public class CmdClaim extends FCommand {
int radius = context.argAsInt(0, 1); // Default to 1
final Faction forFaction = context.argAsFaction(1, context.faction); // Default to own
if (!context.fPlayer.isAdminBypassing()) {
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);
return;
}
}
if (!context.fPlayer.isAdminBypassing() && !(context.fPlayer.getFaction().equals(forFaction) && context.fPlayer.getRole() == Role.LEADER) && forFaction.getAccess(context.fPlayer, PermissableAction.TERRITORY) != Access.ALLOW) {
context.msg(TL.COMMAND_CLAIM_DENIED);
return;
}
@ -90,12 +86,11 @@ public class CmdClaim extends FCommand {
return true;
}
@Override
public void finish() {
if (FactionsPlugin.cachedRadiusClaim) {
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()));
stop();
}
if (FactionsPlugin.cachedRadiusClaim && 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()));
stop();
}
}
};

View File

@ -68,15 +68,10 @@ public class CmdClaimLine extends FCommand {
}
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 (!context.fPlayer.isAdminBypassing()) {
if (forFaction.getAccess(context.fPlayer, PermissableAction.TERRITORY) != Access.ALLOW) {
if (forFaction != context.fPlayer.getFaction() && !context.fPlayer.isAdminBypassing() && forFaction.getAccess(context.fPlayer, PermissableAction.TERRITORY) != Access.ALLOW) {
context.msg(TL.COMMAND_CLAIM_DENIED);
return;
}
}
}
Location location = context.player.getLocation();
@ -85,13 +80,11 @@ public class CmdClaimLine extends FCommand {
int claims = 0;
for (int i = 0; i < amount; i++) {
if (FactionsPlugin.cachedRadiusClaim && context.fPlayer.attemptClaim(forFaction, context.player.getLocation(), false)) {
claims++;
} else {
if (!FactionsPlugin.cachedRadiusClaim || !context.fPlayer.attemptClaim(forFaction, context.player.getLocation(), false)) {
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(","));
}
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.FCommand;
import com.massivecraft.factions.cmd.audit.FLogType;
import com.massivecraft.factions.iface.EconomyParticipator;
import com.massivecraft.factions.integration.Econ;
import com.massivecraft.factions.struct.Permission;
import com.massivecraft.factions.struct.Role;
@ -44,23 +43,21 @@ public class CmdMoneyWithdraw extends FCommand {
return;
}
EconomyParticipator faction = context.argAsFaction(1, context.faction);
Faction faction = context.argAsFaction(1, context.faction);
if (faction == null) {
return;
}
Access access = context.faction.getAccess(context.fPlayer, PermissableAction.WITHDRAW);
if (context.fPlayer.getRole() != Role.LEADER) {
if (access == Access.DENY) {
context.msg(TL.GENERIC_NOPERMISSION, "withdraw", "withdraw money from the bank");
return;
}
if (context.fPlayer.getRole() != Role.LEADER && access == Access.DENY) {
context.msg(TL.GENERIC_NOPERMISSION, "withdraw", "withdraw money from the bank");
return;
}
boolean success = Econ.transferMoney(context.fPlayer, faction, context.fPlayer, amount);
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.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,31 +37,29 @@ public class CmdGrace extends FCommand {
return;
}
if(context.args.size() == 1) {
if (context.sender.hasPermission(String.valueOf(Permission.GRACETOGGLE))) {
if (context.argAsString(0).equalsIgnoreCase("on") || context.argAsString(0).equalsIgnoreCase("start")) {
FactionsPlugin.getInstance().getTimerManager().graceTimer.setPaused(false);
FactionsPlugin.getInstance().getTimerManager().graceTimer.setRemaining(TimeUnit.DAYS.toMillis(Conf.gracePeriodTimeDays), true);
if (Conf.broadcastGraceToggles) {
for (FPlayer follower : FPlayers.getInstance().getOnlinePlayers())
follower.msg(TL.COMMAND_GRACE_ENABLED_FORMAT, String.valueOf(TimerManager.getRemaining(FactionsPlugin.getInstance().getTimerManager().graceTimer.getRemaining(), true)));
}
return;
if (context.args.size() == 1 && context.sender.hasPermission(String.valueOf(Permission.GRACETOGGLE))) {
if (context.argAsString(0).equalsIgnoreCase("on") || context.argAsString(0).equalsIgnoreCase("start")) {
FactionsPlugin.getInstance().getTimerManager().graceTimer.setPaused(false);
FactionsPlugin.getInstance().getTimerManager().graceTimer.setRemaining(TimeUnit.DAYS.toMillis(Conf.gracePeriodTimeDays), true);
if (Conf.broadcastGraceToggles) {
for (FPlayer follower : FPlayers.getInstance().getOnlinePlayers())
follower.msg(TL.COMMAND_GRACE_ENABLED_FORMAT, String.valueOf(TimerManager.getRemaining(FactionsPlugin.getInstance().getTimerManager().graceTimer.getRemaining(), true)));
}
return;
}
if (context.argAsString(0).equalsIgnoreCase("off") || context.argAsString(0).equalsIgnoreCase("stop")) {
FactionsPlugin.getInstance().getTimerManager().graceTimer.setRemaining(TimeUnit.SECONDS.toMillis(0L), true);
FactionsPlugin.getInstance().getTimerManager().graceTimer.setPaused(false);
if (Conf.broadcastGraceToggles) {
for (FPlayer follower : FPlayers.getInstance().getOnlinePlayers())
follower.msg(TL.COMMAND_GRACE_DISABLED_FORMAT);
}
return;
if (context.argAsString(0).equalsIgnoreCase("off") || context.argAsString(0).equalsIgnoreCase("stop")) {
FactionsPlugin.getInstance().getTimerManager().graceTimer.setRemaining(TimeUnit.SECONDS.toMillis(0L), true);
FactionsPlugin.getInstance().getTimerManager().graceTimer.setPaused(false);
if (Conf.broadcastGraceToggles) {
for (FPlayer follower : FPlayers.getInstance().getOnlinePlayers())
follower.msg(TL.COMMAND_GRACE_DISABLED_FORMAT);
}
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());
} else {
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<>();
private Map<UUID, Long> logoutCooldown = new HashMap<>();
private String name;
public LogoutHandler(String name) {
this.name = name;
factionDatas.put(name, this);
}

View File

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

View File

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

View File

@ -60,17 +60,17 @@ public class CmdSetGuild extends FCommand {
if (guild == null) {
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);
} else {
context.msg(TL.SET_GUILD_ID_PMING_OWNER);
User user = guild.getOwner().getUser();
Guild finalGuild = 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 = "";
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));
context.msg(TL.SET_GUILD_ID_SUCCESS);
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();
context.msg(TL.SET_GUILD_ID_TIMED_OUT_MINECRAFT);
});
}, (t) -> {
context.msg(TL.SET_GUILD_ID_UNABLE_TO_MESSAGE_GUILD_OWNER);
}), (t) -> context.msg(TL.SET_GUILD_ID_UNABLE_TO_MESSAGE_GUILD_OWNER));
}, t -> context.msg(TL.SET_GUILD_ID_UNABLE_TO_MESSAGE_GUILD_OWNER)), t -> context.msg(TL.SET_GUILD_ID_UNABLE_TO_MESSAGE_GUILD_OWNER));
}
} else {
faction.setGuildId(null);

View File

@ -31,7 +31,7 @@ public class Discord {
public static Boolean confUseDiscord;
public static String botToken;
public static String mainGuildID;
public static Boolean useDiscord;
public static boolean useDiscord;
public static java.awt.Color roleColor;
public static Guild mainGuild;
public static Role leader;
@ -53,13 +53,11 @@ public class Discord {
* Called to reload variables and if needed start JDA
*/
public static void setupDiscord() {
if (jda == null) {
if (startBot()) {
varSetup();
jda.addEventListener(new FactionChatHandler(plugin));
jda.addEventListener(new DiscordListener(plugin));
return;
}
if (jda == null && startBot()) {
varSetup();
jda.addEventListener(new FactionChatHandler(plugin));
jda.addEventListener(new DiscordListener(plugin));
return;
}
varSetup();
}
@ -84,6 +82,7 @@ public class Discord {
confUseDiscord = Conf.useDiscordSystem;
botToken = Conf.discordBotToken;
if (jda != null && Conf.leaderRoles || Conf.factionDiscordTags) {
assert jda != null;
mainGuild = jda.getGuildById(Conf.mainGuildID);
} else {
mainGuild = null;
@ -151,12 +150,9 @@ public class Discord {
* @param s String target Faction tag
* @return
*/
public static Boolean doesFactionRoleExist(String s) {
StringBuilder sb = new StringBuilder();
sb.append(Conf.factionRolePrefix);
sb.append(s);
sb.append(Conf.factionRoleSuffix);
return getRoleFromName(sb.toString()) != null;
public static boolean doesFactionRoleExist(String s) {
String sb = Conf.factionRolePrefix + s + Conf.factionRoleSuffix;
return getRoleFromName(sb) != null;
}
public static Role getRoleFromName(String s) {
@ -189,7 +185,8 @@ public class Discord {
sb.append(Conf.factionRoleSuffix);
if (!doesFactionRoleExist(sb.toString())) {
try {
Role newRole = mainGuild.getController().createRole()
Role newRole;
newRole = mainGuild.getController().createRole()
.setName(sb.toString())
.setColor(roleColor)
.setPermissions(Permission.EMPTY_PERMISSIONS)
@ -211,11 +208,7 @@ public class Discord {
* @return Name of would be Role
*/
public static String getFactionRoleName(String tag) {
StringBuilder sb = new StringBuilder();
sb.append(Conf.factionRolePrefix);
sb.append(tag);
sb.append(Conf.factionRoleSuffix);
return sb.toString();
return Conf.factionRolePrefix + tag + Conf.factionRoleSuffix;
}
/**
@ -224,7 +217,7 @@ public class Discord {
* @param u User
* @return Boolean
*/
public static Boolean isInMainGuild(User u) {
public static boolean isInMainGuild(User u) {
if (mainGuild == null) return false;
return mainGuild.getMember(u) == null ? Boolean.FALSE : Boolean.TRUE;
}
@ -252,10 +245,12 @@ public class Discord {
if (fp.discordSetup() && isInMainGuild(fp.discordUser())) {
try {
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();
}
if (Conf.factionRoles) {
if (factionRoles) {
mainGuild.getController().removeSingleRoleFromMember(m, Objects.requireNonNull(getRoleFromName(oldTag))).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.plugin = plugin;
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() {
@ -64,6 +64,7 @@ public class DiscordListener extends ListenerAdapter {
}
}
@Override
public void onPrivateMessageReceived(PrivateMessageReceivedEvent e) {
Integer i;
if (e.getAuthor().isBot()) return;
@ -85,6 +86,7 @@ public class DiscordListener extends ListenerAdapter {
}
}
@Override
public void onGuildMessageReceived(GuildMessageReceivedEvent event) {
try {
if (event.getMessage().isWebhookMessage() || event.getAuthor().isBot()) return;

View File

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

View File

@ -35,7 +35,7 @@ public class FactionChatHandler extends ListenerAdapter {
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 messageWithMentions = null;
if (factionsChatChannelId == null || factionsChatChannelId.isEmpty()) return;

View File

@ -49,7 +49,6 @@ public class Econ {
econ = rsp.getProvider();
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");
//FactionsPlugin.getInstance().cmdBase.cmdHelp.updateHelp();
}
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.
if (you instanceof Faction && fI == fYou && (Conf.bankMembersCanWithdraw || (i instanceof FPlayer && ((FPlayer) i).getRole().value >= Role.MODERATOR.value)))
return true;
// Otherwise you may not!;,,;
i.msg(TL.ECON_CANTCONTROLMONEY, i.describeTo(i, true), you.describeTo(i));
return false;
}
@ -237,7 +235,7 @@ public class Econ {
acc = Bukkit.getOfflinePlayer(UUID.fromString(ep.getAccountId()));
if (acc.getName() == null) return false;
} else acc = Bukkit.getOfflinePlayer(ep.getAccountId());
String You = ep.describeTo(ep, true);
String you = ep.describeTo(ep, true);
if (delta == 0) return true;
else if (delta > 0) {
@ -247,12 +245,12 @@ public class Econ {
if (er.transactionSuccess()) {
modifyUniverseMoney(-delta);
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;
} else {
// transfer to account failed
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;
}
} else {
@ -262,12 +260,12 @@ public class Econ {
// There is enough money to pay
modifyUniverseMoney(-delta);
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;
} else {
// There was not enough money to pay
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;
}
}

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("WorldGuard 7.0.0 support is currently in BETA. Please be careful!");
regionContainer = null;
return;
}
}
}

View File

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

View File

@ -15,7 +15,7 @@ public class TempMarkerSet {
public boolean hideByDefault;
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) {
return null;
@ -41,10 +41,8 @@ public class TempMarkerSet {
markerset.setMarkerSetLabel(this.label);
}
if (this.minimumZoom > 0) {
if (markerset.getMinZoom() != this.minimumZoom) {
if (this.minimumZoom > 0 && markerset.getMinZoom() != this.minimumZoom) {
markerset.setMinZoom(this.minimumZoom);
}
}
if (markerset.getLayerPriority() != this.priority) {

View File

@ -47,6 +47,8 @@ public class FactionsBlockListener implements Listener {
public static HashMap<String, Location> bannerLocations = new HashMap<>();
private HashMap<String, Boolean> bannerCooldownMap = new HashMap<>();
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) {
@ -61,9 +63,8 @@ public class FactionsBlockListener implements Listener {
if (otherFaction.isWilderness()) {
if (Conf.worldGuardBuildPriority && Worldguard.getInstance().playerCanBuild(player, location)) return true;
if (location.getWorld() != null) {
if (!Conf.wildernessDenyBuild || Conf.worldsNoWildernessProtection.contains(location.getWorld().getName()))
return true;
if (location.getWorld() != null && !Conf.wildernessDenyBuild || Conf.worldsNoWildernessProtection.contains(location.getWorld().getName())) {
return true;
}
if (!justCheck) me.msg(TL.ACTION_DENIED_WILDERNESS, action);
return false;
@ -93,24 +94,27 @@ public class FactionsBlockListener implements Listener {
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())))
return true;
else if (landOwned && !myFaction.getOwnerListString(loc).contains(player.getName())) {
me.msg(TL.ACTIONS_OWNEDTERRITORYDENY.toString().replace("{owners}", myFaction.getOwnerListString(loc)));
if (shouldHurt) {
player.damage(Conf.actionDeniedPainAmount);
me.msg(TL.ACTIONS_NOPERMISSIONPAIN.toString().replace("{action}", action.toString()).replace("{faction}", Board.getInstance().getFactionAt(loc).getTag(myFaction)));
}
return false;
} else if (!landOwned && access == Access.DENY) { // If land is not owned but access is set to DENY anyway
if (shouldHurt) {
player.damage(Conf.actionDeniedPainAmount);
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)));
}
if (myFaction.getTag(me.getFaction()) != null && action != null)
me.msg(TL.ACTIONS_NOPERMISSION.toString().replace("{faction}", myFaction.getTag(me.getFaction())).replace("{action}", action.toString()));
return false;
} else if (access == Access.ALLOW) return true;
me.msg(TL.ACTIONS_NOPERMISSION.toString().replace("{faction}", myFaction.getTag(me.getFaction())).replace("{action}", action.toString()));
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)));
if (shouldHurt) {
player.damage(Conf.actionDeniedPainAmount);
me.msg(replace.replace(varFac, Board.getInstance().getFactionAt(loc).getTag(myFaction)));
}
return false;
} else if (!landOwned && access == Access.DENY) { // If land is not owned but access is set to DENY anyway
if (shouldHurt) {
player.damage(Conf.actionDeniedPainAmount);
if ((Board.getInstance().getFactionAt(loc).getTag(myFaction)) != null)
me.msg(replace.replace(varFac, Board.getInstance().getFactionAt(loc).getTag(myFaction)));
}
if (myFaction.getTag(me.getFaction()) != null && action != null)
me.msg(TL.ACTIONS_NOPERMISSION.toString().replace(varFac, myFaction.getTag(me.getFaction())).replace(varAction, action.toString()));
return false;
} else if (access == Access.ALLOW) return true;
}
me.msg(TL.ACTIONS_NOPERMISSION.toString().replace(varFac, myFaction.getTag(me.getFaction())).replace(varAction, action.toString()));
return false;
}
@ -118,10 +122,10 @@ public class FactionsBlockListener implements Listener {
if (Conf.ownedAreasEnabled && target.doesLocationHaveOwnersSet(location) && !target.playerHasOwnershipRights(me, location)) {
// If pain should be applied
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;
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;
}
}
@ -168,11 +172,9 @@ public class FactionsBlockListener implements Listener {
return;
}
if (isSpawner) {
if (Conf.spawnerLock) {
event.setCancelled(true);
event.getPlayer().sendMessage(FactionsPlugin.getInstance().color(TL.COMMAND_SPAWNER_LOCK_CANNOT_PLACE.toString()));
}
if (isSpawner && Conf.spawnerLock) {
event.setCancelled(true);
event.getPlayer().sendMessage(FactionsPlugin.getInstance().color(TL.COMMAND_SPAWNER_LOCK_CANNOT_PLACE.toString()));
}
}
@ -180,23 +182,21 @@ public class FactionsBlockListener implements Listener {
public void onBlockFromTo(BlockFromToEvent event) {
if (!Conf.handleExploitLiquidFlow) return;
if (event.getBlock().isLiquid()) {
if (event.getToBlock().isEmpty()) {
Faction from = Board.getInstance().getFactionAt(new FLocation(event.getBlock()));
Faction to = Board.getInstance().getFactionAt(new FLocation(event.getToBlock()));
if (from == to) return;
// from faction != to faction
if(to.isSystemFaction()) {
event.setCancelled(true);
if (event.getBlock().isLiquid() && event.getToBlock().isEmpty()) {
Faction from = Board.getInstance().getFactionAt(new FLocation(event.getBlock()));
Faction to = Board.getInstance().getFactionAt(new FLocation(event.getToBlock()));
if (from == to) return;
// from faction != to faction
if (to.isSystemFaction()) {
event.setCancelled(true);
return;
}
if (to.isNormal()) {
if (from.isNormal() && from.getRelationTo(to).isAlly()) {
return;
}
if (to.isNormal()) {
if (from.isNormal() && from.getRelationTo(to).isAlly()) {
return;
}
event.setCancelled(true);
}
event.setCancelled(true);
}
}
}
@ -217,7 +217,7 @@ public class FactionsBlockListener implements Listener {
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 ((targetBlock.isEmpty() || targetBlock.isLiquid()) && !canPistonMoveBlock(pistonFaction, targetBlock.getLocation()))
if ((targetBlock.isEmpty() || targetBlock.isLiquid()) && canPistonMoveBlock(pistonFaction, targetBlock.getLocation()))
event.setCancelled(true);
}
@ -286,12 +286,10 @@ public class FactionsBlockListener implements Listener {
continue;
}
if (blockLoc.getBlock().getType() == XMaterial.CHEST.parseMaterial()) {
if (factionAt.getVault().equals(blockLoc)) {
e.setCancelled(true);
fme.msg(TL.COMMAND_VAULT_NO_HOPPER);
return;
}
if (blockLoc.getBlock().getType() == XMaterial.CHEST.parseMaterial() && factionAt.getVault().equals(blockLoc)) {
e.setCancelled(true);
fme.msg(TL.COMMAND_VAULT_NO_HOPPER);
return;
}
}
}
@ -316,7 +314,7 @@ public class FactionsBlockListener implements Listener {
// if potentially retracted block is just air/water/lava, no worries
if (targetLoc.getBlock().isEmpty() || targetLoc.getBlock().isLiquid()) return;
Faction pistonFaction = Board.getInstance().getFactionAt(new FLocation(event.getBlock()));
if (!canPistonMoveBlock(pistonFaction, targetLoc)) event.setCancelled(true);
if (canPistonMoveBlock(pistonFaction, targetLoc)) event.setCancelled(true);
}
@EventHandler
@ -326,11 +324,9 @@ public class FactionsBlockListener implements Listener {
return;
}
if (bannerLocations.containsValue(e.getBlock().getLocation())) {
if (e.getBlock().getType().name().contains("BANNER")) {
e.setCancelled(true);
fme.msg(TL.BANNER_CANNOT_BREAK);
}
if (bannerLocations.containsValue(e.getBlock().getLocation()) && e.getBlock().getType().name().contains("BANNER")) {
e.setCancelled(true);
fme.msg(TL.BANNER_CANNOT_BREAK);
}
}
@ -430,7 +426,8 @@ public class FactionsBlockListener implements Listener {
if (!justCheck) fPlayer.setLastFrostwalkerMessage();
// 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
@ -448,15 +445,15 @@ public class FactionsBlockListener implements Listener {
private boolean canPistonMoveBlock(Faction pistonFaction, Location target) {
Faction otherFaction = Board.getInstance().getFactionAt(new FLocation(target));
if (pistonFaction == otherFaction) return true;
if (pistonFaction == otherFaction) return false;
if (otherFaction.isWilderness())
return !Conf.wildernessDenyBuild || Conf.worldsNoWildernessProtection.contains(target.getWorld().getName());
else if (otherFaction.isSafeZone()) return !Conf.safeZoneDenyBuild;
else if (otherFaction.isWarZone()) return !Conf.warZoneDenyBuild;
return Conf.wildernessDenyBuild && !Conf.worldsNoWildernessProtection.contains(target.getWorld().getName());
else if (otherFaction.isSafeZone()) return Conf.safeZoneDenyBuild;
else if (otherFaction.isWarZone()) return Conf.warZoneDenyBuild;
Relation rel = pistonFaction.getRelationTo(otherFaction);
return !rel.confDenyBuild(otherFaction.hasPlayersOnline());
return rel.confDenyBuild(otherFaction.hasPlayersOnline());
}
@EventHandler(priority = EventPriority.NORMAL, ignoreCancelled = true)
@ -504,15 +501,12 @@ public class FactionsBlockListener implements Listener {
@EventHandler(priority = EventPriority.HIGHEST)
public void FrameRemove(HangingBreakByEntityEvent event) {
public void frameRemove(HangingBreakByEntityEvent event) {
if (event.getRemover() == null) return;
if ((event.getRemover() instanceof Player)) {
if (event.getEntity().getType().equals(EntityType.ITEM_FRAME)) {
Player p = (Player) event.getRemover();
if (!playerCanBuildDestroyBlock(p, event.getEntity().getLocation(), "destroy", true)) {
event.setCancelled(true);
return;
}
if ((event.getRemover() instanceof Player) && event.getEntity().getType().equals(EntityType.ITEM_FRAME)) {
Player p = (Player) event.getRemover();
if (!playerCanBuildDestroyBlock(p, event.getEntity().getLocation(), "destroy", true)) {
event.setCancelled(true);
}
}
}

View File

@ -87,7 +87,7 @@ public class FactionsChatListener implements Listener {
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);
} else if (chat == ChatMode.ALLIANCE) {
Faction myFaction = me.getFaction();

View File

@ -4,7 +4,6 @@ import com.massivecraft.factions.*;
import com.massivecraft.factions.event.PowerLossEvent;
import com.massivecraft.factions.struct.Relation;
import com.massivecraft.factions.util.MiscUtil;
import com.massivecraft.factions.util.timer.type.GraceTimer;
import com.massivecraft.factions.zcore.util.TL;
import org.bukkit.Bukkit;
import org.bukkit.Location;
@ -144,7 +143,7 @@ public class FactionsEntityListener implements Listener {
} else {
// 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
if (!this.checkExplosionForBlock(damager, damagee.getLocation().getBlock()))
if (this.checkExplosionForBlock(damager, damagee.getLocation().getBlock()))
event.setCancelled(true);
}
// we don't need to go after
@ -217,7 +216,7 @@ public class FactionsEntityListener implements Listener {
Entity boomer = event.getEntity();
// 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);
return;
}
@ -225,7 +224,7 @@ public class FactionsEntityListener implements Listener {
// Loop the blocklist to run checks on each aimed block
// 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
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()));
if (faction.noExplosionsInTerritory() || (faction.isPeaceful() && Conf.peacefulTerritoryDisableBoom))
return false;
return true;
// faction is peaceful and has explosions set to disabled
boolean online = faction.hasPlayersOnline();
@ -270,17 +269,17 @@ public class FactionsEntityListener implements Listener {
(faction.isWarZone() && Conf.warZoneBlockCreepers) ||
faction.isSafeZone())) {
// creeper which needs prevention
return false;
return true;
} 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
(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
return false;
return true;
} else
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.isWarZone() || !Conf.warZoneBlockTNT) &&
(!faction.isSafeZone() || !Conf.safeZoneBlockTNT));
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.isWarZone() && Conf.warZoneBlockTNT) ||
(faction.isSafeZone() && Conf.safeZoneBlockTNT));
// No condition retained, destroy the block!
}
@ -312,7 +311,7 @@ public class FactionsEntityListener implements Listener {
if (thrower instanceof Player) {
Player player = (Player) thrower;
FPlayer fPlayer = FPlayers.getInstance().getByPlayer(player);
if (badjuju && fPlayer.getFaction().isPeaceful()) {
if (fPlayer.getFaction().isPeaceful()) {
event.setCancelled(true);
return;
}
@ -507,10 +506,8 @@ public class FactionsEntityListener implements Listener {
if (!(e.getRemover() instanceof Player)) return;
Player p = (Player) e.getRemover();
if (e.getEntity().getType() == EntityType.PAINTING || e.getEntity().getType() == EntityType.ITEM_FRAME) {
if (!FactionsBlockListener.playerCanBuildDestroyBlock(p, e.getEntity().getLocation(), "destroy", false)) {
e.setCancelled(true);
}
if (e.getEntity().getType() == EntityType.PAINTING || e.getEntity().getType() == EntityType.ITEM_FRAME && !FactionsBlockListener.playerCanBuildDestroyBlock(p, e.getEntity().getLocation(), "destroy", false)) {
e.setCancelled(true);
}
}
@ -518,11 +515,9 @@ public class FactionsEntityListener implements Listener {
public void onPaintingPlace(HangingPlaceEvent e) {
if (e.getPlayer() == null) return;
if (e.getEntity().getType() == EntityType.PAINTING || e.getEntity().getType() == EntityType.ITEM_FRAME) {
if (!FactionsBlockListener.playerCanBuildDestroyBlock(e.getPlayer(), e.getBlock().getLocation(), "build", false)) {
e.setCancelled(true);
e.getPlayer().updateInventory();
}
if (e.getEntity().getType() == EntityType.PAINTING || e.getEntity().getType() == EntityType.ITEM_FRAME && !FactionsBlockListener.playerCanBuildDestroyBlock(e.getPlayer(), e.getBlock().getLocation(), "build", false)) {
e.setCancelled(true);
e.getPlayer().updateInventory();
}
}
@ -547,73 +542,37 @@ 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
public void onHit(EntityDamageByEntityEvent e) {
if (e.getDamager() instanceof Player) {
if (e.getEntity() instanceof Player) {
Player victim = (Player) e.getEntity();
Player attacker = (Player) e.getDamager();
FPlayer fvictim = FPlayers.getInstance().getByPlayer(victim);
FPlayer fattacker = FPlayers.getInstance().getByPlayer(attacker);
if (fattacker.getRelationTo(fvictim) == Relation.TRUCE) {
fattacker.msg(TL.PLAYER_PVP_CANTHURT, fvictim.describeTo(fattacker));
e.setCancelled(true);
}
if (e.getDamager() instanceof Player && e.getEntity() instanceof Player) {
Player victim = (Player) e.getEntity();
Player attacker = (Player) e.getDamager();
FPlayer fvictim = FPlayers.getInstance().getByPlayer(victim);
FPlayer fattacker = FPlayers.getInstance().getByPlayer(attacker);
if (fattacker.getRelationTo(fvictim) == Relation.TRUCE) {
fattacker.msg(TL.PLAYER_PVP_CANTHURT, fvictim.describeTo(fattacker));
e.setCancelled(true);
}
}
}
@EventHandler
public void onBowHit(EntityDamageByEntityEvent e) {
if (e.getDamager() instanceof Projectile) {
if (e.getEntity() instanceof Player) {
Projectile arrow = ((Projectile) e.getDamager());
if (arrow.getShooter() instanceof Player) {
Player damager = (Player) ((Projectile) e.getDamager()).getShooter();
Player victim = (Player) e.getEntity();
FPlayer fdamager = FPlayers.getInstance().getByPlayer(damager);
FPlayer fvictim = FPlayers.getInstance().getByPlayer(victim);
if (damager == victim) return;
if (fdamager == fvictim) return;
if (fvictim.getRelationTo(fdamager) == Relation.TRUCE) {
fdamager.msg(TL.PLAYER_PVP_CANTHURT, fvictim.describeTo(fdamager));
e.setCancelled(true);
}
if (fvictim.getRelationTo(fdamager) == Relation.ENEMY) {
if (fvictim.isFlying()) {
fvictim.setFFlying(false, true);
}
}
if (e.getDamager() instanceof Projectile && e.getEntity() instanceof Player) {
Projectile arrow = ((Projectile) e.getDamager());
if (arrow.getShooter() instanceof Player) {
Player damager = (Player) ((Projectile) e.getDamager()).getShooter();
Player victim = (Player) e.getEntity();
FPlayer fdamager = FPlayers.getInstance().getByPlayer(damager);
FPlayer fvictim = FPlayers.getInstance().getByPlayer(victim);
if (damager == victim) return;
if (fdamager == fvictim) return;
if (fvictim.getRelationTo(fdamager) == Relation.TRUCE) {
fdamager.msg(TL.PLAYER_PVP_CANTHURT, fvictim.describeTo(fdamager));
e.setCancelled(true);
}
if (fvictim.getRelationTo(fdamager) == Relation.ENEMY && fvictim.isFlying()) {
fvictim.setFFlying(false, true);
}
}
}

View File

@ -4,7 +4,6 @@ import com.massivecraft.factions.*;
import com.massivecraft.factions.cmd.CmdFGlobal;
import com.massivecraft.factions.cmd.CmdFly;
import com.massivecraft.factions.cmd.CmdSeeChunk;
import com.massivecraft.factions.cmd.FCmdRoot;
import com.massivecraft.factions.cmd.audit.FLogType;
import com.massivecraft.factions.cmd.logout.LogoutHandler;
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 org.bukkit.*;
import org.bukkit.block.Block;
import org.bukkit.entity.Boat;
import org.bukkit.entity.Minecart;
import org.bukkit.entity.Player;
import org.bukkit.event.Event;
import org.bukkit.event.EventHandler;
@ -191,7 +188,6 @@ public class FactionsPlayerListener implements Listener {
FLocation loc = new FLocation(block);
Faction otherFaction = Board.getInstance().getFactionAt(loc);
Faction myFaction = me.getFaction();
Relation rel = myFaction.getRelationTo(otherFaction);
// no door/chest/whatever protection in wilderness, war zones, or safe zones
if (otherFaction.isSystemFaction()) return true;
@ -522,13 +518,11 @@ public class FactionsPlayerListener implements Listener {
@EventHandler
public void onPlayerFall(EntityDamageEvent e) {
if (e.getEntity() instanceof Player) {
if (e.getCause() == EntityDamageEvent.DamageCause.FALL) {
Player player = (Player) e.getEntity();
if (fallMap.containsKey(player)) {
e.setCancelled(true);
fallMap.remove(player);
}
if (e.getEntity() instanceof Player && e.getCause() == EntityDamageEvent.DamageCause.FALL) {
Player player = (Player) e.getEntity();
if (fallMap.containsKey(player)) {
e.setCancelled(true);
fallMap.remove(player);
}
}
}
@ -616,7 +610,7 @@ public class FactionsPlayerListener implements Listener {
fplayer.msg(TL.COMMAND_INSPECT_BYPASS);
}
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());
return;
}
@ -656,7 +650,7 @@ public class FactionsPlayerListener implements Listener {
}
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() {
positionTask = Bukkit.getScheduler().runTaskTimer(FactionsPlugin.getInstance(), () -> {
@ -830,18 +824,14 @@ 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.
// 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 (type != null && !Conf.territoryDenySwitchMaterials.contains(block.getType())) {
if (Conf.territoryCancelAndAllowItemUseMaterial.contains(type)) {
return;
}
if (type != null && !Conf.territoryDenySwitchMaterials.contains(block.getType()) && Conf.territoryCancelAndAllowItemUseMaterial.contains(type)) {
return;
}
if (GetPermissionFromUsableBlock(block.getType()) != null) {
if (!canPlayerUseBlock(player, block, false)) {
event.setCancelled(true);
event.setUseInteractedBlock(Event.Result.DENY);
return;
}
if (GetPermissionFromUsableBlock(block.getType()) != null && !canPlayerUseBlock(player, block, false)) {
event.setCancelled(true);
event.setUseInteractedBlock(Event.Result.DENY);
return;
}
if (type != null && !playerCanUseItemHere(player, block.getLocation(), event.getItem().getType(), false, PermissableAction.ITEM)) {
@ -862,14 +852,13 @@ public class FactionsPlayerListener implements Listener {
public void onPlayerBoneMeal(PlayerInteractEvent event) {
Block block = event.getClickedBlock();
if (event.getAction() == Action.RIGHT_CLICK_BLOCK && block.getType() == XMaterial.GRASS_BLOCK.parseMaterial()
&& event.hasItem() && event.getItem().getType() == XMaterial.BONE_MEAL.parseMaterial()) {
if (!FactionsBlockListener.playerCanBuildDestroyBlock(event.getPlayer(), block.getLocation(), PermissableAction.BUILD.name(), true)) {
FPlayer me = FPlayers.getInstance().getById(event.getPlayer().getUniqueId().toString());
Faction myFaction = me.getFaction();
&& event.hasItem() && event.getItem().getType() == XMaterial.BONE_MEAL.parseMaterial()
&& !FactionsBlockListener.playerCanBuildDestroyBlock(event.getPlayer(), block.getLocation(), PermissableAction.BUILD.name(), true)) {
FPlayer me = FPlayers.getInstance().getById(event.getPlayer().getUniqueId().toString());
Faction myFaction = me.getFaction();
me.msg(TL.ACTIONS_NOPERMISSION.toString().replace("{faction}", myFaction.getTag(me.getFaction())).replace("{action}", "use bone meal"));
event.setCancelled(true);
}
me.msg(TL.ACTIONS_NOPERMISSION.toString().replace("{faction}", myFaction.getTag(me.getFaction())).replace("{action}", "use bone meal"));
event.setCancelled(true);
}
}
@ -937,10 +926,8 @@ public class FactionsPlayerListener implements Listener {
player.sendMessage(String.valueOf(TL.COMMAND_LOGOUT_DAMAGE_TAKEN));
}
WaitExecutor.handleAction(player);
if (CmdWild.teleporting.contains(player)) {
if (!FactionsPlugin.getInstance().getConfig().getBoolean("Wild.FallDamage") && e.getCause() == EntityDamageEvent.DamageCause.FALL) {
e.setCancelled(true);
}
if (CmdWild.teleporting.contains(player) && !FactionsPlugin.getInstance().getConfig().getBoolean("Wild.FallDamage") && e.getCause() == EntityDamageEvent.DamageCause.FALL) {
e.setCancelled(true);
}
}
}
@ -949,7 +936,6 @@ public class FactionsPlayerListener implements Listener {
public void onTeleport(PlayerTeleportEvent e) {
Player player = e.getPlayer();
if (player == null) return;
LogoutHandler handler = LogoutHandler.getByName(player.getName());
if (handler.isLogoutActive(player)) {
handler.cancelLogout(player);
@ -987,7 +973,7 @@ public class FactionsPlayerListener implements Listener {
}
@EventHandler(priority = EventPriority.MONITOR, ignoreCancelled = true)
final public void onFactionJoin(FPlayerJoinEvent event) {
final void onFactionJoin(FPlayerJoinEvent event) {
FTeamWrapper.applyUpdatesLater(event.getFaction());
}
@ -1001,7 +987,7 @@ public class FactionsPlayerListener implements Listener {
}
@EventHandler
public void AsyncPlayerChatEvent(AsyncPlayerChatEvent e) {
public void asyncPlayerChatEvent(AsyncPlayerChatEvent e) {
Player p = e.getPlayer();
if (CmdFGlobal.toggled.contains(p.getUniqueId())) {
@ -1027,10 +1013,8 @@ public class FactionsPlayerListener implements Listener {
for (int i = l.size() - 1; i >= 0; i--) { // going backwards in the list to prevent a ConcurrentModificationException
Player recipient = l.get(i);
if (recipient != null) {
if (CmdFGlobal.toggled.contains(recipient.getUniqueId())) {
e.getRecipients().remove(recipient);
}
if (recipient != null && CmdFGlobal.toggled.contains(recipient.getUniqueId())) {
e.getRecipients().remove(recipient);
}
}
}

View File

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

View File

@ -137,7 +137,7 @@ public class FScoreboard {
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() {

View File

@ -25,6 +25,8 @@ public class FTeamWrapper {
private final String teamName;
private final Faction faction;
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) {
this.teamName = "faction_" + (factionTeamPtr++);
@ -44,7 +46,7 @@ public class FTeamWrapper {
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;
}
@ -66,7 +68,7 @@ public class FTeamWrapper {
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;
}
@ -158,7 +160,7 @@ public class FTeamWrapper {
}
private void updatePrefixes() {
if (FactionsPlugin.getInstance().getConfig().getBoolean("scoreboard.default-prefixes", false)) {
if (FactionsPlugin.getInstance().getConfig().getBoolean(defaultPrefixes, false)) {
for (FScoreboard fboard : teams.keySet()) {
updatePrefix(fboard);
}
@ -166,19 +168,19 @@ public class FTeamWrapper {
}
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();
Team team = teams.get(fboard);
boolean focused = false;
if (FactionsPlugin.getInstance().getConfig().getBoolean("See-Invisible-Faction-Members", false)) {
if (FactionsPlugin.getInstance().getConfig().getBoolean(invisFactionMembers, false)) {
team.setCanSeeFriendlyInvisibles(true);
}
if ((FactionsPlugin.getInstance().getConfig().getBoolean("ffocus.Enabled")) && (fplayer.getFaction() != null) && (fplayer.getFaction().getFocused() != null)) {
for (FPlayer fp : faction.getFPlayersWhereOnline(true)) {
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;
}
}
@ -191,7 +193,8 @@ public class FTeamWrapper {
prefix = prefix.replace("{relationcolor}", faction.getRelationTo(fplayer).getColor().toString());
prefix = prefix.replace("{faction}",
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);
}
}

View File

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

View File

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

View File

@ -17,27 +17,27 @@ public enum FactionTag implements Tag {
* @author FactionsUUID Team
*/
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_Z("{z}", (fac) -> fac.hasHome() ? String.valueOf(fac.getHome().getBlockZ()) : Tag.isMinimalShow() ? null : "{ig}"),
CHUNKS("{chunks}", (fac) -> String.valueOf(fac.getLandRounded())),
WARPS("{warps}", (fac) -> String.valueOf(fac.getWarps().size())),
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_Z("{z}", fac -> fac.hasHome() ? String.valueOf(fac.getHome().getBlockZ()) : Tag.isMinimalShow() ? null : "{ig}"),
CHUNKS("{chunks}", fac -> String.valueOf(fac.getLandRounded())),
WARPS("{warps}", fac -> String.valueOf(fac.getWarps().size())),
HEADER("{header}", (fac, fp) -> FactionsPlugin.getInstance().txt.titleize(fac.getTag(fp))),
POWER("{power}", (fac) -> String.valueOf(fac.getPowerRounded())),
MAX_POWER("{maxPower}", (fac) -> String.valueOf(fac.getPowerMaxRounded())),
POWER_BOOST("{power-boost}", (fac) -> {
POWER("{power}", fac -> String.valueOf(fac.getPowerRounded())),
MAX_POWER("{maxPower}", fac -> String.valueOf(fac.getPowerMaxRounded())),
POWER_BOOST("{power-boost}", fac -> {
double powerBoost = fac.getPowerBoost();
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();
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_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}"),
RAIDABLE("{raidable}", (fac) -> {
HOME_WORLD("{world}", fac -> fac.hasHome() ? fac.getHome().getWorld().getName() : Tag.isMinimalShow() ? null : "{ig}"),
RAIDABLE("{raidable}", fac -> {
if (FactionsPlugin.getInstance().getConfig().getBoolean("hcf.raidable", false)) {
boolean raidable = fac.getLandRounded() >= fac.getPowerRounded();
String str = raidable ? TL.RAIDABLE_TRUE.toString() : TL.RAIDABLE_FALSE.toString();
@ -50,37 +50,35 @@ public enum FactionTag implements Tag {
return null;
}),
ANNOUNCEMENT("{announcement}", (fac) -> {
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
LAND_VALUE("{land-value}", (fac) -> Econ.shouldBeUsed() ? Econ.moneyString(Econ.calculateTotalLandValue(fac.getLandRounded())) : Tag.isMinimalShow() ? null : TL.ECON_OFF.format("value")),
ANNOUNCEMENT("{announcement}", fac -> 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
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),
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")),
BANK_BALANCE("{faction-balance}", (fac) -> {
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")),
BANK_BALANCE("{faction-balance}", fac -> {
if (Econ.shouldBeUsed()) {
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");
}),
TNT_BALANCE("{tnt-balance}", (fac) -> {
TNT_BALANCE("{tnt-balance}", fac -> {
if (FactionsPlugin.instance.getConfig().getBoolean("ftnt.Enabled")) {
return String.valueOf(fac.getTnt());
}
return Tag.isMinimalShow() ? null : "";
}),
TNT_MAX("{tnt-max-balance}", (fac) -> {
TNT_MAX("{tnt-max-balance}", fac -> {
if (FactionsPlugin.instance.getConfig().getBoolean("ftnt.Enabled")) {
return String.valueOf(fac.getTntBankLimit());
}
return Tag.isMinimalShow() ? null : "";
}),
ALLIES_COUNT("{allies}", (fac) -> String.valueOf(fac.getRelationCount(Relation.ALLY))),
ENEMIES_COUNT("{enemies}", (fac) -> String.valueOf(fac.getRelationCount(Relation.ENEMY))),
TRUCES_COUNT("{truces}", (fac) -> String.valueOf(fac.getRelationCount(Relation.TRUCE))),
ALLIES_COUNT("{allies}", fac -> String.valueOf(fac.getRelationCount(Relation.ALLY))),
ENEMIES_COUNT("{enemies}", fac -> String.valueOf(fac.getRelationCount(Relation.ENEMY))),
TRUCES_COUNT("{truces}", fac -> String.valueOf(fac.getRelationCount(Relation.TRUCE))),
ONLINE_COUNT("{online}", (fac, fp) -> {
if (fp != null && fp.isOnline()) {
return String.valueOf(fac.getFPlayersWhereOnline(true, fp).size());
@ -97,12 +95,12 @@ public enum FactionTag implements Tag {
return String.valueOf(fac.getFPlayersWhereOnline(false).size());
}
}),
FACTION_STRIKES("{faction-strikes}", (fac) -> String.valueOf(fac.getStrikes())),
FACTION_POINTS("{faction-points}", (fac) -> String.valueOf(fac.getPoints())),
FACTION_SIZE("{members}", (fac) -> String.valueOf(fac.getFPlayers().size())),
FACTION_KILLS("{faction-kills}", (fac) -> String.valueOf(fac.getKills())),
FACTION_DEATHS("{faction-deaths}", (fac) -> String.valueOf(fac.getDeaths())),
FACTION_BANCOUNT("{faction-bancount}", (fac) -> String.valueOf(fac.getBannedPlayers().size())),
FACTION_STRIKES("{faction-strikes}", fac -> String.valueOf(fac.getStrikes())),
FACTION_POINTS("{faction-points}", fac -> String.valueOf(fac.getPoints())),
FACTION_SIZE("{members}", fac -> String.valueOf(fac.getFPlayers().size())),
FACTION_KILLS("{faction-kills}", fac -> String.valueOf(fac.getKills())),
FACTION_DEATHS("{faction-deaths}", fac -> String.valueOf(fac.getDeaths())),
FACTION_BANCOUNT("{faction-bancount}", fac -> String.valueOf(fac.getBannedPlayers().size())),
;
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) {
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);
}

View File

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

View File

@ -19,7 +19,7 @@ public class Cooldown {
}
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();
return (time > System.currentTimeMillis());
}

View File

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

View File

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

View File

@ -20,8 +20,6 @@ public class RelationUtil {
}
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 (me instanceof FPlayer && myFaction == thatFaction) {
ret = TL.GENERIC_YOURFACTION.toString();

View File

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

View File

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

View File

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