Compare commits
40 Commits
Author | SHA1 | Date | |
---|---|---|---|
5d3fe2a2f4 | |||
|
1becd7b299 | ||
|
f7c9de0664 | ||
|
7667e69cf2 | ||
1383e451f1 | |||
|
677c609ec8 | ||
|
09f1df49a9 | ||
|
dd94b45347 | ||
|
28b07fc6a4 | ||
|
11ea9bc1aa | ||
|
7f922fef28 | ||
|
81ef43768d | ||
|
1a19ee77ba | ||
|
0444517eec | ||
|
03077b62ba | ||
|
d98c647397 | ||
|
e9923344a2 | ||
|
cdc07ed5eb | ||
|
7b94367eb4 | ||
|
b7d991c0dd | ||
|
6372245fcd | ||
|
f2c0f725b7 | ||
|
0b677cb4de | ||
|
e8642a3108 | ||
|
a355b1d0c8 | ||
|
929c34d850 | ||
|
903129e462 | ||
|
e84c69f2b0 | ||
|
3e530487d7 | ||
|
14776b8877 | ||
|
24aaa0ed6f | ||
|
2a01682fbe | ||
|
ba59310548 | ||
|
bec09168b6 | ||
|
4fe6484db9 | ||
|
71a099beeb | ||
|
ddd3150732 | ||
|
ec1501bf4f | ||
|
8ad2fdf848 | ||
|
1ee62c2267 |
33
pom.xml
33
pom.xml
@ -4,7 +4,7 @@
|
|||||||
|
|
||||||
<groupId>com.massivecraft</groupId>
|
<groupId>com.massivecraft</groupId>
|
||||||
<artifactId>Factions</artifactId>
|
<artifactId>Factions</artifactId>
|
||||||
<version>1.6.9.5-2.3.7-RC</version>
|
<version>1.6.9.5-2.4.1-RC</version>
|
||||||
<packaging>jar</packaging>
|
<packaging>jar</packaging>
|
||||||
|
|
||||||
<name>SaberFactions</name>
|
<name>SaberFactions</name>
|
||||||
@ -99,12 +99,6 @@
|
|||||||
<version>1.3</version>
|
<version>1.3</version>
|
||||||
<scope>compile</scope>
|
<scope>compile</scope>
|
||||||
</dependency>
|
</dependency>
|
||||||
<dependency>
|
|
||||||
<groupId>com.mojang</groupId>
|
|
||||||
<artifactId>brigadier</artifactId>
|
|
||||||
<version>1.0.14</version>
|
|
||||||
<scope>compile</scope>
|
|
||||||
</dependency>
|
|
||||||
<dependency>
|
<dependency>
|
||||||
<groupId>com.github.stefvanschie.inventoryframework</groupId>
|
<groupId>com.github.stefvanschie.inventoryframework</groupId>
|
||||||
<artifactId>IF</artifactId>
|
<artifactId>IF</artifactId>
|
||||||
@ -138,11 +132,6 @@
|
|||||||
</exclusion>
|
</exclusion>
|
||||||
</exclusions>
|
</exclusions>
|
||||||
</dependency>
|
</dependency>
|
||||||
<dependency>
|
|
||||||
<groupId>org.ocpsoft.prettytime</groupId>
|
|
||||||
<artifactId>prettytime</artifactId>
|
|
||||||
<version>4.0.0.Final</version>
|
|
||||||
</dependency>
|
|
||||||
<dependency>
|
<dependency>
|
||||||
<groupId>net.milkbowl.vault</groupId>
|
<groupId>net.milkbowl.vault</groupId>
|
||||||
<artifactId>VaultAPI</artifactId>
|
<artifactId>VaultAPI</artifactId>
|
||||||
@ -297,8 +286,12 @@
|
|||||||
<scope>compile</scope>
|
<scope>compile</scope>
|
||||||
<exclusions>
|
<exclusions>
|
||||||
<exclusion>
|
<exclusion>
|
||||||
<artifactId>gson</artifactId>
|
<artifactId>*</artifactId>
|
||||||
<groupId>com.google.code.gson</groupId>
|
<groupId>shaded</groupId>
|
||||||
|
</exclusion>
|
||||||
|
<exclusion>
|
||||||
|
<artifactId>*</artifactId>
|
||||||
|
<groupId>gson</groupId>
|
||||||
</exclusion>
|
</exclusion>
|
||||||
</exclusions>
|
</exclusions>
|
||||||
</dependency>
|
</dependency>
|
||||||
@ -350,12 +343,6 @@
|
|||||||
</exclusion>
|
</exclusion>
|
||||||
</exclusions>
|
</exclusions>
|
||||||
</dependency>
|
</dependency>
|
||||||
<dependency>
|
|
||||||
<groupId>com.google.code.gson</groupId>
|
|
||||||
<artifactId>gson</artifactId>
|
|
||||||
<version>2.8.5</version>
|
|
||||||
<scope>compile</scope>
|
|
||||||
</dependency>
|
|
||||||
<dependency>
|
<dependency>
|
||||||
<groupId>me.clip</groupId>
|
<groupId>me.clip</groupId>
|
||||||
<artifactId>placeholderapi</artifactId>
|
<artifactId>placeholderapi</artifactId>
|
||||||
@ -398,6 +385,12 @@
|
|||||||
<artifactId>authlib</artifactId>
|
<artifactId>authlib</artifactId>
|
||||||
<version>1.5.21</version>
|
<version>1.5.21</version>
|
||||||
<scope>compile</scope>
|
<scope>compile</scope>
|
||||||
|
<exclusions>
|
||||||
|
<exclusion>
|
||||||
|
<groupId>org.apache.logging.log4j</groupId>
|
||||||
|
<artifactId>*</artifactId>
|
||||||
|
</exclusion>
|
||||||
|
</exclusions>
|
||||||
</dependency>
|
</dependency>
|
||||||
<dependency>
|
<dependency>
|
||||||
<groupId>me.rayzr522</groupId>
|
<groupId>me.rayzr522</groupId>
|
||||||
|
@ -268,6 +268,7 @@ public class Conf {
|
|||||||
public static boolean ownedMessageInsideTerritory = true;
|
public static boolean ownedMessageInsideTerritory = true;
|
||||||
public static boolean ownedMessageByChunk = false;
|
public static boolean ownedMessageByChunk = false;
|
||||||
public static boolean pistonProtectionThroughDenyBuild = true;
|
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> territoryProtectedMaterials = EnumSet.noneOf(Material.class);
|
||||||
public static Set<Material> territoryDenyUsageMaterials = EnumSet.noneOf(Material.class);
|
public static Set<Material> territoryDenyUsageMaterials = EnumSet.noneOf(Material.class);
|
||||||
public static Set<Material> territoryProtectedMaterialsWhenOffline = EnumSet.noneOf(Material.class);
|
public static Set<Material> territoryProtectedMaterialsWhenOffline = EnumSet.noneOf(Material.class);
|
||||||
@ -576,7 +577,7 @@ public class Conf {
|
|||||||
safeZoneNerfedCreatureTypes.add(EntityType.ENDERMAN);
|
safeZoneNerfedCreatureTypes.add(EntityType.ENDERMAN);
|
||||||
safeZoneNerfedCreatureTypes.add(EntityType.GHAST);
|
safeZoneNerfedCreatureTypes.add(EntityType.GHAST);
|
||||||
safeZoneNerfedCreatureTypes.add(EntityType.MAGMA_CUBE);
|
safeZoneNerfedCreatureTypes.add(EntityType.MAGMA_CUBE);
|
||||||
safeZoneNerfedCreatureTypes.add(EntityType.PIG_ZOMBIE);
|
if (!FactionsPlugin.getInstance().mc116) safeZoneNerfedCreatureTypes.add(EntityType.PIG_ZOMBIE);
|
||||||
safeZoneNerfedCreatureTypes.add(EntityType.SILVERFISH);
|
safeZoneNerfedCreatureTypes.add(EntityType.SILVERFISH);
|
||||||
safeZoneNerfedCreatureTypes.add(EntityType.SKELETON);
|
safeZoneNerfedCreatureTypes.add(EntityType.SKELETON);
|
||||||
safeZoneNerfedCreatureTypes.add(EntityType.SPIDER);
|
safeZoneNerfedCreatureTypes.add(EntityType.SPIDER);
|
||||||
|
@ -81,6 +81,7 @@ public class FactionsPlugin extends MPlugin {
|
|||||||
public boolean mc113 = false;
|
public boolean mc113 = false;
|
||||||
public boolean mc114 = false;
|
public boolean mc114 = false;
|
||||||
public boolean mc115 = false;
|
public boolean mc115 = false;
|
||||||
|
public boolean mc116 = false;
|
||||||
public boolean useNonPacketParticles = false;
|
public boolean useNonPacketParticles = false;
|
||||||
public List<String> itemList = getConfig().getStringList("fchest.Items-Not-Allowed");
|
public List<String> itemList = getConfig().getStringList("fchest.Items-Not-Allowed");
|
||||||
SkriptAddon skriptAddon;
|
SkriptAddon skriptAddon;
|
||||||
@ -167,14 +168,16 @@ public class FactionsPlugin extends MPlugin {
|
|||||||
FactionsPlugin.instance.log("Minecraft Version 1.15 found.");
|
FactionsPlugin.instance.log("Minecraft Version 1.15 found.");
|
||||||
mc115 = true;
|
mc115 = true;
|
||||||
break;
|
break;
|
||||||
default:
|
case 16:
|
||||||
throw new IllegalStateException("Unexpected value: " + version);
|
FactionsPlugin.instance.log("Minecraft Version 1.16 found.");
|
||||||
|
mc116 = true;
|
||||||
|
break;
|
||||||
}
|
}
|
||||||
migrateFPlayerLeaders();
|
migrateFPlayerLeaders();
|
||||||
log("==== End Setup ====");
|
log("==== End Setup ====");
|
||||||
|
|
||||||
int pluginId = 7013;
|
int pluginId = 7013;
|
||||||
new Metrics(this, pluginId);
|
Metrics metrics = new Metrics(this, pluginId);
|
||||||
|
|
||||||
if (!preEnable()) {
|
if (!preEnable()) {
|
||||||
this.loadSuccessful = false;
|
this.loadSuccessful = false;
|
||||||
@ -182,6 +185,7 @@ public class FactionsPlugin extends MPlugin {
|
|||||||
}
|
}
|
||||||
|
|
||||||
saveDefaultConfig();
|
saveDefaultConfig();
|
||||||
|
this.reloadConfig();
|
||||||
//Start wait task executor
|
//Start wait task executor
|
||||||
WaitExecutor.startTask();
|
WaitExecutor.startTask();
|
||||||
// Load Conf from disk
|
// Load Conf from disk
|
||||||
@ -396,12 +400,14 @@ public class FactionsPlugin extends MPlugin {
|
|||||||
return this.mvdwPlaceholderAPIManager;
|
return this.mvdwPlaceholderAPIManager;
|
||||||
}
|
}
|
||||||
|
|
||||||
private void setupPermissions() {
|
private boolean setupPermissions() {
|
||||||
try {
|
try {
|
||||||
RegisteredServiceProvider<Permission> rsp = getServer().getServicesManager().getRegistration(Permission.class);
|
RegisteredServiceProvider<Permission> rsp = getServer().getServicesManager().getRegistration(Permission.class);
|
||||||
if (rsp != null) perms = rsp.getProvider();
|
if (rsp != null) perms = rsp.getProvider();
|
||||||
} catch (NoClassDefFoundError ignored) {
|
} catch (NoClassDefFoundError ex) {
|
||||||
|
return false;
|
||||||
}
|
}
|
||||||
|
return perms != null;
|
||||||
}
|
}
|
||||||
|
|
||||||
private boolean setupPlayervaults() {
|
private boolean setupPlayervaults() {
|
||||||
|
@ -57,7 +57,7 @@ public class CmdAdmin extends FCommand {
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
if(fyou.isAlt()){
|
if (fyou.isAlt()) {
|
||||||
return;
|
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");
|
FactionsPlugin.instance.getFlogManager().log(targetFaction, FLogType.RANK_EDIT, context.fPlayer.getName(), fyou.getName(), ChatColor.RED + "Admin");
|
||||||
|
|
||||||
// Inform all players
|
// 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()) {
|
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));
|
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;
|
return TL.COMMAND_ANNOUNCE_DESCRIPTION;
|
||||||
}
|
}
|
||||||
|
|
||||||
protected static class AnnounceBrigadier implements BrigadierProvider {
|
protected class AnnounceBrigadier implements BrigadierProvider {
|
||||||
@Override
|
@Override
|
||||||
public ArgumentBuilder<Object, ?> get(ArgumentBuilder<Object, ?> parent) {
|
public ArgumentBuilder<Object, ?> get(ArgumentBuilder<Object, ?> parent) {
|
||||||
return parent.then(RequiredArgumentBuilder.argument("message", StringArgumentType.greedyString()));
|
return parent.then(RequiredArgumentBuilder.argument("message", StringArgumentType.greedyString()));
|
||||||
|
@ -60,6 +60,7 @@ public class CmdBanner extends FCommand {
|
|||||||
@Deprecated
|
@Deprecated
|
||||||
public void takeMoney(FPlayer fme, int amt) {
|
public void takeMoney(FPlayer fme, int amt) {
|
||||||
if (this.hasMoney(fme, amt)) {
|
if (this.hasMoney(fme, amt)) {
|
||||||
|
Economy econ = FactionsPlugin.getInstance().getEcon();
|
||||||
fme.sendMessage(TL.COMMAND_BANNER_MONEYTAKE.toString().replace("{amount}", amt + ""));
|
fme.sendMessage(TL.COMMAND_BANNER_MONEYTAKE.toString().replace("{amount}", amt + ""));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -14,6 +14,7 @@ public class CmdBoom extends FCommand {
|
|||||||
super();
|
super();
|
||||||
this.aliases.addAll(Aliases.boom);
|
this.aliases.addAll(Aliases.boom);
|
||||||
|
|
||||||
|
//this.requiredArgs.add("");
|
||||||
this.optionalArgs.put("on/off", "flip");
|
this.optionalArgs.put("on/off", "flip");
|
||||||
|
|
||||||
this.requirements = new CommandRequirements.Builder(Permission.NO_BOOM)
|
this.requirements = new CommandRequirements.Builder(Permission.NO_BOOM)
|
||||||
|
@ -14,6 +14,7 @@ public class CmdBypass extends FCommand {
|
|||||||
super();
|
super();
|
||||||
this.aliases.addAll(Aliases.bypass);
|
this.aliases.addAll(Aliases.bypass);
|
||||||
|
|
||||||
|
//this.requiredArgs.add("");
|
||||||
this.optionalArgs.put("on/off", "flip");
|
this.optionalArgs.put("on/off", "flip");
|
||||||
|
|
||||||
this.requirements = new CommandRequirements.Builder(Permission.BYPASS)
|
this.requirements = new CommandRequirements.Builder(Permission.BYPASS)
|
||||||
|
@ -18,6 +18,7 @@ public class CmdChat extends FCommand {
|
|||||||
super();
|
super();
|
||||||
this.aliases.addAll(Aliases.chat);
|
this.aliases.addAll(Aliases.chat);
|
||||||
|
|
||||||
|
//this.requiredArgs.add("");
|
||||||
this.optionalArgs.put("mode", "next");
|
this.optionalArgs.put("mode", "next");
|
||||||
|
|
||||||
this.requirements = new CommandRequirements.Builder(Permission.CHAT)
|
this.requirements = new CommandRequirements.Builder(Permission.CHAT)
|
||||||
@ -85,7 +86,7 @@ public class CmdChat extends FCommand {
|
|||||||
return TL.COMMAND_CHAT_DESCRIPTION;
|
return TL.COMMAND_CHAT_DESCRIPTION;
|
||||||
}
|
}
|
||||||
|
|
||||||
protected static class ChatBrigadier implements BrigadierProvider {
|
protected class ChatBrigadier implements BrigadierProvider {
|
||||||
@Override
|
@Override
|
||||||
public ArgumentBuilder<Object, ?> get(ArgumentBuilder<Object, ?> parent) {
|
public ArgumentBuilder<Object, ?> get(ArgumentBuilder<Object, ?> parent) {
|
||||||
return parent.then(LiteralArgumentBuilder.literal("public"))
|
return parent.then(LiteralArgumentBuilder.literal("public"))
|
||||||
|
@ -2,7 +2,10 @@ package com.massivecraft.factions.cmd;
|
|||||||
|
|
||||||
import com.massivecraft.factions.*;
|
import com.massivecraft.factions.*;
|
||||||
import com.massivecraft.factions.struct.Permission;
|
import com.massivecraft.factions.struct.Permission;
|
||||||
|
import com.massivecraft.factions.struct.Role;
|
||||||
import com.massivecraft.factions.util.WarmUpUtil;
|
import com.massivecraft.factions.util.WarmUpUtil;
|
||||||
|
import com.massivecraft.factions.zcore.fperms.Access;
|
||||||
|
import com.massivecraft.factions.zcore.fperms.PermissableAction;
|
||||||
import com.massivecraft.factions.zcore.util.TL;
|
import com.massivecraft.factions.zcore.util.TL;
|
||||||
|
|
||||||
public class CmdCheckpoint extends FCommand {
|
public class CmdCheckpoint extends FCommand {
|
||||||
@ -17,10 +20,7 @@ public class CmdCheckpoint extends FCommand {
|
|||||||
|
|
||||||
this.optionalArgs.put("set", "");
|
this.optionalArgs.put("set", "");
|
||||||
|
|
||||||
this.requirements = new CommandRequirements.Builder(Permission.CHECKPOINT)
|
this.requirements = new CommandRequirements.Builder(Permission.CHECKPOINT).playerOnly().memberOnly().build();
|
||||||
.playerOnly()
|
|
||||||
.memberOnly()
|
|
||||||
.build();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
@ -29,17 +29,39 @@ public class CmdCheckpoint extends FCommand {
|
|||||||
context.msg(TL.COMMAND_CHECKPOINT_DISABLED);
|
context.msg(TL.COMMAND_CHECKPOINT_DISABLED);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
if (context.args.size() == 1) {
|
if (context.args.size() == 1 && context.args.get(0).equalsIgnoreCase("set")) {
|
||||||
FLocation myLocation = new FLocation(context.player.getLocation());
|
if (context.fPlayer.getRole() == Role.LEADER) {
|
||||||
Faction myLocFaction = Board.getInstance().getFactionAt(myLocation);
|
FLocation myLocation = new FLocation(context.player.getLocation());
|
||||||
if (myLocFaction == Factions.getInstance().getWilderness() || myLocFaction == context.faction) {
|
Faction myLocFaction = Board.getInstance().getFactionAt(myLocation);
|
||||||
context.faction.setCheckpoint(context.player.getLocation());
|
if (myLocFaction == Factions.getInstance().getWilderness() || myLocFaction == context.faction) {
|
||||||
context.msg(TL.COMMAND_CHECKPOINT_SET);
|
context.faction.setCheckpoint(context.player.getLocation());
|
||||||
|
context.msg(TL.COMMAND_CHECKPOINT_SET);
|
||||||
|
return;
|
||||||
|
}
|
||||||
} else {
|
} else {
|
||||||
context.msg(TL.COMMAND_CHECKPOINT_INVALIDLOCATION);
|
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) {
|
if (context.faction.getCheckpoint() == null) {
|
||||||
context.msg(TL.COMMAND_CHECKPOINT_NOT_SET);
|
context.msg(TL.COMMAND_CHECKPOINT_NOT_SET);
|
||||||
return;
|
return;
|
||||||
@ -56,8 +78,6 @@ public class CmdCheckpoint extends FCommand {
|
|||||||
} else {
|
} else {
|
||||||
context.msg(TL.COMMAND_CHECKPOINT_CLAIMED);
|
context.msg(TL.COMMAND_CHECKPOINT_CLAIMED);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
@ -55,7 +55,7 @@ public class CmdColeader extends FCommand {
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
if(you.isAlt()){
|
if (you.isAlt()) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -54,7 +54,7 @@ public class CmdCreate extends FCommand {
|
|||||||
return;
|
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);
|
context.msg(TL.COMMAND_COOLDOWN);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
@ -66,7 +66,7 @@ public class CmdCreate extends FCommand {
|
|||||||
}
|
}
|
||||||
|
|
||||||
ArrayList<String> tagValidationErrors = MiscUtil.validateTag(tag);
|
ArrayList<String> tagValidationErrors = MiscUtil.validateTag(tag);
|
||||||
if (tagValidationErrors.isEmpty()) {
|
if (tagValidationErrors.size() > 0) {
|
||||||
context.sendMessage(tagValidationErrors);
|
context.sendMessage(tagValidationErrors);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
@ -3,10 +3,7 @@ package com.massivecraft.factions.cmd;
|
|||||||
import com.massivecraft.factions.Conf;
|
import com.massivecraft.factions.Conf;
|
||||||
import com.massivecraft.factions.FPlayer;
|
import com.massivecraft.factions.FPlayer;
|
||||||
import com.massivecraft.factions.FPlayers;
|
import com.massivecraft.factions.FPlayers;
|
||||||
import com.massivecraft.factions.FactionsPlugin;
|
|
||||||
import com.massivecraft.factions.struct.Permission;
|
import com.massivecraft.factions.struct.Permission;
|
||||||
import com.massivecraft.factions.struct.Role;
|
|
||||||
import com.massivecraft.factions.zcore.fperms.Access;
|
|
||||||
import com.massivecraft.factions.zcore.fperms.PermissableAction;
|
import com.massivecraft.factions.zcore.fperms.PermissableAction;
|
||||||
import com.massivecraft.factions.zcore.util.TL;
|
import com.massivecraft.factions.zcore.util.TL;
|
||||||
import mkremins.fanciful.FancyMessage;
|
import mkremins.fanciful.FancyMessage;
|
||||||
@ -56,6 +53,7 @@ public class CmdDeinvite extends FCommand {
|
|||||||
|
|
||||||
context.faction.msg(TL.COMMAND_DEINVITE_REVOKES, context.fPlayer.describeTo(context.faction), you.describeTo(context.faction));
|
context.faction.msg(TL.COMMAND_DEINVITE_REVOKES, context.fPlayer.describeTo(context.faction), you.describeTo(context.faction));
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public TL getUsageTranslation() {
|
public TL getUsageTranslation() {
|
||||||
return TL.COMMAND_DEINVITE_DESCRIPTION;
|
return TL.COMMAND_DEINVITE_DESCRIPTION;
|
||||||
|
@ -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
|
// 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.
|
// 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);
|
context.faction.setDescription(desc);
|
||||||
Bukkit.getScheduler().scheduleSyncDelayedTask(FactionsPlugin.instance, () -> FactionsPlugin.instance.logFactionEvent(context.faction, FLogType.FDESC_EDIT, context.fPlayer.getName(), desc));
|
Bukkit.getScheduler().scheduleSyncDelayedTask(FactionsPlugin.instance, () -> FactionsPlugin.instance.logFactionEvent(context.faction, FLogType.FDESC_EDIT, context.fPlayer.getName(), desc));
|
||||||
if (!Conf.broadcastDescriptionChanges) {
|
if (!Conf.broadcastDescriptionChanges) {
|
||||||
|
@ -42,8 +42,8 @@ public class CmdDisband extends FCommand {
|
|||||||
|
|
||||||
boolean isMyFaction = context.fPlayer != null && faction == context.faction;
|
boolean isMyFaction = context.fPlayer != null && faction == context.faction;
|
||||||
|
|
||||||
if (!isMyFaction && !Permission.DISBAND_ANY.has(context.sender, true)) {
|
if (!isMyFaction) {
|
||||||
return;
|
if (!Permission.DISBAND_ANY.has(context.sender, true)) return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@ -81,9 +81,13 @@ public class CmdDisband extends FCommand {
|
|||||||
access = true;
|
access = true;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!access && Conf.useDisbandGUI && (!context.fPlayer.isAdminBypassing() || !context.player.isOp()) && !disbandMap.containsKey(context.player.getUniqueId().toString())) {
|
if (!access) {
|
||||||
new FDisbandFrame(context.faction).buildGUI(context.fPlayer);
|
if (Conf.useDisbandGUI && (!context.fPlayer.isAdminBypassing() || !context.player.isOp())) {
|
||||||
return;
|
if (!disbandMap.containsKey(context.player.getUniqueId().toString())) {
|
||||||
|
new FDisbandFrame(context.faction).buildGUI(context.fPlayer);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// check for tnt before disbanding.
|
// check for tnt before disbanding.
|
||||||
|
@ -19,6 +19,7 @@ import java.util.concurrent.ConcurrentHashMap;
|
|||||||
|
|
||||||
public class CmdFly extends FCommand {
|
public class CmdFly extends FCommand {
|
||||||
|
|
||||||
|
public static final boolean fly = FactionsPlugin.getInstance().getConfig().getBoolean("enable-faction-flight");
|
||||||
/**
|
/**
|
||||||
* @author FactionsUUID Team
|
* @author FactionsUUID Team
|
||||||
*/
|
*/
|
||||||
@ -27,8 +28,6 @@ public class CmdFly extends FCommand {
|
|||||||
public static ConcurrentHashMap<String, Boolean> flyMap = new ConcurrentHashMap<>();
|
public static ConcurrentHashMap<String, Boolean> flyMap = new ConcurrentHashMap<>();
|
||||||
public static BukkitTask particleTask = null;
|
public static BukkitTask particleTask = null;
|
||||||
|
|
||||||
public static final boolean fly = FactionsPlugin.getInstance().getConfig().getBoolean("enable-faction-flight");
|
|
||||||
|
|
||||||
|
|
||||||
public CmdFly() {
|
public CmdFly() {
|
||||||
super();
|
super();
|
||||||
@ -65,25 +64,25 @@ public class CmdFly extends FCommand {
|
|||||||
|
|
||||||
if (toFac != fme.getFaction()) {
|
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 (!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;
|
return false;
|
||||||
}
|
}
|
||||||
Access access = toFac.getAccess(fme, PermissableAction.FLY);
|
Access access = toFac.getAccess(fme, PermissableAction.FLY);
|
||||||
if ((!(me.hasPermission(Permission.FLY_ENEMY.node) || access == Access.ALLOW)) && toFac.getRelationTo(fme.getFaction()) == Relation.ENEMY) {
|
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;
|
return false;
|
||||||
}
|
}
|
||||||
if (!(me.hasPermission(Permission.FLY_ALLY.node) || access == Access.ALLOW) && toFac.getRelationTo(fme.getFaction()) == Relation.ALLY) {
|
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;
|
return false;
|
||||||
}
|
}
|
||||||
if (!(me.hasPermission(Permission.FLY_TRUCE.node) || access == Access.ALLOW) && toFac.getRelationTo(fme.getFaction()) == Relation.TRUCE) {
|
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;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!(me.hasPermission(Permission.FLY_NEUTRAL.node) || access == Access.ALLOW) && toFac.getRelationTo(fme.getFaction()) == Relation.NEUTRAL && !toFac.isSystemFaction()) {
|
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 false;
|
||||||
}
|
}
|
||||||
return me.hasPermission(Permission.FLY_FLY.node) && (access != Access.DENY || toFac.isSystemFaction());
|
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 class CmdFriendlyFire extends FCommand {
|
||||||
|
|
||||||
public CmdFriendlyFire(){
|
public CmdFriendlyFire() {
|
||||||
super();
|
super();
|
||||||
this.aliases.addAll(Aliases.friendlyFire);
|
this.aliases.addAll(Aliases.friendlyFire);
|
||||||
|
|
||||||
@ -23,12 +23,12 @@ public class CmdFriendlyFire extends FCommand {
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void perform(CommandContext context) {
|
public void perform(CommandContext context) {
|
||||||
if(!Conf.friendlyFireFPlayersCommand){
|
if (!Conf.friendlyFireFPlayersCommand) {
|
||||||
context.msg(TL.GENERIC_DISABLED, "friendly fire");
|
context.msg(TL.GENERIC_DISABLED, "friendly fire");
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
if(context.fPlayer.hasFriendlyFire()){
|
if (context.fPlayer.hasFriendlyFire()) {
|
||||||
context.fPlayer.setFriendlyFire(false);
|
context.fPlayer.setFriendlyFire(false);
|
||||||
context.msg(TL.COMMAND_FRIENDLY_FIRE_TOGGLE_OFF);
|
context.msg(TL.COMMAND_FRIENDLY_FIRE_TOGGLE_OFF);
|
||||||
} else {
|
} else {
|
||||||
|
@ -88,7 +88,11 @@ public class CmdHome extends FCommand {
|
|||||||
final Location loc = context.player.getLocation().clone();
|
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 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();
|
World w = loc.getWorld();
|
||||||
double x = loc.getX();
|
double x = loc.getX();
|
||||||
|
@ -49,7 +49,6 @@ public class CmdInventorySee extends FCommand {
|
|||||||
|
|
||||||
FPlayer targetInv = context.argAsFPlayer(0);
|
FPlayer targetInv = context.argAsFPlayer(0);
|
||||||
if (targetInv == null || !fplayers.contains(targetInv.getPlayer())) {
|
if (targetInv == null || !fplayers.contains(targetInv.getPlayer())) {
|
||||||
assert targetInv != null;
|
|
||||||
context.msg(TL.PLAYER_NOT_FOUND, Objects.requireNonNull(targetInv.getName()));
|
context.msg(TL.PLAYER_NOT_FOUND, Objects.requireNonNull(targetInv.getName()));
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
@ -9,7 +9,6 @@ import com.massivecraft.factions.util.CC;
|
|||||||
import com.massivecraft.factions.zcore.fperms.PermissableAction;
|
import com.massivecraft.factions.zcore.fperms.PermissableAction;
|
||||||
import com.massivecraft.factions.zcore.util.TL;
|
import com.massivecraft.factions.zcore.util.TL;
|
||||||
import mkremins.fanciful.FancyMessage;
|
import mkremins.fanciful.FancyMessage;
|
||||||
import org.bukkit.ChatColor;
|
|
||||||
|
|
||||||
public class CmdInvite extends FCommand {
|
public class CmdInvite extends FCommand {
|
||||||
|
|
||||||
@ -61,9 +60,9 @@ public class CmdInvite extends FCommand {
|
|||||||
if (target.isOnline()) {
|
if (target.isOnline()) {
|
||||||
// Tooltips, colors, and commands only apply to the string immediately before it.
|
// Tooltips, colors, and commands only apply to the string immediately before it.
|
||||||
FancyMessage message = new FancyMessage(TL.COMMAND_INVITE_INVITEDYOU.toString()
|
FancyMessage message = new FancyMessage(TL.COMMAND_INVITE_INVITEDYOU.toString()
|
||||||
.replace("%1$s", context.fPlayer.describeTo(target, true))
|
.replace("%1$s", context.fPlayer.describeTo(target, true))
|
||||||
.replace("%2$s", context.faction.getTag())
|
.replace("%2$s", context.faction.getTag())
|
||||||
.replace("&", "§"))
|
.replaceAll("&", "§"))
|
||||||
.tooltip(TL.COMMAND_INVITE_CLICKTOJOIN.toString())
|
.tooltip(TL.COMMAND_INVITE_CLICKTOJOIN.toString())
|
||||||
.command("/" + Conf.baseCommandAliases.get(0) + " join " + context.faction.getTag());
|
.command("/" + Conf.baseCommandAliases.get(0) + " join " + context.faction.getTag());
|
||||||
message.send(target.getPlayer());
|
message.send(target.getPlayer());
|
||||||
|
@ -1,19 +1,12 @@
|
|||||||
package com.massivecraft.factions.cmd;
|
package com.massivecraft.factions.cmd;
|
||||||
|
|
||||||
import com.massivecraft.factions.*;
|
import com.massivecraft.factions.*;
|
||||||
import com.massivecraft.factions.cmd.audit.FLogType;
|
|
||||||
import com.massivecraft.factions.discord.Discord;
|
|
||||||
import com.massivecraft.factions.event.FPlayerJoinEvent;
|
import com.massivecraft.factions.event.FPlayerJoinEvent;
|
||||||
import com.massivecraft.factions.struct.Permission;
|
import com.massivecraft.factions.struct.Permission;
|
||||||
import com.massivecraft.factions.util.CC;
|
|
||||||
import com.massivecraft.factions.zcore.frame.fupgrades.UpgradeType;
|
import com.massivecraft.factions.zcore.frame.fupgrades.UpgradeType;
|
||||||
import com.massivecraft.factions.zcore.util.TL;
|
import com.massivecraft.factions.zcore.util.TL;
|
||||||
import net.dv8tion.jda.core.entities.Member;
|
|
||||||
import net.dv8tion.jda.core.exceptions.HierarchyException;
|
|
||||||
import org.bukkit.Bukkit;
|
import org.bukkit.Bukkit;
|
||||||
|
|
||||||
import java.util.Objects;
|
|
||||||
|
|
||||||
public class CmdJoin extends FCommand {
|
public class CmdJoin extends FCommand {
|
||||||
|
|
||||||
public CmdJoin() {
|
public CmdJoin() {
|
||||||
|
@ -1,6 +1,9 @@
|
|||||||
package com.massivecraft.factions.cmd;
|
package com.massivecraft.factions.cmd;
|
||||||
|
|
||||||
import com.massivecraft.factions.*;
|
import com.massivecraft.factions.Conf;
|
||||||
|
import com.massivecraft.factions.FPlayer;
|
||||||
|
import com.massivecraft.factions.Faction;
|
||||||
|
import com.massivecraft.factions.FactionsPlugin;
|
||||||
import com.massivecraft.factions.cmd.audit.FLogType;
|
import com.massivecraft.factions.cmd.audit.FLogType;
|
||||||
import com.massivecraft.factions.event.FPlayerLeaveEvent;
|
import com.massivecraft.factions.event.FPlayerLeaveEvent;
|
||||||
import com.massivecraft.factions.struct.Permission;
|
import com.massivecraft.factions.struct.Permission;
|
||||||
@ -125,7 +128,7 @@ public class CmdKick extends FCommand {
|
|||||||
FactionsPlugin.instance.logFactionEvent(toKickFaction, FLogType.INVITES, context.fPlayer.getName(), CC.Red + "kicked", toKick.getName());
|
FactionsPlugin.instance.logFactionEvent(toKickFaction, FLogType.INVITES, context.fPlayer.getName(), CC.Red + "kicked", toKick.getName());
|
||||||
toKickFaction.deinvite(toKick);
|
toKickFaction.deinvite(toKick);
|
||||||
toKick.resetFactionData();
|
toKick.resetFactionData();
|
||||||
if(!CmdFly.checkBypassPerms(toKick, toKick.getPlayer(), toKickFaction, false)){
|
if (!CmdFly.checkBypassPerms(toKick, toKick.getPlayer(), toKickFaction, false)) {
|
||||||
CmdFly.disableFlight(toKick);
|
CmdFly.disableFlight(toKick);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -50,7 +50,7 @@ public class CmdMod extends FCommand {
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
if(you.isAlt()){
|
if (you.isAlt()) {
|
||||||
return;
|
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();
|
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);
|
context.msg(TL.COMMAND_COOLDOWN);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
@ -51,7 +51,7 @@ public class CmdOpen extends FCommand {
|
|||||||
Cooldown.setCooldown(fplayer.getPlayer(), "openCooldown", FactionsPlugin.getInstance().getConfig().getInt("fcooldowns.f-open"));
|
Cooldown.setCooldown(fplayer.getPlayer(), "openCooldown", FactionsPlugin.getInstance().getConfig().getInt("fcooldowns.f-open"));
|
||||||
continue;
|
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);
|
fplayer.msg(TL.COMMAND_OPEN_CHANGED, context.faction.getTag(fplayer.getFaction()), open);
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
@ -66,16 +66,18 @@ public class CmdRules extends FCommand {
|
|||||||
String message = "";
|
String message = "";
|
||||||
StringBuilder string = new StringBuilder(message);
|
StringBuilder string = new StringBuilder(message);
|
||||||
for (int i = 1; i <= context.args.size() - 1; i++) {
|
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.faction.addRule(string.toString());
|
||||||
context.msg(TL.COMMAND_RULES_ADD_SUCCESS);
|
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);
|
int index = context.argAsInt(1);
|
||||||
context.faction.removeRule(index - 1);
|
context.faction.removeRule(index - 1);
|
||||||
context.msg(TL.COMMAND_RULES_REMOVE_SUCCESS);
|
context.msg(TL.COMMAND_RULES_REMOVE_SUCCESS);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
@ -88,7 +88,7 @@ public class CmdShow extends FCommand {
|
|||||||
Faction finalFaction = faction;
|
Faction finalFaction = faction;
|
||||||
instance.getServer().getScheduler().runTaskAsynchronously(instance, () -> {
|
instance.getServer().getScheduler().runTaskAsynchronously(instance, () -> {
|
||||||
for (String raw : finalShow) {
|
for (String raw : finalShow) {
|
||||||
String parsed = TagUtil.parsePlain(finalFaction, context.fPlayer, raw); // use relations
|
String parsed = instance.getConfig().getBoolean("relational-show", true) ? TagUtil.parsePlain(finalFaction, context.fPlayer, raw) : TagUtil.parsePlain(finalFaction, raw); // use relations
|
||||||
if (parsed == null) {
|
if (parsed == null) {
|
||||||
continue; // Due to minimal f show.
|
continue; // Due to minimal f show.
|
||||||
}
|
}
|
||||||
@ -110,7 +110,7 @@ public class CmdShow extends FCommand {
|
|||||||
parsed = parsed.substring(0, parsed.indexOf("{ig}")) + TL.COMMAND_SHOW_NOHOME.toString();
|
parsed = parsed.substring(0, parsed.indexOf("{ig}")) + TL.COMMAND_SHOW_NOHOME.toString();
|
||||||
}
|
}
|
||||||
if (parsed.contains("%")) {
|
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);
|
parsed = FactionsPlugin.getInstance().txt.parse(parsed);
|
||||||
FancyMessage localFancy = instance.txt.parseFancy(parsed);
|
FancyMessage localFancy = instance.txt.parseFancy(parsed);
|
||||||
|
@ -54,7 +54,7 @@ public class CmdTag extends FCommand {
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
if(Cooldown.isOnCooldown(context.player, "tagCooldown") && !context.fPlayer.isAdminBypassing()){
|
if (Cooldown.isOnCooldown(context.player, "tagCooldown") && !context.fPlayer.isAdminBypassing()) {
|
||||||
context.msg(TL.COMMAND_COOLDOWN);
|
context.msg(TL.COMMAND_COOLDOWN);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
@ -72,7 +72,6 @@ public class CmdTag extends FCommand {
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
String oldtag = context.faction.getTag();
|
String oldtag = context.faction.getTag();
|
||||||
context.faction.setTag(tag);
|
context.faction.setTag(tag);
|
||||||
|
|
||||||
|
@ -30,7 +30,9 @@ public class CmdTpBanner extends FCommand {
|
|||||||
|
|
||||||
if (FactionsBlockListener.bannerLocations.containsKey(context.fPlayer.getTag())) {
|
if (FactionsBlockListener.bannerLocations.containsKey(context.fPlayer.getTag())) {
|
||||||
context.msg(TL.COMMAND_TPBANNER_SUCCESS);
|
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 {
|
} else {
|
||||||
context.msg(TL.COMMAND_TPBANNER_NOTSET);
|
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.Access;
|
||||||
import com.massivecraft.factions.zcore.fperms.PermissableAction;
|
import com.massivecraft.factions.zcore.fperms.PermissableAction;
|
||||||
import com.massivecraft.factions.zcore.util.TL;
|
import com.massivecraft.factions.zcore.util.TL;
|
||||||
import org.bukkit.Material;
|
|
||||||
|
|
||||||
public class CmdUnban extends FCommand {
|
public class CmdUnban extends FCommand {
|
||||||
|
|
||||||
@ -33,8 +32,12 @@ public class CmdUnban extends FCommand {
|
|||||||
return; // the above method sends a message if fails to find someone.
|
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());
|
context.fPlayer.msg(TL.COMMAND_UNBAN_TARGET_IN_OTHER_FACTION, target.getName());
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!context.faction.isBanned(target)) {
|
if (!context.faction.isBanned(target)) {
|
||||||
|
@ -70,9 +70,13 @@ public class CommandRequirements {
|
|||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (access != Access.ALLOW && role != null && !context.fPlayer.getRole().isAtLeast(role)) {
|
if (access != Access.ALLOW) {
|
||||||
if (informIfNot) context.msg(TL.GENERIC_YOUMUSTBE, role.translation);
|
// They have undefined assert their role
|
||||||
return false;
|
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
|
// They have been explicitly allowed
|
||||||
return true;
|
return true;
|
||||||
|
@ -26,6 +26,7 @@ import com.massivecraft.factions.discord.CmdInviteBot;
|
|||||||
import com.massivecraft.factions.discord.CmdSetGuild;
|
import com.massivecraft.factions.discord.CmdSetGuild;
|
||||||
import com.massivecraft.factions.missions.CmdMissions;
|
import com.massivecraft.factions.missions.CmdMissions;
|
||||||
import com.massivecraft.factions.shop.CmdShop;
|
import com.massivecraft.factions.shop.CmdShop;
|
||||||
|
import com.massivecraft.factions.shop.ShopGUIFrame;
|
||||||
import com.massivecraft.factions.zcore.util.TL;
|
import com.massivecraft.factions.zcore.util.TL;
|
||||||
import me.lucko.commodore.CommodoreProvider;
|
import me.lucko.commodore.CommodoreProvider;
|
||||||
import org.bukkit.Bukkit;
|
import org.bukkit.Bukkit;
|
||||||
@ -377,6 +378,7 @@ public class FCmdRoot extends FCommand implements CommandExecutor {
|
|||||||
}
|
}
|
||||||
if (FactionsPlugin.getInstance().getConfig().getBoolean("F-Shop.Enabled", false) && !fShopEnabled) {
|
if (FactionsPlugin.getInstance().getConfig().getBoolean("F-Shop.Enabled", false) && !fShopEnabled) {
|
||||||
this.addSubCommand(this.cmdShop);
|
this.addSubCommand(this.cmdShop);
|
||||||
|
new ShopGUIFrame(null).checkShopConfig();
|
||||||
fShopEnabled = true;
|
fShopEnabled = true;
|
||||||
}
|
}
|
||||||
if (FactionsPlugin.getInstance().getConfig().getBoolean("f-inventory-see.Enabled", false) && !invSeeEnabled) {
|
if (FactionsPlugin.getInstance().getConfig().getBoolean("f-inventory-see.Enabled", false) && !invSeeEnabled) {
|
||||||
|
@ -44,7 +44,7 @@ public class CmdAltsList extends FCommand {
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (faction.getAltPlayers().isEmpty()) {
|
if (faction.getAltPlayers().size() == 0) {
|
||||||
context.msg(TL.COMMAND_ALTS_LIST_NOALTS, faction.getTag());
|
context.msg(TL.COMMAND_ALTS_LIST_NOALTS, faction.getTag());
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
@ -114,7 +114,7 @@ public class FAuditMenu extends GUIMenu {
|
|||||||
}
|
}
|
||||||
lore.add("");
|
lore.add("");
|
||||||
lore.add(CC.Gray + "Click to toggle timestamp");
|
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);
|
e.setCancelled(true);
|
||||||
timeStamp = !timeStamp;
|
timeStamp = !timeStamp;
|
||||||
drawItems();
|
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);
|
event.setCancelled(true);
|
||||||
Bukkit.getScheduler().scheduleSyncDelayedTask(FactionsPlugin.instance, () -> (new FAuditMenu(player, faction)).open(player));
|
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 Map<UUID, LogTimer> logTimers = new ConcurrentHashMap<>();
|
||||||
private boolean saving = false;
|
private boolean saving = false;
|
||||||
|
|
||||||
|
public FLogManager() {
|
||||||
|
}
|
||||||
|
|
||||||
public void log(Faction faction, FLogType type, String... arguments) {
|
public void log(Faction faction, FLogType type, String... arguments) {
|
||||||
FactionLogs logs = factionLogMap.computeIfAbsent(faction.getId(), (n) -> new FactionLogs());
|
FactionLogs logs = factionLogMap.computeIfAbsent(faction.getId(), (n) -> new FactionLogs());
|
||||||
@ -88,7 +90,8 @@ public class FLogManager {
|
|||||||
Faction faction = null;
|
Faction faction = null;
|
||||||
|
|
||||||
for (Map.Entry<UUID, LogTimer> uuidLogTimerEntry : getLogTimers().entrySet()) {
|
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) {
|
if (faction == null) {
|
||||||
faction = Factions.getInstance().getFactionById(logTimer.getFactionId());
|
faction = Factions.getInstance().getFactionById(logTimer.getFactionId());
|
||||||
}
|
}
|
||||||
|
@ -65,11 +65,11 @@ public class FactionLogs {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if (logs.isEmpty())
|
if (logs.size() <= 0)
|
||||||
toRemove.add(logType);
|
toRemove.add(logType);
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
toRemove.forEach(rem -> mostRecentLogs.remove(rem));
|
toRemove.forEach((rem) -> mostRecentLogs.remove(rem));
|
||||||
}
|
}
|
||||||
|
|
||||||
public Map<FLogType, LinkedList<FactionLog>> getMostRecentLogs() {
|
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) {
|
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) {
|
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) {
|
public void pushLogs(Faction faction, LogTimer.TimerType type) {
|
||||||
|
@ -13,19 +13,24 @@ import org.bukkit.inventory.Inventory;
|
|||||||
import org.bukkit.inventory.ItemStack;
|
import org.bukkit.inventory.ItemStack;
|
||||||
import org.bukkit.inventory.meta.ItemMeta;
|
import org.bukkit.inventory.meta.ItemMeta;
|
||||||
import org.bukkit.material.MaterialData;
|
import org.bukkit.material.MaterialData;
|
||||||
import org.jetbrains.annotations.NotNull;
|
|
||||||
|
|
||||||
import java.text.SimpleDateFormat;
|
import java.text.SimpleDateFormat;
|
||||||
import java.util.*;
|
import java.util.*;
|
||||||
|
|
||||||
public class CheckHistoryFrame implements FactionGUI {
|
public class CheckHistoryFrame implements FactionGUI {
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @author Driftay
|
||||||
|
*/
|
||||||
|
|
||||||
|
private FactionsPlugin plugin;
|
||||||
private Faction faction;
|
private Faction faction;
|
||||||
private Inventory inventory;
|
private Inventory inventory;
|
||||||
private SimpleDateFormat simpleDateFormat;
|
private SimpleDateFormat simpleDateFormat;
|
||||||
|
|
||||||
public CheckHistoryFrame(FactionsPlugin plugin, Faction faction) {
|
public CheckHistoryFrame(FactionsPlugin plugin, Faction faction) {
|
||||||
this.simpleDateFormat = new SimpleDateFormat(Conf.dateFormat);
|
this.simpleDateFormat = new SimpleDateFormat(Conf.dateFormat);
|
||||||
|
this.plugin = plugin;
|
||||||
this.faction = faction;
|
this.faction = faction;
|
||||||
this.inventory = plugin.getServer().createInventory(this, 54, TL.CHECK_HISTORY_GUI_TITLE.toString());
|
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() {
|
public Inventory getInventory() {
|
||||||
return inventory;
|
return inventory;
|
||||||
}
|
}
|
||||||
|
@ -12,7 +12,6 @@ import org.bukkit.inventory.Inventory;
|
|||||||
import org.bukkit.inventory.InventoryHolder;
|
import org.bukkit.inventory.InventoryHolder;
|
||||||
import org.bukkit.inventory.ItemStack;
|
import org.bukkit.inventory.ItemStack;
|
||||||
import org.bukkit.inventory.meta.ItemMeta;
|
import org.bukkit.inventory.meta.ItemMeta;
|
||||||
import org.jetbrains.annotations.NotNull;
|
|
||||||
|
|
||||||
import java.util.Collections;
|
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);
|
inventory.setItem(FactionsPlugin.getInstance().getConfig().getInt("f-check.history.slot"), historyStack);
|
||||||
}
|
}
|
||||||
|
|
||||||
@NotNull
|
|
||||||
public Inventory getInventory() {
|
public Inventory getInventory() {
|
||||||
return this.inventory;
|
return this.inventory;
|
||||||
}
|
}
|
||||||
@ -94,6 +92,9 @@ public class CheckSettingsFrame implements InventoryHolder, FactionGUI {
|
|||||||
case 15: {
|
case 15: {
|
||||||
return 30;
|
return 30;
|
||||||
}
|
}
|
||||||
|
case 30: {
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
default: {
|
default: {
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
@ -11,7 +11,14 @@ import net.dv8tion.jda.core.entities.TextChannel;
|
|||||||
|
|
||||||
public class WeeWooTask implements Runnable {
|
public class WeeWooTask implements Runnable {
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @author Driftay
|
||||||
|
*/
|
||||||
|
|
||||||
|
private FactionsPlugin plugin;
|
||||||
|
|
||||||
public WeeWooTask(FactionsPlugin plugin) {
|
public WeeWooTask(FactionsPlugin plugin) {
|
||||||
|
this.plugin = plugin;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
@ -29,11 +29,13 @@ public class AntiChestListener implements Listener {
|
|||||||
Inventory clicked = e.getClickedInventory();
|
Inventory clicked = e.getClickedInventory();
|
||||||
Inventory clicker = e.getWhoClicked().getInventory();
|
Inventory clicker = e.getWhoClicked().getInventory();
|
||||||
|
|
||||||
if (e.getClick().isShiftClick() && clicked == clicker) {
|
if (e.getClick().isShiftClick()) {
|
||||||
ItemStack clickedOn = e.getCurrentItem();
|
if (clicked == clicker) {
|
||||||
if (clickedOn != null && FactionsPlugin.getInstance().itemList.contains(clickedOn.getType().toString())) {
|
ItemStack clickedOn = e.getCurrentItem();
|
||||||
fPlayer.msg(TL.CHEST_ITEM_DENIED_TRANSFER, clickedOn.getType().toString());
|
if (clickedOn != null && FactionsPlugin.getInstance().itemList.contains(clickedOn.getType().toString())) {
|
||||||
e.setCancelled(true);
|
fPlayer.msg(TL.CHEST_ITEM_DENIED_TRANSFER, clickedOn.getType().toString());
|
||||||
|
e.setCancelled(true);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -26,6 +26,7 @@ public class CmdAutoClaim extends FCommand {
|
|||||||
super();
|
super();
|
||||||
this.aliases.addAll(Aliases.claim_auto);
|
this.aliases.addAll(Aliases.claim_auto);
|
||||||
|
|
||||||
|
//this.requiredArgs.add("");
|
||||||
this.optionalArgs.put("faction", "your");
|
this.optionalArgs.put("faction", "your");
|
||||||
|
|
||||||
this.requirements = new CommandRequirements.Builder(Permission.AUTOCLAIM)
|
this.requirements = new CommandRequirements.Builder(Permission.AUTOCLAIM)
|
||||||
@ -38,9 +39,13 @@ public class CmdAutoClaim extends FCommand {
|
|||||||
public void perform(CommandContext context) {
|
public void perform(CommandContext context) {
|
||||||
Faction forFaction = context.argAsFaction(0, context.faction);
|
Faction forFaction = context.argAsFaction(0, context.faction);
|
||||||
|
|
||||||
if (forFaction != context.fPlayer.getFaction() && !context.fPlayer.isAdminBypassing() && forFaction.getAccess(context.fPlayer, PermissableAction.TERRITORY) != Access.ALLOW) {
|
if (forFaction != context.fPlayer.getFaction()) {
|
||||||
context.msg(TL.COMMAND_CLAIM_DENIED);
|
if (!context.fPlayer.isAdminBypassing()) {
|
||||||
return;
|
if (forFaction.getAccess(context.fPlayer, PermissableAction.TERRITORY) != Access.ALLOW) {
|
||||||
|
context.msg(TL.COMMAND_CLAIM_DENIED);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (forFaction == null || forFaction == context.fPlayer.getAutoClaimFor()) {
|
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
|
int radius = context.argAsInt(0, 1); // Default to 1
|
||||||
final Faction forFaction = context.argAsFaction(1, context.faction); // Default to own
|
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) {
|
if (!context.fPlayer.isAdminBypassing()) {
|
||||||
context.msg(TL.COMMAND_CLAIM_DENIED);
|
if (!(context.fPlayer.getFaction().equals(forFaction) && context.fPlayer.getRole() == Role.LEADER)) {
|
||||||
return;
|
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;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
|
||||||
public void finish() {
|
public void finish() {
|
||||||
if (FactionsPlugin.cachedRadiusClaim && successfulClaims > 0) {
|
if (FactionsPlugin.cachedRadiusClaim) {
|
||||||
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()));
|
if (successfulClaims > 0) {
|
||||||
stop();
|
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);
|
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);
|
context.msg(TL.COMMAND_CLAIM_DENIED);
|
||||||
return;
|
return;
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
Location location = context.player.getLocation();
|
Location location = context.player.getLocation();
|
||||||
@ -80,11 +85,13 @@ public class CmdClaimLine extends FCommand {
|
|||||||
int claims = 0;
|
int claims = 0;
|
||||||
|
|
||||||
for (int i = 0; i < amount; i++) {
|
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);
|
context.fPlayer.attemptClaim(forFaction, location, true);
|
||||||
|
claims++;
|
||||||
}
|
}
|
||||||
claims++;
|
location = location.add(blockFace.getModX() * 16, 0, blockFace.getModZ() * 16);
|
||||||
location = location.add(blockFace.getModX() * 16D, 0, blockFace.getModZ() * 16D);
|
|
||||||
FactionsPlugin.instance.logFactionEvent(forFaction, FLogType.CHUNK_CLAIMS, context.fPlayer.getName(), CC.GreenB + "CLAIMED", String.valueOf(i), new FLocation(context.player.getLocation()).formatXAndZ(","));
|
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;
|
int cachedClaims = claims;
|
||||||
|
@ -31,13 +31,16 @@ public class CmdUnclaim extends FCommand {
|
|||||||
|
|
||||||
this.requirements = new CommandRequirements.Builder(Permission.UNCLAIM)
|
this.requirements = new CommandRequirements.Builder(Permission.UNCLAIM)
|
||||||
.playerOnly()
|
.playerOnly()
|
||||||
.memberOnly()
|
|
||||||
.withAction(PermissableAction.TERRITORY)
|
.withAction(PermissableAction.TERRITORY)
|
||||||
.build();
|
.build();
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void perform(CommandContext context) {
|
public void perform(CommandContext context) {
|
||||||
|
if (!context.fPlayer.isAdminBypassing() && !context.fPlayer.hasFaction()) {
|
||||||
|
context.fPlayer.msg(TL.GENERIC_MEMBERONLY);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
if (context.args.size() == 2) {
|
if (context.args.size() == 2) {
|
||||||
Faction target = context.argAsFaction(1);
|
Faction target = context.argAsFaction(1);
|
||||||
@ -63,6 +66,11 @@ public class CmdUnclaim extends FCommand {
|
|||||||
boolean didUnClaim = unClaim(new FLocation(context.player), context);
|
boolean didUnClaim = unClaim(new FLocation(context.player), context);
|
||||||
if (didUnClaim && !context.fPlayer.canFlyAtLocation())
|
if (didUnClaim && !context.fPlayer.canFlyAtLocation())
|
||||||
context.fPlayer.setFFlying(false, false);
|
context.fPlayer.setFFlying(false, false);
|
||||||
|
|
||||||
|
for(FPlayer fPlayer : context.faction.getFPlayersWhereOnline(true)){
|
||||||
|
if(!fPlayer.canFlyAtLocation())
|
||||||
|
fPlayer.setFFlying(false, false);
|
||||||
|
}
|
||||||
} else {
|
} else {
|
||||||
// radius claim
|
// radius claim
|
||||||
if (!Permission.CLAIM_RADIUS.has(context.sender, false)) {
|
if (!Permission.CLAIM_RADIUS.has(context.sender, false)) {
|
||||||
@ -83,10 +91,13 @@ public class CmdUnclaim extends FCommand {
|
|||||||
this.stop();
|
this.stop();
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
|
boolean didUnClaim = unClaim(new FLocation(context.player), context);
|
||||||
|
if (didUnClaim && !context.fPlayer.canFlyAtLocation())
|
||||||
|
context.fPlayer.setFFlying(false, false);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -57,14 +57,8 @@ public class CmdUnclaimall extends FCommand {
|
|||||||
}
|
}
|
||||||
if (Econ.shouldBeUsed()) {
|
if (Econ.shouldBeUsed()) {
|
||||||
double refund = Econ.calculateTotalLandRefund(target.getLandRounded());
|
double refund = Econ.calculateTotalLandRefund(target.getLandRounded());
|
||||||
if (Conf.bankEnabled && Conf.bankFactionPaysLandCosts) {
|
if (!Econ.modifyMoney(target, refund, TL.COMMAND_UNCLAIMALL_TOUNCLAIM.toString(), TL.COMMAND_UNCLAIMALL_FORUNCLAIM.toString())) {
|
||||||
if (!Econ.modifyMoney(target, refund, TL.COMMAND_UNCLAIMALL_TOUNCLAIM.toString(), TL.COMMAND_UNCLAIMALL_FORUNCLAIM.toString())) {
|
return;
|
||||||
return;
|
|
||||||
}
|
|
||||||
} else {
|
|
||||||
if (!Econ.modifyMoney(target, refund, TL.COMMAND_UNCLAIMALL_TOUNCLAIM.toString(), TL.COMMAND_UNCLAIMALL_FORUNCLAIM.toString())) {
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -8,6 +8,7 @@ import com.massivecraft.factions.cmd.CommandContext;
|
|||||||
import com.massivecraft.factions.cmd.CommandRequirements;
|
import com.massivecraft.factions.cmd.CommandRequirements;
|
||||||
import com.massivecraft.factions.cmd.FCommand;
|
import com.massivecraft.factions.cmd.FCommand;
|
||||||
import com.massivecraft.factions.cmd.audit.FLogType;
|
import com.massivecraft.factions.cmd.audit.FLogType;
|
||||||
|
import com.massivecraft.factions.iface.EconomyParticipator;
|
||||||
import com.massivecraft.factions.integration.Econ;
|
import com.massivecraft.factions.integration.Econ;
|
||||||
import com.massivecraft.factions.struct.Permission;
|
import com.massivecraft.factions.struct.Permission;
|
||||||
import com.massivecraft.factions.struct.Role;
|
import com.massivecraft.factions.struct.Role;
|
||||||
@ -43,21 +44,23 @@ public class CmdMoneyWithdraw extends FCommand {
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
Faction faction = context.argAsFaction(1, context.faction);
|
EconomyParticipator faction = context.argAsFaction(1, context.faction);
|
||||||
if (faction == null) {
|
if (faction == null) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
Access access = context.faction.getAccess(context.fPlayer, PermissableAction.WITHDRAW);
|
Access access = context.faction.getAccess(context.fPlayer, PermissableAction.WITHDRAW);
|
||||||
if (context.fPlayer.getRole() != Role.LEADER && access == Access.DENY) {
|
if (context.fPlayer.getRole() != Role.LEADER) {
|
||||||
context.msg(TL.GENERIC_NOPERMISSION, "withdraw", "withdraw money from the bank");
|
if (access == Access.DENY) {
|
||||||
return;
|
context.msg(TL.GENERIC_NOPERMISSION, "withdraw", "withdraw money from the bank");
|
||||||
|
return;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
boolean success = Econ.transferMoney(context.fPlayer, faction, context.fPlayer, amount);
|
boolean success = Econ.transferMoney(context.fPlayer, faction, context.fPlayer, amount);
|
||||||
|
|
||||||
if (success && Conf.logMoneyTransactions) {
|
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.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;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (context.args.size() == 1 && context.sender.hasPermission(String.valueOf(Permission.GRACETOGGLE))) {
|
if (context.args.size() == 1) {
|
||||||
if (context.argAsString(0).equalsIgnoreCase("on") || context.argAsString(0).equalsIgnoreCase("start")) {
|
if (context.sender.hasPermission(String.valueOf(Permission.GRACETOGGLE))) {
|
||||||
FactionsPlugin.getInstance().getTimerManager().graceTimer.setPaused(false);
|
if (context.argAsString(0).equalsIgnoreCase("on") || context.argAsString(0).equalsIgnoreCase("start")) {
|
||||||
FactionsPlugin.getInstance().getTimerManager().graceTimer.setRemaining(TimeUnit.DAYS.toMillis(Conf.gracePeriodTimeDays), true);
|
FactionsPlugin.getInstance().getTimerManager().graceTimer.setPaused(false);
|
||||||
if (Conf.broadcastGraceToggles) {
|
FactionsPlugin.getInstance().getTimerManager().graceTimer.setRemaining(TimeUnit.DAYS.toMillis(Conf.gracePeriodTimeDays), true);
|
||||||
for (FPlayer follower : FPlayers.getInstance().getOnlinePlayers())
|
if (Conf.broadcastGraceToggles) {
|
||||||
follower.msg(TL.COMMAND_GRACE_ENABLED_FORMAT, String.valueOf(TimerManager.getRemaining(FactionsPlugin.getInstance().getTimerManager().graceTimer.getRemaining(), true)));
|
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")) {
|
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.setRemaining(TimeUnit.SECONDS.toMillis(0L), true);
|
||||||
FactionsPlugin.getInstance().getTimerManager().graceTimer.setPaused(false);
|
FactionsPlugin.getInstance().getTimerManager().graceTimer.setPaused(false);
|
||||||
if (Conf.broadcastGraceToggles) {
|
if (Conf.broadcastGraceToggles) {
|
||||||
for (FPlayer follower : FPlayers.getInstance().getOnlinePlayers())
|
for (FPlayer follower : FPlayers.getInstance().getOnlinePlayers())
|
||||||
follower.msg(TL.COMMAND_GRACE_DISABLED_FORMAT);
|
follower.msg(TL.COMMAND_GRACE_DISABLED_FORMAT);
|
||||||
|
}
|
||||||
|
return;
|
||||||
}
|
}
|
||||||
return;
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -15,8 +15,10 @@ public class LogoutHandler {
|
|||||||
|
|
||||||
public static Map<String, LogoutHandler> factionDatas = new HashMap<>();
|
public static Map<String, LogoutHandler> factionDatas = new HashMap<>();
|
||||||
private Map<UUID, Long> logoutCooldown = new HashMap<>();
|
private Map<UUID, Long> logoutCooldown = new HashMap<>();
|
||||||
|
private String name;
|
||||||
|
|
||||||
public LogoutHandler(String name) {
|
public LogoutHandler(String name) {
|
||||||
|
this.name = name;
|
||||||
factionDatas.put(name, this);
|
factionDatas.put(name, this);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -112,14 +112,16 @@ public abstract class FRelationCommand extends FCommand {
|
|||||||
|
|
||||||
private boolean hasMaxRelations(Faction us, Faction them, Relation targetRelation) {
|
private boolean hasMaxRelations(Faction us, Faction them, Relation targetRelation) {
|
||||||
int max = FactionsPlugin.getInstance().getConfig().getInt("max-relations." + targetRelation.toString(), -1);
|
int max = FactionsPlugin.getInstance().getConfig().getInt("max-relations." + targetRelation.toString(), -1);
|
||||||
if (FactionsPlugin.getInstance().getConfig().getBoolean("max-relations.enabled", false) && max != -1) {
|
if (FactionsPlugin.getInstance().getConfig().getBoolean("max-relations.enabled", false)) {
|
||||||
if (us.getRelationCount(targetRelation) >= max) {
|
if (max != -1) {
|
||||||
us.msg(TL.COMMAND_RELATIONS_EXCEEDS_ME, max, targetRelation.getPluralTranslation());
|
if (us.getRelationCount(targetRelation) >= max) {
|
||||||
return true;
|
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());
|
if (them.getRelationCount(targetRelation) >= max) {
|
||||||
return true;
|
them.msg(TL.COMMAND_RELATIONS_EXCEEDS_THEY, max, targetRelation.getPluralTranslation());
|
||||||
|
return true;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return false;
|
return false;
|
||||||
|
@ -74,7 +74,7 @@ public class FPromoteCommand extends FCommand {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if(target.isAlt()){
|
if (target.isAlt()) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -26,8 +26,8 @@ import java.util.Random;
|
|||||||
* @author DroppingAnvil
|
* @author DroppingAnvil
|
||||||
*/
|
*/
|
||||||
public class CmdWild extends FCommand implements WaitedTask {
|
public class CmdWild extends FCommand implements WaitedTask {
|
||||||
public static HashMap<Player, String> teleportRange = new HashMap<>();
|
public static HashMap<Player, String> teleportRange;
|
||||||
public static HashSet<Player> teleporting = new HashSet<>();
|
public static HashSet<Player> teleporting;
|
||||||
public static CmdWild instance;
|
public static CmdWild instance;
|
||||||
|
|
||||||
public CmdWild() {
|
public CmdWild() {
|
||||||
@ -37,7 +37,9 @@ public class CmdWild extends FCommand implements WaitedTask {
|
|||||||
this.requirements = new CommandRequirements.Builder(Permission.WILD)
|
this.requirements = new CommandRequirements.Builder(Permission.WILD)
|
||||||
.playerOnly()
|
.playerOnly()
|
||||||
.build();
|
.build();
|
||||||
}
|
teleporting = new HashSet<>();
|
||||||
|
teleportRange = new HashMap<>();
|
||||||
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void perform(CommandContext context) {
|
public void perform(CommandContext context) {
|
||||||
|
@ -60,17 +60,17 @@ public class CmdSetGuild extends FCommand {
|
|||||||
|
|
||||||
if (guild == null) {
|
if (guild == null) {
|
||||||
context.msg(TL.SET_GUILD_ID_INVALID_ID);
|
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);
|
context.msg(TL.SET_GUILD_ID_GUILD_ALREADY_LINKED);
|
||||||
} else {
|
} else {
|
||||||
context.msg(TL.SET_GUILD_ID_PMING_OWNER);
|
context.msg(TL.SET_GUILD_ID_PMING_OWNER);
|
||||||
User user = guild.getOwner().getUser();
|
User user = guild.getOwner().getUser();
|
||||||
Guild finalGuild = guild;
|
Guild finalGuild = guild;
|
||||||
Guild finalGuild1 = 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 = "✅";
|
String checkMark = "✅";
|
||||||
message.addReaction(checkMark).queue();
|
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));
|
faction.setGuildId(context.argAsString(0));
|
||||||
context.msg(TL.SET_GUILD_ID_SUCCESS);
|
context.msg(TL.SET_GUILD_ID_SUCCESS);
|
||||||
privateChannel.sendMessage("Successfully linked **" + finalGuild.getName() + " & " + ChatColor.stripColor(faction.getTag()) + "**").queue();
|
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();
|
privateChannel.sendMessage(TL.SET_GUILD_ID_TIMED_OUT_DISCORD.toString()).queue();
|
||||||
context.msg(TL.SET_GUILD_ID_TIMED_OUT_MINECRAFT);
|
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 {
|
} else {
|
||||||
faction.setGuildId(null);
|
faction.setGuildId(null);
|
||||||
|
@ -31,7 +31,7 @@ public class Discord {
|
|||||||
public static Boolean confUseDiscord;
|
public static Boolean confUseDiscord;
|
||||||
public static String botToken;
|
public static String botToken;
|
||||||
public static String mainGuildID;
|
public static String mainGuildID;
|
||||||
public static boolean useDiscord;
|
public static Boolean useDiscord;
|
||||||
public static java.awt.Color roleColor;
|
public static java.awt.Color roleColor;
|
||||||
public static Guild mainGuild;
|
public static Guild mainGuild;
|
||||||
public static Role leader;
|
public static Role leader;
|
||||||
@ -53,11 +53,13 @@ public class Discord {
|
|||||||
* Called to reload variables and if needed start JDA
|
* Called to reload variables and if needed start JDA
|
||||||
*/
|
*/
|
||||||
public static void setupDiscord() {
|
public static void setupDiscord() {
|
||||||
if (jda == null && startBot()) {
|
if (jda == null) {
|
||||||
varSetup();
|
if (startBot()) {
|
||||||
jda.addEventListener(new FactionChatHandler(plugin));
|
varSetup();
|
||||||
jda.addEventListener(new DiscordListener(plugin));
|
jda.addEventListener(new FactionChatHandler(plugin));
|
||||||
return;
|
jda.addEventListener(new DiscordListener(plugin));
|
||||||
|
return;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
varSetup();
|
varSetup();
|
||||||
}
|
}
|
||||||
@ -82,7 +84,6 @@ public class Discord {
|
|||||||
confUseDiscord = Conf.useDiscordSystem;
|
confUseDiscord = Conf.useDiscordSystem;
|
||||||
botToken = Conf.discordBotToken;
|
botToken = Conf.discordBotToken;
|
||||||
if (jda != null && Conf.leaderRoles || Conf.factionDiscordTags) {
|
if (jda != null && Conf.leaderRoles || Conf.factionDiscordTags) {
|
||||||
assert jda != null;
|
|
||||||
mainGuild = jda.getGuildById(Conf.mainGuildID);
|
mainGuild = jda.getGuildById(Conf.mainGuildID);
|
||||||
} else {
|
} else {
|
||||||
mainGuild = null;
|
mainGuild = null;
|
||||||
@ -150,9 +151,12 @@ public class Discord {
|
|||||||
* @param s String target Faction tag
|
* @param s String target Faction tag
|
||||||
* @return
|
* @return
|
||||||
*/
|
*/
|
||||||
public static boolean doesFactionRoleExist(String s) {
|
public static Boolean doesFactionRoleExist(String s) {
|
||||||
String sb = Conf.factionRolePrefix + s + Conf.factionRoleSuffix;
|
StringBuilder sb = new StringBuilder();
|
||||||
return getRoleFromName(sb) != null;
|
sb.append(Conf.factionRolePrefix);
|
||||||
|
sb.append(s);
|
||||||
|
sb.append(Conf.factionRoleSuffix);
|
||||||
|
return getRoleFromName(sb.toString()) != null;
|
||||||
}
|
}
|
||||||
|
|
||||||
public static Role getRoleFromName(String s) {
|
public static Role getRoleFromName(String s) {
|
||||||
@ -185,8 +189,7 @@ public class Discord {
|
|||||||
sb.append(Conf.factionRoleSuffix);
|
sb.append(Conf.factionRoleSuffix);
|
||||||
if (!doesFactionRoleExist(sb.toString())) {
|
if (!doesFactionRoleExist(sb.toString())) {
|
||||||
try {
|
try {
|
||||||
Role newRole;
|
Role newRole = mainGuild.getController().createRole()
|
||||||
newRole = mainGuild.getController().createRole()
|
|
||||||
.setName(sb.toString())
|
.setName(sb.toString())
|
||||||
.setColor(roleColor)
|
.setColor(roleColor)
|
||||||
.setPermissions(Permission.EMPTY_PERMISSIONS)
|
.setPermissions(Permission.EMPTY_PERMISSIONS)
|
||||||
@ -208,7 +211,11 @@ public class Discord {
|
|||||||
* @return Name of would be Role
|
* @return Name of would be Role
|
||||||
*/
|
*/
|
||||||
public static String getFactionRoleName(String tag) {
|
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
|
* @param u User
|
||||||
* @return Boolean
|
* @return Boolean
|
||||||
*/
|
*/
|
||||||
public static boolean isInMainGuild(User u) {
|
public static Boolean isInMainGuild(User u) {
|
||||||
if (mainGuild == null) return false;
|
if (mainGuild == null) return false;
|
||||||
return mainGuild.getMember(u) == null ? Boolean.FALSE : Boolean.TRUE;
|
return mainGuild.getMember(u) == null ? Boolean.FALSE : Boolean.TRUE;
|
||||||
}
|
}
|
||||||
@ -245,12 +252,10 @@ public class Discord {
|
|||||||
if (fp.discordSetup() && isInMainGuild(fp.discordUser())) {
|
if (fp.discordSetup() && isInMainGuild(fp.discordUser())) {
|
||||||
try {
|
try {
|
||||||
Member m = mainGuild.getMember(fp.discordUser());
|
Member m = mainGuild.getMember(fp.discordUser());
|
||||||
boolean discordTags = Conf.factionDiscordTags;
|
if (Conf.factionDiscordTags) {
|
||||||
boolean factionRoles = Conf.factionRoles;
|
|
||||||
if (discordTags) {
|
|
||||||
mainGuild.getController().setNickname(m, Discord.getNicknameString(fp)).queue();
|
mainGuild.getController().setNickname(m, Discord.getNicknameString(fp)).queue();
|
||||||
}
|
}
|
||||||
if (factionRoles) {
|
if (Conf.factionRoles) {
|
||||||
mainGuild.getController().removeSingleRoleFromMember(m, Objects.requireNonNull(getRoleFromName(oldTag))).queue();
|
mainGuild.getController().removeSingleRoleFromMember(m, Objects.requireNonNull(getRoleFromName(oldTag))).queue();
|
||||||
mainGuild.getController().addSingleRoleToMember(m, Objects.requireNonNull(createFactionRole(f.getTag()))).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.decimalFormat = new DecimalFormat("$#,###.##");
|
||||||
this.plugin = plugin;
|
this.plugin = plugin;
|
||||||
int minute = 3600;
|
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() {
|
private static JSONGuilds loadGuilds() {
|
||||||
@ -64,7 +64,6 @@ public class DiscordListener extends ListenerAdapter {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
|
||||||
public void onPrivateMessageReceived(PrivateMessageReceivedEvent e) {
|
public void onPrivateMessageReceived(PrivateMessageReceivedEvent e) {
|
||||||
Integer i;
|
Integer i;
|
||||||
if (e.getAuthor().isBot()) return;
|
if (e.getAuthor().isBot()) return;
|
||||||
@ -86,7 +85,6 @@ public class DiscordListener extends ListenerAdapter {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
|
||||||
public void onGuildMessageReceived(GuildMessageReceivedEvent event) {
|
public void onGuildMessageReceived(GuildMessageReceivedEvent event) {
|
||||||
try {
|
try {
|
||||||
if (event.getMessage().isWebhookMessage() || event.getAuthor().isBot()) return;
|
if (event.getMessage().isWebhookMessage() || event.getAuthor().isBot()) return;
|
||||||
|
@ -109,7 +109,7 @@ public class DiscordSetupAttempt {
|
|||||||
sb.append(inProcessTime);
|
sb.append(inProcessTime);
|
||||||
//Just a separator for looks
|
//Just a separator for looks
|
||||||
sb.append(" ");
|
sb.append(" ");
|
||||||
String s;
|
String s = "";
|
||||||
switch (timeIndex) {
|
switch (timeIndex) {
|
||||||
case 0:
|
case 0:
|
||||||
s = "MS";
|
s = "MS";
|
||||||
@ -129,8 +129,6 @@ public class DiscordSetupAttempt {
|
|||||||
case 5:
|
case 5:
|
||||||
s = "Years";
|
s = "Years";
|
||||||
break;
|
break;
|
||||||
default:
|
|
||||||
throw new IllegalStateException("Unexpected value: " + timeIndex);
|
|
||||||
}
|
}
|
||||||
sb.append(s);
|
sb.append(s);
|
||||||
sb.append(" ago");
|
sb.append(" ago");
|
||||||
|
@ -35,7 +35,7 @@ public class FactionChatHandler extends ListenerAdapter {
|
|||||||
this.plugin = plugin;
|
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 factionsChatChannelId = faction.getFactionChatChannelId();
|
||||||
String messageWithMentions = null;
|
String messageWithMentions = null;
|
||||||
if (factionsChatChannelId == null || factionsChatChannelId.isEmpty()) return;
|
if (factionsChatChannelId == null || factionsChatChannelId.isEmpty()) return;
|
||||||
|
@ -48,7 +48,9 @@ public class Econ {
|
|||||||
}
|
}
|
||||||
econ = rsp.getProvider();
|
econ = rsp.getProvider();
|
||||||
FactionsPlugin.getInstance().log("Economy integration through Vault plugin successful.");
|
FactionsPlugin.getInstance().log("Economy integration through Vault plugin successful.");
|
||||||
if (!Conf.econEnabled) FactionsPlugin.getInstance().log("NOTE: Economy is disabled. You can enable it with the command: f config econEnabled true");
|
if (!Conf.econEnabled)
|
||||||
|
FactionsPlugin.getInstance().log("NOTE: Economy is disabled. You can enable it with the command: f config econEnabled true");
|
||||||
|
//FactionsPlugin.getInstance().cmdBase.cmdHelp.updateHelp();
|
||||||
}
|
}
|
||||||
|
|
||||||
public static boolean shouldBeUsed() {
|
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.
|
// 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)))
|
if (you instanceof Faction && fI == fYou && (Conf.bankMembersCanWithdraw || (i instanceof FPlayer && ((FPlayer) i).getRole().value >= Role.MODERATOR.value)))
|
||||||
return true;
|
return true;
|
||||||
|
// Otherwise you may not!;,,;
|
||||||
i.msg(TL.ECON_CANTCONTROLMONEY, i.describeTo(i, true), you.describeTo(i));
|
i.msg(TL.ECON_CANTCONTROLMONEY, i.describeTo(i, true), you.describeTo(i));
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
@ -235,7 +238,7 @@ public class Econ {
|
|||||||
acc = Bukkit.getOfflinePlayer(UUID.fromString(ep.getAccountId()));
|
acc = Bukkit.getOfflinePlayer(UUID.fromString(ep.getAccountId()));
|
||||||
if (acc.getName() == null) return false;
|
if (acc.getName() == null) return false;
|
||||||
} else acc = Bukkit.getOfflinePlayer(ep.getAccountId());
|
} else acc = Bukkit.getOfflinePlayer(ep.getAccountId());
|
||||||
String you = ep.describeTo(ep, true);
|
String You = ep.describeTo(ep, true);
|
||||||
|
|
||||||
if (delta == 0) return true;
|
if (delta == 0) return true;
|
||||||
else if (delta > 0) {
|
else if (delta > 0) {
|
||||||
@ -245,12 +248,12 @@ public class Econ {
|
|||||||
if (er.transactionSuccess()) {
|
if (er.transactionSuccess()) {
|
||||||
modifyUniverseMoney(-delta);
|
modifyUniverseMoney(-delta);
|
||||||
if (forDoingThis != null && !forDoingThis.isEmpty())
|
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;
|
return true;
|
||||||
} else {
|
} else {
|
||||||
// transfer to account failed
|
// transfer to account failed
|
||||||
if (forDoingThis != null && !forDoingThis.isEmpty())
|
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;
|
return false;
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
@ -260,12 +263,12 @@ public class Econ {
|
|||||||
// There is enough money to pay
|
// There is enough money to pay
|
||||||
modifyUniverseMoney(-delta);
|
modifyUniverseMoney(-delta);
|
||||||
if (forDoingThis != null && !forDoingThis.isEmpty())
|
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;
|
return true;
|
||||||
} else {
|
} else {
|
||||||
// There was not enough money to pay
|
// There was not enough money to pay
|
||||||
if (toDoThis != null && !toDoThis.isEmpty())
|
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;
|
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("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!");
|
FactionsPlugin.getInstance().log("WorldGuard 7.0.0 support is currently in BETA. Please be careful!");
|
||||||
regionContainer = null;
|
regionContainer = null;
|
||||||
|
return;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -12,6 +12,8 @@ import org.dynmap.DynmapAPI;
|
|||||||
import org.dynmap.markers.*;
|
import org.dynmap.markers.*;
|
||||||
import org.dynmap.utils.TileFlags;
|
import org.dynmap.utils.TileFlags;
|
||||||
|
|
||||||
|
import java.awt.*;
|
||||||
|
import java.util.List;
|
||||||
import java.util.*;
|
import java.util.*;
|
||||||
import java.util.Map.Entry;
|
import java.util.Map.Entry;
|
||||||
|
|
||||||
@ -26,17 +28,20 @@ public class EngineDynmap {
|
|||||||
// CONSTANTS
|
// 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 final static String FACTIONS = "factions";
|
||||||
public static final String FACTIONS_ = FACTIONS + "_";
|
public final static String FACTIONS_ = FACTIONS + "_";
|
||||||
public static final String FACTIONS_MARKERSET = FACTIONS_ + "markerset";
|
|
||||||
public static final String FACTIONS_HOME = FACTIONS_ + "home";
|
public final static String FACTIONS_MARKERSET = FACTIONS_ + "markerset";
|
||||||
public static final String FACTIONS_HOME_ = FACTIONS_HOME + "_";
|
|
||||||
public static final String FACTIONS_PLAYERSET = FACTIONS_ + "playerset";
|
public final static String FACTIONS_HOME = FACTIONS_ + "home";
|
||||||
public static final String FACTIONS_PLAYERSET_ = FACTIONS_PLAYERSET + "_";
|
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
|
// INSTANCE & CONSTRUCT
|
||||||
@ -47,6 +52,8 @@ public class EngineDynmap {
|
|||||||
public MarkerAPI markerApi;
|
public MarkerAPI markerApi;
|
||||||
public MarkerSet markerset;
|
public MarkerSet markerset;
|
||||||
|
|
||||||
|
List<List<Point>> polyLine = new ArrayList<List<Point>>();
|
||||||
|
|
||||||
private EngineDynmap() {
|
private EngineDynmap() {
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -77,9 +84,7 @@ public class EngineDynmap {
|
|||||||
for (int i = 0; i < string.length(); i++) {
|
for (int i = 0; i < string.length(); i++) {
|
||||||
char c = string.charAt(i);
|
char c = string.charAt(i);
|
||||||
if (c > 127 || c == '"' || c == '<' || c == '>' || c == '&') {
|
if (c > 127 || c == '"' || c == '<' || c == '>' || c == '&') {
|
||||||
out.append("&#")
|
out.append("&#").append((int) c).append(';');
|
||||||
.append((int) c)
|
|
||||||
.append(';');
|
|
||||||
} else {
|
} else {
|
||||||
out.append(c);
|
out.append(c);
|
||||||
}
|
}
|
||||||
@ -118,10 +123,12 @@ public class EngineDynmap {
|
|||||||
}
|
}
|
||||||
|
|
||||||
// Shedule non thread safe sync at the end!
|
// 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, TempMarker> homes = createHomes();
|
||||||
final Map<String, TempAreaMarker> areas = createAreas();
|
final Map<String, TempAreaMarker> areas = createAreas();
|
||||||
|
final Map<String, TempPolyLineMarker> polys = createPolys(areas);
|
||||||
final Map<String, Set<String>> playerSets = createPlayersets();
|
final Map<String, Set<String>> playerSets = createPlayersets();
|
||||||
|
|
||||||
if (!updateCore()) {
|
if (!updateCore()) {
|
||||||
@ -135,6 +142,7 @@ public class EngineDynmap {
|
|||||||
|
|
||||||
updateHomes(homes);
|
updateHomes(homes);
|
||||||
updateAreas(areas);
|
updateAreas(areas);
|
||||||
|
updatePolys(polys);
|
||||||
updatePlayersets(playerSets);
|
updatePlayersets(playerSets);
|
||||||
}, 100L, 100L);
|
}, 100L, 100L);
|
||||||
}
|
}
|
||||||
@ -236,6 +244,7 @@ public class EngineDynmap {
|
|||||||
// NOTE: That way what is left at the end will be outdated markers to remove.
|
// NOTE: That way what is left at the end will be outdated markers to remove.
|
||||||
Marker marker = markers.remove(markerId);
|
Marker marker = markers.remove(markerId);
|
||||||
if (marker == null) {
|
if (marker == null) {
|
||||||
|
marker = temp.create(this.markerApi, this.markerset, markerId);
|
||||||
marker = temp.create(this.markerApi, this.markerset, markerId);
|
marker = temp.create(this.markerApi, this.markerset, markerId);
|
||||||
if (marker == null) {
|
if (marker == null) {
|
||||||
EngineDynmap.severe("Could not get/create the home marker " + markerId);
|
EngineDynmap.severe("Could not get/create the home marker " + markerId);
|
||||||
@ -257,6 +266,29 @@ public class EngineDynmap {
|
|||||||
// -------------------------------------------- //
|
// -------------------------------------------- //
|
||||||
|
|
||||||
// Thread Safe: YES
|
// 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() {
|
public Map<String, TempAreaMarker> createAreas() {
|
||||||
Map<String, Map<Faction, Set<FLocation>>> worldFactionChunks = createWorldFactionChunks();
|
Map<String, Map<Faction, Set<FLocation>>> worldFactionChunks = createWorldFactionChunks();
|
||||||
return createAreas(worldFactionChunks);
|
return createAreas(worldFactionChunks);
|
||||||
@ -274,13 +306,13 @@ public class EngineDynmap {
|
|||||||
String world = entry.getKey().getWorldName();
|
String world = entry.getKey().getWorldName();
|
||||||
Faction chunkOwner = Factions.getInstance().getFactionById(entry.getValue());
|
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) {
|
if (factionChunks == null) {
|
||||||
factionChunks = new HashMap<>();
|
factionChunks = new HashMap<>();
|
||||||
worldFactionChunks.put(world, factionChunks);
|
worldFactionChunks.put(world, factionChunks);
|
||||||
}
|
}
|
||||||
|
|
||||||
Set<FLocation> factionTerritory = factionChunks.computeIfAbsent(chunkOwner, s -> null);
|
Set<FLocation> factionTerritory = factionChunks.get(chunkOwner);
|
||||||
if (factionTerritory == null) {
|
if (factionTerritory == null) {
|
||||||
factionTerritory = new HashSet<>();
|
factionTerritory = new HashSet<>();
|
||||||
factionChunks.put(chunkOwner, factionTerritory);
|
factionChunks.put(chunkOwner, factionTerritory);
|
||||||
@ -348,12 +380,11 @@ public class EngineDynmap {
|
|||||||
|
|
||||||
// Loop through until we don't find more areas
|
// Loop through until we don't find more areas
|
||||||
while (allChunks != null) {
|
while (allChunks != null) {
|
||||||
|
|
||||||
TileFlags ourChunkFlags = null;
|
TileFlags ourChunkFlags = null;
|
||||||
LinkedList<FLocation> ourChunks = null;
|
LinkedList<FLocation> ourChunks = null;
|
||||||
LinkedList<FLocation> newChunks = null;
|
LinkedList<FLocation> newChunks = null;
|
||||||
|
|
||||||
int minimumX = Integer.MAX_VALUE;
|
|
||||||
int minimumZ = Integer.MAX_VALUE;
|
|
||||||
for (FLocation chunk : allChunks) {
|
for (FLocation chunk : allChunks) {
|
||||||
int chunkX = (int) chunk.getX();
|
int chunkX = (int) chunk.getX();
|
||||||
int chunkZ = (int) chunk.getZ();
|
int chunkZ = (int) chunk.getZ();
|
||||||
@ -364,18 +395,10 @@ public class EngineDynmap {
|
|||||||
ourChunks = new LinkedList<>();
|
ourChunks = new LinkedList<>();
|
||||||
floodFillTarget(allChunkFlags, ourChunkFlags, chunkX, chunkZ); // Copy shape
|
floodFillTarget(allChunkFlags, ourChunkFlags, chunkX, chunkZ); // Copy shape
|
||||||
ourChunks.add(chunk); // Add it to our chunk list
|
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
|
// If shape found, and we're in it, add to our node list
|
||||||
else if (ourChunkFlags != null && ourChunkFlags.getFlag(chunkX, chunkZ)) {
|
else if (ourChunkFlags != null && ourChunkFlags.getFlag(chunkX, chunkZ)) {
|
||||||
ourChunks.add(chunk);
|
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, keep it in the list for the next polygon
|
||||||
else {
|
else {
|
||||||
@ -388,86 +411,129 @@ public class EngineDynmap {
|
|||||||
|
|
||||||
// Replace list (null if no more to process)
|
// Replace list (null if no more to process)
|
||||||
allChunks = newChunks;
|
allChunks = newChunks;
|
||||||
|
|
||||||
if (ourChunkFlags == null) {
|
if (ourChunkFlags == null) {
|
||||||
continue;
|
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+
|
if (ourChunks == null) {
|
||||||
int initialX = minimumX;
|
continue;
|
||||||
int initialZ = minimumZ;
|
}
|
||||||
int currentX = minimumX;
|
|
||||||
int currentZ = minimumZ;
|
for (FLocation loc : ourChunks) {
|
||||||
Direction direction = Direction.XPLUS;
|
int x = loc.getChunk().getX();
|
||||||
ArrayList<int[]> linelist = new ArrayList<>();
|
int z = loc.getChunk().getZ();
|
||||||
linelist.add(new int[]{initialX, initialZ}); // Add start point
|
|
||||||
while ((currentX != initialX) || (currentZ != initialZ) || (direction != Direction.ZMINUS)) {
|
TempLine line = new TempLine(new Point(x * 16, z * 16), new Point(x * 16 + 16, z * 16));
|
||||||
switch (direction) {
|
if (lines.containsKey(line)) {
|
||||||
case XPLUS: // Segment in X+ direction
|
lines.put(line, lines.get(line) + 1);
|
||||||
if (!ourChunkFlags.getFlag(currentX + 1, currentZ)) { // Right turn?
|
} else {
|
||||||
linelist.add(new int[]{currentX + 1, currentZ}); // Finish line
|
lines.put(line, 1);
|
||||||
direction = Direction.ZPLUS; // Change direction
|
}
|
||||||
} else if (!ourChunkFlags.getFlag(currentX + 1, currentZ - 1)) { // Straight?
|
|
||||||
currentX++;
|
line = new TempLine(new Point(x * 16 + 16, z * 16), new Point(x * 16 + 16, z * 16 + 16));
|
||||||
} else { // Left turn
|
if (lines.containsKey(line)) {
|
||||||
linelist.add(new int[]{currentX + 1, currentZ}); // Finish line
|
lines.put(line, lines.get(line) + 1);
|
||||||
direction = Direction.ZMINUS;
|
} else {
|
||||||
currentX++;
|
lines.put(line, 1);
|
||||||
currentZ--;
|
}
|
||||||
}
|
|
||||||
break;
|
line = new TempLine(new Point(x * 16 + 16, z * 16 + 16), new Point(x * 16, z * 16 + 16));
|
||||||
case ZPLUS: // Segment in Z+ direction
|
if (lines.containsKey(line)) {
|
||||||
if (!ourChunkFlags.getFlag(currentX, currentZ + 1)) { // Right turn?
|
lines.put(line, lines.get(line) + 1);
|
||||||
linelist.add(new int[]{currentX + 1, currentZ + 1}); // Finish line
|
} else {
|
||||||
direction = Direction.XMINUS; // Change direction
|
lines.put(line, 1);
|
||||||
} else if (!ourChunkFlags.getFlag(currentX + 1, currentZ + 1)) { // Straight?
|
}
|
||||||
currentZ++;
|
|
||||||
} else { // Left turn
|
line = new TempLine(new Point(x * 16, z * 16 + 16), new Point(x * 16, z * 16));
|
||||||
linelist.add(new int[]{currentX + 1, currentZ + 1}); // Finish line
|
if (lines.containsKey(line)) {
|
||||||
direction = Direction.XPLUS;
|
lines.put(line, lines.get(line) + 1);
|
||||||
currentX++;
|
} else {
|
||||||
currentZ++;
|
lines.put(line, 1);
|
||||||
}
|
|
||||||
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;
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
int sz = linelist.size();
|
Iterator<Entry<TempLine, Integer>> iterator = lines.entrySet().iterator();
|
||||||
double[] x = new double[sz];
|
|
||||||
double[] z = new double[sz];
|
List<TempLine> lineList = new ArrayList<TempLine>();
|
||||||
for (int i = 0; i < sz; i++) {
|
lineList.addAll(lines.keySet());
|
||||||
int[] line = linelist.get(i);
|
|
||||||
x[i] = (double) line[0] * (double) BLOCKS_PER_CHUNK;
|
while (iterator.hasNext()) {
|
||||||
z[i] = (double) line[1] * (double) BLOCKS_PER_CHUNK;
|
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
|
// 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;
|
String markerId = FACTIONS_ + world + "__" + faction.getId() + "__" + markerIndex;
|
||||||
|
|
||||||
TempAreaMarker temp = new TempAreaMarker();
|
TempAreaMarker temp = new TempAreaMarker();
|
||||||
@ -485,8 +551,10 @@ public class EngineDynmap {
|
|||||||
temp.fillOpacity = style.getFillOpacity();
|
temp.fillOpacity = style.getFillOpacity();
|
||||||
|
|
||||||
temp.boost = style.getBoost();
|
temp.boost = style.getBoost();
|
||||||
|
temp.setPolyLine(polyLine);
|
||||||
|
|
||||||
ret.put(markerId, temp);
|
ret.put(markerId, temp);
|
||||||
|
polyLine.clear();
|
||||||
|
|
||||||
markerIndex++;
|
markerIndex++;
|
||||||
}
|
}
|
||||||
@ -494,10 +562,114 @@ public class EngineDynmap {
|
|||||||
return ret;
|
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
|
// 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
|
// Thread Safe: NO
|
||||||
public void updateAreas(Map<String, TempAreaMarker> areas) {
|
public void updateAreas(Map<String, TempAreaMarker> areas) {
|
||||||
// Map Current
|
// Map Current
|
||||||
@ -655,7 +827,6 @@ public class EngineDynmap {
|
|||||||
money = String.format("%.2f", Econ.getBalance(faction.getAccountId()));
|
money = String.format("%.2f", Econ.getBalance(faction.getAccountId()));
|
||||||
ret = ret.replace("%money%", money);
|
ret = ret.replace("%money%", money);
|
||||||
|
|
||||||
|
|
||||||
// Players
|
// Players
|
||||||
Set<FPlayer> playersList = faction.getFPlayers();
|
Set<FPlayer> playersList = faction.getFPlayers();
|
||||||
String playersCount = String.valueOf(playersList.size());
|
String playersCount = String.valueOf(playersList.size());
|
||||||
@ -672,7 +843,6 @@ public class EngineDynmap {
|
|||||||
String playersModeratorsCount = String.valueOf(playersModeratorsList.size());
|
String playersModeratorsCount = String.valueOf(playersModeratorsList.size());
|
||||||
String playersModerators = getHtmlPlayerString(playersModeratorsList);
|
String playersModerators = getHtmlPlayerString(playersModeratorsList);
|
||||||
|
|
||||||
|
|
||||||
ArrayList<FPlayer> playersNormalsList = faction.getFPlayersWhereRole(Role.NORMAL);
|
ArrayList<FPlayer> playersNormalsList = faction.getFPlayersWhereRole(Role.NORMAL);
|
||||||
String playersNormalsCount = String.valueOf(playersNormalsList.size());
|
String playersNormalsCount = String.valueOf(playersNormalsList.size());
|
||||||
String playersNormals = getHtmlPlayerString(playersNormalsList);
|
String playersNormals = getHtmlPlayerString(playersNormalsList);
|
||||||
@ -732,7 +902,8 @@ public class EngineDynmap {
|
|||||||
}
|
}
|
||||||
|
|
||||||
// Find all contiguous blocks, set in target and clear in source
|
// 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<>();
|
ArrayDeque<int[]> stack = new ArrayDeque<>();
|
||||||
stack.push(new int[]{x, y});
|
stack.push(new int[]{x, y});
|
||||||
|
|
||||||
@ -743,6 +914,7 @@ public class EngineDynmap {
|
|||||||
if (source.getFlag(x, y)) { // Set in src
|
if (source.getFlag(x, y)) { // Set in src
|
||||||
source.setFlag(x, y, false); // Clear source
|
source.setFlag(x, y, false); // Clear source
|
||||||
destination.setFlag(x, y, true); // Set in destination
|
destination.setFlag(x, y, true); // Set in destination
|
||||||
|
cnt++;
|
||||||
if (source.getFlag(x + 1, y)) {
|
if (source.getFlag(x + 1, y)) {
|
||||||
stack.push(new int[]{x + 1, y});
|
stack.push(new int[]{x + 1, y});
|
||||||
}
|
}
|
||||||
@ -757,6 +929,7 @@ public class EngineDynmap {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
return cnt;
|
||||||
}
|
}
|
||||||
|
|
||||||
enum Direction {
|
enum Direction {
|
||||||
|
@ -3,6 +3,10 @@ package com.massivecraft.factions.integration.dynmap;
|
|||||||
import org.dynmap.markers.AreaMarker;
|
import org.dynmap.markers.AreaMarker;
|
||||||
import org.dynmap.markers.MarkerSet;
|
import org.dynmap.markers.MarkerSet;
|
||||||
|
|
||||||
|
import java.awt.*;
|
||||||
|
import java.util.ArrayList;
|
||||||
|
import java.util.List;
|
||||||
|
|
||||||
public class TempAreaMarker {
|
public class TempAreaMarker {
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -18,15 +22,13 @@ public class TempAreaMarker {
|
|||||||
public double[] x;
|
public double[] x;
|
||||||
public double[] z;
|
public double[] z;
|
||||||
public String description;
|
public String description;
|
||||||
|
|
||||||
public int lineColor;
|
public int lineColor;
|
||||||
public double lineOpacity;
|
public double lineOpacity;
|
||||||
public int lineWeight;
|
public int lineWeight;
|
||||||
|
|
||||||
public int fillColor;
|
public int fillColor;
|
||||||
public double fillOpacity;
|
public double fillOpacity;
|
||||||
|
|
||||||
public boolean boost;
|
public boolean boost;
|
||||||
|
private List<List<Point>> polyLine = new ArrayList<List<Point>>();
|
||||||
|
|
||||||
// -------------------------------------------- //
|
// -------------------------------------------- //
|
||||||
// CREATE
|
// CREATE
|
||||||
@ -54,6 +56,15 @@ public class TempAreaMarker {
|
|||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public List<List<Point>> getPolyLine() {
|
||||||
|
return polyLine;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setPolyLine(List<List<Point>> points) {
|
||||||
|
polyLine.clear();
|
||||||
|
polyLine.addAll(points);
|
||||||
|
}
|
||||||
|
|
||||||
// -------------------------------------------- //
|
// -------------------------------------------- //
|
||||||
// UPDATE
|
// UPDATE
|
||||||
// -------------------------------------------- //
|
// -------------------------------------------- //
|
||||||
@ -61,16 +72,17 @@ public class TempAreaMarker {
|
|||||||
public AreaMarker create(MarkerSet markerset, String markerId) {
|
public AreaMarker create(MarkerSet markerset, String markerId) {
|
||||||
AreaMarker ret = markerset.createAreaMarker(markerId, this.label, false, this.world, this.x, this.z, false // not persistent
|
AreaMarker ret = markerset.createAreaMarker(markerId, this.label, false, this.world, this.x, this.z, false // not persistent
|
||||||
);
|
);
|
||||||
|
|
||||||
if (ret == null) {
|
if (ret == null) {
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
int counter = 0;
|
||||||
|
|
||||||
// Description
|
// Description
|
||||||
ret.setDescription(this.description);
|
ret.setDescription(this.description);
|
||||||
|
|
||||||
// Line Style
|
// Line Style
|
||||||
ret.setLineStyle(this.lineWeight, this.lineOpacity, this.lineColor);
|
ret.setLineStyle(0, 0, 0);
|
||||||
|
|
||||||
// Fill Style
|
// Fill Style
|
||||||
ret.setFillStyle(this.fillOpacity, this.fillColor);
|
ret.setFillStyle(this.fillOpacity, this.fillColor);
|
||||||
@ -80,7 +92,6 @@ public class TempAreaMarker {
|
|||||||
|
|
||||||
return ret;
|
return ret;
|
||||||
}
|
}
|
||||||
|
|
||||||
// -------------------------------------------- //
|
// -------------------------------------------- //
|
||||||
// UTIL
|
// UTIL
|
||||||
// -------------------------------------------- //
|
// -------------------------------------------- //
|
||||||
@ -95,18 +106,15 @@ public class TempAreaMarker {
|
|||||||
if (!marker.getLabel().equals(this.label)) {
|
if (!marker.getLabel().equals(this.label)) {
|
||||||
marker.setLabel(this.label);
|
marker.setLabel(this.label);
|
||||||
}
|
}
|
||||||
|
|
||||||
// Description
|
|
||||||
if (!marker.getDescription().equals(this.description)) {
|
if (!marker.getDescription().equals(this.description)) {
|
||||||
marker.setDescription(this.description);
|
marker.setDescription(this.description);
|
||||||
}
|
}
|
||||||
|
|
||||||
// Line Style
|
// // Line Style
|
||||||
if (marker.getLineWeight() != this.lineWeight ||
|
// if (marker.getLineWeight() != this.lineWeight || marker.getLineOpacity() != this.lineOpacity || marker.getLineColor() != this.lineColor)
|
||||||
marker.getLineOpacity() != this.lineOpacity ||
|
// {
|
||||||
marker.getLineColor() != this.lineColor) {
|
// marker.setLineStyle(this.lineWeight, this.lineOpacity, this.lineColor);
|
||||||
marker.setLineStyle(this.lineWeight, this.lineOpacity, this.lineColor);
|
// }
|
||||||
}
|
|
||||||
|
|
||||||
// Fill Style
|
// Fill Style
|
||||||
if ((marker.getFillOpacity() != this.fillOpacity) || (marker.getFillColor() != this.fillColor)) {
|
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 boolean hideByDefault;
|
||||||
|
|
||||||
public MarkerSet create(MarkerAPI markerApi, String id) {
|
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) {
|
if (ret == null) {
|
||||||
return null;
|
return null;
|
||||||
@ -41,8 +41,10 @@ public class TempMarkerSet {
|
|||||||
markerset.setMarkerSetLabel(this.label);
|
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);
|
markerset.setMinZoom(this.minimumZoom);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (markerset.getLayerPriority() != this.priority) {
|
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);
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
@ -47,8 +47,6 @@ public class FactionsBlockListener implements Listener {
|
|||||||
public static HashMap<String, Location> bannerLocations = new HashMap<>();
|
public static HashMap<String, Location> bannerLocations = new HashMap<>();
|
||||||
private HashMap<String, Boolean> bannerCooldownMap = new HashMap<>();
|
private HashMap<String, Boolean> bannerCooldownMap = new HashMap<>();
|
||||||
private long placeTimer = TimeUnit.SECONDS.toMillis(15L);
|
private long placeTimer = TimeUnit.SECONDS.toMillis(15L);
|
||||||
private static final String varFac = "{faction}";
|
|
||||||
private static final String varAction = "{action}";
|
|
||||||
|
|
||||||
|
|
||||||
public static boolean playerCanBuildDestroyBlock(Player player, Location location, String action, boolean justCheck) {
|
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 (otherFaction.isWilderness()) {
|
||||||
if (Conf.worldGuardBuildPriority && Worldguard.getInstance().playerCanBuild(player, location)) return true;
|
if (Conf.worldGuardBuildPriority && Worldguard.getInstance().playerCanBuild(player, location)) return true;
|
||||||
if (location.getWorld() != null && !Conf.wildernessDenyBuild || Conf.worldsNoWildernessProtection.contains(location.getWorld().getName())) {
|
if (location.getWorld() != null) {
|
||||||
return true;
|
if (!Conf.wildernessDenyBuild || Conf.worldsNoWildernessProtection.contains(location.getWorld().getName()))
|
||||||
|
return true;
|
||||||
}
|
}
|
||||||
if (!justCheck) me.msg(TL.ACTION_DENIED_WILDERNESS, action);
|
if (!justCheck) me.msg(TL.ACTION_DENIED_WILDERNESS, action);
|
||||||
return false;
|
return false;
|
||||||
@ -94,27 +93,24 @@ public class FactionsBlockListener implements Listener {
|
|||||||
boolean landOwned = (myFaction.doesLocationHaveOwnersSet(loc) && !myFaction.getOwnerList(loc).isEmpty());
|
boolean landOwned = (myFaction.doesLocationHaveOwnersSet(loc) && !myFaction.getOwnerList(loc).isEmpty());
|
||||||
if ((landOwned && myFaction.getOwnerListString(loc).contains(player.getName())) || (me.getRole() == Role.LEADER && me.getFactionId().equals(myFaction.getId())))
|
if ((landOwned && myFaction.getOwnerListString(loc).contains(player.getName())) || (me.getRole() == Role.LEADER && me.getFactionId().equals(myFaction.getId())))
|
||||||
return true;
|
return true;
|
||||||
else {
|
else if (landOwned && !myFaction.getOwnerListString(loc).contains(player.getName())) {
|
||||||
String replace = TL.ACTIONS_NOPERMISSIONPAIN.toString().replace(varAction, action.toString());
|
me.msg(TL.ACTIONS_OWNEDTERRITORYDENY.toString().replace("{owners}", myFaction.getOwnerListString(loc)));
|
||||||
if (landOwned && !myFaction.getOwnerListString(loc).contains(player.getName())) {
|
if (shouldHurt) {
|
||||||
me.msg(TL.ACTIONS_OWNEDTERRITORYDENY.toString().replace("{owners}", myFaction.getOwnerListString(loc)));
|
player.damage(Conf.actionDeniedPainAmount);
|
||||||
if (shouldHurt) {
|
me.msg(TL.ACTIONS_NOPERMISSIONPAIN.toString().replace("{action}", action.toString()).replace("{faction}", Board.getInstance().getFactionAt(loc).getTag(myFaction)));
|
||||||
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
|
||||||
return false;
|
if (shouldHurt) {
|
||||||
} else if (!landOwned && access == Access.DENY) { // If land is not owned but access is set to DENY anyway
|
player.damage(Conf.actionDeniedPainAmount);
|
||||||
if (shouldHurt) {
|
if ((Board.getInstance().getFactionAt(loc).getTag(myFaction)) != null)
|
||||||
player.damage(Conf.actionDeniedPainAmount);
|
me.msg(TL.ACTIONS_NOPERMISSIONPAIN.toString().replace("{action}", action.toString()).replace("{faction}", Board.getInstance().getFactionAt(loc).getTag(myFaction)));
|
||||||
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("{faction}", myFaction.getTag(me.getFaction())).replace("{action}", action.toString()));
|
||||||
if (myFaction.getTag(me.getFaction()) != null && action != null)
|
return false;
|
||||||
me.msg(TL.ACTIONS_NOPERMISSION.toString().replace(varFac, myFaction.getTag(me.getFaction())).replace(varAction, action.toString()));
|
} else if (access == Access.ALLOW) return true;
|
||||||
return false;
|
me.msg(TL.ACTIONS_NOPERMISSION.toString().replace("{faction}", myFaction.getTag(me.getFaction())).replace("{action}", action.toString()));
|
||||||
} else if (access == Access.ALLOW) return true;
|
|
||||||
}
|
|
||||||
me.msg(TL.ACTIONS_NOPERMISSION.toString().replace(varFac, myFaction.getTag(me.getFaction())).replace(varAction, action.toString()));
|
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -122,10 +118,10 @@ public class FactionsBlockListener implements Listener {
|
|||||||
if (Conf.ownedAreasEnabled && target.doesLocationHaveOwnersSet(location) && !target.playerHasOwnershipRights(me, location)) {
|
if (Conf.ownedAreasEnabled && target.doesLocationHaveOwnersSet(location) && !target.playerHasOwnershipRights(me, location)) {
|
||||||
// If pain should be applied
|
// If pain should be applied
|
||||||
if (pain && Conf.ownedAreaPainBuild)
|
if (pain && Conf.ownedAreaPainBuild)
|
||||||
me.msg(TL.ACTIONS_OWNEDTERRITORYPAINDENY.toString().replace(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;
|
if (Conf.ownedAreaDenyBuild && pain) return false;
|
||||||
else if (Conf.ownedAreaDenyBuild) {
|
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;
|
return false;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -172,9 +168,11 @@ public class FactionsBlockListener implements Listener {
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (isSpawner && Conf.spawnerLock) {
|
if (isSpawner) {
|
||||||
event.setCancelled(true);
|
if (Conf.spawnerLock) {
|
||||||
event.getPlayer().sendMessage(FactionsPlugin.getInstance().color(TL.COMMAND_SPAWNER_LOCK_CANNOT_PLACE.toString()));
|
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) {
|
public void onBlockFromTo(BlockFromToEvent event) {
|
||||||
if (!Conf.handleExploitLiquidFlow) return;
|
if (!Conf.handleExploitLiquidFlow) return;
|
||||||
|
|
||||||
if (event.getBlock().isLiquid() && event.getToBlock().isEmpty()) {
|
if (event.getBlock().isLiquid()) {
|
||||||
Faction from = Board.getInstance().getFactionAt(new FLocation(event.getBlock()));
|
if (event.getToBlock().isEmpty()) {
|
||||||
Faction to = Board.getInstance().getFactionAt(new FLocation(event.getToBlock()));
|
Faction from = Board.getInstance().getFactionAt(new FLocation(event.getBlock()));
|
||||||
if (from == to) return;
|
Faction to = Board.getInstance().getFactionAt(new FLocation(event.getToBlock()));
|
||||||
// from faction != to faction
|
if (from == to) return;
|
||||||
if (to.isSystemFaction()) {
|
// from faction != to faction
|
||||||
event.setCancelled(true);
|
if (to.isSystemFaction()) {
|
||||||
return;
|
event.setCancelled(true);
|
||||||
}
|
|
||||||
|
|
||||||
if (to.isNormal()) {
|
|
||||||
if (from.isNormal() && from.getRelationTo(to).isAlly()) {
|
|
||||||
return;
|
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);
|
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 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);
|
event.setCancelled(true);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -286,10 +286,12 @@ public class FactionsBlockListener implements Listener {
|
|||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (blockLoc.getBlock().getType() == XMaterial.CHEST.parseMaterial() && factionAt.getVault().equals(blockLoc)) {
|
if (blockLoc.getBlock().getType() == XMaterial.CHEST.parseMaterial()) {
|
||||||
e.setCancelled(true);
|
if (factionAt.getVault().equals(blockLoc)) {
|
||||||
fme.msg(TL.COMMAND_VAULT_NO_HOPPER);
|
e.setCancelled(true);
|
||||||
return;
|
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 potentially retracted block is just air/water/lava, no worries
|
||||||
if (targetLoc.getBlock().isEmpty() || targetLoc.getBlock().isLiquid()) return;
|
if (targetLoc.getBlock().isEmpty() || targetLoc.getBlock().isLiquid()) return;
|
||||||
Faction pistonFaction = Board.getInstance().getFactionAt(new FLocation(event.getBlock()));
|
Faction pistonFaction = Board.getInstance().getFactionAt(new FLocation(event.getBlock()));
|
||||||
if (canPistonMoveBlock(pistonFaction, targetLoc)) event.setCancelled(true);
|
if (!canPistonMoveBlock(pistonFaction, targetLoc)) event.setCancelled(true);
|
||||||
}
|
}
|
||||||
|
|
||||||
@EventHandler
|
@EventHandler
|
||||||
@ -324,9 +326,11 @@ public class FactionsBlockListener implements Listener {
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (bannerLocations.containsValue(e.getBlock().getLocation()) && e.getBlock().getType().name().contains("BANNER")) {
|
if (bannerLocations.containsValue(e.getBlock().getLocation())) {
|
||||||
e.setCancelled(true);
|
if (e.getBlock().getType().name().contains("BANNER")) {
|
||||||
fme.msg(TL.BANNER_CANNOT_BREAK);
|
e.setCancelled(true);
|
||||||
|
fme.msg(TL.BANNER_CANNOT_BREAK);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -426,7 +430,7 @@ public class FactionsBlockListener implements Listener {
|
|||||||
if (!justCheck) fPlayer.setLastFrostwalkerMessage();
|
if (!justCheck) fPlayer.setLastFrostwalkerMessage();
|
||||||
|
|
||||||
// Check if they have build permissions here. If not, block this from happening.
|
// Check if they have build permissions here. If not, block this from happening.
|
||||||
if (!playerCanBuildDestroyBlock(player, location, PermissableAction.FROST_WALK.toString(), justCheck))
|
if (!playerCanBuildDestroyBlock(player, location, "frostwalk", justCheck))
|
||||||
event.setCancelled(true);
|
event.setCancelled(true);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -445,15 +449,15 @@ public class FactionsBlockListener implements Listener {
|
|||||||
private boolean canPistonMoveBlock(Faction pistonFaction, Location target) {
|
private boolean canPistonMoveBlock(Faction pistonFaction, Location target) {
|
||||||
Faction otherFaction = Board.getInstance().getFactionAt(new FLocation(target));
|
Faction otherFaction = Board.getInstance().getFactionAt(new FLocation(target));
|
||||||
|
|
||||||
if (pistonFaction == otherFaction) return false;
|
if (pistonFaction == otherFaction) return true;
|
||||||
|
|
||||||
if (otherFaction.isWilderness())
|
if (otherFaction.isWilderness())
|
||||||
return Conf.wildernessDenyBuild && !Conf.worldsNoWildernessProtection.contains(target.getWorld().getName());
|
return !Conf.wildernessDenyBuild || Conf.worldsNoWildernessProtection.contains(target.getWorld().getName());
|
||||||
else if (otherFaction.isSafeZone()) return Conf.safeZoneDenyBuild;
|
else if (otherFaction.isSafeZone()) return !Conf.safeZoneDenyBuild;
|
||||||
else if (otherFaction.isWarZone()) return Conf.warZoneDenyBuild;
|
else if (otherFaction.isWarZone()) return !Conf.warZoneDenyBuild;
|
||||||
|
|
||||||
Relation rel = pistonFaction.getRelationTo(otherFaction);
|
Relation rel = pistonFaction.getRelationTo(otherFaction);
|
||||||
return rel.confDenyBuild(otherFaction.hasPlayersOnline());
|
return !rel.confDenyBuild(otherFaction.hasPlayersOnline());
|
||||||
}
|
}
|
||||||
|
|
||||||
@EventHandler(priority = EventPriority.NORMAL, ignoreCancelled = true)
|
@EventHandler(priority = EventPriority.NORMAL, ignoreCancelled = true)
|
||||||
@ -501,12 +505,14 @@ public class FactionsBlockListener implements Listener {
|
|||||||
|
|
||||||
|
|
||||||
@EventHandler(priority = EventPriority.HIGHEST)
|
@EventHandler(priority = EventPriority.HIGHEST)
|
||||||
public void frameRemove(HangingBreakByEntityEvent event) {
|
public void FrameRemove(HangingBreakByEntityEvent event) {
|
||||||
if (event.getRemover() == null) return;
|
if (event.getRemover() == null) return;
|
||||||
if ((event.getRemover() instanceof Player) && event.getEntity().getType().equals(EntityType.ITEM_FRAME)) {
|
if ((event.getRemover() instanceof Player)) {
|
||||||
Player p = (Player) event.getRemover();
|
if (event.getEntity().getType().equals(EntityType.ITEM_FRAME)) {
|
||||||
if (!playerCanBuildDestroyBlock(p, event.getEntity().getLocation(), "destroy", true)) {
|
Player p = (Player) event.getRemover();
|
||||||
event.setCancelled(true);
|
if (!playerCanBuildDestroyBlock(p, event.getEntity().getLocation(), "destroy", true)) {
|
||||||
|
event.setCancelled(true);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -515,7 +521,7 @@ public class FactionsBlockListener implements Listener {
|
|||||||
public void onFarmLandDamage(EntityChangeBlockEvent event) {
|
public void onFarmLandDamage(EntityChangeBlockEvent event) {
|
||||||
if (event.getEntity() instanceof Player) {
|
if (event.getEntity() instanceof Player) {
|
||||||
Player player = (Player) event.getEntity();
|
Player player = (Player) event.getEntity();
|
||||||
if (!playerCanBuildDestroyBlock(player, event.getBlock().getLocation(), PermissableAction.DESTROY.name(), true)) {
|
if (!playerCanBuildDestroyBlock(player, event.getBlock().getLocation(), "destroy", true)) {
|
||||||
FPlayer me = FPlayers.getInstance().getByPlayer(player);
|
FPlayer me = FPlayers.getInstance().getByPlayer(player);
|
||||||
Faction otherFaction = Board.getInstance().getFactionAt(new FLocation(event.getBlock().getLocation()));
|
Faction otherFaction = Board.getInstance().getFactionAt(new FLocation(event.getBlock().getLocation()));
|
||||||
me.msg(TL.ACTION_DENIED_OTHER, otherFaction.getTag(), "trample crops");
|
me.msg(TL.ACTION_DENIED_OTHER, otherFaction.getTag(), "trample crops");
|
||||||
@ -523,4 +529,4 @@ public class FactionsBlockListener implements Listener {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
@ -87,7 +87,7 @@ public class FactionsChatListener implements Listener {
|
|||||||
fplayer.sendMessage("[FCspy] " + myFaction.getTag() + ": " + message);
|
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);
|
event.setCancelled(true);
|
||||||
} else if (chat == ChatMode.ALLIANCE) {
|
} else if (chat == ChatMode.ALLIANCE) {
|
||||||
Faction myFaction = me.getFaction();
|
Faction myFaction = me.getFaction();
|
||||||
|
@ -143,7 +143,7 @@ public class FactionsEntityListener implements Listener {
|
|||||||
} else {
|
} else {
|
||||||
// we don't want to let mobs/arrows destroy item frames/armor stands
|
// 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
|
// 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);
|
event.setCancelled(true);
|
||||||
}
|
}
|
||||||
// we don't need to go after
|
// we don't need to go after
|
||||||
@ -216,7 +216,7 @@ public class FactionsEntityListener implements Listener {
|
|||||||
Entity boomer = event.getEntity();
|
Entity boomer = event.getEntity();
|
||||||
|
|
||||||
// Before we need to check the location where the block is placed
|
// 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);
|
event.setCancelled(true);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
@ -224,7 +224,7 @@ public class FactionsEntityListener implements Listener {
|
|||||||
// Loop the blocklist to run checks on each aimed block
|
// Loop the blocklist to run checks on each aimed block
|
||||||
|
|
||||||
// The block don't have to explode
|
// 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
|
// Cancel the event if no block will explode
|
||||||
if (!event.blockList().isEmpty() && (boomer instanceof TNTPrimed || boomer instanceof ExplosiveMinecart) && Conf.handleExploitTNTWaterlog) {
|
if (!event.blockList().isEmpty() && (boomer instanceof TNTPrimed || boomer instanceof ExplosiveMinecart) && Conf.handleExploitTNTWaterlog) {
|
||||||
@ -259,7 +259,7 @@ public class FactionsEntityListener implements Listener {
|
|||||||
Faction faction = Board.getInstance().getFactionAt(new FLocation(block.getLocation()));
|
Faction faction = Board.getInstance().getFactionAt(new FLocation(block.getLocation()));
|
||||||
|
|
||||||
if (faction.noExplosionsInTerritory() || (faction.isPeaceful() && Conf.peacefulTerritoryDisableBoom))
|
if (faction.noExplosionsInTerritory() || (faction.isPeaceful() && Conf.peacefulTerritoryDisableBoom))
|
||||||
return true;
|
return false;
|
||||||
// faction is peaceful and has explosions set to disabled
|
// faction is peaceful and has explosions set to disabled
|
||||||
|
|
||||||
boolean online = faction.hasPlayersOnline();
|
boolean online = faction.hasPlayersOnline();
|
||||||
@ -269,17 +269,17 @@ public class FactionsEntityListener implements Listener {
|
|||||||
(faction.isWarZone() && Conf.warZoneBlockCreepers) ||
|
(faction.isWarZone() && Conf.warZoneBlockCreepers) ||
|
||||||
faction.isSafeZone())) {
|
faction.isSafeZone())) {
|
||||||
// creeper which needs prevention
|
// creeper which needs prevention
|
||||||
return true;
|
return false;
|
||||||
} else if (
|
} 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
|
// 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())) {
|
(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
|
// ghast fireball which needs prevention
|
||||||
return true;
|
return false;
|
||||||
} else
|
} else
|
||||||
return (boomer instanceof TNTPrimed || boomer instanceof ExplosiveMinecart) && ((faction.isWilderness() && Conf.wildernessBlockTNT && !Conf.worldsNoWildernessProtection.contains(block.getWorld().getName())) ||
|
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.isNormal() || (online ? !Conf.territoryBlockTNT : !Conf.territoryBlockTNTWhenOffline)) &&
|
||||||
(faction.isWarZone() && Conf.warZoneBlockTNT) ||
|
(!faction.isWarZone() || !Conf.warZoneBlockTNT) &&
|
||||||
(faction.isSafeZone() && Conf.safeZoneBlockTNT));
|
(!faction.isSafeZone() || !Conf.safeZoneBlockTNT));
|
||||||
|
|
||||||
// No condition retained, destroy the block!
|
// No condition retained, destroy the block!
|
||||||
}
|
}
|
||||||
@ -311,7 +311,7 @@ public class FactionsEntityListener implements Listener {
|
|||||||
if (thrower instanceof Player) {
|
if (thrower instanceof Player) {
|
||||||
Player player = (Player) thrower;
|
Player player = (Player) thrower;
|
||||||
FPlayer fPlayer = FPlayers.getInstance().getByPlayer(player);
|
FPlayer fPlayer = FPlayers.getInstance().getByPlayer(player);
|
||||||
if (fPlayer.getFaction().isPeaceful()) {
|
if (badjuju && fPlayer.getFaction().isPeaceful()) {
|
||||||
event.setCancelled(true);
|
event.setCancelled(true);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
@ -506,8 +506,10 @@ public class FactionsEntityListener implements Listener {
|
|||||||
if (!(e.getRemover() instanceof Player)) return;
|
if (!(e.getRemover() instanceof Player)) return;
|
||||||
Player p = (Player) e.getRemover();
|
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)) {
|
if (e.getEntity().getType() == EntityType.PAINTING || e.getEntity().getType() == EntityType.ITEM_FRAME) {
|
||||||
e.setCancelled(true);
|
if (!FactionsBlockListener.playerCanBuildDestroyBlock(p, e.getEntity().getLocation(), "destroy", false)) {
|
||||||
|
e.setCancelled(true);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -515,9 +517,11 @@ public class FactionsEntityListener implements Listener {
|
|||||||
public void onPaintingPlace(HangingPlaceEvent e) {
|
public void onPaintingPlace(HangingPlaceEvent e) {
|
||||||
if (e.getPlayer() == null) return;
|
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)) {
|
if (e.getEntity().getType() == EntityType.PAINTING || e.getEntity().getType() == EntityType.ITEM_FRAME) {
|
||||||
e.setCancelled(true);
|
if (!FactionsBlockListener.playerCanBuildDestroyBlock(e.getPlayer(), e.getBlock().getLocation(), "build", false)) {
|
||||||
e.getPlayer().updateInventory();
|
e.setCancelled(true);
|
||||||
|
e.getPlayer().updateInventory();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -542,37 +546,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
|
@EventHandler
|
||||||
public void onHit(EntityDamageByEntityEvent e) {
|
public void onHit(EntityDamageByEntityEvent e) {
|
||||||
if (e.getDamager() instanceof Player && e.getEntity() instanceof Player) {
|
if (e.getDamager() instanceof Player) {
|
||||||
Player victim = (Player) e.getEntity();
|
if (e.getEntity() instanceof Player) {
|
||||||
Player attacker = (Player) e.getDamager();
|
Player victim = (Player) e.getEntity();
|
||||||
FPlayer fvictim = FPlayers.getInstance().getByPlayer(victim);
|
Player attacker = (Player) e.getDamager();
|
||||||
FPlayer fattacker = FPlayers.getInstance().getByPlayer(attacker);
|
FPlayer fvictim = FPlayers.getInstance().getByPlayer(victim);
|
||||||
if (fattacker.getRelationTo(fvictim) == Relation.TRUCE) {
|
FPlayer fattacker = FPlayers.getInstance().getByPlayer(attacker);
|
||||||
fattacker.msg(TL.PLAYER_PVP_CANTHURT, fvictim.describeTo(fattacker));
|
if (fattacker.getRelationTo(fvictim) == Relation.TRUCE) {
|
||||||
e.setCancelled(true);
|
fattacker.msg(TL.PLAYER_PVP_CANTHURT, fvictim.describeTo(fattacker));
|
||||||
|
e.setCancelled(true);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@EventHandler
|
@EventHandler
|
||||||
public void onBowHit(EntityDamageByEntityEvent e) {
|
public void onBowHit(EntityDamageByEntityEvent e) {
|
||||||
if (e.getDamager() instanceof Projectile && e.getEntity() instanceof Player) {
|
if (e.getDamager() instanceof Projectile) {
|
||||||
Projectile arrow = ((Projectile) e.getDamager());
|
if (e.getEntity() instanceof Player) {
|
||||||
if (arrow.getShooter() instanceof Player) {
|
Projectile arrow = ((Projectile) e.getDamager());
|
||||||
Player damager = (Player) ((Projectile) e.getDamager()).getShooter();
|
if (arrow.getShooter() instanceof Player) {
|
||||||
Player victim = (Player) e.getEntity();
|
Player damager = (Player) ((Projectile) e.getDamager()).getShooter();
|
||||||
FPlayer fdamager = FPlayers.getInstance().getByPlayer(damager);
|
Player victim = (Player) e.getEntity();
|
||||||
FPlayer fvictim = FPlayers.getInstance().getByPlayer(victim);
|
FPlayer fdamager = FPlayers.getInstance().getByPlayer(damager);
|
||||||
if (damager == victim) return;
|
FPlayer fvictim = FPlayers.getInstance().getByPlayer(victim);
|
||||||
if (fdamager == fvictim) return;
|
if (damager == victim) return;
|
||||||
if (fvictim.getRelationTo(fdamager) == Relation.TRUCE) {
|
if (fdamager == fvictim) return;
|
||||||
fdamager.msg(TL.PLAYER_PVP_CANTHURT, fvictim.describeTo(fdamager));
|
if (fvictim.getRelationTo(fdamager) == Relation.TRUCE) {
|
||||||
e.setCancelled(true);
|
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 (fvictim.getRelationTo(fdamager) == Relation.ENEMY) {
|
||||||
|
if (fvictim.isFlying()) {
|
||||||
|
fvictim.setFFlying(false, true);
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -54,7 +54,9 @@ import java.util.logging.Level;
|
|||||||
|
|
||||||
public class FactionsPlayerListener implements Listener {
|
public class FactionsPlayerListener implements Listener {
|
||||||
|
|
||||||
|
public final static Map<UUID, Location> lastLocations = new HashMap<>();
|
||||||
public static Set<FLocation> corners;
|
public static Set<FLocation> corners;
|
||||||
|
public static BukkitTask positionTask = null;
|
||||||
/**
|
/**
|
||||||
* @author FactionsUUID Team
|
* @author FactionsUUID Team
|
||||||
*/
|
*/
|
||||||
@ -188,6 +190,7 @@ public class FactionsPlayerListener implements Listener {
|
|||||||
FLocation loc = new FLocation(block);
|
FLocation loc = new FLocation(block);
|
||||||
Faction otherFaction = Board.getInstance().getFactionAt(loc);
|
Faction otherFaction = Board.getInstance().getFactionAt(loc);
|
||||||
Faction myFaction = me.getFaction();
|
Faction myFaction = me.getFaction();
|
||||||
|
Relation rel = myFaction.getRelationTo(otherFaction);
|
||||||
|
|
||||||
// no door/chest/whatever protection in wilderness, war zones, or safe zones
|
// no door/chest/whatever protection in wilderness, war zones, or safe zones
|
||||||
if (otherFaction.isSystemFaction()) return true;
|
if (otherFaction.isSystemFaction()) return true;
|
||||||
@ -486,7 +489,7 @@ public class FactionsPlayerListener implements Listener {
|
|||||||
|
|
||||||
if (FactionsPlugin.instance.getConfig().getBoolean("scoreboard.default-enabled", false)) {
|
if (FactionsPlugin.instance.getConfig().getBoolean("scoreboard.default-enabled", false)) {
|
||||||
FScoreboard.init(me);
|
FScoreboard.init(me);
|
||||||
FScoreboard.get(me).setDefaultSidebar(new FDefaultSidebar(), FactionsPlugin.instance.getConfig().getInt("scoreboard.default-update-interval", 20));
|
FScoreboard.get(me).setDefaultSidebar(new FDefaultSidebar());
|
||||||
FScoreboard.get(me).setSidebarVisibility(me.showScoreboard());
|
FScoreboard.get(me).setSidebarVisibility(me.showScoreboard());
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -518,11 +521,13 @@ public class FactionsPlayerListener implements Listener {
|
|||||||
|
|
||||||
@EventHandler
|
@EventHandler
|
||||||
public void onPlayerFall(EntityDamageEvent e) {
|
public void onPlayerFall(EntityDamageEvent e) {
|
||||||
if (e.getEntity() instanceof Player && e.getCause() == EntityDamageEvent.DamageCause.FALL) {
|
if (e.getEntity() instanceof Player) {
|
||||||
Player player = (Player) e.getEntity();
|
if (e.getCause() == EntityDamageEvent.DamageCause.FALL) {
|
||||||
if (fallMap.containsKey(player)) {
|
Player player = (Player) e.getEntity();
|
||||||
e.setCancelled(true);
|
if (fallMap.containsKey(player)) {
|
||||||
fallMap.remove(player);
|
e.setCancelled(true);
|
||||||
|
fallMap.remove(player);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -559,7 +564,7 @@ public class FactionsPlayerListener implements Listener {
|
|||||||
|
|
||||||
CmdSeeChunk.seeChunkMap.remove(event.getPlayer().getName());
|
CmdSeeChunk.seeChunkMap.remove(event.getPlayer().getName());
|
||||||
|
|
||||||
FScoreboard.remove(me);
|
FScoreboard.remove(me, event.getPlayer());
|
||||||
}
|
}
|
||||||
|
|
||||||
public String parseAllPlaceholders(String string, Faction faction, Player player) {
|
public String parseAllPlaceholders(String string, Faction faction, Player player) {
|
||||||
@ -610,7 +615,7 @@ public class FactionsPlayerListener implements Listener {
|
|||||||
fplayer.msg(TL.COMMAND_INSPECT_BYPASS);
|
fplayer.msg(TL.COMMAND_INSPECT_BYPASS);
|
||||||
}
|
}
|
||||||
List<String[]> info = CoreProtect.getInstance().getAPI().blockLookup(e.getClickedBlock(), 0);
|
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());
|
e.getPlayer().sendMessage(TL.COMMAND_INSPECT_NODATA.toString());
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
@ -649,9 +654,6 @@ public class FactionsPlayerListener implements Listener {
|
|||||||
return (result.length() == 3 ? result + "0" : result) + "/hrs ago";
|
return (result.length() == 3 ? result + "0" : result) + "/hrs ago";
|
||||||
}
|
}
|
||||||
|
|
||||||
public static BukkitTask positionTask = null;
|
|
||||||
public final Map<UUID, Location> lastLocations = new HashMap<>();
|
|
||||||
|
|
||||||
public void startPositionCheck() {
|
public void startPositionCheck() {
|
||||||
positionTask = Bukkit.getScheduler().runTaskTimer(FactionsPlugin.getInstance(), () -> {
|
positionTask = Bukkit.getScheduler().runTaskTimer(FactionsPlugin.getInstance(), () -> {
|
||||||
if (lastLocations.isEmpty()) return;
|
if (lastLocations.isEmpty()) return;
|
||||||
@ -735,7 +737,9 @@ public class FactionsPlayerListener implements Listener {
|
|||||||
me.attemptClaim(me.getAutoClaimFor(), newLocation, true);
|
me.attemptClaim(me.getAutoClaimFor(), newLocation, true);
|
||||||
}
|
}
|
||||||
FactionsPlugin.instance.logFactionEvent(me.getAutoClaimFor(), FLogType.CHUNK_CLAIMS, me.getName(), CC.GreenB + "CLAIMED", String.valueOf(1), (new FLocation(player.getLocation())).formatXAndZ(","));
|
FactionsPlugin.instance.logFactionEvent(me.getAutoClaimFor(), FLogType.CHUNK_CLAIMS, me.getName(), CC.GreenB + "CLAIMED", String.valueOf(1), (new FLocation(player.getLocation())).formatXAndZ(","));
|
||||||
if (Conf.disableFlightOnFactionClaimChange) CmdFly.disableFlight(me);
|
if (Conf.disableFlightOnFactionClaimChange && FactionsPlugin.getInstance().getConfig().getBoolean("enable-faction-flight"))
|
||||||
|
CmdFly.disableFlight(me);
|
||||||
|
|
||||||
} else if (me.isAutoSafeClaimEnabled()) {
|
} else if (me.isAutoSafeClaimEnabled()) {
|
||||||
if (!Permission.MANAGE_SAFE_ZONE.has(player)) {
|
if (!Permission.MANAGE_SAFE_ZONE.has(player)) {
|
||||||
me.setIsAutoSafeClaimEnabled(false);
|
me.setIsAutoSafeClaimEnabled(false);
|
||||||
@ -824,14 +828,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.
|
// 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
|
// 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 they're clicking on territoryDenySwitchMaterials, let the protection system handle the permissions
|
||||||
if (type != null && !Conf.territoryDenySwitchMaterials.contains(block.getType()) && Conf.territoryCancelAndAllowItemUseMaterial.contains(type)) {
|
if (type != null && !Conf.territoryDenySwitchMaterials.contains(block.getType())) {
|
||||||
return;
|
if (Conf.territoryCancelAndAllowItemUseMaterial.contains(type)) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (GetPermissionFromUsableBlock(block.getType()) != null && !canPlayerUseBlock(player, block, false)) {
|
if (GetPermissionFromUsableBlock(block.getType()) != null) {
|
||||||
event.setCancelled(true);
|
if (!canPlayerUseBlock(player, block, false)) {
|
||||||
event.setUseInteractedBlock(Event.Result.DENY);
|
event.setCancelled(true);
|
||||||
return;
|
event.setUseInteractedBlock(Event.Result.DENY);
|
||||||
|
return;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (type != null && !playerCanUseItemHere(player, block.getLocation(), event.getItem().getType(), false, PermissableAction.ITEM)) {
|
if (type != null && !playerCanUseItemHere(player, block.getLocation(), event.getItem().getType(), false, PermissableAction.ITEM)) {
|
||||||
@ -852,13 +860,14 @@ public class FactionsPlayerListener implements Listener {
|
|||||||
public void onPlayerBoneMeal(PlayerInteractEvent event) {
|
public void onPlayerBoneMeal(PlayerInteractEvent event) {
|
||||||
Block block = event.getClickedBlock();
|
Block block = event.getClickedBlock();
|
||||||
if (event.getAction() == Action.RIGHT_CLICK_BLOCK && block.getType() == XMaterial.GRASS_BLOCK.parseMaterial()
|
if (event.getAction() == Action.RIGHT_CLICK_BLOCK && block.getType() == XMaterial.GRASS_BLOCK.parseMaterial()
|
||||||
&& event.hasItem() && event.getItem().getType() == XMaterial.BONE_MEAL.parseMaterial()
|
&& event.hasItem() && event.getItem().getType() == XMaterial.BONE_MEAL.parseMaterial()) {
|
||||||
&& !FactionsBlockListener.playerCanBuildDestroyBlock(event.getPlayer(), block.getLocation(), PermissableAction.BUILD.name(), true)) {
|
if (!FactionsBlockListener.playerCanBuildDestroyBlock(event.getPlayer(), block.getLocation(), "build", true)) {
|
||||||
FPlayer me = FPlayers.getInstance().getById(event.getPlayer().getUniqueId().toString());
|
FPlayer me = FPlayers.getInstance().getById(event.getPlayer().getUniqueId().toString());
|
||||||
Faction myFaction = me.getFaction();
|
Faction myFaction = me.getFaction();
|
||||||
|
|
||||||
me.msg(TL.ACTIONS_NOPERMISSION.toString().replace("{faction}", myFaction.getTag(me.getFaction())).replace("{action}", "use bone meal"));
|
me.msg(TL.ACTIONS_NOPERMISSION.toString().replace("{faction}", myFaction.getTag(me.getFaction())).replace("{action}", "use bone meal"));
|
||||||
event.setCancelled(true);
|
event.setCancelled(true);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -926,8 +935,10 @@ public class FactionsPlayerListener implements Listener {
|
|||||||
player.sendMessage(String.valueOf(TL.COMMAND_LOGOUT_DAMAGE_TAKEN));
|
player.sendMessage(String.valueOf(TL.COMMAND_LOGOUT_DAMAGE_TAKEN));
|
||||||
}
|
}
|
||||||
WaitExecutor.handleAction(player);
|
WaitExecutor.handleAction(player);
|
||||||
if (CmdWild.teleporting.contains(player) && !FactionsPlugin.getInstance().getConfig().getBoolean("Wild.FallDamage") && e.getCause() == EntityDamageEvent.DamageCause.FALL) {
|
if (CmdWild.teleporting.contains(player)) {
|
||||||
e.setCancelled(true);
|
if (!FactionsPlugin.getInstance().getConfig().getBoolean("Wild.FallDamage") && e.getCause() == EntityDamageEvent.DamageCause.FALL) {
|
||||||
|
e.setCancelled(true);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -936,6 +947,7 @@ public class FactionsPlayerListener implements Listener {
|
|||||||
public void onTeleport(PlayerTeleportEvent e) {
|
public void onTeleport(PlayerTeleportEvent e) {
|
||||||
Player player = e.getPlayer();
|
Player player = e.getPlayer();
|
||||||
|
|
||||||
|
if (player == null) return;
|
||||||
LogoutHandler handler = LogoutHandler.getByName(player.getName());
|
LogoutHandler handler = LogoutHandler.getByName(player.getName());
|
||||||
if (handler.isLogoutActive(player)) {
|
if (handler.isLogoutActive(player)) {
|
||||||
handler.cancelLogout(player);
|
handler.cancelLogout(player);
|
||||||
@ -973,7 +985,7 @@ public class FactionsPlayerListener implements Listener {
|
|||||||
}
|
}
|
||||||
|
|
||||||
@EventHandler(priority = EventPriority.MONITOR, ignoreCancelled = true)
|
@EventHandler(priority = EventPriority.MONITOR, ignoreCancelled = true)
|
||||||
final void onFactionJoin(FPlayerJoinEvent event) {
|
final public void onFactionJoin(FPlayerJoinEvent event) {
|
||||||
FTeamWrapper.applyUpdatesLater(event.getFaction());
|
FTeamWrapper.applyUpdatesLater(event.getFaction());
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -987,7 +999,7 @@ public class FactionsPlayerListener implements Listener {
|
|||||||
}
|
}
|
||||||
|
|
||||||
@EventHandler
|
@EventHandler
|
||||||
public void asyncPlayerChatEvent(AsyncPlayerChatEvent e) {
|
public void AsyncPlayerChatEvent(AsyncPlayerChatEvent e) {
|
||||||
Player p = e.getPlayer();
|
Player p = e.getPlayer();
|
||||||
|
|
||||||
if (CmdFGlobal.toggled.contains(p.getUniqueId())) {
|
if (CmdFGlobal.toggled.contains(p.getUniqueId())) {
|
||||||
@ -1013,8 +1025,10 @@ public class FactionsPlayerListener implements Listener {
|
|||||||
|
|
||||||
for (int i = l.size() - 1; i >= 0; i--) { // going backwards in the list to prevent a ConcurrentModificationException
|
for (int i = l.size() - 1; i >= 0; i--) { // going backwards in the list to prevent a ConcurrentModificationException
|
||||||
Player recipient = l.get(i);
|
Player recipient = l.get(i);
|
||||||
if (recipient != null && CmdFGlobal.toggled.contains(recipient.getUniqueId())) {
|
if (recipient != null) {
|
||||||
e.getRecipients().remove(recipient);
|
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 class MenuListener implements Listener {
|
||||||
|
|
||||||
|
public MenuListener() {
|
||||||
|
}
|
||||||
|
|
||||||
@EventHandler
|
@EventHandler
|
||||||
public void onInventoryClick(InventoryClickEvent event) {
|
public void onInventoryClick(InventoryClickEvent event) {
|
||||||
if (event.getView().getTitle().equals("Faction Logs")) {
|
if (event.getView().getTitle().equals("Faction Logs")) {
|
||||||
|
@ -9,15 +9,27 @@ import org.bukkit.scoreboard.Team;
|
|||||||
|
|
||||||
import java.lang.reflect.Method;
|
import java.lang.reflect.Method;
|
||||||
import java.util.*;
|
import java.util.*;
|
||||||
|
import java.util.regex.Matcher;
|
||||||
|
import java.util.regex.Pattern;
|
||||||
|
|
||||||
public class BufferedObjective {
|
public class BufferedObjective {
|
||||||
|
|
||||||
/**
|
|
||||||
* @author FactionsUUID Team
|
|
||||||
*/
|
|
||||||
|
|
||||||
private static final Method addEntryMethod;
|
private static final Method addEntryMethod;
|
||||||
private static final int MAX_LINE_LENGTH;
|
private static final int MAX_LINE_LENGTH;
|
||||||
|
private static final Pattern PATTERN = Pattern.compile("(\u00A7[0-9a-fk-r])|(.)");
|
||||||
|
|
||||||
|
private final Scoreboard scoreboard;
|
||||||
|
private final String baseName;
|
||||||
|
|
||||||
|
private Objective current;
|
||||||
|
private List<Team> currentTeams = new ArrayList<>();
|
||||||
|
private String title;
|
||||||
|
private DisplaySlot displaySlot;
|
||||||
|
|
||||||
|
private int objPtr;
|
||||||
|
private int teamPtr;
|
||||||
|
private boolean requiresUpdate = false;
|
||||||
|
|
||||||
|
private final Map<Integer, String> contents = new HashMap<>();
|
||||||
|
|
||||||
static {
|
static {
|
||||||
// Check for long line support.
|
// Check for long line support.
|
||||||
@ -39,17 +51,6 @@ public class BufferedObjective {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private final Scoreboard scoreboard;
|
|
||||||
private final String baseName;
|
|
||||||
private final Map<Integer, String> contents = new HashMap<>();
|
|
||||||
private Objective current;
|
|
||||||
private List<Team> currentTeams = new ArrayList<>();
|
|
||||||
private String title;
|
|
||||||
private DisplaySlot displaySlot;
|
|
||||||
private int objPtr;
|
|
||||||
private int teamPtr;
|
|
||||||
private boolean requiresUpdate = false;
|
|
||||||
|
|
||||||
public BufferedObjective(Scoreboard scoreboard) {
|
public BufferedObjective(Scoreboard scoreboard) {
|
||||||
this.scoreboard = scoreboard;
|
this.scoreboard = scoreboard;
|
||||||
this.baseName = createBaseName();
|
this.baseName = createBaseName();
|
||||||
@ -122,14 +123,75 @@ public class BufferedObjective {
|
|||||||
Team team = scoreboard.registerNewTeam(getNextTeamName());
|
Team team = scoreboard.registerNewTeam(getNextTeamName());
|
||||||
bufferTeams.add(team);
|
bufferTeams.add(team);
|
||||||
|
|
||||||
Iterator<String> split = Splitter.fixedLength(16).split(entry.getValue()).iterator();
|
String name, prefix = null, suffix = null;
|
||||||
|
|
||||||
team.setPrefix(split.next());
|
String value = entry.getValue();
|
||||||
String name = split.next();
|
if (value.length() > 16) {
|
||||||
if (split.hasNext()) { // We only guarantee two splits
|
String[] arrImAPirate = new String[3];
|
||||||
team.setSuffix(split.next());
|
Matcher matcherrr = PATTERN.matcher(value);
|
||||||
|
StringBuilder builderrr = new StringBuilder();
|
||||||
|
int sCURvy = 0;
|
||||||
|
char currrentColorrr = 'r';
|
||||||
|
char currrentFormat = 'r';
|
||||||
|
while (sCURvy < 3 && matcherrr.find()) {
|
||||||
|
String tharSheBlows = matcherrr.group();
|
||||||
|
boolean hoist = false;
|
||||||
|
if (tharSheBlows.length() == 1) {
|
||||||
|
builderrr.append(tharSheBlows);
|
||||||
|
if (builderrr.length() == 16) {
|
||||||
|
hoist = true;
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
char c = tharSheBlows.charAt(1);
|
||||||
|
if (c >= 'k' && c <= 'r') { // format!
|
||||||
|
currrentFormat = c;
|
||||||
|
if (c == 'r') {
|
||||||
|
currrentColorrr = 'r';
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
currrentColorrr = c;
|
||||||
|
currrentFormat = 'r';
|
||||||
|
}
|
||||||
|
if (builderrr.length() < 14) {
|
||||||
|
builderrr.append(tharSheBlows);
|
||||||
|
} else {
|
||||||
|
hoist = true;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if (hoist) {
|
||||||
|
arrImAPirate[sCURvy++] = builderrr.toString();
|
||||||
|
builderrr = new StringBuilder();
|
||||||
|
if (currrentColorrr != 'r') {
|
||||||
|
builderrr.append('\u00A7').append(currrentColorrr);
|
||||||
|
}
|
||||||
|
if (currrentFormat != 'r') {
|
||||||
|
builderrr.append('\u00A7').append(currrentFormat);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if (sCURvy < 3 && builderrr.length() > 0) {
|
||||||
|
arrImAPirate[sCURvy] = builderrr.toString();
|
||||||
|
}
|
||||||
|
if (arrImAPirate[2] == null) {
|
||||||
|
name = arrImAPirate[0];
|
||||||
|
suffix = arrImAPirate[1];
|
||||||
|
} else {
|
||||||
|
prefix = arrImAPirate[0];
|
||||||
|
name = arrImAPirate[1];
|
||||||
|
suffix = arrImAPirate[2];
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
name = value;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (prefix != null) {
|
||||||
|
team.setPrefix(prefix);
|
||||||
|
}
|
||||||
|
if (suffix != null) {
|
||||||
|
team.setSuffix(suffix);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
try {
|
try {
|
||||||
addEntryMethod.invoke(team, name);
|
addEntryMethod.invoke(team, name);
|
||||||
} catch (ReflectiveOperationException ignored) {
|
} catch (ReflectiveOperationException ignored) {
|
||||||
|
@ -58,10 +58,13 @@ public class FScoreboard {
|
|||||||
FTeamWrapper.track(fboard);
|
FTeamWrapper.track(fboard);
|
||||||
}
|
}
|
||||||
|
|
||||||
public static void remove(FPlayer fplayer) {
|
public static void remove(FPlayer fplayer, Player player) {
|
||||||
FScoreboard fboard = fscoreboards.remove(fplayer);
|
FScoreboard fboard = fscoreboards.remove(fplayer);
|
||||||
|
|
||||||
if (fboard != null) {
|
if (fboard != null) {
|
||||||
|
if (fboard.scoreboard == player.getScoreboard()) { // No equals method implemented, so may as well skip a nullcheck
|
||||||
|
player.setScoreboard(Bukkit.getScoreboardManager().getMainScoreboard());
|
||||||
|
}
|
||||||
fboard.removed = true;
|
fboard.removed = true;
|
||||||
FTeamWrapper.untrack(fboard);
|
FTeamWrapper.untrack(fboard);
|
||||||
}
|
}
|
||||||
@ -91,7 +94,7 @@ public class FScoreboard {
|
|||||||
bufferedObjective.setDisplaySlot(visible ? DisplaySlot.SIDEBAR : null);
|
bufferedObjective.setDisplaySlot(visible ? DisplaySlot.SIDEBAR : null);
|
||||||
}
|
}
|
||||||
|
|
||||||
public void setDefaultSidebar(final FSidebarProvider provider, int updateInterval) {
|
public void setDefaultSidebar(final FSidebarProvider provider) {
|
||||||
if (!isSupportedByServer()) {
|
if (!isSupportedByServer()) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
@ -114,7 +117,7 @@ public class FScoreboard {
|
|||||||
updateObjective();
|
updateObjective();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}.runTaskTimer(FactionsPlugin.getInstance(), updateInterval, updateInterval);
|
}.runTaskTimer(FactionsPlugin.getInstance(), 20, 20);
|
||||||
}
|
}
|
||||||
|
|
||||||
public void setTemporarySidebar(final FSidebarProvider provider) {
|
public void setTemporarySidebar(final FSidebarProvider provider) {
|
||||||
@ -137,7 +140,7 @@ public class FScoreboard {
|
|||||||
updateObjective();
|
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() {
|
private void updateObjective() {
|
||||||
|
@ -3,6 +3,7 @@ package com.massivecraft.factions.scoreboards;
|
|||||||
import com.massivecraft.factions.FPlayer;
|
import com.massivecraft.factions.FPlayer;
|
||||||
import com.massivecraft.factions.Faction;
|
import com.massivecraft.factions.Faction;
|
||||||
import com.massivecraft.factions.FactionsPlugin;
|
import com.massivecraft.factions.FactionsPlugin;
|
||||||
|
import com.massivecraft.factions.tag.Tag;
|
||||||
import com.massivecraft.factions.zcore.util.TL;
|
import com.massivecraft.factions.zcore.util.TL;
|
||||||
import com.massivecraft.factions.zcore.util.TagUtil;
|
import com.massivecraft.factions.zcore.util.TagUtil;
|
||||||
|
|
||||||
@ -20,16 +21,16 @@ public abstract class FSidebarProvider {
|
|||||||
public abstract List<String> getLines(FPlayer fplayer);
|
public abstract List<String> getLines(FPlayer fplayer);
|
||||||
|
|
||||||
public String replaceTags(FPlayer fPlayer, String s) {
|
public String replaceTags(FPlayer fPlayer, String s) {
|
||||||
s = TagUtil.parsePlaceholders(fPlayer.getPlayer(), s);
|
s = Tag.parsePlaceholders(fPlayer.getPlayer(), s);
|
||||||
|
|
||||||
return qualityAssure(TagUtil.parsePlain(fPlayer, s));
|
return qualityAssure(Tag.parsePlain(fPlayer, s));
|
||||||
}
|
}
|
||||||
|
|
||||||
public String replaceTags(Faction faction, FPlayer fPlayer, String s) {
|
public String replaceTags(Faction faction, FPlayer fPlayer, String s) {
|
||||||
// Run through Placeholder API first
|
// Run through Placeholder API first
|
||||||
s = TagUtil.parsePlaceholders(fPlayer.getPlayer(), s);
|
s = Tag.parsePlaceholders(fPlayer.getPlayer(), s);
|
||||||
|
|
||||||
return qualityAssure(Objects.requireNonNull(TagUtil.parsePlain(faction, fPlayer, s)));
|
return qualityAssure(Tag.parsePlain(faction, fPlayer, s));
|
||||||
}
|
}
|
||||||
|
|
||||||
private String qualityAssure(String line) {
|
private String qualityAssure(String line) {
|
||||||
|
@ -19,14 +19,13 @@ public class FTeamWrapper {
|
|||||||
|
|
||||||
private static final Map<Faction, FTeamWrapper> wrappers = new HashMap<>();
|
private static final Map<Faction, FTeamWrapper> wrappers = new HashMap<>();
|
||||||
private static final List<FScoreboard> tracking = new ArrayList<>();
|
private static final List<FScoreboard> tracking = new ArrayList<>();
|
||||||
private static final Set<Faction> updating = new HashSet<>();
|
|
||||||
private static int factionTeamPtr;
|
private static int factionTeamPtr;
|
||||||
|
private static final Set<Faction> updating = new HashSet<>();
|
||||||
|
|
||||||
private final Map<FScoreboard, Team> teams = new HashMap<>();
|
private final Map<FScoreboard, Team> teams = new HashMap<>();
|
||||||
private final String teamName;
|
private final String teamName;
|
||||||
private final Faction faction;
|
private final Faction faction;
|
||||||
private final Set<OfflinePlayer> members = new HashSet<>();
|
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) {
|
private FTeamWrapper(Faction faction) {
|
||||||
this.teamName = "faction_" + (factionTeamPtr++);
|
this.teamName = "faction_" + (factionTeamPtr++);
|
||||||
@ -38,18 +37,11 @@ public class FTeamWrapper {
|
|||||||
}
|
}
|
||||||
|
|
||||||
public static void applyUpdatesLater(final Faction faction) {
|
public static void applyUpdatesLater(final Faction faction) {
|
||||||
if (!FScoreboard.isSupportedByServer()) {
|
if (!FScoreboard.isSupportedByServer()) return;
|
||||||
|
if (faction.isWilderness()) return;
|
||||||
|
if (!FactionsPlugin.getInstance().getConfig().getBoolean("scoreboard.default-prefixes", false)
|
||||||
|
|| FactionsPlugin.getInstance().getConfig().getBoolean("See-Invisible-Faction-Members"))
|
||||||
return;
|
return;
|
||||||
}
|
|
||||||
|
|
||||||
if (faction.isWilderness()) {
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (!FactionsPlugin.getInstance().getConfig().getBoolean(defaultPrefixes, false) || FactionsPlugin.getInstance().getConfig().getBoolean(invisFactionMembers)) {
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
if (updating.add(faction)) {
|
if (updating.add(faction)) {
|
||||||
Bukkit.getScheduler().runTask(FactionsPlugin.getInstance(), () -> {
|
Bukkit.getScheduler().runTask(FactionsPlugin.getInstance(), () -> {
|
||||||
@ -60,22 +52,17 @@ public class FTeamWrapper {
|
|||||||
}
|
}
|
||||||
|
|
||||||
public static void applyUpdates(Faction faction) {
|
public static void applyUpdates(Faction faction) {
|
||||||
if (!FScoreboard.isSupportedByServer()) {
|
if (!FScoreboard.isSupportedByServer()) return;
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (faction.isWilderness()) {
|
if (faction.isWilderness()) return;
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (!FactionsPlugin.getInstance().getConfig().getBoolean(defaultPrefixes, false) || FactionsPlugin.getInstance().getConfig().getBoolean(invisFactionMembers)) {
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (updating.contains(faction)) {
|
if (!FactionsPlugin.getInstance().getConfig().getBoolean("scoreboard.default-prefixes", false)
|
||||||
// Faction will be updated soon.
|
|| FactionsPlugin.getInstance().getConfig().getBoolean("See-Invisible-Faction-Members"))
|
||||||
return;
|
return;
|
||||||
}
|
|
||||||
|
|
||||||
|
if (updating.contains(faction)) return;
|
||||||
|
|
||||||
FTeamWrapper wrapper = wrappers.get(faction);
|
FTeamWrapper wrapper = wrappers.get(faction);
|
||||||
Set<FPlayer> factionMembers = faction.getFPlayers();
|
Set<FPlayer> factionMembers = faction.getFPlayers();
|
||||||
@ -100,21 +87,16 @@ public class FTeamWrapper {
|
|||||||
}
|
}
|
||||||
|
|
||||||
for (FPlayer fmember : factionMembers) {
|
for (FPlayer fmember : factionMembers) {
|
||||||
if (!fmember.isOnline()) {
|
if (!fmember.isOnline()) continue;
|
||||||
continue;
|
|
||||||
}
|
|
||||||
|
|
||||||
// Scoreboard might not have player; add him/her
|
// Scoreboard might not have player; add him/her
|
||||||
wrapper.addPlayer(fmember.getPlayer());
|
wrapper.addPlayer(fmember.getPlayer());
|
||||||
}
|
}
|
||||||
|
|
||||||
wrapper.updatePrefixes();
|
wrapper.updatePrefixes();
|
||||||
}
|
}
|
||||||
|
|
||||||
public static void updatePrefixes(Faction faction) {
|
public static void updatePrefixes(Faction faction) {
|
||||||
if (!FScoreboard.isSupportedByServer()) {
|
if (!FScoreboard.isSupportedByServer()) return;
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (!wrappers.containsKey(faction)) {
|
if (!wrappers.containsKey(faction)) {
|
||||||
applyUpdates(faction);
|
applyUpdates(faction);
|
||||||
@ -124,34 +106,22 @@ public class FTeamWrapper {
|
|||||||
}
|
}
|
||||||
|
|
||||||
protected static void track(FScoreboard fboard) {
|
protected static void track(FScoreboard fboard) {
|
||||||
if (!FScoreboard.isSupportedByServer()) {
|
if (!FScoreboard.isSupportedByServer()) return;
|
||||||
return;
|
|
||||||
}
|
|
||||||
tracking.add(fboard);
|
tracking.add(fboard);
|
||||||
for (FTeamWrapper wrapper : wrappers.values()) {
|
for (FTeamWrapper wrapper : wrappers.values()) wrapper.add(fboard);
|
||||||
wrapper.add(fboard);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
protected static void untrack(FScoreboard fboard) {
|
protected static void untrack(FScoreboard fboard) {
|
||||||
if (!FScoreboard.isSupportedByServer()) {
|
if (!FScoreboard.isSupportedByServer()) return;
|
||||||
return;
|
|
||||||
}
|
|
||||||
tracking.remove(fboard);
|
tracking.remove(fboard);
|
||||||
for (FTeamWrapper wrapper : wrappers.values()) {
|
for (FTeamWrapper wrapper : wrappers.values()) wrapper.remove(fboard);
|
||||||
wrapper.remove(fboard);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
private void add(FScoreboard fboard) {
|
private void add(FScoreboard fboard) {
|
||||||
Scoreboard board = fboard.getScoreboard();
|
Scoreboard board = fboard.getScoreboard();
|
||||||
Team team = board.registerNewTeam(teamName);
|
Team team = board.registerNewTeam(teamName);
|
||||||
teams.put(fboard, team);
|
teams.put(fboard, team);
|
||||||
|
for (OfflinePlayer player : getPlayers()) team.addPlayer(player);
|
||||||
for (OfflinePlayer player : getPlayers()) {
|
|
||||||
team.addPlayer(player);
|
|
||||||
}
|
|
||||||
|
|
||||||
updatePrefix(fboard);
|
updatePrefix(fboard);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -160,27 +130,25 @@ public class FTeamWrapper {
|
|||||||
}
|
}
|
||||||
|
|
||||||
private void updatePrefixes() {
|
private void updatePrefixes() {
|
||||||
if (FactionsPlugin.getInstance().getConfig().getBoolean(defaultPrefixes, false)) {
|
if (FactionsPlugin.getInstance().getConfig().getBoolean("scoreboard.default-prefixes", false)) {
|
||||||
for (FScoreboard fboard : teams.keySet()) {
|
for (FScoreboard fboard : teams.keySet()) updatePrefix(fboard);
|
||||||
updatePrefix(fboard);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private void updatePrefix(FScoreboard fboard) {
|
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();
|
FPlayer fplayer = fboard.getFPlayer();
|
||||||
Team team = teams.get(fboard);
|
Team team = teams.get(fboard);
|
||||||
boolean focused = false;
|
boolean focused = false;
|
||||||
|
|
||||||
if (FactionsPlugin.getInstance().getConfig().getBoolean(invisFactionMembers, false)) {
|
if (FactionsPlugin.getInstance().getConfig().getBoolean("See-Invisible-Faction-Members", false)) {
|
||||||
team.setCanSeeFriendlyInvisibles(true);
|
team.setCanSeeFriendlyInvisibles(true);
|
||||||
}
|
}
|
||||||
|
|
||||||
if ((FactionsPlugin.getInstance().getConfig().getBoolean("ffocus.Enabled")) && (fplayer.getFaction() != null) && (fplayer.getFaction().getFocused() != null)) {
|
if ((FactionsPlugin.getInstance().getConfig().getBoolean("ffocus.Enabled")) && (fplayer.getFaction() != null) && (fplayer.getFaction().getFocused() != null)) {
|
||||||
for (FPlayer fp : faction.getFPlayersWhereOnline(true)) {
|
for (FPlayer fp : faction.getFPlayersWhereOnline(true)) {
|
||||||
if (fplayer.getFaction().getFocused().equalsIgnoreCase(fp.getName())) {
|
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;
|
focused = true;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -193,8 +161,7 @@ public class FTeamWrapper {
|
|||||||
prefix = prefix.replace("{relationcolor}", faction.getRelationTo(fplayer).getColor().toString());
|
prefix = prefix.replace("{relationcolor}", faction.getRelationTo(fplayer).getColor().toString());
|
||||||
prefix = prefix.replace("{faction}",
|
prefix = prefix.replace("{faction}",
|
||||||
faction.getTag().substring(0, Math.min("{faction}".length() + 16 - prefix.length(), faction.getTag().length())));
|
faction.getTag().substring(0, Math.min("{faction}".length() + 16 - prefix.length(), faction.getTag().length())));
|
||||||
team.getPrefix();
|
if ((team.getPrefix() == null) || (!team.getPrefix().equals(prefix))) {
|
||||||
if (!team.getPrefix().equals(prefix)) {
|
|
||||||
team.setPrefix(prefix);
|
team.setPrefix(prefix);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -11,6 +11,7 @@ import com.massivecraft.factions.util.XMaterial;
|
|||||||
import com.massivecraft.factions.zcore.util.TL;
|
import com.massivecraft.factions.zcore.util.TL;
|
||||||
import org.bukkit.Bukkit;
|
import org.bukkit.Bukkit;
|
||||||
import org.bukkit.ChatColor;
|
import org.bukkit.ChatColor;
|
||||||
|
import org.bukkit.Material;
|
||||||
import org.bukkit.configuration.ConfigurationSection;
|
import org.bukkit.configuration.ConfigurationSection;
|
||||||
import org.bukkit.enchantments.Enchantment;
|
import org.bukkit.enchantments.Enchantment;
|
||||||
import org.bukkit.entity.Player;
|
import org.bukkit.entity.Player;
|
||||||
@ -20,6 +21,9 @@ import org.bukkit.inventory.meta.ItemMeta;
|
|||||||
|
|
||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
import java.util.Map;
|
||||||
|
import java.util.Set;
|
||||||
|
import java.util.logging.Level;
|
||||||
import java.util.stream.Collectors;
|
import java.util.stream.Collectors;
|
||||||
|
|
||||||
public class ShopGUIFrame {
|
public class ShopGUIFrame {
|
||||||
@ -31,28 +35,28 @@ public class ShopGUIFrame {
|
|||||||
private Gui gui;
|
private Gui gui;
|
||||||
|
|
||||||
public ShopGUIFrame(Faction f) {
|
public ShopGUIFrame(Faction f) {
|
||||||
gui = new Gui(FactionsPlugin.getInstance(),
|
gui = new Gui(FactionsPlugin.getInstance(), FactionsPlugin.getInstance().getConfig().getInt("F-Shop.GUI.Rows", 4), FactionsPlugin.getInstance().color(FactionsPlugin.getInstance().getConfig().getString("F-Shop.GUI.Name")));
|
||||||
FactionsPlugin.getInstance().getConfig().getInt("F-Shop.GUI.Rows", 4),
|
|
||||||
FactionsPlugin.getInstance().color(FactionsPlugin.getInstance().getConfig().getString("F-Shop.GUI.Name")));
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public void buildGUI(FPlayer fplayer) {
|
public void buildGUI(FPlayer fplayer) {
|
||||||
PaginatedPane pane = new PaginatedPane(0, 0, 9, gui.getRows());
|
PaginatedPane pane = new PaginatedPane(0, 0, 9, gui.getRows());
|
||||||
List<GuiItem> GUIItems = new ArrayList<>();
|
List<GuiItem> GUIItems = new ArrayList<>();
|
||||||
ItemStack dummy = buildDummyItem(fplayer.getFaction());
|
ItemStack dummy = buildDummyItem(fplayer.getFaction());
|
||||||
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();
|
Set<String> items = FactionsPlugin.getInstance().getFileManager().getShop().getConfig().getConfigurationSection("items").getKeys(false);
|
||||||
for (int a = 1; a <= items; a++) {
|
for (String s : items) {
|
||||||
String s = a + "";
|
if (!checkShopConfig(s)) {
|
||||||
String varItems = "items.";
|
continue;
|
||||||
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");
|
|
||||||
|
|
||||||
|
int slot = FactionsPlugin.getInstance().getFileManager().getShop().fetchInt("items." + s + ".slot");
|
||||||
|
ItemStack item = XMaterial.matchXMaterial(FactionsPlugin.getInstance().getFileManager().getShop().fetchString("items." + s + ".block")).get().parseItem();
|
||||||
|
int cost = FactionsPlugin.getInstance().getFileManager().getShop().fetchInt("items." + s + ".cost");
|
||||||
|
String name = FactionsPlugin.getInstance().getFileManager().getShop().fetchString("items." + s + ".name");
|
||||||
|
boolean glowing = FactionsPlugin.getInstance().getFileManager().getShop().fetchBoolean("items." + s + ".glowing");
|
||||||
|
List<String> lore = FactionsPlugin.getInstance().getFileManager().getShop().fetchStringList("items." + s + ".lore");
|
||||||
|
|
||||||
assert item != null;
|
assert item != null;
|
||||||
ItemMeta meta = item.getItemMeta();
|
ItemMeta meta = item.getItemMeta();
|
||||||
@ -62,23 +66,26 @@ public class ShopGUIFrame {
|
|||||||
meta.addItemFlags(ItemFlag.HIDE_ENCHANTS);
|
meta.addItemFlags(ItemFlag.HIDE_ENCHANTS);
|
||||||
meta.addEnchant(Enchantment.DURABILITY, 1, true);
|
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());
|
List<String> replacedLore = lore.stream().map(t -> t.replace("{cost}", cost + "")).collect(Collectors.toList());
|
||||||
meta.setLore(FactionsPlugin.instance.colorList(replacedLore));
|
meta.setLore(FactionsPlugin.instance.colorList(replacedLore));
|
||||||
item.setItemMeta(meta);
|
item.setItemMeta(meta);
|
||||||
GUIItems.set(slot, new GuiItem(item, e -> {
|
GUIItems.set(slot, new GuiItem(item, e ->
|
||||||
|
{
|
||||||
e.setCancelled(true);
|
e.setCancelled(true);
|
||||||
FPlayer fme = FPlayers.getInstance().getByPlayer((Player) e.getWhoClicked());
|
FPlayer fme = FPlayers.getInstance().getByPlayer((Player) e.getWhoClicked());
|
||||||
if (fplayer.getFaction().getPoints() >= cost) {
|
if (fplayer.getFaction().getPoints() >= cost) {
|
||||||
fplayer.getFaction().setPoints(fplayer.getFaction().getPoints() - cost);
|
if (runCommands(FactionsPlugin.getInstance().getFileManager().getShop().fetchStringList("items." + s + ".cmds"), fplayer.getPlayer())) {
|
||||||
runCommands(FactionsPlugin.getInstance().getFileManager().getShop().fetchStringList("items." + s + ".cmds"), fplayer.getPlayer());
|
fplayer.getFaction().setPoints(fplayer.getFaction().getPoints() - cost);
|
||||||
for (FPlayer fplayerBuy : fplayer.getFaction().getFPlayers()) {
|
for (FPlayer fplayerBuy : fplayer.getFaction().getFPlayers()) {
|
||||||
fplayerBuy.getPlayer().sendMessage(TL.SHOP_BOUGHT_BROADCAST_FACTION.toString()
|
fplayerBuy.getPlayer().sendMessage(TL.SHOP_BOUGHT_BROADCAST_FACTION.toString().replace("{player}", fplayer.getPlayer().getName()).replace("{item}", ChatColor.stripColor(FactionsPlugin.getInstance().color(name)))
|
||||||
.replace("{player}", fplayer.getPlayer().getName())
|
.replace("{cost}", cost + ""));
|
||||||
.replace("{item}", ChatColor.stripColor(FactionsPlugin.getInstance().color(name)))
|
}
|
||||||
.replace("{cost}", cost + ""));
|
buildGUI(fme);
|
||||||
|
} else {
|
||||||
|
fplayer.msg(TL.SHOP_ERROR_DURING_PURCHASE);
|
||||||
}
|
}
|
||||||
buildGUI(fme);
|
|
||||||
} else {
|
} else {
|
||||||
fplayer.msg(TL.SHOP_NOT_ENOUGH_POINTS);
|
fplayer.msg(TL.SHOP_NOT_ENOUGH_POINTS);
|
||||||
}
|
}
|
||||||
@ -90,7 +97,6 @@ public class ShopGUIFrame {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
private ItemStack buildDummyItem(Faction f) {
|
private ItemStack buildDummyItem(Faction f) {
|
||||||
ConfigurationSection config = FactionsPlugin.getInstance().getConfig().getConfigurationSection("F-Shop.GUI.dummy-item");
|
ConfigurationSection config = FactionsPlugin.getInstance().getConfig().getConfigurationSection("F-Shop.GUI.dummy-item");
|
||||||
ItemStack item = XMaterial.matchXMaterial(config.getString("Type")).get().parseItem();
|
ItemStack item = XMaterial.matchXMaterial(config.getString("Type")).get().parseItem();
|
||||||
@ -103,10 +109,83 @@ public class ShopGUIFrame {
|
|||||||
return item;
|
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) {
|
for (String cmd : list) {
|
||||||
cmd = cmd.replace("%player%", p.getName());
|
cmd = cmd.replace("%player%", p.getName());
|
||||||
Bukkit.dispatchCommand(Bukkit.getConsoleSender(), cmd);
|
Bukkit.dispatchCommand(Bukkit.getConsoleSender(), cmd);
|
||||||
}
|
}
|
||||||
|
return true;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -55,9 +55,9 @@ public enum Role implements Permissable {
|
|||||||
return COLEADER;
|
return COLEADER;
|
||||||
case 4:
|
case 4:
|
||||||
return LEADER;
|
return LEADER;
|
||||||
default:
|
|
||||||
throw new IllegalStateException("Unexpected value: " + value);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
return null;
|
||||||
}
|
}
|
||||||
|
|
||||||
public static Role fromString(String check) {
|
public static Role fromString(String check) {
|
||||||
@ -76,9 +76,9 @@ public enum Role implements Permissable {
|
|||||||
case "recruit":
|
case "recruit":
|
||||||
case "rec":
|
case "rec":
|
||||||
return RECRUIT;
|
return RECRUIT;
|
||||||
default:
|
|
||||||
throw new IllegalStateException("Unexpected value: " + check.toLowerCase());
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
return null;
|
||||||
}
|
}
|
||||||
|
|
||||||
public boolean isAtLeast(Role role) {
|
public boolean isAtLeast(Role role) {
|
||||||
|
@ -6,7 +6,9 @@ import com.massivecraft.factions.Faction;
|
|||||||
import com.massivecraft.factions.FactionsPlugin;
|
import com.massivecraft.factions.FactionsPlugin;
|
||||||
import com.massivecraft.factions.integration.Econ;
|
import com.massivecraft.factions.integration.Econ;
|
||||||
import com.massivecraft.factions.struct.Relation;
|
import com.massivecraft.factions.struct.Relation;
|
||||||
|
import com.massivecraft.factions.util.timer.DateTimeFormats;
|
||||||
import com.massivecraft.factions.zcore.util.TL;
|
import com.massivecraft.factions.zcore.util.TL;
|
||||||
|
import org.apache.commons.lang.time.DurationFormatUtils;
|
||||||
|
|
||||||
import java.util.function.BiFunction;
|
import java.util.function.BiFunction;
|
||||||
import java.util.function.Function;
|
import java.util.function.Function;
|
||||||
@ -17,27 +19,32 @@ public enum FactionTag implements Tag {
|
|||||||
* @author FactionsUUID Team
|
* @author FactionsUUID Team
|
||||||
*/
|
*/
|
||||||
|
|
||||||
HOME_X("{x}", fac -> fac.hasHome() ? String.valueOf(fac.getHome().getBlockX()) : Tag.isMinimalShow() ? null : "{ig}"),
|
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_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}"),
|
HOME_Z("{z}", (fac) -> fac.hasHome() ? String.valueOf(fac.getHome().getBlockZ()) : Tag.isMinimalShow() ? null : "{ig}"),
|
||||||
CHUNKS("{chunks}", fac -> String.valueOf(fac.getLandRounded())),
|
CHUNKS("{chunks}", (fac) -> String.valueOf(fac.getLandRounded())),
|
||||||
WARPS("{warps}", fac -> String.valueOf(fac.getWarps().size())),
|
WARPS("{warps}", (fac) -> String.valueOf(fac.getWarps().size())),
|
||||||
HEADER("{header}", (fac, fp) -> FactionsPlugin.getInstance().txt.titleize(fac.getTag(fp))),
|
HEADER("{header}", (fac, fp) -> FactionsPlugin.getInstance().txt.titleize(fac.getTag(fp))),
|
||||||
POWER("{power}", fac -> String.valueOf(fac.getPowerRounded())),
|
POWER("{power}", (fac) -> String.valueOf(fac.getPowerRounded())),
|
||||||
MAX_POWER("{maxPower}", fac -> String.valueOf(fac.getPowerMaxRounded())),
|
MAX_POWER("{maxPower}", (fac) -> String.valueOf(fac.getPowerMaxRounded())),
|
||||||
POWER_BOOST("{power-boost}", fac -> {
|
POWER_BOOST("{power-boost}", (fac) -> {
|
||||||
double powerBoost = fac.getPowerBoost();
|
double powerBoost = fac.getPowerBoost();
|
||||||
return (powerBoost == 0.0) ? "" : (powerBoost > 0.0 ? TL.COMMAND_SHOW_BONUS.toString() : TL.COMMAND_SHOW_PENALTY.toString() + powerBoost + ")");
|
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();
|
FPlayer fAdmin = fac.getFPlayerAdmin();
|
||||||
return fAdmin == null ? "Server" : fAdmin.getName().substring(0, fAdmin.getName().length() > 14 ? 13 : fAdmin.getName().length());
|
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("{faction}", (Function<Faction, String>) Faction::getTag),
|
||||||
FACTION_RELATION_COLOR("{faction-relation-color}", (fac, fp) -> fp == null ? "" : fp.getColorTo(fac).toString()),
|
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}"),
|
//SHIELD_STATUS("{shield-status}",(fac) -> {
|
||||||
RAIDABLE("{raidable}", fac -> {
|
//if(fac.isProtected() && fac.getShieldFrame() != null) return String.valueOf(TL.SHIELD_CURRENTLY_ENABLE);
|
||||||
|
//if(fac.getShieldFrame() == null) return String.valueOf(TL.SHIELD_NOT_SET);
|
||||||
|
// return TL.SHIELD_CURRENTLY_NOT_ENABLED.toString();
|
||||||
|
//}),
|
||||||
|
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)) {
|
if (FactionsPlugin.getInstance().getConfig().getBoolean("hcf.raidable", false)) {
|
||||||
boolean raidable = fac.getLandRounded() >= fac.getPowerRounded();
|
boolean raidable = fac.getLandRounded() >= fac.getPowerRounded();
|
||||||
String str = raidable ? TL.RAIDABLE_TRUE.toString() : TL.RAIDABLE_FALSE.toString();
|
String str = raidable ? TL.RAIDABLE_TRUE.toString() : TL.RAIDABLE_FALSE.toString();
|
||||||
@ -50,35 +57,37 @@ public enum FactionTag implements Tag {
|
|||||||
return null;
|
return null;
|
||||||
}),
|
}),
|
||||||
|
|
||||||
ANNOUNCEMENT("{announcement}", fac -> String.valueOf(fac.getAnnouncements())),
|
ANNOUNCEMENT("{announcement}", (fac) -> {
|
||||||
PEACEFUL("{peaceful}", fac -> fac.isPeaceful() ? Conf.colorNeutral + TL.COMMAND_SHOW_PEACEFUL.toString() : ""),
|
return String.valueOf(fac.getAnnouncements());
|
||||||
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")),
|
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),
|
DESCRIPTION("{description}", Faction::getDescription),
|
||||||
CREATE_DATE("{create-date}", fac -> TL.sdf.format(fac.getFoundedDate())),
|
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")),
|
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 -> {
|
BANK_BALANCE("{faction-balance}", (fac) -> {
|
||||||
if (Econ.shouldBeUsed()) {
|
if (Econ.shouldBeUsed()) {
|
||||||
return Conf.bankEnabled ? Econ.moneyString(Econ.getBalance(fac.getAccountId())) : Tag.isMinimalShow() ? null : TL.ECON_OFF.format("balance");
|
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");
|
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")) {
|
if (FactionsPlugin.instance.getConfig().getBoolean("ftnt.Enabled")) {
|
||||||
return String.valueOf(fac.getTnt());
|
return String.valueOf(fac.getTnt());
|
||||||
}
|
}
|
||||||
return Tag.isMinimalShow() ? null : "";
|
return Tag.isMinimalShow() ? null : "";
|
||||||
}),
|
}),
|
||||||
TNT_MAX("{tnt-max-balance}", fac -> {
|
TNT_MAX("{tnt-max-balance}", (fac) -> {
|
||||||
if (FactionsPlugin.instance.getConfig().getBoolean("ftnt.Enabled")) {
|
if (FactionsPlugin.instance.getConfig().getBoolean("ftnt.Enabled")) {
|
||||||
return String.valueOf(fac.getTntBankLimit());
|
return String.valueOf(fac.getTntBankLimit());
|
||||||
}
|
}
|
||||||
return Tag.isMinimalShow() ? null : "";
|
return Tag.isMinimalShow() ? null : "";
|
||||||
}),
|
}),
|
||||||
|
|
||||||
ALLIES_COUNT("{allies}", fac -> String.valueOf(fac.getRelationCount(Relation.ALLY))),
|
ALLIES_COUNT("{allies}", (fac) -> String.valueOf(fac.getRelationCount(Relation.ALLY))),
|
||||||
ENEMIES_COUNT("{enemies}", fac -> String.valueOf(fac.getRelationCount(Relation.ENEMY))),
|
ENEMIES_COUNT("{enemies}", (fac) -> String.valueOf(fac.getRelationCount(Relation.ENEMY))),
|
||||||
TRUCES_COUNT("{truces}", fac -> String.valueOf(fac.getRelationCount(Relation.TRUCE))),
|
TRUCES_COUNT("{truces}", (fac) -> String.valueOf(fac.getRelationCount(Relation.TRUCE))),
|
||||||
ONLINE_COUNT("{online}", (fac, fp) -> {
|
ONLINE_COUNT("{online}", (fac, fp) -> {
|
||||||
if (fp != null && fp.isOnline()) {
|
if (fp != null && fp.isOnline()) {
|
||||||
return String.valueOf(fac.getFPlayersWhereOnline(true, fp).size());
|
return String.valueOf(fac.getFPlayersWhereOnline(true, fp).size());
|
||||||
@ -95,12 +104,12 @@ public enum FactionTag implements Tag {
|
|||||||
return String.valueOf(fac.getFPlayersWhereOnline(false).size());
|
return String.valueOf(fac.getFPlayersWhereOnline(false).size());
|
||||||
}
|
}
|
||||||
}),
|
}),
|
||||||
FACTION_STRIKES("{faction-strikes}", fac -> String.valueOf(fac.getStrikes())),
|
FACTION_STRIKES("{faction-strikes}", (fac) -> String.valueOf(fac.getStrikes())),
|
||||||
FACTION_POINTS("{faction-points}", fac -> String.valueOf(fac.getPoints())),
|
FACTION_POINTS("{faction-points}", (fac) -> String.valueOf(fac.getPoints())),
|
||||||
FACTION_SIZE("{members}", fac -> String.valueOf(fac.getFPlayers().size())),
|
FACTION_SIZE("{members}", (fac) -> String.valueOf(fac.getFPlayers().size())),
|
||||||
FACTION_KILLS("{faction-kills}", fac -> String.valueOf(fac.getKills())),
|
FACTION_KILLS("{faction-kills}", (fac) -> String.valueOf(fac.getKills())),
|
||||||
FACTION_DEATHS("{faction-deaths}", fac -> String.valueOf(fac.getDeaths())),
|
FACTION_DEATHS("{faction-deaths}", (fac) -> String.valueOf(fac.getDeaths())),
|
||||||
FACTION_BANCOUNT("{faction-bancount}", fac -> String.valueOf(fac.getBannedPlayers().size())),
|
FACTION_BANCOUNT("{faction-bancount}", (fac) -> String.valueOf(fac.getBannedPlayers().size())),
|
||||||
;
|
;
|
||||||
|
|
||||||
private final String tag;
|
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) {
|
public List getMessage(String text, Faction faction, FPlayer player, Map<UUID, String> groupMap) {
|
||||||
if (!this.foundInString(text)) {
|
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);
|
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 {
|
public class AutoLeaveProcessTask extends BukkitRunnable {
|
||||||
|
|
||||||
private transient boolean readyToGo;
|
private transient boolean readyToGo = false;
|
||||||
private transient boolean finished;
|
private transient boolean finished = false;
|
||||||
private transient ListIterator<FPlayer> iterator;
|
private transient ListIterator<FPlayer> iterator;
|
||||||
private transient double toleranceMillis;
|
private transient double toleranceMillis;
|
||||||
|
|
||||||
|
@ -15,12 +15,15 @@ import org.bukkit.ChatColor;
|
|||||||
import org.bukkit.entity.Player;
|
import org.bukkit.entity.Player;
|
||||||
|
|
||||||
import java.lang.reflect.InvocationTargetException;
|
import java.lang.reflect.InvocationTargetException;
|
||||||
import java.util.Arrays;
|
|
||||||
import java.util.UUID;
|
import java.util.UUID;
|
||||||
import java.util.logging.Level;
|
import java.util.logging.Level;
|
||||||
|
|
||||||
public class ClipPlaceholderAPIManager extends PlaceholderExpansion implements Relational {
|
public class ClipPlaceholderAPIManager extends PlaceholderExpansion implements Relational {
|
||||||
|
|
||||||
|
private static void logInvalid(String placeholder) {
|
||||||
|
FactionsPlugin.getInstance().getLogger().log(Level.INFO, "Invalid request through PlaceholderAPI for placeholder '" + placeholder + "'");
|
||||||
|
}
|
||||||
|
|
||||||
// Identifier for this expansion
|
// Identifier for this expansion
|
||||||
@Override
|
@Override
|
||||||
public String getIdentifier() {
|
public String getIdentifier() {
|
||||||
@ -214,7 +217,7 @@ public class ClipPlaceholderAPIManager extends PlaceholderExpansion implements R
|
|||||||
case "faction_relation_color":
|
case "faction_relation_color":
|
||||||
return fPlayer.getColorTo(faction).toString();
|
return fPlayer.getColorTo(faction).toString();
|
||||||
case "grace_time":
|
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));
|
return String.valueOf(TimerManager.getRemaining(FactionsPlugin.getInstance().getTimerManager().graceTimer.getRemaining(), true));
|
||||||
} else {
|
} else {
|
||||||
return TL.GRACE_DISABLED_PLACEHOLDER.toString();
|
return TL.GRACE_DISABLED_PLACEHOLDER.toString();
|
||||||
@ -249,10 +252,6 @@ public class ClipPlaceholderAPIManager extends PlaceholderExpansion implements R
|
|||||||
return TL.PLACEHOLDERAPI_NULL.toString();
|
return TL.PLACEHOLDERAPI_NULL.toString();
|
||||||
}
|
}
|
||||||
|
|
||||||
private static void logInvalid(String placeholder) {
|
|
||||||
FactionsPlugin.getInstance().getLogger().log(Level.INFO, "Invalid request through PlaceholderAPI for placeholder '" + placeholder + "'");
|
|
||||||
}
|
|
||||||
|
|
||||||
private int countOn(Faction f, Relation relation, Boolean status, FPlayer player) {
|
private int countOn(Faction f, Relation relation, Boolean status, FPlayer player) {
|
||||||
int count = 0;
|
int count = 0;
|
||||||
for (Faction faction : Factions.getInstance().getAllFactions()) {
|
for (Faction faction : Factions.getInstance().getAllFactions()) {
|
||||||
|
@ -3,7 +3,6 @@ package com.massivecraft.factions.util;
|
|||||||
import com.massivecraft.factions.FactionsPlugin;
|
import com.massivecraft.factions.FactionsPlugin;
|
||||||
import org.bukkit.entity.Player;
|
import org.bukkit.entity.Player;
|
||||||
import org.bukkit.metadata.FixedMetadataValue;
|
import org.bukkit.metadata.FixedMetadataValue;
|
||||||
import org.bukkit.metadata.MetadataValue;
|
|
||||||
|
|
||||||
import java.util.concurrent.TimeUnit;
|
import java.util.concurrent.TimeUnit;
|
||||||
|
|
||||||
@ -19,7 +18,7 @@ public class Cooldown {
|
|||||||
}
|
}
|
||||||
|
|
||||||
public static boolean isOnCooldown(Player player, String name) {
|
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();
|
long time = player.getMetadata(name).get(0).asLong();
|
||||||
return (time > System.currentTimeMillis());
|
return (time > System.currentTimeMillis());
|
||||||
}
|
}
|
||||||
|
@ -15,7 +15,7 @@ import java.io.IOException;
|
|||||||
public class InventoryUtil {
|
public class InventoryUtil {
|
||||||
|
|
||||||
|
|
||||||
public static String InventoryToString(ItemStack[] items) {
|
public static String InventoryToString(ItemStack[] items) throws IllegalStateException {
|
||||||
try {
|
try {
|
||||||
ByteArrayOutputStream outputStream = new ByteArrayOutputStream();
|
ByteArrayOutputStream outputStream = new ByteArrayOutputStream();
|
||||||
BukkitObjectOutputStream dataOutput = new BukkitObjectOutputStream(outputStream);
|
BukkitObjectOutputStream dataOutput = new BukkitObjectOutputStream(outputStream);
|
||||||
|
@ -109,6 +109,8 @@ public class MiscUtil {
|
|||||||
|
|
||||||
switch (player.getRole()) {
|
switch (player.getRole()) {
|
||||||
case LEADER:
|
case LEADER:
|
||||||
|
admins.add(player);
|
||||||
|
break;
|
||||||
case COLEADER:
|
case COLEADER:
|
||||||
admins.add(player);
|
admins.add(player);
|
||||||
break;
|
break;
|
||||||
|
@ -20,6 +20,8 @@ public class RelationUtil {
|
|||||||
}
|
}
|
||||||
|
|
||||||
Faction myFaction = getFaction(me);
|
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 (that instanceof Faction) {
|
||||||
if (me instanceof FPlayer && myFaction == thatFaction) {
|
if (me instanceof FPlayer && myFaction == thatFaction) {
|
||||||
ret = TL.GENERIC_YOURFACTION.toString();
|
ret = TL.GENERIC_YOURFACTION.toString();
|
||||||
|
@ -187,6 +187,7 @@ public abstract class SpiralTask implements Runnable {
|
|||||||
|
|
||||||
// for successful completion
|
// for successful completion
|
||||||
public void finish() {
|
public void finish() {
|
||||||
|
// FactionsPlugin.getInstance().log("SpiralTask successfully completed!");
|
||||||
this.stop();
|
this.stop();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -16,7 +16,8 @@ public class VisualizeUtil {
|
|||||||
}
|
}
|
||||||
|
|
||||||
public static Set<Location> getPlayerLocations(UUID uuid) {
|
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")
|
@SuppressWarnings("deprecation")
|
||||||
|
@ -1,5 +1,4 @@
|
|||||||
package com.massivecraft.factions.util;
|
package com.massivecraft.factions.util;
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* The MIT License (MIT)
|
* The MIT License (MIT)
|
||||||
*
|
*
|
||||||
@ -42,30 +41,23 @@ import java.util.*;
|
|||||||
import java.util.concurrent.TimeUnit;
|
import java.util.concurrent.TimeUnit;
|
||||||
import java.util.regex.Pattern;
|
import java.util.regex.Pattern;
|
||||||
|
|
||||||
/*
|
/**
|
||||||
* References
|
* <b>XMaterial</b> - Data Values/Pre-flattening<br>
|
||||||
*
|
* 1.13 and above as priority.
|
||||||
* * * GitHub: https://github.com/CryptoMorin/XSeries/blob/master/XMaterial.java
|
* <p>
|
||||||
* * XSeries: https://www.spigotmc.org/threads/378136/
|
* This class is mainly designed to support ItemStacks.
|
||||||
|
* If you want to use it on blocks you'll have to
|
||||||
|
* use <a href="https://github.com/CryptoMorin/XSeries/blob/master/XBlock.java">XBlock</a>
|
||||||
|
* <p>
|
||||||
* Pre-flattening: https://minecraft.gamepedia.com/Java_Edition_data_values/Pre-flattening
|
* Pre-flattening: https://minecraft.gamepedia.com/Java_Edition_data_values/Pre-flattening
|
||||||
* Materials: https://hub.spigotmc.org/javadocs/spigot/org/bukkit/Material.html
|
* Materials: https://hub.spigotmc.org/javadocs/spigot/org/bukkit/Material.html
|
||||||
* Materials (1.12): https://helpch.at/docs/1.12.2/index.html?org/bukkit/Material.html
|
* Materials (1.12): https://helpch.at/docs/1.12.2/index.html?org/bukkit/Material.html
|
||||||
* Material IDs: https://minecraft-ids.grahamedgecombe.com/
|
* Material IDs: https://minecraft-ids.grahamedgecombe.com/
|
||||||
* Material Source Code: https://hub.spigotmc.org/stash/projects/SPIGOT/repos/bukkit/browse/src/main/java/org/bukkit/Material.java
|
* Material Source Code: https://hub.spigotmc.org/stash/projects/SPIGOT/repos/bukkit/browse/src/main/java/org/bukkit/Material.java
|
||||||
* XMaterial v1: https://www.spigotmc.org/threads/329630/
|
* XMaterial v1: https://www.spigotmc.org/threads/329630/
|
||||||
*/
|
|
||||||
|
|
||||||
/**
|
|
||||||
* <b>XMaterial</b> - Data Values/Pre-flattening<br>
|
|
||||||
* Supports 1.8-1.15<br>
|
|
||||||
* 1.13 and above as priority.
|
|
||||||
* <p>
|
|
||||||
* This class is mainly designed to support ItemStacks.
|
|
||||||
* If you want to use it on blocks you'll have to
|
|
||||||
* use <a href="https://github.com/CryptoMorin/XSeries/blob/master/XBlock.java">XBlock</a>
|
|
||||||
*
|
*
|
||||||
* @author Crypto Morin
|
* @author Crypto Morin
|
||||||
* @version 4.0.0
|
* @version 5.0.0
|
||||||
* @see Material
|
* @see Material
|
||||||
* @see ItemStack
|
* @see ItemStack
|
||||||
*/
|
*/
|
||||||
@ -96,6 +88,7 @@ public enum XMaterial {
|
|||||||
*/
|
*/
|
||||||
AIR,
|
AIR,
|
||||||
ALLIUM(2, "RED_ROSE"),
|
ALLIUM(2, "RED_ROSE"),
|
||||||
|
ANCIENT_DEBRIS("1.16"),
|
||||||
ANDESITE(5, "STONE"),
|
ANDESITE(5, "STONE"),
|
||||||
ANDESITE_SLAB,
|
ANDESITE_SLAB,
|
||||||
ANDESITE_STAIRS,
|
ANDESITE_STAIRS,
|
||||||
@ -112,6 +105,7 @@ public enum XMaterial {
|
|||||||
BAMBOO_SAPLING("1.14"),
|
BAMBOO_SAPLING("1.14"),
|
||||||
BARREL("1.14", "CHEST", ""),
|
BARREL("1.14", "CHEST", ""),
|
||||||
BARRIER,
|
BARRIER,
|
||||||
|
BASALT("1.16"),
|
||||||
BAT_SPAWN_EGG(65, "MONSTER_EGG"),
|
BAT_SPAWN_EGG(65, "MONSTER_EGG"),
|
||||||
BEACON,
|
BEACON,
|
||||||
BEDROCK,
|
BEDROCK,
|
||||||
@ -144,8 +138,12 @@ public enum XMaterial {
|
|||||||
BIRCH_TRAPDOOR("TRAP_DOOR"),
|
BIRCH_TRAPDOOR("TRAP_DOOR"),
|
||||||
BIRCH_WALL_SIGN("SIGN_POST", "WALL_SIGN"),
|
BIRCH_WALL_SIGN("SIGN_POST", "WALL_SIGN"),
|
||||||
BIRCH_WOOD(2, "LOG"),
|
BIRCH_WOOD(2, "LOG"),
|
||||||
|
BLACKSTONE("1.16"),
|
||||||
|
BLACKSTONE_SLAB("1.16"),
|
||||||
|
BLACKSTONE_STAIRS("1.16"),
|
||||||
|
BLACKSTONE_WALL("1.16"),
|
||||||
BLACK_BANNER("BANNER", "STANDING_BANNER"),
|
BLACK_BANNER("BANNER", "STANDING_BANNER"),
|
||||||
BLACK_BED(15, "BED", "BED_BLOCK"),
|
BLACK_BED(15, "BED_BLOCK", "BED"),
|
||||||
BLACK_CARPET(15, "CARPET"),
|
BLACK_CARPET(15, "CARPET"),
|
||||||
BLACK_CONCRETE(15, "CONCRETE"),
|
BLACK_CONCRETE(15, "CONCRETE"),
|
||||||
BLACK_CONCRETE_POWDER(15, "CONCRETE_POWDER"),
|
BLACK_CONCRETE_POWDER(15, "CONCRETE_POWDER"),
|
||||||
@ -161,8 +159,8 @@ public enum XMaterial {
|
|||||||
BLAZE_POWDER,
|
BLAZE_POWDER,
|
||||||
BLAZE_ROD,
|
BLAZE_ROD,
|
||||||
BLAZE_SPAWN_EGG(61, "MONSTER_EGG"),
|
BLAZE_SPAWN_EGG(61, "MONSTER_EGG"),
|
||||||
BLUE_BANNER(11, "BANNER", "STANDING_BANNER"),
|
BLUE_BANNER(4, "BANNER", "STANDING_BANNER"),
|
||||||
BLUE_BED(4, "BED", "BED_BLOCK"),
|
BLUE_BED(11, "BED_BLOCK", "BED"),
|
||||||
BLUE_CARPET(11, "CARPET"),
|
BLUE_CARPET(11, "CARPET"),
|
||||||
BLUE_CONCRETE(11, "CONCRETE"),
|
BLUE_CONCRETE(11, "CONCRETE"),
|
||||||
BLUE_CONCRETE_POWDER(11, "CONCRETE_POWDER"),
|
BLUE_CONCRETE_POWDER(11, "CONCRETE_POWDER"),
|
||||||
@ -173,8 +171,8 @@ public enum XMaterial {
|
|||||||
BLUE_SHULKER_BOX,
|
BLUE_SHULKER_BOX,
|
||||||
BLUE_STAINED_GLASS(11, "STAINED_GLASS"),
|
BLUE_STAINED_GLASS(11, "STAINED_GLASS"),
|
||||||
BLUE_STAINED_GLASS_PANE(11, "THIN_GLASS", "STAINED_GLASS_PANE"),
|
BLUE_STAINED_GLASS_PANE(11, "THIN_GLASS", "STAINED_GLASS_PANE"),
|
||||||
BLUE_TERRACOTTA(11, "STAINED_CLAY"),
|
BLUE_TERRACOTTA(11, "HARD_CLAY", "STAINED_CLAY"),
|
||||||
BLUE_WALL_BANNER(11, "WALL_BANNER"),
|
BLUE_WALL_BANNER(4, "WALL_BANNER"),
|
||||||
BLUE_WOOL(11, "WOOL"),
|
BLUE_WOOL(11, "WOOL"),
|
||||||
BONE,
|
BONE,
|
||||||
BONE_BLOCK,
|
BONE_BLOCK,
|
||||||
@ -195,7 +193,7 @@ public enum XMaterial {
|
|||||||
BRICK_STAIRS,
|
BRICK_STAIRS,
|
||||||
BRICK_WALL,
|
BRICK_WALL,
|
||||||
BROWN_BANNER(3, "BANNER", "STANDING_BANNER"),
|
BROWN_BANNER(3, "BANNER", "STANDING_BANNER"),
|
||||||
BROWN_BED(12, "BED", "BED_BLOCK"),
|
BROWN_BED(12, "BED_BLOCK", "BED"),
|
||||||
BROWN_CARPET(12, "CARPET"),
|
BROWN_CARPET(12, "CARPET"),
|
||||||
BROWN_CONCRETE(12, "CONCRETE"),
|
BROWN_CONCRETE(12, "CONCRETE"),
|
||||||
BROWN_CONCRETE_POWDER(12, "CONCRETE_POWDER"),
|
BROWN_CONCRETE_POWDER(12, "CONCRETE_POWDER"),
|
||||||
@ -232,6 +230,7 @@ public enum XMaterial {
|
|||||||
*/
|
*/
|
||||||
CAVE_AIR("AIR"),
|
CAVE_AIR("AIR"),
|
||||||
CAVE_SPIDER_SPAWN_EGG(59, "MONSTER_EGG"),
|
CAVE_SPIDER_SPAWN_EGG(59, "MONSTER_EGG"),
|
||||||
|
CHAIN("1.16"),
|
||||||
CHAINMAIL_BOOTS,
|
CHAINMAIL_BOOTS,
|
||||||
CHAINMAIL_CHESTPLATE,
|
CHAINMAIL_CHESTPLATE,
|
||||||
CHAINMAIL_HELMET,
|
CHAINMAIL_HELMET,
|
||||||
@ -243,6 +242,8 @@ public enum XMaterial {
|
|||||||
CHICKEN("RAW_CHICKEN"),
|
CHICKEN("RAW_CHICKEN"),
|
||||||
CHICKEN_SPAWN_EGG(93, "MONSTER_EGG"),
|
CHICKEN_SPAWN_EGG(93, "MONSTER_EGG"),
|
||||||
CHIPPED_ANVIL(1, "ANVIL"),
|
CHIPPED_ANVIL(1, "ANVIL"),
|
||||||
|
CHISELED_NETHER_BRICKS(1, "NETHER_BRICKS"),
|
||||||
|
CHISELED_POLISHED_BLACKSTONE("1.16", "POLISHED_BLACKSTONE"),
|
||||||
CHISELED_QUARTZ_BLOCK(1, "QUARTZ_BLOCK"),
|
CHISELED_QUARTZ_BLOCK(1, "QUARTZ_BLOCK"),
|
||||||
CHISELED_RED_SANDSTONE(1, "RED_SANDSTONE"),
|
CHISELED_RED_SANDSTONE(1, "RED_SANDSTONE"),
|
||||||
CHISELED_SANDSTONE(1, "SANDSTONE"),
|
CHISELED_SANDSTONE(1, "SANDSTONE"),
|
||||||
@ -269,7 +270,14 @@ public enum XMaterial {
|
|||||||
COD_SPAWN_EGG("1.13", "MONSTER_EGG", ""),
|
COD_SPAWN_EGG("1.13", "MONSTER_EGG", ""),
|
||||||
COMMAND_BLOCK("COMMAND"),
|
COMMAND_BLOCK("COMMAND"),
|
||||||
COMMAND_BLOCK_MINECART("COMMAND_MINECART"),
|
COMMAND_BLOCK_MINECART("COMMAND_MINECART"),
|
||||||
COMPARATOR("REDSTONE_COMPARATOR", "REDSTONE_COMPARATOR_ON", "REDSTONE_COMPARATOR_OFF"),
|
/**
|
||||||
|
* Unlike redstone torch and redstone lamp... neither REDTONE_COMPARATOR_OFF nor REDSTONE_COMPARATOR_ON
|
||||||
|
* are items. REDSTONE_COMPARATOR is.
|
||||||
|
*
|
||||||
|
* @see #REDSTONE_TORCH
|
||||||
|
* @see #REDSTONE_LAMP
|
||||||
|
*/
|
||||||
|
COMPARATOR("REDSTONE_COMPARATOR_OFF", "REDSTONE_COMPARATOR_ON", "REDSTONE_COMPARATOR"),
|
||||||
COMPASS,
|
COMPASS,
|
||||||
COMPOSTER("1.14", "CAULDRON", ""),
|
COMPOSTER("1.14", "CAULDRON", ""),
|
||||||
CONDUIT("1.13", "BEACON"),
|
CONDUIT("1.13", "BEACON"),
|
||||||
@ -283,19 +291,38 @@ public enum XMaterial {
|
|||||||
COOKIE,
|
COOKIE,
|
||||||
CORNFLOWER(4, "1.14", "BLUE_DYE", ""),
|
CORNFLOWER(4, "1.14", "BLUE_DYE", ""),
|
||||||
COW_SPAWN_EGG(92, "MONSTER_EGG"),
|
COW_SPAWN_EGG(92, "MONSTER_EGG"),
|
||||||
|
CRACKED_NETHER_BRICKS(2, "NETHER_BRICKS"),
|
||||||
|
CRACKED_POLISHED_BLACKSTONE_BRICKS("1.16", "POLISHED_BLACKSTONE_BRICKS"),
|
||||||
CRACKED_STONE_BRICKS(2, "SMOOTH_BRICK"),
|
CRACKED_STONE_BRICKS(2, "SMOOTH_BRICK"),
|
||||||
CRAFTING_TABLE("WORKBENCH"),
|
CRAFTING_TABLE("WORKBENCH"),
|
||||||
CREEPER_BANNER_PATTERN,
|
CREEPER_BANNER_PATTERN,
|
||||||
CREEPER_HEAD(4, "SKULL", "SKULL_ITEM"),
|
CREEPER_HEAD(4, "SKULL", "SKULL_ITEM"),
|
||||||
CREEPER_SPAWN_EGG(50, "MONSTER_EGG"),
|
CREEPER_SPAWN_EGG(50, "MONSTER_EGG"),
|
||||||
CREEPER_WALL_HEAD(4, "SKULL", "SKULL_ITEM"),
|
CREEPER_WALL_HEAD(4, "SKULL", "SKULL_ITEM"),
|
||||||
|
CRIMSON_BUTTON("1.16"),
|
||||||
|
CRIMSON_DOOR("1.16"),
|
||||||
|
CRIMSON_FENCE("1.16"),
|
||||||
|
CRIMSON_FENCE_GATE("1.16"),
|
||||||
|
CRIMSON_FUNGUS("1.16"),
|
||||||
|
CRIMSON_HYPHAE("1.16"),
|
||||||
|
CRIMSON_NYLIUM("1.16"),
|
||||||
|
CRIMSON_PLANKS("1.16"),
|
||||||
|
CRIMSON_PRESSURE_PLATE("1.16"),
|
||||||
|
CRIMSON_ROOTS("1.16"),
|
||||||
|
CRIMSON_SIGN("1.16"),
|
||||||
|
CRIMSON_SLAB("1.16"),
|
||||||
|
CRIMSON_STAIRS("1.16"),
|
||||||
|
CRIMSON_STEM("1.16"),
|
||||||
|
CRIMSON_TRAPDOOR("1.16"),
|
||||||
|
CRIMSON_WALL_SIGN("1.16"),
|
||||||
CROSSBOW,
|
CROSSBOW,
|
||||||
|
CRYING_OBSIDIAN("1.16"),
|
||||||
CUT_RED_SANDSTONE("1.13"),
|
CUT_RED_SANDSTONE("1.13"),
|
||||||
CUT_RED_SANDSTONE_SLAB("STONE_SLAB2"),
|
CUT_RED_SANDSTONE_SLAB("STONE_SLAB2"),
|
||||||
CUT_SANDSTONE("1.13"),
|
CUT_SANDSTONE("1.13"),
|
||||||
CUT_SANDSTONE_SLAB("STEP"),
|
CUT_SANDSTONE_SLAB("STEP"),
|
||||||
CYAN_BANNER(6, "BANNER", "STANDING_BANNER"),
|
CYAN_BANNER(6, "BANNER", "STANDING_BANNER"),
|
||||||
CYAN_BED(9, "BED", "BED_BLOCK"),
|
CYAN_BED(9, "BED_BLOCK", "BED"),
|
||||||
CYAN_CARPET(9, "CARPET"),
|
CYAN_CARPET(9, "CARPET"),
|
||||||
CYAN_CONCRETE(9, "CONCRETE"),
|
CYAN_CONCRETE(9, "CONCRETE"),
|
||||||
CYAN_CONCRETE_POWDER(9, "CONCRETE_POWDER"),
|
CYAN_CONCRETE_POWDER(9, "CONCRETE_POWDER"),
|
||||||
@ -314,13 +341,13 @@ public enum XMaterial {
|
|||||||
DARK_OAK_DOOR("DARK_OAK_DOOR_ITEM"),
|
DARK_OAK_DOOR("DARK_OAK_DOOR_ITEM"),
|
||||||
DARK_OAK_FENCE,
|
DARK_OAK_FENCE,
|
||||||
DARK_OAK_FENCE_GATE,
|
DARK_OAK_FENCE_GATE,
|
||||||
DARK_OAK_LEAVES(1, "LEAVES", "LEAVES_2"),
|
DARK_OAK_LEAVES(4, "LEAVES", "LEAVES_2"),
|
||||||
DARK_OAK_LOG(1, "LOG", "LOG_2"),
|
DARK_OAK_LOG(1, "LOG", "LOG_2"),
|
||||||
DARK_OAK_PLANKS(5, "WOOD"),
|
DARK_OAK_PLANKS(5, "WOOD"),
|
||||||
DARK_OAK_PRESSURE_PLATE("WOOD_PLATE"),
|
DARK_OAK_PRESSURE_PLATE("WOOD_PLATE"),
|
||||||
DARK_OAK_SAPLING(5, "SAPLING"),
|
DARK_OAK_SAPLING(5, "SAPLING"),
|
||||||
DARK_OAK_SIGN("SIGN"),
|
DARK_OAK_SIGN("SIGN"),
|
||||||
DARK_OAK_SLAB("WOOD_STEP", "WOODEN_SLAB", "WOOD_DOUBLE_STEP"),
|
DARK_OAK_SLAB(5, "WOOD_STEP", "WOODEN_SLAB", "WOOD_DOUBLE_STEP"),
|
||||||
DARK_OAK_STAIRS,
|
DARK_OAK_STAIRS,
|
||||||
DARK_OAK_TRAPDOOR("TRAP_DOOR"),
|
DARK_OAK_TRAPDOOR("TRAP_DOOR"),
|
||||||
DARK_OAK_WALL_SIGN("SIGN_POST", "WALL_SIGN"),
|
DARK_OAK_WALL_SIGN("SIGN_POST", "WALL_SIGN"),
|
||||||
@ -402,7 +429,7 @@ public enum XMaterial {
|
|||||||
END_ROD("1.9", "BLAZE_ROD", ""),
|
END_ROD("1.9", "BLAZE_ROD", ""),
|
||||||
END_STONE("ENDER_STONE"),
|
END_STONE("ENDER_STONE"),
|
||||||
END_STONE_BRICKS("END_BRICKS"),
|
END_STONE_BRICKS("END_BRICKS"),
|
||||||
END_STONE_BRICK_SLAB(4, "STEP"),
|
END_STONE_BRICK_SLAB(6, "STEP"),
|
||||||
END_STONE_BRICK_STAIRS("SMOOTH_STAIRS"),
|
END_STONE_BRICK_STAIRS("SMOOTH_STAIRS"),
|
||||||
END_STONE_BRICK_WALL,
|
END_STONE_BRICK_WALL,
|
||||||
EVOKER_SPAWN_EGG(34, "MONSTER_EGG"),
|
EVOKER_SPAWN_EGG(34, "MONSTER_EGG"),
|
||||||
@ -410,7 +437,12 @@ public enum XMaterial {
|
|||||||
FARMLAND("SOIL"),
|
FARMLAND("SOIL"),
|
||||||
FEATHER,
|
FEATHER,
|
||||||
FERMENTED_SPIDER_EYE,
|
FERMENTED_SPIDER_EYE,
|
||||||
FERN(2, "LONG_GRASS"),
|
FERN(1, "LONG_GRASS"),
|
||||||
|
/**
|
||||||
|
* For some reasons filled map items are really special.
|
||||||
|
* Their data value starts from 0 and every time a player
|
||||||
|
* creates a new map that maps data value increases.
|
||||||
|
*/
|
||||||
FILLED_MAP("MAP"),
|
FILLED_MAP("MAP"),
|
||||||
FIRE,
|
FIRE,
|
||||||
FIREWORK_ROCKET("FIREWORK"),
|
FIREWORK_ROCKET("FIREWORK"),
|
||||||
@ -467,7 +499,7 @@ public enum XMaterial {
|
|||||||
GRASS_PATH,
|
GRASS_PATH,
|
||||||
GRAVEL,
|
GRAVEL,
|
||||||
GRAY_BANNER(8, "BANNER", "STANDING_BANNER"),
|
GRAY_BANNER(8, "BANNER", "STANDING_BANNER"),
|
||||||
GRAY_BED(7, "BED", "BED_BLOCK"),
|
GRAY_BED(7, "BED_BLOCK", "BED"),
|
||||||
GRAY_CARPET(7, "CARPET"),
|
GRAY_CARPET(7, "CARPET"),
|
||||||
GRAY_CONCRETE(7, "CONCRETE"),
|
GRAY_CONCRETE(7, "CONCRETE"),
|
||||||
GRAY_CONCRETE_POWDER(7, "CONCRETE_POWDER"),
|
GRAY_CONCRETE_POWDER(7, "CONCRETE_POWDER"),
|
||||||
@ -480,7 +512,7 @@ public enum XMaterial {
|
|||||||
GRAY_WALL_BANNER(8, "WALL_BANNER"),
|
GRAY_WALL_BANNER(8, "WALL_BANNER"),
|
||||||
GRAY_WOOL(7, "WOOL"),
|
GRAY_WOOL(7, "WOOL"),
|
||||||
GREEN_BANNER(2, "BANNER", "STANDING_BANNER"),
|
GREEN_BANNER(2, "BANNER", "STANDING_BANNER"),
|
||||||
GREEN_BED(13, "BED", "BED_BLOCK"),
|
GREEN_BED(13, "BED_BLOCK", "BED"),
|
||||||
GREEN_CARPET(13, "CARPET"),
|
GREEN_CARPET(13, "CARPET"),
|
||||||
GREEN_CONCRETE(13, "CONCRETE"),
|
GREEN_CONCRETE(13, "CONCRETE"),
|
||||||
GREEN_CONCRETE_POWDER(13, "CONCRETE_POWDER"),
|
GREEN_CONCRETE_POWDER(13, "CONCRETE_POWDER"),
|
||||||
@ -498,6 +530,7 @@ public enum XMaterial {
|
|||||||
HAY_BLOCK,
|
HAY_BLOCK,
|
||||||
HEART_OF_THE_SEA("1.13"),
|
HEART_OF_THE_SEA("1.13"),
|
||||||
HEAVY_WEIGHTED_PRESSURE_PLATE("IRON_PLATE"),
|
HEAVY_WEIGHTED_PRESSURE_PLATE("IRON_PLATE"),
|
||||||
|
HOGLIN_SPAWN_EGG("1.16", "MONSTER_EGG"),
|
||||||
HONEYCOMB("1.15"),
|
HONEYCOMB("1.15"),
|
||||||
HONEYCOMB_BLOCK("1.15"),
|
HONEYCOMB_BLOCK("1.15"),
|
||||||
HONEY_BLOCK("1.15", "SLIME_BLOCK", ""),
|
HONEY_BLOCK("1.15", "SLIME_BLOCK", ""),
|
||||||
@ -575,8 +608,8 @@ public enum XMaterial {
|
|||||||
LEATHER_LEGGINGS,
|
LEATHER_LEGGINGS,
|
||||||
LECTERN("1.14", "BOOKSHELF", ""),
|
LECTERN("1.14", "BOOKSHELF", ""),
|
||||||
LEVER,
|
LEVER,
|
||||||
LIGHT_BLUE_BANNER(3, "BANNER", "STANDING_BANNER"),
|
LIGHT_BLUE_BANNER(12, "BANNER", "STANDING_BANNER"),
|
||||||
LIGHT_BLUE_BED(3, "BED", "BED_BLOCK"),
|
LIGHT_BLUE_BED(3, "BED_BLOCK", "BED"),
|
||||||
LIGHT_BLUE_CARPET(3, "CARPET"),
|
LIGHT_BLUE_CARPET(3, "CARPET"),
|
||||||
LIGHT_BLUE_CONCRETE(3, "CONCRETE"),
|
LIGHT_BLUE_CONCRETE(3, "CONCRETE"),
|
||||||
LIGHT_BLUE_CONCRETE_POWDER(3, "CONCRETE_POWDER"),
|
LIGHT_BLUE_CONCRETE_POWDER(3, "CONCRETE_POWDER"),
|
||||||
@ -589,16 +622,16 @@ public enum XMaterial {
|
|||||||
LIGHT_BLUE_WALL_BANNER(12, "WALL_BANNER", "BANNER", "STANDING_BANNER"),
|
LIGHT_BLUE_WALL_BANNER(12, "WALL_BANNER", "BANNER", "STANDING_BANNER"),
|
||||||
LIGHT_BLUE_WOOL(3, "WOOL"),
|
LIGHT_BLUE_WOOL(3, "WOOL"),
|
||||||
LIGHT_GRAY_BANNER(7, "BANNER", "STANDING_BANNER"),
|
LIGHT_GRAY_BANNER(7, "BANNER", "STANDING_BANNER"),
|
||||||
LIGHT_GRAY_BED(8, "BED", "BED_BLOCK"),
|
LIGHT_GRAY_BED(8, "BED_BLOCK", "BED"),
|
||||||
LIGHT_GRAY_CARPET(8, "CARPET"),
|
LIGHT_GRAY_CARPET(8, "CARPET"),
|
||||||
LIGHT_GRAY_CONCRETE(8, "CONCRETE"),
|
LIGHT_GRAY_CONCRETE(8, "CONCRETE"),
|
||||||
LIGHT_GRAY_CONCRETE_POWDER(8, "CONCRETE_POWDER"),
|
LIGHT_GRAY_CONCRETE_POWDER(8, "CONCRETE_POWDER"),
|
||||||
LIGHT_GRAY_DYE(7, "INK_SACK"),
|
LIGHT_GRAY_DYE(7, "INK_SACK"),
|
||||||
/**
|
/**
|
||||||
* Renamed to SILVER_GLAZED_TERRACOTTA in 1.13
|
* Renamed to SILVER_GLAZED_TERRACOTTA in 1.12
|
||||||
* Renamed to LIGHT_GRAY_GLAZED_TERRACOTTA in 1.14
|
* Renamed to LIGHT_GRAY_GLAZED_TERRACOTTA in 1.14
|
||||||
*/
|
*/
|
||||||
LIGHT_GRAY_GLAZED_TERRACOTTA(8, "1.12", "HARD_CLAY", "STAINED_CLAY", "LIGHT_GRAY_TERRACOTTA", "SILVER_GLAZED_TERRACOTTA"),
|
LIGHT_GRAY_GLAZED_TERRACOTTA("1.12", "HARD_CLAY", "STAINED_CLAY", "LIGHT_GRAY_TERRACOTTA", "SILVER_GLAZED_TERRACOTTA"),
|
||||||
LIGHT_GRAY_SHULKER_BOX("SILVER_SHULKER_BOX"),
|
LIGHT_GRAY_SHULKER_BOX("SILVER_SHULKER_BOX"),
|
||||||
LIGHT_GRAY_STAINED_GLASS(8, "STAINED_GLASS"),
|
LIGHT_GRAY_STAINED_GLASS(8, "STAINED_GLASS"),
|
||||||
LIGHT_GRAY_STAINED_GLASS_PANE(8, "THIN_GLASS", "STAINED_GLASS_PANE"),
|
LIGHT_GRAY_STAINED_GLASS_PANE(8, "THIN_GLASS", "STAINED_GLASS_PANE"),
|
||||||
@ -610,7 +643,7 @@ public enum XMaterial {
|
|||||||
LILY_OF_THE_VALLEY(15, "1.14", "WHITE_DYE", ""),
|
LILY_OF_THE_VALLEY(15, "1.14", "WHITE_DYE", ""),
|
||||||
LILY_PAD("WATER_LILY"),
|
LILY_PAD("WATER_LILY"),
|
||||||
LIME_BANNER(10, "BANNER", "STANDING_BANNER"),
|
LIME_BANNER(10, "BANNER", "STANDING_BANNER"),
|
||||||
LIME_BED(5, "BED", "BED_BLOCK"),
|
LIME_BED(5, "BED_BLOCK", "BED"),
|
||||||
LIME_CARPET(5, "CARPET"),
|
LIME_CARPET(5, "CARPET"),
|
||||||
LIME_CONCRETE(5, "CONCRETE"),
|
LIME_CONCRETE(5, "CONCRETE"),
|
||||||
LIME_CONCRETE_POWDER(5, "CONCRETE_POWDER"),
|
LIME_CONCRETE_POWDER(5, "CONCRETE_POWDER"),
|
||||||
@ -624,9 +657,10 @@ public enum XMaterial {
|
|||||||
LIME_WOOL(5, "WOOL"),
|
LIME_WOOL(5, "WOOL"),
|
||||||
LINGERING_POTION,
|
LINGERING_POTION,
|
||||||
LLAMA_SPAWN_EGG(103, "MONSTER_EGG"),
|
LLAMA_SPAWN_EGG(103, "MONSTER_EGG"),
|
||||||
|
LODESTONE("1.16"),
|
||||||
LOOM("1.14"),
|
LOOM("1.14"),
|
||||||
MAGENTA_BANNER(13, "BANNER", "STANDING_BANNER"),
|
MAGENTA_BANNER(13, "BANNER", "STANDING_BANNER"),
|
||||||
MAGENTA_BED(2, "BED", "BED_BLOCK"),
|
MAGENTA_BED(2, "BED_BLOCK", "BED"),
|
||||||
MAGENTA_CARPET(2, "CARPET"),
|
MAGENTA_CARPET(2, "CARPET"),
|
||||||
MAGENTA_CONCRETE(2, "CONCRETE"),
|
MAGENTA_CONCRETE(2, "CONCRETE"),
|
||||||
MAGENTA_CONCRETE_POWDER(2, "CONCRETE_POWDER"),
|
MAGENTA_CONCRETE_POWDER(2, "CONCRETE_POWDER"),
|
||||||
@ -641,6 +675,13 @@ public enum XMaterial {
|
|||||||
MAGMA_BLOCK("1.10", "MAGMA"),
|
MAGMA_BLOCK("1.10", "MAGMA"),
|
||||||
MAGMA_CREAM,
|
MAGMA_CREAM,
|
||||||
MAGMA_CUBE_SPAWN_EGG(62, "MONSTER_EGG"),
|
MAGMA_CUBE_SPAWN_EGG(62, "MONSTER_EGG"),
|
||||||
|
/**
|
||||||
|
* Adding this to the duplicated list will give you a filled map
|
||||||
|
* for 1.13+ versions and removing it from duplicated list will
|
||||||
|
* still give you a filled map in -1.12 versions.
|
||||||
|
* Since higher versions are our priority I'll keep 1.13+ support
|
||||||
|
* until I can come up with something to fix it.
|
||||||
|
*/
|
||||||
MAP("EMPTY_MAP"),
|
MAP("EMPTY_MAP"),
|
||||||
MELON("MELON_BLOCK"),
|
MELON("MELON_BLOCK"),
|
||||||
MELON_SEEDS,
|
MELON_SEEDS,
|
||||||
@ -655,7 +696,7 @@ public enum XMaterial {
|
|||||||
MOSSY_COBBLESTONE_STAIRS,
|
MOSSY_COBBLESTONE_STAIRS,
|
||||||
MOSSY_COBBLESTONE_WALL(1, "COBBLE_WALL", "COBBLESTONE_WALL"),
|
MOSSY_COBBLESTONE_WALL(1, "COBBLE_WALL", "COBBLESTONE_WALL"),
|
||||||
MOSSY_STONE_BRICKS(1, "SMOOTH_BRICK"),
|
MOSSY_STONE_BRICKS(1, "SMOOTH_BRICK"),
|
||||||
MOSSY_STONE_BRICK_SLAB(4, "STEP"),
|
MOSSY_STONE_BRICK_SLAB(5, "STEP"),
|
||||||
MOSSY_STONE_BRICK_STAIRS("SMOOTH_STAIRS"),
|
MOSSY_STONE_BRICK_STAIRS("SMOOTH_STAIRS"),
|
||||||
MOSSY_STONE_BRICK_WALL,
|
MOSSY_STONE_BRICK_WALL,
|
||||||
MOVING_PISTON("PISTON_BASE", "PISTON_MOVING_PIECE"),
|
MOVING_PISTON("PISTON_BASE", "PISTON_MOVING_PIECE"),
|
||||||
@ -678,15 +719,29 @@ public enum XMaterial {
|
|||||||
MYCELIUM("MYCEL"),
|
MYCELIUM("MYCEL"),
|
||||||
NAME_TAG,
|
NAME_TAG,
|
||||||
NAUTILUS_SHELL("1.13"),
|
NAUTILUS_SHELL("1.13"),
|
||||||
|
NETHERITE_AXE("1.16"),
|
||||||
|
NETHERITE_BLOCK("1.16"),
|
||||||
|
NETHERITE_BOOTS("1.16"),
|
||||||
|
NETHERITE_CHESTPLATE("1.16"),
|
||||||
|
NETHERITE_HELMET("1.16"),
|
||||||
|
NETHERITE_HOE("1.16"),
|
||||||
|
NETHERITE_INGOT("1.16"),
|
||||||
|
NETHERITE_LEGGINGS("1.16"),
|
||||||
|
NETHERITE_PICKAXE("1.16"),
|
||||||
|
NETHERITE_SCRAP("1.16"),
|
||||||
|
NETHERITE_SHOVEL("1.16"),
|
||||||
|
NETHERITE_SWORD("1.16"),
|
||||||
NETHERRACK,
|
NETHERRACK,
|
||||||
NETHER_BRICK("NETHER_BRICK_ITEM"),
|
NETHER_BRICK("NETHER_BRICK_ITEM"),
|
||||||
NETHER_BRICKS("NETHER_BRICK"),
|
NETHER_BRICKS("NETHER_BRICK"),
|
||||||
NETHER_BRICK_FENCE("NETHER_FENCE"),
|
NETHER_BRICK_FENCE("NETHER_FENCE"),
|
||||||
NETHER_BRICK_SLAB(4, "STEP"),
|
NETHER_BRICK_SLAB(6, "STEP"),
|
||||||
NETHER_BRICK_STAIRS,
|
NETHER_BRICK_STAIRS,
|
||||||
NETHER_BRICK_WALL,
|
NETHER_BRICK_WALL,
|
||||||
|
NETHER_GOLD_ORE("1.16"),
|
||||||
NETHER_PORTAL("PORTAL"),
|
NETHER_PORTAL("PORTAL"),
|
||||||
NETHER_QUARTZ_ORE("QUARTZ_ORE"),
|
NETHER_QUARTZ_ORE("QUARTZ_ORE"),
|
||||||
|
NETHER_SPROUTS("1.16"),
|
||||||
NETHER_STAR,
|
NETHER_STAR,
|
||||||
/**
|
/**
|
||||||
* Just like mentioned in https://minecraft.gamepedia.com/Nether_Wart
|
* Just like mentioned in https://minecraft.gamepedia.com/Nether_Wart
|
||||||
@ -716,7 +771,7 @@ public enum XMaterial {
|
|||||||
OBSIDIAN,
|
OBSIDIAN,
|
||||||
OCELOT_SPAWN_EGG(98, "MONSTER_EGG"),
|
OCELOT_SPAWN_EGG(98, "MONSTER_EGG"),
|
||||||
ORANGE_BANNER(14, "BANNER", "STANDING_BANNER"),
|
ORANGE_BANNER(14, "BANNER", "STANDING_BANNER"),
|
||||||
ORANGE_BED(1, "BED", "BED_BLOCK"),
|
ORANGE_BED(1, "BED_BLOCK", "BED"),
|
||||||
ORANGE_CARPET(1, "CARPET"),
|
ORANGE_CARPET(1, "CARPET"),
|
||||||
ORANGE_CONCRETE(1, "CONCRETE"),
|
ORANGE_CONCRETE(1, "CONCRETE"),
|
||||||
ORANGE_CONCRETE_POWDER(1, "CONCRETE_POWDER"),
|
ORANGE_CONCRETE_POWDER(1, "CONCRETE_POWDER"),
|
||||||
@ -742,7 +797,7 @@ public enum XMaterial {
|
|||||||
PIG_SPAWN_EGG(90, "MONSTER_EGG"),
|
PIG_SPAWN_EGG(90, "MONSTER_EGG"),
|
||||||
PILLAGER_SPAWN_EGG("1.14"),
|
PILLAGER_SPAWN_EGG("1.14"),
|
||||||
PINK_BANNER(9, "BANNER", "STANDING_BANNER"),
|
PINK_BANNER(9, "BANNER", "STANDING_BANNER"),
|
||||||
PINK_BED(6, "BED", "BED_BLOCK"),
|
PINK_BED(6, "BED_BLOCK", "BED"),
|
||||||
PINK_CARPET(6, "CARPET"),
|
PINK_CARPET(6, "CARPET"),
|
||||||
PINK_CONCRETE(6, "CONCRETE"),
|
PINK_CONCRETE(6, "CONCRETE"),
|
||||||
PINK_CONCRETE_POWDER(6, "CONCRETE_POWDER"),
|
PINK_CONCRETE_POWDER(6, "CONCRETE_POWDER"),
|
||||||
@ -753,7 +808,7 @@ public enum XMaterial {
|
|||||||
PINK_STAINED_GLASS_PANE(6, "THIN_GLASS", "STAINED_GLASS_PANE"),
|
PINK_STAINED_GLASS_PANE(6, "THIN_GLASS", "STAINED_GLASS_PANE"),
|
||||||
PINK_TERRACOTTA(6, "HARD_CLAY", "STAINED_CLAY"),
|
PINK_TERRACOTTA(6, "HARD_CLAY", "STAINED_CLAY"),
|
||||||
PINK_TULIP(7, "RED_ROSE"),
|
PINK_TULIP(7, "RED_ROSE"),
|
||||||
PINK_WALL_BANNER(14, "WALL_BANNER"),
|
PINK_WALL_BANNER(9, "WALL_BANNER"),
|
||||||
PINK_WOOL(6, "WOOL"),
|
PINK_WOOL(6, "WOOL"),
|
||||||
PISTON("PISTON_BASE"),
|
PISTON("PISTON_BASE"),
|
||||||
PISTON_HEAD("PISTON_EXTENSION"),
|
PISTON_HEAD("PISTON_EXTENSION"),
|
||||||
@ -765,6 +820,17 @@ public enum XMaterial {
|
|||||||
POLISHED_ANDESITE(6, "STONE"),
|
POLISHED_ANDESITE(6, "STONE"),
|
||||||
POLISHED_ANDESITE_SLAB,
|
POLISHED_ANDESITE_SLAB,
|
||||||
POLISHED_ANDESITE_STAIRS,
|
POLISHED_ANDESITE_STAIRS,
|
||||||
|
POLISHED_BASALT("1.16"),
|
||||||
|
POLISHED_BLACKSTONE("1.16"),
|
||||||
|
POLISHED_BLACKSTONE_BRICKS("1.16"),
|
||||||
|
POLISHED_BLACKSTONE_BRICK_SLAB("1.16"),
|
||||||
|
POLISHED_BLACKSTONE_BRICK_STAIRS("1.16"),
|
||||||
|
POLISHED_BLACKSTONE_BRICK_WALL("1.16"),
|
||||||
|
POLISHED_BLACKSTONE_BUTTON("1.16"),
|
||||||
|
POLISHED_BLACKSTONE_PRESSURE_PLATE("1.16"),
|
||||||
|
POLISHED_BLACKSTONE_SLAB("1.16"),
|
||||||
|
POLISHED_BLACKSTONE_STAIRS("1.16"),
|
||||||
|
POLISHED_BLACKSTONE_WALL("1.16"),
|
||||||
POLISHED_DIORITE(4, "STONE"),
|
POLISHED_DIORITE(4, "STONE"),
|
||||||
POLISHED_DIORITE_SLAB,
|
POLISHED_DIORITE_SLAB,
|
||||||
POLISHED_DIORITE_STAIRS,
|
POLISHED_DIORITE_STAIRS,
|
||||||
@ -820,7 +886,7 @@ public enum XMaterial {
|
|||||||
PUMPKIN_SEEDS,
|
PUMPKIN_SEEDS,
|
||||||
PUMPKIN_STEM,
|
PUMPKIN_STEM,
|
||||||
PURPLE_BANNER(5, "BANNER", "STANDING_BANNER"),
|
PURPLE_BANNER(5, "BANNER", "STANDING_BANNER"),
|
||||||
PURPLE_BED(10, "BED", "BED_BLOCK"),
|
PURPLE_BED(10, "BED_BLOCK", "BED"),
|
||||||
PURPLE_CARPET(10, "CARPET"),
|
PURPLE_CARPET(10, "CARPET"),
|
||||||
PURPLE_CONCRETE(10, "CONCRETE"),
|
PURPLE_CONCRETE(10, "CONCRETE"),
|
||||||
PURPLE_CONCRETE_POWDER(10, "CONCRETE_POWDER"),
|
PURPLE_CONCRETE_POWDER(10, "CONCRETE_POWDER"),
|
||||||
@ -850,17 +916,34 @@ public enum XMaterial {
|
|||||||
RAVAGER_SPAWN_EGG("1.14"),
|
RAVAGER_SPAWN_EGG("1.14"),
|
||||||
REDSTONE,
|
REDSTONE,
|
||||||
REDSTONE_BLOCK,
|
REDSTONE_BLOCK,
|
||||||
REDSTONE_LAMP("REDSTONE_LAMP_OFF", "REDSTONE_LAMP_ON"),
|
/**
|
||||||
|
* Unlike redstone torch, REDSTONE_LAMP_ON isn't an item.
|
||||||
|
* The name is just here on the list for matching.
|
||||||
|
*
|
||||||
|
* @see #REDSTONE_TORCH
|
||||||
|
*/
|
||||||
|
REDSTONE_LAMP("REDSTONE_LAMP_ON", "REDSTONE_LAMP_OFF"),
|
||||||
REDSTONE_ORE("GLOWING_REDSTONE_ORE"),
|
REDSTONE_ORE("GLOWING_REDSTONE_ORE"),
|
||||||
REDSTONE_TORCH("REDSTONE_TORCH_ON", "REDSTONE_TORCH_OFF"),
|
/**
|
||||||
REDSTONE_WALL_TORCH(1, "REDSTONE_TORCH_ON", "REDSTONE_TORCH_OFF"),
|
* REDSTONE_TORCH_OFF isn't an item, but a block.
|
||||||
|
* But REDSTONE_TORCH_ON is the item.
|
||||||
|
* The name is just here on the list for matching.
|
||||||
|
*/
|
||||||
|
REDSTONE_TORCH("REDSTONE_TORCH_OFF", "REDSTONE_TORCH_ON"),
|
||||||
|
REDSTONE_WALL_TORCH,
|
||||||
REDSTONE_WIRE,
|
REDSTONE_WIRE,
|
||||||
RED_BANNER(1, "BANNER", "STANDING_BANNER"),
|
RED_BANNER(1, "BANNER", "STANDING_BANNER"),
|
||||||
RED_BED(14, "BED", "BED_BLOCK"),
|
/**
|
||||||
|
* Data value 14 or 0
|
||||||
|
*/
|
||||||
|
RED_BED(0, "BED_BLOCK", "BED"),
|
||||||
RED_CARPET(14, "CARPET"),
|
RED_CARPET(14, "CARPET"),
|
||||||
RED_CONCRETE(14, "CONCRETE"),
|
RED_CONCRETE(14, "CONCRETE"),
|
||||||
RED_CONCRETE_POWDER(14, "CONCRETE_POWDER"),
|
RED_CONCRETE_POWDER(14, "CONCRETE_POWDER"),
|
||||||
RED_DYE(1, "ROSE_RED"),
|
/**
|
||||||
|
* Data value 0 or 1?
|
||||||
|
*/
|
||||||
|
RED_DYE(0, "INK_SACK", "ROSE_RED"),
|
||||||
RED_GLAZED_TERRACOTTA(14, "1.12", "HARD_CLAY", "STAINED_CLAY", "RED_TERRACOTTA"),
|
RED_GLAZED_TERRACOTTA(14, "1.12", "HARD_CLAY", "STAINED_CLAY", "RED_TERRACOTTA"),
|
||||||
RED_MUSHROOM,
|
RED_MUSHROOM,
|
||||||
RED_MUSHROOM_BLOCK("RED_MUSHROOM", "HUGE_MUSHROOM_2"),
|
RED_MUSHROOM_BLOCK("RED_MUSHROOM", "HUGE_MUSHROOM_2"),
|
||||||
@ -882,6 +965,7 @@ public enum XMaterial {
|
|||||||
RED_WOOL(14, "WOOL"),
|
RED_WOOL(14, "WOOL"),
|
||||||
REPEATER("DIODE", "DIODE_BLOCK_ON", "DIODE_BLOCK_OFF"),
|
REPEATER("DIODE", "DIODE_BLOCK_ON", "DIODE_BLOCK_OFF"),
|
||||||
REPEATING_COMMAND_BLOCK("COMMAND", "COMMAND_REPEATING"),
|
REPEATING_COMMAND_BLOCK("COMMAND", "COMMAND_REPEATING"),
|
||||||
|
RESPAWN_ANCHOR("1.16"),
|
||||||
ROSE_BUSH(4, "DOUBLE_PLANT"),
|
ROSE_BUSH(4, "DOUBLE_PLANT"),
|
||||||
ROTTEN_FLESH,
|
ROTTEN_FLESH,
|
||||||
SADDLE,
|
SADDLE,
|
||||||
@ -901,6 +985,7 @@ public enum XMaterial {
|
|||||||
SHEARS,
|
SHEARS,
|
||||||
SHEEP_SPAWN_EGG(91, "MONSTER_EGG"),
|
SHEEP_SPAWN_EGG(91, "MONSTER_EGG"),
|
||||||
SHIELD,
|
SHIELD,
|
||||||
|
SHROOMLIGHT("1.16"),
|
||||||
SHULKER_BOX("PURPLE_SHULKER_BOX"),
|
SHULKER_BOX("PURPLE_SHULKER_BOX"),
|
||||||
SHULKER_SHELL,
|
SHULKER_SHELL,
|
||||||
SHULKER_SPAWN_EGG(69, "MONSTER_EGG"),
|
SHULKER_SPAWN_EGG(69, "MONSTER_EGG"),
|
||||||
@ -929,7 +1014,13 @@ public enum XMaterial {
|
|||||||
SNOW,
|
SNOW,
|
||||||
SNOWBALL("SNOW_BALL"),
|
SNOWBALL("SNOW_BALL"),
|
||||||
SNOW_BLOCK,
|
SNOW_BLOCK,
|
||||||
|
SOUL_CAMPFIRE("1.16"),
|
||||||
|
SOUL_FIRE("1.16"),
|
||||||
|
SOUL_LANTERN("1.16"),
|
||||||
SOUL_SAND,
|
SOUL_SAND,
|
||||||
|
SOUL_SOIL("1.16"),
|
||||||
|
SOUL_TORCH("1.16"),
|
||||||
|
SOUL_WALL_TORCH("1.16"),
|
||||||
SPAWNER("MOB_SPAWNER"),
|
SPAWNER("MOB_SPAWNER"),
|
||||||
SPECTRAL_ARROW("1.9", "ARROW", ""),
|
SPECTRAL_ARROW("1.9", "ARROW", ""),
|
||||||
SPIDER_EYE,
|
SPIDER_EYE,
|
||||||
@ -976,6 +1067,8 @@ public enum XMaterial {
|
|||||||
STRIPPED_ACACIA_WOOD("LOG_2"),
|
STRIPPED_ACACIA_WOOD("LOG_2"),
|
||||||
STRIPPED_BIRCH_LOG(2, "LOG"),
|
STRIPPED_BIRCH_LOG(2, "LOG"),
|
||||||
STRIPPED_BIRCH_WOOD(2, "LOG"),
|
STRIPPED_BIRCH_WOOD(2, "LOG"),
|
||||||
|
STRIPPED_CRIMSON_HYPHAE("1.16"),
|
||||||
|
STRIPPED_CRIMSON_STEM("1.16"),
|
||||||
STRIPPED_DARK_OAK_LOG("LOG"),
|
STRIPPED_DARK_OAK_LOG("LOG"),
|
||||||
STRIPPED_DARK_OAK_WOOD("LOG"),
|
STRIPPED_DARK_OAK_WOOD("LOG"),
|
||||||
STRIPPED_JUNGLE_LOG(3, "LOG"),
|
STRIPPED_JUNGLE_LOG(3, "LOG"),
|
||||||
@ -984,6 +1077,8 @@ public enum XMaterial {
|
|||||||
STRIPPED_OAK_WOOD("LOG"),
|
STRIPPED_OAK_WOOD("LOG"),
|
||||||
STRIPPED_SPRUCE_LOG(1, "LOG"),
|
STRIPPED_SPRUCE_LOG(1, "LOG"),
|
||||||
STRIPPED_SPRUCE_WOOD(1, "LOG"),
|
STRIPPED_SPRUCE_WOOD(1, "LOG"),
|
||||||
|
STRIPPED_WARPED_HYPHAE("1.16"),
|
||||||
|
STRIPPED_WARPED_STEM("1.16"),
|
||||||
STRUCTURE_BLOCK,
|
STRUCTURE_BLOCK,
|
||||||
/**
|
/**
|
||||||
* Originally developers used barrier blocks for its purpose.
|
* Originally developers used barrier blocks for its purpose.
|
||||||
@ -1002,6 +1097,7 @@ public enum XMaterial {
|
|||||||
SWEET_BERRY_BUSH("1.14", "GRASS", ""),
|
SWEET_BERRY_BUSH("1.14", "GRASS", ""),
|
||||||
TALL_GRASS(2, "DOUBLE_PLANT"),
|
TALL_GRASS(2, "DOUBLE_PLANT"),
|
||||||
TALL_SEAGRASS(2, "1.13", "TALL_GRASS", ""),
|
TALL_SEAGRASS(2, "1.13", "TALL_GRASS", ""),
|
||||||
|
TARGET("1.16"),
|
||||||
TERRACOTTA("HARD_CLAY"),
|
TERRACOTTA("HARD_CLAY"),
|
||||||
TIPPED_ARROW("1.9", "ARROW", ""),
|
TIPPED_ARROW("1.9", "ARROW", ""),
|
||||||
TNT,
|
TNT,
|
||||||
@ -1023,6 +1119,8 @@ public enum XMaterial {
|
|||||||
TURTLE_EGG("1.13", "EGG", ""),
|
TURTLE_EGG("1.13", "EGG", ""),
|
||||||
TURTLE_HELMET("1.13", "IRON_HELMET", ""),
|
TURTLE_HELMET("1.13", "IRON_HELMET", ""),
|
||||||
TURTLE_SPAWN_EGG("1.13", "CHICKEN_SPAWN_EGG", ""),
|
TURTLE_SPAWN_EGG("1.13", "CHICKEN_SPAWN_EGG", ""),
|
||||||
|
TWISTING_VINES("1.16"),
|
||||||
|
TWISTING_VINES_PLANT("1.16"),
|
||||||
VEX_SPAWN_EGG(35, "MONSTER_EGG"),
|
VEX_SPAWN_EGG(35, "MONSTER_EGG"),
|
||||||
VILLAGER_SPAWN_EGG(120, "MONSTER_EGG"),
|
VILLAGER_SPAWN_EGG(120, "MONSTER_EGG"),
|
||||||
VINDICATOR_SPAWN_EGG(36, "MONSTER_EGG"),
|
VINDICATOR_SPAWN_EGG(36, "MONSTER_EGG"),
|
||||||
@ -1035,6 +1133,24 @@ public enum XMaterial {
|
|||||||
VOID_AIR("AIR"),
|
VOID_AIR("AIR"),
|
||||||
WALL_TORCH("TORCH"),
|
WALL_TORCH("TORCH"),
|
||||||
WANDERING_TRADER_SPAWN_EGG("1.14", "VILLAGER_SPAWN_EGG", ""),
|
WANDERING_TRADER_SPAWN_EGG("1.14", "VILLAGER_SPAWN_EGG", ""),
|
||||||
|
WARPED_BUTTON("1.16"),
|
||||||
|
WARPED_DOOR("1.16"),
|
||||||
|
WARPED_FENCE("1.16"),
|
||||||
|
WARPED_FENCE_GATE("1.16"),
|
||||||
|
WARPED_FUNGUS("1.16"),
|
||||||
|
WARPED_FUNGUS_ON_A_STICK("1.16"),
|
||||||
|
WARPED_HYPHAE("1.16"),
|
||||||
|
WARPED_NYLIUM("1.16"),
|
||||||
|
WARPED_PLANKS("1.16"),
|
||||||
|
WARPED_PRESSURE_PLATE("1.16"),
|
||||||
|
WARPED_ROOTS("1.16"),
|
||||||
|
WARPED_SIGN("1.16"),
|
||||||
|
WARPED_SLAB("1.16"),
|
||||||
|
WARPED_STAIRS("1.16"),
|
||||||
|
WARPED_STEM("1.16"),
|
||||||
|
WARPED_TRAPDOOR("1.16"),
|
||||||
|
WARPED_WALL_SIGN("1.16"),
|
||||||
|
WARPED_WART_BLOCK("1.16"),
|
||||||
/**
|
/**
|
||||||
* This is used for blocks only.
|
* This is used for blocks only.
|
||||||
* In 1.13- WATER will turn into STATIONARY_WATER after it finished spreading.
|
* In 1.13- WATER will turn into STATIONARY_WATER after it finished spreading.
|
||||||
@ -1044,6 +1160,8 @@ public enum XMaterial {
|
|||||||
*/
|
*/
|
||||||
WATER("STATIONARY_WATER"),
|
WATER("STATIONARY_WATER"),
|
||||||
WATER_BUCKET,
|
WATER_BUCKET,
|
||||||
|
WEEPING_VINES("1.16"),
|
||||||
|
WEEPING_VINES_PLANT("1.16"),
|
||||||
WET_SPONGE(1, "SPONGE"),
|
WET_SPONGE(1, "SPONGE"),
|
||||||
/**
|
/**
|
||||||
* Wheat is a known material in pre-1.13
|
* Wheat is a known material in pre-1.13
|
||||||
@ -1052,16 +1170,16 @@ public enum XMaterial {
|
|||||||
WHEAT("CROPS"),
|
WHEAT("CROPS"),
|
||||||
WHEAT_SEEDS("SEEDS"),
|
WHEAT_SEEDS("SEEDS"),
|
||||||
WHITE_BANNER(15, "BANNER", "STANDING_BANNER"),
|
WHITE_BANNER(15, "BANNER", "STANDING_BANNER"),
|
||||||
WHITE_BED("BED", "BED_BLOCK"),
|
WHITE_BED("BED_BLOCK", "BED"),
|
||||||
WHITE_CARPET("CARPET"),
|
WHITE_CARPET("CARPET"),
|
||||||
WHITE_CONCRETE("CONCRETE"),
|
WHITE_CONCRETE("CONCRETE"),
|
||||||
WHITE_CONCRETE_POWDER("CONCRETE_POWDER"),
|
WHITE_CONCRETE_POWDER("CONCRETE_POWDER"),
|
||||||
WHITE_DYE(15, "1.14", "INK_SACK", "BONE_MEAL"),
|
WHITE_DYE(15, "1.14", "INK_SACK", "BONE_MEAL"),
|
||||||
WHITE_GLAZED_TERRACOTTA("1.12", "HARD_CLAY", "STAINED_CLAY", "WHITE_TERRACOTTA"),
|
WHITE_GLAZED_TERRACOTTA("1.12", "HARD_CLAY", "STAINED_CLAY"),
|
||||||
WHITE_SHULKER_BOX,
|
WHITE_SHULKER_BOX,
|
||||||
WHITE_STAINED_GLASS("STAINED_GLASS"),
|
WHITE_STAINED_GLASS("STAINED_GLASS"),
|
||||||
WHITE_STAINED_GLASS_PANE("THIN_GLASS", "STAINED_GLASS_PANE"),
|
WHITE_STAINED_GLASS_PANE("THIN_GLASS", "STAINED_GLASS_PANE"),
|
||||||
WHITE_TERRACOTTA("HARD_CLAY", "TERRACOTTA"),
|
WHITE_TERRACOTTA("HARD_CLAY", "STAINED_CLAY", "TERRACOTTA"),
|
||||||
WHITE_TULIP(6, "RED_ROSE"),
|
WHITE_TULIP(6, "RED_ROSE"),
|
||||||
WHITE_WALL_BANNER(15, "WALL_BANNER"),
|
WHITE_WALL_BANNER(15, "WALL_BANNER"),
|
||||||
WHITE_WOOL("WOOL"),
|
WHITE_WOOL("WOOL"),
|
||||||
@ -1079,7 +1197,7 @@ public enum XMaterial {
|
|||||||
WRITABLE_BOOK("BOOK_AND_QUILL"),
|
WRITABLE_BOOK("BOOK_AND_QUILL"),
|
||||||
WRITTEN_BOOK,
|
WRITTEN_BOOK,
|
||||||
YELLOW_BANNER(11, "BANNER", "STANDING_BANNER"),
|
YELLOW_BANNER(11, "BANNER", "STANDING_BANNER"),
|
||||||
YELLOW_BED(4, "BED", "BED_BLOCK"),
|
YELLOW_BED(4, "BED_BLOCK", "BED"),
|
||||||
YELLOW_CARPET(4, "CARPET"),
|
YELLOW_CARPET(4, "CARPET"),
|
||||||
YELLOW_CONCRETE(4, "CONCRETE"),
|
YELLOW_CONCRETE(4, "CONCRETE"),
|
||||||
YELLOW_CONCRETE_POWDER(4, "CONCRETE_POWDER"),
|
YELLOW_CONCRETE_POWDER(4, "CONCRETE_POWDER"),
|
||||||
@ -1096,7 +1214,8 @@ public enum XMaterial {
|
|||||||
ZOMBIE_PIGMAN_SPAWN_EGG(57, "MONSTER_EGG"),
|
ZOMBIE_PIGMAN_SPAWN_EGG(57, "MONSTER_EGG"),
|
||||||
ZOMBIE_SPAWN_EGG(54, "MONSTER_EGG"),
|
ZOMBIE_SPAWN_EGG(54, "MONSTER_EGG"),
|
||||||
ZOMBIE_VILLAGER_SPAWN_EGG(27, "MONSTER_EGG"),
|
ZOMBIE_VILLAGER_SPAWN_EGG(27, "MONSTER_EGG"),
|
||||||
ZOMBIE_WALL_HEAD(2, "SKULL", "SKULL_ITEM");
|
ZOMBIE_WALL_HEAD(2, "SKULL", "SKULL_ITEM"),
|
||||||
|
ZOMBIFIED_PIGLIN_SPAWN_EGG(54, "MONSTER_EGG");
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -1132,16 +1251,26 @@ public enum XMaterial {
|
|||||||
* @since 3.0.0
|
* @since 3.0.0
|
||||||
*/
|
*/
|
||||||
@SuppressWarnings("UnstableApiUsage")
|
@SuppressWarnings("UnstableApiUsage")
|
||||||
private static final ImmutableMap<XMaterial, XMaterial> DUPLICATED = Maps.immutableEnumMap(ImmutableMap.<XMaterial, XMaterial>builder()
|
private static final ImmutableMap<XMaterial, XMaterial> duplicated = Maps.immutableEnumMap(ImmutableMap.<XMaterial, XMaterial>builder()
|
||||||
.put(MELON, MELON_SLICE)
|
.put(MELON, MELON_SLICE)
|
||||||
.put(CARROT, CARROTS)
|
.put(CARROT, CARROTS)
|
||||||
.put(POTATO, POTATOES)
|
.put(POTATO, POTATOES)
|
||||||
.put(BEETROOT, BEETROOTS)
|
.put(BEETROOT, BEETROOTS)
|
||||||
.put(BROWN_MUSHROOM, BROWN_MUSHROOM_BLOCK)
|
.put(BROWN_MUSHROOM, BROWN_MUSHROOM_BLOCK)
|
||||||
.put(BRICK, BRICKS)
|
.put(BRICK, BRICKS)
|
||||||
.put(RED_MUSHROOM, RED_MUSHROOM_BLOCK)
|
|
||||||
.put(MAP, FILLED_MAP)
|
|
||||||
.put(NETHER_BRICK, NETHER_BRICKS)
|
.put(NETHER_BRICK, NETHER_BRICKS)
|
||||||
|
|
||||||
|
// Illegal Elements
|
||||||
|
// Since both 1.12 and 1.13 have <type>_DOOR XMaterial will use it
|
||||||
|
// for 1.12 to parse the material, but it needs <type>_DOOR_ITEM.
|
||||||
|
// We'll trick XMaterial into thinking this needs to be parsed
|
||||||
|
// using the old methods.
|
||||||
|
.put(DARK_OAK_DOOR, DARK_OAK_DOOR)
|
||||||
|
.put(ACACIA_DOOR, ACACIA_DOOR)
|
||||||
|
.put(BIRCH_DOOR, BIRCH_DOOR)
|
||||||
|
.put(JUNGLE_DOOR, JUNGLE_DOOR)
|
||||||
|
.put(SPRUCE_DOOR, SPRUCE_DOOR)
|
||||||
|
|
||||||
.build()
|
.build()
|
||||||
);
|
);
|
||||||
/*
|
/*
|
||||||
@ -1232,7 +1361,7 @@ public enum XMaterial {
|
|||||||
* An invocation of this method yields the cached result from the expression:
|
* An invocation of this method yields the cached result from the expression:
|
||||||
* <p>
|
* <p>
|
||||||
* <blockquote>
|
* <blockquote>
|
||||||
* {@link #supports(int 13)}}
|
* {@link #supports(int) 13}}
|
||||||
* </blockquote>
|
* </blockquote>
|
||||||
*
|
*
|
||||||
* @return true if 1.13 or higher.
|
* @return true if 1.13 or higher.
|
||||||
@ -1283,13 +1412,14 @@ public enum XMaterial {
|
|||||||
@Nullable
|
@Nullable
|
||||||
private static XMaterial requestOldXMaterial(@Nonnull String name, byte data) {
|
private static XMaterial requestOldXMaterial(@Nonnull String name, byte data) {
|
||||||
String holder = name + data;
|
String holder = name + data;
|
||||||
XMaterial material = NAME_CACHE.getIfPresent(holder);
|
XMaterial cache = NAME_CACHE.getIfPresent(holder);
|
||||||
if (material != null) return material;
|
if (cache != null) return cache;
|
||||||
|
|
||||||
for (XMaterial materials : VALUES) {
|
for (XMaterial material : VALUES) {
|
||||||
if ((data == -1 || data == materials.data) && materials.anyMatchLegacy(name)) {
|
// Not using material.name().equals(name) check is intended.
|
||||||
NAME_CACHE.put(holder, materials);
|
if ((data == -1 || data == material.data) && material.anyMatchLegacy(name)) {
|
||||||
return materials;
|
NAME_CACHE.put(holder, material);
|
||||||
|
return material;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -1320,37 +1450,15 @@ public enum XMaterial {
|
|||||||
/**
|
/**
|
||||||
* Parses the given material name as an XMaterial with unspecified data value.
|
* Parses the given material name as an XMaterial with unspecified data value.
|
||||||
*
|
*
|
||||||
* @see #matchXMaterial(String, byte)
|
* @see #matchXMaterialWithData(String)
|
||||||
* @since 2.0.0
|
* @since 2.0.0
|
||||||
*/
|
*/
|
||||||
@Nonnull
|
@Nonnull
|
||||||
public static Optional<XMaterial> matchXMaterial(@Nonnull String name) {
|
public static Optional<XMaterial> matchXMaterial(@Nonnull String name) {
|
||||||
return matchXMaterial(name, (byte) -1);
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Parses the given material name as an XMaterial.
|
|
||||||
* Can also be used like: <b>MATERIAL:DATA</b>
|
|
||||||
* <p>
|
|
||||||
* <b>Examples</b>
|
|
||||||
* <pre>
|
|
||||||
* INK_SACK:1 -> RED_DYE
|
|
||||||
* WOOL, 14 -> RED_WOOL
|
|
||||||
* </pre>
|
|
||||||
*
|
|
||||||
* @see #matchDefinedXMaterial(String, byte)
|
|
||||||
* @see #matchXMaterial(ItemStack)
|
|
||||||
* @since 2.0.0
|
|
||||||
*/
|
|
||||||
@Nonnull
|
|
||||||
public static Optional<XMaterial> matchXMaterial(@Nonnull String name, byte data) {
|
|
||||||
Validate.notEmpty(name, "Cannot match a material with null or empty material name");
|
Validate.notEmpty(name, "Cannot match a material with null or empty material name");
|
||||||
Optional<XMaterial> oldMatch = matchXMaterialWithData(name);
|
Optional<XMaterial> oldMatch = matchXMaterialWithData(name);
|
||||||
if (oldMatch.isPresent()) return oldMatch;
|
if (oldMatch.isPresent()) return oldMatch;
|
||||||
|
return matchDefinedXMaterial(format(name), (byte) -1);
|
||||||
// -1 Determines whether the item's data value is unknown and only the name is given.
|
|
||||||
// Checking if the item is damageable won't do anything as the data is not going to be checked in requestOldMaterial anyway.
|
|
||||||
return matchDefinedXMaterial(format(name), data);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -1360,8 +1468,8 @@ public enum XMaterial {
|
|||||||
* <p>
|
* <p>
|
||||||
* <b>Examples</b>
|
* <b>Examples</b>
|
||||||
* <p><pre>
|
* <p><pre>
|
||||||
* INK_SACK:1 -> RED_DYE
|
* {@code INK_SACK:1 -> RED_DYE}
|
||||||
* WOOL, 14 -> RED_WOOL
|
* {@code WOOL, 14 -> RED_WOOL}
|
||||||
* </pre>
|
* </pre>
|
||||||
*
|
*
|
||||||
* @param name the material string that consists of the material name, data and separator character.
|
* @param name the material string that consists of the material name, data and separator character.
|
||||||
@ -1394,7 +1502,7 @@ public enum XMaterial {
|
|||||||
public static XMaterial matchXMaterial(@Nonnull Material material) {
|
public static XMaterial matchXMaterial(@Nonnull Material material) {
|
||||||
Objects.requireNonNull(material, "Cannot match null material");
|
Objects.requireNonNull(material, "Cannot match null material");
|
||||||
return matchDefinedXMaterial(material.name(), (byte) -1)
|
return matchDefinedXMaterial(material.name(), (byte) -1)
|
||||||
.orElseThrow(() -> new IllegalArgumentException("Unsupported Material: " + material));
|
.orElseThrow(() -> new IllegalArgumentException("Unsupported Material With No Bytes: " + material.name()));
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -1411,9 +1519,10 @@ public enum XMaterial {
|
|||||||
public static XMaterial matchXMaterial(@Nonnull ItemStack item) {
|
public static XMaterial matchXMaterial(@Nonnull ItemStack item) {
|
||||||
Objects.requireNonNull(item, "Cannot match null ItemStack");
|
Objects.requireNonNull(item, "Cannot match null ItemStack");
|
||||||
String material = item.getType().name();
|
String material = item.getType().name();
|
||||||
return matchDefinedXMaterial(material,
|
byte data = (byte) (ISFLAT || isDamageable(material) ? 0 : item.getDurability());
|
||||||
isDamageable(material) ? (byte) 0 : (byte) item.getDurability())
|
|
||||||
.orElseThrow(() -> new IllegalArgumentException("Unsupported Material: " + material));
|
return matchDefinedXMaterial(material, data)
|
||||||
|
.orElseThrow(() -> new IllegalArgumentException("Unsupported Material: " + material + " (" + data + ')'));
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -1423,7 +1532,6 @@ public enum XMaterial {
|
|||||||
* @param name the formatted name of the material.
|
* @param name the formatted name of the material.
|
||||||
* @param data the data value of the material.
|
* @param data the data value of the material.
|
||||||
* @return an XMaterial (with the same data value if specified)
|
* @return an XMaterial (with the same data value if specified)
|
||||||
* @see #matchXMaterial(String, byte)
|
|
||||||
* @see #matchXMaterial(Material)
|
* @see #matchXMaterial(Material)
|
||||||
* @see #matchXMaterial(int, byte)
|
* @see #matchXMaterial(int, byte)
|
||||||
* @see #matchXMaterial(ItemStack)
|
* @see #matchXMaterial(ItemStack)
|
||||||
@ -1436,7 +1544,7 @@ public enum XMaterial {
|
|||||||
// Do basic number and boolean checks before accessing more complex enum stuff.
|
// Do basic number and boolean checks before accessing more complex enum stuff.
|
||||||
// Maybe we can simplify (ISFLAT || !duplicated) with the (!ISFLAT && duplicated) under it to save a few nanoseconds?
|
// Maybe we can simplify (ISFLAT || !duplicated) with the (!ISFLAT && duplicated) under it to save a few nanoseconds?
|
||||||
// if (!Boolean.valueOf(Boolean.getBoolean(Boolean.TRUE.toString())).equals(Boolean.FALSE.booleanValue())) return null;
|
// if (!Boolean.valueOf(Boolean.getBoolean(Boolean.TRUE.toString())).equals(Boolean.FALSE.booleanValue())) return null;
|
||||||
if (data <= 0 && (ISFLAT || !duplicated)) {
|
if (data <= 0 && !duplicated) {
|
||||||
// Apparently the transform method is more efficient than toJavaUtil()
|
// Apparently the transform method is more efficient than toJavaUtil()
|
||||||
// toJavaUtil isn't even supported in older versions.
|
// toJavaUtil isn't even supported in older versions.
|
||||||
Optional<XMaterial> xMat = Enums.getIfPresent(XMaterial.class, name).transform(Optional::of).or(Optional.empty());
|
Optional<XMaterial> xMat = Enums.getIfPresent(XMaterial.class, name).transform(Optional::of).or(Optional.empty());
|
||||||
@ -1447,8 +1555,20 @@ public enum XMaterial {
|
|||||||
// I've concluded that this is just an infinite loop that keeps
|
// I've concluded that this is just an infinite loop that keeps
|
||||||
// going around the Singular Form and the Plural Form materials. A waste of brain cells and a waste of time.
|
// going around the Singular Form and the Plural Form materials. A waste of brain cells and a waste of time.
|
||||||
// This solution works just fine anyway.
|
// This solution works just fine anyway.
|
||||||
if (!ISFLAT && duplicated) return Optional.ofNullable(requestDuplicatedXMaterial(name, data));
|
XMaterial xMat = requestOldXMaterial(name, data);
|
||||||
return Optional.ofNullable(requestOldXMaterial(name, data));
|
if (xMat == null) {
|
||||||
|
// Special case. Refer to FILLED_MAP for more info.
|
||||||
|
if (data > 0 && name.endsWith("MAP")) return Optional.of(FILLED_MAP);
|
||||||
|
return Optional.empty();
|
||||||
|
}
|
||||||
|
|
||||||
|
if (!ISFLAT && duplicated && xMat.name().charAt(xMat.name().length() - 1) == 'S') {
|
||||||
|
// A solution for XMaterial Paradox.
|
||||||
|
// Manually parses the duplicated materials to find the exact material based on the server version.
|
||||||
|
// If ends with "S" -> Plural Form Material
|
||||||
|
return Enums.getIfPresent(XMaterial.class, name).transform(Optional::of).or(Optional.empty());
|
||||||
|
}
|
||||||
|
return Optional.ofNullable(xMat);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -1463,13 +1583,12 @@ public enum XMaterial {
|
|||||||
* @see #isDuplicated()
|
* @see #isDuplicated()
|
||||||
* @since 2.0.0
|
* @since 2.0.0
|
||||||
*/
|
*/
|
||||||
public static boolean isDuplicated(@Nonnull String name) {
|
private static boolean isDuplicated(@Nonnull String name) {
|
||||||
Validate.notEmpty(name, "Cannot check duplication for null or empty material name");
|
|
||||||
name = format(name);
|
|
||||||
|
|
||||||
// Don't use matchXMaterial() since this method is being called from matchXMaterial() itself and will cause a StackOverflowError.
|
// Don't use matchXMaterial() since this method is being called from matchXMaterial() itself and will cause a StackOverflowError.
|
||||||
for (Map.Entry<XMaterial, XMaterial> duplicated : DUPLICATED.entrySet())
|
for (Map.Entry<XMaterial, XMaterial> duplicated : duplicated.entrySet()) {
|
||||||
if (duplicated.getKey().name().equals(name) || duplicated.getKey().anyMatchLegacy(name)) return true;
|
XMaterial material = duplicated.getKey();
|
||||||
|
if (material.name().equals(name) || material.anyMatchLegacy(name)) return true;
|
||||||
|
}
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -1493,60 +1612,6 @@ public enum XMaterial {
|
|||||||
return Optional.empty();
|
return Optional.empty();
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
|
||||||
* A solution for <b>XMaterial Paradox</b>.
|
|
||||||
* Manually parses the duplicated materials to find the exact material based on the server version.
|
|
||||||
*
|
|
||||||
* @param name the name of the material.
|
|
||||||
* @return the duplicated XMaterial based on the version.
|
|
||||||
* @throws IllegalArgumentException may be thrown. If thrown, it's a bug.
|
|
||||||
* @since 2.0.0
|
|
||||||
*/
|
|
||||||
@Nullable
|
|
||||||
private static XMaterial requestDuplicatedXMaterial(@Nonnull String name, byte data) {
|
|
||||||
XMaterial mat = requestOldXMaterial(name, data);
|
|
||||||
// If ends with "S" -> Plural Form Material
|
|
||||||
return mat.name().charAt(mat.name().length() - 1) == 'S' ? Enums.getIfPresent(XMaterial.class, name).orNull() : mat;
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Always returns the value with the given duplicated material key name.
|
|
||||||
*
|
|
||||||
* @param name the name of the material.
|
|
||||||
* @return the new XMaterial of this duplicated material.
|
|
||||||
* @see #getXMaterialIfDuplicated(String)
|
|
||||||
* @since 2.0.0
|
|
||||||
*/
|
|
||||||
@Nonnull
|
|
||||||
public static Optional<XMaterial> getNewXMaterialIfDuplicated(@Nonnull String name) {
|
|
||||||
Validate.notEmpty(name, "Cannot get new duplicated material for null or empty material name");
|
|
||||||
name = format(name);
|
|
||||||
|
|
||||||
for (Map.Entry<XMaterial, XMaterial> duplicated : DUPLICATED.entrySet())
|
|
||||||
if (duplicated.getKey().name().equals(name)) return Optional.of(duplicated.getKey());
|
|
||||||
return Optional.empty();
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Checks if the item is duplicated for a different purpose in new versions from {@link #DUPLICATED}.
|
|
||||||
*
|
|
||||||
* @param name the name of the material.
|
|
||||||
* @return the other XMaterial (key or value) of the XMaterial (key or value).
|
|
||||||
* @see #matchXMaterial(String, byte)
|
|
||||||
* @since 2.0.0
|
|
||||||
*/
|
|
||||||
@Nullable
|
|
||||||
public static XMaterial getXMaterialIfDuplicated(@Nonnull String name) {
|
|
||||||
Validate.notEmpty(name, "Cannot get duplicated material for null or empty material name");
|
|
||||||
name = format(name);
|
|
||||||
|
|
||||||
for (Map.Entry<XMaterial, XMaterial> duplicated : DUPLICATED.entrySet())
|
|
||||||
if (duplicated.getKey().name().equals(name)) return duplicated.getValue();
|
|
||||||
else if (duplicated.getValue().name().equals(name)) return duplicated.getKey();
|
|
||||||
|
|
||||||
return null;
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Attempts to build the string like an enum name.
|
* Attempts to build the string like an enum name.
|
||||||
* Removes all the spaces, numbers and extra non-English characters. Also removes some config/in-game based strings.
|
* Removes all the spaces, numbers and extra non-English characters. Also removes some config/in-game based strings.
|
||||||
@ -1564,7 +1629,7 @@ public enum XMaterial {
|
|||||||
/**
|
/**
|
||||||
* Checks if the specified version is the same version or higher than the current server version.
|
* Checks if the specified version is the same version or higher than the current server version.
|
||||||
*
|
*
|
||||||
* @param version the major version to be checked. "1." is ignored -> 1.12 = 12 | 1.9 = 9
|
* @param version the major version to be checked. "1." is ignored. E.g. 1.12 = 12 | 1.9 = 9
|
||||||
* @return true of the version is equal or higher than the current version.
|
* @return true of the version is equal or higher than the current version.
|
||||||
* @since 2.0.0
|
* @since 2.0.0
|
||||||
*/
|
*/
|
||||||
@ -1663,14 +1728,14 @@ public enum XMaterial {
|
|||||||
* <br>
|
* <br>
|
||||||
* <b>{@code CONTAINS} Examples:</b>
|
* <b>{@code CONTAINS} Examples:</b>
|
||||||
* <pre>
|
* <pre>
|
||||||
* "CONTAINS:CHEST" -> CHEST, ENDERCHEST, TRAPPED_CHEST -> true
|
* {@code "CONTAINS:CHEST" -> CHEST, ENDERCHEST, TRAPPED_CHEST -> true}
|
||||||
* "cOnTaINS:dYe" -> GREEN_DYE, YELLOW_DYE, BLUE_DYE, INK_SACK -> true
|
* {@code "cOnTaINS:dYe" -> GREEN_DYE, YELLOW_DYE, BLUE_DYE, INK_SACK -> true}
|
||||||
* </pre>
|
* </pre>
|
||||||
* <p>
|
* <p>
|
||||||
* <b>{@code REGEX} Examples</b>
|
* <b>{@code REGEX} Examples</b>
|
||||||
* <pre>
|
* <pre>
|
||||||
* "REGEX:^.+_.+_.+$" -> Every Material with 3 underlines or more: SHULKER_SPAWN_EGG, SILVERFISH_SPAWN_EGG, SKELETON_HORSE_SPAWN_EGG
|
* {@code "REGEX:^.+_.+_.+$" -> Every Material with 3 underlines or more: SHULKER_SPAWN_EGG, SILVERFISH_SPAWN_EGG, SKELETON_HORSE_SPAWN_EGG}
|
||||||
* "REGEX:^.{1,3}$" -> Material names that have 3 letters only: BED, MAP, AIR
|
* {@code "REGEX:^.{1,3}$" -> Material names that have 3 letters only: BED, MAP, AIR}
|
||||||
* </pre>
|
* </pre>
|
||||||
* <p>
|
* <p>
|
||||||
* The reason that there are tags for {@code CONTAINS} and {@code REGEX}
|
* The reason that there are tags for {@code CONTAINS} and {@code REGEX}
|
||||||
@ -1803,8 +1868,7 @@ public enum XMaterial {
|
|||||||
*/
|
*/
|
||||||
@SuppressWarnings("deprecation")
|
@SuppressWarnings("deprecation")
|
||||||
public int getId() {
|
public int getId() {
|
||||||
if (this.data != 0 || (this.legacy.length != 0 && Integer.parseInt(this.legacy[0].substring(2)) >= 13))
|
if (this.data != 0 || (this.legacy.length != 0 && Integer.parseInt(this.legacy[0].substring(2)) >= 13)) return -1;
|
||||||
return -1;
|
|
||||||
Material material = this.parseMaterial();
|
Material material = this.parseMaterial();
|
||||||
return material == null ? -1 : material.getId();
|
return material == null ? -1 : material.getId();
|
||||||
}
|
}
|
||||||
@ -1813,25 +1877,11 @@ public enum XMaterial {
|
|||||||
* Checks if the material has any duplicates.
|
* Checks if the material has any duplicates.
|
||||||
*
|
*
|
||||||
* @return true if there is a duplicated name for this material, otherwise false.
|
* @return true if there is a duplicated name for this material, otherwise false.
|
||||||
* @see #getXMaterialIfDuplicated()
|
|
||||||
* @see #isDuplicated(String)
|
* @see #isDuplicated(String)
|
||||||
* @since 2.0.0
|
* @since 2.0.0
|
||||||
*/
|
*/
|
||||||
public boolean isDuplicated() {
|
public boolean isDuplicated() {
|
||||||
return DUPLICATED.containsKey(this);
|
return duplicated.containsKey(this);
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Checks if the item is duplicated for a different purpose in new versions.
|
|
||||||
*
|
|
||||||
* @return true if the item's name is duplicated, otherwise false.
|
|
||||||
* @see #isDuplicated()
|
|
||||||
* @see #getNewXMaterialIfDuplicated(String)
|
|
||||||
* @since 2.0.0
|
|
||||||
*/
|
|
||||||
@Nullable
|
|
||||||
public XMaterial getXMaterialIfDuplicated() {
|
|
||||||
return DUPLICATED.get(this);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -1891,7 +1941,7 @@ public enum XMaterial {
|
|||||||
* Parses an item from this XMaterial.
|
* Parses an item from this XMaterial.
|
||||||
* Uses data values on older versions.
|
* Uses data values on older versions.
|
||||||
*
|
*
|
||||||
* @param suggest if true {@link #parseMaterial(boolean true)} will be used.
|
* @param suggest if true {@link #parseMaterial(boolean)} true will be used.
|
||||||
* @return an ItemStack with the same material (and data value if in older versions.)
|
* @return an ItemStack with the same material (and data value if in older versions.)
|
||||||
* @see #setType(ItemStack)
|
* @see #setType(ItemStack)
|
||||||
* @since 2.0.0
|
* @since 2.0.0
|
||||||
@ -1921,7 +1971,6 @@ public enum XMaterial {
|
|||||||
*
|
*
|
||||||
* @param suggest use a suggested material (from older materials) if the material is added in a later version of Minecraft.
|
* @param suggest use a suggested material (from older materials) if the material is added in a later version of Minecraft.
|
||||||
* @return the material related to this XMaterial based on the server version.
|
* @return the material related to this XMaterial based on the server version.
|
||||||
* @see #matchXMaterial(String, byte)
|
|
||||||
* @since 2.0.0
|
* @since 2.0.0
|
||||||
*/
|
*/
|
||||||
@SuppressWarnings("OptionalAssignedToNull")
|
@SuppressWarnings("OptionalAssignedToNull")
|
||||||
|
@ -1,12 +1,5 @@
|
|||||||
package com.massivecraft.factions.util.timer;
|
package com.massivecraft.factions.util.timer;
|
||||||
|
|
||||||
import com.massivecraft.factions.util.Config;
|
|
||||||
|
|
||||||
import java.util.LinkedHashMap;
|
|
||||||
import java.util.Map;
|
|
||||||
import java.util.Set;
|
|
||||||
import java.util.UUID;
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Factions - Developed by Driftay.
|
* Factions - Developed by Driftay.
|
||||||
* All rights reserved 2020.
|
* All rights reserved 2020.
|
||||||
|
@ -8,8 +8,8 @@ import com.massivecraft.factions.util.Config;
|
|||||||
* Creation Date: 4/7/2020
|
* Creation Date: 4/7/2020
|
||||||
*/
|
*/
|
||||||
public abstract class Timer {
|
public abstract class Timer {
|
||||||
protected final String name;
|
|
||||||
public final long defaultCooldown;
|
public final long defaultCooldown;
|
||||||
|
protected final String name;
|
||||||
|
|
||||||
|
|
||||||
public Timer(String name, long defaultCooldown) {
|
public Timer(String name, long defaultCooldown) {
|
||||||
|
@ -16,14 +16,24 @@ import java.util.concurrent.TimeUnit;
|
|||||||
* Creation Date: 4/7/2020
|
* Creation Date: 4/7/2020
|
||||||
*/
|
*/
|
||||||
public class TimerManager implements Listener, Runnable {
|
public class TimerManager implements Listener, Runnable {
|
||||||
private final Set<Timer> timers;
|
|
||||||
private final FactionsPlugin plugin;
|
|
||||||
private final List<TimerRunnable> timerRunnableList = new ArrayList<>();
|
|
||||||
private Config config;
|
|
||||||
public GraceTimer graceTimer;
|
|
||||||
private static final long MINUTE = TimeUnit.MINUTES.toMillis(1L);
|
private static final long MINUTE = TimeUnit.MINUTES.toMillis(1L);
|
||||||
private static final long HOUR = TimeUnit.HOURS.toMillis(1L);
|
private static final long HOUR = TimeUnit.HOURS.toMillis(1L);
|
||||||
private static final long MULTI_HOUR = TimeUnit.HOURS.toMillis(10);
|
private static final long MULTI_HOUR = TimeUnit.HOURS.toMillis(10);
|
||||||
|
private final Set<Timer> timers;
|
||||||
|
private final FactionsPlugin plugin;
|
||||||
|
private final List<TimerRunnable> timerRunnableList = new ArrayList<>();
|
||||||
|
public GraceTimer graceTimer;
|
||||||
|
private Config config;
|
||||||
|
|
||||||
|
public TimerManager(FactionsPlugin plugin) {
|
||||||
|
this.timers = new HashSet<>();
|
||||||
|
this.plugin = plugin;
|
||||||
|
plugin.getServer().getPluginManager().registerEvents(this, plugin);
|
||||||
|
if (Conf.useGraceSystem) {
|
||||||
|
this.registerTimer(this.graceTimer = new GraceTimer());
|
||||||
|
}
|
||||||
|
plugin.getServer().getScheduler().runTaskTimer(plugin, this, 4, 4);
|
||||||
|
}
|
||||||
|
|
||||||
public static String getRemaining(long millis, boolean milliseconds) {
|
public static String getRemaining(long millis, boolean milliseconds) {
|
||||||
return getRemaining(millis, milliseconds, true);
|
return getRemaining(millis, milliseconds, true);
|
||||||
@ -31,21 +41,11 @@ public class TimerManager implements Listener, Runnable {
|
|||||||
|
|
||||||
public static String getRemaining(long duration, boolean milliseconds, boolean trail) {
|
public static String getRemaining(long duration, boolean milliseconds, boolean trail) {
|
||||||
if ((milliseconds) && (duration < MINUTE)) {
|
if ((milliseconds) && (duration < MINUTE)) {
|
||||||
return ( (trail ? DateTimeFormats.REMAINING_SECONDS_TRAILING : DateTimeFormats.REMAINING_SECONDS).get()).format(duration * 0.001D) + 's';
|
return ((trail ? DateTimeFormats.REMAINING_SECONDS_TRAILING : DateTimeFormats.REMAINING_SECONDS).get()).format(duration * 0.001D) + 's';
|
||||||
}
|
}
|
||||||
return DurationFormatUtils.formatDuration(duration, (duration >= HOUR ? (duration >= MULTI_HOUR ? "d" : "") + "d:" : "") + "HH:mm:ss");
|
return DurationFormatUtils.formatDuration(duration, (duration >= HOUR ? (duration >= MULTI_HOUR ? "d" : "") + "d:" : "") + "HH:mm:ss");
|
||||||
}
|
}
|
||||||
|
|
||||||
public TimerManager(FactionsPlugin plugin) {
|
|
||||||
this.timers = new HashSet<>();
|
|
||||||
this.plugin = plugin;
|
|
||||||
plugin.getServer().getPluginManager().registerEvents(this, plugin);
|
|
||||||
if(Conf.useGraceSystem) {
|
|
||||||
this.registerTimer(this.graceTimer = new GraceTimer());
|
|
||||||
}
|
|
||||||
plugin.getServer().getScheduler().runTaskTimer(plugin, this, 4, 4);
|
|
||||||
}
|
|
||||||
|
|
||||||
public Collection<Timer> getTimers() {
|
public Collection<Timer> getTimers() {
|
||||||
return this.timers;
|
return this.timers;
|
||||||
}
|
}
|
||||||
|
@ -25,6 +25,13 @@ public class TimerRunnable {
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
public TimerRunnable(UUID playerUUID, Timer timer, long duration) {
|
||||||
|
this.timer = timer;
|
||||||
|
setRemaining(duration);
|
||||||
|
FactionsPlugin plugin = FactionsPlugin.getInstance();
|
||||||
|
plugin.getTimerManager().getTimerRunnableList().add(this);
|
||||||
|
}
|
||||||
|
|
||||||
public boolean isCancelled() {
|
public boolean isCancelled() {
|
||||||
return cancelled;
|
return cancelled;
|
||||||
}
|
}
|
||||||
@ -38,15 +45,13 @@ public class TimerRunnable {
|
|||||||
return getRemaining(false);
|
return getRemaining(false);
|
||||||
}
|
}
|
||||||
|
|
||||||
public long getRemaining(long now) {
|
|
||||||
return getRemaining(false, now);
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
public void setRemaining(long remaining) {
|
public void setRemaining(long remaining) {
|
||||||
setExpiryMillis(remaining);
|
setExpiryMillis(remaining);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public long getRemaining(long now) {
|
||||||
|
return getRemaining(false, now);
|
||||||
|
}
|
||||||
|
|
||||||
public long getRemaining(boolean ignorePaused) {
|
public long getRemaining(boolean ignorePaused) {
|
||||||
if ((!ignorePaused) && (this.pauseMillis != 0L)) return this.pauseMillis;
|
if ((!ignorePaused) && (this.pauseMillis != 0L)) return this.pauseMillis;
|
||||||
|
@ -26,20 +26,22 @@ public class GraceTimer extends GlobalTimer implements Listener {
|
|||||||
|
|
||||||
@EventHandler
|
@EventHandler
|
||||||
public void onBreak(EntityExplodeEvent e) {
|
public void onBreak(EntityExplodeEvent e) {
|
||||||
if (getRemaining() > 0) {
|
if (getRemaining() > 0)
|
||||||
e.setCancelled(true);
|
e.setCancelled(true);
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@EventHandler
|
@EventHandler
|
||||||
public void onTNTPlace(BlockPlaceEvent event) {
|
public void onTNTPlace(BlockPlaceEvent event) {
|
||||||
FPlayer fp = FPlayers.getInstance().getByPlayer(event.getPlayer());
|
FPlayer fp = FPlayers.getInstance().getByPlayer(event.getPlayer());
|
||||||
if (getRemaining() > 0 && !fp.isAdminBypassing() && event.getBlock().getType().equals(Material.TNT)) {
|
if (getRemaining() > 0) {
|
||||||
event.setCancelled(true);
|
if (!fp.isAdminBypassing()) {
|
||||||
|
if (event.getBlock().getType().equals(Material.TNT)) {
|
||||||
|
event.setCancelled(true);
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void load(Config config) {
|
public void load(Config config) {
|
||||||
setPaused(config.getBoolean(this.name + ".paused"));
|
setPaused(config.getBoolean(this.name + ".paused"));
|
||||||
|
@ -3,7 +3,10 @@ package com.massivecraft.factions.zcore;
|
|||||||
import com.google.gson.Gson;
|
import com.google.gson.Gson;
|
||||||
import com.google.gson.GsonBuilder;
|
import com.google.gson.GsonBuilder;
|
||||||
import com.google.gson.reflect.TypeToken;
|
import com.google.gson.reflect.TypeToken;
|
||||||
import com.massivecraft.factions.*;
|
import com.massivecraft.factions.Board;
|
||||||
|
import com.massivecraft.factions.Conf;
|
||||||
|
import com.massivecraft.factions.FPlayers;
|
||||||
|
import com.massivecraft.factions.Factions;
|
||||||
import com.massivecraft.factions.zcore.persist.SaveTask;
|
import com.massivecraft.factions.zcore.persist.SaveTask;
|
||||||
import com.massivecraft.factions.zcore.util.PermUtil;
|
import com.massivecraft.factions.zcore.util.PermUtil;
|
||||||
import com.massivecraft.factions.zcore.util.Persist;
|
import com.massivecraft.factions.zcore.util.Persist;
|
||||||
|
@ -56,6 +56,10 @@ public class CustomFile {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public boolean containsKey(String key) {
|
||||||
|
return getCachedObjects().containsKey(key) || getConfig().contains(key);
|
||||||
|
}
|
||||||
|
|
||||||
public String fetchString(String key) {
|
public String fetchString(String key) {
|
||||||
return (String) getObj(key, dataTypes.STRING);
|
return (String) getObj(key, dataTypes.STRING);
|
||||||
}
|
}
|
||||||
|
@ -6,13 +6,11 @@ import com.github.stefvanschie.inventoryframework.pane.PaginatedPane;
|
|||||||
import com.massivecraft.factions.FPlayer;
|
import com.massivecraft.factions.FPlayer;
|
||||||
import com.massivecraft.factions.Faction;
|
import com.massivecraft.factions.Faction;
|
||||||
import com.massivecraft.factions.FactionsPlugin;
|
import com.massivecraft.factions.FactionsPlugin;
|
||||||
import com.massivecraft.factions.cmd.audit.FLogType;
|
|
||||||
import com.massivecraft.factions.util.XMaterial;
|
import com.massivecraft.factions.util.XMaterial;
|
||||||
import com.massivecraft.factions.zcore.fperms.Access;
|
import com.massivecraft.factions.zcore.fperms.Access;
|
||||||
import com.massivecraft.factions.zcore.fperms.Permissable;
|
import com.massivecraft.factions.zcore.fperms.Permissable;
|
||||||
import com.massivecraft.factions.zcore.fperms.PermissableAction;
|
import com.massivecraft.factions.zcore.fperms.PermissableAction;
|
||||||
import com.massivecraft.factions.zcore.util.TL;
|
import com.massivecraft.factions.zcore.util.TL;
|
||||||
import org.bukkit.ChatColor;
|
|
||||||
import org.bukkit.configuration.ConfigurationSection;
|
import org.bukkit.configuration.ConfigurationSection;
|
||||||
import org.bukkit.inventory.ItemStack;
|
import org.bukkit.inventory.ItemStack;
|
||||||
import org.bukkit.inventory.meta.ItemMeta;
|
import org.bukkit.inventory.meta.ItemMeta;
|
||||||
|
@ -16,7 +16,6 @@ import org.bukkit.inventory.meta.ItemMeta;
|
|||||||
|
|
||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
import java.util.Objects;
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @author Saser
|
* @author Saser
|
||||||
@ -36,7 +35,8 @@ public class FUpgradeFrame {
|
|||||||
PaginatedPane pane = new PaginatedPane(0, 0, 9, this.gui.getRows());
|
PaginatedPane pane = new PaginatedPane(0, 0, 9, this.gui.getRows());
|
||||||
List<GuiItem> GUIItems = new ArrayList<>();
|
List<GuiItem> GUIItems = new ArrayList<>();
|
||||||
ItemStack dummy = buildDummyItem();
|
ItemStack dummy = buildDummyItem();
|
||||||
for (int x = 0; x <= this.gui.getRows() * 9 - 1; ++x) GUIItems.add(new GuiItem(dummy, e -> e.setCancelled(true)));
|
for (int x = 0; x <= this.gui.getRows() * 9 - 1; ++x)
|
||||||
|
GUIItems.add(new GuiItem(dummy, e -> e.setCancelled(true)));
|
||||||
for (UpgradeType value : UpgradeType.values()) {
|
for (UpgradeType value : UpgradeType.values()) {
|
||||||
if (value.getSlot() != -1) {
|
if (value.getSlot() != -1) {
|
||||||
GUIItems.set(value.getSlot(), new GuiItem(value.buildAsset(fplayer.getFaction()), e -> {
|
GUIItems.set(value.getSlot(), new GuiItem(value.buildAsset(fplayer.getFaction()), e -> {
|
||||||
@ -44,19 +44,19 @@ public class FUpgradeFrame {
|
|||||||
FPlayer fme = FPlayers.getInstance().getByPlayer((Player) e.getWhoClicked());
|
FPlayer fme = FPlayers.getInstance().getByPlayer((Player) e.getWhoClicked());
|
||||||
if (fme.getFaction().getUpgrade(value) == value.getMaxLevel()) return;
|
if (fme.getFaction().getUpgrade(value) == value.getMaxLevel()) return;
|
||||||
int cost = FactionsPlugin.getInstance().getConfig().getInt("fupgrades.MainMenu." + value.toString() + ".Cost.level-" + (fme.getFaction().getUpgrade(value) + 1));
|
int cost = FactionsPlugin.getInstance().getConfig().getInt("fupgrades.MainMenu." + value.toString() + ".Cost.level-" + (fme.getFaction().getUpgrade(value) + 1));
|
||||||
if (fme.hasMoney(cost)) {
|
if (fme.hasMoney(cost)) {
|
||||||
fme.takeMoney(cost);
|
fme.takeMoney(cost);
|
||||||
if (value == UpgradeType.CHEST) updateChests(fme.getFaction());
|
if (value == UpgradeType.CHEST) updateChests(fme.getFaction());
|
||||||
|
|
||||||
if (value == UpgradeType.POWER) updateFactionPowerBoost(fme.getFaction());
|
if (value == UpgradeType.POWER) updateFactionPowerBoost(fme.getFaction());
|
||||||
|
|
||||||
if (value == UpgradeType.TNT) updateTNT(fme.getFaction());
|
if (value == UpgradeType.TNT) updateTNT(fme.getFaction());
|
||||||
|
|
||||||
if (value == UpgradeType.WARP) updateWarps(fme.getFaction());
|
if (value == UpgradeType.WARP) updateWarps(fme.getFaction());
|
||||||
|
|
||||||
fme.getFaction().setUpgrade(value, fme.getFaction().getUpgrade(value) + 1);
|
fme.getFaction().setUpgrade(value, fme.getFaction().getUpgrade(value) + 1);
|
||||||
buildGUI(fme);
|
buildGUI(fme);
|
||||||
}
|
}
|
||||||
}));
|
}));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -28,7 +28,7 @@ public class UpgradesListener implements Listener {
|
|||||||
if (e.isCancelled()) return;
|
if (e.isCancelled()) return;
|
||||||
|
|
||||||
if (!(e.getDamager() instanceof Player) || !(e.getEntity() instanceof Player)) return;
|
if (!(e.getDamager() instanceof Player) || !(e.getEntity() instanceof Player)) return;
|
||||||
if(e.getEntity() == null) return;
|
if (e.getEntity() == null) return;
|
||||||
|
|
||||||
FPlayer fme = FPlayers.getInstance().getByPlayer((Player) e.getEntity());
|
FPlayer fme = FPlayers.getInstance().getByPlayer((Player) e.getEntity());
|
||||||
FPlayer dame = FPlayers.getInstance().getByPlayer((Player) e.getDamager());
|
FPlayer dame = FPlayers.getInstance().getByPlayer((Player) e.getDamager());
|
||||||
@ -36,7 +36,7 @@ public class UpgradesListener implements Listener {
|
|||||||
if (fme == null || dame == null) return;
|
if (fme == null || dame == null) return;
|
||||||
FLocation floc = new FLocation(fme.getPlayer().getLocation());
|
FLocation floc = new FLocation(fme.getPlayer().getLocation());
|
||||||
|
|
||||||
if(floc == null) return;
|
if (floc == null) return;
|
||||||
|
|
||||||
if (Board.getInstance().getFactionAt(floc) == fme.getFaction()) {
|
if (Board.getInstance().getFactionAt(floc) == fme.getFaction()) {
|
||||||
if (dame.getFaction() == fme.getFaction()) return;
|
if (dame.getFaction() == fme.getFaction()) return;
|
||||||
|
@ -738,7 +738,7 @@ public abstract class MemoryFPlayer implements FPlayer {
|
|||||||
public void sendFactionHereMessage(Faction from) {
|
public void sendFactionHereMessage(Faction from) {
|
||||||
Faction toShow = Board.getInstance().getFactionAt(getLastStoodAt());
|
Faction toShow = Board.getInstance().getFactionAt(getLastStoodAt());
|
||||||
|
|
||||||
if(Conf.worldsNoClaiming.contains(getLastStoodAt().getWorldName())) return;
|
if (Conf.worldsNoClaiming.contains(getLastStoodAt().getWorldName())) return;
|
||||||
|
|
||||||
if (showInfoBoard(toShow)) {
|
if (showInfoBoard(toShow)) {
|
||||||
FScoreboard.get(this).setTemporarySidebar(new FInfoSidebar(toShow));
|
FScoreboard.get(this).setTemporarySidebar(new FInfoSidebar(toShow));
|
||||||
@ -860,7 +860,7 @@ public abstract class MemoryFPlayer implements FPlayer {
|
|||||||
int factionBuffer = plugin.getConfig().getInt("hcf.buffer-zone", 0);
|
int factionBuffer = plugin.getConfig().getInt("hcf.buffer-zone", 0);
|
||||||
int worldBuffer = plugin.getConfig().getInt("world-border.buffer", 0) - 1;
|
int worldBuffer = plugin.getConfig().getInt("world-border.buffer", 0) - 1;
|
||||||
|
|
||||||
if (Conf.worldGuardChecking && Worldguard.getInstance().checkForRegionsInChunk(flocation)) {
|
if (Conf.worldGuardChecking && Worldguard.getInstance().checkForRegionsInChunk(flocation)) {
|
||||||
// Checks for WorldGuard regions in the chunk attempting to be claimed
|
// Checks for WorldGuard regions in the chunk attempting to be claimed
|
||||||
error = plugin.txt.parse(TL.CLAIM_PROTECTED.toString());
|
error = plugin.txt.parse(TL.CLAIM_PROTECTED.toString());
|
||||||
} else if (flocation.isOutsideWorldBorder(plugin.getConfig().getInt("world-border.buffer", 0) - 1)) {
|
} else if (flocation.isOutsideWorldBorder(plugin.getConfig().getInt("world-border.buffer", 0) - 1)) {
|
||||||
@ -873,7 +873,7 @@ public abstract class MemoryFPlayer implements FPlayer {
|
|||||||
return true;
|
return true;
|
||||||
} else if (forFaction.isWarZone() && Permission.MANAGE_WAR_ZONE.has(getPlayer())) {
|
} else if (forFaction.isWarZone() && Permission.MANAGE_WAR_ZONE.has(getPlayer())) {
|
||||||
return true;
|
return true;
|
||||||
} else if (currentFaction.getAccess(this, PermissableAction.TERRITORY) == Access.ALLOW && forFaction != currentFaction ) {
|
} else if (currentFaction.getAccess(this, PermissableAction.TERRITORY) == Access.ALLOW && forFaction != currentFaction) {
|
||||||
return true;
|
return true;
|
||||||
} else if (myFaction != forFaction) {
|
} else if (myFaction != forFaction) {
|
||||||
error = plugin.txt.parse(TL.CLAIM_CANTCLAIM.toString(), forFaction.describeTo(this));
|
error = plugin.txt.parse(TL.CLAIM_CANTCLAIM.toString(), forFaction.describeTo(this));
|
||||||
@ -972,36 +972,38 @@ public abstract class MemoryFPlayer implements FPlayer {
|
|||||||
}
|
}
|
||||||
|
|
||||||
public void setFFlying(boolean fly, boolean damage) {
|
public void setFFlying(boolean fly, boolean damage) {
|
||||||
Player player = getPlayer();
|
if (FactionsPlugin.getInstance().getConfig().getBoolean("enable-faction-flight")) {
|
||||||
if (player == null) return;
|
Player player = getPlayer();
|
||||||
|
if (player == null) return;
|
||||||
|
|
||||||
player.setAllowFlight(fly);
|
player.setAllowFlight(fly);
|
||||||
player.setFlying(fly);
|
player.setFlying(fly);
|
||||||
|
|
||||||
if (!damage) {
|
if (!damage) {
|
||||||
msg(TL.COMMAND_FLY_CHANGE, fly ? "enabled" : "disabled");
|
msg(TL.COMMAND_FLY_CHANGE, fly ? "enabled" : "disabled");
|
||||||
|
if (!fly) {
|
||||||
|
sendMessage(TL.COMMAND_FLY_COOLDOWN.toString().replace("{amount}", FactionsPlugin.getInstance().getConfig().getInt("fly-falldamage-cooldown", 3) + ""));
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
msg(TL.COMMAND_FLY_DAMAGE);
|
||||||
|
}
|
||||||
|
|
||||||
|
// If leaving fly mode, don't let them take fall damage for x seconds.
|
||||||
if (!fly) {
|
if (!fly) {
|
||||||
sendMessage(TL.COMMAND_FLY_COOLDOWN.toString().replace("{amount}", FactionsPlugin.getInstance().getConfig().getInt("fly-falldamage-cooldown", 3) + ""));
|
int cooldown = FactionsPlugin.getInstance().getConfig().getInt("fly-falldamage-cooldown", 3);
|
||||||
|
CmdFly.flyMap.remove(player.getName());
|
||||||
|
|
||||||
|
// If the value is 0 or lower, make them take fall damage.
|
||||||
|
// Otherwise, start a timer and have this cancel after a few seconds.
|
||||||
|
// Short task so we're just doing it in method. Not clean but eh.
|
||||||
|
if (cooldown > 0) {
|
||||||
|
setTakeFallDamage(false);
|
||||||
|
Bukkit.getScheduler().runTaskLater(FactionsPlugin.getInstance(), () -> setTakeFallDamage(true), 20L * cooldown);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
} else {
|
|
||||||
msg(TL.COMMAND_FLY_DAMAGE);
|
isFlying = fly;
|
||||||
}
|
}
|
||||||
|
|
||||||
// If leaving fly mode, don't let them take fall damage for x seconds.
|
|
||||||
if (!fly) {
|
|
||||||
int cooldown = FactionsPlugin.getInstance().getConfig().getInt("fly-falldamage-cooldown", 3);
|
|
||||||
CmdFly.flyMap.remove(player.getName());
|
|
||||||
|
|
||||||
// If the value is 0 or lower, make them take fall damage.
|
|
||||||
// Otherwise, start a timer and have this cancel after a few seconds.
|
|
||||||
// Short task so we're just doing it in method. Not clean but eh.
|
|
||||||
if (cooldown > 0) {
|
|
||||||
setTakeFallDamage(false);
|
|
||||||
Bukkit.getScheduler().runTaskLater(FactionsPlugin.getInstance(), () -> setTakeFallDamage(true), 20L * cooldown);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
isFlying = fly;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public boolean isInFactionsChest() {
|
public boolean isInFactionsChest() {
|
||||||
@ -1220,11 +1222,11 @@ public abstract class MemoryFPlayer implements FPlayer {
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
public boolean hasFriendlyFire(){
|
public boolean hasFriendlyFire() {
|
||||||
return friendlyFire;
|
return friendlyFire;
|
||||||
}
|
}
|
||||||
|
|
||||||
public void setFriendlyFire(boolean status){
|
public void setFriendlyFire(boolean status) {
|
||||||
friendlyFire = status;
|
friendlyFire = status;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -1302,7 +1304,7 @@ public abstract class MemoryFPlayer implements FPlayer {
|
|||||||
|
|
||||||
|
|
||||||
// announce success
|
// announce success
|
||||||
if(!FactionsPlugin.cachedRadiusClaim) {
|
if (!FactionsPlugin.cachedRadiusClaim) {
|
||||||
Set<FPlayer> informTheseFPlayers = new HashSet<>();
|
Set<FPlayer> informTheseFPlayers = new HashSet<>();
|
||||||
informTheseFPlayers.add(this);
|
informTheseFPlayers.add(this);
|
||||||
informTheseFPlayers.addAll(forFaction.getFPlayersWhereOnline(true));
|
informTheseFPlayers.addAll(forFaction.getFPlayersWhereOnline(true));
|
||||||
|
@ -1277,7 +1277,7 @@ public abstract class MemoryFaction implements Faction, EconomyParticipator {
|
|||||||
if (Conf.logFactionDisband)
|
if (Conf.logFactionDisband)
|
||||||
FactionsPlugin.getInstance().log("The faction " + this.getTag() + " (" + this.getId() + ") has been disbanded since it has no members left" + (autoLeave ? " and by inactivity" : "") + ".");
|
FactionsPlugin.getInstance().log("The faction " + this.getTag() + " (" + this.getId() + ") has been disbanded since it has no members left" + (autoLeave ? " and by inactivity" : "") + ".");
|
||||||
|
|
||||||
if(FactionsPlugin.getInstance().getConfig().getBoolean("faction-disband-broadcast")) {
|
if (FactionsPlugin.getInstance().getConfig().getBoolean("faction-disband-broadcast")) {
|
||||||
for (FPlayer fplayer : FPlayers.getInstance().getOnlinePlayers())
|
for (FPlayer fplayer : FPlayers.getInstance().getOnlinePlayers())
|
||||||
fplayer.msg(TL.COMMAND_DISBAND_BROADCAST_GENERIC, this.getTag(fplayer));
|
fplayer.msg(TL.COMMAND_DISBAND_BROADCAST_GENERIC, this.getTag(fplayer));
|
||||||
}
|
}
|
||||||
|
@ -73,21 +73,22 @@ public class JSONFPlayers extends MemoryFPlayers {
|
|||||||
if (!this.file.exists()) return new HashMap<>();
|
if (!this.file.exists()) return new HashMap<>();
|
||||||
String content = DiscUtil.readCatch(this.file);
|
String content = DiscUtil.readCatch(this.file);
|
||||||
if (content == null) return null;
|
if (content == null) return null;
|
||||||
Map<String, JSONFPlayer> data = this.gson.fromJson(content, new TypeToken<Map<String, JSONFPlayer>>() {
|
try {
|
||||||
}.getType());
|
Map<String, JSONFPlayer> data = this.gson.fromJson(content, new TypeToken<Map<String, JSONFPlayer>>() {
|
||||||
Set<String> list = new HashSet<>();
|
}.getType());
|
||||||
Set<String> invalidList = new HashSet<>();
|
Set<String> list = new HashSet<>();
|
||||||
for (Entry<String, JSONFPlayer> entry : data.entrySet()) {
|
Set<String> invalidList = new HashSet<>();
|
||||||
String key = entry.getKey();
|
for (Entry<String, JSONFPlayer> entry : data.entrySet()) {
|
||||||
entry.getValue().setId(key);
|
String key = entry.getKey();
|
||||||
if (doesKeyNeedMigration(key)) {
|
entry.getValue().setId(key);
|
||||||
if (!isKeyInvalid(key)) {
|
if (doesKeyNeedMigration(key)) {
|
||||||
list.add(key);
|
if (!isKeyInvalid(key)) {
|
||||||
} else {
|
list.add(key);
|
||||||
invalidList.add(key);
|
} else {
|
||||||
|
invalidList.add(key);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
|
||||||
|
|
||||||
if (list.size() > 0) {
|
if (list.size() > 0) {
|
||||||
// We've got some converting to do!
|
// We've got some converting to do!
|
||||||
@ -150,6 +151,14 @@ public class JSONFPlayers extends MemoryFPlayers {
|
|||||||
Bukkit.getLogger().log(Level.INFO, "Done converting players.json to UUID.");
|
Bukkit.getLogger().log(Level.INFO, "Done converting players.json to UUID.");
|
||||||
}
|
}
|
||||||
return data;
|
return data;
|
||||||
|
} catch (NullPointerException exception) {
|
||||||
|
exception.printStackTrace();
|
||||||
|
if (this.file.length() < 200) {
|
||||||
|
return new HashMap<>();
|
||||||
|
} else {
|
||||||
|
throw exception;
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private boolean doesKeyNeedMigration(String key) {
|
private boolean doesKeyNeedMigration(String key) {
|
||||||
|
@ -824,6 +824,7 @@ public enum TL {
|
|||||||
COMMAND_STRIKESINFO_DESCRIPTION("Get a faction's strikes"),
|
COMMAND_STRIKESINFO_DESCRIPTION("Get a faction's strikes"),
|
||||||
|
|
||||||
SHOP_NOT_ENOUGH_POINTS("&c&l[!] &7Your faction does not have enough points to purchase this!"),
|
SHOP_NOT_ENOUGH_POINTS("&c&l[!] &7Your faction does not have enough points to purchase this!"),
|
||||||
|
SHOP_ERROR_DURING_PURCHASE("&c&l[!] &7There was an error while trying to give items please check your inventory! Purchase was not completed!"),
|
||||||
SHOP_BOUGHT_BROADCAST_FACTION("\n&c&l[!] &e&lFactionShop » &b{player} &7bought &b{item}&7 for &b{cost} &7points!\n"),
|
SHOP_BOUGHT_BROADCAST_FACTION("\n&c&l[!] &e&lFactionShop » &b{player} &7bought &b{item}&7 for &b{cost} &7points!\n"),
|
||||||
|
|
||||||
|
|
||||||
@ -1250,6 +1251,10 @@ public enum TL {
|
|||||||
PLAYER_PVP_NEUTRALFAIL("You can't hurt %s in their own territory unless you declare them as an enemy."),
|
PLAYER_PVP_NEUTRALFAIL("You can't hurt %s in their own territory unless you declare them as an enemy."),
|
||||||
PLAYER_PVP_TRIED("%s tried to hurt you."),
|
PLAYER_PVP_TRIED("%s tried to hurt you."),
|
||||||
|
|
||||||
|
SHIELD_CURRENTLY_ENABLE("&a&lCurrently Protected"),
|
||||||
|
SHIELD_NOT_SET("&c&lNot Set"),
|
||||||
|
SHIELD_CURRENTLY_NOT_ENABLED("&c&lCurrently Unprotected"),
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Strings lying around in other bits of the plugins
|
* Strings lying around in other bits of the plugins
|
||||||
*/
|
*/
|
||||||
|
@ -78,6 +78,7 @@ public enum TagReplacer {
|
|||||||
FACTION_BANCOUNT(TagType.FACTION, "{faction-bancount}"),
|
FACTION_BANCOUNT(TagType.FACTION, "{faction-bancount}"),
|
||||||
FACTION_STRIKES(TagType.FACTION, "{strikes}"),
|
FACTION_STRIKES(TagType.FACTION, "{strikes}"),
|
||||||
FACTION_POINTS(TagType.FACTION, "{faction-points}"),
|
FACTION_POINTS(TagType.FACTION, "{faction-points}"),
|
||||||
|
SHIELD_STATUS(TagType.FACTION, "{shield-status}"),
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -239,6 +240,10 @@ public enum TagReplacer {
|
|||||||
return fac.hasHome() ? String.valueOf(fac.getHome().getBlockY()) : minimal ? null : "{ig}";
|
return fac.hasHome() ? String.valueOf(fac.getHome().getBlockY()) : minimal ? null : "{ig}";
|
||||||
case HOME_Z:
|
case HOME_Z:
|
||||||
return fac.hasHome() ? String.valueOf(fac.getHome().getBlockZ()) : minimal ? null : "{ig}";
|
return fac.hasHome() ? String.valueOf(fac.getHome().getBlockZ()) : minimal ? null : "{ig}";
|
||||||
|
//case SHIELD_STATUS:
|
||||||
|
//if(fac.isProtected() && fac.getShieldFrame() != null) return String.valueOf(TL.SHIELD_CURRENTLY_ENABLE);
|
||||||
|
//if(fac.getShieldFrame() == null) return String.valueOf(TL.SHIELD_NOT_SET);
|
||||||
|
//return TL.SHIELD_CURRENTLY_NOT_ENABLED.toString();
|
||||||
case LAND_VALUE:
|
case LAND_VALUE:
|
||||||
return Econ.shouldBeUsed() ? Econ.moneyString(Econ.calculateTotalLandValue(fac.getLandRounded())) : minimal ? null : TL.ECON_OFF.format("value");
|
return Econ.shouldBeUsed() ? Econ.moneyString(Econ.calculateTotalLandValue(fac.getLandRounded())) : minimal ? null : TL.ECON_OFF.format("value");
|
||||||
case LAND_REFUND:
|
case LAND_REFUND:
|
||||||
|
Some files were not shown because too many files have changed in this diff Show More
Loading…
Reference in New Issue
Block a user