ItemFrame Fix, Claiming with No Power Double Check, Scoreboard Duplicate Double Check modified BlockListener

This commit is contained in:
Driftay 2020-04-06 10:32:16 -04:00
parent 8d1b26e561
commit 0c5cc3a978
28 changed files with 151 additions and 260 deletions

View File

@ -98,10 +98,6 @@ public class FactionsPlugin extends MPlugin {
private List<ReserveObject> reserveObjects; private List<ReserveObject> reserveObjects;
private FileManager fileManager; private FileManager fileManager;
public FileManager getFileManager() {
return fileManager;
}
public FactionsPlugin() { public FactionsPlugin() {
instance = this; instance = this;
} }
@ -110,6 +106,10 @@ public class FactionsPlugin extends MPlugin {
return instance; return instance;
} }
public FileManager getFileManager() {
return fileManager;
}
public boolean getLocked() { public boolean getLocked() {
return this.locked; return this.locked;
} }

View File

@ -4,9 +4,9 @@ import com.massivecraft.factions.*;
import com.massivecraft.factions.event.FactionDisbandEvent.PlayerDisbandReason; import com.massivecraft.factions.event.FactionDisbandEvent.PlayerDisbandReason;
import com.massivecraft.factions.struct.Permission; import com.massivecraft.factions.struct.Permission;
import com.massivecraft.factions.struct.Role; import com.massivecraft.factions.struct.Role;
import com.massivecraft.factions.zcore.frame.fdisband.FDisbandFrame;
import com.massivecraft.factions.zcore.fperms.Access; import com.massivecraft.factions.zcore.fperms.Access;
import com.massivecraft.factions.zcore.fperms.PermissableAction; import com.massivecraft.factions.zcore.fperms.PermissableAction;
import com.massivecraft.factions.zcore.frame.fdisband.FDisbandFrame;
import com.massivecraft.factions.zcore.util.TL; import com.massivecraft.factions.zcore.util.TL;
import org.bukkit.Bukkit; import org.bukkit.Bukkit;
import org.bukkit.command.ConsoleCommandSender; import org.bukkit.command.ConsoleCommandSender;

View File

@ -4,8 +4,8 @@ import com.google.common.collect.Lists;
import com.massivecraft.factions.Conf; import com.massivecraft.factions.Conf;
import com.massivecraft.factions.Faction; import com.massivecraft.factions.Faction;
import com.massivecraft.factions.FactionsPlugin; import com.massivecraft.factions.FactionsPlugin;
import com.massivecraft.factions.zcore.frame.FactionGUI;
import com.massivecraft.factions.util.XMaterial; import com.massivecraft.factions.util.XMaterial;
import com.massivecraft.factions.zcore.frame.FactionGUI;
import com.massivecraft.factions.zcore.util.TL; import com.massivecraft.factions.zcore.util.TL;
import org.bukkit.DyeColor; import org.bukkit.DyeColor;
import org.bukkit.event.inventory.ClickType; import org.bukkit.event.inventory.ClickType;

View File

@ -3,8 +3,8 @@ package com.massivecraft.factions.cmd.check;
import com.massivecraft.factions.FPlayer; import com.massivecraft.factions.FPlayer;
import com.massivecraft.factions.Faction; import com.massivecraft.factions.Faction;
import com.massivecraft.factions.FactionsPlugin; import com.massivecraft.factions.FactionsPlugin;
import com.massivecraft.factions.zcore.frame.FactionGUI;
import com.massivecraft.factions.util.XMaterial; import com.massivecraft.factions.util.XMaterial;
import com.massivecraft.factions.zcore.frame.FactionGUI;
import com.massivecraft.factions.zcore.util.TL; import com.massivecraft.factions.zcore.util.TL;
import org.bukkit.ChatColor; import org.bukkit.ChatColor;
import org.bukkit.event.inventory.ClickType; import org.bukkit.event.inventory.ClickType;

View File

@ -83,7 +83,6 @@ public class CmdClaim extends FCommand {
this.stop(); this.stop();
return false; return false;
} }
return true; return true;
} }
}; };

View File

