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 FileManager fileManager;
public FileManager getFileManager() {
return fileManager;
}
public FactionsPlugin() {
instance = this;
}
@ -110,6 +106,10 @@ public class FactionsPlugin extends MPlugin {
return instance;
}
public FileManager getFileManager() {
return fileManager;
}
public boolean getLocked() {
return this.locked;
}

View File

@ -4,9 +4,9 @@ import com.massivecraft.factions.*;
import com.massivecraft.factions.event.FactionDisbandEvent.PlayerDisbandReason;
import com.massivecraft.factions.struct.Permission;
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.PermissableAction;
import com.massivecraft.factions.zcore.frame.fdisband.FDisbandFrame;
import com.massivecraft.factions.zcore.util.TL;
import org.bukkit.Bukkit;
import org.bukkit.command.ConsoleCommandSender;
@ -103,7 +103,7 @@ public class CmdDisband extends FCommand {
follower.msg(TL.COMMAND_DISBAND_BROADCAST_NOTYOURS, amountString, faction.getTag(follower));
}
}
if (FactionsPlugin.getInstance().getConfig().getBoolean("enable-faction-flight")){
if (FactionsPlugin.getInstance().getConfig().getBoolean("enable-faction-flight")) {
faction.disband(context.player, PlayerDisbandReason.COMMAND);
context.fPlayer.setFFlying(false, false);
return;

View File

@ -4,8 +4,8 @@ import com.google.common.collect.Lists;
import com.massivecraft.factions.Conf;
import com.massivecraft.factions.Faction;
import com.massivecraft.factions.FactionsPlugin;
import com.massivecraft.factions.zcore.frame.FactionGUI;
import com.massivecraft.factions.util.XMaterial;
import com.massivecraft.factions.zcore.frame.FactionGUI;
import com.massivecraft.factions.zcore.util.TL;
import org.bukkit.DyeColor;
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.Faction;
import com.massivecraft.factions.FactionsPlugin;
import com.massivecraft.factions.zcore.frame.FactionGUI;
import com.massivecraft.factions.util.XMaterial;
import com.massivecraft.factions.zcore.frame.FactionGUI;
import com.massivecraft.factions.zcore.util.TL;
import org.bukkit.ChatColor;
import org.bukkit.event.inventory.ClickType;

View File

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

View File

@ -37,7 +37,7 @@ public class CmdMoneyDeposit extends FCommand {
double amount = context.argAsDouble(0, 0d);
EconomyParticipator faction = context.argAsFaction(1, context.faction);
if(amount <= 0){
if (amount <= 0) {
return;
}

View File

@ -34,7 +34,7 @@ public class CmdMoneyTransferFf extends FCommand {
public void perform(CommandContext context) {
double amount = context.argAsDouble(0, 0d);
if(amount <= 0){
if (amount <= 0) {
return;
}

View File

@ -33,7 +33,7 @@ public class CmdMoneyTransferFp extends FCommand {
public void perform(CommandContext context) {
double amount = context.argAsDouble(0, 0d);
if(amount <= 0){
if (amount <= 0) {
return;
}

View File

@ -33,7 +33,7 @@ public class CmdMoneyTransferPf extends FCommand {
public void perform(CommandContext context) {
double amount = context.argAsDouble(0, 0d);
if(amount <= 0){
if (amount <= 0) {
return;
}

View File

@ -40,7 +40,7 @@ public class CmdMoneyWithdraw extends FCommand {
public void perform(CommandContext context) {
double amount = context.argAsDouble(0, 0d);
if(amount <= 0){
if (amount <= 0) {
return;
}

View File

@ -32,7 +32,7 @@ public class CmdPointsBalance extends FCommand {
if (context.argIsSet(0)) {
faction = context.argAsFaction(0);
} else if(context.faction.isNormal()){
} else if (context.faction.isNormal()) {
context.msg(TL.COMMAND_POINTS_SHOW_OWN, context.faction.getPoints());
return;
} else {

View File

@ -20,7 +20,6 @@ import org.bukkit.inventory.ItemStack;
import org.bukkit.inventory.PlayerInventory;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
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.FactionsPlugin;
import com.massivecraft.factions.util.XMaterial;
import com.massivecraft.factions.util.wait.WaitExecutor;
import com.massivecraft.factions.util.wait.WaitTask;
import com.massivecraft.factions.zcore.frame.FactionGUI;
import com.massivecraft.factions.util.XMaterial;
import com.massivecraft.factions.zcore.util.TL;
import org.bukkit.Bukkit;
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.association.Associables;
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.managers.RegionManager;
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.Method;
import java.util.*;
import java.util.ArrayList;
import java.util.Collection;
import java.util.List;
/*
* WorldGuard Permission Checking.
@ -34,10 +35,6 @@ import java.util.*;
public class Worldguard {
private static Worldguard instance;
/**
* @author FactionsUUID Team
*/
private Object worldGuard;
private WorldGuardPlugin worldGuardPlugin;
private Object regionContainer;
@ -59,7 +56,7 @@ public class Worldguard {
Plugin p = Bukkit.getPluginManager().getPlugin("WorldGuard");
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;
}
if (p instanceof WorldGuardPlugin) {
@ -69,9 +66,9 @@ public class Worldguard {
Class<?> worldGuardClass = Class.forName("com.sk89q.worldguard.WorldGuard");
Method getInstanceMethod = worldGuardClass.getMethod("getInstance");
worldGuard = getInstanceMethod.invoke(null);
FactionsPlugin.instance.log("Found WorldGuard 7+");
FactionsPlugin.getInstance().log("Found WorldGuard 7+");
} catch (Exception ex) {
FactionsPlugin.instance.log("Found WorldGuard <7");
FactionsPlugin.getInstance().log("Found WorldGuard <7");
}
}
}
@ -95,42 +92,6 @@ public class Worldguard {
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!
*/
@ -159,8 +120,8 @@ public class Worldguard {
breakFlag = (StateFlag) flagsClass.getField("BREAK").get(null);
} catch (Exception ex) {
FactionsPlugin.instance.log("We failed to load some part of World Guard. Support will be removed!");
FactionsPlugin.instance.log("WorldGuard 7.0.0 support is currently in BETA. Please be careful!");
FactionsPlugin.getInstance().log("We failed to load some part of World Guard. Support will be removed!");
FactionsPlugin.getInstance().log("WorldGuard 7.0.0 support is currently in BETA. Please be careful!");
regionContainer = null;
return;
}
@ -178,8 +139,8 @@ public class Worldguard {
breakFlag = (StateFlag) flagsClass.getField("BREAK").get(null);
} catch (Exception ex) {
FactionsPlugin.instance.log("We failed to load some part of World Guard. Support will be removed!");
FactionsPlugin.instance.log("WorldGuard 7.0.0 support is currently in BETA. Please be careful!");
FactionsPlugin.getInstance().log("We failed to load some part of World Guard. Support will be removed!");
FactionsPlugin.getInstance().log("WorldGuard 7.0.0 support is currently in BETA. Please be careful!");
regionContainer = null;
return;
}
@ -195,8 +156,8 @@ public class Worldguard {
vectorConstructorAsAMethodBecauseWhyNot = vectorClass.getMethod("at", Double.TYPE, Double.TYPE, Double.TYPE);
regionManagerGetMethod = RegionManager.class.getMethod("getApplicableRegions", vectorClass);
} catch (Exception sodonewiththis) {
FactionsPlugin.instance.log("We failed to load Vector Classes from WorldGuard! Support will be removed!");
FactionsPlugin.instance.log("WorldGuard 7.0.0 support is currently in BETA. Please be careful!");
FactionsPlugin.getInstance().log("We failed to load Vector Classes from WorldGuard! Support will be removed!");
FactionsPlugin.getInstance().log("WorldGuard 7.0.0 support is currently in BETA. Please be careful!");
regionContainer = null;
return;
}
@ -216,7 +177,7 @@ public class Worldguard {
regionManager = (RegionManager) regionContainerGetMethod.invoke(regionContainer, world);
}
} 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;
}
@ -230,8 +191,8 @@ public class Worldguard {
: vectorConstructorAsAMethodBecauseWhyNot.invoke(null, location.getX(), location.getY(), location.getZ());
return (ApplicableRegionSet) regionManagerGetMethod.invoke(regionManager, vector);
} catch (Exception ex) {
FactionsPlugin.instance.log("An error occurred looking up a WorldGuard ApplicableRegionSet");
FactionsPlugin.instance.log("WorldGuard 7.0.0 support is currently in BETA. Please be careful!");
FactionsPlugin.getInstance().log("An error occurred looking up a WorldGuard ApplicableRegionSet");
FactionsPlugin.getInstance().log("WorldGuard 7.0.0 support is currently in BETA. Please be careful!");
}
return null;
}
@ -255,8 +216,8 @@ public class Worldguard {
} else
return (boolean) regionQueryTestStateMethod.invoke(query, location, getAssociable(player), new StateFlag[]{buildFlag});
} catch (Exception ex) {
FactionsPlugin.instance.log("An error occurred querying WorldGuard! Report this issue to SF Developers!");
FactionsPlugin.instance.log("WorldGuard 7.0.0 support is currently in BETA. Please be careful!");
FactionsPlugin.getInstance().log("An error occurred querying WorldGuard! Report this issue to SF Developers!");
FactionsPlugin.getInstance().log("WorldGuard 7.0.0 support is currently in BETA. Please be careful!");
}
}
return true;
@ -281,8 +242,8 @@ public class Worldguard {
return (boolean) regionQueryTestStateMethod.invoke(query, location, getAssociable(player), new StateFlag[]{breakFlag});
} catch (Exception ex) {
FactionsPlugin.instance.log("An error occurred querying WorldGuard! Report this issue to SF Developers!");
FactionsPlugin.instance.log("WorldGuard 7.0.0 support is currently in BETA. Please be careful!");
FactionsPlugin.getInstance().log("An error occurred querying WorldGuard! Report this issue to SF Developers!");
FactionsPlugin.getInstance().log("WorldGuard 7.0.0 support is currently in BETA. Please be careful!");
}
}
return true;
@ -320,8 +281,8 @@ public class Worldguard {
return overlaps != null && !overlaps.isEmpty();
} catch (Exception ex) {
FactionsPlugin.instance.log("An error occurred querying WorldGuard! Report this issue to SF Developers!");
FactionsPlugin.instance.log("WorldGuard 7.0.0 support is currently in BETA. Please be careful!");
FactionsPlugin.getInstance().log("An error occurred querying WorldGuard! Report this issue to SF Developers!");
FactionsPlugin.getInstance().log("WorldGuard 7.0.0 support is currently in BETA. Please be careful!");
}
}
return false;

View File

@ -94,26 +94,23 @@ public class FactionsBlockListener implements Listener {
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())))
return true;
else {
String replace = TL.ACTIONS_NOPERMISSIONPAIN.toString().replace("{action}", action.toString());
if (landOwned && !myFaction.getOwnerListString(loc).contains(player.getName())) {
else if (landOwned && !myFaction.getOwnerListString(loc).contains(player.getName())) {
me.msg(TL.ACTIONS_OWNEDTERRITORYDENY.toString().replace("{owners}", myFaction.getOwnerListString(loc)));
if (shouldHurt) {
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;
} else if (!landOwned && access == Access.DENY) { // If land is not owned but access is set to DENY anyway
if (shouldHurt) {
player.damage(Conf.actionDeniedPainAmount);
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)
me.msg(TL.ACTIONS_NOPERMISSION.toString().replace("{faction}", myFaction.getTag(me.getFaction())).replace("{action}", action.toString()));
return false;
} else if (access == Access.ALLOW) return true;
}
me.msg(TL.ACTIONS_NOPERMISSION.toString().replace("{faction}", myFaction.getTag(me.getFaction())).replace("{action}", action.toString()));
return false;
}
@ -416,9 +413,8 @@ public class FactionsBlockListener implements Listener {
@EventHandler(priority = EventPriority.NORMAL, ignoreCancelled = true)
public void onFrostWalker(EntityBlockFormEvent event) {
if (event.getEntity() == null || event.getEntity().getType() != EntityType.PLAYER || event.getBlock() == null) {
if (event.getEntity() == null || event.getEntity().getType() != EntityType.PLAYER || event.getBlock() == null)
return;
}
Player player = (Player) event.getEntity();
Location location = event.getBlock().getLocation();
@ -426,15 +422,12 @@ public class FactionsBlockListener implements Listener {
// only notify every 10 seconds
FPlayer fPlayer = FPlayers.getInstance().getByPlayer(player);
boolean justCheck = fPlayer.getLastFrostwalkerMessage() + 10000 > System.currentTimeMillis();
if (!justCheck) {
fPlayer.setLastFrostwalkerMessage();
}
if (!justCheck) fPlayer.setLastFrostwalkerMessage();
// Check if they have build permissions here. If not, block this from happening.
if (!playerCanBuildDestroyBlock(player, location, PermissableAction.FROST_WALK.toString(), justCheck)) {
if (!playerCanBuildDestroyBlock(player, location, PermissableAction.FROST_WALK.toString(), justCheck))
event.setCancelled(true);
}
}
@EventHandler
public void onFallingBlock(EntityChangeBlockEvent event) {
@ -538,6 +531,7 @@ public class FactionsBlockListener implements Listener {
Player p = (Player) event.getRemover();
if (!playerCanBuildDestroyBlock(p, event.getEntity().getLocation(), "destroy", 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 org.bukkit.Bukkit;
import org.bukkit.Location;
import org.bukkit.Material;
import org.bukkit.block.Block;
import org.bukkit.entity.*;
import org.bukkit.entity.minecart.ExplosiveMinecart;
@ -95,11 +94,9 @@ public class FactionsEntityListener implements Listener {
public void onEntityDamage(EntityDamageEvent event) {
if (event instanceof EntityDamageByEntityEvent) {
EntityDamageByEntityEvent sub = (EntityDamageByEntityEvent) event;
if (!this.canDamagerHurtDamagee(sub, true)) {
event.setCancelled(true);
}
// event is not cancelled by factions
if (!this.canDamagerHurtDamagee(sub, true)) event.setCancelled(true);
// event is not cancelled by factions
Entity damagee = sub.getEntity();
Entity damager = sub.getDamager();
if (damagee instanceof Player) {
@ -126,15 +123,12 @@ public class FactionsEntityListener implements Listener {
// this should disable the fly so
return;
}
} else {
// this should trigger if the attacker shootin the arrow is a mob
return;
}
} else return; // this should trigger if the attacker shootin the arrow is a mob
}
}
} else {
// 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
if (damager instanceof Projectile && ((Projectile) damager).getShooter() instanceof Entity) {
damager = (Entity) ((Projectile) damager).getShooter();
@ -142,37 +136,22 @@ public class FactionsEntityListener implements Listener {
// Run the check for a player
if (damager instanceof Player) {
Player player = (Player) damager;
Material material = null;
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)) {
if (!FactionsBlockListener.playerCanBuildDestroyBlock((Player) damager, damagee.getLocation(), "destroy", false))
event.setCancelled(true);
}
} else {
// 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
if (!this.checkExplosionForBlock(damager, damagee.getLocation().getBlock())) {
if (!this.checkExplosionForBlock(damager, damagee.getLocation().getBlock()))
event.setCancelled(true);
}
}
// we don't need to go after
return;
}
//this one should trigger if something other than a player takes damage
if (damager instanceof Player) {
// 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 (damager instanceof Player) return;
}
if (damagee != null && damagee instanceof Player) {
cancelFStuckTeleport((Player) damagee);
@ -216,6 +195,7 @@ public class FactionsEntityListener implements Listener {
}
}
private void cancelFFly(Player player) {
if (player == null) return;
FPlayer fPlayer = FPlayers.getInstance().getByPlayer(player);
@ -361,26 +341,23 @@ public class FactionsEntityListener implements Listener {
if (!(damagee instanceof Player)) return true;
FPlayer defender = FPlayers.getInstance().getByPlayer((Player) damagee);
if (defender == null || defender.getPlayer() == null) return true;
Location defenderLoc = defender.getPlayer().getLocation();
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
if (damager instanceof Projectile) {
Projectile projectile = (Projectile) damager;
if (!(projectile.getShooter() instanceof Entity)) return true;
damager = (Entity) projectile.getShooter();
}
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 (damager instanceof Player) {
if (notify) {
@ -394,19 +371,14 @@ public class FactionsEntityListener implements Listener {
if (!(damager instanceof Player)) return true;
FPlayer attacker = FPlayers.getInstance().getByPlayer((Player) damager);
if (attacker == null || attacker.getPlayer() == null) return true;
if (Conf.playersWhoBypassAllProtection.contains(attacker.getName())) return true;
if (attacker.hasLoginPvpDisabled()) {
if (notify) {
attacker.msg(TL.PLAYER_PVP_LOGIN, Conf.noPVPDamageToOthersForXSecondsAfterLogin);
}
if (notify) attacker.msg(TL.PLAYER_PVP_LOGIN, Conf.noPVPDamageToOthersForXSecondsAfterLogin);
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?
if (locFaction.noPvPInTerritory()) {
if (notify) {
if (notify)
attacker.msg(TL.PLAYER_CANTHURT, (locFaction.isSafeZone() ? TL.REGION_SAFEZONE.toString() : TL.REGION_PEACEFUL.toString()));
}
return false;
}
if (locFaction.isWarZone() && Conf.warZoneFriendlyFire) return true;
if (Conf.worldsIgnorePvP.contains(defenderLoc.getWorld().getName())) return true;
Faction defendFaction = defender.getFaction();
Faction attackFaction = attacker.getFaction();
if (attackFaction.isWilderness() && Conf.disablePVPForFactionlessPlayers) {
if (notify) {
attacker.msg(TL.PLAYER_PVP_REQUIREFACTION);
}
if (notify) attacker.msg(TL.PLAYER_PVP_REQUIREFACTION);
return false;
} else if (defendFaction.isWilderness()) {
if (defLocFaction == attackFaction && Conf.enablePVPAgainstFactionlessInAttackersLand) {
// Allow PVP vs. Factionless in attacker's faction territory
return true;
} else if (Conf.disablePVPForFactionlessPlayers) {
if (notify) {
attacker.msg(TL.PLAYER_PVP_FACTIONLESS);
}
if (notify) attacker.msg(TL.PLAYER_PVP_FACTIONLESS);
return false;
}
}
if (defendFaction.isPeaceful()) {
if (notify) {
attacker.msg(TL.PLAYER_PVP_PEACEFUL);
}
return false;
} else if (attackFaction.isPeaceful()) {
if (notify) {
attacker.msg(TL.PLAYER_PVP_PEACEFUL);
}
if (defendFaction.isPeaceful() || attackFaction.isPeaceful()) {
if (notify) attacker.msg(TL.PLAYER_PVP_PEACEFUL);
return false;
}
@ -462,21 +419,16 @@ public class FactionsEntityListener implements Listener {
// You can not hurt neutral factions
if (Conf.disablePVPBetweenNeutralFactions && relation.isNeutral()) {
if (notify) {
attacker.msg(TL.PLAYER_PVP_NEUTRAL);
}
if (notify) attacker.msg(TL.PLAYER_PVP_NEUTRAL);
return false;
}
// Players without faction may be hurt anywhere
if (!defender.hasFaction()) return true;
// You can never hurt faction members or allies
if (relation.isMember() || relation.isAlly() || relation.isTruce()) {
if (notify) {
attacker.msg(TL.PLAYER_PVP_CANTHURT, defender.describeTo(attacker));
}
if (relation.isMember() || relation.isAlly()) {
if (notify) attacker.msg(TL.PLAYER_PVP_CANTHURT, defender.describeTo(attacker));
return false;
}
@ -490,23 +442,10 @@ public class FactionsEntityListener implements Listener {
}
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;
}
@EventHandler(priority = EventPriority.NORMAL, ignoreCancelled = true)
public void onCreatureSpawn(CreatureSpawnEvent event) {
if (event.getLocation() == null) return;
@ -557,14 +496,10 @@ public class FactionsEntityListener implements Listener {
@EventHandler
public void onHangerBreak(HangingBreakByEntityEvent e) {
if (e.getRemover() == null) return;
if (!(e.getRemover() instanceof Player)) return;
Player p = (Player) e.getRemover();
if (e.getEntity().getType().equals(EntityType.PAINTING)) {
if (!FactionsBlockListener.playerCanBuildDestroyBlock(p, e.getEntity().getLocation(), "destroy", false)) {
e.setCancelled(true);
}
} else if (e.getEntity().getType().equals(EntityType.ITEM_FRAME)) {
if (e.getEntity().getType() == EntityType.PAINTING || e.getEntity().getType() == EntityType.ITEM_FRAME) {
if (!FactionsBlockListener.playerCanBuildDestroyBlock(p, e.getEntity().getLocation(), "destroy", false)) {
e.setCancelled(true);
}
@ -572,48 +507,38 @@ public class FactionsEntityListener implements Listener {
}
@EventHandler(priority = EventPriority.NORMAL, ignoreCancelled = true)
public void onPaintingPlace(HangingPlaceEvent event) {
if (event.getEntity().getType().equals(EntityType.PAINTING)) {
if (!FactionsBlockListener.playerCanBuildDestroyBlock(event.getPlayer(), event.getBlock().getLocation(), "build", false)) {
event.setCancelled(true);
// Fix: update player's inventory to avoid items glitches
event.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();
public void onPaintingPlace(HangingPlaceEvent e) {
if (e.getPlayer() == null) return;
if (e.getEntity().getType() == EntityType.PAINTING || e.getEntity().getType() == EntityType.ITEM_FRAME) {
if (!FactionsBlockListener.playerCanBuildDestroyBlock(e.getPlayer(), e.getBlock().getLocation(), "build", false)) {
e.setCancelled(true);
e.getPlayer().updateInventory();
}
}
}
@EventHandler(priority = EventPriority.NORMAL, ignoreCancelled = true)
public void onEntityChangeBlock(EntityChangeBlockEvent event) {
Entity entity = event.getEntity();
public void onEntityChangeBlock(EntityChangeBlockEvent e) {
Entity entity = e.getEntity();
Location loc = e.getBlock().getLocation();
// for now, only interested in Enderman and Wither boss tomfoolery
if (!(entity instanceof Enderman) && !(entity instanceof Wither)) return;
Location loc = event.getBlock().getLocation();
if (entity instanceof Enderman) {
if (stopEndermanBlockManipulation(loc)) {
event.setCancelled(true);
}
} else if (entity instanceof Wither) {
if (entity.getType() == EntityType.ENDERMAN) {
if (stopEndermanBlockManipulation(loc)) e.setCancelled(true);
} else if (entity.getType() == EntityType.WITHER) {
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
if ((faction.isWilderness() && Conf.wildernessBlockFireballs && !Conf.worldsNoWildernessProtection.contains(loc.getWorld().getName())) ||
(faction.isNormal() && (faction.hasPlayersOnline() ? Conf.territoryBlockFireballs : Conf.territoryBlockFireballsWhenOffline)) ||
(faction.isWarZone() && Conf.warZoneBlockFireballs) ||
faction.isSafeZone()) {
event.setCancelled(true);
e.setCancelled(true);
}
}
}
/*
@EventHandler
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.Role;
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.XMaterial;
import com.massivecraft.factions.util.wait.WaitExecutor;
import com.massivecraft.factions.zcore.fperms.Access;
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.util.TL;
import com.massivecraft.factions.zcore.util.TagUtil;
@ -571,7 +571,8 @@ public class FactionsPlayerListener implements Listener {
}
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;
me.setFFlying(true, false);
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.FactionsPlugin;
import com.massivecraft.factions.zcore.frame.FactionGUI;
import com.massivecraft.factions.util.XMaterial;
import com.massivecraft.factions.zcore.frame.FactionGUI;
import com.massivecraft.factions.zcore.util.TL;
import org.bukkit.ChatColor;
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 org.bukkit.Bukkit;
import org.bukkit.ChatColor;
import org.bukkit.Material;
import org.bukkit.configuration.ConfigurationSection;
import org.bukkit.enchantments.Enchantment;
import org.bukkit.entity.Item;
import org.bukkit.entity.Player;
import org.bukkit.inventory.ItemFlag;
import org.bukkit.inventory.ItemStack;
@ -22,7 +20,6 @@ import org.bukkit.inventory.meta.ItemMeta;
import java.util.ArrayList;
import java.util.List;
import java.util.Objects;
import java.util.stream.Collectors;
public class ShopGUIFrame {

View File

@ -1,7 +1,6 @@
package com.massivecraft.factions.tag;
import com.massivecraft.factions.FPlayer;
import com.massivecraft.factions.FactionsPlugin;
import com.massivecraft.factions.integration.Econ;
import com.massivecraft.factions.zcore.util.TL;
import org.apache.commons.lang.time.DurationFormatUtils;
@ -16,13 +15,6 @@ public enum PlayerTag implements Tag {
/**
* @author FactionsUUID Team
*/
GROUP("{group}", (fp) -> {
if (fp.isOnline()) {
return FactionsPlugin.getInstance().getPrimaryGroup(fp.getPlayer());
} else {
return "";
}
}),
LAST_SEEN("{lastSeen}", (fp) -> {
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);

View File

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

View File

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

View File

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

View File

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

View File

@ -817,7 +817,7 @@ public abstract class MemoryFPlayer implements FPlayer {
if (myFaction.isNormal() && !perm && myFaction.getFPlayers().isEmpty()) {
// Remove this faction
if(FactionsPlugin.getInstance().getConfig().getBoolean("faction-disband-broadcast")) {
if (FactionsPlugin.getInstance().getConfig().getBoolean("faction-disband-broadcast")) {
for (FPlayer fplayer : FPlayers.getInstance().getOnlinePlayers())
fplayer.msg(TL.LEAVE_DISBANDED, myFaction.describeTo(fplayer, true));
}
@ -846,14 +846,14 @@ public abstract class MemoryFPlayer implements FPlayer {
Faction currentFaction = Board.getInstance().getFactionAt(flocation);
int ownedLand = forFaction.getLandRounded();
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()) {
// Checks for WorldGuard regions in the chunk attempting to be claimed
error = FactionsPlugin.getInstance().txt.parse(TL.CLAIM_PROTECTED.toString());
} else if (flocation.isOutsideWorldBorder(FactionsPlugin.getInstance().getConfig().getInt("world-border.buffer", 0))) {
} else if (flocation.isOutsideWorldBorder(FactionsPlugin.getInstance().getConfig().getInt("world-border.buffer", 0) - 1)) {
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());
} else if (this.isAdminBypassing()) {
return true;
@ -863,14 +863,10 @@ public abstract class MemoryFPlayer implements FPlayer {
return true;
} else if (currentFaction.getAccess(this, PermissableAction.TERRITORY) == Access.ALLOW) {
return true;
} else if (currentFaction.isWilderness() && forFaction.getAccess(this, PermissableAction.TERRITORY) == Access.ALLOW) {
return true;
} else if (myFaction != forFaction) {
error = FactionsPlugin.getInstance().txt.parse(TL.CLAIM_CANTCLAIM.toString(), forFaction.describeTo(this));
} else if (forFaction == currentFaction) {
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) {
error = FactionsPlugin.getInstance().txt.parse(TL.CLAIM_MEMBERS.toString(), Conf.claimsRequireMinFactionMembers);
} else if (currentFaction.isSafeZone()) {
@ -914,7 +910,9 @@ public abstract class MemoryFPlayer implements FPlayer {
}
// TODO: Add more else if statements.
if (notifyFailure && error != null) msg(error);
if (notifyFailure && error != null) {
msg(error);
}
return error == null;
}
@ -973,7 +971,8 @@ public abstract class MemoryFPlayer implements FPlayer {
if (!damage) {
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 {
msg(TL.COMMAND_FLY_DAMAGE);
}
@ -1216,10 +1215,14 @@ public abstract class MemoryFPlayer implements FPlayer {
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
// return value is false on failure, true on success
Faction currentFaction = Board.getInstance().getFactionAt(flocation);
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
boolean mustPay = Econ.shouldBeUsed() && !this.isAdminBypassing() && !forFaction.isSafeZone() && !forFaction.isWarZone() && (Conf.econCostClaimWilderness != 0);
double cost = 0.0;
@ -1238,21 +1241,38 @@ public abstract class MemoryFPlayer implements FPlayer {
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);
Bukkit.getPluginManager().callEvent(claimEvent);
if (claimEvent.isCancelled()) return false;
if (claimEvent.isCancelled()) {
return false;
}
// 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;
}
// Was an over claim
if (mustPay && currentFaction.isNormal() && currentFaction.hasLandInflation())
if (currentFaction.isNormal() && currentFaction.hasLandInflation()) {
// Give them money for over claiming.
Econ.modifyMoney(payee, Conf.econOverclaimRewardMultiplier, TL.CLAIM_TOOVERCLAIM.toString(), TL.CLAIM_FOROVERCLAIM.toString());
}
// announce success
@ -1260,14 +1280,15 @@ public abstract class MemoryFPlayer implements FPlayer {
informTheseFPlayers.add(this);
informTheseFPlayers.addAll(forFaction.getFPlayersWhereOnline(true));
for (FPlayer fp : informTheseFPlayers) {
if (!fp.hasNotificationsEnabled()) continue;
fp.msg(TL.CLAIM_CLAIMED, this.describeTo(fp, true), forFaction.describeTo(fp), currentFaction.describeTo(fp));
}
Board.getInstance().setFactionAt(forFaction, flocation);
if (Conf.logLandClaims)
if (Conf.logLandClaims) {
FactionsPlugin.getInstance().log(TL.CLAIM_CLAIMEDLOG.toString(), this.getName(), flocation.getCoordString(), forFaction.getTag());
}
return true;
}

View File

@ -1110,6 +1110,7 @@ public enum TL {
GENERIC_NOFACTION_FOUND("&cCouldn't find a faction with that name!"),
GENERIC_YOUMUSTBE("&cYour must be atleast %1$s 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_MISSION_STARTED("&f%1$s &dstarted the %2$s &fmission"),

View File

@ -134,7 +134,7 @@ public enum TagReplacer {
}
return TL.GENERIC_INFINITY.toString();
case MAX_ALTS:
if(FactionsPlugin.getInstance().getConfig().getBoolean("f-alts.Enabled")){
if (FactionsPlugin.getInstance().getConfig().getBoolean("f-alts.Enabled")) {
return String.valueOf(Conf.factionAltMemberLimit);
}
return TL.GENERIC_INFINITY.toString();