Compare commits

..

19 Commits

Author SHA1 Message Date
Driftay
4496d4251b Finished Grace Timer :) 2020-04-07 23:22:53 -04:00
Driftay
d86d8fc73a Merge remote-tracking branch 'origin/1.6.x' into 1.6.x 2020-04-07 22:24:55 -04:00
Driftay
380caf1ca3 More things to GraceTimer 2020-04-07 22:24:07 -04:00
DroppingAnvil
103c69fecf Changed every fly check to the same one instead of having multiple, FactionsPlayerListener.checkCanFly will be removed soon. 2020-04-07 16:02:18 -05:00
Driftay
d4ac0ab310 Completely Reformatted GracePeriod with a timer now 2020-04-07 07:59:18 -04:00
Driftay
8fb697888f Added Neutral List PlaceHolder 2020-04-06 16:55:22 -04:00
Driftay
b15ff69682 Finalized F Cooldowns 2020-04-06 16:50:12 -04:00
Driftay
919a3ada25 Revert cooldown is player is bypassing 2020-04-06 16:21:22 -04:00
Driftay
62e4114466 Cooldowns initiated & Disable Open Broadcasts 2020-04-06 16:19:41 -04:00
Driftay
cb2afb5a4f Anotha one 2020-04-06 15:34:26 -04:00
Driftay
8efe68111b Class Cast Exception Fixed 2020-04-06 15:28:49 -04:00
Driftay
388f83694d Per Player Friend Fire Added (Command Usage: /f friendlyfire) 2020-04-06 15:10:37 -04:00
Driftay
23320db201 Create As Many Levels to Upgrades As You Would Like Now, Properly Relocating InventoryFramework 2020-04-06 11:26:48 -04:00
Driftay
0c5cc3a978 ItemFrame Fix, Claiming with No Power Double Check, Scoreboard Duplicate Double Check modified BlockListener 2020-04-06 10:32:16 -04:00
Driftay
8d1b26e561 Small Fix in Conf 2020-04-05 16:13:02 -04:00
Driftay
ef90cd5be8 Metrics & bStats 2020-04-05 12:57:28 -04:00
DroppingAnvil
5809387df2 Small change to fly 2020-04-04 18:42:38 -05:00
DroppingAnvil
5cf21d479e Fly improved 2020-04-04 18:41:13 -05:00
Driftay
44cac68a15 Alt Fix Join Limit 2020-04-04 09:31:45 -04:00
58 changed files with 950 additions and 571 deletions

20
pom.xml
View File

@@ -4,7 +4,7 @@
<groupId>com.massivecraft</groupId> <groupId>com.massivecraft</groupId>
<artifactId>Factions</artifactId> <artifactId>Factions</artifactId>
<version>1.6.9.5-2.3.2-RC</version> <version>1.6.9.5-2.3.3-RC</version>
<packaging>jar</packaging> <packaging>jar</packaging>
<name>SaberFactions</name> <name>SaberFactions</name>
@@ -41,6 +41,14 @@
<configuration> <configuration>
<createDependencyReducedPom>false</createDependencyReducedPom> <createDependencyReducedPom>false</createDependencyReducedPom>
<relocations> <relocations>
<relocation>
<pattern>com.github.stefvanschie.inventoryframework</pattern>
<shadedPattern>com.massivecraft.factions.shade.stefvanschie.inventoryframework</shadedPattern>
</relocation>
<relocation>
<pattern>org.bstats</pattern>
<shadedPattern>com.massivecraft.factions.shade.org.bstats</shadedPattern>
</relocation>
<relocation> <relocation>
<pattern>net.dv8tion</pattern> <pattern>net.dv8tion</pattern>
<shadedPattern>com.massivecraft.factions.shade.net.dv8tion</shadedPattern> <shadedPattern>com.massivecraft.factions.shade.net.dv8tion</shadedPattern>
@@ -403,9 +411,19 @@
<version>2.1</version> <version>2.1</version>
<scope>compile</scope> <scope>compile</scope>
</dependency> </dependency>
<dependency>
<groupId>org.bstats</groupId>
<artifactId>bstats-bukkit</artifactId>
<version>1.7</version>
<scope>compile</scope>
</dependency>
</dependencies> </dependencies>
<repositories> <repositories>
<repository>
<id>CodeMC</id>
<url>https://repo.codemc.org/repository/maven-public</url>
</repository>
<repository> <repository>
<id>central</id> <id>central</id>
<name>bintray</name> <name>bintray</name>

View File

