commit
14776b8877
@ -2,45 +2,71 @@ package com.massivecraft.factions.cmd;
|
|||||||
|
|
||||||
import com.massivecraft.factions.*;
|
import com.massivecraft.factions.*;
|
||||||
import com.massivecraft.factions.struct.Permission;
|
import com.massivecraft.factions.struct.Permission;
|
||||||
|
import com.massivecraft.factions.struct.Role;
|
||||||
import com.massivecraft.factions.util.WarmUpUtil;
|
import com.massivecraft.factions.util.WarmUpUtil;
|
||||||
|
import com.massivecraft.factions.zcore.fperms.Access;
|
||||||
|
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();
|
{
|
||||||
this.aliases.addAll(Aliases.checkpoint);
|
super();
|
||||||
|
this.aliases.addAll(Aliases.checkpoint);
|
||||||
|
|
||||||
this.optionalArgs.put("set", "");
|
this.optionalArgs.put("set", "");
|
||||||
|
|
||||||
this.requirements = new CommandRequirements.Builder(Permission.CHECKPOINT)
|
this.requirements = new CommandRequirements.Builder(Permission.CHECKPOINT).playerOnly().memberOnly().build();
|
||||||
.playerOnly()
|
}
|
||||||
.memberOnly()
|
|
||||||
.build();
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void perform(CommandContext context) {
|
public void perform(CommandContext context) {
|
||||||
if (!FactionsPlugin.getInstance().getConfig().getBoolean("checkpoints.Enabled")) {
|
if (!FactionsPlugin.getInstance().getConfig().getBoolean("checkpoints.Enabled")) {
|
||||||
context.msg(TL.COMMAND_CHECKPOINT_DISABLED);
|
context.msg(TL.COMMAND_CHECKPOINT_DISABLED);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
if (context.args.size() == 1) {
|
if (context.args.size() == 1 && context.args.get(0).equalsIgnoreCase("set")) {
|
||||||
FLocation myLocation = new FLocation(context.player.getLocation());
|
if (context.fPlayer.getRole() == Role.LEADER)
|
||||||
Faction myLocFaction = Board.getInstance().getFactionAt(myLocation);
|
{
|
||||||
if (myLocFaction == Factions.getInstance().getWilderness() || myLocFaction == context.faction) {
|
FLocation myLocation = new FLocation(context.player.getLocation());
|
||||||
context.faction.setCheckpoint(context.player.getLocation());
|
Faction myLocFaction = Board.getInstance().getFactionAt(myLocation);
|
||||||
context.msg(TL.COMMAND_CHECKPOINT_SET);
|
if (myLocFaction == Factions.getInstance().getWilderness() || myLocFaction == context.faction) {
|
||||||
return;
|
context.faction.setCheckpoint(context.player.getLocation());
|
||||||
} else {
|
context.msg(TL.COMMAND_CHECKPOINT_SET);
|
||||||
context.msg(TL.COMMAND_CHECKPOINT_INVALIDLOCATION);
|
return;
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
context.msg(TL.COMMAND_CHECKPOINT_INVALIDLOCATION);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
PermissableAction action = PermissableAction.SETWARP;
|
||||||
|
Access access = context.faction.getAccess(context.fPlayer, action);
|
||||||
|
if (access == Access.DENY) {
|
||||||
|
context.msg(TL.GENERIC_FPERM_NOPERMISSION, action.getName());
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
FLocation myLocation = new FLocation(context.player.getLocation());
|
||||||
|
Faction myLocFaction = Board.getInstance().getFactionAt(myLocation);
|
||||||
|
if (myLocFaction == Factions.getInstance().getWilderness() || myLocFaction == context.faction) {
|
||||||
|
context.faction.setCheckpoint(context.player.getLocation());
|
||||||
|
context.msg(TL.COMMAND_CHECKPOINT_SET);
|
||||||
|
return;
|
||||||
|
}else {
|
||||||
|
context.msg(TL.COMMAND_CHECKPOINT_INVALIDLOCATION);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (context.faction.getCheckpoint() == null) {
|
if (context.faction.getCheckpoint() == null) {
|
||||||
context.msg(TL.COMMAND_CHECKPOINT_NOT_SET);
|
context.msg(TL.COMMAND_CHECKPOINT_NOT_SET);
|
||||||
return;
|
return;
|
||||||
@ -57,12 +83,11 @@ public class CmdCheckpoint extends FCommand {
|
|||||||
} else {
|
} else {
|
||||||
context.msg(TL.COMMAND_CHECKPOINT_CLAIMED);
|
context.msg(TL.COMMAND_CHECKPOINT_CLAIMED);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public TL getUsageTranslation() {
|
public TL getUsageTranslation()
|
||||||
return TL.COMMAND_CHECKPOINT_DESCRIPTION;
|
{
|
||||||
}
|
return TL.COMMAND_CHECKPOINT_DESCRIPTION;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
@ -26,6 +26,7 @@ import com.massivecraft.factions.discord.CmdInviteBot;
|
|||||||
import com.massivecraft.factions.discord.CmdSetGuild;
|
import com.massivecraft.factions.discord.CmdSetGuild;
|
||||||
import com.massivecraft.factions.missions.CmdMissions;
|
import com.massivecraft.factions.missions.CmdMissions;
|
||||||
import com.massivecraft.factions.shop.CmdShop;
|
import com.massivecraft.factions.shop.CmdShop;
|
||||||
|
import com.massivecraft.factions.shop.ShopGUIFrame;
|
||||||
import com.massivecraft.factions.zcore.util.TL;
|
import com.massivecraft.factions.zcore.util.TL;
|
||||||
import me.lucko.commodore.CommodoreProvider;
|
import me.lucko.commodore.CommodoreProvider;
|
||||||
import org.bukkit.Bukkit;
|
import org.bukkit.Bukkit;
|
||||||
@ -377,6 +378,7 @@ public class FCmdRoot extends FCommand implements CommandExecutor {
|
|||||||
}
|
}
|
||||||
if (FactionsPlugin.getInstance().getConfig().getBoolean("F-Shop.Enabled", false) && !fShopEnabled) {
|
if (FactionsPlugin.getInstance().getConfig().getBoolean("F-Shop.Enabled", false) && !fShopEnabled) {
|
||||||
this.addSubCommand(this.cmdShop);
|
this.addSubCommand(this.cmdShop);
|
||||||
|
new ShopGUIFrame(null).checkShopConfig();
|
||||||
fShopEnabled = true;
|
fShopEnabled = true;
|
||||||
}
|
}
|
||||||
if (FactionsPlugin.getInstance().getConfig().getBoolean("f-inventory-see.Enabled", false) && !invSeeEnabled) {
|
if (FactionsPlugin.getInstance().getConfig().getBoolean("f-inventory-see.Enabled", false) && !invSeeEnabled) {
|
||||||
|
File diff suppressed because it is too large
Load Diff
@ -1,121 +1,151 @@
|
|||||||
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 {
|
public class TempAreaMarker
|
||||||
|
{
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @author FactionsUUID Team
|
* @author FactionsUUID Team
|
||||||
*/
|
*/
|
||||||
|
|
||||||
// -------------------------------------------- //
|
// -------------------------------------------- //
|
||||||
// FIELDS
|
// FIELDS
|
||||||
// -------------------------------------------- //
|
// -------------------------------------------- //
|
||||||
|
|
||||||
public String label;
|
public String label;
|
||||||
public String world;
|
public String world;
|
||||||
public double[] x;
|
public double[] x;
|
||||||
public double[] z;
|
public double[] z;
|
||||||
public String description;
|
|
||||||
|
|
||||||
public int lineColor;
|
private List<List<Point>> polyLine = new ArrayList<List<Point>>();
|
||||||
public double lineOpacity;
|
|
||||||
public int lineWeight;
|
|
||||||
|
|
||||||
public int fillColor;
|
public String description;
|
||||||
public double fillOpacity;
|
|
||||||
|
|
||||||
public boolean boost;
|
public int lineColor;
|
||||||
|
public double lineOpacity;
|
||||||
|
public int lineWeight;
|
||||||
|
|
||||||
// -------------------------------------------- //
|
public int fillColor;
|
||||||
// CREATE
|
public double fillOpacity;
|
||||||
// -------------------------------------------- //
|
|
||||||
|
|
||||||
public static boolean equals(AreaMarker marker, double[] x, double[] z) {
|
public boolean boost;
|
||||||
int length = marker.getCornerCount();
|
|
||||||
|
|
||||||
if (x.length != length) {
|
// -------------------------------------------- //
|
||||||
return false;
|
// CREATE
|
||||||
}
|
// -------------------------------------------- //
|
||||||
if (z.length != length) {
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
|
|
||||||
for (int i = 0; i < length; i++) {
|
public static boolean equals(AreaMarker marker, double[] x, double[] z)
|
||||||
if (marker.getCornerX(i) != x[i]) {
|
{
|
||||||
return false;
|
int length = marker.getCornerCount();
|
||||||
}
|
|
||||||
if (marker.getCornerZ(i) != z[i]) {
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
return true;
|
if (x.length != length)
|
||||||
}
|
{
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
if (z.length != length)
|
||||||
|
{
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
// -------------------------------------------- //
|
for (int i = 0; i < length; i++)
|
||||||
// UPDATE
|
{
|
||||||
// -------------------------------------------- //
|
if (marker.getCornerX(i) != x[i])
|
||||||
|
{
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
if (marker.getCornerZ(i) != z[i])
|
||||||
|
{
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
public AreaMarker create(MarkerSet markerset, String markerId) {
|
return true;
|
||||||
AreaMarker ret = markerset.createAreaMarker(markerId, this.label, false, this.world, this.x, this.z, false // not persistent
|
}
|
||||||
);
|
|
||||||
|
|
||||||
if (ret == null) {
|
public void setPolyLine(List<List<Point>> points)
|
||||||
return null;
|
{
|
||||||
}
|
polyLine.clear();
|
||||||
|
polyLine.addAll(points);
|
||||||
|
}
|
||||||
|
|
||||||
// Description
|
public List<List<Point>> getPolyLine()
|
||||||
ret.setDescription(this.description);
|
{
|
||||||
|
return polyLine;
|
||||||
|
}
|
||||||
|
|
||||||
// Line Style
|
// -------------------------------------------- //
|
||||||
ret.setLineStyle(this.lineWeight, this.lineOpacity, this.lineColor);
|
// UPDATE
|
||||||
|
// -------------------------------------------- //
|
||||||
|
|
||||||
// Fill Style
|
public AreaMarker create(MarkerSet markerset, String markerId)
|
||||||
ret.setFillStyle(this.fillOpacity, this.fillColor);
|
{
|
||||||
|
AreaMarker ret = markerset.createAreaMarker(markerId, this.label, false, this.world, this.x, this.z, false // not persistent
|
||||||
|
);
|
||||||
|
if (ret == null)
|
||||||
|
{
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
|
||||||
// Boost Flag
|
int counter = 0;
|
||||||
ret.setBoostFlag(this.boost);
|
|
||||||
|
|
||||||
return ret;
|
// Description
|
||||||
}
|
ret.setDescription(this.description);
|
||||||
|
|
||||||
// -------------------------------------------- //
|
// Line Style
|
||||||
// UTIL
|
ret.setLineStyle(0, 0, 0);
|
||||||
// -------------------------------------------- //
|
|
||||||
|
|
||||||
public void update(AreaMarker marker) {
|
// Fill Style
|
||||||
// Corner Locations
|
ret.setFillStyle(this.fillOpacity, this.fillColor);
|
||||||
if (!equals(marker, this.x, this.z)) {
|
|
||||||
marker.setCornerLocations(this.x, this.z);
|
|
||||||
}
|
|
||||||
|
|
||||||
// Label
|
// Boost Flag
|
||||||
if (!marker.getLabel().equals(this.label)) {
|
ret.setBoostFlag(this.boost);
|
||||||
marker.setLabel(this.label);
|
|
||||||
}
|
|
||||||
|
|
||||||
// Description
|
return ret;
|
||||||
if (!marker.getDescription().equals(this.description)) {
|
}
|
||||||
marker.setDescription(this.description);
|
// -------------------------------------------- //
|
||||||
}
|
// UTIL
|
||||||
|
// -------------------------------------------- //
|
||||||
|
|
||||||
// Line Style
|
public void update(AreaMarker marker)
|
||||||
if (marker.getLineWeight() != this.lineWeight ||
|
{
|
||||||
marker.getLineOpacity() != this.lineOpacity ||
|
// Corner Locations
|
||||||
marker.getLineColor() != this.lineColor) {
|
if (!equals(marker, this.x, this.z))
|
||||||
marker.setLineStyle(this.lineWeight, this.lineOpacity, this.lineColor);
|
{
|
||||||
}
|
marker.setCornerLocations(this.x, this.z);
|
||||||
|
}
|
||||||
|
|
||||||
// Fill Style
|
// Label
|
||||||
if ((marker.getFillOpacity() != this.fillOpacity) || (marker.getFillColor() != this.fillColor)) {
|
if (!marker.getLabel().equals(this.label))
|
||||||
marker.setFillStyle(this.fillOpacity, this.fillColor);
|
{
|
||||||
}
|
marker.setLabel(this.label);
|
||||||
// Boost Flag
|
}
|
||||||
if (marker.getBoostFlag() != this.boost) {
|
if (!marker.getDescription().equals(this.description))
|
||||||
marker.setBoostFlag(this.boost);
|
{
|
||||||
}
|
marker.setDescription(this.description);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// // Line Style
|
||||||
|
// if (marker.getLineWeight() != this.lineWeight || marker.getLineOpacity() != this.lineOpacity || marker.getLineColor() != this.lineColor)
|
||||||
|
// {
|
||||||
|
// marker.setLineStyle(this.lineWeight, this.lineOpacity, this.lineColor);
|
||||||
|
// }
|
||||||
|
|
||||||
|
// Fill Style
|
||||||
|
if ((marker.getFillOpacity() != this.fillOpacity) || (marker.getFillColor() != this.fillColor))
|
||||||
|
{
|
||||||
|
marker.setFillStyle(this.fillOpacity, this.fillColor);
|
||||||
|
}
|
||||||
|
// Boost Flag
|
||||||
|
if (marker.getBoostFlag() != this.boost)
|
||||||
|
{
|
||||||
|
marker.setBoostFlag(this.boost);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
@ -0,0 +1,62 @@
|
|||||||
|
package com.massivecraft.factions.integration.dynmap;
|
||||||
|
|
||||||
|
import java.awt.Point;
|
||||||
|
import java.util.ArrayList;
|
||||||
|
import java.util.List;
|
||||||
|
|
||||||
|
public class TempLine
|
||||||
|
{
|
||||||
|
private Point p1;
|
||||||
|
private Point p2;
|
||||||
|
private List<TempLine> connectedLines = new ArrayList<TempLine>();
|
||||||
|
|
||||||
|
TempLine(Point p1, Point p2)
|
||||||
|
{
|
||||||
|
this.p1 = p1;
|
||||||
|
this.p2 = p2;
|
||||||
|
}
|
||||||
|
|
||||||
|
public Point getP1()
|
||||||
|
{
|
||||||
|
return p1;
|
||||||
|
}
|
||||||
|
|
||||||
|
public Point getP2()
|
||||||
|
{
|
||||||
|
return p2;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void addAdditionLines(List<TempLine> connectedLines)
|
||||||
|
{
|
||||||
|
this.connectedLines = connectedLines;
|
||||||
|
}
|
||||||
|
|
||||||
|
public List<TempLine> getConnectedLines()
|
||||||
|
{
|
||||||
|
return connectedLines;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public boolean equals(Object o)
|
||||||
|
{
|
||||||
|
TempLine line = (TempLine) o;
|
||||||
|
if (line.p1.x == this.p1.x && line.p2.x == this.p2.x && line.p1.y == this.p1.y && line.p2.y == this.p2.y)
|
||||||
|
{
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
if (line.p1.x == this.p2.x && line.p2.x == this.p1.x && line.p1.y == this.p2.y && line.p2.y == this.p1.y)
|
||||||
|
{
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public int hashCode()
|
||||||
|
{
|
||||||
|
String test = "" + (p1.x + p2.x);
|
||||||
|
test += " " + (p1.y + p2.y);
|
||||||
|
return test.hashCode();
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
@ -0,0 +1,111 @@
|
|||||||
|
package com.massivecraft.factions.integration.dynmap;
|
||||||
|
|
||||||
|
import java.awt.Point;
|
||||||
|
import java.util.ArrayList;
|
||||||
|
import java.util.List;
|
||||||
|
import org.dynmap.markers.MarkerSet;
|
||||||
|
import org.dynmap.markers.PolyLineMarker;
|
||||||
|
|
||||||
|
public class TempPolyLineMarker
|
||||||
|
{
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @author FactionsUUID Team
|
||||||
|
*/
|
||||||
|
|
||||||
|
// -------------------------------------------- //
|
||||||
|
// FIELDS
|
||||||
|
// -------------------------------------------- //
|
||||||
|
|
||||||
|
public String world;
|
||||||
|
|
||||||
|
public List<Point> polyLine = new ArrayList<Point>();
|
||||||
|
|
||||||
|
public int lineColor;
|
||||||
|
public double lineOpacity;
|
||||||
|
public int lineWeight;
|
||||||
|
|
||||||
|
// -------------------------------------------- //
|
||||||
|
// CREATE
|
||||||
|
// -------------------------------------------- //
|
||||||
|
|
||||||
|
public static boolean equals(PolyLineMarker marker, List<Point> points)
|
||||||
|
{
|
||||||
|
int length = marker.getCornerCount();
|
||||||
|
|
||||||
|
if (points.size() != length)
|
||||||
|
{
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
for (int i = 0; i < length; i++)
|
||||||
|
{
|
||||||
|
if (marker.getCornerX(i) != points.get(i).x)
|
||||||
|
{
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
if (marker.getCornerZ(i) != points.get(i).y)
|
||||||
|
{
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
// -------------------------------------------- //
|
||||||
|
// UPDATE
|
||||||
|
// -------------------------------------------- //
|
||||||
|
|
||||||
|
public PolyLineMarker create(MarkerSet markerset, String markerId)
|
||||||
|
{
|
||||||
|
double[] polyX = new double[polyLine.size()];
|
||||||
|
double[] polyY = new double[polyLine.size()];
|
||||||
|
double[] polyZ = new double[polyLine.size()];
|
||||||
|
for (int i = 0; i < polyLine.size(); i++)
|
||||||
|
{
|
||||||
|
Point p = polyLine.get(i);
|
||||||
|
polyX[i] = p.getX();
|
||||||
|
polyY[i] = 64;
|
||||||
|
polyZ[i] = p.getY();
|
||||||
|
}
|
||||||
|
PolyLineMarker poly = markerset.createPolyLineMarker(markerId, "", false, this.world, polyX, polyY, polyZ, false);
|
||||||
|
// Poly Line Style
|
||||||
|
if (poly != null)
|
||||||
|
{
|
||||||
|
poly.setLineStyle(this.lineWeight, this.lineOpacity, this.lineColor);
|
||||||
|
}
|
||||||
|
return poly;
|
||||||
|
}
|
||||||
|
|
||||||
|
// -------------------------------------------- //
|
||||||
|
// UTIL
|
||||||
|
// -------------------------------------------- //
|
||||||
|
|
||||||
|
public void update(PolyLineMarker marker)
|
||||||
|
{
|
||||||
|
// Corner Locations
|
||||||
|
if (!equals(marker, polyLine))
|
||||||
|
{
|
||||||
|
double[] polyX = new double[polyLine.size()];
|
||||||
|
double[] polyY = new double[polyLine.size()];
|
||||||
|
double[] polyZ = new double[polyLine.size()];
|
||||||
|
for (int i = 0; i < polyLine.size(); i++)
|
||||||
|
{
|
||||||
|
Point p = polyLine.get(i);
|
||||||
|
polyX[i] = p.getX();
|
||||||
|
polyY[i] = 64;
|
||||||
|
polyZ[i] = p.getY();
|
||||||
|
}
|
||||||
|
marker.setCornerLocations(polyX, polyY, polyZ);
|
||||||
|
marker.setLineStyle(this.lineWeight, this.lineOpacity, this.lineColor);
|
||||||
|
}
|
||||||
|
|
||||||
|
// Line Style
|
||||||
|
if (marker.getLineWeight() != this.lineWeight || marker.getLineOpacity() != this.lineOpacity || marker.getLineColor() != this.lineColor)
|
||||||
|
{
|
||||||
|
marker.setLineStyle(this.lineWeight, this.lineOpacity, this.lineColor);
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
File diff suppressed because it is too large
Load Diff
@ -5,6 +5,7 @@ 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.util.timer.type.GraceTimer;
|
||||||
|
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;
|
||||||
import org.bukkit.Location;
|
import org.bukkit.Location;
|
||||||
@ -138,7 +139,7 @@ public class FactionsEntityListener implements Listener {
|
|||||||
// Run the check for a player
|
// Run the check for a player
|
||||||
if (damager instanceof Player) {
|
if (damager instanceof Player) {
|
||||||
|
|
||||||
if (!FactionsBlockListener.playerCanBuildDestroyBlock((Player) damager, damagee.getLocation(), "destroy", false))
|
if (!FactionsBlockListener.playerCanBuildDestroyBlock((Player) damager, damagee.getLocation(), PermissableAction.DESTROY, false))
|
||||||
event.setCancelled(true);
|
event.setCancelled(true);
|
||||||
|
|
||||||
} else {
|
} else {
|
||||||
@ -508,7 +509,7 @@ public class FactionsEntityListener implements Listener {
|
|||||||
Player p = (Player) e.getRemover();
|
Player p = (Player) e.getRemover();
|
||||||
|
|
||||||
if (e.getEntity().getType() == EntityType.PAINTING || e.getEntity().getType() == EntityType.ITEM_FRAME) {
|
if (e.getEntity().getType() == EntityType.PAINTING || e.getEntity().getType() == EntityType.ITEM_FRAME) {
|
||||||
if (!FactionsBlockListener.playerCanBuildDestroyBlock(p, e.getEntity().getLocation(), "destroy", false)) {
|
if (!FactionsBlockListener.playerCanBuildDestroyBlock(p, e.getEntity().getLocation(), PermissableAction.DESTROY, false)) {
|
||||||
e.setCancelled(true);
|
e.setCancelled(true);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -519,7 +520,7 @@ public class FactionsEntityListener implements Listener {
|
|||||||
if (e.getPlayer() == null) return;
|
if (e.getPlayer() == null) return;
|
||||||
|
|
||||||
if (e.getEntity().getType() == EntityType.PAINTING || e.getEntity().getType() == EntityType.ITEM_FRAME) {
|
if (e.getEntity().getType() == EntityType.PAINTING || e.getEntity().getType() == EntityType.ITEM_FRAME) {
|
||||||
if (!FactionsBlockListener.playerCanBuildDestroyBlock(e.getPlayer(), e.getBlock().getLocation(), "build", false)) {
|
if (!FactionsBlockListener.playerCanBuildDestroyBlock(e.getPlayer(), e.getBlock().getLocation(), PermissableAction.BUILD, false)) {
|
||||||
e.setCancelled(true);
|
e.setCancelled(true);
|
||||||
e.getPlayer().updateInventory();
|
e.getPlayer().updateInventory();
|
||||||
}
|
}
|
||||||
@ -626,7 +627,7 @@ public class FactionsEntityListener implements Listener {
|
|||||||
if (event.getRightClicked() == null) return;
|
if (event.getRightClicked() == null) return;
|
||||||
if (!event.getRightClicked().getType().equals(EntityType.ITEM_FRAME)) return;
|
if (!event.getRightClicked().getType().equals(EntityType.ITEM_FRAME)) return;
|
||||||
|
|
||||||
if (!FactionsBlockListener.playerCanBuildDestroyBlock(event.getPlayer(), event.getRightClicked().getLocation(), "build", false)) {
|
if (!FactionsBlockListener.playerCanBuildDestroyBlock(event.getPlayer(), event.getRightClicked().getLocation(), PermissableAction.BUILD, false)) {
|
||||||
event.setCancelled(true);
|
event.setCancelled(true);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -741,7 +741,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) 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)) {
|
||||||
me.setIsAutoSafeClaimEnabled(false);
|
me.setIsAutoSafeClaimEnabled(false);
|
||||||
@ -863,7 +864,7 @@ public class FactionsPlayerListener implements Listener {
|
|||||||
Block block = event.getClickedBlock();
|
Block block = event.getClickedBlock();
|
||||||
if (event.getAction() == Action.RIGHT_CLICK_BLOCK && block.getType() == XMaterial.GRASS_BLOCK.parseMaterial()
|
if (event.getAction() == Action.RIGHT_CLICK_BLOCK && block.getType() == XMaterial.GRASS_BLOCK.parseMaterial()
|
||||||
&& event.hasItem() && event.getItem().getType() == XMaterial.BONE_MEAL.parseMaterial()) {
|
&& event.hasItem() && event.getItem().getType() == XMaterial.BONE_MEAL.parseMaterial()) {
|
||||||
if (!FactionsBlockListener.playerCanBuildDestroyBlock(event.getPlayer(), block.getLocation(), PermissableAction.BUILD.name(), true)) {
|
if (!FactionsBlockListener.playerCanBuildDestroyBlock(event.getPlayer(), block.getLocation(), PermissableAction.BUILD, true)) {
|
||||||
FPlayer me = FPlayers.getInstance().getById(event.getPlayer().getUniqueId().toString());
|
FPlayer me = FPlayers.getInstance().getById(event.getPlayer().getUniqueId().toString());
|
||||||
Faction myFaction = me.getFaction();
|
Faction myFaction = me.getFaction();
|
||||||
|
|
||||||
|
@ -11,6 +11,7 @@ import com.massivecraft.factions.util.XMaterial;
|
|||||||
import com.massivecraft.factions.zcore.util.TL;
|
import com.massivecraft.factions.zcore.util.TL;
|
||||||
import org.bukkit.Bukkit;
|
import org.bukkit.Bukkit;
|
||||||
import org.bukkit.ChatColor;
|
import org.bukkit.ChatColor;
|
||||||
|
import org.bukkit.Material;
|
||||||
import org.bukkit.configuration.ConfigurationSection;
|
import org.bukkit.configuration.ConfigurationSection;
|
||||||
import org.bukkit.enchantments.Enchantment;
|
import org.bukkit.enchantments.Enchantment;
|
||||||
import org.bukkit.entity.Player;
|
import org.bukkit.entity.Player;
|
||||||
@ -20,92 +21,210 @@ 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.Map;
|
||||||
|
import java.util.Set;
|
||||||
|
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
|
||||||
*/
|
*/
|
||||||
|
|
||||||
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),
|
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")));
|
||||||
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());
|
{
|
||||||
List<GuiItem> GUIItems = new ArrayList<>();
|
PaginatedPane pane = new PaginatedPane(0, 0, 9, gui.getRows());
|
||||||
ItemStack dummy = buildDummyItem(fplayer.getFaction());
|
List<GuiItem> GUIItems = new ArrayList<>();
|
||||||
for (int x = 0; x <= (gui.getRows() * 9) - 1; x++) GUIItems.add(new GuiItem(dummy, e -> e.setCancelled(true)));
|
ItemStack dummy = buildDummyItem(fplayer.getFaction());
|
||||||
|
for (int x = 0; x <= (gui.getRows() * 9) - 1; x++)
|
||||||
|
GUIItems.add(new GuiItem(dummy, e -> e.setCancelled(true)));
|
||||||
|
|
||||||
int items = FactionsPlugin.getInstance().getFileManager().getShop().getConfig().getConfigurationSection("items").getKeys(false).size();
|
Set<String> items = FactionsPlugin.getInstance().getFileManager().getShop().getConfig().getConfigurationSection("items").getKeys(false);
|
||||||
for (int a = 1; a <= items; a++) {
|
for (String s : items)
|
||||||
String s = a + "";
|
{
|
||||||
int slot = FactionsPlugin.getInstance().getFileManager().getShop().fetchInt("items." + s + ".slot");
|
if (!checkShopConfig(s))
|
||||||
ItemStack item = XMaterial.matchXMaterial(FactionsPlugin.getInstance().getFileManager().getShop().fetchString("items." + s + ".block")).get().parseItem();
|
{
|
||||||
int cost = FactionsPlugin.getInstance().getFileManager().getShop().fetchInt("items." + s + ".cost");
|
continue;
|
||||||
String name = FactionsPlugin.getInstance().getFileManager().getShop().fetchString("items." + s + ".name");
|
}
|
||||||
boolean glowing = FactionsPlugin.getInstance().getFileManager().getShop().fetchBoolean("items." + s + ".glowing");
|
|
||||||
List<String> lore = FactionsPlugin.getInstance().getFileManager().getShop().fetchStringList("items." + s + ".lore");
|
|
||||||
|
|
||||||
|
int slot = FactionsPlugin.getInstance().getFileManager().getShop().fetchInt("items." + s + ".slot");
|
||||||
|
ItemStack item = XMaterial.matchXMaterial(FactionsPlugin.getInstance().getFileManager().getShop().fetchString("items." + s + ".block")).get().parseItem();
|
||||||
|
int cost = FactionsPlugin.getInstance().getFileManager().getShop().fetchInt("items." + s + ".cost");
|
||||||
|
String name = FactionsPlugin.getInstance().getFileManager().getShop().fetchString("items." + s + ".name");
|
||||||
|
boolean glowing = FactionsPlugin.getInstance().getFileManager().getShop().fetchBoolean("items." + s + ".glowing");
|
||||||
|
List<String> lore = FactionsPlugin.getInstance().getFileManager().getShop().fetchStringList("items." + s + ".lore");
|
||||||
|
|
||||||
assert item != null;
|
assert item != null;
|
||||||
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.addEnchant(Enchantment.DURABILITY, 1, true);
|
meta.addItemFlags(ItemFlag.HIDE_ENCHANTS);
|
||||||
}
|
meta.addEnchant(Enchantment.DURABILITY, 1, true);
|
||||||
if (!glowing) meta.removeEnchant(Enchantment.DURABILITY);
|
}
|
||||||
List<String> replacedLore = lore.stream().map(t -> t.replace("{cost}", cost + "")).collect(Collectors.toList());
|
if (!glowing)
|
||||||
meta.setLore(FactionsPlugin.instance.colorList(replacedLore));
|
meta.removeEnchant(Enchantment.DURABILITY);
|
||||||
item.setItemMeta(meta);
|
List<String> replacedLore = lore.stream().map(t -> t.replace("{cost}", cost + "")).collect(Collectors.toList());
|
||||||
GUIItems.set(slot, new GuiItem(item, e -> {
|
meta.setLore(FactionsPlugin.instance.colorList(replacedLore));
|
||||||
e.setCancelled(true);
|
item.setItemMeta(meta);
|
||||||
FPlayer fme = FPlayers.getInstance().getByPlayer((Player) e.getWhoClicked());
|
GUIItems.set(slot, new GuiItem(item, e ->
|
||||||
if (fplayer.getFaction().getPoints() >= cost) {
|
{
|
||||||
fplayer.getFaction().setPoints(fplayer.getFaction().getPoints() - cost);
|
e.setCancelled(true);
|
||||||
runCommands(FactionsPlugin.getInstance().getFileManager().getShop().fetchStringList("items." + s + ".cmds"), fplayer.getPlayer());
|
FPlayer fme = FPlayers.getInstance().getByPlayer((Player) e.getWhoClicked());
|
||||||
for (FPlayer fplayerBuy : fplayer.getFaction().getFPlayers()) {
|
if (fplayer.getFaction().getPoints() >= cost)
|
||||||
fplayerBuy.getPlayer().sendMessage(TL.SHOP_BOUGHT_BROADCAST_FACTION.toString()
|
{
|
||||||
.replace("{player}", fplayer.getPlayer().getName())
|
if (runCommands(FactionsPlugin.getInstance().getFileManager().getShop().fetchStringList("items." + s + ".cmds"), fplayer.getPlayer()))
|
||||||
.replace("{item}", ChatColor.stripColor(FactionsPlugin.getInstance().color(name)))
|
{
|
||||||
.replace("{cost}", cost + ""));
|
fplayer.getFaction().setPoints(fplayer.getFaction().getPoints() - cost);
|
||||||
}
|
for (FPlayer fplayerBuy : fplayer.getFaction().getFPlayers())
|
||||||
buildGUI(fme);
|
{
|
||||||
} else {
|
fplayerBuy.getPlayer().sendMessage(TL.SHOP_BOUGHT_BROADCAST_FACTION.toString().replace("{player}", fplayer.getPlayer().getName()).replace("{item}", ChatColor.stripColor(FactionsPlugin.getInstance().color(name)))
|
||||||
fplayer.msg(TL.SHOP_NOT_ENOUGH_POINTS);
|
.replace("{cost}", cost + ""));
|
||||||
}
|
}
|
||||||
}));
|
buildGUI(fme);
|
||||||
pane.populateWithGuiItems(GUIItems);
|
}
|
||||||
gui.addPane(pane);
|
else
|
||||||
gui.update();
|
{
|
||||||
gui.show(fplayer.getPlayer());
|
fplayer.msg(TL.SHOP_ERROR_DURING_PURCHASE);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
fplayer.msg(TL.SHOP_NOT_ENOUGH_POINTS);
|
||||||
|
}
|
||||||
|
}));
|
||||||
|
pane.populateWithGuiItems(GUIItems);
|
||||||
|
gui.addPane(pane);
|
||||||
|
gui.update();
|
||||||
|
gui.show(fplayer.getPlayer());
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
private ItemStack buildDummyItem(Faction f)
|
||||||
|
{
|
||||||
|
ConfigurationSection config = FactionsPlugin.getInstance().getConfig().getConfigurationSection("F-Shop.GUI.dummy-item");
|
||||||
|
ItemStack item = XMaterial.matchXMaterial(config.getString("Type")).get().parseItem();
|
||||||
|
ItemMeta meta = item.getItemMeta();
|
||||||
|
if (meta != null)
|
||||||
|
{
|
||||||
|
meta.setLore(FactionsPlugin.getInstance().colorList(config.getStringList("Lore")));
|
||||||
|
meta.setDisplayName(FactionsPlugin.getInstance().color(config.getString("Name").replace("{points}", f.getPoints() + "")));
|
||||||
|
item.setItemMeta(meta);
|
||||||
|
}
|
||||||
|
return item;
|
||||||
|
}
|
||||||
|
|
||||||
private ItemStack buildDummyItem(Faction f) {
|
public boolean checkShopConfig()
|
||||||
ConfigurationSection config = FactionsPlugin.getInstance().getConfig().getConfigurationSection("F-Shop.GUI.dummy-item");
|
{
|
||||||
ItemStack item = XMaterial.matchXMaterial(config.getString("Type")).get().parseItem();
|
boolean ret = true;
|
||||||
ItemMeta meta = item.getItemMeta();
|
Set<String> items = FactionsPlugin.getInstance().getFileManager().getShop().getConfig().getConfigurationSection("items").getKeys(false);
|
||||||
if (meta != null) {
|
for (String s : items)
|
||||||
meta.setLore(FactionsPlugin.getInstance().colorList(config.getStringList("Lore")));
|
{
|
||||||
meta.setDisplayName(FactionsPlugin.getInstance().color(config.getString("Name").replace("{points}", f.getPoints() + "")));
|
if (checkShopConfig(s) == false)
|
||||||
item.setItemMeta(meta);
|
{
|
||||||
}
|
ret = false;
|
||||||
return item;
|
}
|
||||||
}
|
}
|
||||||
|
return ret;
|
||||||
|
}
|
||||||
|
|
||||||
public void runCommands(List<String> list, Player p) {
|
public boolean checkShopConfig(String s)
|
||||||
for (String cmd : list) {
|
{
|
||||||
cmd = cmd.replace("%player%", p.getName());
|
boolean ret = true;
|
||||||
Bukkit.dispatchCommand(Bukkit.getConsoleSender(), cmd);
|
if (!FactionsPlugin.getInstance().getFileManager().getShop().containsKey("items." + s + ".slot"))
|
||||||
}
|
{
|
||||||
}
|
FactionsPlugin.getInstance().log(Level.WARNING, "Problem with config item \'" + s + "\' missing slot variable");
|
||||||
|
ret = false;
|
||||||
|
}
|
||||||
|
if (!FactionsPlugin.getInstance().getFileManager().getShop().containsKey("items." + s + ".block"))
|
||||||
|
{
|
||||||
|
FactionsPlugin.getInstance().log(Level.WARNING, "Problem with config item \'" + s + "\' missing block variable");
|
||||||
|
ret = false;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (!FactionsPlugin.getInstance().getFileManager().getShop().containsKey("items." + s + ".cmds"))
|
||||||
|
{
|
||||||
|
FactionsPlugin.getInstance().log(Level.WARNING, "Problee with config item \'" + s + "\' missing cmds variable");
|
||||||
|
ret = false;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (!FactionsPlugin.getInstance().getFileManager().getShop().containsKey("items." + s + ".cost"))
|
||||||
|
{
|
||||||
|
FactionsPlugin.getInstance().log(Level.WARNING, "Problem with config item \'" + s + "\' missing cost variable this item will cost 0");
|
||||||
|
}
|
||||||
|
if (!FactionsPlugin.getInstance().getFileManager().getShop().containsKey("items." + s + ".name"))
|
||||||
|
{
|
||||||
|
FactionsPlugin.getInstance().log(Level.WARNING, "Problem with config item \'" + s + "\' missing name variable");
|
||||||
|
ret = false;
|
||||||
|
}
|
||||||
|
return ret;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
*
|
||||||
|
* @param list
|
||||||
|
* The list of commands to be ran.
|
||||||
|
* @param p
|
||||||
|
* The player that is using the shop
|
||||||
|
* @return if all commands are able to be ran or if they did run.
|
||||||
|
*/
|
||||||
|
public boolean runCommands(List<String> list, Player p)
|
||||||
|
{
|
||||||
|
for (String cmd : list)
|
||||||
|
{
|
||||||
|
cmd = cmd.replace("%player%", p.getName());
|
||||||
|
if (cmd.toLowerCase().startsWith("give"))
|
||||||
|
{
|
||||||
|
String[] args = cmd.split(" ");
|
||||||
|
if (args.length == 4)
|
||||||
|
{
|
||||||
|
Material material = Material.matchMaterial(args[2]);
|
||||||
|
int amount = Integer.parseInt(args[3]);
|
||||||
|
Player player = Bukkit.getPlayer(args[1]);
|
||||||
|
if (!player.isOnline())
|
||||||
|
{
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
// See if the player has this item in their inventory;
|
||||||
|
if (player.getInventory().contains(material) && player.getInventory().firstEmpty() < 0)
|
||||||
|
{
|
||||||
|
int spacesAvailable = 0;
|
||||||
|
Map<Integer, ? extends ItemStack> contents = player.getInventory().all(material);
|
||||||
|
for (ItemStack stack : contents.values())
|
||||||
|
{
|
||||||
|
spacesAvailable += stack.getMaxStackSize() - stack.getAmount();
|
||||||
|
}
|
||||||
|
if (spacesAvailable < amount)
|
||||||
|
{
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
if (player.getInventory().firstEmpty() < 0)
|
||||||
|
{
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
for (String cmd : list)
|
||||||
|
{
|
||||||
|
cmd = cmd.replace("%player%", p.getName());
|
||||||
|
Bukkit.dispatchCommand(Bukkit.getConsoleSender(), cmd);
|
||||||
|
}
|
||||||
|
return true;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
@ -55,6 +55,10 @@ public class CustomFile {
|
|||||||
e.printStackTrace();
|
e.printStackTrace();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public boolean containsKey(String key) {
|
||||||
|
return getCachedObjects().containsKey(key)|| getConfig().contains(key);
|
||||||
|
}
|
||||||
|
|
||||||
public String fetchString(String key) {
|
public String fetchString(String key) {
|
||||||
return (String) getObj(key, dataTypes.STRING);
|
return (String) getObj(key, dataTypes.STRING);
|
||||||
|
@ -972,36 +972,39 @@ public abstract class MemoryFPlayer implements FPlayer {
|
|||||||
}
|
}
|
||||||
|
|
||||||
public void setFFlying(boolean fly, boolean damage) {
|
public void setFFlying(boolean fly, boolean damage) {
|
||||||
Player player = getPlayer();
|
if(FactionsPlugin.getInstance().getConfig().getBoolean("enable-faction-flight"))
|
||||||
if (player == null) return;
|
{
|
||||||
|
Player player = getPlayer();
|
||||||
player.setAllowFlight(fly);
|
if (player == null) return;
|
||||||
player.setFlying(fly);
|
|
||||||
|
player.setAllowFlight(fly);
|
||||||
if (!damage) {
|
player.setFlying(fly);
|
||||||
msg(TL.COMMAND_FLY_CHANGE, fly ? "enabled" : "disabled");
|
|
||||||
if (!fly) {
|
if (!damage) {
|
||||||
sendMessage(TL.COMMAND_FLY_COOLDOWN.toString().replace("{amount}", FactionsPlugin.getInstance().getConfig().getInt("fly-falldamage-cooldown", 3) + ""));
|
msg(TL.COMMAND_FLY_CHANGE, fly ? "enabled" : "disabled");
|
||||||
}
|
if (!fly) {
|
||||||
} else {
|
sendMessage(TL.COMMAND_FLY_COOLDOWN.toString().replace("{amount}", FactionsPlugin.getInstance().getConfig().getInt("fly-falldamage-cooldown", 3) + ""));
|
||||||
msg(TL.COMMAND_FLY_DAMAGE);
|
}
|
||||||
}
|
} else {
|
||||||
|
msg(TL.COMMAND_FLY_DAMAGE);
|
||||||
// If leaving fly mode, don't let them take fall damage for x seconds.
|
}
|
||||||
if (!fly) {
|
|
||||||
int cooldown = FactionsPlugin.getInstance().getConfig().getInt("fly-falldamage-cooldown", 3);
|
// If leaving fly mode, don't let them take fall damage for x seconds.
|
||||||
CmdFly.flyMap.remove(player.getName());
|
if (!fly) {
|
||||||
|
int cooldown = FactionsPlugin.getInstance().getConfig().getInt("fly-falldamage-cooldown", 3);
|
||||||
// If the value is 0 or lower, make them take fall damage.
|
CmdFly.flyMap.remove(player.getName());
|
||||||
// Otherwise, start a timer and have this cancel after a few seconds.
|
|
||||||
// Short task so we're just doing it in method. Not clean but eh.
|
// If the value is 0 or lower, make them take fall damage.
|
||||||
if (cooldown > 0) {
|
// Otherwise, start a timer and have this cancel after a few seconds.
|
||||||
setTakeFallDamage(false);
|
// Short task so we're just doing it in method. Not clean but eh.
|
||||||
Bukkit.getScheduler().runTaskLater(FactionsPlugin.getInstance(), () -> setTakeFallDamage(true), 20L * cooldown);
|
if (cooldown > 0) {
|
||||||
}
|
setTakeFallDamage(false);
|
||||||
}
|
Bukkit.getScheduler().runTaskLater(FactionsPlugin.getInstance(), () -> setTakeFallDamage(true), 20L * cooldown);
|
||||||
|
}
|
||||||
isFlying = fly;
|
}
|
||||||
|
|
||||||
|
isFlying = fly;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public boolean isInFactionsChest() {
|
public boolean isInFactionsChest() {
|
||||||
|
@ -824,6 +824,7 @@ public enum TL {
|
|||||||
COMMAND_STRIKESINFO_DESCRIPTION("Get a faction's strikes"),
|
COMMAND_STRIKESINFO_DESCRIPTION("Get a faction's strikes"),
|
||||||
|
|
||||||
SHOP_NOT_ENOUGH_POINTS("&c&l[!] &7Your faction does not have enough points to purchase this!"),
|
SHOP_NOT_ENOUGH_POINTS("&c&l[!] &7Your faction does not have enough points to purchase this!"),
|
||||||
|
SHOP_ERROR_DURING_PURCHASE("&c&l[!] &7There was an error while trying to give items please check your inventory! Purchase was not completed!"),
|
||||||
SHOP_BOUGHT_BROADCAST_FACTION("\n&c&l[!] &e&lFactionShop » &b{player} &7bought &b{item}&7 for &b{cost} &7points!\n"),
|
SHOP_BOUGHT_BROADCAST_FACTION("\n&c&l[!] &e&lFactionShop » &b{player} &7bought &b{item}&7 for &b{cost} &7points!\n"),
|
||||||
|
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user