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

Commit a28fe04

Browse files
committed
Merge remote-tracking branch 'origin/1.6.x' into 1.6.x
2 parents 11f7b75 + 2afae3a commit a28fe04

16 files changed

+216
-38
lines changed

src/main/java/com/massivecraft/factions/Conf.java

+2
Original file line numberDiff line numberDiff line change
@@ -371,6 +371,7 @@ public class Conf {
371371
territoryDenyUseageMaterials.add(Material.BUCKET);
372372
territoryDenyUseageMaterials.add(Material.WATER_BUCKET);
373373
territoryDenyUseageMaterials.add(Material.LAVA_BUCKET);
374+
territoryDenyUseageMaterials.add(Material.ARMOR_STAND);
374375

375376
territoryProtectedMaterialsWhenOffline.add(P.p.WOODEN_DOOR);
376377
territoryProtectedMaterialsWhenOffline.add(P.p.TRAP_DOOR);
@@ -397,6 +398,7 @@ public class Conf {
397398
territoryDenyUseageMaterialsWhenOffline.add(Material.BUCKET);
398399
territoryDenyUseageMaterialsWhenOffline.add(Material.WATER_BUCKET);
399400
territoryDenyUseageMaterialsWhenOffline.add(Material.LAVA_BUCKET);
401+
territoryDenyUseageMaterialsWhenOffline.add(Material.ARMOR_STAND);
400402

401403
safeZoneNerfedCreatureTypes.add(EntityType.BLAZE);
402404
safeZoneNerfedCreatureTypes.add(EntityType.CAVE_SPIDER);

src/main/java/com/massivecraft/factions/FLocation.java

+4
Original file line numberDiff line numberDiff line change
@@ -99,6 +99,10 @@ public static int regionToChunk(int regionVal) {
9999
return regionVal << 5; // "<< 5" == "* 32"
100100
}
101101

102+
public Chunk getChunk(){
103+
return Bukkit.getWorld(worldName).getChunkAt(x, z);
104+
}
105+
102106
public static HashSet<FLocation> getArea(FLocation from, FLocation to) {
103107
HashSet<FLocation> ret = new HashSet<>();
104108

src/main/java/com/massivecraft/factions/Faction.java

+4
Original file line numberDiff line numberDiff line change
@@ -326,4 +326,8 @@ public interface Faction extends EconomyParticipator {
326326
void remove();
327327

328328
Set<FLocation> getAllClaims();
329+
330+
String getPaypal();
331+
332+
void paypalSet(String paypal);
329333
}

src/main/java/com/massivecraft/factions/cmd/CmdCreate.java

+3
Original file line numberDiff line numberDiff line change
@@ -100,6 +100,9 @@ public void perform() {
100100
if (Conf.logFactionCreate) {
101101
P.p.log(fme.getName() + TL.COMMAND_CREATE_CREATEDLOG.toString() + tag);
102102
}
103+
if (P.p.getConfig().getBoolean("fpaypal.Enabled")) {
104+
this.fme.msg(TL.COMMAND_PAYPALSET_CREATED);
105+
}
103106
}
104107

105108
@Override

src/main/java/com/massivecraft/factions/cmd/CmdFly.java

+6-6
Original file line numberDiff line numberDiff line change
@@ -193,19 +193,19 @@ public void perform() {
193193
FLocation myfloc = new FLocation(me.getLocation());
194194
Faction toFac = Board.getInstance().getFactionAt(myfloc);
195195
if (!checkBypassPerms(fme, me, toFac)) return;
196-
List<Entity> entities = me.getNearbyEntities(16, 256, 16);
197-
for (int i = 0; i <= entities.size() - 1; i++) {
196+
List<Entity> entities = this.me.getNearbyEntities(16.0D, 256.0D, 16.0D);
197+
198+
for(int i = 0; i <= entities.size() - 1; ++i) {
198199
if (entities.get(i) instanceof Player) {
199-
Player eplayer = (Player) entities.get(i);
200+
Player eplayer = (Player)entities.get(i);
200201
FPlayer efplayer = FPlayers.getInstance().getByPlayer(eplayer);
201-
if (efplayer.getRelationTo(fme) == Relation.ENEMY && !efplayer.isStealthEnabled()) {
202-
fme.msg(TL.COMMAND_FLY_CHECK_ENEMY);
202+
if (efplayer.getRelationTo(this.fme) == Relation.ENEMY && !efplayer.isStealthEnabled()) {
203+
this.fme.msg(TL.COMMAND_FLY_CHECK_ENEMY);
203204
return;
204205
}
205206
}
206207
}
207208

208-
209209
if (args.size() == 0) {
210210
toggleFlight(!fme.isFlying(), me);
211211
} else if (args.size() == 1) {
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,50 @@
1+
package com.massivecraft.factions.cmd;
2+
3+
import com.massivecraft.factions.Faction;
4+
import com.massivecraft.factions.P;
5+
import com.massivecraft.factions.struct.Permission;
6+
import com.massivecraft.factions.zcore.util.TL;
7+
import org.bukkit.ChatColor;
8+
9+
public class CmdPaypalSee extends FCommand{
10+
public CmdPaypalSee() {
11+
aliases.add("seepaypal");
12+
aliases.add("getpaypal");
13+
requiredArgs.add("faction");
14+
permission = Permission.ADMIN.node;
15+
disableOnLock = false;
16+
senderMustBePlayer = false;
17+
senderMustBeMember = false;
18+
senderMustBeModerator = false;
19+
senderMustBeColeader = false;
20+
senderMustBeAdmin = false;
21+
}
22+
23+
public void perform() {
24+
if (!P.p.getConfig().getBoolean("fpaypal.Enabled")) {
25+
fme.msg(TL.GENERIC_DISABLED);
26+
} else {
27+
Faction faction = argAsFaction(0);
28+
String paypal = argAsString(1);
29+
30+
if (faction != null) {
31+
if (!faction.isWilderness() && !faction.isSafeZone() && !faction.isWarZone()) {
32+
if (faction.getPaypal() != null) {
33+
fme.msg(TL.COMMAND_PAYPALSEE_FACTION_PAYPAL.toString(), faction.getTag(), faction.getPaypal());
34+
} else {
35+
fme.msg(TL.COMMAND_PAYPALSEE_FACTION_NOTSET.toString(), faction.getTag(), faction.getPaypal());
36+
}
37+
38+
} else {
39+
fme.msg(TL.COMMAND_PAYPALSEE_FACTION_NOFACTION.toString(), me.getName());
40+
}
41+
}
42+
}
43+
}
44+
45+
public TL getUsageTranslation() {
46+
return TL.COMMAND_PAYPALSEE_DESCRIPTION;
47+
}
48+
}
49+
50+
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,38 @@
1+
package com.massivecraft.factions.cmd;
2+
3+
import com.massivecraft.factions.P;
4+
import com.massivecraft.factions.struct.Permission;
5+
import com.massivecraft.factions.zcore.util.TL;
6+
7+
public class CmdPaypalSet extends FCommand{
8+
9+
public CmdPaypalSet() {
10+
this.aliases.add("setpaypal");
11+
this.aliases.add("paypal");
12+
this.requiredArgs.add("email");
13+
this.permission = Permission.PAYPALSET.node;
14+
this.disableOnLock = false;
15+
this.senderMustBePlayer = true;
16+
this.senderMustBeMember = false;
17+
this.senderMustBeModerator = false;
18+
this.senderMustBeColeader = true;
19+
this.senderMustBeAdmin = false;
20+
}
21+
22+
public void perform() {
23+
if (!P.p.getConfig().getBoolean("fpaypal.Enabled")) {
24+
fme.msg(TL.GENERIC_DISABLED);
25+
} else {
26+
String paypal = argAsString(0);
27+
if (paypal != null) {
28+
myFaction.paypalSet(paypal);
29+
fme.msg(TL.COMMAND_PAYPALSET_SUCCESSFUL, paypal);
30+
}
31+
}
32+
}
33+
34+
public TL getUsageTranslation() {
35+
return TL.COMMAND_PAYPALSET_DESCRIPTION;
36+
}
37+
}
38+
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
package com.massivecraft.factions.cmd;
22

3+
import com.massivecraft.factions.Faction;
34
import com.massivecraft.factions.P;
45
import com.massivecraft.factions.integration.Econ;
56
import com.massivecraft.factions.struct.Permission;
@@ -22,41 +23,16 @@ public CmdStealth() {
2223
}
2324

2425
public void perform() {
25-
if (myFaction != null && !myFaction.isWilderness() && !myFaction.isSafeZone() && !myFaction.isWarZone() && myFaction.isNormal()) {
26-
27-
28-
// Sends Enable/Disable Message
29-
if (fme.isStealthEnabled()) {
30-
fme.setStealth(false);
31-
} else {
32-
/* The FPlayer#takeMoney method calls the FPlayer#hasMoney method beforehand to check if the amount
33-
* can be withdrawn successfully.
34-
* The FPlayer#hasMoney method already sends a deny message so there isn't a need to send another.
35-
* Basically the takeMoney is an all in one solution for taking money :)
36-
*/
37-
fme.takeMoney(P.p.getConfig().getInt("stealth-cost"));
38-
fme.setStealth(true);
39-
Bukkit.getScheduler().scheduleSyncDelayedTask(P.p, new Runnable() {
40-
@Override
41-
public void run() {
42-
if (fme.isStealthEnabled()) {
43-
fme.setStealth(false);
44-
fme.msg(TL.COMMAND_STEALTH_DISABLE);
45-
}
46-
}
47-
// We multiplied by 20 here because the value is in ticks.
48-
}, P.p.getConfig().getInt("stealth-timeout") * 20);
49-
}
50-
51-
fme.sendMessage(fme.isStealthEnabled() ? TL.COMMAND_STEALTH_ENABLE.toString().replace("{timeout}", P.p.getConfig().getInt("stealth-timeout") + "") : TL.COMMAND_STEALTH_DISABLE.toString());
26+
Faction faction = fme.getFaction();
27+
if (faction != null && !faction.getId().equalsIgnoreCase("0") && !faction.getId().equalsIgnoreCase("none") && !faction.getId().equalsIgnoreCase("safezone") && !faction.getId().equalsIgnoreCase("warzone")) {
28+
fme.setStealth(!fme.isStealthEnabled());
29+
fme.msg(fme.isStealthEnabled() ? TL.COMMAND_STEALTH_ENABLE : TL.COMMAND_STEALTH_DISABLE);
5230
} else {
5331
fme.msg(TL.COMMAND_STEALTH_MUSTBEMEMBER);
5432
}
5533
}
5634

57-
@Override
5835
public TL getUsageTranslation() {
5936
return TL.COMMAND_STEALTH_DESCRIPTION;
6037
}
61-
6238
}

src/main/java/com/massivecraft/factions/cmd/FCmdRoot.java

+6
Original file line numberDiff line numberDiff line change
@@ -63,6 +63,8 @@ public class FCmdRoot extends FCommand {
6363
public CmdSB cmdSB = new CmdSB();
6464
public CmdShowInvites cmdShowInvites = new CmdShowInvites();
6565
public CmdAnnounce cmdAnnounce = new CmdAnnounce();
66+
public CmdPaypalSet cmdPaypalSet = new CmdPaypalSet();
67+
public CmdPaypalSee cmdPaypalSee = new CmdPaypalSee();
6668
public CmdSeeChunk cmdSeeChunk = new CmdSeeChunk();
6769
public CmdConvert cmdConvert = new CmdConvert();
6870
public CmdFWarp cmdFWarp = new CmdFWarp();
@@ -231,6 +233,10 @@ public FCmdRoot() {
231233
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.");
232234
this.addSubCommand(this.cmdTop);
233235
}
236+
if (P.p.getConfig().getBoolean("fpaypal.Enabled")) {
237+
this.addSubCommand(this.cmdPaypalSet);
238+
this.addSubCommand(this.cmdPaypalSee);
239+
}
234240

235241
}
236242

src/main/java/com/massivecraft/factions/listeners/FactionsEntityListener.java

+68
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,8 @@
1919
import org.bukkit.event.hanging.HangingBreakEvent;
2020
import org.bukkit.event.hanging.HangingBreakEvent.RemoveCause;
2121
import org.bukkit.event.hanging.HangingPlaceEvent;
22+
import org.bukkit.event.player.PlayerInteractAtEntityEvent;
23+
import org.bukkit.event.player.PlayerInteractEntityEvent;
2224
import org.bukkit.event.player.PlayerPortalEvent;
2325
import org.bukkit.potion.PotionEffect;
2426
import org.bukkit.potion.PotionEffectType;
@@ -132,6 +134,39 @@ public void onEntityDamage(EntityDamageEvent event) {
132134
}
133135
}
134136
} else {
137+
// Protect armor stands/item frames from being damaged in protected territories
138+
if (damagee.getType() == EntityType.ITEM_FRAME || damagee.getType() == EntityType.ARMOR_STAND) {
139+
// Manage projectiles launched by players
140+
if (damager instanceof Projectile && ((Projectile) damager).getShooter() instanceof Entity) {
141+
damager = (Entity) ((Projectile) damager).getShooter();
142+
}
143+
144+
// Run the check for a player
145+
if (damager instanceof Player) {
146+
// Generate the action message.
147+
String entityAction;
148+
149+
if (damagee.getType() == EntityType.ITEM_FRAME) {
150+
entityAction = "item frames";
151+
} else {
152+
entityAction = "armor stands";
153+
}
154+
155+
if (!FactionsBlockListener.playerCanBuildDestroyBlock((Player) damager, damagee.getLocation(), "destroy " + entityAction, false)) {
156+
event.setCancelled(true);
157+
}
158+
} else {
159+
// we don't want to let mobs/arrows destroy item frames/armor stands
160+
// so we only have to run the check as if there had been an explosion at the damager location
161+
if (!this.checkExplosionForBlock(damager, damagee.getLocation().getBlock())) {
162+
event.setCancelled(true);
163+
}
164+
}
165+
166+
// we don't need to go after
167+
return;
168+
}
169+
135170
//this one should trigger if something other than a player takes damage
136171
if (damager instanceof Player) {
137172
// now itll only go here if the damage is dealt by a player
@@ -582,6 +617,8 @@ public void onPaintingBreak(HangingBreakEvent event) {
582617
public void onPaintingPlace(HangingPlaceEvent event) {
583618
if (!FactionsBlockListener.playerCanBuildDestroyBlock(event.getPlayer(), event.getBlock().getLocation(), "place paintings", false)) {
584619
event.setCancelled(true);
620+
// Fix: update player's inventory to avoid items glitches
621+
event.getPlayer().updateInventory();
585622
}
586623
}
587624

@@ -680,6 +717,37 @@ public void onBowHit(EntityDamageByEntityEvent e) {
680717
}
681718
}
682719

720+
// For disabling interactions with item frames in another faction's territory
721+
@EventHandler(priority = EventPriority.NORMAL, ignoreCancelled = true)
722+
public void onPlayerInteractEntity(PlayerInteractEntityEvent event) {
723+
// only need to check for item frames
724+
if (event.getRightClicked().getType() != EntityType.ITEM_FRAME) {
725+
return;
726+
}
727+
728+
Player player = event.getPlayer();
729+
Entity entity = event.getRightClicked();
730+
731+
if (!FactionsBlockListener.playerCanBuildDestroyBlock(player, entity.getLocation(), "use item frames", false)) {
732+
event.setCancelled(true);
733+
}
734+
}
735+
736+
// For disabling interactions with armor stands in another faction's territory
737+
@EventHandler(priority = EventPriority.NORMAL, ignoreCancelled = true)
738+
public void onPlayerInteractAtEntity(PlayerInteractAtEntityEvent event) {
739+
Entity entity = event.getRightClicked();
740+
741+
// only need to check for armor stand and item frames
742+
if (entity.getType() != EntityType.ARMOR_STAND) {
743+
return;
744+
}
745+
746+
if (!FactionsBlockListener.playerCanBuildDestroyBlock(event.getPlayer(), entity.getLocation(), "use armor stands", false)) {
747+
event.setCancelled(true);
748+
}
749+
}
750+
683751
private boolean stopEndermanBlockManipulation(Location loc) {
684752
if (loc == null) {
685753
return false;

src/main/java/com/massivecraft/factions/struct/Permission.java

+1
Original file line numberDiff line numberDiff line change
@@ -64,6 +64,7 @@ public enum Permission {
6464
SET_PERMANENT("setpermanent"),
6565
SET_PERMANENTPOWER("setpermanentpower"),
6666
SHOW_INVITES("showinvites"),
67+
PAYPALSET("setpaypal"),
6768
PERMISSIONS("permissions"),
6869
POWERBOOST("powerboost"),
6970
POWER("power"),

src/main/java/com/massivecraft/factions/zcore/persist/MemoryFPlayer.java

+3-3
Original file line numberDiff line numberDiff line change
@@ -1046,9 +1046,9 @@ public boolean checkIfNearbyEnemies(){
10461046
if (eplayer == null) { continue; }
10471047
FPlayer efplayer = FPlayers.getInstance().getByPlayer(eplayer);
10481048
if (efplayer == null) { continue; }
1049-
if (Conf.allowedStealthFactions != null && !efplayer.isStealthEnabled()) {
1050-
this.setFlying(false);
1051-
this.msg(TL.COMMAND_FLY_ENEMY_NEAR);
1049+
if (efplayer != null && this.getRelationTo(efplayer).equals(Relation.ENEMY) && !efplayer.isStealthEnabled()) {
1050+
setFlying(false);
1051+
msg(TL.COMMAND_FLY_ENEMY_NEAR);
10521052
Bukkit.getServer().getPluginManager().callEvent(new FPlayerStoppedFlying(this));
10531053
return true;
10541054
}

src/main/java/com/massivecraft/factions/zcore/persist/MemoryFaction.java

+8
Original file line numberDiff line numberDiff line change
@@ -51,6 +51,7 @@ public abstract class MemoryFaction implements Faction, EconomyParticipator {
5151
protected transient long lastPlayerLoggedOffTime;
5252
protected double money;
5353
protected double powerBoost;
54+
protected String paypal;
5455
protected Map<String, Relation> relationWish = new HashMap<>();
5556
protected Map<FLocation, Set<String>> claimOwnership = new ConcurrentHashMap<>();
5657
protected transient Set<FPlayer> fplayers = new HashSet<>();
@@ -164,6 +165,13 @@ public boolean removeWarp(String name) {
164165
public boolean isWarpPassword(String warp, String password) {
165166
return hasWarpPassword(warp) && warpPasswords.get(warp.toLowerCase()).equals(password);
166167
}
168+
public String getPaypal() {
169+
return this.paypal;
170+
}
171+
172+
public void paypalSet(String paypal) {
173+
this.paypal = paypal;
174+
}
167175

168176
public boolean hasWarpPassword(String warp) {
169177
return warpPasswords.containsKey(warp.toLowerCase());

src/main/java/com/massivecraft/factions/zcore/util/TL.java

+8
Original file line numberDiff line numberDiff line change
@@ -470,6 +470,14 @@ public enum TL {
470470
COMMAND_OWNERLIST_OWNERS("&c&l[!]&7 Current owner(s) of this land: %1$s"),
471471
COMMAND_OWNERLIST_DESCRIPTION("List owner(s) of this claimed land"),
472472

473+
COMMAND_PAYPALSET_DESCRIPTION("&c&l[!] &7Set the email of your faction to claim rewards."),
474+
COMMAND_PAYPALSEE_DESCRIPTION("&c&l[!] &7View a specific factions paypal email with &b/f <seepaypal/getpaypal> <faction>&b."),
475+
COMMAND_PAYPALSET_CREATED("&c&l[!] &7Make sure to type &b/f <paypal/setpaypal> <email>&7!"),
476+
COMMAND_PAYPALSET_SUCCESSFUL("&c&l[!] &7Successfully set your factions email - &b%1$s&7."),
477+
COMMAND_PAYPALSEE_FACTION_PAYPAL("&c&l[!] &b%1$s's &7faction has their paypal set to &b%2$s&7."),
478+
COMMAND_PAYPALSEE_FACTION_NOTSET("&c&l[!] &b%1$s's &7paypal has not yet been set!"),
479+
COMMAND_PAYPALSEE_FACTION_NOFACTION("&c&l[!] &b%1$s &7does not have a faction!"),
480+
473481
COMMAND_PEACEFUL_DESCRIPTION("&c&l[!]&7Set a faction to peaceful"),
474482
COMMAND_PEACEFUL_YOURS("&c&l[!]&7%1$s has %2$s your faction"),
475483
COMMAND_PEACEFUL_OTHER("&c&l[!]&7%s has %s the faction '%s<i>'."),

0 commit comments

Comments
 (0)