Merge remote-tracking branch 'origin/1.6.x' into 1.6.x

This commit is contained in:
ProSavage 2018-09-30 15:49:41 -05:00
commit a28fe04b8a
16 changed files with 216 additions and 38 deletions

View File

@ -371,6 +371,7 @@ public class Conf {
territoryDenyUseageMaterials.add(Material.BUCKET); territoryDenyUseageMaterials.add(Material.BUCKET);
territoryDenyUseageMaterials.add(Material.WATER_BUCKET); territoryDenyUseageMaterials.add(Material.WATER_BUCKET);
territoryDenyUseageMaterials.add(Material.LAVA_BUCKET); territoryDenyUseageMaterials.add(Material.LAVA_BUCKET);
territoryDenyUseageMaterials.add(Material.ARMOR_STAND);
territoryProtectedMaterialsWhenOffline.add(P.p.WOODEN_DOOR); territoryProtectedMaterialsWhenOffline.add(P.p.WOODEN_DOOR);
territoryProtectedMaterialsWhenOffline.add(P.p.TRAP_DOOR); territoryProtectedMaterialsWhenOffline.add(P.p.TRAP_DOOR);
@ -397,6 +398,7 @@ public class Conf {
territoryDenyUseageMaterialsWhenOffline.add(Material.BUCKET); territoryDenyUseageMaterialsWhenOffline.add(Material.BUCKET);
territoryDenyUseageMaterialsWhenOffline.add(Material.WATER_BUCKET); territoryDenyUseageMaterialsWhenOffline.add(Material.WATER_BUCKET);
territoryDenyUseageMaterialsWhenOffline.add(Material.LAVA_BUCKET); territoryDenyUseageMaterialsWhenOffline.add(Material.LAVA_BUCKET);
territoryDenyUseageMaterialsWhenOffline.add(Material.ARMOR_STAND);
safeZoneNerfedCreatureTypes.add(EntityType.BLAZE); safeZoneNerfedCreatureTypes.add(EntityType.BLAZE);
safeZoneNerfedCreatureTypes.add(EntityType.CAVE_SPIDER); safeZoneNerfedCreatureTypes.add(EntityType.CAVE_SPIDER);

View File

@ -99,6 +99,10 @@ public class FLocation implements Serializable {
return regionVal << 5; // "<< 5" == "* 32" return regionVal << 5; // "<< 5" == "* 32"
} }
public Chunk getChunk(){
return Bukkit.getWorld(worldName).getChunkAt(x, z);
}
public static HashSet<FLocation> getArea(FLocation from, FLocation to) { public static HashSet<FLocation> getArea(FLocation from, FLocation to) {
HashSet<FLocation> ret = new HashSet<>(); HashSet<FLocation> ret = new HashSet<>();

View File

@ -326,4 +326,8 @@ public interface Faction extends EconomyParticipator {
void remove(); void remove();
Set<FLocation> getAllClaims(); Set<FLocation> getAllClaims();
String getPaypal();
void paypalSet(String paypal);
} }

View File

@ -100,6 +100,9 @@ public class CmdCreate extends FCommand {
if (Conf.logFactionCreate) { if (Conf.logFactionCreate) {
P.p.log(fme.getName() + TL.COMMAND_CREATE_CREATEDLOG.toString() + tag); P.p.log(fme.getName() + TL.COMMAND_CREATE_CREATEDLOG.toString() + tag);
} }
if (P.p.getConfig().getBoolean("fpaypal.Enabled")) {
this.fme.msg(TL.COMMAND_PAYPALSET_CREATED);
}
} }
@Override @Override

View File

@ -193,19 +193,19 @@ public class CmdFly extends FCommand {
FLocation myfloc = new FLocation(me.getLocation()); FLocation myfloc = new FLocation(me.getLocation());
Faction toFac = Board.getInstance().getFactionAt(myfloc); Faction toFac = Board.getInstance().getFactionAt(myfloc);
if (!checkBypassPerms(fme, me, toFac)) return; if (!checkBypassPerms(fme, me, toFac)) return;
List<Entity> entities = me.getNearbyEntities(16, 256, 16); List<Entity> entities = this.me.getNearbyEntities(16.0D, 256.0D, 16.0D);
for (int i = 0; i <= entities.size() - 1; i++) {
for(int i = 0; i <= entities.size() - 1; ++i) {
if (entities.get(i) instanceof Player) { if (entities.get(i) instanceof Player) {
Player eplayer = (Player) entities.get(i); Player eplayer = (Player)entities.get(i);
FPlayer efplayer = FPlayers.getInstance().getByPlayer(eplayer); FPlayer efplayer = FPlayers.getInstance().getByPlayer(eplayer);
if (efplayer.getRelationTo(fme) == Relation.ENEMY && !efplayer.isStealthEnabled()) { if (efplayer.getRelationTo(this.fme) == Relation.ENEMY && !efplayer.isStealthEnabled()) {
fme.msg(TL.COMMAND_FLY_CHECK_ENEMY); this.fme.msg(TL.COMMAND_FLY_CHECK_ENEMY);
return; return;
} }
} }
} }
if (args.size() == 0) { if (args.size() == 0) {
toggleFlight(!fme.isFlying(), me); toggleFlight(!fme.isFlying(), me);
} else if (args.size() == 1) { } else if (args.size() == 1) {

View File

@ -0,0 +1,50 @@
package com.massivecraft.factions.cmd;
import com.massivecraft.factions.Faction;
import com.massivecraft.factions.P;
import com.massivecraft.factions.struct.Permission;
import com.massivecraft.factions.zcore.util.TL;
import org.bukkit.ChatColor;
public class CmdPaypalSee extends FCommand{
public CmdPaypalSee() {
aliases.add("seepaypal");
aliases.add("getpaypal");
requiredArgs.add("faction");
permission = Permission.ADMIN.node;
disableOnLock = false;
senderMustBePlayer = false;
senderMustBeMember = false;
senderMustBeModerator = false;
senderMustBeColeader = false;
senderMustBeAdmin = false;
}
public void perform() {
if (!P.p.getConfig().getBoolean("fpaypal.Enabled")) {
fme.msg(TL.GENERIC_DISABLED);
} else {
Faction faction = argAsFaction(0);
String paypal = argAsString(1);
if (faction != null) {
if (!faction.isWilderness() && !faction.isSafeZone() && !faction.isWarZone()) {
if (faction.getPaypal() != null) {
fme.msg(TL.COMMAND_PAYPALSEE_FACTION_PAYPAL.toString(), faction.getTag(), faction.getPaypal());
} else {
fme.msg(TL.COMMAND_PAYPALSEE_FACTION_NOTSET.toString(), faction.getTag(), faction.getPaypal());
}
} else {
fme.msg(TL.COMMAND_PAYPALSEE_FACTION_NOFACTION.toString(), me.getName());
}
}
}
}
public TL getUsageTranslation() {
return TL.COMMAND_PAYPALSEE_DESCRIPTION;
}
}

View File

@ -0,0 +1,38 @@
package com.massivecraft.factions.cmd;
import com.massivecraft.factions.P;
import com.massivecraft.factions.struct.Permission;
import com.massivecraft.factions.zcore.util.TL;
public class CmdPaypalSet extends FCommand{
public CmdPaypalSet() {
this.aliases.add("setpaypal");
this.aliases.add("paypal");
this.requiredArgs.add("email");
this.permission = Permission.PAYPALSET.node;
this.disableOnLock = false;
this.senderMustBePlayer = true;
this.senderMustBeMember = false;
this.senderMustBeModerator = false;
this.senderMustBeColeader = true;
this.senderMustBeAdmin = false;
}
public void perform() {
if (!P.p.getConfig().getBoolean("fpaypal.Enabled")) {
fme.msg(TL.GENERIC_DISABLED);
} else {
String paypal = argAsString(0);
if (paypal != null) {
myFaction.paypalSet(paypal);
fme.msg(TL.COMMAND_PAYPALSET_SUCCESSFUL, paypal);
}
}
}
public TL getUsageTranslation() {
return TL.COMMAND_PAYPALSET_DESCRIPTION;
}
}

View File

@ -1,5 +1,6 @@
package com.massivecraft.factions.cmd; package com.massivecraft.factions.cmd;
import com.massivecraft.factions.Faction;
import com.massivecraft.factions.P; import com.massivecraft.factions.P;
import com.massivecraft.factions.integration.Econ; import com.massivecraft.factions.integration.Econ;
import com.massivecraft.factions.struct.Permission; import com.massivecraft.factions.struct.Permission;
@ -22,41 +23,16 @@ public class CmdStealth extends FCommand {
} }
public void perform() { public void perform() {
if (myFaction != null && !myFaction.isWilderness() && !myFaction.isSafeZone() && !myFaction.isWarZone() && myFaction.isNormal()) { Faction faction = fme.getFaction();
if (faction != null && !faction.getId().equalsIgnoreCase("0") && !faction.getId().equalsIgnoreCase("none") && !faction.getId().equalsIgnoreCase("safezone") && !faction.getId().equalsIgnoreCase("warzone")) {
fme.setStealth(!fme.isStealthEnabled());
// Sends Enable/Disable Message fme.msg(fme.isStealthEnabled() ? TL.COMMAND_STEALTH_ENABLE : TL.COMMAND_STEALTH_DISABLE);
if (fme.isStealthEnabled()) {
fme.setStealth(false);
} else {
/* The FPlayer#takeMoney method calls the FPlayer#hasMoney method beforehand to check if the amount
* can be withdrawn successfully.
* The FPlayer#hasMoney method already sends a deny message so there isn't a need to send another.
* Basically the takeMoney is an all in one solution for taking money :)
*/
fme.takeMoney(P.p.getConfig().getInt("stealth-cost"));
fme.setStealth(true);
Bukkit.getScheduler().scheduleSyncDelayedTask(P.p, new Runnable() {
@Override
public void run() {
if (fme.isStealthEnabled()) {
fme.setStealth(false);
fme.msg(TL.COMMAND_STEALTH_DISABLE);
}
}
// We multiplied by 20 here because the value is in ticks.
}, P.p.getConfig().getInt("stealth-timeout") * 20);
}
fme.sendMessage(fme.isStealthEnabled() ? TL.COMMAND_STEALTH_ENABLE.toString().replace("{timeout}", P.p.getConfig().getInt("stealth-timeout") + "") : TL.COMMAND_STEALTH_DISABLE.toString());
} else { } else {
fme.msg(TL.COMMAND_STEALTH_MUSTBEMEMBER); fme.msg(TL.COMMAND_STEALTH_MUSTBEMEMBER);
} }
} }
@Override
public TL getUsageTranslation() { public TL getUsageTranslation() {
return TL.COMMAND_STEALTH_DESCRIPTION; return TL.COMMAND_STEALTH_DESCRIPTION;
} }
} }

View File

@ -63,6 +63,8 @@ public class FCmdRoot extends FCommand {
public CmdSB cmdSB = new CmdSB(); public CmdSB cmdSB = new CmdSB();
public CmdShowInvites cmdShowInvites = new CmdShowInvites(); public CmdShowInvites cmdShowInvites = new CmdShowInvites();
public CmdAnnounce cmdAnnounce = new CmdAnnounce(); public CmdAnnounce cmdAnnounce = new CmdAnnounce();
public CmdPaypalSet cmdPaypalSet = new CmdPaypalSet();
public CmdPaypalSee cmdPaypalSee = new CmdPaypalSee();
public CmdSeeChunk cmdSeeChunk = new CmdSeeChunk(); public CmdSeeChunk cmdSeeChunk = new CmdSeeChunk();
public CmdConvert cmdConvert = new CmdConvert(); public CmdConvert cmdConvert = new CmdConvert();
public CmdFWarp cmdFWarp = new CmdFWarp(); public CmdFWarp cmdFWarp = new CmdFWarp();
@ -231,6 +233,10 @@ public class FCmdRoot extends FCommand {
P.p.log(Level.INFO, "Enabling FactionsTop command, this is a very basic /f top please get a dedicated /f top resource if you want land calculation etc."); P.p.log(Level.INFO, "Enabling FactionsTop command, this is a very basic /f top please get a dedicated /f top resource if you want land calculation etc.");
this.addSubCommand(this.cmdTop); this.addSubCommand(this.cmdTop);
} }
if (P.p.getConfig().getBoolean("fpaypal.Enabled")) {
this.addSubCommand(this.cmdPaypalSet);
this.addSubCommand(this.cmdPaypalSee);
}
} }

