Compare commits

...

79 Commits

Author SHA1 Message Date
DroppingAnvil
d98c647397 Version change for shield removal 2020-06-08 16:04:03 -04:00
DroppingAnvil
e9923344a2 Deal with remaining shield code 2020-06-08 16:03:28 -04:00
DroppingAnvil
cdc07ed5eb Revert "Merge pull request #134 from ImCarib/1.6.x"
This reverts commit 0b677cb4de, reversing
changes made to a355b1d0c8.
2020-06-08 15:52:29 -04:00
Driftay
7b94367eb4 Added shield status placeholder 2020-06-08 15:03:36 -04:00
Driftay
b7d991c0dd unclaim fly fix 2020-06-08 07:06:16 -04:00
Driftay
6372245fcd Version Change 2020-06-08 06:42:51 -04:00
Driftay
f2c0f725b7 Carib unregistered the command 2020-06-08 05:46:25 -04:00
Driftay
0b677cb4de Merge pull request #134 from ImCarib/1.6.x
shields added
2020-06-08 05:39:38 -04:00
ImCarib
e8642a3108 shields added 2020-06-08 05:22:50 -04:00
DroppingAnvil
a355b1d0c8 Fix certain GUIs not loading 2020-06-07 20:34:42 -04:00
Driftay
929c34d850 Final Touches on PermissableAction Rollback 2020-06-01 22:52:03 -04:00
Driftay
903129e462 Reverted Back To Old FactionsBlockListener to Reference Other Plugins Hook Systems 2020-06-01 22:41:14 -04:00
Driftay
e84c69f2b0 Code Cleanup & Fix With Fly Unclaiming 2020-05-27 23:40:46 -04:00
Driftay
3e530487d7 Merge pull request #131 from SaberLLC/beta
Beta
2020-05-25 20:40:22 -04:00
Driftay
14776b8877 Merge pull request #127 from Juniormunk/1.6.x
Fix Bugs
2020-05-25 20:38:35 -04:00
Driftay
7f927189ea Alts Can No Longer Be Promoted 2020-05-25 14:16:49 -04:00
Driftay
6f293dce17 Fixed Kicked Player Staying In Fly Map & FPerms GUI Returning Only Black Stained Glass Pane 2020-05-24 09:35:10 -04:00
Driftay
2676f048d6 Alt Limit Fix 2020-05-24 05:58:35 -04:00
droppinganvil
24aaa0ed6f Merge remote-tracking branch 'origin/1.6.x' into 1.6.x 2020-05-23 13:36:04 -05:00
DroppingAnvil
2a01682fbe Fix issue not allowing use of multiworld wild 2020-05-23 13:35:51 -05:00
Juniormunk
ba59310548 Fix occasional dynmap bug 2020-05-22 17:11:53 -04:00
Juniormunk
bec09168b6 Remove debugging prints 2020-05-22 02:33:31 -04:00
Juniormunk
4fe6484db9 Fix bug #129 2020-05-22 02:24:57 -04:00
Juniormunk
71a099beeb Fix bugs #123, #128 2020-05-21 19:29:51 -04:00
Juniormunk
ddd3150732 Fix bugs #118 , #122 2020-05-21 04:22:53 -04:00
Juniormunk
ec1501bf4f Fix Bug #125 2020-05-21 02:51:41 -04:00
Juniormunk
8ad2fdf848 Fix Bug #126 2020-05-21 01:58:05 -04:00
Driftay
1ee62c2267 Merge pull request #121 from SaberLLC/beta
Beta
2020-05-19 13:48:00 -04:00
Driftay
7e6646b4df Config Fix for default worlds 2020-05-19 06:28:05 -04:00
Driftay
0d08ff4cec Wild Updates 2020-05-19 06:27:20 -04:00
Driftay
cf3ce62023 Merge pull request #120 from SaberLLC/1.6.x
Merging
2020-05-19 06:25:42 -04:00
Driftay
30d6b3c248 Merge pull request #119 from SaberLLC/beta
F Show Async Calling
2020-05-19 06:24:02 -04:00
Driftay
c22e3a5227 F Show Async Calling 2020-05-19 06:22:09 -04:00
Driftay
cf71603eeb Merge pull request #117 from SaberLLC/beta
Beta
2020-05-18 04:31:06 -04:00
Driftay
c45b68a95f Merge pull request #116 from Aeris1One/patch-1
Fix
2020-05-18 04:29:42 -04:00
Aeris One
67a9a6db28 Update ja_JP.yml 2020-05-16 12:07:53 +02:00
DroppingAnvil
0ea56fe5d2 World now per range instead of global + CmdWild cleanup 2020-05-12 14:41:12 -05:00
DroppingAnvil
7d3c4d6e33 Merge pull request #115 from Stefan923/1.6.x
Fixed a JSON issue.
2020-05-11 16:47:08 -05:00
Stefan923
4d05b4a376 Fixed "RESET is not a style/color" error. 2020-05-10 17:18:48 +03:00
Driftay
c29850eaaa Fixes NPE on Saving Task onDisable MPlugin, removed Async Throw for 1.15 in F Show 2020-05-09 14:04:17 -04:00
Driftay
ece5dd0bb7 Merge pull request #113 from Stefan923/1.6.x
Fixed issues
2020-05-09 14:01:55 -04:00
Driftay
bbaee8ab06 Merge pull request #114 from Stefan923/1.6.x
Fixed issues
2020-05-09 13:39:51 -04:00
Stefan923
c42949ec59 Fixed a bug: people were able to move banned items in /f chest by using hotbar keys. 2020-05-09 17:37:06 +03:00
Stefan923
f5f8e6aad2 Edited some translation messages. 2020-05-09 16:22:16 +03:00
Stefan923
447bfedbb1 Fixed an internal error caused by some unhandled cases. 2020-05-09 15:51:14 +03:00
Stefan923
1d4a1c2a1a Avoid disabling player's flight mode if it's not enabled. 2020-05-09 14:53:53 +03:00
Stefan923
31b8f0be25 Fixed internal error caused by trying to demote a player who already has the lowest rank 2020-05-09 14:53:02 +03:00
Driftay
e2d85d83f3 Merge pull request #111 from Stefan923/1.6.x
Fixed AutoFly issue
2020-05-08 20:22:33 -04:00
Driftay
66f2fd22f6 Merge pull request #112 from SaberLLC/beta
Beta
2020-05-08 20:21:55 -04:00
Stefan923
842eb097c6 Fixed issue. If the player does not have the fly activated when he joins another teritory, it skips the checks and his flight is activated. 2020-05-09 00:30:03 +03:00
DroppingAnvil
2f18da3cfb Merge pull request #110 from Stefan923/1.6.x
Fixed issues
2020-05-08 15:57:02 -05:00
Stefan923
5fb8d06d98 Fixed the asynchronous command dispatch issue. The issue was being thrown on PaperSpigot and its forks. 2020-05-08 20:29:54 +03:00
Stefan923
868e7f4102 Method weren't formatting both color and style to the same text. 2020-05-08 20:27:03 +03:00
Popescu Ștefan
d8b08ef6d7 Merge pull request #1 from SaberLLC/beta
Beta
2020-05-07 23:06:20 +03:00
DroppingAnvil
7bffed2d34 Merge pull request #108 from Stefan923/1.6.x
Fixed an issue with disband GUI
2020-05-07 14:44:15 -05:00
BrowkS
541e1fc69b Fixed issue - ignoring "useDisbandGui" if the player is not an OP 2020-05-07 22:36:39 +03:00
Driftay
07dce634af Addressed Config Properly 2020-05-07 12:23:32 -04:00
Driftay
75faaa4bb5 More Radius Claiming Changes 2020-05-07 07:07:40 -04:00
Driftay
17e2a86717 Cleaned Up Double Message With Fly & Double Message With Radius Claim System When Claiming A Single Claim 2020-05-07 05:56:12 -04:00
Driftay
f384100925 Fixed Small Issue With Owner List In Replacement Of TL Translation 2020-05-07 05:26:08 -04:00
Driftay
b8c695c2f4 Grace Check in checkForExplosion Method & Added a Async Task On Show.
NOTE: Ran 100 Alts Running /f who every second whilst all being in my faction with 0 lag or errors with LuckPerms
2020-05-07 05:11:28 -04:00
Driftay
78a5e65e5c Merge pull request #106 from Stefan923/1.6.x
Fixed some internal errors caused by using /f wild and a placeholder issue
2020-05-07 01:57:05 -04:00
Driftay
33761fee2b Radius Claiming Finalized, Few Fixes With Econ & Essentials & Fly Performance 2020-05-07 01:55:24 -04:00
BrowkS
bf23521309 Sending join message to faction members after setting player's faction and role. 2020-05-06 22:32:40 +03:00
BrowkS
55fd5ffdfd Added {player-role} placeholder. 2020-05-06 13:07:16 +03:00
BrowkS
04273de995 Removed an unnecessary check 2020-05-06 12:36:24 +03:00
Stefan923
7fc1ad19ad Fixed an internal error. Trying to send a message without enough arguments. 2020-05-05 18:32:50 +03:00
Stefan923
01913e7286 Fixed an internal error. Player wasn't being removed from teleportRange after a failed teleportation. 2020-05-05 18:30:09 +03:00
Driftay
ae7bb670d7 Reverted Back To Old Fly Mechanics 2020-05-05 07:20:06 -04:00
Driftay
499d41dea0 Radius Claiming & Alt Limit Fix 2020-05-04 20:27:39 -04:00
DroppingAnvil
e0d2e6b4db Version change for fly changes 2020-04-30 14:40:59 -05:00
DroppingAnvil
e37745eff9 Fixed a few known issues with F Fly 2020-04-30 14:27:26 -05:00
DroppingAnvil
86cba0e24c PlaceholderAPI expansion revamp 2020-04-29 16:31:47 -05:00
droppinganvil
69a4651e23 Merge remote-tracking branch 'origin/1.6.x' into 1.6.x 2020-04-26 12:54:03 -05:00
DroppingAnvil
f2c6d0b9da Even more fly changes 2020-04-26 12:53:48 -05:00
Driftay
8f343a5344 FIXED MASSIVE BUG WITH SAVING 2020-04-21 21:39:28 -04:00
Driftay
8665d92476 FIXED MASSIVE BUG WITH SAVING 2020-04-21 20:25:44 -04:00
droppinganvil
b89db7b082 Merge remote-tracking branch 'origin/1.6.x' into 1.6.x 2020-04-21 16:04:39 -05:00
DroppingAnvil
00cb78fd9b Set a world for /f wild 2020-04-21 16:04:18 -05:00
71 changed files with 1357 additions and 1122 deletions

