Compare commits
22 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
d847013e39 | ||
|
|
06d85573ba | ||
|
|
9284707db6 | ||
|
|
7b07e3ed23 | ||
|
|
c0719ec4f5 | ||
|
|
c9fd86ef9e | ||
|
|
939a60c611 | ||
|
|
36f22262c6 | ||
|
|
f5e9ce3d90 | ||
|
|
e244b469aa | ||
|
|
5f80ecfa76 | ||
|
|
28517ef391 | ||
|
|
5744b7e28e | ||
|
|
f3b0dcdb7f | ||
|
|
0b127cbe72 | ||
|
|
4f6329996f | ||
|
|
3710031b80 | ||
|
|
6c10cdd47d | ||
|
|
5eeb8a2020 | ||
|
|
fe5378e9d7 | ||
|
|
e60d58e68b | ||
|
|
649392363f |
7
pom.xml
7
pom.xml
@@ -4,7 +4,7 @@
|
||||
|
||||
<groupId>com.massivecraft</groupId>
|
||||
<artifactId>Factions</artifactId>
|
||||
<version>1.6.9.5-U0.2.1-2.0.6-STABLE</version>
|
||||
<version>1.6.9.5-U0.2.1-2.1.0-BETA</version>
|
||||
<packaging>jar</packaging>
|
||||
|
||||
<name>SaberFactions</name>
|
||||
@@ -387,11 +387,6 @@
|
||||
<version>1.0.0</version>
|
||||
<scope>compile</scope>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>org.codemc.worldguardwrapper</groupId>
|
||||
<artifactId>worldguardwrapper</artifactId>
|
||||
<version>1.1.6-SNAPSHOT</version>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>com.jagrosh</groupId>
|
||||
<artifactId>jda-utilities-commons</artifactId>
|
||||
|
||||
@@ -115,6 +115,7 @@ public class Conf {
|
||||
public static boolean logMoneyTransactions = true;
|
||||
public static boolean logPlayerCommands = true;
|
||||
// prevent some potential exploits
|
||||
public static boolean denyFlightIfInNoClaimingWorld = false;
|
||||
public static boolean preventCreeperGlitch = true;
|
||||
public static boolean handleExploitObsidianGenerators = true;
|
||||
public static boolean handleExploitEnderPearlClipping = true;
|
||||
@@ -219,6 +220,10 @@ public class Conf {
|
||||
public static boolean ownedMessageInsideTerritory = true;
|
||||
public static boolean ownedMessageByChunk = false;
|
||||
public static boolean pistonProtectionThroughDenyBuild = true;
|
||||
|
||||
//logs
|
||||
public static Set<Material> loggableMaterials = EnumSet.noneOf(Material.class);
|
||||
|
||||
public static Set<Material> territoryProtectedMaterials = EnumSet.noneOf(Material.class);
|
||||
public static Set<Material> territoryDenyUsageMaterials = EnumSet.noneOf(Material.class);
|
||||
public static Set<Material> territoryProtectedMaterialsWhenOffline = EnumSet.noneOf(Material.class);
|
||||
@@ -231,6 +236,12 @@ public class Conf {
|
||||
public static Set<Material> territoryBypassProtectedMaterials = EnumSet.noneOf(Material.class);
|
||||
// Dependency check
|
||||
public static boolean dependencyCheck = true;
|
||||
|
||||
public static Set<Material> territoryCancelAndAllowItemUseMaterial = new HashSet<>();
|
||||
public static Set<Material> territoryDenySwitchMaterials = new HashSet<>();
|
||||
public static Set<Material> territoryBypasssProtectedMaterials = EnumSet.noneOf(Material.class);
|
||||
public static boolean allowCreeperEggingChests = true;
|
||||
|
||||
// Economy settings
|
||||
public static boolean econEnabled = false;
|
||||
public static String econUniverseAccount = "";
|
||||
@@ -343,6 +354,7 @@ public class Conf {
|
||||
// faction-<factionId>
|
||||
public static int defaultMaxVaults = 0;
|
||||
public static boolean disableFlightOnFactionClaimChange = true;
|
||||
public static boolean sendFactionChangeMessage = true;
|
||||
|
||||
public static Backend backEnd = Backend.JSON;
|
||||
|
||||
@@ -388,11 +400,108 @@ public class Conf {
|
||||
territoryEnemyDenyCommands.add("tpaccept");
|
||||
territoryEnemyDenyCommands.add("tpa");
|
||||
|
||||
territoryDenySwitchMaterials.add(XMaterial.ACACIA_FENCE_GATE.parseMaterial());
|
||||
territoryDenySwitchMaterials.add(XMaterial.BIRCH_FENCE_GATE.parseMaterial());
|
||||
territoryDenySwitchMaterials.add(XMaterial.DARK_OAK_FENCE_GATE.parseMaterial());
|
||||
territoryDenySwitchMaterials.add(XMaterial.JUNGLE_FENCE_GATE.parseMaterial());
|
||||
territoryDenySwitchMaterials.add(XMaterial.OAK_FENCE_GATE.parseMaterial());
|
||||
territoryDenySwitchMaterials.add(XMaterial.SPRUCE_FENCE_GATE.parseMaterial());
|
||||
territoryDenySwitchMaterials.add(XMaterial.ACACIA_DOOR.parseMaterial());
|
||||
territoryDenySwitchMaterials.add(XMaterial.BIRCH_DOOR.parseMaterial());
|
||||
territoryDenySwitchMaterials.add(XMaterial.DARK_OAK_DOOR.parseMaterial());
|
||||
territoryDenySwitchMaterials.add(XMaterial.JUNGLE_DOOR.parseMaterial());
|
||||
territoryDenySwitchMaterials.add(XMaterial.OAK_DOOR.parseMaterial());
|
||||
territoryDenySwitchMaterials.add(XMaterial.SPRUCE_DOOR.parseMaterial());
|
||||
territoryDenySwitchMaterials.add(XMaterial.DISPENSER.parseMaterial());
|
||||
territoryDenySwitchMaterials.add(XMaterial.CHEST.parseMaterial());
|
||||
territoryDenySwitchMaterials.add(XMaterial.TRAPPED_CHEST.parseMaterial());
|
||||
territoryDenySwitchMaterials.add(XMaterial.ACACIA_BUTTON.parseMaterial());
|
||||
territoryDenySwitchMaterials.add(XMaterial.BIRCH_BUTTON.parseMaterial());
|
||||
territoryDenySwitchMaterials.add(XMaterial.DARK_OAK_BUTTON.parseMaterial());
|
||||
territoryDenySwitchMaterials.add(XMaterial.JUNGLE_BUTTON.parseMaterial());
|
||||
territoryDenySwitchMaterials.add(XMaterial.OAK_BUTTON.parseMaterial());
|
||||
territoryDenySwitchMaterials.add(XMaterial.SPRUCE_BUTTON.parseMaterial());
|
||||
territoryDenySwitchMaterials.add(XMaterial.DROPPER.parseMaterial());
|
||||
territoryDenySwitchMaterials.add(XMaterial.HOPPER.parseMaterial());
|
||||
territoryDenySwitchMaterials.add(XMaterial.ITEM_FRAME.parseMaterial());
|
||||
territoryDenySwitchMaterials.add(XMaterial.ACACIA_TRAPDOOR.parseMaterial());
|
||||
territoryDenySwitchMaterials.add(XMaterial.BIRCH_TRAPDOOR.parseMaterial());
|
||||
territoryDenySwitchMaterials.add(XMaterial.DARK_OAK_TRAPDOOR.parseMaterial());
|
||||
territoryDenySwitchMaterials.add(XMaterial.JUNGLE_TRAPDOOR.parseMaterial());
|
||||
territoryDenySwitchMaterials.add(XMaterial.OAK_TRAPDOOR.parseMaterial());
|
||||
territoryDenySwitchMaterials.add(XMaterial.SPRUCE_TRAPDOOR.parseMaterial());
|
||||
territoryDenySwitchMaterials.add(XMaterial.LEVER.parseMaterial());
|
||||
territoryDenySwitchMaterials.add(XMaterial.COMPARATOR.parseMaterial());
|
||||
territoryDenySwitchMaterials.add(XMaterial.REPEATER.parseMaterial());
|
||||
territoryDenySwitchMaterials.add(XMaterial.ACACIA_BUTTON.parseMaterial());
|
||||
territoryDenySwitchMaterials.add(XMaterial.BIRCH_BUTTON.parseMaterial());
|
||||
territoryDenySwitchMaterials.add(XMaterial.DARK_OAK_BUTTON.parseMaterial());
|
||||
territoryDenySwitchMaterials.add(XMaterial.JUNGLE_BUTTON.parseMaterial());
|
||||
territoryDenySwitchMaterials.add(XMaterial.OAK_BUTTON.parseMaterial());
|
||||
territoryDenySwitchMaterials.add(XMaterial.SPRUCE_BUTTON.parseMaterial());
|
||||
|
||||
territoryDenySwitchMaterials.add(XMaterial.PURPLE_SHULKER_BOX.parseMaterial());
|
||||
territoryDenySwitchMaterials.add(XMaterial.WHITE_SHULKER_BOX.parseMaterial());
|
||||
territoryDenySwitchMaterials.add(XMaterial.MAGENTA_SHULKER_BOX.parseMaterial());
|
||||
territoryDenySwitchMaterials.add(XMaterial.LIGHT_BLUE_SHULKER_BOX.parseMaterial());
|
||||
territoryDenySwitchMaterials.add(XMaterial.CYAN_SHULKER_BOX.parseMaterial());
|
||||
territoryDenySwitchMaterials.add(XMaterial.BLUE_SHULKER_BOX.parseMaterial());
|
||||
territoryDenySwitchMaterials.add(XMaterial.BROWN_SHULKER_BOX.parseMaterial());
|
||||
territoryDenySwitchMaterials.add(XMaterial.ORANGE_SHULKER_BOX.parseMaterial());
|
||||
territoryDenySwitchMaterials.add(XMaterial.GREEN_SHULKER_BOX.parseMaterial());
|
||||
territoryDenySwitchMaterials.add(XMaterial.RED_SHULKER_BOX.parseMaterial());
|
||||
territoryDenySwitchMaterials.add(XMaterial.BLACK_SHULKER_BOX.parseMaterial());
|
||||
territoryDenySwitchMaterials.add(XMaterial.GRAY_SHULKER_BOX.parseMaterial());
|
||||
territoryDenySwitchMaterials.add(XMaterial.LIME_SHULKER_BOX.parseMaterial());
|
||||
territoryDenySwitchMaterials.add(XMaterial.LIGHT_GRAY_SHULKER_BOX.parseMaterial());
|
||||
territoryDenySwitchMaterials.add(XMaterial.PINK_SHULKER_BOX.parseMaterial());
|
||||
territoryDenySwitchMaterials.add(XMaterial.YELLOW_SHULKER_BOX.parseMaterial());
|
||||
territoryDenySwitchMaterials.add(XMaterial.SHULKER_BOX.parseMaterial());
|
||||
|
||||
// 1.14 Barrel is a container.
|
||||
territoryDenySwitchMaterials.add(XMaterial.BARREL.parseMaterial());
|
||||
|
||||
territoryCancelAndAllowItemUseMaterial.add(XMaterial.GOLDEN_APPLE.parseMaterial());
|
||||
territoryCancelAndAllowItemUseMaterial.add(XMaterial.APPLE.parseMaterial());
|
||||
territoryCancelAndAllowItemUseMaterial.add(XMaterial.ENCHANTED_GOLDEN_APPLE.parseMaterial());
|
||||
territoryCancelAndAllowItemUseMaterial.add(XMaterial.COOKED_BEEF.parseMaterial());
|
||||
territoryCancelAndAllowItemUseMaterial.add(XMaterial.COOKED_MUTTON.parseMaterial());
|
||||
territoryCancelAndAllowItemUseMaterial.add(XMaterial.COOKED_CHICKEN.parseMaterial());
|
||||
territoryCancelAndAllowItemUseMaterial.add(XMaterial.COOKED_COD.parseMaterial());
|
||||
territoryCancelAndAllowItemUseMaterial.add(XMaterial.COOKED_PORKCHOP.parseMaterial());
|
||||
territoryCancelAndAllowItemUseMaterial.add(XMaterial.COOKED_RABBIT.parseMaterial());
|
||||
territoryCancelAndAllowItemUseMaterial.add(XMaterial.COOKED_SALMON.parseMaterial());
|
||||
territoryCancelAndAllowItemUseMaterial.add(XMaterial.ENDER_PEARL.parseMaterial());
|
||||
territoryCancelAndAllowItemUseMaterial.add(XMaterial.POTION.parseMaterial());
|
||||
territoryCancelAndAllowItemUseMaterial.add(XMaterial.SPLASH_POTION.parseMaterial());
|
||||
territoryCancelAndAllowItemUseMaterial.add(XMaterial.CREEPER_SPAWN_EGG.parseMaterial());
|
||||
territoryCancelAndAllowItemUseMaterial.add(XMaterial.BOW.parseMaterial());
|
||||
territoryCancelAndAllowItemUseMaterial.add(XMaterial.DIAMOND_HELMET.parseMaterial());
|
||||
territoryCancelAndAllowItemUseMaterial.add(XMaterial.DIAMOND_CHESTPLATE.parseMaterial());
|
||||
territoryCancelAndAllowItemUseMaterial.add(XMaterial.DIAMOND_LEGGINGS.parseMaterial());
|
||||
territoryCancelAndAllowItemUseMaterial.add(XMaterial.DIAMOND_BOOTS.parseMaterial());
|
||||
territoryCancelAndAllowItemUseMaterial.add(XMaterial.IRON_HELMET.parseMaterial());
|
||||
territoryCancelAndAllowItemUseMaterial.add(XMaterial.IRON_CHESTPLATE.parseMaterial());
|
||||
territoryCancelAndAllowItemUseMaterial.add(XMaterial.IRON_LEGGINGS.parseMaterial());
|
||||
territoryCancelAndAllowItemUseMaterial.add(XMaterial.IRON_BOOTS.parseMaterial());
|
||||
territoryCancelAndAllowItemUseMaterial.add(XMaterial.LEATHER_HELMET.parseMaterial());
|
||||
territoryCancelAndAllowItemUseMaterial.add(XMaterial.LEATHER_CHESTPLATE.parseMaterial());
|
||||
territoryCancelAndAllowItemUseMaterial.add(XMaterial.LEATHER_LEGGINGS.parseMaterial());
|
||||
territoryCancelAndAllowItemUseMaterial.add(XMaterial.LEATHER_BOOTS.parseMaterial());
|
||||
territoryCancelAndAllowItemUseMaterial.add(XMaterial.CHAINMAIL_HELMET.parseMaterial());
|
||||
territoryCancelAndAllowItemUseMaterial.add(XMaterial.CHAINMAIL_CHESTPLATE.parseMaterial());
|
||||
territoryCancelAndAllowItemUseMaterial.add(XMaterial.CHAINMAIL_LEGGINGS.parseMaterial());
|
||||
territoryCancelAndAllowItemUseMaterial.add(XMaterial.CHAINMAIL_BOOTS.parseMaterial());
|
||||
|
||||
|
||||
/// TODO: Consider removing this in a future release, as permissions works just fine now
|
||||
territoryProtectedMaterials.add(Material.BEACON);
|
||||
|
||||
// Config is not loading if value is empty ???
|
||||
territoryBypassProtectedMaterials.add(Material.COOKIE);
|
||||
territoryBypassProtectedMaterials.add(Material.CHEST);
|
||||
territoryBypassProtectedMaterials.add(Material.TRAPPED_CHEST);
|
||||
|
||||
|
||||
territoryDenyUsageMaterials.add(XMaterial.FIRE_CHARGE.parseMaterial());
|
||||
territoryDenyUsageMaterials.add(Material.FLINT_AND_STEEL);
|
||||
@@ -436,6 +545,10 @@ public class Conf {
|
||||
defaultFactionPermissions.put("MODERATOR", new DefaultPermissions(true));
|
||||
defaultFactionPermissions.put("NORMAL MEMBER", new DefaultPermissions(false));
|
||||
defaultFactionPermissions.put("RECRUIT", new DefaultPermissions(false));
|
||||
defaultFactionPermissions.put("ALLY", new DefaultPermissions(false));
|
||||
defaultFactionPermissions.put("ENEMY", new DefaultPermissions(false));
|
||||
defaultFactionPermissions.put("TRUCE", new DefaultPermissions(false));
|
||||
defaultFactionPermissions.put("NEUTRAL", new DefaultPermissions(false));
|
||||
}
|
||||
|
||||
public static void load() {
|
||||
@@ -446,6 +559,8 @@ public class Conf {
|
||||
FactionsPlugin.getInstance().persist.save(i);
|
||||
}
|
||||
|
||||
public static void saveSync() { FactionsPlugin.instance.persist.saveSync(i); }
|
||||
|
||||
public enum Backend {
|
||||
JSON,
|
||||
//MYSQL, TODO add MySQL storage
|
||||
|
||||
@@ -244,6 +244,10 @@ public class FLocation implements Serializable {
|
||||
return (this.x << 9) + this.z + (this.worldName != null ? this.worldName.hashCode() : 0);
|
||||
}
|
||||
|
||||
public String formatXAndZ(String splitter) {
|
||||
return chunkToBlock(this.x) + "x" + splitter + " " + chunkToBlock(this.z) + "z";
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean equals(Object obj) {
|
||||
if (obj == this) {
|
||||
|
||||
@@ -30,6 +30,18 @@ public interface FPlayer extends EconomyParticipator {
|
||||
|
||||
boolean hasNotificationsEnabled();
|
||||
|
||||
/**
|
||||
* Used to check if this player should be served titles
|
||||
* @return if this FPlayer has titles enabled as a boolean
|
||||
*/
|
||||
boolean hasTitlesEnabled();
|
||||
|
||||
/**
|
||||
* Used to set if player should be served titles
|
||||
* @param b Boolean to titlesEnabled to
|
||||
*/
|
||||
void setTitlesEnabled(Boolean b);
|
||||
|
||||
/**
|
||||
* Used to determine if a player is in their faction's chest
|
||||
* @return if player is in their faction's as a boolean
|
||||
|
||||
@@ -11,12 +11,14 @@ import com.massivecraft.factions.cmd.FCommand;
|
||||
import com.massivecraft.factions.cmd.check.CheckTask;
|
||||
import com.massivecraft.factions.cmd.check.WeeWooTask;
|
||||
import com.massivecraft.factions.cmd.chest.AntiChestListener;
|
||||
import com.massivecraft.factions.cmd.chest.FChestListener;
|
||||
import com.massivecraft.factions.discord.DiscordListener;
|
||||
import com.massivecraft.factions.discord.FactionChatHandler;
|
||||
import com.massivecraft.factions.integration.Econ;
|
||||
import com.massivecraft.factions.integration.Worldguard;
|
||||
import com.massivecraft.factions.integration.dynmap.EngineDynmap;
|
||||
import com.massivecraft.factions.listeners.*;
|
||||
import com.massivecraft.factions.listeners.menu.MenuListener;
|
||||
import com.massivecraft.factions.missions.MissionHandler;
|
||||
import com.massivecraft.factions.shop.ShopConfig;
|
||||
import com.massivecraft.factions.struct.ChatMode;
|
||||
@@ -26,6 +28,8 @@ import com.massivecraft.factions.util.*;
|
||||
import com.massivecraft.factions.util.Particles.ReflectionUtils;
|
||||
import com.massivecraft.factions.zcore.CommandVisibility;
|
||||
import com.massivecraft.factions.zcore.MPlugin;
|
||||
import com.massivecraft.factions.zcore.faudit.FLogManager;
|
||||
import com.massivecraft.factions.zcore.faudit.FLogType;
|
||||
import com.massivecraft.factions.zcore.fperms.Access;
|
||||
import com.massivecraft.factions.zcore.fperms.Permissable;
|
||||
import com.massivecraft.factions.zcore.fperms.PermissableAction;
|
||||
@@ -89,6 +93,8 @@ public class FactionsPlugin extends MPlugin {
|
||||
private boolean mvdwPlaceholderAPIManager = false;
|
||||
private Listener[] eventsListener;
|
||||
public List<String> itemList = getConfig().getStringList("fchest.Items-Not-Allowed");
|
||||
private Worldguard wg;
|
||||
private FLogManager flogManager;
|
||||
|
||||
|
||||
public FactionsPlugin() {
|
||||
@@ -183,6 +189,8 @@ public class FactionsPlugin extends MPlugin {
|
||||
PermissionList.generateFile();
|
||||
// Load Conf from disk
|
||||
Conf.load();
|
||||
flogManager = new FLogManager();
|
||||
|
||||
//Dependency checks
|
||||
if (Conf.dependencyCheck && (!Bukkit.getPluginManager().isPluginEnabled("Vault") && !Bukkit.getPluginManager().isPluginEnabled("Essentials"))) {
|
||||
divider();
|
||||
@@ -194,7 +202,7 @@ public class FactionsPlugin extends MPlugin {
|
||||
return;
|
||||
}
|
||||
//Update their config if needed
|
||||
Updater.updateIfNeeded(getConfig());
|
||||
// Updater.updateIfNeeded(getConfig());
|
||||
RegisteredServiceProvider<Economy> rsp = FactionsPlugin.this.getServer().getServicesManager().getRegistration(Economy.class);
|
||||
FactionsPlugin.econ = rsp.getProvider();
|
||||
com.massivecraft.factions.integration.Essentials.setup();
|
||||
@@ -230,9 +238,7 @@ public class FactionsPlugin extends MPlugin {
|
||||
Econ.setup();
|
||||
setupPermissions();
|
||||
|
||||
if (Conf.worldGuardChecking || Conf.worldGuardBuildPriority) {
|
||||
Worldguard.init(this);
|
||||
}
|
||||
if (Conf.worldGuardChecking || Conf.worldGuardBuildPriority) wg = new Worldguard();
|
||||
|
||||
EngineDynmap.getInstance().init();
|
||||
|
||||
@@ -275,7 +281,7 @@ public class FactionsPlugin extends MPlugin {
|
||||
}
|
||||
|
||||
ShopConfig.setup();
|
||||
|
||||
flogManager.loadLogs(this);
|
||||
getServer().getPluginManager().registerEvents(factionsPlayerListener = new FactionsPlayerListener(), this);
|
||||
|
||||
// Register Event Handlers
|
||||
@@ -287,6 +293,8 @@ public class FactionsPlugin extends MPlugin {
|
||||
new FUpgradesGUI(),
|
||||
new UpgradesListener(),
|
||||
new MissionHandler(this),
|
||||
new FChestListener(),
|
||||
new MenuListener(),
|
||||
new AntiChestListener()
|
||||
};
|
||||
|
||||
@@ -426,9 +434,7 @@ public class FactionsPlugin extends MPlugin {
|
||||
public void onDisable() {
|
||||
// only save data if plugin actually completely loaded successfully
|
||||
if (this.loadSuccessful) {
|
||||
// Dont save, as this is kind of pointless, as the /f config command manually saves.
|
||||
// So any edits done are saved, this way manual edits to json can go through.
|
||||
// Conf.save();
|
||||
Conf.saveSync();
|
||||
}
|
||||
|
||||
if (AutoLeaveTask != null) {
|
||||
@@ -437,6 +443,12 @@ public class FactionsPlugin extends MPlugin {
|
||||
}
|
||||
DiscordListener.saveGuilds();
|
||||
super.onDisable();
|
||||
|
||||
try {
|
||||
flogManager.saveLogs();
|
||||
} catch (Exception e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
}
|
||||
|
||||
public void startAutoLeaveTask(boolean restartIfRunning) {
|
||||
@@ -562,21 +574,6 @@ public class FactionsPlugin extends MPlugin {
|
||||
}
|
||||
}
|
||||
|
||||
public void createTimedHologram(final Location location, String text, Long timeout) {
|
||||
ArmorStand as = (ArmorStand) location.add(0.5, 1, 0.5).getWorld().spawnEntity(location, EntityType.ARMOR_STAND); //Spawn the ArmorStand
|
||||
as.setVisible(false); //Makes the ArmorStand invisible
|
||||
as.setGravity(false); //Make sure it doesn't fall
|
||||
as.setCanPickupItems(false); //I'm not sure what happens if you leave this as it is, but you might as well disable it
|
||||
as.setCustomName(FactionsPlugin.instance.color(text)); //Set this to the text you want
|
||||
as.setCustomNameVisible(true); //This makes the text appear no matter if your looking at the entity or not
|
||||
final ArmorStand armorStand = as;
|
||||
|
||||
Bukkit.getScheduler().scheduleSyncDelayedTask(FactionsPlugin.instance, () -> {
|
||||
armorStand.remove();
|
||||
getLogger().info("Removing Hologram.");
|
||||
}
|
||||
, timeout * 20);
|
||||
}
|
||||
|
||||
|
||||
// -------------------------------------------- //
|
||||
@@ -717,6 +714,14 @@ public class FactionsPlugin extends MPlugin {
|
||||
return hookedPlayervaults;
|
||||
}
|
||||
|
||||
public FLogManager getFlogManager() {
|
||||
return flogManager;
|
||||
}
|
||||
|
||||
public void logFactionEvent(Faction faction, FLogType type, String... arguments) {
|
||||
this.flogManager.log(faction, type, arguments);
|
||||
}
|
||||
|
||||
public String getPrimaryGroup(OfflinePlayer player) {
|
||||
AtomicReference<String> primaryGroup = new AtomicReference<>();
|
||||
|
||||
@@ -740,4 +745,8 @@ public class FactionsPlugin extends MPlugin {
|
||||
public void debug(String s) {
|
||||
debug(Level.INFO, s);
|
||||
}
|
||||
|
||||
public Worldguard getWg() {
|
||||
return wg;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -3,11 +3,14 @@ package com.massivecraft.factions.cmd;
|
||||
import com.massivecraft.factions.FPlayer;
|
||||
import com.massivecraft.factions.FPlayers;
|
||||
import com.massivecraft.factions.Faction;
|
||||
import com.massivecraft.factions.FactionsPlugin;
|
||||
import com.massivecraft.factions.event.FPlayerJoinEvent;
|
||||
import com.massivecraft.factions.struct.Permission;
|
||||
import com.massivecraft.factions.struct.Role;
|
||||
import com.massivecraft.factions.zcore.faudit.FLogType;
|
||||
import com.massivecraft.factions.zcore.util.TL;
|
||||
import org.bukkit.Bukkit;
|
||||
import org.bukkit.ChatColor;
|
||||
|
||||
public class CmdAdmin extends FCommand {
|
||||
|
||||
@@ -25,6 +28,10 @@ public class CmdAdmin extends FCommand {
|
||||
|
||||
@Override
|
||||
public void perform(CommandContext context) {
|
||||
if (context.player == null) {
|
||||
context.msg(TL.GENERIC_PLAYERONLY);
|
||||
return;
|
||||
}
|
||||
// Allows admins bypass this.
|
||||
if (!context.fPlayer.isAdminBypassing() && !context.fPlayer.getRole().equals(Role.LEADER)) {
|
||||
context.msg(TL.COMMAND_ADMIN_NOTADMIN);
|
||||
@@ -73,7 +80,7 @@ public class CmdAdmin extends FCommand {
|
||||
}
|
||||
fyou.setRole(Role.LEADER);
|
||||
context.msg(TL.COMMAND_ADMIN_PROMOTES, fyou.describeTo(context.fPlayer, true));
|
||||
|
||||
FactionsPlugin.instance.getFlogManager().log(targetFaction, FLogType.RANK_EDIT, context.fPlayer.getName(), fyou.getName(), ChatColor.RED + "Admin");
|
||||
// Inform all players
|
||||
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));
|
||||
|
||||
34
src/main/java/com/massivecraft/factions/cmd/CmdAudit.java
Normal file
34
src/main/java/com/massivecraft/factions/cmd/CmdAudit.java
Normal file
@@ -0,0 +1,34 @@
|
||||
package com.massivecraft.factions.cmd;
|
||||
|
||||
import com.massivecraft.factions.Faction;
|
||||
import com.massivecraft.factions.struct.Permission;
|
||||
import com.massivecraft.factions.zcore.faudit.FAuditMenu;
|
||||
import com.massivecraft.factions.zcore.util.TL;
|
||||
import org.bukkit.entity.Player;
|
||||
|
||||
public class CmdAudit extends FCommand {
|
||||
|
||||
public CmdAudit() {
|
||||
super();
|
||||
this.aliases.add("audit");
|
||||
this.aliases.add("logs");
|
||||
this.aliases.add("log");
|
||||
|
||||
|
||||
this.requirements = new CommandRequirements.Builder(Permission.AUDIT)
|
||||
.playerOnly()
|
||||
.memberOnly()
|
||||
.noErrorOnManyArgs()
|
||||
.build();
|
||||
}
|
||||
@Override
|
||||
public void perform(CommandContext context) {
|
||||
Faction faction = context.args.size() == 1 && context.sender.isOp() ? context.argAsFaction(0) : context.faction;
|
||||
new FAuditMenu((Player)context.sender, faction).open((Player)context.sender);
|
||||
}
|
||||
|
||||
@Override
|
||||
public TL getUsageTranslation() {
|
||||
return null;
|
||||
}
|
||||
}
|
||||
@@ -5,7 +5,9 @@ import com.massivecraft.factions.FactionsPlugin;
|
||||
import com.massivecraft.factions.event.FPlayerLeaveEvent;
|
||||
import com.massivecraft.factions.struct.BanInfo;
|
||||
import com.massivecraft.factions.struct.Permission;
|
||||
import com.massivecraft.factions.zcore.faudit.FLogType;
|
||||
import com.massivecraft.factions.zcore.fperms.PermissableAction;
|
||||
import com.massivecraft.factions.zcore.util.CC;
|
||||
import com.massivecraft.factions.zcore.util.TL;
|
||||
import org.bukkit.Bukkit;
|
||||
|
||||
@@ -75,6 +77,7 @@ public class CmdBan extends FCommand {
|
||||
|
||||
// Lets inform the people!
|
||||
target.msg(TL.COMMAND_BAN_TARGET, context.faction.getTag(target.getFaction()));
|
||||
FactionsPlugin.instance.logFactionEvent(context.faction, FLogType.BANS, context.fPlayer.getName(), CC.Green + "banned", target.getName());
|
||||
context.faction.msg(TL.COMMAND_BAN_BANNED, context.fPlayer.getName(), target.getName());
|
||||
}
|
||||
|
||||
|
||||
@@ -3,8 +3,10 @@ package com.massivecraft.factions.cmd;
|
||||
import com.massivecraft.factions.Conf;
|
||||
import com.massivecraft.factions.FPlayer;
|
||||
import com.massivecraft.factions.Faction;
|
||||
import com.massivecraft.factions.FactionsPlugin;
|
||||
import com.massivecraft.factions.struct.Permission;
|
||||
import com.massivecraft.factions.struct.Role;
|
||||
import com.massivecraft.factions.zcore.faudit.FLogType;
|
||||
import com.massivecraft.factions.zcore.util.TL;
|
||||
import mkremins.fanciful.FancyMessage;
|
||||
import org.bukkit.ChatColor;
|
||||
@@ -76,6 +78,7 @@ public class CmdColeader extends FCommand {
|
||||
you.setRole(Role.COLEADER);
|
||||
targetFaction.msg(TL.COMMAND_COLEADER_PROMOTED, you.describeTo(targetFaction, true));
|
||||
context.msg(TL.COMMAND_COLEADER_PROMOTES, you.describeTo(context.fPlayer, true));
|
||||
FactionsPlugin.instance.getFlogManager().log(targetFaction, FLogType.RANK_EDIT, context.fPlayer.getName(), you.getName(), ChatColor.RED + "Co-Leader");
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -31,9 +31,11 @@ public class CmdDeinvite extends FCommand {
|
||||
|
||||
// Check if arg 0 == null do you don't have
|
||||
// `No player "null" could be found.` message.
|
||||
|
||||
if (context.args.get(0) == null) {
|
||||
FancyMessage msg = new FancyMessage(TL.COMMAND_DEINVITE_CANDEINVITE.toString()).color(ChatColor.GOLD);
|
||||
for (String id : context.faction.getInvites()) {
|
||||
if(context.faction.getInvites().isEmpty()) return;
|
||||
FPlayer fp = FPlayers.getInstance().getById(id);
|
||||
String name = fp != null ? fp.getName() : id;
|
||||
msg.then(name + " ").color(ChatColor.WHITE).tooltip(TL.COMMAND_DEINVITE_CLICKTODEINVITE.format(name)).command("/" + Conf.baseCommandAliases.get(0) + " deinvite " + name);
|
||||
@@ -54,6 +56,7 @@ public class CmdDeinvite extends FCommand {
|
||||
if (you == null) {
|
||||
FancyMessage msg = new FancyMessage(TL.COMMAND_DEINVITE_CANDEINVITE.toString()).color(ChatColor.GOLD);
|
||||
for (String id : context.faction.getInvites()) {
|
||||
if(context.faction.getInvites().isEmpty()) return;
|
||||
FPlayer fp = FPlayers.getInstance().getById(id);
|
||||
String name = fp != null ? fp.getName() : id;
|
||||
msg.then(name + " ").color(ChatColor.WHITE).tooltip(TL.COMMAND_DEINVITE_CLICKTODEINVITE.format(name)).command("/" + Conf.baseCommandAliases.get(0) + " deinvite " + name);
|
||||
|
||||
@@ -3,9 +3,12 @@ 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.zcore.faudit.FLogType;
|
||||
import com.massivecraft.factions.zcore.util.TL;
|
||||
import com.massivecraft.factions.zcore.util.TextUtil;
|
||||
import org.bukkit.Bukkit;
|
||||
|
||||
public class CmdDescription extends FCommand {
|
||||
|
||||
@@ -32,7 +35,9 @@ public class CmdDescription extends FCommand {
|
||||
|
||||
// since "&" color tags seem to work even through plain old FPlayer.sendMessage() for some reason, we need to break those up
|
||||
// And replace all the % because it messes with string formatting and this is easy way around that.
|
||||
context.faction.setDescription(TextUtil.implode(context.args, " ").replaceAll("%", "").replaceAll("(&([a-f0-9klmnor]))", "& $2"));
|
||||
String desc = TextUtil.implode(context.args, " ").replaceAll("%", "").replaceAll("(&([a-f0-9klmnor]))", "& $2");
|
||||
context.faction.setDescription(desc);
|
||||
Bukkit.getScheduler().scheduleSyncDelayedTask(FactionsPlugin.instance, () -> FactionsPlugin.instance.logFactionEvent(context.faction, FLogType.FDESC_EDIT, context.fPlayer.getName(), desc));
|
||||
|
||||
if (!Conf.broadcastDescriptionChanges) {
|
||||
context.msg(TL.COMMAND_DESCRIPTION_CHANGED, context.faction.describeTo(context.fPlayer));
|
||||
|
||||
@@ -78,18 +78,23 @@ public class CmdDisband extends FCommand {
|
||||
if (FactionsPlugin.getInstance().getConfig().getBoolean("faction-disband-broadcast", true)) {
|
||||
for (FPlayer follower : FPlayers.getInstance().getOnlinePlayers()) {
|
||||
String amountString = context.sender instanceof ConsoleCommandSender ? TL.GENERIC_SERVERADMIN.toString() : context.fPlayer.describeTo(follower);
|
||||
UtilFly.checkFly(context.fPlayer, Board.getInstance().getFactionAt(new FLocation(follower)));
|
||||
if (follower.getFaction() == faction) {
|
||||
follower.msg(TL.COMMAND_DISBAND_BROADCAST_YOURS, amountString);
|
||||
if (!follower.canFlyAtLocation()) {
|
||||
follower.setFFlying(false, false);
|
||||
}
|
||||
} else {
|
||||
follower.msg(TL.COMMAND_DISBAND_BROADCAST_NOTYOURS, amountString, faction.getTag(follower));
|
||||
}
|
||||
}
|
||||
faction.disband(context.player, PlayerDisbandReason.COMMAND);
|
||||
context.fPlayer.setFFlying(false, false);
|
||||
} else {
|
||||
faction.disband(context.player, PlayerDisbandReason.COMMAND);
|
||||
context.player.sendMessage(String.valueOf(TL.COMMAND_DISBAND_PLAYER));
|
||||
}
|
||||
faction.disband(context.player, PlayerDisbandReason.COMMAND);
|
||||
if (!context.fPlayer.canFlyAtLocation()) {
|
||||
context.fPlayer.setFFlying(false, false);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -97,6 +97,9 @@ public class CmdFly extends FCommand {
|
||||
}
|
||||
|
||||
public static boolean checkBypassPerms(FPlayer fme, Player me, Faction toFac) {
|
||||
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_WILD.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));
|
||||
@@ -116,7 +119,7 @@ public class CmdFly extends FCommand {
|
||||
return false;
|
||||
}
|
||||
|
||||
if (!(me.hasPermission(Permission.FLY_NEUTRAL.node) || access == Access.ALLOW) && toFac.getRelationTo(fme.getFaction()) == Relation.NEUTRAL && !isSystemFaction(toFac)) {
|
||||
if (!(me.hasPermission(Permission.FLY_NEUTRAL.node) || access == Access.ALLOW) && toFac.getRelationTo(fme.getFaction()) == Relation.NEUTRAL && !toFac.isSystemFaction()) {
|
||||
fme.msg(TL.COMMAND_FLY_NO_ACCESS, toFac.getTag(fme));
|
||||
return false;
|
||||
}
|
||||
@@ -125,11 +128,6 @@ public class CmdFly extends FCommand {
|
||||
return true;
|
||||
}
|
||||
|
||||
public static Boolean isSystemFaction(Faction faction) {
|
||||
return faction.isSafeZone() ||
|
||||
faction.isWarZone() ||
|
||||
faction.isWilderness();
|
||||
}
|
||||
|
||||
public static void checkTaskState() {
|
||||
if (flyMap.isEmpty()) {
|
||||
@@ -187,7 +185,7 @@ public class CmdFly extends FCommand {
|
||||
}
|
||||
|
||||
|
||||
if (fme.canFlyAtLocation())
|
||||
if (fme.canFlyAtLocation()) {
|
||||
context.doWarmUp(WarmUpUtil.Warmup.FLIGHT, TL.WARMUPS_NOTIFY_FLIGHT, "Fly", () -> {
|
||||
fme.setFlying(true);
|
||||
flyMap.put(fme.getPlayer().getName(), true);
|
||||
@@ -199,6 +197,9 @@ public class CmdFly extends FCommand {
|
||||
startFlyCheck();
|
||||
}
|
||||
}, FactionsPlugin.getInstance().getConfig().getLong("warmups.f-fly", 0));
|
||||
} else {
|
||||
fme.msg(TL.COMMAND_FLY_NO_ACCESS, Board.getInstance().getFactionAt(fme.getLastStoodAt()).getTag());
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
|
||||
@@ -4,7 +4,9 @@ import com.massivecraft.factions.Conf;
|
||||
import com.massivecraft.factions.FPlayer;
|
||||
import com.massivecraft.factions.FactionsPlugin;
|
||||
import com.massivecraft.factions.struct.Permission;
|
||||
import com.massivecraft.factions.zcore.faudit.FLogType;
|
||||
import com.massivecraft.factions.zcore.fperms.PermissableAction;
|
||||
import com.massivecraft.factions.zcore.util.CC;
|
||||
import com.massivecraft.factions.zcore.util.TL;
|
||||
import mkremins.fanciful.FancyMessage;
|
||||
import org.bukkit.ChatColor;
|
||||
@@ -69,6 +71,7 @@ public class CmdInvite extends FCommand {
|
||||
}
|
||||
|
||||
context.faction.msg(TL.COMMAND_INVITE_INVITED, context.fPlayer.describeTo(context.faction, true), target.describeTo(context.faction));
|
||||
FactionsPlugin.instance.logFactionEvent(context.faction, FLogType.INVITES, context.fPlayer.getName(), CC.Green + "invited", target.getName());
|
||||
}
|
||||
|
||||
@Override
|
||||
|
||||
@@ -3,7 +3,9 @@ package com.massivecraft.factions.cmd;
|
||||
import com.massivecraft.factions.*;
|
||||
import com.massivecraft.factions.event.FPlayerJoinEvent;
|
||||
import com.massivecraft.factions.struct.Permission;
|
||||
import com.massivecraft.factions.zcore.faudit.FLogType;
|
||||
import com.massivecraft.factions.zcore.fupgrades.UpgradeType;
|
||||
import com.massivecraft.factions.zcore.util.CC;
|
||||
import com.massivecraft.factions.zcore.util.TL;
|
||||
import org.bukkit.Bukkit;
|
||||
|
||||
@@ -117,6 +119,7 @@ public class CmdJoin extends FCommand {
|
||||
|
||||
faction.deinvite(fplayer);
|
||||
context.fPlayer.setRole(faction.getDefaultRole());
|
||||
FactionsPlugin.instance.logFactionEvent(faction, FLogType.INVITES, context.fPlayer.getName(), CC.Green + "joined", "the faction");
|
||||
|
||||
if (Conf.logFactionJoin) {
|
||||
if (samePlayer) {
|
||||
|
||||
@@ -7,7 +7,9 @@ import com.massivecraft.factions.FactionsPlugin;
|
||||
import com.massivecraft.factions.event.FPlayerLeaveEvent;
|
||||
import com.massivecraft.factions.struct.Permission;
|
||||
import com.massivecraft.factions.struct.Role;
|
||||
import com.massivecraft.factions.zcore.faudit.FLogType;
|
||||
import com.massivecraft.factions.zcore.fperms.PermissableAction;
|
||||
import com.massivecraft.factions.zcore.util.CC;
|
||||
import com.massivecraft.factions.zcore.util.TL;
|
||||
import mkremins.fanciful.FancyMessage;
|
||||
import org.bukkit.Bukkit;
|
||||
@@ -118,6 +120,8 @@ public class CmdKick extends FCommand {
|
||||
if (toKick.getRole() == Role.LEADER) {
|
||||
toKickFaction.promoteNewLeader();
|
||||
}
|
||||
|
||||
FactionsPlugin.instance.logFactionEvent(toKickFaction, FLogType.INVITES, context.fPlayer.getName(), CC.Red + "kicked", toKick.getName());
|
||||
toKickFaction.deinvite(toKick);
|
||||
toKick.resetFactionData();
|
||||
}
|
||||
|
||||
@@ -3,8 +3,10 @@ package com.massivecraft.factions.cmd;
|
||||
import com.massivecraft.factions.Conf;
|
||||
import com.massivecraft.factions.FPlayer;
|
||||
import com.massivecraft.factions.Faction;
|
||||
import com.massivecraft.factions.FactionsPlugin;
|
||||
import com.massivecraft.factions.struct.Permission;
|
||||
import com.massivecraft.factions.struct.Role;
|
||||
import com.massivecraft.factions.zcore.faudit.FLogType;
|
||||
import com.massivecraft.factions.zcore.util.TL;
|
||||
import mkremins.fanciful.FancyMessage;
|
||||
import org.bukkit.ChatColor;
|
||||
@@ -72,6 +74,7 @@ public class CmdMod extends FCommand {
|
||||
you.setRole(Role.MODERATOR);
|
||||
targetFaction.msg(TL.COMMAND_MOD_PROMOTED, you.describeTo(targetFaction, true));
|
||||
context.msg(TL.COMMAND_MOD_PROMOTES, you.describeTo(context.fPlayer, true));
|
||||
FactionsPlugin.instance.getFlogManager().log(targetFaction, FLogType.RANK_EDIT, context.fPlayer.getName(), you.getName(), ChatColor.LIGHT_PURPLE + "Mod");
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -0,0 +1,21 @@
|
||||
package com.massivecraft.factions.cmd;
|
||||
|
||||
import com.massivecraft.factions.FactionsPlugin;
|
||||
import com.massivecraft.factions.struct.Permission;
|
||||
import com.massivecraft.factions.zcore.util.TL;
|
||||
|
||||
public class CmdPlayerTitleToggle extends FCommand {
|
||||
public CmdPlayerTitleToggle() {
|
||||
super();
|
||||
this.aliases.add("titles");
|
||||
this.requirements = new CommandRequirements.Builder(Permission.TOGGLE_TITLES)
|
||||
.build();
|
||||
}
|
||||
@Override
|
||||
public void perform(CommandContext context) {
|
||||
context.fPlayer.setTitlesEnabled(!context.fPlayer.hasTitlesEnabled());
|
||||
context.msg(TL.COMMAND_TITLETOGGLE_TOGGLED, context.fPlayer.hasTitlesEnabled() ? FactionsPlugin.getInstance().color("&dEnabled") : FactionsPlugin.getInstance().color("&dDisabled"));
|
||||
}
|
||||
@Override
|
||||
public TL getUsageTranslation() {return TL.COMMAND_TITLETOGGLE_DESCRIPTION;}
|
||||
}
|
||||
@@ -1,9 +1,6 @@
|
||||
package com.massivecraft.factions.cmd;
|
||||
|
||||
import com.massivecraft.factions.Board;
|
||||
import com.massivecraft.factions.Conf;
|
||||
import com.massivecraft.factions.FPlayers;
|
||||
import com.massivecraft.factions.Factions;
|
||||
import com.massivecraft.factions.*;
|
||||
import com.massivecraft.factions.shop.ShopConfig;
|
||||
import com.massivecraft.factions.struct.Permission;
|
||||
import com.massivecraft.factions.zcore.util.TL;
|
||||
@@ -25,6 +22,11 @@ public class CmdSaveAll extends FCommand {
|
||||
Factions.getInstance().forceSave(false);
|
||||
Board.getInstance().forceSave(false);
|
||||
Conf.save();
|
||||
try {
|
||||
FactionsPlugin.instance.getFlogManager().saveLogs();
|
||||
} catch (Exception e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
ShopConfig.saveShop();
|
||||
context.msg(TL.COMMAND_SAVEALL_SUCCESS);
|
||||
}
|
||||
|
||||
@@ -6,6 +6,7 @@ import com.massivecraft.factions.scoreboards.FTeamWrapper;
|
||||
import com.massivecraft.factions.struct.Permission;
|
||||
import com.massivecraft.factions.struct.Role;
|
||||
import com.massivecraft.factions.util.MiscUtil;
|
||||
import com.massivecraft.factions.zcore.faudit.FLogType;
|
||||
import com.massivecraft.factions.zcore.util.TL;
|
||||
import org.bukkit.Bukkit;
|
||||
|
||||
@@ -61,6 +62,7 @@ public class CmdTag extends FCommand {
|
||||
|
||||
String oldtag = context.faction.getTag();
|
||||
context.faction.setTag(tag);
|
||||
FactionsPlugin.instance.logFactionEvent(context.faction, FLogType.FTAG_EDIT, context.fPlayer.getName(), tag);
|
||||
|
||||
// Inform
|
||||
for (FPlayer fplayer : FPlayers.getInstance().getOnlinePlayers()) {
|
||||
|
||||
@@ -21,7 +21,7 @@ public class CmdUpgrades extends FCommand {
|
||||
@Override
|
||||
public void perform(CommandContext context) {
|
||||
if (!FactionsPlugin.getInstance().getConfig().getBoolean("fupgrades.Enabled")) {
|
||||
context.fPlayer.sendMessage("This command is disabled!");
|
||||
context.fPlayer.msg(TL.COMMAND_UPGRADES_DISABLED);
|
||||
return;
|
||||
}
|
||||
new FUpgradesGUI().openMainMenu(context.fPlayer);
|
||||
|
||||
@@ -52,6 +52,9 @@ public class CommandRequirements {
|
||||
return false;
|
||||
}
|
||||
|
||||
if (context.fPlayer.isAdminBypassing()) return true;
|
||||
|
||||
|
||||
if (!FactionsPlugin.getInstance().perm.has(context.sender, permission.node, informIfNot)) return false;
|
||||
|
||||
// Permissable Action provided compute that before role
|
||||
|
||||
@@ -87,6 +87,7 @@ public class FCmdRoot extends FCommand implements CommandExecutor {
|
||||
public CmdStuck cmdStuck = new CmdStuck();
|
||||
public CmdTag cmdTag = new CmdTag();
|
||||
public CmdTitle cmdTitle = new CmdTitle();
|
||||
public CmdPlayerTitleToggle cmdPlayerTitleToggle = new CmdPlayerTitleToggle();
|
||||
public CmdToggleAllianceChat cmdToggleAllianceChat = new CmdToggleAllianceChat();
|
||||
public CmdUnclaim cmdUnclaim = new CmdUnclaim();
|
||||
public CmdUnclaimall cmdUnclaimall = new CmdUnclaimall();
|
||||
@@ -153,6 +154,7 @@ public class FCmdRoot extends FCommand implements CommandExecutor {
|
||||
public CmdSeeDiscord cmdSeeDiscord = new CmdSeeDiscord();
|
||||
public CmdInviteBot cmdInviteBot = new CmdInviteBot();
|
||||
public CmdSetGuild cmdSetGuild = new CmdSetGuild();
|
||||
public CmdAudit cmdAudit = new CmdAudit();
|
||||
|
||||
public FCmdRoot() {
|
||||
super();
|
||||
@@ -215,6 +217,7 @@ public class FCmdRoot extends FCommand implements CommandExecutor {
|
||||
this.addSubCommand(this.cmdLogout);
|
||||
this.addSubCommand(this.cmdTag);
|
||||
this.addSubCommand(this.cmdTitle);
|
||||
this.addSubCommand(this.cmdPlayerTitleToggle);
|
||||
this.addSubCommand(this.cmdUnclaim);
|
||||
this.addSubCommand(this.cmdUnclaimall);
|
||||
this.addSubCommand(this.cmdVersion);
|
||||
@@ -263,6 +266,7 @@ public class FCmdRoot extends FCommand implements CommandExecutor {
|
||||
this.addSubCommand(this.cmdViewChest);
|
||||
this.addSubCommand(this.cmdConvertConfig);
|
||||
this.addSubCommand(this.cmdSpawnerLock);
|
||||
this.addSubCommand(this.cmdAudit);
|
||||
|
||||
if(Conf.useDiscordSystem){
|
||||
this.addSubCommand(this.cmdInviteBot);
|
||||
|
||||
@@ -12,6 +12,7 @@ public class CmdAlts extends FCommand {
|
||||
|
||||
public CmdInviteAlt cmdInviteAlt = new CmdInviteAlt();
|
||||
public CmdAltsList cmdAltsList = new CmdAltsList();
|
||||
public CmdKickAlt cmdKickAlt = new CmdKickAlt();
|
||||
|
||||
|
||||
public CmdAlts() {
|
||||
@@ -22,6 +23,7 @@ public class CmdAlts extends FCommand {
|
||||
|
||||
this.addSubCommand(this.cmdInviteAlt);
|
||||
this.addSubCommand(this.cmdAltsList);
|
||||
this.addSubCommand(this.cmdKickAlt);
|
||||
|
||||
this.requirements = new CommandRequirements.Builder(Permission.ALTS)
|
||||
.playerOnly()
|
||||
|
||||
@@ -1,6 +1,7 @@
|
||||
package com.massivecraft.factions.cmd.alts;
|
||||
|
||||
import com.massivecraft.factions.Conf;
|
||||
import com.massivecraft.factions.FLocation;
|
||||
import com.massivecraft.factions.FPlayer;
|
||||
import com.massivecraft.factions.FactionsPlugin;
|
||||
import com.massivecraft.factions.cmd.CommandContext;
|
||||
@@ -8,8 +9,10 @@ import com.massivecraft.factions.cmd.CommandRequirements;
|
||||
import com.massivecraft.factions.cmd.FCommand;
|
||||
import com.massivecraft.factions.struct.Permission;
|
||||
import com.massivecraft.factions.struct.Role;
|
||||
import com.massivecraft.factions.zcore.faudit.FLogType;
|
||||
import com.massivecraft.factions.zcore.fperms.Access;
|
||||
import com.massivecraft.factions.zcore.fperms.PermissableAction;
|
||||
import com.massivecraft.factions.zcore.util.CC;
|
||||
import com.massivecraft.factions.zcore.util.TL;
|
||||
import mkremins.fanciful.FancyMessage;
|
||||
import org.bukkit.ChatColor;
|
||||
@@ -82,6 +85,8 @@ public class CmdInviteAlt extends FCommand {
|
||||
message.send(target.getPlayer());
|
||||
|
||||
context.faction.msg(TL.COMMAND_ALTINVITE_INVITED_ALT, context.fPlayer.describeTo(context.faction, true), target.describeTo(context.faction));
|
||||
FactionsPlugin.instance.logFactionEvent(context.faction, FLogType.INVITES, context.fPlayer.getName(), CC.Green + "invited", target.getName());
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
|
||||
138
src/main/java/com/massivecraft/factions/cmd/alts/CmdKickAlt.java
Normal file
138
src/main/java/com/massivecraft/factions/cmd/alts/CmdKickAlt.java
Normal file
@@ -0,0 +1,138 @@
|
||||
package com.massivecraft.factions.cmd.alts;
|
||||
|
||||
import com.massivecraft.factions.Conf;
|
||||
import com.massivecraft.factions.FPlayer;
|
||||
import com.massivecraft.factions.Faction;
|
||||
import com.massivecraft.factions.FactionsPlugin;
|
||||
import com.massivecraft.factions.cmd.CommandContext;
|
||||
import com.massivecraft.factions.cmd.CommandRequirements;
|
||||
import com.massivecraft.factions.cmd.FCommand;
|
||||
import com.massivecraft.factions.event.FPlayerLeaveEvent;
|
||||
import com.massivecraft.factions.struct.Permission;
|
||||
import com.massivecraft.factions.struct.Role;
|
||||
import com.massivecraft.factions.zcore.faudit.FLogType;
|
||||
import com.massivecraft.factions.zcore.fperms.Access;
|
||||
import com.massivecraft.factions.zcore.fperms.PermissableAction;
|
||||
import com.massivecraft.factions.zcore.util.CC;
|
||||
import com.massivecraft.factions.zcore.util.TL;
|
||||
import org.bukkit.Bukkit;
|
||||
import org.bukkit.command.ConsoleCommandSender;
|
||||
|
||||
public class CmdKickAlt extends FCommand {
|
||||
|
||||
public CmdKickAlt(){
|
||||
super();
|
||||
this.aliases.add("kick");
|
||||
this.requiredArgs.add("player name");
|
||||
|
||||
this.requirements = new CommandRequirements.Builder(Permission.KICK)
|
||||
.playerOnly()
|
||||
.memberOnly()
|
||||
.withAction(PermissableAction.KICK)
|
||||
.build();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void perform(CommandContext context) {
|
||||
if (!FactionsPlugin.getInstance().getConfig().getBoolean("f-alts.Enabled", false)) {
|
||||
context.fPlayer.msg(TL.GENERIC_DISABLED);
|
||||
return;
|
||||
}
|
||||
|
||||
FPlayer toKick = context.argIsSet(0) ? context.argAsBestFPlayerMatch(0) : null;
|
||||
if (toKick == null) {
|
||||
context.msg(TL.COMMAND_ALTKICK_NOTMEMBER);
|
||||
return;
|
||||
}
|
||||
|
||||
if (context.fPlayer == toKick) {
|
||||
context.msg(TL.COMMAND_KICK_SELF);
|
||||
context.msg(TL.GENERIC_YOUMAYWANT.toString() + FactionsPlugin.instance.cmdBase.cmdLeave.getUsageTemplate(context));
|
||||
return;
|
||||
}
|
||||
|
||||
Faction toKickFaction = toKick.getFaction();
|
||||
|
||||
if (toKickFaction.isWilderness()) {
|
||||
context.sender.sendMessage(TL.COMMAND_KICK_NONE.toString());
|
||||
return;
|
||||
}
|
||||
|
||||
// players with admin-level "disband" permission can bypass these
|
||||
// requirements
|
||||
if (!Permission.KICK_ANY.has(context.sender)) {
|
||||
if (toKickFaction != context.faction) {
|
||||
context.msg(TL.COMMAND_KICK_NOTMEMBER, toKick.describeTo(context.fPlayer, true), context.faction.describeTo(context.fPlayer));
|
||||
return;
|
||||
}
|
||||
|
||||
if (!toKick.isAlt()) {
|
||||
context.msg(TL.COMMAND_ALTKICK_NOTALT);
|
||||
return;
|
||||
}
|
||||
|
||||
if (!Conf.canLeaveWithNegativePower && toKick.getPower() < 0) {
|
||||
context.msg(TL.COMMAND_KICK_NEGATIVEPOWER);
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
Access access = context.faction.getAccess(context.fPlayer, PermissableAction.KICK);
|
||||
// This statement allows us to check if they've specifically denied it,
|
||||
// or default to
|
||||
// the old setting of allowing moderators to kick
|
||||
if (access != Access.ALLOW && !context.assertMinRole(Role.MODERATOR)) {
|
||||
context.msg(TL.GENERIC_NOPERMISSION, "kick");
|
||||
return;
|
||||
}
|
||||
|
||||
|
||||
// if economy is enabled, they're not on the bypass list, and this
|
||||
// command has a cost set, make sure they can pay
|
||||
if (!context.canAffordCommand(Conf.econCostKick, TL.COMMAND_KICK_TOKICK.toString())) {
|
||||
return;
|
||||
}
|
||||
|
||||
// trigger the leave event (cancellable) [reason:kicked]
|
||||
FPlayerLeaveEvent event = new FPlayerLeaveEvent(toKick, toKick.getFaction(), FPlayerLeaveEvent.PlayerLeaveReason.KICKED);
|
||||
Bukkit.getServer().getPluginManager().callEvent(event);
|
||||
if (event.isCancelled()) {
|
||||
return;
|
||||
}
|
||||
|
||||
|
||||
// then make 'em pay (if applicable)
|
||||
if (!context.payForCommand(Conf.econCostKick, TL.COMMAND_KICK_TOKICK.toString(), TL.COMMAND_KICK_FORKICK.toString())) {
|
||||
return;
|
||||
}
|
||||
|
||||
|
||||
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.msg(TL.COMMAND_KICK_KICKS, toKick.describeTo(context.fPlayer), toKickFaction.describeTo(context.fPlayer));
|
||||
}
|
||||
|
||||
if (Conf.logFactionKick) {
|
||||
FactionsPlugin.instance.log((context.sender instanceof ConsoleCommandSender ? "A console command" : context.fPlayer.getName()) + " kicked " + toKick.getName() + " from the faction: "
|
||||
+ toKickFaction.getTag());
|
||||
}
|
||||
// SHOULD NOT BE POSSIBLE BUT KEPT INCASE
|
||||
if (toKick.getRole() == Role.LEADER) {
|
||||
toKickFaction.promoteNewLeader();
|
||||
}
|
||||
|
||||
FactionsPlugin.instance.logFactionEvent(toKickFaction, FLogType.INVITES, context.fPlayer.getName(), CC.Red + "kicked alt", toKick.getName());
|
||||
toKickFaction.removeAltPlayer(toKick);
|
||||
toKickFaction.deinvite(toKick);
|
||||
toKick.resetFactionData();
|
||||
}
|
||||
|
||||
@Override
|
||||
public TL getUsageTranslation() {
|
||||
return TL.COMMAND_ALTKICK_DESCRIPTION;
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,108 @@
|
||||
package com.massivecraft.factions.cmd.chest;
|
||||
|
||||
import com.massivecraft.factions.FPlayer;
|
||||
import com.massivecraft.factions.FPlayers;
|
||||
import com.massivecraft.factions.Faction;
|
||||
import com.massivecraft.factions.FactionsPlugin;
|
||||
import com.massivecraft.factions.zcore.faudit.FLogType;
|
||||
import com.massivecraft.factions.zcore.util.CC;
|
||||
import org.apache.commons.lang.StringUtils;
|
||||
import org.bukkit.Bukkit;
|
||||
import org.bukkit.Material;
|
||||
import org.bukkit.entity.Player;
|
||||
import org.bukkit.event.EventHandler;
|
||||
import org.bukkit.event.EventPriority;
|
||||
import org.bukkit.event.Listener;
|
||||
import org.bukkit.event.inventory.ClickType;
|
||||
import org.bukkit.event.inventory.InventoryClickEvent;
|
||||
import org.bukkit.event.inventory.InventoryDragEvent;
|
||||
import org.bukkit.inventory.Inventory;
|
||||
import org.bukkit.inventory.ItemStack;
|
||||
|
||||
import java.util.Arrays;
|
||||
|
||||
public class FChestListener implements Listener {
|
||||
|
||||
@EventHandler
|
||||
public void onInventoryDrag(InventoryDragEvent e) {
|
||||
|
||||
Player player = (Player) e.getWhoClicked();
|
||||
FPlayer fPlayer = FPlayers.getInstance().getByPlayer(player);
|
||||
if (!fPlayer.isInFactionsChest()) return;
|
||||
if (e.isCancelled()) return;
|
||||
e.setCancelled(true);
|
||||
e.getWhoClicked().sendMessage(CC.RedB + "(!) " + CC.Red + "You cannot drag items while viewing a /f chest!");
|
||||
}
|
||||
|
||||
|
||||
@EventHandler(
|
||||
priority = EventPriority.HIGHEST,
|
||||
ignoreCancelled = true
|
||||
)
|
||||
public void onPlayerClickInventory(InventoryClickEvent event) {
|
||||
Player player = (Player) event.getWhoClicked();
|
||||
FPlayer fPlayer = FPlayers.getInstance().getByPlayer(player);
|
||||
if (!fPlayer.isInFactionsChest()) return;
|
||||
|
||||
if (event.getClick() == ClickType.UNKNOWN) {
|
||||
event.setCancelled(true);
|
||||
player.sendMessage(CC.RedB + "(!) " + CC.Red + "You cannot use that click type inside the /f chest!");
|
||||
return;
|
||||
}
|
||||
|
||||
ItemStack currentItem = event.getCurrentItem();
|
||||
if (event.getClick() == ClickType.NUMBER_KEY) {
|
||||
currentItem = event.getClickedInventory().getItem(event.getSlot());
|
||||
}
|
||||
|
||||
Material currentItemType = currentItem != null ? currentItem.getType() : Material.AIR;
|
||||
|
||||
ItemStack cursorItem = event.getCursor();
|
||||
if (event.getClick() == ClickType.NUMBER_KEY) {
|
||||
cursorItem = player.getInventory().getItem(event.getHotbarButton());
|
||||
}
|
||||
|
||||
Material cursorItemType = cursorItem != null ? cursorItem.getType() : Material.AIR;
|
||||
FPlayer fplayer = FPlayers.getInstance().getByPlayer(player);
|
||||
Faction faction;
|
||||
if (fplayer == null || !(faction = fplayer.getFaction()).isNormal()) {
|
||||
player.closeInventory();
|
||||
player.sendMessage(CC.RedB + "(!) " + CC.Red + "You are no longer in your faction!");
|
||||
return;
|
||||
}
|
||||
|
||||
if (event.getClickedInventory() == null) {
|
||||
return;
|
||||
}
|
||||
|
||||
if (event.getClickedInventory().getName().equalsIgnoreCase(FactionsPlugin.getInstance().color(FactionsPlugin.getInstance().getConfig().getString("fchest.Inventory-Title")))) {
|
||||
if (currentItemType != Material.AIR) {
|
||||
Inventory ours = faction.getChestInventory();
|
||||
if (ours == null || !ours.contains(currentItem)) {
|
||||
event.setCancelled(true);
|
||||
player.sendMessage(CC.RedB + "(!) That item not longer exists!");
|
||||
Bukkit.getLogger().info("[FactionChest] " + player.getName() + " tried to remove " + currentItem + " from /f chest when it didnt contain! Items: " + (ours == null ? "none" : Arrays.toString(ours.getContents())));
|
||||
player.closeInventory();
|
||||
return;
|
||||
}
|
||||
|
||||
this.logRemoveItem(currentItem, fplayer, player);
|
||||
} else if (cursorItemType != Material.AIR && !event.isShiftClick()) {
|
||||
this.logAddItem(cursorItem, fplayer, player);
|
||||
}
|
||||
} else if (event.isShiftClick() && currentItemType != Material.AIR) {
|
||||
this.logAddItem(currentItem, fplayer, player);
|
||||
}
|
||||
}
|
||||
|
||||
private void logAddItem(ItemStack cursorItem, FPlayer fplayer, Player player) {
|
||||
String itemName = cursorItem.hasItemMeta() && cursorItem.getItemMeta().hasDisplayName() ? cursorItem.getItemMeta().getDisplayName() : StringUtils.capitaliseAllWords(cursorItem.getType().name().replace("_", " ").toLowerCase());
|
||||
FactionsPlugin.instance.logFactionEvent(fplayer.getFaction(), FLogType.FCHEST_EDIT, player.getName(), CC.GreenB + "ADDED", itemName);
|
||||
}
|
||||
|
||||
private void logRemoveItem(ItemStack currentItem, FPlayer fplayer, Player player) {
|
||||
String itemName = currentItem.hasItemMeta() && currentItem.getItemMeta().hasDisplayName() ? currentItem.getItemMeta().getDisplayName() : StringUtils.capitaliseAllWords(currentItem.getType().name().replace("_", " ").toLowerCase());
|
||||
FactionsPlugin.instance.logFactionEvent(fplayer.getFaction(), FLogType.FCHEST_EDIT, player.getName(), CC.RedB + "TOOK", itemName);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,13 +1,17 @@
|
||||
package com.massivecraft.factions.cmd.claim;
|
||||
|
||||
import com.massivecraft.factions.FLocation;
|
||||
import com.massivecraft.factions.Faction;
|
||||
import com.massivecraft.factions.FactionsPlugin;
|
||||
import com.massivecraft.factions.cmd.CommandContext;
|
||||
import com.massivecraft.factions.cmd.CommandRequirements;
|
||||
import com.massivecraft.factions.cmd.FCommand;
|
||||
import com.massivecraft.factions.struct.Permission;
|
||||
import com.massivecraft.factions.struct.Role;
|
||||
import com.massivecraft.factions.zcore.faudit.FLogType;
|
||||
import com.massivecraft.factions.zcore.fperms.Access;
|
||||
import com.massivecraft.factions.zcore.fperms.PermissableAction;
|
||||
import com.massivecraft.factions.zcore.util.CC;
|
||||
import com.massivecraft.factions.zcore.util.TL;
|
||||
|
||||
public class CmdAutoClaim extends FCommand {
|
||||
@@ -53,11 +57,10 @@ public class CmdAutoClaim extends FCommand {
|
||||
|
||||
return;
|
||||
}
|
||||
|
||||
context.fPlayer.setAutoClaimFor(forFaction);
|
||||
|
||||
context.msg(TL.COMMAND_AUTOCLAIM_ENABLED, forFaction.describeTo(context.fPlayer));
|
||||
context.fPlayer.attemptClaim(forFaction, context.fPlayer.getPlayer().getLocation(), true);
|
||||
FactionsPlugin.instance.logFactionEvent(forFaction, FLogType.CHUNK_CLAIMS, context.fPlayer.getName(), CC.GreenB + "CLAIMED", "1", new FLocation(context.fPlayer.getPlayer().getLocation()).formatXAndZ(","));
|
||||
}
|
||||
|
||||
@Override
|
||||
|
||||
@@ -3,14 +3,17 @@ 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.cmd.CommandContext;
|
||||
import com.massivecraft.factions.cmd.CommandRequirements;
|
||||
import com.massivecraft.factions.cmd.FCommand;
|
||||
import com.massivecraft.factions.struct.Permission;
|
||||
import com.massivecraft.factions.struct.Role;
|
||||
import com.massivecraft.factions.util.SpiralTask;
|
||||
import com.massivecraft.factions.zcore.faudit.FLogType;
|
||||
import com.massivecraft.factions.zcore.fperms.Access;
|
||||
import com.massivecraft.factions.zcore.fperms.PermissableAction;
|
||||
import com.massivecraft.factions.zcore.util.CC;
|
||||
import com.massivecraft.factions.zcore.util.TL;
|
||||
|
||||
|
||||
@@ -69,11 +72,11 @@ public class CmdClaim extends FCommand {
|
||||
boolean success = context.fPlayer.attemptClaim(forFaction, this.currentLocation(), true);
|
||||
if (success) {
|
||||
failCount = 0;
|
||||
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();
|
||||
return false;
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
};
|
||||
|
||||
@@ -2,11 +2,14 @@ package com.massivecraft.factions.cmd.claim;
|
||||
|
||||
import com.massivecraft.factions.Conf;
|
||||
import com.massivecraft.factions.FLocation;
|
||||
import com.massivecraft.factions.FactionsPlugin;
|
||||
import com.massivecraft.factions.cmd.CommandContext;
|
||||
import com.massivecraft.factions.cmd.CommandRequirements;
|
||||
import com.massivecraft.factions.cmd.FCommand;
|
||||
import com.massivecraft.factions.struct.Permission;
|
||||
import com.massivecraft.factions.zcore.faudit.FLogType;
|
||||
import com.massivecraft.factions.zcore.fperms.PermissableAction;
|
||||
import com.massivecraft.factions.zcore.util.CC;
|
||||
import com.massivecraft.factions.zcore.util.TL;
|
||||
|
||||
public class CmdClaimAt extends FCommand {
|
||||
|
||||
@@ -1,13 +1,17 @@
|
||||
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.cmd.CommandContext;
|
||||
import com.massivecraft.factions.cmd.CommandRequirements;
|
||||
import com.massivecraft.factions.cmd.FCommand;
|
||||
import com.massivecraft.factions.struct.Permission;
|
||||
import com.massivecraft.factions.zcore.faudit.FLogType;
|
||||
import com.massivecraft.factions.zcore.fperms.Access;
|
||||
import com.massivecraft.factions.zcore.fperms.PermissableAction;
|
||||
import com.massivecraft.factions.zcore.util.CC;
|
||||
import com.massivecraft.factions.zcore.util.TL;
|
||||
import org.bukkit.Location;
|
||||
import org.bukkit.block.BlockFace;
|
||||
@@ -79,7 +83,7 @@ public class CmdClaimLine extends FCommand {
|
||||
for (int i = 0; i < amount; i++) {
|
||||
context.fPlayer.attemptClaim(forFaction, location, true);
|
||||
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(",")); }
|
||||
}
|
||||
|
||||
@Override
|
||||
|
||||
@@ -9,8 +9,10 @@ import com.massivecraft.factions.integration.Econ;
|
||||
import com.massivecraft.factions.struct.Permission;
|
||||
import com.massivecraft.factions.struct.Role;
|
||||
import com.massivecraft.factions.util.SpiralTask;
|
||||
import com.massivecraft.factions.zcore.faudit.FLogType;
|
||||
import com.massivecraft.factions.zcore.fperms.Access;
|
||||
import com.massivecraft.factions.zcore.fperms.PermissableAction;
|
||||
import com.massivecraft.factions.zcore.util.CC;
|
||||
import com.massivecraft.factions.zcore.util.TL;
|
||||
import org.bukkit.Bukkit;
|
||||
|
||||
@@ -54,7 +56,9 @@ public class CmdUnclaim extends FCommand {
|
||||
|
||||
if (radius == 1) {
|
||||
// single chunk
|
||||
unClaim(new FLocation(context.player), context);
|
||||
boolean didUnClaim = unClaim(new FLocation(context.player), context);
|
||||
if (didUnClaim && !context.fPlayer.canFlyAtLocation())
|
||||
context.fPlayer.setFFlying(false, false);
|
||||
} else {
|
||||
// radius claim
|
||||
if (!Permission.CLAIM_RADIUS.has(context.sender, false)) {
|
||||
@@ -122,6 +126,7 @@ public class CmdUnclaim extends FCommand {
|
||||
Board.getInstance().removeAt(target);
|
||||
|
||||
targetFaction.msg(TL.COMMAND_UNCLAIM_UNCLAIMED, context.fPlayer.describeTo(targetFaction, true));
|
||||
FactionsPlugin.instance.logFactionEvent(targetFaction, FLogType.CHUNK_CLAIMS, context.fPlayer.getName(), CC.RedB + "UNCLAIMED", "1", (new FLocation(context.fPlayer.getPlayer().getLocation())).formatXAndZ(","));
|
||||
context.msg(TL.COMMAND_UNCLAIM_UNCLAIMS);
|
||||
|
||||
if (Conf.logLandUnclaims) {
|
||||
@@ -174,6 +179,8 @@ public class CmdUnclaim extends FCommand {
|
||||
|
||||
Board.getInstance().removeAt(target);
|
||||
context.faction.msg(TL.COMMAND_UNCLAIM_FACTIONUNCLAIMED, context.fPlayer.describeTo(context.faction, true));
|
||||
FactionsPlugin.instance.logFactionEvent(targetFaction, FLogType.CHUNK_CLAIMS, context.fPlayer.getName(), CC.RedB + "UNCLAIMED", "1", (new FLocation(context.fPlayer.getPlayer().getLocation())).formatXAndZ(","));
|
||||
|
||||
|
||||
if (Conf.logLandUnclaims) {
|
||||
FactionsPlugin.getInstance().log(TL.COMMAND_UNCLAIM_LOG.format(context.fPlayer.getName(), target.getCoordString(), targetFaction.getTag()));
|
||||
|
||||
@@ -1,16 +1,15 @@
|
||||
package com.massivecraft.factions.cmd.claim;
|
||||
|
||||
import com.massivecraft.factions.Board;
|
||||
import com.massivecraft.factions.Conf;
|
||||
import com.massivecraft.factions.Faction;
|
||||
import com.massivecraft.factions.FactionsPlugin;
|
||||
import com.massivecraft.factions.*;
|
||||
import com.massivecraft.factions.cmd.CommandContext;
|
||||
import com.massivecraft.factions.cmd.CommandRequirements;
|
||||
import com.massivecraft.factions.cmd.FCommand;
|
||||
import com.massivecraft.factions.event.LandUnclaimAllEvent;
|
||||
import com.massivecraft.factions.integration.Econ;
|
||||
import com.massivecraft.factions.struct.Permission;
|
||||
import com.massivecraft.factions.zcore.faudit.FLogType;
|
||||
import com.massivecraft.factions.zcore.fperms.PermissableAction;
|
||||
import com.massivecraft.factions.zcore.util.CC;
|
||||
import com.massivecraft.factions.zcore.util.TL;
|
||||
import org.bukkit.Bukkit;
|
||||
|
||||
@@ -66,12 +65,15 @@ public class CmdUnclaimall extends FCommand {
|
||||
|
||||
LandUnclaimAllEvent unclaimAllEvent = new LandUnclaimAllEvent(target, context.fPlayer);
|
||||
Bukkit.getScheduler().runTask(FactionsPlugin.getInstance(), () -> Bukkit.getServer().getPluginManager().callEvent(unclaimAllEvent));
|
||||
|
||||
if (unclaimAllEvent.isCancelled()) {
|
||||
return;
|
||||
}
|
||||
int unclaimed = target.getAllClaims().size();
|
||||
|
||||
Board.getInstance().unclaimAll(target.getId());
|
||||
context.faction.msg(TL.COMMAND_UNCLAIMALL_UNCLAIMED, context.fPlayer.describeTo(context.faction, true));
|
||||
FactionsPlugin.instance.logFactionEvent(context.faction, FLogType.CHUNK_CLAIMS, context.fPlayer.getName(), CC.RedB + "UNCLAIMED", String.valueOf(unclaimed), new FLocation(context.fPlayer.getPlayer().getLocation()).formatXAndZ(","));
|
||||
|
||||
if (Conf.logLandUnclaims) {
|
||||
FactionsPlugin.getInstance().log(TL.COMMAND_UNCLAIMALL_LOG.format(context.fPlayer.getName(), context.faction.getTag()));
|
||||
|
||||
@@ -8,6 +8,7 @@ import com.massivecraft.factions.cmd.FCommand;
|
||||
import com.massivecraft.factions.iface.EconomyParticipator;
|
||||
import com.massivecraft.factions.integration.Econ;
|
||||
import com.massivecraft.factions.struct.Permission;
|
||||
import com.massivecraft.factions.zcore.faudit.FLogType;
|
||||
import com.massivecraft.factions.zcore.util.TL;
|
||||
import org.bukkit.ChatColor;
|
||||
|
||||
@@ -38,6 +39,8 @@ public class CmdMoneyDeposit extends FCommand {
|
||||
|
||||
if (success && Conf.logMoneyTransactions) {
|
||||
FactionsPlugin.getInstance().log(ChatColor.stripColor(FactionsPlugin.getInstance().txt.parse(TL.COMMAND_MONEYDEPOSIT_DEPOSITED.toString(), context.fPlayer.getName(), Econ.moneyString(amount), faction.describeTo(null))));
|
||||
FactionsPlugin.instance.logFactionEvent(context.faction, FLogType.BANK_EDIT, context.fPlayer.getName(), ChatColor.GREEN + ChatColor.BOLD.toString() + "DEPOSITED", amount + "");
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -1,6 +1,7 @@
|
||||
package com.massivecraft.factions.cmd.econ;
|
||||
|
||||
import com.massivecraft.factions.Conf;
|
||||
import com.massivecraft.factions.Faction;
|
||||
import com.massivecraft.factions.FactionsPlugin;
|
||||
import com.massivecraft.factions.cmd.CommandContext;
|
||||
import com.massivecraft.factions.cmd.CommandRequirements;
|
||||
@@ -9,8 +10,10 @@ import com.massivecraft.factions.iface.EconomyParticipator;
|
||||
import com.massivecraft.factions.integration.Econ;
|
||||
import com.massivecraft.factions.struct.Permission;
|
||||
import com.massivecraft.factions.struct.Role;
|
||||
import com.massivecraft.factions.zcore.faudit.FLogType;
|
||||
import com.massivecraft.factions.zcore.fperms.Access;
|
||||
import com.massivecraft.factions.zcore.fperms.PermissableAction;
|
||||
import com.massivecraft.factions.zcore.util.CC;
|
||||
import com.massivecraft.factions.zcore.util.TL;
|
||||
import org.bukkit.ChatColor;
|
||||
|
||||
@@ -48,6 +51,8 @@ public class CmdMoneyWithdraw extends FCommand {
|
||||
|
||||
if (success && Conf.logMoneyTransactions) {
|
||||
FactionsPlugin.getInstance().log(ChatColor.stripColor(FactionsPlugin.getInstance().txt.parse(TL.COMMAND_MONEYWITHDRAW_WITHDRAW.toString(), context.fPlayer.getName(), Econ.moneyString(amount), faction.describeTo(null))));
|
||||
FactionsPlugin.instance.logFactionEvent((Faction) faction, FLogType.BANK_EDIT, context.fPlayer.getName(), CC.RedB + "WITHDREW", amount + "");
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -12,6 +12,7 @@ import com.massivecraft.factions.scoreboards.FTeamWrapper;
|
||||
import com.massivecraft.factions.struct.Permission;
|
||||
import com.massivecraft.factions.struct.Relation;
|
||||
import com.massivecraft.factions.struct.Role;
|
||||
import com.massivecraft.factions.zcore.faudit.FLogType;
|
||||
import com.massivecraft.factions.zcore.util.TL;
|
||||
import org.bukkit.Bukkit;
|
||||
import org.bukkit.ChatColor;
|
||||
@@ -79,7 +80,8 @@ public abstract class FRelationCommand extends FCommand {
|
||||
// trigger the faction relation event
|
||||
FactionRelationEvent relationEvent = new FactionRelationEvent(context.faction, them, oldRelation, currentRelation);
|
||||
Bukkit.getServer().getPluginManager().callEvent(relationEvent);
|
||||
|
||||
FactionsPlugin.instance.logFactionEvent(context.faction, FLogType.RELATION_CHANGE,context.fPlayer.getName(), this.targetRelation.getColor() + this.targetRelation.name(), oldRelation.getColor() + them.getTag());
|
||||
FactionsPlugin.instance.logFactionEvent(them, FLogType.RELATION_CHANGE, oldRelation.getColor() + context.fPlayer.getName(), this.targetRelation.getColor() + this.targetRelation.name(), "your faction");
|
||||
them.msg(TL.COMMAND_RELATIONS_MUTUAL, currentRelationColor + targetRelation.getTranslation(), currentRelationColor + context.faction.getTag());
|
||||
context.faction.msg(TL.COMMAND_RELATIONS_MUTUAL, currentRelationColor + targetRelation.getTranslation(), currentRelationColor + them.getTag());
|
||||
} else {
|
||||
|
||||
@@ -1,13 +1,17 @@
|
||||
package com.massivecraft.factions.cmd.roles;
|
||||
|
||||
import com.massivecraft.factions.FPlayer;
|
||||
import com.massivecraft.factions.FactionsPlugin;
|
||||
import com.massivecraft.factions.cmd.CommandContext;
|
||||
import com.massivecraft.factions.cmd.CommandRequirements;
|
||||
import com.massivecraft.factions.cmd.FCommand;
|
||||
import com.massivecraft.factions.struct.Permission;
|
||||
import com.massivecraft.factions.struct.Role;
|
||||
import com.massivecraft.factions.zcore.faudit.FLogType;
|
||||
import com.massivecraft.factions.zcore.fperms.PermissableAction;
|
||||
import com.massivecraft.factions.zcore.util.CC;
|
||||
import com.massivecraft.factions.zcore.util.TL;
|
||||
import org.bukkit.ChatColor;
|
||||
|
||||
public class FPromoteCommand extends FCommand {
|
||||
|
||||
@@ -51,6 +55,7 @@ public class FPromoteCommand extends FCommand {
|
||||
context.msg(TL.COMMAND_PROMOTE_NOT_SAME);
|
||||
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);
|
||||
@@ -78,6 +83,8 @@ public class FPromoteCommand extends FCommand {
|
||||
}
|
||||
|
||||
context.msg(TL.COMMAND_PROMOTE_SUCCESS, action, target.getName(), promotion.nicename);
|
||||
FactionsPlugin.instance.getFlogManager().log(context.faction, FLogType.ROLE_PERM_EDIT, context.fPlayer.getName(), action, target.getName(), promotion.nicename);
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
|
||||
@@ -1,11 +1,13 @@
|
||||
package com.massivecraft.factions.cmd.tnt;
|
||||
|
||||
import com.massivecraft.factions.Factions;
|
||||
import com.massivecraft.factions.FactionsPlugin;
|
||||
import com.massivecraft.factions.cmd.CommandContext;
|
||||
import com.massivecraft.factions.cmd.CommandRequirements;
|
||||
import com.massivecraft.factions.cmd.FCommand;
|
||||
import com.massivecraft.factions.struct.Permission;
|
||||
import com.massivecraft.factions.util.XMaterial;
|
||||
import com.massivecraft.factions.zcore.faudit.FLogType;
|
||||
import com.massivecraft.factions.zcore.fperms.PermissableAction;
|
||||
import com.massivecraft.factions.zcore.util.TL;
|
||||
import org.bukkit.Material;
|
||||
@@ -17,7 +19,7 @@ public class CmdTnt extends FCommand {
|
||||
public CmdTnt() {
|
||||
super();
|
||||
this.aliases.add("tnt");
|
||||
this.optionalArgs.put("add/take", "");
|
||||
this.optionalArgs.put("add/take/addall", "");
|
||||
this.optionalArgs.put("amount", "number");
|
||||
|
||||
this.requirements = new CommandRequirements.Builder(Permission.TNT)
|
||||
@@ -33,7 +35,6 @@ public class CmdTnt extends FCommand {
|
||||
context.msg(TL.COMMAND_TNT_DISABLED_MSG);
|
||||
return;
|
||||
}
|
||||
|
||||
if (context.args.size() == 2) {
|
||||
if (context.args.get(0).equalsIgnoreCase("add") || context.args.get(0).equalsIgnoreCase("a")) {
|
||||
try {
|
||||
@@ -62,7 +63,7 @@ public class CmdTnt extends FCommand {
|
||||
return;
|
||||
}
|
||||
ItemStack tnt = new ItemStack(Material.TNT, amount);
|
||||
if (context.faction.getTnt() + amount > FactionsPlugin.instance.getConfig().getInt("ftnt.Bank-Limit")) {
|
||||
if (context.faction.getTnt() + amount > context.faction.getTntBankLimit()) {
|
||||
context.msg(TL.COMMAND_TNT_EXCEEDLIMIT);
|
||||
return;
|
||||
}
|
||||
@@ -71,7 +72,8 @@ public class CmdTnt extends FCommand {
|
||||
|
||||
context.faction.addTnt(amount);
|
||||
context.msg(TL.COMMAND_TNT_DEPOSIT_SUCCESS);
|
||||
context.fPlayer.sendMessage(FactionsPlugin.instance.color(TL.COMMAND_TNT_AMOUNT.toString().replace("{amount}", context.fPlayer.getFaction().getTnt() + "")));
|
||||
FactionsPlugin.instance.getFlogManager().log(context.faction, FLogType.F_TNT, context.fPlayer.getName(), "DEPOSITED", amount + "x TNT");
|
||||
context.fPlayer.sendMessage(FactionsPlugin.instance.color(TL.COMMAND_TNT_AMOUNT.toString().replace("{amount}", context.faction.getTnt() + "").replace("{maxAmount}", context.faction.getTntBankLimit() + "")));
|
||||
return;
|
||||
|
||||
}
|
||||
@@ -91,7 +93,7 @@ public class CmdTnt extends FCommand {
|
||||
context.msg(TL.COMMAND_TNT_WIDTHDRAW_NOTENOUGH_TNT.toString());
|
||||
return;
|
||||
}
|
||||
int fullStacks = Math.round(amount / 64);
|
||||
int fullStacks = amount / 64;
|
||||
int remainderAmt = amount - (fullStacks * 64);
|
||||
if ((remainderAmt == 0 && !hasAvaliableSlot(context.player, fullStacks))) {
|
||||
context.msg(TL.COMMAND_TNT_WIDTHDRAW_NOTENOUGH_SPACE);
|
||||
@@ -108,12 +110,40 @@ public class CmdTnt extends FCommand {
|
||||
context.faction.takeTnt(amount);
|
||||
context.player.updateInventory();
|
||||
context.msg(TL.COMMAND_TNT_WIDTHDRAW_SUCCESS);
|
||||
FactionsPlugin.instance.getFlogManager().log(context.faction, FLogType.F_TNT, context.fPlayer.getName(), "WITHDREW", amount + "x TNT");
|
||||
}
|
||||
} else if (context.args.size() == 1) {
|
||||
if (context.args.get(0).equalsIgnoreCase("addall")) {
|
||||
Inventory inv = context.player.getInventory();
|
||||
int invTnt = 0;
|
||||
for (int i = 0; i <= inv.getSize(); i++) {
|
||||
if (inv.getItem(i) == null) { continue; }
|
||||
if (inv.getItem(i).getType() == Material.TNT) {
|
||||
invTnt += inv.getItem(i).getAmount();
|
||||
}
|
||||
}
|
||||
if (invTnt <= 0) {
|
||||
context.msg(TL.COMMAND_TNT_DEPOSIT_NOTENOUGH);
|
||||
return;
|
||||
}
|
||||
if (context.faction.getTnt() + invTnt > context.faction.getTntBankLimit()) {
|
||||
context.msg(TL.COMMAND_TNT_EXCEEDLIMIT);
|
||||
return;
|
||||
}
|
||||
removeItems(context.player.getInventory(), new ItemStack(Material.TNT), invTnt);
|
||||
context.player.updateInventory();
|
||||
context.faction.addTnt(invTnt);
|
||||
context.msg(TL.COMMAND_TNT_DEPOSIT_SUCCESS);
|
||||
|
||||
context.fPlayer.sendMessage(FactionsPlugin.instance.color(TL.COMMAND_TNT_AMOUNT.toString().replace("{amount}", context.faction.getTnt() + "").replace("{maxAmount}", context.faction.getTntBankLimit() + "")));
|
||||
FactionsPlugin.instance.getFlogManager().log(context.faction, FLogType.F_TNT, context.fPlayer.getName(), "DEPOSITED", invTnt + "x TNT");
|
||||
return;
|
||||
|
||||
}
|
||||
context.msg(TL.GENERIC_ARGS_TOOFEW);
|
||||
context.msg(context.args.get(0).equalsIgnoreCase("take") || context.args.get(0).equalsIgnoreCase("t") ? TL.COMMAND_TNT_TAKE_DESCRIPTION : TL.COMMAND_TNT_ADD_DESCRIPTION);
|
||||
}
|
||||
context.sendMessage(TL.COMMAND_TNT_AMOUNT.toString().replace("{amount}", context.faction.getTnt() + ""));
|
||||
context.sendMessage(TL.COMMAND_TNT_AMOUNT.toString().replace("{amount}", context.faction.getTnt() + "").replace("{maxAmount}", context.faction.getTntBankLimit() + ""));
|
||||
}
|
||||
|
||||
|
||||
@@ -141,6 +171,24 @@ public class CmdTnt extends FCommand {
|
||||
return check >= howmany;
|
||||
}
|
||||
|
||||
public static void removeItems(Inventory inventory, ItemStack item, int toRemove) {
|
||||
if (toRemove <= 0 || inventory == null || item == null)
|
||||
return;
|
||||
for (int i = 0; i < inventory.getSize(); i++) {
|
||||
ItemStack loopItem = inventory.getItem(i);
|
||||
if (loopItem == null || !item.isSimilar(loopItem))
|
||||
continue;
|
||||
if (toRemove <= 0)
|
||||
return;
|
||||
if (toRemove < loopItem.getAmount()) {
|
||||
loopItem.setAmount(loopItem.getAmount() - toRemove);
|
||||
return;
|
||||
}
|
||||
inventory.clear(i);
|
||||
toRemove -= loopItem.getAmount();
|
||||
}
|
||||
}
|
||||
|
||||
public void removeFromInventory(Inventory inventory, ItemStack item) {
|
||||
int amt = item.getAmount();
|
||||
ItemStack[] items = inventory.getContents();
|
||||
|
||||
@@ -86,7 +86,7 @@ public class Econ {
|
||||
FactionsPlugin.getInstance().log(Level.WARNING, "Vault does not appear to be hooked into an economy plugin.");
|
||||
return;
|
||||
}
|
||||
to.sendMessage(String.format("%s's balance is %s.", about.getTag(), Econ.moneyString(econ.getBalance(about.getAccountId()))));
|
||||
to.sendMessage(String.format(TL.ECON_PLAYERBALANCE.toString(), about.getTag(), Econ.moneyString(econ.getBalance(about.getAccountId()))));
|
||||
}
|
||||
|
||||
public static boolean canIControllYou(EconomyParticipator i, EconomyParticipator you) {
|
||||
@@ -126,7 +126,7 @@ public class Econ {
|
||||
}
|
||||
|
||||
// Otherwise you may not!;,,;
|
||||
i.msg("<h>%s<i> lacks permission to control <h>%s's<i> money.", i.describeTo(i, true), you.describeTo(i));
|
||||
i.msg(TL.ECON_CANTCONTROLMONEY, i.describeTo(i, true), you.describeTo(i));
|
||||
return false;
|
||||
}
|
||||
|
||||
@@ -179,7 +179,7 @@ public class Econ {
|
||||
if (!econ.has(fromAcc, amount)) {
|
||||
// There was not enough money to pay
|
||||
if (invoker != null && notify) {
|
||||
invoker.msg("<h>%s<b> can't afford to transfer <h>%s<b> to %s<b>.", from.describeTo(invoker, true), moneyString(amount), to.describeTo(invoker));
|
||||
invoker.msg(TL.COMMAND_MONEYTRANSFERFF_TRANSFERCANTAFFORD, from.describeTo(invoker, true), moneyString(amount), to.describeTo(invoker));
|
||||
}
|
||||
|
||||
return false;
|
||||
@@ -209,7 +209,7 @@ public class Econ {
|
||||
|
||||
// if we get here something with the transaction failed
|
||||
if (notify) {
|
||||
invoker.msg("Unable to transfer %s<b> to <h>%s<b> from <h>%s<b>.", moneyString(amount), to.describeTo(invoker), from.describeTo(invoker, true));
|
||||
invoker.msg(TL.ECON_UNABLETOTRANSFER, moneyString(amount), to.describeTo(invoker), from.describeTo(invoker, true));
|
||||
}
|
||||
|
||||
return false;
|
||||
@@ -237,19 +237,19 @@ public class Econ {
|
||||
|
||||
if (invoker == null) {
|
||||
for (FPlayer recipient : recipients) {
|
||||
recipient.msg("<h>%s<i> was transferred from <h>%s<i> to <h>%s<i>.", moneyString(amount), from.describeTo(recipient), to.describeTo(recipient));
|
||||
recipient.msg(TL.ECON_MONEYTRASFERREDFROM, moneyString(amount), from.describeTo(recipient), to.describeTo(recipient));
|
||||
}
|
||||
} else if (invoker == from) {
|
||||
for (FPlayer recipient : recipients) {
|
||||
recipient.msg("<h>%s<i> <h>gave %s<i> to <h>%s<i>.", from.describeTo(recipient, true), moneyString(amount), to.describeTo(recipient));
|
||||
recipient.msg(TL.ECON_PERSONGAVEMONEYTO, from.describeTo(recipient, true), moneyString(amount), to.describeTo(recipient));
|
||||
}
|
||||
} else if (invoker == to) {
|
||||
for (FPlayer recipient : recipients) {
|
||||
recipient.msg("<h>%s<i> <h>took %s<i> from <h>%s<i>.", to.describeTo(recipient, true), moneyString(amount), from.describeTo(recipient));
|
||||
recipient.msg(TL.ECON_PERSONTOOKMONEYFROM, to.describeTo(recipient, true), moneyString(amount), from.describeTo(recipient));
|
||||
}
|
||||
} else {
|
||||
for (FPlayer recipient : recipients) {
|
||||
recipient.msg("<h>%s<i> transferred <h>%s<i> from <h>%s<i> to <h>%s<i>.", invoker.describeTo(recipient, true), moneyString(amount), from.describeTo(recipient), to.describeTo(recipient));
|
||||
recipient.msg(TL.ECON_MONEYTRASFERREDFROMPERSONTOPERSON, invoker.describeTo(recipient, true), moneyString(amount), from.describeTo(recipient), to.describeTo(recipient));
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -280,7 +280,7 @@ public class Econ {
|
||||
|
||||
if (!affordable) {
|
||||
if (toDoThis != null && !toDoThis.isEmpty()) {
|
||||
ep.msg("<h>%s<i> can't afford <h>%s<i> %s.", ep.describeTo(ep, true), moneyString(delta), toDoThis);
|
||||
ep.msg(TL.COMMAND_MONEY_CANTAFFORD, ep.describeTo(ep, true), moneyString(delta), toDoThis);
|
||||
}
|
||||
return false;
|
||||
}
|
||||
@@ -318,13 +318,13 @@ public class Econ {
|
||||
if (er.transactionSuccess()) {
|
||||
modifyUniverseMoney(-delta);
|
||||
if (forDoingThis != null && !forDoingThis.isEmpty()) {
|
||||
ep.msg("<h>%s<i> gained <h>%s<i> %s.", You, moneyString(delta), forDoingThis);
|
||||
ep.msg(TL.COMMAND_MONEY_GAINED, You, moneyString(delta), forDoingThis);
|
||||
}
|
||||
return true;
|
||||
} else {
|
||||
// transfer to account failed
|
||||
if (forDoingThis != null && !forDoingThis.isEmpty()) {
|
||||
ep.msg("<h>%s<i> would have gained <h>%s<i> %s, but the deposit failed.", You, moneyString(delta), forDoingThis);
|
||||
ep.msg(TL.ECON_DEPOSITFAILED, You, moneyString(delta), forDoingThis);
|
||||
}
|
||||
return false;
|
||||
}
|
||||
@@ -336,13 +336,13 @@ public class Econ {
|
||||
// There is enough money to pay
|
||||
modifyUniverseMoney(-delta);
|
||||
if (forDoingThis != null && !forDoingThis.isEmpty()) {
|
||||
ep.msg("<h>%s<i> lost <h>%s<i> %s.", You, moneyString(-delta), forDoingThis);
|
||||
ep.msg(TL.ECON_MONEYLOST, You, moneyString(-delta), forDoingThis);
|
||||
}
|
||||
return true;
|
||||
} else {
|
||||
// There was not enough money to pay
|
||||
if (toDoThis != null && !toDoThis.isEmpty()) {
|
||||
ep.msg("<h>%s<i> can't afford <h>%s<i> %s.", You, moneyString(-delta), toDoThis);
|
||||
ep.msg(TL.ECON_CANTAFFORD, You, moneyString(-delta), toDoThis);
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
@@ -3,137 +3,288 @@ package com.massivecraft.factions.integration;
|
||||
import com.massivecraft.factions.FLocation;
|
||||
import com.massivecraft.factions.FactionsPlugin;
|
||||
import com.sk89q.worldedit.BlockVector;
|
||||
import com.sk89q.worldedit.Vector;
|
||||
import com.sk89q.worldguard.bukkit.WorldGuardPlugin;
|
||||
import com.sk89q.worldguard.domains.Association;
|
||||
import com.sk89q.worldguard.protection.ApplicableRegionSet;
|
||||
import com.sk89q.worldguard.protection.flags.DefaultFlag;
|
||||
import com.sk89q.worldguard.protection.association.Associables;
|
||||
import com.sk89q.worldguard.protection.association.RegionAssociable;
|
||||
import com.sk89q.worldguard.protection.flags.StateFlag;
|
||||
import com.sk89q.worldguard.protection.managers.RegionManager;
|
||||
import com.sk89q.worldguard.protection.regions.ProtectedCuboidRegion;
|
||||
import com.sk89q.worldguard.protection.regions.ProtectedRegion;
|
||||
import org.bukkit.Bukkit;
|
||||
import org.bukkit.Chunk;
|
||||
import org.bukkit.Location;
|
||||
import org.bukkit.World;
|
||||
import org.bukkit.entity.Player;
|
||||
import org.bukkit.plugin.Plugin;
|
||||
|
||||
import java.lang.reflect.Constructor;
|
||||
import java.lang.reflect.Method;
|
||||
import java.util.ArrayList;
|
||||
import java.util.Collection;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
|
||||
import static com.sk89q.worldguard.bukkit.BukkitUtil.toVector;
|
||||
|
||||
/*
|
||||
* Worldguard Region Checking
|
||||
* Author: Spathizilla
|
||||
* WorldGuard Permission Checking.
|
||||
* https://github.com/elBukkit/MagicPlugin/blob/master/Magic/src/main/java/com/elmakers/mine/bukkit/protection/WorldGuardAPI.java
|
||||
* Original Authors: NathonWolf, killme
|
||||
* Converted & Adapted: Savag3life
|
||||
*/
|
||||
|
||||
public class Worldguard {
|
||||
|
||||
private static WorldGuardPlugin wg;
|
||||
private static boolean enabled = false;
|
||||
private Object worldGuard;
|
||||
private WorldGuardPlugin worldGuardPlugin;
|
||||
private Object regionContainer;
|
||||
private Method regionContainerGetMethod;
|
||||
private Method createQueryMethod;
|
||||
private Method regionQueryTestStateMethod;
|
||||
private Method locationAdaptMethod;
|
||||
private Method worldAdaptMethod;
|
||||
private Method regionManagerGetMethod;
|
||||
private Constructor<?> vectorConstructor;
|
||||
private Method vectorConstructorAsAMethodBecauseWhyNot;
|
||||
private StateFlag buildFlag;
|
||||
private StateFlag breakFlag;
|
||||
private boolean initialized = false;
|
||||
|
||||
public static void init(Plugin plugin) {
|
||||
Plugin wgplug = plugin.getServer().getPluginManager().getPlugin("WorldGuard");
|
||||
if (wgplug == null || !(wgplug instanceof WorldGuardPlugin)) {
|
||||
enabled = false;
|
||||
wg = null;
|
||||
FactionsPlugin.getInstance().log("Could not hook to WorldGuard. WorldGuard checks are disabled.");
|
||||
private static Worldguard instance;
|
||||
|
||||
public Worldguard() {
|
||||
instance = this;
|
||||
|
||||
Plugin p = Bukkit.getPluginManager().getPlugin("WorldGuard");
|
||||
|
||||
if (p == null) {
|
||||
FactionsPlugin.instance.log("Could not find WorldGuard! Support will not be added.");
|
||||
return;
|
||||
}
|
||||
if (p instanceof WorldGuardPlugin) {
|
||||
worldGuardPlugin = (WorldGuardPlugin) p;
|
||||
|
||||
try {
|
||||
Class<?> worldGuardClass = Class.forName("com.sk89q.worldguard.WorldGuard");
|
||||
Method getInstanceMethod = worldGuardClass.getMethod("getInstance");
|
||||
worldGuard = getInstanceMethod.invoke(null);
|
||||
FactionsPlugin.instance.log("Found WorldGuard 7+");
|
||||
} catch (Exception ex) { FactionsPlugin.instance.log("Found WorldGuard <7"); }
|
||||
}
|
||||
}
|
||||
|
||||
public boolean isEnabled() {
|
||||
return worldGuardPlugin != null;
|
||||
}
|
||||
|
||||
public static Worldguard getInstance() { return instance; }
|
||||
|
||||
protected RegionAssociable getAssociable(Player player) {
|
||||
RegionAssociable associable;
|
||||
if (player == null) {
|
||||
associable = Associables.constant(Association.NON_MEMBER);
|
||||
} else {
|
||||
wg = (WorldGuardPlugin) wgplug;
|
||||
enabled = true;
|
||||
FactionsPlugin.getInstance().log("Successfully hooked to WorldGuard.");
|
||||
associable = worldGuardPlugin.wrapPlayer(player);
|
||||
}
|
||||
|
||||
return associable;
|
||||
}
|
||||
|
||||
/**
|
||||
* Credits to the people listed above for using reflections to load WorldGuard 6.0 & 7.0 in 1 class!
|
||||
*/
|
||||
private void initialize() {
|
||||
if (!initialized) {
|
||||
initialized = true;
|
||||
if (worldGuard != null) {
|
||||
try {
|
||||
Method getPlatFormMethod = worldGuard.getClass().getMethod("getPlatform");
|
||||
Object platform = getPlatFormMethod.invoke(worldGuard);
|
||||
Method getRegionContainerMethod = platform.getClass().getMethod("getRegionContainer");
|
||||
regionContainer = getRegionContainerMethod.invoke(platform);
|
||||
createQueryMethod = regionContainer.getClass().getMethod("createQuery");
|
||||
Class<?> worldEditLocationClass = Class.forName("com.sk89q.worldedit.util.Location");
|
||||
Class<?> worldEditWorldClass = Class.forName("com.sk89q.worldedit.world.World");
|
||||
Class<?> worldEditAdapterClass = Class.forName("com.sk89q.worldedit.bukkit.BukkitAdapter");
|
||||
worldAdaptMethod = worldEditAdapterClass.getMethod("adapt", World.class);
|
||||
locationAdaptMethod = worldEditAdapterClass.getMethod("adapt", Location.class);
|
||||
regionContainerGetMethod = regionContainer.getClass().getMethod("get", worldEditWorldClass);
|
||||
Class<?> regionQueryClass = Class.forName("com.sk89q.worldguard.protection.regions.RegionQuery");
|
||||
regionQueryTestStateMethod = regionQueryClass.getMethod("testState", worldEditLocationClass, RegionAssociable.class, StateFlag[].class);
|
||||
|
||||
Class<?> flagsClass = Class.forName("com.sk89q.worldguard.protection.flags.Flags");
|
||||
|
||||
buildFlag = (StateFlag) flagsClass.getField("BUILD").get(null);
|
||||
breakFlag = (StateFlag) flagsClass.getField("BREAK").get(null);
|
||||
|
||||
} catch (Exception ex) {
|
||||
FactionsPlugin.instance.log("We failed to load some part of World Guard. Support will be removed!");
|
||||
FactionsPlugin.instance.log("WorldGuard 7.0.0 support is currently in BETA. Please be careful!");
|
||||
regionContainer = null;
|
||||
return;
|
||||
}
|
||||
} else {
|
||||
regionContainer = worldGuardPlugin.getRegionContainer();
|
||||
try {
|
||||
createQueryMethod = regionContainer.getClass().getMethod("createQuery");
|
||||
regionContainerGetMethod = regionContainer.getClass().getMethod("get", World.class);
|
||||
Class<?> regionQueryClass = Class.forName("com.sk89q.worldguard.bukkit.RegionQuery");
|
||||
regionQueryTestStateMethod = regionQueryClass.getMethod("testState", Location.class, RegionAssociable.class, StateFlag[].class);
|
||||
|
||||
Class<?> flagsClass = Class.forName("com.sk89q.worldguard.protection.flags.DefaultFlag");
|
||||
|
||||
buildFlag = (StateFlag) flagsClass.getField("BUILD").get(null);
|
||||
breakFlag = (StateFlag) flagsClass.getField("BREAK").get(null);
|
||||
|
||||
} catch (Exception ex) {
|
||||
FactionsPlugin.instance.log("We failed to load some part of World Guard. Support will be removed!");
|
||||
FactionsPlugin.instance.log("WorldGuard 7.0.0 support is currently in BETA. Please be careful!");
|
||||
regionContainer = null;
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
try {
|
||||
Class<?> vectorClass = Class.forName("com.sk89q.worldedit.Vector");
|
||||
vectorConstructor = vectorClass.getConstructor(Double.TYPE, Double.TYPE, Double.TYPE);
|
||||
regionManagerGetMethod = RegionManager.class.getMethod("getApplicableRegions", vectorClass);
|
||||
} catch (Exception ex) {
|
||||
try {
|
||||
Class<?> vectorClass = Class.forName("com.sk89q.worldedit.math.BlockVector3");
|
||||
vectorConstructorAsAMethodBecauseWhyNot = vectorClass.getMethod("at", Double.TYPE, Double.TYPE, Double.TYPE);
|
||||
regionManagerGetMethod = RegionManager.class.getMethod("getApplicableRegions", vectorClass);
|
||||
} catch (Exception sodonewiththis) {
|
||||
FactionsPlugin.instance.log("We failed to load Vector Classes from WorldGuard! Support will be removed!");
|
||||
FactionsPlugin.instance.log("WorldGuard 7.0.0 support is currently in BETA. Please be careful!");
|
||||
regionContainer = null;
|
||||
return;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public static boolean isEnabled() {
|
||||
return enabled;
|
||||
}
|
||||
|
||||
// PVP Flag check
|
||||
// Returns:
|
||||
// True: PVP is allowed
|
||||
// False: PVP is disallowed
|
||||
@SuppressWarnings("deprecation")
|
||||
public static boolean isPVP(Player player) {
|
||||
if (!enabled) {
|
||||
// No WG hooks so we'll always bypass this check.
|
||||
return true;
|
||||
}
|
||||
|
||||
Location loc = player.getLocation();
|
||||
World world = loc.getWorld();
|
||||
Vector pt = toVector(loc);
|
||||
|
||||
RegionManager regionManager = wg.getRegionManager(world);
|
||||
ApplicableRegionSet set = regionManager.getApplicableRegions(pt);
|
||||
return set.allows(DefaultFlag.PVP);
|
||||
}
|
||||
|
||||
// Check if player can build at location by worldguards rules.
|
||||
// Returns:
|
||||
// True: Player can build in the region.
|
||||
// False: Player can not build in the region.
|
||||
public static boolean playerCanBuild(Player player, Location loc) {
|
||||
if (!enabled) {
|
||||
// No WG hooks so we'll always bypass this check.
|
||||
return false;
|
||||
}
|
||||
|
||||
World world = loc.getWorld();
|
||||
Vector pt = toVector(loc);
|
||||
|
||||
return wg.getRegionManager(world).getApplicableRegions(pt).size() > 0 && wg.canBuild(player, loc);
|
||||
}
|
||||
|
||||
// Check for Regions in chunk the chunk
|
||||
// Returns:
|
||||
// True: Regions found within chunk
|
||||
// False: No regions found within chunk
|
||||
|
||||
public static boolean checkForRegionsInChunk(FLocation floc) {
|
||||
Chunk chunk = floc.getWorld().getChunkAt((int) floc.getX(), (int) floc.getZ());
|
||||
|
||||
return checkForRegionsInChunk(chunk);
|
||||
}
|
||||
|
||||
public static boolean checkForRegionsInChunk(Location loc) {
|
||||
Chunk chunk = loc.getWorld().getChunkAt(loc);
|
||||
|
||||
return checkForRegionsInChunk(chunk);
|
||||
}
|
||||
|
||||
public static boolean checkForRegionsInChunk(Chunk chunk) {
|
||||
if (!enabled) {
|
||||
// No WG hooks so we'll always bypass this check.
|
||||
return false;
|
||||
}
|
||||
|
||||
World world = chunk.getWorld();
|
||||
int minChunkX = chunk.getX() << 4;
|
||||
int minChunkZ = chunk.getZ() << 4;
|
||||
int maxChunkX = minChunkX + 15;
|
||||
int maxChunkZ = minChunkZ + 15;
|
||||
|
||||
int worldHeight = world.getMaxHeight(); // Allow for heights other than default
|
||||
|
||||
BlockVector minChunk = new BlockVector(minChunkX, 0, minChunkZ);
|
||||
BlockVector maxChunk = new BlockVector(maxChunkX, worldHeight, maxChunkZ);
|
||||
|
||||
RegionManager regionManager = wg.getRegionManager(world);
|
||||
ProtectedCuboidRegion region = new ProtectedCuboidRegion("wgfactionoverlapcheck", minChunk, maxChunk);
|
||||
Map<String, ProtectedRegion> allregions = regionManager.getRegions();
|
||||
Collection<ProtectedRegion> allregionslist = new ArrayList<>(allregions.values());
|
||||
List<ProtectedRegion> overlaps;
|
||||
boolean foundregions = false;
|
||||
|
||||
private RegionManager getRegionManager(World world) {
|
||||
initialize();
|
||||
if (regionContainer == null || regionContainerGetMethod == null) return null;
|
||||
RegionManager regionManager = null;
|
||||
try {
|
||||
overlaps = region.getIntersectingRegions(allregionslist);
|
||||
foundregions = overlaps != null && !overlaps.isEmpty();
|
||||
} catch (Exception e) {
|
||||
e.printStackTrace();
|
||||
if (worldAdaptMethod != null) {
|
||||
Object worldEditWorld = worldAdaptMethod.invoke(null, world);
|
||||
regionManager = (RegionManager)regionContainerGetMethod.invoke(regionContainer, worldEditWorld);
|
||||
} else {
|
||||
regionManager = (RegionManager)regionContainerGetMethod.invoke(regionContainer, world);
|
||||
}
|
||||
} catch (Exception ex) {
|
||||
FactionsPlugin.instance.log("An error occurred looking up a WorldGuard RegionManager");
|
||||
}
|
||||
return regionManager;
|
||||
}
|
||||
|
||||
return foundregions;
|
||||
private ApplicableRegionSet getRegionSet(Location location) {
|
||||
RegionManager regionManager = getRegionManager(location.getWorld());
|
||||
if (regionManager == null) return null;
|
||||
try {
|
||||
Object vector = vectorConstructorAsAMethodBecauseWhyNot == null
|
||||
? vectorConstructor.newInstance(location.getX(), location.getY(), location.getZ())
|
||||
: vectorConstructorAsAMethodBecauseWhyNot.invoke(null, location.getX(), location.getY(), location.getZ());
|
||||
return (ApplicableRegionSet)regionManagerGetMethod.invoke(regionManager, vector);
|
||||
} catch (Exception ex) {
|
||||
FactionsPlugin.instance.log("An error occurred looking up a WorldGuard ApplicableRegionSet");
|
||||
FactionsPlugin.instance.log("WorldGuard 7.0.0 support is currently in BETA. Please be careful!");
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Used to check WorldGuard to see if a Player has permission to place a block.
|
||||
* @param player player in question.
|
||||
* @param location Location of block placed.
|
||||
* @return
|
||||
*/
|
||||
public boolean hasBuildPermission(Player player, Location location) {
|
||||
initialize();
|
||||
if (createQueryMethod != null && regionContainer != null) {
|
||||
try {
|
||||
Object query = createQueryMethod.invoke(regionContainer);
|
||||
if (locationAdaptMethod != null) {
|
||||
Object loc = locationAdaptMethod.invoke(null, location);
|
||||
return (boolean)regionQueryTestStateMethod.invoke(query, loc, getAssociable(player), new StateFlag[]{buildFlag});
|
||||
} else return (boolean)regionQueryTestStateMethod.invoke(query, location, getAssociable(player), new StateFlag[]{buildFlag});
|
||||
} catch (Exception ex) {
|
||||
FactionsPlugin.instance.log("An error occurred querying WorldGuard! Report this issue to SF Developers!");
|
||||
FactionsPlugin.instance.log("WorldGuard 7.0.0 support is currently in BETA. Please be careful!");
|
||||
}
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
/**
|
||||
* Used to check WorldGuard to see if a player has permission to break a block.
|
||||
* @param player player in question.
|
||||
* @param location Location of block broken.
|
||||
* @return
|
||||
*/
|
||||
public boolean hasBreakPermission(Player player, Location location) {
|
||||
initialize();
|
||||
if (createQueryMethod != null && regionContainer != null) {
|
||||
try {
|
||||
Object query = createQueryMethod.invoke(regionContainer);
|
||||
if (locationAdaptMethod != null) {
|
||||
Object loc = locationAdaptMethod.invoke(null, location);
|
||||
return (boolean) regionQueryTestStateMethod.invoke(query, loc, getAssociable(player), new StateFlag[]{breakFlag});
|
||||
} else return (boolean) regionQueryTestStateMethod.invoke(query, location, getAssociable(player), new StateFlag[]{breakFlag});
|
||||
|
||||
} catch (Exception ex) {
|
||||
FactionsPlugin.instance.log("An error occurred querying WorldGuard! Report this issue to SF Developers!");
|
||||
FactionsPlugin.instance.log("WorldGuard 7.0.0 support is currently in BETA. Please be careful!");
|
||||
}
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
public boolean checkForRegionsInChunk(FLocation floc) { return checkForRegionsInChunk(floc.getChunk()); }
|
||||
|
||||
/**
|
||||
* Used for checking if regions are located in a chunk
|
||||
* @param chunk Chunk in question.
|
||||
* @return
|
||||
*/
|
||||
public boolean checkForRegionsInChunk(Chunk chunk) {
|
||||
initialize();
|
||||
if (createQueryMethod != null && regionContainer != null) {
|
||||
try {
|
||||
World world = chunk.getWorld();
|
||||
int minChunkX = chunk.getX() << 4;
|
||||
int minChunkZ = chunk.getZ() << 4;
|
||||
int maxChunkX = minChunkX + 15;
|
||||
int maxChunkZ = minChunkZ + 15;
|
||||
|
||||
int worldHeight = world.getMaxHeight(); // Allow for heights other than default
|
||||
|
||||
BlockVector minChunk = new BlockVector(minChunkX, 0, minChunkZ);
|
||||
BlockVector maxChunk = new BlockVector(maxChunkX, worldHeight, maxChunkZ);
|
||||
|
||||
ProtectedCuboidRegion region = new ProtectedCuboidRegion("wgfactionoverlapcheck", minChunk, maxChunk);
|
||||
|
||||
Collection<ProtectedRegion> allregionslist = new ArrayList<>(getRegionManager(world).getRegions().values());
|
||||
List<ProtectedRegion> overlaps = region.getIntersectingRegions(allregionslist);
|
||||
|
||||
return overlaps != null && !overlaps.isEmpty();
|
||||
} catch (Exception ex) {
|
||||
FactionsPlugin.instance.log("An error occurred querying WorldGuard! Report this issue to SF Developers!");
|
||||
FactionsPlugin.instance.log("WorldGuard 7.0.0 support is currently in BETA. Please be careful!");
|
||||
}
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
/**
|
||||
* General check for WorldGuard region @ location.
|
||||
* @param player player in question.
|
||||
* @param location Location of block broken.
|
||||
* @return
|
||||
*/
|
||||
public boolean playerCanBuild(Player player, Location location) {
|
||||
return hasBuildPermission(player, location) && hasBreakPermission(player, location);
|
||||
}
|
||||
}
|
||||
@@ -5,8 +5,11 @@ import com.massivecraft.factions.integration.Worldguard;
|
||||
import com.massivecraft.factions.struct.Permission;
|
||||
import com.massivecraft.factions.struct.Relation;
|
||||
import com.massivecraft.factions.struct.Role;
|
||||
import com.massivecraft.factions.util.ItemBuilder;
|
||||
import com.massivecraft.factions.util.Particles.ParticleEffect;
|
||||
import com.massivecraft.factions.util.XMaterial;
|
||||
import com.massivecraft.factions.zcore.faudit.FLogManager;
|
||||
import com.massivecraft.factions.zcore.faudit.LogTimer;
|
||||
import com.massivecraft.factions.zcore.fperms.Access;
|
||||
import com.massivecraft.factions.zcore.fperms.PermissableAction;
|
||||
import com.massivecraft.factions.zcore.util.TL;
|
||||
@@ -14,6 +17,8 @@ import org.bukkit.Bukkit;
|
||||
import org.bukkit.Location;
|
||||
import org.bukkit.Material;
|
||||
import org.bukkit.block.Block;
|
||||
import org.bukkit.block.BlockState;
|
||||
import org.bukkit.block.CreatureSpawner;
|
||||
import org.bukkit.entity.ArmorStand;
|
||||
import org.bukkit.entity.Entity;
|
||||
import org.bukkit.entity.EntityType;
|
||||
@@ -25,69 +30,57 @@ import org.bukkit.event.block.*;
|
||||
import org.bukkit.event.entity.EntityChangeBlockEvent;
|
||||
import org.bukkit.event.entity.EntityDamageEvent;
|
||||
import org.bukkit.event.entity.EntityExplodeEvent;
|
||||
import org.bukkit.event.hanging.HangingBreakByEntityEvent;
|
||||
import org.bukkit.inventory.ItemStack;
|
||||
import org.bukkit.inventory.meta.ItemMeta;
|
||||
import org.bukkit.material.MaterialData;
|
||||
import org.bukkit.potion.PotionEffect;
|
||||
import org.bukkit.potion.PotionEffectType;
|
||||
|
||||
import java.util.HashMap;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
import java.util.concurrent.TimeUnit;
|
||||
import java.util.concurrent.atomic.AtomicInteger;
|
||||
|
||||
|
||||
public class FactionsBlockListener implements Listener {
|
||||
|
||||
public static HashMap<String, Location> bannerLocations = new HashMap<>();
|
||||
private HashMap<String, Boolean> bannerCooldownMap = new HashMap<>();
|
||||
private long placeTimer = TimeUnit.SECONDS.toMillis(15L);
|
||||
|
||||
public static boolean playerCanBuildDestroyBlock(Player player, Location location, String action, boolean justCheck) {
|
||||
String name = player.getName();
|
||||
|
||||
if (Conf.playersWhoBypassAllProtection.contains(name))
|
||||
return true;
|
||||
if (Conf.playersWhoBypassAllProtection.contains(player.getName())) return true;
|
||||
|
||||
FPlayer me = FPlayers.getInstance().getById(player.getUniqueId().toString());
|
||||
Faction myFaction = me.getFaction();
|
||||
if (me.isAdminBypassing())
|
||||
return true;
|
||||
if (me.isAdminBypassing()) return true;
|
||||
|
||||
FLocation loc = new FLocation(location);
|
||||
Faction otherFaction = Board.getInstance().getFactionAt(loc);
|
||||
Faction myFaction = me.getFaction();
|
||||
|
||||
if (otherFaction.isWilderness()) {
|
||||
if (Conf.worldGuardBuildPriority && Worldguard.playerCanBuild(player, location))
|
||||
return true;
|
||||
|
||||
if (!Conf.wildernessDenyBuild || Conf.worldsNoWildernessProtection.contains(location.getWorld().getName()))
|
||||
return true; // This is not faction territory. Use whatever you like here.
|
||||
|
||||
if (!justCheck)
|
||||
me.msg("<b>You can't " + action + " in the wilderness.");
|
||||
|
||||
if (Conf.worldGuardBuildPriority && Worldguard.getInstance().playerCanBuild(player, location)) return true;
|
||||
if (location.getWorld() != null) {
|
||||
if (!Conf.wildernessDenyBuild || Conf.worldsNoWildernessProtection.contains(location.getWorld().getName()))
|
||||
return true;
|
||||
}
|
||||
if (!justCheck) me.msg(TL.ACTION_DENIED_WILDERNESS, action);
|
||||
return false;
|
||||
} else if (otherFaction.isSafeZone()) {
|
||||
if (Conf.worldGuardBuildPriority && Worldguard.playerCanBuild(player, location))
|
||||
return true;
|
||||
|
||||
if (!Conf.safeZoneDenyBuild || Permission.MANAGE_SAFE_ZONE.has(player))
|
||||
return true;
|
||||
|
||||
if (!justCheck)
|
||||
me.msg("<b>You can't " + action + " in a safe zone.");
|
||||
|
||||
if (Conf.worldGuardBuildPriority && Worldguard.getInstance().playerCanBuild(player, location)) return true;
|
||||
if (!Conf.safeZoneDenyBuild || Permission.MANAGE_SAFE_ZONE.has(player)) return true;
|
||||
if (!justCheck) me.msg(TL.ACTION_DENIED_SAFEZONE, action);
|
||||
return false;
|
||||
} else if (otherFaction.isWarZone()) {
|
||||
if (Conf.worldGuardBuildPriority && Worldguard.playerCanBuild(player, location))
|
||||
return true;
|
||||
|
||||
if (!Conf.warZoneDenyBuild || Permission.MANAGE_WAR_ZONE.has(player))
|
||||
return true;
|
||||
|
||||
if (!justCheck)
|
||||
me.msg("<b>You can't " + action + " in a war zone.");
|
||||
|
||||
if (Conf.worldGuardBuildPriority && Worldguard.getInstance().playerCanBuild(player, location)) return true;
|
||||
if (!Conf.warZoneDenyBuild || Permission.MANAGE_WAR_ZONE.has(player)) return true;
|
||||
if (!justCheck) me.msg(TL.ACTION_DENIED_WARZONE, action);
|
||||
return false;
|
||||
} else if (!otherFaction.getId().equals(myFaction.getId())) { // If the faction target is not my own
|
||||
if (FactionsPlugin.getInstance().getConfig().getBoolean("hcf.raidable", false) && otherFaction.getLandRounded() > otherFaction.getPowerRounded())
|
||||
if (FactionsPlugin.instance.getConfig().getBoolean("hcf.raidable", false) && otherFaction.getLandRounded() > otherFaction.getPowerRounded())
|
||||
return true;
|
||||
// Get faction pain build access relation to me
|
||||
boolean pain = !justCheck && otherFaction.getAccess(me, PermissableAction.PAIN_BUILD) == Access.ALLOW;
|
||||
@@ -96,7 +89,6 @@ public class FactionsBlockListener implements Listener {
|
||||
boolean pain = !justCheck && myFaction.getAccess(me, PermissableAction.PAIN_BUILD) == Access.ALLOW;
|
||||
return CheckActionState(myFaction, loc, me, PermissableAction.fromString(action), pain);
|
||||
}
|
||||
|
||||
// Something failed prevent build
|
||||
return false;
|
||||
}
|
||||
@@ -110,16 +102,17 @@ public class FactionsBlockListener implements Listener {
|
||||
me.msg(TL.ACTIONS_OWNEDTERRITORYDENY.toString().replace("{owners}", myFaction.getOwnerListString(loc)));
|
||||
if (shouldHurt) {
|
||||
player.damage(Conf.actionDeniedPainAmount);
|
||||
if ((Board.getInstance().getFactionAt(loc).getTag(myFaction)) != null)
|
||||
me.msg(TL.ACTIONS_NOPERMISSIONPAIN.toString().replace("{action}", action.toString()).replace("{faction}", Board.getInstance().getFactionAt(loc).getTag(myFaction)));
|
||||
me.msg(TL.ACTIONS_NOPERMISSIONPAIN.toString().replace("{action}", action.toString()).replace("{faction}", Board.getInstance().getFactionAt(loc).getTag(myFaction)));
|
||||
}
|
||||
return false;
|
||||
} else if (!landOwned && access == Access.DENY) { // If land is not owned but access is set to DENY anyway
|
||||
if (shouldHurt) {
|
||||
player.damage(Conf.actionDeniedPainAmount);
|
||||
me.msg(TL.ACTIONS_NOPERMISSIONPAIN.toString().replace("{action}", action.toString()).replace("{faction}", Board.getInstance().getFactionAt(loc).getTag(myFaction)));
|
||||
if ((Board.getInstance().getFactionAt(loc).getTag(myFaction)) != null)
|
||||
me.msg(TL.ACTIONS_NOPERMISSIONPAIN.toString().replace("{action}", action.toString()).replace("{faction}", Board.getInstance().getFactionAt(loc).getTag(myFaction)));
|
||||
}
|
||||
me.msg(TL.ACTIONS_NOPERMISSION.toString().replace("{faction}", myFaction.getTag(me.getFaction())).replace("{action}", action.toString()));
|
||||
if (myFaction.getTag(me.getFaction()) != null && action != null)
|
||||
me.msg(TL.ACTIONS_NOPERMISSION.toString().replace("{faction}", myFaction.getTag(me.getFaction())).replace("{action}", action.toString()));
|
||||
return false;
|
||||
} else if (access == Access.ALLOW) return true;
|
||||
me.msg(TL.ACTIONS_NOPERMISSION.toString().replace("{faction}", myFaction.getTag(me.getFaction())).replace("{action}", action.toString()));
|
||||
@@ -142,41 +135,34 @@ public class FactionsBlockListener implements Listener {
|
||||
|
||||
@EventHandler(priority = EventPriority.NORMAL, ignoreCancelled = true)
|
||||
public void onBlockPlace(BlockPlaceEvent event) {
|
||||
if (!event.canBuild()) {
|
||||
return;
|
||||
}
|
||||
|
||||
Faction at = Board.getInstance().getFactionAt(new FLocation(event.getBlockPlaced()));
|
||||
if (!event.canBuild()) return;
|
||||
|
||||
// special case for flint&steel, which should only be prevented by DenyUsage list
|
||||
if (event.getBlockPlaced().getType() == Material.FIRE) {
|
||||
return;
|
||||
}
|
||||
if (event.getBlockPlaced().getType() == Material.FIRE) return;
|
||||
boolean isSpawner = event.getBlock().getType().equals(XMaterial.SPAWNER.parseMaterial());
|
||||
|
||||
if (!playerCanBuildDestroyBlock(event.getPlayer(), event.getBlock().getLocation(), "build", false)) {
|
||||
if (!playerCanBuildDestroyBlock(event.getPlayer(), event.getBlock().getLocation(), !isSpawner ? "build" : "mine spawners", false)) {
|
||||
event.setCancelled(true);
|
||||
return;
|
||||
}
|
||||
|
||||
if (event.getBlock().getType().equals(XMaterial.SPAWNER.parseMaterial())) {
|
||||
if (isSpawner) {
|
||||
if (Conf.spawnerLock) {
|
||||
event.setCancelled(true);
|
||||
event.getPlayer().sendMessage(FactionsPlugin.getInstance().color(TL.COMMAND_SPAWNER_LOCK_CANNOT_PLACE.toString()));
|
||||
return;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@EventHandler(priority = EventPriority.NORMAL, ignoreCancelled = true)
|
||||
public void onBlockFromTo(BlockFromToEvent event) {
|
||||
if (!Conf.handleExploitLiquidFlow) {
|
||||
return;
|
||||
}
|
||||
if (!Conf.handleExploitLiquidFlow) return;
|
||||
if (event.getBlock().isLiquid()) {
|
||||
if (event.getToBlock().isEmpty()) {
|
||||
Faction from = Board.getInstance().getFactionAt(new FLocation(event.getBlock()));
|
||||
Faction to = Board.getInstance().getFactionAt(new FLocation(event.getToBlock()));
|
||||
if (from == to) {
|
||||
// not concerned with inter-faction events
|
||||
return;
|
||||
}
|
||||
if (from == to) return;
|
||||
// from faction != to faction
|
||||
if (to.isNormal()) {
|
||||
if (from.isNormal() && from.getRelationTo(to).isAlly()) {
|
||||
@@ -197,31 +183,27 @@ public class FactionsBlockListener implements Listener {
|
||||
|
||||
@EventHandler(priority = EventPriority.NORMAL, ignoreCancelled = true)
|
||||
public void onBlockPistonExtend(BlockPistonExtendEvent event) {
|
||||
if (!Conf.pistonProtectionThroughDenyBuild) {
|
||||
return;
|
||||
}
|
||||
|
||||
if (!Conf.pistonProtectionThroughDenyBuild) return;
|
||||
Faction pistonFaction = Board.getInstance().getFactionAt(new FLocation(event.getBlock()));
|
||||
|
||||
// target end-of-the-line empty (air) block which is being pushed into, including if piston itself would extend into air
|
||||
Block targetBlock = event.getBlock().getRelative(event.getDirection(), event.getLength() + 1);
|
||||
|
||||
// if potentially pushing into air/water/lava in another territory, we need to check it out
|
||||
if ((targetBlock.isEmpty() || targetBlock.isLiquid()) && !canPistonMoveBlock(pistonFaction, targetBlock.getLocation())) {
|
||||
if ((targetBlock.isEmpty() || targetBlock.isLiquid()) && !canPistonMoveBlock(pistonFaction, targetBlock.getLocation()))
|
||||
event.setCancelled(true);
|
||||
}
|
||||
|
||||
/*
|
||||
* note that I originally was testing the territory of each affected block, but since I found that pistons can only push
|
||||
* up to 12 blocks and the width of any territory is 16 blocks, it should be safe (and much more lightweight) to test
|
||||
* only the target block as done above
|
||||
*/
|
||||
}
|
||||
|
||||
|
||||
@EventHandler
|
||||
public void onVaultPlace(BlockPlaceEvent e) {
|
||||
if (e.getItemInHand().getType() == Material.CHEST) {
|
||||
ItemStack vault = FactionsPlugin.getInstance().createItem(Material.CHEST, 1, (short) 0, FactionsPlugin.getInstance().color(FactionsPlugin.getInstance().getConfig().getString("fvault.Item.Name")), FactionsPlugin.getInstance().colorList(FactionsPlugin.getInstance().getConfig().getStringList("fvault.Item.Lore")));
|
||||
|
||||
ItemStack vault = new ItemBuilder(Material.CHEST)
|
||||
.amount(1).name(FactionsPlugin.instance.getConfig().getString("fvault.Item.Name"))
|
||||
.lore(FactionsPlugin.instance.getConfig().getStringList("fvault.Item.Lore"))
|
||||
.build();
|
||||
|
||||
if (e.getItemInHand().isSimilar(vault)) {
|
||||
FPlayer fme = FPlayers.getInstance().getByPlayer(e.getPlayer());
|
||||
if (fme.getFaction().getVault() != null) {
|
||||
@@ -244,10 +226,8 @@ public class FactionsBlockListener implements Listener {
|
||||
if (blockLoc.getX() == start.getLocation().getX() && blockLoc.getY() == start.getLocation().getY() && blockLoc.getZ() == start.getLocation().getZ()) {
|
||||
continue;
|
||||
}
|
||||
|
||||
Material blockMaterial = blockLoc.getBlock().getType();
|
||||
|
||||
if (blockMaterial == Material.CHEST || (FactionsPlugin.getInstance().getConfig().getBoolean("fvault.No-Hoppers-near-vault") && blockMaterial == Material.HOPPER)) {
|
||||
if (blockMaterial == Material.CHEST || (FactionsPlugin.instance.getConfig().getBoolean("fvault.No-Hoppers-near-vault") && blockMaterial == Material.HOPPER)) {
|
||||
e.setCancelled(true);
|
||||
fme.msg(TL.COMMAND_GETVAULT_CHESTNEAR);
|
||||
return;
|
||||
@@ -255,7 +235,6 @@ public class FactionsBlockListener implements Listener {
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
fme.msg(TL.COMMAND_GETVAULT_SUCCESS);
|
||||
fme.getFaction().setVault(e.getBlockPlaced().getLocation());
|
||||
|
||||
@@ -263,21 +242,12 @@ public class FactionsBlockListener implements Listener {
|
||||
}
|
||||
}
|
||||
|
||||
@EventHandler (ignoreCancelled = true)
|
||||
@EventHandler
|
||||
public void onHopperPlace(BlockPlaceEvent e) {
|
||||
if (e.getItemInHand().getType() != Material.HOPPER || !FactionsPlugin.getInstance().getConfig().getBoolean("fvault.No-Hoppers-near-vault")) {
|
||||
return;
|
||||
}
|
||||
|
||||
if (e.getItemInHand().getType() != Material.HOPPER && !FactionsPlugin.instance.getConfig().getBoolean("fvault.No-Hoppers-near-vault")) return;
|
||||
Faction factionAt = Board.getInstance().getFactionAt(new FLocation(e.getBlockPlaced().getLocation()));
|
||||
|
||||
if (factionAt.isWilderness() || factionAt.getVault() == null) {
|
||||
return;
|
||||
}
|
||||
|
||||
|
||||
if (factionAt.isWilderness() || factionAt.getVault() == null) return;
|
||||
FPlayer fme = FPlayers.getInstance().getByPlayer(e.getPlayer());
|
||||
|
||||
Block start = e.getBlockPlaced();
|
||||
int radius = 1;
|
||||
for (double x = start.getLocation().getX() - radius; x <= start.getLocation().getX() + radius; x++) {
|
||||
@@ -288,7 +258,7 @@ public class FactionsBlockListener implements Listener {
|
||||
continue;
|
||||
}
|
||||
|
||||
if (blockLoc.getBlock().getType() == Material.CHEST) {
|
||||
if (blockLoc.getBlock().getType() == XMaterial.CHEST.parseMaterial()) {
|
||||
if (factionAt.getVault().equals(blockLoc)) {
|
||||
e.setCancelled(true);
|
||||
fme.msg(TL.COMMAND_VAULT_NO_HOPPER);
|
||||
@@ -304,32 +274,21 @@ public class FactionsBlockListener implements Listener {
|
||||
@EventHandler(priority = EventPriority.NORMAL, ignoreCancelled = true)
|
||||
public void onBlockPistonRetract(BlockPistonRetractEvent event) {
|
||||
// if not a sticky piston, retraction should be fine
|
||||
if (!event.isSticky() || !Conf.pistonProtectionThroughDenyBuild) {
|
||||
return;
|
||||
}
|
||||
if (!event.isSticky() || !Conf.pistonProtectionThroughDenyBuild) return;
|
||||
|
||||
if (event.getBlocks().isEmpty()) {
|
||||
return;
|
||||
}
|
||||
Location targetLoc = event.getBlocks().get(0).getLocation();
|
||||
Location targetLoc = event.getRetractLocation();
|
||||
Faction otherFaction = Board.getInstance().getFactionAt(new FLocation(targetLoc));
|
||||
|
||||
// Check if the piston is moving in a faction's territory. This disables pistons entirely in faction territory.
|
||||
if (otherFaction.isNormal() && FactionsPlugin.getInstance().getConfig().getBoolean("disable-pistons-in-territory", false)) {
|
||||
if (otherFaction.isNormal() && FactionsPlugin.instance.getConfig().getBoolean("disable-pistons-in-territory", false)) {
|
||||
event.setCancelled(true);
|
||||
return;
|
||||
}
|
||||
|
||||
// if potentially retracted block is just air/water/lava, no worries
|
||||
if (targetLoc.getBlock().isEmpty() || targetLoc.getBlock().isLiquid()) {
|
||||
return;
|
||||
}
|
||||
|
||||
if (targetLoc.getBlock().isEmpty() || targetLoc.getBlock().isLiquid()) return;
|
||||
Faction pistonFaction = Board.getInstance().getFactionAt(new FLocation(event.getBlock()));
|
||||
|
||||
if (!canPistonMoveBlock(pistonFaction, targetLoc)) {
|
||||
event.setCancelled(true);
|
||||
}
|
||||
if (!canPistonMoveBlock(pistonFaction, targetLoc)) event.setCancelled(true);
|
||||
}
|
||||
|
||||
@EventHandler
|
||||
@@ -349,16 +308,13 @@ public class FactionsBlockListener implements Listener {
|
||||
|
||||
@EventHandler
|
||||
public void onBannerPlace(BlockPlaceEvent e) {
|
||||
if (FactionsPlugin.getInstance().mc17) {
|
||||
return;
|
||||
}
|
||||
if (FactionsPlugin.getInstance().mc17) return;
|
||||
|
||||
if (e.getItemInHand().getType().name().contains("BANNER")) {
|
||||
ItemStack bannerInHand = e.getItemInHand();
|
||||
FPlayer fme = FPlayers.getInstance().getByPlayer(e.getPlayer());
|
||||
ItemStack warBanner = fme.getFaction().getBanner();
|
||||
if (warBanner == null) {
|
||||
return;
|
||||
}
|
||||
if (warBanner == null) return;
|
||||
ItemMeta warmeta = warBanner.getItemMeta();
|
||||
warmeta.setDisplayName(FactionsPlugin.getInstance().color(FactionsPlugin.getInstance().getConfig().getString("fbanners.Item.Name")));
|
||||
warmeta.setLore(FactionsPlugin.getInstance().colorList(FactionsPlugin.getInstance().getConfig().getStringList("fbanners.Item.Lore")));
|
||||
@@ -440,9 +396,8 @@ public class FactionsBlockListener implements Listener {
|
||||
|
||||
@EventHandler(priority = EventPriority.NORMAL, ignoreCancelled = true)
|
||||
public void onFrostWalker(EntityBlockFormEvent event) {
|
||||
if (event.getEntity() == null || event.getEntity().getType() != EntityType.PLAYER || event.getBlock() == null) {
|
||||
if (event.getEntity() == null || event.getEntity().getType() != EntityType.PLAYER || event.getBlock() == null)
|
||||
return;
|
||||
}
|
||||
|
||||
Player player = (Player) event.getEntity();
|
||||
Location location = event.getBlock().getLocation();
|
||||
@@ -450,14 +405,10 @@ public class FactionsBlockListener implements Listener {
|
||||
// only notify every 10 seconds
|
||||
FPlayer fPlayer = FPlayers.getInstance().getByPlayer(player);
|
||||
boolean justCheck = fPlayer.getLastFrostwalkerMessage() + 10000 > System.currentTimeMillis();
|
||||
if (!justCheck) {
|
||||
fPlayer.setLastFrostwalkerMessage();
|
||||
}
|
||||
if (!justCheck) fPlayer.setLastFrostwalkerMessage();
|
||||
|
||||
// Check if they have build permissions here. If not, block this from happening.
|
||||
if (!playerCanBuildDestroyBlock(player, location, "frostwalk", justCheck)) {
|
||||
event.setCancelled(true);
|
||||
}
|
||||
if (!playerCanBuildDestroyBlock(player, location, "frostwalk", justCheck)) event.setCancelled(true);
|
||||
}
|
||||
|
||||
@EventHandler
|
||||
@@ -476,14 +427,12 @@ public class FactionsBlockListener implements Listener {
|
||||
@EventHandler
|
||||
public void onBreak(EntityExplodeEvent e) {
|
||||
if (!Conf.gracePeriod) return;
|
||||
|
||||
e.setCancelled(true);
|
||||
}
|
||||
|
||||
@EventHandler
|
||||
public void entityDamage(EntityDamageEvent e) {
|
||||
if (!Conf.gracePeriod) return;
|
||||
|
||||
if (e.getEntity() instanceof Player) {
|
||||
if (e.getCause() == EntityDamageEvent.DamageCause.PROJECTILE) {
|
||||
e.setCancelled(true);
|
||||
@@ -499,48 +448,89 @@ public class FactionsBlockListener implements Listener {
|
||||
if (!fp.isAdminBypassing()) {
|
||||
if (e1.getBlock().getType().equals(Material.TNT)) {
|
||||
e1.setCancelled(true);
|
||||
|
||||
fp.msg(TL.COMMAND_GRACE_ENABLED, e1.getBlockPlaced().getType().toString());
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private boolean canPistonMoveBlock(Faction pistonFaction, Location target) {
|
||||
|
||||
Faction otherFaction = Board.getInstance().getFactionAt(new FLocation(target));
|
||||
|
||||
if (pistonFaction == otherFaction)
|
||||
return true;
|
||||
if (pistonFaction == otherFaction) return true;
|
||||
|
||||
if (otherFaction.isWilderness())
|
||||
return !Conf.wildernessDenyBuild || Conf.worldsNoWildernessProtection.contains(target.getWorld().getName());
|
||||
|
||||
else if (otherFaction.isSafeZone())
|
||||
return !Conf.safeZoneDenyBuild;
|
||||
|
||||
else if (otherFaction.isWarZone())
|
||||
return !Conf.warZoneDenyBuild;
|
||||
else if (otherFaction.isSafeZone()) return !Conf.safeZoneDenyBuild;
|
||||
else if (otherFaction.isWarZone()) return !Conf.warZoneDenyBuild;
|
||||
|
||||
Relation rel = pistonFaction.getRelationTo(otherFaction);
|
||||
|
||||
return !rel.confDenyBuild(otherFaction.hasPlayersOnline());
|
||||
}
|
||||
|
||||
|
||||
public void handleSpawnerUpdate(Faction at, Player player, ItemStack spawnerItem, LogTimer.TimerSubType subType) {
|
||||
FLogManager manager = FactionsPlugin.instance.getFlogManager();
|
||||
LogTimer logTimer = manager.getLogTimers().computeIfAbsent(player.getUniqueId(), e -> new LogTimer(player.getName(), at.getId()));
|
||||
LogTimer.Timer timer = logTimer.attemptLog(LogTimer.TimerType.SPAWNER_EDIT, subType, 0L);
|
||||
Map<MaterialData, AtomicInteger> currentCounts = (timer.getExtraData() == null) ? new HashMap<>() : ((Map) timer.getExtraData());
|
||||
currentCounts.computeIfAbsent(spawnerItem.getData(), e -> new AtomicInteger(0)).addAndGet(1);
|
||||
timer.setExtraData(currentCounts);
|
||||
if (timer.isReadyToLog(this.placeTimer)) {
|
||||
logTimer.pushLogs(at, LogTimer.TimerType.SPAWNER_EDIT);
|
||||
}
|
||||
}
|
||||
|
||||
@EventHandler(
|
||||
priority = EventPriority.HIGH,
|
||||
ignoreCancelled = true
|
||||
)
|
||||
public void onPlayerPlace(BlockPlaceEvent event) {
|
||||
ItemStack item = event.getItemInHand();
|
||||
if (item != null && item.getType() == XMaterial.SPAWNER.parseMaterial()) {
|
||||
Faction at = Board.getInstance().getFactionAt(new FLocation(event.getBlockPlaced()));
|
||||
if (at != null && at.isNormal()) {
|
||||
FPlayer fplayer = FPlayers.getInstance().getByPlayer(event.getPlayer());
|
||||
if (fplayer != null && at.getRelationTo(fplayer.getFaction()).isAtLeast(Relation.TRUCE)) {
|
||||
this.handleSpawnerUpdate(at, event.getPlayer(), item, LogTimer.TimerSubType.SPAWNER_PLACE);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@EventHandler(priority = EventPriority.NORMAL, ignoreCancelled = true)
|
||||
public void onBlockBreak(BlockBreakEvent event) {
|
||||
FPlayer fme = FPlayers.getInstance().getByPlayer(event.getPlayer());
|
||||
if (!playerCanBuildDestroyBlock(event.getPlayer(), event.getBlock().getLocation(), "destroy", false)) {
|
||||
Block block = event.getBlock();
|
||||
|
||||
Faction at = Board.getInstance().getFactionAt(new FLocation(block));
|
||||
boolean isSpawner = event.getBlock().getType() == XMaterial.SPAWNER.parseMaterial();
|
||||
if (!playerCanBuildDestroyBlock(event.getPlayer(), event.getBlock().getLocation(), !isSpawner ? "destroy" : "mine spawners", false)) {
|
||||
event.setCancelled(true);
|
||||
return;
|
||||
}
|
||||
if (!fme.hasFaction())
|
||||
return;
|
||||
if (block != null && isSpawner) {
|
||||
ItemStack item = new ItemStack(block.getType(), 1, (short) block.getData());
|
||||
if (at != null && at.isNormal()) {
|
||||
FPlayer fplayer = FPlayers.getInstance().getByPlayer(event.getPlayer());
|
||||
if (fplayer != null) {
|
||||
BlockState state = block.getState();
|
||||
if (state instanceof CreatureSpawner) {
|
||||
CreatureSpawner spawner = (CreatureSpawner) state;
|
||||
item.setDurability(spawner.getSpawnedType().getTypeId());
|
||||
}
|
||||
handleSpawnerUpdate(at, event.getPlayer(), item, LogTimer.TimerSubType.SPAWNER_BREAK);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (event.getBlock().getType() == XMaterial.SPAWNER.parseMaterial()) {
|
||||
if (!fme.isAdminBypassing()) {
|
||||
Access access = fme.getFaction().getAccess(fme, PermissableAction.SPAWNER);
|
||||
if (access != Access.ALLOW && fme.getRole() != Role.LEADER) {
|
||||
fme.msg(TL.GENERIC_FPERM_NOPERMISSION, "mine spawners");
|
||||
@EventHandler(priority = EventPriority.HIGHEST)
|
||||
public void FrameRemove(HangingBreakByEntityEvent event) {
|
||||
if (event.getRemover() == null) return;
|
||||
if ((event.getRemover() instanceof Player)) {
|
||||
if (event.getEntity().getType().equals(EntityType.ITEM_FRAME)) {
|
||||
Player p = (Player) event.getRemover();
|
||||
if (!playerCanBuildDestroyBlock(p, event.getEntity().getLocation(), "destroy", true)) {
|
||||
event.setCancelled(true);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -551,11 +541,9 @@ public class FactionsBlockListener implements Listener {
|
||||
if (event.getEntity() instanceof Player) {
|
||||
Player player = (Player) event.getEntity();
|
||||
if (!playerCanBuildDestroyBlock(player, event.getBlock().getLocation(), PermissableAction.DESTROY.name(), true)) {
|
||||
FPlayer me = FPlayers.getInstance().getById(player.getUniqueId().toString());
|
||||
FPlayer me = FPlayers.getInstance().getByPlayer(player);
|
||||
Faction otherFaction = Board.getInstance().getFactionAt(new FLocation(event.getBlock().getLocation()));
|
||||
Faction myFaction = me.getFaction();
|
||||
|
||||
me.msg("<b>You can't jump on farmland in the territory of " + otherFaction.getTag(myFaction));
|
||||
me.msg(TL.ACTION_DENIED_OTHER, otherFaction.getTag(), "trample crops");
|
||||
event.setCancelled(true);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -139,7 +139,6 @@ public class FactionsEntityListener implements Listener {
|
||||
// this should trigger if the attacker shootin the arrow is a mob
|
||||
return;
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
} else {
|
||||
@@ -226,25 +225,18 @@ public class FactionsEntityListener implements Listener {
|
||||
}
|
||||
|
||||
private void cancelFFly(Player player) {
|
||||
if (player == null) {
|
||||
return;
|
||||
}
|
||||
|
||||
if (player == null) return;
|
||||
FPlayer fPlayer = FPlayers.getInstance().getByPlayer(player);
|
||||
if (fPlayer.isFlying()) {
|
||||
fPlayer.setFFlying(false, true);
|
||||
}
|
||||
if (fPlayer.isFlying()) fPlayer.setFFlying(false, true);
|
||||
}
|
||||
|
||||
public void cancelFStuckTeleport(Player player) {
|
||||
if (player == null) {
|
||||
return;
|
||||
}
|
||||
if (player == null) return;
|
||||
|
||||
UUID uuid = player.getUniqueId();
|
||||
if (FactionsPlugin.getInstance().getStuckMap().containsKey(uuid)) {
|
||||
if (FactionsPlugin.getInstance().getStuckMap().containsKey(uuid))
|
||||
FPlayers.getInstance().getByPlayer(player).msg(TL.COMMAND_STUCK_CANCELLED);
|
||||
FactionsPlugin.getInstance().getStuckMap().remove(uuid);
|
||||
}
|
||||
}
|
||||
|
||||
@EventHandler(priority = EventPriority.NORMAL, ignoreCancelled = true)
|
||||
@@ -294,10 +286,9 @@ public class FactionsEntityListener implements Listener {
|
||||
private boolean checkExplosionForBlock(Entity boomer, Block block) {
|
||||
Faction faction = Board.getInstance().getFactionAt(new FLocation(block.getLocation()));
|
||||
|
||||
if (faction.noExplosionsInTerritory() || (faction.isPeaceful() && Conf.peacefulTerritoryDisableBoom)) {
|
||||
// faction is peaceful and has explosions set to disabled
|
||||
if (faction.noExplosionsInTerritory() || (faction.isPeaceful() && Conf.peacefulTerritoryDisableBoom))
|
||||
return false;
|
||||
}
|
||||
// faction is peaceful and has explosions set to disabled
|
||||
|
||||
boolean online = faction.hasPlayersOnline();
|
||||
|
||||
@@ -325,9 +316,8 @@ public class FactionsEntityListener implements Listener {
|
||||
@EventHandler(priority = EventPriority.NORMAL, ignoreCancelled = true)
|
||||
public void onEntityCombustByEntity(EntityCombustByEntityEvent event) {
|
||||
EntityDamageByEntityEvent sub = new EntityDamageByEntityEvent(event.getCombuster(), event.getEntity(), EntityDamageEvent.DamageCause.FIRE, 0d);
|
||||
if (!this.canDamagerHurtDamagee(sub, false)) {
|
||||
event.setCancelled(true);
|
||||
}
|
||||
if (!this.canDamagerHurtDamagee(sub, false)) event.setCancelled(true);
|
||||
|
||||
}
|
||||
|
||||
@EventHandler(priority = EventPriority.NORMAL, ignoreCancelled = true)
|
||||
@@ -340,14 +330,11 @@ public class FactionsEntityListener implements Listener {
|
||||
break;
|
||||
}
|
||||
}
|
||||
if (!badjuju) {
|
||||
return;
|
||||
}
|
||||
if (!badjuju) return;
|
||||
|
||||
ProjectileSource thrower = event.getPotion().getShooter();
|
||||
if (!(thrower instanceof Entity)) {
|
||||
return;
|
||||
}
|
||||
if (!(thrower instanceof Entity)) return;
|
||||
|
||||
|
||||
if (thrower instanceof Player) {
|
||||
Player player = (Player) thrower;
|
||||
@@ -361,16 +348,14 @@ public class FactionsEntityListener implements Listener {
|
||||
// scan through affected entities to make sure they're all valid targets
|
||||
for (LivingEntity target : event.getAffectedEntities()) {
|
||||
EntityDamageByEntityEvent sub = new EntityDamageByEntityEvent((Entity) thrower, target, EntityDamageEvent.DamageCause.CUSTOM, 0);
|
||||
if (!this.canDamagerHurtDamagee(sub, true)) {
|
||||
if (!this.canDamagerHurtDamagee(sub, true))
|
||||
event.setIntensity(target, 0.0); // affected entity list doesn't accept modification (so no iter.remove()), but this works
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public boolean isPlayerInSafeZone(Entity damagee) {
|
||||
if (!(damagee instanceof Player)) {
|
||||
return false;
|
||||
}
|
||||
if (!(damagee instanceof Player)) return false;
|
||||
|
||||
return Board.getInstance().getFactionAt(new FLocation(damagee.getLocation())).isSafeZone();
|
||||
}
|
||||
|
||||
@@ -382,15 +367,13 @@ public class FactionsEntityListener implements Listener {
|
||||
Entity damager = sub.getDamager();
|
||||
Entity damagee = sub.getEntity();
|
||||
|
||||
if (!(damagee instanceof Player)) {
|
||||
return true;
|
||||
}
|
||||
if (!(damagee instanceof Player)) return true;
|
||||
|
||||
|
||||
FPlayer defender = FPlayers.getInstance().getByPlayer((Player) damagee);
|
||||
|
||||
if (defender == null || defender.getPlayer() == null) {
|
||||
return true;
|
||||
}
|
||||
if (defender == null || defender.getPlayer() == null) return true;
|
||||
|
||||
|
||||
Location defenderLoc = defender.getPlayer().getLocation();
|
||||
Faction defLocFaction = Board.getInstance().getFactionAt(new FLocation(defenderLoc));
|
||||
@@ -399,17 +382,11 @@ public class FactionsEntityListener implements Listener {
|
||||
if (damager instanceof Projectile) {
|
||||
Projectile projectile = (Projectile) damager;
|
||||
|
||||
if (!(projectile.getShooter() instanceof Entity)) {
|
||||
return true;
|
||||
}
|
||||
|
||||
if (!(projectile.getShooter() instanceof Entity)) return true;
|
||||
damager = (Entity) projectile.getShooter();
|
||||
}
|
||||
|
||||
if (damager == damagee) // ender pearl usage and other self-inflicted damage
|
||||
{
|
||||
return true;
|
||||
}
|
||||
if (damager == damagee) return true; // ender pearl usage and other self-inflicted damage
|
||||
|
||||
// Players can not take attack damage in a SafeZone, or possibly peaceful territory
|
||||
if (defLocFaction.noPvPInTerritory()) {
|
||||
@@ -423,19 +400,16 @@ public class FactionsEntityListener implements Listener {
|
||||
return !defLocFaction.noMonstersInTerritory();
|
||||
}
|
||||
|
||||
if (!(damager instanceof Player)) {
|
||||
return true;
|
||||
}
|
||||
if (!(damager instanceof Player)) return true;
|
||||
|
||||
|
||||
FPlayer attacker = FPlayers.getInstance().getByPlayer((Player) damager);
|
||||
|
||||
if (attacker == null || attacker.getPlayer() == null) {
|
||||
return true;
|
||||
}
|
||||
if (attacker == null || attacker.getPlayer() == null) return true;
|
||||
|
||||
|
||||
if (Conf.playersWhoBypassAllProtection.contains(attacker.getName())) return true;
|
||||
|
||||
if (Conf.playersWhoBypassAllProtection.contains(attacker.getName())) {
|
||||
return true;
|
||||
}
|
||||
|
||||
if (attacker.hasLoginPvpDisabled()) {
|
||||
if (notify) {
|
||||
@@ -454,13 +428,11 @@ public class FactionsEntityListener implements Listener {
|
||||
return false;
|
||||
}
|
||||
|
||||
if (locFaction.isWarZone() && Conf.warZoneFriendlyFire) {
|
||||
return true;
|
||||
}
|
||||
if (locFaction.isWarZone() && Conf.warZoneFriendlyFire) return true;
|
||||
|
||||
|
||||
if (Conf.worldsIgnorePvP.contains(defenderLoc.getWorld().getName())) return true;
|
||||
|
||||
if (Conf.worldsIgnorePvP.contains(defenderLoc.getWorld().getName())) {
|
||||
return true;
|
||||
}
|
||||
|
||||
Faction defendFaction = defender.getFaction();
|
||||
Faction attackFaction = attacker.getFaction();
|
||||
@@ -505,9 +477,8 @@ public class FactionsEntityListener implements Listener {
|
||||
}
|
||||
|
||||
// Players without faction may be hurt anywhere
|
||||
if (!defender.hasFaction()) {
|
||||
return true;
|
||||
}
|
||||
if (!defender.hasFaction()) return true;
|
||||
|
||||
|
||||
// You can never hurt faction members or allies
|
||||
if (relation.isMember() || relation.isAlly() || relation.isTruce()) {
|
||||
@@ -546,9 +517,8 @@ public class FactionsEntityListener implements Listener {
|
||||
|
||||
@EventHandler(priority = EventPriority.NORMAL, ignoreCancelled = true)
|
||||
public void onCreatureSpawn(CreatureSpawnEvent event) {
|
||||
if (event.getLocation() == null) {
|
||||
return;
|
||||
}
|
||||
if (event.getLocation() == null) return;
|
||||
|
||||
|
||||
if (Conf.safeZoneNerfedCreatureTypes.contains(event.getEntityType()) && Board.getInstance().getFactionAt(new FLocation(event.getLocation())).noMonstersInTerritory()) {
|
||||
event.setCancelled(true);
|
||||
@@ -559,14 +529,10 @@ public class FactionsEntityListener implements Listener {
|
||||
public void onEntityTarget(EntityTargetEvent event) {
|
||||
// if there is a target
|
||||
Entity target = event.getTarget();
|
||||
if (target == null) {
|
||||
return;
|
||||
}
|
||||
if (target == null) return;
|
||||
|
||||
// We are interested in blocking targeting for certain mobs:
|
||||
if (!Conf.safeZoneNerfedCreatureTypes.contains(MiscUtil.creatureTypeFromEntity(event.getEntity()))) {
|
||||
return;
|
||||
}
|
||||
if (!Conf.safeZoneNerfedCreatureTypes.contains(MiscUtil.creatureTypeFromEntity(event.getEntity()))) return;
|
||||
|
||||
// in case the target is in a safe zone.
|
||||
if (Board.getInstance().getFactionAt(new FLocation(target.getLocation())).noMonstersInTerritory()) {
|
||||
@@ -635,9 +601,8 @@ public class FactionsEntityListener implements Listener {
|
||||
Entity entity = event.getEntity();
|
||||
|
||||
// for now, only interested in Enderman and Wither boss tomfoolery
|
||||
if (!(entity instanceof Enderman) && !(entity instanceof Wither)) {
|
||||
return;
|
||||
}
|
||||
if (!(entity instanceof Enderman) && !(entity instanceof Wither)) return;
|
||||
|
||||
|
||||
Location loc = event.getBlock().getLocation();
|
||||
|
||||
@@ -659,9 +624,9 @@ public class FactionsEntityListener implements Listener {
|
||||
|
||||
@EventHandler
|
||||
public void onTravel(PlayerPortalEvent event) {
|
||||
if (!FactionsPlugin.getInstance().getConfig().getBoolean("portals.limit", false)) {
|
||||
if (!FactionsPlugin.getInstance().getConfig().getBoolean("portals.limit", false))
|
||||
return; // Don't do anything if they don't want us to.
|
||||
}
|
||||
|
||||
|
||||
TravelAgent agent = event.getPortalTravelAgent();
|
||||
|
||||
@@ -738,30 +703,27 @@ public class FactionsEntityListener implements Listener {
|
||||
}
|
||||
|
||||
private boolean stopEndermanBlockManipulation(Location loc) {
|
||||
if (loc == null) {
|
||||
return false;
|
||||
}
|
||||
if (loc == null) return false;
|
||||
|
||||
// quick check to see if all Enderman deny options are enabled; if so, no need to check location
|
||||
if (Conf.wildernessDenyEndermanBlocks &&
|
||||
Conf.territoryDenyEndermanBlocks &&
|
||||
Conf.territoryDenyEndermanBlocksWhenOffline &&
|
||||
Conf.safeZoneDenyEndermanBlocks &&
|
||||
Conf.warZoneDenyEndermanBlocks) {
|
||||
return true;
|
||||
}
|
||||
Conf.warZoneDenyEndermanBlocks) return true;
|
||||
|
||||
|
||||
FLocation fLoc = new FLocation(loc);
|
||||
Faction claimFaction = Board.getInstance().getFactionAt(fLoc);
|
||||
|
||||
if (claimFaction.isWilderness()) {
|
||||
if (claimFaction.isWilderness())
|
||||
return Conf.wildernessDenyEndermanBlocks;
|
||||
} else if (claimFaction.isNormal()) {
|
||||
else if (claimFaction.isNormal())
|
||||
return claimFaction.hasPlayersOnline() ? Conf.territoryDenyEndermanBlocks : Conf.territoryDenyEndermanBlocksWhenOffline;
|
||||
} else if (claimFaction.isSafeZone()) {
|
||||
else if (claimFaction.isSafeZone())
|
||||
return Conf.safeZoneDenyEndermanBlocks;
|
||||
} else if (claimFaction.isWarZone()) {
|
||||
else if (claimFaction.isWarZone())
|
||||
return Conf.warZoneDenyEndermanBlocks;
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
@@ -18,9 +18,11 @@ import com.massivecraft.factions.struct.Role;
|
||||
import com.massivecraft.factions.util.FactionGUI;
|
||||
import com.massivecraft.factions.util.VisualizeUtil;
|
||||
import com.massivecraft.factions.util.XMaterial;
|
||||
import com.massivecraft.factions.zcore.faudit.FLogType;
|
||||
import com.massivecraft.factions.zcore.fperms.Access;
|
||||
import com.massivecraft.factions.zcore.fperms.PermissableAction;
|
||||
import com.massivecraft.factions.zcore.persist.MemoryFPlayer;
|
||||
import com.massivecraft.factions.zcore.util.CC;
|
||||
import com.massivecraft.factions.zcore.util.TL;
|
||||
import com.massivecraft.factions.zcore.util.TagUtil;
|
||||
import com.massivecraft.factions.zcore.util.TextUtil;
|
||||
@@ -39,6 +41,7 @@ import org.bukkit.event.inventory.InventoryClickEvent;
|
||||
import org.bukkit.event.inventory.InventoryCloseEvent;
|
||||
import org.bukkit.event.inventory.InventoryDragEvent;
|
||||
import org.bukkit.event.player.*;
|
||||
import org.bukkit.scheduler.BukkitTask;
|
||||
|
||||
import java.util.*;
|
||||
import java.util.logging.Level;
|
||||
@@ -50,16 +53,11 @@ public class FactionsPlayerListener implements Listener {
|
||||
public static Set<FLocation> corners;
|
||||
// Holds the next time a player can have a map shown.
|
||||
private HashMap<UUID, Long> showTimes = new HashMap<>();
|
||||
// for handling people who repeatedly spam attempts to open a door (or similar) in another faction's territory
|
||||
private Map<String, InteractAttemptSpam> interactSpammers = new HashMap<>();
|
||||
|
||||
public FactionsPlayerListener() {
|
||||
for (Player player : FactionsPlugin.getInstance().getServer().getOnlinePlayers()) {
|
||||
initPlayer(player);
|
||||
}
|
||||
if (!FactionsPlugin.getInstance().mc17) {
|
||||
loadCorners();
|
||||
}
|
||||
for (Player player : FactionsPlugin.getInstance().getServer().getOnlinePlayers()) initPlayer(player);
|
||||
if (positionTask == null) startPositionCheck();
|
||||
if (!FactionsPlugin.getInstance().mc17) loadCorners();
|
||||
}
|
||||
|
||||
public static void loadCorners() {
|
||||
@@ -295,25 +293,23 @@ public class FactionsPlayerListener implements Listener {
|
||||
}
|
||||
|
||||
private static boolean CheckPlayerAccess(Player player, FPlayer me, FLocation loc, Faction factionToCheck, Access access, PermissableAction action, boolean pain) {
|
||||
boolean doPain = pain && Conf.handleExploitInteractionSpam;
|
||||
if (access != null && access != Access.UNDEFINED) {
|
||||
// TODO: Update this once new access values are added other than just allow / deny.
|
||||
boolean doPain = pain || Conf.handleExploitInteractionSpam; // Painbuild should take priority. But we want to use exploit interaction as well.
|
||||
if (access != null) {
|
||||
boolean landOwned = (factionToCheck.doesLocationHaveOwnersSet(loc) && !factionToCheck.getOwnerList(loc).isEmpty());
|
||||
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("<b>You can't do that in this territory, it is owned by: " + factionToCheck.getOwnerListString(loc));
|
||||
if (doPain) {
|
||||
player.damage(Conf.actionDeniedPainAmount);
|
||||
}
|
||||
me.msg(TL.ACTIONS_OWNEDTERRITORYDENY, factionToCheck.getOwnerListString(loc));
|
||||
if (doPain) player.damage(Conf.actionDeniedPainAmount);
|
||||
return false;
|
||||
} else if (!landOwned && access == Access.ALLOW) {
|
||||
return true;
|
||||
} else {
|
||||
me.msg("You cannot " + action + " in the territory of " + factionToCheck.getTag(me.getFaction()));
|
||||
me.msg(TL.PLAYER_USE_TERRITORY, action, factionToCheck.getTag(me.getFaction()));
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
// Approves any permission check if the player in question is a leader AND owns the faction.
|
||||
if (me.getRole().equals(Role.LEADER) && me.getFaction().equals(factionToCheck)) return true;
|
||||
if (factionToCheck != null) {
|
||||
@@ -329,20 +325,16 @@ public class FactionsPlayerListener implements Listener {
|
||||
return GetPermissionFromUsableBlock(block.getType());
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// This will try to resolve a permission action based on the item material, if it's not usable, will return null
|
||||
/// <summary>
|
||||
private static PermissableAction GetPermissionFromUsableBlock(Material material) {
|
||||
// Check for doors that might have diff material name in old version.
|
||||
if (material.name().contains("DOOR") || material.name().contains("FENCE_GATE"))
|
||||
return PermissableAction.DOOR;
|
||||
if (material.name().toUpperCase().contains("BUTTON") || material.name().toUpperCase().contains("PRESSURE"))
|
||||
if (material.name().toUpperCase().contains("BUTTON") || material.name().toUpperCase().contains("PRESSURE") || material.name().contains("DIODE") || material.name().contains("COMPARATOR"))
|
||||
return PermissableAction.BUTTON;
|
||||
if (FactionsPlugin.getInstance().mc113) {
|
||||
if (FactionsPlugin.instance.mc113 || FactionsPlugin.instance.mc114) {
|
||||
switch (material) {
|
||||
case LEVER:
|
||||
return PermissableAction.LEVER;
|
||||
|
||||
case ACACIA_BUTTON:
|
||||
case BIRCH_BUTTON:
|
||||
case DARK_OAK_BUTTON:
|
||||
@@ -350,6 +342,8 @@ public class FactionsPlayerListener implements Listener {
|
||||
case OAK_BUTTON:
|
||||
case SPRUCE_BUTTON:
|
||||
case STONE_BUTTON:
|
||||
case COMPARATOR:
|
||||
case REPEATER:
|
||||
return PermissableAction.BUTTON;
|
||||
|
||||
case ACACIA_DOOR:
|
||||
@@ -424,11 +418,10 @@ public class FactionsPlayerListener implements Listener {
|
||||
case IRON_DOOR:
|
||||
case JUNGLE_DOOR:
|
||||
case SPRUCE_DOOR:
|
||||
|
||||
case ACACIA_FENCE_GATE:
|
||||
case BIRCH_FENCE_GATE:
|
||||
case DARK_OAK_FENCE_GATE:
|
||||
case OAK_FENCE_GATE:
|
||||
case DARK_OAK_FENCE_GATE:
|
||||
case JUNGLE_FENCE_GATE:
|
||||
case SPRUCE_FENCE_GATE:
|
||||
return PermissableAction.DOOR;
|
||||
@@ -469,41 +462,34 @@ public class FactionsPlayerListener implements Listener {
|
||||
|
||||
me.login(); // set kills / deaths
|
||||
|
||||
// Check for Faction announcements. Let's delay this so they actually see it.
|
||||
Bukkit.getScheduler().runTaskLater(FactionsPlugin.getInstance(), () -> {
|
||||
if (me.isOnline()) {
|
||||
me.getFaction().sendUnreadAnnouncements(me);
|
||||
}
|
||||
}, 33L); // Don't ask me why.
|
||||
Bukkit.getScheduler().runTaskLater(FactionsPlugin.instance, () -> {
|
||||
if (me.isOnline()) me.getFaction().sendUnreadAnnouncements(me);
|
||||
}, 33L);
|
||||
|
||||
if (FactionsPlugin.getInstance().getConfig().getBoolean("scoreboard.default-enabled", false)) {
|
||||
if (FactionsPlugin.instance.getConfig().getBoolean("scoreboard.default-enabled", false)) {
|
||||
FScoreboard.init(me);
|
||||
FScoreboard.get(me).setDefaultSidebar(new FDefaultSidebar(), FactionsPlugin.getInstance().getConfig().getInt("scoreboard.default-update-interval", 20));
|
||||
FScoreboard.get(me).setDefaultSidebar(new FDefaultSidebar(), FactionsPlugin.instance.getConfig().getInt("scoreboard.default-update-interval", 20));
|
||||
FScoreboard.get(me).setSidebarVisibility(me.showScoreboard());
|
||||
}
|
||||
|
||||
Faction myFaction = me.getFaction();
|
||||
if (!myFaction.isWilderness()) {
|
||||
for (FPlayer other : myFaction.getFPlayersWhereOnline(true)) {
|
||||
if (other != me && other.isMonitoringJoins()) {
|
||||
other.msg(TL.FACTION_LOGIN, me.getName());
|
||||
}
|
||||
if (other != me && other.isMonitoringJoins()) other.msg(TL.FACTION_LOGIN, me.getName());
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
fallMap.put(me.getPlayer(), false);
|
||||
Bukkit.getScheduler().scheduleSyncDelayedTask(FactionsPlugin.getInstance(), () -> fallMap.remove(me.getPlayer()), 180L);
|
||||
|
||||
Bukkit.getScheduler().scheduleSyncDelayedTask(FactionsPlugin.instance, () -> fallMap.remove(me.getPlayer()), 180L);
|
||||
|
||||
if (me.isSpyingChat() && !player.hasPermission(Permission.CHATSPY.node)) {
|
||||
me.setSpyingChat(false);
|
||||
FactionsPlugin.getInstance().log(Level.INFO, "Found %s spying chat without permission on login. Disabled their chat spying.", player.getName());
|
||||
FactionsPlugin.instance.log(Level.INFO, "Found %s spying chat without permission on login. Disabled their chat spying.", player.getName());
|
||||
}
|
||||
|
||||
if (me.isAdminBypassing() && !player.hasPermission(Permission.BYPASS.node)) {
|
||||
me.setIsAdminBypassing(false);
|
||||
FactionsPlugin.getInstance().log(Level.INFO, "Found %s on admin Bypass without permission on login. Disabled it for them.", player.getName());
|
||||
FactionsPlugin.instance.log(Level.INFO, "Found %s on admin Bypass without permission on login. Disabled it for them.", player.getName());
|
||||
}
|
||||
|
||||
|
||||
@@ -537,23 +523,19 @@ public class FactionsPlayerListener implements Listener {
|
||||
me.logout(); // cache kills / deaths
|
||||
|
||||
// if player is waiting for fstuck teleport but leaves, remove
|
||||
if (FactionsPlugin.getInstance().getStuckMap().containsKey(me.getPlayer().getUniqueId())) {
|
||||
if (FactionsPlugin.instance.getStuckMap().containsKey(me.getPlayer().getUniqueId())) {
|
||||
FPlayers.getInstance().getByPlayer(me.getPlayer()).msg(TL.COMMAND_STUCK_CANCELLED);
|
||||
FactionsPlugin.getInstance().getStuckMap().remove(me.getPlayer().getUniqueId());
|
||||
FactionsPlugin.getInstance().getTimers().remove(me.getPlayer().getUniqueId());
|
||||
FactionsPlugin.instance.getStuckMap().remove(me.getPlayer().getUniqueId());
|
||||
FactionsPlugin.instance.getTimers().remove(me.getPlayer().getUniqueId());
|
||||
}
|
||||
|
||||
Faction myFaction = me.getFaction();
|
||||
if (!myFaction.isWilderness()) {
|
||||
myFaction.memberLoggedOff();
|
||||
}
|
||||
if (!myFaction.isWilderness()) myFaction.memberLoggedOff();
|
||||
|
||||
if (!myFaction.isWilderness()) {
|
||||
for (FPlayer player : myFaction.getFPlayersWhereOnline(true)) {
|
||||
if (player != me && player.isMonitoringJoins()) {
|
||||
player.msg(TL.FACTION_LOGOUT, me.getName());
|
||||
}
|
||||
}
|
||||
for (FPlayer player : myFaction.getFPlayersWhereOnline(true))
|
||||
if (player != me && player.isMonitoringJoins()) player.msg(TL.FACTION_LOGOUT, me.getName());
|
||||
|
||||
}
|
||||
|
||||
CmdSeeChunk.seeChunkMap.remove(event.getPlayer().getName());
|
||||
@@ -570,23 +552,22 @@ public class FactionsPlayerListener implements Listener {
|
||||
.replace("{chunks}", faction.getAllClaims().size() + "")
|
||||
.replace("{power}", faction.getPower() + "")
|
||||
.replace("{leader}", faction.getFPlayerAdmin() + "");
|
||||
|
||||
return string;
|
||||
}
|
||||
|
||||
public void enableFly(FPlayer me) {
|
||||
if (!me.getPlayer().hasPermission(Permission.FLY.node)) return;
|
||||
public void checkCanFly(FPlayer me) {
|
||||
if (me.isFlying() && (!me.canFlyAtLocation() || me.checkIfNearbyEnemies())) {
|
||||
me.setFFlying(false, false);
|
||||
me.msg(TL.COMMAND_FLY_NO_ACCESS, Board.getInstance().getFactionAt(me.getLastStoodAt()).getTag());
|
||||
return;
|
||||
}
|
||||
if (me.isFlying() || !FactionsPlugin.instance.getConfig().getBoolean("ffly.AutoEnable"))
|
||||
return;
|
||||
me.setFFlying(true, false);
|
||||
|
||||
if (FactionsPlugin.getInstance().getConfig().getBoolean("ffly.AutoEnable")) {
|
||||
me.setFlying(true);
|
||||
CmdFly.flyMap.put(me.getName(), true);
|
||||
if (CmdFly.particleTask == null)
|
||||
if (FactionsPlugin.getInstance().getConfig().getBoolean("ffly.Particles.Enabled"))
|
||||
CmdFly.startParticles();
|
||||
}
|
||||
if (CmdFly.flyTask == null) CmdFly.startFlyCheck();
|
||||
}
|
||||
CmdFly.flyMap.put(me.getName(), true);
|
||||
if (CmdFly.particleTask == null)
|
||||
CmdFly.startParticles();
|
||||
}
|
||||
|
||||
|
||||
//inspect
|
||||
@@ -622,8 +603,8 @@ public class FactionsPlayerListener implements Listener {
|
||||
.replace("{y}", e.getClickedBlock().getY() + "")
|
||||
.replace("{z}", e.getClickedBlock().getZ() + ""));
|
||||
String rowFormat = TL.COMMAND_INSPECT_ROW.toString();
|
||||
for (int i = 0; i < info.size(); i++) {
|
||||
CoreProtectAPI.ParseResult row = coAPI.parseResult(info.get(i));
|
||||
for (String[] strings : info) {
|
||||
CoreProtectAPI.ParseResult row = coAPI.parseResult(strings);
|
||||
player.sendMessage(rowFormat
|
||||
.replace("{time}", convertTime(row.getTime()))
|
||||
.replace("{action}", row.getActionString())
|
||||
@@ -639,11 +620,9 @@ public class FactionsPlayerListener implements Listener {
|
||||
Player player = e.getPlayer();
|
||||
if (player.getItemInHand().getType() == Material.ENDER_PEARL) {
|
||||
FPlayer fPlayer = FPlayers.getInstance().getByPlayer(player);
|
||||
if (fPlayer.isFlying()) {
|
||||
if (Conf.noEnderpearlsInFly) {
|
||||
fPlayer.msg(TL.COMMAND_FLY_NO_EPEARL);
|
||||
e.setCancelled(true);
|
||||
}
|
||||
if (fPlayer.isFlying() && Conf.noEnderpearlsInFly) {
|
||||
fPlayer.msg(TL.COMMAND_FLY_NO_EPEARL);
|
||||
e.setCancelled(true);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -653,16 +632,59 @@ public class FactionsPlayerListener implements Listener {
|
||||
return (result.length() == 3 ? result + "0" : result) + "/hrs ago";
|
||||
}
|
||||
|
||||
@EventHandler(priority = EventPriority.MONITOR, ignoreCancelled = true)
|
||||
public void onPlayerMove(PlayerMoveEvent event) {
|
||||
Player player = event.getPlayer();
|
||||
public static BukkitTask positionTask = null;
|
||||
public 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())) {
|
||||
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);
|
||||
}
|
||||
|
||||
public void refreshPosition(Player player, Location oldLocation, Location newLocation) {
|
||||
FPlayer me = FPlayers.getInstance().getByPlayer(player);
|
||||
|
||||
// clear visualization
|
||||
if (event.getFrom().getBlockX() != event.getTo().getBlockX()
|
||||
|| event.getFrom().getBlockY() != event.getTo().getBlockY()
|
||||
|| event.getFrom().getBlockZ() != event.getTo().getBlockZ()) {
|
||||
VisualizeUtil.clear(event.getPlayer());
|
||||
if (oldLocation.getBlockX() != newLocation.getBlockX()
|
||||
|| oldLocation.getBlockY() != newLocation.getBlockY()
|
||||
|| oldLocation.getBlockZ() != newLocation.getBlockZ()) {
|
||||
VisualizeUtil.clear(player);
|
||||
if (me.isWarmingUp()) {
|
||||
me.clearWarmup();
|
||||
me.msg(TL.WARMUPS_CANCELLED);
|
||||
@@ -670,23 +692,20 @@ public class FactionsPlayerListener implements Listener {
|
||||
}
|
||||
|
||||
// quick check to make sure player is moving between chunks; good performance boost
|
||||
if (event.getFrom().getBlockX() >> 4 == event.getTo().getBlockX() >> 4
|
||||
&& event.getFrom().getBlockZ() >> 4 == event.getTo().getBlockZ() >> 4
|
||||
&& event.getFrom().getWorld() == event.getTo().getWorld()) {
|
||||
if (oldLocation.getBlockX() >> 4 == newLocation.getBlockX() >> 4
|
||||
&& oldLocation.getBlockZ() >> 4 == newLocation.getBlockZ() >> 4
|
||||
&& oldLocation.getWorld() == newLocation.getWorld()) {
|
||||
return;
|
||||
}
|
||||
|
||||
|
||||
// Did we change coord?
|
||||
FLocation from = me.getLastStoodAt();
|
||||
FLocation to = new FLocation(event.getTo());
|
||||
FLocation to = new FLocation(player.getLocation());
|
||||
|
||||
if (from.equals(to)) {
|
||||
return;
|
||||
}
|
||||
if (from.equals(to)) return;
|
||||
|
||||
// Yes we did change coord (:
|
||||
|
||||
me.setLastStoodAt(to);
|
||||
|
||||
// Did we change "host"(faction)?
|
||||
@@ -696,43 +715,33 @@ public class FactionsPlayerListener implements Listener {
|
||||
|
||||
|
||||
if (changedFaction) {
|
||||
Bukkit.getServer().getPluginManager().callEvent(new FPlayerEnteredFactionEvent(factionTo, factionFrom, me));
|
||||
if (FactionsPlugin.getInstance().getConfig().getBoolean("Title.Show-Title")) {
|
||||
String title = FactionsPlugin.getInstance().getConfig().getString("Title.Format.Title");
|
||||
Bukkit.getScheduler().runTask(FactionsPlugin.instance, () -> Bukkit.getServer().getPluginManager().callEvent(new FPlayerEnteredFactionEvent(factionTo, factionFrom, me)));
|
||||
if (FactionsPlugin.instance.getConfig().getBoolean("Title.Show-Title") && me.hasTitlesEnabled()) {
|
||||
String title = FactionsPlugin.instance.getConfig().getString("Title.Format.Title");
|
||||
title = title.replace("{Faction}", factionTo.getColorTo(me) + factionTo.getTag());
|
||||
title = parseAllPlaceholders(title, factionTo, player);
|
||||
String subTitle = FactionsPlugin.getInstance().getConfig().getString("Title.Format.Subtitle").replace("{Description}", factionTo.getDescription()).replace("{Faction}", factionTo.getColorTo(me) + factionTo.getTag());
|
||||
String subTitle = FactionsPlugin.instance.getConfig().getString("Title.Format.Subtitle").replace("{Description}", factionTo.getDescription()).replace("{Faction}", factionTo.getColorTo(me) + factionTo.getTag());
|
||||
subTitle = parseAllPlaceholders(subTitle, factionTo, player);
|
||||
if (!FactionsPlugin.getInstance().mc17) {
|
||||
if (!FactionsPlugin.getInstance().mc18) {
|
||||
me.getPlayer().sendTitle(FactionsPlugin.getInstance().color(title), FactionsPlugin.getInstance().color(subTitle), FactionsPlugin.getInstance().getConfig().getInt("Title.Options.FadeInTime"),
|
||||
FactionsPlugin.getInstance().getConfig().getInt("Title.Options.ShowTime"),
|
||||
FactionsPlugin.getInstance().getConfig().getInt("Title.Options.FadeOutTime"));
|
||||
} else {
|
||||
me.getPlayer().sendTitle(FactionsPlugin.getInstance().color(title), FactionsPlugin.getInstance().color(subTitle));
|
||||
}
|
||||
final String finalTitle = title;
|
||||
final String finalsubTitle = subTitle;
|
||||
if (!FactionsPlugin.instance.mc17) {
|
||||
Bukkit.getScheduler().runTaskLater(FactionsPlugin.instance, () -> {
|
||||
if (!FactionsPlugin.instance.mc18) {
|
||||
me.getPlayer().sendTitle(FactionsPlugin.instance.color(finalTitle), FactionsPlugin.instance.color(finalsubTitle), FactionsPlugin.instance.getConfig().getInt("Title.Options.FadeInTime"),
|
||||
FactionsPlugin.instance.getConfig().getInt("Title.Options.ShowTime"),
|
||||
FactionsPlugin.instance.getConfig().getInt("Title.Options.FadeOutTime"));
|
||||
} else {
|
||||
me.getPlayer().sendTitle(FactionsPlugin.instance.color(finalTitle), FactionsPlugin.instance.color(finalsubTitle));
|
||||
}
|
||||
}, 5);
|
||||
}
|
||||
}
|
||||
this.checkCanFly(me);
|
||||
|
||||
// enable fly :)
|
||||
if (FactionsPlugin.getInstance().factionsFlight && me.hasFaction() && !me.isFlying()) {
|
||||
if (factionTo == me.getFaction()) enableFly(me);
|
||||
// bypass checks
|
||||
Relation relationTo = factionTo.getRelationTo(me);
|
||||
if ((factionTo.isWilderness() && me.canflyinWilderness()) ||
|
||||
(factionTo.isWarZone() && me.canflyinWarzone()) ||
|
||||
(factionTo.isSafeZone() && me.canflyinSafezone()) ||
|
||||
(relationTo == Relation.ENEMY && me.canflyinEnemy()) ||
|
||||
(relationTo == Relation.ALLY && me.canflyinAlly()) ||
|
||||
(relationTo == Relation.TRUCE && me.canflyinTruce()) ||
|
||||
(relationTo == Relation.NEUTRAL && me.canflyinNeutral() && !isSystemFaction(factionTo))) {
|
||||
Bukkit.getScheduler().runTask(FactionsPlugin.instance, () -> enableFly(me));
|
||||
}
|
||||
}
|
||||
if (me.getAutoClaimFor() != null) {
|
||||
me.attemptClaim(me.getAutoClaimFor(), event.getTo(), true);
|
||||
if (Conf.disableFlightOnFactionClaimChange && event.getPlayer().getGameMode() != GameMode.CREATIVE)
|
||||
CmdFly.disableFlight(me);
|
||||
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);
|
||||
} else if (me.isAutoSafeClaimEnabled()) {
|
||||
if (!Permission.MANAGE_SAFE_ZONE.has(player)) {
|
||||
me.setIsAutoSafeClaimEnabled(false);
|
||||
@@ -754,27 +763,26 @@ public class FactionsPlayerListener implements Listener {
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
if (me.isMapAutoUpdating()) {
|
||||
if (showTimes.containsKey(player.getUniqueId()) && (showTimes.get(player.getUniqueId()) > System.currentTimeMillis())) {
|
||||
if (FactionsPlugin.getInstance().getConfig().getBoolean("findfactionsexploit.log", false)) {
|
||||
FactionsPlugin.getInstance().log(Level.WARNING, "%s tried to show a faction map too soon and triggered exploit blocker.", player.getName());
|
||||
if (FactionsPlugin.instance.getConfig().getBoolean("findfactionsexploit.log", false)) {
|
||||
FactionsPlugin.instance.log(Level.WARNING, "%s tried to show a faction map too soon and triggered exploit blocker.", player.getName());
|
||||
}
|
||||
} else {
|
||||
me.sendFancyMessage(Board.getInstance().getMap(me, to, player.getLocation().getYaw()));
|
||||
showTimes.put(player.getUniqueId(), System.currentTimeMillis() + FactionsPlugin.getInstance().getConfig().getLong("findfactionsexploit.cooldown", 2000));
|
||||
showTimes.put(player.getUniqueId(), System.currentTimeMillis() + FactionsPlugin.instance.getConfig().getLong("findfactionsexploit.cooldown", 2000));
|
||||
}
|
||||
} else {
|
||||
Faction myFaction = me.getFaction();
|
||||
String ownersTo = myFaction.getOwnerListString(to);
|
||||
if (changedFaction) {
|
||||
me.sendFactionHereMessage(factionFrom);
|
||||
if (Conf.ownedAreasEnabled && Conf.ownedMessageOnBorder && myFaction == factionTo && !ownersTo.isEmpty() && me.hasNotificationsEnabled()) {
|
||||
if (Conf.sendFactionChangeMessage) me.sendFactionHereMessage(factionFrom);
|
||||
if (Conf.ownedAreasEnabled && Conf.ownedMessageOnBorder && myFaction == factionTo && !ownersTo.isEmpty()) {
|
||||
me.sendMessage(TL.GENERIC_OWNERS.format(ownersTo));
|
||||
}
|
||||
} else if (Conf.ownedAreasEnabled && Conf.ownedMessageInsideTerritory && myFaction == factionTo && !myFaction.isWilderness()) {
|
||||
String ownersFrom = myFaction.getOwnerListString(from);
|
||||
if (Conf.ownedMessageByChunk || !ownersFrom.equals(ownersTo) && me.hasNotificationsEnabled()) {
|
||||
if (Conf.ownedMessageByChunk || !ownersFrom.equals(ownersTo)) {
|
||||
if (!ownersTo.isEmpty()) {
|
||||
me.sendMessage(TL.GENERIC_OWNERS.format(ownersTo));
|
||||
} else if (!TL.GENERIC_PUBLICLAND.toString().isEmpty()) {
|
||||
@@ -792,15 +800,16 @@ public class FactionsPlayerListener implements Listener {
|
||||
if (fme.isInFactionsChest()) fme.setInFactionsChest(false);
|
||||
}
|
||||
|
||||
@EventHandler(priority = EventPriority.NORMAL, ignoreCancelled = true)
|
||||
@EventHandler
|
||||
public void onPlayerInteract(PlayerInteractEvent event) {
|
||||
// only need to check right-clicks and physical as of MC 1.4+; good performance boost
|
||||
if (event.getAction().equals(Action.LEFT_CLICK_BLOCK) || event.getAction().equals(Action.LEFT_CLICK_AIR))
|
||||
if (event.getAction().equals(Action.LEFT_CLICK_AIR) || event.getAction().equals(Action.LEFT_CLICK_BLOCK))
|
||||
return;
|
||||
|
||||
Block block = event.getClickedBlock();
|
||||
Player player = event.getPlayer();
|
||||
// Check if the material is bypassing protection
|
||||
if (block == null) return; // clicked in air, apparently
|
||||
|
||||
if (block == null) return;
|
||||
|
||||
|
||||
Material type;
|
||||
if (event.getItem() != null) {
|
||||
@@ -810,26 +819,31 @@ public class FactionsPlayerListener implements Listener {
|
||||
type = null;
|
||||
}
|
||||
|
||||
if (Conf.territoryBypassProtectedMaterials.contains(block.getType())) return;
|
||||
// Creeper Egg Bypass.
|
||||
if (Conf.allowCreeperEggingChests && block.getType() == Material.CHEST && type == XMaterial.CREEPER_SPAWN_EGG.parseMaterial() && event.getPlayer().isSneaking()) {
|
||||
return;
|
||||
}
|
||||
|
||||
if (GetPermissionFromUsableBlock(event.getClickedBlock().getType()) != null) {
|
||||
|
||||
// territoryBypasssProtectedMaterials totally bypass the protection system
|
||||
if (Conf.territoryBypasssProtectedMaterials.contains(block.getType())) return;
|
||||
// Do type null checks so if XMaterial has a parsing issue and fills null as a value it will not bypass.
|
||||
// territoryCancelAndAllowItemUseMaterial bypass the protection system but only if they're not clicking on territoryDenySwitchMaterials
|
||||
// if they're clicking on territoryDenySwitchMaterials, let the protection system handle the permissions
|
||||
if (type != null && !Conf.territoryDenySwitchMaterials.contains(block.getType())) {
|
||||
if (Conf.territoryCancelAndAllowItemUseMaterial.contains(type)) {
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
if (GetPermissionFromUsableBlock(block.getType()) != null) {
|
||||
if (!canPlayerUseBlock(player, block, false)) {
|
||||
event.setCancelled(true);
|
||||
event.setUseInteractedBlock(Event.Result.DENY);
|
||||
return;
|
||||
}
|
||||
}
|
||||
if (event.getPlayer().getItemInHand() != null) {
|
||||
Material handItem = event.getPlayer().getItemInHand().getType();
|
||||
if (handItem.isEdible()
|
||||
|| handItem.equals(XMaterial.POTION.parseMaterial())
|
||||
|| handItem.equals(XMaterial.LINGERING_POTION.parseMaterial())
|
||||
|| handItem.equals(XMaterial.SPLASH_POTION.parseMaterial())) {
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
if (event.getItem() == null) return;
|
||||
if (type != null && !playerCanUseItemHere(player, block.getLocation(), event.getItem().getType(), false, PermissableAction.ITEM)) {
|
||||
event.setCancelled(true);
|
||||
event.setUseInteractedBlock(Event.Result.DENY);
|
||||
@@ -837,7 +851,7 @@ public class FactionsPlayerListener implements Listener {
|
||||
}
|
||||
|
||||
@EventHandler
|
||||
public void onInentorySee(InventoryClickEvent e) {
|
||||
public void onInventorySee(InventoryClickEvent e) {
|
||||
if (e.getCurrentItem() == null)
|
||||
return;
|
||||
|
||||
@@ -850,7 +864,6 @@ public class FactionsPlayerListener implements Listener {
|
||||
@EventHandler
|
||||
public void onPlayerBoneMeal(PlayerInteractEvent event) {
|
||||
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)) {
|
||||
@@ -935,9 +948,7 @@ public class FactionsPlayerListener implements Listener {
|
||||
|
||||
@EventHandler(priority = EventPriority.HIGH)
|
||||
public void onPlayerInteractGUI(InventoryClickEvent event) {
|
||||
if (event.getClickedInventory() == null) {
|
||||
return;
|
||||
}
|
||||
if (event.getClickedInventory() == null) return;
|
||||
if (event.getClickedInventory().getHolder() instanceof FactionGUI) {
|
||||
event.setCancelled(true);
|
||||
((FactionGUI) event.getClickedInventory().getHolder()).onClick(event.getRawSlot(), event.getClick());
|
||||
@@ -946,23 +957,18 @@ public class FactionsPlayerListener implements Listener {
|
||||
|
||||
@EventHandler(priority = EventPriority.HIGH)
|
||||
public void onPlayerMoveGUI(InventoryDragEvent event) {
|
||||
if (event.getInventory().getHolder() instanceof FactionGUI) {
|
||||
event.setCancelled(true);
|
||||
}
|
||||
if (event.getInventory().getHolder() instanceof FactionGUI) event.setCancelled(true);
|
||||
}
|
||||
|
||||
@EventHandler(priority = EventPriority.NORMAL, ignoreCancelled = true)
|
||||
public void onPlayerKick(PlayerKickEvent event) {
|
||||
FPlayer badGuy = FPlayers.getInstance().getByPlayer(event.getPlayer());
|
||||
if (badGuy == null) {
|
||||
return;
|
||||
}
|
||||
if (badGuy == null) return;
|
||||
|
||||
// if player was banned (not just kicked), get rid of their stored info
|
||||
if (Conf.removePlayerDataWhenBanned && event.getReason().equals("Banned by admin.")) {
|
||||
if (badGuy.getRole() == Role.LEADER) {
|
||||
badGuy.getFaction().promoteNewLeader();
|
||||
}
|
||||
if (badGuy.getRole() == Role.LEADER) badGuy.getFaction().promoteNewLeader();
|
||||
|
||||
|
||||
badGuy.leave(false);
|
||||
badGuy.remove();
|
||||
@@ -980,7 +986,7 @@ public class FactionsPlayerListener implements Listener {
|
||||
}
|
||||
|
||||
public Set<FLocation> getCorners() {
|
||||
return this.corners;
|
||||
return corners;
|
||||
}
|
||||
|
||||
@EventHandler
|
||||
@@ -1020,23 +1026,6 @@ public class FactionsPlayerListener implements Listener {
|
||||
@EventHandler
|
||||
public void onDisconnect(PlayerQuitEvent e) {
|
||||
FPlayer fPlayer = FPlayers.getInstance().getByPlayer(e.getPlayer());
|
||||
if (fPlayer.isInFactionsChest()) fPlayer.setInFactionsChest(false);
|
||||
}
|
||||
|
||||
private static class InteractAttemptSpam {
|
||||
private int attempts = 0;
|
||||
private long lastAttempt = System.currentTimeMillis();
|
||||
|
||||
// returns the current attempt count
|
||||
public int increment() {
|
||||
long now = System.currentTimeMillis();
|
||||
if (now > lastAttempt + 2000) {
|
||||
attempts = 1;
|
||||
} else {
|
||||
attempts++;
|
||||
}
|
||||
lastAttempt = now;
|
||||
return attempts;
|
||||
}
|
||||
if (fPlayer.isInFactionsChest()) fPlayer.setInFactionsChest(false);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -0,0 +1,46 @@
|
||||
package com.massivecraft.factions.listeners.menu;
|
||||
|
||||
import com.massivecraft.factions.zcore.util.ItemUtil;
|
||||
import org.bukkit.event.inventory.InventoryClickEvent;
|
||||
import org.bukkit.inventory.ItemStack;
|
||||
import org.bukkit.inventory.meta.ItemMeta;
|
||||
|
||||
import java.util.List;
|
||||
import java.util.function.Consumer;
|
||||
|
||||
public class ClickableItemStack extends ItemStack {
|
||||
private Consumer<InventoryClickEvent> itemCallback;
|
||||
|
||||
public ClickableItemStack(ItemStack clone) {
|
||||
super(clone);
|
||||
}
|
||||
|
||||
public ClickableItemStack setClickCallback(Consumer<InventoryClickEvent> callback) {
|
||||
this.itemCallback = callback;
|
||||
return this;
|
||||
}
|
||||
|
||||
public ClickableItemStack setDisplayName(String name) {
|
||||
ItemMeta im = this.getItemMeta();
|
||||
im.setDisplayName(name);
|
||||
this.setItemMeta(im);
|
||||
return this;
|
||||
}
|
||||
|
||||
|
||||
public ClickableItemStack setLore(List<String> lore) {
|
||||
ItemMeta im = this.getItemMeta();
|
||||
im.setLore(lore);
|
||||
this.setItemMeta(im);
|
||||
return this;
|
||||
}
|
||||
|
||||
public ClickableItemStack setDura(short dura) {
|
||||
this.setDurability(dura);
|
||||
return this;
|
||||
}
|
||||
|
||||
public Consumer<InventoryClickEvent> getItemCallback() {
|
||||
return this.itemCallback;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,153 @@
|
||||
package com.massivecraft.factions.listeners.menu;
|
||||
|
||||
import com.google.common.collect.Lists;
|
||||
import com.massivecraft.factions.FPlayer;
|
||||
import com.massivecraft.factions.Faction;
|
||||
import com.massivecraft.factions.FactionsPlugin;
|
||||
import com.massivecraft.factions.struct.Role;
|
||||
import org.bukkit.Bukkit;
|
||||
import org.bukkit.ChatColor;
|
||||
import org.bukkit.DyeColor;
|
||||
import org.bukkit.Material;
|
||||
import org.bukkit.entity.HumanEntity;
|
||||
import org.bukkit.entity.Player;
|
||||
import org.bukkit.event.inventory.InventoryCloseEvent;
|
||||
import org.bukkit.inventory.Inventory;
|
||||
import org.bukkit.inventory.ItemStack;
|
||||
import org.bukkit.material.MaterialData;
|
||||
|
||||
import java.util.HashMap;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
import java.util.UUID;
|
||||
import java.util.function.Consumer;
|
||||
|
||||
public abstract class GUIMenu {
|
||||
protected Inventory menu;
|
||||
private Map<Integer, ClickableItemStack> menuItems = new HashMap();
|
||||
private static Map<UUID, GUIMenu> menus = new HashMap();
|
||||
private Consumer<InventoryCloseEvent> closeCallback;
|
||||
private String name;
|
||||
private int size;
|
||||
private GUIMenu previousMenu;
|
||||
|
||||
public GUIMenu(String name, int size) {
|
||||
if (name.length() > 32) {
|
||||
name = name.substring(0, 32);
|
||||
}
|
||||
|
||||
this.name = name;
|
||||
this.size = size;
|
||||
this.menu = Bukkit.createInventory(null, size, name);
|
||||
}
|
||||
|
||||
public void setInventorySize(int size) {
|
||||
if (this.size != size) {
|
||||
int oldSize = this.size;
|
||||
this.size = size;
|
||||
List<HumanEntity> viewing = Lists.newArrayList(this.menu.getViewers());
|
||||
this.menu = Bukkit.createInventory(null, size, this.name);
|
||||
viewing.forEach((pl) -> {
|
||||
pl.closeInventory();
|
||||
pl.openInventory(this.menu);
|
||||
menus.put(pl.getUniqueId(), this);
|
||||
Bukkit.getLogger().info("Reopening Menu for " + pl.getName() + " due to menu changing size from " + oldSize + " -> " + size);
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
public GUIMenu setPreviousMenu(GUIMenu menu) {
|
||||
this.previousMenu = menu;
|
||||
return this;
|
||||
}
|
||||
|
||||
public void setItem(int slot, ClickableItemStack item) {
|
||||
this.menu.setItem(slot, item);
|
||||
this.menuItems.put(slot, item);
|
||||
}
|
||||
|
||||
public abstract void drawItems();
|
||||
|
||||
private boolean canEditPermissions(Faction faction, FPlayer player) {
|
||||
Role role = player.getRole();
|
||||
if (role != null && role.isAtLeast(Role.COLEADER)) {
|
||||
Faction theirfac = player.getFaction();
|
||||
return theirfac != null && theirfac.isNormal() && theirfac.equals(faction);
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
public ClickableItemStack getBackButton(Material data, String name, String... lore) {
|
||||
return (new ClickableItemStack(new ItemStack(data != null ? data : Material.RED_STAINED_GLASS_PANE, 1, data != null ? (short) 0 : 0 ))).setDisplayName(name != null ? name : ChatColor.RED + ChatColor.BOLD.toString() + "Back").setLore(lore != null ? Lists.newArrayList(lore) : Lists.newArrayList(ChatColor.GRAY + "Click to return to previous menu.")).setClickCallback((e) -> {
|
||||
if (this.previousMenu != null) {
|
||||
this.previousMenu.open((Player)e.getWhoClicked());
|
||||
}
|
||||
|
||||
});
|
||||
}
|
||||
|
||||
protected void clearItems() {
|
||||
this.getMenuItems().clear();
|
||||
this.menu.clear();
|
||||
}
|
||||
|
||||
public void open(Player player) {
|
||||
GUIMenu openMenu = menus.get(player.getUniqueId());
|
||||
if (openMenu != null) {
|
||||
player.closeInventory();
|
||||
Bukkit.getScheduler().scheduleSyncDelayedTask(FactionsPlugin.instance, () -> {
|
||||
this.drawItems();
|
||||
player.openInventory(this.menu);
|
||||
menus.put(player.getUniqueId(), this);
|
||||
}, 1L);
|
||||
} else {
|
||||
this.drawItems();
|
||||
player.openInventory(this.menu);
|
||||
menus.put(player.getUniqueId(), this);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
public void fillEmpty(ClickableItemStack item) {
|
||||
for(int i = 0; i < this.menu.getSize(); ++i) {
|
||||
ItemStack is = this.menu.getItem(i);
|
||||
if (is == null || is.getType() == Material.AIR) {
|
||||
this.setItem(i, item);
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
public static int fitSlots(int size) {
|
||||
return size <= 9 ? 9 : (size <= 18 ? 18 : (size <= 27 ? 27 : (size <= 36 ? 36 : (size <= 45 ? 45 : (size <= 54 ? 54 : 54)))));
|
||||
}
|
||||
|
||||
public Map<Integer, ClickableItemStack> getMenuItems() {
|
||||
return this.menuItems;
|
||||
}
|
||||
|
||||
public static Map<UUID, GUIMenu> getMenus() {
|
||||
return menus;
|
||||
}
|
||||
|
||||
public Consumer<InventoryCloseEvent> getCloseCallback() {
|
||||
return this.closeCallback;
|
||||
}
|
||||
|
||||
public void setCloseCallback(Consumer<InventoryCloseEvent> closeCallback) {
|
||||
this.closeCallback = closeCallback;
|
||||
}
|
||||
|
||||
public String getName() {
|
||||
return this.name;
|
||||
}
|
||||
|
||||
public int getSize() {
|
||||
return this.size;
|
||||
}
|
||||
|
||||
public GUIMenu getPreviousMenu() {
|
||||
return this.previousMenu;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,59 @@
|
||||
package com.massivecraft.factions.listeners.menu;
|
||||
|
||||
import org.bukkit.entity.Player;
|
||||
import org.bukkit.event.EventHandler;
|
||||
import org.bukkit.event.Listener;
|
||||
import org.bukkit.event.inventory.InventoryClickEvent;
|
||||
import org.bukkit.event.inventory.InventoryCloseEvent;
|
||||
import org.bukkit.event.player.PlayerQuitEvent;
|
||||
import org.bukkit.inventory.ItemStack;
|
||||
|
||||
public class MenuListener implements Listener {
|
||||
|
||||
public MenuListener() {
|
||||
}
|
||||
|
||||
@EventHandler
|
||||
public void onInventoryClick(InventoryClickEvent event) {
|
||||
if (event.getInventory().getName().equals("Faction Logs")) {
|
||||
event.setCancelled(true);
|
||||
}
|
||||
|
||||
Player player = (Player)event.getWhoClicked();
|
||||
GUIMenu menu = GUIMenu.getMenus().get(player.getUniqueId());
|
||||
if (menu != null) {
|
||||
event.setCancelled(true);
|
||||
if (!menu.getName().equals(event.getInventory().getName())) {
|
||||
player.closeInventory();
|
||||
return;
|
||||
}
|
||||
|
||||
ItemStack item = event.getCurrentItem();
|
||||
if (item == null) return;
|
||||
if (event.getRawSlot() >= event.getInventory().getSize()) return;
|
||||
ClickableItemStack found = menu.getMenuItems().get(event.getRawSlot());
|
||||
if (found != null && found.getType() == item.getType() && found.getDurability() == item.getDurability()) {
|
||||
if (found.getItemCallback() == null) {
|
||||
return;
|
||||
}
|
||||
found.getItemCallback().accept(event);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@EventHandler
|
||||
public void onInventoryClose(InventoryCloseEvent event) {
|
||||
GUIMenu menu = GUIMenu.getMenus().remove(event.getPlayer().getUniqueId());
|
||||
if (menu != null && menu.getCloseCallback() != null) {
|
||||
menu.getCloseCallback().accept(event);
|
||||
}
|
||||
}
|
||||
|
||||
@EventHandler
|
||||
public void onPLayerLeave(PlayerQuitEvent event) {
|
||||
GUIMenu menu = GUIMenu.getMenus().remove(event.getPlayer().getUniqueId());
|
||||
if (menu != null && menu.getCloseCallback() != null) {
|
||||
menu.getCloseCallback().accept(new InventoryCloseEvent(event.getPlayer().getOpenInventory()));
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -24,9 +24,6 @@ public class CmdMissions extends FCommand {
|
||||
|
||||
@Override
|
||||
public void perform(CommandContext context) {
|
||||
if (context.faction == null) {
|
||||
return;
|
||||
}
|
||||
final MissionGUI missionsGUI = new MissionGUI(FactionsPlugin.getInstance(), context.fPlayer);
|
||||
missionsGUI.build();
|
||||
context.player.openInventory(missionsGUI.getInventory());
|
||||
|
||||
@@ -30,30 +30,44 @@ public class MissionGUI implements FactionGUI {
|
||||
|
||||
@Override
|
||||
public void onClick(int slot, ClickType action) {
|
||||
String missionName = slots.get(slot);
|
||||
if (missionName == null) return;
|
||||
ConfigurationSection configurationSection = plugin.getConfig().getConfigurationSection("Missions");
|
||||
if (configurationSection == null) {
|
||||
return;
|
||||
}
|
||||
if (missionName.equals(plugin.color(FactionsPlugin.getInstance().getConfig().getString("Randomization.Start-Item.Allowed.Name")))) {
|
||||
Mission pickedMission = null;
|
||||
Set<String> keys = plugin.getConfig().getConfigurationSection("Missions").getKeys(false);
|
||||
while (pickedMission == null) {
|
||||
Random r = new Random();
|
||||
int pick = r.nextInt(keys.size() - 1);
|
||||
if (!keys.toArray()[pick].toString().equals("FillItem")) {
|
||||
missionName = keys.toArray()[pick].toString();
|
||||
if (!fPlayer.getFaction().getMissions().keySet().contains(missionName)) {
|
||||
pickedMission = new Mission(missionName, plugin.getConfig().getString("Missions." + missionName + ".Mission.Type"));
|
||||
fPlayer.getFaction().getMissions().put(missionName, pickedMission);
|
||||
fPlayer.msg(TL.MISSION_MISSION_STARTED, fPlayer.describeTo(fPlayer.getFaction()), plugin.color(plugin.getConfig().getString("Missions." + missionName + ".Name")));
|
||||
build();
|
||||
fPlayer.getPlayer().openInventory(inventory);
|
||||
return;
|
||||
}
|
||||
}
|
||||
}
|
||||
} else if (plugin.getConfig().getBoolean("Randomization.Enabled")) {return;}
|
||||
if (configurationSection == null) return;
|
||||
|
||||
int max = plugin.getConfig().getInt("MaximumMissionsAllowedAtOnce");
|
||||
if (fPlayer.getFaction().getMissions().size() >= max) {
|
||||
fPlayer.msg(TL.MISSION_MISSION_MAX_ALLOWED, max);
|
||||
return;
|
||||
}
|
||||
String missionName = slots.get(slot);
|
||||
if (missionName == null) {
|
||||
return;
|
||||
}
|
||||
//if (missionName.equals(plugin.color(FactionsPlugin.getInstance().getConfig().getString("Randomization.Start-Item.Disallowed.Name")))) {
|
||||
//return;
|
||||
//}
|
||||
if (missionName.equals(plugin.color(FactionsPlugin.getInstance().getConfig().getString("Randomization.Start-Item.Disallowed.Name")))) return;
|
||||
|
||||
if (fPlayer.getFaction().getMissions().containsKey(missionName)) {
|
||||
fPlayer.msg(TL.MISSION_MISSION_ACTIVE);
|
||||
return;
|
||||
}
|
||||
ConfigurationSection section = configurationSection.getConfigurationSection(missionName);
|
||||
if (section == null) {
|
||||
return;
|
||||
}
|
||||
if (section == null) return;
|
||||
|
||||
if(FactionsPlugin.getInstance().getConfig().getBoolean("DenyMissionsMoreThenOnce")) {
|
||||
if (fPlayer.getFaction().getCompletedMissions().contains(missionName)) {
|
||||
fPlayer.msg(TL.MISSION_ALREAD_COMPLETED);
|
||||
@@ -62,27 +76,8 @@ public class MissionGUI implements FactionGUI {
|
||||
}
|
||||
|
||||
ConfigurationSection missionSection = section.getConfigurationSection("Mission");
|
||||
if (missionSection == null) {
|
||||
return;
|
||||
}
|
||||
//Coming soon (:
|
||||
//if (missionName.equals(plugin.color(FactionsPlugin.getInstance().getConfig().getString("Randomization.Start-Item.Allowed.Name")))) {
|
||||
//Mission pickedMission = null;
|
||||
//Set<String> keys = plugin.getConfig().getConfigurationSection("Missions").getKeys(false);
|
||||
//while (pickedMission == null) {
|
||||
//Random r = new Random();
|
||||
//int pick = r.nextInt(keys.size() - 1);
|
||||
//if (!keys.toArray()[pick].toString().equals("FillItem")) {
|
||||
//missionName = keys.toArray()[pick].toString();
|
||||
//pickedMission = new Mission(missionName, plugin.getConfig().getString("Missions." + missionName + ".Mission.Type"));
|
||||
//fPlayer.getFaction().getMissions().put(missionName, pickedMission);
|
||||
//fPlayer.msg(TL.MISSION_MISSION_STARTED, fPlayer.describeTo(fPlayer.getFaction()), plugin.color(plugin.getConfig().getString("Missions." + missionName + ".Name")));
|
||||
//build();
|
||||
//fPlayer.getPlayer().openInventory(inventory);
|
||||
//return;
|
||||
//}
|
||||
//}
|
||||
//}
|
||||
if (missionSection == null) return;
|
||||
|
||||
Mission mission = new Mission(missionName, missionSection.getString("Type"));
|
||||
fPlayer.getFaction().getMissions().put(missionName, mission);
|
||||
fPlayer.msg(TL.MISSION_MISSION_STARTED, fPlayer.describeTo(fPlayer.getFaction()), plugin.color(section.getString("Name")));
|
||||
@@ -136,8 +131,7 @@ public class MissionGUI implements FactionGUI {
|
||||
start = XMaterial.matchXMaterial(plugin.getConfig().getString("Randomization.Start-Item.Allowed.Material")).parseItem();
|
||||
meta = start.getItemMeta();
|
||||
meta.setDisplayName(plugin.color(plugin.getConfig().getString("Randomization.Start-Item.Allowed.Name")));
|
||||
List<String> loree = meta.getLore();
|
||||
loree.clear();
|
||||
List<String> loree = new ArrayList<>();
|
||||
for (String string : plugin.getConfig().getStringList("Randomization.Start-Item.Allowed.Lore")) {
|
||||
loree.add(plugin.color(string));
|
||||
}
|
||||
@@ -147,8 +141,7 @@ public class MissionGUI implements FactionGUI {
|
||||
start = XMaterial.matchXMaterial(plugin.getConfig().getString("Randomization.Start-Item.Disallowed.Material")).parseItem();
|
||||
meta = start.getItemMeta();
|
||||
meta.setDisplayName(plugin.color(plugin.getConfig().getString("Randomization.Start-Item.Disallowed.Name")));
|
||||
List<String> lore = meta.getLore();
|
||||
lore.clear();
|
||||
List<String> lore = new ArrayList<>();
|
||||
for (String string : plugin.getConfig().getStringList("Randomization.Start-Item.Disallowed.Lore")) {
|
||||
lore.add(plugin.color(string).replace("%reason%", TL.MISSION_MISSION_ALL_COMPLETED.toString()));
|
||||
}
|
||||
@@ -159,8 +152,7 @@ public class MissionGUI implements FactionGUI {
|
||||
start = XMaterial.matchXMaterial(plugin.getConfig().getString("Randomization.Start-Item.Disallowed.Material")).parseItem();
|
||||
meta = start.getItemMeta();
|
||||
meta.setDisplayName(plugin.color(plugin.getConfig().getString("Randomization.Start-Item.Disallowed.Name")));
|
||||
List<String> lore = meta.getLore();
|
||||
lore.clear();
|
||||
List<String> lore = new ArrayList<>();
|
||||
for (String string : plugin.getConfig().getStringList("Randomization.Start-Item.Disallowed.Lore")) {
|
||||
lore.add(plugin.color(string).replace("%reason%", FactionsPlugin.getInstance().txt.parse(TL.MISSION_MISSION_MAX_ALLOWED.toString(), plugin.getConfig().getInt("MaximumMissionsAllowedAtOnce"))));
|
||||
}
|
||||
|
||||
@@ -31,18 +31,9 @@ public class FTeamWrapper {
|
||||
}
|
||||
|
||||
public static void applyUpdatesLater(final Faction faction) {
|
||||
if (!FScoreboard.isSupportedByServer()) {
|
||||
return;
|
||||
}
|
||||
|
||||
if (faction.isWilderness()) {
|
||||
return;
|
||||
}
|
||||
|
||||
if (!FactionsPlugin.getInstance().getConfig().getBoolean("scoreboard.default-prefixes", false) || FactionsPlugin.getInstance().getConfig().getBoolean("See-Invisible-Faction-Members")) {
|
||||
return;
|
||||
}
|
||||
|
||||
if (!FScoreboard.isSupportedByServer()) return;
|
||||
if (faction.isWilderness()) return;
|
||||
if (!FactionsPlugin.getInstance().getConfig().getBoolean("scoreboard.default-prefixes", false) || FactionsPlugin.getInstance().getConfig().getBoolean("See-Invisible-Faction-Members")) return;
|
||||
|
||||
if (updating.add(faction)) {
|
||||
Bukkit.getScheduler().runTask(FactionsPlugin.getInstance(), () -> {
|
||||
@@ -53,22 +44,12 @@ public class FTeamWrapper {
|
||||
}
|
||||
|
||||
public static void applyUpdates(Faction faction) {
|
||||
if (!FScoreboard.isSupportedByServer()) {
|
||||
return;
|
||||
}
|
||||
if (!FScoreboard.isSupportedByServer()) return;
|
||||
|
||||
if (faction.isWilderness()) {
|
||||
return;
|
||||
}
|
||||
if (faction.isWilderness()) return;
|
||||
|
||||
if (!FactionsPlugin.getInstance().getConfig().getBoolean("scoreboard.default-prefixes", false) || FactionsPlugin.getInstance().getConfig().getBoolean("See-Invisible-Faction-Members")) {
|
||||
return;
|
||||
}
|
||||
|
||||
if (updating.contains(faction)) {
|
||||
// Faction will be updated soon.
|
||||
return;
|
||||
}
|
||||
if (!FactionsPlugin.getInstance().getConfig().getBoolean("scoreboard.default-prefixes", false) || FactionsPlugin.getInstance().getConfig().getBoolean("See-Invisible-Faction-Members")) return;
|
||||
if (updating.contains(faction)) return;
|
||||
|
||||
FTeamWrapper wrapper = wrappers.get(faction);
|
||||
Set<FPlayer> factionMembers = faction.getFPlayers();
|
||||
|
||||
@@ -12,6 +12,7 @@ public enum Permission {
|
||||
ADMIN_ANY("admin.any"),
|
||||
AHOME("ahome"),
|
||||
ANNOUNCE("announce"),
|
||||
AUDIT("audit"),
|
||||
AUTOCLAIM("autoclaim"),
|
||||
AUTO_LEAVE_BYPASS("autoleavebypass"),
|
||||
BAN("ban"),
|
||||
@@ -36,13 +37,13 @@ public enum Permission {
|
||||
DISBAND_ANY("disband.any"),
|
||||
DISCORD("discord"),
|
||||
FLY("fly"),
|
||||
FLY_WILD("factions.fly.wilderness"),
|
||||
FLY_SAFEZONE("factions.fly.safezone"),
|
||||
FLY_WARZONE("factions.fly.warzone"),
|
||||
FLY_ENEMY("factions.fly.enemy"),
|
||||
FLY_ALLY("factions.fly.ally"),
|
||||
FLY_TRUCE("factions.fly.truce"),
|
||||
FLY_NEUTRAL("factions.fly.neutral"),
|
||||
FLY_WILD("fly.wilderness"),
|
||||
FLY_SAFEZONE("fly.safezone"),
|
||||
FLY_WARZONE("fly.warzone"),
|
||||
FLY_ENEMY("fly.enemy"),
|
||||
FLY_ALLY("fly.ally"),
|
||||
FLY_TRUCE("fly.truce"),
|
||||
FLY_NEUTRAL("fly.neutral"),
|
||||
FOCUS("focus"),
|
||||
GLOBALCHAT("globalchat"),
|
||||
GRACE("grace"),
|
||||
@@ -108,6 +109,7 @@ public enum Permission {
|
||||
STEALTH("stealth"),
|
||||
STUCK("stuck"),
|
||||
TAG("tag"),
|
||||
TOGGLE_TITLES("toggletitles"),
|
||||
TNT("tnt"),
|
||||
TITLE("title"),
|
||||
TITLE_COLOR("title.color"),
|
||||
|
||||
@@ -116,23 +116,27 @@ public class ClipPlaceholderAPIManager extends PlaceholderExpansion implements R
|
||||
case "faction_description":
|
||||
return faction.getDescription();
|
||||
case "faction_claims":
|
||||
return String.valueOf(faction.getAllClaims().size());
|
||||
return fPlayer.hasFaction() ? String.valueOf(faction.getAllClaims().size()) : "0";
|
||||
case "faction_maxclaims":
|
||||
return String.valueOf(Conf.claimedLandsMax);
|
||||
case "faction_founded":
|
||||
return TL.sdf.format(faction.getFoundedDate());
|
||||
case "faction_joining":
|
||||
return (faction.getOpen() ? TL.COMMAND_SHOW_UNINVITED.toString() : TL.COMMAND_SHOW_INVITATION.toString());
|
||||
case "faction_strikes":
|
||||
return fPlayer.hasFaction() ? String.valueOf(faction.getStrikes()) : "0";
|
||||
case "faction_peaceful":
|
||||
return faction.isPeaceful() ? Conf.colorNeutral + TL.COMMAND_SHOW_PEACEFUL.toString() : "";
|
||||
case "faction_tntbank_balance":
|
||||
return String.valueOf(faction.getTnt());
|
||||
case "faction_points":
|
||||
return String.valueOf(faction.getPoints());
|
||||
return fPlayer.hasFaction() ? String.valueOf(faction.getPoints()) : "0";
|
||||
case "faction_powerboost":
|
||||
double powerBoost = faction.getPowerBoost();
|
||||
return (powerBoost == 0.0) ? "" : (powerBoost > 0.0 ? TL.COMMAND_SHOW_BONUS.toString() : TL.COMMAND_SHOW_PENALTY.toString()) + powerBoost + ")";
|
||||
case "faction_leader":
|
||||
FPlayer fAdmin = faction.getFPlayerAdmin();
|
||||
return fAdmin == null ? "Server" : fAdmin.getName().substring(0, fAdmin.getName().length() > 14 ? 13 : fAdmin.getName().length());
|
||||
return fAdmin == null ? TL.GENERIC_SERVER.toString() : fAdmin.getName().substring(0, fAdmin.getName().length() > 14 ? 13 : fAdmin.getName().length());
|
||||
case "faction_warps":
|
||||
return String.valueOf(faction.getWarps().size());
|
||||
case "faction_raidable":
|
||||
|
||||
@@ -38,7 +38,11 @@ public class FactionWarpsFrame {
|
||||
GUIItems.add(new GuiItem(buildDummyItem(), e -> e.setCancelled(true)));
|
||||
slots.forEach(slot -> GUIItems.set(slot, new GuiItem(XMaterial.AIR.parseItem())));
|
||||
for (final Map.Entry<String, LazyLocation> warp : fplayer.getFaction().getWarps().entrySet()) {
|
||||
if (count > slots.size()) continue;
|
||||
if (slots.size() < fplayer.getFaction().getWarps().entrySet().size()){
|
||||
slots.add(slots.get(slots.size()-1)+1);
|
||||
FactionsPlugin.instance.log("Automatically setting F WARP GUI slot since slot not specified. Head config.yml and add more entries in warp-slots section.");
|
||||
}
|
||||
|
||||
GUIItems.set(slots.get(count), new GuiItem(buildWarpAsset(warp, fplayer.getFaction()), e -> {
|
||||
e.setCancelled(true);
|
||||
fplayer.getPlayer().closeInventory();
|
||||
|
||||
@@ -33,10 +33,9 @@ public class Updater {
|
||||
lore.clear();
|
||||
lore.add("&4%reason%");
|
||||
conf.set("Randomization.Start-Item.Disallowed.Lore", lore);
|
||||
conf.set("Randomization.Start-Item.Slot", 23);
|
||||
conf.set("Randomization.Start-Item.Slot", 28);
|
||||
conf.set("Config-Version", 1.1);
|
||||
version = 1.1;
|
||||
|
||||
currentVersion = 1.1;
|
||||
}
|
||||
//End with save + reload
|
||||
try {
|
||||
|
||||
@@ -0,0 +1,154 @@
|
||||
package com.massivecraft.factions.zcore.faudit;
|
||||
|
||||
import com.google.common.collect.Lists;
|
||||
import com.massivecraft.factions.Faction;
|
||||
import com.massivecraft.factions.FactionsPlugin;
|
||||
import com.massivecraft.factions.listeners.menu.ClickableItemStack;
|
||||
import com.massivecraft.factions.listeners.menu.GUIMenu;
|
||||
import com.massivecraft.factions.util.ItemBuilder;
|
||||
import com.massivecraft.factions.zcore.util.CC;
|
||||
import org.bukkit.Bukkit;
|
||||
import org.bukkit.Material;
|
||||
import org.bukkit.entity.Player;
|
||||
import org.bukkit.event.inventory.ClickType;
|
||||
|
||||
import java.util.Iterator;
|
||||
import java.util.LinkedList;
|
||||
import java.util.List;
|
||||
|
||||
public class FAuditMenu extends GUIMenu {
|
||||
private static int logsPerPage = 20;
|
||||
private Player player;
|
||||
private boolean showTimestamps = true;
|
||||
private Faction faction;
|
||||
|
||||
public FAuditMenu(Player player, Faction faction) {
|
||||
super("Faction Logs", 18);
|
||||
this.faction = faction;
|
||||
this.player = player;
|
||||
}
|
||||
|
||||
public void drawItems() {
|
||||
int index = 0;
|
||||
FLogType[] logTypes = FLogType.values();
|
||||
int length1 = logTypes.length;
|
||||
|
||||
for (FLogType type : logTypes) {
|
||||
if (type != FLogType.F_TNT || FactionsPlugin.getInstance().getConfig().getBoolean("f-points.Enabled")) {
|
||||
if (index == 9) {
|
||||
index = FactionsPlugin.getInstance().getConfig().getBoolean("f-points.Enabled") ? 11 : 12;
|
||||
}
|
||||
|
||||
FactionLogs logs = FactionsPlugin.instance.getFlogManager().getFactionLogMap().get(this.faction.getId());
|
||||
if (logs == null) {
|
||||
logs = new FactionLogs();
|
||||
}
|
||||
|
||||
LinkedList<FactionLogs.FactionLog> recentLogs = logs.getMostRecentLogs().get(type);
|
||||
if (recentLogs == null) {
|
||||
recentLogs = Lists.newLinkedList();
|
||||
}
|
||||
|
||||
List<String> lore = Lists.newArrayList("", CC.GreenB + "Recent Logs " + CC.Green + "(" + CC.GreenB + recentLogs.size() + CC.Green + ")");
|
||||
int added = 0;
|
||||
Iterator backwars = recentLogs.descendingIterator();
|
||||
while (backwars.hasNext()) {
|
||||
FactionLogs.FactionLog log = (FactionLogs.FactionLog) backwars.next();
|
||||
if (added >= logsPerPage) {
|
||||
break;
|
||||
}
|
||||
|
||||
String length = log.getLogLine(type, this.showTimestamps);
|
||||
lore.add(" " + CC.Yellow + length);
|
||||
++added;
|
||||
}
|
||||
|
||||
int logSize = recentLogs.size();
|
||||
int logsLeft = logSize - logsPerPage;
|
||||
if (logsLeft > 0) {
|
||||
lore.add(CC.YellowB + logsLeft + CC.Yellow + " more logs...");
|
||||
}
|
||||
|
||||
lore.add("");
|
||||
if (logsLeft > 0) {
|
||||
lore.add(CC.Yellow + "Left-Click " + CC.Gray + "to view more logs");
|
||||
}
|
||||
|
||||
lore.add(CC.Yellow + "Right-Click " + CC.Gray + "to toggle timestamps");
|
||||
this.setItem(index++, (new ClickableItemStack((new ItemBuilder(type.getDisplayMaterial())).name(CC.GreenB + type.getDisplayName()).lore(lore).build())).setClickCallback((click) -> {
|
||||
click.setCancelled(true);
|
||||
if (click.getClick() == ClickType.RIGHT) {
|
||||
this.showTimestamps = !this.showTimestamps;
|
||||
this.drawItems();
|
||||
} else {
|
||||
if (logsLeft <= 0) {
|
||||
this.player.sendMessage(CC.Red + "No extra logs to load.");
|
||||
return;
|
||||
}
|
||||
Bukkit.getScheduler().scheduleSyncDelayedTask(FactionsPlugin.instance, () -> (new FAuditLogMenu(this.player, this.faction, type)).open(this.player));
|
||||
}
|
||||
}));
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
class FAuditLogMenu extends GUIMenu {
|
||||
private Player player;
|
||||
private Faction faction;
|
||||
private FLogType logType;
|
||||
private boolean timeStamp = false;
|
||||
|
||||
public FAuditLogMenu(Player player, Faction faction, FLogType type) {
|
||||
super("Faction Logs", 9);
|
||||
this.player = player;
|
||||
this.faction = faction;
|
||||
this.logType = type;
|
||||
}
|
||||
|
||||
public void drawItems() {
|
||||
FactionLogs logs = FactionsPlugin.instance.getFlogManager().getFactionLogMap().get(faction.getId());
|
||||
int perPage = this.logType == FLogType.F_TNT ? 25 : 20;
|
||||
if (logs != null) {
|
||||
LinkedList<FactionLogs.FactionLog> log = logs.getMostRecentLogs().get(this.logType);
|
||||
if (log != null) {
|
||||
int slot = this.logType == FLogType.F_TNT ? 0 : 3;
|
||||
int pagesToShow = (int)Math.max(1.0D, Math.ceil((double)log.size() / (double)perPage));
|
||||
|
||||
for(int page = 1; page <= pagesToShow; ++page) {
|
||||
int startIndex = log.size() - (page * perPage - perPage);
|
||||
if (startIndex >= log.size()) {
|
||||
startIndex = log.size() - 1;
|
||||
}
|
||||
|
||||
List<String> lore = Lists.newArrayList("", CC.GreenB + "Logs");
|
||||
|
||||
for(int i = startIndex; i > startIndex - perPage; --i) {
|
||||
if (i < log.size()) {
|
||||
if (i < 0) {
|
||||
break;
|
||||
}
|
||||
|
||||
FactionLogs.FactionLog l = log.get(i);
|
||||
lore.add(" " + CC.Yellow + l.getLogLine(this.logType, this.timeStamp));
|
||||
}
|
||||
}
|
||||
|
||||
lore.add("");
|
||||
lore.add(CC.Gray + "Click to toggle timestamp");
|
||||
this.setItem(slot++, (new ClickableItemStack((new ItemBuilder(Material.PAPER)).name(CC.GreenB + "Log #" + page).lore(lore).build())).setClickCallback((e) -> {
|
||||
e.setCancelled(true);
|
||||
this.timeStamp = !this.timeStamp;
|
||||
this.drawItems();
|
||||
}));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
this.setItem(this.getSize() - 1, (new ClickableItemStack((new ItemBuilder(Material.ARROW)).name(CC.Green + "Previous Page").lore("", CC.Gray + "Click to view previous page!").build())).setClickCallback((event) -> {
|
||||
event.setCancelled(true);
|
||||
Bukkit.getScheduler().scheduleSyncDelayedTask(FactionsPlugin.instance, () -> (new FAuditMenu(this.player, this.faction)).open(this.player));
|
||||
}));
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,148 @@
|
||||
package com.massivecraft.factions.zcore.faudit;
|
||||
|
||||
import com.google.common.reflect.TypeToken;
|
||||
import com.massivecraft.factions.Faction;
|
||||
import com.massivecraft.factions.Factions;
|
||||
import com.massivecraft.factions.FactionsPlugin;
|
||||
import com.massivecraft.factions.zcore.util.JSONUtils;
|
||||
import org.bukkit.Bukkit;
|
||||
|
||||
import java.io.File;
|
||||
import java.lang.reflect.Type;
|
||||
import java.util.Map;
|
||||
import java.util.Timer;
|
||||
import java.util.UUID;
|
||||
import java.util.concurrent.ConcurrentHashMap;
|
||||
import java.util.concurrent.TimeUnit;
|
||||
|
||||
public class FLogManager {
|
||||
private Map<String, FactionLogs> factionLogMap = new ConcurrentHashMap();
|
||||
private File logFile;
|
||||
private Type logToken = (new TypeToken<ConcurrentHashMap<String, FactionLogs>>() {
|
||||
}).getType();
|
||||
private Map<UUID, LogTimer> logTimers = new ConcurrentHashMap();
|
||||
private boolean saving = false;
|
||||
|
||||
public FLogManager() {
|
||||
}
|
||||
|
||||
public void log(Faction faction, FLogType type, String... arguments) {
|
||||
FactionLogs logs = factionLogMap.computeIfAbsent(faction.getId(), (n) -> new FactionLogs());
|
||||
logs.log(type, arguments);
|
||||
}
|
||||
|
||||
public void loadLogs(FactionsPlugin plugin) {
|
||||
try {
|
||||
logFile = new File(plugin.getDataFolder(), "factionLogs.json");
|
||||
if (!logFile.exists()) {
|
||||
logFile.createNewFile();
|
||||
}
|
||||
|
||||
factionLogMap = (Map) JSONUtils.fromJson(logFile, logToken);
|
||||
if (factionLogMap == null) {
|
||||
factionLogMap = new ConcurrentHashMap();
|
||||
}
|
||||
|
||||
factionLogMap.forEach((factionId, factionLogs) -> {
|
||||
|
||||
Faction faction = Factions.getInstance().getFactionById(factionId);
|
||||
if (faction != null && faction.isNormal()) {
|
||||
factionLogs.checkExpired();
|
||||
if (factionLogs.isEmpty()) {
|
||||
factionLogMap.remove(factionId);
|
||||
}
|
||||
|
||||
} else {
|
||||
Bukkit.getLogger().info("Removing dead faction logs for " + factionId + "!");
|
||||
factionLogMap.remove(factionId);
|
||||
}
|
||||
});
|
||||
} catch (Exception e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
|
||||
long delay = TimeUnit.SECONDS.toMillis(15L);
|
||||
long sellDelay = TimeUnit.SECONDS.toMillis(30L);
|
||||
Bukkit.getScheduler().scheduleSyncRepeatingTask(FactionsPlugin.instance, () -> {
|
||||
if (saving) {
|
||||
Bukkit.getLogger().info("Ignoring saveLogs scheduler due to saving == true!");
|
||||
} else {
|
||||
logTimers.forEach((uuid, logTimer) -> {
|
||||
if (logTimer != null && logTimer.getFactionId() != null) {
|
||||
Faction faction = Factions.getInstance().getFactionById(logTimer.getFactionId());
|
||||
if (faction == null) {
|
||||
logTimers.remove(uuid);
|
||||
Bukkit.getLogger().info("Null faction for logs " + logTimer.getFactionId());
|
||||
} else {
|
||||
if (logTimer.isEmpty()) {
|
||||
logTimers.remove(uuid);
|
||||
}
|
||||
}
|
||||
} else {
|
||||
logTimers.remove(uuid);
|
||||
}
|
||||
});
|
||||
}
|
||||
}, 20L, 400L);
|
||||
}
|
||||
|
||||
public void pushPendingLogs(LogTimer.TimerType type) {
|
||||
Faction faction = null;
|
||||
|
||||
for (Map.Entry<UUID, LogTimer> uuidLogTimerEntry : getLogTimers().entrySet()) {
|
||||
Map.Entry<UUID, LogTimer> timer = uuidLogTimerEntry;
|
||||
LogTimer logTimer = timer.getValue();
|
||||
if (faction == null) {
|
||||
faction = Factions.getInstance().getFactionById(logTimer.getFactionId());
|
||||
}
|
||||
|
||||
if (type != null) {
|
||||
Map<LogTimer.TimerSubType, Timer> timers = (Map) logTimer.get(type);
|
||||
if (timers != null && faction != null) {
|
||||
logTimer.pushLogs(faction, type);
|
||||
}
|
||||
} else if (faction != null) {
|
||||
Faction finalFaction = faction;
|
||||
logTimer.keySet().forEach((timerType) -> logTimer.pushLogs(finalFaction, timerType));
|
||||
logTimer.clear();
|
||||
}
|
||||
}
|
||||
|
||||
if (type == null) {
|
||||
getLogTimers().clear();
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
public void saveLogs() {
|
||||
if (saving) {
|
||||
Bukkit.getLogger().info("Ignoring saveLogs due to saving==true!");
|
||||
} else {
|
||||
saving = true;
|
||||
|
||||
try {
|
||||
pushPendingLogs(null);
|
||||
} catch (Exception e) {
|
||||
Bukkit.getLogger().info("error pushing pending logs: " + e.getMessage());
|
||||
e.printStackTrace();
|
||||
}
|
||||
|
||||
try {
|
||||
JSONUtils.saveJSONToFile(logFile, factionLogMap,logToken);
|
||||
} catch (Exception e1) {
|
||||
Bukkit.getLogger().info("ERRRO SAVING JSON LOGS: " + e1.getMessage());
|
||||
e1.printStackTrace();
|
||||
}
|
||||
|
||||
saving = false;
|
||||
}
|
||||
}
|
||||
|
||||
public Map<String, FactionLogs> getFactionLogMap() {
|
||||
return factionLogMap;
|
||||
}
|
||||
|
||||
public Map<UUID, LogTimer> getLogTimers() {
|
||||
return logTimers;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,49 @@
|
||||
package com.massivecraft.factions.zcore.faudit;
|
||||
|
||||
import com.massivecraft.factions.util.XMaterial;
|
||||
import org.bukkit.Material;
|
||||
|
||||
public enum FLogType {
|
||||
|
||||
INVITES("Roster Edits", XMaterial.WRITABLE_BOOK.parseMaterial(), "&e%s&7 &a%s&7 &e%s", 3),
|
||||
BANS("Player Bans", XMaterial.ANVIL.parseMaterial(), "&e%s&7 &e%s&6 &e%s", 3),
|
||||
CHUNK_CLAIMS("Claim Edits", XMaterial.WOODEN_AXE.parseMaterial(), "&e%s&7 %s&7 &e%s&7 near &e%s", 3),
|
||||
PERM_EDIT_DEFAULTS("Default Perm Edits", XMaterial.WRITTEN_BOOK.parseMaterial(), "&e%s&7 %s&7 %s for &e%s", 4),
|
||||
BANK_EDIT("/f money Edits", XMaterial.GOLD_INGOT.parseMaterial(), "&e%s&7 %s &e&l$&e%s", 3),
|
||||
FCHEST_EDIT("/f chest Edits", XMaterial.CHEST.parseMaterial(), "&e%s&7 %s &f%s", 3),
|
||||
RELATION_CHANGE("Relation Edits", XMaterial.GOLDEN_SWORD.parseMaterial(), "&e%s %s&e'd %s", 3),
|
||||
FTAG_EDIT("/f tag Edits", XMaterial.NAME_TAG.parseMaterial(), "&e%s&7 set to &e'%s'", 2),
|
||||
FDESC_EDIT("/f desc Edits", XMaterial.PAPER.parseMaterial(), "&e%s&7 set to &e'%s'", 2),
|
||||
ROLE_PERM_EDIT("/f promote Edits", XMaterial.WRITTEN_BOOK.parseMaterial(), "&e%s&7&e %s &e%s &7to &e%s", 4),
|
||||
SPAWNER_EDIT("Spawner Edits", XMaterial.SPAWNER.parseMaterial(), "&e%s&7 %s &e%s&7 %s", 4),
|
||||
RANK_EDIT("Rank Edits", XMaterial.GOLDEN_HELMET.parseMaterial(), "&e%s&7 set &e%s&7 to %s", 3),
|
||||
F_TNT("/f tnt Edits", XMaterial.TNT.parseMaterial(), "&e%s&7 %s &e%s", 3);
|
||||
|
||||
private String displayName;
|
||||
private Material displayMaterial;
|
||||
private String msg;
|
||||
private int requiredArgs;
|
||||
|
||||
public String getDisplayName() {
|
||||
return this.displayName;
|
||||
}
|
||||
|
||||
public Material getDisplayMaterial() {
|
||||
return this.displayMaterial;
|
||||
}
|
||||
|
||||
public String getMsg() {
|
||||
return this.msg;
|
||||
}
|
||||
|
||||
public int getRequiredArgs() {
|
||||
return this.requiredArgs;
|
||||
}
|
||||
|
||||
FLogType(String displayName, Material displayMaterial, String msg, int requiredArgs) {
|
||||
this.displayName = displayName;
|
||||
this.displayMaterial = displayMaterial;
|
||||
this.msg = msg;
|
||||
this.requiredArgs = requiredArgs;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,103 @@
|
||||
package com.massivecraft.factions.zcore.faudit;
|
||||
|
||||
import com.google.common.collect.Lists;
|
||||
import org.bukkit.Bukkit;
|
||||
import org.bukkit.ChatColor;
|
||||
|
||||
import java.text.SimpleDateFormat;
|
||||
import java.util.Iterator;
|
||||
import java.util.LinkedList;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
import java.util.concurrent.ConcurrentHashMap;
|
||||
import java.util.concurrent.TimeUnit;
|
||||
|
||||
public class FactionLogs {
|
||||
private Map<FLogType, LinkedList<FactionLog>> mostRecentLogs = new ConcurrentHashMap();
|
||||
public static transient SimpleDateFormat format = new SimpleDateFormat("MM/dd hh:mmaa");
|
||||
private static transient int MAX_LOG_SIZE = 60;
|
||||
|
||||
public FactionLogs() {
|
||||
}
|
||||
|
||||
public void log(FLogType type, String... arguments) {
|
||||
if (type.getRequiredArgs() > arguments.length) {
|
||||
Bukkit.getLogger().info("INVALID ARGUMENT COUNT MET: " + type.getRequiredArgs() + " REQUIRED: ");
|
||||
Thread.dumpStack();
|
||||
} else {
|
||||
LinkedList<FactionLog> logs = this.mostRecentLogs.computeIfAbsent(type, (lists) -> new LinkedList());
|
||||
logs.add(new FactionLog(System.currentTimeMillis(), Lists.newArrayList(arguments)));
|
||||
int maxLog = type == FLogType.F_TNT ? 200 : 60;
|
||||
if (logs.size() > maxLog) {
|
||||
logs.pop();
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
public boolean isEmpty() {
|
||||
return this.mostRecentLogs.isEmpty();
|
||||
}
|
||||
|
||||
public void checkExpired() {
|
||||
long duration = TimeUnit.DAYS.toMillis(7L);
|
||||
List<FLogType> toRemove = Lists.newArrayList();
|
||||
mostRecentLogs.forEach((logType, logs) -> {
|
||||
if (logs == null) {
|
||||
toRemove.add(logType);
|
||||
} else if (logType != FLogType.F_TNT) {
|
||||
Iterator iter = logs.iterator();
|
||||
while (iter.hasNext()) {
|
||||
try {
|
||||
FactionLog log = (FactionLog) iter.next();
|
||||
if (log == null || log.isExpired(duration)) {
|
||||
iter.remove();
|
||||
}
|
||||
} catch (Exception e) {
|
||||
Bukkit.getLogger().info("ERROR TRYING TO GET next FACTION LOG: " + e.getMessage());
|
||||
try {
|
||||
iter.remove();
|
||||
} catch (Exception e1) {
|
||||
e1.printStackTrace();
|
||||
}
|
||||
}
|
||||
}
|
||||
if (logs.size() <= 0)
|
||||
toRemove.add(logType);
|
||||
}
|
||||
});
|
||||
toRemove.forEach((rem) -> {
|
||||
LinkedList linkedList = this.mostRecentLogs.remove(rem);
|
||||
});
|
||||
}
|
||||
|
||||
public Map<FLogType, LinkedList<FactionLog>> getMostRecentLogs() {
|
||||
return this.mostRecentLogs;
|
||||
}
|
||||
|
||||
public class FactionLog {
|
||||
private long t;
|
||||
private List<String> a;
|
||||
|
||||
public FactionLog(long t, List<String> a) {
|
||||
this.t = t;
|
||||
this.a = a;
|
||||
}
|
||||
|
||||
public boolean isExpired(long duration) {
|
||||
return System.currentTimeMillis() - this.t >= duration;
|
||||
}
|
||||
|
||||
public String getLogLine(FLogType type, boolean timestamp) {
|
||||
String[] args = this.a.toArray(new String[0]);
|
||||
String timeFormat = "";
|
||||
if (timestamp) {
|
||||
timeFormat = FactionLogs.format.format(this.t);
|
||||
if (timeFormat.startsWith("0")) {
|
||||
timeFormat = timeFormat.substring(1);
|
||||
}
|
||||
}
|
||||
return String.format(ChatColor.translateAlternateColorCodes('&', type.getMsg()), (String[])args) + (timestamp ? ChatColor.GRAY + " - " + timeFormat : "");
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,123 @@
|
||||
package com.massivecraft.factions.zcore.faudit;
|
||||
|
||||
import com.massivecraft.factions.Faction;
|
||||
import com.massivecraft.factions.FactionsPlugin;
|
||||
import org.apache.commons.lang.StringUtils;
|
||||
import org.bukkit.Bukkit;
|
||||
import org.bukkit.entity.EntityType;
|
||||
import org.bukkit.material.MaterialData;
|
||||
|
||||
import java.util.HashMap;
|
||||
import java.util.Map;
|
||||
import java.util.concurrent.ConcurrentHashMap;
|
||||
import java.util.concurrent.atomic.AtomicInteger;
|
||||
|
||||
public class LogTimer extends ConcurrentHashMap<LogTimer.TimerType, Map<LogTimer.TimerSubType, LogTimer.Timer>> {
|
||||
private String factionId;
|
||||
private String username;
|
||||
|
||||
public LogTimer(String username, String factionId) {
|
||||
this.username = username;
|
||||
this.factionId = factionId;
|
||||
}
|
||||
|
||||
public Map<LogTimer.TimerSubType, LogTimer.Timer> getCurrentTimersOrCreate(LogTimer.TimerType type) {
|
||||
return this.computeIfAbsent(type, (m) -> new ConcurrentHashMap());
|
||||
}
|
||||
|
||||
public LogTimer.Timer attemptLog(LogTimer.TimerType type, LogTimer.TimerSubType subType, long increment) {
|
||||
return this.getCurrentTimersOrCreate(type).computeIfAbsent(subType, (e) -> new Timer(System.currentTimeMillis(), 0L, null)).increment(increment);
|
||||
}
|
||||
|
||||
public void pushLogs(Faction faction, LogTimer.TimerType type) {
|
||||
StringBuilder soldString = new StringBuilder();
|
||||
forEach((timerType, map) -> {
|
||||
if (timerType == type) {
|
||||
if (timerType == LogTimer.TimerType.SPAWNER_EDIT) {
|
||||
map.forEach((subTimer, timer) -> {
|
||||
Map<EntityType, AtomicInteger> entityCounts = new HashMap();
|
||||
Map<MaterialData, AtomicInteger> currentCounts = (Map) timer.getExtraData();
|
||||
if (currentCounts != null) {
|
||||
currentCounts.forEach((data, ints) -> {
|
||||
EntityType types = EntityType.fromId(data.getData());
|
||||
if (types == null) {
|
||||
Bukkit.getLogger().info("Unable to find EntityType for " + data.getData() + " for " + subTimer + " for fac " + this.factionId + "!");
|
||||
} else {
|
||||
entityCounts.computeIfAbsent(types, (e) -> new AtomicInteger(0)).addAndGet(ints.get());
|
||||
}
|
||||
});
|
||||
entityCounts.forEach((entityType, count) -> FactionsPlugin.instance.getFlogManager().log(faction, FLogType.SPAWNER_EDIT, this.username, subTimer == TimerSubType.SPAWNER_BREAK ? "broke" : "placed", count.get() + "x", StringUtils.capitaliseAllWords(entityType.name().toLowerCase().replace("_", " "))));
|
||||
}
|
||||
});
|
||||
}
|
||||
}
|
||||
});
|
||||
this.remove(type);
|
||||
}
|
||||
|
||||
public String getFactionId() {
|
||||
return this.factionId;
|
||||
}
|
||||
|
||||
public String getUsername() {
|
||||
return this.username;
|
||||
}
|
||||
|
||||
public class Timer {
|
||||
private long startTime;
|
||||
private long count;
|
||||
private Object extraData;
|
||||
|
||||
LogTimer.Timer increment(long amount) {
|
||||
this.count += amount;
|
||||
return this;
|
||||
}
|
||||
|
||||
public boolean isReadyToLog(long expiration) {
|
||||
return System.currentTimeMillis() - this.startTime >= expiration;
|
||||
}
|
||||
|
||||
public Timer(long startTime, long count, Object extraData) {
|
||||
this.startTime = startTime;
|
||||
this.count = count;
|
||||
this.extraData = extraData;
|
||||
}
|
||||
|
||||
public long getStartTime() {
|
||||
return this.startTime;
|
||||
}
|
||||
|
||||
public long getCount() {
|
||||
return this.count;
|
||||
}
|
||||
|
||||
public Object getExtraData() {
|
||||
return this.extraData;
|
||||
}
|
||||
|
||||
public void setStartTime(long startTime) {
|
||||
this.startTime = startTime;
|
||||
}
|
||||
|
||||
public void setCount(long count) {
|
||||
this.count = count;
|
||||
}
|
||||
|
||||
public void setExtraData(Object extraData) {
|
||||
this.extraData = extraData;
|
||||
}
|
||||
}
|
||||
|
||||
public enum TimerSubType {
|
||||
SPAWNER_BREAK,
|
||||
SPAWNER_PLACE;
|
||||
TimerSubType() {
|
||||
}
|
||||
}
|
||||
|
||||
public enum TimerType {
|
||||
SPAWNER_EDIT;
|
||||
TimerType() {
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -3,14 +3,17 @@ package com.massivecraft.factions.zcore.fperms.gui;
|
||||
import com.github.stefvanschie.inventoryframework.Gui;
|
||||
import com.github.stefvanschie.inventoryframework.GuiItem;
|
||||
import com.github.stefvanschie.inventoryframework.pane.PaginatedPane;
|
||||
import com.massivecraft.factions.FLocation;
|
||||
import com.massivecraft.factions.FPlayer;
|
||||
import com.massivecraft.factions.Faction;
|
||||
import com.massivecraft.factions.FactionsPlugin;
|
||||
import com.massivecraft.factions.util.XMaterial;
|
||||
import com.massivecraft.factions.zcore.faudit.FLogType;
|
||||
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;
|
||||
@@ -47,10 +50,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;
|
||||
|
||||
@@ -17,8 +17,10 @@ import com.massivecraft.factions.struct.Relation;
|
||||
import com.massivecraft.factions.struct.Role;
|
||||
import com.massivecraft.factions.util.RelationUtil;
|
||||
import com.massivecraft.factions.util.WarmUpUtil;
|
||||
import com.massivecraft.factions.zcore.faudit.FLogType;
|
||||
import com.massivecraft.factions.zcore.fperms.Access;
|
||||
import com.massivecraft.factions.zcore.fperms.PermissableAction;
|
||||
import com.massivecraft.factions.zcore.util.CC;
|
||||
import com.massivecraft.factions.zcore.util.TL;
|
||||
import mkremins.fanciful.FancyMessage;
|
||||
import net.milkbowl.vault.economy.Economy;
|
||||
@@ -78,6 +80,7 @@ public abstract class MemoryFPlayer implements FPlayer {
|
||||
protected transient boolean shouldTakeFallDamage = true;
|
||||
protected boolean isStealthEnabled = false;
|
||||
protected boolean notificationsEnabled = true;
|
||||
protected boolean titlesEnabled = true;
|
||||
protected boolean isAlt = false;
|
||||
boolean inspectMode = false;
|
||||
|
||||
@@ -217,7 +220,12 @@ public abstract class MemoryFPlayer implements FPlayer {
|
||||
public boolean hasNotificationsEnabled() {
|
||||
return this.notificationsEnabled;
|
||||
}
|
||||
|
||||
public boolean hasTitlesEnabled() {
|
||||
return this.titlesEnabled;
|
||||
}
|
||||
public void setTitlesEnabled(Boolean b) {
|
||||
this.titlesEnabled = b;
|
||||
}
|
||||
public String getFactionId() {
|
||||
return this.factionId;
|
||||
}
|
||||
@@ -783,6 +791,7 @@ public abstract class MemoryFPlayer implements FPlayer {
|
||||
}
|
||||
|
||||
this.resetFactionData();
|
||||
FactionsPlugin.instance.logFactionEvent(myFaction, FLogType.INVITES, this.getName(), CC.Red + "left", "the faction");
|
||||
setFlying(false);
|
||||
|
||||
if (myFaction.isNormal() && !perm && myFaction.getFPlayers().isEmpty()) {
|
||||
@@ -817,7 +826,7 @@ public abstract class MemoryFPlayer implements FPlayer {
|
||||
int factionBuffer = FactionsPlugin.getInstance().getConfig().getInt("hcf.buffer-zone", 0);
|
||||
int worldBuffer = FactionsPlugin.getInstance().getConfig().getInt("world-border.buffer", 0);
|
||||
|
||||
if (Conf.worldGuardChecking && Worldguard.checkForRegionsInChunk(flocation) && !this.isAdminBypassing()) {
|
||||
if (Conf.worldGuardChecking && Worldguard.getInstance().checkForRegionsInChunk(flocation) && !this.isAdminBypassing()) {
|
||||
// Checks for WorldGuard regions in the chunk attempting to be claimed
|
||||
error = FactionsPlugin.getInstance().txt.parse(TL.CLAIM_PROTECTED.toString());
|
||||
} else if (flocation.isOutsideWorldBorder(FactionsPlugin.getInstance().getConfig().getInt("world-border.buffer", 0))) {
|
||||
@@ -988,8 +997,8 @@ public abstract class MemoryFPlayer implements FPlayer {
|
||||
return true;
|
||||
}
|
||||
|
||||
if (faction.isWilderness() || faction.isSafeZone() || faction.isWarZone()){
|
||||
return CmdFly.checkBypassPerms(this, this.getPlayer(), faction);
|
||||
if (faction.isSystemFaction()) {
|
||||
return CmdFly.checkBypassPerms(this, getPlayer(), faction);
|
||||
}
|
||||
|
||||
Access access = faction.getAccess(this, PermissableAction.FLY);
|
||||
@@ -1225,7 +1234,7 @@ public abstract class MemoryFPlayer implements FPlayer {
|
||||
}
|
||||
|
||||
// if economy is enabled and they're not on the bypass list, make sure they can pay
|
||||
boolean mustPay = Econ.shouldBeUsed() && !this.isAdminBypassing() && !forFaction.isSafeZone() && !forFaction.isWarZone();
|
||||
boolean mustPay = Econ.shouldBeUsed() && !this.isAdminBypassing() && !forFaction.isSafeZone() && !forFaction.isWarZone() && (Conf.econCostClaimWilderness != 0);
|
||||
double cost = 0.0;
|
||||
EconomyParticipator payee = null;
|
||||
if (mustPay) {
|
||||
|
||||
@@ -160,7 +160,6 @@ public abstract class MemoryFaction implements Faction, EconomyParticipator {
|
||||
this.checks = new ConcurrentHashMap<>();
|
||||
this.playerWallCheckCount = new ConcurrentHashMap<>();
|
||||
this.playerBufferCheckCount = new ConcurrentHashMap<>();
|
||||
|
||||
resetPerms(); // Reset on new Faction so it has default values.
|
||||
}
|
||||
|
||||
@@ -564,7 +563,7 @@ public abstract class MemoryFaction implements Faction, EconomyParticipator {
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setGuildId(final String guildId) {
|
||||
public void setGuildId(String guildId) {
|
||||
this.guildId = guildId;
|
||||
}
|
||||
|
||||
@@ -584,7 +583,7 @@ public abstract class MemoryFaction implements Faction, EconomyParticipator {
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setWallNotifyChannelId(final String wallNotifyChannelId) {
|
||||
public void setWallNotifyChannelId(String wallNotifyChannelId) {
|
||||
this.wallNotifyChannelId = wallNotifyChannelId;
|
||||
}
|
||||
|
||||
@@ -594,7 +593,7 @@ public abstract class MemoryFaction implements Faction, EconomyParticipator {
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setBufferNotifyChannelId(final String bufferNotifyChannelId) {
|
||||
public void setBufferNotifyChannelId(String bufferNotifyChannelId) {
|
||||
this.bufferNotifyChannelId = bufferNotifyChannelId;
|
||||
}
|
||||
|
||||
@@ -604,7 +603,7 @@ public abstract class MemoryFaction implements Faction, EconomyParticipator {
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setWeeWooChannelId(final String weeWooChannelId) {
|
||||
public void setWeeWooChannelId(String weeWooChannelId) {
|
||||
this.weeWooChannelId = weeWooChannelId;
|
||||
}
|
||||
|
||||
@@ -614,7 +613,7 @@ public abstract class MemoryFaction implements Faction, EconomyParticipator {
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setNotifyFormat(final String notifyFormat) {
|
||||
public void setNotifyFormat(String notifyFormat) {
|
||||
this.notifyFormat = notifyFormat;
|
||||
}
|
||||
|
||||
@@ -624,17 +623,17 @@ public abstract class MemoryFaction implements Faction, EconomyParticipator {
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setWeeWooFormat(final String weeWooFormat) {
|
||||
public void setWeeWooFormat(String weeWooFormat) {
|
||||
this.weeWooFormat = weeWooFormat;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setFactionChatChannelId(final String factionChatChannelId) {
|
||||
public void setFactionChatChannelId(String factionChatChannelId) {
|
||||
this.factionChatChannelId = factionChatChannelId;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setMemberRoleId(final String memberRoleId) {
|
||||
public void setMemberRoleId(String memberRoleId) {
|
||||
this.memberRoleId = memberRoleId;
|
||||
}
|
||||
|
||||
@@ -774,7 +773,7 @@ public abstract class MemoryFaction implements Faction, EconomyParticipator {
|
||||
return;
|
||||
}
|
||||
|
||||
msg("<b>Your faction home has been un-set since it is no longer in your territory.");
|
||||
msg(TL.COMMAND_HOME_UNSET);
|
||||
this.home = null;
|
||||
}
|
||||
|
||||
@@ -866,22 +865,13 @@ public abstract class MemoryFaction implements Faction, EconomyParticipator {
|
||||
* @return
|
||||
*/
|
||||
public Access getAccess(FPlayer player, PermissableAction permissableAction) {
|
||||
if (player == null || permissableAction == null) {
|
||||
return Access.UNDEFINED;
|
||||
}
|
||||
if (player == null || permissableAction == null) return Access.UNDEFINED;
|
||||
|
||||
Permissable perm;
|
||||
|
||||
if (player.getFaction() == this) {
|
||||
perm = player.getRole();
|
||||
} else {
|
||||
perm = player.getFaction().getRelationTo(this);
|
||||
}
|
||||
Permissable perm = player.getFaction() == this ? player.getRole() : player.getFaction().getRelationTo(this);
|
||||
|
||||
Map<PermissableAction, Access> accessMap = permissions.get(perm);
|
||||
if (accessMap != null && accessMap.containsKey(permissableAction)) {
|
||||
return accessMap.get(permissableAction);
|
||||
}
|
||||
if (accessMap != null && accessMap.containsKey(permissableAction)) return accessMap.get(permissableAction);
|
||||
|
||||
return Access.UNDEFINED;
|
||||
}
|
||||
@@ -896,7 +886,6 @@ public abstract class MemoryFaction implements Faction, EconomyParticipator {
|
||||
|
||||
public void resetPerms() {
|
||||
FactionsPlugin.getInstance().log(Level.WARNING, "Resetting permissions for Faction: " + tag);
|
||||
|
||||
permissions.clear();
|
||||
|
||||
// First populate a map with undefined as the permission for each action.
|
||||
@@ -1312,7 +1301,7 @@ public abstract class MemoryFaction implements Faction, EconomyParticipator {
|
||||
}
|
||||
|
||||
for (FPlayer fplayer : FPlayers.getInstance().getOnlinePlayers()) {
|
||||
fplayer.msg("The faction %s<i> was disbanded.", this.getTag(fplayer));
|
||||
fplayer.msg(TL.COMMAND_DISBAND_BROADCAST_GENERIC, this.getTag(fplayer));
|
||||
}
|
||||
|
||||
FactionDisbandEvent disbandEvent = new FactionDisbandEvent(null, getId(), autoLeave ? PlayerDisbandReason.INACTIVITY : PlayerDisbandReason.LEAVE);
|
||||
@@ -1324,8 +1313,7 @@ public abstract class MemoryFaction implements Faction, EconomyParticipator {
|
||||
oldLeader.setRole(Role.NORMAL);
|
||||
}
|
||||
replacements.get(0).setRole(Role.LEADER);
|
||||
//TODO:TL
|
||||
this.msg("<i>Faction admin <h>%s<i> has been removed. %s<i> has been promoted as the new faction admin.", oldLeader == null ? "" : oldLeader.getName(), replacements.get(0).getName());
|
||||
this.msg(TL.COMMAND_ADMIN_PROMOTED_AUTOLEAVE, oldLeader == null ? "" : oldLeader.getName(), replacements.get(0).getName());
|
||||
FactionsPlugin.getInstance().log("Faction " + this.getTag() + " (" + this.getId() + ") admin was removed. Replacement admin: " + replacements.get(0).getName());
|
||||
}
|
||||
}
|
||||
@@ -1459,8 +1447,7 @@ public abstract class MemoryFaction implements Faction, EconomyParticipator {
|
||||
ownerList.append(", ");
|
||||
}
|
||||
OfflinePlayer offlinePlayer = Bukkit.getOfflinePlayer(UUID.fromString(anOwnerData));
|
||||
//TODO:TL
|
||||
ownerList.append(offlinePlayer != null ? offlinePlayer.getName() : "null player");
|
||||
ownerList.append(offlinePlayer != null ? offlinePlayer.getName() : TL.GENERIC_NULLPLAYER.toString());
|
||||
}
|
||||
return ownerList.toString();
|
||||
}
|
||||
|
||||
92
src/main/java/com/massivecraft/factions/zcore/util/CC.java
Normal file
92
src/main/java/com/massivecraft/factions/zcore/util/CC.java
Normal file
@@ -0,0 +1,92 @@
|
||||
package com.massivecraft.factions.zcore.util;
|
||||
|
||||
import org.bukkit.ChatColor;
|
||||
|
||||
public class CC {
|
||||
public static String Black = ChatColor.BLACK.toString();
|
||||
public static String BlackB = ChatColor.BLACK + ChatColor.BOLD.toString();
|
||||
public static String BlackI = ChatColor.BLACK + ChatColor.ITALIC.toString();;
|
||||
public static String BlackU = ChatColor.BLACK + ChatColor.UNDERLINE.toString();
|
||||
public static String DarkBlue = ChatColor.DARK_BLUE.toString();
|
||||
public static String DarkBlueB = ChatColor.DARK_BLUE + ChatColor.BOLD.toString();
|
||||
public static String DarkBlueI = ChatColor.DARK_BLUE + ChatColor.ITALIC.toString();
|
||||
public static String DarkBlueU = ChatColor.DARK_BLUE + ChatColor.UNDERLINE.toString();
|
||||
public static String DarkGreen = ChatColor.DARK_GREEN.toString();
|
||||
public static String DarkGreenB = ChatColor.DARK_GREEN + ChatColor.BOLD.toString();
|
||||
public static String DarkGreenI = ChatColor.DARK_GREEN + ChatColor.ITALIC.toString();
|
||||
public static String DarkGreenU = ChatColor.DARK_GREEN + ChatColor.UNDERLINE.toString();
|
||||
public static String DarkAqua = ChatColor.DARK_AQUA.toString();
|
||||
public static String DarkAquaB = ChatColor.DARK_AQUA + ChatColor.BOLD.toString();
|
||||
public static String DarkAquaI = ChatColor.DARK_AQUA + ChatColor.ITALIC.toString();
|
||||
public static String DarkAquaU = ChatColor.DARK_AQUA + ChatColor.UNDERLINE.toString();
|
||||
public static String DarkRed = ChatColor.DARK_RED.toString();
|
||||
public static String DarkRedB = ChatColor.DARK_RED + ChatColor.BOLD.toString();
|
||||
public static String DarkRedI = ChatColor.DARK_RED + ChatColor.ITALIC.toString();
|
||||
public static String DarkRedU = ChatColor.DARK_RED + ChatColor.UNDERLINE.toString();
|
||||
public static String DarkPurple = ChatColor.DARK_PURPLE.toString();
|
||||
public static String DarkPurpleB = ChatColor.DARK_PURPLE + ChatColor.BOLD.toString();
|
||||
public static String DarkPurpleI = ChatColor.DARK_PURPLE + ChatColor.ITALIC.toString();
|
||||
public static String DarkPurpleU = ChatColor.DARK_PURPLE + ChatColor.UNDERLINE.toString();
|
||||
public static String Gold = ChatColor.GOLD.toString();
|
||||
public static String GoldB = ChatColor.GOLD + ChatColor.BOLD.toString();
|
||||
public static String GoldI = ChatColor.GOLD + ChatColor.ITALIC.toString();
|
||||
public static String GoldU = ChatColor.GOLD + ChatColor.UNDERLINE.toString();
|
||||
public static String Gray = ChatColor.GRAY.toString();
|
||||
public static String GrayB = ChatColor.GRAY + ChatColor.BOLD.toString();
|
||||
public static String GrayI = ChatColor.GRAY + ChatColor.ITALIC.toString();
|
||||
public static String GrayU = ChatColor.GRAY + ChatColor.UNDERLINE.toString();
|
||||
public static String DarkGray = ChatColor.DARK_GRAY.toString();
|
||||
public static String DarkGrayB = ChatColor.DARK_GRAY + ChatColor.BOLD.toString();
|
||||
public static String DarkGrayI = ChatColor.DARK_GRAY + ChatColor.ITALIC.toString();
|
||||
public static String DarkGrayU = ChatColor.DARK_GRAY + ChatColor.UNDERLINE.toString();
|
||||
public static String Blue = ChatColor.BLUE.toString();
|
||||
public static String BlueB = ChatColor.BLUE + ChatColor.BOLD.toString();
|
||||
public static String BlueI = ChatColor.BLUE + ChatColor.ITALIC.toString();
|
||||
public static String BlueU = ChatColor.BLUE + ChatColor.UNDERLINE.toString();
|
||||
public static String Green = ChatColor.GREEN.toString();
|
||||
public static String GreenB = ChatColor.GREEN + ChatColor.BOLD.toString();
|
||||
public static String GreenI = ChatColor.GREEN + ChatColor.ITALIC.toString();
|
||||
public static String GreenU = ChatColor.GREEN + ChatColor.UNDERLINE.toString();
|
||||
public static String Aqua = ChatColor.AQUA.toString();
|
||||
public static String AquaB = ChatColor.AQUA + ChatColor.BOLD.toString();
|
||||
public static String AquaI = ChatColor.AQUA + ChatColor.ITALIC.toString();
|
||||
public static String AquaU = ChatColor.AQUA + ChatColor.UNDERLINE.toString();
|
||||
public static String Red = ChatColor.RED.toString();
|
||||
public static String RedB = ChatColor.RED + ChatColor.BOLD.toString();
|
||||
public static String RedI = ChatColor.RED + ChatColor.ITALIC.toString();
|
||||
public static String RedU = ChatColor.RED + ChatColor.UNDERLINE.toString();
|
||||
public static String LightPurple = ChatColor.LIGHT_PURPLE.toString();
|
||||
public static String LightPurpleB = ChatColor.LIGHT_PURPLE + ChatColor.BOLD.toString();
|
||||
public static String LightPurpleI = ChatColor.LIGHT_PURPLE + ChatColor.ITALIC.toString();
|
||||
public static String LightPurpleU = ChatColor.LIGHT_PURPLE + ChatColor.UNDERLINE.toString();
|
||||
public static String Yellow = ChatColor.YELLOW.toString();
|
||||
public static String YellowB = ChatColor.YELLOW + ChatColor.BOLD.toString();
|
||||
public static String YellowI = ChatColor.YELLOW + ChatColor.ITALIC.toString();
|
||||
public static String YellowU = ChatColor.YELLOW + ChatColor.UNDERLINE.toString();
|
||||
public static String White = ChatColor.WHITE.toString();
|
||||
public static String WhiteB = ChatColor.WHITE + ChatColor.BOLD.toString();
|
||||
public static String WhiteI = ChatColor.WHITE + ChatColor.ITALIC.toString();
|
||||
public static String WhiteU = ChatColor.WHITE + ChatColor.UNDERLINE.toString();
|
||||
public static String Bold = ChatColor.BOLD.toString();
|
||||
public static String Strike = ChatColor.STRIKETHROUGH.toString();
|
||||
public static String Underline = ChatColor.UNDERLINE.toString();
|
||||
public static String Magic = ChatColor.MAGIC.toString();
|
||||
public static String Italic = ChatColor.ITALIC.toString();
|
||||
public static String Reset = ChatColor.RESET.toString();
|
||||
public static String Go = GreenB + "<!> " + Green;
|
||||
public static String Wait = YellowB + "<!> " + Yellow;
|
||||
public static String Stop = RedB + "<!> " + Red;
|
||||
|
||||
public static String prefix(char color) {
|
||||
return translate("&" + color + "&l<!> &" + color);
|
||||
}
|
||||
|
||||
public static String translate(String string) {
|
||||
return ChatColor.translateAlternateColorCodes('&', string);
|
||||
}
|
||||
|
||||
public static String strip(String string) {
|
||||
return ChatColor.stripColor(string);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -0,0 +1,48 @@
|
||||
package com.massivecraft.factions.zcore.util;
|
||||
|
||||
import com.massivecraft.factions.util.XMaterial;
|
||||
import org.bukkit.Material;
|
||||
import org.bukkit.inventory.Inventory;
|
||||
import org.bukkit.inventory.ItemStack;
|
||||
import org.bukkit.inventory.meta.SkullMeta;
|
||||
|
||||
import java.util.HashMap;
|
||||
import java.util.Map;
|
||||
|
||||
public class ItemUtil {
|
||||
private static Map<String, ItemStack> cachedSkulls = new HashMap();
|
||||
|
||||
public ItemUtil() {
|
||||
}
|
||||
|
||||
public static int getItemCount(Inventory inventory) {
|
||||
if (inventory == null) {
|
||||
return 0;
|
||||
} else {
|
||||
int itemsFound = 0;
|
||||
|
||||
for(int i = 0; i < inventory.getSize(); ++i) {
|
||||
ItemStack item = inventory.getItem(i);
|
||||
if (item != null && item.getType() != Material.AIR) {
|
||||
++itemsFound;
|
||||
}
|
||||
}
|
||||
|
||||
return itemsFound;
|
||||
}
|
||||
}
|
||||
|
||||
public static ItemStack createPlayerHead(String name) {
|
||||
ItemStack skull = cachedSkulls.get(name);
|
||||
if (skull != null) {
|
||||
return skull.clone();
|
||||
} else {
|
||||
skull = new ItemStack(XMaterial.PLAYER_HEAD.parseMaterial());
|
||||
SkullMeta sm = (SkullMeta)skull.getItemMeta();
|
||||
sm.setOwner(name);
|
||||
skull.setItemMeta(sm);
|
||||
cachedSkulls.put(name, skull.clone());
|
||||
return skull;
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,98 @@
|
||||
package com.massivecraft.factions.zcore.util;
|
||||
|
||||
import com.google.common.reflect.TypeToken;
|
||||
import com.google.gson.Gson;
|
||||
import com.google.gson.GsonBuilder;
|
||||
import org.bukkit.Bukkit;
|
||||
|
||||
import java.io.*;
|
||||
import java.lang.reflect.Type;
|
||||
|
||||
public class JSONUtils {
|
||||
public static Gson gson = (new GsonBuilder()).enableComplexMapKeySerialization().create();
|
||||
|
||||
public JSONUtils() {
|
||||
}
|
||||
|
||||
public static File getOrCreateFile(File parent, String string) throws IOException {
|
||||
if (!parent.exists()) {
|
||||
parent.mkdir();
|
||||
Bukkit.getLogger().info("Creating directory " + parent.getName());
|
||||
}
|
||||
|
||||
File f = new File(parent, string);
|
||||
if (!f.exists()) {
|
||||
Bukkit.getLogger().info("Creating new file " + string + " due to it not existing!");
|
||||
f.createNewFile();
|
||||
}
|
||||
return f;
|
||||
}
|
||||
|
||||
public static File getOrCreateFile(String fileName) throws IOException {
|
||||
File f = new File(fileName);
|
||||
if (!f.exists()) {
|
||||
Bukkit.getLogger().info("Creating new file " + fileName + " due to it not existing!");
|
||||
f.createNewFile();
|
||||
}
|
||||
return f;
|
||||
}
|
||||
|
||||
public static Object fromJson(String fileName, Object token) throws IOException {
|
||||
File f = getOrCreateFile(fileName);
|
||||
return fromJson(f, token);
|
||||
}
|
||||
|
||||
public static Object fromJson(File f, Object clazz) throws FileNotFoundException {
|
||||
return gson.fromJson(new FileReader(f), getTypeFromObject(clazz));
|
||||
}
|
||||
|
||||
public static Object fromJson(File f, Object clazz, Object defaultObj) throws FileNotFoundException {
|
||||
Object retr = gson.fromJson(new FileReader(f), getTypeFromObject(clazz));
|
||||
return retr == null ? defaultObj : retr;
|
||||
}
|
||||
|
||||
public static Object fromJson(File f, Type token) throws FileNotFoundException {
|
||||
return fromJson(f, token, gson);
|
||||
}
|
||||
|
||||
public static Object fromJson(File f, Type token, Gson gson) throws FileNotFoundException {
|
||||
return gson.fromJson(new FileReader(f), token);
|
||||
}
|
||||
|
||||
public static String toJSON(Object object, Object token) {
|
||||
return toJSON(object, token, gson);
|
||||
}
|
||||
|
||||
public static String toJSON(Object object, Object token, Gson gson) {
|
||||
return gson.toJson(object, getTypeFromObject(token));
|
||||
}
|
||||
|
||||
public static boolean saveJSONToFile(String fileName, Object toSave, Object token) throws IOException {
|
||||
return saveJSONToFile(getOrCreateFile(fileName), toSave, token);
|
||||
}
|
||||
|
||||
public static boolean saveJSONToFile(File f, Object toSave, Object token, Gson gson) throws IOException {
|
||||
String str = toJSON(toSave, token, gson);
|
||||
FileWriter writer = new FileWriter(f);
|
||||
writer.write(str);
|
||||
writer.flush();
|
||||
writer.close();
|
||||
return true;
|
||||
}
|
||||
|
||||
public static boolean saveJSONToFile(File f, Object toSave, Object token) throws IOException {
|
||||
try {
|
||||
return saveJSONToFile(f, toSave, token, gson);
|
||||
} catch (Throwable var4) {
|
||||
throw var4;
|
||||
}
|
||||
}
|
||||
|
||||
private static Type getTypeFromObject(Object object) {
|
||||
return object instanceof Type ? (Type)object : getTypeFromClass(object.getClass());
|
||||
}
|
||||
|
||||
private static Type getTypeFromClass(Class<?> clazz) {
|
||||
return TypeToken.of(clazz).getType();
|
||||
}
|
||||
}
|
||||
@@ -103,6 +103,18 @@ public class Persist {
|
||||
return DiscUtil.writeCatch(file, p.gson.toJson(instance), false);
|
||||
}
|
||||
|
||||
public boolean saveSync(Object instance) {
|
||||
return saveSync(instance, getFile(instance));
|
||||
}
|
||||
|
||||
public boolean saveSync(Object instance, String name) {
|
||||
return saveSync(instance, getFile(name));
|
||||
}
|
||||
|
||||
public boolean saveSync(Object instance, File file) {
|
||||
return DiscUtil.writeCatch(file, p.gson.toJson(instance), true);
|
||||
}
|
||||
|
||||
// LOAD BY CLASS
|
||||
|
||||
public <T> T load(Class<T> clazz) {
|
||||
|
||||
@@ -56,6 +56,12 @@ public enum TL {
|
||||
ACTIONS_MUSTBE("Youmust be {role} to {action}."),
|
||||
ACTIONS_NOSAMEROLE("{role} can't control each other..."),
|
||||
ACTIONS_NOFACTION("You are not member of any faction."),
|
||||
|
||||
ACTION_DENIED_SAFEZONE("You can't use %1$s in safezone!"),
|
||||
ACTION_DENIED_WARZONE("You can't use %1$s in warzone!"),
|
||||
ACTION_DENIED_WILDERNESS("You can't use %1$s in wilderness!"),
|
||||
ACTION_DENIED_OTHER("%1$s does not allow you to %2$s here!"),
|
||||
|
||||
/**
|
||||
* Command translations
|
||||
*/
|
||||
@@ -120,6 +126,8 @@ public enum TL {
|
||||
COMMAND_CONTEXT_ADMINISTER_MOD_REQUIRED("&c[!] You must be a faction moderator to do that."),
|
||||
|
||||
COMMAND_UPGRADES_DESCRIPTION("&cOpen the Upgrades Menu"),
|
||||
COMMAND_UPGRADES_DISABLED("&c[!] &7Faction Upgrades are &cdisabled&7."),
|
||||
|
||||
COMMAND_CORNER_CANT_CLAIM("&c&l[!] &cYou may not claim this corner!"),
|
||||
COMMAND_CORNER_CLAIMED("\n&2&l[!] &aYou have claimed the corner successfully, totalling in &b%1$d &achunks!\n"),
|
||||
COMMAND_CORNER_ATTEMPTING_CLAIM("&c&l[!] &7Attempting to claim corner..."),
|
||||
@@ -135,6 +143,7 @@ public enum TL {
|
||||
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 ðe leadership of &6%3$s&e."),
|
||||
COMMAND_ADMIN_PROMOTED_AUTOLEAVE("&e&l[!] &7Faction admin &c%s&7 has been removed. &c%s&7 has been promoted as the new faction admin."),
|
||||
COMMAND_ADMIN_DESCRIPTION("Hand over your admin rights"),
|
||||
COMMAND_ADMIN_NOMEMBERS("&e&l[!] &cNo one else to promote, please disband faction."),
|
||||
|
||||
@@ -362,6 +371,7 @@ public enum TL {
|
||||
COMMAND_DISBAND_IMMUTABLE("&c&l[!]&7 &7You &ccannot&7 disband &2Wilderness&7,&e SafeZone&7, or &4WarZone."),
|
||||
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_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"),
|
||||
@@ -405,6 +415,7 @@ public enum TL {
|
||||
COMMAND_HOME_DISABLED("&c&l[!]&7 Sorry, Faction homes are &cdisabled on this server."),
|
||||
COMMAND_HOME_TELEPORTDISABLED("&c&l[!]&7 Sorry, the ability to &cteleport &7to Faction homes is &cdisabled &7on this server."),
|
||||
COMMAND_HOME_NOHOME("&c&l[!]&7 Your faction does &cnot &7have a home. "),
|
||||
COMMAND_HOME_UNSET("&c&l[!]&7 Sorry, your faction home has been &cun-set &7since it is no longer in your territory."),
|
||||
COMMAND_HOME_INENEMY("&c&l[!]&7 You &ccannot teleport &7to your &cfaction home&7 while in the territory of an &cenemy faction&7."),
|
||||
COMMAND_HOME_WRONGWORLD("&c&l[!]&7 You &ccannot &7teleport to your &cfaction home&7 while in a different world."),
|
||||
COMMAND_HOME_ENEMYNEAR("&c&l[!]&7 You &ccannot teleport&7 to your faction home while an enemy is within &c%s&7 blocks of you."),
|
||||
@@ -541,6 +552,9 @@ public enum TL {
|
||||
COMMAND_MONEY_LONG("&c&l[!]&7 The faction money commands."),
|
||||
COMMAND_MONEY_DESCRIPTION("Faction money commands"),
|
||||
|
||||
COMMAND_MONEY_CANTAFFORD("&c&l[!]&7 &c%1$s&7 can't afford &c%2$s&7 %3$s"),
|
||||
COMMAND_MONEY_GAINED("&c&l[!]&7 &c%1$s&7 gained &c%2$s %2%6"),
|
||||
|
||||
COMMAND_MONEYBALANCE_SHORT("show faction balance"),
|
||||
COMMAND_MONEYBALANCE_DESCRIPTION("Show your factions current money balance"),
|
||||
|
||||
@@ -549,6 +563,8 @@ public enum TL {
|
||||
|
||||
COMMAND_MONEYTRANSFERFF_DESCRIPTION("Transfer f -> f"),
|
||||
COMMAND_MONEYTRANSFERFF_TRANSFER("&c&l[!]&7 &c%1$s&7 transferred&c %2$s &7from the faction &c\"%3$s\"&7 to the faction&c \"%4$s\"&7"),
|
||||
COMMAND_MONEYTRANSFERFF_TRANSFERCANTAFFORD("&c&l[!]&7 &c%1$s&7 can't afford to transfer &c%2$s &7to %3$s"),
|
||||
|
||||
|
||||
COMMAND_MONEYTRANSFERFP_DESCRIPTION("Transfer f -> plugin"),
|
||||
COMMAND_MONEYTRANSFERFP_TRANSFER("&c&l[!]&7 &c%1$s &7transferred&c %2$s &7from the faction&c \"%3$s\" &7to the player &c\"%4$s\""),
|
||||
@@ -861,6 +877,10 @@ public enum TL {
|
||||
COMMAND_TITLE_CHANGED("%1$s changed a title: %2$s"),
|
||||
COMMAND_TITLE_DESCRIPTION("Set or remove a players title"),
|
||||
|
||||
COMMAND_TITLETOGGLE_TOGGLED("You have changed your title setting to &c%1$s"),
|
||||
COMMAND_TITLETOGGLE_DESCRIPTION("Toggle titles to be served to you"),
|
||||
|
||||
|
||||
COMMAND_TOGGLEALLIANCECHAT_DESCRIPTION("Toggles whether or not you will see alliance chat"),
|
||||
COMMAND_TOGGLEALLIANCECHAT_IGNORE("Alliance chat is now ignored"),
|
||||
COMMAND_TOGGLEALLIANCECHAT_UNIGNORE("Alliance chat is no longer ignored"),
|
||||
@@ -882,7 +902,7 @@ public enum TL {
|
||||
COMMAND_TNT_WIDTHDRAW_SUCCESS("&cSuccessfully withdrew tnt."),
|
||||
COMMAND_TNT_WIDTHDRAW_NOTENOUGH("&cNot enough tnt in bank."),
|
||||
COMMAND_TNT_DEPOSIT_NOTENOUGH("&cNot enough tnt in tnt inventory."),
|
||||
COMMAND_TNT_AMOUNT("&cYour faction has %1$s tnt in the tnt bank."),
|
||||
COMMAND_TNT_AMOUNT("&cYour faction has {amount}/{maxAmount} tnt in the tnt bank."),
|
||||
COMMAND_TNT_POSITIVE("&cPlease use positive numbers!"),
|
||||
COMMAND_TNT_DESCRIPTION("add/widthraw from faction's tnt bank"),
|
||||
COMMAND_TNT_WIDTHDRAW_NOTENOUGH_SPACE("&cNot enough space in your inventory."),
|
||||
@@ -998,6 +1018,7 @@ public enum TL {
|
||||
GENERIC_YOU("you"),
|
||||
GENERIC_YOURFACTION("your faction"),
|
||||
GENERIC_NOPERMISSION("You don't have permission to %1$s."),
|
||||
GENERIC_ACTION_NOPERMISSION("You don't have permission to use %1$s"),
|
||||
GENERIC_FPERM_NOPERMISSION("&7The faction leader does not allow you to &c%1$s."),
|
||||
GENERIC_DOTHAT("do that"), //Ugh nuke this from high orbit
|
||||
GENERIC_NOPLAYERMATCH("No player match found for \"<plugin>%1$s\"."),
|
||||
@@ -1009,9 +1030,11 @@ public enum TL {
|
||||
GENERIC_PUBLICLAND("Public faction land."),
|
||||
GENERIC_FACTIONLESS("factionless"),
|
||||
GENERIC_SERVERADMIN("A server admin"),
|
||||
GENERIC_SERVER("Server"),
|
||||
GENERIC_DISABLED("disabled"),
|
||||
GENERIC_ENABLED("enabled"),
|
||||
GENERIC_INFINITY("∞"),
|
||||
GENERIC_NULLPLAYER("null player"),
|
||||
GENERIC_CONSOLEONLY("This command cannot be run as a player."),
|
||||
GENERIC_PLAYERONLY("This command can only be used by ingame players."),
|
||||
GENERIC_ASKYOURLEADER(" Ask your leader to:"),
|
||||
@@ -1032,7 +1055,7 @@ public enum TL {
|
||||
GENERIC_YOUMUSTBE("&cYour must be atleast %1$s to do this!"),
|
||||
GENERIC_MEMBERONLY("&cYou must be in a faction to do this!"),
|
||||
|
||||
|
||||
// MISSION_CREATED_COOLDOWN("&c&l[!] &7Due to your immediate faction creation, you may not start missions for &b%1$s minutes&7!"),
|
||||
MISSION_MISSION_STARTED("&f%1$s &dstarted the %2$s &fmission"),
|
||||
MISSION_ALREAD_COMPLETED("&c&l[!] &7You may not restart a mission you have already completed"),
|
||||
MISSION_MISSION_ACTIVE("&c&l[!] &7This mission is currently active!"),
|
||||
@@ -1075,8 +1098,19 @@ public enum TL {
|
||||
|
||||
ECON_OFF("no %s"), // no balance, no value, no refund, etc
|
||||
ECON_FORMAT("###,###.###"),
|
||||
ECON_MONEYTRASFERREDFROM("%1$s was transferred from %2$s to %3$s."),
|
||||
ECON_PERSONGAVEMONEYTO("%1$s gave %2$s to %3$s."),
|
||||
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_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."),
|
||||
ECON_DEPOSITFAILED("&c%s&7 would have gained &c%s&7 %s, but the deposit failed."),
|
||||
ECON_CANTCONTROLMONEY("&c%s&7 lacks permission to control &c%s&7's money."),
|
||||
ECON_MONEYTRASFERREDFROMPERSONTOPERSON("%1$s transferred %2$s from %3$s to %4$s."),
|
||||
|
||||
|
||||
/**
|
||||
* Relations
|
||||
|
||||
@@ -535,7 +535,7 @@ fperm-gui:
|
||||
- ''
|
||||
- '&4&l* &cStatus: &f{action-access-color}{action-access}'
|
||||
- ''
|
||||
- '&2&l* &aLeft click to &alAllow&a.'
|
||||
- '&2&l* &aLeft click to &a&lAllow&a.'
|
||||
- '&4&l* &cRight click to &c&lDeny&c.'
|
||||
- '&8&l* &7Middle click to &7&lUndefine&7.'
|
||||
# Back item will be take you to the previous GUI
|
||||
@@ -748,7 +748,7 @@ f-points:
|
||||
# | Faction Missions | #
|
||||
# +------------------------------------------------------+ #
|
||||
############################################################
|
||||
MissionGUISize: 3
|
||||
MissionGUISize: 4
|
||||
Missions-Enabled: true
|
||||
Missions-GUI-Title: '&8&lFaction Missions'
|
||||
MaximumMissionsAllowedAtOnce: 1
|
||||
@@ -767,14 +767,15 @@ Randomization:
|
||||
Material: GRAY_STAINED_GLASS_PANE
|
||||
Lore:
|
||||
- '&4%reason%'
|
||||
Slot: 23
|
||||
# in default configuration you will need to change the GUI size to 4 and for best results change the fillitem rows to 4 as well.
|
||||
Slot: 31
|
||||
DenyMissionsMoreThenOnce: true #this setting to true, means that if they complete a mission they cannot redo the same mission
|
||||
|
||||
#Mission Types: KILL, MINE, PLACE, FISH, TAME, ENCHANT, CONSUME
|
||||
Missions:
|
||||
FillItem:
|
||||
Material: BLACK_STAINED_GLASS_PANE
|
||||
Rows: 3
|
||||
Rows: 4
|
||||
sugarcane:
|
||||
Slot: 11
|
||||
Material: "SUGAR_CANE"
|
||||
@@ -1291,7 +1292,7 @@ fbanners:
|
||||
- SPEED:2
|
||||
BannerHolo: '&c{Faction}''s War Banner'
|
||||
Placeable:
|
||||
Warzone: true
|
||||
Warzone: false
|
||||
Enemy: true
|
||||
|
||||
#Title when moving between chunks
|
||||
@@ -1330,7 +1331,6 @@ Tntfill:
|
||||
max-radius: 32
|
||||
max-amount: 64
|
||||
|
||||
|
||||
############################################################
|
||||
# +------------------------------------------------------+ #
|
||||
# | Big List of variables | #
|
||||
|
||||
@@ -104,6 +104,7 @@ permissions:
|
||||
factions.show: true
|
||||
factions.stuck: true
|
||||
factions.tag: true
|
||||
factions.toggletitles: true
|
||||
factions.title: true
|
||||
factions.version: true
|
||||
factions.unclaim: true
|
||||
|
||||
Reference in New Issue
Block a user