Compare commits
21 Commits
2.0.5
...
2.0.7-BETA
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
0b127cbe72 | ||
|
|
4f6329996f | ||
|
|
3710031b80 | ||
|
|
6c10cdd47d | ||
|
|
5eeb8a2020 | ||
|
|
fe5378e9d7 | ||
|
|
e60d58e68b | ||
|
|
649392363f | ||
|
|
1927f49221 | ||
|
|
9349a914ce | ||
|
|
f8e22896d5 | ||
|
|
ac859db55f | ||
|
|
8c7addb68e | ||
|
|
d808bac17b | ||
|
|
d3a7fc67a5 | ||
|
|
bd77c8266c | ||
|
|
8bde1385fc | ||
|
|
472cb86465 | ||
|
|
d77ee76ea7 | ||
|
|
441382acdc | ||
|
|
d3870731f4 |
21
pom.xml
21
pom.xml
@@ -4,7 +4,7 @@
|
|||||||
|
|
||||||
<groupId>com.massivecraft</groupId>
|
<groupId>com.massivecraft</groupId>
|
||||||
<artifactId>Factions</artifactId>
|
<artifactId>Factions</artifactId>
|
||||||
<version>1.6.9.5-U0.2.1-2.0.5-BETA</version>
|
<version>1.6.9.5-U0.2.1-2.0.7-BETA</version>
|
||||||
<packaging>jar</packaging>
|
<packaging>jar</packaging>
|
||||||
|
|
||||||
<name>SaberFactions</name>
|
<name>SaberFactions</name>
|
||||||
@@ -126,6 +126,11 @@
|
|||||||
</exclusion>
|
</exclusion>
|
||||||
</exclusions>
|
</exclusions>
|
||||||
</dependency>
|
</dependency>
|
||||||
|
<dependency>
|
||||||
|
<groupId>org.ocpsoft.prettytime</groupId>
|
||||||
|
<artifactId>prettytime</artifactId>
|
||||||
|
<version>4.0.0.Final</version>
|
||||||
|
</dependency>
|
||||||
<dependency>
|
<dependency>
|
||||||
<groupId>net.milkbowl.vault</groupId>
|
<groupId>net.milkbowl.vault</groupId>
|
||||||
<artifactId>VaultAPI</artifactId>
|
<artifactId>VaultAPI</artifactId>
|
||||||
@@ -376,6 +381,12 @@
|
|||||||
</exclusion>
|
</exclusion>
|
||||||
</exclusions>
|
</exclusions>
|
||||||
</dependency>
|
</dependency>
|
||||||
|
<dependency>
|
||||||
|
<groupId>me.rayzr522</groupId>
|
||||||
|
<artifactId>jsonmessage</artifactId>
|
||||||
|
<version>1.0.0</version>
|
||||||
|
<scope>compile</scope>
|
||||||
|
</dependency>
|
||||||
<dependency>
|
<dependency>
|
||||||
<groupId>org.codemc.worldguardwrapper</groupId>
|
<groupId>org.codemc.worldguardwrapper</groupId>
|
||||||
<artifactId>worldguardwrapper</artifactId>
|
<artifactId>worldguardwrapper</artifactId>
|
||||||
@@ -411,6 +422,14 @@
|
|||||||
<id>spigot-repo</id>
|
<id>spigot-repo</id>
|
||||||
<url>https://hub.spigotmc.org/nexus/content/groups/public/</url>
|
<url>https://hub.spigotmc.org/nexus/content/groups/public/</url>
|
||||||
</repository>
|
</repository>
|
||||||
|
<repository>
|
||||||
|
<id>org.ocpsoft.prettytime</id>
|
||||||
|
<url>https://mvnrepository.com/artifact/org.ocpsoft.prettytime/prettytime</url>
|
||||||
|
</repository>
|
||||||
|
<repository>
|
||||||
|
<id>rayzr-repo</id>
|
||||||
|
<url>https://cdn.rawgit.com/Rayzr522/maven-repo/master/</url>
|
||||||
|
</repository>
|
||||||
<repository>
|
<repository>
|
||||||
<id>maven.sk89q.com</id>
|
<id>maven.sk89q.com</id>
|
||||||
<url>http://maven.sk89q.com/repo/</url>
|
<url>http://maven.sk89q.com/repo/</url>
|
||||||
|
|||||||
@@ -70,6 +70,7 @@ public class Conf {
|
|||||||
public static boolean chatTagEnabled = true;
|
public static boolean chatTagEnabled = true;
|
||||||
public static transient boolean chatTagHandledByAnotherPlugin = false;
|
public static transient boolean chatTagHandledByAnotherPlugin = false;
|
||||||
public static boolean chatTagRelationColored = true;
|
public static boolean chatTagRelationColored = true;
|
||||||
|
public static List<String> blacklistedFactionNames = new ArrayList<>();
|
||||||
public static String chatTagReplaceString = "[FACTION]";
|
public static String chatTagReplaceString = "[FACTION]";
|
||||||
public static String chatTagInsertAfterString = "";
|
public static String chatTagInsertAfterString = "";
|
||||||
public static String chatTagInsertBeforeString = "";
|
public static String chatTagInsertBeforeString = "";
|
||||||
@@ -230,6 +231,12 @@ public class Conf {
|
|||||||
public static Set<Material> territoryBypassProtectedMaterials = EnumSet.noneOf(Material.class);
|
public static Set<Material> territoryBypassProtectedMaterials = EnumSet.noneOf(Material.class);
|
||||||
// Dependency check
|
// Dependency check
|
||||||
public static boolean dependencyCheck = true;
|
public static boolean dependencyCheck = true;
|
||||||
|
|
||||||
|
public static 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
|
// Economy settings
|
||||||
public static boolean econEnabled = false;
|
public static boolean econEnabled = false;
|
||||||
public static String econUniverseAccount = "";
|
public static String econUniverseAccount = "";
|
||||||
@@ -342,6 +349,7 @@ public class Conf {
|
|||||||
// faction-<factionId>
|
// faction-<factionId>
|
||||||
public static int defaultMaxVaults = 0;
|
public static int defaultMaxVaults = 0;
|
||||||
public static boolean disableFlightOnFactionClaimChange = true;
|
public static boolean disableFlightOnFactionClaimChange = true;
|
||||||
|
public static boolean sendFactionChangeMessage = true;
|
||||||
|
|
||||||
public static Backend backEnd = Backend.JSON;
|
public static Backend backEnd = Backend.JSON;
|
||||||
|
|
||||||
@@ -378,6 +386,8 @@ public class Conf {
|
|||||||
static {
|
static {
|
||||||
baseCommandAliases.add("f");
|
baseCommandAliases.add("f");
|
||||||
|
|
||||||
|
blacklistedFactionNames.add("somenamehere");
|
||||||
|
|
||||||
territoryEnemyDenyCommands.add("home");
|
territoryEnemyDenyCommands.add("home");
|
||||||
territoryEnemyDenyCommands.add("sethome");
|
territoryEnemyDenyCommands.add("sethome");
|
||||||
territoryEnemyDenyCommands.add("spawn");
|
territoryEnemyDenyCommands.add("spawn");
|
||||||
@@ -385,11 +395,108 @@ public class Conf {
|
|||||||
territoryEnemyDenyCommands.add("tpaccept");
|
territoryEnemyDenyCommands.add("tpaccept");
|
||||||
territoryEnemyDenyCommands.add("tpa");
|
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
|
/// TODO: Consider removing this in a future release, as permissions works just fine now
|
||||||
territoryProtectedMaterials.add(Material.BEACON);
|
territoryProtectedMaterials.add(Material.BEACON);
|
||||||
|
|
||||||
// Config is not loading if value is empty ???
|
// Config is not loading if value is empty ???
|
||||||
territoryBypassProtectedMaterials.add(Material.COOKIE);
|
territoryBypassProtectedMaterials.add(Material.COOKIE);
|
||||||
|
territoryBypassProtectedMaterials.add(Material.CHEST);
|
||||||
|
territoryBypassProtectedMaterials.add(Material.TRAPPED_CHEST);
|
||||||
|
|
||||||
|
|
||||||
territoryDenyUsageMaterials.add(XMaterial.FIRE_CHARGE.parseMaterial());
|
territoryDenyUsageMaterials.add(XMaterial.FIRE_CHARGE.parseMaterial());
|
||||||
territoryDenyUsageMaterials.add(Material.FLINT_AND_STEEL);
|
territoryDenyUsageMaterials.add(Material.FLINT_AND_STEEL);
|
||||||
@@ -443,6 +550,8 @@ public class Conf {
|
|||||||
FactionsPlugin.getInstance().persist.save(i);
|
FactionsPlugin.getInstance().persist.save(i);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public static void saveSync() { FactionsPlugin.instance.persist.saveSync(i); }
|
||||||
|
|
||||||
public enum Backend {
|
public enum Backend {
|
||||||
JSON,
|
JSON,
|
||||||
//MYSQL, TODO add MySQL storage
|
//MYSQL, TODO add MySQL storage
|
||||||
|
|||||||
@@ -30,6 +30,17 @@ public interface FPlayer extends EconomyParticipator {
|
|||||||
|
|
||||||
boolean hasNotificationsEnabled();
|
boolean hasNotificationsEnabled();
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Used to determine if a player is in their faction's chest
|
||||||
|
* @return if player is in their faction's as a boolean
|
||||||
|
*/
|
||||||
|
boolean isInFactionsChest();
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Set if the player is inside of their faction's chest
|
||||||
|
*/
|
||||||
|
void setInFactionsChest(boolean b);
|
||||||
|
|
||||||
boolean isAlt();
|
boolean isAlt();
|
||||||
|
|
||||||
void setAlt(boolean alt);
|
void setAlt(boolean alt);
|
||||||
|
|||||||
@@ -440,5 +440,4 @@ public interface Faction extends EconomyParticipator {
|
|||||||
String getPaypal();
|
String getPaypal();
|
||||||
|
|
||||||
void paypalSet(String paypal);
|
void paypalSet(String paypal);
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -11,7 +11,6 @@ import com.massivecraft.factions.cmd.FCommand;
|
|||||||
import com.massivecraft.factions.cmd.check.CheckTask;
|
import com.massivecraft.factions.cmd.check.CheckTask;
|
||||||
import com.massivecraft.factions.cmd.check.WeeWooTask;
|
import com.massivecraft.factions.cmd.check.WeeWooTask;
|
||||||
import com.massivecraft.factions.cmd.chest.AntiChestListener;
|
import com.massivecraft.factions.cmd.chest.AntiChestListener;
|
||||||
import com.massivecraft.factions.cmd.chest.ChestLogsHandler;
|
|
||||||
import com.massivecraft.factions.discord.DiscordListener;
|
import com.massivecraft.factions.discord.DiscordListener;
|
||||||
import com.massivecraft.factions.discord.FactionChatHandler;
|
import com.massivecraft.factions.discord.FactionChatHandler;
|
||||||
import com.massivecraft.factions.integration.Econ;
|
import com.massivecraft.factions.integration.Econ;
|
||||||
@@ -90,6 +89,7 @@ public class FactionsPlugin extends MPlugin {
|
|||||||
private boolean mvdwPlaceholderAPIManager = false;
|
private boolean mvdwPlaceholderAPIManager = false;
|
||||||
private Listener[] eventsListener;
|
private Listener[] eventsListener;
|
||||||
public List<String> itemList = getConfig().getStringList("fchest.Items-Not-Allowed");
|
public List<String> itemList = getConfig().getStringList("fchest.Items-Not-Allowed");
|
||||||
|
private Worldguard wg;
|
||||||
|
|
||||||
|
|
||||||
public FactionsPlugin() {
|
public FactionsPlugin() {
|
||||||
@@ -185,17 +185,19 @@ public class FactionsPlugin extends MPlugin {
|
|||||||
// Load Conf from disk
|
// Load Conf from disk
|
||||||
Conf.load();
|
Conf.load();
|
||||||
//Dependency checks
|
//Dependency checks
|
||||||
if (Conf.dependencyCheck && (Bukkit.getPluginManager().isPluginEnabled("Vault") && Bukkit.getPluginManager().isPluginEnabled("Essentials"))) {
|
if (Conf.dependencyCheck && (!Bukkit.getPluginManager().isPluginEnabled("Vault") && !Bukkit.getPluginManager().isPluginEnabled("Essentials"))) {
|
||||||
RegisteredServiceProvider<Economy> rsp = FactionsPlugin.this.getServer().getServicesManager().getRegistration(Economy.class);
|
|
||||||
FactionsPlugin.econ = rsp.getProvider();
|
|
||||||
} else if (Conf.dependencyCheck) {
|
|
||||||
divider();
|
divider();
|
||||||
System.out.println("You are missing dependencies!");
|
System.out.println("You are missing dependencies!");
|
||||||
System.out.println("Please verify EssentialsX and Vault are installed!");
|
System.out.println("Please verify EssentialsX and Vault are installed!");
|
||||||
|
Conf.save();
|
||||||
Bukkit.getPluginManager().disablePlugin(instance);
|
Bukkit.getPluginManager().disablePlugin(instance);
|
||||||
divider();
|
divider();
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
//Update their config if needed
|
||||||
|
Updater.updateIfNeeded(getConfig());
|
||||||
|
RegisteredServiceProvider<Economy> rsp = FactionsPlugin.this.getServer().getServicesManager().getRegistration(Economy.class);
|
||||||
|
FactionsPlugin.econ = rsp.getProvider();
|
||||||
com.massivecraft.factions.integration.Essentials.setup();
|
com.massivecraft.factions.integration.Essentials.setup();
|
||||||
hookedPlayervaults = setupPlayervaults();
|
hookedPlayervaults = setupPlayervaults();
|
||||||
FPlayers.getInstance().load();
|
FPlayers.getInstance().load();
|
||||||
@@ -229,9 +231,7 @@ public class FactionsPlugin extends MPlugin {
|
|||||||
Econ.setup();
|
Econ.setup();
|
||||||
setupPermissions();
|
setupPermissions();
|
||||||
|
|
||||||
if (Conf.worldGuardChecking || Conf.worldGuardBuildPriority) {
|
if (Conf.worldGuardChecking || Conf.worldGuardBuildPriority) wg = new Worldguard();
|
||||||
Worldguard.init(this);
|
|
||||||
}
|
|
||||||
|
|
||||||
EngineDynmap.getInstance().init();
|
EngineDynmap.getInstance().init();
|
||||||
|
|
||||||
@@ -286,8 +286,7 @@ public class FactionsPlugin extends MPlugin {
|
|||||||
new FUpgradesGUI(),
|
new FUpgradesGUI(),
|
||||||
new UpgradesListener(),
|
new UpgradesListener(),
|
||||||
new MissionHandler(this),
|
new MissionHandler(this),
|
||||||
new AntiChestListener(),
|
new AntiChestListener()
|
||||||
new ChestLogsHandler()
|
|
||||||
};
|
};
|
||||||
|
|
||||||
for (Listener eventListener : eventsListener)
|
for (Listener eventListener : eventsListener)
|
||||||
@@ -426,9 +425,7 @@ public class FactionsPlugin extends MPlugin {
|
|||||||
public void onDisable() {
|
public void onDisable() {
|
||||||
// only save data if plugin actually completely loaded successfully
|
// only save data if plugin actually completely loaded successfully
|
||||||
if (this.loadSuccessful) {
|
if (this.loadSuccessful) {
|
||||||
// Dont save, as this is kind of pointless, as the /f config command manually saves.
|
Conf.saveSync();
|
||||||
// So any edits done are saved, this way manual edits to json can go through.
|
|
||||||
// Conf.save();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
if (AutoLeaveTask != null) {
|
if (AutoLeaveTask != null) {
|
||||||
|
|||||||
@@ -25,6 +25,10 @@ public class CmdAdmin extends FCommand {
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void perform(CommandContext context) {
|
public void perform(CommandContext context) {
|
||||||
|
if (context.player == null) {
|
||||||
|
context.msg(TL.GENERIC_PLAYERONLY);
|
||||||
|
return;
|
||||||
|
}
|
||||||
// Allows admins bypass this.
|
// Allows admins bypass this.
|
||||||
if (!context.fPlayer.isAdminBypassing() && !context.fPlayer.getRole().equals(Role.LEADER)) {
|
if (!context.fPlayer.isAdminBypassing() && !context.fPlayer.getRole().equals(Role.LEADER)) {
|
||||||
context.msg(TL.COMMAND_ADMIN_NOTADMIN);
|
context.msg(TL.COMMAND_ADMIN_NOTADMIN);
|
||||||
|
|||||||
@@ -78,18 +78,23 @@ public class CmdDisband extends FCommand {
|
|||||||
if (FactionsPlugin.getInstance().getConfig().getBoolean("faction-disband-broadcast", true)) {
|
if (FactionsPlugin.getInstance().getConfig().getBoolean("faction-disband-broadcast", true)) {
|
||||||
for (FPlayer follower : FPlayers.getInstance().getOnlinePlayers()) {
|
for (FPlayer follower : FPlayers.getInstance().getOnlinePlayers()) {
|
||||||
String amountString = context.sender instanceof ConsoleCommandSender ? TL.GENERIC_SERVERADMIN.toString() : context.fPlayer.describeTo(follower);
|
String amountString = context.sender instanceof ConsoleCommandSender ? TL.GENERIC_SERVERADMIN.toString() : context.fPlayer.describeTo(follower);
|
||||||
UtilFly.checkFly(context.fPlayer, Board.getInstance().getFactionAt(new FLocation(follower)));
|
|
||||||
if (follower.getFaction() == faction) {
|
if (follower.getFaction() == faction) {
|
||||||
follower.msg(TL.COMMAND_DISBAND_BROADCAST_YOURS, amountString);
|
follower.msg(TL.COMMAND_DISBAND_BROADCAST_YOURS, amountString);
|
||||||
|
if (!follower.canFlyAtLocation()) {
|
||||||
|
follower.setFFlying(false, false);
|
||||||
|
}
|
||||||
} else {
|
} else {
|
||||||
follower.msg(TL.COMMAND_DISBAND_BROADCAST_NOTYOURS, amountString, faction.getTag(follower));
|
follower.msg(TL.COMMAND_DISBAND_BROADCAST_NOTYOURS, amountString, faction.getTag(follower));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
faction.disband(context.player, PlayerDisbandReason.COMMAND);
|
context.fPlayer.setFFlying(false, false);
|
||||||
} else {
|
} else {
|
||||||
faction.disband(context.player, PlayerDisbandReason.COMMAND);
|
|
||||||
context.player.sendMessage(String.valueOf(TL.COMMAND_DISBAND_PLAYER));
|
context.player.sendMessage(String.valueOf(TL.COMMAND_DISBAND_PLAYER));
|
||||||
}
|
}
|
||||||
|
faction.disband(context.player, PlayerDisbandReason.COMMAND);
|
||||||
|
if (!context.fPlayer.canFlyAtLocation()) {
|
||||||
|
context.fPlayer.setFFlying(false, false);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -20,8 +20,8 @@ import java.util.concurrent.ConcurrentHashMap;
|
|||||||
public class CmdFly extends FCommand {
|
public class CmdFly extends FCommand {
|
||||||
|
|
||||||
|
|
||||||
public static ConcurrentHashMap<String, Boolean> flyMap = new ConcurrentHashMap<String, Boolean>();
|
public static ConcurrentHashMap<String, Boolean> flyMap = new ConcurrentHashMap<>();
|
||||||
public static int id = -1;
|
public static BukkitTask particleTask = null;
|
||||||
public static BukkitTask flyTask = null;
|
public static BukkitTask flyTask = null;
|
||||||
|
|
||||||
|
|
||||||
@@ -38,7 +38,7 @@ public class CmdFly extends FCommand {
|
|||||||
|
|
||||||
public static void startParticles() {
|
public static void startParticles() {
|
||||||
|
|
||||||
id = Bukkit.getScheduler().scheduleSyncRepeatingTask(FactionsPlugin.getInstance(), () -> {
|
particleTask = Bukkit.getScheduler().runTaskTimerAsynchronously(FactionsPlugin.instance, () -> {
|
||||||
for (String name : flyMap.keySet()) {
|
for (String name : flyMap.keySet()) {
|
||||||
Player player = Bukkit.getPlayer(name);
|
Player player = Bukkit.getPlayer(name);
|
||||||
if (player == null) continue;
|
if (player == null) continue;
|
||||||
@@ -49,11 +49,10 @@ public class CmdFly extends FCommand {
|
|||||||
|
|
||||||
FPlayer fplayer = FPlayers.getInstance().getByPlayer(player);
|
FPlayer fplayer = FPlayers.getInstance().getByPlayer(player);
|
||||||
fplayer.isVanished();
|
fplayer.isVanished();
|
||||||
|
|
||||||
}
|
}
|
||||||
if (flyMap.keySet().size() == 0) {
|
if (flyMap.isEmpty()) {
|
||||||
Bukkit.getScheduler().cancelTask(id);
|
particleTask.cancel();
|
||||||
id = -1;
|
particleTask = null;
|
||||||
}
|
}
|
||||||
}, 10L, 3L);
|
}, 10L, 3L);
|
||||||
}
|
}
|
||||||
@@ -117,20 +116,15 @@ public class CmdFly extends FCommand {
|
|||||||
return false;
|
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));
|
fme.msg(TL.COMMAND_FLY_NO_ACCESS, toFac.getTag(fme));
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
return me.hasPermission(Permission.FLY.node) && (access != Access.DENY || toFac.isSystemFaction());
|
return me.hasPermission(Permission.FLY.node) && (access != Access.DENY || toFac.isSystemFaction());
|
||||||
}
|
}
|
||||||
return true;
|
return fme.canFlyAtLocation();
|
||||||
}
|
}
|
||||||
|
|
||||||
public static Boolean isSystemFaction(Faction faction) {
|
|
||||||
return faction.isSafeZone() ||
|
|
||||||
faction.isWarZone() ||
|
|
||||||
faction.isWilderness();
|
|
||||||
}
|
|
||||||
|
|
||||||
public static void checkTaskState() {
|
public static void checkTaskState() {
|
||||||
if (flyMap.isEmpty()) {
|
if (flyMap.isEmpty()) {
|
||||||
@@ -192,6 +186,10 @@ public class CmdFly extends FCommand {
|
|||||||
context.doWarmUp(WarmUpUtil.Warmup.FLIGHT, TL.WARMUPS_NOTIFY_FLIGHT, "Fly", () -> {
|
context.doWarmUp(WarmUpUtil.Warmup.FLIGHT, TL.WARMUPS_NOTIFY_FLIGHT, "Fly", () -> {
|
||||||
fme.setFlying(true);
|
fme.setFlying(true);
|
||||||
flyMap.put(fme.getPlayer().getName(), true);
|
flyMap.put(fme.getPlayer().getName(), true);
|
||||||
|
if (particleTask == null) {
|
||||||
|
startParticles();
|
||||||
|
}
|
||||||
|
|
||||||
if (flyTask == null) {
|
if (flyTask == null) {
|
||||||
startFlyCheck();
|
startFlyCheck();
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -23,7 +23,7 @@ public class CmdHome extends FCommand {
|
|||||||
public CmdHome() {
|
public CmdHome() {
|
||||||
super();
|
super();
|
||||||
this.aliases.add("home");
|
this.aliases.add("home");
|
||||||
this.optionalArgs.put("home", "faction-name");
|
this.optionalArgs.put("faction", "yours");
|
||||||
|
|
||||||
this.requirements = new CommandRequirements.Builder(Permission.HOME)
|
this.requirements = new CommandRequirements.Builder(Permission.HOME)
|
||||||
.playerOnly()
|
.playerOnly()
|
||||||
@@ -45,10 +45,14 @@ public class CmdHome extends FCommand {
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (context.args.size() == 1) {
|
if (context.args.size() >= 1) {
|
||||||
Faction faction = context.argAsFaction(0);
|
Faction target = context.argAsFaction(0);
|
||||||
if (faction == null) return;
|
if (target == null) return;
|
||||||
context.faction = faction;
|
context.faction = target;
|
||||||
|
if (target.getAccess(context.fPlayer, PermissableAction.HOME) != Access.ALLOW) {
|
||||||
|
context.fPlayer.msg(TL.GENERIC_FPERM_NOPERMISSION, "teleport home");
|
||||||
|
return;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!context.faction.hasHome()) {
|
if (!context.faction.hasHome()) {
|
||||||
@@ -83,9 +87,9 @@ public class CmdHome extends FCommand {
|
|||||||
if (Conf.homesTeleportAllowedEnemyDistance > 0
|
if (Conf.homesTeleportAllowedEnemyDistance > 0
|
||||||
&& !faction.isSafeZone()
|
&& !faction.isSafeZone()
|
||||||
&& (!context.fPlayer.isInOwnTerritory()
|
&& (!context.fPlayer.isInOwnTerritory()
|
||||||
|| !Conf.homesTeleportIgnoreEnemiesIfInOwnTerritory)
|
|| (context.fPlayer.isInOwnTerritory()
|
||||||
&& (!Conf.homesTeleportIgnoreEnemiesIfInNoClaimingWorld
|
&& !Conf.homesTeleportIgnoreEnemiesIfInOwnTerritory))) {
|
||||||
|| !Conf.worldsNoClaiming.contains(context.fPlayer.getPlayer().getWorld().getName()))) {
|
|
||||||
World w = loc.getWorld();
|
World w = loc.getWorld();
|
||||||
double x = loc.getX();
|
double x = loc.getX();
|
||||||
double y = loc.getY();
|
double y = loc.getY();
|
||||||
|
|||||||
@@ -19,7 +19,6 @@ public class CmdLock extends FCommand {
|
|||||||
this.optionalArgs.put("on/off", "flip");
|
this.optionalArgs.put("on/off", "flip");
|
||||||
|
|
||||||
this.requirements = new CommandRequirements.Builder(Permission.LOCK)
|
this.requirements = new CommandRequirements.Builder(Permission.LOCK)
|
||||||
.playerOnly()
|
|
||||||
.build();
|
.build();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -52,6 +52,9 @@ public class CommandRequirements {
|
|||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (context.fPlayer.isAdminBypassing()) return true;
|
||||||
|
|
||||||
|
|
||||||
if (!FactionsPlugin.getInstance().perm.has(context.sender, permission.node, informIfNot)) return false;
|
if (!FactionsPlugin.getInstance().perm.has(context.sender, permission.node, informIfNot)) return false;
|
||||||
|
|
||||||
// Permissable Action provided compute that before role
|
// Permissable Action provided compute that before role
|
||||||
|
|||||||
@@ -12,6 +12,7 @@ public class CmdAlts extends FCommand {
|
|||||||
|
|
||||||
public CmdInviteAlt cmdInviteAlt = new CmdInviteAlt();
|
public CmdInviteAlt cmdInviteAlt = new CmdInviteAlt();
|
||||||
public CmdAltsList cmdAltsList = new CmdAltsList();
|
public CmdAltsList cmdAltsList = new CmdAltsList();
|
||||||
|
public CmdKickAlt cmdKickAlt = new CmdKickAlt();
|
||||||
|
|
||||||
|
|
||||||
public CmdAlts() {
|
public CmdAlts() {
|
||||||
@@ -22,6 +23,7 @@ public class CmdAlts extends FCommand {
|
|||||||
|
|
||||||
this.addSubCommand(this.cmdInviteAlt);
|
this.addSubCommand(this.cmdInviteAlt);
|
||||||
this.addSubCommand(this.cmdAltsList);
|
this.addSubCommand(this.cmdAltsList);
|
||||||
|
this.addSubCommand(this.cmdKickAlt);
|
||||||
|
|
||||||
this.requirements = new CommandRequirements.Builder(Permission.ALTS)
|
this.requirements = new CommandRequirements.Builder(Permission.ALTS)
|
||||||
.playerOnly()
|
.playerOnly()
|
||||||
|
|||||||
136
src/main/java/com/massivecraft/factions/cmd/alts/CmdKickAlt.java
Normal file
136
src/main/java/com/massivecraft/factions/cmd/alts/CmdKickAlt.java
Normal file
@@ -0,0 +1,136 @@
|
|||||||
|
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.fperms.Access;
|
||||||
|
import com.massivecraft.factions.zcore.fperms.PermissableAction;
|
||||||
|
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();
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
toKickFaction.removeAltPlayer(toKick);
|
||||||
|
toKickFaction.deinvite(toKick);
|
||||||
|
toKick.resetFactionData();
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public TL getUsageTranslation() {
|
||||||
|
return TL.COMMAND_ALTKICK_DESCRIPTION;
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
@@ -19,7 +19,7 @@ public class AntiChestListener implements Listener {
|
|||||||
public void onInventoryClick(InventoryClickEvent e) {
|
public void onInventoryClick(InventoryClickEvent e) {
|
||||||
Player player = (Player) e.getWhoClicked();
|
Player player = (Player) e.getWhoClicked();
|
||||||
FPlayer fPlayer = FPlayers.getInstance().getByPlayer(player);
|
FPlayer fPlayer = FPlayers.getInstance().getByPlayer(player);
|
||||||
if (!e.getView().getTopInventory().getTitle().equalsIgnoreCase(FactionsPlugin.getInstance().color(FactionsPlugin.getInstance().getConfig().getString("fchest.Inventory-Title")))) return;
|
if (!fPlayer.isInFactionsChest()) return;
|
||||||
|
|
||||||
if (e.isCancelled()) return;
|
if (e.isCancelled()) return;
|
||||||
|
|
||||||
@@ -49,7 +49,7 @@ public class AntiChestListener implements Listener {
|
|||||||
Player p = (Player) e.getWhoClicked();
|
Player p = (Player) e.getWhoClicked();
|
||||||
FPlayer fPlayer = FPlayers.getInstance().getByPlayer(p);
|
FPlayer fPlayer = FPlayers.getInstance().getByPlayer(p);
|
||||||
|
|
||||||
if (!e.getView().getTopInventory().getTitle().equalsIgnoreCase(FactionsPlugin.getInstance().color(FactionsPlugin.getInstance().getConfig().getString("fchest.Inventory-Title")))) return;
|
if (!fPlayer.isInFactionsChest()) return;
|
||||||
if (e.isCancelled()) return;
|
if (e.isCancelled()) return;
|
||||||
|
|
||||||
ItemStack dragged = e.getOldCursor();
|
ItemStack dragged = e.getOldCursor();
|
||||||
|
|||||||
@@ -1,123 +0,0 @@
|
|||||||
package com.massivecraft.factions.cmd.chest;
|
|
||||||
|
|
||||||
import com.massivecraft.factions.FPlayers;
|
|
||||||
import org.bukkit.Material;
|
|
||||||
import org.bukkit.entity.Player;
|
|
||||||
import org.bukkit.event.EventHandler;
|
|
||||||
import org.bukkit.event.Listener;
|
|
||||||
import org.bukkit.event.inventory.InventoryClickEvent;
|
|
||||||
import org.bukkit.inventory.Inventory;
|
|
||||||
import org.bukkit.inventory.ItemStack;
|
|
||||||
|
|
||||||
import java.util.ArrayList;
|
|
||||||
import java.util.HashMap;
|
|
||||||
import java.util.List;
|
|
||||||
import java.util.Map;
|
|
||||||
|
|
||||||
public class ChestLogsHandler implements Listener {
|
|
||||||
|
|
||||||
|
|
||||||
public static HashMap<String, List<String>> removeMap = new HashMap<>();
|
|
||||||
public static HashMap<String, List<String>> addMap = new HashMap<>();
|
|
||||||
public static HashMap<String, Integer> totalMap = new HashMap<>();
|
|
||||||
|
|
||||||
public static int getAll(String uuid) {
|
|
||||||
int t = 0;
|
|
||||||
t = t + removeMap.get(uuid).size();
|
|
||||||
t = t + addMap.get(uuid).size();
|
|
||||||
return t;
|
|
||||||
}
|
|
||||||
|
|
||||||
public static int getAll() {
|
|
||||||
int t = 0;
|
|
||||||
for (Map.Entry<String, List<String>> entry : removeMap.entrySet()) {
|
|
||||||
t = t + entry.getValue().size();
|
|
||||||
}
|
|
||||||
for (Map.Entry<String, List<String>> entry : addMap.entrySet()) {
|
|
||||||
t = t + entry.getValue().size();
|
|
||||||
}
|
|
||||||
return t;
|
|
||||||
}
|
|
||||||
|
|
||||||
public void mapAdd(String uuid, String string) {
|
|
||||||
List<String> list = new ArrayList<>();
|
|
||||||
if (addMap.get(uuid) != null) {
|
|
||||||
list = addMap.get(uuid);
|
|
||||||
}
|
|
||||||
list.add(string);
|
|
||||||
addMap.remove(uuid);
|
|
||||||
addMap.put(uuid, list);
|
|
||||||
|
|
||||||
if (totalMap.get(uuid) == null) {
|
|
||||||
totalMap.put(uuid, 1);
|
|
||||||
} else {
|
|
||||||
int t = totalMap.get(uuid);
|
|
||||||
totalMap.remove(uuid);
|
|
||||||
totalMap.put(uuid, t + 1);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
public void mapRemove(String uuid, String string) {
|
|
||||||
List<String> list = new ArrayList<>();
|
|
||||||
if (removeMap.get(uuid) != null) {
|
|
||||||
list = removeMap.get(uuid);
|
|
||||||
}
|
|
||||||
list.add(string);
|
|
||||||
removeMap.remove(uuid);
|
|
||||||
removeMap.put(uuid, list);
|
|
||||||
if (totalMap.get(uuid) == null) {
|
|
||||||
totalMap.put(uuid, 1);
|
|
||||||
} else {
|
|
||||||
int t = totalMap.get(uuid);
|
|
||||||
totalMap.remove(uuid);
|
|
||||||
totalMap.put(uuid, t + 1);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
public String itemString(ItemStack itemStack) {
|
|
||||||
String s = "x" + itemStack.getAmount() + " " + itemStack.getType().name().toLowerCase();
|
|
||||||
if (itemStack.hasItemMeta() && itemStack.getItemMeta().hasDisplayName()) {
|
|
||||||
s = s + " (" + itemStack.getItemMeta().getDisplayName() + ")";
|
|
||||||
}
|
|
||||||
return s.replace("_", " ");
|
|
||||||
}
|
|
||||||
|
|
||||||
@EventHandler
|
|
||||||
public void fChestInventoryClick(InventoryClickEvent e) {
|
|
||||||
Player p = (Player) e.getWhoClicked();
|
|
||||||
|
|
||||||
Inventory topInventory = p.getOpenInventory().getTopInventory();
|
|
||||||
Inventory bottomInventory = p.getOpenInventory().getBottomInventory();
|
|
||||||
if (topInventory != null) {
|
|
||||||
if (topInventory.equals(FPlayers.getInstance().getByPlayer(p).getFaction().getChestInventory())) {
|
|
||||||
|
|
||||||
if (e.getClickedInventory() != null) {
|
|
||||||
if (e.getClickedInventory().equals(topInventory)) {
|
|
||||||
ItemStack current = e.getCurrentItem();
|
|
||||||
if (current == null) return;
|
|
||||||
ItemStack cursor = e.getCursor();
|
|
||||||
if (e.getClick().isShiftClick()) return;
|
|
||||||
if (cursor != null) {
|
|
||||||
if (current.getType().equals(Material.AIR)) {
|
|
||||||
if (!cursor.getType().equals(Material.AIR)) {
|
|
||||||
mapAdd(p.getName(), itemString(cursor));
|
|
||||||
}
|
|
||||||
} else {
|
|
||||||
if (!current.getType().equals(Material.AIR)) {
|
|
||||||
mapRemove(p.getName(), itemString(current));
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
} else {
|
|
||||||
if (e.getClickedInventory().equals(bottomInventory)) {
|
|
||||||
//clicking from bottom inventory
|
|
||||||
if (e.getClick().isShiftClick()) {
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
@@ -30,6 +30,7 @@ public class CmdChest extends FCommand {
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
// This permission check is way too explicit but it's clean
|
// This permission check is way too explicit but it's clean
|
||||||
|
context.fPlayer.setInFactionsChest(true);
|
||||||
context.player.openInventory(context.faction.getChestInventory());
|
context.player.openInventory(context.faction.getChestInventory());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -31,11 +31,7 @@ public class CmdClaimAt extends FCommand {
|
|||||||
int x = context.argAsInt(1);
|
int x = context.argAsInt(1);
|
||||||
int z = context.argAsInt(2);
|
int z = context.argAsInt(2);
|
||||||
FLocation location = new FLocation(context.argAsString(0), x, z);
|
FLocation location = new FLocation(context.argAsString(0), x, z);
|
||||||
if (!((context.player.getLocation().getX() + (x * 16)) > (context.player.getLocation().getX() + (Conf.mapWidth * 16))) &&
|
context.fPlayer.attemptClaim(context.faction, location, true);
|
||||||
!((context.player.getLocation().getZ() + (z * 16)) > (context.player.getLocation().getZ() + (Conf.mapHeight * 16))) &&
|
|
||||||
!context.argAsString(0).equals(context.player.getLocation().getWorld().getName())) {
|
|
||||||
context.fPlayer.attemptClaim(context.faction, location, true);
|
|
||||||
} else context.fPlayer.msg(TL.COMMAND_CLAIM_DENIED);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
@@ -54,7 +54,9 @@ public class CmdUnclaim extends FCommand {
|
|||||||
|
|
||||||
if (radius == 1) {
|
if (radius == 1) {
|
||||||
// single chunk
|
// 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 {
|
} else {
|
||||||
// radius claim
|
// radius claim
|
||||||
if (!Permission.CLAIM_RADIUS.has(context.sender, false)) {
|
if (!Permission.CLAIM_RADIUS.has(context.sender, false)) {
|
||||||
|
|||||||
@@ -39,7 +39,7 @@ public class CmdMoneyBalance extends FCommand {
|
|||||||
}
|
}
|
||||||
|
|
||||||
if (context.fPlayer != null) {
|
if (context.fPlayer != null) {
|
||||||
Econ.sendBalanceInfo((CommandSender) context.fPlayer, faction);
|
Econ.sendBalanceInfo(context.sender, faction);
|
||||||
} else {
|
} else {
|
||||||
Econ.sendBalanceInfo(context.sender, faction);
|
Econ.sendBalanceInfo(context.sender, faction);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -29,7 +29,7 @@ public class CmdTnt extends FCommand {
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void perform(CommandContext context) {
|
public void perform(CommandContext context) {
|
||||||
if (!FactionsPlugin.getInstance().getConfig().getBoolean("ftnt.Enabled")) {
|
if (!FactionsPlugin.instance.getConfig().getBoolean("ftnt.Enabled")) {
|
||||||
context.msg(TL.COMMAND_TNT_DISABLED_MSG);
|
context.msg(TL.COMMAND_TNT_DISABLED_MSG);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
@@ -62,7 +62,7 @@ public class CmdTnt extends FCommand {
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
ItemStack tnt = new ItemStack(Material.TNT, amount);
|
ItemStack tnt = new ItemStack(Material.TNT, amount);
|
||||||
if (context.faction.getTnt() + amount > FactionsPlugin.getInstance().getConfig().getInt("ftnt.Bank-Limit")) {
|
if (context.faction.getTnt() + amount > FactionsPlugin.instance.getConfig().getInt("ftnt.Bank-Limit")) {
|
||||||
context.msg(TL.COMMAND_TNT_EXCEEDLIMIT);
|
context.msg(TL.COMMAND_TNT_EXCEEDLIMIT);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
@@ -71,7 +71,7 @@ public class CmdTnt extends FCommand {
|
|||||||
|
|
||||||
context.faction.addTnt(amount);
|
context.faction.addTnt(amount);
|
||||||
context.msg(TL.COMMAND_TNT_DEPOSIT_SUCCESS);
|
context.msg(TL.COMMAND_TNT_DEPOSIT_SUCCESS);
|
||||||
context.fPlayer.sendMessage(FactionsPlugin.getInstance().color(TL.COMMAND_TNT_AMOUNT.toString().replace("{amount}", context.fPlayer.getFaction().getTnt() + "")));
|
context.fPlayer.sendMessage(FactionsPlugin.instance.color(TL.COMMAND_TNT_AMOUNT.toString().replace("{amount}", context.fPlayer.getFaction().getTnt() + "")));
|
||||||
return;
|
return;
|
||||||
|
|
||||||
}
|
}
|
||||||
@@ -102,10 +102,8 @@ public class CmdTnt extends FCommand {
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
for (int i = 0; i <= fullStacks - 1; i++)
|
for (int i = 0; i <= fullStacks - 1; i++) context.player.getInventory().addItem(new ItemStack(XMaterial.TNT.parseMaterial(), 64));
|
||||||
context.player.getInventory().addItem(new ItemStack(XMaterial.TNT.parseMaterial(), 64));
|
if (remainderAmt != 0) context.player.getInventory().addItem(new ItemStack(XMaterial.TNT.parseMaterial(), remainderAmt));
|
||||||
if (remainderAmt != 0)
|
|
||||||
context.player.getInventory().addItem(new ItemStack(XMaterial.TNT.parseMaterial(), remainderAmt));
|
|
||||||
|
|
||||||
context.faction.takeTnt(amount);
|
context.faction.takeTnt(amount);
|
||||||
context.player.updateInventory();
|
context.player.updateInventory();
|
||||||
@@ -115,7 +113,7 @@ public class CmdTnt extends FCommand {
|
|||||||
context.msg(TL.GENERIC_ARGS_TOOFEW);
|
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.msg(context.args.get(0).equalsIgnoreCase("take") || context.args.get(0).equalsIgnoreCase("t") ? TL.COMMAND_TNT_TAKE_DESCRIPTION : TL.COMMAND_TNT_ADD_DESCRIPTION);
|
||||||
}
|
}
|
||||||
context.msg(TL.COMMAND_TNT_AMOUNT, context.faction.getTnt(), context.faction.getTntBankLimit());
|
context.sendMessage(TL.COMMAND_TNT_AMOUNT.toString().replace("{amount}", context.faction.getTnt() + ""));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@@ -134,7 +132,7 @@ public class CmdTnt extends FCommand {
|
|||||||
}
|
}
|
||||||
|
|
||||||
public boolean hasAvaliableSlot(Player player, int howmany) {
|
public boolean hasAvaliableSlot(Player player, int howmany) {
|
||||||
Integer check = 0;
|
int check = 0;
|
||||||
for (ItemStack item : player.getInventory().getContents()) {
|
for (ItemStack item : player.getInventory().getContents()) {
|
||||||
if (item == null) {
|
if (item == null) {
|
||||||
check++;
|
check++;
|
||||||
@@ -168,4 +166,3 @@ public class CmdTnt extends FCommand {
|
|||||||
return TL.COMMAND_TNT_DESCRIPTION;
|
return TL.COMMAND_TNT_DESCRIPTION;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -18,9 +18,7 @@ import org.bukkit.inventory.Inventory;
|
|||||||
import org.bukkit.inventory.ItemStack;
|
import org.bukkit.inventory.ItemStack;
|
||||||
import org.bukkit.inventory.PlayerInventory;
|
import org.bukkit.inventory.PlayerInventory;
|
||||||
|
|
||||||
import java.util.ArrayList;
|
import java.util.*;
|
||||||
import java.util.HashMap;
|
|
||||||
import java.util.List;
|
|
||||||
|
|
||||||
public class CmdTntFill extends FCommand {
|
public class CmdTntFill extends FCommand {
|
||||||
|
|
||||||
@@ -40,7 +38,7 @@ public class CmdTntFill extends FCommand {
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void perform(CommandContext context) {
|
public void perform(CommandContext context) {
|
||||||
if (!FactionsPlugin.getInstance().getConfig().getBoolean("Tntfill.enabled")) {
|
if (!FactionsPlugin.instance.getConfig().getBoolean("Tntfill.enabled")) {
|
||||||
context.msg(TL.GENERIC_DISABLED);
|
context.msg(TL.GENERIC_DISABLED);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
@@ -62,12 +60,12 @@ public class CmdTntFill extends FCommand {
|
|||||||
context.msg(TL.COMMAND_TNT_POSITIVE);
|
context.msg(TL.COMMAND_TNT_POSITIVE);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
if (radius > FactionsPlugin.getInstance().getConfig().getInt("Tntfill.max-radius")) {
|
if (radius > FactionsPlugin.instance.getConfig().getInt("Tntfill.max-radius")) {
|
||||||
context.msg(TL.COMMAND_TNTFILL_RADIUSMAX.toString().replace("{max}", FactionsPlugin.getInstance().getConfig().getInt("Tntfill.max-radius") + ""));
|
context.msg(TL.COMMAND_TNTFILL_RADIUSMAX.toString().replace("{max}", FactionsPlugin.instance.getConfig().getInt("Tntfill.max-radius") + ""));
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
if (amount > FactionsPlugin.getInstance().getConfig().getInt("Tntfill.max-amount")) {
|
if (amount > FactionsPlugin.instance.getConfig().getInt("Tntfill.max-amount")) {
|
||||||
context.msg(TL.COMMAND_TNTFILL_AMOUNTMAX.toString().replace("{max}", FactionsPlugin.getInstance().getConfig().getInt("Tntfill.max-amount") + ""));
|
context.msg(TL.COMMAND_TNTFILL_AMOUNTMAX.toString().replace("{max}", FactionsPlugin.instance.getConfig().getInt("Tntfill.max-amount") + ""));
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -108,19 +106,17 @@ public class CmdTntFill extends FCommand {
|
|||||||
}
|
}
|
||||||
|
|
||||||
// Take TNT from the bank.
|
// Take TNT from the bank.
|
||||||
context.faction.takeTnt(getFactionTnt);
|
removeFromBank(context, getFactionTnt);
|
||||||
}
|
}
|
||||||
fillDispensers(context.fPlayer, opDispensers, amount);
|
fillDispensers(context.fPlayer, opDispensers, amount);
|
||||||
// Remove used TNT from player inventory.
|
// Remove used TNT from player inventory.
|
||||||
context.sendMessage(TL.COMMAND_TNTFILL_SUCCESS.toString().replace("{amount}", requiredTnt + "").replace("{dispensers}", opDispensers.size() + ""));
|
context.sendMessage(TL.COMMAND_TNTFILL_SUCCESS.toString().replace("{amount}", requiredTnt + "").replace("{dispensers}", opDispensers.size() + ""));
|
||||||
}
|
}
|
||||||
|
|
||||||
// Actually fill every dispenser with the precise amount.
|
// Actually fill every dispenser with the precise amount.
|
||||||
private void fillDispensers(FPlayer fPlayer, List<Dispenser> dispensers, int count) {
|
private void fillDispensers(FPlayer fPlayer, List<Dispenser> dispensers, int count) {
|
||||||
for (Dispenser dispenser : dispensers) {
|
for (Dispenser dispenser : dispensers) {
|
||||||
if (takeTnt(fPlayer, count)) {
|
takeTnt(fPlayer, count);
|
||||||
dispenser.getInventory().addItem(new ItemStack(Material.TNT, count));
|
dispenser.getInventory().addItem(new ItemStack(Material.TNT, count));
|
||||||
} else {return;}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -161,7 +157,7 @@ public class CmdTntFill extends FCommand {
|
|||||||
context.player.updateInventory();
|
context.player.updateInventory();
|
||||||
}
|
}
|
||||||
|
|
||||||
private boolean takeTnt(FPlayer fme, int amount) {
|
private void takeTnt(FPlayer fme, int amount) {
|
||||||
Inventory inv = fme.getPlayer().getInventory();
|
Inventory inv = fme.getPlayer().getInventory();
|
||||||
int invTnt = 0;
|
int invTnt = 0;
|
||||||
for (int i = 0; i <= inv.getSize(); i++) {
|
for (int i = 0; i <= inv.getSize(); i++) {
|
||||||
@@ -174,15 +170,14 @@ public class CmdTntFill extends FCommand {
|
|||||||
}
|
}
|
||||||
if (amount > invTnt) {
|
if (amount > invTnt) {
|
||||||
fme.msg(TL.COMMAND_TNTFILL_NOTENOUGH.toString());
|
fme.msg(TL.COMMAND_TNTFILL_NOTENOUGH.toString());
|
||||||
return false;
|
return;
|
||||||
}
|
}
|
||||||
ItemStack tnt = new ItemStack(Material.TNT, amount);
|
ItemStack tnt = new ItemStack(Material.TNT, amount);
|
||||||
if (fme.getFaction().getTnt() + amount > FactionsPlugin.getInstance().getConfig().getInt("ftnt.Bank-Limit")) {
|
if (fme.getFaction().getTnt() + amount > FactionsPlugin.instance.getConfig().getInt("ftnt.Bank-Limit")) {
|
||||||
fme.msg(TL.COMMAND_TNT_EXCEEDLIMIT.toString());
|
fme.msg(TL.COMMAND_TNT_EXCEEDLIMIT.toString());
|
||||||
return false;
|
return;
|
||||||
}
|
}
|
||||||
removeFromInventory(fme.getPlayer().getInventory(), tnt);
|
removeFromInventory(fme.getPlayer().getInventory(), tnt);
|
||||||
return true;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// Counts the item type available in the inventory.
|
// Counts the item type available in the inventory.
|
||||||
|
|||||||
@@ -3,137 +3,288 @@ package com.massivecraft.factions.integration;
|
|||||||
import com.massivecraft.factions.FLocation;
|
import com.massivecraft.factions.FLocation;
|
||||||
import com.massivecraft.factions.FactionsPlugin;
|
import com.massivecraft.factions.FactionsPlugin;
|
||||||
import com.sk89q.worldedit.BlockVector;
|
import com.sk89q.worldedit.BlockVector;
|
||||||
import com.sk89q.worldedit.Vector;
|
|
||||||
import com.sk89q.worldguard.bukkit.WorldGuardPlugin;
|
import com.sk89q.worldguard.bukkit.WorldGuardPlugin;
|
||||||
|
import com.sk89q.worldguard.domains.Association;
|
||||||
import com.sk89q.worldguard.protection.ApplicableRegionSet;
|
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.managers.RegionManager;
|
||||||
import com.sk89q.worldguard.protection.regions.ProtectedCuboidRegion;
|
import com.sk89q.worldguard.protection.regions.ProtectedCuboidRegion;
|
||||||
import com.sk89q.worldguard.protection.regions.ProtectedRegion;
|
import com.sk89q.worldguard.protection.regions.ProtectedRegion;
|
||||||
|
import org.bukkit.Bukkit;
|
||||||
import org.bukkit.Chunk;
|
import org.bukkit.Chunk;
|
||||||
import org.bukkit.Location;
|
import org.bukkit.Location;
|
||||||
import org.bukkit.World;
|
import org.bukkit.World;
|
||||||
import org.bukkit.entity.Player;
|
import org.bukkit.entity.Player;
|
||||||
import org.bukkit.plugin.Plugin;
|
import org.bukkit.plugin.Plugin;
|
||||||
|
|
||||||
|
import java.lang.reflect.Constructor;
|
||||||
|
import java.lang.reflect.Method;
|
||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
import java.util.Collection;
|
import java.util.Collection;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
import java.util.Map;
|
|
||||||
|
|
||||||
import static com.sk89q.worldguard.bukkit.BukkitUtil.toVector;
|
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Worldguard Region Checking
|
* WorldGuard Permission Checking.
|
||||||
* Author: Spathizilla
|
* 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 {
|
public class Worldguard {
|
||||||
|
|
||||||
private static WorldGuardPlugin wg;
|
private Object worldGuard;
|
||||||
private static boolean enabled = false;
|
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) {
|
private static Worldguard instance;
|
||||||
Plugin wgplug = plugin.getServer().getPluginManager().getPlugin("WorldGuard");
|
|
||||||
if (wgplug == null || !(wgplug instanceof WorldGuardPlugin)) {
|
public Worldguard() {
|
||||||
enabled = false;
|
instance = this;
|
||||||
wg = null;
|
|
||||||
FactionsPlugin.getInstance().log("Could not hook to WorldGuard. WorldGuard checks are disabled.");
|
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 {
|
} else {
|
||||||
wg = (WorldGuardPlugin) wgplug;
|
associable = worldGuardPlugin.wrapPlayer(player);
|
||||||
enabled = true;
|
}
|
||||||
FactionsPlugin.getInstance().log("Successfully hooked to WorldGuard.");
|
|
||||||
|
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() {
|
private RegionManager getRegionManager(World world) {
|
||||||
return enabled;
|
initialize();
|
||||||
}
|
if (regionContainer == null || regionContainerGetMethod == null) return null;
|
||||||
|
RegionManager regionManager = null;
|
||||||
// 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;
|
|
||||||
|
|
||||||
try {
|
try {
|
||||||
overlaps = region.getIntersectingRegions(allregionslist);
|
if (worldAdaptMethod != null) {
|
||||||
foundregions = overlaps != null && !overlaps.isEmpty();
|
Object worldEditWorld = worldAdaptMethod.invoke(null, world);
|
||||||
} catch (Exception e) {
|
regionManager = (RegionManager)regionContainerGetMethod.invoke(regionContainer, worldEditWorld);
|
||||||
e.printStackTrace();
|
} 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,6 +5,7 @@ import com.massivecraft.factions.integration.Worldguard;
|
|||||||
import com.massivecraft.factions.struct.Permission;
|
import com.massivecraft.factions.struct.Permission;
|
||||||
import com.massivecraft.factions.struct.Relation;
|
import com.massivecraft.factions.struct.Relation;
|
||||||
import com.massivecraft.factions.struct.Role;
|
import com.massivecraft.factions.struct.Role;
|
||||||
|
import com.massivecraft.factions.util.ItemBuilder;
|
||||||
import com.massivecraft.factions.util.Particles.ParticleEffect;
|
import com.massivecraft.factions.util.Particles.ParticleEffect;
|
||||||
import com.massivecraft.factions.util.XMaterial;
|
import com.massivecraft.factions.util.XMaterial;
|
||||||
import com.massivecraft.factions.zcore.fperms.Access;
|
import com.massivecraft.factions.zcore.fperms.Access;
|
||||||
@@ -25,6 +26,7 @@ import org.bukkit.event.block.*;
|
|||||||
import org.bukkit.event.entity.EntityChangeBlockEvent;
|
import org.bukkit.event.entity.EntityChangeBlockEvent;
|
||||||
import org.bukkit.event.entity.EntityDamageEvent;
|
import org.bukkit.event.entity.EntityDamageEvent;
|
||||||
import org.bukkit.event.entity.EntityExplodeEvent;
|
import org.bukkit.event.entity.EntityExplodeEvent;
|
||||||
|
import org.bukkit.event.hanging.HangingBreakByEntityEvent;
|
||||||
import org.bukkit.inventory.ItemStack;
|
import org.bukkit.inventory.ItemStack;
|
||||||
import org.bukkit.inventory.meta.ItemMeta;
|
import org.bukkit.inventory.meta.ItemMeta;
|
||||||
import org.bukkit.potion.PotionEffect;
|
import org.bukkit.potion.PotionEffect;
|
||||||
@@ -40,54 +42,36 @@ public class FactionsBlockListener implements Listener {
|
|||||||
private HashMap<String, Boolean> bannerCooldownMap = new HashMap<>();
|
private HashMap<String, Boolean> bannerCooldownMap = new HashMap<>();
|
||||||
|
|
||||||
public static boolean playerCanBuildDestroyBlock(Player player, Location location, String action, boolean justCheck) {
|
public static boolean playerCanBuildDestroyBlock(Player player, Location location, String action, boolean justCheck) {
|
||||||
String name = player.getName();
|
|
||||||
|
|
||||||
if (Conf.playersWhoBypassAllProtection.contains(name))
|
if (Conf.playersWhoBypassAllProtection.contains(player.getName())) return true;
|
||||||
return true;
|
|
||||||
|
|
||||||
FPlayer me = FPlayers.getInstance().getById(player.getUniqueId().toString());
|
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);
|
FLocation loc = new FLocation(location);
|
||||||
Faction otherFaction = Board.getInstance().getFactionAt(loc);
|
Faction otherFaction = Board.getInstance().getFactionAt(loc);
|
||||||
|
Faction myFaction = me.getFaction();
|
||||||
|
|
||||||
if (otherFaction.isWilderness()) {
|
if (otherFaction.isWilderness()) {
|
||||||
if (Conf.worldGuardBuildPriority && Worldguard.playerCanBuild(player, location))
|
if (Conf.worldGuardBuildPriority && Worldguard.getInstance().playerCanBuild(player, location)) return true;
|
||||||
return true;
|
if (location.getWorld() != null) {
|
||||||
|
if (!Conf.wildernessDenyBuild || Conf.worldsNoWildernessProtection.contains(location.getWorld().getName()))
|
||||||
if (!Conf.wildernessDenyBuild || Conf.worldsNoWildernessProtection.contains(location.getWorld().getName()))
|
return true;
|
||||||
return true; // This is not faction territory. Use whatever you like here.
|
}
|
||||||
|
if (!justCheck) me.msg(TL.ACTION_DENIED_WILDERNESS, action);
|
||||||
if (!justCheck)
|
|
||||||
me.msg("<b>You can't " + action + " in the wilderness.");
|
|
||||||
|
|
||||||
return false;
|
return false;
|
||||||
} else if (otherFaction.isSafeZone()) {
|
} else if (otherFaction.isSafeZone()) {
|
||||||
if (Conf.worldGuardBuildPriority && Worldguard.playerCanBuild(player, location))
|
if (Conf.worldGuardBuildPriority && Worldguard.getInstance().playerCanBuild(player, location)) return true;
|
||||||
return true;
|
if (!Conf.safeZoneDenyBuild || Permission.MANAGE_SAFE_ZONE.has(player)) return true;
|
||||||
|
if (!justCheck) me.msg(TL.ACTION_DENIED_SAFEZONE, action);
|
||||||
if (!Conf.safeZoneDenyBuild || Permission.MANAGE_SAFE_ZONE.has(player))
|
|
||||||
return true;
|
|
||||||
|
|
||||||
if (!justCheck)
|
|
||||||
me.msg("<b>You can't " + action + " in a safe zone.");
|
|
||||||
|
|
||||||
return false;
|
return false;
|
||||||
} else if (otherFaction.isWarZone()) {
|
} else if (otherFaction.isWarZone()) {
|
||||||
if (Conf.worldGuardBuildPriority && Worldguard.playerCanBuild(player, location))
|
if (Conf.worldGuardBuildPriority && Worldguard.getInstance().playerCanBuild(player, location)) return true;
|
||||||
return true;
|
if (!Conf.warZoneDenyBuild || Permission.MANAGE_WAR_ZONE.has(player)) return true;
|
||||||
|
if (!justCheck) me.msg(TL.ACTION_DENIED_WARZONE, action);
|
||||||
if (!Conf.warZoneDenyBuild || Permission.MANAGE_WAR_ZONE.has(player))
|
|
||||||
return true;
|
|
||||||
|
|
||||||
if (!justCheck)
|
|
||||||
me.msg("<b>You can't " + action + " in a war zone.");
|
|
||||||
|
|
||||||
return false;
|
return false;
|
||||||
} else if (!otherFaction.getId().equals(myFaction.getId())) { // If the faction target is not my own
|
} 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;
|
return true;
|
||||||
// Get faction pain build access relation to me
|
// Get faction pain build access relation to me
|
||||||
boolean pain = !justCheck && otherFaction.getAccess(me, PermissableAction.PAIN_BUILD) == Access.ALLOW;
|
boolean pain = !justCheck && otherFaction.getAccess(me, PermissableAction.PAIN_BUILD) == Access.ALLOW;
|
||||||
@@ -110,16 +94,17 @@ public class FactionsBlockListener implements Listener {
|
|||||||
me.msg(TL.ACTIONS_OWNEDTERRITORYDENY.toString().replace("{owners}", myFaction.getOwnerListString(loc)));
|
me.msg(TL.ACTIONS_OWNEDTERRITORYDENY.toString().replace("{owners}", myFaction.getOwnerListString(loc)));
|
||||||
if (shouldHurt) {
|
if (shouldHurt) {
|
||||||
player.damage(Conf.actionDeniedPainAmount);
|
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;
|
return false;
|
||||||
} else if (!landOwned && access == Access.DENY) { // If land is not owned but access is set to DENY anyway
|
} else if (!landOwned && access == Access.DENY) { // If land is not owned but access is set to DENY anyway
|
||||||
if (shouldHurt) {
|
if (shouldHurt) {
|
||||||
player.damage(Conf.actionDeniedPainAmount);
|
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;
|
return false;
|
||||||
} else if (access == Access.ALLOW) return true;
|
} else if (access == Access.ALLOW) return true;
|
||||||
me.msg(TL.ACTIONS_NOPERMISSION.toString().replace("{faction}", myFaction.getTag(me.getFaction())).replace("{action}", action.toString()));
|
me.msg(TL.ACTIONS_NOPERMISSION.toString().replace("{faction}", myFaction.getTag(me.getFaction())).replace("{action}", action.toString()));
|
||||||
@@ -142,21 +127,18 @@ public class FactionsBlockListener implements Listener {
|
|||||||
|
|
||||||
@EventHandler(priority = EventPriority.NORMAL, ignoreCancelled = true)
|
@EventHandler(priority = EventPriority.NORMAL, ignoreCancelled = true)
|
||||||
public void onBlockPlace(BlockPlaceEvent event) {
|
public void onBlockPlace(BlockPlaceEvent event) {
|
||||||
if (!event.canBuild()) {
|
if (!event.canBuild()) return;
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
// special case for flint&steel, which should only be prevented by DenyUsage list
|
// special case for flint&steel, which should only be prevented by DenyUsage list
|
||||||
if (event.getBlockPlaced().getType() == Material.FIRE) {
|
if (event.getBlockPlaced().getType() == Material.FIRE) return;
|
||||||
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);
|
event.setCancelled(true);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (event.getBlock().getType().equals(XMaterial.SPAWNER.parseMaterial())) {
|
if (isSpawner) {
|
||||||
if (Conf.spawnerLock) {
|
if (Conf.spawnerLock) {
|
||||||
event.setCancelled(true);
|
event.setCancelled(true);
|
||||||
event.getPlayer().sendMessage(FactionsPlugin.getInstance().color(TL.COMMAND_SPAWNER_LOCK_CANNOT_PLACE.toString()));
|
event.getPlayer().sendMessage(FactionsPlugin.getInstance().color(TL.COMMAND_SPAWNER_LOCK_CANNOT_PLACE.toString()));
|
||||||
@@ -166,17 +148,12 @@ public class FactionsBlockListener implements Listener {
|
|||||||
|
|
||||||
@EventHandler(priority = EventPriority.NORMAL, ignoreCancelled = true)
|
@EventHandler(priority = EventPriority.NORMAL, ignoreCancelled = true)
|
||||||
public void onBlockFromTo(BlockFromToEvent event) {
|
public void onBlockFromTo(BlockFromToEvent event) {
|
||||||
if (!Conf.handleExploitLiquidFlow) {
|
if (!Conf.handleExploitLiquidFlow) return;
|
||||||
return;
|
|
||||||
}
|
|
||||||
if (event.getBlock().isLiquid()) {
|
if (event.getBlock().isLiquid()) {
|
||||||
if (event.getToBlock().isEmpty()) {
|
if (event.getToBlock().isEmpty()) {
|
||||||
Faction from = Board.getInstance().getFactionAt(new FLocation(event.getBlock()));
|
Faction from = Board.getInstance().getFactionAt(new FLocation(event.getBlock()));
|
||||||
Faction to = Board.getInstance().getFactionAt(new FLocation(event.getToBlock()));
|
Faction to = Board.getInstance().getFactionAt(new FLocation(event.getToBlock()));
|
||||||
if (from == to) {
|
if (from == to) return;
|
||||||
// not concerned with inter-faction events
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
// from faction != to faction
|
// from faction != to faction
|
||||||
if (to.isNormal()) {
|
if (to.isNormal()) {
|
||||||
if (from.isNormal() && from.getRelationTo(to).isAlly()) {
|
if (from.isNormal() && from.getRelationTo(to).isAlly()) {
|
||||||
@@ -197,31 +174,27 @@ public class FactionsBlockListener implements Listener {
|
|||||||
|
|
||||||
@EventHandler(priority = EventPriority.NORMAL, ignoreCancelled = true)
|
@EventHandler(priority = EventPriority.NORMAL, ignoreCancelled = true)
|
||||||
public void onBlockPistonExtend(BlockPistonExtendEvent event) {
|
public void onBlockPistonExtend(BlockPistonExtendEvent event) {
|
||||||
if (!Conf.pistonProtectionThroughDenyBuild) {
|
if (!Conf.pistonProtectionThroughDenyBuild) return;
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
Faction pistonFaction = Board.getInstance().getFactionAt(new FLocation(event.getBlock()));
|
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
|
// 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);
|
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 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);
|
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
|
@EventHandler
|
||||||
public void onVaultPlace(BlockPlaceEvent e) {
|
public void onVaultPlace(BlockPlaceEvent e) {
|
||||||
if (e.getItemInHand().getType() == Material.CHEST) {
|
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)) {
|
if (e.getItemInHand().isSimilar(vault)) {
|
||||||
FPlayer fme = FPlayers.getInstance().getByPlayer(e.getPlayer());
|
FPlayer fme = FPlayers.getInstance().getByPlayer(e.getPlayer());
|
||||||
if (fme.getFaction().getVault() != null) {
|
if (fme.getFaction().getVault() != null) {
|
||||||
@@ -244,10 +217,8 @@ public class FactionsBlockListener implements Listener {
|
|||||||
if (blockLoc.getX() == start.getLocation().getX() && blockLoc.getY() == start.getLocation().getY() && blockLoc.getZ() == start.getLocation().getZ()) {
|
if (blockLoc.getX() == start.getLocation().getX() && blockLoc.getY() == start.getLocation().getY() && blockLoc.getZ() == start.getLocation().getZ()) {
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
|
||||||
Material blockMaterial = blockLoc.getBlock().getType();
|
Material blockMaterial = blockLoc.getBlock().getType();
|
||||||
|
if (blockMaterial == Material.CHEST || (FactionsPlugin.instance.getConfig().getBoolean("fvault.No-Hoppers-near-vault") && blockMaterial == Material.HOPPER)) {
|
||||||
if (blockMaterial == Material.CHEST || (FactionsPlugin.getInstance().getConfig().getBoolean("fvault.No-Hoppers-near-vault") && blockMaterial == Material.HOPPER)) {
|
|
||||||
e.setCancelled(true);
|
e.setCancelled(true);
|
||||||
fme.msg(TL.COMMAND_GETVAULT_CHESTNEAR);
|
fme.msg(TL.COMMAND_GETVAULT_CHESTNEAR);
|
||||||
return;
|
return;
|
||||||
@@ -255,7 +226,6 @@ public class FactionsBlockListener implements Listener {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
fme.msg(TL.COMMAND_GETVAULT_SUCCESS);
|
fme.msg(TL.COMMAND_GETVAULT_SUCCESS);
|
||||||
fme.getFaction().setVault(e.getBlockPlaced().getLocation());
|
fme.getFaction().setVault(e.getBlockPlaced().getLocation());
|
||||||
|
|
||||||
@@ -263,21 +233,12 @@ public class FactionsBlockListener implements Listener {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@EventHandler (ignoreCancelled = true)
|
@EventHandler
|
||||||
public void onHopperPlace(BlockPlaceEvent e) {
|
public void onHopperPlace(BlockPlaceEvent e) {
|
||||||
if (e.getItemInHand().getType() != Material.HOPPER || !FactionsPlugin.getInstance().getConfig().getBoolean("fvault.No-Hoppers-near-vault")) {
|
if (e.getItemInHand().getType() != Material.HOPPER && !FactionsPlugin.instance.getConfig().getBoolean("fvault.No-Hoppers-near-vault")) return;
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
Faction factionAt = Board.getInstance().getFactionAt(new FLocation(e.getBlockPlaced().getLocation()));
|
Faction factionAt = Board.getInstance().getFactionAt(new FLocation(e.getBlockPlaced().getLocation()));
|
||||||
|
if (factionAt.isWilderness() || factionAt.getVault() == null) return;
|
||||||
if (factionAt.isWilderness() || factionAt.getVault() == null) {
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
FPlayer fme = FPlayers.getInstance().getByPlayer(e.getPlayer());
|
FPlayer fme = FPlayers.getInstance().getByPlayer(e.getPlayer());
|
||||||
|
|
||||||
Block start = e.getBlockPlaced();
|
Block start = e.getBlockPlaced();
|
||||||
int radius = 1;
|
int radius = 1;
|
||||||
for (double x = start.getLocation().getX() - radius; x <= start.getLocation().getX() + radius; x++) {
|
for (double x = start.getLocation().getX() - radius; x <= start.getLocation().getX() + radius; x++) {
|
||||||
@@ -288,7 +249,7 @@ public class FactionsBlockListener implements Listener {
|
|||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (blockLoc.getBlock().getType() == Material.CHEST) {
|
if (blockLoc.getBlock().getType() == XMaterial.CHEST.parseMaterial()) {
|
||||||
if (factionAt.getVault().equals(blockLoc)) {
|
if (factionAt.getVault().equals(blockLoc)) {
|
||||||
e.setCancelled(true);
|
e.setCancelled(true);
|
||||||
fme.msg(TL.COMMAND_VAULT_NO_HOPPER);
|
fme.msg(TL.COMMAND_VAULT_NO_HOPPER);
|
||||||
@@ -304,32 +265,21 @@ public class FactionsBlockListener implements Listener {
|
|||||||
@EventHandler(priority = EventPriority.NORMAL, ignoreCancelled = true)
|
@EventHandler(priority = EventPriority.NORMAL, ignoreCancelled = true)
|
||||||
public void onBlockPistonRetract(BlockPistonRetractEvent event) {
|
public void onBlockPistonRetract(BlockPistonRetractEvent event) {
|
||||||
// if not a sticky piston, retraction should be fine
|
// if not a sticky piston, retraction should be fine
|
||||||
if (!event.isSticky() || !Conf.pistonProtectionThroughDenyBuild) {
|
if (!event.isSticky() || !Conf.pistonProtectionThroughDenyBuild) return;
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (event.getBlocks().isEmpty()) {
|
Location targetLoc = event.getRetractLocation();
|
||||||
return;
|
|
||||||
}
|
|
||||||
Location targetLoc = event.getBlocks().get(0).getLocation();
|
|
||||||
Faction otherFaction = Board.getInstance().getFactionAt(new FLocation(targetLoc));
|
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.
|
// 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);
|
event.setCancelled(true);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
// if potentially retracted block is just air/water/lava, no worries
|
// if potentially retracted block is just air/water/lava, no worries
|
||||||
if (targetLoc.getBlock().isEmpty() || targetLoc.getBlock().isLiquid()) {
|
if (targetLoc.getBlock().isEmpty() || targetLoc.getBlock().isLiquid()) return;
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
Faction pistonFaction = Board.getInstance().getFactionAt(new FLocation(event.getBlock()));
|
Faction pistonFaction = Board.getInstance().getFactionAt(new FLocation(event.getBlock()));
|
||||||
|
if (!canPistonMoveBlock(pistonFaction, targetLoc)) event.setCancelled(true);
|
||||||
if (!canPistonMoveBlock(pistonFaction, targetLoc)) {
|
|
||||||
event.setCancelled(true);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@EventHandler
|
@EventHandler
|
||||||
@@ -349,16 +299,13 @@ public class FactionsBlockListener implements Listener {
|
|||||||
|
|
||||||
@EventHandler
|
@EventHandler
|
||||||
public void onBannerPlace(BlockPlaceEvent e) {
|
public void onBannerPlace(BlockPlaceEvent e) {
|
||||||
if (FactionsPlugin.getInstance().mc17) {
|
if (FactionsPlugin.getInstance().mc17) return;
|
||||||
return;
|
|
||||||
}
|
|
||||||
if (e.getItemInHand().getType().name().contains("BANNER")) {
|
if (e.getItemInHand().getType().name().contains("BANNER")) {
|
||||||
ItemStack bannerInHand = e.getItemInHand();
|
ItemStack bannerInHand = e.getItemInHand();
|
||||||
FPlayer fme = FPlayers.getInstance().getByPlayer(e.getPlayer());
|
FPlayer fme = FPlayers.getInstance().getByPlayer(e.getPlayer());
|
||||||
ItemStack warBanner = fme.getFaction().getBanner();
|
ItemStack warBanner = fme.getFaction().getBanner();
|
||||||
if (warBanner == null) {
|
if (warBanner == null) return;
|
||||||
return;
|
|
||||||
}
|
|
||||||
ItemMeta warmeta = warBanner.getItemMeta();
|
ItemMeta warmeta = warBanner.getItemMeta();
|
||||||
warmeta.setDisplayName(FactionsPlugin.getInstance().color(FactionsPlugin.getInstance().getConfig().getString("fbanners.Item.Name")));
|
warmeta.setDisplayName(FactionsPlugin.getInstance().color(FactionsPlugin.getInstance().getConfig().getString("fbanners.Item.Name")));
|
||||||
warmeta.setLore(FactionsPlugin.getInstance().colorList(FactionsPlugin.getInstance().getConfig().getStringList("fbanners.Item.Lore")));
|
warmeta.setLore(FactionsPlugin.getInstance().colorList(FactionsPlugin.getInstance().getConfig().getStringList("fbanners.Item.Lore")));
|
||||||
@@ -440,9 +387,8 @@ public class FactionsBlockListener implements Listener {
|
|||||||
|
|
||||||
@EventHandler(priority = EventPriority.NORMAL, ignoreCancelled = true)
|
@EventHandler(priority = EventPriority.NORMAL, ignoreCancelled = true)
|
||||||
public void onFrostWalker(EntityBlockFormEvent event) {
|
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;
|
return;
|
||||||
}
|
|
||||||
|
|
||||||
Player player = (Player) event.getEntity();
|
Player player = (Player) event.getEntity();
|
||||||
Location location = event.getBlock().getLocation();
|
Location location = event.getBlock().getLocation();
|
||||||
@@ -450,14 +396,10 @@ public class FactionsBlockListener implements Listener {
|
|||||||
// only notify every 10 seconds
|
// only notify every 10 seconds
|
||||||
FPlayer fPlayer = FPlayers.getInstance().getByPlayer(player);
|
FPlayer fPlayer = FPlayers.getInstance().getByPlayer(player);
|
||||||
boolean justCheck = fPlayer.getLastFrostwalkerMessage() + 10000 > System.currentTimeMillis();
|
boolean justCheck = fPlayer.getLastFrostwalkerMessage() + 10000 > System.currentTimeMillis();
|
||||||
if (!justCheck) {
|
if (!justCheck) fPlayer.setLastFrostwalkerMessage();
|
||||||
fPlayer.setLastFrostwalkerMessage();
|
|
||||||
}
|
|
||||||
|
|
||||||
// Check if they have build permissions here. If not, block this from happening.
|
// Check if they have build permissions here. If not, block this from happening.
|
||||||
if (!playerCanBuildDestroyBlock(player, location, "frostwalk", justCheck)) {
|
if (!playerCanBuildDestroyBlock(player, location, "frostwalk", justCheck)) event.setCancelled(true);
|
||||||
event.setCancelled(true);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@EventHandler
|
@EventHandler
|
||||||
@@ -506,41 +448,36 @@ public class FactionsBlockListener implements Listener {
|
|||||||
}
|
}
|
||||||
|
|
||||||
private boolean canPistonMoveBlock(Faction pistonFaction, Location target) {
|
private boolean canPistonMoveBlock(Faction pistonFaction, Location target) {
|
||||||
|
|
||||||
Faction otherFaction = Board.getInstance().getFactionAt(new FLocation(target));
|
Faction otherFaction = Board.getInstance().getFactionAt(new FLocation(target));
|
||||||
|
|
||||||
if (pistonFaction == otherFaction)
|
if (pistonFaction == otherFaction) return true;
|
||||||
return true;
|
|
||||||
|
|
||||||
if (otherFaction.isWilderness())
|
if (otherFaction.isWilderness())
|
||||||
return !Conf.wildernessDenyBuild || Conf.worldsNoWildernessProtection.contains(target.getWorld().getName());
|
return !Conf.wildernessDenyBuild || Conf.worldsNoWildernessProtection.contains(target.getWorld().getName());
|
||||||
|
else if (otherFaction.isSafeZone()) return !Conf.safeZoneDenyBuild;
|
||||||
else if (otherFaction.isSafeZone())
|
else if (otherFaction.isWarZone()) return !Conf.warZoneDenyBuild;
|
||||||
return !Conf.safeZoneDenyBuild;
|
|
||||||
|
|
||||||
else if (otherFaction.isWarZone())
|
|
||||||
return !Conf.warZoneDenyBuild;
|
|
||||||
|
|
||||||
Relation rel = pistonFaction.getRelationTo(otherFaction);
|
Relation rel = pistonFaction.getRelationTo(otherFaction);
|
||||||
|
|
||||||
return !rel.confDenyBuild(otherFaction.hasPlayersOnline());
|
return !rel.confDenyBuild(otherFaction.hasPlayersOnline());
|
||||||
}
|
}
|
||||||
|
|
||||||
@EventHandler(priority = EventPriority.NORMAL, ignoreCancelled = true)
|
@EventHandler(priority = EventPriority.NORMAL, ignoreCancelled = true)
|
||||||
public void onBlockBreak(BlockBreakEvent event) {
|
public void onBlockBreak(BlockBreakEvent event) {
|
||||||
FPlayer fme = FPlayers.getInstance().getByPlayer(event.getPlayer());
|
boolean isSpawner = event.getBlock().getType() == XMaterial.SPAWNER.parseMaterial();
|
||||||
if (!playerCanBuildDestroyBlock(event.getPlayer(), event.getBlock().getLocation(), "destroy", false)) {
|
if (!playerCanBuildDestroyBlock(event.getPlayer(), event.getBlock().getLocation(), !isSpawner ? "destroy" : "mine spawners", false)) {
|
||||||
event.setCancelled(true);
|
event.setCancelled(true);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
if (!fme.hasFaction())
|
}
|
||||||
return;
|
|
||||||
|
|
||||||
if (event.getBlock().getType() == XMaterial.SPAWNER.parseMaterial()) {
|
@EventHandler(priority = EventPriority.HIGHEST)
|
||||||
if (!fme.isAdminBypassing()) {
|
public void FrameRemove(HangingBreakByEntityEvent event) {
|
||||||
Access access = fme.getFaction().getAccess(fme, PermissableAction.SPAWNER);
|
if (event.getRemover() == null) return;
|
||||||
if (access != Access.ALLOW && fme.getRole() != Role.LEADER) {
|
if ((event.getRemover() instanceof Player)) {
|
||||||
fme.msg(TL.GENERIC_FPERM_NOPERMISSION, "mine spawners");
|
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 +488,9 @@ public class FactionsBlockListener implements Listener {
|
|||||||
if (event.getEntity() instanceof Player) {
|
if (event.getEntity() instanceof Player) {
|
||||||
Player player = (Player) event.getEntity();
|
Player player = (Player) event.getEntity();
|
||||||
if (!playerCanBuildDestroyBlock(player, event.getBlock().getLocation(), PermissableAction.DESTROY.name(), true)) {
|
if (!playerCanBuildDestroyBlock(player, event.getBlock().getLocation(), 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 otherFaction = Board.getInstance().getFactionAt(new FLocation(event.getBlock().getLocation()));
|
||||||
Faction myFaction = me.getFaction();
|
me.msg(TL.ACTION_DENIED_OTHER, otherFaction.getTag(), "trample crops");
|
||||||
|
|
||||||
me.msg("<b>You can't jump on farmland in the territory of " + otherFaction.getTag(myFaction));
|
|
||||||
event.setCancelled(true);
|
event.setCancelled(true);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -139,7 +139,6 @@ public class FactionsEntityListener implements Listener {
|
|||||||
// this should trigger if the attacker shootin the arrow is a mob
|
// this should trigger if the attacker shootin the arrow is a mob
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
@@ -226,25 +225,18 @@ public class FactionsEntityListener implements Listener {
|
|||||||
}
|
}
|
||||||
|
|
||||||
private void cancelFFly(Player player) {
|
private void cancelFFly(Player player) {
|
||||||
if (player == null) {
|
if (player == null) return;
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
FPlayer fPlayer = FPlayers.getInstance().getByPlayer(player);
|
FPlayer fPlayer = FPlayers.getInstance().getByPlayer(player);
|
||||||
if (fPlayer.isFlying()) {
|
if (fPlayer.isFlying()) fPlayer.setFFlying(false, true);
|
||||||
fPlayer.setFFlying(false, true);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public void cancelFStuckTeleport(Player player) {
|
public void cancelFStuckTeleport(Player player) {
|
||||||
if (player == null) {
|
if (player == null) return;
|
||||||
return;
|
|
||||||
}
|
|
||||||
UUID uuid = player.getUniqueId();
|
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);
|
FPlayers.getInstance().getByPlayer(player).msg(TL.COMMAND_STUCK_CANCELLED);
|
||||||
FactionsPlugin.getInstance().getStuckMap().remove(uuid);
|
FactionsPlugin.getInstance().getStuckMap().remove(uuid);
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@EventHandler(priority = EventPriority.NORMAL, ignoreCancelled = true)
|
@EventHandler(priority = EventPriority.NORMAL, ignoreCancelled = true)
|
||||||
@@ -294,10 +286,9 @@ public class FactionsEntityListener implements Listener {
|
|||||||
private boolean checkExplosionForBlock(Entity boomer, Block block) {
|
private boolean checkExplosionForBlock(Entity boomer, Block block) {
|
||||||
Faction faction = Board.getInstance().getFactionAt(new FLocation(block.getLocation()));
|
Faction faction = Board.getInstance().getFactionAt(new FLocation(block.getLocation()));
|
||||||
|
|
||||||
if (faction.noExplosionsInTerritory() || (faction.isPeaceful() && Conf.peacefulTerritoryDisableBoom)) {
|
if (faction.noExplosionsInTerritory() || (faction.isPeaceful() && Conf.peacefulTerritoryDisableBoom))
|
||||||
// faction is peaceful and has explosions set to disabled
|
|
||||||
return false;
|
return false;
|
||||||
}
|
// faction is peaceful and has explosions set to disabled
|
||||||
|
|
||||||
boolean online = faction.hasPlayersOnline();
|
boolean online = faction.hasPlayersOnline();
|
||||||
|
|
||||||
@@ -325,9 +316,8 @@ public class FactionsEntityListener implements Listener {
|
|||||||
@EventHandler(priority = EventPriority.NORMAL, ignoreCancelled = true)
|
@EventHandler(priority = EventPriority.NORMAL, ignoreCancelled = true)
|
||||||
public void onEntityCombustByEntity(EntityCombustByEntityEvent event) {
|
public void onEntityCombustByEntity(EntityCombustByEntityEvent event) {
|
||||||
EntityDamageByEntityEvent sub = new EntityDamageByEntityEvent(event.getCombuster(), event.getEntity(), EntityDamageEvent.DamageCause.FIRE, 0d);
|
EntityDamageByEntityEvent sub = new EntityDamageByEntityEvent(event.getCombuster(), event.getEntity(), EntityDamageEvent.DamageCause.FIRE, 0d);
|
||||||
if (!this.canDamagerHurtDamagee(sub, false)) {
|
if (!this.canDamagerHurtDamagee(sub, false)) event.setCancelled(true);
|
||||||
event.setCancelled(true);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@EventHandler(priority = EventPriority.NORMAL, ignoreCancelled = true)
|
@EventHandler(priority = EventPriority.NORMAL, ignoreCancelled = true)
|
||||||
@@ -340,14 +330,11 @@ public class FactionsEntityListener implements Listener {
|
|||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if (!badjuju) {
|
if (!badjuju) return;
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
ProjectileSource thrower = event.getPotion().getShooter();
|
ProjectileSource thrower = event.getPotion().getShooter();
|
||||||
if (!(thrower instanceof Entity)) {
|
if (!(thrower instanceof Entity)) return;
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (thrower instanceof Player) {
|
if (thrower instanceof Player) {
|
||||||
Player player = (Player) thrower;
|
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
|
// scan through affected entities to make sure they're all valid targets
|
||||||
for (LivingEntity target : event.getAffectedEntities()) {
|
for (LivingEntity target : event.getAffectedEntities()) {
|
||||||
EntityDamageByEntityEvent sub = new EntityDamageByEntityEvent((Entity) thrower, target, EntityDamageEvent.DamageCause.CUSTOM, 0);
|
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
|
event.setIntensity(target, 0.0); // affected entity list doesn't accept modification (so no iter.remove()), but this works
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public boolean isPlayerInSafeZone(Entity damagee) {
|
public boolean isPlayerInSafeZone(Entity damagee) {
|
||||||
if (!(damagee instanceof Player)) {
|
if (!(damagee instanceof Player)) return false;
|
||||||
return false;
|
|
||||||
}
|
|
||||||
return Board.getInstance().getFactionAt(new FLocation(damagee.getLocation())).isSafeZone();
|
return Board.getInstance().getFactionAt(new FLocation(damagee.getLocation())).isSafeZone();
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -382,15 +367,13 @@ public class FactionsEntityListener implements Listener {
|
|||||||
Entity damager = sub.getDamager();
|
Entity damager = sub.getDamager();
|
||||||
Entity damagee = sub.getEntity();
|
Entity damagee = sub.getEntity();
|
||||||
|
|
||||||
if (!(damagee instanceof Player)) {
|
if (!(damagee instanceof Player)) return true;
|
||||||
return true;
|
|
||||||
}
|
|
||||||
|
|
||||||
FPlayer defender = FPlayers.getInstance().getByPlayer((Player) damagee);
|
FPlayer defender = FPlayers.getInstance().getByPlayer((Player) damagee);
|
||||||
|
|
||||||
if (defender == null || defender.getPlayer() == null) {
|
if (defender == null || defender.getPlayer() == null) return true;
|
||||||
return true;
|
|
||||||
}
|
|
||||||
|
|
||||||
Location defenderLoc = defender.getPlayer().getLocation();
|
Location defenderLoc = defender.getPlayer().getLocation();
|
||||||
Faction defLocFaction = Board.getInstance().getFactionAt(new FLocation(defenderLoc));
|
Faction defLocFaction = Board.getInstance().getFactionAt(new FLocation(defenderLoc));
|
||||||
@@ -399,17 +382,11 @@ public class FactionsEntityListener implements Listener {
|
|||||||
if (damager instanceof Projectile) {
|
if (damager instanceof Projectile) {
|
||||||
Projectile projectile = (Projectile) damager;
|
Projectile projectile = (Projectile) damager;
|
||||||
|
|
||||||
if (!(projectile.getShooter() instanceof Entity)) {
|
if (!(projectile.getShooter() instanceof Entity)) return true;
|
||||||
return true;
|
|
||||||
}
|
|
||||||
|
|
||||||
damager = (Entity) projectile.getShooter();
|
damager = (Entity) projectile.getShooter();
|
||||||
}
|
}
|
||||||
|
|
||||||
if (damager == damagee) // ender pearl usage and other self-inflicted damage
|
if (damager == damagee) return true; // ender pearl usage and other self-inflicted damage
|
||||||
{
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
|
|
||||||
// Players can not take attack damage in a SafeZone, or possibly peaceful territory
|
// Players can not take attack damage in a SafeZone, or possibly peaceful territory
|
||||||
if (defLocFaction.noPvPInTerritory()) {
|
if (defLocFaction.noPvPInTerritory()) {
|
||||||
@@ -423,19 +400,16 @@ public class FactionsEntityListener implements Listener {
|
|||||||
return !defLocFaction.noMonstersInTerritory();
|
return !defLocFaction.noMonstersInTerritory();
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!(damager instanceof Player)) {
|
if (!(damager instanceof Player)) return true;
|
||||||
return true;
|
|
||||||
}
|
|
||||||
|
|
||||||
FPlayer attacker = FPlayers.getInstance().getByPlayer((Player) damager);
|
FPlayer attacker = FPlayers.getInstance().getByPlayer((Player) damager);
|
||||||
|
|
||||||
if (attacker == null || attacker.getPlayer() == null) {
|
if (attacker == null || attacker.getPlayer() == null) return true;
|
||||||
return true;
|
|
||||||
}
|
|
||||||
|
if (Conf.playersWhoBypassAllProtection.contains(attacker.getName())) return true;
|
||||||
|
|
||||||
if (Conf.playersWhoBypassAllProtection.contains(attacker.getName())) {
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (attacker.hasLoginPvpDisabled()) {
|
if (attacker.hasLoginPvpDisabled()) {
|
||||||
if (notify) {
|
if (notify) {
|
||||||
@@ -454,13 +428,11 @@ public class FactionsEntityListener implements Listener {
|
|||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (locFaction.isWarZone() && Conf.warZoneFriendlyFire) {
|
if (locFaction.isWarZone() && Conf.warZoneFriendlyFire) return true;
|
||||||
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 defendFaction = defender.getFaction();
|
||||||
Faction attackFaction = attacker.getFaction();
|
Faction attackFaction = attacker.getFaction();
|
||||||
@@ -505,9 +477,8 @@ public class FactionsEntityListener implements Listener {
|
|||||||
}
|
}
|
||||||
|
|
||||||
// Players without faction may be hurt anywhere
|
// Players without faction may be hurt anywhere
|
||||||
if (!defender.hasFaction()) {
|
if (!defender.hasFaction()) return true;
|
||||||
return true;
|
|
||||||
}
|
|
||||||
|
|
||||||
// You can never hurt faction members or allies
|
// You can never hurt faction members or allies
|
||||||
if (relation.isMember() || relation.isAlly() || relation.isTruce()) {
|
if (relation.isMember() || relation.isAlly() || relation.isTruce()) {
|
||||||
@@ -546,9 +517,8 @@ public class FactionsEntityListener implements Listener {
|
|||||||
|
|
||||||
@EventHandler(priority = EventPriority.NORMAL, ignoreCancelled = true)
|
@EventHandler(priority = EventPriority.NORMAL, ignoreCancelled = true)
|
||||||
public void onCreatureSpawn(CreatureSpawnEvent event) {
|
public void onCreatureSpawn(CreatureSpawnEvent event) {
|
||||||
if (event.getLocation() == null) {
|
if (event.getLocation() == null) return;
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (Conf.safeZoneNerfedCreatureTypes.contains(event.getEntityType()) && Board.getInstance().getFactionAt(new FLocation(event.getLocation())).noMonstersInTerritory()) {
|
if (Conf.safeZoneNerfedCreatureTypes.contains(event.getEntityType()) && Board.getInstance().getFactionAt(new FLocation(event.getLocation())).noMonstersInTerritory()) {
|
||||||
event.setCancelled(true);
|
event.setCancelled(true);
|
||||||
@@ -559,14 +529,10 @@ public class FactionsEntityListener implements Listener {
|
|||||||
public void onEntityTarget(EntityTargetEvent event) {
|
public void onEntityTarget(EntityTargetEvent event) {
|
||||||
// if there is a target
|
// if there is a target
|
||||||
Entity target = event.getTarget();
|
Entity target = event.getTarget();
|
||||||
if (target == null) {
|
if (target == null) return;
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
// We are interested in blocking targeting for certain mobs:
|
// We are interested in blocking targeting for certain mobs:
|
||||||
if (!Conf.safeZoneNerfedCreatureTypes.contains(MiscUtil.creatureTypeFromEntity(event.getEntity()))) {
|
if (!Conf.safeZoneNerfedCreatureTypes.contains(MiscUtil.creatureTypeFromEntity(event.getEntity()))) return;
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
// in case the target is in a safe zone.
|
// in case the target is in a safe zone.
|
||||||
if (Board.getInstance().getFactionAt(new FLocation(target.getLocation())).noMonstersInTerritory()) {
|
if (Board.getInstance().getFactionAt(new FLocation(target.getLocation())).noMonstersInTerritory()) {
|
||||||
@@ -635,9 +601,8 @@ public class FactionsEntityListener implements Listener {
|
|||||||
Entity entity = event.getEntity();
|
Entity entity = event.getEntity();
|
||||||
|
|
||||||
// for now, only interested in Enderman and Wither boss tomfoolery
|
// for now, only interested in Enderman and Wither boss tomfoolery
|
||||||
if (!(entity instanceof Enderman) && !(entity instanceof Wither)) {
|
if (!(entity instanceof Enderman) && !(entity instanceof Wither)) return;
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
Location loc = event.getBlock().getLocation();
|
Location loc = event.getBlock().getLocation();
|
||||||
|
|
||||||
@@ -659,9 +624,9 @@ public class FactionsEntityListener implements Listener {
|
|||||||
|
|
||||||
@EventHandler
|
@EventHandler
|
||||||
public void onTravel(PlayerPortalEvent event) {
|
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.
|
return; // Don't do anything if they don't want us to.
|
||||||
}
|
|
||||||
|
|
||||||
TravelAgent agent = event.getPortalTravelAgent();
|
TravelAgent agent = event.getPortalTravelAgent();
|
||||||
|
|
||||||
@@ -738,30 +703,27 @@ public class FactionsEntityListener implements Listener {
|
|||||||
}
|
}
|
||||||
|
|
||||||
private boolean stopEndermanBlockManipulation(Location loc) {
|
private boolean stopEndermanBlockManipulation(Location loc) {
|
||||||
if (loc == null) {
|
if (loc == null) return false;
|
||||||
return false;
|
|
||||||
}
|
|
||||||
// quick check to see if all Enderman deny options are enabled; if so, no need to check location
|
// quick check to see if all Enderman deny options are enabled; if so, no need to check location
|
||||||
if (Conf.wildernessDenyEndermanBlocks &&
|
if (Conf.wildernessDenyEndermanBlocks &&
|
||||||
Conf.territoryDenyEndermanBlocks &&
|
Conf.territoryDenyEndermanBlocks &&
|
||||||
Conf.territoryDenyEndermanBlocksWhenOffline &&
|
Conf.territoryDenyEndermanBlocksWhenOffline &&
|
||||||
Conf.safeZoneDenyEndermanBlocks &&
|
Conf.safeZoneDenyEndermanBlocks &&
|
||||||
Conf.warZoneDenyEndermanBlocks) {
|
Conf.warZoneDenyEndermanBlocks) return true;
|
||||||
return true;
|
|
||||||
}
|
|
||||||
|
|
||||||
FLocation fLoc = new FLocation(loc);
|
FLocation fLoc = new FLocation(loc);
|
||||||
Faction claimFaction = Board.getInstance().getFactionAt(fLoc);
|
Faction claimFaction = Board.getInstance().getFactionAt(fLoc);
|
||||||
|
|
||||||
if (claimFaction.isWilderness()) {
|
if (claimFaction.isWilderness())
|
||||||
return Conf.wildernessDenyEndermanBlocks;
|
return Conf.wildernessDenyEndermanBlocks;
|
||||||
} else if (claimFaction.isNormal()) {
|
else if (claimFaction.isNormal())
|
||||||
return claimFaction.hasPlayersOnline() ? Conf.territoryDenyEndermanBlocks : Conf.territoryDenyEndermanBlocksWhenOffline;
|
return claimFaction.hasPlayersOnline() ? Conf.territoryDenyEndermanBlocks : Conf.territoryDenyEndermanBlocksWhenOffline;
|
||||||
} else if (claimFaction.isSafeZone()) {
|
else if (claimFaction.isSafeZone())
|
||||||
return Conf.safeZoneDenyEndermanBlocks;
|
return Conf.safeZoneDenyEndermanBlocks;
|
||||||
} else if (claimFaction.isWarZone()) {
|
else if (claimFaction.isWarZone())
|
||||||
return Conf.warZoneDenyEndermanBlocks;
|
return Conf.warZoneDenyEndermanBlocks;
|
||||||
}
|
|
||||||
|
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -39,6 +39,7 @@ import org.bukkit.event.inventory.InventoryClickEvent;
|
|||||||
import org.bukkit.event.inventory.InventoryCloseEvent;
|
import org.bukkit.event.inventory.InventoryCloseEvent;
|
||||||
import org.bukkit.event.inventory.InventoryDragEvent;
|
import org.bukkit.event.inventory.InventoryDragEvent;
|
||||||
import org.bukkit.event.player.*;
|
import org.bukkit.event.player.*;
|
||||||
|
import org.bukkit.scheduler.BukkitTask;
|
||||||
|
|
||||||
import java.util.*;
|
import java.util.*;
|
||||||
import java.util.logging.Level;
|
import java.util.logging.Level;
|
||||||
@@ -50,16 +51,11 @@ public class FactionsPlayerListener implements Listener {
|
|||||||
public static Set<FLocation> corners;
|
public static Set<FLocation> corners;
|
||||||
// Holds the next time a player can have a map shown.
|
// Holds the next time a player can have a map shown.
|
||||||
private HashMap<UUID, Long> showTimes = new HashMap<>();
|
private HashMap<UUID, Long> showTimes = new HashMap<>();
|
||||||
// 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() {
|
public FactionsPlayerListener() {
|
||||||
for (Player player : FactionsPlugin.getInstance().getServer().getOnlinePlayers()) {
|
for (Player player : FactionsPlugin.getInstance().getServer().getOnlinePlayers()) initPlayer(player);
|
||||||
initPlayer(player);
|
if (positionTask == null) startPositionCheck();
|
||||||
}
|
if (!FactionsPlugin.getInstance().mc17) loadCorners();
|
||||||
if (!FactionsPlugin.getInstance().mc17) {
|
|
||||||
loadCorners();
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public static void loadCorners() {
|
public static void loadCorners() {
|
||||||
@@ -82,7 +78,7 @@ public class FactionsPlayerListener implements Listener {
|
|||||||
faction.isWilderness();
|
faction.isWilderness();
|
||||||
}
|
}
|
||||||
|
|
||||||
public static boolean playerCanUseItemHere(Player player, Location location, Material material, boolean justCheck) {
|
public static boolean playerCanUseItemHere(Player player, Location location, Material material, boolean justCheck, PermissableAction permissableAction) {
|
||||||
String name = player.getName();
|
String name = player.getName();
|
||||||
if (Conf.playersWhoBypassAllProtection.contains(name)) {
|
if (Conf.playersWhoBypassAllProtection.contains(name)) {
|
||||||
return true;
|
return true;
|
||||||
@@ -163,8 +159,8 @@ public class FactionsPlayerListener implements Listener {
|
|||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
Access access = otherFaction.getAccess(me, PermissableAction.ITEM);
|
Access access = otherFaction.getAccess(me, permissableAction);
|
||||||
return CheckPlayerAccess(player, me, loc, otherFaction, access, PermissableAction.ITEM, false);
|
return CheckPlayerAccess(player, me, loc, otherFaction, access, permissableAction, false);
|
||||||
}
|
}
|
||||||
|
|
||||||
@SuppressWarnings("deprecation")
|
@SuppressWarnings("deprecation")
|
||||||
@@ -295,25 +291,23 @@ public class FactionsPlayerListener implements Listener {
|
|||||||
}
|
}
|
||||||
|
|
||||||
private static boolean CheckPlayerAccess(Player player, FPlayer me, FLocation loc, Faction factionToCheck, Access access, PermissableAction action, boolean pain) {
|
private static boolean CheckPlayerAccess(Player player, FPlayer me, FLocation loc, Faction factionToCheck, Access access, PermissableAction action, boolean pain) {
|
||||||
boolean doPain = pain && Conf.handleExploitInteractionSpam;
|
boolean doPain = pain || Conf.handleExploitInteractionSpam; // Painbuild should take priority. But we want to use exploit interaction as well.
|
||||||
if (access != null && access != Access.UNDEFINED) {
|
if (access != null) {
|
||||||
// TODO: Update this once new access values are added other than just allow / deny.
|
|
||||||
boolean landOwned = (factionToCheck.doesLocationHaveOwnersSet(loc) && !factionToCheck.getOwnerList(loc).isEmpty());
|
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()))) {
|
if ((landOwned && factionToCheck.getOwnerListString(loc).contains(player.getName())) || (me.getRole() == Role.LEADER && me.getFactionId().equals(factionToCheck.getId()))) {
|
||||||
return true;
|
return true;
|
||||||
} else if (landOwned && !factionToCheck.getOwnerListString(loc).contains(player.getName())) {
|
} else if (landOwned && !factionToCheck.getOwnerListString(loc).contains(player.getName())) {
|
||||||
me.msg("<b>You can't do that in this territory, it is owned by: " + factionToCheck.getOwnerListString(loc));
|
me.msg(TL.ACTIONS_OWNEDTERRITORYDENY, factionToCheck.getOwnerListString(loc));
|
||||||
if (doPain) {
|
if (doPain) player.damage(Conf.actionDeniedPainAmount);
|
||||||
player.damage(Conf.actionDeniedPainAmount);
|
|
||||||
}
|
|
||||||
return false;
|
return false;
|
||||||
} else if (!landOwned && access == Access.ALLOW) {
|
} else if (!landOwned && access == Access.ALLOW) {
|
||||||
return true;
|
return true;
|
||||||
} else {
|
} 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;
|
return false;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// Approves any permission check if the player in question is a leader AND owns the faction.
|
// 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 (me.getRole().equals(Role.LEADER) && me.getFaction().equals(factionToCheck)) return true;
|
||||||
if (factionToCheck != null) {
|
if (factionToCheck != null) {
|
||||||
@@ -329,20 +323,16 @@ public class FactionsPlayerListener implements Listener {
|
|||||||
return GetPermissionFromUsableBlock(block.getType());
|
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) {
|
private static PermissableAction GetPermissionFromUsableBlock(Material material) {
|
||||||
// Check for doors that might have diff material name in old version.
|
// Check for doors that might have diff material name in old version.
|
||||||
if (material.name().contains("DOOR") || material.name().contains("FENCE_GATE"))
|
if (material.name().contains("DOOR") || material.name().contains("FENCE_GATE"))
|
||||||
return PermissableAction.DOOR;
|
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;
|
return PermissableAction.BUTTON;
|
||||||
if (FactionsPlugin.getInstance().mc113) {
|
if (FactionsPlugin.instance.mc113 || FactionsPlugin.instance.mc114) {
|
||||||
switch (material) {
|
switch (material) {
|
||||||
case LEVER:
|
case LEVER:
|
||||||
return PermissableAction.LEVER;
|
return PermissableAction.LEVER;
|
||||||
|
|
||||||
case ACACIA_BUTTON:
|
case ACACIA_BUTTON:
|
||||||
case BIRCH_BUTTON:
|
case BIRCH_BUTTON:
|
||||||
case DARK_OAK_BUTTON:
|
case DARK_OAK_BUTTON:
|
||||||
@@ -350,6 +340,8 @@ public class FactionsPlayerListener implements Listener {
|
|||||||
case OAK_BUTTON:
|
case OAK_BUTTON:
|
||||||
case SPRUCE_BUTTON:
|
case SPRUCE_BUTTON:
|
||||||
case STONE_BUTTON:
|
case STONE_BUTTON:
|
||||||
|
case COMPARATOR:
|
||||||
|
case REPEATER:
|
||||||
return PermissableAction.BUTTON;
|
return PermissableAction.BUTTON;
|
||||||
|
|
||||||
case ACACIA_DOOR:
|
case ACACIA_DOOR:
|
||||||
@@ -424,11 +416,10 @@ public class FactionsPlayerListener implements Listener {
|
|||||||
case IRON_DOOR:
|
case IRON_DOOR:
|
||||||
case JUNGLE_DOOR:
|
case JUNGLE_DOOR:
|
||||||
case SPRUCE_DOOR:
|
case SPRUCE_DOOR:
|
||||||
|
|
||||||
case ACACIA_FENCE_GATE:
|
case ACACIA_FENCE_GATE:
|
||||||
case BIRCH_FENCE_GATE:
|
case BIRCH_FENCE_GATE:
|
||||||
case DARK_OAK_FENCE_GATE:
|
|
||||||
case OAK_FENCE_GATE:
|
case OAK_FENCE_GATE:
|
||||||
|
case DARK_OAK_FENCE_GATE:
|
||||||
case JUNGLE_FENCE_GATE:
|
case JUNGLE_FENCE_GATE:
|
||||||
case SPRUCE_FENCE_GATE:
|
case SPRUCE_FENCE_GATE:
|
||||||
return PermissableAction.DOOR;
|
return PermissableAction.DOOR;
|
||||||
@@ -469,41 +460,34 @@ public class FactionsPlayerListener implements Listener {
|
|||||||
|
|
||||||
me.login(); // set kills / deaths
|
me.login(); // set kills / deaths
|
||||||
|
|
||||||
// Check for Faction announcements. Let's delay this so they actually see it.
|
Bukkit.getScheduler().runTaskLater(FactionsPlugin.instance, () -> {
|
||||||
Bukkit.getScheduler().runTaskLater(FactionsPlugin.getInstance(), () -> {
|
if (me.isOnline()) me.getFaction().sendUnreadAnnouncements(me);
|
||||||
if (me.isOnline()) {
|
}, 33L);
|
||||||
me.getFaction().sendUnreadAnnouncements(me);
|
|
||||||
}
|
|
||||||
}, 33L); // Don't ask me why.
|
|
||||||
|
|
||||||
if (FactionsPlugin.getInstance().getConfig().getBoolean("scoreboard.default-enabled", false)) {
|
if (FactionsPlugin.instance.getConfig().getBoolean("scoreboard.default-enabled", false)) {
|
||||||
FScoreboard.init(me);
|
FScoreboard.init(me);
|
||||||
FScoreboard.get(me).setDefaultSidebar(new FDefaultSidebar(), FactionsPlugin.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());
|
FScoreboard.get(me).setSidebarVisibility(me.showScoreboard());
|
||||||
}
|
}
|
||||||
|
|
||||||
Faction myFaction = me.getFaction();
|
Faction myFaction = me.getFaction();
|
||||||
if (!myFaction.isWilderness()) {
|
if (!myFaction.isWilderness()) {
|
||||||
for (FPlayer other : myFaction.getFPlayersWhereOnline(true)) {
|
for (FPlayer other : myFaction.getFPlayersWhereOnline(true)) {
|
||||||
if (other != me && other.isMonitoringJoins()) {
|
if (other != me && other.isMonitoringJoins()) other.msg(TL.FACTION_LOGIN, me.getName());
|
||||||
other.msg(TL.FACTION_LOGIN, me.getName());
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
fallMap.put(me.getPlayer(), false);
|
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)) {
|
if (me.isSpyingChat() && !player.hasPermission(Permission.CHATSPY.node)) {
|
||||||
me.setSpyingChat(false);
|
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)) {
|
if (me.isAdminBypassing() && !player.hasPermission(Permission.BYPASS.node)) {
|
||||||
me.setIsAdminBypassing(false);
|
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 +521,19 @@ public class FactionsPlayerListener implements Listener {
|
|||||||
me.logout(); // cache kills / deaths
|
me.logout(); // cache kills / deaths
|
||||||
|
|
||||||
// if player is waiting for fstuck teleport but leaves, remove
|
// 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);
|
FPlayers.getInstance().getByPlayer(me.getPlayer()).msg(TL.COMMAND_STUCK_CANCELLED);
|
||||||
FactionsPlugin.getInstance().getStuckMap().remove(me.getPlayer().getUniqueId());
|
FactionsPlugin.instance.getStuckMap().remove(me.getPlayer().getUniqueId());
|
||||||
FactionsPlugin.getInstance().getTimers().remove(me.getPlayer().getUniqueId());
|
FactionsPlugin.instance.getTimers().remove(me.getPlayer().getUniqueId());
|
||||||
}
|
}
|
||||||
|
|
||||||
Faction myFaction = me.getFaction();
|
Faction myFaction = me.getFaction();
|
||||||
if (!myFaction.isWilderness()) {
|
if (!myFaction.isWilderness()) myFaction.memberLoggedOff();
|
||||||
myFaction.memberLoggedOff();
|
|
||||||
}
|
|
||||||
|
|
||||||
if (!myFaction.isWilderness()) {
|
if (!myFaction.isWilderness()) {
|
||||||
for (FPlayer player : myFaction.getFPlayersWhereOnline(true)) {
|
for (FPlayer player : myFaction.getFPlayersWhereOnline(true))
|
||||||
if (player != me && player.isMonitoringJoins()) {
|
if (player != me && player.isMonitoringJoins()) player.msg(TL.FACTION_LOGOUT, me.getName());
|
||||||
player.msg(TL.FACTION_LOGOUT, me.getName());
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
CmdSeeChunk.seeChunkMap.remove(event.getPlayer().getName());
|
CmdSeeChunk.seeChunkMap.remove(event.getPlayer().getName());
|
||||||
@@ -570,26 +550,17 @@ public class FactionsPlayerListener implements Listener {
|
|||||||
.replace("{chunks}", faction.getAllClaims().size() + "")
|
.replace("{chunks}", faction.getAllClaims().size() + "")
|
||||||
.replace("{power}", faction.getPower() + "")
|
.replace("{power}", faction.getPower() + "")
|
||||||
.replace("{leader}", faction.getFPlayerAdmin() + "");
|
.replace("{leader}", faction.getFPlayerAdmin() + "");
|
||||||
|
|
||||||
return string;
|
return string;
|
||||||
}
|
}
|
||||||
|
|
||||||
public void enableFly(FPlayer me) {
|
public void enableFly(FPlayer me) {
|
||||||
if (!me.getPlayer().hasPermission(Permission.FLY.node)) return;
|
if (!FactionsPlugin.instance.getConfig().getBoolean("ffly.AutoEnable")) return; // Looks prettier sorry
|
||||||
|
if (!me.canFlyAtLocation()) return;
|
||||||
me.setFFlying(true, false);
|
me.setFFlying(true, false);
|
||||||
|
CmdFly.flyMap.put(me.getName(), true);
|
||||||
if (FactionsPlugin.getInstance().getConfig().getBoolean("ffly.AutoEnable")) {
|
if (CmdFly.particleTask == null)
|
||||||
me.setFlying(true);
|
CmdFly.startParticles();
|
||||||
CmdFly.flyMap.put(me.getName(), true);
|
}
|
||||||
if (CmdFly.id == -1) {
|
|
||||||
if (FactionsPlugin.getInstance().getConfig().getBoolean("ffly.Particles.Enabled")) {
|
|
||||||
CmdFly.startParticles();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
if (CmdFly.flyTask == null) CmdFly.startFlyCheck();
|
|
||||||
CmdFly.startFlyCheck();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
//inspect
|
//inspect
|
||||||
@@ -625,8 +596,8 @@ public class FactionsPlayerListener implements Listener {
|
|||||||
.replace("{y}", e.getClickedBlock().getY() + "")
|
.replace("{y}", e.getClickedBlock().getY() + "")
|
||||||
.replace("{z}", e.getClickedBlock().getZ() + ""));
|
.replace("{z}", e.getClickedBlock().getZ() + ""));
|
||||||
String rowFormat = TL.COMMAND_INSPECT_ROW.toString();
|
String rowFormat = TL.COMMAND_INSPECT_ROW.toString();
|
||||||
for (int i = 0; i < info.size(); i++) {
|
for (String[] strings : info) {
|
||||||
CoreProtectAPI.ParseResult row = coAPI.parseResult(info.get(i));
|
CoreProtectAPI.ParseResult row = coAPI.parseResult(strings);
|
||||||
player.sendMessage(rowFormat
|
player.sendMessage(rowFormat
|
||||||
.replace("{time}", convertTime(row.getTime()))
|
.replace("{time}", convertTime(row.getTime()))
|
||||||
.replace("{action}", row.getActionString())
|
.replace("{action}", row.getActionString())
|
||||||
@@ -642,11 +613,9 @@ public class FactionsPlayerListener implements Listener {
|
|||||||
Player player = e.getPlayer();
|
Player player = e.getPlayer();
|
||||||
if (player.getItemInHand().getType() == Material.ENDER_PEARL) {
|
if (player.getItemInHand().getType() == Material.ENDER_PEARL) {
|
||||||
FPlayer fPlayer = FPlayers.getInstance().getByPlayer(player);
|
FPlayer fPlayer = FPlayers.getInstance().getByPlayer(player);
|
||||||
if (fPlayer.isFlying()) {
|
if (fPlayer.isFlying() && Conf.noEnderpearlsInFly) {
|
||||||
if (Conf.noEnderpearlsInFly) {
|
fPlayer.msg(TL.COMMAND_FLY_NO_EPEARL);
|
||||||
fPlayer.msg(TL.COMMAND_FLY_NO_EPEARL);
|
e.setCancelled(true);
|
||||||
e.setCancelled(true);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -656,16 +625,59 @@ public class FactionsPlayerListener implements Listener {
|
|||||||
return (result.length() == 3 ? result + "0" : result) + "/hrs ago";
|
return (result.length() == 3 ? result + "0" : result) + "/hrs ago";
|
||||||
}
|
}
|
||||||
|
|
||||||
@EventHandler(priority = EventPriority.MONITOR, ignoreCancelled = true)
|
public static BukkitTask positionTask = null;
|
||||||
public void onPlayerMove(PlayerMoveEvent event) {
|
public static Map<UUID, Location> lastLocations = new HashMap<>();
|
||||||
Player player = event.getPlayer();
|
|
||||||
|
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);
|
FPlayer me = FPlayers.getInstance().getByPlayer(player);
|
||||||
|
|
||||||
// clear visualization
|
// clear visualization
|
||||||
if (event.getFrom().getBlockX() != event.getTo().getBlockX()
|
if (oldLocation.getBlockX() != newLocation.getBlockX()
|
||||||
|| event.getFrom().getBlockY() != event.getTo().getBlockY()
|
|| oldLocation.getBlockY() != newLocation.getBlockY()
|
||||||
|| event.getFrom().getBlockZ() != event.getTo().getBlockZ()) {
|
|| oldLocation.getBlockZ() != newLocation.getBlockZ()) {
|
||||||
VisualizeUtil.clear(event.getPlayer());
|
VisualizeUtil.clear(player);
|
||||||
if (me.isWarmingUp()) {
|
if (me.isWarmingUp()) {
|
||||||
me.clearWarmup();
|
me.clearWarmup();
|
||||||
me.msg(TL.WARMUPS_CANCELLED);
|
me.msg(TL.WARMUPS_CANCELLED);
|
||||||
@@ -673,23 +685,20 @@ public class FactionsPlayerListener implements Listener {
|
|||||||
}
|
}
|
||||||
|
|
||||||
// quick check to make sure player is moving between chunks; good performance boost
|
// quick check to make sure player is moving between chunks; good performance boost
|
||||||
if (event.getFrom().getBlockX() >> 4 == event.getTo().getBlockX() >> 4
|
if (oldLocation.getBlockX() >> 4 == newLocation.getBlockX() >> 4
|
||||||
&& event.getFrom().getBlockZ() >> 4 == event.getTo().getBlockZ() >> 4
|
&& oldLocation.getBlockZ() >> 4 == newLocation.getBlockZ() >> 4
|
||||||
&& event.getFrom().getWorld() == event.getTo().getWorld()) {
|
&& oldLocation.getWorld() == newLocation.getWorld()) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
// Did we change coord?
|
// Did we change coord?
|
||||||
FLocation from = me.getLastStoodAt();
|
FLocation from = me.getLastStoodAt();
|
||||||
FLocation to = new FLocation(event.getTo());
|
FLocation to = new FLocation(player.getLocation());
|
||||||
|
|
||||||
if (from.equals(to)) {
|
if (from.equals(to)) return;
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
// Yes we did change coord (:
|
// Yes we did change coord (:
|
||||||
|
|
||||||
me.setLastStoodAt(to);
|
me.setLastStoodAt(to);
|
||||||
|
|
||||||
// Did we change "host"(faction)?
|
// Did we change "host"(faction)?
|
||||||
@@ -699,43 +708,34 @@ public class FactionsPlayerListener implements Listener {
|
|||||||
|
|
||||||
|
|
||||||
if (changedFaction) {
|
if (changedFaction) {
|
||||||
Bukkit.getServer().getPluginManager().callEvent(new FPlayerEnteredFactionEvent(factionTo, factionFrom, me));
|
Bukkit.getScheduler().runTask(FactionsPlugin.instance, () -> Bukkit.getServer().getPluginManager().callEvent(new FPlayerEnteredFactionEvent(factionTo, factionFrom, me)));
|
||||||
if (FactionsPlugin.getInstance().getConfig().getBoolean("Title.Show-Title")) {
|
if (FactionsPlugin.instance.getConfig().getBoolean("Title.Show-Title")) {
|
||||||
String title = FactionsPlugin.getInstance().getConfig().getString("Title.Format.Title");
|
String title = FactionsPlugin.instance.getConfig().getString("Title.Format.Title");
|
||||||
title = title.replace("{Faction}", factionTo.getColorTo(me) + factionTo.getTag());
|
title = title.replace("{Faction}", factionTo.getColorTo(me) + factionTo.getTag());
|
||||||
title = parseAllPlaceholders(title, factionTo, player);
|
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);
|
subTitle = parseAllPlaceholders(subTitle, factionTo, player);
|
||||||
if (!FactionsPlugin.getInstance().mc17) {
|
final String finalTitle = title;
|
||||||
if (!FactionsPlugin.getInstance().mc18) {
|
final String finalsubTitle = subTitle;
|
||||||
me.getPlayer().sendTitle(FactionsPlugin.getInstance().color(title), FactionsPlugin.getInstance().color(subTitle), FactionsPlugin.getInstance().getConfig().getInt("Title.Options.FadeInTime"),
|
if (!FactionsPlugin.instance.mc17) {
|
||||||
FactionsPlugin.getInstance().getConfig().getInt("Title.Options.ShowTime"),
|
Bukkit.getScheduler().runTaskLater(FactionsPlugin.instance, () -> {
|
||||||
FactionsPlugin.getInstance().getConfig().getInt("Title.Options.FadeOutTime"));
|
if (!FactionsPlugin.instance.mc18) {
|
||||||
} else {
|
me.getPlayer().sendTitle(FactionsPlugin.instance.color(finalTitle), FactionsPlugin.instance.color(finalsubTitle), FactionsPlugin.instance.getConfig().getInt("Title.Options.FadeInTime"),
|
||||||
me.getPlayer().sendTitle(FactionsPlugin.getInstance().color(title), FactionsPlugin.getInstance().color(subTitle));
|
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);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
if (!me.isFlying()) {
|
||||||
|
enableFly(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))) {
|
|
||||||
enableFly(me);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
if (me.getAutoClaimFor() != null) {
|
if (me.getAutoClaimFor() != null) {
|
||||||
me.attemptClaim(me.getAutoClaimFor(), event.getTo(), true);
|
me.attemptClaim(me.getAutoClaimFor(), newLocation, true);
|
||||||
if (Conf.disableFlightOnFactionClaimChange && event.getPlayer().getGameMode() != GameMode.CREATIVE)
|
if (Conf.disableFlightOnFactionClaimChange) CmdFly.disableFlight(me);
|
||||||
CmdFly.disableFlight(me);
|
|
||||||
} else if (me.isAutoSafeClaimEnabled()) {
|
} else if (me.isAutoSafeClaimEnabled()) {
|
||||||
if (!Permission.MANAGE_SAFE_ZONE.has(player)) {
|
if (!Permission.MANAGE_SAFE_ZONE.has(player)) {
|
||||||
me.setIsAutoSafeClaimEnabled(false);
|
me.setIsAutoSafeClaimEnabled(false);
|
||||||
@@ -757,27 +757,26 @@ public class FactionsPlayerListener implements Listener {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
if (me.isMapAutoUpdating()) {
|
if (me.isMapAutoUpdating()) {
|
||||||
if (showTimes.containsKey(player.getUniqueId()) && (showTimes.get(player.getUniqueId()) > System.currentTimeMillis())) {
|
if (showTimes.containsKey(player.getUniqueId()) && (showTimes.get(player.getUniqueId()) > System.currentTimeMillis())) {
|
||||||
if (FactionsPlugin.getInstance().getConfig().getBoolean("findfactionsexploit.log", false)) {
|
if (FactionsPlugin.instance.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());
|
FactionsPlugin.instance.log(Level.WARNING, "%s tried to show a faction map too soon and triggered exploit blocker.", player.getName());
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
me.sendFancyMessage(Board.getInstance().getMap(me, to, player.getLocation().getYaw()));
|
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 {
|
} else {
|
||||||
Faction myFaction = me.getFaction();
|
Faction myFaction = me.getFaction();
|
||||||
String ownersTo = myFaction.getOwnerListString(to);
|
String ownersTo = myFaction.getOwnerListString(to);
|
||||||
if (changedFaction) {
|
if (changedFaction) {
|
||||||
me.sendFactionHereMessage(factionFrom);
|
if (Conf.sendFactionChangeMessage) me.sendFactionHereMessage(factionFrom);
|
||||||
if (Conf.ownedAreasEnabled && Conf.ownedMessageOnBorder && myFaction == factionTo && !ownersTo.isEmpty() && me.hasNotificationsEnabled()) {
|
if (Conf.ownedAreasEnabled && Conf.ownedMessageOnBorder && myFaction == factionTo && !ownersTo.isEmpty()) {
|
||||||
me.sendMessage(TL.GENERIC_OWNERS.format(ownersTo));
|
me.sendMessage(TL.GENERIC_OWNERS.format(ownersTo));
|
||||||
}
|
}
|
||||||
} else if (Conf.ownedAreasEnabled && Conf.ownedMessageInsideTerritory && myFaction == factionTo && !myFaction.isWilderness()) {
|
} else if (Conf.ownedAreasEnabled && Conf.ownedMessageInsideTerritory && myFaction == factionTo && !myFaction.isWilderness()) {
|
||||||
String ownersFrom = myFaction.getOwnerListString(from);
|
String ownersFrom = myFaction.getOwnerListString(from);
|
||||||
if (Conf.ownedMessageByChunk || !ownersFrom.equals(ownersTo) && me.hasNotificationsEnabled()) {
|
if (Conf.ownedMessageByChunk || !ownersFrom.equals(ownersTo)) {
|
||||||
if (!ownersTo.isEmpty()) {
|
if (!ownersTo.isEmpty()) {
|
||||||
me.sendMessage(TL.GENERIC_OWNERS.format(ownersTo));
|
me.sendMessage(TL.GENERIC_OWNERS.format(ownersTo));
|
||||||
} else if (!TL.GENERIC_PUBLICLAND.toString().isEmpty()) {
|
} else if (!TL.GENERIC_PUBLICLAND.toString().isEmpty()) {
|
||||||
@@ -791,47 +790,62 @@ public class FactionsPlayerListener implements Listener {
|
|||||||
@EventHandler
|
@EventHandler
|
||||||
public void onClose(InventoryCloseEvent e) {
|
public void onClose(InventoryCloseEvent e) {
|
||||||
FPlayer fme = FPlayers.getInstance().getById(e.getPlayer().getUniqueId().toString());
|
FPlayer fme = FPlayers.getInstance().getById(e.getPlayer().getUniqueId().toString());
|
||||||
if (fme.isInVault())
|
if (fme.isInVault()) fme.setInVault(false);
|
||||||
fme.setInVault(false);
|
if (fme.isInFactionsChest()) fme.setInFactionsChest(false);
|
||||||
}
|
}
|
||||||
|
|
||||||
@EventHandler(priority = EventPriority.NORMAL, ignoreCancelled = true)
|
@EventHandler
|
||||||
public void onPlayerInteract(PlayerInteractEvent event) {
|
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_AIR) || event.getAction().equals(Action.LEFT_CLICK_BLOCK))
|
||||||
if (event.getAction().equals(Action.LEFT_CLICK_BLOCK) || event.getAction().equals(Action.LEFT_CLICK_AIR))
|
|
||||||
return;
|
return;
|
||||||
|
|
||||||
Block block = event.getClickedBlock();
|
Block block = event.getClickedBlock();
|
||||||
Player player = event.getPlayer();
|
Player player = event.getPlayer();
|
||||||
// Check if the material is bypassing protection
|
|
||||||
if (block == null) return; // clicked in air, apparently
|
|
||||||
if (Conf.territoryBypassProtectedMaterials.contains(block.getType())) return;
|
|
||||||
|
|
||||||
if (GetPermissionFromUsableBlock(event.getClickedBlock().getType()) != null) {
|
if (block == null) return;
|
||||||
|
|
||||||
|
|
||||||
|
Material type;
|
||||||
|
if (event.getItem() != null) {
|
||||||
|
// Convert 1.8 Material Names -> 1.14
|
||||||
|
type = XMaterial.matchXMaterial(event.getItem().getType().toString()).parseMaterial();
|
||||||
|
} else {
|
||||||
|
type = null;
|
||||||
|
}
|
||||||
|
|
||||||
|
// Creeper Egg Bypass.
|
||||||
|
if (Conf.allowCreeperEggingChests && block.getType() == Material.CHEST && type == XMaterial.CREEPER_SPAWN_EGG.parseMaterial() && event.getPlayer().isSneaking()) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
// 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)) {
|
if (!canPlayerUseBlock(player, block, false)) {
|
||||||
event.setCancelled(true);
|
event.setCancelled(true);
|
||||||
event.setUseInteractedBlock(Event.Result.DENY);
|
event.setUseInteractedBlock(Event.Result.DENY);
|
||||||
return;
|
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)) {
|
||||||
if (!playerCanUseItemHere(player, block.getLocation(), event.getItem().getType(), false)) {
|
|
||||||
event.setCancelled(true);
|
event.setCancelled(true);
|
||||||
event.setUseInteractedBlock(Event.Result.DENY);
|
event.setUseInteractedBlock(Event.Result.DENY);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@EventHandler
|
@EventHandler
|
||||||
public void onInentorySee(InventoryClickEvent e) {
|
public void onInventorySee(InventoryClickEvent e) {
|
||||||
if (e.getCurrentItem() == null)
|
if (e.getCurrentItem() == null)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
@@ -844,7 +858,6 @@ public class FactionsPlayerListener implements Listener {
|
|||||||
@EventHandler
|
@EventHandler
|
||||||
public void onPlayerBoneMeal(PlayerInteractEvent event) {
|
public void onPlayerBoneMeal(PlayerInteractEvent event) {
|
||||||
Block block = event.getClickedBlock();
|
Block block = event.getClickedBlock();
|
||||||
|
|
||||||
if (event.getAction() == Action.RIGHT_CLICK_BLOCK && block.getType() == XMaterial.GRASS_BLOCK.parseMaterial()
|
if (event.getAction() == Action.RIGHT_CLICK_BLOCK && block.getType() == XMaterial.GRASS_BLOCK.parseMaterial()
|
||||||
&& event.hasItem() && event.getItem().getType() == XMaterial.BONE_MEAL.parseMaterial()) {
|
&& event.hasItem() && event.getItem().getType() == XMaterial.BONE_MEAL.parseMaterial()) {
|
||||||
if (!FactionsBlockListener.playerCanBuildDestroyBlock(event.getPlayer(), block.getLocation(), PermissableAction.BUILD.name(), true)) {
|
if (!FactionsBlockListener.playerCanBuildDestroyBlock(event.getPlayer(), block.getLocation(), PermissableAction.BUILD.name(), true)) {
|
||||||
@@ -879,7 +892,7 @@ public class FactionsPlayerListener implements Listener {
|
|||||||
Block block = event.getBlockClicked();
|
Block block = event.getBlockClicked();
|
||||||
Player player = event.getPlayer();
|
Player player = event.getPlayer();
|
||||||
|
|
||||||
if (!playerCanUseItemHere(player, block.getLocation(), event.getBucket(), false)) {
|
if (!playerCanUseItemHere(player, block.getLocation(), event.getBucket(), false, PermissableAction.BUILD)) {
|
||||||
event.setCancelled(true);
|
event.setCancelled(true);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -889,7 +902,7 @@ public class FactionsPlayerListener implements Listener {
|
|||||||
Block block = event.getBlockClicked();
|
Block block = event.getBlockClicked();
|
||||||
Player player = event.getPlayer();
|
Player player = event.getPlayer();
|
||||||
|
|
||||||
if (!playerCanUseItemHere(player, block.getLocation(), event.getBucket(), false)) {
|
if (!playerCanUseItemHere(player, block.getLocation(), event.getBucket(), false, PermissableAction.DESTROY)) {
|
||||||
event.setCancelled(true);
|
event.setCancelled(true);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -929,9 +942,7 @@ public class FactionsPlayerListener implements Listener {
|
|||||||
|
|
||||||
@EventHandler(priority = EventPriority.HIGH)
|
@EventHandler(priority = EventPriority.HIGH)
|
||||||
public void onPlayerInteractGUI(InventoryClickEvent event) {
|
public void onPlayerInteractGUI(InventoryClickEvent event) {
|
||||||
if (event.getClickedInventory() == null) {
|
if (event.getClickedInventory() == null) return;
|
||||||
return;
|
|
||||||
}
|
|
||||||
if (event.getClickedInventory().getHolder() instanceof FactionGUI) {
|
if (event.getClickedInventory().getHolder() instanceof FactionGUI) {
|
||||||
event.setCancelled(true);
|
event.setCancelled(true);
|
||||||
((FactionGUI) event.getClickedInventory().getHolder()).onClick(event.getRawSlot(), event.getClick());
|
((FactionGUI) event.getClickedInventory().getHolder()).onClick(event.getRawSlot(), event.getClick());
|
||||||
@@ -940,23 +951,18 @@ public class FactionsPlayerListener implements Listener {
|
|||||||
|
|
||||||
@EventHandler(priority = EventPriority.HIGH)
|
@EventHandler(priority = EventPriority.HIGH)
|
||||||
public void onPlayerMoveGUI(InventoryDragEvent event) {
|
public void onPlayerMoveGUI(InventoryDragEvent event) {
|
||||||
if (event.getInventory().getHolder() instanceof FactionGUI) {
|
if (event.getInventory().getHolder() instanceof FactionGUI) event.setCancelled(true);
|
||||||
event.setCancelled(true);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@EventHandler(priority = EventPriority.NORMAL, ignoreCancelled = true)
|
@EventHandler(priority = EventPriority.NORMAL, ignoreCancelled = true)
|
||||||
public void onPlayerKick(PlayerKickEvent event) {
|
public void onPlayerKick(PlayerKickEvent event) {
|
||||||
FPlayer badGuy = FPlayers.getInstance().getByPlayer(event.getPlayer());
|
FPlayer badGuy = FPlayers.getInstance().getByPlayer(event.getPlayer());
|
||||||
if (badGuy == null) {
|
if (badGuy == null) return;
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
// if player was banned (not just kicked), get rid of their stored info
|
// if player was banned (not just kicked), get rid of their stored info
|
||||||
if (Conf.removePlayerDataWhenBanned && event.getReason().equals("Banned by admin.")) {
|
if (Conf.removePlayerDataWhenBanned && event.getReason().equals("Banned by admin.")) {
|
||||||
if (badGuy.getRole() == Role.LEADER) {
|
if (badGuy.getRole() == Role.LEADER) badGuy.getFaction().promoteNewLeader();
|
||||||
badGuy.getFaction().promoteNewLeader();
|
|
||||||
}
|
|
||||||
|
|
||||||
badGuy.leave(false);
|
badGuy.leave(false);
|
||||||
badGuy.remove();
|
badGuy.remove();
|
||||||
@@ -974,7 +980,7 @@ public class FactionsPlayerListener implements Listener {
|
|||||||
}
|
}
|
||||||
|
|
||||||
public Set<FLocation> getCorners() {
|
public Set<FLocation> getCorners() {
|
||||||
return this.corners;
|
return corners;
|
||||||
}
|
}
|
||||||
|
|
||||||
@EventHandler
|
@EventHandler
|
||||||
@@ -1011,21 +1017,9 @@ public class FactionsPlayerListener implements Listener {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@EventHandler
|
||||||
private static class InteractAttemptSpam {
|
public void onDisconnect(PlayerQuitEvent e) {
|
||||||
private int attempts = 0;
|
FPlayer fPlayer = FPlayers.getInstance().getByPlayer(e.getPlayer());
|
||||||
private long lastAttempt = System.currentTimeMillis();
|
if (fPlayer.isInFactionsChest()) fPlayer.setInFactionsChest(false);
|
||||||
|
|
||||||
// returns the current attempt count
|
|
||||||
public int increment() {
|
|
||||||
long now = System.currentTimeMillis();
|
|
||||||
if (now > lastAttempt + 2000) {
|
|
||||||
attempts = 1;
|
|
||||||
} else {
|
|
||||||
attempts++;
|
|
||||||
}
|
|
||||||
lastAttempt = now;
|
|
||||||
return attempts;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -13,7 +13,6 @@ import org.bukkit.inventory.Inventory;
|
|||||||
import org.bukkit.inventory.ItemFlag;
|
import org.bukkit.inventory.ItemFlag;
|
||||||
import org.bukkit.inventory.ItemStack;
|
import org.bukkit.inventory.ItemStack;
|
||||||
import org.bukkit.inventory.meta.ItemMeta;
|
import org.bukkit.inventory.meta.ItemMeta;
|
||||||
|
|
||||||
import java.util.*;
|
import java.util.*;
|
||||||
|
|
||||||
public class MissionGUI implements FactionGUI {
|
public class MissionGUI implements FactionGUI {
|
||||||
@@ -31,7 +30,30 @@ public class MissionGUI implements FactionGUI {
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void onClick(int slot, ClickType action) {
|
public void onClick(int slot, ClickType action) {
|
||||||
|
String missionName = slots.get(slot);
|
||||||
|
if (missionName == null) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
ConfigurationSection configurationSection = plugin.getConfig().getConfigurationSection("Missions");
|
ConfigurationSection configurationSection = plugin.getConfig().getConfigurationSection("Missions");
|
||||||
|
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) {
|
if (configurationSection == null) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
@@ -40,8 +62,7 @@ public class MissionGUI implements FactionGUI {
|
|||||||
fPlayer.msg(TL.MISSION_MISSION_MAX_ALLOWED, max);
|
fPlayer.msg(TL.MISSION_MISSION_MAX_ALLOWED, max);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
String missionName = slots.get(slot);
|
if (missionName.equals(plugin.color(FactionsPlugin.getInstance().getConfig().getString("Randomization.Start-Item.Disallowed.Name")))) {
|
||||||
if (missionName == null) {
|
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
if (fPlayer.getFaction().getMissions().containsKey(missionName)) {
|
if (fPlayer.getFaction().getMissions().containsKey(missionName)) {
|
||||||
@@ -63,6 +84,7 @@ public class MissionGUI implements FactionGUI {
|
|||||||
if (missionSection == null) {
|
if (missionSection == null) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
Mission mission = new Mission(missionName, missionSection.getString("Type"));
|
Mission mission = new Mission(missionName, missionSection.getString("Type"));
|
||||||
fPlayer.getFaction().getMissions().put(missionName, mission);
|
fPlayer.getFaction().getMissions().put(missionName, mission);
|
||||||
fPlayer.msg(TL.MISSION_MISSION_STARTED, fPlayer.describeTo(fPlayer.getFaction()), plugin.color(section.getString("Name")));
|
fPlayer.msg(TL.MISSION_MISSION_STARTED, fPlayer.describeTo(fPlayer.getFaction()), plugin.color(section.getString("Name")));
|
||||||
@@ -110,6 +132,43 @@ public class MissionGUI implements FactionGUI {
|
|||||||
slots.put(slot, key);
|
slots.put(slot, key);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
if (plugin.getConfig().getBoolean("Randomization.Enabled")) {
|
||||||
|
ItemStack start = null;
|
||||||
|
ItemMeta meta;
|
||||||
|
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 = new ArrayList<>();
|
||||||
|
for (String string : plugin.getConfig().getStringList("Randomization.Start-Item.Allowed.Lore")) {
|
||||||
|
loree.add(plugin.color(string));
|
||||||
|
}
|
||||||
|
meta.setLore(loree);
|
||||||
|
start.setItemMeta(meta);
|
||||||
|
if (fPlayer.getFaction().getCompletedMissions().size() >= configurationSection.getKeys(false).size() - 1 && plugin.getConfig().getBoolean("DenyMissionsMoreThenOnce")) {
|
||||||
|
start = XMaterial.matchXMaterial(plugin.getConfig().getString("Randomization.Start-Item.Disallowed.Material")).parseItem();
|
||||||
|
meta = start.getItemMeta();
|
||||||
|
meta.setDisplayName(plugin.color(plugin.getConfig().getString("Randomization.Start-Item.Disallowed.Name")));
|
||||||
|
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()));
|
||||||
|
}
|
||||||
|
meta.setLore(lore);
|
||||||
|
start.setItemMeta(meta);
|
||||||
|
}
|
||||||
|
if (fPlayer.getFaction().getMissions().size() >= plugin.getConfig().getInt("MaximumMissionsAllowedAtOnce")) {
|
||||||
|
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 = 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"))));
|
||||||
|
}
|
||||||
|
meta.setLore(lore);
|
||||||
|
start.setItemMeta(meta);
|
||||||
|
}
|
||||||
|
inventory.setItem(plugin.getConfig().getInt("Randomization.Start-Item.Slot"), start);
|
||||||
|
slots.put(plugin.getConfig().getInt("Randomization.Start-Item.Slot"), start.getItemMeta().getDisplayName());
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public Inventory getInventory() {
|
public Inventory getInventory() {
|
||||||
|
|||||||
@@ -3,6 +3,7 @@ package com.massivecraft.factions.util;
|
|||||||
import com.massivecraft.factions.*;
|
import com.massivecraft.factions.*;
|
||||||
import com.massivecraft.factions.integration.Econ;
|
import com.massivecraft.factions.integration.Econ;
|
||||||
import com.massivecraft.factions.struct.Relation;
|
import com.massivecraft.factions.struct.Relation;
|
||||||
|
import com.massivecraft.factions.tag.Tag;
|
||||||
import com.massivecraft.factions.zcore.util.TL;
|
import com.massivecraft.factions.zcore.util.TL;
|
||||||
import me.clip.placeholderapi.expansion.PlaceholderExpansion;
|
import me.clip.placeholderapi.expansion.PlaceholderExpansion;
|
||||||
import me.clip.placeholderapi.expansion.Relational;
|
import me.clip.placeholderapi.expansion.Relational;
|
||||||
@@ -104,6 +105,10 @@ public class ClipPlaceholderAPIManager extends PlaceholderExpansion implements R
|
|||||||
// Then Faction stuff
|
// Then Faction stuff
|
||||||
case "faction_name":
|
case "faction_name":
|
||||||
return fPlayer.hasFaction() ? faction.getTag() : TL.NOFACTION_PREFIX.toString();
|
return fPlayer.hasFaction() ? faction.getTag() : TL.NOFACTION_PREFIX.toString();
|
||||||
|
case "faction_name_custom":
|
||||||
|
return fPlayer.hasFaction() ? Tag.parsePlain(fPlayer, TL.PLACEHOLDER_CUSTOM_FACTION.toString()) : "";
|
||||||
|
case "faction_only_space":
|
||||||
|
return fPlayer.hasFaction() ? " " : "";
|
||||||
case "faction_power":
|
case "faction_power":
|
||||||
return String.valueOf(faction.getPowerRounded());
|
return String.valueOf(faction.getPowerRounded());
|
||||||
case "faction_powermax":
|
case "faction_powermax":
|
||||||
@@ -141,7 +146,7 @@ public class ClipPlaceholderAPIManager extends PlaceholderExpansion implements R
|
|||||||
return faction.hasHome() ? String.valueOf(faction.getHome().getBlockY()) : "";
|
return faction.hasHome() ? String.valueOf(faction.getHome().getBlockY()) : "";
|
||||||
case "faction_home_z":
|
case "faction_home_z":
|
||||||
return faction.hasHome() ? String.valueOf(faction.getHome().getBlockZ()) : "";
|
return faction.hasHome() ? String.valueOf(faction.getHome().getBlockZ()) : "";
|
||||||
case "facion_land_value":
|
case "faction_land_value":
|
||||||
return Econ.shouldBeUsed() ? Econ.moneyString(Econ.calculateTotalLandValue(faction.getLandRounded())) : TL.ECON_OFF.format("value");
|
return Econ.shouldBeUsed() ? Econ.moneyString(Econ.calculateTotalLandValue(faction.getLandRounded())) : TL.ECON_OFF.format("value");
|
||||||
case "faction_land_refund":
|
case "faction_land_refund":
|
||||||
return Econ.shouldBeUsed() ? Econ.moneyString(Econ.calculateTotalLandRefund(faction.getLandRounded())) : TL.ECON_OFF.format("refund");
|
return Econ.shouldBeUsed() ? Econ.moneyString(Econ.calculateTotalLandRefund(faction.getLandRounded())) : TL.ECON_OFF.format("refund");
|
||||||
|
|||||||
@@ -0,0 +1,97 @@
|
|||||||
|
package com.massivecraft.factions.util;
|
||||||
|
|
||||||
|
|
||||||
|
import com.massivecraft.factions.FactionsPlugin;
|
||||||
|
import org.bukkit.ChatColor;
|
||||||
|
import org.bukkit.Material;
|
||||||
|
import org.bukkit.enchantments.Enchantment;
|
||||||
|
import org.bukkit.inventory.ItemFlag;
|
||||||
|
import org.bukkit.inventory.ItemStack;
|
||||||
|
import org.bukkit.inventory.meta.ItemMeta;
|
||||||
|
|
||||||
|
import java.util.ArrayList;
|
||||||
|
import java.util.List;
|
||||||
|
|
||||||
|
public class ItemBuilder {
|
||||||
|
private ItemMeta meta;
|
||||||
|
private ItemStack item;
|
||||||
|
|
||||||
|
public ItemBuilder(ItemStack item) {
|
||||||
|
this.item = item;
|
||||||
|
this.meta = item.getItemMeta();
|
||||||
|
}
|
||||||
|
|
||||||
|
public ItemBuilder(Material material, int amount, int durability) {
|
||||||
|
this(new ItemStack(material, amount, (short) durability));
|
||||||
|
}
|
||||||
|
|
||||||
|
public ItemBuilder(Material material, int amount) {
|
||||||
|
this(material, amount, 0);
|
||||||
|
}
|
||||||
|
|
||||||
|
public ItemBuilder(Material material) {
|
||||||
|
this(material, 1);
|
||||||
|
}
|
||||||
|
|
||||||
|
public static List<String> color(List<String> string) {
|
||||||
|
List<String> colored = new ArrayList<>();
|
||||||
|
for (String line : string) {
|
||||||
|
colored.add(FactionsPlugin.instance.color(line));
|
||||||
|
}
|
||||||
|
return colored;
|
||||||
|
}
|
||||||
|
|
||||||
|
public ItemBuilder durability(short durability) {
|
||||||
|
this.item.setDurability(durability);
|
||||||
|
return this;
|
||||||
|
}
|
||||||
|
|
||||||
|
public ItemBuilder lore(String... lore) {
|
||||||
|
if (lore != null) {
|
||||||
|
ArrayList<String> arrayList = new ArrayList<>();
|
||||||
|
for (String line : lore) {
|
||||||
|
arrayList.add(FactionsPlugin.instance.color(line));
|
||||||
|
}
|
||||||
|
this.meta.setLore(arrayList);
|
||||||
|
}
|
||||||
|
return this;
|
||||||
|
}
|
||||||
|
|
||||||
|
public ItemBuilder lore(List<String> lore) {
|
||||||
|
this.meta.setLore(color(lore));
|
||||||
|
return this;
|
||||||
|
}
|
||||||
|
|
||||||
|
public ItemBuilder name(String name) {
|
||||||
|
this.meta.setDisplayName(ChatColor.translateAlternateColorCodes('&', name));
|
||||||
|
return this;
|
||||||
|
}
|
||||||
|
|
||||||
|
public ItemStack build() {
|
||||||
|
this.item.setItemMeta(this.meta);
|
||||||
|
return this.item;
|
||||||
|
}
|
||||||
|
|
||||||
|
public ItemBuilder amount(int amount) {
|
||||||
|
this.item.setAmount(amount);
|
||||||
|
return this;
|
||||||
|
}
|
||||||
|
|
||||||
|
public ItemBuilder glowing(boolean status) {
|
||||||
|
if (status) {
|
||||||
|
this.meta.addItemFlags(ItemFlag.HIDE_ENCHANTS);
|
||||||
|
this.meta.addEnchant(Enchantment.DURABILITY, 1, true);
|
||||||
|
} else {
|
||||||
|
this.meta.removeItemFlags(ItemFlag.HIDE_ENCHANTS);
|
||||||
|
this.meta.removeEnchant(Enchantment.DURABILITY);
|
||||||
|
}
|
||||||
|
return this;
|
||||||
|
}
|
||||||
|
|
||||||
|
public ItemBuilder addLineToLore(String line) {
|
||||||
|
List<String> lore = this.meta.getLore();
|
||||||
|
lore.add(FactionsPlugin.instance.color(line));
|
||||||
|
this.meta.setLore(lore);
|
||||||
|
return this;
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -67,6 +67,13 @@ public class MiscUtil {
|
|||||||
public static ArrayList<String> validateTag(String str) {
|
public static ArrayList<String> validateTag(String str) {
|
||||||
ArrayList<String> errors = new ArrayList<>();
|
ArrayList<String> errors = new ArrayList<>();
|
||||||
|
|
||||||
|
for (String blacklistItem : Conf.blacklistedFactionNames) {
|
||||||
|
if (str.toLowerCase().contains(blacklistItem.toLowerCase())) {
|
||||||
|
errors.add(FactionsPlugin.instance.txt.parse(TL.GENERIC_FACTIONTAG_BLACKLIST.toString()));
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
if (getComparisonString(str).length() < Conf.factionTagLengthMin) {
|
if (getComparisonString(str).length() < Conf.factionTagLengthMin) {
|
||||||
errors.add(FactionsPlugin.getInstance().txt.parse(TL.GENERIC_FACTIONTAG_TOOSHORT.toString(), Conf.factionTagLengthMin));
|
errors.add(FactionsPlugin.getInstance().txt.parse(TL.GENERIC_FACTIONTAG_TOOSHORT.toString(), Conf.factionTagLengthMin));
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -0,0 +1,31 @@
|
|||||||
|
package com.massivecraft.factions.util;
|
||||||
|
|
||||||
|
import java.util.TreeMap;
|
||||||
|
|
||||||
|
public class RomanNumber {
|
||||||
|
private static TreeMap<Integer, String> map;
|
||||||
|
|
||||||
|
static {
|
||||||
|
(map = new TreeMap<>()).put(1000, "M");
|
||||||
|
RomanNumber.map.put(900, "CM");
|
||||||
|
RomanNumber.map.put(500, "D");
|
||||||
|
RomanNumber.map.put(400, "CD");
|
||||||
|
RomanNumber.map.put(100, "C");
|
||||||
|
RomanNumber.map.put(90, "XC");
|
||||||
|
RomanNumber.map.put(50, "L");
|
||||||
|
RomanNumber.map.put(40, "XL");
|
||||||
|
RomanNumber.map.put(10, "X");
|
||||||
|
RomanNumber.map.put(9, "IX");
|
||||||
|
RomanNumber.map.put(5, "V");
|
||||||
|
RomanNumber.map.put(4, "IV");
|
||||||
|
RomanNumber.map.put(1, "I");
|
||||||
|
}
|
||||||
|
|
||||||
|
public static String toRoman(int number) {
|
||||||
|
int l = RomanNumber.map.floorKey(number);
|
||||||
|
if (number == l) {
|
||||||
|
return RomanNumber.map.get(number);
|
||||||
|
}
|
||||||
|
return RomanNumber.map.get(l) + toRoman(number - l);
|
||||||
|
}
|
||||||
|
}
|
||||||
47
src/main/java/com/massivecraft/factions/util/Updater.java
Normal file
47
src/main/java/com/massivecraft/factions/util/Updater.java
Normal file
@@ -0,0 +1,47 @@
|
|||||||
|
package com.massivecraft.factions.util;
|
||||||
|
|
||||||
|
import com.massivecraft.factions.FactionsPlugin;
|
||||||
|
import org.bukkit.configuration.file.FileConfiguration;
|
||||||
|
|
||||||
|
import java.io.File;
|
||||||
|
import java.io.IOException;
|
||||||
|
import java.util.ArrayList;
|
||||||
|
import java.util.List;
|
||||||
|
|
||||||
|
public class Updater {
|
||||||
|
public static double currentVersion = 1.1;
|
||||||
|
public static void updateIfNeeded(FileConfiguration conf) {
|
||||||
|
double version = conf.getDouble("Config-Version", 0);
|
||||||
|
//Previous version
|
||||||
|
if (version == 0) {
|
||||||
|
//Instructions for this configuration to be updated to current
|
||||||
|
FactionsPlugin.getInstance().log("Your config.yml is pre-versioning so we are going to assign it version 1.0 \n Please regenerate your config.yml if you run into any errors relating to config.");
|
||||||
|
conf.set("Config-Version", 1.0);
|
||||||
|
version = 1.0;
|
||||||
|
}
|
||||||
|
if (version == 1.0) {
|
||||||
|
FactionsPlugin.getInstance().log("Updating config from version 1.0 to 1.1");
|
||||||
|
FactionsPlugin.getInstance().log("Adding randomization support for f missions...");
|
||||||
|
conf.set("Randomization.Enabled", false);
|
||||||
|
conf.set("Randomization.Start-Item.Allowed.Name", "&aStart!");
|
||||||
|
conf.set("Randomization.Start-Item.Allowed.Material", "GREEN_STAINED_GLASS_PANE");
|
||||||
|
List<String> lore = new ArrayList<>();
|
||||||
|
lore.add("&aStart a new mission!");
|
||||||
|
conf.set("Randomization.Start-Item.Allowed.Lore", lore);
|
||||||
|
conf.set("Randomization.Start-Item.Disallowed.Name", "&4Cannot start new mission");
|
||||||
|
conf.set("Randomization.Start-Item.Disallowed.Material", "GRAY_STAINED_GLASS_PANE");
|
||||||
|
lore.clear();
|
||||||
|
lore.add("&4%reason%");
|
||||||
|
conf.set("Randomization.Start-Item.Disallowed.Lore", lore);
|
||||||
|
conf.set("Randomization.Start-Item.Slot", 28);
|
||||||
|
conf.set("Config-Version", 1.1);
|
||||||
|
version = 1.1;
|
||||||
|
|
||||||
|
}
|
||||||
|
//End with save + reload
|
||||||
|
try {
|
||||||
|
conf.save(new File("plugins/Factions/config.yml"));
|
||||||
|
FactionsPlugin.getInstance().reloadConfig();
|
||||||
|
} catch (IOException e) {e.printStackTrace();}
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -0,0 +1,20 @@
|
|||||||
|
package com.massivecraft.factions.util.serializable;
|
||||||
|
|
||||||
|
public class InventoryUtils {
|
||||||
|
private int x;
|
||||||
|
private int y;
|
||||||
|
private int rows;
|
||||||
|
|
||||||
|
public InventoryUtils(int x, int y, int rows) {
|
||||||
|
this.x = x;
|
||||||
|
this.y = y;
|
||||||
|
this.rows = rows;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void increment() {
|
||||||
|
if (this.x == 9) {
|
||||||
|
this.x = 0;
|
||||||
|
++this.y;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -0,0 +1,40 @@
|
|||||||
|
package com.massivecraft.factions.util.serializable;
|
||||||
|
|
||||||
|
|
||||||
|
import com.massivecraft.factions.util.ItemBuilder;
|
||||||
|
import com.massivecraft.factions.util.XMaterial;
|
||||||
|
import org.bukkit.inventory.ItemStack;
|
||||||
|
|
||||||
|
import java.util.List;
|
||||||
|
|
||||||
|
public class Item {
|
||||||
|
private String name;
|
||||||
|
private List<String> lore;
|
||||||
|
private XMaterial material;
|
||||||
|
private int amount;
|
||||||
|
private int slot;
|
||||||
|
|
||||||
|
public Item(String name, List<String> lore, XMaterial material, int amount, int slot) {
|
||||||
|
this.name = name;
|
||||||
|
this.lore = lore;
|
||||||
|
this.material = material;
|
||||||
|
this.amount = amount;
|
||||||
|
this.slot = slot;
|
||||||
|
}
|
||||||
|
|
||||||
|
public ItemStack buildItemStack(boolean isSelected) {
|
||||||
|
return new ItemBuilder(material.parseItem()).name(name).lore(lore).glowing(isSelected).amount(amount).build();
|
||||||
|
}
|
||||||
|
|
||||||
|
public int getAmount() {
|
||||||
|
return this.amount;
|
||||||
|
}
|
||||||
|
|
||||||
|
public String getName() {
|
||||||
|
return this.name;
|
||||||
|
}
|
||||||
|
|
||||||
|
public int getSlot() {
|
||||||
|
return this.slot;
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -37,6 +37,7 @@ public class PermissableRelationFrame {
|
|||||||
GUIItems.add(new GuiItem(dumby, e -> e.setCancelled(true)));
|
GUIItems.add(new GuiItem(dumby, e -> e.setCancelled(true)));
|
||||||
ConfigurationSection sec = FactionsPlugin.getInstance().getConfig().getConfigurationSection("fperm-gui.relation");
|
ConfigurationSection sec = FactionsPlugin.getInstance().getConfig().getConfigurationSection("fperm-gui.relation");
|
||||||
for (String key : sec.getConfigurationSection("slots").getKeys(false)) {
|
for (String key : sec.getConfigurationSection("slots").getKeys(false)) {
|
||||||
|
if (key == null || sec.getInt("slots." + key) < 0) continue;
|
||||||
GUIItems.set(sec.getInt("slots." + key), new GuiItem(buildAsset("fperm-gui.relation.materials." + key, key), e -> {
|
GUIItems.set(sec.getInt("slots." + key), new GuiItem(buildAsset("fperm-gui.relation.materials." + key, key), e -> {
|
||||||
e.setCancelled(true);
|
e.setCancelled(true);
|
||||||
// Closing and opening resets the cursor.
|
// Closing and opening resets the cursor.
|
||||||
|
|||||||
@@ -41,6 +41,7 @@ import java.util.*;
|
|||||||
*/
|
*/
|
||||||
|
|
||||||
public abstract class MemoryFPlayer implements FPlayer {
|
public abstract class MemoryFPlayer implements FPlayer {
|
||||||
|
public boolean inChest = false;
|
||||||
public boolean inVault = false;
|
public boolean inVault = false;
|
||||||
protected HashMap<String, Long> commandCooldown = new HashMap<>();
|
protected HashMap<String, Long> commandCooldown = new HashMap<>();
|
||||||
protected String factionId;
|
protected String factionId;
|
||||||
@@ -816,7 +817,7 @@ public abstract class MemoryFPlayer implements FPlayer {
|
|||||||
int factionBuffer = FactionsPlugin.getInstance().getConfig().getInt("hcf.buffer-zone", 0);
|
int factionBuffer = FactionsPlugin.getInstance().getConfig().getInt("hcf.buffer-zone", 0);
|
||||||
int worldBuffer = FactionsPlugin.getInstance().getConfig().getInt("world-border.buffer", 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
|
// Checks for WorldGuard regions in the chunk attempting to be claimed
|
||||||
error = FactionsPlugin.getInstance().txt.parse(TL.CLAIM_PROTECTED.toString());
|
error = FactionsPlugin.getInstance().txt.parse(TL.CLAIM_PROTECTED.toString());
|
||||||
} else if (flocation.isOutsideWorldBorder(FactionsPlugin.getInstance().getConfig().getInt("world-border.buffer", 0))) {
|
} else if (flocation.isOutsideWorldBorder(FactionsPlugin.getInstance().getConfig().getInt("world-border.buffer", 0))) {
|
||||||
@@ -963,6 +964,12 @@ public abstract class MemoryFPlayer implements FPlayer {
|
|||||||
isFlying = fly;
|
isFlying = fly;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public boolean isInFactionsChest() {
|
||||||
|
return inChest;
|
||||||
|
}
|
||||||
|
public void setInFactionsChest(boolean b) {
|
||||||
|
inChest = b;
|
||||||
|
}
|
||||||
public boolean isInVault() {
|
public boolean isInVault() {
|
||||||
return inVault;
|
return inVault;
|
||||||
}
|
}
|
||||||
@@ -981,7 +988,7 @@ public abstract class MemoryFPlayer implements FPlayer {
|
|||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (faction.isWilderness() || faction.isSafeZone() || faction.isWarZone()){
|
if (faction.isSystemFaction()) {
|
||||||
return CmdFly.checkBypassPerms(this, this.getPlayer(), faction);
|
return CmdFly.checkBypassPerms(this, this.getPlayer(), faction);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -870,13 +870,7 @@ public abstract class MemoryFaction implements Faction, EconomyParticipator {
|
|||||||
return Access.UNDEFINED;
|
return Access.UNDEFINED;
|
||||||
}
|
}
|
||||||
|
|
||||||
Permissable perm;
|
Permissable perm = player.getFaction() == null ? player.getRole() : player.getFaction().getRelationTo(this);
|
||||||
|
|
||||||
if (player.getFaction() == this) {
|
|
||||||
perm = player.getRole();
|
|
||||||
} else {
|
|
||||||
perm = player.getFaction().getRelationTo(this);
|
|
||||||
}
|
|
||||||
|
|
||||||
Map<PermissableAction, Access> accessMap = permissions.get(perm);
|
Map<PermissableAction, Access> accessMap = permissions.get(perm);
|
||||||
if (accessMap != null && accessMap.containsKey(permissableAction)) {
|
if (accessMap != null && accessMap.containsKey(permissableAction)) {
|
||||||
|
|||||||
@@ -103,6 +103,18 @@ public class Persist {
|
|||||||
return DiscUtil.writeCatch(file, p.gson.toJson(instance), false);
|
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
|
// LOAD BY CLASS
|
||||||
|
|
||||||
public <T> T load(Class<T> clazz) {
|
public <T> T load(Class<T> clazz) {
|
||||||
|
|||||||
@@ -56,6 +56,12 @@ public enum TL {
|
|||||||
ACTIONS_MUSTBE("Youmust be {role} to {action}."),
|
ACTIONS_MUSTBE("Youmust be {role} to {action}."),
|
||||||
ACTIONS_NOSAMEROLE("{role} can't control each other..."),
|
ACTIONS_NOSAMEROLE("{role} can't control each other..."),
|
||||||
ACTIONS_NOFACTION("You are not member of any faction."),
|
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
|
* Command translations
|
||||||
*/
|
*/
|
||||||
@@ -882,7 +888,7 @@ public enum TL {
|
|||||||
COMMAND_TNT_WIDTHDRAW_SUCCESS("&cSuccessfully withdrew tnt."),
|
COMMAND_TNT_WIDTHDRAW_SUCCESS("&cSuccessfully withdrew tnt."),
|
||||||
COMMAND_TNT_WIDTHDRAW_NOTENOUGH("&cNot enough tnt in bank."),
|
COMMAND_TNT_WIDTHDRAW_NOTENOUGH("&cNot enough tnt in bank."),
|
||||||
COMMAND_TNT_DEPOSIT_NOTENOUGH("&cNot enough tnt in tnt inventory."),
|
COMMAND_TNT_DEPOSIT_NOTENOUGH("&cNot enough tnt in tnt inventory."),
|
||||||
COMMAND_TNT_AMOUNT("&cYour faction has %1$s tnt out of %2$s in the tnt bank."),
|
COMMAND_TNT_AMOUNT("&cYour faction has %1$s tnt in the tnt bank."),
|
||||||
COMMAND_TNT_POSITIVE("&cPlease use positive numbers!"),
|
COMMAND_TNT_POSITIVE("&cPlease use positive numbers!"),
|
||||||
COMMAND_TNT_DESCRIPTION("add/widthraw from faction's tnt bank"),
|
COMMAND_TNT_DESCRIPTION("add/widthraw from faction's tnt bank"),
|
||||||
COMMAND_TNT_WIDTHDRAW_NOTENOUGH_SPACE("&cNot enough space in your inventory."),
|
COMMAND_TNT_WIDTHDRAW_NOTENOUGH_SPACE("&cNot enough space in your inventory."),
|
||||||
@@ -1020,6 +1026,7 @@ public enum TL {
|
|||||||
GENERIC_TRANSLATION_VERSION("Translation: %1$s(%2$s,%3$s) State: %4$s"),
|
GENERIC_TRANSLATION_VERSION("Translation: %1$s(%2$s,%3$s) State: %4$s"),
|
||||||
GENERIC_TRANSLATION_CONTRIBUTORS("Translation contributors: %1$s"),
|
GENERIC_TRANSLATION_CONTRIBUTORS("Translation contributors: %1$s"),
|
||||||
GENERIC_TRANSLATION_RESPONSIBLE("Responsible for translation: %1$s"),
|
GENERIC_TRANSLATION_RESPONSIBLE("Responsible for translation: %1$s"),
|
||||||
|
GENERIC_FACTIONTAG_BLACKLIST("&cThat faction tag is blacklisted."),
|
||||||
GENERIC_FACTIONTAG_TOOSHORT("The faction tag can't be shorter than %1$s chars."),
|
GENERIC_FACTIONTAG_TOOSHORT("The faction tag can't be shorter than %1$s chars."),
|
||||||
GENERIC_FACTIONTAG_TOOLONG("The faction tag can't be longer than %s chars."),
|
GENERIC_FACTIONTAG_TOOLONG("The faction tag can't be longer than %s chars."),
|
||||||
GENERIC_FACTIONTAG_ALPHANUMERIC("Faction tag must be alphanumeric. \"%s\" is not allowed."),
|
GENERIC_FACTIONTAG_ALPHANUMERIC("Faction tag must be alphanumeric. \"%s\" is not allowed."),
|
||||||
@@ -1035,7 +1042,8 @@ public enum TL {
|
|||||||
MISSION_MISSION_STARTED("&f%1$s &dstarted the %2$s &fmission"),
|
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_ALREAD_COMPLETED("&c&l[!] &7You may not restart a mission you have already completed"),
|
||||||
MISSION_MISSION_ACTIVE("&c&l[!] &7This mission is currently active!"),
|
MISSION_MISSION_ACTIVE("&c&l[!] &7This mission is currently active!"),
|
||||||
MISSION_MISSION_MAX_ALLOWED("&c&l[!] &7You may not have more then &b%1$s &7missions active at once."),
|
MISSION_MISSION_MAX_ALLOWED("&c&l[!] &7You may not have more than &b%1$s &7missions active at once."),
|
||||||
|
MISSION_MISSION_ALL_COMPLETED("&c&l[!] &7Your faction has completed all available missions."),
|
||||||
MISSION_MISSION_FINISHED("&c&l[!] &7Your faction has successfully completed %1$s mission!"),
|
MISSION_MISSION_FINISHED("&c&l[!] &7Your faction has successfully completed %1$s mission!"),
|
||||||
COMMAND_MISSION_DESCRIPTION("Opens missions gui"),
|
COMMAND_MISSION_DESCRIPTION("Opens missions gui"),
|
||||||
// F Global \\
|
// F Global \\
|
||||||
@@ -1043,6 +1051,7 @@ public enum TL {
|
|||||||
|
|
||||||
PLAYER_NOT_FOUND("&c&l[!] &b%1$s &7is either not online or not in your faction!"),
|
PLAYER_NOT_FOUND("&c&l[!] &b%1$s &7is either not online or not in your faction!"),
|
||||||
PLACEHOLDER_ROLE_NAME("None"),
|
PLACEHOLDER_ROLE_NAME("None"),
|
||||||
|
PLACEHOLDER_CUSTOM_FACTION("{faction} "),
|
||||||
|
|
||||||
|
|
||||||
WARBANNER_NOFACTION("&cYou need a faction to use a warbanner!"),
|
WARBANNER_NOFACTION("&cYou need a faction to use a warbanner!"),
|
||||||
|
|||||||
@@ -1,3 +1,4 @@
|
|||||||
|
Config-Version: 1.1
|
||||||
# SaberFactions by Driftay
|
# SaberFactions by Driftay
|
||||||
# Report issues: https://github.com/Driftay/Saber-Factions/issues/new
|
# Report issues: https://github.com/Driftay/Saber-Factions/issues/new
|
||||||
# Live support: https://discord.gg/TFxWKeX
|
# Live support: https://discord.gg/TFxWKeX
|
||||||
@@ -747,18 +748,34 @@ f-points:
|
|||||||
# | Faction Missions | #
|
# | Faction Missions | #
|
||||||
# +------------------------------------------------------+ #
|
# +------------------------------------------------------+ #
|
||||||
############################################################
|
############################################################
|
||||||
MissionGUISize: 3
|
MissionGUISize: 4
|
||||||
Missions-Enabled: true
|
Missions-Enabled: true
|
||||||
Missions-GUI-Title: '&8&lFaction Missions'
|
Missions-GUI-Title: '&8&lFaction Missions'
|
||||||
MaximumMissionsAllowedAtOnce: 1
|
MaximumMissionsAllowedAtOnce: 1
|
||||||
Mission-Progress-Format: '&b&lProgression: &f{progress}&7/&e{total}'
|
Mission-Progress-Format: '&b&lProgression: &f{progress}&7/&e{total}'
|
||||||
|
Randomization:
|
||||||
|
Enabled: false
|
||||||
|
Start-Item:
|
||||||
|
# Allowed means that they are under maximum allowed missions at one AND if applicable they have not completed every mission more than once
|
||||||
|
Allowed:
|
||||||
|
Name: "&aStart!"
|
||||||
|
Material: GREEN_STAINED_GLASS_PANE
|
||||||
|
Lore: "&2Start a new mission!"
|
||||||
|
Disallowed:
|
||||||
|
# Placeholder %reason% supported throughout this section
|
||||||
|
Name: "&4Cannot start new mission"
|
||||||
|
Material: GRAY_STAINED_GLASS_PANE
|
||||||
|
Lore:
|
||||||
|
- '&4%reason%'
|
||||||
|
# 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
|
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
|
#Mission Types: KILL, MINE, PLACE, FISH, TAME, ENCHANT, CONSUME
|
||||||
Missions:
|
Missions:
|
||||||
FillItem:
|
FillItem:
|
||||||
Material: BLACK_STAINED_GLASS_PANE
|
Material: BLACK_STAINED_GLASS_PANE
|
||||||
Rows: 3
|
Rows: 4
|
||||||
sugarcane:
|
sugarcane:
|
||||||
Slot: 11
|
Slot: 11
|
||||||
Material: "SUGAR_CANE"
|
Material: "SUGAR_CANE"
|
||||||
|
|||||||
Reference in New Issue
Block a user