Compare commits

..

10 Commits

Author SHA1 Message Date
Driftay
ce1eedd7cd Home Fix & Version Change 2020-01-19 03:40:30 -05:00
Driftay
417cc57aa7 Confirmation Disband GUI Created 2020-01-19 02:55:56 -05:00
DroppingAnvil
57ac2c8c98 Fix getAccess for leaders 2020-01-18 21:26:21 -06:00
Driftay
25515d863e Fixed F Show & Made SaberFacs not Require Essentials 2020-01-18 02:33:01 -05:00
Driftay
2412931122 Reformat again 2020-01-18 02:20:11 -05:00
Driftay
51838df0d7 TntFill Fixed & Code Cleanup 2020-01-18 02:18:38 -05:00
Driftay
e3e6f5561c Discord Placeholders 2020-01-17 21:50:34 -05:00
Driftay
a54a7aa4fb Added Placeholders to papi 2020-01-17 21:45:18 -05:00
Driftay
9de773ddae Announcement Placeholder 2020-01-17 21:42:23 -05:00
Driftay
9a32cd9501 Adding some placeholders 2020-01-17 21:36:36 -05:00
64 changed files with 650 additions and 581 deletions

View File

@@ -4,7 +4,7 @@
<groupId>com.massivecraft</groupId>
<artifactId>Factions</artifactId>
<version>1.6.9.5-2.2.6-RC</version>
<version>1.6.9.5-2.2.7-RC</version>
<packaging>jar</packaging>
<name>SaberFactions</name>

View File

