Code Cleanup/Added Configurable option to deny and remove homes in ANY factions land.

More Soon..
This commit is contained in:
Driftay
2019-02-10 23:57:45 -05:00
parent 3559a9f090
commit 5a37320397
125 changed files with 3676 additions and 3410 deletions

View File

@@ -107,7 +107,7 @@ public class ClipPlaceholderAPIManager extends PlaceholderExpansion implements R
case "faction_claims":
return String.valueOf(faction.getAllClaims().size());
case "faction_founded":
return String.valueOf(TL.sdf.format(faction.getFoundedDate()));
return TL.sdf.format(faction.getFoundedDate());
case "faction_joining":
return (faction.getOpen() ? TL.COMMAND_SHOW_UNINVITED.toString() : TL.COMMAND_SHOW_INVITATION.toString());
case "faction_peaceful":
@@ -156,8 +156,8 @@ public class ClipPlaceholderAPIManager extends PlaceholderExpansion implements R
case "faction_maxvaults":
return String.valueOf(faction.getMaxVaults());
case "faction_name_at_location":
Faction factionAtLocation = Board.getInstance().getFactionAt(new FLocation(player.getLocation()));
return factionAtLocation != null ? factionAtLocation.getTag():Factions.getInstance().getWilderness().getTag();
Faction factionAtLocation = Board.getInstance().getFactionAt(new FLocation(player.getLocation()));
return factionAtLocation != null ? factionAtLocation.getTag() : Factions.getInstance().getWilderness().getTag();
}
return null;

View File

@@ -1,66 +1,66 @@
package com.massivecraft.factions.util;
import com.google.gson.Gson;
import com.google.gson.TypeAdapter;
import com.google.gson.TypeAdapterFactory;
import com.google.gson.annotations.SerializedName;
import com.google.gson.reflect.TypeToken;
import com.google.gson.stream.JsonReader;
import com.google.gson.stream.JsonToken;
import com.google.gson.stream.JsonWriter;
import java.io.IOException;
import java.util.HashMap;
import java.util.Map;
public final class EnumTypeAdapter<T extends Enum<T>> extends TypeAdapter<T> {
public static final TypeAdapterFactory ENUM_FACTORY = newEnumTypeHierarchyFactory();
private final Map<String, T> nameToConstant = new HashMap<>();
private final Map<T, String> constantToName = new HashMap<>();
public EnumTypeAdapter(Class<T> classOfT) {
try {
for (T constant : classOfT.getEnumConstants()) {
String name = constant.name();
SerializedName annotation = classOfT.getField(name).getAnnotation(SerializedName.class);
if (annotation != null) {
name = annotation.value();
}
nameToConstant.put(name, constant);
constantToName.put(constant, name);
}
} catch (NoSuchFieldException e) {
// ignore since it could be a modified enum
}
}
public static <TT> TypeAdapterFactory newEnumTypeHierarchyFactory() {
return new TypeAdapterFactory() {
@SuppressWarnings ({"rawtypes", "unchecked"})
public <T> TypeAdapter<T> create(Gson gson, TypeToken<T> typeToken) {
Class<? super T> rawType = typeToken.getRawType();
if (!Enum.class.isAssignableFrom(rawType) || rawType == Enum.class) {
return null;
}
if (!rawType.isEnum()) {
rawType = rawType.getSuperclass(); // handle anonymous subclasses
}
return (TypeAdapter<T>) new EnumTypeAdapter(rawType);
}
};
}
public T read(JsonReader in) throws IOException {
if (in.peek() == JsonToken.NULL) {
in.nextNull();
return null;
}
return nameToConstant.get(in.nextString());
}
public void write(JsonWriter out, T value) throws IOException {
out.value(value == null ? null : constantToName.get(value));
}
}
package com.massivecraft.factions.util;
import com.google.gson.Gson;
import com.google.gson.TypeAdapter;
import com.google.gson.TypeAdapterFactory;
import com.google.gson.annotations.SerializedName;
import com.google.gson.reflect.TypeToken;
import com.google.gson.stream.JsonReader;
import com.google.gson.stream.JsonToken;
import com.google.gson.stream.JsonWriter;
import java.io.IOException;
import java.util.HashMap;
import java.util.Map;
public final class EnumTypeAdapter<T extends Enum<T>> extends TypeAdapter<T> {
public static final TypeAdapterFactory ENUM_FACTORY = newEnumTypeHierarchyFactory();
private final Map<String, T> nameToConstant = new HashMap<>();
private final Map<T, String> constantToName = new HashMap<>();
public EnumTypeAdapter(Class<T> classOfT) {
try {
for (T constant : classOfT.getEnumConstants()) {
String name = constant.name();
SerializedName annotation = classOfT.getField(name).getAnnotation(SerializedName.class);
if (annotation != null) {
name = annotation.value();
}
nameToConstant.put(name, constant);
constantToName.put(constant, name);
}
} catch (NoSuchFieldException e) {
// ignore since it could be a modified enum
}
}
public static <TT> TypeAdapterFactory newEnumTypeHierarchyFactory() {
return new TypeAdapterFactory() {
@SuppressWarnings({"rawtypes", "unchecked"})
public <T> TypeAdapter<T> create(Gson gson, TypeToken<T> typeToken) {
Class<? super T> rawType = typeToken.getRawType();
if (!Enum.class.isAssignableFrom(rawType) || rawType == Enum.class) {
return null;
}
if (!rawType.isEnum()) {
rawType = rawType.getSuperclass(); // handle anonymous subclasses
}
return (TypeAdapter<T>) new EnumTypeAdapter(rawType);
}
};
}
public T read(JsonReader in) throws IOException {
if (in.peek() == JsonToken.NULL) {
in.nextNull();
return null;
}
return nameToConstant.get(in.nextString());
}
public void write(JsonWriter out, T value) throws IOException {
out.value(value == null ? null : constantToName.get(value));
}
}

