Compare commits

...

39 Commits

Author SHA1 Message Date
Driftay
ed73baf5f1 SeeChunk 1.15 Fix 2020-01-29 14:32:32 -05:00
Driftay
94d2035c78 Version Change 2020-01-27 00:52:52 -05:00
Driftay
8ff8c78a44 Fixed Mouse Movement for Wild Teleportation & Properly initialized tntfill aliases 2020-01-27 00:47:48 -05:00
Driftay
591dc2172f Fixed F Disband w/Admins Disbanding Other Factions 2020-01-26 16:17:08 -05:00
Driftay
1a4c860c46 Fixed F Power Upgrade 2020-01-26 16:08:03 -05:00
Driftay
ad56264c5d 1.15 Support for Permissable Items & Fixed F Upgrades GUI Rows 2020-01-26 15:54:54 -05:00
Driftay
def1a8b15a Merge remote-tracking branch 'origin/1.6.x' into 1.6.x 2020-01-26 12:51:58 -05:00
Driftay
8b577d360b Added Barrels to Container Permissible Action & Fixed NPE When running f seechunk on 1.15.1 2020-01-26 12:51:41 -05:00
DroppingAnvil
f34ebc73fa Remove unused import. 2020-01-26 00:48:21 -06:00
DroppingAnvil
c86db7ab51 Fix system factions with custom names fly permissions. 2020-01-26 00:48:21 -06:00
Driftay
070f239948 Merge remote-tracking branch 'origin/1.6.x' into 1.6.x 2020-01-20 03:47:25 -05:00
Driftay
018f08699d 1.15 Item Conversion Complete 2020-01-20 03:46:53 -05:00
Driftay
5542245b2a Update README.md 2020-01-20 03:07:36 -05:00
Driftay
6eb204587d Update README.md 2020-01-20 02:33:32 -05:00
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
DroppingAnvil
90d39a3974 Version change
1.6.9.5-2.2.5-RC -> 1.6.9.5-2.2.6-RC
2020-01-17 18:24:53 -06:00
DroppingAnvil
6544513ca7 Many F Fly bug fixes:
- Async get nearby entities
- Not respecting admin bypass
- Not respecting permissions for system claims
- Not respecting permissions for relations
- Sending fly disabled message when user is not flying
- Sending double messages when disabling
- Sometimes disabling fly while in creative and spectator game modes
2020-01-17 17:55:37 -06:00
DroppingAnvil
f7619f0685 Fixed a few issues with CmdAdmin now being Async 2020-01-15 16:01:32 -06:00
droppinganvil
a20c2ec2eb Tiny bug fix. 2020-01-15 15:21:02 -06:00
DroppingAnvil
028734a42c Shutdown JDA on disable. 2020-01-14 12:57:09 -06:00
DroppingAnvil
29b9eadd57 Fix mistype made in Aliases. 2020-01-10 20:41:12 -06:00
Driftay
83a33c2222 Version Change 2020-01-07 15:38:43 -05:00
Driftay
c274918244 Removed everything shield wise for release with bug fixes 2020-01-07 15:37:46 -05:00
Driftay
57833bee13 Fixed TntFill (Again) -_- 2020-01-04 18:49:55 -05:00
Driftay
0a1346f1c2 Made Scoreboard Dummy Proof & Started Adding Shield Tasks Timers and Objects 2020-01-04 18:29:49 -05:00
Driftay
5145ae1714 Allowed players to continue using Essentials fly is Factions Fly is Disabled 2020-01-04 13:23:55 -05:00
Driftay
086ec3e145 Allowed Custom Heads to be in Faction Upgrades 2020-01-04 12:42:53 -05:00
Driftay
d538502457 Added Enchanting on Level 1 or Higher for Upgrades 2020-01-04 12:26:23 -05:00
Driftay
978782e2fe Remade Faction GUI 2020-01-04 12:23:10 -05:00
Driftay
ce1004d318 Removed Stream Code lol 2020-01-04 11:29:44 -05:00
88 changed files with 2530 additions and 2575 deletions

View File