@@ -22,6 +22,7 @@ public class Conf {
public static final transient String DYNMAP_STYLE_HOME_MARKER = "greenflag"; public static final transient String DYNMAP_STYLE_HOME_MARKER = "greenflag";
public static final transient boolean DYNMAP_STYLE_BOOST = false; public static final transient boolean DYNMAP_STYLE_BOOST = false;
public static List<String> baseCommandAliases = new ArrayList<>(); public static List<String> baseCommandAliases = new ArrayList<>();
public static String serverTimeZone = "EST";
public static boolean allowNoSlashCommand = true; public static boolean allowNoSlashCommand = true;
// Colors // Colors
@@ -54,8 +55,8 @@ public class Conf {
public static boolean factionTagForceUpperCase = false; public static boolean factionTagForceUpperCase = false;
public static boolean newFactionsDefaultOpen = false; public static boolean newFactionsDefaultOpen = false;
// when faction membership hits this limit, players will no longer be able to join using /f join; default is 0, no limit // when faction membership hits this limit, players will no longer be able to join using /f join; default is 0, no limit
public static int factionMemberLimit = 0; public static int factionMemberLimit = 30;
public static int factionAltMemberLimit = 0; public static int factionAltMemberLimit = 10;
// what faction ID to start new players in when they first join the server; default is 0, "no faction" // what faction ID to start new players in when they first join the server; default is 0, "no faction"
public static String newPlayerStartingFactionID = "0"; public static String newPlayerStartingFactionID = "0";
public static boolean showMapFactionKey = true; public static boolean showMapFactionKey = true;
@@ -86,7 +87,9 @@ public class Conf {
public static int factionBufferSize = 20; public static int factionBufferSize = 20;
public static boolean useCheckSystem = true; public static boolean useCheckSystem = true;
public static boolean spawnerLock = false; public static boolean spawnerLock = false;
public static boolean gracePeriod = false; public static boolean useGraceSystem = true;
public static boolean broadcastGraceToggles = true;
public static int gracePeriodTimeDays = 7;
public static boolean noEnderpearlsInFly = false; public static boolean noEnderpearlsInFly = false;
public static boolean broadcastDescriptionChanges = false; public static boolean broadcastDescriptionChanges = false;
public static boolean broadcastTagChanges = false; public static boolean broadcastTagChanges = false;
@@ -99,6 +102,8 @@ public class Conf {
public static boolean worldGuardChecking = false; public static boolean worldGuardChecking = false;
public static boolean worldGuardBuildPriority = false; public static boolean worldGuardBuildPriority = false;
//FRIENDLY FIRE
public static boolean friendlyFireFPlayersCommand = false;
//Claim Fill //Claim Fill
public static int maxFillClaimCount = 25; public static int maxFillClaimCount = 25;
@@ -282,7 +287,7 @@ public class Conf {
public static boolean econEnabled = false; public static boolean econEnabled = false;
public static String econUniverseAccount = ""; public static String econUniverseAccount = "";
public static double econCostClaimWilderness = 30.0; public static double econCostClaimWilderness = 30.0;
public static double econCostClaimFromFactionBonus = 30.0; public static double econCostClaimFromFactionBonus = 0.0;
public static double econOverclaimRewardMultiplier = 0.0; public static double econOverclaimRewardMultiplier = 0.0;
public static double econClaimAdditionalMultiplier = 0.5; public static double econClaimAdditionalMultiplier = 0.5;
public static double econClaimRefundMultiplier = 0.7; public static double econClaimRefundMultiplier = 0.7;

View File

@@ -288,6 +288,11 @@ public interface FPlayer extends EconomyParticipator {
boolean hasMoney(int amt); boolean hasMoney(int amt);
//Fplayer specific friendly fire.
boolean hasFriendlyFire();
void setFriendlyFire(boolean status);
//inspect Stuff //inspect Stuff
boolean isInspectMode(); boolean isInspectMode();
@@ -387,6 +392,7 @@ public interface FPlayer extends EconomyParticipator {
// Actions // Actions
// ------------------------------- // -------------------------------
void leave(boolean makePay); void leave(boolean makePay);
boolean canClaimForFaction(Faction forFaction); boolean canClaimForFaction(Faction forFaction);

View File

@@ -26,6 +26,7 @@ import com.massivecraft.factions.struct.Relation;
import com.massivecraft.factions.struct.Role; import com.massivecraft.factions.struct.Role;
import com.massivecraft.factions.util.*; import com.massivecraft.factions.util.*;
import com.massivecraft.factions.util.adapters.*; import com.massivecraft.factions.util.adapters.*;
import com.massivecraft.factions.util.timer.TimerManager;
import com.massivecraft.factions.util.wait.WaitExecutor; import com.massivecraft.factions.util.wait.WaitExecutor;
import com.massivecraft.factions.zcore.CommandVisibility; import com.massivecraft.factions.zcore.CommandVisibility;
import com.massivecraft.factions.zcore.MPlugin; import com.massivecraft.factions.zcore.MPlugin;
@@ -34,10 +35,10 @@ import com.massivecraft.factions.zcore.fperms.Access;
import com.massivecraft.factions.zcore.fperms.Permissable; import com.massivecraft.factions.zcore.fperms.Permissable;
import com.massivecraft.factions.zcore.fperms.PermissableAction; import com.massivecraft.factions.zcore.fperms.PermissableAction;
import com.massivecraft.factions.zcore.frame.fupgrades.UpgradesListener; import com.massivecraft.factions.zcore.frame.fupgrades.UpgradesListener;
import com.massivecraft.factions.zcore.util.TextUtil;
import me.lucko.commodore.CommodoreProvider; import me.lucko.commodore.CommodoreProvider;
import net.milkbowl.vault.economy.Economy; import net.milkbowl.vault.economy.Economy;
import net.milkbowl.vault.permission.Permission; import net.milkbowl.vault.permission.Permission;
import org.bstats.bukkit.Metrics;
import org.bukkit.*; import org.bukkit.*;
import org.bukkit.command.Command; import org.bukkit.command.Command;
import org.bukkit.command.CommandSender; import org.bukkit.command.CommandSender;
@@ -96,10 +97,7 @@ public class FactionsPlugin extends MPlugin {
private FLogManager fLogManager; private FLogManager fLogManager;
private List<ReserveObject> reserveObjects; private List<ReserveObject> reserveObjects;
private FileManager fileManager; private FileManager fileManager;
private TimerManager timerManager;
public FileManager getFileManager() {
return fileManager;
}
public FactionsPlugin() { public FactionsPlugin() {
instance = this; instance = this;
@@ -109,6 +107,10 @@ public class FactionsPlugin extends MPlugin {
return instance; return instance;
} }
public FileManager getFileManager() {
return fileManager;
}
public boolean getLocked() { public boolean getLocked() {
return this.locked; return this.locked;
} }
@@ -178,6 +180,10 @@ public class FactionsPlugin extends MPlugin {
migrateFPlayerLeaders(); migrateFPlayerLeaders();
log("==== End Setup ===="); log("==== End Setup ====");
int pluginId = 7013;
Metrics metrics = new Metrics(this, pluginId);
if (!preEnable()) return; if (!preEnable()) return;
this.loadSuccessful = false; this.loadSuccessful = false;
@@ -273,6 +279,10 @@ public class FactionsPlugin extends MPlugin {
fLogManager.loadLogs(this); fLogManager.loadLogs(this);
this.timerManager = new TimerManager(this);
this.timerManager.reloadTimerData();
System.out.println("[SABER-FACTIONS] - Loaded " + timerManager.getTimers().size() + " timers into list!");
getServer().getPluginManager().registerEvents(factionsPlayerListener = new FactionsPlayerListener(), this); getServer().getPluginManager().registerEvents(factionsPlayerListener = new FactionsPlayerListener(), this);
// Register Event Handlers // Register Event Handlers
@@ -285,6 +295,7 @@ public class FactionsPlugin extends MPlugin {
new MissionHandler(this), new MissionHandler(this),
new FChestListener(), new FChestListener(),
new MenuListener(), new MenuListener(),
timerManager.graceTimer,
new AntiChestListener() new AntiChestListener()
}; };
@@ -313,6 +324,7 @@ public class FactionsPlugin extends MPlugin {
} catch (Exception e) { } catch (Exception e) {
e.printStackTrace(); e.printStackTrace();
} }
if (getDescription().getFullName().contains("BETA")) { if (getDescription().getFullName().contains("BETA")) {
divider(); divider();
System.out.println("You are using a BETA version of the plugin!"); System.out.println("You are using a BETA version of the plugin!");
@@ -438,6 +450,8 @@ public class FactionsPlugin extends MPlugin {
@Override @Override
public void onDisable() { public void onDisable() {
super.onDisable();
timerManager.saveTimerData();
try { try {
String path = Paths.get(getDataFolder().getAbsolutePath()).toAbsolutePath().toString() + File.separator + "reserves.json"; String path = Paths.get(getDataFolder().getAbsolutePath()).toAbsolutePath().toString() + File.separator + "reserves.json";
File file = new File(path); File file = new File(path);
@@ -462,7 +476,6 @@ public class FactionsPlugin extends MPlugin {
if (Discord.jda != null) { if (Discord.jda != null) {
Discord.jda.shutdownNow(); Discord.jda.shutdownNow();
} }
super.onDisable();
try { try {
fLogManager.saveLogs(); fLogManager.saveLogs();
} catch (Exception e) { } catch (Exception e) {
@@ -522,14 +535,6 @@ public class FactionsPlugin extends MPlugin {
return sender instanceof Player && FactionsPlayerListener.preventCommand(commandString, (Player) sender) || super.handleCommand(sender, commandString, testOnly); return sender instanceof Player && FactionsPlayerListener.preventCommand(commandString, (Player) sender) || super.handleCommand(sender, commandString, testOnly);
} }
@Override
public boolean onCommand(CommandSender sender, Command command, String label, String[] split) {
if (split.length == 0) return handleCommand(sender, "/f help", false);
// otherwise, needs to be handled; presumably another plugin directly ran the command
String cmd = Conf.baseCommandAliases.isEmpty() ? "/f" : "/" + Conf.baseCommandAliases.get(0);
return handleCommand(sender, cmd + " " + TextUtil.implode(Arrays.asList(split), " "), false);
}
// This method must stay for < 1.12 versions // This method must stay for < 1.12 versions
@Override @Override
@@ -716,6 +721,10 @@ public class FactionsPlugin extends MPlugin {
return perms == null || !perms.hasGroupSupport() ? " " : perms.getPrimaryGroup(Bukkit.getWorlds().get(0).toString(), player); return perms == null || !perms.hasGroupSupport() ? " " : perms.getPrimaryGroup(Bukkit.getWorlds().get(0).toString(), player);
} }
public TimerManager getTimerManager() {
return timerManager;
}
public void debug(Level level, String s) { public void debug(Level level, String s) {
if (getConfig().getBoolean("debug", false)) getLogger().log(level, s); if (getConfig().getBoolean("debug", false)) getLogger().log(level, s);
} }

View File

@@ -10,6 +10,8 @@ public class Aliases {
/** /**
* @author DroppingAnvil * @author DroppingAnvil
*/ */
public static ArrayList<String> friendlyFire = new ArrayList<>(Arrays.asList("friendlyfire", "ff"));
public static ArrayList<String> notifications = new ArrayList<>(Arrays.asList("notifications", "notis")); public static ArrayList<String> notifications = new ArrayList<>(Arrays.asList("notifications", "notis"));
public static ArrayList<String> alts_alts = new ArrayList<>(Arrays.asList("alts", "alt")); public static ArrayList<String> alts_alts = new ArrayList<>(Arrays.asList("alts", "alt"));
public static ArrayList<String> alts_list = new ArrayList<>(Arrays.asList("list", "l")); public static ArrayList<String> alts_list = new ArrayList<>(Arrays.asList("list", "l"));

View File

@@ -8,6 +8,7 @@ import com.massivecraft.factions.event.FactionCreateEvent;
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;
import com.massivecraft.factions.util.Cooldown;
import com.massivecraft.factions.util.MiscUtil; import com.massivecraft.factions.util.MiscUtil;
import com.massivecraft.factions.zcore.util.TL; import com.massivecraft.factions.zcore.util.TL;
import net.dv8tion.jda.core.entities.Member; import net.dv8tion.jda.core.entities.Member;
@@ -53,6 +54,11 @@ public class CmdCreate extends FCommand {
return; return;
} }
if(Cooldown.isOnCooldown(context.fPlayer.getPlayer(), "createCooldown") && !context.fPlayer.isAdminBypassing()){
context.msg(TL.COMMAND_COOLDOWN);
return;
}
ReserveObject factionReserve = FactionsPlugin.getInstance().getFactionReserves().stream().filter(factionReserve1 -> factionReserve1.getFactionName().equalsIgnoreCase(tag)).findFirst().orElse(null); ReserveObject factionReserve = FactionsPlugin.getInstance().getFactionReserves().stream().filter(factionReserve1 -> factionReserve1.getFactionName().equalsIgnoreCase(tag)).findFirst().orElse(null);
if (factionReserve != null && !factionReserve.getName().equalsIgnoreCase(context.player.getName())) { if (factionReserve != null && !factionReserve.getName().equalsIgnoreCase(context.player.getName())) {
context.msg(TL.COMMAND_CREATE_ALREADY_RESERVED); context.msg(TL.COMMAND_CREATE_ALREADY_RESERVED);
@@ -105,6 +111,7 @@ public class CmdCreate extends FCommand {
// That way we don't have to mess up deleting more stuff. // That way we don't have to mess up deleting more stuff.
// And prevent the user from being returned to NORMAL after deleting his old faction. // And prevent the user from being returned to NORMAL after deleting his old faction.
context.fPlayer.setRole(Role.LEADER); context.fPlayer.setRole(Role.LEADER);
Cooldown.setCooldown(context.fPlayer.getPlayer(), "createCooldown", FactionsPlugin.getInstance().getConfig().getInt("fcooldowns.f-create"));
if (FactionsPlugin.getInstance().getConfig().getBoolean("faction-creation-broadcast", true)) { if (FactionsPlugin.getInstance().getConfig().getBoolean("faction-creation-broadcast", true)) {
for (FPlayer follower : FPlayers.getInstance().getOnlinePlayers()) { for (FPlayer follower : FPlayers.getInstance().getOnlinePlayers()) {
follower.msg(TL.COMMAND_CREATE_CREATED, context.fPlayer.getName(), faction.getTag(follower)); follower.msg(TL.COMMAND_CREATE_CREATED, context.fPlayer.getName(), faction.getTag(follower));

View File

@@ -4,9 +4,10 @@ import com.massivecraft.factions.*;
import com.massivecraft.factions.event.FactionDisbandEvent.PlayerDisbandReason; import com.massivecraft.factions.event.FactionDisbandEvent.PlayerDisbandReason;
import com.massivecraft.factions.struct.Permission; import com.massivecraft.factions.struct.Permission;
import com.massivecraft.factions.struct.Role; import com.massivecraft.factions.struct.Role;
import com.massivecraft.factions.zcore.frame.fdisband.FDisbandFrame; import com.massivecraft.factions.util.Cooldown;
import com.massivecraft.factions.zcore.fperms.Access; import com.massivecraft.factions.zcore.fperms.Access;
import com.massivecraft.factions.zcore.fperms.PermissableAction; import com.massivecraft.factions.zcore.fperms.PermissableAction;
import com.massivecraft.factions.zcore.frame.fdisband.FDisbandFrame;
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.command.ConsoleCommandSender; import org.bukkit.command.ConsoleCommandSender;
@@ -69,6 +70,11 @@ public class CmdDisband extends FCommand {
return; return;
} }
if(Cooldown.isOnCooldown(context.fPlayer.getPlayer(), "disbandCooldown") && !context.fPlayer.isAdminBypassing()){
context.msg(TL.COMMAND_COOLDOWN);
return;
}
boolean access = false; boolean access = false;
if (context.fPlayer.getPlayer().hasMetadata("disband_confirm") && (time = context.fPlayer.getPlayer().getMetadata("disband_confirm").get(0).asLong()) != 0L && System.currentTimeMillis() - time <= TimeUnit.SECONDS.toMillis(3L)) { if (context.fPlayer.getPlayer().hasMetadata("disband_confirm") && (time = context.fPlayer.getPlayer().getMetadata("disband_confirm").get(0).asLong()) != 0L && System.currentTimeMillis() - time <= TimeUnit.SECONDS.toMillis(3L)) {
@@ -84,7 +90,6 @@ public class CmdDisband extends FCommand {
} }
} }
// 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) {
context.msg(TL.COMMAND_DISBAND_CONFIRM.toString().replace("{tnt}", faction.getTnt() + "")); context.msg(TL.COMMAND_DISBAND_CONFIRM.toString().replace("{tnt}", faction.getTnt() + ""));
@@ -103,15 +108,17 @@ public class CmdDisband extends FCommand {
follower.msg(TL.COMMAND_DISBAND_BROADCAST_NOTYOURS, amountString, faction.getTag(follower)); follower.msg(TL.COMMAND_DISBAND_BROADCAST_NOTYOURS, amountString, faction.getTag(follower));
} }
} }
if (FactionsPlugin.getInstance().getConfig().getBoolean("enable-faction-flight")){ if (FactionsPlugin.getInstance().getConfig().getBoolean("enable-faction-flight")) {
faction.disband(context.player, PlayerDisbandReason.COMMAND); faction.disband(context.player, PlayerDisbandReason.COMMAND);
context.fPlayer.setFFlying(false, false); context.fPlayer.setFFlying(false, false);
Cooldown.setCooldown(context.fPlayer.getPlayer(), "disbandCooldown", FactionsPlugin.getInstance().getConfig().getInt("fcooldowns.f-disband"));
return; return;
} }
} else { } else {
context.player.sendMessage(String.valueOf(TL.COMMAND_DISBAND_PLAYER)); context.player.sendMessage(String.valueOf(TL.COMMAND_DISBAND_PLAYER));
} }
faction.disband(context.player, PlayerDisbandReason.COMMAND); faction.disband(context.player, PlayerDisbandReason.COMMAND);
Cooldown.setCooldown(context.fPlayer.getPlayer(), "disbandCooldown", FactionsPlugin.getInstance().getConfig().getInt("fcooldowns.f-disband"));
if (!context.fPlayer.canFlyAtLocation() && FactionsPlugin.getInstance().getConfig().getBoolean("enable-faction-flight")) { if (!context.fPlayer.canFlyAtLocation() && FactionsPlugin.getInstance().getConfig().getBoolean("enable-faction-flight")) {
context.fPlayer.setFFlying(false, false); context.fPlayer.setFFlying(false, false);
} }

View File

@@ -27,6 +27,7 @@ public class CmdFly extends FCommand {
public static ConcurrentHashMap<String, Boolean> flyMap = new ConcurrentHashMap<>(); public static ConcurrentHashMap<String, Boolean> flyMap = new ConcurrentHashMap<>();
public static BukkitTask particleTask = null; public static BukkitTask particleTask = null;
public static BukkitTask flyTask = null; public static BukkitTask flyTask = null;
public static boolean autoenable = FactionsPlugin.instance.getConfig().getBoolean("ffly.AutoEnable");
public CmdFly() { public CmdFly() {
@@ -77,27 +78,27 @@ public class CmdFly extends FCommand {
continue; continue;
} }
FPlayer fPlayer = FPlayers.getInstance().getByPlayer(player); FPlayer fPlayer = FPlayers.getInstance().getByPlayer(player);
Faction myFaction = fPlayer.getFaction(); if (fPlayer.isAdminBypassing()) continue;
if (!player.hasPermission("factions.fly.bypassnearbyenemycheck") && !fPlayer.isAdminBypassing()) { if (!player.hasPermission("factions.fly.bypassnearbyenemycheck")) {
if (fPlayer.hasEnemiesNearby()) disableFlightSync(fPlayer); if (fPlayer.hasEnemiesNearby()) {
disableFlightSync(fPlayer);
continue;
}
checkEnemiesSync(fPlayer); checkEnemiesSync(fPlayer);
continue;
} }
FLocation myFloc = new FLocation(player.getLocation()); FLocation myFloc = new FLocation(player.getLocation());
if (Board.getInstance().getFactionAt(myFloc) != myFaction) { if (!checkFly(fPlayer, player, Board.getInstance().getFactionAt(myFloc))) {
if (!checkFly(fPlayer, player, Board.getInstance().getFactionAt(myFloc))) { disableFlightSync(fPlayer);
disableFlightSync(fPlayer);
}
} }
} }
} }
}, 20L, 20L); }, 20L, 15L);
} }
public static boolean checkFly(FPlayer fme, Player me, Faction toFac) { public static boolean checkFly(FPlayer fme, Player me, Faction toFac) {
if (Conf.denyFlightIfInNoClaimingWorld && !Conf.worldsNoClaiming.isEmpty() && Conf.worldsNoClaiming.stream().anyMatch(me.getWorld().getName()::equalsIgnoreCase)) if ((Conf.denyFlightIfInNoClaimingWorld && !Conf.worldsNoClaiming.isEmpty() && Conf.worldsNoClaiming.stream().anyMatch(me.getWorld().getName()::equalsIgnoreCase)) || me.hasPermission(Permission.FLY_FLY.node))
return false; return false;
if (toFac.getAccess(fme, PermissableAction.FLY) == Access.ALLOW) return true; if (toFac.getAccess(fme, PermissableAction.FLY) == Access.ALLOW) return true;
if (fme.getFaction().isWilderness()) return false; if (fme.getFaction().isWilderness()) return false;

View File

@@ -0,0 +1,44 @@
package com.massivecraft.factions.cmd;
import com.massivecraft.factions.Conf;
import com.massivecraft.factions.struct.Permission;
import com.massivecraft.factions.zcore.util.TL;
/**
* Factions - Developed by Driftay.
* All rights reserved 2020.
* Creation Date: 4/6/2020
*/
public class CmdFriendlyFire extends FCommand {
public CmdFriendlyFire(){
super();
this.aliases.addAll(Aliases.friendlyFire);
this.requirements = new CommandRequirements.Builder(Permission.FRIENDLYFIRE)
.playerOnly()
.memberOnly()
.build();
}
@Override
public void perform(CommandContext context) {
if(!Conf.friendlyFireFPlayersCommand){
context.msg(TL.GENERIC_DISABLED, "friendly fire");
return;
}
if(context.fPlayer.hasFriendlyFire()){
context.fPlayer.setFriendlyFire(false);
context.msg(TL.COMMAND_FRIENDLY_FIRE_TOGGLE_OFF);
} else {
context.fPlayer.setFriendlyFire(true);
context.msg(TL.COMMAND_FRIENDLY_FIRE_TOGGLE_ON);
}
}
@Override
public TL getUsageTranslation() {
return TL.COMMAND_FRIENDLY_FIRE_DESCRIPTION;
}
}

View File

@@ -56,7 +56,7 @@ public class CmdJoin extends FCommand {
return; return;
} }
if (Conf.factionMemberLimit > 0 && faction.getFPlayers().size() >= getFactionMemberLimit(faction)) { if (!faction.altInvited(fplayer) && Conf.factionMemberLimit > 0 && faction.getFPlayers().size() >= getFactionMemberLimit(faction)) {
context.msg(TL.COMMAND_JOIN_ATLIMIT, faction.getTag(context.fPlayer), getFactionMemberLimit(faction), fplayer.describeTo(context.fPlayer, false)); context.msg(TL.COMMAND_JOIN_ATLIMIT, faction.getTag(context.fPlayer), getFactionMemberLimit(faction), fplayer.describeTo(context.fPlayer, false));
return; return;
} }

View File

@@ -6,6 +6,7 @@ import com.massivecraft.factions.FPlayers;
import com.massivecraft.factions.FactionsPlugin; import com.massivecraft.factions.FactionsPlugin;
import com.massivecraft.factions.struct.Permission; import com.massivecraft.factions.struct.Permission;
import com.massivecraft.factions.struct.Role; import com.massivecraft.factions.struct.Role;
import com.massivecraft.factions.util.Cooldown;
import com.massivecraft.factions.zcore.util.TL; import com.massivecraft.factions.zcore.util.TL;
public class CmdOpen extends FCommand { public class CmdOpen extends FCommand {
@@ -38,12 +39,19 @@ public class CmdOpen extends FCommand {
String open = context.faction.getOpen() ? TL.COMMAND_OPEN_OPEN.toString() : TL.COMMAND_OPEN_CLOSED.toString(); String open = context.faction.getOpen() ? TL.COMMAND_OPEN_OPEN.toString() : TL.COMMAND_OPEN_CLOSED.toString();
if(Cooldown.isOnCooldown(context.fPlayer.getPlayer(), "openCooldown") && !context.fPlayer.isAdminBypassing()){
context.msg(TL.COMMAND_COOLDOWN);
return;
}
// Inform // Inform
for (FPlayer fplayer : FPlayers.getInstance().getOnlinePlayers()) { for (FPlayer fplayer : FPlayers.getInstance().getOnlinePlayers()) {
if (fplayer.getFactionId().equals(context.faction.getId())) { if (fplayer.getFactionId().equals(context.faction.getId())) {
fplayer.msg(TL.COMMAND_OPEN_CHANGES, context.fPlayer.getName(), open); fplayer.msg(TL.COMMAND_OPEN_CHANGES, context.fPlayer.getName(), open);
Cooldown.setCooldown(fplayer.getPlayer(), "openCooldown", FactionsPlugin.getInstance().getConfig().getInt("fcooldowns.f-open"));
continue; continue;
} }
if(FactionsPlugin.getInstance().getConfig().getBoolean("faction-open-broadcast")) return;
fplayer.msg(TL.COMMAND_OPEN_CHANGED, context.faction.getTag(fplayer.getFaction()), open); fplayer.msg(TL.COMMAND_OPEN_CHANGED, context.faction.getTag(fplayer.getFaction()), open);
} }
}); });

View File

@@ -24,6 +24,7 @@ public class CmdSaveAll extends FCommand {
Factions.getInstance().forceSave(false); Factions.getInstance().forceSave(false);
Board.getInstance().forceSave(false); Board.getInstance().forceSave(false);
Conf.save(); Conf.save();
FactionsPlugin.getInstance().getTimerManager().saveTimerData();
try { try {
FactionsPlugin.instance.getFlogManager().saveLogs(); FactionsPlugin.instance.getFlogManager().saveLogs();
} catch (Exception e) { } catch (Exception e) {

View File

@@ -7,6 +7,7 @@ import com.massivecraft.factions.event.FactionRenameEvent;
import com.massivecraft.factions.scoreboards.FTeamWrapper; import com.massivecraft.factions.scoreboards.FTeamWrapper;
import com.massivecraft.factions.struct.Permission; import com.massivecraft.factions.struct.Permission;
import com.massivecraft.factions.struct.Role; import com.massivecraft.factions.struct.Role;
import com.massivecraft.factions.util.Cooldown;
import com.massivecraft.factions.util.MiscUtil; import com.massivecraft.factions.util.MiscUtil;
import com.massivecraft.factions.zcore.util.TL; import com.massivecraft.factions.zcore.util.TL;
import org.bukkit.Bukkit; import org.bukkit.Bukkit;
@@ -53,6 +54,11 @@ public class CmdTag extends FCommand {
return; return;
} }
if(Cooldown.isOnCooldown(context.player, "tagCooldown") && !context.fPlayer.isAdminBypassing()){
context.msg(TL.COMMAND_COOLDOWN);
return;
}
// trigger the faction rename event (cancellable) // trigger the faction rename event (cancellable)
FactionRenameEvent renameEvent = new FactionRenameEvent(context.fPlayer, tag); FactionRenameEvent renameEvent = new FactionRenameEvent(context.fPlayer, tag);
Bukkit.getServer().getPluginManager().callEvent(renameEvent); Bukkit.getServer().getPluginManager().callEvent(renameEvent);
@@ -65,8 +71,11 @@ public class CmdTag extends FCommand {
return; return;
} }
String oldtag = context.faction.getTag(); String oldtag = context.faction.getTag();
context.faction.setTag(tag); context.faction.setTag(tag);
Discord.changeFactionTag(context.faction, oldtag); Discord.changeFactionTag(context.faction, oldtag);
FactionsPlugin.instance.logFactionEvent(context.faction, FLogType.FTAG_EDIT, context.fPlayer.getName(), tag); FactionsPlugin.instance.logFactionEvent(context.faction, FLogType.FTAG_EDIT, context.fPlayer.getName(), tag);
@@ -75,6 +84,7 @@ public class CmdTag extends FCommand {
for (FPlayer fplayer : FPlayers.getInstance().getOnlinePlayers()) { for (FPlayer fplayer : FPlayers.getInstance().getOnlinePlayers()) {
if (fplayer.getFactionId().equals(context.faction.getId())) { if (fplayer.getFactionId().equals(context.faction.getId())) {
fplayer.msg(TL.COMMAND_TAG_FACTION, context.fPlayer.describeTo(context.faction, true), context.faction.getTag(context.faction)); fplayer.msg(TL.COMMAND_TAG_FACTION, context.fPlayer.describeTo(context.faction, true), context.faction.getTag(context.faction));
Cooldown.setCooldown(fplayer.getPlayer(), "tagCooldown", FactionsPlugin.getInstance().getConfig().getInt("fcooldowns.f-tag"));
continue; continue;
} }
// Broadcast the tag change (if applicable) // Broadcast the tag change (if applicable)

View File

@@ -8,7 +8,6 @@ import com.massivecraft.factions.cmd.check.CmdCheck;
import com.massivecraft.factions.cmd.check.CmdWeeWoo; import com.massivecraft.factions.cmd.check.CmdWeeWoo;
import com.massivecraft.factions.cmd.chest.CmdChest; import com.massivecraft.factions.cmd.chest.CmdChest;
import com.massivecraft.factions.cmd.claim.*; import com.massivecraft.factions.cmd.claim.*;
import com.massivecraft.factions.cmd.configsf.CmdConvertConfig;
import com.massivecraft.factions.cmd.econ.CmdMoney; import com.massivecraft.factions.cmd.econ.CmdMoney;
import com.massivecraft.factions.cmd.grace.CmdGrace; import com.massivecraft.factions.cmd.grace.CmdGrace;
import com.massivecraft.factions.cmd.logout.CmdLogout; import com.massivecraft.factions.cmd.logout.CmdLogout;
@@ -156,7 +155,6 @@ public class FCmdRoot extends FCommand implements CommandExecutor {
public CmdCheck cmdCheck = new CmdCheck(); public CmdCheck cmdCheck = new CmdCheck();
public CmdWeeWoo cmdWeeWoo = new CmdWeeWoo(); public CmdWeeWoo cmdWeeWoo = new CmdWeeWoo();
public CmdWild cmdWild = new CmdWild(); public CmdWild cmdWild = new CmdWild();
public CmdConvertConfig cmdConvertConfig = new CmdConvertConfig();
public CmdSpawnerLock cmdSpawnerLock = new CmdSpawnerLock(); public CmdSpawnerLock cmdSpawnerLock = new CmdSpawnerLock();
public CmdSetDiscord cmdSetDiscord = new CmdSetDiscord(); public CmdSetDiscord cmdSetDiscord = new CmdSetDiscord();
public CmdSeeDiscord cmdSeeDiscord = new CmdSeeDiscord(); public CmdSeeDiscord cmdSeeDiscord = new CmdSeeDiscord();
@@ -171,6 +169,7 @@ public class FCmdRoot extends FCommand implements CommandExecutor {
public CmdDelHome cmdDelHome = new CmdDelHome(); public CmdDelHome cmdDelHome = new CmdDelHome();
public CmdClaimFill cmdClaimFill = new CmdClaimFill(); public CmdClaimFill cmdClaimFill = new CmdClaimFill();
public CmdNotifications cmdNotifications = new CmdNotifications(); public CmdNotifications cmdNotifications = new CmdNotifications();
public CmdFriendlyFire cmdFriendlyFire = new CmdFriendlyFire();
//Variables to know if we already setup certain sub commands //Variables to know if we already setup certain sub commands
public Boolean discordEnabled = false; public Boolean discordEnabled = false;
@@ -301,11 +300,11 @@ public class FCmdRoot extends FCommand implements CommandExecutor {
this.addSubCommand(this.cmdCorner); this.addSubCommand(this.cmdCorner);
this.addSubCommand(this.cmdFGlobal); this.addSubCommand(this.cmdFGlobal);
this.addSubCommand(this.cmdViewChest); this.addSubCommand(this.cmdViewChest);
this.addSubCommand(this.cmdConvertConfig);
this.addSubCommand(this.cmdSpawnerLock); this.addSubCommand(this.cmdSpawnerLock);
this.addSubCommand(this.cmdDrain); this.addSubCommand(this.cmdDrain);
this.addSubCommand(this.cmdLookup); this.addSubCommand(this.cmdLookup);
this.addSubCommand(this.cmdNotifications); this.addSubCommand(this.cmdNotifications);
this.addSubCommand(this.cmdFriendlyFire);
addVariableCommands(); addVariableCommands();
if (CommodoreProvider.isSupported()) brigadierManager.build(); if (CommodoreProvider.isSupported()) brigadierManager.build();
} }
@@ -403,6 +402,8 @@ public class FCmdRoot extends FCommand implements CommandExecutor {
if (FactionsPlugin.getInstance().getConfig().getBoolean("enable-faction-flight", false) && !fFlyEnabled) { if (FactionsPlugin.getInstance().getConfig().getBoolean("enable-faction-flight", false) && !fFlyEnabled) {
this.addSubCommand(this.cmdFly); this.addSubCommand(this.cmdFly);
fFlyEnabled = true; fFlyEnabled = true;
CmdFly.startFlyCheck();
CmdFly.startParticles();
} }
} }

View File

@@ -4,8 +4,8 @@ import com.google.common.collect.Lists;
import com.massivecraft.factions.Conf; import com.massivecraft.factions.Conf;
import com.massivecraft.factions.Faction; import com.massivecraft.factions.Faction;
import com.massivecraft.factions.FactionsPlugin; import com.massivecraft.factions.FactionsPlugin;
import com.massivecraft.factions.zcore.frame.FactionGUI;
import com.massivecraft.factions.util.XMaterial; import com.massivecraft.factions.util.XMaterial;
import com.massivecraft.factions.zcore.frame.FactionGUI;
import com.massivecraft.factions.zcore.util.TL; import com.massivecraft.factions.zcore.util.TL;
import org.bukkit.DyeColor; import org.bukkit.DyeColor;
import org.bukkit.event.inventory.ClickType; import org.bukkit.event.inventory.ClickType;

View File

@@ -3,8 +3,8 @@ package com.massivecraft.factions.cmd.check;
import com.massivecraft.factions.FPlayer; import com.massivecraft.factions.FPlayer;
import com.massivecraft.factions.Faction; import com.massivecraft.factions.Faction;
import com.massivecraft.factions.FactionsPlugin; import com.massivecraft.factions.FactionsPlugin;
import com.massivecraft.factions.zcore.frame.FactionGUI;
import com.massivecraft.factions.util.XMaterial; import com.massivecraft.factions.util.XMaterial;
import com.massivecraft.factions.zcore.frame.FactionGUI;
import com.massivecraft.factions.zcore.util.TL; import com.massivecraft.factions.zcore.util.TL;
import org.bukkit.ChatColor; import org.bukkit.ChatColor;
import org.bukkit.event.inventory.ClickType; import org.bukkit.event.inventory.ClickType;

View File

@@ -83,7 +83,6 @@ public class CmdClaim extends FCommand {
this.stop(); this.stop();
return false; return false;
} }
return true; return true;
} }
}; };

View File

@@ -1,29 +0,0 @@
package com.massivecraft.factions.cmd.configsf;
import com.massivecraft.factions.cmd.CommandContext;
import com.massivecraft.factions.cmd.CommandRequirements;
import com.massivecraft.factions.cmd.FCommand;
import com.massivecraft.factions.struct.Permission;
import com.massivecraft.factions.zcore.util.TL;
public class CmdConvertConfig extends FCommand {
public CmdConvertConfig() {
super();
this.aliases.add("convertconfig");
this.requirements = new CommandRequirements.Builder(Permission.CONVERTCONFIG)
.playerOnly()
.build();
}
@Override
public void perform(CommandContext context) {
ConvertConfigHandler.convertconfig(context.player);
}
@Override
public TL getUsageTranslation() {
return TL.COMMAND_CONVERTCONFIG_DESCRIPTION;
}
}

View File

@@ -1,147 +0,0 @@
package com.massivecraft.factions.cmd.configsf;
import com.massivecraft.factions.FactionsPlugin;
import com.massivecraft.factions.zcore.util.TL;
import org.bukkit.Bukkit;
import org.bukkit.configuration.ConfigurationSection;
import org.bukkit.configuration.file.FileConfiguration;
import org.bukkit.configuration.file.YamlConfiguration;
import org.bukkit.entity.Player;
import org.bukkit.plugin.java.JavaPlugin;
import org.bukkit.scheduler.BukkitScheduler;
import java.io.File;
import java.io.IOException;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.List;
import java.util.logging.Level;
public class ConvertConfigHandler {
static File savageConfigFile = new File("plugins/Factions/SavageFactions/config.yml");
static FileConfiguration sv = YamlConfiguration.loadConfiguration(savageConfigFile);
static File configFile = new File("plugins/Factions/config.yml");
static FileConfiguration sb = YamlConfiguration.loadConfiguration(configFile);
static JavaPlugin plugin = JavaPlugin.getProvidingPlugin(FactionsPlugin.class);
public static void setString(String s) {
sb.set(s, sv.getString(s));
}
public static void setInt(String s) {
sb.set(s, sv.getInt(s));
}
public static void setConfigSec(String s) {
ConfigurationSection cs = sv.getConfigurationSection(s);
sb.set(s, cs);
}
public static void setBoolean(String s) {
sb.set(s, sv.getBoolean(s));
}
public static void convertconfig(Player player) {
if (new File("plugins/Factions/SavageFactions/config.yml").exists()) {
BukkitScheduler scheduler = plugin.getServer().getScheduler();
scheduler.scheduleAsyncDelayedTask(plugin, () -> {
File savageConfigFile = new File("plugins/Factions/SavageFactions/config.yml");
FileConfiguration sv = YamlConfiguration.loadConfiguration(savageConfigFile);
File configFile = new File("plugins/Factions/config.yml");
FileConfiguration sb = YamlConfiguration.loadConfiguration(configFile);
sb.set("ConfigConvertedFromSavageFactions", true);
sb.set("debug", sv.getBoolean("debug"));
ConfigurationSection ffe = sv.getConfigurationSection("findfactionsexploit");
sb.set("findfactionsexploit", ffe);
setString("default-relation");
ConfigurationSection pC = sv.getConfigurationSection("portals");
sb.set("portals", pC);
sb.set("maxwarps", sv.getInt("maxwarps"));
setConfigSec("warp-cost");
setBoolean("enable-faction-flight");
setBoolean("ffly.AutoEnable");
setInt("fly-falldamage-cooldown");
setBoolean("disable-pistons-in-territory");
setConfigSec("tooltips");
setConfigSec("scoreboard");
sb.set("scoreboard.also-send-chat", true);
setConfigSec("warmups");
setConfigSec("max-relations");
setInt("world-border.buffer");
setConfigSec("hcf");
sb.set("show", sv.getStringList("show"));
setBoolean("show-exempt");
sb.set("map", sv.getStringList("map"));
setConfigSec("list");
setBoolean("use-old-help");
setConfigSec("help");
setConfigSec("fperm-gui");
sb.set("fperm-gui.action.slots.check", 50);
setConfigSec("fwarp-gui");
setBoolean("faction-creation-broadcast");
setBoolean("faction-disband-broadcast");
setBoolean("See-Invisible-Faction-Members");
setConfigSec("frules");
setConfigSec("ftnt");
setBoolean("fpaypal.Enabled");
setBoolean("checkpoints.Enabled");
setConfigSec("fnear");
setConfigSec("ffocus");
setConfigSec("fvualt");
setString("fupgrades.MainMenu.Title");
setString("fupgrades.MainMenu.DummyItem.Name");
setString("fupgrades.MainMenu.DummyItem.Type");
List<String> l = sv.getStringList("fupgrades.MainMenu.DummyItem.Lore");
sb.set("fupgrades.MainMenu.DummyItem.Lore", l);
setConfigSec("fupgrades.MainMenu.Crops.Crop-Boost");
setConfigSec("fupgrades.MainMenu.Crops.Cost");
sb.set("fupgrades.MainMenu.Crops.CropItem", sv.getConfigurationSection("fupgrades.MainMenu.Crops.DisplayItem"));
setConfigSec("fupgrades.MainMenu.EXP.EXP-Boost");
setConfigSec("fupgrades.MainMenu.EXP.Cost");
sb.set("fupgrades.MainMenu.EXP.EXPItem", sv.getConfigurationSection("fupgrades.MainMenu.EXP.DisplayItem"));
setConfigSec("fupgrades.MainMenu.Power.Power-Boost");
setConfigSec("fupgrades.MainMenu.Power.Cost");
sb.set("fupgrades.MainMenu.Power.PowerItem", sv.getConfigurationSection("fupgrades.MainMenu.Power.DisplayItem"));
List<Integer> p = new ArrayList();
p.add(sv.getInt("fupgrades.MainMenu.Power.DisplayItem.Slot"));
sb.set("fupgrades.MainMenu.Power.PowerItem.slots", p);
sb.set("fupgrades.MainMenu.Power.PowerItem.Amount", 1);
sb.set("fupgrades.MainMenu.Power.PowerItem.Damage", 0);
sb.set("fupgrades.MainMenu.Power.PowerItem.Slot", null);
sb.set("fupgrades.MainMenu.Members.Members-Limit", sv.getConfigurationSection("fupgrades.MainMenu.Members.Members-Boost"));
setConfigSec("fupgrades.MainMenu.Spawners.Spawner-Boost");
setConfigSec("fupgrades.MainMenu.Spawners.Cost");
sb.set("fupgrades.MainMenu.Spawners.SpawnerItem", sv.getConfigurationSection("fupgrades.MainMenu.Spawners.DisplayItem"));
setConfigSec("fupgrades.MainMenu.Chest.Chest-Size");
setConfigSec("fupgrades.MainMenu.Chest.Cost");
sb.set("fupgrades.MainMenu.Chest.ChestItem", sv.getConfigurationSection("fupgrades.MainMenu.Chest.DisplayItem"));
setConfigSec("fupgrades.MainMenu.Members.Cost");
sb.set("fupgrades.MainMenu.Members.MembersItem", sv.getConfigurationSection("fupgrades.MainMenu.Members.DisplayItem"));
sb.set("fupgrades.MainMenu.Members.MembersItem.Amount", 1);
sb.set("fupgrades.MainMenu.Members.MembersItem.Damage", 0);
if (sv.getString("fupgrades.MainMenu.Members.DisplayItem.Type").equalsIgnoreCase("PLAYER_HEAD"))
sb.set("fupgrades.MainMenu.Members.MembersItem.Type", "PAPER");
List<Integer> x = new ArrayList();
x.add(sv.getInt("fupgrades.MainMenu.Members.DisplayItem.Slot"));
sb.set("fupgrades.MainMenu.Members.MembersItem.slots", x);
sb.set("fupgrades.MainMenu.Members.MembersItem.Slot", null);
sb.set("fupgrades.MainMenu.Members.Members-Limit", sv.getConfigurationSection("fupgrades.MainMenu.Members.Members-Boost"));
setConfigSec("fbanners");
setConfigSec("see-chunk");
setConfigSec("Tntfill");
try {
sb.save(configFile);
plugin.reloadConfig();
} catch (IOException e) {
player.sendMessage(TL.COMMAND_CONVERTCONFIG_FAIL.toString());
Bukkit.getLogger().log(Level.SEVERE, Arrays.toString(e.getStackTrace()));
}
player.sendMessage(TL.COMMAND_CONVERTCONFIG_SUCCESS.toString());
}, 0L);
} else {
player.sendMessage(TL.COMMAND_CONVERTCONFIG_FAILCONFIGMISSING.toString());
}
}
}

View File

@@ -37,7 +37,7 @@ public class CmdMoneyDeposit extends FCommand {
double amount = context.argAsDouble(0, 0d); double amount = context.argAsDouble(0, 0d);
EconomyParticipator faction = context.argAsFaction(1, context.faction); EconomyParticipator faction = context.argAsFaction(1, context.faction);
if(amount <= 0){ if (amount <= 0) {
return; return;
} }

View File

@@ -34,7 +34,7 @@ public class CmdMoneyTransferFf extends FCommand {
public void perform(CommandContext context) { public void perform(CommandContext context) {
double amount = context.argAsDouble(0, 0d); double amount = context.argAsDouble(0, 0d);
if(amount <= 0){ if (amount <= 0) {
return; return;
} }

View File

@@ -33,7 +33,7 @@ public class CmdMoneyTransferFp extends FCommand {
public void perform(CommandContext context) { public void perform(CommandContext context) {
double amount = context.argAsDouble(0, 0d); double amount = context.argAsDouble(0, 0d);
if(amount <= 0){ if (amount <= 0) {
return; return;
} }

View File

@@ -33,7 +33,7 @@ public class CmdMoneyTransferPf extends FCommand {
public void perform(CommandContext context) { public void perform(CommandContext context) {
double amount = context.argAsDouble(0, 0d); double amount = context.argAsDouble(0, 0d);
if(amount <= 0){ if (amount <= 0) {
return; return;
} }

View File

@@ -40,7 +40,7 @@ public class CmdMoneyWithdraw extends FCommand {
public void perform(CommandContext context) { public void perform(CommandContext context) {
double amount = context.argAsDouble(0, 0d); double amount = context.argAsDouble(0, 0d);
if(amount <= 0){ if (amount <= 0) {
return; return;
} }

View File

@@ -1,35 +1,73 @@
package com.massivecraft.factions.cmd.grace; package com.massivecraft.factions.cmd.grace;
import com.massivecraft.factions.Conf; import com.massivecraft.factions.Conf;
import com.massivecraft.factions.FPlayer;
import com.massivecraft.factions.FPlayers;
import com.massivecraft.factions.FactionsPlugin; import com.massivecraft.factions.FactionsPlugin;
import com.massivecraft.factions.cmd.Aliases; import com.massivecraft.factions.cmd.Aliases;
import com.massivecraft.factions.cmd.CommandContext; 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.struct.Permission; import com.massivecraft.factions.struct.Permission;
import com.massivecraft.factions.util.timer.TimerManager;
import com.massivecraft.factions.zcore.util.TL; import com.massivecraft.factions.zcore.util.TL;
import java.util.concurrent.TimeUnit;
public class CmdGrace extends FCommand { public class CmdGrace extends FCommand {
/** /**
* @author Driftay * @author Driftay
*/ */
//TODO: Make Timed Format For Grace Period
public CmdGrace() { public CmdGrace() {
super(); super();
this.aliases.addAll(Aliases.grace); this.aliases.addAll(Aliases.grace);
this.optionalArgs.put("on/off", "toggle");
this.requirements = new CommandRequirements.Builder(Permission.GRACE) this.requirements = new CommandRequirements.Builder(Permission.GRACE)
.build(); .build();
} }
@Override @Override
public void perform(CommandContext context) { public void perform(CommandContext context) {
Conf.gracePeriod = !Conf.gracePeriod; if (!Conf.useGraceSystem) {
context.msg(TL.COMMAND_GRACE_TOGGLE, Conf.gracePeriod ? FactionsPlugin.getInstance().color("&aEnabled") : FactionsPlugin.getInstance().color("&4Disabled")); context.msg(TL.GENERIC_DISABLED, "factions grace");
} 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.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) {
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)));
}
}
@Override @Override
public TL getUsageTranslation() { public TL getUsageTranslation() {

View File

@@ -32,7 +32,7 @@ public class CmdPointsBalance extends FCommand {
if (context.argIsSet(0)) { if (context.argIsSet(0)) {
faction = context.argAsFaction(0); faction = context.argAsFaction(0);
} else if(context.faction.isNormal()){ } else if (context.faction.isNormal()) {
context.msg(TL.COMMAND_POINTS_SHOW_OWN, context.faction.getPoints()); context.msg(TL.COMMAND_POINTS_SHOW_OWN, context.faction.getPoints());
return; return;
} else { } else {

View File

@@ -20,7 +20,6 @@ import org.bukkit.inventory.ItemStack;
import org.bukkit.inventory.PlayerInventory; import org.bukkit.inventory.PlayerInventory;
import java.util.ArrayList; import java.util.ArrayList;
import java.util.HashMap;
import java.util.List; import java.util.List;
public class CmdTntFill extends FCommand { public class CmdTntFill extends FCommand {

View File

@@ -2,10 +2,10 @@ package com.massivecraft.factions.cmd.wild;
import com.massivecraft.factions.FPlayer; import com.massivecraft.factions.FPlayer;
import com.massivecraft.factions.FactionsPlugin; import com.massivecraft.factions.FactionsPlugin;
import com.massivecraft.factions.util.XMaterial;
import com.massivecraft.factions.util.wait.WaitExecutor; import com.massivecraft.factions.util.wait.WaitExecutor;
import com.massivecraft.factions.util.wait.WaitTask; import com.massivecraft.factions.util.wait.WaitTask;
import com.massivecraft.factions.zcore.frame.FactionGUI; import com.massivecraft.factions.zcore.frame.FactionGUI;
import com.massivecraft.factions.util.XMaterial;
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.entity.Player; import org.bukkit.entity.Player;

View File

@@ -8,7 +8,6 @@ import com.sk89q.worldguard.domains.Association;
import com.sk89q.worldguard.protection.ApplicableRegionSet; import com.sk89q.worldguard.protection.ApplicableRegionSet;
import com.sk89q.worldguard.protection.association.Associables; import com.sk89q.worldguard.protection.association.Associables;
import com.sk89q.worldguard.protection.association.RegionAssociable; import com.sk89q.worldguard.protection.association.RegionAssociable;
import com.sk89q.worldguard.protection.flags.DefaultFlag;
import com.sk89q.worldguard.protection.flags.StateFlag; import com.sk89q.worldguard.protection.flags.StateFlag;
import com.sk89q.worldguard.protection.managers.RegionManager; import com.sk89q.worldguard.protection.managers.RegionManager;
import com.sk89q.worldguard.protection.regions.ProtectedCuboidRegion; import com.sk89q.worldguard.protection.regions.ProtectedCuboidRegion;
@@ -22,7 +21,9 @@ import org.bukkit.plugin.Plugin;
import java.lang.reflect.Constructor; import java.lang.reflect.Constructor;
import java.lang.reflect.Method; import java.lang.reflect.Method;
import java.util.*; import java.util.ArrayList;
import java.util.Collection;
import java.util.List;
/* /*
* WorldGuard Permission Checking. * WorldGuard Permission Checking.
@@ -34,10 +35,6 @@ import java.util.*;
public class Worldguard { public class Worldguard {
private static Worldguard instance; private static Worldguard instance;
/**
* @author FactionsUUID Team
*/
private Object worldGuard; private Object worldGuard;
private WorldGuardPlugin worldGuardPlugin; private WorldGuardPlugin worldGuardPlugin;
private Object regionContainer; private Object regionContainer;
@@ -59,7 +56,7 @@ public class Worldguard {
Plugin p = Bukkit.getPluginManager().getPlugin("WorldGuard"); Plugin p = Bukkit.getPluginManager().getPlugin("WorldGuard");
if (p == null) { if (p == null) {
FactionsPlugin.instance.log("Could not find WorldGuard! Support will not be added."); FactionsPlugin.getInstance().log("Could not find WorldGuard! Support will not be added.");
return; return;
} }
if (p instanceof WorldGuardPlugin) { if (p instanceof WorldGuardPlugin) {
@@ -69,9 +66,9 @@ public class Worldguard {
Class<?> worldGuardClass = Class.forName("com.sk89q.worldguard.WorldGuard"); Class<?> worldGuardClass = Class.forName("com.sk89q.worldguard.WorldGuard");
Method getInstanceMethod = worldGuardClass.getMethod("getInstance"); Method getInstanceMethod = worldGuardClass.getMethod("getInstance");
worldGuard = getInstanceMethod.invoke(null); worldGuard = getInstanceMethod.invoke(null);
FactionsPlugin.instance.log("Found WorldGuard 7+"); FactionsPlugin.getInstance().log("Found WorldGuard 7+");
} catch (Exception ex) { } catch (Exception ex) {
FactionsPlugin.instance.log("Found WorldGuard <7"); FactionsPlugin.getInstance().log("Found WorldGuard <7");
} }
} }
} }
@@ -95,42 +92,6 @@ public class Worldguard {
return associable; return associable;
} }
public static boolean isPvPDisabled(Location l) {
try {
ApplicableRegionSet regionSet = Objects.requireNonNull(instance.getRegionManager(l.getWorld())).getApplicableRegions(l);
if (regionSet.size() < 1) {
try {
return Objects.requireNonNull(Objects.requireNonNull(instance.getRegionManager(l.getWorld())).getRegion("__global__")).getFlags().get(DefaultFlag.PVP) == StateFlag.State.DENY;
} catch (Exception e) {
if (!(e instanceof NullPointerException)) {
e.printStackTrace();
}
return false;
}
} else {
boolean return_flag = false;
int return_priority = -1;
for (ProtectedRegion region : regionSet) {
if (region.getFlags().containsKey(DefaultFlag.PVP)) {
StateFlag.State pvp_flag = (StateFlag.State) region.getFlags().get(DefaultFlag.PVP);
int region_priority = region.getPriority();
if (return_priority == -1) {
return_flag = pvp_flag == StateFlag.State.DENY;
return_priority = region_priority;
} else if (region_priority > return_priority) {
return_flag = pvp_flag == StateFlag.State.DENY;
return_priority = region_priority;
}
}
}
return return_flag;
}
} catch (Exception e) {
return false;
}
}
/** /**
* Credits to the people listed above for using reflections to load WorldGuard 6.0 & 7.0 in 1 class! * Credits to the people listed above for using reflections to load WorldGuard 6.0 & 7.0 in 1 class!
*/ */
@@ -159,8 +120,8 @@ public class Worldguard {
breakFlag = (StateFlag) flagsClass.getField("BREAK").get(null); breakFlag = (StateFlag) flagsClass.getField("BREAK").get(null);
} catch (Exception ex) { } catch (Exception ex) {
FactionsPlugin.instance.log("We failed to load some part of World Guard. Support will be removed!"); FactionsPlugin.getInstance().log("We failed to load some part of World Guard. Support will be removed!");
FactionsPlugin.instance.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; return;
} }
@@ -178,8 +139,8 @@ public class Worldguard {
breakFlag = (StateFlag) flagsClass.getField("BREAK").get(null); breakFlag = (StateFlag) flagsClass.getField("BREAK").get(null);
} catch (Exception ex) { } catch (Exception ex) {
FactionsPlugin.instance.log("We failed to load some part of World Guard. Support will be removed!"); FactionsPlugin.getInstance().log("We failed to load some part of World Guard. Support will be removed!");
FactionsPlugin.instance.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; return;
} }
@@ -195,8 +156,8 @@ public class Worldguard {
vectorConstructorAsAMethodBecauseWhyNot = vectorClass.getMethod("at", Double.TYPE, Double.TYPE, Double.TYPE); vectorConstructorAsAMethodBecauseWhyNot = vectorClass.getMethod("at", Double.TYPE, Double.TYPE, Double.TYPE);
regionManagerGetMethod = RegionManager.class.getMethod("getApplicableRegions", vectorClass); regionManagerGetMethod = RegionManager.class.getMethod("getApplicableRegions", vectorClass);
} catch (Exception sodonewiththis) { } catch (Exception sodonewiththis) {
FactionsPlugin.instance.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.instance.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; return;
} }
@@ -216,7 +177,7 @@ public class Worldguard {
regionManager = (RegionManager) regionContainerGetMethod.invoke(regionContainer, world); regionManager = (RegionManager) regionContainerGetMethod.invoke(regionContainer, world);
} }
} catch (Exception ex) { } catch (Exception ex) {
FactionsPlugin.instance.log("An error occurred looking up a WorldGuard RegionManager"); FactionsPlugin.getInstance().log("An error occurred looking up a WorldGuard RegionManager");
} }
return regionManager; return regionManager;
} }
@@ -230,8 +191,8 @@ public class Worldguard {
: vectorConstructorAsAMethodBecauseWhyNot.invoke(null, location.getX(), location.getY(), location.getZ()); : vectorConstructorAsAMethodBecauseWhyNot.invoke(null, location.getX(), location.getY(), location.getZ());
return (ApplicableRegionSet) regionManagerGetMethod.invoke(regionManager, vector); return (ApplicableRegionSet) regionManagerGetMethod.invoke(regionManager, vector);
} catch (Exception ex) { } catch (Exception ex) {
FactionsPlugin.instance.log("An error occurred looking up a WorldGuard ApplicableRegionSet"); FactionsPlugin.getInstance().log("An error occurred looking up a WorldGuard ApplicableRegionSet");
FactionsPlugin.instance.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!");
} }
return null; return null;
} }
@@ -255,8 +216,8 @@ public class Worldguard {
} else } else
return (boolean) regionQueryTestStateMethod.invoke(query, location, getAssociable(player), new StateFlag[]{buildFlag}); return (boolean) regionQueryTestStateMethod.invoke(query, location, getAssociable(player), new StateFlag[]{buildFlag});
} catch (Exception ex) { } catch (Exception ex) {
FactionsPlugin.instance.log("An error occurred querying WorldGuard! Report this issue to SF Developers!"); FactionsPlugin.getInstance().log("An error occurred querying WorldGuard! Report this issue to SF Developers!");
FactionsPlugin.instance.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!");
} }
} }
return true; return true;
@@ -281,8 +242,8 @@ public class Worldguard {
return (boolean) regionQueryTestStateMethod.invoke(query, location, getAssociable(player), new StateFlag[]{breakFlag}); return (boolean) regionQueryTestStateMethod.invoke(query, location, getAssociable(player), new StateFlag[]{breakFlag});
} catch (Exception ex) { } catch (Exception ex) {
FactionsPlugin.instance.log("An error occurred querying WorldGuard! Report this issue to SF Developers!"); FactionsPlugin.getInstance().log("An error occurred querying WorldGuard! Report this issue to SF Developers!");
FactionsPlugin.instance.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!");
} }
} }
return true; return true;
@@ -320,8 +281,8 @@ public class Worldguard {
return overlaps != null && !overlaps.isEmpty(); return overlaps != null && !overlaps.isEmpty();
} catch (Exception ex) { } catch (Exception ex) {
FactionsPlugin.instance.log("An error occurred querying WorldGuard! Report this issue to SF Developers!"); FactionsPlugin.getInstance().log("An error occurred querying WorldGuard! Report this issue to SF Developers!");
FactionsPlugin.instance.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!");
} }
} }
return false; return false;

View File

@@ -94,26 +94,23 @@ 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 { else if (landOwned && !myFaction.getOwnerListString(loc).contains(player.getName())) {
String replace = TL.ACTIONS_NOPERMISSIONPAIN.toString().replace("{action}", action.toString()); me.msg(TL.ACTIONS_OWNEDTERRITORYDENY.toString().replace("{owners}", myFaction.getOwnerListString(loc)));
if (landOwned && !myFaction.getOwnerListString(loc).contains(player.getName())) { if (shouldHurt) {
me.msg(TL.ACTIONS_OWNEDTERRITORYDENY.toString().replace("{owners}", myFaction.getOwnerListString(loc))); player.damage(Conf.actionDeniedPainAmount);
if (shouldHurt) { me.msg(TL.ACTIONS_NOPERMISSIONPAIN.toString().replace("{action}", action.toString()).replace("{faction}", Board.getInstance().getFactionAt(loc).getTag(myFaction)));
player.damage(Conf.actionDeniedPainAmount); }
me.msg(replace.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
return false; if (shouldHurt) {
} else if (!landOwned && access == Access.DENY) { // If land is not owned but access is set to DENY anyway player.damage(Conf.actionDeniedPainAmount);
if (shouldHurt) { if ((Board.getInstance().getFactionAt(loc).getTag(myFaction)) != null)
player.damage(Conf.actionDeniedPainAmount); me.msg(TL.ACTIONS_NOPERMISSIONPAIN.toString().replace("{action}", action.toString()).replace("{faction}", Board.getInstance().getFactionAt(loc).getTag(myFaction)));
if ((Board.getInstance().getFactionAt(loc).getTag(myFaction)) != null) }
me.msg(replace.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()));
if (myFaction.getTag(me.getFaction()) != null && action != null) return false;
me.msg(TL.ACTIONS_NOPERMISSION.toString().replace("{faction}", myFaction.getTag(me.getFaction())).replace("{action}", action.toString())); } else if (access == Access.ALLOW) return true;
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())); me.msg(TL.ACTIONS_NOPERMISSION.toString().replace("{faction}", myFaction.getTag(me.getFaction())).replace("{action}", action.toString()));
return false; return false;
} }
@@ -416,9 +413,8 @@ public class FactionsBlockListener implements Listener {
@EventHandler(priority = EventPriority.NORMAL, ignoreCancelled = true) @EventHandler(priority = EventPriority.NORMAL, ignoreCancelled = true)
public void onFrostWalker(EntityBlockFormEvent event) { public void onFrostWalker(EntityBlockFormEvent event) {
if (event.getEntity() == null || event.getEntity().getType() != EntityType.PLAYER || event.getBlock() == null) { if (event.getEntity() == null || event.getEntity().getType() != EntityType.PLAYER || event.getBlock() == null)
return; return;
}
Player player = (Player) event.getEntity(); Player player = (Player) event.getEntity();
Location location = event.getBlock().getLocation(); Location location = event.getBlock().getLocation();
@@ -426,14 +422,10 @@ public class FactionsBlockListener implements Listener {
// only notify every 10 seconds // only notify every 10 seconds
FPlayer fPlayer = FPlayers.getInstance().getByPlayer(player); FPlayer fPlayer = FPlayers.getInstance().getByPlayer(player);
boolean justCheck = fPlayer.getLastFrostwalkerMessage() + 10000 > System.currentTimeMillis(); boolean justCheck = fPlayer.getLastFrostwalkerMessage() + 10000 > System.currentTimeMillis();
if (!justCheck) { if (!justCheck) fPlayer.setLastFrostwalkerMessage();
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)) { if (!playerCanBuildDestroyBlock(player, location, PermissableAction.FROST_WALK.toString(), justCheck)) event.setCancelled(true);
event.setCancelled(true);
}
} }
@EventHandler @EventHandler
@@ -448,29 +440,6 @@ public class FactionsBlockListener implements Listener {
} }
} }
//Grace
@EventHandler
public void onBreak(EntityExplodeEvent e) {
if (!Conf.gracePeriod) return;
e.setCancelled(true);
}
@EventHandler
public void onTNTPlace(BlockPlaceEvent e1) {
FPlayer fp = FPlayers.getInstance().getByPlayer(e1.getPlayer());
if (!Conf.gracePeriod) return;
if (!fp.isAdminBypassing()) {
if (e1.getBlock().getType().equals(Material.TNT)) {
e1.setCancelled(true);
fp.msg(TL.COMMAND_GRACE_ENABLED, e1.getBlockPlaced().getType().toString());
}
}
}
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));
@@ -493,7 +462,6 @@ public class FactionsBlockListener implements Listener {
Faction at = Board.getInstance().getFactionAt(new FLocation(block)); Faction at = Board.getInstance().getFactionAt(new FLocation(block));
boolean isSpawner = event.getBlock().getType().equals(XMaterial.SPAWNER.parseMaterial()); boolean isSpawner = event.getBlock().getType().equals(XMaterial.SPAWNER.parseMaterial());
if (!playerCanBuildDestroyBlock(event.getPlayer(), event.getBlock().getLocation(), "destroy", false)) { if (!playerCanBuildDestroyBlock(event.getPlayer(), event.getBlock().getLocation(), "destroy", false)) {
event.setCancelled(true); event.setCancelled(true);
return; return;
@@ -538,6 +506,7 @@ public class FactionsBlockListener implements Listener {
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

@@ -7,7 +7,6 @@ import com.massivecraft.factions.util.MiscUtil;
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;
import org.bukkit.Material;
import org.bukkit.block.Block; import org.bukkit.block.Block;
import org.bukkit.entity.*; import org.bukkit.entity.*;
import org.bukkit.entity.minecart.ExplosiveMinecart; import org.bukkit.entity.minecart.ExplosiveMinecart;
@@ -95,11 +94,9 @@ public class FactionsEntityListener implements Listener {
public void onEntityDamage(EntityDamageEvent event) { public void onEntityDamage(EntityDamageEvent event) {
if (event instanceof EntityDamageByEntityEvent) { if (event instanceof EntityDamageByEntityEvent) {
EntityDamageByEntityEvent sub = (EntityDamageByEntityEvent) event; EntityDamageByEntityEvent sub = (EntityDamageByEntityEvent) event;
if (!this.canDamagerHurtDamagee(sub, true)) { if (!this.canDamagerHurtDamagee(sub, true)) event.setCancelled(true);
event.setCancelled(true);
}
// event is not cancelled by factions
// event is not cancelled by factions
Entity damagee = sub.getEntity(); Entity damagee = sub.getEntity();
Entity damager = sub.getDamager(); Entity damager = sub.getDamager();
if (damagee instanceof Player) { if (damagee instanceof Player) {
@@ -126,15 +123,12 @@ public class FactionsEntityListener implements Listener {
// this should disable the fly so // this should disable the fly so
return; return;
} }
} else { } else return; // this should trigger if the attacker shootin the arrow is a mob
// this should trigger if the attacker shootin the arrow is a mob
return;
}
} }
} }
} else { } else {
// Protect armor stands/item frames from being damaged in protected territories // Protect armor stands/item frames from being damaged in protected territories
if (damagee.getType() == EntityType.ITEM_FRAME || damagee.getType().name().equals("armor_stand")) { if (damagee.getType() == EntityType.ITEM_FRAME || damagee.getType() == EntityType.ARMOR_STAND) {
// Manage projectiles launched by players // Manage projectiles launched by players
if (damager instanceof Projectile && ((Projectile) damager).getShooter() instanceof Entity) { if (damager instanceof Projectile && ((Projectile) damager).getShooter() instanceof Entity) {
damager = (Entity) ((Projectile) damager).getShooter(); damager = (Entity) ((Projectile) damager).getShooter();
@@ -142,37 +136,22 @@ public class FactionsEntityListener implements Listener {
// Run the check for a player // Run the check for a player
if (damager instanceof Player) { if (damager instanceof Player) {
Player player = (Player) damager;
Material material = null; if (!FactionsBlockListener.playerCanBuildDestroyBlock((Player) damager, damagee.getLocation(), "destroy", false))
switch (sub.getEntity().getType()) {
case ITEM_FRAME:
material = Material.ITEM_FRAME;
break;
case ARMOR_STAND:
material = Material.ARMOR_STAND;
break;
}
if (material != null && !FactionsBlockListener.playerCanBuildDestroyBlock(player, damagee.getLocation(), "destroy " + material.toString().toLowerCase(), false)) {
event.setCancelled(true); event.setCancelled(true);
}
} 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
return; return;
} }
//this one should trigger if something other than a player takes damage //this one should trigger if something other than a player takes damage
if (damager instanceof Player) { if (damager instanceof Player) return;
// now itll only go here if the damage is dealt by a player
return;
// we cancel it so fly isnt removed when you hit a mob etc
}
} }
if (damagee != null && damagee instanceof Player) { if (damagee != null && damagee instanceof Player) {
cancelFStuckTeleport((Player) damagee); cancelFStuckTeleport((Player) damagee);
@@ -216,6 +195,7 @@ public class FactionsEntityListener implements Listener {
} }
} }
private void cancelFFly(Player player) { private void cancelFFly(Player player) {
if (player == null) return; if (player == null) return;
FPlayer fPlayer = FPlayers.getInstance().getByPlayer(player); FPlayer fPlayer = FPlayers.getInstance().getByPlayer(player);
@@ -361,26 +341,39 @@ public class FactionsEntityListener implements Listener {
if (!(damagee instanceof Player)) return true; if (!(damagee instanceof Player)) return true;
FPlayer defender = FPlayers.getInstance().getByPlayer((Player) damagee); FPlayer defender = FPlayers.getInstance().getByPlayer((Player) damagee);
if (defender == null || defender.getPlayer() == null) return true;
if (damager instanceof Player) {
FPlayer attacker = FPlayers.getInstance().getByPlayer((Player) damager);
if (defender == null || defender.getPlayer() == null) return true;
if (attacker.getFaction() == defender.getFaction()) {
if (attacker.hasFriendlyFire() && defender.hasFriendlyFire()) return true;
if (attacker.hasFriendlyFire() && !defender.hasFriendlyFire()) {
attacker.msg(TL.FRIENDLY_FIRE_OFF_ATTACKER, defender.getName());
return false;
} else if (!attacker.hasFriendlyFire() && defender.hasFriendlyFire()) {
attacker.msg(TL.FRIENDLY_FIRE_YOU_MUST);
return false;
}
}
}
Location defenderLoc = defender.getPlayer().getLocation(); Location defenderLoc = defender.getPlayer().getLocation();
Faction defLocFaction = Board.getInstance().getFactionAt(new FLocation(defenderLoc)); Faction defLocFaction = Board.getInstance().getFactionAt(new FLocation(defenderLoc));
// for damage caused by projectiles, getDamager() returns the projectile... what we need to know is the source // for damage caused by projectiles, getDamager() returns the projectile... what we need to know is the source
if (damager instanceof Projectile) { if (damager instanceof Projectile) {
Projectile projectile = (Projectile) damager; Projectile projectile = (Projectile) damager;
if (!(projectile.getShooter() instanceof Entity)) return true; if (!(projectile.getShooter() instanceof Entity)) return true;
damager = (Entity) projectile.getShooter(); damager = (Entity) projectile.getShooter();
} }
if (damager == damagee) return true; // ender pearl usage and other self-inflicted damage if (damager == damagee) return true; // ender pearl usage and other self-inflicted damage
// Players can not take attack damage in a SafeZone, or possibly peaceful territory // Players can not take attack damage in a SafeZone or peaceful territory depending on Conf options.
if (defLocFaction.noPvPInTerritory()) { if (defLocFaction.noPvPInTerritory()) {
if (damager instanceof Player) { if (damager instanceof Player) {
if (notify) { if (notify) {
@@ -394,19 +387,14 @@ public class FactionsEntityListener implements Listener {
if (!(damager instanceof Player)) return true; if (!(damager instanceof Player)) return true;
FPlayer attacker = FPlayers.getInstance().getByPlayer((Player) damager); FPlayer attacker = FPlayers.getInstance().getByPlayer((Player) damager);
if (attacker == null || attacker.getPlayer() == null) return true; if (attacker == null || attacker.getPlayer() == null) return true;
if (Conf.playersWhoBypassAllProtection.contains(attacker.getName())) return true; if (Conf.playersWhoBypassAllProtection.contains(attacker.getName())) return true;
if (attacker.hasLoginPvpDisabled()) { if (attacker.hasLoginPvpDisabled()) {
if (notify) { if (notify) attacker.msg(TL.PLAYER_PVP_LOGIN, Conf.noPVPDamageToOthersForXSecondsAfterLogin);
attacker.msg(TL.PLAYER_PVP_LOGIN, Conf.noPVPDamageToOthersForXSecondsAfterLogin);
}
return false; return false;
} }
@@ -414,47 +402,32 @@ public class FactionsEntityListener implements Listener {
// so we know from above that the defender isn't in a safezone... what about the attacker, sneaky dog that he might be? // so we know from above that the defender isn't in a safezone... what about the attacker, sneaky dog that he might be?
if (locFaction.noPvPInTerritory()) { if (locFaction.noPvPInTerritory()) {
if (notify) { if (notify)
attacker.msg(TL.PLAYER_CANTHURT, (locFaction.isSafeZone() ? TL.REGION_SAFEZONE.toString() : TL.REGION_PEACEFUL.toString())); attacker.msg(TL.PLAYER_CANTHURT, (locFaction.isSafeZone() ? TL.REGION_SAFEZONE.toString() : TL.REGION_PEACEFUL.toString()));
}
return false; return false;
} }
if (locFaction.isWarZone() && Conf.warZoneFriendlyFire) return true; if (locFaction.isWarZone() && Conf.warZoneFriendlyFire) return true;
if (Conf.worldsIgnorePvP.contains(defenderLoc.getWorld().getName())) return true; if (Conf.worldsIgnorePvP.contains(defenderLoc.getWorld().getName())) return true;
Faction defendFaction = defender.getFaction(); Faction defendFaction = defender.getFaction();
Faction attackFaction = attacker.getFaction(); Faction attackFaction = attacker.getFaction();
if (attackFaction.isWilderness() && Conf.disablePVPForFactionlessPlayers) { if (attackFaction.isWilderness() && Conf.disablePVPForFactionlessPlayers) {
if (notify) { if (notify) attacker.msg(TL.PLAYER_PVP_REQUIREFACTION);
attacker.msg(TL.PLAYER_PVP_REQUIREFACTION);
}
return false; return false;
} else if (defendFaction.isWilderness()) { } else if (defendFaction.isWilderness()) {
if (defLocFaction == attackFaction && Conf.enablePVPAgainstFactionlessInAttackersLand) { if (defLocFaction == attackFaction && Conf.enablePVPAgainstFactionlessInAttackersLand) {
// Allow PVP vs. Factionless in attacker's faction territory // Allow PVP vs. Factionless in attacker's faction territory
return true; return true;
} else if (Conf.disablePVPForFactionlessPlayers) { } else if (Conf.disablePVPForFactionlessPlayers) {
if (notify) { if (notify) attacker.msg(TL.PLAYER_PVP_FACTIONLESS);
attacker.msg(TL.PLAYER_PVP_FACTIONLESS);
}
return false; return false;
} }
} }
if (defendFaction.isPeaceful()) { if (defendFaction.isPeaceful() || attackFaction.isPeaceful()) {
if (notify) { if (notify) attacker.msg(TL.PLAYER_PVP_PEACEFUL);
attacker.msg(TL.PLAYER_PVP_PEACEFUL);
}
return false;
} else if (attackFaction.isPeaceful()) {
if (notify) {
attacker.msg(TL.PLAYER_PVP_PEACEFUL);
}
return false; return false;
} }
@@ -462,21 +435,16 @@ public class FactionsEntityListener implements Listener {
// You can not hurt neutral factions // You can not hurt neutral factions
if (Conf.disablePVPBetweenNeutralFactions && relation.isNeutral()) { if (Conf.disablePVPBetweenNeutralFactions && relation.isNeutral()) {
if (notify) { if (notify) attacker.msg(TL.PLAYER_PVP_NEUTRAL);
attacker.msg(TL.PLAYER_PVP_NEUTRAL);
}
return false; return false;
} }
// Players without faction may be hurt anywhere // Players without faction may be hurt anywhere
if (!defender.hasFaction()) return true; if (!defender.hasFaction()) return true;
// You can never hurt faction members or allies // You can never hurt faction members or allies
if (relation.isMember() || relation.isAlly() || relation.isTruce()) { if (relation.isMember() || relation.isAlly()) {
if (notify) { if (notify) attacker.msg(TL.PLAYER_PVP_CANTHURT, defender.describeTo(attacker));
attacker.msg(TL.PLAYER_PVP_CANTHURT, defender.describeTo(attacker));
}
return false; return false;
} }
@@ -490,23 +458,10 @@ public class FactionsEntityListener implements Listener {
} }
return false; return false;
} }
// Damage will be dealt. However check if the damage should be reduced.
/*
if (damage > 0.0 && ownTerritory && Conf.territoryShieldFactor > 0) {
double newDamage = Math.ceil(damage * (1D - Conf.territoryShieldFactor));
sub.setDamage(newDamage);
// Send message
if (notify) {
String perc = MessageFormat.format("{0,number,#%}", (Conf.territoryShieldFactor)); // TODO does this display correctly??
defender.msg("<i>Enemy damage reduced by <rose>%s<i>.", perc);
}
} */
return true; return true;
} }
@EventHandler(priority = EventPriority.NORMAL, ignoreCancelled = true) @EventHandler(priority = EventPriority.NORMAL, ignoreCancelled = true)
public void onCreatureSpawn(CreatureSpawnEvent event) { public void onCreatureSpawn(CreatureSpawnEvent event) {
if (event.getLocation() == null) return; if (event.getLocation() == null) return;
@@ -557,14 +512,10 @@ public class FactionsEntityListener implements Listener {
@EventHandler @EventHandler
public void onHangerBreak(HangingBreakByEntityEvent e) { public void onHangerBreak(HangingBreakByEntityEvent e) {
if (e.getRemover() == null) return;
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().equals(EntityType.PAINTING)) {
if (!FactionsBlockListener.playerCanBuildDestroyBlock(p, e.getEntity().getLocation(), "destroy", false)) { if (e.getEntity().getType() == EntityType.PAINTING || e.getEntity().getType() == EntityType.ITEM_FRAME) {
e.setCancelled(true);
}
} else if (e.getEntity().getType().equals(EntityType.ITEM_FRAME)) {
if (!FactionsBlockListener.playerCanBuildDestroyBlock(p, e.getEntity().getLocation(), "destroy", false)) { if (!FactionsBlockListener.playerCanBuildDestroyBlock(p, e.getEntity().getLocation(), "destroy", false)) {
e.setCancelled(true); e.setCancelled(true);
} }
@@ -572,48 +523,38 @@ public class FactionsEntityListener implements Listener {
} }
@EventHandler(priority = EventPriority.NORMAL, ignoreCancelled = true) @EventHandler(priority = EventPriority.NORMAL, ignoreCancelled = true)
public void onPaintingPlace(HangingPlaceEvent event) { public void onPaintingPlace(HangingPlaceEvent e) {
if (event.getEntity().getType().equals(EntityType.PAINTING)) { if (e.getPlayer() == null) return;
if (!FactionsBlockListener.playerCanBuildDestroyBlock(event.getPlayer(), event.getBlock().getLocation(), "build", false)) {
event.setCancelled(true); if (e.getEntity().getType() == EntityType.PAINTING || e.getEntity().getType() == EntityType.ITEM_FRAME) {
// Fix: update player's inventory to avoid items glitches if (!FactionsBlockListener.playerCanBuildDestroyBlock(e.getPlayer(), e.getBlock().getLocation(), "build", false)) {
event.getPlayer().updateInventory(); e.setCancelled(true);
} e.getPlayer().updateInventory();
} else if (event.getEntity().getType().equals(EntityType.ITEM_FRAME)) {
if (!FactionsBlockListener.playerCanBuildDestroyBlock(event.getPlayer(), event.getEntity().getLocation(), "build", false)) {
event.setCancelled(true);
// Fix: update player's inventory to avoid items glitches
event.getPlayer().updateInventory();
} }
} }
} }
@EventHandler(priority = EventPriority.NORMAL, ignoreCancelled = true) @EventHandler(priority = EventPriority.NORMAL, ignoreCancelled = true)
public void onEntityChangeBlock(EntityChangeBlockEvent event) { public void onEntityChangeBlock(EntityChangeBlockEvent e) {
Entity entity = event.getEntity(); Entity entity = e.getEntity();
Location loc = e.getBlock().getLocation();
// for now, only interested in Enderman and Wither boss tomfoolery // for now, only interested in Enderman and Wither boss tomfoolery
if (!(entity instanceof Enderman) && !(entity instanceof Wither)) return; if (entity.getType() == EntityType.ENDERMAN) {
if (stopEndermanBlockManipulation(loc)) e.setCancelled(true);
} else if (entity.getType() == EntityType.WITHER) {
Location loc = event.getBlock().getLocation();
if (entity instanceof Enderman) {
if (stopEndermanBlockManipulation(loc)) {
event.setCancelled(true);
}
} else if (entity instanceof Wither) {
Faction faction = Board.getInstance().getFactionAt(new FLocation(loc)); Faction faction = Board.getInstance().getFactionAt(new FLocation(loc));
// it's a bit crude just using fireball protection, but I'd rather not add in a whole new set of xxxBlockWitherExplosion or whatever // it's a bit crude just using fireball protection, but I'd rather not add in a whole new set of xxxBlockWitherExplosion or whatever
if ((faction.isWilderness() && Conf.wildernessBlockFireballs && !Conf.worldsNoWildernessProtection.contains(loc.getWorld().getName())) || if ((faction.isWilderness() && Conf.wildernessBlockFireballs && !Conf.worldsNoWildernessProtection.contains(loc.getWorld().getName())) ||
(faction.isNormal() && (faction.hasPlayersOnline() ? Conf.territoryBlockFireballs : Conf.territoryBlockFireballsWhenOffline)) || (faction.isNormal() && (faction.hasPlayersOnline() ? Conf.territoryBlockFireballs : Conf.territoryBlockFireballsWhenOffline)) ||
(faction.isWarZone() && Conf.warZoneBlockFireballs) || (faction.isWarZone() && Conf.warZoneBlockFireballs) ||
faction.isSafeZone()) { faction.isSafeZone()) {
event.setCancelled(true); e.setCancelled(true);
} }
} }
} }
/* /*
@EventHandler @EventHandler
public void onTravel(PlayerPortalEvent event) { public void onTravel(PlayerPortalEvent event) {

View File

@@ -4,6 +4,7 @@ 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;
@@ -19,12 +20,12 @@ import com.massivecraft.factions.struct.Permission;
import com.massivecraft.factions.struct.Relation; import com.massivecraft.factions.struct.Relation;
import com.massivecraft.factions.struct.Role; import com.massivecraft.factions.struct.Role;
import com.massivecraft.factions.util.CC; import com.massivecraft.factions.util.CC;
import com.massivecraft.factions.util.wait.WaitExecutor;
import com.massivecraft.factions.zcore.frame.FactionGUI;
import com.massivecraft.factions.util.VisualizeUtil; import com.massivecraft.factions.util.VisualizeUtil;
import com.massivecraft.factions.util.XMaterial; import com.massivecraft.factions.util.XMaterial;
import com.massivecraft.factions.util.wait.WaitExecutor;
import com.massivecraft.factions.zcore.fperms.Access; import com.massivecraft.factions.zcore.fperms.Access;
import com.massivecraft.factions.zcore.fperms.PermissableAction; import com.massivecraft.factions.zcore.fperms.PermissableAction;
import com.massivecraft.factions.zcore.frame.FactionGUI;
import com.massivecraft.factions.zcore.persist.MemoryFPlayer; import com.massivecraft.factions.zcore.persist.MemoryFPlayer;
import com.massivecraft.factions.zcore.util.TL; import com.massivecraft.factions.zcore.util.TL;
import com.massivecraft.factions.zcore.util.TagUtil; import com.massivecraft.factions.zcore.util.TagUtil;
@@ -569,19 +570,17 @@ public class FactionsPlayerListener implements Listener {
.replace("{leader}", faction.getFPlayerAdmin() + ""); .replace("{leader}", faction.getFPlayerAdmin() + "");
return string; return string;
} }
@Deprecated
public void checkCanFly(FPlayer me) { public void checkCanFly(FPlayer me) {
if (!FactionsPlugin.getInstance().getConfig().getBoolean("enable-faction-flight")) return; if (!FactionsPlugin.getInstance().getConfig().getBoolean("enable-faction-flight") || !FactionsPlugin.instance.getConfig().getBoolean("ffly.AutoEnable"))
if (me.isFlying() && !me.isVanished() && (!me.canFlyAtLocation() || me.checkIfNearbyEnemies())) {
me.setFFlying(false, false);
me.msg(TL.COMMAND_FLY_NO_ACCESS, Board.getInstance().getFactionAt(me.getLastStoodAt()).getTag());
return; return;
if (me.isFlying()) return;
if (me.getPlayer().hasPermission(Permission.FLY_FLY.node)) {
me.setFFlying(true, false);
CmdFly.flyMap.put(me.getName(), true);
if (CmdFly.particleTask == null)
CmdFly.startParticles();
} }
if (me.isFlying() || !FactionsPlugin.instance.getConfig().getBoolean("ffly.AutoEnable")) return;
me.setFFlying(true, false);
CmdFly.flyMap.put(me.getName(), true);
if (CmdFly.particleTask == null)
CmdFly.startParticles();
} }
//inspect //inspect
@@ -656,33 +655,6 @@ public class FactionsPlayerListener implements Listener {
} }
refreshPosition(player, lastLocations.get(player.getUniqueId()), player.getLocation()); refreshPosition(player, lastLocations.get(player.getUniqueId()), player.getLocation());
lastLocations.put(player.getUniqueId(), player.getLocation()); lastLocations.put(player.getUniqueId(), player.getLocation());
if (CmdFly.flyMap.containsKey(player.getName())) {
String name = player.getName();
if (!player.isFlying()
|| player.getGameMode() == GameMode.CREATIVE
|| !FactionsPlugin.instance.mc17 && player.getGameMode() == GameMode.SPECTATOR) {
continue;
}
FPlayer fPlayer = FPlayers.getInstance().getByPlayer(player);
Faction myFaction = fPlayer.getFaction();
if (myFaction.isWilderness()) {
Bukkit.getScheduler().runTask(FactionsPlugin.instance, () -> fPlayer.setFlying(false));
CmdFly.flyMap.remove(player.getName());
continue;
}
Bukkit.getScheduler().runTask(FactionsPlugin.instance, () -> {
if (!fPlayer.checkIfNearbyEnemies()) {
FLocation myFloc = new FLocation(player.getLocation());
if (Board.getInstance().getFactionAt(myFloc) != myFaction) {
if (!CmdFly.checkFly(fPlayer, player, Board.getInstance().getFactionAt(myFloc))) {
fPlayer.setFFlying(false, false);
CmdFly.flyMap.remove(name);
}
}
}
});
}
} }
} }
}, 5L, 10L); }, 5L, 10L);
@@ -747,7 +719,13 @@ public class FactionsPlayerListener implements Listener {
}, 5); }, 5);
} }
} }
this.checkCanFly(me); if (FCmdRoot.instance.fFlyEnabled && CmdFly.autoenable && CmdFly.checkFly(me, me.getPlayer(), factionTo)) {
me.setFFlying(true, false);
CmdFly.flyMap.put(me.getName(), true);
if (CmdFly.particleTask == null)
CmdFly.startParticles();
}
if (me.getAutoClaimFor() != null) { if (me.getAutoClaimFor() != null) {
me.attemptClaim(me.getAutoClaimFor(), newLocation, true); me.attemptClaim(me.getAutoClaimFor(), newLocation, true);

View File

@@ -2,8 +2,8 @@ package com.massivecraft.factions.missions;
import com.massivecraft.factions.FPlayer; import com.massivecraft.factions.FPlayer;
import com.massivecraft.factions.FactionsPlugin; import com.massivecraft.factions.FactionsPlugin;
import com.massivecraft.factions.zcore.frame.FactionGUI;
import com.massivecraft.factions.util.XMaterial; import com.massivecraft.factions.util.XMaterial;
import com.massivecraft.factions.zcore.frame.FactionGUI;
import com.massivecraft.factions.zcore.util.TL; import com.massivecraft.factions.zcore.util.TL;
import org.bukkit.ChatColor; import org.bukkit.ChatColor;
import org.bukkit.configuration.ConfigurationSection; import org.bukkit.configuration.ConfigurationSection;

View File

@@ -11,10 +11,8 @@ import com.massivecraft.factions.util.XMaterial;
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.ChatColor; import org.bukkit.ChatColor;
import org.bukkit.Material;
import org.bukkit.configuration.ConfigurationSection; import org.bukkit.configuration.ConfigurationSection;
import org.bukkit.enchantments.Enchantment; import org.bukkit.enchantments.Enchantment;
import org.bukkit.entity.Item;
import org.bukkit.entity.Player; import org.bukkit.entity.Player;
import org.bukkit.inventory.ItemFlag; import org.bukkit.inventory.ItemFlag;
import org.bukkit.inventory.ItemStack; import org.bukkit.inventory.ItemStack;
@@ -22,7 +20,6 @@ import org.bukkit.inventory.meta.ItemMeta;
import java.util.ArrayList; import java.util.ArrayList;
import java.util.List; import java.util.List;
import java.util.Objects;
import java.util.stream.Collectors; import java.util.stream.Collectors;
public class ShopGUIFrame { public class ShopGUIFrame {

View File

@@ -54,8 +54,10 @@ public enum Permission {
FLY_TRUCE("fly.truce"), FLY_TRUCE("fly.truce"),
FLY_NEUTRAL("fly.neutral"), FLY_NEUTRAL("fly.neutral"),
FOCUS("focus"), FOCUS("focus"),
FRIENDLYFIRE("friendlyfire"),
GLOBALCHAT("globalchat"), GLOBALCHAT("globalchat"),
GRACE("grace"), GRACE("grace"),
GRACETOGGLE("gracetoggle"),
HELP("help"), HELP("help"),
HOME("home"), HOME("home"),
INVITE("invite"), INVITE("invite"),

View File

@@ -18,6 +18,7 @@ public enum FancyTag implements Tag {
* @author FactionsUUID Team * @author FactionsUUID Team
*/ */
NEUTRAL_LIST("{neutral-list}", (target, fme, prefix, gm) -> processRelation(prefix, target, fme, Relation.NEUTRAL)),
ALLIES_LIST("{allies-list}", (target, fme, prefix, gm) -> processRelation(prefix, target, fme, Relation.ALLY)), ALLIES_LIST("{allies-list}", (target, fme, prefix, gm) -> processRelation(prefix, target, fme, Relation.ALLY)),
ENEMIES_LIST("{enemies-list}", (target, fme, prefix, gm) -> processRelation(prefix, target, fme, Relation.ENEMY)), ENEMIES_LIST("{enemies-list}", (target, fme, prefix, gm) -> processRelation(prefix, target, fme, Relation.ENEMY)),
TRUCES_LIST("{truces-list}", (target, fme, prefix, gm) -> processRelation(prefix, target, fme, Relation.TRUCE)), TRUCES_LIST("{truces-list}", (target, fme, prefix, gm) -> processRelation(prefix, target, fme, Relation.TRUCE)),

View File

@@ -2,6 +2,7 @@ package com.massivecraft.factions.tag;
import com.massivecraft.factions.FPlayers; import com.massivecraft.factions.FPlayers;
import com.massivecraft.factions.FactionsPlugin; import com.massivecraft.factions.FactionsPlugin;
import com.massivecraft.factions.util.timer.TimerManager;
import com.massivecraft.factions.zcore.util.TL; import com.massivecraft.factions.zcore.util.TL;
import org.bukkit.Bukkit; import org.bukkit.Bukkit;
@@ -12,7 +13,7 @@ public enum GeneralTag implements Tag {
/** /**
* @author FactionsUUID Team * @author FactionsUUID Team
*/ */
GRACE_TIMER("{grace-time}", () -> String.valueOf(TimerManager.getRemaining(FactionsPlugin.getInstance().getTimerManager().graceTimer.getRemaining(), true))),
MAX_WARPS("{max-warps}", () -> String.valueOf(FactionsPlugin.getInstance().getConfig().getInt("max-warps", 5))), MAX_WARPS("{max-warps}", () -> String.valueOf(FactionsPlugin.getInstance().getConfig().getInt("max-warps", 5))),
MAX_ALLIES("{max-allies}", () -> getRelation("ally")), MAX_ALLIES("{max-allies}", () -> getRelation("ally")),
MAX_ENEMIES("{max-enemies}", () -> getRelation("enemy")), MAX_ENEMIES("{max-enemies}", () -> getRelation("enemy")),

View File

@@ -1,7 +1,6 @@
package com.massivecraft.factions.tag; package com.massivecraft.factions.tag;
import com.massivecraft.factions.FPlayer; import com.massivecraft.factions.FPlayer;
import com.massivecraft.factions.FactionsPlugin;
import com.massivecraft.factions.integration.Econ; import com.massivecraft.factions.integration.Econ;
import com.massivecraft.factions.zcore.util.TL; import com.massivecraft.factions.zcore.util.TL;
import org.apache.commons.lang.time.DurationFormatUtils; import org.apache.commons.lang.time.DurationFormatUtils;
@@ -16,13 +15,6 @@ public enum PlayerTag implements Tag {
/** /**
* @author FactionsUUID Team * @author FactionsUUID Team
*/ */
GROUP("{group}", (fp) -> {
if (fp.isOnline()) {
return FactionsPlugin.getInstance().getPrimaryGroup(fp.getPlayer());
} else {
return "";
}
}),
LAST_SEEN("{lastSeen}", (fp) -> { LAST_SEEN("{lastSeen}", (fp) -> {
String humanized = DurationFormatUtils.formatDurationWords(System.currentTimeMillis() - fp.getLastLoginTime(), true, true) + TL.COMMAND_STATUS_AGOSUFFIX; String humanized = DurationFormatUtils.formatDurationWords(System.currentTimeMillis() - fp.getLastLoginTime(), true, true) + TL.COMMAND_STATUS_AGOSUFFIX;
return fp.isOnline() ? ChatColor.GREEN + TL.COMMAND_STATUS_ONLINE.toString() : (System.currentTimeMillis() - fp.getLastLoginTime() < 432000000 ? ChatColor.YELLOW + humanized : ChatColor.RED + humanized); return fp.isOnline() ? ChatColor.GREEN + TL.COMMAND_STATUS_ONLINE.toString() : (System.currentTimeMillis() - fp.getLastLoginTime() < 432000000 ? ChatColor.YELLOW + humanized : ChatColor.RED + humanized);

View File

@@ -5,6 +5,7 @@ import com.massivecraft.factions.integration.Econ;
import com.massivecraft.factions.struct.Relation; import com.massivecraft.factions.struct.Relation;
import com.massivecraft.factions.tag.FactionTag; import com.massivecraft.factions.tag.FactionTag;
import com.massivecraft.factions.tag.Tag; import com.massivecraft.factions.tag.Tag;
import com.massivecraft.factions.util.timer.TimerManager;
import com.massivecraft.factions.zcore.util.TL; import com.massivecraft.factions.zcore.util.TL;
import me.clip.placeholderapi.expansion.PlaceholderExpansion; import me.clip.placeholderapi.expansion.PlaceholderExpansion;
import me.clip.placeholderapi.expansion.Relational; import me.clip.placeholderapi.expansion.Relational;
@@ -209,8 +210,8 @@ public class ClipPlaceholderAPIManager extends PlaceholderExpansion implements R
return String.valueOf(faction.getMaxVaults()); return String.valueOf(faction.getMaxVaults());
case "faction_relation_color": case "faction_relation_color":
return fPlayer.getColorTo(faction).toString(); return fPlayer.getColorTo(faction).toString();
case "faction_grace": case "faction_grace_time":
return Conf.gracePeriod ? "Enabled" : "Disabled"; return String.valueOf(TimerManager.getRemaining(FactionsPlugin.getInstance().getTimerManager().graceTimer.getRemaining(), true));
case "faction_name_at_location": case "faction_name_at_location":
Faction factionAtLocation = Board.getInstance().getFactionAt(new FLocation(player.getLocation())); Faction factionAtLocation = Board.getInstance().getFactionAt(new FLocation(player.getLocation()));
return factionAtLocation != null ? factionAtLocation.getTag() : Factions.getInstance().getWilderness().getTag(); return factionAtLocation != null ? factionAtLocation.getTag() : Factions.getInstance().getWilderness().getTag();

View File

@@ -0,0 +1,82 @@
package com.massivecraft.factions.util;
import com.massivecraft.factions.FactionsPlugin;
import org.bukkit.configuration.file.YamlConfiguration;
import java.io.File;
import java.util.Objects;
/**
* Factions - Developed by Driftay.
* All rights reserved 2020.
* Creation Date: 4/7/2020
*/
public class Config extends YamlConfiguration {
private String fileName;
private FactionsPlugin plugin;
public Config(FactionsPlugin plugin, String fileName) {
this(plugin, fileName, ".yml");
}
public Config(FactionsPlugin plugin, String fileName, String fileExtension) {
this.plugin = plugin;
this.fileName = fileName + (fileName.endsWith(fileExtension) ? "" : fileExtension);
this.createFile();
}
public String getFileName() {
return this.fileName;
}
public FactionsPlugin getPlugin() {
return this.plugin;
}
private void createFile() {
File folder = this.plugin.getDataFolder();
try {
File ex = new File(folder, this.fileName);
if (!ex.exists()) {
if (this.plugin.getResource(this.fileName) != null) {
this.plugin.saveResource(this.fileName, false);
} else {
this.save(ex);
}
} else {
this.load(ex);
this.save(ex);
}
} catch (Exception e) {
e.printStackTrace();
}
}
public void save() {
File folder = this.plugin.getDataFolder();
try {
this.save(new File(folder, this.fileName));
} catch (Exception e) {
e.printStackTrace();
}
}
public boolean equals(Object o) {
if (this == o) {
return true;
}
if (!(o instanceof Config)) {
return false;
}
Config config = (Config) o;
if (this.fileName != null) {
if (this.fileName.equals(config.fileName)) {
return Objects.equals(this.plugin, config.plugin);
}
} else if (config.fileName == null) {
return Objects.equals(this.plugin, config.plugin);
}
return false;
}
}

View File

@@ -0,0 +1,27 @@
package com.massivecraft.factions.util;
import com.massivecraft.factions.FactionsPlugin;
import org.bukkit.entity.Player;
import org.bukkit.metadata.FixedMetadataValue;
import org.bukkit.metadata.MetadataValue;
import java.util.concurrent.TimeUnit;
/**
* Factions - Developed by Driftay.
* All rights reserved 2020.
* Creation Date: 4/6/2020
*/
public class Cooldown {
public static void setCooldown(Player player, String name, int seconds) {
player.setMetadata(name, new FixedMetadataValue(FactionsPlugin.getInstance(), System.currentTimeMillis() + TimeUnit.SECONDS.toMillis(seconds)));
}
public static boolean isOnCooldown(Player player, String name) {
if (!player.hasMetadata(name) || player.getMetadata(name).size() <= 0) return false;
long time = player.getMetadata(name).get(0).asLong();
return (time > System.currentTimeMillis());
}
}

View File

@@ -5,7 +5,7 @@ package com.massivecraft.factions.util;
* All rights reserved 2020. * All rights reserved 2020.
* Creation Date: 4/4/2020 * Creation Date: 4/4/2020
*/ */
import com.massivecraft.factions.util.XMaterial;
import org.bukkit.Bukkit; import org.bukkit.Bukkit;
import org.bukkit.Color; import org.bukkit.Color;
import org.bukkit.Location; import org.bukkit.Location;

View File

@@ -5,6 +5,7 @@ package com.massivecraft.factions.util;
* All rights reserved 2020. * All rights reserved 2020.
* Creation Date: 4/4/2020 * Creation Date: 4/4/2020
*/ */
import org.bukkit.Bukkit; import org.bukkit.Bukkit;
import java.lang.reflect.Constructor; import java.lang.reflect.Constructor;

View File

@@ -0,0 +1,29 @@
package com.massivecraft.factions.util.timer;
import com.massivecraft.factions.Conf;
import org.apache.commons.lang.time.FastDateFormat;
import java.text.DecimalFormat;
import java.time.ZoneId;
import java.util.Locale;
import java.util.TimeZone;
/**
* Factions - Developed by Driftay.
* All rights reserved 2020.
* Creation Date: 4/7/2020
*/
public final class DateTimeFormats {
public static final TimeZone SERVER_TIME_ZONE = TimeZone.getTimeZone(Conf.serverTimeZone);
public static final ZoneId SERVER_ZONE_ID = SERVER_TIME_ZONE.toZoneId();
public static final FastDateFormat DAY_MTH_HR_MIN_SECS = FastDateFormat.getInstance("dd/MM HH:mm:ss", SERVER_TIME_ZONE, Locale.ENGLISH);
public static final FastDateFormat DAY_MTH_YR_HR_MIN_AMPM = FastDateFormat.getInstance("dd/MM/yy hh:mma", SERVER_TIME_ZONE, Locale.ENGLISH);
public static final FastDateFormat DAY_MTH_HR_MIN_AMPM = FastDateFormat.getInstance("dd/MM hh:mma", SERVER_TIME_ZONE, Locale.ENGLISH);
public static final FastDateFormat HR_MIN_AMPM = FastDateFormat.getInstance("hh:mma", SERVER_TIME_ZONE, Locale.ENGLISH);
public static final FastDateFormat HR_MIN_AMPM_TIMEZONE = FastDateFormat.getInstance("hh:mma z", SERVER_TIME_ZONE, Locale.ENGLISH);
public static final FastDateFormat HR_MIN = FastDateFormat.getInstance("hh:mm", SERVER_TIME_ZONE, Locale.ENGLISH);
public static final FastDateFormat MIN_SECS = FastDateFormat.getInstance("mm:ss", SERVER_TIME_ZONE, Locale.ENGLISH);
public static final ThreadLocal<DecimalFormat> SECONDS = ThreadLocal.withInitial(() -> new DecimalFormat("0"));
public static final ThreadLocal<DecimalFormat> REMAINING_SECONDS = ThreadLocal.withInitial(() -> new DecimalFormat("0.#"));
public static final ThreadLocal<DecimalFormat> REMAINING_SECONDS_TRAILING = ThreadLocal.withInitial(() -> new DecimalFormat("0.0"));
}

View File

@@ -0,0 +1,74 @@
package com.massivecraft.factions.util.timer;
import com.massivecraft.factions.util.Config;
import java.util.LinkedHashMap;
import java.util.Map;
import java.util.Set;
import java.util.UUID;
/**
* Factions - Developed by Driftay.
* All rights reserved 2020.
* Creation Date: 4/7/2020
*/
public abstract class GlobalTimer extends Timer {
private TimerRunnable runnable;
public GlobalTimer(String name, long defaultCooldown) {
super(name, defaultCooldown);
}
public boolean clearCooldown() {
if (this.runnable != null) {
this.runnable.cancel();
this.runnable = null;
return true;
}
return false;
}
public boolean isPaused() {
return (this.runnable != null) && (this.runnable.isPaused());
}
public void setPaused(boolean paused) {
if ((this.runnable != null) && (this.runnable.isPaused() != paused)) {
this.runnable.setPaused(paused);
}
}
public long getRemaining() {
return this.runnable == null ? 0L : this.runnable.getRemaining();
}
public long getRemaining(long now) {
return this.runnable == null ? 0L : this.runnable.getRemaining(now);
}
public boolean setRemaining() {
return setRemaining(this.defaultCooldown, false);
}
public boolean setRemaining(long duration, boolean overwrite) {
boolean hadCooldown = false;
if (this.runnable != null) {
if (!overwrite) {
return false;
}
hadCooldown = this.runnable.getRemaining() > 0L;
this.runnable.setRemaining(duration);
} else {
this.runnable = new TimerRunnable(this, duration);
}
return !hadCooldown;
}
}

View File

@@ -0,0 +1,30 @@
package com.massivecraft.factions.util.timer;
import com.massivecraft.factions.util.Config;
/**
* Factions - Developed by Driftay.
* All rights reserved 2020.
* Creation Date: 4/7/2020
*/
public abstract class Timer {
protected final String name;
public final long defaultCooldown;
public Timer(String name, long defaultCooldown) {
this.name = name;
this.defaultCooldown = defaultCooldown;
}
public String getName() {
return this.name;
}
public void load(Config config) {
}
public void save(Config config) {
}
}

View File

@@ -0,0 +1,86 @@
package com.massivecraft.factions.util.timer;
import com.massivecraft.factions.Conf;
import com.massivecraft.factions.FactionsPlugin;
import com.massivecraft.factions.util.Config;
import com.massivecraft.factions.util.timer.type.GraceTimer;
import org.apache.commons.lang.time.DurationFormatUtils;
import org.bukkit.event.Listener;
import java.util.*;
import java.util.concurrent.TimeUnit;
/**
* Factions - Developed by Driftay.
* All rights reserved 2020.
* Creation Date: 4/7/2020
*/
public class TimerManager implements Listener, Runnable {
private final Set<Timer> timers;
private final FactionsPlugin plugin;
private final List<TimerRunnable> timerRunnableList = new ArrayList<>();
private Config config;
public GraceTimer graceTimer;
private static final long MINUTE = TimeUnit.MINUTES.toMillis(1L);
private static final long HOUR = TimeUnit.HOURS.toMillis(1L);
private static final long MULTI_HOUR = TimeUnit.HOURS.toMillis(10);
public static String getRemaining(long millis, boolean milliseconds) {
return getRemaining(millis, milliseconds, true);
}
public static String getRemaining(long duration, boolean milliseconds, boolean trail) {
if ((milliseconds) && (duration < MINUTE)) {
return ( (trail ? DateTimeFormats.REMAINING_SECONDS_TRAILING : DateTimeFormats.REMAINING_SECONDS).get()).format(duration * 0.001D) + 's';
}
return DurationFormatUtils.formatDuration(duration, (duration >= HOUR ? (duration >= MULTI_HOUR ? "d" : "") + "d:" : "") + "HH:mm:ss");
}
public TimerManager(FactionsPlugin plugin) {
this.timers = new HashSet<>();
this.plugin = plugin;
plugin.getServer().getPluginManager().registerEvents(this, plugin);
if(Conf.useGraceSystem) {
this.registerTimer(this.graceTimer = new GraceTimer());
}
plugin.getServer().getScheduler().runTaskTimer(plugin, this, 4, 4);
}
public Collection<Timer> getTimers() {
return this.timers;
}
public void registerTimer(Timer timer) {
this.timers.add(timer);
if (timer instanceof Listener) {
this.plugin.getServer().getPluginManager().registerEvents((Listener) timer, this.plugin);
}
}
public void unregisterTimer(Timer timer) {
this.timers.remove(timer);
}
public void reloadTimerData() {
this.config = new Config(this.plugin, "timers");
for (Timer timer : this.timers) {
timer.load(this.config);
}
}
public void saveTimerData() {
for (Timer timer : this.timers) {
timer.save(this.config);
}
this.config.save();
}
public void run() {
long now = System.currentTimeMillis();
timerRunnableList.removeIf(next -> next.check(now));
}
public List<TimerRunnable> getTimerRunnableList() {
return timerRunnableList;
}
}

View File

@@ -0,0 +1,117 @@
package com.massivecraft.factions.util.timer;
import com.massivecraft.factions.FactionsPlugin;
import java.util.UUID;
/**
* Factions - Developed by Driftay.
* All rights reserved 2020.
* Creation Date: 4/7/2020
*/
public class TimerRunnable {
private final Timer timer;
private long expiryMillis;
private long pauseMillis;
private boolean cancelled = false;
public TimerRunnable(Timer timer, long duration) {
this.timer = timer;
setRemaining(duration);
FactionsPlugin plugin = FactionsPlugin.getInstance();
plugin.getTimerManager().getTimerRunnableList().add(this);
}
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;
}
public Timer getTimer() {
return this.timer;
}
public long getRemaining() {
return getRemaining(false);
}
public long getRemaining(long now) {
return getRemaining(false, now);
}
public void setRemaining(long remaining) {
setExpiryMillis(remaining);
}
public long getRemaining(boolean ignorePaused) {
if ((!ignorePaused) && (this.pauseMillis != 0L)) return this.pauseMillis;
return this.expiryMillis - System.currentTimeMillis();
}
public long getRemaining(boolean ignorePaused, long now) {
if ((!ignorePaused) && (this.pauseMillis != 0L)) return this.pauseMillis;
return this.expiryMillis - now;
}
public long getExpiryMillis() {
return this.expiryMillis;
}
private void setExpiryMillis(long remainingMillis) {
long expiryMillis = System.currentTimeMillis() + remainingMillis;
if (expiryMillis == this.expiryMillis) return;
this.expiryMillis = expiryMillis;
}
public boolean check(long now) {
if (cancelled) return true;
return getRemaining(false, now) <= 0;
}
public long getPauseMillis() {
return this.pauseMillis;
}
public void setPauseMillis(long pauseMillis) {
this.pauseMillis = pauseMillis;
}
public boolean isPaused() {
return this.pauseMillis != 0L;
}
public void setPaused(boolean paused) {
if (paused == isPaused()) return;
if (paused) {
this.pauseMillis = getRemaining(true);
cancel();
} else {
setExpiryMillis(this.pauseMillis);
this.pauseMillis = 0L;
}
}
public void cancel() {
cancelled = true;
}
}

View File

@@ -0,0 +1,57 @@
package com.massivecraft.factions.util.timer.type;
import com.massivecraft.factions.Conf;
import com.massivecraft.factions.FPlayer;
import com.massivecraft.factions.FPlayers;
import com.massivecraft.factions.util.Config;
import com.massivecraft.factions.util.timer.GlobalTimer;
import org.bukkit.Material;
import org.bukkit.event.EventHandler;
import org.bukkit.event.Listener;
import org.bukkit.event.block.BlockPlaceEvent;
import org.bukkit.event.entity.EntityExplodeEvent;
import java.util.concurrent.TimeUnit;
/**
* Factions - Developed by Driftay.
* All rights reserved 2020.
* Creation Date: 4/7/2020
*/
public class GraceTimer extends GlobalTimer implements Listener {
public GraceTimer() {
super("GRACE", TimeUnit.DAYS.toMillis(Conf.gracePeriodTimeDays));
}
@EventHandler
public void onBreak(EntityExplodeEvent e) {
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);
}
}
}
}
@Override
public void load(Config config) {
setPaused(config.getBoolean(this.name + ".paused"));
setRemaining(config.getLong(this.name + ".time"), false);
}
@Override
public void save(Config config) {
config.set(this.name + ".paused", isPaused());
config.set(this.name + ".time", getRemaining());
}
}

View File

@@ -13,8 +13,8 @@ import java.util.concurrent.ConcurrentHashMap;
* Creation Date: 4/4/2020 * Creation Date: 4/4/2020
*/ */
public class WaitExecutor { public class WaitExecutor {
private static boolean enabled = false;
public static ConcurrentHashMap<Player, WaitTask> taskMap = new ConcurrentHashMap<>(); public static ConcurrentHashMap<Player, WaitTask> taskMap = new ConcurrentHashMap<>();
private static boolean enabled = false;
public static void startTask() { public static void startTask() {
if (enabled) return; if (enabled) return;

View File

@@ -25,6 +25,10 @@ public class WaitTask {
return wait; return wait;
} }
public void setWait(Integer i) {
wait = i;
}
public TL getMessage() { public TL getMessage() {
return msg; return msg;
} }
@@ -33,10 +37,6 @@ public class WaitTask {
return player; return player;
} }
public void setWait(Integer i) {
wait = i;
}
public void success() { public void success() {
origin.handleSuccess(player); origin.handleSuccess(player);
} }

View File

@@ -28,42 +28,35 @@ public class FUpgradeFrame {
public FUpgradeFrame(Faction f) { public FUpgradeFrame(Faction f) {
this.gui = new Gui(FactionsPlugin.getInstance(), this.gui = new Gui(FactionsPlugin.getInstance(),
FactionsPlugin.getInstance().getConfig().getInt("fupgrades.MainMenu.Rows", 5), FactionsPlugin.getInstance().getConfig().getInt("fupgrades.MainMenu.Rows", 5),
ChatColor.translateAlternateColorCodes('&', Objects.requireNonNull(FactionsPlugin.getInstance().getConfig() ChatColor.translateAlternateColorCodes('&', FactionsPlugin.getInstance().getConfig()
.getString("fupgrades.MainMenu.Title")).replace("{faction}", f.getTag()))); .getString("fupgrades.MainMenu.Title").replace("{faction}", f.getTag())));
} }
public void buildGUI(FPlayer fplayer) { public void buildGUI(FPlayer fplayer) {
PaginatedPane pane = new PaginatedPane(0, 0, 9, this.gui.getRows()); PaginatedPane pane = new PaginatedPane(0, 0, 9, this.gui.getRows());
List<GuiItem> GUIItems = new ArrayList<>(); List<GuiItem> GUIItems = new ArrayList<>();
ItemStack dummy = buildDummyItem(); ItemStack dummy = buildDummyItem();
for (int x = 0; x <= this.gui.getRows() * 9 - 1; ++x) for (int x = 0; x <= this.gui.getRows() * 9 - 1; ++x) GUIItems.add(new GuiItem(dummy, e -> e.setCancelled(true)));
GUIItems.add(new GuiItem(dummy, (e) -> e.setCancelled(true)));
for (UpgradeType value : UpgradeType.values()) { for (UpgradeType value : UpgradeType.values()) {
if (value.getSlot() != -1) { if (value.getSlot() != -1) {
GUIItems.set(value.getSlot(), new GuiItem(value.buildAsset(fplayer.getFaction()), (e) -> { GUIItems.set(value.getSlot(), new GuiItem(value.buildAsset(fplayer.getFaction()), e -> {
e.setCancelled(true); e.setCancelled(true);
FPlayer fme = FPlayers.getInstance().getByPlayer((Player) e.getWhoClicked()); FPlayer fme = FPlayers.getInstance().getByPlayer((Player) e.getWhoClicked());
if (fme.getFaction().getUpgrade(value) != value.getMaxLevel()) { if (fme.getFaction().getUpgrade(value) == value.getMaxLevel()) return;
int cost = FactionsPlugin.getInstance().getConfig().getInt("fupgrades.MainMenu." + value.toString() + ".Cost.level-" + (fme.getFaction().getUpgrade(value) + 1)); int cost = FactionsPlugin.getInstance().getConfig().getInt("fupgrades.MainMenu." + value.toString() + ".Cost.level-" + (fme.getFaction().getUpgrade(value) + 1));
if (fme.hasMoney(cost)) { if (fme.hasMoney(cost)) {
fme.takeMoney(cost); fme.takeMoney(cost);
if (value == UpgradeType.CHEST) if (value == UpgradeType.CHEST) updateChests(fme.getFaction());
updateChests(fme.getFaction());
if (value == UpgradeType.POWER) if (value == UpgradeType.POWER) updateFactionPowerBoost(fme.getFaction());
updateFactionPowerBoost(fme.getFaction());
if (value == UpgradeType.TNT) if (value == UpgradeType.TNT) updateTNT(fme.getFaction());
updateTNT(fme.getFaction());
if (value == UpgradeType.WARP) if (value == UpgradeType.WARP) updateWarps(fme.getFaction());
updateWarps(fme.getFaction());
fme.getFaction().setUpgrade(value, fme.getFaction().getUpgrade(value) + 1); fme.getFaction().setUpgrade(value, fme.getFaction().getUpgrade(value) + 1);
this.buildGUI(fme); buildGUI(fme);
} }
}
})); }));
} }
} }

View File

@@ -22,18 +22,18 @@ public enum UpgradeType {
* @author Illyria Team * @author Illyria Team
*/ */
CHEST("Chest", 3), CHEST("Chest", FactionsPlugin.getInstance().getConfig().getInt("fupgrades.MainMenu.Chest.Max-Level")),
SPAWNER("Spawners", 3), SPAWNER("Spawners", FactionsPlugin.getInstance().getConfig().getInt("fupgrades.MainMenu.Spawners.Max-Level")),
EXP("EXP", 3), EXP("EXP", FactionsPlugin.getInstance().getConfig().getInt("fupgrades.MainMenu.EXP.Max-Level")),
CROP("Crops", 3), CROP("Crops", FactionsPlugin.getInstance().getConfig().getInt("fupgrades.MainMenu.Crops.Max-Level")),
POWER("Power", 3), POWER("Power", FactionsPlugin.getInstance().getConfig().getInt("fupgrades.MainMenu.Power.Max-Level")),
REDSTONE("Redstone", 1), REDSTONE("Redstone", FactionsPlugin.getInstance().getConfig().getInt("fupgrades.MainMenu.Redstone.Max-Level")),
MEMBERS("Members", 3), MEMBERS("Members", FactionsPlugin.getInstance().getConfig().getInt("fupgrades.MainMenu.Members.Max-Level")),
TNT("TNT", 3), TNT("TNT", FactionsPlugin.getInstance().getConfig().getInt("fupgrades.MainMenu.TNT.Max-Level")),
WARP("Warps", 3), WARP("Warps", FactionsPlugin.getInstance().getConfig().getInt("fupgrades.MainMenu.Warps.Max-Level")),
DAMAGEINCREASE("DamageIncrease", 3), DAMAGEINCREASE("DamageIncrease", FactionsPlugin.getInstance().getConfig().getInt("fupgrades.MainMenu.DamageIncrease.Max-Level")),
DAMAGEDECREASE("DamageReduct", 3), DAMAGEDECREASE("DamageReduct", FactionsPlugin.getInstance().getConfig().getInt("fupgrades.MainMenu.DamageReduct.Max-Level")),
REINFORCEDARMOR("Armor", 3); REINFORCEDARMOR("Armor", FactionsPlugin.getInstance().getConfig().getInt("fupgrades.MainMenu.Armor.Max-Level"));
private String id; private String id;
private int maxLevel; private int maxLevel;
@@ -86,7 +86,6 @@ public enum UpgradeType {
private ItemStack updateLevelStatus(ItemStack item, int level) { private ItemStack updateLevelStatus(ItemStack item, int level) {
if (level >= 1) { if (level >= 1) {
item.setAmount(level); item.setAmount(level);
enchant(item);
} }
return item; return item;
} }

View File

@@ -90,6 +90,7 @@ public abstract class MemoryFPlayer implements FPlayer {
protected boolean titlesEnabled = true; protected boolean titlesEnabled = true;
protected boolean isAlt = false; protected boolean isAlt = false;
boolean inspectMode = false; boolean inspectMode = false;
boolean friendlyFire = false;
public MemoryFPlayer() { public MemoryFPlayer() {
} }
@@ -817,7 +818,7 @@ public abstract class MemoryFPlayer implements FPlayer {
if (myFaction.isNormal() && !perm && myFaction.getFPlayers().isEmpty()) { if (myFaction.isNormal() && !perm && myFaction.getFPlayers().isEmpty()) {
// Remove this faction // Remove this faction
if(FactionsPlugin.getInstance().getConfig().getBoolean("faction-disband-broadcast")) { if (FactionsPlugin.getInstance().getConfig().getBoolean("faction-disband-broadcast")) {
for (FPlayer fplayer : FPlayers.getInstance().getOnlinePlayers()) for (FPlayer fplayer : FPlayers.getInstance().getOnlinePlayers())
fplayer.msg(TL.LEAVE_DISBANDED, myFaction.describeTo(fplayer, true)); fplayer.msg(TL.LEAVE_DISBANDED, myFaction.describeTo(fplayer, true));
} }
@@ -846,14 +847,14 @@ public abstract class MemoryFPlayer implements FPlayer {
Faction currentFaction = Board.getInstance().getFactionAt(flocation); Faction currentFaction = Board.getInstance().getFactionAt(flocation);
int ownedLand = forFaction.getLandRounded(); int ownedLand = forFaction.getLandRounded();
int factionBuffer = FactionsPlugin.getInstance().getConfig().getInt("hcf.buffer-zone", 0); int factionBuffer = FactionsPlugin.getInstance().getConfig().getInt("hcf.buffer-zone", 0);
int worldBuffer = FactionsPlugin.getInstance().getConfig().getInt("world-border.buffer", 0); int worldBuffer = FactionsPlugin.getInstance().getConfig().getInt("world-border.buffer", 0) - 1;
if (Conf.worldGuardChecking && Worldguard.getInstance().checkForRegionsInChunk(flocation) && !this.isAdminBypassing()) { if (Conf.worldGuardChecking && Worldguard.getInstance().checkForRegionsInChunk(flocation) && !this.isAdminBypassing()) {
// Checks for WorldGuard regions in the chunk attempting to be claimed // Checks for WorldGuard regions in the chunk attempting to be claimed
error = FactionsPlugin.getInstance().txt.parse(TL.CLAIM_PROTECTED.toString()); error = FactionsPlugin.getInstance().txt.parse(TL.CLAIM_PROTECTED.toString());
} else if (flocation.isOutsideWorldBorder(FactionsPlugin.getInstance().getConfig().getInt("world-border.buffer", 0))) { } else if (flocation.isOutsideWorldBorder(FactionsPlugin.getInstance().getConfig().getInt("world-border.buffer", 0) - 1)) {
error = FactionsPlugin.getInstance().txt.parse(TL.CLAIM_OUTSIDEWORLDBORDER.toString()); error = FactionsPlugin.getInstance().txt.parse(TL.CLAIM_OUTSIDEWORLDBORDER.toString());
} else if (Conf.useWorldConfigurationsAsWhitelist != Conf.worldsNoClaiming.contains(flocation.getWorldName())) { } else if (Conf.worldsNoClaiming.contains(flocation.getWorldName())) {
error = FactionsPlugin.getInstance().txt.parse(TL.CLAIM_DISABLED.toString()); error = FactionsPlugin.getInstance().txt.parse(TL.CLAIM_DISABLED.toString());
} else if (this.isAdminBypassing()) { } else if (this.isAdminBypassing()) {
return true; return true;
@@ -863,14 +864,10 @@ public abstract class MemoryFPlayer implements FPlayer {
return true; return true;
} else if (currentFaction.getAccess(this, PermissableAction.TERRITORY) == Access.ALLOW) { } else if (currentFaction.getAccess(this, PermissableAction.TERRITORY) == Access.ALLOW) {
return true; return true;
} else if (currentFaction.isWilderness() && forFaction.getAccess(this, PermissableAction.TERRITORY) == Access.ALLOW) {
return true;
} else if (myFaction != forFaction) { } else if (myFaction != forFaction) {
error = FactionsPlugin.getInstance().txt.parse(TL.CLAIM_CANTCLAIM.toString(), forFaction.describeTo(this)); error = FactionsPlugin.getInstance().txt.parse(TL.CLAIM_CANTCLAIM.toString(), forFaction.describeTo(this));
} else if (forFaction == currentFaction) { } else if (forFaction == currentFaction) {
error = FactionsPlugin.getInstance().txt.parse(TL.CLAIM_ALREADYOWN.toString(), forFaction.describeTo(this, true)); error = FactionsPlugin.getInstance().txt.parse(TL.CLAIM_ALREADYOWN.toString(), forFaction.describeTo(this, true));
} else if (forFaction.getAccess(this, PermissableAction.TERRITORY) != Access.ALLOW) {
error = TL.COMMAND_CLAIM_DENIED.toString();
} else if (forFaction.getFPlayers().size() < Conf.claimsRequireMinFactionMembers) { } else if (forFaction.getFPlayers().size() < Conf.claimsRequireMinFactionMembers) {
error = FactionsPlugin.getInstance().txt.parse(TL.CLAIM_MEMBERS.toString(), Conf.claimsRequireMinFactionMembers); error = FactionsPlugin.getInstance().txt.parse(TL.CLAIM_MEMBERS.toString(), Conf.claimsRequireMinFactionMembers);
} else if (currentFaction.isSafeZone()) { } else if (currentFaction.isSafeZone()) {
@@ -914,7 +911,9 @@ public abstract class MemoryFPlayer implements FPlayer {
} }
// TODO: Add more else if statements. // TODO: Add more else if statements.
if (notifyFailure && error != null) msg(error); if (notifyFailure && error != null) {
msg(error);
}
return error == null; return error == null;
} }
@@ -973,7 +972,8 @@ public abstract class MemoryFPlayer implements FPlayer {
if (!damage) { if (!damage) {
msg(TL.COMMAND_FLY_CHANGE, fly ? "enabled" : "disabled"); msg(TL.COMMAND_FLY_CHANGE, fly ? "enabled" : "disabled");
if (!fly) sendMessage(TL.COMMAND_FLY_COOLDOWN.toString().replace("{amount}", FactionsPlugin.getInstance().getConfig().getInt("fly-falldamage-cooldown", 3) + "")); if (!fly)
sendMessage(TL.COMMAND_FLY_COOLDOWN.toString().replace("{amount}", FactionsPlugin.getInstance().getConfig().getInt("fly-falldamage-cooldown", 3) + ""));
} else { } else {
msg(TL.COMMAND_FLY_DAMAGE); msg(TL.COMMAND_FLY_DAMAGE);
} }
@@ -1203,6 +1203,15 @@ public abstract class MemoryFPlayer implements FPlayer {
} }
public boolean hasFriendlyFire(){
return friendlyFire;
}
public void setFriendlyFire(boolean status){
friendlyFire = status;
}
@Override @Override
public boolean isInspectMode() { public boolean isInspectMode() {
return inspectMode; return inspectMode;
@@ -1216,10 +1225,14 @@ public abstract class MemoryFPlayer implements FPlayer {
public boolean attemptClaim(Faction forFaction, FLocation flocation, boolean notifyFailure) { public boolean attemptClaim(Faction forFaction, FLocation flocation, boolean notifyFailure) {
// notifyFailure is false if called by auto-claim; no need to notify on every failure for it // notifyFailure is false if called by auto-claim; no need to notify on every failure for it
// return value is false on failure, true on success // return value is false on failure, true on success
Faction currentFaction = Board.getInstance().getFactionAt(flocation); Faction currentFaction = Board.getInstance().getFactionAt(flocation);
int ownedLand = forFaction.getLandRounded(); int ownedLand = forFaction.getLandRounded();
if (!this.canClaimForFactionAtLocation(forFaction, flocation, notifyFailure)) return false; if (!this.canClaimForFactionAtLocation(forFaction, flocation, notifyFailure)) {
return false;
}
// if economy is enabled and they're not on the bypass list, make sure they can pay // if economy is enabled and they're not on the bypass list, make sure they can pay
boolean mustPay = Econ.shouldBeUsed() && !this.isAdminBypassing() && !forFaction.isSafeZone() && !forFaction.isWarZone() && (Conf.econCostClaimWilderness != 0); boolean mustPay = Econ.shouldBeUsed() && !this.isAdminBypassing() && !forFaction.isSafeZone() && !forFaction.isWarZone() && (Conf.econCostClaimWilderness != 0);
double cost = 0.0; double cost = 0.0;
@@ -1238,21 +1251,38 @@ public abstract class MemoryFPlayer implements FPlayer {
payee = this; payee = this;
} }
if (!Econ.hasAtLeast(payee, cost, TL.CLAIM_TOCLAIM.toString())) return false; if (!Econ.hasAtLeast(payee, cost, TL.CLAIM_TOCLAIM.toString())) {
return false;
}
}
if (forFaction.getClaimOwnership().containsKey(flocation) && !forFaction.isPlayerInOwnerList(this, flocation)) {
this.msg(TL.GENERIC_FPERM_OWNER_NOPERMISSION, "claim");
return false;
}
if (Conf.worldGuardChecking && Worldguard.getInstance().checkForRegionsInChunk(flocation)) {
this.msg(TL.GENERIC_WORLDGUARD);
return false;
} }
LandClaimEvent claimEvent = new LandClaimEvent(flocation, forFaction, this); LandClaimEvent claimEvent = new LandClaimEvent(flocation, forFaction, this);
Bukkit.getPluginManager().callEvent(claimEvent); Bukkit.getPluginManager().callEvent(claimEvent);
if (claimEvent.isCancelled()) return false;
if (claimEvent.isCancelled()) {
return false;
}
// then make 'em pay (if applicable) // then make 'em pay (if applicable)
if (mustPay && !Econ.modifyMoney(payee, -cost, TL.CLAIM_TOCLAIM.toString(), TL.CLAIM_FORCLAIM.toString())) if (mustPay && !Econ.modifyMoney(payee, -cost, TL.CLAIM_TOCLAIM.toString(), TL.CLAIM_FORCLAIM.toString())) {
return false; return false;
}
// Was an over claim // Was an over claim
if (mustPay && currentFaction.isNormal() && currentFaction.hasLandInflation()) if (currentFaction.isNormal() && currentFaction.hasLandInflation()) {
// Give them money for over claiming. // Give them money for over claiming.
Econ.modifyMoney(payee, Conf.econOverclaimRewardMultiplier, TL.CLAIM_TOOVERCLAIM.toString(), TL.CLAIM_FOROVERCLAIM.toString()); Econ.modifyMoney(payee, Conf.econOverclaimRewardMultiplier, TL.CLAIM_TOOVERCLAIM.toString(), TL.CLAIM_FOROVERCLAIM.toString());
}
// announce success // announce success
@@ -1260,14 +1290,15 @@ public abstract class MemoryFPlayer implements FPlayer {
informTheseFPlayers.add(this); informTheseFPlayers.add(this);
informTheseFPlayers.addAll(forFaction.getFPlayersWhereOnline(true)); informTheseFPlayers.addAll(forFaction.getFPlayersWhereOnline(true));
for (FPlayer fp : informTheseFPlayers) { for (FPlayer fp : informTheseFPlayers) {
if (!fp.hasNotificationsEnabled()) continue;
fp.msg(TL.CLAIM_CLAIMED, this.describeTo(fp, true), forFaction.describeTo(fp), currentFaction.describeTo(fp)); fp.msg(TL.CLAIM_CLAIMED, this.describeTo(fp, true), forFaction.describeTo(fp), currentFaction.describeTo(fp));
} }
Board.getInstance().setFactionAt(forFaction, flocation); Board.getInstance().setFactionAt(forFaction, flocation);
if (Conf.logLandClaims)
if (Conf.logLandClaims) {
FactionsPlugin.getInstance().log(TL.CLAIM_CLAIMEDLOG.toString(), this.getName(), flocation.getCoordString(), forFaction.getTag()); FactionsPlugin.getInstance().log(TL.CLAIM_CLAIMEDLOG.toString(), this.getName(), flocation.getCoordString(), forFaction.getTag());
}
return true; return true;
} }

View File

@@ -416,6 +416,11 @@ public enum TL {
COMMAND_FOCUS_NO_LONGER("&c&l[!] &7Your faction is no longer focusing &c%s"), COMMAND_FOCUS_NO_LONGER("&c&l[!] &7Your faction is no longer focusing &c%s"),
COMMAND_FOCUS_DESCRIPTION("Focus a Specific Player"), COMMAND_FOCUS_DESCRIPTION("Focus a Specific Player"),
COMMAND_FRIENDLY_FIRE_DESCRIPTION("Toggle friendly fire for yourself."),
COMMAND_FRIENDLY_FIRE_TOGGLE_OFF("&c[!] &7You have toggled friendly fire &4off&7!"),
COMMAND_FRIENDLY_FIRE_TOGGLE_ON("&c[!] &7You have toggled friendly fire &aon&7!"),
FRIENDLY_FIRE_OFF_ATTACKER("&b%1$s &7has friendly fire toggle &4off&7!"),
FRIENDLY_FIRE_YOU_MUST("&c[!] &7You must have friendly fire active to attack faction members!"),
COMMAND_FWARP_CLICKTOWARP("&c&l[!]&7 Click to &cwarp!"), COMMAND_FWARP_CLICKTOWARP("&c&l[!]&7 Click to &cwarp!"),
COMMAND_FWARP_COMMANDFORMAT("&c&l[!]&7 /f warp <warpname> &c[password]"), COMMAND_FWARP_COMMANDFORMAT("&c&l[!]&7 /f warp <warpname> &c[password]"),
@@ -429,9 +434,12 @@ public enum TL {
COMMAND_FWARP_PASSWORD_REQUIRED("&c&l[!]&c Warp Password:"), COMMAND_FWARP_PASSWORD_REQUIRED("&c&l[!]&c Warp Password:"),
COMMAND_FWARP_PASSWORD_TIMEOUT("&c&l[!]&7 Warp password &ccanceled"), COMMAND_FWARP_PASSWORD_TIMEOUT("&c&l[!]&7 Warp password &ccanceled"),
COMMAND_GRACE_TIME_REMAINING("&c&lGracePeriod &8» &cTime Remaining: &b%1$s"),
COMMAND_GRACE_DISABLED_NO_FORMAT("&c[!] &7Grace is disabled! Explosions are allowed!"),
COMMAND_GRACE_ENABLED_FORMAT("&c&lGracePeriod &8» &7Grace Period Has Now &aStarted&7! &cTime Remaining: &b%1$s"),
COMMAND_GRACE_DISABLED_FORMAT("&c&lGracePeriod &8» &7Grace Period Has Now &cEnded&7! &cExplosions are now enabled!"),
COMMAND_GRACE_DESCRIPTION("Toggles Grace Period on/off"), COMMAND_GRACE_DESCRIPTION("Toggles Grace Period on/off"),
COMMAND_GRACE_ENABLED("&cYou cannot place &e%s &cwhile grace period is active!"), COMMAND_GRACE_ENABLED_PLACEMENT("&cYou cannot place &e%s &cwhile grace period is active!"),
COMMAND_GRACE_TOGGLE("&8» &7Grace period is now &c%1$s"),
COMMAND_HINT_PERMISSION("&aYou can manage your factions permissions using &7/f perms"), COMMAND_HINT_PERMISSION("&aYou can manage your factions permissions using &7/f perms"),
@@ -606,6 +614,8 @@ public enum TL {
COMMAND_MONEYWITHDRAW_DESCRIPTION("Withdraw money"), COMMAND_MONEYWITHDRAW_DESCRIPTION("Withdraw money"),
COMMAND_MONEYWITHDRAW_WITHDRAW("&c&l[!]&7 &c%1$s&7 withdrew&c %2$s &7from the faction bank:&c %3$s"), COMMAND_MONEYWITHDRAW_WITHDRAW("&c&l[!]&7 &c%1$s&7 withdrew&c %2$s &7from the faction bank:&c %3$s"),
COMMAND_COOLDOWN("&c&l[!] &7You are currently on cooldown for this command!"),
COMMAND_OPEN_TOOPEN("to open or close the faction"), COMMAND_OPEN_TOOPEN("to open or close the faction"),
COMMAND_OPEN_FOROPEN("for opening or closing the faction"), COMMAND_OPEN_FOROPEN("for opening or closing the faction"),
COMMAND_OPEN_OPEN("open"), COMMAND_OPEN_OPEN("open"),
@@ -1110,6 +1120,7 @@ public enum TL {
GENERIC_NOFACTION_FOUND("&cCouldn't find a faction with that name!"), GENERIC_NOFACTION_FOUND("&cCouldn't find a faction with that name!"),
GENERIC_YOUMUSTBE("&cYour must be atleast %1$s to do this!"), GENERIC_YOUMUSTBE("&cYour must be atleast %1$s to do this!"),
GENERIC_MEMBERONLY("&cYou must be in a faction to do this!"), GENERIC_MEMBERONLY("&cYou must be in a faction to do this!"),
GENERIC_WORLDGUARD("&cThis area is worldguard protected."),
// MISSION_CREATED_COOLDOWN("&c&l[!] &7Due to your immediate faction creation, you may not start missions for &b%1$s minutes&7!"), // MISSION_CREATED_COOLDOWN("&c&l[!] &7Due to your immediate faction creation, you may not start missions for &b%1$s minutes&7!"),
MISSION_MISSION_STARTED("&f%1$s &dstarted the %2$s &fmission"), MISSION_MISSION_STARTED("&f%1$s &dstarted the %2$s &fmission"),

View File

@@ -3,6 +3,7 @@ package com.massivecraft.factions.zcore.util;
import com.massivecraft.factions.*; import com.massivecraft.factions.*;
import com.massivecraft.factions.integration.Econ; import com.massivecraft.factions.integration.Econ;
import com.massivecraft.factions.struct.Relation; import com.massivecraft.factions.struct.Relation;
import com.massivecraft.factions.util.timer.TimerManager;
import org.apache.commons.lang.time.DurationFormatUtils; import org.apache.commons.lang.time.DurationFormatUtils;
import org.bukkit.Bukkit; import org.bukkit.Bukkit;
import org.bukkit.ChatColor; import org.bukkit.ChatColor;
@@ -20,6 +21,7 @@ public enum TagReplacer {
/** /**
* Fancy variables, used by f show * Fancy variables, used by f show
*/ */
NEUTRAL_LIST(TagType.FANCY, "{neutral-list}"),
ALLIES_LIST(TagType.FANCY, "{allies-list}"), ALLIES_LIST(TagType.FANCY, "{allies-list}"),
ONLINE_LIST(TagType.FANCY, "{online-list}"), ONLINE_LIST(TagType.FANCY, "{online-list}"),
ENEMIES_LIST(TagType.FANCY, "{enemies-list}"), ENEMIES_LIST(TagType.FANCY, "{enemies-list}"),
@@ -81,6 +83,7 @@ public enum TagReplacer {
/** /**
* General variables, require no faction or player * General variables, require no faction or player
*/ */
GRACE_TIMER(TagType.GENERAL, "{grace-time}"),
MAX_WARPS(TagType.GENERAL, "{max-warps}"), MAX_WARPS(TagType.GENERAL, "{max-warps}"),
MAX_ALLIES(TagType.GENERAL, "{max-allies}"), MAX_ALLIES(TagType.GENERAL, "{max-allies}"),
MAX_ALTS(TagType.GENERAL, "{max-alts}"), MAX_ALTS(TagType.GENERAL, "{max-alts}"),
@@ -124,6 +127,8 @@ public enum TagReplacer {
*/ */
protected String getValue() { protected String getValue() {
switch (this) { switch (this) {
case GRACE_TIMER:
return String.valueOf(TimerManager.getRemaining(FactionsPlugin.getInstance().getTimerManager().graceTimer.getRemaining(), true));
case TOTAL_ONLINE: case TOTAL_ONLINE:
return String.valueOf(Bukkit.getOnlinePlayers().size()); return String.valueOf(Bukkit.getOnlinePlayers().size());
case FACTIONLESS: case FACTIONLESS:
@@ -134,7 +139,7 @@ public enum TagReplacer {
} }
return TL.GENERIC_INFINITY.toString(); return TL.GENERIC_INFINITY.toString();
case MAX_ALTS: case MAX_ALTS:
if(FactionsPlugin.getInstance().getConfig().getBoolean("f-alts.Enabled")){ if (FactionsPlugin.getInstance().getConfig().getBoolean("f-alts.Enabled")) {
return String.valueOf(Conf.factionAltMemberLimit); return String.valueOf(Conf.factionAltMemberLimit);
} }
return TL.GENERIC_INFINITY.toString(); return TL.GENERIC_INFINITY.toString();

View File

@@ -345,7 +345,7 @@ help:
# We use '1' to preserve default functionality of /f help 1 # We use '1' to preserve default functionality of /f help 1
'1': '1':
- '&7&m----------------------------------------------------' - '&7&m----------------------------------------------------'
- '&6&lFactions Help &8- &f(1/2) ' - '&6&lFactions Help &8- &f(1/3) '
- '&7&m----------------------------------------------------' - '&7&m----------------------------------------------------'
- '&c/f create &f<name> &8- &7Create your own faction.' - '&c/f create &f<name> &8- &7Create your own faction.'
- '&c/f who &f<name> &8- &7Show faction information.' - '&c/f who &f<name> &8- &7Show faction information.'
@@ -594,11 +594,12 @@ fwarp-gui:
- ' ' - ' '
############################################################ ############################################################
# +------------------------------------------------------+ # # +------------------------------------------------------+ #
# | Faction Creation/Disband Broadcast | # # | Faction Broadcasts | #
# +------------------------------------------------------+ # # +------------------------------------------------------+ #
############################################################ ############################################################
faction-creation-broadcast: true #Disabling this will not make faction creation broadcasts appear in chat. faction-creation-broadcast: true #Disabling this will not make faction creation broadcasts appear in chat.
faction-disband-broadcast: true #Disabling this will not make faction disband broadcasts appear in chat. faction-disband-broadcast: true #Disabling this will not make faction disband broadcasts appear in chat.
faction-open-broadcast: true #Disabling this will not make faction open broadcasts appear in chat.
############################################################ ############################################################
# +------------------------------------------------------+ # # +------------------------------------------------------+ #
@@ -729,8 +730,7 @@ F-Shop:
# | Faction Command Cooldowns | # # | Faction Command Cooldowns | #
# +------------------------------------------------------+ # # +------------------------------------------------------+ #
############################################################ ############################################################
#To-Do# fcooldowns: #All of These Cooldowns Are In Seconds
fcooldowns:
f-open: 5 f-open: 5
f-disband: 10 f-disband: 10
f-create: 10 f-create: 10
@@ -954,6 +954,7 @@ fupgrades:
Lore: Lore:
- ' ' - ' '
Crops: Crops:
Max-Level: 4
Crop-Boost: Crop-Boost:
level-1: 10 level-1: 10
level-2: 20 level-2: 20
@@ -969,7 +970,7 @@ fupgrades:
Lore: Lore:
- '&7&oIncrease growth &c&ospeed&7&o of crops in &c&oclaims.' - '&7&oIncrease growth &c&ospeed&7&o of crops in &c&oclaims.'
- '&7&oChance to Grow Two Levels.' - '&7&oChance to Grow Two Levels.'
- 'Current level is &e&l&o{level}' - '&7&oYour current level is &e&l&o{level}'
- '' - ''
- '&c&lChances' - '&c&lChances'
- '&4&l* &cLevel 1: &f10% Chance' - '&4&l* &cLevel 1: &f10% Chance'
@@ -984,6 +985,7 @@ fupgrades:
- '&7&o(( Tip: &f&oleft-click&7&o to &c&oupgrade&7&o ))' - '&7&o(( Tip: &f&oleft-click&7&o to &c&oupgrade&7&o ))'
Slot: 31 Slot: 31
EXP: EXP:
Max-Level: 3
EXP-Boost: EXP-Boost:
level-1: 1.5 level-1: 1.5
level-2: 2.0 level-2: 2.0
@@ -1013,6 +1015,7 @@ fupgrades:
- '&7&o(( Tip: &f&oleft-click&7&o to &c&oupgrade&7&o ))' - '&7&o(( Tip: &f&oleft-click&7&o to &c&oupgrade&7&o ))'
Slot: 32 Slot: 32
Power: Power:
Max-Level: 3
Power-Boost: Power-Boost:
level-1: 100.0 level-1: 100.0
level-2: 200.0 level-2: 200.0
@@ -1028,7 +1031,7 @@ fupgrades:
Lore: Lore:
- '&a&oIncrease&7&o the amount of &c&opower' - '&a&oIncrease&7&o the amount of &c&opower'
- '&7&oyour &a&ofaction has&7&o.' - '&7&oyour &a&ofaction has&7&o.'
- 'Current level is &e&l&o{level}' - '&7&oYour current level is &e&l&o{level}'
- '' - ''
- '&c&lIncreased Faction Power' - '&c&lIncreased Faction Power'
- '&4&l* &cLevel 1: &f100' - '&4&l* &cLevel 1: &f100'
@@ -1043,6 +1046,7 @@ fupgrades:
- '&7&o(( Tip: &f&oleft-click&7&o to &c&oupgrade&7&o ))' - '&7&o(( Tip: &f&oleft-click&7&o to &c&oupgrade&7&o ))'
Slot: 22 Slot: 22
Redstone: Redstone:
Max-Level: 1
Cost: Cost:
level-1: 1000000 level-1: 1000000
DisplayItem: DisplayItem:
@@ -1058,6 +1062,7 @@ fupgrades:
- '&7&o(( Tip: &f&oLeft-click&7&o to &c&oupgrade&7&o ))' - '&7&o(( Tip: &f&oLeft-click&7&o to &c&oupgrade&7&o ))'
Slot: 23 Slot: 23
Spawners: Spawners:
Max-Level: 3
Spawner-Boost: Spawner-Boost:
# This is a Percentage so .10 means 10% lowered spawner delay! # This is a Percentage so .10 means 10% lowered spawner delay!
level-1: 0.10 level-1: 0.10
@@ -1088,6 +1093,7 @@ fupgrades:
- '&7&o(( Tip: &f&oleft-click&7&o to &c&oupgrade&7&o ))' - '&7&o(( Tip: &f&oleft-click&7&o to &c&oupgrade&7&o ))'
Slot: 30 Slot: 30
DamageReduct: DamageReduct:
Max-Level: 3
DamageReductPercent: DamageReductPercent:
level-1: 3 level-1: 3
level-2: 5 level-2: 5
@@ -1117,6 +1123,7 @@ fupgrades:
- '&7&o(( Tip: &f&oleft-click&7&o to &c&oupgrade&7&o ))' - '&7&o(( Tip: &f&oleft-click&7&o to &c&oupgrade&7&o ))'
Slot: 7 Slot: 7
DamageIncrease: DamageIncrease:
Max-Level: 3
DamageIncreasePercent: DamageIncreasePercent:
level-1: 3 level-1: 3
level-2: 5 level-2: 5
@@ -1146,6 +1153,7 @@ fupgrades:
- '&7&o(( Tip: &f&oleft-click&7&o to &c&oupgrade&7&o ))' - '&7&o(( Tip: &f&oleft-click&7&o to &c&oupgrade&7&o ))'
Slot: 1 Slot: 1
TNT: TNT:
Max-Level: 3
tnt-limit: tnt-limit:
level-1: 500000 level-1: 500000
level-2: 1000000 level-2: 1000000
@@ -1175,6 +1183,7 @@ fupgrades:
- '&7&o(( Tip: &f&oleft-click&7&o to &c&oupgrade&7&o ))' - '&7&o(( Tip: &f&oleft-click&7&o to &c&oupgrade&7&o ))'
Slot: 21 Slot: 21
Warps: Warps:
Max-Level: 3
warp-limit: warp-limit:
level-1: 3 level-1: 3
level-2: 4 level-2: 4
@@ -1204,6 +1213,7 @@ fupgrades:
- '&7&o(( Tip: &f&oleft-click&7&o to &c&oupgrade&7&o ))' - '&7&o(( Tip: &f&oleft-click&7&o to &c&oupgrade&7&o ))'
Slot: 24 Slot: 24
Chest: Chest:
Max-Level: 3
Chest-Size: Chest-Size:
# This is rows # This is rows
level-1: 2 level-1: 2
@@ -1234,6 +1244,7 @@ fupgrades:
- '&7&o(( Tip: &f&oleft-click&7&o to &c&oupgrade&7&o ))' - '&7&o(( Tip: &f&oleft-click&7&o to &c&oupgrade&7&o ))'
Slot: 20 Slot: 20
Members: Members:
Max-Level: 3
Members-Limit: Members-Limit:
level-1: 30 level-1: 30
level-2: 35 level-2: 35
@@ -1263,6 +1274,7 @@ fupgrades:
- '&7&o(( Tip: &f&oleft-click&7&o to &c&oupgrade&7&o ))' - '&7&o(( Tip: &f&oleft-click&7&o to &c&oupgrade&7&o ))'
Slot: 40 Slot: 40
Armor: Armor:
Max-Level: 3
Armor-HP-Drop: Armor-HP-Drop:
# HP Drop is in percent so .10 would mean it would drop 10% of the damage to the armor # HP Drop is in percent so .10 would mean it would drop 10% of the damage to the armor
level-1: .10 level-1: .10
@@ -1548,6 +1560,7 @@ Wild:
# - {action-access-color} : Access color # - {action-access-color} : Access color
# General variables. Can be used anywhere. # General variables. Can be used anywhere.
# - {grace-time} : Time of Grace Period
# - {total-online} : Total # of players on the server # - {total-online} : Total # of players on the server
# - {max-warps} : Max # of warps a faction can set # - {max-warps} : Max # of warps a faction can set
# - {max-allies} : Max # of allies a faction can have # - {max-allies} : Max # of allies a faction can have

View File

@@ -158,6 +158,8 @@ permissions:
description: auto-claim land as you walk around description: auto-claim land as you walk around
factions.bypass: factions.bypass:
description: enable admin bypass mode description: enable admin bypass mode
factions.friendlyfire:
description: ability to toggle on friend fire per player
factions.lookup: factions.lookup:
description: Lookup claim & home stats for faction description: Lookup claim & home stats for faction
factions.chat: factions.chat: