Code Cleanup & Fix With Fly Unclaiming

This commit is contained in:
Driftay 2020-05-27 23:40:46 -04:00
parent 3e530487d7
commit e84c69f2b0
43 changed files with 1915 additions and 2292 deletions

View File

@ -57,7 +57,7 @@ public class CmdAdmin extends FCommand {
return;
}
if(fyou.isAlt()){
if (fyou.isAlt()) {
return;
}
@ -90,7 +90,7 @@ public class CmdAdmin extends FCommand {
FactionsPlugin.instance.getFlogManager().log(targetFaction, FLogType.RANK_EDIT, context.fPlayer.getName(), fyou.getName(), ChatColor.RED + "Admin");
// Inform all players
if(FactionsPlugin.instance.getConfig().getBoolean("faction-leader-broadcast")) {
if (FactionsPlugin.instance.getConfig().getBoolean("faction-leader-broadcast")) {
for (FPlayer fplayer : FPlayers.getInstance().getOnlinePlayers()) {
fplayer.msg(TL.COMMAND_ADMIN_PROMOTED, context.player == null ? TL.GENERIC_SERVERADMIN.toString() : context.fPlayer.describeTo(fplayer, true), fyou.describeTo(fplayer), targetFaction.describeTo(fplayer));
}

View File

@ -8,65 +8,60 @@ import com.massivecraft.factions.zcore.fperms.Access;
import com.massivecraft.factions.zcore.fperms.PermissableAction;
import com.massivecraft.factions.zcore.util.TL;
public class CmdCheckpoint extends FCommand
{
public class CmdCheckpoint extends FCommand {
/**
* @author Illyria Team
*/
/**
* @author Illyria Team
*/
public CmdCheckpoint()
{
super();
this.aliases.addAll(Aliases.checkpoint);
public CmdCheckpoint() {
super();
this.aliases.addAll(Aliases.checkpoint);
this.optionalArgs.put("set", "");
this.optionalArgs.put("set", "");
this.requirements = new CommandRequirements.Builder(Permission.CHECKPOINT).playerOnly().memberOnly().build();
}
this.requirements = new CommandRequirements.Builder(Permission.CHECKPOINT).playerOnly().memberOnly().build();
}
@Override
@Override
public void perform(CommandContext context) {
if (!FactionsPlugin.getInstance().getConfig().getBoolean("checkpoints.Enabled")) {
context.msg(TL.COMMAND_CHECKPOINT_DISABLED);
return;
}
if (context.args.size() == 1 && context.args.get(0).equalsIgnoreCase("set")) {
if (context.fPlayer.getRole() == Role.LEADER)
{
FLocation myLocation = new FLocation(context.player.getLocation());
Faction myLocFaction = Board.getInstance().getFactionAt(myLocation);
if (myLocFaction == Factions.getInstance().getWilderness() || myLocFaction == context.faction) {
context.faction.setCheckpoint(context.player.getLocation());
context.msg(TL.COMMAND_CHECKPOINT_SET);
return;
}
} else {
context.msg(TL.COMMAND_CHECKPOINT_INVALIDLOCATION);
if (context.fPlayer.getRole() == Role.LEADER) {
FLocation myLocation = new FLocation(context.player.getLocation());
Faction myLocFaction = Board.getInstance().getFactionAt(myLocation);
if (myLocFaction == Factions.getInstance().getWilderness() || myLocFaction == context.faction) {
context.faction.setCheckpoint(context.player.getLocation());
context.msg(TL.COMMAND_CHECKPOINT_SET);
return;
}
PermissableAction action = PermissableAction.SETWARP;
Access access = context.faction.getAccess(context.fPlayer, action);
if (access == Access.DENY) {
context.msg(TL.GENERIC_FPERM_NOPERMISSION, action.getName());
} else {
context.msg(TL.COMMAND_CHECKPOINT_INVALIDLOCATION);
return;
}
else
{
FLocation myLocation = new FLocation(context.player.getLocation());
Faction myLocFaction = Board.getInstance().getFactionAt(myLocation);
if (myLocFaction == Factions.getInstance().getWilderness() || myLocFaction == context.faction) {
context.faction.setCheckpoint(context.player.getLocation());
context.msg(TL.COMMAND_CHECKPOINT_SET);
return;
}else {
PermissableAction action = PermissableAction.SETWARP;
Access access = context.faction.getAccess(context.fPlayer, action);
if (access == Access.DENY) {
context.msg(TL.GENERIC_FPERM_NOPERMISSION, action.getName());
return;
} else {
FLocation myLocation = new FLocation(context.player.getLocation());
Faction myLocFaction = Board.getInstance().getFactionAt(myLocation);
if (myLocFaction == Factions.getInstance().getWilderness() || myLocFaction == context.faction) {
context.faction.setCheckpoint(context.player.getLocation());
context.msg(TL.COMMAND_CHECKPOINT_SET);
return;
} else {
context.msg(TL.COMMAND_CHECKPOINT_INVALIDLOCATION);
return;
}
}
}
if (context.faction.getCheckpoint() == null) {
context.msg(TL.COMMAND_CHECKPOINT_NOT_SET);
return;
@ -85,9 +80,8 @@ public class CmdCheckpoint extends FCommand
}
}
@Override
public TL getUsageTranslation()
{
return TL.COMMAND_CHECKPOINT_DESCRIPTION;
}
@Override
public TL getUsageTranslation() {
return TL.COMMAND_CHECKPOINT_DESCRIPTION;
}
}

View File

@ -55,7 +55,7 @@ public class CmdColeader extends FCommand {
return;
}
if(you.isAlt()){
if (you.isAlt()) {
return;
}

View File

@ -54,7 +54,7 @@ public class CmdCreate extends FCommand {
return;
}
if(Cooldown.isOnCooldown(context.fPlayer.getPlayer(), "createCooldown") && !context.fPlayer.isAdminBypassing()){
if (Cooldown.isOnCooldown(context.fPlayer.getPlayer(), "createCooldown") && !context.fPlayer.isAdminBypassing()) {
context.msg(TL.COMMAND_COOLDOWN);
return;
}

View File

@ -3,10 +3,7 @@ package com.massivecraft.factions.cmd;
import com.massivecraft.factions.Conf;
import com.massivecraft.factions.FPlayer;
import com.massivecraft.factions.FPlayers;
import com.massivecraft.factions.FactionsPlugin;
import com.massivecraft.factions.struct.Permission;
import com.massivecraft.factions.struct.Role;
import com.massivecraft.factions.zcore.fperms.Access;
import com.massivecraft.factions.zcore.fperms.PermissableAction;
import com.massivecraft.factions.zcore.util.TL;
import mkremins.fanciful.FancyMessage;
@ -56,6 +53,7 @@ public class CmdDeinvite extends FCommand {
context.faction.msg(TL.COMMAND_DEINVITE_REVOKES, context.fPlayer.describeTo(context.faction), you.describeTo(context.faction));
}
@Override
public TL getUsageTranslation() {
return TL.COMMAND_DEINVITE_DESCRIPTION;

View File

@ -70,7 +70,7 @@ public class CmdDisband extends FCommand {
return;
}
if(Cooldown.isOnCooldown(context.fPlayer.getPlayer(), "disbandCooldown") && !context.fPlayer.isAdminBypassing()){
if (Cooldown.isOnCooldown(context.fPlayer.getPlayer(), "disbandCooldown") && !context.fPlayer.isAdminBypassing()) {
context.msg(TL.COMMAND_COOLDOWN);
return;
}

View File

@ -19,6 +19,7 @@ import java.util.concurrent.ConcurrentHashMap;
public class CmdFly extends FCommand {
public static final boolean fly = FactionsPlugin.getInstance().getConfig().getBoolean("enable-faction-flight");
/**
* @author FactionsUUID Team
*/
@ -27,8 +28,6 @@ public class CmdFly extends FCommand {
public static ConcurrentHashMap<String, Boolean> flyMap = new ConcurrentHashMap<>();
public static BukkitTask particleTask = null;
public static final boolean fly = FactionsPlugin.getInstance().getConfig().getBoolean("enable-faction-flight");
public CmdFly() {
super();
@ -65,25 +64,25 @@ public class CmdFly extends FCommand {
if (toFac != fme.getFaction()) {
if (!me.hasPermission(Permission.FLY_WILDERNESS.node) && toFac.isWilderness() || !me.hasPermission(Permission.FLY_SAFEZONE.node) && toFac.isSafeZone() || !me.hasPermission(Permission.FLY_WARZONE.node) && toFac.isWarZone()) {
if(sendMessage) fme.msg(TL.COMMAND_FLY_NO_ACCESS, toFac.getTag(fme));
if (sendMessage) fme.msg(TL.COMMAND_FLY_NO_ACCESS, toFac.getTag(fme));
return false;
}
Access access = toFac.getAccess(fme, PermissableAction.FLY);
if ((!(me.hasPermission(Permission.FLY_ENEMY.node) || access == Access.ALLOW)) && toFac.getRelationTo(fme.getFaction()) == Relation.ENEMY) {
if(sendMessage) fme.msg(TL.COMMAND_FLY_NO_ACCESS, toFac.getTag(fme));
if (sendMessage) fme.msg(TL.COMMAND_FLY_NO_ACCESS, toFac.getTag(fme));
return false;
}
if (!(me.hasPermission(Permission.FLY_ALLY.node) || access == Access.ALLOW) && toFac.getRelationTo(fme.getFaction()) == Relation.ALLY) {
if(sendMessage) fme.msg(TL.COMMAND_FLY_NO_ACCESS, toFac.getTag(fme));
if (sendMessage) fme.msg(TL.COMMAND_FLY_NO_ACCESS, toFac.getTag(fme));
return false;
}
if (!(me.hasPermission(Permission.FLY_TRUCE.node) || access == Access.ALLOW) && toFac.getRelationTo(fme.getFaction()) == Relation.TRUCE) {
if(sendMessage) fme.msg(TL.COMMAND_FLY_NO_ACCESS, toFac.getTag(fme));
if (sendMessage) fme.msg(TL.COMMAND_FLY_NO_ACCESS, toFac.getTag(fme));
return false;
}
if (!(me.hasPermission(Permission.FLY_NEUTRAL.node) || access == Access.ALLOW) && toFac.getRelationTo(fme.getFaction()) == Relation.NEUTRAL && !toFac.isSystemFaction()) {
if(sendMessage) fme.msg(TL.COMMAND_FLY_NO_ACCESS, toFac.getTag(fme));
if (sendMessage) fme.msg(TL.COMMAND_FLY_NO_ACCESS, toFac.getTag(fme));
return false;
}
return me.hasPermission(Permission.FLY_FLY.node) && (access != Access.DENY || toFac.isSystemFaction());

View File

@ -11,7 +11,7 @@ import com.massivecraft.factions.zcore.util.TL;
*/
public class CmdFriendlyFire extends FCommand {
public CmdFriendlyFire(){
public CmdFriendlyFire() {
super();
this.aliases.addAll(Aliases.friendlyFire);
@ -23,12 +23,12 @@ public class CmdFriendlyFire extends FCommand {
@Override
public void perform(CommandContext context) {
if(!Conf.friendlyFireFPlayersCommand){
if (!Conf.friendlyFireFPlayersCommand) {
context.msg(TL.GENERIC_DISABLED, "friendly fire");
return;
}
if(context.fPlayer.hasFriendlyFire()){
if (context.fPlayer.hasFriendlyFire()) {
context.fPlayer.setFriendlyFire(false);
context.msg(TL.COMMAND_FRIENDLY_FIRE_TOGGLE_OFF);
} else {

View File

@ -9,7 +9,6 @@ import com.massivecraft.factions.util.CC;
import com.massivecraft.factions.zcore.fperms.PermissableAction;
import com.massivecraft.factions.zcore.util.TL;
import mkremins.fanciful.FancyMessage;
import org.bukkit.ChatColor;
public class CmdInvite extends FCommand {
@ -61,9 +60,9 @@ public class CmdInvite extends FCommand {
if (target.isOnline()) {
// Tooltips, colors, and commands only apply to the string immediately before it.
FancyMessage message = new FancyMessage(TL.COMMAND_INVITE_INVITEDYOU.toString()
.replace("%1$s", context.fPlayer.describeTo(target, true))
.replace("%2$s", context.faction.getTag())
.replaceAll("&", "§"))
.replace("%1$s", context.fPlayer.describeTo(target, true))
.replace("%2$s", context.faction.getTag())
.replaceAll("&", "§"))
.tooltip(TL.COMMAND_INVITE_CLICKTOJOIN.toString())
.command("/" + Conf.baseCommandAliases.get(0) + " join " + context.faction.getTag());
message.send(target.getPlayer());

View File

@ -1,19 +1,12 @@
package com.massivecraft.factions.cmd;
import com.massivecraft.factions.*;
import com.massivecraft.factions.cmd.audit.FLogType;
import com.massivecraft.factions.discord.Discord;
import com.massivecraft.factions.event.FPlayerJoinEvent;
import com.massivecraft.factions.struct.Permission;
import com.massivecraft.factions.util.CC;
import com.massivecraft.factions.zcore.frame.fupgrades.UpgradeType;
import com.massivecraft.factions.zcore.util.TL;
import net.dv8tion.jda.core.entities.Member;
import net.dv8tion.jda.core.exceptions.HierarchyException;
import org.bukkit.Bukkit;
import java.util.Objects;
public class CmdJoin extends FCommand {
public CmdJoin() {

View File

@ -1,6 +1,9 @@
package com.massivecraft.factions.cmd;
import com.massivecraft.factions.*;
import com.massivecraft.factions.Conf;
import com.massivecraft.factions.FPlayer;
import com.massivecraft.factions.Faction;
import com.massivecraft.factions.FactionsPlugin;
import com.massivecraft.factions.cmd.audit.FLogType;
import com.massivecraft.factions.event.FPlayerLeaveEvent;
import com.massivecraft.factions.struct.Permission;
@ -125,7 +128,7 @@ public class CmdKick extends FCommand {
FactionsPlugin.instance.logFactionEvent(toKickFaction, FLogType.INVITES, context.fPlayer.getName(), CC.Red + "kicked", toKick.getName());
toKickFaction.deinvite(toKick);
toKick.resetFactionData();
if(!CmdFly.checkBypassPerms(toKick, toKick.getPlayer(), toKickFaction, false)){
if (!CmdFly.checkBypassPerms(toKick, toKick.getPlayer(), toKickFaction, false)) {
CmdFly.disableFlight(toKick);
}
}

View File

@ -50,7 +50,7 @@ public class CmdMod extends FCommand {
return;
}
if(you.isAlt()){
if (you.isAlt()) {
return;
}

View File

@ -39,7 +39,7 @@ public class CmdOpen extends FCommand {
String open = context.faction.getOpen() ? TL.COMMAND_OPEN_OPEN.toString() : TL.COMMAND_OPEN_CLOSED.toString();
if(Cooldown.isOnCooldown(context.fPlayer.getPlayer(), "openCooldown") && !context.fPlayer.isAdminBypassing()){
if (Cooldown.isOnCooldown(context.fPlayer.getPlayer(), "openCooldown") && !context.fPlayer.isAdminBypassing()) {
context.msg(TL.COMMAND_COOLDOWN);
return;
}
@ -51,7 +51,7 @@ public class CmdOpen extends FCommand {
Cooldown.setCooldown(fplayer.getPlayer(), "openCooldown", FactionsPlugin.getInstance().getConfig().getInt("fcooldowns.f-open"));
continue;
}
if(FactionsPlugin.getInstance().getConfig().getBoolean("faction-open-broadcast")) return;
if (FactionsPlugin.getInstance().getConfig().getBoolean("faction-open-broadcast")) return;
fplayer.msg(TL.COMMAND_OPEN_CHANGED, context.faction.getTag(fplayer.getFaction()), open);
}
});

View File

@ -54,7 +54,7 @@ public class CmdTag extends FCommand {
return;
}
if(Cooldown.isOnCooldown(context.player, "tagCooldown") && !context.fPlayer.isAdminBypassing()){
if (Cooldown.isOnCooldown(context.player, "tagCooldown") && !context.fPlayer.isAdminBypassing()) {
context.msg(TL.COMMAND_COOLDOWN);
return;
}
@ -72,7 +72,6 @@ public class CmdTag extends FCommand {
}
String oldtag = context.faction.getTag();
context.faction.setTag(tag);

View File

@ -5,7 +5,6 @@ import com.massivecraft.factions.struct.Permission;
import com.massivecraft.factions.zcore.fperms.Access;
import com.massivecraft.factions.zcore.fperms.PermissableAction;
import com.massivecraft.factions.zcore.util.TL;
import org.bukkit.Material;
public class CmdUnban extends FCommand {

View File

@ -83,10 +83,13 @@ public class CmdUnclaim extends FCommand {
this.stop();
return false;
}
return true;
}
};
boolean didUnClaim = unClaim(new FLocation(context.player), context);
if (didUnClaim && !context.fPlayer.canFlyAtLocation())
context.fPlayer.setFFlying(false, false);
}
}

View File

@ -57,14 +57,8 @@ public class CmdUnclaimall extends FCommand {
}
if (Econ.shouldBeUsed()) {
double refund = Econ.calculateTotalLandRefund(target.getLandRounded());
if (Conf.bankEnabled && Conf.bankFactionPaysLandCosts) {
if (!Econ.modifyMoney(target, refund, TL.COMMAND_UNCLAIMALL_TOUNCLAIM.toString(), TL.COMMAND_UNCLAIMALL_FORUNCLAIM.toString())) {
return;
}
} else {
if (!Econ.modifyMoney(target, refund, TL.COMMAND_UNCLAIMALL_TOUNCLAIM.toString(), TL.COMMAND_UNCLAIMALL_FORUNCLAIM.toString())) {
return;
}
if (!Econ.modifyMoney(target, refund, TL.COMMAND_UNCLAIMALL_TOUNCLAIM.toString(), TL.COMMAND_UNCLAIMALL_FORUNCLAIM.toString())) {
return;
}
}

View File

@ -37,7 +37,7 @@ public class CmdGrace extends FCommand {
return;
}
if(context.args.size() == 1) {
if (context.args.size() == 1) {
if (context.sender.hasPermission(String.valueOf(Permission.GRACETOGGLE))) {
if (context.argAsString(0).equalsIgnoreCase("on") || context.argAsString(0).equalsIgnoreCase("start")) {
FactionsPlugin.getInstance().getTimerManager().graceTimer.setPaused(false);
@ -61,7 +61,7 @@ public class CmdGrace extends FCommand {
}
}
if(FactionsPlugin.getInstance().getTimerManager().graceTimer.getRemaining() <= 0L) {
if (FactionsPlugin.getInstance().getTimerManager().graceTimer.getRemaining() <= 0L) {
context.fPlayer.msg(TL.COMMAND_GRACE_DISABLED_NO_FORMAT.toString());
} else {
context.fPlayer.msg(TL.COMMAND_GRACE_TIME_REMAINING, String.valueOf(TimerManager.getRemaining(FactionsPlugin.getInstance().getTimerManager().graceTimer.getRemaining(), true)));

View File

@ -41,7 +41,7 @@ public abstract class FRelationCommand extends FCommand {
Faction them = context.argAsFaction(0);
if (them == null) return;
if(!context.faction.isNormal()) return;
if (!context.faction.isNormal()) return;
if (!them.isNormal()) {
context.msg(TL.COMMAND_RELATIONS_ALLTHENOPE);

View File

@ -74,7 +74,7 @@ public class FPromoteCommand extends FCommand {
}
}
if(target.isAlt()){
if (target.isAlt()) {
return;
}

View File

@ -48,7 +48,8 @@ public class Econ {
}
econ = rsp.getProvider();
FactionsPlugin.getInstance().log("Economy integration through Vault plugin successful.");
if (!Conf.econEnabled) FactionsPlugin.getInstance().log("NOTE: Economy is disabled. You can enable it with the command: f config econEnabled true");
if (!Conf.econEnabled)
FactionsPlugin.getInstance().log("NOTE: Economy is disabled. You can enable it with the command: f config econEnabled true");
//FactionsPlugin.getInstance().cmdBase.cmdHelp.updateHelp();
}

View File

@ -1,151 +1,129 @@
package com.massivecraft.factions.integration.dynmap;
import java.awt.Point;
import java.util.ArrayList;
import java.util.List;
import org.dynmap.markers.AreaMarker;
import org.dynmap.markers.MarkerSet;
public class TempAreaMarker
{
import java.awt.*;
import java.util.ArrayList;
import java.util.List;
/**
* @author FactionsUUID Team
*/
public class TempAreaMarker {
// -------------------------------------------- //
// FIELDS
// -------------------------------------------- //
/**
* @author FactionsUUID Team
*/
public String label;
public String world;
public double[] x;
public double[] z;
// -------------------------------------------- //
// FIELDS
// -------------------------------------------- //
private List<List<Point>> polyLine = new ArrayList<List<Point>>();
public String label;
public String world;
public double[] x;
public double[] z;
public String description;
public int lineColor;
public double lineOpacity;
public int lineWeight;
public int fillColor;
public double fillOpacity;
public boolean boost;
private List<List<Point>> polyLine = new ArrayList<List<Point>>();
public String description;
// -------------------------------------------- //
// CREATE
// -------------------------------------------- //
public int lineColor;
public double lineOpacity;
public int lineWeight;
public static boolean equals(AreaMarker marker, double[] x, double[] z) {
int length = marker.getCornerCount();
public int fillColor;
public double fillOpacity;
if (x.length != length) {
return false;
}
if (z.length != length) {
return false;
}
public boolean boost;
for (int i = 0; i < length; i++) {
if (marker.getCornerX(i) != x[i]) {
return false;
}
if (marker.getCornerZ(i) != z[i]) {
return false;
}
}
// -------------------------------------------- //
// CREATE
// -------------------------------------------- //
return true;
}
public static boolean equals(AreaMarker marker, double[] x, double[] z)
{
int length = marker.getCornerCount();
public List<List<Point>> getPolyLine() {
return polyLine;
}
if (x.length != length)
{
return false;
}
if (z.length != length)
{
return false;
}
public void setPolyLine(List<List<Point>> points) {
polyLine.clear();
polyLine.addAll(points);
}
for (int i = 0; i < length; i++)
{
if (marker.getCornerX(i) != x[i])
{
return false;
}
if (marker.getCornerZ(i) != z[i])
{
return false;
}
}
// -------------------------------------------- //
// UPDATE
// -------------------------------------------- //
return true;
}
public AreaMarker create(MarkerSet markerset, String markerId) {
AreaMarker ret = markerset.createAreaMarker(markerId, this.label, false, this.world, this.x, this.z, false // not persistent
);
if (ret == null) {
return null;
}
public void setPolyLine(List<List<Point>> points)
{
polyLine.clear();
polyLine.addAll(points);
}
int counter = 0;
public List<List<Point>> getPolyLine()
{
return polyLine;
}
// Description
ret.setDescription(this.description);
// -------------------------------------------- //
// UPDATE
// -------------------------------------------- //
// Line Style
ret.setLineStyle(0, 0, 0);
public AreaMarker create(MarkerSet markerset, String markerId)
{
AreaMarker ret = markerset.createAreaMarker(markerId, this.label, false, this.world, this.x, this.z, false // not persistent
);
if (ret == null)
{
return null;
}
// Fill Style
ret.setFillStyle(this.fillOpacity, this.fillColor);
int counter = 0;
// Boost Flag
ret.setBoostFlag(this.boost);
// Description
ret.setDescription(this.description);
return ret;
}
// -------------------------------------------- //
// UTIL
// -------------------------------------------- //
// Line Style
ret.setLineStyle(0, 0, 0);
public void update(AreaMarker marker) {
// Corner Locations
if (!equals(marker, this.x, this.z)) {
marker.setCornerLocations(this.x, this.z);
}
// Fill Style
ret.setFillStyle(this.fillOpacity, this.fillColor);
// Label
if (!marker.getLabel().equals(this.label)) {
marker.setLabel(this.label);
}
if (!marker.getDescription().equals(this.description)) {
marker.setDescription(this.description);
}
// Boost Flag
ret.setBoostFlag(this.boost);
// // Line Style
// if (marker.getLineWeight() != this.lineWeight || marker.getLineOpacity() != this.lineOpacity || marker.getLineColor() != this.lineColor)
// {
// marker.setLineStyle(this.lineWeight, this.lineOpacity, this.lineColor);
// }
return ret;
}
// -------------------------------------------- //
// UTIL
// -------------------------------------------- //
public void update(AreaMarker marker)
{
// Corner Locations
if (!equals(marker, this.x, this.z))
{
marker.setCornerLocations(this.x, this.z);
}
// Label
if (!marker.getLabel().equals(this.label))
{
marker.setLabel(this.label);
}
if (!marker.getDescription().equals(this.description))
{
marker.setDescription(this.description);
}
// // Line Style
// if (marker.getLineWeight() != this.lineWeight || marker.getLineOpacity() != this.lineOpacity || marker.getLineColor() != this.lineColor)
// {
// marker.setLineStyle(this.lineWeight, this.lineOpacity, this.lineColor);
// }
// Fill Style
if ((marker.getFillOpacity() != this.fillOpacity) || (marker.getFillColor() != this.fillColor))
{
marker.setFillStyle(this.fillOpacity, this.fillColor);
}
// Boost Flag
if (marker.getBoostFlag() != this.boost)
{
marker.setBoostFlag(this.boost);
}
}
// Fill Style
if ((marker.getFillOpacity() != this.fillOpacity) || (marker.getFillColor() != this.fillColor)) {
marker.setFillStyle(this.fillOpacity, this.fillColor);
}
// Boost Flag
if (marker.getBoostFlag() != this.boost) {
marker.setBoostFlag(this.boost);
}
}
}

View File

@ -1,62 +1,49 @@
package com.massivecraft.factions.integration.dynmap;
import java.awt.Point;
import java.awt.*;
import java.util.ArrayList;
import java.util.List;
public class TempLine
{
private Point p1;
private Point p2;
private List<TempLine> connectedLines = new ArrayList<TempLine>();
public class TempLine {
private Point p1;
private Point p2;
private List<TempLine> connectedLines = new ArrayList<TempLine>();
TempLine(Point p1, Point p2)
{
this.p1 = p1;
this.p2 = p2;
TempLine(Point p1, Point p2) {
this.p1 = p1;
this.p2 = p2;
}
public Point getP1() {
return p1;
}
public Point getP2() {
return p2;
}
public void addAdditionLines(List<TempLine> connectedLines) {
this.connectedLines = connectedLines;
}
public List<TempLine> getConnectedLines() {
return connectedLines;
}
@Override
public boolean equals(Object o) {
TempLine line = (TempLine) o;
if (line.p1.x == this.p1.x && line.p2.x == this.p2.x && line.p1.y == this.p1.y && line.p2.y == this.p2.y) {
return true;
}
return line.p1.x == this.p2.x && line.p2.x == this.p1.x && line.p1.y == this.p2.y && line.p2.y == this.p1.y;
}
public Point getP1()
{
return p1;
}
public Point getP2()
{
return p2;
}
public void addAdditionLines(List<TempLine> connectedLines)
{
this.connectedLines = connectedLines;
}
public List<TempLine> getConnectedLines()
{
return connectedLines;
}
@Override
public boolean equals(Object o)
{
TempLine line = (TempLine) o;
if (line.p1.x == this.p1.x && line.p2.x == this.p2.x && line.p1.y == this.p1.y && line.p2.y == this.p2.y)
{
return true;
}
if (line.p1.x == this.p2.x && line.p2.x == this.p1.x && line.p1.y == this.p2.y && line.p2.y == this.p1.y)
{
return true;
}
return false;
}
@Override
public int hashCode()
{
String test = "" + (p1.x + p2.x);
test += " " + (p1.y + p2.y);
return test.hashCode();
}
@Override
public int hashCode() {
String test = "" + (p1.x + p2.x);
test += " " + (p1.y + p2.y);
return test.hashCode();
}
}

View File

@ -1,111 +1,99 @@
package com.massivecraft.factions.integration.dynmap;
import java.awt.Point;
import java.util.ArrayList;
import java.util.List;
import org.dynmap.markers.MarkerSet;
import org.dynmap.markers.PolyLineMarker;
public class TempPolyLineMarker
{
import java.awt.*;
import java.util.ArrayList;
import java.util.List;
/**
* @author FactionsUUID Team
*/
public class TempPolyLineMarker {
// -------------------------------------------- //
// FIELDS
// -------------------------------------------- //
/**
* @author FactionsUUID Team
*/
public String world;
// -------------------------------------------- //
// FIELDS
// -------------------------------------------- //
public List<Point> polyLine = new ArrayList<Point>();
public String world;
public int lineColor;
public double lineOpacity;
public int lineWeight;
public List<Point> polyLine = new ArrayList<Point>();
// -------------------------------------------- //
// CREATE
// -------------------------------------------- //
public int lineColor;
public double lineOpacity;
public int lineWeight;
public static boolean equals(PolyLineMarker marker, List<Point> points)
{
int length = marker.getCornerCount();
// -------------------------------------------- //
// CREATE
// -------------------------------------------- //
if (points.size() != length)
{
return false;
}
for (int i = 0; i < length; i++)
{
if (marker.getCornerX(i) != points.get(i).x)
{
return false;
}
if (marker.getCornerZ(i) != points.get(i).y)
{
return false;
}
}
public static boolean equals(PolyLineMarker marker, List<Point> points) {
int length = marker.getCornerCount();
return true;
}
if (points.size() != length) {
return false;
}
for (int i = 0; i < length; i++) {
if (marker.getCornerX(i) != points.get(i).x) {
return false;
}
if (marker.getCornerZ(i) != points.get(i).y) {
return false;
}
}
// -------------------------------------------- //
// UPDATE
// -------------------------------------------- //
return true;
}
public PolyLineMarker create(MarkerSet markerset, String markerId)
{
double[] polyX = new double[polyLine.size()];
double[] polyY = new double[polyLine.size()];
double[] polyZ = new double[polyLine.size()];
for (int i = 0; i < polyLine.size(); i++)
{
Point p = polyLine.get(i);
polyX[i] = p.getX();
polyY[i] = 64;
polyZ[i] = p.getY();
}
PolyLineMarker poly = markerset.createPolyLineMarker(markerId, "", false, this.world, polyX, polyY, polyZ, false);
// Poly Line Style
if (poly != null)
{
poly.setLineStyle(this.lineWeight, this.lineOpacity, this.lineColor);
}
return poly;
}
// -------------------------------------------- //
// UPDATE
// -------------------------------------------- //
// -------------------------------------------- //
// UTIL
// -------------------------------------------- //
public PolyLineMarker create(MarkerSet markerset, String markerId) {
double[] polyX = new double[polyLine.size()];
double[] polyY = new double[polyLine.size()];
double[] polyZ = new double[polyLine.size()];
for (int i = 0; i < polyLine.size(); i++) {
Point p = polyLine.get(i);
polyX[i] = p.getX();
polyY[i] = 64;
polyZ[i] = p.getY();
}
PolyLineMarker poly = markerset.createPolyLineMarker(markerId, "", false, this.world, polyX, polyY, polyZ, false);
// Poly Line Style
if (poly != null) {
poly.setLineStyle(this.lineWeight, this.lineOpacity, this.lineColor);
}
return poly;
}
public void update(PolyLineMarker marker)
{
// Corner Locations
if (!equals(marker, polyLine))
{
double[] polyX = new double[polyLine.size()];
double[] polyY = new double[polyLine.size()];
double[] polyZ = new double[polyLine.size()];
for (int i = 0; i < polyLine.size(); i++)
{
Point p = polyLine.get(i);
polyX[i] = p.getX();
polyY[i] = 64;
polyZ[i] = p.getY();
}
marker.setCornerLocations(polyX, polyY, polyZ);
marker.setLineStyle(this.lineWeight, this.lineOpacity, this.lineColor);
}
// -------------------------------------------- //
// UTIL
// -------------------------------------------- //
// Line Style
if (marker.getLineWeight() != this.lineWeight || marker.getLineOpacity() != this.lineOpacity || marker.getLineColor() != this.lineColor)
{
marker.setLineStyle(this.lineWeight, this.lineOpacity, this.lineColor);
}
public void update(PolyLineMarker marker) {
// Corner Locations
if (!equals(marker, polyLine)) {
double[] polyX = new double[polyLine.size()];
double[] polyY = new double[polyLine.size()];
double[] polyZ = new double[polyLine.size()];
for (int i = 0; i < polyLine.size(); i++) {
Point p = polyLine.get(i);
polyX[i] = p.getX();
polyY[i] = 64;
polyZ[i] = p.getY();
}
marker.setCornerLocations(polyX, polyY, polyZ);
marker.setLineStyle(this.lineWeight, this.lineOpacity, this.lineColor);
}
}
// Line Style
if (marker.getLineWeight() != this.lineWeight || marker.getLineOpacity() != this.lineOpacity || marker.getLineColor() != this.lineColor) {
marker.setLineStyle(this.lineWeight, this.lineOpacity, this.lineColor);
}
}
}

View File

@ -4,7 +4,6 @@ import com.massivecraft.factions.*;
import com.massivecraft.factions.event.PowerLossEvent;
import com.massivecraft.factions.struct.Relation;
import com.massivecraft.factions.util.MiscUtil;
import com.massivecraft.factions.util.timer.type.GraceTimer;
import com.massivecraft.factions.zcore.fperms.PermissableAction;
import com.massivecraft.factions.zcore.util.TL;
import org.bukkit.Bukkit;

View File

@ -4,7 +4,6 @@ import com.massivecraft.factions.*;
import com.massivecraft.factions.cmd.CmdFGlobal;
import com.massivecraft.factions.cmd.CmdFly;
import com.massivecraft.factions.cmd.CmdSeeChunk;
import com.massivecraft.factions.cmd.FCmdRoot;
import com.massivecraft.factions.cmd.audit.FLogType;
import com.massivecraft.factions.cmd.logout.LogoutHandler;
import com.massivecraft.factions.cmd.wild.CmdWild;
@ -36,8 +35,6 @@ import net.dv8tion.jda.core.entities.Member;
import net.dv8tion.jda.core.entities.TextChannel;
import org.bukkit.*;
import org.bukkit.block.Block;
import org.bukkit.entity.Boat;
import org.bukkit.entity.Minecart;
import org.bukkit.entity.Player;
import org.bukkit.event.Event;
import org.bukkit.event.EventHandler;
@ -57,7 +54,9 @@ import java.util.logging.Level;
public class FactionsPlayerListener implements Listener {
public final static Map<UUID, Location> lastLocations = new HashMap<>();
public static Set<FLocation> corners;
public static BukkitTask positionTask = null;
/**
* @author FactionsUUID Team
*/
@ -655,9 +654,6 @@ public class FactionsPlayerListener implements Listener {
return (result.length() == 3 ? result + "0" : result) + "/hrs ago";
}
public static BukkitTask positionTask = null;
public final static Map<UUID, Location> lastLocations = new HashMap<>();
public void startPositionCheck() {
positionTask = Bukkit.getScheduler().runTaskTimer(FactionsPlugin.getInstance(), () -> {
if (lastLocations.isEmpty()) return;
@ -741,7 +737,8 @@ public class FactionsPlayerListener implements Listener {
me.attemptClaim(me.getAutoClaimFor(), newLocation, true);
}
FactionsPlugin.instance.logFactionEvent(me.getAutoClaimFor(), FLogType.CHUNK_CLAIMS, me.getName(), CC.GreenB + "CLAIMED", String.valueOf(1), (new FLocation(player.getLocation())).formatXAndZ(","));
if (Conf.disableFlightOnFactionClaimChange && FactionsPlugin.getInstance().getConfig().getBoolean("enable-faction-flight")) CmdFly.disableFlight(me);
if (Conf.disableFlightOnFactionClaimChange && FactionsPlugin.getInstance().getConfig().getBoolean("enable-faction-flight"))
CmdFly.disableFlight(me);
} else if (me.isAutoSafeClaimEnabled()) {
if (!Permission.MANAGE_SAFE_ZONE.has(player)) {

View File

@ -26,205 +26,166 @@ import java.util.Set;
import java.util.logging.Level;
import java.util.stream.Collectors;
public class ShopGUIFrame
{
public class ShopGUIFrame {
/**
* @author Driftay
*/
/**
* @author Driftay
*/
private Gui gui;
private Gui gui;
public ShopGUIFrame(Faction f)
{
gui = new Gui(FactionsPlugin.getInstance(), FactionsPlugin.getInstance().getConfig().getInt("F-Shop.GUI.Rows", 4), FactionsPlugin.getInstance().color(FactionsPlugin.getInstance().getConfig().getString("F-Shop.GUI.Name")));
}
public ShopGUIFrame(Faction f) {
gui = new Gui(FactionsPlugin.getInstance(), FactionsPlugin.getInstance().getConfig().getInt("F-Shop.GUI.Rows", 4), FactionsPlugin.getInstance().color(FactionsPlugin.getInstance().getConfig().getString("F-Shop.GUI.Name")));
}
public void buildGUI(FPlayer fplayer)
{
PaginatedPane pane = new PaginatedPane(0, 0, 9, gui.getRows());
List<GuiItem> GUIItems = new ArrayList<>();
ItemStack dummy = buildDummyItem(fplayer.getFaction());
for (int x = 0; x <= (gui.getRows() * 9) - 1; x++)
GUIItems.add(new GuiItem(dummy, e -> e.setCancelled(true)));
public void buildGUI(FPlayer fplayer) {
PaginatedPane pane = new PaginatedPane(0, 0, 9, gui.getRows());
List<GuiItem> GUIItems = new ArrayList<>();
ItemStack dummy = buildDummyItem(fplayer.getFaction());
for (int x = 0; x <= (gui.getRows() * 9) - 1; x++)
GUIItems.add(new GuiItem(dummy, e -> e.setCancelled(true)));
Set<String> items = FactionsPlugin.getInstance().getFileManager().getShop().getConfig().getConfigurationSection("items").getKeys(false);
for (String s : items)
{
if (!checkShopConfig(s))
{
continue;
}
Set<String> items = FactionsPlugin.getInstance().getFileManager().getShop().getConfig().getConfigurationSection("items").getKeys(false);
for (String s : items) {
if (!checkShopConfig(s)) {
continue;
}
int slot = FactionsPlugin.getInstance().getFileManager().getShop().fetchInt("items." + s + ".slot");
ItemStack item = XMaterial.matchXMaterial(FactionsPlugin.getInstance().getFileManager().getShop().fetchString("items." + s + ".block")).get().parseItem();
int cost = FactionsPlugin.getInstance().getFileManager().getShop().fetchInt("items." + s + ".cost");
String name = FactionsPlugin.getInstance().getFileManager().getShop().fetchString("items." + s + ".name");
boolean glowing = FactionsPlugin.getInstance().getFileManager().getShop().fetchBoolean("items." + s + ".glowing");
List<String> lore = FactionsPlugin.getInstance().getFileManager().getShop().fetchStringList("items." + s + ".lore");
int slot = FactionsPlugin.getInstance().getFileManager().getShop().fetchInt("items." + s + ".slot");
ItemStack item = XMaterial.matchXMaterial(FactionsPlugin.getInstance().getFileManager().getShop().fetchString("items." + s + ".block")).get().parseItem();
int cost = FactionsPlugin.getInstance().getFileManager().getShop().fetchInt("items." + s + ".cost");
String name = FactionsPlugin.getInstance().getFileManager().getShop().fetchString("items." + s + ".name");
boolean glowing = FactionsPlugin.getInstance().getFileManager().getShop().fetchBoolean("items." + s + ".glowing");
List<String> lore = FactionsPlugin.getInstance().getFileManager().getShop().fetchStringList("items." + s + ".lore");
assert item != null;
ItemMeta meta = item.getItemMeta();
meta.setDisplayName(FactionsPlugin.instance.color(name));
meta.addItemFlags();
if (glowing)
{
meta.addItemFlags(ItemFlag.HIDE_ENCHANTS);
meta.addEnchant(Enchantment.DURABILITY, 1, true);
}
if (!glowing)
meta.removeEnchant(Enchantment.DURABILITY);
List<String> replacedLore = lore.stream().map(t -> t.replace("{cost}", cost + "")).collect(Collectors.toList());
meta.setLore(FactionsPlugin.instance.colorList(replacedLore));
item.setItemMeta(meta);
GUIItems.set(slot, new GuiItem(item, e ->
{
e.setCancelled(true);
FPlayer fme = FPlayers.getInstance().getByPlayer((Player) e.getWhoClicked());
if (fplayer.getFaction().getPoints() >= cost)
{
if (runCommands(FactionsPlugin.getInstance().getFileManager().getShop().fetchStringList("items." + s + ".cmds"), fplayer.getPlayer()))
{
fplayer.getFaction().setPoints(fplayer.getFaction().getPoints() - cost);
for (FPlayer fplayerBuy : fplayer.getFaction().getFPlayers())
{
fplayerBuy.getPlayer().sendMessage(TL.SHOP_BOUGHT_BROADCAST_FACTION.toString().replace("{player}", fplayer.getPlayer().getName()).replace("{item}", ChatColor.stripColor(FactionsPlugin.getInstance().color(name)))
.replace("{cost}", cost + ""));
}
buildGUI(fme);
}
else
{
fplayer.msg(TL.SHOP_ERROR_DURING_PURCHASE);
}
}
else
{
fplayer.msg(TL.SHOP_NOT_ENOUGH_POINTS);
}
}));
pane.populateWithGuiItems(GUIItems);
gui.addPane(pane);
gui.update();
gui.show(fplayer.getPlayer());
}
}
assert item != null;
ItemMeta meta = item.getItemMeta();
meta.setDisplayName(FactionsPlugin.instance.color(name));
meta.addItemFlags();
if (glowing) {
meta.addItemFlags(ItemFlag.HIDE_ENCHANTS);
meta.addEnchant(Enchantment.DURABILITY, 1, true);
}
if (!glowing)
meta.removeEnchant(Enchantment.DURABILITY);
List<String> replacedLore = lore.stream().map(t -> t.replace("{cost}", cost + "")).collect(Collectors.toList());
meta.setLore(FactionsPlugin.instance.colorList(replacedLore));
item.setItemMeta(meta);
GUIItems.set(slot, new GuiItem(item, e ->
{
e.setCancelled(true);
FPlayer fme = FPlayers.getInstance().getByPlayer((Player) e.getWhoClicked());
if (fplayer.getFaction().getPoints() >= cost) {
if (runCommands(FactionsPlugin.getInstance().getFileManager().getShop().fetchStringList("items." + s + ".cmds"), fplayer.getPlayer())) {
fplayer.getFaction().setPoints(fplayer.getFaction().getPoints() - cost);
for (FPlayer fplayerBuy : fplayer.getFaction().getFPlayers()) {
fplayerBuy.getPlayer().sendMessage(TL.SHOP_BOUGHT_BROADCAST_FACTION.toString().replace("{player}", fplayer.getPlayer().getName()).replace("{item}", ChatColor.stripColor(FactionsPlugin.getInstance().color(name)))
.replace("{cost}", cost + ""));
}
buildGUI(fme);
} else {
fplayer.msg(TL.SHOP_ERROR_DURING_PURCHASE);
}
} else {
fplayer.msg(TL.SHOP_NOT_ENOUGH_POINTS);
}
}));
pane.populateWithGuiItems(GUIItems);
gui.addPane(pane);
gui.update();
gui.show(fplayer.getPlayer());
}
}
private ItemStack buildDummyItem(Faction f)
{
ConfigurationSection config = FactionsPlugin.getInstance().getConfig().getConfigurationSection("F-Shop.GUI.dummy-item");
ItemStack item = XMaterial.matchXMaterial(config.getString("Type")).get().parseItem();
ItemMeta meta = item.getItemMeta();
if (meta != null)
{
meta.setLore(FactionsPlugin.getInstance().colorList(config.getStringList("Lore")));
meta.setDisplayName(FactionsPlugin.getInstance().color(config.getString("Name").replace("{points}", f.getPoints() + "")));
item.setItemMeta(meta);
}
return item;
}
private ItemStack buildDummyItem(Faction f) {
ConfigurationSection config = FactionsPlugin.getInstance().getConfig().getConfigurationSection("F-Shop.GUI.dummy-item");
ItemStack item = XMaterial.matchXMaterial(config.getString("Type")).get().parseItem();
ItemMeta meta = item.getItemMeta();
if (meta != null) {
meta.setLore(FactionsPlugin.getInstance().colorList(config.getStringList("Lore")));
meta.setDisplayName(FactionsPlugin.getInstance().color(config.getString("Name").replace("{points}", f.getPoints() + "")));
item.setItemMeta(meta);
}
return item;
}
public boolean checkShopConfig()
{
boolean ret = true;
Set<String> items = FactionsPlugin.getInstance().getFileManager().getShop().getConfig().getConfigurationSection("items").getKeys(false);
for (String s : items)
{
if (checkShopConfig(s) == false)
{
ret = false;
}
}
return ret;
}
public boolean checkShopConfig() {
boolean ret = true;
Set<String> items = FactionsPlugin.getInstance().getFileManager().getShop().getConfig().getConfigurationSection("items").getKeys(false);
for (String s : items) {
if (checkShopConfig(s) == false) {
ret = false;
}
}
return ret;
}
public boolean checkShopConfig(String s)
{
boolean ret = true;
if (!FactionsPlugin.getInstance().getFileManager().getShop().containsKey("items." + s + ".slot"))
{
FactionsPlugin.getInstance().log(Level.WARNING, "Problem with config item \'" + s + "\' missing slot variable");
ret = false;
}
if (!FactionsPlugin.getInstance().getFileManager().getShop().containsKey("items." + s + ".block"))
{
FactionsPlugin.getInstance().log(Level.WARNING, "Problem with config item \'" + s + "\' missing block variable");
ret = false;
}
public boolean checkShopConfig(String s) {
boolean ret = true;
if (!FactionsPlugin.getInstance().getFileManager().getShop().containsKey("items." + s + ".slot")) {
FactionsPlugin.getInstance().log(Level.WARNING, "Problem with config item '" + s + "' missing slot variable");
ret = false;
}
if (!FactionsPlugin.getInstance().getFileManager().getShop().containsKey("items." + s + ".block")) {
FactionsPlugin.getInstance().log(Level.WARNING, "Problem with config item '" + s + "' missing block variable");
ret = false;
}
if (!FactionsPlugin.getInstance().getFileManager().getShop().containsKey("items." + s + ".cmds"))
{
FactionsPlugin.getInstance().log(Level.WARNING, "Problee with config item \'" + s + "\' missing cmds variable");
ret = false;
}
if (!FactionsPlugin.getInstance().getFileManager().getShop().containsKey("items." + s + ".cmds")) {
FactionsPlugin.getInstance().log(Level.WARNING, "Problee with config item '" + s + "' missing cmds variable");
ret = false;
}
if (!FactionsPlugin.getInstance().getFileManager().getShop().containsKey("items." + s + ".cost"))
{
FactionsPlugin.getInstance().log(Level.WARNING, "Problem with config item \'" + s + "\' missing cost variable this item will cost 0");
}
if (!FactionsPlugin.getInstance().getFileManager().getShop().containsKey("items." + s + ".name"))
{
FactionsPlugin.getInstance().log(Level.WARNING, "Problem with config item \'" + s + "\' missing name variable");
ret = false;
}
return ret;
}
if (!FactionsPlugin.getInstance().getFileManager().getShop().containsKey("items." + s + ".cost")) {
FactionsPlugin.getInstance().log(Level.WARNING, "Problem with config item '" + s + "' missing cost variable this item will cost 0");
}
if (!FactionsPlugin.getInstance().getFileManager().getShop().containsKey("items." + s + ".name")) {
FactionsPlugin.getInstance().log(Level.WARNING, "Problem with config item '" + s + "' missing name variable");
ret = false;
}
return ret;
}
/**
*
* @param list
* The list of commands to be ran.
* @param p
* The player that is using the shop
* @return if all commands are able to be ran or if they did run.
*/
public boolean runCommands(List<String> list, Player p)
{
for (String cmd : list)
{
cmd = cmd.replace("%player%", p.getName());
if (cmd.toLowerCase().startsWith("give"))
{
String[] args = cmd.split(" ");
if (args.length == 4)
{
Material material = Material.matchMaterial(args[2]);
int amount = Integer.parseInt(args[3]);
Player player = Bukkit.getPlayer(args[1]);
if (!player.isOnline())
{
return false;
}
// See if the player has this item in their inventory;
if (player.getInventory().contains(material) && player.getInventory().firstEmpty() < 0)
{
int spacesAvailable = 0;
Map<Integer, ? extends ItemStack> contents = player.getInventory().all(material);
for (ItemStack stack : contents.values())
{
spacesAvailable += stack.getMaxStackSize() - stack.getAmount();
}
if (spacesAvailable < amount)
{
return false;
}
/**
* @param list The list of commands to be ran.
* @param p The player that is using the shop
* @return if all commands are able to be ran or if they did run.
*/
public boolean runCommands(List<String> list, Player p) {
for (String cmd : list) {
cmd = cmd.replace("%player%", p.getName());
if (cmd.toLowerCase().startsWith("give")) {
String[] args = cmd.split(" ");
if (args.length == 4) {
Material material = Material.matchMaterial(args[2]);
int amount = Integer.parseInt(args[3]);
Player player = Bukkit.getPlayer(args[1]);
if (!player.isOnline()) {
return false;
}
// See if the player has this item in their inventory;
if (player.getInventory().contains(material) && player.getInventory().firstEmpty() < 0) {
int spacesAvailable = 0;
Map<Integer, ? extends ItemStack> contents = player.getInventory().all(material);
for (ItemStack stack : contents.values()) {
spacesAvailable += stack.getMaxStackSize() - stack.getAmount();
}
if (spacesAvailable < amount) {
return false;
}
}
else
{
if (player.getInventory().firstEmpty() < 0)
{
return false;
}
}
}
}
}
for (String cmd : list)
{
cmd = cmd.replace("%player%", p.getName());
Bukkit.dispatchCommand(Bukkit.getConsoleSender(), cmd);
}
return true;
}
} else {
if (player.getInventory().firstEmpty() < 0) {
return false;
}
}
}
}
}
for (String cmd : list) {
cmd = cmd.replace("%player%", p.getName());
Bukkit.dispatchCommand(Bukkit.getConsoleSender(), cmd);
}
return true;
}
}

View File

@ -15,12 +15,15 @@ import org.bukkit.ChatColor;
import org.bukkit.entity.Player;
import java.lang.reflect.InvocationTargetException;
import java.util.Arrays;
import java.util.UUID;
import java.util.logging.Level;
public class ClipPlaceholderAPIManager extends PlaceholderExpansion implements Relational {
private static void logInvalid(String placeholder) {
FactionsPlugin.getInstance().getLogger().log(Level.INFO, "Invalid request through PlaceholderAPI for placeholder '" + placeholder + "'");
}
// Identifier for this expansion
@Override
public String getIdentifier() {
@ -214,7 +217,7 @@ public class ClipPlaceholderAPIManager extends PlaceholderExpansion implements R
case "faction_relation_color":
return fPlayer.getColorTo(faction).toString();
case "grace_time":
if(FactionsPlugin.getInstance().getTimerManager().graceTimer.getRemaining() >= 0) {
if (FactionsPlugin.getInstance().getTimerManager().graceTimer.getRemaining() >= 0) {
return String.valueOf(TimerManager.getRemaining(FactionsPlugin.getInstance().getTimerManager().graceTimer.getRemaining(), true));
} else {
return TL.GRACE_DISABLED_PLACEHOLDER.toString();
@ -249,10 +252,6 @@ public class ClipPlaceholderAPIManager extends PlaceholderExpansion implements R
return TL.PLACEHOLDERAPI_NULL.toString();
}
private static void logInvalid(String placeholder) {
FactionsPlugin.getInstance().getLogger().log(Level.INFO, "Invalid request through PlaceholderAPI for placeholder '" + placeholder + "'");
}
private int countOn(Faction f, Relation relation, Boolean status, FPlayer player) {
int count = 0;
for (Faction faction : Factions.getInstance().getAllFactions()) {

View File

@ -3,7 +3,6 @@ package com.massivecraft.factions.util;
import com.massivecraft.factions.FactionsPlugin;
import org.bukkit.entity.Player;
import org.bukkit.metadata.FixedMetadataValue;
import org.bukkit.metadata.MetadataValue;
import java.util.concurrent.TimeUnit;

View File

@ -1,12 +1,5 @@
package com.massivecraft.factions.util.timer;
import com.massivecraft.factions.util.Config;
import java.util.LinkedHashMap;
import java.util.Map;
import java.util.Set;
import java.util.UUID;
/**
* Factions - Developed by Driftay.
* All rights reserved 2020.

View File

@ -8,8 +8,8 @@ import com.massivecraft.factions.util.Config;
* Creation Date: 4/7/2020
*/
public abstract class Timer {
protected final String name;
public final long defaultCooldown;
protected final String name;
public Timer(String name, long defaultCooldown) {

View File

@ -16,14 +16,24 @@ import java.util.concurrent.TimeUnit;
* Creation Date: 4/7/2020
*/
public class TimerManager implements Listener, Runnable {
private final Set<Timer> timers;
private final FactionsPlugin plugin;
private final List<TimerRunnable> timerRunnableList = new ArrayList<>();
private Config config;
public GraceTimer graceTimer;
private static final long MINUTE = TimeUnit.MINUTES.toMillis(1L);
private static final long HOUR = TimeUnit.HOURS.toMillis(1L);
private static final long MULTI_HOUR = TimeUnit.HOURS.toMillis(10);
private final Set<Timer> timers;
private final FactionsPlugin plugin;
private final List<TimerRunnable> timerRunnableList = new ArrayList<>();
public GraceTimer graceTimer;
private Config config;
public TimerManager(FactionsPlugin plugin) {
this.timers = new HashSet<>();
this.plugin = plugin;
plugin.getServer().getPluginManager().registerEvents(this, plugin);
if (Conf.useGraceSystem) {
this.registerTimer(this.graceTimer = new GraceTimer());
}
plugin.getServer().getScheduler().runTaskTimer(plugin, this, 4, 4);
}
public static String getRemaining(long millis, boolean milliseconds) {
return getRemaining(millis, milliseconds, true);
@ -31,21 +41,11 @@ public class TimerManager implements Listener, Runnable {
public static String getRemaining(long duration, boolean milliseconds, boolean trail) {
if ((milliseconds) && (duration < MINUTE)) {
return ( (trail ? DateTimeFormats.REMAINING_SECONDS_TRAILING : DateTimeFormats.REMAINING_SECONDS).get()).format(duration * 0.001D) + 's';
return ((trail ? DateTimeFormats.REMAINING_SECONDS_TRAILING : DateTimeFormats.REMAINING_SECONDS).get()).format(duration * 0.001D) + 's';
}
return DurationFormatUtils.formatDuration(duration, (duration >= HOUR ? (duration >= MULTI_HOUR ? "d" : "") + "d:" : "") + "HH:mm:ss");
}
public TimerManager(FactionsPlugin plugin) {
this.timers = new HashSet<>();
this.plugin = plugin;
plugin.getServer().getPluginManager().registerEvents(this, plugin);
if(Conf.useGraceSystem) {
this.registerTimer(this.graceTimer = new GraceTimer());
}
plugin.getServer().getScheduler().runTaskTimer(plugin, this, 4, 4);
}
public Collection<Timer> getTimers() {
return this.timers;
}

View File

@ -45,15 +45,13 @@ public class TimerRunnable {
return getRemaining(false);
}
public long getRemaining(long now) {
return getRemaining(false, now);
}
public void setRemaining(long remaining) {
setExpiryMillis(remaining);
}
public long getRemaining(long now) {
return getRemaining(false, now);
}
public long getRemaining(boolean ignorePaused) {
if ((!ignorePaused) && (this.pauseMillis != 0L)) return this.pauseMillis;

View File

@ -26,14 +26,14 @@ public class GraceTimer extends GlobalTimer implements Listener {
@EventHandler
public void onBreak(EntityExplodeEvent e) {
if(getRemaining() > 0)
e.setCancelled(true);
if (getRemaining() > 0)
e.setCancelled(true);
}
@EventHandler
public void onTNTPlace(BlockPlaceEvent event) {
FPlayer fp = FPlayers.getInstance().getByPlayer(event.getPlayer());
if(getRemaining() > 0) {
if (getRemaining() > 0) {
if (!fp.isAdminBypassing()) {
if (event.getBlock().getType().equals(Material.TNT)) {
event.setCancelled(true);

View File

@ -3,7 +3,10 @@ package com.massivecraft.factions.zcore;
import com.google.gson.Gson;
import com.google.gson.GsonBuilder;
import com.google.gson.reflect.TypeToken;
import com.massivecraft.factions.*;
import com.massivecraft.factions.Board;
import com.massivecraft.factions.Conf;
import com.massivecraft.factions.FPlayers;
import com.massivecraft.factions.Factions;
import com.massivecraft.factions.zcore.persist.SaveTask;
import com.massivecraft.factions.zcore.util.PermUtil;
import com.massivecraft.factions.zcore.util.Persist;

View File

@ -55,9 +55,9 @@ public class CustomFile {
e.printStackTrace();
}
}
public boolean containsKey(String key) {
return getCachedObjects().containsKey(key)|| getConfig().contains(key);
return getCachedObjects().containsKey(key) || getConfig().contains(key);
}
public String fetchString(String key) {

View File

@ -6,13 +6,11 @@ import com.github.stefvanschie.inventoryframework.pane.PaginatedPane;
import com.massivecraft.factions.FPlayer;
import com.massivecraft.factions.Faction;
import com.massivecraft.factions.FactionsPlugin;
import com.massivecraft.factions.cmd.audit.FLogType;
import com.massivecraft.factions.util.XMaterial;
import com.massivecraft.factions.zcore.fperms.Access;
import com.massivecraft.factions.zcore.fperms.Permissable;
import com.massivecraft.factions.zcore.fperms.PermissableAction;
import com.massivecraft.factions.zcore.util.TL;
import org.bukkit.ChatColor;
import org.bukkit.configuration.ConfigurationSection;
import org.bukkit.inventory.ItemStack;
import org.bukkit.inventory.meta.ItemMeta;

View File

@ -16,7 +16,6 @@ import org.bukkit.inventory.meta.ItemMeta;
import java.util.ArrayList;
import java.util.List;
import java.util.Objects;
/**
* @author Saser
@ -36,7 +35,8 @@ public class FUpgradeFrame {
PaginatedPane pane = new PaginatedPane(0, 0, 9, this.gui.getRows());
List<GuiItem> GUIItems = new ArrayList<>();
ItemStack dummy = buildDummyItem();
for (int x = 0; x <= this.gui.getRows() * 9 - 1; ++x) GUIItems.add(new GuiItem(dummy, e -> e.setCancelled(true)));
for (int x = 0; x <= this.gui.getRows() * 9 - 1; ++x)
GUIItems.add(new GuiItem(dummy, e -> e.setCancelled(true)));
for (UpgradeType value : UpgradeType.values()) {
if (value.getSlot() != -1) {
GUIItems.set(value.getSlot(), new GuiItem(value.buildAsset(fplayer.getFaction()), e -> {
@ -44,19 +44,19 @@ public class FUpgradeFrame {
FPlayer fme = FPlayers.getInstance().getByPlayer((Player) e.getWhoClicked());
if (fme.getFaction().getUpgrade(value) == value.getMaxLevel()) return;
int cost = FactionsPlugin.getInstance().getConfig().getInt("fupgrades.MainMenu." + value.toString() + ".Cost.level-" + (fme.getFaction().getUpgrade(value) + 1));
if (fme.hasMoney(cost)) {
fme.takeMoney(cost);
if (value == UpgradeType.CHEST) updateChests(fme.getFaction());
if (fme.hasMoney(cost)) {
fme.takeMoney(cost);
if (value == UpgradeType.CHEST) updateChests(fme.getFaction());
if (value == UpgradeType.POWER) updateFactionPowerBoost(fme.getFaction());
if (value == UpgradeType.POWER) updateFactionPowerBoost(fme.getFaction());
if (value == UpgradeType.TNT) updateTNT(fme.getFaction());
if (value == UpgradeType.TNT) updateTNT(fme.getFaction());
if (value == UpgradeType.WARP) updateWarps(fme.getFaction());
if (value == UpgradeType.WARP) updateWarps(fme.getFaction());
fme.getFaction().setUpgrade(value, fme.getFaction().getUpgrade(value) + 1);
buildGUI(fme);
}
fme.getFaction().setUpgrade(value, fme.getFaction().getUpgrade(value) + 1);
buildGUI(fme);
}
}));
}
}

View File

@ -28,7 +28,7 @@ public class UpgradesListener implements Listener {
if (e.isCancelled()) return;
if (!(e.getDamager() instanceof Player) || !(e.getEntity() instanceof Player)) return;
if(e.getEntity() == null) return;
if (e.getEntity() == null) return;
FPlayer fme = FPlayers.getInstance().getByPlayer((Player) e.getEntity());
FPlayer dame = FPlayers.getInstance().getByPlayer((Player) e.getDamager());
@ -36,7 +36,7 @@ public class UpgradesListener implements Listener {
if (fme == null || dame == null) return;
FLocation floc = new FLocation(fme.getPlayer().getLocation());
if(floc == null) return;
if (floc == null) return;
if (Board.getInstance().getFactionAt(floc) == fme.getFaction()) {
if (dame.getFaction() == fme.getFaction()) return;

View File

@ -738,7 +738,7 @@ public abstract class MemoryFPlayer implements FPlayer {
public void sendFactionHereMessage(Faction from) {
Faction toShow = Board.getInstance().getFactionAt(getLastStoodAt());
if(Conf.worldsNoClaiming.contains(getLastStoodAt().getWorldName())) return;
if (Conf.worldsNoClaiming.contains(getLastStoodAt().getWorldName())) return;
if (showInfoBoard(toShow)) {
FScoreboard.get(this).setTemporarySidebar(new FInfoSidebar(toShow));
@ -860,7 +860,7 @@ public abstract class MemoryFPlayer implements FPlayer {
int factionBuffer = plugin.getConfig().getInt("hcf.buffer-zone", 0);
int worldBuffer = plugin.getConfig().getInt("world-border.buffer", 0) - 1;
if (Conf.worldGuardChecking && Worldguard.getInstance().checkForRegionsInChunk(flocation)) {
if (Conf.worldGuardChecking && Worldguard.getInstance().checkForRegionsInChunk(flocation)) {
// Checks for WorldGuard regions in the chunk attempting to be claimed
error = plugin.txt.parse(TL.CLAIM_PROTECTED.toString());
} else if (flocation.isOutsideWorldBorder(plugin.getConfig().getInt("world-border.buffer", 0) - 1)) {
@ -873,7 +873,7 @@ public abstract class MemoryFPlayer implements FPlayer {
return true;
} else if (forFaction.isWarZone() && Permission.MANAGE_WAR_ZONE.has(getPlayer())) {
return true;
} else if (currentFaction.getAccess(this, PermissableAction.TERRITORY) == Access.ALLOW && forFaction != currentFaction ) {
} else if (currentFaction.getAccess(this, PermissableAction.TERRITORY) == Access.ALLOW && forFaction != currentFaction) {
return true;
} else if (myFaction != forFaction) {
error = plugin.txt.parse(TL.CLAIM_CANTCLAIM.toString(), forFaction.describeTo(this));
@ -972,39 +972,38 @@ public abstract class MemoryFPlayer implements FPlayer {
}
public void setFFlying(boolean fly, boolean damage) {
if(FactionsPlugin.getInstance().getConfig().getBoolean("enable-faction-flight"))
{
Player player = getPlayer();
if (player == null) return;
player.setAllowFlight(fly);
player.setFlying(fly);
if (!damage) {
msg(TL.COMMAND_FLY_CHANGE, fly ? "enabled" : "disabled");
if (!fly) {
sendMessage(TL.COMMAND_FLY_COOLDOWN.toString().replace("{amount}", FactionsPlugin.getInstance().getConfig().getInt("fly-falldamage-cooldown", 3) + ""));
}
} else {
msg(TL.COMMAND_FLY_DAMAGE);
}
// If leaving fly mode, don't let them take fall damage for x seconds.
if (!fly) {
int cooldown = FactionsPlugin.getInstance().getConfig().getInt("fly-falldamage-cooldown", 3);
CmdFly.flyMap.remove(player.getName());
// If the value is 0 or lower, make them take fall damage.
// Otherwise, start a timer and have this cancel after a few seconds.
// Short task so we're just doing it in method. Not clean but eh.
if (cooldown > 0) {
setTakeFallDamage(false);
Bukkit.getScheduler().runTaskLater(FactionsPlugin.getInstance(), () -> setTakeFallDamage(true), 20L * cooldown);
}
}
isFlying = fly;
}
if (FactionsPlugin.getInstance().getConfig().getBoolean("enable-faction-flight")) {
Player player = getPlayer();
if (player == null) return;
player.setAllowFlight(fly);
player.setFlying(fly);
if (!damage) {
msg(TL.COMMAND_FLY_CHANGE, fly ? "enabled" : "disabled");
if (!fly) {
sendMessage(TL.COMMAND_FLY_COOLDOWN.toString().replace("{amount}", FactionsPlugin.getInstance().getConfig().getInt("fly-falldamage-cooldown", 3) + ""));
}
} else {
msg(TL.COMMAND_FLY_DAMAGE);
}
// If leaving fly mode, don't let them take fall damage for x seconds.
if (!fly) {
int cooldown = FactionsPlugin.getInstance().getConfig().getInt("fly-falldamage-cooldown", 3);
CmdFly.flyMap.remove(player.getName());
// If the value is 0 or lower, make them take fall damage.
// Otherwise, start a timer and have this cancel after a few seconds.
// Short task so we're just doing it in method. Not clean but eh.
if (cooldown > 0) {
setTakeFallDamage(false);
Bukkit.getScheduler().runTaskLater(FactionsPlugin.getInstance(), () -> setTakeFallDamage(true), 20L * cooldown);
}
}
isFlying = fly;
}
}
public boolean isInFactionsChest() {
@ -1223,11 +1222,11 @@ public abstract class MemoryFPlayer implements FPlayer {
}
public boolean hasFriendlyFire(){
public boolean hasFriendlyFire() {
return friendlyFire;
}
public void setFriendlyFire(boolean status){
public void setFriendlyFire(boolean status) {
friendlyFire = status;
}
@ -1305,7 +1304,7 @@ public abstract class MemoryFPlayer implements FPlayer {
// announce success
if(!FactionsPlugin.cachedRadiusClaim) {
if (!FactionsPlugin.cachedRadiusClaim) {
Set<FPlayer> informTheseFPlayers = new HashSet<>();
informTheseFPlayers.add(this);
informTheseFPlayers.addAll(forFaction.getFPlayersWhereOnline(true));

View File

@ -1277,7 +1277,7 @@ public abstract class MemoryFaction implements Faction, EconomyParticipator {
if (Conf.logFactionDisband)
FactionsPlugin.getInstance().log("The faction " + this.getTag() + " (" + this.getId() + ") has been disbanded since it has no members left" + (autoLeave ? " and by inactivity" : "") + ".");
if(FactionsPlugin.getInstance().getConfig().getBoolean("faction-disband-broadcast")) {
if (FactionsPlugin.getInstance().getConfig().getBoolean("faction-disband-broadcast")) {
for (FPlayer fplayer : FPlayers.getInstance().getOnlinePlayers())
fplayer.msg(TL.COMMAND_DISBAND_BROADCAST_GENERIC, this.getTag(fplayer));
}