@ -20,7 +20,6 @@ import org.bukkit.inventory.ItemStack;
import org.bukkit.inventory.PlayerInventory; import org.bukkit.inventory.PlayerInventory;
import java.util.ArrayList; import java.util.ArrayList;
import java.util.HashMap;
import java.util.List; import java.util.List;
public class CmdTntFill extends FCommand { public class CmdTntFill extends FCommand {

View File

@ -2,10 +2,10 @@ package com.massivecraft.factions.cmd.wild;
import com.massivecraft.factions.FPlayer; import com.massivecraft.factions.FPlayer;
import com.massivecraft.factions.FactionsPlugin; import com.massivecraft.factions.FactionsPlugin;
import com.massivecraft.factions.util.XMaterial;
import com.massivecraft.factions.util.wait.WaitExecutor; import com.massivecraft.factions.util.wait.WaitExecutor;
import com.massivecraft.factions.util.wait.WaitTask; import com.massivecraft.factions.util.wait.WaitTask;
import com.massivecraft.factions.zcore.frame.FactionGUI; import com.massivecraft.factions.zcore.frame.FactionGUI;
import com.massivecraft.factions.util.XMaterial;
import com.massivecraft.factions.zcore.util.TL; import com.massivecraft.factions.zcore.util.TL;
import org.bukkit.Bukkit; import org.bukkit.Bukkit;
import org.bukkit.entity.Player; import org.bukkit.entity.Player;

View File

@ -8,7 +8,6 @@ import com.sk89q.worldguard.domains.Association;
import com.sk89q.worldguard.protection.ApplicableRegionSet; import com.sk89q.worldguard.protection.ApplicableRegionSet;
import com.sk89q.worldguard.protection.association.Associables; import com.sk89q.worldguard.protection.association.Associables;
import com.sk89q.worldguard.protection.association.RegionAssociable; import com.sk89q.worldguard.protection.association.RegionAssociable;
import com.sk89q.worldguard.protection.flags.DefaultFlag;
import com.sk89q.worldguard.protection.flags.StateFlag; 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;
@ -22,7 +21,9 @@ import org.bukkit.plugin.Plugin;
import java.lang.reflect.Constructor; import java.lang.reflect.Constructor;
import java.lang.reflect.Method; import java.lang.reflect.Method;
import java.util.*; import java.util.ArrayList;
import java.util.Collection;
import java.util.List;
/* /*
* WorldGuard Permission Checking. * WorldGuard Permission Checking.
@ -34,10 +35,6 @@ import java.util.*;
public class Worldguard { public class Worldguard {
private static Worldguard instance; private static Worldguard instance;
/**
* @author FactionsUUID Team
*/
private Object worldGuard; private Object worldGuard;
private WorldGuardPlugin worldGuardPlugin; private WorldGuardPlugin worldGuardPlugin;
private Object regionContainer; private Object regionContainer;
@ -59,7 +56,7 @@ public class Worldguard {
Plugin p = Bukkit.getPluginManager().getPlugin("WorldGuard"); Plugin p = Bukkit.getPluginManager().getPlugin("WorldGuard");
if (p == null) { if (p == null) {
FactionsPlugin.instance.log("Could not find WorldGuard! Support will not be added."); FactionsPlugin.getInstance().log("Could not find WorldGuard! Support will not be added.");
return; return;
} }
if (p instanceof WorldGuardPlugin) { if (p instanceof WorldGuardPlugin) {
@ -69,9 +66,9 @@ public class Worldguard {
Class<?> worldGuardClass = Class.forName("com.sk89q.worldguard.WorldGuard"); Class<?> worldGuardClass = Class.forName("com.sk89q.worldguard.WorldGuard");
Method getInstanceMethod = worldGuardClass.getMethod("getInstance"); Method getInstanceMethod = worldGuardClass.getMethod("getInstance");
worldGuard = getInstanceMethod.invoke(null); worldGuard = getInstanceMethod.invoke(null);
FactionsPlugin.instance.log("Found WorldGuard 7+"); FactionsPlugin.getInstance().log("Found WorldGuard 7+");
} catch (Exception ex) { } catch (Exception ex) {
FactionsPlugin.instance.log("Found WorldGuard <7"); FactionsPlugin.getInstance().log("Found WorldGuard <7");
} }
} }
} }
@ -95,42 +92,6 @@ public class Worldguard {
return associable; return associable;
} }
public static boolean isPvPDisabled(Location l) {
try {
ApplicableRegionSet regionSet = Objects.requireNonNull(instance.getRegionManager(l.getWorld())).getApplicableRegions(l);
if (regionSet.size() < 1) {
try {
return Objects.requireNonNull(Objects.requireNonNull(instance.getRegionManager(l.getWorld())).getRegion("__global__")).getFlags().get(DefaultFlag.PVP) == StateFlag.State.DENY;
} catch (Exception e) {
if (!(e instanceof NullPointerException)) {
e.printStackTrace();
}
return false;
}
} else {
boolean return_flag = false;
int return_priority = -1;
for (ProtectedRegion region : regionSet) {
if (region.getFlags().containsKey(DefaultFlag.PVP)) {
StateFlag.State pvp_flag = (StateFlag.State) region.getFlags().get(DefaultFlag.PVP);
int region_priority = region.getPriority();
if (return_priority == -1) {
return_flag = pvp_flag == StateFlag.State.DENY;
return_priority = region_priority;
} else if (region_priority > return_priority) {
return_flag = pvp_flag == StateFlag.State.DENY;
return_priority = region_priority;
}
}
}
return return_flag;
}
} catch (Exception e) {
return false;
}
}
/** /**
* Credits to the people listed above for using reflections to load WorldGuard 6.0 & 7.0 in 1 class! * Credits to the people listed above for using reflections to load WorldGuard 6.0 & 7.0 in 1 class!
*/ */
@ -159,8 +120,8 @@ public class Worldguard {
breakFlag = (StateFlag) flagsClass.getField("BREAK").get(null); breakFlag = (StateFlag) flagsClass.getField("BREAK").get(null);
} catch (Exception ex) { } catch (Exception ex) {
FactionsPlugin.instance.log("We failed to load some part of World Guard. Support will be removed!"); FactionsPlugin.getInstance().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!"); FactionsPlugin.getInstance().log("WorldGuard 7.0.0 support is currently in BETA. Please be careful!");
regionContainer = null; regionContainer = null;
return; return;
} }
@ -178,8 +139,8 @@ public class Worldguard {
breakFlag = (StateFlag) flagsClass.getField("BREAK").get(null); breakFlag = (StateFlag) flagsClass.getField("BREAK").get(null);
} catch (Exception ex) { } catch (Exception ex) {
FactionsPlugin.instance.log("We failed to load some part of World Guard. Support will be removed!"); FactionsPlugin.getInstance().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!"); FactionsPlugin.getInstance().log("WorldGuard 7.0.0 support is currently in BETA. Please be careful!");
regionContainer = null; regionContainer = null;
return; return;
} }
@ -195,8 +156,8 @@ public class Worldguard {
vectorConstructorAsAMethodBecauseWhyNot = vectorClass.getMethod("at", Double.TYPE, Double.TYPE, Double.TYPE); vectorConstructorAsAMethodBecauseWhyNot = vectorClass.getMethod("at", Double.TYPE, Double.TYPE, Double.TYPE);
regionManagerGetMethod = RegionManager.class.getMethod("getApplicableRegions", vectorClass); regionManagerGetMethod = RegionManager.class.getMethod("getApplicableRegions", vectorClass);
} catch (Exception sodonewiththis) { } catch (Exception sodonewiththis) {
FactionsPlugin.instance.log("We failed to load Vector Classes from WorldGuard! Support will be removed!"); FactionsPlugin.getInstance().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!"); FactionsPlugin.getInstance().log("WorldGuard 7.0.0 support is currently in BETA. Please be careful!");
regionContainer = null; regionContainer = null;
return; return;
} }
@ -216,7 +177,7 @@ public class Worldguard {
regionManager = (RegionManager) regionContainerGetMethod.invoke(regionContainer, world); regionManager = (RegionManager) regionContainerGetMethod.invoke(regionContainer, world);
} }
} catch (Exception ex) { } catch (Exception ex) {
FactionsPlugin.instance.log("An error occurred looking up a WorldGuard RegionManager"); FactionsPlugin.getInstance().log("An error occurred looking up a WorldGuard RegionManager");
} }
return regionManager; return regionManager;
} }
@ -230,8 +191,8 @@ public class Worldguard {
: vectorConstructorAsAMethodBecauseWhyNot.invoke(null, location.getX(), location.getY(), location.getZ()); : vectorConstructorAsAMethodBecauseWhyNot.invoke(null, location.getX(), location.getY(), location.getZ());
return (ApplicableRegionSet) regionManagerGetMethod.invoke(regionManager, vector); return (ApplicableRegionSet) regionManagerGetMethod.invoke(regionManager, vector);
} catch (Exception ex) { } catch (Exception ex) {
FactionsPlugin.instance.log("An error occurred looking up a WorldGuard ApplicableRegionSet"); FactionsPlugin.getInstance().log("An error occurred looking up a WorldGuard ApplicableRegionSet");
FactionsPlugin.instance.log("WorldGuard 7.0.0 support is currently in BETA. Please be careful!"); FactionsPlugin.getInstance().log("WorldGuard 7.0.0 support is currently in BETA. Please be careful!");
} }
return null; return null;
} }
@ -255,8 +216,8 @@ public class Worldguard {
} else } else
return (boolean) regionQueryTestStateMethod.invoke(query, location, getAssociable(player), new StateFlag[]{buildFlag}); return (boolean) regionQueryTestStateMethod.invoke(query, location, getAssociable(player), new StateFlag[]{buildFlag});
} catch (Exception ex) { } catch (Exception ex) {
FactionsPlugin.instance.log("An error occurred querying WorldGuard! Report this issue to SF Developers!"); FactionsPlugin.getInstance().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!"); FactionsPlugin.getInstance().log("WorldGuard 7.0.0 support is currently in BETA. Please be careful!");
} }
} }
return true; return true;
@ -281,8 +242,8 @@ public class Worldguard {
return (boolean) regionQueryTestStateMethod.invoke(query, location, getAssociable(player), new StateFlag[]{breakFlag}); return (boolean) regionQueryTestStateMethod.invoke(query, location, getAssociable(player), new StateFlag[]{breakFlag});
} catch (Exception ex) { } catch (Exception ex) {
FactionsPlugin.instance.log("An error occurred querying WorldGuard! Report this issue to SF Developers!"); FactionsPlugin.getInstance().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!"); FactionsPlugin.getInstance().log("WorldGuard 7.0.0 support is currently in BETA. Please be careful!");
} }
} }
return true; return true;
@ -320,8 +281,8 @@ public class Worldguard {
return overlaps != null && !overlaps.isEmpty(); return overlaps != null && !overlaps.isEmpty();
} catch (Exception ex) { } catch (Exception ex) {
FactionsPlugin.instance.log("An error occurred querying WorldGuard! Report this issue to SF Developers!"); FactionsPlugin.getInstance().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!"); FactionsPlugin.getInstance().log("WorldGuard 7.0.0 support is currently in BETA. Please be careful!");
} }
} }
return false; return false;