View File

@@ -4,7 +4,7 @@
<groupId>com.massivecraft</groupId>
<artifactId>Factions</artifactId>
<version>1.6.9.5-2.3.4-RC</version>
<version>1.6.9.5-2.3.9-RC</version>
<packaging>jar</packaging>
<name>SaberFactions</name>
@@ -108,7 +108,7 @@
<dependency>
<groupId>com.github.stefvanschie.inventoryframework</groupId>
<artifactId>IF</artifactId>
<version>0.5.8</version>
<version>0.5.19</version>
</dependency>
<dependency>
<groupId>org.spigotmc</groupId>

View File

@@ -103,6 +103,9 @@ public class Conf {
public static boolean worldGuardChecking = false;
public static boolean worldGuardBuildPriority = false;
//RADIUS CLAIMING
public static boolean useRadiusClaimSystem = true;
//FRIENDLY FIRE
public static boolean friendlyFireFPlayersCommand = false;
@@ -276,8 +279,7 @@ public class Conf {
/// Useful for HCF features.
/// </summary>
public static Set<Material> territoryBypassProtectedMaterials = EnumSet.noneOf(Material.class);
// Dependency check
public static boolean dependencyCheck = true;
public static boolean enableClickToClaim = true;
public static Set<Material> territoryCancelAndAllowItemUseMaterial = new HashSet<>();
@@ -424,6 +426,8 @@ public class Conf {
public static HashMap<String, DefaultPermissions> defaultFactionPermissions = new HashMap<>();
public static HashSet<PermissableAction> lockedPermissions = new HashSet<>();
public static boolean useComplexFly = true;
public static boolean wildLoadChunkBeforeTeleport = true;
private static transient Conf i = new Conf();
@@ -556,7 +560,6 @@ public class Conf {
territoryDenyUsageMaterials.add(Material.ARMOR_STAND);
}
territoryProtectedMaterialsWhenOffline.add(Material.BEACON);
territoryDenyUsageMaterialsWhenOffline.add(XMaterial.FIRE_CHARGE.parseMaterial());

View File

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

View File

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

View File

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

View File

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

View File

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

View File

@@ -3,10 +3,7 @@ package com.massivecraft.factions.cmd;
import com.massivecraft.factions.Conf;
import com.massivecraft.factions.FPlayer;
import com.massivecraft.factions.FPlayers;
import com.massivecraft.factions.FactionsPlugin;
import com.massivecraft.factions.struct.Permission;
import com.massivecraft.factions.struct.Role;
import com.massivecraft.factions.zcore.fperms.Access;
import com.massivecraft.factions.zcore.fperms.PermissableAction;
import com.massivecraft.factions.zcore.util.TL;
import mkremins.fanciful.FancyMessage;
@@ -56,6 +53,7 @@ public class CmdDeinvite extends FCommand {
context.faction.msg(TL.COMMAND_DEINVITE_REVOKES, context.fPlayer.describeTo(context.faction), you.describeTo(context.faction));
}
@Override
public TL getUsageTranslation() {
return TL.COMMAND_DEINVITE_DESCRIPTION;

View File

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

View File

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

View File

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

View File

@@ -9,7 +9,6 @@ import com.massivecraft.factions.util.CC;
import com.massivecraft.factions.zcore.fperms.PermissableAction;
import com.massivecraft.factions.zcore.util.TL;
import mkremins.fanciful.FancyMessage;
import org.bukkit.ChatColor;
public class CmdInvite extends FCommand {
@@ -61,9 +60,9 @@ public class CmdInvite extends FCommand {
if (target.isOnline()) {
// Tooltips, colors, and commands only apply to the string immediately before it.
FancyMessage message = new FancyMessage(TL.COMMAND_INVITE_INVITEDYOU.toString()
.replace("%1$s", context.fPlayer.describeTo(target, true))
.replace("%2$s", context.faction.getTag())
.replaceAll("&", "§"))
.replace("%1$s", context.fPlayer.describeTo(target, true))
.replace("%2$s", context.faction.getTag())
.replaceAll("&", "§"))
.tooltip(TL.COMMAND_INVITE_CLICKTOJOIN.toString())
.command("/" + Conf.baseCommandAliases.get(0) + " join " + context.faction.getTag());
message.send(target.getPlayer());

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

@@ -5,7 +5,6 @@ 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.Material;
public class CmdUnban extends FCommand {

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

@@ -63,6 +63,11 @@ public class CmdUnclaim extends FCommand {
boolean didUnClaim = unClaim(new FLocation(context.player), context);
if (didUnClaim && !context.fPlayer.canFlyAtLocation())
context.fPlayer.setFFlying(false, false);
for(FPlayer fPlayer : context.faction.getFPlayersWhereOnline(true)){
if(!fPlayer.canFlyAtLocation())
fPlayer.setFFlying(false, false);
}
} else {
// radius claim
if (!Permission.CLAIM_RADIUS.has(context.sender, false)) {
@@ -83,10 +88,13 @@ public class CmdUnclaim extends FCommand {
this.stop();
return false;
}
return true;
}
};
boolean didUnClaim = unClaim(new FLocation(context.player), context);
if (didUnClaim && !context.fPlayer.canFlyAtLocation())
context.fPlayer.setFFlying(false, false);
}
}

View File

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

View File

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

View File

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

View File

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

View File

@@ -19,8 +19,12 @@ import org.bukkit.potion.PotionEffectType;
import java.util.HashMap;
import java.util.HashSet;
import java.util.Objects;
import java.util.Random;
/**
* @author DroppingAnvil
*/
public class CmdWild extends FCommand implements WaitedTask {
public static HashMap<Player, String> teleportRange;
public static HashSet<Player> teleporting;
@@ -41,8 +45,6 @@ public class CmdWild extends FCommand implements WaitedTask {
public void perform(CommandContext context) {
if (!teleportRange.containsKey(context.player)) {
context.player.openInventory(new WildGUI(context.player, context.fPlayer).getInventory());
} else {
context.fPlayer.msg(TL.COMMAND_WILD_WAIT);
}
}
@@ -52,11 +54,12 @@ public class CmdWild extends FCommand implements WaitedTask {
int tries = 0;
ConfigurationSection c = FactionsPlugin.getInstance().getConfig().getConfigurationSection("Wild.Zones." + teleportRange.get(p));
while (tries < 5) {
assert c != null;
int x = new Random().nextInt((c.getInt("Range.MaxX") - c.getInt("Range.MinX")) + 1) + c.getInt("Range.MinX");
int z = new Random().nextInt((c.getInt("Range.MaxZ") - c.getInt("Range.MinZ")) + 1) + c.getInt("Range.MinZ");
if (Board.getInstance().getFactionAt(new FLocation(p.getWorld().getName(), x, z)).isWilderness()) {
success = true;
FLocation loc = new FLocation(p.getWorld().getName(), x, z);
FLocation loc = new FLocation(Objects.requireNonNull(c.getString("World", "World")), x, z);
teleportRange.remove(p);
if (!FPlayers.getInstance().getByPlayer(p).takeMoney(c.getInt("Cost"))) {
p.sendMessage(TL.GENERIC_NOTENOUGHMONEY.toString());
@@ -70,15 +73,16 @@ public class CmdWild extends FCommand implements WaitedTask {
}
if (!success) {
p.sendMessage(TL.COMMAND_WILD_FAILED.toString());
teleportRange.remove(p);
}
}
public void teleportPlayer(Player p, FLocation loc) {
Location finalLoc;
if (FactionsPlugin.getInstance().getConfig().getBoolean("Wild.Arrival.SpawnAbove")) {
finalLoc = new Location(p.getWorld(), loc.getX(), p.getWorld().getHighestBlockYAt(Math.round(loc.getX()), Math.round(loc.getZ())) + FactionsPlugin.getInstance().getConfig().getInt("Wild.Arrival.SpawnAboveBlocks", 1), loc.getZ());
finalLoc = new Location(loc.getWorld(), loc.getX(), loc.getWorld().getHighestBlockYAt(Math.round(loc.getX()), Math.round(loc.getZ())) + FactionsPlugin.getInstance().getConfig().getInt("Wild.Arrival.SpawnAboveBlocks", 1), loc.getZ());
} else {
finalLoc = new Location(p.getWorld(), loc.getX(), p.getWorld().getHighestBlockYAt(Math.round(loc.getX()), Math.round(loc.getZ())), loc.getZ());
finalLoc = new Location(loc.getWorld(), loc.getX(), loc.getWorld().getHighestBlockYAt(Math.round(loc.getX()), Math.round(loc.getZ())), loc.getZ());
}
p.teleport(finalLoc, PlayerTeleportEvent.TeleportCause.PLUGIN);
setTeleporting(p);
@@ -87,7 +91,7 @@ public class CmdWild extends FCommand implements WaitedTask {
public void applyEffects(Player p) {
for (String s : FactionsPlugin.getInstance().getConfig().getStringList("Wild.Arrival.Effects")) {
p.addPotionEffect(new PotionEffect(PotionEffectType.getByName(s), 40, 1));
p.addPotionEffect(new PotionEffect(Objects.requireNonNull(PotionEffectType.getByName(s)), 40, 1));
}
}
@@ -109,6 +113,6 @@ public class CmdWild extends FCommand implements WaitedTask {
@Override
public void handleFailure(Player player) {
player.sendMessage(TL.COMMAND_WILD_INTERUPTED.toString());
teleportRange.remove(player);
}
}
}

View File

@@ -20,6 +20,9 @@ import java.util.HashMap;
import java.util.List;
import java.util.Objects;
/**
* @author DroppingAnvil
*/
public class WildGUI implements FactionGUI {
Player player;
FPlayer fplayer;
@@ -57,7 +60,8 @@ public class WildGUI implements FactionGUI {
inv.setItem(fill, fillItem);
}
for (String key : Objects.requireNonNull(FactionsPlugin.getInstance().getConfig().getConfigurationSection("Wild.Zones")).getKeys(false)) {
ItemStack zoneItem = XMaterial.matchXMaterial(FactionsPlugin.getInstance().getConfig().getString("Wild.Zones." + key + ".Material")).get().parseItem();
ItemStack zoneItem = XMaterial.matchXMaterial(Objects.requireNonNull(FactionsPlugin.getInstance().getConfig().getString("Wild.Zones." + key + ".Material"))).get().parseItem();
assert zoneItem != null;
ItemMeta zoneMeta = zoneItem.getItemMeta();
if (zoneMeta == null) return;
List<String> lore = new ArrayList<>();

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

@@ -27,7 +27,6 @@ import org.bukkit.event.EventPriority;
import org.bukkit.event.Listener;
import org.bukkit.event.block.*;
import org.bukkit.event.entity.EntityChangeBlockEvent;
import org.bukkit.event.entity.EntityExplodeEvent;
import org.bukkit.event.hanging.HangingBreakByEntityEvent;
import org.bukkit.inventory.ItemStack;
import org.bukkit.inventory.meta.ItemMeta;
@@ -187,7 +186,7 @@ public class FactionsBlockListener implements Listener {
Faction to = Board.getInstance().getFactionAt(new FLocation(event.getToBlock()));
if (from == to) return;
// from faction != to faction
if(to.isSystemFaction()) {
if (to.isSystemFaction()) {
event.setCancelled(true);
return;
}
@@ -431,7 +430,8 @@ public class FactionsBlockListener implements Listener {
if (!justCheck) fPlayer.setLastFrostwalkerMessage();
// Check if they have build permissions here. If not, block this from happening.
if (!playerCanBuildDestroyBlock(player, location, PermissableAction.FROST_WALK.toString(), justCheck)) event.setCancelled(true);
if (!playerCanBuildDestroyBlock(player, location, "frostwalk", justCheck))
event.setCancelled(true);
}
@EventHandler
@@ -512,7 +512,6 @@ public class FactionsBlockListener implements Listener {
Player p = (Player) event.getRemover();
if (!playerCanBuildDestroyBlock(p, event.getEntity().getLocation(), "destroy", true)) {
event.setCancelled(true);
return;
}
}
}
@@ -522,7 +521,7 @@ public class FactionsBlockListener implements Listener {
public void onFarmLandDamage(EntityChangeBlockEvent event) {
if (event.getEntity() instanceof Player) {
Player player = (Player) event.getEntity();
if (!playerCanBuildDestroyBlock(player, event.getBlock().getLocation(), PermissableAction.DESTROY.name(), true)) {
if (!playerCanBuildDestroyBlock(player, event.getBlock().getLocation(), "destroy", true)) {
FPlayer me = FPlayers.getInstance().getByPlayer(player);
Faction otherFaction = Board.getInstance().getFactionAt(new FLocation(event.getBlock().getLocation()));
me.msg(TL.ACTION_DENIED_OTHER, otherFaction.getTag(), "trample crops");
@@ -530,4 +529,4 @@ public class FactionsBlockListener implements Listener {
}
}
}
}
}

View File

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

View File

@@ -4,7 +4,6 @@ import com.massivecraft.factions.*;
import com.massivecraft.factions.cmd.CmdFGlobal;
import com.massivecraft.factions.cmd.CmdFly;
import com.massivecraft.factions.cmd.CmdSeeChunk;
import com.massivecraft.factions.cmd.FCmdRoot;
import com.massivecraft.factions.cmd.audit.FLogType;
import com.massivecraft.factions.cmd.logout.LogoutHandler;
import com.massivecraft.factions.cmd.wild.CmdWild;
@@ -36,8 +35,6 @@ import net.dv8tion.jda.core.entities.Member;
import net.dv8tion.jda.core.entities.TextChannel;
import org.bukkit.*;
import org.bukkit.block.Block;
import org.bukkit.entity.Boat;
import org.bukkit.entity.Minecart;
import org.bukkit.entity.Player;
import org.bukkit.event.Event;
import org.bukkit.event.EventHandler;
@@ -57,9 +54,9 @@ import java.util.logging.Level;
public class FactionsPlayerListener implements Listener {
public final static Map<UUID, Location> lastLocations = new HashMap<>();
public static Set<FLocation> corners;
public static BukkitTask positionTask = null;
public static Map<UUID, Location> lastLocations = new HashMap<>();
/**
* @author FactionsUUID Team
*/
@@ -311,7 +308,7 @@ public class FactionsPlayerListener implements Listener {
if ((landOwned && factionToCheck.getOwnerListString(loc).contains(player.getName())) || (me.getRole() == Role.LEADER && me.getFactionId().equals(factionToCheck.getId()))) {
return true;
} else if (landOwned && !factionToCheck.getOwnerListString(loc).contains(player.getName())) {
me.msg(TL.ACTIONS_OWNEDTERRITORYDENY, factionToCheck.getOwnerListString(loc));
me.msg(TL.ACTIONS_OWNEDTERRITORYDENY.toString().replace("{owners}", factionToCheck.getOwnerListString(loc)));
if (doPain) player.damage(Conf.actionDeniedPainAmount);
return false;
} else if (!landOwned && access == Access.ALLOW) {
@@ -479,6 +476,8 @@ public class FactionsPlayerListener implements Listener {
// Update the lastLoginTime for this fplayer
me.setLastLoginTime(System.currentTimeMillis());
lastLocations.put(player.getUniqueId(), player.getLocation());
// Store player's current FLocation and notify them where they are
me.setLastStoodAt(new FLocation(player.getLocation()));
@@ -535,6 +534,7 @@ public class FactionsPlayerListener implements Listener {
@EventHandler(priority = EventPriority.NORMAL)
public void onPlayerQuit(PlayerQuitEvent event) {
Player this_ = event.getPlayer();
FPlayer me = FPlayers.getInstance().getByPlayer(event.getPlayer());
// Make sure player's power is up to date when they log off.
@@ -551,6 +551,8 @@ public class FactionsPlayerListener implements Listener {
FactionsPlugin.instance.getTimers().remove(me.getPlayer().getUniqueId());
}
lastLocations.remove(this_.getUniqueId());
Faction myFaction = me.getFaction();
if (!myFaction.isWilderness()) myFaction.memberLoggedOff();
@@ -575,17 +577,19 @@ public class FactionsPlayerListener implements Listener {
.replace("{leader}", faction.getFPlayerAdmin() + "");
return string;
}
@Deprecated
public void checkCanFly(FPlayer me) {
if (!FactionsPlugin.factionsFlight || !FactionsPlugin.instance.getConfig().getBoolean("ffly.AutoEnable"))
if (!me.canFlyAtLocation() || me.checkIfNearbyEnemies()) {
if (me.isFlying())
me.setFFlying(false, false);
return;
if (me.isFlying()) return;
if (me.getPlayer().hasPermission(Permission.FLY_FLY.node)) {
me.setFFlying(true, false);
CmdFly.flyMap.put(me.getName(), true);
if (CmdFly.particleTask == null)
CmdFly.startParticles();
}
if (me.isFlying() || !FactionsPlugin.instance.getConfig().getBoolean("ffly.AutoEnable"))
return;
me.setFFlying(true, false);
CmdFly.flyMap.put(me.getName(), true);
if (CmdFly.particleTask == null)
CmdFly.startParticles();
}
//inspect
@@ -651,14 +655,12 @@ public class FactionsPlayerListener implements Listener {
}
public void startPositionCheck() {
positionTask = Bukkit.getScheduler().runTaskTimer(FactionsPlugin.instance, () -> {
if (Bukkit.getOnlinePlayers().size() > 0) {
for (Player player : Bukkit.getOnlinePlayers()) {
if (!lastLocations.containsKey(player.getUniqueId())) {
lastLocations.put(player.getUniqueId(), player.getLocation());
continue;
}
refreshPosition(player, lastLocations.get(player.getUniqueId()), player.getLocation());
positionTask = Bukkit.getScheduler().runTaskTimer(FactionsPlugin.getInstance(), () -> {
if (lastLocations.isEmpty()) return;
for (Map.Entry<UUID, Location> check : lastLocations.entrySet()) {
Player player = Bukkit.getPlayer(check.getKey());
if (player != null) {
refreshPosition(player, check.getValue(), player.getLocation());
lastLocations.put(player.getUniqueId(), player.getLocation());
}
}
@@ -724,18 +726,20 @@ public class FactionsPlayerListener implements Listener {
}, 5);
}
}
if (FCmdRoot.instance.fFlyEnabled && CmdFly.autoenable && CmdFly.checkFly(me, me.getPlayer(), factionTo)) {
me.setFFlying(true, false);
CmdFly.flyMap.put(me.getName(), true);
if (CmdFly.particleTask == null)
CmdFly.startParticles();
}
checkCanFly(me);
Faction at = Board.getInstance().getFactionAt(new FLocation(me.getPlayer().getLocation()));
if (me.getAutoClaimFor() != null) {
me.attemptClaim(me.getAutoClaimFor(), newLocation, true);
if (FactionsPlugin.cachedRadiusClaim && me.attemptClaim(me.getFaction(), me.getPlayer().getLocation(), true)) {
me.getFaction().getFPlayersWhereOnline(true).forEach(f -> f.msg(TL.CLAIM_CLAIMED, me.describeTo(f, true), me.getFaction().describeTo(f), at.describeTo(f)));
} else {
me.attemptClaim(me.getAutoClaimFor(), newLocation, true);
}
FactionsPlugin.instance.logFactionEvent(me.getAutoClaimFor(), FLogType.CHUNK_CLAIMS, me.getName(), CC.GreenB + "CLAIMED", String.valueOf(1), (new FLocation(player.getLocation())).formatXAndZ(","));
if (Conf.disableFlightOnFactionClaimChange) CmdFly.disableFlight(me);
if (Conf.disableFlightOnFactionClaimChange && FactionsPlugin.getInstance().getConfig().getBoolean("enable-faction-flight"))
CmdFly.disableFlight(me);
} else if (me.isAutoSafeClaimEnabled()) {
if (!Permission.MANAGE_SAFE_ZONE.has(player)) {
me.setIsAutoSafeClaimEnabled(false);
@@ -857,7 +861,7 @@ public class FactionsPlayerListener implements Listener {
Block block = event.getClickedBlock();
if (event.getAction() == Action.RIGHT_CLICK_BLOCK && block.getType() == XMaterial.GRASS_BLOCK.parseMaterial()
&& event.hasItem() && event.getItem().getType() == XMaterial.BONE_MEAL.parseMaterial()) {
if (!FactionsBlockListener.playerCanBuildDestroyBlock(event.getPlayer(), block.getLocation(), PermissableAction.BUILD.name(), true)) {
if (!FactionsBlockListener.playerCanBuildDestroyBlock(event.getPlayer(), block.getLocation(), "build", true)) {
FPlayer me = FPlayers.getInstance().getById(event.getPlayer().getUniqueId().toString());
Faction myFaction = me.getFaction();

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

@@ -663,25 +663,34 @@ public abstract class MemoryFPlayer implements FPlayer {
public void updatePower() {
if (this.isOffline()) {
losePowerFromBeingOffline();
if (!Conf.powerRegenOffline) return;
if (!Conf.powerRegenOffline) {
return;
}
} else if (hasFaction() && getFaction().isPowerFrozen()) {
return; // Don't let power regen if faction power is frozen.
}
long now = System.currentTimeMillis();
this.millisPassed = now - this.lastPowerUpdateTime;
long millisPassed = now - this.lastPowerUpdateTime;
this.lastPowerUpdateTime = now;
Player thisPlayer = this.getPlayer();
if (thisPlayer != null && thisPlayer.isDead())
if (thisPlayer != null && thisPlayer.isDead()) {
return; // don't let dead players regain power until they respawn
PowerRegenEvent powerRegenEvent = new PowerRegenEvent(getFaction(), this);
Bukkit.getScheduler().runTask(FactionsPlugin.getInstance(), () -> Bukkit.getServer().getPluginManager().callEvent(powerRegenEvent));
}
if (!powerRegenEvent.isCancelled())
if (!powerRegenEvent.usingCustomPower())
this.alterPower(millisPassed * Conf.powerPerMinute / 60000); // millisPerMinute : 60 * 1000
else this.alterPower(+powerRegenEvent.getCustomPower());
double delta = millisPassed * Conf.powerPerMinute / 60000; // millisPerMinute : 60 * 1000
if (Bukkit.getPluginManager().getPlugin("FactionsPlugin") != null) {
Bukkit.getScheduler().runTask(FactionsPlugin.getInstance(), () -> {
PowerRegenEvent powerRegenEvent = new PowerRegenEvent(getFaction(), this, delta);
Bukkit.getServer().getPluginManager().callEvent(powerRegenEvent);
if (!powerRegenEvent.isCancelled()) {
this.alterPower(powerRegenEvent.getDelta());
}
});
} else {
this.alterPower(delta);
}
}
public void losePowerFromBeingOffline() {
@@ -729,7 +738,7 @@ public abstract class MemoryFPlayer implements FPlayer {
public void sendFactionHereMessage(Faction from) {
Faction toShow = Board.getInstance().getFactionAt(getLastStoodAt());
if(Conf.worldsNoClaiming.contains(getLastStoodAt().getWorldName())) return;
if (Conf.worldsNoClaiming.contains(getLastStoodAt().getWorldName())) return;
if (showInfoBoard(toShow)) {
FScoreboard.get(this).setTemporarySidebar(new FInfoSidebar(toShow));
@@ -851,7 +860,7 @@ public abstract class MemoryFPlayer implements FPlayer {
int factionBuffer = plugin.getConfig().getInt("hcf.buffer-zone", 0);
int worldBuffer = plugin.getConfig().getInt("world-border.buffer", 0) - 1;
if (Conf.worldGuardChecking && Worldguard.getInstance().checkForRegionsInChunk(flocation)) {
if (Conf.worldGuardChecking && Worldguard.getInstance().checkForRegionsInChunk(flocation)) {
// Checks for WorldGuard regions in the chunk attempting to be claimed
error = plugin.txt.parse(TL.CLAIM_PROTECTED.toString());
} else if (flocation.isOutsideWorldBorder(plugin.getConfig().getInt("world-border.buffer", 0) - 1)) {
@@ -864,7 +873,7 @@ public abstract class MemoryFPlayer implements FPlayer {
return true;
} else if (forFaction.isWarZone() && Permission.MANAGE_WAR_ZONE.has(getPlayer())) {
return true;
} else if (currentFaction.getAccess(this, PermissableAction.TERRITORY) == Access.ALLOW && forFaction != currentFaction ) {
} else if (currentFaction.getAccess(this, PermissableAction.TERRITORY) == Access.ALLOW && forFaction != currentFaction) {
return true;
} else if (myFaction != forFaction) {
error = plugin.txt.parse(TL.CLAIM_CANTCLAIM.toString(), forFaction.describeTo(this));
@@ -963,37 +972,38 @@ public abstract class MemoryFPlayer implements FPlayer {
}
public void setFFlying(boolean fly, boolean damage) {
if (!FactionsPlugin.factionsFlight)
return;
if (FactionsPlugin.getInstance().getConfig().getBoolean("enable-faction-flight")) {
Player player = getPlayer();
if (player == null) return;
Player player = getPlayer();
if (player == null) return;
player.setAllowFlight(fly);
player.setFlying(fly);
player.setAllowFlight(fly);
player.setFlying(fly);
if (!damage) {
msg(TL.COMMAND_FLY_CHANGE, fly ? "enabled" : "disabled");
if (!fly)
sendMessage(TL.COMMAND_FLY_COOLDOWN.toString().replace("{amount}", FactionsPlugin.getInstance().getConfig().getInt("fly-falldamage-cooldown", 3) + ""));
} else {
msg(TL.COMMAND_FLY_DAMAGE);
}
// If leaving fly mode, don't let them take fall damage for x seconds.
if (!fly) {
int cooldown = FactionsPlugin.getInstance().getConfig().getInt("fly-falldamage-cooldown", 3);
CmdFly.flyMap.remove(player.getName());
// If the value is 0 or lower, make them take fall damage.
// Otherwise, start a timer and have this cancel after a few seconds.
// Short task so we're just doing it in method. Not clean but eh.
if (cooldown > 0) {
setTakeFallDamage(false);
Bukkit.getScheduler().runTaskLater(FactionsPlugin.getInstance(), () -> setTakeFallDamage(true), 20L * cooldown);
if (!damage) {
msg(TL.COMMAND_FLY_CHANGE, fly ? "enabled" : "disabled");
if (!fly) {
sendMessage(TL.COMMAND_FLY_COOLDOWN.toString().replace("{amount}", FactionsPlugin.getInstance().getConfig().getInt("fly-falldamage-cooldown", 3) + ""));
}
} else {
msg(TL.COMMAND_FLY_DAMAGE);
}
// If leaving fly mode, don't let them take fall damage for x seconds.
if (!fly) {
int cooldown = FactionsPlugin.getInstance().getConfig().getInt("fly-falldamage-cooldown", 3);
CmdFly.flyMap.remove(player.getName());
// If the value is 0 or lower, make them take fall damage.
// Otherwise, start a timer and have this cancel after a few seconds.
// Short task so we're just doing it in method. Not clean but eh.
if (cooldown > 0) {
setTakeFallDamage(false);
Bukkit.getScheduler().runTaskLater(FactionsPlugin.getInstance(), () -> setTakeFallDamage(true), 20L * cooldown);
}
}
isFlying = fly;
}
isFlying = fly;
}
public boolean isInFactionsChest() {
@@ -1018,8 +1028,14 @@ public abstract class MemoryFPlayer implements FPlayer {
public boolean canFlyAtLocation(FLocation location) {
Faction faction = Board.getInstance().getFactionAt(location);
if ((faction == getFaction() && getRole() == Role.LEADER) || isAdminBypassing) return true;
if (faction.isSystemFaction()) return CmdFly.checkFly(this, getPlayer(), faction);
if ((faction == getFaction() && getRole() == Role.LEADER) || isAdminBypassing) {
return true;
}
if (faction.isSystemFaction()) {
return CmdFly.checkBypassPerms(this, getPlayer(), faction, false);
}
Access access = faction.getAccess(this, PermissableAction.FLY);
return access == null || access == Access.UNDEFINED || access == Access.ALLOW;
}
@@ -1206,11 +1222,11 @@ public abstract class MemoryFPlayer implements FPlayer {
}
public boolean hasFriendlyFire(){
public boolean hasFriendlyFire() {
return friendlyFire;
}
public void setFriendlyFire(boolean status){
public void setFriendlyFire(boolean status) {
friendlyFire = status;
}
@@ -1288,11 +1304,13 @@ public abstract class MemoryFPlayer implements FPlayer {
// announce success
Set<FPlayer> informTheseFPlayers = new HashSet<>();
informTheseFPlayers.add(this);
informTheseFPlayers.addAll(forFaction.getFPlayersWhereOnline(true));
for (FPlayer fp : informTheseFPlayers) {
fp.msg(TL.CLAIM_CLAIMED, this.describeTo(fp, true), forFaction.describeTo(fp), currentFaction.describeTo(fp));
if (!FactionsPlugin.cachedRadiusClaim) {
Set<FPlayer> informTheseFPlayers = new HashSet<>();
informTheseFPlayers.add(this);
informTheseFPlayers.addAll(forFaction.getFPlayersWhereOnline(true));
for (FPlayer fp : informTheseFPlayers) {
fp.msg(TL.CLAIM_CLAIMED, this.describeTo(fp, true), forFaction.describeTo(fp), currentFaction.describeTo(fp));
}
}
Board.getInstance().setFactionAt(forFaction, flocation);

View File

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

View File

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

View File

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

View File

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

View File

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

View File

@@ -282,6 +282,7 @@ show:
- '&4* &cDescription: &f{description}'
- '&4* &cLand / Power / Max Power: &f{chunks} &8/ &f{power} &8/ &f{maxPower}'
- '&4* &cFaction Strikes: &f{strikes}'
- '&4* &cShield Status: &f{shield-status}'
- '&4* &cFaction Points: &f{faction-points}'
- '&4* &cFounded: &f{create-date}'
- '&4* &cBalance: &f{faction-balance}'
@@ -832,7 +833,7 @@ Missions:
- "&b&lMine &f&n10,000&r &2Sugar Cane"
Mission:
Type: "MINE"
Material: "SUGAR_CANE_BLOCK"
Material: "SUGAR_CANE"
Amount: 10000
Reward:
Commands: ["f points add %faction% 100"]
@@ -1250,9 +1251,9 @@ fupgrades:
Members:
Max-Level: 3
Members-Limit:
level-1: 30
level-2: 35
level-3: 40
level-1: 5 #The Number Of Members It Will Increase By
level-2: 10
level-3: 15
Cost:
level-1: 1000000
level-2: 2000000
@@ -1266,9 +1267,9 @@ fupgrades:
- '&7&oYour current level is &e&l&o{level}'
- ''
- '&c&lFaction Member Limit'
- '&4&l* &cLevel 1: &f30'
- '&4&l* &cLevel 2: &f35'
- '&4&l* &cLevel 3: &f40'
- '&4&l* &cLevel 1: &f35'
- '&4&l* &cLevel 2: &f40'
- '&4&l* &cLevel 3: &f45'
- '&f'
- '&c&lCosts'
- '&4&l* &cLevel 1: &f$1,000,000'
@@ -1448,6 +1449,7 @@ Wild:
Zones:
# You may create your own zones here please just follow the original format #
Close:
World: world
Range:
MinX: -200
MaxX: 200
@@ -1462,6 +1464,7 @@ Wild:
Name: '&cLow Range'
Slot: 1
Medium:
World: world
Range:
MinX: -400
MaxX: 400
@@ -1476,6 +1479,7 @@ Wild:
Name: '&cMedium Range'
Slot: 4
Far:
World: world
Range:
MinX: -800
MaxX: 800
@@ -1555,6 +1559,7 @@ Wild:
# - {tnt-balance} : # of tnt a faction has in their tnt bank
# - {tnt-max-balance} : # of possible tnt a faction can have in their tnt bank
# - {faction-strikes} : # of strikes a faction has
# - {shield-status} : Status of the factions shield
# Faction Permissions GUI variables. Can only be used in GUI
# - {relation} : Shows relation name (Can be used in action and relation)

View File

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