Compare commits

..

92 Commits

Author SHA1 Message Date
Driftay
abf5c45053 Version Change 2019-09-29 18:51:24 -04:00
Driftay
a1f527346a Fixed NPE on Guild loading 2019-09-29 18:45:48 -04:00
Driftay
8a4478764f Merge pull request #19 from DroppingAnvil/1.6.x
You can now mention discord users in game!
2019-09-29 18:45:15 -04:00
DroppingAnvil
8b70947d03 Uncommented something that shouldnt have been 2019-09-29 13:36:37 -05:00
DroppingAnvil
58b25c726f First step to mentions! You can now mention discord users ingame if they have a one word name and there is not someone named the same thing! I plan to make this system much much better soon! 2019-09-29 13:29:23 -05:00
Driftay
22ed86b4d8 Added f points to stats discord command 2019-09-29 08:13:48 -04:00
Driftay
ed9b2419a6 Jar reduced by 200kbs 2019-09-29 07:24:37 -04:00
Driftay
2d0d3c96fc Little thing to avoid npe's being thrown in the console 2019-09-29 06:50:45 -04:00
Driftay
206914247d Version Change 2019-09-29 06:44:45 -04:00
DroppingAnvil
90d9486165 Merge pull request #7 from Driftay/1.6.x
Merge
2019-09-29 04:16:37 -05:00
Driftay
e5cfc1ebdc Changed f invitebot format 2019-09-29 05:16:13 -04:00
Driftay
f63121ed86 Removed token from conf, so owners didnt accidentally use that token 2019-09-29 04:46:21 -04:00
Driftay
3998a346b4 Discord Integration AKA Changing Factions Forever 2019-09-29 04:39:30 -04:00
Driftay
0b1add2a3e Fixed Some things with inventorysee 2019-09-28 03:22:23 -04:00
Driftay
4ab3f3a465 Stopped Referencing ItemStack by mistake 2019-09-28 03:05:03 -04:00
Driftay
6f20087ebe Version Change 2019-09-27 13:01:36 -04:00
Driftay
a493f1494e Code Cleanup 2019-09-24 17:54:12 -04:00
Driftay
2a08f167bb Fixed Citizens error with new upgrades 2019-09-24 17:42:10 -04:00
DroppingAnvil
c2ac4a6517 Merge from Driftay/1.6.x 2019-09-24 12:07:58 -05:00
Driftay
f358e6d75b Added Anti-FChest-Items
(Ability to deny storing items in factions chest)
2019-09-24 06:39:43 -04:00
Driftay
8338e21dd2 Added F Discord 2019-09-21 13:02:51 -04:00
Driftay
d47806b33a Merge remote-tracking branch 'origin/1.6.x' into 1.6.x 2019-09-21 10:35:23 -04:00
Driftay
99edc5b3b5 Missions Not Be Able to Be Done Multiple Times 2019-09-21 10:35:08 -04:00
Driftay
a19cfade75 Merge pull request #18 from DroppingAnvil/1.6.x
Allow F grace from console
2019-09-20 17:06:41 -04:00
Driftay
5b8d2ac4d5 Version Change 2019-09-20 16:59:57 -04:00
Driftay
d6ca2934de Fixed a Few Things 2019-09-20 16:59:31 -04:00
DroppingAnvil
31c3cc538a Merge pull request #5 from Driftay/1.6.x
Merge
2019-09-19 19:25:36 -05:00
DroppingAnvil
917a5feca8 Allow F grace from console 2019-09-19 13:35:07 -05:00
Driftay
81636c6448 Version Change 2019-09-18 08:01:05 -04:00
Driftay
3ce77fe7e1 Fixed Shop Items Sowwy :) 2019-09-18 07:47:03 -04:00
Driftay
8ec16505c4 Fixed Shop Items Sowwy :) 2019-09-18 07:43:18 -04:00
Driftay
0ac6112437 Added Anti-Creeper Glitch To avoid issues with freecam cegging 2019-09-18 05:22:05 -04:00
Driftay
3d45684c6f Version Change 2019-09-17 19:29:40 -04:00
Driftay
4046ab62e2 Merge pull request #17 from DroppingAnvil/1.6.x
Fixed grace period issues!
2019-09-17 19:29:07 -04:00
Driftay
b70741b0d5 Merge remote-tracking branch 'origin/1.6.x' into 1.6.x 2019-09-17 19:08:47 -04:00
Driftay
bd4e6cb6a8 Shop GUI Cleaned up :D 2019-09-17 19:08:23 -04:00
DroppingAnvil
a3b819cda3 Fixed grace period issues! 2019-09-17 17:28:32 -05:00
Driftay
0971f72a7a Merge pull request #16 from DroppingAnvil/1.6.x
Fixed Faction Upgrades compatibility with 1.14
2019-09-16 16:23:36 -04:00
DroppingAnvil
b29dd64581 Removed my old conversion code for 1.14 since transitioned to XMaterial. XMaterial support added for EXP upgrade 2019-09-16 13:45:41 -05:00
DroppingAnvil
bc00a5ebd7 Changed Faction Upgrades GUI to XMaterial 2019-09-16 13:37:25 -05:00
DroppingAnvil
89413057cc Fixed some default Faction Upgrades materials not being compatible with 1.14 2019-09-16 12:51:58 -05:00
Driftay
c0a9eeca87 PlaceHolders and better configurability 2019-09-16 07:56:11 -04:00
Driftay
17378f7c3a Merge pull request #15 from DroppingAnvil/1.6.x
Added 2 new Faction Mission types!
2019-09-16 07:37:45 -04:00
Driftay
41fb4dd7ad Added Spawner Lock Command, And Formatted Grace Differently 2019-09-16 07:36:42 -04:00
DroppingAnvil
4181ff539d Cleaned up unused imports 2019-09-15 23:03:58 -05:00
DroppingAnvil
b3eca15839 Added 2 new Faction Mission types! 2019-09-15 23:01:34 -05:00
Driftay
8df75a59d4 version change 2019-09-15 18:49:12 -04:00
Driftay
b0ca56fc71 Spelling POG 2019-09-15 18:48:47 -04:00
Driftay
338b062de0 Merge pull request #14 from DroppingAnvil/1.6.x
New F Upgrade!
2019-09-15 18:16:51 -04:00
DroppingAnvil
1e7bd8ff35 Removed 2 lines used for debug. 2019-09-15 17:10:15 -05:00
DroppingAnvil
26010c6ba2 Added a new F Upgrade type! 2019-09-15 17:08:36 -05:00
Driftay
570cb4e805 Merge pull request #13 from AigleDev/1.6.x
fix an NPE and other changes
2019-09-15 16:58:14 -04:00
Driftay
2fe4d29c0e Spelling POG 2019-09-15 16:33:22 -04:00
DroppingAnvil
f78290b63d Merge from Driftay/1.6.x 2019-09-15 14:03:20 -05:00
AigleDev
fb3204ddb1 fix an NPE and other changes 2019-09-15 20:53:27 +02:00
Driftay
4f38bfa949 forgot i already added 1 to the level 2019-09-15 07:53:20 -04:00
Driftay
488eb78405 Forgot To Register Upgrade Listener xD 2019-09-15 07:52:29 -04:00
Driftay
82d2971b65 Added Warp, DamageIncrease & Reduction, and TNT F Upgrades 2019-09-15 07:51:12 -04:00
Driftay
7f988031ca Showing Dropping Anvil Something (Ignore) 2019-09-15 05:19:06 -04:00
Driftay
2feaed0aad Showing Dropping Anvil Something (Ignore) 2019-09-15 05:15:33 -04:00
Driftay
e7db7170d1 Showing Dropping Anvil Something (Ignore) 2019-09-15 05:14:14 -04:00
Driftay
2a1a8db554 Showing Dropping Anvil Something (Ignore) 2019-09-15 05:12:52 -04:00
Driftay
e07dc303ef Showing Dropping Anvil Something (Ignore) 2019-09-15 05:08:00 -04:00
Driftay
978bcbbb3b Merge remote-tracking branch 'origin/1.6.x' into 1.6.x
# Conflicts:
#	src/main/java/com/massivecraft/factions/listeners/FactionsBlockListener.java
#	src/main/java/com/massivecraft/factions/missions/MissionHandler.java
2019-09-15 05:04:22 -04:00
Driftay
d98f5d9723 Showing Dropping Anvil Something (Ignore) 2019-09-15 05:02:53 -04:00
Driftay
7e9c6cead8 Merge pull request #12 from DroppingAnvil/1.6.x
Added new mission type + added an existing type that was missing from config + added ALL for all missions that use Material or EntityType
2019-09-15 04:55:59 -04:00
DroppingAnvil
8f013e13a4 Fixed a small config mistake I had made 2019-09-15 03:50:07 -05:00
DroppingAnvil
b1525601a0 Merge remote-tracking branch 'origin/1.6.x' into 1.6.x 2019-09-15 03:46:59 -05:00
DroppingAnvil
0d5e5dda73 Added tame mission type added "ALL" for all Missions that require Material or EntityType 2019-09-15 03:46:41 -05:00
DroppingAnvil
b4b226e4f0 Merge pull request #3 from Driftay/1.6.x
Update from base
2019-09-15 03:32:36 -05:00
Driftay
c4e81286b7 Deny Breaking Banners to avoid dupe glitches in enemy territory 2019-09-15 04:26:16 -04:00
DroppingAnvil
fcab9790b5 Merge!
Finally back on course and able to merge automatically with Driftay's SaberFactions!
2019-09-15 03:25:14 -05:00
DroppingAnvil
6f5ba4c11b Getting back on course... 2019-09-15 03:23:10 -05:00
DroppingAnvil
8e238e2b48 Merging branches 1 new mission type 2019-09-15 03:14:15 -05:00
Driftay
ed0e17e2a0 Missions Fix 2019-09-15 03:48:25 -04:00
Driftay
58efba39b0 Config Converter Added (DroppingAnvil) 2019-09-14 16:04:20 -04:00
Driftay
804160429d Fixed Fly Disable For People In Creative 2019-09-14 15:51:30 -04:00
Driftay
db9c951283 Version Change 2019-09-14 15:33:49 -04:00
Driftay
3c9b606bb9 Introduced Brigadier Command System. More Formatting Coming in next commit. 2019-09-14 15:14:28 -04:00
DroppingAnvil
c23d19435d Added check for gamemode when disabling flight as to not disable flight for players not using factions flight but minecraft flight 2019-09-14 10:22:58 -05:00
BuildTools
8035e26af0 Merge remote-tracking branch 'origin/1.6.x' into 1.6.x 2019-09-14 09:23:35 -05:00
BuildTools
2439e5258f Fixed WarBanner Persistence Error with Placement 2019-09-14 09:22:38 -05:00
DroppingAnvil
049ba10321 Update README.md 2019-09-12 19:32:58 -05:00
DroppingAnvil
ab9ce5649d Update README.md 2019-09-12 19:04:49 -05:00
BuildTools
0530b67b77 Updated Factions.jar 2019-09-12 18:58:40 -05:00
BuildTools
baeb797c0d Updated configuration converted for new SaberFactions config. 2019-09-12 18:57:09 -05:00
Driftay
b06e6e0f04 Merge pull request #8 from AigleDev/patch
Fix an NPE
2019-09-12 18:50:58 -04:00
DroppingAnvil
679fbbf92f Fixed missing import for ConvertConfigHandler added convert perm to Admin kit 2019-09-12 17:28:15 -05:00
BuildTools
a58b28536b Changed role names added capitalization and a grammar fix. 2019-09-12 17:14:10 -05:00
BuildTools
8ede39413c Added configuration conversion! 2019-09-12 15:53:52 -05:00
AigleDev
0d8526372e change 2019-09-12 21:21:23 +02:00
AigleDev
ba86f28994 NPE fix 2019-09-12 21:20:20 +02:00
227 changed files with 7070 additions and 4539 deletions

View File

@@ -108,7 +108,7 @@ var activeTableTab = "activeTableTab";
<li><a href="../../../com/massivecraft/factions/zcore/MPlugin.html" title="class in com.massivecraft.factions.zcore">com.massivecraft.factions.zcore.MPlugin</a></li> <li><a href="../../../com/massivecraft/factions/zcore/MPlugin.html" title="class in com.massivecraft.factions.zcore">com.massivecraft.factions.zcore.MPlugin</a></li>
<li> <li>
<ul class="inheritance"> <ul class="inheritance">
<li>com.massivecraft.factions.P</li> <li>com.massivecraft.factions.FactionsPlugin</li>
</ul> </ul>
</li> </li>
</ul> </ul>

57
pom.xml
View File

@@ -4,7 +4,7 @@
<groupId>com.massivecraft</groupId> <groupId>com.massivecraft</groupId>
<artifactId>Factions</artifactId> <artifactId>Factions</artifactId>
<version>1.6.9.5-U0.2.1-1.8.1-BETA</version> <version>1.6.9.5-U0.2.1-2.0.1-BETA</version>
<packaging>jar</packaging> <packaging>jar</packaging>
<name>SaberFactions</name> <name>SaberFactions</name>
@@ -81,6 +81,18 @@
</build> </build>
<dependencies> <dependencies>
<dependency>
<groupId>me.lucko</groupId>
<artifactId>commodore</artifactId>
<version>1.3</version>
<scope>compile</scope>
</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>
@@ -166,6 +178,18 @@
</exclusion> </exclusion>
</exclusions> </exclusions>
</dependency> </dependency>
<dependency>
<groupId>net.dv8tion</groupId>
<artifactId>JDA</artifactId>
<version>3.8.3_463</version>
<scope>compile</scope>
<exclusions>
<exclusion>
<groupId>club.minnced</groupId>
<artifactId>opus-java</artifactId>
</exclusion>
</exclusions>
</dependency>
<dependency> <dependency>
<groupId>com.sk89q.worldedit</groupId> <groupId>com.sk89q.worldedit</groupId>
<artifactId>worldedit-bukkit</artifactId> <artifactId>worldedit-bukkit</artifactId>
@@ -352,14 +376,33 @@
</exclusion> </exclusion>
</exclusions> </exclusions>
</dependency> </dependency>
<dependency>
<groupId>org.codemc.worldguardwrapper</groupId>
<artifactId>worldguardwrapper</artifactId>
<version>1.1.6-SNAPSHOT</version>
</dependency>
<dependency>
<groupId>com.jagrosh</groupId>
<artifactId>jda-utilities-commons</artifactId>
<version>2.1</version>
<scope>compile</scope>
</dependency>
</dependencies> </dependencies>
<repositories> <repositories>
<repository>
<id>central</id>
<name>bintray</name>
<url>http://jcenter.bintray.com</url>
</repository>
<repository> <repository>
<id>net.coreprotect</id> <id>net.coreprotect</id>
<url>http://maven.playpro.com/</url> <url>http://maven.playpro.com/</url>
</repository> </repository>
<repository>
<id>codemc-repo</id>
<url>https://repo.codemc.org/repository/maven-public/</url>
</repository>
<repository> <repository>
<id>ess-repo</id> <id>ess-repo</id>
<url>http://ci.ender.zone/plugin/repository/everything/</url> <url>http://ci.ender.zone/plugin/repository/everything/</url>
@@ -372,6 +415,11 @@
<id>maven.sk89q.com</id> <id>maven.sk89q.com</id>
<url>http://maven.sk89q.com/repo/</url> <url>http://maven.sk89q.com/repo/</url>
</repository> </repository>
<repository>
<id>jcenter</id>
<name>jcenter-bintray</name>
<url>https://jcenter.bintray.com</url>
</repository>
<repository> <repository>
<id>repo.mikeprimm.com</id> <id>repo.mikeprimm.com</id>
<url>http://repo.mikeprimm.com/</url> <url>http://repo.mikeprimm.com/</url>
@@ -393,6 +441,11 @@
<id>jitpack.io</id> <id>jitpack.io</id>
<url>https://jitpack.io</url> <url>https://jitpack.io</url>
</repository> </repository>
<repository>
<id>minecraft-libraries</id>
<name>Minecraft Libraries</name>
<url>https://libraries.minecraft.net</url>
</repository>
</repositories> </repositories>
<distributionManagement> <distributionManagement>

View File

@@ -84,6 +84,7 @@ public class Conf {
public static int stealthFlyCheckRadius = 32; public static int stealthFlyCheckRadius = 32;
public static int factionBufferSize = 20; public static int factionBufferSize = 20;
public static boolean useCheckSystem = true; public static boolean useCheckSystem = true;
public static boolean spawnerLock = false;
public static boolean gracePeriod = false; public static boolean gracePeriod = false;
public static boolean noEnderpearlsInFly = false; public static boolean noEnderpearlsInFly = false;
public static boolean broadcastDescriptionChanges = false; public static boolean broadcastDescriptionChanges = false;
@@ -96,6 +97,12 @@ public class Conf {
public static boolean autoLeaveDeleteFPlayerData = true; // Let them just remove player from Faction. public static boolean autoLeaveDeleteFPlayerData = true; // Let them just remove player from Faction.
public static boolean worldGuardChecking = false; public static boolean worldGuardChecking = false;
public static boolean worldGuardBuildPriority = false; public static boolean worldGuardBuildPriority = false;
//DISCORD
public static boolean useDiscordSystem = true;
public static String discordBotToken = "<token here>";
public static String fromDiscordFactionChatPrefix = "&f[&dDiscord&f] ";
public static String avatarUrl = "http://cravatar.eu/helmavatar/%uuid%.png";
public static String webhookName = "SaberFactions Hook";
// server logging options // server logging options
public static boolean logFactionCreate = true; public static boolean logFactionCreate = true;
public static boolean logFactionDisband = true; public static boolean logFactionDisband = true;
@@ -386,7 +393,7 @@ public class Conf {
territoryDenyUseageMaterials.add(Material.BUCKET); territoryDenyUseageMaterials.add(Material.BUCKET);
territoryDenyUseageMaterials.add(Material.WATER_BUCKET); territoryDenyUseageMaterials.add(Material.WATER_BUCKET);
territoryDenyUseageMaterials.add(Material.LAVA_BUCKET); territoryDenyUseageMaterials.add(Material.LAVA_BUCKET);
if (!P.p.mc17) { if (!FactionsPlugin.getInstance().mc17) {
territoryDenyUseageMaterials.add(Material.ARMOR_STAND); territoryDenyUseageMaterials.add(Material.ARMOR_STAND);
} }
@@ -398,7 +405,7 @@ public class Conf {
territoryDenyUseageMaterialsWhenOffline.add(Material.BUCKET); territoryDenyUseageMaterialsWhenOffline.add(Material.BUCKET);
territoryDenyUseageMaterialsWhenOffline.add(Material.WATER_BUCKET); territoryDenyUseageMaterialsWhenOffline.add(Material.WATER_BUCKET);
territoryDenyUseageMaterialsWhenOffline.add(Material.LAVA_BUCKET); territoryDenyUseageMaterialsWhenOffline.add(Material.LAVA_BUCKET);
if (!P.p.mc17) { if (!FactionsPlugin.getInstance().mc17) {
territoryDenyUseageMaterialsWhenOffline.add(Material.ARMOR_STAND); territoryDenyUseageMaterialsWhenOffline.add(Material.ARMOR_STAND);
} }
safeZoneNerfedCreatureTypes.add(EntityType.BLAZE); safeZoneNerfedCreatureTypes.add(EntityType.BLAZE);
@@ -426,11 +433,11 @@ public class Conf {
} }
public static void load() { public static void load() {
P.p.persist.loadOrSaveDefault(i, Conf.class, "conf"); FactionsPlugin.getInstance().persist.loadOrSaveDefault(i, Conf.class, "conf");
} }
public static void save() { public static void save() {
P.p.persist.save(i); FactionsPlugin.getInstance().persist.save(i);
} }
public enum Backend { public enum Backend {

View File

@@ -23,6 +23,55 @@ import java.util.concurrent.ConcurrentHashMap;
public interface Faction extends EconomyParticipator { public interface Faction extends EconomyParticipator {
String getMemberRoleId();
void setMemberRoleId(String roleId);
String getGuildId();
void setGuildId(String id);
String getWallNotifyChannelId();
void setWallNotifyChannelId(String channelId);
String getBufferNotifyChannelId();
void setBufferNotifyChannelId(String channelId);
String getWeeWooChannelId();
void setWeeWooChannelId(String channelId);
String getNotifyFormat();
void setNotifyFormat(String format);
String getWeeWooFormat();
void setWeeWooFormat(String format);
String getFactionChatChannelId();
void setFactionChatChannelId(String channelId);
String getDiscord();
void setDiscord(String link);
void checkPerms();
double getReinforcedArmor();
void setReinforcedArmor(double percent);
int getWarpsLimit();
void setWarpsLimit(int limit);
int getTntBankLimit();
void setTntBankLimit(int limit);
int getWallCheckMinutes(); int getWallCheckMinutes();
@@ -46,6 +95,8 @@ public interface Faction extends EconomyParticipator {
Map<String, Mission> getMissions(); Map<String, Mission> getMissions();
List<String> getCompletedMissions();
void deinviteAlt(FPlayer alt); void deinviteAlt(FPlayer alt);
void deinviteAllAlts(); void deinviteAllAlts();

View File

@@ -5,28 +5,34 @@ import ch.njol.skript.SkriptAddon;
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.cmd.CmdAutoHelp; import com.massivecraft.factions.cmd.CmdAutoHelp;
import com.massivecraft.factions.cmd.CommandContext;
import com.massivecraft.factions.cmd.FCmdRoot; import com.massivecraft.factions.cmd.FCmdRoot;
import com.massivecraft.factions.cmd.FCommand;
import com.massivecraft.factions.cmd.check.CheckTask; import com.massivecraft.factions.cmd.check.CheckTask;
import com.massivecraft.factions.cmd.check.WeeWooTask; import com.massivecraft.factions.cmd.check.WeeWooTask;
import com.massivecraft.factions.cmd.chest.AntiChestListener;
import com.massivecraft.factions.cmd.chest.ChestLogsHandler; import com.massivecraft.factions.cmd.chest.ChestLogsHandler;
import com.massivecraft.factions.discord.DiscordListener;
import com.massivecraft.factions.discord.FactionChatHandler;
import com.massivecraft.factions.integration.Econ; import com.massivecraft.factions.integration.Econ;
import com.massivecraft.factions.integration.Worldguard; import com.massivecraft.factions.integration.Worldguard;
import com.massivecraft.factions.integration.dynmap.EngineDynmap; import com.massivecraft.factions.integration.dynmap.EngineDynmap;
import com.massivecraft.factions.listeners.*; import com.massivecraft.factions.listeners.*;
import com.massivecraft.factions.missions.MissionHandler; import com.massivecraft.factions.missions.MissionHandler;
import com.massivecraft.factions.shop.ShopClickPersistence;
import com.massivecraft.factions.shop.ShopConfig; import com.massivecraft.factions.shop.ShopConfig;
import com.massivecraft.factions.struct.ChatMode; import com.massivecraft.factions.struct.ChatMode;
import com.massivecraft.factions.struct.Relation;
import com.massivecraft.factions.struct.Role;
import com.massivecraft.factions.util.*; import com.massivecraft.factions.util.*;
import com.massivecraft.factions.util.Particles.ReflectionUtils; import com.massivecraft.factions.util.Particles.ReflectionUtils;
import com.massivecraft.factions.zcore.CommandVisibility; import com.massivecraft.factions.zcore.CommandVisibility;
import com.massivecraft.factions.zcore.MCommand;
import com.massivecraft.factions.zcore.MPlugin; import com.massivecraft.factions.zcore.MPlugin;
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.fupgrades.*; import com.massivecraft.factions.zcore.fupgrades.*;
import com.massivecraft.factions.zcore.util.TextUtil; import com.massivecraft.factions.zcore.util.TextUtil;
import me.lucko.commodore.CommodoreProvider;
import net.milkbowl.vault.economy.Economy; import net.milkbowl.vault.economy.Economy;
import net.milkbowl.vault.permission.Permission; import net.milkbowl.vault.permission.Permission;
import org.bukkit.*; import org.bukkit.*;
@@ -52,11 +58,11 @@ import java.util.logging.Level;
import java.util.stream.Collectors; import java.util.stream.Collectors;
public class P extends MPlugin { public class FactionsPlugin extends MPlugin {
// Our single plugin instance. // Our single plugin instance.
// Single 4 life. // Single 4 life.
public static P p; public static FactionsPlugin instance;
public static Permission perms = null; public static Permission perms = null;
// This plugin sets the boolean true when fully enabled. // This plugin sets the boolean true when fully enabled.
// Plugins can check this boolean while hooking in have // Plugins can check this boolean while hooking in have
@@ -83,10 +89,15 @@ public class P extends MPlugin {
private ClipPlaceholderAPIManager clipPlaceholderAPIManager; private ClipPlaceholderAPIManager clipPlaceholderAPIManager;
private boolean mvdwPlaceholderAPIManager = false; private boolean mvdwPlaceholderAPIManager = false;
private Listener[] eventsListener; private Listener[] eventsListener;
public List<String> itemList = getConfig().getStringList("fchest.Items-Not-Allowed");
public P() { public FactionsPlugin() {
p = this; instance = this;
}
public static FactionsPlugin getInstance() {
return instance;
} }
public boolean getLocked() { public boolean getLocked() {
@@ -139,29 +150,29 @@ public class P extends MPlugin {
// Vault dependency check. // Vault dependency check.
if (getServer().getPluginManager().getPlugin("Vault") == null) { if (getServer().getPluginManager().getPlugin("Vault") == null) {
log("Vault is not present, the plugin will not run properly."); log("Vault is not present, the plugin will not run properly.");
getServer().getPluginManager().disablePlugin(p); getServer().getPluginManager().disablePlugin(instance);
return; return;
} }
int version = Integer.parseInt(ReflectionUtils.PackageType.getServerVersion().split("_")[1]); int version = Integer.parseInt(ReflectionUtils.PackageType.getServerVersion().split("_")[1]);
switch (version) { switch (version) {
case 7: case 7:
P.p.log("Minecraft Version 1.7 found, disabling banners, itemflags inside GUIs, and Titles."); FactionsPlugin.instance.log("Minecraft Version 1.7 found, disabling banners, itemflags inside GUIs, and Titles.");
mc17 = true; mc17 = true;
break; break;
case 8: case 8:
P.p.log("Minecraft Version 1.8 found, Title Fadeouttime etc will not be configurable."); FactionsPlugin.instance.log("Minecraft Version 1.8 found, Title Fadeouttime etc will not be configurable.");
mc18 = true; mc18 = true;
break; break;
case 12: case 12:
mc112 = true; mc112 = true;
break; break;
case 13: case 13:
P.p.log("Minecraft Version 1.13 found, New Items will be used."); FactionsPlugin.instance.log("Minecraft Version 1.13 found, New Items will be used.");
mc113 = true; mc113 = true;
break; break;
case 14: case 14:
P.p.log("Minecraft Version 1.14 found."); FactionsPlugin.instance.log("Minecraft Version 1.14 found.");
mc114 = true; mc114 = true;
break; break;
} }
@@ -206,7 +217,6 @@ public class P extends MPlugin {
// Add Base Commands // Add Base Commands
this.cmdBase = new FCmdRoot(); this.cmdBase = new FCmdRoot();
this.cmdAutoHelp = new CmdAutoHelp(); this.cmdAutoHelp = new CmdAutoHelp();
this.getBaseCommands().add(cmdBase);
Econ.setup(); Econ.setup();
setupPermissions(); setupPermissions();
@@ -230,7 +240,7 @@ public class P extends MPlugin {
} }
if (getServer().getPluginManager().getPlugin("Skript") != null) { if (getServer().getPluginManager().getPlugin("Skript") != null) {
log("Skript was found! Registering P Addon..."); log("Skript was found! Registering FactionsPlugin Addon...");
skriptAddon = Skript.registerAddon(this); skriptAddon = Skript.registerAddon(this);
try { try {
skriptAddon.loadClasses("com.massivecraft.factions.skript", "expressions"); skriptAddon.loadClasses("com.massivecraft.factions.skript", "expressions");
@@ -249,6 +259,10 @@ public class P extends MPlugin {
this.getServer().getScheduler().runTaskTimer(this, CheckTask::cleanupTask, 0L, 1200L); this.getServer().getScheduler().runTaskTimer(this, CheckTask::cleanupTask, 0L, 1200L);
this.getServer().getScheduler().runTaskTimerAsynchronously(this, new WeeWooTask(this), 600L, 600L); this.getServer().getScheduler().runTaskTimerAsynchronously(this, new WeeWooTask(this), 600L, 600L);
} }
if(Conf.useDiscordSystem) {
new FactionChatHandler(this);
}
ShopConfig.setup(); ShopConfig.setup();
getServer().getPluginManager().registerEvents(factionsPlayerListener = new FactionsPlayerListener(), this); getServer().getPluginManager().registerEvents(factionsPlayerListener = new FactionsPlayerListener(), this);
@@ -260,25 +274,22 @@ public class P extends MPlugin {
new FactionsExploitListener(), new FactionsExploitListener(),
new FactionsBlockListener(), new FactionsBlockListener(),
new FUpgradesGUI(), new FUpgradesGUI(),
new EXPUpgrade(), new UpgradesListener(),
new CropUpgrades(),
new RedstoneUpgrade(),
new ShopClickPersistence(),
new MissionHandler(this), new MissionHandler(this),
new ChestLogsHandler(), new AntiChestListener(),
new SpawnerUpgrades() new ChestLogsHandler()
}; };
for (Listener eventListener : eventsListener) for (Listener eventListener : eventsListener)
getServer().getPluginManager().registerEvents(eventListener, this); getServer().getPluginManager().registerEvents(eventListener, this);
// since some other plugins execute commands directly through this command interface, provide it this.getCommand(refCommand).setExecutor(cmdBase);
getCommand(this.refCommand).setExecutor(this);
getCommand(this.refCommand).setTabCompleter(this); if (!CommodoreProvider.isSupported()) this.getCommand(refCommand).setTabCompleter(this);
RegisteredServiceProvider<Economy> rsp = P.this.getServer().getServicesManager().getRegistration(Economy.class); RegisteredServiceProvider<Economy> rsp = FactionsPlugin.this.getServer().getServicesManager().getRegistration(Economy.class);
P.econ = rsp.getProvider(); FactionsPlugin.econ = rsp.getProvider();
if (getDescription().getFullName().contains("BETA")) { if (getDescription().getFullName().contains("BETA")) {
divider(); divider();
@@ -292,7 +303,7 @@ public class P extends MPlugin {
this.postEnable(); this.postEnable();
this.loadSuccessful = true; this.loadSuccessful = true;
// Set startup finished to true. to give plugins hooking in a greenlight // Set startup finished to true. to give plugins hooking in a greenlight
P.startupFinished = true; FactionsPlugin.startupFinished = true;
} }
public SkriptAddon getSkriptAddon() { public SkriptAddon getSkriptAddon() {
@@ -411,7 +422,6 @@ public class P extends MPlugin {
if (this.loadSuccessful) { if (this.loadSuccessful) {
// Dont save, as this is kind of pointless, as the /f config command manually saves. // Dont save, as this is kind of pointless, as the /f config command manually saves.
// So any edits done are saved, this way manual edits to json can go through. // So any edits done are saved, this way manual edits to json can go through.
// Conf.save(); // Conf.save();
} }
@@ -419,7 +429,7 @@ public class P extends MPlugin {
this.getServer().getScheduler().cancelTask(AutoLeaveTask); this.getServer().getScheduler().cancelTask(AutoLeaveTask);
AutoLeaveTask = null; AutoLeaveTask = null;
} }
DiscordListener.saveGuilds();
super.onDisable(); super.onDisable();
} }
@@ -455,14 +465,14 @@ public class P extends MPlugin {
public ItemStack createLazyItem(Material material, int amount, short datavalue, String name, String lore) { public ItemStack createLazyItem(Material material, int amount, short datavalue, String name, String lore) {
ItemStack item = new ItemStack(material, amount, datavalue); ItemStack item = new ItemStack(material, amount, datavalue);
ItemMeta meta = item.getItemMeta(); ItemMeta meta = item.getItemMeta();
meta.setDisplayName(color(P.p.getConfig().getString(name))); meta.setDisplayName(color(FactionsPlugin.instance.getConfig().getString(name)));
meta.setLore(colorList(P.p.getConfig().getStringList(lore))); meta.setLore(colorList(FactionsPlugin.instance.getConfig().getStringList(lore)));
item.setItemMeta(meta); item.setItemMeta(meta);
return item; return item;
} }
public Economy getEcon() { public Economy getEcon() {
RegisteredServiceProvider<Economy> rsp = P.p.getServer().getServicesManager().getRegistration(Economy.class); RegisteredServiceProvider<Economy> rsp = FactionsPlugin.instance.getServer().getServicesManager().getRegistration(Economy.class);
return rsp.getProvider(); return rsp.getProvider();
} }
@@ -488,48 +498,62 @@ public class P extends MPlugin {
return handleCommand(sender, cmd + " " + TextUtil.implode(Arrays.asList(split), " "), false); return handleCommand(sender, cmd + " " + TextUtil.implode(Arrays.asList(split), " "), false);
} }
// This method must stay for < 1.12 versions
@Override @Override
public List<String> onTabComplete(CommandSender sender, Command command, String alias, String[] args) { public List<String> onTabComplete(CommandSender sender, Command command, String alias, String[] args) {
FPlayer fPlayer = FPlayers.getInstance().getByPlayer((Player) sender); // Must be a LinkedList to prevent UnsupportedOperationException.
List<String> completions = new ArrayList<>(); List<String> argsList = new LinkedList<>(Arrays.asList(args));
CommandContext context = new CommandContext(sender, argsList, alias);
String cmd = Conf.baseCommandAliases.isEmpty() ? "/f" : "/" + Conf.baseCommandAliases.get(0); String cmd = Conf.baseCommandAliases.isEmpty() ? "/f" : "/" + Conf.baseCommandAliases.get(0);
List<String> argsList = new ArrayList<>(Arrays.asList(args)); // String cmdValid = (cmd + " " + TextUtil.implode(context.args, " ")).trim();
argsList.remove(argsList.size() - 1); List<FCommand> commandsList = cmdBase.subCommands;
String cmdValid = (cmd + " " + TextUtil.implode(argsList, " ")).trim(); FCommand commandsEx = cmdBase;
MCommand<?> commandEx = cmdBase; List<String> completions = new ArrayList<>();
List<MCommand<?>> commandsList = cmdBase.subCommands;
for (; !commandsList.isEmpty() && !argsList.isEmpty(); argsList.remove(0)) { // Check for "" first arg because spigot is mangled.
String cmdName = argsList.get(0).toLowerCase(); if (context.args.get(0).equals("")) {
MCommand<?> commandFounded = commandsList.stream() for (FCommand subCommand : commandsEx.subCommands) {
.filter(c -> c.aliases.contains(cmdName)) if (subCommand.requirements.playerOnly && sender.hasPermission(subCommand.requirements.permission.node) && subCommand.visibility != CommandVisibility.INVISIBLE)
.findFirst().orElse(null);
if (commandFounded != null) {
commandEx = commandFounded;
commandsList = commandFounded.subCommands;
} else break;
}
if (argsList.isEmpty()) {
for (MCommand<?> subCommand : commandEx.subCommands) {
subCommand.setCommandSender(sender);
if (handleCommand(sender, cmdValid + " " + subCommand.aliases.get(0), true)
&& subCommand.visibility != CommandVisibility.INVISIBLE
&& subCommand.validSenderType(sender, false)
&& subCommand.validSenderPermissions(sender, false))
completions.addAll(subCommand.aliases); completions.addAll(subCommand.aliases);
} }
} return completions;
} else if (context.args.size() == 1) {
for (; !commandsList.isEmpty() && !context.args.isEmpty(); context.args.remove(0)) {
String cmdName = context.args.get(0).toLowerCase();
boolean toggle = false;
for (FCommand fCommand : commandsList) {
for (String s : fCommand.aliases) {
if (s.startsWith(cmdName)) {
commandsList = fCommand.subCommands;
completions.addAll(fCommand.aliases);
toggle = true;
break;
}
}
if (toggle) break;
}
}
String lastArg = args[args.length - 1].toLowerCase();
String lastArg = args[args.length - 1].toLowerCase(); completions = completions.stream()
for (Player player : Bukkit.getServer().getOnlinePlayers()) { .filter(m -> m.toLowerCase().startsWith(lastArg))
completions.add(player.getName()); .collect(Collectors.toList());
return completions;
} else {
String lastArg = args[args.length - 1].toLowerCase();
for (Role value : Role.values()) completions.add(value.nicename);
for (Relation value : Relation.values()) completions.add(value.nicename);
// The stream and foreach from the old implementation looped 2 times, by looping all players -> filtered -> looped filter and added -> filtered AGAIN at the end.
// This loops them once and just adds, because we are filtering the arguments at the end anyways
for (Player player : Bukkit.getServer().getOnlinePlayers()) completions.add(player.getName());
for (Faction faction : Factions.getInstance().getAllFactions())
completions.add(ChatColor.stripColor(faction.getTag()));
completions = completions.stream().filter(m -> m.toLowerCase().startsWith(lastArg)).collect(Collectors.toList());
return completions;
} }
completions = completions.stream()
.filter(m -> m.toLowerCase().startsWith(lastArg))
.collect(Collectors.toList());
return completions;
} }
public void createTimedHologram(final Location location, String text, Long timeout) { public void createTimedHologram(final Location location, String text, Long timeout) {
@@ -537,11 +561,11 @@ public class P extends MPlugin {
as.setVisible(false); //Makes the ArmorStand invisible as.setVisible(false); //Makes the ArmorStand invisible
as.setGravity(false); //Make sure it doesn't fall as.setGravity(false); //Make sure it doesn't fall
as.setCanPickupItems(false); //I'm not sure what happens if you leave this as it is, but you might as well disable it as.setCanPickupItems(false); //I'm not sure what happens if you leave this as it is, but you might as well disable it
as.setCustomName(P.p.color(text)); //Set this to the text you want as.setCustomName(FactionsPlugin.instance.color(text)); //Set this to the text you want
as.setCustomNameVisible(true); //This makes the text appear no matter if your looking at the entity or not as.setCustomNameVisible(true); //This makes the text appear no matter if your looking at the entity or not
final ArmorStand armorStand = as; final ArmorStand armorStand = as;
Bukkit.getScheduler().scheduleSyncDelayedTask(P.p, () -> { Bukkit.getScheduler().scheduleSyncDelayedTask(FactionsPlugin.instance, () -> {
armorStand.remove(); armorStand.remove();
getLogger().info("Removing Hologram."); getLogger().info("Removing Hologram.");
} }

View File

@@ -0,0 +1,92 @@
package com.massivecraft.factions.cmd;
import com.massivecraft.factions.FactionsPlugin;
import com.mojang.brigadier.arguments.StringArgumentType;
import com.mojang.brigadier.builder.LiteralArgumentBuilder;
import com.mojang.brigadier.builder.RequiredArgumentBuilder;
import com.mojang.brigadier.tree.CommandNode;
import me.lucko.commodore.Commodore;
import me.lucko.commodore.CommodoreProvider;
import java.lang.reflect.Constructor;
import java.util.ArrayList;
import java.util.List;
import java.util.Map;
public class BrigadierManager {
public Commodore commodore;
public LiteralArgumentBuilder<Object> brigadier = LiteralArgumentBuilder.literal("factions");
public BrigadierManager() {
commodore = CommodoreProvider.getCommodore(FactionsPlugin.getInstance());
}
public void build() {
commodore.register(brigadier.build());
// Add factions children to f alias
LiteralArgumentBuilder<Object> fLiteral = LiteralArgumentBuilder.literal("f");
for (CommandNode<Object> node : brigadier.getArguments()) fLiteral.then(node);
commodore.register(fLiteral.build());
}
public void addSubCommand(FCommand subCommand) {
// Register brigadier to all command aliases
for (String alias : subCommand.aliases) {
LiteralArgumentBuilder<Object> literal = LiteralArgumentBuilder.literal(alias);
if (subCommand.requirements.brigadier != null) {
// If the requirements explicitly provide a BrigadierProvider then use it
Class<? extends BrigadierProvider> brigadierProvider = subCommand.requirements.brigadier;
try {
Constructor<? extends BrigadierProvider> constructor = brigadierProvider.getDeclaredConstructor(subCommand.getClass());
brigadier.then(constructor.newInstance(subCommand).get(literal));
} catch (Exception e) {
e.printStackTrace();
}
} else {
// Generate our own based on args - quite ugly
// We create an orderly stack of all args, required and optional, format them differently
List<RequiredArgumentBuilder<Object, ?>> stack = new ArrayList<>();
for (String required : subCommand.requiredArgs) {
// Simply add the arg name as required
stack.add(RequiredArgumentBuilder.argument(required, StringArgumentType.word()));
}
for (Map.Entry<String, String> optionalEntry : subCommand.optionalArgs.entrySet()) {
RequiredArgumentBuilder<Object, ?> optional;
// Optional without default
if (optionalEntry.getKey().equalsIgnoreCase(optionalEntry.getValue())) {
optional = RequiredArgumentBuilder.argument(":" + optionalEntry.getKey(), StringArgumentType.word());
// Optional with default, explain
} else {
optional = RequiredArgumentBuilder.argument(optionalEntry.getKey() + "|" + optionalEntry.getValue(), StringArgumentType.word());
}
stack.add(optional);
}
// Reverse the stack and apply .then()
RequiredArgumentBuilder<Object, ?> previous = null;
for (int i = stack.size() - 1; i >= 0; i--) {
if (previous == null) {
previous = stack.get(i);
} else {
previous = stack.get(i).then(previous);
}
}
if (previous == null) {
brigadier.then(literal);
} else {
brigadier.then(literal.then(previous));
}
}
}
}
}

View File

@@ -0,0 +1,9 @@
package com.massivecraft.factions.cmd;
import com.mojang.brigadier.builder.ArgumentBuilder;
public interface BrigadierProvider {
ArgumentBuilder<Object, ?> get(ArgumentBuilder<Object, ?> parent);
}

View File

@@ -12,23 +12,17 @@ public class CmdAHome extends FCommand {
super(); super();
this.aliases.add("ahome"); this.aliases.add("ahome");
this.requiredArgs.add("player name"); this.requiredArgs.add("player");
this.permission = Permission.AHOME.node; this.requirements = new CommandRequirements.Builder(Permission.AHOME).noDisableOnLock().build();
this.disableOnLock = false;
this.disableOnSpam = false;
senderMustBePlayer = false;
senderMustBeMember = false;
senderMustBeModerator = false;
senderMustBeAdmin = false;
} }
@Override @Override
public void perform() { public void perform(CommandContext context) {
FPlayer target = argAsBestFPlayerMatch(0); FPlayer target = context.argAsBestFPlayerMatch(0);
if (target == null) { if (target == null) {
msg(TL.GENERIC_NOPLAYERMATCH, argAsString(0)); context.msg(TL.GENERIC_NOPLAYERMATCH, context.argAsString(0));
return; return;
} }
@@ -36,13 +30,13 @@ public class CmdAHome extends FCommand {
Faction faction = target.getFaction(); Faction faction = target.getFaction();
if (faction.hasHome()) { if (faction.hasHome()) {
target.getPlayer().teleport(faction.getHome(), PlayerTeleportEvent.TeleportCause.PLUGIN); target.getPlayer().teleport(faction.getHome(), PlayerTeleportEvent.TeleportCause.PLUGIN);
msg(TL.COMMAND_AHOME_SUCCESS, target.getName()); context.msg(TL.COMMAND_AHOME_SUCCESS, target.getName());
target.msg(TL.COMMAND_AHOME_TARGET); target.msg(TL.COMMAND_AHOME_TARGET);
} else { } else {
msg(TL.COMMAND_AHOME_NOHOME, target.getName()); context.msg(TL.COMMAND_AHOME_NOHOME, target.getName());
} }
} else { } else {
msg(TL.COMMAND_AHOME_OFFLINE, target.getName()); context.msg(TL.COMMAND_AHOME_OFFLINE, target.getName());
} }
} }
@@ -50,4 +44,4 @@ public class CmdAHome extends FCommand {
public TL getUsageTranslation() { public TL getUsageTranslation() {
return TL.COMMAND_AHOME_DESCRIPTION; return TL.COMMAND_AHOME_DESCRIPTION;
} }
} }

View File

@@ -8,7 +8,6 @@ import com.massivecraft.factions.struct.Permission;
import com.massivecraft.factions.struct.Role; import com.massivecraft.factions.struct.Role;
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;
public class CmdAdmin extends FCommand { public class CmdAdmin extends FCommand {
@@ -19,52 +18,39 @@ public class CmdAdmin extends FCommand {
this.aliases.add("leader"); this.aliases.add("leader");
this.aliases.add("setleader"); this.aliases.add("setleader");
this.requiredArgs.add("player name"); this.requiredArgs.add("player");
this.permission = Permission.ADMIN.node; this.requirements = new CommandRequirements.Builder(Permission.ADMIN).build();
this.disableOnLock = true;
this.disableOnSpam = true;
senderMustBePlayer = false;
senderMustBeMember = false;
senderMustBeModerator = false;
senderMustBeAdmin = false;
} }
@Override @Override
public void perform() { public void perform(CommandContext context) {
FPlayer fyou = this.argAsBestFPlayerMatch(0); // Allows admins bypass this.
if (fyou == null || fyou.getFaction().isWarZone() || fyou.getFaction().isWilderness() || fyou.getFaction().isSafeZone()) { if (!context.fPlayer.isAdminBypassing() && !context.fPlayer.getRole().equals(Role.LEADER)) {
context.msg(TL.COMMAND_ADMIN_NOTADMIN);
return;
}
FPlayer fyou = context.argAsBestFPlayerMatch(0);
if (fyou == null) {
return; return;
} }
boolean permAny = Permission.ADMIN_ANY.has(sender, false); boolean permAny = Permission.ADMIN_ANY.has(context.sender, false);
Faction targetFaction = fyou.getFaction(); Faction targetFaction = fyou.getFaction();
if (fyou.isAlt()) { if (targetFaction != context.faction && !permAny) {
msg(ChatColor.RED + "You can not promote alt accounts."); context.msg(TL.COMMAND_ADMIN_NOTMEMBER, fyou.describeTo(context.fPlayer, true));
return; return;
} }
if (targetFaction != myFaction && !permAny) { if (fyou == context.fPlayer && !permAny) {
msg(TL.COMMAND_ADMIN_NOTMEMBER, fyou.describeTo(fme, true)); context.msg(TL.COMMAND_ADMIN_TARGETSELF);
return;
}
if (fme != null && fme.getRole() != Role.LEADER && !permAny) {
msg(TL.COMMAND_ADMIN_NOTADMIN);
return;
}
if (fyou == fme && !permAny) {
msg(TL.COMMAND_ADMIN_TARGETSELF);
return; return;
} }
// only perform a FPlayerJoinEvent when newLeader isn't actually in the faction // only perform a FPlayerJoinEvent when newLeader isn't actually in the faction
if (fyou.getFaction() != targetFaction) { if (fyou.getFaction() != targetFaction) {
FPlayerJoinEvent event = new FPlayerJoinEvent(FPlayers.getInstance().getByPlayer(me), targetFaction, FPlayerJoinEvent.PlayerJoinReason.LEADER); FPlayerJoinEvent event = new FPlayerJoinEvent(FPlayers.getInstance().getByPlayer(context.player), targetFaction, FPlayerJoinEvent.PlayerJoinReason.LEADER);
Bukkit.getServer().getPluginManager().callEvent(event); Bukkit.getServer().getPluginManager().callEvent(event);
if (event.isCancelled()) { if (event.isCancelled()) {
return; return;
@@ -73,16 +59,11 @@ public class CmdAdmin extends FCommand {
FPlayer admin = targetFaction.getFPlayerAdmin(); FPlayer admin = targetFaction.getFPlayerAdmin();
if (fyou == admin && fyou.getFaction().getSize() == 1) {
msg(TL.COMMAND_ADMIN_NOMEMBERS);
return;
}
// if target player is currently admin, demote and replace him // if target player is currently admin, demote and replace him
if (fyou == admin) { if (fyou == admin) {
targetFaction.promoteNewLeader(); targetFaction.promoteNewLeader();
msg(TL.COMMAND_ADMIN_DEMOTES, fyou.describeTo(fme, true)); context.msg(TL.COMMAND_ADMIN_DEMOTES, fyou.describeTo(context.fPlayer, true));
fyou.msg(TL.COMMAND_ADMIN_DEMOTED, senderIsConsole ? TL.GENERIC_SERVERADMIN.toString() : fme.describeTo(fyou, true)); fyou.msg(TL.COMMAND_ADMIN_DEMOTED, context.player == null ? TL.GENERIC_SERVERADMIN.toString() : context.fPlayer.describeTo(fyou, true));
return; return;
} }
@@ -91,11 +72,11 @@ public class CmdAdmin extends FCommand {
admin.setRole(Role.COLEADER); admin.setRole(Role.COLEADER);
} }
fyou.setRole(Role.LEADER); fyou.setRole(Role.LEADER);
msg(TL.COMMAND_ADMIN_PROMOTES, fyou.describeTo(fme, true)); context.msg(TL.COMMAND_ADMIN_PROMOTES, fyou.describeTo(context.fPlayer, true));
// Inform all players // Inform all players
for (FPlayer fplayer : FPlayers.getInstance().getOnlinePlayers()) { for (FPlayer fplayer : FPlayers.getInstance().getOnlinePlayers()) {
fplayer.msg(TL.COMMAND_ADMIN_PROMOTED, senderIsConsole ? TL.GENERIC_SERVERADMIN.toString() : fme.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));
} }
} }

View File

@@ -3,6 +3,9 @@ package com.massivecraft.factions.cmd;
import com.massivecraft.factions.FPlayer; import com.massivecraft.factions.FPlayer;
import com.massivecraft.factions.struct.Permission; import com.massivecraft.factions.struct.Permission;
import com.massivecraft.factions.zcore.util.TL; import com.massivecraft.factions.zcore.util.TL;
import com.mojang.brigadier.arguments.StringArgumentType;
import com.mojang.brigadier.builder.ArgumentBuilder;
import com.mojang.brigadier.builder.RequiredArgumentBuilder;
import org.apache.commons.lang.StringUtils; import org.apache.commons.lang.StringUtils;
import org.bukkit.ChatColor; import org.bukkit.ChatColor;
import org.bukkit.entity.Player; import org.bukkit.entity.Player;
@@ -15,30 +18,27 @@ public class CmdAnnounce extends FCommand {
this.aliases.add("announce"); this.aliases.add("announce");
this.requiredArgs.add("message"); this.requiredArgs.add("message");
this.errorOnToManyArgs = false;
this.permission = Permission.ANNOUNCE.node; this.requirements = new CommandRequirements.Builder(Permission.ANNOUNCE)
this.disableOnLock = false; .playerOnly()
this.disableOnSpam = false; .memberOnly()
.brigadier(AnnounceBrigadier.class)
senderMustBePlayer = true; .noErrorOnManyArgs()
senderMustBeMember = true; .build();
senderMustBeModerator = false;
senderMustBeColeader = false;
} }
@Override @Override
public void perform() { public void perform(CommandContext context) {
String prefix = ChatColor.GREEN + myFaction.getTag() + ChatColor.YELLOW + " [" + ChatColor.GRAY + me.getName() + ChatColor.YELLOW + "] " + ChatColor.RESET; String prefix = ChatColor.GREEN + context.faction.getTag() + ChatColor.YELLOW + " [" + ChatColor.GRAY + context.player.getName() + ChatColor.YELLOW + "] " + ChatColor.RESET;
String message = StringUtils.join(args, " "); String message = StringUtils.join(context.args, " ");
for (Player player : myFaction.getOnlinePlayers()) { for (Player player : context.faction.getOnlinePlayers()) {
player.sendMessage(prefix + message); player.sendMessage(prefix + message);
} }
// Add for offline players. // Add for offline players.
for (FPlayer fp : myFaction.getFPlayersWhereOnline(false)) { for (FPlayer fp : context.faction.getFPlayersWhereOnline(false)) {
myFaction.addAnnouncement(fp, prefix + message); context.faction.addAnnouncement(fp, prefix + message);
} }
} }
@@ -47,4 +47,11 @@ public class CmdAnnounce extends FCommand {
return TL.COMMAND_ANNOUNCE_DESCRIPTION; return TL.COMMAND_ANNOUNCE_DESCRIPTION;
} }
} protected class AnnounceBrigadier implements BrigadierProvider {
@Override
public ArgumentBuilder<Object, ?> get(ArgumentBuilder<Object, ?> parent) {
return parent.then(RequiredArgumentBuilder.argument("message", StringArgumentType.greedyString()));
}
}
}

View File

@@ -1,16 +1,14 @@
package com.massivecraft.factions.cmd; package com.massivecraft.factions.cmd;
import com.massivecraft.factions.P; import com.massivecraft.factions.FactionsPlugin;
import com.massivecraft.factions.zcore.CommandVisibility; import com.massivecraft.factions.zcore.CommandVisibility;
import com.massivecraft.factions.zcore.MCommand;
import com.massivecraft.factions.zcore.util.TL; import com.massivecraft.factions.zcore.util.TL;
import java.util.ArrayList; import java.util.ArrayList;
public class CmdAutoHelp extends MCommand<P> { public class CmdAutoHelp extends FCommand {
public CmdAutoHelp() { public CmdAutoHelp() {
super(P.p);
this.aliases.add("?"); this.aliases.add("?");
this.aliases.add("h"); this.aliases.add("h");
this.aliases.add("help"); this.aliases.add("help");
@@ -21,22 +19,22 @@ public class CmdAutoHelp extends MCommand<P> {
} }
@Override @Override
public void perform() { public void perform(CommandContext context) {
if (context.commandChain.size() == 0) {
if (this.commandChain.size() == 0) {
return; return;
} }
MCommand<?> pcmd = this.commandChain.get(this.commandChain.size() - 1); FCommand pcmd = context.commandChain.get(context.commandChain.size() - 1);
ArrayList<String> lines = new ArrayList<>(pcmd.helpLong); ArrayList<String> lines = new ArrayList<>(pcmd.helpLong);
for (MCommand<?> scmd : pcmd.subCommands) { for (FCommand scmd : pcmd.subCommands) {
if (scmd.visibility == CommandVisibility.VISIBLE || (scmd.visibility == CommandVisibility.SECRET && scmd.validSenderPermissions(sender, false))) { if (scmd.visibility == CommandVisibility.VISIBLE) {
lines.add(scmd.getUseageTemplate(this.commandChain, true)); lines.add(scmd.getUsageTemplate(context, true));
} }
// TODO deal with other visibilities
} }
sendMessage(p.txt.getPage(lines, this.argAsInt(0, 1), TL.COMMAND_AUTOHELP_HELPFOR.toString() + pcmd.aliases.get(0) + "\"")); context.sendMessage(FactionsPlugin.getInstance().txt.getPage(lines, context.argAsInt(0, 1), TL.COMMAND_AUTOHELP_HELPFOR.toString() + pcmd.aliases.get(0) + "\""));
} }
@Override @Override

View File

@@ -1,12 +1,10 @@
package com.massivecraft.factions.cmd; package com.massivecraft.factions.cmd;
import com.massivecraft.factions.FPlayer; import com.massivecraft.factions.FPlayer;
import com.massivecraft.factions.P; import com.massivecraft.factions.FactionsPlugin;
import com.massivecraft.factions.event.FPlayerLeaveEvent; import com.massivecraft.factions.event.FPlayerLeaveEvent;
import com.massivecraft.factions.struct.BanInfo; import com.massivecraft.factions.struct.BanInfo;
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 org.bukkit.Bukkit; import org.bukkit.Bukkit;
@@ -21,78 +19,63 @@ public class CmdBan extends FCommand {
this.requiredArgs.add("target"); this.requiredArgs.add("target");
this.permission = Permission.BAN.node; this.requirements = new CommandRequirements.Builder(Permission.BAN)
this.disableOnLock = true; .playerOnly()
this.disableOnSpam = false; .withAction(PermissableAction.BAN)
.build();
senderMustBePlayer = true;
senderMustBeMember = false;
senderMustBeModerator = false;
senderMustBeColeader = false;
senderMustBeAdmin = false;
} }
@Override @Override
public void perform() { public void perform(CommandContext context) {
// Adds bypass to admins and clean permission check
if (!fme.isAdminBypassing()) {
Access access = myFaction.getAccess(fme, PermissableAction.BAN);
if (access != Access.ALLOW && fme.getRole() != Role.LEADER) {
fme.msg(TL.GENERIC_FPERM_NOPERMISSION, "ban");
return;
}
}
// Good on permission checks. Now lets just ban the player. // Good on permission checks. Now lets just ban the player.
FPlayer target = argAsFPlayer(0); FPlayer target = context.argAsFPlayer(0);
if (target == null) { if (target == null) {
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 (fme == target) { if (context.fPlayer == target) {
// You may not ban yourself // You may not ban yourself
fme.msg(TL.COMMAND_BAN_SELF); context.msg(TL.COMMAND_BAN_SELF);
return; return;
} else if (target.getFaction() == myFaction && target.getRole().value >= fme.getRole().value) { } else if (target.getFaction() == context.faction && target.getRole().value >= context.fPlayer.getRole().value) {
// You may not ban someone that has same or higher faction rank // You may not ban someone that has same or higher faction rank
fme.msg(TL.COMMAND_BAN_INSUFFICIENTRANK, target.getName()); context.msg(TL.COMMAND_BAN_INSUFFICIENTRANK, target.getName());
return; return;
} }
for (BanInfo banInfo : myFaction.getBannedPlayers()) { for (BanInfo banInfo : context.faction.getBannedPlayers()) {
if (banInfo.getBanned().equals(target.getId())) { if (banInfo.getBanned().equals(target.getId())) {
msg(TL.COMMAND_BAN_ALREADYBANNED); context.msg(TL.COMMAND_BAN_ALREADYBANNED);
return; return;
} }
} }
// Ban the user. // Ban the user.
myFaction.ban(target, fme); context.faction.ban(target, context.fPlayer);
myFaction.deinvite(target); // can't hurt context.faction.deinvite(target); // can't hurt
// If in same Faction, lets make sure to kick them and throw an event. // If in same Faction, lets make sure to kick them and throw an event.
if (target.getFaction() == myFaction) { if (target.getFaction() == context.faction) {
FPlayerLeaveEvent event = new FPlayerLeaveEvent(target, myFaction, FPlayerLeaveEvent.PlayerLeaveReason.BANNED); FPlayerLeaveEvent event = new FPlayerLeaveEvent(target, context.faction, FPlayerLeaveEvent.PlayerLeaveReason.BANNED);
Bukkit.getServer().getPluginManager().callEvent(event); Bukkit.getServer().getPluginManager().callEvent(event);
if (event.isCancelled()) { if (event.isCancelled()) {
// if someone cancels a ban, we'll get people complaining here. So lets log it. // if someone cancels a ban, we'll get people complaining here. So lets log it.
P.p.log(Level.WARNING, "Attempted to ban {0} but someone cancelled the kick event. This isn't good.", target.getName()); FactionsPlugin.getInstance().log(Level.WARNING, "Attempted to ban {0} but someone cancelled the kick event. This isn't good.", target.getName());
return; return;
} }
// Didn't get cancelled so remove them and reset their invite. // Didn't get cancelled so remove them and reset their invite.
myFaction.removeFPlayer(target); context.faction.removeFPlayer(target);
target.resetFactionData(); target.resetFactionData();
} }
// Lets inform the people! // Lets inform the people!
target.msg(TL.COMMAND_BAN_TARGET, myFaction.getTag(target.getFaction())); target.msg(TL.COMMAND_BAN_TARGET, context.faction.getTag(target.getFaction()));
myFaction.msg(TL.COMMAND_BAN_BANNED, fme.getName(), target.getName()); context.faction.msg(TL.COMMAND_BAN_BANNED, context.fPlayer.getName(), target.getName());
} }
@Override @Override

View File

@@ -21,35 +21,31 @@ public class CmdBanlist extends FCommand {
this.optionalArgs.put("faction", "faction"); this.optionalArgs.put("faction", "faction");
this.permission = Permission.BAN.node; this.requirements = new CommandRequirements.Builder(Permission.BAN)
this.disableOnLock = true; .playerOnly()
this.disableOnSpam = false; .memberOnly()
.build();
senderMustBePlayer = true;
senderMustBeMember = false;
senderMustBeModerator = false;
senderMustBeAdmin = false;
} }
@Override @Override
public void perform() { public void perform(CommandContext context) {
Faction target = myFaction; Faction target = context.faction;
if (!args.isEmpty()) { if (!context.args.isEmpty()) {
target = argAsFaction(0); target = context.argAsFaction(0);
} }
if (target == Factions.getInstance().getWilderness()) { if (target == Factions.getInstance().getWilderness()) {
sender.sendMessage(TL.COMMAND_BANLIST_NOFACTION.toString()); context.sender.sendMessage(TL.COMMAND_BANLIST_NOFACTION.toString());
return; return;
} }
if (target == null) { if (target == null) {
sender.sendMessage(TL.COMMAND_BANLIST_INVALID.format(argAsString(0))); context.sender.sendMessage(TL.COMMAND_BANLIST_INVALID.format(context.argAsString(0)));
return; return;
} }
List<String> lines = new ArrayList<>(); List<String> lines = new ArrayList<>();
lines.add(TL.COMMAND_BANLIST_HEADER.format(target.getBannedPlayers().size(), target.getTag(myFaction))); lines.add(TL.COMMAND_BANLIST_HEADER.format(target.getBannedPlayers().size(), target.getTag(context.faction)));
int i = 1; int i = 1;
for (BanInfo info : target.getBannedPlayers()) { for (BanInfo info : target.getBannedPlayers()) {
@@ -62,7 +58,7 @@ public class CmdBanlist extends FCommand {
} }
for (String s : lines) { for (String s : lines) {
fme.sendMessage(s); context.fPlayer.getPlayer().sendMessage(s);
} }
} }

View File

@@ -1,9 +1,8 @@
package com.massivecraft.factions.cmd; package com.massivecraft.factions.cmd;
import com.massivecraft.factions.FPlayer; import com.massivecraft.factions.FPlayer;
import com.massivecraft.factions.P; import com.massivecraft.factions.FactionsPlugin;
import com.massivecraft.factions.struct.Permission; import com.massivecraft.factions.struct.Permission;
import com.massivecraft.factions.util.XMaterial;
import com.massivecraft.factions.zcore.util.TL; import com.massivecraft.factions.zcore.util.TL;
import net.milkbowl.vault.economy.Economy; import net.milkbowl.vault.economy.Economy;
import org.bukkit.Material; import org.bukkit.Material;
@@ -15,67 +14,50 @@ import org.bukkit.inventory.meta.ItemMeta;
public class CmdBanner extends FCommand { public class CmdBanner extends FCommand {
public CmdBanner() { public CmdBanner() {
super();
this.aliases.add("banner"); this.aliases.add("banner");
this.aliases.add("warbanner"); this.aliases.add("warbanner");
this.requirements = new CommandRequirements.Builder(Permission.BANNER).playerOnly().memberOnly().build();
this.permission = Permission.BANNER.node;
this.disableOnLock = false;
senderMustBePlayer = true;
senderMustBeMember = false;
senderMustBeModerator = false;
senderMustBeColeader = true;
senderMustBeAdmin = false;
} }
@Override @Override
public void perform() { public void perform(CommandContext context) {
if (!P.p.getConfig().getBoolean("fbanners.Enabled")) { if (!FactionsPlugin.getInstance().getConfig().getBoolean("fbanners.Enabled")) {
msg(TL.COMMAND_BANNER_DISABLED); context.msg(TL.COMMAND_BANNER_DISABLED);
return; return;
} }
if (!fme.hasMoney(P.p.getConfig().getInt("fbanners.Banner-Cost", 5000))) { if (context.faction.getBanner() == null) {
msg(TL.COMMAND_BANNER_NOTENOUGHMONEY); context.msg(TL.COMMAND_BANNER_NOBANNER);
return; return;
} }
takeMoney(fme, P.p.getConfig().getInt("fbanners.Banner-Cost", 5000)); if (!context.fPlayer.hasMoney(FactionsPlugin.getInstance().getConfig().getInt("fbanners.Banner-Cost", 5000))) {
context.msg(TL.COMMAND_BANNER_NOTENOUGHMONEY);
//ItemStack warBanner = P.p.createItem(Material.BANNER, 1, (short) 1, P.p.getConfig().getString("fbanners.Item.Name"), P.p.getConfig().getStringList("fbanners.Item.Lore")); return;
//BannerMeta bannerMeta = (BannerMeta) warBanner.getItemMeta();
ItemStack warBanner = fme.getFaction().getBanner();
if (warBanner != null) {
ItemMeta warmeta = warBanner.getItemMeta();
warmeta.setDisplayName(P.p.color(P.p.getConfig().getString("fbanners.Item.Name")));
warmeta.setLore(P.p.colorList(P.p.getConfig().getStringList("fbanners.Item.Lore")));
warBanner.setItemMeta(warmeta);
} else {
warBanner = P.p.createItem(XMaterial.BLACK_BANNER.parseMaterial(), 1, (short) 1, P.p.getConfig().getString("fbanners.Item.Name"), P.p.getConfig().getStringList("fbanners.Item.Lore"));
} }
fme.msg(TL.COMMAND_BANNER_SUCCESS); this.takeMoney(context.fPlayer, FactionsPlugin.getInstance().getConfig().getInt("fbanners.Banner-Cost", 5000));
this.takeMoney(context.fPlayer, FactionsPlugin.getInstance().getConfig().getInt("fbanners.Banner-Cost", 5000));
ItemStack warBanner = context.fPlayer.getFaction().getBanner();
ItemMeta warmeta = warBanner.getItemMeta();
warmeta.setDisplayName(FactionsPlugin.getInstance().color(FactionsPlugin.getInstance().getConfig().getString("fbanners.Item.Name")));
warmeta.setLore(FactionsPlugin.getInstance().colorList(FactionsPlugin.getInstance().getConfig().getStringList("fbanners.Item.Lore")));
warBanner.setItemMeta(warmeta);
context.msg(TL.COMMAND_BANNER_SUCCESS);
warBanner.setAmount(1); warBanner.setAmount(1);
me.getInventory().addItem(warBanner); context.player.getInventory().addItem(warBanner);
} }
public boolean hasMoney(FPlayer fme, int amt) { public boolean hasMoney(FPlayer fme, int amt) {
Economy econ = P.p.getEcon(); Economy econ = FactionsPlugin.getInstance().getEcon();
if (econ.getBalance(fme.getPlayer()) >= amt) { if (econ.getBalance(fme.getPlayer()) >= amt) {
return true; return true;
} else {
fme.msg(TL.COMMAND_BANNER_NOTENOUGHMONEY);
return false;
} }
fme.msg(TL.COMMAND_BANNER_NOTENOUGHMONEY);
return false;
} }
public void takeMoney(FPlayer fme, int amt) { public void takeMoney(FPlayer fme, int amt) {
if (hasMoney(fme, amt)) { if (this.hasMoney(fme, amt)) {
Economy econ = P.p.getEcon(); Economy econ = FactionsPlugin.getInstance().getEcon();
econ.withdrawPlayer(fme.getPlayer(), amt); econ.withdrawPlayer(fme.getPlayer(), (double) amt);
fme.sendMessage(TL.COMMAND_BANNER_MONEYTAKE.toString().replace("{amount}", amt + "")); fme.sendMessage(TL.COMMAND_BANNER_MONEYTAKE.toString().replace("{amount}", amt + ""));
} }
} }
@@ -83,9 +65,9 @@ public class CmdBanner extends FCommand {
public boolean inventoryContains(Inventory inventory, ItemStack item) { public boolean inventoryContains(Inventory inventory, ItemStack item) {
int count = 0; int count = 0;
ItemStack[] items = inventory.getContents(); ItemStack[] items = inventory.getContents();
for (int i = 0; i < items.length; i++) { for (ItemStack item1 : items) {
if (items[i] != null && items[i].getType() == item.getType() && items[i].getDurability() == item.getDurability()) { if (item1 != null && item1.getType() == item.getType() && item1.getDurability() == item.getDurability()) {
count += items[i].getAmount(); count += item1.getAmount();
} }
if (count >= item.getAmount()) { if (count >= item.getAmount()) {
return true; return true;
@@ -94,22 +76,21 @@ public class CmdBanner extends FCommand {
return false; return false;
} }
public void removeFromInventory(Inventory inventory, ItemStack item) { public void removeFromInventory(Inventory inventory, ItemStack item) {
int amt = item.getAmount(); int amt = item.getAmount();
ItemStack[] items = inventory.getContents(); ItemStack[] items = inventory.getContents();
for (int i = 0; i < items.length; i++) { for (int i = 0; i < items.length; ++i) {
if (items[i] != null && items[i].getType() == item.getType() && items[i].getDurability() == item.getDurability()) { if (items[i] != null && items[i].getType() == item.getType() && items[i].getDurability() == item.getDurability()) {
if (items[i].getAmount() > amt) { if (items[i].getAmount() > amt) {
items[i].setAmount(items[i].getAmount() - amt); items[i].setAmount(items[i].getAmount() - amt);
break; break;
} else if (items[i].getAmount() == amt) { }
if (items[i].getAmount() == amt) {
items[i] = null; items[i] = null;
break; break;
} else {
amt -= items[i].getAmount();
items[i] = null;
} }
amt -= items[i].getAmount();
items[i] = null;
} }
} }
inventory.setContents(items); inventory.setContents(items);
@@ -119,14 +100,14 @@ public class CmdBanner extends FCommand {
PlayerInventory inventory = p.getInventory(); PlayerInventory inventory = p.getInventory();
ItemStack[] cont = inventory.getContents(); ItemStack[] cont = inventory.getContents();
int i = 0; int i = 0;
for (ItemStack item : cont) for (ItemStack item : cont) {
if (item != null && item.getType() != Material.AIR) { if (item != null && item.getType() != Material.AIR) {
i++; ++i;
} }
}
return 36 - i; return 36 - i;
} }
@Override @Override
public TL getUsageTranslation() { public TL getUsageTranslation() {
return TL.COMMAND_BANNER_DESCRIPTION; return TL.COMMAND_BANNER_DESCRIPTION;

View File

@@ -15,34 +15,29 @@ public class CmdBoom extends FCommand {
//this.requiredArgs.add(""); //this.requiredArgs.add("");
this.optionalArgs.put("on/off", "flip"); this.optionalArgs.put("on/off", "flip");
this.permission = Permission.NO_BOOM.node; this.requirements = new CommandRequirements.Builder(Permission.NO_BOOM)
this.disableOnLock = true; .playerOnly()
.build();
senderMustBePlayer = true;
senderMustBeMember = false;
senderMustBeModerator = false;
senderMustBeColeader = true;
senderMustBeAdmin = false;
} }
@Override @Override
public void perform() { public void perform(CommandContext context) {
if (!myFaction.isPeaceful()) { if (!context.faction.isPeaceful()) {
fme.msg(TL.COMMAND_BOOM_PEACEFULONLY); context.msg(TL.COMMAND_BOOM_PEACEFULONLY);
return; return;
} }
// if economy is enabled, they're not on the bypass list, and this command has a cost set, make 'em pay // if economy is enabled, they're not on the bypass list, and this command has a cost set, make 'em pay
if (!payForCommand(Conf.econCostNoBoom, TL.COMMAND_BOOM_TOTOGGLE, TL.COMMAND_BOOM_FORTOGGLE)) { if (!context.payForCommand(Conf.econCostNoBoom, TL.COMMAND_BOOM_TOTOGGLE, TL.COMMAND_BOOM_FORTOGGLE)) {
return; return;
} }
myFaction.setPeacefulExplosionsEnabled(this.argAsBool(0, !myFaction.getPeacefulExplosionsEnabled())); context.faction.setPeacefulExplosionsEnabled(context.argAsBool(0, !context.faction.getPeacefulExplosionsEnabled()));
String enabled = myFaction.noExplosionsInTerritory() ? TL.GENERIC_DISABLED.toString() : TL.GENERIC_ENABLED.toString(); String enabled = context.faction.noExplosionsInTerritory() ? TL.GENERIC_DISABLED.toString() : TL.GENERIC_ENABLED.toString();
// Inform // Inform
myFaction.msg(TL.COMMAND_BOOM_ENABLED, fme.describeTo(myFaction), enabled); context.faction.msg(TL.COMMAND_BOOM_ENABLED, context.fPlayer.describeTo(context.faction), enabled);
} }
@Override @Override

View File

@@ -1,6 +1,6 @@
package com.massivecraft.factions.cmd; package com.massivecraft.factions.cmd;
import com.massivecraft.factions.P; import com.massivecraft.factions.FactionsPlugin;
import com.massivecraft.factions.struct.Permission; import com.massivecraft.factions.struct.Permission;
import com.massivecraft.factions.zcore.util.TL; import com.massivecraft.factions.zcore.util.TL;
@@ -13,27 +13,22 @@ public class CmdBypass extends FCommand {
//this.requiredArgs.add(""); //this.requiredArgs.add("");
this.optionalArgs.put("on/off", "flip"); this.optionalArgs.put("on/off", "flip");
this.permission = Permission.BYPASS.node; this.requirements = new CommandRequirements.Builder(Permission.BYPASS)
this.disableOnLock = false; .playerOnly()
.build();
senderMustBePlayer = true;
senderMustBeMember = false;
senderMustBeModerator = false;
senderMustBeColeader = false;
senderMustBeAdmin = false;
} }
@Override @Override
public void perform() { public void perform(CommandContext context) {
fme.setIsAdminBypassing(this.argAsBool(0, !fme.isAdminBypassing())); context.fPlayer.setIsAdminBypassing(context.argAsBool(0, !context.fPlayer.isAdminBypassing()));
// TODO: Move this to a transient field in the model?? // TODO: Move this to a transient field in the model??
if (fme.isAdminBypassing()) { if (context.fPlayer.isAdminBypassing()) {
fme.msg(TL.COMMAND_BYPASS_ENABLE.toString()); context.fPlayer.msg(TL.COMMAND_BYPASS_ENABLE.toString());
P.p.log(fme.getName() + TL.COMMAND_BYPASS_ENABLELOG.toString()); FactionsPlugin.getInstance().log(context.fPlayer.getName() + TL.COMMAND_BYPASS_ENABLELOG.toString());
} else { } else {
fme.msg(TL.COMMAND_BYPASS_DISABLE.toString()); context.fPlayer.msg(TL.COMMAND_BYPASS_DISABLE.toString());
P.p.log(fme.getName() + TL.COMMAND_BYPASS_DISABLELOG.toString()); FactionsPlugin.getInstance().log(context.fPlayer.getName() + TL.COMMAND_BYPASS_DISABLELOG.toString());
} }
} }
@@ -41,4 +36,4 @@ public class CmdBypass extends FCommand {
public TL getUsageTranslation() { public TL getUsageTranslation() {
return TL.COMMAND_BYPASS_DESCRIPTION; return TL.COMMAND_BYPASS_DESCRIPTION;
} }
} }

View File

@@ -5,6 +5,8 @@ import com.massivecraft.factions.struct.ChatMode;
import com.massivecraft.factions.struct.Permission; import com.massivecraft.factions.struct.Permission;
import com.massivecraft.factions.struct.Role; import com.massivecraft.factions.struct.Role;
import com.massivecraft.factions.zcore.util.TL; import com.massivecraft.factions.zcore.util.TL;
import com.mojang.brigadier.builder.ArgumentBuilder;
import com.mojang.brigadier.builder.LiteralArgumentBuilder;
public class CmdChat extends FCommand { public class CmdChat extends FCommand {
@@ -16,33 +18,29 @@ public class CmdChat extends FCommand {
//this.requiredArgs.add(""); //this.requiredArgs.add("");
this.optionalArgs.put("mode", "next"); this.optionalArgs.put("mode", "next");
this.permission = Permission.CHAT.node; this.requirements = new CommandRequirements.Builder(Permission.CHAT)
this.disableOnLock = false; .playerOnly()
.memberOnly()
.brigadier(ChatBrigadier.class)
senderMustBePlayer = true; .build();
senderMustBeMember = true;
senderMustBeModerator = false;
senderMustBeColeader = false;
senderMustBeAdmin = false;
} }
@Override @Override
public void perform() { public void perform(CommandContext context) {
if (!Conf.factionOnlyChat) { if (!Conf.factionOnlyChat) {
msg(TL.COMMAND_CHAT_DISABLED.toString()); context.msg(TL.COMMAND_CHAT_DISABLED.toString());
return; return;
} }
String modeString = this.argAsString(0); String modeString = context.argAsString(0);
ChatMode modeTarget = fme.getChatMode().getNext(); ChatMode modeTarget = context.fPlayer.getChatMode().getNext();
if (modeString != null) { if (modeString != null) {
modeString = modeString.toLowerCase(); modeString = modeString.toLowerCase();
// Only allow Mods and higher rank to switch to this channel. // Only allow Mods and higher rank to switch to this channel.
if (modeString.startsWith("m")) { if (modeString.startsWith("m")) {
if (!fme.getRole().isAtLeast(Role.MODERATOR)) { if (!context.fPlayer.getRole().isAtLeast(Role.MODERATOR)) {
msg(TL.COMMAND_CHAT_MOD_ONLY); context.msg(TL.COMMAND_CHAT_MOD_ONLY);
return; return;
} else modeTarget = ChatMode.MOD; } else modeTarget = ChatMode.MOD;
} else if (modeString.startsWith("p")) { } else if (modeString.startsWith("p")) {
@@ -54,28 +52,28 @@ public class CmdChat extends FCommand {
} else if (modeString.startsWith("t")) { } else if (modeString.startsWith("t")) {
modeTarget = ChatMode.TRUCE; modeTarget = ChatMode.TRUCE;
} else { } else {
msg(TL.COMMAND_CHAT_INVALIDMODE); context.msg(TL.COMMAND_CHAT_INVALIDMODE);
return; return;
} }
} }
fme.setChatMode(modeTarget); context.fPlayer.setChatMode(modeTarget);
switch (fme.getChatMode()) { switch (context.fPlayer.getChatMode()) {
case MOD: case MOD:
msg(TL.COMMAND_CHAT_MODE_MOD); context.msg(TL.COMMAND_CHAT_MODE_MOD);
break; break;
case PUBLIC: case PUBLIC:
msg(TL.COMMAND_CHAT_MODE_PUBLIC); context.msg(TL.COMMAND_CHAT_MODE_PUBLIC);
break; break;
case ALLIANCE: case ALLIANCE:
msg(TL.COMMAND_CHAT_MODE_ALLIANCE); context.msg(TL.COMMAND_CHAT_MODE_ALLIANCE);
break; break;
case TRUCE: case TRUCE:
msg(TL.COMMAND_CHAT_MODE_TRUCE); context.msg(TL.COMMAND_CHAT_MODE_TRUCE);
break; break;
default: default:
msg(TL.COMMAND_CHAT_MODE_FACTION); context.msg(TL.COMMAND_CHAT_MODE_FACTION);
break; break;
} }
} }
@@ -84,4 +82,16 @@ public class CmdChat extends FCommand {
public TL getUsageTranslation() { public TL getUsageTranslation() {
return TL.COMMAND_CHAT_DESCRIPTION; return TL.COMMAND_CHAT_DESCRIPTION;
} }
protected class ChatBrigadier implements BrigadierProvider {
@Override
public ArgumentBuilder<Object, ?> get(ArgumentBuilder<Object, ?> parent) {
return parent.then(LiteralArgumentBuilder.literal("public"))
.then(LiteralArgumentBuilder.literal("mod"))
.then(LiteralArgumentBuilder.literal("alliance"))
.then(LiteralArgumentBuilder.literal("faction"))
.then(LiteralArgumentBuilder.literal("truce"));
}
}
} }

View File

@@ -1,6 +1,6 @@
package com.massivecraft.factions.cmd; package com.massivecraft.factions.cmd;
import com.massivecraft.factions.P; import com.massivecraft.factions.FactionsPlugin;
import com.massivecraft.factions.struct.Permission; import com.massivecraft.factions.struct.Permission;
import com.massivecraft.factions.zcore.util.TL; import com.massivecraft.factions.zcore.util.TL;
@@ -12,26 +12,21 @@ public class CmdChatSpy extends FCommand {
this.optionalArgs.put("on/off", "flip"); this.optionalArgs.put("on/off", "flip");
this.permission = Permission.CHATSPY.node; this.requirements = new CommandRequirements.Builder(Permission.CHATSPY)
this.disableOnLock = false; .playerOnly()
.build();
senderMustBePlayer = true;
senderMustBeMember = false;
senderMustBeModerator = false;
senderMustBeColeader = false;
senderMustBeAdmin = false;
} }
@Override @Override
public void perform() { public void perform(CommandContext context) {
fme.setSpyingChat(this.argAsBool(0, !fme.isSpyingChat())); context.fPlayer.setSpyingChat(context.argAsBool(0, !context.fPlayer.isSpyingChat()));
if (fme.isSpyingChat()) { if (context.fPlayer.isSpyingChat()) {
fme.msg(TL.COMMAND_CHATSPY_ENABLE); context.msg(TL.COMMAND_CHATSPY_ENABLE);
P.p.log(fme.getName() + TL.COMMAND_CHATSPY_ENABLELOG.toString()); FactionsPlugin.getInstance().log(context.fPlayer.getName() + TL.COMMAND_CHATSPY_ENABLELOG.toString());
} else { } else {
fme.msg(TL.COMMAND_CHATSPY_DISABLE); context.msg(TL.COMMAND_CHATSPY_DISABLE);
P.p.log(fme.getName() + TL.COMMAND_CHATSPY_DISABLELOG.toString()); FactionsPlugin.getInstance().log(context.fPlayer.getName() + TL.COMMAND_CHATSPY_DISABLELOG.toString());
} }
} }

View File

@@ -14,46 +14,45 @@ public class CmdCheckpoint extends FCommand {
this.optionalArgs.put("set", ""); this.optionalArgs.put("set", "");
this.permission = Permission.CHECKPOINT.node; this.requirements = new CommandRequirements.Builder(Permission.CHECKPOINT)
this.disableOnLock = false; .playerOnly()
.memberOnly()
senderMustBePlayer = true; .build();
senderMustBeMember = true;
senderMustBeModerator = false;
senderMustBeColeader = false;
senderMustBeAdmin = false;
} }
@Override @Override
public void perform() { public void perform(CommandContext context) {
if (!P.p.getConfig().getBoolean("checkpoints.Enabled")) { if (!FactionsPlugin.getInstance().getConfig().getBoolean("checkpoints.Enabled")) {
fme.msg(TL.COMMAND_CHECKPOINT_DISABLED); context.msg(TL.COMMAND_CHECKPOINT_DISABLED);
return; return;
} }
if (args.size() == 1) { if (context.args.size() == 1) {
FLocation myLocation = new FLocation(fme.getPlayer().getLocation()); FLocation myLocation = new FLocation(context.player.getLocation());
Faction myLocFaction = Board.getInstance().getFactionAt(myLocation); Faction myLocFaction = Board.getInstance().getFactionAt(myLocation);
if (myLocFaction == Factions.getInstance().getWilderness() || myLocFaction == fme.getFaction()) { if (myLocFaction == Factions.getInstance().getWilderness() || myLocFaction == context.faction) {
fme.getFaction().setCheckpoint(fme.getPlayer().getLocation()); context.faction.setCheckpoint(context.player.getLocation());
fme.msg(TL.COMMAND_CHECKPOINT_SET); context.msg(TL.COMMAND_CHECKPOINT_SET);
return; return;
} else { } else {
fme.msg(TL.COMMAND_CHECKPOINT_INVALIDLOCATION); context.msg(TL.COMMAND_CHECKPOINT_INVALIDLOCATION);
return; return;
} }
} }
if (fme.getFaction().getCheckpoint() == null) { if (context.faction.getCheckpoint() == null) {
fme.msg(TL.COMMAND_CHECKPOINT_NOT_SET); context.msg(TL.COMMAND_CHECKPOINT_NOT_SET);
return; return;
} }
FLocation checkLocation = new FLocation(fme.getFaction().getCheckpoint()); FLocation checkLocation = new FLocation(context.faction.getCheckpoint());
Faction checkfaction = Board.getInstance().getFactionAt(checkLocation); Faction checkfaction = Board.getInstance().getFactionAt(checkLocation);
if (checkfaction.getId().equals(Factions.getInstance().getWilderness().getId()) || checkfaction.getId().equals(fme.getFaction().getId())) { if (checkfaction.getId().equals(Factions.getInstance().getWilderness().getId()) || checkfaction.getId().equals(context.faction.getId())) {
fme.msg(TL.COMMAND_CHECKPOINT_GO); context.msg(TL.COMMAND_CHECKPOINT_GO);
this.doWarmUp(WarmUpUtil.Warmup.CHECKPOINT, TL.WARMUPS_NOTIFY_TELEPORT, "Checkpoint", () -> fme.getPlayer().teleport(fme.getFaction().getCheckpoint()), this.p.getConfig().getLong("warmups.f-checkpoint", 0));
context.doWarmUp(WarmUpUtil.Warmup.CHECKPOINT, TL.WARMUPS_NOTIFY_TELEPORT, "Checkpoint", () -> {
context.player.teleport(context.faction.getCheckpoint());
}, FactionsPlugin.getInstance().getConfig().getLong("warmups.f-checkpoint", 0));
} else { } else {
fme.msg(TL.COMMAND_CHECKPOINT_CLAIMED); context.msg(TL.COMMAND_CHECKPOINT_CLAIMED);
} }

View File

@@ -18,61 +18,51 @@ public class CmdColeader extends FCommand {
this.aliases.add("setco"); this.aliases.add("setco");
this.optionalArgs.put("player name", "name"); this.optionalArgs.put("player name", "name");
//this.optionalArgs.put("", "");
this.permission = Permission.COLEADER.node; this.requirements = new CommandRequirements.Builder(Permission.COLEADER)
this.disableOnLock = true; .memberOnly()
.withRole(Role.LEADER)
.build();
senderMustBePlayer = false;
senderMustBeMember = true;
senderMustBeModerator = false;
senderMustBeAdmin = true;
} }
@Override @Override
public void perform() { public void perform(CommandContext context) {
FPlayer you = this.argAsBestFPlayerMatch(0); FPlayer you = context.argAsBestFPlayerMatch(0);
if (you == null) { if (you == null) {
FancyMessage msg = new FancyMessage(TL.COMMAND_COLEADER_CANDIDATES.toString()).color(ChatColor.GOLD); FancyMessage msg = new FancyMessage(TL.COMMAND_COLEADER_CANDIDATES.toString()).color(ChatColor.GOLD);
for (FPlayer player : myFaction.getFPlayersWhereRole(Role.NORMAL)) { for (FPlayer player : context.faction.getFPlayersWhereRole(Role.NORMAL)) {
String s = player.getName(); String s = player.getName();
msg.then(s + " ").color(ChatColor.WHITE).tooltip(TL.COMMAND_MOD_CLICKTOPROMOTE.toString() + s).command("/" + Conf.baseCommandAliases.get(0) + " coleader " + s); msg.then(s + " ").color(ChatColor.WHITE).tooltip(TL.COMMAND_MOD_CLICKTOPROMOTE.toString() + s).command("/" + Conf.baseCommandAliases.get(0) + " coleader " + s);
} }
for (FPlayer player : myFaction.getFPlayersWhereRole(Role.MODERATOR)) { for (FPlayer player : context.faction.getFPlayersWhereRole(Role.MODERATOR)) {
String s = player.getName(); String s = player.getName();
msg.then(s + " ").color(ChatColor.WHITE).tooltip(TL.COMMAND_MOD_CLICKTOPROMOTE.toString() + s).command("/" + Conf.baseCommandAliases.get(0) + " coleader " + s); msg.then(s + " ").color(ChatColor.WHITE).tooltip(TL.COMMAND_MOD_CLICKTOPROMOTE.toString() + s).command("/" + Conf.baseCommandAliases.get(0) + " coleader " + s);
} }
sendFancyMessage(msg); context.sendFancyMessage(msg);
return; return;
} }
boolean permAny = Permission.COLEADER_ANY.has(sender, false); boolean permAny = Permission.COLEADER_ANY.has(context.sender, false);
Faction targetFaction = you.getFaction(); Faction targetFaction = you.getFaction();
if (you.isAlt()) { if (targetFaction != context.faction && !permAny) {
msg(ChatColor.RED + "You can not promote alt accounts."); context.msg(TL.COMMAND_MOD_NOTMEMBER, you.describeTo(context.fPlayer, true));
return; return;
} }
if (targetFaction != myFaction && !permAny) { if (context.fPlayer != null && context.fPlayer.getRole() != Role.LEADER && !permAny) {
msg(TL.COMMAND_MOD_NOTMEMBER, you.describeTo(fme, true)); context.msg(TL.COMMAND_COLEADER_NOTADMIN);
return; return;
} }
if (fme != null && fme.getRole() != Role.LEADER && !permAny) { if (you == context.fPlayer && !permAny) {
msg(TL.COMMAND_COLEADER_NOTADMIN); context.msg(TL.COMMAND_COLEADER_SELF);
return;
}
if (you == fme && !permAny) {
msg(TL.COMMAND_COLEADER_SELF);
return; return;
} }
if (you.getRole() == Role.LEADER) { if (you.getRole() == Role.LEADER) {
msg(TL.COMMAND_COLEADER_TARGETISADMIN); context.msg(TL.COMMAND_COLEADER_TARGETISADMIN);
return; return;
} }
@@ -80,12 +70,12 @@ public class CmdColeader extends FCommand {
// Revoke // Revoke
you.setRole(Role.MODERATOR); you.setRole(Role.MODERATOR);
targetFaction.msg(TL.COMMAND_COLEADER_REVOKED, you.describeTo(targetFaction, true)); targetFaction.msg(TL.COMMAND_COLEADER_REVOKED, you.describeTo(targetFaction, true));
msg(TL.COMMAND_COLEADER_REVOKES, you.describeTo(fme, true)); context.msg(TL.COMMAND_COLEADER_REVOKES, you.describeTo(context.fPlayer, true));
} else { } else {
// Give // Give
you.setRole(Role.COLEADER); you.setRole(Role.COLEADER);
targetFaction.msg(TL.COMMAND_COLEADER_PROMOTED, you.describeTo(targetFaction, true)); targetFaction.msg(TL.COMMAND_COLEADER_PROMOTED, you.describeTo(targetFaction, true));
msg(TL.COMMAND_COLEADER_PROMOTES, you.describeTo(fme, true)); context.msg(TL.COMMAND_COLEADER_PROMOTES, you.describeTo(context.fPlayer, true));
} }
} }
@@ -94,3 +84,4 @@ public class CmdColeader extends FCommand {
return TL.COMMAND_COLEADER_DESCRIPTION; return TL.COMMAND_COLEADER_DESCRIPTION;
} }
} }

View File

@@ -1,7 +1,7 @@
package com.massivecraft.factions.cmd; package com.massivecraft.factions.cmd;
import com.massivecraft.factions.Conf; import com.massivecraft.factions.Conf;
import com.massivecraft.factions.P; import com.massivecraft.factions.FactionsPlugin;
import com.massivecraft.factions.struct.Permission; import com.massivecraft.factions.struct.Permission;
import com.massivecraft.factions.zcore.util.TL; import com.massivecraft.factions.zcore.util.TL;
import org.bukkit.ChatColor; import org.bukkit.ChatColor;
@@ -24,20 +24,14 @@ public class CmdConfig extends FCommand {
this.requiredArgs.add("setting"); this.requiredArgs.add("setting");
this.requiredArgs.add("value"); this.requiredArgs.add("value");
this.errorOnToManyArgs = false;
this.permission = Permission.CONFIG.node; this.requirements = new CommandRequirements.Builder(Permission.CONFIG)
this.disableOnLock = true; .noErrorOnManyArgs()
.build();
senderMustBePlayer = false;
senderMustBeMember = false;
senderMustBeModerator = false;
senderMustBeColeader = false;
senderMustBeAdmin = false;
} }
@Override @Override
public void perform() { public void perform(CommandContext context) {
// store a lookup map of lowercase field names paired with proper capitalization field names // store a lookup map of lowercase field names paired with proper capitalization field names
// that way, if the person using this command messes up the capitalization, we can fix that // that way, if the person using this command messes up the capitalization, we can fix that
if (properFieldNames.isEmpty()) { if (properFieldNames.isEmpty()) {
@@ -47,22 +41,22 @@ public class CmdConfig extends FCommand {
} }
} }
String field = this.argAsString(0).toLowerCase(); String field = context.argAsString(0).toLowerCase();
if (field.startsWith("\"") && field.endsWith("\"")) { if (field.startsWith("\"") && field.endsWith("\"")) {
field = field.substring(1, field.length() - 1); field = field.substring(1, field.length() - 1);
} }
String fieldName = properFieldNames.get(field); String fieldName = properFieldNames.get(field);
if (fieldName == null || fieldName.isEmpty()) { if (fieldName == null || fieldName.isEmpty()) {
msg(TL.COMMAND_CONFIG_NOEXIST, field); context.msg(TL.COMMAND_CONFIG_NOEXIST, field);
return; return;
} }
String success; String success;
StringBuilder value = new StringBuilder(args.get(1)); StringBuilder value = new StringBuilder(context.args.get(1));
for (int i = 2; i < args.size(); i++) { for (int i = 2; i < context.args.size(); i++) {
value.append(' ').append(args.get(i)); value.append(' ').append(context.args.get(i));
} }
try { try {
@@ -70,7 +64,7 @@ public class CmdConfig extends FCommand {
// boolean // boolean
if (target.getType() == boolean.class) { if (target.getType() == boolean.class) {
boolean targetValue = this.strAsBool(value.toString()); boolean targetValue = context.strAsBool(value.toString());
target.setBoolean(null, targetValue); target.setBoolean(null, targetValue);
if (targetValue) { if (targetValue) {
@@ -87,7 +81,7 @@ public class CmdConfig extends FCommand {
target.setInt(null, intVal); target.setInt(null, intVal);
success = "\"" + fieldName + TL.COMMAND_CONFIG_OPTIONSET.toString() + intVal + "."; success = "\"" + fieldName + TL.COMMAND_CONFIG_OPTIONSET.toString() + intVal + ".";
} catch (NumberFormatException ex) { } catch (NumberFormatException ex) {
sendMessage(TL.COMMAND_CONFIG_INTREQUIRED.format(fieldName)); context.sendMessage(TL.COMMAND_CONFIG_INTREQUIRED.format(fieldName));
return; return;
} }
} }
@@ -99,7 +93,7 @@ public class CmdConfig extends FCommand {
target.setLong(null, longVal); target.setLong(null, longVal);
success = "\"" + fieldName + TL.COMMAND_CONFIG_OPTIONSET.toString() + longVal + "."; success = "\"" + fieldName + TL.COMMAND_CONFIG_OPTIONSET.toString() + longVal + ".";
} catch (NumberFormatException ex) { } catch (NumberFormatException ex) {
sendMessage(TL.COMMAND_CONFIG_LONGREQUIRED.format(fieldName)); context.sendMessage(TL.COMMAND_CONFIG_LONGREQUIRED.format(fieldName));
return; return;
} }
} }
@@ -111,7 +105,7 @@ public class CmdConfig extends FCommand {
target.setDouble(null, doubleVal); target.setDouble(null, doubleVal);
success = "\"" + fieldName + TL.COMMAND_CONFIG_OPTIONSET.toString() + doubleVal + "."; success = "\"" + fieldName + TL.COMMAND_CONFIG_OPTIONSET.toString() + doubleVal + ".";
} catch (NumberFormatException ex) { } catch (NumberFormatException ex) {
sendMessage(TL.COMMAND_CONFIG_DOUBLEREQUIRED.format(fieldName)); context.sendMessage(TL.COMMAND_CONFIG_DOUBLEREQUIRED.format(fieldName));
return; return;
} }
} }
@@ -123,7 +117,7 @@ public class CmdConfig extends FCommand {
target.setFloat(null, floatVal); target.setFloat(null, floatVal);
success = "\"" + fieldName + TL.COMMAND_CONFIG_OPTIONSET.toString() + floatVal + "."; success = "\"" + fieldName + TL.COMMAND_CONFIG_OPTIONSET.toString() + floatVal + ".";
} catch (NumberFormatException ex) { } catch (NumberFormatException ex) {
sendMessage(TL.COMMAND_CONFIG_FLOATREQUIRED.format(fieldName)); context.sendMessage(TL.COMMAND_CONFIG_FLOATREQUIRED.format(fieldName));
return; return;
} }
} }
@@ -143,7 +137,7 @@ public class CmdConfig extends FCommand {
} }
if (newColor == null) { if (newColor == null) {
sendMessage(TL.COMMAND_CONFIG_INVALID_COLOUR.format(fieldName, value.toString().toUpperCase())); context.sendMessage(TL.COMMAND_CONFIG_INVALID_COLOUR.format(fieldName, value.toString().toUpperCase()));
return; return;
} }
target.set(null, newColor); target.set(null, newColor);
@@ -157,7 +151,7 @@ public class CmdConfig extends FCommand {
// not a Set, somehow, and that should be the only collection we're using in Conf.java // not a Set, somehow, and that should be the only collection we're using in Conf.java
if (targSet.getRawType() != Set.class) { if (targSet.getRawType() != Set.class) {
sendMessage(TL.COMMAND_CONFIG_INVALID_COLLECTION.format(fieldName)); context.sendMessage(TL.COMMAND_CONFIG_INVALID_COLLECTION.format(fieldName));
return; return;
} }
@@ -170,7 +164,7 @@ public class CmdConfig extends FCommand {
} }
if (newMat == null) { if (newMat == null) {
sendMessage(TL.COMMAND_CONFIG_INVALID_MATERIAL.format(fieldName, value.toString().toUpperCase())); context.sendMessage(TL.COMMAND_CONFIG_INVALID_MATERIAL.format(fieldName, value.toString().toUpperCase()));
return; return;
} }
@@ -210,31 +204,31 @@ public class CmdConfig extends FCommand {
// Set of unknown type // Set of unknown type
else { else {
sendMessage(TL.COMMAND_CONFIG_INVALID_TYPESET.format(fieldName)); context.sendMessage(TL.COMMAND_CONFIG_INVALID_TYPESET.format(fieldName));
return; return;
} }
} }
// unknown type // unknown type
else { else {
sendMessage(TL.COMMAND_CONFIG_ERROR_TYPE.format(fieldName, target.getClass().getName())); context.sendMessage(TL.COMMAND_CONFIG_ERROR_TYPE.format(fieldName, target.getClass().getName()));
return; return;
} }
} catch (NoSuchFieldException ex) { } catch (NoSuchFieldException ex) {
sendMessage(TL.COMMAND_CONFIG_ERROR_MATCHING.format(fieldName)); context.sendMessage(TL.COMMAND_CONFIG_ERROR_MATCHING.format(fieldName));
return; return;
} catch (IllegalAccessException ex) { } catch (IllegalAccessException ex) {
sendMessage(TL.COMMAND_CONFIG_ERROR_SETTING.format(fieldName, value.toString())); context.sendMessage(TL.COMMAND_CONFIG_ERROR_SETTING.format(fieldName, value.toString()));
return; return;
} }
if (!success.isEmpty()) { if (!success.isEmpty()) {
if (sender instanceof Player) { if (context.sender instanceof Player) {
sendMessage(success); context.sendMessage(success);
P.p.log(success + TL.COMMAND_CONFIG_LOG.format((Player) sender)); FactionsPlugin.getInstance().log(success + TL.COMMAND_CONFIG_LOG.format((Player) context.sender));
} else // using P.p.log() instead of sendMessage if run from server console so that "[Factions v#.#.#]" is prepended in server log } else // using FactionsPlugin.getInstance().log() instead of sendMessage if run from server console so that "[Factions v#.#.#]" is prepended in server log
{ {
P.p.log(success); FactionsPlugin.getInstance().log(success);
} }
} }
// save change to disk // save change to disk

View File

@@ -11,26 +11,26 @@ public class CmdConvert extends FCommand {
public CmdConvert() { public CmdConvert() {
this.aliases.add("convert"); this.aliases.add("convert");
this.permission = Permission.CONVERT.node;
this.requiredArgs.add("[MYSQL|JSON]"); this.requiredArgs.add("[MYSQL|JSON]");
this.requirements = new CommandRequirements.Builder(Permission.CONVERT)
.build();
} }
@Override @Override
public void perform() { public void perform(CommandContext context) {
if (!(this.sender instanceof ConsoleCommandSender)) { if (!(context.sender instanceof ConsoleCommandSender)) {
this.sender.sendMessage(TL.GENERIC_CONSOLEONLY.toString()); context.sender.sendMessage(TL.GENERIC_CONSOLEONLY.toString());
} }
Backend nb = Backend.valueOf(this.argAsString(0).toUpperCase()); Backend nb = Backend.valueOf(context.argAsString(0).toUpperCase());
if (nb == Conf.backEnd) { if (nb == Conf.backEnd) {
this.sender.sendMessage(TL.COMMAND_CONVERT_BACKEND_RUNNING.toString()); context.sender.sendMessage(TL.COMMAND_CONVERT_BACKEND_RUNNING.toString());
return; return;
} }
if (nb == Backend.JSON) { if (nb == Backend.JSON) {
FactionsJSON.convertTo(); FactionsJSON.convertTo();
} else { } else {
this.sender.sendMessage(TL.COMMAND_CONVERT_BACKEND_INVALID.toString()); context.sender.sendMessage(TL.COMMAND_CONVERT_BACKEND_INVALID.toString());
return; return;
} }
Conf.backEnd = nb; Conf.backEnd = nb;
@@ -41,4 +41,4 @@ public class CmdConvert extends FCommand {
return TL.COMMAND_CONVERT_DESCRIPTION; return TL.COMMAND_CONVERT_DESCRIPTION;
} }
} }

View File

@@ -12,23 +12,18 @@ public class CmdCoords extends FCommand {
this.aliases.add("coords"); this.aliases.add("coords");
this.aliases.add("coord"); this.aliases.add("coord");
this.permission = Permission.COORD.node; this.requirements = new CommandRequirements.Builder(Permission.COORD)
this.disableOnLock = true; .playerOnly()
.memberOnly()
.build();
senderMustBePlayer = true;
senderMustBeMember = true;
senderMustBeModerator = false;
senderMustBeColeader = false;
senderMustBeAdmin = false;
} }
@Override @Override
public void perform() { public void perform(CommandContext context) {
Location location = fme.getPlayer().getLocation(); Location location = context.player.getLocation();
String message = TL.COMMAND_COORDS_MESSAGE.toString().replace("{player}", fme.getPlayer().getDisplayName()).replace("{x}", (int) location.getX() + "") String message = TL.COMMAND_COORDS_MESSAGE.toString().replace("{player}", context.player.getDisplayName()).replace("{x}", (int) location.getX() + "")
.replace("{y}", (int) location.getY() + "").replace("{z}", (int) location.getZ() + "").replace("{world}", location.getWorld().getName()); .replace("{y}", (int) location.getY() + "").replace("{z}", (int) location.getZ() + "").replace("{world}", location.getWorld().getName());
for (FPlayer fPlayer : fme.getFaction().getFPlayers()) { for (FPlayer fPlayer : context.faction.getFPlayers()) {
fPlayer.sendMessage(message); fPlayer.sendMessage(message);
} }
} }

View File

@@ -20,58 +20,46 @@ public class CmdCreate extends FCommand {
this.aliases.add("create"); this.aliases.add("create");
this.requiredArgs.add("faction tag"); this.requiredArgs.add("faction tag");
//this.optionalArgs.put("", "");
this.permission = Permission.CREATE.node; this.requirements = new CommandRequirements.Builder(Permission.CREATE)
this.disableOnLock = true; .playerOnly()
this.disableOnSpam = true; .build();
senderMustBePlayer = true;
senderMustBeMember = false;
senderMustBeModerator = false;
senderMustBeColeader = false;
senderMustBeAdmin = false;
} }
@Override @Override
public void perform() { public void perform(CommandContext context) {
String tag = this.argAsString(0); String tag = context.argAsString(0);
if (fme.hasFaction()) { if (context.fPlayer.hasFaction()) {
msg(TL.COMMAND_CREATE_MUSTLEAVE); context.msg(TL.COMMAND_CREATE_MUSTLEAVE);
return;
}
if (!fme.isCooldownEnded("create")) {
fme.msg(TL.COMMAND_ONCOOOLDOWN, fme.getCooldown("create"));
return; return;
} }
if (Factions.getInstance().isTagTaken(tag)) { if (Factions.getInstance().isTagTaken(tag)) {
msg(TL.COMMAND_CREATE_INUSE); context.msg(TL.COMMAND_CREATE_INUSE);
return; return;
} }
ArrayList<String> tagValidationErrors = MiscUtil.validateTag(tag); ArrayList<String> tagValidationErrors = MiscUtil.validateTag(tag);
if (tagValidationErrors.size() > 0) { if (tagValidationErrors.size() > 0) {
sendMessage(tagValidationErrors); context.sendMessage(tagValidationErrors);
return; return;
} }
// if economy is enabled, they're not on the bypass list, and this command has a cost set, make sure they can pay // if economy is enabled, they're not on the bypass list, and this command has a cost set, make sure they can pay
if (!canAffordCommand(Conf.econCostCreate, TL.COMMAND_CREATE_TOCREATE.toString())) { if (!context.canAffordCommand(Conf.econCostCreate, TL.COMMAND_CREATE_TOCREATE.toString())) {
return; return;
} }
// trigger the faction creation event (cancellable) // trigger the faction creation event (cancellable)
FactionCreateEvent createEvent = new FactionCreateEvent(me, tag); FactionCreateEvent createEvent = new FactionCreateEvent(context.player, tag);
Bukkit.getServer().getPluginManager().callEvent(createEvent); Bukkit.getServer().getPluginManager().callEvent(createEvent);
if (createEvent.isCancelled()) { if (createEvent.isCancelled()) {
return; return;
} }
// then make 'em pay (if applicable) // then make 'em pay (if applicable)
if (!payForCommand(Conf.econCostCreate, TL.COMMAND_CREATE_TOCREATE, TL.COMMAND_CREATE_FORCREATE)) { if (!context.payForCommand(Conf.econCostCreate, TL.COMMAND_CREATE_TOCREATE, TL.COMMAND_CREATE_FORCREATE)) {
return; return;
} }
@@ -79,7 +67,7 @@ public class CmdCreate extends FCommand {
// TODO: Why would this even happen??? Auto increment clash?? // TODO: Why would this even happen??? Auto increment clash??
if (faction == null) { if (faction == null) {
msg(TL.COMMAND_CREATE_ERROR); context.msg(TL.COMMAND_CREATE_ERROR);
return; return;
} }
@@ -87,39 +75,29 @@ public class CmdCreate extends FCommand {
faction.setTag(tag); faction.setTag(tag);
// trigger the faction join event for the creator // trigger the faction join event for the creator
FPlayerJoinEvent joinEvent = new FPlayerJoinEvent(FPlayers.getInstance().getByPlayer(me), faction, FPlayerJoinEvent.PlayerJoinReason.CREATE); FPlayerJoinEvent joinEvent = new FPlayerJoinEvent(FPlayers.getInstance().getByPlayer(context.player), faction, FPlayerJoinEvent.PlayerJoinReason.CREATE);
Bukkit.getServer().getPluginManager().callEvent(joinEvent); Bukkit.getServer().getPluginManager().callEvent(joinEvent);
// join event cannot be cancelled or you'll have an empty faction // join event cannot be cancelled or you'll have an empty faction
// finish setting up the FPlayer // finish setting up the FPlayer
fme.setFaction(faction, false); context.fPlayer.setFaction(faction, false);
// We should consider adding the role just AFTER joining the faction. // We should consider adding the role just AFTER joining the faction.
// That way we don't have to mess up deleting more stuff. // That way we don't have to mess up deleting more stuff.
// And prevent the user from being returned to NORMAL after deleting his old faction. // And prevent the user from being returned to NORMAL after deleting his old faction.
fme.setRole(Role.LEADER); context.fPlayer.setRole(Role.LEADER);
if (P.p.getConfig().getBoolean("faction-creation-broadcast", true)) { if (FactionsPlugin.getInstance().getConfig().getBoolean("faction-creation-broadcast", true)) {
for (FPlayer follower : FPlayers.getInstance().getOnlinePlayers()) { for (FPlayer follower : FPlayers.getInstance().getOnlinePlayers()) {
follower.msg(TL.COMMAND_CREATE_CREATED, fme.describeTo(follower, true), faction.getTag(follower)); follower.msg(TL.COMMAND_CREATE_CREATED, context.fPlayer.getName(), faction.getTag(follower));
} }
} }
msg(TL.COMMAND_CREATE_YOUSHOULD, p.cmdBase.cmdDescription.getUseageTemplate()); context.msg(TL.COMMAND_CREATE_YOUSHOULD, FactionsPlugin.getInstance().cmdBase.cmdDescription.getUsageTemplate(context));
if (Conf.econEnabled) Econ.setBalance(faction.getAccountId(), Conf.econFactionStartingBalance);
if (Conf.econEnabled)
Econ.setBalance(faction.getAccountId(), Conf.econFactionStartingBalance);
if (Conf.logFactionCreate) if (Conf.logFactionCreate)
P.p.log(fme.getName() + TL.COMMAND_CREATE_CREATEDLOG.toString() + tag); FactionsPlugin.getInstance().log(context.fPlayer.getName() + TL.COMMAND_CREATE_CREATEDLOG.toString() + tag);
if (FactionsPlugin.getInstance().getConfig().getBoolean("fpaypal.Enabled"))
if (P.p.getConfig().getBoolean("fpaypal.Enabled")) context.msg(TL.COMMAND_PAYPALSET_CREATED);
this.fme.msg(TL.COMMAND_PAYPALSET_CREATED);
if (Conf.useCustomDefaultPermissions) faction.setDefaultPerms(); if (Conf.useCustomDefaultPermissions) faction.setDefaultPerms();
if (Conf.usePermissionHints) fme.msg(TL.COMMAND_HINT_PERMISSION); if (Conf.usePermissionHints) context.msg(TL.COMMAND_HINT_PERMISSION);
fme.setCooldown("create", System.currentTimeMillis() + (P.p.getConfig().getInt("fcooldowns.f-create") * 1000));
} }
@Override @Override

View File

@@ -3,6 +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.struct.Role;
import com.massivecraft.factions.zcore.fperms.Access; import com.massivecraft.factions.zcore.fperms.Access;
@@ -19,51 +20,59 @@ public class CmdDeinvite extends FCommand {
this.aliases.add("deinv"); this.aliases.add("deinv");
this.optionalArgs.put("player name", "name"); this.optionalArgs.put("player name", "name");
//this.optionalArgs.put("", "");
this.permission = Permission.DEINVITE.node; this.requirements = new CommandRequirements.Builder(Permission.DEINVITE)
this.disableOnLock = true; .memberOnly()
.build();
senderMustBePlayer = true;
senderMustBeMember = false;
senderMustBeModerator = true;
senderMustBeColeader = false;
senderMustBeAdmin = false;
} }
@Override @Override
public void perform() { public void perform(CommandContext context) {
FPlayer you = this.argAsBestFPlayerMatch(0);
if (!fme.isAdminBypassing()) { // Check if arg 0 == null do you don't have
Access access = myFaction.getAccess(fme, PermissableAction.INVITE); // `No player "null" could be found.` message.
if (access != Access.ALLOW && fme.getRole() != Role.LEADER) { if (context.args.get(0) == null) {
fme.msg(TL.GENERIC_FPERM_NOPERMISSION, "manage invites");
return;
}
}
if (you == null) {
FancyMessage msg = new FancyMessage(TL.COMMAND_DEINVITE_CANDEINVITE.toString()).color(ChatColor.GOLD); FancyMessage msg = new FancyMessage(TL.COMMAND_DEINVITE_CANDEINVITE.toString()).color(ChatColor.GOLD);
for (String id : myFaction.getInvites()) { for (String id : context.faction.getInvites()) {
FPlayer fp = FPlayers.getInstance().getById(id); FPlayer fp = FPlayers.getInstance().getById(id);
String name = fp != null ? fp.getName() : id; String name = fp != null ? fp.getName() : id;
msg.then(name + " ").color(ChatColor.WHITE).tooltip(TL.COMMAND_DEINVITE_CLICKTODEINVITE.format(name)).command("/" + Conf.baseCommandAliases.get(0) + " deinvite " + name); msg.then(name + " ").color(ChatColor.WHITE).tooltip(TL.COMMAND_DEINVITE_CLICKTODEINVITE.format(name)).command("/" + Conf.baseCommandAliases.get(0) + " deinvite " + name);
} }
sendFancyMessage(msg); context.sendFancyMessage(msg);
return; return;
} }
if (you.getFaction() == myFaction) { FPlayer you = context.argAsBestFPlayerMatch(0);
msg(TL.COMMAND_DEINVITE_ALREADYMEMBER, you.getName(), myFaction.getTag()); if (!context.fPlayer.isAdminBypassing()) {
msg(TL.COMMAND_DEINVITE_MIGHTWANT, p.cmdBase.cmdKick.getUseageTemplate(false)); Access access = context.faction.getAccess(context.fPlayer, PermissableAction.INVITE);
if (access != Access.ALLOW && context.fPlayer.getRole() != Role.LEADER) {
context.msg(TL.GENERIC_FPERM_NOPERMISSION, "manage invites");
return;
}
}
if (you == null) {
FancyMessage msg = new FancyMessage(TL.COMMAND_DEINVITE_CANDEINVITE.toString()).color(ChatColor.GOLD);
for (String id : context.faction.getInvites()) {
FPlayer fp = FPlayers.getInstance().getById(id);
String name = fp != null ? fp.getName() : id;
msg.then(name + " ").color(ChatColor.WHITE).tooltip(TL.COMMAND_DEINVITE_CLICKTODEINVITE.format(name)).command("/" + Conf.baseCommandAliases.get(0) + " deinvite " + name);
}
context.sendFancyMessage(msg);
return; return;
} }
myFaction.deinvite(you); if (you.getFaction() == context.faction) {
context.msg(TL.COMMAND_DEINVITE_ALREADYMEMBER, you.getName(), context.faction.getTag());
context.msg(TL.COMMAND_DEINVITE_MIGHTWANT, FactionsPlugin.getInstance().cmdBase.cmdKick.getUsageTemplate(context));
return;
}
you.msg(TL.COMMAND_DEINVITE_REVOKED, fme.describeTo(you), myFaction.describeTo(you)); context.faction.deinvite(you);
myFaction.msg(TL.COMMAND_DEINVITE_REVOKES, fme.describeTo(myFaction), you.describeTo(myFaction)); you.msg(TL.COMMAND_DEINVITE_REVOKED, context.fPlayer.describeTo(you), context.faction.describeTo(you));
context.faction.msg(TL.COMMAND_DEINVITE_REVOKES, context.fPlayer.describeTo(context.faction), you.describeTo(context.faction));
} }
@Override @Override
@@ -72,3 +81,4 @@ public class CmdDeinvite extends FCommand {
} }
} }

View File

@@ -1,7 +1,7 @@
package com.massivecraft.factions.cmd; package com.massivecraft.factions.cmd;
import com.massivecraft.factions.FPlayer; import com.massivecraft.factions.FPlayer;
import com.massivecraft.factions.P; import com.massivecraft.factions.FactionsPlugin;
import com.massivecraft.factions.struct.Permission; import com.massivecraft.factions.struct.Permission;
import com.massivecraft.factions.zcore.util.TL; import com.massivecraft.factions.zcore.util.TL;
@@ -13,29 +13,29 @@ public class CmdDelFWarp extends FCommand {
this.aliases.add("dw"); this.aliases.add("dw");
this.aliases.add("deletewarp"); this.aliases.add("deletewarp");
this.requiredArgs.add("warp name"); this.requiredArgs.add("warp name");
this.senderMustBeMember = true;
this.senderMustBeModerator = true;
this.senderMustBePlayer = true;
this.permission = Permission.SETWARP.node;
this.requirements = new CommandRequirements.Builder(Permission.SETWARP)
.playerOnly()
.memberOnly()
.build();
} }
@Override @Override
public void perform() { public void perform(CommandContext context) {
String warp = argAsString(0); String warp = context.argAsString(0);
if (myFaction.isWarp(warp)) { if (context.faction.isWarp(warp)) {
if (!transact(fme)) { if (!transact(context.fPlayer, context)) {
return; return;
} }
myFaction.removeWarp(warp); context.faction.removeWarp(warp);
fme.msg(TL.COMMAND_DELFWARP_DELETED, warp); context.msg(TL.COMMAND_DELFWARP_DELETED, warp);
} else { } else {
fme.msg(TL.COMMAND_DELFWARP_INVALID, warp); context.msg(TL.COMMAND_DELFWARP_INVALID, warp);
} }
} }
private boolean transact(FPlayer player) { private boolean transact(FPlayer player, CommandContext context) {
return !P.p.getConfig().getBoolean("warp-cost.enabled", false) || player.isAdminBypassing() || payForCommand(P.p.getConfig().getDouble("warp-cost.delwarp", 5), TL.COMMAND_DELFWARP_TODELETE.toString(), TL.COMMAND_DELFWARP_FORDELETE.toString()); return !FactionsPlugin.getInstance().getConfig().getBoolean("warp-cost.enabled", false) || player.isAdminBypassing() || context.payForCommand(FactionsPlugin.getInstance().getConfig().getDouble("warp-cost.delwarp", 5), TL.COMMAND_DELFWARP_TODELETE.toString(), TL.COMMAND_DELFWARP_FORDELETE.toString());
} }
@Override @Override
@@ -43,3 +43,4 @@ public class CmdDelFWarp extends FCommand {
return TL.COMMAND_DELFWARP_DESCRIPTION; return TL.COMMAND_DELFWARP_DESCRIPTION;
} }
} }

View File

@@ -15,41 +15,35 @@ public class CmdDescription extends FCommand {
this.aliases.add("description"); this.aliases.add("description");
this.requiredArgs.add("desc"); this.requiredArgs.add("desc");
this.errorOnToManyArgs = false;
//this.optionalArgs
this.permission = Permission.DESCRIPTION.node; this.requirements = new CommandRequirements.Builder(Permission.DESCRIPTION)
this.disableOnLock = true; .playerOnly()
.memberOnly()
.noErrorOnManyArgs()
senderMustBePlayer = true; .build();
senderMustBeMember = false;
senderMustBeModerator = false;
senderMustBeColeader = true;
senderMustBeAdmin = false;
} }
@Override @Override
public void perform() { public void perform(CommandContext context) {
// if economy is enabled, they're not on the bypass list, and this command has a cost set, make 'em pay // if economy is enabled, they're not on the bypass list, and this command has a cost set, make 'em pay
if (!payForCommand(Conf.econCostDesc, TL.COMMAND_DESCRIPTION_TOCHANGE, TL.COMMAND_DESCRIPTION_FORCHANGE)) { if (!context.payForCommand(Conf.econCostDesc, TL.COMMAND_DESCRIPTION_TOCHANGE, TL.COMMAND_DESCRIPTION_FORCHANGE)) {
return; return;
} }
// 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.
myFaction.setDescription(TextUtil.implode(args, " ").replaceAll("%", "").replaceAll("(&([a-f0-9klmnor]))", "& $2")); context.faction.setDescription(TextUtil.implode(context.args, " ").replaceAll("%", "").replaceAll("(&([a-f0-9klmnor]))", "& $2"));
if (!Conf.broadcastDescriptionChanges) { if (!Conf.broadcastDescriptionChanges) {
fme.msg(TL.COMMAND_DESCRIPTION_CHANGED, myFaction.describeTo(fme)); context.msg(TL.COMMAND_DESCRIPTION_CHANGED, context.faction.describeTo(context.fPlayer));
fme.sendMessage(myFaction.getDescription()); context.sendMessage(context.faction.getDescription());
return; return;
} }
// Broadcast the description to everyone // Broadcast the description to everyone
for (FPlayer fplayer : FPlayers.getInstance().getOnlinePlayers()) { for (FPlayer fplayer : FPlayers.getInstance().getOnlinePlayers()) {
fplayer.msg(TL.COMMAND_DESCRIPTION_CHANGES, myFaction.describeTo(fplayer)); fplayer.msg(TL.COMMAND_DESCRIPTION_CHANGES, context.faction.describeTo(fplayer));
fplayer.sendMessage(myFaction.getDescription()); // players can inject "&" or "`" or "<i>" or whatever in their description; &k is particularly interesting looking fplayer.sendMessage(context.faction.getDescription()); // players can inject "&" or "`" or "<i>" or whatever in their description; &k is particularly interesting looking
} }
} }
@@ -58,4 +52,4 @@ public class CmdDescription extends FCommand {
return TL.COMMAND_DESCRIPTION_DESCRIPTION; return TL.COMMAND_DESCRIPTION_DESCRIPTION;
} }
} }

View File

@@ -9,6 +9,7 @@ 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.Bukkit; import org.bukkit.Bukkit;
import org.bukkit.command.ConsoleCommandSender;
import java.util.HashMap; import java.util.HashMap;
@@ -23,87 +24,71 @@ public class CmdDisband extends FCommand {
super(); super();
this.aliases.add("disband"); this.aliases.add("disband");
//this.requiredArgs.add("");
this.optionalArgs.put("faction tag", "yours"); this.optionalArgs.put("faction tag", "yours");
this.permission = Permission.DISBAND.node; this.requirements = new CommandRequirements.Builder(Permission.DISBAND)
this.disableOnLock = true; .build();
this.disableOnSpam = true;
senderMustBePlayer = false;
senderMustBeMember = false;
senderMustBeModerator = false;
senderMustBeColeader = false;
senderMustBeAdmin = false;
} }
@Override @Override
public void perform() { public void perform(CommandContext context) {
// The faction, default to your own.. but null if console sender. // The faction, default to your own.. but null if console sender.
Faction faction = this.argAsFaction(0, fme == null ? null : myFaction); Faction faction = context.argAsFaction(0, context.fPlayer == null ? null : context.faction);
if (faction == null) { if (faction == null) return;
return;
}
boolean isMyFaction = context.fPlayer != null && faction == context.faction;
if (!fme.isCooldownEnded("disband")) { if (!isMyFaction) {
fme.msg(TL.COMMAND_ONCOOOLDOWN, fme.getCooldown("disband")); if (!Permission.DISBAND_ANY.has(context.sender, true)) {
return;
}
boolean isMyFaction = fme != null && faction == myFaction;
if (isMyFaction) {
if (!assertMinRole(Role.LEADER)) {
return;
}
} else {
if (!Permission.DISBAND_ANY.has(sender, true)) {
return; return;
} }
} }
if (fme != null && !fme.isAdminBypassing()) { if (context.fPlayer != null && !context.fPlayer.isAdminBypassing()) {
Access access = faction.getAccess(fme, PermissableAction.DISBAND); Access access = faction.getAccess(context.fPlayer, PermissableAction.DISBAND);
if (fme.getRole() != Role.LEADER && faction.getFPlayerLeader() != fme && access != Access.ALLOW) { if (context.fPlayer.getRole() != Role.LEADER && faction.getFPlayerLeader() != context.fPlayer && access != Access.ALLOW) {
fme.msg(TL.GENERIC_FPERM_NOPERMISSION, "disband " + faction.getTag()); context.msg(TL.GENERIC_FPERM_NOPERMISSION, "disband " + faction.getTag());
return; return;
} }
} }
if (!faction.isNormal()) { if (!faction.isNormal()) {
msg(TL.COMMAND_DISBAND_IMMUTABLE.toString()); context.msg(TL.COMMAND_DISBAND_IMMUTABLE.toString());
return; return;
} }
if (faction.isPermanent()) { if (faction.isPermanent()) {
msg(TL.COMMAND_DISBAND_MARKEDPERMANENT.toString()); context.msg(TL.COMMAND_DISBAND_MARKEDPERMANENT.toString());
return;
}
// THis means they are a console command sender.
if (context.player == null) {
faction.disband(null, PlayerDisbandReason.PLUGIN);
return; return;
} }
// check for tnt before disbanding. // check for tnt before disbanding.
if (!disbandMap.containsKey(context.player.getUniqueId().toString()) && faction.getTnt() > 0) {
if ((fme != null && !disbandMap.containsKey(me.getUniqueId().toString())) && faction.getTnt() > 0) { context.msg(TL.COMMAND_DISBAND_CONFIRM.toString().replace("{tnt}", faction.getTnt() + ""));
msg(TL.COMMAND_DISBAND_CONFIRM.toString().replace("{tnt}", faction.getTnt() + "")); disbandMap.put(context.player.getUniqueId().toString(), faction.getId());
disbandMap.put(me.getUniqueId().toString(), faction.getId()); Bukkit.getScheduler().scheduleSyncDelayedTask(FactionsPlugin.getInstance(), () -> disbandMap.remove(context.player.getUniqueId().toString()), 200L);
Bukkit.getScheduler().scheduleSyncDelayedTask(P.p, () -> disbandMap.remove(me.getUniqueId().toString()), 200L); } else if (faction.getId().equals(disbandMap.get(context.player.getUniqueId().toString())) || faction.getTnt() == 0) {
} else if (faction.getId().equals(disbandMap.get(me.getUniqueId().toString())) || faction.getTnt() == 0) { if (FactionsPlugin.getInstance().getConfig().getBoolean("faction-disband-broadcast", true)) {
if (P.p.getConfig().getBoolean("faction-disband-broadcast", true)) {
for (FPlayer follower : FPlayers.getInstance().getOnlinePlayers()) { for (FPlayer follower : FPlayers.getInstance().getOnlinePlayers()) {
String amountString = senderIsConsole ? TL.GENERIC_SERVERADMIN.toString() : fme.describeTo(follower); String amountString = context.sender instanceof ConsoleCommandSender ? TL.GENERIC_SERVERADMIN.toString() : context.fPlayer.describeTo(follower);
UtilFly.checkFly(this.fme, Board.getInstance().getFactionAt(new FLocation(follower))); UtilFly.checkFly(context.fPlayer, Board.getInstance().getFactionAt(new FLocation(follower)));
if (follower.getFaction() == faction) { if (follower.getFaction() == faction) {
follower.msg(TL.COMMAND_DISBAND_BROADCAST_YOURS, amountString); follower.msg(TL.COMMAND_DISBAND_BROADCAST_YOURS, amountString);
fme.setCooldown("disband", System.currentTimeMillis() + (P.p.getConfig().getInt("fcooldowns.f-disband") * 1000));
} else { } else {
follower.msg(TL.COMMAND_DISBAND_BROADCAST_NOTYOURS, amountString, faction.getTag(follower)); follower.msg(TL.COMMAND_DISBAND_BROADCAST_NOTYOURS, amountString, faction.getTag(follower));
} }
} }
faction.disband(me, PlayerDisbandReason.COMMAND); faction.disband(context.player, PlayerDisbandReason.COMMAND);
} else { } else {
faction.disband(me, PlayerDisbandReason.COMMAND); faction.disband(context.player, PlayerDisbandReason.COMMAND);
me.sendMessage(String.valueOf(TL.COMMAND_DISBAND_PLAYER)); context.player.sendMessage(String.valueOf(TL.COMMAND_DISBAND_PLAYER));
} }
} }
} }

View File

@@ -1,7 +1,7 @@
package com.massivecraft.factions.cmd; package com.massivecraft.factions.cmd;
import com.massivecraft.factions.struct.Permission;
import com.massivecraft.factions.zcore.util.TL; import com.massivecraft.factions.zcore.util.TL;
import org.bukkit.entity.Player;
import java.util.ArrayList; import java.util.ArrayList;
import java.util.List; import java.util.List;
@@ -12,36 +12,28 @@ public class CmdFGlobal extends FCommand {
public static List<UUID> toggled = new ArrayList<>(); public static List<UUID> toggled = new ArrayList<>();
public CmdFGlobal() { public CmdFGlobal() {
super(); super();
this.aliases.add("gchat"); this.aliases.add("gchat");
this.aliases.add("global"); this.aliases.add("global");
this.aliases.add("globalchat"); this.aliases.add("globalchat");
this.disableOnLock = false; this.requirements = new CommandRequirements.Builder(Permission.GLOBALCHAT)
this.disableOnSpam = false; .playerOnly()
.memberOnly()
senderMustBePlayer = true; .build();
senderMustBeMember = true;
senderMustBeModerator = false;
senderMustBeColeader = false;
senderMustBeAdmin = false;
} }
@Override @Override
public void perform() { public void perform(CommandContext context) {
Player p = (Player) sender;
// /f global // /f global
if (toggled.contains(p.getUniqueId())) { if (toggled.contains(context.player.getUniqueId())) {
toggled.remove(p.getUniqueId()); toggled.remove(context.player.getUniqueId());
} else { } else {
toggled.add(p.getUniqueId()); toggled.add(context.player.getUniqueId());
} }
fme.msg(TL.COMMAND_F_GLOBAL_TOGGLE, toggled.contains(p.getUniqueId()) ? "disabled" : "enabled"); context.msg(TL.COMMAND_F_GLOBAL_TOGGLE, toggled.contains(context.player.getUniqueId()) ? "disabled" : "enabled");
} }
@Override @Override

View File

@@ -1,12 +1,10 @@
package com.massivecraft.factions.cmd; package com.massivecraft.factions.cmd;
import com.massivecraft.factions.FPlayer; import com.massivecraft.factions.FPlayer;
import com.massivecraft.factions.P; 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.util.FactionWarpsFrame; import com.massivecraft.factions.util.FactionWarpsFrame;
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.fperms.PermissableAction;
import com.massivecraft.factions.zcore.util.TL; import com.massivecraft.factions.zcore.util.TL;
import org.bukkit.Bukkit; import org.bukkit.Bukkit;
@@ -23,63 +21,56 @@ public class CmdFWarp extends FCommand {
this.optionalArgs.put("warpname", "warpname"); this.optionalArgs.put("warpname", "warpname");
this.optionalArgs.put("password", "password"); this.optionalArgs.put("password", "password");
this.requirements = new CommandRequirements.Builder(Permission.WARP)
this.permission = Permission.WARP.node; .playerOnly()
this.senderMustBeMember = true; .memberOnly()
this.senderMustBeModerator = false; .withAction(PermissableAction.WARP)
.build();
} }
@Override @Override
public void perform() { public void perform(CommandContext context) {
//TODO: check if in combat.
if (!fme.isAdminBypassing()) {
Access access = myFaction.getAccess(fme, PermissableAction.WARP);
if (access != Access.ALLOW && fme.getRole() != Role.LEADER) {
fme.msg(TL.GENERIC_FPERM_NOPERMISSION, "use warps");
return;
}
}
if (context.args.size() == 0) {
if (args.size() == 0) { new FactionWarpsFrame(context.faction).buildGUI(context.fPlayer);
new FactionWarpsFrame(fme.getFaction()).buildGUI(fme); } else if (context.args.size() > 2) {
} else if (args.size() > 2) { context.msg(TL.COMMAND_FWARP_COMMANDFORMAT);
fme.msg(TL.COMMAND_FWARP_COMMANDFORMAT);
} else { } else {
final String warpName = argAsString(0); final String warpName = context.argAsString(0);
final String passwordAttempt = argAsString(1); final String passwordAttempt = context.argAsString(1);
if (myFaction.isWarp(argAsString(0))) { if (context.faction.isWarp(context.argAsString(0))) {
// Check if requires password and if so, check if valid. CASE SENSITIVE // Check if requires password and if so, check if valid. CASE SENSITIVE
if (myFaction.hasWarpPassword(warpName) && !myFaction.isWarpPassword(warpName, passwordAttempt)) { if (context.faction.hasWarpPassword(warpName) && !context.faction.isWarpPassword(warpName, passwordAttempt)) {
fme.msg(TL.COMMAND_FWARP_INVALID_PASSWORD); context.faction.msg(TL.COMMAND_FWARP_INVALID_PASSWORD);
return; return;
} }
// Check transaction AFTER password check. // Check transaction AFTER password check.
if (!transact(fme)) return; if (!transact(context.fPlayer, context)) return;
final FPlayer fPlayer = fme;
final UUID uuid = fme.getPlayer().getUniqueId(); final FPlayer fPlayer = context.fPlayer;
this.doWarmUp(WarmUpUtil.Warmup.WARP, TL.WARMUPS_NOTIFY_TELEPORT, warpName, () -> { final UUID uuid = context.player.getUniqueId();
context.doWarmUp(WarmUpUtil.Warmup.WARP, TL.WARMUPS_NOTIFY_TELEPORT, warpName, () -> {
Player player = Bukkit.getPlayer(uuid); Player player = Bukkit.getPlayer(uuid);
if (player != null) { if (player != null) {
player.teleport(fPlayer.getFaction().getWarp(warpName).getLocation()); player.teleport(fPlayer.getFaction().getWarp(warpName).getLocation());
fPlayer.msg(TL.COMMAND_FWARP_WARPED, warpName); fPlayer.msg(TL.COMMAND_FWARP_WARPED, warpName);
} }
}, this.p.getConfig().getLong("warmups.f-warp", 0)); }, FactionsPlugin.getInstance().getConfig().getLong("warmups.f-warp", 0));
} else { } else {
fme.msg(TL.COMMAND_FWARP_INVALID_WARP, warpName); context.msg(TL.COMMAND_FWARP_INVALID_WARP, warpName);
} }
} }
} }
private boolean transact(FPlayer player) { private boolean transact(FPlayer player, CommandContext context) {
return !P.p.getConfig().getBoolean("warp-cost.enabled", false) || player.isAdminBypassing() || payForCommand(P.p.getConfig().getDouble("warp-cost.warp", 5), TL.COMMAND_FWARP_TOWARP.toString(), TL.COMMAND_FWARP_FORWARPING.toString()); return !FactionsPlugin.getInstance().getConfig().getBoolean("warp-cost.enabled", false) || player.isAdminBypassing() || context.payForCommand(FactionsPlugin.getInstance().getConfig().getDouble("warp-cost.warp", 5), TL.COMMAND_FWARP_TOWARP.toString(), TL.COMMAND_FWARP_FORWARPING.toString());
} }
@Override @Override
public TL getUsageTranslation() { public TL getUsageTranslation() {
return TL.COMMAND_FWARP_DESCRIPTION; return TL.COMMAND_FWARP_DESCRIPTION;
} }
} }

View File

@@ -4,14 +4,12 @@ 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.Relation; import com.massivecraft.factions.struct.Relation;
import com.massivecraft.factions.util.Particles.ParticleEffect;
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.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.Bukkit; import org.bukkit.Bukkit;
import org.bukkit.GameMode; import org.bukkit.GameMode;
import org.bukkit.Particle;
import org.bukkit.entity.Entity; import org.bukkit.entity.Entity;
import org.bukkit.entity.Player; import org.bukkit.entity.Player;
@@ -28,52 +26,27 @@ public class CmdFly extends FCommand {
public CmdFly() { public CmdFly() {
super(); super();
this.aliases.add("fly"); this.aliases.add("fly");
this.optionalArgs.put("on/off", "flip"); this.optionalArgs.put("on/off", "flip");
this.requirements = new CommandRequirements.Builder(Permission.FLY)
this.permission = Permission.FLY.node; .playerOnly()
this.senderMustBeMember = true; .memberOnly()
this.senderMustBeModerator = false; .build();
} }
public static void startParticles() { public static void startParticles() {
// Just a secondary check.
if (!P.p.getConfig().getBoolean("ffly.Particles.Enabled")) {
return;
}
id = Bukkit.getScheduler().scheduleSyncRepeatingTask(P.p, () -> { id = Bukkit.getScheduler().scheduleSyncRepeatingTask(FactionsPlugin.getInstance(), () -> {
for (String name : flyMap.keySet()) { for (String name : flyMap.keySet()) {
Player player = Bukkit.getPlayer(name); Player player = Bukkit.getPlayer(name);
if (player == null) { if (player == null) continue;
continue; if (!player.isFlying()) continue;
} if (!FactionsPlugin.getInstance().mc17) {
if (!player.isFlying()) { if (player.getGameMode() == GameMode.SPECTATOR) continue;
continue;
}
if (!P.p.mc17) {
if (player.getGameMode() == GameMode.SPECTATOR) {
continue;
}
} }
if (FPlayers.getInstance().getByPlayer(player).isVanished()) { FPlayer fplayer = FPlayers.getInstance().getByPlayer(player);
// Actually, vanished players (such as admins) should not display particles to prevent others from knowing their vanished assistance for moderation. fplayer.isVanished();
// But we can keep it as a config.
if (P.p.getConfig().getBoolean("ffly.Particles.Enable-While-Vanished")) {
return;
}
continue;
}
if (P.p.useNonPacketParticles) {
// 1.9+ based servers will use the built in particleAPI instead of packet based.
// any particle amount higher than 0 made them go everywhere, and the offset at 0 was not working.
// So setting the amount to 0 spawns 1 in the precise location
player.getWorld().spawnParticle(Particle.CLOUD, player.getLocation().add(0, -0.35, 0), 0);
} else {
ParticleEffect.CLOUD.display((float) 0, (float) 0, (float) 0, (float) 0, 3, player.getLocation().add(0, -0.35, 0), 16);
}
} }
if (flyMap.keySet().size() == 0) { if (flyMap.keySet().size() == 0) {
@@ -84,7 +57,7 @@ public class CmdFly extends FCommand {
} }
public static void startFlyCheck() { public static void startFlyCheck() {
flyid = Bukkit.getScheduler().scheduleSyncRepeatingTask(P.p, () -> { //threw the exception for now, until I recode fly :( Cringe. flyid = Bukkit.getScheduler().scheduleSyncRepeatingTask(FactionsPlugin.getInstance(), () -> { //threw the exception for now, until I recode fly :( Cringe.
checkTaskState(); checkTaskState();
if (flyMap.keySet().size() != 0) { if (flyMap.keySet().size() != 0) {
for (String name : flyMap.keySet()) { for (String name : flyMap.keySet()) {
@@ -95,7 +68,7 @@ public class CmdFly extends FCommand {
if (player == null if (player == null
|| !player.isFlying() || !player.isFlying()
|| player.getGameMode() == GameMode.CREATIVE || player.getGameMode() == GameMode.CREATIVE
|| !P.p.mc17 && player.getGameMode() == GameMode.SPECTATOR) { || !FactionsPlugin.getInstance().mc17 && player.getGameMode() == GameMode.SPECTATOR) {
continue; continue;
} }
FPlayer fPlayer = FPlayers.getInstance().getByPlayer(player); FPlayer fPlayer = FPlayers.getInstance().getByPlayer(player);
@@ -105,7 +78,7 @@ public class CmdFly extends FCommand {
flyMap.remove(name); flyMap.remove(name);
continue; continue;
} }
if (fPlayer.checkIfNearbyEnemies()) { if (player.hasPermission("factions.fly.bypassnearbyenemycheck") || fPlayer.checkIfNearbyEnemies()) {
continue; continue;
} }
FLocation myFloc = new FLocation(player.getLocation()); FLocation myFloc = new FLocation(player.getLocation());
@@ -174,57 +147,53 @@ public class CmdFly extends FCommand {
} }
@Override @Override
public void perform() { public void perform(CommandContext context) {
// Disabled by default. // Disabled by default.
if (!P.p.getConfig().getBoolean("enable-faction-flight", false)) { if (!FactionsPlugin.getInstance().getConfig().getBoolean("enable-faction-flight", false)) {
fme.msg(TL.COMMAND_FLY_DISABLED); context.fPlayer.msg(TL.COMMAND_FLY_DISABLED);
return; return;
} }
FLocation myfloc = new FLocation(me.getLocation()); FLocation myfloc = new FLocation(context.player.getLocation());
Faction toFac = Board.getInstance().getFactionAt(myfloc); Faction toFac = Board.getInstance().getFactionAt(myfloc);
if (!checkBypassPerms(fme, me, toFac)) return; if (!checkBypassPerms(context.fPlayer, context.player, toFac)) return;
List<Entity> entities = this.me.getNearbyEntities(16.0D, 256.0D, 16.0D); List<Entity> entities = context.player.getNearbyEntities(16.0D, 256.0D, 16.0D);
for (int i = 0; i <= entities.size() - 1; ++i) { for (int i = 0; i <= entities.size() - 1; ++i) {
if (entities.get(i) instanceof Player) { if (entities.get(i) instanceof Player) {
Player eplayer = (Player) entities.get(i); Player eplayer = (Player) entities.get(i);
FPlayer efplayer = FPlayers.getInstance().getByPlayer(eplayer); FPlayer efplayer = FPlayers.getInstance().getByPlayer(eplayer);
if (efplayer.getRelationTo(this.fme) == Relation.ENEMY && !efplayer.isStealthEnabled()) { if (efplayer.getRelationTo(context.fPlayer) == Relation.ENEMY && !efplayer.isStealthEnabled()) {
this.fme.msg(TL.COMMAND_FLY_CHECK_ENEMY); context.msg(TL.COMMAND_FLY_CHECK_ENEMY);
return; return;
} }
} }
} }
if (args.size() == 0) { if (context.args.size() == 0) {
toggleFlight(fme.isFlying(), me); toggleFlight(context.fPlayer.isFlying(), context.fPlayer, context);
} else if (args.size() == 1) { } else if (context.args.size() == 1) {
toggleFlight(argAsBool(0), me); toggleFlight(context.argAsBool(0), context.fPlayer, context);
} }
} }
private void toggleFlight(final boolean toggle, final Player player) { private void toggleFlight(final boolean toggle, final FPlayer fme, CommandContext context) {
if (toggle) { if (toggle) {
fme.setFlying(false); fme.setFlying(false);
flyMap.remove(player.getName()); flyMap.remove(fme.getPlayer().getName());
return; return;
} }
if (fme.canFlyAtLocation()) if (fme.canFlyAtLocation())
this.doWarmUp(WarmUpUtil.Warmup.FLIGHT, TL.WARMUPS_NOTIFY_FLIGHT, "Fly", () -> { context.doWarmUp(WarmUpUtil.Warmup.FLIGHT, TL.WARMUPS_NOTIFY_FLIGHT, "Fly", () -> {
fme.setFlying(true); fme.setFlying(true);
flyMap.put(player.getName(), true); flyMap.put(fme.getPlayer().getName(), true);
if (id == -1) {
if (P.p.getConfig().getBoolean("ffly.Particles.Enabled")) {
startParticles();
}
}
if (flyid == -1) { if (flyid == -1) {
startFlyCheck(); startFlyCheck();
} }
}, this.p.getConfig().getLong("warmups.f-fly", 0)); }, FactionsPlugin.getInstance().getConfig().getLong("warmups.f-fly", 0));
} }
@Override @Override
@@ -232,4 +201,4 @@ public class CmdFly extends FCommand {
return TL.COMMAND_FLY_DESCRIPTION; return TL.COMMAND_FLY_DESCRIPTION;
} }
} }

View File

@@ -1,49 +1,45 @@
package com.massivecraft.factions.cmd; package com.massivecraft.factions.cmd;
import com.massivecraft.factions.FPlayer; import com.massivecraft.factions.FPlayer;
import com.massivecraft.factions.P; import com.massivecraft.factions.FactionsPlugin;
import com.massivecraft.factions.scoreboards.FTeamWrapper; import com.massivecraft.factions.scoreboards.FTeamWrapper;
import com.massivecraft.factions.struct.Permission; import com.massivecraft.factions.struct.Permission;
import com.massivecraft.factions.zcore.util.TL; import com.massivecraft.factions.zcore.util.TL;
public class CmdFocus public class CmdFocus extends FCommand {
extends FCommand {
public CmdFocus() { public CmdFocus() {
aliases.add("focus"); aliases.add("focus");
requiredArgs.add("player"); requiredArgs.add("player");
permission = Permission.FOCUS.node; this.requirements = new CommandRequirements.Builder(Permission.FOCUS)
.playerOnly()
.memberOnly()
senderMustBePlayer = true; .build();
senderMustBeMember = false;
senderMustBeModerator = true;
senderMustBeColeader = false;
senderMustBeAdmin = false;
} }
public void perform() { @Override
if (!P.p.getConfig().getBoolean("ffocus.Enabled")) { public void perform(CommandContext context) {
fme.msg(TL.GENERIC_DISABLED); if (!FactionsPlugin.getInstance().getConfig().getBoolean("ffocus.Enabled")) {
context.msg(TL.GENERIC_DISABLED);
return; return;
} }
FPlayer target = argAsFPlayer(0); FPlayer target = context.argAsFPlayer(0);
if (target == null) { if (target == null) {
return; return;
} }
if (target.getFaction().getId().equalsIgnoreCase(myFaction.getId())) { if (target.getFaction().getId().equalsIgnoreCase(context.faction.getId())) {
fme.msg(TL.COMMAND_FOCUS_SAMEFACTION); context.msg(TL.COMMAND_FOCUS_SAMEFACTION);
return; return;
} }
if ((myFaction.getFocused() != null) && (myFaction.getFocused().equalsIgnoreCase(target.getName()))) { if ((context.faction.getFocused() != null) && (context.faction.getFocused().equalsIgnoreCase(target.getName()))) {
myFaction.setFocused(null); context.faction.setFocused(null);
myFaction.msg(TL.COMMAND_FOCUS_NO_LONGER, target.getName()); context.faction.msg(TL.COMMAND_FOCUS_NO_LONGER, target.getName());
FTeamWrapper.updatePrefixes(target.getFaction()); FTeamWrapper.updatePrefixes(target.getFaction());
return; return;
} }
myFaction.msg(TL.COMMAND_FOCUS_FOCUSING, target.getName()); context.faction.msg(TL.COMMAND_FOCUS_FOCUSING, target.getName());
myFaction.setFocused(target.getName()); context.faction.setFocused(target.getName());
FTeamWrapper.updatePrefixes(target.getFaction()); FTeamWrapper.updatePrefixes(target.getFaction());
} }
@@ -51,4 +47,3 @@ public class CmdFocus
return TL.COMMAND_FOCUS_DESCRIPTION; return TL.COMMAND_FOCUS_DESCRIPTION;
} }
} }

View File

@@ -1,6 +1,6 @@
package com.massivecraft.factions.cmd; package com.massivecraft.factions.cmd;
import com.massivecraft.factions.P; import com.massivecraft.factions.FactionsPlugin;
import com.massivecraft.factions.struct.Permission; import com.massivecraft.factions.struct.Permission;
import com.massivecraft.factions.zcore.util.TL; import com.massivecraft.factions.zcore.util.TL;
import org.bukkit.Location; import org.bukkit.Location;
@@ -11,48 +11,42 @@ import org.bukkit.inventory.ItemStack;
public class CmdGetVault extends FCommand { public class CmdGetVault extends FCommand {
public CmdGetVault() { public CmdGetVault() {
super(); super();
this.aliases.add("getvault"); this.aliases.add("getvault");
this.permission = Permission.GETVAULT.node; this.requirements = new CommandRequirements.Builder(Permission.GETVAULT)
this.disableOnLock = true; .playerOnly()
.memberOnly()
.build();
senderMustBePlayer = true;
senderMustBeMember = true;
senderMustBeModerator = false;
senderMustBeColeader = false;
senderMustBeAdmin = false;
} }
@Override @Override
public void perform() { public void perform(CommandContext context) {
if (!P.p.getConfig().getBoolean("fvault.Enabled")) { if (!FactionsPlugin.getInstance().getConfig().getBoolean("fvault.Enabled")) {
fme.sendMessage("This command is disabled!"); context.fPlayer.sendMessage("This command is disabled!");
return; return;
} }
Location vaultLocation = fme.getFaction().getVault(); Location vaultLocation = context.faction.getVault();
ItemStack vault = P.p.createItem(Material.CHEST, 1, (short) 0, P.p.color(P.p.getConfig().getString("fvault.Item.Name")), P.p.colorList(P.p.getConfig().getStringList("fvault.Item.Lore"))); ItemStack vault = FactionsPlugin.getInstance().createItem(Material.CHEST, 1, (short) 0, FactionsPlugin.getInstance().color(FactionsPlugin.getInstance().getConfig().getString("fvault.Item.Name")), FactionsPlugin.getInstance().colorList(FactionsPlugin.getInstance().getConfig().getStringList("fvault.Item.Lore")));
//check if vault is set //check if vault is set
if (vaultLocation != null) { if (vaultLocation != null) {
fme.msg(TL.COMMAND_GETVAULT_ALREADYSET); context.msg(TL.COMMAND_GETVAULT_ALREADYSET);
return; return;
} }
//has enough money? //has enough money?
int amount = P.p.getConfig().getInt("fvault.Price"); int amount = FactionsPlugin.getInstance().getConfig().getInt("fvault.Price");
if (!fme.hasMoney(amount)) { if (!context.fPlayer.hasMoney(amount)) {
return; return;
} }
//success :) //success :)
fme.takeMoney(amount); context.fPlayer.takeMoney(amount);
me.getInventory().addItem(vault); context.player.getInventory().addItem(vault);
fme.msg(TL.COMMAND_GETVAULT_RECEIVE); context.fPlayer.msg(TL.COMMAND_GETVAULT_RECEIVE);
} }

View File

@@ -1,7 +1,7 @@
package com.massivecraft.factions.cmd; package com.massivecraft.factions.cmd;
import com.massivecraft.factions.Conf; import com.massivecraft.factions.Conf;
import com.massivecraft.factions.P; import com.massivecraft.factions.FactionsPlugin;
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.zcore.util.TL; import com.massivecraft.factions.zcore.util.TL;
@@ -24,14 +24,8 @@ public class CmdHelp extends FCommand {
//this.requiredArgs.add(""); //this.requiredArgs.add("");
this.optionalArgs.put("page", "1"); this.optionalArgs.put("page", "1");
this.permission = Permission.HELP.node; this.requirements = new CommandRequirements.Builder(Permission.HELP)
this.disableOnLock = false; .build();
senderMustBePlayer = false;
senderMustBeMember = false;
senderMustBeModerator = false;
senderMustBeColeader = false;
senderMustBeAdmin = false;
} }
//----------------------------------------------// //----------------------------------------------//
@@ -39,80 +33,80 @@ public class CmdHelp extends FCommand {
//----------------------------------------------// //----------------------------------------------//
@Override @Override
public void perform() { public void perform(CommandContext context) {
if (P.p.getConfig().getBoolean("use-old-help", true)) { if (FactionsPlugin.getInstance().getConfig().getBoolean("use-old-help", true)) {
if (helpPages == null) { if (helpPages == null) {
updateHelp(); updateHelp(context);
} }
int page = this.argAsInt(0, 1); int page = context.argAsInt(0, 1);
sendMessage(p.txt.titleize("Factions Help (" + page + "/" + helpPages.size() + ")")); context.sendMessage(FactionsPlugin.getInstance().txt.titleize("Factions Help (" + page + "/" + helpPages.size() + ")"));
page -= 1; page -= 1;
if (page < 0 || page >= helpPages.size()) { if (page < 0 || page >= helpPages.size()) {
msg(TL.COMMAND_HELP_404.format(String.valueOf(page))); context.msg(TL.COMMAND_HELP_404.format(String.valueOf(page)));
return; return;
} }
sendMessage(helpPages.get(page)); context.sendMessage(helpPages.get(page));
return; return;
} }
ConfigurationSection help = P.p.getConfig().getConfigurationSection("help"); ConfigurationSection help = FactionsPlugin.getInstance().getConfig().getConfigurationSection("help");
if (help == null) { if (help == null) {
help = P.p.getConfig().createSection("help"); // create new help section help = FactionsPlugin.getInstance().getConfig().createSection("help"); // create new help section
List<String> error = new ArrayList<>(); List<String> error = new ArrayList<>();
error.add("&cUpdate help messages in config.yml!"); error.add("&cUpdate help messages in config.yml!");
error.add("&cSet use-old-help for legacy help messages"); error.add("&cSet use-old-help for legacy help messages");
help.set("'1'", error); // add default error messages help.set("'1'", error); // add default error messages
} }
String pageArg = this.argAsString(0, "1"); String pageArg = context.argAsString(0, "1");
List<String> page = help.getStringList(pageArg); List<String> page = help.getStringList(pageArg);
if (page == null || page.isEmpty()) { if (page == null || page.isEmpty()) {
msg(TL.COMMAND_HELP_404.format(pageArg)); context.msg(TL.COMMAND_HELP_404.format(pageArg));
return; return;
} }
for (String helpLine : page) { for (String helpLine : page) {
sendMessage(P.p.txt.parse(helpLine)); context.sendMessage(FactionsPlugin.getInstance().txt.parse(helpLine));
} }
} }
public void updateHelp() { public void updateHelp(CommandContext context) {
helpPages = new ArrayList<>(); helpPages = new ArrayList<>();
ArrayList<String> pageLines; ArrayList<String> pageLines;
pageLines = new ArrayList<>(); pageLines = new ArrayList<>();
pageLines.add(p.cmdBase.cmdHelp.getUseageTemplate(true)); pageLines.add(FactionsPlugin.getInstance().cmdBase.cmdHelp.getUsageTemplate(context));
pageLines.add(p.cmdBase.cmdList.getUseageTemplate(true)); pageLines.add(FactionsPlugin.getInstance().cmdBase.cmdList.getUsageTemplate(context));
pageLines.add(p.cmdBase.cmdShow.getUseageTemplate(true)); pageLines.add(FactionsPlugin.getInstance().cmdBase.cmdShow.getUsageTemplate(context));
pageLines.add(p.cmdBase.cmdPower.getUseageTemplate(true)); pageLines.add(FactionsPlugin.getInstance().cmdBase.cmdPower.getUsageTemplate(context));
pageLines.add(p.cmdBase.cmdJoin.getUseageTemplate(true)); pageLines.add(FactionsPlugin.getInstance().cmdBase.cmdJoin.getUsageTemplate(context));
pageLines.add(p.cmdBase.cmdLeave.getUseageTemplate(true)); pageLines.add(FactionsPlugin.getInstance().cmdBase.cmdLeave.getUsageTemplate(context));
pageLines.add(p.cmdBase.cmdChat.getUseageTemplate(true)); pageLines.add(FactionsPlugin.getInstance().cmdBase.cmdChat.getUsageTemplate(context));
pageLines.add(p.cmdBase.cmdToggleAllianceChat.getUseageTemplate(true)); pageLines.add(FactionsPlugin.getInstance().cmdBase.cmdToggleAllianceChat.getUsageTemplate(context));
pageLines.add(p.cmdBase.cmdHome.getUseageTemplate(true)); pageLines.add(FactionsPlugin.getInstance().cmdBase.cmdHome.getUsageTemplate(context));
pageLines.add(p.txt.parse(TL.COMMAND_HELP_NEXTCREATE.toString())); pageLines.add(FactionsPlugin.getInstance().txt.parse(TL.COMMAND_HELP_NEXTCREATE.toString()));
helpPages.add(pageLines); helpPages.add(pageLines);
pageLines = new ArrayList<>(); pageLines = new ArrayList<>();
pageLines.add(p.cmdBase.cmdCreate.getUseageTemplate(true)); pageLines.add(FactionsPlugin.getInstance().cmdBase.cmdCreate.getUsageTemplate(context));
pageLines.add(p.cmdBase.cmdDescription.getUseageTemplate(true)); pageLines.add(FactionsPlugin.getInstance().cmdBase.cmdDescription.getUsageTemplate(context));
pageLines.add(p.cmdBase.cmdTag.getUseageTemplate(true)); pageLines.add(FactionsPlugin.getInstance().cmdBase.cmdTag.getUsageTemplate(context));
pageLines.add(p.txt.parse(TL.COMMAND_HELP_INVITATIONS.toString())); pageLines.add(FactionsPlugin.getInstance().txt.parse(TL.COMMAND_HELP_INVITATIONS.toString()));
pageLines.add(p.cmdBase.cmdOpen.getUseageTemplate(true)); pageLines.add(FactionsPlugin.getInstance().cmdBase.cmdOpen.getUsageTemplate(context));
pageLines.add(p.cmdBase.cmdInvite.getUseageTemplate(true)); pageLines.add(FactionsPlugin.getInstance().cmdBase.cmdInvite.getUsageTemplate(context));
pageLines.add(p.cmdBase.cmdDeinvite.getUseageTemplate(true)); pageLines.add(FactionsPlugin.getInstance().cmdBase.cmdDeinvite.getUsageTemplate(context));
pageLines.add(p.txt.parse(TL.COMMAND_HELP_HOME.toString())); pageLines.add(FactionsPlugin.getInstance().txt.parse(TL.COMMAND_HELP_HOME.toString()));
pageLines.add(p.cmdBase.cmdSethome.getUseageTemplate(true)); pageLines.add(FactionsPlugin.getInstance().cmdBase.cmdSethome.getUsageTemplate(context));
helpPages.add(pageLines); helpPages.add(pageLines);
if (Econ.isSetup() && Conf.econEnabled && Conf.bankEnabled) { if (Econ.isSetup() && Conf.econEnabled && Conf.bankEnabled) {
pageLines = new ArrayList<>(); pageLines = new ArrayList<>();
pageLines.add(""); pageLines.add("");
pageLines.add(p.txt.parse(TL.COMMAND_HELP_BANK_1.toString())); pageLines.add(FactionsPlugin.getInstance().txt.parse(TL.COMMAND_HELP_BANK_1.toString()));
pageLines.add(p.txt.parse(TL.COMMAND_HELP_BANK_2.toString())); pageLines.add(FactionsPlugin.getInstance().txt.parse(TL.COMMAND_HELP_BANK_2.toString()));
pageLines.add(p.txt.parse(TL.COMMAND_HELP_BANK_3.toString())); pageLines.add(FactionsPlugin.getInstance().txt.parse(TL.COMMAND_HELP_BANK_3.toString()));
pageLines.add(""); pageLines.add("");
pageLines.add(p.cmdBase.cmdMoney.getUseageTemplate(true)); pageLines.add(FactionsPlugin.getInstance().cmdBase.cmdMoney.getUsageTemplate(context));
pageLines.add(""); pageLines.add("");
pageLines.add(""); pageLines.add("");
pageLines.add(""); pageLines.add("");
@@ -120,94 +114,94 @@ public class CmdHelp extends FCommand {
} }
pageLines = new ArrayList<>(); pageLines = new ArrayList<>();
pageLines.add(p.cmdBase.cmdClaim.getUseageTemplate(true)); pageLines.add(FactionsPlugin.getInstance().cmdBase.cmdClaim.getUsageTemplate(context));
pageLines.add(p.cmdBase.cmdAutoClaim.getUseageTemplate(true)); pageLines.add(FactionsPlugin.getInstance().cmdBase.cmdAutoClaim.getUsageTemplate(context));
pageLines.add(p.cmdBase.cmdUnclaim.getUseageTemplate(true)); pageLines.add(FactionsPlugin.getInstance().cmdBase.cmdUnclaim.getUsageTemplate(context));
pageLines.add(p.cmdBase.cmdUnclaimall.getUseageTemplate(true)); pageLines.add(FactionsPlugin.getInstance().cmdBase.cmdUnclaimall.getUsageTemplate(context));
pageLines.add(p.cmdBase.cmdKick.getUseageTemplate(true)); pageLines.add(FactionsPlugin.getInstance().cmdBase.cmdKick.getUsageTemplate(context));
pageLines.add(p.cmdBase.cmdMod.getUseageTemplate(true)); pageLines.add(FactionsPlugin.getInstance().cmdBase.cmdMod.getUsageTemplate(context));
pageLines.add(p.cmdBase.cmdAdmin.getUseageTemplate(true)); pageLines.add(FactionsPlugin.getInstance().cmdBase.cmdAdmin.getUsageTemplate(context));
pageLines.add(p.cmdBase.cmdTitle.getUseageTemplate(true)); pageLines.add(FactionsPlugin.getInstance().cmdBase.cmdTitle.getUsageTemplate(context));
pageLines.add(p.cmdBase.cmdSB.getUseageTemplate(true)); pageLines.add(FactionsPlugin.getInstance().cmdBase.cmdSB.getUsageTemplate(context));
pageLines.add(p.cmdBase.cmdSeeChunk.getUseageTemplate(true)); pageLines.add(FactionsPlugin.getInstance().cmdBase.cmdSeeChunk.getUsageTemplate(context));
pageLines.add(p.cmdBase.cmdStatus.getUseageTemplate(true)); pageLines.add(FactionsPlugin.getInstance().cmdBase.cmdStatus.getUsageTemplate(context));
pageLines.add(p.txt.parse(TL.COMMAND_HELP_PLAYERTITLES.toString())); pageLines.add(FactionsPlugin.getInstance().txt.parse(TL.COMMAND_HELP_PLAYERTITLES.toString()));
helpPages.add(pageLines); helpPages.add(pageLines);
pageLines = new ArrayList<>(); pageLines = new ArrayList<>();
pageLines.add(p.cmdBase.cmdMap.getUseageTemplate(true)); pageLines.add(FactionsPlugin.getInstance().cmdBase.cmdMap.getUsageTemplate(context));
pageLines.add(p.cmdBase.cmdBoom.getUseageTemplate(true)); pageLines.add(FactionsPlugin.getInstance().cmdBase.cmdBoom.getUsageTemplate(context));
pageLines.add(p.cmdBase.cmdOwner.getUseageTemplate(true)); pageLines.add(FactionsPlugin.getInstance().cmdBase.cmdOwner.getUsageTemplate(context));
pageLines.add(p.cmdBase.cmdOwnerList.getUseageTemplate(true)); pageLines.add(FactionsPlugin.getInstance().cmdBase.cmdOwnerList.getUsageTemplate(context));
pageLines.add(p.txt.parse(TL.COMMAND_HELP_OWNERSHIP_1.toString())); pageLines.add(FactionsPlugin.getInstance().txt.parse(TL.COMMAND_HELP_OWNERSHIP_1.toString()));
pageLines.add(p.txt.parse(TL.COMMAND_HELP_OWNERSHIP_2.toString())); pageLines.add(FactionsPlugin.getInstance().txt.parse(TL.COMMAND_HELP_OWNERSHIP_2.toString()));
pageLines.add(p.txt.parse(TL.COMMAND_HELP_OWNERSHIP_3.toString())); pageLines.add(FactionsPlugin.getInstance().txt.parse(TL.COMMAND_HELP_OWNERSHIP_3.toString()));
helpPages.add(pageLines); helpPages.add(pageLines);
pageLines = new ArrayList<>(); pageLines = new ArrayList<>();
pageLines.add(p.cmdBase.cmdDisband.getUseageTemplate(true)); pageLines.add(FactionsPlugin.getInstance().cmdBase.cmdDisband.getUsageTemplate(context));
pageLines.add(""); pageLines.add("");
pageLines.add(p.cmdBase.cmdRelationAlly.getUseageTemplate(true)); pageLines.add(FactionsPlugin.getInstance().cmdBase.cmdRelationAlly.getUsageTemplate(context));
pageLines.add(p.cmdBase.cmdRelationNeutral.getUseageTemplate(true)); pageLines.add(FactionsPlugin.getInstance().cmdBase.cmdRelationNeutral.getUsageTemplate(context));
pageLines.add(p.cmdBase.cmdRelationEnemy.getUseageTemplate(true)); pageLines.add(FactionsPlugin.getInstance().cmdBase.cmdRelationEnemy.getUsageTemplate(context));
pageLines.add(p.txt.parse(TL.COMMAND_HELP_RELATIONS_1.toString())); pageLines.add(FactionsPlugin.getInstance().txt.parse(TL.COMMAND_HELP_RELATIONS_1.toString()));
pageLines.add(p.txt.parse(TL.COMMAND_HELP_RELATIONS_2.toString())); pageLines.add(FactionsPlugin.getInstance().txt.parse(TL.COMMAND_HELP_RELATIONS_2.toString()));
pageLines.add(p.txt.parse(TL.COMMAND_HELP_RELATIONS_3.toString())); pageLines.add(FactionsPlugin.getInstance().txt.parse(TL.COMMAND_HELP_RELATIONS_3.toString()));
pageLines.add(p.txt.parse(TL.COMMAND_HELP_RELATIONS_4.toString())); pageLines.add(FactionsPlugin.getInstance().txt.parse(TL.COMMAND_HELP_RELATIONS_4.toString()));
helpPages.add(pageLines); helpPages.add(pageLines);
pageLines = new ArrayList<>(); pageLines = new ArrayList<>();
pageLines.add(p.txt.parse(TL.COMMAND_HELP_RELATIONS_5.toString())); pageLines.add(FactionsPlugin.getInstance().txt.parse(TL.COMMAND_HELP_RELATIONS_5.toString()));
pageLines.add(p.txt.parse(TL.COMMAND_HELP_RELATIONS_6.toString())); pageLines.add(FactionsPlugin.getInstance().txt.parse(TL.COMMAND_HELP_RELATIONS_6.toString()));
pageLines.add(p.txt.parse(TL.COMMAND_HELP_RELATIONS_7.toString())); pageLines.add(FactionsPlugin.getInstance().txt.parse(TL.COMMAND_HELP_RELATIONS_7.toString()));
pageLines.add(TL.COMMAND_HELP_RELATIONS_8.toString()); pageLines.add(TL.COMMAND_HELP_RELATIONS_8.toString());
pageLines.add(p.txt.parse(TL.COMMAND_HELP_RELATIONS_9.toString())); pageLines.add(FactionsPlugin.getInstance().txt.parse(TL.COMMAND_HELP_RELATIONS_9.toString()));
pageLines.add(p.txt.parse(TL.COMMAND_HELP_RELATIONS_10.toString())); pageLines.add(FactionsPlugin.getInstance().txt.parse(TL.COMMAND_HELP_RELATIONS_10.toString()));
pageLines.add(p.txt.parse(TL.COMMAND_HELP_RELATIONS_11.toString())); pageLines.add(FactionsPlugin.getInstance().txt.parse(TL.COMMAND_HELP_RELATIONS_11.toString()));
pageLines.add(p.txt.parse(TL.COMMAND_HELP_RELATIONS_12.toString())); pageLines.add(FactionsPlugin.getInstance().txt.parse(TL.COMMAND_HELP_RELATIONS_12.toString()));
pageLines.add(p.txt.parse(TL.COMMAND_HELP_RELATIONS_13.toString())); pageLines.add(FactionsPlugin.getInstance().txt.parse(TL.COMMAND_HELP_RELATIONS_13.toString()));
helpPages.add(pageLines); helpPages.add(pageLines);
pageLines = new ArrayList<>(); pageLines = new ArrayList<>();
pageLines.add(p.txt.parse(TL.COMMAND_HELP_PERMISSIONS_1.toString())); pageLines.add(FactionsPlugin.getInstance().txt.parse(TL.COMMAND_HELP_PERMISSIONS_1.toString()));
pageLines.add(p.txt.parse(TL.COMMAND_HELP_PERMISSIONS_2.toString())); pageLines.add(FactionsPlugin.getInstance().txt.parse(TL.COMMAND_HELP_PERMISSIONS_2.toString()));
pageLines.add(p.txt.parse(TL.COMMAND_HELP_PERMISSIONS_3.toString())); pageLines.add(FactionsPlugin.getInstance().txt.parse(TL.COMMAND_HELP_PERMISSIONS_3.toString()));
pageLines.add(TL.COMMAND_HELP_PERMISSIONS_4.toString()); pageLines.add(TL.COMMAND_HELP_PERMISSIONS_4.toString());
pageLines.add(p.txt.parse(TL.COMMAND_HELP_PERMISSIONS_5.toString())); pageLines.add(FactionsPlugin.getInstance().txt.parse(TL.COMMAND_HELP_PERMISSIONS_5.toString()));
pageLines.add(p.txt.parse(TL.COMMAND_HELP_PERMISSIONS_6.toString())); pageLines.add(FactionsPlugin.getInstance().txt.parse(TL.COMMAND_HELP_PERMISSIONS_6.toString()));
pageLines.add(p.txt.parse(TL.COMMAND_HELP_PERMISSIONS_7.toString())); pageLines.add(FactionsPlugin.getInstance().txt.parse(TL.COMMAND_HELP_PERMISSIONS_7.toString()));
pageLines.add(p.txt.parse(TL.COMMAND_HELP_PERMISSIONS_8.toString())); pageLines.add(FactionsPlugin.getInstance().txt.parse(TL.COMMAND_HELP_PERMISSIONS_8.toString()));
pageLines.add(p.txt.parse(TL.COMMAND_HELP_PERMISSIONS_9.toString())); pageLines.add(FactionsPlugin.getInstance().txt.parse(TL.COMMAND_HELP_PERMISSIONS_9.toString()));
helpPages.add(pageLines); helpPages.add(pageLines);
pageLines = new ArrayList<>(); pageLines = new ArrayList<>();
pageLines.add(TL.COMMAND_HELP_MOAR_1.toString()); pageLines.add(TL.COMMAND_HELP_MOAR_1.toString());
pageLines.add(p.cmdBase.cmdBypass.getUseageTemplate(true)); pageLines.add(FactionsPlugin.getInstance().cmdBase.cmdBypass.getUsageTemplate(context));
pageLines.add(p.txt.parse(TL.COMMAND_HELP_ADMIN_1.toString())); pageLines.add(FactionsPlugin.getInstance().txt.parse(TL.COMMAND_HELP_ADMIN_1.toString()));
pageLines.add(p.txt.parse(TL.COMMAND_HELP_ADMIN_2.toString())); pageLines.add(FactionsPlugin.getInstance().txt.parse(TL.COMMAND_HELP_ADMIN_2.toString()));
pageLines.add(p.txt.parse(TL.COMMAND_HELP_ADMIN_3.toString())); pageLines.add(FactionsPlugin.getInstance().txt.parse(TL.COMMAND_HELP_ADMIN_3.toString()));
pageLines.add(p.cmdBase.cmdSafeunclaimall.getUseageTemplate(true)); pageLines.add(FactionsPlugin.getInstance().cmdBase.cmdSafeunclaimall.getUsageTemplate(context));
pageLines.add(p.cmdBase.cmdWarunclaimall.getUseageTemplate(true)); pageLines.add(FactionsPlugin.getInstance().cmdBase.cmdWarunclaimall.getUsageTemplate(context));
//TODO:TL //TODO:TL
pageLines.add(p.txt.parse("<i>Note: " + p.cmdBase.cmdUnclaim.getUseageTemplate(false) + P.p.txt.parse("<i>") + " works on safe/war zones as well.")); pageLines.add(FactionsPlugin.getInstance().txt.parse("<i>Note: " + FactionsPlugin.getInstance().cmdBase.cmdUnclaim.getUsageTemplate(context) + FactionsPlugin.getInstance().txt.parse("<i>") + " works on safe/war zones as well."));
pageLines.add(p.cmdBase.cmdPeaceful.getUseageTemplate(true)); pageLines.add(FactionsPlugin.getInstance().cmdBase.cmdPeaceful.getUsageTemplate(context));
helpPages.add(pageLines); helpPages.add(pageLines);
pageLines = new ArrayList<>(); pageLines = new ArrayList<>();
pageLines.add(p.txt.parse(TL.COMMAND_HELP_MOAR_2.toString())); pageLines.add(FactionsPlugin.getInstance().txt.parse(TL.COMMAND_HELP_MOAR_2.toString()));
pageLines.add(p.cmdBase.cmdChatSpy.getUseageTemplate(true)); pageLines.add(FactionsPlugin.getInstance().cmdBase.cmdChatSpy.getUsageTemplate(context));
pageLines.add(p.cmdBase.cmdPermanent.getUseageTemplate(true)); pageLines.add(FactionsPlugin.getInstance().cmdBase.cmdPermanent.getUsageTemplate(context));
pageLines.add(p.cmdBase.cmdPermanentPower.getUseageTemplate(true)); pageLines.add(FactionsPlugin.getInstance().cmdBase.cmdPermanentPower.getUsageTemplate(context));
pageLines.add(p.cmdBase.cmdPowerBoost.getUseageTemplate(true)); pageLines.add(FactionsPlugin.getInstance().cmdBase.cmdPowerBoost.getUsageTemplate(context));
pageLines.add(p.cmdBase.cmdConfig.getUseageTemplate(true)); pageLines.add(FactionsPlugin.getInstance().cmdBase.cmdConfig.getUsageTemplate(context));
helpPages.add(pageLines); helpPages.add(pageLines);
pageLines = new ArrayList<>(); pageLines = new ArrayList<>();
pageLines.add(p.txt.parse(TL.COMMAND_HELP_MOAR_3.toString())); pageLines.add(FactionsPlugin.getInstance().txt.parse(TL.COMMAND_HELP_MOAR_3.toString()));
pageLines.add(p.cmdBase.cmdLock.getUseageTemplate(true)); pageLines.add(FactionsPlugin.getInstance().cmdBase.cmdLock.getUsageTemplate(context));
pageLines.add(p.cmdBase.cmdReload.getUseageTemplate(true)); pageLines.add(FactionsPlugin.getInstance().cmdBase.cmdReload.getUsageTemplate(context));
pageLines.add(p.cmdBase.cmdSaveAll.getUseageTemplate(true)); pageLines.add(FactionsPlugin.getInstance().cmdBase.cmdSaveAll.getUsageTemplate(context));
pageLines.add(p.cmdBase.cmdVersion.getUseageTemplate(true)); pageLines.add(FactionsPlugin.getInstance().cmdBase.cmdVersion.getUsageTemplate(context));
helpPages.add(pageLines); helpPages.add(pageLines);
} }

View File

@@ -1,6 +1,7 @@
package com.massivecraft.factions.cmd; package com.massivecraft.factions.cmd;
import com.massivecraft.factions.*; import com.massivecraft.factions.*;
import com.massivecraft.factions.integration.Essentials;
import com.massivecraft.factions.struct.Permission; import com.massivecraft.factions.struct.Permission;
import com.massivecraft.factions.struct.Relation; import com.massivecraft.factions.struct.Relation;
import com.massivecraft.factions.struct.Role; import com.massivecraft.factions.struct.Role;
@@ -23,106 +24,68 @@ public class CmdHome extends FCommand {
super(); super();
this.aliases.add("home"); this.aliases.add("home");
this.optionalArgs.put("faction", "yours"); this.requirements = new CommandRequirements.Builder(Permission.HOME)
//this.requiredArgs.add(""); .playerOnly()
//this.optionalArgs.put("", ""); .memberOnly()
.withAction(PermissableAction.HOME)
this.permission = Permission.HOME.node; .build();
this.disableOnLock = false;
senderMustBePlayer = true;
senderMustBeMember = false;
senderMustBeModerator = false;
senderMustBeColeader = false;
senderMustBeAdmin = false;
} }
@Override @Override
public void perform() { public void perform(CommandContext context) {
// TODO: Hide this command on help also. // TODO: Hide this command on help also.
if (!Conf.homesEnabled) { if (!Conf.homesEnabled) {
fme.msg(TL.COMMAND_HOME_DISABLED); context.msg(TL.COMMAND_HOME_DISABLED);
return; return;
} }
if (!Conf.homesTeleportCommandEnabled) { if (!Conf.homesTeleportCommandEnabled) {
fme.msg(TL.COMMAND_HOME_TELEPORTDISABLED); context.msg(TL.COMMAND_HOME_TELEPORTDISABLED);
return; return;
} }
Faction factionArg; if (!context.faction.hasHome()) {
context.msg(TL.COMMAND_HOME_NOHOME.toString() + (context.fPlayer.getRole().value < Role.MODERATOR.value ? TL.GENERIC_ASKYOURLEADER.toString() : TL.GENERIC_YOUSHOULD.toString()));
if (args.isEmpty()) context.sendMessage(FactionsPlugin.getInstance().cmdBase.cmdSethome.getUsageTemplate(context));
factionArg = myFaction;
else
factionArg = argAsFaction(0);
if (factionArg.isSystemFaction()) {
fme.msg(TL.GENERIC_NOPERMISSION, "teleport to system faction home");
return; return;
} }
myFaction = factionArg; if (!Conf.homesTeleportAllowedFromEnemyTerritory && context.fPlayer.isInEnemyTerritory()) {
context.msg(TL.COMMAND_HOME_INENEMY);
if (myFaction.isWilderness())
return; return;
}
if (!fme.isAdminBypassing()) { if (!Conf.homesTeleportAllowedFromDifferentWorld && context.player.getWorld().getUID() != context.faction.getHome().getWorld().getUID()) {
Access access = myFaction.getAccess(fme, PermissableAction.HOME); context.msg(TL.COMMAND_HOME_WRONGWORLD);
if (access != Access.ALLOW && fme.getRole() != Role.LEADER) { return;
fme.msg(TL.GENERIC_FPERM_NOPERMISSION, "teleport home"); }
if (!context.fPlayer.isAdminBypassing()) {
Access access = context.faction.getAccess(context.fPlayer, PermissableAction.HOME);
if (access != Access.ALLOW && context.fPlayer.getRole() != Role.LEADER) {
context.fPlayer.msg(TL.GENERIC_FPERM_NOPERMISSION, "teleport home");
return; return;
} }
} }
if (!myFaction.hasHome()) { Faction faction = Board.getInstance().getFactionAt(new FLocation(context.player.getLocation()));
fme.msg(TL.COMMAND_HOME_NOHOME.toString() + (fme.getRole().value < Role.MODERATOR.value ? TL.GENERIC_ASKYOURLEADER.toString() : TL.GENERIC_YOUSHOULD.toString())); final Location loc = context.player.getLocation().clone();
fme.sendMessage(p.cmdBase.cmdSethome.getUseageTemplate());
return;
}
if (!Conf.homesTeleportAllowedFromEnemyTerritory && fme.isInEnemyTerritory()) {
fme.msg(TL.COMMAND_HOME_INENEMY);
return;
}
if (!Conf.homesTeleportAllowedFromDifferentWorld && me.getWorld().getUID() != myFaction.getHome().getWorld().getUID()) {
fme.msg(TL.COMMAND_HOME_WRONGWORLD);
return;
}
if (!fme.isAdminBypassing()) {
Access access = fme.getFaction().getAccess(fme, PermissableAction.HOME);
if (access != Access.ALLOW && fme.getRole() != Role.LEADER) {
fme.msg(TL.GENERIC_FPERM_NOPERMISSION, "teleport home");
return;
}
}
Faction faction = Board.getInstance().getFactionAt(new FLocation(me.getLocation()));
final Location loc = me.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() && (!fme.isInOwnTerritory() || !Conf.homesTeleportIgnoreEnemiesIfInOwnTerritory)) { if (Conf.homesTeleportAllowedEnemyDistance > 0 && !faction.isSafeZone() && (!context.fPlayer.isInOwnTerritory() || !Conf.homesTeleportIgnoreEnemiesIfInOwnTerritory)) {
World w = loc.getWorld(); World w = loc.getWorld();
double x = loc.getX(); double x = loc.getX();
double y = loc.getY(); double y = loc.getY();
double z = loc.getZ(); double z = loc.getZ();
for (Player p : me.getServer().getOnlinePlayers()) { for (Player p : context.player.getServer().getOnlinePlayers()) {
if (p == null || !p.isOnline() || p.isDead() || p == me || p.getWorld() != w) { if (p == null || !p.isOnline() || p.isDead() || p == context.player || p.getWorld() != w) {
continue; continue;
} }
FPlayer fp = FPlayers.getInstance().getByPlayer(p); FPlayer fp = FPlayers.getInstance().getByPlayer(p);
if (fme.getRelationTo(fp) != Relation.ENEMY || fp.isVanished()) { if (context.fPlayer.getRelationTo(fp) != Relation.ENEMY || fp.isVanished()) {
continue; continue;
} }
@@ -137,37 +100,33 @@ public class CmdHome extends FCommand {
continue; continue;
} }
fme.msg(TL.COMMAND_HOME_ENEMYNEAR, String.valueOf(Conf.homesTeleportAllowedEnemyDistance)); context.msg(TL.COMMAND_HOME_ENEMYNEAR, String.valueOf(Conf.homesTeleportAllowedEnemyDistance));
return; return;
} }
} }
// if economy is enabled, they're not on the bypass list, and this command has a cost set, make 'em pay // if economy is enabled, they're not on the bypass list, and this command has a cost set, make 'em pay
if (!payForCommand(Conf.econCostHome, TL.COMMAND_HOME_TOTELEPORT.toString(), TL.COMMAND_HOME_FORTELEPORT.toString())) { if (!context.payForCommand(Conf.econCostHome, TL.COMMAND_HOME_TOTELEPORT.toString(), TL.COMMAND_HOME_FORTELEPORT.toString())) {
return; return;
} }
// TODO: Need to document this better confusing everyone, removed for now. // if Essentials teleport handling is enabled and available, pass the teleport off to it (for delay and cooldown)
// // if Essentials teleport handling is enabled and available, pass the teleport off to it (for delay and cooldown) if (Essentials.handleTeleport(context.player, context.faction.getHome())) {
// if (Essentials.handleTeleport(me, myFaction.getHome())) { return;
// return; }
// }
context.doWarmUp(WarmUpUtil.Warmup.HOME, TL.WARMUPS_NOTIFY_TELEPORT, "Home", () -> {
this.doWarmUp(WarmUpUtil.Warmup.HOME, TL.WARMUPS_NOTIFY_TELEPORT, "Home", () -> {
// Create a smoke effect // Create a smoke effect
if (Conf.homesTeleportCommandSmokeEffectEnabled) { if (Conf.homesTeleportCommandSmokeEffectEnabled) {
List<Location> smokeLocations = new ArrayList<>(); List<Location> smokeLocations = new ArrayList<>();
smokeLocations.add(loc); smokeLocations.add(loc);
smokeLocations.add(loc.add(0, 1, 0)); smokeLocations.add(loc.add(0, 1, 0));
smokeLocations.add(CmdHome.this.myFaction.getHome()); smokeLocations.add(context.faction.getHome());
smokeLocations.add(CmdHome.this.myFaction.getHome().clone().add(0, 1, 0)); smokeLocations.add(context.faction.getHome().clone().add(0, 1, 0));
SmokeUtil.spawnCloudRandom(smokeLocations, Conf.homesTeleportCommandSmokeEffectThickness); SmokeUtil.spawnCloudRandom(smokeLocations, Conf.homesTeleportCommandSmokeEffectThickness);
} }
context.player.teleport(context.faction.getHome());
CmdHome.this.me.teleport(CmdHome.this.myFaction.getHome()); }, FactionsPlugin.getInstance().getConfig().getLong("warmups.f-home", 0));
}, this.p.getConfig().getLong("warmups.f-home", 0));
} }
@Override @Override

View File

@@ -9,26 +9,21 @@ public class CmdInspect extends FCommand {
this.aliases.add("inspect"); this.aliases.add("inspect");
this.aliases.add("ins"); this.aliases.add("ins");
this.permission = Permission.INSPECT.node; this.requirements = new CommandRequirements.Builder(Permission.INSPECT)
this.disableOnLock = true; .playerOnly()
.memberOnly()
.build();
senderMustBePlayer = true;
senderMustBeMember = true;
senderMustBeModerator = false;
senderMustBeColeader = false;
senderMustBeAdmin = false;
} }
@Override @Override
public void perform() { public void perform(CommandContext context) {
if (fme.isInspectMode()) { if (context.fPlayer.isInspectMode()) {
fme.setInspectMode(false); context.fPlayer.setInspectMode(false);
msg(TL.COMMAND_INSPECT_DISABLED_MSG); context.msg(TL.COMMAND_INSPECT_DISABLED_MSG);
} else { } else {
fme.setInspectMode(true); context.fPlayer.setInspectMode(true);
msg(TL.COMMAND_INSPECT_ENABLED); context.msg(TL.COMMAND_INSPECT_ENABLED);
} }
} }
@@ -38,3 +33,4 @@ public class CmdInspect extends FCommand {
return TL.COMMAND_INSPECT_DESCRIPTION; return TL.COMMAND_INSPECT_DESCRIPTION;
} }
} }

View File

@@ -1,7 +1,7 @@
package com.massivecraft.factions.cmd; package com.massivecraft.factions.cmd;
import com.massivecraft.factions.FPlayer; import com.massivecraft.factions.FPlayer;
import com.massivecraft.factions.P; 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.struct.Role;
import com.massivecraft.factions.zcore.fperms.Access; import com.massivecraft.factions.zcore.fperms.Access;
@@ -24,44 +24,38 @@ public class CmdInventorySee extends FCommand {
this.requiredArgs.add("member name"); this.requiredArgs.add("member name");
this.permission = Permission.INVSEE.node; this.requirements = new CommandRequirements.Builder(Permission.INVSEE)
this.disableOnLock = true; .playerOnly()
this.disableOnSpam = false; .build();
senderMustBePlayer = true;
senderMustBeMember = true;
senderMustBeModerator = false;
senderMustBeColeader = false;
senderMustBeAdmin = false;
} }
@Override @Override
public void perform() { public void perform(CommandContext context) {
if (!P.p.getConfig().getBoolean("f-inventory-see.Enabled")) { if (!FactionsPlugin.getInstance().getConfig().getBoolean("f-inventory-see.Enabled")) {
fme.msg(TL.GENERIC_DISABLED); context.msg(TL.GENERIC_DISABLED);
return; return;
} }
Access use = myFaction.getAccess(fme, PermissableAction.TERRITORY); Access use = context.fPlayer.getFaction().getAccess(context.fPlayer, PermissableAction.TERRITORY);
if (use == Access.DENY || (use == Access.UNDEFINED && !assertMinRole(Role.MODERATOR))) { if (use == Access.DENY || (use == Access.UNDEFINED && !context.assertMinRole(Role.MODERATOR))) {
fme.msg(TL.GENERIC_NOPERMISSION, "territory"); context.msg(TL.GENERIC_NOPERMISSION, "see other faction members inventories");
return; return;
} }
ArrayList<Player> fplayers = myFaction.getOnlinePlayers(); ArrayList<Player> fplayers = context.fPlayer.getFaction().getOnlinePlayers();
FPlayer targetInv = argAsFPlayer(0); FPlayer targetInv = context.argAsFPlayer(0);
if (targetInv == null || !fplayers.contains(targetInv.getPlayer())) { if (targetInv == null || !fplayers.contains(targetInv.getPlayer())) {
fme.msg(TL.PLAYER_NOT_FOUND, Objects.requireNonNull(targetInv).toString()); context.msg(TL.PLAYER_NOT_FOUND, Objects.requireNonNull(targetInv.getName()));
return; return;
} }
Inventory inventory = Bukkit.createInventory(me, 36, targetInv.getName() + "'s Inventory"); Inventory inventory = Bukkit.createInventory(context.player, 36, targetInv.getName() + "'s Inventory");
for (int i = 0; i < 36; i++) for (int i = 0; i < 36; i++)
if (targetInv.getPlayer().getInventory().getItem(i) != null) if (targetInv.getPlayer().getInventory().getItem(i) != null)
inventory.setItem(i, targetInv.getPlayer().getInventory().getItem(i)); inventory.setItem(i, targetInv.getPlayer().getInventory().getItem(i));
me.openInventory(inventory); context.player.openInventory(inventory);
} }
@Override @Override

View File

@@ -2,9 +2,8 @@ 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.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;
@@ -18,72 +17,58 @@ public class CmdInvite extends FCommand {
this.aliases.add("inv"); this.aliases.add("inv");
this.requiredArgs.add("player name"); this.requiredArgs.add("player name");
//this.optionalArgs.put("", "");
this.permission = Permission.INVITE.node; this.requirements = new CommandRequirements.Builder(Permission.INVITE)
this.disableOnLock = true; .playerOnly()
.withAction(PermissableAction.INVITE)
.build();
senderMustBePlayer = true;
senderMustBeMember = false;
senderMustBeModerator = false;
senderMustBeColeader = false;
senderMustBeAdmin = false;
} }
@Override @Override
public void perform() { public void perform(CommandContext context) {
FPlayer target = this.argAsBestFPlayerMatch(0); FPlayer target = context.argAsBestFPlayerMatch(0);
if (target == null) { if (target == null) {
return; return;
} }
if (target.getFaction() == myFaction) { if (target.getFaction() == context.faction) {
msg(TL.COMMAND_INVITE_ALREADYMEMBER, target.getName(), myFaction.getTag()); context.msg(TL.COMMAND_INVITE_ALREADYMEMBER, target.getName(), context.faction.getTag());
msg(TL.GENERIC_YOUMAYWANT.toString() + p.cmdBase.cmdKick.getUseageTemplate(false)); context.msg(TL.GENERIC_YOUMAYWANT.toString() + FactionsPlugin.getInstance().cmdBase.cmdKick.getUsageTemplate(context));
return; return;
} }
// if economy is enabled, they're not on the bypass list, and this command has a cost set, make 'em pay // if economy is enabled, they're not on the bypass list, and this command has a cost set, make 'em pay
if (!payForCommand(Conf.econCostInvite, TL.COMMAND_INVITE_TOINVITE.toString(), TL.COMMAND_INVITE_FORINVITE.toString())) { if (!context.payForCommand(Conf.econCostInvite, TL.COMMAND_INVITE_TOINVITE.toString(), TL.COMMAND_INVITE_FORINVITE.toString())) {
return; return;
} }
if (!fme.isAdminBypassing()) { if (context.faction.isInvited(target)) {
Access access = myFaction.getAccess(fme, PermissableAction.INVITE); context.msg(TL.COMMAND_INVITE_ALREADYINVITED, target.getName());
if (access != Access.ALLOW && fme.getRole() != Role.LEADER) {
fme.msg(TL.GENERIC_FPERM_NOPERMISSION, "manage invites");
return;
}
}
if (myFaction.isInvited(target)) {
fme.msg(TL.COMMAND_INVITE_ALREADYINVITED, target.getName());
return; return;
} }
if (myFaction.isBanned(target)) { if (context.faction.isBanned(target)) {
fme.msg(TL.COMMAND_INVITE_BANNED, target.getName()); context.msg(TL.COMMAND_INVITE_BANNED, target.getName());
return; return;
} }
myFaction.invite(target); context.faction.invite(target);
// Send the invitation to the target player when online, otherwise just ignore // Send the invitation to the target player when online, otherwise just ignore
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(fme.describeTo(target, true)) FancyMessage message = new FancyMessage(context.fPlayer.describeTo(target, true))
.tooltip(TL.COMMAND_INVITE_CLICKTOJOIN.toString()) .tooltip(TL.COMMAND_INVITE_CLICKTOJOIN.toString())
.command("/" + Conf.baseCommandAliases.get(0) + " join " + myFaction.getTag()) .command("/" + Conf.baseCommandAliases.get(0) + " join " + context.faction.getTag())
.then(TL.COMMAND_INVITE_INVITEDYOU.toString()) .then(TL.COMMAND_INVITE_INVITEDYOU.toString())
.color(ChatColor.YELLOW) .color(ChatColor.YELLOW)
.tooltip(TL.COMMAND_INVITE_CLICKTOJOIN.toString()) .tooltip(TL.COMMAND_INVITE_CLICKTOJOIN.toString())
.command("/" + Conf.baseCommandAliases.get(0) + " join " + myFaction.getTag()) .command("/" + Conf.baseCommandAliases.get(0) + " join " + context.faction.getTag())
.then(myFaction.describeTo(target)).tooltip(TL.COMMAND_INVITE_CLICKTOJOIN.toString()) .then(context.faction.describeTo(target)).tooltip(TL.COMMAND_INVITE_CLICKTOJOIN.toString())
.command("/" + Conf.baseCommandAliases.get(0) + " join " + myFaction.getTag()); .command("/" + Conf.baseCommandAliases.get(0) + " join " + context.faction.getTag());
message.send(target.getPlayer()); message.send(target.getPlayer());
} }
myFaction.msg(TL.COMMAND_INVITE_INVITED, fme.describeTo(myFaction, true), target.describeTo(myFaction)); context.faction.msg(TL.COMMAND_INVITE_INVITED, context.fPlayer.describeTo(context.faction, true), target.describeTo(context.faction));
} }
@Override @Override

View File

@@ -12,120 +12,96 @@ public class CmdJoin extends FCommand {
public CmdJoin() { public CmdJoin() {
super(); super();
this.aliases.add("join"); this.aliases.add("join");
this.requiredArgs.add("faction name"); this.requiredArgs.add("faction name");
this.optionalArgs.put("player", "you"); this.optionalArgs.put("player", "you");
this.permission = Permission.JOIN.node; this.requirements = new CommandRequirements.Builder(Permission.JOIN)
this.disableOnLock = true; .playerOnly()
.build();
senderMustBePlayer = true;
senderMustBeMember = false;
senderMustBeModerator = false;
senderMustBeColeader = false;
senderMustBeAdmin = false;
} }
@Override @Override
public void perform() { public void perform(CommandContext context) {
Faction faction = this.argAsFaction(0); Faction faction = context.argAsFaction(0);
if (faction == null) { if (faction == null) {
return; return;
} }
FPlayer fplayer = this.argAsBestFPlayerMatch(1, fme, false); FPlayer fplayer = context.argAsBestFPlayerMatch(1, context.fPlayer, false);
boolean samePlayer = fplayer == fme; boolean samePlayer = fplayer == context.fPlayer;
if (!samePlayer && !Permission.JOIN_OTHERS.has(sender, false)) { if (!samePlayer && !Permission.JOIN_OTHERS.has(context.sender, false)) {
msg(TL.COMMAND_JOIN_CANNOTFORCE); context.msg(TL.COMMAND_JOIN_CANNOTFORCE);
return; return;
} }
if (!faction.isNormal()) { if (!faction.isNormal()) {
msg(TL.COMMAND_JOIN_SYSTEMFACTION); context.msg(TL.COMMAND_JOIN_SYSTEMFACTION);
return; return;
} }
if (faction == fplayer.getFaction()) { if (faction == fplayer.getFaction()) {
//TODO:TL context.msg(TL.COMMAND_JOIN_ALREADYMEMBER, fplayer.describeTo(context.fPlayer, true), (samePlayer ? "are" : "is"), faction.getTag(context.fPlayer));
msg(TL.COMMAND_JOIN_ALREADYMEMBER, fplayer.describeTo(fme, true), (samePlayer ? "are" : "is"), faction.getTag(fme));
return; return;
} }
if (Conf.factionMemberLimit > 0 && faction.getFPlayers().size() >= Conf.factionMemberLimit) { if (Conf.factionMemberLimit > 0 && faction.getFPlayers().size() >= getFactionMemberLimit(faction)) {
msg(TL.COMMAND_JOIN_ATLIMIT, faction.getTag(fme), Conf.factionMemberLimit, fplayer.describeTo(fme, false)); context.msg(TL.COMMAND_JOIN_ATLIMIT, faction.getTag(context.fPlayer), getFactionMemberLimit(faction), fplayer.describeTo(context.fPlayer, false));
return; return;
} }
if (fplayer.hasFaction()) { if (fplayer.hasFaction()) {
//TODO:TL context.msg(TL.COMMAND_JOIN_INOTHERFACTION, fplayer.describeTo(context.fPlayer, true), (samePlayer ? "your" : "their"));
msg(TL.COMMAND_JOIN_INOTHERFACTION, fplayer.describeTo(fme, true), (samePlayer ? "your" : "their"));
return; return;
} }
if (!Conf.canLeaveWithNegativePower && fplayer.getPower() < 0) { if (!Conf.canLeaveWithNegativePower && fplayer.getPower() < 0) {
msg(TL.COMMAND_JOIN_NEGATIVEPOWER, fplayer.describeTo(fme, true)); context.msg(TL.COMMAND_JOIN_NEGATIVEPOWER, fplayer.describeTo(context.fPlayer, true));
return; return;
} }
if (!(faction.getOpen() || faction.isInvited(fplayer) || fme.isAdminBypassing() || Permission.JOIN_ANY.has(sender, false))) { if (!(faction.getOpen() || faction.isInvited(fplayer) || context.fPlayer.isAdminBypassing() || Permission.JOIN_ANY.has(context.sender, false))) {
msg(TL.COMMAND_JOIN_REQUIRESINVITATION); context.msg(TL.COMMAND_JOIN_REQUIRESINVITATION);
if (samePlayer) { if (samePlayer) {
faction.msg(TL.COMMAND_JOIN_ATTEMPTEDJOIN, fplayer.describeTo(faction, true)); faction.msg(TL.COMMAND_JOIN_ATTEMPTEDJOIN, fplayer.describeTo(faction, true));
} }
return; return;
} }
int level = faction.getUpgrade(UpgradeType.MEMBERS);
int limit = 0;
if (level == 0) {
limit = Conf.factionMemberLimit;
} else {
limit = P.p.getConfig().getInt("fupgrades.MainMenu.Members.Members-Limit.level-" + level);
}
if (limit > 0 && faction.getFPlayers().size() >= limit && !faction.altInvited(fme)) {
msg(TL.COMMAND_JOIN_ATLIMIT, faction.getTag(fme), limit, fplayer.describeTo(fme, false));
return;
}
int altLimit = Conf.factionAltMemberLimit; int altLimit = Conf.factionAltMemberLimit;
if (altLimit > 0 && faction.getAltPlayers().size() >= altLimit && !faction.altInvited(fme)) { if (altLimit > 0 && faction.getAltPlayers().size() >= altLimit && !faction.altInvited(context.fPlayer)) {
msg(TL.COMMAND_JOIN_ATLIMIT, faction.getTag(fme), altLimit, fplayer.describeTo(fme, false)); context.msg(TL.COMMAND_JOIN_ATLIMIT, faction.getTag(context.fPlayer), altLimit, fplayer.describeTo(context.fPlayer, false));
return; return;
} }
// if economy is enabled, they're not on the bypass list, and this command has a cost set, make sure they can pay // if economy is enabled, they're not on the bypass list, and this command has a cost set, make sure they can pay
if (samePlayer && !canAffordCommand(Conf.econCostJoin, TL.COMMAND_JOIN_TOJOIN.toString())) { if (samePlayer && !context.canAffordCommand(Conf.econCostJoin, TL.COMMAND_JOIN_TOJOIN.toString())) {
return; return;
} }
// Check for ban // Check for ban
if (!fme.isAdminBypassing() && faction.isBanned(fme)) { if (!context.fPlayer.isAdminBypassing() && faction.isBanned(context.fPlayer)) {
fme.msg(TL.COMMAND_JOIN_BANNED, faction.getTag(fme)); context.msg(TL.COMMAND_JOIN_BANNED, faction.getTag(context.fPlayer));
return; return;
} }
// trigger the join event (cancellable) // trigger the join event (cancellable)
FPlayerJoinEvent joinEvent = new FPlayerJoinEvent(FPlayers.getInstance().getByPlayer(me), faction, FPlayerJoinEvent.PlayerJoinReason.COMMAND); FPlayerJoinEvent joinEvent = new FPlayerJoinEvent(FPlayers.getInstance().getByPlayer(context.player), faction, FPlayerJoinEvent.PlayerJoinReason.COMMAND);
Bukkit.getServer().getPluginManager().callEvent(joinEvent); Bukkit.getServer().getPluginManager().callEvent(joinEvent);
if (joinEvent.isCancelled()) { if (joinEvent.isCancelled()) {
return; return;
} }
// then make 'em pay (if applicable) // then make 'em pay (if applicable)
if (samePlayer && !payForCommand(Conf.econCostJoin, TL.COMMAND_JOIN_TOJOIN.toString(), TL.COMMAND_JOIN_FORJOIN.toString())) { if (samePlayer && !context.payForCommand(Conf.econCostJoin, TL.COMMAND_JOIN_TOJOIN.toString(), TL.COMMAND_JOIN_FORJOIN.toString())) {
return; return;
} }
fme.msg(TL.COMMAND_JOIN_SUCCESS, fplayer.describeTo(fme, true), faction.getTag(fme)); context.msg(TL.COMMAND_JOIN_SUCCESS, fplayer.describeTo(context.fPlayer, true), faction.getTag(context.fPlayer));
if (!samePlayer) { if (!samePlayer) {
fplayer.msg(TL.COMMAND_JOIN_MOVED, fme.describeTo(fplayer, true), faction.getTag(fplayer)); fplayer.msg(TL.COMMAND_JOIN_MOVED, context.fPlayer.describeTo(fplayer, true), faction.getTag(fplayer));
} }
faction.msg(TL.COMMAND_JOIN_JOINED, fplayer.describeTo(faction, true)); faction.msg(TL.COMMAND_JOIN_JOINED, fplayer.describeTo(faction, true));
@@ -140,18 +116,25 @@ public class CmdJoin extends FCommand {
} }
faction.deinvite(fplayer); faction.deinvite(fplayer);
fplayer.setRole(faction.getDefaultRole()); context.fPlayer.setRole(faction.getDefaultRole());
if (Conf.logFactionJoin) { if (Conf.logFactionJoin) {
if (samePlayer) { if (samePlayer) {
P.p.log(TL.COMMAND_JOIN_JOINEDLOG.toString(), fplayer.getName(), faction.getTag()); FactionsPlugin.getInstance().log(TL.COMMAND_JOIN_JOINEDLOG.toString(), fplayer.getName(), faction.getTag());
} else { } else {
P.p.log(TL.COMMAND_JOIN_MOVEDLOG.toString(), fme.getName(), fplayer.getName(), faction.getTag()); FactionsPlugin.getInstance().log(TL.COMMAND_JOIN_MOVEDLOG.toString(), context.fPlayer.getName(), fplayer.getName(), faction.getTag());
} }
} }
} }
private int getFactionMemberLimit(Faction f) {
if (f.getUpgrade(UpgradeType.MEMBERS) == 0) return Conf.factionMemberLimit;
return Conf.factionMemberLimit + FactionsPlugin.getInstance().getConfig().getInt("fupgrades.MainMenu.Members.Member-Boost.level-" + f.getUpgrade(UpgradeType.MEMBERS));
}
@Override @Override
public TL getUsageTranslation() { public TL getUsageTranslation() {
return TL.COMMAND_JOIN_DESCRIPTION; return TL.COMMAND_JOIN_DESCRIPTION;
} }
} }

View File

@@ -3,80 +3,69 @@ 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.Faction; import com.massivecraft.factions.Faction;
import com.massivecraft.factions.P; import com.massivecraft.factions.FactionsPlugin;
import com.massivecraft.factions.event.FPlayerLeaveEvent; import com.massivecraft.factions.event.FPlayerLeaveEvent;
import com.massivecraft.factions.struct.Permission; import com.massivecraft.factions.struct.Permission;
import com.massivecraft.factions.struct.Role; 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;
import org.bukkit.Bukkit; import org.bukkit.Bukkit;
import org.bukkit.ChatColor; import org.bukkit.ChatColor;
import org.bukkit.command.ConsoleCommandSender;
public class CmdKick extends FCommand { public class CmdKick extends FCommand {
public CmdKick() { public CmdKick() {
super(); super();
this.aliases.add("kick"); this.aliases.add("kick");
this.optionalArgs.put("player name", "player name"); this.optionalArgs.put("player name", "player name");
//this.optionalArgs.put("", "");
this.permission = Permission.KICK.node; this.requirements = new CommandRequirements.Builder(Permission.KICK)
this.disableOnLock = false; .playerOnly()
.withAction(PermissableAction.KICK)
.memberOnly()
senderMustBePlayer = true; .build();
senderMustBeMember = false;
senderMustBeModerator = false;
senderMustBeAdmin = false;
} }
@Override @Override
public void perform() { public void perform(CommandContext context) {
FPlayer toKick = this.argIsSet(0) ? this.argAsBestFPlayerMatch(0) : null; FPlayer toKick = context.argIsSet(0) ? context.argAsBestFPlayerMatch(0) : null;
if (toKick == null) { if (toKick == null) {
FancyMessage msg = new FancyMessage(TL.COMMAND_KICK_CANDIDATES.toString()).color(ChatColor.GOLD); FancyMessage msg = new FancyMessage(TL.COMMAND_KICK_CANDIDATES.toString()).color(ChatColor.GOLD);
for (FPlayer player : myFaction.getFPlayersWhereRole(Role.NORMAL)) { for (FPlayer player : context.faction.getFPlayersWhereRole(Role.NORMAL)) {
String s = player.getName(); String s = player.getName();
msg.then(s + " ").color(ChatColor.WHITE).tooltip(TL.COMMAND_KICK_CLICKTOKICK.toString() + s).command("/" + Conf.baseCommandAliases.get(0) + " kick " + s); msg.then(s + " ").color(ChatColor.WHITE).tooltip(TL.COMMAND_KICK_CLICKTOKICK.toString() + s).command("/" + Conf.baseCommandAliases.get(0) + " kick " + s);
} }
if (fme.getRole().isAtLeast(Role.COLEADER)) { if (context.fPlayer.getRole().isAtLeast(Role.COLEADER)) {
// For both coleader and admin, add mods. // For both coleader and admin, add mods.
for (FPlayer player : myFaction.getFPlayersWhereRole(Role.MODERATOR)) { for (FPlayer player : context.faction.getFPlayersWhereRole(Role.MODERATOR)) {
String s = player.getName(); String s = player.getName();
msg.then(s + " ").color(ChatColor.GRAY).tooltip(TL.COMMAND_KICK_CLICKTOKICK.toString() + s).command("/" + Conf.baseCommandAliases.get(0) + " kick " + s); msg.then(s + " ").color(ChatColor.GRAY).tooltip(TL.COMMAND_KICK_CLICKTOKICK.toString() + s).command("/" + Conf.baseCommandAliases.get(0) + " kick " + s);
} }
if (fme.getRole() == Role.LEADER) { if (context.fPlayer.getRole() == Role.LEADER) {
// Only add coleader to this for the leader. // Only add coleader to this for the leader.
for (FPlayer player : myFaction.getFPlayersWhereRole(Role.COLEADER)) { for (FPlayer player : context.faction.getFPlayersWhereRole(Role.COLEADER)) {
String s = player.getName(); String s = player.getName();
msg.then(s + " ").color(ChatColor.RED).tooltip(TL.COMMAND_KICK_CLICKTOKICK.toString() + s).command("/" + Conf.baseCommandAliases.get(0) + " kick " + s); msg.then(s + " ").color(ChatColor.RED).tooltip(TL.COMMAND_KICK_CLICKTOKICK.toString() + s).command("/" + Conf.baseCommandAliases.get(0) + " kick " + s);
} }
} }
} }
sendFancyMessage(msg); context.sendFancyMessage(msg);
return; return;
} }
if (fme == toKick) { if (context.fPlayer == toKick) {
msg(TL.COMMAND_KICK_SELF); context.msg(TL.COMMAND_KICK_SELF);
msg(TL.GENERIC_YOUMAYWANT.toString() + p.cmdBase.cmdLeave.getUseageTemplate(false)); context.msg(TL.GENERIC_YOUMAYWANT.toString() + FactionsPlugin.getInstance().cmdBase.cmdLeave.getUsageTemplate(context));
return;
}
if (toKick.isAlt()) {
msg(P.p.color("&cToo few arguments, &eUse like this:"));
msg(P.p.color("&b/f alts,alt kick &3<player name>"));
return; return;
} }
Faction toKickFaction = toKick.getFaction(); Faction toKickFaction = toKick.getFaction();
if (toKickFaction.isWilderness()) { if (toKickFaction.isWilderness()) {
sender.sendMessage(TL.COMMAND_KICK_NONE.toString()); context.sender.sendMessage(TL.COMMAND_KICK_NONE.toString());
return; return;
} }
@@ -85,28 +74,23 @@ public class CmdKick extends FCommand {
// - Check for the kick permission. // - Check for the kick permission.
// - Make sure the player is in the faction. // - Make sure the player is in the faction.
// - Make sure the kicked player has lower rank than the kicker. // - Make sure the kicked player has lower rank than the kicker.
if (!fme.isAdminBypassing()) { if (!context.fPlayer.isAdminBypassing()) {
Access access = myFaction.getAccess(fme, PermissableAction.KICK); if (toKickFaction != context.faction) {
if (access != Access.ALLOW && fme.getRole() != Role.LEADER) { context.msg(TL.COMMAND_KICK_NOTMEMBER, toKick.describeTo(context.fPlayer, true), context.faction.describeTo(context.fPlayer));
fme.msg(TL.GENERIC_NOPERMISSION, "kick");
return; return;
} }
if (toKickFaction != myFaction) { if (toKick.getRole().value >= context.fPlayer.getRole().value) {
msg(TL.COMMAND_KICK_NOTMEMBER, toKick.describeTo(fme, true), myFaction.describeTo(fme)); context.msg(TL.COMMAND_KICK_INSUFFICIENTRANK);
return;
}
if (toKick.getRole().value >= fme.getRole().value) {
msg(TL.COMMAND_KICK_INSUFFICIENTRANK);
return; return;
} }
if (!Conf.canLeaveWithNegativePower && toKick.getPower() < 0) { if (!Conf.canLeaveWithNegativePower && toKick.getPower() < 0) {
msg(TL.COMMAND_KICK_NEGATIVEPOWER); context.msg(TL.COMMAND_KICK_NEGATIVEPOWER);
return; return;
} }
} }
// if economy is enabled, they're not on the bypass list, and this command has a cost set, make sure they can pay // if economy is enabled, they're not on the bypass list, and this command has a cost set, make sure they can pay
if (!canAffordCommand(Conf.econCostKick, TL.COMMAND_KICK_TOKICK.toString())) { if (!context.canAffordCommand(Conf.econCostKick, TL.COMMAND_KICK_TOKICK.toString())) {
return; return;
} }
@@ -118,18 +102,18 @@ public class CmdKick extends FCommand {
} }
// then make 'em pay (if applicable) // then make 'em pay (if applicable)
if (!payForCommand(Conf.econCostKick, TL.COMMAND_KICK_TOKICK.toString(), TL.COMMAND_KICK_FORKICK.toString())) { if (!context.payForCommand(Conf.econCostKick, TL.COMMAND_KICK_TOKICK.toString(), TL.COMMAND_KICK_FORKICK.toString())) {
return; return;
} }
toKickFaction.msg(TL.COMMAND_KICK_FACTION, fme.describeTo(toKickFaction, true), toKick.describeTo(toKickFaction, true)); toKickFaction.msg(TL.COMMAND_KICK_FACTION, context.fPlayer.describeTo(toKickFaction, true), toKick.describeTo(toKickFaction, true));
toKick.msg(TL.COMMAND_KICK_KICKED, fme.describeTo(toKick, true), toKickFaction.describeTo(toKick)); toKick.msg(TL.COMMAND_KICK_KICKED, context.fPlayer.describeTo(toKick, true), toKickFaction.describeTo(toKick));
if (toKickFaction != myFaction) { if (toKickFaction != context.faction) {
fme.msg(TL.COMMAND_KICK_KICKS, toKick.describeTo(fme), toKickFaction.describeTo(fme)); context.fPlayer.msg(TL.COMMAND_KICK_KICKS, toKick.describeTo(context.fPlayer), toKickFaction.describeTo(context.fPlayer));
} }
if (Conf.logFactionKick) { if (Conf.logFactionKick) {
P.p.log((senderIsConsole ? "A console command" : fme.getName()) + " kicked " + toKick.getName() + " from the faction: " + toKickFaction.getTag()); FactionsPlugin.getInstance().log((context.sender instanceof ConsoleCommandSender ? "A console command" : context.fPlayer.getName()) + " kicked " + toKick.getName() + " from the faction: " + toKickFaction.getTag());
} }
if (toKick.getRole() == Role.LEADER) { if (toKick.getRole() == Role.LEADER) {
toKickFaction.promoteNewLeader(); toKickFaction.promoteNewLeader();

View File

@@ -6,25 +6,18 @@ import com.massivecraft.factions.zcore.util.TL;
public class CmdKillHolograms extends FCommand { public class CmdKillHolograms extends FCommand {
public CmdKillHolograms() { public CmdKillHolograms() {
super(); super();
this.aliases.add("killholos"); this.aliases.add("killholos");
this.requiredArgs.add("radius"); this.requiredArgs.add("radius");
this.permission = Permission.KILLHOLOS.node; this.requirements = new CommandRequirements.Builder(Permission.KILLHOLOS)
this.disableOnLock = true; .playerOnly()
.build();
senderMustBePlayer = true;
senderMustBeMember = false;
senderMustBeModerator = false;
senderMustBeColeader = false;
senderMustBeAdmin = false;
} }
@Override @Override
public void perform() { public void perform(CommandContext context) {
me.sendMessage("Killing Invisible Armor Stands.."); context.player.sendMessage("Killing Invisible Armor Stands..");
me.chat("/minecraft:kill @e[type=ArmorStand,r=" + argAsInt(0) + "]"); context.player.chat("/minecraft:kill @e[type=ArmorStand,r=" + context.argAsInt(0) + "]");
} }
@@ -33,3 +26,4 @@ public class CmdKillHolograms extends FCommand {
return TL.COMMAND_KILLHOLOGRAMS_DESCRIPTION; return TL.COMMAND_KILLHOLOGRAMS_DESCRIPTION;
} }
} }

View File

@@ -9,23 +9,15 @@ public class CmdLeave extends FCommand {
super(); super();
this.aliases.add("leave"); this.aliases.add("leave");
//this.requiredArgs.add(""); this.requirements = new CommandRequirements.Builder(Permission.LEAVE)
//this.optionalArgs.put("", ""); .playerOnly()
.memberOnly()
this.permission = Permission.LEAVE.node; .build();
this.disableOnLock = true;
senderMustBePlayer = true;
senderMustBeMember = true;
senderMustBeModerator = false;
senderMustBeColeader = false;
senderMustBeAdmin = false;
} }
@Override @Override
public void perform() { public void perform(CommandContext context) {
fme.leave(true); context.fPlayer.leave(true);
} }
@Override @Override
@@ -33,4 +25,4 @@ public class CmdLeave extends FCommand {
return TL.LEAVE_DESCRIPTION; return TL.LEAVE_DESCRIPTION;
} }
} }

View File

@@ -3,13 +3,12 @@ package com.massivecraft.factions.cmd;
import com.massivecraft.factions.Conf; import com.massivecraft.factions.Conf;
import com.massivecraft.factions.Faction; import com.massivecraft.factions.Faction;
import com.massivecraft.factions.Factions; import com.massivecraft.factions.Factions;
import com.massivecraft.factions.P; import com.massivecraft.factions.FactionsPlugin;
import com.massivecraft.factions.struct.Permission; import com.massivecraft.factions.struct.Permission;
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;
import java.util.ArrayList; import java.util.ArrayList;
import java.util.Collections;
import java.util.List; import java.util.List;
@@ -30,20 +29,15 @@ public class CmdList extends FCommand {
//this.requiredArgs.add(""); //this.requiredArgs.add("");
this.optionalArgs.put("page", "1"); this.optionalArgs.put("page", "1");
this.permission = Permission.LIST.node; this.requirements = new CommandRequirements.Builder(Permission.LIST)
this.disableOnLock = false; .playerOnly()
.build();
senderMustBePlayer = false;
senderMustBeMember = false;
senderMustBeModerator = false;
senderMustBeColeader = false;
senderMustBeAdmin = false;
} }
@Override @Override
public void perform() { public void perform(CommandContext context) {
// if economy is enabled, they're not on the bypass list, and this command has a cost set, make 'em pay // if economy is enabled, they're not on the bypass list, and this command has a cost set, make 'em pay
if (!payForCommand(Conf.econCostList, "to list the factions", "for listing the factions")) if (!context.payForCommand(Conf.econCostList, "to list the factions", "for listing the factions"))
return; return;
ArrayList<Faction> factionList = Factions.getInstance().getAllFactions(); ArrayList<Faction> factionList = Factions.getInstance().getAllFactions();
@@ -52,14 +46,14 @@ public class CmdList extends FCommand {
factionList.remove(Factions.getInstance().getWarZone()); factionList.remove(Factions.getInstance().getWarZone());
// remove exempt factions // remove exempt factions
if (fme != null && fme.getPlayer() != null && !fme.getPlayer().hasPermission("factions.show.bypassexempt")) { if (context.fPlayer != null && context.fPlayer.getPlayer() != null && !context.fPlayer.getPlayer().hasPermission("factions.show.bypassexempt")) {
List<String> exemptFactions = P.p.getConfig().getStringList("show-exempt"); List<String> exemptFactions = FactionsPlugin.getInstance().getConfig().getStringList("show-exempt");
factionList.removeIf(next -> exemptFactions.contains(next.getTag())); factionList.removeIf(next -> exemptFactions.contains(next.getTag()));
} }
// Sort by total followers first // Sort by total followers first
Collections.sort(factionList, (f1, f2) -> { factionList.sort((f1, f2) -> {
int f1Size = f1.getFPlayers().size(); int f1Size = f1.getFPlayers().size();
int f2Size = f2.getFPlayers().size(); int f2Size = f2.getFPlayers().size();
if (f1Size < f2Size) { if (f1Size < f2Size) {
@@ -87,7 +81,7 @@ public class CmdList extends FCommand {
factionList.add(0, Factions.getInstance().getWilderness()); factionList.add(0, Factions.getInstance().getWilderness());
final int pageheight = 9; final int pageheight = 9;
int pagenumber = this.argAsInt(0, 1); int pagenumber = context.argAsInt(0, 1);
int pagecount = (factionList.size() / pageheight) + 1; int pagecount = (factionList.size() / pageheight) + 1;
if (pagenumber > pagecount) { if (pagenumber > pagecount) {
pagenumber = pagecount; pagenumber = pagecount;
@@ -101,18 +95,18 @@ public class CmdList extends FCommand {
} }
String header = p.getConfig().getString("list.header", defaults[0]); String header = FactionsPlugin.getInstance().getConfig().getString("list.header", defaults[0]);
header = header.replace("{pagenumber}", String.valueOf(pagenumber)).replace("{pagecount}", String.valueOf(pagecount)); header = header.replace("{pagenumber}", String.valueOf(pagenumber)).replace("{pagecount}", String.valueOf(pagecount));
lines.add(p.txt.parse(header)); lines.add(FactionsPlugin.getInstance().txt.parse(header));
for (Faction faction : factionList.subList(start, end)) { for (Faction faction : factionList.subList(start, end)) {
if (faction.isWilderness()) { if (faction.isWilderness()) {
lines.add(p.txt.parse(TagUtil.parsePlain(faction, p.getConfig().getString("list.factionless", defaults[1])))); lines.add(FactionsPlugin.getInstance().txt.parse(TagUtil.parsePlain(faction, FactionsPlugin.getInstance().getConfig().getString("list.factionless", defaults[1]))));
continue; continue;
} }
lines.add(p.txt.parse(TagUtil.parsePlain(faction, fme, p.getConfig().getString("list.entry", defaults[2])))); lines.add(FactionsPlugin.getInstance().txt.parse(TagUtil.parsePlain(faction, context.fPlayer, FactionsPlugin.getInstance().getConfig().getString("list.entry", defaults[2]))));
} }
sendMessage(lines); context.sendMessage(lines);
} }
@Override @Override

View File

@@ -1,5 +1,6 @@
package com.massivecraft.factions.cmd; package com.massivecraft.factions.cmd;
import com.massivecraft.factions.FactionsPlugin;
import com.massivecraft.factions.struct.Permission; import com.massivecraft.factions.struct.Permission;
import com.massivecraft.factions.zcore.util.TL; import com.massivecraft.factions.zcore.util.TL;
@@ -15,25 +16,17 @@ public class CmdLock extends FCommand {
public CmdLock() { public CmdLock() {
super(); super();
this.aliases.add("lock"); this.aliases.add("lock");
//this.requiredArgs.add("");
this.optionalArgs.put("on/off", "flip"); this.optionalArgs.put("on/off", "flip");
this.permission = Permission.LOCK.node; this.requirements = new CommandRequirements.Builder(Permission.LOCK)
this.disableOnLock = false; .playerOnly()
.build();
senderMustBePlayer = false;
senderMustBeMember = false;
senderMustBeModerator = false;
senderMustBeColeader = false;
senderMustBeAdmin = false;
} }
@Override @Override
public void perform() { public void perform(CommandContext context) {
p.setLocked(this.argAsBool(0, !p.getLocked())); FactionsPlugin.getInstance().setLocked(context.argAsBool(0, !FactionsPlugin.getInstance().getLocked()));
msg(p.getLocked() ? TL.COMMAND_LOCK_LOCKED : TL.COMMAND_LOCK_UNLOCKED); context.msg(FactionsPlugin.getInstance().getLocked() ? TL.COMMAND_LOCK_LOCKED : TL.COMMAND_LOCK_UNLOCKED);
} }
@Override @Override
@@ -42,3 +35,4 @@ public class CmdLock extends FCommand {
} }
} }

View File

@@ -11,17 +11,18 @@ public class CmdLogins extends FCommand {
this.aliases.add("logins"); this.aliases.add("logins");
this.aliases.add("logout"); this.aliases.add("logout");
this.aliases.add("logouts"); this.aliases.add("logouts");
this.senderMustBePlayer = true;
this.senderMustBeMember = true; this.requirements = new CommandRequirements.Builder(Permission.MONITOR_LOGINS)
this.permission = Permission.MONITOR_LOGINS.node; .playerOnly()
.memberOnly()
.build();
} }
@Override @Override
public void perform() { public void perform(CommandContext context) {
boolean monitor = fme.isMonitoringJoins(); boolean monitor = context.fPlayer.isMonitoringJoins();
fme.msg(TL.COMMAND_LOGINS_TOGGLE, String.valueOf(!monitor)); context.msg(TL.COMMAND_LOGINS_TOGGLE, String.valueOf(!monitor));
fme.setMonitorJoins(!monitor); context.fPlayer.setMonitorJoins(!monitor);
} }
@Override @Override

View File

@@ -2,6 +2,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.struct.Permission;
import com.massivecraft.factions.zcore.util.TL; import com.massivecraft.factions.zcore.util.TL;
public class CmdLowPower extends FCommand { public class CmdLowPower extends FCommand {
@@ -10,26 +11,21 @@ public class CmdLowPower extends FCommand {
super(); super();
this.aliases.add("lowpower"); this.aliases.add("lowpower");
this.requirements = new CommandRequirements.Builder(Permission.POWER_ANY)
this.disableOnLock = false; .playerOnly()
.memberOnly()
senderMustBePlayer = true; .build();
senderMustBeMember = true;
senderMustBeModerator = false;
senderMustBeColeader = true;
senderMustBeAdmin = false;
} }
@Override @Override
public void perform() { public void perform(CommandContext context) {
double maxPower = Conf.powerPlayerMax; double maxPower = Conf.powerPlayerMax;
String format = TL.COMMAND_LOWPOWER_FORMAT.toString(); String format = TL.COMMAND_LOWPOWER_FORMAT.toString();
msg(TL.COMMAND_LOWPOWER_HEADER.toString().replace("{maxpower}", (int) maxPower + "")); context.msg(TL.COMMAND_LOWPOWER_HEADER.toString().replace("{maxpower}", (int) maxPower + ""));
for (FPlayer fPlayer : fme.getFaction().getFPlayers()) { for (FPlayer fPlayer : context.faction.getFPlayers()) {
if (fPlayer.getPower() < maxPower) { if (fPlayer.getPower() < maxPower) {
sendMessage(format.replace("{player}", fPlayer.getName()).replace("{player_power}", (int) fPlayer.getPower() + "").replace("{maxpower}", (int) maxPower + "")); context.sendMessage(format.replace("{player}", fPlayer.getName()).replace("{player_power}", (int) fPlayer.getPower() + "").replace("{maxpower}", (int) maxPower + ""));
} }
} }
} }
@@ -40,4 +36,4 @@ public class CmdLowPower extends FCommand {
} }
} }

View File

@@ -12,54 +12,47 @@ public class CmdMap extends FCommand {
public CmdMap() { public CmdMap() {
super(); super();
this.aliases.add("map"); this.aliases.add("map");
//this.requiredArgs.add("");
this.optionalArgs.put("on/off", "once"); this.optionalArgs.put("on/off", "once");
this.permission = Permission.MAP.node; this.requirements = new CommandRequirements.Builder(Permission.MAP)
this.disableOnLock = false; .playerOnly()
.build();
senderMustBePlayer = true;
senderMustBeMember = false;
senderMustBeModerator = false;
senderMustBeColeader = false;
senderMustBeAdmin = false;
} }
@Override @Override
public void perform() { public void perform(CommandContext context) {
if (this.argIsSet(0)) { if (context.argIsSet(0)) {
if (this.argAsBool(0, !fme.isMapAutoUpdating())) { if (context.argAsBool(0, !context.fPlayer.isMapAutoUpdating())) {
// Turn on // Turn on
// if economy is enabled, they're not on the bypass list, and this command has a cost set, make 'em pay // if economy is enabled, they're not on the bypass list, and this command has a cost set, make 'em pay
if (!payForCommand(Conf.econCostMap, "to show the map", "for showing the map")) { if (!context.payForCommand(Conf.econCostMap, "to show the map", "for showing the map")) {
return; return;
} }
fme.setMapAutoUpdating(true); context.fPlayer.setMapAutoUpdating(true);
msg(TL.COMMAND_MAP_UPDATE_ENABLED); context.msg(TL.COMMAND_MAP_UPDATE_ENABLED);
// And show the map once // And show the map once
showMap(); showMap(context);
} else { } else {
// Turn off // Turn off
fme.setMapAutoUpdating(false); context.fPlayer.setMapAutoUpdating(false);
msg(TL.COMMAND_MAP_UPDATE_DISABLED); context.msg(TL.COMMAND_MAP_UPDATE_DISABLED);
} }
} else { } else {
// if economy is enabled, they're not on the bypass list, and this command has a cost set, make 'em pay // if economy is enabled, they're not on the bypass list, and this command has a cost set, make 'em pay
if (!payForCommand(Conf.econCostMap, TL.COMMAND_MAP_TOSHOW, TL.COMMAND_MAP_FORSHOW)) { if (!context.payForCommand(Conf.econCostMap, TL.COMMAND_MAP_TOSHOW, TL.COMMAND_MAP_FORSHOW)) {
return; return;
} }
showMap(); showMap(context);
} }
} }
public void showMap() { public void showMap(CommandContext context) {
sendFancyMessage(Board.getInstance().getMap(fme, new FLocation(fme), fme.getPlayer().getLocation().getYaw())); context.sendFancyMessage(Board.getInstance().getMap(context.fPlayer, new FLocation(context.fPlayer), context.player.getLocation().getYaw()));
} }
@Override @Override
@@ -67,4 +60,4 @@ public class CmdMap extends FCommand {
return TL.COMMAND_MAP_DESCRIPTION; return TL.COMMAND_MAP_DESCRIPTION;
} }
} }

View File

@@ -10,26 +10,24 @@ public class CmdMapHeight extends FCommand {
this.aliases.add("mapheight"); this.aliases.add("mapheight");
this.aliases.add("mh"); this.aliases.add("mh");
this.optionalArgs.put("height", "height"); this.optionalArgs.put("height", "height");
this.permission = Permission.MAPHEIGHT.node; this.requirements = new CommandRequirements.Builder(Permission.MAPHEIGHT)
.playerOnly()
.build();
this.senderMustBePlayer = true;
} }
@Override @Override
public void perform() { public void perform(CommandContext context) {
if (args.size() == 0) { if (context.args.size() == 0) {
fme.sendMessage(TL.COMMAND_MAPHEIGHT_CURRENT.format(fme.getMapHeight())); context.fPlayer.sendMessage(TL.COMMAND_MAPHEIGHT_CURRENT.format(context.fPlayer.getMapHeight()));
return; return;
} }
int height = argAsInt(0); int height = context.argAsInt(0);
fme.setMapHeight(height); context.fPlayer.setMapHeight(height);
fme.sendMessage(TL.COMMAND_MAPHEIGHT_SET.format(fme.getMapHeight())); context.msg(TL.COMMAND_MAPHEIGHT_SET.format(context.fPlayer.getMapHeight()));
} }
@Override @Override

View File

@@ -19,58 +19,46 @@ public class CmdMod extends FCommand {
this.aliases.add("setofficer"); this.aliases.add("setofficer");
this.optionalArgs.put("player name", "name"); this.optionalArgs.put("player name", "name");
//this.optionalArgs.put("", "");
this.permission = Permission.MOD.node; this.requirements = new CommandRequirements.Builder(Permission.MOD)
this.disableOnLock = true; .playerOnly()
.memberOnly()
.build();
senderMustBePlayer = false;
senderMustBeMember = true;
senderMustBeModerator = false;
senderMustBeColeader = true;
senderMustBeAdmin = false;
} }
@Override @Override
public void perform() { public void perform(CommandContext context) {
FPlayer you = this.argAsBestFPlayerMatch(0); FPlayer you = context.argAsBestFPlayerMatch(0);
if (you == null) { if (you == null) {
FancyMessage msg = new FancyMessage(TL.COMMAND_MOD_CANDIDATES.toString()).color(ChatColor.GOLD); FancyMessage msg = new FancyMessage(TL.COMMAND_MOD_CANDIDATES.toString()).color(ChatColor.GOLD);
for (FPlayer player : myFaction.getFPlayersWhereRole(Role.NORMAL)) { for (FPlayer player : context.faction.getFPlayersWhereRole(Role.NORMAL)) {
String s = player.getName(); String s = player.getName();
msg.then(s + " ").color(ChatColor.WHITE).tooltip(TL.COMMAND_MOD_CLICKTOPROMOTE.toString() + s).command("/" + Conf.baseCommandAliases.get(0) + " mod " + s); msg.then(s + " ").color(ChatColor.WHITE).tooltip(TL.COMMAND_MOD_CLICKTOPROMOTE.toString() + s).command("/" + Conf.baseCommandAliases.get(0) + " mod " + s);
} }
sendFancyMessage(msg); context.sendFancyMessage(msg);
return; return;
} }
boolean permAny = Permission.MOD_ANY.has(sender, false); boolean permAny = Permission.MOD_ANY.has(context.sender, false);
Faction targetFaction = you.getFaction(); Faction targetFaction = you.getFaction();
if (targetFaction != context.faction && !permAny) {
if (you.isAlt()) { context.msg(TL.COMMAND_MOD_NOTMEMBER, you.describeTo(context.fPlayer, true));
msg(ChatColor.RED + "You can not promote alt accounts.");
return; return;
} }
if (targetFaction != myFaction && !permAny) { if (context.fPlayer != null && context.fPlayer.getRole() != Role.LEADER && !permAny) {
msg(TL.COMMAND_MOD_NOTMEMBER, you.describeTo(fme, true)); context.msg(TL.COMMAND_MOD_NOTADMIN);
return; return;
} }
if (fme != null && fme.getRole() != Role.LEADER && !permAny) { if (you == context.fPlayer && !permAny) {
msg(TL.COMMAND_MOD_NOTADMIN); context.msg(TL.COMMAND_MOD_SELF);
return;
}
if (you == fme && !permAny) {
msg(TL.COMMAND_MOD_SELF);
return; return;
} }
if (you.getRole() == Role.LEADER) { if (you.getRole() == Role.LEADER) {
msg(TL.COMMAND_MOD_TARGETISADMIN); context.msg(TL.COMMAND_MOD_TARGETISADMIN);
return; return;
} }
@@ -78,12 +66,12 @@ public class CmdMod extends FCommand {
// Revoke // Revoke
you.setRole(Role.NORMAL); you.setRole(Role.NORMAL);
targetFaction.msg(TL.COMMAND_MOD_REVOKED, you.describeTo(targetFaction, true)); targetFaction.msg(TL.COMMAND_MOD_REVOKED, you.describeTo(targetFaction, true));
msg(TL.COMMAND_MOD_REVOKES, you.describeTo(fme, true)); context.msg(TL.COMMAND_MOD_REVOKES, you.describeTo(context.fPlayer, true));
} else { } else {
// Give // Give
you.setRole(Role.MODERATOR); you.setRole(Role.MODERATOR);
targetFaction.msg(TL.COMMAND_MOD_PROMOTED, you.describeTo(targetFaction, true)); targetFaction.msg(TL.COMMAND_MOD_PROMOTED, you.describeTo(targetFaction, true));
msg(TL.COMMAND_MOD_PROMOTES, you.describeTo(fme, true)); context.msg(TL.COMMAND_MOD_PROMOTES, you.describeTo(context.fPlayer, true));
} }
} }

View File

@@ -17,30 +17,24 @@ public class CmdModifyPower extends FCommand {
this.requiredArgs.add("name"); this.requiredArgs.add("name");
this.requiredArgs.add("power"); this.requiredArgs.add("power");
this.permission = Permission.MODIFY_POWER.node; // admin only perm. this.requirements = new CommandRequirements.Builder(Permission.MODIFY_POWER)
.build();
// Let's not require anything and let console modify this as well.
this.senderMustBeAdmin = false;
this.senderMustBePlayer = false;
this.senderMustBeMember = false;
senderMustBeColeader = false;
this.senderMustBeModerator = false;
} }
@Override @Override
public void perform() { public void perform(CommandContext context) {
// /f modify <name> # // /f modify <name> #
FPlayer player = argAsBestFPlayerMatch(0); FPlayer player = context.argAsBestFPlayerMatch(0);
Double number = argAsDouble(1); // returns null if not a Double. Double number = context.argAsDouble(1); // returns null if not a Double.
if (player == null || number == null) { if (player == null || number == null) {
sender.sendMessage(getHelpShort()); context.sender.sendMessage(getHelpShort());
return; return;
} }
player.alterPower(number); player.alterPower(number);
int newPower = player.getPowerRounded(); // int so we don't have super long doubles. int newPower = player.getPowerRounded(); // int so we don't have super long doubles.
msg(TL.COMMAND_MODIFYPOWER_ADDED, number, player.getName(), newPower); context.msg(TL.COMMAND_MODIFYPOWER_ADDED, number, player.getName(), newPower);
} }
@Override @Override

View File

@@ -2,7 +2,8 @@ package com.massivecraft.factions.cmd;
import com.massivecraft.factions.FPlayer; import com.massivecraft.factions.FPlayer;
import com.massivecraft.factions.FPlayers; import com.massivecraft.factions.FPlayers;
import com.massivecraft.factions.P; import com.massivecraft.factions.FactionsPlugin;
import com.massivecraft.factions.struct.Permission;
import com.massivecraft.factions.zcore.util.TL; import com.massivecraft.factions.zcore.util.TL;
import org.bukkit.entity.Entity; import org.bukkit.entity.Entity;
import org.bukkit.entity.Player; import org.bukkit.entity.Player;
@@ -10,37 +11,32 @@ import org.bukkit.entity.Player;
public class CmdNear extends FCommand { public class CmdNear extends FCommand {
public CmdNear() { public CmdNear() {
super(); super();
this.aliases.add("near"); this.aliases.add("near");
this.aliases.add("nearby"); this.aliases.add("nearby");
this.disableOnLock = true; this.requirements = new CommandRequirements.Builder(Permission.NEAR)
.playerOnly()
.memberOnly()
senderMustBePlayer = true; .build();
senderMustBeMember = true;
senderMustBeModerator = false;
senderMustBeColeader = false;
senderMustBeAdmin = false;
} }
@Override @Override
public void perform() { public void perform(CommandContext context) {
if (!P.p.getConfig().getBoolean("fnear.Enabled")) { if (!FactionsPlugin.getInstance().getConfig().getBoolean("fnear.Enabled")) {
fme.msg(TL.COMMAND_NEAR_DISABLED_MSG); context.msg(TL.COMMAND_NEAR_DISABLED_MSG);
return; return;
} }
double range = P.p.getConfig().getInt("fnear.Radius"); double range = FactionsPlugin.getInstance().getConfig().getInt("fnear.Radius");
String format = TL.COMMAND_NEAR_FORMAT.toString(); String format = TL.COMMAND_NEAR_FORMAT.toString();
fme.msg(TL.COMMAND_NEAR_USE_MSG); context.msg(TL.COMMAND_NEAR_USE_MSG);
for (Entity e : me.getNearbyEntities(range, 255, range)) { for (Entity e : context.player.getNearbyEntities(range, 255, range)) {
if (e instanceof Player) { if (e instanceof Player) {
Player player = (((Player) e).getPlayer()); Player player = (((Player) e).getPlayer());
FPlayer fplayer = FPlayers.getInstance().getByPlayer(player); FPlayer fplayer = FPlayers.getInstance().getByPlayer(player);
if (fme.getFaction() == fplayer.getFaction()) { if (context.faction == fplayer.getFaction()) {
double distance = me.getLocation().distance(player.getLocation()); double distance = context.player.getLocation().distance(player.getLocation());
fme.sendMessage(format.replace("{playername}", player.getDisplayName()).replace("{distance}", (int) distance + "")); context.sendMessage(format.replace("{playername}", player.getDisplayName()).replace("{distance}", (int) distance + ""));
} }
} }

View File

@@ -1,37 +0,0 @@
package com.massivecraft.factions.cmd;
import com.massivecraft.factions.zcore.util.TL;
public class CmdNotifications extends FCommand {
public CmdNotifications() {
this.aliases.add("notifications");
this.aliases.add("messages");
this.optionalArgs.put("on/off", "flip");
this.senderMustBeMember = true;
this.senderMustBeModerator = false;
}
@Override
public void perform() {
if (args.size() == 0) {
toggleNotifications(!fme.hasNotificationsEnabled());
} else if (args.size() == 1) {
toggleNotifications(argAsBool(0));
}
}
private void toggleNotifications(boolean toggle) {
fme.setNotificationsEnabled(toggle);
if (toggle) {
fme.msg(TL.COMMAND_NOTIFICATIONS_TOGGLED_ON);
} else {
fme.msg(TL.COMMAND_NOTIFICATIONS_TOGGLED_OFF);
}
}
@Override
public TL getUsageTranslation() {
return TL.COMMAND_NOTIFICATIONS_DESCRIPTION;
}
}

View File

@@ -3,8 +3,8 @@ 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.P;
import com.massivecraft.factions.struct.Permission; import com.massivecraft.factions.struct.Permission;
import com.massivecraft.factions.struct.Role;
import com.massivecraft.factions.zcore.util.TL; import com.massivecraft.factions.zcore.util.TL;
public class CmdOpen extends FCommand { public class CmdOpen extends FCommand {
@@ -12,47 +12,34 @@ public class CmdOpen extends FCommand {
public CmdOpen() { public CmdOpen() {
super(); super();
this.aliases.add("open"); this.aliases.add("open");
//this.requiredArgs.add("");
this.optionalArgs.put("yes/no", "flip"); this.optionalArgs.put("yes/no", "flip");
this.permission = Permission.OPEN.node; this.requirements = new CommandRequirements.Builder(Permission.OPEN)
this.disableOnLock = false; .withRole(Role.COLEADER)
this.disableOnSpam = true; .playerOnly()
.memberOnly()
.build();
senderMustBePlayer = true;
senderMustBeMember = false;
senderMustBeModerator = false;
senderMustBeColeader = true;
senderMustBeAdmin = false;
} }
@Override @Override
public void perform() { public void perform(CommandContext context) {
// if economy is enabled, they're not on the bypass list, and this command has a cost set, make 'em pay // if economy is enabled, they're not on the bypass list, and this command has a cost set, make 'em pay
if (!payForCommand(Conf.econCostOpen, TL.COMMAND_OPEN_TOOPEN, TL.COMMAND_OPEN_FOROPEN)) { if (!context.payForCommand(Conf.econCostOpen, TL.COMMAND_OPEN_TOOPEN, TL.COMMAND_OPEN_FOROPEN)) {
return; return;
} }
if (!fme.isCooldownEnded("open")) { context.faction.setOpen(context.argAsBool(0, !context.faction.getOpen()));
fme.msg(TL.COMMAND_ONCOOOLDOWN, fme.getCooldown("open"));
return;
}
myFaction.setOpen(this.argAsBool(0, !myFaction.getOpen())); String open = context.faction.getOpen() ? TL.COMMAND_OPEN_OPEN.toString() : TL.COMMAND_OPEN_CLOSED.toString();
String open = myFaction.getOpen() ? TL.COMMAND_OPEN_OPEN.toString() : TL.COMMAND_OPEN_CLOSED.toString();
// Inform // Inform
for (FPlayer fplayer : FPlayers.getInstance().getOnlinePlayers()) { for (FPlayer fplayer : FPlayers.getInstance().getOnlinePlayers()) {
if (fplayer.getFactionId().equals(myFaction.getId())) { if (fplayer.getFactionId().equals(context.faction.getId())) {
fplayer.msg(TL.COMMAND_OPEN_CHANGES, fme.getName(), open); fplayer.msg(TL.COMMAND_OPEN_CHANGES, context.fPlayer.getName(), open);
continue; continue;
} }
fplayer.msg(TL.COMMAND_OPEN_CHANGED, myFaction.getTag(fplayer.getFaction()), open); fplayer.msg(TL.COMMAND_OPEN_CHANGED, context.faction.getTag(fplayer.getFaction()), open);
} }
fme.setCooldown("open", System.currentTimeMillis() + (P.p.getConfig().getInt("fcooldowns.f-open") * 1000));
} }
@Override @Override

View File

@@ -11,93 +11,87 @@ public class CmdOwner extends FCommand {
public CmdOwner() { public CmdOwner() {
super(); super();
this.aliases.add("owner"); this.aliases.add("owner");
//this.requiredArgs.add("");
this.optionalArgs.put("player name", "you"); this.optionalArgs.put("player name", "you");
this.permission = Permission.OWNER.node; this.requirements = new CommandRequirements.Builder(Permission.OWNER)
this.disableOnLock = true; .withRole(Role.LEADER)
.playerOnly()
.memberOnly()
senderMustBePlayer = true; .build();
senderMustBeMember = false;
senderMustBeModerator = false;
senderMustBeColeader = false;
senderMustBeAdmin = false;
} }
// TODO: Fix colors! // TODO: Fix colors!
@Override @Override
public void perform() { public void perform(CommandContext context) {
boolean hasBypass = fme.isAdminBypassing(); boolean hasBypass = context.fPlayer.isAdminBypassing();
if (!hasBypass && !assertHasFaction()) { if (!hasBypass && !context.assertHasFaction()) {
return; return;
} }
if (!Conf.ownedAreasEnabled) { if (!Conf.ownedAreasEnabled) {
fme.msg(TL.COMMAND_OWNER_DISABLED); context.msg(TL.COMMAND_OWNER_DISABLED);
return; return;
} }
if (!hasBypass && Conf.ownedAreasLimitPerFaction > 0 && myFaction.getCountOfClaimsWithOwners() >= Conf.ownedAreasLimitPerFaction) { if (!hasBypass && Conf.ownedAreasLimitPerFaction > 0 && context.faction.getCountOfClaimsWithOwners() >= Conf.ownedAreasLimitPerFaction) {
fme.msg(TL.COMMAND_OWNER_LIMIT, Conf.ownedAreasLimitPerFaction); context.msg(TL.COMMAND_OWNER_LIMIT, Conf.ownedAreasLimitPerFaction);
return; return;
} }
if (!hasBypass && !assertMinRole(Conf.ownedAreasModeratorsCanSet ? Role.MODERATOR : Role.LEADER)) { if (!hasBypass && !context.assertMinRole(Conf.ownedAreasModeratorsCanSet ? Role.MODERATOR : Role.LEADER)) {
return; return;
} }
FLocation flocation = new FLocation(fme); FLocation flocation = new FLocation(context.fPlayer);
Faction factionHere = Board.getInstance().getFactionAt(flocation); Faction factionHere = Board.getInstance().getFactionAt(flocation);
if (factionHere != myFaction) { if (factionHere != context.faction) {
if (!factionHere.isNormal()) { if (!factionHere.isNormal()) {
fme.msg(TL.COMMAND_OWNER_NOTCLAIMED); context.msg(TL.COMMAND_OWNER_NOTCLAIMED);
return; return;
} }
if (!hasBypass) { if (!hasBypass) {
fme.msg(TL.COMMAND_OWNER_WRONGFACTION); context.msg(TL.COMMAND_OWNER_WRONGFACTION);
return; return;
} }
} }
FPlayer target = this.argAsBestFPlayerMatch(0, fme); FPlayer target = context.argAsBestFPlayerMatch(0, context.fPlayer);
if (target == null) { if (target == null) {
return; return;
} }
String playerName = target.getName(); String playerName = target.getName();
if (target.getFaction() != myFaction) { if (target.getFaction() != context.faction) {
fme.msg(TL.COMMAND_OWNER_NOTMEMBER, playerName); context.msg(TL.COMMAND_OWNER_NOTMEMBER, playerName);
return; return;
} }
// if no player name was passed, and this claim does already have owners set, clear them // if no player name was passed, and this claim does already have owners set, clear them
if (args.isEmpty() && myFaction.doesLocationHaveOwnersSet(flocation)) { if (context.args.isEmpty() && context.faction.doesLocationHaveOwnersSet(flocation)) {
myFaction.clearClaimOwnership(flocation); context.faction.clearClaimOwnership(flocation);
fme.msg(TL.COMMAND_OWNER_CLEARED); context.msg(TL.COMMAND_OWNER_CLEARED);
return; return;
} }
if (myFaction.isPlayerInOwnerList(target, flocation)) { if (context.faction.isPlayerInOwnerList(target, flocation)) {
myFaction.removePlayerAsOwner(target, flocation); context.faction.removePlayerAsOwner(target, flocation);
fme.msg(TL.COMMAND_OWNER_REMOVED, playerName); context.msg(TL.COMMAND_OWNER_REMOVED, playerName);
return; return;
} }
// if economy is enabled, they're not on the bypass list, and this command has a cost set, make 'em pay // if economy is enabled, they're not on the bypass list, and this command has a cost set, make 'em pay
if (!payForCommand(Conf.econCostOwner, TL.COMMAND_OWNER_TOSET, TL.COMMAND_OWNER_FORSET)) { if (!context.payForCommand(Conf.econCostOwner, TL.COMMAND_OWNER_TOSET, TL.COMMAND_OWNER_FORSET)) {
return; return;
} }
myFaction.setPlayerAsOwner(target, flocation); context.faction.setPlayerAsOwner(target, flocation);
fme.msg(TL.COMMAND_OWNER_ADDED, playerName); context.msg(TL.COMMAND_OWNER_ADDED, playerName);
} }
@Override @Override

View File

@@ -13,60 +13,52 @@ public class CmdOwnerList extends FCommand {
super(); super();
this.aliases.add("ownerlist"); this.aliases.add("ownerlist");
//this.requiredArgs.add(""); this.requirements = new CommandRequirements.Builder(Permission.OWNERLIST)
//this.optionalArgs.put("", ""); .playerOnly()
.memberOnly()
this.permission = Permission.OWNERLIST.node; .build();
this.disableOnLock = false;
senderMustBePlayer = true;
senderMustBeMember = false;
senderMustBeModerator = false;
senderMustBeColeader = false;
senderMustBeAdmin = false;
} }
@Override @Override
public void perform() { public void perform(CommandContext context) {
boolean hasBypass = fme.isAdminBypassing(); boolean hasBypass = context.fPlayer.isAdminBypassing();
if (!hasBypass && !assertHasFaction()) { if (!hasBypass && !context.assertHasFaction()) {
return; return;
} }
if (!Conf.ownedAreasEnabled) { if (!Conf.ownedAreasEnabled) {
fme.msg(TL.COMMAND_OWNERLIST_DISABLED); context.msg(TL.COMMAND_OWNERLIST_DISABLED);
return; return;
} }
FLocation flocation = new FLocation(fme); FLocation flocation = new FLocation(context.fPlayer);
if (Board.getInstance().getFactionAt(flocation) != myFaction) { if (Board.getInstance().getFactionAt(flocation) != context.faction) {
if (!hasBypass) { if (!hasBypass) {
fme.msg(TL.COMMAND_OWNERLIST_WRONGFACTION); context.msg(TL.COMMAND_OWNERLIST_WRONGFACTION);
return; return;
} }
//TODO: This code won't ever be called. //TODO: This code won't ever be called.
myFaction = Board.getInstance().getFactionAt(flocation); context.faction = Board.getInstance().getFactionAt(flocation);
if (!myFaction.isNormal()) { if (!context.faction.isNormal()) {
fme.msg(TL.COMMAND_OWNERLIST_NOTCLAIMED); context.msg(TL.COMMAND_OWNERLIST_NOTCLAIMED);
return; return;
} }
} }
String owners = myFaction.getOwnerListString(flocation); String owners = context.faction.getOwnerListString(flocation);
if (owners == null || owners.isEmpty()) { if (owners == null || owners.isEmpty()) {
fme.msg(TL.COMMAND_OWNERLIST_NONE); context.msg(TL.COMMAND_OWNERLIST_NONE);
return; return;
} }
fme.msg(TL.COMMAND_OWNERLIST_OWNERS, owners); context.msg(TL.COMMAND_OWNERLIST_OWNERS, owners);
} }
@Override @Override
public TL getUsageTranslation() { public TL getUsageTranslation() {
return TL.COMMAND_OWNERLIST_DESCRIPTION; return TL.COMMAND_OWNERLIST_DESCRIPTION;
} }
} }

View File

@@ -1,57 +1,52 @@
package com.massivecraft.factions.cmd; package com.massivecraft.factions.cmd;
import com.massivecraft.factions.Faction; import com.massivecraft.factions.Faction;
import com.massivecraft.factions.P; import com.massivecraft.factions.FactionsPlugin;
import com.massivecraft.factions.struct.Permission; import com.massivecraft.factions.struct.Permission;
import com.massivecraft.factions.zcore.util.TL; import com.massivecraft.factions.zcore.util.TL;
public class CmdPaypalSee extends FCommand { public class CmdPaypalSee extends FCommand {
public CmdPaypalSee() { public CmdPaypalSee() {
aliases.add("seepaypal"); this.aliases.add("seepaypal");
aliases.add("paypal"); this.aliases.add("paypal");
optionalArgs.put("faction", "yours"); this.optionalArgs.put("faction", "yours");
permission = Permission.PAYPAL.node;
disableOnLock = false;
senderMustBePlayer = true;
senderMustBeMember = true;
senderMustBeModerator = false;
senderMustBeColeader = false;
senderMustBeAdmin = true;
this.requirements = new CommandRequirements.Builder(Permission.PAYPAL)
.memberOnly()
.build();
} }
@Override @Override
public void perform() { public void perform(CommandContext context) {
if (!P.p.getConfig().getBoolean("fpaypal.Enabled")) { if (!FactionsPlugin.getInstance().getConfig().getBoolean("fpaypal.Enabled")) {
fme.msg(TL.GENERIC_DISABLED); context.msg(TL.GENERIC_DISABLED);
return; return;
} }
if (args.size() == 0) {
if (myFaction.getPaypal().isEmpty()) {
msg(TL.COMMAND_PAYPAL_NOTSET); if (context.args.size() == 0) {
if (context.fPlayer.getFaction().getPaypal() == null) {
context.msg(TL.COMMAND_PAYPAL_NOTSET);
} else { } else {
msg(TL.PAYPALSEE_PLAYER_PAYPAL, myFaction.getPaypal()); context.msg(TL.PAYPALSEE_PLAYER_PAYPAL, context.fPlayer.getFaction().getPaypal());
} }
} else if (args.size() == 1) { } else if (context.args.size() == 1) {
if (fme.isAdminBypassing()) { if (context.fPlayer.isAdminBypassing()) {
Faction faction = argAsFaction(0); Faction faction = context.argAsFaction(0);
if (faction != null) { if (faction != null) {
if (faction.getPaypal().isEmpty()) { if (faction.getPaypal() == null) {
msg(TL.COMMAND_PAYPALSEE_FACTION_NOTSET, faction.getTag()); context.msg(TL.COMMAND_PAYPALSEE_FACTION_NOTSET, faction.getTag());
} else { } else {
msg(TL.COMMAND_PAYPALSEE_FACTION_PAYPAL.toString(), faction.getTag(), faction.getPaypal()); context.msg(TL.COMMAND_PAYPALSEE_FACTION_PAYPAL.toString(), faction.getTag(), faction.getPaypal());
} }
} }
} else { } else {
msg(TL.GENERIC_NOPERMISSION, "see another factions paypal."); context.msg(TL.GENERIC_NOPERMISSION, "see another factions paypal.");
} }
} else { } else {
msg(P.p.cmdBase.cmdPaypalSee.getUseageTemplate()); context.msg(FactionsPlugin.getInstance().cmdBase.cmdPaypalSee.getUsageTemplate(context));
} }
} }

View File

@@ -1,7 +1,7 @@
package com.massivecraft.factions.cmd; package com.massivecraft.factions.cmd;
import com.massivecraft.factions.Faction; import com.massivecraft.factions.Faction;
import com.massivecraft.factions.P; import com.massivecraft.factions.FactionsPlugin;
import com.massivecraft.factions.struct.Permission; import com.massivecraft.factions.struct.Permission;
import com.massivecraft.factions.zcore.util.TL; import com.massivecraft.factions.zcore.util.TL;
@@ -14,47 +14,43 @@ public class CmdPaypalSet extends FCommand {
this.requiredArgs.add("email"); this.requiredArgs.add("email");
this.permission = Permission.PAYPALSET.node; this.requirements = new CommandRequirements.Builder(Permission.PAYPALSET)
.playerOnly()
this.disableOnLock = false; .memberOnly()
this.senderMustBePlayer = true; .build();
this.senderMustBeMember = true;
this.senderMustBeModerator = false;
this.senderMustBeColeader = false;
this.senderMustBeAdmin = true;
} }
@Override @Override
public void perform() { public void perform(CommandContext context) {
if (!P.p.getConfig().getBoolean("fpaypal.Enabled")) { if (!FactionsPlugin.getInstance().getConfig().getBoolean("fpaypal.Enabled")) {
fme.msg(TL.GENERIC_DISABLED); context.fPlayer.msg(TL.GENERIC_DISABLED);
return; return;
} }
if (args.size() == 1) { if (context.args.size() == 1) {
if (isEmail(argAsString(0))) { if (isEmail(context.argAsString(0))) {
myFaction.paypalSet(argAsString(0)); context.fPlayer.getFaction().paypalSet(context.argAsString(0));
msg(TL.COMMAND_PAYPALSET_SUCCESSFUL, argAsString(0)); context.msg(TL.COMMAND_PAYPALSET_SUCCESSFUL, context.argAsString(0));
} else { } else {
msg(TL.COMMAND_PAYPALSET_NOTEMAIL, argAsString(0)); context.msg(TL.COMMAND_PAYPALSET_NOTEMAIL, context.argAsString(0));
} }
} else if (args.size() == 2) { } else if (context.args.size() == 2) {
if (fme.isAdminBypassing()) { if (context.fPlayer.isAdminBypassing()) {
Faction faction = argAsFaction(1); Faction faction = context.argAsFaction(1);
if (faction != null) { if (faction != null) {
if (isEmail(argAsString(0))) { if (isEmail(context.argAsString(0))) {
myFaction.paypalSet(argAsString(0)); context.fPlayer.getFaction().paypalSet(context.argAsString(0));
msg(TL.COMMAND_PAYPALSET_ADMIN_SUCCESSFUL, faction.getTag(), argAsString(0)); context.msg(TL.COMMAND_PAYPALSET_ADMIN_SUCCESSFUL, faction.getTag(), context.argAsString(0));
} else { } else {
msg(TL.COMMAND_PAYPALSET_ADMIN_FAILED, argAsString(0)); context.msg(TL.COMMAND_PAYPALSET_ADMIN_FAILED, context.argAsString(0));
} }
} }
} else { } else {
msg(TL.GENERIC_NOPERMISSION, "set another factions paypal!"); context.msg(TL.GENERIC_NOPERMISSION, "set another factions paypal!");
} }
} else { } else {
msg(P.p.cmdBase.cmdPaypalSet.getUseageTemplate()); context.msg(FactionsPlugin.getInstance().cmdBase.cmdPaypalSet.getUsageTemplate(context));
} }
} }

View File

@@ -11,24 +11,16 @@ public class CmdPeaceful extends FCommand {
public CmdPeaceful() { public CmdPeaceful() {
super(); super();
this.aliases.add("peaceful"); this.aliases.add("peaceful");
this.requiredArgs.add("faction tag"); this.requiredArgs.add("faction tag");
//this.optionalArgs.put("", "");
this.permission = Permission.SET_PEACEFUL.node; this.requirements = new CommandRequirements.Builder(Permission.SET_PEACEFUL)
this.disableOnLock = true; .build();
senderMustBePlayer = false;
senderMustBeMember = false;
senderMustBeModerator = false;
senderMustBeColeader = false;
senderMustBeAdmin = false;
} }
@Override @Override
public void perform() { public void perform(CommandContext context) {
Faction faction = this.argAsFaction(0); Faction faction = context.argAsFaction(0);
if (faction == null) { if (faction == null) {
return; return;
} }
@@ -44,7 +36,7 @@ public class CmdPeaceful extends FCommand {
// Inform all players // Inform all players
for (FPlayer fplayer : FPlayers.getInstance().getOnlinePlayers()) { for (FPlayer fplayer : FPlayers.getInstance().getOnlinePlayers()) {
String blame = (fme == null ? TL.GENERIC_SERVERADMIN.toString() : fme.describeTo(fplayer, true)); String blame = (context.fPlayer == null ? TL.GENERIC_SERVERADMIN.toString() : context.fPlayer.describeTo(fplayer, true));
if (fplayer.getFaction() == faction) { if (fplayer.getFaction() == faction) {
fplayer.msg(TL.COMMAND_PEACEFUL_YOURS, blame, change); fplayer.msg(TL.COMMAND_PEACEFUL_YOURS, blame, change);
} else { } else {

View File

@@ -1,6 +1,7 @@
package com.massivecraft.factions.cmd; package com.massivecraft.factions.cmd;
import com.massivecraft.factions.P; import com.massivecraft.factions.FactionsPlugin;
import com.massivecraft.factions.struct.Permission;
import com.massivecraft.factions.struct.Relation; import com.massivecraft.factions.struct.Relation;
import com.massivecraft.factions.struct.Role; import com.massivecraft.factions.struct.Role;
import com.massivecraft.factions.zcore.fperms.Access; import com.massivecraft.factions.zcore.fperms.Access;
@@ -27,46 +28,43 @@ public class CmdPerm extends FCommand {
this.optionalArgs.put("action", "action"); this.optionalArgs.put("action", "action");
this.optionalArgs.put("access", "access"); this.optionalArgs.put("access", "access");
this.requirements = new CommandRequirements.Builder(Permission.PERMISSIONS)
this.disableOnLock = true; .playerOnly()
.memberOnly()
senderMustBePlayer = true; .withRole(Role.LEADER)
senderMustBeMember = true; .build();
senderMustBeModerator = false;
senderMustBeColeader = false;
senderMustBeAdmin = true;
} }
@Override @Override
public void perform() { public void perform(CommandContext context) {
if (args.size() == 0) {
new PermissableRelationFrame(fme.getFaction()).buildGUI(fme); if (context.args.size() == 0) {
new PermissableRelationFrame(context.faction).buildGUI(context.fPlayer);
return; return;
} else if (args.size() == 1 && getPermissable(argAsString(0)) != null) { } else if (context.args.size() == 1 && getPermissable(context.argAsString(0)) != null) {
new PermissableActionFrame(fme.getFaction()).buildGUI(fme, getPermissable(argAsString(0))); new PermissableActionFrame(context.faction).buildGUI(context.fPlayer, getPermissable(context.argAsString(0)));
return; return;
} }
// If not opening GUI, then setting the permission manually. // If not opening GUI, then setting the permission manually.
if (args.size() != 3) { if (context.args.size() != 3) {
fme.msg(TL.COMMAND_PERM_DESCRIPTION); context.msg(TL.COMMAND_PERM_DESCRIPTION);
return; return;
} }
Set<Permissable> permissables = new HashSet<>(); Set<Permissable> permissables = new HashSet<>();
Set<PermissableAction> permissableActions = new HashSet<>(); Set<PermissableAction> permissableActions = new HashSet<>();
boolean allRelations = argAsString(0).equalsIgnoreCase("all"); boolean allRelations = context.argAsString(0).equalsIgnoreCase("all");
boolean allActions = argAsString(1).equalsIgnoreCase("all"); boolean allActions = context.argAsString(1).equalsIgnoreCase("all");
if (allRelations) { if (allRelations) {
permissables.addAll(myFaction.getPermissions().keySet()); permissables.addAll(context.faction.getPermissions().keySet());
} else { } else {
Permissable permissable = getPermissable(argAsString(0)); Permissable permissable = getPermissable(context.argAsString(0));
if (permissable == null) { if (permissable == null) {
fme.msg(TL.COMMAND_PERM_INVALID_RELATION); context.msg(TL.COMMAND_PERM_INVALID_RELATION);
return; return;
} }
@@ -76,29 +74,30 @@ public class CmdPerm extends FCommand {
if (allActions) { if (allActions) {
permissableActions.addAll(Arrays.asList(PermissableAction.values())); permissableActions.addAll(Arrays.asList(PermissableAction.values()));
} else { } else {
PermissableAction permissableAction = PermissableAction.fromString(argAsString(1)); PermissableAction permissableAction = PermissableAction.fromString(context.argAsString(1));
if (permissableAction == null) { if (permissableAction == null) {
fme.msg(TL.COMMAND_PERM_INVALID_ACTION); context.msg(TL.COMMAND_PERM_INVALID_ACTION);
return; return;
} }
permissableActions.add(permissableAction); permissableActions.add(permissableAction);
} }
Access access = Access.fromString(argAsString(2)); Access access = Access.fromString(context.argAsString(2));
if (access == null) { if (access == null) {
fme.msg(TL.COMMAND_PERM_INVALID_ACCESS); context.msg(TL.COMMAND_PERM_INVALID_ACCESS);
return; return;
} }
for (Permissable permissable : permissables) { for (Permissable permissable : permissables) {
for (PermissableAction permissableAction : permissableActions) { for (PermissableAction permissableAction : permissableActions) {
fme.getFaction().setPermission(permissable, permissableAction, access); context.faction.setPermission(permissable, permissableAction, access);
} }
} }
fme.msg(TL.COMMAND_PERM_SET, argAsString(1), access.name(), argAsString(0));
P.p.log(String.format(TL.COMMAND_PERM_SET.toString(), argAsString(1), access.name(), argAsString(0)) + " for faction " + fme.getTag()); context.msg(TL.COMMAND_PERM_SET, context.argAsString(1), access.name(), context.argAsString(0));
FactionsPlugin.getInstance().log(String.format(TL.COMMAND_PERM_SET.toString(), context.argAsString(1), access.name(), context.argAsString(0)) + " for faction " + context.fPlayer.getTag());
} }
private Permissable getPermissable(String name) { private Permissable getPermissable(String name) {

View File

@@ -3,7 +3,7 @@ package com.massivecraft.factions.cmd;
import com.massivecraft.factions.FPlayer; import com.massivecraft.factions.FPlayer;
import com.massivecraft.factions.FPlayers; import com.massivecraft.factions.FPlayers;
import com.massivecraft.factions.Faction; import com.massivecraft.factions.Faction;
import com.massivecraft.factions.P; import com.massivecraft.factions.FactionsPlugin;
import com.massivecraft.factions.struct.Permission; import com.massivecraft.factions.struct.Permission;
import com.massivecraft.factions.zcore.util.TL; import com.massivecraft.factions.zcore.util.TL;
@@ -13,23 +13,15 @@ public class CmdPermanent extends FCommand {
public CmdPermanent() { public CmdPermanent() {
super(); super();
this.aliases.add("permanent"); this.aliases.add("permanent");
this.requiredArgs.add("faction tag"); this.requiredArgs.add("faction tag");
//this.optionalArgs.put("", "");
this.permission = Permission.SET_PERMANENT.node; this.requirements = new CommandRequirements.Builder(Permission.SET_PERMANENT)
this.disableOnLock = true; .build();
senderMustBePlayer = false;
senderMustBeMember = false;
senderMustBeModerator = false;
senderMustBeColeader = false;
senderMustBeAdmin = false;
} }
@Override @Override
public void perform() { public void perform(CommandContext context) {
Faction faction = this.argAsFaction(0); Faction faction = context.argAsFaction(0);
if (faction == null) { if (faction == null) {
return; return;
} }
@@ -43,11 +35,11 @@ public class CmdPermanent extends FCommand {
faction.setPermanent(true); faction.setPermanent(true);
} }
P.p.log((fme == null ? "A server admin" : fme.getName()) + " " + change + " the faction \"" + faction.getTag() + "\"."); FactionsPlugin.getInstance().log((context.fPlayer == null ? "A server admin" : context.fPlayer.getName()) + " " + change + " the faction \"" + faction.getTag() + "\".");
// Inform all players // Inform all players
for (FPlayer fplayer : FPlayers.getInstance().getOnlinePlayers()) { for (FPlayer fplayer : FPlayers.getInstance().getOnlinePlayers()) {
String blame = (fme == null ? TL.GENERIC_SERVERADMIN.toString() : fme.describeTo(fplayer, true)); String blame = (context.fPlayer == null ? TL.GENERIC_SERVERADMIN.toString() : context.fPlayer.describeTo(fplayer, true));
if (fplayer.getFaction() == faction) { if (fplayer.getFaction() == faction) {
fplayer.msg(TL.COMMAND_PERMANENT_YOURS, blame, change); fplayer.msg(TL.COMMAND_PERMANENT_YOURS, blame, change);
} else { } else {
@@ -61,3 +53,4 @@ public class CmdPermanent extends FCommand {
return TL.COMMAND_PERMANENT_DESCRIPTION; return TL.COMMAND_PERMANENT_DESCRIPTION;
} }
} }

View File

@@ -9,28 +9,21 @@ public class CmdPermanentPower extends FCommand {
public CmdPermanentPower() { public CmdPermanentPower() {
super(); super();
this.aliases.add("permanentpower"); this.aliases.add("permanentpower");
this.requiredArgs.add("faction"); this.requiredArgs.add("faction");
this.requiredArgs.add("power"); this.requiredArgs.add("power");
this.permission = Permission.SET_PERMANENTPOWER.node; this.requirements = new CommandRequirements.Builder(Permission.SET_PERMANENTPOWER)
this.disableOnLock = true; .build();
senderMustBePlayer = false;
senderMustBeMember = false;
senderMustBeModerator = false;
senderMustBeColeader = false;
senderMustBeAdmin = false;
} }
@Override @Override
public void perform() { public void perform(CommandContext context) {
Faction targetFaction = this.argAsFaction(0); Faction targetFaction = context.argAsFaction(0);
if (targetFaction == null) { if (targetFaction == null) {
return; return;
} }
Integer targetPower = this.argAsInt(1); Integer targetPower = context.argAsInt(1);
targetFaction.setPermanentPower(targetPower); targetFaction.setPermanentPower(targetPower);
@@ -40,14 +33,14 @@ public class CmdPermanentPower extends FCommand {
} }
// Inform sender // Inform sender
msg(TL.COMMAND_PERMANENTPOWER_SUCCESS, change, targetFaction.describeTo(fme)); context.msg(TL.COMMAND_PERMANENTPOWER_SUCCESS, change, targetFaction.describeTo(context.fPlayer));
// Inform all other players // Inform all other players
for (FPlayer fplayer : targetFaction.getFPlayersWhereOnline(true)) { for (FPlayer fplayer : targetFaction.getFPlayersWhereOnline(true)) {
if (fplayer == fme) { if (fplayer == context.fPlayer) {
continue; continue;
} }
String blame = (fme == null ? TL.GENERIC_SERVERADMIN.toString() : fme.describeTo(fplayer, true)); String blame = (context.fPlayer == null ? TL.GENERIC_SERVERADMIN.toString() : context.fPlayer.describeTo(fplayer, true));
fplayer.msg(TL.COMMAND_PERMANENTPOWER_FACTION, blame, change); fplayer.msg(TL.COMMAND_PERMANENTPOWER_FACTION, blame, change);
} }
} }

View File

@@ -11,41 +11,33 @@ public class CmdPower extends FCommand {
super(); super();
this.aliases.add("power"); this.aliases.add("power");
this.aliases.add("pow"); this.aliases.add("pow");
//this.requiredArgs.add("faction tag");
this.optionalArgs.put("player name", "you"); this.optionalArgs.put("player name", "you");
this.permission = Permission.POWER.node; this.requirements = new CommandRequirements.Builder(Permission.POWER)
this.disableOnLock = false; .build();
senderMustBePlayer = false;
senderMustBeMember = false;
senderMustBeModerator = false;
senderMustBeColeader = false;
senderMustBeAdmin = false;
} }
@Override @Override
public void perform() { public void perform(CommandContext context) {
FPlayer target = this.argAsBestFPlayerMatch(0, fme); FPlayer target = context.argAsBestFPlayerMatch(0, context.fPlayer);
if (target == null) { if (target == null) {
return; return;
} }
if (target != fme && !Permission.POWER_ANY.has(sender, true)) { if (target != context.fPlayer && !Permission.POWER_ANY.has(context.sender, true)) {
return; return;
} }
// if economy is enabled, they're not on the bypass list, and this command has a cost set, make 'em pay // if economy is enabled, they're not on the bypass list, and this command has a cost set, make 'em pay
if (!payForCommand(Conf.econCostPower, TL.COMMAND_POWER_TOSHOW, TL.COMMAND_POWER_FORSHOW)) { if (!context.payForCommand(Conf.econCostPower, TL.COMMAND_POWER_TOSHOW, TL.COMMAND_POWER_FORSHOW)) {
return; return;
} }
double powerBoost = target.getPowerBoost(); double powerBoost = target.getPowerBoost();
String boost = (powerBoost == 0.0) ? "" : (powerBoost > 0.0 ? TL.COMMAND_POWER_BONUS.toString() : TL.COMMAND_POWER_PENALTY.toString()) + powerBoost + ")"; String boost = (powerBoost == 0.0) ? "" : (powerBoost > 0.0 ? TL.COMMAND_POWER_BONUS.toString() : TL.COMMAND_POWER_PENALTY.toString()) + powerBoost + ")";
msg(TL.COMMAND_POWER_POWER, target.describeTo(fme, true), target.getPowerRounded(), target.getPowerMaxRounded(), boost); context.msg(TL.COMMAND_POWER_POWER, target.describeTo(context.fPlayer, true), target.getPowerRounded(), target.getPowerMaxRounded(), boost);
} }
@Override @Override

View File

@@ -2,48 +2,42 @@ package com.massivecraft.factions.cmd;
import com.massivecraft.factions.FPlayer; import com.massivecraft.factions.FPlayer;
import com.massivecraft.factions.Faction; import com.massivecraft.factions.Faction;
import com.massivecraft.factions.P; import com.massivecraft.factions.FactionsPlugin;
import com.massivecraft.factions.struct.Permission; import com.massivecraft.factions.struct.Permission;
import com.massivecraft.factions.zcore.util.TL; import com.massivecraft.factions.zcore.util.TL;
import org.bukkit.command.ConsoleCommandSender;
public class CmdPowerBoost extends FCommand { public class CmdPowerBoost extends FCommand {
public CmdPowerBoost() { public CmdPowerBoost() {
super(); super();
this.aliases.add("powerboost"); this.aliases.add("powerboost");
this.requiredArgs.add("plugin|f|player|faction"); this.requiredArgs.add("plugin|f|player|faction");
this.requiredArgs.add("name"); this.requiredArgs.add("name");
this.requiredArgs.add("# or reset"); this.requiredArgs.add("# or reset");
this.permission = Permission.POWERBOOST.node; this.requirements = new CommandRequirements.Builder(Permission.POWERBOOST)
this.disableOnLock = true; .build();
senderMustBePlayer = false;
senderMustBeMember = false;
senderMustBeModerator = false;
senderMustBeColeader = false;
senderMustBeAdmin = false;
} }
@Override @Override
public void perform() { public void perform(CommandContext context) {
String type = this.argAsString(0).toLowerCase(); String type = context.argAsString(0).toLowerCase();
boolean doPlayer = true; boolean doPlayer = true;
if (type.equals("f") || type.equals("faction")) { if (type.equals("f") || type.equals("faction")) {
doPlayer = false; doPlayer = false;
} else if (!type.equals("plugin") && !type.equals("player")) { } else if (!type.equals("plugin") && !type.equals("player")) {
msg(TL.COMMAND_POWERBOOST_HELP_1); context.msg(TL.COMMAND_POWERBOOST_HELP_1);
msg(TL.COMMAND_POWERBOOST_HELP_2); context.msg(TL.COMMAND_POWERBOOST_HELP_2);
return; return;
} }
Double targetPower = this.argAsDouble(2); Double targetPower = context.argAsDouble(2);
if (targetPower == null) { if (targetPower == null) {
if (this.argAsString(2).equalsIgnoreCase("reset")) { if (context.argAsString(2).equalsIgnoreCase("reset")) {
targetPower = 0D; targetPower = 0D;
} else { } else {
msg(TL.COMMAND_POWERBOOST_INVALIDNUM); context.msg(TL.COMMAND_POWERBOOST_INVALIDNUM);
return; return;
} }
} }
@@ -51,7 +45,7 @@ public class CmdPowerBoost extends FCommand {
String target; String target;
if (doPlayer) { if (doPlayer) {
FPlayer targetPlayer = this.argAsBestFPlayerMatch(1); FPlayer targetPlayer = context.argAsBestFPlayerMatch(1);
if (targetPlayer == null) { if (targetPlayer == null) {
return; return;
} }
@@ -62,7 +56,7 @@ public class CmdPowerBoost extends FCommand {
targetPlayer.setPowerBoost(targetPower); targetPlayer.setPowerBoost(targetPower);
target = TL.COMMAND_POWERBOOST_PLAYER.format(targetPlayer.getName()); target = TL.COMMAND_POWERBOOST_PLAYER.format(targetPlayer.getName());
} else { } else {
Faction targetFaction = this.argAsFaction(1); Faction targetFaction = context.argAsFaction(1);
if (targetFaction == null) { if (targetFaction == null) {
return; return;
} }
@@ -75,9 +69,9 @@ public class CmdPowerBoost extends FCommand {
} }
int roundedPower = (int) Math.round(targetPower); int roundedPower = (int) Math.round(targetPower);
msg(TL.COMMAND_POWERBOOST_BOOST, target, roundedPower); context.msg(TL.COMMAND_POWERBOOST_BOOST, target, roundedPower);
if (!senderIsConsole) { if (!(context.sender instanceof ConsoleCommandSender)) {
P.p.log(TL.COMMAND_POWERBOOST_BOOSTLOG.toString(), fme.getName(), target, roundedPower); FactionsPlugin.getInstance().log(TL.COMMAND_POWERBOOST_BOOSTLOG.toString(), context.fPlayer.getName(), target, roundedPower);
} }
} }

View File

@@ -1,7 +1,7 @@
package com.massivecraft.factions.cmd; package com.massivecraft.factions.cmd;
import com.massivecraft.factions.Conf; import com.massivecraft.factions.Conf;
import com.massivecraft.factions.P; import com.massivecraft.factions.FactionsPlugin;
import com.massivecraft.factions.shop.ShopConfig; import com.massivecraft.factions.shop.ShopConfig;
import com.massivecraft.factions.struct.Permission; import com.massivecraft.factions.struct.Permission;
import com.massivecraft.factions.zcore.util.TL; import com.massivecraft.factions.zcore.util.TL;
@@ -12,36 +12,29 @@ public class CmdReload extends FCommand {
super(); super();
this.aliases.add("reload"); this.aliases.add("reload");
this.permission = Permission.RELOAD.node; this.requirements = new CommandRequirements.Builder(Permission.RELOAD).build();
this.disableOnLock = false;
senderMustBePlayer = false;
senderMustBeMember = false;
senderMustBeModerator = false;
senderMustBeColeader = false;
senderMustBeAdmin = false;
} }
@Override @Override
public void perform() { public void perform(CommandContext context) {
long timeInitStart = System.currentTimeMillis(); long timeInitStart = System.currentTimeMillis();
Conf.load(); Conf.load();
Conf.save(); Conf.save();
P.p.reloadConfig();
P.p.loadLang();
ShopConfig.loadShop(); ShopConfig.loadShop();
FactionsPlugin.getInstance().reloadConfig();
FactionsPlugin.getInstance().loadLang();
if (P.p.getConfig().getBoolean("enable-faction-flight")) { if (FactionsPlugin.getInstance().getConfig().getBoolean("enable-faction-flight")) {
P.p.factionsFlight = true; FactionsPlugin.getInstance().factionsFlight = true;
} }
long timeReload = (System.currentTimeMillis() - timeInitStart); long timeReload = (System.currentTimeMillis() - timeInitStart);
msg(TL.COMMAND_RELOAD_TIME, timeReload); context.msg(TL.COMMAND_RELOAD_TIME, timeReload);
} }
@Override @Override
public TL getUsageTranslation() { public TL getUsageTranslation() {
return TL.COMMAND_RELOAD_DESCRIPTION; return TL.COMMAND_RELOAD_DESCRIPTION;
} }
} }

View File

@@ -1,6 +1,6 @@
package com.massivecraft.factions.cmd; package com.massivecraft.factions.cmd;
import com.massivecraft.factions.P; import com.massivecraft.factions.FactionsPlugin;
import com.massivecraft.factions.struct.Permission; import com.massivecraft.factions.struct.Permission;
import com.massivecraft.factions.zcore.util.TL; import com.massivecraft.factions.zcore.util.TL;
@@ -15,69 +15,65 @@ public class CmdRules extends FCommand {
aliases.add("rules"); aliases.add("rules");
this.optionalArgs.put("add/remove/set/clear", ""); this.optionalArgs.put("add/remove/set/clear", "");
this.errorOnToManyArgs = false;
permission = Permission.RULES.node;
senderMustBePlayer = true;
senderMustBeMember = true;
senderMustBeModerator = false;
senderMustBeColeader = true;
senderMustBeAdmin = false;
this.requirements = new CommandRequirements.Builder(Permission.RULES)
.playerOnly()
.memberOnly()
.noErrorOnManyArgs()
.build();
} }
@Override @Override
public void perform() { public void perform(CommandContext context) {
if (!P.p.getConfig().getBoolean("frules.Enabled")) { if (!FactionsPlugin.getInstance().getConfig().getBoolean("frules.Enabled")) {
fme.msg(TL.COMMAND_RULES_DISABLED_MSG); context.msg(TL.COMMAND_RULES_DISABLED_MSG);
return; return;
} }
if (this.args.size() == 0) { if (context.args.size() == 0) {
HashMap<Integer, String> rules = fme.getFaction().getRulesMap(); HashMap<Integer, String> rules = context.faction.getRulesMap();
if (rules.size() == 0) { if (rules.size() == 0) {
List<String> ruleList = P.p.getConfig().getStringList("frules.default-rules"); List<String> ruleList = FactionsPlugin.getInstance().getConfig().getStringList("frules.default-rules");
fme.sendMessage(P.p.colorList(ruleList)); context.sendMessage(FactionsPlugin.getInstance().colorList(ruleList));
} else { } else {
for (int i = 0; i <= rules.size() - 1; i++) { for (int i = 0; i <= rules.size() - 1; i++) {
fme.sendMessage(P.p.color(rules.get(i))); context.sendMessage(FactionsPlugin.getInstance().color(rules.get(i)));
} }
} }
} }
if (this.args.size() == 1) { if (context.args.size() == 1) {
if (args.get(0).equalsIgnoreCase("add")) { if (context.args.get(0).equalsIgnoreCase("add")) {
fme.msg(TL.COMMAND_RULES_ADD_INVALIDARGS); context.msg(TL.COMMAND_RULES_ADD_INVALIDARGS);
} }
if (args.get(0).equalsIgnoreCase("set")) { if (context.args.get(0).equalsIgnoreCase("set")) {
fme.msg(TL.COMMAND_RULES_SET_INVALIDARGS); context.msg(TL.COMMAND_RULES_SET_INVALIDARGS);
} }
if (args.get(0).equalsIgnoreCase("remove")) { if (context.args.get(0).equalsIgnoreCase("remove")) {
fme.msg(TL.COMMAND_RULES_REMOVE_INVALIDARGS); context.msg(TL.COMMAND_RULES_REMOVE_INVALIDARGS);
} }
if (args.get(0).equalsIgnoreCase("clear")) { if (context.args.get(0).equalsIgnoreCase("clear")) {
fme.getFaction().clearRules(); context.faction.clearRules();
fme.msg(TL.COMMAND_RULES_CLEAR_SUCCESS); context.msg(TL.COMMAND_RULES_CLEAR_SUCCESS);
} }
} }
if (this.args.size() >= 2) { if (context.args.size() >= 2) {
if (args.get(0).equalsIgnoreCase("add")) { if (context.args.get(0).equalsIgnoreCase("add")) {
String message = ""; String message = "";
StringBuilder string = new StringBuilder(message); StringBuilder string = new StringBuilder(message);
for (int i = 1; i <= args.size() - 1; i++) { for (int i = 1; i <= context.args.size() - 1; i++) {
string.append(" ").append(args.get(i)); string.append(" " + context.args.get(i));
} }
fme.getFaction().addRule(string.toString()); context.faction.addRule(string.toString());
fme.msg(TL.COMMAND_RULES_ADD_SUCCESS); context.msg(TL.COMMAND_RULES_ADD_SUCCESS);
} }
if (this.args.size() == 2) { if (context.args.size() == 2) {
if (args.get(0).equalsIgnoreCase("remove")) { if (context.args.get(0).equalsIgnoreCase("remove")) {
int index = argAsInt(1); int index = context.argAsInt(1);
fme.getFaction().removeRule(index - 1); context.faction.removeRule(index - 1);
fme.msg(TL.COMMAND_RULES_REMOVE_SUCCESS); context.msg(TL.COMMAND_RULES_REMOVE_SUCCESS);
} }
} }
@@ -88,4 +84,4 @@ public class CmdRules extends FCommand {
public TL getUsageTranslation() { public TL getUsageTranslation() {
return TL.COMMAND_RULES_DESCRIPTION; return TL.COMMAND_RULES_DESCRIPTION;
} }
} }

View File

@@ -9,25 +9,27 @@ public class CmdSB extends FCommand {
public CmdSB() { public CmdSB() {
this.aliases.add("sb"); this.aliases.add("sb");
this.aliases.add("scoreboard"); this.aliases.add("scoreboard");
this.permission = Permission.SCOREBOARD.node;
this.senderMustBePlayer = true; this.requirements = new CommandRequirements.Builder(Permission.SCOREBOARD)
.playerOnly()
.build();
} }
@Override @Override
public void perform() { public void perform(CommandContext context) {
boolean toggleTo = !fme.showScoreboard(); boolean toggleTo = !context.fPlayer.showScoreboard();
FScoreboard board = FScoreboard.get(fme); FScoreboard board = FScoreboard.get(context.fPlayer);
if (board == null) { if (board == null) {
me.sendMessage(TL.COMMAND_TOGGLESB_DISABLED.toString()); context.msg(TL.COMMAND_TOGGLESB_DISABLED.toString());
} else { } else {
me.sendMessage(TL.TOGGLE_SB.toString().replace("{value}", String.valueOf(toggleTo))); context.msg(TL.TOGGLE_SB.toString().replace("{value}", String.valueOf(toggleTo)));
board.setSidebarVisibility(toggleTo); board.setSidebarVisibility(toggleTo);
} }
fme.setShowScoreboard(toggleTo); context.fPlayer.setShowScoreboard(toggleTo);
} }
@Override @Override
public TL getUsageTranslation() { public TL getUsageTranslation() {
return TL.COMMAND_SCOREBOARD_DESCRIPTION; return TL.COMMAND_SCOREBOARD_DESCRIPTION;
} }
} }

View File

@@ -4,6 +4,7 @@ import com.massivecraft.factions.Board;
import com.massivecraft.factions.Conf; import com.massivecraft.factions.Conf;
import com.massivecraft.factions.FPlayers; import com.massivecraft.factions.FPlayers;
import com.massivecraft.factions.Factions; import com.massivecraft.factions.Factions;
import com.massivecraft.factions.shop.ShopConfig;
import com.massivecraft.factions.struct.Permission; import com.massivecraft.factions.struct.Permission;
import com.massivecraft.factions.zcore.util.TL; import com.massivecraft.factions.zcore.util.TL;
@@ -14,26 +15,18 @@ public class CmdSaveAll extends FCommand {
this.aliases.add("saveall"); this.aliases.add("saveall");
this.aliases.add("save"); this.aliases.add("save");
//this.requiredArgs.add(""); this.requirements = new CommandRequirements.Builder(Permission.SAVE)
//this.optionalArgs.put("", ""); .build();
this.permission = Permission.SAVE.node;
this.disableOnLock = false;
senderMustBePlayer = false;
senderMustBeMember = false;
senderMustBeModerator = false;
senderMustBeColeader = false;
senderMustBeAdmin = false;
} }
@Override @Override
public void perform() { public void perform(CommandContext context) {
FPlayers.getInstance().forceSave(false); FPlayers.getInstance().forceSave(false);
Factions.getInstance().forceSave(false); Factions.getInstance().forceSave(false);
Board.getInstance().forceSave(false); Board.getInstance().forceSave(false);
Conf.save(); Conf.save();
msg(TL.COMMAND_SAVEALL_SUCCESS); ShopConfig.saveShop();
context.msg(TL.COMMAND_SAVEALL_SUCCESS);
} }
@Override @Override

View File

@@ -2,7 +2,7 @@ package com.massivecraft.factions.cmd;
import com.massivecraft.factions.FLocation; import com.massivecraft.factions.FLocation;
import com.massivecraft.factions.P; import com.massivecraft.factions.FactionsPlugin;
import com.massivecraft.factions.struct.Permission; import com.massivecraft.factions.struct.Permission;
import com.massivecraft.factions.util.Particles.ParticleEffect; import com.massivecraft.factions.util.Particles.ParticleEffect;
import com.massivecraft.factions.util.VisualizeUtil; import com.massivecraft.factions.util.VisualizeUtil;
@@ -17,7 +17,7 @@ public class CmdSeeChunk extends FCommand {
//Used a hashmap cuz imma make a particle selection gui later, will store it where the boolean is rn. //Used a hashmap cuz imma make a particle selection gui later, will store it where the boolean is rn.
public static HashMap<String, Boolean> seeChunkMap = new HashMap<>(); public static HashMap<String, Boolean> seeChunkMap = new HashMap<>();
Long interval; private long interval;
private boolean useParticles; private boolean useParticles;
private ParticleEffect effect; private ParticleEffect effect;
private int taskID = -1; private int taskID = -1;
@@ -31,30 +31,26 @@ public class CmdSeeChunk extends FCommand {
aliases.add("seechunk"); aliases.add("seechunk");
aliases.add("sc"); aliases.add("sc");
permission = Permission.SEECHUNK.node; this.useParticles = FactionsPlugin.getInstance().getConfig().getBoolean("see-chunk.particles", true);
interval = FactionsPlugin.getInstance().getConfig().getLong("see-chunk.interval", 10L);
senderMustBePlayer = true;
senderMustBeMember = false;
senderMustBeModerator = false;
senderMustBeAdmin = false;
this.useParticles = p.getConfig().getBoolean("see-chunk.particles", true);
interval = P.p.getConfig().getLong("see-chunk.interval", 10L);
if (effect == null) { if (effect == null) {
effect = ParticleEffect.REDSTONE; effect = ParticleEffect.REDSTONE;
} }
this.requirements = new CommandRequirements.Builder(Permission.SEECHUNK)
.playerOnly()
.build();
} }
@Override @Override
public void perform() { public void perform(CommandContext context) {
if (seeChunkMap.containsKey(me.getName())) { if (seeChunkMap.containsKey(context.player.getName())) {
seeChunkMap.remove(me.getName()); seeChunkMap.remove(context.player.getName());
msg(TL.COMMAND_SEECHUNK_DISABLED); context.msg(TL.COMMAND_SEECHUNK_DISABLED);
} else { } else {
seeChunkMap.put(me.getName(), true); seeChunkMap.put(context.player.getName(), true);
msg(TL.COMMAND_SEECHUNK_ENABLED); context.msg(TL.COMMAND_SEECHUNK_ENABLED);
manageTask(); manageTask();
} }
} }
@@ -71,7 +67,7 @@ public class CmdSeeChunk extends FCommand {
} }
private void startTask() { private void startTask() {
taskID = Bukkit.getScheduler().scheduleSyncRepeatingTask(P.p, () -> { taskID = Bukkit.getScheduler().scheduleSyncRepeatingTask(FactionsPlugin.getInstance(), () -> {
for (Object nameObject : seeChunkMap.keySet()) { for (Object nameObject : seeChunkMap.keySet()) {
String name = nameObject + ""; String name = nameObject + "";
Player player = Bukkit.getPlayer(name); Player player = Bukkit.getPlayer(name);
@@ -115,10 +111,10 @@ public class CmdSeeChunk extends FCommand {
continue; continue;
} }
if (useParticles) { if (useParticles) {
if (P.p.useNonPacketParticles) { if (FactionsPlugin.getInstance().useNonPacketParticles) {
// Dust options only exists in the 1.13 API, so we use an // Dust options only exists in the 1.13 API, so we use an
// alternative method to achieve this in lower versions. // alternative method to achieve this in lower versions.
if (P.p.mc113) { if (FactionsPlugin.getInstance().mc113 || FactionsPlugin.getInstance().mc114) {
player.spawnParticle(Particle.REDSTONE, loc, 0, new Particle.DustOptions(Color.RED, 1)); player.spawnParticle(Particle.REDSTONE, loc, 0, new Particle.DustOptions(Color.RED, 1));
} else { } else {
player.getWorld().spawnParticle(Particle.REDSTONE, loc, 0, 255, 0, 0, 1); player.getWorld().spawnParticle(Particle.REDSTONE, loc, 0, 255, 0, 0, 1);

View File

@@ -0,0 +1,59 @@
package com.massivecraft.factions.cmd;
import com.massivecraft.factions.Faction;
import com.massivecraft.factions.FactionsPlugin;
import com.massivecraft.factions.struct.Permission;
import com.massivecraft.factions.zcore.util.TL;
public class CmdSeeDiscord extends FCommand{
public CmdSeeDiscord() {
this.aliases.add("seediscord");
this.aliases.add("discord");
this.optionalArgs.put("faction", "yours");
this.requirements = new CommandRequirements.Builder(Permission.DISCORD)
.memberOnly()
.build();
}
@Override
public void perform(CommandContext context) {
if (!FactionsPlugin.getInstance().getConfig().getBoolean("fdiscord.Enabled")) {
context.msg(TL.GENERIC_DISABLED);
return;
}
if (context.args.size() == 0) {
if (context.fPlayer.getFaction().getDiscord() == null) {
context.msg(TL.COMMAND_DISCORD_NOTSET);
} else {
context.msg(TL.DISCORD_PLAYER_DISCORD, context.fPlayer.getFaction().getDiscord());
}
} else if (context.args.size() == 1) {
if (context.fPlayer.isAdminBypassing()) {
Faction faction = context.argAsFaction(0);
if (faction != null) {
if (faction.getDiscord() == null) {
context.msg(TL.COMMAND_DISCORDSEE_FACTION_NOTSET, faction.getTag());
} else {
context.msg(TL.COMMAND_DISCORDSEE_FACTION_DISCORD.toString(), faction.getTag(), faction.getDiscord());
}
}
} else {
context.msg(TL.GENERIC_NOPERMISSION, "see another factions discord.");
}
} else {
context.msg(FactionsPlugin.getInstance().cmdBase.cmdSeeDiscord.getUsageTemplate(context));
}
}
@Override
public TL getUsageTranslation() {
return TL.COMMAND_DISCORDSEE_DESCRIPTION;
}
}

View File

@@ -9,24 +9,20 @@ public class CmdSetBanner extends FCommand {
super(); super();
aliases.add("setbanner"); aliases.add("setbanner");
permission = Permission.BANNER.node; this.requirements = new CommandRequirements.Builder(Permission.BANNER)
.playerOnly()
senderMustBePlayer = true; .build();
senderMustBeMember = false;
senderMustBeModerator = false;
senderMustBeAdmin = true;
} }
public void perform() { @Override
if (!me.getItemInHand().getType().toString().contains("BANNER")) { public void perform(CommandContext context) {
fme.msg(TL.COMMAND_SETBANNER_NOTBANNER); if (!context.player.getItemInHand().getType().toString().contains("BANNER")) {
context.msg(TL.COMMAND_SETBANNER_NOTBANNER);
return; return;
} }
fme.getFaction().setBannerPattern(me.getItemInHand()); context.faction.setBannerPattern(context.player.getItemInHand());
fme.msg(TL.COMMAND_SETBANNER_SUCCESS); context.msg(TL.COMMAND_SETBANNER_SUCCESS);
} }

View File

@@ -15,30 +15,28 @@ public class CmdSetDefaultRole extends FCommand {
this.aliases.add("def"); this.aliases.add("def");
this.requiredArgs.add("role"); this.requiredArgs.add("role");
this.senderMustBeAdmin = true; this.requirements = new CommandRequirements.Builder(Permission.DEFAULTRANK)
this.senderMustBePlayer = true; .playerOnly()
senderMustBeColeader = false; .memberOnly()
.build();
this.permission = Permission.DEFAULTRANK.node;
} }
@Override @Override
public void perform() { public void perform(CommandContext context) {
Role target = Role.fromString(argAsString(0).toUpperCase()); Role target = Role.fromString(context.argAsString(0).toUpperCase());
if (target == null) { if (target == null) {
msg(TL.COMMAND_SETDEFAULTROLE_INVALIDROLE, argAsString(0)); context.msg(TL.COMMAND_SETDEFAULTROLE_INVALIDROLE, context.argAsString(0));
return; return;
} }
if (target == Role.LEADER) { if (target == Role.LEADER) {
msg(TL.COMMAND_SETDEFAULTROLE_NOTTHATROLE, argAsString(0)); context.msg(TL.COMMAND_SETDEFAULTROLE_NOTTHATROLE, context.argAsString(0));
return; return;
} }
myFaction.setDefaultRole(target); context.faction.setDefaultRole(target);
msg(TL.COMMAND_SETDEFAULTROLE_SUCCESS, target.nicename); context.msg(TL.COMMAND_SETDEFAULTROLE_SUCCESS, target.nicename);
} }
@Override @Override

View File

@@ -0,0 +1,65 @@
package com.massivecraft.factions.cmd;
import com.massivecraft.factions.Faction;
import com.massivecraft.factions.FactionsPlugin;
import com.massivecraft.factions.struct.Permission;
import com.massivecraft.factions.zcore.util.TL;
public class CmdSetDiscord extends FCommand {
public CmdSetDiscord(){
super();
this.aliases.add("setdiscord");
this.optionalArgs.put("faction", "yours");
this.requiredArgs.add("link");
this.requirements = new CommandRequirements.Builder(Permission.SETDISCORD)
.playerOnly()
.memberOnly()
.build();
}
@Override
public void perform(CommandContext context) {
if (!FactionsPlugin.getInstance().getConfig().getBoolean("fdiscord.Enabled")) {
context.fPlayer.msg(TL.GENERIC_DISABLED, "discord");
return;
}
if (context.args.size() == 1) {
if (isDiscordInvite(context.argAsString(0))) {
context.fPlayer.getFaction().setDiscord(context.argAsString(0));
context.msg(TL.COMMAND_DISCORDSET_SUCCESSFUL, context.argAsString(0));
} else {
context.msg(TL.COMMAND_DISCORDSET_NOTEMAIL, context.argAsString(0));
}
} else if (context.args.size() == 2) {
if (context.fPlayer.isAdminBypassing()) {
Faction faction = context.argAsFaction(1);
if (faction != null) {
if (isDiscordInvite(context.argAsString(0))) {
context.fPlayer.getFaction().setDiscord(context.argAsString(0));
context.msg(TL.COMMAND_DISCORDSET_ADMIN_SUCCESSFUL, faction.getTag(), context.argAsString(0));
} else {
context.msg(TL.COMMAND_DISCORDSET_ADMIN_FAILED, context.argAsString(0));
}
}
} else {
context.msg(TL.GENERIC_NOPERMISSION, "set another factions discord link!");
}
} else {
context.msg(FactionsPlugin.getInstance().cmdBase.cmdSetDiscord.getUsageTemplate(context));
}
}
private boolean isDiscordInvite(String invite){
return invite.contains("discord.gg") || invite.contains("discord.me");
}
@Override
public TL getUsageTranslation() {
return TL.COMMAND_DISCORDSET_DESCRIPTION;
}
}

View File

@@ -1,79 +1,50 @@
package com.massivecraft.factions.cmd; package com.massivecraft.factions.cmd;
import com.massivecraft.factions.FPlayer; import com.massivecraft.factions.FPlayer;
import com.massivecraft.factions.P; import com.massivecraft.factions.FactionsPlugin;
import com.massivecraft.factions.struct.Permission; import com.massivecraft.factions.struct.Permission;
import com.massivecraft.factions.struct.Relation; import com.massivecraft.factions.struct.Relation;
import com.massivecraft.factions.struct.Role;
import com.massivecraft.factions.util.LazyLocation; import com.massivecraft.factions.util.LazyLocation;
import com.massivecraft.factions.zcore.fperms.Access;
import com.massivecraft.factions.zcore.fperms.PermissableAction; import com.massivecraft.factions.zcore.fperms.PermissableAction;
import com.massivecraft.factions.zcore.util.TL; import com.massivecraft.factions.zcore.util.TL;
public class CmdSetFWarp extends FCommand { public class CmdSetFWarp extends FCommand {
public CmdSetFWarp() { public CmdSetFWarp() {
super();
this.aliases.add("setwarp"); this.aliases.add("setwarp");
this.aliases.add("sw"); this.aliases.add("sw");
this.requiredArgs.add("warp name"); this.requiredArgs.add("warp name");
this.optionalArgs.put("password", "password"); this.optionalArgs.put("password", "password");
this.requirements = new CommandRequirements.Builder(Permission.SETWARP).playerOnly().memberOnly().withAction(PermissableAction.SETWARP).build();
this.senderMustBeMember = true;
this.senderMustBeModerator = false;
this.senderMustBePlayer = true;
this.permission = Permission.SETWARP.node;
} }
@Override @Override
public void perform() { public void perform(CommandContext context) {
if (!(fme.getRelationToLocation() == Relation.MEMBER)) { if (context.fPlayer.getRelationToLocation() != Relation.MEMBER) {
fme.msg(TL.COMMAND_SETFWARP_NOTCLAIMED); context.msg(TL.COMMAND_SETFWARP_NOTCLAIMED);
return; return;
} }
String warp = context.argAsString(0);
// This statement allows us to check if they've specifically denied it, or default to boolean warpExists = context.faction.isWarp(warp);
// the old setting of allowing moderators to set warps. int maxWarps = context.faction.getWarpsLimit();
if (!fme.isAdminBypassing()) { boolean tooManyWarps = maxWarps <= context.faction.getWarps().size();
Access access = myFaction.getAccess(fme, PermissableAction.SETWARP);
if (access != Access.ALLOW && fme.getRole() != Role.LEADER) {
fme.msg(TL.GENERIC_FPERM_NOPERMISSION, "set warps");
return;
}
}
String warp = argAsString(0);
// Checks if warp with same name already exists and ignores maxWarp check if it does.
boolean warpExists = myFaction.isWarp(warp);
int maxWarps = P.p.getConfig().getInt("max-warps", 5);
boolean tooManyWarps = maxWarps <= myFaction.getWarps().size();
if (tooManyWarps && !warpExists) { if (tooManyWarps && !warpExists) {
fme.msg(TL.COMMAND_SETFWARP_LIMIT, maxWarps); context.msg(TL.COMMAND_SETFWARP_LIMIT, maxWarps);
return; return;
} }
if (!this.transact(context.fPlayer, context)) {
if (!transact(fme)) {
return; return;
} }
String password = context.argAsString(1);
String password = argAsString(1); LazyLocation loc = new LazyLocation(context.player.getLocation());
context.faction.setWarp(warp, loc);
LazyLocation loc = new LazyLocation(fme.getPlayer().getLocation());
myFaction.setWarp(warp, loc);
if (password != null) { if (password != null) {
myFaction.setWarpPassword(warp, password); context.faction.setWarpPassword(warp, password);
} }
fme.msg(TL.COMMAND_SETFWARP_SET, warp, password != null ? password : ""); context.msg(TL.COMMAND_SETFWARP_SET, warp, (password != null) ? password : "");
} }
private boolean transact(FPlayer player) { private boolean transact(FPlayer player, CommandContext context) {
return !P.p.getConfig().getBoolean("warp-cost.enabled", false) || player.isAdminBypassing() || payForCommand(P.p.getConfig().getDouble("warp-cost.setwarp", 5), TL.COMMAND_SETFWARP_TOSET.toString(), TL.COMMAND_SETFWARP_FORSET.toString()); return !FactionsPlugin.getInstance().getConfig().getBoolean("warp-cost.enabled", false) || player.isAdminBypassing() || context.payForCommand(FactionsPlugin.getInstance().getConfig().getDouble("warp-cost.setwarp", 5.0), TL.COMMAND_SETFWARP_TOSET.toString(), TL.COMMAND_SETFWARP_FORSET.toString());
} }
@Override @Override
@@ -81,3 +52,4 @@ public class CmdSetFWarp extends FCommand {
return TL.COMMAND_SETFWARP_DESCRIPTION; return TL.COMMAND_SETFWARP_DESCRIPTION;
} }
} }

View File

@@ -10,37 +10,29 @@ public class CmdSetMaxVaults extends FCommand {
public CmdSetMaxVaults() { public CmdSetMaxVaults() {
this.aliases.add("setmaxvaults"); this.aliases.add("setmaxvaults");
this.aliases.add("smv"); this.aliases.add("smv");
this.requiredArgs.add("faction"); this.requiredArgs.add("faction");
this.requiredArgs.add("number"); this.requiredArgs.add("number");
this.permission = Permission.SETMAXVAULTS.node; this.requirements = new CommandRequirements.Builder(Permission.SETMAXVAULTS)
this.disableOnLock = false; .build();
senderMustBePlayer = false;
senderMustBeMember = false;
senderMustBeModerator = false;
senderMustBeColeader = false;
senderMustBeAdmin = false;
} }
@Override @Override
public void perform() { public void perform(CommandContext context) {
Faction targetFaction = argAsFaction(0); Faction targetFaction = context.argAsFaction(0);
int value = argAsInt(1, -1); int value = context.argAsInt(1, -1);
if (value < 0) { if (value < 0) {
sender.sendMessage(ChatColor.RED + "Number must be greater than 0."); context.sender.sendMessage(ChatColor.RED + "Number must be greater than 0.");
return; return;
} }
if (targetFaction == null) { if (targetFaction == null) {
sender.sendMessage(ChatColor.RED + "Couldn't find Faction: " + ChatColor.YELLOW + argAsString(0)); context.sender.sendMessage(ChatColor.RED + "Couldn't find Faction: " + ChatColor.YELLOW + context.argAsString(0));
return; return;
} }
targetFaction.setMaxVaults(value); targetFaction.setMaxVaults(value);
sender.sendMessage(TL.COMMAND_SETMAXVAULTS_SUCCESS.format(targetFaction.getTag(), value)); context.sender.sendMessage(TL.COMMAND_SETMAXVAULTS_SUCCESS.format(targetFaction.getTag(), value));
} }
@Override @Override

View File

@@ -1,12 +1,7 @@
package com.massivecraft.factions.cmd; package com.massivecraft.factions.cmd;
import com.massivecraft.factions.Board; import com.massivecraft.factions.*;
import com.massivecraft.factions.Conf;
import com.massivecraft.factions.FLocation;
import com.massivecraft.factions.Faction;
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;
@@ -14,60 +9,46 @@ public class CmdSethome extends FCommand {
public CmdSethome() { public CmdSethome() {
this.aliases.add("sethome"); this.aliases.add("sethome");
//this.requiredArgs.add("");
this.optionalArgs.put("faction tag", "mine"); this.optionalArgs.put("faction tag", "mine");
this.permission = Permission.SETHOME.node; this.requirements = new CommandRequirements.Builder(Permission.SETHOME)
this.disableOnLock = true; .playerOnly()
.memberOnly()
senderMustBePlayer = true; .withAction(PermissableAction.SETHOME)
senderMustBeMember = false; .build();
senderMustBeModerator = false;
senderMustBeColeader = false;
senderMustBeAdmin = false;
} }
@Override @Override
public void perform() { public void perform(CommandContext context) {
if (!Conf.homesEnabled) { if (!Conf.homesEnabled) {
fme.msg(TL.COMMAND_SETHOME_DISABLED); context.msg(TL.COMMAND_SETHOME_DISABLED);
return; return;
} }
Faction faction = this.argAsFaction(0, myFaction); Faction faction = context.argAsFaction(0, context.faction);
if (faction == null) { if (faction == null) {
return; return;
} }
if (!fme.isAdminBypassing()) {
Access access = myFaction.getAccess(fme, PermissableAction.SETHOME);
if (access != Access.ALLOW && fme.getRole() != Role.LEADER && !Permission.SETHOME_ANY.has(sender, true)) {
fme.msg(TL.GENERIC_FPERM_NOPERMISSION, "set home");
return;
}
}
// Can the player set the faction home HERE? // Can the player set the faction home HERE?
if (!Permission.BYPASS.has(me) && if (!Permission.BYPASS.has(context.player) &&
Conf.homesMustBeInClaimedTerritory && Conf.homesMustBeInClaimedTerritory &&
Board.getInstance().getFactionAt(new FLocation(me)) != faction) { Board.getInstance().getFactionAt(new FLocation(context.player)) != faction) {
fme.msg(TL.COMMAND_SETHOME_NOTCLAIMED); context.msg(TL.COMMAND_SETHOME_NOTCLAIMED);
return; return;
} }
// if economy is enabled, they're not on the bypass list, and this command has a cost set, make 'em pay // if economy is enabled, they're not on the bypass list, and this command has a cost set, make 'em pay
if (!payForCommand(Conf.econCostSethome, TL.COMMAND_SETHOME_TOSET, TL.COMMAND_SETHOME_FORSET)) { if (!context.payForCommand(Conf.econCostSethome, TL.COMMAND_SETHOME_TOSET, TL.COMMAND_SETHOME_FORSET)) {
return; return;
} }
faction.setHome(me.getLocation()); faction.setHome(context.player.getLocation());
faction.msg(TL.COMMAND_SETHOME_SET, fme.describeTo(myFaction, true)); faction.msg(TL.COMMAND_SETHOME_SET, context.fPlayer.describeTo(context.faction, true));
faction.sendMessage(p.cmdBase.cmdHome.getUseageTemplate()); faction.sendMessage(FactionsPlugin.getInstance().cmdBase.cmdHome.getUsageTemplate(context));
if (faction != myFaction) { if (faction != context.faction) {
fme.msg(TL.COMMAND_SETHOME_SETOTHER, faction.getTag(fme)); context.msg(TL.COMMAND_SETHOME_SETOTHER, faction.getTag(context.fPlayer));
} }
} }

View File

@@ -2,7 +2,7 @@ package com.massivecraft.factions.cmd;
import com.massivecraft.factions.Conf; import com.massivecraft.factions.Conf;
import com.massivecraft.factions.Faction; import com.massivecraft.factions.Faction;
import com.massivecraft.factions.P; import com.massivecraft.factions.FactionsPlugin;
import com.massivecraft.factions.struct.Permission; import com.massivecraft.factions.struct.Permission;
import com.massivecraft.factions.zcore.util.TL; import com.massivecraft.factions.zcore.util.TL;
import com.massivecraft.factions.zcore.util.TagReplacer; import com.massivecraft.factions.zcore.util.TagReplacer;
@@ -19,14 +19,12 @@ public class CmdShow extends FCommand {
public CmdShow() { public CmdShow() {
this.aliases.add("show"); this.aliases.add("show");
this.aliases.add("who"); this.aliases.add("who");
this.aliases.add("f");
// add defaults to /f show in case config doesnt have it // add defaults to /f show in case config doesnt have it
defaults.add("{header}"); defaults.add("{header}");
defaults.add("<a>Description: <i>{description}"); defaults.add("<a>Description: <i>{description}");
defaults.add("<a>Joining: <i>{joining} {peaceful}"); defaults.add("<a>Joining: <i>{joining} {peaceful}");
defaults.add("<a>Land / Power / Maxpower: <i> {chunks} / {power} / {maxPower}"); defaults.add("<a>Land / Power / Maxpower: <i> {chunks} / {power} / {maxPower}");
defaults.add("<a>Faction Strikes: {strikes}");
defaults.add("<a>Founded: <i>{create-date}"); defaults.add("<a>Founded: <i>{create-date}");
defaults.add("<a>This faction is permanent, remaining even with no members."); defaults.add("<a>This faction is permanent, remaining even with no members.");
defaults.add("<a>Land value: <i>{land-value} {land-refund}"); defaults.add("<a>Land value: <i>{land-value} {land-refund}");
@@ -34,69 +32,63 @@ public class CmdShow extends FCommand {
defaults.add("<a>Allies(<i>{allies}<a>/<i>{max-allies}<a>): {allies-list}"); defaults.add("<a>Allies(<i>{allies}<a>/<i>{max-allies}<a>): {allies-list}");
defaults.add("<a>Online: (<i>{online}<a>/<i>{members}<a>): {online-list}"); defaults.add("<a>Online: (<i>{online}<a>/<i>{members}<a>): {online-list}");
defaults.add("<a>Offline: (<i>{offline}<a>/<i>{members}<a>): {offline-list}"); defaults.add("<a>Offline: (<i>{offline}<a>/<i>{members}<a>): {offline-list}");
defaults.add("<a>Alt List: <i>{alts}");
// this.requiredArgs.add(""); // this.requiredArgs.add("");
this.optionalArgs.put("faction tag", "yours"); this.optionalArgs.put("faction tag", "yours");
this.permission = Permission.SHOW.node; this.requirements = new CommandRequirements.Builder(Permission.SHOW).build();
this.disableOnLock = false;
senderMustBeMember = false;
senderMustBeModerator = false;
senderMustBeAdmin = false;
} }
@Override @Override
public void perform() { public void perform(CommandContext context) {
Faction faction = myFaction; Faction faction = context.faction;
if (this.argIsSet(0)) if (context.argIsSet(0))
faction = this.argAsFaction(0); faction = context.argAsFaction(0);
if (faction == null) if (faction == null)
return; return;
if (fme != null && !fme.getPlayer().hasPermission("factions.show.bypassexempt") if (context.fPlayer != null && !context.player.getPlayer().hasPermission("factions.show.bypassexempt")
&& P.p.getConfig().getStringList("show-exempt").contains(faction.getTag())) { && FactionsPlugin.getInstance().getConfig().getStringList("show-exempt").contains(faction.getTag())) {
msg(TL.COMMAND_SHOW_EXEMPT); context.msg(TL.COMMAND_SHOW_EXEMPT);
return; return;
} }
// if economy is enabled, they're not on the bypass list, and this command has a cost set, make 'em pay // if economy is enabled, they're not on the bypass list, and this command has a cost set, make 'em pay
if (!payForCommand(Conf.econCostShow, TL.COMMAND_SHOW_TOSHOW, TL.COMMAND_SHOW_FORSHOW)) { if (!context.payForCommand(Conf.econCostShow, TL.COMMAND_SHOW_TOSHOW, TL.COMMAND_SHOW_FORSHOW)) {
return; return;
} }
List<String> show = P.p.getConfig().getStringList("show"); List<String> show = FactionsPlugin.getInstance().getConfig().getStringList("show");
if (show == null || show.isEmpty()) if (show == null || show.isEmpty())
show = defaults; show = defaults;
if (!faction.isNormal()) { if (!faction.isNormal()) {
String tag = faction.getTag(fme); String tag = faction.getTag(context.fPlayer);
// send header and that's all // send header and that's all
String header = show.get(0); String header = show.get(0);
if (TagReplacer.HEADER.contains(header)) { if (TagReplacer.HEADER.contains(header)) {
msg(p.txt.titleize(tag)); context.msg(FactionsPlugin.getInstance().txt.titleize(tag));
} else { } else {
msg(p.txt.parse(TagReplacer.FACTION.replace(header, tag))); context.msg(FactionsPlugin.getInstance().txt.parse(TagReplacer.FACTION.replace(header, tag)));
} }
return; // we only show header for non-normal factions return; // we only show header for non-normal factions
} }
for (String raw : show) { for (String raw : show) {
String parsed = TagUtil.parsePlain(faction, fme, raw); // use relations String parsed = TagUtil.parsePlain(faction, context.fPlayer, raw); // use relations
if (parsed == null) { if (parsed == null) {
continue; // Due to minimal f show. continue; // Due to minimal f show.
} }
if (fme != null) { if (context.fPlayer != null) {
parsed = TagUtil.parsePlaceholders(fme.getPlayer(), parsed); parsed = TagUtil.parsePlaceholders(context.fPlayer.getPlayer(), parsed);
} }
if (TagUtil.hasFancy(parsed)) { if (TagUtil.hasFancy(parsed)) {
List<FancyMessage> fancy = TagUtil.parseFancy(faction, fme, parsed); List<FancyMessage> fancy = TagUtil.parseFancy(faction, context.fPlayer, parsed);
if (fancy != null) if (fancy != null)
sendFancyMessage(fancy); context.sendFancyMessage(fancy);
continue; continue;
} }
@@ -108,7 +100,7 @@ public class CmdShow extends FCommand {
if (parsed.contains("%")) { if (parsed.contains("%")) {
parsed = parsed.replaceAll("%", ""); // 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.
} }
msg(p.txt.parse(parsed)); context.msg(FactionsPlugin.getInstance().txt.parse(parsed));
} }
} }
} }

View File

@@ -9,39 +9,37 @@ import com.massivecraft.factions.zcore.util.TL;
public class CmdShowClaims extends FCommand { public class CmdShowClaims extends FCommand {
public CmdShowClaims() { public CmdShowClaims() {
this.aliases.add("showclaims"); this.aliases.add("showclaims");
this.aliases.add("showclaim"); this.aliases.add("showclaim");
permission = Permission.SHOWCLAIMS.node; this.requirements = new CommandRequirements.Builder(Permission.SHOWCLAIMS)
.playerOnly()
this.senderMustBePlayer = true; .memberOnly()
this.senderMustBeMember = true; .build();
this.senderMustBeModerator = false;
} }
@Override @Override
public void perform() { public void perform(CommandContext context) {
sendMessage(TL.COMMAND_SHOWCLAIMS_HEADER.toString().replace("{faction}", fme.getFaction().describeTo(fme))); context.sendMessage(TL.COMMAND_SHOWCLAIMS_HEADER.toString().replace("{faction}", context.faction.describeTo(context.fPlayer)));
ListMultimap<String, String> chunkMap = ArrayListMultimap.create(); ListMultimap<String, String> chunkMap = ArrayListMultimap.create();
String format = TL.COMMAND_SHOWCLAIMS_CHUNKSFORMAT.toString(); String format = TL.COMMAND_SHOWCLAIMS_CHUNKSFORMAT.toString();
for (FLocation fLocation : fme.getFaction().getAllClaims()) { for (FLocation fLocation : context.faction.getAllClaims()) {
chunkMap.put(fLocation.getWorldName(), format.replace("{x}", fLocation.getX() + "").replace("{z}", fLocation.getZ() + "")); chunkMap.put(fLocation.getWorldName(), format.replace("{x}", fLocation.getX() + "").replace("{z}", fLocation.getZ() + ""));
} }
for (String world : chunkMap.keySet()) { for (String world : chunkMap.keySet()) {
String message = TL.COMMAND_SHOWCLAIMS_FORMAT.toString().replace("{world}", world); String message = TL.COMMAND_SHOWCLAIMS_FORMAT.toString().replace("{world}", world);
// made {chunks} blank as I removed the placeholder and people wont update their config :shrug: // made {chunks} blank as I removed the placeholder and people wont update their config :shrug:
sendMessage(message.replace("{chunks}", "")); context.sendMessage(message.replace("{chunks}", ""));
StringBuilder chunks = new StringBuilder(); StringBuilder chunks = new StringBuilder();
for (String chunkString : chunkMap.get(world)) { for (String chunkString : chunkMap.get(world)) {
chunks.append(chunkString).append(", "); chunks.append(chunkString).append(", ");
if (chunks.toString().length() >= 2000) { if (chunks.toString().length() >= 2000) {
sendMessage(chunks.toString()); context.sendMessage(chunks.toString());
chunks.setLength(0); chunks.setLength(0);
} }
} }
if (chunks.length() != 0) sendMessage(chunks.toString()); if (chunks.length() != 0) context.sendMessage(chunks.toString());
sendMessage(""); context.sendMessage("");
} }
@@ -54,3 +52,4 @@ public class CmdShowClaims extends FCommand {
} }

View File

@@ -13,23 +13,24 @@ public class CmdShowInvites extends FCommand {
public CmdShowInvites() { public CmdShowInvites() {
super(); super();
aliases.add("showinvites"); aliases.add("showinvites");
permission = Permission.SHOW_INVITES.node;
senderMustBePlayer = true; this.requirements = new CommandRequirements.Builder(Permission.SHOW_INVITES)
senderMustBeMember = true; .playerOnly()
.memberOnly()
.build();
} }
@Override @Override
public void perform() { public void perform(CommandContext context) {
FancyMessage msg = new FancyMessage(TL.COMMAND_SHOWINVITES_PENDING.toString()).color(ChatColor.GOLD); FancyMessage msg = new FancyMessage(TL.COMMAND_SHOWINVITES_PENDING.toString()).color(ChatColor.GOLD);
for (String id : myFaction.getInvites()) { for (String id : context.faction.getInvites()) {
FPlayer fp = FPlayers.getInstance().getById(id); FPlayer fp = FPlayers.getInstance().getById(id);
String name = fp != null ? fp.getName() : id; String name = fp != null ? fp.getName() : id;
msg.then(name + " ").color(ChatColor.WHITE).tooltip(TL.COMMAND_SHOWINVITES_CLICKTOREVOKE.format(name)).command("/" + Conf.baseCommandAliases.get(0) + " deinvite " + name); msg.then(name + " ").color(ChatColor.WHITE).tooltip(TL.COMMAND_SHOWINVITES_CLICKTOREVOKE.format(name)).command("/" + Conf.baseCommandAliases.get(0) + " deinvite " + name);
} }
sendFancyMessage(msg); context.sendFancyMessage(msg);
} }
@Override @Override
@@ -39,3 +40,4 @@ public class CmdShowInvites extends FCommand {
} }

View File

@@ -1,33 +0,0 @@
package com.massivecraft.factions.cmd;
import com.massivecraft.factions.struct.Permission;
import com.massivecraft.factions.zcore.util.TL;
public class CmdSpam extends FCommand {
public CmdSpam() {
this.aliases.add("spam");
this.optionalArgs.put("on/off", "flip");
this.permission = Permission.SPAM.node;
this.disableOnLock = false;
this.disableOnSpam = false;
senderMustBePlayer = false;
senderMustBeMember = false;
senderMustBeModerator = false;
senderMustBeAdmin = false;
}
@Override
public void perform() {
p.setSpam(this.argAsBool(0, !p.getSpam()));
msg(p.getSpam() ? TL.COMMAND_SPAM_ENABLED : TL.COMMAND_SPAM_DISABLED);
}
@Override
public TL getUsageTranslation() {
return TL.COMMAND_SPAM_DESCRIPTION;
}
}

View File

@@ -0,0 +1,29 @@
package com.massivecraft.factions.cmd;
import com.massivecraft.factions.Conf;
import com.massivecraft.factions.FactionsPlugin;
import com.massivecraft.factions.struct.Permission;
import com.massivecraft.factions.zcore.util.TL;
public class CmdSpawnerLock extends FCommand {
public CmdSpawnerLock(){
super();
this.aliases.add("lockspawners");
this.aliases.add("spawnerlock");
this.requirements = new CommandRequirements.Builder(Permission.LOCKSPAWNERS)
.build();
}
@Override
public void perform(CommandContext context){
Conf.spawnerLock = !Conf.spawnerLock;
context.msg(TL.COMMAND_SPAWNER_LOCK_TOGGLED, Conf.spawnerLock ? FactionsPlugin.getInstance().color("&aEnabled") : FactionsPlugin.getInstance().color("&4Disabled"));
}
@Override
public TL getUsageTranslation() {
return TL.COMMAND_SPAWNER_LOCK_DESCRIPTION;
}
}

View File

@@ -15,25 +15,22 @@ public class CmdStatus extends FCommand {
this.aliases.add("status"); this.aliases.add("status");
this.aliases.add("s"); this.aliases.add("s");
this.permission = Permission.STATUS.node; this.requirements = new CommandRequirements.Builder(Permission.STATUS)
.playerOnly()
senderMustBePlayer = true; .memberOnly()
senderMustBeMember = true; .build();
senderMustBeModerator = false;
senderMustBeAdmin = false;
} }
@Override @Override
public void perform() { public void perform(CommandContext context) {
ArrayList<String> ret = new ArrayList<>(); ArrayList<String> ret = new ArrayList<>();
for (FPlayer fp : myFaction.getFPlayers()) { for (FPlayer fp : context.faction.getFPlayers()) {
String humanized = DurationFormatUtils.formatDurationWords(System.currentTimeMillis() - fp.getLastLoginTime(), true, true) + TL.COMMAND_STATUS_AGOSUFFIX; String humanized = DurationFormatUtils.formatDurationWords(System.currentTimeMillis() - fp.getLastLoginTime(), true, true) + TL.COMMAND_STATUS_AGOSUFFIX;
String last = fp.isOnline() ? ChatColor.GREEN + TL.COMMAND_STATUS_ONLINE.toString() : (System.currentTimeMillis() - fp.getLastLoginTime() < 432000000 ? ChatColor.YELLOW + humanized : ChatColor.RED + humanized); String last = fp.isOnline() ? ChatColor.GREEN + TL.COMMAND_STATUS_ONLINE.toString() : (System.currentTimeMillis() - fp.getLastLoginTime() < 432000000 ? ChatColor.YELLOW + humanized : ChatColor.RED + humanized);
String power = ChatColor.YELLOW + String.valueOf(fp.getPowerRounded()) + " / " + fp.getPowerMaxRounded() + ChatColor.RESET; String power = ChatColor.YELLOW + String.valueOf(fp.getPowerRounded()) + " / " + fp.getPowerMaxRounded() + ChatColor.RESET;
ret.add(String.format(TL.COMMAND_STATUS_FORMAT.toString(), ChatColor.GOLD + fp.getRole().getPrefix() + fp.getName() + ChatColor.RESET, power, last).trim()); ret.add(String.format(TL.COMMAND_STATUS_FORMAT.toString(), ChatColor.GOLD + fp.getRole().getPrefix() + fp.getName() + ChatColor.RESET, power, last).trim());
} }
fme.sendMessage(ret); context.fPlayer.sendMessage(ret);
} }
@Override @Override

View File

@@ -1,6 +1,5 @@
package com.massivecraft.factions.cmd; package com.massivecraft.factions.cmd;
import com.massivecraft.factions.Faction;
import com.massivecraft.factions.struct.Permission; import com.massivecraft.factions.struct.Permission;
import com.massivecraft.factions.zcore.util.TL; import com.massivecraft.factions.zcore.util.TL;
@@ -8,31 +7,23 @@ public class CmdStealth extends FCommand {
public CmdStealth() { public CmdStealth() {
this.aliases.add("ninja"); this.aliases.add("ninja");
this.aliases.add("stealth"); this.aliases.add("stealth");
this.permission = Permission.STEALTH.node;
this.disableOnLock = true;
this.senderMustBePlayer = true;
this.senderMustBeMember = false;
this.senderMustBeModerator = false;
this.senderMustBeColeader = false;
this.senderMustBeAdmin = false;
this.requirements = new CommandRequirements.Builder(Permission.STEALTH)
.playerOnly()
.build();
} }
public void perform() { @Override
public void perform(CommandContext context) {
if (context.faction != null && !context.faction.getId().equalsIgnoreCase("0") && !context.faction.getId().equalsIgnoreCase("none") && !context.faction.getId().equalsIgnoreCase("safezone") && !context.faction.getId().equalsIgnoreCase("warzone")) {
Faction faction = fme.getFaction(); context.fPlayer.setStealth(!context.fPlayer.isStealthEnabled());
if (faction != null && !faction.getId().equalsIgnoreCase("0") && !faction.getId().equalsIgnoreCase("none") && !faction.getId().equalsIgnoreCase("safezone") && !faction.getId().equalsIgnoreCase("warzone")) { context.msg(context.fPlayer.isStealthEnabled() ? TL.COMMAND_STEALTH_ENABLE : TL.COMMAND_STEALTH_DISABLE);
fme.setStealth(!fme.isStealthEnabled());
fme.msg(fme.isStealthEnabled() ? TL.COMMAND_STEALTH_ENABLE : TL.COMMAND_STEALTH_DISABLE);
} else { } else {
fme.msg(TL.COMMAND_STEALTH_MUSTBEMEMBER); context.msg(TL.COMMAND_STEALTH_MUSTBEMEMBER);
} }
} }
public TL getUsageTranslation() { public TL getUsageTranslation() {
return TL.COMMAND_STEALTH_DESCRIPTION; return TL.COMMAND_STEALTH_DESCRIPTION;
} }
} }

View File

@@ -1,52 +0,0 @@
package com.massivecraft.factions.cmd;
import com.massivecraft.factions.Faction;
import com.massivecraft.factions.Factions;
import com.massivecraft.factions.zcore.util.TL;
public class CmdStrike extends FCommand {
public CmdStrike() {
super();
this.aliases.add("strike");
this.aliases.add("strikes");
this.optionalArgs.put("faction", "tag");
this.disableOnLock = true;
senderMustBePlayer = true;
senderMustBeMember = false;
senderMustBeModerator = false;
senderMustBeAdmin = false;
}
@Override
public void perform() {
if (args.size() == 0) {
if (myFaction.isWilderness()) {
fme.msg(TL.COMMAND_STRIKE_NEEDFACTION);
return;
}
fme.msg(TL.COMMAND_STRIKE_MESSAGE.toString().replace("{faction}", fme.getFaction().getTag()).replace("{strikes}", fme.getFaction().getStrikes() + ""));
return;
}
Faction faction = Factions.getInstance().getByTag(args.get(0));
if (faction != null) {
fme.msg(TL.COMMAND_STRIKE_MESSAGE.toString().replace("{faction}", faction.getTag()).replace("{strikes}", faction.getStrikes() + ""));
} else {
fme.msg(TL.COMMAND_STRIKE_NOTFOUND.toString().replace("{faction}", args.get(0)));
}
}
@Override
public TL getUsageTranslation() {
return TL.COMMAND_STUCK_DESCRIPTION;
}
}

View File

@@ -1,86 +0,0 @@
package com.massivecraft.factions.cmd;
import com.massivecraft.factions.FPlayer;
import com.massivecraft.factions.FPlayers;
import com.massivecraft.factions.Faction;
import com.massivecraft.factions.Factions;
import com.massivecraft.factions.struct.Permission;
import com.massivecraft.factions.zcore.util.TL;
public class CmdStrikeSet extends FCommand {
public CmdStrikeSet() {
super();
this.aliases.add("setstrikes");
this.aliases.add("setstrike");
this.requiredArgs.add("set,give,remove");
this.requiredArgs.add("faction");
this.requiredArgs.add("# of strikes");
this.requiredArgs.add("reason");
this.errorOnToManyArgs = false;
//this.optionalArgs
this.permission = Permission.SETSTRIKES.node;
this.disableOnLock = true;
senderMustBePlayer = false;
senderMustBeMember = false;
senderMustBeModerator = false;
senderMustBeColeader = false;
senderMustBeAdmin = false;
}
@Override
public void perform() {
Faction faction = Factions.getInstance().getByTag(args.get(1));
boolean success = false;
if (faction == null) {
fme.msg(TL.COMMAND_SETSTRIKES_FAILURE.toString().replace("{faction}", args.get(1)));
}
if (faction != null) {
if (args.get(0).equalsIgnoreCase("set")) {
faction.setStrikes(argAsInt(2));
success = true;
} else if (args.get(0).equalsIgnoreCase("give")) {
faction.setStrikes(faction.getStrikes() + argAsInt(2));
success = true;
} else if (args.get(0).equalsIgnoreCase("take")) {
faction.setStrikes(faction.getStrikes() - argAsInt(2));
success = true;
}
if (success) {
for (FPlayer fPlayer : FPlayers.getInstance().getOnlinePlayers()) {
fPlayer.msg(TL.COMMAND_SETSTRIKES_BROADCAST.toString()
.replace("{faction}", faction.getTag())
.replace("{reason}", getReason()));
}
fme.msg(TL.COMMAND_SETSTRIKES_SUCCESS.toString()
.replace("{faction}", faction.getTag())
.replace("{strikes}", faction.getStrikes() + ""));
}
}
}
private String getReason() {
StringBuilder reason = new StringBuilder();
for (int i = 3; i < args.size(); i++) {
reason.append(args.get(i)).append(" ");
}
return reason.toString();
}
@Override
public TL getUsageTranslation() {
return TL.COMMAND_SETSTRIKES_DESCRIPTION;
}
}

View File

@@ -0,0 +1,41 @@
package com.massivecraft.factions.cmd;
import com.massivecraft.factions.FactionsPlugin;
import com.massivecraft.factions.struct.Permission;
import com.massivecraft.factions.zcore.util.TL;
public class CmdStrikes extends FCommand {
public CmdStrikesGive cmdStrikesGive = new CmdStrikesGive();
public CmdStrikesInfo cmdStrikesInfo = new CmdStrikesInfo();
public CmdStrikesSet cmdStrikesSet = new CmdStrikesSet();
public CmdStrikesTake cmdStrikesTake = new CmdStrikesTake();
public CmdStrikes() {
super();
this.aliases.add("strikes");
this.addSubCommand(cmdStrikesGive);
this.addSubCommand(cmdStrikesInfo);
this.addSubCommand(cmdStrikesSet);
this.addSubCommand(cmdStrikesTake);
this.requirements = new CommandRequirements.Builder(Permission.SETSTRIKES)
.playerOnly()
.build();
}
@Override
public void perform(CommandContext context) {
context.commandChain.add(this);
FactionsPlugin.getInstance().cmdAutoHelp.execute(context);
}
@Override
public TL getUsageTranslation() {
return TL.COMMAND_STRIKES_DESCRIPTION;
}
}

View File

@@ -0,0 +1,37 @@
package com.massivecraft.factions.cmd;
import com.massivecraft.factions.Faction;
import com.massivecraft.factions.struct.Permission;
import com.massivecraft.factions.zcore.util.TL;
public class CmdStrikesGive extends FCommand {
public CmdStrikesGive() {
super();
this.aliases.add("give");
this.requiredArgs.add(0, "faction");
this.requirements = new CommandRequirements.Builder(Permission.SETSTRIKES)
.playerOnly()
.build();
}
@Override
public void perform(CommandContext context) {
Faction target = context.argAsFaction(0);
if (target == null || target.isSystemFaction()) {
context.msg(TL.COMMAND_STRIKES_TARGET_INVALID, context.argAsString(0));
return;
}
target.setStrikes(target.getStrikes() + 1);
context.msg(TL.COMMAND_STRIKES_CHANGED, target.getTag(), target.getStrikes());
}
@Override
public TL getUsageTranslation() {
return TL.COMMAND_STRIKESGIVE_DESCRIPTION;
}
}

View File

@@ -0,0 +1,37 @@
package com.massivecraft.factions.cmd;
import com.massivecraft.factions.Faction;
import com.massivecraft.factions.struct.Permission;
import com.massivecraft.factions.zcore.util.TL;
public class CmdStrikesInfo extends FCommand {
public CmdStrikesInfo() {
super();
this.aliases.add("info");
this.optionalArgs.put("target", "faction");
this.requirements = new CommandRequirements.Builder(Permission.SETSTRIKES)
.playerOnly()
.build();
}
@Override
public void perform(CommandContext context) {
Faction target = context.argAsFaction(0);
if (target == null) target = context.faction;
if (target.isSystemFaction()) {
context.msg(TL.COMMAND_STRIKES_TARGET_INVALID, context.argAsString(0));
return;
}
context.msg(TL.COMMAND_STRIKES_INFO, target.getTag(), target.getStrikes());
}
@Override
public TL getUsageTranslation() {
return TL.COMMAND_STRIKESINFO_DESCRIPTION;
}
}

View File

@@ -0,0 +1,37 @@
package com.massivecraft.factions.cmd;
import com.massivecraft.factions.Faction;
import com.massivecraft.factions.struct.Permission;
import com.massivecraft.factions.zcore.util.TL;
public class CmdStrikesSet extends FCommand {
public CmdStrikesSet() {
super();
this.aliases.add("set");
this.requiredArgs.add(0, "faction");
this.requiredArgs.add(1, "amount");
this.requirements = new CommandRequirements.Builder(Permission.SETSTRIKES)
.playerOnly()
.build();
}
@Override
public void perform(CommandContext context) {
Faction target = context.argAsFaction(0);
if (target == null || target.isSystemFaction()) {
context.msg(TL.COMMAND_STRIKES_TARGET_INVALID, context.argAsString(0));
return;
}
target.setStrikes(context.argAsInt(1));
context.msg(TL.COMMAND_STRIKES_CHANGED, target.getTag(), target.getStrikes());
}
@Override
public TL getUsageTranslation() {
return TL.COMMAND_STRIKESET_DESCRIPTION;
}
}

View File

@@ -0,0 +1,38 @@
package com.massivecraft.factions.cmd;
import com.massivecraft.factions.Faction;
import com.massivecraft.factions.struct.Permission;
import com.massivecraft.factions.zcore.util.TL;
public class CmdStrikesTake extends FCommand {
public CmdStrikesTake() {
super();
this.aliases.add("take");
this.requiredArgs.add(0, "faction");
this.requiredArgs.add(1, "number of strikes");
this.requirements = new CommandRequirements.Builder(Permission.SETSTRIKES)
.playerOnly()
.build();
}
@Override
public void perform(CommandContext context) {
Faction target = context.argAsFaction(0);
if (target == null || target.isSystemFaction()) {
context.msg(TL.COMMAND_STRIKES_TARGET_INVALID, context.argAsString(0));
return;
}
target.setStrikes(target.getStrikes() - context.argAsInt(1));
context.msg(TL.COMMAND_STRIKES_CHANGED, target.getTag(), target.getStrikes());
}
@Override
public TL getUsageTranslation() {
return TL.COMMAND_STRIKETAKE_DESCRIPTION;
}
}

View File

@@ -10,87 +10,75 @@ import org.bukkit.Bukkit;
import org.bukkit.Location; import org.bukkit.Location;
import org.bukkit.World; import org.bukkit.World;
import org.bukkit.entity.Player; import org.bukkit.entity.Player;
import org.bukkit.scheduler.BukkitRunnable;
public class CmdStuck extends FCommand { public class CmdStuck extends FCommand {
public CmdStuck() { public CmdStuck() {
super(); super();
this.aliases.add("stuck"); this.aliases.add("stuck");
this.aliases.add("halp!"); // halp!c: this.aliases.add("halp!"); // halp!c:
this.permission = Permission.STUCK.node;
this.disableOnLock = true;
senderMustBePlayer = false;
senderMustBeMember = false;
senderMustBeModerator = false;
senderMustBeAdmin = false;
this.requirements = new CommandRequirements.Builder(Permission.STUCK)
.playerOnly()
.build();
} }
@Override @Override
public void perform() { public void perform(CommandContext context) {
final Player player = fme.getPlayer(); final Player player = context.player;
final Location sentAt = player.getLocation(); final Location sentAt = player.getLocation();
final FLocation chunk = fme.getLastStoodAt(); final FLocation chunk = context.fPlayer.getLastStoodAt();
final long delay = P.p.getConfig().getLong("hcf.stuck.delay", 30); final long delay = FactionsPlugin.getInstance().getConfig().getLong("hcf.stuck.delay", 30);
final int radius = P.p.getConfig().getInt("hcf.stuck.radius", 10); final int radius = FactionsPlugin.getInstance().getConfig().getInt("hcf.stuck.radius", 10);
if (P.p.getStuckMap().containsKey(player.getUniqueId())) { if (FactionsPlugin.getInstance().getStuckMap().containsKey(player.getUniqueId())) {
long wait = P.p.getTimers().get(player.getUniqueId()) - System.currentTimeMillis(); long wait = FactionsPlugin.getInstance().getTimers().get(player.getUniqueId()) - System.currentTimeMillis();
String time = DurationFormatUtils.formatDuration(wait, TL.COMMAND_STUCK_TIMEFORMAT.toString(), true); String time = DurationFormatUtils.formatDuration(wait, TL.COMMAND_STUCK_TIMEFORMAT.toString(), true);
msg(TL.COMMAND_STUCK_EXISTS, time); context.msg(TL.COMMAND_STUCK_EXISTS, time);
} else { } else {
// if economy is enabled, they're not on the bypass list, and this command has a cost set, make 'em pay // if economy is enabled, they're not on the bypass list, and this command has a cost set, make 'em pay
if (!payForCommand(Conf.econCostStuck, TL.COMMAND_STUCK_TOSTUCK.format(fme.getName()), TL.COMMAND_STUCK_FORSTUCK.format(fme.getName()))) { if (!context.payForCommand(Conf.econCostStuck, TL.COMMAND_STUCK_TOSTUCK.format(context.fPlayer.getName()), TL.COMMAND_STUCK_FORSTUCK.format(context.fPlayer.getName()))) {
return; return;
} }
final int id = Bukkit.getScheduler().runTaskLater(P.p, new BukkitRunnable() { final int id = Bukkit.getScheduler().runTaskLater(FactionsPlugin.getInstance(), new Runnable() {
@Override @Override
public void run() { public void run() {
if (!P.p.getStuckMap().containsKey(player.getUniqueId())) { if (!FactionsPlugin.getInstance().getStuckMap().containsKey(player.getUniqueId())) {
return; return;
} }
// check for world difference or radius exceeding // check for world difference or radius exceeding
final World world = chunk.getWorld(); final World world = chunk.getWorld();
if (world.getUID() != player.getWorld().getUID() || sentAt.distance(player.getLocation()) > radius) { if (world.getUID() != player.getWorld().getUID() || sentAt.distance(player.getLocation()) > radius) {
msg(TL.COMMAND_STUCK_OUTSIDE.format(radius)); context.msg(TL.COMMAND_STUCK_OUTSIDE.format(radius));
P.p.getTimers().remove(player.getUniqueId()); FactionsPlugin.getInstance().getTimers().remove(player.getUniqueId());
P.p.getStuckMap().remove(player.getUniqueId()); FactionsPlugin.getInstance().getStuckMap().remove(player.getUniqueId());
return; return;
} }
final Board board = Board.getInstance(); final Board board = Board.getInstance();
// spiral task to find nearest wilderness chunk // spiral task to find nearest wilderness chunk
new SpiralTask(new FLocation(me), radius * 2) { new SpiralTask(new FLocation(context.player), radius * 2) {
final int buffer = P.p.getConfig().getInt("world-border.buffer", 0);
@Override @Override
public boolean work() { public boolean work() {
FLocation chunk = currentFLocation(); FLocation chunk = currentFLocation();
if (chunk.isOutsideWorldBorder(buffer)) {
return true;
}
Faction faction = board.getFactionAt(chunk); Faction faction = board.getFactionAt(chunk);
int buffer = P.p.getConfig().getInt("world-border.buffer", 0); int buffer = FactionsPlugin.getInstance().getConfig().getInt("world-border.buffer", 0) - 1;
if (faction.isWilderness() && !chunk.isOutsideWorldBorder(buffer)) { if (faction.isWilderness() && !chunk.isOutsideWorldBorder(buffer)) {
int cx = FLocation.chunkToBlock((int) chunk.getX()); int cx = FLocation.chunkToBlock((int) chunk.getX());
int cz = FLocation.chunkToBlock((int) chunk.getZ()); int cz = FLocation.chunkToBlock((int) chunk.getZ());
int y = world.getHighestBlockYAt(cx, cz); int y = world.getHighestBlockYAt(cx, cz);
Location tp = new Location(world, cx, y, cz); Location tp = new Location(world, cx, y, cz);
msg(TL.COMMAND_STUCK_TELEPORT, tp.getBlockX(), tp.getBlockY(), tp.getBlockZ()); context.msg(TL.COMMAND_STUCK_TELEPORT, tp.getBlockX(), tp.getBlockY(), tp.getBlockZ());
P.p.getTimers().remove(player.getUniqueId()); FactionsPlugin.getInstance().getTimers().remove(player.getUniqueId());
P.p.getStuckMap().remove(player.getUniqueId()); FactionsPlugin.getInstance().getStuckMap().remove(player.getUniqueId());
if (!Essentials.handleTeleport(player, tp)) { if (!Essentials.handleTeleport(player, tp)) {
player.teleport(tp); player.teleport(tp);
P.p.debug("/f stuck used regular teleport, not essentials!"); FactionsPlugin.getInstance().debug("/f stuck used regular teleport, not essentials!");
} }
this.stop(); this.stop();
return false; return false;
@@ -101,11 +89,11 @@ public class CmdStuck extends FCommand {
} }
}, delay * 20).getTaskId(); }, delay * 20).getTaskId();
P.p.getTimers().put(player.getUniqueId(), System.currentTimeMillis() + (delay * 1000)); FactionsPlugin.getInstance().getTimers().put(player.getUniqueId(), System.currentTimeMillis() + (delay * 1000));
long wait = P.p.getTimers().get(player.getUniqueId()) - System.currentTimeMillis(); long wait = FactionsPlugin.getInstance().getTimers().get(player.getUniqueId()) - System.currentTimeMillis();
String time = DurationFormatUtils.formatDuration(wait, TL.COMMAND_STUCK_TIMEFORMAT.toString(), true); String time = DurationFormatUtils.formatDuration(wait, TL.COMMAND_STUCK_TIMEFORMAT.toString(), true);
msg(TL.COMMAND_STUCK_START, time); context.msg(TL.COMMAND_STUCK_START, time);
P.p.getStuckMap().put(player.getUniqueId(), id); FactionsPlugin.getInstance().getStuckMap().put(player.getUniqueId(), id);
} }
} }
@@ -114,3 +102,4 @@ public class CmdStuck extends FCommand {
return TL.COMMAND_STUCK_DESCRIPTION; return TL.COMMAND_STUCK_DESCRIPTION;
} }
} }

View File

@@ -4,6 +4,7 @@ import com.massivecraft.factions.*;
import com.massivecraft.factions.event.FactionRenameEvent; import com.massivecraft.factions.event.FactionRenameEvent;
import com.massivecraft.factions.scoreboards.FTeamWrapper; import com.massivecraft.factions.scoreboards.FTeamWrapper;
import com.massivecraft.factions.struct.Permission; import com.massivecraft.factions.struct.Permission;
import com.massivecraft.factions.struct.Role;
import com.massivecraft.factions.util.MiscUtil; import com.massivecraft.factions.util.MiscUtil;
import com.massivecraft.factions.zcore.util.TL; import com.massivecraft.factions.zcore.util.TL;
import org.bukkit.Bukkit; import org.bukkit.Bukkit;
@@ -17,77 +18,65 @@ public class CmdTag extends FCommand {
this.aliases.add("rename"); this.aliases.add("rename");
this.requiredArgs.add("faction tag"); this.requiredArgs.add("faction tag");
//this.optionalArgs.put("", "");
this.permission = Permission.TAG.node;
this.disableOnLock = true;
this.disableOnSpam = true;
senderMustBePlayer = true;
senderMustBeMember = false;
senderMustBeModerator = true;
senderMustBeAdmin = false;
this.requirements = new CommandRequirements.Builder(Permission.TAG)
.withRole(Role.COLEADER)
.playerOnly()
.memberOnly()
.build();
} }
@Override @Override
public void perform() { public void perform(CommandContext context) {
String tag = this.argAsString(0); String tag = context.argAsString(0);
if (!fme.isCooldownEnded("tag")) {
fme.msg(TL.COMMAND_ONCOOOLDOWN, fme.getCooldown("tag"));
return;
}
// TODO does not first test cover selfcase? // TODO does not first test cover selfcase?
if (Factions.getInstance().isTagTaken(tag) && !MiscUtil.getComparisonString(tag).equals(myFaction.getComparisonTag())) { if (Factions.getInstance().isTagTaken(tag) && !MiscUtil.getComparisonString(tag).equals(context.faction.getComparisonTag())) {
msg(TL.COMMAND_TAG_TAKEN); context.msg(TL.COMMAND_TAG_TAKEN);
return; return;
} }
ArrayList<String> errors = MiscUtil.validateTag(tag); ArrayList<String> errors = MiscUtil.validateTag(tag);
if (errors.size() > 0) { if (errors.size() > 0) {
sendMessage(errors); context.sendMessage(errors);
return; return;
} }
// if economy is enabled, they're not on the bypass list, and this command has a cost set, make sure they can pay // if economy is enabled, they're not on the bypass list, and this command has a cost set, make sure they can pay
if (!canAffordCommand(Conf.econCostTag, TL.COMMAND_TAG_TOCHANGE.toString())) { if (!context.canAffordCommand(Conf.econCostTag, TL.COMMAND_TAG_TOCHANGE.toString())) {
return; return;
} }
// trigger the faction rename event (cancellable) // trigger the faction rename event (cancellable)
FactionRenameEvent renameEvent = new FactionRenameEvent(fme, tag); FactionRenameEvent renameEvent = new FactionRenameEvent(context.fPlayer, tag);
Bukkit.getServer().getPluginManager().callEvent(renameEvent); Bukkit.getServer().getPluginManager().callEvent(renameEvent);
if (renameEvent.isCancelled()) { if (renameEvent.isCancelled()) {
return; return;
} }
// then make 'em pay (if applicable) // then make 'em pay (if applicable)
if (!payForCommand(Conf.econCostTag, TL.COMMAND_TAG_TOCHANGE, TL.COMMAND_TAG_FORCHANGE)) { if (!context.payForCommand(Conf.econCostTag, TL.COMMAND_TAG_TOCHANGE, TL.COMMAND_TAG_FORCHANGE)) {
return; return;
} }
String oldtag = myFaction.getTag(); String oldtag = context.faction.getTag();
myFaction.setTag(tag); context.faction.setTag(tag);
// Inform // Inform
for (FPlayer fplayer : FPlayers.getInstance().getOnlinePlayers()) { for (FPlayer fplayer : FPlayers.getInstance().getOnlinePlayers()) {
if (fplayer.getFactionId().equals(myFaction.getId())) { if (fplayer.getFactionId().equals(context.faction.getId())) {
fplayer.msg(TL.COMMAND_TAG_FACTION, fme.describeTo(myFaction, true), myFaction.getTag(myFaction)); fplayer.msg(TL.COMMAND_TAG_FACTION, context.fPlayer.describeTo(context.faction, true), context.faction.getTag(context.faction));
continue; continue;
} }
// Broadcast the tag change (if applicable) // Broadcast the tag change (if applicable)
if (Conf.broadcastTagChanges) { if (Conf.broadcastTagChanges) {
Faction faction = fplayer.getFaction(); Faction faction = fplayer.getFaction();
fplayer.msg(TL.COMMAND_TAG_CHANGED, fme.getColorTo(faction) + oldtag, myFaction.getTag(faction)); fplayer.msg(TL.COMMAND_TAG_CHANGED, context.fPlayer.getColorTo(faction) + oldtag, context.faction.getTag(faction));
} }
} }
fme.setCooldown("tag", System.currentTimeMillis() + (P.p.getConfig().getInt("fcooldowns.f-tag") * 1000));
FTeamWrapper.updatePrefixes(myFaction); FTeamWrapper.updatePrefixes(context.faction);
} }
@Override @Override
@@ -95,4 +84,4 @@ public class CmdTag extends FCommand {
return TL.COMMAND_TAG_DESCRIPTION; return TL.COMMAND_TAG_DESCRIPTION;
} }
} }

View File

@@ -10,45 +10,26 @@ public class CmdTitle extends FCommand {
public CmdTitle() { public CmdTitle() {
this.aliases.add("title"); this.aliases.add("title");
this.requiredArgs.add("player name"); this.requiredArgs.add("player name");
this.optionalArgs.put("title", ""); this.optionalArgs.put("title", "");
this.permission = Permission.TITLE.node; this.requirements = new CommandRequirements.Builder(Permission.TITLE)
this.disableOnLock = true; .playerOnly()
.build();
senderMustBePlayer = true;
senderMustBeMember = false;
senderMustBeModerator = true;
senderMustBeAdmin = false;
} }
@Override @Override
public void perform() { public void perform(CommandContext context) {
FPlayer you = this.argAsBestFPlayerMatch(0); FPlayer you = context.argAsBestFPlayerMatch(0);
if (you == null) { if (you == null) return;
return; context.args.remove(0);
} String title = TextUtil.implode(context.args, " ");
if (!context.canIAdministerYou(context.fPlayer, you)) return;
args.remove(0);
String title = TextUtil.implode(args, " ");
title = title.replaceAll(",", "");
if (!canIAdministerYou(fme, you)) {
return;
}
// if economy is enabled, they're not on the bypass list, and this command has a cost set, make 'em pay // if economy is enabled, they're not on the bypass list, and this command has a cost set, make 'em pay
if (!payForCommand(Conf.econCostTitle, TL.COMMAND_TITLE_TOCHANGE, TL.COMMAND_TITLE_FORCHANGE)) { if (!context.payForCommand(Conf.econCostTitle, TL.COMMAND_TITLE_TOCHANGE, TL.COMMAND_TITLE_FORCHANGE)) return;
return; you.setTitle(context.sender, title);
}
you.setTitle(sender, title);
// Inform // Inform
myFaction.msg(TL.COMMAND_TITLE_CHANGED, fme.describeTo(myFaction, true), you.describeTo(myFaction, true)); context.faction.msg(TL.COMMAND_TITLE_CHANGED, context.fPlayer.describeTo(context.faction, true), you.describeTo(context.faction, true));
} }
@Override @Override
@@ -56,4 +37,4 @@ public class CmdTitle extends FCommand {
return TL.COMMAND_TITLE_DESCRIPTION; return TL.COMMAND_TITLE_DESCRIPTION;
} }
} }

View File

@@ -12,16 +12,10 @@ public class CmdToggleAllianceChat extends FCommand {
this.aliases.add("togglealliancechat"); this.aliases.add("togglealliancechat");
this.aliases.add("ac"); this.aliases.add("ac");
this.disableOnLock = false; this.requirements = new CommandRequirements.Builder(Permission.TOGGLE_ALLIANCE_CHAT)
.playerOnly()
this.permission = Permission.TOGGLE_ALLIANCE_CHAT.node; .memberOnly()
this.disableOnLock = false; .build();
senderMustBePlayer = true;
senderMustBeMember = true;
senderMustBeModerator = false;
senderMustBeAdmin = false;
} }
@Override @Override
@@ -30,15 +24,16 @@ public class CmdToggleAllianceChat extends FCommand {
} }
@Override @Override
public void perform() { public void perform(CommandContext context) {
if (!Conf.factionOnlyChat) { if (!Conf.factionOnlyChat) {
msg(TL.COMMAND_CHAT_DISABLED.toString()); context.msg(TL.COMMAND_CHAT_DISABLED.toString());
return; return;
} }
boolean ignoring = fme.isIgnoreAllianceChat(); boolean ignoring = context.fPlayer.isIgnoreAllianceChat();
msg(ignoring ? TL.COMMAND_TOGGLEALLIANCECHAT_UNIGNORE : TL.COMMAND_TOGGLEALLIANCECHAT_IGNORE); context.msg(ignoring ? TL.COMMAND_TOGGLEALLIANCECHAT_UNIGNORE : TL.COMMAND_TOGGLEALLIANCECHAT_IGNORE);
fme.setIgnoreAllianceChat(!ignoring); context.fPlayer.setIgnoreAllianceChat(!ignoring);
} }
} }

View File

@@ -16,24 +16,16 @@ public class CmdTop extends FCommand {
super(); super();
this.aliases.add("top"); this.aliases.add("top");
this.aliases.add("t"); this.aliases.add("t");
//this.requiredArgs.add("");
this.requiredArgs.add("criteria"); this.requiredArgs.add("criteria");
this.optionalArgs.put("page", "1"); this.optionalArgs.put("page", "1");
this.permission = Permission.TOP.node; this.requirements = new CommandRequirements.Builder(Permission.TOP)
this.disableOnLock = false; .build();
senderMustBePlayer = false;
senderMustBeMember = false;
senderMustBeModerator = false;
senderMustBeAdmin = false;
} }
@Override @Override
public void perform() { public void perform(CommandContext context) {
// Can sort by: money, members, online, allies, enemies, power, land. // Can sort by: money, members, online, allies, enemies, power, land.
// Get all Factions and remove non player ones. // Get all Factions and remove non player ones.
ArrayList<Faction> factionList = Factions.getInstance().getAllFactions(); ArrayList<Faction> factionList = Factions.getInstance().getAllFactions();
@@ -41,7 +33,7 @@ public class CmdTop extends FCommand {
factionList.remove(Factions.getInstance().getSafeZone()); factionList.remove(Factions.getInstance().getSafeZone());
factionList.remove(Factions.getInstance().getWarZone()); factionList.remove(Factions.getInstance().getWarZone());
String criteria = argAsString(0); String criteria = context.argAsString(0);
// TODO: Better way to sort? // TODO: Better way to sort?
if (criteria.equalsIgnoreCase("members")) { if (criteria.equalsIgnoreCase("members")) {
@@ -119,14 +111,13 @@ public class CmdTop extends FCommand {
return 0; return 0;
}); });
} else { } else {
msg(TL.COMMAND_TOP_INVALID, criteria); context.msg(TL.COMMAND_TOP_INVALID, criteria);
return;
} }
ArrayList<String> lines = new ArrayList<>(); ArrayList<String> lines = new ArrayList<>();
final int pageheight = 9; final int pageheight = 9;
int pagenumber = this.argAsInt(1, 1); int pagenumber = context.argAsInt(1, 1);
int pagecount = (factionList.size() / pageheight) + 1; int pagecount = (factionList.size() / pageheight) + 1;
if (pagenumber > pagecount) { if (pagenumber > pagecount) {
pagenumber = pagecount; pagenumber = pagecount;
@@ -144,12 +135,12 @@ public class CmdTop extends FCommand {
int rank = 1; int rank = 1;
for (Faction faction : factionList.subList(start, end)) { for (Faction faction : factionList.subList(start, end)) {
// Get the relation color if player is executing this. // Get the relation color if player is executing this.
String fac = sender instanceof Player ? faction.getRelationTo(fme).getColor() + faction.getTag() : faction.getTag(); String fac = context.sender instanceof Player ? faction.getRelationTo(context.fPlayer).getColor() + faction.getTag() : faction.getTag();
lines.add(TL.COMMAND_TOP_LINE.format(rank, fac, getValue(faction, criteria))); lines.add(TL.COMMAND_TOP_LINE.format(rank, fac, getValue(faction, criteria)));
rank++; rank++;
} }
sendMessage(lines); context.sendMessage(lines);
} }
private String getValue(Faction faction, String criteria) { private String getValue(Faction faction, String criteria) {

View File

@@ -1,39 +1,39 @@
package com.massivecraft.factions.cmd; package com.massivecraft.factions.cmd;
import com.massivecraft.factions.P; import com.massivecraft.factions.FactionsPlugin;
import com.massivecraft.factions.listeners.FactionsBlockListener; import com.massivecraft.factions.listeners.FactionsBlockListener;
import com.massivecraft.factions.listeners.FactionsPlayerListener;
import com.massivecraft.factions.struct.Permission; import com.massivecraft.factions.struct.Permission;
import com.massivecraft.factions.util.WarmUpUtil; import com.massivecraft.factions.util.WarmUpUtil;
import com.massivecraft.factions.zcore.util.TL; import com.massivecraft.factions.zcore.util.TL;
public class CmdTpBanner extends FCommand { public class CmdTpBanner extends FCommand {
public CmdTpBanner() { public CmdTpBanner() {
super(); super();
this.aliases.add("tpbanner"); this.aliases.add("tpbanner");
this.permission = Permission.TPBANNER.node; this.requirements = new CommandRequirements.Builder(Permission.TPBANNER)
this.disableOnLock = true; .playerOnly()
.memberOnly()
senderMustBePlayer = true; .build();
senderMustBeMember = true;
senderMustBeModerator = false;
senderMustBeColeader = false;
senderMustBeAdmin = false;
} }
@Override @Override
public void perform() { public void perform(CommandContext context) {
if (!P.p.getConfig().getBoolean("fbanners.Enabled")) { if (!FactionsPlugin.getInstance().getConfig().getBoolean("fbanners.Enabled")) {
return; return;
} }
if (FactionsBlockListener.bannerLocations.containsKey(fme.getTag())) { final FactionsPlayerListener fpl = new FactionsPlayerListener();
fme.msg(TL.COMMAND_TPBANNER_SUCCESS);
this.doWarmUp(WarmUpUtil.Warmup.BANNER, TL.WARMUPS_NOTIFY_TELEPORT, "Banner", () -> me.teleport(FactionsBlockListener.bannerLocations.get(fme.getTag())), this.p.getConfig().getLong("warmups.f-banner", 0)); if (FactionsBlockListener.bannerLocations.containsKey(context.fPlayer.getTag())) {
context.msg(TL.COMMAND_TPBANNER_SUCCESS);
context.doWarmUp(WarmUpUtil.Warmup.BANNER, TL.WARMUPS_NOTIFY_TELEPORT, "Banner", () -> {
context.player.teleport(FactionsBlockListener.bannerLocations.get(context.fPlayer.getTag()));
}, FactionsPlugin.getInstance().getConfig().getLong("warmups.f-banner", 0));
} else { } else {
fme.msg(TL.COMMAND_TPBANNER_NOTSET); context.msg(TL.COMMAND_TPBANNER_NOTSET);
} }
} }

View File

@@ -2,7 +2,6 @@ package com.massivecraft.factions.cmd;
import com.massivecraft.factions.FPlayer; import com.massivecraft.factions.FPlayer;
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.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;
@@ -12,44 +11,40 @@ public class CmdUnban extends FCommand {
public CmdUnban() { public CmdUnban() {
super(); super();
this.aliases.add("unban"); this.aliases.add("unban");
this.requiredArgs.add("target"); this.requiredArgs.add("target");
this.permission = Permission.BAN.node; this.requirements = new CommandRequirements.Builder(Permission.BAN)
this.disableOnLock = true; .playerOnly()
.memberOnly()
senderMustBePlayer = true; .withAction(PermissableAction.BAN)
senderMustBeMember = false; .build();
senderMustBeModerator = false;
senderMustBeAdmin = false;
} }
@Override @Override
public void perform() { public void perform(CommandContext context) {
if (!fme.isAdminBypassing()) {
Access access = myFaction.getAccess(fme, PermissableAction.BAN);
if (access != Access.ALLOW && fme.getRole() != Role.LEADER && !Permission.BAN.has(sender, true)) {
fme.msg(TL.GENERIC_FPERM_NOPERMISSION, "manage bans");
return;
}
}
// Good on permission checks. Now lets just ban the player. // Good on permission checks. Now lets just ban the player.
FPlayer target = argAsFPlayer(0); FPlayer target = context.argAsFPlayer(0);
if (target == null) { if (target == null) {
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 (!myFaction.isBanned(target)) { if (target.getFaction() != context.fPlayer.getFaction()) {
fme.msg(TL.COMMAND_UNBAN_NOTBANNED, target.getName()); if (target.getFaction().getAccess(context.fPlayer, PermissableAction.BAN) != Access.ALLOW) {
if (!context.fPlayer.isAdminBypassing()) {
context.fPlayer.msg(TL.COMMAND_UNBAN_TARGET_IN_OTHER_FACTION, target.getName());
}
}
}
if (!context.faction.isBanned(target)) {
context.msg(TL.COMMAND_UNBAN_NOTBANNED, target.getName());
return; return;
} }
myFaction.unban(target); context.faction.unban(target);
myFaction.msg(TL.COMMAND_UNBAN_UNBANNED, fme.getName(), target.getName()); context.msg(TL.COMMAND_UNBAN_UNBANNED, context.fPlayer.getName(), target.getName());
target.msg(TL.COMMAND_UNBAN_TARGET, myFaction.getTag(target)); target.msg(TL.COMMAND_UNBAN_TARGET, context.faction.getTag(target));
} }
@Override @Override

View File

@@ -1,6 +1,6 @@
package com.massivecraft.factions.cmd; package com.massivecraft.factions.cmd;
import com.massivecraft.factions.P; import com.massivecraft.factions.FactionsPlugin;
import com.massivecraft.factions.struct.Permission; import com.massivecraft.factions.struct.Permission;
import com.massivecraft.factions.zcore.fupgrades.FUpgradesGUI; import com.massivecraft.factions.zcore.fupgrades.FUpgradesGUI;
import com.massivecraft.factions.zcore.util.TL; import com.massivecraft.factions.zcore.util.TL;
@@ -11,26 +11,20 @@ public class CmdUpgrades extends FCommand {
this.aliases.add("upgrades"); this.aliases.add("upgrades");
this.aliases.add("upgrade"); this.aliases.add("upgrade");
//this.requiredArgs.add(""); this.requirements = new CommandRequirements.Builder(Permission.UPGRADES)
this.optionalArgs.put("mobs/crops/exp/power", ""); .playerOnly()
.memberOnly()
this.permission = Permission.UPGRADES.node; .build();
this.disableOnLock = true;
senderMustBePlayer = true;
senderMustBeMember = true;
senderMustBeModerator = false;
senderMustBeAdmin = false;
} }
@Override @Override
public void perform() { public void perform(CommandContext context) {
if (!P.p.getConfig().getBoolean("fupgrades.Enabled")) { if (!FactionsPlugin.getInstance().getConfig().getBoolean("fupgrades.Enabled")) {
fme.sendMessage("This command is disabled!"); context.fPlayer.sendMessage("This command is disabled!");
return; return;
} }
new FUpgradesGUI().openMainMenu(fme); new FUpgradesGUI().openMainMenu(context.fPlayer);
} }
@Override @Override

View File

@@ -2,9 +2,8 @@ package com.massivecraft.factions.cmd;
import com.massivecraft.factions.Board; import com.massivecraft.factions.Board;
import com.massivecraft.factions.FLocation; import com.massivecraft.factions.FLocation;
import com.massivecraft.factions.P; import com.massivecraft.factions.FactionsPlugin;
import com.massivecraft.factions.struct.Permission; import com.massivecraft.factions.struct.Permission;
import com.massivecraft.factions.zcore.fperms.Access;
import com.massivecraft.factions.zcore.fperms.PermissableAction; import com.massivecraft.factions.zcore.fperms.PermissableAction;
import com.massivecraft.factions.zcore.util.TL; import com.massivecraft.factions.zcore.util.TL;
import org.bukkit.Location; import org.bukkit.Location;
@@ -17,57 +16,48 @@ public class CmdVault extends FCommand {
public CmdVault() { public CmdVault() {
this.aliases.add("vault"); this.aliases.add("vault");
//this.requiredArgs.add(""); this.requirements = new CommandRequirements.Builder(Permission.VAULT)
.playerOnly()
.memberOnly()
this.permission = Permission.VAULT.node; .withAction(PermissableAction.VAULT)
this.disableOnLock = false; .build();
senderMustBePlayer = true;
senderMustBeMember = true;
senderMustBeModerator = false;
senderMustBeAdmin = false;
} }
@Override @Override
public void perform() { public void perform(CommandContext context) {
if (!P.p.getConfig().getBoolean("fvault.Enabled")) { if (!FactionsPlugin.getInstance().getConfig().getBoolean("fvault.Enabled")) {
fme.sendMessage("This command is disabled!"); context.fPlayer.sendMessage("This command is disabled!");
return;
}
Access access = fme.getFaction().getAccess(fme, PermissableAction.VAULT);
if (access.equals(Access.DENY)) {
fme.msg(TL.GENERIC_NOPERMISSION, "vault");
return; return;
} }
if (fme.isInVault()) { if (context.fPlayer.isInVault()) {
me.closeInventory(); context.player.closeInventory();
return; return;
} }
fme.setInVault(true);
Location vaultLocation = fme.getFaction().getVault(); context.fPlayer.setInVault(true);
Location vaultLocation = context.faction.getVault();
if (vaultLocation == null) { if (vaultLocation == null) {
fme.msg(TL.COMMAND_VAULT_INVALID); context.msg(TL.COMMAND_VAULT_INVALID);
return; return;
} }
FLocation vaultFLocation = new FLocation(vaultLocation); FLocation vaultFLocation = new FLocation(vaultLocation);
if (Board.getInstance().getFactionAt(vaultFLocation) != fme.getFaction()) { if (Board.getInstance().getFactionAt(vaultFLocation) != context.faction) {
fme.getFaction().setVault(null); context.faction.setVault(null);
fme.msg(TL.COMMAND_VAULT_INVALID); context.msg(TL.COMMAND_VAULT_INVALID);
return; return;
} }
if (vaultLocation.getBlock().getType() != Material.CHEST) { if (vaultLocation.getBlock().getType() != Material.CHEST) {
fme.getFaction().setVault(null); context.faction.setVault(null);
fme.msg(TL.COMMAND_VAULT_INVALID); context.msg(TL.COMMAND_VAULT_INVALID);
return; return;
} }
Chest chest = (Chest) vaultLocation.getBlock().getState(); Chest chest = (Chest) vaultLocation.getBlock().getState();
Inventory chestInv = chest.getBlockInventory(); Inventory chestInv = chest.getBlockInventory();
fme.msg(TL.COMMAND_VAULT_OPENING); context.msg(TL.COMMAND_VAULT_OPENING);
me.openInventory(chestInv); context.player.openInventory(chestInv);
} }
@@ -76,4 +66,5 @@ public class CmdVault extends FCommand {
public TL getUsageTranslation() { public TL getUsageTranslation() {
return TL.COMMAND_VAULT_DESCRIPTION; return TL.COMMAND_VAULT_DESCRIPTION;
} }
}
}

View File

@@ -1,6 +1,6 @@
package com.massivecraft.factions.cmd; package com.massivecraft.factions.cmd;
import com.massivecraft.factions.P; import com.massivecraft.factions.FactionsPlugin;
import com.massivecraft.factions.struct.Permission; import com.massivecraft.factions.struct.Permission;
import com.massivecraft.factions.zcore.util.TL; import com.massivecraft.factions.zcore.util.TL;
@@ -11,26 +11,18 @@ public class CmdVersion extends FCommand {
this.aliases.add("version"); this.aliases.add("version");
this.aliases.add("ver"); this.aliases.add("ver");
//this.requiredArgs.add(""); this.requirements = new CommandRequirements.Builder(Permission.VERSION)
//this.optionalArgs.put("", ""); .build();
this.permission = Permission.VERSION.node;
this.disableOnLock = false;
senderMustBePlayer = false;
senderMustBeMember = false;
senderMustBeModerator = false;
senderMustBeAdmin = false;
} }
@Override @Override
public void perform() { public void perform(CommandContext context) {
msg(TL.COMMAND_VERSION_NAME); // Did this so people can differentiate between P and FactionsUUID (( Requested Feature )) context.msg(TL.COMMAND_VERSION_NAME); // Did this so people can differentiate between SavageFactions and FactionsUUID (( Requested Feature ))
msg(TL.COMMAND_VERSION_VERSION, P.p.getDescription().getFullName()); context.msg(TL.COMMAND_VERSION_VERSION, FactionsPlugin.getInstance().getDescription().getFullName());
} }
@Override @Override
public TL getUsageTranslation() { public TL getUsageTranslation() {
return TL.COMMAND_VERSION_DESCRIPTION; return TL.COMMAND_VERSION_DESCRIPTION;
} }
} }

Some files were not shown because too many files have changed in this diff Show More