View File

@@ -4,8 +4,8 @@ import org.bukkit.event.inventory.ClickType;
public interface FactionGUI {
public void onClick(int slot, ClickType action);
void onClick(int slot, ClickType action);
public void build();
void build();
}

View File

@@ -12,7 +12,7 @@ import java.io.Serializable;
*/
public class LazyLocation implements Serializable {
private static final long serialVersionUID = - 6049901271320963314L;
private static final long serialVersionUID = -6049901271320963314L;
private transient Location location = null;
private String worldName;
private double x;

View File

@@ -100,11 +100,21 @@ public class MiscUtil {
}
switch (player.getRole()) {
case LEADER: admins.add(player); break;
case COLEADER: admins.add(player); break;
case MODERATOR: moderators.add(player); break;
case NORMAL: normal.add(player); break;
case RECRUIT: recruit.add(player); break;
case LEADER:
admins.add(player);
break;
case COLEADER:
admins.add(player);
break;
case MODERATOR:
moderators.add(player);
break;
case NORMAL:
normal.add(player);
break;
case RECRUIT:
recruit.add(player);
break;
}
}

View File

@@ -858,8 +858,8 @@ public enum MultiversionMaterials {
ZOMBIE_VILLAGER_SPAWN_EGG("MONSTER_EGG", 0),
ZOMBIE_WALL_HEAD("SKULL", 0),
;
static int newV = - 1;
static int newV = -1;
private static HashMap<String, MultiversionMaterials> cachedSearch = new HashMap<>();
String m;
int data;
@@ -872,13 +872,13 @@ public enum MultiversionMaterials {
public static boolean isNewVersion() {
if (newV == 0) return false;
if (newV == 1) return true;
Material mat = Material.matchMaterial("RED_WOOL");
if (mat != null) {
newV = 1;
return true;
}
newV = 0;
return false;
}
@@ -898,11 +898,11 @@ public enum MultiversionMaterials {
public static MultiversionMaterials fromString(String key) {
try {
return MultiversionMaterials.valueOf(key);
return MultiversionMaterials.valueOf(key);
} catch (IllegalArgumentException e) {
String[] split = key.split(":");
return split.length == 1 ? requestXMaterial(key, (byte) 0):requestXMaterial(split[0], (byte) Integer.parseInt(split[1]));
return split.length == 1 ? requestXMaterial(key, (byte) 0) : requestXMaterial(split[0], (byte) Integer.parseInt(split[1]));
}
}
@@ -944,7 +944,7 @@ public enum MultiversionMaterials {
public boolean isDamageable(MultiversionMaterials type) {
String[] split = type.toString().split("_");
switch (split[split.length - 1]) {
case "HELMET":
case "CHESTPLATE":
@@ -968,7 +968,7 @@ public enum MultiversionMaterials {
public Material parseMaterial() {
Material mat = Material.matchMaterial(this.toString());
return mat != null ? mat:Material.matchMaterial(m);
return mat != null ? mat : Material.matchMaterial(m);
}
}

View File

@@ -20,7 +20,7 @@ import java.util.Map.Entry;
/**
* <b>ParticleEffect Library</b>
* This library was created by @DarkBlade12 and allows you to display all Minecraft particle effects on a Bukkit server
*
* <p>
* You are welcome to use it, modify it and redistribute it under the following conditions:
* <ul>
* <li>Don't claim this class as your own
@@ -47,7 +47,7 @@ public enum ParticleEffect {
* <li>The speed value influences the velocity at which the particle flies off
* </ul>
*/
EXPLOSION_NORMAL("explode", 0, - 1, ParticleProperty.DIRECTIONAL),
EXPLOSION_NORMAL("explode", 0, -1, ParticleProperty.DIRECTIONAL),
/**
* A particle effect which is displayed by exploding ghast fireballs and wither skulls:
* <ul>
@@ -55,7 +55,7 @@ public enum ParticleEffect {
* <li>The speed value slightly influences the size of this particle effect
* </ul>
*/
EXPLOSION_LARGE("largeexplode", 1, - 1),
EXPLOSION_LARGE("largeexplode", 1, -1),
/**
* A particle effect which is displayed by exploding tnt and creepers:
* <ul>
@@ -63,7 +63,7 @@ public enum ParticleEffect {
* <li>The speed value has no influence on this particle effect
* </ul>
*/
EXPLOSION_HUGE("hugeexplosion", 2, - 1),
EXPLOSION_HUGE("hugeexplosion", 2, -1),
/**
* A particle effect which is displayed by launching fireworks:
* <ul>
@@ -71,7 +71,7 @@ public enum ParticleEffect {
* <li>The speed value influences the velocity at which the particle flies off
* </ul>
*/
FIREWORKS_SPARK("fireworksSpark", 3, - 1, ParticleProperty.DIRECTIONAL),
FIREWORKS_SPARK("fireworksSpark", 3, -1, ParticleProperty.DIRECTIONAL),
/**
* A particle effect which is displayed by swimming entities and arrows in water:
* <ul>
@@ -79,7 +79,7 @@ public enum ParticleEffect {
* <li>The speed value influences the velocity at which the particle flies off
* </ul>
*/
WATER_BUBBLE("bubble", 4, - 1, ParticleProperty.DIRECTIONAL, ParticleProperty.REQUIRES_WATER),
WATER_BUBBLE("bubble", 4, -1, ParticleProperty.DIRECTIONAL, ParticleProperty.REQUIRES_WATER),
/**
* A particle effect which is displayed by swimming entities and shaking wolves:
* <ul>
@@ -87,7 +87,7 @@ public enum ParticleEffect {
* <li>The speed value has no influence on this particle effect
* </ul>
*/
WATER_SPLASH("splash", 5, - 1, ParticleProperty.DIRECTIONAL),
WATER_SPLASH("splash", 5, -1, ParticleProperty.DIRECTIONAL),
/**
* A particle effect which is displayed on water when fishing:
* <ul>
@@ -103,7 +103,7 @@ public enum ParticleEffect {
* <li>The speed value has no influence on this particle effect
* </ul>
*/
SUSPENDED("suspended", 7, - 1, ParticleProperty.REQUIRES_WATER),
SUSPENDED("suspended", 7, -1, ParticleProperty.REQUIRES_WATER),
/**
* A particle effect which is displayed by air when close to bedrock and the in the void:
* <ul>
@@ -111,7 +111,7 @@ public enum ParticleEffect {
* <li>The speed value has no influence on this particle effect
* </ul>
*/
SUSPENDED_DEPTH("depthSuspend", 8, - 1, ParticleProperty.DIRECTIONAL),
SUSPENDED_DEPTH("depthSuspend", 8, -1, ParticleProperty.DIRECTIONAL),
/**
* A particle effect which is displayed when landing a critical hit and by arrows:
* <ul>
@@ -119,7 +119,7 @@ public enum ParticleEffect {
* <li>The speed value influences the velocity at which the particle flies off
* </ul>
*/
CRIT("crit", 9, - 1, ParticleProperty.DIRECTIONAL),
CRIT("crit", 9, -1, ParticleProperty.DIRECTIONAL),
/**
* A particle effect which is displayed when landing a hit with an enchanted weapon:
* <ul>
@@ -127,7 +127,7 @@ public enum ParticleEffect {
* <li>The speed value influences the velocity at which the particle flies off
* </ul>
*/
CRIT_MAGIC("magicCrit", 10, - 1, ParticleProperty.DIRECTIONAL),
CRIT_MAGIC("magicCrit", 10, -1, ParticleProperty.DIRECTIONAL),
/**
* A particle effect which is displayed by primed tnt, torches, droppers, dispensers, end portals, brewing stands and monster spawners:
* <ul>
@@ -135,7 +135,7 @@ public enum ParticleEffect {
* <li>The speed value influences the velocity at which the particle flies off
* </ul>
*/
SMOKE_NORMAL("smoke", 11, - 1, ParticleProperty.DIRECTIONAL),
SMOKE_NORMAL("smoke", 11, -1, ParticleProperty.DIRECTIONAL),
/**
* A particle effect which is displayed by fire, minecarts with furnace and blazes:
* <ul>
@@ -143,7 +143,7 @@ public enum ParticleEffect {
* <li>The speed value influences the velocity at which the particle flies off
* </ul>
*/
SMOKE_LARGE("largesmoke", 12, - 1, ParticleProperty.DIRECTIONAL),
SMOKE_LARGE("largesmoke", 12, -1, ParticleProperty.DIRECTIONAL),
/**
* A particle effect which is displayed when splash potions or bottles o' enchanting hit something:
* <ul>
@@ -152,7 +152,7 @@ public enum ParticleEffect {
* <li>Only the motion on the y-axis can be controlled, the motion on the x- and z-axis are multiplied by 0.1 when setting the values to 0
* </ul>
*/
SPELL("spell", 13, - 1),
SPELL("spell", 13, -1),
/**
* A particle effect which is displayed when instant splash potions hit something:
* <ul>
@@ -161,7 +161,7 @@ public enum ParticleEffect {
* <li>Only the motion on the y-axis can be controlled, the motion on the x- and z-axis are multiplied by 0.1 when setting the values to 0
* </ul>
*/
SPELL_INSTANT("instantSpell", 14, - 1),
SPELL_INSTANT("instantSpell", 14, -1),
/**
* A particle effect which is displayed by entities with active potion effects:
* <ul>
@@ -170,7 +170,7 @@ public enum ParticleEffect {
* <li>The particle color gets lighter when increasing the speed and darker when decreasing the speed
* </ul>
*/
SPELL_MOB("mobSpell", 15, - 1, ParticleProperty.COLORABLE),
SPELL_MOB("mobSpell", 15, -1, ParticleProperty.COLORABLE),
/**
* A particle effect which is displayed by entities with active potion effects applied through a beacon:
* <ul>
@@ -179,7 +179,7 @@ public enum ParticleEffect {
* <li>The particle color gets lighter when increasing the speed and darker when decreasing the speed
* </ul>
*/
SPELL_MOB_AMBIENT("mobSpellAmbient", 16, - 1, ParticleProperty.COLORABLE),
SPELL_MOB_AMBIENT("mobSpellAmbient", 16, -1, ParticleProperty.COLORABLE),
/**
* A particle effect which is displayed by witches:
* <ul>
@@ -188,7 +188,7 @@ public enum ParticleEffect {
* <li>Only the motion on the y-axis can be controlled, the motion on the x- and z-axis are multiplied by 0.1 when setting the values to 0
* </ul>
*/
SPELL_WITCH("witchMagic", 17, - 1),
SPELL_WITCH("witchMagic", 17, -1),
/**
* A particle effect which is displayed by blocks beneath a water source:
* <ul>
@@ -196,7 +196,7 @@ public enum ParticleEffect {
* <li>The speed value has no influence on this particle effect
* </ul>
*/
DRIP_WATER("dripWater", 18, - 1),
DRIP_WATER("dripWater", 18, -1),
/**
* A particle effect which is displayed by blocks beneath a lava source:
* <ul>
@@ -204,7 +204,7 @@ public enum ParticleEffect {
* <li>The speed value has no influence on this particle effect
* </ul>
*/
DRIP_LAVA("dripLava", 19, - 1),
DRIP_LAVA("dripLava", 19, -1),
/**
* A particle effect which is displayed when attacking a villager in a village:
* <ul>
@@ -212,7 +212,7 @@ public enum ParticleEffect {
* <li>The speed value has no influence on this particle effect
* </ul>
*/
VILLAGER_ANGRY("angryVillager", 20, - 1),
VILLAGER_ANGRY("angryVillager", 20, -1),
/**
* A particle effect which is displayed when using bone meal and trading with a villager in a village:
* <ul>
@@ -220,7 +220,7 @@ public enum ParticleEffect {
* <li>The speed value has no influence on this particle effect
* </ul>
*/
VILLAGER_HAPPY("happyVillager", 21, - 1, ParticleProperty.DIRECTIONAL),
VILLAGER_HAPPY("happyVillager", 21, -1, ParticleProperty.DIRECTIONAL),
/**
* A particle effect which is displayed by mycelium:
* <ul>
@@ -228,7 +228,7 @@ public enum ParticleEffect {
* <li>The speed value has no influence on this particle effect
* </ul>
*/
TOWN_AURA("townaura", 22, - 1, ParticleProperty.DIRECTIONAL),
TOWN_AURA("townaura", 22, -1, ParticleProperty.DIRECTIONAL),
/**
* A particle effect which is displayed by note blocks:
* <ul>
@@ -236,7 +236,7 @@ public enum ParticleEffect {
* <li>The speed value causes the particle to be colored green when set to 0
* </ul>
*/
NOTE("note", 23, - 1, ParticleProperty.COLORABLE),
NOTE("note", 23, -1, ParticleProperty.COLORABLE),
/**
* A particle effect which is displayed by nether portals, endermen, ender pearls, eyes of ender, ender chests and dragon eggs:
* <ul>
@@ -244,7 +244,7 @@ public enum ParticleEffect {
* <li>The speed value influences the spread of this particle effect
* </ul>
*/
PORTAL("portal", 24, - 1, ParticleProperty.DIRECTIONAL),
PORTAL("portal", 24, -1, ParticleProperty.DIRECTIONAL),
/**
* A particle effect which is displayed by enchantment tables which are nearby bookshelves:
* <ul>
@@ -252,7 +252,7 @@ public enum ParticleEffect {
* <li>The speed value influences the spread of this particle effect
* </ul>
*/
ENCHANTMENT_TABLE("enchantmenttable", 25, - 1, ParticleProperty.DIRECTIONAL),
ENCHANTMENT_TABLE("enchantmenttable", 25, -1, ParticleProperty.DIRECTIONAL),
/**
* A particle effect which is displayed by torches, active furnaces, magma cubes and monster spawners:
* <ul>
@@ -260,7 +260,7 @@ public enum ParticleEffect {
* <li>The speed value influences the velocity at which the particle flies off
* </ul>
*/
FLAME("flame", 26, - 1, ParticleProperty.DIRECTIONAL),
FLAME("flame", 26, -1, ParticleProperty.DIRECTIONAL),
/**
* A particle effect which is displayed by lava:
* <ul>
@@ -268,7 +268,7 @@ public enum ParticleEffect {
* <li>The speed value has no influence on this particle effect
* </ul>
*/
LAVA("lava", 27, - 1),
LAVA("lava", 27, -1),
/**
* A particle effect which is currently unused:
* <ul>
@@ -276,7 +276,7 @@ public enum ParticleEffect {
* <li>The speed value has no influence on this particle effect
* </ul>
*/
FOOTSTEP("footstep", 28, - 1),
FOOTSTEP("footstep", 28, -1),
/**
* A particle effect which is displayed when a mob dies:
* <ul>
@@ -284,7 +284,7 @@ public enum ParticleEffect {
* <li>The speed value influences the velocity at which the particle flies off
* </ul>
*/
CLOUD("cloud", 29, - 1, ParticleProperty.DIRECTIONAL),
CLOUD("cloud", 29, -1, ParticleProperty.DIRECTIONAL),
/**
* A particle effect which is displayed by redstone ore, powered redstone, redstone torches and redstone repeaters:
* <ul>
@@ -292,7 +292,7 @@ public enum ParticleEffect {
* <li>The speed value causes the particle to be colored red when set to 0
* </ul>
*/
REDSTONE("reddust", 30, - 1, ParticleProperty.COLORABLE),
REDSTONE("reddust", 30, -1, ParticleProperty.COLORABLE),
/**
* A particle effect which is displayed when snowballs hit a block:
* <ul>
@@ -300,7 +300,7 @@ public enum ParticleEffect {
* <li>The speed value has no influence on this particle effect
* </ul>
*/
SNOWBALL("snowballpoof", 31, - 1),
SNOWBALL("snowballpoof", 31, -1),
/**
* A particle effect which is currently unused:
* <ul>
@@ -308,7 +308,7 @@ public enum ParticleEffect {
* <li>The speed value influences the velocity at which the particle flies off
* </ul>
*/
SNOW_SHOVEL("snowshovel", 32, - 1, ParticleProperty.DIRECTIONAL),
SNOW_SHOVEL("snowshovel", 32, -1, ParticleProperty.DIRECTIONAL),
/**
* A particle effect which is displayed by slimes:
* <ul>
@@ -316,7 +316,7 @@ public enum ParticleEffect {
* <li>The speed value has no influence on this particle effect
* </ul>
*/
SLIME("slime", 33, - 1),
SLIME("slime", 33, -1),
/**
* A particle effect which is displayed when breeding and taming animals:
* <ul>
@@ -324,7 +324,7 @@ public enum ParticleEffect {
* <li>The speed value has no influence on this particle effect
* </ul>
*/
HEART("heart", 34, - 1),
HEART("heart", 34, -1),
/**
* A particle effect which is displayed by barriers:
* <ul>
@@ -339,7 +339,7 @@ public enum ParticleEffect {
* <li>It looks like a little piece with an item texture
* </ul>
*/
ITEM_CRACK("iconcrack", 36, - 1, ParticleProperty.DIRECTIONAL, ParticleProperty.REQUIRES_DATA),
ITEM_CRACK("iconcrack", 36, -1, ParticleProperty.DIRECTIONAL, ParticleProperty.REQUIRES_DATA),
/**
* A particle effect which is displayed when breaking blocks or sprinting:
* <ul>
@@ -347,7 +347,7 @@ public enum ParticleEffect {
* <li>The speed value has no influence on this particle effect
* </ul>
*/
BLOCK_CRACK("blockcrack", 37, - 1, ParticleProperty.REQUIRES_DATA),
BLOCK_CRACK("blockcrack", 37, -1, ParticleProperty.REQUIRES_DATA),
/**
* A particle effect which is displayed when falling:
* <ul>
@@ -524,7 +524,6 @@ public enum ParticleEffect {
/**
* Determine if this particle effect has a specific property
*
*
* @param property - property to check.
* @return Whether it has the property or not
*/
@@ -538,7 +537,7 @@ public enum ParticleEffect {
* @return Whether the particle effect is supported or not
*/
public boolean isSupported() {
if (requiredVersion == - 1) {
if (requiredVersion == -1) {
return true;
}
return ParticlePacket.getVersion() >= requiredVersion;
@@ -946,7 +945,7 @@ public enum ParticleEffect {
* @param material Material of the item/block
* @param data Data value of the item/block
*/
@SuppressWarnings ("deprecation")
@SuppressWarnings("deprecation")
public ParticleData(Material material, byte data) {
this.material = material;
this.data = data;
@@ -1177,7 +1176,7 @@ public enum ParticleEffect {
/**
* Represents the color for the {@link ParticleEffect#NOTE} effect
*
* <p>
* This class is part of the <b>ParticleEffect Library</b> and follows the same usage conditions
*
* @author DarkBlade12
@@ -1236,7 +1235,7 @@ public enum ParticleEffect {
/**
* Represents a runtime exception that is thrown either if the displayed particle effect requires data and has none or vice-versa or if the data type is incorrect
*
* <p>
* This class is part of the <b>ParticleEffect Library</b> and follows the same usage conditions
*
* @author DarkBlade12
@@ -1257,7 +1256,7 @@ public enum ParticleEffect {
/**
* Represents a runtime exception that is thrown either if the displayed particle effect is not colorable or if the particle color type is incorrect
*
* <p>
* This class is part of the <b>ParticleEffect Library</b> and follows the same usage conditions
*
* @author DarkBlade12
@@ -1278,7 +1277,7 @@ public enum ParticleEffect {
/**
* Represents a runtime exception that is thrown if the displayed particle effect requires a newer version
*
* <p>
* This class is part of the <b>ParticleEffect Library</b> and follows the same usage conditions
*
* @author DarkBlade12
@@ -1299,7 +1298,7 @@ public enum ParticleEffect {
/**
* Represents a particle effect packet with all attributes which is used for sending packets to the players
*
* <p>
* This class is part of the <b>ParticleEffect Library</b> and follows the same usage conditions
*
* @author DarkBlade12
@@ -1385,7 +1384,7 @@ public enum ParticleEffect {
/**
* Initializes {@link #packetConstructor}, {@link #getHandle}, {@link #playerConnection} and {@link #sendPacket} and sets {@link #initialized} to <code>true</code> if it succeeds
*
*
* <b>Note:</b> These fields only have to be initialized once, so it will return if {@link #initialized} is already set to <code>true</code>
*
* @throws VersionIncompatibleException if your bukkit version is not supported by this library
@@ -1532,7 +1531,7 @@ public enum ParticleEffect {
/**
* Represents a runtime exception that is thrown if a bukkit version is not compatible with this library
*
* <p>
* This class is part of the <b>ParticleEffect Library</b> and follows the same usage conditions
*
* @author DarkBlade12
@@ -1554,7 +1553,7 @@ public enum ParticleEffect {
/**
* Represents a runtime exception that is thrown if packet instantiation fails
*
* <p>
* This class is part of the <b>ParticleEffect Library</b> and follows the same usage conditions
*
* @author DarkBlade12
@@ -1576,7 +1575,7 @@ public enum ParticleEffect {
/**
* Represents a runtime exception that is thrown if packet sending fails
*
* <p>
* This class is part of the <b>ParticleEffect Library</b> and follows the same usage conditions
*
* @author DarkBlade12

View File

@@ -11,15 +11,15 @@ import java.util.Map;
/**
* <b>ReflectionUtils</b>
*
* <p>
* This class provides useful methods which makes dealing with reflection much easier, especially when working with Bukkit
*
* <p>
* You are welcome to use it, modify it and redistribute it under the following conditions:
* <ul>
* <li>Don't claim this class as your own
* <li>Don't remove this disclaimer
* </ul>
*
*
* <i>It would be nice if you provide credit to me if you use this class in a published project</i>
*
* @author DarkBlade12
@@ -346,7 +346,7 @@ public final class ReflectionUtils {
/**
* Represents an enumeration of dynamic packages of NMS and CraftBukkit
*
* <p>
* This class is part of the <b>ReflectionUtils</b> and follows the same usage conditions
*
* @author DarkBlade12
@@ -433,7 +433,7 @@ public final class ReflectionUtils {
/**
* Represents an enumeration of Java data types with corresponding classes
*
* <p>
* This class is part of the <b>ReflectionUtils</b> and follows the same usage conditions
*
* @author DarkBlade12

View File

@@ -1,111 +1,111 @@
package com.massivecraft.factions.util;
import com.massivecraft.factions.Conf;
import com.massivecraft.factions.FPlayer;
import com.massivecraft.factions.Faction;
import com.massivecraft.factions.iface.RelationParticipator;
import com.massivecraft.factions.struct.Relation;
import com.massivecraft.factions.zcore.util.TL;
import com.massivecraft.factions.zcore.util.TextUtil;
import org.bukkit.ChatColor;
public class RelationUtil {
public static String describeThatToMe(RelationParticipator that, RelationParticipator me, boolean ucfirst) {
String ret = "";
Faction thatFaction = getFaction(that);
if (thatFaction == null) {
return "ERROR"; // ERROR
}
Faction myFaction = getFaction(me);
// if (myFaction == null) return that.describeTo(null); // no relation, but can show basic name or tag
if (that instanceof Faction) {
if (me instanceof FPlayer && myFaction == thatFaction) {
ret = TL.GENERIC_YOURFACTION.toString();
} else {
ret = thatFaction.getTag();
}
} else if (that instanceof FPlayer) {
FPlayer fplayerthat = (FPlayer) that;
if (that == me) {
ret = TL.GENERIC_YOU.toString();
} else if (thatFaction == myFaction) {
ret = fplayerthat.getNameAndTitle();
} else {
ret = fplayerthat.getNameAndTag();
}
}
if (ucfirst) {
ret = TextUtil.upperCaseFirst(ret);
}
return "" + getColorOfThatToMe(that, me) + ret;
}
public static String describeThatToMe(RelationParticipator that, RelationParticipator me) {
return describeThatToMe(that, me, false);
}
public static Relation getRelationTo(RelationParticipator me, RelationParticipator that) {
return getRelationTo(that, me, false);
}
public static Relation getRelationTo(RelationParticipator me, RelationParticipator that, boolean ignorePeaceful) {
Faction fthat = getFaction(that);
Faction fme = getFaction(me);
if (fthat == null || fme == null) {
return Relation.NEUTRAL; // ERROR
}
if (!fthat.isNormal() || !fme.isNormal()) {
return Relation.NEUTRAL;
}
if (fthat.equals(fme)) {
return Relation.MEMBER;
}
if (!ignorePeaceful && (fme.isPeaceful() || fthat.isPeaceful())) {
return Relation.NEUTRAL;
}
if (fme.getRelationWish(fthat).value >= fthat.getRelationWish(fme).value) {
return fthat.getRelationWish(fme);
}
return fme.getRelationWish(fthat);
}
public static Faction getFaction(RelationParticipator rp) {
if (rp instanceof Faction) {
return (Faction) rp;
}
if (rp instanceof FPlayer) {
return ((FPlayer) rp).getFaction();
}
// ERROR
return null;
}
public static ChatColor getColorOfThatToMe(RelationParticipator that, RelationParticipator me) {
Faction thatFaction = getFaction(that);
if (thatFaction != null && thatFaction != getFaction(me)) {
if (thatFaction.isPeaceful())
return Conf.colorPeaceful;
else if (thatFaction.isSafeZone())
return Conf.colorPeaceful;
else if (thatFaction.isWarZone())
return Conf.colorWar;
}
return getRelationTo(that, me).getColor();
}
}
package com.massivecraft.factions.util;
import com.massivecraft.factions.Conf;
import com.massivecraft.factions.FPlayer;
import com.massivecraft.factions.Faction;
import com.massivecraft.factions.iface.RelationParticipator;
import com.massivecraft.factions.struct.Relation;
import com.massivecraft.factions.zcore.util.TL;
import com.massivecraft.factions.zcore.util.TextUtil;
import org.bukkit.ChatColor;
public class RelationUtil {
public static String describeThatToMe(RelationParticipator that, RelationParticipator me, boolean ucfirst) {
String ret = "";
Faction thatFaction = getFaction(that);
if (thatFaction == null) {
return "ERROR"; // ERROR
}
Faction myFaction = getFaction(me);
// if (myFaction == null) return that.describeTo(null); // no relation, but can show basic name or tag
if (that instanceof Faction) {
if (me instanceof FPlayer && myFaction == thatFaction) {
ret = TL.GENERIC_YOURFACTION.toString();
} else {
ret = thatFaction.getTag();
}
} else if (that instanceof FPlayer) {
FPlayer fplayerthat = (FPlayer) that;
if (that == me) {
ret = TL.GENERIC_YOU.toString();
} else if (thatFaction == myFaction) {
ret = fplayerthat.getNameAndTitle();
} else {
ret = fplayerthat.getNameAndTag();
}
}
if (ucfirst) {
ret = TextUtil.upperCaseFirst(ret);
}
return "" + getColorOfThatToMe(that, me) + ret;
}
public static String describeThatToMe(RelationParticipator that, RelationParticipator me) {
return describeThatToMe(that, me, false);
}
public static Relation getRelationTo(RelationParticipator me, RelationParticipator that) {
return getRelationTo(that, me, false);
}
public static Relation getRelationTo(RelationParticipator me, RelationParticipator that, boolean ignorePeaceful) {
Faction fthat = getFaction(that);
Faction fme = getFaction(me);
if (fthat == null || fme == null) {
return Relation.NEUTRAL; // ERROR
}
if (!fthat.isNormal() || !fme.isNormal()) {
return Relation.NEUTRAL;
}
if (fthat.equals(fme)) {
return Relation.MEMBER;
}
if (!ignorePeaceful && (fme.isPeaceful() || fthat.isPeaceful())) {
return Relation.NEUTRAL;
}
if (fme.getRelationWish(fthat).value >= fthat.getRelationWish(fme).value) {
return fthat.getRelationWish(fme);
}
return fme.getRelationWish(fthat);
}
public static Faction getFaction(RelationParticipator rp) {
if (rp instanceof Faction) {
return (Faction) rp;
}
if (rp instanceof FPlayer) {
return ((FPlayer) rp).getFaction();
}
// ERROR
return null;
}
public static ChatColor getColorOfThatToMe(RelationParticipator that, RelationParticipator me) {
Faction thatFaction = getFaction(that);
if (thatFaction != null && thatFaction != getFaction(me)) {
if (thatFaction.isPeaceful())
return Conf.colorPeaceful;
else if (thatFaction.isSafeZone())
return Conf.colorPeaceful;
else if (thatFaction.isWarZone())
return Conf.colorWar;
}
return getRelationTo(that, me).getColor();
}
}

View File

@@ -27,7 +27,7 @@ public abstract class SpiralTask implements Runnable {
// general task-related reference data
private transient World world = null;
private transient boolean readyToGo = false;
private transient int taskID = - 1;
private transient int taskID = -1;
private transient int limit = 0;
// values for the spiral pattern routine
@@ -35,10 +35,10 @@ public abstract class SpiralTask implements Runnable {
private transient int z = 0;
private transient boolean isZLeg = false;
private transient boolean isNeg = false;
private transient int length = - 1;
private transient int length = -1;
private transient int current = 0;
@SuppressWarnings ("LeakingThisInConstructor")
@SuppressWarnings("LeakingThisInConstructor")
public SpiralTask(FLocation fLocation, int radius) {
// limit is determined based on spiral leg length for given radius; see insideRadius()
this.limit = (radius - 1) * 2;
@@ -103,7 +103,7 @@ public abstract class SpiralTask implements Runnable {
}
public final void setTaskID(int ID) {
if (ID == - 1) {
if (ID == -1) {
this.stop();
}
taskID = ID;
@@ -169,9 +169,9 @@ public abstract class SpiralTask implements Runnable {
// move one chunk further in the appropriate direction
if (isZLeg) {
z += (isNeg) ? - 1 : 1;
z += (isNeg) ? -1 : 1;
} else {
x += (isNeg) ? - 1 : 1;
x += (isNeg) ? -1 : 1;
}
return true;
@@ -199,11 +199,11 @@ public abstract class SpiralTask implements Runnable {
readyToGo = false;
Bukkit.getServer().getScheduler().cancelTask(taskID);
taskID = - 1;
taskID = -1;
}
// is this task still valid/workable?
public final boolean valid() {
return taskID != - 1;
return taskID != -1;
}
}

View File

@@ -0,0 +1,114 @@
package com.massivecraft.factions.util;
import com.massivecraft.factions.FPlayer;
import com.massivecraft.factions.Faction;
import com.massivecraft.factions.SavageFactions;
import com.massivecraft.factions.struct.Relation;
import com.massivecraft.factions.zcore.util.TL;
import org.bukkit.Bukkit;
import java.util.ArrayList;
import java.util.Iterator;
public class UtilFly {
public static ArrayList<FPlayer> playersFlying;
static {
playersFlying = SavageFactions.playersFlying;
}
public UtilFly() {
}
public static void run() {
if (SavageFactions.plugin.getConfig().getBoolean("enable-faction-flight")) {
playersFlying.clear();
Bukkit.getScheduler().scheduleSyncRepeatingTask(SavageFactions.plugin, new Runnable() {
public void run() {
Iterator var2 = UtilFly.playersFlying.iterator();
while (var2.hasNext()) {
FPlayer fp = (FPlayer) var2.next();
if (fp != null) {
fp.checkIfNearbyEnemies();
}
}
}
}, 0L, (long) SavageFactions.plugin.getConfig().getInt("fly-task-interval", 10));
}
}
public static void setFly(FPlayer fp, boolean fly, boolean silent, boolean damage) {
if (SavageFactions.plugin.getConfig().getBoolean("enable-faction-flight")) {
fp.getPlayer().setAllowFlight(fly);
fp.getPlayer().setFlying(fly);
fp.setFlying(fly);
if (fly) {
playersFlying.add(fp);
} else {
playersFlying.remove(fp);
}
if (!silent) {
if (!damage) {
fp.msg(TL.COMMAND_FLY_CHANGE, fly ? "enabled" : "disabled");
} else {
fp.msg(TL.COMMAND_FLY_DAMAGE);
}
}
setFallDamage(fp, fly, damage);
}
}
public static void checkFly(FPlayer me, Faction factionTo) {
if (SavageFactions.plugin.getConfig().getBoolean("enable-faction-flight")) {
if (!me.isAdminBypassing() || !me.isFlying()) {
Relation relationTo;
if (!me.isFlying()) {
if (me.isAdminBypassing()) {
setFly(me, true, false, false);
return;
}
if (factionTo == me.getFaction() && me.getPlayer().hasPermission("factions.fly")) {
setFly(me, true, false, false);
} else {
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()) {
setFly(me, true, false, false);
}
}
} else {
relationTo = factionTo.getRelationTo(me);
if (factionTo.equals(me.getFaction()) && !me.getPlayer().hasPermission("factions.fly") || 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()) {
setFly(me, false, false, false);
}
}
}
}
}
public static void setFallDamage(final FPlayer fp, boolean fly, boolean damage) {
if (!fly) {
if (!damage) {
fp.sendMessage(TL.COMMAND_FLY_COOLDOWN.toString().replace("{amount}", String.valueOf(SavageFactions.plugin.getConfig().getInt("fly-falldamage-cooldown", 3))));
}
int cooldown = SavageFactions.plugin.getConfig().getInt("fly-falldamage-cooldown", 3);
if (cooldown > 0) {
fp.setTakeFallDamage(false);
Bukkit.getScheduler().runTaskLater(SavageFactions.plugin, new Runnable() {
public void run() {
fp.setTakeFallDamage(true);
}
}, 20L * (long) cooldown);
}
}
}
}

View File

@@ -1,72 +1,72 @@
package com.massivecraft.factions.util;
import org.bukkit.Location;
import org.bukkit.Material;
import org.bukkit.block.Block;
import org.bukkit.entity.Player;
import java.util.*;
public class VisualizeUtil {
protected static Map<UUID, Set<Location>> playerLocations = new HashMap<>();
public static Set<Location> getPlayerLocations(Player player) {
return getPlayerLocations(player.getUniqueId());
}
public static Set<Location> getPlayerLocations(UUID uuid) {
Set<Location> ret = playerLocations.get(uuid);
if (ret == null) {
ret = new HashSet<>();
playerLocations.put(uuid, ret);
}
return ret;
}
@SuppressWarnings ("deprecation")
public static void addLocation(Player player, Location location, Material type, byte data) {
getPlayerLocations(player).add(location);
player.sendBlockChange(location, type, data);
}
@SuppressWarnings ("deprecation")
public static void addLocation(Player player, Location location, Material material) {
getPlayerLocations(player).add(location);
player.sendBlockChange(location, material, (byte) 0);
}
@SuppressWarnings ("deprecation")
public static void addLocations(Player player, Collection<Location> locations, Material material) {
Set<Location> ploc = getPlayerLocations(player);
for (Location location : locations) {
ploc.add(location);
player.sendBlockChange(location, material, (byte) 0);
}
}
@SuppressWarnings ("deprecation")
public static void addBlocks(Player player, Collection<Block> blocks, Material material) {
Set<Location> ploc = getPlayerLocations(player);
for (Block block : blocks) {
Location location = block.getLocation();
ploc.add(location);
player.sendBlockChange(location, material, (byte) 0);
}
}
@SuppressWarnings ("deprecation")
public static void clear(Player player) {
Set<Location> locations = getPlayerLocations(player);
if (locations == null) {
return;
}
for (Location location : locations) {
Block block = location.getWorld().getBlockAt(location);
player.sendBlockChange(location, block.getType(), block.getData());
}
locations.clear();
}
}
package com.massivecraft.factions.util;
import org.bukkit.Location;
import org.bukkit.Material;
import org.bukkit.block.Block;
import org.bukkit.entity.Player;
import java.util.*;
public class VisualizeUtil {
protected static Map<UUID, Set<Location>> playerLocations = new HashMap<>();
public static Set<Location> getPlayerLocations(Player player) {
return getPlayerLocations(player.getUniqueId());
}
public static Set<Location> getPlayerLocations(UUID uuid) {
Set<Location> ret = playerLocations.get(uuid);
if (ret == null) {
ret = new HashSet<>();
playerLocations.put(uuid, ret);
}
return ret;
}
@SuppressWarnings("deprecation")
public static void addLocation(Player player, Location location, Material type, byte data) {
getPlayerLocations(player).add(location);
player.sendBlockChange(location, type, data);
}
@SuppressWarnings("deprecation")
public static void addLocation(Player player, Location location, Material material) {
getPlayerLocations(player).add(location);
player.sendBlockChange(location, material, (byte) 0);
}
@SuppressWarnings("deprecation")
public static void addLocations(Player player, Collection<Location> locations, Material material) {
Set<Location> ploc = getPlayerLocations(player);
for (Location location : locations) {
ploc.add(location);
player.sendBlockChange(location, material, (byte) 0);
}
}
@SuppressWarnings("deprecation")
public static void addBlocks(Player player, Collection<Block> blocks, Material material) {
Set<Location> ploc = getPlayerLocations(player);
for (Block block : blocks) {
Location location = block.getLocation();
ploc.add(location);
player.sendBlockChange(location, material, (byte) 0);
}
}
@SuppressWarnings("deprecation")
public static void clear(Player player) {
Set<Location> locations = getPlayerLocations(player);
if (locations == null) {
return;
}
for (Location location : locations) {
Block block = location.getWorld().getBlockAt(location);
player.sendBlockChange(location, block.getType(), block.getData());
}
locations.clear();
}
}

View File

@@ -12,7 +12,7 @@ public class WarmUpUtil {
* @param action The action, inserted into the notification message.
* @param runnable The task to run after the delay. If the delay is 0, the task is instantly ran.
* @param delay The time used, in seconds, for the delay.
*
* <p>
* note: for translations: %s = action, %d = delay
*/
public static void process(final FPlayer player, Warmup warmup, TL translationKey, String action, final Runnable runnable, long delay) {

View File

@@ -140,9 +140,9 @@ public class WarpGUI implements InventoryHolder, FactionGUI {
}
if (Conf.bankEnabled && Conf.bankFactionPaysCosts && fme.hasFaction()) {
return Econ.modifyMoney(fme.getFaction(), - cost, TL.COMMAND_FWARP_TOWARP.toString(), TL.COMMAND_FWARP_FORWARPING.toString());
return Econ.modifyMoney(fme.getFaction(), -cost, TL.COMMAND_FWARP_TOWARP.toString(), TL.COMMAND_FWARP_FORWARPING.toString());
} else {
return Econ.modifyMoney(fme, - cost, TL.COMMAND_FWARP_TOWARP.toString(), TL.COMMAND_FWARP_FORWARPING.toString());
return Econ.modifyMoney(fme, -cost, TL.COMMAND_FWARP_TOWARP.toString(), TL.COMMAND_FWARP_FORWARPING.toString());
}
}