@@ -105,6 +105,9 @@ public class Conf {
//AUDIT
public static boolean useAuditSystem = true;
//GUI's
public static boolean useDisbandGUI = true;
//DISCORD
public static boolean useDiscordSystem = false;
public static String discordBotToken = "<token here>";

View File

@@ -69,7 +69,6 @@ public class FactionsPlugin extends MPlugin {
// Plugins can check this boolean while hooking in have
// a green light to use the api.
public static boolean startupFinished = false;
public static Economy econ = null;
public boolean PlaceholderApi;
// Commands
public FCmdRoot cmdBase;
@@ -182,10 +181,10 @@ public class FactionsPlugin extends MPlugin {
Conf.load();
fLogManager = new FLogManager();
//Dependency checks
if (Conf.dependencyCheck && (!Bukkit.getPluginManager().isPluginEnabled("Vault") && !Bukkit.getPluginManager().isPluginEnabled("Essentials"))) {
if (Conf.dependencyCheck && (!Bukkit.getPluginManager().isPluginEnabled("Vault"))) {
divider();
System.out.println("You are missing dependencies!");
System.out.println("Please verify EssentialsX and Vault are installed!");
System.out.println("Please verify and Vault are installed!");
Conf.save();
Bukkit.getPluginManager().disablePlugin(instance);
divider();
@@ -194,7 +193,6 @@ public class FactionsPlugin extends MPlugin {
//Update their config if needed
// Updater.updateIfNeeded(getConfig());
RegisteredServiceProvider<Economy> rsp = FactionsPlugin.this.getServer().getServicesManager().getRegistration(Economy.class);
FactionsPlugin.econ = rsp.getProvider();
com.massivecraft.factions.integration.Essentials.setup();
hookedPlayervaults = setupPlayervaults();
FPlayers.getInstance().load();

View File

@@ -143,6 +143,7 @@ public class Aliases {
public static ArrayList<String> vault = new ArrayList<>(Collections.singletonList("vault"));
public static ArrayList<String> viewChest = new ArrayList<>(Arrays.asList("viewchest", "viewpv"));
private static transient Aliases i = new Aliases();
public static void load() {
FactionsPlugin.getInstance().persist.loadOrSaveDefault(i, Aliases.class, "aliases");
}

View File

@@ -46,6 +46,7 @@ public class CmdBanner extends FCommand {
warBanner.setAmount(1);
context.player.getInventory().addItem(warBanner);
}
@Deprecated
public boolean hasMoney(FPlayer fme, int amt) {
Economy econ = FactionsPlugin.getInstance().getEcon();
@@ -55,6 +56,7 @@ public class CmdBanner extends FCommand {
fme.msg(TL.COMMAND_BANNER_NOTENOUGHMONEY);
return false;
}
@Deprecated
public void takeMoney(FPlayer fme, int amt) {
if (this.hasMoney(fme, amt)) {

View File

@@ -225,7 +225,7 @@ public class CmdConfig extends FCommand {
if (!success.isEmpty()) {
if (context.sender instanceof Player) {
context.sendMessage(success);
FactionsPlugin.getInstance().log(success + TL.COMMAND_CONFIG_LOG.format((Player) context.sender));
FactionsPlugin.getInstance().log(success + TL.COMMAND_CONFIG_LOG.format(context.sender));
} else // using FactionsPlugin.getInstance().log() instead of sendMessage if run from server console so that "[Factions v#.#.#]" is prepended in server log
{
FactionsPlugin.getInstance().log(success);

View File

@@ -115,7 +115,9 @@ public class CmdCreate extends FCommand {
Discord.mainGuild.getController().setNickname(m, Discord.getNicknameString(context.fPlayer)).queue();
}
}
} catch (HierarchyException e) {System.out.print(e.getMessage());}
} catch (HierarchyException e) {
System.out.print(e.getMessage());
}
//End Discord
context.msg(TL.COMMAND_CREATE_YOUSHOULD, FactionsPlugin.getInstance().cmdBase.cmdDescription.getUsageTemplate(context));
if (Conf.econEnabled) Econ.setBalance(faction.getAccountId(), Conf.econFactionStartingBalance);

View File

@@ -13,6 +13,7 @@ public class CmdDebug extends FCommand {
this.aliases.add("debug");
this.requirements = new CommandRequirements.Builder(Permission.DEBUG).build();
}
@Override
public void perform(CommandContext context) {
FactionsPlugin.getInstance().divider();
@@ -51,7 +52,9 @@ public class CmdDebug extends FCommand {
System.out.print("Emotes enabled: " + Discord.useEmotes);
System.out.print("Leader role null: " + (Discord.leader == null ? "True" : "False"));
System.out.print("Attempt Log:");
for (DiscordSetupAttempt d : Discord.setupLog) {System.out.print(d.getDifferentialFormatted() + " " + d.getSuccess() + " " + d.getReason());}
for (DiscordSetupAttempt d : Discord.setupLog) {
System.out.print(d.getDifferentialFormatted() + " " + d.getSuccess() + " " + d.getReason());
}
System.out.print("End Attempt Log");
System.out.print("----End Discord----");
System.out.print("--------End Debug Info--------");

View File

@@ -4,14 +4,16 @@ import com.massivecraft.factions.*;
import com.massivecraft.factions.event.FactionDisbandEvent.PlayerDisbandReason;
import com.massivecraft.factions.struct.Permission;
import com.massivecraft.factions.struct.Role;
import com.massivecraft.factions.util.UtilFly;
import com.massivecraft.factions.zcore.fdisband.FDisbandFrame;
import com.massivecraft.factions.zcore.fperms.Access;
import com.massivecraft.factions.zcore.fperms.PermissableAction;
import com.massivecraft.factions.zcore.util.TL;
import org.bukkit.Bukkit;
import org.bukkit.Sound;
import org.bukkit.command.ConsoleCommandSender;
import java.util.HashMap;
import java.util.concurrent.TimeUnit;
public class CmdDisband extends FCommand {
@@ -35,6 +37,7 @@ public class CmdDisband extends FCommand {
@Override
public void perform(CommandContext context) {
long time;
// The faction, default to your own.. but null if console sender.
Faction faction = context.argAsFaction(0, context.fPlayer == null ? null : context.faction);
if (faction == null) return;
@@ -42,9 +45,7 @@ public class CmdDisband extends FCommand {
boolean isMyFaction = context.fPlayer != null && faction == context.faction;
if (!isMyFaction) {
if (!Permission.DISBAND_ANY.has(context.sender, true)) {
return;
}
if (!Permission.DISBAND_ANY.has(context.sender, true)) return;
}
@@ -71,6 +72,21 @@ public class CmdDisband extends FCommand {
return;
}
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)) {
access = true;
}
if (!access) {
if(Conf.useDisbandGUI) {
if (!disbandMap.containsKey(context.player.getUniqueId().toString())) {
new FDisbandFrame(context.faction).buildGUI(context.fPlayer);
return;
}
}
}
// check for tnt before disbanding.
if (!disbandMap.containsKey(context.player.getUniqueId().toString()) && faction.getTnt() > 0) {
context.msg(TL.COMMAND_DISBAND_CONFIRM.toString().replace("{tnt}", faction.getTnt() + ""));
@@ -89,7 +105,8 @@ public class CmdDisband extends FCommand {
follower.msg(TL.COMMAND_DISBAND_BROADCAST_NOTYOURS, amountString, faction.getTag(follower));
}
}
if(FactionsPlugin.getInstance().getConfig().getBoolean("enable-faction-flight")) context.fPlayer.setFFlying(false, false);
if (FactionsPlugin.getInstance().getConfig().getBoolean("enable-faction-flight"))
context.fPlayer.setFFlying(false, false);
} else {
context.player.sendMessage(String.valueOf(TL.COMMAND_DISBAND_PLAYER));
}

View File

@@ -14,6 +14,7 @@ public class CmdDiscord extends FCommand {
.playerOnly()
.build();
}
@Override
public void perform(CommandContext context) {
if (context.fPlayer.discordSetup()) {

View File

@@ -7,7 +7,6 @@ import com.massivecraft.factions.FactionsPlugin;
import com.massivecraft.factions.struct.Permission;
import com.massivecraft.factions.zcore.fperms.PermissableAction;
import com.massivecraft.factions.zcore.util.TL;
import org.bukkit.entity.Player;
import java.text.DecimalFormat;

View File

@@ -102,9 +102,11 @@ public class CmdFly extends FCommand {
return false;
if (toFac.getAccess(fme, PermissableAction.FLY) == Access.ALLOW) return true;
if (fme.getFaction().isWilderness()) return false;
if (toFac.isSystemFaction()) return me.hasPermission(Permission.valueOf("FLY_" + ChatColor.stripColor(toFac.getTag()).toUpperCase()).node);
if (toFac.isSystemFaction())
return me.hasPermission(Permission.valueOf("FLY_" + ChatColor.stripColor(toFac.getTag()).toUpperCase()).node);
Relation relationTo = toFac.getRelationTo(fme.getFaction());
if (!relationTo.isEnemy() && !relationTo.isMember()) return me.hasPermission(Permission.valueOf("FLY_" + relationTo.name()).node);
if (!relationTo.isEnemy() && !relationTo.isMember())
return me.hasPermission(Permission.valueOf("FLY_" + relationTo.name()).node);
return false;
}
@@ -126,14 +128,14 @@ public class CmdFly extends FCommand {
flyMap.remove(fme.getName());
}
public boolean isInFlightChecker(Player player) {
return flyMap.containsKey(player.getName());
}
private static void checkEnemiesSync(FPlayer fp) {
Bukkit.getScheduler().runTask(FactionsPlugin.instance, fp::checkIfNearbyEnemies);
}
public boolean isInFlightChecker(Player player) {
return flyMap.containsKey(player.getName());
}
@Override
public void perform(CommandContext context) {
if (!context.fPlayer.isAdminBypassing()) {

View File

@@ -47,7 +47,9 @@ public class CmdGetVault extends FCommand {
return;
}
if (!context.fPlayer.takeMoney(amount)) {return;}
if (!context.fPlayer.takeMoney(amount)) {
return;
}
//success :)
context.player.getInventory().addItem(vault);

View File

@@ -18,6 +18,7 @@ public class CmdHelp extends FCommand {
*/
public ArrayList<ArrayList<String>> helpPages;
//TODO: Add Help GUI
public CmdHelp() {
super();

View File

@@ -139,7 +139,9 @@ public class CmdJoin extends FCommand {
Discord.mainGuild.getController().setNickname(m, Discord.getNicknameString(context.fPlayer)).queue();
}
}
} catch (HierarchyException e) {System.out.print(e.getMessage());}
} catch (HierarchyException e) {
System.out.print(e.getMessage());
}
if (Conf.logFactionJoin) {
if (samePlayer) {

View File

@@ -1,9 +1,7 @@
package com.massivecraft.factions.cmd;
import com.massivecraft.factions.Conf;
import com.massivecraft.factions.struct.Permission;
import com.massivecraft.factions.zcore.util.TL;
import org.bukkit.ChatColor;
public class CmdLeave extends FCommand {

View File

@@ -16,7 +16,6 @@ public class CmdLock extends FCommand {
description: use the /f lock [on/off] command to temporarily lock the data files from being overwritten
default: op
*/
public CmdLock() {
super();
this.aliases.addAll(Aliases.lock);

View File

@@ -29,7 +29,6 @@ public class CmdPaypalSee extends FCommand {
}
if (context.args.size() == 0) {
if (context.fPlayer.getFaction().getPaypal() == null) {
context.msg(TL.COMMAND_PAYPAL_NOTSET);

View File

@@ -11,11 +11,15 @@ public class CmdPlayerTitleToggle extends FCommand {
this.requirements = new CommandRequirements.Builder(Permission.TOGGLE_TITLES)
.build();
}
@Override
public void perform(CommandContext context) {
context.fPlayer.setTitlesEnabled(!context.fPlayer.hasTitlesEnabled());
context.msg(TL.COMMAND_TITLETOGGLE_TOGGLED, context.fPlayer.hasTitlesEnabled() ? FactionsPlugin.getInstance().color("&dEnabled") : FactionsPlugin.getInstance().color("&dDisabled"));
}
@Override
public TL getUsageTranslation() {return TL.COMMAND_TITLETOGGLE_DESCRIPTION;}
public TL getUsageTranslation() {
return TL.COMMAND_TITLETOGGLE_DESCRIPTION;
}
}

View File

@@ -29,7 +29,6 @@ public class CmdSeeDiscord extends FCommand{
}
if (context.args.size() == 0) {
if (context.fPlayer.getFaction().getDiscord() == null) {
context.msg(TL.COMMAND_DISCORD_NOTSET);

View File

@@ -2,6 +2,7 @@ package com.massivecraft.factions.cmd;
import com.massivecraft.factions.*;
import com.massivecraft.factions.struct.Permission;
import com.massivecraft.factions.zcore.fperms.Access;
import com.massivecraft.factions.zcore.fperms.PermissableAction;
import com.massivecraft.factions.zcore.util.TL;
@@ -43,6 +44,16 @@ public class CmdSethome extends FCommand {
return;
}
if (!context.args.isEmpty()) {
Faction target = context.argAsFaction(0);
if (target == null) return;
context.faction = target;
if (target.getAccess(context.fPlayer, PermissableAction.SETHOME) != Access.ALLOW) {
context.fPlayer.msg(TL.GENERIC_FPERM_NOPERMISSION, "set faction home");
return;
}
}
// if economy is enabled, they're not on the bypass list, and this command has a cost set, make 'em pay
if (!context.payForCommand(Conf.econCostSethome, TL.COMMAND_SETHOME_TOSET, TL.COMMAND_SETHOME_FORSET)) {
return;

View File

@@ -3,7 +3,6 @@ package com.massivecraft.factions.cmd;
import com.massivecraft.factions.Conf;
import com.massivecraft.factions.FPlayer;
import com.massivecraft.factions.FPlayers;
import com.massivecraft.factions.FactionsPlugin;
import com.massivecraft.factions.struct.Permission;
import com.massivecraft.factions.zcore.util.TL;
import mkremins.fanciful.FancyMessage;

View File

@@ -2,7 +2,6 @@ package com.massivecraft.factions.cmd;
import com.massivecraft.factions.FactionsPlugin;
import com.massivecraft.factions.listeners.FactionsBlockListener;
import com.massivecraft.factions.listeners.FactionsPlayerListener;
import com.massivecraft.factions.struct.Permission;
import com.massivecraft.factions.util.WarmUpUtil;
import com.massivecraft.factions.zcore.util.TL;

View File

@@ -394,7 +394,9 @@ public class FCmdRoot extends FCommand implements CommandExecutor {
}
}
public void rebuild() {if (CommodoreProvider.isSupported()) brigadierManager.build();}
public void rebuild() {
if (CommodoreProvider.isSupported()) brigadierManager.build();
}
@Override
public void perform(CommandContext context) {

View File

@@ -26,6 +26,7 @@ public class CmdAudit extends FCommand {
.noErrorOnManyArgs()
.build();
}
@Override
public void perform(CommandContext context) {
Faction faction = context.args.size() == 1 && context.sender.isOp() ? context.argAsFaction(0) : context.faction;

View File

@@ -3,6 +3,7 @@ package com.massivecraft.factions.cmd.audit;
/*
@author Saser
*/
import com.google.common.collect.Lists;
import com.massivecraft.factions.Faction;
import com.massivecraft.factions.FactionsPlugin;

View File

@@ -3,6 +3,7 @@ package com.massivecraft.factions.cmd.audit;
/**
* @author Saser
*/
import com.massivecraft.factions.FPlayer;
import com.massivecraft.factions.FPlayers;
import com.massivecraft.factions.Faction;
@@ -45,17 +46,20 @@ public class FChestListener implements Listener {
Player player = (Player) event.getWhoClicked();
FPlayer fPlayer = FPlayers.getInstance().getByPlayer(player);
Faction faction;
if(!event.getView().getTitle().equalsIgnoreCase(FactionsPlugin.getInstance().color(FactionsPlugin.getInstance().getConfig().getString("fchest.Inventory-Title")))) return;
if (!event.getView().getTitle().equalsIgnoreCase(FactionsPlugin.getInstance().color(FactionsPlugin.getInstance().getConfig().getString("fchest.Inventory-Title"))))
return;
if (event.getClick() == ClickType.UNKNOWN) {
event.setCancelled(true);
player.sendMessage(CC.RedB + "(!) " + CC.Red + "You cannot use that click type inside the /f chest!");
return;
}
ItemStack currentItem = event.getCurrentItem();
if (event.getClick() == ClickType.NUMBER_KEY) currentItem = event.getClickedInventory().getItem(event.getSlot());
if (event.getClick() == ClickType.NUMBER_KEY)
currentItem = event.getClickedInventory().getItem(event.getSlot());
Material currentItemType = currentItem != null ? currentItem.getType() : Material.AIR;
ItemStack cursorItem = event.getCursor();
if (event.getClick() == ClickType.NUMBER_KEY) cursorItem = player.getInventory().getItem(event.getHotbarButton());
if (event.getClick() == ClickType.NUMBER_KEY)
cursorItem = player.getInventory().getItem(event.getHotbarButton());
Material cursorItemType = cursorItem != null ? cursorItem.getType() : Material.AIR;
if (fPlayer == null || !(faction = fPlayer.getFaction()).isNormal()) {
player.closeInventory();

View File

@@ -3,6 +3,7 @@ package com.massivecraft.factions.cmd.audit;
/**
* @author Saser
*/
import com.google.common.reflect.TypeToken;
import com.massivecraft.factions.Faction;
import com.massivecraft.factions.Factions;

View File

@@ -27,8 +27,10 @@ public enum FLogType {
private String msg;
private int requiredArgs;
public String getDisplayName() {
return this.displayName;
FLogType(String displayName, String msg, int requiredArgs) {
this.displayName = displayName;
this.msg = msg;
this.requiredArgs = requiredArgs;
}
/**
@@ -46,16 +48,23 @@ public enum FLogType {
return null;
}
@Override
public String toString() { return name(); }
public String getDisplayName() {
return this.displayName;
}
public int getSlot() { return FactionsPlugin.getInstance().getConfig().getInt("faudit-gui.slots." + name().toLowerCase()); }
@Override
public String toString() {
return name();
}
public int getSlot() {
return FactionsPlugin.getInstance().getConfig().getInt("faudit-gui.slots." + name().toLowerCase());
}
public Material getMaterial() {
return XMaterial.matchXMaterial(FactionsPlugin.getInstance().getConfig().getString("faudit-gui.materials." + name().toLowerCase())).parseMaterial();
}
public String getMsg() {
return this.msg;
}
@@ -63,10 +72,4 @@ public enum FLogType {
public int getRequiredArgs() {
return this.requiredArgs;
}
FLogType(String displayName, String msg, int requiredArgs) {
this.displayName = displayName;
this.msg = msg;
this.requiredArgs = requiredArgs;
}
}

View File

@@ -3,6 +3,7 @@ package com.massivecraft.factions.cmd.audit;
/**
* @author Saser
*/
import com.google.common.collect.Lists;
import org.bukkit.Bukkit;
import org.bukkit.ChatColor;
@@ -16,8 +17,8 @@ import java.util.concurrent.ConcurrentHashMap;
import java.util.concurrent.TimeUnit;
public class FactionLogs {
private Map<FLogType, LinkedList<FactionLog>> mostRecentLogs = new ConcurrentHashMap<>();
public static transient SimpleDateFormat format = new SimpleDateFormat("MM/dd hh:mmaa");
private Map<FLogType, LinkedList<FactionLog>> mostRecentLogs = new ConcurrentHashMap<>();
public FactionLogs() {
}

View File

@@ -3,6 +3,7 @@ package com.massivecraft.factions.cmd.audit;
/**
* @author Saser
*/
import com.massivecraft.factions.Faction;
import com.massivecraft.factions.FactionsPlugin;
import org.apache.commons.lang.StringUtils;
@@ -65,11 +66,32 @@ public class LogTimer extends ConcurrentHashMap<LogTimer.TimerType, Map<LogTimer
return this.username;
}
public enum TimerSubType {
SPAWNER_BREAK,
SPAWNER_PLACE;
TimerSubType() {
}
}
public enum TimerType {
SPAWNER_EDIT;
TimerType() {
}
}
public class Timer {
private long startTime;
private long count;
private Object extraData;
public Timer(long startTime, long count, Object extraData) {
this.startTime = startTime;
this.count = count;
this.extraData = extraData;
}
LogTimer.Timer increment(long amount) {
this.count += amount;
return this;
@@ -79,47 +101,28 @@ public class LogTimer extends ConcurrentHashMap<LogTimer.TimerType, Map<LogTimer
return System.currentTimeMillis() - this.startTime >= expiration;
}
public Timer(long startTime, long count, Object extraData) {
this.startTime = startTime;
this.count = count;
this.extraData = extraData;
}
public long getStartTime() {
return this.startTime;
}
public long getCount() {
return this.count;
}
public Object getExtraData() {
return this.extraData;
}
public void setStartTime(long startTime) {
this.startTime = startTime;
}
public long getCount() {
return this.count;
}
public void setCount(long count) {
this.count = count;
}
public Object getExtraData() {
return this.extraData;
}
public void setExtraData(Object extraData) {
this.extraData = extraData;
}
}
public enum TimerSubType {
SPAWNER_BREAK,
SPAWNER_PLACE;
TimerSubType() {
}
}
public enum TimerType {
SPAWNER_EDIT;
TimerType() {
}
}
}

View File

@@ -1,7 +1,6 @@
package com.massivecraft.factions.cmd.claim;
import com.massivecraft.factions.Board;
import com.massivecraft.factions.Conf;
import com.massivecraft.factions.FLocation;
import com.massivecraft.factions.FactionsPlugin;
import com.massivecraft.factions.cmd.Aliases;

View File

@@ -10,8 +10,6 @@ import com.massivecraft.factions.struct.Permission;
import com.massivecraft.factions.util.CornerTask;
import com.massivecraft.factions.zcore.fperms.PermissableAction;
import com.massivecraft.factions.zcore.util.TL;
import org.bukkit.ChatColor;
import org.bukkit.entity.Player;
import java.util.ArrayList;
import java.util.Comparator;

View File

@@ -21,7 +21,6 @@ public class CmdUnclaimall extends FCommand {
*/
//TODO: Add UnclaimAll Confirmation GUI
public CmdUnclaimall() {
this.aliases.addAll(Aliases.unclaim_all_unsafe);

View File

@@ -40,7 +40,7 @@ public class CmdMoney extends FCommand {
@Override
public void perform(CommandContext context) {
if (!Conf.econEnabled || !Conf.bankEnabled) {
context.msg(TL.ECON_OFF, "economy option is enabled, please set \'econEnabled\' to true in conf.json");
context.msg(TL.ECON_OFF, "economy option is enabled, please set 'econEnabled' to true in conf.json");
return;
}
context.commandChain.add(this);

View File

@@ -8,7 +8,6 @@ import com.massivecraft.factions.cmd.FCommand;
import com.massivecraft.factions.integration.Econ;
import com.massivecraft.factions.struct.Permission;
import com.massivecraft.factions.zcore.util.TL;
import org.bukkit.command.CommandSender;
public class CmdMoneyBalance extends FCommand {

View File

@@ -16,7 +16,6 @@ public class CmdGrace extends FCommand {
*/
//TODO: Make Timed Format For Grace Period
public CmdGrace() {
super();
this.aliases.addAll(Aliases.grace);

View File

@@ -10,14 +10,22 @@ import java.util.ArrayList;
public class ListParameterizedType implements ParameterizedType {
private Type type;
public ListParameterizedType(Type type) { this.type = type; }
@Override
public Type[] getActualTypeArguments() { return new Type[] { this.type }; }
@Override
public Type getRawType() { return ArrayList.class; }
@Override
public Type getOwnerType() { return null; }
public ListParameterizedType(Type type) {
this.type = type;
}
@Override
public Type[] getActualTypeArguments() {
return new Type[]{this.type};
}
@Override
public Type getRawType() {
return ArrayList.class;
}
@Override
public Type getOwnerType() {
return null;
}
}

View File

@@ -6,13 +6,16 @@ package com.massivecraft.factions.cmd.reserve;
public class ReserveObject {
private String name;
private String factionName;
public ReserveObject(String name, String factionName) {
this.name = name;
this.factionName = factionName;
}
public String getName() {
return this.name;
}
public String getFactionName() {
return this.factionName;
}

View File

@@ -34,6 +34,24 @@ public class CmdTnt extends FCommand {
.build();
}
public static void removeItems(Inventory inventory, ItemStack item, int toRemove) {
if (toRemove <= 0 || inventory == null || item == null)
return;
for (int i = 0; i < inventory.getSize(); i++) {
ItemStack loopItem = inventory.getItem(i);
if (loopItem == null || !item.isSimilar(loopItem))
continue;
if (toRemove <= 0)
return;
if (toRemove < loopItem.getAmount()) {
loopItem.setAmount(loopItem.getAmount() - toRemove);
return;
}
inventory.clear(i);
toRemove -= loopItem.getAmount();
}
}
@Override
public void perform(CommandContext context) {
if (!FactionsPlugin.instance.getConfig().getBoolean("ftnt.Enabled")) {
@@ -110,8 +128,10 @@ public class CmdTnt extends FCommand {
return;
}
for (int i = 0; i <= fullStacks - 1; i++) context.player.getInventory().addItem(new ItemStack(XMaterial.TNT.parseMaterial(), 64));
if (remainderAmt != 0) context.player.getInventory().addItem(new ItemStack(XMaterial.TNT.parseMaterial(), remainderAmt));
for (int i = 0; i <= fullStacks - 1; i++)
context.player.getInventory().addItem(new ItemStack(XMaterial.TNT.parseMaterial(), 64));
if (remainderAmt != 0)
context.player.getInventory().addItem(new ItemStack(XMaterial.TNT.parseMaterial(), remainderAmt));
context.faction.takeTnt(amount);
context.player.updateInventory();
@@ -123,7 +143,9 @@ public class CmdTnt extends FCommand {
Inventory inv = context.player.getInventory();
int invTnt = 0;
for (int i = 0; i <= inv.getSize(); i++) {
if (inv.getItem(i) == null) { continue; }
if (inv.getItem(i) == null) {
continue;
}
if (inv.getItem(i).getType() == Material.TNT) {
invTnt += inv.getItem(i).getAmount();
}
@@ -152,7 +174,6 @@ public class CmdTnt extends FCommand {
context.sendMessage(TL.COMMAND_TNT_AMOUNT.toString().replace("{amount}", context.faction.getTnt() + "").replace("{maxAmount}", context.faction.getTntBankLimit() + ""));
}
public boolean inventoryContains(Inventory inventory, ItemStack item) {
int count = 0;
ItemStack[] items = inventory.getContents();
@@ -177,24 +198,6 @@ public class CmdTnt extends FCommand {
return check >= howmany;
}
public static void removeItems(Inventory inventory, ItemStack item, int toRemove) {
if (toRemove <= 0 || inventory == null || item == null)
return;
for (int i = 0; i < inventory.getSize(); i++) {
ItemStack loopItem = inventory.getItem(i);
if (loopItem == null || !item.isSimilar(loopItem))
continue;
if (toRemove <= 0)
return;
if (toRemove < loopItem.getAmount()) {
loopItem.setAmount(loopItem.getAmount() - toRemove);
return;
}
inventory.clear(i);
toRemove -= loopItem.getAmount();
}
}
public void removeFromInventory(Inventory inventory, ItemStack item) {
int amt = item.getAmount();
ItemStack[] items = inventory.getContents();

View File

@@ -1,6 +1,7 @@
package com.massivecraft.factions.cmd.tnt;
import com.massivecraft.factions.FPlayer;
import com.massivecraft.factions.Factions;
import com.massivecraft.factions.FactionsPlugin;
import com.massivecraft.factions.cmd.Aliases;
import com.massivecraft.factions.cmd.CommandContext;
@@ -23,13 +24,9 @@ import java.util.*;
public class CmdTntFill extends FCommand {
/**
* @author Illyria Team
*/
public CmdTntFill() {
super();
this.aliases.addAll(Aliases.tnt_tntfill);
this.aliases.add("tntfill");
this.requiredArgs.add("radius");
this.requiredArgs.add("amount");
@@ -66,15 +63,15 @@ public class CmdTntFill extends FCommand {
return;
}
if (radius > FactionsPlugin.instance.getConfig().getInt("Tntfill.max-radius")) {
context.msg(TL.COMMAND_TNTFILL_RADIUSMAX.toString().replace("{max}", FactionsPlugin.instance.getConfig().getInt("Tntfill.max-radius") + ""));
if (radius > FactionsPlugin.getInstance().getConfig().getInt("Tntfill.max-radius")) {
context.msg(TL.COMMAND_TNTFILL_RADIUSMAX.toString().replace("{max}", FactionsPlugin.getInstance().getConfig().getInt("Tntfill.max-radius") + ""));
return;
}
if (amount > FactionsPlugin.getInstance().getConfig().getInt("Tntfill.max-amount")) {
context.msg(TL.COMMAND_TNTFILL_AMOUNTMAX.toString().replace("{max}", FactionsPlugin.getInstance().getConfig().getInt("Tntfill.max-amount") + ""));
return;
}
if (amount > FactionsPlugin.instance.getConfig().getInt("Tntfill.max-amount")) {
context.msg(TL.COMMAND_TNTFILL_AMOUNTMAX.toString().replace("{max}", FactionsPlugin.instance.getConfig().getInt("Tntfill.max-amount") + ""));
return;
}
// How many dispensers are we to fill in?
Location start = context.player.getLocation();
@@ -89,104 +86,83 @@ public class CmdTntFill extends FCommand {
if (block == null) continue;
BlockState blockState = block.getState();
if (!(blockState instanceof Dispenser)) continue;
Dispenser dis = (Dispenser) blockState;
// skip if we can't add anything
if (isInvFull(dis.getInventory())) continue;
opDispensers.add((Dispenser) blockState);
}
if (opDispensers.isEmpty()) {
context.fPlayer.msg(TL.COMMAND_TNTFILL_NODISPENSERS.toString().replace("{radius}", radius + ""));
return;
}
// What's the required amount of resources
int requiredTnt = (opDispensers.size() * amount);
// Do I have enough tnt in my inventory?
int playerTnt = inventoryItemCount(context.player.getInventory(), Material.TNT);
int playerTnt = getTNTInside(context.player);
// if player does not have enough tnt, just take whatever he has and add it to the bank
// then use the bank as source. If bank < required abort.
if (playerTnt < requiredTnt) {
// How much TNT will I take from bank?
int getFactionTnt = requiredTnt - playerTnt;
// Do I have enough tnt in bank?
if ((context.faction.getTnt() < getFactionTnt)) {
if ((context.faction.getTnt() < (requiredTnt - playerTnt))) {
context.fPlayer.msg(TL.COMMAND_TNT_WIDTHDRAW_NOTENOUGH_TNT.toString());
return;
}
// Take TNT from the bank.
removeFromBank(context, getFactionTnt);
}
// move whatever tnt you have to the bank, ignoring limit because its gonna be taken out later anyways
context.faction.addTnt(playerTnt);
removeItems(context.fPlayer.getPlayer().getInventory(), new ItemStack(Material.TNT), playerTnt);
// Take TNT from the bank
fillDispensers(context, opDispensers, amount);
} else {
// Take TNT from the player
fillDispensers(context.fPlayer, opDispensers, amount);
// Remove used TNT from player inventory.
}
context.sendMessage(TL.COMMAND_TNTFILL_SUCCESS.toString().replace("{amount}", requiredTnt + "").replace("{dispensers}", opDispensers.size() + ""));
}
// Actually fill every dispenser with the precise amount.
private void fillDispensers(FPlayer fPlayer, List<Dispenser> dispensers, int count) {
for (Dispenser dispenser : dispensers) {
if (takeTnt(fPlayer, count)) {
dispenser.getInventory().addItem(new ItemStack(Material.TNT, count));
} else {return;}
int canBeAdded = getAddable(dispenser.getInventory(), Material.TNT);
if (canBeAdded <= 0) continue;
int toAdd = Math.min(canBeAdded, count);
if (toAdd > getTNTInside(fPlayer.getPlayer())) {
fPlayer.msg(TL.COMMAND_TNTFILL_NOTENOUGH.toString());
return;
}
removeItems(fPlayer.getPlayer().getInventory(), new ItemStack(Material.TNT), toAdd);
dispenser.getInventory().addItem(new ItemStack(Material.TNT, toAdd));
}
}
private void removeFromBank(CommandContext context, int amount) {
try {
Integer.parseInt(context.args.get(1));
} catch (NumberFormatException e) {
context.fPlayer.msg(TL.COMMAND_TNT_INVALID_NUM.toString());
return;
}
if (amount < 0) {
context.fPlayer.msg(TL.COMMAND_TNT_POSITIVE.toString());
return;
}
if (context.faction.getTnt() < amount) {
private void fillDispensers(CommandContext context, List<Dispenser> dispensers, int count) {
for (Dispenser dispenser : dispensers) {
int canBeAdded = getAddable(dispenser.getInventory(), Material.TNT);
if (canBeAdded <= 0) continue;
int toAdd = Math.min(canBeAdded, count);
if (context.faction.getTnt() < toAdd) {
context.fPlayer.msg(TL.COMMAND_TNT_WIDTHDRAW_NOTENOUGH_TNT.toString());
return;
}
int fullStacks = amount / 64;
int remainderAmt = amount % 64;
if ((remainderAmt == 0 && getEmptySlots(context.player) <= fullStacks)) {
context.fPlayer.msg(TL.COMMAND_TNT_WIDTHDRAW_NOTENOUGH_TNT.toString());
return;
context.faction.takeTnt(toAdd);
dispenser.getInventory().addItem(new ItemStack(Material.TNT, toAdd));
}
if (getEmptySlots(context.player) + 1 <= fullStacks) {
context.fPlayer.msg(TL.COMMAND_TNT_WIDTHDRAW_NOTENOUGH_TNT.toString());
return;
}
ItemStack tnt64 = new ItemStack(Material.TNT, 64);
for (int i = 0; i <= fullStacks - 1; i++) {
context.player.getInventory().addItem(tnt64);
}
if (remainderAmt != 0) {
ItemStack tnt = new ItemStack(Material.TNT, remainderAmt);
context.player.getInventory().addItem(tnt);
}
context.faction.takeTnt(amount);
context.player.updateInventory();
}
private boolean takeTnt(FPlayer fme, int amount) {
Inventory inv = fme.getPlayer().getInventory();
int invTnt = 0;
for (int i = 0; i <= inv.getSize(); i++) {
if (inv.getItem(i) == null) {
public static void removeItems(Inventory inventory, ItemStack item, int toRemove) {
if (toRemove <= 0 || inventory == null || item == null)
return;
for (int i = 0; i < inventory.getSize(); i++) {
ItemStack loopItem = inventory.getItem(i);
if (loopItem == null || !item.isSimilar(loopItem))
continue;
if (toRemove <= 0)
return;
if (toRemove < loopItem.getAmount()) {
loopItem.setAmount(loopItem.getAmount() - toRemove);
return;
}
if (inv.getItem(i).getType() == Material.TNT) {
invTnt += inv.getItem(i).getAmount();
inventory.clear(i);
toRemove -= loopItem.getAmount();
}
}
if (amount > invTnt) {
fme.msg(TL.COMMAND_TNTFILL_NOTENOUGH.toString());
return false;
}
ItemStack tnt = new ItemStack(Material.TNT, amount);
if (fme.getFaction().getTnt() + amount > FactionsPlugin.getInstance().getConfig().getInt("ftnt.Bank-Limit")) {
fme.msg(TL.COMMAND_TNT_EXCEEDLIMIT.toString());
return false;
}
removeFromInventory(fme.getPlayer().getInventory(), tnt);
return true;
}
// Counts the item type available in the inventory.
private int inventoryItemCount(Inventory inventory, Material mat) {
@@ -197,35 +173,37 @@ public class CmdTntFill extends FCommand {
return count;
}
private void removeFromInventory(Inventory inventory, ItemStack item) {
int amt = item.getAmount();
ItemStack[] items = inventory.getContents();
for (int i = 0; i < items.length; i++) {
if (items[i] != null && items[i].getType() == item.getType() && items[i].getDurability() == item.getDurability()) {
if (items[i].getAmount() > amt) {
items[i].setAmount(items[i].getAmount() - amt);
break;
} else if (items[i].getAmount() == amt) {
items[i] = null;
break;
} else {
amt -= items[i].getAmount();
items[i] = null;
public int getAddable(Inventory inv, Material material) {
int output = 0;
int notempty = 0;
for (int i = 0; i < inv.getSize(); ++i) {
ItemStack is = inv.getItem(i);
if (is != null) {
++notempty;
if (is.getType() == material) {
int amount = is.getAmount();
output += 64 - amount;
}
}
}
inventory.setContents(items);
return output + (inv.getSize() - notempty) * 64;
}
private int getEmptySlots(Player p) {
PlayerInventory inventory = p.getInventory();
ItemStack[] cont = inventory.getContents();
int i = 0;
for (ItemStack item : cont)
if (item != null && item.getType() != Material.AIR) {
i++;
public boolean isInvFull(Inventory inv) {
return inv.firstEmpty() == -1;
}
return 36 - i;
public int getTNTInside(Player p) {
int result = 0;
PlayerInventory pi = p.getInventory();
ItemStack[] contents;
for (int length = (contents = pi.getContents()).length, i = 0; i < length; ++i) {
ItemStack is = contents[i];
if (is != null && is.getType() == Material.TNT) {
result += is.getAmount();
}
}
return result;
}
@Override

View File

@@ -27,6 +27,7 @@ public class CmdWild extends FCommand {
public static HashMap<Player, Integer> waitingTeleport;
public static HashMap<Player, String> teleportRange;
public static HashSet<Player> teleporting;
public CmdWild() {
super();
this.aliases.addAll(Aliases.wild);
@@ -38,11 +39,14 @@ public class CmdWild extends FCommand {
teleportRange = new HashMap<>();
startWild();
}
@Override
public void perform(CommandContext context) {
if (!waitingTeleport.containsKey(context.player)) {
context.player.openInventory(new WildGUI(context.player, context.fPlayer).getInventory());
} else {context.fPlayer.msg(TL.COMMAND_WILD_WAIT);}
} else {
context.fPlayer.msg(TL.COMMAND_WILD_WAIT);
}
}
public void startWild() {
@@ -64,6 +68,7 @@ public class CmdWild extends FCommand {
}
}, 0L, 20L);
}
public void attemptTeleport(Player p) {
boolean success = false;
int tries = 0;
@@ -84,26 +89,34 @@ public class CmdWild extends FCommand {
}
tries++;
}
if (!success) {p.sendMessage(TL.COMMAND_WILD_FAILED.toString());}
if (!success) {
p.sendMessage(TL.COMMAND_WILD_FAILED.toString());
}
}
public void teleportPlayer(Player p, FLocation loc) {
Location finalLoc;
if (FactionsPlugin.getInstance().getConfig().getBoolean("Wild.Arrival.SpawnAbove")) {
finalLoc = new Location(p.getWorld(), loc.getX(), p.getWorld().getHighestBlockYAt(Math.round(loc.getX()), Math.round(loc.getZ())) + FactionsPlugin.getInstance().getConfig().getInt("Wild.Arrival.SpawnAboveBlocks", 1), loc.getZ());
} else {finalLoc = new Location(p.getWorld(), loc.getX(), p.getWorld().getHighestBlockYAt(Math.round(loc.getX()), Math.round(loc.getZ())), loc.getZ());}
} else {
finalLoc = new Location(p.getWorld(), loc.getX(), p.getWorld().getHighestBlockYAt(Math.round(loc.getX()), Math.round(loc.getZ())), loc.getZ());
}
p.teleport(finalLoc, PlayerTeleportEvent.TeleportCause.PLUGIN);
setTeleporting(p);
applyEffects(p);
}
public void applyEffects(Player p) {
for (String s : FactionsPlugin.getInstance().getConfig().getStringList("Wild.Arrival.Effects")) {
p.addPotionEffect(new PotionEffect(PotionEffectType.getByName(s), 40, 1));
}
}
public void setTeleporting(Player p) {
teleporting.add(p);
Bukkit.getScheduler().scheduleSyncDelayedTask(FactionsPlugin.instance, () -> teleporting.remove(p), FactionsPlugin.getInstance().getConfig().getInt("Wild.Arrival.FallDamageWindow") * 20);
}
@Override
public TL getUsageTranslation() {
return TL.COMMAND_WILD_DESCRIPTION;

View File

@@ -23,11 +23,13 @@ public class WildGUI implements FactionGUI {
FPlayer fplayer;
HashMap<Integer, String> map;
Inventory inv;
public WildGUI(Player player, FPlayer fplayer) {
this.player = player;
this.fplayer = fplayer;
map = new HashMap<>();
}
@Override
public void onClick(int slot, ClickType action) {
if (map.containsKey(slot)) {
@@ -72,7 +74,9 @@ public class WildGUI implements FactionGUI {
@NotNull
@Override
public Inventory getInventory() {
if (inv == null) {build();}
if (inv == null) {
build();
}
return inv;
}
}

View File

@@ -73,6 +73,9 @@ public class EngineDynmap {
}
public static String escapeHtml(String string) {
if (string == null) {
return "";
}
StringBuilder out = new StringBuilder(Math.max(16, string.length()));
for (int i = 0; i < string.length(); i++) {
char c = string.charAt(i);

View File

@@ -265,7 +265,8 @@ public class FactionsBlockListener implements Listener {
@EventHandler
public void onHopperPlace(BlockPlaceEvent e) {
if (e.getItemInHand().getType() != Material.HOPPER && !FactionsPlugin.instance.getConfig().getBoolean("fvault.No-Hoppers-near-vault")) return;
if (e.getItemInHand().getType() != Material.HOPPER && !FactionsPlugin.instance.getConfig().getBoolean("fvault.No-Hoppers-near-vault"))
return;
Faction factionAt = Board.getInstance().getFactionAt(new FLocation(e.getBlockPlaced().getLocation()));
if (factionAt.isWilderness() || factionAt.getVault() == null) return;
FPlayer fme = FPlayers.getInstance().getByPlayer(e.getPlayer());
@@ -356,12 +357,8 @@ public class FactionsBlockListener implements Listener {
return;
}
for (FPlayer fplayer : fme.getFaction().getFPlayers()) {
if (XMaterial.isVersionOrHigher(XMaterial.MinecraftVersion.VERSION_1_9)) {
fplayer.getPlayer().sendTitle(FactionsPlugin.getInstance().color(fme.getTag() + " Placed A WarBanner!"), FactionsPlugin.getInstance().color("&7use &c/f tpbanner&7 to tp to the banner!"), 10, 70, 20);
} else {
fplayer.getPlayer().sendTitle(FactionsPlugin.getInstance().color(fme.getTag() + " Placed A WarBanner!"), FactionsPlugin.getInstance().color("&7use &c/f tpbanner&7 to tp to the banner!"));
}
}
bannerCooldownMap.put(fme.getTag(), true);
FactionsBlockListener.bannerLocations.put(fme.getTag(), e.getBlockPlaced().getLocation());
int bannerCooldown = FactionsPlugin.getInstance().getConfig().getInt("fbanners.Banner-Place-Cooldown");

View File

@@ -49,6 +49,8 @@ public enum FactionTag implements Tag {
}
return null;
}),
ANNOUNCEMENT("{announcement}", (fac) -> { return String.valueOf(fac.getAnnouncements()); }),
PEACEFUL("{peaceful}", (fac) -> fac.isPeaceful() ? Conf.colorNeutral + TL.COMMAND_SHOW_PEACEFUL.toString() : ""),
PERMANENT("permanent", (fac) -> fac.isPermanent() ? "permanent" : "{notPermanent}"), // no braces needed
LAND_VALUE("{land-value}", (fac) -> Econ.shouldBeUsed() ? Econ.moneyString(Econ.calculateTotalLandValue(fac.getLandRounded())) : Tag.isMinimalShow() ? null : TL.ECON_OFF.format("value")),
@@ -61,6 +63,19 @@ public enum FactionTag implements Tag {
}
return Tag.isMinimalShow() ? null : TL.ECON_OFF.format("balance");
}),
TNT_BALANCE("{tnt-balance}", (fac) -> {
if (FactionsPlugin.instance.getConfig().getBoolean("ftnt.Enabled")) {
return String.valueOf(fac.getTnt());
}
return Tag.isMinimalShow() ? null : "";
}),
TNT_MAX("{tnt-max-balance}", (fac) -> {
if (FactionsPlugin.instance.getConfig().getBoolean("ftnt.Enabled")) {
return String.valueOf(fac.getTntBankLimit());
}
return Tag.isMinimalShow() ? null : "";
}),
ALLIES_COUNT("{allies}", (fac) -> String.valueOf(fac.getRelationCount(Relation.ALLY))),
ENEMIES_COUNT("{enemies}", (fac) -> String.valueOf(fac.getRelationCount(Relation.ENEMY))),
TRUCES_COUNT("{truces}", (fac) -> String.valueOf(fac.getRelationCount(Relation.TRUCE))),
@@ -80,6 +95,8 @@ public enum FactionTag implements Tag {
return String.valueOf(fac.getFPlayersWhereOnline(false).size());
}
}),
FACTION_STRIKES("{faction-strikes}",(fac) -> String.valueOf(fac.getStrikes())),
FACTION_POINTS("{faction-points}", (fac) -> String.valueOf(fac.getPoints())),
FACTION_SIZE("{members}", (fac) -> String.valueOf(fac.getFPlayers().size())),
FACTION_KILLS("{faction-kills}", (fac) -> String.valueOf(fac.getKills())),
FACTION_DEATHS("{faction-deaths}", (fac) -> String.valueOf(fac.getDeaths())),

View File

@@ -100,7 +100,7 @@ public enum FancyTag implements Tag {
return tag.getMessage(text, faction, player, groupMap);
}
}
return Collections.EMPTY_LIST; // We really shouldn't be here.
return Collections.emptyList(); // We really shouldn't be here.
}
public static boolean anyMatch(String text) {
@@ -174,7 +174,7 @@ public enum FancyTag implements Tag {
return test != null && test.contains(this.tag);
}
public List<FancyMessage> getMessage(String text, Faction faction, FPlayer player, Map<UUID, String> groupMap) {
public List getMessage(String text, Faction faction, FPlayer player, Map<UUID, String> groupMap) {
if (!this.foundInString(text)) {
return Collections.EMPTY_LIST; // We really, really shouldn't be here.
}

View File

@@ -18,8 +18,8 @@ public enum GeneralTag implements Tag {
MAX_ALLIES("{max-allies}", () -> getRelation("ally")),
MAX_ENEMIES("{max-enemies}", () -> getRelation("enemy")),
MAX_TRUCES("{max-truces}", () -> getRelation("truce")),
FACTIONLESS("factionless", () -> String.valueOf(FPlayers.getInstance().getOnlinePlayers().stream().filter(p -> !p.hasFaction()).count())),
FACTIONLESS_TOTAL("factionless-total", () -> String.valueOf(FPlayers.getInstance().getAllFPlayers().stream().filter(p -> !p.hasFaction()).count())),
FACTIONLESS("{factionless}", () -> String.valueOf(FPlayers.getInstance().getOnlinePlayers().stream().filter(p -> !p.hasFaction()).count())),
FACTIONLESS_TOTAL("{factionless-total}", () -> String.valueOf(FPlayers.getInstance().getAllFPlayers().stream().filter(p -> !p.hasFaction()).count())),
TOTAL_ONLINE("{total-online}", () -> String.valueOf(Bukkit.getOnlinePlayers().size())),
;

View File

@@ -3,6 +3,7 @@ package com.massivecraft.factions.util;
import com.massivecraft.factions.*;
import com.massivecraft.factions.integration.Econ;
import com.massivecraft.factions.struct.Relation;
import com.massivecraft.factions.tag.FactionTag;
import com.massivecraft.factions.tag.Tag;
import com.massivecraft.factions.zcore.util.TL;
import me.clip.placeholderapi.expansion.PlaceholderExpansion;
@@ -133,8 +134,14 @@ public class ClipPlaceholderAPIManager extends PlaceholderExpansion implements R
return faction.isPeaceful() ? Conf.colorNeutral + TL.COMMAND_SHOW_PEACEFUL.toString() : "";
case "faction_tntbank_balance":
return String.valueOf(faction.getTnt());
case "faction_tnt_max_balance":
return FactionTag.TNT_MAX.replace(FactionTag.TNT_MAX.getTag(), faction);
case "faction_points":
return fPlayer.hasFaction() ? String.valueOf(faction.getPoints()) : "0";
case "discord_acount":
return fPlayer.discordSetup() ? String.valueOf(fPlayer.discordUserID()) : "Not Linked";
case "faction_discord":
return fPlayer.hasFaction() ? String.valueOf(faction.getDiscord()) : "Not Linked";
case "faction_powerboost":
double powerBoost = faction.getPowerBoost();
return (powerBoost == 0.0) ? "" : (powerBoost > 0.0 ? TL.COMMAND_SHOW_BONUS.toString() : TL.COMMAND_SHOW_PENALTY.toString()) + powerBoost + ")";
@@ -172,6 +179,8 @@ public class ClipPlaceholderAPIManager extends PlaceholderExpansion implements R
return String.valueOf(faction.getFPlayers().size() - faction.getOnlinePlayers().size());
case "faction_size":
return String.valueOf(faction.getFPlayers().size());
case "faction_announcement":
return String.valueOf(faction.getAnnouncements());
case "faction_kills":
return String.valueOf(faction.getKills());
case "faction_deaths":

View File

@@ -21,14 +21,9 @@ public class ItemBuilder {
this.meta = item.getItemMeta();
}
public ItemBuilder(Material material, int amount, int durability) {
this(new ItemStack(material, amount, (short) durability));
}
public ItemBuilder(Material material, int amount) {
this(material, amount, 0);
this(new ItemStack(material, amount));
}
public ItemBuilder(Material material) {
this(material, 1);
}

View File

@@ -0,0 +1,27 @@
package com.massivecraft.factions.util;
/**
* Factions - Developed by FactionsUUID Team.
*/
public class Pair<Left, Right> {
public static <Left, Right> Pair<Left, Right> of(Left left, Right right) {
return new Pair<>(left, right);
}
private final Left left;
private final Right right;
private Pair(Left left, Right right) {
this.left = left;
this.right = right;
}
public Left getLeft() {
return this.left;
}
public Right getRight() {
return this.right;
}
}

View File

@@ -1,151 +0,0 @@
package com.massivecraft.factions.util.serializable;
/**
* @author Driftay
*/
import com.massivecraft.factions.FactionsPlugin;
import org.bukkit.Bukkit;
import org.bukkit.entity.Player;
import org.bukkit.event.inventory.InventoryClickEvent;
import org.bukkit.event.inventory.InventoryType;
import org.bukkit.inventory.Inventory;
import org.bukkit.inventory.ItemStack;
import org.bukkit.plugin.java.JavaPlugin;
import java.util.*;
import java.util.concurrent.ConcurrentHashMap;
import java.util.function.Consumer;
public abstract class SaberGUI {
public static Set<String> allGUINames = new HashSet<>();
public static Map<UUID, SaberGUI> activeGUIs = new ConcurrentHashMap<>();
public SaberGUI parentGUI;
protected String title;
protected int size;
protected Player player;
protected Inventory inventory;
private Map<Integer, InventoryItem> inventoryItems;
private String owningPluginName;
private Runnable closeRunnable;
public SaberGUI(Player player, String title, int size) {
this(player, title, size, InventoryType.CHEST);
}
public SaberGUI(Player player, String title, int size, InventoryType type) {
this.inventoryItems = new HashMap<>();
this.inventory = type == InventoryType.CHEST ? Bukkit.createInventory(null, size, title) : Bukkit.createInventory(null, type, title);
this.player = player;
this.size = size;
this.title = title;
allGUINames.add(this.title);
}
public SaberGUI setParentGUI(SaberGUI parent) {
this.parentGUI = parent;
return this;
}
public void onUnknownItemClick(InventoryClickEvent event) {
}
public abstract void redraw();
public void openGUI(JavaPlugin owning) {
this.owningPluginName = owning.getName();
SaberGUI currentlyActive = activeGUIs.get(this.player.getUniqueId());
if (currentlyActive != null) {
Bukkit.getLogger().info("Closing already open menu first!");
Bukkit.getScheduler().scheduleSyncDelayedTask(owning, () -> {
currentlyActive.close();
activeGUIs.put(this.player.getUniqueId(), this);
this.redraw();
this.player.openInventory(this.inventory);
});
} else {
activeGUIs.put(this.player.getUniqueId(), this);
this.redraw();
this.player.openInventory(this.inventory);
}
}
public void setItem(int slot, InventoryItem inventoryItem) {
if (inventoryItem != null && inventoryItem.getItem() != null) {
this.inventoryItems.put(slot, inventoryItem);
this.inventory.setItem(slot, inventoryItem.getItem());
} else {
this.removeItem(slot);
}
}
public void closeWithDelay() {
this.closeWithDelay(null);
}
public void closeWithDelay(Consumer<Player> afterClose) {
Bukkit.getScheduler().scheduleSyncDelayedTask(FactionsPlugin.instance, () -> {
this.player.closeInventory();
if (afterClose != null) {
afterClose.accept(this.player);
}
}, 1L);
}
public void setItem(int slot, ItemStack item, Runnable runnable) {
this.setItem(slot, (new InventoryItem(item)).click(runnable));
}
public void onInventoryClose() {
if (this.closeRunnable != null) {
this.closeRunnable.run();
}
}
public void close() {
this.onInventoryClose();
this.player.closeInventory();
}
public void removeItem(int slot) {
this.inventory.setItem(slot, null);
this.inventoryItems.remove(slot);
}
public SaberGUI setOnClose(Runnable runnable) {
this.closeRunnable = runnable;
return this;
}
public boolean isInventory(Inventory inventory) {
return this.inventory.equals(inventory);
}
public static SaberGUI getActiveGUI(UUID uuid) { return activeGUIs.get(uuid); }
public static void removeGUI(UUID uuid) {
activeGUIs.remove(uuid);
}
public SaberGUI getParentGUI() {
return this.parentGUI;
}
public Map<Integer, InventoryItem> getInventoryItems() {
return this.inventoryItems;
}
public String getOwningPluginName() {
return this.owningPluginName;
}
public void setOwningPluginName(String owningPluginName) {
this.owningPluginName = owningPluginName;
}
public Runnable getCloseRunnable() {
return this.closeRunnable;
}
}

View File

@@ -0,0 +1,89 @@
package com.massivecraft.factions.zcore.fdisband;
import com.github.stefvanschie.inventoryframework.Gui;
import com.github.stefvanschie.inventoryframework.GuiItem;
import com.github.stefvanschie.inventoryframework.pane.PaginatedPane;
import com.massivecraft.factions.FPlayer;
import com.massivecraft.factions.Faction;
import com.massivecraft.factions.FactionsPlugin;
import com.massivecraft.factions.util.XMaterial;
import org.bukkit.configuration.ConfigurationSection;
import org.bukkit.inventory.ItemStack;
import org.bukkit.inventory.meta.ItemMeta;
import org.bukkit.metadata.FixedMetadataValue;
import java.util.ArrayList;
import java.util.List;
import java.util.Objects;
/**
* Factions - Developed by Driftay.
* All rights reserved 2020.
* Creation Date: 1/18/2020
*/
public class FDisbandFrame {
private Gui gui;
public FDisbandFrame(Faction faction) {
this.gui = new Gui(FactionsPlugin.getInstance(), 1, "Confirm Disband");
}
public void buildGUI(FPlayer fPlayer) {
int i;
PaginatedPane pane = new PaginatedPane(0, 0, 9, this.gui.getRows());
List<GuiItem> GUIItems = new ArrayList<>();
ItemStack confirm = buildConfirmDummyItem(fPlayer.getFaction());
ItemStack deny = buildDenyDummyItem();
for (i = 0; i < 5; ++i) {
GUIItems.add(new GuiItem(confirm, (e) -> {
e.setCancelled(true);
fPlayer.getPlayer().setMetadata("disband_confirm", new FixedMetadataValue(FactionsPlugin.getInstance(), System.currentTimeMillis()));
fPlayer.getPlayer().closeInventory();
fPlayer.getPlayer().performCommand("f disband");
}));
}
GUIItems.set(4, new GuiItem(XMaterial.BLACK_WOOL.parseItem(), (e) -> e.setCancelled(true)));
for (i = 5; i < 10; ++i) {
GUIItems.add(new GuiItem(deny, (e) -> {
e.setCancelled(true);
fPlayer.getPlayer().closeInventory();
}));
}
pane.populateWithGuiItems(GUIItems);
gui.addPane(pane);
gui.update();
gui.show(fPlayer.getPlayer());
}
private ItemStack buildConfirmDummyItem(Faction faction) {
ConfigurationSection config = FactionsPlugin.getInstance().getConfig().getConfigurationSection("f-disband-gui.confirm-item");
ItemStack item = XMaterial.matchXMaterial(config.getString("Type")).parseItem();
ItemMeta meta = item.getItemMeta();
if (meta != null) {
List<String> lore = new ArrayList<>();
for (String s : config.getStringList("Lore")) {
lore.add(FactionsPlugin.getInstance().color(s).replace("{faction}", faction.getTag()));
}
meta.setLore(lore);
meta.setDisplayName(FactionsPlugin.getInstance().color(Objects.requireNonNull(config.getString("Name"))));
item.setItemMeta(meta);
}
return item;
}
private ItemStack buildDenyDummyItem() {
ConfigurationSection config = FactionsPlugin.getInstance().getConfig().getConfigurationSection("f-disband-gui.deny-item");
ItemStack item = XMaterial.matchXMaterial(config.getString("Type")).parseItem();
ItemMeta meta = item.getItemMeta();
if (meta != null) {
meta.setLore(FactionsPlugin.getInstance().colorList(config.getStringList("Lore")));
meta.setDisplayName(FactionsPlugin.getInstance().color(config.getString("Name")));
item.setItemMeta(meta);
}
return item;
}
}

View File

@@ -883,7 +883,7 @@ public abstract class MemoryFaction implements Faction, EconomyParticipator {
*/
public Access getAccess(FPlayer player, PermissableAction permissableAction) {
if (player == null || permissableAction == null) return Access.UNDEFINED;
if (player.getFaction() == this && player.getRole() == Role.LEADER) return Access.ALLOW;
Permissable perm = player.getFaction() == this ? player.getRole() : player.getFaction().getRelationTo(this);

View File

@@ -276,19 +276,19 @@ hcf:
show:
# First line can be {header} for default header, or any string (we recommend &m for smooth lines ;plugin)
- '&8&m--------------&7 &8<&e{faction}&8> &8&m--------------'
- '&4&l* &cOwner: &f{leader}'
- '&4&l* &cDescription: &f{description}'
- '&4&l* &cLand / Power / Max Power: &f{chunks} &8/ &f{power} &8/ &f{maxPower}'
- '&4&l* &cFaction Strikes: &f{strikes}'
- '&4&l* &cFaction Points: &f{faction-points}'
- '&4&l* &cFounded: &f{create-date}'
- '&4&l* &cBalance: &f{faction-balance}'
- '&4&l* &cAllies: &a{allies-list}'
- '&4&l* &cEnemies: &4{enemies-list}'
- '&4&l* &cOnline Members: &8[&f{online}/{members}&8] &a{online-list}'
- '&4&l* &cOffline Members: &8[&f{offline}/{members}&8] &a{offline-list}'
- '&4&l* &cAlts: &f{alts}'
- '&4&l* &cBans: &f{faction-bancount}'
- '&4* &cOwner: &f{leader}'
- '&4* &cDescription: &f{description}'
- '&4* &cLand / Power / Max Power: &f{chunks} &8/ &f{power} &8/ &f{maxPower}'
- '&4* &cFaction Strikes: &f{strikes}'
- '&4* &cFaction Points: &f{faction-points}'
- '&4* &cFounded: &f{create-date}'
- '&4* &cBalance: &f{faction-balance}'
- '&4* &cAllies: &a{allies-list}'
- '&4* &cEnemies: &4{enemies-list}'
- '&4* &cOnline Members: &8[&f{online}/{members}&8] &a{online-list}'
- '&4* &cOffline Members: &8[&f{offline}/{members}&8] &a{offline-list}'
- '&4* &cAlts: &f{alts}'
- '&4* &cBans: &f{faction-bancount}'
- '&8&m----------------------------------------'
# For a /f show that does not display fancy messages that are essentially empty, use minimal-show
minimal-show: false
@@ -651,6 +651,7 @@ frules:
- '&f'
- '&r &r &r &r &r &r &r &r &r &r &r &7&o(( Tip: Use &f&o/f rules add <rule>&7&o add a &c&orule&7&o ))'
- ''
############################################################
# +------------------------------------------------------+ #
# | Faction TNT Bank | #
@@ -708,6 +709,7 @@ F-Shop:
Name: '&cFaction Points: &b{points}'
Lore:
- ' '
############################################################
# +------------------------------------------------------+ #
# | Faction Command Cooldowns | #
@@ -730,6 +732,27 @@ fcooldowns:
Falling-Block-Fix:
enabled: true
############################################################
# +------------------------------------------------------+ #
# | Faction Disband | #
# +------------------------------------------------------+ #
############################################################
f-disband-gui:
confirm-item:
Type: LIME_STAINED_GLASS_PANE
Name: '&a&lConfirm'
Lore:
- ' '
- '&7Confirm disbanding of &a&b{faction}&7!'
deny-item:
Type: RED_STAINED_GLASS_PANE
Name: '&c&lCancel'
Lore:
- ' '
- '&7Click to cancel faction disband.'
############################################################
# +------------------------------------------------------+ #
# | Faction GracePeriod | #