Merge remote-tracking branch 'origin/1.6.x' into 1.6.x

This commit is contained in:
droppinganvil 2020-04-21 16:04:39 -05:00
commit b89db7b082
24 changed files with 133 additions and 130 deletions

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.3-RC</version> <version>1.6.9.5-2.3.4-RC</version>
<packaging>jar</packaging> <packaging>jar</packaging>
<name>SaberFactions</name> <name>SaberFactions</name>

View File

@ -98,6 +98,7 @@ public class Conf {
public static double autoLeaveRoutineRunsEveryXMinutes = 5.0; public static double autoLeaveRoutineRunsEveryXMinutes = 5.0;
public static int autoLeaveRoutineMaxMillisecondsPerTick = 5; // 1 server tick is roughly 50ms, so default max 10% of a tick public static int autoLeaveRoutineMaxMillisecondsPerTick = 5; // 1 server tick is roughly 50ms, so default max 10% of a tick
public static boolean removePlayerDataWhenBanned = true; public static boolean removePlayerDataWhenBanned = true;
public static String removePlayerDataWhenBannedReason = "Banned by admin.";
public static boolean autoLeaveDeleteFPlayerData = true; // Let them just remove player from Faction. public static boolean autoLeaveDeleteFPlayerData = true; // Let them just remove player from Faction.
public static boolean worldGuardChecking = false; public static boolean worldGuardChecking = false;
public static boolean worldGuardBuildPriority = false; public static boolean worldGuardBuildPriority = false;
@ -122,7 +123,7 @@ public class Conf {
public static boolean useDisbandGUI = true; public static boolean useDisbandGUI = true;
//SEALTH //SEALTH
public static boolean useSealthSystem = true; public static boolean useStealthSystem = true;
//STRIKES //STRIKES
public static boolean useStrikeSystem = true; public static boolean useStrikeSystem = true;

View File

@ -82,7 +82,7 @@ public class FactionsPlugin extends MPlugin {
public boolean mc114 = false; public boolean mc114 = false;
public boolean mc115 = false; public boolean mc115 = false;
public boolean useNonPacketParticles = false; public boolean useNonPacketParticles = false;
public boolean factionsFlight = false; public static boolean factionsFlight = false;
public List<String> itemList = getConfig().getStringList("fchest.Items-Not-Allowed"); public List<String> itemList = getConfig().getStringList("fchest.Items-Not-Allowed");
SkriptAddon skriptAddon; SkriptAddon skriptAddon;
private FactionsPlayerListener factionsPlayerListener; private FactionsPlayerListener factionsPlayerListener;
@ -453,37 +453,32 @@ public class FactionsPlugin extends MPlugin {
@Override @Override
public void onDisable() { public void onDisable() {
super.onDisable();
timerManager.saveTimerData();
try {
String path = Paths.get(getDataFolder().getAbsolutePath()).toAbsolutePath().toString() + File.separator + "reserves.json";
File file = new File(path);
if (!file.exists()) {
file.getParentFile().mkdirs();
file.createNewFile();
}
Files.write(Paths.get(file.getPath()), getGsonBuilder().create().toJson(reserveObjects).getBytes());
} catch (IOException e) {
e.printStackTrace();
}
// only save data if plugin actually completely loaded successfully // only save data if plugin actually completely loaded successfully
if (this.loadSuccessful) Conf.saveSync(); if (this.loadSuccessful) {
Conf.load();
Conf.saveSync();
if (AutoLeaveTask != null) { timerManager.saveTimerData();
this.getServer().getScheduler().cancelTask(AutoLeaveTask); DiscordListener.saveGuilds();
AutoLeaveTask = null; if (Discord.jda != null) Discord.jda.shutdownNow();
} try {
DiscordListener.saveGuilds(); fLogManager.saveLogs();
if (Discord.jda != null) { } catch (Exception e) {
Discord.jda.shutdownNow(); e.printStackTrace();
} }
try { try {
fLogManager.saveLogs(); String path = Paths.get(getDataFolder().getAbsolutePath()).toAbsolutePath().toString() + File.separator + "reserves.json";
} catch (Exception e) { File file = new File(path);
e.printStackTrace(); if (!file.exists()) {
file.getParentFile().mkdirs();
file.createNewFile();
}
Files.write(Paths.get(file.getPath()), getGsonBuilder().create().toJson(reserveObjects).getBytes());
} catch (IOException e) {
e.printStackTrace();
}
} }
this.getServer().getScheduler().cancelTasks(this);
super.onDisable();
} }
public void startAutoLeaveTask(boolean restartIfRunning) { public void startAutoLeaveTask(boolean restartIfRunning) {

View File

@ -86,24 +86,20 @@ public class CmdAdmin extends FCommand {
FactionsPlugin.instance.getFlogManager().log(targetFaction, FLogType.RANK_EDIT, context.fPlayer.getName(), fyou.getName(), ChatColor.RED + "Admin"); FactionsPlugin.instance.getFlogManager().log(targetFaction, FLogType.RANK_EDIT, context.fPlayer.getName(), fyou.getName(), ChatColor.RED + "Admin");
// Inform all players // Inform all players
for (FPlayer fplayer : FPlayers.getInstance().getOnlinePlayers()) { if(FactionsPlugin.instance.getConfig().getBoolean("faction-leader-broadcast")) {
fplayer.msg(TL.COMMAND_ADMIN_PROMOTED, for (FPlayer fplayer : FPlayers.getInstance().getOnlinePlayers()) {
context.player == null ? TL.GENERIC_SERVERADMIN.toString() : context.fPlayer.describeTo(fplayer, true), fplayer.msg(TL.COMMAND_ADMIN_PROMOTED, context.player == null ? TL.GENERIC_SERVERADMIN.toString() : context.fPlayer.describeTo(fplayer, true), fyou.describeTo(fplayer), targetFaction.describeTo(fplayer));
fyou.describeTo(fplayer), targetFaction.describeTo(fplayer)); }
} }
}); });
} }
private void setRole(FPlayer fp, Role r) { private void setRole(FPlayer fp, Role r) {
FactionsPlugin.getInstance().getServer().getScheduler().runTask(FactionsPlugin.instance, () -> { FactionsPlugin.getInstance().getServer().getScheduler().runTask(FactionsPlugin.instance, () -> fp.setRole(r));
fp.setRole(r);
});
} }
private void promoteNewLeader(Faction f) { private void promoteNewLeader(Faction f) {
FactionsPlugin.getInstance().getServer().getScheduler().runTask(FactionsPlugin.instance, () -> { FactionsPlugin.getInstance().getServer().getScheduler().runTask(FactionsPlugin.instance, (Runnable) f::promoteNewLeader);
f.promoteNewLeader();
});
} }
public TL getUsageTranslation() { public TL getUsageTranslation() {

View File

@ -25,36 +25,17 @@ public class CmdDeinvite extends FCommand {
this.optionalArgs.put("player name", "name"); this.optionalArgs.put("player name", "name");
this.requirements = new CommandRequirements.Builder(Permission.DEINVITE) this.requirements = new CommandRequirements.Builder(Permission.DEINVITE)
.withAction(PermissableAction.INVITE)
.memberOnly() .memberOnly()
.build(); .build();
} }
@Override @Override
public void perform(CommandContext context) { public void perform(CommandContext context) {
if (context.args.size() == 0) {
FancyMessage msg = new FancyMessage(TL.COMMAND_DEINVITE_CANDEINVITE.toString()).color(ChatColor.GOLD);
for (String id : context.faction.getInvites()) {
FPlayer fp = FPlayers.getInstance().getById(id);
String name = fp != null ? fp.getName() : id;
msg.then(name + " ").color(ChatColor.WHITE).tooltip(TL.COMMAND_DEINVITE_CLICKTODEINVITE.format(name)).command("/" + Conf.baseCommandAliases.get(0) + " deinvite " + name);
}
context.sendFancyMessage(msg);
return;
}
FPlayer you = context.argAsBestFPlayerMatch(0); FPlayer you = context.argAsBestFPlayerMatch(0);
if (!context.fPlayer.isAdminBypassing()) {
Access access = context.faction.getAccess(context.fPlayer, PermissableAction.INVITE);
if (access != Access.ALLOW && context.fPlayer.getRole() != Role.LEADER) {
context.msg(TL.GENERIC_FPERM_NOPERMISSION, "manage invites");
return;
}
}
if (you == null) { if (you == null) {
FancyMessage msg = new FancyMessage(TL.COMMAND_DEINVITE_CANDEINVITE.toString()).color(ChatColor.GOLD); FancyMessage msg = new FancyMessage(TL.COMMAND_DEINVITE_CANDEINVITE.toString()).color(ChatColor.GOLD);
for (String id : context.faction.getInvites()) { for (String id : context.faction.getInvites()) {
if (context.faction.getInvites().isEmpty()) return;
FPlayer fp = FPlayers.getInstance().getById(id); FPlayer fp = FPlayers.getInstance().getById(id);
String name = fp != null ? fp.getName() : id; String name = fp != null ? fp.getName() : id;
msg.then(name + " ").color(ChatColor.WHITE).tooltip(TL.COMMAND_DEINVITE_CLICKTODEINVITE.format(name)).command("/" + Conf.baseCommandAliases.get(0) + " deinvite " + name); msg.then(name + " ").color(ChatColor.WHITE).tooltip(TL.COMMAND_DEINVITE_CLICKTODEINVITE.format(name)).command("/" + Conf.baseCommandAliases.get(0) + " deinvite " + name);
@ -65,15 +46,16 @@ public class CmdDeinvite extends FCommand {
if (you.getFaction() == context.faction) { if (you.getFaction() == context.faction) {
context.msg(TL.COMMAND_DEINVITE_ALREADYMEMBER, you.getName(), context.faction.getTag()); context.msg(TL.COMMAND_DEINVITE_ALREADYMEMBER, you.getName(), context.faction.getTag());
context.msg(TL.COMMAND_DEINVITE_MIGHTWANT, FactionsPlugin.getInstance().cmdBase.cmdKick.getUsageTemplate(context)); context.msg(TL.COMMAND_DEINVITE_MIGHTWANT, FCmdRoot.instance.cmdKick.getUsageTemplate(context));
return; return;
} }
context.faction.deinvite(you); context.faction.deinvite(you);
you.msg(TL.COMMAND_DEINVITE_REVOKED, context.fPlayer.describeTo(you), context.faction.describeTo(you)); you.msg(TL.COMMAND_DEINVITE_REVOKED, context.fPlayer.describeTo(you), context.faction.describeTo(you));
context.faction.msg(TL.COMMAND_DEINVITE_REVOKES, context.fPlayer.describeTo(context.faction), you.describeTo(context.faction)); context.faction.msg(TL.COMMAND_DEINVITE_REVOKES, context.fPlayer.describeTo(context.faction), you.describeTo(context.faction));
} }
@Override @Override
public TL getUsageTranslation() { public TL getUsageTranslation() {
return TL.COMMAND_DEINVITE_DESCRIPTION; return TL.COMMAND_DEINVITE_DESCRIPTION;

View File

@ -101,14 +101,14 @@ public class CmdDisband extends FCommand {
String amountString = context.sender instanceof ConsoleCommandSender ? TL.GENERIC_SERVERADMIN.toString() : context.fPlayer.describeTo(follower); String amountString = context.sender instanceof ConsoleCommandSender ? TL.GENERIC_SERVERADMIN.toString() : context.fPlayer.describeTo(follower);
if (follower.getFaction() == faction) { if (follower.getFaction() == faction) {
follower.msg(TL.COMMAND_DISBAND_BROADCAST_YOURS, amountString); follower.msg(TL.COMMAND_DISBAND_BROADCAST_YOURS, amountString);
if (!follower.canFlyAtLocation() && FactionsPlugin.getInstance().getConfig().getBoolean("enable-faction-flight")) { if (!follower.canFlyAtLocation() && FactionsPlugin.factionsFlight) {
follower.setFFlying(false, false); follower.setFFlying(false, false);
} }
} else { } else {
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.factionsFlight) {
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")); Cooldown.setCooldown(context.fPlayer.getPlayer(), "disbandCooldown", FactionsPlugin.getInstance().getConfig().getInt("fcooldowns.f-disband"));
@ -119,7 +119,7 @@ public class CmdDisband extends FCommand {
} }
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")); 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.factionsFlight) {
context.fPlayer.setFFlying(false, false); context.fPlayer.setFFlying(false, false);
} }
} }

View File

@ -60,14 +60,11 @@ public class CmdInvite extends FCommand {
// Send the invitation to the target player when online, otherwise just ignore // Send the invitation to the target player when online, otherwise just ignore
if (target.isOnline()) { if (target.isOnline()) {
// Tooltips, colors, and commands only apply to the string immediately before it. // Tooltips, colors, and commands only apply to the string immediately before it.
FancyMessage message = new FancyMessage(context.fPlayer.describeTo(target, true)) FancyMessage message = new FancyMessage(TL.COMMAND_INVITE_INVITEDYOU.toString()
.replace("%1$s", context.fPlayer.describeTo(target, true))
.replace("%2$s", context.faction.getTag())
.replaceAll("&", "§"))
.tooltip(TL.COMMAND_INVITE_CLICKTOJOIN.toString()) .tooltip(TL.COMMAND_INVITE_CLICKTOJOIN.toString())
.command("/" + Conf.baseCommandAliases.get(0) + " join " + context.faction.getTag())
.then(TL.COMMAND_INVITE_INVITEDYOU.toString())
.color(ChatColor.YELLOW)
.tooltip(TL.COMMAND_INVITE_CLICKTOJOIN.toString())
.command("/" + Conf.baseCommandAliases.get(0) + " join " + context.faction.getTag())
.then(context.faction.describeTo(target)).tooltip(TL.COMMAND_INVITE_CLICKTOJOIN.toString())
.command("/" + Conf.baseCommandAliases.get(0) + " join " + context.faction.getTag()); .command("/" + Conf.baseCommandAliases.get(0) + " join " + context.faction.getTag());
message.send(target.getPlayer()); message.send(target.getPlayer());
} }

View File

@ -31,7 +31,7 @@ public class CmdReload extends FCommand {
if (FactionsPlugin.getInstance().getConfig().getBoolean("enable-faction-flight", false)) { if (FactionsPlugin.getInstance().getConfig().getBoolean("enable-faction-flight", false)) {
FactionsPlugin.getInstance().factionsFlight = true; FactionsPlugin.factionsFlight = true;
} }
if (!FactionsPlugin.getInstance().mc17) { if (!FactionsPlugin.getInstance().mc17) {

View File

@ -4,6 +4,7 @@ import com.google.common.collect.ArrayListMultimap;
import com.google.common.collect.ListMultimap; import com.google.common.collect.ListMultimap;
import com.massivecraft.factions.FLocation; import com.massivecraft.factions.FLocation;
import com.massivecraft.factions.struct.Permission; import com.massivecraft.factions.struct.Permission;
import com.massivecraft.factions.zcore.fperms.PermissableAction;
import com.massivecraft.factions.zcore.util.TL; import com.massivecraft.factions.zcore.util.TL;
public class CmdShowClaims extends FCommand { public class CmdShowClaims extends FCommand {
@ -16,6 +17,7 @@ public class CmdShowClaims extends FCommand {
this.aliases.addAll(Aliases.show_claims); this.aliases.addAll(Aliases.show_claims);
this.requirements = new CommandRequirements.Builder(Permission.SHOWCLAIMS) this.requirements = new CommandRequirements.Builder(Permission.SHOWCLAIMS)
.withAction(PermissableAction.TERRITORY)
.playerOnly() .playerOnly()
.memberOnly() .memberOnly()
.build(); .build();

View File

@ -33,6 +33,7 @@ public class CmdShowInvites extends FCommand {
String name = fp != null ? fp.getName() : id; String name = fp != null ? fp.getName() : id;
msg.then(name + " ").color(ChatColor.WHITE).tooltip(TL.COMMAND_SHOWINVITES_CLICKTOREVOKE.format(name)).command("/" + Conf.baseCommandAliases.get(0) + " deinvite " + name); msg.then(name + " ").color(ChatColor.WHITE).tooltip(TL.COMMAND_SHOWINVITES_CLICKTOREVOKE.format(name)).command("/" + Conf.baseCommandAliases.get(0) + " deinvite " + name);
} }
context.sendFancyMessage(msg);
} }
@Override @Override

View File

@ -20,7 +20,7 @@ public class CmdStealth extends FCommand {
@Override @Override
public void perform(CommandContext context) { public void perform(CommandContext context) {
if (!Conf.useSealthSystem) { if (!Conf.useStealthSystem) {
context.msg(TL.GENERIC_DISABLED, "Factions Stealth"); context.msg(TL.GENERIC_DISABLED, "Factions Stealth");
return; return;
} }

View File

@ -5,6 +5,7 @@ import com.massivecraft.factions.struct.Permission;
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.util.TL; import com.massivecraft.factions.zcore.util.TL;
import org.bukkit.Material;
public class CmdUnban extends FCommand { public class CmdUnban extends FCommand {
@ -48,7 +49,7 @@ public class CmdUnban extends FCommand {
context.faction.unban(target); context.faction.unban(target);
context.msg(TL.COMMAND_UNBAN_UNBANNED, context.fPlayer.getName(), target.getName()); context.msg(TL.COMMAND_UNBAN_UNBANNED, context.fPlayer.getName(), target.getName());
target.msg(TL.COMMAND_UNBAN_TARGET, context.faction.getTag(target)); target.msg(TL.COMMAND_UNBAN_TARGETUNBANNED, context.faction.getTag(target));
} }
@Override @Override

View File

@ -180,12 +180,18 @@ public class FactionsBlockListener implements Listener {
@EventHandler(priority = EventPriority.NORMAL, ignoreCancelled = true) @EventHandler(priority = EventPriority.NORMAL, ignoreCancelled = true)
public void onBlockFromTo(BlockFromToEvent event) { public void onBlockFromTo(BlockFromToEvent event) {
if (!Conf.handleExploitLiquidFlow) return; if (!Conf.handleExploitLiquidFlow) return;
if (event.getBlock().isLiquid()) { if (event.getBlock().isLiquid()) {
if (event.getToBlock().isEmpty()) { if (event.getToBlock().isEmpty()) {
Faction from = Board.getInstance().getFactionAt(new FLocation(event.getBlock())); Faction from = Board.getInstance().getFactionAt(new FLocation(event.getBlock()));
Faction to = Board.getInstance().getFactionAt(new FLocation(event.getToBlock())); Faction to = Board.getInstance().getFactionAt(new FLocation(event.getToBlock()));
if (from == to) return; if (from == to) return;
// from faction != to faction // from faction != to faction
if(to.isSystemFaction()) {
event.setCancelled(true);
return;
}
if (to.isNormal()) { if (to.isNormal()) {
if (from.isNormal() && from.getRelationTo(to).isAlly()) { if (from.isNormal() && from.getRelationTo(to).isAlly()) {
return; return;

View File

@ -36,6 +36,8 @@ import net.dv8tion.jda.core.entities.Member;
import net.dv8tion.jda.core.entities.TextChannel; import net.dv8tion.jda.core.entities.TextChannel;
import org.bukkit.*; import org.bukkit.*;
import org.bukkit.block.Block; import org.bukkit.block.Block;
import org.bukkit.entity.Boat;
import org.bukkit.entity.Minecart;
import org.bukkit.entity.Player; import org.bukkit.entity.Player;
import org.bukkit.event.Event; import org.bukkit.event.Event;
import org.bukkit.event.EventHandler; import org.bukkit.event.EventHandler;
@ -385,6 +387,10 @@ public class FactionsPlayerListener implements Listener {
case CHEST_MINECART: case CHEST_MINECART:
case BARREL: case BARREL:
case COMPOSTER:
case LOOM:
case CARTOGRAPHY_TABLE:
case GRINDSTONE:
case SHULKER_BOX: case SHULKER_BOX:
case BLACK_SHULKER_BOX: case BLACK_SHULKER_BOX:
@ -453,7 +459,6 @@ public class FactionsPlayerListener implements Listener {
case CHIPPED_ANVIL: case CHIPPED_ANVIL:
case DAMAGED_ANVIL: case DAMAGED_ANVIL:
case BREWING_STAND: case BREWING_STAND:
return PermissableAction.CONTAINER; return PermissableAction.CONTAINER;
default: default:
return null; return null;
@ -572,7 +577,7 @@ public class FactionsPlayerListener implements Listener {
} }
@Deprecated @Deprecated
public void checkCanFly(FPlayer me) { public void checkCanFly(FPlayer me) {
if (!FactionsPlugin.getInstance().getConfig().getBoolean("enable-faction-flight") || !FactionsPlugin.instance.getConfig().getBoolean("ffly.AutoEnable")) if (!FactionsPlugin.factionsFlight || !FactionsPlugin.instance.getConfig().getBoolean("ffly.AutoEnable"))
return; return;
if (me.isFlying()) return; if (me.isFlying()) return;
if (me.getPlayer().hasPermission(Permission.FLY_FLY.node)) { if (me.getPlayer().hasPermission(Permission.FLY_FLY.node)) {
@ -841,15 +846,12 @@ public class FactionsPlayerListener implements Listener {
@EventHandler @EventHandler
public void onInventorySee(InventoryClickEvent e) { public void onInventorySee(InventoryClickEvent e) {
if (e.getCurrentItem() == null) if (e.getCurrentItem() == null) return;
return; if (!e.getView().getTitle().endsWith("'s Inventory")) return;
if (!e.getView().getTitle().endsWith("'s Inventory"))
return;
e.setCancelled(true); e.setCancelled(true);
} }
@EventHandler @EventHandler
public void onPlayerBoneMeal(PlayerInteractEvent event) { public void onPlayerBoneMeal(PlayerInteractEvent event) {
Block block = event.getClickedBlock(); Block block = event.getClickedBlock();
@ -969,7 +971,7 @@ public class FactionsPlayerListener implements Listener {
if (badGuy == null) return; if (badGuy == null) return;
// if player was banned (not just kicked), get rid of their stored info // if player was banned (not just kicked), get rid of their stored info
if (Conf.removePlayerDataWhenBanned && event.getReason().equals("Banned by admin.")) { if (Conf.removePlayerDataWhenBanned && event.getReason().equals(Conf.removePlayerDataWhenBannedReason)) {
if (badGuy.getRole() == Role.LEADER) badGuy.getFaction().promoteNewLeader(); if (badGuy.getRole() == Role.LEADER) badGuy.getFaction().promoteNewLeader();

View File

@ -31,7 +31,17 @@ public class FInfoSidebar extends FSidebarProvider {
ListIterator<String> it = lines.listIterator(); ListIterator<String> it = lines.listIterator();
while (it.hasNext()) { while (it.hasNext()) {
it.set(replaceTags(faction, fplayer, it.next())); String next = it.next();
if (next == null) {
it.remove();
continue;
}
String replaced = replaceTags(faction, fplayer, next);
if (replaced == null) {
it.remove();
} else {
it.set(replaced);
}
} }
return lines; return lines;
} }

View File

@ -210,8 +210,12 @@ 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_time": case "grace_time":
return String.valueOf(TimerManager.getRemaining(FactionsPlugin.getInstance().getTimerManager().graceTimer.getRemaining(), true)); if(FactionsPlugin.getInstance().getTimerManager().graceTimer.getRemaining() >= 0) {
return String.valueOf(TimerManager.getRemaining(FactionsPlugin.getInstance().getTimerManager().graceTimer.getRemaining(), true));
} else {
return TL.GRACE_DISABLED_PLACEHOLDER.toString();
}
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

@ -85,6 +85,7 @@ public class MiscUtil {
for (char c : str.toCharArray()) { for (char c : str.toCharArray()) {
if (!substanceChars.contains(String.valueOf(c))) { if (!substanceChars.contains(String.valueOf(c))) {
errors.add(FactionsPlugin.getInstance().txt.parse(TL.GENERIC_FACTIONTAG_ALPHANUMERIC.toString(), c)); errors.add(FactionsPlugin.getInstance().txt.parse(TL.GENERIC_FACTIONTAG_ALPHANUMERIC.toString(), c));
break;
} }
} }

View File

@ -15,7 +15,7 @@ public class UtilFly {
*/ */
@Deprecated @Deprecated
public static void run() { public static void run() {
if (!FactionsPlugin.getInstance().getConfig().getBoolean("enable-faction-flight")) if (!FactionsPlugin.factionsFlight)
return; return;
Bukkit.getScheduler().scheduleSyncRepeatingTask(FactionsPlugin.getInstance(), () -> { Bukkit.getScheduler().scheduleSyncRepeatingTask(FactionsPlugin.getInstance(), () -> {
@ -28,7 +28,7 @@ public class UtilFly {
@Deprecated @Deprecated
public static void setFly(FPlayer fp, boolean fly, boolean silent, boolean damage) { public static void setFly(FPlayer fp, boolean fly, boolean silent, boolean damage) {
if (!FactionsPlugin.getInstance().getConfig().getBoolean("enable-faction-flight")) if (!FactionsPlugin.factionsFlight)
return; return;
fp.getPlayer().setAllowFlight(fly); fp.getPlayer().setAllowFlight(fly);

View File

@ -178,7 +178,6 @@ public abstract class MPlugin extends JavaPlugin {
} }
public void onDisable() { public void onDisable() {
try {
if (saveTask != null) { if (saveTask != null) {
this.getServer().getScheduler().cancelTask(saveTask); this.getServer().getScheduler().cancelTask(saveTask);
saveTask = null; saveTask = null;
@ -190,8 +189,6 @@ public abstract class MPlugin extends JavaPlugin {
Board.getInstance().forceSave(); Board.getInstance().forceSave();
} }
log("Disabled"); log("Disabled");
} catch (IllegalPluginAccessException e) {
}
} }
// -------------------------------------------- // // -------------------------------------------- //

View File

@ -28,7 +28,7 @@ public class FDisbandFrame {
private Gui gui; private Gui gui;
public FDisbandFrame(Faction faction) { public FDisbandFrame(Faction faction) {
this.gui = new Gui(FactionsPlugin.getInstance(), 1, "Confirm Disband"); this.gui = new Gui(FactionsPlugin.getInstance(), 1, ChatColor.translateAlternateColorCodes('&', Objects.requireNonNull(FactionsPlugin.getInstance().getConfig().getString("f-disband-gui.title"))));
} }
public void buildGUI(FPlayer fPlayer) { public void buildGUI(FPlayer fPlayer) {

View File

@ -40,7 +40,8 @@ public class FactionWarpsFrame {
int count = 0; int count = 0;
for (int x = 0; x <= gui.getRows() * 9 - 1; ++x) for (int x = 0; x <= gui.getRows() * 9 - 1; ++x)
GUIItems.add(new GuiItem(buildDummyItem(), e -> e.setCancelled(true))); GUIItems.add(new GuiItem(buildDummyItem(), e -> e.setCancelled(true)));
slots.forEach(slot -> GUIItems.set(slot, new GuiItem(XMaterial.AIR.parseItem()))); //We comment this out for now so it does not interfere with item placement when no warps are set
//slots.forEach(slot -> GUIItems.set(slot, new GuiItem(XMaterial.AIR.parseItem())));
for (final Map.Entry<String, LazyLocation> warp : fplayer.getFaction().getWarps().entrySet()) { for (final Map.Entry<String, LazyLocation> warp : fplayer.getFaction().getWarps().entrySet()) {
if (slots.size() < fplayer.getFaction().getWarps().entrySet().size()) { if (slots.size() < fplayer.getFaction().getWarps().entrySet().size()) {
slots.add(slots.get(slots.size() - 1) + 1); slots.add(slots.get(slots.size() - 1) + 1);

View File

@ -728,12 +728,13 @@ public abstract class MemoryFPlayer implements FPlayer {
public void sendFactionHereMessage(Faction from) { public void sendFactionHereMessage(Faction from) {
Faction toShow = Board.getInstance().getFactionAt(getLastStoodAt()); Faction toShow = Board.getInstance().getFactionAt(getLastStoodAt());
boolean showChat = true;
if(Conf.worldsNoClaiming.contains(getLastStoodAt().getWorldName())) return;
if (showInfoBoard(toShow)) { if (showInfoBoard(toShow)) {
FScoreboard.get(this).setTemporarySidebar(new FInfoSidebar(toShow)); FScoreboard.get(this).setTemporarySidebar(new FInfoSidebar(toShow));
showChat = FactionsPlugin.getInstance().getConfig().getBoolean("scoreboard.also-send-chat", true);
} }
if (showChat) if (FactionsPlugin.getInstance().getConfig().getBoolean("scoreboard.also-send-chat", true))
this.sendMessage(FactionsPlugin.getInstance().txt.parse(TL.FACTION_LEAVE.format(from.getTag(this), toShow.getTag(this)))); this.sendMessage(FactionsPlugin.getInstance().txt.parse(TL.FACTION_LEAVE.format(from.getTag(this), toShow.getTag(this))));
} }
@ -842,71 +843,72 @@ public abstract class MemoryFPlayer implements FPlayer {
} }
public boolean canClaimForFactionAtLocation(Faction forFaction, FLocation flocation, boolean notifyFailure) { public boolean canClaimForFactionAtLocation(Faction forFaction, FLocation flocation, boolean notifyFailure) {
FactionsPlugin plugin = FactionsPlugin.getInstance();
String error = null; String error = null;
Faction myFaction = getFaction(); Faction myFaction = getFaction();
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 = plugin.getConfig().getInt("hcf.buffer-zone", 0);
int worldBuffer = FactionsPlugin.getInstance().getConfig().getInt("world-border.buffer", 0) - 1; int worldBuffer = plugin.getConfig().getInt("world-border.buffer", 0) - 1;
if (Conf.worldGuardChecking && Worldguard.getInstance().checkForRegionsInChunk(flocation) && !this.isAdminBypassing()) { if (Conf.worldGuardChecking && Worldguard.getInstance().checkForRegionsInChunk(flocation)) {
// 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 = plugin.txt.parse(TL.CLAIM_PROTECTED.toString());
} else if (flocation.isOutsideWorldBorder(FactionsPlugin.getInstance().getConfig().getInt("world-border.buffer", 0) - 1)) { } else if (flocation.isOutsideWorldBorder(plugin.getConfig().getInt("world-border.buffer", 0) - 1)) {
error = FactionsPlugin.getInstance().txt.parse(TL.CLAIM_OUTSIDEWORLDBORDER.toString()); error = plugin.txt.parse(TL.CLAIM_OUTSIDEWORLDBORDER.toString());
} else if (Conf.worldsNoClaiming.contains(flocation.getWorldName())) { } else if (Conf.worldsNoClaiming.contains(flocation.getWorldName())) {
error = FactionsPlugin.getInstance().txt.parse(TL.CLAIM_DISABLED.toString()); error = plugin.txt.parse(TL.CLAIM_DISABLED.toString());
} else if (this.isAdminBypassing()) { } else if (this.isAdminBypassing()) {
return true; return true;
} else if (forFaction.isSafeZone() && Permission.MANAGE_SAFE_ZONE.has(getPlayer())) { } else if (forFaction.isSafeZone() && Permission.MANAGE_SAFE_ZONE.has(getPlayer())) {
return true; return true;
} else if (forFaction.isWarZone() && Permission.MANAGE_WAR_ZONE.has(getPlayer())) { } else if (forFaction.isWarZone() && Permission.MANAGE_WAR_ZONE.has(getPlayer())) {
return true; return true;
} else if (currentFaction.getAccess(this, PermissableAction.TERRITORY) == Access.ALLOW) { } else if (currentFaction.getAccess(this, PermissableAction.TERRITORY) == Access.ALLOW && forFaction != currentFaction ) {
return true; return true;
} else if (myFaction != forFaction) { } else if (myFaction != forFaction) {
error = FactionsPlugin.getInstance().txt.parse(TL.CLAIM_CANTCLAIM.toString(), forFaction.describeTo(this)); error = plugin.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 = plugin.txt.parse(TL.CLAIM_ALREADYOWN.toString(), forFaction.describeTo(this, true));
} 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 = plugin.txt.parse(TL.CLAIM_MEMBERS.toString(), Conf.claimsRequireMinFactionMembers);
} else if (currentFaction.isSafeZone()) { } else if (currentFaction.isSafeZone()) {
error = FactionsPlugin.getInstance().txt.parse(TL.CLAIM_SAFEZONE.toString()); error = plugin.txt.parse(TL.CLAIM_SAFEZONE.toString());
} else if (currentFaction.isWarZone()) { } else if (currentFaction.isWarZone()) {
error = FactionsPlugin.getInstance().txt.parse(TL.CLAIM_WARZONE.toString()); error = plugin.txt.parse(TL.CLAIM_WARZONE.toString());
} else if (FactionsPlugin.getInstance().getConfig().getBoolean("hcf.allow-overclaim", true) && ownedLand >= forFaction.getPowerRounded()) { } else if (plugin.getConfig().getBoolean("hcf.allow-overclaim", true) && ownedLand >= forFaction.getPowerRounded()) {
error = FactionsPlugin.getInstance().txt.parse(TL.CLAIM_POWER.toString()); error = plugin.txt.parse(TL.CLAIM_POWER.toString());
} else if (Conf.claimedLandsMax != 0 && ownedLand >= Conf.claimedLandsMax && forFaction.isNormal()) { } else if (Conf.claimedLandsMax != 0 && ownedLand >= Conf.claimedLandsMax && forFaction.isNormal()) {
error = FactionsPlugin.getInstance().txt.parse(TL.CLAIM_LIMIT.toString()); error = plugin.txt.parse(TL.CLAIM_LIMIT.toString());
} else if (currentFaction.getRelationTo(forFaction) == Relation.ALLY) { } else if (currentFaction.getRelationTo(forFaction) == Relation.ALLY) {
error = FactionsPlugin.getInstance().txt.parse(TL.CLAIM_ALLY.toString()); error = plugin.txt.parse(TL.CLAIM_ALLY.toString());
} else if (Conf.claimsMustBeConnected && !this.isAdminBypassing() && myFaction.getLandRoundedInWorld(flocation.getWorldName()) > 0 && !Board.getInstance().isConnectedLocation(flocation, myFaction) && (!Conf.claimsCanBeUnconnectedIfOwnedByOtherFaction || !currentFaction.isNormal())) { } else if (Conf.claimsMustBeConnected && !this.isAdminBypassing() && myFaction.getLandRoundedInWorld(flocation.getWorldName()) > 0 && !Board.getInstance().isConnectedLocation(flocation, myFaction) && (!Conf.claimsCanBeUnconnectedIfOwnedByOtherFaction || !currentFaction.isNormal())) {
if (Conf.claimsCanBeUnconnectedIfOwnedByOtherFaction) { if (Conf.claimsCanBeUnconnectedIfOwnedByOtherFaction) {
error = FactionsPlugin.getInstance().txt.parse(TL.CLAIM_CONTIGIOUS.toString()); error = plugin.txt.parse(TL.CLAIM_CONTIGIOUS.toString());
} else { } else {
error = FactionsPlugin.getInstance().txt.parse(TL.CLAIM_FACTIONCONTIGUOUS.toString()); error = plugin.txt.parse(TL.CLAIM_FACTIONCONTIGUOUS.toString());
} }
} else if (factionBuffer > 0 && Board.getInstance().hasFactionWithin(flocation, myFaction, factionBuffer)) { } else if (factionBuffer > 0 && Board.getInstance().hasFactionWithin(flocation, myFaction, factionBuffer)) {
error = FactionsPlugin.getInstance().txt.parse(TL.CLAIM_TOOCLOSETOOTHERFACTION.format(factionBuffer)); error = plugin.txt.parse(TL.CLAIM_TOOCLOSETOOTHERFACTION.format(factionBuffer));
} else if (flocation.isOutsideWorldBorder(worldBuffer)) { } else if (flocation.isOutsideWorldBorder(worldBuffer)) {
if (worldBuffer > 0) { if (worldBuffer > 0) {
error = FactionsPlugin.getInstance().txt.parse(TL.CLAIM_OUTSIDEBORDERBUFFER.format(worldBuffer)); error = plugin.txt.parse(TL.CLAIM_OUTSIDEBORDERBUFFER.format(worldBuffer));
} else { } else {
error = FactionsPlugin.getInstance().txt.parse(TL.CLAIM_OUTSIDEWORLDBORDER.toString()); error = plugin.txt.parse(TL.CLAIM_OUTSIDEWORLDBORDER.toString());
} }
} else if (currentFaction.isNormal()) { } else if (currentFaction.isNormal()) {
if (myFaction.isPeaceful()) { if (myFaction.isPeaceful()) {
error = FactionsPlugin.getInstance().txt.parse(TL.CLAIM_PEACEFUL.toString(), currentFaction.getTag(this)); error = plugin.txt.parse(TL.CLAIM_PEACEFUL.toString(), currentFaction.getTag(this));
} else if (currentFaction.isPeaceful()) { } else if (currentFaction.isPeaceful()) {
error = FactionsPlugin.getInstance().txt.parse(TL.CLAIM_PEACEFULTARGET.toString(), currentFaction.getTag(this)); error = plugin.txt.parse(TL.CLAIM_PEACEFULTARGET.toString(), currentFaction.getTag(this));
} else if (!currentFaction.hasLandInflation()) { } else if (!currentFaction.hasLandInflation()) {
// TODO more messages WARN current faction most importantly // TODO more messages WARN current faction most importantly
error = FactionsPlugin.getInstance().txt.parse(TL.CLAIM_THISISSPARTA.toString(), currentFaction.getTag(this)); error = plugin.txt.parse(TL.CLAIM_THISISSPARTA.toString(), currentFaction.getTag(this));
} else if (currentFaction.hasLandInflation() && !FactionsPlugin.getInstance().getConfig().getBoolean("hcf.allow-overclaim", true)) { } else if (currentFaction.hasLandInflation() && !plugin.getConfig().getBoolean("hcf.allow-overclaim", true)) {
// deny over claim when it normally would be allowed. // deny over claim when it normally would be allowed.
error = FactionsPlugin.getInstance().txt.parse(TL.CLAIM_OVERCLAIM_DISABLED.toString()); error = plugin.txt.parse(TL.CLAIM_OVERCLAIM_DISABLED.toString());
} else if (!Board.getInstance().isBorderLocation(flocation)) { } else if (!Board.getInstance().isBorderLocation(flocation)) {
error = FactionsPlugin.getInstance().txt.parse(TL.CLAIM_BORDER.toString()); error = plugin.txt.parse(TL.CLAIM_BORDER.toString());
} }
} }
// TODO: Add more else if statements. // TODO: Add more else if statements.
@ -961,7 +963,7 @@ public abstract class MemoryFPlayer implements FPlayer {
} }
public void setFFlying(boolean fly, boolean damage) { public void setFFlying(boolean fly, boolean damage) {
if (!FactionsPlugin.getInstance().getConfig().getBoolean("enable-faction-flight")) if (!FactionsPlugin.factionsFlight)
return; return;
Player player = getPlayer(); Player player = getPlayer();

View File

@ -470,7 +470,7 @@ public enum TL {
COMMAND_INVITE_TOINVITE("to invite someone"), COMMAND_INVITE_TOINVITE("to invite someone"),
COMMAND_INVITE_FORINVITE("for inviting someone"), COMMAND_INVITE_FORINVITE("for inviting someone"),
COMMAND_INVITE_CLICKTOJOIN("Click to join!"), COMMAND_INVITE_CLICKTOJOIN("Click to join!"),
COMMAND_INVITE_INVITEDYOU(" &chas invited you to join "), COMMAND_INVITE_INVITEDYOU("&l[!]&7 &c%1$s&7 has invited you to join &c%2$s&7"),
COMMAND_INVITE_INVITED("&c&l[!]&7 &c%1$s&7 invited &c%2$s&7 to your faction."), COMMAND_INVITE_INVITED("&c&l[!]&7 &c%1$s&7 invited &c%2$s&7 to your faction."),
COMMAND_ALTINVITE_INVITED_ALT("&c&l[!]&7 &c%1$s&7 invited &c%2$s&7 to your faction as an alt."), COMMAND_ALTINVITE_INVITED_ALT("&c&l[!]&7 &c%1$s&7 invited &c%2$s&7 to your faction as an alt."),
@ -972,7 +972,7 @@ public enum TL {
COMMAND_UNBAN_NOTBANNED("&7%s &cisn't banned. Not doing anything."), COMMAND_UNBAN_NOTBANNED("&7%s &cisn't banned. Not doing anything."),
COMMAND_UNBAN_TARGET_IN_OTHER_FACTION("&c%1$s is not in your faction!"), COMMAND_UNBAN_TARGET_IN_OTHER_FACTION("&c%1$s is not in your faction!"),
COMMAND_UNBAN_UNBANNED("&e%1$s &cunbanned &7%2$s"), COMMAND_UNBAN_UNBANNED("&e%1$s &cunbanned &7%2$s"),
COMMAND_UNBAN_TARGET("&aYou were unbanned from &r%s"), COMMAND_UNBAN_TARGETUNBANNED("&aYou were unbanned from &r%s"),
COMMAND_UNCLAIM_SAFEZONE_SUCCESS("Safe zone was unclaimed."), COMMAND_UNCLAIM_SAFEZONE_SUCCESS("Safe zone was unclaimed."),
COMMAND_UNCLAIM_SAFEZONE_NOPERM("This is a safe zone. You lack permissions to unclaim."), COMMAND_UNCLAIM_SAFEZONE_NOPERM("This is a safe zone. You lack permissions to unclaim."),
@ -1121,6 +1121,7 @@ public enum TL {
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."), GENERIC_WORLDGUARD("&cThis area is worldguard protected."),
GRACE_DISABLED_PLACEHOLDER("Disabled"),
// 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

@ -362,7 +362,9 @@ help:
- '&c/f banlist &8- &7List banned players from your faction.' - '&c/f banlist &8- &7List banned players from your faction.'
- '&c/f lowpower &8- &7List player with power under max from your faction.' - '&c/f lowpower &8- &7List player with power under max from your faction.'
- '&c/f coords &8- &7Broadcast your location to your faction.' - '&c/f coords &8- &7Broadcast your location to your faction.'
#THIS IS AFFILIATED WITH F PERMS PERMISSION (TERRITORY) LOL
- '&c/f showclaims &8- &7List all claims from your faction.' - '&c/f showclaims &8- &7List all claims from your faction.'
#THIS IS AFFILIATED WITH F PERMS PERMISSION (TERRITORY) LOL
- '&7&m--------------------&r &e/f help 2 &7&m-----------------------' - '&7&m--------------------&r &e/f help 2 &7&m-----------------------'
'2': '2':
- '&7&m----------------------------------------------------' - '&7&m----------------------------------------------------'
@ -600,6 +602,7 @@ fwarp-gui:
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. faction-open-broadcast: true #Disabling this will not make faction open broadcasts appear in chat.
faction-leader-broadcast: true #Disabling this will not make leader changes appear in chat.
############################################################ ############################################################
# +------------------------------------------------------+ # # +------------------------------------------------------+ #
@ -753,6 +756,7 @@ Falling-Block-Fix:
# +------------------------------------------------------+ # # +------------------------------------------------------+ #
############################################################ ############################################################
f-disband-gui: f-disband-gui:
title: '&7Confirm Disband'
confirm-item: confirm-item:
Type: LIME_STAINED_GLASS_PANE Type: LIME_STAINED_GLASS_PANE
Name: '&a&lConfirm' Name: '&a&lConfirm'