Code Cleanup & Fix With Fly Unclaiming
This commit is contained in:
parent
3e530487d7
commit
e84c69f2b0
@ -8,15 +8,13 @@ import com.massivecraft.factions.zcore.fperms.Access;
|
|||||||
import com.massivecraft.factions.zcore.fperms.PermissableAction;
|
import com.massivecraft.factions.zcore.fperms.PermissableAction;
|
||||||
import com.massivecraft.factions.zcore.util.TL;
|
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()
|
public CmdCheckpoint() {
|
||||||
{
|
|
||||||
super();
|
super();
|
||||||
this.aliases.addAll(Aliases.checkpoint);
|
this.aliases.addAll(Aliases.checkpoint);
|
||||||
|
|
||||||
@ -32,8 +30,7 @@ public class CmdCheckpoint extends FCommand
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
if (context.args.size() == 1 && context.args.get(0).equalsIgnoreCase("set")) {
|
if (context.args.size() == 1 && context.args.get(0).equalsIgnoreCase("set")) {
|
||||||
if (context.fPlayer.getRole() == Role.LEADER)
|
if (context.fPlayer.getRole() == Role.LEADER) {
|
||||||
{
|
|
||||||
FLocation myLocation = new FLocation(context.player.getLocation());
|
FLocation myLocation = new FLocation(context.player.getLocation());
|
||||||
Faction myLocFaction = Board.getInstance().getFactionAt(myLocation);
|
Faction myLocFaction = Board.getInstance().getFactionAt(myLocation);
|
||||||
if (myLocFaction == Factions.getInstance().getWilderness() || myLocFaction == context.faction) {
|
if (myLocFaction == Factions.getInstance().getWilderness() || myLocFaction == context.faction) {
|
||||||
@ -51,9 +48,7 @@ public class CmdCheckpoint extends FCommand
|
|||||||
if (access == Access.DENY) {
|
if (access == Access.DENY) {
|
||||||
context.msg(TL.GENERIC_FPERM_NOPERMISSION, action.getName());
|
context.msg(TL.GENERIC_FPERM_NOPERMISSION, action.getName());
|
||||||
return;
|
return;
|
||||||
}
|
} else {
|
||||||
else
|
|
||||||
{
|
|
||||||
FLocation myLocation = new FLocation(context.player.getLocation());
|
FLocation myLocation = new FLocation(context.player.getLocation());
|
||||||
Faction myLocFaction = Board.getInstance().getFactionAt(myLocation);
|
Faction myLocFaction = Board.getInstance().getFactionAt(myLocation);
|
||||||
if (myLocFaction == Factions.getInstance().getWilderness() || myLocFaction == context.faction) {
|
if (myLocFaction == Factions.getInstance().getWilderness() || myLocFaction == context.faction) {
|
||||||
@ -86,8 +81,7 @@ public class CmdCheckpoint extends FCommand
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public TL getUsageTranslation()
|
public TL getUsageTranslation() {
|
||||||
{
|
|
||||||
return TL.COMMAND_CHECKPOINT_DESCRIPTION;
|
return TL.COMMAND_CHECKPOINT_DESCRIPTION;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -3,10 +3,7 @@ package com.massivecraft.factions.cmd;
|
|||||||
import com.massivecraft.factions.Conf;
|
import com.massivecraft.factions.Conf;
|
||||||
import com.massivecraft.factions.FPlayer;
|
import com.massivecraft.factions.FPlayer;
|
||||||
import com.massivecraft.factions.FPlayers;
|
import com.massivecraft.factions.FPlayers;
|
||||||
import com.massivecraft.factions.FactionsPlugin;
|
|
||||||
import com.massivecraft.factions.struct.Permission;
|
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.fperms.PermissableAction;
|
||||||
import com.massivecraft.factions.zcore.util.TL;
|
import com.massivecraft.factions.zcore.util.TL;
|
||||||
import mkremins.fanciful.FancyMessage;
|
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));
|
context.faction.msg(TL.COMMAND_DEINVITE_REVOKES, context.fPlayer.describeTo(context.faction), you.describeTo(context.faction));
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public TL getUsageTranslation() {
|
public TL getUsageTranslation() {
|
||||||
return TL.COMMAND_DEINVITE_DESCRIPTION;
|
return TL.COMMAND_DEINVITE_DESCRIPTION;
|
||||||
|
@ -19,6 +19,7 @@ import java.util.concurrent.ConcurrentHashMap;
|
|||||||
|
|
||||||
public class CmdFly extends FCommand {
|
public class CmdFly extends FCommand {
|
||||||
|
|
||||||
|
public static final boolean fly = FactionsPlugin.getInstance().getConfig().getBoolean("enable-faction-flight");
|
||||||
/**
|
/**
|
||||||
* @author FactionsUUID Team
|
* @author FactionsUUID Team
|
||||||
*/
|
*/
|
||||||
@ -27,8 +28,6 @@ public class CmdFly extends FCommand {
|
|||||||
public static ConcurrentHashMap<String, Boolean> flyMap = new ConcurrentHashMap<>();
|
public static ConcurrentHashMap<String, Boolean> flyMap = new ConcurrentHashMap<>();
|
||||||
public static BukkitTask particleTask = null;
|
public static BukkitTask particleTask = null;
|
||||||
|
|
||||||
public static final boolean fly = FactionsPlugin.getInstance().getConfig().getBoolean("enable-faction-flight");
|
|
||||||
|
|
||||||
|
|
||||||
public CmdFly() {
|
public CmdFly() {
|
||||||
super();
|
super();
|
||||||
|
@ -9,7 +9,6 @@ import com.massivecraft.factions.util.CC;
|
|||||||
import com.massivecraft.factions.zcore.fperms.PermissableAction;
|
import com.massivecraft.factions.zcore.fperms.PermissableAction;
|
||||||
import com.massivecraft.factions.zcore.util.TL;
|
import com.massivecraft.factions.zcore.util.TL;
|
||||||
import mkremins.fanciful.FancyMessage;
|
import mkremins.fanciful.FancyMessage;
|
||||||
import org.bukkit.ChatColor;
|
|
||||||
|
|
||||||
public class CmdInvite extends FCommand {
|
public class CmdInvite extends FCommand {
|
||||||
|
|
||||||
|
@ -1,19 +1,12 @@
|
|||||||
package com.massivecraft.factions.cmd;
|
package com.massivecraft.factions.cmd;
|
||||||
|
|
||||||
import com.massivecraft.factions.*;
|
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.event.FPlayerJoinEvent;
|
||||||
import com.massivecraft.factions.struct.Permission;
|
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.frame.fupgrades.UpgradeType;
|
||||||
import com.massivecraft.factions.zcore.util.TL;
|
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 org.bukkit.Bukkit;
|
||||||
|
|
||||||
import java.util.Objects;
|
|
||||||
|
|
||||||
public class CmdJoin extends FCommand {
|
public class CmdJoin extends FCommand {
|
||||||
|
|
||||||
public CmdJoin() {
|
public CmdJoin() {
|
||||||
|
@ -1,6 +1,9 @@
|
|||||||
package com.massivecraft.factions.cmd;
|
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.cmd.audit.FLogType;
|
||||||
import com.massivecraft.factions.event.FPlayerLeaveEvent;
|
import com.massivecraft.factions.event.FPlayerLeaveEvent;
|
||||||
import com.massivecraft.factions.struct.Permission;
|
import com.massivecraft.factions.struct.Permission;
|
||||||
|
@ -72,7 +72,6 @@ public class CmdTag extends FCommand {
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
String oldtag = context.faction.getTag();
|
String oldtag = context.faction.getTag();
|
||||||
context.faction.setTag(tag);
|
context.faction.setTag(tag);
|
||||||
|
|
||||||
|
@ -5,7 +5,6 @@ import com.massivecraft.factions.struct.Permission;
|
|||||||
import com.massivecraft.factions.zcore.fperms.Access;
|
import com.massivecraft.factions.zcore.fperms.Access;
|
||||||
import com.massivecraft.factions.zcore.fperms.PermissableAction;
|
import com.massivecraft.factions.zcore.fperms.PermissableAction;
|
||||||
import com.massivecraft.factions.zcore.util.TL;
|
import com.massivecraft.factions.zcore.util.TL;
|
||||||
import org.bukkit.Material;
|
|
||||||
|
|
||||||
public class CmdUnban extends FCommand {
|
public class CmdUnban extends FCommand {
|
||||||
|
|
||||||
|
@ -83,10 +83,13 @@ public class CmdUnclaim extends FCommand {
|
|||||||
this.stop();
|
this.stop();
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
|
boolean didUnClaim = unClaim(new FLocation(context.player), context);
|
||||||
|
if (didUnClaim && !context.fPlayer.canFlyAtLocation())
|
||||||
|
context.fPlayer.setFFlying(false, false);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -57,15 +57,9 @@ public class CmdUnclaimall extends FCommand {
|
|||||||
}
|
}
|
||||||
if (Econ.shouldBeUsed()) {
|
if (Econ.shouldBeUsed()) {
|
||||||
double refund = Econ.calculateTotalLandRefund(target.getLandRounded());
|
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())) {
|
if (!Econ.modifyMoney(target, refund, TL.COMMAND_UNCLAIMALL_TOUNCLAIM.toString(), TL.COMMAND_UNCLAIMALL_FORUNCLAIM.toString())) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
} else {
|
|
||||||
if (!Econ.modifyMoney(target, refund, TL.COMMAND_UNCLAIMALL_TOUNCLAIM.toString(), TL.COMMAND_UNCLAIMALL_FORUNCLAIM.toString())) {
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
LandUnclaimAllEvent unclaimAllEvent = new LandUnclaimAllEvent(target, context.fPlayer);
|
LandUnclaimAllEvent unclaimAllEvent = new LandUnclaimAllEvent(target, context.fPlayer);
|
||||||
|
@ -48,7 +48,8 @@ public class Econ {
|
|||||||
}
|
}
|
||||||
econ = rsp.getProvider();
|
econ = rsp.getProvider();
|
||||||
FactionsPlugin.getInstance().log("Economy integration through Vault plugin successful.");
|
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();
|
//FactionsPlugin.getInstance().cmdBase.cmdHelp.updateHelp();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
File diff suppressed because it is too large
Load Diff
@ -1,14 +1,13 @@
|
|||||||
package com.massivecraft.factions.integration.dynmap;
|
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.AreaMarker;
|
||||||
import org.dynmap.markers.MarkerSet;
|
import org.dynmap.markers.MarkerSet;
|
||||||
|
|
||||||
public class TempAreaMarker
|
import java.awt.*;
|
||||||
{
|
import java.util.ArrayList;
|
||||||
|
import java.util.List;
|
||||||
|
|
||||||
|
public class TempAreaMarker {
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @author FactionsUUID Team
|
* @author FactionsUUID Team
|
||||||
@ -22,45 +21,34 @@ public class TempAreaMarker
|
|||||||
public String world;
|
public String world;
|
||||||
public double[] x;
|
public double[] x;
|
||||||
public double[] z;
|
public double[] z;
|
||||||
|
|
||||||
private List<List<Point>> polyLine = new ArrayList<List<Point>>();
|
|
||||||
|
|
||||||
public String description;
|
public String description;
|
||||||
|
|
||||||
public int lineColor;
|
public int lineColor;
|
||||||
public double lineOpacity;
|
public double lineOpacity;
|
||||||
public int lineWeight;
|
public int lineWeight;
|
||||||
|
|
||||||
public int fillColor;
|
public int fillColor;
|
||||||
public double fillOpacity;
|
public double fillOpacity;
|
||||||
|
|
||||||
public boolean boost;
|
public boolean boost;
|
||||||
|
private List<List<Point>> polyLine = new ArrayList<List<Point>>();
|
||||||
|
|
||||||
// -------------------------------------------- //
|
// -------------------------------------------- //
|
||||||
// CREATE
|
// 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();
|
int length = marker.getCornerCount();
|
||||||
|
|
||||||
if (x.length != length)
|
if (x.length != length) {
|
||||||
{
|
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
if (z.length != length)
|
if (z.length != length) {
|
||||||
{
|
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
for (int i = 0; i < length; i++)
|
for (int i = 0; i < length; i++) {
|
||||||
{
|
if (marker.getCornerX(i) != x[i]) {
|
||||||
if (marker.getCornerX(i) != x[i])
|
|
||||||
{
|
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
if (marker.getCornerZ(i) != z[i])
|
if (marker.getCornerZ(i) != z[i]) {
|
||||||
{
|
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -68,27 +56,23 @@ public class TempAreaMarker
|
|||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
public void setPolyLine(List<List<Point>> points)
|
public List<List<Point>> getPolyLine() {
|
||||||
{
|
return polyLine;
|
||||||
polyLine.clear();
|
|
||||||
polyLine.addAll(points);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public List<List<Point>> getPolyLine()
|
public void setPolyLine(List<List<Point>> points) {
|
||||||
{
|
polyLine.clear();
|
||||||
return polyLine;
|
polyLine.addAll(points);
|
||||||
}
|
}
|
||||||
|
|
||||||
// -------------------------------------------- //
|
// -------------------------------------------- //
|
||||||
// UPDATE
|
// UPDATE
|
||||||
// -------------------------------------------- //
|
// -------------------------------------------- //
|
||||||
|
|
||||||
public AreaMarker create(MarkerSet markerset, String markerId)
|
public AreaMarker create(MarkerSet markerset, String markerId) {
|
||||||
{
|
|
||||||
AreaMarker ret = markerset.createAreaMarker(markerId, this.label, false, this.world, this.x, this.z, false // not persistent
|
AreaMarker ret = markerset.createAreaMarker(markerId, this.label, false, this.world, this.x, this.z, false // not persistent
|
||||||
);
|
);
|
||||||
if (ret == null)
|
if (ret == null) {
|
||||||
{
|
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -112,21 +96,17 @@ public class TempAreaMarker
|
|||||||
// UTIL
|
// UTIL
|
||||||
// -------------------------------------------- //
|
// -------------------------------------------- //
|
||||||
|
|
||||||
public void update(AreaMarker marker)
|
public void update(AreaMarker marker) {
|
||||||
{
|
|
||||||
// Corner Locations
|
// Corner Locations
|
||||||
if (!equals(marker, this.x, this.z))
|
if (!equals(marker, this.x, this.z)) {
|
||||||
{
|
|
||||||
marker.setCornerLocations(this.x, this.z);
|
marker.setCornerLocations(this.x, this.z);
|
||||||
}
|
}
|
||||||
|
|
||||||
// Label
|
// Label
|
||||||
if (!marker.getLabel().equals(this.label))
|
if (!marker.getLabel().equals(this.label)) {
|
||||||
{
|
|
||||||
marker.setLabel(this.label);
|
marker.setLabel(this.label);
|
||||||
}
|
}
|
||||||
if (!marker.getDescription().equals(this.description))
|
if (!marker.getDescription().equals(this.description)) {
|
||||||
{
|
|
||||||
marker.setDescription(this.description);
|
marker.setDescription(this.description);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -137,13 +117,11 @@ public class TempAreaMarker
|
|||||||
// }
|
// }
|
||||||
|
|
||||||
// Fill Style
|
// Fill Style
|
||||||
if ((marker.getFillOpacity() != this.fillOpacity) || (marker.getFillColor() != this.fillColor))
|
if ((marker.getFillOpacity() != this.fillOpacity) || (marker.getFillColor() != this.fillColor)) {
|
||||||
{
|
|
||||||
marker.setFillStyle(this.fillOpacity, this.fillColor);
|
marker.setFillStyle(this.fillOpacity, this.fillColor);
|
||||||
}
|
}
|
||||||
// Boost Flag
|
// Boost Flag
|
||||||
if (marker.getBoostFlag() != this.boost)
|
if (marker.getBoostFlag() != this.boost) {
|
||||||
{
|
|
||||||
marker.setBoostFlag(this.boost);
|
marker.setBoostFlag(this.boost);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -1,59 +1,46 @@
|
|||||||
package com.massivecraft.factions.integration.dynmap;
|
package com.massivecraft.factions.integration.dynmap;
|
||||||
|
|
||||||
import java.awt.Point;
|
import java.awt.*;
|
||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
|
||||||
public class TempLine
|
public class TempLine {
|
||||||
{
|
|
||||||
private Point p1;
|
private Point p1;
|
||||||
private Point p2;
|
private Point p2;
|
||||||
private List<TempLine> connectedLines = new ArrayList<TempLine>();
|
private List<TempLine> connectedLines = new ArrayList<TempLine>();
|
||||||
|
|
||||||
TempLine(Point p1, Point p2)
|
TempLine(Point p1, Point p2) {
|
||||||
{
|
|
||||||
this.p1 = p1;
|
this.p1 = p1;
|
||||||
this.p2 = p2;
|
this.p2 = p2;
|
||||||
}
|
}
|
||||||
|
|
||||||
public Point getP1()
|
public Point getP1() {
|
||||||
{
|
|
||||||
return p1;
|
return p1;
|
||||||
}
|
}
|
||||||
|
|
||||||
public Point getP2()
|
public Point getP2() {
|
||||||
{
|
|
||||||
return p2;
|
return p2;
|
||||||
}
|
}
|
||||||
|
|
||||||
public void addAdditionLines(List<TempLine> connectedLines)
|
public void addAdditionLines(List<TempLine> connectedLines) {
|
||||||
{
|
|
||||||
this.connectedLines = connectedLines;
|
this.connectedLines = connectedLines;
|
||||||
}
|
}
|
||||||
|
|
||||||
public List<TempLine> getConnectedLines()
|
public List<TempLine> getConnectedLines() {
|
||||||
{
|
|
||||||
return connectedLines;
|
return connectedLines;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public boolean equals(Object o)
|
public boolean equals(Object o) {
|
||||||
{
|
|
||||||
TempLine line = (TempLine) 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)
|
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 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 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
|
@Override
|
||||||
public int hashCode()
|
public int hashCode() {
|
||||||
{
|
|
||||||
String test = "" + (p1.x + p2.x);
|
String test = "" + (p1.x + p2.x);
|
||||||
test += " " + (p1.y + p2.y);
|
test += " " + (p1.y + p2.y);
|
||||||
return test.hashCode();
|
return test.hashCode();
|
||||||
|
@ -1,13 +1,13 @@
|
|||||||
package com.massivecraft.factions.integration.dynmap;
|
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.MarkerSet;
|
||||||
import org.dynmap.markers.PolyLineMarker;
|
import org.dynmap.markers.PolyLineMarker;
|
||||||
|
|
||||||
public class TempPolyLineMarker
|
import java.awt.*;
|
||||||
{
|
import java.util.ArrayList;
|
||||||
|
import java.util.List;
|
||||||
|
|
||||||
|
public class TempPolyLineMarker {
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @author FactionsUUID Team
|
* @author FactionsUUID Team
|
||||||
@ -29,22 +29,17 @@ public class TempPolyLineMarker
|
|||||||
// CREATE
|
// CREATE
|
||||||
// -------------------------------------------- //
|
// -------------------------------------------- //
|
||||||
|
|
||||||
public static boolean equals(PolyLineMarker marker, List<Point> points)
|
public static boolean equals(PolyLineMarker marker, List<Point> points) {
|
||||||
{
|
|
||||||
int length = marker.getCornerCount();
|
int length = marker.getCornerCount();
|
||||||
|
|
||||||
if (points.size() != length)
|
if (points.size() != length) {
|
||||||
{
|
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
for (int i = 0; i < length; i++)
|
for (int i = 0; i < length; i++) {
|
||||||
{
|
if (marker.getCornerX(i) != points.get(i).x) {
|
||||||
if (marker.getCornerX(i) != points.get(i).x)
|
|
||||||
{
|
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
if (marker.getCornerZ(i) != points.get(i).y)
|
if (marker.getCornerZ(i) != points.get(i).y) {
|
||||||
{
|
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -56,13 +51,11 @@ public class TempPolyLineMarker
|
|||||||
// UPDATE
|
// UPDATE
|
||||||
// -------------------------------------------- //
|
// -------------------------------------------- //
|
||||||
|
|
||||||
public PolyLineMarker create(MarkerSet markerset, String markerId)
|
public PolyLineMarker create(MarkerSet markerset, String markerId) {
|
||||||
{
|
|
||||||
double[] polyX = new double[polyLine.size()];
|
double[] polyX = new double[polyLine.size()];
|
||||||
double[] polyY = new double[polyLine.size()];
|
double[] polyY = new double[polyLine.size()];
|
||||||
double[] polyZ = new double[polyLine.size()];
|
double[] polyZ = new double[polyLine.size()];
|
||||||
for (int i = 0; i < polyLine.size(); i++)
|
for (int i = 0; i < polyLine.size(); i++) {
|
||||||
{
|
|
||||||
Point p = polyLine.get(i);
|
Point p = polyLine.get(i);
|
||||||
polyX[i] = p.getX();
|
polyX[i] = p.getX();
|
||||||
polyY[i] = 64;
|
polyY[i] = 64;
|
||||||
@ -70,8 +63,7 @@ public class TempPolyLineMarker
|
|||||||
}
|
}
|
||||||
PolyLineMarker poly = markerset.createPolyLineMarker(markerId, "", false, this.world, polyX, polyY, polyZ, false);
|
PolyLineMarker poly = markerset.createPolyLineMarker(markerId, "", false, this.world, polyX, polyY, polyZ, false);
|
||||||
// Poly Line Style
|
// Poly Line Style
|
||||||
if (poly != null)
|
if (poly != null) {
|
||||||
{
|
|
||||||
poly.setLineStyle(this.lineWeight, this.lineOpacity, this.lineColor);
|
poly.setLineStyle(this.lineWeight, this.lineOpacity, this.lineColor);
|
||||||
}
|
}
|
||||||
return poly;
|
return poly;
|
||||||
@ -81,16 +73,13 @@ public class TempPolyLineMarker
|
|||||||
// UTIL
|
// UTIL
|
||||||
// -------------------------------------------- //
|
// -------------------------------------------- //
|
||||||
|
|
||||||
public void update(PolyLineMarker marker)
|
public void update(PolyLineMarker marker) {
|
||||||
{
|
|
||||||
// Corner Locations
|
// Corner Locations
|
||||||
if (!equals(marker, polyLine))
|
if (!equals(marker, polyLine)) {
|
||||||
{
|
|
||||||
double[] polyX = new double[polyLine.size()];
|
double[] polyX = new double[polyLine.size()];
|
||||||
double[] polyY = new double[polyLine.size()];
|
double[] polyY = new double[polyLine.size()];
|
||||||
double[] polyZ = new double[polyLine.size()];
|
double[] polyZ = new double[polyLine.size()];
|
||||||
for (int i = 0; i < polyLine.size(); i++)
|
for (int i = 0; i < polyLine.size(); i++) {
|
||||||
{
|
|
||||||
Point p = polyLine.get(i);
|
Point p = polyLine.get(i);
|
||||||
polyX[i] = p.getX();
|
polyX[i] = p.getX();
|
||||||
polyY[i] = 64;
|
polyY[i] = 64;
|
||||||
@ -101,8 +90,7 @@ public class TempPolyLineMarker
|
|||||||
}
|
}
|
||||||
|
|
||||||
// Line Style
|
// Line Style
|
||||||
if (marker.getLineWeight() != this.lineWeight || marker.getLineOpacity() != this.lineOpacity || marker.getLineColor() != this.lineColor)
|
if (marker.getLineWeight() != this.lineWeight || marker.getLineOpacity() != this.lineOpacity || marker.getLineColor() != this.lineColor) {
|
||||||
{
|
|
||||||
marker.setLineStyle(this.lineWeight, this.lineOpacity, this.lineColor);
|
marker.setLineStyle(this.lineWeight, this.lineOpacity, this.lineColor);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -42,15 +42,13 @@ import java.util.concurrent.TimeUnit;
|
|||||||
import java.util.concurrent.atomic.AtomicInteger;
|
import java.util.concurrent.atomic.AtomicInteger;
|
||||||
|
|
||||||
|
|
||||||
public class FactionsBlockListener implements Listener
|
public class FactionsBlockListener implements Listener {
|
||||||
{
|
|
||||||
|
|
||||||
public static HashMap<String, Location> bannerLocations = new HashMap<>();
|
public static HashMap<String, Location> bannerLocations = new HashMap<>();
|
||||||
private HashMap<String, Boolean> bannerCooldownMap = new HashMap<>();
|
private HashMap<String, Boolean> bannerCooldownMap = new HashMap<>();
|
||||||
private long placeTimer = TimeUnit.SECONDS.toMillis(15L);
|
private long placeTimer = TimeUnit.SECONDS.toMillis(15L);
|
||||||
|
|
||||||
public static boolean playerCanBuildDestroyBlock(Player player, Location location, PermissableAction action, boolean justCheck)
|
public static boolean playerCanBuildDestroyBlock(Player player, Location location, PermissableAction action, boolean justCheck) {
|
||||||
{
|
|
||||||
if (Conf.playersWhoBypassAllProtection.contains(player.getName()))
|
if (Conf.playersWhoBypassAllProtection.contains(player.getName()))
|
||||||
return true;
|
return true;
|
||||||
|
|
||||||
@ -62,21 +60,17 @@ public class FactionsBlockListener implements Listener
|
|||||||
Faction otherFaction = Board.getInstance().getFactionAt(loc);
|
Faction otherFaction = Board.getInstance().getFactionAt(loc);
|
||||||
Faction myFaction = me.getFaction();
|
Faction myFaction = me.getFaction();
|
||||||
|
|
||||||
if (otherFaction.isWilderness())
|
if (otherFaction.isWilderness()) {
|
||||||
{
|
|
||||||
if (Conf.worldGuardBuildPriority && Worldguard.getInstance().playerCanBuild(player, location))
|
if (Conf.worldGuardBuildPriority && Worldguard.getInstance().playerCanBuild(player, location))
|
||||||
return true;
|
return true;
|
||||||
if (location.getWorld() != null)
|
if (location.getWorld() != null) {
|
||||||
{
|
|
||||||
if (!Conf.wildernessDenyBuild || Conf.worldsNoWildernessProtection.contains(location.getWorld().getName()))
|
if (!Conf.wildernessDenyBuild || Conf.worldsNoWildernessProtection.contains(location.getWorld().getName()))
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
if (!justCheck)
|
if (!justCheck)
|
||||||
me.msg(TL.ACTION_DENIED_WILDERNESS, action.toString());
|
me.msg(TL.ACTION_DENIED_WILDERNESS, action.toString());
|
||||||
return false;
|
return false;
|
||||||
}
|
} else if (otherFaction.isSafeZone()) {
|
||||||
else if (otherFaction.isSafeZone())
|
|
||||||
{
|
|
||||||
if (Conf.worldGuardBuildPriority && Worldguard.getInstance().playerCanBuild(player, location))
|
if (Conf.worldGuardBuildPriority && Worldguard.getInstance().playerCanBuild(player, location))
|
||||||
return true;
|
return true;
|
||||||
if (!Conf.safeZoneDenyBuild || Permission.MANAGE_SAFE_ZONE.has(player))
|
if (!Conf.safeZoneDenyBuild || Permission.MANAGE_SAFE_ZONE.has(player))
|
||||||
@ -84,9 +78,7 @@ public class FactionsBlockListener implements Listener
|
|||||||
if (!justCheck)
|
if (!justCheck)
|
||||||
me.msg(TL.ACTION_DENIED_SAFEZONE, action.toString());
|
me.msg(TL.ACTION_DENIED_SAFEZONE, action.toString());
|
||||||
return false;
|
return false;
|
||||||
}
|
} else if (otherFaction.isWarZone()) {
|
||||||
else if (otherFaction.isWarZone())
|
|
||||||
{
|
|
||||||
if (Conf.worldGuardBuildPriority && Worldguard.getInstance().playerCanBuild(player, location))
|
if (Conf.worldGuardBuildPriority && Worldguard.getInstance().playerCanBuild(player, location))
|
||||||
return true;
|
return true;
|
||||||
if (!Conf.warZoneDenyBuild || Permission.MANAGE_WAR_ZONE.has(player))
|
if (!Conf.warZoneDenyBuild || Permission.MANAGE_WAR_ZONE.has(player))
|
||||||
@ -94,41 +86,31 @@ public class FactionsBlockListener implements Listener
|
|||||||
if (!justCheck)
|
if (!justCheck)
|
||||||
me.msg(TL.ACTION_DENIED_WARZONE, action.toString());
|
me.msg(TL.ACTION_DENIED_WARZONE, action.toString());
|
||||||
return false;
|
return false;
|
||||||
}
|
} else if (!otherFaction.getId().equals(myFaction.getId())) { // If the faction target is not my own
|
||||||
else if (!otherFaction.getId().equals(myFaction.getId()))
|
|
||||||
{ // If the faction target is not my own
|
|
||||||
if (FactionsPlugin.getInstance().getConfig().getBoolean("hcf.raidable", false) && otherFaction.getLandRounded() > otherFaction.getPowerRounded())
|
if (FactionsPlugin.getInstance().getConfig().getBoolean("hcf.raidable", false) && otherFaction.getLandRounded() > otherFaction.getPowerRounded())
|
||||||
return true;
|
return true;
|
||||||
boolean pain = !justCheck && otherFaction.getAccess(me, PermissableAction.PAIN_BUILD) == Access.ALLOW;
|
boolean pain = !justCheck && otherFaction.getAccess(me, PermissableAction.PAIN_BUILD) == Access.ALLOW;
|
||||||
return CheckActionState(otherFaction, loc, me, action, pain, justCheck);
|
return CheckActionState(otherFaction, loc, me, action, pain, justCheck);
|
||||||
}
|
} else if (otherFaction.getId().equals(myFaction.getId())) {
|
||||||
else if (otherFaction.getId().equals(myFaction.getId()))
|
|
||||||
{
|
|
||||||
boolean pain = !justCheck && myFaction.getAccess(me, PermissableAction.PAIN_BUILD) == Access.ALLOW;
|
boolean pain = !justCheck && myFaction.getAccess(me, PermissableAction.PAIN_BUILD) == Access.ALLOW;
|
||||||
return CheckActionState(myFaction, loc, me, action, pain, justCheck);
|
return CheckActionState(myFaction, loc, me, action, pain, justCheck);
|
||||||
}
|
}
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
private static boolean CheckPlayerAccess(Player player, FPlayer me, FLocation loc, Faction myFaction, Access access, PermissableAction action, boolean shouldHurt, boolean justCheck)
|
private static boolean CheckPlayerAccess(Player player, FPlayer me, FLocation loc, Faction myFaction, Access access, PermissableAction action, boolean shouldHurt, boolean justCheck) {
|
||||||
{
|
|
||||||
boolean landOwned = (myFaction.doesLocationHaveOwnersSet(loc) && !myFaction.getOwnerList(loc).isEmpty());
|
boolean landOwned = (myFaction.doesLocationHaveOwnersSet(loc) && !myFaction.getOwnerList(loc).isEmpty());
|
||||||
if ((landOwned && myFaction.getOwnerListString(loc).contains(player.getName())) || (me.getRole() == Role.LEADER && me.getFactionId().equals(myFaction.getId())))
|
if ((landOwned && myFaction.getOwnerListString(loc).contains(player.getName())) || (me.getRole() == Role.LEADER && me.getFactionId().equals(myFaction.getId())))
|
||||||
return true;
|
return true;
|
||||||
else if (landOwned && !myFaction.getOwnerListString(loc).contains(player.getName()))
|
else if (landOwned && !myFaction.getOwnerListString(loc).contains(player.getName())) {
|
||||||
{
|
|
||||||
me.msg(TL.ACTIONS_OWNEDTERRITORYDENY.toString().replace("{owners}", myFaction.getOwnerListString(loc)));
|
me.msg(TL.ACTIONS_OWNEDTERRITORYDENY.toString().replace("{owners}", myFaction.getOwnerListString(loc)));
|
||||||
if (shouldHurt)
|
if (shouldHurt) {
|
||||||
{
|
|
||||||
player.damage(Conf.actionDeniedPainAmount);
|
player.damage(Conf.actionDeniedPainAmount);
|
||||||
me.msg(TL.ACTIONS_NOPERMISSIONPAIN.toString().replace("{action}", action.toString()).replace("{faction}", Board.getInstance().getFactionAt(loc).getTag(myFaction)));
|
me.msg(TL.ACTIONS_NOPERMISSIONPAIN.toString().replace("{action}", action.toString()).replace("{faction}", Board.getInstance().getFactionAt(loc).getTag(myFaction)));
|
||||||
}
|
}
|
||||||
return false;
|
return false;
|
||||||
}
|
} else if (!landOwned && access == Access.DENY) { // If land is not owned but access is set to DENY anyway
|
||||||
else if (!landOwned && access == Access.DENY)
|
if (shouldHurt) {
|
||||||
{ // If land is not owned but access is set to DENY anyway
|
|
||||||
if (shouldHurt)
|
|
||||||
{
|
|
||||||
player.damage(Conf.actionDeniedPainAmount);
|
player.damage(Conf.actionDeniedPainAmount);
|
||||||
if ((Board.getInstance().getFactionAt(loc).getTag(myFaction)) != null)
|
if ((Board.getInstance().getFactionAt(loc).getTag(myFaction)) != null)
|
||||||
me.msg(TL.ACTIONS_NOPERMISSIONPAIN.toString().replace("{action}", action.toString()).replace("{faction}", Board.getInstance().getFactionAt(loc).getTag(myFaction)));
|
me.msg(TL.ACTIONS_NOPERMISSIONPAIN.toString().replace("{action}", action.toString()).replace("{faction}", Board.getInstance().getFactionAt(loc).getTag(myFaction)));
|
||||||
@ -136,8 +118,7 @@ public class FactionsBlockListener implements Listener
|
|||||||
if (myFaction.getTag(me.getFaction()) != null && action != null && !justCheck)
|
if (myFaction.getTag(me.getFaction()) != null && action != null && !justCheck)
|
||||||
me.msg(TL.ACTIONS_NOPERMISSION.toString().replace("{faction}", myFaction.getTag(me.getFaction())).replace("{action}", action.toString()));
|
me.msg(TL.ACTIONS_NOPERMISSION.toString().replace("{faction}", myFaction.getTag(me.getFaction())).replace("{action}", action.toString()));
|
||||||
return false;
|
return false;
|
||||||
}
|
} else if (access == Access.ALLOW)
|
||||||
else if (access == Access.ALLOW)
|
|
||||||
return true;
|
return true;
|
||||||
|
|
||||||
if (!justCheck)
|
if (!justCheck)
|
||||||
@ -145,18 +126,15 @@ public class FactionsBlockListener implements Listener
|
|||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
private static boolean CheckActionState(Faction target, FLocation location, FPlayer me, PermissableAction action, boolean pain, boolean justCheck)
|
private static boolean CheckActionState(Faction target, FLocation location, FPlayer me, PermissableAction action, boolean pain, boolean justCheck) {
|
||||||
{
|
if (Conf.ownedAreasEnabled && target.doesLocationHaveOwnersSet(location) && !target.playerHasOwnershipRights(me, location)) {
|
||||||
if (Conf.ownedAreasEnabled && target.doesLocationHaveOwnersSet(location) && !target.playerHasOwnershipRights(me, location))
|
|
||||||
{
|
|
||||||
// If pain should be applied
|
// If pain should be applied
|
||||||
|
|
||||||
if (pain && Conf.ownedAreaPainBuild)
|
if (pain && Conf.ownedAreaPainBuild)
|
||||||
me.msg(TL.ACTIONS_OWNEDTERRITORYPAINDENY.toString().replace("{action}", action.toString()).replace("{faction}", target.getOwnerListString(location)));
|
me.msg(TL.ACTIONS_OWNEDTERRITORYPAINDENY.toString().replace("{action}", action.toString()).replace("{faction}", target.getOwnerListString(location)));
|
||||||
if (Conf.ownedAreaDenyBuild && pain)
|
if (Conf.ownedAreaDenyBuild && pain)
|
||||||
return false;
|
return false;
|
||||||
else if (Conf.ownedAreaDenyBuild)
|
else if (Conf.ownedAreaDenyBuild) {
|
||||||
{
|
|
||||||
if (!justCheck)
|
if (!justCheck)
|
||||||
me.msg(TL.ACTIONS_NOPERMISSION.toString().replace("{faction}", target.getTag(me.getFaction())).replace("{action}", action.toString()));
|
me.msg(TL.ACTIONS_NOPERMISSION.toString().replace("{faction}", target.getTag(me.getFaction())).replace("{action}", action.toString()));
|
||||||
return false;
|
return false;
|
||||||
@ -165,32 +143,26 @@ public class FactionsBlockListener implements Listener
|
|||||||
return CheckPlayerAccess(me.getPlayer(), me, location, target, target.getAccess(me, action), action, pain, justCheck);
|
return CheckPlayerAccess(me.getPlayer(), me, location, target, target.getAccess(me, action), action, pain, justCheck);
|
||||||
}
|
}
|
||||||
|
|
||||||
public void handleSpawnerUpdate(Faction at, Player player, ItemStack spawnerItem, LogTimer.TimerSubType subType)
|
public void handleSpawnerUpdate(Faction at, Player player, ItemStack spawnerItem, LogTimer.TimerSubType subType) {
|
||||||
{
|
|
||||||
FLogManager manager = FactionsPlugin.instance.getFlogManager();
|
FLogManager manager = FactionsPlugin.instance.getFlogManager();
|
||||||
LogTimer logTimer = manager.getLogTimers().computeIfAbsent(player.getUniqueId(), e -> new LogTimer(player.getName(), at.getId()));
|
LogTimer logTimer = manager.getLogTimers().computeIfAbsent(player.getUniqueId(), e -> new LogTimer(player.getName(), at.getId()));
|
||||||
LogTimer.Timer timer = logTimer.attemptLog(LogTimer.TimerType.SPAWNER_EDIT, subType, 0L);
|
LogTimer.Timer timer = logTimer.attemptLog(LogTimer.TimerType.SPAWNER_EDIT, subType, 0L);
|
||||||
Map<MaterialData, AtomicInteger> currentCounts = (timer.getExtraData() == null) ? new HashMap<>() : ((Map) timer.getExtraData());
|
Map<MaterialData, AtomicInteger> currentCounts = (timer.getExtraData() == null) ? new HashMap<>() : ((Map) timer.getExtraData());
|
||||||
currentCounts.computeIfAbsent(spawnerItem.getData(), e -> new AtomicInteger(0)).addAndGet(1);
|
currentCounts.computeIfAbsent(spawnerItem.getData(), e -> new AtomicInteger(0)).addAndGet(1);
|
||||||
timer.setExtraData(currentCounts);
|
timer.setExtraData(currentCounts);
|
||||||
if (timer.isReadyToLog(this.placeTimer))
|
if (timer.isReadyToLog(this.placeTimer)) {
|
||||||
{
|
|
||||||
logTimer.pushLogs(at, LogTimer.TimerType.SPAWNER_EDIT);
|
logTimer.pushLogs(at, LogTimer.TimerType.SPAWNER_EDIT);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@EventHandler(priority = EventPriority.HIGH, ignoreCancelled = true)
|
@EventHandler(priority = EventPriority.HIGH, ignoreCancelled = true)
|
||||||
public void onPlayerPlace(BlockPlaceEvent event)
|
public void onPlayerPlace(BlockPlaceEvent event) {
|
||||||
{
|
|
||||||
ItemStack item = event.getItemInHand();
|
ItemStack item = event.getItemInHand();
|
||||||
if (item != null && item.getType() == XMaterial.SPAWNER.parseMaterial())
|
if (item != null && item.getType() == XMaterial.SPAWNER.parseMaterial()) {
|
||||||
{
|
|
||||||
Faction at = Board.getInstance().getFactionAt(new FLocation(event.getBlockPlaced()));
|
Faction at = Board.getInstance().getFactionAt(new FLocation(event.getBlockPlaced()));
|
||||||
if (at != null && at.isNormal())
|
if (at != null && at.isNormal()) {
|
||||||
{
|
|
||||||
FPlayer fplayer = FPlayers.getInstance().getByPlayer(event.getPlayer());
|
FPlayer fplayer = FPlayers.getInstance().getByPlayer(event.getPlayer());
|
||||||
if (fplayer != null && at.getRelationTo(fplayer.getFaction()).isAtLeast(Relation.TRUCE))
|
if (fplayer != null && at.getRelationTo(fplayer.getFaction()).isAtLeast(Relation.TRUCE)) {
|
||||||
{
|
|
||||||
this.handleSpawnerUpdate(at, event.getPlayer(), item, LogTimer.TimerSubType.SPAWNER_PLACE);
|
this.handleSpawnerUpdate(at, event.getPlayer(), item, LogTimer.TimerSubType.SPAWNER_PLACE);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -198,24 +170,20 @@ public class FactionsBlockListener implements Listener
|
|||||||
}
|
}
|
||||||
|
|
||||||
@EventHandler(priority = EventPriority.NORMAL, ignoreCancelled = true)
|
@EventHandler(priority = EventPriority.NORMAL, ignoreCancelled = true)
|
||||||
public void onBlockPlace(BlockPlaceEvent event)
|
public void onBlockPlace(BlockPlaceEvent event) {
|
||||||
{
|
|
||||||
|
|
||||||
if (!event.canBuild())
|
if (!event.canBuild())
|
||||||
return;
|
return;
|
||||||
if (event.getBlockPlaced().getType() == Material.FIRE)
|
if (event.getBlockPlaced().getType() == Material.FIRE)
|
||||||
return;
|
return;
|
||||||
boolean isSpawner = event.getBlock().getType().equals(XMaterial.SPAWNER.parseMaterial());
|
boolean isSpawner = event.getBlock().getType().equals(XMaterial.SPAWNER.parseMaterial());
|
||||||
if (!playerCanBuildDestroyBlock(event.getPlayer(), event.getBlock().getLocation(), PermissableAction.BUILD, false))
|
if (!playerCanBuildDestroyBlock(event.getPlayer(), event.getBlock().getLocation(), PermissableAction.BUILD, false)) {
|
||||||
{
|
|
||||||
event.setCancelled(true);
|
event.setCancelled(true);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (isSpawner)
|
if (isSpawner) {
|
||||||
{
|
if (Conf.spawnerLock) {
|
||||||
if (Conf.spawnerLock)
|
|
||||||
{
|
|
||||||
event.setCancelled(true);
|
event.setCancelled(true);
|
||||||
event.getPlayer().sendMessage(FactionsPlugin.getInstance().color(TL.COMMAND_SPAWNER_LOCK_CANNOT_PLACE.toString()));
|
event.getPlayer().sendMessage(FactionsPlugin.getInstance().color(TL.COMMAND_SPAWNER_LOCK_CANNOT_PLACE.toString()));
|
||||||
}
|
}
|
||||||
@ -223,30 +191,24 @@ public class FactionsBlockListener implements Listener
|
|||||||
}
|
}
|
||||||
|
|
||||||
@EventHandler(priority = EventPriority.NORMAL, ignoreCancelled = true)
|
@EventHandler(priority = EventPriority.NORMAL, ignoreCancelled = true)
|
||||||
public void onBlockFromTo(BlockFromToEvent event)
|
public void onBlockFromTo(BlockFromToEvent event) {
|
||||||
{
|
|
||||||
if (!Conf.handleExploitLiquidFlow)
|
if (!Conf.handleExploitLiquidFlow)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
if (event.getBlock().isLiquid())
|
if (event.getBlock().isLiquid()) {
|
||||||
{
|
if (event.getToBlock().isEmpty()) {
|
||||||
if (event.getToBlock().isEmpty())
|
|
||||||
{
|
|
||||||
Faction from = Board.getInstance().getFactionAt(new FLocation(event.getBlock()));
|
Faction from = Board.getInstance().getFactionAt(new FLocation(event.getBlock()));
|
||||||
Faction to = Board.getInstance().getFactionAt(new FLocation(event.getToBlock()));
|
Faction to = Board.getInstance().getFactionAt(new FLocation(event.getToBlock()));
|
||||||
if (from == to)
|
if (from == to)
|
||||||
return;
|
return;
|
||||||
// from faction != to faction
|
// from faction != to faction
|
||||||
if (to.isSystemFaction())
|
if (to.isSystemFaction()) {
|
||||||
{
|
|
||||||
event.setCancelled(true);
|
event.setCancelled(true);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (to.isNormal())
|
if (to.isNormal()) {
|
||||||
{
|
if (from.isNormal() && from.getRelationTo(to).isAlly()) {
|
||||||
if (from.isNormal() && from.getRelationTo(to).isAlly())
|
|
||||||
{
|
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
event.setCancelled(true);
|
event.setCancelled(true);
|
||||||
@ -256,17 +218,14 @@ public class FactionsBlockListener implements Listener
|
|||||||
}
|
}
|
||||||
|
|
||||||
@EventHandler(priority = EventPriority.NORMAL, ignoreCancelled = true)
|
@EventHandler(priority = EventPriority.NORMAL, ignoreCancelled = true)
|
||||||
public void onBlockDamage(BlockDamageEvent event)
|
public void onBlockDamage(BlockDamageEvent event) {
|
||||||
{
|
if (event.getInstaBreak() && !playerCanBuildDestroyBlock(event.getPlayer(), event.getBlock().getLocation(), PermissableAction.DESTROY, false)) {
|
||||||
if (event.getInstaBreak() && !playerCanBuildDestroyBlock(event.getPlayer(), event.getBlock().getLocation(), PermissableAction.DESTROY, false))
|
|
||||||
{
|
|
||||||
event.setCancelled(true);
|
event.setCancelled(true);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@EventHandler(priority = EventPriority.NORMAL, ignoreCancelled = true)
|
@EventHandler(priority = EventPriority.NORMAL, ignoreCancelled = true)
|
||||||
public void onBlockPistonExtend(BlockPistonExtendEvent event)
|
public void onBlockPistonExtend(BlockPistonExtendEvent event) {
|
||||||
{
|
|
||||||
if (!Conf.pistonProtectionThroughDenyBuild)
|
if (!Conf.pistonProtectionThroughDenyBuild)
|
||||||
return;
|
return;
|
||||||
Faction pistonFaction = Board.getInstance().getFactionAt(new FLocation(event.getBlock()));
|
Faction pistonFaction = Board.getInstance().getFactionAt(new FLocation(event.getBlock()));
|
||||||
@ -280,45 +239,35 @@ public class FactionsBlockListener implements Listener
|
|||||||
}
|
}
|
||||||
|
|
||||||
@EventHandler
|
@EventHandler
|
||||||
public void onVaultPlace(BlockPlaceEvent e)
|
public void onVaultPlace(BlockPlaceEvent e) {
|
||||||
{
|
if (e.getItemInHand().getType() == Material.CHEST) {
|
||||||
if (e.getItemInHand().getType() == Material.CHEST)
|
|
||||||
{
|
|
||||||
|
|
||||||
ItemStack vault = new ItemBuilder(Material.CHEST).amount(1).name(FactionsPlugin.instance.getConfig().getString("fvault.Item.Name")).lore(FactionsPlugin.instance.getConfig().getStringList("fvault.Item.Lore")).build();
|
ItemStack vault = new ItemBuilder(Material.CHEST).amount(1).name(FactionsPlugin.instance.getConfig().getString("fvault.Item.Name")).lore(FactionsPlugin.instance.getConfig().getStringList("fvault.Item.Lore")).build();
|
||||||
|
|
||||||
if (e.getItemInHand().isSimilar(vault))
|
if (e.getItemInHand().isSimilar(vault)) {
|
||||||
{
|
|
||||||
FPlayer fme = FPlayers.getInstance().getByPlayer(e.getPlayer());
|
FPlayer fme = FPlayers.getInstance().getByPlayer(e.getPlayer());
|
||||||
if (fme.getFaction().getVault() != null)
|
if (fme.getFaction().getVault() != null) {
|
||||||
{
|
|
||||||
fme.msg(TL.COMMAND_GETVAULT_ALREADYSET);
|
fme.msg(TL.COMMAND_GETVAULT_ALREADYSET);
|
||||||
e.setCancelled(true);
|
e.setCancelled(true);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
FLocation flocation = new FLocation(e.getBlockPlaced().getLocation());
|
FLocation flocation = new FLocation(e.getBlockPlaced().getLocation());
|
||||||
if (Board.getInstance().getFactionAt(flocation) != fme.getFaction())
|
if (Board.getInstance().getFactionAt(flocation) != fme.getFaction()) {
|
||||||
{
|
|
||||||
fme.msg(TL.COMMAND_GETVAULT_INVALIDLOCATION);
|
fme.msg(TL.COMMAND_GETVAULT_INVALIDLOCATION);
|
||||||
e.setCancelled(true);
|
e.setCancelled(true);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
Block start = e.getBlockPlaced();
|
Block start = e.getBlockPlaced();
|
||||||
int radius = 1;
|
int radius = 1;
|
||||||
for (double x = start.getLocation().getX() - radius; x <= start.getLocation().getX() + radius; x++)
|
for (double x = start.getLocation().getX() - radius; x <= start.getLocation().getX() + radius; x++) {
|
||||||
{
|
for (double y = start.getLocation().getY() - radius; y <= start.getLocation().getY() + radius; y++) {
|
||||||
for (double y = start.getLocation().getY() - radius; y <= start.getLocation().getY() + radius; y++)
|
for (double z = start.getLocation().getZ() - radius; z <= start.getLocation().getZ() + radius; z++) {
|
||||||
{
|
|
||||||
for (double z = start.getLocation().getZ() - radius; z <= start.getLocation().getZ() + radius; z++)
|
|
||||||
{
|
|
||||||
Location blockLoc = new Location(e.getPlayer().getWorld(), x, y, z);
|
Location blockLoc = new Location(e.getPlayer().getWorld(), x, y, z);
|
||||||
if (blockLoc.getX() == start.getLocation().getX() && blockLoc.getY() == start.getLocation().getY() && blockLoc.getZ() == start.getLocation().getZ())
|
if (blockLoc.getX() == start.getLocation().getX() && blockLoc.getY() == start.getLocation().getY() && blockLoc.getZ() == start.getLocation().getZ()) {
|
||||||
{
|
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
Material blockMaterial = blockLoc.getBlock().getType();
|
Material blockMaterial = blockLoc.getBlock().getType();
|
||||||
if (blockMaterial == Material.CHEST || (FactionsPlugin.instance.getConfig().getBoolean("fvault.No-Hoppers-near-vault") && blockMaterial == Material.HOPPER))
|
if (blockMaterial == Material.CHEST || (FactionsPlugin.instance.getConfig().getBoolean("fvault.No-Hoppers-near-vault") && blockMaterial == Material.HOPPER)) {
|
||||||
{
|
|
||||||
e.setCancelled(true);
|
e.setCancelled(true);
|
||||||
fme.msg(TL.COMMAND_GETVAULT_CHESTNEAR);
|
fme.msg(TL.COMMAND_GETVAULT_CHESTNEAR);
|
||||||
return;
|
return;
|
||||||
@ -334,8 +283,7 @@ public class FactionsBlockListener implements Listener
|
|||||||
}
|
}
|
||||||
|
|
||||||
@EventHandler
|
@EventHandler
|
||||||
public void onHopperPlace(BlockPlaceEvent e)
|
public void onHopperPlace(BlockPlaceEvent e) {
|
||||||
{
|
|
||||||
if (e.getItemInHand().getType() != Material.HOPPER && !FactionsPlugin.instance.getConfig().getBoolean("fvault.No-Hoppers-near-vault"))
|
if (e.getItemInHand().getType() != Material.HOPPER && !FactionsPlugin.instance.getConfig().getBoolean("fvault.No-Hoppers-near-vault"))
|
||||||
return;
|
return;
|
||||||
Faction factionAt = Board.getInstance().getFactionAt(new FLocation(e.getBlockPlaced().getLocation()));
|
Faction factionAt = Board.getInstance().getFactionAt(new FLocation(e.getBlockPlaced().getLocation()));
|
||||||
@ -344,22 +292,16 @@ public class FactionsBlockListener implements Listener
|
|||||||
FPlayer fme = FPlayers.getInstance().getByPlayer(e.getPlayer());
|
FPlayer fme = FPlayers.getInstance().getByPlayer(e.getPlayer());
|
||||||
Block start = e.getBlockPlaced();
|
Block start = e.getBlockPlaced();
|
||||||
int radius = 1;
|
int radius = 1;
|
||||||
for (double x = start.getLocation().getX() - radius; x <= start.getLocation().getX() + radius; x++)
|
for (double x = start.getLocation().getX() - radius; x <= start.getLocation().getX() + radius; x++) {
|
||||||
{
|
for (double y = start.getLocation().getY() - radius; y <= start.getLocation().getY() + radius; y++) {
|
||||||
for (double y = start.getLocation().getY() - radius; y <= start.getLocation().getY() + radius; y++)
|
for (double z = start.getLocation().getZ() - radius; z <= start.getLocation().getZ() + radius; z++) {
|
||||||
{
|
|
||||||
for (double z = start.getLocation().getZ() - radius; z <= start.getLocation().getZ() + radius; z++)
|
|
||||||
{
|
|
||||||
Location blockLoc = new Location(e.getPlayer().getWorld(), x, y, z);
|
Location blockLoc = new Location(e.getPlayer().getWorld(), x, y, z);
|
||||||
if (blockLoc.getX() == start.getLocation().getX() && blockLoc.getY() == start.getLocation().getY() && blockLoc.getZ() == start.getLocation().getZ())
|
if (blockLoc.getX() == start.getLocation().getX() && blockLoc.getY() == start.getLocation().getY() && blockLoc.getZ() == start.getLocation().getZ()) {
|
||||||
{
|
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (blockLoc.getBlock().getType() == XMaterial.CHEST.parseMaterial())
|
if (blockLoc.getBlock().getType() == XMaterial.CHEST.parseMaterial()) {
|
||||||
{
|
if (factionAt.getVault().equals(blockLoc)) {
|
||||||
if (factionAt.getVault().equals(blockLoc))
|
|
||||||
{
|
|
||||||
e.setCancelled(true);
|
e.setCancelled(true);
|
||||||
fme.msg(TL.COMMAND_VAULT_NO_HOPPER);
|
fme.msg(TL.COMMAND_VAULT_NO_HOPPER);
|
||||||
return;
|
return;
|
||||||
@ -372,8 +314,7 @@ public class FactionsBlockListener implements Listener
|
|||||||
}
|
}
|
||||||
|
|
||||||
@EventHandler(priority = EventPriority.NORMAL, ignoreCancelled = true)
|
@EventHandler(priority = EventPriority.NORMAL, ignoreCancelled = true)
|
||||||
public void onBlockPistonRetract(BlockPistonRetractEvent event)
|
public void onBlockPistonRetract(BlockPistonRetractEvent event) {
|
||||||
{
|
|
||||||
// if not a sticky piston, retraction should be fine
|
// if not a sticky piston, retraction should be fine
|
||||||
if (!event.isSticky() || !Conf.pistonProtectionThroughDenyBuild)
|
if (!event.isSticky() || !Conf.pistonProtectionThroughDenyBuild)
|
||||||
return;
|
return;
|
||||||
@ -382,8 +323,7 @@ public class FactionsBlockListener implements Listener
|
|||||||
Faction otherFaction = Board.getInstance().getFactionAt(new FLocation(targetLoc));
|
Faction otherFaction = Board.getInstance().getFactionAt(new FLocation(targetLoc));
|
||||||
|
|
||||||
// Check if the piston is moving in a faction's territory. This disables pistons entirely in faction territory.
|
// Check if the piston is moving in a faction's territory. This disables pistons entirely in faction territory.
|
||||||
if (otherFaction.isNormal() && FactionsPlugin.instance.getConfig().getBoolean("disable-pistons-in-territory", false))
|
if (otherFaction.isNormal() && FactionsPlugin.instance.getConfig().getBoolean("disable-pistons-in-territory", false)) {
|
||||||
{
|
|
||||||
event.setCancelled(true);
|
event.setCancelled(true);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
@ -397,18 +337,14 @@ public class FactionsBlockListener implements Listener
|
|||||||
}
|
}
|
||||||
|
|
||||||
@EventHandler
|
@EventHandler
|
||||||
public void onBannerBreak(BlockBreakEvent e)
|
public void onBannerBreak(BlockBreakEvent e) {
|
||||||
{
|
|
||||||
FPlayer fme = FPlayers.getInstance().getByPlayer(e.getPlayer());
|
FPlayer fme = FPlayers.getInstance().getByPlayer(e.getPlayer());
|
||||||
if (FactionsPlugin.getInstance().mc17)
|
if (FactionsPlugin.getInstance().mc17) {
|
||||||
{
|
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (bannerLocations.containsValue(e.getBlock().getLocation()))
|
if (bannerLocations.containsValue(e.getBlock().getLocation())) {
|
||||||
{
|
if (e.getBlock().getType().name().contains("BANNER")) {
|
||||||
if (e.getBlock().getType().name().contains("BANNER"))
|
|
||||||
{
|
|
||||||
e.setCancelled(true);
|
e.setCancelled(true);
|
||||||
fme.msg(TL.BANNER_CANNOT_BREAK);
|
fme.msg(TL.BANNER_CANNOT_BREAK);
|
||||||
}
|
}
|
||||||
@ -416,13 +352,11 @@ public class FactionsBlockListener implements Listener
|
|||||||
}
|
}
|
||||||
|
|
||||||
@EventHandler
|
@EventHandler
|
||||||
public void onBannerPlace(BlockPlaceEvent e)
|
public void onBannerPlace(BlockPlaceEvent e) {
|
||||||
{
|
|
||||||
if (FactionsPlugin.getInstance().mc17)
|
if (FactionsPlugin.getInstance().mc17)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
if (e.getItemInHand().getType().name().contains("BANNER"))
|
if (e.getItemInHand().getType().name().contains("BANNER")) {
|
||||||
{
|
|
||||||
ItemStack bannerInHand = e.getItemInHand();
|
ItemStack bannerInHand = e.getItemInHand();
|
||||||
FPlayer fme = FPlayers.getInstance().getByPlayer(e.getPlayer());
|
FPlayer fme = FPlayers.getInstance().getByPlayer(e.getPlayer());
|
||||||
ItemStack warBanner = fme.getFaction().getBanner();
|
ItemStack warBanner = fme.getFaction().getBanner();
|
||||||
@ -432,10 +366,8 @@ public class FactionsBlockListener implements Listener
|
|||||||
warmeta.setDisplayName(FactionsPlugin.getInstance().color(FactionsPlugin.getInstance().getConfig().getString("fbanners.Item.Name")));
|
warmeta.setDisplayName(FactionsPlugin.getInstance().color(FactionsPlugin.getInstance().getConfig().getString("fbanners.Item.Name")));
|
||||||
warmeta.setLore(FactionsPlugin.getInstance().colorList(FactionsPlugin.getInstance().getConfig().getStringList("fbanners.Item.Lore")));
|
warmeta.setLore(FactionsPlugin.getInstance().colorList(FactionsPlugin.getInstance().getConfig().getStringList("fbanners.Item.Lore")));
|
||||||
warBanner.setItemMeta(warmeta);
|
warBanner.setItemMeta(warmeta);
|
||||||
if (warBanner.isSimilar(bannerInHand))
|
if (warBanner.isSimilar(bannerInHand)) {
|
||||||
{
|
if (fme.getFaction().isWilderness()) {
|
||||||
if (fme.getFaction().isWilderness())
|
|
||||||
{
|
|
||||||
fme.msg(TL.WARBANNER_NOFACTION);
|
fme.msg(TL.WARBANNER_NOFACTION);
|
||||||
e.setCancelled(true);
|
e.setCancelled(true);
|
||||||
return;
|
return;
|
||||||
@ -444,16 +376,13 @@ public class FactionsBlockListener implements Listener
|
|||||||
Location placedLoc = e.getBlockPlaced().getLocation();
|
Location placedLoc = e.getBlockPlaced().getLocation();
|
||||||
FLocation fplacedLoc = new FLocation(placedLoc);
|
FLocation fplacedLoc = new FLocation(placedLoc);
|
||||||
if ((Board.getInstance().getFactionAt(fplacedLoc).isWarZone() && FactionsPlugin.getInstance().getConfig().getBoolean("fbanners.Placeable.Warzone"))
|
if ((Board.getInstance().getFactionAt(fplacedLoc).isWarZone() && FactionsPlugin.getInstance().getConfig().getBoolean("fbanners.Placeable.Warzone"))
|
||||||
|| (fme.getFaction().getRelationTo(Board.getInstance().getFactionAt(fplacedLoc)) == Relation.ENEMY && FactionsPlugin.getInstance().getConfig().getBoolean("fbanners.Placeable.Enemy")))
|
|| (fme.getFaction().getRelationTo(Board.getInstance().getFactionAt(fplacedLoc)) == Relation.ENEMY && FactionsPlugin.getInstance().getConfig().getBoolean("fbanners.Placeable.Enemy"))) {
|
||||||
{
|
if (bannerCooldownMap.containsKey(fme.getTag())) {
|
||||||
if (bannerCooldownMap.containsKey(fme.getTag()))
|
|
||||||
{
|
|
||||||
fme.msg(TL.WARBANNER_COOLDOWN);
|
fme.msg(TL.WARBANNER_COOLDOWN);
|
||||||
e.setCancelled(true);
|
e.setCancelled(true);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
for (FPlayer fplayer : fme.getFaction().getFPlayers())
|
for (FPlayer fplayer : fme.getFaction().getFPlayers()) {
|
||||||
{
|
|
||||||
fplayer.getPlayer().sendTitle(FactionsPlugin.getInstance().color(fme.getTag() + " Placed A WarBanner!"), FactionsPlugin.getInstance().color("&7use &c/f tpbanner&7 to tp to the banner!"));
|
fplayer.getPlayer().sendTitle(FactionsPlugin.getInstance().color(fme.getTag() + " Placed A WarBanner!"), FactionsPlugin.getInstance().color("&7use &c/f tpbanner&7 to tp to the banner!"));
|
||||||
}
|
}
|
||||||
bannerCooldownMap.put(fme.getTag(), true);
|
bannerCooldownMap.put(fme.getTag(), true);
|
||||||
@ -475,23 +404,18 @@ public class FactionsBlockListener implements Listener
|
|||||||
List<String> effects = FactionsPlugin.getInstance().getConfig().getStringList("fbanners.Effects");
|
List<String> effects = FactionsPlugin.getInstance().getConfig().getStringList("fbanners.Effects");
|
||||||
int affectorTask = Bukkit.getScheduler().scheduleSyncRepeatingTask(FactionsPlugin.getInstance(), () ->
|
int affectorTask = Bukkit.getScheduler().scheduleSyncRepeatingTask(FactionsPlugin.getInstance(), () ->
|
||||||
{
|
{
|
||||||
for (Entity e1 : Objects.requireNonNull(banner.getLocation().getWorld()).getNearbyEntities(banner.getLocation(), radius, 255.0, radius))
|
for (Entity e1 : Objects.requireNonNull(banner.getLocation().getWorld()).getNearbyEntities(banner.getLocation(), radius, 255.0, radius)) {
|
||||||
{
|
if (e1 instanceof Player) {
|
||||||
if (e1 instanceof Player)
|
|
||||||
{
|
|
||||||
Player player = (Player) e1;
|
Player player = (Player) e1;
|
||||||
FPlayer fplayer = FPlayers.getInstance().getByPlayer(player);
|
FPlayer fplayer = FPlayers.getInstance().getByPlayer(player);
|
||||||
if (fplayer.getFaction() != bannerFaction)
|
if (fplayer.getFaction() != bannerFaction) {
|
||||||
{
|
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
for (String effect : effects)
|
for (String effect : effects) {
|
||||||
{
|
|
||||||
String[] components = effect.split(":");
|
String[] components = effect.split(":");
|
||||||
player.addPotionEffect(new PotionEffect(Objects.requireNonNull(PotionEffectType.getByName(components[0])), 100, Integer.parseInt(components[1])));
|
player.addPotionEffect(new PotionEffect(Objects.requireNonNull(PotionEffectType.getByName(components[0])), 100, Integer.parseInt(components[1])));
|
||||||
}
|
}
|
||||||
if (banner.getType() == bannerType)
|
if (banner.getType() == bannerType) {
|
||||||
{
|
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
banner.setType(bannerType);
|
banner.setType(bannerType);
|
||||||
@ -506,9 +430,7 @@ public class FactionsBlockListener implements Listener
|
|||||||
Bukkit.getScheduler().cancelTask(affectorTask);
|
Bukkit.getScheduler().cancelTask(affectorTask);
|
||||||
FactionsBlockListener.bannerLocations.remove(bannerFaction.getTag());
|
FactionsBlockListener.bannerLocations.remove(bannerFaction.getTag());
|
||||||
}, Long.parseLong(bannerTime + ""));
|
}, Long.parseLong(bannerTime + ""));
|
||||||
}
|
} else {
|
||||||
else
|
|
||||||
{
|
|
||||||
fme.msg(TL.WARBANNER_INVALIDLOC);
|
fme.msg(TL.WARBANNER_INVALIDLOC);
|
||||||
e.setCancelled(true);
|
e.setCancelled(true);
|
||||||
}
|
}
|
||||||
@ -517,15 +439,13 @@ public class FactionsBlockListener implements Listener
|
|||||||
}
|
}
|
||||||
|
|
||||||
@EventHandler(priority = EventPriority.NORMAL, ignoreCancelled = true)
|
@EventHandler(priority = EventPriority.NORMAL, ignoreCancelled = true)
|
||||||
public void onFrostWalker(EntityBlockFormEvent event)
|
public void onFrostWalker(EntityBlockFormEvent event) {
|
||||||
{
|
|
||||||
if (event.getEntity() == null || event.getEntity().getType() != EntityType.PLAYER || event.getBlock() == null)
|
if (event.getEntity() == null || event.getEntity().getType() != EntityType.PLAYER || event.getBlock() == null)
|
||||||
return;
|
return;
|
||||||
Player player = (Player) event.getEntity();
|
Player player = (Player) event.getEntity();
|
||||||
Location location = event.getBlock().getLocation();
|
Location location = event.getBlock().getLocation();
|
||||||
|
|
||||||
if (!event.getBlock().getType().equals(Material.WATER))
|
if (!event.getBlock().getType().equals(Material.WATER)) {
|
||||||
{
|
|
||||||
// If we are not replacing water then this is clearly not a frostwalker event.
|
// If we are not replacing water then this is clearly not a frostwalker event.
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
@ -542,21 +462,18 @@ public class FactionsBlockListener implements Listener
|
|||||||
}
|
}
|
||||||
|
|
||||||
@EventHandler
|
@EventHandler
|
||||||
public void onFallingBlock(EntityChangeBlockEvent event)
|
public void onFallingBlock(EntityChangeBlockEvent event) {
|
||||||
{
|
|
||||||
if (!FactionsPlugin.getInstance().getConfig().getBoolean("Falling-Block-Fix.Enabled"))
|
if (!FactionsPlugin.getInstance().getConfig().getBoolean("Falling-Block-Fix.Enabled"))
|
||||||
return;
|
return;
|
||||||
|
|
||||||
Faction faction = Board.getInstance().getFactionAt(new FLocation(event.getBlock()));
|
Faction faction = Board.getInstance().getFactionAt(new FLocation(event.getBlock()));
|
||||||
if (faction.isWarZone() || faction.isSafeZone())
|
if (faction.isWarZone() || faction.isSafeZone()) {
|
||||||
{
|
|
||||||
event.getBlock().setType(Material.AIR);
|
event.getBlock().setType(Material.AIR);
|
||||||
event.setCancelled(true);
|
event.setCancelled(true);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private boolean canPistonMoveBlock(Faction pistonFaction, Location target)
|
private boolean canPistonMoveBlock(Faction pistonFaction, Location target) {
|
||||||
{
|
|
||||||
Faction otherFaction = Board.getInstance().getFactionAt(new FLocation(target));
|
Faction otherFaction = Board.getInstance().getFactionAt(new FLocation(target));
|
||||||
|
|
||||||
if (pistonFaction == otherFaction)
|
if (pistonFaction == otherFaction)
|
||||||
@ -574,17 +491,14 @@ public class FactionsBlockListener implements Listener
|
|||||||
}
|
}
|
||||||
|
|
||||||
@EventHandler(priority = EventPriority.NORMAL, ignoreCancelled = true)
|
@EventHandler(priority = EventPriority.NORMAL, ignoreCancelled = true)
|
||||||
public void onBlockBreak(BlockBreakEvent event)
|
public void onBlockBreak(BlockBreakEvent event) {
|
||||||
{
|
|
||||||
// If there is an error its much safer to not allow the block to be broken
|
// If there is an error its much safer to not allow the block to be broken
|
||||||
try
|
try {
|
||||||
{
|
|
||||||
Block block = event.getBlock();
|
Block block = event.getBlock();
|
||||||
|
|
||||||
Faction at = Board.getInstance().getFactionAt(new FLocation(block));
|
Faction at = Board.getInstance().getFactionAt(new FLocation(block));
|
||||||
boolean isSpawner = event.getBlock().getType().equals(XMaterial.SPAWNER.parseMaterial());
|
boolean isSpawner = event.getBlock().getType().equals(XMaterial.SPAWNER.parseMaterial());
|
||||||
if (!playerCanBuildDestroyBlock(event.getPlayer(), event.getBlock().getLocation(), PermissableAction.DESTROY, false))
|
if (!playerCanBuildDestroyBlock(event.getPlayer(), event.getBlock().getLocation(), PermissableAction.DESTROY, false)) {
|
||||||
{
|
|
||||||
event.setCancelled(true);
|
event.setCancelled(true);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
@ -593,26 +507,20 @@ public class FactionsBlockListener implements Listener
|
|||||||
if (fme == null || !fme.hasFaction())
|
if (fme == null || !fme.hasFaction())
|
||||||
return;
|
return;
|
||||||
|
|
||||||
if (isSpawner)
|
if (isSpawner) {
|
||||||
{
|
|
||||||
Access access = fme.getFaction().getAccess(fme, PermissableAction.SPAWNER);
|
Access access = fme.getFaction().getAccess(fme, PermissableAction.SPAWNER);
|
||||||
if (access != Access.ALLOW && fme.getRole() != Role.LEADER)
|
if (access != Access.ALLOW && fme.getRole() != Role.LEADER) {
|
||||||
{
|
|
||||||
fme.msg(TL.GENERIC_FPERM_NOPERMISSION, "mine spawners");
|
fme.msg(TL.GENERIC_FPERM_NOPERMISSION, "mine spawners");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (isSpawner && !fme.isAdminBypassing())
|
if (isSpawner && !fme.isAdminBypassing()) {
|
||||||
{
|
|
||||||
ItemStack item = new ItemStack(block.getType(), 1, block.getData());
|
ItemStack item = new ItemStack(block.getType(), 1, block.getData());
|
||||||
if (at != null && at.isNormal())
|
if (at != null && at.isNormal()) {
|
||||||
{
|
|
||||||
FPlayer fplayer = FPlayers.getInstance().getByPlayer(event.getPlayer());
|
FPlayer fplayer = FPlayers.getInstance().getByPlayer(event.getPlayer());
|
||||||
if (fplayer != null)
|
if (fplayer != null) {
|
||||||
{
|
|
||||||
BlockState state = block.getState();
|
BlockState state = block.getState();
|
||||||
if (state instanceof CreatureSpawner)
|
if (state instanceof CreatureSpawner) {
|
||||||
{
|
|
||||||
CreatureSpawner spawner = (CreatureSpawner) state;
|
CreatureSpawner spawner = (CreatureSpawner) state;
|
||||||
item.setDurability(spawner.getSpawnedType().getTypeId());
|
item.setDurability(spawner.getSpawnedType().getTypeId());
|
||||||
}
|
}
|
||||||
@ -620,26 +528,20 @@ public class FactionsBlockListener implements Listener
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
} catch (Exception e) {
|
||||||
catch (Exception e)
|
|
||||||
{
|
|
||||||
event.setCancelled(true);
|
event.setCancelled(true);
|
||||||
e.printStackTrace();
|
e.printStackTrace();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@EventHandler(priority = EventPriority.HIGHEST)
|
@EventHandler(priority = EventPriority.HIGHEST)
|
||||||
public void FrameRemove(HangingBreakByEntityEvent event)
|
public void FrameRemove(HangingBreakByEntityEvent event) {
|
||||||
{
|
|
||||||
if (event.getRemover() == null)
|
if (event.getRemover() == null)
|
||||||
return;
|
return;
|
||||||
if ((event.getRemover() instanceof Player))
|
if ((event.getRemover() instanceof Player)) {
|
||||||
{
|
if (event.getEntity().getType().equals(EntityType.ITEM_FRAME)) {
|
||||||
if (event.getEntity().getType().equals(EntityType.ITEM_FRAME))
|
|
||||||
{
|
|
||||||
Player p = (Player) event.getRemover();
|
Player p = (Player) event.getRemover();
|
||||||
if (!playerCanBuildDestroyBlock(p, event.getEntity().getLocation(), PermissableAction.DESTROY, true))
|
if (!playerCanBuildDestroyBlock(p, event.getEntity().getLocation(), PermissableAction.DESTROY, true)) {
|
||||||
{
|
|
||||||
event.setCancelled(true);
|
event.setCancelled(true);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
@ -648,13 +550,10 @@ public class FactionsBlockListener implements Listener
|
|||||||
}
|
}
|
||||||
|
|
||||||
@EventHandler
|
@EventHandler
|
||||||
public void onFarmLandDamage(EntityChangeBlockEvent event)
|
public void onFarmLandDamage(EntityChangeBlockEvent event) {
|
||||||
{
|
if (event.getEntity() instanceof Player) {
|
||||||
if (event.getEntity() instanceof Player)
|
|
||||||
{
|
|
||||||
Player player = (Player) event.getEntity();
|
Player player = (Player) event.getEntity();
|
||||||
if (!playerCanBuildDestroyBlock(player, event.getBlock().getLocation(), PermissableAction.DESTROY, true))
|
if (!playerCanBuildDestroyBlock(player, event.getBlock().getLocation(), PermissableAction.DESTROY, true)) {
|
||||||
{
|
|
||||||
FPlayer me = FPlayers.getInstance().getByPlayer(player);
|
FPlayer me = FPlayers.getInstance().getByPlayer(player);
|
||||||
Faction otherFaction = Board.getInstance().getFactionAt(new FLocation(event.getBlock().getLocation()));
|
Faction otherFaction = Board.getInstance().getFactionAt(new FLocation(event.getBlock().getLocation()));
|
||||||
me.msg(TL.ACTION_DENIED_OTHER, otherFaction.getTag(), "trample crops");
|
me.msg(TL.ACTION_DENIED_OTHER, otherFaction.getTag(), "trample crops");
|
||||||
|
@ -4,7 +4,6 @@ import com.massivecraft.factions.*;
|
|||||||
import com.massivecraft.factions.event.PowerLossEvent;
|
import com.massivecraft.factions.event.PowerLossEvent;
|
||||||
import com.massivecraft.factions.struct.Relation;
|
import com.massivecraft.factions.struct.Relation;
|
||||||
import com.massivecraft.factions.util.MiscUtil;
|
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.fperms.PermissableAction;
|
||||||
import com.massivecraft.factions.zcore.util.TL;
|
import com.massivecraft.factions.zcore.util.TL;
|
||||||
import org.bukkit.Bukkit;
|
import org.bukkit.Bukkit;
|
||||||
|
@ -4,7 +4,6 @@ import com.massivecraft.factions.*;
|
|||||||
import com.massivecraft.factions.cmd.CmdFGlobal;
|
import com.massivecraft.factions.cmd.CmdFGlobal;
|
||||||
import com.massivecraft.factions.cmd.CmdFly;
|
import com.massivecraft.factions.cmd.CmdFly;
|
||||||
import com.massivecraft.factions.cmd.CmdSeeChunk;
|
import com.massivecraft.factions.cmd.CmdSeeChunk;
|
||||||
import com.massivecraft.factions.cmd.FCmdRoot;
|
|
||||||
import com.massivecraft.factions.cmd.audit.FLogType;
|
import com.massivecraft.factions.cmd.audit.FLogType;
|
||||||
import com.massivecraft.factions.cmd.logout.LogoutHandler;
|
import com.massivecraft.factions.cmd.logout.LogoutHandler;
|
||||||
import com.massivecraft.factions.cmd.wild.CmdWild;
|
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 net.dv8tion.jda.core.entities.TextChannel;
|
||||||
import org.bukkit.*;
|
import org.bukkit.*;
|
||||||
import org.bukkit.block.Block;
|
import org.bukkit.block.Block;
|
||||||
import org.bukkit.entity.Boat;
|
|
||||||
import org.bukkit.entity.Minecart;
|
|
||||||
import org.bukkit.entity.Player;
|
import org.bukkit.entity.Player;
|
||||||
import org.bukkit.event.Event;
|
import org.bukkit.event.Event;
|
||||||
import org.bukkit.event.EventHandler;
|
import org.bukkit.event.EventHandler;
|
||||||
@ -57,7 +54,9 @@ import java.util.logging.Level;
|
|||||||
|
|
||||||
public class FactionsPlayerListener implements Listener {
|
public class FactionsPlayerListener implements Listener {
|
||||||
|
|
||||||
|
public final static Map<UUID, Location> lastLocations = new HashMap<>();
|
||||||
public static Set<FLocation> corners;
|
public static Set<FLocation> corners;
|
||||||
|
public static BukkitTask positionTask = null;
|
||||||
/**
|
/**
|
||||||
* @author FactionsUUID Team
|
* @author FactionsUUID Team
|
||||||
*/
|
*/
|
||||||
@ -655,9 +654,6 @@ public class FactionsPlayerListener implements Listener {
|
|||||||
return (result.length() == 3 ? result + "0" : result) + "/hrs ago";
|
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() {
|
public void startPositionCheck() {
|
||||||
positionTask = Bukkit.getScheduler().runTaskTimer(FactionsPlugin.getInstance(), () -> {
|
positionTask = Bukkit.getScheduler().runTaskTimer(FactionsPlugin.getInstance(), () -> {
|
||||||
if (lastLocations.isEmpty()) return;
|
if (lastLocations.isEmpty()) return;
|
||||||
@ -741,7 +737,8 @@ public class FactionsPlayerListener implements Listener {
|
|||||||
me.attemptClaim(me.getAutoClaimFor(), newLocation, true);
|
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(","));
|
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()) {
|
} else if (me.isAutoSafeClaimEnabled()) {
|
||||||
if (!Permission.MANAGE_SAFE_ZONE.has(player)) {
|
if (!Permission.MANAGE_SAFE_ZONE.has(player)) {
|
||||||
|
@ -26,8 +26,7 @@ import java.util.Set;
|
|||||||
import java.util.logging.Level;
|
import java.util.logging.Level;
|
||||||
import java.util.stream.Collectors;
|
import java.util.stream.Collectors;
|
||||||
|
|
||||||
public class ShopGUIFrame
|
public class ShopGUIFrame {
|
||||||
{
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @author Driftay
|
* @author Driftay
|
||||||
@ -35,13 +34,11 @@ public class ShopGUIFrame
|
|||||||
|
|
||||||
private Gui gui;
|
private Gui gui;
|
||||||
|
|
||||||
public ShopGUIFrame(Faction f)
|
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")));
|
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)
|
public void buildGUI(FPlayer fplayer) {
|
||||||
{
|
|
||||||
PaginatedPane pane = new PaginatedPane(0, 0, 9, gui.getRows());
|
PaginatedPane pane = new PaginatedPane(0, 0, 9, gui.getRows());
|
||||||
List<GuiItem> GUIItems = new ArrayList<>();
|
List<GuiItem> GUIItems = new ArrayList<>();
|
||||||
ItemStack dummy = buildDummyItem(fplayer.getFaction());
|
ItemStack dummy = buildDummyItem(fplayer.getFaction());
|
||||||
@ -49,10 +46,8 @@ public class ShopGUIFrame
|
|||||||
GUIItems.add(new GuiItem(dummy, e -> e.setCancelled(true)));
|
GUIItems.add(new GuiItem(dummy, e -> e.setCancelled(true)));
|
||||||
|
|
||||||
Set<String> items = FactionsPlugin.getInstance().getFileManager().getShop().getConfig().getConfigurationSection("items").getKeys(false);
|
Set<String> items = FactionsPlugin.getInstance().getFileManager().getShop().getConfig().getConfigurationSection("items").getKeys(false);
|
||||||
for (String s : items)
|
for (String s : items) {
|
||||||
{
|
if (!checkShopConfig(s)) {
|
||||||
if (!checkShopConfig(s))
|
|
||||||
{
|
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -67,8 +62,7 @@ public class ShopGUIFrame
|
|||||||
ItemMeta meta = item.getItemMeta();
|
ItemMeta meta = item.getItemMeta();
|
||||||
meta.setDisplayName(FactionsPlugin.instance.color(name));
|
meta.setDisplayName(FactionsPlugin.instance.color(name));
|
||||||
meta.addItemFlags();
|
meta.addItemFlags();
|
||||||
if (glowing)
|
if (glowing) {
|
||||||
{
|
|
||||||
meta.addItemFlags(ItemFlag.HIDE_ENCHANTS);
|
meta.addItemFlags(ItemFlag.HIDE_ENCHANTS);
|
||||||
meta.addEnchant(Enchantment.DURABILITY, 1, true);
|
meta.addEnchant(Enchantment.DURABILITY, 1, true);
|
||||||
}
|
}
|
||||||
@ -81,25 +75,18 @@ public class ShopGUIFrame
|
|||||||
{
|
{
|
||||||
e.setCancelled(true);
|
e.setCancelled(true);
|
||||||
FPlayer fme = FPlayers.getInstance().getByPlayer((Player) e.getWhoClicked());
|
FPlayer fme = FPlayers.getInstance().getByPlayer((Player) e.getWhoClicked());
|
||||||
if (fplayer.getFaction().getPoints() >= cost)
|
if (fplayer.getFaction().getPoints() >= cost) {
|
||||||
{
|
if (runCommands(FactionsPlugin.getInstance().getFileManager().getShop().fetchStringList("items." + s + ".cmds"), fplayer.getPlayer())) {
|
||||||
if (runCommands(FactionsPlugin.getInstance().getFileManager().getShop().fetchStringList("items." + s + ".cmds"), fplayer.getPlayer()))
|
|
||||||
{
|
|
||||||
fplayer.getFaction().setPoints(fplayer.getFaction().getPoints() - cost);
|
fplayer.getFaction().setPoints(fplayer.getFaction().getPoints() - cost);
|
||||||
for (FPlayer fplayerBuy : fplayer.getFaction().getFPlayers())
|
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)))
|
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 + ""));
|
.replace("{cost}", cost + ""));
|
||||||
}
|
}
|
||||||
buildGUI(fme);
|
buildGUI(fme);
|
||||||
}
|
} else {
|
||||||
else
|
|
||||||
{
|
|
||||||
fplayer.msg(TL.SHOP_ERROR_DURING_PURCHASE);
|
fplayer.msg(TL.SHOP_ERROR_DURING_PURCHASE);
|
||||||
}
|
}
|
||||||
}
|
} else {
|
||||||
else
|
|
||||||
{
|
|
||||||
fplayer.msg(TL.SHOP_NOT_ENOUGH_POINTS);
|
fplayer.msg(TL.SHOP_NOT_ENOUGH_POINTS);
|
||||||
}
|
}
|
||||||
}));
|
}));
|
||||||
@ -110,13 +97,11 @@ public class ShopGUIFrame
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private ItemStack buildDummyItem(Faction f)
|
private ItemStack buildDummyItem(Faction f) {
|
||||||
{
|
|
||||||
ConfigurationSection config = FactionsPlugin.getInstance().getConfig().getConfigurationSection("F-Shop.GUI.dummy-item");
|
ConfigurationSection config = FactionsPlugin.getInstance().getConfig().getConfigurationSection("F-Shop.GUI.dummy-item");
|
||||||
ItemStack item = XMaterial.matchXMaterial(config.getString("Type")).get().parseItem();
|
ItemStack item = XMaterial.matchXMaterial(config.getString("Type")).get().parseItem();
|
||||||
ItemMeta meta = item.getItemMeta();
|
ItemMeta meta = item.getItemMeta();
|
||||||
if (meta != null)
|
if (meta != null) {
|
||||||
{
|
|
||||||
meta.setLore(FactionsPlugin.getInstance().colorList(config.getStringList("Lore")));
|
meta.setLore(FactionsPlugin.getInstance().colorList(config.getStringList("Lore")));
|
||||||
meta.setDisplayName(FactionsPlugin.getInstance().color(config.getString("Name").replace("{points}", f.getPoints() + "")));
|
meta.setDisplayName(FactionsPlugin.getInstance().color(config.getString("Name").replace("{points}", f.getPoints() + "")));
|
||||||
item.setItemMeta(meta);
|
item.setItemMeta(meta);
|
||||||
@ -124,104 +109,80 @@ public class ShopGUIFrame
|
|||||||
return item;
|
return item;
|
||||||
}
|
}
|
||||||
|
|
||||||
public boolean checkShopConfig()
|
public boolean checkShopConfig() {
|
||||||
{
|
|
||||||
boolean ret = true;
|
boolean ret = true;
|
||||||
Set<String> items = FactionsPlugin.getInstance().getFileManager().getShop().getConfig().getConfigurationSection("items").getKeys(false);
|
Set<String> items = FactionsPlugin.getInstance().getFileManager().getShop().getConfig().getConfigurationSection("items").getKeys(false);
|
||||||
for (String s : items)
|
for (String s : items) {
|
||||||
{
|
if (checkShopConfig(s) == false) {
|
||||||
if (checkShopConfig(s) == false)
|
|
||||||
{
|
|
||||||
ret = false;
|
ret = false;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return ret;
|
return ret;
|
||||||
}
|
}
|
||||||
|
|
||||||
public boolean checkShopConfig(String s)
|
public boolean checkShopConfig(String s) {
|
||||||
{
|
|
||||||
boolean ret = true;
|
boolean ret = true;
|
||||||
if (!FactionsPlugin.getInstance().getFileManager().getShop().containsKey("items." + s + ".slot"))
|
if (!FactionsPlugin.getInstance().getFileManager().getShop().containsKey("items." + s + ".slot")) {
|
||||||
{
|
FactionsPlugin.getInstance().log(Level.WARNING, "Problem with config item '" + s + "' missing slot variable");
|
||||||
FactionsPlugin.getInstance().log(Level.WARNING, "Problem with config item \'" + s + "\' missing slot variable");
|
|
||||||
ret = false;
|
ret = false;
|
||||||
}
|
}
|
||||||
if (!FactionsPlugin.getInstance().getFileManager().getShop().containsKey("items." + s + ".block"))
|
if (!FactionsPlugin.getInstance().getFileManager().getShop().containsKey("items." + s + ".block")) {
|
||||||
{
|
FactionsPlugin.getInstance().log(Level.WARNING, "Problem with config item '" + s + "' missing block variable");
|
||||||
FactionsPlugin.getInstance().log(Level.WARNING, "Problem with config item \'" + s + "\' missing block variable");
|
|
||||||
ret = false;
|
ret = false;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!FactionsPlugin.getInstance().getFileManager().getShop().containsKey("items." + s + ".cmds"))
|
if (!FactionsPlugin.getInstance().getFileManager().getShop().containsKey("items." + s + ".cmds")) {
|
||||||
{
|
FactionsPlugin.getInstance().log(Level.WARNING, "Problee with config item '" + s + "' missing cmds variable");
|
||||||
FactionsPlugin.getInstance().log(Level.WARNING, "Problee with config item \'" + s + "\' missing cmds variable");
|
|
||||||
ret = false;
|
ret = false;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!FactionsPlugin.getInstance().getFileManager().getShop().containsKey("items." + s + ".cost"))
|
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");
|
||||||
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"))
|
if (!FactionsPlugin.getInstance().getFileManager().getShop().containsKey("items." + s + ".name")) {
|
||||||
{
|
FactionsPlugin.getInstance().log(Level.WARNING, "Problem with config item '" + s + "' missing name variable");
|
||||||
FactionsPlugin.getInstance().log(Level.WARNING, "Problem with config item \'" + s + "\' missing name variable");
|
|
||||||
ret = false;
|
ret = false;
|
||||||
}
|
}
|
||||||
return ret;
|
return ret;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
*
|
* @param list The list of commands to be ran.
|
||||||
* @param list
|
* @param p The player that is using the shop
|
||||||
* 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.
|
* @return if all commands are able to be ran or if they did run.
|
||||||
*/
|
*/
|
||||||
public boolean runCommands(List<String> list, Player p)
|
public boolean runCommands(List<String> list, Player p) {
|
||||||
{
|
for (String cmd : list) {
|
||||||
for (String cmd : list)
|
|
||||||
{
|
|
||||||
cmd = cmd.replace("%player%", p.getName());
|
cmd = cmd.replace("%player%", p.getName());
|
||||||
if (cmd.toLowerCase().startsWith("give"))
|
if (cmd.toLowerCase().startsWith("give")) {
|
||||||
{
|
|
||||||
String[] args = cmd.split(" ");
|
String[] args = cmd.split(" ");
|
||||||
if (args.length == 4)
|
if (args.length == 4) {
|
||||||
{
|
|
||||||
Material material = Material.matchMaterial(args[2]);
|
Material material = Material.matchMaterial(args[2]);
|
||||||
int amount = Integer.parseInt(args[3]);
|
int amount = Integer.parseInt(args[3]);
|
||||||
Player player = Bukkit.getPlayer(args[1]);
|
Player player = Bukkit.getPlayer(args[1]);
|
||||||
if (!player.isOnline())
|
if (!player.isOnline()) {
|
||||||
{
|
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
// See if the player has this item in their inventory;
|
// See if the player has this item in their inventory;
|
||||||
if (player.getInventory().contains(material) && player.getInventory().firstEmpty() < 0)
|
if (player.getInventory().contains(material) && player.getInventory().firstEmpty() < 0) {
|
||||||
{
|
|
||||||
int spacesAvailable = 0;
|
int spacesAvailable = 0;
|
||||||
Map<Integer, ? extends ItemStack> contents = player.getInventory().all(material);
|
Map<Integer, ? extends ItemStack> contents = player.getInventory().all(material);
|
||||||
for (ItemStack stack : contents.values())
|
for (ItemStack stack : contents.values()) {
|
||||||
{
|
|
||||||
spacesAvailable += stack.getMaxStackSize() - stack.getAmount();
|
spacesAvailable += stack.getMaxStackSize() - stack.getAmount();
|
||||||
}
|
}
|
||||||
if (spacesAvailable < amount)
|
if (spacesAvailable < amount) {
|
||||||
{
|
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
} else {
|
||||||
else
|
if (player.getInventory().firstEmpty() < 0) {
|
||||||
{
|
|
||||||
if (player.getInventory().firstEmpty() < 0)
|
|
||||||
{
|
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
for (String cmd : list)
|
for (String cmd : list) {
|
||||||
{
|
|
||||||
cmd = cmd.replace("%player%", p.getName());
|
cmd = cmd.replace("%player%", p.getName());
|
||||||
Bukkit.dispatchCommand(Bukkit.getConsoleSender(), cmd);
|
Bukkit.dispatchCommand(Bukkit.getConsoleSender(), cmd);
|
||||||
}
|
}
|
||||||
|
@ -15,12 +15,15 @@ import org.bukkit.ChatColor;
|
|||||||
import org.bukkit.entity.Player;
|
import org.bukkit.entity.Player;
|
||||||
|
|
||||||
import java.lang.reflect.InvocationTargetException;
|
import java.lang.reflect.InvocationTargetException;
|
||||||
import java.util.Arrays;
|
|
||||||
import java.util.UUID;
|
import java.util.UUID;
|
||||||
import java.util.logging.Level;
|
import java.util.logging.Level;
|
||||||
|
|
||||||
public class ClipPlaceholderAPIManager extends PlaceholderExpansion implements Relational {
|
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
|
// Identifier for this expansion
|
||||||
@Override
|
@Override
|
||||||
public String getIdentifier() {
|
public String getIdentifier() {
|
||||||
@ -249,10 +252,6 @@ public class ClipPlaceholderAPIManager extends PlaceholderExpansion implements R
|
|||||||
return TL.PLACEHOLDERAPI_NULL.toString();
|
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) {
|
private int countOn(Faction f, Relation relation, Boolean status, FPlayer player) {
|
||||||
int count = 0;
|
int count = 0;
|
||||||
for (Faction faction : Factions.getInstance().getAllFactions()) {
|
for (Faction faction : Factions.getInstance().getAllFactions()) {
|
||||||
|
@ -3,7 +3,6 @@ package com.massivecraft.factions.util;
|
|||||||
import com.massivecraft.factions.FactionsPlugin;
|
import com.massivecraft.factions.FactionsPlugin;
|
||||||
import org.bukkit.entity.Player;
|
import org.bukkit.entity.Player;
|
||||||
import org.bukkit.metadata.FixedMetadataValue;
|
import org.bukkit.metadata.FixedMetadataValue;
|
||||||
import org.bukkit.metadata.MetadataValue;
|
|
||||||
|
|
||||||
import java.util.concurrent.TimeUnit;
|
import java.util.concurrent.TimeUnit;
|
||||||
|
|
||||||
|
@ -1,12 +1,5 @@
|
|||||||
package com.massivecraft.factions.util.timer;
|
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.
|
* Factions - Developed by Driftay.
|
||||||
* All rights reserved 2020.
|
* All rights reserved 2020.
|
||||||
|
@ -8,8 +8,8 @@ import com.massivecraft.factions.util.Config;
|
|||||||
* Creation Date: 4/7/2020
|
* Creation Date: 4/7/2020
|
||||||
*/
|
*/
|
||||||
public abstract class Timer {
|
public abstract class Timer {
|
||||||
protected final String name;
|
|
||||||
public final long defaultCooldown;
|
public final long defaultCooldown;
|
||||||
|
protected final String name;
|
||||||
|
|
||||||
|
|
||||||
public Timer(String name, long defaultCooldown) {
|
public Timer(String name, long defaultCooldown) {
|
||||||
|
@ -16,14 +16,24 @@ import java.util.concurrent.TimeUnit;
|
|||||||
* Creation Date: 4/7/2020
|
* Creation Date: 4/7/2020
|
||||||
*/
|
*/
|
||||||
public class TimerManager implements Listener, Runnable {
|
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 MINUTE = TimeUnit.MINUTES.toMillis(1L);
|
||||||
private static final long HOUR = TimeUnit.HOURS.toMillis(1L);
|
private static final long HOUR = TimeUnit.HOURS.toMillis(1L);
|
||||||
private static final long MULTI_HOUR = TimeUnit.HOURS.toMillis(10);
|
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) {
|
public static String getRemaining(long millis, boolean milliseconds) {
|
||||||
return getRemaining(millis, milliseconds, true);
|
return getRemaining(millis, milliseconds, true);
|
||||||
@ -36,16 +46,6 @@ public class TimerManager implements Listener, Runnable {
|
|||||||
return DurationFormatUtils.formatDuration(duration, (duration >= HOUR ? (duration >= MULTI_HOUR ? "d" : "") + "d:" : "") + "HH:mm:ss");
|
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() {
|
public Collection<Timer> getTimers() {
|
||||||
return this.timers;
|
return this.timers;
|
||||||
}
|
}
|
||||||
|
@ -45,15 +45,13 @@ public class TimerRunnable {
|
|||||||
return getRemaining(false);
|
return getRemaining(false);
|
||||||
}
|
}
|
||||||
|
|
||||||
public long getRemaining(long now) {
|
|
||||||
return getRemaining(false, now);
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
public void setRemaining(long remaining) {
|
public void setRemaining(long remaining) {
|
||||||
setExpiryMillis(remaining);
|
setExpiryMillis(remaining);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public long getRemaining(long now) {
|
||||||
|
return getRemaining(false, now);
|
||||||
|
}
|
||||||
|
|
||||||
public long getRemaining(boolean ignorePaused) {
|
public long getRemaining(boolean ignorePaused) {
|
||||||
if ((!ignorePaused) && (this.pauseMillis != 0L)) return this.pauseMillis;
|
if ((!ignorePaused) && (this.pauseMillis != 0L)) return this.pauseMillis;
|
||||||
|
@ -3,7 +3,10 @@ package com.massivecraft.factions.zcore;
|
|||||||
import com.google.gson.Gson;
|
import com.google.gson.Gson;
|
||||||
import com.google.gson.GsonBuilder;
|
import com.google.gson.GsonBuilder;
|
||||||
import com.google.gson.reflect.TypeToken;
|
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.persist.SaveTask;
|
||||||
import com.massivecraft.factions.zcore.util.PermUtil;
|
import com.massivecraft.factions.zcore.util.PermUtil;
|
||||||
import com.massivecraft.factions.zcore.util.Persist;
|
import com.massivecraft.factions.zcore.util.Persist;
|
||||||
|
@ -6,13 +6,11 @@ import com.github.stefvanschie.inventoryframework.pane.PaginatedPane;
|
|||||||
import com.massivecraft.factions.FPlayer;
|
import com.massivecraft.factions.FPlayer;
|
||||||
import com.massivecraft.factions.Faction;
|
import com.massivecraft.factions.Faction;
|
||||||
import com.massivecraft.factions.FactionsPlugin;
|
import com.massivecraft.factions.FactionsPlugin;
|
||||||
import com.massivecraft.factions.cmd.audit.FLogType;
|
|
||||||
import com.massivecraft.factions.util.XMaterial;
|
import com.massivecraft.factions.util.XMaterial;
|
||||||
import com.massivecraft.factions.zcore.fperms.Access;
|
import com.massivecraft.factions.zcore.fperms.Access;
|
||||||
import com.massivecraft.factions.zcore.fperms.Permissable;
|
import com.massivecraft.factions.zcore.fperms.Permissable;
|
||||||
import com.massivecraft.factions.zcore.fperms.PermissableAction;
|
import com.massivecraft.factions.zcore.fperms.PermissableAction;
|
||||||
import com.massivecraft.factions.zcore.util.TL;
|
import com.massivecraft.factions.zcore.util.TL;
|
||||||
import org.bukkit.ChatColor;
|
|
||||||
import org.bukkit.configuration.ConfigurationSection;
|
import org.bukkit.configuration.ConfigurationSection;
|
||||||
import org.bukkit.inventory.ItemStack;
|
import org.bukkit.inventory.ItemStack;
|
||||||
import org.bukkit.inventory.meta.ItemMeta;
|
import org.bukkit.inventory.meta.ItemMeta;
|
||||||
|
@ -16,7 +16,6 @@ import org.bukkit.inventory.meta.ItemMeta;
|
|||||||
|
|
||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
import java.util.Objects;
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @author Saser
|
* @author Saser
|
||||||
@ -36,7 +35,8 @@ public class FUpgradeFrame {
|
|||||||
PaginatedPane pane = new PaginatedPane(0, 0, 9, this.gui.getRows());
|
PaginatedPane pane = new PaginatedPane(0, 0, 9, this.gui.getRows());
|
||||||
List<GuiItem> GUIItems = new ArrayList<>();
|
List<GuiItem> GUIItems = new ArrayList<>();
|
||||||
ItemStack dummy = buildDummyItem();
|
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()) {
|
for (UpgradeType value : UpgradeType.values()) {
|
||||||
if (value.getSlot() != -1) {
|
if (value.getSlot() != -1) {
|
||||||
GUIItems.set(value.getSlot(), new GuiItem(value.buildAsset(fplayer.getFaction()), e -> {
|
GUIItems.set(value.getSlot(), new GuiItem(value.buildAsset(fplayer.getFaction()), e -> {
|
||||||
|
@ -972,8 +972,7 @@ public abstract class MemoryFPlayer implements FPlayer {
|
|||||||
}
|
}
|
||||||
|
|
||||||
public void setFFlying(boolean fly, boolean damage) {
|
public void setFFlying(boolean fly, boolean damage) {
|
||||||
if(FactionsPlugin.getInstance().getConfig().getBoolean("enable-faction-flight"))
|
if (FactionsPlugin.getInstance().getConfig().getBoolean("enable-faction-flight")) {
|
||||||
{
|
|
||||||
Player player = getPlayer();
|
Player player = getPlayer();
|
||||||
if (player == null) return;
|
if (player == null) return;
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user