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

Commit ca75e76

Browse files
authored
Merge branch '1.6.x' into permsfix
2 parents 786d6be + 98dd9a7 commit ca75e76

File tree

9 files changed

+130
-126
lines changed

9 files changed

+130
-126
lines changed

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

+1-1
Original file line numberDiff line numberDiff line change
@@ -496,7 +496,7 @@ public void postAutoSave() {
496496
}
497497

498498
public ItemStack createItem(Material material, int amount, short datavalue, String name, List<String> lore) {
499-
ItemStack item = new ItemStack(material, amount, datavalue);
499+
ItemStack item = new ItemStack(MultiversionMaterials.fromString(material.toString()).parseMaterial(), amount, datavalue);
500500
ItemMeta meta = item.getItemMeta();
501501
meta.setDisplayName(color(name));
502502
meta.setLore(colorList(lore));

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

+5-5
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,7 @@ public CmdAdmin() {
3434
@Override
3535
public void perform() {
3636
FPlayer fyou = this.argAsBestFPlayerMatch(0);
37-
if (fyou == null) {
37+
if (fyou == null || fyou.getFaction().isWarZone() || fyou.getFaction().isWilderness() || fyou.getFaction().isSafeZone()) {
3838
return;
3939
}
4040

@@ -74,10 +74,10 @@ public void perform() {
7474

7575
// if target player is currently admin, demote and replace him
7676
if (fyou == admin) {
77-
targetFaction.promoteNewLeader();
78-
msg(TL.COMMAND_ADMIN_DEMOTES, fyou.describeTo(fme, true));
79-
fyou.msg(TL.COMMAND_ADMIN_DEMOTED, senderIsConsole ? TL.GENERIC_SERVERADMIN.toString() : fme.describeTo(fyou, true));
80-
return;
77+
targetFaction.promoteNewLeader();
78+
msg(TL.COMMAND_ADMIN_DEMOTES, fyou.describeTo(fme, true));
79+
fyou.msg(TL.COMMAND_ADMIN_DEMOTED, senderIsConsole ? TL.GENERIC_SERVERADMIN.toString() : fme.describeTo(fyou, true));
80+
return;
8181
}
8282

8383
// promote target player, and demote existing admin if one exists

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

+77-86
Original file line numberDiff line numberDiff line change
@@ -44,99 +44,93 @@ public static void startParticles() {
4444
return;
4545
}
4646

47-
id = Bukkit.getScheduler().scheduleSyncRepeatingTask(SavageFactions.plugin, new Runnable() {
48-
@Override
49-
public void run() {
47+
id = Bukkit.getScheduler().scheduleSyncRepeatingTask(SavageFactions.plugin, () -> {
48+
for (String name : flyMap.keySet()) {
49+
Player player = Bukkit.getPlayer(name);
50+
if (player == null) {
51+
continue;
52+
}
53+
if (!player.isFlying()) {
54+
continue;
55+
}
56+
if (!SavageFactions.plugin.mc17) {
57+
if (player.getGameMode() == GameMode.SPECTATOR) {
58+
continue;
59+
}
60+
}
61+
62+
if (FPlayers.getInstance().getByPlayer(player).isVanished()) {
63+
// Actually, vanished players (such as admins) should not display particles to prevent others from knowing their vanished assistance for moderation.
64+
// But we can keep it as a config.
65+
if (SavageFactions.plugin.getConfig().getBoolean("ffly.Particles.Enable-While-Vanished")) {
66+
return;
67+
}
68+
continue;
69+
}
70+
if (SavageFactions.plugin.useNonPacketParticles) {
71+
// 1.9+ based servers will use the built in particleAPI instead of packet based.
72+
// any particle amount higher than 0 made them go everywhere, and the offset at 0 was not working.
73+
// So setting the amount to 0 spawns 1 in the precise location
74+
player.getWorld().spawnParticle(Particle.CLOUD, player.getLocation().add(0, -0.35, 0), 0);
75+
} else {
76+
ParticleEffect.CLOUD.display((float) 0, (float) 0, (float) 0, (float) 0, 3, player.getLocation().add(0, -0.35, 0), 16);
77+
}
78+
79+
}
80+
if (flyMap.keySet().size() == 0) {
81+
Bukkit.getScheduler().cancelTask(id);
82+
id = -1;
83+
}
84+
}, 10L, 3L);
85+
}
86+
87+
public static void startFlyCheck() {
88+
flyid = Bukkit.getScheduler().scheduleSyncRepeatingTask(SavageFactions.plugin, () -> { //threw the exception for now, until I recode fly :( Cringe.
89+
checkTaskState();
90+
if (flyMap.keySet().size() != 0) {
5091
for (String name : flyMap.keySet()) {
92+
if (name == null) {
93+
continue;
94+
}
5195
Player player = Bukkit.getPlayer(name);
5296
if (player == null) {
5397
continue;
5498
}
5599
if (!player.isFlying()) {
56100
continue;
57101
}
58-
if (!SavageFactions.plugin.mc17) {
59-
if (player.getGameMode() == GameMode.SPECTATOR) {
60-
continue;
61-
}
102+
FPlayer fPlayer = FPlayers.getInstance().getByPlayer(player);
103+
if (fPlayer == null) {
104+
continue;
62105
}
63-
64-
if (FPlayers.getInstance().getByPlayer(player).isVanished()) {
65-
// Actually, vanished players (such as admins) should not display particles to prevent others from knowing their vanished assistance for moderation.
66-
// But we can keep it as a config.
67-
if (SavageFactions.plugin.getConfig().getBoolean("ffly.Particles.Enable-While-Vanished")) {
68-
return;
69-
}
106+
if (player.getGameMode() == GameMode.CREATIVE) {
70107
continue;
71108
}
72-
if (SavageFactions.plugin.useNonPacketParticles) {
73-
// 1.9+ based servers will use the built in particleAPI instead of packet based.
74-
// any particle amount higher than 0 made them go everywhere, and the offset at 0 was not working.
75-
// So setting the amount to 0 spawns 1 in the precise location
76-
player.getWorld().spawnParticle(Particle.CLOUD, player.getLocation().add(0, -0.35, 0), 0);
77-
} else {
78-
ParticleEffect.CLOUD.display((float) 0, (float) 0, (float) 0, (float) 0, 3, player.getLocation().add(0, -0.35, 0), 16);
109+
if (!SavageFactions.plugin.mc17 && player.getGameMode() == GameMode.SPECTATOR) {
110+
continue;
79111
}
80-
81-
}
82-
if (flyMap.keySet().size() == 0) {
83-
Bukkit.getScheduler().cancelTask(id);
84-
id = -1;
85-
}
86-
}
87-
}, 10L, 3L);
88-
}
89-
90-
public static void startFlyCheck() {
91-
flyid = Bukkit.getScheduler().scheduleSyncRepeatingTask(SavageFactions.plugin, new Runnable() {
92-
@Override
93-
public void run() throws ConcurrentModificationException { //threw the exception for now, until I recode fly :( Cringe.
94-
checkTaskState();
95-
if (flyMap.keySet().size() != 0) {
96-
for (String name : flyMap.keySet()) {
97-
if (name == null) {
98-
continue;
99-
}
100-
Player player = Bukkit.getPlayer(name);
101-
if (player == null) {
102-
continue;
103-
}
104-
if (!player.isFlying()) {
105-
continue;
106-
}
107-
FPlayer fPlayer = FPlayers.getInstance().getByPlayer(player);
108-
if (fPlayer == null) {
109-
continue;
110-
}
111-
if (player.getGameMode() == GameMode.CREATIVE) {
112-
continue;
113-
}
114-
if (!SavageFactions.plugin.mc17 && player.getGameMode() == GameMode.SPECTATOR) {
115-
continue;
116-
}
117-
Faction myFaction = fPlayer.getFaction();
118-
if (myFaction.isWilderness()) {
112+
Faction myFaction = fPlayer.getFaction();
113+
if (myFaction.isWilderness()) {
114+
fPlayer.setFlying(false);
115+
flyMap.remove(name);
116+
continue;
117+
}
118+
if (fPlayer.checkIfNearbyEnemies()) {
119+
continue;
120+
}
121+
FLocation myFloc = new FLocation(player.getLocation());
122+
Faction toFac = Board.getInstance().getFactionAt(myFloc);
123+
if (Board.getInstance().getFactionAt(myFloc) != myFaction) {
124+
if (!checkBypassPerms(fPlayer, player, toFac)) {
119125
fPlayer.setFlying(false);
120126
flyMap.remove(name);
121127
continue;
122128
}
123-
if (fPlayer.checkIfNearbyEnemies()) {
124-
continue;
125-
}
126-
FLocation myFloc = new FLocation(player.getLocation());
127-
Faction toFac = Board.getInstance().getFactionAt(myFloc);
128-
if (Board.getInstance().getFactionAt(myFloc) != myFaction) {
129-
if (!checkBypassPerms(fPlayer, player, toFac)) {
130-
fPlayer.setFlying(false);
131-
flyMap.remove(name);
132-
continue;
133-
}
134-
}
135-
136129
}
137-
}
138130

131+
}
139132
}
133+
140134
}, 20L, 20L);
141135
}
142136

@@ -226,20 +220,17 @@ private void toggleFlight(final boolean toggle, final Player player) {
226220

227221
if (fme.canFlyAtLocation())
228222

229-
this.doWarmUp(WarmUpUtil.Warmup.FLIGHT, TL.WARMUPS_NOTIFY_FLIGHT, "Fly", new Runnable() {
230-
@Override
231-
public void run() {
232-
fme.setFlying(true);
233-
flyMap.put(player.getName(), true);
234-
if (id == -1) {
235-
if (SavageFactions.plugin.getConfig().getBoolean("ffly.Particles.Enabled")) {
236-
startParticles();
237-
}
238-
}
239-
if (flyid == -1) {
240-
startFlyCheck();
223+
this.doWarmUp(WarmUpUtil.Warmup.FLIGHT, TL.WARMUPS_NOTIFY_FLIGHT, "Fly", () -> {
224+
fme.setFlying(true);
225+
flyMap.put(player.getName(), true);
226+
if (id == -1) {
227+
if (SavageFactions.plugin.getConfig().getBoolean("ffly.Particles.Enabled")) {
228+
startParticles();
241229
}
242230
}
231+
if (flyid == -1) {
232+
startFlyCheck();
233+
}
243234
}, this.p.getConfig().getLong("warmups.f-fly", 0));
244235
}
245236

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

+13-10
Original file line numberDiff line numberDiff line change
@@ -8,9 +8,11 @@
88
public class CmdPaypalSee extends FCommand {
99
public CmdPaypalSee() {
1010
aliases.add("seepaypal");
11-
aliases.add("getpaypal");
11+
1212
requiredArgs.add("faction");
13+
1314
permission = Permission.ADMIN.node;
15+
1416
disableOnLock = false;
1517
senderMustBePlayer = false;
1618
senderMustBeMember = false;
@@ -19,28 +21,29 @@ public CmdPaypalSee() {
1921
senderMustBeAdmin = false;
2022

2123
}
22-
24+
@Override
2325
public void perform() {
2426
if (!SavageFactions.plugin.getConfig().getBoolean("fpaypal.Enabled")) {
2527
fme.msg(TL.GENERIC_DISABLED);
26-
} else {
28+
return;
29+
}
2730
Faction faction = argAsFaction(0);
2831

29-
if (faction != null) {
32+
if (faction != null)
33+
return;
34+
3035
if (!faction.isWilderness() && !faction.isSafeZone() && !faction.isWarZone()) {
36+
fme.msg(TL.COMMAND_PAYPALSEE_FACTION_NOFACTION.toString(), me.getName());
37+
return;
38+
}
3139
if (faction.getPaypal() != null) {
3240
fme.msg(TL.COMMAND_PAYPALSEE_FACTION_PAYPAL.toString(), faction.getTag(), faction.getPaypal());
3341
} else {
3442
fme.msg(TL.COMMAND_PAYPALSEE_FACTION_NOTSET.toString(), faction.getTag(), faction.getPaypal());
3543
}
36-
37-
} else {
38-
fme.msg(TL.COMMAND_PAYPALSEE_FACTION_NOFACTION.toString(), me.getName());
3944
}
40-
}
41-
}
42-
}
4345

46+
@Override
4447
public TL getUsageTranslation() {
4548
return TL.COMMAND_PAYPALSEE_DESCRIPTION;
4649
}

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

+11-10
Original file line numberDiff line numberDiff line change
@@ -8,30 +8,31 @@ public class CmdPaypalSet extends FCommand {
88

99
public CmdPaypalSet() {
1010
this.aliases.add("setpaypal");
11-
this.aliases.add("paypal");
1211
this.requiredArgs.add("email");
1312
this.permission = Permission.PAYPALSET.node;
1413
this.disableOnLock = false;
1514
this.senderMustBePlayer = true;
1615
this.senderMustBeMember = false;
1716
this.senderMustBeModerator = false;
18-
this.senderMustBeColeader = true;
19-
this.senderMustBeAdmin = false;
17+
this.senderMustBeColeader = false;
18+
this.senderMustBeAdmin = true;
2019

2120
}
22-
21+
@Override
2322
public void perform() {
2423
if (!SavageFactions.plugin.getConfig().getBoolean("fpaypal.Enabled")) {
2524
fme.msg(TL.GENERIC_DISABLED);
26-
} else {
27-
String paypal = argAsString(0);
28-
if (paypal != null) {
29-
myFaction.paypalSet(paypal);
30-
fme.msg(TL.COMMAND_PAYPALSET_SUCCESSFUL, paypal);
31-
}
25+
return;
3226
}
27+
28+
String paypal = this.argAsString(0);
29+
if(paypal == null)
30+
return;
31+
myFaction.paypalSet(paypal);
32+
fme.msg(TL.COMMAND_PAYPALSET_SUCCESSFUL, paypal);
3333
}
3434

35+
@Override
3536
public TL getUsageTranslation() {
3637
return TL.COMMAND_PAYPALSET_DESCRIPTION;
3738
}

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

+2-6
Original file line numberDiff line numberDiff line change
@@ -256,11 +256,7 @@ public void onEntityExplode(EntityExplodeEvent event) {
256256
}
257257

258258
// Cancel the event if no block will explode
259-
if (event.blockList().isEmpty()) {
260-
event.setCancelled(true);
261-
262-
// Or handle the exploit of TNT in water/lava
263-
} else if ((boomer instanceof TNTPrimed || boomer instanceof ExplosiveMinecart) && Conf.handleExploitTNTWaterlog) {
259+
if (!event.blockList().isEmpty() && (boomer instanceof TNTPrimed || boomer instanceof ExplosiveMinecart) && Conf.handleExploitTNTWaterlog) {
264260
// TNT in water/lava doesn't normally destroy any surrounding blocks, which is usually desired behavior, but...
265261
// this change below provides workaround for waterwalling providing perfect protection,
266262
// and makes cheap (non-obsidian) TNT cannons require minor maintenance between shots
@@ -280,7 +276,7 @@ public void onEntityExplode(EntityExplodeEvent event) {
280276
@SuppressWarnings("deprecation")
281277
int id = target.getType().getId();
282278
// ignore air, bedrock, water, lava, obsidian, enchanting table, etc.... too bad we can't get a blast resistance value through Bukkit yet
283-
if (id != 0 && (id < 7 || id > 11) && id != 49 && id != 90 && id != 116 && id != 119 && id != 120 && id != 130) {
279+
if (id != 0 && (id < 7 || id > 11) && id != 90 && id != 116 && id != 119 && id != 120 && id != 130) {
284280
target.breakNaturally();
285281
}
286282
}

0 commit comments

Comments
 (0)