Merge branch '1.6.x' into permsfix

This commit is contained in:
Naman 2019-04-01 17:04:55 -05:00 committed by GitHub
commit ca75e76449
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
9 changed files with 131 additions and 127 deletions

View File

@ -496,7 +496,7 @@ public class SavageFactions extends MPlugin {
} }
public ItemStack createItem(Material material, int amount, short datavalue, String name, List<String> lore) { public ItemStack createItem(Material material, int amount, short datavalue, String name, List<String> lore) {
ItemStack item = new ItemStack(material, amount, datavalue); ItemStack item = new ItemStack(MultiversionMaterials.fromString(material.toString()).parseMaterial(), amount, datavalue);
ItemMeta meta = item.getItemMeta(); ItemMeta meta = item.getItemMeta();
meta.setDisplayName(color(name)); meta.setDisplayName(color(name));
meta.setLore(colorList(lore)); meta.setLore(colorList(lore));

View File

@ -34,7 +34,7 @@ public class CmdAdmin extends FCommand {
@Override @Override
public void perform() { public void perform() {
FPlayer fyou = this.argAsBestFPlayerMatch(0); FPlayer fyou = this.argAsBestFPlayerMatch(0);
if (fyou == null) { if (fyou == null || fyou.getFaction().isWarZone() || fyou.getFaction().isWilderness() || fyou.getFaction().isSafeZone()) {
return; return;
} }
@ -74,10 +74,10 @@ public class CmdAdmin extends FCommand {
// if target player is currently admin, demote and replace him // if target player is currently admin, demote and replace him
if (fyou == admin) { if (fyou == admin) {
targetFaction.promoteNewLeader(); targetFaction.promoteNewLeader();
msg(TL.COMMAND_ADMIN_DEMOTES, fyou.describeTo(fme, true)); msg(TL.COMMAND_ADMIN_DEMOTES, fyou.describeTo(fme, true));
fyou.msg(TL.COMMAND_ADMIN_DEMOTED, senderIsConsole ? TL.GENERIC_SERVERADMIN.toString() : fme.describeTo(fyou, true)); fyou.msg(TL.COMMAND_ADMIN_DEMOTED, senderIsConsole ? TL.GENERIC_SERVERADMIN.toString() : fme.describeTo(fyou, true));
return; return;
} }
// promote target player, and demote existing admin if one exists // promote target player, and demote existing admin if one exists

View File

@ -44,10 +44,54 @@ public class CmdFly extends FCommand {
return; return;
} }
id = Bukkit.getScheduler().scheduleSyncRepeatingTask(SavageFactions.plugin, new Runnable() { id = Bukkit.getScheduler().scheduleSyncRepeatingTask(SavageFactions.plugin, () -> {
@Override for (String name : flyMap.keySet()) {
public void run() { Player player = Bukkit.getPlayer(name);
if (player == null) {
continue;
}
if (!player.isFlying()) {
continue;
}
if (!SavageFactions.plugin.mc17) {
if (player.getGameMode() == GameMode.SPECTATOR) {
continue;
}
}
if (FPlayers.getInstance().getByPlayer(player).isVanished()) {
// Actually, vanished players (such as admins) should not display particles to prevent others from knowing their vanished assistance for moderation.
// But we can keep it as a config.
if (SavageFactions.plugin.getConfig().getBoolean("ffly.Particles.Enable-While-Vanished")) {
return;
}
continue;
}
if (SavageFactions.plugin.useNonPacketParticles) {
// 1.9+ based servers will use the built in particleAPI instead of packet based.
// any particle amount higher than 0 made them go everywhere, and the offset at 0 was not working.
// So setting the amount to 0 spawns 1 in the precise location
player.getWorld().spawnParticle(Particle.CLOUD, player.getLocation().add(0, -0.35, 0), 0);
} else {
ParticleEffect.CLOUD.display((float) 0, (float) 0, (float) 0, (float) 0, 3, player.getLocation().add(0, -0.35, 0), 16);
}
}
if (flyMap.keySet().size() == 0) {
Bukkit.getScheduler().cancelTask(id);
id = -1;
}
}, 10L, 3L);
}
public static void startFlyCheck() {
flyid = Bukkit.getScheduler().scheduleSyncRepeatingTask(SavageFactions.plugin, () -> { //threw the exception for now, until I recode fly :( Cringe.
checkTaskState();
if (flyMap.keySet().size() != 0) {
for (String name : flyMap.keySet()) { for (String name : flyMap.keySet()) {
if (name == null) {
continue;
}
Player player = Bukkit.getPlayer(name); Player player = Bukkit.getPlayer(name);
if (player == null) { if (player == null) {
continue; continue;
@ -55,88 +99,38 @@ public class CmdFly extends FCommand {
if (!player.isFlying()) { if (!player.isFlying()) {
continue; continue;
} }
if (!SavageFactions.plugin.mc17) { FPlayer fPlayer = FPlayers.getInstance().getByPlayer(player);
if (player.getGameMode() == GameMode.SPECTATOR) { if (fPlayer == null) {
continue;
}
}
if (FPlayers.getInstance().getByPlayer(player).isVanished()) {
// Actually, vanished players (such as admins) should not display particles to prevent others from knowing their vanished assistance for moderation.
// But we can keep it as a config.
if (SavageFactions.plugin.getConfig().getBoolean("ffly.Particles.Enable-While-Vanished")) {
return;
}
continue; continue;
} }
if (SavageFactions.plugin.useNonPacketParticles) { if (player.getGameMode() == GameMode.CREATIVE) {
// 1.9+ based servers will use the built in particleAPI instead of packet based. continue;
// any particle amount higher than 0 made them go everywhere, and the offset at 0 was not working.
// So setting the amount to 0 spawns 1 in the precise location
player.getWorld().spawnParticle(Particle.CLOUD, player.getLocation().add(0, -0.35, 0), 0);
} else {
ParticleEffect.CLOUD.display((float) 0, (float) 0, (float) 0, (float) 0, 3, player.getLocation().add(0, -0.35, 0), 16);
} }
if (!SavageFactions.plugin.mc17 && player.getGameMode() == GameMode.SPECTATOR) {
} continue;
if (flyMap.keySet().size() == 0) { }
Bukkit.getScheduler().cancelTask(id); Faction myFaction = fPlayer.getFaction();
id = -1; if (myFaction.isWilderness()) {
} fPlayer.setFlying(false);
} flyMap.remove(name);
}, 10L, 3L); continue;
} }
if (fPlayer.checkIfNearbyEnemies()) {
public static void startFlyCheck() { continue;
flyid = Bukkit.getScheduler().scheduleSyncRepeatingTask(SavageFactions.plugin, new Runnable() { }
@Override FLocation myFloc = new FLocation(player.getLocation());
public void run() throws ConcurrentModificationException { //threw the exception for now, until I recode fly :( Cringe. Faction toFac = Board.getInstance().getFactionAt(myFloc);
checkTaskState(); if (Board.getInstance().getFactionAt(myFloc) != myFaction) {
if (flyMap.keySet().size() != 0) { if (!checkBypassPerms(fPlayer, player, toFac)) {
for (String name : flyMap.keySet()) {
if (name == null) {
continue;
}
Player player = Bukkit.getPlayer(name);
if (player == null) {
continue;
}
if (!player.isFlying()) {
continue;
}
FPlayer fPlayer = FPlayers.getInstance().getByPlayer(player);
if (fPlayer == null) {
continue;
}
if (player.getGameMode() == GameMode.CREATIVE) {
continue;
}
if (!SavageFactions.plugin.mc17 && player.getGameMode() == GameMode.SPECTATOR) {
continue;
}
Faction myFaction = fPlayer.getFaction();
if (myFaction.isWilderness()) {
fPlayer.setFlying(false); fPlayer.setFlying(false);
flyMap.remove(name); flyMap.remove(name);
continue; continue;
} }
if (fPlayer.checkIfNearbyEnemies()) {
continue;
}
FLocation myFloc = new FLocation(player.getLocation());
Faction toFac = Board.getInstance().getFactionAt(myFloc);
if (Board.getInstance().getFactionAt(myFloc) != myFaction) {
if (!checkBypassPerms(fPlayer, player, toFac)) {
fPlayer.setFlying(false);
flyMap.remove(name);
continue;
}
}
} }
}
}
} }
}, 20L, 20L); }, 20L, 20L);
} }
@ -226,20 +220,17 @@ public class CmdFly extends FCommand {
if (fme.canFlyAtLocation()) if (fme.canFlyAtLocation())
this.doWarmUp(WarmUpUtil.Warmup.FLIGHT, TL.WARMUPS_NOTIFY_FLIGHT, "Fly", new Runnable() { this.doWarmUp(WarmUpUtil.Warmup.FLIGHT, TL.WARMUPS_NOTIFY_FLIGHT, "Fly", () -> {
@Override fme.setFlying(true);
public void run() { flyMap.put(player.getName(), true);
fme.setFlying(true); if (id == -1) {
flyMap.put(player.getName(), true); if (SavageFactions.plugin.getConfig().getBoolean("ffly.Particles.Enabled")) {
if (id == -1) { startParticles();
if (SavageFactions.plugin.getConfig().getBoolean("ffly.Particles.Enabled")) {
startParticles();
}
}
if (flyid == -1) {
startFlyCheck();
} }
} }
if (flyid == -1) {
startFlyCheck();
}
}, this.p.getConfig().getLong("warmups.f-fly", 0)); }, this.p.getConfig().getLong("warmups.f-fly", 0));
} }

View File

@ -8,9 +8,11 @@ import com.massivecraft.factions.zcore.util.TL;
public class CmdPaypalSee extends FCommand { public class CmdPaypalSee extends FCommand {
public CmdPaypalSee() { public CmdPaypalSee() {
aliases.add("seepaypal"); aliases.add("seepaypal");
aliases.add("getpaypal");
requiredArgs.add("faction"); requiredArgs.add("faction");
permission = Permission.ADMIN.node; permission = Permission.ADMIN.node;
disableOnLock = false; disableOnLock = false;
senderMustBePlayer = false; senderMustBePlayer = false;
senderMustBeMember = false; senderMustBeMember = false;
@ -19,28 +21,29 @@ public class CmdPaypalSee extends FCommand {
senderMustBeAdmin = false; senderMustBeAdmin = false;
} }
@Override
public void perform() { public void perform() {
if (!SavageFactions.plugin.getConfig().getBoolean("fpaypal.Enabled")) { if (!SavageFactions.plugin.getConfig().getBoolean("fpaypal.Enabled")) {
fme.msg(TL.GENERIC_DISABLED); fme.msg(TL.GENERIC_DISABLED);
} else { return;
}
Faction faction = argAsFaction(0); Faction faction = argAsFaction(0);
if (faction != null) { if (faction != null)
return;
if (!faction.isWilderness() && !faction.isSafeZone() && !faction.isWarZone()) { if (!faction.isWilderness() && !faction.isSafeZone() && !faction.isWarZone()) {
fme.msg(TL.COMMAND_PAYPALSEE_FACTION_NOFACTION.toString(), me.getName());
return;
}
if (faction.getPaypal() != null) { if (faction.getPaypal() != null) {
fme.msg(TL.COMMAND_PAYPALSEE_FACTION_PAYPAL.toString(), faction.getTag(), faction.getPaypal()); fme.msg(TL.COMMAND_PAYPALSEE_FACTION_PAYPAL.toString(), faction.getTag(), faction.getPaypal());
} else { } else {
fme.msg(TL.COMMAND_PAYPALSEE_FACTION_NOTSET.toString(), faction.getTag(), faction.getPaypal()); fme.msg(TL.COMMAND_PAYPALSEE_FACTION_NOTSET.toString(), faction.getTag(), faction.getPaypal());
} }
} else {
fme.msg(TL.COMMAND_PAYPALSEE_FACTION_NOFACTION.toString(), me.getName());
} }
}
}
}
@Override
public TL getUsageTranslation() { public TL getUsageTranslation() {
return TL.COMMAND_PAYPALSEE_DESCRIPTION; return TL.COMMAND_PAYPALSEE_DESCRIPTION;
} }

View File

@ -8,30 +8,31 @@ public class CmdPaypalSet extends FCommand {
public CmdPaypalSet() { public CmdPaypalSet() {
this.aliases.add("setpaypal"); this.aliases.add("setpaypal");
this.aliases.add("paypal");
this.requiredArgs.add("email"); this.requiredArgs.add("email");
this.permission = Permission.PAYPALSET.node; this.permission = Permission.PAYPALSET.node;
this.disableOnLock = false; this.disableOnLock = false;
this.senderMustBePlayer = true; this.senderMustBePlayer = true;
this.senderMustBeMember = false; this.senderMustBeMember = false;
this.senderMustBeModerator = false; this.senderMustBeModerator = false;
this.senderMustBeColeader = true; this.senderMustBeColeader = false;
this.senderMustBeAdmin = false; this.senderMustBeAdmin = true;
} }
@Override
public void perform() { public void perform() {
if (!SavageFactions.plugin.getConfig().getBoolean("fpaypal.Enabled")) { if (!SavageFactions.plugin.getConfig().getBoolean("fpaypal.Enabled")) {
fme.msg(TL.GENERIC_DISABLED); fme.msg(TL.GENERIC_DISABLED);
} else { return;
String paypal = argAsString(0);
if (paypal != null) {
myFaction.paypalSet(paypal);
fme.msg(TL.COMMAND_PAYPALSET_SUCCESSFUL, paypal);
}
} }
String paypal = this.argAsString(0);
if(paypal == null)
return;
myFaction.paypalSet(paypal);
fme.msg(TL.COMMAND_PAYPALSET_SUCCESSFUL, paypal);
} }
@Override
public TL getUsageTranslation() { public TL getUsageTranslation() {
return TL.COMMAND_PAYPALSET_DESCRIPTION; return TL.COMMAND_PAYPALSET_DESCRIPTION;
} }

View File

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

View File

@ -18,7 +18,7 @@ import com.massivecraft.factions.util.MultiversionMaterials;
import com.massivecraft.factions.util.VisualizeUtil; import com.massivecraft.factions.util.VisualizeUtil;
import com.massivecraft.factions.zcore.fperms.Access; import com.massivecraft.factions.zcore.fperms.Access;
import com.massivecraft.factions.zcore.fperms.PermissableAction; import com.massivecraft.factions.zcore.fperms.PermissableAction;
import com.massivecraft.factions.zcore.persist.*; import com.massivecraft.factions.zcore.persist.MemoryFPlayer;
import com.massivecraft.factions.zcore.util.TL; import com.massivecraft.factions.zcore.util.TL;
import com.massivecraft.factions.zcore.util.TagUtil; import com.massivecraft.factions.zcore.util.TagUtil;
import com.massivecraft.factions.zcore.util.TextUtil; import com.massivecraft.factions.zcore.util.TextUtil;
@ -499,7 +499,7 @@ public class FactionsPlayerListener implements Listener {
boolean isHome = false; boolean isHome = false;
for (String str : SavageFactions.plugin.ess.getUser(event.getPlayer()).getHomes()) { for (String str : SavageFactions.plugin.ess.getUser(event.getPlayer()).getHomes()) {
Location home = SavageFactions.plugin.ess.getUser(event.getPlayer()).getHome(str); Location home = SavageFactions.plugin.ess.getUser(event.getPlayer()).getHome(str);
if (home.getBlockX() == event.getTo().getBlockX() && home.getBlockY() == event.getTo().getBlockY() && home.getBlockZ() == event.getTo().getBlockZ()) { if (home.getBlockX() == event.getTo().getBlockX() && home.getBlockZ() == event.getTo().getBlockZ()) {
isHome = true; isHome = true;
} }
} }
@ -747,9 +747,9 @@ public class FactionsPlayerListener implements Listener {
if (event.getPlayer().getItemInHand() != null) { if (event.getPlayer().getItemInHand() != null) {
Material handItem = event.getPlayer().getItemInHand().getType(); Material handItem = event.getPlayer().getItemInHand().getType();
if (handItem.isEdible() if (handItem.isEdible()
|| handItem.equals(Material.POTION) || handItem.equals(MultiversionMaterials.POTION.parseMaterial())
|| handItem.equals(Material.LINGERING_POTION) || handItem.equals(MultiversionMaterials.LINGERING_POTION.parseMaterial())
|| handItem.equals(Material.SPLASH_POTION)) { || handItem.equals(MultiversionMaterials.SPLASH_POTION.parseMaterial())) {
return; return;
} }
} }
@ -890,7 +890,7 @@ public class FactionsPlayerListener implements Listener {
/// <param name="loc">The World location where the action is being executed</param> /// <param name="loc">The World location where the action is being executed</param>
/// <param name="myFaction">The faction of the player being checked</param> /// <param name="myFaction">The faction of the player being checked</param>
/// <param name="access">The current's faction access permission for the action</param> /// <param name="access">The current's faction access permission for the action</param>
private static boolean CheckPlayerAccess(Player player, FPlayer me, FLocation loc, Faction myFaction, Access access, PermissableAction action, boolean pain) { private static boolean CheckPlayerAccess(Player player, FPlayer me, FLocation loc, Faction factionToCheck, Access access, PermissableAction action, boolean pain) {
boolean doPain = pain && Conf.handleExploitInteractionSpam; boolean doPain = pain && Conf.handleExploitInteractionSpam;
if (access != null && access != Access.UNDEFINED) { if (access != null && access != Access.UNDEFINED) {
// TODO: Update this once new access values are added other than just allow / deny. // TODO: Update this once new access values are added other than just allow / deny.
@ -898,6 +898,11 @@ public class FactionsPlayerListener implements Listener {
if ((landOwned && myFaction.getOwnerListString(loc).contains(player.getName())) || (me.getRole() == Role.LEADER && me.getFactionId().equals(myFaction.getId()))) return true; if ((landOwned && myFaction.getOwnerListString(loc).contains(player.getName())) || (me.getRole() == Role.LEADER && me.getFactionId().equals(myFaction.getId()))) return true;
else 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))); me.msg(TL.ACTIONS_OWNEDTERRITORYDENY.toString().replace("{owners}", myFaction.getOwnerListString(loc)));
boolean landOwned = (factionToCheck.doesLocationHaveOwnersSet(loc) && !factionToCheck.getOwnerList(loc).isEmpty());
if ((landOwned && factionToCheck.getOwnerListString(loc).contains(player.getName())) || (me.getRole() == Role.LEADER && me.getFactionId().equals(factionToCheck.getId())))
return true;
else if (landOwned && !factionToCheck.getOwnerListString(loc).contains(player.getName())) {
me.msg("<b>You can't do that in this territory, it is owned by: " + factionToCheck.getOwnerListString(loc));
if (doPain) { if (doPain) {
player.damage(Conf.actionDeniedPainAmount); player.damage(Conf.actionDeniedPainAmount);
} }
@ -909,6 +914,12 @@ public class FactionsPlayerListener implements Listener {
} }
} }
me.msg(TL.ACTIONS_NOPERMISSION.toString().replace("{faction}", myFaction.getTag(me.getFaction())).replace("{action}", action.toString())); me.msg(TL.ACTIONS_NOPERMISSION.toString().replace("{faction}", myFaction.getTag(me.getFaction())).replace("{action}", action.toString()));
me.msg("You cannot " + action + " in the territory of " + factionToCheck.getTag(me.getFaction()));
return false;
}
}
if (me.getRole().equals(Role.LEADER) && me.getFaction().equals(factionToCheck)) return true;
me.msg("You cannot " + action + " in the territory of " + factionToCheck.getTag(me.getFaction()));
return false; return false;
} }
/// <summary> /// <summary>

View File

@ -2,6 +2,7 @@ package com.massivecraft.factions.struct;
import com.massivecraft.factions.Conf; import com.massivecraft.factions.Conf;
import com.massivecraft.factions.SavageFactions; import com.massivecraft.factions.SavageFactions;
import com.massivecraft.factions.util.MultiversionMaterials;
import com.massivecraft.factions.zcore.fperms.Permissable; import com.massivecraft.factions.zcore.fperms.Permissable;
import com.massivecraft.factions.zcore.util.TL; import com.massivecraft.factions.zcore.util.TL;
import org.bukkit.ChatColor; import org.bukkit.ChatColor;
@ -203,7 +204,7 @@ public enum Relation implements Permissable {
String displayName = replacePlaceholders(RELATION_CONFIG.getString("placeholder-item.name", "")); String displayName = replacePlaceholders(RELATION_CONFIG.getString("placeholder-item.name", ""));
List<String> lore = new ArrayList<>(); List<String> lore = new ArrayList<>();
Material material = Material.matchMaterial(RELATION_CONFIG.getString("materials." + name().toLowerCase())); Material material = MultiversionMaterials.fromString(RELATION_CONFIG.getString("materials." + name().toLowerCase())).parseMaterial();
if (material == null) { if (material == null) {
return null; return null;
} }

View File

@ -2,6 +2,7 @@ package com.massivecraft.factions.struct;
import com.massivecraft.factions.Conf; import com.massivecraft.factions.Conf;
import com.massivecraft.factions.SavageFactions; import com.massivecraft.factions.SavageFactions;
import com.massivecraft.factions.util.MultiversionMaterials;
import com.massivecraft.factions.zcore.fperms.Permissable; import com.massivecraft.factions.zcore.fperms.Permissable;
import com.massivecraft.factions.zcore.util.TL; import com.massivecraft.factions.zcore.util.TL;
import org.bukkit.ChatColor; import org.bukkit.ChatColor;
@ -117,7 +118,7 @@ public enum Role implements Permissable {
String displayName = replacePlaceholders(RELATION_CONFIG.getString("placeholder-item.name", "")); String displayName = replacePlaceholders(RELATION_CONFIG.getString("placeholder-item.name", ""));
List<String> lore = new ArrayList<>(); List<String> lore = new ArrayList<>();
Material material = Material.matchMaterial(RELATION_CONFIG.getString("materials." + name().toLowerCase(), "STAINED_CLAY")); Material material = MultiversionMaterials.fromString(RELATION_CONFIG.getString("materials." + name().toLowerCase(), "STAINED_CLAY")).parseMaterial();
if (material == null) { if (material == null) {
return null; return null;
} }