Compare commits
21 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
b7d991c0dd | ||
|
|
6372245fcd | ||
|
|
f2c0f725b7 | ||
|
|
0b677cb4de | ||
|
|
e8642a3108 | ||
|
|
a355b1d0c8 | ||
|
|
929c34d850 | ||
|
|
903129e462 | ||
|
|
e84c69f2b0 | ||
|
|
3e530487d7 | ||
|
|
14776b8877 | ||
|
|
24aaa0ed6f | ||
|
|
2a01682fbe | ||
|
|
ba59310548 | ||
|
|
bec09168b6 | ||
|
|
4fe6484db9 | ||
|
|
71a099beeb | ||
|
|
ddd3150732 | ||
|
|
ec1501bf4f | ||
|
|
8ad2fdf848 | ||
|
|
1ee62c2267 |
29
pom.xml
29
pom.xml
@@ -4,7 +4,7 @@
|
||||
|
||||
<groupId>com.massivecraft</groupId>
|
||||
<artifactId>Factions</artifactId>
|
||||
<version>1.6.9.5-2.3.7-RC</version>
|
||||
<version>1.6.9.5-2.3.8-RC</version>
|
||||
<packaging>jar</packaging>
|
||||
|
||||
<name>SaberFactions</name>
|
||||
@@ -41,6 +41,10 @@
|
||||
<configuration>
|
||||
<createDependencyReducedPom>false</createDependencyReducedPom>
|
||||
<relocations>
|
||||
<relocation>
|
||||
<pattern>com.github.cryptomorin</pattern>
|
||||
<shadedPattern>com.massivecraft.factions.shade.github.cryptomorin</shadedPattern>
|
||||
</relocation>
|
||||
<relocation>
|
||||
<pattern>com.github.stefvanschie.inventoryframework</pattern>
|
||||
<shadedPattern>com.massivecraft.factions.shade.stefvanschie.inventoryframework</shadedPattern>
|
||||
@@ -108,7 +112,8 @@
|
||||
<dependency>
|
||||
<groupId>com.github.stefvanschie.inventoryframework</groupId>
|
||||
<artifactId>IF</artifactId>
|
||||
<version>0.5.19</version>
|
||||
<version>0.5.8</version>
|
||||
<scope>compile</scope>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>org.spigotmc</groupId>
|
||||
@@ -138,6 +143,18 @@
|
||||
</exclusion>
|
||||
</exclusions>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>com.github.cryptomorin</groupId>
|
||||
<artifactId>XSeries</artifactId>
|
||||
<version>5.3.1</version>
|
||||
<scope>compile</scope>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>joda-time</groupId>
|
||||
<artifactId>joda-time</artifactId>
|
||||
<version>2.10.6</version>
|
||||
<scope>compile</scope>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>org.ocpsoft.prettytime</groupId>
|
||||
<artifactId>prettytime</artifactId>
|
||||
@@ -437,10 +454,10 @@
|
||||
<id>net.coreprotect</id>
|
||||
<url>http://maven.playpro.com/</url>
|
||||
</repository>
|
||||
<repository>
|
||||
<id>codemc-repo</id>
|
||||
<url>https://repo.codemc.org/repository/maven-public/</url>
|
||||
</repository>
|
||||
<repository>
|
||||
<id>codemc-repo</id>
|
||||
<url>https://repo.codemc.org/repository/maven-public/</url>
|
||||
</repository>
|
||||
<repository>
|
||||
<id>ess-repo</id>
|
||||
<url>http://ci.ender.zone/plugin/repository/everything/</url>
|
||||
|
||||
@@ -1,8 +1,8 @@
|
||||
package com.massivecraft.factions;
|
||||
|
||||
import com.cryptomorin.xseries.XMaterial;
|
||||
import com.google.common.collect.ImmutableMap;
|
||||
import com.massivecraft.factions.integration.dynmap.DynmapStyle;
|
||||
import com.massivecraft.factions.util.XMaterial;
|
||||
import com.massivecraft.factions.zcore.fperms.DefaultPermissions;
|
||||
import com.massivecraft.factions.zcore.fperms.PermissableAction;
|
||||
import org.bukkit.ChatColor;
|
||||
@@ -103,6 +103,11 @@ public class Conf {
|
||||
public static boolean worldGuardChecking = false;
|
||||
public static boolean worldGuardBuildPriority = false;
|
||||
|
||||
//SHIELDS
|
||||
public static boolean useFShieldSystem = true;
|
||||
public static int shieldTimeHours = 12;
|
||||
public static int shieldFrameChangeCooldownHours = 24;
|
||||
|
||||
//RADIUS CLAIMING
|
||||
public static boolean useRadiusClaimSystem = true;
|
||||
|
||||
@@ -268,6 +273,7 @@ public class Conf {
|
||||
public static boolean ownedMessageInsideTerritory = true;
|
||||
public static boolean ownedMessageByChunk = false;
|
||||
public static boolean pistonProtectionThroughDenyBuild = true;
|
||||
public static Set<Material> loggableMaterials = EnumSet.noneOf(Material.class);
|
||||
public static Set<Material> territoryProtectedMaterials = EnumSet.noneOf(Material.class);
|
||||
public static Set<Material> territoryDenyUsageMaterials = EnumSet.noneOf(Material.class);
|
||||
public static Set<Material> territoryProtectedMaterialsWhenOffline = EnumSet.noneOf(Material.class);
|
||||
|
||||
@@ -1,5 +1,6 @@
|
||||
package com.massivecraft.factions;
|
||||
|
||||
import com.massivecraft.factions.cmd.shields.struct.frame.ShieldFramePersistence;
|
||||
import com.massivecraft.factions.event.FactionDisbandEvent.PlayerDisbandReason;
|
||||
import com.massivecraft.factions.iface.EconomyParticipator;
|
||||
import com.massivecraft.factions.iface.RelationParticipator;
|
||||
@@ -59,6 +60,24 @@ public interface Faction extends EconomyParticipator {
|
||||
|
||||
void setDiscord(String link);
|
||||
|
||||
boolean isProtected();
|
||||
|
||||
void setProtected();
|
||||
|
||||
void setUnprotected();
|
||||
|
||||
ShieldFramePersistence getShieldFrame();
|
||||
|
||||
void setupShieldChange(ShieldFramePersistence frame);
|
||||
|
||||
boolean pendingShieldChange();
|
||||
|
||||
long getShieldChangeTime();
|
||||
|
||||
ShieldFramePersistence getNewFrame();
|
||||
|
||||
void applyShield();
|
||||
|
||||
void checkPerms();
|
||||
|
||||
double getReinforcedArmor();
|
||||
|
||||
@@ -14,6 +14,9 @@ import com.massivecraft.factions.cmd.chest.AntiChestListener;
|
||||
import com.massivecraft.factions.cmd.reserve.ListParameterizedType;
|
||||
import com.massivecraft.factions.cmd.reserve.ReserveAdapter;
|
||||
import com.massivecraft.factions.cmd.reserve.ReserveObject;
|
||||
import com.massivecraft.factions.cmd.shields.struct.ShieldTCMP;
|
||||
import com.massivecraft.factions.cmd.shields.struct.frame.ShieldFrame;
|
||||
import com.massivecraft.factions.cmd.shields.struct.tasks.ShieldManagement;
|
||||
import com.massivecraft.factions.discord.Discord;
|
||||
import com.massivecraft.factions.discord.DiscordListener;
|
||||
import com.massivecraft.factions.integration.Econ;
|
||||
@@ -167,14 +170,12 @@ public class FactionsPlugin extends MPlugin {
|
||||
FactionsPlugin.instance.log("Minecraft Version 1.15 found.");
|
||||
mc115 = true;
|
||||
break;
|
||||
default:
|
||||
throw new IllegalStateException("Unexpected value: " + version);
|
||||
}
|
||||
migrateFPlayerLeaders();
|
||||
log("==== End Setup ====");
|
||||
|
||||
int pluginId = 7013;
|
||||
new Metrics(this, pluginId);
|
||||
Metrics metrics = new Metrics(this, pluginId);
|
||||
|
||||
if (!preEnable()) {
|
||||
this.loadSuccessful = false;
|
||||
@@ -182,6 +183,7 @@ public class FactionsPlugin extends MPlugin {
|
||||
}
|
||||
|
||||
saveDefaultConfig();
|
||||
reloadConfig();
|
||||
//Start wait task executor
|
||||
WaitExecutor.startTask();
|
||||
// Load Conf from disk
|
||||
@@ -194,6 +196,7 @@ public class FactionsPlugin extends MPlugin {
|
||||
|
||||
com.massivecraft.factions.integration.Essentials.setup();
|
||||
hookedPlayervaults = setupPlayervaults();
|
||||
new ShieldTCMP();
|
||||
FPlayers.getInstance().load();
|
||||
Factions.getInstance().load();
|
||||
|
||||
@@ -217,6 +220,7 @@ public class FactionsPlugin extends MPlugin {
|
||||
|
||||
Board.getInstance().load();
|
||||
Board.getInstance().clean();
|
||||
new ShieldManagement();
|
||||
//Load command aliases
|
||||
Aliases.load();
|
||||
// Add Base Commands
|
||||
@@ -396,12 +400,14 @@ public class FactionsPlugin extends MPlugin {
|
||||
return this.mvdwPlaceholderAPIManager;
|
||||
}
|
||||
|
||||
private void setupPermissions() {
|
||||
private boolean setupPermissions() {
|
||||
try {
|
||||
RegisteredServiceProvider<Permission> rsp = getServer().getServicesManager().getRegistration(Permission.class);
|
||||
if (rsp != null) perms = rsp.getProvider();
|
||||
} catch (NoClassDefFoundError ignored) {
|
||||
} catch (NoClassDefFoundError ex) {
|
||||
return false;
|
||||
}
|
||||
return perms != null;
|
||||
}
|
||||
|
||||
private boolean setupPlayervaults() {
|
||||
@@ -424,6 +430,7 @@ public class FactionsPlugin extends MPlugin {
|
||||
.registerTypeAdapter(Inventory.class, new InventoryTypeAdapter())
|
||||
.registerTypeAdapter(ReserveObject.class, new ReserveAdapter())
|
||||
.registerTypeAdapter(Location.class, new LocationTypeAdapter())
|
||||
.registerTypeAdapter(ShieldFrame.class, new ShieldFrameAdapter())
|
||||
.registerTypeAdapterFactory(EnumTypeAdapter.ENUM_FACTORY);
|
||||
}
|
||||
|
||||
@@ -481,7 +488,6 @@ public class FactionsPlugin extends MPlugin {
|
||||
Conf.save();
|
||||
}
|
||||
|
||||
|
||||
public Economy getEcon() {
|
||||
RegisteredServiceProvider<Economy> rsp = getServer().getServicesManager().getRegistration(Economy.class);
|
||||
return rsp.getProvider();
|
||||
|
||||
@@ -57,7 +57,7 @@ public class CmdAdmin extends FCommand {
|
||||
return;
|
||||
}
|
||||
|
||||
if(fyou.isAlt()){
|
||||
if (fyou.isAlt()) {
|
||||
return;
|
||||
}
|
||||
|
||||
@@ -90,7 +90,7 @@ public class CmdAdmin extends FCommand {
|
||||
FactionsPlugin.instance.getFlogManager().log(targetFaction, FLogType.RANK_EDIT, context.fPlayer.getName(), fyou.getName(), ChatColor.RED + "Admin");
|
||||
|
||||
// Inform all players
|
||||
if(FactionsPlugin.instance.getConfig().getBoolean("faction-leader-broadcast")) {
|
||||
if (FactionsPlugin.instance.getConfig().getBoolean("faction-leader-broadcast")) {
|
||||
for (FPlayer fplayer : FPlayers.getInstance().getOnlinePlayers()) {
|
||||
fplayer.msg(TL.COMMAND_ADMIN_PROMOTED, context.player == null ? TL.GENERIC_SERVERADMIN.toString() : context.fPlayer.describeTo(fplayer, true), fyou.describeTo(fplayer), targetFaction.describeTo(fplayer));
|
||||
}
|
||||
|
||||
@@ -50,7 +50,7 @@ public class CmdAnnounce extends FCommand {
|
||||
return TL.COMMAND_ANNOUNCE_DESCRIPTION;
|
||||
}
|
||||
|
||||
protected static class AnnounceBrigadier implements BrigadierProvider {
|
||||
protected class AnnounceBrigadier implements BrigadierProvider {
|
||||
@Override
|
||||
public ArgumentBuilder<Object, ?> get(ArgumentBuilder<Object, ?> parent) {
|
||||
return parent.then(RequiredArgumentBuilder.argument("message", StringArgumentType.greedyString()));
|
||||
|
||||
@@ -60,6 +60,7 @@ public class CmdBanner extends FCommand {
|
||||
@Deprecated
|
||||
public void takeMoney(FPlayer fme, int amt) {
|
||||
if (this.hasMoney(fme, amt)) {
|
||||
Economy econ = FactionsPlugin.getInstance().getEcon();
|
||||
fme.sendMessage(TL.COMMAND_BANNER_MONEYTAKE.toString().replace("{amount}", amt + ""));
|
||||
}
|
||||
}
|
||||
|
||||
@@ -14,6 +14,7 @@ public class CmdBoom extends FCommand {
|
||||
super();
|
||||
this.aliases.addAll(Aliases.boom);
|
||||
|
||||
//this.requiredArgs.add("");
|
||||
this.optionalArgs.put("on/off", "flip");
|
||||
|
||||
this.requirements = new CommandRequirements.Builder(Permission.NO_BOOM)
|
||||
|
||||
@@ -14,6 +14,7 @@ public class CmdBypass extends FCommand {
|
||||
super();
|
||||
this.aliases.addAll(Aliases.bypass);
|
||||
|
||||
//this.requiredArgs.add("");
|
||||
this.optionalArgs.put("on/off", "flip");
|
||||
|
||||
this.requirements = new CommandRequirements.Builder(Permission.BYPASS)
|
||||
|
||||
@@ -18,6 +18,7 @@ public class CmdChat extends FCommand {
|
||||
super();
|
||||
this.aliases.addAll(Aliases.chat);
|
||||
|
||||
//this.requiredArgs.add("");
|
||||
this.optionalArgs.put("mode", "next");
|
||||
|
||||
this.requirements = new CommandRequirements.Builder(Permission.CHAT)
|
||||
@@ -85,7 +86,7 @@ public class CmdChat extends FCommand {
|
||||
return TL.COMMAND_CHAT_DESCRIPTION;
|
||||
}
|
||||
|
||||
protected static class ChatBrigadier implements BrigadierProvider {
|
||||
protected class ChatBrigadier implements BrigadierProvider {
|
||||
@Override
|
||||
public ArgumentBuilder<Object, ?> get(ArgumentBuilder<Object, ?> parent) {
|
||||
return parent.then(LiteralArgumentBuilder.literal("public"))
|
||||
|
||||
@@ -2,7 +2,10 @@ package com.massivecraft.factions.cmd;
|
||||
|
||||
import com.massivecraft.factions.*;
|
||||
import com.massivecraft.factions.struct.Permission;
|
||||
import com.massivecraft.factions.struct.Role;
|
||||
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;
|
||||
|
||||
public class CmdCheckpoint extends FCommand {
|
||||
@@ -17,10 +20,7 @@ public class CmdCheckpoint extends FCommand {
|
||||
|
||||
this.optionalArgs.put("set", "");
|
||||
|
||||
this.requirements = new CommandRequirements.Builder(Permission.CHECKPOINT)
|
||||
.playerOnly()
|
||||
.memberOnly()
|
||||
.build();
|
||||
this.requirements = new CommandRequirements.Builder(Permission.CHECKPOINT).playerOnly().memberOnly().build();
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -29,17 +29,39 @@ public class CmdCheckpoint extends FCommand {
|
||||
context.msg(TL.COMMAND_CHECKPOINT_DISABLED);
|
||||
return;
|
||||
}
|
||||
if (context.args.size() == 1) {
|
||||
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);
|
||||
if (context.args.size() == 1 && context.args.get(0).equalsIgnoreCase("set")) {
|
||||
if (context.fPlayer.getRole() == Role.LEADER) {
|
||||
FLocation myLocation = new FLocation(context.player.getLocation());
|
||||
Faction myLocFaction = Board.getInstance().getFactionAt(myLocation);
|
||||
if (myLocFaction == Factions.getInstance().getWilderness() || myLocFaction == context.faction) {
|
||||
context.faction.setCheckpoint(context.player.getLocation());
|
||||
context.msg(TL.COMMAND_CHECKPOINT_SET);
|
||||
return;
|
||||
}
|
||||
} else {
|
||||
context.msg(TL.COMMAND_CHECKPOINT_INVALIDLOCATION);
|
||||
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;
|
||||
} 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;
|
||||
}
|
||||
}
|
||||
return;
|
||||
}
|
||||
|
||||
if (context.faction.getCheckpoint() == null) {
|
||||
context.msg(TL.COMMAND_CHECKPOINT_NOT_SET);
|
||||
return;
|
||||
@@ -56,8 +78,6 @@ public class CmdCheckpoint extends FCommand {
|
||||
} else {
|
||||
context.msg(TL.COMMAND_CHECKPOINT_CLAIMED);
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
|
||||
@@ -55,7 +55,7 @@ public class CmdColeader extends FCommand {
|
||||
return;
|
||||
}
|
||||
|
||||
if(you.isAlt()){
|
||||
if (you.isAlt()) {
|
||||
return;
|
||||
}
|
||||
|
||||
|
||||
@@ -54,7 +54,7 @@ public class CmdCreate extends FCommand {
|
||||
return;
|
||||
}
|
||||
|
||||
if(Cooldown.isOnCooldown(context.fPlayer.getPlayer(), "createCooldown") && !context.fPlayer.isAdminBypassing()){
|
||||
if (Cooldown.isOnCooldown(context.fPlayer.getPlayer(), "createCooldown") && !context.fPlayer.isAdminBypassing()) {
|
||||
context.msg(TL.COMMAND_COOLDOWN);
|
||||
return;
|
||||
}
|
||||
@@ -66,7 +66,7 @@ public class CmdCreate extends FCommand {
|
||||
}
|
||||
|
||||
ArrayList<String> tagValidationErrors = MiscUtil.validateTag(tag);
|
||||
if (tagValidationErrors.isEmpty()) {
|
||||
if (tagValidationErrors.size() > 0) {
|
||||
context.sendMessage(tagValidationErrors);
|
||||
return;
|
||||
}
|
||||
|
||||
@@ -3,10 +3,7 @@ package com.massivecraft.factions.cmd;
|
||||
import com.massivecraft.factions.Conf;
|
||||
import com.massivecraft.factions.FPlayer;
|
||||
import com.massivecraft.factions.FPlayers;
|
||||
import com.massivecraft.factions.FactionsPlugin;
|
||||
import com.massivecraft.factions.struct.Permission;
|
||||
import com.massivecraft.factions.struct.Role;
|
||||
import com.massivecraft.factions.zcore.fperms.Access;
|
||||
import com.massivecraft.factions.zcore.fperms.PermissableAction;
|
||||
import com.massivecraft.factions.zcore.util.TL;
|
||||
import mkremins.fanciful.FancyMessage;
|
||||
@@ -56,6 +53,7 @@ public class CmdDeinvite extends FCommand {
|
||||
|
||||
context.faction.msg(TL.COMMAND_DEINVITE_REVOKES, context.fPlayer.describeTo(context.faction), you.describeTo(context.faction));
|
||||
}
|
||||
|
||||
@Override
|
||||
public TL getUsageTranslation() {
|
||||
return TL.COMMAND_DEINVITE_DESCRIPTION;
|
||||
|
||||
@@ -39,7 +39,7 @@ public class CmdDescription extends FCommand {
|
||||
|
||||
// since "&" color tags seem to work even through plain old FPlayer.sendMessage() for some reason, we need to break those up
|
||||
// And replace all the % because it messes with string formatting and this is easy way around that.
|
||||
String desc = TextUtil.implode(context.args, " ").replace("%", "").replaceAll("(&([a-f0-9klmnor]))", "& $2");
|
||||
String desc = TextUtil.implode(context.args, " ").replaceAll("%", "").replaceAll("(&([a-f0-9klmnor]))", "& $2");
|
||||
context.faction.setDescription(desc);
|
||||
Bukkit.getScheduler().scheduleSyncDelayedTask(FactionsPlugin.instance, () -> FactionsPlugin.instance.logFactionEvent(context.faction, FLogType.FDESC_EDIT, context.fPlayer.getName(), desc));
|
||||
if (!Conf.broadcastDescriptionChanges) {
|
||||
|
||||
@@ -42,8 +42,8 @@ public class CmdDisband extends FCommand {
|
||||
|
||||
boolean isMyFaction = context.fPlayer != null && faction == context.faction;
|
||||
|
||||
if (!isMyFaction && !Permission.DISBAND_ANY.has(context.sender, true)) {
|
||||
return;
|
||||
if (!isMyFaction) {
|
||||
if (!Permission.DISBAND_ANY.has(context.sender, true)) return;
|
||||
}
|
||||
|
||||
|
||||
@@ -81,9 +81,13 @@ public class CmdDisband extends FCommand {
|
||||
access = true;
|
||||
}
|
||||
|
||||
if (!access && Conf.useDisbandGUI && (!context.fPlayer.isAdminBypassing() || !context.player.isOp()) && !disbandMap.containsKey(context.player.getUniqueId().toString())) {
|
||||
new FDisbandFrame(context.faction).buildGUI(context.fPlayer);
|
||||
return;
|
||||
if (!access) {
|
||||
if (Conf.useDisbandGUI && (!context.fPlayer.isAdminBypassing() || !context.player.isOp())) {
|
||||
if (!disbandMap.containsKey(context.player.getUniqueId().toString())) {
|
||||
new FDisbandFrame(context.faction).buildGUI(context.fPlayer);
|
||||
return;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// check for tnt before disbanding.
|
||||
|
||||
@@ -19,6 +19,7 @@ import java.util.concurrent.ConcurrentHashMap;
|
||||
|
||||
public class CmdFly extends FCommand {
|
||||
|
||||
public static final boolean fly = FactionsPlugin.getInstance().getConfig().getBoolean("enable-faction-flight");
|
||||
/**
|
||||
* @author FactionsUUID Team
|
||||
*/
|
||||
@@ -27,8 +28,6 @@ public class CmdFly extends FCommand {
|
||||
public static ConcurrentHashMap<String, Boolean> flyMap = new ConcurrentHashMap<>();
|
||||
public static BukkitTask particleTask = null;
|
||||
|
||||
public static final boolean fly = FactionsPlugin.getInstance().getConfig().getBoolean("enable-faction-flight");
|
||||
|
||||
|
||||
public CmdFly() {
|
||||
super();
|
||||
@@ -65,25 +64,25 @@ public class CmdFly extends FCommand {
|
||||
|
||||
if (toFac != fme.getFaction()) {
|
||||
if (!me.hasPermission(Permission.FLY_WILDERNESS.node) && toFac.isWilderness() || !me.hasPermission(Permission.FLY_SAFEZONE.node) && toFac.isSafeZone() || !me.hasPermission(Permission.FLY_WARZONE.node) && toFac.isWarZone()) {
|
||||
if(sendMessage) fme.msg(TL.COMMAND_FLY_NO_ACCESS, toFac.getTag(fme));
|
||||
if (sendMessage) fme.msg(TL.COMMAND_FLY_NO_ACCESS, toFac.getTag(fme));
|
||||
return false;
|
||||
}
|
||||
Access access = toFac.getAccess(fme, PermissableAction.FLY);
|
||||
if ((!(me.hasPermission(Permission.FLY_ENEMY.node) || access == Access.ALLOW)) && toFac.getRelationTo(fme.getFaction()) == Relation.ENEMY) {
|
||||
if(sendMessage) fme.msg(TL.COMMAND_FLY_NO_ACCESS, toFac.getTag(fme));
|
||||
if (sendMessage) fme.msg(TL.COMMAND_FLY_NO_ACCESS, toFac.getTag(fme));
|
||||
return false;
|
||||
}
|
||||
if (!(me.hasPermission(Permission.FLY_ALLY.node) || access == Access.ALLOW) && toFac.getRelationTo(fme.getFaction()) == Relation.ALLY) {
|
||||
if(sendMessage) fme.msg(TL.COMMAND_FLY_NO_ACCESS, toFac.getTag(fme));
|
||||
if (sendMessage) fme.msg(TL.COMMAND_FLY_NO_ACCESS, toFac.getTag(fme));
|
||||
return false;
|
||||
}
|
||||
if (!(me.hasPermission(Permission.FLY_TRUCE.node) || access == Access.ALLOW) && toFac.getRelationTo(fme.getFaction()) == Relation.TRUCE) {
|
||||
if(sendMessage) fme.msg(TL.COMMAND_FLY_NO_ACCESS, toFac.getTag(fme));
|
||||
if (sendMessage) fme.msg(TL.COMMAND_FLY_NO_ACCESS, toFac.getTag(fme));
|
||||
return false;
|
||||
}
|
||||
|
||||
if (!(me.hasPermission(Permission.FLY_NEUTRAL.node) || access == Access.ALLOW) && toFac.getRelationTo(fme.getFaction()) == Relation.NEUTRAL && !toFac.isSystemFaction()) {
|
||||
if(sendMessage) fme.msg(TL.COMMAND_FLY_NO_ACCESS, toFac.getTag(fme));
|
||||
if (sendMessage) fme.msg(TL.COMMAND_FLY_NO_ACCESS, toFac.getTag(fme));
|
||||
return false;
|
||||
}
|
||||
return me.hasPermission(Permission.FLY_FLY.node) && (access != Access.DENY || toFac.isSystemFaction());
|
||||
|
||||
@@ -11,7 +11,7 @@ import com.massivecraft.factions.zcore.util.TL;
|
||||
*/
|
||||
public class CmdFriendlyFire extends FCommand {
|
||||
|
||||
public CmdFriendlyFire(){
|
||||
public CmdFriendlyFire() {
|
||||
super();
|
||||
this.aliases.addAll(Aliases.friendlyFire);
|
||||
|
||||
@@ -23,12 +23,12 @@ public class CmdFriendlyFire extends FCommand {
|
||||
|
||||
@Override
|
||||
public void perform(CommandContext context) {
|
||||
if(!Conf.friendlyFireFPlayersCommand){
|
||||
if (!Conf.friendlyFireFPlayersCommand) {
|
||||
context.msg(TL.GENERIC_DISABLED, "friendly fire");
|
||||
return;
|
||||
}
|
||||
|
||||
if(context.fPlayer.hasFriendlyFire()){
|
||||
if (context.fPlayer.hasFriendlyFire()) {
|
||||
context.fPlayer.setFriendlyFire(false);
|
||||
context.msg(TL.COMMAND_FRIENDLY_FIRE_TOGGLE_OFF);
|
||||
} else {
|
||||
|
||||
@@ -88,7 +88,11 @@ public class CmdHome extends FCommand {
|
||||
final Location loc = context.player.getLocation().clone();
|
||||
|
||||
// if player is not in a safe zone or their own faction territory, only allow teleport if no enemies are nearby
|
||||
if (Conf.homesTeleportAllowedEnemyDistance > 0 && !faction.isSafeZone() && (!context.fPlayer.isInOwnTerritory() || !Conf.homesTeleportIgnoreEnemiesIfInOwnTerritory)) {
|
||||
if (Conf.homesTeleportAllowedEnemyDistance > 0
|
||||
&& !faction.isSafeZone()
|
||||
&& (!context.fPlayer.isInOwnTerritory()
|
||||
|| (context.fPlayer.isInOwnTerritory()
|
||||
&& !Conf.homesTeleportIgnoreEnemiesIfInOwnTerritory))) {
|
||||
|
||||
World w = loc.getWorld();
|
||||
double x = loc.getX();
|
||||
|
||||
@@ -49,7 +49,6 @@ public class CmdInventorySee extends FCommand {
|
||||
|
||||
FPlayer targetInv = context.argAsFPlayer(0);
|
||||
if (targetInv == null || !fplayers.contains(targetInv.getPlayer())) {
|
||||
assert targetInv != null;
|
||||
context.msg(TL.PLAYER_NOT_FOUND, Objects.requireNonNull(targetInv.getName()));
|
||||
return;
|
||||
}
|
||||
|
||||
@@ -9,7 +9,6 @@ import com.massivecraft.factions.util.CC;
|
||||
import com.massivecraft.factions.zcore.fperms.PermissableAction;
|
||||
import com.massivecraft.factions.zcore.util.TL;
|
||||
import mkremins.fanciful.FancyMessage;
|
||||
import org.bukkit.ChatColor;
|
||||
|
||||
public class CmdInvite extends FCommand {
|
||||
|
||||
@@ -61,9 +60,9 @@ public class CmdInvite extends FCommand {
|
||||
if (target.isOnline()) {
|
||||
// Tooltips, colors, and commands only apply to the string immediately before it.
|
||||
FancyMessage message = new FancyMessage(TL.COMMAND_INVITE_INVITEDYOU.toString()
|
||||
.replace("%1$s", context.fPlayer.describeTo(target, true))
|
||||
.replace("%2$s", context.faction.getTag())
|
||||
.replace("&", "§"))
|
||||
.replace("%1$s", context.fPlayer.describeTo(target, true))
|
||||
.replace("%2$s", context.faction.getTag())
|
||||
.replaceAll("&", "§"))
|
||||
.tooltip(TL.COMMAND_INVITE_CLICKTOJOIN.toString())
|
||||
.command("/" + Conf.baseCommandAliases.get(0) + " join " + context.faction.getTag());
|
||||
message.send(target.getPlayer());
|
||||
|
||||
@@ -1,19 +1,12 @@
|
||||
package com.massivecraft.factions.cmd;
|
||||
|
||||
import com.massivecraft.factions.*;
|
||||
import com.massivecraft.factions.cmd.audit.FLogType;
|
||||
import com.massivecraft.factions.discord.Discord;
|
||||
import com.massivecraft.factions.event.FPlayerJoinEvent;
|
||||
import com.massivecraft.factions.struct.Permission;
|
||||
import com.massivecraft.factions.util.CC;
|
||||
import com.massivecraft.factions.zcore.frame.fupgrades.UpgradeType;
|
||||
import com.massivecraft.factions.zcore.util.TL;
|
||||
import net.dv8tion.jda.core.entities.Member;
|
||||
import net.dv8tion.jda.core.exceptions.HierarchyException;
|
||||
import org.bukkit.Bukkit;
|
||||
|
||||
import java.util.Objects;
|
||||
|
||||
public class CmdJoin extends FCommand {
|
||||
|
||||
public CmdJoin() {
|
||||
|
||||
@@ -1,6 +1,9 @@
|
||||
package com.massivecraft.factions.cmd;
|
||||
|
||||
import com.massivecraft.factions.*;
|
||||
import com.massivecraft.factions.Conf;
|
||||
import com.massivecraft.factions.FPlayer;
|
||||
import com.massivecraft.factions.Faction;
|
||||
import com.massivecraft.factions.FactionsPlugin;
|
||||
import com.massivecraft.factions.cmd.audit.FLogType;
|
||||
import com.massivecraft.factions.event.FPlayerLeaveEvent;
|
||||
import com.massivecraft.factions.struct.Permission;
|
||||
@@ -125,7 +128,7 @@ public class CmdKick extends FCommand {
|
||||
FactionsPlugin.instance.logFactionEvent(toKickFaction, FLogType.INVITES, context.fPlayer.getName(), CC.Red + "kicked", toKick.getName());
|
||||
toKickFaction.deinvite(toKick);
|
||||
toKick.resetFactionData();
|
||||
if(!CmdFly.checkBypassPerms(toKick, toKick.getPlayer(), toKickFaction, false)){
|
||||
if (!CmdFly.checkBypassPerms(toKick, toKick.getPlayer(), toKickFaction, false)) {
|
||||
CmdFly.disableFlight(toKick);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -50,7 +50,7 @@ public class CmdMod extends FCommand {
|
||||
return;
|
||||
}
|
||||
|
||||
if(you.isAlt()){
|
||||
if (you.isAlt()) {
|
||||
return;
|
||||
}
|
||||
|
||||
|
||||
@@ -39,7 +39,7 @@ public class CmdOpen extends FCommand {
|
||||
|
||||
String open = context.faction.getOpen() ? TL.COMMAND_OPEN_OPEN.toString() : TL.COMMAND_OPEN_CLOSED.toString();
|
||||
|
||||
if(Cooldown.isOnCooldown(context.fPlayer.getPlayer(), "openCooldown") && !context.fPlayer.isAdminBypassing()){
|
||||
if (Cooldown.isOnCooldown(context.fPlayer.getPlayer(), "openCooldown") && !context.fPlayer.isAdminBypassing()) {
|
||||
context.msg(TL.COMMAND_COOLDOWN);
|
||||
return;
|
||||
}
|
||||
@@ -51,7 +51,7 @@ public class CmdOpen extends FCommand {
|
||||
Cooldown.setCooldown(fplayer.getPlayer(), "openCooldown", FactionsPlugin.getInstance().getConfig().getInt("fcooldowns.f-open"));
|
||||
continue;
|
||||
}
|
||||
if(FactionsPlugin.getInstance().getConfig().getBoolean("faction-open-broadcast")) return;
|
||||
if (FactionsPlugin.getInstance().getConfig().getBoolean("faction-open-broadcast")) return;
|
||||
fplayer.msg(TL.COMMAND_OPEN_CHANGED, context.faction.getTag(fplayer.getFaction()), open);
|
||||
}
|
||||
});
|
||||
|
||||
@@ -66,16 +66,18 @@ public class CmdRules extends FCommand {
|
||||
String message = "";
|
||||
StringBuilder string = new StringBuilder(message);
|
||||
for (int i = 1; i <= context.args.size() - 1; i++) {
|
||||
string.append(" ").append(context.args.get(i));
|
||||
string.append(" " + context.args.get(i));
|
||||
}
|
||||
context.faction.addRule(string.toString());
|
||||
context.msg(TL.COMMAND_RULES_ADD_SUCCESS);
|
||||
}
|
||||
|
||||
if (context.args.size() == 2 && context.args.get(0).equalsIgnoreCase("remove")) {
|
||||
if (context.args.size() == 2) {
|
||||
if (context.args.get(0).equalsIgnoreCase("remove")) {
|
||||
int index = context.argAsInt(1);
|
||||
context.faction.removeRule(index - 1);
|
||||
context.msg(TL.COMMAND_RULES_REMOVE_SUCCESS);
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -1,12 +1,12 @@
|
||||
package com.massivecraft.factions.cmd;
|
||||
|
||||
|
||||
import com.cryptomorin.xseries.XMaterial;
|
||||
import com.massivecraft.factions.FLocation;
|
||||
import com.massivecraft.factions.FactionsPlugin;
|
||||
import com.massivecraft.factions.struct.Permission;
|
||||
import com.massivecraft.factions.util.ParticleEffect;
|
||||
import com.massivecraft.factions.util.VisualizeUtil;
|
||||
import com.massivecraft.factions.util.XMaterial;
|
||||
import com.massivecraft.factions.zcore.util.TL;
|
||||
import org.bukkit.*;
|
||||
import org.bukkit.entity.Player;
|
||||
|
||||
@@ -110,7 +110,7 @@ public class CmdShow extends FCommand {
|
||||
parsed = parsed.substring(0, parsed.indexOf("{ig}")) + TL.COMMAND_SHOW_NOHOME.toString();
|
||||
}
|
||||
if (parsed.contains("%")) {
|
||||
parsed = parsed.replace("%", ""); // Just in case it got in there before we disallowed it.
|
||||
parsed = parsed.replaceAll("%", ""); // Just in case it got in there before we disallowed it.
|
||||
}
|
||||
parsed = FactionsPlugin.getInstance().txt.parse(parsed);
|
||||
FancyMessage localFancy = instance.txt.parseFancy(parsed);
|
||||
|
||||
@@ -54,7 +54,7 @@ public class CmdTag extends FCommand {
|
||||
return;
|
||||
}
|
||||
|
||||
if(Cooldown.isOnCooldown(context.player, "tagCooldown") && !context.fPlayer.isAdminBypassing()){
|
||||
if (Cooldown.isOnCooldown(context.player, "tagCooldown") && !context.fPlayer.isAdminBypassing()) {
|
||||
context.msg(TL.COMMAND_COOLDOWN);
|
||||
return;
|
||||
}
|
||||
@@ -72,7 +72,6 @@ public class CmdTag extends FCommand {
|
||||
}
|
||||
|
||||
|
||||
|
||||
String oldtag = context.faction.getTag();
|
||||
context.faction.setTag(tag);
|
||||
|
||||
|
||||
@@ -30,7 +30,9 @@ public class CmdTpBanner extends FCommand {
|
||||
|
||||
if (FactionsBlockListener.bannerLocations.containsKey(context.fPlayer.getTag())) {
|
||||
context.msg(TL.COMMAND_TPBANNER_SUCCESS);
|
||||
context.doWarmUp(WarmUpUtil.Warmup.BANNER, TL.WARMUPS_NOTIFY_TELEPORT, "Banner", () -> context.player.teleport(FactionsBlockListener.bannerLocations.get(context.fPlayer.getTag())), FactionsPlugin.getInstance().getConfig().getLong("warmups.f-banner", 0));
|
||||
context.doWarmUp(WarmUpUtil.Warmup.BANNER, TL.WARMUPS_NOTIFY_TELEPORT, "Banner", () -> {
|
||||
context.player.teleport(FactionsBlockListener.bannerLocations.get(context.fPlayer.getTag()));
|
||||
}, FactionsPlugin.getInstance().getConfig().getLong("warmups.f-banner", 0));
|
||||
} else {
|
||||
context.msg(TL.COMMAND_TPBANNER_NOTSET);
|
||||
}
|
||||
|
||||
@@ -5,7 +5,6 @@ import com.massivecraft.factions.struct.Permission;
|
||||
import com.massivecraft.factions.zcore.fperms.Access;
|
||||
import com.massivecraft.factions.zcore.fperms.PermissableAction;
|
||||
import com.massivecraft.factions.zcore.util.TL;
|
||||
import org.bukkit.Material;
|
||||
|
||||
public class CmdUnban extends FCommand {
|
||||
|
||||
@@ -33,8 +32,12 @@ public class CmdUnban extends FCommand {
|
||||
return; // the above method sends a message if fails to find someone.
|
||||
}
|
||||
|
||||
if (target.getFaction() != context.fPlayer.getFaction() && target.getFaction().getAccess(context.fPlayer, PermissableAction.BAN) != Access.ALLOW && !context.fPlayer.isAdminBypassing()) {
|
||||
if (target.getFaction() != context.fPlayer.getFaction()) {
|
||||
if (target.getFaction().getAccess(context.fPlayer, PermissableAction.BAN) != Access.ALLOW) {
|
||||
if (!context.fPlayer.isAdminBypassing()) {
|
||||
context.fPlayer.msg(TL.COMMAND_UNBAN_TARGET_IN_OTHER_FACTION, target.getName());
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (!context.faction.isBanned(target)) {
|
||||
|
||||
@@ -70,9 +70,13 @@ public class CommandRequirements {
|
||||
return false;
|
||||
}
|
||||
|
||||
if (access != Access.ALLOW && role != null && !context.fPlayer.getRole().isAtLeast(role)) {
|
||||
if (informIfNot) context.msg(TL.GENERIC_YOUMUSTBE, role.translation);
|
||||
return false;
|
||||
if (access != Access.ALLOW) {
|
||||
// They have undefined assert their role
|
||||
if (role != null && !context.fPlayer.getRole().isAtLeast(role)) {
|
||||
// They do not fullfill the role
|
||||
if (informIfNot) context.msg(TL.GENERIC_YOUMUSTBE, role.translation);
|
||||
return false;
|
||||
}
|
||||
}
|
||||
// They have been explicitly allowed
|
||||
return true;
|
||||
|
||||
@@ -19,6 +19,7 @@ import com.massivecraft.factions.cmd.relational.CmdRelationTruce;
|
||||
import com.massivecraft.factions.cmd.reserve.CmdReserve;
|
||||
import com.massivecraft.factions.cmd.roles.CmdDemote;
|
||||
import com.massivecraft.factions.cmd.roles.CmdPromote;
|
||||
import com.massivecraft.factions.cmd.shields.CmdShield;
|
||||
import com.massivecraft.factions.cmd.tnt.CmdTnt;
|
||||
import com.massivecraft.factions.cmd.tnt.CmdTntFill;
|
||||
import com.massivecraft.factions.cmd.wild.CmdWild;
|
||||
@@ -26,6 +27,7 @@ import com.massivecraft.factions.discord.CmdInviteBot;
|
||||
import com.massivecraft.factions.discord.CmdSetGuild;
|
||||
import com.massivecraft.factions.missions.CmdMissions;
|
||||
import com.massivecraft.factions.shop.CmdShop;
|
||||
import com.massivecraft.factions.shop.ShopGUIFrame;
|
||||
import com.massivecraft.factions.zcore.util.TL;
|
||||
import me.lucko.commodore.CommodoreProvider;
|
||||
import org.bukkit.Bukkit;
|
||||
@@ -170,6 +172,7 @@ public class FCmdRoot extends FCommand implements CommandExecutor {
|
||||
public CmdClaimFill cmdClaimFill = new CmdClaimFill();
|
||||
public CmdNotifications cmdNotifications = new CmdNotifications();
|
||||
public CmdFriendlyFire cmdFriendlyFire = new CmdFriendlyFire();
|
||||
public CmdShield cmdShield = new CmdShield();
|
||||
|
||||
//Variables to know if we already setup certain sub commands
|
||||
public Boolean discordEnabled = false;
|
||||
@@ -305,6 +308,7 @@ public class FCmdRoot extends FCommand implements CommandExecutor {
|
||||
this.addSubCommand(this.cmdLookup);
|
||||
this.addSubCommand(this.cmdNotifications);
|
||||
this.addSubCommand(this.cmdFriendlyFire);
|
||||
this.addSubCommand(this.cmdShield);
|
||||
addVariableCommands();
|
||||
if (CommodoreProvider.isSupported()) brigadierManager.build();
|
||||
}
|
||||
@@ -377,6 +381,7 @@ public class FCmdRoot extends FCommand implements CommandExecutor {
|
||||
}
|
||||
if (FactionsPlugin.getInstance().getConfig().getBoolean("F-Shop.Enabled", false) && !fShopEnabled) {
|
||||
this.addSubCommand(this.cmdShop);
|
||||
new ShopGUIFrame(null).checkShopConfig();
|
||||
fShopEnabled = true;
|
||||
}
|
||||
if (FactionsPlugin.getInstance().getConfig().getBoolean("f-inventory-see.Enabled", false) && !invSeeEnabled) {
|
||||
|
||||
@@ -44,7 +44,7 @@ public class CmdAltsList extends FCommand {
|
||||
return;
|
||||
}
|
||||
|
||||
if (faction.getAltPlayers().isEmpty()) {
|
||||
if (faction.getAltPlayers().size() == 0) {
|
||||
context.msg(TL.COMMAND_ALTS_LIST_NOALTS, faction.getTag());
|
||||
return;
|
||||
}
|
||||
|
||||
@@ -114,7 +114,7 @@ public class FAuditMenu extends GUIMenu {
|
||||
}
|
||||
lore.add("");
|
||||
lore.add(CC.Gray + "Click to toggle timestamp");
|
||||
setItem(slot++, (new ClickableItemStack((new ItemBuilder(Material.PAPER)).name(CC.GreenB + "Log #" + page).lore(lore).build())).setClickCallback(e -> {
|
||||
setItem(slot++, (new ClickableItemStack((new ItemBuilder(Material.PAPER)).name(CC.GreenB + "Log #" + page).lore(lore).build())).setClickCallback((e) -> {
|
||||
e.setCancelled(true);
|
||||
timeStamp = !timeStamp;
|
||||
drawItems();
|
||||
@@ -122,7 +122,7 @@ public class FAuditMenu extends GUIMenu {
|
||||
}
|
||||
}
|
||||
}
|
||||
setItem(getSize() - 1, (new ClickableItemStack((new ItemBuilder(Material.ARROW)).name(CC.Green + "Previous Page").lore("", CC.Gray + "Click to view previous page!").build())).setClickCallback(event -> {
|
||||
setItem(getSize() - 1, (new ClickableItemStack((new ItemBuilder(Material.ARROW)).name(CC.Green + "Previous Page").lore("", CC.Gray + "Click to view previous page!").build())).setClickCallback((event) -> {
|
||||
event.setCancelled(true);
|
||||
Bukkit.getScheduler().scheduleSyncDelayedTask(FactionsPlugin.instance, () -> (new FAuditMenu(player, faction)).open(player));
|
||||
}));
|
||||
|
||||
@@ -25,6 +25,8 @@ public class FLogManager {
|
||||
private Map<UUID, LogTimer> logTimers = new ConcurrentHashMap<>();
|
||||
private boolean saving = false;
|
||||
|
||||
public FLogManager() {
|
||||
}
|
||||
|
||||
public void log(Faction faction, FLogType type, String... arguments) {
|
||||
FactionLogs logs = factionLogMap.computeIfAbsent(faction.getId(), (n) -> new FactionLogs());
|
||||
@@ -88,7 +90,8 @@ public class FLogManager {
|
||||
Faction faction = null;
|
||||
|
||||
for (Map.Entry<UUID, LogTimer> uuidLogTimerEntry : getLogTimers().entrySet()) {
|
||||
LogTimer logTimer = uuidLogTimerEntry.getValue();
|
||||
Map.Entry<UUID, LogTimer> timer = uuidLogTimerEntry;
|
||||
LogTimer logTimer = timer.getValue();
|
||||
if (faction == null) {
|
||||
faction = Factions.getInstance().getFactionById(logTimer.getFactionId());
|
||||
}
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
package com.massivecraft.factions.cmd.audit;
|
||||
|
||||
import com.cryptomorin.xseries.XMaterial;
|
||||
import com.massivecraft.factions.FactionsPlugin;
|
||||
import com.massivecraft.factions.util.XMaterial;
|
||||
import org.bukkit.Material;
|
||||
|
||||
/**
|
||||
|
||||
@@ -65,11 +65,11 @@ public class FactionLogs {
|
||||
}
|
||||
}
|
||||
}
|
||||
if (logs.isEmpty())
|
||||
if (logs.size() <= 0)
|
||||
toRemove.add(logType);
|
||||
}
|
||||
});
|
||||
toRemove.forEach(rem -> mostRecentLogs.remove(rem));
|
||||
toRemove.forEach((rem) -> mostRecentLogs.remove(rem));
|
||||
}
|
||||
|
||||
public Map<FLogType, LinkedList<FactionLog>> getMostRecentLogs() {
|
||||
|
||||
@@ -26,11 +26,11 @@ public class LogTimer extends ConcurrentHashMap<LogTimer.TimerType, Map<LogTimer
|
||||
}
|
||||
|
||||
public Map<LogTimer.TimerSubType, LogTimer.Timer> getCurrentTimersOrCreate(LogTimer.TimerType type) {
|
||||
return this.computeIfAbsent(type, m -> new ConcurrentHashMap<>());
|
||||
return this.computeIfAbsent(type, (m) -> new ConcurrentHashMap<>());
|
||||
}
|
||||
|
||||
public LogTimer.Timer attemptLog(LogTimer.TimerType type, LogTimer.TimerSubType subType, long increment) {
|
||||
return this.getCurrentTimersOrCreate(type).computeIfAbsent(subType, e -> new Timer(System.currentTimeMillis(), 0L, null)).increment(increment);
|
||||
return this.getCurrentTimersOrCreate(type).computeIfAbsent(subType, (e) -> new Timer(System.currentTimeMillis(), 0L, null)).increment(increment);
|
||||
}
|
||||
|
||||
public void pushLogs(Faction faction, LogTimer.TimerType type) {
|
||||
|
||||
@@ -1,10 +1,10 @@
|
||||
package com.massivecraft.factions.cmd.check;
|
||||
|
||||
import com.cryptomorin.xseries.XMaterial;
|
||||
import com.google.common.collect.Lists;
|
||||
import com.massivecraft.factions.Conf;
|
||||
import com.massivecraft.factions.Faction;
|
||||
import com.massivecraft.factions.FactionsPlugin;
|
||||
import com.massivecraft.factions.util.XMaterial;
|
||||
import com.massivecraft.factions.zcore.frame.FactionGUI;
|
||||
import com.massivecraft.factions.zcore.util.TL;
|
||||
import org.bukkit.DyeColor;
|
||||
@@ -13,19 +13,24 @@ import org.bukkit.inventory.Inventory;
|
||||
import org.bukkit.inventory.ItemStack;
|
||||
import org.bukkit.inventory.meta.ItemMeta;
|
||||
import org.bukkit.material.MaterialData;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
|
||||
import java.text.SimpleDateFormat;
|
||||
import java.util.*;
|
||||
|
||||
public class CheckHistoryFrame implements FactionGUI {
|
||||
|
||||
/**
|
||||
* @author Driftay
|
||||
*/
|
||||
|
||||
private FactionsPlugin plugin;
|
||||
private Faction faction;
|
||||
private Inventory inventory;
|
||||
private SimpleDateFormat simpleDateFormat;
|
||||
|
||||
public CheckHistoryFrame(FactionsPlugin plugin, Faction faction) {
|
||||
this.simpleDateFormat = new SimpleDateFormat(Conf.dateFormat);
|
||||
this.plugin = plugin;
|
||||
this.faction = faction;
|
||||
this.inventory = plugin.getServer().createInventory(this, 54, TL.CHECK_HISTORY_GUI_TITLE.toString());
|
||||
}
|
||||
@@ -83,7 +88,6 @@ public class CheckHistoryFrame implements FactionGUI {
|
||||
}
|
||||
}
|
||||
|
||||
@NotNull
|
||||
public Inventory getInventory() {
|
||||
return inventory;
|
||||
}
|
||||
|
||||
@@ -1,9 +1,9 @@
|
||||
package com.massivecraft.factions.cmd.check;
|
||||
|
||||
import com.cryptomorin.xseries.XMaterial;
|
||||
import com.massivecraft.factions.FPlayer;
|
||||
import com.massivecraft.factions.Faction;
|
||||
import com.massivecraft.factions.FactionsPlugin;
|
||||
import com.massivecraft.factions.util.XMaterial;
|
||||
import com.massivecraft.factions.zcore.frame.FactionGUI;
|
||||
import com.massivecraft.factions.zcore.util.TL;
|
||||
import org.bukkit.ChatColor;
|
||||
@@ -12,7 +12,6 @@ import org.bukkit.inventory.Inventory;
|
||||
import org.bukkit.inventory.InventoryHolder;
|
||||
import org.bukkit.inventory.ItemStack;
|
||||
import org.bukkit.inventory.meta.ItemMeta;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
|
||||
import java.util.Collections;
|
||||
|
||||
@@ -72,7 +71,6 @@ public class CheckSettingsFrame implements InventoryHolder, FactionGUI {
|
||||
inventory.setItem(FactionsPlugin.getInstance().getConfig().getInt("f-check.history.slot"), historyStack);
|
||||
}
|
||||
|
||||
@NotNull
|
||||
public Inventory getInventory() {
|
||||
return this.inventory;
|
||||
}
|
||||
@@ -94,6 +92,9 @@ public class CheckSettingsFrame implements InventoryHolder, FactionGUI {
|
||||
case 15: {
|
||||
return 30;
|
||||
}
|
||||
case 30: {
|
||||
return 0;
|
||||
}
|
||||
default: {
|
||||
return 0;
|
||||
}
|
||||
|
||||
@@ -11,7 +11,14 @@ import net.dv8tion.jda.core.entities.TextChannel;
|
||||
|
||||
public class WeeWooTask implements Runnable {
|
||||
|
||||
/**
|
||||
* @author Driftay
|
||||
*/
|
||||
|
||||
private FactionsPlugin plugin;
|
||||
|
||||
public WeeWooTask(FactionsPlugin plugin) {
|
||||
this.plugin = plugin;
|
||||
}
|
||||
|
||||
@Override
|
||||
|
||||
@@ -29,11 +29,13 @@ public class AntiChestListener implements Listener {
|
||||
Inventory clicked = e.getClickedInventory();
|
||||
Inventory clicker = e.getWhoClicked().getInventory();
|
||||
|
||||
if (e.getClick().isShiftClick() && clicked == clicker) {
|
||||
ItemStack clickedOn = e.getCurrentItem();
|
||||
if (clickedOn != null && FactionsPlugin.getInstance().itemList.contains(clickedOn.getType().toString())) {
|
||||
fPlayer.msg(TL.CHEST_ITEM_DENIED_TRANSFER, clickedOn.getType().toString());
|
||||
e.setCancelled(true);
|
||||
if (e.getClick().isShiftClick()) {
|
||||
if (clicked == clicker) {
|
||||
ItemStack clickedOn = e.getCurrentItem();
|
||||
if (clickedOn != null && FactionsPlugin.getInstance().itemList.contains(clickedOn.getType().toString())) {
|
||||
fPlayer.msg(TL.CHEST_ITEM_DENIED_TRANSFER, clickedOn.getType().toString());
|
||||
e.setCancelled(true);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -26,6 +26,7 @@ public class CmdAutoClaim extends FCommand {
|
||||
super();
|
||||
this.aliases.addAll(Aliases.claim_auto);
|
||||
|
||||
//this.requiredArgs.add("");
|
||||
this.optionalArgs.put("faction", "your");
|
||||
|
||||
this.requirements = new CommandRequirements.Builder(Permission.AUTOCLAIM)
|
||||
@@ -38,9 +39,13 @@ public class CmdAutoClaim extends FCommand {
|
||||
public void perform(CommandContext context) {
|
||||
Faction forFaction = context.argAsFaction(0, context.faction);
|
||||
|
||||
if (forFaction != context.fPlayer.getFaction() && !context.fPlayer.isAdminBypassing() && forFaction.getAccess(context.fPlayer, PermissableAction.TERRITORY) != Access.ALLOW) {
|
||||
context.msg(TL.COMMAND_CLAIM_DENIED);
|
||||
return;
|
||||
if (forFaction != context.fPlayer.getFaction()) {
|
||||
if (!context.fPlayer.isAdminBypassing()) {
|
||||
if (forFaction.getAccess(context.fPlayer, PermissableAction.TERRITORY) != Access.ALLOW) {
|
||||
context.msg(TL.COMMAND_CLAIM_DENIED);
|
||||
return;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (forFaction == null || forFaction == context.fPlayer.getAutoClaimFor()) {
|
||||
|
||||
@@ -41,9 +41,13 @@ public class CmdClaim extends FCommand {
|
||||
int radius = context.argAsInt(0, 1); // Default to 1
|
||||
final Faction forFaction = context.argAsFaction(1, context.faction); // Default to own
|
||||
|
||||
if (!context.fPlayer.isAdminBypassing() && !(context.fPlayer.getFaction().equals(forFaction) && context.fPlayer.getRole() == Role.LEADER) && forFaction.getAccess(context.fPlayer, PermissableAction.TERRITORY) != Access.ALLOW) {
|
||||
context.msg(TL.COMMAND_CLAIM_DENIED);
|
||||
return;
|
||||
if (!context.fPlayer.isAdminBypassing()) {
|
||||
if (!(context.fPlayer.getFaction().equals(forFaction) && context.fPlayer.getRole() == Role.LEADER)) {
|
||||
if (forFaction.getAccess(context.fPlayer, PermissableAction.TERRITORY) != Access.ALLOW) {
|
||||
context.msg(TL.COMMAND_CLAIM_DENIED);
|
||||
return;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -86,11 +90,12 @@ public class CmdClaim extends FCommand {
|
||||
return true;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void finish() {
|
||||
if (FactionsPlugin.cachedRadiusClaim && successfulClaims > 0) {
|
||||
context.fPlayer.getFaction().getFPlayersWhereOnline(true).forEach(f -> f.msg(TL.CLAIM_RADIUS_CLAIM, context.fPlayer.describeTo(f, true), String.valueOf(successfulClaims), context.fPlayer.getPlayer().getLocation().getChunk().getX(), context.fPlayer.getPlayer().getLocation().getChunk().getZ()));
|
||||
stop();
|
||||
if (FactionsPlugin.cachedRadiusClaim) {
|
||||
if (successfulClaims > 0) {
|
||||
context.fPlayer.getFaction().getFPlayersWhereOnline(true).forEach(f -> f.msg(TL.CLAIM_RADIUS_CLAIM, context.fPlayer.describeTo(f, true), String.valueOf(successfulClaims), context.fPlayer.getPlayer().getLocation().getChunk().getX(), context.fPlayer.getPlayer().getLocation().getChunk().getZ()));
|
||||
stop();
|
||||
}
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
@@ -68,10 +68,15 @@ public class CmdClaimLine extends FCommand {
|
||||
}
|
||||
|
||||
final Faction forFaction = context.argAsFaction(2, context.faction);
|
||||
Faction at = Board.getInstance().getFactionAt(new FLocation(context.fPlayer.getPlayer().getLocation()));
|
||||
|
||||
if (forFaction != context.fPlayer.getFaction() && !context.fPlayer.isAdminBypassing() && forFaction.getAccess(context.fPlayer, PermissableAction.TERRITORY) != Access.ALLOW) {
|
||||
if (forFaction != context.fPlayer.getFaction()) {
|
||||
if (!context.fPlayer.isAdminBypassing()) {
|
||||
if (forFaction.getAccess(context.fPlayer, PermissableAction.TERRITORY) != Access.ALLOW) {
|
||||
context.msg(TL.COMMAND_CLAIM_DENIED);
|
||||
return;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Location location = context.player.getLocation();
|
||||
@@ -80,11 +85,13 @@ public class CmdClaimLine extends FCommand {
|
||||
int claims = 0;
|
||||
|
||||
for (int i = 0; i < amount; i++) {
|
||||
if (!FactionsPlugin.cachedRadiusClaim || !context.fPlayer.attemptClaim(forFaction, context.player.getLocation(), false)) {
|
||||
if (FactionsPlugin.cachedRadiusClaim && context.fPlayer.attemptClaim(forFaction, context.player.getLocation(), false)) {
|
||||
claims++;
|
||||
} else {
|
||||
context.fPlayer.attemptClaim(forFaction, location, true);
|
||||
claims++;
|
||||
}
|
||||
claims++;
|
||||
location = location.add(blockFace.getModX() * 16D, 0, blockFace.getModZ() * 16D);
|
||||
location = location.add(blockFace.getModX() * 16, 0, blockFace.getModZ() * 16);
|
||||
FactionsPlugin.instance.logFactionEvent(forFaction, FLogType.CHUNK_CLAIMS, context.fPlayer.getName(), CC.GreenB + "CLAIMED", String.valueOf(i), new FLocation(context.player.getLocation()).formatXAndZ(","));
|
||||
}
|
||||
int cachedClaims = claims;
|
||||
|
||||
@@ -63,6 +63,11 @@ public class CmdUnclaim extends FCommand {
|
||||
boolean didUnClaim = unClaim(new FLocation(context.player), context);
|
||||
if (didUnClaim && !context.fPlayer.canFlyAtLocation())
|
||||
context.fPlayer.setFFlying(false, false);
|
||||
|
||||
for(FPlayer fPlayer : context.faction.getFPlayersWhereOnline(true)){
|
||||
if(!fPlayer.canFlyAtLocation())
|
||||
fPlayer.setFFlying(false, false);
|
||||
}
|
||||
} else {
|
||||
// radius claim
|
||||
if (!Permission.CLAIM_RADIUS.has(context.sender, false)) {
|
||||
@@ -83,10 +88,13 @@ public class CmdUnclaim extends FCommand {
|
||||
this.stop();
|
||||
return false;
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
};
|
||||
|
||||
boolean didUnClaim = unClaim(new FLocation(context.player), context);
|
||||
if (didUnClaim && !context.fPlayer.canFlyAtLocation())
|
||||
context.fPlayer.setFFlying(false, false);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -57,14 +57,8 @@ public class CmdUnclaimall extends FCommand {
|
||||
}
|
||||
if (Econ.shouldBeUsed()) {
|
||||
double refund = Econ.calculateTotalLandRefund(target.getLandRounded());
|
||||
if (Conf.bankEnabled && Conf.bankFactionPaysLandCosts) {
|
||||
if (!Econ.modifyMoney(target, refund, TL.COMMAND_UNCLAIMALL_TOUNCLAIM.toString(), TL.COMMAND_UNCLAIMALL_FORUNCLAIM.toString())) {
|
||||
return;
|
||||
}
|
||||
} else {
|
||||
if (!Econ.modifyMoney(target, refund, TL.COMMAND_UNCLAIMALL_TOUNCLAIM.toString(), TL.COMMAND_UNCLAIMALL_FORUNCLAIM.toString())) {
|
||||
return;
|
||||
}
|
||||
if (!Econ.modifyMoney(target, refund, TL.COMMAND_UNCLAIMALL_TOUNCLAIM.toString(), TL.COMMAND_UNCLAIMALL_FORUNCLAIM.toString())) {
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -8,6 +8,7 @@ import com.massivecraft.factions.cmd.CommandContext;
|
||||
import com.massivecraft.factions.cmd.CommandRequirements;
|
||||
import com.massivecraft.factions.cmd.FCommand;
|
||||
import com.massivecraft.factions.cmd.audit.FLogType;
|
||||
import com.massivecraft.factions.iface.EconomyParticipator;
|
||||
import com.massivecraft.factions.integration.Econ;
|
||||
import com.massivecraft.factions.struct.Permission;
|
||||
import com.massivecraft.factions.struct.Role;
|
||||
@@ -43,21 +44,23 @@ public class CmdMoneyWithdraw extends FCommand {
|
||||
return;
|
||||
}
|
||||
|
||||
Faction faction = context.argAsFaction(1, context.faction);
|
||||
EconomyParticipator faction = context.argAsFaction(1, context.faction);
|
||||
if (faction == null) {
|
||||
return;
|
||||
}
|
||||
|
||||
Access access = context.faction.getAccess(context.fPlayer, PermissableAction.WITHDRAW);
|
||||
if (context.fPlayer.getRole() != Role.LEADER && access == Access.DENY) {
|
||||
context.msg(TL.GENERIC_NOPERMISSION, "withdraw", "withdraw money from the bank");
|
||||
return;
|
||||
if (context.fPlayer.getRole() != Role.LEADER) {
|
||||
if (access == Access.DENY) {
|
||||
context.msg(TL.GENERIC_NOPERMISSION, "withdraw", "withdraw money from the bank");
|
||||
return;
|
||||
}
|
||||
}
|
||||
boolean success = Econ.transferMoney(context.fPlayer, faction, context.fPlayer, amount);
|
||||
|
||||
if (success && Conf.logMoneyTransactions) {
|
||||
FactionsPlugin.getInstance().log(ChatColor.stripColor(FactionsPlugin.getInstance().txt.parse(TL.COMMAND_MONEYWITHDRAW_WITHDRAW.toString(), context.fPlayer.getName(), Econ.moneyString(amount), faction.describeTo(null))));
|
||||
FactionsPlugin.instance.logFactionEvent(faction, FLogType.BANK_EDIT, context.fPlayer.getName(), CC.RedB + "WITHDREW", amount + "");
|
||||
FactionsPlugin.instance.logFactionEvent((Faction) faction, FLogType.BANK_EDIT, context.fPlayer.getName(), CC.RedB + "WITHDREW", amount + "");
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -37,25 +37,27 @@ public class CmdGrace extends FCommand {
|
||||
return;
|
||||
}
|
||||
|
||||
if (context.args.size() == 1 && context.sender.hasPermission(String.valueOf(Permission.GRACETOGGLE))) {
|
||||
if (context.argAsString(0).equalsIgnoreCase("on") || context.argAsString(0).equalsIgnoreCase("start")) {
|
||||
FactionsPlugin.getInstance().getTimerManager().graceTimer.setPaused(false);
|
||||
FactionsPlugin.getInstance().getTimerManager().graceTimer.setRemaining(TimeUnit.DAYS.toMillis(Conf.gracePeriodTimeDays), true);
|
||||
if (Conf.broadcastGraceToggles) {
|
||||
for (FPlayer follower : FPlayers.getInstance().getOnlinePlayers())
|
||||
follower.msg(TL.COMMAND_GRACE_ENABLED_FORMAT, String.valueOf(TimerManager.getRemaining(FactionsPlugin.getInstance().getTimerManager().graceTimer.getRemaining(), true)));
|
||||
if (context.args.size() == 1) {
|
||||
if (context.sender.hasPermission(String.valueOf(Permission.GRACETOGGLE))) {
|
||||
if (context.argAsString(0).equalsIgnoreCase("on") || context.argAsString(0).equalsIgnoreCase("start")) {
|
||||
FactionsPlugin.getInstance().getTimerManager().graceTimer.setPaused(false);
|
||||
FactionsPlugin.getInstance().getTimerManager().graceTimer.setRemaining(TimeUnit.DAYS.toMillis(Conf.gracePeriodTimeDays), true);
|
||||
if (Conf.broadcastGraceToggles) {
|
||||
for (FPlayer follower : FPlayers.getInstance().getOnlinePlayers())
|
||||
follower.msg(TL.COMMAND_GRACE_ENABLED_FORMAT, String.valueOf(TimerManager.getRemaining(FactionsPlugin.getInstance().getTimerManager().graceTimer.getRemaining(), true)));
|
||||
}
|
||||
return;
|
||||
}
|
||||
return;
|
||||
}
|
||||
|
||||
if (context.argAsString(0).equalsIgnoreCase("off") || context.argAsString(0).equalsIgnoreCase("stop")) {
|
||||
FactionsPlugin.getInstance().getTimerManager().graceTimer.setRemaining(TimeUnit.SECONDS.toMillis(0L), true);
|
||||
FactionsPlugin.getInstance().getTimerManager().graceTimer.setPaused(false);
|
||||
if (Conf.broadcastGraceToggles) {
|
||||
for (FPlayer follower : FPlayers.getInstance().getOnlinePlayers())
|
||||
follower.msg(TL.COMMAND_GRACE_DISABLED_FORMAT);
|
||||
if (context.argAsString(0).equalsIgnoreCase("off") || context.argAsString(0).equalsIgnoreCase("stop")) {
|
||||
FactionsPlugin.getInstance().getTimerManager().graceTimer.setRemaining(TimeUnit.SECONDS.toMillis(0L), true);
|
||||
FactionsPlugin.getInstance().getTimerManager().graceTimer.setPaused(false);
|
||||
if (Conf.broadcastGraceToggles) {
|
||||
for (FPlayer follower : FPlayers.getInstance().getOnlinePlayers())
|
||||
follower.msg(TL.COMMAND_GRACE_DISABLED_FORMAT);
|
||||
}
|
||||
return;
|
||||
}
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -15,8 +15,10 @@ public class LogoutHandler {
|
||||
|
||||
public static Map<String, LogoutHandler> factionDatas = new HashMap<>();
|
||||
private Map<UUID, Long> logoutCooldown = new HashMap<>();
|
||||
private String name;
|
||||
|
||||
public LogoutHandler(String name) {
|
||||
this.name = name;
|
||||
factionDatas.put(name, this);
|
||||
}
|
||||
|
||||
|
||||
@@ -112,14 +112,16 @@ public abstract class FRelationCommand extends FCommand {
|
||||
|
||||
private boolean hasMaxRelations(Faction us, Faction them, Relation targetRelation) {
|
||||
int max = FactionsPlugin.getInstance().getConfig().getInt("max-relations." + targetRelation.toString(), -1);
|
||||
if (FactionsPlugin.getInstance().getConfig().getBoolean("max-relations.enabled", false) && max != -1) {
|
||||
if (us.getRelationCount(targetRelation) >= max) {
|
||||
us.msg(TL.COMMAND_RELATIONS_EXCEEDS_ME, max, targetRelation.getPluralTranslation());
|
||||
return true;
|
||||
}
|
||||
if (them.getRelationCount(targetRelation) >= max) {
|
||||
them.msg(TL.COMMAND_RELATIONS_EXCEEDS_THEY, max, targetRelation.getPluralTranslation());
|
||||
return true;
|
||||
if (FactionsPlugin.getInstance().getConfig().getBoolean("max-relations.enabled", false)) {
|
||||
if (max != -1) {
|
||||
if (us.getRelationCount(targetRelation) >= max) {
|
||||
us.msg(TL.COMMAND_RELATIONS_EXCEEDS_ME, max, targetRelation.getPluralTranslation());
|
||||
return true;
|
||||
}
|
||||
if (them.getRelationCount(targetRelation) >= max) {
|
||||
them.msg(TL.COMMAND_RELATIONS_EXCEEDS_THEY, max, targetRelation.getPluralTranslation());
|
||||
return true;
|
||||
}
|
||||
}
|
||||
}
|
||||
return false;
|
||||
|
||||
@@ -74,7 +74,7 @@ public class FPromoteCommand extends FCommand {
|
||||
}
|
||||
}
|
||||
|
||||
if(target.isAlt()){
|
||||
if (target.isAlt()) {
|
||||
return;
|
||||
}
|
||||
|
||||
|
||||
@@ -0,0 +1,42 @@
|
||||
package com.massivecraft.factions.cmd.shields;
|
||||
|
||||
import com.massivecraft.factions.Conf;
|
||||
import com.massivecraft.factions.cmd.CommandContext;
|
||||
import com.massivecraft.factions.cmd.CommandRequirements;
|
||||
import com.massivecraft.factions.cmd.FCommand;
|
||||
import com.massivecraft.factions.cmd.shields.struct.frame.ShieldFrame;
|
||||
import com.massivecraft.factions.struct.Permission;
|
||||
import com.massivecraft.factions.zcore.fperms.PermissableAction;
|
||||
import com.massivecraft.factions.zcore.util.TL;
|
||||
|
||||
|
||||
/**
|
||||
* Factions - Developed by ImCarib.
|
||||
* All rights reserved 2020.
|
||||
* Creation Date: 5/23/2020
|
||||
*/
|
||||
|
||||
public class CmdShield extends FCommand {
|
||||
|
||||
public CmdShield() {
|
||||
this.aliases.add("shield");
|
||||
this.requirements = new CommandRequirements.Builder(Permission.SHIELD)
|
||||
.playerOnly()
|
||||
.memberOnly()
|
||||
.withAction(PermissableAction.SHIELD)
|
||||
.build();
|
||||
}
|
||||
|
||||
public void perform(CommandContext context) {
|
||||
if (!Conf.useFShieldSystem) {
|
||||
context.msg(TL.GENERIC_DISABLED);
|
||||
return;
|
||||
}
|
||||
|
||||
(new ShieldFrame()).build(context.fPlayer);
|
||||
}
|
||||
|
||||
public TL getUsageTranslation() {
|
||||
return TL.COMMAND_SHIELD_DESCRIPTION;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,41 @@
|
||||
package com.massivecraft.factions.cmd.shields.struct;
|
||||
|
||||
import com.massivecraft.factions.Conf;
|
||||
import com.massivecraft.factions.cmd.shields.struct.frame.ShieldFramePersistence;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
|
||||
/**
|
||||
* Factions - Developed by ImCarib.
|
||||
* All rights reserved 2020.
|
||||
* Creation Date: 5/23/2020
|
||||
*/
|
||||
|
||||
public class ShieldTCMP {
|
||||
private static ShieldTCMP instance;
|
||||
|
||||
private List<ShieldFramePersistence> frames = new ArrayList<>();
|
||||
|
||||
public ShieldTCMP() {
|
||||
instance = this;
|
||||
for (int x = 0; x <= 23; x++) {
|
||||
int end = (x + Conf.shieldTimeHours > 23) ? (x + Conf.shieldTimeHours - 24) : (x + Conf.shieldTimeHours);
|
||||
this.frames.add(new ShieldFramePersistence(x, end));
|
||||
}
|
||||
}
|
||||
|
||||
public static ShieldTCMP getInstance() {
|
||||
return instance;
|
||||
}
|
||||
|
||||
public ShieldFramePersistence getByStart(int start) {
|
||||
if (start > 23) return null;
|
||||
return this.frames.get(start);
|
||||
}
|
||||
|
||||
public List<ShieldFramePersistence> getFrames() {
|
||||
return this.frames;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,75 @@
|
||||
package com.massivecraft.factions.cmd.shields.struct.frame;
|
||||
|
||||
import com.cryptomorin.xseries.XMaterial;
|
||||
import com.github.stefvanschie.inventoryframework.Gui;
|
||||
import com.github.stefvanschie.inventoryframework.GuiItem;
|
||||
import com.github.stefvanschie.inventoryframework.pane.PaginatedPane;
|
||||
import com.massivecraft.factions.FPlayer;
|
||||
import com.massivecraft.factions.FactionsPlugin;
|
||||
import com.massivecraft.factions.cmd.shields.struct.tasks.ShieldManagement;
|
||||
import com.massivecraft.factions.util.ItemBuilder;
|
||||
import com.massivecraft.factions.util.Placeholder;
|
||||
import org.bukkit.inventory.ItemStack;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* Factions - Developed by ImCarib.
|
||||
* All rights reserved 2020.
|
||||
* Creation Date: 5/23/2020
|
||||
*/
|
||||
|
||||
public class ShieldConfirmationFrame {
|
||||
private Gui gui;
|
||||
|
||||
public ShieldConfirmationFrame() {
|
||||
this.gui = new Gui(FactionsPlugin.getInstance(),
|
||||
FactionsPlugin.getInstance().getConfig().getInt("Shields.Frame.Change.Size"),
|
||||
FactionsPlugin.getInstance().color(FactionsPlugin.getInstance().getConfig().getString("Shields.Frame.Change.Title")));
|
||||
}
|
||||
|
||||
public void build(FPlayer fme, ShieldFramePersistence frame) {
|
||||
PaginatedPane pane = new PaginatedPane(0, 0, 9, this.gui.getRows());
|
||||
List<GuiItem> GUIItems = new ArrayList<>();
|
||||
for (int x = 0; x <= this.gui.getRows() * 9 - 1; ) {
|
||||
GUIItems.add(new GuiItem(XMaterial.AIR.parseItem(), e -> e.setCancelled(true)));
|
||||
x++;
|
||||
}
|
||||
ItemStack[] assets = buildAssets(frame);
|
||||
GUIItems.set(4, new GuiItem(assets[0], e -> e.setCancelled(true)));
|
||||
GUIItems.set(11, new GuiItem(assets[1], e -> {
|
||||
e.setCancelled(true);
|
||||
fme.getFaction().setupShieldChange(frame);
|
||||
(new ShieldFrame()).build(fme);
|
||||
}));
|
||||
GUIItems.set(15, new GuiItem(assets[2], e -> {
|
||||
e.setCancelled(true);
|
||||
(new ShieldFrame()).build(fme);
|
||||
}));
|
||||
pane.populateWithGuiItems(GUIItems);
|
||||
this.gui.addPane(pane);
|
||||
this.gui.update();
|
||||
this.gui.show(fme.getPlayer());
|
||||
}
|
||||
|
||||
private ItemStack[] buildAssets(ShieldFramePersistence frame) {
|
||||
String path = "Shields.Frame.Change.Items.";
|
||||
return new ItemStack[]{new ItemBuilder(
|
||||
XMaterial.matchXMaterial(FactionsPlugin.getInstance().getConfig().getString(path + "Info.Type")).get().parseItem())
|
||||
.name(FactionsPlugin.getInstance().getConfig().getString(path + "Info.Display-Name"))
|
||||
.lore(FactionsPlugin.getInstance().replacePlaceholders(FactionsPlugin.getInstance().getConfig().getStringList(path + "Info.Lore"),
|
||||
new Placeholder("{start-time}", frame.getStartTime()),
|
||||
new Placeholder("{end-time}", frame.getEndTime()),
|
||||
new Placeholder("{current-time}", ShieldManagement.getCurrentTime()))).build(),
|
||||
|
||||
new ItemBuilder(
|
||||
XMaterial.matchXMaterial(FactionsPlugin.getInstance().getConfig().getString(path + "Accept.Type")).get().parseItem())
|
||||
.name(FactionsPlugin.getInstance().getConfig().getString(path + "Accept.Display-Name"))
|
||||
.lore(FactionsPlugin.getInstance().getConfig().getStringList(path + "Accept.Lore")).build(),
|
||||
|
||||
new ItemBuilder(XMaterial.matchXMaterial(FactionsPlugin.getInstance().getConfig().getString(path + "Deny.Type")).get().parseItem())
|
||||
.name(FactionsPlugin.getInstance().getConfig().getString(path + "Deny.Display-Name"))
|
||||
.lore(FactionsPlugin.getInstance().getConfig().getStringList(path + "Deny.Lore")).build()};
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,171 @@
|
||||
package com.massivecraft.factions.cmd.shields.struct.frame;
|
||||
|
||||
import com.cryptomorin.xseries.XMaterial;
|
||||
import com.github.stefvanschie.inventoryframework.Gui;
|
||||
import com.github.stefvanschie.inventoryframework.GuiItem;
|
||||
import com.github.stefvanschie.inventoryframework.pane.PaginatedPane;
|
||||
import com.massivecraft.factions.FPlayer;
|
||||
import com.massivecraft.factions.Faction;
|
||||
import com.massivecraft.factions.FactionsPlugin;
|
||||
import com.massivecraft.factions.cmd.shields.struct.ShieldTCMP;
|
||||
import com.massivecraft.factions.cmd.shields.struct.tasks.ShieldManagement;
|
||||
import com.massivecraft.factions.util.ItemBuilder;
|
||||
import com.massivecraft.factions.util.Placeholder;
|
||||
import org.bukkit.Material;
|
||||
import org.bukkit.configuration.ConfigurationSection;
|
||||
import org.bukkit.inventory.ItemStack;
|
||||
import org.bukkit.inventory.meta.ItemMeta;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
import java.util.Objects;
|
||||
|
||||
/**
|
||||
* Factions - Developed by ImCarib.
|
||||
* All rights reserved 2020.
|
||||
* Creation Date: 5/21/2020
|
||||
*/
|
||||
public class ShieldFrame {
|
||||
public Gui gui;
|
||||
|
||||
public ShieldFrame() {
|
||||
this.gui = new Gui(FactionsPlugin.getInstance(), 5, FactionsPlugin.getInstance().color(FactionsPlugin.getInstance().getConfig().getString("Shields.Frame.Main-Menu.Title")));
|
||||
}
|
||||
|
||||
public static String formatTimeMilliseconds(long milliseconds) {
|
||||
long seconds = milliseconds / 1000L;
|
||||
long minutes = seconds / 60L;
|
||||
seconds %= 60L;
|
||||
long hours = minutes / 60L;
|
||||
minutes %= 60L;
|
||||
long days = hours / 24L;
|
||||
hours %= 24L;
|
||||
long months = days / 31L;
|
||||
days %= 31L;
|
||||
if (months != 0L)
|
||||
return months + "M " + days + "d " + hours + "h ";
|
||||
if (days != 0L)
|
||||
return days + "d " + hours + "h " + minutes + "m ";
|
||||
if (hours != 0L)
|
||||
return hours + "h " + minutes + "m " + seconds + "s";
|
||||
if (minutes != 0L)
|
||||
return minutes + "m " + seconds + "s";
|
||||
if (seconds != 0L)
|
||||
return seconds + "s";
|
||||
return "";
|
||||
}
|
||||
|
||||
public void build(FPlayer fme) {
|
||||
PaginatedPane pane = new PaginatedPane(0, 0, 9, this.gui.getRows());
|
||||
List<GuiItem> GUIItems = new ArrayList<>();
|
||||
for (int x = 0; x <= this.gui.getRows() * 9 - 1; x++)
|
||||
GUIItems.add(new GuiItem(new ItemStack(Material.AIR), e -> e.setCancelled(true)));
|
||||
for (int slot : FactionsPlugin.getInstance().getConfig().getIntegerList("Shields.Frame.Frame-Type.Barrier.Slots")) {
|
||||
GUIItems.set(slot, new GuiItem(buildBarrierDummyItem(), e -> e.setCancelled(true)));
|
||||
}
|
||||
int x = 0;
|
||||
for (ShieldFramePersistence frame : ShieldTCMP.getInstance().getFrames()) {
|
||||
ItemStack item = buildShieldFrames(fme.getFaction(), frame);
|
||||
if (fme.getFaction().getShieldFrame() != null &&
|
||||
fme.getFaction().getShieldFrame().equals(frame)) {
|
||||
GUIItems.set(x, new GuiItem(item, e -> e.setCancelled(true)));
|
||||
x++;
|
||||
continue;
|
||||
}
|
||||
if (fme.getFaction().getNewFrame() != null &&
|
||||
fme.getFaction().getNewFrame().equals(frame)) {
|
||||
GUIItems.set(x, new GuiItem(item, e -> e.setCancelled(true)));
|
||||
x++;
|
||||
continue;
|
||||
}
|
||||
GUIItems.set(x, new GuiItem(item, e -> {
|
||||
e.setCancelled(true);
|
||||
(new ShieldConfirmationFrame()).build(fme, frame);
|
||||
}));
|
||||
x++;
|
||||
}
|
||||
ItemStack[] assets = getAssets(fme.getFaction());
|
||||
GUIItems.set(39, new GuiItem(assets[0], e -> e.setCancelled(true)));
|
||||
GUIItems.set(41, new GuiItem(assets[1], e -> e.setCancelled(true)));
|
||||
pane.populateWithGuiItems(GUIItems);
|
||||
this.gui.addPane(pane);
|
||||
this.gui.update();
|
||||
this.gui.show(fme.getPlayer());
|
||||
}
|
||||
|
||||
private ItemStack[] getAssets(Faction f) {
|
||||
ItemStack change;
|
||||
ConfigurationSection sec = FactionsPlugin.getInstance().getConfig().getConfigurationSection("Shields.Frame.Frame-Type.");
|
||||
assert sec != null;
|
||||
ItemStack info = (new ItemBuilder(XMaterial.matchXMaterial(sec.getString("Info-Item.Type")).get().parseItem()).name(sec.getString("Info-Item.Display-Name")).lore(sec.getStringList("Info-Item.Lore")).build());
|
||||
if (f.pendingShieldChange()) {
|
||||
change = (new ItemBuilder(XMaterial.matchXMaterial(sec.getString("Shield-Pending.Type")).get().parseItem()).name(sec.getString("Shield-Pending.Display-Name")).lore(FactionsPlugin.getInstance().replacePlaceholders(sec.getStringList("Shield-Pending.Lore"),
|
||||
new Placeholder("{remaining-time}", timeUntilChange(f)),
|
||||
new Placeholder("{new-start}", f.getNewFrame().getStartTime()),
|
||||
new Placeholder("{new-end}", f.getNewFrame().getEndTime())))).build();
|
||||
} else {
|
||||
change = (new ItemBuilder(XMaterial.matchXMaterial(sec.getString("NoShield-Pending.Type")).get().parseItem()).name(sec.getString("NoShield-Pending.Display-Name")).lore(sec.getStringList("NoShield-Pending.Lore")).build());
|
||||
}
|
||||
return new ItemStack[]{info, change};
|
||||
}
|
||||
|
||||
private String timeUntilChange(Faction f) {
|
||||
long time = f.getShieldChangeTime();
|
||||
time -= System.currentTimeMillis();
|
||||
return formatTimeMilliseconds(time);
|
||||
}
|
||||
|
||||
private ItemStack buildShieldFrames(Faction faction, ShieldFramePersistence frame) {
|
||||
ConfigurationSection config = FactionsPlugin.getInstance().getConfig().getConfigurationSection("Shields.Frame.Frame-Type");
|
||||
if (faction.getShieldFrame() != null && faction.getShieldFrame().equals(frame)) {
|
||||
ItemStack item = XMaterial.matchXMaterial(config.getString("Current-Frame.Type")).get().parseItem();
|
||||
ItemMeta meta = item.getItemMeta();
|
||||
meta.setLore(FactionsPlugin.getInstance().colorList(FactionsPlugin.getInstance().replacePlaceholders(config.getStringList("Current-Frame.Lore"),
|
||||
new Placeholder("{time-currently}", ShieldManagement.getCurrentTime()),
|
||||
new Placeholder("{remaining-time}", timeUntilChange(faction)),
|
||||
new Placeholder("{start-time}", frame.getStartTime()),
|
||||
new Placeholder("{end-time}", frame.getEndTime()))));
|
||||
meta.setDisplayName(FactionsPlugin.getInstance().color(config.getString("Current-Frame.Display-Name")));
|
||||
item.setItemMeta(meta);
|
||||
return item;
|
||||
}
|
||||
if (faction.getNewFrame() != null && faction.getNewFrame().equals(frame)) {
|
||||
ItemStack item = XMaterial.matchXMaterial(config.getString("New-Frame.Type")).get().parseItem();
|
||||
ItemMeta meta = item.getItemMeta();
|
||||
meta.setLore(FactionsPlugin.getInstance().colorList(FactionsPlugin.getInstance().replacePlaceholders(config.getStringList("New-Frame.Lore"),
|
||||
new Placeholder("{time-currently}", ShieldManagement.getCurrentTime()),
|
||||
new Placeholder("{remaining-time}", timeUntilChange(faction)),
|
||||
new Placeholder("{start-time}", frame.getStartTime()),
|
||||
new Placeholder("{end-time}", frame.getEndTime()))));
|
||||
meta.setDisplayName(FactionsPlugin.getInstance().color(config.getString("New-Frame.Display-Name")));
|
||||
item.setItemMeta(meta);
|
||||
return item;
|
||||
}
|
||||
ItemStack item = XMaterial.matchXMaterial(config.getString("Regular-Frame.Type")).get().parseItem();
|
||||
ItemMeta meta = item.getItemMeta();
|
||||
meta.setLore(FactionsPlugin.getInstance().colorList(FactionsPlugin.getInstance().replacePlaceholders(config.getStringList("Regular-Frame.Lore"),
|
||||
new Placeholder("{time-currently}", ShieldManagement.getCurrentTime()),
|
||||
new Placeholder("{remaining-time}", timeUntilChange(faction)),
|
||||
new Placeholder("{start-time}", frame.getStartTime()),
|
||||
new Placeholder("{end-time}", frame.getEndTime()))));
|
||||
meta.setDisplayName(FactionsPlugin.getInstance().color(config.getString("Regular-Frame.Display-Name")));
|
||||
item.setItemMeta(meta);
|
||||
return item;
|
||||
}
|
||||
|
||||
private ItemStack buildBarrierDummyItem() {
|
||||
ConfigurationSection config = FactionsPlugin.getInstance().getConfig().getConfigurationSection("Shields.Frame.Frame-Type.Barrier.");
|
||||
ItemStack item = XMaterial.matchXMaterial(config.getString("Type")).get().parseItem();
|
||||
ItemMeta meta = item.getItemMeta();
|
||||
if (meta != null) {
|
||||
List<String> lore = new ArrayList<>();
|
||||
for (String s : config.getStringList("Lore")) lore.add(FactionsPlugin.getInstance().color(s));
|
||||
meta.setLore(lore);
|
||||
meta.setDisplayName(FactionsPlugin.getInstance().color(Objects.requireNonNull(config.getString("Name"))));
|
||||
item.setItemMeta(meta);
|
||||
}
|
||||
return item;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -0,0 +1,54 @@
|
||||
package com.massivecraft.factions.cmd.shields.struct.frame;
|
||||
|
||||
import com.massivecraft.factions.cmd.shields.struct.tasks.ShieldManagement;
|
||||
|
||||
/**
|
||||
* Factions - Developed by ImCarib.
|
||||
* All rights reserved 2020.
|
||||
* Creation Date: 5/23/2020
|
||||
*/
|
||||
|
||||
public class ShieldFramePersistence {
|
||||
private int start;
|
||||
|
||||
private int end;
|
||||
|
||||
public ShieldFramePersistence(int start, int end) {
|
||||
this.start = start;
|
||||
this.end = end;
|
||||
}
|
||||
|
||||
public int getEndParsed() {
|
||||
return this.end;
|
||||
}
|
||||
|
||||
public int getStartParsed() {
|
||||
return this.start;
|
||||
}
|
||||
|
||||
public String getStartTime() {
|
||||
return toClockFormat(this.start);
|
||||
}
|
||||
|
||||
public String getEndTime() {
|
||||
return toClockFormat(this.end);
|
||||
}
|
||||
|
||||
public boolean isHourProtected(int hour) {
|
||||
if (this.end < this.start) return hour >= this.start;
|
||||
|
||||
return (hour >= this.start && hour < this.end);
|
||||
}
|
||||
|
||||
public boolean isProtectedCurrent() {
|
||||
return isHourProtected(ShieldManagement.getCurrentHour());
|
||||
}
|
||||
|
||||
public String toClockFormat(int x) {
|
||||
if (x == 0) return "12:00 am";
|
||||
if (x == 12) return "12:00 pm";
|
||||
if (x > 12) return (x - 12) + ":00 pm";
|
||||
return x + ":00 am";
|
||||
}
|
||||
}
|
||||
|
||||
@@ -0,0 +1,57 @@
|
||||
package com.massivecraft.factions.cmd.shields.struct.tasks;
|
||||
|
||||
import com.massivecraft.factions.Factions;
|
||||
import com.massivecraft.factions.FactionsPlugin;
|
||||
import com.massivecraft.factions.cmd.shields.struct.ShieldTCMP;
|
||||
import org.bukkit.Bukkit;
|
||||
import org.joda.time.DateTime;
|
||||
import org.joda.time.DateTimeZone;
|
||||
|
||||
/**
|
||||
* Factions - Developed by ImCarib.
|
||||
* All rights reserved 2020.
|
||||
* Creation Date: 5/23/2020
|
||||
*/
|
||||
|
||||
public class ShieldManagement implements Runnable {
|
||||
private static DateTimeZone zone = DateTimeZone.forID("Canada/Eastern");
|
||||
private int lastHour;
|
||||
|
||||
public ShieldManagement() {
|
||||
new ShieldTCMP();
|
||||
this.lastHour = 25;
|
||||
Bukkit.getScheduler().scheduleSyncRepeatingTask(FactionsPlugin.getInstance(), this, 20L, 1200L);
|
||||
}
|
||||
|
||||
public static int getCurrentHour() {
|
||||
DateTime time = new DateTime(zone);
|
||||
return time.getHourOfDay();
|
||||
}
|
||||
|
||||
public static String getCurrentTime() {
|
||||
DateTime time = new DateTime(zone);
|
||||
int hour = time.getHourOfDay();
|
||||
if (hour == 0) hour = 12;
|
||||
|
||||
if (hour > 12)
|
||||
return (hour - 12) + ":" + ((time.getMinuteOfHour() < 10) ? ("0" + time.getMinuteOfHour()) : Integer.valueOf(time.getMinuteOfHour())) + " pm";
|
||||
|
||||
return hour + ":" + ((time.getMinuteOfHour() < 10) ? ("0" + time.getMinuteOfHour()) : Integer.valueOf(time.getMinuteOfHour())) + " am";
|
||||
}
|
||||
|
||||
public void run() {
|
||||
DateTime time = new DateTime(zone);
|
||||
int hour = time.getHourOfDay();
|
||||
if (this.lastHour == 25 || this.lastHour != hour) {
|
||||
long now = System.currentTimeMillis();
|
||||
Factions.getInstance().getAllFactions().forEach(faction -> {
|
||||
if (faction.pendingShieldChange() && faction.getShieldChangeTime() < now) faction.applyShield();
|
||||
if (faction.getShieldFrame() != null) {
|
||||
if (faction.getShieldFrame().isHourProtected(hour)) faction.setProtected();
|
||||
} else {
|
||||
faction.setUnprotected();
|
||||
}
|
||||
});
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -1,5 +1,6 @@
|
||||
package com.massivecraft.factions.cmd.tnt;
|
||||
|
||||
import com.cryptomorin.xseries.XMaterial;
|
||||
import com.massivecraft.factions.FactionsPlugin;
|
||||
import com.massivecraft.factions.cmd.Aliases;
|
||||
import com.massivecraft.factions.cmd.CommandContext;
|
||||
@@ -7,7 +8,6 @@ import com.massivecraft.factions.cmd.CommandRequirements;
|
||||
import com.massivecraft.factions.cmd.FCommand;
|
||||
import com.massivecraft.factions.cmd.audit.FLogType;
|
||||
import com.massivecraft.factions.struct.Permission;
|
||||
import com.massivecraft.factions.util.XMaterial;
|
||||
import com.massivecraft.factions.zcore.fperms.PermissableAction;
|
||||
import com.massivecraft.factions.zcore.util.TL;
|
||||
import org.bukkit.Material;
|
||||
|
||||
@@ -26,8 +26,8 @@ import java.util.Random;
|
||||
* @author DroppingAnvil
|
||||
*/
|
||||
public class CmdWild extends FCommand implements WaitedTask {
|
||||
public static HashMap<Player, String> teleportRange = new HashMap<>();
|
||||
public static HashSet<Player> teleporting = new HashSet<>();
|
||||
public static HashMap<Player, String> teleportRange;
|
||||
public static HashSet<Player> teleporting;
|
||||
public static CmdWild instance;
|
||||
|
||||
public CmdWild() {
|
||||
@@ -37,7 +37,9 @@ public class CmdWild extends FCommand implements WaitedTask {
|
||||
this.requirements = new CommandRequirements.Builder(Permission.WILD)
|
||||
.playerOnly()
|
||||
.build();
|
||||
}
|
||||
teleporting = new HashSet<>();
|
||||
teleportRange = new HashMap<>();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void perform(CommandContext context) {
|
||||
|
||||
@@ -1,8 +1,8 @@
|
||||
package com.massivecraft.factions.cmd.wild;
|
||||
|
||||
import com.cryptomorin.xseries.XMaterial;
|
||||
import com.massivecraft.factions.FPlayer;
|
||||
import com.massivecraft.factions.FactionsPlugin;
|
||||
import com.massivecraft.factions.util.XMaterial;
|
||||
import com.massivecraft.factions.util.wait.WaitExecutor;
|
||||
import com.massivecraft.factions.util.wait.WaitTask;
|
||||
import com.massivecraft.factions.zcore.frame.FactionGUI;
|
||||
|
||||
@@ -60,17 +60,17 @@ public class CmdSetGuild extends FCommand {
|
||||
|
||||
if (guild == null) {
|
||||
context.msg(TL.SET_GUILD_ID_INVALID_ID);
|
||||
} else if (Factions.getInstance().getAllFactions().stream().anyMatch(f -> guildId.equals(f.getGuildId()))) {
|
||||
} else if (Factions.getInstance().getAllFactions().stream().anyMatch((f) -> guildId.equals(f.getGuildId()))) {
|
||||
context.msg(TL.SET_GUILD_ID_GUILD_ALREADY_LINKED);
|
||||
} else {
|
||||
context.msg(TL.SET_GUILD_ID_PMING_OWNER);
|
||||
User user = guild.getOwner().getUser();
|
||||
Guild finalGuild = guild;
|
||||
Guild finalGuild1 = guild;
|
||||
user.openPrivateChannel().queue(privateChannel -> privateChannel.sendMessage("Link guild **" + finalGuild1.getName() + "** to faction **" + ChatColor.stripColor(faction.getTag()) + "**?").queue(message -> {
|
||||
user.openPrivateChannel().queue((privateChannel) -> privateChannel.sendMessage("Link guild **" + finalGuild1.getName() + "** to faction **" + ChatColor.stripColor(faction.getTag()) + "**?").queue((message) -> {
|
||||
String checkMark = "âś…";
|
||||
message.addReaction(checkMark).queue();
|
||||
this.eventWaiter.waitForEvent(PrivateMessageReactionAddEvent.class, event -> event.getReactionEmote().getName().equals(checkMark) && event.getUser().getId().equals(user.getId()) && event.getMessageId().equals(message.getId()), event -> {
|
||||
this.eventWaiter.waitForEvent(PrivateMessageReactionAddEvent.class, (event) -> event.getReactionEmote().getName().equals(checkMark) && event.getUser().getId().equals(user.getId()) && event.getMessageId().equals(message.getId()), (event) -> {
|
||||
faction.setGuildId(context.argAsString(0));
|
||||
context.msg(TL.SET_GUILD_ID_SUCCESS);
|
||||
privateChannel.sendMessage("Successfully linked **" + finalGuild.getName() + " & " + ChatColor.stripColor(faction.getTag()) + "**").queue();
|
||||
@@ -78,7 +78,9 @@ public class CmdSetGuild extends FCommand {
|
||||
privateChannel.sendMessage(TL.SET_GUILD_ID_TIMED_OUT_DISCORD.toString()).queue();
|
||||
context.msg(TL.SET_GUILD_ID_TIMED_OUT_MINECRAFT);
|
||||
});
|
||||
}, t -> context.msg(TL.SET_GUILD_ID_UNABLE_TO_MESSAGE_GUILD_OWNER)), t -> context.msg(TL.SET_GUILD_ID_UNABLE_TO_MESSAGE_GUILD_OWNER));
|
||||
}, (t) -> {
|
||||
context.msg(TL.SET_GUILD_ID_UNABLE_TO_MESSAGE_GUILD_OWNER);
|
||||
}), (t) -> context.msg(TL.SET_GUILD_ID_UNABLE_TO_MESSAGE_GUILD_OWNER));
|
||||
}
|
||||
} else {
|
||||
faction.setGuildId(null);
|
||||
|
||||
@@ -31,7 +31,7 @@ public class Discord {
|
||||
public static Boolean confUseDiscord;
|
||||
public static String botToken;
|
||||
public static String mainGuildID;
|
||||
public static boolean useDiscord;
|
||||
public static Boolean useDiscord;
|
||||
public static java.awt.Color roleColor;
|
||||
public static Guild mainGuild;
|
||||
public static Role leader;
|
||||
@@ -53,11 +53,13 @@ public class Discord {
|
||||
* Called to reload variables and if needed start JDA
|
||||
*/
|
||||
public static void setupDiscord() {
|
||||
if (jda == null && startBot()) {
|
||||
varSetup();
|
||||
jda.addEventListener(new FactionChatHandler(plugin));
|
||||
jda.addEventListener(new DiscordListener(plugin));
|
||||
return;
|
||||
if (jda == null) {
|
||||
if (startBot()) {
|
||||
varSetup();
|
||||
jda.addEventListener(new FactionChatHandler(plugin));
|
||||
jda.addEventListener(new DiscordListener(plugin));
|
||||
return;
|
||||
}
|
||||
}
|
||||
varSetup();
|
||||
}
|
||||
@@ -82,7 +84,6 @@ public class Discord {
|
||||
confUseDiscord = Conf.useDiscordSystem;
|
||||
botToken = Conf.discordBotToken;
|
||||
if (jda != null && Conf.leaderRoles || Conf.factionDiscordTags) {
|
||||
assert jda != null;
|
||||
mainGuild = jda.getGuildById(Conf.mainGuildID);
|
||||
} else {
|
||||
mainGuild = null;
|
||||
@@ -150,9 +151,12 @@ public class Discord {
|
||||
* @param s String target Faction tag
|
||||
* @return
|
||||
*/
|
||||
public static boolean doesFactionRoleExist(String s) {
|
||||
String sb = Conf.factionRolePrefix + s + Conf.factionRoleSuffix;
|
||||
return getRoleFromName(sb) != null;
|
||||
public static Boolean doesFactionRoleExist(String s) {
|
||||
StringBuilder sb = new StringBuilder();
|
||||
sb.append(Conf.factionRolePrefix);
|
||||
sb.append(s);
|
||||
sb.append(Conf.factionRoleSuffix);
|
||||
return getRoleFromName(sb.toString()) != null;
|
||||
}
|
||||
|
||||
public static Role getRoleFromName(String s) {
|
||||
@@ -185,8 +189,7 @@ public class Discord {
|
||||
sb.append(Conf.factionRoleSuffix);
|
||||
if (!doesFactionRoleExist(sb.toString())) {
|
||||
try {
|
||||
Role newRole;
|
||||
newRole = mainGuild.getController().createRole()
|
||||
Role newRole = mainGuild.getController().createRole()
|
||||
.setName(sb.toString())
|
||||
.setColor(roleColor)
|
||||
.setPermissions(Permission.EMPTY_PERMISSIONS)
|
||||
@@ -208,7 +211,11 @@ public class Discord {
|
||||
* @return Name of would be Role
|
||||
*/
|
||||
public static String getFactionRoleName(String tag) {
|
||||
return Conf.factionRolePrefix + tag + Conf.factionRoleSuffix;
|
||||
StringBuilder sb = new StringBuilder();
|
||||
sb.append(Conf.factionRolePrefix);
|
||||
sb.append(tag);
|
||||
sb.append(Conf.factionRoleSuffix);
|
||||
return sb.toString();
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -217,7 +224,7 @@ public class Discord {
|
||||
* @param u User
|
||||
* @return Boolean
|
||||
*/
|
||||
public static boolean isInMainGuild(User u) {
|
||||
public static Boolean isInMainGuild(User u) {
|
||||
if (mainGuild == null) return false;
|
||||
return mainGuild.getMember(u) == null ? Boolean.FALSE : Boolean.TRUE;
|
||||
}
|
||||
@@ -245,12 +252,10 @@ public class Discord {
|
||||
if (fp.discordSetup() && isInMainGuild(fp.discordUser())) {
|
||||
try {
|
||||
Member m = mainGuild.getMember(fp.discordUser());
|
||||
boolean discordTags = Conf.factionDiscordTags;
|
||||
boolean factionRoles = Conf.factionRoles;
|
||||
if (discordTags) {
|
||||
if (Conf.factionDiscordTags) {
|
||||
mainGuild.getController().setNickname(m, Discord.getNicknameString(fp)).queue();
|
||||
}
|
||||
if (factionRoles) {
|
||||
if (Conf.factionRoles) {
|
||||
mainGuild.getController().removeSingleRoleFromMember(m, Objects.requireNonNull(getRoleFromName(oldTag))).queue();
|
||||
mainGuild.getController().addSingleRoleToMember(m, Objects.requireNonNull(createFactionRole(f.getTag()))).queue();
|
||||
}
|
||||
|
||||
@@ -37,7 +37,7 @@ public class DiscordListener extends ListenerAdapter {
|
||||
this.decimalFormat = new DecimalFormat("$#,###.##");
|
||||
this.plugin = plugin;
|
||||
int minute = 3600;
|
||||
plugin.getServer().getScheduler().runTaskTimerAsynchronously(plugin, DiscordListener::saveGuilds, minute * 15L, minute * 15L);
|
||||
plugin.getServer().getScheduler().runTaskTimerAsynchronously(plugin, DiscordListener::saveGuilds, minute * 15, minute * 15);
|
||||
}
|
||||
|
||||
private static JSONGuilds loadGuilds() {
|
||||
@@ -64,7 +64,6 @@ public class DiscordListener extends ListenerAdapter {
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onPrivateMessageReceived(PrivateMessageReceivedEvent e) {
|
||||
Integer i;
|
||||
if (e.getAuthor().isBot()) return;
|
||||
@@ -86,7 +85,6 @@ public class DiscordListener extends ListenerAdapter {
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onGuildMessageReceived(GuildMessageReceivedEvent event) {
|
||||
try {
|
||||
if (event.getMessage().isWebhookMessage() || event.getAuthor().isBot()) return;
|
||||
|
||||
@@ -109,7 +109,7 @@ public class DiscordSetupAttempt {
|
||||
sb.append(inProcessTime);
|
||||
//Just a separator for looks
|
||||
sb.append(" ");
|
||||
String s;
|
||||
String s = "";
|
||||
switch (timeIndex) {
|
||||
case 0:
|
||||
s = "MS";
|
||||
@@ -129,8 +129,6 @@ public class DiscordSetupAttempt {
|
||||
case 5:
|
||||
s = "Years";
|
||||
break;
|
||||
default:
|
||||
throw new IllegalStateException("Unexpected value: " + timeIndex);
|
||||
}
|
||||
sb.append(s);
|
||||
sb.append(" ago");
|
||||
|
||||
@@ -35,7 +35,7 @@ public class FactionChatHandler extends ListenerAdapter {
|
||||
this.plugin = plugin;
|
||||
}
|
||||
|
||||
public static void sendMessage(Faction faction, UUID uuid, String username, String message) {
|
||||
public static void sendMessage(FactionsPlugin plugin, Faction faction, UUID uuid, String username, String message) {
|
||||
String factionsChatChannelId = faction.getFactionChatChannelId();
|
||||
String messageWithMentions = null;
|
||||
if (factionsChatChannelId == null || factionsChatChannelId.isEmpty()) return;
|
||||
|
||||
@@ -48,7 +48,9 @@ public class Econ {
|
||||
}
|
||||
econ = rsp.getProvider();
|
||||
FactionsPlugin.getInstance().log("Economy integration through Vault plugin successful.");
|
||||
if (!Conf.econEnabled) FactionsPlugin.getInstance().log("NOTE: Economy is disabled. You can enable it with the command: f config econEnabled true");
|
||||
if (!Conf.econEnabled)
|
||||
FactionsPlugin.getInstance().log("NOTE: Economy is disabled. You can enable it with the command: f config econEnabled true");
|
||||
//FactionsPlugin.getInstance().cmdBase.cmdHelp.updateHelp();
|
||||
}
|
||||
|
||||
public static boolean shouldBeUsed() {
|
||||
@@ -102,6 +104,7 @@ public class Econ {
|
||||
// Factions can be controlled by members that are moderators... or any member if any member can withdraw.
|
||||
if (you instanceof Faction && fI == fYou && (Conf.bankMembersCanWithdraw || (i instanceof FPlayer && ((FPlayer) i).getRole().value >= Role.MODERATOR.value)))
|
||||
return true;
|
||||
// Otherwise you may not!;,,;
|
||||
i.msg(TL.ECON_CANTCONTROLMONEY, i.describeTo(i, true), you.describeTo(i));
|
||||
return false;
|
||||
}
|
||||
@@ -235,7 +238,7 @@ public class Econ {
|
||||
acc = Bukkit.getOfflinePlayer(UUID.fromString(ep.getAccountId()));
|
||||
if (acc.getName() == null) return false;
|
||||
} else acc = Bukkit.getOfflinePlayer(ep.getAccountId());
|
||||
String you = ep.describeTo(ep, true);
|
||||
String You = ep.describeTo(ep, true);
|
||||
|
||||
if (delta == 0) return true;
|
||||
else if (delta > 0) {
|
||||
@@ -245,12 +248,12 @@ public class Econ {
|
||||
if (er.transactionSuccess()) {
|
||||
modifyUniverseMoney(-delta);
|
||||
if (forDoingThis != null && !forDoingThis.isEmpty())
|
||||
ep.msg(TL.COMMAND_MONEY_GAINED, you, moneyString(delta), forDoingThis);
|
||||
ep.msg(TL.COMMAND_MONEY_GAINED, You, moneyString(delta), forDoingThis);
|
||||
return true;
|
||||
} else {
|
||||
// transfer to account failed
|
||||
if (forDoingThis != null && !forDoingThis.isEmpty())
|
||||
ep.msg(TL.ECON_DEPOSITFAILED, you, moneyString(delta), forDoingThis);
|
||||
ep.msg(TL.ECON_DEPOSITFAILED, You, moneyString(delta), forDoingThis);
|
||||
return false;
|
||||
}
|
||||
} else {
|
||||
@@ -260,12 +263,12 @@ public class Econ {
|
||||
// There is enough money to pay
|
||||
modifyUniverseMoney(-delta);
|
||||
if (forDoingThis != null && !forDoingThis.isEmpty())
|
||||
ep.msg(TL.ECON_MONEYLOST, you, moneyString(-delta), forDoingThis);
|
||||
ep.msg(TL.ECON_MONEYLOST, You, moneyString(-delta), forDoingThis);
|
||||
return true;
|
||||
} else {
|
||||
// There was not enough money to pay
|
||||
if (toDoThis != null && !toDoThis.isEmpty())
|
||||
ep.msg(TL.ECON_CANTAFFORD, you, moneyString(-delta), toDoThis);
|
||||
ep.msg(TL.ECON_CANTAFFORD, You, moneyString(-delta), toDoThis);
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -159,6 +159,7 @@ public class Worldguard {
|
||||
FactionsPlugin.getInstance().log("We failed to load Vector Classes from WorldGuard! Support will be removed!");
|
||||
FactionsPlugin.getInstance().log("WorldGuard 7.0.0 support is currently in BETA. Please be careful!");
|
||||
regionContainer = null;
|
||||
return;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -12,6 +12,8 @@ import org.dynmap.DynmapAPI;
|
||||
import org.dynmap.markers.*;
|
||||
import org.dynmap.utils.TileFlags;
|
||||
|
||||
import java.awt.*;
|
||||
import java.util.List;
|
||||
import java.util.*;
|
||||
import java.util.Map.Entry;
|
||||
|
||||
@@ -26,17 +28,20 @@ public class EngineDynmap {
|
||||
// CONSTANTS
|
||||
// -------------------------------------------- //
|
||||
|
||||
public static final int BLOCKS_PER_CHUNK = 16;
|
||||
public final static int BLOCKS_PER_CHUNK = 16;
|
||||
|
||||
public static final String DYNMAP_INTEGRATION = "\u00A7dDynmap Integration: \u00A7e";
|
||||
public final static String DYNMAP_INTEGRATION = "\u00A7dDynmap Integration: \u00A7e";
|
||||
|
||||
public static final String FACTIONS = "factions";
|
||||
public static final String FACTIONS_ = FACTIONS + "_";
|
||||
public static final String FACTIONS_MARKERSET = FACTIONS_ + "markerset";
|
||||
public static final String FACTIONS_HOME = FACTIONS_ + "home";
|
||||
public static final String FACTIONS_HOME_ = FACTIONS_HOME + "_";
|
||||
public static final String FACTIONS_PLAYERSET = FACTIONS_ + "playerset";
|
||||
public static final String FACTIONS_PLAYERSET_ = FACTIONS_PLAYERSET + "_";
|
||||
public final static String FACTIONS = "factions";
|
||||
public final static String FACTIONS_ = FACTIONS + "_";
|
||||
|
||||
public final static String FACTIONS_MARKERSET = FACTIONS_ + "markerset";
|
||||
|
||||
public final static String FACTIONS_HOME = FACTIONS_ + "home";
|
||||
public final static String FACTIONS_HOME_ = FACTIONS_HOME + "_";
|
||||
|
||||
public final static String FACTIONS_PLAYERSET = FACTIONS_ + "playerset";
|
||||
public final static String FACTIONS_PLAYERSET_ = FACTIONS_PLAYERSET + "_";
|
||||
|
||||
// -------------------------------------------- //
|
||||
// INSTANCE & CONSTRUCT
|
||||
@@ -47,6 +52,8 @@ public class EngineDynmap {
|
||||
public MarkerAPI markerApi;
|
||||
public MarkerSet markerset;
|
||||
|
||||
List<List<Point>> polyLine = new ArrayList<List<Point>>();
|
||||
|
||||
private EngineDynmap() {
|
||||
}
|
||||
|
||||
@@ -77,9 +84,7 @@ public class EngineDynmap {
|
||||
for (int i = 0; i < string.length(); i++) {
|
||||
char c = string.charAt(i);
|
||||
if (c > 127 || c == '"' || c == '<' || c == '>' || c == '&') {
|
||||
out.append("&#")
|
||||
.append((int) c)
|
||||
.append(';');
|
||||
out.append("&#").append((int) c).append(';');
|
||||
} else {
|
||||
out.append(c);
|
||||
}
|
||||
@@ -118,10 +123,12 @@ public class EngineDynmap {
|
||||
}
|
||||
|
||||
// Shedule non thread safe sync at the end!
|
||||
Bukkit.getScheduler().scheduleSyncRepeatingTask(FactionsPlugin.getInstance(), () -> {
|
||||
Bukkit.getScheduler().scheduleSyncRepeatingTask(FactionsPlugin.getInstance(), () ->
|
||||
{
|
||||
|
||||
final Map<String, TempMarker> homes = createHomes();
|
||||
final Map<String, TempAreaMarker> areas = createAreas();
|
||||
final Map<String, TempPolyLineMarker> polys = createPolys(areas);
|
||||
final Map<String, Set<String>> playerSets = createPlayersets();
|
||||
|
||||
if (!updateCore()) {
|
||||
@@ -135,6 +142,7 @@ public class EngineDynmap {
|
||||
|
||||
updateHomes(homes);
|
||||
updateAreas(areas);
|
||||
updatePolys(polys);
|
||||
updatePlayersets(playerSets);
|
||||
}, 100L, 100L);
|
||||
}
|
||||
@@ -236,6 +244,7 @@ public class EngineDynmap {
|
||||
// NOTE: That way what is left at the end will be outdated markers to remove.
|
||||
Marker marker = markers.remove(markerId);
|
||||
if (marker == null) {
|
||||
marker = temp.create(this.markerApi, this.markerset, markerId);
|
||||
marker = temp.create(this.markerApi, this.markerset, markerId);
|
||||
if (marker == null) {
|
||||
EngineDynmap.severe("Could not get/create the home marker " + markerId);
|
||||
@@ -257,6 +266,29 @@ public class EngineDynmap {
|
||||
// -------------------------------------------- //
|
||||
|
||||
// Thread Safe: YES
|
||||
|
||||
public Map<String, TempPolyLineMarker> createPolys(Map<String, TempAreaMarker> areas) {
|
||||
Map<String, TempPolyLineMarker> ret = new HashMap<String, TempPolyLineMarker>();
|
||||
for (Entry<String, TempAreaMarker> entry : areas.entrySet()) {
|
||||
String markerID = entry.getKey();
|
||||
TempAreaMarker area = entry.getValue();
|
||||
|
||||
int counter = 0;
|
||||
for (List<Point> points : area.getPolyLine()) {
|
||||
markerID = markerID + "_poly_" + counter;
|
||||
TempPolyLineMarker tempPoly = new TempPolyLineMarker();
|
||||
tempPoly.polyLine = points;
|
||||
tempPoly.lineColor = area.lineColor;
|
||||
tempPoly.lineOpacity = area.lineOpacity;
|
||||
tempPoly.lineWeight = area.lineWeight;
|
||||
tempPoly.world = area.world;
|
||||
ret.put(markerID, tempPoly);
|
||||
counter++;
|
||||
}
|
||||
}
|
||||
return ret;
|
||||
}
|
||||
|
||||
public Map<String, TempAreaMarker> createAreas() {
|
||||
Map<String, Map<Faction, Set<FLocation>>> worldFactionChunks = createWorldFactionChunks();
|
||||
return createAreas(worldFactionChunks);
|
||||
@@ -274,13 +306,13 @@ public class EngineDynmap {
|
||||
String world = entry.getKey().getWorldName();
|
||||
Faction chunkOwner = Factions.getInstance().getFactionById(entry.getValue());
|
||||
|
||||
Map<Faction, Set<FLocation>> factionChunks = worldFactionChunks.computeIfAbsent(world, s -> null);
|
||||
Map<Faction, Set<FLocation>> factionChunks = worldFactionChunks.get(world);
|
||||
if (factionChunks == null) {
|
||||
factionChunks = new HashMap<>();
|
||||
worldFactionChunks.put(world, factionChunks);
|
||||
}
|
||||
|
||||
Set<FLocation> factionTerritory = factionChunks.computeIfAbsent(chunkOwner, s -> null);
|
||||
Set<FLocation> factionTerritory = factionChunks.get(chunkOwner);
|
||||
if (factionTerritory == null) {
|
||||
factionTerritory = new HashSet<>();
|
||||
factionChunks.put(chunkOwner, factionTerritory);
|
||||
@@ -348,12 +380,11 @@ public class EngineDynmap {
|
||||
|
||||
// Loop through until we don't find more areas
|
||||
while (allChunks != null) {
|
||||
|
||||
TileFlags ourChunkFlags = null;
|
||||
LinkedList<FLocation> ourChunks = null;
|
||||
LinkedList<FLocation> newChunks = null;
|
||||
|
||||
int minimumX = Integer.MAX_VALUE;
|
||||
int minimumZ = Integer.MAX_VALUE;
|
||||
for (FLocation chunk : allChunks) {
|
||||
int chunkX = (int) chunk.getX();
|
||||
int chunkZ = (int) chunk.getZ();
|
||||
@@ -364,18 +395,10 @@ public class EngineDynmap {
|
||||
ourChunks = new LinkedList<>();
|
||||
floodFillTarget(allChunkFlags, ourChunkFlags, chunkX, chunkZ); // Copy shape
|
||||
ourChunks.add(chunk); // Add it to our chunk list
|
||||
minimumX = chunkX;
|
||||
minimumZ = chunkZ;
|
||||
}
|
||||
// If shape found, and we're in it, add to our node list
|
||||
else if (ourChunkFlags != null && ourChunkFlags.getFlag(chunkX, chunkZ)) {
|
||||
ourChunks.add(chunk);
|
||||
if (chunkX < minimumX) {
|
||||
minimumX = chunkX;
|
||||
minimumZ = chunkZ;
|
||||
} else if (chunkX == minimumX && chunkZ < minimumZ) {
|
||||
minimumZ = chunkZ;
|
||||
}
|
||||
}
|
||||
// Else, keep it in the list for the next polygon
|
||||
else {
|
||||
@@ -388,86 +411,129 @@ public class EngineDynmap {
|
||||
|
||||
// Replace list (null if no more to process)
|
||||
allChunks = newChunks;
|
||||
|
||||
if (ourChunkFlags == null) {
|
||||
continue;
|
||||
}
|
||||
List<TempLine> outputLines = new ArrayList<TempLine>();
|
||||
Map<TempLine, Integer> lines = new HashMap<TempLine, Integer>();
|
||||
|
||||
// Trace outline of blocks - start from minx, minz going to x+
|
||||
int initialX = minimumX;
|
||||
int initialZ = minimumZ;
|
||||
int currentX = minimumX;
|
||||
int currentZ = minimumZ;
|
||||
Direction direction = Direction.XPLUS;
|
||||
ArrayList<int[]> linelist = new ArrayList<>();
|
||||
linelist.add(new int[]{initialX, initialZ}); // Add start point
|
||||
while ((currentX != initialX) || (currentZ != initialZ) || (direction != Direction.ZMINUS)) {
|
||||
switch (direction) {
|
||||
case XPLUS: // Segment in X+ direction
|
||||
if (!ourChunkFlags.getFlag(currentX + 1, currentZ)) { // Right turn?
|
||||
linelist.add(new int[]{currentX + 1, currentZ}); // Finish line
|
||||
direction = Direction.ZPLUS; // Change direction
|
||||
} else if (!ourChunkFlags.getFlag(currentX + 1, currentZ - 1)) { // Straight?
|
||||
currentX++;
|
||||
} else { // Left turn
|
||||
linelist.add(new int[]{currentX + 1, currentZ}); // Finish line
|
||||
direction = Direction.ZMINUS;
|
||||
currentX++;
|
||||
currentZ--;
|
||||
}
|
||||
break;
|
||||
case ZPLUS: // Segment in Z+ direction
|
||||
if (!ourChunkFlags.getFlag(currentX, currentZ + 1)) { // Right turn?
|
||||
linelist.add(new int[]{currentX + 1, currentZ + 1}); // Finish line
|
||||
direction = Direction.XMINUS; // Change direction
|
||||
} else if (!ourChunkFlags.getFlag(currentX + 1, currentZ + 1)) { // Straight?
|
||||
currentZ++;
|
||||
} else { // Left turn
|
||||
linelist.add(new int[]{currentX + 1, currentZ + 1}); // Finish line
|
||||
direction = Direction.XPLUS;
|
||||
currentX++;
|
||||
currentZ++;
|
||||
}
|
||||
break;
|
||||
case XMINUS: // Segment in X- direction
|
||||
if (!ourChunkFlags.getFlag(currentX - 1, currentZ)) { // Right turn?
|
||||
linelist.add(new int[]{currentX, currentZ + 1}); // Finish line
|
||||
direction = Direction.ZMINUS; // Change direction
|
||||
} else if (!ourChunkFlags.getFlag(currentX - 1, currentZ + 1)) { // Straight?
|
||||
currentX--;
|
||||
} else { // Left turn
|
||||
linelist.add(new int[]{currentX, currentZ + 1}); // Finish line
|
||||
direction = Direction.ZPLUS;
|
||||
currentX--;
|
||||
currentZ++;
|
||||
}
|
||||
break;
|
||||
case ZMINUS: // Segment in Z- direction
|
||||
if (!ourChunkFlags.getFlag(currentX, currentZ - 1)) { // Right turn?
|
||||
linelist.add(new int[]{currentX, currentZ}); // Finish line
|
||||
direction = Direction.XPLUS; // Change direction
|
||||
} else if (!ourChunkFlags.getFlag(currentX - 1, currentZ - 1)) { // Straight?
|
||||
currentZ--;
|
||||
} else { // Left turn
|
||||
linelist.add(new int[]{currentX, currentZ}); // Finish line
|
||||
direction = Direction.XMINUS;
|
||||
currentX--;
|
||||
currentZ--;
|
||||
}
|
||||
break;
|
||||
if (ourChunks == null) {
|
||||
continue;
|
||||
}
|
||||
|
||||
for (FLocation loc : ourChunks) {
|
||||
int x = loc.getChunk().getX();
|
||||
int z = loc.getChunk().getZ();
|
||||
|
||||
TempLine line = new TempLine(new Point(x * 16, z * 16), new Point(x * 16 + 16, z * 16));
|
||||
if (lines.containsKey(line)) {
|
||||
lines.put(line, lines.get(line) + 1);
|
||||
} else {
|
||||
lines.put(line, 1);
|
||||
}
|
||||
|
||||
line = new TempLine(new Point(x * 16 + 16, z * 16), new Point(x * 16 + 16, z * 16 + 16));
|
||||
if (lines.containsKey(line)) {
|
||||
lines.put(line, lines.get(line) + 1);
|
||||
} else {
|
||||
lines.put(line, 1);
|
||||
}
|
||||
|
||||
line = new TempLine(new Point(x * 16 + 16, z * 16 + 16), new Point(x * 16, z * 16 + 16));
|
||||
if (lines.containsKey(line)) {
|
||||
lines.put(line, lines.get(line) + 1);
|
||||
} else {
|
||||
lines.put(line, 1);
|
||||
}
|
||||
|
||||
line = new TempLine(new Point(x * 16, z * 16 + 16), new Point(x * 16, z * 16));
|
||||
if (lines.containsKey(line)) {
|
||||
lines.put(line, lines.get(line) + 1);
|
||||
} else {
|
||||
lines.put(line, 1);
|
||||
}
|
||||
}
|
||||
|
||||
int sz = linelist.size();
|
||||
double[] x = new double[sz];
|
||||
double[] z = new double[sz];
|
||||
for (int i = 0; i < sz; i++) {
|
||||
int[] line = linelist.get(i);
|
||||
x[i] = (double) line[0] * (double) BLOCKS_PER_CHUNK;
|
||||
z[i] = (double) line[1] * (double) BLOCKS_PER_CHUNK;
|
||||
Iterator<Entry<TempLine, Integer>> iterator = lines.entrySet().iterator();
|
||||
|
||||
List<TempLine> lineList = new ArrayList<TempLine>();
|
||||
lineList.addAll(lines.keySet());
|
||||
|
||||
while (iterator.hasNext()) {
|
||||
Entry<TempLine, Integer> entry = iterator.next();
|
||||
if (entry.getValue() > 1) {
|
||||
lineList.remove(entry.getKey());
|
||||
}
|
||||
}
|
||||
|
||||
// Find the leftmost MCRWPoint
|
||||
|
||||
TempLine l = null;
|
||||
for (Iterator<TempLine> it = lineList.iterator(); it.hasNext(); ) {
|
||||
TempLine tl = it.next();
|
||||
if (l == null || tl.getP1().x < l.getP1().x)
|
||||
l = tl;
|
||||
}
|
||||
|
||||
for (Iterator<TempLine> it = lineList.iterator(); it.hasNext(); ) {
|
||||
TempLine tl = it.next();
|
||||
if (tl.getP2().x < l.getP2().x)
|
||||
l = tl;
|
||||
}
|
||||
|
||||
outputLines.add(l);
|
||||
lineList.remove(l);
|
||||
while (lineList.size() > 0) {
|
||||
// MCRWPoint targetp = new MCRWPoint((int) lastLine.x1, (int) lastLine.y1);
|
||||
// MCRWPointWLines.get(targetp);
|
||||
|
||||
TempLine nextLine = null;
|
||||
for (Iterator<TempLine> it = lineList.iterator(); it.hasNext(); ) {
|
||||
TempLine line = it.next();
|
||||
if (l.getP2().x == line.getP1().x && l.getP2().y == line.getP1().y) {
|
||||
|
||||
nextLine = line;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
if (nextLine != null) {
|
||||
outputLines.add(nextLine);
|
||||
lineList.remove(nextLine);
|
||||
l = nextLine;
|
||||
} else {
|
||||
outputLines.get(outputLines.size() - 1).addAdditionLines(CamScan1(lineList));
|
||||
break;
|
||||
}
|
||||
|
||||
}
|
||||
List<Point> outputPoints = new ArrayList<Point>();
|
||||
|
||||
List<Point> polyPoints = new ArrayList<Point>();
|
||||
|
||||
for (int i = 0; i < outputLines.size(); i++) {
|
||||
Point p = new Point(outputLines.get(i).getP1().x, outputLines.get(i).getP1().y);
|
||||
outputPoints.add(p);
|
||||
polyPoints.add(p);
|
||||
if (outputLines.get(i).getConnectedLines().size() > 0) {
|
||||
|
||||
outputPoints.addAll(addRecursivePoints(new Point(outputLines.get(i).getP1().x, outputLines.get(i).getP1().y), outputLines.get(i)));
|
||||
}
|
||||
p = new Point(outputLines.get(i).getP2().x, outputLines.get(i).getP2().y);
|
||||
outputPoints.add(p);
|
||||
polyPoints.add(p);
|
||||
}
|
||||
polyLine.add(polyPoints);
|
||||
|
||||
// Build information for specific area
|
||||
double[] x = new double[outputPoints.size()];
|
||||
double[] z = new double[outputPoints.size()];
|
||||
|
||||
for (int i = 0; i < outputPoints.size(); i++) {
|
||||
x[i] = outputPoints.get(i).x;
|
||||
z[i] = outputPoints.get(i).y;
|
||||
}
|
||||
|
||||
String markerId = FACTIONS_ + world + "__" + faction.getId() + "__" + markerIndex;
|
||||
|
||||
TempAreaMarker temp = new TempAreaMarker();
|
||||
@@ -485,8 +551,10 @@ public class EngineDynmap {
|
||||
temp.fillOpacity = style.getFillOpacity();
|
||||
|
||||
temp.boost = style.getBoost();
|
||||
temp.setPolyLine(polyLine);
|
||||
|
||||
ret.put(markerId, temp);
|
||||
polyLine.clear();
|
||||
|
||||
markerIndex++;
|
||||
}
|
||||
@@ -494,10 +562,114 @@ public class EngineDynmap {
|
||||
return ret;
|
||||
}
|
||||
|
||||
public List<Point> addRecursivePoints(Point returnPoint, TempLine line) {
|
||||
List<Point> ret = new ArrayList<Point>();
|
||||
boolean shouldReturn = false;
|
||||
List<TempLine> connectedLines = line.getConnectedLines();
|
||||
List<Point> polyPoints = new ArrayList<Point>();
|
||||
for (TempLine line2 : connectedLines) {
|
||||
Point p = new Point(line2.getP1().x, line2.getP1().y);
|
||||
ret.add(p);
|
||||
polyPoints.add(p);
|
||||
shouldReturn = true;
|
||||
if (line2.getConnectedLines().size() > 0) {
|
||||
ret.addAll(addRecursivePoints(new Point(line2.getP1().x, line2.getP1().y), line2));
|
||||
}
|
||||
p = new Point(line2.getP2().x, line2.getP2().y);
|
||||
ret.add(p);
|
||||
polyPoints.add(p);
|
||||
|
||||
}
|
||||
if (shouldReturn) {
|
||||
ret.add(returnPoint);
|
||||
}
|
||||
polyLine.add(polyPoints);
|
||||
return ret;
|
||||
}
|
||||
|
||||
private List<TempLine> CamScan1(List<TempLine> lineList) {
|
||||
List<TempLine> ret = new ArrayList<TempLine>();
|
||||
|
||||
// Find the leftmost MCRWPoint
|
||||
|
||||
TempLine l = null;
|
||||
for (Iterator<TempLine> it = lineList.iterator(); it.hasNext(); ) {
|
||||
|
||||
TempLine tl = it.next();
|
||||
if (l == null || tl.getP1().x < l.getP1().x)
|
||||
l = tl;
|
||||
}
|
||||
|
||||
for (Iterator<TempLine> it = lineList.iterator(); it.hasNext(); ) {
|
||||
TempLine tl = it.next();
|
||||
if (tl.getP2().x < l.getP2().x)
|
||||
l = tl;
|
||||
}
|
||||
|
||||
ret.add(l);
|
||||
lineList.remove(l);
|
||||
while (lineList.size() > 0) {
|
||||
// MCRWPoint targetp = new MCRWPoint((int) lastLine.x1, (int) lastLine.y1);
|
||||
// MCRWPointWLines.get(targetp);
|
||||
|
||||
TempLine thisChunkLine = null;
|
||||
for (Iterator<TempLine> it = lineList.iterator(); it.hasNext(); ) {
|
||||
TempLine line = it.next();
|
||||
if (l.getP2().x == line.getP1().x && l.getP2().y == line.getP1().y) {
|
||||
|
||||
thisChunkLine = line;
|
||||
}
|
||||
|
||||
}
|
||||
if (thisChunkLine != null) {
|
||||
ret.add(thisChunkLine);
|
||||
lineList.remove(thisChunkLine);
|
||||
l = thisChunkLine;
|
||||
} else {
|
||||
// break;
|
||||
ret.get(ret.size() - 1).addAdditionLines(CamScan1(lineList));
|
||||
}
|
||||
|
||||
}
|
||||
return ret;
|
||||
}
|
||||
|
||||
// -------------------------------------------- //
|
||||
// UTIL & SHARED
|
||||
// -------------------------------------------- //
|
||||
|
||||
public void updatePolys(Map<String, TempPolyLineMarker> polys) {
|
||||
// Map Current
|
||||
Map<String, PolyLineMarker> markers = new HashMap<>();
|
||||
for (PolyLineMarker marker : this.markerset.getPolyLineMarkers()) {
|
||||
markers.put(marker.getMarkerID(), marker);
|
||||
}
|
||||
|
||||
// Loop New
|
||||
for (Entry<String, TempPolyLineMarker> entry : polys.entrySet()) {
|
||||
String markerId = entry.getKey();
|
||||
TempPolyLineMarker temp = entry.getValue();
|
||||
|
||||
// Get Creative
|
||||
// NOTE: I remove from the map created just in the beginning of this method.
|
||||
// NOTE: That way what is left at the end will be outdated markers to remove.
|
||||
PolyLineMarker marker = markers.remove(markerId);
|
||||
if (marker == null) {
|
||||
marker = temp.create(this.markerset, markerId);
|
||||
if (marker == null) {
|
||||
severe("Could not get/create the area marker " + markerId);
|
||||
}
|
||||
} else {
|
||||
temp.update(marker);
|
||||
}
|
||||
}
|
||||
|
||||
// Only old/outdated should now be left. Delete them.
|
||||
for (PolyLineMarker marker : markers.values()) {
|
||||
marker.deleteMarker();
|
||||
}
|
||||
}
|
||||
|
||||
// Thread Safe: NO
|
||||
public void updateAreas(Map<String, TempAreaMarker> areas) {
|
||||
// Map Current
|
||||
@@ -655,7 +827,6 @@ public class EngineDynmap {
|
||||
money = String.format("%.2f", Econ.getBalance(faction.getAccountId()));
|
||||
ret = ret.replace("%money%", money);
|
||||
|
||||
|
||||
// Players
|
||||
Set<FPlayer> playersList = faction.getFPlayers();
|
||||
String playersCount = String.valueOf(playersList.size());
|
||||
@@ -672,7 +843,6 @@ public class EngineDynmap {
|
||||
String playersModeratorsCount = String.valueOf(playersModeratorsList.size());
|
||||
String playersModerators = getHtmlPlayerString(playersModeratorsList);
|
||||
|
||||
|
||||
ArrayList<FPlayer> playersNormalsList = faction.getFPlayersWhereRole(Role.NORMAL);
|
||||
String playersNormalsCount = String.valueOf(playersNormalsList.size());
|
||||
String playersNormals = getHtmlPlayerString(playersNormalsList);
|
||||
@@ -732,7 +902,8 @@ public class EngineDynmap {
|
||||
}
|
||||
|
||||
// Find all contiguous blocks, set in target and clear in source
|
||||
private void floodFillTarget(TileFlags source, TileFlags destination, int x, int y) {
|
||||
private int floodFillTarget(TileFlags source, TileFlags destination, int x, int y) {
|
||||
int cnt = 0;
|
||||
ArrayDeque<int[]> stack = new ArrayDeque<>();
|
||||
stack.push(new int[]{x, y});
|
||||
|
||||
@@ -743,6 +914,7 @@ public class EngineDynmap {
|
||||
if (source.getFlag(x, y)) { // Set in src
|
||||
source.setFlag(x, y, false); // Clear source
|
||||
destination.setFlag(x, y, true); // Set in destination
|
||||
cnt++;
|
||||
if (source.getFlag(x + 1, y)) {
|
||||
stack.push(new int[]{x + 1, y});
|
||||
}
|
||||
@@ -757,6 +929,7 @@ public class EngineDynmap {
|
||||
}
|
||||
}
|
||||
}
|
||||
return cnt;
|
||||
}
|
||||
|
||||
enum Direction {
|
||||
|
||||
@@ -3,6 +3,10 @@ package com.massivecraft.factions.integration.dynmap;
|
||||
import org.dynmap.markers.AreaMarker;
|
||||
import org.dynmap.markers.MarkerSet;
|
||||
|
||||
import java.awt.*;
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
public class TempAreaMarker {
|
||||
|
||||
/**
|
||||
@@ -18,15 +22,13 @@ public class TempAreaMarker {
|
||||
public double[] x;
|
||||
public double[] z;
|
||||
public String description;
|
||||
|
||||
public int lineColor;
|
||||
public double lineOpacity;
|
||||
public int lineWeight;
|
||||
|
||||
public int fillColor;
|
||||
public double fillOpacity;
|
||||
|
||||
public boolean boost;
|
||||
private List<List<Point>> polyLine = new ArrayList<List<Point>>();
|
||||
|
||||
// -------------------------------------------- //
|
||||
// CREATE
|
||||
@@ -54,6 +56,15 @@ public class TempAreaMarker {
|
||||
return true;
|
||||
}
|
||||
|
||||
public List<List<Point>> getPolyLine() {
|
||||
return polyLine;
|
||||
}
|
||||
|
||||
public void setPolyLine(List<List<Point>> points) {
|
||||
polyLine.clear();
|
||||
polyLine.addAll(points);
|
||||
}
|
||||
|
||||
// -------------------------------------------- //
|
||||
// UPDATE
|
||||
// -------------------------------------------- //
|
||||
@@ -61,16 +72,17 @@ public class TempAreaMarker {
|
||||
public AreaMarker create(MarkerSet markerset, String markerId) {
|
||||
AreaMarker ret = markerset.createAreaMarker(markerId, this.label, false, this.world, this.x, this.z, false // not persistent
|
||||
);
|
||||
|
||||
if (ret == null) {
|
||||
return null;
|
||||
}
|
||||
|
||||
int counter = 0;
|
||||
|
||||
// Description
|
||||
ret.setDescription(this.description);
|
||||
|
||||
// Line Style
|
||||
ret.setLineStyle(this.lineWeight, this.lineOpacity, this.lineColor);
|
||||
ret.setLineStyle(0, 0, 0);
|
||||
|
||||
// Fill Style
|
||||
ret.setFillStyle(this.fillOpacity, this.fillColor);
|
||||
@@ -80,7 +92,6 @@ public class TempAreaMarker {
|
||||
|
||||
return ret;
|
||||
}
|
||||
|
||||
// -------------------------------------------- //
|
||||
// UTIL
|
||||
// -------------------------------------------- //
|
||||
@@ -95,18 +106,15 @@ public class TempAreaMarker {
|
||||
if (!marker.getLabel().equals(this.label)) {
|
||||
marker.setLabel(this.label);
|
||||
}
|
||||
|
||||
// Description
|
||||
if (!marker.getDescription().equals(this.description)) {
|
||||
marker.setDescription(this.description);
|
||||
}
|
||||
|
||||
// Line Style
|
||||
if (marker.getLineWeight() != this.lineWeight ||
|
||||
marker.getLineOpacity() != this.lineOpacity ||
|
||||
marker.getLineColor() != this.lineColor) {
|
||||
marker.setLineStyle(this.lineWeight, this.lineOpacity, this.lineColor);
|
||||
}
|
||||
// // 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)) {
|
||||
|
||||
@@ -0,0 +1,49 @@
|
||||
package com.massivecraft.factions.integration.dynmap;
|
||||
|
||||
import java.awt.*;
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
public class TempLine {
|
||||
private Point p1;
|
||||
private Point p2;
|
||||
private List<TempLine> connectedLines = new ArrayList<TempLine>();
|
||||
|
||||
TempLine(Point p1, Point p2) {
|
||||
this.p1 = p1;
|
||||
this.p2 = p2;
|
||||
}
|
||||
|
||||
public Point getP1() {
|
||||
return p1;
|
||||
}
|
||||
|
||||
public Point getP2() {
|
||||
return p2;
|
||||
}
|
||||
|
||||
public void addAdditionLines(List<TempLine> connectedLines) {
|
||||
this.connectedLines = connectedLines;
|
||||
}
|
||||
|
||||
public List<TempLine> getConnectedLines() {
|
||||
return connectedLines;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean equals(Object o) {
|
||||
TempLine line = (TempLine) o;
|
||||
if (line.p1.x == this.p1.x && line.p2.x == this.p2.x && line.p1.y == this.p1.y && line.p2.y == this.p2.y) {
|
||||
return true;
|
||||
}
|
||||
return line.p1.x == this.p2.x && line.p2.x == this.p1.x && line.p1.y == this.p2.y && line.p2.y == this.p1.y;
|
||||
}
|
||||
|
||||
@Override
|
||||
public int hashCode() {
|
||||
String test = "" + (p1.x + p2.x);
|
||||
test += " " + (p1.y + p2.y);
|
||||
return test.hashCode();
|
||||
}
|
||||
|
||||
}
|
||||
@@ -15,7 +15,7 @@ public class TempMarkerSet {
|
||||
public boolean hideByDefault;
|
||||
|
||||
public MarkerSet create(MarkerAPI markerApi, String id) {
|
||||
MarkerSet ret = markerApi.createMarkerSet(id, this.label, null, false); // ("null, false" at the end means "all icons allowed, not persistent")
|
||||
MarkerSet ret = markerApi.createMarkerSet(id, this.label, null, false); // ("null, false" at the end means "all icons allowed, not perisistent")
|
||||
|
||||
if (ret == null) {
|
||||
return null;
|
||||
@@ -41,8 +41,10 @@ public class TempMarkerSet {
|
||||
markerset.setMarkerSetLabel(this.label);
|
||||
}
|
||||
|
||||
if (this.minimumZoom > 0 && markerset.getMinZoom() != this.minimumZoom) {
|
||||
if (this.minimumZoom > 0) {
|
||||
if (markerset.getMinZoom() != this.minimumZoom) {
|
||||
markerset.setMinZoom(this.minimumZoom);
|
||||
}
|
||||
}
|
||||
|
||||
if (markerset.getLayerPriority() != this.priority) {
|
||||
|
||||
@@ -0,0 +1,99 @@
|
||||
package com.massivecraft.factions.integration.dynmap;
|
||||
|
||||
import org.dynmap.markers.MarkerSet;
|
||||
import org.dynmap.markers.PolyLineMarker;
|
||||
|
||||
import java.awt.*;
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
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);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
@@ -1,5 +1,6 @@
|
||||
package com.massivecraft.factions.listeners;
|
||||
|
||||
import com.cryptomorin.xseries.XMaterial;
|
||||
import com.massivecraft.factions.*;
|
||||
import com.massivecraft.factions.cmd.audit.FLogManager;
|
||||
import com.massivecraft.factions.cmd.audit.LogTimer;
|
||||
@@ -8,7 +9,6 @@ import com.massivecraft.factions.struct.Permission;
|
||||
import com.massivecraft.factions.struct.Relation;
|
||||
import com.massivecraft.factions.struct.Role;
|
||||
import com.massivecraft.factions.util.ItemBuilder;
|
||||
import com.massivecraft.factions.util.XMaterial;
|
||||
import com.massivecraft.factions.zcore.fperms.Access;
|
||||
import com.massivecraft.factions.zcore.fperms.PermissableAction;
|
||||
import com.massivecraft.factions.zcore.util.TL;
|
||||
@@ -47,8 +47,6 @@ public class FactionsBlockListener implements Listener {
|
||||
public static HashMap<String, Location> bannerLocations = new HashMap<>();
|
||||
private HashMap<String, Boolean> bannerCooldownMap = new HashMap<>();
|
||||
private long placeTimer = TimeUnit.SECONDS.toMillis(15L);
|
||||
private static final String varFac = "{faction}";
|
||||
private static final String varAction = "{action}";
|
||||
|
||||
|
||||
public static boolean playerCanBuildDestroyBlock(Player player, Location location, String action, boolean justCheck) {
|
||||
@@ -63,8 +61,9 @@ public class FactionsBlockListener implements Listener {
|
||||
|
||||
if (otherFaction.isWilderness()) {
|
||||
if (Conf.worldGuardBuildPriority && Worldguard.getInstance().playerCanBuild(player, location)) return true;
|
||||
if (location.getWorld() != null && !Conf.wildernessDenyBuild || Conf.worldsNoWildernessProtection.contains(location.getWorld().getName())) {
|
||||
return true;
|
||||
if (location.getWorld() != null) {
|
||||
if (!Conf.wildernessDenyBuild || Conf.worldsNoWildernessProtection.contains(location.getWorld().getName()))
|
||||
return true;
|
||||
}
|
||||
if (!justCheck) me.msg(TL.ACTION_DENIED_WILDERNESS, action);
|
||||
return false;
|
||||
@@ -94,27 +93,24 @@ public class FactionsBlockListener implements Listener {
|
||||
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())))
|
||||
return true;
|
||||
else {
|
||||
String replace = TL.ACTIONS_NOPERMISSIONPAIN.toString().replace(varAction, action.toString());
|
||||
if (landOwned && !myFaction.getOwnerListString(loc).contains(player.getName())) {
|
||||
me.msg(TL.ACTIONS_OWNEDTERRITORYDENY.toString().replace("{owners}", myFaction.getOwnerListString(loc)));
|
||||
if (shouldHurt) {
|
||||
player.damage(Conf.actionDeniedPainAmount);
|
||||
me.msg(replace.replace(varFac, Board.getInstance().getFactionAt(loc).getTag(myFaction)));
|
||||
}
|
||||
return false;
|
||||
} else if (!landOwned && access == Access.DENY) { // If land is not owned but access is set to DENY anyway
|
||||
if (shouldHurt) {
|
||||
player.damage(Conf.actionDeniedPainAmount);
|
||||
if ((Board.getInstance().getFactionAt(loc).getTag(myFaction)) != null)
|
||||
me.msg(replace.replace(varFac, Board.getInstance().getFactionAt(loc).getTag(myFaction)));
|
||||
}
|
||||
if (myFaction.getTag(me.getFaction()) != null && action != null)
|
||||
me.msg(TL.ACTIONS_NOPERMISSION.toString().replace(varFac, myFaction.getTag(me.getFaction())).replace(varAction, action.toString()));
|
||||
return false;
|
||||
} else if (access == Access.ALLOW) return true;
|
||||
}
|
||||
me.msg(TL.ACTIONS_NOPERMISSION.toString().replace(varFac, myFaction.getTag(me.getFaction())).replace(varAction, action.toString()));
|
||||
else if (landOwned && !myFaction.getOwnerListString(loc).contains(player.getName())) {
|
||||
me.msg(TL.ACTIONS_OWNEDTERRITORYDENY.toString().replace("{owners}", myFaction.getOwnerListString(loc)));
|
||||
if (shouldHurt) {
|
||||
player.damage(Conf.actionDeniedPainAmount);
|
||||
me.msg(TL.ACTIONS_NOPERMISSIONPAIN.toString().replace("{action}", action.toString()).replace("{faction}", Board.getInstance().getFactionAt(loc).getTag(myFaction)));
|
||||
}
|
||||
return false;
|
||||
} else if (!landOwned && access == Access.DENY) { // If land is not owned but access is set to DENY anyway
|
||||
if (shouldHurt) {
|
||||
player.damage(Conf.actionDeniedPainAmount);
|
||||
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)));
|
||||
}
|
||||
if (myFaction.getTag(me.getFaction()) != null && action != null)
|
||||
me.msg(TL.ACTIONS_NOPERMISSION.toString().replace("{faction}", myFaction.getTag(me.getFaction())).replace("{action}", action.toString()));
|
||||
return false;
|
||||
} else if (access == Access.ALLOW) return true;
|
||||
me.msg(TL.ACTIONS_NOPERMISSION.toString().replace("{faction}", myFaction.getTag(me.getFaction())).replace("{action}", action.toString()));
|
||||
return false;
|
||||
}
|
||||
|
||||
@@ -122,10 +118,10 @@ public class FactionsBlockListener implements Listener {
|
||||
if (Conf.ownedAreasEnabled && target.doesLocationHaveOwnersSet(location) && !target.playerHasOwnershipRights(me, location)) {
|
||||
// If pain should be applied
|
||||
if (pain && Conf.ownedAreaPainBuild)
|
||||
me.msg(TL.ACTIONS_OWNEDTERRITORYPAINDENY.toString().replace(varAction, action.toString()).replace(varFac, target.getOwnerListString(location)));
|
||||
me.msg(TL.ACTIONS_OWNEDTERRITORYPAINDENY.toString().replace("{action}", action.toString()).replace("{faction}", target.getOwnerListString(location)));
|
||||
if (Conf.ownedAreaDenyBuild && pain) return false;
|
||||
else if (Conf.ownedAreaDenyBuild) {
|
||||
me.msg(TL.ACTIONS_NOPERMISSION.toString().replace(varFac, target.getTag(me.getFaction())).replace(varAction, action.toString()));
|
||||
me.msg(TL.ACTIONS_NOPERMISSION.toString().replace("{faction}", target.getTag(me.getFaction())).replace("{action}", action.toString()));
|
||||
return false;
|
||||
}
|
||||
}
|
||||
@@ -172,9 +168,11 @@ public class FactionsBlockListener implements Listener {
|
||||
return;
|
||||
}
|
||||
|
||||
if (isSpawner && Conf.spawnerLock) {
|
||||
event.setCancelled(true);
|
||||
event.getPlayer().sendMessage(FactionsPlugin.getInstance().color(TL.COMMAND_SPAWNER_LOCK_CANNOT_PLACE.toString()));
|
||||
if (isSpawner) {
|
||||
if (Conf.spawnerLock) {
|
||||
event.setCancelled(true);
|
||||
event.getPlayer().sendMessage(FactionsPlugin.getInstance().color(TL.COMMAND_SPAWNER_LOCK_CANNOT_PLACE.toString()));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -182,21 +180,23 @@ public class FactionsBlockListener implements Listener {
|
||||
public void onBlockFromTo(BlockFromToEvent event) {
|
||||
if (!Conf.handleExploitLiquidFlow) return;
|
||||
|
||||
if (event.getBlock().isLiquid() && event.getToBlock().isEmpty()) {
|
||||
Faction from = Board.getInstance().getFactionAt(new FLocation(event.getBlock()));
|
||||
Faction to = Board.getInstance().getFactionAt(new FLocation(event.getToBlock()));
|
||||
if (from == to) return;
|
||||
// from faction != to faction
|
||||
if (to.isSystemFaction()) {
|
||||
event.setCancelled(true);
|
||||
return;
|
||||
}
|
||||
|
||||
if (to.isNormal()) {
|
||||
if (from.isNormal() && from.getRelationTo(to).isAlly()) {
|
||||
if (event.getBlock().isLiquid()) {
|
||||
if (event.getToBlock().isEmpty()) {
|
||||
Faction from = Board.getInstance().getFactionAt(new FLocation(event.getBlock()));
|
||||
Faction to = Board.getInstance().getFactionAt(new FLocation(event.getToBlock()));
|
||||
if (from == to) return;
|
||||
// from faction != to faction
|
||||
if (to.isSystemFaction()) {
|
||||
event.setCancelled(true);
|
||||
return;
|
||||
}
|
||||
event.setCancelled(true);
|
||||
|
||||
if (to.isNormal()) {
|
||||
if (from.isNormal() && from.getRelationTo(to).isAlly()) {
|
||||
return;
|
||||
}
|
||||
event.setCancelled(true);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -217,7 +217,7 @@ public class FactionsBlockListener implements Listener {
|
||||
Block targetBlock = event.getBlock().getRelative(event.getDirection(), event.getLength() + 1);
|
||||
|
||||
// if potentially pushing into air/water/lava in another territory, we need to check it out
|
||||
if ((targetBlock.isEmpty() || targetBlock.isLiquid()) && canPistonMoveBlock(pistonFaction, targetBlock.getLocation()))
|
||||
if ((targetBlock.isEmpty() || targetBlock.isLiquid()) && !canPistonMoveBlock(pistonFaction, targetBlock.getLocation()))
|
||||
event.setCancelled(true);
|
||||
}
|
||||
|
||||
@@ -286,10 +286,12 @@ public class FactionsBlockListener implements Listener {
|
||||
continue;
|
||||
}
|
||||
|
||||
if (blockLoc.getBlock().getType() == XMaterial.CHEST.parseMaterial() && factionAt.getVault().equals(blockLoc)) {
|
||||
e.setCancelled(true);
|
||||
fme.msg(TL.COMMAND_VAULT_NO_HOPPER);
|
||||
return;
|
||||
if (blockLoc.getBlock().getType() == XMaterial.CHEST.parseMaterial()) {
|
||||
if (factionAt.getVault().equals(blockLoc)) {
|
||||
e.setCancelled(true);
|
||||
fme.msg(TL.COMMAND_VAULT_NO_HOPPER);
|
||||
return;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -314,7 +316,7 @@ public class FactionsBlockListener implements Listener {
|
||||
// if potentially retracted block is just air/water/lava, no worries
|
||||
if (targetLoc.getBlock().isEmpty() || targetLoc.getBlock().isLiquid()) return;
|
||||
Faction pistonFaction = Board.getInstance().getFactionAt(new FLocation(event.getBlock()));
|
||||
if (canPistonMoveBlock(pistonFaction, targetLoc)) event.setCancelled(true);
|
||||
if (!canPistonMoveBlock(pistonFaction, targetLoc)) event.setCancelled(true);
|
||||
}
|
||||
|
||||
@EventHandler
|
||||
@@ -324,9 +326,11 @@ public class FactionsBlockListener implements Listener {
|
||||
return;
|
||||
}
|
||||
|
||||
if (bannerLocations.containsValue(e.getBlock().getLocation()) && e.getBlock().getType().name().contains("BANNER")) {
|
||||
e.setCancelled(true);
|
||||
fme.msg(TL.BANNER_CANNOT_BREAK);
|
||||
if (bannerLocations.containsValue(e.getBlock().getLocation())) {
|
||||
if (e.getBlock().getType().name().contains("BANNER")) {
|
||||
e.setCancelled(true);
|
||||
fme.msg(TL.BANNER_CANNOT_BREAK);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -445,15 +449,15 @@ public class FactionsBlockListener implements Listener {
|
||||
private boolean canPistonMoveBlock(Faction pistonFaction, Location target) {
|
||||
Faction otherFaction = Board.getInstance().getFactionAt(new FLocation(target));
|
||||
|
||||
if (pistonFaction == otherFaction) return false;
|
||||
if (pistonFaction == otherFaction) return true;
|
||||
|
||||
if (otherFaction.isWilderness())
|
||||
return Conf.wildernessDenyBuild && !Conf.worldsNoWildernessProtection.contains(target.getWorld().getName());
|
||||
else if (otherFaction.isSafeZone()) return Conf.safeZoneDenyBuild;
|
||||
else if (otherFaction.isWarZone()) return Conf.warZoneDenyBuild;
|
||||
return !Conf.wildernessDenyBuild || Conf.worldsNoWildernessProtection.contains(target.getWorld().getName());
|
||||
else if (otherFaction.isSafeZone()) return !Conf.safeZoneDenyBuild;
|
||||
else if (otherFaction.isWarZone()) return !Conf.warZoneDenyBuild;
|
||||
|
||||
Relation rel = pistonFaction.getRelationTo(otherFaction);
|
||||
return rel.confDenyBuild(otherFaction.hasPlayersOnline());
|
||||
return !rel.confDenyBuild(otherFaction.hasPlayersOnline());
|
||||
}
|
||||
|
||||
@EventHandler(priority = EventPriority.NORMAL, ignoreCancelled = true)
|
||||
@@ -501,12 +505,15 @@ public class FactionsBlockListener implements Listener {
|
||||
|
||||
|
||||
@EventHandler(priority = EventPriority.HIGHEST)
|
||||
public void frameRemove(HangingBreakByEntityEvent event) {
|
||||
public void FrameRemove(HangingBreakByEntityEvent event) {
|
||||
if (event.getRemover() == null) return;
|
||||
if ((event.getRemover() instanceof Player) && event.getEntity().getType().equals(EntityType.ITEM_FRAME)) {
|
||||
Player p = (Player) event.getRemover();
|
||||
if (!playerCanBuildDestroyBlock(p, event.getEntity().getLocation(), "destroy", true)) {
|
||||
event.setCancelled(true);
|
||||
if ((event.getRemover() instanceof Player)) {
|
||||
if (event.getEntity().getType().equals(EntityType.ITEM_FRAME)) {
|
||||
Player p = (Player) event.getRemover();
|
||||
if (!playerCanBuildDestroyBlock(p, event.getEntity().getLocation(), "destroy", true)) {
|
||||
event.setCancelled(true);
|
||||
return;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -87,7 +87,7 @@ public class FactionsChatListener implements Listener {
|
||||
fplayer.sendMessage("[FCspy] " + myFaction.getTag() + ": " + message);
|
||||
}
|
||||
}
|
||||
FactionChatHandler.sendMessage(myFaction, me.getPlayer().getUniqueId(), me.getPlayer().getName(), event.getMessage());
|
||||
FactionChatHandler.sendMessage(FactionsPlugin.getInstance(), myFaction, me.getPlayer().getUniqueId(), me.getPlayer().getName(), event.getMessage());
|
||||
event.setCancelled(true);
|
||||
} else if (chat == ChatMode.ALLIANCE) {
|
||||
Faction myFaction = me.getFaction();
|
||||
|
||||
@@ -143,7 +143,7 @@ public class FactionsEntityListener implements Listener {
|
||||
} else {
|
||||
// we don't want to let mobs/arrows destroy item frames/armor stands
|
||||
// so we only have to run the check as if there had been an explosion at the damager location
|
||||
if (this.checkExplosionForBlock(damager, damagee.getLocation().getBlock()))
|
||||
if (!this.checkExplosionForBlock(damager, damagee.getLocation().getBlock()))
|
||||
event.setCancelled(true);
|
||||
}
|
||||
// we don't need to go after
|
||||
@@ -216,7 +216,7 @@ public class FactionsEntityListener implements Listener {
|
||||
Entity boomer = event.getEntity();
|
||||
|
||||
// Before we need to check the location where the block is placed
|
||||
if (this.checkExplosionForBlock(boomer, event.getLocation().getBlock())) {
|
||||
if (!this.checkExplosionForBlock(boomer, event.getLocation().getBlock())) {
|
||||
event.setCancelled(true);
|
||||
return;
|
||||
}
|
||||
@@ -224,7 +224,7 @@ public class FactionsEntityListener implements Listener {
|
||||
// Loop the blocklist to run checks on each aimed block
|
||||
|
||||
// The block don't have to explode
|
||||
event.blockList().removeIf(block -> this.checkExplosionForBlock(boomer, block));
|
||||
event.blockList().removeIf(block -> !this.checkExplosionForBlock(boomer, block));
|
||||
|
||||
// Cancel the event if no block will explode
|
||||
if (!event.blockList().isEmpty() && (boomer instanceof TNTPrimed || boomer instanceof ExplosiveMinecart) && Conf.handleExploitTNTWaterlog) {
|
||||
@@ -257,9 +257,10 @@ public class FactionsEntityListener implements Listener {
|
||||
|
||||
private boolean checkExplosionForBlock(Entity boomer, Block block) {
|
||||
Faction faction = Board.getInstance().getFactionAt(new FLocation(block.getLocation()));
|
||||
if (faction.isProtected()) return false;
|
||||
|
||||
if (faction.noExplosionsInTerritory() || (faction.isPeaceful() && Conf.peacefulTerritoryDisableBoom))
|
||||
return true;
|
||||
return false;
|
||||
// faction is peaceful and has explosions set to disabled
|
||||
|
||||
boolean online = faction.hasPlayersOnline();
|
||||
@@ -269,17 +270,17 @@ public class FactionsEntityListener implements Listener {
|
||||
(faction.isWarZone() && Conf.warZoneBlockCreepers) ||
|
||||
faction.isSafeZone())) {
|
||||
// creeper which needs prevention
|
||||
return true;
|
||||
return false;
|
||||
} else if (
|
||||
// it's a bit crude just using fireball protection for Wither boss too, but I'd rather not add in a whole new set of xxxBlockWitherExplosion or whatever
|
||||
(boomer instanceof Fireball || boomer instanceof Wither) && (faction.isWilderness() && Conf.wildernessBlockFireballs && !Conf.worldsNoWildernessProtection.contains(block.getWorld().getName()) || faction.isNormal() && (online ? Conf.territoryBlockFireballs : Conf.territoryBlockFireballsWhenOffline) || faction.isWarZone() && Conf.warZoneBlockFireballs || faction.isSafeZone())) {
|
||||
// ghast fireball which needs prevention
|
||||
return true;
|
||||
return false;
|
||||
} else
|
||||
return (boomer instanceof TNTPrimed || boomer instanceof ExplosiveMinecart) && ((faction.isWilderness() && Conf.wildernessBlockTNT && !Conf.worldsNoWildernessProtection.contains(block.getWorld().getName())) ||
|
||||
(faction.isNormal() && (online ? Conf.territoryBlockTNT : Conf.territoryBlockTNTWhenOffline)) ||
|
||||
(faction.isWarZone() && Conf.warZoneBlockTNT) ||
|
||||
(faction.isSafeZone() && Conf.safeZoneBlockTNT));
|
||||
return (!(boomer instanceof TNTPrimed) && !(boomer instanceof ExplosiveMinecart)) || ((!faction.isWilderness() || !Conf.wildernessBlockTNT || Conf.worldsNoWildernessProtection.contains(block.getWorld().getName())) &&
|
||||
(!faction.isNormal() || (online ? !Conf.territoryBlockTNT : !Conf.territoryBlockTNTWhenOffline)) &&
|
||||
(!faction.isWarZone() || !Conf.warZoneBlockTNT) &&
|
||||
(!faction.isSafeZone() || !Conf.safeZoneBlockTNT));
|
||||
|
||||
// No condition retained, destroy the block!
|
||||
}
|
||||
@@ -311,7 +312,7 @@ public class FactionsEntityListener implements Listener {
|
||||
if (thrower instanceof Player) {
|
||||
Player player = (Player) thrower;
|
||||
FPlayer fPlayer = FPlayers.getInstance().getByPlayer(player);
|
||||
if (fPlayer.getFaction().isPeaceful()) {
|
||||
if (badjuju && fPlayer.getFaction().isPeaceful()) {
|
||||
event.setCancelled(true);
|
||||
return;
|
||||
}
|
||||
@@ -506,8 +507,10 @@ public class FactionsEntityListener implements Listener {
|
||||
if (!(e.getRemover() instanceof Player)) return;
|
||||
Player p = (Player) e.getRemover();
|
||||
|
||||
if (e.getEntity().getType() == EntityType.PAINTING || e.getEntity().getType() == EntityType.ITEM_FRAME && !FactionsBlockListener.playerCanBuildDestroyBlock(p, e.getEntity().getLocation(), "destroy", false)) {
|
||||
e.setCancelled(true);
|
||||
if (e.getEntity().getType() == EntityType.PAINTING || e.getEntity().getType() == EntityType.ITEM_FRAME) {
|
||||
if (!FactionsBlockListener.playerCanBuildDestroyBlock(p, e.getEntity().getLocation(), "destroy", false)) {
|
||||
e.setCancelled(true);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -515,9 +518,11 @@ public class FactionsEntityListener implements Listener {
|
||||
public void onPaintingPlace(HangingPlaceEvent e) {
|
||||
if (e.getPlayer() == null) return;
|
||||
|
||||
if (e.getEntity().getType() == EntityType.PAINTING || e.getEntity().getType() == EntityType.ITEM_FRAME && !FactionsBlockListener.playerCanBuildDestroyBlock(e.getPlayer(), e.getBlock().getLocation(), "build", false)) {
|
||||
e.setCancelled(true);
|
||||
e.getPlayer().updateInventory();
|
||||
if (e.getEntity().getType() == EntityType.PAINTING || e.getEntity().getType() == EntityType.ITEM_FRAME) {
|
||||
if (!FactionsBlockListener.playerCanBuildDestroyBlock(e.getPlayer(), e.getBlock().getLocation(), "build", false)) {
|
||||
e.setCancelled(true);
|
||||
e.getPlayer().updateInventory();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -542,37 +547,73 @@ public class FactionsEntityListener implements Listener {
|
||||
}
|
||||
|
||||
|
||||
/*
|
||||
@EventHandler
|
||||
public void onTravel(PlayerPortalEvent event) {
|
||||
if (!FactionsPlugin.getInstance().getConfig().getBoolean("portals.limit", false))
|
||||
return; // Don't do anything if they don't want us to.
|
||||
|
||||
|
||||
TravelAgent agent = event.getPortalTravelAgent();
|
||||
|
||||
// If they aren't able to find a portal, it'll try to create one.
|
||||
if (event.useTravelAgent() && agent.getCanCreatePortal() && agent.findPortal(event.getTo()) == null) {
|
||||
FLocation loc = new FLocation(event.getTo());
|
||||
Faction faction = Board.getInstance().getFactionAt(loc);
|
||||
if (faction.isWilderness()) {
|
||||
return; // We don't care about wilderness.
|
||||
} else if (!faction.isNormal() && !event.getPlayer().isOp()) {
|
||||
// Don't let non ops make portals in safezone or warzone.
|
||||
event.setCancelled(true);
|
||||
return;
|
||||
}
|
||||
|
||||
FPlayer fp = FPlayers.getInstance().getByPlayer(event.getPlayer());
|
||||
String mininumRelation = FactionsPlugin.getInstance().getConfig().getString("portals.minimum-relation", "MEMBER"); // Defaults to Neutral if typed wrong.
|
||||
if (!fp.getFaction().getRelationTo(faction).isAtLeast(Relation.fromString(mininumRelation))) {
|
||||
event.setCancelled(true);
|
||||
}
|
||||
}
|
||||
}
|
||||
*/
|
||||
|
||||
@EventHandler
|
||||
public void onHit(EntityDamageByEntityEvent e) {
|
||||
if (e.getDamager() instanceof Player && e.getEntity() instanceof Player) {
|
||||
Player victim = (Player) e.getEntity();
|
||||
Player attacker = (Player) e.getDamager();
|
||||
FPlayer fvictim = FPlayers.getInstance().getByPlayer(victim);
|
||||
FPlayer fattacker = FPlayers.getInstance().getByPlayer(attacker);
|
||||
if (fattacker.getRelationTo(fvictim) == Relation.TRUCE) {
|
||||
fattacker.msg(TL.PLAYER_PVP_CANTHURT, fvictim.describeTo(fattacker));
|
||||
e.setCancelled(true);
|
||||
if (e.getDamager() instanceof Player) {
|
||||
if (e.getEntity() instanceof Player) {
|
||||
Player victim = (Player) e.getEntity();
|
||||
Player attacker = (Player) e.getDamager();
|
||||
FPlayer fvictim = FPlayers.getInstance().getByPlayer(victim);
|
||||
FPlayer fattacker = FPlayers.getInstance().getByPlayer(attacker);
|
||||
if (fattacker.getRelationTo(fvictim) == Relation.TRUCE) {
|
||||
fattacker.msg(TL.PLAYER_PVP_CANTHURT, fvictim.describeTo(fattacker));
|
||||
e.setCancelled(true);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@EventHandler
|
||||
public void onBowHit(EntityDamageByEntityEvent e) {
|
||||
if (e.getDamager() instanceof Projectile && e.getEntity() instanceof Player) {
|
||||
Projectile arrow = ((Projectile) e.getDamager());
|
||||
if (arrow.getShooter() instanceof Player) {
|
||||
Player damager = (Player) ((Projectile) e.getDamager()).getShooter();
|
||||
Player victim = (Player) e.getEntity();
|
||||
FPlayer fdamager = FPlayers.getInstance().getByPlayer(damager);
|
||||
FPlayer fvictim = FPlayers.getInstance().getByPlayer(victim);
|
||||
if (damager == victim) return;
|
||||
if (fdamager == fvictim) return;
|
||||
if (fvictim.getRelationTo(fdamager) == Relation.TRUCE) {
|
||||
fdamager.msg(TL.PLAYER_PVP_CANTHURT, fvictim.describeTo(fdamager));
|
||||
e.setCancelled(true);
|
||||
}
|
||||
if (fvictim.getRelationTo(fdamager) == Relation.ENEMY && fvictim.isFlying()) {
|
||||
fvictim.setFFlying(false, true);
|
||||
if (e.getDamager() instanceof Projectile) {
|
||||
if (e.getEntity() instanceof Player) {
|
||||
Projectile arrow = ((Projectile) e.getDamager());
|
||||
if (arrow.getShooter() instanceof Player) {
|
||||
Player damager = (Player) ((Projectile) e.getDamager()).getShooter();
|
||||
Player victim = (Player) e.getEntity();
|
||||
FPlayer fdamager = FPlayers.getInstance().getByPlayer(damager);
|
||||
FPlayer fvictim = FPlayers.getInstance().getByPlayer(victim);
|
||||
if (damager == victim) return;
|
||||
if (fdamager == fvictim) return;
|
||||
if (fvictim.getRelationTo(fdamager) == Relation.TRUCE) {
|
||||
fdamager.msg(TL.PLAYER_PVP_CANTHURT, fvictim.describeTo(fdamager));
|
||||
e.setCancelled(true);
|
||||
}
|
||||
if (fvictim.getRelationTo(fdamager) == Relation.ENEMY) {
|
||||
if (fvictim.isFlying()) {
|
||||
fvictim.setFFlying(false, true);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
package com.massivecraft.factions.listeners;
|
||||
|
||||
import com.cryptomorin.xseries.XMaterial;
|
||||
import com.massivecraft.factions.Conf;
|
||||
import com.massivecraft.factions.util.XMaterial;
|
||||
import org.bukkit.Location;
|
||||
import org.bukkit.Material;
|
||||
import org.bukkit.block.Block;
|
||||
|
||||
@@ -1,5 +1,6 @@
|
||||
package com.massivecraft.factions.listeners;
|
||||
|
||||
import com.cryptomorin.xseries.XMaterial;
|
||||
import com.massivecraft.factions.*;
|
||||
import com.massivecraft.factions.cmd.CmdFGlobal;
|
||||
import com.massivecraft.factions.cmd.CmdFly;
|
||||
@@ -20,7 +21,6 @@ import com.massivecraft.factions.struct.Relation;
|
||||
import com.massivecraft.factions.struct.Role;
|
||||
import com.massivecraft.factions.util.CC;
|
||||
import com.massivecraft.factions.util.VisualizeUtil;
|
||||
import com.massivecraft.factions.util.XMaterial;
|
||||
import com.massivecraft.factions.util.wait.WaitExecutor;
|
||||
import com.massivecraft.factions.zcore.fperms.Access;
|
||||
import com.massivecraft.factions.zcore.fperms.PermissableAction;
|
||||
@@ -54,7 +54,9 @@ import java.util.logging.Level;
|
||||
|
||||
public class FactionsPlayerListener implements Listener {
|
||||
|
||||
public final static Map<UUID, Location> lastLocations = new HashMap<>();
|
||||
public static Set<FLocation> corners;
|
||||
public static BukkitTask positionTask = null;
|
||||
/**
|
||||
* @author FactionsUUID Team
|
||||
*/
|
||||
@@ -188,6 +190,7 @@ public class FactionsPlayerListener implements Listener {
|
||||
FLocation loc = new FLocation(block);
|
||||
Faction otherFaction = Board.getInstance().getFactionAt(loc);
|
||||
Faction myFaction = me.getFaction();
|
||||
Relation rel = myFaction.getRelationTo(otherFaction);
|
||||
|
||||
// no door/chest/whatever protection in wilderness, war zones, or safe zones
|
||||
if (otherFaction.isSystemFaction()) return true;
|
||||
@@ -332,131 +335,36 @@ public class FactionsPlayerListener implements Listener {
|
||||
}
|
||||
|
||||
private static PermissableAction GetPermissionFromUsableBlock(Material material) {
|
||||
// Check for doors that might have diff material name in old version.
|
||||
if (material.name().contains("DOOR") || material.name().contains("FENCE_GATE"))
|
||||
return PermissableAction.DOOR;
|
||||
if (material.name().toUpperCase().contains("BUTTON") || material.name().toUpperCase().contains("PRESSURE") || material.name().contains("DIODE") || material.name().contains("COMPARATOR"))
|
||||
return PermissableAction.BUTTON;
|
||||
if (FactionsPlugin.instance.mc113 || FactionsPlugin.instance.mc114 || FactionsPlugin.getInstance().mc115) {
|
||||
switch (material) {
|
||||
case LEVER:
|
||||
return PermissableAction.LEVER;
|
||||
case ACACIA_BUTTON:
|
||||
case BIRCH_BUTTON:
|
||||
case DARK_OAK_BUTTON:
|
||||
case JUNGLE_BUTTON:
|
||||
case OAK_BUTTON:
|
||||
case SPRUCE_BUTTON:
|
||||
case STONE_BUTTON:
|
||||
case COMPARATOR:
|
||||
case REPEATER:
|
||||
return PermissableAction.BUTTON;
|
||||
|
||||
case ACACIA_DOOR:
|
||||
case BIRCH_DOOR:
|
||||
case IRON_DOOR:
|
||||
case JUNGLE_DOOR:
|
||||
case OAK_DOOR:
|
||||
case SPRUCE_DOOR:
|
||||
case DARK_OAK_DOOR:
|
||||
|
||||
case ACACIA_TRAPDOOR:
|
||||
case BIRCH_TRAPDOOR:
|
||||
case DARK_OAK_TRAPDOOR:
|
||||
case IRON_TRAPDOOR:
|
||||
case JUNGLE_TRAPDOOR:
|
||||
case OAK_TRAPDOOR:
|
||||
case SPRUCE_TRAPDOOR:
|
||||
|
||||
case ACACIA_FENCE_GATE:
|
||||
case BIRCH_FENCE_GATE:
|
||||
case DARK_OAK_FENCE_GATE:
|
||||
case JUNGLE_FENCE_GATE:
|
||||
case OAK_FENCE_GATE:
|
||||
case SPRUCE_FENCE_GATE:
|
||||
return PermissableAction.DOOR;
|
||||
|
||||
case CHEST:
|
||||
case TRAPPED_CHEST:
|
||||
case CHEST_MINECART:
|
||||
|
||||
case BARREL:
|
||||
case COMPOSTER:
|
||||
case LOOM:
|
||||
case CARTOGRAPHY_TABLE:
|
||||
case GRINDSTONE:
|
||||
|
||||
case SHULKER_BOX:
|
||||
case BLACK_SHULKER_BOX:
|
||||
case BLUE_SHULKER_BOX:
|
||||
case BROWN_SHULKER_BOX:
|
||||
case CYAN_SHULKER_BOX:
|
||||
case GRAY_SHULKER_BOX:
|
||||
case GREEN_SHULKER_BOX:
|
||||
case LIGHT_BLUE_SHULKER_BOX:
|
||||
case LIGHT_GRAY_SHULKER_BOX:
|
||||
case LIME_SHULKER_BOX:
|
||||
case MAGENTA_SHULKER_BOX:
|
||||
case ORANGE_SHULKER_BOX:
|
||||
case PINK_SHULKER_BOX:
|
||||
case PURPLE_SHULKER_BOX:
|
||||
case RED_SHULKER_BOX:
|
||||
case WHITE_SHULKER_BOX:
|
||||
case YELLOW_SHULKER_BOX:
|
||||
|
||||
case FURNACE:
|
||||
case BLAST_FURNACE:
|
||||
case SMOKER:
|
||||
case DROPPER:
|
||||
case DISPENSER:
|
||||
case ENCHANTING_TABLE:
|
||||
case BREWING_STAND:
|
||||
case CAULDRON:
|
||||
case HOPPER:
|
||||
case BEACON:
|
||||
case JUKEBOX:
|
||||
case ANVIL:
|
||||
case CHIPPED_ANVIL:
|
||||
case DAMAGED_ANVIL:
|
||||
return PermissableAction.CONTAINER;
|
||||
default:
|
||||
return null;
|
||||
}
|
||||
} else {
|
||||
switch (material) {
|
||||
case LEVER:
|
||||
return PermissableAction.LEVER;
|
||||
case DARK_OAK_DOOR:
|
||||
case ACACIA_DOOR:
|
||||
case BIRCH_DOOR:
|
||||
case IRON_DOOR:
|
||||
case JUNGLE_DOOR:
|
||||
case SPRUCE_DOOR:
|
||||
case ACACIA_FENCE_GATE:
|
||||
case BIRCH_FENCE_GATE:
|
||||
case OAK_FENCE_GATE:
|
||||
case DARK_OAK_FENCE_GATE:
|
||||
case JUNGLE_FENCE_GATE:
|
||||
case SPRUCE_FENCE_GATE:
|
||||
return PermissableAction.DOOR;
|
||||
case CHEST:
|
||||
case ENDER_CHEST:
|
||||
case TRAPPED_CHEST:
|
||||
case DISPENSER:
|
||||
case ENCHANTING_TABLE:
|
||||
case DROPPER:
|
||||
case FURNACE:
|
||||
case BLAST_FURNACE:
|
||||
case SMOKER:
|
||||
case HOPPER:
|
||||
case ANVIL:
|
||||
case CHIPPED_ANVIL:
|
||||
case DAMAGED_ANVIL:
|
||||
case BREWING_STAND:
|
||||
return PermissableAction.CONTAINER;
|
||||
default:
|
||||
return null;
|
||||
}
|
||||
if (material.name().contains("_BUTTON")
|
||||
|| material.name().contains("COMPARATOR")
|
||||
|| material.name().contains("PRESSURE")
|
||||
|| material.name().contains("REPEATER")
|
||||
|| material.name().contains("DIODE")) return PermissableAction.BUTTON;
|
||||
if (material.name().contains("_DOOR")
|
||||
|| material.name().contains("_TRAPDOOR")
|
||||
|| material.name().contains("_FENCE_GATE")
|
||||
|| material.name().startsWith("FENCE_GATE")) return PermissableAction.DOOR;
|
||||
if (material.name().contains("SHULKER_BOX")
|
||||
|| material.name().endsWith("ANVIL")
|
||||
|| material.name().startsWith("CHEST_MINECART")
|
||||
|| material.name().endsWith("CHEST")
|
||||
|| material.name().endsWith("JUKEBOX")
|
||||
|| material.name().endsWith("CAULDRON")
|
||||
|| material.name().endsWith("FURNACE")
|
||||
|| material.name().endsWith("HOPPER")
|
||||
|| material.name().endsWith("BEACON")
|
||||
|| material.name().startsWith("TRAPPED_CHEST")
|
||||
|| material.name().equalsIgnoreCase("ENCHANTING_TABLE")
|
||||
|| material.name().equalsIgnoreCase("ENCHANTMENT_TABLE")
|
||||
|| material.name().endsWith("BREWING_STAND")
|
||||
|| material.name().equalsIgnoreCase("BARREL")) return PermissableAction.CONTAINER;
|
||||
if (material.name().endsWith("LEVER")) return PermissableAction.LEVER;
|
||||
switch (material) {
|
||||
case DISPENSER:
|
||||
case DROPPER:
|
||||
return PermissableAction.CONTAINER;
|
||||
default:
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -518,11 +426,13 @@ public class FactionsPlayerListener implements Listener {
|
||||
|
||||
@EventHandler
|
||||
public void onPlayerFall(EntityDamageEvent e) {
|
||||
if (e.getEntity() instanceof Player && e.getCause() == EntityDamageEvent.DamageCause.FALL) {
|
||||
Player player = (Player) e.getEntity();
|
||||
if (fallMap.containsKey(player)) {
|
||||
e.setCancelled(true);
|
||||
fallMap.remove(player);
|
||||
if (e.getEntity() instanceof Player) {
|
||||
if (e.getCause() == EntityDamageEvent.DamageCause.FALL) {
|
||||
Player player = (Player) e.getEntity();
|
||||
if (fallMap.containsKey(player)) {
|
||||
e.setCancelled(true);
|
||||
fallMap.remove(player);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -610,7 +520,7 @@ public class FactionsPlayerListener implements Listener {
|
||||
fplayer.msg(TL.COMMAND_INSPECT_BYPASS);
|
||||
}
|
||||
List<String[]> info = CoreProtect.getInstance().getAPI().blockLookup(e.getClickedBlock(), 0);
|
||||
if (info.isEmpty()) {
|
||||
if (info.size() == 0) {
|
||||
e.getPlayer().sendMessage(TL.COMMAND_INSPECT_NODATA.toString());
|
||||
return;
|
||||
}
|
||||
@@ -649,9 +559,6 @@ public class FactionsPlayerListener implements Listener {
|
||||
return (result.length() == 3 ? result + "0" : result) + "/hrs ago";
|
||||
}
|
||||
|
||||
public static BukkitTask positionTask = null;
|
||||
public final Map<UUID, Location> lastLocations = new HashMap<>();
|
||||
|
||||
public void startPositionCheck() {
|
||||
positionTask = Bukkit.getScheduler().runTaskTimer(FactionsPlugin.getInstance(), () -> {
|
||||
if (lastLocations.isEmpty()) return;
|
||||
@@ -808,7 +715,11 @@ public class FactionsPlayerListener implements Listener {
|
||||
Material type;
|
||||
if (event.getItem() != null) {
|
||||
// Convert 1.8 Material Names -> 1.15
|
||||
type = XMaterial.matchXMaterial(event.getItem().getType().toString()).get().parseMaterial();
|
||||
try {
|
||||
type = XMaterial.matchXMaterial(event.getItem().getType().toString()).get().parseMaterial();
|
||||
} catch (NullPointerException npe) {
|
||||
type = null;
|
||||
}
|
||||
} else {
|
||||
type = null;
|
||||
}
|
||||
@@ -824,14 +735,18 @@ public class FactionsPlayerListener implements Listener {
|
||||
// Do type null checks so if XMaterial has a parsing issue and fills null as a value it will not bypass.
|
||||
// territoryCancelAndAllowItemUseMaterial bypass the protection system but only if they're not clicking on territoryDenySwitchMaterials
|
||||
// if they're clicking on territoryDenySwitchMaterials, let the protection system handle the permissions
|
||||
if (type != null && !Conf.territoryDenySwitchMaterials.contains(block.getType()) && Conf.territoryCancelAndAllowItemUseMaterial.contains(type)) {
|
||||
return;
|
||||
if (type != null && !Conf.territoryDenySwitchMaterials.contains(block.getType())) {
|
||||
if (Conf.territoryCancelAndAllowItemUseMaterial.contains(type)) {
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
if (GetPermissionFromUsableBlock(block.getType()) != null && !canPlayerUseBlock(player, block, false)) {
|
||||
event.setCancelled(true);
|
||||
event.setUseInteractedBlock(Event.Result.DENY);
|
||||
return;
|
||||
if (GetPermissionFromUsableBlock(block.getType()) != null) {
|
||||
if (!canPlayerUseBlock(player, block, false)) {
|
||||
event.setCancelled(true);
|
||||
event.setUseInteractedBlock(Event.Result.DENY);
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
if (type != null && !playerCanUseItemHere(player, block.getLocation(), event.getItem().getType(), false, PermissableAction.ITEM)) {
|
||||
@@ -852,13 +767,14 @@ public class FactionsPlayerListener implements Listener {
|
||||
public void onPlayerBoneMeal(PlayerInteractEvent event) {
|
||||
Block block = event.getClickedBlock();
|
||||
if (event.getAction() == Action.RIGHT_CLICK_BLOCK && block.getType() == XMaterial.GRASS_BLOCK.parseMaterial()
|
||||
&& event.hasItem() && event.getItem().getType() == XMaterial.BONE_MEAL.parseMaterial()
|
||||
&& !FactionsBlockListener.playerCanBuildDestroyBlock(event.getPlayer(), block.getLocation(), PermissableAction.BUILD.name(), true)) {
|
||||
FPlayer me = FPlayers.getInstance().getById(event.getPlayer().getUniqueId().toString());
|
||||
Faction myFaction = me.getFaction();
|
||||
&& event.hasItem() && event.getItem().getType() == XMaterial.BONE_MEAL.parseMaterial()) {
|
||||
if (!FactionsBlockListener.playerCanBuildDestroyBlock(event.getPlayer(), block.getLocation(), PermissableAction.BUILD.name(), true)) {
|
||||
FPlayer me = FPlayers.getInstance().getById(event.getPlayer().getUniqueId().toString());
|
||||
Faction myFaction = me.getFaction();
|
||||
|
||||
me.msg(TL.ACTIONS_NOPERMISSION.toString().replace("{faction}", myFaction.getTag(me.getFaction())).replace("{action}", "use bone meal"));
|
||||
event.setCancelled(true);
|
||||
me.msg(TL.ACTIONS_NOPERMISSION.toString().replace("{faction}", myFaction.getTag(me.getFaction())).replace("{action}", "use bone meal"));
|
||||
event.setCancelled(true);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -926,8 +842,10 @@ public class FactionsPlayerListener implements Listener {
|
||||
player.sendMessage(String.valueOf(TL.COMMAND_LOGOUT_DAMAGE_TAKEN));
|
||||
}
|
||||
WaitExecutor.handleAction(player);
|
||||
if (CmdWild.teleporting.contains(player) && !FactionsPlugin.getInstance().getConfig().getBoolean("Wild.FallDamage") && e.getCause() == EntityDamageEvent.DamageCause.FALL) {
|
||||
e.setCancelled(true);
|
||||
if (CmdWild.teleporting.contains(player)) {
|
||||
if (!FactionsPlugin.getInstance().getConfig().getBoolean("Wild.FallDamage") && e.getCause() == EntityDamageEvent.DamageCause.FALL) {
|
||||
e.setCancelled(true);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -936,6 +854,7 @@ public class FactionsPlayerListener implements Listener {
|
||||
public void onTeleport(PlayerTeleportEvent e) {
|
||||
Player player = e.getPlayer();
|
||||
|
||||
if (player == null) return;
|
||||
LogoutHandler handler = LogoutHandler.getByName(player.getName());
|
||||
if (handler.isLogoutActive(player)) {
|
||||
handler.cancelLogout(player);
|
||||
@@ -973,7 +892,7 @@ public class FactionsPlayerListener implements Listener {
|
||||
}
|
||||
|
||||
@EventHandler(priority = EventPriority.MONITOR, ignoreCancelled = true)
|
||||
final void onFactionJoin(FPlayerJoinEvent event) {
|
||||
final public void onFactionJoin(FPlayerJoinEvent event) {
|
||||
FTeamWrapper.applyUpdatesLater(event.getFaction());
|
||||
}
|
||||
|
||||
@@ -987,7 +906,7 @@ public class FactionsPlayerListener implements Listener {
|
||||
}
|
||||
|
||||
@EventHandler
|
||||
public void asyncPlayerChatEvent(AsyncPlayerChatEvent e) {
|
||||
public void AsyncPlayerChatEvent(AsyncPlayerChatEvent e) {
|
||||
Player p = e.getPlayer();
|
||||
|
||||
if (CmdFGlobal.toggled.contains(p.getUniqueId())) {
|
||||
@@ -1013,8 +932,10 @@ public class FactionsPlayerListener implements Listener {
|
||||
|
||||
for (int i = l.size() - 1; i >= 0; i--) { // going backwards in the list to prevent a ConcurrentModificationException
|
||||
Player recipient = l.get(i);
|
||||
if (recipient != null && CmdFGlobal.toggled.contains(recipient.getUniqueId())) {
|
||||
e.getRecipients().remove(recipient);
|
||||
if (recipient != null) {
|
||||
if (CmdFGlobal.toggled.contains(recipient.getUniqueId())) {
|
||||
e.getRecipients().remove(recipient);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -15,6 +15,9 @@ import org.bukkit.inventory.ItemStack;
|
||||
*/
|
||||
public class MenuListener implements Listener {
|
||||
|
||||
public MenuListener() {
|
||||
}
|
||||
|
||||
@EventHandler
|
||||
public void onInventoryClick(InventoryClickEvent event) {
|
||||
if (event.getView().getTitle().equals("Faction Logs")) {
|
||||
|
||||
@@ -1,8 +1,8 @@
|
||||
package com.massivecraft.factions.missions;
|
||||
|
||||
import com.cryptomorin.xseries.XMaterial;
|
||||
import com.massivecraft.factions.FPlayer;
|
||||
import com.massivecraft.factions.FactionsPlugin;
|
||||
import com.massivecraft.factions.util.XMaterial;
|
||||
import com.massivecraft.factions.zcore.frame.FactionGUI;
|
||||
import com.massivecraft.factions.zcore.util.TL;
|
||||
import org.bukkit.ChatColor;
|
||||
|
||||
@@ -137,7 +137,7 @@ public class FScoreboard {
|
||||
updateObjective();
|
||||
}
|
||||
}
|
||||
}.runTaskLater(FactionsPlugin.getInstance(), FactionsPlugin.getInstance().getConfig().getInt("scoreboard.expiration", 7) * 20L);
|
||||
}.runTaskLater(FactionsPlugin.getInstance(), FactionsPlugin.getInstance().getConfig().getInt("scoreboard.expiration", 7) * 20);
|
||||
}
|
||||
|
||||
private void updateObjective() {
|
||||
|
||||
@@ -25,8 +25,6 @@ public class FTeamWrapper {
|
||||
private final String teamName;
|
||||
private final Faction faction;
|
||||
private final Set<OfflinePlayer> members = new HashSet<>();
|
||||
private static final String defaultPrefixes = "scoreboard.default-prefixes";
|
||||
private static final String invisFactionMembers = "See-Invisible-Faction-Members";
|
||||
|
||||
private FTeamWrapper(Faction faction) {
|
||||
this.teamName = "faction_" + (factionTeamPtr++);
|
||||
@@ -46,7 +44,7 @@ public class FTeamWrapper {
|
||||
return;
|
||||
}
|
||||
|
||||
if (!FactionsPlugin.getInstance().getConfig().getBoolean(defaultPrefixes, false) || FactionsPlugin.getInstance().getConfig().getBoolean(invisFactionMembers)) {
|
||||
if (!FactionsPlugin.getInstance().getConfig().getBoolean("scoreboard.default-prefixes", false) || FactionsPlugin.getInstance().getConfig().getBoolean("See-Invisible-Faction-Members")) {
|
||||
return;
|
||||
}
|
||||
|
||||
@@ -68,7 +66,7 @@ public class FTeamWrapper {
|
||||
return;
|
||||
}
|
||||
|
||||
if (!FactionsPlugin.getInstance().getConfig().getBoolean(defaultPrefixes, false) || FactionsPlugin.getInstance().getConfig().getBoolean(invisFactionMembers)) {
|
||||
if (!FactionsPlugin.getInstance().getConfig().getBoolean("scoreboard.default-prefixes", false) || FactionsPlugin.getInstance().getConfig().getBoolean("See-Invisible-Faction-Members")) {
|
||||
return;
|
||||
}
|
||||
|
||||
@@ -160,7 +158,7 @@ public class FTeamWrapper {
|
||||
}
|
||||
|
||||
private void updatePrefixes() {
|
||||
if (FactionsPlugin.getInstance().getConfig().getBoolean(defaultPrefixes, false)) {
|
||||
if (FactionsPlugin.getInstance().getConfig().getBoolean("scoreboard.default-prefixes", false)) {
|
||||
for (FScoreboard fboard : teams.keySet()) {
|
||||
updatePrefix(fboard);
|
||||
}
|
||||
@@ -168,19 +166,19 @@ public class FTeamWrapper {
|
||||
}
|
||||
|
||||
private void updatePrefix(FScoreboard fboard) {
|
||||
if (FactionsPlugin.getInstance().getConfig().getBoolean(defaultPrefixes, false)) {
|
||||
if (FactionsPlugin.getInstance().getConfig().getBoolean("scoreboard.default-prefixes", false)) {
|
||||
FPlayer fplayer = fboard.getFPlayer();
|
||||
Team team = teams.get(fboard);
|
||||
boolean focused = false;
|
||||
|
||||
if (FactionsPlugin.getInstance().getConfig().getBoolean(invisFactionMembers, false)) {
|
||||
if (FactionsPlugin.getInstance().getConfig().getBoolean("See-Invisible-Faction-Members", false)) {
|
||||
team.setCanSeeFriendlyInvisibles(true);
|
||||
}
|
||||
|
||||
if ((FactionsPlugin.getInstance().getConfig().getBoolean("ffocus.Enabled")) && (fplayer.getFaction() != null) && (fplayer.getFaction().getFocused() != null)) {
|
||||
for (FPlayer fp : faction.getFPlayersWhereOnline(true)) {
|
||||
if (fplayer.getFaction().getFocused().equalsIgnoreCase(fp.getName())) {
|
||||
team.setPrefix(ChatColor.translateAlternateColorCodes('&', Objects.requireNonNull(FactionsPlugin.getInstance().getConfig().getString("ffocus.Prefix", "&7»&b"))));
|
||||
team.setPrefix(ChatColor.translateAlternateColorCodes('&', FactionsPlugin.getInstance().getConfig().getString("ffocus.Prefix", "&7»&b")));
|
||||
focused = true;
|
||||
}
|
||||
}
|
||||
@@ -193,8 +191,7 @@ public class FTeamWrapper {
|
||||
prefix = prefix.replace("{relationcolor}", faction.getRelationTo(fplayer).getColor().toString());
|
||||
prefix = prefix.replace("{faction}",
|
||||
faction.getTag().substring(0, Math.min("{faction}".length() + 16 - prefix.length(), faction.getTag().length())));
|
||||
team.getPrefix();
|
||||
if (!team.getPrefix().equals(prefix)) {
|
||||
if ((team.getPrefix() == null) || (!team.getPrefix().equals(prefix))) {
|
||||
team.setPrefix(prefix);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,5 +1,6 @@
|
||||
package com.massivecraft.factions.shop;
|
||||
|
||||
import com.cryptomorin.xseries.XMaterial;
|
||||
import com.github.stefvanschie.inventoryframework.Gui;
|
||||
import com.github.stefvanschie.inventoryframework.GuiItem;
|
||||
import com.github.stefvanschie.inventoryframework.pane.PaginatedPane;
|
||||
@@ -7,10 +8,10 @@ import com.massivecraft.factions.FPlayer;
|
||||
import com.massivecraft.factions.FPlayers;
|
||||
import com.massivecraft.factions.Faction;
|
||||
import com.massivecraft.factions.FactionsPlugin;
|
||||
import com.massivecraft.factions.util.XMaterial;
|
||||
import com.massivecraft.factions.zcore.util.TL;
|
||||
import org.bukkit.Bukkit;
|
||||
import org.bukkit.ChatColor;
|
||||
import org.bukkit.Material;
|
||||
import org.bukkit.configuration.ConfigurationSection;
|
||||
import org.bukkit.enchantments.Enchantment;
|
||||
import org.bukkit.entity.Player;
|
||||
@@ -20,6 +21,9 @@ import org.bukkit.inventory.meta.ItemMeta;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
import java.util.Set;
|
||||
import java.util.logging.Level;
|
||||
import java.util.stream.Collectors;
|
||||
|
||||
public class ShopGUIFrame {
|
||||
@@ -31,28 +35,28 @@ public class ShopGUIFrame {
|
||||
private Gui gui;
|
||||
|
||||
public ShopGUIFrame(Faction f) {
|
||||
gui = new Gui(FactionsPlugin.getInstance(),
|
||||
FactionsPlugin.getInstance().getConfig().getInt("F-Shop.GUI.Rows", 4),
|
||||
FactionsPlugin.getInstance().color(FactionsPlugin.getInstance().getConfig().getString("F-Shop.GUI.Name")));
|
||||
gui = new Gui(FactionsPlugin.getInstance(), FactionsPlugin.getInstance().getConfig().getInt("F-Shop.GUI.Rows", 4), FactionsPlugin.getInstance().color(FactionsPlugin.getInstance().getConfig().getString("F-Shop.GUI.Name")));
|
||||
}
|
||||
|
||||
public void buildGUI(FPlayer fplayer) {
|
||||
PaginatedPane pane = new PaginatedPane(0, 0, 9, gui.getRows());
|
||||
List<GuiItem> GUIItems = new ArrayList<>();
|
||||
ItemStack dummy = buildDummyItem(fplayer.getFaction());
|
||||
for (int x = 0; x <= (gui.getRows() * 9) - 1; x++) GUIItems.add(new GuiItem(dummy, e -> e.setCancelled(true)));
|
||||
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();
|
||||
for (int a = 1; a <= items; a++) {
|
||||
String s = a + "";
|
||||
String varItems = "items.";
|
||||
int slot = FactionsPlugin.getInstance().getFileManager().getShop().fetchInt(varItems + s + ".slot");
|
||||
ItemStack item = XMaterial.matchXMaterial(FactionsPlugin.getInstance().getFileManager().getShop().fetchString(varItems + s + ".block")).get().parseItem();
|
||||
int cost = FactionsPlugin.getInstance().getFileManager().getShop().fetchInt(varItems + s + ".cost");
|
||||
String name = FactionsPlugin.getInstance().getFileManager().getShop().fetchString(varItems + s + ".name");
|
||||
boolean glowing = FactionsPlugin.getInstance().getFileManager().getShop().fetchBoolean(varItems + s + ".glowing");
|
||||
List<String> lore = FactionsPlugin.getInstance().getFileManager().getShop().fetchStringList(varItems + s + ".lore");
|
||||
Set<String> items = FactionsPlugin.getInstance().getFileManager().getShop().getConfig().getConfigurationSection("items").getKeys(false);
|
||||
for (String s : items) {
|
||||
if (!checkShopConfig(s)) {
|
||||
continue;
|
||||
}
|
||||
|
||||
int slot = FactionsPlugin.getInstance().getFileManager().getShop().fetchInt("items." + s + ".slot");
|
||||
ItemStack item = XMaterial.matchXMaterial(FactionsPlugin.getInstance().getFileManager().getShop().fetchString("items." + s + ".block")).get().parseItem();
|
||||
int cost = FactionsPlugin.getInstance().getFileManager().getShop().fetchInt("items." + s + ".cost");
|
||||
String name = FactionsPlugin.getInstance().getFileManager().getShop().fetchString("items." + s + ".name");
|
||||
boolean glowing = FactionsPlugin.getInstance().getFileManager().getShop().fetchBoolean("items." + s + ".glowing");
|
||||
List<String> lore = FactionsPlugin.getInstance().getFileManager().getShop().fetchStringList("items." + s + ".lore");
|
||||
|
||||
assert item != null;
|
||||
ItemMeta meta = item.getItemMeta();
|
||||
@@ -62,23 +66,26 @@ public class ShopGUIFrame {
|
||||
meta.addItemFlags(ItemFlag.HIDE_ENCHANTS);
|
||||
meta.addEnchant(Enchantment.DURABILITY, 1, true);
|
||||
}
|
||||
if (!glowing) meta.removeEnchant(Enchantment.DURABILITY);
|
||||
if (!glowing)
|
||||
meta.removeEnchant(Enchantment.DURABILITY);
|
||||
List<String> replacedLore = lore.stream().map(t -> t.replace("{cost}", cost + "")).collect(Collectors.toList());
|
||||
meta.setLore(FactionsPlugin.instance.colorList(replacedLore));
|
||||
item.setItemMeta(meta);
|
||||
GUIItems.set(slot, new GuiItem(item, e -> {
|
||||
GUIItems.set(slot, new GuiItem(item, e ->
|
||||
{
|
||||
e.setCancelled(true);
|
||||
FPlayer fme = FPlayers.getInstance().getByPlayer((Player) e.getWhoClicked());
|
||||
if (fplayer.getFaction().getPoints() >= cost) {
|
||||
fplayer.getFaction().setPoints(fplayer.getFaction().getPoints() - cost);
|
||||
runCommands(FactionsPlugin.getInstance().getFileManager().getShop().fetchStringList("items." + s + ".cmds"), fplayer.getPlayer());
|
||||
for (FPlayer fplayerBuy : fplayer.getFaction().getFPlayers()) {
|
||||
fplayerBuy.getPlayer().sendMessage(TL.SHOP_BOUGHT_BROADCAST_FACTION.toString()
|
||||
.replace("{player}", fplayer.getPlayer().getName())
|
||||
.replace("{item}", ChatColor.stripColor(FactionsPlugin.getInstance().color(name)))
|
||||
.replace("{cost}", cost + ""));
|
||||
if (runCommands(FactionsPlugin.getInstance().getFileManager().getShop().fetchStringList("items." + s + ".cmds"), fplayer.getPlayer())) {
|
||||
fplayer.getFaction().setPoints(fplayer.getFaction().getPoints() - cost);
|
||||
for (FPlayer fplayerBuy : fplayer.getFaction().getFPlayers()) {
|
||||
fplayerBuy.getPlayer().sendMessage(TL.SHOP_BOUGHT_BROADCAST_FACTION.toString().replace("{player}", fplayer.getPlayer().getName()).replace("{item}", ChatColor.stripColor(FactionsPlugin.getInstance().color(name)))
|
||||
.replace("{cost}", cost + ""));
|
||||
}
|
||||
buildGUI(fme);
|
||||
} else {
|
||||
fplayer.msg(TL.SHOP_ERROR_DURING_PURCHASE);
|
||||
}
|
||||
buildGUI(fme);
|
||||
} else {
|
||||
fplayer.msg(TL.SHOP_NOT_ENOUGH_POINTS);
|
||||
}
|
||||
@@ -90,7 +97,6 @@ public class ShopGUIFrame {
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
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();
|
||||
@@ -103,10 +109,83 @@ public class ShopGUIFrame {
|
||||
return item;
|
||||
}
|
||||
|
||||
public void runCommands(List<String> list, Player p) {
|
||||
public boolean checkShopConfig() {
|
||||
boolean ret = true;
|
||||
Set<String> items = FactionsPlugin.getInstance().getFileManager().getShop().getConfig().getConfigurationSection("items").getKeys(false);
|
||||
for (String s : items) {
|
||||
if (checkShopConfig(s) == false) {
|
||||
ret = false;
|
||||
}
|
||||
}
|
||||
return ret;
|
||||
}
|
||||
|
||||
public boolean checkShopConfig(String s) {
|
||||
boolean ret = true;
|
||||
if (!FactionsPlugin.getInstance().getFileManager().getShop().containsKey("items." + s + ".slot")) {
|
||||
FactionsPlugin.getInstance().log(Level.WARNING, "Problem with config item '" + s + "' missing slot variable");
|
||||
ret = false;
|
||||
}
|
||||
if (!FactionsPlugin.getInstance().getFileManager().getShop().containsKey("items." + s + ".block")) {
|
||||
FactionsPlugin.getInstance().log(Level.WARNING, "Problem with config item '" + s + "' missing block variable");
|
||||
ret = false;
|
||||
}
|
||||
|
||||
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;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -134,6 +134,7 @@ public enum Permission {
|
||||
SCOREBOARD("scoreboard"),
|
||||
SEECHUNK("seechunk"),
|
||||
SETWARP("setwarp"),
|
||||
SHIELD("shield"),
|
||||
SHOP("shop"),
|
||||
TOP("top"),
|
||||
VIEWCHEST("viewchest"),
|
||||
|
||||
@@ -1,8 +1,8 @@
|
||||
package com.massivecraft.factions.struct;
|
||||
|
||||
import com.cryptomorin.xseries.XMaterial;
|
||||
import com.massivecraft.factions.Conf;
|
||||
import com.massivecraft.factions.FactionsPlugin;
|
||||
import com.massivecraft.factions.util.XMaterial;
|
||||
import com.massivecraft.factions.zcore.fperms.Permissable;
|
||||
import com.massivecraft.factions.zcore.util.TL;
|
||||
import org.bukkit.ChatColor;
|
||||
|
||||
@@ -1,8 +1,8 @@
|
||||
package com.massivecraft.factions.struct;
|
||||
|
||||
import com.cryptomorin.xseries.XMaterial;
|
||||
import com.massivecraft.factions.Conf;
|
||||
import com.massivecraft.factions.FactionsPlugin;
|
||||
import com.massivecraft.factions.util.XMaterial;
|
||||
import com.massivecraft.factions.zcore.fperms.Permissable;
|
||||
import com.massivecraft.factions.zcore.util.TL;
|
||||
import org.bukkit.ChatColor;
|
||||
@@ -55,9 +55,9 @@ public enum Role implements Permissable {
|
||||
return COLEADER;
|
||||
case 4:
|
||||
return LEADER;
|
||||
default:
|
||||
throw new IllegalStateException("Unexpected value: " + value);
|
||||
}
|
||||
|
||||
return null;
|
||||
}
|
||||
|
||||
public static Role fromString(String check) {
|
||||
@@ -76,9 +76,9 @@ public enum Role implements Permissable {
|
||||
case "recruit":
|
||||
case "rec":
|
||||
return RECRUIT;
|
||||
default:
|
||||
throw new IllegalStateException("Unexpected value: " + check.toLowerCase());
|
||||
}
|
||||
|
||||
return null;
|
||||
}
|
||||
|
||||
public boolean isAtLeast(Role role) {
|
||||
|
||||
@@ -17,27 +17,27 @@ public enum FactionTag implements Tag {
|
||||
* @author FactionsUUID Team
|
||||
*/
|
||||
|
||||
HOME_X("{x}", fac -> fac.hasHome() ? String.valueOf(fac.getHome().getBlockX()) : Tag.isMinimalShow() ? null : "{ig}"),
|
||||
HOME_Y("{y}", fac -> fac.hasHome() ? String.valueOf(fac.getHome().getBlockY()) : Tag.isMinimalShow() ? null : "{ig}"),
|
||||
HOME_Z("{z}", fac -> fac.hasHome() ? String.valueOf(fac.getHome().getBlockZ()) : Tag.isMinimalShow() ? null : "{ig}"),
|
||||
CHUNKS("{chunks}", fac -> String.valueOf(fac.getLandRounded())),
|
||||
WARPS("{warps}", fac -> String.valueOf(fac.getWarps().size())),
|
||||
HOME_X("{x}", (fac) -> fac.hasHome() ? String.valueOf(fac.getHome().getBlockX()) : Tag.isMinimalShow() ? null : "{ig}"),
|
||||
HOME_Y("{y}", (fac) -> fac.hasHome() ? String.valueOf(fac.getHome().getBlockY()) : Tag.isMinimalShow() ? null : "{ig}"),
|
||||
HOME_Z("{z}", (fac) -> fac.hasHome() ? String.valueOf(fac.getHome().getBlockZ()) : Tag.isMinimalShow() ? null : "{ig}"),
|
||||
CHUNKS("{chunks}", (fac) -> String.valueOf(fac.getLandRounded())),
|
||||
WARPS("{warps}", (fac) -> String.valueOf(fac.getWarps().size())),
|
||||
HEADER("{header}", (fac, fp) -> FactionsPlugin.getInstance().txt.titleize(fac.getTag(fp))),
|
||||
POWER("{power}", fac -> String.valueOf(fac.getPowerRounded())),
|
||||
MAX_POWER("{maxPower}", fac -> String.valueOf(fac.getPowerMaxRounded())),
|
||||
POWER_BOOST("{power-boost}", fac -> {
|
||||
POWER("{power}", (fac) -> String.valueOf(fac.getPowerRounded())),
|
||||
MAX_POWER("{maxPower}", (fac) -> String.valueOf(fac.getPowerMaxRounded())),
|
||||
POWER_BOOST("{power-boost}", (fac) -> {
|
||||
double powerBoost = fac.getPowerBoost();
|
||||
return (powerBoost == 0.0) ? "" : (powerBoost > 0.0 ? TL.COMMAND_SHOW_BONUS.toString() : TL.COMMAND_SHOW_PENALTY.toString() + powerBoost + ")");
|
||||
}),
|
||||
LEADER("{leader}", fac -> {
|
||||
LEADER("{leader}", (fac) -> {
|
||||
FPlayer fAdmin = fac.getFPlayerAdmin();
|
||||
return fAdmin == null ? "Server" : fAdmin.getName().substring(0, fAdmin.getName().length() > 14 ? 13 : fAdmin.getName().length());
|
||||
}),
|
||||
JOINING("{joining}", fac -> (fac.getOpen() ? TL.COMMAND_SHOW_UNINVITED.toString() : TL.COMMAND_SHOW_INVITATION.toString())),
|
||||
JOINING("{joining}", (fac) -> (fac.getOpen() ? TL.COMMAND_SHOW_UNINVITED.toString() : TL.COMMAND_SHOW_INVITATION.toString())),
|
||||
FACTION("{faction}", (Function<Faction, String>) Faction::getTag),
|
||||
FACTION_RELATION_COLOR("{faction-relation-color}", (fac, fp) -> fp == null ? "" : fp.getColorTo(fac).toString()),
|
||||
HOME_WORLD("{world}", fac -> fac.hasHome() ? fac.getHome().getWorld().getName() : Tag.isMinimalShow() ? null : "{ig}"),
|
||||
RAIDABLE("{raidable}", fac -> {
|
||||
HOME_WORLD("{world}", (fac) -> fac.hasHome() ? fac.getHome().getWorld().getName() : Tag.isMinimalShow() ? null : "{ig}"),
|
||||
RAIDABLE("{raidable}", (fac) -> {
|
||||
if (FactionsPlugin.getInstance().getConfig().getBoolean("hcf.raidable", false)) {
|
||||
boolean raidable = fac.getLandRounded() >= fac.getPowerRounded();
|
||||
String str = raidable ? TL.RAIDABLE_TRUE.toString() : TL.RAIDABLE_FALSE.toString();
|
||||
@@ -50,35 +50,37 @@ public enum FactionTag implements Tag {
|
||||
return null;
|
||||
}),
|
||||
|
||||
ANNOUNCEMENT("{announcement}", fac -> String.valueOf(fac.getAnnouncements())),
|
||||
PEACEFUL("{peaceful}", fac -> fac.isPeaceful() ? Conf.colorNeutral + TL.COMMAND_SHOW_PEACEFUL.toString() : ""),
|
||||
PERMANENT("permanent", fac -> fac.isPermanent() ? "permanent" : "{notPermanent}"), // no braces needed
|
||||
LAND_VALUE("{land-value}", fac -> Econ.shouldBeUsed() ? Econ.moneyString(Econ.calculateTotalLandValue(fac.getLandRounded())) : Tag.isMinimalShow() ? null : TL.ECON_OFF.format("value")),
|
||||
ANNOUNCEMENT("{announcement}", (fac) -> {
|
||||
return String.valueOf(fac.getAnnouncements());
|
||||
}),
|
||||
PEACEFUL("{peaceful}", (fac) -> fac.isPeaceful() ? Conf.colorNeutral + TL.COMMAND_SHOW_PEACEFUL.toString() : ""),
|
||||
PERMANENT("permanent", (fac) -> fac.isPermanent() ? "permanent" : "{notPermanent}"), // no braces needed
|
||||
LAND_VALUE("{land-value}", (fac) -> Econ.shouldBeUsed() ? Econ.moneyString(Econ.calculateTotalLandValue(fac.getLandRounded())) : Tag.isMinimalShow() ? null : TL.ECON_OFF.format("value")),
|
||||
DESCRIPTION("{description}", Faction::getDescription),
|
||||
CREATE_DATE("{create-date}", fac -> TL.sdf.format(fac.getFoundedDate())),
|
||||
LAND_REFUND("{land-refund}", fac -> Econ.shouldBeUsed() ? Econ.moneyString(Econ.calculateTotalLandRefund(fac.getLandRounded())) : Tag.isMinimalShow() ? null : TL.ECON_OFF.format("refund")),
|
||||
BANK_BALANCE("{faction-balance}", fac -> {
|
||||
CREATE_DATE("{create-date}", (fac) -> TL.sdf.format(fac.getFoundedDate())),
|
||||
LAND_REFUND("{land-refund}", (fac) -> Econ.shouldBeUsed() ? Econ.moneyString(Econ.calculateTotalLandRefund(fac.getLandRounded())) : Tag.isMinimalShow() ? null : TL.ECON_OFF.format("refund")),
|
||||
BANK_BALANCE("{faction-balance}", (fac) -> {
|
||||
if (Econ.shouldBeUsed()) {
|
||||
return Conf.bankEnabled ? Econ.moneyString(Econ.getBalance(fac.getAccountId())) : Tag.isMinimalShow() ? null : TL.ECON_OFF.format("balance");
|
||||
}
|
||||
return Tag.isMinimalShow() ? null : TL.ECON_OFF.format("balance");
|
||||
}),
|
||||
TNT_BALANCE("{tnt-balance}", fac -> {
|
||||
TNT_BALANCE("{tnt-balance}", (fac) -> {
|
||||
if (FactionsPlugin.instance.getConfig().getBoolean("ftnt.Enabled")) {
|
||||
return String.valueOf(fac.getTnt());
|
||||
}
|
||||
return Tag.isMinimalShow() ? null : "";
|
||||
}),
|
||||
TNT_MAX("{tnt-max-balance}", fac -> {
|
||||
TNT_MAX("{tnt-max-balance}", (fac) -> {
|
||||
if (FactionsPlugin.instance.getConfig().getBoolean("ftnt.Enabled")) {
|
||||
return String.valueOf(fac.getTntBankLimit());
|
||||
}
|
||||
return Tag.isMinimalShow() ? null : "";
|
||||
}),
|
||||
|
||||
ALLIES_COUNT("{allies}", fac -> String.valueOf(fac.getRelationCount(Relation.ALLY))),
|
||||
ENEMIES_COUNT("{enemies}", fac -> String.valueOf(fac.getRelationCount(Relation.ENEMY))),
|
||||
TRUCES_COUNT("{truces}", fac -> String.valueOf(fac.getRelationCount(Relation.TRUCE))),
|
||||
ALLIES_COUNT("{allies}", (fac) -> String.valueOf(fac.getRelationCount(Relation.ALLY))),
|
||||
ENEMIES_COUNT("{enemies}", (fac) -> String.valueOf(fac.getRelationCount(Relation.ENEMY))),
|
||||
TRUCES_COUNT("{truces}", (fac) -> String.valueOf(fac.getRelationCount(Relation.TRUCE))),
|
||||
ONLINE_COUNT("{online}", (fac, fp) -> {
|
||||
if (fp != null && fp.isOnline()) {
|
||||
return String.valueOf(fac.getFPlayersWhereOnline(true, fp).size());
|
||||
@@ -95,12 +97,12 @@ public enum FactionTag implements Tag {
|
||||
return String.valueOf(fac.getFPlayersWhereOnline(false).size());
|
||||
}
|
||||
}),
|
||||
FACTION_STRIKES("{faction-strikes}", fac -> String.valueOf(fac.getStrikes())),
|
||||
FACTION_POINTS("{faction-points}", fac -> String.valueOf(fac.getPoints())),
|
||||
FACTION_SIZE("{members}", fac -> String.valueOf(fac.getFPlayers().size())),
|
||||
FACTION_KILLS("{faction-kills}", fac -> String.valueOf(fac.getKills())),
|
||||
FACTION_DEATHS("{faction-deaths}", fac -> String.valueOf(fac.getDeaths())),
|
||||
FACTION_BANCOUNT("{faction-bancount}", fac -> String.valueOf(fac.getBannedPlayers().size())),
|
||||
FACTION_STRIKES("{faction-strikes}", (fac) -> String.valueOf(fac.getStrikes())),
|
||||
FACTION_POINTS("{faction-points}", (fac) -> String.valueOf(fac.getPoints())),
|
||||
FACTION_SIZE("{members}", (fac) -> String.valueOf(fac.getFPlayers().size())),
|
||||
FACTION_KILLS("{faction-kills}", (fac) -> String.valueOf(fac.getKills())),
|
||||
FACTION_DEATHS("{faction-deaths}", (fac) -> String.valueOf(fac.getDeaths())),
|
||||
FACTION_BANCOUNT("{faction-bancount}", (fac) -> String.valueOf(fac.getBannedPlayers().size())),
|
||||
;
|
||||
|
||||
private final String tag;
|
||||
|
||||
@@ -177,7 +177,7 @@ public enum FancyTag implements Tag {
|
||||
|
||||
public List getMessage(String text, Faction faction, FPlayer player, Map<UUID, String> groupMap) {
|
||||
if (!this.foundInString(text)) {
|
||||
return Collections.emptyList(); // We really, really shouldn't be here.
|
||||
return Collections.EMPTY_LIST; // We really, really shouldn't be here.
|
||||
}
|
||||
return this.function.apply(faction, player, text.replace(this.getTag(), ""), groupMap);
|
||||
}
|
||||
|
||||
@@ -10,8 +10,8 @@ import java.util.logging.Level;
|
||||
|
||||
public class AutoLeaveProcessTask extends BukkitRunnable {
|
||||
|
||||
private transient boolean readyToGo;
|
||||
private transient boolean finished;
|
||||
private transient boolean readyToGo = false;
|
||||
private transient boolean finished = false;
|
||||
private transient ListIterator<FPlayer> iterator;
|
||||
private transient double toleranceMillis;
|
||||
|
||||
|
||||
@@ -15,12 +15,15 @@ import org.bukkit.ChatColor;
|
||||
import org.bukkit.entity.Player;
|
||||
|
||||
import java.lang.reflect.InvocationTargetException;
|
||||
import java.util.Arrays;
|
||||
import java.util.UUID;
|
||||
import java.util.logging.Level;
|
||||
|
||||
public class ClipPlaceholderAPIManager extends PlaceholderExpansion implements Relational {
|
||||
|
||||
private static void logInvalid(String placeholder) {
|
||||
FactionsPlugin.getInstance().getLogger().log(Level.INFO, "Invalid request through PlaceholderAPI for placeholder '" + placeholder + "'");
|
||||
}
|
||||
|
||||
// Identifier for this expansion
|
||||
@Override
|
||||
public String getIdentifier() {
|
||||
@@ -214,7 +217,7 @@ public class ClipPlaceholderAPIManager extends PlaceholderExpansion implements R
|
||||
case "faction_relation_color":
|
||||
return fPlayer.getColorTo(faction).toString();
|
||||
case "grace_time":
|
||||
if(FactionsPlugin.getInstance().getTimerManager().graceTimer.getRemaining() >= 0) {
|
||||
if (FactionsPlugin.getInstance().getTimerManager().graceTimer.getRemaining() >= 0) {
|
||||
return String.valueOf(TimerManager.getRemaining(FactionsPlugin.getInstance().getTimerManager().graceTimer.getRemaining(), true));
|
||||
} else {
|
||||
return TL.GRACE_DISABLED_PLACEHOLDER.toString();
|
||||
@@ -249,10 +252,6 @@ public class ClipPlaceholderAPIManager extends PlaceholderExpansion implements R
|
||||
return TL.PLACEHOLDERAPI_NULL.toString();
|
||||
}
|
||||
|
||||
private static void logInvalid(String placeholder) {
|
||||
FactionsPlugin.getInstance().getLogger().log(Level.INFO, "Invalid request through PlaceholderAPI for placeholder '" + placeholder + "'");
|
||||
}
|
||||
|
||||
private int countOn(Faction f, Relation relation, Boolean status, FPlayer player) {
|
||||
int count = 0;
|
||||
for (Faction faction : Factions.getInstance().getAllFactions()) {
|
||||
|
||||
@@ -3,7 +3,6 @@ package com.massivecraft.factions.util;
|
||||
import com.massivecraft.factions.FactionsPlugin;
|
||||
import org.bukkit.entity.Player;
|
||||
import org.bukkit.metadata.FixedMetadataValue;
|
||||
import org.bukkit.metadata.MetadataValue;
|
||||
|
||||
import java.util.concurrent.TimeUnit;
|
||||
|
||||
@@ -19,7 +18,7 @@ public class Cooldown {
|
||||
}
|
||||
|
||||
public static boolean isOnCooldown(Player player, String name) {
|
||||
if (!player.hasMetadata(name) || player.getMetadata(name).isEmpty()) return false;
|
||||
if (!player.hasMetadata(name) || player.getMetadata(name).size() <= 0) return false;
|
||||
long time = player.getMetadata(name).get(0).asLong();
|
||||
return (time > System.currentTimeMillis());
|
||||
}
|
||||
|
||||
@@ -15,7 +15,7 @@ import java.io.IOException;
|
||||
public class InventoryUtil {
|
||||
|
||||
|
||||
public static String InventoryToString(ItemStack[] items) {
|
||||
public static String InventoryToString(ItemStack[] items) throws IllegalStateException {
|
||||
try {
|
||||
ByteArrayOutputStream outputStream = new ByteArrayOutputStream();
|
||||
BukkitObjectOutputStream dataOutput = new BukkitObjectOutputStream(outputStream);
|
||||
|
||||
@@ -109,6 +109,8 @@ public class MiscUtil {
|
||||
|
||||
switch (player.getRole()) {
|
||||
case LEADER:
|
||||
admins.add(player);
|
||||
break;
|
||||
case COLEADER:
|
||||
admins.add(player);
|
||||
break;
|
||||
|
||||
@@ -6,6 +6,7 @@ package com.massivecraft.factions.util;
|
||||
* Creation Date: 4/4/2020
|
||||
*/
|
||||
|
||||
import com.cryptomorin.xseries.XMaterial;
|
||||
import org.bukkit.Bukkit;
|
||||
import org.bukkit.Color;
|
||||
import org.bukkit.Location;
|
||||
|
||||
@@ -20,6 +20,8 @@ public class RelationUtil {
|
||||
}
|
||||
|
||||
Faction myFaction = getFaction(me);
|
||||
// if (myFaction == null) return that.describeTo(null); // no relation, but can show basic name or tag
|
||||
|
||||
if (that instanceof Faction) {
|
||||
if (me instanceof FPlayer && myFaction == thatFaction) {
|
||||
ret = TL.GENERIC_YOURFACTION.toString();
|
||||
|
||||
@@ -187,6 +187,7 @@ public abstract class SpiralTask implements Runnable {
|
||||
|
||||
// for successful completion
|
||||
public void finish() {
|
||||
// FactionsPlugin.getInstance().log("SpiralTask successfully completed!");
|
||||
this.stop();
|
||||
}
|
||||
|
||||
|
||||
@@ -16,7 +16,8 @@ public class VisualizeUtil {
|
||||
}
|
||||
|
||||
public static Set<Location> getPlayerLocations(UUID uuid) {
|
||||
return playerLocations.computeIfAbsent(uuid, k -> new HashSet<>());
|
||||
Set<Location> ret = playerLocations.computeIfAbsent(uuid, k -> new HashSet<>());
|
||||
return ret;
|
||||
}
|
||||
|
||||
@SuppressWarnings("deprecation")
|
||||
|
||||
File diff suppressed because it is too large
Load Diff
@@ -0,0 +1,37 @@
|
||||
package com.massivecraft.factions.util.adapters;
|
||||
|
||||
import com.google.gson.*;
|
||||
import com.massivecraft.factions.cmd.shields.struct.ShieldTCMP;
|
||||
import com.massivecraft.factions.cmd.shields.struct.frame.ShieldFramePersistence;
|
||||
|
||||
import java.lang.reflect.Type;
|
||||
|
||||
/**
|
||||
* Factions - Developed by ImCarib.
|
||||
* All rights reserved 2020.
|
||||
* Creation Date: 5/23/2020
|
||||
*/
|
||||
public class ShieldFrameAdapter implements JsonDeserializer<ShieldFramePersistence>, JsonSerializer<ShieldFramePersistence> {
|
||||
|
||||
public ShieldFramePersistence deserialize(JsonElement json, Type typeOfT, JsonDeserializationContext context) throws JsonParseException {
|
||||
try {
|
||||
JsonObject obj = json.getAsJsonObject();
|
||||
int frame = obj.get("id").getAsInt();
|
||||
return ShieldTCMP.getInstance().getByStart(frame);
|
||||
} catch (Exception ex) {
|
||||
ex.printStackTrace();
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
||||
public JsonElement serialize(ShieldFramePersistence src, Type typeOfSrc, JsonSerializationContext context) {
|
||||
JsonObject obj = new JsonObject();
|
||||
try {
|
||||
obj.addProperty("id", src.getStartParsed());
|
||||
return obj;
|
||||
} catch (Exception ex) {
|
||||
ex.printStackTrace();
|
||||
return obj;
|
||||
}
|
||||
}
|
||||
}
|
||||
Some files were not shown because too many files have changed in this diff Show More
Reference in New Issue
Block a user