View File

@ -94,26 +94,23 @@ public class FactionsBlockListener implements Listener {
boolean landOwned = (myFaction.doesLocationHaveOwnersSet(loc) && !myFaction.getOwnerList(loc).isEmpty()); boolean landOwned = (myFaction.doesLocationHaveOwnersSet(loc) && !myFaction.getOwnerList(loc).isEmpty());
if ((landOwned && myFaction.getOwnerListString(loc).contains(player.getName())) || (me.getRole() == Role.LEADER && me.getFactionId().equals(myFaction.getId()))) if ((landOwned && myFaction.getOwnerListString(loc).contains(player.getName())) || (me.getRole() == Role.LEADER && me.getFactionId().equals(myFaction.getId())))
return true; return true;
else { else if (landOwned && !myFaction.getOwnerListString(loc).contains(player.getName())) {
String replace = TL.ACTIONS_NOPERMISSIONPAIN.toString().replace("{action}", action.toString());
if (landOwned && !myFaction.getOwnerListString(loc).contains(player.getName())) {
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);
me.msg(replace.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);
if ((Board.getInstance().getFactionAt(loc).getTag(myFaction)) != null) if ((Board.getInstance().getFactionAt(loc).getTag(myFaction)) != null)
me.msg(replace.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)));
} }
if (myFaction.getTag(me.getFaction()) != null && action != null) if (myFaction.getTag(me.getFaction()) != null && action != null)
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()));
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()));
return false; return false;
} }
@ -416,9 +413,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();
@ -426,15 +422,12 @@ 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, PermissableAction.FROST_WALK.toString(), justCheck)) { if (!playerCanBuildDestroyBlock(player, location, PermissableAction.FROST_WALK.toString(), justCheck))
event.setCancelled(true); event.setCancelled(true);
} }
}
@EventHandler @EventHandler
public void onFallingBlock(EntityChangeBlockEvent event) { public void onFallingBlock(EntityChangeBlockEvent event) {
@ -538,6 +531,7 @@ public class FactionsBlockListener implements Listener {
Player p = (Player) event.getRemover(); Player p = (Player) event.getRemover();
if (!playerCanBuildDestroyBlock(p, event.getEntity().getLocation(), "destroy", true)) { if (!playerCanBuildDestroyBlock(p, event.getEntity().getLocation(), "destroy", true)) {
event.setCancelled(true); event.setCancelled(true);
return;
} }
} }
} }

View File