@@ -1,9 +1,8 @@
# SaberFactions # SaberFactions
![Downloads](https://img.shields.io/github/downloads/driftay/saber-factions/total.svg) [![CodeFactor](https://www.codefactor.io/repository/github/driftay/saber-factions/badge)](https://www.codefactor.io/repository/github/driftay/saber-factions) ![Downloads](https://img.shields.io/github/downloads/driftay/saber-factions/total.svg) [![CodeFactor](https://www.codefactor.io/repository/github/driftay/saber-factions/badge)](https://www.codefactor.io/repository/github/driftay/saber-factions) [![License](https://img.shields.io/badge/license-GNU%20General%20Public%20License%20v3.0-brightgreen)](https://github.com/SaberLLC/Saber-Factions/blob/1.6.x/LICENSE) ![GitHub commit activity](https://img.shields.io/github/commit-activity/m/SaberLLC/Saber-Factions)
SaberFactions is a fork of both FactionsUUID and SavageFactions. Creators of those plugins include DtrShock and ProSavage. Credits to them. SaberFactions is an exotic, performance optmized, and feature rich factions plugin that focuses on not only making the player experience as great as possibly but maintaining this aspect with the cost of NOTHING! We strive to continue development for SaberFactions as the factions community is strongly growing and seeking new players every day.
SaberFactions is the newest, latest and greatest factions plugin designed for the best and most functional factions experience minecraft has seen!
## Some Exciting Features ## Some Exciting Features
Some of our features include the following Some of our features include the following
@@ -14,21 +13,27 @@ Some of our features include the following
* More F Upgrades - Unbreakable Redstone Upgrade, Members Upgrade, and Power Upgrade. * More F Upgrades - Unbreakable Redstone Upgrade, Members Upgrade, and Power Upgrade.
* Factions Corner - In the corner of a world? No Problem /f corner will claim your entire buffer for you! * Factions Corner - In the corner of a world? No Problem /f corner will claim your entire buffer for you!
* Command Cooldowns - Configurable Command Cooldowns for most "spam" commands. And so Much More to Come! * Command Cooldowns - Configurable Command Cooldowns for most "spam" commands. And so Much More to Come!
* Faction Points - A point based currency that can be used for any aspect of factions gameplay!
* Faction Shop - A shop that essentially lets players buy in-game items in exchange for faction points!
* Faction Discord Integration - A discord intergrated factions bot for each faction to have their own personalized discord bot within their faction!
* Faction Audit - A full based logging system (GUI designed) to see every aspect of what happens in your faction!
* Factions Check System - An automated check system that alerts players when to check walls/buffers!
* Faction Reserves - A system designed to reserve a specific faction name for a specific player!
## Dependency With Maven ## Dependency With Maven
``` ```
<repositories> <repositories>
<repository> <repository>
<id>jitpack.io</id> <id>jitpack.io</id>
<url>https://jitpack.io</url> <url>https://jitpack.io</url>
</repository> </repository>
</repositories> </repositories>
<dependency> <dependency>
<groupId>com.github.Driftay</groupId> <groupId>com.github.SaberLLC</groupId>
<artifactId>Saber-Factions</artifactId> <artifactId>Saber-Factions</artifactId>
<version>1.4.1</version> <version>2.2.7-STABLE</version>
</dependency> </dependency>
``` ```
## Moving Forward ## Moving Forward
@@ -36,8 +41,8 @@ Moving forward we plan to take all suggestions into consideration, as they come
We Plan on Releasing the latest and greatest factions/skyblock/prison plugins minecraft has to offer and wont settle for anything less We Plan on Releasing the latest and greatest factions/skyblock/prison plugins minecraft has to offer and wont settle for anything less
## Support ## Support
Our Discord is Currently In Progress of a Massive Overhaul, but we still encourage our community to join and express any concerns/questions/suggestions they may have Have a problem, question, or concer? We encourage our community to join and express any inquiry you may have
https://Discord.Saber.pw https://discord.saber.pw
Look forward to a bright future and a journey with all of you! Look forward to a bright future and a journey with all of you!

12
pom.xml
View File

@@ -4,7 +4,7 @@
<groupId>com.massivecraft</groupId> <groupId>com.massivecraft</groupId>
<artifactId>Factions</artifactId> <artifactId>Factions</artifactId>
<version>1.6.9.5-2.2.4-RC</version> <version>1.6.9.5-2.2.8-RC</version>
<packaging>jar</packaging> <packaging>jar</packaging>
<name>SaberFactions</name> <name>SaberFactions</name>
@@ -385,6 +385,12 @@
</exclusion> </exclusion>
</exclusions> </exclusions>
</dependency> </dependency>
<dependency>
<groupId>com.mojang</groupId>
<artifactId>authlib</artifactId>
<version>1.5.21</version>
<scope>compile</scope>
</dependency>
<dependency> <dependency>
<groupId>me.rayzr522</groupId> <groupId>me.rayzr522</groupId>
<artifactId>jsonmessage</artifactId> <artifactId>jsonmessage</artifactId>
@@ -405,6 +411,10 @@
<name>bintray</name> <name>bintray</name>
<url>http://jcenter.bintray.com</url> <url>http://jcenter.bintray.com</url>
</repository> </repository>
<repository>
<id>mojang-repo</id>
<url>https://libraries.minecraft.net/</url>
</repository>
<repository> <repository>
<id>net.coreprotect</id> <id>net.coreprotect</id>
<url>http://maven.playpro.com/</url> <url>http://maven.playpro.com/</url>

View File

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

View File

@@ -31,6 +31,19 @@ public interface FPlayer extends EconomyParticipator {
boolean hasNotificationsEnabled(); boolean hasNotificationsEnabled();
/**
* Determine if a player has enemies nearby based on the enemy check task in CmdFly
* NOTE: THIS VALUE IS ONLY UPDATED WHEN A USER IS USING FLY
* @return enemiesNearby as a boolean
*/
boolean hasEnemiesNearby();
/**
* Set if this FPlayer has an enemy nearby
* @param b enemiesNearby
*/
void setEnemiesNearby(Boolean b);
/** /**
* Get if a player has setup their Discord before * Get if a player has setup their Discord before
* @return if the player setup Discord as a boolean * @return if the player setup Discord as a boolean

View File

@@ -441,4 +441,7 @@ public interface Faction extends EconomyParticipator {
void paypalSet(String paypal); void paypalSet(String paypal);
// -------------------------------
// Shields
// -------------------------------
} }

View File

@@ -31,7 +31,6 @@ import com.massivecraft.factions.zcore.MPlugin;
import com.massivecraft.factions.zcore.fperms.Access; import com.massivecraft.factions.zcore.fperms.Access;
import com.massivecraft.factions.zcore.fperms.Permissable; import com.massivecraft.factions.zcore.fperms.Permissable;
import com.massivecraft.factions.zcore.fperms.PermissableAction; import com.massivecraft.factions.zcore.fperms.PermissableAction;
import com.massivecraft.factions.zcore.fupgrades.FUpgradesGUI;
import com.massivecraft.factions.zcore.fupgrades.UpgradesListener; import com.massivecraft.factions.zcore.fupgrades.UpgradesListener;
import com.massivecraft.factions.zcore.util.TextUtil; import com.massivecraft.factions.zcore.util.TextUtil;
import me.lucko.commodore.CommodoreProvider; import me.lucko.commodore.CommodoreProvider;
@@ -70,7 +69,6 @@ public class FactionsPlugin extends MPlugin {
// Plugins can check this boolean while hooking in have // Plugins can check this boolean while hooking in have
// a green light to use the api. // a green light to use the api.
public static boolean startupFinished = false; public static boolean startupFinished = false;
public static Economy econ = null;
public boolean PlaceholderApi; public boolean PlaceholderApi;
// Commands // Commands
public FCmdRoot cmdBase; public FCmdRoot cmdBase;
@@ -80,6 +78,7 @@ public class FactionsPlugin extends MPlugin {
public boolean mc112 = false; public boolean mc112 = false;
public boolean mc113 = false; public boolean mc113 = false;
public boolean mc114 = false; public boolean mc114 = false;
public boolean mc115 = false;
public boolean useNonPacketParticles = false; public boolean useNonPacketParticles = false;
public boolean factionsFlight = false; public boolean factionsFlight = false;
SkriptAddon skriptAddon; SkriptAddon skriptAddon;
@@ -124,21 +123,15 @@ public class FactionsPlugin extends MPlugin {
} }
public void playSoundForAll(String sound) { public void playSoundForAll(String sound) {
for (Player pl : Bukkit.getOnlinePlayers()) { for (Player pl : Bukkit.getOnlinePlayers()) playSound(pl, sound);
playSound(pl, sound);
}
} }
public void playSoundForAll(List<String> sounds) { public void playSoundForAll(List<String> sounds) {
for (Player pl : Bukkit.getOnlinePlayers()) { for (Player pl : Bukkit.getOnlinePlayers()) playSound(pl, sounds);
playSound(pl, sounds);
}
} }
public void playSound(Player p, List<String> sounds) { public void playSound(Player p, List<String> sounds) {
for (String sound : sounds) { for (String sound : sounds) playSound(p, sound);
playSound(p, sound);
}
} }
public void playSound(Player p, String sound) { public void playSound(Player p, String sound) {
@@ -172,13 +165,15 @@ public class FactionsPlugin extends MPlugin {
FactionsPlugin.instance.log("Minecraft Version 1.14 found."); FactionsPlugin.instance.log("Minecraft Version 1.14 found.");
mc114 = true; mc114 = true;
break; break;
case 15:
FactionsPlugin.instance.log("Minecraft Version 1.15 found.");
mc115 = true;
break;
} }
migrateFPlayerLeaders(); migrateFPlayerLeaders();
log("==== End Setup ===="); log("==== End Setup ====");
if (!preEnable()) { if (!preEnable()) return;
return;
}
this.loadSuccessful = false; this.loadSuccessful = false;
if (!new File(this.getDataFolder() + "/config.yml").exists()) { if (!new File(this.getDataFolder() + "/config.yml").exists()) {
@@ -191,19 +186,18 @@ public class FactionsPlugin extends MPlugin {
Conf.load(); Conf.load();
fLogManager = new FLogManager(); fLogManager = new FLogManager();
//Dependency checks //Dependency checks
if (Conf.dependencyCheck && (!Bukkit.getPluginManager().isPluginEnabled("Vault") && !Bukkit.getPluginManager().isPluginEnabled("Essentials"))) { if (Conf.dependencyCheck && (!Bukkit.getPluginManager().isPluginEnabled("Vault"))) {
divider(); divider();
System.out.println("You are missing dependencies!"); 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(); Conf.save();
Bukkit.getPluginManager().disablePlugin(instance); Bukkit.getPluginManager().disablePlugin(instance);
divider(); divider();
return; return;
} }
//Update their config if needed //Update their config if needed
// Updater.updateIfNeeded(getConfig()); // Updater.updateIfNeeded(getConfig());
RegisteredServiceProvider<Economy> rsp = FactionsPlugin.this.getServer().getServicesManager().getRegistration(Economy.class); RegisteredServiceProvider<Economy> rsp = FactionsPlugin.this.getServer().getServicesManager().getRegistration(Economy.class);
FactionsPlugin.econ = rsp.getProvider();
com.massivecraft.factions.integration.Essentials.setup(); com.massivecraft.factions.integration.Essentials.setup();
hookedPlayervaults = setupPlayervaults(); hookedPlayervaults = setupPlayervaults();
FPlayers.getInstance().load(); FPlayers.getInstance().load();
@@ -216,16 +210,10 @@ public class FactionsPlugin extends MPlugin {
fPlayer.resetFactionData(false); fPlayer.resetFactionData(false);
continue; continue;
} }
if (fPlayer.isAlt()) { if (fPlayer.isAlt()) faction.addAltPlayer(fPlayer);
faction.addAltPlayer(fPlayer); else faction.addFPlayer(fPlayer);
} else {
faction.addFPlayer(fPlayer);
}
} }
if (getConfig().getBoolean("enable-faction-flight", true)) {
UtilFly.run();
}
Board.getInstance().load(); Board.getInstance().load();
Board.getInstance().clean(); Board.getInstance().clean();
@@ -250,9 +238,7 @@ public class FactionsPlugin extends MPlugin {
log("Minecraft Version 1.9 or higher found, using non packet based particle API"); log("Minecraft Version 1.9 or higher found, using non packet based particle API");
} }
if (getConfig().getBoolean("enable-faction-flight")) { if (getConfig().getBoolean("enable-faction-flight")) factionsFlight = true;
factionsFlight = true;
}
if (getServer().getPluginManager().getPlugin("Skript") != null) { if (getServer().getPluginManager().getPlugin("Skript") != null) {
log("Skript was found! Registering FactionsPlugin Addon..."); log("Skript was found! Registering FactionsPlugin Addon...");
@@ -288,7 +274,6 @@ public class FactionsPlugin extends MPlugin {
new FactionsEntityListener(), new FactionsEntityListener(),
new FactionsExploitListener(), new FactionsExploitListener(),
new FactionsBlockListener(), new FactionsBlockListener(),
new FUpgradesGUI(),
new UpgradesListener(), new UpgradesListener(),
new MissionHandler(this), new MissionHandler(this),
new FChestListener(), new FChestListener(),
@@ -317,14 +302,10 @@ public class FactionsPlugin extends MPlugin {
json = "[]"; json = "[]";
} }
reserveObjects = this.getGsonBuilder().create().fromJson(json, new ListParameterizedType(ReserveObject.class)); reserveObjects = this.getGsonBuilder().create().fromJson(json, new ListParameterizedType(ReserveObject.class));
if (reserveObjects == null) { if (reserveObjects == null) reserveObjects = new ArrayList<>();
reserveObjects = new ArrayList<>(); } catch (Exception e) {
}
}
catch (Exception e) {
e.printStackTrace(); e.printStackTrace();
} }
if (getDescription().getFullName().contains("BETA")) { if (getDescription().getFullName().contains("BETA")) {
divider(); divider();
System.out.println("You are using a BETA version of the plugin!"); System.out.println("You are using a BETA version of the plugin!");
@@ -381,7 +362,6 @@ public class FactionsPlugin extends MPlugin {
try { try {
BufferedReader br = new BufferedReader(new FileReader(fplayerFile)); BufferedReader br = new BufferedReader(new FileReader(fplayerFile));
System.out.println("Migrating old players.json file."); System.out.println("Migrating old players.json file.");
String line; String line;
while ((line = br.readLine()) != null) { while ((line = br.readLine()) != null) {
if (line.contains("\"role\": \"ADMIN\"")) { if (line.contains("\"role\": \"ADMIN\"")) {
@@ -413,9 +393,7 @@ public class FactionsPlugin extends MPlugin {
private boolean setupPermissions() { private boolean setupPermissions() {
try { try {
RegisteredServiceProvider<Permission> rsp = getServer().getServicesManager().getRegistration(Permission.class); RegisteredServiceProvider<Permission> rsp = getServer().getServicesManager().getRegistration(Permission.class);
if (rsp != null) { if (rsp != null) perms = rsp.getProvider();
perms = rsp.getProvider();
}
} catch (NoClassDefFoundError ex) { } catch (NoClassDefFoundError ex) {
return false; return false;
} }
@@ -453,15 +431,17 @@ public class FactionsPlugin extends MPlugin {
@Override @Override
public void onDisable() { public void onDisable() {
// only save data if plugin actually completely loaded successfully // only save data if plugin actually completely loaded successfully
if (this.loadSuccessful) { if (this.loadSuccessful) Conf.saveSync();
Conf.saveSync();
}
if (AutoLeaveTask != null) { if (AutoLeaveTask != null) {
this.getServer().getScheduler().cancelTask(AutoLeaveTask); this.getServer().getScheduler().cancelTask(AutoLeaveTask);
AutoLeaveTask = null; AutoLeaveTask = null;
} }
DiscordListener.saveGuilds(); DiscordListener.saveGuilds();
if (Discord.jda != null) {
Discord.jda.shutdownNow();
}
super.onDisable(); super.onDisable();
try { try {
fLogManager.saveLogs(); fLogManager.saveLogs();
@@ -472,9 +452,7 @@ public class FactionsPlugin extends MPlugin {
public void startAutoLeaveTask(boolean restartIfRunning) { public void startAutoLeaveTask(boolean restartIfRunning) {
if (AutoLeaveTask != null) { if (AutoLeaveTask != null) {
if (!restartIfRunning) { if (!restartIfRunning) return;
return;
}
this.getServer().getScheduler().cancelTask(AutoLeaveTask); this.getServer().getScheduler().cancelTask(AutoLeaveTask);
} }
@@ -491,7 +469,7 @@ public class FactionsPlugin extends MPlugin {
} }
public ItemStack createItem(Material material, int amount, short datavalue, String name, List<String> lore) { public ItemStack createItem(Material material, int amount, short datavalue, String name, List<String> lore) {
ItemStack item = new ItemStack(XMaterial.matchXMaterial(material.toString()).parseMaterial(), amount, datavalue); ItemStack item = new ItemStack(XMaterial.matchXMaterial(material.toString()).get().parseMaterial(), amount, datavalue);
ItemMeta meta = item.getItemMeta(); ItemMeta meta = item.getItemMeta();
meta.setDisplayName(color(name)); meta.setDisplayName(color(name));
meta.setLore(colorList(lore)); meta.setLore(colorList(lore));
@@ -526,9 +504,7 @@ public class FactionsPlugin extends MPlugin {
@Override @Override
public boolean onCommand(CommandSender sender, Command command, String label, String[] split) { public boolean onCommand(CommandSender sender, Command command, String label, String[] split) {
if (split.length == 0) { if (split.length == 0) return handleCommand(sender, "/f help", false);
return handleCommand(sender, "/f help", false);
}
// otherwise, needs to be handled; presumably another plugin directly ran the command // otherwise, needs to be handled; presumably another plugin directly ran the command
String cmd = Conf.baseCommandAliases.isEmpty() ? "/f" : "/" + Conf.baseCommandAliases.get(0); String cmd = Conf.baseCommandAliases.isEmpty() ? "/f" : "/" + Conf.baseCommandAliases.get(0);
@@ -541,8 +517,6 @@ public class FactionsPlugin extends MPlugin {
// Must be a LinkedList to prevent UnsupportedOperationException. // Must be a LinkedList to prevent UnsupportedOperationException.
List<String> argsList = new LinkedList<>(Arrays.asList(args)); List<String> argsList = new LinkedList<>(Arrays.asList(args));
CommandContext context = new CommandContext(sender, argsList, alias); CommandContext context = new CommandContext(sender, argsList, alias);
String cmd = Conf.baseCommandAliases.isEmpty() ? "/f" : "/" + Conf.baseCommandAliases.get(0);
// String cmdValid = (cmd + " " + TextUtil.implode(context.args, " ")).trim();
List<FCommand> commandsList = cmdBase.subCommands; List<FCommand> commandsList = cmdBase.subCommands;
FCommand commandsEx = cmdBase; FCommand commandsEx = cmdBase;
List<String> completions = new ArrayList<>(); List<String> completions = new ArrayList<>();
@@ -571,16 +545,12 @@ public class FactionsPlugin extends MPlugin {
} }
} }
String lastArg = args[args.length - 1].toLowerCase(); String lastArg = args[args.length - 1].toLowerCase();
completions = completions.stream() completions = completions.stream()
.filter(m -> m.toLowerCase().startsWith(lastArg)) .filter(m -> m.toLowerCase().startsWith(lastArg))
.collect(Collectors.toList()); .collect(Collectors.toList());
return completions; return completions;
} else { } else {
String lastArg = args[args.length - 1].toLowerCase(); String lastArg = args[args.length - 1].toLowerCase();
for (Role value : Role.values()) completions.add(value.nicename); for (Role value : Role.values()) completions.add(value.nicename);
for (Relation value : Relation.values()) completions.add(value.nicename); for (Relation value : Relation.values()) completions.add(value.nicename);
// The stream and foreach from the old implementation looped 2 times, by looping all players -> filtered -> looped filter and added -> filtered AGAIN at the end. // The stream and foreach from the old implementation looped 2 times, by looping all players -> filtered -> looped filter and added -> filtered AGAIN at the end.
@@ -619,11 +589,8 @@ public class FactionsPlugin extends MPlugin {
// Does player have Faction Chat enabled? If so, chat plugins should preferably not do channels, // Does player have Faction Chat enabled? If so, chat plugins should preferably not do channels,
// local chat, or anything else which targets individual recipients, so Faction Chat can be done // local chat, or anything else which targets individual recipients, so Faction Chat can be done
public boolean isPlayerFactionChatting(Player player) { public boolean isPlayerFactionChatting(Player player) {
if (player == null) { if (player == null) return false;
return false;
}
FPlayer me = FPlayers.getInstance().getByPlayer(player); FPlayer me = FPlayers.getInstance().getByPlayer(player);
return me != null && me.getChatMode().isAtLeast(ChatMode.ALLIANCE); return me != null && me.getChatMode().isAtLeast(ChatMode.ALLIANCE);
} }
@@ -644,15 +611,11 @@ public class FactionsPlugin extends MPlugin {
public String getPlayerFactionTagRelation(Player speaker, Player listener) { public String getPlayerFactionTagRelation(Player speaker, Player listener) {
String tag = "~"; String tag = "~";
if (speaker == null) { if (speaker == null) return tag;
return tag;
}
FPlayer me = FPlayers.getInstance().getByPlayer(speaker); FPlayer me = FPlayers.getInstance().getByPlayer(speaker);
if (me == null) { if (me == null) return tag;
return tag;
}
// if listener isn't set, or config option is disabled, give back uncolored tag // if listener isn't set, or config option is disabled, give back uncolored tag
if (listener == null || !Conf.chatTagRelationColored) { if (listener == null || !Conf.chatTagRelationColored) {
tag = me.getChatTag().trim(); tag = me.getChatTag().trim();
@@ -660,15 +623,11 @@ public class FactionsPlugin extends MPlugin {
FPlayer you = FPlayers.getInstance().getByPlayer(listener); FPlayer you = FPlayers.getInstance().getByPlayer(listener);
if (you == null) { if (you == null) {
tag = me.getChatTag().trim(); tag = me.getChatTag().trim();
} else // everything checks out, give the colored tag } else { // everything checks out, give the colored tag
{
tag = me.getChatTag(you).trim(); tag = me.getChatTag(you).trim();
} }
} }
if (tag.isEmpty()) { if (tag.isEmpty()) tag = "~";
tag = "~";
}
return tag; return tag;
} }
@@ -683,15 +642,9 @@ public class FactionsPlugin extends MPlugin {
// Get a player's title within their faction, mainly for usage by chat plugins for local/channel chat // Get a player's title within their faction, mainly for usage by chat plugins for local/channel chat
public String getPlayerTitle(Player player) { public String getPlayerTitle(Player player) {
if (player == null) { if (player == null) return "";
return "";
}
FPlayer me = FPlayers.getInstance().getByPlayer(player); FPlayer me = FPlayers.getInstance().getByPlayer(player);
if (me == null) { if (me == null) return "";
return "";
}
return me.getTitle().trim(); return me.getTitle().trim();
} }
@@ -702,9 +655,7 @@ public class FactionsPlugin extends MPlugin {
//colors a string list //colors a string list
public List<String> colorList(List<String> lore) { public List<String> colorList(List<String> lore) {
for (int i = 0; i <= lore.size() - 1; i++) { for (int i = 0; i <= lore.size() - 1; i++) lore.set(i, color(lore.get(i)));
lore.set(i, color(lore.get(i)));
}
return lore; return lore;
} }
@@ -722,9 +673,7 @@ public class FactionsPlugin extends MPlugin {
Set<String> players = new HashSet<>(); Set<String> players = new HashSet<>();
Faction faction = Factions.getInstance().getByTag(factionTag); Faction faction = Factions.getInstance().getByTag(factionTag);
if (faction != null) { if (faction != null) {
for (FPlayer fplayer : faction.getFPlayers()) { for (FPlayer fplayer : faction.getFPlayers()) players.add(fplayer.getName());
players.add(fplayer.getName());
}
} }
return players; return players;
} }
@@ -734,9 +683,7 @@ public class FactionsPlugin extends MPlugin {
Set<String> players = new HashSet<>(); Set<String> players = new HashSet<>();
Faction faction = Factions.getInstance().getByTag(factionTag); Faction faction = Factions.getInstance().getByTag(factionTag);
if (faction != null) { if (faction != null) {
for (FPlayer fplayer : faction.getFPlayersWhereOnline(true)) { for (FPlayer fplayer : faction.getFPlayersWhereOnline(true)) players.add(fplayer.getName());
players.add(fplayer.getName());
}
} }
return players; return players;
} }
@@ -756,9 +703,7 @@ public class FactionsPlugin extends MPlugin {
} }
public void debug(Level level, String s) { public void debug(Level level, String s) {
if (getConfig().getBoolean("debug", false)) { if (getConfig().getBoolean("debug", false)) getLogger().log(level, s);
getLogger().log(level, s);
}
} }
public FactionsPlayerListener getFactionsPlayerListener() { public FactionsPlayerListener getFactionsPlayerListener() {

View File

@@ -46,7 +46,7 @@ public class Aliases {
public static ArrayList<String> relation_truce = new ArrayList<>(Collections.singletonList("truce")); public static ArrayList<String> relation_truce = new ArrayList<>(Collections.singletonList("truce"));
public static ArrayList<String> reserve = new ArrayList<>(Collections.singletonList("reserve")); public static ArrayList<String> reserve = new ArrayList<>(Collections.singletonList("reserve"));
public static ArrayList<String> roles_demote = new ArrayList<>(Collections.singletonList("demote")); public static ArrayList<String> roles_demote = new ArrayList<>(Collections.singletonList("demote"));
public static ArrayList<String> roles_promote = new ArrayList<>(Collections.singletonList("ally")); public static ArrayList<String> roles_promote = new ArrayList<>(Collections.singletonList("promote"));
public static ArrayList<String> tnt_tnt = new ArrayList<>(Collections.singletonList("tnt")); public static ArrayList<String> tnt_tnt = new ArrayList<>(Collections.singletonList("tnt"));
public static ArrayList<String> tnt_tntfill = new ArrayList<>(Collections.singletonList("tntfill")); public static ArrayList<String> tnt_tntfill = new ArrayList<>(Collections.singletonList("tntfill"));
public static ArrayList<String> wild = new ArrayList<>(Collections.singletonList("wild")); public static ArrayList<String> wild = new ArrayList<>(Collections.singletonList("wild"));
@@ -143,6 +143,7 @@ public class Aliases {
public static ArrayList<String> vault = new ArrayList<>(Collections.singletonList("vault")); public static ArrayList<String> vault = new ArrayList<>(Collections.singletonList("vault"));
public static ArrayList<String> viewChest = new ArrayList<>(Arrays.asList("viewchest", "viewpv")); public static ArrayList<String> viewChest = new ArrayList<>(Arrays.asList("viewchest", "viewpv"));
private static transient Aliases i = new Aliases(); private static transient Aliases i = new Aliases();
public static void load() { public static void load() {
FactionsPlugin.getInstance().persist.loadOrSaveDefault(i, Aliases.class, "aliases"); FactionsPlugin.getInstance().persist.loadOrSaveDefault(i, Aliases.class, "aliases");
} }

View File

@@ -70,7 +70,7 @@ public class CmdAdmin extends FCommand {
// if target player is currently admin, demote and replace him // if target player is currently admin, demote and replace him
if (fyou == admin) { if (fyou == admin) {
targetFaction.promoteNewLeader(); promoteNewLeader(targetFaction);
context.msg(TL.COMMAND_ADMIN_DEMOTES, fyou.describeTo(context.fPlayer, true)); context.msg(TL.COMMAND_ADMIN_DEMOTES, fyou.describeTo(context.fPlayer, true));
fyou.msg(TL.COMMAND_ADMIN_DEMOTED, context.player == null ? TL.GENERIC_SERVERADMIN.toString() : context.fPlayer.describeTo(fyou, true)); fyou.msg(TL.COMMAND_ADMIN_DEMOTED, context.player == null ? TL.GENERIC_SERVERADMIN.toString() : context.fPlayer.describeTo(fyou, true));
return; return;
@@ -78,9 +78,9 @@ public class CmdAdmin extends FCommand {
// promote target player, and demote existing admin if one exists // promote target player, and demote existing admin if one exists
if (admin != null) { if (admin != null) {
admin.setRole(Role.COLEADER); setRole(admin, Role.COLEADER);
} }
fyou.setRole(Role.LEADER); setRole(fyou, Role.LEADER);
context.msg(TL.COMMAND_ADMIN_PROMOTES, fyou.describeTo(context.fPlayer, true)); context.msg(TL.COMMAND_ADMIN_PROMOTES, fyou.describeTo(context.fPlayer, true));
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");
@@ -94,6 +94,18 @@ public class CmdAdmin extends FCommand {
}); });
} }
private void setRole(FPlayer fp, Role r) {
FactionsPlugin.getInstance().getServer().getScheduler().runTask(FactionsPlugin.instance, () -> {
fp.setRole(r);
});
}
private void promoteNewLeader(Faction f) {
FactionsPlugin.getInstance().getServer().getScheduler().runTask(FactionsPlugin.instance, () -> {
f.promoteNewLeader();
});
}
public TL getUsageTranslation() { public TL getUsageTranslation() {
return TL.COMMAND_ADMIN_DESCRIPTION; return TL.COMMAND_ADMIN_DESCRIPTION;
} }

View File

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

View File

@@ -225,7 +225,7 @@ public class CmdConfig extends FCommand {
if (!success.isEmpty()) { if (!success.isEmpty()) {
if (context.sender instanceof Player) { if (context.sender instanceof Player) {
context.sendMessage(success); 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 } 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); 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(); 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 //End Discord
context.msg(TL.COMMAND_CREATE_YOUSHOULD, FactionsPlugin.getInstance().cmdBase.cmdDescription.getUsageTemplate(context)); context.msg(TL.COMMAND_CREATE_YOUSHOULD, FactionsPlugin.getInstance().cmdBase.cmdDescription.getUsageTemplate(context));
if (Conf.econEnabled) Econ.setBalance(faction.getAccountId(), Conf.econFactionStartingBalance); 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.aliases.add("debug");
this.requirements = new CommandRequirements.Builder(Permission.DEBUG).build(); this.requirements = new CommandRequirements.Builder(Permission.DEBUG).build();
} }
@Override @Override
public void perform(CommandContext context) { public void perform(CommandContext context) {
FactionsPlugin.getInstance().divider(); FactionsPlugin.getInstance().divider();
@@ -51,7 +52,9 @@ public class CmdDebug extends FCommand {
System.out.print("Emotes enabled: " + Discord.useEmotes); System.out.print("Emotes enabled: " + Discord.useEmotes);
System.out.print("Leader role null: " + (Discord.leader == null ? "True" : "False")); System.out.print("Leader role null: " + (Discord.leader == null ? "True" : "False"));
System.out.print("Attempt Log:"); 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 Attempt Log");
System.out.print("----End Discord----"); System.out.print("----End Discord----");
System.out.print("--------End Debug Info--------"); System.out.print("--------End Debug Info--------");

View File

@@ -31,47 +31,47 @@ public class CmdDeinvite extends FCommand {
@Override @Override
public void perform(CommandContext context) { public void perform(CommandContext context) {
if (context.args.size() == 0) { if (context.args.size() == 0) {
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()) {
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);
} }
context.sendFancyMessage(msg); context.sendFancyMessage(msg);
return;
}
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; return;
} }
}
FPlayer you = context.argAsBestFPlayerMatch(0); if (you == null) {
if (!context.fPlayer.isAdminBypassing()) { FancyMessage msg = new FancyMessage(TL.COMMAND_DEINVITE_CANDEINVITE.toString()).color(ChatColor.GOLD);
Access access = context.faction.getAccess(context.fPlayer, PermissableAction.INVITE); for (String id : context.faction.getInvites()) {
if (access != Access.ALLOW && context.fPlayer.getRole() != Role.LEADER) { if (context.faction.getInvites().isEmpty()) return;
context.msg(TL.GENERIC_FPERM_NOPERMISSION, "manage invites"); FPlayer fp = FPlayers.getInstance().getById(id);
return; 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;
}
if (you == null) { if (you.getFaction() == context.faction) {
FancyMessage msg = new FancyMessage(TL.COMMAND_DEINVITE_CANDEINVITE.toString()).color(ChatColor.GOLD); context.msg(TL.COMMAND_DEINVITE_ALREADYMEMBER, you.getName(), context.faction.getTag());
for (String id : context.faction.getInvites()) { context.msg(TL.COMMAND_DEINVITE_MIGHTWANT, FactionsPlugin.getInstance().cmdBase.cmdKick.getUsageTemplate(context));
if (context.faction.getInvites().isEmpty()) return; return;
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;
}
if (you.getFaction() == context.faction) { context.faction.deinvite(you);
context.msg(TL.COMMAND_DEINVITE_ALREADYMEMBER, you.getName(), context.faction.getTag()); you.msg(TL.COMMAND_DEINVITE_REVOKED, context.fPlayer.describeTo(you), context.faction.describeTo(you));
context.msg(TL.COMMAND_DEINVITE_MIGHTWANT, FactionsPlugin.getInstance().cmdBase.cmdKick.getUsageTemplate(context)); context.faction.msg(TL.COMMAND_DEINVITE_REVOKES, context.fPlayer.describeTo(context.faction), you.describeTo(context.faction));
return;
}
context.faction.deinvite(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));
} }
@Override @Override

View File

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

View File

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

View File

@@ -7,15 +7,14 @@ import com.massivecraft.factions.FactionsPlugin;
import com.massivecraft.factions.struct.Permission; import com.massivecraft.factions.struct.Permission;
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.entity.Player;
import java.text.DecimalFormat; import java.text.DecimalFormat;
/** /**
* @author Saser * @author Saser
*/ */
public class CmdDrain extends FCommand{ public class CmdDrain extends FCommand {
public CmdDrain(){ public CmdDrain() {
this.aliases.addAll(Aliases.drain); this.aliases.addAll(Aliases.drain);
this.requirements = new CommandRequirements.Builder(Permission.DRAIN) this.requirements = new CommandRequirements.Builder(Permission.DRAIN)
.playerOnly() .playerOnly()
@@ -34,12 +33,12 @@ public class CmdDrain extends FCommand{
double totalBalance = 0; double totalBalance = 0;
for(FPlayer fPlayer : context.faction.getFPlayers()) { for (FPlayer fPlayer : context.faction.getFPlayers()) {
if(context.faction.getFPlayers().size() == 1){ if (context.faction.getFPlayers().size() == 1) {
context.fPlayer.msg(TL.COMMAND_DRAIN_NO_PLAYERS); context.fPlayer.msg(TL.COMMAND_DRAIN_NO_PLAYERS);
return; return;
} }
if (FPlayers.getInstance().getByPlayer(context.player).equals(fPlayer)){ if (FPlayers.getInstance().getByPlayer(context.player).equals(fPlayer)) {
continue; // skip the command executor continue; // skip the command executor
} }
double balance = FactionsPlugin.getInstance().getEcon().getBalance(fPlayer.getPlayer()); double balance = FactionsPlugin.getInstance().getEcon().getBalance(fPlayer.getPlayer());

View File

@@ -34,7 +34,7 @@ public class CmdFly extends FCommand {
this.aliases.addAll(Aliases.fly); this.aliases.addAll(Aliases.fly);
this.optionalArgs.put("on/off", "flip"); this.optionalArgs.put("on/off", "flip");
this.requirements = new CommandRequirements.Builder(Permission.FLY) this.requirements = new CommandRequirements.Builder(Permission.FLY_FLY)
.playerOnly() .playerOnly()
.memberOnly() .memberOnly()
.build(); .build();
@@ -78,19 +78,15 @@ public class CmdFly extends FCommand {
} }
FPlayer fPlayer = FPlayers.getInstance().getByPlayer(player); FPlayer fPlayer = FPlayers.getInstance().getByPlayer(player);
Faction myFaction = fPlayer.getFaction(); Faction myFaction = fPlayer.getFaction();
if (myFaction.isWilderness()) { if (!player.hasPermission("factions.fly.bypassnearbyenemycheck") && !fPlayer.isAdminBypassing()) {
fPlayer.setFlying(false); if (fPlayer.hasEnemiesNearby()) disableFlightSync(fPlayer);
flyMap.remove(name); checkEnemiesSync(fPlayer);
continue;
}
if (player.hasPermission("factions.fly.bypassnearbyenemycheck") || fPlayer.checkIfNearbyEnemies()) {
continue; continue;
} }
FLocation myFloc = new FLocation(player.getLocation()); FLocation myFloc = new FLocation(player.getLocation());
if (Board.getInstance().getFactionAt(myFloc) != myFaction) { if (Board.getInstance().getFactionAt(myFloc) != myFaction) {
if (!checkBypassPerms(fPlayer, player, Board.getInstance().getFactionAt(myFloc))) { if (!checkFly(fPlayer, player, Board.getInstance().getFactionAt(myFloc))) {
Bukkit.getScheduler().runTask(FactionsPlugin.instance, () -> fPlayer.setFFlying(false, false)); disableFlightSync(fPlayer);
flyMap.remove(name);
} }
} }
@@ -100,36 +96,17 @@ public class CmdFly extends FCommand {
}, 20L, 20L); }, 20L, 20L);
} }
public static boolean checkBypassPerms(FPlayer fme, Player me, Faction toFac) { public static boolean checkFly(FPlayer fme, Player me, Faction toFac) {
if (Conf.denyFlightIfInNoClaimingWorld && !Conf.worldsNoClaiming.isEmpty() && Conf.worldsNoClaiming.stream().anyMatch(me.getWorld().getName()::equalsIgnoreCase)) if (Conf.denyFlightIfInNoClaimingWorld && !Conf.worldsNoClaiming.isEmpty() && Conf.worldsNoClaiming.stream().anyMatch(me.getWorld().getName()::equalsIgnoreCase))
return false; return false;
if (toFac.getAccess(fme, PermissableAction.FLY) == Access.ALLOW) return true;
if (toFac != fme.getFaction()) { if (fme.getFaction().isWilderness()) return false;
if (!me.hasPermission(Permission.FLY_WILD.node) && toFac.isWilderness() || !me.hasPermission(Permission.FLY_SAFEZONE.node) && toFac.isSafeZone() || !me.hasPermission(Permission.FLY_WARZONE.node) && toFac.isWarZone()) { if (toFac.isSystemFaction())
fme.msg(TL.COMMAND_FLY_NO_ACCESS, toFac.getTag(fme)); return me.hasPermission(toFac.isWilderness() ? Permission.FLY_WILDERNESS.node : toFac.isSafeZone() ? Permission.FLY_SAFEZONE.node : Permission.FLY_WARZONE.node);
return false; Relation relationTo = toFac.getRelationTo(fme.getFaction());
} if (!relationTo.isEnemy() && !relationTo.isMember())
Access access = toFac.getAccess(fme, PermissableAction.FLY); return me.hasPermission(Permission.valueOf("FLY_" + relationTo.name()).node);
if ((!(me.hasPermission(Permission.FLY_ENEMY.node) || access == Access.ALLOW)) && toFac.getRelationTo(fme.getFaction()) == Relation.ENEMY) { return false;
fme.msg(TL.COMMAND_FLY_NO_ACCESS, toFac.getTag(fme));
return false;
}
if (!(me.hasPermission(Permission.FLY_ALLY.node) || access == Access.ALLOW) && toFac.getRelationTo(fme.getFaction()) == Relation.ALLY) {
fme.msg(TL.COMMAND_FLY_NO_ACCESS, toFac.getTag(fme));
return false;
}
if (!(me.hasPermission(Permission.FLY_TRUCE.node) || access == Access.ALLOW) && toFac.getRelationTo(fme.getFaction()) == Relation.TRUCE) {
fme.msg(TL.COMMAND_FLY_NO_ACCESS, toFac.getTag(fme));
return false;
}
if (!(me.hasPermission(Permission.FLY_NEUTRAL.node) || access == Access.ALLOW) && toFac.getRelationTo(fme.getFaction()) == Relation.NEUTRAL && !toFac.isSystemFaction()) {
fme.msg(TL.COMMAND_FLY_NO_ACCESS, toFac.getTag(fme));
return false;
}
return me.hasPermission(Permission.FLY.node) && (access != Access.DENY || toFac.isSystemFaction());
}
return true;
} }
@@ -145,34 +122,43 @@ public class CmdFly extends FCommand {
flyMap.remove(fme.getPlayer().getName()); flyMap.remove(fme.getPlayer().getName());
} }
private static void disableFlightSync(FPlayer fme) {
Bukkit.getScheduler().runTask(FactionsPlugin.instance, () -> fme.setFFlying(false, false));
flyMap.remove(fme.getName());
}
private static void checkEnemiesSync(FPlayer fp) {
Bukkit.getScheduler().runTask(FactionsPlugin.instance, fp::checkIfNearbyEnemies);
}
public boolean isInFlightChecker(Player player) { public boolean isInFlightChecker(Player player) {
return flyMap.containsKey(player.getName()); return flyMap.containsKey(player.getName());
} }
@Override @Override
public void perform(CommandContext context) { public void perform(CommandContext context) {
// Disabled by default. if (!context.fPlayer.isAdminBypassing()) {
if (!FactionsPlugin.getInstance().getConfig().getBoolean("enable-faction-flight", false)) { List<Entity> entities = context.player.getNearbyEntities(16.0D, 256.0D, 16.0D);
context.fPlayer.msg(TL.COMMAND_FLY_DISABLED);
return;
}
FLocation myfloc = new FLocation(context.player.getLocation()); for (int i = 0; i <= entities.size() - 1; ++i) {
Faction toFac = Board.getInstance().getFactionAt(myfloc); if (entities.get(i) instanceof Player) {
if (!checkBypassPerms(context.fPlayer, context.player, toFac)) return; Player eplayer = (Player) entities.get(i);
List<Entity> entities = context.player.getNearbyEntities(16.0D, 256.0D, 16.0D); FPlayer efplayer = FPlayers.getInstance().getByPlayer(eplayer);
if (efplayer.getRelationTo(context.fPlayer) == Relation.ENEMY && !efplayer.isStealthEnabled()) {
for (int i = 0; i <= entities.size() - 1; ++i) { context.msg(TL.COMMAND_FLY_CHECK_ENEMY);
if (entities.get(i) instanceof Player) { return;
Player eplayer = (Player) entities.get(i); }
FPlayer efplayer = FPlayers.getInstance().getByPlayer(eplayer); context.fPlayer.setEnemiesNearby(false);
if (efplayer.getRelationTo(context.fPlayer) == Relation.ENEMY && !efplayer.isStealthEnabled()) {
context.msg(TL.COMMAND_FLY_CHECK_ENEMY);
return;
} }
} }
}
FLocation myfloc = new FLocation(context.player.getLocation());
Faction toFac = Board.getInstance().getFactionAt(myfloc);
if (!checkFly(context.fPlayer, context.player, toFac)) {
context.fPlayer.sendMessage(TL.COMMAND_FLY_NO_ACCESS.format(toFac.getTag()));
return;
}
}
if (context.args.size() == 0) { if (context.args.size() == 0) {
toggleFlight(context.fPlayer.isFlying(), context.fPlayer, context); toggleFlight(context.fPlayer.isFlying(), context.fPlayer, context);
@@ -188,22 +174,17 @@ public class CmdFly extends FCommand {
return; return;
} }
context.doWarmUp(WarmUpUtil.Warmup.FLIGHT, TL.WARMUPS_NOTIFY_FLIGHT, "Fly", () -> {
fme.setFlying(true);
flyMap.put(fme.getPlayer().getName(), true);
if (particleTask == null) {
startParticles();
}
if (fme.canFlyAtLocation()) { if (flyTask == null) {
context.doWarmUp(WarmUpUtil.Warmup.FLIGHT, TL.WARMUPS_NOTIFY_FLIGHT, "Fly", () -> { startFlyCheck();
fme.setFlying(true); }
flyMap.put(fme.getPlayer().getName(), true); }, FactionsPlugin.getInstance().getConfig().getLong("warmups.f-fly", 0));
if (particleTask == null) {
startParticles();
}
if (flyTask == null) {
startFlyCheck();
}
}, FactionsPlugin.getInstance().getConfig().getLong("warmups.f-fly", 0));
} else {
fme.msg(TL.COMMAND_FLY_NO_ACCESS, Board.getInstance().getFactionAt(fme.getLastStoodAt()).getTag());
}
} }
@Override @Override

View File

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

View File

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

View File

@@ -139,7 +139,9 @@ public class CmdJoin extends FCommand {
Discord.mainGuild.getController().setNickname(m, Discord.getNicknameString(context.fPlayer)).queue(); 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 (Conf.logFactionJoin) {
if (samePlayer) { if (samePlayer) {

View File

@@ -1,9 +1,7 @@
package com.massivecraft.factions.cmd; package com.massivecraft.factions.cmd;
import com.massivecraft.factions.Conf;
import com.massivecraft.factions.struct.Permission; import com.massivecraft.factions.struct.Permission;
import com.massivecraft.factions.zcore.util.TL; import com.massivecraft.factions.zcore.util.TL;
import org.bukkit.ChatColor;
public class CmdLeave extends FCommand { 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 description: use the /f lock [on/off] command to temporarily lock the data files from being overwritten
default: op default: op
*/ */
public CmdLock() { public CmdLock() {
super(); super();
this.aliases.addAll(Aliases.lock); this.aliases.addAll(Aliases.lock);

View File

@@ -31,53 +31,53 @@ public class CmdMod extends FCommand {
@Override @Override
public void perform(CommandContext context) { public void perform(CommandContext context) {
FPlayer you = context.argAsBestFPlayerMatch(0); FPlayer you = context.argAsBestFPlayerMatch(0);
if (you == null) { if (you == null) {
FancyMessage msg = new FancyMessage(TL.COMMAND_MOD_CANDIDATES.toString()).color(ChatColor.GOLD); FancyMessage msg = new FancyMessage(TL.COMMAND_MOD_CANDIDATES.toString()).color(ChatColor.GOLD);
for (FPlayer player : context.faction.getFPlayersWhereRole(Role.NORMAL)) { for (FPlayer player : context.faction.getFPlayersWhereRole(Role.NORMAL)) {
String s = player.getName(); String s = player.getName();
msg.then(s + " ").color(ChatColor.WHITE).tooltip(TL.COMMAND_MOD_CLICKTOPROMOTE.toString() + s).command("/" + Conf.baseCommandAliases.get(0) + " mod " + s); msg.then(s + " ").color(ChatColor.WHITE).tooltip(TL.COMMAND_MOD_CLICKTOPROMOTE.toString() + s).command("/" + Conf.baseCommandAliases.get(0) + " mod " + s);
}
context.sendFancyMessage(msg);
return;
} }
boolean permAny = Permission.MOD_ANY.has(context.sender, false); context.sendFancyMessage(msg);
Faction targetFaction = you.getFaction(); return;
if (targetFaction != context.faction && !permAny) { }
context.msg(TL.COMMAND_MOD_NOTMEMBER, you.describeTo(context.fPlayer, true));
return;
}
if (context.fPlayer != null && context.fPlayer.getRole() != Role.LEADER && !permAny) { boolean permAny = Permission.MOD_ANY.has(context.sender, false);
context.msg(TL.COMMAND_MOD_NOTADMIN); Faction targetFaction = you.getFaction();
return; if (targetFaction != context.faction && !permAny) {
} context.msg(TL.COMMAND_MOD_NOTMEMBER, you.describeTo(context.fPlayer, true));
return;
}
if (you == context.fPlayer && !permAny) { if (context.fPlayer != null && context.fPlayer.getRole() != Role.LEADER && !permAny) {
context.msg(TL.COMMAND_MOD_SELF); context.msg(TL.COMMAND_MOD_NOTADMIN);
return; return;
} }
if (you.getRole() == Role.LEADER) { if (you == context.fPlayer && !permAny) {
context.msg(TL.COMMAND_MOD_TARGETISADMIN); context.msg(TL.COMMAND_MOD_SELF);
return; return;
} }
if (you.getRole() == Role.MODERATOR) { if (you.getRole() == Role.LEADER) {
// Revoke context.msg(TL.COMMAND_MOD_TARGETISADMIN);
you.setRole(Role.NORMAL); return;
targetFaction.msg(TL.COMMAND_MOD_REVOKED, you.describeTo(targetFaction, true)); }
context.msg(TL.COMMAND_MOD_REVOKES, you.describeTo(context.fPlayer, true));
} else {
// Give
you.setRole(Role.MODERATOR);
targetFaction.msg(TL.COMMAND_MOD_PROMOTED, you.describeTo(targetFaction, true));
context.msg(TL.COMMAND_MOD_PROMOTES, you.describeTo(context.fPlayer, true));
FactionsPlugin.instance.getFlogManager().log(targetFaction, FLogType.RANK_EDIT, context.fPlayer.getName(), you.getName(), ChatColor.LIGHT_PURPLE + "Mod");
} if (you.getRole() == Role.MODERATOR) {
// Revoke
you.setRole(Role.NORMAL);
targetFaction.msg(TL.COMMAND_MOD_REVOKED, you.describeTo(targetFaction, true));
context.msg(TL.COMMAND_MOD_REVOKES, you.describeTo(context.fPlayer, true));
} else {
// Give
you.setRole(Role.MODERATOR);
targetFaction.msg(TL.COMMAND_MOD_PROMOTED, you.describeTo(targetFaction, true));
context.msg(TL.COMMAND_MOD_PROMOTES, you.describeTo(context.fPlayer, true));
FactionsPlugin.instance.getFlogManager().log(targetFaction, FLogType.RANK_EDIT, context.fPlayer.getName(), you.getName(), ChatColor.LIGHT_PURPLE + "Mod");
}
} }
@Override @Override

View File

@@ -29,7 +29,6 @@ public class CmdPaypalSee extends FCommand {
} }
if (context.args.size() == 0) { if (context.args.size() == 0) {
if (context.fPlayer.getFaction().getPaypal() == null) { if (context.fPlayer.getFaction().getPaypal() == null) {
context.msg(TL.COMMAND_PAYPAL_NOTSET); 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) this.requirements = new CommandRequirements.Builder(Permission.TOGGLE_TITLES)
.build(); .build();
} }
@Override @Override
public void perform(CommandContext context) { public void perform(CommandContext context) {
context.fPlayer.setTitlesEnabled(!context.fPlayer.hasTitlesEnabled()); context.fPlayer.setTitlesEnabled(!context.fPlayer.hasTitlesEnabled());
context.msg(TL.COMMAND_TITLETOGGLE_TOGGLED, context.fPlayer.hasTitlesEnabled() ? FactionsPlugin.getInstance().color("&dEnabled") : FactionsPlugin.getInstance().color("&dDisabled")); context.msg(TL.COMMAND_TITLETOGGLE_TOGGLED, context.fPlayer.hasTitlesEnabled() ? FactionsPlugin.getInstance().color("&dEnabled") : FactionsPlugin.getInstance().color("&dDisabled"));
} }
@Override @Override
public TL getUsageTranslation() {return TL.COMMAND_TITLETOGGLE_DESCRIPTION;} public TL getUsageTranslation() {
return TL.COMMAND_TITLETOGGLE_DESCRIPTION;
}
} }

View File

@@ -74,7 +74,9 @@ public class CmdSeeChunk extends FCommand {
for (Object nameObject : seeChunkMap.keySet()) { for (Object nameObject : seeChunkMap.keySet()) {
String name = nameObject + ""; String name = nameObject + "";
Player player = Bukkit.getPlayer(name); Player player = Bukkit.getPlayer(name);
showBorders(player); if (player != null) {
showBorders(player);
}
} }
manageTask(); manageTask();
}, 0, interval); }, 0, interval);
@@ -110,24 +112,19 @@ public class CmdSeeChunk extends FCommand {
private void showPillar(Player player, World world, int blockX, int blockZ) { private void showPillar(Player player, World world, int blockX, int blockZ) {
for (int blockY = 0; blockY < player.getLocation().getBlockY() + 30; blockY++) { for (int blockY = 0; blockY < player.getLocation().getBlockY() + 30; blockY++) {
Location loc = new Location(world, blockX, blockY, blockZ).add(0.5, 0, 0.5); Location loc = new Location(world, blockX, blockY, blockZ).add(0.5, 0, 0.5);
if (loc.getBlock().getType() != Material.AIR) { if (loc.getBlock().getType() != Material.AIR) continue;
continue;
}
if (useParticles) { if (useParticles) {
if (FactionsPlugin.getInstance().useNonPacketParticles) { if (FactionsPlugin.getInstance().useNonPacketParticles) {
// Dust options only exists in the 1.13 API, so we use an // Dust options only exists in the 1.13 API, so we use an
// alternative method to achieve this in lower versions. // alternative method to achieve this in lower versions.
if (FactionsPlugin.getInstance().mc113 || FactionsPlugin.getInstance().mc114) { if (FactionsPlugin.getInstance().mc113 || FactionsPlugin.getInstance().mc114 || FactionsPlugin.getInstance().mc115) {
player.spawnParticle(Particle.REDSTONE, loc, 0, new Particle.DustOptions(Color.RED, 1)); player.spawnParticle(Particle.REDSTONE, loc, 0, new Particle.DustOptions(Color.RED, 1));
} else { } else {
player.getWorld().spawnParticle(Particle.REDSTONE, loc, 0, 255, 0, 0, 1); player.getWorld().spawnParticle(Particle.REDSTONE, loc, 0, 255, 0, 0, 1);
} }
} else { } else {
this.effect.display(0, 0, 0, 0, 1, loc, player); this.effect.display(0, 0, 0, 0, 1, loc, player);
} }
} else { } else {
Material type = blockY % 5 == 0 ? XMaterial.REDSTONE_LAMP.parseMaterial() : XMaterial.BLACK_STAINED_GLASS.parseMaterial(); Material type = blockY % 5 == 0 ? XMaterial.REDSTONE_LAMP.parseMaterial() : XMaterial.BLACK_STAINED_GLASS.parseMaterial();
VisualizeUtil.addLocation(player, loc, type); VisualizeUtil.addLocation(player, loc, type);

View File

@@ -5,7 +5,7 @@ import com.massivecraft.factions.FactionsPlugin;
import com.massivecraft.factions.struct.Permission; import com.massivecraft.factions.struct.Permission;
import com.massivecraft.factions.zcore.util.TL; import com.massivecraft.factions.zcore.util.TL;
public class CmdSeeDiscord extends FCommand{ public class CmdSeeDiscord extends FCommand {
/** /**
* @author Driftay * @author Driftay
@@ -29,7 +29,6 @@ public class CmdSeeDiscord extends FCommand{
} }
if (context.args.size() == 0) { if (context.args.size() == 0) {
if (context.fPlayer.getFaction().getDiscord() == null) { if (context.fPlayer.getFaction().getDiscord() == null) {
context.msg(TL.COMMAND_DISCORD_NOTSET); context.msg(TL.COMMAND_DISCORD_NOTSET);

View File

@@ -12,7 +12,7 @@ public class CmdSetDiscord extends FCommand {
* @author Driftay * @author Driftay
*/ */
public CmdSetDiscord(){ public CmdSetDiscord() {
super(); super();
this.aliases.addAll(Aliases.discord_set); this.aliases.addAll(Aliases.discord_set);
@@ -64,7 +64,7 @@ public class CmdSetDiscord extends FCommand {
} }
} }
private boolean isDiscordInvite(String invite){ private boolean isDiscordInvite(String invite) {
return invite.contains("discord.gg") || invite.contains("discord.me"); return invite.contains("discord.gg") || invite.contains("discord.me");
} }

View File

@@ -2,6 +2,7 @@ package com.massivecraft.factions.cmd;
import com.massivecraft.factions.*; import com.massivecraft.factions.*;
import com.massivecraft.factions.struct.Permission; 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.fperms.PermissableAction;
import com.massivecraft.factions.zcore.util.TL; import com.massivecraft.factions.zcore.util.TL;
@@ -43,6 +44,16 @@ public class CmdSethome extends FCommand {
return; 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 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)) { if (!context.payForCommand(Conf.econCostSethome, TL.COMMAND_SETHOME_TOSET, TL.COMMAND_SETHOME_FORSET)) {
return; return;

View File

@@ -3,7 +3,6 @@ package com.massivecraft.factions.cmd;
import com.massivecraft.factions.Conf; import com.massivecraft.factions.Conf;
import com.massivecraft.factions.FPlayer; import com.massivecraft.factions.FPlayer;
import com.massivecraft.factions.FPlayers; import com.massivecraft.factions.FPlayers;
import com.massivecraft.factions.FactionsPlugin;
import com.massivecraft.factions.struct.Permission; import com.massivecraft.factions.struct.Permission;
import com.massivecraft.factions.zcore.util.TL; import com.massivecraft.factions.zcore.util.TL;
import mkremins.fanciful.FancyMessage; import mkremins.fanciful.FancyMessage;
@@ -28,12 +27,12 @@ public class CmdShowInvites extends FCommand {
@Override @Override
public void perform(CommandContext context) { public void perform(CommandContext context) {
FancyMessage msg = new FancyMessage(TL.COMMAND_SHOWINVITES_PENDING.toString()).color(ChatColor.GOLD); FancyMessage msg = new FancyMessage(TL.COMMAND_SHOWINVITES_PENDING.toString()).color(ChatColor.GOLD);
for (String id : context.faction.getInvites()) { for (String id : context.faction.getInvites()) {
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_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);
} }
} }
@Override @Override

View File

@@ -11,7 +11,7 @@ public class CmdSpawnerLock extends FCommand {
* @author Illyria Team * @author Illyria Team
*/ */
public CmdSpawnerLock(){ public CmdSpawnerLock() {
super(); super();
this.aliases.addAll(Aliases.spawnerlock); this.aliases.addAll(Aliases.spawnerlock);
@@ -20,7 +20,7 @@ public class CmdSpawnerLock extends FCommand {
} }
@Override @Override
public void perform(CommandContext context){ public void perform(CommandContext context) {
Conf.spawnerLock = !Conf.spawnerLock; Conf.spawnerLock = !Conf.spawnerLock;
context.msg(TL.COMMAND_SPAWNER_LOCK_TOGGLED, Conf.spawnerLock ? FactionsPlugin.getInstance().color("&aEnabled") : FactionsPlugin.getInstance().color("&4Disabled")); context.msg(TL.COMMAND_SPAWNER_LOCK_TOGGLED, Conf.spawnerLock ? FactionsPlugin.getInstance().color("&aEnabled") : FactionsPlugin.getInstance().color("&4Disabled"));
} }

View File

@@ -34,56 +34,56 @@ public class CmdTag extends FCommand {
@Override @Override
public void perform(CommandContext context) { public void perform(CommandContext context) {
String tag = context.argAsString(0); String tag = context.argAsString(0);
// TODO does not first test cover selfcase? // TODO does not first test cover selfcase?
if (Factions.getInstance().isTagTaken(tag) && !MiscUtil.getComparisonString(tag).equals(context.faction.getComparisonTag())) { if (Factions.getInstance().isTagTaken(tag) && !MiscUtil.getComparisonString(tag).equals(context.faction.getComparisonTag())) {
context.msg(TL.COMMAND_TAG_TAKEN); context.msg(TL.COMMAND_TAG_TAKEN);
return; return;
}
ArrayList<String> errors = MiscUtil.validateTag(tag);
if (errors.size() > 0) {
context.sendMessage(errors);
return;
}
// if economy is enabled, they're not on the bypass list, and this command has a cost set, make sure they can pay
if (!context.canAffordCommand(Conf.econCostTag, TL.COMMAND_TAG_TOCHANGE.toString())) {
return;
}
// trigger the faction rename event (cancellable)
FactionRenameEvent renameEvent = new FactionRenameEvent(context.fPlayer, tag);
Bukkit.getServer().getPluginManager().callEvent(renameEvent);
if (renameEvent.isCancelled()) {
return;
}
// then make 'em pay (if applicable)
if (!context.payForCommand(Conf.econCostTag, TL.COMMAND_TAG_TOCHANGE, TL.COMMAND_TAG_FORCHANGE)) {
return;
}
String oldtag = context.faction.getTag();
context.faction.setTag(tag);
Discord.changeFactionTag(context.faction, oldtag);
FactionsPlugin.instance.logFactionEvent(context.faction, FLogType.FTAG_EDIT, context.fPlayer.getName(), tag);
// Inform
for (FPlayer fplayer : FPlayers.getInstance().getOnlinePlayers()) {
if (fplayer.getFactionId().equals(context.faction.getId())) {
fplayer.msg(TL.COMMAND_TAG_FACTION, context.fPlayer.describeTo(context.faction, true), context.faction.getTag(context.faction));
continue;
} }
// Broadcast the tag change (if applicable)
ArrayList<String> errors = MiscUtil.validateTag(tag); if (Conf.broadcastTagChanges) {
if (errors.size() > 0) { Faction faction = fplayer.getFaction();
context.sendMessage(errors); fplayer.msg(TL.COMMAND_TAG_CHANGED, context.fPlayer.getColorTo(faction) + oldtag, context.faction.getTag(faction));
return;
} }
}
// if economy is enabled, they're not on the bypass list, and this command has a cost set, make sure they can pay FTeamWrapper.updatePrefixes(context.faction);
if (!context.canAffordCommand(Conf.econCostTag, TL.COMMAND_TAG_TOCHANGE.toString())) {
return;
}
// trigger the faction rename event (cancellable)
FactionRenameEvent renameEvent = new FactionRenameEvent(context.fPlayer, tag);
Bukkit.getServer().getPluginManager().callEvent(renameEvent);
if (renameEvent.isCancelled()) {
return;
}
// then make 'em pay (if applicable)
if (!context.payForCommand(Conf.econCostTag, TL.COMMAND_TAG_TOCHANGE, TL.COMMAND_TAG_FORCHANGE)) {
return;
}
String oldtag = context.faction.getTag();
context.faction.setTag(tag);
Discord.changeFactionTag(context.faction, oldtag);
FactionsPlugin.instance.logFactionEvent(context.faction, FLogType.FTAG_EDIT, context.fPlayer.getName(), tag);
// Inform
for (FPlayer fplayer : FPlayers.getInstance().getOnlinePlayers()) {
if (fplayer.getFactionId().equals(context.faction.getId())) {
fplayer.msg(TL.COMMAND_TAG_FACTION, context.fPlayer.describeTo(context.faction, true), context.faction.getTag(context.faction));
continue;
}
// Broadcast the tag change (if applicable)
if (Conf.broadcastTagChanges) {
Faction faction = fplayer.getFaction();
fplayer.msg(TL.COMMAND_TAG_CHANGED, context.fPlayer.getColorTo(faction) + oldtag, context.faction.getTag(faction));
}
}
FTeamWrapper.updatePrefixes(context.faction);
} }
@Override @Override

View File

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

View File

@@ -2,7 +2,7 @@ package com.massivecraft.factions.cmd;
import com.massivecraft.factions.FactionsPlugin; import com.massivecraft.factions.FactionsPlugin;
import com.massivecraft.factions.struct.Permission; import com.massivecraft.factions.struct.Permission;
import com.massivecraft.factions.zcore.fupgrades.FUpgradesGUI; import com.massivecraft.factions.zcore.fupgrades.FUpgradeFrame;
import com.massivecraft.factions.zcore.util.TL; import com.massivecraft.factions.zcore.util.TL;
public class CmdUpgrades extends FCommand { public class CmdUpgrades extends FCommand {
@@ -19,7 +19,6 @@ public class CmdUpgrades extends FCommand {
.playerOnly() .playerOnly()
.memberOnly() .memberOnly()
.build(); .build();
} }
@Override @Override
@@ -28,7 +27,7 @@ public class CmdUpgrades extends FCommand {
context.fPlayer.msg(TL.COMMAND_UPGRADES_DISABLED); context.fPlayer.msg(TL.COMMAND_UPGRADES_DISABLED);
return; return;
} }
new FUpgradesGUI().openMainMenu(context.fPlayer); new FUpgradeFrame(context.faction).buildGUI(context.fPlayer);
} }
@Override @Override

View File

@@ -268,7 +268,6 @@ public class FCmdRoot extends FCommand implements CommandExecutor {
this.addSubCommand(this.cmdPromote); this.addSubCommand(this.cmdPromote);
this.addSubCommand(this.cmdDebug); this.addSubCommand(this.cmdDebug);
this.addSubCommand(this.cmdDemote); this.addSubCommand(this.cmdDemote);
this.addSubCommand(this.cmdDiscord);
this.addSubCommand(this.cmdSetDefaultRole); this.addSubCommand(this.cmdSetDefaultRole);
this.addSubCommand(this.cmdMapHeight); this.addSubCommand(this.cmdMapHeight);
this.addSubCommand(this.cmdClaimAt); this.addSubCommand(this.cmdClaimAt);
@@ -309,16 +308,16 @@ public class FCmdRoot extends FCommand implements CommandExecutor {
*/ */
public void addVariableCommands() { public void addVariableCommands() {
//Discord //Discord
if (Conf.useDiscordSystem && !discordEnabled) { if (Conf.useDiscordSystem && !discordEnabled) {
this.addSubCommand(this.cmdInviteBot); this.addSubCommand(this.cmdInviteBot);
this.addSubCommand(this.cmdSetGuild); this.addSubCommand(this.cmdSetGuild);
this.addSubCommand(this.cmdSetDiscord); this.addSubCommand(this.cmdSetDiscord);
this.addSubCommand(this.cmdSeeDiscord); this.addSubCommand(this.cmdSeeDiscord);
this.addSubCommand(this.cmdDiscord); this.addSubCommand(this.cmdDiscord);
discordEnabled = true; discordEnabled = true;
} }
//Reserve //Reserve
if(Conf.useReserveSystem){ if (Conf.useReserveSystem) {
this.addSubCommand(this.cmdReserve); this.addSubCommand(this.cmdReserve);
} }
@@ -351,7 +350,7 @@ public class FCmdRoot extends FCommand implements CommandExecutor {
internalFTOPEnabled = true; internalFTOPEnabled = true;
} }
if(Conf.useAuditSystem){ if (Conf.useAuditSystem) {
this.addSubCommand(cmdAudit); this.addSubCommand(cmdAudit);
fAuditEnabled = true; fAuditEnabled = true;
} }
@@ -395,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 @Override
public void perform(CommandContext context) { public void perform(CommandContext context) {

View File

@@ -25,7 +25,7 @@ public class CmdKickAlt extends FCommand {
* @author Driftay * @author Driftay
*/ */
public CmdKickAlt(){ public CmdKickAlt() {
super(); super();
this.aliases.addAll(Aliases.alts_kick); this.aliases.addAll(Aliases.alts_kick);
this.requiredArgs.add("player name"); this.requiredArgs.add("player name");
@@ -86,7 +86,7 @@ public class CmdKickAlt extends FCommand {
// This statement allows us to check if they've specifically denied it, // This statement allows us to check if they've specifically denied it,
// or default to // or default to
// the old setting of allowing moderators to kick // the old setting of allowing moderators to kick
if (access != Access.ALLOW && !context.assertMinRole(Role.MODERATOR)) { if (access != Access.ALLOW && !context.assertMinRole(Role.MODERATOR)) {
context.msg(TL.GENERIC_NOPERMISSION, "kick"); context.msg(TL.GENERIC_NOPERMISSION, "kick");
return; return;
} }

View File

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

View File

@@ -3,6 +3,7 @@ package com.massivecraft.factions.cmd.audit;
/* /*
@author Saser @author Saser
*/ */
import com.google.common.collect.Lists; import com.google.common.collect.Lists;
import com.massivecraft.factions.Faction; import com.massivecraft.factions.Faction;
import com.massivecraft.factions.FactionsPlugin; import com.massivecraft.factions.FactionsPlugin;
@@ -92,9 +93,9 @@ public class FAuditMenu extends GUIMenu {
LinkedList<FactionLogs.FactionLog> log = logs.getMostRecentLogs().get(logType); LinkedList<FactionLogs.FactionLog> log = logs.getMostRecentLogs().get(logType);
if (log != null) { if (log != null) {
int slot = logType == FLogType.F_TNT ? 0 : 3; int slot = logType == FLogType.F_TNT ? 0 : 3;
int pagesToShow = (int)Math.max(1.0D, Math.ceil((double)log.size() / (double)perPage)); int pagesToShow = (int) Math.max(1.0D, Math.ceil((double) log.size() / (double) perPage));
for(int page = 1; page <= pagesToShow; ++page) { for (int page = 1; page <= pagesToShow; ++page) {
int startIndex = log.size() - (page * perPage - perPage); int startIndex = log.size() - (page * perPage - perPage);
if (startIndex >= log.size()) { if (startIndex >= log.size()) {
startIndex = log.size() - 1; startIndex = log.size() - 1;
@@ -102,7 +103,7 @@ public class FAuditMenu extends GUIMenu {
List<String> lore = Lists.newArrayList("", CC.GreenB + "Logs"); List<String> lore = Lists.newArrayList("", CC.GreenB + "Logs");
for(int i = startIndex; i > startIndex - perPage; --i) { for (int i = startIndex; i > startIndex - perPage; --i) {
if (i < log.size()) { if (i < log.size()) {
if (i < 0) { if (i < 0) {
break; break;

View File

@@ -3,6 +3,7 @@ package com.massivecraft.factions.cmd.audit;
/** /**
* @author Saser * @author Saser
*/ */
import com.massivecraft.factions.FPlayer; import com.massivecraft.factions.FPlayer;
import com.massivecraft.factions.FPlayers; import com.massivecraft.factions.FPlayers;
import com.massivecraft.factions.Faction; import com.massivecraft.factions.Faction;
@@ -45,17 +46,20 @@ public class FChestListener implements Listener {
Player player = (Player) event.getWhoClicked(); Player player = (Player) event.getWhoClicked();
FPlayer fPlayer = FPlayers.getInstance().getByPlayer(player); FPlayer fPlayer = FPlayers.getInstance().getByPlayer(player);
Faction faction; 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) { if (event.getClick() == ClickType.UNKNOWN) {
event.setCancelled(true); event.setCancelled(true);
player.sendMessage(CC.RedB + "(!) " + CC.Red + "You cannot use that click type inside the /f chest!"); player.sendMessage(CC.RedB + "(!) " + CC.Red + "You cannot use that click type inside the /f chest!");
return; return;
} }
ItemStack currentItem = event.getCurrentItem(); 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; Material currentItemType = currentItem != null ? currentItem.getType() : Material.AIR;
ItemStack cursorItem = event.getCursor(); 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; Material cursorItemType = cursorItem != null ? cursorItem.getType() : Material.AIR;
if (fPlayer == null || !(faction = fPlayer.getFaction()).isNormal()) { if (fPlayer == null || !(faction = fPlayer.getFaction()).isNormal()) {
player.closeInventory(); player.closeInventory();
@@ -65,16 +69,16 @@ public class FChestListener implements Listener {
if (event.getClickedInventory() == null) return; if (event.getClickedInventory() == null) return;
if (event.getView().getTitle().equalsIgnoreCase(FactionsPlugin.getInstance().color(FactionsPlugin.getInstance().getConfig().getString("fchest.Inventory-Title"))) && !event.getClick().isShiftClick()) { if (event.getView().getTitle().equalsIgnoreCase(FactionsPlugin.getInstance().color(FactionsPlugin.getInstance().getConfig().getString("fchest.Inventory-Title"))) && !event.getClick().isShiftClick()) {
if (currentItemType != Material.AIR) { if (currentItemType != Material.AIR) {
Inventory ours = faction.getChestInventory(); Inventory ours = faction.getChestInventory();
if(event.getClickedInventory() == ours) { if (event.getClickedInventory() == ours) {
if (ours == null || !ours.contains(currentItem)) { if (ours == null || !ours.contains(currentItem)) {
event.setCancelled(true); event.setCancelled(true);
player.sendMessage(CC.RedB + "(!) That item not longer exists!"); player.sendMessage(CC.RedB + "(!) That item not longer exists!");
Bukkit.getLogger().info("[FactionChest] " + player.getName() + " tried to remove " + currentItem + " from /f chest when it didnt contain! Items: " + (ours == null ? "none" : Arrays.toString(ours.getContents()))); Bukkit.getLogger().info("[FactionChest] " + player.getName() + " tried to remove " + currentItem + " from /f chest when it didnt contain! Items: " + (ours == null ? "none" : Arrays.toString(ours.getContents())));
player.closeInventory(); player.closeInventory();
return; return;
}
} }
}
logRemoveItem(currentItem, fPlayer, player); logRemoveItem(currentItem, fPlayer, player);
} else if (cursorItemType != Material.AIR && !event.isShiftClick()) { } else if (cursorItemType != Material.AIR && !event.isShiftClick()) {
logAddItem(cursorItem, fPlayer, player); logAddItem(cursorItem, fPlayer, player);

View File

@@ -3,6 +3,7 @@ package com.massivecraft.factions.cmd.audit;
/** /**
* @author Saser * @author Saser
*/ */
import com.google.common.reflect.TypeToken; import com.google.common.reflect.TypeToken;
import com.massivecraft.factions.Faction; import com.massivecraft.factions.Faction;
import com.massivecraft.factions.Factions; import com.massivecraft.factions.Factions;
@@ -127,7 +128,7 @@ public class FLogManager {
} }
try { try {
JSONUtils.saveJSONToFile(logFile, factionLogMap,logToken); JSONUtils.saveJSONToFile(logFile, factionLogMap, logToken);
} catch (Exception e1) { } catch (Exception e1) {
Bukkit.getLogger().info("ERROR SAVING JSON LOGS: " + e1.getMessage()); Bukkit.getLogger().info("ERROR SAVING JSON LOGS: " + e1.getMessage());
e1.printStackTrace(); e1.printStackTrace();

View File

@@ -27,8 +27,10 @@ public enum FLogType {
private String msg; private String msg;
private int requiredArgs; private int requiredArgs;
public String getDisplayName() { FLogType(String displayName, String msg, int requiredArgs) {
return this.displayName; this.displayName = displayName;
this.msg = msg;
this.requiredArgs = requiredArgs;
} }
/** /**
@@ -46,15 +48,22 @@ public enum FLogType {
return null; return null;
} }
@Override public String getDisplayName() {
public String toString() { return name(); } return this.displayName;
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();
} }
@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())).get().parseMaterial();
}
public String getMsg() { public String getMsg() {
return this.msg; return this.msg;
@@ -63,10 +72,4 @@ public enum FLogType {
public int getRequiredArgs() { public int getRequiredArgs() {
return this.requiredArgs; 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 * @author Saser
*/ */
import com.google.common.collect.Lists; import com.google.common.collect.Lists;
import org.bukkit.Bukkit; import org.bukkit.Bukkit;
import org.bukkit.ChatColor; import org.bukkit.ChatColor;
@@ -16,8 +17,8 @@ import java.util.concurrent.ConcurrentHashMap;
import java.util.concurrent.TimeUnit; import java.util.concurrent.TimeUnit;
public class FactionLogs { public class FactionLogs {
private Map<FLogType, LinkedList<FactionLog>> mostRecentLogs = new ConcurrentHashMap<>();
public static transient SimpleDateFormat format = new SimpleDateFormat("MM/dd hh:mmaa"); public static transient SimpleDateFormat format = new SimpleDateFormat("MM/dd hh:mmaa");
private Map<FLogType, LinkedList<FactionLog>> mostRecentLogs = new ConcurrentHashMap<>();
public FactionLogs() { public FactionLogs() {
} }

View File

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

View File

@@ -52,19 +52,19 @@ public class CheckSettingsFrame implements InventoryHolder, FactionGUI {
public void build() { public void build() {
Faction faction = fPlayer.getFaction(); Faction faction = fPlayer.getFaction();
ItemStack wallsStack = XMaterial.matchXMaterial(FactionsPlugin.getInstance().getConfig().getString("f-check.wall-check.Type")).parseItem(); ItemStack wallsStack = XMaterial.matchXMaterial(FactionsPlugin.getInstance().getConfig().getString("f-check.wall-check.Type")).get().parseItem();
ItemMeta wallsMeta = wallsStack.getItemMeta(); ItemMeta wallsMeta = wallsStack.getItemMeta();
wallsMeta.setDisplayName(TL.CHECK_WALL_CHECK_GUI_ICON.toString()); wallsMeta.setDisplayName(TL.CHECK_WALL_CHECK_GUI_ICON.toString());
wallsMeta.setLore(Collections.singletonList(TL.CHECK_CHECK_LORE_LINE.format(getFormatted(faction.getWallCheckMinutes())))); wallsMeta.setLore(Collections.singletonList(TL.CHECK_CHECK_LORE_LINE.format(getFormatted(faction.getWallCheckMinutes()))));
wallsStack.setItemMeta(wallsMeta); wallsStack.setItemMeta(wallsMeta);
inventory.setItem(FactionsPlugin.getInstance().getConfig().getInt("f-check.wall-check.slot"), wallsStack); inventory.setItem(FactionsPlugin.getInstance().getConfig().getInt("f-check.wall-check.slot"), wallsStack);
ItemStack bufferStack = XMaterial.matchXMaterial(FactionsPlugin.getInstance().getConfig().getString("f-check.buffer-check.Type")).parseItem(); ItemStack bufferStack = XMaterial.matchXMaterial(FactionsPlugin.getInstance().getConfig().getString("f-check.buffer-check.Type")).get().parseItem();
ItemMeta bufferMeta = bufferStack.getItemMeta(); ItemMeta bufferMeta = bufferStack.getItemMeta();
bufferMeta.setDisplayName(TL.CHECK_BUFFER_CHECK_GUI_ICON.toString()); bufferMeta.setDisplayName(TL.CHECK_BUFFER_CHECK_GUI_ICON.toString());
bufferMeta.setLore(Collections.singletonList(TL.CHECK_CHECK_LORE_LINE.format(getFormatted(faction.getBufferCheckMinutes())))); bufferMeta.setLore(Collections.singletonList(TL.CHECK_CHECK_LORE_LINE.format(getFormatted(faction.getBufferCheckMinutes()))));
bufferStack.setItemMeta(bufferMeta); bufferStack.setItemMeta(bufferMeta);
inventory.setItem(FactionsPlugin.getInstance().getConfig().getInt("f-check.buffer-check.slot"), bufferStack); inventory.setItem(FactionsPlugin.getInstance().getConfig().getInt("f-check.buffer-check.slot"), bufferStack);
ItemStack historyStack = XMaterial.matchXMaterial(FactionsPlugin.getInstance().getConfig().getString("f-check.history.Type")).parseItem(); ItemStack historyStack = XMaterial.matchXMaterial(FactionsPlugin.getInstance().getConfig().getString("f-check.history.Type")).get().parseItem();
ItemMeta historyMeta = historyStack.getItemMeta(); ItemMeta historyMeta = historyStack.getItemMeta();
historyMeta.setDisplayName(TL.CHECK_HISTORY_GUI_ICON.toString()); historyMeta.setDisplayName(TL.CHECK_HISTORY_GUI_ICON.toString());
historyStack.setItemMeta(historyMeta); historyStack.setItemMeta(historyMeta);

View File

@@ -59,7 +59,7 @@ public class CmdWeeWoo extends FCommand {
} }
context.faction.setWeeWoo(false); context.faction.setWeeWoo(false);
context.msg(TL.COMMAND_WEEWOO_STOPPED, context.fPlayer.getNameAndTag()); context.msg(TL.COMMAND_WEEWOO_STOPPED, context.fPlayer.getNameAndTag());
if(!Conf.useDiscordSystem) return; if (!Conf.useDiscordSystem) return;
String discordChannelId = context.faction.getWeeWooChannelId(); String discordChannelId = context.faction.getWeeWooChannelId();
if (discordChannelId != null && !discordChannelId.isEmpty()) { if (discordChannelId != null && !discordChannelId.isEmpty()) {
TextChannel textChannel = Discord.jda.getTextChannelById(discordChannelId); TextChannel textChannel = Discord.jda.getTextChannelById(discordChannelId);

View File

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

View File

@@ -89,7 +89,7 @@ public class CmdClaimLine extends FCommand {
location = location.add(blockFace.getModX() * 16, 0, blockFace.getModZ() * 16); location = location.add(blockFace.getModX() * 16, 0, blockFace.getModZ() * 16);
FactionsPlugin.instance.logFactionEvent(forFaction, FLogType.CHUNK_CLAIMS, context.fPlayer.getName(), CC.GreenB + "CLAIMED", String.valueOf(i), new FLocation(context.player.getLocation()).formatXAndZ(",")); FactionsPlugin.instance.logFactionEvent(forFaction, FLogType.CHUNK_CLAIMS, context.fPlayer.getName(), CC.GreenB + "CLAIMED", String.valueOf(i), new FLocation(context.player.getLocation()).formatXAndZ(","));
} }
} }
@Override @Override
public TL getUsageTranslation() { public TL getUsageTranslation() {

View File

@@ -10,8 +10,6 @@ import com.massivecraft.factions.struct.Permission;
import com.massivecraft.factions.util.CornerTask; import com.massivecraft.factions.util.CornerTask;
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.ChatColor;
import org.bukkit.entity.Player;
import java.util.ArrayList; import java.util.ArrayList;
import java.util.Comparator; import java.util.Comparator;

View File

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

View File

@@ -40,7 +40,7 @@ public class CmdMoney extends FCommand {
@Override @Override
public void perform(CommandContext context) { public void perform(CommandContext context) {
if (!Conf.econEnabled || !Conf.bankEnabled) { 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; return;
} }
context.commandChain.add(this); 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.integration.Econ;
import com.massivecraft.factions.struct.Permission; import com.massivecraft.factions.struct.Permission;
import com.massivecraft.factions.zcore.util.TL; import com.massivecraft.factions.zcore.util.TL;
import org.bukkit.command.CommandSender;
public class CmdMoneyBalance extends FCommand { public class CmdMoneyBalance extends FCommand {

View File

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

View File

@@ -84,7 +84,7 @@ public abstract class FRelationCommand extends FCommand {
// trigger the faction relation event // trigger the faction relation event
FactionRelationEvent relationEvent = new FactionRelationEvent(context.faction, them, oldRelation, currentRelation); FactionRelationEvent relationEvent = new FactionRelationEvent(context.faction, them, oldRelation, currentRelation);
Bukkit.getServer().getPluginManager().callEvent(relationEvent); Bukkit.getServer().getPluginManager().callEvent(relationEvent);
FactionsPlugin.instance.logFactionEvent(context.faction, FLogType.RELATION_CHANGE,context.fPlayer.getName(), this.targetRelation.getColor() + this.targetRelation.name(), oldRelation.getColor() + them.getTag()); FactionsPlugin.instance.logFactionEvent(context.faction, FLogType.RELATION_CHANGE, context.fPlayer.getName(), this.targetRelation.getColor() + this.targetRelation.name(), oldRelation.getColor() + them.getTag());
FactionsPlugin.instance.logFactionEvent(them, FLogType.RELATION_CHANGE, oldRelation.getColor() + context.fPlayer.getName(), this.targetRelation.getColor() + this.targetRelation.name(), "your faction"); FactionsPlugin.instance.logFactionEvent(them, FLogType.RELATION_CHANGE, oldRelation.getColor() + context.fPlayer.getName(), this.targetRelation.getColor() + this.targetRelation.name(), "your faction");
them.msg(TL.COMMAND_RELATIONS_MUTUAL, currentRelationColor + targetRelation.getTranslation(), currentRelationColor + context.faction.getTag()); them.msg(TL.COMMAND_RELATIONS_MUTUAL, currentRelationColor + targetRelation.getTranslation(), currentRelationColor + context.faction.getTag());

View File

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

View File

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

View File

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

View File

@@ -1,6 +1,7 @@
package com.massivecraft.factions.cmd.tnt; package com.massivecraft.factions.cmd.tnt;
import com.massivecraft.factions.FPlayer; import com.massivecraft.factions.FPlayer;
import com.massivecraft.factions.Factions;
import com.massivecraft.factions.FactionsPlugin; import com.massivecraft.factions.FactionsPlugin;
import com.massivecraft.factions.cmd.Aliases; import com.massivecraft.factions.cmd.Aliases;
import com.massivecraft.factions.cmd.CommandContext; import com.massivecraft.factions.cmd.CommandContext;
@@ -23,10 +24,6 @@ import java.util.*;
public class CmdTntFill extends FCommand { public class CmdTntFill extends FCommand {
/**
* @author Illyria Team
*/
public CmdTntFill() { public CmdTntFill() {
super(); super();
this.aliases.addAll(Aliases.tnt_tntfill); this.aliases.addAll(Aliases.tnt_tntfill);
@@ -61,16 +58,17 @@ public class CmdTntFill extends FCommand {
int radius = context.argAsInt(0, 0); // We don't know the max yet, so let's not assume. int radius = context.argAsInt(0, 0); // We don't know the max yet, so let's not assume.
int amount = context.argAsInt(1, 0); // We don't know the max yet, so let's not assume. int amount = context.argAsInt(1, 0); // We don't know the max yet, so let's not assume.
if (amount < 0) { if (amount <= 0 || radius <= 0) {
context.msg(TL.COMMAND_TNT_POSITIVE); context.msg(TL.COMMAND_TNT_POSITIVE);
return; 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; return;
} }
if (amount > FactionsPlugin.instance.getConfig().getInt("Tntfill.max-amount")) { if (amount > FactionsPlugin.getInstance().getConfig().getInt("Tntfill.max-amount")) {
context.msg(TL.COMMAND_TNTFILL_AMOUNTMAX.toString().replace("{max}", FactionsPlugin.instance.getConfig().getInt("Tntfill.max-amount") + "")); context.msg(TL.COMMAND_TNTFILL_AMOUNTMAX.toString().replace("{max}", FactionsPlugin.getInstance().getConfig().getInt("Tntfill.max-amount") + ""));
return; return;
} }
@@ -88,103 +86,82 @@ public class CmdTntFill extends FCommand {
if (block == null) continue; if (block == null) continue;
BlockState blockState = block.getState(); BlockState blockState = block.getState();
if (!(blockState instanceof Dispenser)) continue; 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); opDispensers.add((Dispenser) blockState);
} }
if (opDispensers.isEmpty()) { if (opDispensers.isEmpty()) {
context.fPlayer.msg(TL.COMMAND_TNTFILL_NODISPENSERS.toString().replace("{radius}", radius + "")); context.fPlayer.msg(TL.COMMAND_TNTFILL_NODISPENSERS.toString().replace("{radius}", radius + ""));
return; return;
} }
// What's the required amount of resources
int requiredTnt = (opDispensers.size() * amount); int requiredTnt = (opDispensers.size() * amount);
int playerTnt = getTNTInside(context.player);
// Do I have enough tnt in my inventory? // if player does not have enough tnt, just take whatever he has and add it to the bank
int playerTnt = inventoryItemCount(context.player.getInventory(), Material.TNT); // then use the bank as source. If bank < required abort.
if (playerTnt < requiredTnt) { if (playerTnt < requiredTnt) {
// How much TNT will I take from bank?
int getFactionTnt = requiredTnt - playerTnt;
// Do I have enough tnt in bank? // 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()); context.fPlayer.msg(TL.COMMAND_TNT_WIDTHDRAW_NOTENOUGH_TNT.toString());
return; return;
} }
// move whatever tnt you have to the bank, ignoring limit because its gonna be taken out later anyways
// Take TNT from the bank. context.faction.addTnt(playerTnt);
context.faction.takeTnt(getFactionTnt); 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);
} }
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() + "")); context.sendMessage(TL.COMMAND_TNTFILL_SUCCESS.toString().replace("{amount}", requiredTnt + "").replace("{dispensers}", opDispensers.size() + ""));
} }
// Actually fill every dispenser with the precise amount. // Actually fill every dispenser with the precise amount.
private void fillDispensers(FPlayer fPlayer, List<Dispenser> dispensers, int count) { private void fillDispensers(FPlayer fPlayer, List<Dispenser> dispensers, int count) {
for (Dispenser dispenser : dispensers) { for (Dispenser dispenser : dispensers) {
if (takeTnt(fPlayer, count)) { int canBeAdded = getAddable(dispenser.getInventory(), Material.TNT);
dispenser.getInventory().addItem(new ItemStack(Material.TNT, count)); if (canBeAdded <= 0) continue;
} else {return;} 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) { private void fillDispensers(CommandContext context, List<Dispenser> dispensers, int count) {
try { for (Dispenser dispenser : dispensers) {
Integer.parseInt(context.args.get(1)); int canBeAdded = getAddable(dispenser.getInventory(), Material.TNT);
} catch (NumberFormatException e) { if (canBeAdded <= 0) continue;
context.fPlayer.msg(TL.COMMAND_TNT_INVALID_NUM.toString()); int toAdd = Math.min(canBeAdded, count);
return; if (context.faction.getTnt() < toAdd) {
context.fPlayer.msg(TL.COMMAND_TNT_WIDTHDRAW_NOTENOUGH_TNT.toString());
return;
}
context.faction.takeTnt(toAdd);
dispenser.getInventory().addItem(new ItemStack(Material.TNT, toAdd));
} }
if (amount < 0) {
context.fPlayer.msg(TL.COMMAND_TNT_POSITIVE.toString());
return;
}
if (context.faction.getTnt() < amount) {
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;
}
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) { public static void removeItems(Inventory inventory, ItemStack item, int toRemove) {
Inventory inv = fme.getPlayer().getInventory(); if (toRemove <= 0 || inventory == null || item == null)
int invTnt = 0; return;
for (int i = 0; i <= inv.getSize(); i++) { for (int i = 0; i < inventory.getSize(); i++) {
if (inv.getItem(i) == null) { ItemStack loopItem = inventory.getItem(i);
if (loopItem == null || !item.isSimilar(loopItem))
continue; continue;
if (toRemove <= 0)
return;
if (toRemove < loopItem.getAmount()) {
loopItem.setAmount(loopItem.getAmount() - toRemove);
return;
} }
if (inv.getItem(i).getType() == Material.TNT) { inventory.clear(i);
invTnt += inv.getItem(i).getAmount(); 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. // Counts the item type available in the inventory.
@@ -196,35 +173,37 @@ public class CmdTntFill extends FCommand {
return count; return count;
} }
private void removeFromInventory(Inventory inventory, ItemStack item) { public int getAddable(Inventory inv, Material material) {
int amt = item.getAmount(); int output = 0;
ItemStack[] items = inventory.getContents(); int notempty = 0;
for (int i = 0; i < items.length; i++) { for (int i = 0; i < inv.getSize(); ++i) {
if (items[i] != null && items[i].getType() == item.getType() && items[i].getDurability() == item.getDurability()) { ItemStack is = inv.getItem(i);
if (items[i].getAmount() > amt) { if (is != null) {
items[i].setAmount(items[i].getAmount() - amt); ++notempty;
break; if (is.getType() == material) {
} else if (items[i].getAmount() == amt) { int amount = is.getAmount();
items[i] = null; output += 64 - amount;
break;
} else {
amt -= items[i].getAmount();
items[i] = null;
} }
} }
} }
inventory.setContents(items); return output + (inv.getSize() - notempty) * 64;
} }
private int getEmptySlots(Player p) { public boolean isInvFull(Inventory inv) {
PlayerInventory inventory = p.getInventory(); return inv.firstEmpty() == -1;
ItemStack[] cont = inventory.getContents(); }
int i = 0;
for (ItemStack item : cont) public int getTNTInside(Player p) {
if (item != null && item.getType() != Material.AIR) { int result = 0;
i++; 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 36 - i; }
return result;
} }
@Override @Override

View File

@@ -27,22 +27,26 @@ public class CmdWild extends FCommand {
public static HashMap<Player, Integer> waitingTeleport; public static HashMap<Player, Integer> waitingTeleport;
public static HashMap<Player, String> teleportRange; public static HashMap<Player, String> teleportRange;
public static HashSet<Player> teleporting; public static HashSet<Player> teleporting;
public CmdWild() { public CmdWild() {
super(); super();
this.aliases.addAll(Aliases.wild); this.aliases.addAll(Aliases.wild);
this.requirements = new CommandRequirements.Builder(Permission.WILD) this.requirements = new CommandRequirements.Builder(Permission.WILD)
.playerOnly() .playerOnly()
.build(); .build();
waitingTeleport = new HashMap<>(); waitingTeleport = new HashMap<>();
teleporting = new HashSet<>(); teleporting = new HashSet<>();
teleportRange = new HashMap<>(); teleportRange = new HashMap<>();
startWild(); startWild();
} }
@Override @Override
public void perform(CommandContext context) { public void perform(CommandContext context) {
if (!waitingTeleport.containsKey(context.player)) { if (!waitingTeleport.containsKey(context.player)) {
context.player.openInventory(new WildGUI(context.player, context.fPlayer).getInventory()); 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() { public void startWild() {
@@ -64,6 +68,7 @@ public class CmdWild extends FCommand {
} }
}, 0L, 20L); }, 0L, 20L);
} }
public void attemptTeleport(Player p) { public void attemptTeleport(Player p) {
boolean success = false; boolean success = false;
int tries = 0; int tries = 0;
@@ -84,26 +89,34 @@ public class CmdWild extends FCommand {
} }
tries++; 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) { public void teleportPlayer(Player p, FLocation loc) {
Location finalLoc; Location finalLoc;
if (FactionsPlugin.getInstance().getConfig().getBoolean("Wild.Arrival.SpawnAbove")) { 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()); 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); p.teleport(finalLoc, PlayerTeleportEvent.TeleportCause.PLUGIN);
setTeleporting(p); setTeleporting(p);
applyEffects(p); applyEffects(p);
} }
public void applyEffects(Player p) { public void applyEffects(Player p) {
for (String s : FactionsPlugin.getInstance().getConfig().getStringList("Wild.Arrival.Effects")) { for (String s : FactionsPlugin.getInstance().getConfig().getStringList("Wild.Arrival.Effects")) {
p.addPotionEffect(new PotionEffect(PotionEffectType.getByName(s), 40, 1)); p.addPotionEffect(new PotionEffect(PotionEffectType.getByName(s), 40, 1));
} }
} }
public void setTeleporting(Player p) { public void setTeleporting(Player p) {
teleporting.add(p); teleporting.add(p);
Bukkit.getScheduler().scheduleSyncDelayedTask(FactionsPlugin.instance, () -> teleporting.remove(p), FactionsPlugin.getInstance().getConfig().getInt("Wild.Arrival.FallDamageWindow") * 20); Bukkit.getScheduler().scheduleSyncDelayedTask(FactionsPlugin.instance, () -> teleporting.remove(p), FactionsPlugin.getInstance().getConfig().getInt("Wild.Arrival.FallDamageWindow") * 20);
} }
@Override @Override
public TL getUsageTranslation() { public TL getUsageTranslation() {
return TL.COMMAND_WILD_DESCRIPTION; return TL.COMMAND_WILD_DESCRIPTION;

View File

@@ -23,11 +23,13 @@ public class WildGUI implements FactionGUI {
FPlayer fplayer; FPlayer fplayer;
HashMap<Integer, String> map; HashMap<Integer, String> map;
Inventory inv; Inventory inv;
public WildGUI(Player player, FPlayer fplayer) { public WildGUI(Player player, FPlayer fplayer) {
this.player = player; this.player = player;
this.fplayer = fplayer; this.fplayer = fplayer;
map = new HashMap<>(); map = new HashMap<>();
} }
@Override @Override
public void onClick(int slot, ClickType action) { public void onClick(int slot, ClickType action) {
if (map.containsKey(slot)) { if (map.containsKey(slot)) {
@@ -44,18 +46,18 @@ public class WildGUI implements FactionGUI {
@Override @Override
public void build() { public void build() {
inv = Bukkit.createInventory(this, FactionsPlugin.getInstance().getConfig().getInt("Wild.GUI.Size"), FactionsPlugin.getInstance().color(FactionsPlugin.getInstance().getConfig().getString("Wild.GUI.Name"))); inv = Bukkit.createInventory(this, FactionsPlugin.getInstance().getConfig().getInt("Wild.GUI.Size"), FactionsPlugin.getInstance().color(FactionsPlugin.getInstance().getConfig().getString("Wild.GUI.Name")));
ItemStack fillItem = XMaterial.matchXMaterial(FactionsPlugin.getInstance().getConfig().getString("Wild.GUI.FillMaterial")).parseItem(); ItemStack fillItem = XMaterial.matchXMaterial(FactionsPlugin.getInstance().getConfig().getString("Wild.GUI.FillMaterial")).get().parseItem();
ItemMeta meta = fillItem.getItemMeta(); ItemMeta meta = fillItem.getItemMeta();
if(meta == null) return; if (meta == null) return;
meta.setDisplayName(""); meta.setDisplayName("");
fillItem.setItemMeta(meta); fillItem.setItemMeta(meta);
for (int fill = 0; fill < FactionsPlugin.getInstance().getConfig().getInt("Wild.GUI.Size"); ++fill) { for (int fill = 0; fill < FactionsPlugin.getInstance().getConfig().getInt("Wild.GUI.Size"); ++fill) {
inv.setItem(fill, fillItem); inv.setItem(fill, fillItem);
} }
for (String key : Objects.requireNonNull(FactionsPlugin.getInstance().getConfig().getConfigurationSection("Wild.Zones")).getKeys(false)) { for (String key : Objects.requireNonNull(FactionsPlugin.getInstance().getConfig().getConfigurationSection("Wild.Zones")).getKeys(false)) {
ItemStack zoneItem = XMaterial.matchXMaterial(FactionsPlugin.getInstance().getConfig().getString("Wild.Zones." + key + ".Material")).parseItem(); ItemStack zoneItem = XMaterial.matchXMaterial(FactionsPlugin.getInstance().getConfig().getString("Wild.Zones." + key + ".Material")).get().parseItem();
ItemMeta zoneMeta = zoneItem.getItemMeta(); ItemMeta zoneMeta = zoneItem.getItemMeta();
if(zoneMeta == null) return; if (zoneMeta == null) return;
List<String> lore = new ArrayList<>(); List<String> lore = new ArrayList<>();
for (String s : FactionsPlugin.getInstance().getConfig().getStringList("Wild.Zones." + key + ".Lore")) { for (String s : FactionsPlugin.getInstance().getConfig().getStringList("Wild.Zones." + key + ".Lore")) {
lore.add(FactionsPlugin.getInstance().color(s)); lore.add(FactionsPlugin.getInstance().color(s));
@@ -72,7 +74,9 @@ public class WildGUI implements FactionGUI {
@NotNull @NotNull
@Override @Override
public Inventory getInventory() { public Inventory getInventory() {
if (inv == null) {build();} if (inv == null) {
build();
}
return inv; return inv;
} }
} }

View File

@@ -32,7 +32,7 @@ public class FPlayerRoleChangeEvent extends FactionPlayerEvent implements Cancel
@Override @Override
public boolean isCancelled() { public boolean isCancelled() {
return false; return cancelled;
} }
@Override @Override

View File

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

View File

@@ -40,6 +40,7 @@ import org.bukkit.potion.PotionEffectType;
import java.util.HashMap; import java.util.HashMap;
import java.util.List; import java.util.List;
import java.util.Map; import java.util.Map;
import java.util.Objects;
import java.util.concurrent.TimeUnit; import java.util.concurrent.TimeUnit;
import java.util.concurrent.atomic.AtomicInteger; import java.util.concurrent.atomic.AtomicInteger;
@@ -265,7 +266,8 @@ public class FactionsBlockListener implements Listener {
@EventHandler @EventHandler
public void onHopperPlace(BlockPlaceEvent e) { 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())); Faction factionAt = Board.getInstance().getFactionAt(new FLocation(e.getBlockPlaced().getLocation()));
if (factionAt.isWilderness() || factionAt.getVault() == null) return; if (factionAt.isWilderness() || factionAt.getVault() == null) return;
FPlayer fme = FPlayers.getInstance().getByPlayer(e.getPlayer()); FPlayer fme = FPlayers.getInstance().getByPlayer(e.getPlayer());
@@ -356,11 +358,7 @@ public class FactionsBlockListener implements Listener {
return; return;
} }
for (FPlayer fplayer : fme.getFaction().getFPlayers()) { 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!"));
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); bannerCooldownMap.put(fme.getTag(), true);
FactionsBlockListener.bannerLocations.put(fme.getTag(), e.getBlockPlaced().getLocation()); FactionsBlockListener.bannerLocations.put(fme.getTag(), e.getBlockPlaced().getLocation());
@@ -380,7 +378,7 @@ public class FactionsBlockListener implements Listener {
int radius = FactionsPlugin.getInstance().getConfig().getInt("fbanners.Banner-Effect-Radius"); int radius = FactionsPlugin.getInstance().getConfig().getInt("fbanners.Banner-Effect-Radius");
List<String> effects = FactionsPlugin.getInstance().getConfig().getStringList("fbanners.Effects"); List<String> effects = FactionsPlugin.getInstance().getConfig().getStringList("fbanners.Effects");
int affectorTask = Bukkit.getScheduler().scheduleSyncRepeatingTask(FactionsPlugin.getInstance(), () -> { int affectorTask = Bukkit.getScheduler().scheduleSyncRepeatingTask(FactionsPlugin.getInstance(), () -> {
for (Entity e1 : banner.getLocation().getWorld().getNearbyEntities(banner.getLocation(), radius, 255.0, radius)) { for (Entity e1 : Objects.requireNonNull(banner.getLocation().getWorld()).getNearbyEntities(banner.getLocation(), radius, 255.0, radius)) {
if (e1 instanceof Player) { if (e1 instanceof Player) {
Player player = (Player) e1; Player player = (Player) e1;
FPlayer fplayer = FPlayers.getInstance().getByPlayer(player); FPlayer fplayer = FPlayers.getInstance().getByPlayer(player);
@@ -389,7 +387,7 @@ public class FactionsBlockListener implements Listener {
} }
for (String effect : effects) { for (String effect : effects) {
String[] components = effect.split(":"); String[] components = effect.split(":");
player.addPotionEffect(new PotionEffect(PotionEffectType.getByName(components[0]), 100, Integer.parseInt(components[1]))); player.addPotionEffect(new PotionEffect(Objects.requireNonNull(PotionEffectType.getByName(components[0])), 100, Integer.parseInt(components[1])));
} }
ParticleEffect.LAVA.display(1.0f, 1.0f, 1.0f, 1.0f, 10, banner.getLocation(), 16.0); ParticleEffect.LAVA.display(1.0f, 1.0f, 1.0f, 1.0f, 10, banner.getLocation(), 16.0);
ParticleEffect.FLAME.display(1.0f, 1.0f, 1.0f, 1.0f, 10, banner.getLocation(), 16.0); ParticleEffect.FLAME.display(1.0f, 1.0f, 1.0f, 1.0f, 10, banner.getLocation(), 16.0);
@@ -502,7 +500,7 @@ public class FactionsBlockListener implements Listener {
return; return;
} }
if (block != null && isSpawner) { if (block != null && isSpawner) {
ItemStack item = new ItemStack(block.getType(), 1, (short) block.getData()); ItemStack item = new ItemStack(block.getType(), 1, block.getData());
if (at != null && at.isNormal()) { if (at != null && at.isNormal()) {
FPlayer fplayer = FPlayers.getInstance().getByPlayer(event.getPlayer()); FPlayer fplayer = FPlayers.getInstance().getByPlayer(event.getPlayer());
if (fplayer != null) { if (fplayer != null) {

View File

@@ -338,7 +338,7 @@ public class FactionsPlayerListener implements Listener {
return PermissableAction.DOOR; return PermissableAction.DOOR;
if (material.name().toUpperCase().contains("BUTTON") || material.name().toUpperCase().contains("PRESSURE") || material.name().contains("DIODE") || material.name().contains("COMPARATOR")) if (material.name().toUpperCase().contains("BUTTON") || material.name().toUpperCase().contains("PRESSURE") || material.name().contains("DIODE") || material.name().contains("COMPARATOR"))
return PermissableAction.BUTTON; return PermissableAction.BUTTON;
if (FactionsPlugin.instance.mc113 || FactionsPlugin.instance.mc114) { if (FactionsPlugin.instance.mc113 || FactionsPlugin.instance.mc114 || FactionsPlugin.getInstance().mc115) {
switch (material) { switch (material) {
case LEVER: case LEVER:
return PermissableAction.LEVER; return PermissableAction.LEVER;
@@ -381,6 +381,8 @@ public class FactionsPlayerListener implements Listener {
case TRAPPED_CHEST: case TRAPPED_CHEST:
case CHEST_MINECART: case CHEST_MINECART:
case BARREL:
case SHULKER_BOX: case SHULKER_BOX:
case BLACK_SHULKER_BOX: case BLACK_SHULKER_BOX:
case BLUE_SHULKER_BOX: case BLUE_SHULKER_BOX:
@@ -552,7 +554,6 @@ public class FactionsPlayerListener implements Listener {
public String parseAllPlaceholders(String string, Faction faction, Player player) { public String parseAllPlaceholders(String string, Faction faction, Player player) {
string = TagUtil.parsePlaceholders(player, string); string = TagUtil.parsePlaceholders(player, string);
string = string.replace("{Faction}", faction.getTag()) string = string.replace("{Faction}", faction.getTag())
.replace("{online}", faction.getOnlinePlayers().size() + "") .replace("{online}", faction.getOnlinePlayers().size() + "")
.replace("{offline}", faction.getFPlayers().size() - faction.getOnlinePlayers().size() + "") .replace("{offline}", faction.getFPlayers().size() - faction.getOnlinePlayers().size() + "")
@@ -563,27 +564,19 @@ public class FactionsPlayerListener implements Listener {
} }
public void checkCanFly(FPlayer me) { public void checkCanFly(FPlayer me) {
if (!FactionsPlugin.getInstance().getConfig().getBoolean("enable-faction-flight")) return;
if (me.isFlying() && (!me.canFlyAtLocation() || me.checkIfNearbyEnemies())) { if (me.isFlying() && (!me.canFlyAtLocation() || me.checkIfNearbyEnemies())) {
me.setFFlying(false, false); me.setFFlying(false, false);
me.msg(TL.COMMAND_FLY_NO_ACCESS, Board.getInstance().getFactionAt(me.getLastStoodAt()).getTag()); me.msg(TL.COMMAND_FLY_NO_ACCESS, Board.getInstance().getFactionAt(me.getLastStoodAt()).getTag());
return; return;
} }
if (me.isFlying() || !FactionsPlugin.instance.getConfig().getBoolean("ffly.AutoEnable")) if (me.isFlying() || !FactionsPlugin.instance.getConfig().getBoolean("ffly.AutoEnable")) return;
return;
me.setFFlying(true, false); me.setFFlying(true, false);
CmdFly.flyMap.put(me.getName(), true); CmdFly.flyMap.put(me.getName(), true);
if (CmdFly.particleTask == null) if (CmdFly.particleTask == null)
CmdFly.startParticles(); CmdFly.startParticles();
} }
@EventHandler
public void onCommand(PlayerCommandPreprocessEvent e){
if(e.getMessage().equalsIgnoreCase("/f outpost")){
e.setMessage("/outpost");
}
}
//inspect //inspect
@EventHandler @EventHandler
public void onInspect(PlayerInteractEvent e) { public void onInspect(PlayerInteractEvent e) {
@@ -677,7 +670,7 @@ public class FactionsPlayerListener implements Listener {
if (!fPlayer.checkIfNearbyEnemies()) { if (!fPlayer.checkIfNearbyEnemies()) {
FLocation myFloc = new FLocation(player.getLocation()); FLocation myFloc = new FLocation(player.getLocation());
if (Board.getInstance().getFactionAt(myFloc) != myFaction) { if (Board.getInstance().getFactionAt(myFloc) != myFaction) {
if (!CmdFly.checkBypassPerms(fPlayer, player, Board.getInstance().getFactionAt(myFloc))) { if (!CmdFly.checkFly(fPlayer, player, Board.getInstance().getFactionAt(myFloc))) {
fPlayer.setFFlying(false, false); fPlayer.setFFlying(false, false);
CmdFly.flyMap.remove(name); CmdFly.flyMap.remove(name);
} }
@@ -828,7 +821,7 @@ public class FactionsPlayerListener implements Listener {
Material type; Material type;
if (event.getItem() != null) { if (event.getItem() != null) {
// Convert 1.8 Material Names -> 1.14 // Convert 1.8 Material Names -> 1.14
type = XMaterial.matchXMaterial(event.getItem().getType().toString()).parseMaterial(); type = XMaterial.matchXMaterial(event.getItem().getType().toString()).get().parseMaterial();
} else { } else {
type = null; type = null;
} }
@@ -927,6 +920,8 @@ public class FactionsPlayerListener implements Listener {
} }
} }
@EventHandler @EventHandler
public void onLogoutMove(PlayerMoveEvent e) { public void onLogoutMove(PlayerMoveEvent e) {
LogoutHandler handler = LogoutHandler.getByName(e.getPlayer().getName()); LogoutHandler handler = LogoutHandler.getByName(e.getPlayer().getName());
@@ -934,6 +929,12 @@ public class FactionsPlayerListener implements Listener {
handler.cancelLogout(e.getPlayer()); handler.cancelLogout(e.getPlayer());
e.getPlayer().sendMessage(String.valueOf(TL.COMMAND_LOGOUT_MOVED)); e.getPlayer().sendMessage(String.valueOf(TL.COMMAND_LOGOUT_MOVED));
} }
if (e.getTo().getBlockX() == e.getFrom().getBlockX() &&
e.getTo().getBlockY() == e.getFrom().getBlockY() &&
e.getTo().getBlockZ() == e.getFrom().getBlockZ())
return;
if (CmdWild.waitingTeleport.containsKey(e.getPlayer())) { if (CmdWild.waitingTeleport.containsKey(e.getPlayer())) {
CmdWild.waitingTeleport.remove(e.getPlayer()); CmdWild.waitingTeleport.remove(e.getPlayer());
FPlayers.getInstance().getByPlayer(e.getPlayer()).msg(TL.COMMAND_WILD_INTERUPTED); FPlayers.getInstance().getByPlayer(e.getPlayer()).msg(TL.COMMAND_WILD_INTERUPTED);
@@ -1069,13 +1070,13 @@ public class FactionsPlayerListener implements Listener {
} }
FPlayer fp = FPlayers.getInstance().getByPlayer(e.getPlayer()); FPlayer fp = FPlayers.getInstance().getByPlayer(e.getPlayer());
if(fp == null) return; if (fp == null) return;
if (fp.getChatMode() != ChatMode.FACTION) { if (fp.getChatMode() != ChatMode.FACTION) {
return; return;
} }
Faction f = fp.getFaction(); Faction f = fp.getFaction();
if(f == null) return; if (f == null) return;
if (f.isSystemFaction()) { if (f.isSystemFaction()) {
return; return;
} }
@@ -1094,7 +1095,7 @@ public class FactionsPlayerListener implements Listener {
} }
} else { } else {
for (Member m : t.getMembers()) { for (Member m : t.getMembers()) {
if (m.getEffectiveName().contains(target) | m.getUser().getName().contains(target)){ if (m.getEffectiveName().contains(target) | m.getUser().getName().contains(target)) {
targets.add("@" + m.getUser().getName() + "#" + m.getUser().getDiscriminator()); targets.add("@" + m.getUser().getName() + "#" + m.getUser().getDiscriminator());
} }
} }

View File

@@ -96,7 +96,7 @@ public class MissionGUI implements FactionGUI {
if (configurationSection == null) { if (configurationSection == null) {
return; return;
} }
ItemStack fillItem = XMaterial.matchXMaterial(configurationSection.getString("FillItem.Material")).parseItem(); ItemStack fillItem = XMaterial.matchXMaterial(configurationSection.getString("FillItem.Material")).get().parseItem();
ItemMeta fillmeta = fillItem.getItemMeta(); ItemMeta fillmeta = fillItem.getItemMeta();
fillmeta.setDisplayName(""); fillmeta.setDisplayName("");
fillItem.setItemMeta(fillmeta); fillItem.setItemMeta(fillmeta);
@@ -109,7 +109,7 @@ public class MissionGUI implements FactionGUI {
ConfigurationSection section = configurationSection.getConfigurationSection(key); ConfigurationSection section = configurationSection.getConfigurationSection(key);
int slot = section.getInt("Slot"); int slot = section.getInt("Slot");
ItemStack itemStack = XMaterial.matchXMaterial(section.getString("Material")).parseItem(); ItemStack itemStack = XMaterial.matchXMaterial(section.getString("Material")).get().parseItem();
ItemMeta itemMeta = itemStack.getItemMeta(); ItemMeta itemMeta = itemStack.getItemMeta();
itemMeta.setDisplayName(ChatColor.translateAlternateColorCodes('&', section.getString("Name"))); itemMeta.setDisplayName(ChatColor.translateAlternateColorCodes('&', section.getString("Name")));
List<String> loreLines = new ArrayList<>(); List<String> loreLines = new ArrayList<>();
@@ -134,7 +134,7 @@ public class MissionGUI implements FactionGUI {
if (plugin.getConfig().getBoolean("Randomization.Enabled")) { if (plugin.getConfig().getBoolean("Randomization.Enabled")) {
ItemStack start; ItemStack start;
ItemMeta meta; ItemMeta meta;
start = XMaterial.matchXMaterial(plugin.getConfig().getString("Randomization.Start-Item.Allowed.Material")).parseItem(); start = XMaterial.matchXMaterial(plugin.getConfig().getString("Randomization.Start-Item.Allowed.Material")).get().parseItem();
meta = start.getItemMeta(); meta = start.getItemMeta();
meta.setDisplayName(plugin.color(plugin.getConfig().getString("Randomization.Start-Item.Allowed.Name"))); meta.setDisplayName(plugin.color(plugin.getConfig().getString("Randomization.Start-Item.Allowed.Name")));
List<String> loree = new ArrayList<>(); List<String> loree = new ArrayList<>();
@@ -144,7 +144,7 @@ public class MissionGUI implements FactionGUI {
meta.setLore(loree); meta.setLore(loree);
start.setItemMeta(meta); start.setItemMeta(meta);
if (fPlayer.getFaction().getCompletedMissions().size() >= configurationSection.getKeys(false).size() - 1 && plugin.getConfig().getBoolean("DenyMissionsMoreThenOnce")) { if (fPlayer.getFaction().getCompletedMissions().size() >= configurationSection.getKeys(false).size() - 1 && plugin.getConfig().getBoolean("DenyMissionsMoreThenOnce")) {
start = XMaterial.matchXMaterial(plugin.getConfig().getString("Randomization.Start-Item.Disallowed.Material")).parseItem(); start = XMaterial.matchXMaterial(plugin.getConfig().getString("Randomization.Start-Item.Disallowed.Material")).get().parseItem();
meta = start.getItemMeta(); meta = start.getItemMeta();
meta.setDisplayName(plugin.color(plugin.getConfig().getString("Randomization.Start-Item.Disallowed.Name"))); meta.setDisplayName(plugin.color(plugin.getConfig().getString("Randomization.Start-Item.Disallowed.Name")));
List<String> lore = new ArrayList<>(); List<String> lore = new ArrayList<>();
@@ -155,7 +155,7 @@ public class MissionGUI implements FactionGUI {
start.setItemMeta(meta); start.setItemMeta(meta);
} }
if (fPlayer.getFaction().getMissions().size() >= plugin.getConfig().getInt("MaximumMissionsAllowedAtOnce")) { if (fPlayer.getFaction().getMissions().size() >= plugin.getConfig().getInt("MaximumMissionsAllowedAtOnce")) {
start = XMaterial.matchXMaterial(plugin.getConfig().getString("Randomization.Start-Item.Disallowed.Material")).parseItem(); start = XMaterial.matchXMaterial(plugin.getConfig().getString("Randomization.Start-Item.Disallowed.Material")).get().parseItem();
meta = start.getItemMeta(); meta = start.getItemMeta();
meta.setDisplayName(plugin.color(plugin.getConfig().getString("Randomization.Start-Item.Disallowed.Name"))); meta.setDisplayName(plugin.color(plugin.getConfig().getString("Randomization.Start-Item.Disallowed.Name")));
List<String> lore = new ArrayList<>(); List<String> lore = new ArrayList<>();

View File

@@ -47,7 +47,7 @@ public class ShopGUIFrame {
for (int a = 1; a <= items; a++) { for (int a = 1; a <= items; a++) {
String s = a + ""; String s = a + "";
int slot = ShopConfig.getShop().getInt("items." + s + ".slot"); int slot = ShopConfig.getShop().getInt("items." + s + ".slot");
Material material = XMaterial.matchXMaterial(ShopConfig.getShop().getString("items." + s + ".block")).parseMaterial(); Material material = XMaterial.matchXMaterial(ShopConfig.getShop().getString("items." + s + ".block")).get().parseMaterial();
int cost = ShopConfig.getShop().getInt("items." + s + ".cost"); int cost = ShopConfig.getShop().getInt("items." + s + ".cost");
String name = ShopConfig.getShop().getString("items." + s + ".name"); String name = ShopConfig.getShop().getString("items." + s + ".name");
boolean glowing = ShopConfig.getShop().getBoolean("items." + s + ".glowing"); boolean glowing = ShopConfig.getShop().getBoolean("items." + s + ".glowing");
@@ -62,19 +62,12 @@ public class ShopGUIFrame {
meta.addItemFlags(ItemFlag.HIDE_ENCHANTS); meta.addItemFlags(ItemFlag.HIDE_ENCHANTS);
meta.addEnchant(Enchantment.DURABILITY, 1, true); meta.addEnchant(Enchantment.DURABILITY, 1, true);
} }
if (!glowing) { if (!glowing) meta.removeEnchant(Enchantment.DURABILITY);
meta.removeEnchant(Enchantment.DURABILITY);
}
List<String> replacedLore = lore.stream().map(t -> t.replace("{cost}", cost + "")).collect(Collectors.toList()); List<String> replacedLore = lore.stream().map(t -> t.replace("{cost}", cost + "")).collect(Collectors.toList());
meta.setLore(FactionsPlugin.instance.colorList(replacedLore)); meta.setLore(FactionsPlugin.instance.colorList(replacedLore));
item.setItemMeta(meta); item.setItemMeta(meta);
GUIItems.set(slot, new GuiItem(item, e -> { GUIItems.set(slot, new GuiItem(item, e -> {
e.setCancelled(true); e.setCancelled(true);
FPlayer fme = FPlayers.getInstance().getByPlayer((Player) e.getWhoClicked()); FPlayer fme = FPlayers.getInstance().getByPlayer((Player) e.getWhoClicked());
if (fplayer.getFaction().getPoints() >= cost) { if (fplayer.getFaction().getPoints() >= cost) {
fplayer.getFaction().setPoints(fplayer.getFaction().getPoints() - cost); fplayer.getFaction().setPoints(fplayer.getFaction().getPoints() - cost);
@@ -100,7 +93,7 @@ public class ShopGUIFrame {
private ItemStack buildDummyItem(Faction f) { private ItemStack buildDummyItem(Faction f) {
ConfigurationSection config = FactionsPlugin.getInstance().getConfig().getConfigurationSection("F-Shop.GUI.dummy-item"); ConfigurationSection config = FactionsPlugin.getInstance().getConfig().getConfigurationSection("F-Shop.GUI.dummy-item");
ItemStack item = XMaterial.matchXMaterial(config.getString("Type")).parseItem(); ItemStack item = XMaterial.matchXMaterial(config.getString("Type")).get().parseItem();
ItemMeta meta = item.getItemMeta(); ItemMeta meta = item.getItemMeta();
if (meta != null) { if (meta != null) {
meta.setLore(FactionsPlugin.getInstance().colorList(config.getStringList("Lore"))); meta.setLore(FactionsPlugin.getInstance().colorList(config.getStringList("Lore")));

View File

@@ -44,8 +44,8 @@ public enum Permission {
DISBAND_ANY("disband.any"), DISBAND_ANY("disband.any"),
DISCORD("discord"), DISCORD("discord"),
DRAIN("drain"), DRAIN("drain"),
FLY("fly"), FLY_FLY("fly"),
FLY_WILD("fly.wilderness"), FLY_WILDERNESS("fly.wilderness"),
FLY_SAFEZONE("fly.safezone"), FLY_SAFEZONE("fly.safezone"),
FLY_WARZONE("fly.warzone"), FLY_WARZONE("fly.warzone"),
FLY_ENEMY("fly.enemy"), FLY_ENEMY("fly.enemy"),

View File

@@ -210,7 +210,7 @@ public enum Relation implements Permissable {
String displayName = replacePlaceholders(RELATION_CONFIG.getString("placeholder-item.name", "")); String displayName = replacePlaceholders(RELATION_CONFIG.getString("placeholder-item.name", ""));
List<String> lore = new ArrayList<>(); List<String> lore = new ArrayList<>();
Material material = XMaterial.matchXMaterial(RELATION_CONFIG.getString("materials." + name().toLowerCase())).parseMaterial(); Material material = XMaterial.matchXMaterial(RELATION_CONFIG.getString("materials." + name().toLowerCase())).get().parseMaterial();
if (material == null) { if (material == null) {
return null; return null;
} }

View File

@@ -128,7 +128,7 @@ public enum Role implements Permissable {
String displayName = replacePlaceholders(RELATION_CONFIG.getString("placeholder-item.name", "")); String displayName = replacePlaceholders(RELATION_CONFIG.getString("placeholder-item.name", ""));
List<String> lore = new ArrayList<>(); List<String> lore = new ArrayList<>();
Material material = XMaterial.matchXMaterial(RELATION_CONFIG.getString("materials." + name().toLowerCase(), "STAINED_CLAY")).parseMaterial(); Material material = XMaterial.matchXMaterial(RELATION_CONFIG.getString("materials." + name().toLowerCase(), "STAINED_CLAY")).get().parseMaterial();
if (material == null) { if (material == null) {
return null; return null;
} }

View File

@@ -49,6 +49,8 @@ public enum FactionTag implements Tag {
} }
return null; return null;
}), }),
ANNOUNCEMENT("{announcement}", (fac) -> { return String.valueOf(fac.getAnnouncements()); }),
PEACEFUL("{peaceful}", (fac) -> fac.isPeaceful() ? Conf.colorNeutral + TL.COMMAND_SHOW_PEACEFUL.toString() : ""), PEACEFUL("{peaceful}", (fac) -> fac.isPeaceful() ? Conf.colorNeutral + TL.COMMAND_SHOW_PEACEFUL.toString() : ""),
PERMANENT("permanent", (fac) -> fac.isPermanent() ? "permanent" : "{notPermanent}"), // no braces needed 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")), 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"); 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))), ALLIES_COUNT("{allies}", (fac) -> String.valueOf(fac.getRelationCount(Relation.ALLY))),
ENEMIES_COUNT("{enemies}", (fac) -> String.valueOf(fac.getRelationCount(Relation.ENEMY))), ENEMIES_COUNT("{enemies}", (fac) -> String.valueOf(fac.getRelationCount(Relation.ENEMY))),
TRUCES_COUNT("{truces}", (fac) -> String.valueOf(fac.getRelationCount(Relation.TRUCE))), TRUCES_COUNT("{truces}", (fac) -> String.valueOf(fac.getRelationCount(Relation.TRUCE))),
@@ -80,6 +95,8 @@ public enum FactionTag implements Tag {
return String.valueOf(fac.getFPlayersWhereOnline(false).size()); return String.valueOf(fac.getFPlayersWhereOnline(false).size());
} }
}), }),
FACTION_STRIKES("{faction-strikes}",(fac) -> String.valueOf(fac.getStrikes())),
FACTION_POINTS("{faction-points}", (fac) -> String.valueOf(fac.getPoints())),
FACTION_SIZE("{members}", (fac) -> String.valueOf(fac.getFPlayers().size())), FACTION_SIZE("{members}", (fac) -> String.valueOf(fac.getFPlayers().size())),
FACTION_KILLS("{faction-kills}", (fac) -> String.valueOf(fac.getKills())), FACTION_KILLS("{faction-kills}", (fac) -> String.valueOf(fac.getKills())),
FACTION_DEATHS("{faction-deaths}", (fac) -> String.valueOf(fac.getDeaths())), FACTION_DEATHS("{faction-deaths}", (fac) -> String.valueOf(fac.getDeaths())),

View File

@@ -100,7 +100,7 @@ public enum FancyTag implements Tag {
return tag.getMessage(text, faction, player, groupMap); 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) { public static boolean anyMatch(String text) {
@@ -174,7 +174,7 @@ public enum FancyTag implements Tag {
return test != null && test.contains(this.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)) { if (!this.foundInString(text)) {
return Collections.EMPTY_LIST; // We really, really shouldn't be here. 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_ALLIES("{max-allies}", () -> getRelation("ally")),
MAX_ENEMIES("{max-enemies}", () -> getRelation("enemy")), MAX_ENEMIES("{max-enemies}", () -> getRelation("enemy")),
MAX_TRUCES("{max-truces}", () -> getRelation("truce")), MAX_TRUCES("{max-truces}", () -> getRelation("truce")),
FACTIONLESS("factionless", () -> String.valueOf(FPlayers.getInstance().getOnlinePlayers().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())), FACTIONLESS_TOTAL("{factionless-total}", () -> String.valueOf(FPlayers.getInstance().getAllFPlayers().stream().filter(p -> !p.hasFaction()).count())),
TOTAL_ONLINE("{total-online}", () -> String.valueOf(Bukkit.getOnlinePlayers().size())), 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.*;
import com.massivecraft.factions.integration.Econ; import com.massivecraft.factions.integration.Econ;
import com.massivecraft.factions.struct.Relation; import com.massivecraft.factions.struct.Relation;
import com.massivecraft.factions.tag.FactionTag;
import com.massivecraft.factions.tag.Tag; import com.massivecraft.factions.tag.Tag;
import com.massivecraft.factions.zcore.util.TL; import com.massivecraft.factions.zcore.util.TL;
import me.clip.placeholderapi.expansion.PlaceholderExpansion; import me.clip.placeholderapi.expansion.PlaceholderExpansion;
@@ -133,8 +134,14 @@ public class ClipPlaceholderAPIManager extends PlaceholderExpansion implements R
return faction.isPeaceful() ? Conf.colorNeutral + TL.COMMAND_SHOW_PEACEFUL.toString() : ""; return faction.isPeaceful() ? Conf.colorNeutral + TL.COMMAND_SHOW_PEACEFUL.toString() : "";
case "faction_tntbank_balance": case "faction_tntbank_balance":
return String.valueOf(faction.getTnt()); return String.valueOf(faction.getTnt());
case "faction_tnt_max_balance":
return FactionTag.TNT_MAX.replace(FactionTag.TNT_MAX.getTag(), faction);
case "faction_points": case "faction_points":
return fPlayer.hasFaction() ? String.valueOf(faction.getPoints()) : "0"; 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": case "faction_powerboost":
double powerBoost = faction.getPowerBoost(); double powerBoost = faction.getPowerBoost();
return (powerBoost == 0.0) ? "" : (powerBoost > 0.0 ? TL.COMMAND_SHOW_BONUS.toString() : TL.COMMAND_SHOW_PENALTY.toString()) + powerBoost + ")"; return (powerBoost == 0.0) ? "" : (powerBoost > 0.0 ? TL.COMMAND_SHOW_BONUS.toString() : TL.COMMAND_SHOW_PENALTY.toString()) + powerBoost + ")";
@@ -172,6 +179,8 @@ public class ClipPlaceholderAPIManager extends PlaceholderExpansion implements R
return String.valueOf(faction.getFPlayers().size() - faction.getOnlinePlayers().size()); return String.valueOf(faction.getFPlayers().size() - faction.getOnlinePlayers().size());
case "faction_size": case "faction_size":
return String.valueOf(faction.getFPlayers().size()); return String.valueOf(faction.getFPlayers().size());
case "faction_announcement":
return String.valueOf(faction.getAnnouncements());
case "faction_kills": case "faction_kills":
return String.valueOf(faction.getKills()); return String.valueOf(faction.getKills());
case "faction_deaths": case "faction_deaths":

View File

@@ -72,7 +72,7 @@ public class FactionWarpsFrame {
private ItemStack buildWarpAsset(final Map.Entry<String, LazyLocation> warp, final Faction faction) { private ItemStack buildWarpAsset(final Map.Entry<String, LazyLocation> warp, final Faction faction) {
final ConfigurationSection config = this.section.getConfigurationSection("warp-item"); final ConfigurationSection config = this.section.getConfigurationSection("warp-item");
final ItemStack item = XMaterial.matchXMaterial(config.getString("Type")).parseItem(); final ItemStack item = XMaterial.matchXMaterial(config.getString("Type")).get().parseItem();
final ItemMeta meta = item.getItemMeta(); final ItemMeta meta = item.getItemMeta();
meta.setLore(FactionsPlugin.getInstance().colorList(FactionsPlugin.getInstance().replacePlaceholders(config.getStringList("Lore"), new Placeholder("{warp-protected}", faction.hasWarpPassword(warp.getKey()) ? "Enabled" : "Disabled"), new Placeholder("{warp-cost}", FactionsPlugin.getInstance().getConfig().getBoolean("warp-cost.enabled", false) ? Integer.toString(FactionsPlugin.getInstance().getConfig().getInt("warp-cost.warp", 5)) : "Disabled")))); meta.setLore(FactionsPlugin.getInstance().colorList(FactionsPlugin.getInstance().replacePlaceholders(config.getStringList("Lore"), new Placeholder("{warp-protected}", faction.hasWarpPassword(warp.getKey()) ? "Enabled" : "Disabled"), new Placeholder("{warp-cost}", FactionsPlugin.getInstance().getConfig().getBoolean("warp-cost.enabled", false) ? Integer.toString(FactionsPlugin.getInstance().getConfig().getInt("warp-cost.warp", 5)) : "Disabled"))));
meta.setDisplayName(FactionsPlugin.getInstance().color(config.getString("Name").replace("{warp}", warp.getKey()))); meta.setDisplayName(FactionsPlugin.getInstance().color(config.getString("Name").replace("{warp}", warp.getKey())));
@@ -82,7 +82,7 @@ public class FactionWarpsFrame {
private ItemStack buildDummyItem() { private ItemStack buildDummyItem() {
final ConfigurationSection config = this.section.getConfigurationSection("dummy-item"); final ConfigurationSection config = this.section.getConfigurationSection("dummy-item");
final ItemStack item = XMaterial.matchXMaterial(config.getString("Type")).parseItem(); final ItemStack item = XMaterial.matchXMaterial(config.getString("Type")).get().parseItem();
final ItemMeta meta = item.getItemMeta(); final ItemMeta meta = item.getItemMeta();
meta.setLore(FactionsPlugin.getInstance().colorList(config.getStringList("Lore"))); meta.setLore(FactionsPlugin.getInstance().colorList(config.getStringList("Lore")));
meta.setDisplayName(FactionsPlugin.getInstance().color(config.getString("Name"))); meta.setDisplayName(FactionsPlugin.getInstance().color(config.getString("Name")));

View File

@@ -21,14 +21,9 @@ public class ItemBuilder {
this.meta = item.getItemMeta(); 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) { public ItemBuilder(Material material, int amount) {
this(material, amount, 0); this(new ItemStack(material, amount));
} }
public ItemBuilder(Material material) { public ItemBuilder(Material material) {
this(material, 1); 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

@@ -10,7 +10,10 @@ import org.bukkit.Bukkit;
public class UtilFly { public class UtilFly {
/**
* UtilFly is being removed very soon as all of its functionality has been updated and moved to CmdFly
*/
@Deprecated
public static void run() { public static void run() {
if (!FactionsPlugin.getInstance().getConfig().getBoolean("enable-faction-flight")) if (!FactionsPlugin.getInstance().getConfig().getBoolean("enable-faction-flight"))
return; return;
@@ -22,7 +25,7 @@ public class UtilFly {
} }
}, 0, FactionsPlugin.getInstance().getConfig().getInt("fly-task-interval", 10)); }, 0, FactionsPlugin.getInstance().getConfig().getInt("fly-task-interval", 10));
} }
@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.getInstance().getConfig().getBoolean("enable-faction-flight"))
return; return;
@@ -42,7 +45,7 @@ public class UtilFly {
setFallDamage(fp, fly, damage); setFallDamage(fp, fly, damage);
} }
@Deprecated
public static void checkFly(FPlayer me, Faction factionTo) { public static void checkFly(FPlayer me, Faction factionTo) {
if (!FactionsPlugin.getInstance().getConfig().getBoolean("enable-faction-flight")) if (!FactionsPlugin.getInstance().getConfig().getBoolean("enable-faction-flight"))
return; return;

File diff suppressed because it is too large Load Diff

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")).get().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")).get().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

@@ -104,7 +104,7 @@ public enum PermissableAction {
public ItemStack buildAsset(FPlayer fme, Permissable perm) { public ItemStack buildAsset(FPlayer fme, Permissable perm) {
ConfigurationSection section = FactionsPlugin.getInstance().getConfig().getConfigurationSection("fperm-gui.action"); ConfigurationSection section = FactionsPlugin.getInstance().getConfig().getConfigurationSection("fperm-gui.action");
ItemStack item = XMaterial.matchXMaterial(section.getString("Materials." + this.name)).parseItem(); ItemStack item = XMaterial.matchXMaterial(section.getString("Materials." + this.name)).get().parseItem();
ItemMeta meta = item.getItemMeta(); ItemMeta meta = item.getItemMeta();
meta.setDisplayName(FactionsPlugin.getInstance().color(section.getString("placeholder-item.name").replace("{action}", this.name))); meta.setDisplayName(FactionsPlugin.getInstance().color(section.getString("placeholder-item.name").replace("{action}", this.name)));

View File

@@ -91,7 +91,7 @@ public class PermissableActionFrame {
private ItemStack buildDummyItem() { private ItemStack buildDummyItem() {
ConfigurationSection config = FactionsPlugin.getInstance().getConfig().getConfigurationSection("fperm-gui.dummy-item"); ConfigurationSection config = FactionsPlugin.getInstance().getConfig().getConfigurationSection("fperm-gui.dummy-item");
ItemStack item = XMaterial.matchXMaterial(config.getString("Type")).parseItem(); ItemStack item = XMaterial.matchXMaterial(config.getString("Type")).get().parseItem();
ItemMeta meta = item.getItemMeta(); ItemMeta meta = item.getItemMeta();
meta.setLore(FactionsPlugin.getInstance().colorList(config.getStringList("Lore"))); meta.setLore(FactionsPlugin.getInstance().colorList(config.getStringList("Lore")));
meta.setDisplayName(FactionsPlugin.getInstance().color(config.getString("Name"))); meta.setDisplayName(FactionsPlugin.getInstance().color(config.getString("Name")));
@@ -101,7 +101,7 @@ public class PermissableActionFrame {
private ItemStack buildBackItem() { private ItemStack buildBackItem() {
ConfigurationSection config = FactionsPlugin.getInstance().getConfig().getConfigurationSection("fperm-gui.back-item"); ConfigurationSection config = FactionsPlugin.getInstance().getConfig().getConfigurationSection("fperm-gui.back-item");
ItemStack item = XMaterial.matchXMaterial(config.getString("Type")).parseItem(); ItemStack item = XMaterial.matchXMaterial(config.getString("Type")).get().parseItem();
ItemMeta meta = item.getItemMeta(); ItemMeta meta = item.getItemMeta();
meta.setLore(FactionsPlugin.getInstance().colorList(config.getStringList("Lore"))); meta.setLore(FactionsPlugin.getInstance().colorList(config.getStringList("Lore")));
meta.setDisplayName(FactionsPlugin.getInstance().color(config.getString("Name"))); meta.setDisplayName(FactionsPlugin.getInstance().color(config.getString("Name")));

View File

@@ -56,7 +56,7 @@ public class PermissableRelationFrame {
} }
private ItemStack buildAsset(String loc, String relation) { private ItemStack buildAsset(String loc, String relation) {
ItemStack item = XMaterial.matchXMaterial(FactionsPlugin.getInstance().getConfig().getString(loc)).parseItem(); ItemStack item = XMaterial.matchXMaterial(FactionsPlugin.getInstance().getConfig().getString(loc)).get().parseItem();
ItemMeta meta = item.getItemMeta(); ItemMeta meta = item.getItemMeta();
meta.setDisplayName(FactionsPlugin.getInstance().color(FactionsPlugin.getInstance().getConfig().getString("fperm-gui.relation.Placeholder-Item.Name").replace("{relation}", relation))); meta.setDisplayName(FactionsPlugin.getInstance().color(FactionsPlugin.getInstance().getConfig().getString("fperm-gui.relation.Placeholder-Item.Name").replace("{relation}", relation)));
item.setItemMeta(meta); item.setItemMeta(meta);
@@ -65,7 +65,7 @@ public class PermissableRelationFrame {
private ItemStack buildDummyItem() { private ItemStack buildDummyItem() {
ConfigurationSection config = FactionsPlugin.getInstance().getConfig().getConfigurationSection("fperm-gui.dummy-item"); ConfigurationSection config = FactionsPlugin.getInstance().getConfig().getConfigurationSection("fperm-gui.dummy-item");
ItemStack item = XMaterial.matchXMaterial(config.getString("Type")).parseItem(); ItemStack item = XMaterial.matchXMaterial(config.getString("Type")).get().parseItem();
ItemMeta meta = item.getItemMeta(); ItemMeta meta = item.getItemMeta();
meta.setLore(FactionsPlugin.getInstance().colorList(config.getStringList("Lore"))); meta.setLore(FactionsPlugin.getInstance().colorList(config.getStringList("Lore")));
meta.setDisplayName(FactionsPlugin.getInstance().color(config.getString("Name"))); meta.setDisplayName(FactionsPlugin.getInstance().color(config.getString("Name")));

View File

@@ -0,0 +1,113 @@
package com.massivecraft.factions.zcore.fupgrades;
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.FPlayers;
import com.massivecraft.factions.Faction;
import com.massivecraft.factions.FactionsPlugin;
import com.massivecraft.factions.util.XMaterial;
import org.bukkit.configuration.ConfigurationSection;
import org.bukkit.entity.Player;
import org.bukkit.inventory.ItemStack;
import org.bukkit.inventory.meta.ItemMeta;
import java.util.ArrayList;
import java.util.List;
/**
* @author Saser
*/
public class FUpgradeFrame {
private Gui gui;
public FUpgradeFrame(Faction f) {
this.gui = new Gui(FactionsPlugin.getInstance(),
FactionsPlugin.getInstance().getConfig().getInt("fupgrades.MainMenu.Rows", 5),
FactionsPlugin.getInstance().getConfig().getString("fupgrades.MainMenu.Title").replace("{faction}", f.getTag()));
}
public void buildGUI(FPlayer fplayer) {
PaginatedPane pane = new PaginatedPane(0, 0, 9, this.gui.getRows());
List<GuiItem> GUIItems = new ArrayList<>();
ItemStack dummy = buildDummyItem();
for (int x = 0; x <= this.gui.getRows() * 9 - 1; ++x)
GUIItems.add(new GuiItem(dummy, (e) -> e.setCancelled(true)));
for (UpgradeType value : UpgradeType.values()) {
if (value.getSlot() != -1) {
GUIItems.set(value.getSlot(), new GuiItem(value.buildAsset(fplayer.getFaction()), (e) -> {
e.setCancelled(true);
FPlayer fme = FPlayers.getInstance().getByPlayer((Player) e.getWhoClicked());
if (fme.getFaction().getUpgrade(value) != value.getMaxLevel()) {
int cost = FactionsPlugin.getInstance().getConfig().getInt("fupgrades.MainMenu." + value.toString() + ".Cost.level-" + (fme.getFaction().getUpgrade(value) + 1));
if (fme.hasMoney(cost)) {
fme.takeMoney(cost);
if (value == UpgradeType.CHEST)
updateChests(fme.getFaction());
if (value == UpgradeType.POWER)
updateFactionPowerBoost(fme.getFaction());
if (value == UpgradeType.TNT)
updateTNT(fme.getFaction());
if (value == UpgradeType.WARP)
updateWarps(fme.getFaction());
fme.getFaction().setUpgrade(value, fme.getFaction().getUpgrade(value) + 1);
this.buildGUI(fme);
}
}
}));
}
}
pane.populateWithGuiItems(GUIItems);
gui.addPane(pane);
gui.update();
gui.show(fplayer.getPlayer());
}
private void updateWarps(Faction faction) {
int level = faction.getUpgrade(UpgradeType.WARP);
int size = FactionsPlugin.getInstance().getConfig().getInt("fupgrades.MainMenu.Warps.warp-limit.level-" + (level + 1));
faction.setWarpsLimit(size);
}
private void updateTNT(Faction faction) {
int level = faction.getUpgrade(UpgradeType.TNT);
int size = FactionsPlugin.getInstance().getConfig().getInt("fupgrades.MainMenu.TNT.tnt-limit.level-" + (level + 1));
faction.setTntBankLimit(size);
}
private void updateChests(Faction faction) {
String invName = FactionsPlugin.getInstance().color(FactionsPlugin.getInstance().getConfig().getString("fchest.Inventory-Title"));
for (Player player : faction.getOnlinePlayers()) {
if (player.getOpenInventory().getTitle().equalsIgnoreCase(invName)) player.closeInventory();
}
int level = faction.getUpgrade(UpgradeType.CHEST);
int size = FactionsPlugin.getInstance().getConfig().getInt("fupgrades.MainMenu.Chest.Chest-Size.level-" + (level + 1));
faction.setChestSize(size * 9);
}
private void updateFactionPowerBoost(Faction f) {
double boost = FactionsPlugin.getInstance().getConfig().getDouble("fupgrades.MainMenu.Power.Power-Boost.level-" + (f.getUpgrade(UpgradeType.POWER) + 1));
if (boost < 0.0) return;
f.setPowerBoost(boost);
}
private ItemStack buildDummyItem() {
ConfigurationSection config = FactionsPlugin.getInstance().getConfig().getConfigurationSection("fupgrades.MainMenu.DummyItem");
ItemStack item = XMaterial.matchXMaterial(config.getString("Type")).get().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

@@ -1,667 +0,0 @@
package com.massivecraft.factions.zcore.fupgrades;
import com.massivecraft.factions.FPlayer;
import com.massivecraft.factions.FPlayers;
import com.massivecraft.factions.Faction;
import com.massivecraft.factions.FactionsPlugin;
import com.massivecraft.factions.util.XMaterial;
import org.bukkit.Bukkit;
import org.bukkit.Material;
import org.bukkit.enchantments.Enchantment;
import org.bukkit.entity.HumanEntity;
import org.bukkit.entity.Player;
import org.bukkit.event.EventHandler;
import org.bukkit.event.Listener;
import org.bukkit.event.inventory.InventoryClickEvent;
import org.bukkit.inventory.Inventory;
import org.bukkit.inventory.ItemFlag;
import org.bukkit.inventory.ItemStack;
import org.bukkit.inventory.meta.ItemMeta;
import java.util.List;
public class FUpgradesGUI implements Listener {
/**
* @author Illyria Team
*/
public void openMainMenu(FPlayer fme) {
Inventory inventory = Bukkit.createInventory(null, FactionsPlugin.getInstance().getConfig().getInt("fupgrades.MainMenu.DummyItem.rows") * 9, FactionsPlugin.getInstance().color(FactionsPlugin.getInstance().getConfig().getString("fupgrades.MainMenu.Title").replace("{faction}", fme.getFaction().getTag())));
ItemStack dummyItem = XMaterial.matchXMaterial(FactionsPlugin.getInstance().getConfig().getString("fupgrades.MainMenu.DummyItem.Type")).parseItem();
ItemMeta meta = dummyItem.getItemMeta();
meta.setLore(FactionsPlugin.getInstance().colorList(FactionsPlugin.getInstance().getConfig().getStringList("fupgrades.MainMenu.DummyItem.Lore")));
meta.setDisplayName(FactionsPlugin.getInstance().color(FactionsPlugin.getInstance().getConfig().getString("fupgrades.MainMenu.DummyItem.Name")));
dummyItem.setItemMeta(meta);
for (int fill = 0; fill < FactionsPlugin.getInstance().getConfig().getInt("fupgrades.MainMenu.DummyItem.rows") * 9; ++fill) {
inventory.setItem(fill, dummyItem);
}
ItemStack[] items = buildItems(fme);
List<Integer> cropSlots = FactionsPlugin.getInstance().getConfig().getIntegerList("fupgrades.MainMenu.Crops.CropItem.slots");
List<Integer> spawnerSlots = FactionsPlugin.getInstance().getConfig().getIntegerList("fupgrades.MainMenu.Spawners.SpawnerItem.slots");
List<Integer> expSlots = FactionsPlugin.getInstance().getConfig().getIntegerList("fupgrades.MainMenu.EXP.EXPItem.slots");
List<Integer> chestSlots = FactionsPlugin.getInstance().getConfig().getIntegerList("fupgrades.MainMenu.Chest.ChestItem.slots");
List<Integer> powerSlots = FactionsPlugin.getInstance().getConfig().getIntegerList("fupgrades.MainMenu.Power.PowerItem.slots");
List<Integer> redSlots = FactionsPlugin.getInstance().getConfig().getIntegerList("fupgrades.MainMenu.Redstone.RedstoneItem.slots");
List<Integer> memberSlots = FactionsPlugin.getInstance().getConfig().getIntegerList("fupgrades.MainMenu.Members.MembersItem.slots");
List<Integer> reductSlots = FactionsPlugin.getInstance().getConfig().getIntegerList("fupgrades.MainMenu.DamageReduct.ReduceItem.slots");
List<Integer> increaseSlots = FactionsPlugin.getInstance().getConfig().getIntegerList("fupgrades.MainMenu.DamageIncrease.IncreaseItem.slots");
List<Integer> tntSlots = FactionsPlugin.getInstance().getConfig().getIntegerList("fupgrades.MainMenu.TNT.TntItem.slots");
List<Integer> warpSlots = FactionsPlugin.getInstance().getConfig().getIntegerList("fupgrades.MainMenu.Warps.WarpItem.slots");
List<Integer> armorSlots = FactionsPlugin.getInstance().getConfig().getIntegerList("fupgrades.MainMenu.Armor.ArmorItem.slots");
for (Integer cropSlot : cropSlots) if (cropSlot != -1) inventory.setItem(cropSlot, items[2]);
for (Integer spawnerSlot : spawnerSlots) if (spawnerSlot != -1) inventory.setItem(spawnerSlot, items[1]);
for (Integer expSlot : expSlots) if (expSlot != -1) inventory.setItem(expSlot, items[0]);
for (Integer chestSlot : chestSlots) if (chestSlot != -1) inventory.setItem(chestSlot, items[3]);
for (Integer powerSlot : powerSlots) if (powerSlot != -1) inventory.setItem(powerSlot, items[4]);
for (Integer redSlot : redSlots) if (redSlot != -1) inventory.setItem(redSlot, items[5]);
for (Integer memberSlot : memberSlots) if (memberSlot != -1) inventory.setItem(memberSlot, items[6]);
for (Integer reduceSlot : reductSlots) if (reduceSlot != -1) inventory.setItem(reduceSlot, items[7]);
for (Integer increaseSlot : increaseSlots) if (increaseSlot != -1) inventory.setItem(increaseSlot, items[8]);
for(Integer tntSlot : tntSlots) if(tntSlot != -1) inventory.setItem(tntSlot, items[9]);
for(Integer warpSlot : warpSlots) if(warpSlot != -1) inventory.setItem(warpSlot, items[10]);
for(Integer armorSlot : armorSlots) if(armorSlot != -1) inventory.setItem(armorSlot, items[11]);
fme.getPlayer().openInventory(inventory);
}
@EventHandler
public void onClick(InventoryClickEvent e) {
if (e.getClickedInventory() == null || e.getCurrentItem() == null || e.getCurrentItem().getItemMeta() == null || e.getCursor() == null)
return;
FPlayer fme = FPlayers.getInstance().getByPlayer((Player) e.getWhoClicked());
if (e.getView().getTitle().equalsIgnoreCase(FactionsPlugin.getInstance().color(FactionsPlugin.getInstance().getConfig().getString("fupgrades.MainMenu.Title").replace("{faction}", fme.getFaction().getTag())))) {
e.setCancelled(true);
ItemStack[] items = buildItems(fme);
ItemStack cropItem = items[2];
ItemStack expItem = items[0];
ItemStack chestitem = items[3];
ItemStack spawnerItem = items[1];
ItemStack powerItem = items[4];
ItemStack redItem = items[5];
ItemStack memberItem = items[6];
ItemStack reduceItem = items[7];
ItemStack increaseItem = items[8];
ItemStack tntItem = items[9];
ItemStack warpItem = items[10];
ItemStack armorItem = items[11];
if (e.getCurrentItem().equals(cropItem)) {
int cropLevel = fme.getFaction().getUpgrade(UpgradeType.CROP);
switch (cropLevel) {
case 3:
return;
case 2:
upgradeItem(fme, UpgradeType.CROP, 3, FactionsPlugin.getInstance().getConfig().getInt("fupgrades.MainMenu.Crops.Cost.level-3"));
break;
case 1:
upgradeItem(fme, UpgradeType.CROP, 2, FactionsPlugin.getInstance().getConfig().getInt("fupgrades.MainMenu.Crops.Cost.level-2"));
break;
case 0:
upgradeItem(fme, UpgradeType.CROP, 1, FactionsPlugin.getInstance().getConfig().getInt("fupgrades.MainMenu.Crops.Cost.level-1"));
break;
}
} else if (e.getCurrentItem().equals(powerItem)) {
int powerLevel = fme.getFaction().getUpgrade(UpgradeType.POWER);
switch (powerLevel) {
case 3:
return;
case 2:
upgradeItem(fme, UpgradeType.POWER, 3, FactionsPlugin.getInstance().getConfig().getInt("fupgrades.MainMenu.Power.Cost.level-3"));
updatePower(fme.getFaction());
break;
case 1:
upgradeItem(fme, UpgradeType.POWER, 2, FactionsPlugin.getInstance().getConfig().getInt("fupgrades.MainMenu.Power.Cost.level-2"));
updatePower(fme.getFaction());
break;
case 0:
upgradeItem(fme, UpgradeType.POWER, 1, FactionsPlugin.getInstance().getConfig().getInt("fupgrades.MainMenu.Power.Cost.level-1"));
updatePower(fme.getFaction());
break;
}
} else if (e.getCurrentItem().equals(spawnerItem)) {
int spawnerLevel = fme.getFaction().getUpgrade(UpgradeType.SPAWNER);
switch (spawnerLevel) {
case 3:
return;
case 2:
upgradeItem(fme, UpgradeType.SPAWNER, 3, FactionsPlugin.getInstance().getConfig().getInt("fupgrades.MainMenu.Spawners.Cost.level-3"));
break;
case 1:
upgradeItem(fme, UpgradeType.SPAWNER, 2, FactionsPlugin.getInstance().getConfig().getInt("fupgrades.MainMenu.Spawners.Cost.level-2"));
break;
case 0:
upgradeItem(fme, UpgradeType.SPAWNER, 1, FactionsPlugin.getInstance().getConfig().getInt("fupgrades.MainMenu.Spawners.Cost.level-1"));
break;
}
} else if (e.getCurrentItem().equals(expItem)) {
int expLevel = fme.getFaction().getUpgrade(UpgradeType.EXP);
switch (expLevel) {
case 3:
return;
case 2:
upgradeItem(fme, UpgradeType.EXP, 3, FactionsPlugin.getInstance().getConfig().getInt("fupgrades.MainMenu.EXP.Cost.level-3"));
break;
case 1:
upgradeItem(fme, UpgradeType.EXP, 2, FactionsPlugin.getInstance().getConfig().getInt("fupgrades.MainMenu.EXP.Cost.level-2"));
break;
case 0:
upgradeItem(fme, UpgradeType.EXP, 1, FactionsPlugin.getInstance().getConfig().getInt("fupgrades.MainMenu.EXP.Cost.level-1"));
break;
}
} else if (e.getCurrentItem().equals(redItem)) {
int redLevel = fme.getFaction().getUpgrade(UpgradeType.REDSTONE);
switch (redLevel) {
case 1:
return;
case 0:
upgradeItem(fme, UpgradeType.REDSTONE, 1, FactionsPlugin.getInstance().getConfig().getInt("fupgrades.MainMenu.Redstone.Cost"));
break;
}
} else if (e.getCurrentItem().equals(chestitem)) {
int chestLevel = fme.getFaction().getUpgrade(UpgradeType.CHEST);
switch (chestLevel) {
case 3:
return;
case 2: {
if (upgradeItem(fme, UpgradeType.CHEST, 3, FactionsPlugin.getInstance().getConfig().getInt("fupgrades.MainMenu.Chest.Cost.level-3")))
updateChests(fme.getFaction());
break;
}
case 1: {
if (upgradeItem(fme, UpgradeType.CHEST, 2, FactionsPlugin.getInstance().getConfig().getInt("fupgrades.MainMenu.Chest.Cost.level-2")))
updateChests(fme.getFaction());
break;
}
case 0: {
if (upgradeItem(fme, UpgradeType.CHEST, 1, FactionsPlugin.getInstance().getConfig().getInt("fupgrades.MainMenu.Chest.Cost.level-1")))
updateChests(fme.getFaction());
break;
}
}
} else if (e.getCurrentItem().equals(armorItem)) {
int armorLevel = fme.getFaction().getUpgrade(UpgradeType.REINFORCEDARMOR);
switch (armorLevel) {
case 3:
return;
case 2: {
if (upgradeItem(fme, UpgradeType.REINFORCEDARMOR, 3, FactionsPlugin.getInstance().getConfig().getInt("fupgrades.MainMenu.Armor.Cost.level-3")))
break;
}
case 1: {
if (upgradeItem(fme, UpgradeType.REINFORCEDARMOR, 2, FactionsPlugin.getInstance().getConfig().getInt("fupgrades.MainMenu.Armor.Cost.level-2")))
break;
}
case 0: {
if (upgradeItem(fme, UpgradeType.REINFORCEDARMOR, 1, FactionsPlugin.getInstance().getConfig().getInt("fupgrades.MainMenu.Armor.Cost.level-1")))
break;
}
}
} else if (e.getCurrentItem().equals(memberItem)) {
int memberLevel = fme.getFaction().getUpgrade(UpgradeType.MEMBERS) + 1;
if (!FactionsPlugin.getInstance().getConfig().isSet("fupgrades.MainMenu.Members.Cost.level-" + memberLevel)) {
return;
}
int cost = FactionsPlugin.getInstance().getConfig().getInt("fupgrades.MainMenu.Members.Cost.level-" + memberLevel);
if (hasMoney(fme, cost)) {
fme.getFaction().setUpgrade(UpgradeType.MEMBERS, memberLevel);
fme.getPlayer().closeInventory();
takeMoney(fme, cost);
}
} else if (e.getCurrentItem().equals(reduceItem)) {
int reduceLevel = fme.getFaction().getUpgrade(UpgradeType.DAMAGEDECREASE) + 1;
if (!FactionsPlugin.getInstance().getConfig().isSet("fupgrades.MainMenu.DamageReduct.Cost.level-" + reduceLevel)) {
return;
}
int cost = FactionsPlugin.getInstance().getConfig().getInt("fupgrades.MainMenu.DamageReduct.Cost.level-" + reduceLevel);
if (hasMoney(fme, cost)) {
fme.getFaction().setUpgrade(UpgradeType.DAMAGEDECREASE, reduceLevel);
fme.getPlayer().closeInventory();
takeMoney(fme, cost);
}
} else if (e.getCurrentItem().equals(increaseItem)) {
int increaseLevel = fme.getFaction().getUpgrade(UpgradeType.DAMAGEINCREASE) + 1;
if (!FactionsPlugin.getInstance().getConfig().isSet("fupgrades.MainMenu.DamageIncrease.Cost.level-" + increaseLevel)) {
return;
}
int cost = FactionsPlugin.getInstance().getConfig().getInt("fupgrades.MainMenu.DamageIncrease.Cost.level-" + increaseLevel);
if (hasMoney(fme, cost)) {
fme.getFaction().setUpgrade(UpgradeType.DAMAGEINCREASE, increaseLevel);
fme.getPlayer().closeInventory();
takeMoney(fme, cost);
}
} else if(e.getCurrentItem().equals(tntItem)){
int tntLevel = fme.getFaction().getUpgrade(UpgradeType.TNT) + 1;
if (!FactionsPlugin.getInstance().getConfig().isSet("fupgrades.MainMenu.TNT.Cost.level-" + tntLevel)) {
return;
}
int cost = FactionsPlugin.getInstance().getConfig().getInt("fupgrades.MainMenu.TNT.Cost.level-" + tntLevel);
if (hasMoney(fme, cost)) {
fme.getFaction().setUpgrade(UpgradeType.TNT, tntLevel);
fme.getPlayer().closeInventory();
takeMoney(fme, cost);
updateTntBanks(fme.getFaction());
}
} else if(e.getCurrentItem().equals(warpItem)){
int warpLevel = fme.getFaction().getUpgrade(UpgradeType.WARP) + 1;
if (!FactionsPlugin.getInstance().getConfig().isSet("fupgrades.MainMenu.Warps.Cost.level-" + warpLevel)) {
return;
}
int cost = FactionsPlugin.getInstance().getConfig().getInt("fupgrades.MainMenu.Warps.Cost.level-" + warpLevel);
if (hasMoney(fme, cost)) {
fme.getFaction().setUpgrade(UpgradeType.WARP, warpLevel);
fme.getPlayer().closeInventory();
takeMoney(fme, cost);
setWarpLimit(fme.getFaction());
}
}
}
}
private void updateChests(Faction faction) {
String invName = FactionsPlugin.getInstance().color(FactionsPlugin.getInstance().getConfig().getString("fchest.Inventory-Title"));
for (HumanEntity player : faction.getChestInventory().getViewers()) {
if (player.getOpenInventory().getTitle() != null && player.getOpenInventory().getTitle().equalsIgnoreCase(invName))
player.closeInventory();
}
int level = faction.getUpgrade(UpgradeType.CHEST);
int size = FactionsPlugin.getInstance().getConfig().getInt("fchest.Default-Size");
switch (level) {
case 1:
size = FactionsPlugin.getInstance().getConfig().getInt("fupgrades.MainMenu.Chest.Chest-Size.level-1");
break;
case 2:
size = FactionsPlugin.getInstance().getConfig().getInt("fupgrades.MainMenu.Chest.Chest-Size.level-2");
break;
case 3:
size = FactionsPlugin.getInstance().getConfig().getInt("fupgrades.MainMenu.Chest.Chest-Size.level-3");
break;
}
faction.setChestSize(size * 9);
}
private void updatePower(Faction faction) {
int level = faction.getUpgrade(UpgradeType.POWER);
double power = 0.0;
switch (level) {
case 1:
power = FactionsPlugin.getInstance().getConfig().getInt("fupgrades.MainMenu.Power.Power-Boost.level-1");
break;
case 2:
power = FactionsPlugin.getInstance().getConfig().getInt("fupgrades.MainMenu.Power.Power-Boost.level-2");
break;
case 3:
power = FactionsPlugin.getInstance().getConfig().getInt("fupgrades.MainMenu.Power.Power-Boost.level-3");
break;
}
faction.setPowerBoost(power);
}
@SuppressWarnings("Duplicates")
private ItemStack[] buildItems(FPlayer fme) {
byte expData = (byte) (FactionsPlugin.getInstance().getConfig().getInt("fupgrades.MainMenu.EXP.EXPItem.Damage"));
Material expMaterial = XMaterial.parseMaterial(FactionsPlugin.getInstance().getConfig().getString("fupgrades.MainMenu.EXP.EXPItem.Type"), expData);
int expAmt = FactionsPlugin.getInstance().getConfig().getInt("fupgrades.MainMenu.EXP.EXPItem.Amount");
String expName = FactionsPlugin.getInstance().color(FactionsPlugin.getInstance().getConfig().getString("fupgrades.MainMenu.EXP.EXPItem.Name"));
List<String> expLore = FactionsPlugin.getInstance().colorList(FactionsPlugin.getInstance().getConfig().getStringList("fupgrades.MainMenu.EXP.EXPItem.Lore"));
int expLevel = fme.getFaction().getUpgrade(UpgradeType.EXP);
for (int i = 0; i <= expLore.size() - 1; i++)
expLore.set(i, expLore.get(i).replace("{level}", expLevel + ""));
ItemStack expItem = FactionsPlugin.getInstance().createItem(expMaterial, expAmt, expData, expName, expLore);
if (expLevel >= 1) {
ItemMeta itemMeta = expItem.getItemMeta();
if (!FactionsPlugin.getInstance().mc17) {
itemMeta.addItemFlags(ItemFlag.HIDE_ENCHANTS);
}
itemMeta.addEnchant(Enchantment.DURABILITY, 3, true);
expItem.setItemMeta(itemMeta);
expItem.setAmount(expLevel);
}
byte spawnerData = (byte) (FactionsPlugin.getInstance().getConfig().getInt("fupgrades.MainMenu.Spawners.SpawnerItem.Damage"));
Material spawnerMaterial = XMaterial.parseMaterial(FactionsPlugin.getInstance().getConfig().getString("fupgrades.MainMenu.Spawners.SpawnerItem.Type"), spawnerData);
int spawnerAmt = FactionsPlugin.getInstance().getConfig().getInt("fupgrades.MainMenu.Spawners.SpawnerItem.Amount");
String spawnerName = FactionsPlugin.getInstance().color(FactionsPlugin.getInstance().getConfig().getString("fupgrades.MainMenu.Spawners.SpawnerItem.Name"));
List<String> spawnerLore = FactionsPlugin.getInstance().colorList(FactionsPlugin.getInstance().getConfig().getStringList("fupgrades.MainMenu.Spawners.SpawnerItem.Lore"));
int spawnerLevel = fme.getFaction().getUpgrade(UpgradeType.SPAWNER);
for (int i = 0; i <= spawnerLore.size() - 1; i++) {
spawnerLore.set(i, spawnerLore.get(i).replace("{level}", spawnerLevel + ""));
}
byte cropData = (byte) (FactionsPlugin.getInstance().getConfig().getInt("fupgrades.MainMenu.Crops.CropItem.Damage"));
Material cropMaterial = XMaterial.parseMaterial(FactionsPlugin.getInstance().getConfig().getString("fupgrades.MainMenu.Crops.CropItem.Type"), cropData);
int cropAmt = FactionsPlugin.getInstance().getConfig().getInt("fupgrades.MainMenu.Crops.CropItem.Amount");
String cropName = FactionsPlugin.getInstance().color(FactionsPlugin.getInstance().getConfig().getString("fupgrades.MainMenu.Crops.CropItem.Name"));
List<String> cropLore = FactionsPlugin.getInstance().colorList(FactionsPlugin.getInstance().getConfig().getStringList("fupgrades.MainMenu.Crops.CropItem.Lore"));
int cropLevel = fme.getFaction().getUpgrade(UpgradeType.CROP);
for (int i = 0; i <= cropLore.size() - 1; i++) {
String line = cropLore.get(i);
line = line.replace("{level}", cropLevel + "");
cropLore.set(i, line);
}
ItemStack cropItem = FactionsPlugin.getInstance().createItem(cropMaterial, cropAmt, cropData, cropName, cropLore);
cropItem.getItemMeta().setLore(cropLore);
if (cropLevel >= 1) {
ItemMeta itemMeta = cropItem.getItemMeta();
if (!FactionsPlugin.getInstance().mc17) {
itemMeta.addItemFlags(ItemFlag.HIDE_ENCHANTS);
}
itemMeta.addEnchant(Enchantment.DURABILITY, 3, true);
cropItem.setItemMeta(itemMeta);
cropItem.setAmount(cropLevel);
}
ItemStack spawnerItem = FactionsPlugin.getInstance().createItem(spawnerMaterial, spawnerAmt, spawnerData, spawnerName, spawnerLore);
spawnerItem.getItemMeta().setLore(spawnerLore);
if (spawnerLevel >= 1) {
ItemMeta itemMeta = spawnerItem.getItemMeta();
if (!FactionsPlugin.getInstance().mc17) {
itemMeta.addItemFlags(ItemFlag.HIDE_ENCHANTS);
}
itemMeta.addEnchant(Enchantment.DURABILITY, 3, true);
spawnerItem.setItemMeta(itemMeta);
spawnerItem.setAmount(spawnerLevel);
}
byte chestData = (byte) (FactionsPlugin.getInstance().getConfig().getInt("fupgrades.MainMenu.Chest.ChestItem.Damage"));
Material chestMaterial = XMaterial.parseMaterial(FactionsPlugin.getInstance().getConfig().getString("fupgrades.MainMenu.Chest.ChestItem.Type"), chestData);
int chestAmt = FactionsPlugin.getInstance().getConfig().getInt("fupgrades.MainMenu.Chest.ChestItem.Amount");
String chestName = FactionsPlugin.getInstance().color(FactionsPlugin.getInstance().getConfig().getString("fupgrades.MainMenu.Chest.ChestItem.Name", "&e&lUpgrade Chest Size"));
List<String> chestLore = FactionsPlugin.getInstance().colorList(FactionsPlugin.getInstance().getConfig().getStringList("fupgrades.MainMenu.Chest.ChestItem.Lore"));
int chestlevel = fme.getFaction().getUpgrade(UpgradeType.CHEST);
for (int i = 0; i <= chestLore.size() - 1; i++) {
String line = chestLore.get(i);
line = line.replace("{level}", chestlevel + "");
chestLore.set(i, line);
}
ItemStack chestItem = FactionsPlugin.getInstance().createItem(chestMaterial, chestAmt, chestData, chestName, chestLore);
if (chestlevel >= 1) {
ItemMeta itemMeta = chestItem.getItemMeta();
if (!FactionsPlugin.getInstance().mc17) {
itemMeta.addItemFlags(ItemFlag.HIDE_ENCHANTS);
}
itemMeta.addEnchant(Enchantment.DURABILITY, 3, true);
chestItem.setItemMeta(itemMeta);
chestItem.setAmount(chestlevel);
}
byte memberData = (byte) (FactionsPlugin.getInstance().getConfig().getInt("fupgrades.MainMenu.Members.MembersItem.Damage"));
Material memberMaterial = XMaterial.parseMaterial(FactionsPlugin.getInstance().getConfig().getString("fupgrades.MainMenu.Members.MembersItem.Type"), memberData);
int memberAmt = FactionsPlugin.getInstance().getConfig().getInt("fupgrades.MainMenu.Members.MembersItem.Amount");
String memberName = FactionsPlugin.getInstance().color(FactionsPlugin.getInstance().getConfig().getString("fupgrades.MainMenu.Members.MembersItem.Name", "&e&lUpgrade Member Size"));
List<String> memberLore = FactionsPlugin.getInstance().colorList(FactionsPlugin.getInstance().getConfig().getStringList("fupgrades.MainMenu.Members.MembersItem.Lore"));
int memberlevel = fme.getFaction().getUpgrade(UpgradeType.MEMBERS);
for (int i = 0; i <= memberLore.size() - 1; i++) {
String line = memberLore.get(i);
line = line.replace("{level}", memberlevel + "");
memberLore.set(i, line);
}
ItemStack memberItem = FactionsPlugin.getInstance().createItem(memberMaterial, memberAmt, memberData, memberName, memberLore);
if (memberlevel >= 1) {
ItemMeta itemMeta = memberItem.getItemMeta();
if (!FactionsPlugin.getInstance().mc17) {
itemMeta.addItemFlags(ItemFlag.HIDE_ENCHANTS);
}
itemMeta.addEnchant(Enchantment.DURABILITY, 3, true);
memberItem.setItemMeta(itemMeta);
memberItem.setAmount(memberlevel);
}
byte powerData = (byte) (FactionsPlugin.getInstance().getConfig().getInt("fupgrades.MainMenu.Power.PowerItem.Damage"));
Material powerMaterial = XMaterial.parseMaterial(FactionsPlugin.getInstance().getConfig().getString("fupgrades.MainMenu.Power.PowerItem.Type"), powerData);
int powerAmt = FactionsPlugin.getInstance().getConfig().getInt("fupgrades.MainMenu.Power.PowerItem.Amount");
String powerName = FactionsPlugin.getInstance().color(FactionsPlugin.getInstance().getConfig().getString("fupgrades.MainMenu.Power.PowerItem.Name"));
List<String> powerLore = FactionsPlugin.getInstance().colorList(FactionsPlugin.getInstance().getConfig().getStringList("fupgrades.MainMenu.Power.PowerItem.Lore"));
int powerLevel = fme.getFaction().getUpgrade(UpgradeType.POWER);
for (int i = 0; i <= powerLore.size() - 1; i++) {
String line = powerLore.get(i);
line = line.replace("{level}", powerLevel + "");
powerLore.set(i, line);
}
ItemStack powerItem = FactionsPlugin.getInstance().createItem(powerMaterial, powerAmt, powerData, powerName, powerLore);
powerItem.getItemMeta().setLore(powerLore);
if (powerLevel >= 1) {
ItemMeta itemMeta = powerItem.getItemMeta();
if (!FactionsPlugin.getInstance().mc17) {
itemMeta.addItemFlags(ItemFlag.HIDE_ENCHANTS);
}
itemMeta.addEnchant(Enchantment.DURABILITY, 3, true);
powerItem.setItemMeta(itemMeta);
powerItem.setAmount(powerLevel);
}
byte redData = (byte) (FactionsPlugin.getInstance().getConfig().getInt("fupgrades.MainMenu.Redstone.RedstoneItem.Damage"));
Material redMaterial = XMaterial.parseMaterial(FactionsPlugin.getInstance().getConfig().getString("fupgrades.MainMenu.Redstone.RedstoneItem.Type"), redData);
int redAmt = FactionsPlugin.getInstance().getConfig().getInt("fupgrades.MainMenu.Redstone.RedstoneItem.Amount");
String redName = FactionsPlugin.getInstance().color(FactionsPlugin.getInstance().getConfig().getString("fupgrades.MainMenu.Redstone.RedstoneItem.Name"));
List<String> redLore = FactionsPlugin.getInstance().colorList(FactionsPlugin.getInstance().getConfig().getStringList("fupgrades.MainMenu.Redstone.RedstoneItem.Lore"));
int redLevel = fme.getFaction().getUpgrade(UpgradeType.REDSTONE);
for (int i = 0; i <= redLore.size() - 1; i++) {
String line = redLore.get(i);
line = line.replace("{level}", redLevel + "");
redLore.set(i, line);
}
ItemStack redItem = FactionsPlugin.getInstance().createItem(redMaterial, redAmt, redData, redName, redLore);
redItem.getItemMeta().setLore(redLore);
if (redLevel >= 1) {
ItemMeta itemMeta = redItem.getItemMeta();
if (!FactionsPlugin.getInstance().mc17) {
itemMeta.addItemFlags(ItemFlag.HIDE_ENCHANTS);
}
itemMeta.addEnchant(Enchantment.DURABILITY, 3, true);
redItem.setItemMeta(itemMeta);
redItem.setAmount(redLevel);
}
byte reduceData = (byte) (FactionsPlugin.getInstance().getConfig().getInt("fupgrades.MainMenu.DamageReduct.ReduceItem.Damage"));
Material reduceMaterial = XMaterial.parseMaterial(FactionsPlugin.getInstance().getConfig().getString("fupgrades.MainMenu.DamageReduct.ReduceItem.Type"), reduceData);
int reduceAmt = FactionsPlugin.getInstance().getConfig().getInt("fupgrades.MainMenu.DamageReduct.ReduceItem.Amount");
String reduceName = FactionsPlugin.getInstance().color(FactionsPlugin.getInstance().getConfig().getString("fupgrades.MainMenu.DamageReduct.ReduceItem.Name"));
List<String> reduceLore = FactionsPlugin.getInstance().colorList(FactionsPlugin.getInstance().getConfig().getStringList("fupgrades.MainMenu.DamageReduct.ReduceItem.Lore"));
int reduceLevel = fme.getFaction().getUpgrade(UpgradeType.DAMAGEDECREASE);
for (int i = 0; i <= reduceLore.size() - 1; i++) {
String line = reduceLore.get(i);
line = line.replace("{level}", reduceLevel + "");
reduceLore.set(i, line);
}
ItemStack reduceItem = FactionsPlugin.getInstance().createItem(reduceMaterial, reduceAmt, reduceData, reduceName, reduceLore);
reduceItem.getItemMeta().setLore(reduceLore);
if (reduceLevel >= 1) {
ItemMeta itemMeta = reduceItem.getItemMeta();
if (!FactionsPlugin.getInstance().mc17) {
itemMeta.addItemFlags(ItemFlag.HIDE_ENCHANTS);
}
itemMeta.addEnchant(Enchantment.DURABILITY, 3, true);
reduceItem.setItemMeta(itemMeta);
reduceItem.setAmount(reduceLevel);
}
byte increaseData = (byte) (FactionsPlugin.getInstance().getConfig().getInt("fupgrades.MainMenu.DamageIncrease.IncreaseItem.Damage"));
Material increaseMaterial = XMaterial.parseMaterial(FactionsPlugin.getInstance().getConfig().getString("fupgrades.MainMenu.DamageIncrease.IncreaseItem.Type"), increaseData);
int increaseAmt = FactionsPlugin.getInstance().getConfig().getInt("fupgrades.MainMenu.DamageIncrease.IncreaseItem.Amount");
String increaseName = FactionsPlugin.getInstance().color(FactionsPlugin.getInstance().getConfig().getString("fupgrades.MainMenu.DamageIncrease.IncreaseItem.Name"));
List<String> increaseLore = FactionsPlugin.getInstance().colorList(FactionsPlugin.getInstance().getConfig().getStringList("fupgrades.MainMenu.DamageIncrease.IncreaseItem.Lore"));
int increaseLevel = fme.getFaction().getUpgrade(UpgradeType.DAMAGEINCREASE);
for (int i = 0; i <= increaseLore.size() - 1; i++) {
String line = increaseLore.get(i);
line = line.replace("{level}", increaseLevel + "");
increaseLore.set(i, line);
}
ItemStack increaseItem = FactionsPlugin.getInstance().createItem(increaseMaterial, increaseAmt, increaseData, increaseName, increaseLore);
increaseItem.getItemMeta().setLore(increaseLore);
if (increaseLevel >= 1) {
ItemMeta itemMeta = increaseItem.getItemMeta();
if (!FactionsPlugin.getInstance().mc17) {
itemMeta.addItemFlags(ItemFlag.HIDE_ENCHANTS);
}
itemMeta.addEnchant(Enchantment.DURABILITY, 3, true);
increaseItem.setItemMeta(itemMeta);
increaseItem.setAmount(increaseLevel);
}
byte tntData = (byte) (FactionsPlugin.getInstance().getConfig().getInt("fupgrades.MainMenu.TNT.TntItem.Damage"));
Material tntMaterial = XMaterial.parseMaterial(FactionsPlugin.getInstance().getConfig().getString("fupgrades.MainMenu.TNT.TntItem.Type"), tntData);
int tntAmt = FactionsPlugin.getInstance().getConfig().getInt("fupgrades.MainMenu.TNT.TntItem.Amount");
String tntName = FactionsPlugin.getInstance().color(FactionsPlugin.getInstance().getConfig().getString("fupgrades.MainMenu.TNT.TntItem.Name"));
List<String> tntLore = FactionsPlugin.getInstance().colorList(FactionsPlugin.getInstance().getConfig().getStringList("fupgrades.MainMenu.TNT.TntItem.Lore"));
int tntLevel = fme.getFaction().getUpgrade(UpgradeType.TNT);
for (int i = 0; i <= tntLore.size() - 1; i++) {
String line = tntLore.get(i);
line = line.replace("{level}", tntLevel + "");
tntLore.set(i, line);
}
ItemStack tntItem = FactionsPlugin.getInstance().createItem(tntMaterial, tntAmt, tntData, tntName, tntLore);
tntItem.getItemMeta().setLore(tntLore);
if (tntLevel >= 1) {
ItemMeta itemMeta = tntItem.getItemMeta();
if (!FactionsPlugin.getInstance().mc17) {
itemMeta.addItemFlags(ItemFlag.HIDE_ENCHANTS);
}
itemMeta.addEnchant(Enchantment.DURABILITY, 3, true);
tntItem.setItemMeta(itemMeta);
tntItem.setAmount(tntLevel);
}
byte warpData = (byte) (FactionsPlugin.getInstance().getConfig().getInt("fupgrades.MainMenu.Warps.WarpItem.Damage"));
Material warpMaterial = XMaterial.parseMaterial(FactionsPlugin.getInstance().getConfig().getString("fupgrades.MainMenu.Warps.WarpItem.Type"), warpData);
int warpAmt = FactionsPlugin.getInstance().getConfig().getInt("fupgrades.MainMenu.Warps.WarpItem.Amount");
String warpName = FactionsPlugin.getInstance().color(FactionsPlugin.getInstance().getConfig().getString("fupgrades.MainMenu.Warps.WarpItem.Name"));
List<String> warpLore = FactionsPlugin.getInstance().colorList(FactionsPlugin.getInstance().getConfig().getStringList("fupgrades.MainMenu.Warps.WarpItem.Lore"));
int warpLevel = fme.getFaction().getUpgrade(UpgradeType.WARP);
for (int i = 0; i <= warpLore.size() - 1; i++) {
String line = warpLore.get(i);
line = line.replace("{level}", warpLevel + "");
warpLore.set(i, line);
}
ItemStack warpItem = FactionsPlugin.getInstance().createItem(warpMaterial, warpAmt, warpData, warpName, warpLore);
warpItem.getItemMeta().setLore(warpLore);
if (warpLevel >= 1) {
ItemMeta itemMeta = warpItem.getItemMeta();
if (!FactionsPlugin.getInstance().mc17) {
itemMeta.addItemFlags(ItemFlag.HIDE_ENCHANTS);
}
itemMeta.addEnchant(Enchantment.DURABILITY, 3, true);
warpItem.setItemMeta(itemMeta);
warpItem.setAmount(warpLevel);
}
byte armorData = (byte) (FactionsPlugin.getInstance().getConfig().getInt("fupgrades.MainMenu.Armor.ArmorItem.Damage"));
Material armorMaterial = XMaterial.parseMaterial(FactionsPlugin.getInstance().getConfig().getString("fupgrades.MainMenu.Armor.ArmorItem.Type"), warpData);
int armorAmt = FactionsPlugin.getInstance().getConfig().getInt("fupgrades.MainMenu.Armor.ArmorItem.Amount");
String armorName = FactionsPlugin.getInstance().color(FactionsPlugin.getInstance().getConfig().getString("fupgrades.MainMenu.Armor.ArmorItem.Name"));
List<String> armorLore = FactionsPlugin.getInstance().colorList(FactionsPlugin.getInstance().getConfig().getStringList("fupgrades.MainMenu.Armor.ArmorItem.Lore"));
int armorLevel = fme.getFaction().getUpgrade(UpgradeType.REINFORCEDARMOR);
for (int i = 0; i <= armorLore.size() - 1; i++) {
String line = armorLore.get(i);
line = line.replace("{level}", armorLevel + "");
armorLore.set(i, line);
}
ItemStack armorItem = FactionsPlugin.getInstance().createItem(armorMaterial, armorAmt, armorData, armorName, armorLore);
armorItem.getItemMeta().setLore(armorLore);
if (armorLevel >= 1) {
ItemMeta itemMeta = armorItem.getItemMeta();
if (!FactionsPlugin.getInstance().mc17) {
itemMeta.addItemFlags(ItemFlag.HIDE_ENCHANTS);
}
itemMeta.addEnchant(Enchantment.DURABILITY, 3, true);
armorItem.setItemMeta(itemMeta);
armorItem.setAmount(armorLevel);
}
return new ItemStack[]{expItem, spawnerItem, cropItem, chestItem, powerItem, redItem, memberItem, reduceItem, increaseItem, tntItem, warpItem, armorItem};
}
private void updateTntBanks(Faction faction) {
int level = faction.getUpgrade(UpgradeType.TNT);
int size = FactionsPlugin.getInstance().getConfig().getInt("fupgrades.MainMenu.TNT.tnt-limit.level-" + (level));
faction.setTntBankLimit(size);
}
private void setWarpLimit(Faction faction) {
int level = faction.getUpgrade(UpgradeType.WARP);
int size = FactionsPlugin.getInstance().getConfig().getInt("fupgrades.MainMenu.Warps.warp-limit.level-" + (level));
faction.setWarpsLimit(size);
}
private boolean hasMoney(FPlayer fme, int amt) {
return fme.hasMoney(amt);
}
private boolean takeMoney(FPlayer fme, int amt) {
return fme.takeMoney(amt);
}
private boolean upgradeItem(FPlayer fme, UpgradeType upgrade, int level, int cost) {
if (hasMoney(fme, cost)) {
if (!takeMoney(fme, cost)) {return false;}
fme.getFaction().setUpgrade(upgrade, level);
fme.getPlayer().closeInventory();
return true;
}
return false;
}
}

View File

@@ -1,32 +1,103 @@
package com.massivecraft.factions.zcore.fupgrades; package com.massivecraft.factions.zcore.fupgrades;
import com.massivecraft.factions.Faction;
import com.massivecraft.factions.FactionsPlugin;
import com.massivecraft.factions.util.Placeholder;
import com.massivecraft.factions.util.XMaterial;
import com.mojang.authlib.GameProfile;
import com.mojang.authlib.properties.Property;
import org.bukkit.configuration.ConfigurationSection;
import org.bukkit.enchantments.Enchantment;
import org.bukkit.inventory.ItemFlag;
import org.bukkit.inventory.ItemStack;
import org.bukkit.inventory.meta.ItemMeta;
import org.bukkit.inventory.meta.SkullMeta;
import java.lang.reflect.Field;
import java.util.UUID;
public enum UpgradeType { public enum UpgradeType {
/** /**
* @author Illyria Team * @author Illyria Team
*/ */
CHEST("Chest"), CHEST("Chest", 3),
SPAWNER("Spawner"), SPAWNER("Spawners", 3),
EXP("Exp"), EXP("EXP", 3),
CROP("Crop"), CROP("Crops", 3),
POWER("Power"), POWER("Power", 3),
REDSTONE("Redstone"), REDSTONE("Redstone", 1),
MEMBERS("Members"), MEMBERS("Members", 3),
TNT("TNT"), TNT("TNT", 3),
WARP("Warps"), WARP("Warps", 3),
DAMAGEINCREASE("DamageIncrease"), DAMAGEINCREASE("DamageIncrease", 3),
DAMAGEDECREASE("DamageDecrease"), DAMAGEDECREASE("DamageReduct", 3),
REINFORCEDARMOR("ReinforcedArmor"); REINFORCEDARMOR("Armor", 3);
private String id; private String id;
private int maxLevel;
UpgradeType(String id) { UpgradeType(String id, int maxLevel) {
this.id = id; this.id = id;
this.maxLevel = maxLevel;
} }
@Override @Override
public String toString() { public String toString() {
return this.id; return this.id;
} }
public int getSlot() {
return FactionsPlugin.getInstance().getConfig().getInt("fupgrades.MainMenu." + this.id + ".DisplayItem.Slot");
}
public int getMaxLevel() {
return this.maxLevel;
}
public ItemStack buildAsset(Faction f) {
ConfigurationSection config = FactionsPlugin.getInstance().getConfig().getConfigurationSection("fupgrades.MainMenu." + this.id + ".DisplayItem");
ItemStack item = XMaterial.matchXMaterial(config.getString("Type")).get().parseItem();
int level = f.getUpgrade(this);
ItemMeta meta = item.getItemMeta();
if (meta != null) {
meta.setLore(FactionsPlugin.getInstance().colorList(FactionsPlugin.getInstance().replacePlaceholders(config.getStringList("Lore"), new Placeholder("{level}", level + ""))));
meta.setDisplayName(FactionsPlugin.getInstance().color(config.getString("Name")));
item.setItemMeta(meta);
if (XMaterial.matchXMaterial(item) == XMaterial.PLAYER_HEAD && config.isSet("Texture")) {
SkullMeta skullMeta = (SkullMeta) meta;
GameProfile profile = new GameProfile(UUID.randomUUID(), null);
profile.getProperties().put("textures", new Property("textures", config.getString("Texture")));
Field profileField;
try {
profileField = meta.getClass().getDeclaredField("profile");
profileField.setAccessible(true);
profileField.set(meta, profile);
} catch (IllegalAccessException | NoSuchFieldException | SecurityException | IllegalArgumentException e) {
e.printStackTrace();
}
item.setItemMeta(skullMeta);
}
}
return this.updateLevelStatus(item, level);
}
private ItemStack updateLevelStatus(ItemStack item, int level) {
if (level >= 1) {
item.setAmount(level);
enchant(item);
}
return item;
}
private ItemStack enchant(ItemStack item) {
ItemMeta itemMeta = item.getItemMeta();
if (itemMeta != null) {
itemMeta.addItemFlags(ItemFlag.HIDE_ENCHANTS);
itemMeta.addEnchant(Enchantment.DURABILITY, 1, true);
item.setItemMeta(itemMeta);
}
return item;
}
} }

View File

@@ -47,6 +47,7 @@ import java.util.*;
*/ */
public abstract class MemoryFPlayer implements FPlayer { public abstract class MemoryFPlayer implements FPlayer {
public boolean enemiesNearby = false;
public boolean inChest = false; public boolean inChest = false;
public boolean discordSetup = false; public boolean discordSetup = false;
public String discordUserID = ""; public String discordUserID = "";
@@ -221,6 +222,10 @@ public abstract class MemoryFPlayer implements FPlayer {
return this.notificationsEnabled; return this.notificationsEnabled;
} }
public boolean hasEnemiesNearby() {return this.enemiesNearby;}
public void setEnemiesNearby(Boolean b) {this.enemiesNearby = b;}
public boolean discordSetup() {return this.discordSetup;} public boolean discordSetup() {return this.discordSetup;}
public String discordUserID() {return this.discordUserID;} public String discordUserID() {return this.discordUserID;}
@@ -972,7 +977,7 @@ public abstract class MemoryFPlayer implements FPlayer {
public boolean canFlyAtLocation(FLocation location) { public boolean canFlyAtLocation(FLocation location) {
Faction faction = Board.getInstance().getFactionAt(location); Faction faction = Board.getInstance().getFactionAt(location);
if ((faction == getFaction() && getRole() == Role.LEADER) || isAdminBypassing) return true; if ((faction == getFaction() && getRole() == Role.LEADER) || isAdminBypassing) return true;
if (faction.isSystemFaction()) return CmdFly.checkBypassPerms(this, getPlayer(), faction); if (faction.isSystemFaction()) return CmdFly.checkFly(this, getPlayer(), faction);
Access access = faction.getAccess(this, PermissableAction.FLY); Access access = faction.getAccess(this, PermissableAction.FLY);
return access == null || access == Access.UNDEFINED || access == Access.ALLOW; return access == null || access == Access.UNDEFINED || access == Access.ALLOW;
} }
@@ -1108,16 +1113,18 @@ public abstract class MemoryFPlayer implements FPlayer {
setFlying(false); setFlying(false);
msg(TL.COMMAND_FLY_ENEMY_NEAR); msg(TL.COMMAND_FLY_ENEMY_NEAR);
Bukkit.getServer().getPluginManager().callEvent(new FPlayerStoppedFlying(this)); Bukkit.getServer().getPluginManager().callEvent(new FPlayerStoppedFlying(this));
this.enemiesNearby = true;
return true; return true;
} }
} }
} }
this.enemiesNearby = false;
return false; return false;
} }
@Override @Override
public Boolean canflyinWilderness() { public Boolean canflyinWilderness() {
return getPlayer().hasPermission(Permission.FLY_WILD.node); return getPlayer().hasPermission(Permission.FLY_WILDERNESS.node);
} }
@Override @Override

View File

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

View File

@@ -147,16 +147,16 @@ scoreboard:
# {maxPower} - player's max power. # {maxPower} - player's max power.
# {powerBoost} - player's powerboost. # {powerBoost} - player's powerboost.
default-enabled: false # Default to false to keep original functionality. ######################################################
##################### SCOREBOARD #####################
######################################################
default-enabled: false # This is to enable or disable the scoreboard: false = Disabled
default-title: "&cSaberFactions" # Can use any of the values from above but this won't update once it's set (so don't set {balance}). default-title: "&cSaberFactions" # Can use any of the values from above but this won't update once it's set (so don't set {balance}).
default-update-interval: 2 # in seconds. default-update-interval: 2 # in seconds.
# This will show faction prefixes colored based on relation on nametags and in the tab. # This will show faction prefixes colored based on relation on nametags and in the tab.
# The scoreboard needs to be enabled for this to work. # The scoreboard needs to be enabled for this to work.
default-prefixes: true default-prefixes: true
# SUPPORTS PLACEHOLDERS # SUPPORTS PLACEHOLDERS
default: default:
- "&7&m--------------------------" - "&7&m--------------------------"
- "&4&lFaction Info &8»" - "&4&lFaction Info &8»"
@@ -185,6 +185,7 @@ scoreboard:
- "&7&m---------------------------" - "&7&m---------------------------"
# Configration section for warmups. # Configration section for warmups.
# Warmup times are in seconds - if a value of 0 is set, there is no warmup. # Warmup times are in seconds - if a value of 0 is set, there is no warmup.
warmups: warmups:
@@ -275,19 +276,19 @@ hcf:
show: show:
# First line can be {header} for default header, or any string (we recommend &m for smooth lines ;plugin) # 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--------------' - '&8&m--------------&7 &8<&e{faction}&8> &8&m--------------'
- '&4&l* &cOwner: &f{leader}' - '&4* &cOwner: &f{leader}'
- '&4&l* &cDescription: &f{description}' - '&4* &cDescription: &f{description}'
- '&4&l* &cLand / Power / Max Power: &f{chunks} &8/ &f{power} &8/ &f{maxPower}' - '&4* &cLand / Power / Max Power: &f{chunks} &8/ &f{power} &8/ &f{maxPower}'
- '&4&l* &cFaction Strikes: &f{strikes}' - '&4* &cFaction Strikes: &f{strikes}'
- '&4&l* &cFaction Points: &f{faction-points}' - '&4* &cFaction Points: &f{faction-points}'
- '&4&l* &cFounded: &f{create-date}' - '&4* &cFounded: &f{create-date}'
- '&4&l* &cBalance: &f{faction-balance}' - '&4* &cBalance: &f{faction-balance}'
- '&4&l* &cAllies: &a{allies-list}' - '&4* &cAllies: &a{allies-list}'
- '&4&l* &cEnemies: &4{enemies-list}' - '&4* &cEnemies: &4{enemies-list}'
- '&4&l* &cOnline Members: &8[&f{online}/{members}&8] &a{online-list}' - '&4* &cOnline Members: &8[&f{online}/{members}&8] &a{online-list}'
- '&4&l* &cOffline Members: &8[&f{offline}/{members}&8] &a{offline-list}' - '&4* &cOffline Members: &8[&f{offline}/{members}&8] &a{offline-list}'
- '&4&l* &cAlts: &f{alts}' - '&4* &cAlts: &f{alts}'
- '&4&l* &cBans: &f{faction-bancount}' - '&4* &cBans: &f{faction-bancount}'
- '&8&m----------------------------------------' - '&8&m----------------------------------------'
# For a /f show that does not display fancy messages that are essentially empty, use minimal-show # For a /f show that does not display fancy messages that are essentially empty, use minimal-show
minimal-show: false minimal-show: false
@@ -650,6 +651,7 @@ frules:
- '&f' - '&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 ))' - '&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 | # # | Faction TNT Bank | #
@@ -707,6 +709,7 @@ F-Shop:
Name: '&cFaction Points: &b{points}' Name: '&cFaction Points: &b{points}'
Lore: Lore:
- ' ' - ' '
############################################################ ############################################################
# +------------------------------------------------------+ # # +------------------------------------------------------+ #
# | Faction Command Cooldowns | # # | Faction Command Cooldowns | #
@@ -729,6 +732,27 @@ fcooldowns:
Falling-Block-Fix: Falling-Block-Fix:
enabled: true 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 | # # | Faction GracePeriod | #
@@ -900,9 +924,9 @@ fchest:
fupgrades: fupgrades:
Enabled: true Enabled: true
MainMenu: MainMenu:
Rows: 5
Title: '&8&l{faction}''s Upgrade Menu' Title: '&8&l{faction}''s Upgrade Menu'
DummyItem: DummyItem:
rows: 5
Name: '&f' Name: '&f'
Type: BLACK_STAINED_GLASS_PANE Type: BLACK_STAINED_GLASS_PANE
Lore: Lore:
@@ -916,11 +940,10 @@ fupgrades:
level-1: 250000 level-1: 250000
level-2: 500000 level-2: 500000
level-3: 750000 level-3: 750000
CropItem: DisplayItem:
Name: '&c&lGrowth Speed' Name: '&c&lGrowth Speed'
Type: WHEAT Type: WHEAT #MUST BE PLAYER_HEAD FOR TEXTURE TO WORK!
Amount: 1 Texture: '' #Hash of skull here from minecraft-heads.com
Damage: 0
Lore: Lore:
- '&7&oIncrease growth &c&ospeed&7&o of crops in &c&oclaims.' - '&7&oIncrease growth &c&ospeed&7&o of crops in &c&oclaims.'
- '&7&oChance to Grow Two Levels.' - '&7&oChance to Grow Two Levels.'
@@ -937,8 +960,7 @@ fupgrades:
- '&4&l* &cLevel 3: &f$750,000' - '&4&l* &cLevel 3: &f$750,000'
- '' - ''
- '&7&o(( Tip: &f&oleft-click&7&o to &c&oupgrade&7&o ))' - '&7&o(( Tip: &f&oleft-click&7&o to &c&oupgrade&7&o ))'
slots: Slot: 31
- 31
EXP: EXP:
EXP-Boost: EXP-Boost:
level-1: 1.5 level-1: 1.5
@@ -948,11 +970,10 @@ fupgrades:
level-1: 2000000 level-1: 2000000
level-2: 4000000 level-2: 4000000
level-3: 6000000 level-3: 6000000
EXPItem: DisplayItem:
Name: '&c&lEXP Drop Rate' Name: '&c&lEXP Drop Rate'
Type: EXP_BOTTLE Type: EXP_BOTTLE #MUST BE PLAYER_HEAD FOR TEXTURE TO WORK!
Amount: 1 Texture: '' #Hash of skull here from minecraft-heads.com
Damage: 0
Lore: Lore:
- '&7&oIncreased Vanilla &e&oEXP&7&o gained from &c&omonsters&7&o.' - '&7&oIncreased Vanilla &e&oEXP&7&o gained from &c&omonsters&7&o.'
- '&7&oYour current level is &e&l&o{level}' - '&7&oYour current level is &e&l&o{level}'
@@ -968,8 +989,7 @@ fupgrades:
- '&4&l* &cLevel 3: &f$6,000,000' - '&4&l* &cLevel 3: &f$6,000,000'
- '' - ''
- '&7&o(( Tip: &f&oleft-click&7&o to &c&oupgrade&7&o ))' - '&7&o(( Tip: &f&oleft-click&7&o to &c&oupgrade&7&o ))'
slots: Slot: 32
- 32
Power: Power:
Power-Boost: Power-Boost:
level-1: 100.0 level-1: 100.0
@@ -979,11 +999,10 @@ fupgrades:
level-1: 1000000 level-1: 1000000
level-2: 2000000 level-2: 2000000
level-3: 3000000 level-3: 3000000
PowerItem: DisplayItem:
Name: '&c&lFaction Power' Name: '&c&lFaction Power'
Type: NETHER_STAR Type: NETHER_STAR #MUST BE PLAYER_HEAD FOR TEXTURE TO WORK!
Amount: 1 Texture: '' #Hash of skull here from minecraft-heads.com
Damage: 0
Lore: Lore:
- '&a&oIncrease&7&o the amount of &c&opower' - '&a&oIncrease&7&o the amount of &c&opower'
- '&7&oyour &a&ofaction has&7&o.' - '&7&oyour &a&ofaction has&7&o.'
@@ -1000,15 +1019,14 @@ fupgrades:
- '&4&l* &cLevel 3: &f$3,000,000' - '&4&l* &cLevel 3: &f$3,000,000'
- '' - ''
- '&7&o(( Tip: &f&oleft-click&7&o to &c&oupgrade&7&o ))' - '&7&o(( Tip: &f&oleft-click&7&o to &c&oupgrade&7&o ))'
slots: Slot: 22
- 22
Redstone: Redstone:
Cost: 1000000 Cost:
RedstoneItem: level-1: 1000000
DisplayItem:
Name: '&c&lUnbreakable Redstone' Name: '&c&lUnbreakable Redstone'
Type: REDSTONE Type: REDSTONE #MUST BE PLAYER_HEAD FOR TEXTURE TO WORK!
Amount: 1 Texture: '' #Hash of skull here from minecraft-heads.com
Damage: 0
Lore: Lore:
- '&7&oPrevents &e&owater&7&o from being' - '&7&oPrevents &e&owater&7&o from being'
- '&7&oable to break &c&oredstone' - '&7&oable to break &c&oredstone'
@@ -1016,8 +1034,7 @@ fupgrades:
- '&4&l* &cCost: &f$1,000,000' - '&4&l* &cCost: &f$1,000,000'
- '' - ''
- '&7&o(( Tip: &f&oLeft-click&7&o to &c&oupgrade&7&o ))' - '&7&o(( Tip: &f&oLeft-click&7&o to &c&oupgrade&7&o ))'
slots: Slot: 23
- 23
Spawners: Spawners:
Spawner-Boost: Spawner-Boost:
# This is a Percentage so .10 means 10% lowered spawner delay! # This is a Percentage so .10 means 10% lowered spawner delay!
@@ -1028,11 +1045,10 @@ fupgrades:
level-1: 1000000 level-1: 1000000
level-2: 2000000 level-2: 2000000
level-3: 3000000 level-3: 3000000
SpawnerItem: DisplayItem:
Name: '&c&lSpawn Rate' Name: '&c&lSpawn Rate'
Type: MOB_SPAWNER Type: MOB_SPAWNER #MUST BE PLAYER_HEAD FOR TEXTURE TO WORK!
Amount: 1 Texture: '' #Hash of skull here from minecraft-heads.com
Damage: 0
Lore: Lore:
- '&c&oDecreased&7&o mob spawner delay in &a&oclaims&7&o.' - '&c&oDecreased&7&o mob spawner delay in &a&oclaims&7&o.'
- '&7&oYour current level is &e&l&o{level}' - '&7&oYour current level is &e&l&o{level}'
@@ -1048,8 +1064,7 @@ fupgrades:
- '&4&l* &cLevel 3: &f$3,000,000' - '&4&l* &cLevel 3: &f$3,000,000'
- '' - ''
- '&7&o(( Tip: &f&oleft-click&7&o to &c&oupgrade&7&o ))' - '&7&o(( Tip: &f&oleft-click&7&o to &c&oupgrade&7&o ))'
slots: Slot: 30
- 30
DamageReduct: DamageReduct:
DamageReductPercent: DamageReductPercent:
level-1: 3 level-1: 3
@@ -1059,11 +1074,10 @@ fupgrades:
level-1: 2000000 level-1: 2000000
level-2: 4000000 level-2: 4000000
level-3: 6000000 level-3: 6000000
ReduceItem: DisplayItem:
Name: '&c&lDamage Reduction' Name: '&c&lDamage Reduction'
Type: GOLD_CHESTPLATE Type: GOLD_CHESTPLATE #MUST BE PLAYER_HEAD FOR TEXTURE TO WORK!
Amount: 1 Texture: '' #Hash of skull here from minecraft-heads.com
Damage: 0
Lore: Lore:
- '&a&oReduce&7&o the amount of &a&odamage taken&7&o in faction claims.' - '&a&oReduce&7&o the amount of &a&odamage taken&7&o in faction claims.'
- '&7&oYour current level is &e&l&o{level}' - '&7&oYour current level is &e&l&o{level}'
@@ -1079,8 +1093,7 @@ fupgrades:
- '&4&l* &cLevel 3: &f$6,000,000' - '&4&l* &cLevel 3: &f$6,000,000'
- '' - ''
- '&7&o(( Tip: &f&oleft-click&7&o to &c&oupgrade&7&o ))' - '&7&o(( Tip: &f&oleft-click&7&o to &c&oupgrade&7&o ))'
slots: Slot: 7
- 7
DamageIncrease: DamageIncrease:
DamageIncreasePercent: DamageIncreasePercent:
level-1: 3 level-1: 3
@@ -1090,11 +1103,10 @@ fupgrades:
level-1: 2000000 level-1: 2000000
level-2: 4000000 level-2: 4000000
level-3: 6000000 level-3: 6000000
IncreaseItem: DisplayItem:
Name: '&c&lDamage Increase' Name: '&c&lDamage Increase'
Type: DIAMOND_SWORD Type: DIAMOND_SWORD #MUST BE PLAYER_HEAD FOR TEXTURE TO WORK!
Amount: 1 Texture: '' #Hash of skull here from minecraft-heads.com
Damage: 0
Lore: Lore:
- '&a&oIncrease&7&o the amount of &a&odamage given&7&o.' - '&a&oIncrease&7&o the amount of &a&odamage given&7&o.'
- '&7&oYour current level is &e&l&o{level}' - '&7&oYour current level is &e&l&o{level}'
@@ -1110,8 +1122,7 @@ fupgrades:
- '&4&l* &cLevel 3: &f$6,000,000' - '&4&l* &cLevel 3: &f$6,000,000'
- '' - ''
- '&7&o(( Tip: &f&oleft-click&7&o to &c&oupgrade&7&o ))' - '&7&o(( Tip: &f&oleft-click&7&o to &c&oupgrade&7&o ))'
slots: Slot: 1
- 1
TNT: TNT:
tnt-limit: tnt-limit:
level-1: 500000 level-1: 500000
@@ -1121,11 +1132,10 @@ fupgrades:
level-1: 2000000 level-1: 2000000
level-2: 4000000 level-2: 4000000
level-3: 6000000 level-3: 6000000
TntItem: DisplayItem:
Name: '&c&lTNT Bank' Name: '&c&lTNT Bank'
Type: TNT Type: TNT #MUST BE PLAYER_HEAD FOR TEXTURE TO WORK!
Amount: 1 Texture: '' #Hash of skull here from minecraft-heads.com
Damage: 0
Lore: Lore:
- '&a&oUpgrade&7&o your &a&ofactions tnt&7&o limit.' - '&a&oUpgrade&7&o your &a&ofactions tnt&7&o limit.'
- '&7&oYour current level is &e&l&o{level}' - '&7&oYour current level is &e&l&o{level}'
@@ -1141,8 +1151,7 @@ fupgrades:
- '&4&l* &cLevel 3: &f$3,000,000' - '&4&l* &cLevel 3: &f$3,000,000'
- '' - ''
- '&7&o(( Tip: &f&oleft-click&7&o to &c&oupgrade&7&o ))' - '&7&o(( Tip: &f&oleft-click&7&o to &c&oupgrade&7&o ))'
slots: Slot: 21
- 21
Warps: Warps:
warp-limit: warp-limit:
level-1: 3 level-1: 3
@@ -1152,11 +1161,10 @@ fupgrades:
level-1: 1000000 level-1: 1000000
level-2: 2000000 level-2: 2000000
level-3: 3000000 level-3: 3000000
WarpItem: DisplayItem:
Name: '&c&lWarps' Name: '&c&lWarps'
Type: EYE_OF_ENDER Type: EYE_OF_ENDER #MUST BE PLAYER_HEAD FOR TEXTURE TO WORK!
Amount: 1 Texture: '' #Hash of skull here from minecraft-heads.com
Damage: 0
Lore: Lore:
- '&a&oIncrease&7&o the &a&ofaction warp&7&o limit.' - '&a&oIncrease&7&o the &a&ofaction warp&7&o limit.'
- '&7&oYour current level is &e&l&o{level}' - '&7&oYour current level is &e&l&o{level}'
@@ -1172,8 +1180,7 @@ fupgrades:
- '&4&l* &cLevel 3: &f$3,000,000' - '&4&l* &cLevel 3: &f$3,000,000'
- '' - ''
- '&7&o(( Tip: &f&oleft-click&7&o to &c&oupgrade&7&o ))' - '&7&o(( Tip: &f&oleft-click&7&o to &c&oupgrade&7&o ))'
slots: Slot: 24
- 24
Chest: Chest:
Chest-Size: Chest-Size:
# This is rows # This is rows
@@ -1184,11 +1191,10 @@ fupgrades:
level-1: 1000000 level-1: 1000000
level-2: 2000000 level-2: 2000000
level-3: 3000000 level-3: 3000000
ChestItem: DisplayItem:
Name: '&c&lFaction Chest' Name: '&c&lFaction Chest'
Type: CHEST Type: CHEST #MUST BE PLAYER_HEAD FOR TEXTURE TO WORK!
Amount: 1 Texture: '' #Hash of skull here from minecraft-heads.com
Damage: 0
Lore: Lore:
- '&a&oIncreased&7&o Faction Chest Size.' - '&a&oIncreased&7&o Faction Chest Size.'
- '&7&oYour current level is &e&l&o{level}' - '&7&oYour current level is &e&l&o{level}'
@@ -1204,8 +1210,7 @@ fupgrades:
- '&4&l* &cLevel 3: &f$3,000,000' - '&4&l* &cLevel 3: &f$3,000,000'
- '' - ''
- '&7&o(( Tip: &f&oleft-click&7&o to &c&oupgrade&7&o ))' - '&7&o(( Tip: &f&oleft-click&7&o to &c&oupgrade&7&o ))'
slots: Slot: 20
- 20
Members: Members:
Members-Limit: Members-Limit:
level-1: 30 level-1: 30
@@ -1215,11 +1220,10 @@ fupgrades:
level-1: 1000000 level-1: 1000000
level-2: 2000000 level-2: 2000000
level-3: 3000000 level-3: 3000000
MembersItem: DisplayItem:
Name: '&c&lFaction Members' Name: '&c&lFaction Members'
Type: PAPER Type: PAPER #MUST BE PLAYER_HEAD FOR TEXTURE TO WORK!
Amount: 1 Texture: '' #Hash of skull here from minecraft-heads.com
Damage: 0
Lore: Lore:
- '&a&oIncrease&7&o the &a&ofaction member&7&o limit.' - '&a&oIncrease&7&o the &a&ofaction member&7&o limit.'
- '&7&oYour current level is &e&l&o{level}' - '&7&oYour current level is &e&l&o{level}'
@@ -1235,8 +1239,7 @@ fupgrades:
- '&4&l* &cLevel 3: &f$3,000,000' - '&4&l* &cLevel 3: &f$3,000,000'
- '' - ''
- '&7&o(( Tip: &f&oleft-click&7&o to &c&oupgrade&7&o ))' - '&7&o(( Tip: &f&oleft-click&7&o to &c&oupgrade&7&o ))'
slots: Slot: 40
- 40
Armor: Armor:
Armor-HP-Drop: Armor-HP-Drop:
# HP Drop is in percent so .10 would mean it would drop 10% of the damage to the armor # HP Drop is in percent so .10 would mean it would drop 10% of the damage to the armor
@@ -1247,11 +1250,10 @@ fupgrades:
level-1: 1000000 level-1: 1000000
level-2: 2000000 level-2: 2000000
level-3: 3000000 level-3: 3000000
ArmorItem: DisplayItem:
Name: '&c&lReinforced Armor' Name: '&c&lReinforced Armor'
Type: DIAMOND_CHESTPLATE Type: DIAMOND_CHESTPLATE #MUST BE PLAYER_HEAD FOR TEXTURE TO WORK!
Amount: 1 Texture: '' #Hash of skull here from minecraft-heads.com
Damage: 0
Lore: Lore:
- '&a&oDecreases&7&o damage done &a&oto armor&7&o.' - '&a&oDecreases&7&o damage done &a&oto armor&7&o.'
- '&7&oYour current level is &e&l&o{level}' - '&7&oYour current level is &e&l&o{level}'
@@ -1267,8 +1269,7 @@ fupgrades:
- '&4&l* &cLevel 3: &f$3,000,000' - '&4&l* &cLevel 3: &f$3,000,000'
- '' - ''
- '&7&o(( Tip: &f&oleft-click&7&o to &c&oupgrade&7&o ))' - '&7&o(( Tip: &f&oleft-click&7&o to &c&oupgrade&7&o ))'
slots: Slot: 4
- 4
############################################################ ############################################################
# +------------------------------------------------------+ # # +------------------------------------------------------+ #