Compare commits
65 Commits
2.2.4-STAB
...
2.3.1-STAB
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
e55f053e4d | ||
|
|
945edc946e | ||
|
|
8cace99444 | ||
|
|
5d4735859b | ||
|
|
cef153691d | ||
|
|
4dec162d46 | ||
|
|
606e82c890 | ||
|
|
323dce1c4f | ||
|
|
36c8d53a85 | ||
|
|
81bac35b51 | ||
|
|
19f09a6379 | ||
|
|
19ea590e5f | ||
|
|
d6a274ddc5 | ||
|
|
5591048136 | ||
|
|
fe7738fea0 | ||
|
|
3ba6e1f376 | ||
|
|
dfbfbf9981 | ||
|
|
13399c53c5 | ||
|
|
55d6af7195 | ||
|
|
4f675dfd66 | ||
|
|
22957b641b | ||
|
|
0fc3e47289 | ||
|
|
730693aed1 | ||
|
|
61570be012 | ||
|
|
bcc04e6174 | ||
|
|
d30780e06e | ||
|
|
ed73baf5f1 | ||
|
|
94d2035c78 | ||
|
|
8ff8c78a44 | ||
|
|
591dc2172f | ||
|
|
1a4c860c46 | ||
|
|
ad56264c5d | ||
|
|
def1a8b15a | ||
|
|
8b577d360b | ||
|
|
f34ebc73fa | ||
|
|
c86db7ab51 | ||
|
|
070f239948 | ||
|
|
018f08699d | ||
|
|
5542245b2a | ||
|
|
6eb204587d | ||
|
|
ce1eedd7cd | ||
|
|
417cc57aa7 | ||
|
|
57ac2c8c98 | ||
|
|
25515d863e | ||
|
|
2412931122 | ||
|
|
51838df0d7 | ||
|
|
e3e6f5561c | ||
|
|
a54a7aa4fb | ||
|
|
9de773ddae | ||
|
|
9a32cd9501 | ||
|
|
90d39a3974 | ||
|
|
6544513ca7 | ||
|
|
f7619f0685 | ||
|
|
a20c2ec2eb | ||
|
|
028734a42c | ||
|
|
29b9eadd57 | ||
|
|
83a33c2222 | ||
|
|
c274918244 | ||
|
|
57833bee13 | ||
|
|
0a1346f1c2 | ||
|
|
5145ae1714 | ||
|
|
086ec3e145 | ||
|
|
d538502457 | ||
|
|
978782e2fe | ||
|
|
ce1004d318 |
2
.github/ISSUE_TEMPLATE/bug_report.md
vendored
2
.github/ISSUE_TEMPLATE/bug_report.md
vendored
@@ -23,7 +23,7 @@ A clear and concise description of what you expected to happen.
|
|||||||
**Screenshots**
|
**Screenshots**
|
||||||
If applicable, add screenshots to help explain your problem.
|
If applicable, add screenshots to help explain your problem.
|
||||||
|
|
||||||
**Server VErsion (please complete the following information):**
|
**Server Version (please complete the following information):**
|
||||||
- Spigot Version: [e.g. Paperspigot 1.8.8]
|
- Spigot Version: [e.g. Paperspigot 1.8.8]
|
||||||
- Factions Version [use /f version]
|
- Factions Version [use /f version]
|
||||||
- Minecraft Version: [If a bug is dependent on client version]
|
- Minecraft Version: [If a bug is dependent on client version]
|
||||||
|
|||||||
19
README.md
19
README.md
@@ -1,9 +1,8 @@
|
|||||||
# SaberFactions
|
# SaberFactions
|
||||||
|
|
||||||
 [](https://www.codefactor.io/repository/github/driftay/saber-factions)
|
 [](https://www.codefactor.io/repository/github/driftay/saber-factions) [](https://github.com/SaberLLC/Saber-Factions/blob/1.6.x/LICENSE) 
|
||||||
|
|
||||||
SaberFactions is a fork of both FactionsUUID and SavageFactions. Creators of those plugins include DtrShock and ProSavage. Credits to them.
|
SaberFactions is an exotic, performance optmized, and feature rich factions plugin that focuses on not only making the player experience as great as possibly but maintaining this aspect with the cost of NOTHING! We strive to continue development for SaberFactions as the factions community is strongly growing and seeking new players every day.
|
||||||
SaberFactions is the newest, latest and greatest factions plugin designed for the best and most functional factions experience minecraft has seen!
|
|
||||||
|
|
||||||
## Some Exciting Features
|
## Some Exciting Features
|
||||||
Some of our features include the following
|
Some of our features include the following
|
||||||
@@ -14,6 +13,12 @@ Some of our features include the following
|
|||||||
* More F Upgrades - Unbreakable Redstone Upgrade, Members Upgrade, and Power Upgrade.
|
* More F Upgrades - Unbreakable Redstone Upgrade, Members Upgrade, and Power Upgrade.
|
||||||
* Factions Corner - In the corner of a world? No Problem /f corner will claim your entire buffer for you!
|
* Factions Corner - In the corner of a world? No Problem /f corner will claim your entire buffer for you!
|
||||||
* Command Cooldowns - Configurable Command Cooldowns for most "spam" commands. And so Much More to Come!
|
* Command Cooldowns - Configurable Command Cooldowns for most "spam" commands. And so Much More to Come!
|
||||||
|
* Faction Points - A point based currency that can be used for any aspect of factions gameplay!
|
||||||
|
* Faction Shop - A shop that essentially lets players buy in-game items in exchange for faction points!
|
||||||
|
* Faction Discord Integration - A discord intergrated factions bot for each faction to have their own personalized discord bot within their faction!
|
||||||
|
* Faction Audit - A full based logging system (GUI designed) to see every aspect of what happens in your faction!
|
||||||
|
* Factions Check System - An automated check system that alerts players when to check walls/buffers!
|
||||||
|
* Faction Reserves - A system designed to reserve a specific faction name for a specific player!
|
||||||
|
|
||||||
## Dependency With Maven
|
## Dependency With Maven
|
||||||
```
|
```
|
||||||
@@ -25,9 +30,9 @@ Some of our features include the following
|
|||||||
</repositories>
|
</repositories>
|
||||||
|
|
||||||
<dependency>
|
<dependency>
|
||||||
<groupId>com.github.Driftay</groupId>
|
<groupId>com.github.SaberLLC</groupId>
|
||||||
<artifactId>Saber-Factions</artifactId>
|
<artifactId>Saber-Factions</artifactId>
|
||||||
<version>1.4.1</version>
|
<version>2.2.7-STABLE</version>
|
||||||
</dependency>
|
</dependency>
|
||||||
```
|
```
|
||||||
## Moving Forward
|
## Moving Forward
|
||||||
@@ -36,8 +41,8 @@ Moving forward we plan to take all suggestions into consideration, as they come
|
|||||||
We Plan on Releasing the latest and greatest factions/skyblock/prison plugins minecraft has to offer and wont settle for anything less
|
We Plan on Releasing the latest and greatest factions/skyblock/prison plugins minecraft has to offer and wont settle for anything less
|
||||||
|
|
||||||
## Support
|
## Support
|
||||||
Our Discord is Currently In Progress of a Massive Overhaul, but we still encourage our community to join and express any concerns/questions/suggestions they may have
|
Have a problem, question, or concer? We encourage our community to join and express any inquiry you may have
|
||||||
https://Discord.Saber.pw
|
https://discord.saber.pw
|
||||||
|
|
||||||
Look forward to a bright future and a journey with all of you!
|
Look forward to a bright future and a journey with all of you!
|
||||||
|
|
||||||
|
|||||||
12
pom.xml
12
pom.xml
@@ -4,7 +4,7 @@
|
|||||||
|
|
||||||
<groupId>com.massivecraft</groupId>
|
<groupId>com.massivecraft</groupId>
|
||||||
<artifactId>Factions</artifactId>
|
<artifactId>Factions</artifactId>
|
||||||
<version>1.6.9.5-2.2.4-RC</version>
|
<version>1.6.9.5-2.3.1-RC</version>
|
||||||
<packaging>jar</packaging>
|
<packaging>jar</packaging>
|
||||||
|
|
||||||
<name>SaberFactions</name>
|
<name>SaberFactions</name>
|
||||||
@@ -385,6 +385,12 @@
|
|||||||
</exclusion>
|
</exclusion>
|
||||||
</exclusions>
|
</exclusions>
|
||||||
</dependency>
|
</dependency>
|
||||||
|
<dependency>
|
||||||
|
<groupId>com.mojang</groupId>
|
||||||
|
<artifactId>authlib</artifactId>
|
||||||
|
<version>1.5.21</version>
|
||||||
|
<scope>compile</scope>
|
||||||
|
</dependency>
|
||||||
<dependency>
|
<dependency>
|
||||||
<groupId>me.rayzr522</groupId>
|
<groupId>me.rayzr522</groupId>
|
||||||
<artifactId>jsonmessage</artifactId>
|
<artifactId>jsonmessage</artifactId>
|
||||||
@@ -405,6 +411,10 @@
|
|||||||
<name>bintray</name>
|
<name>bintray</name>
|
||||||
<url>http://jcenter.bintray.com</url>
|
<url>http://jcenter.bintray.com</url>
|
||||||
</repository>
|
</repository>
|
||||||
|
<repository>
|
||||||
|
<id>mojang-repo</id>
|
||||||
|
<url>https://libraries.minecraft.net/</url>
|
||||||
|
</repository>
|
||||||
<repository>
|
<repository>
|
||||||
<id>net.coreprotect</id>
|
<id>net.coreprotect</id>
|
||||||
<url>http://maven.playpro.com/</url>
|
<url>http://maven.playpro.com/</url>
|
||||||
|
|||||||
@@ -1,7 +1,6 @@
|
|||||||
package com.massivecraft.factions;
|
package com.massivecraft.factions;
|
||||||
|
|
||||||
import com.google.common.collect.ImmutableMap;
|
import com.google.common.collect.ImmutableMap;
|
||||||
import com.google.common.collect.ImmutableSet;
|
|
||||||
import com.massivecraft.factions.integration.dynmap.DynmapStyle;
|
import com.massivecraft.factions.integration.dynmap.DynmapStyle;
|
||||||
import com.massivecraft.factions.util.XMaterial;
|
import com.massivecraft.factions.util.XMaterial;
|
||||||
import com.massivecraft.factions.zcore.fperms.DefaultPermissions;
|
import com.massivecraft.factions.zcore.fperms.DefaultPermissions;
|
||||||
@@ -99,12 +98,30 @@ public class Conf {
|
|||||||
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;
|
||||||
|
|
||||||
|
|
||||||
|
//Claim Fill
|
||||||
|
public static int maxFillClaimCount = 25;
|
||||||
|
public static int maxFillClaimDistance = 5;
|
||||||
|
|
||||||
public static boolean factionsDrainEnabled = false;
|
public static boolean factionsDrainEnabled = false;
|
||||||
//RESERVE
|
//RESERVE
|
||||||
public static boolean useReserveSystem = true;
|
public static boolean useReserveSystem = true;
|
||||||
//AUDIT
|
//AUDIT
|
||||||
public static boolean useAuditSystem = true;
|
public static boolean useAuditSystem = true;
|
||||||
|
|
||||||
|
//INSPECT
|
||||||
|
public static boolean useInspectSystem = true;
|
||||||
|
|
||||||
|
//GUI's
|
||||||
|
public static boolean useDisbandGUI = true;
|
||||||
|
|
||||||
|
//SEALTH
|
||||||
|
public static boolean useSealthSystem = true;
|
||||||
|
|
||||||
|
//STRIKES
|
||||||
|
public static boolean useStrikeSystem = true;
|
||||||
|
|
||||||
//DISCORD
|
//DISCORD
|
||||||
public static boolean useDiscordSystem = false;
|
public static boolean useDiscordSystem = false;
|
||||||
public static String discordBotToken = "<token here>";
|
public static String discordBotToken = "<token here>";
|
||||||
@@ -256,6 +273,7 @@ public class Conf {
|
|||||||
public static Set<Material> territoryBypassProtectedMaterials = EnumSet.noneOf(Material.class);
|
public static Set<Material> territoryBypassProtectedMaterials = EnumSet.noneOf(Material.class);
|
||||||
// Dependency check
|
// Dependency check
|
||||||
public static boolean dependencyCheck = true;
|
public static boolean dependencyCheck = true;
|
||||||
|
public static boolean enableClickToClaim = true;
|
||||||
|
|
||||||
public static Set<Material> territoryCancelAndAllowItemUseMaterial = new HashSet<>();
|
public static Set<Material> territoryCancelAndAllowItemUseMaterial = new HashSet<>();
|
||||||
public static Set<Material> territoryDenySwitchMaterials = new HashSet<>();
|
public static Set<Material> territoryDenySwitchMaterials = new HashSet<>();
|
||||||
@@ -577,7 +595,9 @@ public class Conf {
|
|||||||
FactionsPlugin.getInstance().persist.save(i);
|
FactionsPlugin.getInstance().persist.save(i);
|
||||||
}
|
}
|
||||||
|
|
||||||
public static void saveSync() { FactionsPlugin.instance.persist.saveSync(i); }
|
public static void saveSync() {
|
||||||
|
FactionsPlugin.instance.persist.saveSync(i);
|
||||||
|
}
|
||||||
|
|
||||||
public enum Backend {
|
public enum Backend {
|
||||||
JSON,
|
JSON,
|
||||||
|
|||||||
@@ -14,6 +14,7 @@ import java.util.Set;
|
|||||||
public class FLocation implements Serializable {
|
public class FLocation implements Serializable {
|
||||||
private static final long serialVersionUID = -8292915234027387983L;
|
private static final long serialVersionUID = -8292915234027387983L;
|
||||||
private static final boolean worldBorderSupport;
|
private static final boolean worldBorderSupport;
|
||||||
|
|
||||||
static {
|
static {
|
||||||
boolean worldBorderClassPresent = false;
|
boolean worldBorderClassPresent = false;
|
||||||
try {
|
try {
|
||||||
@@ -150,7 +151,9 @@ public class FLocation implements Serializable {
|
|||||||
return "" + x + "," + z;
|
return "" + x + "," + z;
|
||||||
}
|
}
|
||||||
|
|
||||||
public String formatXAndZ(String splitter) { return chunkToBlock(this.x) + "x" + splitter + " " + chunkToBlock(this.z) + "z"; }
|
public String formatXAndZ(String splitter) {
|
||||||
|
return chunkToBlock(this.x) + "x" + splitter + " " + chunkToBlock(this.z) + "z";
|
||||||
|
}
|
||||||
|
|
||||||
//----------------------------------------------//
|
//----------------------------------------------//
|
||||||
// Misc Geometry
|
// Misc Geometry
|
||||||
|
|||||||
@@ -31,50 +31,73 @@ public interface FPlayer extends EconomyParticipator {
|
|||||||
|
|
||||||
boolean hasNotificationsEnabled();
|
boolean hasNotificationsEnabled();
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Determine if a player has enemies nearby based on the enemy check task in CmdFly
|
||||||
|
* NOTE: THIS VALUE IS ONLY UPDATED WHEN A USER IS USING FLY
|
||||||
|
*
|
||||||
|
* @return enemiesNearby as a boolean
|
||||||
|
*/
|
||||||
|
boolean hasEnemiesNearby();
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Set if this FPlayer has an enemy nearby
|
||||||
|
*
|
||||||
|
* @param b enemiesNearby
|
||||||
|
*/
|
||||||
|
void setEnemiesNearby(Boolean b);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Get if a player has setup their Discord before
|
* Get if a player has setup their Discord before
|
||||||
|
*
|
||||||
* @return if the player setup Discord as a boolean
|
* @return if the player setup Discord as a boolean
|
||||||
*/
|
*/
|
||||||
boolean discordSetup();
|
boolean discordSetup();
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Get the players Discord user ID
|
* Get the players Discord user ID
|
||||||
|
*
|
||||||
* @return players Discord user ID as a String
|
* @return players Discord user ID as a String
|
||||||
*/
|
*/
|
||||||
String discordUserID();
|
String discordUserID();
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Set the players Boolean defining if the player has setup their Discord
|
* Set the players Boolean defining if the player has setup their Discord
|
||||||
|
*
|
||||||
* @param b Boolean for discordSetup to be defined to
|
* @param b Boolean for discordSetup to be defined to
|
||||||
*/
|
*/
|
||||||
void setDiscordSetup(Boolean b);
|
void setDiscordSetup(Boolean b);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Set the players Discord user ID
|
* Set the players Discord user ID
|
||||||
|
*
|
||||||
* @param s String for their user ID to be set to
|
* @param s String for their user ID to be set to
|
||||||
*/
|
*/
|
||||||
void setDiscordUserID(String s);
|
void setDiscordUserID(String s);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Get the players Discord user (If the player has not setup Discord it will return null!)
|
* Get the players Discord user (If the player has not setup Discord it will return null!)
|
||||||
|
*
|
||||||
* @return User from players set Discord User ID
|
* @return User from players set Discord User ID
|
||||||
*/
|
*/
|
||||||
User discordUser();
|
User discordUser();
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Used to check if this player should be served titles
|
* Used to check if this player should be served titles
|
||||||
|
*
|
||||||
* @return if this FPlayer has titles enabled as a boolean
|
* @return if this FPlayer has titles enabled as a boolean
|
||||||
*/
|
*/
|
||||||
boolean hasTitlesEnabled();
|
boolean hasTitlesEnabled();
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Used to set if player should be served titles
|
* Used to set if player should be served titles
|
||||||
|
*
|
||||||
* @param b Boolean to titlesEnabled to
|
* @param b Boolean to titlesEnabled to
|
||||||
*/
|
*/
|
||||||
void setTitlesEnabled(Boolean b);
|
void setTitlesEnabled(Boolean b);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Used to determine if a player is in their faction's chest
|
* Used to determine if a player is in their faction's chest
|
||||||
|
*
|
||||||
* @return if player is in their faction's as a boolean
|
* @return if player is in their faction's as a boolean
|
||||||
*/
|
*/
|
||||||
boolean isInFactionsChest();
|
boolean isInFactionsChest();
|
||||||
|
|||||||
@@ -247,6 +247,8 @@ public interface Faction extends EconomyParticipator {
|
|||||||
|
|
||||||
void setHome(Location home);
|
void setHome(Location home);
|
||||||
|
|
||||||
|
void deleteHome();
|
||||||
|
|
||||||
long getFoundedDate();
|
long getFoundedDate();
|
||||||
|
|
||||||
void setFoundedDate(long newDate);
|
void setFoundedDate(long newDate);
|
||||||
@@ -441,4 +443,7 @@ public interface Faction extends EconomyParticipator {
|
|||||||
|
|
||||||
void paypalSet(String paypal);
|
void paypalSet(String paypal);
|
||||||
|
|
||||||
|
// -------------------------------
|
||||||
|
// Shields
|
||||||
|
// -------------------------------
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -31,7 +31,6 @@ import com.massivecraft.factions.zcore.MPlugin;
|
|||||||
import com.massivecraft.factions.zcore.fperms.Access;
|
import com.massivecraft.factions.zcore.fperms.Access;
|
||||||
import com.massivecraft.factions.zcore.fperms.Permissable;
|
import com.massivecraft.factions.zcore.fperms.Permissable;
|
||||||
import com.massivecraft.factions.zcore.fperms.PermissableAction;
|
import com.massivecraft.factions.zcore.fperms.PermissableAction;
|
||||||
import com.massivecraft.factions.zcore.fupgrades.FUpgradesGUI;
|
|
||||||
import com.massivecraft.factions.zcore.fupgrades.UpgradesListener;
|
import com.massivecraft.factions.zcore.fupgrades.UpgradesListener;
|
||||||
import com.massivecraft.factions.zcore.util.TextUtil;
|
import com.massivecraft.factions.zcore.util.TextUtil;
|
||||||
import me.lucko.commodore.CommodoreProvider;
|
import me.lucko.commodore.CommodoreProvider;
|
||||||
@@ -70,7 +69,6 @@ public class FactionsPlugin extends MPlugin {
|
|||||||
// Plugins can check this boolean while hooking in have
|
// Plugins can check this boolean while hooking in have
|
||||||
// a green light to use the api.
|
// a green light to use the api.
|
||||||
public static boolean startupFinished = false;
|
public static boolean startupFinished = false;
|
||||||
public static Economy econ = null;
|
|
||||||
public boolean PlaceholderApi;
|
public boolean PlaceholderApi;
|
||||||
// Commands
|
// Commands
|
||||||
public FCmdRoot cmdBase;
|
public FCmdRoot cmdBase;
|
||||||
@@ -80,8 +78,10 @@ public class FactionsPlugin extends MPlugin {
|
|||||||
public boolean mc112 = false;
|
public boolean mc112 = false;
|
||||||
public boolean mc113 = false;
|
public boolean mc113 = false;
|
||||||
public boolean mc114 = false;
|
public boolean mc114 = false;
|
||||||
|
public boolean mc115 = false;
|
||||||
public boolean useNonPacketParticles = false;
|
public boolean useNonPacketParticles = false;
|
||||||
public boolean factionsFlight = false;
|
public boolean factionsFlight = false;
|
||||||
|
public List<String> itemList = getConfig().getStringList("fchest.Items-Not-Allowed");
|
||||||
SkriptAddon skriptAddon;
|
SkriptAddon skriptAddon;
|
||||||
private FactionsPlayerListener factionsPlayerListener;
|
private FactionsPlayerListener factionsPlayerListener;
|
||||||
private boolean locked = false;
|
private boolean locked = false;
|
||||||
@@ -91,7 +91,6 @@ public class FactionsPlugin extends MPlugin {
|
|||||||
private ClipPlaceholderAPIManager clipPlaceholderAPIManager;
|
private ClipPlaceholderAPIManager clipPlaceholderAPIManager;
|
||||||
private boolean mvdwPlaceholderAPIManager = false;
|
private boolean mvdwPlaceholderAPIManager = false;
|
||||||
private Listener[] eventsListener;
|
private Listener[] eventsListener;
|
||||||
public List<String> itemList = getConfig().getStringList("fchest.Items-Not-Allowed");
|
|
||||||
private Worldguard wg;
|
private Worldguard wg;
|
||||||
private FLogManager fLogManager;
|
private FLogManager fLogManager;
|
||||||
private List<ReserveObject> reserveObjects;
|
private List<ReserveObject> reserveObjects;
|
||||||
@@ -124,21 +123,15 @@ public class FactionsPlugin extends MPlugin {
|
|||||||
}
|
}
|
||||||
|
|
||||||
public void playSoundForAll(String sound) {
|
public void playSoundForAll(String sound) {
|
||||||
for (Player pl : Bukkit.getOnlinePlayers()) {
|
for (Player pl : Bukkit.getOnlinePlayers()) playSound(pl, sound);
|
||||||
playSound(pl, sound);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public void playSoundForAll(List<String> sounds) {
|
public void playSoundForAll(List<String> sounds) {
|
||||||
for (Player pl : Bukkit.getOnlinePlayers()) {
|
for (Player pl : Bukkit.getOnlinePlayers()) playSound(pl, sounds);
|
||||||
playSound(pl, sounds);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public void playSound(Player p, List<String> sounds) {
|
public void playSound(Player p, List<String> sounds) {
|
||||||
for (String sound : sounds) {
|
for (String sound : sounds) playSound(p, sound);
|
||||||
playSound(p, sound);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public void playSound(Player p, String sound) {
|
public void playSound(Player p, String sound) {
|
||||||
@@ -172,13 +165,15 @@ public class FactionsPlugin extends MPlugin {
|
|||||||
FactionsPlugin.instance.log("Minecraft Version 1.14 found.");
|
FactionsPlugin.instance.log("Minecraft Version 1.14 found.");
|
||||||
mc114 = true;
|
mc114 = true;
|
||||||
break;
|
break;
|
||||||
|
case 15:
|
||||||
|
FactionsPlugin.instance.log("Minecraft Version 1.15 found.");
|
||||||
|
mc115 = true;
|
||||||
|
break;
|
||||||
}
|
}
|
||||||
migrateFPlayerLeaders();
|
migrateFPlayerLeaders();
|
||||||
log("==== End Setup ====");
|
log("==== End Setup ====");
|
||||||
|
|
||||||
if (!preEnable()) {
|
if (!preEnable()) return;
|
||||||
return;
|
|
||||||
}
|
|
||||||
this.loadSuccessful = false;
|
this.loadSuccessful = false;
|
||||||
|
|
||||||
if (!new File(this.getDataFolder() + "/config.yml").exists()) {
|
if (!new File(this.getDataFolder() + "/config.yml").exists()) {
|
||||||
@@ -191,10 +186,10 @@ public class FactionsPlugin extends MPlugin {
|
|||||||
Conf.load();
|
Conf.load();
|
||||||
fLogManager = new FLogManager();
|
fLogManager = new FLogManager();
|
||||||
//Dependency checks
|
//Dependency checks
|
||||||
if (Conf.dependencyCheck && (!Bukkit.getPluginManager().isPluginEnabled("Vault") && !Bukkit.getPluginManager().isPluginEnabled("Essentials"))) {
|
if (Conf.dependencyCheck && (!Bukkit.getPluginManager().isPluginEnabled("Vault"))) {
|
||||||
divider();
|
divider();
|
||||||
System.out.println("You are missing dependencies!");
|
System.out.println("You are missing dependencies!");
|
||||||
System.out.println("Please verify EssentialsX and Vault are installed!");
|
System.out.println("Please verify and Vault are installed!");
|
||||||
Conf.save();
|
Conf.save();
|
||||||
Bukkit.getPluginManager().disablePlugin(instance);
|
Bukkit.getPluginManager().disablePlugin(instance);
|
||||||
divider();
|
divider();
|
||||||
@@ -203,7 +198,6 @@ public class FactionsPlugin extends MPlugin {
|
|||||||
//Update their config if needed
|
//Update their config if needed
|
||||||
// Updater.updateIfNeeded(getConfig());
|
// Updater.updateIfNeeded(getConfig());
|
||||||
RegisteredServiceProvider<Economy> rsp = FactionsPlugin.this.getServer().getServicesManager().getRegistration(Economy.class);
|
RegisteredServiceProvider<Economy> rsp = FactionsPlugin.this.getServer().getServicesManager().getRegistration(Economy.class);
|
||||||
FactionsPlugin.econ = rsp.getProvider();
|
|
||||||
com.massivecraft.factions.integration.Essentials.setup();
|
com.massivecraft.factions.integration.Essentials.setup();
|
||||||
hookedPlayervaults = setupPlayervaults();
|
hookedPlayervaults = setupPlayervaults();
|
||||||
FPlayers.getInstance().load();
|
FPlayers.getInstance().load();
|
||||||
@@ -216,16 +210,10 @@ public class FactionsPlugin extends MPlugin {
|
|||||||
fPlayer.resetFactionData(false);
|
fPlayer.resetFactionData(false);
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
if (fPlayer.isAlt()) {
|
if (fPlayer.isAlt()) faction.addAltPlayer(fPlayer);
|
||||||
faction.addAltPlayer(fPlayer);
|
else faction.addFPlayer(fPlayer);
|
||||||
} else {
|
|
||||||
faction.addFPlayer(fPlayer);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
if (getConfig().getBoolean("enable-faction-flight", true)) {
|
|
||||||
UtilFly.run();
|
|
||||||
}
|
|
||||||
|
|
||||||
Board.getInstance().load();
|
Board.getInstance().load();
|
||||||
Board.getInstance().clean();
|
Board.getInstance().clean();
|
||||||
@@ -250,9 +238,7 @@ public class FactionsPlugin extends MPlugin {
|
|||||||
log("Minecraft Version 1.9 or higher found, using non packet based particle API");
|
log("Minecraft Version 1.9 or higher found, using non packet based particle API");
|
||||||
}
|
}
|
||||||
|
|
||||||
if (getConfig().getBoolean("enable-faction-flight")) {
|
if (getConfig().getBoolean("enable-faction-flight")) factionsFlight = true;
|
||||||
factionsFlight = true;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (getServer().getPluginManager().getPlugin("Skript") != null) {
|
if (getServer().getPluginManager().getPlugin("Skript") != null) {
|
||||||
log("Skript was found! Registering FactionsPlugin Addon...");
|
log("Skript was found! Registering FactionsPlugin Addon...");
|
||||||
@@ -288,7 +274,6 @@ public class FactionsPlugin extends MPlugin {
|
|||||||
new FactionsEntityListener(),
|
new FactionsEntityListener(),
|
||||||
new FactionsExploitListener(),
|
new FactionsExploitListener(),
|
||||||
new FactionsBlockListener(),
|
new FactionsBlockListener(),
|
||||||
new FUpgradesGUI(),
|
|
||||||
new UpgradesListener(),
|
new UpgradesListener(),
|
||||||
new MissionHandler(this),
|
new MissionHandler(this),
|
||||||
new FChestListener(),
|
new FChestListener(),
|
||||||
@@ -317,14 +302,10 @@ public class FactionsPlugin extends MPlugin {
|
|||||||
json = "[]";
|
json = "[]";
|
||||||
}
|
}
|
||||||
reserveObjects = this.getGsonBuilder().create().fromJson(json, new ListParameterizedType(ReserveObject.class));
|
reserveObjects = this.getGsonBuilder().create().fromJson(json, new ListParameterizedType(ReserveObject.class));
|
||||||
if (reserveObjects == null) {
|
if (reserveObjects == null) reserveObjects = new ArrayList<>();
|
||||||
reserveObjects = new ArrayList<>();
|
} catch (Exception e) {
|
||||||
}
|
|
||||||
}
|
|
||||||
catch (Exception e) {
|
|
||||||
e.printStackTrace();
|
e.printStackTrace();
|
||||||
}
|
}
|
||||||
|
|
||||||
if (getDescription().getFullName().contains("BETA")) {
|
if (getDescription().getFullName().contains("BETA")) {
|
||||||
divider();
|
divider();
|
||||||
System.out.println("You are using a BETA version of the plugin!");
|
System.out.println("You are using a BETA version of the plugin!");
|
||||||
@@ -381,7 +362,6 @@ public class FactionsPlugin extends MPlugin {
|
|||||||
try {
|
try {
|
||||||
BufferedReader br = new BufferedReader(new FileReader(fplayerFile));
|
BufferedReader br = new BufferedReader(new FileReader(fplayerFile));
|
||||||
System.out.println("Migrating old players.json file.");
|
System.out.println("Migrating old players.json file.");
|
||||||
|
|
||||||
String line;
|
String line;
|
||||||
while ((line = br.readLine()) != null) {
|
while ((line = br.readLine()) != null) {
|
||||||
if (line.contains("\"role\": \"ADMIN\"")) {
|
if (line.contains("\"role\": \"ADMIN\"")) {
|
||||||
@@ -413,9 +393,7 @@ public class FactionsPlugin extends MPlugin {
|
|||||||
private boolean setupPermissions() {
|
private boolean setupPermissions() {
|
||||||
try {
|
try {
|
||||||
RegisteredServiceProvider<Permission> rsp = getServer().getServicesManager().getRegistration(Permission.class);
|
RegisteredServiceProvider<Permission> rsp = getServer().getServicesManager().getRegistration(Permission.class);
|
||||||
if (rsp != null) {
|
if (rsp != null) perms = rsp.getProvider();
|
||||||
perms = rsp.getProvider();
|
|
||||||
}
|
|
||||||
} catch (NoClassDefFoundError ex) {
|
} catch (NoClassDefFoundError ex) {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
@@ -452,16 +430,30 @@ public class FactionsPlugin extends MPlugin {
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void onDisable() {
|
public void onDisable() {
|
||||||
// only save data if plugin actually completely loaded successfully
|
try {
|
||||||
if (this.loadSuccessful) {
|
String path = Paths.get(getDataFolder().getAbsolutePath()).toAbsolutePath().toString() + File.separator + "reserves.json";
|
||||||
Conf.saveSync();
|
File file = new File(path);
|
||||||
|
if (!file.exists()) {
|
||||||
|
file.getParentFile().mkdirs();
|
||||||
|
file.createNewFile();
|
||||||
}
|
}
|
||||||
|
Files.write(Paths.get(file.getPath()), getGsonBuilder().create().toJson(reserveObjects).getBytes());
|
||||||
|
} catch (IOException e) {
|
||||||
|
e.printStackTrace();
|
||||||
|
}
|
||||||
|
|
||||||
|
// only save data if plugin actually completely loaded successfully
|
||||||
|
if (this.loadSuccessful) Conf.saveSync();
|
||||||
|
|
||||||
|
|
||||||
if (AutoLeaveTask != null) {
|
if (AutoLeaveTask != null) {
|
||||||
this.getServer().getScheduler().cancelTask(AutoLeaveTask);
|
this.getServer().getScheduler().cancelTask(AutoLeaveTask);
|
||||||
AutoLeaveTask = null;
|
AutoLeaveTask = null;
|
||||||
}
|
}
|
||||||
DiscordListener.saveGuilds();
|
DiscordListener.saveGuilds();
|
||||||
|
if (Discord.jda != null) {
|
||||||
|
Discord.jda.shutdownNow();
|
||||||
|
}
|
||||||
super.onDisable();
|
super.onDisable();
|
||||||
try {
|
try {
|
||||||
fLogManager.saveLogs();
|
fLogManager.saveLogs();
|
||||||
@@ -472,9 +464,7 @@ public class FactionsPlugin extends MPlugin {
|
|||||||
|
|
||||||
public void startAutoLeaveTask(boolean restartIfRunning) {
|
public void startAutoLeaveTask(boolean restartIfRunning) {
|
||||||
if (AutoLeaveTask != null) {
|
if (AutoLeaveTask != null) {
|
||||||
if (!restartIfRunning) {
|
if (!restartIfRunning) return;
|
||||||
return;
|
|
||||||
}
|
|
||||||
this.getServer().getScheduler().cancelTask(AutoLeaveTask);
|
this.getServer().getScheduler().cancelTask(AutoLeaveTask);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -491,7 +481,7 @@ public class FactionsPlugin extends MPlugin {
|
|||||||
}
|
}
|
||||||
|
|
||||||
public ItemStack createItem(Material material, int amount, short datavalue, String name, List<String> lore) {
|
public ItemStack createItem(Material material, int amount, short datavalue, String name, List<String> lore) {
|
||||||
ItemStack item = new ItemStack(XMaterial.matchXMaterial(material.toString()).parseMaterial(), amount, datavalue);
|
ItemStack item = new ItemStack(XMaterial.matchXMaterial(material.toString()).get().parseMaterial(), amount, datavalue);
|
||||||
ItemMeta meta = item.getItemMeta();
|
ItemMeta meta = item.getItemMeta();
|
||||||
meta.setDisplayName(color(name));
|
meta.setDisplayName(color(name));
|
||||||
meta.setLore(colorList(lore));
|
meta.setLore(colorList(lore));
|
||||||
@@ -526,9 +516,7 @@ public class FactionsPlugin extends MPlugin {
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
public boolean onCommand(CommandSender sender, Command command, String label, String[] split) {
|
public boolean onCommand(CommandSender sender, Command command, String label, String[] split) {
|
||||||
if (split.length == 0) {
|
if (split.length == 0) return handleCommand(sender, "/f help", false);
|
||||||
return handleCommand(sender, "/f help", false);
|
|
||||||
}
|
|
||||||
|
|
||||||
// otherwise, needs to be handled; presumably another plugin directly ran the command
|
// otherwise, needs to be handled; presumably another plugin directly ran the command
|
||||||
String cmd = Conf.baseCommandAliases.isEmpty() ? "/f" : "/" + Conf.baseCommandAliases.get(0);
|
String cmd = Conf.baseCommandAliases.isEmpty() ? "/f" : "/" + Conf.baseCommandAliases.get(0);
|
||||||
@@ -541,8 +529,6 @@ public class FactionsPlugin extends MPlugin {
|
|||||||
// Must be a LinkedList to prevent UnsupportedOperationException.
|
// Must be a LinkedList to prevent UnsupportedOperationException.
|
||||||
List<String> argsList = new LinkedList<>(Arrays.asList(args));
|
List<String> argsList = new LinkedList<>(Arrays.asList(args));
|
||||||
CommandContext context = new CommandContext(sender, argsList, alias);
|
CommandContext context = new CommandContext(sender, argsList, alias);
|
||||||
String cmd = Conf.baseCommandAliases.isEmpty() ? "/f" : "/" + Conf.baseCommandAliases.get(0);
|
|
||||||
// String cmdValid = (cmd + " " + TextUtil.implode(context.args, " ")).trim();
|
|
||||||
List<FCommand> commandsList = cmdBase.subCommands;
|
List<FCommand> commandsList = cmdBase.subCommands;
|
||||||
FCommand commandsEx = cmdBase;
|
FCommand commandsEx = cmdBase;
|
||||||
List<String> completions = new ArrayList<>();
|
List<String> completions = new ArrayList<>();
|
||||||
@@ -571,16 +557,12 @@ public class FactionsPlugin extends MPlugin {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
String lastArg = args[args.length - 1].toLowerCase();
|
String lastArg = args[args.length - 1].toLowerCase();
|
||||||
|
|
||||||
completions = completions.stream()
|
completions = completions.stream()
|
||||||
.filter(m -> m.toLowerCase().startsWith(lastArg))
|
.filter(m -> m.toLowerCase().startsWith(lastArg))
|
||||||
.collect(Collectors.toList());
|
.collect(Collectors.toList());
|
||||||
|
|
||||||
return completions;
|
return completions;
|
||||||
|
|
||||||
} else {
|
} else {
|
||||||
String lastArg = args[args.length - 1].toLowerCase();
|
String lastArg = args[args.length - 1].toLowerCase();
|
||||||
|
|
||||||
for (Role value : Role.values()) completions.add(value.nicename);
|
for (Role value : Role.values()) completions.add(value.nicename);
|
||||||
for (Relation value : Relation.values()) completions.add(value.nicename);
|
for (Relation value : Relation.values()) completions.add(value.nicename);
|
||||||
// The stream and foreach from the old implementation looped 2 times, by looping all players -> filtered -> looped filter and added -> filtered AGAIN at the end.
|
// The stream and foreach from the old implementation looped 2 times, by looping all players -> filtered -> looped filter and added -> filtered AGAIN at the end.
|
||||||
@@ -619,11 +601,8 @@ public class FactionsPlugin extends MPlugin {
|
|||||||
// Does player have Faction Chat enabled? If so, chat plugins should preferably not do channels,
|
// Does player have Faction Chat enabled? If so, chat plugins should preferably not do channels,
|
||||||
// local chat, or anything else which targets individual recipients, so Faction Chat can be done
|
// local chat, or anything else which targets individual recipients, so Faction Chat can be done
|
||||||
public boolean isPlayerFactionChatting(Player player) {
|
public boolean isPlayerFactionChatting(Player player) {
|
||||||
if (player == null) {
|
if (player == null) return false;
|
||||||
return false;
|
|
||||||
}
|
|
||||||
FPlayer me = FPlayers.getInstance().getByPlayer(player);
|
FPlayer me = FPlayers.getInstance().getByPlayer(player);
|
||||||
|
|
||||||
return me != null && me.getChatMode().isAtLeast(ChatMode.ALLIANCE);
|
return me != null && me.getChatMode().isAtLeast(ChatMode.ALLIANCE);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -644,15 +623,11 @@ public class FactionsPlugin extends MPlugin {
|
|||||||
public String getPlayerFactionTagRelation(Player speaker, Player listener) {
|
public String getPlayerFactionTagRelation(Player speaker, Player listener) {
|
||||||
String tag = "~";
|
String tag = "~";
|
||||||
|
|
||||||
if (speaker == null) {
|
if (speaker == null) return tag;
|
||||||
return tag;
|
|
||||||
}
|
|
||||||
|
|
||||||
FPlayer me = FPlayers.getInstance().getByPlayer(speaker);
|
FPlayer me = FPlayers.getInstance().getByPlayer(speaker);
|
||||||
if (me == null) {
|
if (me == null) return tag;
|
||||||
return tag;
|
|
||||||
}
|
|
||||||
|
|
||||||
// if listener isn't set, or config option is disabled, give back uncolored tag
|
// if listener isn't set, or config option is disabled, give back uncolored tag
|
||||||
if (listener == null || !Conf.chatTagRelationColored) {
|
if (listener == null || !Conf.chatTagRelationColored) {
|
||||||
tag = me.getChatTag().trim();
|
tag = me.getChatTag().trim();
|
||||||
@@ -660,15 +635,11 @@ public class FactionsPlugin extends MPlugin {
|
|||||||
FPlayer you = FPlayers.getInstance().getByPlayer(listener);
|
FPlayer you = FPlayers.getInstance().getByPlayer(listener);
|
||||||
if (you == null) {
|
if (you == null) {
|
||||||
tag = me.getChatTag().trim();
|
tag = me.getChatTag().trim();
|
||||||
} else // everything checks out, give the colored tag
|
} else { // everything checks out, give the colored tag
|
||||||
{
|
|
||||||
tag = me.getChatTag(you).trim();
|
tag = me.getChatTag(you).trim();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if (tag.isEmpty()) {
|
if (tag.isEmpty()) tag = "~";
|
||||||
tag = "~";
|
|
||||||
}
|
|
||||||
|
|
||||||
return tag;
|
return tag;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -683,15 +654,9 @@ public class FactionsPlugin extends MPlugin {
|
|||||||
|
|
||||||
// Get a player's title within their faction, mainly for usage by chat plugins for local/channel chat
|
// Get a player's title within their faction, mainly for usage by chat plugins for local/channel chat
|
||||||
public String getPlayerTitle(Player player) {
|
public String getPlayerTitle(Player player) {
|
||||||
if (player == null) {
|
if (player == null) return "";
|
||||||
return "";
|
|
||||||
}
|
|
||||||
|
|
||||||
FPlayer me = FPlayers.getInstance().getByPlayer(player);
|
FPlayer me = FPlayers.getInstance().getByPlayer(player);
|
||||||
if (me == null) {
|
if (me == null) return "";
|
||||||
return "";
|
|
||||||
}
|
|
||||||
|
|
||||||
return me.getTitle().trim();
|
return me.getTitle().trim();
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -702,9 +667,7 @@ public class FactionsPlugin extends MPlugin {
|
|||||||
|
|
||||||
//colors a string list
|
//colors a string list
|
||||||
public List<String> colorList(List<String> lore) {
|
public List<String> colorList(List<String> lore) {
|
||||||
for (int i = 0; i <= lore.size() - 1; i++) {
|
for (int i = 0; i <= lore.size() - 1; i++) lore.set(i, color(lore.get(i)));
|
||||||
lore.set(i, color(lore.get(i)));
|
|
||||||
}
|
|
||||||
return lore;
|
return lore;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -722,9 +685,7 @@ public class FactionsPlugin extends MPlugin {
|
|||||||
Set<String> players = new HashSet<>();
|
Set<String> players = new HashSet<>();
|
||||||
Faction faction = Factions.getInstance().getByTag(factionTag);
|
Faction faction = Factions.getInstance().getByTag(factionTag);
|
||||||
if (faction != null) {
|
if (faction != null) {
|
||||||
for (FPlayer fplayer : faction.getFPlayers()) {
|
for (FPlayer fplayer : faction.getFPlayers()) players.add(fplayer.getName());
|
||||||
players.add(fplayer.getName());
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
return players;
|
return players;
|
||||||
}
|
}
|
||||||
@@ -734,9 +695,7 @@ public class FactionsPlugin extends MPlugin {
|
|||||||
Set<String> players = new HashSet<>();
|
Set<String> players = new HashSet<>();
|
||||||
Faction faction = Factions.getInstance().getByTag(factionTag);
|
Faction faction = Factions.getInstance().getByTag(factionTag);
|
||||||
if (faction != null) {
|
if (faction != null) {
|
||||||
for (FPlayer fplayer : faction.getFPlayersWhereOnline(true)) {
|
for (FPlayer fplayer : faction.getFPlayersWhereOnline(true)) players.add(fplayer.getName());
|
||||||
players.add(fplayer.getName());
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
return players;
|
return players;
|
||||||
}
|
}
|
||||||
@@ -756,9 +715,7 @@ public class FactionsPlugin extends MPlugin {
|
|||||||
}
|
}
|
||||||
|
|
||||||
public void debug(Level level, String s) {
|
public void debug(Level level, String s) {
|
||||||
if (getConfig().getBoolean("debug", false)) {
|
if (getConfig().getBoolean("debug", false)) getLogger().log(level, s);
|
||||||
getLogger().log(level, s);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public FactionsPlayerListener getFactionsPlayerListener() {
|
public FactionsPlayerListener getFactionsPlayerListener() {
|
||||||
|
|||||||
@@ -21,8 +21,10 @@ public class Aliases {
|
|||||||
public static ArrayList<String> claim_auto = new ArrayList<>(Collections.singletonList("autoclaim"));
|
public static ArrayList<String> claim_auto = new ArrayList<>(Collections.singletonList("autoclaim"));
|
||||||
public static ArrayList<String> claim_claim = new ArrayList<>(Collections.singletonList("claim"));
|
public static ArrayList<String> claim_claim = new ArrayList<>(Collections.singletonList("claim"));
|
||||||
public static ArrayList<String> claim_at = new ArrayList<>(Collections.singletonList("claimat"));
|
public static ArrayList<String> claim_at = new ArrayList<>(Collections.singletonList("claimat"));
|
||||||
|
public static ArrayList<String> claim_claimFill = new ArrayList<>(Arrays.asList("claimfill", "cf"));
|
||||||
public static ArrayList<String> claim_line = new ArrayList<>(Arrays.asList("claimline", "cl"));
|
public static ArrayList<String> claim_line = new ArrayList<>(Arrays.asList("claimline", "cl"));
|
||||||
public static ArrayList<String> claim_corner = new ArrayList<>(Arrays.asList("corner"));
|
public static ArrayList<String> claim_corner = new ArrayList<>(Arrays.asList("corner"));
|
||||||
|
public static ArrayList<String> delfHome = new ArrayList<>(Arrays.asList("delhome", "deletehome"));
|
||||||
public static ArrayList<String> unclaim_all_safe = new ArrayList<>(Arrays.asList("safeunclaimall", "safedeclaimall"));
|
public static ArrayList<String> unclaim_all_safe = new ArrayList<>(Arrays.asList("safeunclaimall", "safedeclaimall"));
|
||||||
public static ArrayList<String> unclaim_unclaim = new ArrayList<>(Arrays.asList("unclaim", "declaim"));
|
public static ArrayList<String> unclaim_unclaim = new ArrayList<>(Arrays.asList("unclaim", "declaim"));
|
||||||
public static ArrayList<String> unclaim_all_unsafe = new ArrayList<>(Arrays.asList("unclaimall", "declaimall"));
|
public static ArrayList<String> unclaim_all_unsafe = new ArrayList<>(Arrays.asList("unclaimall", "declaimall"));
|
||||||
@@ -46,7 +48,7 @@ public class Aliases {
|
|||||||
public static ArrayList<String> relation_truce = new ArrayList<>(Collections.singletonList("truce"));
|
public static ArrayList<String> relation_truce = new ArrayList<>(Collections.singletonList("truce"));
|
||||||
public static ArrayList<String> reserve = new ArrayList<>(Collections.singletonList("reserve"));
|
public static ArrayList<String> reserve = new ArrayList<>(Collections.singletonList("reserve"));
|
||||||
public static ArrayList<String> roles_demote = new ArrayList<>(Collections.singletonList("demote"));
|
public static ArrayList<String> roles_demote = new ArrayList<>(Collections.singletonList("demote"));
|
||||||
public static ArrayList<String> roles_promote = new ArrayList<>(Collections.singletonList("ally"));
|
public static ArrayList<String> roles_promote = new ArrayList<>(Collections.singletonList("promote"));
|
||||||
public static ArrayList<String> tnt_tnt = new ArrayList<>(Collections.singletonList("tnt"));
|
public static ArrayList<String> tnt_tnt = new ArrayList<>(Collections.singletonList("tnt"));
|
||||||
public static ArrayList<String> tnt_tntfill = new ArrayList<>(Collections.singletonList("tntfill"));
|
public static ArrayList<String> tnt_tntfill = new ArrayList<>(Collections.singletonList("tntfill"));
|
||||||
public static ArrayList<String> wild = new ArrayList<>(Collections.singletonList("wild"));
|
public static ArrayList<String> wild = new ArrayList<>(Collections.singletonList("wild"));
|
||||||
@@ -143,6 +145,7 @@ public class Aliases {
|
|||||||
public static ArrayList<String> vault = new ArrayList<>(Collections.singletonList("vault"));
|
public static ArrayList<String> vault = new ArrayList<>(Collections.singletonList("vault"));
|
||||||
public static ArrayList<String> viewChest = new ArrayList<>(Arrays.asList("viewchest", "viewpv"));
|
public static ArrayList<String> viewChest = new ArrayList<>(Arrays.asList("viewchest", "viewpv"));
|
||||||
private static transient Aliases i = new Aliases();
|
private static transient Aliases i = new Aliases();
|
||||||
|
|
||||||
public static void load() {
|
public static void load() {
|
||||||
FactionsPlugin.getInstance().persist.loadOrSaveDefault(i, Aliases.class, "aliases");
|
FactionsPlugin.getInstance().persist.loadOrSaveDefault(i, Aliases.class, "aliases");
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -70,7 +70,7 @@ public class CmdAdmin extends FCommand {
|
|||||||
|
|
||||||
// if target player is currently admin, demote and replace him
|
// if target player is currently admin, demote and replace him
|
||||||
if (fyou == admin) {
|
if (fyou == admin) {
|
||||||
targetFaction.promoteNewLeader();
|
promoteNewLeader(targetFaction);
|
||||||
context.msg(TL.COMMAND_ADMIN_DEMOTES, fyou.describeTo(context.fPlayer, true));
|
context.msg(TL.COMMAND_ADMIN_DEMOTES, fyou.describeTo(context.fPlayer, true));
|
||||||
fyou.msg(TL.COMMAND_ADMIN_DEMOTED, context.player == null ? TL.GENERIC_SERVERADMIN.toString() : context.fPlayer.describeTo(fyou, true));
|
fyou.msg(TL.COMMAND_ADMIN_DEMOTED, context.player == null ? TL.GENERIC_SERVERADMIN.toString() : context.fPlayer.describeTo(fyou, true));
|
||||||
return;
|
return;
|
||||||
@@ -78,9 +78,9 @@ public class CmdAdmin extends FCommand {
|
|||||||
|
|
||||||
// promote target player, and demote existing admin if one exists
|
// promote target player, and demote existing admin if one exists
|
||||||
if (admin != null) {
|
if (admin != null) {
|
||||||
admin.setRole(Role.COLEADER);
|
setRole(admin, Role.COLEADER);
|
||||||
}
|
}
|
||||||
fyou.setRole(Role.LEADER);
|
setRole(fyou, Role.LEADER);
|
||||||
context.msg(TL.COMMAND_ADMIN_PROMOTES, fyou.describeTo(context.fPlayer, true));
|
context.msg(TL.COMMAND_ADMIN_PROMOTES, fyou.describeTo(context.fPlayer, true));
|
||||||
|
|
||||||
FactionsPlugin.instance.getFlogManager().log(targetFaction, FLogType.RANK_EDIT, context.fPlayer.getName(), fyou.getName(), ChatColor.RED + "Admin");
|
FactionsPlugin.instance.getFlogManager().log(targetFaction, FLogType.RANK_EDIT, context.fPlayer.getName(), fyou.getName(), ChatColor.RED + "Admin");
|
||||||
@@ -94,6 +94,18 @@ public class CmdAdmin extends FCommand {
|
|||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private void setRole(FPlayer fp, Role r) {
|
||||||
|
FactionsPlugin.getInstance().getServer().getScheduler().runTask(FactionsPlugin.instance, () -> {
|
||||||
|
fp.setRole(r);
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
private void promoteNewLeader(Faction f) {
|
||||||
|
FactionsPlugin.getInstance().getServer().getScheduler().runTask(FactionsPlugin.instance, () -> {
|
||||||
|
f.promoteNewLeader();
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
public TL getUsageTranslation() {
|
public TL getUsageTranslation() {
|
||||||
return TL.COMMAND_ADMIN_DESCRIPTION;
|
return TL.COMMAND_ADMIN_DESCRIPTION;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -46,6 +46,7 @@ public class CmdBanner extends FCommand {
|
|||||||
warBanner.setAmount(1);
|
warBanner.setAmount(1);
|
||||||
context.player.getInventory().addItem(warBanner);
|
context.player.getInventory().addItem(warBanner);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Deprecated
|
@Deprecated
|
||||||
public boolean hasMoney(FPlayer fme, int amt) {
|
public boolean hasMoney(FPlayer fme, int amt) {
|
||||||
Economy econ = FactionsPlugin.getInstance().getEcon();
|
Economy econ = FactionsPlugin.getInstance().getEcon();
|
||||||
@@ -55,6 +56,7 @@ public class CmdBanner extends FCommand {
|
|||||||
fme.msg(TL.COMMAND_BANNER_NOTENOUGHMONEY);
|
fme.msg(TL.COMMAND_BANNER_NOTENOUGHMONEY);
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Deprecated
|
@Deprecated
|
||||||
public void takeMoney(FPlayer fme, int amt) {
|
public void takeMoney(FPlayer fme, int amt) {
|
||||||
if (this.hasMoney(fme, amt)) {
|
if (this.hasMoney(fme, amt)) {
|
||||||
|
|||||||
@@ -225,7 +225,7 @@ public class CmdConfig extends FCommand {
|
|||||||
if (!success.isEmpty()) {
|
if (!success.isEmpty()) {
|
||||||
if (context.sender instanceof Player) {
|
if (context.sender instanceof Player) {
|
||||||
context.sendMessage(success);
|
context.sendMessage(success);
|
||||||
FactionsPlugin.getInstance().log(success + TL.COMMAND_CONFIG_LOG.format((Player) context.sender));
|
FactionsPlugin.getInstance().log(success + TL.COMMAND_CONFIG_LOG.format(context.sender));
|
||||||
} else // using FactionsPlugin.getInstance().log() instead of sendMessage if run from server console so that "[Factions v#.#.#]" is prepended in server log
|
} else // using FactionsPlugin.getInstance().log() instead of sendMessage if run from server console so that "[Factions v#.#.#]" is prepended in server log
|
||||||
{
|
{
|
||||||
FactionsPlugin.getInstance().log(success);
|
FactionsPlugin.getInstance().log(success);
|
||||||
|
|||||||
@@ -115,7 +115,9 @@ public class CmdCreate extends FCommand {
|
|||||||
Discord.mainGuild.getController().setNickname(m, Discord.getNicknameString(context.fPlayer)).queue();
|
Discord.mainGuild.getController().setNickname(m, Discord.getNicknameString(context.fPlayer)).queue();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
} catch (HierarchyException e) {System.out.print(e.getMessage());}
|
} catch (HierarchyException e) {
|
||||||
|
System.out.print(e.getMessage());
|
||||||
|
}
|
||||||
//End Discord
|
//End Discord
|
||||||
context.msg(TL.COMMAND_CREATE_YOUSHOULD, FactionsPlugin.getInstance().cmdBase.cmdDescription.getUsageTemplate(context));
|
context.msg(TL.COMMAND_CREATE_YOUSHOULD, FactionsPlugin.getInstance().cmdBase.cmdDescription.getUsageTemplate(context));
|
||||||
if (Conf.econEnabled) Econ.setBalance(faction.getAccountId(), Conf.econFactionStartingBalance);
|
if (Conf.econEnabled) Econ.setBalance(faction.getAccountId(), Conf.econFactionStartingBalance);
|
||||||
|
|||||||
@@ -13,6 +13,7 @@ public class CmdDebug extends FCommand {
|
|||||||
this.aliases.add("debug");
|
this.aliases.add("debug");
|
||||||
this.requirements = new CommandRequirements.Builder(Permission.DEBUG).build();
|
this.requirements = new CommandRequirements.Builder(Permission.DEBUG).build();
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void perform(CommandContext context) {
|
public void perform(CommandContext context) {
|
||||||
FactionsPlugin.getInstance().divider();
|
FactionsPlugin.getInstance().divider();
|
||||||
@@ -51,7 +52,9 @@ public class CmdDebug extends FCommand {
|
|||||||
System.out.print("Emotes enabled: " + Discord.useEmotes);
|
System.out.print("Emotes enabled: " + Discord.useEmotes);
|
||||||
System.out.print("Leader role null: " + (Discord.leader == null ? "True" : "False"));
|
System.out.print("Leader role null: " + (Discord.leader == null ? "True" : "False"));
|
||||||
System.out.print("Attempt Log:");
|
System.out.print("Attempt Log:");
|
||||||
for (DiscordSetupAttempt d : Discord.setupLog) {System.out.print(d.getDifferentialFormatted() + " " + d.getSuccess() + " " + d.getReason());}
|
for (DiscordSetupAttempt d : Discord.setupLog) {
|
||||||
|
System.out.print(d.getDifferentialFormatted() + " " + d.getSuccess() + " " + d.getReason());
|
||||||
|
}
|
||||||
System.out.print("End Attempt Log");
|
System.out.print("End Attempt Log");
|
||||||
System.out.print("----End Discord----");
|
System.out.print("----End Discord----");
|
||||||
System.out.print("--------End Debug Info--------");
|
System.out.print("--------End Debug Info--------");
|
||||||
|
|||||||
51
src/main/java/com/massivecraft/factions/cmd/CmdDelHome.java
Normal file
51
src/main/java/com/massivecraft/factions/cmd/CmdDelHome.java
Normal file
@@ -0,0 +1,51 @@
|
|||||||
|
package com.massivecraft.factions.cmd;
|
||||||
|
|
||||||
|
import com.massivecraft.factions.Conf;
|
||||||
|
import com.massivecraft.factions.FactionsPlugin;
|
||||||
|
import com.massivecraft.factions.struct.Permission;
|
||||||
|
import com.massivecraft.factions.zcore.fperms.PermissableAction;
|
||||||
|
import com.massivecraft.factions.zcore.util.TL;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Factions - Developed by Driftay.
|
||||||
|
* All rights reserved 2020.
|
||||||
|
* Creation Date: 3/24/2020
|
||||||
|
*/
|
||||||
|
public class CmdDelHome extends FCommand {
|
||||||
|
|
||||||
|
public CmdDelHome() {
|
||||||
|
this.aliases.addAll(Aliases.delfHome);
|
||||||
|
|
||||||
|
this.requirements = new CommandRequirements.Builder(Permission.DELHOME)
|
||||||
|
.memberOnly()
|
||||||
|
.withAction(PermissableAction.SETHOME)
|
||||||
|
.build();
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void perform(CommandContext context) {
|
||||||
|
FactionsPlugin.getInstance().getServer().getScheduler().runTaskAsynchronously(FactionsPlugin.instance, () -> {
|
||||||
|
//Check if homes are enabled
|
||||||
|
if (!Conf.homesEnabled) {
|
||||||
|
context.msg(TL.COMMAND_SETHOME_DISABLED);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
//If They Don't Have Home
|
||||||
|
if (!context.faction.hasHome()) {
|
||||||
|
context.msg(TL.COMMAND_HOME_NOHOME.toString());
|
||||||
|
context.msg(FactionsPlugin.getInstance().cmdBase.cmdSethome.getUsageTemplate(context));
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
context.faction.deleteHome();
|
||||||
|
context.faction.msg(TL.COMMAND_DELHOME_SUCCESS, context.fPlayer.describeTo(context.faction, true));
|
||||||
|
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public TL getUsageTranslation() {
|
||||||
|
return TL.COMMAND_DELHOME_DESCRIPTION;
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -4,7 +4,7 @@ import com.massivecraft.factions.*;
|
|||||||
import com.massivecraft.factions.event.FactionDisbandEvent.PlayerDisbandReason;
|
import com.massivecraft.factions.event.FactionDisbandEvent.PlayerDisbandReason;
|
||||||
import com.massivecraft.factions.struct.Permission;
|
import com.massivecraft.factions.struct.Permission;
|
||||||
import com.massivecraft.factions.struct.Role;
|
import com.massivecraft.factions.struct.Role;
|
||||||
import com.massivecraft.factions.util.UtilFly;
|
import com.massivecraft.factions.zcore.fdisband.FDisbandFrame;
|
||||||
import com.massivecraft.factions.zcore.fperms.Access;
|
import com.massivecraft.factions.zcore.fperms.Access;
|
||||||
import com.massivecraft.factions.zcore.fperms.PermissableAction;
|
import com.massivecraft.factions.zcore.fperms.PermissableAction;
|
||||||
import com.massivecraft.factions.zcore.util.TL;
|
import com.massivecraft.factions.zcore.util.TL;
|
||||||
@@ -12,6 +12,7 @@ import org.bukkit.Bukkit;
|
|||||||
import org.bukkit.command.ConsoleCommandSender;
|
import org.bukkit.command.ConsoleCommandSender;
|
||||||
|
|
||||||
import java.util.HashMap;
|
import java.util.HashMap;
|
||||||
|
import java.util.concurrent.TimeUnit;
|
||||||
|
|
||||||
|
|
||||||
public class CmdDisband extends FCommand {
|
public class CmdDisband extends FCommand {
|
||||||
@@ -35,6 +36,7 @@ public class CmdDisband extends FCommand {
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void perform(CommandContext context) {
|
public void perform(CommandContext context) {
|
||||||
|
long time;
|
||||||
// The faction, default to your own.. but null if console sender.
|
// The faction, default to your own.. but null if console sender.
|
||||||
Faction faction = context.argAsFaction(0, context.fPlayer == null ? null : context.faction);
|
Faction faction = context.argAsFaction(0, context.fPlayer == null ? null : context.faction);
|
||||||
if (faction == null) return;
|
if (faction == null) return;
|
||||||
@@ -42,9 +44,7 @@ public class CmdDisband extends FCommand {
|
|||||||
boolean isMyFaction = context.fPlayer != null && faction == context.faction;
|
boolean isMyFaction = context.fPlayer != null && faction == context.faction;
|
||||||
|
|
||||||
if (!isMyFaction) {
|
if (!isMyFaction) {
|
||||||
if (!Permission.DISBAND_ANY.has(context.sender, true)) {
|
if (!Permission.DISBAND_ANY.has(context.sender, true)) return;
|
||||||
return;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@@ -71,6 +71,22 @@ public class CmdDisband extends FCommand {
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
boolean access = false;
|
||||||
|
if (context.fPlayer.getPlayer().hasMetadata("disband_confirm") && (time = context.fPlayer.getPlayer().getMetadata("disband_confirm").get(0).asLong()) != 0L && System.currentTimeMillis() - time <= TimeUnit.SECONDS.toMillis(3L)) {
|
||||||
|
access = true;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (!access) {
|
||||||
|
if (Conf.useDisbandGUI && !context.fPlayer.isAdminBypassing() || !context.player.isOp()) {
|
||||||
|
if (!disbandMap.containsKey(context.player.getUniqueId().toString())) {
|
||||||
|
new FDisbandFrame(context.faction).buildGUI(context.fPlayer);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
// check for tnt before disbanding.
|
// check for tnt before disbanding.
|
||||||
if (!disbandMap.containsKey(context.player.getUniqueId().toString()) && faction.getTnt() > 0) {
|
if (!disbandMap.containsKey(context.player.getUniqueId().toString()) && faction.getTnt() > 0) {
|
||||||
context.msg(TL.COMMAND_DISBAND_CONFIRM.toString().replace("{tnt}", faction.getTnt() + ""));
|
context.msg(TL.COMMAND_DISBAND_CONFIRM.toString().replace("{tnt}", faction.getTnt() + ""));
|
||||||
@@ -82,19 +98,21 @@ public class CmdDisband extends FCommand {
|
|||||||
String amountString = context.sender instanceof ConsoleCommandSender ? TL.GENERIC_SERVERADMIN.toString() : context.fPlayer.describeTo(follower);
|
String amountString = context.sender instanceof ConsoleCommandSender ? TL.GENERIC_SERVERADMIN.toString() : context.fPlayer.describeTo(follower);
|
||||||
if (follower.getFaction() == faction) {
|
if (follower.getFaction() == faction) {
|
||||||
follower.msg(TL.COMMAND_DISBAND_BROADCAST_YOURS, amountString);
|
follower.msg(TL.COMMAND_DISBAND_BROADCAST_YOURS, amountString);
|
||||||
if (!follower.canFlyAtLocation()) {
|
if (!follower.canFlyAtLocation() && FactionsPlugin.getInstance().getConfig().getBoolean("enable-faction-flight")) {
|
||||||
follower.setFFlying(false, false);
|
follower.setFFlying(false, false);
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
follower.msg(TL.COMMAND_DISBAND_BROADCAST_NOTYOURS, amountString, faction.getTag(follower));
|
follower.msg(TL.COMMAND_DISBAND_BROADCAST_NOTYOURS, amountString, faction.getTag(follower));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
if (FactionsPlugin.getInstance().getConfig().getBoolean("enable-faction-flight"))
|
||||||
context.fPlayer.setFFlying(false, false);
|
context.fPlayer.setFFlying(false, false);
|
||||||
} else {
|
} else {
|
||||||
context.player.sendMessage(String.valueOf(TL.COMMAND_DISBAND_PLAYER));
|
context.player.sendMessage(String.valueOf(TL.COMMAND_DISBAND_PLAYER));
|
||||||
}
|
}
|
||||||
|
Bukkit.broadcastMessage("Called");
|
||||||
faction.disband(context.player, PlayerDisbandReason.COMMAND);
|
faction.disband(context.player, PlayerDisbandReason.COMMAND);
|
||||||
if (!context.fPlayer.canFlyAtLocation()) {
|
if (!context.fPlayer.canFlyAtLocation() && FactionsPlugin.getInstance().getConfig().getBoolean("enable-faction-flight")) {
|
||||||
context.fPlayer.setFFlying(false, false);
|
context.fPlayer.setFFlying(false, false);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -14,6 +14,7 @@ public class CmdDiscord extends FCommand {
|
|||||||
.playerOnly()
|
.playerOnly()
|
||||||
.build();
|
.build();
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void perform(CommandContext context) {
|
public void perform(CommandContext context) {
|
||||||
if (context.fPlayer.discordSetup()) {
|
if (context.fPlayer.discordSetup()) {
|
||||||
|
|||||||
@@ -7,7 +7,6 @@ import com.massivecraft.factions.FactionsPlugin;
|
|||||||
import com.massivecraft.factions.struct.Permission;
|
import com.massivecraft.factions.struct.Permission;
|
||||||
import com.massivecraft.factions.zcore.fperms.PermissableAction;
|
import com.massivecraft.factions.zcore.fperms.PermissableAction;
|
||||||
import com.massivecraft.factions.zcore.util.TL;
|
import com.massivecraft.factions.zcore.util.TL;
|
||||||
import org.bukkit.entity.Player;
|
|
||||||
|
|
||||||
import java.text.DecimalFormat;
|
import java.text.DecimalFormat;
|
||||||
|
|
||||||
|
|||||||
@@ -34,7 +34,7 @@ public class CmdFly extends FCommand {
|
|||||||
this.aliases.addAll(Aliases.fly);
|
this.aliases.addAll(Aliases.fly);
|
||||||
this.optionalArgs.put("on/off", "flip");
|
this.optionalArgs.put("on/off", "flip");
|
||||||
|
|
||||||
this.requirements = new CommandRequirements.Builder(Permission.FLY)
|
this.requirements = new CommandRequirements.Builder(Permission.FLY_FLY)
|
||||||
.playerOnly()
|
.playerOnly()
|
||||||
.memberOnly()
|
.memberOnly()
|
||||||
.build();
|
.build();
|
||||||
@@ -78,19 +78,15 @@ public class CmdFly extends FCommand {
|
|||||||
}
|
}
|
||||||
FPlayer fPlayer = FPlayers.getInstance().getByPlayer(player);
|
FPlayer fPlayer = FPlayers.getInstance().getByPlayer(player);
|
||||||
Faction myFaction = fPlayer.getFaction();
|
Faction myFaction = fPlayer.getFaction();
|
||||||
if (myFaction.isWilderness()) {
|
if (!player.hasPermission("factions.fly.bypassnearbyenemycheck") && !fPlayer.isAdminBypassing()) {
|
||||||
fPlayer.setFlying(false);
|
if (fPlayer.hasEnemiesNearby()) disableFlightSync(fPlayer);
|
||||||
flyMap.remove(name);
|
checkEnemiesSync(fPlayer);
|
||||||
continue;
|
|
||||||
}
|
|
||||||
if (player.hasPermission("factions.fly.bypassnearbyenemycheck") || fPlayer.checkIfNearbyEnemies()) {
|
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
FLocation myFloc = new FLocation(player.getLocation());
|
FLocation myFloc = new FLocation(player.getLocation());
|
||||||
if (Board.getInstance().getFactionAt(myFloc) != myFaction) {
|
if (Board.getInstance().getFactionAt(myFloc) != myFaction) {
|
||||||
if (!checkBypassPerms(fPlayer, player, Board.getInstance().getFactionAt(myFloc))) {
|
if (!checkFly(fPlayer, player, Board.getInstance().getFactionAt(myFloc))) {
|
||||||
Bukkit.getScheduler().runTask(FactionsPlugin.instance, () -> fPlayer.setFFlying(false, false));
|
disableFlightSync(fPlayer);
|
||||||
flyMap.remove(name);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -100,37 +96,18 @@ public class CmdFly extends FCommand {
|
|||||||
}, 20L, 20L);
|
}, 20L, 20L);
|
||||||
}
|
}
|
||||||
|
|
||||||
public static boolean checkBypassPerms(FPlayer fme, Player me, Faction toFac) {
|
public static boolean checkFly(FPlayer fme, Player me, Faction toFac) {
|
||||||
if (Conf.denyFlightIfInNoClaimingWorld && !Conf.worldsNoClaiming.isEmpty() && Conf.worldsNoClaiming.stream().anyMatch(me.getWorld().getName()::equalsIgnoreCase))
|
if (Conf.denyFlightIfInNoClaimingWorld && !Conf.worldsNoClaiming.isEmpty() && Conf.worldsNoClaiming.stream().anyMatch(me.getWorld().getName()::equalsIgnoreCase))
|
||||||
return false;
|
return false;
|
||||||
|
if (toFac.getAccess(fme, PermissableAction.FLY) == Access.ALLOW) return true;
|
||||||
if (toFac != fme.getFaction()) {
|
if (fme.getFaction().isWilderness()) return false;
|
||||||
if (!me.hasPermission(Permission.FLY_WILD.node) && toFac.isWilderness() || !me.hasPermission(Permission.FLY_SAFEZONE.node) && toFac.isSafeZone() || !me.hasPermission(Permission.FLY_WARZONE.node) && toFac.isWarZone()) {
|
if (toFac.isSystemFaction())
|
||||||
fme.msg(TL.COMMAND_FLY_NO_ACCESS, toFac.getTag(fme));
|
return me.hasPermission(toFac.isWilderness() ? Permission.FLY_WILDERNESS.node : toFac.isSafeZone() ? Permission.FLY_SAFEZONE.node : Permission.FLY_WARZONE.node);
|
||||||
|
Relation relationTo = toFac.getRelationTo(fme.getFaction());
|
||||||
|
if (!relationTo.isEnemy() && !relationTo.isMember())
|
||||||
|
return me.hasPermission(Permission.valueOf("FLY_" + relationTo.name()).node);
|
||||||
return false;
|
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) {
|
|
||||||
fme.msg(TL.COMMAND_FLY_NO_ACCESS, toFac.getTag(fme));
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
if (!(me.hasPermission(Permission.FLY_ALLY.node) || access == Access.ALLOW) && toFac.getRelationTo(fme.getFaction()) == Relation.ALLY) {
|
|
||||||
fme.msg(TL.COMMAND_FLY_NO_ACCESS, toFac.getTag(fme));
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
if (!(me.hasPermission(Permission.FLY_TRUCE.node) || access == Access.ALLOW) && toFac.getRelationTo(fme.getFaction()) == Relation.TRUCE) {
|
|
||||||
fme.msg(TL.COMMAND_FLY_NO_ACCESS, toFac.getTag(fme));
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (!(me.hasPermission(Permission.FLY_NEUTRAL.node) || access == Access.ALLOW) && toFac.getRelationTo(fme.getFaction()) == Relation.NEUTRAL && !toFac.isSystemFaction()) {
|
|
||||||
fme.msg(TL.COMMAND_FLY_NO_ACCESS, toFac.getTag(fme));
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
return me.hasPermission(Permission.FLY.node) && (access != Access.DENY || toFac.isSystemFaction());
|
|
||||||
}
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
public static void checkTaskState() {
|
public static void checkTaskState() {
|
||||||
@@ -145,21 +122,22 @@ public class CmdFly extends FCommand {
|
|||||||
flyMap.remove(fme.getPlayer().getName());
|
flyMap.remove(fme.getPlayer().getName());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private static void disableFlightSync(FPlayer fme) {
|
||||||
|
Bukkit.getScheduler().runTask(FactionsPlugin.instance, () -> fme.setFFlying(false, false));
|
||||||
|
flyMap.remove(fme.getName());
|
||||||
|
}
|
||||||
|
|
||||||
|
private static void checkEnemiesSync(FPlayer fp) {
|
||||||
|
Bukkit.getScheduler().runTask(FactionsPlugin.instance, fp::checkIfNearbyEnemies);
|
||||||
|
}
|
||||||
|
|
||||||
public boolean isInFlightChecker(Player player) {
|
public boolean isInFlightChecker(Player player) {
|
||||||
return flyMap.containsKey(player.getName());
|
return flyMap.containsKey(player.getName());
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void perform(CommandContext context) {
|
public void perform(CommandContext context) {
|
||||||
// Disabled by default.
|
if (!context.fPlayer.isAdminBypassing()) {
|
||||||
if (!FactionsPlugin.getInstance().getConfig().getBoolean("enable-faction-flight", false)) {
|
|
||||||
context.fPlayer.msg(TL.COMMAND_FLY_DISABLED);
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
FLocation myfloc = new FLocation(context.player.getLocation());
|
|
||||||
Faction toFac = Board.getInstance().getFactionAt(myfloc);
|
|
||||||
if (!checkBypassPerms(context.fPlayer, context.player, toFac)) return;
|
|
||||||
List<Entity> entities = context.player.getNearbyEntities(16.0D, 256.0D, 16.0D);
|
List<Entity> entities = context.player.getNearbyEntities(16.0D, 256.0D, 16.0D);
|
||||||
|
|
||||||
for (int i = 0; i <= entities.size() - 1; ++i) {
|
for (int i = 0; i <= entities.size() - 1; ++i) {
|
||||||
@@ -170,9 +148,17 @@ public class CmdFly extends FCommand {
|
|||||||
context.msg(TL.COMMAND_FLY_CHECK_ENEMY);
|
context.msg(TL.COMMAND_FLY_CHECK_ENEMY);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
context.fPlayer.setEnemiesNearby(false);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
FLocation myfloc = new FLocation(context.player.getLocation());
|
||||||
|
Faction toFac = Board.getInstance().getFactionAt(myfloc);
|
||||||
|
if (!checkFly(context.fPlayer, context.player, toFac)) {
|
||||||
|
context.fPlayer.sendMessage(TL.COMMAND_FLY_NO_ACCESS.format(toFac.getTag()));
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
if (context.args.size() == 0) {
|
if (context.args.size() == 0) {
|
||||||
toggleFlight(context.fPlayer.isFlying(), context.fPlayer, context);
|
toggleFlight(context.fPlayer.isFlying(), context.fPlayer, context);
|
||||||
@@ -188,8 +174,6 @@ public class CmdFly extends FCommand {
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
if (fme.canFlyAtLocation()) {
|
|
||||||
context.doWarmUp(WarmUpUtil.Warmup.FLIGHT, TL.WARMUPS_NOTIFY_FLIGHT, "Fly", () -> {
|
context.doWarmUp(WarmUpUtil.Warmup.FLIGHT, TL.WARMUPS_NOTIFY_FLIGHT, "Fly", () -> {
|
||||||
fme.setFlying(true);
|
fme.setFlying(true);
|
||||||
flyMap.put(fme.getPlayer().getName(), true);
|
flyMap.put(fme.getPlayer().getName(), true);
|
||||||
@@ -201,9 +185,6 @@ public class CmdFly extends FCommand {
|
|||||||
startFlyCheck();
|
startFlyCheck();
|
||||||
}
|
}
|
||||||
}, FactionsPlugin.getInstance().getConfig().getLong("warmups.f-fly", 0));
|
}, FactionsPlugin.getInstance().getConfig().getLong("warmups.f-fly", 0));
|
||||||
} else {
|
|
||||||
fme.msg(TL.COMMAND_FLY_NO_ACCESS, Board.getInstance().getFactionAt(fme.getLastStoodAt()).getTag());
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
|||||||
@@ -47,7 +47,9 @@ public class CmdGetVault extends FCommand {
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!context.fPlayer.takeMoney(amount)) {return;}
|
if (!context.fPlayer.takeMoney(amount)) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
//success :)
|
//success :)
|
||||||
context.player.getInventory().addItem(vault);
|
context.player.getInventory().addItem(vault);
|
||||||
|
|||||||
@@ -18,6 +18,7 @@ public class CmdHelp extends FCommand {
|
|||||||
*/
|
*/
|
||||||
|
|
||||||
public ArrayList<ArrayList<String>> helpPages;
|
public ArrayList<ArrayList<String>> helpPages;
|
||||||
|
|
||||||
//TODO: Add Help GUI
|
//TODO: Add Help GUI
|
||||||
public CmdHelp() {
|
public CmdHelp() {
|
||||||
super();
|
super();
|
||||||
|
|||||||
@@ -1,5 +1,6 @@
|
|||||||
package com.massivecraft.factions.cmd;
|
package com.massivecraft.factions.cmd;
|
||||||
|
|
||||||
|
import com.massivecraft.factions.Conf;
|
||||||
import com.massivecraft.factions.struct.Permission;
|
import com.massivecraft.factions.struct.Permission;
|
||||||
import com.massivecraft.factions.zcore.util.TL;
|
import com.massivecraft.factions.zcore.util.TL;
|
||||||
|
|
||||||
@@ -21,6 +22,11 @@ public class CmdInspect extends FCommand {
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void perform(CommandContext context) {
|
public void perform(CommandContext context) {
|
||||||
|
if (!Conf.useInspectSystem) {
|
||||||
|
context.fPlayer.msg(TL.GENERIC_DISABLED, "Faction Inspection");
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
if (context.fPlayer.isInspectMode()) {
|
if (context.fPlayer.isInspectMode()) {
|
||||||
context.fPlayer.setInspectMode(false);
|
context.fPlayer.setInspectMode(false);
|
||||||
context.msg(TL.COMMAND_INSPECT_DISABLED_MSG);
|
context.msg(TL.COMMAND_INSPECT_DISABLED_MSG);
|
||||||
|
|||||||
@@ -127,6 +127,7 @@ public class CmdJoin extends FCommand {
|
|||||||
}
|
}
|
||||||
|
|
||||||
faction.deinvite(fplayer);
|
faction.deinvite(fplayer);
|
||||||
|
|
||||||
try {
|
try {
|
||||||
context.fPlayer.setRole(faction.getDefaultRole());
|
context.fPlayer.setRole(faction.getDefaultRole());
|
||||||
FactionsPlugin.instance.logFactionEvent(faction, FLogType.INVITES, context.fPlayer.getName(), CC.Green + "joined", "the faction");
|
FactionsPlugin.instance.logFactionEvent(faction, FLogType.INVITES, context.fPlayer.getName(), CC.Green + "joined", "the faction");
|
||||||
@@ -139,7 +140,9 @@ public class CmdJoin extends FCommand {
|
|||||||
Discord.mainGuild.getController().setNickname(m, Discord.getNicknameString(context.fPlayer)).queue();
|
Discord.mainGuild.getController().setNickname(m, Discord.getNicknameString(context.fPlayer)).queue();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
} catch (HierarchyException e) {System.out.print(e.getMessage());}
|
} catch (HierarchyException e) {
|
||||||
|
System.out.print(e.getMessage());
|
||||||
|
}
|
||||||
|
|
||||||
if (Conf.logFactionJoin) {
|
if (Conf.logFactionJoin) {
|
||||||
if (samePlayer) {
|
if (samePlayer) {
|
||||||
@@ -152,7 +155,7 @@ public class CmdJoin extends FCommand {
|
|||||||
|
|
||||||
private int getFactionMemberLimit(Faction f) {
|
private int getFactionMemberLimit(Faction f) {
|
||||||
if (f.getUpgrade(UpgradeType.MEMBERS) == 0) return Conf.factionMemberLimit;
|
if (f.getUpgrade(UpgradeType.MEMBERS) == 0) return Conf.factionMemberLimit;
|
||||||
return Conf.factionMemberLimit + FactionsPlugin.getInstance().getConfig().getInt("fupgrades.MainMenu.Members.Member-Boost.level-" + f.getUpgrade(UpgradeType.MEMBERS));
|
return Conf.factionMemberLimit + FactionsPlugin.getInstance().getConfig().getInt("fupgrades.MainMenu.Members.Members-Limit.level-" + f.getUpgrade(UpgradeType.MEMBERS));
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
|||||||
@@ -1,9 +1,7 @@
|
|||||||
package com.massivecraft.factions.cmd;
|
package com.massivecraft.factions.cmd;
|
||||||
|
|
||||||
import com.massivecraft.factions.Conf;
|
|
||||||
import com.massivecraft.factions.struct.Permission;
|
import com.massivecraft.factions.struct.Permission;
|
||||||
import com.massivecraft.factions.zcore.util.TL;
|
import com.massivecraft.factions.zcore.util.TL;
|
||||||
import org.bukkit.ChatColor;
|
|
||||||
|
|
||||||
public class CmdLeave extends FCommand {
|
public class CmdLeave extends FCommand {
|
||||||
|
|
||||||
|
|||||||
@@ -16,7 +16,6 @@ public class CmdLock extends FCommand {
|
|||||||
description: use the /f lock [on/off] command to temporarily lock the data files from being overwritten
|
description: use the /f lock [on/off] command to temporarily lock the data files from being overwritten
|
||||||
default: op
|
default: op
|
||||||
*/
|
*/
|
||||||
|
|
||||||
public CmdLock() {
|
public CmdLock() {
|
||||||
super();
|
super();
|
||||||
this.aliases.addAll(Aliases.lock);
|
this.aliases.addAll(Aliases.lock);
|
||||||
|
|||||||
@@ -29,7 +29,6 @@ public class CmdPaypalSee extends FCommand {
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
if (context.args.size() == 0) {
|
if (context.args.size() == 0) {
|
||||||
if (context.fPlayer.getFaction().getPaypal() == null) {
|
if (context.fPlayer.getFaction().getPaypal() == null) {
|
||||||
context.msg(TL.COMMAND_PAYPAL_NOTSET);
|
context.msg(TL.COMMAND_PAYPAL_NOTSET);
|
||||||
|
|||||||
@@ -11,11 +11,15 @@ public class CmdPlayerTitleToggle extends FCommand {
|
|||||||
this.requirements = new CommandRequirements.Builder(Permission.TOGGLE_TITLES)
|
this.requirements = new CommandRequirements.Builder(Permission.TOGGLE_TITLES)
|
||||||
.build();
|
.build();
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void perform(CommandContext context) {
|
public void perform(CommandContext context) {
|
||||||
context.fPlayer.setTitlesEnabled(!context.fPlayer.hasTitlesEnabled());
|
context.fPlayer.setTitlesEnabled(!context.fPlayer.hasTitlesEnabled());
|
||||||
context.msg(TL.COMMAND_TITLETOGGLE_TOGGLED, context.fPlayer.hasTitlesEnabled() ? FactionsPlugin.getInstance().color("&dEnabled") : FactionsPlugin.getInstance().color("&dDisabled"));
|
context.msg(TL.COMMAND_TITLETOGGLE_TOGGLED, context.fPlayer.hasTitlesEnabled() ? FactionsPlugin.getInstance().color("&dEnabled") : FactionsPlugin.getInstance().color("&dDisabled"));
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public TL getUsageTranslation() {return TL.COMMAND_TITLETOGGLE_DESCRIPTION;}
|
public TL getUsageTranslation() {
|
||||||
|
return TL.COMMAND_TITLETOGGLE_DESCRIPTION;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -74,8 +74,10 @@ public class CmdSeeChunk extends FCommand {
|
|||||||
for (Object nameObject : seeChunkMap.keySet()) {
|
for (Object nameObject : seeChunkMap.keySet()) {
|
||||||
String name = nameObject + "";
|
String name = nameObject + "";
|
||||||
Player player = Bukkit.getPlayer(name);
|
Player player = Bukkit.getPlayer(name);
|
||||||
|
if (player != null) {
|
||||||
showBorders(player);
|
showBorders(player);
|
||||||
}
|
}
|
||||||
|
}
|
||||||
manageTask();
|
manageTask();
|
||||||
}, 0, interval);
|
}, 0, interval);
|
||||||
}
|
}
|
||||||
@@ -110,24 +112,19 @@ public class CmdSeeChunk extends FCommand {
|
|||||||
private void showPillar(Player player, World world, int blockX, int blockZ) {
|
private void showPillar(Player player, World world, int blockX, int blockZ) {
|
||||||
for (int blockY = 0; blockY < player.getLocation().getBlockY() + 30; blockY++) {
|
for (int blockY = 0; blockY < player.getLocation().getBlockY() + 30; blockY++) {
|
||||||
Location loc = new Location(world, blockX, blockY, blockZ).add(0.5, 0, 0.5);
|
Location loc = new Location(world, blockX, blockY, blockZ).add(0.5, 0, 0.5);
|
||||||
if (loc.getBlock().getType() != Material.AIR) {
|
if (loc.getBlock().getType() != Material.AIR) continue;
|
||||||
continue;
|
|
||||||
}
|
|
||||||
if (useParticles) {
|
if (useParticles) {
|
||||||
if (FactionsPlugin.getInstance().useNonPacketParticles) {
|
if (FactionsPlugin.getInstance().useNonPacketParticles) {
|
||||||
// Dust options only exists in the 1.13 API, so we use an
|
// Dust options only exists in the 1.13 API, so we use an
|
||||||
// alternative method to achieve this in lower versions.
|
// alternative method to achieve this in lower versions.
|
||||||
if (FactionsPlugin.getInstance().mc113 || FactionsPlugin.getInstance().mc114) {
|
if (FactionsPlugin.getInstance().mc113 || FactionsPlugin.getInstance().mc114 || FactionsPlugin.getInstance().mc115) {
|
||||||
player.spawnParticle(Particle.REDSTONE, loc, 0, new Particle.DustOptions(Color.RED, 1));
|
player.spawnParticle(Particle.REDSTONE, loc, 0, new Particle.DustOptions(Color.RED, 1));
|
||||||
} else {
|
} else {
|
||||||
player.getWorld().spawnParticle(Particle.REDSTONE, loc, 0, 255, 0, 0, 1);
|
player.getWorld().spawnParticle(Particle.REDSTONE, loc, 0, 255, 0, 0, 1);
|
||||||
}
|
}
|
||||||
|
|
||||||
} else {
|
} else {
|
||||||
this.effect.display(0, 0, 0, 0, 1, loc, player);
|
this.effect.display(0, 0, 0, 0, 1, loc, player);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
} else {
|
} else {
|
||||||
Material type = blockY % 5 == 0 ? XMaterial.REDSTONE_LAMP.parseMaterial() : XMaterial.BLACK_STAINED_GLASS.parseMaterial();
|
Material type = blockY % 5 == 0 ? XMaterial.REDSTONE_LAMP.parseMaterial() : XMaterial.BLACK_STAINED_GLASS.parseMaterial();
|
||||||
VisualizeUtil.addLocation(player, loc, type);
|
VisualizeUtil.addLocation(player, loc, type);
|
||||||
|
|||||||
@@ -29,7 +29,6 @@ public class CmdSeeDiscord extends FCommand{
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
if (context.args.size() == 0) {
|
if (context.args.size() == 0) {
|
||||||
if (context.fPlayer.getFaction().getDiscord() == null) {
|
if (context.fPlayer.getFaction().getDiscord() == null) {
|
||||||
context.msg(TL.COMMAND_DISCORD_NOTSET);
|
context.msg(TL.COMMAND_DISCORD_NOTSET);
|
||||||
|
|||||||
@@ -2,6 +2,7 @@ package com.massivecraft.factions.cmd;
|
|||||||
|
|
||||||
import com.massivecraft.factions.*;
|
import com.massivecraft.factions.*;
|
||||||
import com.massivecraft.factions.struct.Permission;
|
import com.massivecraft.factions.struct.Permission;
|
||||||
|
import com.massivecraft.factions.zcore.fperms.Access;
|
||||||
import com.massivecraft.factions.zcore.fperms.PermissableAction;
|
import com.massivecraft.factions.zcore.fperms.PermissableAction;
|
||||||
import com.massivecraft.factions.zcore.util.TL;
|
import com.massivecraft.factions.zcore.util.TL;
|
||||||
|
|
||||||
@@ -43,6 +44,16 @@ public class CmdSethome extends FCommand {
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (!context.args.isEmpty()) {
|
||||||
|
Faction target = context.argAsFaction(0);
|
||||||
|
if (target == null) return;
|
||||||
|
context.faction = target;
|
||||||
|
if (target.getAccess(context.fPlayer, PermissableAction.SETHOME) != Access.ALLOW) {
|
||||||
|
context.fPlayer.msg(TL.GENERIC_FPERM_NOPERMISSION, "set faction home");
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
// if economy is enabled, they're not on the bypass list, and this command has a cost set, make 'em pay
|
// if economy is enabled, they're not on the bypass list, and this command has a cost set, make 'em pay
|
||||||
if (!context.payForCommand(Conf.econCostSethome, TL.COMMAND_SETHOME_TOSET, TL.COMMAND_SETHOME_FORSET)) {
|
if (!context.payForCommand(Conf.econCostSethome, TL.COMMAND_SETHOME_TOSET, TL.COMMAND_SETHOME_FORSET)) {
|
||||||
return;
|
return;
|
||||||
|
|||||||
@@ -3,7 +3,6 @@ package com.massivecraft.factions.cmd;
|
|||||||
import com.massivecraft.factions.Conf;
|
import com.massivecraft.factions.Conf;
|
||||||
import com.massivecraft.factions.FPlayer;
|
import com.massivecraft.factions.FPlayer;
|
||||||
import com.massivecraft.factions.FPlayers;
|
import com.massivecraft.factions.FPlayers;
|
||||||
import com.massivecraft.factions.FactionsPlugin;
|
|
||||||
import com.massivecraft.factions.struct.Permission;
|
import com.massivecraft.factions.struct.Permission;
|
||||||
import com.massivecraft.factions.zcore.util.TL;
|
import com.massivecraft.factions.zcore.util.TL;
|
||||||
import mkremins.fanciful.FancyMessage;
|
import mkremins.fanciful.FancyMessage;
|
||||||
|
|||||||
@@ -1,5 +1,6 @@
|
|||||||
package com.massivecraft.factions.cmd;
|
package com.massivecraft.factions.cmd;
|
||||||
|
|
||||||
|
import com.massivecraft.factions.Conf;
|
||||||
import com.massivecraft.factions.struct.Permission;
|
import com.massivecraft.factions.struct.Permission;
|
||||||
import com.massivecraft.factions.zcore.util.TL;
|
import com.massivecraft.factions.zcore.util.TL;
|
||||||
|
|
||||||
@@ -19,6 +20,12 @@ public class CmdStealth extends FCommand {
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void perform(CommandContext context) {
|
public void perform(CommandContext context) {
|
||||||
|
if (!Conf.useSealthSystem) {
|
||||||
|
context.msg(TL.GENERIC_DISABLED, "Factions Stealth");
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
if (context.faction != null && !context.faction.getId().equalsIgnoreCase("0") && !context.faction.getId().equalsIgnoreCase("none") && !context.faction.getId().equalsIgnoreCase("safezone") && !context.faction.getId().equalsIgnoreCase("warzone")) {
|
if (context.faction != null && !context.faction.getId().equalsIgnoreCase("0") && !context.faction.getId().equalsIgnoreCase("none") && !context.faction.getId().equalsIgnoreCase("safezone") && !context.faction.getId().equalsIgnoreCase("warzone")) {
|
||||||
context.fPlayer.setStealth(!context.fPlayer.isStealthEnabled());
|
context.fPlayer.setStealth(!context.fPlayer.isStealthEnabled());
|
||||||
context.msg(context.fPlayer.isStealthEnabled() ? TL.COMMAND_STEALTH_ENABLE : TL.COMMAND_STEALTH_DISABLE);
|
context.msg(context.fPlayer.isStealthEnabled() ? TL.COMMAND_STEALTH_ENABLE : TL.COMMAND_STEALTH_DISABLE);
|
||||||
|
|||||||
@@ -35,6 +35,12 @@ public class CmdStuck extends FCommand {
|
|||||||
final long delay = FactionsPlugin.getInstance().getConfig().getLong("hcf.stuck.delay", 30);
|
final long delay = FactionsPlugin.getInstance().getConfig().getLong("hcf.stuck.delay", 30);
|
||||||
final int radius = FactionsPlugin.getInstance().getConfig().getInt("hcf.stuck.radius", 10);
|
final int radius = FactionsPlugin.getInstance().getConfig().getInt("hcf.stuck.radius", 10);
|
||||||
|
|
||||||
|
if (!FactionsPlugin.getInstance().getConfig().getBoolean("hcf.stuck.Enabled", false)) {
|
||||||
|
context.msg(TL.GENERIC_DISABLED, "Factions Stuck");
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
if (FactionsPlugin.getInstance().getStuckMap().containsKey(player.getUniqueId())) {
|
if (FactionsPlugin.getInstance().getStuckMap().containsKey(player.getUniqueId())) {
|
||||||
long wait = FactionsPlugin.getInstance().getTimers().get(player.getUniqueId()) - System.currentTimeMillis();
|
long wait = FactionsPlugin.getInstance().getTimers().get(player.getUniqueId()) - System.currentTimeMillis();
|
||||||
String time = DurationFormatUtils.formatDuration(wait, TL.COMMAND_STUCK_TIMEFORMAT.toString(), true);
|
String time = DurationFormatUtils.formatDuration(wait, TL.COMMAND_STUCK_TIMEFORMAT.toString(), true);
|
||||||
|
|||||||
@@ -2,7 +2,6 @@ package com.massivecraft.factions.cmd;
|
|||||||
|
|
||||||
import com.massivecraft.factions.FactionsPlugin;
|
import com.massivecraft.factions.FactionsPlugin;
|
||||||
import com.massivecraft.factions.listeners.FactionsBlockListener;
|
import com.massivecraft.factions.listeners.FactionsBlockListener;
|
||||||
import com.massivecraft.factions.listeners.FactionsPlayerListener;
|
|
||||||
import com.massivecraft.factions.struct.Permission;
|
import com.massivecraft.factions.struct.Permission;
|
||||||
import com.massivecraft.factions.util.WarmUpUtil;
|
import com.massivecraft.factions.util.WarmUpUtil;
|
||||||
import com.massivecraft.factions.zcore.util.TL;
|
import com.massivecraft.factions.zcore.util.TL;
|
||||||
|
|||||||
@@ -2,7 +2,7 @@ package com.massivecraft.factions.cmd;
|
|||||||
|
|
||||||
import com.massivecraft.factions.FactionsPlugin;
|
import com.massivecraft.factions.FactionsPlugin;
|
||||||
import com.massivecraft.factions.struct.Permission;
|
import com.massivecraft.factions.struct.Permission;
|
||||||
import com.massivecraft.factions.zcore.fupgrades.FUpgradesGUI;
|
import com.massivecraft.factions.zcore.fupgrades.FUpgradeFrame;
|
||||||
import com.massivecraft.factions.zcore.util.TL;
|
import com.massivecraft.factions.zcore.util.TL;
|
||||||
|
|
||||||
public class CmdUpgrades extends FCommand {
|
public class CmdUpgrades extends FCommand {
|
||||||
@@ -19,7 +19,6 @@ public class CmdUpgrades extends FCommand {
|
|||||||
.playerOnly()
|
.playerOnly()
|
||||||
.memberOnly()
|
.memberOnly()
|
||||||
.build();
|
.build();
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
@@ -28,7 +27,7 @@ public class CmdUpgrades extends FCommand {
|
|||||||
context.fPlayer.msg(TL.COMMAND_UPGRADES_DISABLED);
|
context.fPlayer.msg(TL.COMMAND_UPGRADES_DISABLED);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
new FUpgradesGUI().openMainMenu(context.fPlayer);
|
new FUpgradeFrame(context.faction).buildGUI(context.fPlayer);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
|||||||
@@ -168,6 +168,8 @@ public class FCmdRoot extends FCommand implements CommandExecutor {
|
|||||||
public CmdLookup cmdLookup = new CmdLookup();
|
public CmdLookup cmdLookup = new CmdLookup();
|
||||||
public CmdAudit cmdAudit = new CmdAudit();
|
public CmdAudit cmdAudit = new CmdAudit();
|
||||||
public CmdReserve cmdReserve = new CmdReserve();
|
public CmdReserve cmdReserve = new CmdReserve();
|
||||||
|
public CmdDelHome cmdDelHome = new CmdDelHome();
|
||||||
|
public CmdClaimFill cmdClaimFill = new CmdClaimFill();
|
||||||
//Variables to know if we already setup certain sub commands
|
//Variables to know if we already setup certain sub commands
|
||||||
public Boolean discordEnabled = false;
|
public Boolean discordEnabled = false;
|
||||||
public Boolean checkEnabled = false;
|
public Boolean checkEnabled = false;
|
||||||
@@ -184,6 +186,7 @@ public class FCmdRoot extends FCommand implements CommandExecutor {
|
|||||||
public Boolean internalFTOPEnabled = false;
|
public Boolean internalFTOPEnabled = false;
|
||||||
public Boolean fWildEnabled = false;
|
public Boolean fWildEnabled = false;
|
||||||
public Boolean fAuditEnabled = false;
|
public Boolean fAuditEnabled = false;
|
||||||
|
public Boolean fStrikes = false;
|
||||||
|
|
||||||
public FCmdRoot() {
|
public FCmdRoot() {
|
||||||
super();
|
super();
|
||||||
@@ -212,6 +215,7 @@ public class FCmdRoot extends FCommand implements CommandExecutor {
|
|||||||
this.addSubCommand(this.cmdCreate);
|
this.addSubCommand(this.cmdCreate);
|
||||||
this.addSubCommand(this.cmdDeinvite);
|
this.addSubCommand(this.cmdDeinvite);
|
||||||
this.addSubCommand(this.cmdDescription);
|
this.addSubCommand(this.cmdDescription);
|
||||||
|
this.addSubCommand(this.cmdDelHome);
|
||||||
this.addSubCommand(this.cmdDisband);
|
this.addSubCommand(this.cmdDisband);
|
||||||
this.addSubCommand(this.cmdHelp);
|
this.addSubCommand(this.cmdHelp);
|
||||||
this.addSubCommand(this.cmdHome);
|
this.addSubCommand(this.cmdHome);
|
||||||
@@ -262,13 +266,13 @@ public class FCmdRoot extends FCommand implements CommandExecutor {
|
|||||||
this.addSubCommand(this.cmdDelFWarp);
|
this.addSubCommand(this.cmdDelFWarp);
|
||||||
this.addSubCommand(this.cmdModifyPower);
|
this.addSubCommand(this.cmdModifyPower);
|
||||||
this.addSubCommand(this.cmdLogins);
|
this.addSubCommand(this.cmdLogins);
|
||||||
|
this.addSubCommand(this.cmdClaimFill);
|
||||||
this.addSubCommand(this.cmdClaimLine);
|
this.addSubCommand(this.cmdClaimLine);
|
||||||
this.addSubCommand(this.cmdAHome);
|
this.addSubCommand(this.cmdAHome);
|
||||||
this.addSubCommand(this.cmdPerm);
|
this.addSubCommand(this.cmdPerm);
|
||||||
this.addSubCommand(this.cmdPromote);
|
this.addSubCommand(this.cmdPromote);
|
||||||
this.addSubCommand(this.cmdDebug);
|
this.addSubCommand(this.cmdDebug);
|
||||||
this.addSubCommand(this.cmdDemote);
|
this.addSubCommand(this.cmdDemote);
|
||||||
this.addSubCommand(this.cmdDiscord);
|
|
||||||
this.addSubCommand(this.cmdSetDefaultRole);
|
this.addSubCommand(this.cmdSetDefaultRole);
|
||||||
this.addSubCommand(this.cmdMapHeight);
|
this.addSubCommand(this.cmdMapHeight);
|
||||||
this.addSubCommand(this.cmdClaimAt);
|
this.addSubCommand(this.cmdClaimAt);
|
||||||
@@ -293,7 +297,6 @@ public class FCmdRoot extends FCommand implements CommandExecutor {
|
|||||||
this.addSubCommand(this.cmdChest);
|
this.addSubCommand(this.cmdChest);
|
||||||
this.addSubCommand(this.cmdSetBanner);
|
this.addSubCommand(this.cmdSetBanner);
|
||||||
this.addSubCommand(this.cmdCorner);
|
this.addSubCommand(this.cmdCorner);
|
||||||
this.addSubCommand(this.cmdStrikes);
|
|
||||||
this.addSubCommand(this.cmdFGlobal);
|
this.addSubCommand(this.cmdFGlobal);
|
||||||
this.addSubCommand(this.cmdViewChest);
|
this.addSubCommand(this.cmdViewChest);
|
||||||
this.addSubCommand(this.cmdConvertConfig);
|
this.addSubCommand(this.cmdConvertConfig);
|
||||||
@@ -356,6 +359,11 @@ public class FCmdRoot extends FCommand implements CommandExecutor {
|
|||||||
fAuditEnabled = true;
|
fAuditEnabled = true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (Conf.useStrikeSystem) {
|
||||||
|
this.addSubCommand(this.cmdStrikes);
|
||||||
|
fStrikes = true;
|
||||||
|
}
|
||||||
|
|
||||||
//Other
|
//Other
|
||||||
if (FactionsPlugin.getInstance().getConfig().getBoolean("Wild.Enabled", false) && !fWildEnabled) {
|
if (FactionsPlugin.getInstance().getConfig().getBoolean("Wild.Enabled", false) && !fWildEnabled) {
|
||||||
this.addSubCommand(this.cmdWild);
|
this.addSubCommand(this.cmdWild);
|
||||||
@@ -395,7 +403,9 @@ public class FCmdRoot extends FCommand implements CommandExecutor {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public void rebuild() {if (CommodoreProvider.isSupported()) brigadierManager.build();}
|
public void rebuild() {
|
||||||
|
if (CommodoreProvider.isSupported()) brigadierManager.build();
|
||||||
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void perform(CommandContext context) {
|
public void perform(CommandContext context) {
|
||||||
|
|||||||
@@ -26,6 +26,7 @@ public class CmdAudit extends FCommand {
|
|||||||
.noErrorOnManyArgs()
|
.noErrorOnManyArgs()
|
||||||
.build();
|
.build();
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void perform(CommandContext context) {
|
public void perform(CommandContext context) {
|
||||||
Faction faction = context.args.size() == 1 && context.sender.isOp() ? context.argAsFaction(0) : context.faction;
|
Faction faction = context.args.size() == 1 && context.sender.isOp() ? context.argAsFaction(0) : context.faction;
|
||||||
|
|||||||
@@ -3,6 +3,7 @@ package com.massivecraft.factions.cmd.audit;
|
|||||||
/*
|
/*
|
||||||
@author Saser
|
@author Saser
|
||||||
*/
|
*/
|
||||||
|
|
||||||
import com.google.common.collect.Lists;
|
import com.google.common.collect.Lists;
|
||||||
import com.massivecraft.factions.Faction;
|
import com.massivecraft.factions.Faction;
|
||||||
import com.massivecraft.factions.FactionsPlugin;
|
import com.massivecraft.factions.FactionsPlugin;
|
||||||
|
|||||||
@@ -3,6 +3,7 @@ package com.massivecraft.factions.cmd.audit;
|
|||||||
/**
|
/**
|
||||||
* @author Saser
|
* @author Saser
|
||||||
*/
|
*/
|
||||||
|
|
||||||
import com.massivecraft.factions.FPlayer;
|
import com.massivecraft.factions.FPlayer;
|
||||||
import com.massivecraft.factions.FPlayers;
|
import com.massivecraft.factions.FPlayers;
|
||||||
import com.massivecraft.factions.Faction;
|
import com.massivecraft.factions.Faction;
|
||||||
@@ -45,17 +46,20 @@ public class FChestListener implements Listener {
|
|||||||
Player player = (Player) event.getWhoClicked();
|
Player player = (Player) event.getWhoClicked();
|
||||||
FPlayer fPlayer = FPlayers.getInstance().getByPlayer(player);
|
FPlayer fPlayer = FPlayers.getInstance().getByPlayer(player);
|
||||||
Faction faction;
|
Faction faction;
|
||||||
if(!event.getView().getTitle().equalsIgnoreCase(FactionsPlugin.getInstance().color(FactionsPlugin.getInstance().getConfig().getString("fchest.Inventory-Title")))) return;
|
if (!event.getView().getTitle().equalsIgnoreCase(FactionsPlugin.getInstance().color(FactionsPlugin.getInstance().getConfig().getString("fchest.Inventory-Title"))))
|
||||||
|
return;
|
||||||
if (event.getClick() == ClickType.UNKNOWN) {
|
if (event.getClick() == ClickType.UNKNOWN) {
|
||||||
event.setCancelled(true);
|
event.setCancelled(true);
|
||||||
player.sendMessage(CC.RedB + "(!) " + CC.Red + "You cannot use that click type inside the /f chest!");
|
player.sendMessage(CC.RedB + "(!) " + CC.Red + "You cannot use that click type inside the /f chest!");
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
ItemStack currentItem = event.getCurrentItem();
|
ItemStack currentItem = event.getCurrentItem();
|
||||||
if (event.getClick() == ClickType.NUMBER_KEY) currentItem = event.getClickedInventory().getItem(event.getSlot());
|
if (event.getClick() == ClickType.NUMBER_KEY)
|
||||||
|
currentItem = event.getClickedInventory().getItem(event.getSlot());
|
||||||
Material currentItemType = currentItem != null ? currentItem.getType() : Material.AIR;
|
Material currentItemType = currentItem != null ? currentItem.getType() : Material.AIR;
|
||||||
ItemStack cursorItem = event.getCursor();
|
ItemStack cursorItem = event.getCursor();
|
||||||
if (event.getClick() == ClickType.NUMBER_KEY) cursorItem = player.getInventory().getItem(event.getHotbarButton());
|
if (event.getClick() == ClickType.NUMBER_KEY)
|
||||||
|
cursorItem = player.getInventory().getItem(event.getHotbarButton());
|
||||||
Material cursorItemType = cursorItem != null ? cursorItem.getType() : Material.AIR;
|
Material cursorItemType = cursorItem != null ? cursorItem.getType() : Material.AIR;
|
||||||
if (fPlayer == null || !(faction = fPlayer.getFaction()).isNormal()) {
|
if (fPlayer == null || !(faction = fPlayer.getFaction()).isNormal()) {
|
||||||
player.closeInventory();
|
player.closeInventory();
|
||||||
|
|||||||
@@ -3,6 +3,7 @@ package com.massivecraft.factions.cmd.audit;
|
|||||||
/**
|
/**
|
||||||
* @author Saser
|
* @author Saser
|
||||||
*/
|
*/
|
||||||
|
|
||||||
import com.google.common.reflect.TypeToken;
|
import com.google.common.reflect.TypeToken;
|
||||||
import com.massivecraft.factions.Faction;
|
import com.massivecraft.factions.Faction;
|
||||||
import com.massivecraft.factions.Factions;
|
import com.massivecraft.factions.Factions;
|
||||||
|
|||||||
@@ -27,8 +27,10 @@ public enum FLogType {
|
|||||||
private String msg;
|
private String msg;
|
||||||
private int requiredArgs;
|
private int requiredArgs;
|
||||||
|
|
||||||
public String getDisplayName() {
|
FLogType(String displayName, String msg, int requiredArgs) {
|
||||||
return this.displayName;
|
this.displayName = displayName;
|
||||||
|
this.msg = msg;
|
||||||
|
this.requiredArgs = requiredArgs;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -46,15 +48,22 @@ public enum FLogType {
|
|||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
public String getDisplayName() {
|
||||||
public String toString() { return name(); }
|
return this.displayName;
|
||||||
|
|
||||||
public int getSlot() { return FactionsPlugin.getInstance().getConfig().getInt("faudit-gui.slots." + name().toLowerCase()); }
|
|
||||||
|
|
||||||
public Material getMaterial(){
|
|
||||||
return XMaterial.matchXMaterial(FactionsPlugin.getInstance().getConfig().getString("faudit-gui.materials." + name().toLowerCase())).parseMaterial();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public String toString() {
|
||||||
|
return name();
|
||||||
|
}
|
||||||
|
|
||||||
|
public int getSlot() {
|
||||||
|
return FactionsPlugin.getInstance().getConfig().getInt("faudit-gui.slots." + name().toLowerCase());
|
||||||
|
}
|
||||||
|
|
||||||
|
public Material getMaterial() {
|
||||||
|
return XMaterial.matchXMaterial(FactionsPlugin.getInstance().getConfig().getString("faudit-gui.materials." + name().toLowerCase())).get().parseMaterial();
|
||||||
|
}
|
||||||
|
|
||||||
public String getMsg() {
|
public String getMsg() {
|
||||||
return this.msg;
|
return this.msg;
|
||||||
@@ -63,10 +72,4 @@ public enum FLogType {
|
|||||||
public int getRequiredArgs() {
|
public int getRequiredArgs() {
|
||||||
return this.requiredArgs;
|
return this.requiredArgs;
|
||||||
}
|
}
|
||||||
|
|
||||||
FLogType(String displayName, String msg, int requiredArgs) {
|
|
||||||
this.displayName = displayName;
|
|
||||||
this.msg = msg;
|
|
||||||
this.requiredArgs = requiredArgs;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -3,6 +3,7 @@ package com.massivecraft.factions.cmd.audit;
|
|||||||
/**
|
/**
|
||||||
* @author Saser
|
* @author Saser
|
||||||
*/
|
*/
|
||||||
|
|
||||||
import com.google.common.collect.Lists;
|
import com.google.common.collect.Lists;
|
||||||
import org.bukkit.Bukkit;
|
import org.bukkit.Bukkit;
|
||||||
import org.bukkit.ChatColor;
|
import org.bukkit.ChatColor;
|
||||||
@@ -16,8 +17,8 @@ import java.util.concurrent.ConcurrentHashMap;
|
|||||||
import java.util.concurrent.TimeUnit;
|
import java.util.concurrent.TimeUnit;
|
||||||
|
|
||||||
public class FactionLogs {
|
public class FactionLogs {
|
||||||
private Map<FLogType, LinkedList<FactionLog>> mostRecentLogs = new ConcurrentHashMap<>();
|
|
||||||
public static transient SimpleDateFormat format = new SimpleDateFormat("MM/dd hh:mmaa");
|
public static transient SimpleDateFormat format = new SimpleDateFormat("MM/dd hh:mmaa");
|
||||||
|
private Map<FLogType, LinkedList<FactionLog>> mostRecentLogs = new ConcurrentHashMap<>();
|
||||||
|
|
||||||
public FactionLogs() {
|
public FactionLogs() {
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -3,6 +3,7 @@ package com.massivecraft.factions.cmd.audit;
|
|||||||
/**
|
/**
|
||||||
* @author Saser
|
* @author Saser
|
||||||
*/
|
*/
|
||||||
|
|
||||||
import com.massivecraft.factions.Faction;
|
import com.massivecraft.factions.Faction;
|
||||||
import com.massivecraft.factions.FactionsPlugin;
|
import com.massivecraft.factions.FactionsPlugin;
|
||||||
import org.apache.commons.lang.StringUtils;
|
import org.apache.commons.lang.StringUtils;
|
||||||
@@ -65,11 +66,32 @@ public class LogTimer extends ConcurrentHashMap<LogTimer.TimerType, Map<LogTimer
|
|||||||
return this.username;
|
return this.username;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public enum TimerSubType {
|
||||||
|
SPAWNER_BREAK,
|
||||||
|
SPAWNER_PLACE;
|
||||||
|
|
||||||
|
TimerSubType() {
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public enum TimerType {
|
||||||
|
SPAWNER_EDIT;
|
||||||
|
|
||||||
|
TimerType() {
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
public class Timer {
|
public class Timer {
|
||||||
private long startTime;
|
private long startTime;
|
||||||
private long count;
|
private long count;
|
||||||
private Object extraData;
|
private Object extraData;
|
||||||
|
|
||||||
|
public Timer(long startTime, long count, Object extraData) {
|
||||||
|
this.startTime = startTime;
|
||||||
|
this.count = count;
|
||||||
|
this.extraData = extraData;
|
||||||
|
}
|
||||||
|
|
||||||
LogTimer.Timer increment(long amount) {
|
LogTimer.Timer increment(long amount) {
|
||||||
this.count += amount;
|
this.count += amount;
|
||||||
return this;
|
return this;
|
||||||
@@ -79,47 +101,28 @@ public class LogTimer extends ConcurrentHashMap<LogTimer.TimerType, Map<LogTimer
|
|||||||
return System.currentTimeMillis() - this.startTime >= expiration;
|
return System.currentTimeMillis() - this.startTime >= expiration;
|
||||||
}
|
}
|
||||||
|
|
||||||
public Timer(long startTime, long count, Object extraData) {
|
|
||||||
this.startTime = startTime;
|
|
||||||
this.count = count;
|
|
||||||
this.extraData = extraData;
|
|
||||||
}
|
|
||||||
|
|
||||||
public long getStartTime() {
|
public long getStartTime() {
|
||||||
return this.startTime;
|
return this.startTime;
|
||||||
}
|
}
|
||||||
|
|
||||||
public long getCount() {
|
|
||||||
return this.count;
|
|
||||||
}
|
|
||||||
|
|
||||||
public Object getExtraData() {
|
|
||||||
return this.extraData;
|
|
||||||
}
|
|
||||||
|
|
||||||
public void setStartTime(long startTime) {
|
public void setStartTime(long startTime) {
|
||||||
this.startTime = startTime;
|
this.startTime = startTime;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public long getCount() {
|
||||||
|
return this.count;
|
||||||
|
}
|
||||||
|
|
||||||
public void setCount(long count) {
|
public void setCount(long count) {
|
||||||
this.count = count;
|
this.count = count;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public Object getExtraData() {
|
||||||
|
return this.extraData;
|
||||||
|
}
|
||||||
|
|
||||||
public void setExtraData(Object extraData) {
|
public void setExtraData(Object extraData) {
|
||||||
this.extraData = extraData;
|
this.extraData = extraData;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public enum TimerSubType {
|
|
||||||
SPAWNER_BREAK,
|
|
||||||
SPAWNER_PLACE;
|
|
||||||
TimerSubType() {
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
public enum TimerType {
|
|
||||||
SPAWNER_EDIT;
|
|
||||||
TimerType() {
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -52,19 +52,19 @@ public class CheckSettingsFrame implements InventoryHolder, FactionGUI {
|
|||||||
|
|
||||||
public void build() {
|
public void build() {
|
||||||
Faction faction = fPlayer.getFaction();
|
Faction faction = fPlayer.getFaction();
|
||||||
ItemStack wallsStack = XMaterial.matchXMaterial(FactionsPlugin.getInstance().getConfig().getString("f-check.wall-check.Type")).parseItem();
|
ItemStack wallsStack = XMaterial.matchXMaterial(FactionsPlugin.getInstance().getConfig().getString("f-check.wall-check.Type")).get().parseItem();
|
||||||
ItemMeta wallsMeta = wallsStack.getItemMeta();
|
ItemMeta wallsMeta = wallsStack.getItemMeta();
|
||||||
wallsMeta.setDisplayName(TL.CHECK_WALL_CHECK_GUI_ICON.toString());
|
wallsMeta.setDisplayName(TL.CHECK_WALL_CHECK_GUI_ICON.toString());
|
||||||
wallsMeta.setLore(Collections.singletonList(TL.CHECK_CHECK_LORE_LINE.format(getFormatted(faction.getWallCheckMinutes()))));
|
wallsMeta.setLore(Collections.singletonList(TL.CHECK_CHECK_LORE_LINE.format(getFormatted(faction.getWallCheckMinutes()))));
|
||||||
wallsStack.setItemMeta(wallsMeta);
|
wallsStack.setItemMeta(wallsMeta);
|
||||||
inventory.setItem(FactionsPlugin.getInstance().getConfig().getInt("f-check.wall-check.slot"), wallsStack);
|
inventory.setItem(FactionsPlugin.getInstance().getConfig().getInt("f-check.wall-check.slot"), wallsStack);
|
||||||
ItemStack bufferStack = XMaterial.matchXMaterial(FactionsPlugin.getInstance().getConfig().getString("f-check.buffer-check.Type")).parseItem();
|
ItemStack bufferStack = XMaterial.matchXMaterial(FactionsPlugin.getInstance().getConfig().getString("f-check.buffer-check.Type")).get().parseItem();
|
||||||
ItemMeta bufferMeta = bufferStack.getItemMeta();
|
ItemMeta bufferMeta = bufferStack.getItemMeta();
|
||||||
bufferMeta.setDisplayName(TL.CHECK_BUFFER_CHECK_GUI_ICON.toString());
|
bufferMeta.setDisplayName(TL.CHECK_BUFFER_CHECK_GUI_ICON.toString());
|
||||||
bufferMeta.setLore(Collections.singletonList(TL.CHECK_CHECK_LORE_LINE.format(getFormatted(faction.getBufferCheckMinutes()))));
|
bufferMeta.setLore(Collections.singletonList(TL.CHECK_CHECK_LORE_LINE.format(getFormatted(faction.getBufferCheckMinutes()))));
|
||||||
bufferStack.setItemMeta(bufferMeta);
|
bufferStack.setItemMeta(bufferMeta);
|
||||||
inventory.setItem(FactionsPlugin.getInstance().getConfig().getInt("f-check.buffer-check.slot"), bufferStack);
|
inventory.setItem(FactionsPlugin.getInstance().getConfig().getInt("f-check.buffer-check.slot"), bufferStack);
|
||||||
ItemStack historyStack = XMaterial.matchXMaterial(FactionsPlugin.getInstance().getConfig().getString("f-check.history.Type")).parseItem();
|
ItemStack historyStack = XMaterial.matchXMaterial(FactionsPlugin.getInstance().getConfig().getString("f-check.history.Type")).get().parseItem();
|
||||||
ItemMeta historyMeta = historyStack.getItemMeta();
|
ItemMeta historyMeta = historyStack.getItemMeta();
|
||||||
historyMeta.setDisplayName(TL.CHECK_HISTORY_GUI_ICON.toString());
|
historyMeta.setDisplayName(TL.CHECK_HISTORY_GUI_ICON.toString());
|
||||||
historyStack.setItemMeta(historyMeta);
|
historyStack.setItemMeta(historyMeta);
|
||||||
|
|||||||
@@ -1,7 +1,6 @@
|
|||||||
package com.massivecraft.factions.cmd.claim;
|
package com.massivecraft.factions.cmd.claim;
|
||||||
|
|
||||||
import com.massivecraft.factions.Board;
|
import com.massivecraft.factions.Board;
|
||||||
import com.massivecraft.factions.Conf;
|
|
||||||
import com.massivecraft.factions.FLocation;
|
import com.massivecraft.factions.FLocation;
|
||||||
import com.massivecraft.factions.FactionsPlugin;
|
import com.massivecraft.factions.FactionsPlugin;
|
||||||
import com.massivecraft.factions.cmd.Aliases;
|
import com.massivecraft.factions.cmd.Aliases;
|
||||||
|
|||||||
@@ -0,0 +1,130 @@
|
|||||||
|
package com.massivecraft.factions.cmd.claim;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Created by FactionsUUID Team
|
||||||
|
*/
|
||||||
|
|
||||||
|
import com.massivecraft.factions.Board;
|
||||||
|
import com.massivecraft.factions.Conf;
|
||||||
|
import com.massivecraft.factions.FLocation;
|
||||||
|
import com.massivecraft.factions.Faction;
|
||||||
|
import com.massivecraft.factions.cmd.Aliases;
|
||||||
|
import com.massivecraft.factions.cmd.CommandContext;
|
||||||
|
import com.massivecraft.factions.cmd.CommandRequirements;
|
||||||
|
import com.massivecraft.factions.cmd.FCommand;
|
||||||
|
import com.massivecraft.factions.struct.Permission;
|
||||||
|
import com.massivecraft.factions.zcore.fperms.Access;
|
||||||
|
import com.massivecraft.factions.zcore.fperms.PermissableAction;
|
||||||
|
import com.massivecraft.factions.zcore.util.TL;
|
||||||
|
import org.bukkit.Location;
|
||||||
|
|
||||||
|
import java.util.HashSet;
|
||||||
|
import java.util.LinkedList;
|
||||||
|
import java.util.Queue;
|
||||||
|
import java.util.Set;
|
||||||
|
|
||||||
|
public class CmdClaimFill extends FCommand {
|
||||||
|
|
||||||
|
public CmdClaimFill() {
|
||||||
|
|
||||||
|
// Aliases
|
||||||
|
this.aliases.addAll(Aliases.claim_claimFill);
|
||||||
|
|
||||||
|
// Args
|
||||||
|
this.optionalArgs.put("limit", String.valueOf(Conf.maxFillClaimCount));
|
||||||
|
this.optionalArgs.put("faction", "you");
|
||||||
|
|
||||||
|
this.requirements = new CommandRequirements.Builder(Permission.CLAIM_FILL)
|
||||||
|
.playerOnly()
|
||||||
|
.build();
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void perform(CommandContext context) {
|
||||||
|
// Args
|
||||||
|
final int limit = context.argAsInt(0, Conf.maxFillClaimCount);
|
||||||
|
|
||||||
|
if (limit > Conf.maxFillClaimCount) {
|
||||||
|
context.msg(TL.COMMAND_CLAIMFILL_ABOVEMAX, Conf.maxFillClaimCount);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
final Faction forFaction = context.argAsFaction(2, context.faction);
|
||||||
|
Location location = context.player.getLocation();
|
||||||
|
FLocation loc = new FLocation(location);
|
||||||
|
|
||||||
|
Faction currentFaction = Board.getInstance().getFactionAt(loc);
|
||||||
|
|
||||||
|
if (currentFaction.equals(forFaction)) {
|
||||||
|
context.msg(TL.CLAIM_ALREADYOWN, forFaction.describeTo(context.fPlayer, true));
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (!currentFaction.isWilderness()) {
|
||||||
|
context.msg(TL.COMMAND_CLAIMFILL_ALREADYCLAIMED);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (!context.fPlayer.isAdminBypassing() && forFaction.getAccess(context.fPlayer, PermissableAction.TERRITORY) != Access.ALLOW) {
|
||||||
|
context.msg(TL.CLAIM_CANTCLAIM, forFaction.describeTo(context.fPlayer));
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
final double distance = Conf.maxFillClaimDistance;
|
||||||
|
long startX = loc.getX();
|
||||||
|
long startZ = loc.getZ();
|
||||||
|
|
||||||
|
Set<FLocation> toClaim = new HashSet<>();
|
||||||
|
Queue<FLocation> queue = new LinkedList<>();
|
||||||
|
FLocation currentHead;
|
||||||
|
queue.add(loc);
|
||||||
|
toClaim.add(loc);
|
||||||
|
while (!queue.isEmpty() && toClaim.size() <= limit) {
|
||||||
|
currentHead = queue.poll();
|
||||||
|
|
||||||
|
if (Math.abs(currentHead.getX() - startX) > distance || Math.abs(currentHead.getZ() - startZ) > distance) {
|
||||||
|
context.msg(TL.COMMAND_CLAIMFILL_TOOFAR, distance);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
addIf(toClaim, queue, currentHead.getRelative(0, 1));
|
||||||
|
addIf(toClaim, queue, currentHead.getRelative(0, -1));
|
||||||
|
addIf(toClaim, queue, currentHead.getRelative(1, 0));
|
||||||
|
addIf(toClaim, queue, currentHead.getRelative(-1, 0));
|
||||||
|
}
|
||||||
|
|
||||||
|
if (toClaim.size() > limit) {
|
||||||
|
context.msg(TL.COMMAND_CLAIMFILL_PASTLIMIT);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (toClaim.size() > context.faction.getPowerRounded() - context.faction.getLandRounded()) {
|
||||||
|
context.msg(TL.COMMAND_CLAIMFILL_NOTENOUGHLANDLEFT, forFaction.describeTo(context.fPlayer), toClaim.size());
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
final int limFail = Conf.radiusClaimFailureLimit;
|
||||||
|
int fails = 0;
|
||||||
|
for (FLocation currentLocation : toClaim) {
|
||||||
|
if (!context.fPlayer.attemptClaim(forFaction, currentLocation, true)) {
|
||||||
|
fails++;
|
||||||
|
}
|
||||||
|
if (fails >= limFail) {
|
||||||
|
context.msg(TL.COMMAND_CLAIMFILL_TOOMUCHFAIL, fails);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
private void addIf(Set<FLocation> toClaim, Queue<FLocation> queue, FLocation examine) {
|
||||||
|
if (Board.getInstance().getFactionAt(examine).isWilderness() && !toClaim.contains(examine)) {
|
||||||
|
toClaim.add(examine);
|
||||||
|
queue.add(examine);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public TL getUsageTranslation() {
|
||||||
|
return TL.COMMAND_CLAIMFILL_DESCRIPTION;
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -10,8 +10,6 @@ import com.massivecraft.factions.struct.Permission;
|
|||||||
import com.massivecraft.factions.util.CornerTask;
|
import com.massivecraft.factions.util.CornerTask;
|
||||||
import com.massivecraft.factions.zcore.fperms.PermissableAction;
|
import com.massivecraft.factions.zcore.fperms.PermissableAction;
|
||||||
import com.massivecraft.factions.zcore.util.TL;
|
import com.massivecraft.factions.zcore.util.TL;
|
||||||
import org.bukkit.ChatColor;
|
|
||||||
import org.bukkit.entity.Player;
|
|
||||||
|
|
||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
import java.util.Comparator;
|
import java.util.Comparator;
|
||||||
|
|||||||
@@ -21,7 +21,6 @@ public class CmdUnclaimall extends FCommand {
|
|||||||
*/
|
*/
|
||||||
|
|
||||||
//TODO: Add UnclaimAll Confirmation GUI
|
//TODO: Add UnclaimAll Confirmation GUI
|
||||||
|
|
||||||
public CmdUnclaimall() {
|
public CmdUnclaimall() {
|
||||||
this.aliases.addAll(Aliases.unclaim_all_unsafe);
|
this.aliases.addAll(Aliases.unclaim_all_unsafe);
|
||||||
|
|
||||||
|
|||||||
@@ -40,7 +40,7 @@ public class CmdMoney extends FCommand {
|
|||||||
@Override
|
@Override
|
||||||
public void perform(CommandContext context) {
|
public void perform(CommandContext context) {
|
||||||
if (!Conf.econEnabled || !Conf.bankEnabled) {
|
if (!Conf.econEnabled || !Conf.bankEnabled) {
|
||||||
context.msg(TL.ECON_OFF, "economy option is enabled, please set \'econEnabled\' to true in conf.json");
|
context.msg(TL.ECON_OFF, "economy option is enabled, please set 'econEnabled' to true in conf.json");
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
context.commandChain.add(this);
|
context.commandChain.add(this);
|
||||||
|
|||||||
@@ -8,7 +8,6 @@ import com.massivecraft.factions.cmd.FCommand;
|
|||||||
import com.massivecraft.factions.integration.Econ;
|
import com.massivecraft.factions.integration.Econ;
|
||||||
import com.massivecraft.factions.struct.Permission;
|
import com.massivecraft.factions.struct.Permission;
|
||||||
import com.massivecraft.factions.zcore.util.TL;
|
import com.massivecraft.factions.zcore.util.TL;
|
||||||
import org.bukkit.command.CommandSender;
|
|
||||||
|
|
||||||
public class CmdMoneyBalance extends FCommand {
|
public class CmdMoneyBalance extends FCommand {
|
||||||
|
|
||||||
|
|||||||
@@ -16,7 +16,6 @@ public class CmdGrace extends FCommand {
|
|||||||
*/
|
*/
|
||||||
|
|
||||||
//TODO: Make Timed Format For Grace Period
|
//TODO: Make Timed Format For Grace Period
|
||||||
|
|
||||||
public CmdGrace() {
|
public CmdGrace() {
|
||||||
super();
|
super();
|
||||||
this.aliases.addAll(Aliases.grace);
|
this.aliases.addAll(Aliases.grace);
|
||||||
|
|||||||
@@ -10,14 +10,22 @@ import java.util.ArrayList;
|
|||||||
public class ListParameterizedType implements ParameterizedType {
|
public class ListParameterizedType implements ParameterizedType {
|
||||||
private Type type;
|
private Type type;
|
||||||
|
|
||||||
public ListParameterizedType(Type type) { this.type = type; }
|
public ListParameterizedType(Type type) {
|
||||||
|
this.type = type;
|
||||||
@Override
|
}
|
||||||
public Type[] getActualTypeArguments() { return new Type[] { this.type }; }
|
|
||||||
|
@Override
|
||||||
@Override
|
public Type[] getActualTypeArguments() {
|
||||||
public Type getRawType() { return ArrayList.class; }
|
return new Type[]{this.type};
|
||||||
|
}
|
||||||
@Override
|
|
||||||
public Type getOwnerType() { return null; }
|
@Override
|
||||||
|
public Type getRawType() {
|
||||||
|
return ArrayList.class;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public Type getOwnerType() {
|
||||||
|
return null;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -6,13 +6,16 @@ package com.massivecraft.factions.cmd.reserve;
|
|||||||
public class ReserveObject {
|
public class ReserveObject {
|
||||||
private String name;
|
private String name;
|
||||||
private String factionName;
|
private String factionName;
|
||||||
|
|
||||||
public ReserveObject(String name, String factionName) {
|
public ReserveObject(String name, String factionName) {
|
||||||
this.name = name;
|
this.name = name;
|
||||||
this.factionName = factionName;
|
this.factionName = factionName;
|
||||||
}
|
}
|
||||||
|
|
||||||
public String getName() {
|
public String getName() {
|
||||||
return this.name;
|
return this.name;
|
||||||
}
|
}
|
||||||
|
|
||||||
public String getFactionName() {
|
public String getFactionName() {
|
||||||
return this.factionName;
|
return this.factionName;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -34,6 +34,24 @@ public class CmdTnt extends FCommand {
|
|||||||
.build();
|
.build();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public static void removeItems(Inventory inventory, ItemStack item, int toRemove) {
|
||||||
|
if (toRemove <= 0 || inventory == null || item == null)
|
||||||
|
return;
|
||||||
|
for (int i = 0; i < inventory.getSize(); i++) {
|
||||||
|
ItemStack loopItem = inventory.getItem(i);
|
||||||
|
if (loopItem == null || !item.isSimilar(loopItem))
|
||||||
|
continue;
|
||||||
|
if (toRemove <= 0)
|
||||||
|
return;
|
||||||
|
if (toRemove < loopItem.getAmount()) {
|
||||||
|
loopItem.setAmount(loopItem.getAmount() - toRemove);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
inventory.clear(i);
|
||||||
|
toRemove -= loopItem.getAmount();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void perform(CommandContext context) {
|
public void perform(CommandContext context) {
|
||||||
if (!FactionsPlugin.instance.getConfig().getBoolean("ftnt.Enabled")) {
|
if (!FactionsPlugin.instance.getConfig().getBoolean("ftnt.Enabled")) {
|
||||||
@@ -110,8 +128,10 @@ public class CmdTnt extends FCommand {
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
for (int i = 0; i <= fullStacks - 1; i++) context.player.getInventory().addItem(new ItemStack(XMaterial.TNT.parseMaterial(), 64));
|
for (int i = 0; i <= fullStacks - 1; i++)
|
||||||
if (remainderAmt != 0) context.player.getInventory().addItem(new ItemStack(XMaterial.TNT.parseMaterial(), remainderAmt));
|
context.player.getInventory().addItem(new ItemStack(XMaterial.TNT.parseMaterial(), 64));
|
||||||
|
if (remainderAmt != 0)
|
||||||
|
context.player.getInventory().addItem(new ItemStack(XMaterial.TNT.parseMaterial(), remainderAmt));
|
||||||
|
|
||||||
context.faction.takeTnt(amount);
|
context.faction.takeTnt(amount);
|
||||||
context.player.updateInventory();
|
context.player.updateInventory();
|
||||||
@@ -123,7 +143,9 @@ public class CmdTnt extends FCommand {
|
|||||||
Inventory inv = context.player.getInventory();
|
Inventory inv = context.player.getInventory();
|
||||||
int invTnt = 0;
|
int invTnt = 0;
|
||||||
for (int i = 0; i <= inv.getSize(); i++) {
|
for (int i = 0; i <= inv.getSize(); i++) {
|
||||||
if (inv.getItem(i) == null) { continue; }
|
if (inv.getItem(i) == null) {
|
||||||
|
continue;
|
||||||
|
}
|
||||||
if (inv.getItem(i).getType() == Material.TNT) {
|
if (inv.getItem(i).getType() == Material.TNT) {
|
||||||
invTnt += inv.getItem(i).getAmount();
|
invTnt += inv.getItem(i).getAmount();
|
||||||
}
|
}
|
||||||
@@ -152,7 +174,6 @@ public class CmdTnt extends FCommand {
|
|||||||
context.sendMessage(TL.COMMAND_TNT_AMOUNT.toString().replace("{amount}", context.faction.getTnt() + "").replace("{maxAmount}", context.faction.getTntBankLimit() + ""));
|
context.sendMessage(TL.COMMAND_TNT_AMOUNT.toString().replace("{amount}", context.faction.getTnt() + "").replace("{maxAmount}", context.faction.getTntBankLimit() + ""));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
public boolean inventoryContains(Inventory inventory, ItemStack item) {
|
public boolean inventoryContains(Inventory inventory, ItemStack item) {
|
||||||
int count = 0;
|
int count = 0;
|
||||||
ItemStack[] items = inventory.getContents();
|
ItemStack[] items = inventory.getContents();
|
||||||
@@ -177,24 +198,6 @@ public class CmdTnt extends FCommand {
|
|||||||
return check >= howmany;
|
return check >= howmany;
|
||||||
}
|
}
|
||||||
|
|
||||||
public static void removeItems(Inventory inventory, ItemStack item, int toRemove) {
|
|
||||||
if (toRemove <= 0 || inventory == null || item == null)
|
|
||||||
return;
|
|
||||||
for (int i = 0; i < inventory.getSize(); i++) {
|
|
||||||
ItemStack loopItem = inventory.getItem(i);
|
|
||||||
if (loopItem == null || !item.isSimilar(loopItem))
|
|
||||||
continue;
|
|
||||||
if (toRemove <= 0)
|
|
||||||
return;
|
|
||||||
if (toRemove < loopItem.getAmount()) {
|
|
||||||
loopItem.setAmount(loopItem.getAmount() - toRemove);
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
inventory.clear(i);
|
|
||||||
toRemove -= loopItem.getAmount();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
public void removeFromInventory(Inventory inventory, ItemStack item) {
|
public void removeFromInventory(Inventory inventory, ItemStack item) {
|
||||||
int amt = item.getAmount();
|
int amt = item.getAmount();
|
||||||
ItemStack[] items = inventory.getContents();
|
ItemStack[] items = inventory.getContents();
|
||||||
|
|||||||
@@ -19,14 +19,12 @@ import org.bukkit.inventory.Inventory;
|
|||||||
import org.bukkit.inventory.ItemStack;
|
import org.bukkit.inventory.ItemStack;
|
||||||
import org.bukkit.inventory.PlayerInventory;
|
import org.bukkit.inventory.PlayerInventory;
|
||||||
|
|
||||||
import java.util.*;
|
import java.util.ArrayList;
|
||||||
|
import java.util.HashMap;
|
||||||
|
import java.util.List;
|
||||||
|
|
||||||
public class CmdTntFill extends FCommand {
|
public class CmdTntFill extends FCommand {
|
||||||
|
|
||||||
/**
|
|
||||||
* @author Illyria Team
|
|
||||||
*/
|
|
||||||
|
|
||||||
public CmdTntFill() {
|
public CmdTntFill() {
|
||||||
super();
|
super();
|
||||||
this.aliases.addAll(Aliases.tnt_tntfill);
|
this.aliases.addAll(Aliases.tnt_tntfill);
|
||||||
@@ -41,6 +39,24 @@ public class CmdTntFill extends FCommand {
|
|||||||
.build();
|
.build();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public static void removeItems(Inventory inventory, ItemStack item, int toRemove) {
|
||||||
|
if (toRemove <= 0 || inventory == null || item == null)
|
||||||
|
return;
|
||||||
|
for (int i = 0; i < inventory.getSize(); i++) {
|
||||||
|
ItemStack loopItem = inventory.getItem(i);
|
||||||
|
if (loopItem == null || !item.isSimilar(loopItem))
|
||||||
|
continue;
|
||||||
|
if (toRemove <= 0)
|
||||||
|
return;
|
||||||
|
if (toRemove < loopItem.getAmount()) {
|
||||||
|
loopItem.setAmount(loopItem.getAmount() - toRemove);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
inventory.clear(i);
|
||||||
|
toRemove -= loopItem.getAmount();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void perform(CommandContext context) {
|
public void perform(CommandContext context) {
|
||||||
if (!FactionsPlugin.instance.getConfig().getBoolean("Tntfill.enabled")) {
|
if (!FactionsPlugin.instance.getConfig().getBoolean("Tntfill.enabled")) {
|
||||||
@@ -61,16 +77,17 @@ public class CmdTntFill extends FCommand {
|
|||||||
int radius = context.argAsInt(0, 0); // We don't know the max yet, so let's not assume.
|
int radius = context.argAsInt(0, 0); // We don't know the max yet, so let's not assume.
|
||||||
int amount = context.argAsInt(1, 0); // We don't know the max yet, so let's not assume.
|
int amount = context.argAsInt(1, 0); // We don't know the max yet, so let's not assume.
|
||||||
|
|
||||||
if (amount < 0) {
|
if (amount <= 0 || radius <= 0) {
|
||||||
context.msg(TL.COMMAND_TNT_POSITIVE);
|
context.msg(TL.COMMAND_TNT_POSITIVE);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
if (radius > FactionsPlugin.instance.getConfig().getInt("Tntfill.max-radius")) {
|
|
||||||
context.msg(TL.COMMAND_TNTFILL_RADIUSMAX.toString().replace("{max}", FactionsPlugin.instance.getConfig().getInt("Tntfill.max-radius") + ""));
|
if (radius > FactionsPlugin.getInstance().getConfig().getInt("Tntfill.max-radius")) {
|
||||||
|
context.msg(TL.COMMAND_TNTFILL_RADIUSMAX.toString().replace("{max}", FactionsPlugin.getInstance().getConfig().getInt("Tntfill.max-radius") + ""));
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
if (amount > FactionsPlugin.instance.getConfig().getInt("Tntfill.max-amount")) {
|
if (amount > FactionsPlugin.getInstance().getConfig().getInt("Tntfill.max-amount")) {
|
||||||
context.msg(TL.COMMAND_TNTFILL_AMOUNTMAX.toString().replace("{max}", FactionsPlugin.instance.getConfig().getInt("Tntfill.max-amount") + ""));
|
context.msg(TL.COMMAND_TNTFILL_AMOUNTMAX.toString().replace("{max}", FactionsPlugin.getInstance().getConfig().getInt("Tntfill.max-amount") + ""));
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -88,103 +105,64 @@ public class CmdTntFill extends FCommand {
|
|||||||
if (block == null) continue;
|
if (block == null) continue;
|
||||||
BlockState blockState = block.getState();
|
BlockState blockState = block.getState();
|
||||||
if (!(blockState instanceof Dispenser)) continue;
|
if (!(blockState instanceof Dispenser)) continue;
|
||||||
|
Dispenser dis = (Dispenser) blockState;
|
||||||
|
// skip if we can't add anything
|
||||||
|
if (isInvFull(dis.getInventory())) continue;
|
||||||
opDispensers.add((Dispenser) blockState);
|
opDispensers.add((Dispenser) blockState);
|
||||||
}
|
}
|
||||||
if (opDispensers.isEmpty()) {
|
if (opDispensers.isEmpty()) {
|
||||||
context.fPlayer.msg(TL.COMMAND_TNTFILL_NODISPENSERS.toString().replace("{radius}", radius + ""));
|
context.fPlayer.msg(TL.COMMAND_TNTFILL_NODISPENSERS.toString().replace("{radius}", radius + ""));
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
// What's the required amount of resources
|
|
||||||
int requiredTnt = (opDispensers.size() * amount);
|
int requiredTnt = (opDispensers.size() * amount);
|
||||||
|
int playerTnt = getTNTInside(context.player);
|
||||||
// Do I have enough tnt in my inventory?
|
// if player does not have enough tnt, just take whatever he has and add it to the bank
|
||||||
int playerTnt = inventoryItemCount(context.player.getInventory(), Material.TNT);
|
// then use the bank as source. If bank < required abort.
|
||||||
if (playerTnt < requiredTnt) {
|
if (playerTnt < requiredTnt) {
|
||||||
// How much TNT will I take from bank?
|
|
||||||
int getFactionTnt = requiredTnt - playerTnt;
|
|
||||||
|
|
||||||
// Do I have enough tnt in bank?
|
// Do I have enough tnt in bank?
|
||||||
if ((context.faction.getTnt() < getFactionTnt)) {
|
if ((context.faction.getTnt() < (requiredTnt - playerTnt))) {
|
||||||
context.fPlayer.msg(TL.COMMAND_TNT_WIDTHDRAW_NOTENOUGH_TNT.toString());
|
context.fPlayer.msg(TL.COMMAND_TNT_WIDTHDRAW_NOTENOUGH_TNT.toString());
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
// move whatever tnt you have to the bank, ignoring limit because its gonna be taken out later anyways
|
||||||
// Take TNT from the bank.
|
context.faction.addTnt(playerTnt);
|
||||||
context.faction.takeTnt(getFactionTnt);
|
removeItems(context.fPlayer.getPlayer().getInventory(), new ItemStack(Material.TNT), playerTnt);
|
||||||
}
|
// Take TNT from the bank
|
||||||
|
fillDispensers(context, opDispensers, amount);
|
||||||
|
} else {
|
||||||
|
// Take TNT from the player
|
||||||
fillDispensers(context.fPlayer, opDispensers, amount);
|
fillDispensers(context.fPlayer, opDispensers, amount);
|
||||||
// Remove used TNT from player inventory.
|
}
|
||||||
context.sendMessage(TL.COMMAND_TNTFILL_SUCCESS.toString().replace("{amount}", requiredTnt + "").replace("{dispensers}", opDispensers.size() + ""));
|
context.sendMessage(TL.COMMAND_TNTFILL_SUCCESS.toString().replace("{amount}", requiredTnt + "").replace("{dispensers}", opDispensers.size() + ""));
|
||||||
}
|
}
|
||||||
|
|
||||||
// Actually fill every dispenser with the precise amount.
|
// Actually fill every dispenser with the precise amount.
|
||||||
private void fillDispensers(FPlayer fPlayer, List<Dispenser> dispensers, int count) {
|
private void fillDispensers(FPlayer fPlayer, List<Dispenser> dispensers, int count) {
|
||||||
for (Dispenser dispenser : dispensers) {
|
for (Dispenser dispenser : dispensers) {
|
||||||
if (takeTnt(fPlayer, count)) {
|
int canBeAdded = getAddable(dispenser.getInventory(), Material.TNT);
|
||||||
dispenser.getInventory().addItem(new ItemStack(Material.TNT, count));
|
if (canBeAdded <= 0) continue;
|
||||||
} else {return;}
|
int toAdd = Math.min(canBeAdded, count);
|
||||||
|
if (toAdd > getTNTInside(fPlayer.getPlayer())) {
|
||||||
|
fPlayer.msg(TL.COMMAND_TNTFILL_NOTENOUGH.toString());
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
removeItems(fPlayer.getPlayer().getInventory(), new ItemStack(Material.TNT), toAdd);
|
||||||
|
dispenser.getInventory().addItem(new ItemStack(Material.TNT, toAdd));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private void removeFromBank(CommandContext context, int amount) {
|
private void fillDispensers(CommandContext context, List<Dispenser> dispensers, int count) {
|
||||||
try {
|
for (Dispenser dispenser : dispensers) {
|
||||||
Integer.parseInt(context.args.get(1));
|
int canBeAdded = getAddable(dispenser.getInventory(), Material.TNT);
|
||||||
} catch (NumberFormatException e) {
|
if (canBeAdded <= 0) continue;
|
||||||
context.fPlayer.msg(TL.COMMAND_TNT_INVALID_NUM.toString());
|
int toAdd = Math.min(canBeAdded, count);
|
||||||
return;
|
if (context.faction.getTnt() < toAdd) {
|
||||||
}
|
|
||||||
if (amount < 0) {
|
|
||||||
context.fPlayer.msg(TL.COMMAND_TNT_POSITIVE.toString());
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
if (context.faction.getTnt() < amount) {
|
|
||||||
context.fPlayer.msg(TL.COMMAND_TNT_WIDTHDRAW_NOTENOUGH_TNT.toString());
|
context.fPlayer.msg(TL.COMMAND_TNT_WIDTHDRAW_NOTENOUGH_TNT.toString());
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
int fullStacks = amount / 64;
|
context.faction.takeTnt(toAdd);
|
||||||
int remainderAmt = amount % 64;
|
dispenser.getInventory().addItem(new ItemStack(Material.TNT, toAdd));
|
||||||
if ((remainderAmt == 0 && getEmptySlots(context.player) <= fullStacks)) {
|
|
||||||
context.fPlayer.msg(TL.COMMAND_TNT_WIDTHDRAW_NOTENOUGH_TNT.toString());
|
|
||||||
return;
|
|
||||||
}
|
}
|
||||||
if (getEmptySlots(context.player) + 1 <= fullStacks) {
|
|
||||||
context.fPlayer.msg(TL.COMMAND_TNT_WIDTHDRAW_NOTENOUGH_TNT.toString());
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
ItemStack tnt64 = new ItemStack(Material.TNT, 64);
|
|
||||||
for (int i = 0; i <= fullStacks - 1; i++) {
|
|
||||||
context.player.getInventory().addItem(tnt64);
|
|
||||||
}
|
|
||||||
if (remainderAmt != 0) {
|
|
||||||
ItemStack tnt = new ItemStack(Material.TNT, remainderAmt);
|
|
||||||
context.player.getInventory().addItem(tnt);
|
|
||||||
}
|
|
||||||
context.faction.takeTnt(amount);
|
|
||||||
context.player.updateInventory();
|
|
||||||
}
|
|
||||||
|
|
||||||
private boolean takeTnt(FPlayer fme, int amount) {
|
|
||||||
Inventory inv = fme.getPlayer().getInventory();
|
|
||||||
int invTnt = 0;
|
|
||||||
for (int i = 0; i <= inv.getSize(); i++) {
|
|
||||||
if (inv.getItem(i) == null) {
|
|
||||||
continue;
|
|
||||||
}
|
|
||||||
if (inv.getItem(i).getType() == Material.TNT) {
|
|
||||||
invTnt += inv.getItem(i).getAmount();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
if (amount > invTnt) {
|
|
||||||
fme.msg(TL.COMMAND_TNTFILL_NOTENOUGH.toString());
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
ItemStack tnt = new ItemStack(Material.TNT, amount);
|
|
||||||
if (fme.getFaction().getTnt() + amount > FactionsPlugin.getInstance().getConfig().getInt("ftnt.Bank-Limit")) {
|
|
||||||
fme.msg(TL.COMMAND_TNT_EXCEEDLIMIT.toString());
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
removeFromInventory(fme.getPlayer().getInventory(), tnt);
|
|
||||||
return true;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// Counts the item type available in the inventory.
|
// Counts the item type available in the inventory.
|
||||||
@@ -196,35 +174,37 @@ public class CmdTntFill extends FCommand {
|
|||||||
return count;
|
return count;
|
||||||
}
|
}
|
||||||
|
|
||||||
private void removeFromInventory(Inventory inventory, ItemStack item) {
|
public int getAddable(Inventory inv, Material material) {
|
||||||
int amt = item.getAmount();
|
int output = 0;
|
||||||
ItemStack[] items = inventory.getContents();
|
int notempty = 0;
|
||||||
for (int i = 0; i < items.length; i++) {
|
for (int i = 0; i < inv.getSize(); ++i) {
|
||||||
if (items[i] != null && items[i].getType() == item.getType() && items[i].getDurability() == item.getDurability()) {
|
ItemStack is = inv.getItem(i);
|
||||||
if (items[i].getAmount() > amt) {
|
if (is != null) {
|
||||||
items[i].setAmount(items[i].getAmount() - amt);
|
++notempty;
|
||||||
break;
|
if (is.getType() == material) {
|
||||||
} else if (items[i].getAmount() == amt) {
|
int amount = is.getAmount();
|
||||||
items[i] = null;
|
output += 64 - amount;
|
||||||
break;
|
|
||||||
} else {
|
|
||||||
amt -= items[i].getAmount();
|
|
||||||
items[i] = null;
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
inventory.setContents(items);
|
return output + (inv.getSize() - notempty) * 64;
|
||||||
}
|
}
|
||||||
|
|
||||||
private int getEmptySlots(Player p) {
|
public boolean isInvFull(Inventory inv) {
|
||||||
PlayerInventory inventory = p.getInventory();
|
return inv.firstEmpty() == -1;
|
||||||
ItemStack[] cont = inventory.getContents();
|
|
||||||
int i = 0;
|
|
||||||
for (ItemStack item : cont)
|
|
||||||
if (item != null && item.getType() != Material.AIR) {
|
|
||||||
i++;
|
|
||||||
}
|
}
|
||||||
return 36 - i;
|
|
||||||
|
public int getTNTInside(Player p) {
|
||||||
|
int result = 0;
|
||||||
|
PlayerInventory pi = p.getInventory();
|
||||||
|
ItemStack[] contents;
|
||||||
|
for (int length = (contents = pi.getContents()).length, i = 0; i < length; ++i) {
|
||||||
|
ItemStack is = contents[i];
|
||||||
|
if (is != null && is.getType() == Material.TNT) {
|
||||||
|
result += is.getAmount();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return result;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
|||||||
@@ -27,6 +27,7 @@ public class CmdWild extends FCommand {
|
|||||||
public static HashMap<Player, Integer> waitingTeleport;
|
public static HashMap<Player, Integer> waitingTeleport;
|
||||||
public static HashMap<Player, String> teleportRange;
|
public static HashMap<Player, String> teleportRange;
|
||||||
public static HashSet<Player> teleporting;
|
public static HashSet<Player> teleporting;
|
||||||
|
|
||||||
public CmdWild() {
|
public CmdWild() {
|
||||||
super();
|
super();
|
||||||
this.aliases.addAll(Aliases.wild);
|
this.aliases.addAll(Aliases.wild);
|
||||||
@@ -38,11 +39,14 @@ public class CmdWild extends FCommand {
|
|||||||
teleportRange = new HashMap<>();
|
teleportRange = new HashMap<>();
|
||||||
startWild();
|
startWild();
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void perform(CommandContext context) {
|
public void perform(CommandContext context) {
|
||||||
if (!waitingTeleport.containsKey(context.player)) {
|
if (!waitingTeleport.containsKey(context.player)) {
|
||||||
context.player.openInventory(new WildGUI(context.player, context.fPlayer).getInventory());
|
context.player.openInventory(new WildGUI(context.player, context.fPlayer).getInventory());
|
||||||
} else {context.fPlayer.msg(TL.COMMAND_WILD_WAIT);}
|
} else {
|
||||||
|
context.fPlayer.msg(TL.COMMAND_WILD_WAIT);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public void startWild() {
|
public void startWild() {
|
||||||
@@ -64,6 +68,7 @@ public class CmdWild extends FCommand {
|
|||||||
}
|
}
|
||||||
}, 0L, 20L);
|
}, 0L, 20L);
|
||||||
}
|
}
|
||||||
|
|
||||||
public void attemptTeleport(Player p) {
|
public void attemptTeleport(Player p) {
|
||||||
boolean success = false;
|
boolean success = false;
|
||||||
int tries = 0;
|
int tries = 0;
|
||||||
@@ -84,26 +89,34 @@ public class CmdWild extends FCommand {
|
|||||||
}
|
}
|
||||||
tries++;
|
tries++;
|
||||||
}
|
}
|
||||||
if (!success) {p.sendMessage(TL.COMMAND_WILD_FAILED.toString());}
|
if (!success) {
|
||||||
|
p.sendMessage(TL.COMMAND_WILD_FAILED.toString());
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
public void teleportPlayer(Player p, FLocation loc) {
|
public void teleportPlayer(Player p, FLocation loc) {
|
||||||
Location finalLoc;
|
Location finalLoc;
|
||||||
if (FactionsPlugin.getInstance().getConfig().getBoolean("Wild.Arrival.SpawnAbove")) {
|
if (FactionsPlugin.getInstance().getConfig().getBoolean("Wild.Arrival.SpawnAbove")) {
|
||||||
finalLoc = new Location(p.getWorld(), loc.getX(), p.getWorld().getHighestBlockYAt(Math.round(loc.getX()), Math.round(loc.getZ())) + FactionsPlugin.getInstance().getConfig().getInt("Wild.Arrival.SpawnAboveBlocks", 1), loc.getZ());
|
finalLoc = new Location(p.getWorld(), loc.getX(), p.getWorld().getHighestBlockYAt(Math.round(loc.getX()), Math.round(loc.getZ())) + FactionsPlugin.getInstance().getConfig().getInt("Wild.Arrival.SpawnAboveBlocks", 1), loc.getZ());
|
||||||
} else {finalLoc = new Location(p.getWorld(), loc.getX(), p.getWorld().getHighestBlockYAt(Math.round(loc.getX()), Math.round(loc.getZ())), loc.getZ());}
|
} else {
|
||||||
|
finalLoc = new Location(p.getWorld(), loc.getX(), p.getWorld().getHighestBlockYAt(Math.round(loc.getX()), Math.round(loc.getZ())), loc.getZ());
|
||||||
|
}
|
||||||
p.teleport(finalLoc, PlayerTeleportEvent.TeleportCause.PLUGIN);
|
p.teleport(finalLoc, PlayerTeleportEvent.TeleportCause.PLUGIN);
|
||||||
setTeleporting(p);
|
setTeleporting(p);
|
||||||
applyEffects(p);
|
applyEffects(p);
|
||||||
}
|
}
|
||||||
|
|
||||||
public void applyEffects(Player p) {
|
public void applyEffects(Player p) {
|
||||||
for (String s : FactionsPlugin.getInstance().getConfig().getStringList("Wild.Arrival.Effects")) {
|
for (String s : FactionsPlugin.getInstance().getConfig().getStringList("Wild.Arrival.Effects")) {
|
||||||
p.addPotionEffect(new PotionEffect(PotionEffectType.getByName(s), 40, 1));
|
p.addPotionEffect(new PotionEffect(PotionEffectType.getByName(s), 40, 1));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public void setTeleporting(Player p) {
|
public void setTeleporting(Player p) {
|
||||||
teleporting.add(p);
|
teleporting.add(p);
|
||||||
Bukkit.getScheduler().scheduleSyncDelayedTask(FactionsPlugin.instance, () -> teleporting.remove(p), FactionsPlugin.getInstance().getConfig().getInt("Wild.Arrival.FallDamageWindow") * 20);
|
Bukkit.getScheduler().scheduleSyncDelayedTask(FactionsPlugin.instance, () -> teleporting.remove(p), FactionsPlugin.getInstance().getConfig().getInt("Wild.Arrival.FallDamageWindow") * 20);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public TL getUsageTranslation() {
|
public TL getUsageTranslation() {
|
||||||
return TL.COMMAND_WILD_DESCRIPTION;
|
return TL.COMMAND_WILD_DESCRIPTION;
|
||||||
|
|||||||
@@ -23,11 +23,13 @@ public class WildGUI implements FactionGUI {
|
|||||||
FPlayer fplayer;
|
FPlayer fplayer;
|
||||||
HashMap<Integer, String> map;
|
HashMap<Integer, String> map;
|
||||||
Inventory inv;
|
Inventory inv;
|
||||||
|
|
||||||
public WildGUI(Player player, FPlayer fplayer) {
|
public WildGUI(Player player, FPlayer fplayer) {
|
||||||
this.player = player;
|
this.player = player;
|
||||||
this.fplayer = fplayer;
|
this.fplayer = fplayer;
|
||||||
map = new HashMap<>();
|
map = new HashMap<>();
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void onClick(int slot, ClickType action) {
|
public void onClick(int slot, ClickType action) {
|
||||||
if (map.containsKey(slot)) {
|
if (map.containsKey(slot)) {
|
||||||
@@ -44,7 +46,7 @@ public class WildGUI implements FactionGUI {
|
|||||||
@Override
|
@Override
|
||||||
public void build() {
|
public void build() {
|
||||||
inv = Bukkit.createInventory(this, FactionsPlugin.getInstance().getConfig().getInt("Wild.GUI.Size"), FactionsPlugin.getInstance().color(FactionsPlugin.getInstance().getConfig().getString("Wild.GUI.Name")));
|
inv = Bukkit.createInventory(this, FactionsPlugin.getInstance().getConfig().getInt("Wild.GUI.Size"), FactionsPlugin.getInstance().color(FactionsPlugin.getInstance().getConfig().getString("Wild.GUI.Name")));
|
||||||
ItemStack fillItem = XMaterial.matchXMaterial(FactionsPlugin.getInstance().getConfig().getString("Wild.GUI.FillMaterial")).parseItem();
|
ItemStack fillItem = XMaterial.matchXMaterial(FactionsPlugin.getInstance().getConfig().getString("Wild.GUI.FillMaterial")).get().parseItem();
|
||||||
ItemMeta meta = fillItem.getItemMeta();
|
ItemMeta meta = fillItem.getItemMeta();
|
||||||
if (meta == null) return;
|
if (meta == null) return;
|
||||||
meta.setDisplayName("");
|
meta.setDisplayName("");
|
||||||
@@ -53,7 +55,7 @@ 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")).parseItem();
|
ItemStack zoneItem = XMaterial.matchXMaterial(FactionsPlugin.getInstance().getConfig().getString("Wild.Zones." + key + ".Material")).get().parseItem();
|
||||||
ItemMeta zoneMeta = zoneItem.getItemMeta();
|
ItemMeta zoneMeta = zoneItem.getItemMeta();
|
||||||
if (zoneMeta == null) return;
|
if (zoneMeta == null) return;
|
||||||
List<String> lore = new ArrayList<>();
|
List<String> lore = new ArrayList<>();
|
||||||
@@ -72,7 +74,9 @@ public class WildGUI implements FactionGUI {
|
|||||||
@NotNull
|
@NotNull
|
||||||
@Override
|
@Override
|
||||||
public Inventory getInventory() {
|
public Inventory getInventory() {
|
||||||
if (inv == null) {build();}
|
if (inv == null) {
|
||||||
|
build();
|
||||||
|
}
|
||||||
return inv;
|
return inv;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -4,7 +4,6 @@ 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 com.massivecraft.factions.FactionsPlugin;
|
import com.massivecraft.factions.FactionsPlugin;
|
||||||
import com.massivecraft.factions.util.exceptions.SaberException;
|
|
||||||
import net.dv8tion.jda.core.AccountType;
|
import net.dv8tion.jda.core.AccountType;
|
||||||
import net.dv8tion.jda.core.JDA;
|
import net.dv8tion.jda.core.JDA;
|
||||||
import net.dv8tion.jda.core.JDABuilder;
|
import net.dv8tion.jda.core.JDABuilder;
|
||||||
@@ -25,7 +24,6 @@ public class Discord {
|
|||||||
public static HashMap<FPlayer, Integer> waitingLinkk;
|
public static HashMap<FPlayer, Integer> waitingLinkk;
|
||||||
//We want to track the amount of times setup has been tried and the result may be useful for determining issues
|
//We want to track the amount of times setup has been tried and the result may be useful for determining issues
|
||||||
public static HashSet<DiscordSetupAttempt> setupLog;
|
public static HashSet<DiscordSetupAttempt> setupLog;
|
||||||
private static FactionsPlugin plugin;
|
|
||||||
public static Boolean confUseDiscord;
|
public static Boolean confUseDiscord;
|
||||||
public static String botToken;
|
public static String botToken;
|
||||||
public static String mainGuildID;
|
public static String mainGuildID;
|
||||||
@@ -37,6 +35,7 @@ public class Discord {
|
|||||||
public static Boolean useEmotes;
|
public static Boolean useEmotes;
|
||||||
public static Emote positive;
|
public static Emote positive;
|
||||||
public static Emote negative;
|
public static Emote negative;
|
||||||
|
private static FactionsPlugin plugin;
|
||||||
|
|
||||||
public Discord(FactionsPlugin plugin) {
|
public Discord(FactionsPlugin plugin) {
|
||||||
Discord.plugin = plugin;
|
Discord.plugin = plugin;
|
||||||
@@ -62,7 +61,9 @@ public class Discord {
|
|||||||
}
|
}
|
||||||
|
|
||||||
private static Boolean startBot() {
|
private static Boolean startBot() {
|
||||||
if (!Conf.useDiscordSystem) {return false;}
|
if (!Conf.useDiscordSystem) {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
try {
|
try {
|
||||||
jda = new JDABuilder(AccountType.BOT).setToken(Conf.discordBotToken).buildBlocking();
|
jda = new JDABuilder(AccountType.BOT).setToken(Conf.discordBotToken).buildBlocking();
|
||||||
} catch (LoginException | InterruptedException e) {
|
} catch (LoginException | InterruptedException e) {
|
||||||
@@ -90,13 +91,22 @@ public class Discord {
|
|||||||
try {
|
try {
|
||||||
positive = jda.getEmoteById(Conf.positiveReaction);
|
positive = jda.getEmoteById(Conf.positiveReaction);
|
||||||
negative = jda.getEmoteById(Conf.negativeReaction);
|
negative = jda.getEmoteById(Conf.negativeReaction);
|
||||||
if (positive == null | negative == null) {useEmotes = false;}
|
if (positive == null | negative == null) {
|
||||||
|
useEmotes = false;
|
||||||
|
}
|
||||||
} catch (NumberFormatException e) {
|
} catch (NumberFormatException e) {
|
||||||
FactionsPlugin.getInstance().getLogger().log(Level.WARNING, "Invalid Emote(s) disabling them.");
|
FactionsPlugin.getInstance().getLogger().log(Level.WARNING, "Invalid Emote(s) disabling them.");
|
||||||
useEmotes = false;
|
useEmotes = false;
|
||||||
}
|
}
|
||||||
if (mainGuild != null) {leader = mainGuild.getRoleById(Conf.leaderRole);} else {leader = null;}
|
if (mainGuild != null) {
|
||||||
} else {useEmotes = false; leader = null;}
|
leader = mainGuild.getRoleById(Conf.leaderRole);
|
||||||
|
} else {
|
||||||
|
leader = null;
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
useEmotes = false;
|
||||||
|
leader = null;
|
||||||
|
}
|
||||||
} catch (NullPointerException e) {
|
} catch (NullPointerException e) {
|
||||||
setupLog.add(new DiscordSetupAttempt("Threw an NPE while setting up variables", System.currentTimeMillis()));
|
setupLog.add(new DiscordSetupAttempt("Threw an NPE while setting up variables", System.currentTimeMillis()));
|
||||||
}
|
}
|
||||||
@@ -111,11 +121,21 @@ public class Discord {
|
|||||||
public static String getNicknameString(FPlayer f) {
|
public static String getNicknameString(FPlayer f) {
|
||||||
if (useDiscord) {
|
if (useDiscord) {
|
||||||
String temp = Conf.factionTag;
|
String temp = Conf.factionTag;
|
||||||
if (temp.contains("NAME")) { temp = temp.replace("NAME", f.getName()); }
|
if (temp.contains("NAME")) {
|
||||||
if (temp.contains("DiscordName")) { temp = temp.replace("DiscordName", (f.discordUser() == null) ? (f.getName()) : (f.discordUser().getName())); }
|
temp = temp.replace("NAME", f.getName());
|
||||||
if (temp.contains("FACTION")) { temp = temp.replace("FACTION", f.getFaction().getTag()); }
|
}
|
||||||
if (temp.contains("FactionRole")) { temp = temp.replace("FactionRole", f.getRole().getRoleCapitalized()); }
|
if (temp.contains("DiscordName")) {
|
||||||
if (temp.contains("FactionRolePrefix")) { temp = temp.replace("FactionRolePrefix", f.getRole().getPrefix()); }
|
temp = temp.replace("DiscordName", (f.discordUser() == null) ? (f.getName()) : (f.discordUser().getName()));
|
||||||
|
}
|
||||||
|
if (temp.contains("FACTION")) {
|
||||||
|
temp = temp.replace("FACTION", f.getFaction().getTag());
|
||||||
|
}
|
||||||
|
if (temp.contains("FactionRole")) {
|
||||||
|
temp = temp.replace("FactionRole", f.getRole().getRoleCapitalized());
|
||||||
|
}
|
||||||
|
if (temp.contains("FactionRolePrefix")) {
|
||||||
|
temp = temp.replace("FactionRolePrefix", f.getRole().getPrefix());
|
||||||
|
}
|
||||||
return temp;
|
return temp;
|
||||||
}
|
}
|
||||||
return null;
|
return null;
|
||||||
@@ -138,7 +158,9 @@ public class Discord {
|
|||||||
public static Role getRoleFromName(String s) {
|
public static Role getRoleFromName(String s) {
|
||||||
if (useDiscord && mainGuild != null) {
|
if (useDiscord && mainGuild != null) {
|
||||||
for (Role r : mainGuild.getRoles()) {
|
for (Role r : mainGuild.getRoles()) {
|
||||||
if (r.getName().equals(s)) {return r;}
|
if (r.getName().equals(s)) {
|
||||||
|
return r;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return null;
|
return null;
|
||||||
@@ -151,8 +173,12 @@ public class Discord {
|
|||||||
* @return Role generated faction role
|
* @return Role generated faction role
|
||||||
*/
|
*/
|
||||||
public static Role createFactionRole(String s) {
|
public static Role createFactionRole(String s) {
|
||||||
if (!useDiscord) { return null; }
|
if (!useDiscord) {
|
||||||
if (mainGuild == null) { return null; }
|
return null;
|
||||||
|
}
|
||||||
|
if (mainGuild == null) {
|
||||||
|
return null;
|
||||||
|
}
|
||||||
StringBuilder sb = new StringBuilder();
|
StringBuilder sb = new StringBuilder();
|
||||||
sb.append(Conf.factionRolePrefix);
|
sb.append(Conf.factionRolePrefix);
|
||||||
sb.append(s);
|
sb.append(s);
|
||||||
@@ -176,6 +202,7 @@ public class Discord {
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
* Get the name of the Faction Role that would be generated with the tag
|
* Get the name of the Faction Role that would be generated with the tag
|
||||||
|
*
|
||||||
* @param tag Faction Name/Tag
|
* @param tag Faction Name/Tag
|
||||||
* @return Name of would be Role
|
* @return Name of would be Role
|
||||||
*/
|
*/
|
||||||
@@ -204,13 +231,19 @@ public class Discord {
|
|||||||
* @param f FPlayer target
|
* @param f FPlayer target
|
||||||
*/
|
*/
|
||||||
public static void resetNick(FPlayer f) {
|
public static void resetNick(FPlayer f) {
|
||||||
if (mainGuild == null) { return; }
|
if (mainGuild == null) {
|
||||||
if (mainGuild.getMember(f.discordUser()) == null) { return; }
|
return;
|
||||||
|
}
|
||||||
|
if (mainGuild.getMember(f.discordUser()) == null) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
mainGuild.getController().setNickname(mainGuild.getMember(f.discordUser()), f.discordUser().getName()).queue();
|
mainGuild.getController().setNickname(mainGuild.getMember(f.discordUser()), f.discordUser().getName()).queue();
|
||||||
}
|
}
|
||||||
|
|
||||||
public static void changeFactionTag(Faction f, String oldTag) {
|
public static void changeFactionTag(Faction f, String oldTag) {
|
||||||
if (!useDiscord | mainGuild == null) { return; }
|
if (!useDiscord | mainGuild == null) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
for (FPlayer fp : f.getFPlayers()) {
|
for (FPlayer fp : f.getFPlayers()) {
|
||||||
if (fp.discordSetup() && isInMainGuild(fp.discordUser())) {
|
if (fp.discordSetup() && isInMainGuild(fp.discordUser())) {
|
||||||
try {
|
try {
|
||||||
@@ -222,7 +255,9 @@ public class Discord {
|
|||||||
mainGuild.getController().removeSingleRoleFromMember(m, Objects.requireNonNull(getRoleFromName(oldTag))).queue();
|
mainGuild.getController().removeSingleRoleFromMember(m, Objects.requireNonNull(getRoleFromName(oldTag))).queue();
|
||||||
mainGuild.getController().addSingleRoleToMember(m, Objects.requireNonNull(createFactionRole(f.getTag()))).queue();
|
mainGuild.getController().addSingleRoleToMember(m, Objects.requireNonNull(createFactionRole(f.getTag()))).queue();
|
||||||
}
|
}
|
||||||
} catch (HierarchyException e) {System.out.print(e.getMessage());}
|
} catch (HierarchyException e) {
|
||||||
|
System.out.print(e.getMessage());
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -93,7 +93,8 @@ public class DiscordListener extends ListenerAdapter {
|
|||||||
prefix = ".";
|
prefix = ".";
|
||||||
}
|
}
|
||||||
String content = event.getMessage().getContentRaw();
|
String content = event.getMessage().getContentRaw();
|
||||||
if (!content.startsWith(prefix) && !content.startsWith(event.getGuild().getSelfMember().getAsMention())) return;
|
if (!content.startsWith(prefix) && !content.startsWith(event.getGuild().getSelfMember().getAsMention()))
|
||||||
|
return;
|
||||||
if (content.startsWith(prefix + "help") || content.startsWith(event.getGuild().getSelfMember().getAsMention() + " help")) {
|
if (content.startsWith(prefix + "help") || content.startsWith(event.getGuild().getSelfMember().getAsMention() + " help")) {
|
||||||
this.help(event, content, prefix);
|
this.help(event, content, prefix);
|
||||||
} else if (content.startsWith(prefix + "stats")) {
|
} else if (content.startsWith(prefix + "stats")) {
|
||||||
@@ -124,7 +125,8 @@ public class DiscordListener extends ListenerAdapter {
|
|||||||
this.settings(event);
|
this.settings(event);
|
||||||
}
|
}
|
||||||
} catch (PermissionException exception) {
|
} catch (PermissionException exception) {
|
||||||
if (!event.getGuild().getSelfMember().hasPermission(event.getChannel(), Permission.MESSAGE_READ, Permission.MESSAGE_WRITE)) return;
|
if (!event.getGuild().getSelfMember().hasPermission(event.getChannel(), Permission.MESSAGE_READ, Permission.MESSAGE_WRITE))
|
||||||
|
return;
|
||||||
event.getChannel().sendMessage((":x: Missing permission, `" + exception.getPermission().toString() + "`")).queue();
|
event.getChannel().sendMessage((":x: Missing permission, `" + exception.getPermission().toString() + "`")).queue();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -135,7 +137,8 @@ public class DiscordListener extends ListenerAdapter {
|
|||||||
|
|
||||||
private Faction getFactionWithWarning(TextChannel textChannel) {
|
private Faction getFactionWithWarning(TextChannel textChannel) {
|
||||||
Faction faction = this.getFaction(textChannel.getGuild());
|
Faction faction = this.getFaction(textChannel.getGuild());
|
||||||
if (faction == null) textChannel.sendMessage((":x: This guild isn't linked to a faction, use `/f setguild " + textChannel.getGuild().getId() + "` in game")).queue();
|
if (faction == null)
|
||||||
|
textChannel.sendMessage((":x: This guild isn't linked to a faction, use `/f setguild " + textChannel.getGuild().getId() + "` in game")).queue();
|
||||||
return faction;
|
return faction;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -7,6 +7,7 @@ public class DiscordSetupAttempt {
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
* Constructor used when an attempt fails
|
* Constructor used when an attempt fails
|
||||||
|
*
|
||||||
* @param reason String reason for the attempt failing
|
* @param reason String reason for the attempt failing
|
||||||
* @param time Long current system time in millis
|
* @param time Long current system time in millis
|
||||||
*/
|
*/
|
||||||
@@ -18,6 +19,7 @@ public class DiscordSetupAttempt {
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
* Constructor used for successful attempts
|
* Constructor used for successful attempts
|
||||||
|
*
|
||||||
* @param time Long Current system time in millis
|
* @param time Long Current system time in millis
|
||||||
*/
|
*/
|
||||||
public DiscordSetupAttempt(Long time) {
|
public DiscordSetupAttempt(Long time) {
|
||||||
@@ -28,30 +30,43 @@ public class DiscordSetupAttempt {
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
* Get if this attempt to setup the Discord bot was successful
|
* Get if this attempt to setup the Discord bot was successful
|
||||||
|
*
|
||||||
* @return Boolean success
|
* @return Boolean success
|
||||||
*/
|
*/
|
||||||
public Boolean getSuccess() {return this.success;}
|
public Boolean getSuccess() {
|
||||||
|
return this.success;
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Get the reason for the setup failing (If it was successful it will return null)
|
* Get the reason for the setup failing (If it was successful it will return null)
|
||||||
|
*
|
||||||
* @return String reason
|
* @return String reason
|
||||||
*/
|
*/
|
||||||
public String getReason() {return this.reason;}
|
public String getReason() {
|
||||||
|
return this.reason;
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Get the time this setup was attempted
|
* Get the time this setup was attempted
|
||||||
|
*
|
||||||
* @return Long initialTime
|
* @return Long initialTime
|
||||||
*/
|
*/
|
||||||
public Long getInitialTime() {return this.initialTime;}
|
public Long getInitialTime() {
|
||||||
|
return this.initialTime;
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Get the difference of time between when attempted and present time
|
* Get the difference of time between when attempted and present time
|
||||||
|
*
|
||||||
* @return Long time difference in milliseconds
|
* @return Long time difference in milliseconds
|
||||||
*/
|
*/
|
||||||
public Long getDifferentialTime() {return System.currentTimeMillis()-initialTime;}
|
public Long getDifferentialTime() {
|
||||||
|
return System.currentTimeMillis() - initialTime;
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Get the difference in time between when attempted and present time formatted MS,Seconds,Minutes,Hours,Years
|
* Get the difference in time between when attempted and present time formatted MS,Seconds,Minutes,Hours,Years
|
||||||
|
*
|
||||||
* @return String with formatted time difference
|
* @return String with formatted time difference
|
||||||
*/
|
*/
|
||||||
public String getDifferentialFormatted() {
|
public String getDifferentialFormatted() {
|
||||||
@@ -91,12 +106,24 @@ public class DiscordSetupAttempt {
|
|||||||
sb.append(" ");
|
sb.append(" ");
|
||||||
String s = "";
|
String s = "";
|
||||||
switch (timeIndex) {
|
switch (timeIndex) {
|
||||||
case 0: s = "MS"; break;
|
case 0:
|
||||||
case 1: s = "Seconds"; break;
|
s = "MS";
|
||||||
case 2: s = "Minutes"; break;
|
break;
|
||||||
case 3: s = "Hours"; break;
|
case 1:
|
||||||
case 4: s = "Days"; break;
|
s = "Seconds";
|
||||||
case 5: s = "Years"; break;
|
break;
|
||||||
|
case 2:
|
||||||
|
s = "Minutes";
|
||||||
|
break;
|
||||||
|
case 3:
|
||||||
|
s = "Hours";
|
||||||
|
break;
|
||||||
|
case 4:
|
||||||
|
s = "Days";
|
||||||
|
break;
|
||||||
|
case 5:
|
||||||
|
s = "Years";
|
||||||
|
break;
|
||||||
}
|
}
|
||||||
sb.append(s);
|
sb.append(s);
|
||||||
sb.append(" ago");
|
sb.append(" ago");
|
||||||
|
|||||||
@@ -5,8 +5,6 @@ import com.massivecraft.factions.Faction;
|
|||||||
import com.massivecraft.factions.Factions;
|
import com.massivecraft.factions.Factions;
|
||||||
import com.massivecraft.factions.FactionsPlugin;
|
import com.massivecraft.factions.FactionsPlugin;
|
||||||
import mkremins.fanciful.FancyMessage;
|
import mkremins.fanciful.FancyMessage;
|
||||||
import net.dv8tion.jda.core.AccountType;
|
|
||||||
import net.dv8tion.jda.core.JDABuilder;
|
|
||||||
import net.dv8tion.jda.core.Permission;
|
import net.dv8tion.jda.core.Permission;
|
||||||
import net.dv8tion.jda.core.entities.Message;
|
import net.dv8tion.jda.core.entities.Message;
|
||||||
import net.dv8tion.jda.core.entities.TextChannel;
|
import net.dv8tion.jda.core.entities.TextChannel;
|
||||||
@@ -19,12 +17,10 @@ import net.dv8tion.jda.webhook.WebhookMessage;
|
|||||||
import net.dv8tion.jda.webhook.WebhookMessageBuilder;
|
import net.dv8tion.jda.webhook.WebhookMessageBuilder;
|
||||||
import org.bukkit.ChatColor;
|
import org.bukkit.ChatColor;
|
||||||
|
|
||||||
import javax.security.auth.login.LoginException;
|
|
||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
import java.util.Arrays;
|
import java.util.Arrays;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
import java.util.UUID;
|
import java.util.UUID;
|
||||||
import java.util.logging.Level;
|
|
||||||
|
|
||||||
public class FactionChatHandler extends ListenerAdapter {
|
public class FactionChatHandler extends ListenerAdapter {
|
||||||
|
|
||||||
@@ -69,7 +65,9 @@ public class FactionChatHandler extends ListenerAdapter {
|
|||||||
while (i <= x.size() - 1) {
|
while (i <= x.size() - 1) {
|
||||||
mention.append(" ").append(x.get(i));
|
mention.append(" ").append(x.get(i));
|
||||||
ii.add(i);
|
ii.add(i);
|
||||||
if (mention.toString().contains("#")) {break;}
|
if (mention.toString().contains("#")) {
|
||||||
|
break;
|
||||||
|
}
|
||||||
i++;
|
i++;
|
||||||
}
|
}
|
||||||
if (mention.toString().contains("#")) {
|
if (mention.toString().contains("#")) {
|
||||||
|
|||||||
@@ -32,7 +32,7 @@ public class FPlayerRoleChangeEvent extends FactionPlayerEvent implements Cancel
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
public boolean isCancelled() {
|
public boolean isCancelled() {
|
||||||
return false;
|
return cancelled;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
|||||||
@@ -76,32 +76,40 @@ public class PowerLossEvent extends FactionPlayerEvent implements Cancellable {
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
* Gets the configured damage to a players individual power on death
|
* Gets the configured damage to a players individual power on death
|
||||||
|
*
|
||||||
* @return power to be lost as a Double.
|
* @return power to be lost as a Double.
|
||||||
*/
|
*/
|
||||||
public double getDefaultPowerLost() {return Conf.powerPerDeath;}
|
public double getDefaultPowerLost() {
|
||||||
|
return Conf.powerPerDeath;
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Gets the variable power lost. Custom power ignored when less than or equal to zero.
|
* Gets the variable power lost. Custom power ignored when less than or equal to zero.
|
||||||
|
*
|
||||||
* @return custom power to be lost as a Double.
|
* @return custom power to be lost as a Double.
|
||||||
*/
|
*/
|
||||||
public double getCustomPowerLost() {return this.modified;}
|
public double getCustomPowerLost() {
|
||||||
|
return this.modified;
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Sets the variable power lost. Custom power ignored when less than or equal to zero.
|
* Sets the variable power lost. Custom power ignored when less than or equal to zero.
|
||||||
|
*
|
||||||
* @param loss Double amount for the custom power loss to be set to.
|
* @param loss Double amount for the custom power loss to be set to.
|
||||||
*/
|
*/
|
||||||
public void setCustomPowerLost(Double loss) {modified = loss;}
|
public void setCustomPowerLost(Double loss) {
|
||||||
|
modified = loss;
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Determines if custom power is to be used.
|
* Determines if custom power is to be used.
|
||||||
|
*
|
||||||
* @return If custom power is to be used as a boolean.
|
* @return If custom power is to be used as a boolean.
|
||||||
*/
|
*/
|
||||||
public boolean usingCustomPower() {
|
public boolean usingCustomPower() {
|
||||||
if (modified > 0) {
|
return modified > 0;
|
||||||
return true;
|
|
||||||
}
|
|
||||||
return false;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public boolean isCancelled() {
|
public boolean isCancelled() {
|
||||||
return cancelled;
|
return cancelled;
|
||||||
|
|||||||
@@ -3,8 +3,6 @@ package com.massivecraft.factions.event;
|
|||||||
import com.massivecraft.factions.Conf;
|
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 com.massivecraft.factions.zcore.persist.MemoryFPlayer;
|
|
||||||
import com.massivecraft.factions.zcore.persist.MemoryFPlayers;
|
|
||||||
import org.bukkit.event.Cancellable;
|
import org.bukkit.event.Cancellable;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -25,6 +23,7 @@ public class PowerRegenEvent extends FactionPlayerEvent implements Cancellable {
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
* Get the amount of power this player will regen by default
|
* Get the amount of power this player will regen by default
|
||||||
|
*
|
||||||
* @return power amount gained as a Double.
|
* @return power amount gained as a Double.
|
||||||
*/
|
*/
|
||||||
public double getDefaultPowerGained() {
|
public double getDefaultPowerGained() {
|
||||||
@@ -33,26 +32,30 @@ public class PowerRegenEvent extends FactionPlayerEvent implements Cancellable {
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
* Get the amount of custom power this player will gain. Ignored if less than or equal to 0.
|
* Get the amount of custom power this player will gain. Ignored if less than or equal to 0.
|
||||||
|
*
|
||||||
* @return Custom power as a double
|
* @return Custom power as a double
|
||||||
*/
|
*/
|
||||||
public double getCustomPower() {return modified;}
|
public double getCustomPower() {
|
||||||
|
return modified;
|
||||||
/**
|
|
||||||
* 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() {
|
|
||||||
if (modified > 0) {
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
return false;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Set the custom power gain for this event.
|
* Set the custom power gain for this event.
|
||||||
|
*
|
||||||
* @param gain Amount of power to be added to player.
|
* @param gain Amount of power to be added to player.
|
||||||
*/
|
*/
|
||||||
public void setCustomPower(Double gain) {modified = gain;}
|
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
|
||||||
public boolean isCancelled() {
|
public boolean isCancelled() {
|
||||||
|
|||||||
@@ -34,6 +34,7 @@ import java.util.List;
|
|||||||
|
|
||||||
public class Worldguard {
|
public class Worldguard {
|
||||||
|
|
||||||
|
private static Worldguard instance;
|
||||||
/**
|
/**
|
||||||
* @author FactionsUUID Team
|
* @author FactionsUUID Team
|
||||||
*/
|
*/
|
||||||
@@ -53,8 +54,6 @@ public class Worldguard {
|
|||||||
private StateFlag breakFlag;
|
private StateFlag breakFlag;
|
||||||
private boolean initialized = false;
|
private boolean initialized = false;
|
||||||
|
|
||||||
private static Worldguard instance;
|
|
||||||
|
|
||||||
public Worldguard() {
|
public Worldguard() {
|
||||||
instance = this;
|
instance = this;
|
||||||
|
|
||||||
@@ -72,16 +71,20 @@ public class Worldguard {
|
|||||||
Method getInstanceMethod = worldGuardClass.getMethod("getInstance");
|
Method getInstanceMethod = worldGuardClass.getMethod("getInstance");
|
||||||
worldGuard = getInstanceMethod.invoke(null);
|
worldGuard = getInstanceMethod.invoke(null);
|
||||||
FactionsPlugin.instance.log("Found WorldGuard 7+");
|
FactionsPlugin.instance.log("Found WorldGuard 7+");
|
||||||
} catch (Exception ex) { FactionsPlugin.instance.log("Found WorldGuard <7"); }
|
} catch (Exception ex) {
|
||||||
|
FactionsPlugin.instance.log("Found WorldGuard <7");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public static Worldguard getInstance() {
|
||||||
|
return instance;
|
||||||
|
}
|
||||||
|
|
||||||
public boolean isEnabled() {
|
public boolean isEnabled() {
|
||||||
return worldGuardPlugin != null;
|
return worldGuardPlugin != null;
|
||||||
}
|
}
|
||||||
|
|
||||||
public static Worldguard getInstance() { return instance; }
|
|
||||||
|
|
||||||
protected RegionAssociable getAssociable(Player player) {
|
protected RegionAssociable getAssociable(Player player) {
|
||||||
RegionAssociable associable;
|
RegionAssociable associable;
|
||||||
if (player == null) {
|
if (player == null) {
|
||||||
@@ -201,6 +204,7 @@ public class Worldguard {
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
* Used to check WorldGuard to see if a Player has permission to place a block.
|
* Used to check WorldGuard to see if a Player has permission to place a block.
|
||||||
|
*
|
||||||
* @param player player in question.
|
* @param player player in question.
|
||||||
* @param location Location of block placed.
|
* @param location Location of block placed.
|
||||||
* @return
|
* @return
|
||||||
@@ -213,7 +217,8 @@ public class Worldguard {
|
|||||||
if (locationAdaptMethod != null) {
|
if (locationAdaptMethod != null) {
|
||||||
Object loc = locationAdaptMethod.invoke(null, location);
|
Object loc = locationAdaptMethod.invoke(null, location);
|
||||||
return (boolean) regionQueryTestStateMethod.invoke(query, loc, getAssociable(player), new StateFlag[]{buildFlag});
|
return (boolean) regionQueryTestStateMethod.invoke(query, loc, getAssociable(player), new StateFlag[]{buildFlag});
|
||||||
} else return (boolean)regionQueryTestStateMethod.invoke(query, location, getAssociable(player), new StateFlag[]{buildFlag});
|
} else
|
||||||
|
return (boolean) regionQueryTestStateMethod.invoke(query, location, getAssociable(player), new StateFlag[]{buildFlag});
|
||||||
} catch (Exception ex) {
|
} catch (Exception ex) {
|
||||||
FactionsPlugin.instance.log("An error occurred querying WorldGuard! Report this issue to SF Developers!");
|
FactionsPlugin.instance.log("An error occurred querying WorldGuard! Report this issue to SF Developers!");
|
||||||
FactionsPlugin.instance.log("WorldGuard 7.0.0 support is currently in BETA. Please be careful!");
|
FactionsPlugin.instance.log("WorldGuard 7.0.0 support is currently in BETA. Please be careful!");
|
||||||
@@ -224,6 +229,7 @@ public class Worldguard {
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
* Used to check WorldGuard to see if a player has permission to break a block.
|
* Used to check WorldGuard to see if a player has permission to break a block.
|
||||||
|
*
|
||||||
* @param player player in question.
|
* @param player player in question.
|
||||||
* @param location Location of block broken.
|
* @param location Location of block broken.
|
||||||
* @return
|
* @return
|
||||||
@@ -236,7 +242,8 @@ public class Worldguard {
|
|||||||
if (locationAdaptMethod != null) {
|
if (locationAdaptMethod != null) {
|
||||||
Object loc = locationAdaptMethod.invoke(null, location);
|
Object loc = locationAdaptMethod.invoke(null, location);
|
||||||
return (boolean) regionQueryTestStateMethod.invoke(query, loc, getAssociable(player), new StateFlag[]{breakFlag});
|
return (boolean) regionQueryTestStateMethod.invoke(query, loc, getAssociable(player), new StateFlag[]{breakFlag});
|
||||||
} else return (boolean) regionQueryTestStateMethod.invoke(query, location, getAssociable(player), new StateFlag[]{breakFlag});
|
} else
|
||||||
|
return (boolean) regionQueryTestStateMethod.invoke(query, location, getAssociable(player), new StateFlag[]{breakFlag});
|
||||||
|
|
||||||
} catch (Exception ex) {
|
} catch (Exception ex) {
|
||||||
FactionsPlugin.instance.log("An error occurred querying WorldGuard! Report this issue to SF Developers!");
|
FactionsPlugin.instance.log("An error occurred querying WorldGuard! Report this issue to SF Developers!");
|
||||||
@@ -246,10 +253,13 @@ public class Worldguard {
|
|||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
public boolean checkForRegionsInChunk(FLocation floc) { return checkForRegionsInChunk(floc.getChunk()); }
|
public boolean checkForRegionsInChunk(FLocation floc) {
|
||||||
|
return checkForRegionsInChunk(floc.getChunk());
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Used for checking if regions are located in a chunk
|
* Used for checking if regions are located in a chunk
|
||||||
|
*
|
||||||
* @param chunk Chunk in question.
|
* @param chunk Chunk in question.
|
||||||
* @return
|
* @return
|
||||||
*/
|
*/
|
||||||
@@ -284,6 +294,7 @@ public class Worldguard {
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
* General check for WorldGuard region @ location.
|
* General check for WorldGuard region @ location.
|
||||||
|
*
|
||||||
* @param player player in question.
|
* @param player player in question.
|
||||||
* @param location Location of block broken.
|
* @param location Location of block broken.
|
||||||
* @return
|
* @return
|
||||||
|
|||||||
@@ -73,6 +73,9 @@ public class EngineDynmap {
|
|||||||
}
|
}
|
||||||
|
|
||||||
public static String escapeHtml(String string) {
|
public static String escapeHtml(String string) {
|
||||||
|
if (string == null) {
|
||||||
|
return "";
|
||||||
|
}
|
||||||
StringBuilder out = new StringBuilder(Math.max(16, string.length()));
|
StringBuilder out = new StringBuilder(Math.max(16, string.length()));
|
||||||
for (int i = 0; i < string.length(); i++) {
|
for (int i = 0; i < string.length(); i++) {
|
||||||
char c = string.charAt(i);
|
char c = string.charAt(i);
|
||||||
|
|||||||
@@ -40,6 +40,7 @@ import org.bukkit.potion.PotionEffectType;
|
|||||||
import java.util.HashMap;
|
import java.util.HashMap;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
import java.util.Map;
|
import java.util.Map;
|
||||||
|
import java.util.Objects;
|
||||||
import java.util.concurrent.TimeUnit;
|
import java.util.concurrent.TimeUnit;
|
||||||
import java.util.concurrent.atomic.AtomicInteger;
|
import java.util.concurrent.atomic.AtomicInteger;
|
||||||
|
|
||||||
@@ -161,20 +162,22 @@ public class FactionsBlockListener implements Listener {
|
|||||||
|
|
||||||
@EventHandler(priority = EventPriority.NORMAL, ignoreCancelled = true)
|
@EventHandler(priority = EventPriority.NORMAL, ignoreCancelled = true)
|
||||||
public void onBlockPlace(BlockPlaceEvent event) {
|
public void onBlockPlace(BlockPlaceEvent event) {
|
||||||
Faction at = Board.getInstance().getFactionAt(new FLocation(event.getBlockPlaced()));
|
|
||||||
|
|
||||||
if (!event.canBuild()) return;
|
if (!event.canBuild()) return;
|
||||||
if (event.getBlockPlaced().getType() == Material.FIRE) return;
|
if (event.getBlockPlaced().getType() == Material.FIRE) return;
|
||||||
|
boolean isSpawner = event.getBlock().getType().equals(XMaterial.SPAWNER.parseMaterial());
|
||||||
if (!playerCanBuildDestroyBlock(event.getPlayer(), event.getBlock().getLocation(), "build", false)) {
|
if (!playerCanBuildDestroyBlock(event.getPlayer(), event.getBlock().getLocation(), "build", false)) {
|
||||||
event.setCancelled(true);
|
event.setCancelled(true);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
if (event.getBlock().getType().equals(XMaterial.SPAWNER.parseMaterial()) && Conf.spawnerLock) {
|
|
||||||
|
if (isSpawner) {
|
||||||
|
if (Conf.spawnerLock) {
|
||||||
event.setCancelled(true);
|
event.setCancelled(true);
|
||||||
event.getPlayer().sendMessage(FactionsPlugin.getInstance().color(TL.COMMAND_SPAWNER_LOCK_CANNOT_PLACE.toString()));
|
event.getPlayer().sendMessage(FactionsPlugin.getInstance().color(TL.COMMAND_SPAWNER_LOCK_CANNOT_PLACE.toString()));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
@EventHandler(priority = EventPriority.NORMAL, ignoreCancelled = true)
|
@EventHandler(priority = EventPriority.NORMAL, ignoreCancelled = true)
|
||||||
public void onBlockFromTo(BlockFromToEvent event) {
|
public void onBlockFromTo(BlockFromToEvent event) {
|
||||||
@@ -265,7 +268,8 @@ public class FactionsBlockListener implements Listener {
|
|||||||
|
|
||||||
@EventHandler
|
@EventHandler
|
||||||
public void onHopperPlace(BlockPlaceEvent e) {
|
public void onHopperPlace(BlockPlaceEvent e) {
|
||||||
if (e.getItemInHand().getType() != Material.HOPPER && !FactionsPlugin.instance.getConfig().getBoolean("fvault.No-Hoppers-near-vault")) return;
|
if (e.getItemInHand().getType() != Material.HOPPER && !FactionsPlugin.instance.getConfig().getBoolean("fvault.No-Hoppers-near-vault"))
|
||||||
|
return;
|
||||||
Faction factionAt = Board.getInstance().getFactionAt(new FLocation(e.getBlockPlaced().getLocation()));
|
Faction factionAt = Board.getInstance().getFactionAt(new FLocation(e.getBlockPlaced().getLocation()));
|
||||||
if (factionAt.isWilderness() || factionAt.getVault() == null) return;
|
if (factionAt.isWilderness() || factionAt.getVault() == null) return;
|
||||||
FPlayer fme = FPlayers.getInstance().getByPlayer(e.getPlayer());
|
FPlayer fme = FPlayers.getInstance().getByPlayer(e.getPlayer());
|
||||||
@@ -356,12 +360,8 @@ public class FactionsBlockListener implements Listener {
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
for (FPlayer fplayer : fme.getFaction().getFPlayers()) {
|
for (FPlayer fplayer : fme.getFaction().getFPlayers()) {
|
||||||
if (XMaterial.isVersionOrHigher(XMaterial.MinecraftVersion.VERSION_1_9)) {
|
|
||||||
fplayer.getPlayer().sendTitle(FactionsPlugin.getInstance().color(fme.getTag() + " Placed A WarBanner!"), FactionsPlugin.getInstance().color("&7use &c/f tpbanner&7 to tp to the banner!"), 10, 70, 20);
|
|
||||||
} else {
|
|
||||||
fplayer.getPlayer().sendTitle(FactionsPlugin.getInstance().color(fme.getTag() + " Placed A WarBanner!"), FactionsPlugin.getInstance().color("&7use &c/f tpbanner&7 to tp to the banner!"));
|
fplayer.getPlayer().sendTitle(FactionsPlugin.getInstance().color(fme.getTag() + " Placed A WarBanner!"), FactionsPlugin.getInstance().color("&7use &c/f tpbanner&7 to tp to the banner!"));
|
||||||
}
|
}
|
||||||
}
|
|
||||||
bannerCooldownMap.put(fme.getTag(), true);
|
bannerCooldownMap.put(fme.getTag(), true);
|
||||||
FactionsBlockListener.bannerLocations.put(fme.getTag(), e.getBlockPlaced().getLocation());
|
FactionsBlockListener.bannerLocations.put(fme.getTag(), e.getBlockPlaced().getLocation());
|
||||||
int bannerCooldown = FactionsPlugin.getInstance().getConfig().getInt("fbanners.Banner-Place-Cooldown");
|
int bannerCooldown = FactionsPlugin.getInstance().getConfig().getInt("fbanners.Banner-Place-Cooldown");
|
||||||
@@ -380,7 +380,7 @@ public class FactionsBlockListener implements Listener {
|
|||||||
int radius = FactionsPlugin.getInstance().getConfig().getInt("fbanners.Banner-Effect-Radius");
|
int radius = FactionsPlugin.getInstance().getConfig().getInt("fbanners.Banner-Effect-Radius");
|
||||||
List<String> effects = FactionsPlugin.getInstance().getConfig().getStringList("fbanners.Effects");
|
List<String> effects = FactionsPlugin.getInstance().getConfig().getStringList("fbanners.Effects");
|
||||||
int affectorTask = Bukkit.getScheduler().scheduleSyncRepeatingTask(FactionsPlugin.getInstance(), () -> {
|
int affectorTask = Bukkit.getScheduler().scheduleSyncRepeatingTask(FactionsPlugin.getInstance(), () -> {
|
||||||
for (Entity e1 : banner.getLocation().getWorld().getNearbyEntities(banner.getLocation(), radius, 255.0, radius)) {
|
for (Entity e1 : Objects.requireNonNull(banner.getLocation().getWorld()).getNearbyEntities(banner.getLocation(), radius, 255.0, radius)) {
|
||||||
if (e1 instanceof Player) {
|
if (e1 instanceof Player) {
|
||||||
Player player = (Player) e1;
|
Player player = (Player) e1;
|
||||||
FPlayer fplayer = FPlayers.getInstance().getByPlayer(player);
|
FPlayer fplayer = FPlayers.getInstance().getByPlayer(player);
|
||||||
@@ -389,7 +389,7 @@ public class FactionsBlockListener implements Listener {
|
|||||||
}
|
}
|
||||||
for (String effect : effects) {
|
for (String effect : effects) {
|
||||||
String[] components = effect.split(":");
|
String[] components = effect.split(":");
|
||||||
player.addPotionEffect(new PotionEffect(PotionEffectType.getByName(components[0]), 100, Integer.parseInt(components[1])));
|
player.addPotionEffect(new PotionEffect(Objects.requireNonNull(PotionEffectType.getByName(components[0])), 100, Integer.parseInt(components[1])));
|
||||||
}
|
}
|
||||||
ParticleEffect.LAVA.display(1.0f, 1.0f, 1.0f, 1.0f, 10, banner.getLocation(), 16.0);
|
ParticleEffect.LAVA.display(1.0f, 1.0f, 1.0f, 1.0f, 10, banner.getLocation(), 16.0);
|
||||||
ParticleEffect.FLAME.display(1.0f, 1.0f, 1.0f, 1.0f, 10, banner.getLocation(), 16.0);
|
ParticleEffect.FLAME.display(1.0f, 1.0f, 1.0f, 1.0f, 10, banner.getLocation(), 16.0);
|
||||||
@@ -496,13 +496,25 @@ public class FactionsBlockListener implements Listener {
|
|||||||
Block block = event.getBlock();
|
Block block = event.getBlock();
|
||||||
|
|
||||||
Faction at = Board.getInstance().getFactionAt(new FLocation(block));
|
Faction at = Board.getInstance().getFactionAt(new FLocation(block));
|
||||||
boolean isSpawner = event.getBlock().getType() == XMaterial.SPAWNER.parseMaterial();
|
boolean isSpawner = event.getBlock().getType().equals(XMaterial.SPAWNER.parseMaterial());
|
||||||
if (!playerCanBuildDestroyBlock(event.getPlayer(), event.getBlock().getLocation(), !isSpawner ? "destroy" : "mine spawners", false)) {
|
|
||||||
|
if (!playerCanBuildDestroyBlock(event.getPlayer(), event.getBlock().getLocation(), "destroy", false)) {
|
||||||
event.setCancelled(true);
|
event.setCancelled(true);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
if (block != null && isSpawner) {
|
|
||||||
ItemStack item = new ItemStack(block.getType(), 1, (short) block.getData());
|
FPlayer fme = FPlayers.getInstance().getByPlayer(event.getPlayer());
|
||||||
|
if (fme == null || !fme.hasFaction()) return;
|
||||||
|
|
||||||
|
if (isSpawner) {
|
||||||
|
Access access = fme.getFaction().getAccess(fme, PermissableAction.SPAWNER);
|
||||||
|
if (access != Access.ALLOW && fme.getRole() != Role.LEADER) {
|
||||||
|
fme.msg(TL.GENERIC_FPERM_NOPERMISSION, "mine spawners");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if (isSpawner && !fme.isAdminBypassing()) {
|
||||||
|
ItemStack item = new ItemStack(block.getType(), 1, block.getData());
|
||||||
if (at != null && at.isNormal()) {
|
if (at != null && at.isNormal()) {
|
||||||
FPlayer fplayer = FPlayers.getInstance().getByPlayer(event.getPlayer());
|
FPlayer fplayer = FPlayers.getInstance().getByPlayer(event.getPlayer());
|
||||||
if (fplayer != null) {
|
if (fplayer != null) {
|
||||||
|
|||||||
@@ -7,7 +7,7 @@ import com.massivecraft.factions.util.MiscUtil;
|
|||||||
import com.massivecraft.factions.zcore.util.TL;
|
import com.massivecraft.factions.zcore.util.TL;
|
||||||
import org.bukkit.Bukkit;
|
import org.bukkit.Bukkit;
|
||||||
import org.bukkit.Location;
|
import org.bukkit.Location;
|
||||||
import org.bukkit.TravelAgent;
|
import org.bukkit.Material;
|
||||||
import org.bukkit.block.Block;
|
import org.bukkit.block.Block;
|
||||||
import org.bukkit.entity.*;
|
import org.bukkit.entity.*;
|
||||||
import org.bukkit.entity.minecart.ExplosiveMinecart;
|
import org.bukkit.entity.minecart.ExplosiveMinecart;
|
||||||
@@ -20,7 +20,6 @@ import org.bukkit.event.hanging.HangingBreakEvent;
|
|||||||
import org.bukkit.event.hanging.HangingBreakEvent.RemoveCause;
|
import org.bukkit.event.hanging.HangingBreakEvent.RemoveCause;
|
||||||
import org.bukkit.event.hanging.HangingPlaceEvent;
|
import org.bukkit.event.hanging.HangingPlaceEvent;
|
||||||
import org.bukkit.event.player.PlayerInteractEntityEvent;
|
import org.bukkit.event.player.PlayerInteractEntityEvent;
|
||||||
import org.bukkit.event.player.PlayerPortalEvent;
|
|
||||||
import org.bukkit.potion.PotionEffect;
|
import org.bukkit.potion.PotionEffect;
|
||||||
import org.bukkit.potion.PotionEffectType;
|
import org.bukkit.potion.PotionEffectType;
|
||||||
import org.bukkit.projectiles.ProjectileSource;
|
import org.bukkit.projectiles.ProjectileSource;
|
||||||
@@ -155,16 +154,17 @@ public class FactionsEntityListener implements Listener {
|
|||||||
|
|
||||||
// Run the check for a player
|
// Run the check for a player
|
||||||
if (damager instanceof Player) {
|
if (damager instanceof Player) {
|
||||||
// Generate the action message.
|
Player player = (Player) damager;
|
||||||
String entityAction;
|
Material material = null;
|
||||||
|
switch (sub.getEntity().getType()) {
|
||||||
if (damagee.getType() == EntityType.ITEM_FRAME) {
|
case ITEM_FRAME:
|
||||||
entityAction = "item frames";
|
material = Material.ITEM_FRAME;
|
||||||
} else {
|
break;
|
||||||
entityAction = "armor stands";
|
case ARMOR_STAND:
|
||||||
|
material = Material.ARMOR_STAND;
|
||||||
|
break;
|
||||||
}
|
}
|
||||||
|
if (material != null && !FactionsBlockListener.playerCanBuildDestroyBlock(player, damagee.getLocation(), "destroy " + material.toString().toLowerCase(), false)) {
|
||||||
if (!FactionsBlockListener.playerCanBuildDestroyBlock((Player) damager, damagee.getLocation(), "destroy " + entityAction, false)) {
|
|
||||||
event.setCancelled(true);
|
event.setCancelled(true);
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
|
|||||||
@@ -1,7 +1,6 @@
|
|||||||
package com.massivecraft.factions.listeners;
|
package com.massivecraft.factions.listeners;
|
||||||
|
|
||||||
import com.massivecraft.factions.Conf;
|
import com.massivecraft.factions.Conf;
|
||||||
import com.massivecraft.factions.FactionsPlugin;
|
|
||||||
import com.massivecraft.factions.util.XMaterial;
|
import com.massivecraft.factions.util.XMaterial;
|
||||||
import org.bukkit.Location;
|
import org.bukkit.Location;
|
||||||
import org.bukkit.Material;
|
import org.bukkit.Material;
|
||||||
|
|||||||
@@ -53,12 +53,14 @@ import java.util.logging.Level;
|
|||||||
|
|
||||||
public class FactionsPlayerListener implements Listener {
|
public class FactionsPlayerListener implements Listener {
|
||||||
|
|
||||||
|
public static Set<FLocation> corners;
|
||||||
|
public static BukkitTask positionTask = null;
|
||||||
|
public static Map<UUID, Location> lastLocations = new HashMap<>();
|
||||||
/**
|
/**
|
||||||
* @author FactionsUUID Team
|
* @author FactionsUUID Team
|
||||||
*/
|
*/
|
||||||
|
|
||||||
HashMap<Player, Boolean> fallMap = new HashMap<>();
|
HashMap<Player, Boolean> fallMap = new HashMap<>();
|
||||||
public static Set<FLocation> corners;
|
|
||||||
// Holds the next time a player can have a map shown.
|
// Holds the next time a player can have a map shown.
|
||||||
private HashMap<UUID, Long> showTimes = new HashMap<>();
|
private HashMap<UUID, Long> showTimes = new HashMap<>();
|
||||||
|
|
||||||
@@ -225,7 +227,6 @@ public class FactionsPlayerListener implements Listener {
|
|||||||
return CheckPlayerAccess(player, me, loc, myFaction, otherFaction.getAccess(me, action), action, Conf.territoryPainBuild);
|
return CheckPlayerAccess(player, me, loc, myFaction, otherFaction.getAccess(me, action), action, Conf.territoryPainBuild);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
public static boolean preventCommand(String fullCmd, Player player) {
|
public static boolean preventCommand(String fullCmd, Player player) {
|
||||||
if ((Conf.territoryNeutralDenyCommands.isEmpty() && Conf.territoryEnemyDenyCommands.isEmpty() && Conf.permanentFactionMemberDenyCommands.isEmpty() && Conf.warzoneDenyCommands.isEmpty())) {
|
if ((Conf.territoryNeutralDenyCommands.isEmpty() && Conf.territoryEnemyDenyCommands.isEmpty() && Conf.permanentFactionMemberDenyCommands.isEmpty() && Conf.warzoneDenyCommands.isEmpty())) {
|
||||||
return false;
|
return false;
|
||||||
@@ -261,7 +262,7 @@ public class FactionsPlayerListener implements Listener {
|
|||||||
Relation rel = at.getRelationTo(me);
|
Relation rel = at.getRelationTo(me);
|
||||||
if (at.isNormal() && rel.isAlly() && !Conf.territoryAllyDenyCommands.isEmpty() && !me.isAdminBypassing() && isCommandInList(fullCmd, shortCmd, Conf.territoryAllyDenyCommands.iterator())) {
|
if (at.isNormal() && rel.isAlly() && !Conf.territoryAllyDenyCommands.isEmpty() && !me.isAdminBypassing() && isCommandInList(fullCmd, shortCmd, Conf.territoryAllyDenyCommands.iterator())) {
|
||||||
me.msg(TL.PLAYER_COMMAND_ALLY, fullCmd);
|
me.msg(TL.PLAYER_COMMAND_ALLY, fullCmd);
|
||||||
return false;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (at.isNormal() && rel.isNeutral() && !Conf.territoryNeutralDenyCommands.isEmpty() && !me.isAdminBypassing() && isCommandInList(fullCmd, shortCmd, Conf.territoryNeutralDenyCommands.iterator())) {
|
if (at.isNormal() && rel.isNeutral() && !Conf.territoryNeutralDenyCommands.isEmpty() && !me.isAdminBypassing() && isCommandInList(fullCmd, shortCmd, Conf.territoryNeutralDenyCommands.iterator())) {
|
||||||
@@ -338,7 +339,7 @@ public class FactionsPlayerListener implements Listener {
|
|||||||
return PermissableAction.DOOR;
|
return PermissableAction.DOOR;
|
||||||
if (material.name().toUpperCase().contains("BUTTON") || material.name().toUpperCase().contains("PRESSURE") || material.name().contains("DIODE") || material.name().contains("COMPARATOR"))
|
if (material.name().toUpperCase().contains("BUTTON") || material.name().toUpperCase().contains("PRESSURE") || material.name().contains("DIODE") || material.name().contains("COMPARATOR"))
|
||||||
return PermissableAction.BUTTON;
|
return PermissableAction.BUTTON;
|
||||||
if (FactionsPlugin.instance.mc113 || FactionsPlugin.instance.mc114) {
|
if (FactionsPlugin.instance.mc113 || FactionsPlugin.instance.mc114 || FactionsPlugin.getInstance().mc115) {
|
||||||
switch (material) {
|
switch (material) {
|
||||||
case LEVER:
|
case LEVER:
|
||||||
return PermissableAction.LEVER;
|
return PermissableAction.LEVER;
|
||||||
@@ -381,6 +382,8 @@ public class FactionsPlayerListener implements Listener {
|
|||||||
case TRAPPED_CHEST:
|
case TRAPPED_CHEST:
|
||||||
case CHEST_MINECART:
|
case CHEST_MINECART:
|
||||||
|
|
||||||
|
case BARREL:
|
||||||
|
|
||||||
case SHULKER_BOX:
|
case SHULKER_BOX:
|
||||||
case BLACK_SHULKER_BOX:
|
case BLACK_SHULKER_BOX:
|
||||||
case BLUE_SHULKER_BOX:
|
case BLUE_SHULKER_BOX:
|
||||||
@@ -400,6 +403,8 @@ public class FactionsPlayerListener implements Listener {
|
|||||||
case YELLOW_SHULKER_BOX:
|
case YELLOW_SHULKER_BOX:
|
||||||
|
|
||||||
case FURNACE:
|
case FURNACE:
|
||||||
|
case BLAST_FURNACE:
|
||||||
|
case SMOKER:
|
||||||
case DROPPER:
|
case DROPPER:
|
||||||
case DISPENSER:
|
case DISPENSER:
|
||||||
case ENCHANTING_TABLE:
|
case ENCHANTING_TABLE:
|
||||||
@@ -439,6 +444,8 @@ public class FactionsPlayerListener implements Listener {
|
|||||||
case ENCHANTING_TABLE:
|
case ENCHANTING_TABLE:
|
||||||
case DROPPER:
|
case DROPPER:
|
||||||
case FURNACE:
|
case FURNACE:
|
||||||
|
case BLAST_FURNACE:
|
||||||
|
case SMOKER:
|
||||||
case HOPPER:
|
case HOPPER:
|
||||||
case ANVIL:
|
case ANVIL:
|
||||||
case CHIPPED_ANVIL:
|
case CHIPPED_ANVIL:
|
||||||
@@ -552,7 +559,6 @@ public class FactionsPlayerListener implements Listener {
|
|||||||
|
|
||||||
public String parseAllPlaceholders(String string, Faction faction, Player player) {
|
public String parseAllPlaceholders(String string, Faction faction, Player player) {
|
||||||
string = TagUtil.parsePlaceholders(player, string);
|
string = TagUtil.parsePlaceholders(player, string);
|
||||||
|
|
||||||
string = string.replace("{Faction}", faction.getTag())
|
string = string.replace("{Faction}", faction.getTag())
|
||||||
.replace("{online}", faction.getOnlinePlayers().size() + "")
|
.replace("{online}", faction.getOnlinePlayers().size() + "")
|
||||||
.replace("{offline}", faction.getFPlayers().size() - faction.getOnlinePlayers().size() + "")
|
.replace("{offline}", faction.getFPlayers().size() - faction.getOnlinePlayers().size() + "")
|
||||||
@@ -563,27 +569,19 @@ public class FactionsPlayerListener implements Listener {
|
|||||||
}
|
}
|
||||||
|
|
||||||
public void checkCanFly(FPlayer me) {
|
public void checkCanFly(FPlayer me) {
|
||||||
|
if (!FactionsPlugin.getInstance().getConfig().getBoolean("enable-faction-flight")) return;
|
||||||
if (me.isFlying() && (!me.canFlyAtLocation() || me.checkIfNearbyEnemies())) {
|
if (me.isFlying() && (!me.canFlyAtLocation() || me.checkIfNearbyEnemies())) {
|
||||||
me.setFFlying(false, false);
|
me.setFFlying(false, false);
|
||||||
me.msg(TL.COMMAND_FLY_NO_ACCESS, Board.getInstance().getFactionAt(me.getLastStoodAt()).getTag());
|
me.msg(TL.COMMAND_FLY_NO_ACCESS, Board.getInstance().getFactionAt(me.getLastStoodAt()).getTag());
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
if (me.isFlying() || !FactionsPlugin.instance.getConfig().getBoolean("ffly.AutoEnable"))
|
if (me.isFlying() || !FactionsPlugin.instance.getConfig().getBoolean("ffly.AutoEnable")) return;
|
||||||
return;
|
|
||||||
me.setFFlying(true, false);
|
me.setFFlying(true, false);
|
||||||
CmdFly.flyMap.put(me.getName(), true);
|
CmdFly.flyMap.put(me.getName(), true);
|
||||||
if (CmdFly.particleTask == null)
|
if (CmdFly.particleTask == null)
|
||||||
CmdFly.startParticles();
|
CmdFly.startParticles();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@EventHandler
|
|
||||||
public void onCommand(PlayerCommandPreprocessEvent e){
|
|
||||||
if(e.getMessage().equalsIgnoreCase("/f outpost")){
|
|
||||||
e.setMessage("/outpost");
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
//inspect
|
//inspect
|
||||||
@EventHandler
|
@EventHandler
|
||||||
public void onInspect(PlayerInteractEvent e) {
|
public void onInspect(PlayerInteractEvent e) {
|
||||||
@@ -646,9 +644,6 @@ public class FactionsPlayerListener implements Listener {
|
|||||||
return (result.length() == 3 ? result + "0" : result) + "/hrs ago";
|
return (result.length() == 3 ? result + "0" : result) + "/hrs ago";
|
||||||
}
|
}
|
||||||
|
|
||||||
public static BukkitTask positionTask = null;
|
|
||||||
public static Map<UUID, Location> lastLocations = new HashMap<>();
|
|
||||||
|
|
||||||
public void startPositionCheck() {
|
public void startPositionCheck() {
|
||||||
positionTask = Bukkit.getScheduler().runTaskTimer(FactionsPlugin.instance, () -> {
|
positionTask = Bukkit.getScheduler().runTaskTimer(FactionsPlugin.instance, () -> {
|
||||||
if (Bukkit.getOnlinePlayers().size() > 0) {
|
if (Bukkit.getOnlinePlayers().size() > 0) {
|
||||||
@@ -677,7 +672,7 @@ public class FactionsPlayerListener implements Listener {
|
|||||||
if (!fPlayer.checkIfNearbyEnemies()) {
|
if (!fPlayer.checkIfNearbyEnemies()) {
|
||||||
FLocation myFloc = new FLocation(player.getLocation());
|
FLocation myFloc = new FLocation(player.getLocation());
|
||||||
if (Board.getInstance().getFactionAt(myFloc) != myFaction) {
|
if (Board.getInstance().getFactionAt(myFloc) != myFaction) {
|
||||||
if (!CmdFly.checkBypassPerms(fPlayer, player, Board.getInstance().getFactionAt(myFloc))) {
|
if (!CmdFly.checkFly(fPlayer, player, Board.getInstance().getFactionAt(myFloc))) {
|
||||||
fPlayer.setFFlying(false, false);
|
fPlayer.setFFlying(false, false);
|
||||||
CmdFly.flyMap.remove(name);
|
CmdFly.flyMap.remove(name);
|
||||||
}
|
}
|
||||||
@@ -827,8 +822,8 @@ public class FactionsPlayerListener implements Listener {
|
|||||||
|
|
||||||
Material type;
|
Material type;
|
||||||
if (event.getItem() != null) {
|
if (event.getItem() != null) {
|
||||||
// Convert 1.8 Material Names -> 1.14
|
// Convert 1.8 Material Names -> 1.15
|
||||||
type = XMaterial.matchXMaterial(event.getItem().getType().toString()).parseMaterial();
|
type = XMaterial.matchXMaterial(event.getItem().getType().toString()).get().parseMaterial();
|
||||||
} else {
|
} else {
|
||||||
type = null;
|
type = null;
|
||||||
}
|
}
|
||||||
@@ -927,13 +922,21 @@ public class FactionsPlayerListener implements Listener {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@EventHandler
|
@EventHandler
|
||||||
public void onLogoutMove(PlayerMoveEvent e) {
|
public void onLogoutMove(PlayerMoveEvent e) {
|
||||||
LogoutHandler handler = LogoutHandler.getByName(e.getPlayer().getName());
|
LogoutHandler handler = LogoutHandler.getByName(e.getPlayer().getName());
|
||||||
|
|
||||||
|
if (Objects.requireNonNull(e.getTo()).getBlockX() == e.getFrom().getBlockX() &&
|
||||||
|
e.getTo().getBlockY() == e.getFrom().getBlockY() &&
|
||||||
|
e.getTo().getBlockZ() == e.getFrom().getBlockZ())
|
||||||
|
return;
|
||||||
|
|
||||||
if (handler.isLogoutActive(e.getPlayer())) {
|
if (handler.isLogoutActive(e.getPlayer())) {
|
||||||
handler.cancelLogout(e.getPlayer());
|
handler.cancelLogout(e.getPlayer());
|
||||||
e.getPlayer().sendMessage(String.valueOf(TL.COMMAND_LOGOUT_MOVED));
|
e.getPlayer().sendMessage(String.valueOf(TL.COMMAND_LOGOUT_MOVED));
|
||||||
}
|
}
|
||||||
|
|
||||||
if (CmdWild.waitingTeleport.containsKey(e.getPlayer())) {
|
if (CmdWild.waitingTeleport.containsKey(e.getPlayer())) {
|
||||||
CmdWild.waitingTeleport.remove(e.getPlayer());
|
CmdWild.waitingTeleport.remove(e.getPlayer());
|
||||||
FPlayers.getInstance().getByPlayer(e.getPlayer()).msg(TL.COMMAND_WILD_INTERUPTED);
|
FPlayers.getInstance().getByPlayer(e.getPlayer()).msg(TL.COMMAND_WILD_INTERUPTED);
|
||||||
|
|||||||
@@ -13,6 +13,7 @@ import org.bukkit.inventory.Inventory;
|
|||||||
import org.bukkit.inventory.ItemFlag;
|
import org.bukkit.inventory.ItemFlag;
|
||||||
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.*;
|
import java.util.*;
|
||||||
|
|
||||||
public class MissionGUI implements FactionGUI {
|
public class MissionGUI implements FactionGUI {
|
||||||
@@ -56,7 +57,9 @@ public class MissionGUI implements FactionGUI {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
} else if (plugin.getConfig().getBoolean("Randomization.Enabled")) {return;}
|
} else if (plugin.getConfig().getBoolean("Randomization.Enabled")) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
if (configurationSection == null) return;
|
if (configurationSection == null) return;
|
||||||
|
|
||||||
int max = plugin.getConfig().getInt("MaximumMissionsAllowedAtOnce");
|
int max = plugin.getConfig().getInt("MaximumMissionsAllowedAtOnce");
|
||||||
@@ -64,7 +67,8 @@ public class MissionGUI implements FactionGUI {
|
|||||||
fPlayer.msg(TL.MISSION_MISSION_MAX_ALLOWED, max);
|
fPlayer.msg(TL.MISSION_MISSION_MAX_ALLOWED, max);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
if (missionName.equals(plugin.color(FactionsPlugin.getInstance().getConfig().getString("Randomization.Start-Item.Disallowed.Name")))) return;
|
if (missionName.equals(plugin.color(FactionsPlugin.getInstance().getConfig().getString("Randomization.Start-Item.Disallowed.Name"))))
|
||||||
|
return;
|
||||||
|
|
||||||
if (fPlayer.getFaction().getMissions().containsKey(missionName)) {
|
if (fPlayer.getFaction().getMissions().containsKey(missionName)) {
|
||||||
fPlayer.msg(TL.MISSION_MISSION_ACTIVE);
|
fPlayer.msg(TL.MISSION_MISSION_ACTIVE);
|
||||||
@@ -96,7 +100,7 @@ public class MissionGUI implements FactionGUI {
|
|||||||
if (configurationSection == null) {
|
if (configurationSection == null) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
ItemStack fillItem = XMaterial.matchXMaterial(configurationSection.getString("FillItem.Material")).parseItem();
|
ItemStack fillItem = XMaterial.matchXMaterial(configurationSection.getString("FillItem.Material")).get().parseItem();
|
||||||
ItemMeta fillmeta = fillItem.getItemMeta();
|
ItemMeta fillmeta = fillItem.getItemMeta();
|
||||||
fillmeta.setDisplayName("");
|
fillmeta.setDisplayName("");
|
||||||
fillItem.setItemMeta(fillmeta);
|
fillItem.setItemMeta(fillmeta);
|
||||||
@@ -109,7 +113,7 @@ public class MissionGUI implements FactionGUI {
|
|||||||
ConfigurationSection section = configurationSection.getConfigurationSection(key);
|
ConfigurationSection section = configurationSection.getConfigurationSection(key);
|
||||||
int slot = section.getInt("Slot");
|
int slot = section.getInt("Slot");
|
||||||
|
|
||||||
ItemStack itemStack = XMaterial.matchXMaterial(section.getString("Material")).parseItem();
|
ItemStack itemStack = XMaterial.matchXMaterial(section.getString("Material")).get().parseItem();
|
||||||
ItemMeta itemMeta = itemStack.getItemMeta();
|
ItemMeta itemMeta = itemStack.getItemMeta();
|
||||||
itemMeta.setDisplayName(ChatColor.translateAlternateColorCodes('&', section.getString("Name")));
|
itemMeta.setDisplayName(ChatColor.translateAlternateColorCodes('&', section.getString("Name")));
|
||||||
List<String> loreLines = new ArrayList<>();
|
List<String> loreLines = new ArrayList<>();
|
||||||
@@ -134,7 +138,7 @@ public class MissionGUI implements FactionGUI {
|
|||||||
if (plugin.getConfig().getBoolean("Randomization.Enabled")) {
|
if (plugin.getConfig().getBoolean("Randomization.Enabled")) {
|
||||||
ItemStack start;
|
ItemStack start;
|
||||||
ItemMeta meta;
|
ItemMeta meta;
|
||||||
start = XMaterial.matchXMaterial(plugin.getConfig().getString("Randomization.Start-Item.Allowed.Material")).parseItem();
|
start = XMaterial.matchXMaterial(plugin.getConfig().getString("Randomization.Start-Item.Allowed.Material")).get().parseItem();
|
||||||
meta = start.getItemMeta();
|
meta = start.getItemMeta();
|
||||||
meta.setDisplayName(plugin.color(plugin.getConfig().getString("Randomization.Start-Item.Allowed.Name")));
|
meta.setDisplayName(plugin.color(plugin.getConfig().getString("Randomization.Start-Item.Allowed.Name")));
|
||||||
List<String> loree = new ArrayList<>();
|
List<String> loree = new ArrayList<>();
|
||||||
@@ -144,7 +148,7 @@ public class MissionGUI implements FactionGUI {
|
|||||||
meta.setLore(loree);
|
meta.setLore(loree);
|
||||||
start.setItemMeta(meta);
|
start.setItemMeta(meta);
|
||||||
if (fPlayer.getFaction().getCompletedMissions().size() >= configurationSection.getKeys(false).size() - 1 && plugin.getConfig().getBoolean("DenyMissionsMoreThenOnce")) {
|
if (fPlayer.getFaction().getCompletedMissions().size() >= configurationSection.getKeys(false).size() - 1 && plugin.getConfig().getBoolean("DenyMissionsMoreThenOnce")) {
|
||||||
start = XMaterial.matchXMaterial(plugin.getConfig().getString("Randomization.Start-Item.Disallowed.Material")).parseItem();
|
start = XMaterial.matchXMaterial(plugin.getConfig().getString("Randomization.Start-Item.Disallowed.Material")).get().parseItem();
|
||||||
meta = start.getItemMeta();
|
meta = start.getItemMeta();
|
||||||
meta.setDisplayName(plugin.color(plugin.getConfig().getString("Randomization.Start-Item.Disallowed.Name")));
|
meta.setDisplayName(plugin.color(plugin.getConfig().getString("Randomization.Start-Item.Disallowed.Name")));
|
||||||
List<String> lore = new ArrayList<>();
|
List<String> lore = new ArrayList<>();
|
||||||
@@ -155,7 +159,7 @@ public class MissionGUI implements FactionGUI {
|
|||||||
start.setItemMeta(meta);
|
start.setItemMeta(meta);
|
||||||
}
|
}
|
||||||
if (fPlayer.getFaction().getMissions().size() >= plugin.getConfig().getInt("MaximumMissionsAllowedAtOnce")) {
|
if (fPlayer.getFaction().getMissions().size() >= plugin.getConfig().getInt("MaximumMissionsAllowedAtOnce")) {
|
||||||
start = XMaterial.matchXMaterial(plugin.getConfig().getString("Randomization.Start-Item.Disallowed.Material")).parseItem();
|
start = XMaterial.matchXMaterial(plugin.getConfig().getString("Randomization.Start-Item.Disallowed.Material")).get().parseItem();
|
||||||
meta = start.getItemMeta();
|
meta = start.getItemMeta();
|
||||||
meta.setDisplayName(plugin.color(plugin.getConfig().getString("Randomization.Start-Item.Disallowed.Name")));
|
meta.setDisplayName(plugin.color(plugin.getConfig().getString("Randomization.Start-Item.Disallowed.Name")));
|
||||||
List<String> lore = new ArrayList<>();
|
List<String> lore = new ArrayList<>();
|
||||||
|
|||||||
@@ -47,7 +47,7 @@ public class ShopGUIFrame {
|
|||||||
for (int a = 1; a <= items; a++) {
|
for (int a = 1; a <= items; a++) {
|
||||||
String s = a + "";
|
String s = a + "";
|
||||||
int slot = ShopConfig.getShop().getInt("items." + s + ".slot");
|
int slot = ShopConfig.getShop().getInt("items." + s + ".slot");
|
||||||
Material material = XMaterial.matchXMaterial(ShopConfig.getShop().getString("items." + s + ".block")).parseMaterial();
|
Material material = XMaterial.matchXMaterial(ShopConfig.getShop().getString("items." + s + ".block")).get().parseMaterial();
|
||||||
int cost = ShopConfig.getShop().getInt("items." + s + ".cost");
|
int cost = ShopConfig.getShop().getInt("items." + s + ".cost");
|
||||||
String name = ShopConfig.getShop().getString("items." + s + ".name");
|
String name = ShopConfig.getShop().getString("items." + s + ".name");
|
||||||
boolean glowing = ShopConfig.getShop().getBoolean("items." + s + ".glowing");
|
boolean glowing = ShopConfig.getShop().getBoolean("items." + s + ".glowing");
|
||||||
@@ -62,19 +62,12 @@ public class ShopGUIFrame {
|
|||||||
meta.addItemFlags(ItemFlag.HIDE_ENCHANTS);
|
meta.addItemFlags(ItemFlag.HIDE_ENCHANTS);
|
||||||
meta.addEnchant(Enchantment.DURABILITY, 1, true);
|
meta.addEnchant(Enchantment.DURABILITY, 1, true);
|
||||||
}
|
}
|
||||||
if (!glowing) {
|
if (!glowing) meta.removeEnchant(Enchantment.DURABILITY);
|
||||||
meta.removeEnchant(Enchantment.DURABILITY);
|
|
||||||
}
|
|
||||||
|
|
||||||
List<String> replacedLore = lore.stream().map(t -> t.replace("{cost}", cost + "")).collect(Collectors.toList());
|
List<String> replacedLore = lore.stream().map(t -> t.replace("{cost}", cost + "")).collect(Collectors.toList());
|
||||||
|
|
||||||
meta.setLore(FactionsPlugin.instance.colorList(replacedLore));
|
meta.setLore(FactionsPlugin.instance.colorList(replacedLore));
|
||||||
|
|
||||||
item.setItemMeta(meta);
|
item.setItemMeta(meta);
|
||||||
|
|
||||||
GUIItems.set(slot, new GuiItem(item, e -> {
|
GUIItems.set(slot, new GuiItem(item, e -> {
|
||||||
e.setCancelled(true);
|
e.setCancelled(true);
|
||||||
|
|
||||||
FPlayer fme = FPlayers.getInstance().getByPlayer((Player) e.getWhoClicked());
|
FPlayer fme = FPlayers.getInstance().getByPlayer((Player) e.getWhoClicked());
|
||||||
if (fplayer.getFaction().getPoints() >= cost) {
|
if (fplayer.getFaction().getPoints() >= cost) {
|
||||||
fplayer.getFaction().setPoints(fplayer.getFaction().getPoints() - cost);
|
fplayer.getFaction().setPoints(fplayer.getFaction().getPoints() - cost);
|
||||||
@@ -100,7 +93,7 @@ public class ShopGUIFrame {
|
|||||||
|
|
||||||
private ItemStack buildDummyItem(Faction f) {
|
private ItemStack buildDummyItem(Faction f) {
|
||||||
ConfigurationSection config = FactionsPlugin.getInstance().getConfig().getConfigurationSection("F-Shop.GUI.dummy-item");
|
ConfigurationSection config = FactionsPlugin.getInstance().getConfig().getConfigurationSection("F-Shop.GUI.dummy-item");
|
||||||
ItemStack item = XMaterial.matchXMaterial(config.getString("Type")).parseItem();
|
ItemStack item = XMaterial.matchXMaterial(config.getString("Type")).get().parseItem();
|
||||||
ItemMeta meta = item.getItemMeta();
|
ItemMeta meta = item.getItemMeta();
|
||||||
if (meta != null) {
|
if (meta != null) {
|
||||||
meta.setLore(FactionsPlugin.getInstance().colorList(config.getStringList("Lore")));
|
meta.setLore(FactionsPlugin.getInstance().colorList(config.getStringList("Lore")));
|
||||||
|
|||||||
@@ -28,6 +28,7 @@ public enum Permission {
|
|||||||
CHECK("check"),
|
CHECK("check"),
|
||||||
CLAIM("claim"),
|
CLAIM("claim"),
|
||||||
CLAIMAT("claimat"),
|
CLAIMAT("claimat"),
|
||||||
|
CLAIM_FILL("claimfill"),
|
||||||
CLAIM_LINE("claim.line"),
|
CLAIM_LINE("claim.line"),
|
||||||
CLAIM_RADIUS("claim.radius"),
|
CLAIM_RADIUS("claim.radius"),
|
||||||
CONFIG("config"),
|
CONFIG("config"),
|
||||||
@@ -44,8 +45,8 @@ public enum Permission {
|
|||||||
DISBAND_ANY("disband.any"),
|
DISBAND_ANY("disband.any"),
|
||||||
DISCORD("discord"),
|
DISCORD("discord"),
|
||||||
DRAIN("drain"),
|
DRAIN("drain"),
|
||||||
FLY("fly"),
|
FLY_FLY("fly"),
|
||||||
FLY_WILD("fly.wilderness"),
|
FLY_WILDERNESS("fly.wilderness"),
|
||||||
FLY_SAFEZONE("fly.safezone"),
|
FLY_SAFEZONE("fly.safezone"),
|
||||||
FLY_WARZONE("fly.warzone"),
|
FLY_WARZONE("fly.warzone"),
|
||||||
FLY_ENEMY("fly.enemy"),
|
FLY_ENEMY("fly.enemy"),
|
||||||
|
|||||||
@@ -210,7 +210,7 @@ public enum Relation implements Permissable {
|
|||||||
String displayName = replacePlaceholders(RELATION_CONFIG.getString("placeholder-item.name", ""));
|
String displayName = replacePlaceholders(RELATION_CONFIG.getString("placeholder-item.name", ""));
|
||||||
List<String> lore = new ArrayList<>();
|
List<String> lore = new ArrayList<>();
|
||||||
|
|
||||||
Material material = XMaterial.matchXMaterial(RELATION_CONFIG.getString("materials." + name().toLowerCase())).parseMaterial();
|
Material material = XMaterial.matchXMaterial(RELATION_CONFIG.getString("materials." + name().toLowerCase())).get().parseMaterial();
|
||||||
if (material == null) {
|
if (material == null) {
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -128,7 +128,7 @@ public enum Role implements Permissable {
|
|||||||
String displayName = replacePlaceholders(RELATION_CONFIG.getString("placeholder-item.name", ""));
|
String displayName = replacePlaceholders(RELATION_CONFIG.getString("placeholder-item.name", ""));
|
||||||
List<String> lore = new ArrayList<>();
|
List<String> lore = new ArrayList<>();
|
||||||
|
|
||||||
Material material = XMaterial.matchXMaterial(RELATION_CONFIG.getString("materials." + name().toLowerCase(), "STAINED_CLAY")).parseMaterial();
|
Material material = XMaterial.matchXMaterial(RELATION_CONFIG.getString("materials." + name().toLowerCase(), "STAINED_CLAY")).get().parseMaterial();
|
||||||
if (material == null) {
|
if (material == null) {
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -49,6 +49,10 @@ public enum FactionTag implements Tag {
|
|||||||
}
|
}
|
||||||
return null;
|
return null;
|
||||||
}),
|
}),
|
||||||
|
|
||||||
|
ANNOUNCEMENT("{announcement}", (fac) -> {
|
||||||
|
return String.valueOf(fac.getAnnouncements());
|
||||||
|
}),
|
||||||
PEACEFUL("{peaceful}", (fac) -> fac.isPeaceful() ? Conf.colorNeutral + TL.COMMAND_SHOW_PEACEFUL.toString() : ""),
|
PEACEFUL("{peaceful}", (fac) -> fac.isPeaceful() ? Conf.colorNeutral + TL.COMMAND_SHOW_PEACEFUL.toString() : ""),
|
||||||
PERMANENT("permanent", (fac) -> fac.isPermanent() ? "permanent" : "{notPermanent}"), // no braces needed
|
PERMANENT("permanent", (fac) -> fac.isPermanent() ? "permanent" : "{notPermanent}"), // no braces needed
|
||||||
LAND_VALUE("{land-value}", (fac) -> Econ.shouldBeUsed() ? Econ.moneyString(Econ.calculateTotalLandValue(fac.getLandRounded())) : Tag.isMinimalShow() ? null : TL.ECON_OFF.format("value")),
|
LAND_VALUE("{land-value}", (fac) -> Econ.shouldBeUsed() ? Econ.moneyString(Econ.calculateTotalLandValue(fac.getLandRounded())) : Tag.isMinimalShow() ? null : TL.ECON_OFF.format("value")),
|
||||||
@@ -61,6 +65,19 @@ public enum FactionTag implements Tag {
|
|||||||
}
|
}
|
||||||
return Tag.isMinimalShow() ? null : TL.ECON_OFF.format("balance");
|
return Tag.isMinimalShow() ? null : TL.ECON_OFF.format("balance");
|
||||||
}),
|
}),
|
||||||
|
TNT_BALANCE("{tnt-balance}", (fac) -> {
|
||||||
|
if (FactionsPlugin.instance.getConfig().getBoolean("ftnt.Enabled")) {
|
||||||
|
return String.valueOf(fac.getTnt());
|
||||||
|
}
|
||||||
|
return Tag.isMinimalShow() ? null : "";
|
||||||
|
}),
|
||||||
|
TNT_MAX("{tnt-max-balance}", (fac) -> {
|
||||||
|
if (FactionsPlugin.instance.getConfig().getBoolean("ftnt.Enabled")) {
|
||||||
|
return String.valueOf(fac.getTntBankLimit());
|
||||||
|
}
|
||||||
|
return Tag.isMinimalShow() ? null : "";
|
||||||
|
}),
|
||||||
|
|
||||||
ALLIES_COUNT("{allies}", (fac) -> String.valueOf(fac.getRelationCount(Relation.ALLY))),
|
ALLIES_COUNT("{allies}", (fac) -> String.valueOf(fac.getRelationCount(Relation.ALLY))),
|
||||||
ENEMIES_COUNT("{enemies}", (fac) -> String.valueOf(fac.getRelationCount(Relation.ENEMY))),
|
ENEMIES_COUNT("{enemies}", (fac) -> String.valueOf(fac.getRelationCount(Relation.ENEMY))),
|
||||||
TRUCES_COUNT("{truces}", (fac) -> String.valueOf(fac.getRelationCount(Relation.TRUCE))),
|
TRUCES_COUNT("{truces}", (fac) -> String.valueOf(fac.getRelationCount(Relation.TRUCE))),
|
||||||
@@ -80,6 +97,8 @@ public enum FactionTag implements Tag {
|
|||||||
return String.valueOf(fac.getFPlayersWhereOnline(false).size());
|
return String.valueOf(fac.getFPlayersWhereOnline(false).size());
|
||||||
}
|
}
|
||||||
}),
|
}),
|
||||||
|
FACTION_STRIKES("{faction-strikes}", (fac) -> String.valueOf(fac.getStrikes())),
|
||||||
|
FACTION_POINTS("{faction-points}", (fac) -> String.valueOf(fac.getPoints())),
|
||||||
FACTION_SIZE("{members}", (fac) -> String.valueOf(fac.getFPlayers().size())),
|
FACTION_SIZE("{members}", (fac) -> String.valueOf(fac.getFPlayers().size())),
|
||||||
FACTION_KILLS("{faction-kills}", (fac) -> String.valueOf(fac.getKills())),
|
FACTION_KILLS("{faction-kills}", (fac) -> String.valueOf(fac.getKills())),
|
||||||
FACTION_DEATHS("{faction-deaths}", (fac) -> String.valueOf(fac.getDeaths())),
|
FACTION_DEATHS("{faction-deaths}", (fac) -> String.valueOf(fac.getDeaths())),
|
||||||
|
|||||||
@@ -100,7 +100,7 @@ public enum FancyTag implements Tag {
|
|||||||
return tag.getMessage(text, faction, player, groupMap);
|
return tag.getMessage(text, faction, player, groupMap);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return Collections.EMPTY_LIST; // We really shouldn't be here.
|
return Collections.emptyList(); // We really shouldn't be here.
|
||||||
}
|
}
|
||||||
|
|
||||||
public static boolean anyMatch(String text) {
|
public static boolean anyMatch(String text) {
|
||||||
@@ -174,7 +174,7 @@ public enum FancyTag implements Tag {
|
|||||||
return test != null && test.contains(this.tag);
|
return test != null && test.contains(this.tag);
|
||||||
}
|
}
|
||||||
|
|
||||||
public List<FancyMessage> getMessage(String text, Faction faction, FPlayer player, Map<UUID, String> groupMap) {
|
public List getMessage(String text, Faction faction, FPlayer player, Map<UUID, String> groupMap) {
|
||||||
if (!this.foundInString(text)) {
|
if (!this.foundInString(text)) {
|
||||||
return Collections.EMPTY_LIST; // We really, really shouldn't be here.
|
return Collections.EMPTY_LIST; // We really, really shouldn't be here.
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,7 +1,6 @@
|
|||||||
package com.massivecraft.factions.tag;
|
package com.massivecraft.factions.tag;
|
||||||
|
|
||||||
import com.massivecraft.factions.FPlayers;
|
import com.massivecraft.factions.FPlayers;
|
||||||
import com.massivecraft.factions.Factions;
|
|
||||||
import com.massivecraft.factions.FactionsPlugin;
|
import com.massivecraft.factions.FactionsPlugin;
|
||||||
import com.massivecraft.factions.zcore.util.TL;
|
import com.massivecraft.factions.zcore.util.TL;
|
||||||
import org.bukkit.Bukkit;
|
import org.bukkit.Bukkit;
|
||||||
@@ -18,8 +17,8 @@ public enum GeneralTag implements Tag {
|
|||||||
MAX_ALLIES("{max-allies}", () -> getRelation("ally")),
|
MAX_ALLIES("{max-allies}", () -> getRelation("ally")),
|
||||||
MAX_ENEMIES("{max-enemies}", () -> getRelation("enemy")),
|
MAX_ENEMIES("{max-enemies}", () -> getRelation("enemy")),
|
||||||
MAX_TRUCES("{max-truces}", () -> getRelation("truce")),
|
MAX_TRUCES("{max-truces}", () -> getRelation("truce")),
|
||||||
FACTIONLESS("factionless", () -> String.valueOf(FPlayers.getInstance().getOnlinePlayers().stream().filter(p -> !p.hasFaction()).count())),
|
FACTIONLESS("{factionless}", () -> String.valueOf(FPlayers.getInstance().getOnlinePlayers().stream().filter(p -> !p.hasFaction()).count())),
|
||||||
FACTIONLESS_TOTAL("factionless-total", () -> String.valueOf(FPlayers.getInstance().getAllFPlayers().stream().filter(p -> !p.hasFaction()).count())),
|
FACTIONLESS_TOTAL("{factionless-total}", () -> String.valueOf(FPlayers.getInstance().getAllFPlayers().stream().filter(p -> !p.hasFaction()).count())),
|
||||||
TOTAL_ONLINE("{total-online}", () -> String.valueOf(Bukkit.getOnlinePlayers().size())),
|
TOTAL_ONLINE("{total-online}", () -> String.valueOf(Bukkit.getOnlinePlayers().size())),
|
||||||
;
|
;
|
||||||
|
|
||||||
|
|||||||
@@ -1,6 +1,7 @@
|
|||||||
package com.massivecraft.factions.tag;
|
package com.massivecraft.factions.tag;
|
||||||
|
|
||||||
import com.massivecraft.factions.FPlayer;
|
import com.massivecraft.factions.FPlayer;
|
||||||
|
import com.massivecraft.factions.FactionsPlugin;
|
||||||
import com.massivecraft.factions.integration.Econ;
|
import com.massivecraft.factions.integration.Econ;
|
||||||
import com.massivecraft.factions.zcore.util.TL;
|
import com.massivecraft.factions.zcore.util.TL;
|
||||||
import org.apache.commons.lang.time.DurationFormatUtils;
|
import org.apache.commons.lang.time.DurationFormatUtils;
|
||||||
@@ -15,7 +16,13 @@ public enum PlayerTag implements Tag {
|
|||||||
/**
|
/**
|
||||||
* @author FactionsUUID Team
|
* @author FactionsUUID Team
|
||||||
*/
|
*/
|
||||||
|
GROUP("{group}", (fp) -> {
|
||||||
|
if (fp.isOnline()) {
|
||||||
|
return FactionsPlugin.getInstance().getPrimaryGroup(fp.getPlayer());
|
||||||
|
} else {
|
||||||
|
return "";
|
||||||
|
}
|
||||||
|
}),
|
||||||
LAST_SEEN("{lastSeen}", (fp) -> {
|
LAST_SEEN("{lastSeen}", (fp) -> {
|
||||||
String humanized = DurationFormatUtils.formatDurationWords(System.currentTimeMillis() - fp.getLastLoginTime(), true, true) + TL.COMMAND_STATUS_AGOSUFFIX;
|
String humanized = DurationFormatUtils.formatDurationWords(System.currentTimeMillis() - fp.getLastLoginTime(), true, true) + TL.COMMAND_STATUS_AGOSUFFIX;
|
||||||
return fp.isOnline() ? ChatColor.GREEN + TL.COMMAND_STATUS_ONLINE.toString() : (System.currentTimeMillis() - fp.getLastLoginTime() < 432000000 ? ChatColor.YELLOW + humanized : ChatColor.RED + humanized);
|
return fp.isOnline() ? ChatColor.GREEN + TL.COMMAND_STATUS_ONLINE.toString() : (System.currentTimeMillis() - fp.getLastLoginTime() < 432000000 ? ChatColor.YELLOW + humanized : ChatColor.RED + humanized);
|
||||||
|
|||||||
@@ -3,12 +3,13 @@ package com.massivecraft.factions.util;
|
|||||||
/**
|
/**
|
||||||
* @author Saser
|
* @author Saser
|
||||||
*/
|
*/
|
||||||
|
|
||||||
import org.bukkit.ChatColor;
|
import org.bukkit.ChatColor;
|
||||||
|
|
||||||
public class CC {
|
public class CC {
|
||||||
public static String Black = ChatColor.BLACK.toString();
|
public static String Black = ChatColor.BLACK.toString();
|
||||||
public static String BlackB = ChatColor.BLACK + ChatColor.BOLD.toString();
|
public static String BlackB = ChatColor.BLACK + ChatColor.BOLD.toString();
|
||||||
public static String BlackI = ChatColor.BLACK + ChatColor.ITALIC.toString();;
|
public static String BlackI = ChatColor.BLACK + ChatColor.ITALIC.toString();
|
||||||
public static String BlackU = ChatColor.BLACK + ChatColor.UNDERLINE.toString();
|
public static String BlackU = ChatColor.BLACK + ChatColor.UNDERLINE.toString();
|
||||||
public static String DarkBlue = ChatColor.DARK_BLUE.toString();
|
public static String DarkBlue = ChatColor.DARK_BLUE.toString();
|
||||||
public static String DarkBlueB = ChatColor.DARK_BLUE + ChatColor.BOLD.toString();
|
public static String DarkBlueB = ChatColor.DARK_BLUE + ChatColor.BOLD.toString();
|
||||||
|
|||||||
@@ -3,6 +3,7 @@ package com.massivecraft.factions.util;
|
|||||||
import com.massivecraft.factions.*;
|
import com.massivecraft.factions.*;
|
||||||
import com.massivecraft.factions.integration.Econ;
|
import com.massivecraft.factions.integration.Econ;
|
||||||
import com.massivecraft.factions.struct.Relation;
|
import com.massivecraft.factions.struct.Relation;
|
||||||
|
import com.massivecraft.factions.tag.FactionTag;
|
||||||
import com.massivecraft.factions.tag.Tag;
|
import com.massivecraft.factions.tag.Tag;
|
||||||
import com.massivecraft.factions.zcore.util.TL;
|
import com.massivecraft.factions.zcore.util.TL;
|
||||||
import me.clip.placeholderapi.expansion.PlaceholderExpansion;
|
import me.clip.placeholderapi.expansion.PlaceholderExpansion;
|
||||||
@@ -133,8 +134,14 @@ public class ClipPlaceholderAPIManager extends PlaceholderExpansion implements R
|
|||||||
return faction.isPeaceful() ? Conf.colorNeutral + TL.COMMAND_SHOW_PEACEFUL.toString() : "";
|
return faction.isPeaceful() ? Conf.colorNeutral + TL.COMMAND_SHOW_PEACEFUL.toString() : "";
|
||||||
case "faction_tntbank_balance":
|
case "faction_tntbank_balance":
|
||||||
return String.valueOf(faction.getTnt());
|
return String.valueOf(faction.getTnt());
|
||||||
|
case "faction_tnt_max_balance":
|
||||||
|
return FactionTag.TNT_MAX.replace(FactionTag.TNT_MAX.getTag(), faction);
|
||||||
case "faction_points":
|
case "faction_points":
|
||||||
return fPlayer.hasFaction() ? String.valueOf(faction.getPoints()) : "0";
|
return fPlayer.hasFaction() ? String.valueOf(faction.getPoints()) : "0";
|
||||||
|
case "discord_acount":
|
||||||
|
return fPlayer.discordSetup() ? String.valueOf(fPlayer.discordUserID()) : "Not Linked";
|
||||||
|
case "faction_discord":
|
||||||
|
return fPlayer.hasFaction() ? String.valueOf(faction.getDiscord()) : "Not Linked";
|
||||||
case "faction_powerboost":
|
case "faction_powerboost":
|
||||||
double powerBoost = faction.getPowerBoost();
|
double powerBoost = faction.getPowerBoost();
|
||||||
return (powerBoost == 0.0) ? "" : (powerBoost > 0.0 ? TL.COMMAND_SHOW_BONUS.toString() : TL.COMMAND_SHOW_PENALTY.toString()) + powerBoost + ")";
|
return (powerBoost == 0.0) ? "" : (powerBoost > 0.0 ? TL.COMMAND_SHOW_BONUS.toString() : TL.COMMAND_SHOW_PENALTY.toString()) + powerBoost + ")";
|
||||||
@@ -162,22 +169,44 @@ public class ClipPlaceholderAPIManager extends PlaceholderExpansion implements R
|
|||||||
return Econ.shouldBeUsed() ? Econ.moneyString(Econ.getBalance(faction.getAccountId())) : TL.ECON_OFF.format("balance");
|
return Econ.shouldBeUsed() ? Econ.moneyString(Econ.getBalance(faction.getAccountId())) : TL.ECON_OFF.format("balance");
|
||||||
case "faction_allies":
|
case "faction_allies":
|
||||||
return String.valueOf(faction.getRelationCount(Relation.ALLY));
|
return String.valueOf(faction.getRelationCount(Relation.ALLY));
|
||||||
|
case "faction_allies_players":
|
||||||
|
return String.valueOf(this.countOn(faction, Relation.ALLY, null, fPlayer));
|
||||||
|
case "faction_allies_players_online":
|
||||||
|
return String.valueOf(this.countOn(faction, Relation.ALLY, true, fPlayer));
|
||||||
|
case "faction_allies_players_offline":
|
||||||
|
return String.valueOf(this.countOn(faction, Relation.ALLY, false, fPlayer));
|
||||||
case "faction_enemies":
|
case "faction_enemies":
|
||||||
return String.valueOf(faction.getRelationCount(Relation.ENEMY));
|
return String.valueOf(faction.getRelationCount(Relation.ENEMY));
|
||||||
|
case "faction_enemies_players":
|
||||||
|
return String.valueOf(this.countOn(faction, Relation.ENEMY, null, fPlayer));
|
||||||
|
case "faction_enemies_players_online":
|
||||||
|
return String.valueOf(this.countOn(faction, Relation.ENEMY, true, fPlayer));
|
||||||
|
case "faction_enemies_players_offline":
|
||||||
|
return String.valueOf(this.countOn(faction, Relation.ENEMY, false, fPlayer));
|
||||||
case "faction_truces":
|
case "faction_truces":
|
||||||
return String.valueOf(faction.getRelationCount(Relation.TRUCE));
|
return String.valueOf(faction.getRelationCount(Relation.TRUCE));
|
||||||
|
case "faction_truces_players":
|
||||||
|
return String.valueOf(this.countOn(faction, Relation.TRUCE, null, fPlayer));
|
||||||
|
case "faction_truces_players_online":
|
||||||
|
return String.valueOf(this.countOn(faction, Relation.TRUCE, true, fPlayer));
|
||||||
|
case "faction_truces_players_offline":
|
||||||
|
return String.valueOf(this.countOn(faction, Relation.TRUCE, false, fPlayer));
|
||||||
case "faction_online":
|
case "faction_online":
|
||||||
return String.valueOf(faction.getOnlinePlayers().size());
|
return String.valueOf(faction.getOnlinePlayers().size());
|
||||||
case "faction_offline":
|
case "faction_offline":
|
||||||
return String.valueOf(faction.getFPlayers().size() - faction.getOnlinePlayers().size());
|
return String.valueOf(faction.getFPlayers().size() - faction.getOnlinePlayers().size());
|
||||||
case "faction_size":
|
case "faction_size":
|
||||||
return String.valueOf(faction.getFPlayers().size());
|
return String.valueOf(faction.getFPlayers().size());
|
||||||
|
case "faction_announcement":
|
||||||
|
return String.valueOf(faction.getAnnouncements());
|
||||||
case "faction_kills":
|
case "faction_kills":
|
||||||
return String.valueOf(faction.getKills());
|
return String.valueOf(faction.getKills());
|
||||||
case "faction_deaths":
|
case "faction_deaths":
|
||||||
return String.valueOf(faction.getDeaths());
|
return String.valueOf(faction.getDeaths());
|
||||||
case "faction_maxvaults":
|
case "faction_maxvaults":
|
||||||
return String.valueOf(faction.getMaxVaults());
|
return String.valueOf(faction.getMaxVaults());
|
||||||
|
case "faction_relation_color":
|
||||||
|
return fPlayer.getColorTo(faction).toString();
|
||||||
case "faction_grace":
|
case "faction_grace":
|
||||||
return String.valueOf(Conf.gracePeriod);
|
return String.valueOf(Conf.gracePeriod);
|
||||||
case "faction_name_at_location":
|
case "faction_name_at_location":
|
||||||
@@ -187,4 +216,21 @@ public class ClipPlaceholderAPIManager extends PlaceholderExpansion implements R
|
|||||||
|
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
private int countOn(Faction f, Relation relation, Boolean status, FPlayer player) {
|
||||||
|
int count = 0;
|
||||||
|
for (Faction faction : Factions.getInstance().getAllFactions()) {
|
||||||
|
if (faction.getRelationTo(f) == relation) {
|
||||||
|
if (status == null) {
|
||||||
|
count += faction.getFPlayers().size();
|
||||||
|
} else if (status) {
|
||||||
|
count += faction.getFPlayersWhereOnline(true, player).size();
|
||||||
|
} else {
|
||||||
|
count += faction.getFPlayersWhereOnline(false, player).size();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return count;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
@@ -72,7 +72,7 @@ public class FactionWarpsFrame {
|
|||||||
|
|
||||||
private ItemStack buildWarpAsset(final Map.Entry<String, LazyLocation> warp, final Faction faction) {
|
private ItemStack buildWarpAsset(final Map.Entry<String, LazyLocation> warp, final Faction faction) {
|
||||||
final ConfigurationSection config = this.section.getConfigurationSection("warp-item");
|
final ConfigurationSection config = this.section.getConfigurationSection("warp-item");
|
||||||
final ItemStack item = XMaterial.matchXMaterial(config.getString("Type")).parseItem();
|
final ItemStack item = XMaterial.matchXMaterial(config.getString("Type")).get().parseItem();
|
||||||
final ItemMeta meta = item.getItemMeta();
|
final ItemMeta meta = item.getItemMeta();
|
||||||
meta.setLore(FactionsPlugin.getInstance().colorList(FactionsPlugin.getInstance().replacePlaceholders(config.getStringList("Lore"), new Placeholder("{warp-protected}", faction.hasWarpPassword(warp.getKey()) ? "Enabled" : "Disabled"), new Placeholder("{warp-cost}", FactionsPlugin.getInstance().getConfig().getBoolean("warp-cost.enabled", false) ? Integer.toString(FactionsPlugin.getInstance().getConfig().getInt("warp-cost.warp", 5)) : "Disabled"))));
|
meta.setLore(FactionsPlugin.getInstance().colorList(FactionsPlugin.getInstance().replacePlaceholders(config.getStringList("Lore"), new Placeholder("{warp-protected}", faction.hasWarpPassword(warp.getKey()) ? "Enabled" : "Disabled"), new Placeholder("{warp-cost}", FactionsPlugin.getInstance().getConfig().getBoolean("warp-cost.enabled", false) ? Integer.toString(FactionsPlugin.getInstance().getConfig().getInt("warp-cost.warp", 5)) : "Disabled"))));
|
||||||
meta.setDisplayName(FactionsPlugin.getInstance().color(config.getString("Name").replace("{warp}", warp.getKey())));
|
meta.setDisplayName(FactionsPlugin.getInstance().color(config.getString("Name").replace("{warp}", warp.getKey())));
|
||||||
@@ -82,7 +82,7 @@ public class FactionWarpsFrame {
|
|||||||
|
|
||||||
private ItemStack buildDummyItem() {
|
private ItemStack buildDummyItem() {
|
||||||
final ConfigurationSection config = this.section.getConfigurationSection("dummy-item");
|
final ConfigurationSection config = this.section.getConfigurationSection("dummy-item");
|
||||||
final ItemStack item = XMaterial.matchXMaterial(config.getString("Type")).parseItem();
|
final ItemStack item = XMaterial.matchXMaterial(config.getString("Type")).get().parseItem();
|
||||||
final ItemMeta meta = item.getItemMeta();
|
final ItemMeta meta = item.getItemMeta();
|
||||||
meta.setLore(FactionsPlugin.getInstance().colorList(config.getStringList("Lore")));
|
meta.setLore(FactionsPlugin.getInstance().colorList(config.getStringList("Lore")));
|
||||||
meta.setDisplayName(FactionsPlugin.getInstance().color(config.getString("Name")));
|
meta.setDisplayName(FactionsPlugin.getInstance().color(config.getString("Name")));
|
||||||
|
|||||||
@@ -1,7 +1,6 @@
|
|||||||
package com.massivecraft.factions.util;
|
package com.massivecraft.factions.util;
|
||||||
|
|
||||||
import com.google.gson.*;
|
import com.google.gson.*;
|
||||||
import com.massivecraft.factions.Conf;
|
|
||||||
import com.massivecraft.factions.FactionsPlugin;
|
import com.massivecraft.factions.FactionsPlugin;
|
||||||
import org.bukkit.inventory.Inventory;
|
import org.bukkit.inventory.Inventory;
|
||||||
|
|
||||||
|
|||||||
@@ -21,12 +21,8 @@ public class ItemBuilder {
|
|||||||
this.meta = item.getItemMeta();
|
this.meta = item.getItemMeta();
|
||||||
}
|
}
|
||||||
|
|
||||||
public ItemBuilder(Material material, int amount, int durability) {
|
|
||||||
this(new ItemStack(material, amount, (short) durability));
|
|
||||||
}
|
|
||||||
|
|
||||||
public ItemBuilder(Material material, int amount) {
|
public ItemBuilder(Material material, int amount) {
|
||||||
this(material, amount, 0);
|
this(new ItemStack(material, amount));
|
||||||
}
|
}
|
||||||
|
|
||||||
public ItemBuilder(Material material) {
|
public ItemBuilder(Material material) {
|
||||||
|
|||||||
@@ -3,7 +3,7 @@ package com.massivecraft.factions.util;
|
|||||||
/**
|
/**
|
||||||
* @author Saser
|
* @author Saser
|
||||||
*/
|
*/
|
||||||
import com.massivecraft.factions.util.XMaterial;
|
|
||||||
import org.bukkit.Material;
|
import org.bukkit.Material;
|
||||||
import org.bukkit.inventory.Inventory;
|
import org.bukkit.inventory.Inventory;
|
||||||
import org.bukkit.inventory.ItemStack;
|
import org.bukkit.inventory.ItemStack;
|
||||||
|
|||||||
@@ -3,15 +3,14 @@ package com.massivecraft.factions.util;
|
|||||||
/**
|
/**
|
||||||
* @author Saser
|
* @author Saser
|
||||||
*/
|
*/
|
||||||
|
|
||||||
import com.google.common.reflect.TypeToken;
|
import com.google.common.reflect.TypeToken;
|
||||||
import com.google.gson.Gson;
|
import com.google.gson.Gson;
|
||||||
import com.google.gson.GsonBuilder;
|
import com.google.gson.GsonBuilder;
|
||||||
import com.massivecraft.factions.cmd.audit.FactionLogs;
|
|
||||||
import org.bukkit.Bukkit;
|
import org.bukkit.Bukkit;
|
||||||
|
|
||||||
import java.io.*;
|
import java.io.*;
|
||||||
import java.lang.reflect.Type;
|
import java.lang.reflect.Type;
|
||||||
import java.util.Map;
|
|
||||||
|
|
||||||
public class JSONUtils {
|
public class JSONUtils {
|
||||||
public static Gson gson = (new GsonBuilder()).enableComplexMapKeySerialization().create();
|
public static Gson gson = (new GsonBuilder()).enableComplexMapKeySerialization().create();
|
||||||
|
|||||||
26
src/main/java/com/massivecraft/factions/util/Pair.java
Normal file
26
src/main/java/com/massivecraft/factions/util/Pair.java
Normal file
@@ -0,0 +1,26 @@
|
|||||||
|
package com.massivecraft.factions.util;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Factions - Developed by FactionsUUID Team.
|
||||||
|
*/
|
||||||
|
public class Pair<Left, Right> {
|
||||||
|
|
||||||
|
private final Left left;
|
||||||
|
private final Right right;
|
||||||
|
private Pair(Left left, Right right) {
|
||||||
|
this.left = left;
|
||||||
|
this.right = right;
|
||||||
|
}
|
||||||
|
|
||||||
|
public static <Left, Right> Pair<Left, Right> of(Left left, Right right) {
|
||||||
|
return new Pair<>(left, right);
|
||||||
|
}
|
||||||
|
|
||||||
|
public Left getLeft() {
|
||||||
|
return this.left;
|
||||||
|
}
|
||||||
|
|
||||||
|
public Right getRight() {
|
||||||
|
return this.right;
|
||||||
|
}
|
||||||
|
}
|
||||||
108
src/main/java/com/massivecraft/factions/util/TimeUtil.java
Normal file
108
src/main/java/com/massivecraft/factions/util/TimeUtil.java
Normal file
@@ -0,0 +1,108 @@
|
|||||||
|
package com.massivecraft.factions.util;
|
||||||
|
|
||||||
|
import java.util.Calendar;
|
||||||
|
import java.util.GregorianCalendar;
|
||||||
|
import java.util.concurrent.TimeUnit;
|
||||||
|
import java.util.regex.Matcher;
|
||||||
|
import java.util.regex.Pattern;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Factions - Developed by Driftay.
|
||||||
|
* All rights reserved 2020.
|
||||||
|
* Creation Date: 1/30/2020
|
||||||
|
*/
|
||||||
|
public class TimeUtil {
|
||||||
|
|
||||||
|
public static long parseDateDiff(String time, boolean future) throws Exception {
|
||||||
|
Pattern timePattern = Pattern.compile("(?:([0-9]+)\\s*y[a-z]*[,\\s]*)?(?:([0-9]+)\\s*mo[a-z]*[,\\s]*)?(?:([0-9]+)\\s*w[a-z]*[,\\s]*)?(?:([0-9]+)\\s*d[a-z]*[,\\s]*)?(?:([0-9]+)\\s*h[a-z]*[,\\s]*)?(?:([0-9]+)\\s*m[a-z]*[,\\s]*)?(?:([0-9]+)\\s*(?:s[a-z]*)?)?", 2);
|
||||||
|
Matcher m = timePattern.matcher(time);
|
||||||
|
int years = 0;
|
||||||
|
int months = 0;
|
||||||
|
int weeks = 0;
|
||||||
|
int days = 0;
|
||||||
|
int hours = 0;
|
||||||
|
int minutes = 0;
|
||||||
|
int seconds = 0;
|
||||||
|
boolean found = false;
|
||||||
|
while (m.find()) {
|
||||||
|
if (m.group() != null) {
|
||||||
|
if (m.group().isEmpty()) continue;
|
||||||
|
for (int i = 0; i < m.groupCount(); ++i) {
|
||||||
|
if (m.group(i) != null && !m.group(i).isEmpty()) {
|
||||||
|
found = true;
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if (!found) continue;
|
||||||
|
|
||||||
|
if (m.group(1) != null && !m.group(1).isEmpty()) years = Integer.parseInt(m.group(1));
|
||||||
|
|
||||||
|
if (m.group(2) != null && !m.group(2).isEmpty()) months = Integer.parseInt(m.group(2));
|
||||||
|
|
||||||
|
if (m.group(3) != null && !m.group(3).isEmpty()) weeks = Integer.parseInt(m.group(3));
|
||||||
|
|
||||||
|
if (m.group(4) != null && !m.group(4).isEmpty()) days = Integer.parseInt(m.group(4));
|
||||||
|
|
||||||
|
if (m.group(5) != null && !m.group(5).isEmpty()) hours = Integer.parseInt(m.group(5));
|
||||||
|
|
||||||
|
if (m.group(6) != null && !m.group(6).isEmpty()) minutes = Integer.parseInt(m.group(6));
|
||||||
|
|
||||||
|
if (m.group(7) != null && !m.group(7).isEmpty()) {
|
||||||
|
seconds = Integer.parseInt(m.group(7));
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if (!found) throw new Exception("Illegal Date");
|
||||||
|
|
||||||
|
if (years > 20) throw new Exception("Illegal Date");
|
||||||
|
|
||||||
|
Calendar c = new GregorianCalendar();
|
||||||
|
if (years > 0) c.add(Calendar.YEAR, years * (future ? 1 : -1));
|
||||||
|
|
||||||
|
if (months > 0) c.add(Calendar.MONTH, months * (future ? 1 : -1));
|
||||||
|
|
||||||
|
if (weeks > 0) c.add(Calendar.WEEK_OF_YEAR, weeks * (future ? 1 : -1));
|
||||||
|
|
||||||
|
if (days > 0) c.add(Calendar.DATE, days * (future ? 1 : -1));
|
||||||
|
|
||||||
|
if (hours > 0) c.add(Calendar.HOUR_OF_DAY, hours * (future ? 1 : -1));
|
||||||
|
|
||||||
|
if (minutes > 0) c.add(Calendar.MINUTE, minutes * (future ? 1 : -1));
|
||||||
|
|
||||||
|
if (seconds > 0) c.add(Calendar.SECOND, seconds * (future ? 1 : -1));
|
||||||
|
|
||||||
|
System.out.println("current: " + c.getTimeInMillis() + " Time: " + System.currentTimeMillis() + " Form: " + formatTime(c.getTimeInMillis() / 1000L));
|
||||||
|
return c.getTimeInMillis() / 1000L;
|
||||||
|
}
|
||||||
|
|
||||||
|
public static String formatDifference(long time) {
|
||||||
|
if (time == 0L) return "Never";
|
||||||
|
|
||||||
|
long day = TimeUnit.SECONDS.toDays(time);
|
||||||
|
long hours = TimeUnit.SECONDS.toHours(time) - day * 24L;
|
||||||
|
long minutes = TimeUnit.SECONDS.toMinutes(time) - TimeUnit.SECONDS.toHours(time) * 60L;
|
||||||
|
long seconds = TimeUnit.SECONDS.toSeconds(time) - TimeUnit.SECONDS.toMinutes(time) * 60L;
|
||||||
|
StringBuilder sb = new StringBuilder();
|
||||||
|
if (day > 0L) sb.append(day).append((day == 1L) ? "day" : "days").append(" ");
|
||||||
|
|
||||||
|
if (hours > 0L) sb.append(hours).append((hours == 1L) ? "h" : "h").append(" ");
|
||||||
|
|
||||||
|
if (minutes > 0L) sb.append(minutes).append((minutes == 1L) ? "m" : "m").append(" ");
|
||||||
|
|
||||||
|
if (seconds > 0L) sb.append(seconds).append((seconds == 1L) ? "s" : "s");
|
||||||
|
|
||||||
|
String diff = sb.toString().trim();
|
||||||
|
return diff.isEmpty() ? "Now" : diff;
|
||||||
|
}
|
||||||
|
|
||||||
|
public static String formatTime(long time) {
|
||||||
|
if (time == System.currentTimeMillis()) return "Now";
|
||||||
|
|
||||||
|
if (time == -1L) return "Never";
|
||||||
|
|
||||||
|
return formatDifference(time - System.currentTimeMillis() / 1000L);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
@@ -10,6 +10,7 @@ import java.util.List;
|
|||||||
|
|
||||||
public class Updater {
|
public class Updater {
|
||||||
public static double currentVersion = 1.1;
|
public static double currentVersion = 1.1;
|
||||||
|
|
||||||
public static void updateIfNeeded(FileConfiguration conf) {
|
public static void updateIfNeeded(FileConfiguration conf) {
|
||||||
double version = conf.getDouble("Config-Version", 0);
|
double version = conf.getDouble("Config-Version", 0);
|
||||||
//Previous version
|
//Previous version
|
||||||
@@ -41,6 +42,8 @@ public class Updater {
|
|||||||
try {
|
try {
|
||||||
conf.save(new File("plugins/Factions/config.yml"));
|
conf.save(new File("plugins/Factions/config.yml"));
|
||||||
FactionsPlugin.getInstance().reloadConfig();
|
FactionsPlugin.getInstance().reloadConfig();
|
||||||
} catch (IOException e) {e.printStackTrace();}
|
} catch (IOException e) {
|
||||||
|
e.printStackTrace();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -10,7 +10,10 @@ import org.bukkit.Bukkit;
|
|||||||
|
|
||||||
|
|
||||||
public class UtilFly {
|
public class UtilFly {
|
||||||
|
/**
|
||||||
|
* UtilFly is being removed very soon as all of its functionality has been updated and moved to CmdFly
|
||||||
|
*/
|
||||||
|
@Deprecated
|
||||||
public static void run() {
|
public static void run() {
|
||||||
if (!FactionsPlugin.getInstance().getConfig().getBoolean("enable-faction-flight"))
|
if (!FactionsPlugin.getInstance().getConfig().getBoolean("enable-faction-flight"))
|
||||||
return;
|
return;
|
||||||
@@ -23,6 +26,7 @@ public class UtilFly {
|
|||||||
}, 0, FactionsPlugin.getInstance().getConfig().getInt("fly-task-interval", 10));
|
}, 0, FactionsPlugin.getInstance().getConfig().getInt("fly-task-interval", 10));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Deprecated
|
||||||
public static void setFly(FPlayer fp, boolean fly, boolean silent, boolean damage) {
|
public static void setFly(FPlayer fp, boolean fly, boolean silent, boolean damage) {
|
||||||
if (!FactionsPlugin.getInstance().getConfig().getBoolean("enable-faction-flight"))
|
if (!FactionsPlugin.getInstance().getConfig().getBoolean("enable-faction-flight"))
|
||||||
return;
|
return;
|
||||||
@@ -43,6 +47,7 @@ public class UtilFly {
|
|||||||
setFallDamage(fp, fly, damage);
|
setFallDamage(fp, fly, damage);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Deprecated
|
||||||
public static void checkFly(FPlayer me, Faction factionTo) {
|
public static void checkFly(FPlayer me, Faction factionTo) {
|
||||||
if (!FactionsPlugin.getInstance().getConfig().getBoolean("enable-faction-flight"))
|
if (!FactionsPlugin.getInstance().getConfig().getBoolean("enable-faction-flight"))
|
||||||
return;
|
return;
|
||||||
|
|||||||
File diff suppressed because it is too large
Load Diff
@@ -3,6 +3,7 @@ package com.massivecraft.factions.util.serializable;
|
|||||||
/**
|
/**
|
||||||
* @author Saser
|
* @author Saser
|
||||||
*/
|
*/
|
||||||
|
|
||||||
import org.bukkit.event.inventory.InventoryClickEvent;
|
import org.bukkit.event.inventory.InventoryClickEvent;
|
||||||
import org.bukkit.inventory.ItemStack;
|
import org.bukkit.inventory.ItemStack;
|
||||||
import org.bukkit.inventory.meta.ItemMeta;
|
import org.bukkit.inventory.meta.ItemMeta;
|
||||||
|
|||||||
@@ -3,6 +3,7 @@ package com.massivecraft.factions.util.serializable;
|
|||||||
/**
|
/**
|
||||||
* @author Saser
|
* @author Saser
|
||||||
*/
|
*/
|
||||||
|
|
||||||
import com.google.common.collect.Lists;
|
import com.google.common.collect.Lists;
|
||||||
import com.massivecraft.factions.FPlayer;
|
import com.massivecraft.factions.FPlayer;
|
||||||
import com.massivecraft.factions.Faction;
|
import com.massivecraft.factions.Faction;
|
||||||
@@ -10,14 +11,12 @@ import com.massivecraft.factions.FactionsPlugin;
|
|||||||
import com.massivecraft.factions.struct.Role;
|
import com.massivecraft.factions.struct.Role;
|
||||||
import org.bukkit.Bukkit;
|
import org.bukkit.Bukkit;
|
||||||
import org.bukkit.ChatColor;
|
import org.bukkit.ChatColor;
|
||||||
import org.bukkit.DyeColor;
|
|
||||||
import org.bukkit.Material;
|
import org.bukkit.Material;
|
||||||
import org.bukkit.entity.HumanEntity;
|
import org.bukkit.entity.HumanEntity;
|
||||||
import org.bukkit.entity.Player;
|
import org.bukkit.entity.Player;
|
||||||
import org.bukkit.event.inventory.InventoryCloseEvent;
|
import org.bukkit.event.inventory.InventoryCloseEvent;
|
||||||
import org.bukkit.inventory.Inventory;
|
import org.bukkit.inventory.Inventory;
|
||||||
import org.bukkit.inventory.ItemStack;
|
import org.bukkit.inventory.ItemStack;
|
||||||
import org.bukkit.material.MaterialData;
|
|
||||||
|
|
||||||
import java.util.HashMap;
|
import java.util.HashMap;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
@@ -26,9 +25,9 @@ import java.util.UUID;
|
|||||||
import java.util.function.Consumer;
|
import java.util.function.Consumer;
|
||||||
|
|
||||||
public abstract class GUIMenu {
|
public abstract class GUIMenu {
|
||||||
|
private static Map<UUID, GUIMenu> menus = new HashMap<>();
|
||||||
protected Inventory menu;
|
protected Inventory menu;
|
||||||
private Map<Integer, ClickableItemStack> menuItems = new HashMap<>();
|
private Map<Integer, ClickableItemStack> menuItems = new HashMap<>();
|
||||||
private static Map<UUID, GUIMenu> menus = new HashMap<>();
|
|
||||||
private Consumer<InventoryCloseEvent> closeCallback;
|
private Consumer<InventoryCloseEvent> closeCallback;
|
||||||
private String name;
|
private String name;
|
||||||
private int size;
|
private int size;
|
||||||
@@ -44,6 +43,14 @@ public abstract class GUIMenu {
|
|||||||
this.menu = Bukkit.createInventory(null, size, name);
|
this.menu = Bukkit.createInventory(null, size, name);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public static int fitSlots(int size) {
|
||||||
|
return size <= 9 ? 9 : (size <= 18 ? 18 : (size <= 27 ? 27 : (size <= 36 ? 36 : (size <= 45 ? 45 : (size <= 54 ? 54 : 54)))));
|
||||||
|
}
|
||||||
|
|
||||||
|
public static Map<UUID, GUIMenu> getMenus() {
|
||||||
|
return menus;
|
||||||
|
}
|
||||||
|
|
||||||
public void setInventorySize(int size) {
|
public void setInventorySize(int size) {
|
||||||
if (this.size != size) {
|
if (this.size != size) {
|
||||||
int oldSize = this.size;
|
int oldSize = this.size;
|
||||||
@@ -59,11 +66,6 @@ public abstract class GUIMenu {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public GUIMenu setPreviousMenu(GUIMenu menu) {
|
|
||||||
this.previousMenu = menu;
|
|
||||||
return this;
|
|
||||||
}
|
|
||||||
|
|
||||||
public void setItem(int slot, ClickableItemStack item) {
|
public void setItem(int slot, ClickableItemStack item) {
|
||||||
this.menu.setItem(slot, item);
|
this.menu.setItem(slot, item);
|
||||||
this.menuItems.put(slot, item);
|
this.menuItems.put(slot, item);
|
||||||
@@ -122,18 +124,10 @@ public abstract class GUIMenu {
|
|||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public static int fitSlots(int size) {
|
|
||||||
return size <= 9 ? 9 : (size <= 18 ? 18 : (size <= 27 ? 27 : (size <= 36 ? 36 : (size <= 45 ? 45 : (size <= 54 ? 54 : 54)))));
|
|
||||||
}
|
|
||||||
|
|
||||||
public Map<Integer, ClickableItemStack> getMenuItems() {
|
public Map<Integer, ClickableItemStack> getMenuItems() {
|
||||||
return this.menuItems;
|
return this.menuItems;
|
||||||
}
|
}
|
||||||
|
|
||||||
public static Map<UUID, GUIMenu> getMenus() {
|
|
||||||
return menus;
|
|
||||||
}
|
|
||||||
|
|
||||||
public Consumer<InventoryCloseEvent> getCloseCallback() {
|
public Consumer<InventoryCloseEvent> getCloseCallback() {
|
||||||
return this.closeCallback;
|
return this.closeCallback;
|
||||||
}
|
}
|
||||||
@@ -153,4 +147,9 @@ public abstract class GUIMenu {
|
|||||||
public GUIMenu getPreviousMenu() {
|
public GUIMenu getPreviousMenu() {
|
||||||
return this.previousMenu;
|
return this.previousMenu;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public GUIMenu setPreviousMenu(GUIMenu menu) {
|
||||||
|
this.previousMenu = menu;
|
||||||
|
return this;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -21,7 +21,9 @@ public class InventoryItem {
|
|||||||
this.item = original;
|
this.item = original;
|
||||||
}
|
}
|
||||||
|
|
||||||
public InventoryItem(ItemBuilder original) { this(original.build()); }
|
public InventoryItem(ItemBuilder original) {
|
||||||
|
this(original.build());
|
||||||
|
}
|
||||||
|
|
||||||
public InventoryItem click(ClickType type, Runnable runnable) {
|
public InventoryItem click(ClickType type, Runnable runnable) {
|
||||||
this.clickMap.put(type, runnable);
|
this.clickMap.put(type, runnable);
|
||||||
|
|||||||
@@ -1,151 +0,0 @@
|
|||||||
package com.massivecraft.factions.util.serializable;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @author Driftay
|
|
||||||
*/
|
|
||||||
import com.massivecraft.factions.FactionsPlugin;
|
|
||||||
import org.bukkit.Bukkit;
|
|
||||||
import org.bukkit.entity.Player;
|
|
||||||
import org.bukkit.event.inventory.InventoryClickEvent;
|
|
||||||
import org.bukkit.event.inventory.InventoryType;
|
|
||||||
import org.bukkit.inventory.Inventory;
|
|
||||||
import org.bukkit.inventory.ItemStack;
|
|
||||||
import org.bukkit.plugin.java.JavaPlugin;
|
|
||||||
|
|
||||||
import java.util.*;
|
|
||||||
import java.util.concurrent.ConcurrentHashMap;
|
|
||||||
import java.util.function.Consumer;
|
|
||||||
|
|
||||||
|
|
||||||
public abstract class SaberGUI {
|
|
||||||
public static Set<String> allGUINames = new HashSet<>();
|
|
||||||
public static Map<UUID, SaberGUI> activeGUIs = new ConcurrentHashMap<>();
|
|
||||||
public SaberGUI parentGUI;
|
|
||||||
protected String title;
|
|
||||||
protected int size;
|
|
||||||
protected Player player;
|
|
||||||
protected Inventory inventory;
|
|
||||||
private Map<Integer, InventoryItem> inventoryItems;
|
|
||||||
private String owningPluginName;
|
|
||||||
private Runnable closeRunnable;
|
|
||||||
|
|
||||||
public SaberGUI(Player player, String title, int size) {
|
|
||||||
this(player, title, size, InventoryType.CHEST);
|
|
||||||
}
|
|
||||||
|
|
||||||
public SaberGUI(Player player, String title, int size, InventoryType type) {
|
|
||||||
this.inventoryItems = new HashMap<>();
|
|
||||||
this.inventory = type == InventoryType.CHEST ? Bukkit.createInventory(null, size, title) : Bukkit.createInventory(null, type, title);
|
|
||||||
this.player = player;
|
|
||||||
this.size = size;
|
|
||||||
this.title = title;
|
|
||||||
allGUINames.add(this.title);
|
|
||||||
}
|
|
||||||
|
|
||||||
public SaberGUI setParentGUI(SaberGUI parent) {
|
|
||||||
this.parentGUI = parent;
|
|
||||||
return this;
|
|
||||||
}
|
|
||||||
|
|
||||||
public void onUnknownItemClick(InventoryClickEvent event) {
|
|
||||||
}
|
|
||||||
|
|
||||||
public abstract void redraw();
|
|
||||||
|
|
||||||
public void openGUI(JavaPlugin owning) {
|
|
||||||
this.owningPluginName = owning.getName();
|
|
||||||
SaberGUI currentlyActive = activeGUIs.get(this.player.getUniqueId());
|
|
||||||
if (currentlyActive != null) {
|
|
||||||
Bukkit.getLogger().info("Closing already open menu first!");
|
|
||||||
Bukkit.getScheduler().scheduleSyncDelayedTask(owning, () -> {
|
|
||||||
currentlyActive.close();
|
|
||||||
activeGUIs.put(this.player.getUniqueId(), this);
|
|
||||||
this.redraw();
|
|
||||||
this.player.openInventory(this.inventory);
|
|
||||||
});
|
|
||||||
} else {
|
|
||||||
activeGUIs.put(this.player.getUniqueId(), this);
|
|
||||||
this.redraw();
|
|
||||||
this.player.openInventory(this.inventory);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
public void setItem(int slot, InventoryItem inventoryItem) {
|
|
||||||
if (inventoryItem != null && inventoryItem.getItem() != null) {
|
|
||||||
this.inventoryItems.put(slot, inventoryItem);
|
|
||||||
this.inventory.setItem(slot, inventoryItem.getItem());
|
|
||||||
} else {
|
|
||||||
this.removeItem(slot);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
public void closeWithDelay() {
|
|
||||||
this.closeWithDelay(null);
|
|
||||||
}
|
|
||||||
|
|
||||||
public void closeWithDelay(Consumer<Player> afterClose) {
|
|
||||||
Bukkit.getScheduler().scheduleSyncDelayedTask(FactionsPlugin.instance, () -> {
|
|
||||||
this.player.closeInventory();
|
|
||||||
if (afterClose != null) {
|
|
||||||
afterClose.accept(this.player);
|
|
||||||
}
|
|
||||||
|
|
||||||
}, 1L);
|
|
||||||
}
|
|
||||||
|
|
||||||
public void setItem(int slot, ItemStack item, Runnable runnable) {
|
|
||||||
this.setItem(slot, (new InventoryItem(item)).click(runnable));
|
|
||||||
}
|
|
||||||
|
|
||||||
public void onInventoryClose() {
|
|
||||||
if (this.closeRunnable != null) {
|
|
||||||
this.closeRunnable.run();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
public void close() {
|
|
||||||
this.onInventoryClose();
|
|
||||||
this.player.closeInventory();
|
|
||||||
}
|
|
||||||
|
|
||||||
public void removeItem(int slot) {
|
|
||||||
this.inventory.setItem(slot, null);
|
|
||||||
this.inventoryItems.remove(slot);
|
|
||||||
}
|
|
||||||
|
|
||||||
public SaberGUI setOnClose(Runnable runnable) {
|
|
||||||
this.closeRunnable = runnable;
|
|
||||||
return this;
|
|
||||||
}
|
|
||||||
|
|
||||||
public boolean isInventory(Inventory inventory) {
|
|
||||||
return this.inventory.equals(inventory);
|
|
||||||
}
|
|
||||||
|
|
||||||
public static SaberGUI getActiveGUI(UUID uuid) { return activeGUIs.get(uuid); }
|
|
||||||
|
|
||||||
public static void removeGUI(UUID uuid) {
|
|
||||||
activeGUIs.remove(uuid);
|
|
||||||
}
|
|
||||||
|
|
||||||
public SaberGUI getParentGUI() {
|
|
||||||
return this.parentGUI;
|
|
||||||
}
|
|
||||||
|
|
||||||
public Map<Integer, InventoryItem> getInventoryItems() {
|
|
||||||
return this.inventoryItems;
|
|
||||||
}
|
|
||||||
|
|
||||||
public String getOwningPluginName() {
|
|
||||||
return this.owningPluginName;
|
|
||||||
}
|
|
||||||
|
|
||||||
public void setOwningPluginName(String owningPluginName) {
|
|
||||||
this.owningPluginName = owningPluginName;
|
|
||||||
}
|
|
||||||
|
|
||||||
public Runnable getCloseRunnable() {
|
|
||||||
return this.closeRunnable;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
@@ -0,0 +1,105 @@
|
|||||||
|
package com.massivecraft.factions.zcore.fdisband;
|
||||||
|
|
||||||
|
import com.github.stefvanschie.inventoryframework.Gui;
|
||||||
|
import com.github.stefvanschie.inventoryframework.GuiItem;
|
||||||
|
import com.github.stefvanschie.inventoryframework.pane.PaginatedPane;
|
||||||
|
import com.massivecraft.factions.FPlayer;
|
||||||
|
import com.massivecraft.factions.Faction;
|
||||||
|
import com.massivecraft.factions.FactionsPlugin;
|
||||||
|
import com.massivecraft.factions.util.XMaterial;
|
||||||
|
import org.bukkit.ChatColor;
|
||||||
|
import org.bukkit.configuration.ConfigurationSection;
|
||||||
|
import org.bukkit.configuration.file.FileConfiguration;
|
||||||
|
import org.bukkit.inventory.ItemStack;
|
||||||
|
import org.bukkit.inventory.meta.ItemMeta;
|
||||||
|
import org.bukkit.metadata.FixedMetadataValue;
|
||||||
|
|
||||||
|
import java.util.ArrayList;
|
||||||
|
import java.util.List;
|
||||||
|
import java.util.Objects;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Factions - Developed by Driftay.
|
||||||
|
* All rights reserved 2020.
|
||||||
|
* Creation Date: 1/18/2020
|
||||||
|
*/
|
||||||
|
public class FDisbandFrame {
|
||||||
|
|
||||||
|
private Gui gui;
|
||||||
|
|
||||||
|
public FDisbandFrame(Faction faction) {
|
||||||
|
this.gui = new Gui(FactionsPlugin.getInstance(), 1, "Confirm Disband");
|
||||||
|
}
|
||||||
|
|
||||||
|
public void buildGUI(FPlayer fPlayer) {
|
||||||
|
int i;
|
||||||
|
PaginatedPane pane = new PaginatedPane(0, 0, 9, this.gui.getRows());
|
||||||
|
List<GuiItem> GUIItems = new ArrayList<>();
|
||||||
|
ItemStack confirm = buildConfirmDummyItem(fPlayer.getFaction());
|
||||||
|
ItemStack deny = buildDenyDummyItem();
|
||||||
|
for (i = 0; i < 5; ++i) {
|
||||||
|
GUIItems.add(new GuiItem(confirm, (e) -> {
|
||||||
|
e.setCancelled(true);
|
||||||
|
fPlayer.getPlayer().setMetadata("disband_confirm", new FixedMetadataValue(FactionsPlugin.getInstance(), System.currentTimeMillis()));
|
||||||
|
fPlayer.getPlayer().closeInventory();
|
||||||
|
fPlayer.getPlayer().performCommand("f disband");
|
||||||
|
}));
|
||||||
|
}
|
||||||
|
//Separator
|
||||||
|
FileConfiguration config = FactionsPlugin.getInstance().getConfig();
|
||||||
|
ItemStack separatorItem = XMaterial.matchXMaterial(config.getString("f-disband-gui.separation-item.Type")).get().parseItem();
|
||||||
|
ItemMeta separatorMeta = separatorItem.getItemMeta();
|
||||||
|
separatorMeta.setDisplayName(ChatColor.translateAlternateColorCodes('&', config.getString("f-disband-gui.separation-item.Name")));
|
||||||
|
List<String> separatorLore = config.getStringList("f-disband-gui.separation-item.Lore");
|
||||||
|
if (separatorMeta.getLore() != null) separatorMeta.getLore().clear();
|
||||||
|
if (separatorLore != null) {
|
||||||
|
List<String> lore = new ArrayList<>();
|
||||||
|
for (String loreEntry : config.getStringList("f-disband-gui.separation-item.Lore")) {
|
||||||
|
lore.add(ChatColor.translateAlternateColorCodes('&', loreEntry));
|
||||||
|
}
|
||||||
|
separatorMeta.setLore(lore);
|
||||||
|
}
|
||||||
|
GUIItems.set(4, new GuiItem(separatorItem, (e) -> e.setCancelled(true)));
|
||||||
|
//End Separator
|
||||||
|
|
||||||
|
for (i = 5; i < 10; ++i) {
|
||||||
|
GUIItems.add(new GuiItem(deny, (e) -> {
|
||||||
|
e.setCancelled(true);
|
||||||
|
fPlayer.getPlayer().closeInventory();
|
||||||
|
}));
|
||||||
|
}
|
||||||
|
pane.populateWithGuiItems(GUIItems);
|
||||||
|
gui.addPane(pane);
|
||||||
|
gui.update();
|
||||||
|
gui.show(fPlayer.getPlayer());
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
private ItemStack buildConfirmDummyItem(Faction faction) {
|
||||||
|
ConfigurationSection config = FactionsPlugin.getInstance().getConfig().getConfigurationSection("f-disband-gui.confirm-item");
|
||||||
|
ItemStack item = XMaterial.matchXMaterial(config.getString("Type")).get().parseItem();
|
||||||
|
ItemMeta meta = item.getItemMeta();
|
||||||
|
if (meta != null) {
|
||||||
|
List<String> lore = new ArrayList<>();
|
||||||
|
for (String s : config.getStringList("Lore")) {
|
||||||
|
lore.add(FactionsPlugin.getInstance().color(s).replace("{faction}", faction.getTag()));
|
||||||
|
}
|
||||||
|
meta.setLore(lore);
|
||||||
|
meta.setDisplayName(FactionsPlugin.getInstance().color(Objects.requireNonNull(config.getString("Name"))));
|
||||||
|
item.setItemMeta(meta);
|
||||||
|
}
|
||||||
|
return item;
|
||||||
|
}
|
||||||
|
|
||||||
|
private ItemStack buildDenyDummyItem() {
|
||||||
|
ConfigurationSection config = FactionsPlugin.getInstance().getConfig().getConfigurationSection("f-disband-gui.deny-item");
|
||||||
|
ItemStack item = XMaterial.matchXMaterial(config.getString("Type")).get().parseItem();
|
||||||
|
ItemMeta meta = item.getItemMeta();
|
||||||
|
if (meta != null) {
|
||||||
|
meta.setLore(FactionsPlugin.getInstance().colorList(config.getStringList("Lore")));
|
||||||
|
meta.setDisplayName(FactionsPlugin.getInstance().color(config.getString("Name")));
|
||||||
|
item.setItemMeta(meta);
|
||||||
|
}
|
||||||
|
return item;
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -1,7 +1,5 @@
|
|||||||
package com.massivecraft.factions.zcore.fperms;
|
package com.massivecraft.factions.zcore.fperms;
|
||||||
|
|
||||||
import com.massivecraft.factions.util.XMaterial;
|
|
||||||
|
|
||||||
public class DefaultPermissions {
|
public class DefaultPermissions {
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|||||||
@@ -104,7 +104,7 @@ public enum PermissableAction {
|
|||||||
|
|
||||||
public ItemStack buildAsset(FPlayer fme, Permissable perm) {
|
public ItemStack buildAsset(FPlayer fme, Permissable perm) {
|
||||||
ConfigurationSection section = FactionsPlugin.getInstance().getConfig().getConfigurationSection("fperm-gui.action");
|
ConfigurationSection section = FactionsPlugin.getInstance().getConfig().getConfigurationSection("fperm-gui.action");
|
||||||
ItemStack item = XMaterial.matchXMaterial(section.getString("Materials." + this.name)).parseItem();
|
ItemStack item = XMaterial.matchXMaterial(section.getString("Materials." + this.name)).get().parseItem();
|
||||||
ItemMeta meta = item.getItemMeta();
|
ItemMeta meta = item.getItemMeta();
|
||||||
|
|
||||||
meta.setDisplayName(FactionsPlugin.getInstance().color(section.getString("placeholder-item.name").replace("{action}", this.name)));
|
meta.setDisplayName(FactionsPlugin.getInstance().color(section.getString("placeholder-item.name").replace("{action}", this.name)));
|
||||||
|
|||||||
@@ -91,7 +91,7 @@ public class PermissableActionFrame {
|
|||||||
|
|
||||||
private ItemStack buildDummyItem() {
|
private ItemStack buildDummyItem() {
|
||||||
ConfigurationSection config = FactionsPlugin.getInstance().getConfig().getConfigurationSection("fperm-gui.dummy-item");
|
ConfigurationSection config = FactionsPlugin.getInstance().getConfig().getConfigurationSection("fperm-gui.dummy-item");
|
||||||
ItemStack item = XMaterial.matchXMaterial(config.getString("Type")).parseItem();
|
ItemStack item = XMaterial.matchXMaterial(config.getString("Type")).get().parseItem();
|
||||||
ItemMeta meta = item.getItemMeta();
|
ItemMeta meta = item.getItemMeta();
|
||||||
meta.setLore(FactionsPlugin.getInstance().colorList(config.getStringList("Lore")));
|
meta.setLore(FactionsPlugin.getInstance().colorList(config.getStringList("Lore")));
|
||||||
meta.setDisplayName(FactionsPlugin.getInstance().color(config.getString("Name")));
|
meta.setDisplayName(FactionsPlugin.getInstance().color(config.getString("Name")));
|
||||||
@@ -101,7 +101,7 @@ public class PermissableActionFrame {
|
|||||||
|
|
||||||
private ItemStack buildBackItem() {
|
private ItemStack buildBackItem() {
|
||||||
ConfigurationSection config = FactionsPlugin.getInstance().getConfig().getConfigurationSection("fperm-gui.back-item");
|
ConfigurationSection config = FactionsPlugin.getInstance().getConfig().getConfigurationSection("fperm-gui.back-item");
|
||||||
ItemStack item = XMaterial.matchXMaterial(config.getString("Type")).parseItem();
|
ItemStack item = XMaterial.matchXMaterial(config.getString("Type")).get().parseItem();
|
||||||
ItemMeta meta = item.getItemMeta();
|
ItemMeta meta = item.getItemMeta();
|
||||||
meta.setLore(FactionsPlugin.getInstance().colorList(config.getStringList("Lore")));
|
meta.setLore(FactionsPlugin.getInstance().colorList(config.getStringList("Lore")));
|
||||||
meta.setDisplayName(FactionsPlugin.getInstance().color(config.getString("Name")));
|
meta.setDisplayName(FactionsPlugin.getInstance().color(config.getString("Name")));
|
||||||
|
|||||||
@@ -56,7 +56,7 @@ public class PermissableRelationFrame {
|
|||||||
}
|
}
|
||||||
|
|
||||||
private ItemStack buildAsset(String loc, String relation) {
|
private ItemStack buildAsset(String loc, String relation) {
|
||||||
ItemStack item = XMaterial.matchXMaterial(FactionsPlugin.getInstance().getConfig().getString(loc)).parseItem();
|
ItemStack item = XMaterial.matchXMaterial(FactionsPlugin.getInstance().getConfig().getString(loc)).get().parseItem();
|
||||||
ItemMeta meta = item.getItemMeta();
|
ItemMeta meta = item.getItemMeta();
|
||||||
meta.setDisplayName(FactionsPlugin.getInstance().color(FactionsPlugin.getInstance().getConfig().getString("fperm-gui.relation.Placeholder-Item.Name").replace("{relation}", relation)));
|
meta.setDisplayName(FactionsPlugin.getInstance().color(FactionsPlugin.getInstance().getConfig().getString("fperm-gui.relation.Placeholder-Item.Name").replace("{relation}", relation)));
|
||||||
item.setItemMeta(meta);
|
item.setItemMeta(meta);
|
||||||
@@ -65,7 +65,7 @@ public class PermissableRelationFrame {
|
|||||||
|
|
||||||
private ItemStack buildDummyItem() {
|
private ItemStack buildDummyItem() {
|
||||||
ConfigurationSection config = FactionsPlugin.getInstance().getConfig().getConfigurationSection("fperm-gui.dummy-item");
|
ConfigurationSection config = FactionsPlugin.getInstance().getConfig().getConfigurationSection("fperm-gui.dummy-item");
|
||||||
ItemStack item = XMaterial.matchXMaterial(config.getString("Type")).parseItem();
|
ItemStack item = XMaterial.matchXMaterial(config.getString("Type")).get().parseItem();
|
||||||
ItemMeta meta = item.getItemMeta();
|
ItemMeta meta = item.getItemMeta();
|
||||||
meta.setLore(FactionsPlugin.getInstance().colorList(config.getStringList("Lore")));
|
meta.setLore(FactionsPlugin.getInstance().colorList(config.getStringList("Lore")));
|
||||||
meta.setDisplayName(FactionsPlugin.getInstance().color(config.getString("Name")));
|
meta.setDisplayName(FactionsPlugin.getInstance().color(config.getString("Name")));
|
||||||
|
|||||||
Some files were not shown because too many files have changed in this diff Show More
Reference in New Issue
Block a user