@ -7,7 +7,6 @@ import com.massivecraft.factions.util.MiscUtil;
import com.massivecraft.factions.zcore.util.TL; import com.massivecraft.factions.zcore.util.TL;
import org.bukkit.Bukkit; import org.bukkit.Bukkit;
import org.bukkit.Location; import org.bukkit.Location;
import org.bukkit.Material;
import org.bukkit.block.Block; import org.bukkit.block.Block;
import org.bukkit.entity.*; import org.bukkit.entity.*;
import org.bukkit.entity.minecart.ExplosiveMinecart; import org.bukkit.entity.minecart.ExplosiveMinecart;
@ -95,11 +94,9 @@ public class FactionsEntityListener implements Listener {
public void onEntityDamage(EntityDamageEvent event) { public void onEntityDamage(EntityDamageEvent event) {
if (event instanceof EntityDamageByEntityEvent) { if (event instanceof EntityDamageByEntityEvent) {
EntityDamageByEntityEvent sub = (EntityDamageByEntityEvent) event; EntityDamageByEntityEvent sub = (EntityDamageByEntityEvent) event;
if (!this.canDamagerHurtDamagee(sub, true)) { if (!this.canDamagerHurtDamagee(sub, true)) event.setCancelled(true);
event.setCancelled(true);
}
// event is not cancelled by factions
// event is not cancelled by factions
Entity damagee = sub.getEntity(); Entity damagee = sub.getEntity();
Entity damager = sub.getDamager(); Entity damager = sub.getDamager();
if (damagee instanceof Player) { if (damagee instanceof Player) {
@ -126,15 +123,12 @@ public class FactionsEntityListener implements Listener {
// this should disable the fly so // this should disable the fly so
return; return;
} }
} else { } else return; // 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;
}
} }
} }
} else { } else {
// Protect armor stands/item frames from being damaged in protected territories // Protect armor stands/item frames from being damaged in protected territories
if (damagee.getType() == EntityType.ITEM_FRAME || damagee.getType().name().equals("armor_stand")) { if (damagee.getType() == EntityType.ITEM_FRAME || damagee.getType() == EntityType.ARMOR_STAND) {
// Manage projectiles launched by players // Manage projectiles launched by players
if (damager instanceof Projectile && ((Projectile) damager).getShooter() instanceof Entity) { if (damager instanceof Projectile && ((Projectile) damager).getShooter() instanceof Entity) {
damager = (Entity) ((Projectile) damager).getShooter(); damager = (Entity) ((Projectile) damager).getShooter();
@ -142,37 +136,22 @@ public class FactionsEntityListener implements Listener {
// Run the check for a player // Run the check for a player
if (damager instanceof Player) { if (damager instanceof Player) {
Player player = (Player) damager;
Material material = null; if (!FactionsBlockListener.playerCanBuildDestroyBlock((Player) damager, damagee.getLocation(), "destroy", false))
switch (sub.getEntity().getType()) {
case ITEM_FRAME:
material = Material.ITEM_FRAME;
break;
case ARMOR_STAND:
material = Material.ARMOR_STAND;
break;
}
if (material != null && !FactionsBlockListener.playerCanBuildDestroyBlock(player, damagee.getLocation(), "destroy " + material.toString().toLowerCase(), false)) {
event.setCancelled(true); event.setCancelled(true);
}
} else { } else {
// we don't want to let mobs/arrows destroy item frames/armor stands // we don't want to let mobs/arrows destroy item frames/armor stands
// so we only have to run the check as if there had been an explosion at the damager location // so we only have to run the check as if there had been an explosion at the damager location
if (!this.checkExplosionForBlock(damager, damagee.getLocation().getBlock())) { if (!this.checkExplosionForBlock(damager, damagee.getLocation().getBlock()))
event.setCancelled(true); event.setCancelled(true);
} }
}
// we don't need to go after // we don't need to go after
return; return;
} }
//this one should trigger if something other than a player takes damage //this one should trigger if something other than a player takes damage
if (damager instanceof Player) { if (damager instanceof Player) return;
// now itll only go here if the damage is dealt by a player
return;
// we cancel it so fly isnt removed when you hit a mob etc
}
} }
if (damagee != null && damagee instanceof Player) { if (damagee != null && damagee instanceof Player) {
cancelFStuckTeleport((Player) damagee); cancelFStuckTeleport((Player) damagee);
@ -216,6 +195,7 @@ public class FactionsEntityListener implements Listener {
} }
} }
private void cancelFFly(Player player) { private void cancelFFly(Player player) {
if (player == null) return; if (player == null) return;
FPlayer fPlayer = FPlayers.getInstance().getByPlayer(player); FPlayer fPlayer = FPlayers.getInstance().getByPlayer(player);
@ -361,26 +341,23 @@ public class FactionsEntityListener implements Listener {
if (!(damagee instanceof Player)) return true; if (!(damagee instanceof Player)) return true;
FPlayer defender = FPlayers.getInstance().getByPlayer((Player) damagee); FPlayer defender = FPlayers.getInstance().getByPlayer((Player) damagee);
if (defender == null || defender.getPlayer() == null) return true; if (defender == null || defender.getPlayer() == null) return true;
Location defenderLoc = defender.getPlayer().getLocation(); Location defenderLoc = defender.getPlayer().getLocation();
Faction defLocFaction = Board.getInstance().getFactionAt(new FLocation(defenderLoc)); Faction defLocFaction = Board.getInstance().getFactionAt(new FLocation(defenderLoc));
// for damage caused by projectiles, getDamager() returns the projectile... what we need to know is the source // for damage caused by projectiles, getDamager() returns the projectile... what we need to know is the source
if (damager instanceof Projectile) { if (damager instanceof Projectile) {
Projectile projectile = (Projectile) damager; Projectile projectile = (Projectile) damager;
if (!(projectile.getShooter() instanceof Entity)) return true; if (!(projectile.getShooter() instanceof Entity)) return true;
damager = (Entity) projectile.getShooter(); damager = (Entity) projectile.getShooter();
} }
if (damager == damagee) return true; // ender pearl usage and other self-inflicted damage if (damager == damagee) return true; // ender pearl usage and other self-inflicted damage
// Players can not take attack damage in a SafeZone, or possibly peaceful territory // Players can not take attack damage in a SafeZone or peaceful territory depending on Conf options.
if (defLocFaction.noPvPInTerritory()) { if (defLocFaction.noPvPInTerritory()) {
if (damager instanceof Player) { if (damager instanceof Player) {
if (notify) { if (notify) {
@ -394,19 +371,14 @@ public class FactionsEntityListener implements Listener {
if (!(damager instanceof Player)) return true; if (!(damager instanceof Player)) return true;
FPlayer attacker = FPlayers.getInstance().getByPlayer((Player) damager); FPlayer attacker = FPlayers.getInstance().getByPlayer((Player) damager);
if (attacker == null || attacker.getPlayer() == null) return true; if (attacker == null || attacker.getPlayer() == null) return true;
if (Conf.playersWhoBypassAllProtection.contains(attacker.getName())) return true; if (Conf.playersWhoBypassAllProtection.contains(attacker.getName())) return true;
if (attacker.hasLoginPvpDisabled()) { if (attacker.hasLoginPvpDisabled()) {
if (notify) { if (notify) attacker.msg(TL.PLAYER_PVP_LOGIN, Conf.noPVPDamageToOthersForXSecondsAfterLogin);
attacker.msg(TL.PLAYER_PVP_LOGIN, Conf.noPVPDamageToOthersForXSecondsAfterLogin);
}
return false; return false;
} }
@ -414,47 +386,32 @@ public class FactionsEntityListener implements Listener {
// so we know from above that the defender isn't in a safezone... what about the attacker, sneaky dog that he might be? // so we know from above that the defender isn't in a safezone... what about the attacker, sneaky dog that he might be?
if (locFaction.noPvPInTerritory()) { if (locFaction.noPvPInTerritory()) {
if (notify) { if (notify)
attacker.msg(TL.PLAYER_CANTHURT, (locFaction.isSafeZone() ? TL.REGION_SAFEZONE.toString() : TL.REGION_PEACEFUL.toString())); attacker.msg(TL.PLAYER_CANTHURT, (locFaction.isSafeZone() ? TL.REGION_SAFEZONE.toString() : TL.REGION_PEACEFUL.toString()));
}
return false; return false;
} }
if (locFaction.isWarZone() && Conf.warZoneFriendlyFire) return true; if (locFaction.isWarZone() && Conf.warZoneFriendlyFire) return true;
if (Conf.worldsIgnorePvP.contains(defenderLoc.getWorld().getName())) return true; if (Conf.worldsIgnorePvP.contains(defenderLoc.getWorld().getName())) return true;
Faction defendFaction = defender.getFaction(); Faction defendFaction = defender.getFaction();
Faction attackFaction = attacker.getFaction(); Faction attackFaction = attacker.getFaction();
if (attackFaction.isWilderness() && Conf.disablePVPForFactionlessPlayers) { if (attackFaction.isWilderness() && Conf.disablePVPForFactionlessPlayers) {
if (notify) { if (notify) attacker.msg(TL.PLAYER_PVP_REQUIREFACTION);
attacker.msg(TL.PLAYER_PVP_REQUIREFACTION);
}
return false; return false;
} else if (defendFaction.isWilderness()) { } else if (defendFaction.isWilderness()) {
if (defLocFaction == attackFaction && Conf.enablePVPAgainstFactionlessInAttackersLand) { if (defLocFaction == attackFaction && Conf.enablePVPAgainstFactionlessInAttackersLand) {
// Allow PVP vs. Factionless in attacker's faction territory // Allow PVP vs. Factionless in attacker's faction territory
return true; return true;
} else if (Conf.disablePVPForFactionlessPlayers) { } else if (Conf.disablePVPForFactionlessPlayers) {
if (notify) { if (notify) attacker.msg(TL.PLAYER_PVP_FACTIONLESS);
attacker.msg(TL.PLAYER_PVP_FACTIONLESS);
}
return false; return false;
} }
} }
if (defendFaction.isPeaceful()) { if (defendFaction.isPeaceful() || attackFaction.isPeaceful()) {
if (notify) { if (notify) attacker.msg(TL.PLAYER_PVP_PEACEFUL);
attacker.msg(TL.PLAYER_PVP_PEACEFUL);
}
return false;
} else if (attackFaction.isPeaceful()) {
if (notify) {
attacker.msg(TL.PLAYER_PVP_PEACEFUL);
}
return false; return false;
} }
@ -462,21 +419,16 @@ public class FactionsEntityListener implements Listener {
// You can not hurt neutral factions // You can not hurt neutral factions
if (Conf.disablePVPBetweenNeutralFactions && relation.isNeutral()) { if (Conf.disablePVPBetweenNeutralFactions && relation.isNeutral()) {
if (notify) { if (notify) attacker.msg(TL.PLAYER_PVP_NEUTRAL);
attacker.msg(TL.PLAYER_PVP_NEUTRAL);
}
return false; return false;
} }
// Players without faction may be hurt anywhere // Players without faction may be hurt anywhere
if (!defender.hasFaction()) return true; if (!defender.hasFaction()) return true;
// You can never hurt faction members or allies // You can never hurt faction members or allies
if (relation.isMember() || relation.isAlly() || relation.isTruce()) { if (relation.isMember() || relation.isAlly()) {
if (notify) { if (notify) attacker.msg(TL.PLAYER_PVP_CANTHURT, defender.describeTo(attacker));
attacker.msg(TL.PLAYER_PVP_CANTHURT, defender.describeTo(attacker));
}
return false; return false;
} }
@ -490,23 +442,10 @@ public class FactionsEntityListener implements Listener {
} }
return false; return false;
} }
// Damage will be dealt. However check if the damage should be reduced.
/*
if (damage > 0.0 && ownTerritory && Conf.territoryShieldFactor > 0) {
double newDamage = Math.ceil(damage * (1D - Conf.territoryShieldFactor));
sub.setDamage(newDamage);
// Send message
if (notify) {
String perc = MessageFormat.format("{0,number,#%}", (Conf.territoryShieldFactor)); // TODO does this display correctly??
defender.msg("<i>Enemy damage reduced by <rose>%s<i>.", perc);
}
} */
return true; return true;
} }
@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) return; if (event.getLocation() == null) return;
@ -557,14 +496,10 @@ public class FactionsEntityListener implements Listener {
@EventHandler @EventHandler
public void onHangerBreak(HangingBreakByEntityEvent e) { public void onHangerBreak(HangingBreakByEntityEvent e) {
if (e.getRemover() == null) return;
if (!(e.getRemover() instanceof Player)) return; if (!(e.getRemover() instanceof Player)) return;
Player p = (Player) e.getRemover(); Player p = (Player) e.getRemover();
if (e.getEntity().getType().equals(EntityType.PAINTING)) {
if (!FactionsBlockListener.playerCanBuildDestroyBlock(p, e.getEntity().getLocation(), "destroy", false)) { if (e.getEntity().getType() == EntityType.PAINTING || e.getEntity().getType() == EntityType.ITEM_FRAME) {
e.setCancelled(true);
}
} else if (e.getEntity().getType().equals(EntityType.ITEM_FRAME)) {
if (!FactionsBlockListener.playerCanBuildDestroyBlock(p, e.getEntity().getLocation(), "destroy", false)) { if (!FactionsBlockListener.playerCanBuildDestroyBlock(p, e.getEntity().getLocation(), "destroy", false)) {
e.setCancelled(true); e.setCancelled(true);
} }
@ -572,48 +507,38 @@ public class FactionsEntityListener implements Listener {
} }
@EventHandler(priority = EventPriority.NORMAL, ignoreCancelled = true) @EventHandler(priority = EventPriority.NORMAL, ignoreCancelled = true)
public void onPaintingPlace(HangingPlaceEvent event) { public void onPaintingPlace(HangingPlaceEvent e) {
if (event.getEntity().getType().equals(EntityType.PAINTING)) { if (e.getPlayer() == null) return;
if (!FactionsBlockListener.playerCanBuildDestroyBlock(event.getPlayer(), event.getBlock().getLocation(), "build", false)) {
event.setCancelled(true); if (e.getEntity().getType() == EntityType.PAINTING || e.getEntity().getType() == EntityType.ITEM_FRAME) {
// Fix: update player's inventory to avoid items glitches if (!FactionsBlockListener.playerCanBuildDestroyBlock(e.getPlayer(), e.getBlock().getLocation(), "build", false)) {
event.getPlayer().updateInventory(); e.setCancelled(true);
} e.getPlayer().updateInventory();
} else if (event.getEntity().getType().equals(EntityType.ITEM_FRAME)) {
if (!FactionsBlockListener.playerCanBuildDestroyBlock(event.getPlayer(), event.getEntity().getLocation(), "build", false)) {
event.setCancelled(true);
// Fix: update player's inventory to avoid items glitches
event.getPlayer().updateInventory();
} }
} }
} }
@EventHandler(priority = EventPriority.NORMAL, ignoreCancelled = true) @EventHandler(priority = EventPriority.NORMAL, ignoreCancelled = true)
public void onEntityChangeBlock(EntityChangeBlockEvent event) { public void onEntityChangeBlock(EntityChangeBlockEvent e) {
Entity entity = event.getEntity(); Entity entity = e.getEntity();
Location loc = e.getBlock().getLocation();
// 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)) return; if (entity.getType() == EntityType.ENDERMAN) {
if (stopEndermanBlockManipulation(loc)) e.setCancelled(true);
} else if (entity.getType() == EntityType.WITHER) {
Location loc = event.getBlock().getLocation();
if (entity instanceof Enderman) {
if (stopEndermanBlockManipulation(loc)) {
event.setCancelled(true);
}
} else if (entity instanceof Wither) {
Faction faction = Board.getInstance().getFactionAt(new FLocation(loc)); Faction faction = Board.getInstance().getFactionAt(new FLocation(loc));
// it's a bit crude just using fireball protection, but I'd rather not add in a whole new set of xxxBlockWitherExplosion or whatever // it's a bit crude just using fireball protection, but I'd rather not add in a whole new set of xxxBlockWitherExplosion or whatever
if ((faction.isWilderness() && Conf.wildernessBlockFireballs && !Conf.worldsNoWildernessProtection.contains(loc.getWorld().getName())) || if ((faction.isWilderness() && Conf.wildernessBlockFireballs && !Conf.worldsNoWildernessProtection.contains(loc.getWorld().getName())) ||
(faction.isNormal() && (faction.hasPlayersOnline() ? Conf.territoryBlockFireballs : Conf.territoryBlockFireballsWhenOffline)) || (faction.isNormal() && (faction.hasPlayersOnline() ? Conf.territoryBlockFireballs : Conf.territoryBlockFireballsWhenOffline)) ||
(faction.isWarZone() && Conf.warZoneBlockFireballs) || (faction.isWarZone() && Conf.warZoneBlockFireballs) ||
faction.isSafeZone()) { faction.isSafeZone()) {
event.setCancelled(true); e.setCancelled(true);
} }
} }
} }
/* /*
@EventHandler @EventHandler
public void onTravel(PlayerPortalEvent event) { public void onTravel(PlayerPortalEvent event) {

View File

@ -19,12 +19,12 @@ 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.CC; import com.massivecraft.factions.util.CC;
import com.massivecraft.factions.util.wait.WaitExecutor;
import com.massivecraft.factions.zcore.frame.FactionGUI;
import com.massivecraft.factions.util.VisualizeUtil; import com.massivecraft.factions.util.VisualizeUtil;
import com.massivecraft.factions.util.XMaterial; import com.massivecraft.factions.util.XMaterial;
import com.massivecraft.factions.util.wait.WaitExecutor;
import com.massivecraft.factions.zcore.fperms.Access; import com.massivecraft.factions.zcore.fperms.Access;
import com.massivecraft.factions.zcore.fperms.PermissableAction; import com.massivecraft.factions.zcore.fperms.PermissableAction;
import com.massivecraft.factions.zcore.frame.FactionGUI;
import com.massivecraft.factions.zcore.persist.MemoryFPlayer; import com.massivecraft.factions.zcore.persist.MemoryFPlayer;
import com.massivecraft.factions.zcore.util.TL; import com.massivecraft.factions.zcore.util.TL;
import com.massivecraft.factions.zcore.util.TagUtil; import com.massivecraft.factions.zcore.util.TagUtil;
@ -571,7 +571,8 @@ public class FactionsPlayerListener implements Listener {
} }
public void checkCanFly(FPlayer me) { public void checkCanFly(FPlayer me) {
if (!FactionsPlugin.getInstance().getConfig().getBoolean("enable-faction-flight") || !FactionsPlugin.instance.getConfig().getBoolean("ffly.AutoEnable")) return; if (!FactionsPlugin.getInstance().getConfig().getBoolean("enable-faction-flight") || !FactionsPlugin.instance.getConfig().getBoolean("ffly.AutoEnable"))
return;
if (me.isFlying()) return; if (me.isFlying()) return;
me.setFFlying(true, false); me.setFFlying(true, false);
CmdFly.flyMap.put(me.getName(), true); CmdFly.flyMap.put(me.getName(), true);

View File

@ -2,8 +2,8 @@ package com.massivecraft.factions.missions;
import com.massivecraft.factions.FPlayer; import com.massivecraft.factions.FPlayer;
import com.massivecraft.factions.FactionsPlugin; import com.massivecraft.factions.FactionsPlugin;
import com.massivecraft.factions.zcore.frame.FactionGUI;
import com.massivecraft.factions.util.XMaterial; import com.massivecraft.factions.util.XMaterial;
import com.massivecraft.factions.zcore.frame.FactionGUI;
import com.massivecraft.factions.zcore.util.TL; import com.massivecraft.factions.zcore.util.TL;
import org.bukkit.ChatColor; import org.bukkit.ChatColor;
import org.bukkit.configuration.ConfigurationSection; import org.bukkit.configuration.ConfigurationSection;

View File

@ -11,10 +11,8 @@ import com.massivecraft.factions.util.XMaterial;
import com.massivecraft.factions.zcore.util.TL; import com.massivecraft.factions.zcore.util.TL;
import org.bukkit.Bukkit; import org.bukkit.Bukkit;
import org.bukkit.ChatColor; import org.bukkit.ChatColor;
import org.bukkit.Material;
import org.bukkit.configuration.ConfigurationSection; import org.bukkit.configuration.ConfigurationSection;
import org.bukkit.enchantments.Enchantment; import org.bukkit.enchantments.Enchantment;
import org.bukkit.entity.Item;
import org.bukkit.entity.Player; import org.bukkit.entity.Player;
import org.bukkit.inventory.ItemFlag; import org.bukkit.inventory.ItemFlag;
import org.bukkit.inventory.ItemStack; import org.bukkit.inventory.ItemStack;
@ -22,7 +20,6 @@ import org.bukkit.inventory.meta.ItemMeta;
import java.util.ArrayList; import java.util.ArrayList;
import java.util.List; import java.util.List;
import java.util.Objects;
import java.util.stream.Collectors; import java.util.stream.Collectors;
public class ShopGUIFrame { public class ShopGUIFrame {

View File

@ -1,7 +1,6 @@
package com.massivecraft.factions.tag; package com.massivecraft.factions.tag;
import com.massivecraft.factions.FPlayer; import com.massivecraft.factions.FPlayer;
import com.massivecraft.factions.FactionsPlugin;
import com.massivecraft.factions.integration.Econ; import com.massivecraft.factions.integration.Econ;
import com.massivecraft.factions.zcore.util.TL; import com.massivecraft.factions.zcore.util.TL;
import org.apache.commons.lang.time.DurationFormatUtils; import org.apache.commons.lang.time.DurationFormatUtils;
@ -16,13 +15,6 @@ public enum PlayerTag implements Tag {
/** /**
* @author FactionsUUID Team * @author FactionsUUID Team
*/ */
GROUP("{group}", (fp) -> {
if (fp.isOnline()) {
return FactionsPlugin.getInstance().getPrimaryGroup(fp.getPlayer());
} else {
return "";
}
}),
LAST_SEEN("{lastSeen}", (fp) -> { LAST_SEEN("{lastSeen}", (fp) -> {
String humanized = DurationFormatUtils.formatDurationWords(System.currentTimeMillis() - fp.getLastLoginTime(), true, true) + TL.COMMAND_STATUS_AGOSUFFIX; String humanized = DurationFormatUtils.formatDurationWords(System.currentTimeMillis() - fp.getLastLoginTime(), true, true) + TL.COMMAND_STATUS_AGOSUFFIX;
return fp.isOnline() ? ChatColor.GREEN + TL.COMMAND_STATUS_ONLINE.toString() : (System.currentTimeMillis() - fp.getLastLoginTime() < 432000000 ? ChatColor.YELLOW + humanized : ChatColor.RED + humanized); return fp.isOnline() ? ChatColor.GREEN + TL.COMMAND_STATUS_ONLINE.toString() : (System.currentTimeMillis() - fp.getLastLoginTime() < 432000000 ? ChatColor.YELLOW + humanized : ChatColor.RED + humanized);

View File

@ -5,7 +5,7 @@ package com.massivecraft.factions.util;
* All rights reserved 2020. * All rights reserved 2020.
* Creation Date: 4/4/2020 * Creation Date: 4/4/2020
*/ */
import com.massivecraft.factions.util.XMaterial;
import org.bukkit.Bukkit; import org.bukkit.Bukkit;
import org.bukkit.Color; import org.bukkit.Color;
import org.bukkit.Location; import org.bukkit.Location;

View File

@ -5,6 +5,7 @@ package com.massivecraft.factions.util;
* All rights reserved 2020. * All rights reserved 2020.
* Creation Date: 4/4/2020 * Creation Date: 4/4/2020
*/ */
import org.bukkit.Bukkit; import org.bukkit.Bukkit;
import java.lang.reflect.Constructor; import java.lang.reflect.Constructor;

View File

@ -13,8 +13,8 @@ import java.util.concurrent.ConcurrentHashMap;
* Creation Date: 4/4/2020 * Creation Date: 4/4/2020
*/ */
public class WaitExecutor { public class WaitExecutor {
private static boolean enabled = false;
public static ConcurrentHashMap<Player, WaitTask> taskMap = new ConcurrentHashMap<>(); public static ConcurrentHashMap<Player, WaitTask> taskMap = new ConcurrentHashMap<>();
private static boolean enabled = false;
public static void startTask() { public static void startTask() {
if (enabled) return; if (enabled) return;

View File

@ -25,6 +25,10 @@ public class WaitTask {
return wait; return wait;
} }
public void setWait(Integer i) {
wait = i;
}
public TL getMessage() { public TL getMessage() {
return msg; return msg;
} }
@ -33,10 +37,6 @@ public class WaitTask {
return player; return player;
} }
public void setWait(Integer i) {
wait = i;
}
public void success() { public void success() {
origin.handleSuccess(player); origin.handleSuccess(player);
} }

View File

@ -846,14 +846,14 @@ public abstract class MemoryFPlayer implements FPlayer {
Faction currentFaction = Board.getInstance().getFactionAt(flocation); Faction currentFaction = Board.getInstance().getFactionAt(flocation);
int ownedLand = forFaction.getLandRounded(); int ownedLand = forFaction.getLandRounded();
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) - 1;
if (Conf.worldGuardChecking && Worldguard.getInstance().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) - 1)) {
error = FactionsPlugin.getInstance().txt.parse(TL.CLAIM_OUTSIDEWORLDBORDER.toString()); error = FactionsPlugin.getInstance().txt.parse(TL.CLAIM_OUTSIDEWORLDBORDER.toString());
} else if (Conf.useWorldConfigurationsAsWhitelist != Conf.worldsNoClaiming.contains(flocation.getWorldName())) { } else if (Conf.worldsNoClaiming.contains(flocation.getWorldName())) {
error = FactionsPlugin.getInstance().txt.parse(TL.CLAIM_DISABLED.toString()); error = FactionsPlugin.getInstance().txt.parse(TL.CLAIM_DISABLED.toString());
} else if (this.isAdminBypassing()) { } else if (this.isAdminBypassing()) {
return true; return true;
@ -863,14 +863,10 @@ public abstract class MemoryFPlayer implements FPlayer {
return true; return true;
} else if (currentFaction.getAccess(this, PermissableAction.TERRITORY) == Access.ALLOW) { } else if (currentFaction.getAccess(this, PermissableAction.TERRITORY) == Access.ALLOW) {
return true; return true;
} else if (currentFaction.isWilderness() && forFaction.getAccess(this, PermissableAction.TERRITORY) == Access.ALLOW) {
return true;
} else if (myFaction != forFaction) { } else if (myFaction != forFaction) {
error = FactionsPlugin.getInstance().txt.parse(TL.CLAIM_CANTCLAIM.toString(), forFaction.describeTo(this)); error = FactionsPlugin.getInstance().txt.parse(TL.CLAIM_CANTCLAIM.toString(), forFaction.describeTo(this));
} else if (forFaction == currentFaction) { } else if (forFaction == currentFaction) {
error = FactionsPlugin.getInstance().txt.parse(TL.CLAIM_ALREADYOWN.toString(), forFaction.describeTo(this, true)); error = FactionsPlugin.getInstance().txt.parse(TL.CLAIM_ALREADYOWN.toString(), forFaction.describeTo(this, true));
} else if (forFaction.getAccess(this, PermissableAction.TERRITORY) != Access.ALLOW) {
error = TL.COMMAND_CLAIM_DENIED.toString();
} else if (forFaction.getFPlayers().size() < Conf.claimsRequireMinFactionMembers) { } else if (forFaction.getFPlayers().size() < Conf.claimsRequireMinFactionMembers) {
error = FactionsPlugin.getInstance().txt.parse(TL.CLAIM_MEMBERS.toString(), Conf.claimsRequireMinFactionMembers); error = FactionsPlugin.getInstance().txt.parse(TL.CLAIM_MEMBERS.toString(), Conf.claimsRequireMinFactionMembers);
} else if (currentFaction.isSafeZone()) { } else if (currentFaction.isSafeZone()) {
@ -914,7 +910,9 @@ public abstract class MemoryFPlayer implements FPlayer {
} }
// TODO: Add more else if statements. // TODO: Add more else if statements.
if (notifyFailure && error != null) msg(error); if (notifyFailure && error != null) {
msg(error);
}
return error == null; return error == null;
} }
@ -973,7 +971,8 @@ public abstract class MemoryFPlayer implements FPlayer {
if (!damage) { if (!damage) {
msg(TL.COMMAND_FLY_CHANGE, fly ? "enabled" : "disabled"); msg(TL.COMMAND_FLY_CHANGE, fly ? "enabled" : "disabled");
if (!fly) sendMessage(TL.COMMAND_FLY_COOLDOWN.toString().replace("{amount}", FactionsPlugin.getInstance().getConfig().getInt("fly-falldamage-cooldown", 3) + "")); if (!fly)
sendMessage(TL.COMMAND_FLY_COOLDOWN.toString().replace("{amount}", FactionsPlugin.getInstance().getConfig().getInt("fly-falldamage-cooldown", 3) + ""));
} else { } else {
msg(TL.COMMAND_FLY_DAMAGE); msg(TL.COMMAND_FLY_DAMAGE);
} }
@ -1216,10 +1215,14 @@ public abstract class MemoryFPlayer implements FPlayer {
public boolean attemptClaim(Faction forFaction, FLocation flocation, boolean notifyFailure) { public boolean attemptClaim(Faction forFaction, FLocation flocation, boolean notifyFailure) {
// notifyFailure is false if called by auto-claim; no need to notify on every failure for it // notifyFailure is false if called by auto-claim; no need to notify on every failure for it
// return value is false on failure, true on success // return value is false on failure, true on success
Faction currentFaction = Board.getInstance().getFactionAt(flocation); Faction currentFaction = Board.getInstance().getFactionAt(flocation);
int ownedLand = forFaction.getLandRounded(); int ownedLand = forFaction.getLandRounded();
if (!this.canClaimForFactionAtLocation(forFaction, flocation, notifyFailure)) return false; if (!this.canClaimForFactionAtLocation(forFaction, flocation, notifyFailure)) {
return false;
}
// if economy is enabled and they're not on the bypass list, make sure they can pay // if economy is enabled and they're not on the bypass list, make sure they can pay
boolean mustPay = Econ.shouldBeUsed() && !this.isAdminBypassing() && !forFaction.isSafeZone() && !forFaction.isWarZone() && (Conf.econCostClaimWilderness != 0); boolean mustPay = Econ.shouldBeUsed() && !this.isAdminBypassing() && !forFaction.isSafeZone() && !forFaction.isWarZone() && (Conf.econCostClaimWilderness != 0);
double cost = 0.0; double cost = 0.0;
@ -1238,21 +1241,38 @@ public abstract class MemoryFPlayer implements FPlayer {
payee = this; payee = this;
} }
if (!Econ.hasAtLeast(payee, cost, TL.CLAIM_TOCLAIM.toString())) return false; if (!Econ.hasAtLeast(payee, cost, TL.CLAIM_TOCLAIM.toString())) {
return false;
}
}
if (forFaction.getClaimOwnership().containsKey(flocation) && !forFaction.isPlayerInOwnerList(this, flocation)) {
this.msg(TL.GENERIC_FPERM_OWNER_NOPERMISSION, "claim");
return false;
}
if (Conf.worldGuardChecking && Worldguard.getInstance().checkForRegionsInChunk(flocation)) {
this.msg(TL.GENERIC_WORLDGUARD);
return false;
} }
LandClaimEvent claimEvent = new LandClaimEvent(flocation, forFaction, this); LandClaimEvent claimEvent = new LandClaimEvent(flocation, forFaction, this);
Bukkit.getPluginManager().callEvent(claimEvent); Bukkit.getPluginManager().callEvent(claimEvent);
if (claimEvent.isCancelled()) return false;
if (claimEvent.isCancelled()) {
return false;
}
// then make 'em pay (if applicable) // then make 'em pay (if applicable)
if (mustPay && !Econ.modifyMoney(payee, -cost, TL.CLAIM_TOCLAIM.toString(), TL.CLAIM_FORCLAIM.toString())) if (mustPay && !Econ.modifyMoney(payee, -cost, TL.CLAIM_TOCLAIM.toString(), TL.CLAIM_FORCLAIM.toString())) {
return false; return false;
}
// Was an over claim // Was an over claim
if (mustPay && currentFaction.isNormal() && currentFaction.hasLandInflation()) if (currentFaction.isNormal() && currentFaction.hasLandInflation()) {
// Give them money for over claiming. // Give them money for over claiming.
Econ.modifyMoney(payee, Conf.econOverclaimRewardMultiplier, TL.CLAIM_TOOVERCLAIM.toString(), TL.CLAIM_FOROVERCLAIM.toString()); Econ.modifyMoney(payee, Conf.econOverclaimRewardMultiplier, TL.CLAIM_TOOVERCLAIM.toString(), TL.CLAIM_FOROVERCLAIM.toString());
}
// announce success // announce success
@ -1260,14 +1280,15 @@ public abstract class MemoryFPlayer implements FPlayer {
informTheseFPlayers.add(this); informTheseFPlayers.add(this);
informTheseFPlayers.addAll(forFaction.getFPlayersWhereOnline(true)); informTheseFPlayers.addAll(forFaction.getFPlayersWhereOnline(true));
for (FPlayer fp : informTheseFPlayers) { for (FPlayer fp : informTheseFPlayers) {
if (!fp.hasNotificationsEnabled()) continue;
fp.msg(TL.CLAIM_CLAIMED, this.describeTo(fp, true), forFaction.describeTo(fp), currentFaction.describeTo(fp)); fp.msg(TL.CLAIM_CLAIMED, this.describeTo(fp, true), forFaction.describeTo(fp), currentFaction.describeTo(fp));
} }
Board.getInstance().setFactionAt(forFaction, flocation); Board.getInstance().setFactionAt(forFaction, flocation);
if (Conf.logLandClaims)
if (Conf.logLandClaims) {
FactionsPlugin.getInstance().log(TL.CLAIM_CLAIMEDLOG.toString(), this.getName(), flocation.getCoordString(), forFaction.getTag()); FactionsPlugin.getInstance().log(TL.CLAIM_CLAIMEDLOG.toString(), this.getName(), flocation.getCoordString(), forFaction.getTag());
}
return true; return true;
} }

View File

@ -1110,6 +1110,7 @@ public enum TL {
GENERIC_NOFACTION_FOUND("&cCouldn't find a faction with that name!"), GENERIC_NOFACTION_FOUND("&cCouldn't find a faction with that name!"),
GENERIC_YOUMUSTBE("&cYour must be atleast %1$s to do this!"), GENERIC_YOUMUSTBE("&cYour must be atleast %1$s to do this!"),
GENERIC_MEMBERONLY("&cYou must be in a faction to do this!"), GENERIC_MEMBERONLY("&cYou must be in a faction to do this!"),
GENERIC_WORLDGUARD("&cThis area is worldguard protected."),
// MISSION_CREATED_COOLDOWN("&c&l[!] &7Due to your immediate faction creation, you may not start missions for &b%1$s minutes&7!"), // MISSION_CREATED_COOLDOWN("&c&l[!] &7Due to your immediate faction creation, you may not start missions for &b%1$s minutes&7!"),
MISSION_MISSION_STARTED("&f%1$s &dstarted the %2$s &fmission"), MISSION_MISSION_STARTED("&f%1$s &dstarted the %2$s &fmission"),