Code Cleanup/Added Configurable option to deny and remove homes in ANY factions land.

More Soon..
This commit is contained in:
Driftay 2019-02-10 23:57:45 -05:00
parent 3559a9f090
commit 5a37320397
125 changed files with 3676 additions and 3410 deletions

View File

@ -1,5 +1,5 @@
<assembly xmlns="http://maven.apache.org/plugins/maven-assembly-plugin/assembly/1.1.0"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
<assembly xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xmlns="http://maven.apache.org/plugins/maven-assembly-plugin/assembly/1.1.0"
xsi:schemaLocation="http://maven.apache.org/plugins/maven-assembly-plugin/assembly/1.1.0 http://maven.apache.org/xsd/assembly-1.1.0.xsd">
<id>bin</id>
<includeBaseDirectory>false</includeBaseDirectory>

View File

@ -2,12 +2,12 @@ package com.massivecraft.factions;
import ch.njol.skript.Skript;
import ch.njol.skript.SkriptAddon;
import com.earth2me.essentials.Essentials;
import com.google.gson.GsonBuilder;
import com.google.gson.reflect.TypeToken;
import com.massivecraft.factions.cmd.CmdAutoHelp;
import com.massivecraft.factions.cmd.FCmdRoot;
import com.massivecraft.factions.integration.Econ;
import com.massivecraft.factions.integration.Essentials;
import com.massivecraft.factions.integration.Worldguard;
import com.massivecraft.factions.integration.dynmap.EngineDynmap;
import com.massivecraft.factions.listeners.*;
@ -56,7 +56,9 @@ public class SavageFactions extends MPlugin {
// Single 4 life.
public static SavageFactions plugin;
public static Permission perms = null;
// Persistence related
public static ArrayList<FPlayer> playersFlying = new ArrayList();
public Essentials ess;
public boolean PlaceholderApi;
// Commands
public FCmdRoot cmdBase;
@ -72,15 +74,12 @@ public class SavageFactions extends MPlugin {
SOIL, MOB_SPANWER, THIN_GLASS, IRON_FENCE, NETHER_FENCE, FENCE,
WOODEN_DOOR, TRAP_DOOR, FENCE_GATE, BURNING_FURNACE, DIODE_BLOCK_OFF,
DIODE_BLOCK_ON, ENCHANTMENT_TABLE, FIREBALL;
// Persistence related
SkriptAddon skriptAddon;
private boolean locked = false;
private Integer AutoLeaveTask = null;
private boolean hookedPlayervaults;
private ClipPlaceholderAPIManager clipPlaceholderAPIManager;
private boolean mvdwPlaceholderAPIManager = false;
SkriptAddon skriptAddon;
private Listener[] eventsListener;
public SavageFactions() {
@ -157,7 +156,7 @@ public class SavageFactions extends MPlugin {
// Load Conf from disk
Conf.load();
Essentials.setup();
com.massivecraft.factions.integration.Essentials.setup();
hookedPlayervaults = setupPlayervaults();
FPlayers.getInstance().load();
Factions.getInstance().load();
@ -171,6 +170,11 @@ public class SavageFactions extends MPlugin {
}
faction.addFPlayer(fPlayer);
}
playersFlying.clear();
for (FPlayer fPlayer : FPlayers.getInstance().getAllFPlayers()) {
playersFlying.add(fPlayer);
}
UtilFly.run();
Board.getInstance().load();
Board.getInstance().clean();
@ -238,6 +242,8 @@ public class SavageFactions extends MPlugin {
getCommand(this.refCommand).setExecutor(this);
getCommand(this.refCommand).setTabCompleter(this);
setupEssentials();
if (getDescription().getFullName().contains("BETA")) {
divider();
System.out.println("You are using a BETA version of the plugin!");
@ -505,6 +511,11 @@ public class SavageFactions extends MPlugin {
return econ;
}
private boolean setupEssentials() {
SavageFactions.plugin.ess = (Essentials) this.getServer().getPluginManager().getPlugin("Essentials");
return SavageFactions.plugin.ess == null;
}
@Override
public boolean logPlayerCommands() {
return Conf.logPlayerCommands;
@ -542,25 +553,20 @@ public class SavageFactions extends MPlugin {
return new ArrayList<>();
}
for (; !commandsList.isEmpty() && !argsList.isEmpty(); argsList.remove(0))
{
for (; !commandsList.isEmpty() && !argsList.isEmpty(); argsList.remove(0)) {
String cmdName = argsList.get(0).toLowerCase();
MCommand<?> commandFounded = commandsList.stream()
.filter(c -> c.aliases.contains(cmdName))
.findFirst().orElse(null);
if (commandFounded != null)
{
if (commandFounded != null) {
commandEx = commandFounded;
commandsList = commandFounded.subCommands;
}
else break;
} else break;
}
if (argsList.isEmpty())
{
for (MCommand<?> subCommand: commandEx.subCommands)
{
if (argsList.isEmpty()) {
for (MCommand<?> subCommand : commandEx.subCommands) {
subCommand.setCommandSender(sender);
if (handleCommand(sender, cmdValid + " " + subCommand.aliases.get(0), true)
&& subCommand.visibility != CommandVisibility.INVISIBLE

View File

@ -41,12 +41,10 @@ public class CmdChat extends FCommand {
modeString = modeString.toLowerCase();
// Only allow Mods and higher rank to switch to this channel.
if (modeString.startsWith("m")) {
if (!fme.getRole().isAtLeast(Role.MODERATOR))
{
if (!fme.getRole().isAtLeast(Role.MODERATOR)) {
msg(TL.COMMAND_CHAT_MOD_ONLY);
return;
}
else modeTarget = ChatMode.MOD;
} else modeTarget = ChatMode.MOD;
} else if (modeString.startsWith("p")) {
modeTarget = ChatMode.PUBLIC;
} else if (modeString.startsWith("a")) {
@ -63,13 +61,22 @@ public class CmdChat extends FCommand {
fme.setChatMode(modeTarget);
switch (fme.getChatMode())
{
case MOD: msg(TL.COMMAND_CHAT_MODE_MOD); break;
case PUBLIC: msg(TL.COMMAND_CHAT_MODE_PUBLIC); break;
case ALLIANCE: msg(TL.COMMAND_CHAT_MODE_ALLIANCE); break;
case TRUCE: msg(TL.COMMAND_CHAT_MODE_TRUCE); break;
default: msg(TL.COMMAND_CHAT_MODE_FACTION); break;
switch (fme.getChatMode()) {
case MOD:
msg(TL.COMMAND_CHAT_MODE_MOD);
break;
case PUBLIC:
msg(TL.COMMAND_CHAT_MODE_PUBLIC);
break;
case ALLIANCE:
msg(TL.COMMAND_CHAT_MODE_ALLIANCE);
break;
case TRUCE:
msg(TL.COMMAND_CHAT_MODE_TRUCE);
break;
default:
msg(TL.COMMAND_CHAT_MODE_FACTION);
break;
}
}

View File

@ -46,8 +46,7 @@ public class CmdClaim extends FCommand {
}
}
if (forFaction.isWilderness())
{
if (forFaction.isWilderness()) {
CmdUnclaim cmdUnclaim = SavageFactions.plugin.cmdBase.cmdUnclaim;
cmdUnclaim.execute(sender, args.size() > 1 ? args.subList(0, 1) : args);
return;

View File

@ -1,12 +1,10 @@
package com.massivecraft.factions.cmd;
import com.massivecraft.factions.FPlayer;
import com.massivecraft.factions.FPlayers;
import com.massivecraft.factions.Faction;
import com.massivecraft.factions.SavageFactions;
import com.massivecraft.factions.*;
import com.massivecraft.factions.event.FactionDisbandEvent.PlayerDisbandReason;
import com.massivecraft.factions.struct.Permission;
import com.massivecraft.factions.struct.Role;
import com.massivecraft.factions.util.UtilFly;
import com.massivecraft.factions.zcore.fperms.Access;
import com.massivecraft.factions.zcore.fperms.PermissableAction;
import com.massivecraft.factions.zcore.util.TL;
@ -93,6 +91,7 @@ public class CmdDisband extends FCommand {
if (SavageFactions.plugin.getConfig().getBoolean("faction-disband-broadcast", true)) {
for (FPlayer follower : FPlayers.getInstance().getOnlinePlayers()) {
String amountString = senderIsConsole ? TL.GENERIC_SERVERADMIN.toString() : fme.describeTo(follower);
UtilFly.checkFly(this.fme, Board.getInstance().getFactionAt(new FLocation(follower)));
if (follower.getFaction() == faction) {
follower.msg(TL.COMMAND_DISBAND_BROADCAST_YOURS, amountString);
} else {

View File

@ -21,7 +21,6 @@ public class CmdShowClaims extends FCommand {
this.senderMustBePlayer = true;
}
@Override

View File

@ -99,7 +99,7 @@ public class CmdTnt extends FCommand {
return;
}
if (fme.getFaction().getTnt() < amount) {
fme.msg(TL.COMMAND_TNT_WIDTHDRAW_NOTENOUGH);
fme.msg(TL.COMMAND_TNT_WIDTHDRAW_NOTENOUGH.toString());
return;
}
int fullStacks = amount / 64;

View File

@ -45,8 +45,7 @@ public abstract class FCommand extends MCommand<SavageFactions> {
}
@Override
public void setCommandSender(CommandSender sender)
{
public void setCommandSender(CommandSender sender) {
super.setCommandSender(sender);
if (sender instanceof Player) {
this.fme = FPlayers.getInstance().getByPlayer((Player) sender);

View File

@ -11,9 +11,9 @@ import org.bukkit.event.Cancellable;
*/
public class FactionDisbandEvent extends FactionEvent implements Cancellable {
private boolean cancelled = false;
private final Player sender;
private final PlayerDisbandReason reason;
private boolean cancelled = false;
public FactionDisbandEvent(Player sender, String factionId, PlayerDisbandReason reason) {
super(Factions.getInstance().getFactionById(factionId));

View File

@ -1,9 +1,8 @@
package com.massivecraft.factions.event;
import org.bukkit.event.Cancellable;
import com.massivecraft.factions.FPlayer;
import com.massivecraft.factions.Faction;
import org.bukkit.event.Cancellable;
/**
* Event called when a player regenerate power.

View File

@ -4,9 +4,9 @@ import com.massivecraft.factions.zcore.util.TL;
public interface EconomyParticipator extends RelationParticipator {
public String getAccountId();
String getAccountId();
public void msg(String str, Object... args);
void msg(String str, Object... args);
public void msg(TL translation, Object... args);
void msg(TL translation, Object... args);
}

View File

@ -5,13 +5,13 @@ import org.bukkit.ChatColor;
public interface RelationParticipator {
public String describeTo(RelationParticipator that);
String describeTo(RelationParticipator that);
public String describeTo(RelationParticipator that, boolean ucfirst);
String describeTo(RelationParticipator that, boolean ucfirst);
public Relation getRelationTo(RelationParticipator that);
Relation getRelationTo(RelationParticipator that);
public Relation getRelationTo(RelationParticipator that, boolean ignorePeaceful);
Relation getRelationTo(RelationParticipator that, boolean ignorePeaceful);
public ChatColor getColorTo(RelationParticipator to);
ChatColor getColorTo(RelationParticipator to);
}

View File

@ -3,11 +3,7 @@ package com.massivecraft.factions.integration;
import com.earth2me.essentials.Teleport;
import com.earth2me.essentials.Trade;
import com.massivecraft.factions.Conf;
import net.ess3.api.IEssentials;
import java.math.BigDecimal;
import org.bukkit.Bukkit;
import org.bukkit.ChatColor;
import org.bukkit.Location;
@ -15,6 +11,8 @@ import org.bukkit.entity.Player;
import org.bukkit.event.player.PlayerTeleportEvent.TeleportCause;
import org.bukkit.plugin.Plugin;
import java.math.BigDecimal;
public class Essentials {
private static IEssentials essentials;

View File

@ -45,7 +45,8 @@ public class EngineDynmap {
public MarkerAPI markerApi;
public MarkerSet markerset;
private EngineDynmap() {}
private EngineDynmap() {
}
public static EngineDynmap getInstance() {
return i;

View File

@ -10,8 +10,8 @@ public class TempAreaMarker {
public String label;
public String world;
public double x[];
public double z[];
public double[] x;
public double[] z;
public String description;
public int lineColor;
@ -27,7 +27,7 @@ public class TempAreaMarker {
// CREATE
// -------------------------------------------- //
public static boolean equals(AreaMarker marker, double x[], double z[]) {
public static boolean equals(AreaMarker marker, double[] x, double[] z) {
int length = marker.getCornerCount();
if (x.length != length) {

View File

@ -9,7 +9,6 @@ import com.massivecraft.factions.util.Particles.ParticleEffect;
import com.massivecraft.factions.zcore.fperms.Access;
import com.massivecraft.factions.zcore.fperms.PermissableAction;
import com.massivecraft.factions.zcore.util.TL;
import org.bukkit.Bukkit;
import org.bukkit.Location;
import org.bukkit.Material;
@ -507,13 +506,10 @@ public class FactionsBlockListener implements Listener {
}
@EventHandler
public void onFarmLandDamage(EntityChangeBlockEvent event)
{
if (event.getEntity() instanceof Player)
{
public void onFarmLandDamage(EntityChangeBlockEvent event) {
if (event.getEntity() instanceof Player) {
Player player = (Player) event.getEntity();
if (!playerCanBuildDestroyBlock(player, event.getBlock().getLocation(), PermissableAction.DESTROY.name(), true))
{
if (!playerCanBuildDestroyBlock(player, event.getBlock().getLocation(), PermissableAction.DESTROY.name(), true)) {
FPlayer me = FPlayers.getInstance().getById(player.getUniqueId().toString());
Faction otherFaction = Board.getInstance().getFactionAt(new FLocation(event.getBlock().getLocation()));
Faction myFaction = me.getFaction();

View File

@ -1,5 +1,6 @@
package com.massivecraft.factions.listeners;
import com.earth2me.essentials.User;
import com.massivecraft.factions.*;
import com.massivecraft.factions.cmd.CmdFly;
import com.massivecraft.factions.cmd.CmdSeeChunk;
@ -23,6 +24,7 @@ import com.massivecraft.factions.zcore.util.TextUtil;
import net.coreprotect.CoreProtect;
import net.coreprotect.CoreProtectAPI;
import org.bukkit.Bukkit;
import org.bukkit.ChatColor;
import org.bukkit.Location;
import org.bukkit.Material;
import org.bukkit.block.Block;
@ -648,6 +650,93 @@ public class FactionsPlayerListener implements Listener {
}
}
//For Blocking Homes and Blocking Teleportation To Homes
@EventHandler
public void onPlayerHomeCheck(PlayerTeleportEvent event) throws Exception {
if (event.getPlayer().hasPermission("factions.homes.bypass")) {
return;
}
boolean isHome = false;
for (String str : SavageFactions.plugin.ess.getUser(event.getPlayer()).getHomes()) {
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()) {
isHome = true;
}
}
if (!isHome) {
return;
}
Location loc = event.getTo();
FLocation floc = new FLocation(event.getTo());
Faction fac = Board.getInstance().getFactionAt(floc);
Player player = event.getPlayer();
FPlayer fplayer = FPlayers.getInstance().getByPlayer(player);
User user = SavageFactions.plugin.ess.getUser(event.getPlayer());
List<String> homes = user.getHomes();
if (fac.isWilderness() || FPlayers.getInstance().getByPlayer(event.getPlayer()).getFactionId().equals(fac.getId())) {
return;
}
//Warzone and SafeZone Home Initializers
if (fac.isWarZone() || fac.isSafeZone() && SavageFactions.plugin.getConfig().getBoolean("deny-homes-in-system-factions")) {
event.setCancelled(true);
fplayer.msg(TL.COMMAND_HOME_BLOCKED, fac.getTag());
if (SavageFactions.plugin.getConfig().getBoolean("remove-homes-in-system-factions"))
for (String s : homes) {
if (user.getHome(s).getBlock().getLocation().getChunk().equals(loc.getChunk())) {
user.delHome(s);
}
}
}
if (fplayer.getFaction().getRelationTo(fac) == Relation.ENEMY && SavageFactions.plugin.getConfig().getBoolean("deny-homes-in-enemy-factions")) {
event.setCancelled(true);
fplayer.msg(TL.COMMAND_HOME_BLOCKED, fac.getTag());
if (SavageFactions.plugin.getConfig().getBoolean("remove-homes-in-enemy-factions"))
for (String s : homes) {
if (user.getHome(s).getBlock().getLocation().getChunk().equals(loc.getChunk())) {
user.delHome(s);
}
}
}
if (fplayer.getFaction().getRelationTo(fac) == Relation.NEUTRAL && SavageFactions.plugin.getConfig().getBoolean("deny-homes-in-neutral-factions")) {
event.setCancelled(true);
fplayer.msg(TL.COMMAND_HOME_BLOCKED, fac.getTag());
if (SavageFactions.plugin.getConfig().getBoolean("remove-homes-in-neutral-factions"))
for (String s : homes) {
if (user.getHome(s).getBlock().getLocation().getChunk().equals(loc.getChunk())) {
user.delHome(s);
}
}
}
if (fplayer.getFaction().getRelationTo(fac) == Relation.ALLY && SavageFactions.plugin.getConfig().getBoolean("deny-homes-in-ally-factions")) {
event.setCancelled(true);
fplayer.msg(TL.COMMAND_HOME_BLOCKED, fac.getTag());
if (SavageFactions.plugin.getConfig().getBoolean("remove-homes-in-ally-factions"))
for (String s : homes) {
if (user.getHome(s).getBlock().getLocation().getChunk().equals(loc.getChunk())) {
user.delHome(s);
}
}
}
if (fplayer.getFaction().getRelationTo(fac) == Relation.TRUCE && SavageFactions.plugin.getConfig().getBoolean("deny-homes-in-truce-factions")) {
event.setCancelled(true);
fplayer.msg(TL.COMMAND_HOME_BLOCKED, fac.getTag());
if (SavageFactions.plugin.getConfig().getBoolean("remove-homes-in-truce-factions"))
for (String s : homes) {
if (user.getHome(s).getBlock().getLocation().getChunk().equals(loc.getChunk())) {
user.delHome(s);
}
}
}
}
//Colors a String
public String color(String s) {
return ChatColor.translateAlternateColorCodes('&', s);
}
private String convertTime(int time) {
String result = String.valueOf(Math.round((System.currentTimeMillis() / 1000L - time) / 36.0D) / 100.0D);
return (result.length() == 3 ? result + "0" : result) + "/hrs ago";
@ -859,15 +948,12 @@ public class FactionsPlayerListener implements Listener {
}
@EventHandler
public void onPlayerBoneMeal(PlayerInteractEvent event)
{
public void onPlayerBoneMeal(PlayerInteractEvent event) {
Block block = event.getClickedBlock();
if (event.getAction() == Action.RIGHT_CLICK_BLOCK && block.getType() == Material.GRASS_BLOCK
&& event.hasItem() && event.getItem().getType() == Material.BONE_MEAL)
{
if (!FactionsBlockListener.playerCanBuildDestroyBlock(event.getPlayer(), block.getLocation(), PermissableAction.BUILD.name(), true))
{
&& event.hasItem() && event.getItem().getType() == Material.BONE_MEAL) {
if (!FactionsBlockListener.playerCanBuildDestroyBlock(event.getPlayer(), block.getLocation(), PermissableAction.BUILD.name(), true)) {
FPlayer me = FPlayers.getInstance().getById(event.getPlayer().getUniqueId().toString());
Faction otherFaction = Board.getInstance().getFactionAt(new FLocation(block.getLocation()));
Faction myFaction = me.getFaction();

View File

@ -96,13 +96,17 @@ public enum Relation implements Permissable {
public ChatColor getColor() {
switch (this)
{
case MEMBER: return Conf.colorMember;
case ALLY: return Conf.colorAlly;
case NEUTRAL: return Conf.colorNeutral;
case TRUCE: return Conf.colorTruce;
default: return Conf.colorEnemy;
switch (this) {
case MEMBER:
return Conf.colorMember;
case ALLY:
return Conf.colorAlly;
case NEUTRAL:
return Conf.colorNeutral;
case TRUCE:
return Conf.colorTruce;
default:
return Conf.colorEnemy;
}
}

View File

@ -93,13 +93,17 @@ public enum Role implements Permissable {
public String getPrefix() {
switch (this)
{
case LEADER: return Conf.prefixLeader;
case COLEADER: return Conf.prefixCoLeader;
case MODERATOR: return Conf.prefixMod;
case NORMAL: return Conf.prefixNormal;
case RECRUIT: return Conf.prefixRecruit;
switch (this) {
case LEADER:
return Conf.prefixLeader;
case COLEADER:
return Conf.prefixCoLeader;
case MODERATOR:
return Conf.prefixMod;
case NORMAL:
return Conf.prefixNormal;
case RECRUIT:
return Conf.prefixRecruit;
}
return "";

View File

@ -107,7 +107,7 @@ public class ClipPlaceholderAPIManager extends PlaceholderExpansion implements R
case "faction_claims":
return String.valueOf(faction.getAllClaims().size());
case "faction_founded":
return String.valueOf(TL.sdf.format(faction.getFoundedDate()));
return TL.sdf.format(faction.getFoundedDate());
case "faction_joining":
return (faction.getOpen() ? TL.COMMAND_SHOW_UNINVITED.toString() : TL.COMMAND_SHOW_INVITATION.toString());
case "faction_peaceful":

View File

@ -4,8 +4,8 @@ import org.bukkit.event.inventory.ClickType;
public interface FactionGUI {
public void onClick(int slot, ClickType action);
void onClick(int slot, ClickType action);
public void build();
void build();
}

View File

@ -100,11 +100,21 @@ public class MiscUtil {
}
switch (player.getRole()) {
case LEADER: admins.add(player); break;
case COLEADER: admins.add(player); break;
case MODERATOR: moderators.add(player); break;
case NORMAL: normal.add(player); break;
case RECRUIT: recruit.add(player); break;
case LEADER:
admins.add(player);
break;
case COLEADER:
admins.add(player);
break;
case MODERATOR:
moderators.add(player);
break;
case NORMAL:
normal.add(player);
break;
case RECRUIT:
recruit.add(player);
break;
}
}

View File

@ -20,7 +20,7 @@ import java.util.Map.Entry;
/**
* <b>ParticleEffect Library</b>
* This library was created by @DarkBlade12 and allows you to display all Minecraft particle effects on a Bukkit server
*
* <p>
* You are welcome to use it, modify it and redistribute it under the following conditions:
* <ul>
* <li>Don't claim this class as your own
@ -524,7 +524,6 @@ public enum ParticleEffect {
/**
* Determine if this particle effect has a specific property
*
*
* @param property - property to check.
* @return Whether it has the property or not
*/
@ -1177,7 +1176,7 @@ public enum ParticleEffect {
/**
* Represents the color for the {@link ParticleEffect#NOTE} effect
*
* <p>
* This class is part of the <b>ParticleEffect Library</b> and follows the same usage conditions
*
* @author DarkBlade12
@ -1236,7 +1235,7 @@ public enum ParticleEffect {
/**
* Represents a runtime exception that is thrown either if the displayed particle effect requires data and has none or vice-versa or if the data type is incorrect
*
* <p>
* This class is part of the <b>ParticleEffect Library</b> and follows the same usage conditions
*
* @author DarkBlade12
@ -1257,7 +1256,7 @@ public enum ParticleEffect {
/**
* Represents a runtime exception that is thrown either if the displayed particle effect is not colorable or if the particle color type is incorrect
*
* <p>
* This class is part of the <b>ParticleEffect Library</b> and follows the same usage conditions
*
* @author DarkBlade12
@ -1278,7 +1277,7 @@ public enum ParticleEffect {
/**
* Represents a runtime exception that is thrown if the displayed particle effect requires a newer version
*
* <p>
* This class is part of the <b>ParticleEffect Library</b> and follows the same usage conditions
*
* @author DarkBlade12
@ -1299,7 +1298,7 @@ public enum ParticleEffect {
/**
* Represents a particle effect packet with all attributes which is used for sending packets to the players
*
* <p>
* This class is part of the <b>ParticleEffect Library</b> and follows the same usage conditions
*
* @author DarkBlade12
@ -1532,7 +1531,7 @@ public enum ParticleEffect {
/**
* Represents a runtime exception that is thrown if a bukkit version is not compatible with this library
*
* <p>
* This class is part of the <b>ParticleEffect Library</b> and follows the same usage conditions
*
* @author DarkBlade12
@ -1554,7 +1553,7 @@ public enum ParticleEffect {
/**
* Represents a runtime exception that is thrown if packet instantiation fails
*
* <p>
* This class is part of the <b>ParticleEffect Library</b> and follows the same usage conditions
*
* @author DarkBlade12
@ -1576,7 +1575,7 @@ public enum ParticleEffect {
/**
* Represents a runtime exception that is thrown if packet sending fails
*
* <p>
* This class is part of the <b>ParticleEffect Library</b> and follows the same usage conditions
*
* @author DarkBlade12

View File

@ -11,9 +11,9 @@ import java.util.Map;
/**
* <b>ReflectionUtils</b>
*
* <p>
* This class provides useful methods which makes dealing with reflection much easier, especially when working with Bukkit
*
* <p>
* You are welcome to use it, modify it and redistribute it under the following conditions:
* <ul>
* <li>Don't claim this class as your own
@ -346,7 +346,7 @@ public final class ReflectionUtils {
/**
* Represents an enumeration of dynamic packages of NMS and CraftBukkit
*
* <p>
* This class is part of the <b>ReflectionUtils</b> and follows the same usage conditions
*
* @author DarkBlade12
@ -433,7 +433,7 @@ public final class ReflectionUtils {
/**
* Represents an enumeration of Java data types with corresponding classes
*
* <p>
* This class is part of the <b>ReflectionUtils</b> and follows the same usage conditions
*
* @author DarkBlade12

View File

@ -0,0 +1,114 @@
package com.massivecraft.factions.util;
import com.massivecraft.factions.FPlayer;
import com.massivecraft.factions.Faction;
import com.massivecraft.factions.SavageFactions;
import com.massivecraft.factions.struct.Relation;
import com.massivecraft.factions.zcore.util.TL;
import org.bukkit.Bukkit;
import java.util.ArrayList;
import java.util.Iterator;
public class UtilFly {
public static ArrayList<FPlayer> playersFlying;
static {
playersFlying = SavageFactions.playersFlying;
}
public UtilFly() {
}
public static void run() {
if (SavageFactions.plugin.getConfig().getBoolean("enable-faction-flight")) {
playersFlying.clear();
Bukkit.getScheduler().scheduleSyncRepeatingTask(SavageFactions.plugin, new Runnable() {
public void run() {
Iterator var2 = UtilFly.playersFlying.iterator();
while (var2.hasNext()) {
FPlayer fp = (FPlayer) var2.next();
if (fp != null) {
fp.checkIfNearbyEnemies();
}
}
}
}, 0L, (long) SavageFactions.plugin.getConfig().getInt("fly-task-interval", 10));
}
}
public static void setFly(FPlayer fp, boolean fly, boolean silent, boolean damage) {
if (SavageFactions.plugin.getConfig().getBoolean("enable-faction-flight")) {
fp.getPlayer().setAllowFlight(fly);
fp.getPlayer().setFlying(fly);
fp.setFlying(fly);
if (fly) {
playersFlying.add(fp);
} else {
playersFlying.remove(fp);
}
if (!silent) {
if (!damage) {
fp.msg(TL.COMMAND_FLY_CHANGE, fly ? "enabled" : "disabled");
} else {
fp.msg(TL.COMMAND_FLY_DAMAGE);
}
}
setFallDamage(fp, fly, damage);
}
}
public static void checkFly(FPlayer me, Faction factionTo) {
if (SavageFactions.plugin.getConfig().getBoolean("enable-faction-flight")) {
if (!me.isAdminBypassing() || !me.isFlying()) {
Relation relationTo;
if (!me.isFlying()) {
if (me.isAdminBypassing()) {
setFly(me, true, false, false);
return;
}
if (factionTo == me.getFaction() && me.getPlayer().hasPermission("factions.fly")) {
setFly(me, true, false, false);
} else {
relationTo = factionTo.getRelationTo(me);
if (factionTo.isWilderness() && me.canflyinWilderness() || factionTo.isWarZone() && me.canflyinWarzone() || factionTo.isSafeZone() && me.canflyinSafezone() || relationTo == Relation.ENEMY && me.canflyinEnemy() || relationTo == Relation.ALLY && me.canflyinAlly() || relationTo == Relation.TRUCE && me.canflyinTruce() || relationTo == Relation.NEUTRAL && me.canflyinNeutral()) {
setFly(me, true, false, false);
}
}
} else {
relationTo = factionTo.getRelationTo(me);
if (factionTo.equals(me.getFaction()) && !me.getPlayer().hasPermission("factions.fly") || factionTo.isWilderness() && !me.canflyinWilderness() || factionTo.isWarZone() && !me.canflyinWarzone() || factionTo.isSafeZone() && !me.canflyinSafezone() || relationTo == Relation.ENEMY && !me.canflyinEnemy() || relationTo == Relation.ALLY && !me.canflyinAlly() || relationTo == Relation.TRUCE && !me.canflyinTruce() || relationTo == Relation.NEUTRAL && !me.canflyinNeutral()) {
setFly(me, false, false, false);
}
}
}
}
}
public static void setFallDamage(final FPlayer fp, boolean fly, boolean damage) {
if (!fly) {
if (!damage) {
fp.sendMessage(TL.COMMAND_FLY_COOLDOWN.toString().replace("{amount}", String.valueOf(SavageFactions.plugin.getConfig().getInt("fly-falldamage-cooldown", 3))));
}
int cooldown = SavageFactions.plugin.getConfig().getInt("fly-falldamage-cooldown", 3);
if (cooldown > 0) {
fp.setTakeFallDamage(false);
Bukkit.getScheduler().runTaskLater(SavageFactions.plugin, new Runnable() {
public void run() {
fp.setTakeFallDamage(true);
}
}, 20L * (long) cooldown);
}
}
}
}

View File

@ -12,7 +12,7 @@ public class WarmUpUtil {
* @param action The action, inserted into the notification message.
* @param runnable The task to run after the delay. If the delay is 0, the task is instantly ran.
* @param delay The time used, in seconds, for the delay.
*
* <p>
* note: for translations: %s = action, %d = delay
*/
public static void process(final FPlayer player, Warmup warmup, TL translationKey, String action, final Runnable runnable, long delay) {

View File

@ -85,8 +85,7 @@ public abstract class MCommand<T extends MPlugin> {
public abstract TL getUsageTranslation();
public void setCommandSender(CommandSender sender)
{
public void setCommandSender(CommandSender sender) {
this.sender = sender;
if (sender instanceof Player) {
this.me = (Player) sender;

View File

@ -4,10 +4,10 @@ import org.bukkit.inventory.ItemStack;
public interface Permissable {
public ItemStack buildItem();
ItemStack buildItem();
public String replacePlaceholders(String string);
String replacePlaceholders(String string);
public String name();
String name();
}

View File

@ -109,11 +109,16 @@ public enum PermissableAction {
String accessValue = null;
switch (access)
{
case ALLOW: accessValue = "allow"; break;
case DENY: accessValue = "deny"; break;
case UNDEFINED: accessValue = "undefined"; break;
switch (access) {
case ALLOW:
accessValue = "allow";
break;
case DENY:
accessValue = "deny";
break;
case UNDEFINED:
accessValue = "undefined";
break;
}
// If under the 1.13 version we will use the colorable option.

View File

@ -27,15 +27,19 @@ public class CropUpgrades implements Listener {
if (level != 0) {
int chance = -1;
switch (level)
{
case 1: chance = SavageFactions.plugin.getConfig().getInt("fupgrades.MainMenu.Crops.Crop-Boost.level-1"); break;
case 2: chance = SavageFactions.plugin.getConfig().getInt("fupgrades.MainMenu.Crops.Crop-Boost.level-2"); break;
case 3: chance = SavageFactions.plugin.getConfig().getInt("fupgrades.MainMenu.Crops.Crop-Boost.level-3"); break;
switch (level) {
case 1:
chance = SavageFactions.plugin.getConfig().getInt("fupgrades.MainMenu.Crops.Crop-Boost.level-1");
break;
case 2:
chance = SavageFactions.plugin.getConfig().getInt("fupgrades.MainMenu.Crops.Crop-Boost.level-2");
break;
case 3:
chance = SavageFactions.plugin.getConfig().getInt("fupgrades.MainMenu.Crops.Crop-Boost.level-3");
break;
}
if (chance >= 0)
{
if (chance >= 0) {
int randomNum = ThreadLocalRandom.current().nextInt(1, 100 + 1);
if (randomNum <= chance)
growCrop(e);
@ -63,8 +67,7 @@ public class CropUpgrades implements Listener {
above.setType(SavageFactions.plugin.SUGAR_CANE_BLOCK);
}
}
else if (below.getType() == Material.CACTUS) {
} else if (below.getType() == Material.CACTUS) {
Block above = e.getBlock().getLocation().add(0, 1, 0).getBlock();
if (above.getType() == Material.AIR && above.getLocation().add(0, -2, 0).getBlock().getType() != Material.AIR) {

View File

@ -28,11 +28,16 @@ public class EXPUpgrade implements Listener {
double multiplier = -1;
switch (level)
{
case 1: multiplier = SavageFactions.plugin.getConfig().getDouble("fupgrades.MainMenu.EXP.EXP-Boost.level-1"); break;
case 2: multiplier = SavageFactions.plugin.getConfig().getDouble("fupgrades.MainMenu.EXP.EXP-Boost.level-2"); break;
case 3: multiplier = SavageFactions.plugin.getConfig().getDouble("fupgrades.MainMenu.EXP.EXP-Boost.level-3"); break;
switch (level) {
case 1:
multiplier = SavageFactions.plugin.getConfig().getDouble("fupgrades.MainMenu.EXP.EXP-Boost.level-1");
break;
case 2:
multiplier = SavageFactions.plugin.getConfig().getDouble("fupgrades.MainMenu.EXP.EXP-Boost.level-2");
break;
case 3:
multiplier = SavageFactions.plugin.getConfig().getDouble("fupgrades.MainMenu.EXP.EXP-Boost.level-3");
break;
}
if (multiplier >= 0)

View File

@ -74,9 +74,9 @@ public class FUpgradesGUI implements Listener {
if (e.getCurrentItem().equals(cropItem)) {
int cropLevel = fme.getFaction().getUpgrade(Upgrade.CROP);
switch (cropLevel)
{
case 3: return;
switch (cropLevel) {
case 3:
return;
case 2:
upgradeItem(fme, Upgrade.CROP, 3, SavageFactions.plugin.getConfig().getInt("fupgrades.MainMenu.Crops.Cost.level-3"));
break;
@ -87,13 +87,12 @@ public class FUpgradesGUI implements Listener {
upgradeItem(fme, Upgrade.CROP, 1, SavageFactions.plugin.getConfig().getInt("fupgrades.MainMenu.Crops.Cost.level-1"));
break;
}
}
else if (e.getCurrentItem().equals(spawnerItem)) {
} else if (e.getCurrentItem().equals(spawnerItem)) {
int spawnerLevel = fme.getFaction().getUpgrade(Upgrade.SPAWNER);
switch(spawnerLevel)
{
case 3: return;
switch (spawnerLevel) {
case 3:
return;
case 2:
upgradeItem(fme, Upgrade.SPAWNER, 3, SavageFactions.plugin.getConfig().getInt("fupgrades.MainMenu.Spawners.Cost.level-3"));
break;
@ -104,13 +103,12 @@ public class FUpgradesGUI implements Listener {
upgradeItem(fme, Upgrade.SPAWNER, 1, SavageFactions.plugin.getConfig().getInt("fupgrades.MainMenu.Spawners.Cost.level-1"));
break;
}
}
else if (e.getCurrentItem().equals(expItem)) {
} else if (e.getCurrentItem().equals(expItem)) {
int expLevel = fme.getFaction().getUpgrade(Upgrade.EXP);
switch (expLevel)
{
case 3: return;
switch (expLevel) {
case 3:
return;
case 2:
upgradeItem(fme, Upgrade.EXP, 3, SavageFactions.plugin.getConfig().getInt("fupgrades.MainMenu.EXP.Cost.level-3"));
break;
@ -121,27 +119,23 @@ public class FUpgradesGUI implements Listener {
upgradeItem(fme, Upgrade.EXP, 1, SavageFactions.plugin.getConfig().getInt("fupgrades.MainMenu.EXP.Cost.level-1"));
break;
}
}
else if (e.getCurrentItem().equals(chestitem)) {
} else if (e.getCurrentItem().equals(chestitem)) {
int chestLevel = fme.getFaction().getUpgrade(Upgrade.CHEST);
switch (chestLevel)
{
case 3: return;
case 2:
{
switch (chestLevel) {
case 3:
return;
case 2: {
if (upgradeItem(fme, Upgrade.CHEST, 3, SavageFactions.plugin.getConfig().getInt("fupgrades.MainMenu.Chest.Cost.level-3")))
updateChests(fme.getFaction());
break;
}
case 1:
{
case 1: {
if (upgradeItem(fme, Upgrade.CHEST, 2, SavageFactions.plugin.getConfig().getInt("fupgrades.MainMenu.Chest.Cost.level-2")))
updateChests(fme.getFaction());
break;
}
case 0:
{
case 0: {
if (upgradeItem(fme, Upgrade.CHEST, 1, SavageFactions.plugin.getConfig().getInt("fupgrades.MainMenu.Chest.Cost.level-1")))
updateChests(fme.getFaction());
break;
@ -162,11 +156,16 @@ public class FUpgradesGUI implements Listener {
int level = faction.getUpgrade(Upgrade.CHEST);
int size = 1;
switch (level)
{
case 1: size = SavageFactions.plugin.getConfig().getInt("fupgrades.MainMenu.Chest.Chest-Size.level-1"); break;
case 2: size = SavageFactions.plugin.getConfig().getInt("fupgrades.MainMenu.Chest.Chest-Size.level-2"); break;
case 3: size = SavageFactions.plugin.getConfig().getInt("fupgrades.MainMenu.Chest.Chest-Size.level-3"); break;
switch (level) {
case 1:
size = SavageFactions.plugin.getConfig().getInt("fupgrades.MainMenu.Chest.Chest-Size.level-1");
break;
case 2:
size = SavageFactions.plugin.getConfig().getInt("fupgrades.MainMenu.Chest.Chest-Size.level-2");
break;
case 3:
size = SavageFactions.plugin.getConfig().getInt("fupgrades.MainMenu.Chest.Chest-Size.level-3");
break;
}
faction.setChestSize(size * 9);
}
@ -286,8 +285,7 @@ public class FUpgradesGUI implements Listener {
fme.takeMoney(amt);
}
private boolean upgradeItem(FPlayer fme, Upgrade upgrade, int level, int cost)
{
private boolean upgradeItem(FPlayer fme, Upgrade upgrade, int level, int cost) {
if (hasMoney(fme, cost)) {
takeMoney(fme, cost);
fme.getFaction().setUpgrade(upgrade, level);

View File

@ -18,11 +18,16 @@ public class SpawnerUpgrades implements Listener {
if (!factionAtLoc.isWilderness()) {
int level = factionAtLoc.getUpgrade(Upgrade.SPAWNER);
if (level != 0) {
switch (level)
{
case 1: lowerSpawnerDelay(e, SavageFactions.plugin.getConfig().getInt("fupgrades.MainMenu.Spawners.Spawner-Boost.level-1")); break;
case 2: lowerSpawnerDelay(e, SavageFactions.plugin.getConfig().getInt("fupgrades.MainMenu.Spawners.Spawner-Boost.level-2")); break;
case 3: lowerSpawnerDelay(e, SavageFactions.plugin.getConfig().getInt("fupgrades.MainMenu.Spawners.Spawner-Boost.level-3")); break;
switch (level) {
case 1:
lowerSpawnerDelay(e, SavageFactions.plugin.getConfig().getInt("fupgrades.MainMenu.Spawners.Spawner-Boost.level-1"));
break;
case 2:
lowerSpawnerDelay(e, SavageFactions.plugin.getConfig().getInt("fupgrades.MainMenu.Spawners.Spawner-Boost.level-2"));
break;
case 3:
lowerSpawnerDelay(e, SavageFactions.plugin.getConfig().getInt("fupgrades.MainMenu.Spawners.Spawner-Boost.level-3"));
break;
}
}
}

View File

@ -10,8 +10,8 @@ public class NBTCompound {
private String compundName;
private NBTCompound parent;
protected NBTCompound()
{}
protected NBTCompound() {
}
protected NBTCompound(NBTCompound owner, String name) {
this.compundName = name;

View File

@ -22,8 +22,7 @@ public enum MinecraftVersion {
}
public static MinecraftVersion getVersion() {
if (version == null)
{
if (version == null) {
final String ver = Bukkit.getServer().getClass().getPackage().getName().replace(".", ",").split(",")[3];
System.out.println("[NBTAPI] Found Spigot: " + ver + "!Trying to find NMS support");

View File

@ -2,11 +2,7 @@ package com.massivecraft.factions.zcore.persist;
import com.massivecraft.factions.*;
import com.massivecraft.factions.cmd.CmdFly;
import com.massivecraft.factions.event.FPlayerLeaveEvent;
import com.massivecraft.factions.event.FPlayerStoppedFlying;
import com.massivecraft.factions.event.FactionDisbandEvent;
import com.massivecraft.factions.event.LandClaimEvent;
import com.massivecraft.factions.event.PowerRegenEvent;
import com.massivecraft.factions.event.*;
import com.massivecraft.factions.event.FactionDisbandEvent.PlayerDisbandReason;
import com.massivecraft.factions.iface.EconomyParticipator;
import com.massivecraft.factions.iface.RelationParticipator;
@ -1195,13 +1191,17 @@ public abstract class MemoryFPlayer implements FPlayer {
@Override
public String getRolePrefix() {
switch (getRole())
{
case RECRUIT: return Conf.prefixRecruit;
case NORMAL: return Conf.prefixNormal;
case MODERATOR: return Conf.prefixMod;
case COLEADER: return Conf.prefixCoLeader;
case LEADER: return Conf.prefixLeader;
switch (getRole()) {
case RECRUIT:
return Conf.prefixRecruit;
case NORMAL:
return Conf.prefixNormal;
case MODERATOR:
return Conf.prefixMod;
case COLEADER:
return Conf.prefixCoLeader;
case LEADER:
return Conf.prefixLeader;
}
return null;

View File

@ -196,9 +196,13 @@ public abstract class MemoryFaction implements Faction, EconomyParticipator {
this.maxVaults = value;
}
public String getFocused() { return this.player; }
public String getFocused() {
return this.player;
}
public void setFocused(String fp) { this.player = fp; }
public void setFocused(String fp) {
this.player = fp;
}
public Set<String> getInvites() {
return invites;

View File

@ -43,7 +43,7 @@ public class PermUtil {
* This method tests if me has a certain permission and returns true if me has. Otherwise false
*/
public boolean has(CommandSender me, String perm) {
return me != null ? me.hasPermission(perm):false;
return me != null && me.hasPermission(perm);
}
public boolean has(CommandSender me, String perm, boolean informSenderIfNot) {

View File

@ -317,6 +317,7 @@ public enum TL {
COMMAND_HOME_TOTELEPORT("to teleport to your faction home"),
COMMAND_HOME_FORTELEPORT("for teleporting to your faction home"),
COMMAND_HOME_DESCRIPTION("Teleport to the faction home"),
COMMAND_HOME_BLOCKED("&c&l[!] You may not teleport to a home that is claimed by &b%1$s"),
COMMAND_INSPECT_DISABLED_MSG("&c&l[!]&7 Inspect mode is now &cdisabled."),
COMMAND_INSPECT_DISABLED_NOFAC("&c&l[!]&7 Inspect mode is now &cdisabled,&7 because you &cdo not have a faction!"),

View File

@ -629,6 +629,7 @@ fperm-gui:
name: ' '
lore:
-
############################################################
# +------------------------------------------------------+ #
# | Faction Warp GUI | #
@ -692,6 +693,30 @@ fwarp-gui:
lore:
-
############################################################
# +------------------------------------------------------+ #
# | Faction Homes Essentials | #
# +------------------------------------------------------+ #
############################################################
# Warzone/SafeZone
deny-homes-in-system-factions: false
remove-homes-in-system-factions: false
deny-homes-in-enemy-factions: false
remove-homes-in-enemy-factions: false
deny-homes-in-neutral-factions: false
remove-homes-in-neutral-factions: false
deny-homes-in-ally-factions: false
remove-homes-in-ally-factions: false
deny-homes-in-truce-factions: false
remove-homes-in-truce-factions: false
############################################################
# +------------------------------------------------------+ #
# | Faction Creation/Disband Broadcast | #

View File

@ -150,6 +150,8 @@ permissions:
description: display a help page
factions.home:
description: teleport to the faction home
factions.homes.bypass:
description: bypass all home teleports
factions.invite:
description: invite a player to your faction
factions.join: