Compare commits

..

124 Commits

Author SHA1 Message Date
46829a60db Add renovate.json 2025-03-22 23:13:35 +00:00
Lorenzo Dellacà
5d3fe2a2f4 Merge branch '1.6.x' of https://github.com/SaberLLC/Saber-Factions into 1.6.x 2020-07-01 22:37:14 +02:00
DroppingAnvil
1becd7b299 Version change 2020-06-26 00:49:54 -05:00
DroppingAnvil
f7c9de0664 Version change 2020-06-26 00:45:37 -05:00
DroppingAnvil
7667e69cf2 Update XMaterial 2020-06-26 00:43:26 -05:00
Lorenzo Dellacà
1383e451f1 optimized dependencies for JAR file size (8.6MB -> 7.8MB) 2020-06-25 23:24:39 +02:00
DroppingAnvil
677c609ec8 Merge remote-tracking branch 'origin/1.6.x' into 1.6.x 2020-06-25 13:24:13 -05:00
DroppingAnvil
09f1df49a9 Begin 1.16 support 2020-06-25 13:23:52 -05:00
Driftay
dd94b45347 Forgot about the FactionsPlayerListener 2020-06-19 11:18:11 -04:00
Driftay
28b07fc6a4 Updates To Scoreboard 2020-06-19 11:15:22 -04:00
DroppingAnvil
11ea9bc1aa Allow non-relational show 2020-06-16 11:59:45 -05:00
DroppingAnvil
7f922fef28 Merge remote-tracking branch 'origin/1.6.x' into 1.6.x 2020-06-14 16:02:45 -05:00
DroppingAnvil
81ef43768d Fix startup error that may happen when factions is shutdown improperly 2020-06-14 16:02:18 -05:00
Driftay
1a19ee77ba Merge pull request #138 from f0rb1d/1.6.x
Added Simplified Chinese translation and fixed a typo in English language pack
2020-06-12 23:27:35 -04:00
DroppingAnvil
0444517eec F unclaim can now be used without a faction when bypassing 2020-06-12 18:43:56 -05:00
f0rb1d
03077b62ba Added Simplified Chinese translation and fixed a typo in English language pack. 2020-06-12 01:22:36 -04:00
DroppingAnvil
d98c647397 Version change for shield removal 2020-06-08 16:04:03 -04:00
DroppingAnvil
e9923344a2 Deal with remaining shield code 2020-06-08 16:03:28 -04:00
DroppingAnvil
cdc07ed5eb Revert "Merge pull request #134 from ImCarib/1.6.x"
This reverts commit 0b677cb4de, reversing
changes made to a355b1d0c8.
2020-06-08 15:52:29 -04:00
Driftay
7b94367eb4 Added shield status placeholder 2020-06-08 15:03:36 -04:00
Driftay
b7d991c0dd unclaim fly fix 2020-06-08 07:06:16 -04:00
Driftay
6372245fcd Version Change 2020-06-08 06:42:51 -04:00
Driftay
f2c0f725b7 Carib unregistered the command 2020-06-08 05:46:25 -04:00
Driftay
0b677cb4de Merge pull request #134 from ImCarib/1.6.x
shields added
2020-06-08 05:39:38 -04:00
ImCarib
e8642a3108 shields added 2020-06-08 05:22:50 -04:00
DroppingAnvil
a355b1d0c8 Fix certain GUIs not loading 2020-06-07 20:34:42 -04:00
Driftay
929c34d850 Final Touches on PermissableAction Rollback 2020-06-01 22:52:03 -04:00
Driftay
903129e462 Reverted Back To Old FactionsBlockListener to Reference Other Plugins Hook Systems 2020-06-01 22:41:14 -04:00
Driftay
e84c69f2b0 Code Cleanup & Fix With Fly Unclaiming 2020-05-27 23:40:46 -04:00
Driftay
3e530487d7 Merge pull request #131 from SaberLLC/beta
Beta
2020-05-25 20:40:22 -04:00
Driftay
14776b8877 Merge pull request #127 from Juniormunk/1.6.x
Fix Bugs
2020-05-25 20:38:35 -04:00
Driftay
7f927189ea Alts Can No Longer Be Promoted 2020-05-25 14:16:49 -04:00
Driftay
6f293dce17 Fixed Kicked Player Staying In Fly Map & FPerms GUI Returning Only Black Stained Glass Pane 2020-05-24 09:35:10 -04:00
Driftay
2676f048d6 Alt Limit Fix 2020-05-24 05:58:35 -04:00
droppinganvil
24aaa0ed6f Merge remote-tracking branch 'origin/1.6.x' into 1.6.x 2020-05-23 13:36:04 -05:00
DroppingAnvil
2a01682fbe Fix issue not allowing use of multiworld wild 2020-05-23 13:35:51 -05:00
Juniormunk
ba59310548 Fix occasional dynmap bug 2020-05-22 17:11:53 -04:00
Juniormunk
bec09168b6 Remove debugging prints 2020-05-22 02:33:31 -04:00
Juniormunk
4fe6484db9 Fix bug #129 2020-05-22 02:24:57 -04:00
Juniormunk
71a099beeb Fix bugs #123, #128 2020-05-21 19:29:51 -04:00
Juniormunk
ddd3150732 Fix bugs #118 , #122 2020-05-21 04:22:53 -04:00
Juniormunk
ec1501bf4f Fix Bug #125 2020-05-21 02:51:41 -04:00
Juniormunk
8ad2fdf848 Fix Bug #126 2020-05-21 01:58:05 -04:00
Driftay
1ee62c2267 Merge pull request #121 from SaberLLC/beta
Beta
2020-05-19 13:48:00 -04:00
Driftay
7e6646b4df Config Fix for default worlds 2020-05-19 06:28:05 -04:00
Driftay
0d08ff4cec Wild Updates 2020-05-19 06:27:20 -04:00
Driftay
cf3ce62023 Merge pull request #120 from SaberLLC/1.6.x
Merging
2020-05-19 06:25:42 -04:00
Driftay
30d6b3c248 Merge pull request #119 from SaberLLC/beta
F Show Async Calling
2020-05-19 06:24:02 -04:00
Driftay
c22e3a5227 F Show Async Calling 2020-05-19 06:22:09 -04:00
Driftay
cf71603eeb Merge pull request #117 from SaberLLC/beta
Beta
2020-05-18 04:31:06 -04:00
Driftay
c45b68a95f Merge pull request #116 from Aeris1One/patch-1
Fix
2020-05-18 04:29:42 -04:00
Aeris One
67a9a6db28 Update ja_JP.yml 2020-05-16 12:07:53 +02:00
DroppingAnvil
0ea56fe5d2 World now per range instead of global + CmdWild cleanup 2020-05-12 14:41:12 -05:00
DroppingAnvil
7d3c4d6e33 Merge pull request #115 from Stefan923/1.6.x
Fixed a JSON issue.
2020-05-11 16:47:08 -05:00
Stefan923
4d05b4a376 Fixed "RESET is not a style/color" error. 2020-05-10 17:18:48 +03:00
Driftay
c29850eaaa Fixes NPE on Saving Task onDisable MPlugin, removed Async Throw for 1.15 in F Show 2020-05-09 14:04:17 -04:00
Driftay
ece5dd0bb7 Merge pull request #113 from Stefan923/1.6.x
Fixed issues
2020-05-09 14:01:55 -04:00
Driftay
bbaee8ab06 Merge pull request #114 from Stefan923/1.6.x
Fixed issues
2020-05-09 13:39:51 -04:00
Stefan923
c42949ec59 Fixed a bug: people were able to move banned items in /f chest by using hotbar keys. 2020-05-09 17:37:06 +03:00
Stefan923
f5f8e6aad2 Edited some translation messages. 2020-05-09 16:22:16 +03:00
Stefan923
447bfedbb1 Fixed an internal error caused by some unhandled cases. 2020-05-09 15:51:14 +03:00
Stefan923
1d4a1c2a1a Avoid disabling player's flight mode if it's not enabled. 2020-05-09 14:53:53 +03:00
Stefan923
31b8f0be25 Fixed internal error caused by trying to demote a player who already has the lowest rank 2020-05-09 14:53:02 +03:00
Driftay
e2d85d83f3 Merge pull request #111 from Stefan923/1.6.x
Fixed AutoFly issue
2020-05-08 20:22:33 -04:00
Driftay
66f2fd22f6 Merge pull request #112 from SaberLLC/beta
Beta
2020-05-08 20:21:55 -04:00
Stefan923
842eb097c6 Fixed issue. If the player does not have the fly activated when he joins another teritory, it skips the checks and his flight is activated. 2020-05-09 00:30:03 +03:00
DroppingAnvil
2f18da3cfb Merge pull request #110 from Stefan923/1.6.x
Fixed issues
2020-05-08 15:57:02 -05:00
Stefan923
5fb8d06d98 Fixed the asynchronous command dispatch issue. The issue was being thrown on PaperSpigot and its forks. 2020-05-08 20:29:54 +03:00
Stefan923
868e7f4102 Method weren't formatting both color and style to the same text. 2020-05-08 20:27:03 +03:00
Popescu Ștefan
d8b08ef6d7 Merge pull request #1 from SaberLLC/beta
Beta
2020-05-07 23:06:20 +03:00
DroppingAnvil
7bffed2d34 Merge pull request #108 from Stefan923/1.6.x
Fixed an issue with disband GUI
2020-05-07 14:44:15 -05:00
BrowkS
541e1fc69b Fixed issue - ignoring "useDisbandGui" if the player is not an OP 2020-05-07 22:36:39 +03:00
Driftay
07dce634af Addressed Config Properly 2020-05-07 12:23:32 -04:00
Driftay
75faaa4bb5 More Radius Claiming Changes 2020-05-07 07:07:40 -04:00
Driftay
17e2a86717 Cleaned Up Double Message With Fly & Double Message With Radius Claim System When Claiming A Single Claim 2020-05-07 05:56:12 -04:00
Driftay
f384100925 Fixed Small Issue With Owner List In Replacement Of TL Translation 2020-05-07 05:26:08 -04:00
Driftay
b8c695c2f4 Grace Check in checkForExplosion Method & Added a Async Task On Show.
NOTE: Ran 100 Alts Running /f who every second whilst all being in my faction with 0 lag or errors with LuckPerms
2020-05-07 05:11:28 -04:00
Driftay
78a5e65e5c Merge pull request #106 from Stefan923/1.6.x
Fixed some internal errors caused by using /f wild and a placeholder issue
2020-05-07 01:57:05 -04:00
Driftay
33761fee2b Radius Claiming Finalized, Few Fixes With Econ & Essentials & Fly Performance 2020-05-07 01:55:24 -04:00
BrowkS
bf23521309 Sending join message to faction members after setting player's faction and role. 2020-05-06 22:32:40 +03:00
BrowkS
55fd5ffdfd Added {player-role} placeholder. 2020-05-06 13:07:16 +03:00
BrowkS
04273de995 Removed an unnecessary check 2020-05-06 12:36:24 +03:00
Stefan923
7fc1ad19ad Fixed an internal error. Trying to send a message without enough arguments. 2020-05-05 18:32:50 +03:00
Stefan923
01913e7286 Fixed an internal error. Player wasn't being removed from teleportRange after a failed teleportation. 2020-05-05 18:30:09 +03:00
Driftay
ae7bb670d7 Reverted Back To Old Fly Mechanics 2020-05-05 07:20:06 -04:00
Driftay
499d41dea0 Radius Claiming & Alt Limit Fix 2020-05-04 20:27:39 -04:00
DroppingAnvil
e0d2e6b4db Version change for fly changes 2020-04-30 14:40:59 -05:00
DroppingAnvil
e37745eff9 Fixed a few known issues with F Fly 2020-04-30 14:27:26 -05:00
DroppingAnvil
86cba0e24c PlaceholderAPI expansion revamp 2020-04-29 16:31:47 -05:00
droppinganvil
69a4651e23 Merge remote-tracking branch 'origin/1.6.x' into 1.6.x 2020-04-26 12:54:03 -05:00
DroppingAnvil
f2c6d0b9da Even more fly changes 2020-04-26 12:53:48 -05:00
Driftay
8f343a5344 FIXED MASSIVE BUG WITH SAVING 2020-04-21 21:39:28 -04:00
Driftay
8665d92476 FIXED MASSIVE BUG WITH SAVING 2020-04-21 20:25:44 -04:00
droppinganvil
b89db7b082 Merge remote-tracking branch 'origin/1.6.x' into 1.6.x 2020-04-21 16:04:39 -05:00
DroppingAnvil
00cb78fd9b Set a world for /f wild 2020-04-21 16:04:18 -05:00
Driftay
aca075b5c7 Version Change 2020-04-13 20:30:02 -04:00
Driftay
03886aa84e Merge pull request #92 from CanardConfit/1.6.x
Fix issue #84
2020-04-13 20:26:17 -04:00
CanardConfit
22472f63f1 Merge remote-tracking branch 'origin/1.6.x' into 1.6.x 2020-04-14 01:05:17 +02:00
CanardConfit
6d72e5d167 Fix issue #84 2020-04-14 01:04:33 +02:00
CanardConfit
69765e472c Fix issue #84 2020-04-14 01:01:05 +02:00
Driftay
4f55b10c7d Fixed Faction Claiming Over Themselves 2020-04-13 18:44:17 -04:00
Driftay
0395280a9e Addressed Issue #72 2020-04-13 16:12:46 -04:00
Driftay
d1252df3ba Addressed Issue: 70 Some Blocks may be missing, but they are 100% configurable in conf.json I don't want to hardcode item names that people want to block by default. ex: crafting tables 2020-04-13 15:28:37 -04:00
Driftay
9707226762 Addressed Issue: #90 & Added Configurable removePlayerDataWhenBanned message 2020-04-13 15:20:46 -04:00
Driftay
cf075c270e Addressed Issue: #81 2020-04-13 13:35:27 -04:00
Driftay
f088b42bbe Added uneeded comment 2020-04-13 13:29:01 -04:00
Driftay
baee5d2158 Addressed Issue: #77 & #68 2020-04-13 13:24:30 -04:00
Driftay
f871787b0c Merge remote-tracking branch 'origin/1.6.x' into 1.6.x 2020-04-13 13:18:27 -04:00
Driftay
749fca0690 Merge pull request #91 from CanardConfit/1.6.x
Fix Issue #75
2020-04-13 13:17:59 -04:00
CanardConfit
319940d9b3 Fix Issue #75 2020-04-13 19:12:11 +02:00
Driftay
7ea81a6c10 Addressed Issue: https://github.com/SaberLLC/Saber-Factions/issues/69 2020-04-13 13:09:15 -04:00
Driftay
6205bbca9f Added a bunch of fixes from github requests 2020-04-13 05:03:41 -04:00
Driftay
241a16bc2a Merge remote-tracking branch 'origin/1.6.x' into 1.6.x 2020-04-12 06:26:45 -04:00
Driftay
3aa98121e5 Factions Fly Cache on Startup, Attempt At SaveSync Fix 2020-04-12 06:26:27 -04:00
DroppingAnvil
144798b2dd Fixed message given to WaitExecutor causing F Wild to constantly say "You are already teleporting somewhere" 2020-04-11 15:02:17 -05:00
droppinganvil
dac07178e5 Merge remote-tracking branch 'origin/1.6.x' into 1.6.x 2020-04-11 14:52:12 -05:00
DroppingAnvil
f8421c09cf Option to load chunk before /f wild teleport. 2020-04-11 14:51:57 -05:00
Driftay
932a5768b0 Fixed Small NPE With Grace if GraceSystem was set to false 2020-04-09 17:53:05 -04:00
droppinganvil
861f88a916 Merge remote-tracking branch 'origin/1.6.x' into 1.6.x 2020-04-08 12:59:51 -05:00
DroppingAnvil
5b7f3b0f0e Fixed fly no permission issue 2020-04-08 12:59:41 -05:00
Driftay
304662fa9b Merge remote-tracking branch 'origin/1.6.x' into 1.6.x 2020-04-08 09:19:14 -04:00
Driftay
5a6c660f7f Fixed Small Error With Money Format If Econ is Off 2020-04-08 09:18:50 -04:00
Driftay
0fc736cdf5 Update README.md 2020-04-08 06:22:34 -04:00
Driftay
ef7db546a3 Update README.md 2020-04-08 06:22:14 -04:00
89 changed files with 2355 additions and 1520 deletions

View File

@@ -1,6 +1,7 @@
# 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) [![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) ![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) [![](https://jitpack.io/v/SaberLLC/Saber-Factions.svg)](https://jitpack.io/#SaberLLC/Saber-Factions)
SaberFactions is an exotic, performance optimized, 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 an exotic, performance optimized, 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.
@@ -32,7 +33,7 @@ Some of our features include the following
<dependency> <dependency>
<groupId>com.github.SaberLLC</groupId> <groupId>com.github.SaberLLC</groupId>
<artifactId>Saber-Factions</artifactId> <artifactId>Saber-Factions</artifactId>
<version>2.2.7-STABLE</version> <version>2.3.3-STABLE</version>
</dependency> </dependency>
``` ```
## Moving Forward ## Moving Forward

35
pom.xml
View File

@@ -4,7 +4,7 @@
<groupId>com.massivecraft</groupId> <groupId>com.massivecraft</groupId>
<artifactId>Factions</artifactId> <artifactId>Factions</artifactId>
<version>1.6.9.5-2.3.3-RC</version> <version>1.6.9.5-2.4.1-RC</version>
<packaging>jar</packaging> <packaging>jar</packaging>
<name>SaberFactions</name> <name>SaberFactions</name>
@@ -99,16 +99,10 @@
<version>1.3</version> <version>1.3</version>
<scope>compile</scope> <scope>compile</scope>
</dependency> </dependency>
<dependency>
<groupId>com.mojang</groupId>
<artifactId>brigadier</artifactId>
<version>1.0.14</version>
<scope>compile</scope>
</dependency>
<dependency> <dependency>
<groupId>com.github.stefvanschie.inventoryframework</groupId> <groupId>com.github.stefvanschie.inventoryframework</groupId>
<artifactId>IF</artifactId> <artifactId>IF</artifactId>
<version>0.5.8</version> <version>0.5.19</version>
</dependency> </dependency>
<dependency> <dependency>
<groupId>org.spigotmc</groupId> <groupId>org.spigotmc</groupId>
@@ -138,11 +132,6 @@
</exclusion> </exclusion>
</exclusions> </exclusions>
</dependency> </dependency>
<dependency>
<groupId>org.ocpsoft.prettytime</groupId>
<artifactId>prettytime</artifactId>
<version>4.0.0.Final</version>
</dependency>
<dependency> <dependency>
<groupId>net.milkbowl.vault</groupId> <groupId>net.milkbowl.vault</groupId>
<artifactId>VaultAPI</artifactId> <artifactId>VaultAPI</artifactId>
@@ -297,8 +286,12 @@
<scope>compile</scope> <scope>compile</scope>
<exclusions> <exclusions>
<exclusion> <exclusion>
<artifactId>gson</artifactId> <artifactId>*</artifactId>
<groupId>com.google.code.gson</groupId> <groupId>shaded</groupId>
</exclusion>
<exclusion>
<artifactId>*</artifactId>
<groupId>gson</groupId>
</exclusion> </exclusion>
</exclusions> </exclusions>
</dependency> </dependency>
@@ -350,12 +343,6 @@
</exclusion> </exclusion>
</exclusions> </exclusions>
</dependency> </dependency>
<dependency>
<groupId>com.google.code.gson</groupId>
<artifactId>gson</artifactId>
<version>2.8.5</version>
<scope>compile</scope>
</dependency>
<dependency> <dependency>
<groupId>me.clip</groupId> <groupId>me.clip</groupId>
<artifactId>placeholderapi</artifactId> <artifactId>placeholderapi</artifactId>
@@ -398,6 +385,12 @@
<artifactId>authlib</artifactId> <artifactId>authlib</artifactId>
<version>1.5.21</version> <version>1.5.21</version>
<scope>compile</scope> <scope>compile</scope>
<exclusions>
<exclusion>
<groupId>org.apache.logging.log4j</groupId>
<artifactId>*</artifactId>
</exclusion>
</exclusions>
</dependency> </dependency>
<dependency> <dependency>
<groupId>me.rayzr522</groupId> <groupId>me.rayzr522</groupId>

3
renovate.json Normal file
View File

@@ -0,0 +1,3 @@
{
"$schema": "https://docs.renovatebot.com/renovate-schema.json"
}

View File

@@ -98,10 +98,14 @@ public class Conf {
public static double autoLeaveRoutineRunsEveryXMinutes = 5.0; public static double autoLeaveRoutineRunsEveryXMinutes = 5.0;
public static int autoLeaveRoutineMaxMillisecondsPerTick = 5; // 1 server tick is roughly 50ms, so default max 10% of a tick public static int autoLeaveRoutineMaxMillisecondsPerTick = 5; // 1 server tick is roughly 50ms, so default max 10% of a tick
public static boolean removePlayerDataWhenBanned = true; public static boolean removePlayerDataWhenBanned = true;
public static String removePlayerDataWhenBannedReason = "Banned by admin.";
public static boolean autoLeaveDeleteFPlayerData = true; // Let them just remove player from Faction. public static boolean autoLeaveDeleteFPlayerData = true; // Let them just remove player from Faction.
public static boolean worldGuardChecking = false; public static boolean worldGuardChecking = false;
public static boolean worldGuardBuildPriority = false; public static boolean worldGuardBuildPriority = false;
//RADIUS CLAIMING
public static boolean useRadiusClaimSystem = true;
//FRIENDLY FIRE //FRIENDLY FIRE
public static boolean friendlyFireFPlayersCommand = false; public static boolean friendlyFireFPlayersCommand = false;
@@ -122,7 +126,7 @@ public class Conf {
public static boolean useDisbandGUI = true; public static boolean useDisbandGUI = true;
//SEALTH //SEALTH
public static boolean useSealthSystem = true; public static boolean useStealthSystem = true;
//STRIKES //STRIKES
public static boolean useStrikeSystem = true; public static boolean useStrikeSystem = true;
@@ -275,8 +279,7 @@ public class Conf {
/// Useful for HCF features. /// Useful for HCF features.
/// </summary> /// </summary>
public static Set<Material> territoryBypassProtectedMaterials = EnumSet.noneOf(Material.class); public static Set<Material> territoryBypassProtectedMaterials = EnumSet.noneOf(Material.class);
// Dependency check
public static boolean dependencyCheck = true;
public static boolean enableClickToClaim = true; public static boolean enableClickToClaim = true;
public static Set<Material> territoryCancelAndAllowItemUseMaterial = new HashSet<>(); public static Set<Material> territoryCancelAndAllowItemUseMaterial = new HashSet<>();
@@ -423,6 +426,10 @@ public class Conf {
public static HashMap<String, DefaultPermissions> defaultFactionPermissions = new HashMap<>(); public static HashMap<String, DefaultPermissions> defaultFactionPermissions = new HashMap<>();
public static HashSet<PermissableAction> lockedPermissions = new HashSet<>(); public static HashSet<PermissableAction> lockedPermissions = new HashSet<>();
public static boolean useComplexFly = true;
public static boolean wildLoadChunkBeforeTeleport = true;
private static transient Conf i = new Conf(); private static transient Conf i = new Conf();
static { static {
@@ -553,7 +560,6 @@ public class Conf {
territoryDenyUsageMaterials.add(Material.ARMOR_STAND); territoryDenyUsageMaterials.add(Material.ARMOR_STAND);
} }
territoryProtectedMaterialsWhenOffline.add(Material.BEACON); territoryProtectedMaterialsWhenOffline.add(Material.BEACON);
territoryDenyUsageMaterialsWhenOffline.add(XMaterial.FIRE_CHARGE.parseMaterial()); territoryDenyUsageMaterialsWhenOffline.add(XMaterial.FIRE_CHARGE.parseMaterial());
@@ -571,7 +577,7 @@ public class Conf {
safeZoneNerfedCreatureTypes.add(EntityType.ENDERMAN); safeZoneNerfedCreatureTypes.add(EntityType.ENDERMAN);
safeZoneNerfedCreatureTypes.add(EntityType.GHAST); safeZoneNerfedCreatureTypes.add(EntityType.GHAST);
safeZoneNerfedCreatureTypes.add(EntityType.MAGMA_CUBE); safeZoneNerfedCreatureTypes.add(EntityType.MAGMA_CUBE);
safeZoneNerfedCreatureTypes.add(EntityType.PIG_ZOMBIE); if (!FactionsPlugin.getInstance().mc116) safeZoneNerfedCreatureTypes.add(EntityType.PIG_ZOMBIE);
safeZoneNerfedCreatureTypes.add(EntityType.SILVERFISH); safeZoneNerfedCreatureTypes.add(EntityType.SILVERFISH);
safeZoneNerfedCreatureTypes.add(EntityType.SKELETON); safeZoneNerfedCreatureTypes.add(EntityType.SKELETON);
safeZoneNerfedCreatureTypes.add(EntityType.SPIDER); safeZoneNerfedCreatureTypes.add(EntityType.SPIDER);

View File

@@ -21,7 +21,6 @@ import com.massivecraft.factions.integration.Worldguard;
import com.massivecraft.factions.integration.dynmap.EngineDynmap; import com.massivecraft.factions.integration.dynmap.EngineDynmap;
import com.massivecraft.factions.listeners.*; import com.massivecraft.factions.listeners.*;
import com.massivecraft.factions.missions.MissionHandler; import com.massivecraft.factions.missions.MissionHandler;
import com.massivecraft.factions.struct.ChatMode;
import com.massivecraft.factions.struct.Relation; import com.massivecraft.factions.struct.Relation;
import com.massivecraft.factions.struct.Role; import com.massivecraft.factions.struct.Role;
import com.massivecraft.factions.util.*; import com.massivecraft.factions.util.*;
@@ -39,15 +38,15 @@ import me.lucko.commodore.CommodoreProvider;
import net.milkbowl.vault.economy.Economy; import net.milkbowl.vault.economy.Economy;
import net.milkbowl.vault.permission.Permission; import net.milkbowl.vault.permission.Permission;
import org.bstats.bukkit.Metrics; import org.bstats.bukkit.Metrics;
import org.bukkit.*; import org.bukkit.Bukkit;
import org.bukkit.ChatColor;
import org.bukkit.Location;
import org.bukkit.OfflinePlayer;
import org.bukkit.command.Command; import org.bukkit.command.Command;
import org.bukkit.command.CommandSender; import org.bukkit.command.CommandSender;
import org.bukkit.entity.Player; import org.bukkit.entity.Player;
import org.bukkit.event.Listener; import org.bukkit.event.Listener;
import org.bukkit.event.player.AsyncPlayerChatEvent;
import org.bukkit.inventory.Inventory; import org.bukkit.inventory.Inventory;
import org.bukkit.inventory.ItemStack;
import org.bukkit.inventory.meta.ItemMeta;
import org.bukkit.plugin.Plugin; import org.bukkit.plugin.Plugin;
import org.bukkit.plugin.RegisteredServiceProvider; import org.bukkit.plugin.RegisteredServiceProvider;
@@ -66,6 +65,7 @@ public class FactionsPlugin extends MPlugin {
// Our single plugin instance. // Our single plugin instance.
// Single 4 life. // Single 4 life.
public static FactionsPlugin instance; public static FactionsPlugin instance;
public static boolean cachedRadiusClaim;
public static Permission perms = null; public static Permission perms = null;
// This plugin sets the boolean true when fully enabled. // This plugin sets the boolean true when fully enabled.
// Plugins can check this boolean while hooking in have // Plugins can check this boolean while hooking in have
@@ -81,8 +81,8 @@ public class FactionsPlugin extends MPlugin {
public boolean mc113 = false; public boolean mc113 = false;
public boolean mc114 = false; public boolean mc114 = false;
public boolean mc115 = false; public boolean mc115 = false;
public boolean mc116 = false;
public boolean useNonPacketParticles = false; public boolean useNonPacketParticles = false;
public boolean factionsFlight = false;
public List<String> itemList = getConfig().getStringList("fchest.Items-Not-Allowed"); public List<String> itemList = getConfig().getStringList("fchest.Items-Not-Allowed");
SkriptAddon skriptAddon; SkriptAddon skriptAddon;
private FactionsPlayerListener factionsPlayerListener; private FactionsPlayerListener factionsPlayerListener;
@@ -129,28 +129,20 @@ public class FactionsPlugin extends MPlugin {
this.setAutoSave(val); this.setAutoSave(val);
} }
public void playSoundForAll(String sound) {
for (Player pl : Bukkit.getOnlinePlayers()) playSound(pl, sound);
}
public void playSoundForAll(List<String> sounds) {
for (Player pl : Bukkit.getOnlinePlayers()) playSound(pl, sounds);
}
public void playSound(Player p, List<String> sounds) {
for (String sound : sounds) playSound(p, sound);
}
public void playSound(Player p, String sound) {
float pitch = Float.parseFloat(sound.split(":")[1]);
sound = sound.split(":")[0];
p.playSound(p.getLocation(), Sound.valueOf(sound), pitch, 5.0F);
}
@Override @Override
public void onEnable() { public void onEnable() {
log("==== Setup ===="); log("==== Setup ====");
if (getServer().getPluginManager().getPlugin("Vault") == null) {
divider();
System.out.println("You are missing dependencies!");
System.out.println("Please verify [Vault] is installed!");
Conf.save();
Bukkit.getPluginManager().disablePlugin(instance);
divider();
return;
}
int version = Integer.parseInt(ReflectionUtils.PackageType.getServerVersion().split("_")[1]); int version = Integer.parseInt(ReflectionUtils.PackageType.getServerVersion().split("_")[1]);
switch (version) { switch (version) {
case 7: case 7:
@@ -176,6 +168,10 @@ public class FactionsPlugin extends MPlugin {
FactionsPlugin.instance.log("Minecraft Version 1.15 found."); FactionsPlugin.instance.log("Minecraft Version 1.15 found.");
mc115 = true; mc115 = true;
break; break;
case 16:
FactionsPlugin.instance.log("Minecraft Version 1.16 found.");
mc116 = true;
break;
} }
migrateFPlayerLeaders(); migrateFPlayerLeaders();
log("==== End Setup ===="); log("==== End Setup ====");
@@ -183,35 +179,23 @@ public class FactionsPlugin extends MPlugin {
int pluginId = 7013; int pluginId = 7013;
Metrics metrics = new Metrics(this, pluginId); Metrics metrics = new Metrics(this, pluginId);
if (!preEnable()) {
if (!preEnable()) return; this.loadSuccessful = false;
this.loadSuccessful = false; return;
if (!new File(this.getDataFolder() + "/config.yml").exists()) {
this.saveResource("config.yml", false);
this.reloadConfig();
} }
saveDefaultConfig();
this.reloadConfig();
//Start wait task executor //Start wait task executor
WaitExecutor.startTask(); WaitExecutor.startTask();
// Load Conf from disk // Load Conf from disk
fileManager = new FileManager();
getFileManager().setupFiles();
Conf.load(); Conf.load();
fileManager = new FileManager();
fileManager.setupFiles();
fLogManager = new FLogManager(); fLogManager = new FLogManager();
//Dependency checks
if (Conf.dependencyCheck && (!Bukkit.getPluginManager().isPluginEnabled("Vault"))) {
divider();
System.out.println("You are missing dependencies!");
System.out.println("Please verify [Vault] is installed!");
Conf.save();
Bukkit.getPluginManager().disablePlugin(instance);
divider();
return;
}
//Update their config if needed
// Updater.updateIfNeeded(getConfig());
RegisteredServiceProvider<Economy> rsp = FactionsPlugin.this.getServer().getServicesManager().getRegistration(Economy.class);
com.massivecraft.factions.integration.Essentials.setup(); com.massivecraft.factions.integration.Essentials.setup();
hookedPlayervaults = setupPlayervaults(); hookedPlayervaults = setupPlayervaults();
FPlayers.getInstance().load(); FPlayers.getInstance().load();
@@ -228,6 +212,12 @@ public class FactionsPlugin extends MPlugin {
else faction.addFPlayer(fPlayer); else faction.addFPlayer(fPlayer);
} }
Factions.getInstance().getAllFactions().forEach(Faction::refreshFPlayers);
if (getConfig().getBoolean("enable-faction-flight", true)) {
UtilFly.run();
}
Board.getInstance().load(); Board.getInstance().load();
Board.getInstance().clean(); Board.getInstance().clean();
@@ -247,15 +237,15 @@ public class FactionsPlugin extends MPlugin {
// start up task which runs the autoLeaveAfterDaysOfInactivity routine // start up task which runs the autoLeaveAfterDaysOfInactivity routine
startAutoLeaveTask(false); startAutoLeaveTask(false);
cachedRadiusClaim = Conf.useRadiusClaimSystem;
if (version > 8) { if (version > 8) {
useNonPacketParticles = true; useNonPacketParticles = true;
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")) 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 SaberFactions Addon...");
skriptAddon = Skript.registerAddon(this); skriptAddon = Skript.registerAddon(this);
try { try {
skriptAddon.loadClasses("com.massivecraft.factions.skript", "expressions"); skriptAddon.loadClasses("com.massivecraft.factions.skript", "expressions");
@@ -264,6 +254,7 @@ public class FactionsPlugin extends MPlugin {
} }
log("Skript addon registered!"); log("Skript addon registered!");
} }
if (Conf.useCheckSystem) { if (Conf.useCheckSystem) {
int minute = 1200; int minute = 1200;
this.getServer().getScheduler().runTaskTimerAsynchronously(this, new CheckTask(this, 3), 0L, minute * 3); this.getServer().getScheduler().runTaskTimerAsynchronously(this, new CheckTask(this, 3), 0L, minute * 3);
@@ -295,16 +286,20 @@ public class FactionsPlugin extends MPlugin {
new MissionHandler(this), new MissionHandler(this),
new FChestListener(), new FChestListener(),
new MenuListener(), new MenuListener(),
timerManager.graceTimer,
new AntiChestListener() new AntiChestListener()
}; };
for (Listener eventListener : eventsListener) for (Listener eventListener : eventsListener)
getServer().getPluginManager().registerEvents(eventListener, this); getServer().getPluginManager().registerEvents(eventListener, this);
if (Conf.useGraceSystem) {
getServer().getPluginManager().registerEvents(timerManager.graceTimer, this);
}
this.getCommand(refCommand).setExecutor(cmdBase); this.getCommand(refCommand).setExecutor(cmdBase);
if (!CommodoreProvider.isSupported()) this.getCommand(refCommand).setTabCompleter(this); if (!CommodoreProvider.isSupported()) this.getCommand(refCommand).setTabCompleter(this);
reserveObjects = new ArrayList<>(); reserveObjects = new ArrayList<>();
String path = Paths.get(this.getDataFolder().getAbsolutePath()).toAbsolutePath().toString() + File.separator + "reserves.json"; String path = Paths.get(this.getDataFolder().getAbsolutePath()).toAbsolutePath().toString() + File.separator + "reserves.json";
File file = new File(path); File file = new File(path);
@@ -340,10 +335,6 @@ public class FactionsPlugin extends MPlugin {
FactionsPlugin.startupFinished = true; FactionsPlugin.startupFinished = true;
} }
public SkriptAddon getSkriptAddon() {
return skriptAddon;
}
private void setupPlaceholderAPI() { private void setupPlaceholderAPI() {
Plugin clip = getServer().getPluginManager().getPlugin("PlaceholderAPI"); Plugin clip = getServer().getPluginManager().getPlugin("PlaceholderAPI");
@@ -450,8 +441,19 @@ public class FactionsPlugin extends MPlugin {
@Override @Override
public void onDisable() { public void onDisable() {
super.onDisable(); if (this.AutoLeaveTask != null) {
getServer().getScheduler().cancelTask(this.AutoLeaveTask);
this.AutoLeaveTask = null;
}
Conf.saveSync();
timerManager.saveTimerData(); timerManager.saveTimerData();
DiscordListener.saveGuilds();
if (Discord.jda != null) Discord.jda.shutdownNow();
fLogManager.saveLogs();
try { try {
String path = Paths.get(getDataFolder().getAbsolutePath()).toAbsolutePath().toString() + File.separator + "reserves.json"; String path = Paths.get(getDataFolder().getAbsolutePath()).toAbsolutePath().toString() + File.separator + "reserves.json";
File file = new File(path); File file = new File(path);
@@ -464,23 +466,7 @@ public class FactionsPlugin extends MPlugin {
e.printStackTrace(); e.printStackTrace();
} }
// only save data if plugin actually completely loaded successfully super.onDisable();
if (this.loadSuccessful) Conf.saveSync();
if (AutoLeaveTask != null) {
this.getServer().getScheduler().cancelTask(AutoLeaveTask);
AutoLeaveTask = null;
}
DiscordListener.saveGuilds();
if (Discord.jda != null) {
Discord.jda.shutdownNow();
}
try {
fLogManager.saveLogs();
} catch (Exception e) {
e.printStackTrace();
}
} }
public void startAutoLeaveTask(boolean restartIfRunning) { public void startAutoLeaveTask(boolean restartIfRunning) {
@@ -501,26 +487,9 @@ public class FactionsPlugin extends MPlugin {
Conf.save(); Conf.save();
} }
public ItemStack createItem(Material material, int amount, short datavalue, String name, List<String> lore) {
ItemStack item = new ItemStack(XMaterial.matchXMaterial(material.toString()).get().parseMaterial(), amount, datavalue);
ItemMeta meta = item.getItemMeta();
meta.setDisplayName(color(name));
meta.setLore(colorList(lore));
item.setItemMeta(meta);
return item;
}
public ItemStack createLazyItem(Material material, int amount, short datavalue, String name, String lore) {
ItemStack item = new ItemStack(material, amount, datavalue);
ItemMeta meta = item.getItemMeta();
meta.setDisplayName(color(FactionsPlugin.instance.getConfig().getString(name)));
meta.setLore(colorList(FactionsPlugin.instance.getConfig().getStringList(lore)));
item.setItemMeta(meta);
return item;
}
public Economy getEcon() { public Economy getEcon() {
RegisteredServiceProvider<Economy> rsp = FactionsPlugin.instance.getServer().getServicesManager().getRegistration(Economy.class); RegisteredServiceProvider<Economy> rsp = getServer().getServicesManager().getRegistration(Economy.class);
return rsp.getProvider(); return rsp.getProvider();
} }
@@ -545,7 +514,6 @@ public class FactionsPlugin extends MPlugin {
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<>();
// Check for "" first arg because spigot is mangled. // Check for "" first arg because spigot is mangled.
if (context.args.get(0).equals("")) { if (context.args.get(0).equals("")) {
for (FCommand subCommand : commandsEx.subCommands) { for (FCommand subCommand : commandsEx.subCommands) {
@@ -593,70 +561,11 @@ public class FactionsPlugin extends MPlugin {
// Functions for other plugins to hook into // Functions for other plugins to hook into
// -------------------------------------------- // // -------------------------------------------- //
// This value will be updated whenever new hooks are added
public int hookSupportVersion() {
return 3;
}
// If another plugin is handling insertion of chat tags, this should be used to notify Factions // If another plugin is handling insertion of chat tags, this should be used to notify Factions
public void handleFactionTagExternally(boolean notByFactions) { public void handleFactionTagExternally(boolean notByFactions) {
Conf.chatTagHandledByAnotherPlugin = notByFactions; Conf.chatTagHandledByAnotherPlugin = notByFactions;
} }
// Simply put, should this chat event be left for Factions to handle? For now, that means players with Faction Chat
// enabled or use of the Factions f command without a slash; combination of isPlayerFactionChatting() and isFactionsCommand()
public boolean shouldLetFactionsHandleThisChat(AsyncPlayerChatEvent event) {
return event != null && (isPlayerFactionChatting(event.getPlayer()) || isFactionsCommand(event.getMessage()));
}
// 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
public boolean isPlayerFactionChatting(Player player) {
if (player == null) return false;
FPlayer me = FPlayers.getInstance().getByPlayer(player);
return me != null && me.getChatMode().isAtLeast(ChatMode.ALLIANCE);
}
// Is this chat message actually a Factions command, and thus should be left alone by other plugins?
// TODO: GET THIS BACK AND WORKING
public boolean isFactionsCommand(String check) {
return !(check == null || check.isEmpty()) && this.handleCommand(null, check, true);
}
// Get a player's faction tag (faction name), mainly for usage by chat plugins for local/channel chat
public String getPlayerFactionTag(Player player) {
return getPlayerFactionTagRelation(player, null);
}
// Same as above, but with relation (enemy/neutral/ally) coloring potentially added to the tag
public String getPlayerFactionTagRelation(Player speaker, Player listener) {
String tag = "~";
if (speaker == null) return tag;
FPlayer me = FPlayers.getInstance().getByPlayer(speaker);
if (me == null) return tag;
// if listener isn't set, or config option is disabled, give back uncolored tag
if (listener == null || !Conf.chatTagRelationColored) {
tag = me.getChatTag().trim();
} else {
FPlayer you = FPlayers.getInstance().getByPlayer(listener);
if (you == null) {
tag = me.getChatTag().trim();
} else { // everything checks out, give the colored tag
tag = me.getChatTag(you).trim();
}
}
if (tag.isEmpty()) tag = "~";
return tag;
}
public FLogManager getFlogManager() { public FLogManager getFlogManager() {
return fLogManager; return fLogManager;
} }
@@ -665,14 +574,6 @@ public class FactionsPlugin extends MPlugin {
this.fLogManager.log(faction, type, arguments); this.fLogManager.log(faction, type, arguments);
} }
// Get a player's title within their faction, mainly for usage by chat plugins for local/channel chat
public String getPlayerTitle(Player player) {
if (player == null) return "";
FPlayer me = FPlayers.getInstance().getByPlayer(player);
if (me == null) return "";
return me.getTitle().trim();
}
public String color(String line) { public String color(String line) {
line = ChatColor.translateAlternateColorCodes('&', line); line = ChatColor.translateAlternateColorCodes('&', line);
return line; return line;
@@ -684,38 +585,10 @@ public class FactionsPlugin extends MPlugin {
return lore; return lore;
} }
// Get a list of all faction tags (names)
public Set<String> getFactionTags() {
return Factions.getInstance().getFactionTags();
}
public List<ReserveObject> getFactionReserves() { public List<ReserveObject> getFactionReserves() {
return this.reserveObjects; return this.reserveObjects;
} }
// Get a list of all players in the specified faction
public Set<String> getPlayersInFaction(String factionTag) {
Set<String> players = new HashSet<>();
Faction faction = Factions.getInstance().getByTag(factionTag);
if (faction != null) {
for (FPlayer fplayer : faction.getFPlayers()) players.add(fplayer.getName());
}
return players;
}
// Get a list of all online players in the specified faction
public Set<String> getOnlinePlayersInFaction(String factionTag) {
Set<String> players = new HashSet<>();
Faction faction = Factions.getInstance().getByTag(factionTag);
if (faction != null) {
for (FPlayer fplayer : faction.getFPlayersWhereOnline(true)) players.add(fplayer.getName());
}
return players;
}
public boolean isHookedPlayervaults() {
return hookedPlayervaults;
}
public String getPrimaryGroup(OfflinePlayer player) { public String getPrimaryGroup(OfflinePlayer player) {
return perms == null || !perms.hasGroupSupport() ? " " : perms.getPrimaryGroup(Bukkit.getWorlds().get(0).toString(), player); return perms == null || !perms.hasGroupSupport() ? " " : perms.getPrimaryGroup(Bukkit.getWorlds().get(0).toString(), player);
@@ -737,7 +610,4 @@ public class FactionsPlugin extends MPlugin {
debug(Level.INFO, s); debug(Level.INFO, s);
} }
public Worldguard getWg() {
return wg;
}
} }

View File

@@ -57,6 +57,10 @@ public class CmdAdmin extends FCommand {
return; return;
} }
if (fyou.isAlt()) {
return;
}
// only perform a FPlayerJoinEvent when newLeader isn't actually in the faction // only perform a FPlayerJoinEvent when newLeader isn't actually in the faction
if (fyou.getFaction() != targetFaction) { if (fyou.getFaction() != targetFaction) {
FPlayerJoinEvent event = new FPlayerJoinEvent(FPlayers.getInstance().getByPlayer(context.player), targetFaction, FPlayerJoinEvent.PlayerJoinReason.LEADER); FPlayerJoinEvent event = new FPlayerJoinEvent(FPlayers.getInstance().getByPlayer(context.player), targetFaction, FPlayerJoinEvent.PlayerJoinReason.LEADER);
@@ -86,24 +90,20 @@ public class CmdAdmin extends FCommand {
FactionsPlugin.instance.getFlogManager().log(targetFaction, FLogType.RANK_EDIT, context.fPlayer.getName(), fyou.getName(), ChatColor.RED + "Admin"); FactionsPlugin.instance.getFlogManager().log(targetFaction, FLogType.RANK_EDIT, context.fPlayer.getName(), fyou.getName(), ChatColor.RED + "Admin");
// Inform all players // Inform all players
for (FPlayer fplayer : FPlayers.getInstance().getOnlinePlayers()) { if (FactionsPlugin.instance.getConfig().getBoolean("faction-leader-broadcast")) {
fplayer.msg(TL.COMMAND_ADMIN_PROMOTED, for (FPlayer fplayer : FPlayers.getInstance().getOnlinePlayers()) {
context.player == null ? TL.GENERIC_SERVERADMIN.toString() : context.fPlayer.describeTo(fplayer, true), fplayer.msg(TL.COMMAND_ADMIN_PROMOTED, context.player == null ? TL.GENERIC_SERVERADMIN.toString() : context.fPlayer.describeTo(fplayer, true), fyou.describeTo(fplayer), targetFaction.describeTo(fplayer));
fyou.describeTo(fplayer), targetFaction.describeTo(fplayer)); }
} }
}); });
} }
private void setRole(FPlayer fp, Role r) { private void setRole(FPlayer fp, Role r) {
FactionsPlugin.getInstance().getServer().getScheduler().runTask(FactionsPlugin.instance, () -> { FactionsPlugin.getInstance().getServer().getScheduler().runTask(FactionsPlugin.instance, () -> fp.setRole(r));
fp.setRole(r);
});
} }
private void promoteNewLeader(Faction f) { private void promoteNewLeader(Faction f) {
FactionsPlugin.getInstance().getServer().getScheduler().runTask(FactionsPlugin.instance, () -> { FactionsPlugin.getInstance().getServer().getScheduler().runTask(FactionsPlugin.instance, (Runnable) f::promoteNewLeader);
f.promoteNewLeader();
});
} }
public TL getUsageTranslation() { public TL getUsageTranslation() {

View File

@@ -2,7 +2,10 @@ 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.struct.Role;
import com.massivecraft.factions.util.WarmUpUtil; import com.massivecraft.factions.util.WarmUpUtil;
import com.massivecraft.factions.zcore.fperms.Access;
import com.massivecraft.factions.zcore.fperms.PermissableAction;
import com.massivecraft.factions.zcore.util.TL; import com.massivecraft.factions.zcore.util.TL;
public class CmdCheckpoint extends FCommand { public class CmdCheckpoint extends FCommand {
@@ -17,10 +20,7 @@ public class CmdCheckpoint extends FCommand {
this.optionalArgs.put("set", ""); this.optionalArgs.put("set", "");
this.requirements = new CommandRequirements.Builder(Permission.CHECKPOINT) this.requirements = new CommandRequirements.Builder(Permission.CHECKPOINT).playerOnly().memberOnly().build();
.playerOnly()
.memberOnly()
.build();
} }
@Override @Override
@@ -29,18 +29,39 @@ public class CmdCheckpoint extends FCommand {
context.msg(TL.COMMAND_CHECKPOINT_DISABLED); context.msg(TL.COMMAND_CHECKPOINT_DISABLED);
return; return;
} }
if (context.args.size() == 1) { if (context.args.size() == 1 && context.args.get(0).equalsIgnoreCase("set")) {
FLocation myLocation = new FLocation(context.player.getLocation()); if (context.fPlayer.getRole() == Role.LEADER) {
Faction myLocFaction = Board.getInstance().getFactionAt(myLocation); FLocation myLocation = new FLocation(context.player.getLocation());
if (myLocFaction == Factions.getInstance().getWilderness() || myLocFaction == context.faction) { Faction myLocFaction = Board.getInstance().getFactionAt(myLocation);
context.faction.setCheckpoint(context.player.getLocation()); if (myLocFaction == Factions.getInstance().getWilderness() || myLocFaction == context.faction) {
context.msg(TL.COMMAND_CHECKPOINT_SET); context.faction.setCheckpoint(context.player.getLocation());
return; context.msg(TL.COMMAND_CHECKPOINT_SET);
return;
}
} else { } else {
context.msg(TL.COMMAND_CHECKPOINT_INVALIDLOCATION); context.msg(TL.COMMAND_CHECKPOINT_INVALIDLOCATION);
return; return;
} }
PermissableAction action = PermissableAction.SETWARP;
Access access = context.faction.getAccess(context.fPlayer, action);
if (access == Access.DENY) {
context.msg(TL.GENERIC_FPERM_NOPERMISSION, action.getName());
return;
} else {
FLocation myLocation = new FLocation(context.player.getLocation());
Faction myLocFaction = Board.getInstance().getFactionAt(myLocation);
if (myLocFaction == Factions.getInstance().getWilderness() || myLocFaction == context.faction) {
context.faction.setCheckpoint(context.player.getLocation());
context.msg(TL.COMMAND_CHECKPOINT_SET);
return;
} else {
context.msg(TL.COMMAND_CHECKPOINT_INVALIDLOCATION);
return;
}
}
} }
if (context.faction.getCheckpoint() == null) { if (context.faction.getCheckpoint() == null) {
context.msg(TL.COMMAND_CHECKPOINT_NOT_SET); context.msg(TL.COMMAND_CHECKPOINT_NOT_SET);
return; return;
@@ -57,8 +78,6 @@ public class CmdCheckpoint extends FCommand {
} else { } else {
context.msg(TL.COMMAND_CHECKPOINT_CLAIMED); context.msg(TL.COMMAND_CHECKPOINT_CLAIMED);
} }
} }
@Override @Override

View File

@@ -55,6 +55,10 @@ public class CmdColeader extends FCommand {
return; return;
} }
if (you.isAlt()) {
return;
}
if (context.fPlayer != null && context.fPlayer.getRole() != Role.LEADER && !permAny) { if (context.fPlayer != null && context.fPlayer.getRole() != Role.LEADER && !permAny) {
context.msg(TL.COMMAND_COLEADER_NOTADMIN); context.msg(TL.COMMAND_COLEADER_NOTADMIN);
return; return;

View File

@@ -54,7 +54,7 @@ public class CmdCreate extends FCommand {
return; return;
} }
if(Cooldown.isOnCooldown(context.fPlayer.getPlayer(), "createCooldown") && !context.fPlayer.isAdminBypassing()){ if (Cooldown.isOnCooldown(context.fPlayer.getPlayer(), "createCooldown") && !context.fPlayer.isAdminBypassing()) {
context.msg(TL.COMMAND_COOLDOWN); context.msg(TL.COMMAND_COOLDOWN);
return; return;
} }

View File

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

View File

@@ -70,7 +70,7 @@ public class CmdDisband extends FCommand {
return; return;
} }
if(Cooldown.isOnCooldown(context.fPlayer.getPlayer(), "disbandCooldown") && !context.fPlayer.isAdminBypassing()){ if (Cooldown.isOnCooldown(context.fPlayer.getPlayer(), "disbandCooldown") && !context.fPlayer.isAdminBypassing()) {
context.msg(TL.COMMAND_COOLDOWN); context.msg(TL.COMMAND_COOLDOWN);
return; return;
} }
@@ -82,7 +82,7 @@ public class CmdDisband extends FCommand {
} }
if (!access) { if (!access) {
if (Conf.useDisbandGUI && !context.fPlayer.isAdminBypassing() || !context.player.isOp()) { if (Conf.useDisbandGUI && (!context.fPlayer.isAdminBypassing() || !context.player.isOp())) {
if (!disbandMap.containsKey(context.player.getUniqueId().toString())) { if (!disbandMap.containsKey(context.player.getUniqueId().toString())) {
new FDisbandFrame(context.faction).buildGUI(context.fPlayer); new FDisbandFrame(context.faction).buildGUI(context.fPlayer);
return; return;
@@ -101,27 +101,15 @@ public class CmdDisband extends FCommand {
String amountString = context.sender instanceof ConsoleCommandSender ? TL.GENERIC_SERVERADMIN.toString() : context.fPlayer.describeTo(follower); String amountString = context.sender instanceof ConsoleCommandSender ? TL.GENERIC_SERVERADMIN.toString() : context.fPlayer.describeTo(follower);
if (follower.getFaction() == faction) { if (follower.getFaction() == faction) {
follower.msg(TL.COMMAND_DISBAND_BROADCAST_YOURS, amountString); follower.msg(TL.COMMAND_DISBAND_BROADCAST_YOURS, amountString);
if (!follower.canFlyAtLocation() && FactionsPlugin.getInstance().getConfig().getBoolean("enable-faction-flight")) {
follower.setFFlying(false, false);
}
} else { } else {
follower.msg(TL.COMMAND_DISBAND_BROADCAST_NOTYOURS, amountString, faction.getTag(follower)); follower.msg(TL.COMMAND_DISBAND_BROADCAST_NOTYOURS, amountString, faction.getTag(follower));
} }
} }
if (FactionsPlugin.getInstance().getConfig().getBoolean("enable-faction-flight")) {
faction.disband(context.player, PlayerDisbandReason.COMMAND);
context.fPlayer.setFFlying(false, false);
Cooldown.setCooldown(context.fPlayer.getPlayer(), "disbandCooldown", FactionsPlugin.getInstance().getConfig().getInt("fcooldowns.f-disband"));
return;
}
} else { } else {
context.player.sendMessage(String.valueOf(TL.COMMAND_DISBAND_PLAYER)); context.player.sendMessage(String.valueOf(TL.COMMAND_DISBAND_PLAYER));
} }
faction.disband(context.player, PlayerDisbandReason.COMMAND); faction.disband(context.player, PlayerDisbandReason.COMMAND);
Cooldown.setCooldown(context.fPlayer.getPlayer(), "disbandCooldown", FactionsPlugin.getInstance().getConfig().getInt("fcooldowns.f-disband")); Cooldown.setCooldown(context.fPlayer.getPlayer(), "disbandCooldown", FactionsPlugin.getInstance().getConfig().getInt("fcooldowns.f-disband"));
if (!context.fPlayer.canFlyAtLocation() && FactionsPlugin.getInstance().getConfig().getBoolean("enable-faction-flight")) {
context.fPlayer.setFFlying(false, false);
}
} }
} }

View File

@@ -19,6 +19,7 @@ import java.util.concurrent.ConcurrentHashMap;
public class CmdFly extends FCommand { public class CmdFly extends FCommand {
public static final boolean fly = FactionsPlugin.getInstance().getConfig().getBoolean("enable-faction-flight");
/** /**
* @author FactionsUUID Team * @author FactionsUUID Team
*/ */
@@ -26,8 +27,6 @@ public class CmdFly extends FCommand {
public static ConcurrentHashMap<String, Boolean> flyMap = new ConcurrentHashMap<>(); public static ConcurrentHashMap<String, Boolean> flyMap = new ConcurrentHashMap<>();
public static BukkitTask particleTask = null; public static BukkitTask particleTask = null;
public static BukkitTask flyTask = null;
public static boolean autoenable = FactionsPlugin.instance.getConfig().getBoolean("ffly.AutoEnable");
public CmdFly() { public CmdFly() {
@@ -42,15 +41,12 @@ public class CmdFly extends FCommand {
} }
public static void startParticles() { public static void startParticles() {
particleTask = Bukkit.getScheduler().runTaskTimerAsynchronously(FactionsPlugin.instance, () -> { particleTask = Bukkit.getScheduler().runTaskTimerAsynchronously(FactionsPlugin.instance, () -> {
for (String name : flyMap.keySet()) { for (String name : flyMap.keySet()) {
Player player = Bukkit.getPlayer(name); Player player = Bukkit.getPlayer(name);
if (player == null) continue; if (player == null) continue;
if (!player.isFlying()) continue; if (!player.isFlying()) continue;
if (!FactionsPlugin.getInstance().mc17) { if (!FactionsPlugin.getInstance().mc17 && player.getGameMode() == GameMode.SPECTATOR) continue;
if (player.getGameMode() == GameMode.SPECTATOR) continue;
}
FPlayer fplayer = FPlayers.getInstance().getByPlayer(player); FPlayer fplayer = FPlayers.getInstance().getByPlayer(player);
fplayer.isVanished(); fplayer.isVanished();
@@ -62,75 +58,44 @@ public class CmdFly extends FCommand {
}, 10L, 3L); }, 10L, 3L);
} }
public static void startFlyCheck() { public static boolean checkBypassPerms(FPlayer fme, Player me, Faction toFac, boolean sendMessage) {
flyTask = Bukkit.getScheduler().runTaskTimerAsynchronously(FactionsPlugin.instance, () -> { if (Conf.denyFlightIfInNoClaimingWorld && !Conf.worldsNoClaiming.isEmpty() && Conf.worldsNoClaiming.stream().anyMatch(me.getWorld().getName()::equalsIgnoreCase))
checkTaskState(); return false;
if (flyMap.keySet().size() != 0) {
for (String name : flyMap.keySet()) {
if (name == null) {
continue;
}
Player player = Bukkit.getPlayer(name);
if (player == null
|| !player.isFlying()
|| player.getGameMode() == GameMode.CREATIVE
|| !FactionsPlugin.getInstance().mc17 && player.getGameMode() == GameMode.SPECTATOR) {
continue;
}
FPlayer fPlayer = FPlayers.getInstance().getByPlayer(player);
if (fPlayer.isAdminBypassing()) continue;
if (!player.hasPermission("factions.fly.bypassnearbyenemycheck")) {
if (fPlayer.hasEnemiesNearby()) {
disableFlightSync(fPlayer);
continue;
}
checkEnemiesSync(fPlayer);
}
FLocation myFloc = new FLocation(player.getLocation());
if (!checkFly(fPlayer, player, Board.getInstance().getFactionAt(myFloc))) {
disableFlightSync(fPlayer);
}
} if (toFac != fme.getFaction()) {
if (!me.hasPermission(Permission.FLY_WILDERNESS.node) && toFac.isWilderness() || !me.hasPermission(Permission.FLY_SAFEZONE.node) && toFac.isSafeZone() || !me.hasPermission(Permission.FLY_WARZONE.node) && toFac.isWarZone()) {
if (sendMessage) fme.msg(TL.COMMAND_FLY_NO_ACCESS, toFac.getTag(fme));
return false;
}
Access access = toFac.getAccess(fme, PermissableAction.FLY);
if ((!(me.hasPermission(Permission.FLY_ENEMY.node) || access == Access.ALLOW)) && toFac.getRelationTo(fme.getFaction()) == Relation.ENEMY) {
if (sendMessage) 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) {
if (sendMessage) 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) {
if (sendMessage) fme.msg(TL.COMMAND_FLY_NO_ACCESS, toFac.getTag(fme));
return false;
} }
}, 20L, 15L); if (!(me.hasPermission(Permission.FLY_NEUTRAL.node) || access == Access.ALLOW) && toFac.getRelationTo(fme.getFaction()) == Relation.NEUTRAL && !toFac.isSystemFaction()) {
} if (sendMessage) fme.msg(TL.COMMAND_FLY_NO_ACCESS, toFac.getTag(fme));
return false;
public static boolean checkFly(FPlayer fme, Player me, Faction toFac) { }
if ((Conf.denyFlightIfInNoClaimingWorld && !Conf.worldsNoClaiming.isEmpty() && Conf.worldsNoClaiming.stream().anyMatch(me.getWorld().getName()::equalsIgnoreCase)) || me.hasPermission(Permission.FLY_FLY.node)) return me.hasPermission(Permission.FLY_FLY.node) && (access != Access.DENY || toFac.isSystemFaction());
return false;
if (toFac.getAccess(fme, PermissableAction.FLY) == Access.ALLOW) return true;
if (fme.getFaction().isWilderness()) return false;
if (toFac.isSystemFaction())
return me.hasPermission(toFac.isWilderness() ? Permission.FLY_WILDERNESS.node : toFac.isSafeZone() ? Permission.FLY_SAFEZONE.node : Permission.FLY_WARZONE.node);
Relation relationTo = toFac.getRelationTo(fme.getFaction());
if (!relationTo.isEnemy() && !relationTo.isMember())
return me.hasPermission(Permission.valueOf("FLY_" + relationTo.name()).node);
return false;
}
public static void checkTaskState() {
if (flyMap.isEmpty()) {
flyTask.cancel();
flyTask = null;
} }
return true;
} }
public static void disableFlight(final FPlayer fme) { public static void disableFlight(final FPlayer fme) {
fme.setFlying(false); fme.setFlying(false);
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());
@@ -155,7 +120,7 @@ public class CmdFly extends FCommand {
FLocation myfloc = new FLocation(context.player.getLocation()); FLocation myfloc = new FLocation(context.player.getLocation());
Faction toFac = Board.getInstance().getFactionAt(myfloc); Faction toFac = Board.getInstance().getFactionAt(myfloc);
if (!checkFly(context.fPlayer, context.player, toFac)) { if (!checkBypassPerms(context.fPlayer, context.player, toFac, false)) {
context.fPlayer.sendMessage(TL.COMMAND_FLY_NO_ACCESS.format(toFac.getTag())); context.fPlayer.sendMessage(TL.COMMAND_FLY_NO_ACCESS.format(toFac.getTag()));
return; return;
} }
@@ -175,17 +140,15 @@ public class CmdFly extends FCommand {
return; return;
} }
context.doWarmUp(WarmUpUtil.Warmup.FLIGHT, TL.WARMUPS_NOTIFY_FLIGHT, "Fly", () -> { if (fme.canFlyAtLocation()) {
fme.setFlying(true); context.doWarmUp(WarmUpUtil.Warmup.FLIGHT, TL.WARMUPS_NOTIFY_FLIGHT, "Fly", () -> {
flyMap.put(fme.getPlayer().getName(), true); fme.setFlying(true);
if (particleTask == null) { flyMap.put(fme.getPlayer().getName(), true);
startParticles(); if (particleTask == null) startParticles();
} }, FactionsPlugin.getInstance().getConfig().getLong("warmups.f-fly", 0));
} else {
if (flyTask == null) { fme.msg(TL.COMMAND_FLY_NO_ACCESS, Board.getInstance().getFactionAt(fme.getLastStoodAt()).getTag());
startFlyCheck(); }
}
}, FactionsPlugin.getInstance().getConfig().getLong("warmups.f-fly", 0));
} }
@Override @Override

View File

@@ -11,7 +11,7 @@ import com.massivecraft.factions.zcore.util.TL;
*/ */
public class CmdFriendlyFire extends FCommand { public class CmdFriendlyFire extends FCommand {
public CmdFriendlyFire(){ public CmdFriendlyFire() {
super(); super();
this.aliases.addAll(Aliases.friendlyFire); this.aliases.addAll(Aliases.friendlyFire);
@@ -23,12 +23,12 @@ public class CmdFriendlyFire extends FCommand {
@Override @Override
public void perform(CommandContext context) { public void perform(CommandContext context) {
if(!Conf.friendlyFireFPlayersCommand){ if (!Conf.friendlyFireFPlayersCommand) {
context.msg(TL.GENERIC_DISABLED, "friendly fire"); context.msg(TL.GENERIC_DISABLED, "friendly fire");
return; return;
} }
if(context.fPlayer.hasFriendlyFire()){ if (context.fPlayer.hasFriendlyFire()) {
context.fPlayer.setFriendlyFire(false); context.fPlayer.setFriendlyFire(false);
context.msg(TL.COMMAND_FRIENDLY_FIRE_TOGGLE_OFF); context.msg(TL.COMMAND_FRIENDLY_FIRE_TOGGLE_OFF);
} else { } else {

View File

@@ -2,10 +2,10 @@ 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.util.ItemBuilder;
import com.massivecraft.factions.zcore.util.TL; import com.massivecraft.factions.zcore.util.TL;
import org.bukkit.Location; import org.bukkit.Location;
import org.bukkit.Material; import org.bukkit.Material;
import org.bukkit.inventory.Inventory;
import org.bukkit.inventory.ItemStack; import org.bukkit.inventory.ItemStack;
public class CmdGetVault extends FCommand { public class CmdGetVault extends FCommand {
@@ -30,9 +30,13 @@ public class CmdGetVault extends FCommand {
context.fPlayer.msg(TL.GENERIC_DISABLED, "Faction Vaults"); context.fPlayer.msg(TL.GENERIC_DISABLED, "Faction Vaults");
return; return;
} }
Location vaultLocation = context.faction.getVault();
ItemStack vault = FactionsPlugin.getInstance().createItem(Material.CHEST, 1, (short) 0, FactionsPlugin.getInstance().color(FactionsPlugin.getInstance().getConfig().getString("fvault.Item.Name")), FactionsPlugin.getInstance().colorList(FactionsPlugin.getInstance().getConfig().getStringList("fvault.Item.Lore")));
Location vaultLocation = context.faction.getVault();
ItemStack vault = new ItemBuilder(Material.CHEST)
.amount(1)
.name(FactionsPlugin.getInstance().getConfig().getString("fvault.Item.Name"))
.lore(FactionsPlugin.getInstance().getConfig().getStringList("fvault.Item.Lore"))
.build();
//check if vault is set //check if vault is set
if (vaultLocation != null) { if (vaultLocation != null) {
@@ -40,36 +44,19 @@ public class CmdGetVault extends FCommand {
return; return;
} }
//has enough money? //has enough money?
int amount = FactionsPlugin.getInstance().getConfig().getInt("fvault.Price"); int amount = FactionsPlugin.getInstance().getConfig().getInt("fvault.Price");
if (!context.fPlayer.hasMoney(amount)) { if (!context.fPlayer.hasMoney(amount)) {
return; return;
} }
if (!context.fPlayer.takeMoney(amount)) {
return;
}
//success :) //success :)
context.fPlayer.takeMoney(amount);
context.player.getInventory().addItem(vault); context.player.getInventory().addItem(vault);
context.fPlayer.msg(TL.COMMAND_GETVAULT_RECEIVE); context.fPlayer.msg(TL.COMMAND_GETVAULT_RECEIVE);
} }
public boolean inventoryContains(Inventory inventory, ItemStack item) {
int count = 0;
ItemStack[] items = inventory.getContents();
for (int i = 0; i < items.length; i++) {
if (items[i] != null && items[i].getType() == item.getType() && items[i].getDurability() == item.getDurability()) {
count += items[i].getAmount();
}
if (count >= item.getAmount()) {
return true;
}
}
return false;
}
@Override @Override
public TL getUsageTranslation() { public TL getUsageTranslation() {

View File

@@ -9,7 +9,6 @@ import com.massivecraft.factions.util.CC;
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 mkremins.fanciful.FancyMessage; import mkremins.fanciful.FancyMessage;
import org.bukkit.ChatColor;
public class CmdInvite extends FCommand { public class CmdInvite extends FCommand {
@@ -60,14 +59,11 @@ public class CmdInvite extends FCommand {
// Send the invitation to the target player when online, otherwise just ignore // Send the invitation to the target player when online, otherwise just ignore
if (target.isOnline()) { if (target.isOnline()) {
// Tooltips, colors, and commands only apply to the string immediately before it. // Tooltips, colors, and commands only apply to the string immediately before it.
FancyMessage message = new FancyMessage(context.fPlayer.describeTo(target, true)) FancyMessage message = new FancyMessage(TL.COMMAND_INVITE_INVITEDYOU.toString()
.replace("%1$s", context.fPlayer.describeTo(target, true))
.replace("%2$s", context.faction.getTag())
.replaceAll("&", "§"))
.tooltip(TL.COMMAND_INVITE_CLICKTOJOIN.toString()) .tooltip(TL.COMMAND_INVITE_CLICKTOJOIN.toString())
.command("/" + Conf.baseCommandAliases.get(0) + " join " + context.faction.getTag())
.then(TL.COMMAND_INVITE_INVITEDYOU.toString())
.color(ChatColor.YELLOW)
.tooltip(TL.COMMAND_INVITE_CLICKTOJOIN.toString())
.command("/" + Conf.baseCommandAliases.get(0) + " join " + context.faction.getTag())
.then(context.faction.describeTo(target)).tooltip(TL.COMMAND_INVITE_CLICKTOJOIN.toString())
.command("/" + Conf.baseCommandAliases.get(0) + " join " + context.faction.getTag()); .command("/" + Conf.baseCommandAliases.get(0) + " join " + context.faction.getTag());
message.send(target.getPlayer()); message.send(target.getPlayer());
} }

View File

@@ -1,25 +1,14 @@
package com.massivecraft.factions.cmd; package com.massivecraft.factions.cmd;
import com.massivecraft.factions.*; import com.massivecraft.factions.*;
import com.massivecraft.factions.cmd.audit.FLogType;
import com.massivecraft.factions.discord.Discord;
import com.massivecraft.factions.event.FPlayerJoinEvent; import com.massivecraft.factions.event.FPlayerJoinEvent;
import com.massivecraft.factions.struct.Permission; import com.massivecraft.factions.struct.Permission;
import com.massivecraft.factions.util.CC;
import com.massivecraft.factions.zcore.frame.fupgrades.UpgradeType; import com.massivecraft.factions.zcore.frame.fupgrades.UpgradeType;
import com.massivecraft.factions.zcore.util.TL; import com.massivecraft.factions.zcore.util.TL;
import net.dv8tion.jda.core.entities.Member;
import net.dv8tion.jda.core.exceptions.HierarchyException;
import org.bukkit.Bukkit; import org.bukkit.Bukkit;
import java.util.Objects;
public class CmdJoin extends FCommand { public class CmdJoin extends FCommand {
/**
* @author FactionsUUID Team
*/
public CmdJoin() { public CmdJoin() {
super(); super();
this.aliases.addAll(Aliases.join); this.aliases.addAll(Aliases.join);
@@ -127,28 +116,13 @@ public class CmdJoin extends FCommand {
} }
faction.deinvite(fplayer); faction.deinvite(fplayer);
context.fPlayer.setRole(faction.getDefaultRole());
try {
context.fPlayer.setRole(faction.getDefaultRole());
FactionsPlugin.instance.logFactionEvent(faction, FLogType.INVITES, context.fPlayer.getName(), CC.Green + "joined", "the faction");
if (Discord.useDiscord && context.fPlayer.discordSetup() && Discord.isInMainGuild(context.fPlayer.discordUser()) && Discord.mainGuild != null) {
Member m = Discord.mainGuild.getMember(context.fPlayer.discordUser());
if (Conf.factionRoles) {
Discord.mainGuild.getController().addSingleRoleToMember(m, Objects.requireNonNull(Discord.createFactionRole(faction.getTag()))).queue();
}
if (Conf.factionDiscordTags) {
Discord.mainGuild.getController().setNickname(m, Discord.getNicknameString(context.fPlayer)).queue();
}
}
} catch (HierarchyException e) {
System.out.print(e.getMessage());
}
if (Conf.logFactionJoin) { if (Conf.logFactionJoin) {
if (samePlayer) { if (samePlayer) {
FactionsPlugin.getInstance().log(TL.COMMAND_JOIN_JOINEDLOG.toString(), fplayer.getName(), faction.getTag()); FactionsPlugin.instance.log(TL.COMMAND_JOIN_JOINEDLOG.toString(), fplayer.getName(), faction.getTag());
} else { } else {
FactionsPlugin.getInstance().log(TL.COMMAND_JOIN_MOVEDLOG.toString(), context.fPlayer.getName(), fplayer.getName(), faction.getTag()); FactionsPlugin.instance.log(TL.COMMAND_JOIN_MOVEDLOG.toString(), context.fPlayer.getName(), fplayer.getName(), faction.getTag());
} }
} }
} }

View File

@@ -115,6 +115,7 @@ public class CmdKick extends FCommand {
toKickFaction.msg(TL.COMMAND_KICK_FACTION, context.fPlayer.describeTo(toKickFaction, true), toKick.describeTo(toKickFaction, true)); toKickFaction.msg(TL.COMMAND_KICK_FACTION, context.fPlayer.describeTo(toKickFaction, true), toKick.describeTo(toKickFaction, true));
toKick.msg(TL.COMMAND_KICK_KICKED, context.fPlayer.describeTo(toKick, true), toKickFaction.describeTo(toKick)); toKick.msg(TL.COMMAND_KICK_KICKED, context.fPlayer.describeTo(toKick, true), toKickFaction.describeTo(toKick));
if (toKickFaction != context.faction) { if (toKickFaction != context.faction) {
context.fPlayer.msg(TL.COMMAND_KICK_KICKS, toKick.describeTo(context.fPlayer), toKickFaction.describeTo(context.fPlayer)); context.fPlayer.msg(TL.COMMAND_KICK_KICKS, toKick.describeTo(context.fPlayer), toKickFaction.describeTo(context.fPlayer));
} }
@@ -127,6 +128,9 @@ public class CmdKick extends FCommand {
FactionsPlugin.instance.logFactionEvent(toKickFaction, FLogType.INVITES, context.fPlayer.getName(), CC.Red + "kicked", toKick.getName()); FactionsPlugin.instance.logFactionEvent(toKickFaction, FLogType.INVITES, context.fPlayer.getName(), CC.Red + "kicked", toKick.getName());
toKickFaction.deinvite(toKick); toKickFaction.deinvite(toKick);
toKick.resetFactionData(); toKick.resetFactionData();
if (!CmdFly.checkBypassPerms(toKick, toKick.getPlayer(), toKickFaction, false)) {
CmdFly.disableFlight(toKick);
}
} }
@Override @Override

View File

@@ -42,76 +42,75 @@ public class CmdList extends FCommand {
// 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.econCostList, "to list the factions", "for listing the factions")) if (!context.payForCommand(Conf.econCostList, "to list the factions", "for listing the factions"))
return; return;
FactionsPlugin.getInstance().getServer().getScheduler().runTaskAsynchronously(FactionsPlugin.instance, () -> {
ArrayList<Faction> factionList = Factions.getInstance().getAllFactions(); ArrayList<Faction> factionList = Factions.getInstance().getAllFactions();
factionList.remove(Factions.getInstance().getWilderness()); factionList.remove(Factions.getInstance().getWilderness());
factionList.remove(Factions.getInstance().getSafeZone()); factionList.remove(Factions.getInstance().getSafeZone());
factionList.remove(Factions.getInstance().getWarZone()); factionList.remove(Factions.getInstance().getWarZone());
// remove exempt factions // remove exempt factions
if (context.fPlayer != null && context.fPlayer.getPlayer() != null && !context.fPlayer.getPlayer().hasPermission("factions.show.bypassexempt")) { if (context.fPlayer != null && context.fPlayer.getPlayer() != null && !context.fPlayer.getPlayer().hasPermission("factions.show.bypassexempt")) {
List<String> exemptFactions = FactionsPlugin.getInstance().getConfig().getStringList("show-exempt"); List<String> exemptFactions = FactionsPlugin.getInstance().getConfig().getStringList("show-exempt");
factionList.removeIf(next -> exemptFactions.contains(next.getTag())); factionList.removeIf(next -> exemptFactions.contains(next.getTag()));
}
// Sort by total followers first
factionList.sort((f1, f2) -> {
int f1Size = f1.getFPlayers().size();
int f2Size = f2.getFPlayers().size();
if (f1Size < f2Size) {
return 1;
} else if (f1Size > f2Size) {
return -1;
} }
return 0;
// Sort by total followers first
factionList.sort((f1, f2) -> {
int f1Size = f1.getFPlayers().size();
int f2Size = f2.getFPlayers().size();
if (f1Size < f2Size) {
return 1;
} else if (f1Size > f2Size) {
return -1;
}
return 0;
});
// Then sort by how many members are online now
factionList.sort((f1, f2) -> {
int f1Size = f1.getFPlayersWhereOnline(true).size();
int f2Size = f2.getFPlayersWhereOnline(true).size();
if (f1Size < f2Size) {
return 1;
} else if (f1Size > f2Size) {
return -1;
}
return 0;
});
ArrayList<String> lines = new ArrayList<>();
factionList.add(0, Factions.getInstance().getWilderness());
final int pageheight = 9;
int pagenumber = context.argAsInt(0, 1);
int pagecount = (factionList.size() / pageheight) + 1;
if (pagenumber > pagecount) {
pagenumber = pagecount;
} else if (pagenumber < 1) {
pagenumber = 1;
}
int start = (pagenumber - 1) * pageheight;
int end = start + pageheight;
if (end > factionList.size()) {
end = factionList.size();
}
String header = FactionsPlugin.getInstance().getConfig().getString("list.header", defaults[0]);
header = header.replace("{pagenumber}", String.valueOf(pagenumber)).replace("{pagecount}", String.valueOf(pagecount));
lines.add(FactionsPlugin.getInstance().txt.parse(header));
for (Faction faction : factionList.subList(start, end)) {
if (faction.isWilderness()) {
lines.add(FactionsPlugin.getInstance().txt.parse(TagUtil.parsePlain(faction, FactionsPlugin.getInstance().getConfig().getString("list.factionless", defaults[1]))));
continue;
}
lines.add(FactionsPlugin.getInstance().txt.parse(TagUtil.parsePlain(faction, context.fPlayer, FactionsPlugin.getInstance().getConfig().getString("list.entry", defaults[2]))));
}
context.sendMessage(lines);
}); });
// Then sort by how many members are online now
factionList.sort((f1, f2) -> {
int f1Size = f1.getFPlayersWhereOnline(true).size();
int f2Size = f2.getFPlayersWhereOnline(true).size();
if (f1Size < f2Size) {
return 1;
} else if (f1Size > f2Size) {
return -1;
}
return 0;
});
ArrayList<String> lines = new ArrayList<>();
factionList.add(0, Factions.getInstance().getWilderness());
final int pageheight = 9;
int pagenumber = context.argAsInt(0, 1);
int pagecount = (factionList.size() / pageheight) + 1;
if (pagenumber > pagecount) {
pagenumber = pagecount;
} else if (pagenumber < 1) {
pagenumber = 1;
}
int start = (pagenumber - 1) * pageheight;
int end = start + pageheight;
if (end > factionList.size()) {
end = factionList.size();
}
String header = FactionsPlugin.getInstance().getConfig().getString("list.header", defaults[0]);
assert header != null;
header = header.replace("{pagenumber}", String.valueOf(pagenumber)).replace("{pagecount}", String.valueOf(pagecount));
lines.add(FactionsPlugin.getInstance().txt.parse(header));
for (Faction faction : factionList.subList(start, end)) {
if (faction.isWilderness()) {
lines.add(FactionsPlugin.getInstance().txt.parse(TagUtil.parsePlain(faction, FactionsPlugin.getInstance().getConfig().getString("list.factionless", defaults[1]))));
continue;
}
lines.add(FactionsPlugin.getInstance().txt.parse(TagUtil.parsePlain(faction, context.fPlayer, FactionsPlugin.getInstance().getConfig().getString("list.entry", defaults[2]))));
}
context.sendMessage(lines);
} }
@Override @Override

View File

@@ -50,6 +50,10 @@ public class CmdMod extends FCommand {
return; return;
} }
if (you.isAlt()) {
return;
}
if (context.fPlayer != null && context.fPlayer.getRole() != Role.LEADER && !permAny) { if (context.fPlayer != null && context.fPlayer.getRole() != Role.LEADER && !permAny) {
context.msg(TL.COMMAND_MOD_NOTADMIN); context.msg(TL.COMMAND_MOD_NOTADMIN);
return; return;

View File

@@ -39,7 +39,7 @@ public class CmdOpen extends FCommand {
String open = context.faction.getOpen() ? TL.COMMAND_OPEN_OPEN.toString() : TL.COMMAND_OPEN_CLOSED.toString(); String open = context.faction.getOpen() ? TL.COMMAND_OPEN_OPEN.toString() : TL.COMMAND_OPEN_CLOSED.toString();
if(Cooldown.isOnCooldown(context.fPlayer.getPlayer(), "openCooldown") && !context.fPlayer.isAdminBypassing()){ if (Cooldown.isOnCooldown(context.fPlayer.getPlayer(), "openCooldown") && !context.fPlayer.isAdminBypassing()) {
context.msg(TL.COMMAND_COOLDOWN); context.msg(TL.COMMAND_COOLDOWN);
return; return;
} }
@@ -51,7 +51,7 @@ public class CmdOpen extends FCommand {
Cooldown.setCooldown(fplayer.getPlayer(), "openCooldown", FactionsPlugin.getInstance().getConfig().getInt("fcooldowns.f-open")); Cooldown.setCooldown(fplayer.getPlayer(), "openCooldown", FactionsPlugin.getInstance().getConfig().getInt("fcooldowns.f-open"));
continue; continue;
} }
if(FactionsPlugin.getInstance().getConfig().getBoolean("faction-open-broadcast")) return; if (FactionsPlugin.getInstance().getConfig().getBoolean("faction-open-broadcast")) return;
fplayer.msg(TL.COMMAND_OPEN_CHANGED, context.faction.getTag(fplayer.getFaction()), open); fplayer.msg(TL.COMMAND_OPEN_CHANGED, context.faction.getTag(fplayer.getFaction()), open);
} }
}); });

View File

@@ -30,10 +30,6 @@ public class CmdReload extends FCommand {
FactionsPlugin.getInstance().loadLang(); FactionsPlugin.getInstance().loadLang();
if (FactionsPlugin.getInstance().getConfig().getBoolean("enable-faction-flight", false)) {
FactionsPlugin.getInstance().factionsFlight = true;
}
if (!FactionsPlugin.getInstance().mc17) { if (!FactionsPlugin.getInstance().mc17) {
FactionsPlayerListener.loadCorners(); FactionsPlayerListener.loadCorners();
} }

View File

@@ -24,17 +24,21 @@ public class CmdShow extends FCommand {
this.aliases.addAll(Aliases.show_show); this.aliases.addAll(Aliases.show_show);
// add defaults to /f show in case config doesnt have it // add defaults to /f show in case config doesnt have it
defaults.add("{header}"); defaults.add("&8&m--------------&7 &8<&e{faction}&8> &8&m--------------");
defaults.add("<a>Description: <i>{description}"); defaults.add("&4* &cOwner: &f{leader}");
defaults.add("<a>Joining: <i>{joining} {peaceful}"); defaults.add("&4* &cDescription: &f{description}");
defaults.add("<a>Land / Power / Maxpower: <i> {chunks} / {power} / {maxPower}"); defaults.add("&4* &cLand / Power / Max Power: &f{chunks} &8/ &f{power} &8/ &f{maxPower}");
defaults.add("<a>Founded: <i>{create-date}"); defaults.add("&4* &cFaction Strikes: &f{strikes}");
defaults.add("<a>This faction is permanent, remaining even with no members."); defaults.add("&4* &cFaction Points: &f{faction-points}");
defaults.add("<a>Land value: <i>{land-value} {land-refund}"); defaults.add("&4* &cFounded: &f{create-date}");
defaults.add("<a>Balance: <i>{faction-balance}"); defaults.add("&4* &cBalance: &f{faction-balance}");
defaults.add("<a>Allies(<i>{allies}<a>/<i>{max-allies}<a>): {allies-list}"); defaults.add("&4* &cAllies: &a{allies-list}");
defaults.add("<a>Online: (<i>{online}<a>/<i>{members}<a>): {online-list}"); defaults.add("&4* &cEnemies: &4{enemies-list}");
defaults.add("<a>Offline: (<i>{offline}<a>/<i>{members}<a>): {offline-list}"); defaults.add("&4* &cOnline Members: &8[&f{online}/{members}&8] &a{online-list}");
defaults.add("&4* &cOffline Members: &8[&f{offline}/{members}&8] &a{offline-list}");
defaults.add("&4* &cAlts: &f{alts}");
defaults.add("&4* &cBans: &f{faction-bancount}");
defaults.add("&8&m----------------------------------------");
// this.requiredArgs.add(""); // this.requiredArgs.add("");
this.optionalArgs.put("faction tag", "yours"); this.optionalArgs.put("faction tag", "yours");
@@ -45,6 +49,7 @@ public class CmdShow extends FCommand {
@Override @Override
public void perform(CommandContext context) { public void perform(CommandContext context) {
Faction faction = context.faction; Faction faction = context.faction;
FactionsPlugin instance = FactionsPlugin.getInstance();
if (context.argIsSet(0)) if (context.argIsSet(0))
faction = context.argAsFaction(0); faction = context.argAsFaction(0);
@@ -52,7 +57,7 @@ public class CmdShow extends FCommand {
return; return;
if (context.fPlayer != null && !context.player.getPlayer().hasPermission("factions.show.bypassexempt") if (context.fPlayer != null && !context.player.getPlayer().hasPermission("factions.show.bypassexempt")
&& FactionsPlugin.getInstance().getConfig().getStringList("show-exempt").contains(faction.getTag())) { && instance.getConfig().getStringList("show-exempt").contains(faction.getTag())) {
context.msg(TL.COMMAND_SHOW_EXEMPT); context.msg(TL.COMMAND_SHOW_EXEMPT);
return; return;
} }
@@ -62,7 +67,7 @@ public class CmdShow extends FCommand {
return; return;
} }
List<String> show = FactionsPlugin.getInstance().getConfig().getStringList("show"); List<String> show = instance.getConfig().getStringList("show");
if (show == null || show.isEmpty()) if (show == null || show.isEmpty())
show = defaults; show = defaults;
@@ -71,41 +76,49 @@ public class CmdShow extends FCommand {
// send header and that's all // send header and that's all
String header = show.get(0); String header = show.get(0);
if (TagReplacer.HEADER.contains(header)) { if (TagReplacer.HEADER.contains(header)) {
context.msg(FactionsPlugin.getInstance().txt.titleize(tag)); context.msg(instance.txt.titleize(tag));
} else { } else {
context.msg(FactionsPlugin.getInstance().txt.parse(TagReplacer.FACTION.replace(header, tag))); context.msg(instance.txt.parse(TagReplacer.FACTION.replace(header, tag)));
} }
return; // we only show header for non-normal factions return; // we only show header for non-normal factions
} }
for (String raw : show) { List<FancyMessage> fancy = new ArrayList<>();
String parsed = TagUtil.parsePlain(faction, context.fPlayer, raw); // use relations List<String> finalShow = show;
if (parsed == null) { Faction finalFaction = faction;
continue; // Due to minimal f show. instance.getServer().getScheduler().runTaskAsynchronously(instance, () -> {
} for (String raw : finalShow) {
String parsed = instance.getConfig().getBoolean("relational-show", true) ? TagUtil.parsePlain(finalFaction, context.fPlayer, raw) : TagUtil.parsePlain(finalFaction, raw); // use relations
if (context.fPlayer != null) { if (parsed == null) {
parsed = TagUtil.parsePlaceholders(context.fPlayer.getPlayer(), parsed); continue; // Due to minimal f show.
}
if (TagUtil.hasFancy(parsed)) {
List<FancyMessage> fancy = TagUtil.parseFancy(faction, context.fPlayer, parsed);
if (fancy != null)
context.sendFancyMessage(fancy);
continue;
}
if (!parsed.contains("{notFrozen}") && !parsed.contains("{notPermanent}")) {
if (parsed.contains("{ig}")) {
// replaces all variables with no home TL
parsed = parsed.substring(0, parsed.indexOf("{ig}")) + TL.COMMAND_SHOW_NOHOME.toString();
} }
if (parsed.contains("%")) {
parsed = parsed.replaceAll("%", ""); // Just in case it got in there before we disallowed it. if (context.fPlayer != null) {
parsed = TagUtil.parsePlaceholders(context.fPlayer.getPlayer(), parsed);
}
if (TagUtil.hasFancy(parsed)) {
List<FancyMessage> localFancy = TagUtil.parseFancy(finalFaction, context.fPlayer, parsed);
if (localFancy != null)
fancy.addAll(localFancy);
continue;
}
if (!parsed.contains("{notFrozen}") && !parsed.contains("{notPermanent}")) {
if (parsed.contains("{ig}")) {
// replaces all variables with no home TL
parsed = parsed.substring(0, parsed.indexOf("{ig}")) + TL.COMMAND_SHOW_NOHOME.toString();
}
if (parsed.contains("%")) {
parsed = parsed.replaceAll("%", ""); // Just in case it got in there before we disallowed it.
}
parsed = FactionsPlugin.getInstance().txt.parse(parsed);
FancyMessage localFancy = instance.txt.parseFancy(parsed);
fancy.add(localFancy);
} }
context.msg(FactionsPlugin.getInstance().txt.parse(parsed));
} }
} instance.getServer().getScheduler().runTask(instance, () -> context.sendFancyMessage(fancy));
});
} }
@Override @Override

View File

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

View File

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

View File

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

View File

@@ -54,7 +54,7 @@ public class CmdTag extends FCommand {
return; return;
} }
if(Cooldown.isOnCooldown(context.player, "tagCooldown") && !context.fPlayer.isAdminBypassing()){ if (Cooldown.isOnCooldown(context.player, "tagCooldown") && !context.fPlayer.isAdminBypassing()) {
context.msg(TL.COMMAND_COOLDOWN); context.msg(TL.COMMAND_COOLDOWN);
return; return;
} }
@@ -72,7 +72,6 @@ public class CmdTag extends FCommand {
} }
String oldtag = context.faction.getTag(); String oldtag = context.faction.getTag();
context.faction.setTag(tag); context.faction.setTag(tag);

View File

@@ -48,7 +48,7 @@ public class CmdUnban extends FCommand {
context.faction.unban(target); context.faction.unban(target);
context.msg(TL.COMMAND_UNBAN_UNBANNED, context.fPlayer.getName(), target.getName()); context.msg(TL.COMMAND_UNBAN_UNBANNED, context.fPlayer.getName(), target.getName());
target.msg(TL.COMMAND_UNBAN_TARGET, context.faction.getTag(target)); target.msg(TL.COMMAND_UNBAN_TARGETUNBANNED, context.faction.getTag(target));
} }
@Override @Override

View File

@@ -26,6 +26,7 @@ import com.massivecraft.factions.discord.CmdInviteBot;
import com.massivecraft.factions.discord.CmdSetGuild; import com.massivecraft.factions.discord.CmdSetGuild;
import com.massivecraft.factions.missions.CmdMissions; import com.massivecraft.factions.missions.CmdMissions;
import com.massivecraft.factions.shop.CmdShop; import com.massivecraft.factions.shop.CmdShop;
import com.massivecraft.factions.shop.ShopGUIFrame;
import com.massivecraft.factions.zcore.util.TL; import com.massivecraft.factions.zcore.util.TL;
import me.lucko.commodore.CommodoreProvider; import me.lucko.commodore.CommodoreProvider;
import org.bukkit.Bukkit; import org.bukkit.Bukkit;
@@ -377,6 +378,7 @@ public class FCmdRoot extends FCommand implements CommandExecutor {
} }
if (FactionsPlugin.getInstance().getConfig().getBoolean("F-Shop.Enabled", false) && !fShopEnabled) { if (FactionsPlugin.getInstance().getConfig().getBoolean("F-Shop.Enabled", false) && !fShopEnabled) {
this.addSubCommand(this.cmdShop); this.addSubCommand(this.cmdShop);
new ShopGUIFrame(null).checkShopConfig();
fShopEnabled = true; fShopEnabled = true;
} }
if (FactionsPlugin.getInstance().getConfig().getBoolean("f-inventory-see.Enabled", false) && !invSeeEnabled) { if (FactionsPlugin.getInstance().getConfig().getBoolean("f-inventory-see.Enabled", false) && !invSeeEnabled) {
@@ -399,11 +401,9 @@ public class FCmdRoot extends FCommand implements CommandExecutor {
addSubCommand(this.cmdFocus); addSubCommand(this.cmdFocus);
fFocusEnabled = true; fFocusEnabled = true;
} }
if (FactionsPlugin.getInstance().getConfig().getBoolean("enable-faction-flight", false) && !fFlyEnabled) { if (FactionsPlugin.getInstance().getConfig().getBoolean("enable-faction-flight", true) && !fFlyEnabled) {
this.addSubCommand(this.cmdFly); this.addSubCommand(this.cmdFly);
fFlyEnabled = true; fFlyEnabled = true;
CmdFly.startFlyCheck();
CmdFly.startParticles();
} }
} }

View File

@@ -27,9 +27,10 @@ public class AntiChestListener implements Listener {
if (e.isCancelled()) return; if (e.isCancelled()) return;
Inventory clicked = e.getClickedInventory(); Inventory clicked = e.getClickedInventory();
Inventory clicker = e.getWhoClicked().getInventory();
if (e.getClick().isShiftClick()) { if (e.getClick().isShiftClick()) {
if (clicked == e.getWhoClicked().getInventory()) { if (clicked == clicker) {
ItemStack clickedOn = e.getCurrentItem(); ItemStack clickedOn = e.getCurrentItem();
if (clickedOn != null && FactionsPlugin.getInstance().itemList.contains(clickedOn.getType().toString())) { if (clickedOn != null && FactionsPlugin.getInstance().itemList.contains(clickedOn.getType().toString())) {
fPlayer.msg(TL.CHEST_ITEM_DENIED_TRANSFER, clickedOn.getType().toString()); fPlayer.msg(TL.CHEST_ITEM_DENIED_TRANSFER, clickedOn.getType().toString());
@@ -38,11 +39,17 @@ public class AntiChestListener implements Listener {
} }
} }
if (clicked != e.getWhoClicked().getInventory()) { if (clicked != clicker) {
ItemStack onCursor = e.getCursor(); ItemStack onCursor = e.getCursor();
if (onCursor != null && FactionsPlugin.getInstance().itemList.contains(onCursor.getType().toString())) { if (onCursor != null && FactionsPlugin.getInstance().itemList.contains(onCursor.getType().toString())) {
fPlayer.msg(TL.CHEST_ITEM_DENIED_TRANSFER, onCursor.getType().toString()); fPlayer.msg(TL.CHEST_ITEM_DENIED_TRANSFER, onCursor.getType().toString());
e.setCancelled(true); e.setCancelled(true);
} else if (e.getClick().isKeyboardClick()) {
ItemStack item = clicker.getItem(e.getHotbarButton());
if (item != null && FactionsPlugin.getInstance().itemList.contains(item.getType().toString())) {
fPlayer.msg(TL.CHEST_ITEM_DENIED_TRANSFER, item.getType().toString());
e.setCancelled(true);
}
} }
} }
} }

View File

@@ -1,5 +1,6 @@
package com.massivecraft.factions.cmd.claim; package com.massivecraft.factions.cmd.claim;
import com.massivecraft.factions.Board;
import com.massivecraft.factions.FLocation; import com.massivecraft.factions.FLocation;
import com.massivecraft.factions.Faction; import com.massivecraft.factions.Faction;
import com.massivecraft.factions.FactionsPlugin; import com.massivecraft.factions.FactionsPlugin;
@@ -62,11 +63,15 @@ public class CmdAutoClaim extends FCommand {
return; return;
} }
Faction at = Board.getInstance().getFactionAt(new FLocation(context.fPlayer.getPlayer().getLocation()));
context.fPlayer.setAutoClaimFor(forFaction); context.fPlayer.setAutoClaimFor(forFaction);
FactionsPlugin.instance.logFactionEvent(forFaction, FLogType.CHUNK_CLAIMS, context.fPlayer.getName(), CC.GreenB + "CLAIMED", "1", new FLocation(context.fPlayer.getPlayer().getLocation()).formatXAndZ(",")); FactionsPlugin.instance.logFactionEvent(forFaction, FLogType.CHUNK_CLAIMS, context.fPlayer.getName(), CC.GreenB + "CLAIMED", "1", new FLocation(context.fPlayer.getPlayer().getLocation()).formatXAndZ(","));
context.msg(TL.COMMAND_AUTOCLAIM_ENABLED, forFaction.describeTo(context.fPlayer)); context.msg(TL.COMMAND_AUTOCLAIM_ENABLED, forFaction.describeTo(context.fPlayer));
context.fPlayer.attemptClaim(forFaction, context.fPlayer.getPlayer().getLocation(), true); if (FactionsPlugin.cachedRadiusClaim && context.fPlayer.attemptClaim(forFaction, context.player.getLocation(), true)) {
context.fPlayer.getFaction().getFPlayersWhereOnline(true).forEach(f -> f.msg(TL.CLAIM_CLAIMED, context.fPlayer.describeTo(f, true), context.fPlayer.getFaction().describeTo(f), at.describeTo(f)));
} else {
context.fPlayer.attemptClaim(forFaction, context.fPlayer.getPlayer().getLocation(), true);
}
} }
@Override @Override

View File

@@ -1,9 +1,6 @@
package com.massivecraft.factions.cmd.claim; package com.massivecraft.factions.cmd.claim;
import com.massivecraft.factions.Conf; import com.massivecraft.factions.*;
import com.massivecraft.factions.FLocation;
import com.massivecraft.factions.Faction;
import com.massivecraft.factions.FactionsPlugin;
import com.massivecraft.factions.cmd.Aliases; import com.massivecraft.factions.cmd.Aliases;
import com.massivecraft.factions.cmd.CommandContext; import com.massivecraft.factions.cmd.CommandContext;
import com.massivecraft.factions.cmd.CommandRequirements; import com.massivecraft.factions.cmd.CommandRequirements;
@@ -59,8 +56,14 @@ public class CmdClaim extends FCommand {
return; return;
} }
Faction at = Board.getInstance().getFactionAt(new FLocation(context.fPlayer.getPlayer().getLocation()));
if (radius < 2) { if (radius < 2) {
// single chunk if (FactionsPlugin.cachedRadiusClaim && context.fPlayer.attemptClaim(forFaction, context.player.getLocation(), false)) {
context.fPlayer.getFaction().getFPlayersWhereOnline(true).forEach(f -> f.msg(TL.CLAIM_CLAIMED, context.fPlayer.describeTo(f, true), context.fPlayer.getFaction().describeTo(f), at.describeTo(f)));
FactionsPlugin.instance.logFactionEvent(forFaction, FLogType.CHUNK_CLAIMS, context.fPlayer.getName(), CC.GreenB + "CLAIMED", "1", (new FLocation(context.fPlayer.getPlayer().getLocation())).formatXAndZ(","));
return;
}
context.fPlayer.attemptClaim(forFaction, context.player.getLocation(), true); context.fPlayer.attemptClaim(forFaction, context.player.getLocation(), true);
FactionsPlugin.instance.logFactionEvent(forFaction, FLogType.CHUNK_CLAIMS, context.fPlayer.getName(), CC.GreenB + "CLAIMED", "1", (new FLocation(context.fPlayer.getPlayer().getLocation())).formatXAndZ(",")); FactionsPlugin.instance.logFactionEvent(forFaction, FLogType.CHUNK_CLAIMS, context.fPlayer.getName(), CC.GreenB + "CLAIMED", "1", (new FLocation(context.fPlayer.getPlayer().getLocation())).formatXAndZ(","));
} else { } else {
@@ -68,16 +71,17 @@ public class CmdClaim extends FCommand {
if (!Permission.CLAIM_RADIUS.has(context.sender, true)) { if (!Permission.CLAIM_RADIUS.has(context.sender, true)) {
return; return;
} }
new SpiralTask(new FLocation(context.player), radius) { new SpiralTask(new FLocation(context.player), radius) {
private final int limit = Conf.radiusClaimFailureLimit - 1; private final int limit = Conf.radiusClaimFailureLimit - 1;
private int failCount = 0; private int failCount = 0;
private int successfulClaims = 0;
@Override @Override
public boolean work() { public boolean work() {
boolean success = context.fPlayer.attemptClaim(forFaction, this.currentLocation(), true); boolean success = context.fPlayer.attemptClaim(forFaction, this.currentLocation(), true);
if (success) { if (success) {
failCount = 0; failCount = 0;
successfulClaims++;
FactionsPlugin.instance.logFactionEvent(forFaction, FLogType.CHUNK_CLAIMS, context.fPlayer.getName(), CC.GreenB + "CLAIMED", "1", (new FLocation(context.fPlayer.getPlayer().getLocation())).formatXAndZ(",")); FactionsPlugin.instance.logFactionEvent(forFaction, FLogType.CHUNK_CLAIMS, context.fPlayer.getName(), CC.GreenB + "CLAIMED", "1", (new FLocation(context.fPlayer.getPlayer().getLocation())).formatXAndZ(","));
} else if (failCount++ >= limit) { } else if (failCount++ >= limit) {
this.stop(); this.stop();
@@ -85,6 +89,15 @@ public class CmdClaim extends FCommand {
} }
return true; return true;
} }
public void finish() {
if (FactionsPlugin.cachedRadiusClaim) {
if (successfulClaims > 0) {
context.fPlayer.getFaction().getFPlayersWhereOnline(true).forEach(f -> f.msg(TL.CLAIM_RADIUS_CLAIM, context.fPlayer.describeTo(f, true), String.valueOf(successfulClaims), context.fPlayer.getPlayer().getLocation().getChunk().getX(), context.fPlayer.getPlayer().getLocation().getChunk().getZ()));
stop();
}
}
}
}; };
} }
} }

View File

@@ -2,6 +2,7 @@ package com.massivecraft.factions.cmd.claim;
import com.massivecraft.factions.Board; import com.massivecraft.factions.Board;
import com.massivecraft.factions.FLocation; import com.massivecraft.factions.FLocation;
import com.massivecraft.factions.Faction;
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;
@@ -39,6 +40,15 @@ public class CmdClaimAt extends FCommand {
int x = context.argAsInt(1); int x = context.argAsInt(1);
int z = context.argAsInt(2); int z = context.argAsInt(2);
FLocation location = new FLocation(context.argAsString(0), x, z); FLocation location = new FLocation(context.argAsString(0), x, z);
Faction at = Board.getInstance().getFactionAt(new FLocation(context.fPlayer.getPlayer().getLocation()));
if (FactionsPlugin.cachedRadiusClaim && context.fPlayer.attemptClaim(context.fPlayer.getFaction(), context.player.getLocation(), true)) {
context.fPlayer.getFaction().getFPlayersWhereOnline(true).forEach(f -> f.msg(TL.CLAIM_CLAIMED, context.fPlayer.describeTo(f, true), context.fPlayer.getFaction().describeTo(f), at.describeTo(f)));
FactionsPlugin.instance.logFactionEvent(context.fPlayer.getFaction(), FLogType.CHUNK_CLAIMS, context.fPlayer.getName(), CC.GreenB + "CLAIMED", "1", (new FLocation(context.fPlayer.getPlayer().getLocation())).formatXAndZ(","));
showMap(context);
return;
}
context.fPlayer.attemptClaim(context.faction, location, true); context.fPlayer.attemptClaim(context.faction, location, true);
FactionsPlugin.instance.logFactionEvent(context.fPlayer.getFaction(), FLogType.CHUNK_CLAIMS, context.fPlayer.getName(), CC.GreenB + "CLAIMED", "1", (location).formatXAndZ(",")); FactionsPlugin.instance.logFactionEvent(context.fPlayer.getFaction(), FLogType.CHUNK_CLAIMS, context.fPlayer.getName(), CC.GreenB + "CLAIMED", "1", (location).formatXAndZ(","));
showMap(context); showMap(context);

View File

@@ -1,9 +1,6 @@
package com.massivecraft.factions.cmd.claim; package com.massivecraft.factions.cmd.claim;
import com.massivecraft.factions.Conf; import com.massivecraft.factions.*;
import com.massivecraft.factions.FLocation;
import com.massivecraft.factions.Faction;
import com.massivecraft.factions.FactionsPlugin;
import com.massivecraft.factions.cmd.Aliases; import com.massivecraft.factions.cmd.Aliases;
import com.massivecraft.factions.cmd.CommandContext; import com.massivecraft.factions.cmd.CommandContext;
import com.massivecraft.factions.cmd.CommandRequirements; import com.massivecraft.factions.cmd.CommandRequirements;
@@ -71,6 +68,7 @@ public class CmdClaimLine extends FCommand {
} }
final Faction forFaction = context.argAsFaction(2, context.faction); final Faction forFaction = context.argAsFaction(2, context.faction);
Faction at = Board.getInstance().getFactionAt(new FLocation(context.fPlayer.getPlayer().getLocation()));
if (forFaction != context.fPlayer.getFaction()) { if (forFaction != context.fPlayer.getFaction()) {
if (!context.fPlayer.isAdminBypassing()) { if (!context.fPlayer.isAdminBypassing()) {
@@ -84,11 +82,20 @@ public class CmdClaimLine extends FCommand {
Location location = context.player.getLocation(); Location location = context.player.getLocation();
// TODO: make this a task like claiming a radius? // TODO: make this a task like claiming a radius?
int claims = 0;
for (int i = 0; i < amount; i++) { for (int i = 0; i < amount; i++) {
context.fPlayer.attemptClaim(forFaction, location, true); if (FactionsPlugin.cachedRadiusClaim && context.fPlayer.attemptClaim(forFaction, context.player.getLocation(), false)) {
claims++;
} else {
context.fPlayer.attemptClaim(forFaction, location, true);
claims++;
}
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(","));
} }
int cachedClaims = claims;
context.fPlayer.getFaction().getFPlayersWhereOnline(true).forEach(f -> f.msg(TL.CLAIM_RADIUS_CLAIM, context.fPlayer.describeTo(f, true), String.valueOf(cachedClaims), context.fPlayer.getPlayer().getLocation().getChunk().getX(), context.fPlayer.getPlayer().getLocation().getChunk().getZ()));
} }
@Override @Override

View File

@@ -31,13 +31,16 @@ public class CmdUnclaim extends FCommand {
this.requirements = new CommandRequirements.Builder(Permission.UNCLAIM) this.requirements = new CommandRequirements.Builder(Permission.UNCLAIM)
.playerOnly() .playerOnly()
.memberOnly()
.withAction(PermissableAction.TERRITORY) .withAction(PermissableAction.TERRITORY)
.build(); .build();
} }
@Override @Override
public void perform(CommandContext context) { public void perform(CommandContext context) {
if (!context.fPlayer.isAdminBypassing() && !context.fPlayer.hasFaction()) {
context.fPlayer.msg(TL.GENERIC_MEMBERONLY);
return;
}
if (context.args.size() == 2) { if (context.args.size() == 2) {
Faction target = context.argAsFaction(1); Faction target = context.argAsFaction(1);
@@ -63,6 +66,11 @@ public class CmdUnclaim extends FCommand {
boolean didUnClaim = unClaim(new FLocation(context.player), context); boolean didUnClaim = unClaim(new FLocation(context.player), context);
if (didUnClaim && !context.fPlayer.canFlyAtLocation()) if (didUnClaim && !context.fPlayer.canFlyAtLocation())
context.fPlayer.setFFlying(false, false); context.fPlayer.setFFlying(false, false);
for(FPlayer fPlayer : context.faction.getFPlayersWhereOnline(true)){
if(!fPlayer.canFlyAtLocation())
fPlayer.setFFlying(false, false);
}
} else { } else {
// radius claim // radius claim
if (!Permission.CLAIM_RADIUS.has(context.sender, false)) { if (!Permission.CLAIM_RADIUS.has(context.sender, false)) {
@@ -83,10 +91,13 @@ public class CmdUnclaim extends FCommand {
this.stop(); this.stop();
return false; return false;
} }
return true; return true;
} }
}; };
boolean didUnClaim = unClaim(new FLocation(context.player), context);
if (didUnClaim && !context.fPlayer.canFlyAtLocation())
context.fPlayer.setFFlying(false, false);
} }
} }

View File

@@ -57,14 +57,8 @@ public class CmdUnclaimall extends FCommand {
} }
if (Econ.shouldBeUsed()) { if (Econ.shouldBeUsed()) {
double refund = Econ.calculateTotalLandRefund(target.getLandRounded()); double refund = Econ.calculateTotalLandRefund(target.getLandRounded());
if (Conf.bankEnabled && Conf.bankFactionPaysLandCosts) { if (!Econ.modifyMoney(target, refund, TL.COMMAND_UNCLAIMALL_TOUNCLAIM.toString(), TL.COMMAND_UNCLAIMALL_FORUNCLAIM.toString())) {
if (!Econ.modifyMoney(target, refund, TL.COMMAND_UNCLAIMALL_TOUNCLAIM.toString(), TL.COMMAND_UNCLAIMALL_FORUNCLAIM.toString())) { return;
return;
}
} else {
if (!Econ.modifyMoney(target, refund, TL.COMMAND_UNCLAIMALL_TOUNCLAIM.toString(), TL.COMMAND_UNCLAIMALL_FORUNCLAIM.toString())) {
return;
}
} }
} }

View File

@@ -37,7 +37,7 @@ public class CmdGrace extends FCommand {
return; return;
} }
if(context.args.size() == 1) { if (context.args.size() == 1) {
if (context.sender.hasPermission(String.valueOf(Permission.GRACETOGGLE))) { if (context.sender.hasPermission(String.valueOf(Permission.GRACETOGGLE))) {
if (context.argAsString(0).equalsIgnoreCase("on") || context.argAsString(0).equalsIgnoreCase("start")) { if (context.argAsString(0).equalsIgnoreCase("on") || context.argAsString(0).equalsIgnoreCase("start")) {
FactionsPlugin.getInstance().getTimerManager().graceTimer.setPaused(false); FactionsPlugin.getInstance().getTimerManager().graceTimer.setPaused(false);
@@ -61,7 +61,7 @@ public class CmdGrace extends FCommand {
} }
} }
if(FactionsPlugin.getInstance().getTimerManager().graceTimer.getRemaining() <= 0L) { if (FactionsPlugin.getInstance().getTimerManager().graceTimer.getRemaining() <= 0L) {
context.fPlayer.msg(TL.COMMAND_GRACE_DISABLED_NO_FORMAT.toString()); context.fPlayer.msg(TL.COMMAND_GRACE_DISABLED_NO_FORMAT.toString());
} else { } else {
context.fPlayer.msg(TL.COMMAND_GRACE_TIME_REMAINING, String.valueOf(TimerManager.getRemaining(FactionsPlugin.getInstance().getTimerManager().graceTimer.getRemaining(), true))); context.fPlayer.msg(TL.COMMAND_GRACE_TIME_REMAINING, String.valueOf(TimerManager.getRemaining(FactionsPlugin.getInstance().getTimerManager().graceTimer.getRemaining(), true)));

View File

@@ -39,9 +39,9 @@ public abstract class FRelationCommand extends FCommand {
@Override @Override
public void perform(CommandContext context) { public void perform(CommandContext context) {
Faction them = context.argAsFaction(0); Faction them = context.argAsFaction(0);
if (them == null) { if (them == null) return;
return;
} if (!context.faction.isNormal()) return;
if (!them.isNormal()) { if (!them.isNormal()) {
context.msg(TL.COMMAND_RELATIONS_ALLTHENOPE); context.msg(TL.COMMAND_RELATIONS_ALLTHENOPE);

View File

@@ -57,6 +57,16 @@ public class FPromoteCommand extends FCommand {
context.msg(TL.COMMAND_PROMOTE_NOT_SAME); context.msg(TL.COMMAND_PROMOTE_NOT_SAME);
return; return;
} }
// Don't allow people to promote people with same or higher rank than their.
if (context.fPlayer.getRole().value <= target.getRole().value) {
context.msg(TL.COMMAND_PROMOTE_HIGHER_RANK, target.getName());
return;
}
// Don't allow people to demote people who already have the lowest rank.
if (current.value == 0 && relative <= 0) {
context.msg(TL.COMMAND_PROMOTE_LOWEST_RANK, target.getName());
return;
}
// Don't allow people to promote people to their same or higher rank. // Don't allow people to promote people to their same or higher rank.
if (context.fPlayer.getRole().value <= promotion.value) { if (context.fPlayer.getRole().value <= promotion.value) {
context.msg(TL.COMMAND_PROMOTE_NOT_ALLOWED); context.msg(TL.COMMAND_PROMOTE_NOT_ALLOWED);
@@ -64,11 +74,20 @@ public class FPromoteCommand extends FCommand {
} }
} }
if (promotion == null) { if (target.isAlt()) {
context.msg(TL.COMMAND_PROMOTE_NOTTHATPLAYER);
return; return;
} }
// Don't allow people to demote people who already have the lowest rank.
if (current.value == 0 && relative <= 0) {
context.msg(TL.COMMAND_PROMOTE_LOWEST_RANK, target.getName());
return;
}
// Don't allow people to promote people who already have the highest rank.
if (current.value == 4 && relative > 0) {
context.msg(TL.COMMAND_PROMOTE_HIGHEST_RANK, target.getName());
return;
}
// Don't allow people to promote people to their same or higher rnak. // Don't allow people to promote people to their same or higher rnak.
if (context.fPlayer.getRole().value <= promotion.value) { if (context.fPlayer.getRole().value <= promotion.value) {
context.msg(TL.COMMAND_PROMOTE_NOT_ALLOWED); context.msg(TL.COMMAND_PROMOTE_NOT_ALLOWED);

View File

@@ -1,10 +1,7 @@
package com.massivecraft.factions.cmd.wild; package com.massivecraft.factions.cmd.wild;
import com.massivecraft.factions.Board; import com.massivecraft.factions.*;
import com.massivecraft.factions.FLocation;
import com.massivecraft.factions.FPlayers;
import com.massivecraft.factions.FactionsPlugin;
import com.massivecraft.factions.cmd.Aliases; import com.massivecraft.factions.cmd.Aliases;
import com.massivecraft.factions.cmd.CommandContext; import com.massivecraft.factions.cmd.CommandContext;
import com.massivecraft.factions.cmd.CommandRequirements; import com.massivecraft.factions.cmd.CommandRequirements;
@@ -22,8 +19,12 @@ import org.bukkit.potion.PotionEffectType;
import java.util.HashMap; import java.util.HashMap;
import java.util.HashSet; import java.util.HashSet;
import java.util.Objects;
import java.util.Random; import java.util.Random;
/**
* @author DroppingAnvil
*/
public class CmdWild extends FCommand implements WaitedTask { public class CmdWild extends FCommand implements WaitedTask {
public static HashMap<Player, String> teleportRange; public static HashMap<Player, String> teleportRange;
public static HashSet<Player> teleporting; public static HashSet<Player> teleporting;
@@ -44,8 +45,6 @@ public class CmdWild extends FCommand implements WaitedTask {
public void perform(CommandContext context) { public void perform(CommandContext context) {
if (!teleportRange.containsKey(context.player)) { if (!teleportRange.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);
} }
} }
@@ -55,16 +54,18 @@ public class CmdWild extends FCommand implements WaitedTask {
int tries = 0; int tries = 0;
ConfigurationSection c = FactionsPlugin.getInstance().getConfig().getConfigurationSection("Wild.Zones." + teleportRange.get(p)); ConfigurationSection c = FactionsPlugin.getInstance().getConfig().getConfigurationSection("Wild.Zones." + teleportRange.get(p));
while (tries < 5) { while (tries < 5) {
assert c != null;
int x = new Random().nextInt((c.getInt("Range.MaxX") - c.getInt("Range.MinX")) + 1) + c.getInt("Range.MinX"); int x = new Random().nextInt((c.getInt("Range.MaxX") - c.getInt("Range.MinX")) + 1) + c.getInt("Range.MinX");
int z = new Random().nextInt((c.getInt("Range.MaxZ") - c.getInt("Range.MinZ")) + 1) + c.getInt("Range.MinZ"); int z = new Random().nextInt((c.getInt("Range.MaxZ") - c.getInt("Range.MinZ")) + 1) + c.getInt("Range.MinZ");
if (Board.getInstance().getFactionAt(new FLocation(p.getWorld().getName(), x, z)).isWilderness()) { if (Board.getInstance().getFactionAt(new FLocation(p.getWorld().getName(), x, z)).isWilderness()) {
success = true; success = true;
FLocation loc = new FLocation(p.getWorld().getName(), x, z); FLocation loc = new FLocation(Objects.requireNonNull(c.getString("World", "World")), x, z);
teleportRange.remove(p); teleportRange.remove(p);
if (!FPlayers.getInstance().getByPlayer(p).takeMoney(c.getInt("Cost"))) { if (!FPlayers.getInstance().getByPlayer(p).takeMoney(c.getInt("Cost"))) {
p.sendMessage(TL.GENERIC_NOTENOUGHMONEY.toString()); p.sendMessage(TL.GENERIC_NOTENOUGHMONEY.toString());
return; return;
} }
if (Conf.wildLoadChunkBeforeTeleport && !loc.getChunk().isLoaded()) loc.getChunk().load();
teleportPlayer(p, loc); teleportPlayer(p, loc);
break; break;
} }
@@ -72,15 +73,16 @@ public class CmdWild extends FCommand implements WaitedTask {
} }
if (!success) { if (!success) {
p.sendMessage(TL.COMMAND_WILD_FAILED.toString()); p.sendMessage(TL.COMMAND_WILD_FAILED.toString());
teleportRange.remove(p);
} }
} }
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(loc.getWorld(), loc.getX(), loc.getWorld().getHighestBlockYAt(Math.round(loc.getX()), Math.round(loc.getZ())) + FactionsPlugin.getInstance().getConfig().getInt("Wild.Arrival.SpawnAboveBlocks", 1), loc.getZ());
} else { } else {
finalLoc = new Location(p.getWorld(), loc.getX(), p.getWorld().getHighestBlockYAt(Math.round(loc.getX()), Math.round(loc.getZ())), loc.getZ()); finalLoc = new Location(loc.getWorld(), loc.getX(), loc.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);
@@ -89,7 +91,7 @@ public class CmdWild extends FCommand implements WaitedTask {
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(Objects.requireNonNull(PotionEffectType.getByName(s)), 40, 1));
} }
} }
@@ -111,6 +113,6 @@ public class CmdWild extends FCommand implements WaitedTask {
@Override @Override
public void handleFailure(Player player) { public void handleFailure(Player player) {
player.sendMessage(TL.COMMAND_WILD_INTERUPTED.toString()); player.sendMessage(TL.COMMAND_WILD_INTERUPTED.toString());
teleportRange.remove(player);
} }
}
}

View File

@@ -20,6 +20,9 @@ import java.util.HashMap;
import java.util.List; import java.util.List;
import java.util.Objects; import java.util.Objects;
/**
* @author DroppingAnvil
*/
public class WildGUI implements FactionGUI { public class WildGUI implements FactionGUI {
Player player; Player player;
FPlayer fplayer; FPlayer fplayer;
@@ -37,7 +40,7 @@ public class WildGUI implements FactionGUI {
if (map.containsKey(slot)) { if (map.containsKey(slot)) {
String zone = map.get(slot); String zone = map.get(slot);
if (fplayer.hasMoney(FactionsPlugin.getInstance().getConfig().getInt("Wild.Zones." + zone + ".Cost"))) { if (fplayer.hasMoney(FactionsPlugin.getInstance().getConfig().getInt("Wild.Zones." + zone + ".Cost"))) {
WaitExecutor.taskMap.put(player, new WaitTask(FactionsPlugin.getInstance().getConfig().getInt("Wild.Wait"), TL.COMMAND_WILD_INPROGRESS, player, CmdWild.instance)); WaitExecutor.taskMap.put(player, new WaitTask(FactionsPlugin.getInstance().getConfig().getInt("Wild.Wait"), TL.COMMAND_WILD_WAIT, player, CmdWild.instance));
CmdWild.teleportRange.put(player, zone); CmdWild.teleportRange.put(player, zone);
fplayer.msg(TL.COMMAND_WILD_WAIT, FactionsPlugin.getInstance().getConfig().getInt("Wild.Wait") + " Seconds"); fplayer.msg(TL.COMMAND_WILD_WAIT, FactionsPlugin.getInstance().getConfig().getInt("Wild.Wait") + " Seconds");
player.closeInventory(); player.closeInventory();
@@ -57,7 +60,8 @@ public class WildGUI implements FactionGUI {
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")).get().parseItem(); ItemStack zoneItem = XMaterial.matchXMaterial(Objects.requireNonNull(FactionsPlugin.getInstance().getConfig().getString("Wild.Zones." + key + ".Material"))).get().parseItem();
assert zoneItem != null;
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<>();

View File

@@ -1,6 +1,5 @@
package com.massivecraft.factions.event; package com.massivecraft.factions.event;
import com.massivecraft.factions.Conf;
import com.massivecraft.factions.FPlayer; import com.massivecraft.factions.FPlayer;
import com.massivecraft.factions.Faction; import com.massivecraft.factions.Faction;
import org.bukkit.event.Cancellable; import org.bukkit.event.Cancellable;
@@ -10,51 +9,20 @@ import org.bukkit.event.Cancellable;
*/ */
public class PowerRegenEvent extends FactionPlayerEvent implements Cancellable { public class PowerRegenEvent extends FactionPlayerEvent implements Cancellable {
/**
* @author Illyria Team
*/
private boolean cancelled = false; private boolean cancelled = false;
private double modified = 0; private double delta;
public PowerRegenEvent(Faction f, FPlayer p) { public PowerRegenEvent(Faction f, FPlayer p, double delta) {
super(f, p); super(f, p);
this.delta = delta;
} }
/** public double getDelta() {
* Get the amount of power this player will regen by default return delta;
*
* @return power amount gained as a Double.
*/
public double getDefaultPowerGained() {
return fPlayer.getMillisPassed() * Conf.powerPerMinute / 60000;
} }
/** public void setDelta(double delta) {
* Get the amount of custom power this player will gain. Ignored if less than or equal to 0. this.delta = delta;
*
* @return Custom power as a double
*/
public double getCustomPower() {
return modified;
}
/**
* Set the custom power gain for this event.
*
* @param gain Amount of power to be added to player.
*/
public void setCustomPower(Double gain) {
modified = gain;
}
/**
* Get if we will be using the custom power gain instead of default.
*
* @return If we will process the event custom returned as a Boolean.
*/
public boolean usingCustomPower() {
return modified > 0;
} }
@Override @Override
@@ -67,4 +35,4 @@ public class PowerRegenEvent extends FactionPlayerEvent implements Cancellable {
this.cancelled = c; this.cancelled = c;
} }
} }

View File

@@ -32,9 +32,8 @@ public class Econ {
private static Economy econ = null; private static Economy econ = null;
public static void setup() { public static void setup() {
if (isSetup()) { if (isSetup()) return;
return;
}
String integrationFail = "Economy integration is " + (Conf.econEnabled ? "enabled, but" : "disabled, and") + " the plugin \"Vault\" "; String integrationFail = "Economy integration is " + (Conf.econEnabled ? "enabled, but" : "disabled, and") + " the plugin \"Vault\" ";
@@ -42,20 +41,15 @@ public class Econ {
FactionsPlugin.getInstance().log(integrationFail + "is not installed."); FactionsPlugin.getInstance().log(integrationFail + "is not installed.");
return; return;
} }
RegisteredServiceProvider<Economy> rsp = Bukkit.getServer().getServicesManager().getRegistration(Economy.class); RegisteredServiceProvider<Economy> rsp = Bukkit.getServer().getServicesManager().getRegistration(Economy.class);
if (rsp == null) { if (rsp == null) {
FactionsPlugin.getInstance().log(integrationFail + "is not hooked into an economy plugin."); FactionsPlugin.getInstance().log(integrationFail + "is not hooked into an economy plugin.");
return; return;
} }
econ = rsp.getProvider(); econ = rsp.getProvider();
FactionsPlugin.getInstance().log("Economy integration through Vault plugin successful."); FactionsPlugin.getInstance().log("Economy integration through Vault plugin successful.");
if (!Conf.econEnabled)
if (!Conf.econEnabled) {
FactionsPlugin.getInstance().log("NOTE: Economy is disabled. You can enable it with the command: f config econEnabled true"); FactionsPlugin.getInstance().log("NOTE: Economy is disabled. You can enable it with the command: f config econEnabled true");
}
//FactionsPlugin.getInstance().cmdBase.cmdHelp.updateHelp(); //FactionsPlugin.getInstance().cmdBase.cmdHelp.updateHelp();
} }
@@ -68,26 +62,24 @@ public class Econ {
} }
public static void modifyUniverseMoney(double delta) { public static void modifyUniverseMoney(double delta) {
if (!shouldBeUsed()) { if (!shouldBeUsed()) return;
return; if (Conf.econUniverseAccount == null) return;
} if (Conf.econUniverseAccount.length() == 0) return;
if (!econ.hasAccount(Conf.econUniverseAccount)) return;
if (Conf.econUniverseAccount == null) {
return;
}
if (Conf.econUniverseAccount.length() == 0) {
return;
}
if (!econ.hasAccount(Conf.econUniverseAccount)) {
return;
}
modifyBalance(Conf.econUniverseAccount, delta); modifyBalance(Conf.econUniverseAccount, delta);
} }
public static void sendBalanceInfo(FPlayer to, EconomyParticipator about) {
if (!shouldBeUsed()) {
FactionsPlugin.instance.log(Level.WARNING, "Vault does not appear to be hooked into an economy plugin.");
return;
}
to.msg(TL.ECON_PLAYERBALANCE, about.describeTo(to, true), Econ.moneyString(econ.getBalance(about.getAccountId())));
}
public static void sendBalanceInfo(CommandSender to, Faction about) { public static void sendBalanceInfo(CommandSender to, Faction about) {
if (!shouldBeUsed()) { if (!shouldBeUsed()) {
FactionsPlugin.getInstance().log(Level.WARNING, "Vault does not appear to be hooked into an economy plugin."); FactionsPlugin.instance.log(Level.WARNING, "Vault does not appear to be hooked into an economy plugin.");
return; return;
} }
to.sendMessage(String.format(TL.ECON_PLAYERBALANCE.toString(), about.getTag(), Econ.moneyString(econ.getBalance(about.getAccountId())))); to.sendMessage(String.format(TL.ECON_PLAYERBALANCE.toString(), about.getTag(), Econ.moneyString(econ.getBalance(about.getAccountId()))));
@@ -98,37 +90,20 @@ public class Econ {
Faction fYou = RelationUtil.getFaction(you); Faction fYou = RelationUtil.getFaction(you);
// This is a system invoker. Accept it. // This is a system invoker. Accept it.
if (fI == null) { if (fI == null) return true;
return true;
}
// Bypassing players can do any kind of transaction // Bypassing players can do any kind of transaction
if (i instanceof FPlayer && ((FPlayer) i).isAdminBypassing()) { if (i instanceof FPlayer && ((FPlayer) i).isAdminBypassing()) return true;
return true;
}
// Players with the any withdraw can do. // Players with the any withdraw can do.
if (i instanceof FPlayer && Permission.MONEY_WITHDRAW_ANY.has(((FPlayer) i).getPlayer())) { if (i instanceof FPlayer && Permission.MONEY_WITHDRAW_ANY.has(((FPlayer) i).getPlayer())) return true;
return true;
}
// You can deposit to anywhere you feel like. It's your loss if you can't withdraw it again. // You can deposit to anywhere you feel like. It's your loss if you can't withdraw it again.
if (i == you) { if (i == you) return true;
return true;
}
// A faction can always transfer away the money of it's members and its own money... // A faction can always transfer away the money of it's members and its own money...
// This will however probably never happen as a faction does not have free will. // This will however probably never happen as a faction does not have free will.
// Ohh by the way... Yes it could. For daily rent to the faction. // Ohh by the way... Yes it could. For daily rent to the faction.
if (i == fI && fI == fYou) { if (i == fI && fI == fYou) return true;
return true;
}
// Factions can be controlled by members that are moderators... or any member if any member can withdraw. // Factions can be controlled by members that are moderators... or any member if any member can withdraw.
if (i instanceof FPlayer && you instanceof Faction && fI == fYou && (Conf.bankMembersCanWithdraw || ((FPlayer) i).getRole().value >= Role.MODERATOR.value)) { if (you instanceof Faction && fI == fYou && (Conf.bankMembersCanWithdraw || (i instanceof FPlayer && ((FPlayer) i).getRole().value >= Role.MODERATOR.value)))
return true; return true;
}
// Otherwise you may not!;,,; // Otherwise you may not!;,,;
i.msg(TL.ECON_CANTCONTROLMONEY, i.describeTo(i, true), you.describeTo(i)); i.msg(TL.ECON_CANTCONTROLMONEY, i.describeTo(i, true), you.describeTo(i));
return false; return false;
@@ -140,7 +115,7 @@ public class Econ {
public static boolean transferMoney(EconomyParticipator invoker, EconomyParticipator from, EconomyParticipator to, double amount, boolean notify) { public static boolean transferMoney(EconomyParticipator invoker, EconomyParticipator from, EconomyParticipator to, double amount, boolean notify) {
if (!shouldBeUsed()) { if (!shouldBeUsed()) {
invoker.msg(TL.ECON_OFF); invoker.msg(TL.ECON_DISABLED);
return false; return false;
} }
@@ -154,30 +129,21 @@ public class Econ {
} }
// Check the rights // Check the rights
if (!canIControllYou(invoker, from)) { if (!canIControllYou(invoker, from)) return false;
return false;
}
OfflinePlayer fromAcc; OfflinePlayer fromAcc;
OfflinePlayer toAcc; OfflinePlayer toAcc;
if (isUUID(from.getAccountId())) { if (isUUID(from.getAccountId())) {
fromAcc = Bukkit.getOfflinePlayer(UUID.fromString(from.getAccountId())); fromAcc = Bukkit.getOfflinePlayer(UUID.fromString(from.getAccountId()));
if (fromAcc.getName() == null) { if (fromAcc.getName() == null) return false;
return false; } else fromAcc = Bukkit.getOfflinePlayer(from.getAccountId());
}
} else {
fromAcc = Bukkit.getOfflinePlayer(from.getAccountId());
}
if (isUUID(to.getAccountId())) { if (isUUID(to.getAccountId())) {
toAcc = Bukkit.getOfflinePlayer(UUID.fromString(to.getAccountId())); toAcc = Bukkit.getOfflinePlayer(UUID.fromString(to.getAccountId()));
if (toAcc.getName() == null) { if (toAcc.getName() == null) return false;
return false; } else toAcc = Bukkit.getOfflinePlayer(to.getAccountId());
}
} else {
toAcc = Bukkit.getOfflinePlayer(to.getAccountId());
}
// Is there enough money for the transaction to happen? // Is there enough money for the transaction to happen?
if (!econ.has(fromAcc, amount)) { if (!econ.has(fromAcc, amount)) {
@@ -185,13 +151,6 @@ public class Econ {
if (invoker != null && notify) { if (invoker != null && notify) {
invoker.msg(TL.COMMAND_MONEYTRANSFERFF_TRANSFERCANTAFFORD, from.describeTo(invoker, true), moneyString(amount), to.describeTo(invoker)); invoker.msg(TL.COMMAND_MONEYTRANSFERFF_TRANSFERCANTAFFORD, from.describeTo(invoker, true), moneyString(amount), to.describeTo(invoker));
} }
return false;
}
// Check if the new balance is over Essential's money cap.
if (Essentials.isOverBalCap(to, econ.getBalance(toAcc) + amount)) {
invoker.msg(TL.ECON_OVER_BAL_CAP, amount);
return false; return false;
} }
@@ -201,21 +160,15 @@ public class Econ {
if (erw.transactionSuccess()) { if (erw.transactionSuccess()) {
EconomyResponse erd = econ.depositPlayer(toAcc, amount); EconomyResponse erd = econ.depositPlayer(toAcc, amount);
if (erd.transactionSuccess()) { if (erd.transactionSuccess()) {
if (notify) { if (notify) sendTransferInfo(invoker, from, to, amount);
sendTransferInfo(invoker, from, to, amount);
}
return true; return true;
} else { } else econ.depositPlayer(fromAcc, amount);
// transaction failed, refund account
econ.depositPlayer(fromAcc, amount);
}
} }
// if we get here something with the transaction failed // if we get here something with the transaction failed
if (notify) { if (notify)
invoker.msg(TL.ECON_UNABLETOTRANSFER, moneyString(amount), to.describeTo(invoker), from.describeTo(invoker, true)); invoker.msg(TL.ECON_UNABLETOTRANSFER, moneyString(amount), to.describeTo(invoker), from.describeTo(invoker, true));
}
return false; return false;
} }
@@ -240,28 +193,22 @@ public class Econ {
recipients.addAll(getFplayers(to)); recipients.addAll(getFplayers(to));
if (invoker == null) { if (invoker == null) {
for (FPlayer recipient : recipients) { for (FPlayer recipient : recipients)
recipient.msg(TL.ECON_MONEYTRASFERREDFROM, moneyString(amount), from.describeTo(recipient), to.describeTo(recipient)); recipient.msg(TL.ECON_MONEYTRASFERREDFROM, moneyString(amount), from.describeTo(recipient), to.describeTo(recipient));
}
} else if (invoker == from) { } else if (invoker == from) {
for (FPlayer recipient : recipients) { for (FPlayer recipient : recipients)
recipient.msg(TL.ECON_PERSONGAVEMONEYTO, from.describeTo(recipient, true), moneyString(amount), to.describeTo(recipient)); recipient.msg(TL.ECON_PERSONGAVEMONEYTO, from.describeTo(recipient, true), moneyString(amount), to.describeTo(recipient));
}
} else if (invoker == to) { } else if (invoker == to) {
for (FPlayer recipient : recipients) { for (FPlayer recipient : recipients)
recipient.msg(TL.ECON_PERSONTOOKMONEYFROM, to.describeTo(recipient, true), moneyString(amount), from.describeTo(recipient)); recipient.msg(TL.ECON_PERSONTOOKMONEYFROM, to.describeTo(recipient, true), moneyString(amount), from.describeTo(recipient));
}
} else { } else {
for (FPlayer recipient : recipients) { for (FPlayer recipient : recipients)
recipient.msg(TL.ECON_MONEYTRASFERREDFROMPERSONTOPERSON, invoker.describeTo(recipient, true), moneyString(amount), from.describeTo(recipient), to.describeTo(recipient)); recipient.msg(TL.ECON_MONEYTRASFERREDFROMPERSONTOPERSON, invoker.describeTo(recipient, true), moneyString(amount), from.describeTo(recipient), to.describeTo(recipient));
}
} }
} }
public static boolean hasAtLeast(EconomyParticipator ep, double delta, String toDoThis) { public static boolean hasAtLeast(EconomyParticipator ep, double delta, String toDoThis) {
if (!shouldBeUsed()) { if (!shouldBeUsed()) return true;
return true;
}
// going the hard way round as econ.has refuses to work. // going the hard way round as econ.has refuses to work.
boolean affordable = false; boolean affordable = false;
@@ -269,85 +216,59 @@ public class Econ {
if (isUUID(ep.getAccountId())) { if (isUUID(ep.getAccountId())) {
OfflinePlayer offline = Bukkit.getOfflinePlayer(UUID.fromString(ep.getAccountId())); OfflinePlayer offline = Bukkit.getOfflinePlayer(UUID.fromString(ep.getAccountId()));
if (offline.getName() != null) { if (offline.getName() != null)
currentBalance = econ.getBalance(Bukkit.getOfflinePlayer(UUID.fromString(ep.getAccountId()))); currentBalance = econ.getBalance(Bukkit.getOfflinePlayer(UUID.fromString(ep.getAccountId())));
} else { else currentBalance = 0;
currentBalance = 0; } else currentBalance = econ.getBalance(ep.getAccountId());
} if (currentBalance >= delta) affordable = true;
} else {
currentBalance = econ.getBalance(ep.getAccountId());
}
if (currentBalance >= delta) {
affordable = true;
}
if (!affordable) { if (!affordable) {
if (toDoThis != null && !toDoThis.isEmpty()) { if (toDoThis != null && !toDoThis.isEmpty())
ep.msg(TL.COMMAND_MONEY_CANTAFFORD, ep.describeTo(ep, true), moneyString(delta), toDoThis); ep.msg(TL.COMMAND_MONEY_CANTAFFORD, ep.describeTo(ep, true), moneyString(delta), toDoThis);
}
return false; return false;
} }
return true; return true;
} }
public static boolean modifyMoney(EconomyParticipator ep, double delta, String toDoThis, String forDoingThis) { public static boolean modifyMoney(EconomyParticipator ep, double delta, String toDoThis, String forDoingThis) {
if (!shouldBeUsed()) { if (!shouldBeUsed()) return false;
return false;
}
OfflinePlayer acc; OfflinePlayer acc;
if (isUUID(ep.getAccountId())) { if (isUUID(ep.getAccountId())) {
acc = Bukkit.getOfflinePlayer(UUID.fromString(ep.getAccountId())); acc = Bukkit.getOfflinePlayer(UUID.fromString(ep.getAccountId()));
if (acc.getName() == null) { if (acc.getName() == null) return false;
return false; } else acc = Bukkit.getOfflinePlayer(ep.getAccountId());
}
} else {
acc = Bukkit.getOfflinePlayer(ep.getAccountId());
}
String You = ep.describeTo(ep, true); String You = ep.describeTo(ep, true);
if (delta == 0) { if (delta == 0) return true;
// no money actually transferred? else if (delta > 0) {
// ep.msg("<h>%s<i> didn't have to pay anything %s.", You, forDoingThis); // might be for gains, might be for losses
return true;
}
if (delta > 0) {
// The player should gain money // The player should gain money
// The account might not have enough space // The account might not have enough space
EconomyResponse er = econ.depositPlayer(acc, delta); EconomyResponse er = econ.depositPlayer(acc, delta);
if (er.transactionSuccess()) { if (er.transactionSuccess()) {
modifyUniverseMoney(-delta); modifyUniverseMoney(-delta);
if (forDoingThis != null && !forDoingThis.isEmpty()) { if (forDoingThis != null && !forDoingThis.isEmpty())
ep.msg(TL.COMMAND_MONEY_GAINED, You, moneyString(delta), forDoingThis); ep.msg(TL.COMMAND_MONEY_GAINED, You, moneyString(delta), forDoingThis);
}
return true; return true;
} else { } else {
// transfer to account failed // transfer to account failed
if (forDoingThis != null && !forDoingThis.isEmpty()) { if (forDoingThis != null && !forDoingThis.isEmpty())
ep.msg(TL.ECON_DEPOSITFAILED, You, moneyString(delta), forDoingThis); ep.msg(TL.ECON_DEPOSITFAILED, You, moneyString(delta), forDoingThis);
}
return false; return false;
} }
} else { } else {
// The player should loose money // The player should loose money
// The player might not have enough. // The player might not have enough.
if (econ.has(acc, -delta) && econ.withdrawPlayer(acc, -delta).transactionSuccess()) { if (econ.has(acc, -delta) && econ.withdrawPlayer(acc, -delta).transactionSuccess()) {
// There is enough money to pay // There is enough money to pay
modifyUniverseMoney(-delta); modifyUniverseMoney(-delta);
if (forDoingThis != null && !forDoingThis.isEmpty()) { if (forDoingThis != null && !forDoingThis.isEmpty())
ep.msg(TL.ECON_MONEYLOST, You, moneyString(-delta), forDoingThis); ep.msg(TL.ECON_MONEYLOST, You, moneyString(-delta), forDoingThis);
}
return true; return true;
} else { } else {
// There was not enough money to pay // There was not enough money to pay
if (toDoThis != null && !toDoThis.isEmpty()) { if (toDoThis != null && !toDoThis.isEmpty())
ep.msg(TL.ECON_CANTAFFORD, You, moneyString(-delta), toDoThis); ep.msg(TL.ECON_CANTAFFORD, You, moneyString(-delta), toDoThis);
}
return false; return false;
} }
} }
@@ -359,10 +280,7 @@ public class Econ {
// calculate the cost for claiming land // calculate the cost for claiming land
public static double calculateClaimCost(int ownedLand, boolean takingFromAnotherFaction) { public static double calculateClaimCost(int ownedLand, boolean takingFromAnotherFaction) {
if (!shouldBeUsed()) { if (!shouldBeUsed()) return 0d;
return 0d;
}
// basic claim cost, plus land inflation cost, minus the potential bonus given for claiming from another faction // basic claim cost, plus land inflation cost, minus the potential bonus given for claiming from another faction
return Conf.econCostClaimWilderness + (Conf.econCostClaimWilderness * Conf.econClaimAdditionalMultiplier * ownedLand) - (takingFromAnotherFaction ? Conf.econCostClaimFromFactionBonus : 0); return Conf.econCostClaimWilderness + (Conf.econCostClaimWilderness * Conf.econClaimAdditionalMultiplier * ownedLand) - (takingFromAnotherFaction ? Conf.econCostClaimFromFactionBonus : 0);
} }
@@ -375,9 +293,7 @@ public class Econ {
// calculate value of all owned land // calculate value of all owned land
public static double calculateTotalLandValue(int ownedLand) { public static double calculateTotalLandValue(int ownedLand) {
double amount = 0; double amount = 0;
for (int x = 0; x < ownedLand; x++) { for (int x = 0; x < ownedLand; x++) amount += calculateClaimCost(x, false);
amount += calculateClaimCost(x, false);
}
return amount; return amount;
} }
@@ -401,9 +317,7 @@ public class Econ {
public static String getFriendlyBalance(UUID uuid) { public static String getFriendlyBalance(UUID uuid) {
OfflinePlayer offline = Bukkit.getOfflinePlayer(uuid); OfflinePlayer offline = Bukkit.getOfflinePlayer(uuid);
if (offline.getName() == null) { if (offline.getName() == null) return "0";
return "0";
}
return format.format(econ.getBalance(offline)); return format.format(econ.getBalance(offline));
} }
@@ -413,19 +327,13 @@ public class Econ {
public static boolean setBalance(String account, double amount) { public static boolean setBalance(String account, double amount) {
double current = econ.getBalance(account); double current = econ.getBalance(account);
if (current > amount) { if (current > amount) return econ.withdrawPlayer(account, current - amount).transactionSuccess();
return econ.withdrawPlayer(account, current - amount).transactionSuccess(); else return econ.depositPlayer(account, amount - current).transactionSuccess();
} else {
return econ.depositPlayer(account, amount - current).transactionSuccess();
}
} }
public static boolean modifyBalance(String account, double amount) { public static boolean modifyBalance(String account, double amount) {
if (amount < 0) { if (amount < 0) return econ.withdrawPlayer(account, -amount).transactionSuccess();
return econ.withdrawPlayer(account, -amount).transactionSuccess(); else return econ.depositPlayer(account, amount).transactionSuccess();
} else {
return econ.depositPlayer(account, amount).transactionSuccess();
}
} }
public static boolean deposit(String account, double amount) { public static boolean deposit(String account, double amount) {

View File

@@ -4,47 +4,30 @@ import com.earth2me.essentials.Teleport;
import com.earth2me.essentials.Trade; import com.earth2me.essentials.Trade;
import com.earth2me.essentials.User; import com.earth2me.essentials.User;
import com.massivecraft.factions.Conf; import com.massivecraft.factions.Conf;
import com.massivecraft.factions.iface.EconomyParticipator;
import net.ess3.api.IEssentials; import net.ess3.api.IEssentials;
import org.bukkit.Bukkit; import org.bukkit.Bukkit;
import org.bukkit.ChatColor; import org.bukkit.ChatColor;
import org.bukkit.Location; import org.bukkit.Location;
import org.bukkit.entity.Player; import org.bukkit.entity.Player;
import org.bukkit.event.player.PlayerTeleportEvent.TeleportCause; import org.bukkit.event.player.PlayerTeleportEvent.TeleportCause;
import org.bukkit.plugin.Plugin; import org.bukkit.metadata.MetadataValue;
import java.math.BigDecimal; import java.math.BigDecimal;
public class Essentials { public class Essentials {
/**
* @author FactionsUUID Team
*/
private static IEssentials essentials; private static IEssentials essentials;
public static void setup() { public static void setup() {
Plugin ess = Bukkit.getPluginManager().getPlugin("Essentials"); essentials = (IEssentials) Bukkit.getPluginManager().getPlugin("Essentials");
if (ess != null) {
essentials = (IEssentials) ess;
}
}
public static boolean isOverBalCap(EconomyParticipator participator, double amount) {
if (essentials == null) {
return false;
}
return amount > essentials.getSettings().getMaxMoney().doubleValue();
} }
// return false if feature is disabled or Essentials isn't available // return false if feature is disabled or Essentials isn't available
public static boolean handleTeleport(Player player, Location loc) { public static boolean handleTeleport(Player player, Location loc) {
if (!Conf.homesTeleportCommandEssentialsIntegration || essentials == null) { if (!Conf.homesTeleportCommandEssentialsIntegration || essentials == null) return false;
return false;
}
Teleport teleport = essentials.getUser(player).getTeleport(); Teleport teleport = essentials.getUser(player).getTeleport();
Trade trade = new Trade(new BigDecimal(Conf.econCostHome), essentials); Trade trade = new Trade(BigDecimal.valueOf(Conf.econCostHome), essentials);
try { try {
teleport.teleport(loc, trade, TeleportCause.PLUGIN); teleport.teleport(loc, trade, TeleportCause.PLUGIN);
} catch (Exception e) { } catch (Exception e) {
@@ -54,8 +37,21 @@ public class Essentials {
} }
public static boolean isVanished(Player player) { public static boolean isVanished(Player player) {
if (essentials == null) return false; // Edge case handling.
User user = essentials.getUser(player); if (player == null) return false;
return user != null && user.isVanished(); boolean vanish = false;
if (essentials != null) {
User user = essentials.getUser(player);
if (user != null && user.isVanished()) return true;
}
if (player.hasMetadata("vanished"))
for (MetadataValue meta : player.getMetadata("vanished")) {
if (meta == null) continue;
if (meta.asBoolean()) {
vanish = true;
break;
}
}
return vanish;
} }
} }

View File

@@ -12,6 +12,8 @@ import org.dynmap.DynmapAPI;
import org.dynmap.markers.*; import org.dynmap.markers.*;
import org.dynmap.utils.TileFlags; import org.dynmap.utils.TileFlags;
import java.awt.*;
import java.util.List;
import java.util.*; import java.util.*;
import java.util.Map.Entry; import java.util.Map.Entry;
@@ -50,6 +52,8 @@ public class EngineDynmap {
public MarkerAPI markerApi; public MarkerAPI markerApi;
public MarkerSet markerset; public MarkerSet markerset;
List<List<Point>> polyLine = new ArrayList<List<Point>>();
private EngineDynmap() { private EngineDynmap() {
} }
@@ -80,9 +84,7 @@ public class EngineDynmap {
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);
if (c > 127 || c == '"' || c == '<' || c == '>' || c == '&') { if (c > 127 || c == '"' || c == '<' || c == '>' || c == '&') {
out.append("&#") out.append("&#").append((int) c).append(';');
.append((int) c)
.append(';');
} else { } else {
out.append(c); out.append(c);
} }
@@ -121,10 +123,12 @@ public class EngineDynmap {
} }
// Shedule non thread safe sync at the end! // Shedule non thread safe sync at the end!
Bukkit.getScheduler().scheduleSyncRepeatingTask(FactionsPlugin.getInstance(), () -> { Bukkit.getScheduler().scheduleSyncRepeatingTask(FactionsPlugin.getInstance(), () ->
{
final Map<String, TempMarker> homes = createHomes(); final Map<String, TempMarker> homes = createHomes();
final Map<String, TempAreaMarker> areas = createAreas(); final Map<String, TempAreaMarker> areas = createAreas();
final Map<String, TempPolyLineMarker> polys = createPolys(areas);
final Map<String, Set<String>> playerSets = createPlayersets(); final Map<String, Set<String>> playerSets = createPlayersets();
if (!updateCore()) { if (!updateCore()) {
@@ -138,6 +142,7 @@ public class EngineDynmap {
updateHomes(homes); updateHomes(homes);
updateAreas(areas); updateAreas(areas);
updatePolys(polys);
updatePlayersets(playerSets); updatePlayersets(playerSets);
}, 100L, 100L); }, 100L, 100L);
} }
@@ -239,6 +244,7 @@ public class EngineDynmap {
// NOTE: That way what is left at the end will be outdated markers to remove. // NOTE: That way what is left at the end will be outdated markers to remove.
Marker marker = markers.remove(markerId); Marker marker = markers.remove(markerId);
if (marker == null) { if (marker == null) {
marker = temp.create(this.markerApi, this.markerset, markerId);
marker = temp.create(this.markerApi, this.markerset, markerId); marker = temp.create(this.markerApi, this.markerset, markerId);
if (marker == null) { if (marker == null) {
EngineDynmap.severe("Could not get/create the home marker " + markerId); EngineDynmap.severe("Could not get/create the home marker " + markerId);
@@ -260,6 +266,29 @@ public class EngineDynmap {
// -------------------------------------------- // // -------------------------------------------- //
// Thread Safe: YES // Thread Safe: YES
public Map<String, TempPolyLineMarker> createPolys(Map<String, TempAreaMarker> areas) {
Map<String, TempPolyLineMarker> ret = new HashMap<String, TempPolyLineMarker>();
for (Entry<String, TempAreaMarker> entry : areas.entrySet()) {
String markerID = entry.getKey();
TempAreaMarker area = entry.getValue();
int counter = 0;
for (List<Point> points : area.getPolyLine()) {
markerID = markerID + "_poly_" + counter;
TempPolyLineMarker tempPoly = new TempPolyLineMarker();
tempPoly.polyLine = points;
tempPoly.lineColor = area.lineColor;
tempPoly.lineOpacity = area.lineOpacity;
tempPoly.lineWeight = area.lineWeight;
tempPoly.world = area.world;
ret.put(markerID, tempPoly);
counter++;
}
}
return ret;
}
public Map<String, TempAreaMarker> createAreas() { public Map<String, TempAreaMarker> createAreas() {
Map<String, Map<Faction, Set<FLocation>>> worldFactionChunks = createWorldFactionChunks(); Map<String, Map<Faction, Set<FLocation>>> worldFactionChunks = createWorldFactionChunks();
return createAreas(worldFactionChunks); return createAreas(worldFactionChunks);
@@ -351,12 +380,11 @@ public class EngineDynmap {
// Loop through until we don't find more areas // Loop through until we don't find more areas
while (allChunks != null) { while (allChunks != null) {
TileFlags ourChunkFlags = null; TileFlags ourChunkFlags = null;
LinkedList<FLocation> ourChunks = null; LinkedList<FLocation> ourChunks = null;
LinkedList<FLocation> newChunks = null; LinkedList<FLocation> newChunks = null;
int minimumX = Integer.MAX_VALUE;
int minimumZ = Integer.MAX_VALUE;
for (FLocation chunk : allChunks) { for (FLocation chunk : allChunks) {
int chunkX = (int) chunk.getX(); int chunkX = (int) chunk.getX();
int chunkZ = (int) chunk.getZ(); int chunkZ = (int) chunk.getZ();
@@ -367,18 +395,10 @@ public class EngineDynmap {
ourChunks = new LinkedList<>(); ourChunks = new LinkedList<>();
floodFillTarget(allChunkFlags, ourChunkFlags, chunkX, chunkZ); // Copy shape floodFillTarget(allChunkFlags, ourChunkFlags, chunkX, chunkZ); // Copy shape
ourChunks.add(chunk); // Add it to our chunk list ourChunks.add(chunk); // Add it to our chunk list
minimumX = chunkX;
minimumZ = chunkZ;
} }
// If shape found, and we're in it, add to our node list // If shape found, and we're in it, add to our node list
else if (ourChunkFlags != null && ourChunkFlags.getFlag(chunkX, chunkZ)) { else if (ourChunkFlags != null && ourChunkFlags.getFlag(chunkX, chunkZ)) {
ourChunks.add(chunk); ourChunks.add(chunk);
if (chunkX < minimumX) {
minimumX = chunkX;
minimumZ = chunkZ;
} else if (chunkX == minimumX && chunkZ < minimumZ) {
minimumZ = chunkZ;
}
} }
// Else, keep it in the list for the next polygon // Else, keep it in the list for the next polygon
else { else {
@@ -391,86 +411,129 @@ public class EngineDynmap {
// Replace list (null if no more to process) // Replace list (null if no more to process)
allChunks = newChunks; allChunks = newChunks;
if (ourChunkFlags == null) { if (ourChunkFlags == null) {
continue; continue;
} }
List<TempLine> outputLines = new ArrayList<TempLine>();
Map<TempLine, Integer> lines = new HashMap<TempLine, Integer>();
// Trace outline of blocks - start from minx, minz going to x+ if (ourChunks == null) {
int initialX = minimumX; continue;
int initialZ = minimumZ; }
int currentX = minimumX;
int currentZ = minimumZ; for (FLocation loc : ourChunks) {
Direction direction = Direction.XPLUS; int x = loc.getChunk().getX();
ArrayList<int[]> linelist = new ArrayList<>(); int z = loc.getChunk().getZ();
linelist.add(new int[]{initialX, initialZ}); // Add start point
while ((currentX != initialX) || (currentZ != initialZ) || (direction != Direction.ZMINUS)) { TempLine line = new TempLine(new Point(x * 16, z * 16), new Point(x * 16 + 16, z * 16));
switch (direction) { if (lines.containsKey(line)) {
case XPLUS: // Segment in X+ direction lines.put(line, lines.get(line) + 1);
if (!ourChunkFlags.getFlag(currentX + 1, currentZ)) { // Right turn? } else {
linelist.add(new int[]{currentX + 1, currentZ}); // Finish line lines.put(line, 1);
direction = Direction.ZPLUS; // Change direction }
} else if (!ourChunkFlags.getFlag(currentX + 1, currentZ - 1)) { // Straight?
currentX++; line = new TempLine(new Point(x * 16 + 16, z * 16), new Point(x * 16 + 16, z * 16 + 16));
} else { // Left turn if (lines.containsKey(line)) {
linelist.add(new int[]{currentX + 1, currentZ}); // Finish line lines.put(line, lines.get(line) + 1);
direction = Direction.ZMINUS; } else {
currentX++; lines.put(line, 1);
currentZ--; }
}
break; line = new TempLine(new Point(x * 16 + 16, z * 16 + 16), new Point(x * 16, z * 16 + 16));
case ZPLUS: // Segment in Z+ direction if (lines.containsKey(line)) {
if (!ourChunkFlags.getFlag(currentX, currentZ + 1)) { // Right turn? lines.put(line, lines.get(line) + 1);
linelist.add(new int[]{currentX + 1, currentZ + 1}); // Finish line } else {
direction = Direction.XMINUS; // Change direction lines.put(line, 1);
} else if (!ourChunkFlags.getFlag(currentX + 1, currentZ + 1)) { // Straight? }
currentZ++;
} else { // Left turn line = new TempLine(new Point(x * 16, z * 16 + 16), new Point(x * 16, z * 16));
linelist.add(new int[]{currentX + 1, currentZ + 1}); // Finish line if (lines.containsKey(line)) {
direction = Direction.XPLUS; lines.put(line, lines.get(line) + 1);
currentX++; } else {
currentZ++; lines.put(line, 1);
}
break;
case XMINUS: // Segment in X- direction
if (!ourChunkFlags.getFlag(currentX - 1, currentZ)) { // Right turn?
linelist.add(new int[]{currentX, currentZ + 1}); // Finish line
direction = Direction.ZMINUS; // Change direction
} else if (!ourChunkFlags.getFlag(currentX - 1, currentZ + 1)) { // Straight?
currentX--;
} else { // Left turn
linelist.add(new int[]{currentX, currentZ + 1}); // Finish line
direction = Direction.ZPLUS;
currentX--;
currentZ++;
}
break;
case ZMINUS: // Segment in Z- direction
if (!ourChunkFlags.getFlag(currentX, currentZ - 1)) { // Right turn?
linelist.add(new int[]{currentX, currentZ}); // Finish line
direction = Direction.XPLUS; // Change direction
} else if (!ourChunkFlags.getFlag(currentX - 1, currentZ - 1)) { // Straight?
currentZ--;
} else { // Left turn
linelist.add(new int[]{currentX, currentZ}); // Finish line
direction = Direction.XMINUS;
currentX--;
currentZ--;
}
break;
} }
} }
int sz = linelist.size(); Iterator<Entry<TempLine, Integer>> iterator = lines.entrySet().iterator();
double[] x = new double[sz];
double[] z = new double[sz]; List<TempLine> lineList = new ArrayList<TempLine>();
for (int i = 0; i < sz; i++) { lineList.addAll(lines.keySet());
int[] line = linelist.get(i);
x[i] = (double) line[0] * (double) BLOCKS_PER_CHUNK; while (iterator.hasNext()) {
z[i] = (double) line[1] * (double) BLOCKS_PER_CHUNK; Entry<TempLine, Integer> entry = iterator.next();
if (entry.getValue() > 1) {
lineList.remove(entry.getKey());
}
} }
// Find the leftmost MCRWPoint
TempLine l = null;
for (Iterator<TempLine> it = lineList.iterator(); it.hasNext(); ) {
TempLine tl = it.next();
if (l == null || tl.getP1().x < l.getP1().x)
l = tl;
}
for (Iterator<TempLine> it = lineList.iterator(); it.hasNext(); ) {
TempLine tl = it.next();
if (tl.getP2().x < l.getP2().x)
l = tl;
}
outputLines.add(l);
lineList.remove(l);
while (lineList.size() > 0) {
// MCRWPoint targetp = new MCRWPoint((int) lastLine.x1, (int) lastLine.y1);
// MCRWPointWLines.get(targetp);
TempLine nextLine = null;
for (Iterator<TempLine> it = lineList.iterator(); it.hasNext(); ) {
TempLine line = it.next();
if (l.getP2().x == line.getP1().x && l.getP2().y == line.getP1().y) {
nextLine = line;
}
}
if (nextLine != null) {
outputLines.add(nextLine);
lineList.remove(nextLine);
l = nextLine;
} else {
outputLines.get(outputLines.size() - 1).addAdditionLines(CamScan1(lineList));
break;
}
}
List<Point> outputPoints = new ArrayList<Point>();
List<Point> polyPoints = new ArrayList<Point>();
for (int i = 0; i < outputLines.size(); i++) {
Point p = new Point(outputLines.get(i).getP1().x, outputLines.get(i).getP1().y);
outputPoints.add(p);
polyPoints.add(p);
if (outputLines.get(i).getConnectedLines().size() > 0) {
outputPoints.addAll(addRecursivePoints(new Point(outputLines.get(i).getP1().x, outputLines.get(i).getP1().y), outputLines.get(i)));
}
p = new Point(outputLines.get(i).getP2().x, outputLines.get(i).getP2().y);
outputPoints.add(p);
polyPoints.add(p);
}
polyLine.add(polyPoints);
// Build information for specific area // Build information for specific area
double[] x = new double[outputPoints.size()];
double[] z = new double[outputPoints.size()];
for (int i = 0; i < outputPoints.size(); i++) {
x[i] = outputPoints.get(i).x;
z[i] = outputPoints.get(i).y;
}
String markerId = FACTIONS_ + world + "__" + faction.getId() + "__" + markerIndex; String markerId = FACTIONS_ + world + "__" + faction.getId() + "__" + markerIndex;
TempAreaMarker temp = new TempAreaMarker(); TempAreaMarker temp = new TempAreaMarker();
@@ -488,8 +551,10 @@ public class EngineDynmap {
temp.fillOpacity = style.getFillOpacity(); temp.fillOpacity = style.getFillOpacity();
temp.boost = style.getBoost(); temp.boost = style.getBoost();
temp.setPolyLine(polyLine);
ret.put(markerId, temp); ret.put(markerId, temp);
polyLine.clear();
markerIndex++; markerIndex++;
} }
@@ -497,10 +562,114 @@ public class EngineDynmap {
return ret; return ret;
} }
public List<Point> addRecursivePoints(Point returnPoint, TempLine line) {
List<Point> ret = new ArrayList<Point>();
boolean shouldReturn = false;
List<TempLine> connectedLines = line.getConnectedLines();
List<Point> polyPoints = new ArrayList<Point>();
for (TempLine line2 : connectedLines) {
Point p = new Point(line2.getP1().x, line2.getP1().y);
ret.add(p);
polyPoints.add(p);
shouldReturn = true;
if (line2.getConnectedLines().size() > 0) {
ret.addAll(addRecursivePoints(new Point(line2.getP1().x, line2.getP1().y), line2));
}
p = new Point(line2.getP2().x, line2.getP2().y);
ret.add(p);
polyPoints.add(p);
}
if (shouldReturn) {
ret.add(returnPoint);
}
polyLine.add(polyPoints);
return ret;
}
private List<TempLine> CamScan1(List<TempLine> lineList) {
List<TempLine> ret = new ArrayList<TempLine>();
// Find the leftmost MCRWPoint
TempLine l = null;
for (Iterator<TempLine> it = lineList.iterator(); it.hasNext(); ) {
TempLine tl = it.next();
if (l == null || tl.getP1().x < l.getP1().x)
l = tl;
}
for (Iterator<TempLine> it = lineList.iterator(); it.hasNext(); ) {
TempLine tl = it.next();
if (tl.getP2().x < l.getP2().x)
l = tl;
}
ret.add(l);
lineList.remove(l);
while (lineList.size() > 0) {
// MCRWPoint targetp = new MCRWPoint((int) lastLine.x1, (int) lastLine.y1);
// MCRWPointWLines.get(targetp);
TempLine thisChunkLine = null;
for (Iterator<TempLine> it = lineList.iterator(); it.hasNext(); ) {
TempLine line = it.next();
if (l.getP2().x == line.getP1().x && l.getP2().y == line.getP1().y) {
thisChunkLine = line;
}
}
if (thisChunkLine != null) {
ret.add(thisChunkLine);
lineList.remove(thisChunkLine);
l = thisChunkLine;
} else {
// break;
ret.get(ret.size() - 1).addAdditionLines(CamScan1(lineList));
}
}
return ret;
}
// -------------------------------------------- // // -------------------------------------------- //
// UTIL & SHARED // UTIL & SHARED
// -------------------------------------------- // // -------------------------------------------- //
public void updatePolys(Map<String, TempPolyLineMarker> polys) {
// Map Current
Map<String, PolyLineMarker> markers = new HashMap<>();
for (PolyLineMarker marker : this.markerset.getPolyLineMarkers()) {
markers.put(marker.getMarkerID(), marker);
}
// Loop New
for (Entry<String, TempPolyLineMarker> entry : polys.entrySet()) {
String markerId = entry.getKey();
TempPolyLineMarker temp = entry.getValue();
// Get Creative
// NOTE: I remove from the map created just in the beginning of this method.
// NOTE: That way what is left at the end will be outdated markers to remove.
PolyLineMarker marker = markers.remove(markerId);
if (marker == null) {
marker = temp.create(this.markerset, markerId);
if (marker == null) {
severe("Could not get/create the area marker " + markerId);
}
} else {
temp.update(marker);
}
}
// Only old/outdated should now be left. Delete them.
for (PolyLineMarker marker : markers.values()) {
marker.deleteMarker();
}
}
// Thread Safe: NO // Thread Safe: NO
public void updateAreas(Map<String, TempAreaMarker> areas) { public void updateAreas(Map<String, TempAreaMarker> areas) {
// Map Current // Map Current
@@ -658,7 +827,6 @@ public class EngineDynmap {
money = String.format("%.2f", Econ.getBalance(faction.getAccountId())); money = String.format("%.2f", Econ.getBalance(faction.getAccountId()));
ret = ret.replace("%money%", money); ret = ret.replace("%money%", money);
// Players // Players
Set<FPlayer> playersList = faction.getFPlayers(); Set<FPlayer> playersList = faction.getFPlayers();
String playersCount = String.valueOf(playersList.size()); String playersCount = String.valueOf(playersList.size());
@@ -675,7 +843,6 @@ public class EngineDynmap {
String playersModeratorsCount = String.valueOf(playersModeratorsList.size()); String playersModeratorsCount = String.valueOf(playersModeratorsList.size());
String playersModerators = getHtmlPlayerString(playersModeratorsList); String playersModerators = getHtmlPlayerString(playersModeratorsList);
ArrayList<FPlayer> playersNormalsList = faction.getFPlayersWhereRole(Role.NORMAL); ArrayList<FPlayer> playersNormalsList = faction.getFPlayersWhereRole(Role.NORMAL);
String playersNormalsCount = String.valueOf(playersNormalsList.size()); String playersNormalsCount = String.valueOf(playersNormalsList.size());
String playersNormals = getHtmlPlayerString(playersNormalsList); String playersNormals = getHtmlPlayerString(playersNormalsList);

View File

@@ -3,6 +3,10 @@ package com.massivecraft.factions.integration.dynmap;
import org.dynmap.markers.AreaMarker; import org.dynmap.markers.AreaMarker;
import org.dynmap.markers.MarkerSet; import org.dynmap.markers.MarkerSet;
import java.awt.*;
import java.util.ArrayList;
import java.util.List;
public class TempAreaMarker { public class TempAreaMarker {
/** /**
@@ -18,15 +22,13 @@ public class TempAreaMarker {
public double[] x; public double[] x;
public double[] z; public double[] z;
public String description; public String description;
public int lineColor; public int lineColor;
public double lineOpacity; public double lineOpacity;
public int lineWeight; public int lineWeight;
public int fillColor; public int fillColor;
public double fillOpacity; public double fillOpacity;
public boolean boost; public boolean boost;
private List<List<Point>> polyLine = new ArrayList<List<Point>>();
// -------------------------------------------- // // -------------------------------------------- //
// CREATE // CREATE
@@ -54,6 +56,15 @@ public class TempAreaMarker {
return true; return true;
} }
public List<List<Point>> getPolyLine() {
return polyLine;
}
public void setPolyLine(List<List<Point>> points) {
polyLine.clear();
polyLine.addAll(points);
}
// -------------------------------------------- // // -------------------------------------------- //
// UPDATE // UPDATE
// -------------------------------------------- // // -------------------------------------------- //
@@ -61,16 +72,17 @@ public class TempAreaMarker {
public AreaMarker create(MarkerSet markerset, String markerId) { public AreaMarker create(MarkerSet markerset, String markerId) {
AreaMarker ret = markerset.createAreaMarker(markerId, this.label, false, this.world, this.x, this.z, false // not persistent AreaMarker ret = markerset.createAreaMarker(markerId, this.label, false, this.world, this.x, this.z, false // not persistent
); );
if (ret == null) { if (ret == null) {
return null; return null;
} }
int counter = 0;
// Description // Description
ret.setDescription(this.description); ret.setDescription(this.description);
// Line Style // Line Style
ret.setLineStyle(this.lineWeight, this.lineOpacity, this.lineColor); ret.setLineStyle(0, 0, 0);
// Fill Style // Fill Style
ret.setFillStyle(this.fillOpacity, this.fillColor); ret.setFillStyle(this.fillOpacity, this.fillColor);
@@ -80,7 +92,6 @@ public class TempAreaMarker {
return ret; return ret;
} }
// -------------------------------------------- // // -------------------------------------------- //
// UTIL // UTIL
// -------------------------------------------- // // -------------------------------------------- //
@@ -95,18 +106,15 @@ public class TempAreaMarker {
if (!marker.getLabel().equals(this.label)) { if (!marker.getLabel().equals(this.label)) {
marker.setLabel(this.label); marker.setLabel(this.label);
} }
// Description
if (!marker.getDescription().equals(this.description)) { if (!marker.getDescription().equals(this.description)) {
marker.setDescription(this.description); marker.setDescription(this.description);
} }
// Line Style // // Line Style
if (marker.getLineWeight() != this.lineWeight || // if (marker.getLineWeight() != this.lineWeight || marker.getLineOpacity() != this.lineOpacity || marker.getLineColor() != this.lineColor)
marker.getLineOpacity() != this.lineOpacity || // {
marker.getLineColor() != this.lineColor) { // marker.setLineStyle(this.lineWeight, this.lineOpacity, this.lineColor);
marker.setLineStyle(this.lineWeight, this.lineOpacity, this.lineColor); // }
}
// Fill Style // Fill Style
if ((marker.getFillOpacity() != this.fillOpacity) || (marker.getFillColor() != this.fillColor)) { if ((marker.getFillOpacity() != this.fillOpacity) || (marker.getFillColor() != this.fillColor)) {

View File

@@ -0,0 +1,49 @@
package com.massivecraft.factions.integration.dynmap;
import java.awt.*;
import java.util.ArrayList;
import java.util.List;
public class TempLine {
private Point p1;
private Point p2;
private List<TempLine> connectedLines = new ArrayList<TempLine>();
TempLine(Point p1, Point p2) {
this.p1 = p1;
this.p2 = p2;
}
public Point getP1() {
return p1;
}
public Point getP2() {
return p2;
}
public void addAdditionLines(List<TempLine> connectedLines) {
this.connectedLines = connectedLines;
}
public List<TempLine> getConnectedLines() {
return connectedLines;
}
@Override
public boolean equals(Object o) {
TempLine line = (TempLine) o;
if (line.p1.x == this.p1.x && line.p2.x == this.p2.x && line.p1.y == this.p1.y && line.p2.y == this.p2.y) {
return true;
}
return line.p1.x == this.p2.x && line.p2.x == this.p1.x && line.p1.y == this.p2.y && line.p2.y == this.p1.y;
}
@Override
public int hashCode() {
String test = "" + (p1.x + p2.x);
test += " " + (p1.y + p2.y);
return test.hashCode();
}
}

View File

@@ -0,0 +1,99 @@
package com.massivecraft.factions.integration.dynmap;
import org.dynmap.markers.MarkerSet;
import org.dynmap.markers.PolyLineMarker;
import java.awt.*;
import java.util.ArrayList;
import java.util.List;
public class TempPolyLineMarker {
/**
* @author FactionsUUID Team
*/
// -------------------------------------------- //
// FIELDS
// -------------------------------------------- //
public String world;
public List<Point> polyLine = new ArrayList<Point>();
public int lineColor;
public double lineOpacity;
public int lineWeight;
// -------------------------------------------- //
// CREATE
// -------------------------------------------- //
public static boolean equals(PolyLineMarker marker, List<Point> points) {
int length = marker.getCornerCount();
if (points.size() != length) {
return false;
}
for (int i = 0; i < length; i++) {
if (marker.getCornerX(i) != points.get(i).x) {
return false;
}
if (marker.getCornerZ(i) != points.get(i).y) {
return false;
}
}
return true;
}
// -------------------------------------------- //
// UPDATE
// -------------------------------------------- //
public PolyLineMarker create(MarkerSet markerset, String markerId) {
double[] polyX = new double[polyLine.size()];
double[] polyY = new double[polyLine.size()];
double[] polyZ = new double[polyLine.size()];
for (int i = 0; i < polyLine.size(); i++) {
Point p = polyLine.get(i);
polyX[i] = p.getX();
polyY[i] = 64;
polyZ[i] = p.getY();
}
PolyLineMarker poly = markerset.createPolyLineMarker(markerId, "", false, this.world, polyX, polyY, polyZ, false);
// Poly Line Style
if (poly != null) {
poly.setLineStyle(this.lineWeight, this.lineOpacity, this.lineColor);
}
return poly;
}
// -------------------------------------------- //
// UTIL
// -------------------------------------------- //
public void update(PolyLineMarker marker) {
// Corner Locations
if (!equals(marker, polyLine)) {
double[] polyX = new double[polyLine.size()];
double[] polyY = new double[polyLine.size()];
double[] polyZ = new double[polyLine.size()];
for (int i = 0; i < polyLine.size(); i++) {
Point p = polyLine.get(i);
polyX[i] = p.getX();
polyY[i] = 64;
polyZ[i] = p.getY();
}
marker.setCornerLocations(polyX, polyY, polyZ);
marker.setLineStyle(this.lineWeight, this.lineOpacity, this.lineColor);
}
// Line Style
if (marker.getLineWeight() != this.lineWeight || marker.getLineOpacity() != this.lineOpacity || marker.getLineColor() != this.lineColor) {
marker.setLineStyle(this.lineWeight, this.lineOpacity, this.lineColor);
}
}
}

View File

@@ -27,7 +27,6 @@ import org.bukkit.event.EventPriority;
import org.bukkit.event.Listener; import org.bukkit.event.Listener;
import org.bukkit.event.block.*; import org.bukkit.event.block.*;
import org.bukkit.event.entity.EntityChangeBlockEvent; import org.bukkit.event.entity.EntityChangeBlockEvent;
import org.bukkit.event.entity.EntityExplodeEvent;
import org.bukkit.event.hanging.HangingBreakByEntityEvent; import org.bukkit.event.hanging.HangingBreakByEntityEvent;
import org.bukkit.inventory.ItemStack; import org.bukkit.inventory.ItemStack;
import org.bukkit.inventory.meta.ItemMeta; import org.bukkit.inventory.meta.ItemMeta;
@@ -180,12 +179,18 @@ public class FactionsBlockListener implements Listener {
@EventHandler(priority = EventPriority.NORMAL, ignoreCancelled = true) @EventHandler(priority = EventPriority.NORMAL, ignoreCancelled = true)
public void onBlockFromTo(BlockFromToEvent event) { public void onBlockFromTo(BlockFromToEvent event) {
if (!Conf.handleExploitLiquidFlow) return; if (!Conf.handleExploitLiquidFlow) return;
if (event.getBlock().isLiquid()) { if (event.getBlock().isLiquid()) {
if (event.getToBlock().isEmpty()) { if (event.getToBlock().isEmpty()) {
Faction from = Board.getInstance().getFactionAt(new FLocation(event.getBlock())); Faction from = Board.getInstance().getFactionAt(new FLocation(event.getBlock()));
Faction to = Board.getInstance().getFactionAt(new FLocation(event.getToBlock())); Faction to = Board.getInstance().getFactionAt(new FLocation(event.getToBlock()));
if (from == to) return; if (from == to) return;
// from faction != to faction // from faction != to faction
if (to.isSystemFaction()) {
event.setCancelled(true);
return;
}
if (to.isNormal()) { if (to.isNormal()) {
if (from.isNormal() && from.getRelationTo(to).isAlly()) { if (from.isNormal() && from.getRelationTo(to).isAlly()) {
return; return;
@@ -425,7 +430,8 @@ public class FactionsBlockListener implements Listener {
if (!justCheck) fPlayer.setLastFrostwalkerMessage(); if (!justCheck) fPlayer.setLastFrostwalkerMessage();
// Check if they have build permissions here. If not, block this from happening. // Check if they have build permissions here. If not, block this from happening.
if (!playerCanBuildDestroyBlock(player, location, PermissableAction.FROST_WALK.toString(), justCheck)) event.setCancelled(true); if (!playerCanBuildDestroyBlock(player, location, "frostwalk", justCheck))
event.setCancelled(true);
} }
@EventHandler @EventHandler
@@ -506,7 +512,6 @@ public class FactionsBlockListener implements Listener {
Player p = (Player) event.getRemover(); Player p = (Player) event.getRemover();
if (!playerCanBuildDestroyBlock(p, event.getEntity().getLocation(), "destroy", true)) { if (!playerCanBuildDestroyBlock(p, event.getEntity().getLocation(), "destroy", true)) {
event.setCancelled(true); event.setCancelled(true);
return;
} }
} }
} }
@@ -516,7 +521,7 @@ public class FactionsBlockListener implements Listener {
public void onFarmLandDamage(EntityChangeBlockEvent event) { public void onFarmLandDamage(EntityChangeBlockEvent event) {
if (event.getEntity() instanceof Player) { if (event.getEntity() instanceof Player) {
Player player = (Player) event.getEntity(); Player player = (Player) event.getEntity();
if (!playerCanBuildDestroyBlock(player, event.getBlock().getLocation(), PermissableAction.DESTROY.name(), true)) { if (!playerCanBuildDestroyBlock(player, event.getBlock().getLocation(), "destroy", true)) {
FPlayer me = FPlayers.getInstance().getByPlayer(player); FPlayer me = FPlayers.getInstance().getByPlayer(player);
Faction otherFaction = Board.getInstance().getFactionAt(new FLocation(event.getBlock().getLocation())); Faction otherFaction = Board.getInstance().getFactionAt(new FLocation(event.getBlock().getLocation()));
me.msg(TL.ACTION_DENIED_OTHER, otherFaction.getTag(), "trample crops"); me.msg(TL.ACTION_DENIED_OTHER, otherFaction.getTag(), "trample crops");
@@ -524,4 +529,4 @@ public class FactionsBlockListener implements Listener {
} }
} }
} }
} }

View File

@@ -327,7 +327,6 @@ public class FactionsEntityListener implements Listener {
public boolean isPlayerInSafeZone(Entity damagee) { public boolean isPlayerInSafeZone(Entity damagee) {
if (!(damagee instanceof Player)) return false; if (!(damagee instanceof Player)) return false;
return Board.getInstance().getFactionAt(new FLocation(damagee.getLocation())).isSafeZone(); return Board.getInstance().getFactionAt(new FLocation(damagee.getLocation())).isSafeZone();
} }
@@ -338,12 +337,8 @@ public class FactionsEntityListener implements Listener {
public boolean canDamagerHurtDamagee(EntityDamageByEntityEvent sub, boolean notify) { public boolean canDamagerHurtDamagee(EntityDamageByEntityEvent sub, boolean notify) {
Entity damager = sub.getDamager(); Entity damager = sub.getDamager();
Entity damagee = sub.getEntity(); Entity damagee = sub.getEntity();
if (!(damagee instanceof Player)) return true; if (!(damagee instanceof Player)) return true;
FPlayer defender = FPlayers.getInstance().getByPlayer((Player) damagee); FPlayer defender = FPlayers.getInstance().getByPlayer((Player) damagee);
if (damager instanceof Player) { if (damager instanceof Player) {
FPlayer attacker = FPlayers.getInstance().getByPlayer((Player) damager); FPlayer attacker = FPlayers.getInstance().getByPlayer((Player) damager);
if (defender == null || defender.getPlayer() == null) return true; if (defender == null || defender.getPlayer() == null) return true;
@@ -358,12 +353,8 @@ public class FactionsEntityListener implements Listener {
} }
} }
} }
Location defenderLoc = defender.getPlayer().getLocation(); Location defenderLoc = defender.getPlayer().getLocation();
Faction defLocFaction = Board.getInstance().getFactionAt(new FLocation(defenderLoc)); Faction defLocFaction = Board.getInstance().getFactionAt(new FLocation(defenderLoc));
// for damage caused by projectiles, getDamager() returns the projectile... what we need to know is the source // for damage caused by projectiles, getDamager() returns the projectile... what we need to know is the source
if (damager instanceof Projectile) { if (damager instanceof Projectile) {
Projectile projectile = (Projectile) damager; Projectile projectile = (Projectile) damager;

View File

@@ -4,7 +4,6 @@ import com.massivecraft.factions.*;
import com.massivecraft.factions.cmd.CmdFGlobal; import com.massivecraft.factions.cmd.CmdFGlobal;
import com.massivecraft.factions.cmd.CmdFly; import com.massivecraft.factions.cmd.CmdFly;
import com.massivecraft.factions.cmd.CmdSeeChunk; import com.massivecraft.factions.cmd.CmdSeeChunk;
import com.massivecraft.factions.cmd.FCmdRoot;
import com.massivecraft.factions.cmd.audit.FLogType; import com.massivecraft.factions.cmd.audit.FLogType;
import com.massivecraft.factions.cmd.logout.LogoutHandler; import com.massivecraft.factions.cmd.logout.LogoutHandler;
import com.massivecraft.factions.cmd.wild.CmdWild; import com.massivecraft.factions.cmd.wild.CmdWild;
@@ -55,9 +54,9 @@ import java.util.logging.Level;
public class FactionsPlayerListener implements Listener { public class FactionsPlayerListener implements Listener {
public final static Map<UUID, Location> lastLocations = new HashMap<>();
public static Set<FLocation> corners; public static Set<FLocation> corners;
public static BukkitTask positionTask = null; public static BukkitTask positionTask = null;
public static Map<UUID, Location> lastLocations = new HashMap<>();
/** /**
* @author FactionsUUID Team * @author FactionsUUID Team
*/ */
@@ -309,7 +308,7 @@ public class FactionsPlayerListener implements Listener {
if ((landOwned && factionToCheck.getOwnerListString(loc).contains(player.getName())) || (me.getRole() == Role.LEADER && me.getFactionId().equals(factionToCheck.getId()))) { if ((landOwned && factionToCheck.getOwnerListString(loc).contains(player.getName())) || (me.getRole() == Role.LEADER && me.getFactionId().equals(factionToCheck.getId()))) {
return true; return true;
} else if (landOwned && !factionToCheck.getOwnerListString(loc).contains(player.getName())) { } else if (landOwned && !factionToCheck.getOwnerListString(loc).contains(player.getName())) {
me.msg(TL.ACTIONS_OWNEDTERRITORYDENY, factionToCheck.getOwnerListString(loc)); me.msg(TL.ACTIONS_OWNEDTERRITORYDENY.toString().replace("{owners}", factionToCheck.getOwnerListString(loc)));
if (doPain) player.damage(Conf.actionDeniedPainAmount); if (doPain) player.damage(Conf.actionDeniedPainAmount);
return false; return false;
} else if (!landOwned && access == Access.ALLOW) { } else if (!landOwned && access == Access.ALLOW) {
@@ -385,6 +384,10 @@ public class FactionsPlayerListener implements Listener {
case CHEST_MINECART: case CHEST_MINECART:
case BARREL: case BARREL:
case COMPOSTER:
case LOOM:
case CARTOGRAPHY_TABLE:
case GRINDSTONE:
case SHULKER_BOX: case SHULKER_BOX:
case BLACK_SHULKER_BOX: case BLACK_SHULKER_BOX:
@@ -453,7 +456,6 @@ public class FactionsPlayerListener implements Listener {
case CHIPPED_ANVIL: case CHIPPED_ANVIL:
case DAMAGED_ANVIL: case DAMAGED_ANVIL:
case BREWING_STAND: case BREWING_STAND:
return PermissableAction.CONTAINER; return PermissableAction.CONTAINER;
default: default:
return null; return null;
@@ -474,6 +476,8 @@ public class FactionsPlayerListener implements Listener {
// Update the lastLoginTime for this fplayer // Update the lastLoginTime for this fplayer
me.setLastLoginTime(System.currentTimeMillis()); me.setLastLoginTime(System.currentTimeMillis());
lastLocations.put(player.getUniqueId(), player.getLocation());
// Store player's current FLocation and notify them where they are // Store player's current FLocation and notify them where they are
me.setLastStoodAt(new FLocation(player.getLocation())); me.setLastStoodAt(new FLocation(player.getLocation()));
@@ -485,7 +489,7 @@ public class FactionsPlayerListener implements Listener {
if (FactionsPlugin.instance.getConfig().getBoolean("scoreboard.default-enabled", false)) { if (FactionsPlugin.instance.getConfig().getBoolean("scoreboard.default-enabled", false)) {
FScoreboard.init(me); FScoreboard.init(me);
FScoreboard.get(me).setDefaultSidebar(new FDefaultSidebar(), FactionsPlugin.instance.getConfig().getInt("scoreboard.default-update-interval", 20)); FScoreboard.get(me).setDefaultSidebar(new FDefaultSidebar());
FScoreboard.get(me).setSidebarVisibility(me.showScoreboard()); FScoreboard.get(me).setSidebarVisibility(me.showScoreboard());
} }
@@ -530,6 +534,7 @@ public class FactionsPlayerListener implements Listener {
@EventHandler(priority = EventPriority.NORMAL) @EventHandler(priority = EventPriority.NORMAL)
public void onPlayerQuit(PlayerQuitEvent event) { public void onPlayerQuit(PlayerQuitEvent event) {
Player this_ = event.getPlayer();
FPlayer me = FPlayers.getInstance().getByPlayer(event.getPlayer()); FPlayer me = FPlayers.getInstance().getByPlayer(event.getPlayer());
// Make sure player's power is up to date when they log off. // Make sure player's power is up to date when they log off.
@@ -546,6 +551,8 @@ public class FactionsPlayerListener implements Listener {
FactionsPlugin.instance.getTimers().remove(me.getPlayer().getUniqueId()); FactionsPlugin.instance.getTimers().remove(me.getPlayer().getUniqueId());
} }
lastLocations.remove(this_.getUniqueId());
Faction myFaction = me.getFaction(); Faction myFaction = me.getFaction();
if (!myFaction.isWilderness()) myFaction.memberLoggedOff(); if (!myFaction.isWilderness()) myFaction.memberLoggedOff();
@@ -557,7 +564,7 @@ public class FactionsPlayerListener implements Listener {
CmdSeeChunk.seeChunkMap.remove(event.getPlayer().getName()); CmdSeeChunk.seeChunkMap.remove(event.getPlayer().getName());
FScoreboard.remove(me); FScoreboard.remove(me, event.getPlayer());
} }
public String parseAllPlaceholders(String string, Faction faction, Player player) { public String parseAllPlaceholders(String string, Faction faction, Player player) {
@@ -570,17 +577,19 @@ public class FactionsPlayerListener implements Listener {
.replace("{leader}", faction.getFPlayerAdmin() + ""); .replace("{leader}", faction.getFPlayerAdmin() + "");
return string; return string;
} }
@Deprecated
public void checkCanFly(FPlayer me) { public void checkCanFly(FPlayer me) {
if (!FactionsPlugin.getInstance().getConfig().getBoolean("enable-faction-flight") || !FactionsPlugin.instance.getConfig().getBoolean("ffly.AutoEnable")) if (!me.canFlyAtLocation() || me.checkIfNearbyEnemies()) {
if (me.isFlying())
me.setFFlying(false, false);
return; return;
if (me.isFlying()) return;
if (me.getPlayer().hasPermission(Permission.FLY_FLY.node)) {
me.setFFlying(true, false);
CmdFly.flyMap.put(me.getName(), true);
if (CmdFly.particleTask == null)
CmdFly.startParticles();
} }
if (me.isFlying() || !FactionsPlugin.instance.getConfig().getBoolean("ffly.AutoEnable"))
return;
me.setFFlying(true, false);
CmdFly.flyMap.put(me.getName(), true);
if (CmdFly.particleTask == null)
CmdFly.startParticles();
} }
//inspect //inspect
@@ -646,14 +655,12 @@ public class FactionsPlayerListener implements Listener {
} }
public void startPositionCheck() { public void startPositionCheck() {
positionTask = Bukkit.getScheduler().runTaskTimer(FactionsPlugin.instance, () -> { positionTask = Bukkit.getScheduler().runTaskTimer(FactionsPlugin.getInstance(), () -> {
if (Bukkit.getOnlinePlayers().size() > 0) { if (lastLocations.isEmpty()) return;
for (Player player : Bukkit.getOnlinePlayers()) { for (Map.Entry<UUID, Location> check : lastLocations.entrySet()) {
if (!lastLocations.containsKey(player.getUniqueId())) { Player player = Bukkit.getPlayer(check.getKey());
lastLocations.put(player.getUniqueId(), player.getLocation()); if (player != null) {
continue; refreshPosition(player, check.getValue(), player.getLocation());
}
refreshPosition(player, lastLocations.get(player.getUniqueId()), player.getLocation());
lastLocations.put(player.getUniqueId(), player.getLocation()); lastLocations.put(player.getUniqueId(), player.getLocation());
} }
} }
@@ -719,18 +726,20 @@ public class FactionsPlayerListener implements Listener {
}, 5); }, 5);
} }
} }
if (FCmdRoot.instance.fFlyEnabled && CmdFly.autoenable && CmdFly.checkFly(me, me.getPlayer(), factionTo)) {
me.setFFlying(true, false);
CmdFly.flyMap.put(me.getName(), true);
if (CmdFly.particleTask == null)
CmdFly.startParticles();
}
checkCanFly(me);
Faction at = Board.getInstance().getFactionAt(new FLocation(me.getPlayer().getLocation()));
if (me.getAutoClaimFor() != null) { if (me.getAutoClaimFor() != null) {
me.attemptClaim(me.getAutoClaimFor(), newLocation, true); if (FactionsPlugin.cachedRadiusClaim && me.attemptClaim(me.getFaction(), me.getPlayer().getLocation(), true)) {
me.getFaction().getFPlayersWhereOnline(true).forEach(f -> f.msg(TL.CLAIM_CLAIMED, me.describeTo(f, true), me.getFaction().describeTo(f), at.describeTo(f)));
} else {
me.attemptClaim(me.getAutoClaimFor(), newLocation, true);
}
FactionsPlugin.instance.logFactionEvent(me.getAutoClaimFor(), FLogType.CHUNK_CLAIMS, me.getName(), CC.GreenB + "CLAIMED", String.valueOf(1), (new FLocation(player.getLocation())).formatXAndZ(",")); FactionsPlugin.instance.logFactionEvent(me.getAutoClaimFor(), FLogType.CHUNK_CLAIMS, me.getName(), CC.GreenB + "CLAIMED", String.valueOf(1), (new FLocation(player.getLocation())).formatXAndZ(","));
if (Conf.disableFlightOnFactionClaimChange) CmdFly.disableFlight(me); if (Conf.disableFlightOnFactionClaimChange && FactionsPlugin.getInstance().getConfig().getBoolean("enable-faction-flight"))
CmdFly.disableFlight(me);
} else if (me.isAutoSafeClaimEnabled()) { } else if (me.isAutoSafeClaimEnabled()) {
if (!Permission.MANAGE_SAFE_ZONE.has(player)) { if (!Permission.MANAGE_SAFE_ZONE.has(player)) {
me.setIsAutoSafeClaimEnabled(false); me.setIsAutoSafeClaimEnabled(false);
@@ -841,21 +850,18 @@ public class FactionsPlayerListener implements Listener {
@EventHandler @EventHandler
public void onInventorySee(InventoryClickEvent e) { public void onInventorySee(InventoryClickEvent e) {
if (e.getCurrentItem() == null) if (e.getCurrentItem() == null) return;
return; if (!e.getView().getTitle().endsWith("'s Inventory")) return;
if (!e.getView().getTitle().endsWith("'s Inventory"))
return;
e.setCancelled(true); e.setCancelled(true);
} }
@EventHandler @EventHandler
public void onPlayerBoneMeal(PlayerInteractEvent event) { public void onPlayerBoneMeal(PlayerInteractEvent event) {
Block block = event.getClickedBlock(); Block block = event.getClickedBlock();
if (event.getAction() == Action.RIGHT_CLICK_BLOCK && block.getType() == XMaterial.GRASS_BLOCK.parseMaterial() if (event.getAction() == Action.RIGHT_CLICK_BLOCK && block.getType() == XMaterial.GRASS_BLOCK.parseMaterial()
&& event.hasItem() && event.getItem().getType() == XMaterial.BONE_MEAL.parseMaterial()) { && event.hasItem() && event.getItem().getType() == XMaterial.BONE_MEAL.parseMaterial()) {
if (!FactionsBlockListener.playerCanBuildDestroyBlock(event.getPlayer(), block.getLocation(), PermissableAction.BUILD.name(), true)) { if (!FactionsBlockListener.playerCanBuildDestroyBlock(event.getPlayer(), block.getLocation(), "build", true)) {
FPlayer me = FPlayers.getInstance().getById(event.getPlayer().getUniqueId().toString()); FPlayer me = FPlayers.getInstance().getById(event.getPlayer().getUniqueId().toString());
Faction myFaction = me.getFaction(); Faction myFaction = me.getFaction();
@@ -969,7 +975,7 @@ public class FactionsPlayerListener implements Listener {
if (badGuy == null) return; if (badGuy == null) return;
// if player was banned (not just kicked), get rid of their stored info // if player was banned (not just kicked), get rid of their stored info
if (Conf.removePlayerDataWhenBanned && event.getReason().equals("Banned by admin.")) { if (Conf.removePlayerDataWhenBanned && event.getReason().equals(Conf.removePlayerDataWhenBannedReason)) {
if (badGuy.getRole() == Role.LEADER) badGuy.getFaction().promoteNewLeader(); if (badGuy.getRole() == Role.LEADER) badGuy.getFaction().promoteNewLeader();

View File

@@ -9,15 +9,27 @@ import org.bukkit.scoreboard.Team;
import java.lang.reflect.Method; import java.lang.reflect.Method;
import java.util.*; import java.util.*;
import java.util.regex.Matcher;
import java.util.regex.Pattern;
public class BufferedObjective { public class BufferedObjective {
/**
* @author FactionsUUID Team
*/
private static final Method addEntryMethod; private static final Method addEntryMethod;
private static final int MAX_LINE_LENGTH; private static final int MAX_LINE_LENGTH;
private static final Pattern PATTERN = Pattern.compile("(\u00A7[0-9a-fk-r])|(.)");
private final Scoreboard scoreboard;
private final String baseName;
private Objective current;
private List<Team> currentTeams = new ArrayList<>();
private String title;
private DisplaySlot displaySlot;
private int objPtr;
private int teamPtr;
private boolean requiresUpdate = false;
private final Map<Integer, String> contents = new HashMap<>();
static { static {
// Check for long line support. // Check for long line support.
@@ -39,17 +51,6 @@ public class BufferedObjective {
} }
} }
private final Scoreboard scoreboard;
private final String baseName;
private final Map<Integer, String> contents = new HashMap<>();
private Objective current;
private List<Team> currentTeams = new ArrayList<>();
private String title;
private DisplaySlot displaySlot;
private int objPtr;
private int teamPtr;
private boolean requiresUpdate = false;
public BufferedObjective(Scoreboard scoreboard) { public BufferedObjective(Scoreboard scoreboard) {
this.scoreboard = scoreboard; this.scoreboard = scoreboard;
this.baseName = createBaseName(); this.baseName = createBaseName();
@@ -122,14 +123,75 @@ public class BufferedObjective {
Team team = scoreboard.registerNewTeam(getNextTeamName()); Team team = scoreboard.registerNewTeam(getNextTeamName());
bufferTeams.add(team); bufferTeams.add(team);
Iterator<String> split = Splitter.fixedLength(16).split(entry.getValue()).iterator(); String name, prefix = null, suffix = null;
team.setPrefix(split.next()); String value = entry.getValue();
String name = split.next(); if (value.length() > 16) {
if (split.hasNext()) { // We only guarantee two splits String[] arrImAPirate = new String[3];
team.setSuffix(split.next()); Matcher matcherrr = PATTERN.matcher(value);
StringBuilder builderrr = new StringBuilder();
int sCURvy = 0;
char currrentColorrr = 'r';
char currrentFormat = 'r';
while (sCURvy < 3 && matcherrr.find()) {
String tharSheBlows = matcherrr.group();
boolean hoist = false;
if (tharSheBlows.length() == 1) {
builderrr.append(tharSheBlows);
if (builderrr.length() == 16) {
hoist = true;
}
} else {
char c = tharSheBlows.charAt(1);
if (c >= 'k' && c <= 'r') { // format!
currrentFormat = c;
if (c == 'r') {
currrentColorrr = 'r';
}
} else {
currrentColorrr = c;
currrentFormat = 'r';
}
if (builderrr.length() < 14) {
builderrr.append(tharSheBlows);
} else {
hoist = true;
}
}
if (hoist) {
arrImAPirate[sCURvy++] = builderrr.toString();
builderrr = new StringBuilder();
if (currrentColorrr != 'r') {
builderrr.append('\u00A7').append(currrentColorrr);
}
if (currrentFormat != 'r') {
builderrr.append('\u00A7').append(currrentFormat);
}
}
}
if (sCURvy < 3 && builderrr.length() > 0) {
arrImAPirate[sCURvy] = builderrr.toString();
}
if (arrImAPirate[2] == null) {
name = arrImAPirate[0];
suffix = arrImAPirate[1];
} else {
prefix = arrImAPirate[0];
name = arrImAPirate[1];
suffix = arrImAPirate[2];
}
} else {
name = value;
} }
if (prefix != null) {
team.setPrefix(prefix);
}
if (suffix != null) {
team.setSuffix(suffix);
}
try { try {
addEntryMethod.invoke(team, name); addEntryMethod.invoke(team, name);
} catch (ReflectiveOperationException ignored) { } catch (ReflectiveOperationException ignored) {

View File

@@ -58,10 +58,13 @@ public class FScoreboard {
FTeamWrapper.track(fboard); FTeamWrapper.track(fboard);
} }
public static void remove(FPlayer fplayer) { public static void remove(FPlayer fplayer, Player player) {
FScoreboard fboard = fscoreboards.remove(fplayer); FScoreboard fboard = fscoreboards.remove(fplayer);
if (fboard != null) { if (fboard != null) {
if (fboard.scoreboard == player.getScoreboard()) { // No equals method implemented, so may as well skip a nullcheck
player.setScoreboard(Bukkit.getScoreboardManager().getMainScoreboard());
}
fboard.removed = true; fboard.removed = true;
FTeamWrapper.untrack(fboard); FTeamWrapper.untrack(fboard);
} }
@@ -91,7 +94,7 @@ public class FScoreboard {
bufferedObjective.setDisplaySlot(visible ? DisplaySlot.SIDEBAR : null); bufferedObjective.setDisplaySlot(visible ? DisplaySlot.SIDEBAR : null);
} }
public void setDefaultSidebar(final FSidebarProvider provider, int updateInterval) { public void setDefaultSidebar(final FSidebarProvider provider) {
if (!isSupportedByServer()) { if (!isSupportedByServer()) {
return; return;
} }
@@ -114,7 +117,7 @@ public class FScoreboard {
updateObjective(); updateObjective();
} }
} }
}.runTaskTimer(FactionsPlugin.getInstance(), updateInterval, updateInterval); }.runTaskTimer(FactionsPlugin.getInstance(), 20, 20);
} }
public void setTemporarySidebar(final FSidebarProvider provider) { public void setTemporarySidebar(final FSidebarProvider provider) {

View File

@@ -3,6 +3,7 @@ package com.massivecraft.factions.scoreboards;
import com.massivecraft.factions.FPlayer; import com.massivecraft.factions.FPlayer;
import com.massivecraft.factions.Faction; import com.massivecraft.factions.Faction;
import com.massivecraft.factions.FactionsPlugin; import com.massivecraft.factions.FactionsPlugin;
import com.massivecraft.factions.tag.Tag;
import com.massivecraft.factions.zcore.util.TL; import com.massivecraft.factions.zcore.util.TL;
import com.massivecraft.factions.zcore.util.TagUtil; import com.massivecraft.factions.zcore.util.TagUtil;
@@ -20,16 +21,16 @@ public abstract class FSidebarProvider {
public abstract List<String> getLines(FPlayer fplayer); public abstract List<String> getLines(FPlayer fplayer);
public String replaceTags(FPlayer fPlayer, String s) { public String replaceTags(FPlayer fPlayer, String s) {
s = TagUtil.parsePlaceholders(fPlayer.getPlayer(), s); s = Tag.parsePlaceholders(fPlayer.getPlayer(), s);
return qualityAssure(TagUtil.parsePlain(fPlayer, s)); return qualityAssure(Tag.parsePlain(fPlayer, s));
} }
public String replaceTags(Faction faction, FPlayer fPlayer, String s) { public String replaceTags(Faction faction, FPlayer fPlayer, String s) {
// Run through Placeholder API first // Run through Placeholder API first
s = TagUtil.parsePlaceholders(fPlayer.getPlayer(), s); s = Tag.parsePlaceholders(fPlayer.getPlayer(), s);
return qualityAssure(Objects.requireNonNull(TagUtil.parsePlain(faction, fPlayer, s))); return qualityAssure(Tag.parsePlain(faction, fPlayer, s));
} }
private String qualityAssure(String line) { private String qualityAssure(String line) {

View File

@@ -19,8 +19,9 @@ public class FTeamWrapper {
private static final Map<Faction, FTeamWrapper> wrappers = new HashMap<>(); private static final Map<Faction, FTeamWrapper> wrappers = new HashMap<>();
private static final List<FScoreboard> tracking = new ArrayList<>(); private static final List<FScoreboard> tracking = new ArrayList<>();
private static final Set<Faction> updating = new HashSet<>();
private static int factionTeamPtr; private static int factionTeamPtr;
private static final Set<Faction> updating = new HashSet<>();
private final Map<FScoreboard, Team> teams = new HashMap<>(); private final Map<FScoreboard, Team> teams = new HashMap<>();
private final String teamName; private final String teamName;
private final Faction faction; private final Faction faction;
@@ -36,18 +37,11 @@ public class FTeamWrapper {
} }
public static void applyUpdatesLater(final Faction faction) { public static void applyUpdatesLater(final Faction faction) {
if (!FScoreboard.isSupportedByServer()) { if (!FScoreboard.isSupportedByServer()) return;
if (faction.isWilderness()) return;
if (!FactionsPlugin.getInstance().getConfig().getBoolean("scoreboard.default-prefixes", false)
|| FactionsPlugin.getInstance().getConfig().getBoolean("See-Invisible-Faction-Members"))
return; return;
}
if (faction.isWilderness()) {
return;
}
if (!FactionsPlugin.getInstance().getConfig().getBoolean("scoreboard.default-prefixes", false) || FactionsPlugin.getInstance().getConfig().getBoolean("See-Invisible-Faction-Members")) {
return;
}
if (updating.add(faction)) { if (updating.add(faction)) {
Bukkit.getScheduler().runTask(FactionsPlugin.getInstance(), () -> { Bukkit.getScheduler().runTask(FactionsPlugin.getInstance(), () -> {
@@ -58,22 +52,17 @@ public class FTeamWrapper {
} }
public static void applyUpdates(Faction faction) { public static void applyUpdates(Faction faction) {
if (!FScoreboard.isSupportedByServer()) { if (!FScoreboard.isSupportedByServer()) return;
return;
}
if (faction.isWilderness()) { if (faction.isWilderness()) return;
return;
}
if (!FactionsPlugin.getInstance().getConfig().getBoolean("scoreboard.default-prefixes", false) || FactionsPlugin.getInstance().getConfig().getBoolean("See-Invisible-Faction-Members")) {
return;
}
if (updating.contains(faction)) { if (!FactionsPlugin.getInstance().getConfig().getBoolean("scoreboard.default-prefixes", false)
// Faction will be updated soon. || FactionsPlugin.getInstance().getConfig().getBoolean("See-Invisible-Faction-Members"))
return; return;
}
if (updating.contains(faction)) return;
FTeamWrapper wrapper = wrappers.get(faction); FTeamWrapper wrapper = wrappers.get(faction);
Set<FPlayer> factionMembers = faction.getFPlayers(); Set<FPlayer> factionMembers = faction.getFPlayers();
@@ -98,21 +87,16 @@ public class FTeamWrapper {
} }
for (FPlayer fmember : factionMembers) { for (FPlayer fmember : factionMembers) {
if (!fmember.isOnline()) { if (!fmember.isOnline()) continue;
continue;
}
// Scoreboard might not have player; add him/her // Scoreboard might not have player; add him/her
wrapper.addPlayer(fmember.getPlayer()); wrapper.addPlayer(fmember.getPlayer());
} }
wrapper.updatePrefixes(); wrapper.updatePrefixes();
} }
public static void updatePrefixes(Faction faction) { public static void updatePrefixes(Faction faction) {
if (!FScoreboard.isSupportedByServer()) { if (!FScoreboard.isSupportedByServer()) return;
return;
}
if (!wrappers.containsKey(faction)) { if (!wrappers.containsKey(faction)) {
applyUpdates(faction); applyUpdates(faction);
@@ -122,34 +106,22 @@ public class FTeamWrapper {
} }
protected static void track(FScoreboard fboard) { protected static void track(FScoreboard fboard) {
if (!FScoreboard.isSupportedByServer()) { if (!FScoreboard.isSupportedByServer()) return;
return;
}
tracking.add(fboard); tracking.add(fboard);
for (FTeamWrapper wrapper : wrappers.values()) { for (FTeamWrapper wrapper : wrappers.values()) wrapper.add(fboard);
wrapper.add(fboard);
}
} }
protected static void untrack(FScoreboard fboard) { protected static void untrack(FScoreboard fboard) {
if (!FScoreboard.isSupportedByServer()) { if (!FScoreboard.isSupportedByServer()) return;
return;
}
tracking.remove(fboard); tracking.remove(fboard);
for (FTeamWrapper wrapper : wrappers.values()) { for (FTeamWrapper wrapper : wrappers.values()) wrapper.remove(fboard);
wrapper.remove(fboard);
}
} }
private void add(FScoreboard fboard) { private void add(FScoreboard fboard) {
Scoreboard board = fboard.getScoreboard(); Scoreboard board = fboard.getScoreboard();
Team team = board.registerNewTeam(teamName); Team team = board.registerNewTeam(teamName);
teams.put(fboard, team); teams.put(fboard, team);
for (OfflinePlayer player : getPlayers()) team.addPlayer(player);
for (OfflinePlayer player : getPlayers()) {
team.addPlayer(player);
}
updatePrefix(fboard); updatePrefix(fboard);
} }
@@ -159,9 +131,7 @@ public class FTeamWrapper {
private void updatePrefixes() { private void updatePrefixes() {
if (FactionsPlugin.getInstance().getConfig().getBoolean("scoreboard.default-prefixes", false)) { if (FactionsPlugin.getInstance().getConfig().getBoolean("scoreboard.default-prefixes", false)) {
for (FScoreboard fboard : teams.keySet()) { for (FScoreboard fboard : teams.keySet()) updatePrefix(fboard);
updatePrefix(fboard);
}
} }
} }

View File

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

View File

@@ -11,6 +11,7 @@ import com.massivecraft.factions.util.XMaterial;
import com.massivecraft.factions.zcore.util.TL; import com.massivecraft.factions.zcore.util.TL;
import org.bukkit.Bukkit; import org.bukkit.Bukkit;
import org.bukkit.ChatColor; import org.bukkit.ChatColor;
import org.bukkit.Material;
import org.bukkit.configuration.ConfigurationSection; import org.bukkit.configuration.ConfigurationSection;
import org.bukkit.enchantments.Enchantment; import org.bukkit.enchantments.Enchantment;
import org.bukkit.entity.Player; import org.bukkit.entity.Player;
@@ -20,6 +21,9 @@ import org.bukkit.inventory.meta.ItemMeta;
import java.util.ArrayList; import java.util.ArrayList;
import java.util.List; import java.util.List;
import java.util.Map;
import java.util.Set;
import java.util.logging.Level;
import java.util.stream.Collectors; import java.util.stream.Collectors;
public class ShopGUIFrame { public class ShopGUIFrame {
@@ -31,29 +35,30 @@ public class ShopGUIFrame {
private Gui gui; private Gui gui;
public ShopGUIFrame(Faction f) { public ShopGUIFrame(Faction f) {
gui = new Gui(FactionsPlugin.getInstance(), gui = new Gui(FactionsPlugin.getInstance(), FactionsPlugin.getInstance().getConfig().getInt("F-Shop.GUI.Rows", 4), FactionsPlugin.getInstance().color(FactionsPlugin.getInstance().getConfig().getString("F-Shop.GUI.Name")));
FactionsPlugin.getInstance().getConfig().getInt("F-Shop.GUI.Rows", 4),
FactionsPlugin.getInstance().color(FactionsPlugin.getInstance().getConfig().getString("F-Shop.GUI.Name")));
} }
public void buildGUI(FPlayer fplayer) { public void buildGUI(FPlayer fplayer) {
PaginatedPane pane = new PaginatedPane(0, 0, 9, gui.getRows()); PaginatedPane pane = new PaginatedPane(0, 0, 9, gui.getRows());
List<GuiItem> GUIItems = new ArrayList<>(); List<GuiItem> GUIItems = new ArrayList<>();
ItemStack dummy = buildDummyItem(fplayer.getFaction()); ItemStack dummy = buildDummyItem(fplayer.getFaction());
for (int x = 0; x <= (gui.getRows() * 9) - 1; x++) GUIItems.add(new GuiItem(dummy, e -> e.setCancelled(true))); for (int x = 0; x <= (gui.getRows() * 9) - 1; x++)
GUIItems.add(new GuiItem(dummy, e -> e.setCancelled(true)));
Set<String> items = FactionsPlugin.getInstance().getFileManager().getShop().getConfig().getConfigurationSection("items").getKeys(false);
for (String s : items) {
if (!checkShopConfig(s)) {
continue;
}
int items = FactionsPlugin.getInstance().getFileManager().getShop().getConfig().getConfigurationSection("items").getKeys(false).size();
for (int a = 1; a <= items; a++) {
String s = a + "";
int slot = FactionsPlugin.getInstance().getFileManager().getShop().fetchInt("items." + s + ".slot"); int slot = FactionsPlugin.getInstance().getFileManager().getShop().fetchInt("items." + s + ".slot");
ItemStack material = XMaterial.matchXMaterial(FactionsPlugin.getInstance().getFileManager().getShop().fetchString("items." + s + ".block")).get().parseItem(); ItemStack item = XMaterial.matchXMaterial(FactionsPlugin.getInstance().getFileManager().getShop().fetchString("items." + s + ".block")).get().parseItem();
int cost = FactionsPlugin.getInstance().getFileManager().getShop().fetchInt("items." + s + ".cost"); int cost = FactionsPlugin.getInstance().getFileManager().getShop().fetchInt("items." + s + ".cost");
String name = FactionsPlugin.getInstance().getFileManager().getShop().fetchString("items." + s + ".name"); String name = FactionsPlugin.getInstance().getFileManager().getShop().fetchString("items." + s + ".name");
boolean glowing = FactionsPlugin.getInstance().getFileManager().getShop().fetchBoolean("items." + s + ".glowing"); boolean glowing = FactionsPlugin.getInstance().getFileManager().getShop().fetchBoolean("items." + s + ".glowing");
List<String> lore = FactionsPlugin.getInstance().getFileManager().getShop().fetchStringList("items." + s + ".lore"); List<String> lore = FactionsPlugin.getInstance().getFileManager().getShop().fetchStringList("items." + s + ".lore");
assert item != null;
ItemStack item = new ItemStack(material);
ItemMeta meta = item.getItemMeta(); ItemMeta meta = item.getItemMeta();
meta.setDisplayName(FactionsPlugin.instance.color(name)); meta.setDisplayName(FactionsPlugin.instance.color(name));
meta.addItemFlags(); meta.addItemFlags();
@@ -61,23 +66,26 @@ 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) meta.removeEnchant(Enchantment.DURABILITY); if (!glowing)
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); if (runCommands(FactionsPlugin.getInstance().getFileManager().getShop().fetchStringList("items." + s + ".cmds"), fplayer.getPlayer())) {
runCommands(FactionsPlugin.getInstance().getFileManager().getShop().fetchStringList("items." + s + ".cmds"), fplayer.getPlayer()); fplayer.getFaction().setPoints(fplayer.getFaction().getPoints() - cost);
for (FPlayer fplayerBuy : fplayer.getFaction().getFPlayers()) { for (FPlayer fplayerBuy : fplayer.getFaction().getFPlayers()) {
fplayerBuy.getPlayer().sendMessage(TL.SHOP_BOUGHT_BROADCAST_FACTION.toString() fplayerBuy.getPlayer().sendMessage(TL.SHOP_BOUGHT_BROADCAST_FACTION.toString().replace("{player}", fplayer.getPlayer().getName()).replace("{item}", ChatColor.stripColor(FactionsPlugin.getInstance().color(name)))
.replace("{player}", fplayer.getPlayer().getName()) .replace("{cost}", cost + ""));
.replace("{item}", ChatColor.stripColor(FactionsPlugin.getInstance().color(name))) }
.replace("{cost}", cost + "")); buildGUI(fme);
} else {
fplayer.msg(TL.SHOP_ERROR_DURING_PURCHASE);
} }
buildGUI(fme);
} else { } else {
fplayer.msg(TL.SHOP_NOT_ENOUGH_POINTS); fplayer.msg(TL.SHOP_NOT_ENOUGH_POINTS);
} }
@@ -89,7 +97,6 @@ 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")).get().parseItem(); ItemStack item = XMaterial.matchXMaterial(config.getString("Type")).get().parseItem();
@@ -102,10 +109,83 @@ public class ShopGUIFrame {
return item; return item;
} }
public void runCommands(List<String> list, Player p) { public boolean checkShopConfig() {
boolean ret = true;
Set<String> items = FactionsPlugin.getInstance().getFileManager().getShop().getConfig().getConfigurationSection("items").getKeys(false);
for (String s : items) {
if (checkShopConfig(s) == false) {
ret = false;
}
}
return ret;
}
public boolean checkShopConfig(String s) {
boolean ret = true;
if (!FactionsPlugin.getInstance().getFileManager().getShop().containsKey("items." + s + ".slot")) {
FactionsPlugin.getInstance().log(Level.WARNING, "Problem with config item '" + s + "' missing slot variable");
ret = false;
}
if (!FactionsPlugin.getInstance().getFileManager().getShop().containsKey("items." + s + ".block")) {
FactionsPlugin.getInstance().log(Level.WARNING, "Problem with config item '" + s + "' missing block variable");
ret = false;
}
if (!FactionsPlugin.getInstance().getFileManager().getShop().containsKey("items." + s + ".cmds")) {
FactionsPlugin.getInstance().log(Level.WARNING, "Problee with config item '" + s + "' missing cmds variable");
ret = false;
}
if (!FactionsPlugin.getInstance().getFileManager().getShop().containsKey("items." + s + ".cost")) {
FactionsPlugin.getInstance().log(Level.WARNING, "Problem with config item '" + s + "' missing cost variable this item will cost 0");
}
if (!FactionsPlugin.getInstance().getFileManager().getShop().containsKey("items." + s + ".name")) {
FactionsPlugin.getInstance().log(Level.WARNING, "Problem with config item '" + s + "' missing name variable");
ret = false;
}
return ret;
}
/**
* @param list The list of commands to be ran.
* @param p The player that is using the shop
* @return if all commands are able to be ran or if they did run.
*/
public boolean runCommands(List<String> list, Player p) {
for (String cmd : list) {
cmd = cmd.replace("%player%", p.getName());
if (cmd.toLowerCase().startsWith("give")) {
String[] args = cmd.split(" ");
if (args.length == 4) {
Material material = Material.matchMaterial(args[2]);
int amount = Integer.parseInt(args[3]);
Player player = Bukkit.getPlayer(args[1]);
if (!player.isOnline()) {
return false;
}
// See if the player has this item in their inventory;
if (player.getInventory().contains(material) && player.getInventory().firstEmpty() < 0) {
int spacesAvailable = 0;
Map<Integer, ? extends ItemStack> contents = player.getInventory().all(material);
for (ItemStack stack : contents.values()) {
spacesAvailable += stack.getMaxStackSize() - stack.getAmount();
}
if (spacesAvailable < amount) {
return false;
}
} else {
if (player.getInventory().firstEmpty() < 0) {
return false;
}
}
}
}
}
for (String cmd : list) { for (String cmd : list) {
cmd = cmd.replace("%player%", p.getName()); cmd = cmd.replace("%player%", p.getName());
Bukkit.dispatchCommand(Bukkit.getConsoleSender(), cmd); Bukkit.dispatchCommand(Bukkit.getConsoleSender(), cmd);
} }
return true;
} }
} }

View File

@@ -6,7 +6,9 @@ import com.massivecraft.factions.Faction;
import com.massivecraft.factions.FactionsPlugin; import com.massivecraft.factions.FactionsPlugin;
import com.massivecraft.factions.integration.Econ; import com.massivecraft.factions.integration.Econ;
import com.massivecraft.factions.struct.Relation; import com.massivecraft.factions.struct.Relation;
import com.massivecraft.factions.util.timer.DateTimeFormats;
import com.massivecraft.factions.zcore.util.TL; import com.massivecraft.factions.zcore.util.TL;
import org.apache.commons.lang.time.DurationFormatUtils;
import java.util.function.BiFunction; import java.util.function.BiFunction;
import java.util.function.Function; import java.util.function.Function;
@@ -36,6 +38,11 @@ public enum FactionTag implements Tag {
JOINING("{joining}", (fac) -> (fac.getOpen() ? TL.COMMAND_SHOW_UNINVITED.toString() : TL.COMMAND_SHOW_INVITATION.toString())), JOINING("{joining}", (fac) -> (fac.getOpen() ? TL.COMMAND_SHOW_UNINVITED.toString() : TL.COMMAND_SHOW_INVITATION.toString())),
FACTION("{faction}", (Function<Faction, String>) Faction::getTag), FACTION("{faction}", (Function<Faction, String>) Faction::getTag),
FACTION_RELATION_COLOR("{faction-relation-color}", (fac, fp) -> fp == null ? "" : fp.getColorTo(fac).toString()), FACTION_RELATION_COLOR("{faction-relation-color}", (fac, fp) -> fp == null ? "" : fp.getColorTo(fac).toString()),
//SHIELD_STATUS("{shield-status}",(fac) -> {
//if(fac.isProtected() && fac.getShieldFrame() != null) return String.valueOf(TL.SHIELD_CURRENTLY_ENABLE);
//if(fac.getShieldFrame() == null) return String.valueOf(TL.SHIELD_NOT_SET);
// return TL.SHIELD_CURRENTLY_NOT_ENABLED.toString();
//}),
HOME_WORLD("{world}", (fac) -> fac.hasHome() ? fac.getHome().getWorld().getName() : Tag.isMinimalShow() ? null : "{ig}"), HOME_WORLD("{world}", (fac) -> fac.hasHome() ? fac.getHome().getWorld().getName() : Tag.isMinimalShow() ? null : "{ig}"),
RAIDABLE("{raidable}", (fac) -> { RAIDABLE("{raidable}", (fac) -> {
if (FactionsPlugin.getInstance().getConfig().getBoolean("hcf.raidable", false)) { if (FactionsPlugin.getInstance().getConfig().getBoolean("hcf.raidable", false)) {
@@ -149,10 +156,7 @@ public enum FactionTag implements Tag {
if (!this.foundInString(text)) { if (!this.foundInString(text)) {
return text; return text;
} }
String result = null; String result = this.function == null ? this.biFunction.apply(faction, player) : this.function.apply(faction);
if (this.biFunction != null) {
result = this.function == null ? this.biFunction.apply(faction, player) : this.function.apply(faction);
}
return result == null ? null : text.replace(this.tag, result); return result == null ? null : text.replace(this.tag, result);
} }

View File

@@ -21,6 +21,7 @@ public enum PlayerTag implements Tag {
}), }),
PLAYER_BALANCE("{balance}", (fp) -> Econ.isSetup() ? Econ.getFriendlyBalance(fp) : (Tag.isMinimalShow() ? null : TL.ECON_OFF.format("balance"))), PLAYER_BALANCE("{balance}", (fp) -> Econ.isSetup() ? Econ.getFriendlyBalance(fp) : (Tag.isMinimalShow() ? null : TL.ECON_OFF.format("balance"))),
PLAYER_POWER("{player-power}", (fp) -> String.valueOf(fp.getPowerRounded())), PLAYER_POWER("{player-power}", (fp) -> String.valueOf(fp.getPowerRounded())),
ROLE("{player-role}", FPlayer::getRolePrefix),
PLAYER_MAXPOWER("{player-maxpower}", (fp) -> String.valueOf(fp.getPowerMaxRounded())), PLAYER_MAXPOWER("{player-maxpower}", (fp) -> String.valueOf(fp.getPowerMaxRounded())),
PLAYER_KILLS("{player-kills}", (fp) -> String.valueOf(fp.getKills())), PLAYER_KILLS("{player-kills}", (fp) -> String.valueOf(fp.getKills())),
PLAYER_DEATHS("{player-deaths}", (fp) -> String.valueOf(fp.getDeaths())), PLAYER_DEATHS("{player-deaths}", (fp) -> String.valueOf(fp.getDeaths())),

View File

@@ -14,10 +14,16 @@ import org.bukkit.Bukkit;
import org.bukkit.ChatColor; import org.bukkit.ChatColor;
import org.bukkit.entity.Player; import org.bukkit.entity.Player;
import java.lang.reflect.InvocationTargetException;
import java.util.UUID; import java.util.UUID;
import java.util.logging.Level;
public class ClipPlaceholderAPIManager extends PlaceholderExpansion implements Relational { public class ClipPlaceholderAPIManager extends PlaceholderExpansion implements Relational {
private static void logInvalid(String placeholder) {
FactionsPlugin.getInstance().getLogger().log(Level.INFO, "Invalid request through PlaceholderAPI for placeholder '" + placeholder + "'");
}
// Identifier for this expansion // Identifier for this expansion
@Override @Override
public String getIdentifier() { public String getIdentifier() {
@@ -210,17 +216,42 @@ public class ClipPlaceholderAPIManager extends PlaceholderExpansion implements R
return String.valueOf(faction.getMaxVaults()); return String.valueOf(faction.getMaxVaults());
case "faction_relation_color": case "faction_relation_color":
return fPlayer.getColorTo(faction).toString(); return fPlayer.getColorTo(faction).toString();
case "faction_grace_time": case "grace_time":
return String.valueOf(TimerManager.getRemaining(FactionsPlugin.getInstance().getTimerManager().graceTimer.getRemaining(), true)); if (FactionsPlugin.getInstance().getTimerManager().graceTimer.getRemaining() >= 0) {
return String.valueOf(TimerManager.getRemaining(FactionsPlugin.getInstance().getTimerManager().graceTimer.getRemaining(), true));
} else {
return TL.GRACE_DISABLED_PLACEHOLDER.toString();
}
case "faction_name_at_location": case "faction_name_at_location":
Faction factionAtLocation = Board.getInstance().getFactionAt(new FLocation(player.getLocation())); Faction factionAtLocation = Board.getInstance().getFactionAt(new FLocation(player.getLocation()));
return factionAtLocation != null ? factionAtLocation.getTag() : Factions.getInstance().getWilderness().getTag(); return factionAtLocation != null ? factionAtLocation.getTag() : Factions.getInstance().getWilderness().getTag();
} }
//If its not hardcoded lets try to grab it anyways
boolean targetFaction = false;
Object target = fPlayer;
String stripped = "";
if (placeholder.startsWith("faction_")) {
targetFaction = true;
target = faction;
stripped = placeholder.replace("faction_", "");
} else {
stripped = placeholder.replace("player_", "");
}
try {
Object pulled;
if (targetFaction) {
pulled = Faction.class.getDeclaredMethod(stripped).invoke(target);
} else {
pulled = FPlayer.class.getDeclaredMethod(stripped).invoke(target);
}
return String.valueOf(pulled);
} catch (NoSuchMethodException | IllegalAccessException | InvocationTargetException e) {
logInvalid(stripped);
}
return null; return TL.PLACEHOLDERAPI_NULL.toString();
} }
private int countOn(Faction f, Relation relation, Boolean status, FPlayer player) { private int countOn(Faction f, Relation relation, Boolean status, FPlayer player) {
int count = 0; int count = 0;
for (Faction faction : Factions.getInstance().getAllFactions()) { for (Faction faction : Factions.getInstance().getAllFactions()) {

View File

@@ -3,7 +3,6 @@ package com.massivecraft.factions.util;
import com.massivecraft.factions.FactionsPlugin; import com.massivecraft.factions.FactionsPlugin;
import org.bukkit.entity.Player; import org.bukkit.entity.Player;
import org.bukkit.metadata.FixedMetadataValue; import org.bukkit.metadata.FixedMetadataValue;
import org.bukkit.metadata.MetadataValue;
import java.util.concurrent.TimeUnit; import java.util.concurrent.TimeUnit;

View File

@@ -2,6 +2,7 @@ package com.massivecraft.factions.util;
import com.massivecraft.factions.FLocation; import com.massivecraft.factions.FLocation;
import com.massivecraft.factions.FPlayer; import com.massivecraft.factions.FPlayer;
import com.massivecraft.factions.FactionsPlugin;
import com.massivecraft.factions.zcore.util.TL; import com.massivecraft.factions.zcore.util.TL;
import org.bukkit.scheduler.BukkitRunnable; import org.bukkit.scheduler.BukkitRunnable;
@@ -26,7 +27,9 @@ public class CornerTask extends BukkitRunnable {
cancel(); cancel();
} else { } else {
FLocation fLocation = surrounding.remove(0); FLocation fLocation = surrounding.remove(0);
if (fPlayer.attemptClaim(fPlayer.getFaction(), fLocation, true)) { if (FactionsPlugin.cachedRadiusClaim && fPlayer.attemptClaim(fPlayer.getFaction(), fLocation, true)) {
++amount;
} else if (fPlayer.attemptClaim(fPlayer.getFaction(), fLocation, true)) {
++amount; ++amount;
} else { } else {
fPlayer.sendMessage(TL.COMMAND_CORNER_FAIL_WITH_FEEDBACK.toString().replace("&", "§") + amount); fPlayer.sendMessage(TL.COMMAND_CORNER_FAIL_WITH_FEEDBACK.toString().replace("&", "§") + amount);

View File

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

View File

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

View File

@@ -1,5 +1,4 @@
package com.massivecraft.factions.util; package com.massivecraft.factions.util;
/* /*
* The MIT License (MIT) * The MIT License (MIT)
* *
@@ -42,30 +41,23 @@ import java.util.*;
import java.util.concurrent.TimeUnit; import java.util.concurrent.TimeUnit;
import java.util.regex.Pattern; import java.util.regex.Pattern;
/* /**
* References * <b>XMaterial</b> - Data Values/Pre-flattening<br>
* * 1.13 and above as priority.
* * * GitHub: https://github.com/CryptoMorin/XSeries/blob/master/XMaterial.java * <p>
* * XSeries: https://www.spigotmc.org/threads/378136/ * This class is mainly designed to support ItemStacks.
* If you want to use it on blocks you'll have to
* use <a href="https://github.com/CryptoMorin/XSeries/blob/master/XBlock.java">XBlock</a>
* <p>
* Pre-flattening: https://minecraft.gamepedia.com/Java_Edition_data_values/Pre-flattening * Pre-flattening: https://minecraft.gamepedia.com/Java_Edition_data_values/Pre-flattening
* Materials: https://hub.spigotmc.org/javadocs/spigot/org/bukkit/Material.html * Materials: https://hub.spigotmc.org/javadocs/spigot/org/bukkit/Material.html
* Materials (1.12): https://helpch.at/docs/1.12.2/index.html?org/bukkit/Material.html * Materials (1.12): https://helpch.at/docs/1.12.2/index.html?org/bukkit/Material.html
* Material IDs: https://minecraft-ids.grahamedgecombe.com/ * Material IDs: https://minecraft-ids.grahamedgecombe.com/
* Material Source Code: https://hub.spigotmc.org/stash/projects/SPIGOT/repos/bukkit/browse/src/main/java/org/bukkit/Material.java * Material Source Code: https://hub.spigotmc.org/stash/projects/SPIGOT/repos/bukkit/browse/src/main/java/org/bukkit/Material.java
* XMaterial v1: https://www.spigotmc.org/threads/329630/ * XMaterial v1: https://www.spigotmc.org/threads/329630/
*/
/**
* <b>XMaterial</b> - Data Values/Pre-flattening<br>
* Supports 1.8-1.15<br>
* 1.13 and above as priority.
* <p>
* This class is mainly designed to support ItemStacks.
* If you want to use it on blocks you'll have to
* use <a href="https://github.com/CryptoMorin/XSeries/blob/master/XBlock.java">XBlock</a>
* *
* @author Crypto Morin * @author Crypto Morin
* @version 4.0.0 * @version 5.0.0
* @see Material * @see Material
* @see ItemStack * @see ItemStack
*/ */
@@ -96,6 +88,7 @@ public enum XMaterial {
*/ */
AIR, AIR,
ALLIUM(2, "RED_ROSE"), ALLIUM(2, "RED_ROSE"),
ANCIENT_DEBRIS("1.16"),
ANDESITE(5, "STONE"), ANDESITE(5, "STONE"),
ANDESITE_SLAB, ANDESITE_SLAB,
ANDESITE_STAIRS, ANDESITE_STAIRS,
@@ -112,6 +105,7 @@ public enum XMaterial {
BAMBOO_SAPLING("1.14"), BAMBOO_SAPLING("1.14"),
BARREL("1.14", "CHEST", ""), BARREL("1.14", "CHEST", ""),
BARRIER, BARRIER,
BASALT("1.16"),
BAT_SPAWN_EGG(65, "MONSTER_EGG"), BAT_SPAWN_EGG(65, "MONSTER_EGG"),
BEACON, BEACON,
BEDROCK, BEDROCK,
@@ -144,8 +138,12 @@ public enum XMaterial {
BIRCH_TRAPDOOR("TRAP_DOOR"), BIRCH_TRAPDOOR("TRAP_DOOR"),
BIRCH_WALL_SIGN("SIGN_POST", "WALL_SIGN"), BIRCH_WALL_SIGN("SIGN_POST", "WALL_SIGN"),
BIRCH_WOOD(2, "LOG"), BIRCH_WOOD(2, "LOG"),
BLACKSTONE("1.16"),
BLACKSTONE_SLAB("1.16"),
BLACKSTONE_STAIRS("1.16"),
BLACKSTONE_WALL("1.16"),
BLACK_BANNER("BANNER", "STANDING_BANNER"), BLACK_BANNER("BANNER", "STANDING_BANNER"),
BLACK_BED(15, "BED", "BED_BLOCK"), BLACK_BED(15, "BED_BLOCK", "BED"),
BLACK_CARPET(15, "CARPET"), BLACK_CARPET(15, "CARPET"),
BLACK_CONCRETE(15, "CONCRETE"), BLACK_CONCRETE(15, "CONCRETE"),
BLACK_CONCRETE_POWDER(15, "CONCRETE_POWDER"), BLACK_CONCRETE_POWDER(15, "CONCRETE_POWDER"),
@@ -161,8 +159,8 @@ public enum XMaterial {
BLAZE_POWDER, BLAZE_POWDER,
BLAZE_ROD, BLAZE_ROD,
BLAZE_SPAWN_EGG(61, "MONSTER_EGG"), BLAZE_SPAWN_EGG(61, "MONSTER_EGG"),
BLUE_BANNER(11, "BANNER", "STANDING_BANNER"), BLUE_BANNER(4, "BANNER", "STANDING_BANNER"),
BLUE_BED(4, "BED", "BED_BLOCK"), BLUE_BED(11, "BED_BLOCK", "BED"),
BLUE_CARPET(11, "CARPET"), BLUE_CARPET(11, "CARPET"),
BLUE_CONCRETE(11, "CONCRETE"), BLUE_CONCRETE(11, "CONCRETE"),
BLUE_CONCRETE_POWDER(11, "CONCRETE_POWDER"), BLUE_CONCRETE_POWDER(11, "CONCRETE_POWDER"),
@@ -173,8 +171,8 @@ public enum XMaterial {
BLUE_SHULKER_BOX, BLUE_SHULKER_BOX,
BLUE_STAINED_GLASS(11, "STAINED_GLASS"), BLUE_STAINED_GLASS(11, "STAINED_GLASS"),
BLUE_STAINED_GLASS_PANE(11, "THIN_GLASS", "STAINED_GLASS_PANE"), BLUE_STAINED_GLASS_PANE(11, "THIN_GLASS", "STAINED_GLASS_PANE"),
BLUE_TERRACOTTA(11, "STAINED_CLAY"), BLUE_TERRACOTTA(11, "HARD_CLAY", "STAINED_CLAY"),
BLUE_WALL_BANNER(11, "WALL_BANNER"), BLUE_WALL_BANNER(4, "WALL_BANNER"),
BLUE_WOOL(11, "WOOL"), BLUE_WOOL(11, "WOOL"),
BONE, BONE,
BONE_BLOCK, BONE_BLOCK,
@@ -195,7 +193,7 @@ public enum XMaterial {
BRICK_STAIRS, BRICK_STAIRS,
BRICK_WALL, BRICK_WALL,
BROWN_BANNER(3, "BANNER", "STANDING_BANNER"), BROWN_BANNER(3, "BANNER", "STANDING_BANNER"),
BROWN_BED(12, "BED", "BED_BLOCK"), BROWN_BED(12, "BED_BLOCK", "BED"),
BROWN_CARPET(12, "CARPET"), BROWN_CARPET(12, "CARPET"),
BROWN_CONCRETE(12, "CONCRETE"), BROWN_CONCRETE(12, "CONCRETE"),
BROWN_CONCRETE_POWDER(12, "CONCRETE_POWDER"), BROWN_CONCRETE_POWDER(12, "CONCRETE_POWDER"),
@@ -232,6 +230,7 @@ public enum XMaterial {
*/ */
CAVE_AIR("AIR"), CAVE_AIR("AIR"),
CAVE_SPIDER_SPAWN_EGG(59, "MONSTER_EGG"), CAVE_SPIDER_SPAWN_EGG(59, "MONSTER_EGG"),
CHAIN("1.16"),
CHAINMAIL_BOOTS, CHAINMAIL_BOOTS,
CHAINMAIL_CHESTPLATE, CHAINMAIL_CHESTPLATE,
CHAINMAIL_HELMET, CHAINMAIL_HELMET,
@@ -243,6 +242,8 @@ public enum XMaterial {
CHICKEN("RAW_CHICKEN"), CHICKEN("RAW_CHICKEN"),
CHICKEN_SPAWN_EGG(93, "MONSTER_EGG"), CHICKEN_SPAWN_EGG(93, "MONSTER_EGG"),
CHIPPED_ANVIL(1, "ANVIL"), CHIPPED_ANVIL(1, "ANVIL"),
CHISELED_NETHER_BRICKS(1, "NETHER_BRICKS"),
CHISELED_POLISHED_BLACKSTONE("1.16", "POLISHED_BLACKSTONE"),
CHISELED_QUARTZ_BLOCK(1, "QUARTZ_BLOCK"), CHISELED_QUARTZ_BLOCK(1, "QUARTZ_BLOCK"),
CHISELED_RED_SANDSTONE(1, "RED_SANDSTONE"), CHISELED_RED_SANDSTONE(1, "RED_SANDSTONE"),
CHISELED_SANDSTONE(1, "SANDSTONE"), CHISELED_SANDSTONE(1, "SANDSTONE"),
@@ -269,7 +270,14 @@ public enum XMaterial {
COD_SPAWN_EGG("1.13", "MONSTER_EGG", ""), COD_SPAWN_EGG("1.13", "MONSTER_EGG", ""),
COMMAND_BLOCK("COMMAND"), COMMAND_BLOCK("COMMAND"),
COMMAND_BLOCK_MINECART("COMMAND_MINECART"), COMMAND_BLOCK_MINECART("COMMAND_MINECART"),
COMPARATOR("REDSTONE_COMPARATOR", "REDSTONE_COMPARATOR_ON", "REDSTONE_COMPARATOR_OFF"), /**
* Unlike redstone torch and redstone lamp... neither REDTONE_COMPARATOR_OFF nor REDSTONE_COMPARATOR_ON
* are items. REDSTONE_COMPARATOR is.
*
* @see #REDSTONE_TORCH
* @see #REDSTONE_LAMP
*/
COMPARATOR("REDSTONE_COMPARATOR_OFF", "REDSTONE_COMPARATOR_ON", "REDSTONE_COMPARATOR"),
COMPASS, COMPASS,
COMPOSTER("1.14", "CAULDRON", ""), COMPOSTER("1.14", "CAULDRON", ""),
CONDUIT("1.13", "BEACON"), CONDUIT("1.13", "BEACON"),
@@ -283,19 +291,38 @@ public enum XMaterial {
COOKIE, COOKIE,
CORNFLOWER(4, "1.14", "BLUE_DYE", ""), CORNFLOWER(4, "1.14", "BLUE_DYE", ""),
COW_SPAWN_EGG(92, "MONSTER_EGG"), COW_SPAWN_EGG(92, "MONSTER_EGG"),
CRACKED_NETHER_BRICKS(2, "NETHER_BRICKS"),
CRACKED_POLISHED_BLACKSTONE_BRICKS("1.16", "POLISHED_BLACKSTONE_BRICKS"),
CRACKED_STONE_BRICKS(2, "SMOOTH_BRICK"), CRACKED_STONE_BRICKS(2, "SMOOTH_BRICK"),
CRAFTING_TABLE("WORKBENCH"), CRAFTING_TABLE("WORKBENCH"),
CREEPER_BANNER_PATTERN, CREEPER_BANNER_PATTERN,
CREEPER_HEAD(4, "SKULL", "SKULL_ITEM"), CREEPER_HEAD(4, "SKULL", "SKULL_ITEM"),
CREEPER_SPAWN_EGG(50, "MONSTER_EGG"), CREEPER_SPAWN_EGG(50, "MONSTER_EGG"),
CREEPER_WALL_HEAD(4, "SKULL", "SKULL_ITEM"), CREEPER_WALL_HEAD(4, "SKULL", "SKULL_ITEM"),
CRIMSON_BUTTON("1.16"),
CRIMSON_DOOR("1.16"),
CRIMSON_FENCE("1.16"),
CRIMSON_FENCE_GATE("1.16"),
CRIMSON_FUNGUS("1.16"),
CRIMSON_HYPHAE("1.16"),
CRIMSON_NYLIUM("1.16"),
CRIMSON_PLANKS("1.16"),
CRIMSON_PRESSURE_PLATE("1.16"),
CRIMSON_ROOTS("1.16"),
CRIMSON_SIGN("1.16"),
CRIMSON_SLAB("1.16"),
CRIMSON_STAIRS("1.16"),
CRIMSON_STEM("1.16"),
CRIMSON_TRAPDOOR("1.16"),
CRIMSON_WALL_SIGN("1.16"),
CROSSBOW, CROSSBOW,
CRYING_OBSIDIAN("1.16"),
CUT_RED_SANDSTONE("1.13"), CUT_RED_SANDSTONE("1.13"),
CUT_RED_SANDSTONE_SLAB("STONE_SLAB2"), CUT_RED_SANDSTONE_SLAB("STONE_SLAB2"),
CUT_SANDSTONE("1.13"), CUT_SANDSTONE("1.13"),
CUT_SANDSTONE_SLAB("STEP"), CUT_SANDSTONE_SLAB("STEP"),
CYAN_BANNER(6, "BANNER", "STANDING_BANNER"), CYAN_BANNER(6, "BANNER", "STANDING_BANNER"),
CYAN_BED(9, "BED", "BED_BLOCK"), CYAN_BED(9, "BED_BLOCK", "BED"),
CYAN_CARPET(9, "CARPET"), CYAN_CARPET(9, "CARPET"),
CYAN_CONCRETE(9, "CONCRETE"), CYAN_CONCRETE(9, "CONCRETE"),
CYAN_CONCRETE_POWDER(9, "CONCRETE_POWDER"), CYAN_CONCRETE_POWDER(9, "CONCRETE_POWDER"),
@@ -314,13 +341,13 @@ public enum XMaterial {
DARK_OAK_DOOR("DARK_OAK_DOOR_ITEM"), DARK_OAK_DOOR("DARK_OAK_DOOR_ITEM"),
DARK_OAK_FENCE, DARK_OAK_FENCE,
DARK_OAK_FENCE_GATE, DARK_OAK_FENCE_GATE,
DARK_OAK_LEAVES(1, "LEAVES", "LEAVES_2"), DARK_OAK_LEAVES(4, "LEAVES", "LEAVES_2"),
DARK_OAK_LOG(1, "LOG", "LOG_2"), DARK_OAK_LOG(1, "LOG", "LOG_2"),
DARK_OAK_PLANKS(5, "WOOD"), DARK_OAK_PLANKS(5, "WOOD"),
DARK_OAK_PRESSURE_PLATE("WOOD_PLATE"), DARK_OAK_PRESSURE_PLATE("WOOD_PLATE"),
DARK_OAK_SAPLING(5, "SAPLING"), DARK_OAK_SAPLING(5, "SAPLING"),
DARK_OAK_SIGN("SIGN"), DARK_OAK_SIGN("SIGN"),
DARK_OAK_SLAB("WOOD_STEP", "WOODEN_SLAB", "WOOD_DOUBLE_STEP"), DARK_OAK_SLAB(5, "WOOD_STEP", "WOODEN_SLAB", "WOOD_DOUBLE_STEP"),
DARK_OAK_STAIRS, DARK_OAK_STAIRS,
DARK_OAK_TRAPDOOR("TRAP_DOOR"), DARK_OAK_TRAPDOOR("TRAP_DOOR"),
DARK_OAK_WALL_SIGN("SIGN_POST", "WALL_SIGN"), DARK_OAK_WALL_SIGN("SIGN_POST", "WALL_SIGN"),
@@ -402,7 +429,7 @@ public enum XMaterial {
END_ROD("1.9", "BLAZE_ROD", ""), END_ROD("1.9", "BLAZE_ROD", ""),
END_STONE("ENDER_STONE"), END_STONE("ENDER_STONE"),
END_STONE_BRICKS("END_BRICKS"), END_STONE_BRICKS("END_BRICKS"),
END_STONE_BRICK_SLAB(4, "STEP"), END_STONE_BRICK_SLAB(6, "STEP"),
END_STONE_BRICK_STAIRS("SMOOTH_STAIRS"), END_STONE_BRICK_STAIRS("SMOOTH_STAIRS"),
END_STONE_BRICK_WALL, END_STONE_BRICK_WALL,
EVOKER_SPAWN_EGG(34, "MONSTER_EGG"), EVOKER_SPAWN_EGG(34, "MONSTER_EGG"),
@@ -410,7 +437,12 @@ public enum XMaterial {
FARMLAND("SOIL"), FARMLAND("SOIL"),
FEATHER, FEATHER,
FERMENTED_SPIDER_EYE, FERMENTED_SPIDER_EYE,
FERN(2, "LONG_GRASS"), FERN(1, "LONG_GRASS"),
/**
* For some reasons filled map items are really special.
* Their data value starts from 0 and every time a player
* creates a new map that maps data value increases.
*/
FILLED_MAP("MAP"), FILLED_MAP("MAP"),
FIRE, FIRE,
FIREWORK_ROCKET("FIREWORK"), FIREWORK_ROCKET("FIREWORK"),
@@ -467,7 +499,7 @@ public enum XMaterial {
GRASS_PATH, GRASS_PATH,
GRAVEL, GRAVEL,
GRAY_BANNER(8, "BANNER", "STANDING_BANNER"), GRAY_BANNER(8, "BANNER", "STANDING_BANNER"),
GRAY_BED(7, "BED", "BED_BLOCK"), GRAY_BED(7, "BED_BLOCK", "BED"),
GRAY_CARPET(7, "CARPET"), GRAY_CARPET(7, "CARPET"),
GRAY_CONCRETE(7, "CONCRETE"), GRAY_CONCRETE(7, "CONCRETE"),
GRAY_CONCRETE_POWDER(7, "CONCRETE_POWDER"), GRAY_CONCRETE_POWDER(7, "CONCRETE_POWDER"),
@@ -480,7 +512,7 @@ public enum XMaterial {
GRAY_WALL_BANNER(8, "WALL_BANNER"), GRAY_WALL_BANNER(8, "WALL_BANNER"),
GRAY_WOOL(7, "WOOL"), GRAY_WOOL(7, "WOOL"),
GREEN_BANNER(2, "BANNER", "STANDING_BANNER"), GREEN_BANNER(2, "BANNER", "STANDING_BANNER"),
GREEN_BED(13, "BED", "BED_BLOCK"), GREEN_BED(13, "BED_BLOCK", "BED"),
GREEN_CARPET(13, "CARPET"), GREEN_CARPET(13, "CARPET"),
GREEN_CONCRETE(13, "CONCRETE"), GREEN_CONCRETE(13, "CONCRETE"),
GREEN_CONCRETE_POWDER(13, "CONCRETE_POWDER"), GREEN_CONCRETE_POWDER(13, "CONCRETE_POWDER"),
@@ -498,6 +530,7 @@ public enum XMaterial {
HAY_BLOCK, HAY_BLOCK,
HEART_OF_THE_SEA("1.13"), HEART_OF_THE_SEA("1.13"),
HEAVY_WEIGHTED_PRESSURE_PLATE("IRON_PLATE"), HEAVY_WEIGHTED_PRESSURE_PLATE("IRON_PLATE"),
HOGLIN_SPAWN_EGG("1.16", "MONSTER_EGG"),
HONEYCOMB("1.15"), HONEYCOMB("1.15"),
HONEYCOMB_BLOCK("1.15"), HONEYCOMB_BLOCK("1.15"),
HONEY_BLOCK("1.15", "SLIME_BLOCK", ""), HONEY_BLOCK("1.15", "SLIME_BLOCK", ""),
@@ -575,8 +608,8 @@ public enum XMaterial {
LEATHER_LEGGINGS, LEATHER_LEGGINGS,
LECTERN("1.14", "BOOKSHELF", ""), LECTERN("1.14", "BOOKSHELF", ""),
LEVER, LEVER,
LIGHT_BLUE_BANNER(3, "BANNER", "STANDING_BANNER"), LIGHT_BLUE_BANNER(12, "BANNER", "STANDING_BANNER"),
LIGHT_BLUE_BED(3, "BED", "BED_BLOCK"), LIGHT_BLUE_BED(3, "BED_BLOCK", "BED"),
LIGHT_BLUE_CARPET(3, "CARPET"), LIGHT_BLUE_CARPET(3, "CARPET"),
LIGHT_BLUE_CONCRETE(3, "CONCRETE"), LIGHT_BLUE_CONCRETE(3, "CONCRETE"),
LIGHT_BLUE_CONCRETE_POWDER(3, "CONCRETE_POWDER"), LIGHT_BLUE_CONCRETE_POWDER(3, "CONCRETE_POWDER"),
@@ -589,16 +622,16 @@ public enum XMaterial {
LIGHT_BLUE_WALL_BANNER(12, "WALL_BANNER", "BANNER", "STANDING_BANNER"), LIGHT_BLUE_WALL_BANNER(12, "WALL_BANNER", "BANNER", "STANDING_BANNER"),
LIGHT_BLUE_WOOL(3, "WOOL"), LIGHT_BLUE_WOOL(3, "WOOL"),
LIGHT_GRAY_BANNER(7, "BANNER", "STANDING_BANNER"), LIGHT_GRAY_BANNER(7, "BANNER", "STANDING_BANNER"),
LIGHT_GRAY_BED(8, "BED", "BED_BLOCK"), LIGHT_GRAY_BED(8, "BED_BLOCK", "BED"),
LIGHT_GRAY_CARPET(8, "CARPET"), LIGHT_GRAY_CARPET(8, "CARPET"),
LIGHT_GRAY_CONCRETE(8, "CONCRETE"), LIGHT_GRAY_CONCRETE(8, "CONCRETE"),
LIGHT_GRAY_CONCRETE_POWDER(8, "CONCRETE_POWDER"), LIGHT_GRAY_CONCRETE_POWDER(8, "CONCRETE_POWDER"),
LIGHT_GRAY_DYE(7, "INK_SACK"), LIGHT_GRAY_DYE(7, "INK_SACK"),
/** /**
* Renamed to SILVER_GLAZED_TERRACOTTA in 1.13 * Renamed to SILVER_GLAZED_TERRACOTTA in 1.12
* Renamed to LIGHT_GRAY_GLAZED_TERRACOTTA in 1.14 * Renamed to LIGHT_GRAY_GLAZED_TERRACOTTA in 1.14
*/ */
LIGHT_GRAY_GLAZED_TERRACOTTA(8, "1.12", "HARD_CLAY", "STAINED_CLAY", "LIGHT_GRAY_TERRACOTTA", "SILVER_GLAZED_TERRACOTTA"), LIGHT_GRAY_GLAZED_TERRACOTTA("1.12", "HARD_CLAY", "STAINED_CLAY", "LIGHT_GRAY_TERRACOTTA", "SILVER_GLAZED_TERRACOTTA"),
LIGHT_GRAY_SHULKER_BOX("SILVER_SHULKER_BOX"), LIGHT_GRAY_SHULKER_BOX("SILVER_SHULKER_BOX"),
LIGHT_GRAY_STAINED_GLASS(8, "STAINED_GLASS"), LIGHT_GRAY_STAINED_GLASS(8, "STAINED_GLASS"),
LIGHT_GRAY_STAINED_GLASS_PANE(8, "THIN_GLASS", "STAINED_GLASS_PANE"), LIGHT_GRAY_STAINED_GLASS_PANE(8, "THIN_GLASS", "STAINED_GLASS_PANE"),
@@ -610,7 +643,7 @@ public enum XMaterial {
LILY_OF_THE_VALLEY(15, "1.14", "WHITE_DYE", ""), LILY_OF_THE_VALLEY(15, "1.14", "WHITE_DYE", ""),
LILY_PAD("WATER_LILY"), LILY_PAD("WATER_LILY"),
LIME_BANNER(10, "BANNER", "STANDING_BANNER"), LIME_BANNER(10, "BANNER", "STANDING_BANNER"),
LIME_BED(5, "BED", "BED_BLOCK"), LIME_BED(5, "BED_BLOCK", "BED"),
LIME_CARPET(5, "CARPET"), LIME_CARPET(5, "CARPET"),
LIME_CONCRETE(5, "CONCRETE"), LIME_CONCRETE(5, "CONCRETE"),
LIME_CONCRETE_POWDER(5, "CONCRETE_POWDER"), LIME_CONCRETE_POWDER(5, "CONCRETE_POWDER"),
@@ -624,9 +657,10 @@ public enum XMaterial {
LIME_WOOL(5, "WOOL"), LIME_WOOL(5, "WOOL"),
LINGERING_POTION, LINGERING_POTION,
LLAMA_SPAWN_EGG(103, "MONSTER_EGG"), LLAMA_SPAWN_EGG(103, "MONSTER_EGG"),
LODESTONE("1.16"),
LOOM("1.14"), LOOM("1.14"),
MAGENTA_BANNER(13, "BANNER", "STANDING_BANNER"), MAGENTA_BANNER(13, "BANNER", "STANDING_BANNER"),
MAGENTA_BED(2, "BED", "BED_BLOCK"), MAGENTA_BED(2, "BED_BLOCK", "BED"),
MAGENTA_CARPET(2, "CARPET"), MAGENTA_CARPET(2, "CARPET"),
MAGENTA_CONCRETE(2, "CONCRETE"), MAGENTA_CONCRETE(2, "CONCRETE"),
MAGENTA_CONCRETE_POWDER(2, "CONCRETE_POWDER"), MAGENTA_CONCRETE_POWDER(2, "CONCRETE_POWDER"),
@@ -641,6 +675,13 @@ public enum XMaterial {
MAGMA_BLOCK("1.10", "MAGMA"), MAGMA_BLOCK("1.10", "MAGMA"),
MAGMA_CREAM, MAGMA_CREAM,
MAGMA_CUBE_SPAWN_EGG(62, "MONSTER_EGG"), MAGMA_CUBE_SPAWN_EGG(62, "MONSTER_EGG"),
/**
* Adding this to the duplicated list will give you a filled map
* for 1.13+ versions and removing it from duplicated list will
* still give you a filled map in -1.12 versions.
* Since higher versions are our priority I'll keep 1.13+ support
* until I can come up with something to fix it.
*/
MAP("EMPTY_MAP"), MAP("EMPTY_MAP"),
MELON("MELON_BLOCK"), MELON("MELON_BLOCK"),
MELON_SEEDS, MELON_SEEDS,
@@ -655,7 +696,7 @@ public enum XMaterial {
MOSSY_COBBLESTONE_STAIRS, MOSSY_COBBLESTONE_STAIRS,
MOSSY_COBBLESTONE_WALL(1, "COBBLE_WALL", "COBBLESTONE_WALL"), MOSSY_COBBLESTONE_WALL(1, "COBBLE_WALL", "COBBLESTONE_WALL"),
MOSSY_STONE_BRICKS(1, "SMOOTH_BRICK"), MOSSY_STONE_BRICKS(1, "SMOOTH_BRICK"),
MOSSY_STONE_BRICK_SLAB(4, "STEP"), MOSSY_STONE_BRICK_SLAB(5, "STEP"),
MOSSY_STONE_BRICK_STAIRS("SMOOTH_STAIRS"), MOSSY_STONE_BRICK_STAIRS("SMOOTH_STAIRS"),
MOSSY_STONE_BRICK_WALL, MOSSY_STONE_BRICK_WALL,
MOVING_PISTON("PISTON_BASE", "PISTON_MOVING_PIECE"), MOVING_PISTON("PISTON_BASE", "PISTON_MOVING_PIECE"),
@@ -678,15 +719,29 @@ public enum XMaterial {
MYCELIUM("MYCEL"), MYCELIUM("MYCEL"),
NAME_TAG, NAME_TAG,
NAUTILUS_SHELL("1.13"), NAUTILUS_SHELL("1.13"),
NETHERITE_AXE("1.16"),
NETHERITE_BLOCK("1.16"),
NETHERITE_BOOTS("1.16"),
NETHERITE_CHESTPLATE("1.16"),
NETHERITE_HELMET("1.16"),
NETHERITE_HOE("1.16"),
NETHERITE_INGOT("1.16"),
NETHERITE_LEGGINGS("1.16"),
NETHERITE_PICKAXE("1.16"),
NETHERITE_SCRAP("1.16"),
NETHERITE_SHOVEL("1.16"),
NETHERITE_SWORD("1.16"),
NETHERRACK, NETHERRACK,
NETHER_BRICK("NETHER_BRICK_ITEM"), NETHER_BRICK("NETHER_BRICK_ITEM"),
NETHER_BRICKS("NETHER_BRICK"), NETHER_BRICKS("NETHER_BRICK"),
NETHER_BRICK_FENCE("NETHER_FENCE"), NETHER_BRICK_FENCE("NETHER_FENCE"),
NETHER_BRICK_SLAB(4, "STEP"), NETHER_BRICK_SLAB(6, "STEP"),
NETHER_BRICK_STAIRS, NETHER_BRICK_STAIRS,
NETHER_BRICK_WALL, NETHER_BRICK_WALL,
NETHER_GOLD_ORE("1.16"),
NETHER_PORTAL("PORTAL"), NETHER_PORTAL("PORTAL"),
NETHER_QUARTZ_ORE("QUARTZ_ORE"), NETHER_QUARTZ_ORE("QUARTZ_ORE"),
NETHER_SPROUTS("1.16"),
NETHER_STAR, NETHER_STAR,
/** /**
* Just like mentioned in https://minecraft.gamepedia.com/Nether_Wart * Just like mentioned in https://minecraft.gamepedia.com/Nether_Wart
@@ -716,7 +771,7 @@ public enum XMaterial {
OBSIDIAN, OBSIDIAN,
OCELOT_SPAWN_EGG(98, "MONSTER_EGG"), OCELOT_SPAWN_EGG(98, "MONSTER_EGG"),
ORANGE_BANNER(14, "BANNER", "STANDING_BANNER"), ORANGE_BANNER(14, "BANNER", "STANDING_BANNER"),
ORANGE_BED(1, "BED", "BED_BLOCK"), ORANGE_BED(1, "BED_BLOCK", "BED"),
ORANGE_CARPET(1, "CARPET"), ORANGE_CARPET(1, "CARPET"),
ORANGE_CONCRETE(1, "CONCRETE"), ORANGE_CONCRETE(1, "CONCRETE"),
ORANGE_CONCRETE_POWDER(1, "CONCRETE_POWDER"), ORANGE_CONCRETE_POWDER(1, "CONCRETE_POWDER"),
@@ -742,7 +797,7 @@ public enum XMaterial {
PIG_SPAWN_EGG(90, "MONSTER_EGG"), PIG_SPAWN_EGG(90, "MONSTER_EGG"),
PILLAGER_SPAWN_EGG("1.14"), PILLAGER_SPAWN_EGG("1.14"),
PINK_BANNER(9, "BANNER", "STANDING_BANNER"), PINK_BANNER(9, "BANNER", "STANDING_BANNER"),
PINK_BED(6, "BED", "BED_BLOCK"), PINK_BED(6, "BED_BLOCK", "BED"),
PINK_CARPET(6, "CARPET"), PINK_CARPET(6, "CARPET"),
PINK_CONCRETE(6, "CONCRETE"), PINK_CONCRETE(6, "CONCRETE"),
PINK_CONCRETE_POWDER(6, "CONCRETE_POWDER"), PINK_CONCRETE_POWDER(6, "CONCRETE_POWDER"),
@@ -753,7 +808,7 @@ public enum XMaterial {
PINK_STAINED_GLASS_PANE(6, "THIN_GLASS", "STAINED_GLASS_PANE"), PINK_STAINED_GLASS_PANE(6, "THIN_GLASS", "STAINED_GLASS_PANE"),
PINK_TERRACOTTA(6, "HARD_CLAY", "STAINED_CLAY"), PINK_TERRACOTTA(6, "HARD_CLAY", "STAINED_CLAY"),
PINK_TULIP(7, "RED_ROSE"), PINK_TULIP(7, "RED_ROSE"),
PINK_WALL_BANNER(14, "WALL_BANNER"), PINK_WALL_BANNER(9, "WALL_BANNER"),
PINK_WOOL(6, "WOOL"), PINK_WOOL(6, "WOOL"),
PISTON("PISTON_BASE"), PISTON("PISTON_BASE"),
PISTON_HEAD("PISTON_EXTENSION"), PISTON_HEAD("PISTON_EXTENSION"),
@@ -765,6 +820,17 @@ public enum XMaterial {
POLISHED_ANDESITE(6, "STONE"), POLISHED_ANDESITE(6, "STONE"),
POLISHED_ANDESITE_SLAB, POLISHED_ANDESITE_SLAB,
POLISHED_ANDESITE_STAIRS, POLISHED_ANDESITE_STAIRS,
POLISHED_BASALT("1.16"),
POLISHED_BLACKSTONE("1.16"),
POLISHED_BLACKSTONE_BRICKS("1.16"),
POLISHED_BLACKSTONE_BRICK_SLAB("1.16"),
POLISHED_BLACKSTONE_BRICK_STAIRS("1.16"),
POLISHED_BLACKSTONE_BRICK_WALL("1.16"),
POLISHED_BLACKSTONE_BUTTON("1.16"),
POLISHED_BLACKSTONE_PRESSURE_PLATE("1.16"),
POLISHED_BLACKSTONE_SLAB("1.16"),
POLISHED_BLACKSTONE_STAIRS("1.16"),
POLISHED_BLACKSTONE_WALL("1.16"),
POLISHED_DIORITE(4, "STONE"), POLISHED_DIORITE(4, "STONE"),
POLISHED_DIORITE_SLAB, POLISHED_DIORITE_SLAB,
POLISHED_DIORITE_STAIRS, POLISHED_DIORITE_STAIRS,
@@ -820,7 +886,7 @@ public enum XMaterial {
PUMPKIN_SEEDS, PUMPKIN_SEEDS,
PUMPKIN_STEM, PUMPKIN_STEM,
PURPLE_BANNER(5, "BANNER", "STANDING_BANNER"), PURPLE_BANNER(5, "BANNER", "STANDING_BANNER"),
PURPLE_BED(10, "BED", "BED_BLOCK"), PURPLE_BED(10, "BED_BLOCK", "BED"),
PURPLE_CARPET(10, "CARPET"), PURPLE_CARPET(10, "CARPET"),
PURPLE_CONCRETE(10, "CONCRETE"), PURPLE_CONCRETE(10, "CONCRETE"),
PURPLE_CONCRETE_POWDER(10, "CONCRETE_POWDER"), PURPLE_CONCRETE_POWDER(10, "CONCRETE_POWDER"),
@@ -850,17 +916,34 @@ public enum XMaterial {
RAVAGER_SPAWN_EGG("1.14"), RAVAGER_SPAWN_EGG("1.14"),
REDSTONE, REDSTONE,
REDSTONE_BLOCK, REDSTONE_BLOCK,
REDSTONE_LAMP("REDSTONE_LAMP_OFF", "REDSTONE_LAMP_ON"), /**
* Unlike redstone torch, REDSTONE_LAMP_ON isn't an item.
* The name is just here on the list for matching.
*
* @see #REDSTONE_TORCH
*/
REDSTONE_LAMP("REDSTONE_LAMP_ON", "REDSTONE_LAMP_OFF"),
REDSTONE_ORE("GLOWING_REDSTONE_ORE"), REDSTONE_ORE("GLOWING_REDSTONE_ORE"),
REDSTONE_TORCH("REDSTONE_TORCH_ON", "REDSTONE_TORCH_OFF"), /**
REDSTONE_WALL_TORCH(1, "REDSTONE_TORCH_ON", "REDSTONE_TORCH_OFF"), * REDSTONE_TORCH_OFF isn't an item, but a block.
* But REDSTONE_TORCH_ON is the item.
* The name is just here on the list for matching.
*/
REDSTONE_TORCH("REDSTONE_TORCH_OFF", "REDSTONE_TORCH_ON"),
REDSTONE_WALL_TORCH,
REDSTONE_WIRE, REDSTONE_WIRE,
RED_BANNER(1, "BANNER", "STANDING_BANNER"), RED_BANNER(1, "BANNER", "STANDING_BANNER"),
RED_BED(14, "BED", "BED_BLOCK"), /**
* Data value 14 or 0
*/
RED_BED(0, "BED_BLOCK", "BED"),
RED_CARPET(14, "CARPET"), RED_CARPET(14, "CARPET"),
RED_CONCRETE(14, "CONCRETE"), RED_CONCRETE(14, "CONCRETE"),
RED_CONCRETE_POWDER(14, "CONCRETE_POWDER"), RED_CONCRETE_POWDER(14, "CONCRETE_POWDER"),
RED_DYE(1, "ROSE_RED"), /**
* Data value 0 or 1?
*/
RED_DYE(0, "INK_SACK", "ROSE_RED"),
RED_GLAZED_TERRACOTTA(14, "1.12", "HARD_CLAY", "STAINED_CLAY", "RED_TERRACOTTA"), RED_GLAZED_TERRACOTTA(14, "1.12", "HARD_CLAY", "STAINED_CLAY", "RED_TERRACOTTA"),
RED_MUSHROOM, RED_MUSHROOM,
RED_MUSHROOM_BLOCK("RED_MUSHROOM", "HUGE_MUSHROOM_2"), RED_MUSHROOM_BLOCK("RED_MUSHROOM", "HUGE_MUSHROOM_2"),
@@ -882,6 +965,7 @@ public enum XMaterial {
RED_WOOL(14, "WOOL"), RED_WOOL(14, "WOOL"),
REPEATER("DIODE", "DIODE_BLOCK_ON", "DIODE_BLOCK_OFF"), REPEATER("DIODE", "DIODE_BLOCK_ON", "DIODE_BLOCK_OFF"),
REPEATING_COMMAND_BLOCK("COMMAND", "COMMAND_REPEATING"), REPEATING_COMMAND_BLOCK("COMMAND", "COMMAND_REPEATING"),
RESPAWN_ANCHOR("1.16"),
ROSE_BUSH(4, "DOUBLE_PLANT"), ROSE_BUSH(4, "DOUBLE_PLANT"),
ROTTEN_FLESH, ROTTEN_FLESH,
SADDLE, SADDLE,
@@ -901,6 +985,7 @@ public enum XMaterial {
SHEARS, SHEARS,
SHEEP_SPAWN_EGG(91, "MONSTER_EGG"), SHEEP_SPAWN_EGG(91, "MONSTER_EGG"),
SHIELD, SHIELD,
SHROOMLIGHT("1.16"),
SHULKER_BOX("PURPLE_SHULKER_BOX"), SHULKER_BOX("PURPLE_SHULKER_BOX"),
SHULKER_SHELL, SHULKER_SHELL,
SHULKER_SPAWN_EGG(69, "MONSTER_EGG"), SHULKER_SPAWN_EGG(69, "MONSTER_EGG"),
@@ -929,7 +1014,13 @@ public enum XMaterial {
SNOW, SNOW,
SNOWBALL("SNOW_BALL"), SNOWBALL("SNOW_BALL"),
SNOW_BLOCK, SNOW_BLOCK,
SOUL_CAMPFIRE("1.16"),
SOUL_FIRE("1.16"),
SOUL_LANTERN("1.16"),
SOUL_SAND, SOUL_SAND,
SOUL_SOIL("1.16"),
SOUL_TORCH("1.16"),
SOUL_WALL_TORCH("1.16"),
SPAWNER("MOB_SPAWNER"), SPAWNER("MOB_SPAWNER"),
SPECTRAL_ARROW("1.9", "ARROW", ""), SPECTRAL_ARROW("1.9", "ARROW", ""),
SPIDER_EYE, SPIDER_EYE,
@@ -976,6 +1067,8 @@ public enum XMaterial {
STRIPPED_ACACIA_WOOD("LOG_2"), STRIPPED_ACACIA_WOOD("LOG_2"),
STRIPPED_BIRCH_LOG(2, "LOG"), STRIPPED_BIRCH_LOG(2, "LOG"),
STRIPPED_BIRCH_WOOD(2, "LOG"), STRIPPED_BIRCH_WOOD(2, "LOG"),
STRIPPED_CRIMSON_HYPHAE("1.16"),
STRIPPED_CRIMSON_STEM("1.16"),
STRIPPED_DARK_OAK_LOG("LOG"), STRIPPED_DARK_OAK_LOG("LOG"),
STRIPPED_DARK_OAK_WOOD("LOG"), STRIPPED_DARK_OAK_WOOD("LOG"),
STRIPPED_JUNGLE_LOG(3, "LOG"), STRIPPED_JUNGLE_LOG(3, "LOG"),
@@ -984,6 +1077,8 @@ public enum XMaterial {
STRIPPED_OAK_WOOD("LOG"), STRIPPED_OAK_WOOD("LOG"),
STRIPPED_SPRUCE_LOG(1, "LOG"), STRIPPED_SPRUCE_LOG(1, "LOG"),
STRIPPED_SPRUCE_WOOD(1, "LOG"), STRIPPED_SPRUCE_WOOD(1, "LOG"),
STRIPPED_WARPED_HYPHAE("1.16"),
STRIPPED_WARPED_STEM("1.16"),
STRUCTURE_BLOCK, STRUCTURE_BLOCK,
/** /**
* Originally developers used barrier blocks for its purpose. * Originally developers used barrier blocks for its purpose.
@@ -1002,6 +1097,7 @@ public enum XMaterial {
SWEET_BERRY_BUSH("1.14", "GRASS", ""), SWEET_BERRY_BUSH("1.14", "GRASS", ""),
TALL_GRASS(2, "DOUBLE_PLANT"), TALL_GRASS(2, "DOUBLE_PLANT"),
TALL_SEAGRASS(2, "1.13", "TALL_GRASS", ""), TALL_SEAGRASS(2, "1.13", "TALL_GRASS", ""),
TARGET("1.16"),
TERRACOTTA("HARD_CLAY"), TERRACOTTA("HARD_CLAY"),
TIPPED_ARROW("1.9", "ARROW", ""), TIPPED_ARROW("1.9", "ARROW", ""),
TNT, TNT,
@@ -1023,6 +1119,8 @@ public enum XMaterial {
TURTLE_EGG("1.13", "EGG", ""), TURTLE_EGG("1.13", "EGG", ""),
TURTLE_HELMET("1.13", "IRON_HELMET", ""), TURTLE_HELMET("1.13", "IRON_HELMET", ""),
TURTLE_SPAWN_EGG("1.13", "CHICKEN_SPAWN_EGG", ""), TURTLE_SPAWN_EGG("1.13", "CHICKEN_SPAWN_EGG", ""),
TWISTING_VINES("1.16"),
TWISTING_VINES_PLANT("1.16"),
VEX_SPAWN_EGG(35, "MONSTER_EGG"), VEX_SPAWN_EGG(35, "MONSTER_EGG"),
VILLAGER_SPAWN_EGG(120, "MONSTER_EGG"), VILLAGER_SPAWN_EGG(120, "MONSTER_EGG"),
VINDICATOR_SPAWN_EGG(36, "MONSTER_EGG"), VINDICATOR_SPAWN_EGG(36, "MONSTER_EGG"),
@@ -1035,6 +1133,24 @@ public enum XMaterial {
VOID_AIR("AIR"), VOID_AIR("AIR"),
WALL_TORCH("TORCH"), WALL_TORCH("TORCH"),
WANDERING_TRADER_SPAWN_EGG("1.14", "VILLAGER_SPAWN_EGG", ""), WANDERING_TRADER_SPAWN_EGG("1.14", "VILLAGER_SPAWN_EGG", ""),
WARPED_BUTTON("1.16"),
WARPED_DOOR("1.16"),
WARPED_FENCE("1.16"),
WARPED_FENCE_GATE("1.16"),
WARPED_FUNGUS("1.16"),
WARPED_FUNGUS_ON_A_STICK("1.16"),
WARPED_HYPHAE("1.16"),
WARPED_NYLIUM("1.16"),
WARPED_PLANKS("1.16"),
WARPED_PRESSURE_PLATE("1.16"),
WARPED_ROOTS("1.16"),
WARPED_SIGN("1.16"),
WARPED_SLAB("1.16"),
WARPED_STAIRS("1.16"),
WARPED_STEM("1.16"),
WARPED_TRAPDOOR("1.16"),
WARPED_WALL_SIGN("1.16"),
WARPED_WART_BLOCK("1.16"),
/** /**
* This is used for blocks only. * This is used for blocks only.
* In 1.13- WATER will turn into STATIONARY_WATER after it finished spreading. * In 1.13- WATER will turn into STATIONARY_WATER after it finished spreading.
@@ -1044,6 +1160,8 @@ public enum XMaterial {
*/ */
WATER("STATIONARY_WATER"), WATER("STATIONARY_WATER"),
WATER_BUCKET, WATER_BUCKET,
WEEPING_VINES("1.16"),
WEEPING_VINES_PLANT("1.16"),
WET_SPONGE(1, "SPONGE"), WET_SPONGE(1, "SPONGE"),
/** /**
* Wheat is a known material in pre-1.13 * Wheat is a known material in pre-1.13
@@ -1052,16 +1170,16 @@ public enum XMaterial {
WHEAT("CROPS"), WHEAT("CROPS"),
WHEAT_SEEDS("SEEDS"), WHEAT_SEEDS("SEEDS"),
WHITE_BANNER(15, "BANNER", "STANDING_BANNER"), WHITE_BANNER(15, "BANNER", "STANDING_BANNER"),
WHITE_BED("BED", "BED_BLOCK"), WHITE_BED("BED_BLOCK", "BED"),
WHITE_CARPET("CARPET"), WHITE_CARPET("CARPET"),
WHITE_CONCRETE("CONCRETE"), WHITE_CONCRETE("CONCRETE"),
WHITE_CONCRETE_POWDER("CONCRETE_POWDER"), WHITE_CONCRETE_POWDER("CONCRETE_POWDER"),
WHITE_DYE(15, "1.14", "INK_SACK", "BONE_MEAL"), WHITE_DYE(15, "1.14", "INK_SACK", "BONE_MEAL"),
WHITE_GLAZED_TERRACOTTA("1.12", "HARD_CLAY", "STAINED_CLAY", "WHITE_TERRACOTTA"), WHITE_GLAZED_TERRACOTTA("1.12", "HARD_CLAY", "STAINED_CLAY"),
WHITE_SHULKER_BOX, WHITE_SHULKER_BOX,
WHITE_STAINED_GLASS("STAINED_GLASS"), WHITE_STAINED_GLASS("STAINED_GLASS"),
WHITE_STAINED_GLASS_PANE("THIN_GLASS", "STAINED_GLASS_PANE"), WHITE_STAINED_GLASS_PANE("THIN_GLASS", "STAINED_GLASS_PANE"),
WHITE_TERRACOTTA("HARD_CLAY", "TERRACOTTA"), WHITE_TERRACOTTA("HARD_CLAY", "STAINED_CLAY", "TERRACOTTA"),
WHITE_TULIP(6, "RED_ROSE"), WHITE_TULIP(6, "RED_ROSE"),
WHITE_WALL_BANNER(15, "WALL_BANNER"), WHITE_WALL_BANNER(15, "WALL_BANNER"),
WHITE_WOOL("WOOL"), WHITE_WOOL("WOOL"),
@@ -1079,7 +1197,7 @@ public enum XMaterial {
WRITABLE_BOOK("BOOK_AND_QUILL"), WRITABLE_BOOK("BOOK_AND_QUILL"),
WRITTEN_BOOK, WRITTEN_BOOK,
YELLOW_BANNER(11, "BANNER", "STANDING_BANNER"), YELLOW_BANNER(11, "BANNER", "STANDING_BANNER"),
YELLOW_BED(4, "BED", "BED_BLOCK"), YELLOW_BED(4, "BED_BLOCK", "BED"),
YELLOW_CARPET(4, "CARPET"), YELLOW_CARPET(4, "CARPET"),
YELLOW_CONCRETE(4, "CONCRETE"), YELLOW_CONCRETE(4, "CONCRETE"),
YELLOW_CONCRETE_POWDER(4, "CONCRETE_POWDER"), YELLOW_CONCRETE_POWDER(4, "CONCRETE_POWDER"),
@@ -1096,7 +1214,8 @@ public enum XMaterial {
ZOMBIE_PIGMAN_SPAWN_EGG(57, "MONSTER_EGG"), ZOMBIE_PIGMAN_SPAWN_EGG(57, "MONSTER_EGG"),
ZOMBIE_SPAWN_EGG(54, "MONSTER_EGG"), ZOMBIE_SPAWN_EGG(54, "MONSTER_EGG"),
ZOMBIE_VILLAGER_SPAWN_EGG(27, "MONSTER_EGG"), ZOMBIE_VILLAGER_SPAWN_EGG(27, "MONSTER_EGG"),
ZOMBIE_WALL_HEAD(2, "SKULL", "SKULL_ITEM"); ZOMBIE_WALL_HEAD(2, "SKULL", "SKULL_ITEM"),
ZOMBIFIED_PIGLIN_SPAWN_EGG(54, "MONSTER_EGG");
/** /**
@@ -1132,16 +1251,26 @@ public enum XMaterial {
* @since 3.0.0 * @since 3.0.0
*/ */
@SuppressWarnings("UnstableApiUsage") @SuppressWarnings("UnstableApiUsage")
private static final ImmutableMap<XMaterial, XMaterial> DUPLICATED = Maps.immutableEnumMap(ImmutableMap.<XMaterial, XMaterial>builder() private static final ImmutableMap<XMaterial, XMaterial> duplicated = Maps.immutableEnumMap(ImmutableMap.<XMaterial, XMaterial>builder()
.put(MELON, MELON_SLICE) .put(MELON, MELON_SLICE)
.put(CARROT, CARROTS) .put(CARROT, CARROTS)
.put(POTATO, POTATOES) .put(POTATO, POTATOES)
.put(BEETROOT, BEETROOTS) .put(BEETROOT, BEETROOTS)
.put(BROWN_MUSHROOM, BROWN_MUSHROOM_BLOCK) .put(BROWN_MUSHROOM, BROWN_MUSHROOM_BLOCK)
.put(BRICK, BRICKS) .put(BRICK, BRICKS)
.put(RED_MUSHROOM, RED_MUSHROOM_BLOCK)
.put(MAP, FILLED_MAP)
.put(NETHER_BRICK, NETHER_BRICKS) .put(NETHER_BRICK, NETHER_BRICKS)
// Illegal Elements
// Since both 1.12 and 1.13 have <type>_DOOR XMaterial will use it
// for 1.12 to parse the material, but it needs <type>_DOOR_ITEM.
// We'll trick XMaterial into thinking this needs to be parsed
// using the old methods.
.put(DARK_OAK_DOOR, DARK_OAK_DOOR)
.put(ACACIA_DOOR, ACACIA_DOOR)
.put(BIRCH_DOOR, BIRCH_DOOR)
.put(JUNGLE_DOOR, JUNGLE_DOOR)
.put(SPRUCE_DOOR, SPRUCE_DOOR)
.build() .build()
); );
/* /*
@@ -1232,7 +1361,7 @@ public enum XMaterial {
* An invocation of this method yields the cached result from the expression: * An invocation of this method yields the cached result from the expression:
* <p> * <p>
* <blockquote> * <blockquote>
* {@link #supports(int 13)}} * {@link #supports(int) 13}}
* </blockquote> * </blockquote>
* *
* @return true if 1.13 or higher. * @return true if 1.13 or higher.
@@ -1283,13 +1412,14 @@ public enum XMaterial {
@Nullable @Nullable
private static XMaterial requestOldXMaterial(@Nonnull String name, byte data) { private static XMaterial requestOldXMaterial(@Nonnull String name, byte data) {
String holder = name + data; String holder = name + data;
XMaterial material = NAME_CACHE.getIfPresent(holder); XMaterial cache = NAME_CACHE.getIfPresent(holder);
if (material != null) return material; if (cache != null) return cache;
for (XMaterial materials : VALUES) { for (XMaterial material : VALUES) {
if ((data == -1 || data == materials.data) && materials.anyMatchLegacy(name)) { // Not using material.name().equals(name) check is intended.
NAME_CACHE.put(holder, materials); if ((data == -1 || data == material.data) && material.anyMatchLegacy(name)) {
return materials; NAME_CACHE.put(holder, material);
return material;
} }
} }
@@ -1320,37 +1450,15 @@ public enum XMaterial {
/** /**
* Parses the given material name as an XMaterial with unspecified data value. * Parses the given material name as an XMaterial with unspecified data value.
* *
* @see #matchXMaterial(String, byte) * @see #matchXMaterialWithData(String)
* @since 2.0.0 * @since 2.0.0
*/ */
@Nonnull @Nonnull
public static Optional<XMaterial> matchXMaterial(@Nonnull String name) { public static Optional<XMaterial> matchXMaterial(@Nonnull String name) {
return matchXMaterial(name, (byte) -1);
}
/**
* Parses the given material name as an XMaterial.
* Can also be used like: <b>MATERIAL:DATA</b>
* <p>
* <b>Examples</b>
* <pre>
* INK_SACK:1 -> RED_DYE
* WOOL, 14 -> RED_WOOL
* </pre>
*
* @see #matchDefinedXMaterial(String, byte)
* @see #matchXMaterial(ItemStack)
* @since 2.0.0
*/
@Nonnull
public static Optional<XMaterial> matchXMaterial(@Nonnull String name, byte data) {
Validate.notEmpty(name, "Cannot match a material with null or empty material name"); Validate.notEmpty(name, "Cannot match a material with null or empty material name");
Optional<XMaterial> oldMatch = matchXMaterialWithData(name); Optional<XMaterial> oldMatch = matchXMaterialWithData(name);
if (oldMatch.isPresent()) return oldMatch; if (oldMatch.isPresent()) return oldMatch;
return matchDefinedXMaterial(format(name), (byte) -1);
// -1 Determines whether the item's data value is unknown and only the name is given.
// Checking if the item is damageable won't do anything as the data is not going to be checked in requestOldMaterial anyway.
return matchDefinedXMaterial(format(name), data);
} }
/** /**
@@ -1360,8 +1468,8 @@ public enum XMaterial {
* <p> * <p>
* <b>Examples</b> * <b>Examples</b>
* <p><pre> * <p><pre>
* INK_SACK:1 -> RED_DYE * {@code INK_SACK:1 -> RED_DYE}
* WOOL, 14 -> RED_WOOL * {@code WOOL, 14 -> RED_WOOL}
* </pre> * </pre>
* *
* @param name the material string that consists of the material name, data and separator character. * @param name the material string that consists of the material name, data and separator character.
@@ -1394,7 +1502,7 @@ public enum XMaterial {
public static XMaterial matchXMaterial(@Nonnull Material material) { public static XMaterial matchXMaterial(@Nonnull Material material) {
Objects.requireNonNull(material, "Cannot match null material"); Objects.requireNonNull(material, "Cannot match null material");
return matchDefinedXMaterial(material.name(), (byte) -1) return matchDefinedXMaterial(material.name(), (byte) -1)
.orElseThrow(() -> new IllegalArgumentException("Unsupported Material: " + material)); .orElseThrow(() -> new IllegalArgumentException("Unsupported Material With No Bytes: " + material.name()));
} }
/** /**
@@ -1411,9 +1519,10 @@ public enum XMaterial {
public static XMaterial matchXMaterial(@Nonnull ItemStack item) { public static XMaterial matchXMaterial(@Nonnull ItemStack item) {
Objects.requireNonNull(item, "Cannot match null ItemStack"); Objects.requireNonNull(item, "Cannot match null ItemStack");
String material = item.getType().name(); String material = item.getType().name();
return matchDefinedXMaterial(material, byte data = (byte) (ISFLAT || isDamageable(material) ? 0 : item.getDurability());
isDamageable(material) ? (byte) 0 : (byte) item.getDurability())
.orElseThrow(() -> new IllegalArgumentException("Unsupported Material: " + material)); return matchDefinedXMaterial(material, data)
.orElseThrow(() -> new IllegalArgumentException("Unsupported Material: " + material + " (" + data + ')'));
} }
/** /**
@@ -1423,7 +1532,6 @@ public enum XMaterial {
* @param name the formatted name of the material. * @param name the formatted name of the material.
* @param data the data value of the material. * @param data the data value of the material.
* @return an XMaterial (with the same data value if specified) * @return an XMaterial (with the same data value if specified)
* @see #matchXMaterial(String, byte)
* @see #matchXMaterial(Material) * @see #matchXMaterial(Material)
* @see #matchXMaterial(int, byte) * @see #matchXMaterial(int, byte)
* @see #matchXMaterial(ItemStack) * @see #matchXMaterial(ItemStack)
@@ -1436,7 +1544,7 @@ public enum XMaterial {
// Do basic number and boolean checks before accessing more complex enum stuff. // Do basic number and boolean checks before accessing more complex enum stuff.
// Maybe we can simplify (ISFLAT || !duplicated) with the (!ISFLAT && duplicated) under it to save a few nanoseconds? // Maybe we can simplify (ISFLAT || !duplicated) with the (!ISFLAT && duplicated) under it to save a few nanoseconds?
// if (!Boolean.valueOf(Boolean.getBoolean(Boolean.TRUE.toString())).equals(Boolean.FALSE.booleanValue())) return null; // if (!Boolean.valueOf(Boolean.getBoolean(Boolean.TRUE.toString())).equals(Boolean.FALSE.booleanValue())) return null;
if (data <= 0 && (ISFLAT || !duplicated)) { if (data <= 0 && !duplicated) {
// Apparently the transform method is more efficient than toJavaUtil() // Apparently the transform method is more efficient than toJavaUtil()
// toJavaUtil isn't even supported in older versions. // toJavaUtil isn't even supported in older versions.
Optional<XMaterial> xMat = Enums.getIfPresent(XMaterial.class, name).transform(Optional::of).or(Optional.empty()); Optional<XMaterial> xMat = Enums.getIfPresent(XMaterial.class, name).transform(Optional::of).or(Optional.empty());
@@ -1447,8 +1555,20 @@ public enum XMaterial {
// I've concluded that this is just an infinite loop that keeps // I've concluded that this is just an infinite loop that keeps
// going around the Singular Form and the Plural Form materials. A waste of brain cells and a waste of time. // going around the Singular Form and the Plural Form materials. A waste of brain cells and a waste of time.
// This solution works just fine anyway. // This solution works just fine anyway.
if (!ISFLAT && duplicated) return Optional.ofNullable(requestDuplicatedXMaterial(name, data)); XMaterial xMat = requestOldXMaterial(name, data);
return Optional.ofNullable(requestOldXMaterial(name, data)); if (xMat == null) {
// Special case. Refer to FILLED_MAP for more info.
if (data > 0 && name.endsWith("MAP")) return Optional.of(FILLED_MAP);
return Optional.empty();
}
if (!ISFLAT && duplicated && xMat.name().charAt(xMat.name().length() - 1) == 'S') {
// A solution for XMaterial Paradox.
// Manually parses the duplicated materials to find the exact material based on the server version.
// If ends with "S" -> Plural Form Material
return Enums.getIfPresent(XMaterial.class, name).transform(Optional::of).or(Optional.empty());
}
return Optional.ofNullable(xMat);
} }
/** /**
@@ -1463,13 +1583,12 @@ public enum XMaterial {
* @see #isDuplicated() * @see #isDuplicated()
* @since 2.0.0 * @since 2.0.0
*/ */
public static boolean isDuplicated(@Nonnull String name) { private static boolean isDuplicated(@Nonnull String name) {
Validate.notEmpty(name, "Cannot check duplication for null or empty material name");
name = format(name);
// Don't use matchXMaterial() since this method is being called from matchXMaterial() itself and will cause a StackOverflowError. // Don't use matchXMaterial() since this method is being called from matchXMaterial() itself and will cause a StackOverflowError.
for (Map.Entry<XMaterial, XMaterial> duplicated : DUPLICATED.entrySet()) for (Map.Entry<XMaterial, XMaterial> duplicated : duplicated.entrySet()) {
if (duplicated.getKey().name().equals(name) || duplicated.getKey().anyMatchLegacy(name)) return true; XMaterial material = duplicated.getKey();
if (material.name().equals(name) || material.anyMatchLegacy(name)) return true;
}
return false; return false;
} }
@@ -1493,60 +1612,6 @@ public enum XMaterial {
return Optional.empty(); return Optional.empty();
} }
/**
* A solution for <b>XMaterial Paradox</b>.
* Manually parses the duplicated materials to find the exact material based on the server version.
*
* @param name the name of the material.
* @return the duplicated XMaterial based on the version.
* @throws IllegalArgumentException may be thrown. If thrown, it's a bug.
* @since 2.0.0
*/
@Nullable
private static XMaterial requestDuplicatedXMaterial(@Nonnull String name, byte data) {
XMaterial mat = requestOldXMaterial(name, data);
// If ends with "S" -> Plural Form Material
return mat.name().charAt(mat.name().length() - 1) == 'S' ? Enums.getIfPresent(XMaterial.class, name).orNull() : mat;
}
/**
* Always returns the value with the given duplicated material key name.
*
* @param name the name of the material.
* @return the new XMaterial of this duplicated material.
* @see #getXMaterialIfDuplicated(String)
* @since 2.0.0
*/
@Nonnull
public static Optional<XMaterial> getNewXMaterialIfDuplicated(@Nonnull String name) {
Validate.notEmpty(name, "Cannot get new duplicated material for null or empty material name");
name = format(name);
for (Map.Entry<XMaterial, XMaterial> duplicated : DUPLICATED.entrySet())
if (duplicated.getKey().name().equals(name)) return Optional.of(duplicated.getKey());
return Optional.empty();
}
/**
* Checks if the item is duplicated for a different purpose in new versions from {@link #DUPLICATED}.
*
* @param name the name of the material.
* @return the other XMaterial (key or value) of the XMaterial (key or value).
* @see #matchXMaterial(String, byte)
* @since 2.0.0
*/
@Nullable
public static XMaterial getXMaterialIfDuplicated(@Nonnull String name) {
Validate.notEmpty(name, "Cannot get duplicated material for null or empty material name");
name = format(name);
for (Map.Entry<XMaterial, XMaterial> duplicated : DUPLICATED.entrySet())
if (duplicated.getKey().name().equals(name)) return duplicated.getValue();
else if (duplicated.getValue().name().equals(name)) return duplicated.getKey();
return null;
}
/** /**
* Attempts to build the string like an enum name. * Attempts to build the string like an enum name.
* Removes all the spaces, numbers and extra non-English characters. Also removes some config/in-game based strings. * Removes all the spaces, numbers and extra non-English characters. Also removes some config/in-game based strings.
@@ -1564,7 +1629,7 @@ public enum XMaterial {
/** /**
* Checks if the specified version is the same version or higher than the current server version. * Checks if the specified version is the same version or higher than the current server version.
* *
* @param version the major version to be checked. "1." is ignored -> 1.12 = 12 | 1.9 = 9 * @param version the major version to be checked. "1." is ignored. E.g. 1.12 = 12 | 1.9 = 9
* @return true of the version is equal or higher than the current version. * @return true of the version is equal or higher than the current version.
* @since 2.0.0 * @since 2.0.0
*/ */
@@ -1663,14 +1728,14 @@ public enum XMaterial {
* <br> * <br>
* <b>{@code CONTAINS} Examples:</b> * <b>{@code CONTAINS} Examples:</b>
* <pre> * <pre>
* "CONTAINS:CHEST" -> CHEST, ENDERCHEST, TRAPPED_CHEST -> true * {@code "CONTAINS:CHEST" -> CHEST, ENDERCHEST, TRAPPED_CHEST -> true}
* "cOnTaINS:dYe" -> GREEN_DYE, YELLOW_DYE, BLUE_DYE, INK_SACK -> true * {@code "cOnTaINS:dYe" -> GREEN_DYE, YELLOW_DYE, BLUE_DYE, INK_SACK -> true}
* </pre> * </pre>
* <p> * <p>
* <b>{@code REGEX} Examples</b> * <b>{@code REGEX} Examples</b>
* <pre> * <pre>
* "REGEX:^.+_.+_.+$" -> Every Material with 3 underlines or more: SHULKER_SPAWN_EGG, SILVERFISH_SPAWN_EGG, SKELETON_HORSE_SPAWN_EGG * {@code "REGEX:^.+_.+_.+$" -> Every Material with 3 underlines or more: SHULKER_SPAWN_EGG, SILVERFISH_SPAWN_EGG, SKELETON_HORSE_SPAWN_EGG}
* "REGEX:^.{1,3}$" -> Material names that have 3 letters only: BED, MAP, AIR * {@code "REGEX:^.{1,3}$" -> Material names that have 3 letters only: BED, MAP, AIR}
* </pre> * </pre>
* <p> * <p>
* The reason that there are tags for {@code CONTAINS} and {@code REGEX} * The reason that there are tags for {@code CONTAINS} and {@code REGEX}
@@ -1803,8 +1868,7 @@ public enum XMaterial {
*/ */
@SuppressWarnings("deprecation") @SuppressWarnings("deprecation")
public int getId() { public int getId() {
if (this.data != 0 || (this.legacy.length != 0 && Integer.parseInt(this.legacy[0].substring(2)) >= 13)) if (this.data != 0 || (this.legacy.length != 0 && Integer.parseInt(this.legacy[0].substring(2)) >= 13)) return -1;
return -1;
Material material = this.parseMaterial(); Material material = this.parseMaterial();
return material == null ? -1 : material.getId(); return material == null ? -1 : material.getId();
} }
@@ -1813,25 +1877,11 @@ public enum XMaterial {
* Checks if the material has any duplicates. * Checks if the material has any duplicates.
* *
* @return true if there is a duplicated name for this material, otherwise false. * @return true if there is a duplicated name for this material, otherwise false.
* @see #getXMaterialIfDuplicated()
* @see #isDuplicated(String) * @see #isDuplicated(String)
* @since 2.0.0 * @since 2.0.0
*/ */
public boolean isDuplicated() { public boolean isDuplicated() {
return DUPLICATED.containsKey(this); return duplicated.containsKey(this);
}
/**
* Checks if the item is duplicated for a different purpose in new versions.
*
* @return true if the item's name is duplicated, otherwise false.
* @see #isDuplicated()
* @see #getNewXMaterialIfDuplicated(String)
* @since 2.0.0
*/
@Nullable
public XMaterial getXMaterialIfDuplicated() {
return DUPLICATED.get(this);
} }
/** /**
@@ -1891,7 +1941,7 @@ public enum XMaterial {
* Parses an item from this XMaterial. * Parses an item from this XMaterial.
* Uses data values on older versions. * Uses data values on older versions.
* *
* @param suggest if true {@link #parseMaterial(boolean true)} will be used. * @param suggest if true {@link #parseMaterial(boolean)} true will be used.
* @return an ItemStack with the same material (and data value if in older versions.) * @return an ItemStack with the same material (and data value if in older versions.)
* @see #setType(ItemStack) * @see #setType(ItemStack)
* @since 2.0.0 * @since 2.0.0
@@ -1921,7 +1971,6 @@ public enum XMaterial {
* *
* @param suggest use a suggested material (from older materials) if the material is added in a later version of Minecraft. * @param suggest use a suggested material (from older materials) if the material is added in a later version of Minecraft.
* @return the material related to this XMaterial based on the server version. * @return the material related to this XMaterial based on the server version.
* @see #matchXMaterial(String, byte)
* @since 2.0.0 * @since 2.0.0
*/ */
@SuppressWarnings("OptionalAssignedToNull") @SuppressWarnings("OptionalAssignedToNull")

View File

@@ -1,12 +1,5 @@
package com.massivecraft.factions.util.timer; package com.massivecraft.factions.util.timer;
import com.massivecraft.factions.util.Config;
import java.util.LinkedHashMap;
import java.util.Map;
import java.util.Set;
import java.util.UUID;
/** /**
* Factions - Developed by Driftay. * Factions - Developed by Driftay.
* All rights reserved 2020. * All rights reserved 2020.

View File

@@ -8,8 +8,8 @@ import com.massivecraft.factions.util.Config;
* Creation Date: 4/7/2020 * Creation Date: 4/7/2020
*/ */
public abstract class Timer { public abstract class Timer {
protected final String name;
public final long defaultCooldown; public final long defaultCooldown;
protected final String name;
public Timer(String name, long defaultCooldown) { public Timer(String name, long defaultCooldown) {

View File

@@ -16,14 +16,24 @@ import java.util.concurrent.TimeUnit;
* Creation Date: 4/7/2020 * Creation Date: 4/7/2020
*/ */
public class TimerManager implements Listener, Runnable { public class TimerManager implements Listener, Runnable {
private final Set<Timer> timers;
private final FactionsPlugin plugin;
private final List<TimerRunnable> timerRunnableList = new ArrayList<>();
private Config config;
public GraceTimer graceTimer;
private static final long MINUTE = TimeUnit.MINUTES.toMillis(1L); private static final long MINUTE = TimeUnit.MINUTES.toMillis(1L);
private static final long HOUR = TimeUnit.HOURS.toMillis(1L); private static final long HOUR = TimeUnit.HOURS.toMillis(1L);
private static final long MULTI_HOUR = TimeUnit.HOURS.toMillis(10); private static final long MULTI_HOUR = TimeUnit.HOURS.toMillis(10);
private final Set<Timer> timers;
private final FactionsPlugin plugin;
private final List<TimerRunnable> timerRunnableList = new ArrayList<>();
public GraceTimer graceTimer;
private Config config;
public TimerManager(FactionsPlugin plugin) {
this.timers = new HashSet<>();
this.plugin = plugin;
plugin.getServer().getPluginManager().registerEvents(this, plugin);
if (Conf.useGraceSystem) {
this.registerTimer(this.graceTimer = new GraceTimer());
}
plugin.getServer().getScheduler().runTaskTimer(plugin, this, 4, 4);
}
public static String getRemaining(long millis, boolean milliseconds) { public static String getRemaining(long millis, boolean milliseconds) {
return getRemaining(millis, milliseconds, true); return getRemaining(millis, milliseconds, true);
@@ -31,21 +41,11 @@ public class TimerManager implements Listener, Runnable {
public static String getRemaining(long duration, boolean milliseconds, boolean trail) { public static String getRemaining(long duration, boolean milliseconds, boolean trail) {
if ((milliseconds) && (duration < MINUTE)) { if ((milliseconds) && (duration < MINUTE)) {
return ( (trail ? DateTimeFormats.REMAINING_SECONDS_TRAILING : DateTimeFormats.REMAINING_SECONDS).get()).format(duration * 0.001D) + 's'; return ((trail ? DateTimeFormats.REMAINING_SECONDS_TRAILING : DateTimeFormats.REMAINING_SECONDS).get()).format(duration * 0.001D) + 's';
} }
return DurationFormatUtils.formatDuration(duration, (duration >= HOUR ? (duration >= MULTI_HOUR ? "d" : "") + "d:" : "") + "HH:mm:ss"); return DurationFormatUtils.formatDuration(duration, (duration >= HOUR ? (duration >= MULTI_HOUR ? "d" : "") + "d:" : "") + "HH:mm:ss");
} }
public TimerManager(FactionsPlugin plugin) {
this.timers = new HashSet<>();
this.plugin = plugin;
plugin.getServer().getPluginManager().registerEvents(this, plugin);
if(Conf.useGraceSystem) {
this.registerTimer(this.graceTimer = new GraceTimer());
}
plugin.getServer().getScheduler().runTaskTimer(plugin, this, 4, 4);
}
public Collection<Timer> getTimers() { public Collection<Timer> getTimers() {
return this.timers; return this.timers;
} }

View File

@@ -45,15 +45,13 @@ public class TimerRunnable {
return getRemaining(false); return getRemaining(false);
} }
public long getRemaining(long now) {
return getRemaining(false, now);
}
public void setRemaining(long remaining) { public void setRemaining(long remaining) {
setExpiryMillis(remaining); setExpiryMillis(remaining);
} }
public long getRemaining(long now) {
return getRemaining(false, now);
}
public long getRemaining(boolean ignorePaused) { public long getRemaining(boolean ignorePaused) {
if ((!ignorePaused) && (this.pauseMillis != 0L)) return this.pauseMillis; if ((!ignorePaused) && (this.pauseMillis != 0L)) return this.pauseMillis;

View File

@@ -26,14 +26,14 @@ public class GraceTimer extends GlobalTimer implements Listener {
@EventHandler @EventHandler
public void onBreak(EntityExplodeEvent e) { public void onBreak(EntityExplodeEvent e) {
if(getRemaining() > 0) if (getRemaining() > 0)
e.setCancelled(true); e.setCancelled(true);
} }
@EventHandler @EventHandler
public void onTNTPlace(BlockPlaceEvent event) { public void onTNTPlace(BlockPlaceEvent event) {
FPlayer fp = FPlayers.getInstance().getByPlayer(event.getPlayer()); FPlayer fp = FPlayers.getInstance().getByPlayer(event.getPlayer());
if(getRemaining() > 0) { if (getRemaining() > 0) {
if (!fp.isAdminBypassing()) { if (!fp.isAdminBypassing()) {
if (event.getBlock().getType().equals(Material.TNT)) { if (event.getBlock().getType().equals(Material.TNT)) {
event.setCancelled(true); event.setCancelled(true);

View File

@@ -8,9 +8,7 @@ import org.bukkit.entity.Player;
import java.util.concurrent.ConcurrentHashMap; import java.util.concurrent.ConcurrentHashMap;
/** /**
* Factions - Developed by Driftay. * @author DroppingAnvil
* All rights reserved 2020.
* Creation Date: 4/4/2020
*/ */
public class WaitExecutor { public class WaitExecutor {
public static ConcurrentHashMap<Player, WaitTask> taskMap = new ConcurrentHashMap<>(); public static ConcurrentHashMap<Player, WaitTask> taskMap = new ConcurrentHashMap<>();

View File

@@ -15,7 +15,6 @@ import com.massivecraft.factions.zcore.util.TextUtil;
import org.bukkit.Bukkit; import org.bukkit.Bukkit;
import org.bukkit.command.CommandSender; import org.bukkit.command.CommandSender;
import org.bukkit.configuration.file.YamlConfiguration; import org.bukkit.configuration.file.YamlConfiguration;
import org.bukkit.plugin.IllegalPluginAccessException;
import org.bukkit.plugin.java.JavaPlugin; import org.bukkit.plugin.java.JavaPlugin;
import java.io.*; import java.io.*;
@@ -100,9 +99,7 @@ public abstract class MPlugin extends JavaPlugin {
long saveTicks = (long) (20 * 60 * Conf.saveToFileEveryXMinutes); // Approximately every 30 min by default long saveTicks = (long) (20 * 60 * Conf.saveToFileEveryXMinutes); // Approximately every 30 min by default
saveTask = Bukkit.getServer().getScheduler().scheduleSyncRepeatingTask(this, new SaveTask(this), saveTicks, saveTicks); saveTask = Bukkit.getServer().getScheduler().scheduleSyncRepeatingTask(this, new SaveTask(this), saveTicks, saveTicks);
} }
loadLang(); loadLang();
loadSuccessful = true; loadSuccessful = true;
return true; return true;
} }
@@ -178,20 +175,18 @@ public abstract class MPlugin extends JavaPlugin {
} }
public void onDisable() { public void onDisable() {
try { if (saveTask != null) {
if (saveTask != null) { this.getServer().getScheduler().cancelTask(saveTask);
this.getServer().getScheduler().cancelTask(saveTask); saveTask = null;
saveTask = null;
}
// only save data if plugin actually loaded successfully
if (loadSuccessful) {
Factions.getInstance().forceSave();
FPlayers.getInstance().forceSave();
Board.getInstance().forceSave();
}
log("Disabled");
} catch (IllegalPluginAccessException e) {
} }
// only save data if plugin actually loaded successfully
if (loadSuccessful) {
Factions.getInstance().forceSave();
FPlayers.getInstance().forceSave();
Board.getInstance().forceSave();
}
log("Disabled");
} }
// -------------------------------------------- // // -------------------------------------------- //

View File

@@ -56,6 +56,10 @@ public class CustomFile {
} }
} }
public boolean containsKey(String key) {
return getCachedObjects().containsKey(key) || getConfig().contains(key);
}
public String fetchString(String key) { public String fetchString(String key) {
return (String) getObj(key, dataTypes.STRING); return (String) getObj(key, dataTypes.STRING);
} }

View File

@@ -6,19 +6,18 @@ import com.github.stefvanschie.inventoryframework.pane.PaginatedPane;
import com.massivecraft.factions.FPlayer; import com.massivecraft.factions.FPlayer;
import com.massivecraft.factions.Faction; import com.massivecraft.factions.Faction;
import com.massivecraft.factions.FactionsPlugin; import com.massivecraft.factions.FactionsPlugin;
import com.massivecraft.factions.cmd.audit.FLogType;
import com.massivecraft.factions.util.XMaterial; import com.massivecraft.factions.util.XMaterial;
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.util.TL; import com.massivecraft.factions.zcore.util.TL;
import org.bukkit.ChatColor;
import org.bukkit.configuration.ConfigurationSection; import org.bukkit.configuration.ConfigurationSection;
import org.bukkit.inventory.ItemStack; import org.bukkit.inventory.ItemStack;
import org.bukkit.inventory.meta.ItemMeta; import org.bukkit.inventory.meta.ItemMeta;
import java.util.ArrayList; import java.util.ArrayList;
import java.util.List; import java.util.List;
import java.util.Objects;
public class PermissableActionFrame { public class PermissableActionFrame {
@@ -30,9 +29,10 @@ public class PermissableActionFrame {
public PermissableActionFrame(Faction f) { public PermissableActionFrame(Faction f) {
ConfigurationSection section = FactionsPlugin.getInstance().getConfig().getConfigurationSection("fperm-gui.action"); ConfigurationSection section = FactionsPlugin.getInstance().getConfig().getConfigurationSection("fperm-gui.action");
assert section != null;
gui = new Gui(FactionsPlugin.getInstance(), gui = new Gui(FactionsPlugin.getInstance(),
section.getInt("rows", 3), section.getInt("rows", 4),
FactionsPlugin.getInstance().color(FactionsPlugin.getInstance().getConfig().getString("fperm-gui.action.name").replace("{faction}", f.getTag()))); FactionsPlugin.getInstance().color(Objects.requireNonNull(FactionsPlugin.getInstance().getConfig().getString("fperm-gui.action.name")).replace("{faction}", f.getTag())));
} }
public void buildGUI(FPlayer fplayer, Permissable perm) { public void buildGUI(FPlayer fplayer, Permissable perm) {
@@ -40,8 +40,7 @@ public class PermissableActionFrame {
List<GuiItem> GUIItems = new ArrayList<>(); List<GuiItem> GUIItems = new ArrayList<>();
ItemStack dumby = buildDummyItem(); ItemStack dumby = buildDummyItem();
// Fill background of GUI with dumbyitem & replace GUI assets after // Fill background of GUI with dumbyitem & replace GUI assets after
for (int x = 0; x <= (gui.getRows() * 9) - 1; x++) for (int x = 0; x <= (gui.getRows() * 9) - 1; x++) GUIItems.add(new GuiItem(dumby, e -> e.setCancelled(true)));
GUIItems.add(new GuiItem(dumby, e -> e.setCancelled(true)));
for (PermissableAction action : PermissableAction.values()) { for (PermissableAction action : PermissableAction.values()) {
if (action.getSlot() == -1) continue; if (action.getSlot() == -1) continue;
GUIItems.set(action.getSlot(), new GuiItem(action.buildAsset(fplayer, perm), e -> { GUIItems.set(action.getSlot(), new GuiItem(action.buildAsset(fplayer, perm), e -> {
@@ -53,17 +52,12 @@ public class PermissableActionFrame {
case LEFT: case LEFT:
access = Access.ALLOW; access = Access.ALLOW;
success = fplayer.getFaction().setPermission(perm, action, access); success = fplayer.getFaction().setPermission(perm, action, access);
FactionsPlugin.instance.logFactionEvent(fplayer.getFaction(), FLogType.PERM_EDIT_DEFAULTS, fplayer.getName(), ChatColor.GREEN.toString() + ChatColor.BOLD + "ALLOWED", action.getName(), perm.name());
break; break;
case RIGHT: case RIGHT:
access = Access.DENY; access = Access.DENY;
success = fplayer.getFaction().setPermission(perm, action, access); success = fplayer.getFaction().setPermission(perm, action, access);
FactionsPlugin.instance.logFactionEvent(fplayer.getFaction(), FLogType.PERM_EDIT_DEFAULTS, fplayer.getName(), ChatColor.RED.toString() + ChatColor.BOLD + "DENIED", action.getName(), perm.name());
break; break;
case MIDDLE: case MIDDLE:
access = Access.UNDEFINED;
success = fplayer.getFaction().setPermission(perm, action, access);
break;
default: default:
return; return;
} }
@@ -93,9 +87,11 @@ public class PermissableActionFrame {
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")).get().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"))); if (meta != null) {
meta.setDisplayName(FactionsPlugin.getInstance().color(config.getString("Name"))); meta.setLore(FactionsPlugin.getInstance().colorList(config.getStringList("Lore")));
item.setItemMeta(meta); meta.setDisplayName(FactionsPlugin.getInstance().color(config.getString("Name")));
item.setItemMeta(meta);
}
return item; return item;
} }
@@ -103,9 +99,11 @@ public class PermissableActionFrame {
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")).get().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"))); if (meta != null) {
meta.setDisplayName(FactionsPlugin.getInstance().color(config.getString("Name"))); meta.setLore(FactionsPlugin.getInstance().colorList(config.getStringList("Lore")));
item.setItemMeta(meta); meta.setDisplayName(FactionsPlugin.getInstance().color(config.getString("Name")));
item.setItemMeta(meta);
}
return item; return item;
} }
} }

View File

@@ -16,6 +16,7 @@ import org.bukkit.inventory.meta.ItemMeta;
import java.util.ArrayList; import java.util.ArrayList;
import java.util.List; import java.util.List;
import java.util.Objects;
public class PermissableRelationFrame { public class PermissableRelationFrame {
@@ -27,9 +28,10 @@ public class PermissableRelationFrame {
public PermissableRelationFrame(Faction f) { public PermissableRelationFrame(Faction f) {
ConfigurationSection section = FactionsPlugin.getInstance().getConfig().getConfigurationSection("fperm-gui.relation"); ConfigurationSection section = FactionsPlugin.getInstance().getConfig().getConfigurationSection("fperm-gui.relation");
assert section != null;
gui = new Gui(FactionsPlugin.getInstance(), gui = new Gui(FactionsPlugin.getInstance(),
section.getInt("rows", 3), section.getInt("rows", 4),
FactionsPlugin.getInstance().color(FactionsPlugin.getInstance().getConfig().getString("fperm-gui.relation.name").replace("{faction}", f.getTag()))); FactionsPlugin.getInstance().color(Objects.requireNonNull(FactionsPlugin.getInstance().getConfig().getString("fperm-gui.relation.name")).replace("{faction}", f.getTag())));
} }
public void buildGUI(FPlayer fplayer) { public void buildGUI(FPlayer fplayer) {
@@ -37,8 +39,7 @@ public class PermissableRelationFrame {
List<GuiItem> GUIItems = new ArrayList<>(); List<GuiItem> GUIItems = new ArrayList<>();
ItemStack dumby = buildDummyItem(); ItemStack dumby = buildDummyItem();
// Fill background of GUI with dumbyitem & replace GUI assets after // Fill background of GUI with dumbyitem & replace GUI assets after
for (int x = 0; x <= (gui.getRows() * 9) - 1; x++) for (int x = 0; x <= (gui.getRows() * 9) - 1; x++) GUIItems.add(new GuiItem(dumby, e -> e.setCancelled(true)));
GUIItems.add(new GuiItem(dumby, e -> e.setCancelled(true)));
ConfigurationSection sec = FactionsPlugin.getInstance().getConfig().getConfigurationSection("fperm-gui.relation"); ConfigurationSection sec = FactionsPlugin.getInstance().getConfig().getConfigurationSection("fperm-gui.relation");
for (String key : sec.getConfigurationSection("slots").getKeys(false)) { for (String key : sec.getConfigurationSection("slots").getKeys(false)) {
if (key == null || sec.getInt("slots." + key) < 0) continue; if (key == null || sec.getInt("slots." + key) < 0) continue;
@@ -58,8 +59,10 @@ 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)).get().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))); if (meta != null) {
item.setItemMeta(meta); meta.setDisplayName(FactionsPlugin.getInstance().color(FactionsPlugin.getInstance().getConfig().getString("fperm-gui.relation.Placeholder-Item.Name").replace("{relation}", relation)));
item.setItemMeta(meta);
}
return item; return item;
} }
@@ -67,9 +70,12 @@ public class PermissableRelationFrame {
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")).get().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"))); // So u can set it to air.
meta.setDisplayName(FactionsPlugin.getInstance().color(config.getString("Name"))); if (meta != null) {
item.setItemMeta(meta); meta.setLore(FactionsPlugin.getInstance().colorList(config.getStringList("Lore")));
meta.setDisplayName(FactionsPlugin.getInstance().color(config.getString("Name")));
item.setItemMeta(meta);
}
return item; return item;
} }

View File

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

View File

@@ -16,7 +16,6 @@ import org.bukkit.inventory.meta.ItemMeta;
import java.util.ArrayList; import java.util.ArrayList;
import java.util.List; import java.util.List;
import java.util.Objects;
/** /**
* @author Saser * @author Saser
@@ -36,7 +35,8 @@ public class FUpgradeFrame {
PaginatedPane pane = new PaginatedPane(0, 0, 9, this.gui.getRows()); PaginatedPane pane = new PaginatedPane(0, 0, 9, this.gui.getRows());
List<GuiItem> GUIItems = new ArrayList<>(); List<GuiItem> GUIItems = new ArrayList<>();
ItemStack dummy = buildDummyItem(); ItemStack dummy = buildDummyItem();
for (int x = 0; x <= this.gui.getRows() * 9 - 1; ++x) GUIItems.add(new GuiItem(dummy, e -> e.setCancelled(true))); 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()) { for (UpgradeType value : UpgradeType.values()) {
if (value.getSlot() != -1) { if (value.getSlot() != -1) {
GUIItems.set(value.getSlot(), new GuiItem(value.buildAsset(fplayer.getFaction()), e -> { GUIItems.set(value.getSlot(), new GuiItem(value.buildAsset(fplayer.getFaction()), e -> {
@@ -44,19 +44,19 @@ public class FUpgradeFrame {
FPlayer fme = FPlayers.getInstance().getByPlayer((Player) e.getWhoClicked()); FPlayer fme = FPlayers.getInstance().getByPlayer((Player) e.getWhoClicked());
if (fme.getFaction().getUpgrade(value) == value.getMaxLevel()) return; if (fme.getFaction().getUpgrade(value) == value.getMaxLevel()) return;
int cost = FactionsPlugin.getInstance().getConfig().getInt("fupgrades.MainMenu." + value.toString() + ".Cost.level-" + (fme.getFaction().getUpgrade(value) + 1)); int cost = FactionsPlugin.getInstance().getConfig().getInt("fupgrades.MainMenu." + value.toString() + ".Cost.level-" + (fme.getFaction().getUpgrade(value) + 1));
if (fme.hasMoney(cost)) { if (fme.hasMoney(cost)) {
fme.takeMoney(cost); fme.takeMoney(cost);
if (value == UpgradeType.CHEST) updateChests(fme.getFaction()); if (value == UpgradeType.CHEST) updateChests(fme.getFaction());
if (value == UpgradeType.POWER) updateFactionPowerBoost(fme.getFaction()); if (value == UpgradeType.POWER) updateFactionPowerBoost(fme.getFaction());
if (value == UpgradeType.TNT) updateTNT(fme.getFaction()); if (value == UpgradeType.TNT) updateTNT(fme.getFaction());
if (value == UpgradeType.WARP) updateWarps(fme.getFaction()); if (value == UpgradeType.WARP) updateWarps(fme.getFaction());
fme.getFaction().setUpgrade(value, fme.getFaction().getUpgrade(value) + 1); fme.getFaction().setUpgrade(value, fme.getFaction().getUpgrade(value) + 1);
buildGUI(fme); buildGUI(fme);
} }
})); }));
} }
} }

View File

@@ -25,22 +25,22 @@ public class UpgradesListener implements Listener {
@EventHandler @EventHandler
public static void onDamageReduction(EntityDamageByEntityEvent e) { public static void onDamageReduction(EntityDamageByEntityEvent e) {
if (e.isCancelled()) { if (e.isCancelled()) return;
return;
} if (!(e.getDamager() instanceof Player) || !(e.getEntity() instanceof Player)) return;
if (!(e.getDamager() instanceof Player) || !(e.getEntity() instanceof Player)) { if (e.getEntity() == null) return;
return;
}
FPlayer fme = FPlayers.getInstance().getByPlayer((Player) e.getEntity()); FPlayer fme = FPlayers.getInstance().getByPlayer((Player) e.getEntity());
FPlayer dame = FPlayers.getInstance().getByPlayer((Player) e.getDamager()); FPlayer dame = FPlayers.getInstance().getByPlayer((Player) e.getDamager());
if (fme == null || dame == null) {
return; if (fme == null || dame == null) return;
}
FLocation floc = new FLocation(fme.getPlayer().getLocation()); FLocation floc = new FLocation(fme.getPlayer().getLocation());
if (floc == null) return;
if (Board.getInstance().getFactionAt(floc) == fme.getFaction()) { if (Board.getInstance().getFactionAt(floc) == fme.getFaction()) {
if (dame.getFaction() == fme.getFaction()) { if (dame.getFaction() == fme.getFaction()) return;
return;
}
double damage = e.getDamage(); double damage = e.getDamage();
int level = fme.getFaction().getUpgrade(UpgradeType.DAMAGEDECREASE); int level = fme.getFaction().getUpgrade(UpgradeType.DAMAGEDECREASE);
double increase = FactionsPlugin.getInstance().getConfig().getDouble("fupgrades.MainMenu.DamageReduction.DamageReductionPercent.level-" + level); double increase = FactionsPlugin.getInstance().getConfig().getDouble("fupgrades.MainMenu.DamageReduction.DamageReductionPercent.level-" + level);
@@ -50,20 +50,17 @@ public class UpgradesListener implements Listener {
@EventHandler @EventHandler
public static void onDamageIncrease(EntityDamageByEntityEvent e) { public static void onDamageIncrease(EntityDamageByEntityEvent e) {
if (e == null) { if (e == null) return;
return;
} if (!(e.getDamager() instanceof Player) || !(e.getEntity() instanceof Player)) return;
if (!(e.getDamager() instanceof Player) || !(e.getEntity() instanceof Player)) {
return;
}
if (e.getDamager().hasMetadata("NPC") || e.getEntity().hasMetadata("NPC")) return; if (e.getDamager().hasMetadata("NPC") || e.getEntity().hasMetadata("NPC")) return;
FPlayer fme = FPlayers.getInstance().getByPlayer((Player) e.getEntity()); FPlayer fme = FPlayers.getInstance().getByPlayer((Player) e.getEntity());
FPlayer dame = FPlayers.getInstance().getByPlayer((Player) e.getDamager()); FPlayer dame = FPlayers.getInstance().getByPlayer((Player) e.getDamager());
if (fme == null || dame == null) { if (fme == null || dame == null) return;
return;
}
FLocation floc = new FLocation(fme.getPlayer().getLocation()); FLocation floc = new FLocation(fme.getPlayer().getLocation());
@@ -87,9 +84,8 @@ public class UpgradesListener implements Listener {
@EventHandler @EventHandler
public void onDeath(EntityDeathEvent e) { public void onDeath(EntityDeathEvent e) {
Entity killer = e.getEntity().getKiller(); Entity killer = e.getEntity().getKiller();
if (killer == null || !(killer instanceof Player)) { if (killer == null || !(killer instanceof Player)) return;
return;
}
FLocation floc = new FLocation(e.getEntity().getLocation()); FLocation floc = new FLocation(e.getEntity().getLocation());
Faction faction = Board.getInstance().getFactionAt(floc); Faction faction = Board.getInstance().getFactionAt(floc);
if (!faction.isWilderness()) { if (!faction.isWilderness()) {
@@ -112,9 +108,7 @@ public class UpgradesListener implements Listener {
Faction factionAtLoc = Board.getInstance().getFactionAt(floc); Faction factionAtLoc = Board.getInstance().getFactionAt(floc);
if (!factionAtLoc.isWilderness()) { if (!factionAtLoc.isWilderness()) {
int level = factionAtLoc.getUpgrade(UpgradeType.SPAWNER); int level = factionAtLoc.getUpgrade(UpgradeType.SPAWNER);
if (level == 0) { if (level == 0) return;
return;
}
this.lowerSpawnerDelay(e, FactionsPlugin.getInstance().getConfig().getDouble("fupgrades.MainMenu.Spawners.Spawner-Boost.level-" + level)); this.lowerSpawnerDelay(e, FactionsPlugin.getInstance().getConfig().getDouble("fupgrades.MainMenu.Spawners.Spawner-Boost.level-" + level));
} }
} }
@@ -131,13 +125,10 @@ public class UpgradesListener implements Listener {
if (!factionAtLoc.isWilderness()) { if (!factionAtLoc.isWilderness()) {
int level = factionAtLoc.getUpgrade(UpgradeType.CROP); int level = factionAtLoc.getUpgrade(UpgradeType.CROP);
int chance = FactionsPlugin.getInstance().getConfig().getInt("fupgrades.MainMenu.Crops.Crop-Boost.level-" + level); int chance = FactionsPlugin.getInstance().getConfig().getInt("fupgrades.MainMenu.Crops.Crop-Boost.level-" + level);
if (level == 0 || chance == 0) { if (level == 0 || chance == 0) return;
return;
}
int randomNum = ThreadLocalRandom.current().nextInt(1, 101); int randomNum = ThreadLocalRandom.current().nextInt(1, 101);
if (randomNum <= chance) { if (randomNum <= chance) this.growCrop(e);
this.growCrop(e);
}
} }
} }
@@ -173,21 +164,16 @@ public class UpgradesListener implements Listener {
if (!factionAtLoc.isWilderness()) { if (!factionAtLoc.isWilderness()) {
int level = factionAtLoc.getUpgrade(UpgradeType.REDSTONE); int level = factionAtLoc.getUpgrade(UpgradeType.REDSTONE);
if (level != 0) { if (level != 0) {
if (level == 1) { if (level == 1) FactionsPlugin.getInstance().getConfig().getInt("fupgrades.MainMenu.Redstone.Cost");
FactionsPlugin.getInstance().getConfig().getInt("fupgrades.MainMenu.Redstone.Cost"); if (unbreakable.contains(block)) e.setCancelled(true);
}
if (unbreakable.contains(block)) {
e.setCancelled(true);
}
} }
} }
} }
@EventHandler @EventHandler
public void onArmorDamage(PlayerItemDamageEvent e) { public void onArmorDamage(PlayerItemDamageEvent e) {
if (FPlayers.getInstance().getByPlayer(e.getPlayer()) == null) { if (FPlayers.getInstance().getByPlayer(e.getPlayer()) == null) return;
return;
}
if (e.getItem().getType().toString().contains("LEGGINGS") || e.getItem().getType().toString().contains("CHESTPLATE") || e.getItem().getType().toString().contains("HELMET") || e.getItem().getType().toString().contains("BOOTS")) { if (e.getItem().getType().toString().contains("LEGGINGS") || e.getItem().getType().toString().contains("CHESTPLATE") || e.getItem().getType().toString().contains("HELMET") || e.getItem().getType().toString().contains("BOOTS")) {
int lvl = FPlayers.getInstance().getByPlayer(e.getPlayer()).getFaction().getUpgrade(UpgradeType.REINFORCEDARMOR); int lvl = FPlayers.getInstance().getByPlayer(e.getPlayer()).getFaction().getUpgrade(UpgradeType.REINFORCEDARMOR);
double drop = FactionsPlugin.getInstance().getConfig().getDouble("fupgrades.MainMenu.Armor.Armor-HP-Drop.level-" + lvl); double drop = FactionsPlugin.getInstance().getConfig().getDouble("fupgrades.MainMenu.Armor.Armor-HP-Drop.level-" + lvl);

View File

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

View File

@@ -663,25 +663,34 @@ public abstract class MemoryFPlayer implements FPlayer {
public void updatePower() { public void updatePower() {
if (this.isOffline()) { if (this.isOffline()) {
losePowerFromBeingOffline(); losePowerFromBeingOffline();
if (!Conf.powerRegenOffline) return; if (!Conf.powerRegenOffline) {
return;
}
} else if (hasFaction() && getFaction().isPowerFrozen()) { } else if (hasFaction() && getFaction().isPowerFrozen()) {
return; // Don't let power regen if faction power is frozen. return; // Don't let power regen if faction power is frozen.
} }
long now = System.currentTimeMillis(); long now = System.currentTimeMillis();
this.millisPassed = now - this.lastPowerUpdateTime; long millisPassed = now - this.lastPowerUpdateTime;
this.lastPowerUpdateTime = now; this.lastPowerUpdateTime = now;
Player thisPlayer = this.getPlayer(); Player thisPlayer = this.getPlayer();
if (thisPlayer != null && thisPlayer.isDead()) if (thisPlayer != null && thisPlayer.isDead()) {
return; // don't let dead players regain power until they respawn return; // don't let dead players regain power until they respawn
PowerRegenEvent powerRegenEvent = new PowerRegenEvent(getFaction(), this); }
Bukkit.getScheduler().runTask(FactionsPlugin.getInstance(), () -> Bukkit.getServer().getPluginManager().callEvent(powerRegenEvent));
if (!powerRegenEvent.isCancelled()) double delta = millisPassed * Conf.powerPerMinute / 60000; // millisPerMinute : 60 * 1000
if (!powerRegenEvent.usingCustomPower()) if (Bukkit.getPluginManager().getPlugin("FactionsPlugin") != null) {
this.alterPower(millisPassed * Conf.powerPerMinute / 60000); // millisPerMinute : 60 * 1000 Bukkit.getScheduler().runTask(FactionsPlugin.getInstance(), () -> {
else this.alterPower(+powerRegenEvent.getCustomPower()); PowerRegenEvent powerRegenEvent = new PowerRegenEvent(getFaction(), this, delta);
Bukkit.getServer().getPluginManager().callEvent(powerRegenEvent);
if (!powerRegenEvent.isCancelled()) {
this.alterPower(powerRegenEvent.getDelta());
}
});
} else {
this.alterPower(delta);
}
} }
public void losePowerFromBeingOffline() { public void losePowerFromBeingOffline() {
@@ -728,12 +737,13 @@ public abstract class MemoryFPlayer implements FPlayer {
public void sendFactionHereMessage(Faction from) { public void sendFactionHereMessage(Faction from) {
Faction toShow = Board.getInstance().getFactionAt(getLastStoodAt()); Faction toShow = Board.getInstance().getFactionAt(getLastStoodAt());
boolean showChat = true;
if (Conf.worldsNoClaiming.contains(getLastStoodAt().getWorldName())) return;
if (showInfoBoard(toShow)) { if (showInfoBoard(toShow)) {
FScoreboard.get(this).setTemporarySidebar(new FInfoSidebar(toShow)); FScoreboard.get(this).setTemporarySidebar(new FInfoSidebar(toShow));
showChat = FactionsPlugin.getInstance().getConfig().getBoolean("scoreboard.also-send-chat", true);
} }
if (showChat) if (FactionsPlugin.getInstance().getConfig().getBoolean("scoreboard.also-send-chat", true))
this.sendMessage(FactionsPlugin.getInstance().txt.parse(TL.FACTION_LEAVE.format(from.getTag(this), toShow.getTag(this)))); this.sendMessage(FactionsPlugin.getInstance().txt.parse(TL.FACTION_LEAVE.format(from.getTag(this), toShow.getTag(this))));
} }
@@ -842,71 +852,72 @@ public abstract class MemoryFPlayer implements FPlayer {
} }
public boolean canClaimForFactionAtLocation(Faction forFaction, FLocation flocation, boolean notifyFailure) { public boolean canClaimForFactionAtLocation(Faction forFaction, FLocation flocation, boolean notifyFailure) {
FactionsPlugin plugin = FactionsPlugin.getInstance();
String error = null; String error = null;
Faction myFaction = getFaction(); Faction myFaction = getFaction();
Faction currentFaction = Board.getInstance().getFactionAt(flocation); Faction currentFaction = Board.getInstance().getFactionAt(flocation);
int ownedLand = forFaction.getLandRounded(); int ownedLand = forFaction.getLandRounded();
int factionBuffer = FactionsPlugin.getInstance().getConfig().getInt("hcf.buffer-zone", 0); int factionBuffer = plugin.getConfig().getInt("hcf.buffer-zone", 0);
int worldBuffer = FactionsPlugin.getInstance().getConfig().getInt("world-border.buffer", 0) - 1; int worldBuffer = plugin.getConfig().getInt("world-border.buffer", 0) - 1;
if (Conf.worldGuardChecking && Worldguard.getInstance().checkForRegionsInChunk(flocation) && !this.isAdminBypassing()) { if (Conf.worldGuardChecking && Worldguard.getInstance().checkForRegionsInChunk(flocation)) {
// Checks for WorldGuard regions in the chunk attempting to be claimed // Checks for WorldGuard regions in the chunk attempting to be claimed
error = FactionsPlugin.getInstance().txt.parse(TL.CLAIM_PROTECTED.toString()); error = plugin.txt.parse(TL.CLAIM_PROTECTED.toString());
} else if (flocation.isOutsideWorldBorder(FactionsPlugin.getInstance().getConfig().getInt("world-border.buffer", 0) - 1)) { } else if (flocation.isOutsideWorldBorder(plugin.getConfig().getInt("world-border.buffer", 0) - 1)) {
error = FactionsPlugin.getInstance().txt.parse(TL.CLAIM_OUTSIDEWORLDBORDER.toString()); error = plugin.txt.parse(TL.CLAIM_OUTSIDEWORLDBORDER.toString());
} else if (Conf.worldsNoClaiming.contains(flocation.getWorldName())) { } else if (Conf.worldsNoClaiming.contains(flocation.getWorldName())) {
error = FactionsPlugin.getInstance().txt.parse(TL.CLAIM_DISABLED.toString()); error = plugin.txt.parse(TL.CLAIM_DISABLED.toString());
} else if (this.isAdminBypassing()) { } else if (this.isAdminBypassing()) {
return true; return true;
} else if (forFaction.isSafeZone() && Permission.MANAGE_SAFE_ZONE.has(getPlayer())) { } else if (forFaction.isSafeZone() && Permission.MANAGE_SAFE_ZONE.has(getPlayer())) {
return true; return true;
} else if (forFaction.isWarZone() && Permission.MANAGE_WAR_ZONE.has(getPlayer())) { } else if (forFaction.isWarZone() && Permission.MANAGE_WAR_ZONE.has(getPlayer())) {
return true; return true;
} else if (currentFaction.getAccess(this, PermissableAction.TERRITORY) == Access.ALLOW) { } else if (currentFaction.getAccess(this, PermissableAction.TERRITORY) == Access.ALLOW && forFaction != currentFaction) {
return true; return true;
} else if (myFaction != forFaction) { } else if (myFaction != forFaction) {
error = FactionsPlugin.getInstance().txt.parse(TL.CLAIM_CANTCLAIM.toString(), forFaction.describeTo(this)); error = plugin.txt.parse(TL.CLAIM_CANTCLAIM.toString(), forFaction.describeTo(this));
} else if (forFaction == currentFaction) { } else if (forFaction == currentFaction) {
error = FactionsPlugin.getInstance().txt.parse(TL.CLAIM_ALREADYOWN.toString(), forFaction.describeTo(this, true)); error = plugin.txt.parse(TL.CLAIM_ALREADYOWN.toString(), forFaction.describeTo(this, true));
} else if (forFaction.getFPlayers().size() < Conf.claimsRequireMinFactionMembers) { } else if (forFaction.getFPlayers().size() < Conf.claimsRequireMinFactionMembers) {
error = FactionsPlugin.getInstance().txt.parse(TL.CLAIM_MEMBERS.toString(), Conf.claimsRequireMinFactionMembers); error = plugin.txt.parse(TL.CLAIM_MEMBERS.toString(), Conf.claimsRequireMinFactionMembers);
} else if (currentFaction.isSafeZone()) { } else if (currentFaction.isSafeZone()) {
error = FactionsPlugin.getInstance().txt.parse(TL.CLAIM_SAFEZONE.toString()); error = plugin.txt.parse(TL.CLAIM_SAFEZONE.toString());
} else if (currentFaction.isWarZone()) { } else if (currentFaction.isWarZone()) {
error = FactionsPlugin.getInstance().txt.parse(TL.CLAIM_WARZONE.toString()); error = plugin.txt.parse(TL.CLAIM_WARZONE.toString());
} else if (FactionsPlugin.getInstance().getConfig().getBoolean("hcf.allow-overclaim", true) && ownedLand >= forFaction.getPowerRounded()) { } else if (plugin.getConfig().getBoolean("hcf.allow-overclaim", true) && ownedLand >= forFaction.getPowerRounded()) {
error = FactionsPlugin.getInstance().txt.parse(TL.CLAIM_POWER.toString()); error = plugin.txt.parse(TL.CLAIM_POWER.toString());
} else if (Conf.claimedLandsMax != 0 && ownedLand >= Conf.claimedLandsMax && forFaction.isNormal()) { } else if (Conf.claimedLandsMax != 0 && ownedLand >= Conf.claimedLandsMax && forFaction.isNormal()) {
error = FactionsPlugin.getInstance().txt.parse(TL.CLAIM_LIMIT.toString()); error = plugin.txt.parse(TL.CLAIM_LIMIT.toString());
} else if (currentFaction.getRelationTo(forFaction) == Relation.ALLY) { } else if (currentFaction.getRelationTo(forFaction) == Relation.ALLY) {
error = FactionsPlugin.getInstance().txt.parse(TL.CLAIM_ALLY.toString()); error = plugin.txt.parse(TL.CLAIM_ALLY.toString());
} else if (Conf.claimsMustBeConnected && !this.isAdminBypassing() && myFaction.getLandRoundedInWorld(flocation.getWorldName()) > 0 && !Board.getInstance().isConnectedLocation(flocation, myFaction) && (!Conf.claimsCanBeUnconnectedIfOwnedByOtherFaction || !currentFaction.isNormal())) { } else if (Conf.claimsMustBeConnected && !this.isAdminBypassing() && myFaction.getLandRoundedInWorld(flocation.getWorldName()) > 0 && !Board.getInstance().isConnectedLocation(flocation, myFaction) && (!Conf.claimsCanBeUnconnectedIfOwnedByOtherFaction || !currentFaction.isNormal())) {
if (Conf.claimsCanBeUnconnectedIfOwnedByOtherFaction) { if (Conf.claimsCanBeUnconnectedIfOwnedByOtherFaction) {
error = FactionsPlugin.getInstance().txt.parse(TL.CLAIM_CONTIGIOUS.toString()); error = plugin.txt.parse(TL.CLAIM_CONTIGIOUS.toString());
} else { } else {
error = FactionsPlugin.getInstance().txt.parse(TL.CLAIM_FACTIONCONTIGUOUS.toString()); error = plugin.txt.parse(TL.CLAIM_FACTIONCONTIGUOUS.toString());
} }
} else if (factionBuffer > 0 && Board.getInstance().hasFactionWithin(flocation, myFaction, factionBuffer)) { } else if (factionBuffer > 0 && Board.getInstance().hasFactionWithin(flocation, myFaction, factionBuffer)) {
error = FactionsPlugin.getInstance().txt.parse(TL.CLAIM_TOOCLOSETOOTHERFACTION.format(factionBuffer)); error = plugin.txt.parse(TL.CLAIM_TOOCLOSETOOTHERFACTION.format(factionBuffer));
} else if (flocation.isOutsideWorldBorder(worldBuffer)) { } else if (flocation.isOutsideWorldBorder(worldBuffer)) {
if (worldBuffer > 0) { if (worldBuffer > 0) {
error = FactionsPlugin.getInstance().txt.parse(TL.CLAIM_OUTSIDEBORDERBUFFER.format(worldBuffer)); error = plugin.txt.parse(TL.CLAIM_OUTSIDEBORDERBUFFER.format(worldBuffer));
} else { } else {
error = FactionsPlugin.getInstance().txt.parse(TL.CLAIM_OUTSIDEWORLDBORDER.toString()); error = plugin.txt.parse(TL.CLAIM_OUTSIDEWORLDBORDER.toString());
} }
} else if (currentFaction.isNormal()) { } else if (currentFaction.isNormal()) {
if (myFaction.isPeaceful()) { if (myFaction.isPeaceful()) {
error = FactionsPlugin.getInstance().txt.parse(TL.CLAIM_PEACEFUL.toString(), currentFaction.getTag(this)); error = plugin.txt.parse(TL.CLAIM_PEACEFUL.toString(), currentFaction.getTag(this));
} else if (currentFaction.isPeaceful()) { } else if (currentFaction.isPeaceful()) {
error = FactionsPlugin.getInstance().txt.parse(TL.CLAIM_PEACEFULTARGET.toString(), currentFaction.getTag(this)); error = plugin.txt.parse(TL.CLAIM_PEACEFULTARGET.toString(), currentFaction.getTag(this));
} else if (!currentFaction.hasLandInflation()) { } else if (!currentFaction.hasLandInflation()) {
// TODO more messages WARN current faction most importantly // TODO more messages WARN current faction most importantly
error = FactionsPlugin.getInstance().txt.parse(TL.CLAIM_THISISSPARTA.toString(), currentFaction.getTag(this)); error = plugin.txt.parse(TL.CLAIM_THISISSPARTA.toString(), currentFaction.getTag(this));
} else if (currentFaction.hasLandInflation() && !FactionsPlugin.getInstance().getConfig().getBoolean("hcf.allow-overclaim", true)) { } else if (currentFaction.hasLandInflation() && !plugin.getConfig().getBoolean("hcf.allow-overclaim", true)) {
// deny over claim when it normally would be allowed. // deny over claim when it normally would be allowed.
error = FactionsPlugin.getInstance().txt.parse(TL.CLAIM_OVERCLAIM_DISABLED.toString()); error = plugin.txt.parse(TL.CLAIM_OVERCLAIM_DISABLED.toString());
} else if (!Board.getInstance().isBorderLocation(flocation)) { } else if (!Board.getInstance().isBorderLocation(flocation)) {
error = FactionsPlugin.getInstance().txt.parse(TL.CLAIM_BORDER.toString()); error = plugin.txt.parse(TL.CLAIM_BORDER.toString());
} }
} }
// TODO: Add more else if statements. // TODO: Add more else if statements.
@@ -961,37 +972,38 @@ public abstract class MemoryFPlayer implements FPlayer {
} }
public void setFFlying(boolean fly, boolean damage) { public void setFFlying(boolean fly, boolean damage) {
if (!FactionsPlugin.getInstance().getConfig().getBoolean("enable-faction-flight")) if (FactionsPlugin.getInstance().getConfig().getBoolean("enable-faction-flight")) {
return; Player player = getPlayer();
if (player == null) return;
Player player = getPlayer(); player.setAllowFlight(fly);
if (player == null) return; player.setFlying(fly);
player.setAllowFlight(fly); if (!damage) {
player.setFlying(fly); msg(TL.COMMAND_FLY_CHANGE, fly ? "enabled" : "disabled");
if (!fly) {
if (!damage) { sendMessage(TL.COMMAND_FLY_COOLDOWN.toString().replace("{amount}", FactionsPlugin.getInstance().getConfig().getInt("fly-falldamage-cooldown", 3) + ""));
msg(TL.COMMAND_FLY_CHANGE, fly ? "enabled" : "disabled"); }
if (!fly) } else {
sendMessage(TL.COMMAND_FLY_COOLDOWN.toString().replace("{amount}", FactionsPlugin.getInstance().getConfig().getInt("fly-falldamage-cooldown", 3) + "")); msg(TL.COMMAND_FLY_DAMAGE);
} else {
msg(TL.COMMAND_FLY_DAMAGE);
}
// If leaving fly mode, don't let them take fall damage for x seconds.
if (!fly) {
int cooldown = FactionsPlugin.getInstance().getConfig().getInt("fly-falldamage-cooldown", 3);
CmdFly.flyMap.remove(player.getName());
// If the value is 0 or lower, make them take fall damage.
// Otherwise, start a timer and have this cancel after a few seconds.
// Short task so we're just doing it in method. Not clean but eh.
if (cooldown > 0) {
setTakeFallDamage(false);
Bukkit.getScheduler().runTaskLater(FactionsPlugin.getInstance(), () -> setTakeFallDamage(true), 20L * cooldown);
} }
// If leaving fly mode, don't let them take fall damage for x seconds.
if (!fly) {
int cooldown = FactionsPlugin.getInstance().getConfig().getInt("fly-falldamage-cooldown", 3);
CmdFly.flyMap.remove(player.getName());
// If the value is 0 or lower, make them take fall damage.
// Otherwise, start a timer and have this cancel after a few seconds.
// Short task so we're just doing it in method. Not clean but eh.
if (cooldown > 0) {
setTakeFallDamage(false);
Bukkit.getScheduler().runTaskLater(FactionsPlugin.getInstance(), () -> setTakeFallDamage(true), 20L * cooldown);
}
}
isFlying = fly;
} }
isFlying = fly;
} }
public boolean isInFactionsChest() { public boolean isInFactionsChest() {
@@ -1016,8 +1028,14 @@ 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) {
if (faction.isSystemFaction()) return CmdFly.checkFly(this, getPlayer(), faction); return true;
}
if (faction.isSystemFaction()) {
return CmdFly.checkBypassPerms(this, getPlayer(), faction, false);
}
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;
} }
@@ -1204,11 +1222,11 @@ public abstract class MemoryFPlayer implements FPlayer {
} }
public boolean hasFriendlyFire(){ public boolean hasFriendlyFire() {
return friendlyFire; return friendlyFire;
} }
public void setFriendlyFire(boolean status){ public void setFriendlyFire(boolean status) {
friendlyFire = status; friendlyFire = status;
} }
@@ -1286,11 +1304,13 @@ public abstract class MemoryFPlayer implements FPlayer {
// announce success // announce success
Set<FPlayer> informTheseFPlayers = new HashSet<>(); if (!FactionsPlugin.cachedRadiusClaim) {
informTheseFPlayers.add(this); Set<FPlayer> informTheseFPlayers = new HashSet<>();
informTheseFPlayers.addAll(forFaction.getFPlayersWhereOnline(true)); informTheseFPlayers.add(this);
for (FPlayer fp : informTheseFPlayers) { informTheseFPlayers.addAll(forFaction.getFPlayersWhereOnline(true));
fp.msg(TL.CLAIM_CLAIMED, this.describeTo(fp, true), forFaction.describeTo(fp), currentFaction.describeTo(fp)); for (FPlayer fp : informTheseFPlayers) {
fp.msg(TL.CLAIM_CLAIMED, this.describeTo(fp, true), forFaction.describeTo(fp), currentFaction.describeTo(fp));
}
} }
Board.getInstance().setFactionAt(forFaction, flocation); Board.getInstance().setFactionAt(forFaction, flocation);

View File

@@ -1277,9 +1277,10 @@ public abstract class MemoryFaction implements Faction, EconomyParticipator {
if (Conf.logFactionDisband) if (Conf.logFactionDisband)
FactionsPlugin.getInstance().log("The faction " + this.getTag() + " (" + this.getId() + ") has been disbanded since it has no members left" + (autoLeave ? " and by inactivity" : "") + "."); FactionsPlugin.getInstance().log("The faction " + this.getTag() + " (" + this.getId() + ") has been disbanded since it has no members left" + (autoLeave ? " and by inactivity" : "") + ".");
if (FactionsPlugin.getInstance().getConfig().getBoolean("faction-disband-broadcast")) {
for (FPlayer fplayer : FPlayers.getInstance().getOnlinePlayers()) for (FPlayer fplayer : FPlayers.getInstance().getOnlinePlayers())
fplayer.msg(TL.COMMAND_DISBAND_BROADCAST_GENERIC, this.getTag(fplayer)); fplayer.msg(TL.COMMAND_DISBAND_BROADCAST_GENERIC, this.getTag(fplayer));
}
FactionDisbandEvent disbandEvent = new FactionDisbandEvent(null, getId(), autoLeave ? PlayerDisbandReason.INACTIVITY : PlayerDisbandReason.LEAVE); FactionDisbandEvent disbandEvent = new FactionDisbandEvent(null, getId(), autoLeave ? PlayerDisbandReason.INACTIVITY : PlayerDisbandReason.LEAVE);

View File

@@ -73,21 +73,22 @@ public class JSONFPlayers extends MemoryFPlayers {
if (!this.file.exists()) return new HashMap<>(); if (!this.file.exists()) return new HashMap<>();
String content = DiscUtil.readCatch(this.file); String content = DiscUtil.readCatch(this.file);
if (content == null) return null; if (content == null) return null;
Map<String, JSONFPlayer> data = this.gson.fromJson(content, new TypeToken<Map<String, JSONFPlayer>>() { try {
}.getType()); Map<String, JSONFPlayer> data = this.gson.fromJson(content, new TypeToken<Map<String, JSONFPlayer>>() {
Set<String> list = new HashSet<>(); }.getType());
Set<String> invalidList = new HashSet<>(); Set<String> list = new HashSet<>();
for (Entry<String, JSONFPlayer> entry : data.entrySet()) { Set<String> invalidList = new HashSet<>();
String key = entry.getKey(); for (Entry<String, JSONFPlayer> entry : data.entrySet()) {
entry.getValue().setId(key); String key = entry.getKey();
if (doesKeyNeedMigration(key)) { entry.getValue().setId(key);
if (!isKeyInvalid(key)) { if (doesKeyNeedMigration(key)) {
list.add(key); if (!isKeyInvalid(key)) {
} else { list.add(key);
invalidList.add(key); } else {
invalidList.add(key);
}
} }
} }
}
if (list.size() > 0) { if (list.size() > 0) {
// We've got some converting to do! // We've got some converting to do!
@@ -150,6 +151,14 @@ public class JSONFPlayers extends MemoryFPlayers {
Bukkit.getLogger().log(Level.INFO, "Done converting players.json to UUID."); Bukkit.getLogger().log(Level.INFO, "Done converting players.json to UUID.");
} }
return data; return data;
} catch (NullPointerException exception) {
exception.printStackTrace();
if (this.file.length() < 200) {
return new HashMap<>();
} else {
throw exception;
}
}
} }
private boolean doesKeyNeedMigration(String key) { private boolean doesKeyNeedMigration(String key) {

View File

@@ -141,14 +141,14 @@ public enum TL {
COMMAND_ADMIN_TARGETSELF("'&c&l[!] &cThe target player musn''t be yourself."), COMMAND_ADMIN_TARGETSELF("'&c&l[!] &cThe target player musn''t be yourself."),
COMMAND_ADMIN_DEMOTES("&c&l[!] &cYou have demoted &7%1$s &cfrom the position of faction admin."), COMMAND_ADMIN_DEMOTES("&c&l[!] &cYou have demoted &7%1$s &cfrom the position of faction admin."),
COMMAND_ADMIN_DEMOTED("&c&l[!] &cYou have been demoted from the position of faction admin by &7%1$s&c"), COMMAND_ADMIN_DEMOTED("&c&l[!] &cYou have been demoted from the position of faction admin by &7%1$s&c"),
COMMAND_ADMIN_PROMOTES("&e&l[!] &eYou have promoted &6%1$s &eto the position of faction admin."), COMMAND_ADMIN_PROMOTES("&c&l[!] &7You have promoted &c%1$s &7to the position of faction admin."),
COMMAND_ADMIN_PROMOTED("&e&l[!] &6%1$s &egave &6%2$s &ethe leadership of &6%3$s&e."), COMMAND_ADMIN_PROMOTED("&c&l[!] &c%1$s &7gave &c%2$s &7the leadership of &c%3$s&7."),
COMMAND_ADMIN_DESCRIPTION("Hand over your admin rights"), COMMAND_ADMIN_DESCRIPTION("Hand over your admin rights"),
COMMAND_ADMIN_NOMEMBERS("&e&l[!] &cNo one else to promote, please disband faction."), COMMAND_ADMIN_NOMEMBERS("&e&l[!] &cNo one else to promote, please disband faction."),
COMMAND_AHOME_DESCRIPTION("Send a player to their f home no matter what."), COMMAND_AHOME_DESCRIPTION("Send a player to their f home no matter what."),
COMMAND_AHOME_NOHOME("%1$s doesn't have an f home."), COMMAND_AHOME_NOHOME("%1$s doesn't have an f home."),
COMMAND_AHOME_SUCCESS("$1%s was sent to their f home."), COMMAND_AHOME_SUCCESS("%1%s was sent to their f home."),
COMMAND_AHOME_OFFLINE("%1$s is offline."), COMMAND_AHOME_OFFLINE("%1$s is offline."),
COMMAND_AHOME_TARGET("You were sent to your f home."), COMMAND_AHOME_TARGET("You were sent to your f home."),
@@ -302,7 +302,7 @@ public enum TL {
COMMAND_CREATE_TOCREATE("to create a new faction"), COMMAND_CREATE_TOCREATE("to create a new faction"),
COMMAND_CREATE_FORCREATE("for creating a new faction"), COMMAND_CREATE_FORCREATE("for creating a new faction"),
COMMAND_CREATE_ERROR("&c&l[!]&7 There was an &cinternal error&7 while trying to create your faction. &cPlease try again&7."), COMMAND_CREATE_ERROR("&c&l[!]&7 There was an &cinternal error&7 while trying to create your faction. &cPlease try again&7."),
COMMAND_CREATE_CREATED("&c&l[!]&7 &c%1$s &7created a new faction &c&l%2$s"), COMMAND_CREATE_CREATED("&c&l[!]&7 &c%1$s &7created a new faction named &c&l%2$s&7."),
COMMAND_CREATE_YOUSHOULD("&c&l[!]&7 You should now: &c%1$s"), COMMAND_CREATE_YOUSHOULD("&c&l[!]&7 You should now: &c%1$s"),
COMMAND_CREATE_CREATEDLOG(" created a new faction: "), COMMAND_CREATE_CREATEDLOG(" created a new faction: "),
COMMAND_CREATE_DESCRIPTION("Create a new faction"), COMMAND_CREATE_DESCRIPTION("Create a new faction"),
@@ -395,20 +395,20 @@ public enum TL {
COMMAND_DISBAND_MARKEDPERMANENT("&c&l[!]&7 This faction is designated as&c permanent&7, so you cannot disband it."), COMMAND_DISBAND_MARKEDPERMANENT("&c&l[!]&7 This faction is designated as&c permanent&7, so you cannot disband it."),
COMMAND_DISBAND_BROADCAST_YOURS("&c&l[!]&7 &c%1$s&7 disbanded your &cfaction."), COMMAND_DISBAND_BROADCAST_YOURS("&c&l[!]&7 &c%1$s&7 disbanded your &cfaction."),
COMMAND_DISBAND_BROADCAST_GENERIC("&c&l[!]&7 The Faction &c%1$s&7 was disbanded."), COMMAND_DISBAND_BROADCAST_GENERIC("&c&l[!]&7 The Faction &c%1$s&7 was disbanded."),
COMMAND_DISBAND_BROADCAST_NOTYOURS("&c&l[!]&7 &c%1$s &7disbanded the faction &c%2$s."), COMMAND_DISBAND_BROADCAST_NOTYOURS("&c&l[!]&7 &c%1$s &7disbanded the faction &c%2$s&7."),
COMMAND_DISBAND_HOLDINGS("&c&l[!]&7 &7You have been given the disbanded &cfaction's bank&7, totaling &c%1$s."), COMMAND_DISBAND_HOLDINGS("&c&l[!]&7 &7You have been given the disbanded &cfaction's bank&7, totaling &c%1$s."),
COMMAND_DISBAND_PLAYER("&c&l[!] &7You have disbanded your &cfaction"), COMMAND_DISBAND_PLAYER("&c&l[!] &7You have disbanded your &cfaction"),
COMMAND_DISBAND_CONFIRM("&c&l[!]&7 Your Faction has&c {tnt} &7tnt left in the bank, it will be &clost&7 if the faction is &cdisbanded&7. Type&c /f disband &7again within &c10&7 seconds to&c disband&7."), COMMAND_DISBAND_CONFIRM("&c&l[!]&7 Your Faction has&c {tnt} &7tnt left in the bank, it will be &clost&7 if the faction is &cdisbanded&7. Type&c /f disband &7again within &c10&7 seconds to&c disband&7."),
COMMAND_DISBAND_DESCRIPTION("Disband a faction"), COMMAND_DISBAND_DESCRIPTION("Disband a faction"),
COMMAND_FLY_DISABLED("&c&l[!]&7 Sorry, Faction flight is &cdisabled &7on this server"), COMMAND_FLY_DISABLED("&c&l[!]&7 Sorry, Faction flight is &cdisabled &7on this server."),
COMMAND_FLY_DESCRIPTION("Enter or leave Faction flight mode"), COMMAND_FLY_DESCRIPTION("Enter or leave Faction flight mode"),
COMMAND_FLY_CHANGE("&c&l[!]&7 Faction flight &c%1$s"), COMMAND_FLY_CHANGE("&c&l[!]&7 Faction flight has been &c%1$s&7."),
COMMAND_FLY_COOLDOWN("&c&l[!]&7 You will &cnot&7 take fall damage for &c{amount}&7 seconds"), COMMAND_FLY_COOLDOWN("&c&l[!]&7 You will &cnot&7 take fall damage for &c{amount}&7 seconds."),
COMMAND_FLY_DAMAGE("&c&l[!]&7 Faction flight &cdisabled&7 due to entering combat"), COMMAND_FLY_DAMAGE("&c&l[!]&7 Faction flight &cdisabled&7 due to entering combat."),
COMMAND_FLY_NO_ACCESS("&c&l[!]&7 &cCannot fly &7in territory of %1$s"), COMMAND_FLY_NO_ACCESS("&c&l[!]&7 &cCannot fly &7in territory of %1$s"),
COMMAND_FLY_ENEMY_NEAR("&c&l[!]&7 Flight has been&c disabled&7 an enemy is nearby"), COMMAND_FLY_ENEMY_NEAR("&c&l[!]&7 Flight has been&c disabled&7 an enemy is nearby."),
COMMAND_FLY_CHECK_ENEMY("&c&l[!]&7 Cannot fly here, an enemy is &cnearby"), COMMAND_FLY_CHECK_ENEMY("&c&l[!]&7 Cannot fly here, an enemy is &cnearby&7."),
COMMAND_FLY_NO_EPEARL("&c&l[!] &7You &ccannot&7 throw enderpearls while flying!"), COMMAND_FLY_NO_EPEARL("&c&l[!] &7You &ccannot&7 throw enderpearls while flying!"),
COMMAND_FOCUS_SAMEFACTION("&c[!] You may not focus players in your faction!"), COMMAND_FOCUS_SAMEFACTION("&c[!] You may not focus players in your faction!"),
@@ -470,7 +470,7 @@ public enum TL {
COMMAND_INVITE_TOINVITE("to invite someone"), COMMAND_INVITE_TOINVITE("to invite someone"),
COMMAND_INVITE_FORINVITE("for inviting someone"), COMMAND_INVITE_FORINVITE("for inviting someone"),
COMMAND_INVITE_CLICKTOJOIN("Click to join!"), COMMAND_INVITE_CLICKTOJOIN("Click to join!"),
COMMAND_INVITE_INVITEDYOU(" &chas invited you to join "), COMMAND_INVITE_INVITEDYOU("&l[!]&7 &c%1$s&7 has invited you to join &c%2$s&7"),
COMMAND_INVITE_INVITED("&c&l[!]&7 &c%1$s&7 invited &c%2$s&7 to your faction."), COMMAND_INVITE_INVITED("&c&l[!]&7 &c%1$s&7 invited &c%2$s&7 to your faction."),
COMMAND_ALTINVITE_INVITED_ALT("&c&l[!]&7 &c%1$s&7 invited &c%2$s&7 to your faction as an alt."), COMMAND_ALTINVITE_INVITED_ALT("&c&l[!]&7 &c%1$s&7 invited &c%2$s&7 to your faction as an alt."),
@@ -621,7 +621,7 @@ public enum TL {
COMMAND_OPEN_OPEN("open"), COMMAND_OPEN_OPEN("open"),
COMMAND_OPEN_CLOSED("closed"), COMMAND_OPEN_CLOSED("closed"),
COMMAND_OPEN_CHANGES("&c&l[!]&7 &c%1$s&7 changed the faction to &c%2$s&7."), COMMAND_OPEN_CHANGES("&c&l[!]&7 &c%1$s&7 changed the faction to &c%2$s&7."),
COMMAND_OPEN_CHANGED("&c&l[!]&7 The faction &c%1$s&7 is now &c%2$s"), COMMAND_OPEN_CHANGED("&c&l[!]&7 The faction &c%1$s&7 is now &c%2$s&7."),
COMMAND_OPEN_DESCRIPTION("Switch if invitation is required to join"), COMMAND_OPEN_DESCRIPTION("Switch if invitation is required to join"),
COMMAND_OWNER_DISABLED("&c&l[!]&7 Sorry, but &cowned areas &7are &cdisabled &7on this server."), COMMAND_OWNER_DISABLED("&c&l[!]&7 Sorry, but &cowned areas &7are &cdisabled &7on this server."),
@@ -707,11 +707,14 @@ public enum TL {
COMMAND_PERMANENT_GRANT("&c&l[!]&7 added permanent status to"), COMMAND_PERMANENT_GRANT("&c&l[!]&7 added permanent status to"),
COMMAND_PERMANENT_REVOKE("&c&l[!]&7 removed permanent status from"), COMMAND_PERMANENT_REVOKE("&c&l[!]&7 removed permanent status from"),
COMMAND_PERMANENT_YOURS("&c&l[!]&7 &c%1$s&7 has &c%2$s&7 your faction"), COMMAND_PERMANENT_YOURS("&c&l[!]&7 &c%1$s&7 has &c%2$s&7 your faction"),
COMMAND_PERMANENT_OTHER("&c&l[!]&7 &c%s &7has &c%s &7the faction &c'%s'."), COMMAND_PERMANENT_OTHER("&c&l[!]&7 &c%s &7has &c%s &7the faction '&c%s&7'."),
COMMAND_PROMOTE_TARGET("&c&l[!]&7 You've been &c%1$s&7 to &c%2$s"), COMMAND_PROMOTE_TARGET("&c&l[!]&7 You've been &c%1$s&7 to &c%2$s&7."),
COMMAND_PROMOTE_SUCCESS("&c&l[!]&7 You successfully&c %1$s %2$s &cto&7 %3$s"), COMMAND_PROMOTE_SUCCESS("&c&l[!]&7 You successfully &c%1$s %2$s &cto&7 %3$s&7."),
COMMAND_PROMOTE_PROMOTED("promoted"), COMMAND_PROMOTE_PROMOTED("promoted"),
COMMAND_PROMOTE_DEMOTED("demoted"), COMMAND_PROMOTE_DEMOTED("demoted"),
COMMAND_PROMOTE_LOWEST_RANK("&c&l[!]&7 &c%1$s&7 already has the lowest rank in the faction."),
COMMAND_PROMOTE_HIGHEST_RANK("&c&l[!]&7 &c%1$s&7 already has the highest rank in the faction."),
COMMAND_PROMOTE_HIGHER_RANK("&c&l[!]&7 &c%1$s&7 has a higher rank than yours. You &4can not modify&7 his rank."),
COMMAND_PROMOTE_COLEADER_ADMIN("&c&l[!]&7 &cColeaders cant promote players to Admin!"), COMMAND_PROMOTE_COLEADER_ADMIN("&c&l[!]&7 &cColeaders cant promote players to Admin!"),
COMMAND_PERMANENTPOWER_DESCRIPTION("Toggle permanent faction power option"), COMMAND_PERMANENTPOWER_DESCRIPTION("Toggle permanent faction power option"),
@@ -723,7 +726,6 @@ public enum TL {
COMMAND_PROMOTE_DESCRIPTION("/f promote <name>"), COMMAND_PROMOTE_DESCRIPTION("/f promote <name>"),
COMMAND_PROMOTE_WRONGFACTION("&c&l[!]&7 &c%1$s&7 is &cnot&7 part of your faction."), COMMAND_PROMOTE_WRONGFACTION("&c&l[!]&7 &c%1$s&7 is &cnot&7 part of your faction."),
COMMAND_NOACCESS("&c&l[!]&7 You don't have access to that."), COMMAND_NOACCESS("&c&l[!]&7 You don't have access to that."),
COMMAND_PROMOTE_NOTTHATPLAYER("&c&l[!]&7 That player &ccannot&7 be promoted."),
COMMAND_PROMOTE_NOT_ALLOWED("&c&l[!]&7 You cannot promote to the same rank as yourself!"), COMMAND_PROMOTE_NOT_ALLOWED("&c&l[!]&7 You cannot promote to the same rank as yourself!"),
COMMAND_PROMOTE_NOTSELF("&c&l[!]&7 You cannot manage your own rank."), COMMAND_PROMOTE_NOTSELF("&c&l[!]&7 You cannot manage your own rank."),
COMMAND_PROMOTE_NOT_SAME("&c&l[!]&7 You cannot promote to the same rank as yourself!"), COMMAND_PROMOTE_NOT_SAME("&c&l[!]&7 You cannot promote to the same rank as yourself!"),
@@ -731,7 +733,7 @@ public enum TL {
COMMAND_POWER_TOSHOW("to show player power info"), COMMAND_POWER_TOSHOW("to show player power info"),
COMMAND_POWER_FORSHOW("for showing player power info"), COMMAND_POWER_FORSHOW("for showing player power info"),
COMMAND_POWER_POWER("&c&l[!]&7 &c%1$s » &cPower &7/ &cMaxpower&a » &c%2$d &7/&c%3$d %4$s"), COMMAND_POWER_POWER("&c&l[!]&7 &c%1$s » &cPower &7/ &cMaxpower&a » &c%2$d &7/ &c%3$d %4$s"),
COMMAND_POWER_BONUS(" (bonus: "), COMMAND_POWER_BONUS(" (bonus: "),
COMMAND_POWER_PENALTY(" (penalty: "), COMMAND_POWER_PENALTY(" (penalty: "),
COMMAND_POWER_DESCRIPTION("&a&l» &7Show player &apower &7info"), COMMAND_POWER_DESCRIPTION("&a&l» &7Show player &apower &7info"),
@@ -750,16 +752,16 @@ public enum TL {
COMMAND_RELATIONS_ALREADYINRELATIONSHIP("&c&l[!]&7 You &calready&7 have that relation wish set with&c %1$s."), COMMAND_RELATIONS_ALREADYINRELATIONSHIP("&c&l[!]&7 You &calready&7 have that relation wish set with&c %1$s."),
COMMAND_RELATIONS_TOMARRY("to change a relation wish"), COMMAND_RELATIONS_TOMARRY("to change a relation wish"),
COMMAND_RELATIONS_FORMARRY("for changing a relation wish"), COMMAND_RELATIONS_FORMARRY("for changing a relation wish"),
COMMAND_RELATIONS_MUTUAL("&c&l[!]&7 Your faction is now %1$s to %2$s"), COMMAND_RELATIONS_MUTUAL("&c&l[!]&7 Your faction is now %1$s&7 to &c%2$s&7."),
COMMAND_RELATIONS_PEACEFUL("&c&l[!]&7 This will have no effect while your faction is peaceful."), COMMAND_RELATIONS_PEACEFUL("&c&l[!]&7 This will have no effect while your faction is peaceful."),
COMMAND_RELATIONS_PEACEFULOTHER("&c&l[!]&7 This will have &cno effect&7 while their faction is peaceful."), COMMAND_RELATIONS_PEACEFULOTHER("&c&l[!]&7 This will have &cno effect&7 while their faction is peaceful."),
COMMAND_RELATIONS_DESCRIPTION("Set relation wish to another faction"), COMMAND_RELATIONS_DESCRIPTION("Set relation wish to another faction"),
COMMAND_RELATIONS_EXCEEDS_ME("&c&l[!]&7 Failed to set relation wish. You can only have %1$s %2$s."), COMMAND_RELATIONS_EXCEEDS_ME("&c&l[!]&7 Failed to set relation wish. You can only have %1$s %2$s."),
COMMAND_RELATIONS_EXCEEDS_THEY("&c&l[!]&7 Failed to set relation wish. They can only have %1$s %2$s."), COMMAND_RELATIONS_EXCEEDS_THEY("&c&l[!]&7 Failed to set relation wish. They can only have %1$s %2$s."),
COMMAND_RELATIONS_PROPOSAL_1("&c&l[!]&7&c %1$s &7wishes to be your&c %2$s"), COMMAND_RELATIONS_PROPOSAL_1("&c&l[!]&7 &c%1$s &7wishes to be your &c%2$s&7."),
COMMAND_RELATIONS_PROPOSAL_2("&c&l[!]&7 Type &c/%1$s %2$s %3$s&7 to accept."), COMMAND_RELATIONS_PROPOSAL_2("&c&l[!]&7 Type &c/%1$s %2$s %3$s&7 to accept."),
COMMAND_RELATIONS_PROPOSAL_SENT("&c&l[!]&7 &c%1$s&7 were informed that you wish to be &c%2$s"), COMMAND_RELATIONS_PROPOSAL_SENT("&c&l[!]&7 &c%1$s&7 were informed that you wish to be &c%2$s&7."),
COMMAND_RELOAD_TIME("&c&l[!]&7 Reloaded &call &7configuration files from disk, took &c%1$d ms."), COMMAND_RELOAD_TIME("&c&l[!]&7 Reloaded &call &7configuration files from disk, took &c%1$d ms."),
COMMAND_RELOAD_DESCRIPTION("Reload data file(s) from disk"), COMMAND_RELOAD_DESCRIPTION("Reload data file(s) from disk"),
@@ -822,6 +824,7 @@ public enum TL {
COMMAND_STRIKESINFO_DESCRIPTION("Get a faction's strikes"), COMMAND_STRIKESINFO_DESCRIPTION("Get a faction's strikes"),
SHOP_NOT_ENOUGH_POINTS("&c&l[!] &7Your faction does not have enough points to purchase this!"), SHOP_NOT_ENOUGH_POINTS("&c&l[!] &7Your faction does not have enough points to purchase this!"),
SHOP_ERROR_DURING_PURCHASE("&c&l[!] &7There was an error while trying to give items please check your inventory! Purchase was not completed!"),
SHOP_BOUGHT_BROADCAST_FACTION("\n&c&l[!] &e&lFactionShop » &b{player} &7bought &b{item}&7 for &b{cost} &7points!\n"), SHOP_BOUGHT_BROADCAST_FACTION("\n&c&l[!] &e&lFactionShop » &b{player} &7bought &b{item}&7 for &b{cost} &7points!\n"),
@@ -972,7 +975,7 @@ public enum TL {
COMMAND_UNBAN_NOTBANNED("&7%s &cisn't banned. Not doing anything."), COMMAND_UNBAN_NOTBANNED("&7%s &cisn't banned. Not doing anything."),
COMMAND_UNBAN_TARGET_IN_OTHER_FACTION("&c%1$s is not in your faction!"), COMMAND_UNBAN_TARGET_IN_OTHER_FACTION("&c%1$s is not in your faction!"),
COMMAND_UNBAN_UNBANNED("&e%1$s &cunbanned &7%2$s"), COMMAND_UNBAN_UNBANNED("&e%1$s &cunbanned &7%2$s"),
COMMAND_UNBAN_TARGET("&aYou were unbanned from &r%s"), COMMAND_UNBAN_TARGETUNBANNED("&aYou were unbanned from &r%s"),
COMMAND_UNCLAIM_SAFEZONE_SUCCESS("Safe zone was unclaimed."), COMMAND_UNCLAIM_SAFEZONE_SUCCESS("Safe zone was unclaimed."),
COMMAND_UNCLAIM_SAFEZONE_NOPERM("This is a safe zone. You lack permissions to unclaim."), COMMAND_UNCLAIM_SAFEZONE_NOPERM("This is a safe zone. You lack permissions to unclaim."),
@@ -1033,12 +1036,12 @@ public enum TL {
/** /**
* Leaving - This is accessed through a command, and so it MAY need a COMMAND_* slug :s * Leaving - This is accessed through a command, and so it MAY need a COMMAND_* slug :s
*/ */
LEAVE_PASSADMIN("You must give the admin role to someone else first."), LEAVE_PASSADMIN("&c&l[!] &7You must give the admin role to someone else first."),
LEAVE_NEGATIVEPOWER("You cannot leave until your power is positive."), LEAVE_NEGATIVEPOWER("&c&l[!] &7You cannot leave until your power is positive."),
LEAVE_TOLEAVE("to leave your faction."), LEAVE_TOLEAVE("to leave your faction."),
LEAVE_FORLEAVE("for leaving your faction."), LEAVE_FORLEAVE("for leaving your faction."),
LEAVE_LEFT("%s left faction %s."), LEAVE_LEFT("&c&l[!] &c%s&7 left faction &c%s&7."),
LEAVE_DISBANDED("%s was disbanded."), LEAVE_DISBANDED("&c&l[!] &c%s&7 was disbanded."),
LEAVE_DISBANDEDLOG("The faction %s (%s) was disbanded due to the last player (%s) leaving."), LEAVE_DISBANDEDLOG("The faction %s (%s) was disbanded due to the last player (%s) leaving."),
LEAVE_DESCRIPTION("\\n &a&l» &7Leave your faction"), LEAVE_DESCRIPTION("\\n &a&l» &7Leave your faction"),
AUTOLEAVE_ADMIN_PROMOTED("&e&l[!] &7Faction admin &c%s&7 has been removed. &c%s&7 has been promoted as the new faction admin."), AUTOLEAVE_ADMIN_PROMOTED("&e&l[!] &7Faction admin &c%s&7 has been removed. &c%s&7 has been promoted as the new faction admin."),
@@ -1067,6 +1070,7 @@ public enum TL {
CLAIM_FORCLAIM("for claiming this land"), CLAIM_FORCLAIM("for claiming this land"),
CLAIM_TOOVERCLAIM("to overclaim this land"), CLAIM_TOOVERCLAIM("to overclaim this land"),
CLAIM_FOROVERCLAIM("for over claiming this land"), CLAIM_FOROVERCLAIM("for over claiming this land"),
CLAIM_RADIUS_CLAIM("%1$s &eclaimed %2$s chunks &astarting from &e(X: %3$s, Z: %4$s)"),
CLAIM_CLAIMED("%s claimed land for %s from %s."), CLAIM_CLAIMED("%s claimed land for %s from %s."),
CLAIM_CLAIMEDLOG("%s claimed land at (%s) for the faction: %s"), CLAIM_CLAIMEDLOG("%s claimed land at (%s) for the faction: %s"),
CLAIM_OVERCLAIM_DISABLED("Over claiming is disabled on this server."), CLAIM_OVERCLAIM_DISABLED("Over claiming is disabled on this server."),
@@ -1121,6 +1125,7 @@ public enum TL {
GENERIC_YOUMUSTBE("&cYour must be atleast %1$s to do this!"), GENERIC_YOUMUSTBE("&cYour must be atleast %1$s to do this!"),
GENERIC_MEMBERONLY("&cYou must be in a faction to do this!"), GENERIC_MEMBERONLY("&cYou must be in a faction to do this!"),
GENERIC_WORLDGUARD("&cThis area is worldguard protected."), GENERIC_WORLDGUARD("&cThis area is worldguard protected."),
GRACE_DISABLED_PLACEHOLDER("Disabled"),
// MISSION_CREATED_COOLDOWN("&c&l[!] &7Due to your immediate faction creation, you may not start missions for &b%1$s minutes&7!"), // MISSION_CREATED_COOLDOWN("&c&l[!] &7Due to your immediate faction creation, you may not start missions for &b%1$s minutes&7!"),
MISSION_MISSION_STARTED("&f%1$s &dstarted the %2$s &fmission"), MISSION_MISSION_STARTED("&f%1$s &dstarted the %2$s &fmission"),
@@ -1170,7 +1175,7 @@ public enum TL {
ECON_PERSONTOOKMONEYFROM("%1$s took %2$s from %3$s."), ECON_PERSONTOOKMONEYFROM("%1$s took %2$s from %3$s."),
ECON_DISABLED("Factions econ is disabled."), ECON_DISABLED("Factions econ is disabled."),
ECON_OVER_BAL_CAP("&4The amount &e%s &4is over Essentials' balance cap."), ECON_OVER_BAL_CAP("&4The amount &e%s &4is over Essentials' balance cap."),
ECON_MONEYLOST("&c%s &7lost &c%s &7%s."), ECON_MONEYLOST("&c&l[!] %s &7lost &c%s &7%s."),
ECON_CANTAFFORD("&c%s &7can't afford &c%s&7 %s."), ECON_CANTAFFORD("&c%s &7can't afford &c%s&7 %s."),
ECON_UNABLETOTRANSFER("&7Unable to transfer &c%s&7 to &c%s&7 from &c%s&7."), ECON_UNABLETOTRANSFER("&7Unable to transfer &c%s&7 to &c%s&7 from &c%s&7."),
ECON_PLAYERBALANCE("&c%s&7's balance is &c%s&7."), ECON_PLAYERBALANCE("&c%s&7's balance is &c%s&7."),
@@ -1246,6 +1251,10 @@ public enum TL {
PLAYER_PVP_NEUTRALFAIL("You can't hurt %s in their own territory unless you declare them as an enemy."), PLAYER_PVP_NEUTRALFAIL("You can't hurt %s in their own territory unless you declare them as an enemy."),
PLAYER_PVP_TRIED("%s tried to hurt you."), PLAYER_PVP_TRIED("%s tried to hurt you."),
SHIELD_CURRENTLY_ENABLE("&a&lCurrently Protected"),
SHIELD_NOT_SET("&c&lNot Set"),
SHIELD_CURRENTLY_NOT_ENABLED("&c&lCurrently Unprotected"),
/** /**
* Strings lying around in other bits of the plugins * Strings lying around in other bits of the plugins
*/ */
@@ -1283,7 +1292,9 @@ public enum TL {
WARMUPS_NOTIFY_FLIGHT("&eFlight will enable in &d%2$d &eseconds."), WARMUPS_NOTIFY_FLIGHT("&eFlight will enable in &d%2$d &eseconds."),
WARMUPS_NOTIFY_TELEPORT("&eYou will teleport to &d%1$s &ein &d%2$d &eseconds."), WARMUPS_NOTIFY_TELEPORT("&eYou will teleport to &d%1$s &ein &d%2$d &eseconds."),
WARMUPS_ALREADY("&cYou are already warming up."), WARMUPS_ALREADY("&cYou are already warming up."),
WARMUPS_CANCELLED("&cYou have cancelled your warmup."); WARMUPS_CANCELLED("&cYou have cancelled your warmup."),
PLACEHOLDERAPI_NULL("");
public static SimpleDateFormat sdf; public static SimpleDateFormat sdf;
private static YamlConfiguration LANG; private static YamlConfiguration LANG;

View File

@@ -78,6 +78,7 @@ public enum TagReplacer {
FACTION_BANCOUNT(TagType.FACTION, "{faction-bancount}"), FACTION_BANCOUNT(TagType.FACTION, "{faction-bancount}"),
FACTION_STRIKES(TagType.FACTION, "{strikes}"), FACTION_STRIKES(TagType.FACTION, "{strikes}"),
FACTION_POINTS(TagType.FACTION, "{faction-points}"), FACTION_POINTS(TagType.FACTION, "{faction-points}"),
SHIELD_STATUS(TagType.FACTION, "{shield-status}"),
/** /**
@@ -239,6 +240,10 @@ public enum TagReplacer {
return fac.hasHome() ? String.valueOf(fac.getHome().getBlockY()) : minimal ? null : "{ig}"; return fac.hasHome() ? String.valueOf(fac.getHome().getBlockY()) : minimal ? null : "{ig}";
case HOME_Z: case HOME_Z:
return fac.hasHome() ? String.valueOf(fac.getHome().getBlockZ()) : minimal ? null : "{ig}"; return fac.hasHome() ? String.valueOf(fac.getHome().getBlockZ()) : minimal ? null : "{ig}";
//case SHIELD_STATUS:
//if(fac.isProtected() && fac.getShieldFrame() != null) return String.valueOf(TL.SHIELD_CURRENTLY_ENABLE);
//if(fac.getShieldFrame() == null) return String.valueOf(TL.SHIELD_NOT_SET);
//return TL.SHIELD_CURRENTLY_NOT_ENABLED.toString();
case LAND_VALUE: case LAND_VALUE:
return Econ.shouldBeUsed() ? Econ.moneyString(Econ.calculateTotalLandValue(fac.getLandRounded())) : minimal ? null : TL.ECON_OFF.format("value"); return Econ.shouldBeUsed() ? Econ.moneyString(Econ.calculateTotalLandValue(fac.getLandRounded())) : minimal ? null : TL.ECON_OFF.format("value");
case LAND_REFUND: case LAND_REFUND:

View File

@@ -105,7 +105,6 @@ public class TagUtil {
if (FactionsPlugin.getInstance().isMVdWPlaceholderAPIHooked() && player.isOnline()) { if (FactionsPlugin.getInstance().isMVdWPlaceholderAPIHooked() && player.isOnline()) {
line = be.maximvdw.placeholderapi.PlaceholderAPI.replacePlaceholders(player, line); line = be.maximvdw.placeholderapi.PlaceholderAPI.replacePlaceholders(player, line);
} }
return line; return line;
} }

View File

@@ -47,33 +47,45 @@ public class TextUtil {
String text = ""; String text = "";
FancyMessage message = new FancyMessage(text); FancyMessage message = new FancyMessage(text);
ChatColor color = null; ChatColor color = null;
ChatColor style = null;
char[] chars = first.toCharArray(); char[] chars = first.toCharArray();
for (int i = 0; i < chars.length; i++) { for (int i = 0; i < chars.length; i++) {
// changed this so javadocs wont throw an error // changed this so javadocs wont throw an error
String compareChar = chars[i] + ""; String compareChar = chars[i] + "";
if (compareChar.equals("§")) { if (compareChar.equals("§")) {
if (color != null) { if (color != null || style != null) {
if (color.isColor()) { message.then(text);
message.then(text).color(color); if (color != null)
} else { message.color(color);
message.then(text).style(color); if (style != null) {
message.style(style);
style = null;
} }
text = ""; text = "";
} }
color = ChatColor.getByChar(chars[i + 1]); ChatColor tempColor = ChatColor.getByChar(chars[i + 1]);
if (tempColor != null) {
if (tempColor == ChatColor.RESET) {
color = ChatColor.WHITE;
} else if (tempColor.isColor()) {
color = tempColor;
} else {
style = tempColor;
}
}
i++; // skip color char i++; // skip color char
} else { } else {
text += chars[i]; text += chars[i];
} }
} }
if (text.length() > 0) { if (text.length() > 0) {
if (color != null) { if (color != null || style != null) {
if (color.isColor()) { message.then(text);
message.then(text).color(color); if (color != null)
} else { message.color(color);
message.then(text).style(color); if (style != null)
} message.style(style);
} else { } else {
message.text(text); message.text(text);
} }

View File

@@ -282,6 +282,7 @@ show:
- '&4* &cDescription: &f{description}' - '&4* &cDescription: &f{description}'
- '&4* &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* &cFaction Strikes: &f{strikes}' - '&4* &cFaction Strikes: &f{strikes}'
- '&4* &cShield Status: &f{shield-status}'
- '&4* &cFaction Points: &f{faction-points}' - '&4* &cFaction Points: &f{faction-points}'
- '&4* &cFounded: &f{create-date}' - '&4* &cFounded: &f{create-date}'
- '&4* &cBalance: &f{faction-balance}' - '&4* &cBalance: &f{faction-balance}'
@@ -293,6 +294,7 @@ show:
- '&4* &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
relational-show: true
minimal-show: false minimal-show: false
# Factions that should be exempt from /f show, case sensitive, useful for a # Factions that should be exempt from /f show, case sensitive, useful for a
@@ -362,7 +364,9 @@ help:
- '&c/f banlist &8- &7List banned players from your faction.' - '&c/f banlist &8- &7List banned players from your faction.'
- '&c/f lowpower &8- &7List player with power under max from your faction.' - '&c/f lowpower &8- &7List player with power under max from your faction.'
- '&c/f coords &8- &7Broadcast your location to your faction.' - '&c/f coords &8- &7Broadcast your location to your faction.'
#THIS IS AFFILIATED WITH F PERMS PERMISSION (TERRITORY) LOL
- '&c/f showclaims &8- &7List all claims from your faction.' - '&c/f showclaims &8- &7List all claims from your faction.'
#THIS IS AFFILIATED WITH F PERMS PERMISSION (TERRITORY) LOL
- '&7&m--------------------&r &e/f help 2 &7&m-----------------------' - '&7&m--------------------&r &e/f help 2 &7&m-----------------------'
'2': '2':
- '&7&m----------------------------------------------------' - '&7&m----------------------------------------------------'
@@ -600,6 +604,7 @@ fwarp-gui:
faction-creation-broadcast: true #Disabling this will not make faction creation broadcasts appear in chat. faction-creation-broadcast: true #Disabling this will not make faction creation broadcasts appear in chat.
faction-disband-broadcast: true #Disabling this will not make faction disband broadcasts appear in chat. faction-disband-broadcast: true #Disabling this will not make faction disband broadcasts appear in chat.
faction-open-broadcast: true #Disabling this will not make faction open broadcasts appear in chat. faction-open-broadcast: true #Disabling this will not make faction open broadcasts appear in chat.
faction-leader-broadcast: true #Disabling this will not make leader changes appear in chat.
############################################################ ############################################################
# +------------------------------------------------------+ # # +------------------------------------------------------+ #
@@ -753,6 +758,7 @@ Falling-Block-Fix:
# +------------------------------------------------------+ # # +------------------------------------------------------+ #
############################################################ ############################################################
f-disband-gui: f-disband-gui:
title: '&7Confirm Disband'
confirm-item: confirm-item:
Type: LIME_STAINED_GLASS_PANE Type: LIME_STAINED_GLASS_PANE
Name: '&a&lConfirm' Name: '&a&lConfirm'
@@ -828,7 +834,7 @@ Missions:
- "&b&lMine &f&n10,000&r &2Sugar Cane" - "&b&lMine &f&n10,000&r &2Sugar Cane"
Mission: Mission:
Type: "MINE" Type: "MINE"
Material: "SUGAR_CANE_BLOCK" Material: "SUGAR_CANE"
Amount: 10000 Amount: 10000
Reward: Reward:
Commands: ["f points add %faction% 100"] Commands: ["f points add %faction% 100"]
@@ -1246,9 +1252,9 @@ fupgrades:
Members: Members:
Max-Level: 3 Max-Level: 3
Members-Limit: Members-Limit:
level-1: 30 level-1: 5 #The Number Of Members It Will Increase By
level-2: 35 level-2: 10
level-3: 40 level-3: 15
Cost: Cost:
level-1: 1000000 level-1: 1000000
level-2: 2000000 level-2: 2000000
@@ -1262,9 +1268,9 @@ fupgrades:
- '&7&oYour current level is &e&l&o{level}' - '&7&oYour current level is &e&l&o{level}'
- '' - ''
- '&c&lFaction Member Limit' - '&c&lFaction Member Limit'
- '&4&l* &cLevel 1: &f30' - '&4&l* &cLevel 1: &f35'
- '&4&l* &cLevel 2: &f35' - '&4&l* &cLevel 2: &f40'
- '&4&l* &cLevel 3: &f40' - '&4&l* &cLevel 3: &f45'
- '&f' - '&f'
- '&c&lCosts' - '&c&lCosts'
- '&4&l* &cLevel 1: &f$1,000,000' - '&4&l* &cLevel 1: &f$1,000,000'
@@ -1444,6 +1450,7 @@ Wild:
Zones: Zones:
# You may create your own zones here please just follow the original format # # You may create your own zones here please just follow the original format #
Close: Close:
World: world
Range: Range:
MinX: -200 MinX: -200
MaxX: 200 MaxX: 200
@@ -1458,6 +1465,7 @@ Wild:
Name: '&cLow Range' Name: '&cLow Range'
Slot: 1 Slot: 1
Medium: Medium:
World: world
Range: Range:
MinX: -400 MinX: -400
MaxX: 400 MaxX: 400
@@ -1472,6 +1480,7 @@ Wild:
Name: '&cMedium Range' Name: '&cMedium Range'
Slot: 4 Slot: 4
Far: Far:
World: world
Range: Range:
MinX: -800 MinX: -800
MaxX: 800 MaxX: 800
@@ -1551,6 +1560,7 @@ Wild:
# - {tnt-balance} : # of tnt a faction has in their tnt bank # - {tnt-balance} : # of tnt a faction has in their tnt bank
# - {tnt-max-balance} : # of possible tnt a faction can have in their tnt bank # - {tnt-max-balance} : # of possible tnt a faction can have in their tnt bank
# - {faction-strikes} : # of strikes a faction has # - {faction-strikes} : # of strikes a faction has
# - {shield-status} : Status of the factions shield
# Faction Permissions GUI variables. Can only be used in GUI # Faction Permissions GUI variables. Can only be used in GUI
# - {relation} : Shows relation name (Can be used in action and relation) # - {relation} : Shows relation name (Can be used in action and relation)

View File

@@ -226,7 +226,7 @@ COMMAND:
ONLINEFACTIONLESS: 'Online factionless: ' ONLINEFACTIONLESS: 'Online factionless: '
LOCK: LOCK:
LOCKED: <i>Factions is now locked LOCKED: <i>Factions is now locked
UNLOCKED: <i>Factions in now unlocked UNLOCKED: <i>Factions is now unlocked
LOGINS: LOGINS:
TOGGLE: '<i>Set login / logout notifications for Faction members to: <a>%s' TOGGLE: '<i>Set login / logout notifications for Faction members to: <a>%s'
MAP: MAP:

View File

@@ -89,8 +89,8 @@ COMMAND:
INUSE: <b>That tag is already in use. INUSE: <b>That tag is already in use.
TOCREATE: to create a new faction TOCREATE: to create a new faction
FORCREATE: for creating a new faction FORCREATE: for creating a new faction
ERROR: <b>There was an internal error while trying to create your faction. Please try again. ERROR: '<b>There was an internal error while trying to create your faction. Please try again.'
CREATED: %s<i> created a new faction %s CREATED: '%s<i> created a new faction %s'
CREATEDLOG: ' は新しい党派を造りました: ' CREATEDLOG: ' は新しい党派を造りました: '
YOUSHOULD: '<i>You should now: %s' YOUSHOULD: '<i>You should now: %s'
DEINVITE: DEINVITE:

View File

@@ -0,0 +1,508 @@
# Saber Factions 中文汉化语言包 @ Forbidden
# Made with love <3
root:
AUTHOR: Forbidden
RESPONSIBLE: Forbidden
LANGUAGE: Simplified Chinese
ENCODING: UTF-8
LOCALE: zh_CN
REQUIRESUNICODE: 'true'
DEFAULT: 'false'
STATE: complete
LOCAL:
AUTHOR: Forbidden
RESPONSIBLE: Forbidden
LANGUAGE: 简体中文
REGION: 中国大陆
STATE: 完全汉化
COMMAND:
ADMIN:
NOTMEMBER: '%1$s<i> 不是您派系的一员。'
NOTADMIN: <b>您不是派系的管理员。
TARGETSELF: <b>目标玩家不可为您本人。
DEMOTES: <i>您降职了帮派管理员 %1$s<i>。
DEMOTED: <i>您被 %1$s<i> 降职了。
PROMOTES: <i>您被 %1$s<i> 升职到了派系管理员。
PROMOTED: '%1$s<i> 给予了 %2$s<i> %3$s<i> 的管理员。'
AUTOCLAIM:
ENABLED: <i>正在为 <h>%1$s<i> 自动宣称领土。
DISABLED: <i>已禁用自动宣称领土。
REQUIREDRANK: <b>您必须为 <h>%1$s<b> 才能宣称领土。
OTHERFACTION: <b>您不能为 <h>%1$s<b> 宣称领土。
AUTOHELP:
HELPFOR: 命令 " 的帮助:
BOOM:
PEACEFULONLY: <b>此指令仅限于和平状态下的帮派使用。
TOTOGGLE: 来启用爆炸
FORTOGGLE: 要开关爆炸
ENABLED: '%1$s<i> 已%2$s您领土的爆炸功能。'
BYPASS:
ENABLE: <i>您已启用管理员绕过模式。您可在任意地点建造或破坏。
ENABLELOG: ' 已启用管理员绕过模式。'
DISABLE: <i>您已禁用管理员绕过模式。
DISABLELOG: ' 已禁用管理员绕过模式。'
CHAT:
DISABLED: <b>此服务器禁止了内置聊天频道。
INVALIDMODE: <b>无法识别的聊天模式,<i>请键入 'a'、'f' 或 'plugin'
MODE:
PUBLIC: <i>公共聊天模式。
ALLIANCE: <i>盟友聊天模式。
FACTION: <i>派系聊天模式。
CHATSPY:
ENABLE: <i>您已启用顺风耳模式。
ENABLELOG: ' 已启用顺风耳模式'
DISABLE: <i>您已禁用顺风耳模式。
DISABLELOG: ' 已禁用顺风耳模式。'
CLAIM:
INVALIDRADIUS: <b>若您指定半径,则半径至少应为 1。
DENIED: <b>您没有指定半径宣称领土的权限。
CONFIG:
NOEXIST: <b>"<h>%1$s<b>" 的配置设置不存在。
SET:
'TRUE': '" 选项已设置为 true (已启用)。'
'FALSE': '" 选项已设置为 false (已禁用)。'
ADDED: '"%1$s" 设置:已添加 "%2$s"。'
REMOVED: '"%1$s" 设置:已移除 "%2$s"。'
OPTIONSET: '" 选项已设置为 '
COLOURSET: '" 颜色选项已设置为 "'
INTREQUIRED: '无法设置 "%1$s":选项需要整数值。'
LONGREQUIRED: '无法设置 "%1$s":选项需要长整数值。'
DOUBLEREQUIRED: '无法设置 "%1$s":选项需要双精度值。'
FLOATREQUIRED: '无法设置 "%1$s":选项需要浮点值。'
INVALID:
COLOUR: '无法设置 "%1$s""%2$s" 不是有效颜色。'
COLLECTION: '"%1$s" 不是可用此命令修改的数据集类型。'
MATERIAL: '无法更改 "%1$s" 集:"%2$s" 不是有效的材料。'
TYPESET: '"%1$s" 不是可用此命令修改的数据类型集类型。'
MATERIAL:
ADDED: '"%1$s" 设置:添加了材料 "%2$s"。'
REMOVED: '"%1$s" 设置:移除了材料 "%2$s"。'
LOG: ' (%1$s 运行了指令)'
ERROR:
SETTING: 设置配置选项 "%1$s" 至 "%2$s" 时发生错误。
MATCHING: 无法匹配配置选项 "%1$s",请汇报此错误。
TYPE: '''%1$s'' 的类型为 ''%2$s'',其无法被此命令修改。'
CREATE:
MUSTLEAVE: <b>您必须先离开当前派系。
INUSE: <b>此标签已被使用。
TOCREATE: 来创建新派系
FORCREATE: 要创建新派系
ERROR: <b>创建派系时发生内部错误,请重试。
CREATED: '%1$s<i> 创建了新派系 %2$s'
YOUSHOULD: '<i>您现在应:%1$s'
CREATEDLOG: ' 创建了新派系:'
DEINVITE:
CANDEINVITE: '您可取消邀请的玩家:'
CLICKTODEINVITE: 点击取消 %1$s 的邀请
ALREADYMEMBER: '%1$s<i> 已是 %2$s 的成员'
MIGHTWANT: '<i>您可能想要:%1$s'
REVOKED: '%1$s<i> 撤回了您加入 <h>%2$s<i> 的邀请。'
REVOKES: '%1$s<i> 撤回了 %2$s <i>的邀请。'
DELFWARP:
DELETED: <i>已删除传送点 <a>%1$s
INVALID: <i>无法找到传送点 <a>%1$s
TODELETE: 来删除传送点
FORDELETE: 要删除传送点
DESCRIPTION:
CHANGES: '您更改了 <h>%1$s<i> 的描述至:'
CHANGED: '<i>帮派 %1$s<i> 更改了其描述至:'
TOCHANGE: 来更改帮派描述
FORCHANGE: 要更改帮派描述
DISBAND:
IMMUTABLE: <i>您不可解散荒地 (Wilderness)、安全区 (SafeZone) 或是战区 (WarZone)。
MARKEDPERMANENT: <i>此帮派已被标记为永久存在,您不可解散。
BROADCAST:
YOURS: <h>%1$s<i> 解散了您的帮派。
NOTYOURS: <h>%1$s<i> 解散了帮派 %2$s。
HOLDINGS: <i>您获得了解散帮派银行内的资产,共计 %1$s。
FWARP:
CLICKTOWARP: 点击传送!
COMMANDFORMAT: <i>/f warp <传送点名>
WARPED: <i>已传送至 <a>%1$s
INVALID: <i>无法找到传送点 <a>%1$s
TOWARP: 来传送
FORWARPING: 要传送
WARPS: '传送点:'
HELP:
'404': <b>此页面不存在
NEXTCREATE: <i>您可在下一页了解如何创建帮派。
HOME: '<i>另外,别忘记设置家:'
BANK:
'1': <i>您的帮派有着用于支付特定物品的银行。
'2': <i>因此,银行内应储蓄有钱款。
'3': <i>要了解更多,请使用 money 指令。
PLAYERTITLES: <i>玩家头衔只是为了好玩而已,没有任何钦点的意思。
OWNERSHIP:
'1': <i>已宣称且占有的土地已被保护。
'2': <i>故只有所有者、帮派管理员
'3': <i>才有完整权限。
RELATIONS:
'1': <i>设置您想与其他帮派达成的关系。
'2': <i>默认情况下,您与其他帮派的关系为中立。
'3': <i>若双方选择盟友 (ally) 则你们将成为盟友。
'4': <i>若单方选择敌人 (enemy) 则你们将互为对头。
'5': <i>您不可伤害帮派成员或盟友。
'6': <i>您不可在对方领土上伤害中立成员。
'7': <i>您可伤害敌人及未加入帮派的玩家。
'8': ''
'9': <i>在您领土上,来自敌人的伤害将减少。
'10': <i>在您死亡时,您将失去影响力。影响力将随时间恢复。
'11': <i>一个帮派的影响力为所有成员影响力的总和。
'12': <i>一个帮派的影响力决定了其可维持多少土地。
'13': <i>您可在影响力过少的帮派的领土上进行宣称。
PERMISSIONS:
'1': <i>仅有帮派成员可在其自己的领土上建造或摧毁。
'2': '<i>同时,下列物品的使用也将受限:'
'3': <i>门、箱子、熔炉、发射器及红石中继器。
'4': ''
'5': <i>请确保为您的访客在门前放置压力板。
'6': <i>否则他/她们将无法进入。
'7': <i>您也可以利用此方法来创建仅限成员进入的区域。
'8': <i>同时由于发射器受保护,您可制造陷阱而
'9': <i>不必担忧箭矢被偷。
ADMIN:
'1': <c>/f claim safezone <i>宣称土地为安全区
'2': <c>/f claim warzone <i>宣称土地为战区
'3': <c>/f autoclaim [safezone|warzone] <i>随机宣称区域
MOAR:
'1': '终于,管理员有命令可用了:'
'2': '<i>给管理员的更多命令:'
'3': '<i>给管理员的甚至更多命令:'
HOME:
DISABLED: <b>很抱歉,此服务器上禁用了帮派家功能。
TELEPORTDISABLED: <b>很抱歉,此服务器上禁用了传送至帮派家功能。
NOHOME: '<b>您的帮派没有家。'
INENEMY: <b>您无法在对立帮派的领土上传送至您的帮派家。
WRONGWORLD: <b>您无法在别的世界传送至您的帮派家。
ENEMYNEAR: <b>您无法在敌人距您 %s 方块时传送至您的帮派家。
TOTELEPORT: 来传送至您的帮派家
FORTELEPORT: 要传送至您的帮派家
INVITE:
TOINVITE: 来邀请某位玩家
FORINVITE: 要邀请某位玩家
CLICKTOJOIN: 点击加入!
INVITEDYOU: ' 邀请您加入 '
INVITED: '%1$s<i> 邀请了 %2$s<i> 至您的帮派。'
ALREADYMEMBER: '%1$s<i> 已经是 %2$s 的成员。'
JOIN:
CANNOTFORCE: <b>您没有移动玩家至其他帮派的权限。
SYSTEMFACTION: <b>玩家仅可加入普通帮派,而这是一个系统帮派。
ALREADYMEMBER: <b>%1$s %2$s 已经是 %3$s 的成员。
ATLIMIT: ' <b>!<white> 帮派 %1$s 已达到 %2$d 位成员的限制,故 %3$s 当前无法加入。'
INOTHERFACTION: <b>%1$s 必须先离开 %2$s 当前帮派。
NEGATIVEPOWER: <b>%1$s 无法加入影响力为负的帮派。
REQUIRESINVITATION: <i>此帮派需要邀请。
ATTEMPTEDJOIN: '%1$s<i> 尝试加入您的帮派。'
TOJOIN: 来加入帮派
FORJOIN: 要加入帮派
SUCCESS: <i>%1$s 已成功加入 %2$s.
MOVED: <i>%1$s 已移动您至帮派 %2$s。
JOINED: <i>%1$s 加入了您的帮派。
JOINEDLOG: '%1$s 加入了帮派 %2$s。'
MOVEDLOG: '%1$s 移动了玩家 %2$s 至帮派 %3$s。'
KICK:
CANDIDATES: '您可踢出的玩家:'
CLICKTOKICK: '点击踢出 '
SELF: <b>您无法踢出您自己。
NONE: 此玩家不在帮派里。.
NOTMEMBER: '%1$s<b> 不是 %2$s 的成员。'
INSUFFICIENTRANK: <b>您的等级不足以踢出此玩家。
NEGATIVEPOWER: <b>您无法踢出影响力为负的成员。
TOKICK: 来踢出帮派成员
FORKICK: 要踢出帮派成员
FACTION: '%1$s<i> 将 %2$s<i> 踢出了帮派!:O'
KICKS: <i>您将 %1$s<i> 踢出了帮派 %2$s<i>
KICKED: '%1$s<i> 将您踢出了 %2$s<i>:O'
LIST:
FACTIONLIST: '帮派列表 '
TOLIST: 来列出帮派列表
FORLIST: 要列出帮派列表
ONLINEFACTIONLESS: '在线的非帮派玩家:'
LOCK:
LOCKED: <i>帮派现已锁定
UNLOCKED: <i>帮派现已解锁
LOGINS:
TOGGLE: '<i>设置帮派成员登录 / 登出提示至:<a>%s'
MAP:
TOSHOW: 来展示地图
FORSHOW: 要展示地图
UPDATE:
ENABLED: <i>地图自动更新<green>已启用<i>。
DISABLED: <i>地图自动更新<red>已禁用<i>。
MOD:
CANDIDATES: '您可提拔的玩家列表:'
CLICKTOPROMOTE: '点击提拔 '
NOTMEMBER: '%1$s<b> 并不是您帮派的成员。'
NOTADMIN: <b>您不是帮派管理员。
SELF: <b>目标玩家不可为您自己。
TARGETISADMIN: <b>目标玩家为帮派管理员,请先降职他/她。
REVOKES: <i>您从 %1$s 移除了调停者状态<i>。
REVOKED: '%1$s<i> 不再是您帮派的调停者。'
PROMOTES: '%1$s<i> 晋升到了您帮派的调停者。'
PROMOTED: <i>您提拔了 %1$s<i> 至调停者。
MODIFYPOWER:
ADDED: '<i>添加了 <a>%1$f <i>影响力至 <a>%2$s。<i>四舍五入后的现影响力为:<a>%3$d'
MONEY:
SHORT: 帮派金钱命令
LONG: <i>帮派金钱指令。
MONEYBALANCE:
SHORT: 显示帮派余额
MONEYDEPOSIT:
SHORT: 储蓄钱款
DEPOSITED: '%1$s 储蓄了 %2$s 进帮派银行:%3$s'
MONEYTRANSFERFF:
SHORT: 转账帮派 -> 帮派
TRANSFER: '%1$s 从帮派 "%3$s" 转账了 %2$s 至帮派 "%4$s"'
MONEYTRANSFERFP:
SHORT: 转账帮派 -> 插件
TRANSFER: '%1$s 从帮派 "%3$s" 转账了 %2$s 至玩家 "%4$s"'
MONEYTRANSFERPF:
SHORT: 转账插件 -> 帮派
TRANSFER: '%1$s 从玩家 "%3$s" 转账了 %2$s 至帮派 "%4$s"'
MONEYWITHDRAW:
SHORT: 取出钱款
WITHDRAW: '%1$s 从帮派银行 %3$s 中取出了 %2$s'
OPEN:
TOOPEN: 来开放或关闭帮派
FOROPEN: 要开放或关闭帮派
OPEN: 开放
CLOSED: 关闭
CHANGES: '%1$s<i> 更改了帮派至<h>%2$s<i>.'
CHANGED: <i>帮派 %1$s<i> 现已%2$s
OWNER:
DISABLED: <b>很抱歉,但服务器禁用了占有区域。
LIMIT: <b>很抱歉,但您超过了服务器每个帮派<h>最多 %1$d <b>块占有区域的限制。
WRONGFACTION: <b>此地块尚未被您的帮派宣称,故您不可以设置它的主权。
NOTCLAIMED: <b>此地块尚未被任何帮派宣称,主权不可用。
NOTMEMBER: '%1$s<i> 不是此帮派的一员。'
CLEARED: <i>您已清除此宣称区域的主权。
REMOVED: <i>您已从 %1$s 清除此宣称地皮的主权<i>。
TOSET: 来设置宣称地皮的主权
FORSET: 要设置宣称地皮的主权
ADDED: <i>您已添加 %1$s<i> 至此宣称地皮的所有者列表。
OWNERLIST:
DISABLED: <b>很抱歉,但服务器禁用了占有区域。
WRONGFACTION: <b>此地块尚未被您的帮派宣称。
NOTCLAIMED: <i>此地块尚未被任何的帮派宣称,因此虚位以待。
NONE: <i>这里尚未设置所有者:帮派里的所有人均可访问。
OWNERS: '<i>当前此地块的所有者:%1$s'
POWER:
TOSHOW: 来显示玩家影响力信息
FORSHOW: 要显示玩家影响力信息
POWER: '%1$s<a> - 影响力 / 最大影响力:<i>%2$d / %3$d %4$s'
BONUS: ' (奖励:'
PENALTY: ' (惩罚:'
POWERBOOST:
HELP:
'1': <b>您必须指定插件 "plugin" 或玩家 "player" 来指定玩家或使用 "f" 或 "faction" 来指定帮派。
'2': <b>示例:/f powerboost plugin 玩家 0.5 -或- /f powerboost f 帮派 -5
INVALIDNUM: <b>您必须为影响力奖惩值指定有效的数值。
PLAYER: 玩家 "%1$s"
FACTION: 帮派 "%1$s"
BOOST: <i>%1$s 的最低/最高影响力级别现有 %2$d 的奖惩。
BOOSTLOG: '%1$s 为 %2$s 设置影响力奖惩值至 %3$d。'
RELOAD:
TIME: <i>已从磁盘重载 <h>conf.json <i>,共花费 <h>%1$d ms<i>。
SAFEUNCLAIMALL:
SHORT: 取消宣称使用安全区地块
UNCLAIMED: <i>您已取消宣称使用安全区地块。
UNCLAIMEDLOG: '%1$s 已取消宣称使用安全区地块。'
SAVEALL: <i>帮派信息已保存至磁盘!
SETFWARP:
NOTCLAIMED: <i>您仅可在您的帮派区域里设置传送点。
LIMIT: <i>您的帮派已达到了最多传送点的数量限制 <a>(%1$d)。
SET: <i>已设置传送点 <a>%1$s <i>至您的位置。
TOSET: 来设置传送点
FORSET: 要设置传送点
SETHOME:
DISABLED: <b>很抱歉,此服务器上禁用了帮派家功能。
NOTCLAIMED: <b>很抱歉,帮派家仅能设置在您的宣称领土内。
TOSET: 来设置帮派家
FORSET: 要设置帮派家
SET: '%1$s<i> 为您的帮派设置了帮派家。您现在可使用:'
SETOTHER: <b>您已为帮派 %1$s<i> 设置了家。
SHOW:
NOFACTION:
SELF: 您不在帮派里。
OTHER: 这不是帮派。
TOSHOW: 来显示帮派信息
FORSHOW: 要显示帮派信息
DESCRIPTION: '<a>描述:<i>%1$s'
PEACEFUL: 此帮派处于和平状态
PERMANENT: <a>此帮派被标记为永久,即使无成员也依然存在。
JOINING: '<a>正在加入:<i>%1$s '
INVITATION: 需要邀请
UNINVITED: 无需邀请
POWER: '<a>地块 / 影响力 / 最大影响力:<i> %1$d/%2$d/%3$d %4$s'
BONUS: ' (奖励:'
PENALTY: ' (惩罚:'
DEPRECIATED: (%1$s 已弃用)
LANDVALUE: '<a>总地块价值:<i>%1$s %2$s'
BANKCONTAINS: '<a>银行内有:<i>%1$s'
ALLIES: '盟友:'
ENEMIES: '敌人:'
MEMBERSONLINE: '在线成员:'
MEMBERSOFFLINE: '离线成员:'
SHOWINVITES:
PENDING: '等待接受邀请的玩家:'
CLICKTOREVOKE: 点击撤回 %1$s 的邀请。
STATUS:
FORMAT: '%1$s 影响力:%2$s 上次在线:%3$s'
ONLINE: 在线
AGOSUFFIX: ' 前。'
TAG:
TAKEN: <b>此标签已被使用
TOCHANGE: 来更改帮派标签
FORCHANGE: 要更改帮派标签
FACTION: '%1$s<i> 更改了您帮派标签至 %2$s'
CHANGED: <i>帮派 %1$s<i> 更改了其名称至 %2$s。
TITLE:
TOCHANGE: 来更改玩家头衔
FORCHANGE: 要更改玩家头衔
CHANGED: '%1$s<i> 更改了头衔:%2$s'
UNCLAIM:
SAFEZONE:
SUCCESS: <i>已取消宣称安全区。
NOPERM: <b>这里是安全区,您缺少宣称权限。
WARZONE:
SUCCESS: <i>已取消宣称战区。
NOPERM: <b>这里是战区,您缺少宣称权限。
UNCLAIMED: '%1$s<i> 取消宣称了您的部分领土。'
UNCLAIMS: <i>您取消宣称了此领土。
LOG: '%1$s 从帮派 %3$s 取消宣称了在 (%2$s) 处的领土'
WRONGFACTION: <b>您未拥有此领土。
TOUNCLAIM: 来取消宣称此领土
FORUNCLAIM: 要取消宣称此领土
FACTIONUNCLAIMED: '%1$s<i> 取消宣称了部分领土。'
UNCLAIMALL:
TOUNCLAIM: 来取消宣称所有帮派领土
FORUNCLAIM: 要取消宣称所有帮派领土
UNCLAIMED: '%1$s<i> 取消宣称了您所有的帮派领土。'
LOG: '%1$s 为 %2$s 取消宣称了所有的帮派领土'
VERSION:
VERSION: <i>您正运行 %1$s
WARUNCLAIMALL:
SHORT: 取消宣称所有战区领土
SUCCESS: <i>您取消宣称了所有战区领土。
LOG: '%1$s 取消宣称了所有战区领土。'
RELATIONS:
ALLTHENOPE: <b>并不可以哦!
MORENOPE: <b>不行哦!您不可对您自己改变关系 :)
ALREADYINRELATIONSHIP: <b>您已为 %1$s 设置了相同的关系意愿。
TOMARRY: 来改变关系意愿
FORMARRY: 要改变关系意愿
MUTUAL: <i>您的帮派现已 %1$s<i> 至 %2$s
PEACEFUL: <i>在您帮派处于和平状态时,这将毫无作用。
PEACEFULOTHER: <i>在对方帮派处于和平状态时,这将毫无作用。
PROPOSAL:
'1': '%1$s<i> 想成为您的 %2$s'
'2': <i>键入 <c>/%1$s %2$s %3$s<i> 来同意。
SENT: '%1$s<i> 已悉知您想成为 %2$s 的意愿'
command:
convert:
backend:
running: 已正在运行此后端。
invalid: 无效后端
help:
invitations: '<i>您可能想要关闭并使用邀请:'
LEAVE:
PASSADMIN: <b>您必须现将管理员角色转给他人。
NEGATIVEPOWER: <b>您不可在影响力为正时离开帮派。
TOLEAVE: 来离开您的帮派
FORLEAVE: 要离开您的帮派
LEFT: '%s<i> 离开了帮派 %s<i>。'
DISBANDED: <i>%s<i> 被解散了。
DISBANDEDLOG: 由于帮派 %s (%s) 的最后一名玩家 (%s) 也已离开,其已被解散。
CLAIM:
PROTECTED: <b>此地块已被保护
DISABLED: <b>很抱歉,此世界禁用了领土宣称功能。
CANTCLAIM: <b>您不能为 <h>%s<b> 宣称领土。
ALREADYOWN: '%s<i> 已拥有此地块。'
MUSTBE: <b>您必须为 <h>%s<b> 才能宣称领土。
MEMBERS: 帮派必须有至少 <h>%s<b> 名成员才能宣称领土。
SAFEZONE: <b>您不能宣称安全区。
WARZONE: <b>您不能宣称战区。
POWER: <b>您不能宣称更多领土!您需要更多影响力!
LIMIT: <b>已达到限制。您不可宣称更多领土!
ALLY: <b>您无法宣称您盟友的领土。
CONTIGIOUS: <b>您仅可宣称连到您首块宣称领土或被其他帮派控制的领土的地块!
FACTIONCONTIGUOUS: <b>您仅可宣称连到您首块宣称领土的地块!
PEACEFUL: '%s<i> 拥有此领土。您的帮派处于和平状态,故您不可以宣称来自其他帮派的领土。'
PEACEFULTARGET: '%s<i> 拥有此领土,且其处于和平状态,故您不可以宣称来自他们的领土。'
THISISSPARTA: '%s<i> 拥有此领土,且强大到足以保持此领地。'
BORDER: <b>您必须在领地边境才能开始宣称领土。
TOCLAIM: 来宣称此领土
FORCLAIM: 要宣称此领土
CLAIMED: <h>%s<i> 为 <h>%s<i> 宣称了来自 <h>%s<i> 的领土。
CLAIMEDLOG: '%s 在 (%s) 处为帮派 %s 宣称了领土'
GENERIC:
NOPERMISSION: <b>您没有 %1$s 的权限。
DOTHAT: 进行此操作
NOPLAYERMATCH: <b>未找到匹配 "<plugin>%1$s<b>" 的玩家。
NOPLAYERFOUND: <b>无法找到玩家 "<plugin>%1$s<b>"。
ARGS:
TOOFEW: '<b>参数过少。<i>示例用法:'
TOOMANY: '<b>未知参数 "<plugin>%1$s<b>"。<i>示例用法:'
OWNERS: '所有者:%1$s'
PUBLICLAND: 公共帮派领土。
FACTIONLESS: 无帮派
SERVERADMIN: 服务器管理员
DISABLED: 已禁用
ENABLED: 已启用
CONSOLEONLY: 此命令无法作为玩家运行。
PLAYERONLY: <b>此命令只可被游戏内玩家运行。
ASKYOURLEADER: '<i> 询问您的领袖来:'
YOUSHOULD: '<i>您应:'
YOUMAYWANT: '<i>您可能想要:'
TRANSLATION:
VERSION: '翻译:%1$s(%2$s,%3$s) 状态:%4$s'
CONTRIBUTORS: '翻译贡献者:%1$s'
RESPONSIBLE: '翻译负责人:%1$s'
FACTIONTAG:
TOOSHORT: <i>帮派标签不可少于 <h>%1$s<i> 个字符。
TOOLONG: <i>帮派标签不可长于 <h>%s<i> 个字符。
ALPHANUMERIC: <i>帮派标签必须为英文字母,"<h>%s<i>" 不被允许。
COMPASS:
SHORT:
NORTH:
EAST:
SOUTH:
WEST: 西
ACTIONS:
NOPERMISSION: '<b>{faction} 不允许您 {action}</b>'
NOPERMISSIONPAINFUL: '<b>在 {faction} 的领土上尝试 {action} 是徒劳的</b>'
OWNEDTERRITORYDENY: <b>您不可在此领土进行此操作,其被 {owners} 所拥有</b>
OWNEDTERRITORYPAINDENY: <b>在 {owners} 的领土上尝试 {action} 是徒劳的</b>
MUSTBE: '<b>您</b><h>必须为 {role}</h><b>才能 {action}。</b>'
NOSAMEROLE: <b>{role} 无法控制相同等级的成员...</b>
NOFACTION: '您不是任何帮派的成员。'
CHAT:
FACTION: 帮派聊天
ALLIANCE: 盟友聊天
PUBLIC: 公共聊天
RELATION:
MEMBER: 成员
ALLY: 盟友
NEUTRAL: 中立
ENEMY: 敌人
NOPAGES: <i>很抱歉,无页面可用。
INVALIDPAGE: <i>无效页面,页面数必须介于 1 与 %1$d 之间。
title: '&b帮派 &0|&r'
wilderness: '&2荒野'
wilderness-description: ''
warzone: '&4战区'
warzone-description: 估计不是最安全的地方。
safezone: '&6安全区'
safezone-description: 远离 PVP 及怪物。
toggle-sb: 您已设置计分板至 {value}
default-prefix: '{relationcolor}[{faction}] &r'
faction-login: '&e%1$s &9已登录。'
faction-logout: '&e%1$s &9已登出。'
WARMUPS:
NOTIFY:
TELEPORT: '&e您将于 &d%2$d &e秒内传送至 &d%1$s &e。'
ALREADY: '&c您已在准备传送。'
CANCELLED: '&c您已取消了准备传送。'