Skip to content
This repository has been archived by the owner on Jul 7, 2023. It is now read-only.

Commit

Permalink
Merge remote-tracking branch 'origin/1.6.x' into 1.6.x
Browse files Browse the repository at this point in the history
  • Loading branch information
prosavage committed Sep 30, 2018
2 parents 11f7b75 + 2afae3a commit a28fe04
Show file tree
Hide file tree
Showing 16 changed files with 216 additions and 38 deletions.
2 changes: 2 additions & 0 deletions src/main/java/com/massivecraft/factions/Conf.java
Original file line number Diff line number Diff line change
Expand Up @@ -371,6 +371,7 @@ public class Conf {
territoryDenyUseageMaterials.add(Material.BUCKET);
territoryDenyUseageMaterials.add(Material.WATER_BUCKET);
territoryDenyUseageMaterials.add(Material.LAVA_BUCKET);
territoryDenyUseageMaterials.add(Material.ARMOR_STAND);

territoryProtectedMaterialsWhenOffline.add(P.p.WOODEN_DOOR);
territoryProtectedMaterialsWhenOffline.add(P.p.TRAP_DOOR);
Expand All @@ -397,6 +398,7 @@ public class Conf {
territoryDenyUseageMaterialsWhenOffline.add(Material.BUCKET);
territoryDenyUseageMaterialsWhenOffline.add(Material.WATER_BUCKET);
territoryDenyUseageMaterialsWhenOffline.add(Material.LAVA_BUCKET);
territoryDenyUseageMaterialsWhenOffline.add(Material.ARMOR_STAND);

safeZoneNerfedCreatureTypes.add(EntityType.BLAZE);
safeZoneNerfedCreatureTypes.add(EntityType.CAVE_SPIDER);
Expand Down
4 changes: 4 additions & 0 deletions src/main/java/com/massivecraft/factions/FLocation.java
Original file line number Diff line number Diff line change
Expand Up @@ -99,6 +99,10 @@ public static int regionToChunk(int regionVal) {
return regionVal << 5; // "<< 5" == "* 32"
}

public Chunk getChunk(){
return Bukkit.getWorld(worldName).getChunkAt(x, z);
}

public static HashSet<FLocation> getArea(FLocation from, FLocation to) {
HashSet<FLocation> ret = new HashSet<>();

Expand Down
4 changes: 4 additions & 0 deletions src/main/java/com/massivecraft/factions/Faction.java
Original file line number Diff line number Diff line change
Expand Up @@ -326,4 +326,8 @@ public interface Faction extends EconomyParticipator {
void remove();

Set<FLocation> getAllClaims();

String getPaypal();

void paypalSet(String paypal);
}
3 changes: 3 additions & 0 deletions src/main/java/com/massivecraft/factions/cmd/CmdCreate.java
Original file line number Diff line number Diff line change
Expand Up @@ -100,6 +100,9 @@ public void perform() {
if (Conf.logFactionCreate) {
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
Expand Down
12 changes: 6 additions & 6 deletions src/main/java/com/massivecraft/factions/cmd/CmdFly.java
Original file line number Diff line number Diff line change
Expand Up @@ -193,19 +193,19 @@ public void perform() {
FLocation myfloc = new FLocation(me.getLocation());
Faction toFac = Board.getInstance().getFactionAt(myfloc);
if (!checkBypassPerms(fme, me, toFac)) return;
List<Entity> entities = me.getNearbyEntities(16, 256, 16);
for (int i = 0; i <= entities.size() - 1; i++) {
List<Entity> entities = this.me.getNearbyEntities(16.0D, 256.0D, 16.0D);

for(int i = 0; i <= entities.size() - 1; ++i) {
if (entities.get(i) instanceof Player) {
Player eplayer = (Player) entities.get(i);
Player eplayer = (Player)entities.get(i);
FPlayer efplayer = FPlayers.getInstance().getByPlayer(eplayer);
if (efplayer.getRelationTo(fme) == Relation.ENEMY && !efplayer.isStealthEnabled()) {
fme.msg(TL.COMMAND_FLY_CHECK_ENEMY);
if (efplayer.getRelationTo(this.fme) == Relation.ENEMY && !efplayer.isStealthEnabled()) {
this.fme.msg(TL.COMMAND_FLY_CHECK_ENEMY);
return;
}
}
}


if (args.size() == 0) {
toggleFlight(!fme.isFlying(), me);
} else if (args.size() == 1) {
Expand Down
50 changes: 50 additions & 0 deletions src/main/java/com/massivecraft/factions/cmd/CmdPaypalSee.java
Original file line number Diff line number Diff line change
@@ -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;
}
}


38 changes: 38 additions & 0 deletions src/main/java/com/massivecraft/factions/cmd/CmdPaypalSet.java
Original file line number Diff line number Diff line change
@@ -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;
}
}

34 changes: 5 additions & 29 deletions src/main/java/com/massivecraft/factions/cmd/CmdStealth.java
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
package com.massivecraft.factions.cmd;

import com.massivecraft.factions.Faction;
import com.massivecraft.factions.P;
import com.massivecraft.factions.integration.Econ;
import com.massivecraft.factions.struct.Permission;
Expand All @@ -22,41 +23,16 @@ public CmdStealth() {
}

public void perform() {
if (myFaction != null && !myFaction.isWilderness() && !myFaction.isSafeZone() && !myFaction.isWarZone() && myFaction.isNormal()) {


// Sends Enable/Disable Message
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());
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());
fme.msg(fme.isStealthEnabled() ? TL.COMMAND_STEALTH_ENABLE : TL.COMMAND_STEALTH_DISABLE);
} else {
fme.msg(TL.COMMAND_STEALTH_MUSTBEMEMBER);
}
}

@Override
public TL getUsageTranslation() {
return TL.COMMAND_STEALTH_DESCRIPTION;
}

}
6 changes: 6 additions & 0 deletions src/main/java/com/massivecraft/factions/cmd/FCmdRoot.java
Original file line number Diff line number Diff line change
Expand Up @@ -63,6 +63,8 @@ public class FCmdRoot extends FCommand {
public CmdSB cmdSB = new CmdSB();
public CmdShowInvites cmdShowInvites = new CmdShowInvites();
public CmdAnnounce cmdAnnounce = new CmdAnnounce();
public CmdPaypalSet cmdPaypalSet = new CmdPaypalSet();
public CmdPaypalSee cmdPaypalSee = new CmdPaypalSee();
public CmdSeeChunk cmdSeeChunk = new CmdSeeChunk();
public CmdConvert cmdConvert = new CmdConvert();
public CmdFWarp cmdFWarp = new CmdFWarp();
Expand Down Expand Up @@ -231,6 +233,10 @@ public FCmdRoot() {
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);
}
if (P.p.getConfig().getBoolean("fpaypal.Enabled")) {
this.addSubCommand(this.cmdPaypalSet);
this.addSubCommand(this.cmdPaypalSee);
}

}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,8 @@
import org.bukkit.event.hanging.HangingBreakEvent;
import org.bukkit.event.hanging.HangingBreakEvent.RemoveCause;
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.potion.PotionEffect;
import org.bukkit.potion.PotionEffectType;
Expand Down Expand Up @@ -132,6 +134,39 @@ public void onEntityDamage(EntityDamageEvent event) {
}
}
} 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
if (damager instanceof Player) {
// now itll only go here if the damage is dealt by a player
Expand Down Expand Up @@ -582,6 +617,8 @@ public void onPaintingBreak(HangingBreakEvent event) {
public void onPaintingPlace(HangingPlaceEvent event) {
if (!FactionsBlockListener.playerCanBuildDestroyBlock(event.getPlayer(), event.getBlock().getLocation(), "place paintings", false)) {
event.setCancelled(true);
// Fix: update player's inventory to avoid items glitches
event.getPlayer().updateInventory();
}
}

Expand Down Expand Up @@ -680,6 +717,37 @@ public void onBowHit(EntityDamageByEntityEvent e) {
}
}

// 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) {
if (loc == null) {
return false;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -64,6 +64,7 @@ public enum Permission {
SET_PERMANENT("setpermanent"),
SET_PERMANENTPOWER("setpermanentpower"),
SHOW_INVITES("showinvites"),
PAYPALSET("setpaypal"),
PERMISSIONS("permissions"),
POWERBOOST("powerboost"),
POWER("power"),
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -1046,9 +1046,9 @@ public boolean checkIfNearbyEnemies(){
if (eplayer == null) { continue; }
FPlayer efplayer = FPlayers.getInstance().getByPlayer(eplayer);
if (efplayer == null) { continue; }
if (Conf.allowedStealthFactions != null && !efplayer.isStealthEnabled()) {
this.setFlying(false);
this.msg(TL.COMMAND_FLY_ENEMY_NEAR);
if (efplayer != null && this.getRelationTo(efplayer).equals(Relation.ENEMY) && !efplayer.isStealthEnabled()) {
setFlying(false);
msg(TL.COMMAND_FLY_ENEMY_NEAR);
Bukkit.getServer().getPluginManager().callEvent(new FPlayerStoppedFlying(this));
return true;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -51,6 +51,7 @@ public abstract class MemoryFaction implements Faction, EconomyParticipator {
protected transient long lastPlayerLoggedOffTime;
protected double money;
protected double powerBoost;
protected String paypal;
protected Map<String, Relation> relationWish = new HashMap<>();
protected Map<FLocation, Set<String>> claimOwnership = new ConcurrentHashMap<>();
protected transient Set<FPlayer> fplayers = new HashSet<>();
Expand Down Expand Up @@ -164,6 +165,13 @@ public boolean removeWarp(String name) {
public boolean isWarpPassword(String warp, String 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) {
return warpPasswords.containsKey(warp.toLowerCase());
Expand Down
8 changes: 8 additions & 0 deletions src/main/java/com/massivecraft/factions/zcore/util/TL.java
Original file line number Diff line number Diff line change
Expand Up @@ -470,6 +470,14 @@ public enum TL {
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_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_YOURS("&c&l[!]&7%1$s has %2$s your faction"),
COMMAND_PEACEFUL_OTHER("&c&l[!]&7%s has %s the faction '%s<i>'."),
Expand Down
Loading

0 comments on commit a28fe04

Please sign in to comment.