Reformatted Code
This commit is contained in:
parent
cd09e77b42
commit
b1b9bd1b73
@ -64,7 +64,7 @@ public class FLocation implements Serializable {
|
||||
//----------------------------------------------//
|
||||
|
||||
public static FLocation fromString(String string) {
|
||||
int index = string.indexOf(",", 0);
|
||||
int index = string.indexOf(",");
|
||||
int start = 1;
|
||||
String worldName = string.substring(start, index);
|
||||
start = index + 1;
|
||||
@ -99,10 +99,6 @@ public class FLocation implements Serializable {
|
||||
return regionVal << 5; // "<< 5" == "* 32"
|
||||
}
|
||||
|
||||
public Chunk getChunk(){
|
||||
return Bukkit.getWorld(worldName).getChunkAt(x, z);
|
||||
}
|
||||
|
||||
public static HashSet<FLocation> getArea(FLocation from, FLocation to) {
|
||||
HashSet<FLocation> ret = new HashSet<>();
|
||||
|
||||
@ -115,6 +111,10 @@ public class FLocation implements Serializable {
|
||||
return ret;
|
||||
}
|
||||
|
||||
public Chunk getChunk() {
|
||||
return Bukkit.getWorld(worldName).getChunkAt(x, z);
|
||||
}
|
||||
|
||||
public String getWorldName() {
|
||||
return worldName;
|
||||
}
|
||||
|
@ -60,7 +60,12 @@ public class SavageFactions extends MPlugin {
|
||||
public boolean mc113 = false;
|
||||
public boolean useNonPacketParticles = false;
|
||||
public boolean factionsFlight = false;
|
||||
|
||||
//multiversion material fields
|
||||
public Material SUGAR_CANE_BLOCK, BANNER, CROPS, REDSTONE_LAMP_ON,
|
||||
STAINED_GLASS, STATIONARY_WATER, STAINED_CLAY, WOOD_BUTTON,
|
||||
SOIL, MOB_SPANWER, THIN_GLASS, IRON_FENCE, NETHER_FENCE, FENCE,
|
||||
WOODEN_DOOR, TRAP_DOOR, FENCE_GATE, BURNING_FURNACE, DIODE_BLOCK_OFF,
|
||||
DIODE_BLOCK_ON, ENCHANTMENT_TABLE, FIREBALL;
|
||||
// Persistence related
|
||||
private boolean locked = false;
|
||||
private Integer AutoLeaveTask = null;
|
||||
@ -68,7 +73,6 @@ public class SavageFactions extends MPlugin {
|
||||
private ClipPlaceholderAPIManager clipPlaceholderAPIManager;
|
||||
private boolean mvdwPlaceholderAPIManager = false;
|
||||
|
||||
|
||||
public SavageFactions() {
|
||||
plugin = this;
|
||||
}
|
||||
@ -189,8 +193,6 @@ public class SavageFactions extends MPlugin {
|
||||
new MassiveStats(this);
|
||||
|
||||
|
||||
|
||||
|
||||
if (version > 8) {
|
||||
useNonPacketParticles = true;
|
||||
SavageFactions.plugin.log("Minecraft Version 1.9 or higher found, using non packet based particle API");
|
||||
@ -201,7 +203,6 @@ public class SavageFactions extends MPlugin {
|
||||
}
|
||||
|
||||
|
||||
|
||||
// Register Event Handlers
|
||||
getServer().getPluginManager().registerEvents(new FactionsPlayerListener(this), this);
|
||||
getServer().getPluginManager().registerEvents(new FactionsChatListener(this), this);
|
||||
@ -229,14 +230,6 @@ public class SavageFactions extends MPlugin {
|
||||
this.loadSuccessful = true;
|
||||
}
|
||||
|
||||
|
||||
//multiversion material fields
|
||||
public Material SUGAR_CANE_BLOCK, BANNER, CROPS, REDSTONE_LAMP_ON,
|
||||
STAINED_GLASS, STATIONARY_WATER, STAINED_CLAY, WOOD_BUTTON,
|
||||
SOIL, MOB_SPANWER, THIN_GLASS, IRON_FENCE, NETHER_FENCE, FENCE,
|
||||
WOODEN_DOOR, TRAP_DOOR, FENCE_GATE, BURNING_FURNACE, DIODE_BLOCK_OFF,
|
||||
DIODE_BLOCK_ON, ENCHANTMENT_TABLE, FIREBALL;
|
||||
|
||||
private void setupMultiversionMaterials() {
|
||||
if (mc113) {
|
||||
BANNER = Material.valueOf("LEGACY_BANNER");
|
||||
|
@ -2,7 +2,6 @@ package com.massivecraft.factions.cmd;
|
||||
|
||||
import com.massivecraft.factions.struct.Permission;
|
||||
import com.massivecraft.factions.zcore.util.TL;
|
||||
import org.bukkit.Material;
|
||||
|
||||
public class CmdSetBanner extends FCommand {
|
||||
|
||||
|
@ -44,6 +44,7 @@ public class EngineDynmap {
|
||||
public DynmapAPI dynmapApi;
|
||||
public MarkerAPI markerApi;
|
||||
public MarkerSet markerset;
|
||||
|
||||
private EngineDynmap() {
|
||||
}
|
||||
|
||||
|
@ -32,54 +32,14 @@ import java.util.List;
|
||||
|
||||
public class FactionsBlockListener implements Listener {
|
||||
|
||||
public SavageFactions savageFactions;
|
||||
public static HashMap<String, Location> bannerLocations = new HashMap<>();
|
||||
public SavageFactions savageFactions;
|
||||
private HashMap<String, Boolean> bannerCooldownMap = new HashMap<>();
|
||||
|
||||
public FactionsBlockListener(SavageFactions savageFactions) {
|
||||
this.savageFactions = savageFactions;
|
||||
}
|
||||
|
||||
@EventHandler(priority = EventPriority.NORMAL, ignoreCancelled = true)
|
||||
public void onBlockPlace(BlockPlaceEvent event) {
|
||||
if (!event.canBuild()) {
|
||||
return;
|
||||
}
|
||||
|
||||
// special case for flint&steel, which should only be prevented by DenyUsage list
|
||||
if (event.getBlockPlaced().getType() == Material.FIRE) {
|
||||
return;
|
||||
}
|
||||
|
||||
if (!playerCanBuildDestroyBlock(event.getPlayer(), event.getBlock().getLocation(), "build", false)) {
|
||||
event.setCancelled(true);
|
||||
}
|
||||
}
|
||||
|
||||
@EventHandler(priority = EventPriority.NORMAL, ignoreCancelled = true)
|
||||
public void onBlockFromTo(BlockFromToEvent event) {
|
||||
if (!Conf.handleExploitLiquidFlow) {
|
||||
return;
|
||||
}
|
||||
if (event.getBlock().isLiquid()) {
|
||||
if (event.getToBlock().isEmpty()) {
|
||||
Faction from = Board.getInstance().getFactionAt(new FLocation(event.getBlock()));
|
||||
Faction to = Board.getInstance().getFactionAt(new FLocation(event.getToBlock()));
|
||||
if (from == to) {
|
||||
// not concerned with inter-faction events
|
||||
return;
|
||||
}
|
||||
// from faction != to faction
|
||||
if (to.isNormal()) {
|
||||
if (from.isNormal() && from.getRelationTo(to).isAlly()) {
|
||||
return;
|
||||
}
|
||||
event.setCancelled(true);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public static boolean playerCanBuildDestroyBlock(Player player, Location location, String action, boolean justCheck) {
|
||||
String name = player.getName();
|
||||
if (Conf.playersWhoBypassAllProtection.contains(name)) {
|
||||
@ -201,6 +161,46 @@ public class FactionsBlockListener implements Listener {
|
||||
return true;
|
||||
}
|
||||
|
||||
@EventHandler (priority = EventPriority.NORMAL, ignoreCancelled = true)
|
||||
public void onBlockPlace(BlockPlaceEvent event) {
|
||||
if (! event.canBuild()) {
|
||||
return;
|
||||
}
|
||||
|
||||
// special case for flint&steel, which should only be prevented by DenyUsage list
|
||||
if (event.getBlockPlaced().getType() == Material.FIRE) {
|
||||
return;
|
||||
}
|
||||
|
||||
if (! playerCanBuildDestroyBlock(event.getPlayer(), event.getBlock().getLocation(), "build", false)) {
|
||||
event.setCancelled(true);
|
||||
}
|
||||
}
|
||||
|
||||
@EventHandler (priority = EventPriority.NORMAL, ignoreCancelled = true)
|
||||
public void onBlockFromTo(BlockFromToEvent event) {
|
||||
if (! Conf.handleExploitLiquidFlow) {
|
||||
return;
|
||||
}
|
||||
if (event.getBlock().isLiquid()) {
|
||||
if (event.getToBlock().isEmpty()) {
|
||||
Faction from = Board.getInstance().getFactionAt(new FLocation(event.getBlock()));
|
||||
Faction to = Board.getInstance().getFactionAt(new FLocation(event.getToBlock()));
|
||||
if (from == to) {
|
||||
// not concerned with inter-faction events
|
||||
return;
|
||||
}
|
||||
// from faction != to faction
|
||||
if (to.isNormal()) {
|
||||
if (from.isNormal() && from.getRelationTo(to).isAlly()) {
|
||||
return;
|
||||
}
|
||||
event.setCancelled(true);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@EventHandler (priority = EventPriority.NORMAL, ignoreCancelled = true)
|
||||
public void onBlockDamage(BlockDamageEvent event) {
|
||||
if (event.getInstaBreak() && ! playerCanBuildDestroyBlock(event.getPlayer(), event.getBlock().getLocation(), "destroy", false)) {
|
||||
|
@ -766,7 +766,6 @@ public class FactionsPlayerListener implements Listener {
|
||||
}
|
||||
|
||||
|
||||
|
||||
@EventHandler (priority = EventPriority.NORMAL, ignoreCancelled = true)
|
||||
public void onPlayerInteract(PlayerInteractEvent event) {
|
||||
/// Prevents the use of montster eggs in oned land.
|
||||
|
@ -17,7 +17,6 @@ public class InventoryTypeAdapter implements JsonSerializer<Inventory>, JsonDese
|
||||
}
|
||||
|
||||
|
||||
|
||||
@Override
|
||||
public Inventory deserialize(JsonElement jsonElement, Type type, JsonDeserializationContext jsonDeserializationContext) {
|
||||
JsonObject object = jsonElement.getAsJsonObject();
|
||||
@ -25,5 +24,4 @@ public class InventoryTypeAdapter implements JsonSerializer<Inventory>, JsonDese
|
||||
}
|
||||
|
||||
|
||||
|
||||
}
|
||||
|
@ -1,10 +1,10 @@
|
||||
package com.massivecraft.factions.util;
|
||||
|
||||
import java.util.HashMap;
|
||||
|
||||
import org.bukkit.Material;
|
||||
import org.bukkit.inventory.ItemStack;
|
||||
|
||||
import java.util.HashMap;
|
||||
|
||||
public enum MultiversionMaterials {
|
||||
|
||||
ACACIA_BOAT("BOAT_ACACIA", 0),
|
||||
@ -858,6 +858,8 @@ public enum MultiversionMaterials {
|
||||
ZOMBIE_VILLAGER_SPAWN_EGG("MONSTER_EGG", 0),
|
||||
ZOMBIE_WALL_HEAD("SKULL", 0),
|
||||
;
|
||||
static int newV = - 1;
|
||||
private static HashMap<String, MultiversionMaterials> cachedSearch = new HashMap<>();
|
||||
String m;
|
||||
int data;
|
||||
|
||||
@ -866,14 +868,6 @@ public enum MultiversionMaterials {
|
||||
this.data = data;
|
||||
}
|
||||
|
||||
public ItemStack parseItem(){
|
||||
Material mat = parseMaterial();
|
||||
if(isNewVersion()){
|
||||
return new ItemStack(mat);
|
||||
}
|
||||
return new ItemStack(mat,1,(byte) data);
|
||||
}
|
||||
static int newV = -1;
|
||||
public static boolean isNewVersion() {
|
||||
if (newV == 0) return false;
|
||||
if (newV == 1) return true;
|
||||
@ -886,7 +880,6 @@ public enum MultiversionMaterials {
|
||||
return false;
|
||||
}
|
||||
|
||||
private static HashMap<String, MultiversionMaterials> cachedSearch = new HashMap<>();
|
||||
public static MultiversionMaterials requestXMaterial(String name, byte data) {
|
||||
if (cachedSearch.containsKey(name.toUpperCase() + "," + data)) {
|
||||
return cachedSearch.get(name.toUpperCase() + "," + data);
|
||||
@ -900,36 +893,6 @@ public enum MultiversionMaterials {
|
||||
return null;
|
||||
}
|
||||
|
||||
public boolean isSameMaterial(ItemStack comp){
|
||||
if(isNewVersion()){
|
||||
return comp.getType() == this.parseMaterial();
|
||||
}
|
||||
if(comp.getType() == this.parseMaterial() &&
|
||||
(int) comp.getData().getData() == (int) this.data){
|
||||
return true;
|
||||
}
|
||||
MultiversionMaterials xmat = fromMaterial(comp.getType());
|
||||
if(isDamageable(xmat)){
|
||||
if(this.parseMaterial() == comp.getType()){
|
||||
return true;
|
||||
}
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
public MultiversionMaterials fromMaterial(Material mat){
|
||||
try{
|
||||
return MultiversionMaterials.valueOf(mat.toString());
|
||||
}catch(IllegalArgumentException e){
|
||||
for(MultiversionMaterials xmat:MultiversionMaterials.values()){
|
||||
if(xmat.m.equals(mat.toString())){
|
||||
return xmat;
|
||||
}
|
||||
}
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
public static MultiversionMaterials fromString(String key) {
|
||||
MultiversionMaterials xmat = null;
|
||||
try {
|
||||
@ -947,6 +910,42 @@ public enum MultiversionMaterials {
|
||||
|
||||
}
|
||||
|
||||
public ItemStack parseItem() {
|
||||
Material mat = parseMaterial();
|
||||
if (isNewVersion()) {
|
||||
return new ItemStack(mat);
|
||||
}
|
||||
return new ItemStack(mat, 1, (byte) data);
|
||||
}
|
||||
|
||||
public boolean isSameMaterial(ItemStack comp) {
|
||||
if (isNewVersion()) {
|
||||
return comp.getType() == this.parseMaterial();
|
||||
}
|
||||
if (comp.getType() == this.parseMaterial() &&
|
||||
(int) comp.getData().getData() == this.data) {
|
||||
return true;
|
||||
}
|
||||
MultiversionMaterials xmat = fromMaterial(comp.getType());
|
||||
if (isDamageable(xmat)) {
|
||||
return this.parseMaterial() == comp.getType();
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
public MultiversionMaterials fromMaterial(Material mat) {
|
||||
try {
|
||||
return MultiversionMaterials.valueOf(mat.toString());
|
||||
} catch (IllegalArgumentException e) {
|
||||
for (MultiversionMaterials xmat : MultiversionMaterials.values()) {
|
||||
if (xmat.m.equals(mat.toString())) {
|
||||
return xmat;
|
||||
}
|
||||
}
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
public boolean isDamageable(MultiversionMaterials type) {
|
||||
String[] split = type.toString().split("_");
|
||||
int length = split.length;
|
||||
|
@ -37,7 +37,6 @@ public class VisualizeUtil {
|
||||
}
|
||||
|
||||
|
||||
|
||||
@SuppressWarnings ("deprecation")
|
||||
public static void addLocations(Player player, Collection<Location> locations, Material material) {
|
||||
Set<Location> ploc = getPlayerLocations(player);
|
||||
|
@ -48,6 +48,7 @@ public abstract class MCommand<T extends MPlugin> {
|
||||
// This field may be left blank and will in such case be loaded from the permissions node instead.
|
||||
// Thus make sure the permissions node description is an action description like "eat hamburgers" or "do admin stuff".
|
||||
private String helpShort;
|
||||
|
||||
public MCommand(T p) {
|
||||
this.p = p;
|
||||
|
||||
|
@ -159,7 +159,8 @@ public class NBTCompound {
|
||||
}
|
||||
|
||||
public NBTType getType(String name) {
|
||||
if (MinecraftVersion.getVersion() == MinecraftVersion.MC1_7_R4) return NBTType.NBTTagEnd;
|
||||
if (MinecraftVersion.getVersion() == MinecraftVersion.MC1_7_R4)
|
||||
return NBTType.NBTTagEnd;
|
||||
return NBTType.valueOf(NBTReflectionUtil.getType(this, name));
|
||||
}
|
||||
|
||||
|
@ -635,7 +635,7 @@ public class NBTReflectionUtil {
|
||||
Method method;
|
||||
try {
|
||||
method = workingtag.getClass().getMethod("setFloat", String.class, float.class);
|
||||
method.invoke(workingtag, key, (float) f);
|
||||
method.invoke(workingtag, key, f);
|
||||
comp.setCompound(rootnbttag);
|
||||
} catch (Exception ex) {
|
||||
ex.printStackTrace();
|
||||
@ -673,7 +673,7 @@ public class NBTReflectionUtil {
|
||||
Method method;
|
||||
try {
|
||||
method = workingtag.getClass().getMethod("setLong", String.class, long.class);
|
||||
method.invoke(workingtag, key, (long) f);
|
||||
method.invoke(workingtag, key, f);
|
||||
comp.setCompound(rootnbttag);
|
||||
} catch (Exception ex) {
|
||||
ex.printStackTrace();
|
||||
@ -711,7 +711,7 @@ public class NBTReflectionUtil {
|
||||
Method method;
|
||||
try {
|
||||
method = workingtag.getClass().getMethod("setShort", String.class, short.class);
|
||||
method.invoke(workingtag, key, (short) f);
|
||||
method.invoke(workingtag, key, f);
|
||||
comp.setCompound(rootnbttag);
|
||||
} catch (Exception ex) {
|
||||
ex.printStackTrace();
|
||||
@ -749,7 +749,7 @@ public class NBTReflectionUtil {
|
||||
Method method;
|
||||
try {
|
||||
method = workingtag.getClass().getMethod("setByte", String.class, byte.class);
|
||||
method.invoke(workingtag, key, (byte) f);
|
||||
method.invoke(workingtag, key, f);
|
||||
comp.setCompound(rootnbttag);
|
||||
} catch (Exception ex) {
|
||||
ex.printStackTrace();
|
||||
|
@ -85,13 +85,6 @@ public abstract class MemoryFPlayer implements FPlayer {
|
||||
|
||||
public MemoryFPlayer() {
|
||||
}
|
||||
public boolean isStealthEnabled() {
|
||||
return this.isStealthEnabled;
|
||||
}
|
||||
|
||||
public void setStealth(boolean stealth) {
|
||||
this.isStealthEnabled = stealth;
|
||||
}
|
||||
|
||||
public MemoryFPlayer(String id) {
|
||||
this.id = id;
|
||||
@ -138,6 +131,14 @@ public abstract class MemoryFPlayer implements FPlayer {
|
||||
this.mapHeight = Conf.mapHeight;
|
||||
}
|
||||
|
||||
public boolean isStealthEnabled() {
|
||||
return this.isStealthEnabled;
|
||||
}
|
||||
|
||||
public void setStealth(boolean stealth) {
|
||||
this.isStealthEnabled = stealth;
|
||||
}
|
||||
|
||||
public void login() {
|
||||
this.kills = getPlayer().getStatistic(Statistic.PLAYER_KILLS);
|
||||
this.deaths = getPlayer().getStatistic(Statistic.DEATHS);
|
||||
@ -1040,12 +1041,18 @@ public abstract class MemoryFPlayer implements FPlayer {
|
||||
Player me = this.getPlayer();
|
||||
int radius = Conf.stealthFlyCheckRadius;
|
||||
for (Entity e : me.getNearbyEntities(radius, 255, radius)) {
|
||||
if (e == null) { continue; }
|
||||
if (e == null) {
|
||||
continue;
|
||||
}
|
||||
if (e instanceof Player) {
|
||||
Player eplayer = (((Player) e).getPlayer());
|
||||
if (eplayer == null) { continue; }
|
||||
if (eplayer == null) {
|
||||
continue;
|
||||
}
|
||||
FPlayer efplayer = FPlayers.getInstance().getByPlayer(eplayer);
|
||||
if (efplayer == null) { continue; }
|
||||
if (efplayer == null) {
|
||||
continue;
|
||||
}
|
||||
if (efplayer != null && this.getRelationTo(efplayer).equals(Relation.ENEMY) && ! efplayer.isStealthEnabled()) {
|
||||
setFlying(false);
|
||||
msg(TL.COMMAND_FLY_ENEMY_NEAR);
|
||||
|
@ -164,6 +164,7 @@ public abstract class MemoryFaction implements Faction, EconomyParticipator {
|
||||
public boolean isWarpPassword(String warp, String password) {
|
||||
return hasWarpPassword(warp) && warpPasswords.get(warp.toLowerCase()).equals(password);
|
||||
}
|
||||
|
||||
public String getPaypal() {
|
||||
return this.paypal;
|
||||
}
|
||||
|
@ -107,8 +107,6 @@ public enum TL {
|
||||
COMMAND_UPGRADES_DESCRIPTION("&cOpen the Upgrades Menu"),
|
||||
|
||||
|
||||
|
||||
|
||||
COMMAND_ADMIN_NOTMEMBER("&c&l[!] &7%1$s &cis not a member in your faction."),
|
||||
COMMAND_ADMIN_NOTADMIN("&c&l[!] &cYou are not the faction admin."),
|
||||
COMMAND_ADMIN_TARGETSELF("'&c&l[!] &cThe target player musn''t be yourself."),
|
||||
|
Loading…
Reference in New Issue
Block a user