commit
d8b08ef6d7
@ -279,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<>();
|
||||
@ -561,7 +560,6 @@ public class Conf {
|
||||
territoryDenyUsageMaterials.add(Material.ARMOR_STAND);
|
||||
}
|
||||
|
||||
|
||||
territoryProtectedMaterialsWhenOffline.add(Material.BEACON);
|
||||
|
||||
territoryDenyUsageMaterialsWhenOffline.add(XMaterial.FIRE_CHARGE.parseMaterial());
|
||||
|
@ -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;
|
||||
|
||||
@ -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,37 +174,22 @@ public class FactionsPlugin extends MPlugin {
|
||||
int pluginId = 7013;
|
||||
Metrics metrics = new Metrics(this, pluginId);
|
||||
|
||||
|
||||
if (!preEnable()) {
|
||||
this.loadSuccessful = false;
|
||||
return;
|
||||
}
|
||||
|
||||
if (!new File(this.getDataFolder() + "/config.yml").exists()) {
|
||||
this.saveResource("config.yml", false);
|
||||
this.reloadConfig();
|
||||
}
|
||||
|
||||
saveDefaultConfig();
|
||||
//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();
|
||||
@ -230,6 +206,8 @@ public class FactionsPlugin extends MPlugin {
|
||||
else faction.addFPlayer(fPlayer);
|
||||
}
|
||||
|
||||
Factions.getInstance().getAllFactions().forEach(Faction::refreshFPlayers);
|
||||
|
||||
if (getConfig().getBoolean("enable-faction-flight", true)) {
|
||||
UtilFly.run();
|
||||
}
|
||||
@ -261,7 +239,7 @@ public class FactionsPlugin extends MPlugin {
|
||||
}
|
||||
|
||||
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");
|
||||
@ -270,6 +248,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);
|
||||
@ -307,13 +286,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);
|
||||
@ -349,10 +329,6 @@ public class FactionsPlugin extends MPlugin {
|
||||
FactionsPlugin.startupFinished = true;
|
||||
}
|
||||
|
||||
public SkriptAddon getSkriptAddon() {
|
||||
return skriptAddon;
|
||||
}
|
||||
|
||||
|
||||
private void setupPlaceholderAPI() {
|
||||
Plugin clip = getServer().getPluginManager().getPlugin("PlaceholderAPI");
|
||||
@ -459,18 +435,19 @@ public class FactionsPlugin extends MPlugin {
|
||||
|
||||
@Override
|
||||
public void onDisable() {
|
||||
super.onDisable();
|
||||
if (this.loadSuccessful) {
|
||||
Conf.load();
|
||||
if (this.AutoLeaveTask != null) {
|
||||
getServer().getScheduler().cancelTask(this.AutoLeaveTask);
|
||||
this.AutoLeaveTask = null;
|
||||
}
|
||||
|
||||
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);
|
||||
@ -482,7 +459,7 @@ public class FactionsPlugin extends MPlugin {
|
||||
} catch (IOException e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
}
|
||||
|
||||
super.onDisable();
|
||||
}
|
||||
|
||||
@ -504,26 +481,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();
|
||||
}
|
||||
|
||||
@ -548,7 +508,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) {
|
||||
@ -596,70 +555,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;
|
||||
}
|
||||
@ -668,14 +568,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;
|
||||
@ -687,38 +579,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);
|
||||
@ -740,7 +604,4 @@ public class FactionsPlugin extends MPlugin {
|
||||
debug(Level.INFO, s);
|
||||
}
|
||||
|
||||
public Worldguard getWg() {
|
||||
return wg;
|
||||
}
|
||||
}
|
||||
|
@ -26,8 +26,7 @@ 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 static final boolean fly = FactionsPlugin.getInstance().getConfig().getBoolean("enable-faction-flight");
|
||||
|
||||
|
||||
@ -48,9 +47,7 @@ public class CmdFly extends FCommand {
|
||||
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,71 +59,31 @@ 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);
|
||||
Faction myFaction = fPlayer.getFaction();
|
||||
if (myFaction.isWilderness()) {
|
||||
fPlayer.setFlying(false);
|
||||
flyMap.remove(name);
|
||||
continue;
|
||||
}
|
||||
if (player.hasPermission("factions.fly.bypassnearbyenemycheck") || fPlayer.checkIfNearbyEnemies()) {
|
||||
continue;
|
||||
}
|
||||
FLocation myFloc = new FLocation(player.getLocation());
|
||||
if (Board.getInstance().getFactionAt(myFloc) != myFaction) {
|
||||
if (!checkBypassPerms(fPlayer, player, Board.getInstance().getFactionAt(myFloc))) {
|
||||
Bukkit.getScheduler().runTask(FactionsPlugin.instance, () -> fPlayer.setFFlying(false, false));
|
||||
flyMap.remove(name);
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
}, 20L, 20L);
|
||||
}
|
||||
|
||||
|
||||
public static boolean checkBypassPerms(FPlayer fme, Player me, Faction toFac) {
|
||||
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()) {
|
||||
fme.msg(TL.COMMAND_FLY_NO_ACCESS, toFac.getTag(fme));
|
||||
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) {
|
||||
fme.msg(TL.COMMAND_FLY_NO_ACCESS, toFac.getTag(fme));
|
||||
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) {
|
||||
fme.msg(TL.COMMAND_FLY_NO_ACCESS, toFac.getTag(fme));
|
||||
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) {
|
||||
fme.msg(TL.COMMAND_FLY_NO_ACCESS, toFac.getTag(fme));
|
||||
if(sendMessage) fme.msg(TL.COMMAND_FLY_NO_ACCESS, toFac.getTag(fme));
|
||||
return false;
|
||||
}
|
||||
|
||||
if (!(me.hasPermission(Permission.FLY_NEUTRAL.node) || access == Access.ALLOW) && toFac.getRelationTo(fme.getFaction()) == Relation.NEUTRAL && !toFac.isSystemFaction()) {
|
||||
fme.msg(TL.COMMAND_FLY_NO_ACCESS, toFac.getTag(fme));
|
||||
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());
|
||||
@ -135,21 +92,14 @@ public class CmdFly extends FCommand {
|
||||
}
|
||||
|
||||
|
||||
public static void checkTaskState() {
|
||||
if (flyMap.isEmpty()) {
|
||||
flyTask.cancel();
|
||||
flyTask = null;
|
||||
}
|
||||
}
|
||||
|
||||
public static void disableFlight(final FPlayer fme) {
|
||||
fme.setFlying(false);
|
||||
flyMap.remove(fme.getPlayer().getName());
|
||||
}
|
||||
|
||||
|
||||
public boolean isInFlightChecker(FPlayer fPlayer) {
|
||||
return flyMap.containsKey(fPlayer);
|
||||
public boolean isInFlightChecker(Player player) {
|
||||
return flyMap.containsKey(player.getName());
|
||||
}
|
||||
|
||||
@Override
|
||||
@ -171,7 +121,7 @@ public class CmdFly extends FCommand {
|
||||
|
||||
FLocation myfloc = new FLocation(context.player.getLocation());
|
||||
Faction toFac = Board.getInstance().getFactionAt(myfloc);
|
||||
if (!checkBypassPerms(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;
|
||||
}
|
||||
@ -195,13 +145,7 @@ public class CmdFly extends FCommand {
|
||||
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();
|
||||
}
|
||||
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());
|
||||
|
@ -78,8 +78,11 @@ public class CmdShow extends FCommand {
|
||||
return; // we only show header for non-normal factions
|
||||
}
|
||||
|
||||
for (String raw : show) {
|
||||
String parsed = TagUtil.parsePlain(faction, context.fPlayer, raw); // use relations
|
||||
List<String> finalShow = show;
|
||||
Faction finalFaction = faction;
|
||||
FactionsPlugin.getInstance().getServer().getScheduler().runTaskAsynchronously(FactionsPlugin.instance, () -> {
|
||||
for (String raw : finalShow) {
|
||||
String parsed = TagUtil.parsePlain(finalFaction, context.fPlayer, raw); // use relations
|
||||
if (parsed == null) {
|
||||
continue; // Due to minimal f show.
|
||||
}
|
||||
@ -89,7 +92,7 @@ public class CmdShow extends FCommand {
|
||||
}
|
||||
|
||||
if (TagUtil.hasFancy(parsed)) {
|
||||
List<FancyMessage> fancy = TagUtil.parseFancy(faction, context.fPlayer, parsed);
|
||||
List<FancyMessage> fancy = TagUtil.parseFancy(finalFaction, context.fPlayer, parsed);
|
||||
if (fancy != null)
|
||||
context.sendFancyMessage(fancy);
|
||||
|
||||
@ -106,6 +109,7 @@ public class CmdShow extends FCommand {
|
||||
context.msg(FactionsPlugin.getInstance().txt.parse(parsed));
|
||||
}
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
@Override
|
||||
|
@ -399,11 +399,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();
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -69,10 +69,10 @@ public class CmdAutoClaim extends FCommand {
|
||||
context.msg(TL.COMMAND_AUTOCLAIM_ENABLED, forFaction.describeTo(context.fPlayer));
|
||||
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)));
|
||||
return;
|
||||
}
|
||||
} else {
|
||||
context.fPlayer.attemptClaim(forFaction, context.fPlayer.getPlayer().getLocation(), true);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public TL getUsageTranslation() {
|
||||
|
@ -59,7 +59,7 @@ public class CmdClaim extends FCommand {
|
||||
Faction at = Board.getInstance().getFactionAt(new FLocation(context.fPlayer.getPlayer().getLocation()));
|
||||
|
||||
if (radius < 2) {
|
||||
if (FactionsPlugin.cachedRadiusClaim && context.fPlayer.attemptClaim(forFaction, context.player.getLocation(), true)) {
|
||||
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;
|
||||
|
@ -83,11 +83,13 @@ public class CmdClaimLine extends FCommand {
|
||||
|
||||
// TODO: make this a task like claiming a radius?
|
||||
int claims = 0;
|
||||
|
||||
for (int i = 0; i < amount; i++) {
|
||||
if (FactionsPlugin.cachedRadiusClaim && context.fPlayer.attemptClaim(forFaction, context.player.getLocation(), 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(","));
|
||||
|
@ -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,14 @@ 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) {
|
||||
FactionsPlugin.getInstance().log("NOTE: Economy is disabled. You can enable it with the command: f config econEnabled true");
|
||||
}
|
||||
|
||||
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 +61,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 +89,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 +114,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 +128,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 +150,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 +159,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 +192,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 +215,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 +279,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 +292,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 +316,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 +326,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) {
|
||||
|
@ -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;
|
||||
// Edge case handling.
|
||||
if (player == null) return false;
|
||||
boolean vanish = false;
|
||||
if (essentials != null) {
|
||||
User user = essentials.getUser(player);
|
||||
return user != null && user.isVanished();
|
||||
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;
|
||||
}
|
||||
}
|
||||
|
@ -4,6 +4,7 @@ import com.massivecraft.factions.*;
|
||||
import com.massivecraft.factions.event.PowerLossEvent;
|
||||
import com.massivecraft.factions.struct.Relation;
|
||||
import com.massivecraft.factions.util.MiscUtil;
|
||||
import com.massivecraft.factions.util.timer.type.GraceTimer;
|
||||
import com.massivecraft.factions.zcore.util.TL;
|
||||
import org.bukkit.Bukkit;
|
||||
import org.bukkit.Location;
|
||||
@ -258,6 +259,8 @@ public class FactionsEntityListener implements Listener {
|
||||
private boolean checkExplosionForBlock(Entity boomer, Block block) {
|
||||
Faction faction = Board.getInstance().getFactionAt(new FLocation(block.getLocation()));
|
||||
|
||||
if(FactionsPlugin.getInstance().getTimerManager().graceTimer.getRemaining() > 0) return false;
|
||||
|
||||
if (faction.noExplosionsInTerritory() || (faction.isPeaceful() && Conf.peacefulTerritoryDisableBoom))
|
||||
return false;
|
||||
// faction is peaceful and has explosions set to disabled
|
||||
|
@ -58,8 +58,6 @@ import java.util.logging.Level;
|
||||
public class FactionsPlayerListener implements Listener {
|
||||
|
||||
public static Set<FLocation> corners;
|
||||
public static BukkitTask positionTask = null;
|
||||
public static Map<UUID, Location> lastLocations = new HashMap<>();
|
||||
/**
|
||||
* @author FactionsUUID Team
|
||||
*/
|
||||
@ -311,7 +309,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 +477,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 +535,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 +552,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();
|
||||
|
||||
@ -651,43 +654,16 @@ public class FactionsPlayerListener implements Listener {
|
||||
return (result.length() == 3 ? result + "0" : result) + "/hrs ago";
|
||||
}
|
||||
|
||||
public static BukkitTask positionTask = null;
|
||||
public final static Map<UUID, Location> lastLocations = new HashMap<>();
|
||||
|
||||
public void startPositionCheck() {
|
||||
positionTask = Bukkit.getScheduler().runTaskTimer(FactionsPlugin.instance, () -> {
|
||||
if (Bukkit.getOnlinePlayers().size() > 0) {
|
||||
for (Player player : Bukkit.getOnlinePlayers()) {
|
||||
if (!lastLocations.containsKey(player.getUniqueId())) {
|
||||
positionTask = Bukkit.getScheduler().runTaskTimer(FactionsPlugin.getInstance(), () -> {
|
||||
if (lastLocations.isEmpty()) return;
|
||||
for (Map.Entry<UUID, Location> check : lastLocations.entrySet()) {
|
||||
Player player = Bukkit.getPlayer(check.getKey());
|
||||
refreshPosition(player, check.getValue(), player.getLocation());
|
||||
lastLocations.put(player.getUniqueId(), player.getLocation());
|
||||
continue;
|
||||
}
|
||||
refreshPosition(player, lastLocations.get(player.getUniqueId()), player.getLocation());
|
||||
lastLocations.put(player.getUniqueId(), player.getLocation());
|
||||
if (CmdFly.flyMap.containsKey(player.getName())) {
|
||||
String name = player.getName();
|
||||
if (!player.isFlying()
|
||||
|| player.getGameMode() == GameMode.CREATIVE
|
||||
|| !FactionsPlugin.instance.mc17 && player.getGameMode() == GameMode.SPECTATOR) {
|
||||
continue;
|
||||
}
|
||||
FPlayer fPlayer = FPlayers.getInstance().getByPlayer(player);
|
||||
Faction myFaction = fPlayer.getFaction();
|
||||
if (myFaction.isWilderness()) {
|
||||
Bukkit.getScheduler().runTask(FactionsPlugin.instance, () -> fPlayer.setFlying(false));
|
||||
CmdFly.flyMap.remove(player.getName());
|
||||
continue;
|
||||
}
|
||||
Bukkit.getScheduler().runTask(FactionsPlugin.instance, () -> {
|
||||
if (!fPlayer.checkIfNearbyEnemies()) {
|
||||
FLocation myFloc = new FLocation(player.getLocation());
|
||||
if (Board.getInstance().getFactionAt(myFloc) != myFaction) {
|
||||
if (!CmdFly.checkBypassPerms(fPlayer, player, Board.getInstance().getFactionAt(myFloc))) {
|
||||
fPlayer.setFFlying(false, false);
|
||||
CmdFly.flyMap.remove(name);
|
||||
}
|
||||
}
|
||||
}
|
||||
});
|
||||
}
|
||||
}
|
||||
}
|
||||
}, 5L, 10L);
|
||||
}
|
||||
|
@ -172,11 +172,13 @@ public abstract class MPlugin extends JavaPlugin {
|
||||
}
|
||||
|
||||
public void onDisable() {
|
||||
getServer().getScheduler().cancelTasks(this);
|
||||
if (saveTask != null) {
|
||||
this.getServer().getScheduler().cancelTask(saveTask);
|
||||
saveTask = null;
|
||||
}
|
||||
|
||||
this.getServer().getScheduler().cancelTasks(this);
|
||||
|
||||
// only save data if plugin actually loaded successfully
|
||||
if (loadSuccessful) {
|
||||
Factions.getInstance().forceSave();
|
||||
|
@ -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);
|
||||
|
@ -974,7 +974,6 @@ public abstract class MemoryFPlayer implements FPlayer {
|
||||
if (!fly) {
|
||||
sendMessage(TL.COMMAND_FLY_COOLDOWN.toString().replace("{amount}", FactionsPlugin.getInstance().getConfig().getInt("fly-falldamage-cooldown", 3) + ""));
|
||||
}
|
||||
|
||||
} else {
|
||||
msg(TL.COMMAND_FLY_DAMAGE);
|
||||
}
|
||||
@ -1023,7 +1022,7 @@ public abstract class MemoryFPlayer implements FPlayer {
|
||||
}
|
||||
|
||||
if (faction.isSystemFaction()) {
|
||||
return CmdFly.checkBypassPerms(this, getPlayer(), faction);
|
||||
return CmdFly.checkBypassPerms(this, getPlayer(), faction, false);
|
||||
}
|
||||
|
||||
Access access = faction.getAccess(this, PermissableAction.FLY);
|
||||
|
@ -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" : "") + ".");
|
||||
|
||||
|
||||
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);
|
||||
|
@ -148,7 +148,7 @@ public enum TL {
|
||||
|
||||
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."),
|
||||
|
||||
|
@ -105,7 +105,6 @@ public class TagUtil {
|
||||
if (FactionsPlugin.getInstance().isMVdWPlaceholderAPIHooked() && player.isOnline()) {
|
||||
line = be.maximvdw.placeholderapi.PlaceholderAPI.replacePlaceholders(player, line);
|
||||
}
|
||||
|
||||
return line;
|
||||
}
|
||||
|
||||
|
@ -832,7 +832,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 +1250,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 +1266,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'
|
||||
|
Loading…
Reference in New Issue
Block a user