View File

@ -19,6 +19,8 @@ import org.bukkit.event.hanging.HangingBreakByEntityEvent;
import org.bukkit.event.hanging.HangingBreakEvent; import org.bukkit.event.hanging.HangingBreakEvent;
import org.bukkit.event.hanging.HangingBreakEvent.RemoveCause; import org.bukkit.event.hanging.HangingBreakEvent.RemoveCause;
import org.bukkit.event.hanging.HangingPlaceEvent; import org.bukkit.event.hanging.HangingPlaceEvent;
import org.bukkit.event.player.PlayerInteractAtEntityEvent;
import org.bukkit.event.player.PlayerInteractEntityEvent;
import org.bukkit.event.player.PlayerPortalEvent; import org.bukkit.event.player.PlayerPortalEvent;
import org.bukkit.potion.PotionEffect; import org.bukkit.potion.PotionEffect;
import org.bukkit.potion.PotionEffectType; import org.bukkit.potion.PotionEffectType;
@ -132,6 +134,39 @@ public class FactionsEntityListener implements Listener {
} }
} }
} else { } else {
// Protect armor stands/item frames from being damaged in protected territories
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();
}
// Run the check for a player
if (damager instanceof Player) {
// Generate the action message.
String entityAction;
if (damagee.getType() == EntityType.ITEM_FRAME) {
entityAction = "item frames";
} else {
entityAction = "armor stands";
}
if (!FactionsBlockListener.playerCanBuildDestroyBlock((Player) damager, damagee.getLocation(), "destroy " + entityAction, 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())) {
event.setCancelled(true);
}
}
// we don't need to go after
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) {
// now itll only go here if the damage is dealt by a player // now itll only go here if the damage is dealt by a player
@ -582,6 +617,8 @@ public class FactionsEntityListener implements Listener {
public void onPaintingPlace(HangingPlaceEvent event) { public void onPaintingPlace(HangingPlaceEvent event) {
if (!FactionsBlockListener.playerCanBuildDestroyBlock(event.getPlayer(), event.getBlock().getLocation(), "place paintings", false)) { if (!FactionsBlockListener.playerCanBuildDestroyBlock(event.getPlayer(), event.getBlock().getLocation(), "place paintings", false)) {
event.setCancelled(true); event.setCancelled(true);
// Fix: update player's inventory to avoid items glitches
event.getPlayer().updateInventory();
} }
} }
@ -680,6 +717,37 @@ public class FactionsEntityListener implements Listener {
} }
} }
// For disabling interactions with item frames in another faction's territory
@EventHandler(priority = EventPriority.NORMAL, ignoreCancelled = true)
public void onPlayerInteractEntity(PlayerInteractEntityEvent event) {
// only need to check for item frames
if (event.getRightClicked().getType() != EntityType.ITEM_FRAME) {
return;
}
Player player = event.getPlayer();
Entity entity = event.getRightClicked();
if (!FactionsBlockListener.playerCanBuildDestroyBlock(player, entity.getLocation(), "use item frames", false)) {
event.setCancelled(true);
}
}
// For disabling interactions with armor stands in another faction's territory
@EventHandler(priority = EventPriority.NORMAL, ignoreCancelled = true)
public void onPlayerInteractAtEntity(PlayerInteractAtEntityEvent event) {
Entity entity = event.getRightClicked();
// only need to check for armor stand and item frames
if (entity.getType() != EntityType.ARMOR_STAND) {
return;
}
if (!FactionsBlockListener.playerCanBuildDestroyBlock(event.getPlayer(), entity.getLocation(), "use armor stands", false)) {
event.setCancelled(true);
}
}
private boolean stopEndermanBlockManipulation(Location loc) { private boolean stopEndermanBlockManipulation(Location loc) {
if (loc == null) { if (loc == null) {
return false; return false;

View File

@ -64,6 +64,7 @@ public enum Permission {
SET_PERMANENT("setpermanent"), SET_PERMANENT("setpermanent"),
SET_PERMANENTPOWER("setpermanentpower"), SET_PERMANENTPOWER("setpermanentpower"),
SHOW_INVITES("showinvites"), SHOW_INVITES("showinvites"),
PAYPALSET("setpaypal"),
PERMISSIONS("permissions"), PERMISSIONS("permissions"),
POWERBOOST("powerboost"), POWERBOOST("powerboost"),
POWER("power"), POWER("power"),

View File

@ -1046,9 +1046,9 @@ public abstract class MemoryFPlayer implements FPlayer {
if (eplayer == null) { continue; } if (eplayer == null) { continue; }
FPlayer efplayer = FPlayers.getInstance().getByPlayer(eplayer); FPlayer efplayer = FPlayers.getInstance().getByPlayer(eplayer);
if (efplayer == null) { continue; } if (efplayer == null) { continue; }
if (Conf.allowedStealthFactions != null && !efplayer.isStealthEnabled()) { if (efplayer != null && this.getRelationTo(efplayer).equals(Relation.ENEMY) && !efplayer.isStealthEnabled()) {
this.setFlying(false); setFlying(false);
this.msg(TL.COMMAND_FLY_ENEMY_NEAR); msg(TL.COMMAND_FLY_ENEMY_NEAR);
Bukkit.getServer().getPluginManager().callEvent(new FPlayerStoppedFlying(this)); Bukkit.getServer().getPluginManager().callEvent(new FPlayerStoppedFlying(this));
return true; return true;
} }

View File

@ -51,6 +51,7 @@ public abstract class MemoryFaction implements Faction, EconomyParticipator {
protected transient long lastPlayerLoggedOffTime; protected transient long lastPlayerLoggedOffTime;
protected double money; protected double money;
protected double powerBoost; protected double powerBoost;
protected String paypal;
protected Map<String, Relation> relationWish = new HashMap<>(); protected Map<String, Relation> relationWish = new HashMap<>();
protected Map<FLocation, Set<String>> claimOwnership = new ConcurrentHashMap<>(); protected Map<FLocation, Set<String>> claimOwnership = new ConcurrentHashMap<>();
protected transient Set<FPlayer> fplayers = new HashSet<>(); protected transient Set<FPlayer> fplayers = new HashSet<>();
@ -164,6 +165,13 @@ public abstract class MemoryFaction implements Faction, EconomyParticipator {
public boolean isWarpPassword(String warp, String password) { public boolean isWarpPassword(String warp, String password) {
return hasWarpPassword(warp) && warpPasswords.get(warp.toLowerCase()).equals(password); return hasWarpPassword(warp) && warpPasswords.get(warp.toLowerCase()).equals(password);
} }
public String getPaypal() {
return this.paypal;
}
public void paypalSet(String paypal) {
this.paypal = paypal;
}
public boolean hasWarpPassword(String warp) { public boolean hasWarpPassword(String warp) {
return warpPasswords.containsKey(warp.toLowerCase()); return warpPasswords.containsKey(warp.toLowerCase());

View File

@ -470,6 +470,14 @@ public enum TL {
COMMAND_OWNERLIST_OWNERS("&c&l[!]&7 Current owner(s) of this land: %1$s"), COMMAND_OWNERLIST_OWNERS("&c&l[!]&7 Current owner(s) of this land: %1$s"),
COMMAND_OWNERLIST_DESCRIPTION("List owner(s) of this claimed land"), COMMAND_OWNERLIST_DESCRIPTION("List owner(s) of this claimed land"),
COMMAND_PAYPALSET_DESCRIPTION("&c&l[!] &7Set the email of your faction to claim rewards."),
COMMAND_PAYPALSEE_DESCRIPTION("&c&l[!] &7View a specific factions paypal email with &b/f <seepaypal/getpaypal> <faction>&b."),
COMMAND_PAYPALSET_CREATED("&c&l[!] &7Make sure to type &b/f <paypal/setpaypal> <email>&7!"),
COMMAND_PAYPALSET_SUCCESSFUL("&c&l[!] &7Successfully set your factions email - &b%1$s&7."),
COMMAND_PAYPALSEE_FACTION_PAYPAL("&c&l[!] &b%1$s's &7faction has their paypal set to &b%2$s&7."),
COMMAND_PAYPALSEE_FACTION_NOTSET("&c&l[!] &b%1$s's &7paypal has not yet been set!"),
COMMAND_PAYPALSEE_FACTION_NOFACTION("&c&l[!] &b%1$s &7does not have a faction!"),
COMMAND_PEACEFUL_DESCRIPTION("&c&l[!]&7Set a faction to peaceful"), COMMAND_PEACEFUL_DESCRIPTION("&c&l[!]&7Set a faction to peaceful"),
COMMAND_PEACEFUL_YOURS("&c&l[!]&7%1$s has %2$s your faction"), COMMAND_PEACEFUL_YOURS("&c&l[!]&7%1$s has %2$s your faction"),
COMMAND_PEACEFUL_OTHER("&c&l[!]&7%s has %s the faction '%s<i>'."), COMMAND_PEACEFUL_OTHER("&c&l[!]&7%s has %s the faction '%s<i>'."),

View File

@ -716,6 +716,14 @@ ftnt:
Enabled: true Enabled: true
Bank-Limit: 10000 Bank-Limit: 10000
############################################################
# +------------------------------------------------------+ #
# | Faction PayPal | #
# +------------------------------------------------------+ #
############################################################
fpaypal:
Enabled: true
############################################################ ############################################################
# +------------------------------------------------------+ # # +------------------------------------------------------+ #
# | Faction Checkpoints | # # | Faction Checkpoints | #

View File

@ -227,6 +227,8 @@ permissions:
description: set permanent power for a faction description: set permanent power for a faction
factions.stuck: factions.stuck:
description: teleports player outside a faction description: teleports player outside a faction
factions.setpaypal:
description: set paypal to faction
factions.power: factions.power:
description: show player power info description: show player power info
factions.power.any: factions.power.any: