Compare commits

...

85 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
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
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
74 changed files with 2572 additions and 671 deletions

30
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.9.0-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>
@@ -178,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>
@@ -369,9 +381,20 @@
<artifactId>worldguardwrapper</artifactId> <artifactId>worldguardwrapper</artifactId>
<version>1.1.6-SNAPSHOT</version> <version>1.1.6-SNAPSHOT</version>
</dependency> </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>
@@ -392,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>

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;

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();

21
src/main/java/com/massivecraft/factions/FactionsPlugin.java Normal file → Executable file
View File

@@ -10,13 +10,15 @@ import com.massivecraft.factions.cmd.FCmdRoot;
import com.massivecraft.factions.cmd.FCommand; 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.Relation;
@@ -87,6 +89,7 @@ public class FactionsPlugin 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 FactionsPlugin() { public FactionsPlugin() {
@@ -256,6 +259,10 @@ public class FactionsPlugin 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);
@@ -267,13 +274,10 @@ public class FactionsPlugin 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)
@@ -418,7 +422,6 @@ public class FactionsPlugin 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();
} }
@@ -426,7 +429,7 @@ public class FactionsPlugin extends MPlugin {
this.getServer().getScheduler().cancelTask(AutoLeaveTask); this.getServer().getScheduler().cancelTask(AutoLeaveTask);
AutoLeaveTask = null; AutoLeaveTask = null;
} }
DiscordListener.saveGuilds();
super.onDisable(); super.onDisable();
} }

View File

@@ -29,7 +29,7 @@ public class CmdAutoHelp extends FCommand {
for (FCommand scmd : pcmd.subCommands) { for (FCommand scmd : pcmd.subCommands) {
if (scmd.visibility == CommandVisibility.VISIBLE) { if (scmd.visibility == CommandVisibility.VISIBLE) {
lines.add(scmd.getUseageTemplate(context, true)); lines.add(scmd.getUsageTemplate(context, true));
} }
// TODO deal with other visibilities // TODO deal with other visibilities
} }

View File

@@ -3,7 +3,6 @@ package com.massivecraft.factions.cmd;
import com.massivecraft.factions.FPlayer; import com.massivecraft.factions.FPlayer;
import com.massivecraft.factions.FactionsPlugin; 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,15 +14,9 @@ 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.requirements = new CommandRequirements.Builder(Permission.BANNER)
.playerOnly()
.memberOnly()
.build();
} }
@Override @Override
@@ -32,45 +25,39 @@ public class CmdBanner extends FCommand {
context.msg(TL.COMMAND_BANNER_DISABLED); context.msg(TL.COMMAND_BANNER_DISABLED);
return; return;
} }
if (context.faction.getBanner() == null) {
context.msg(TL.COMMAND_BANNER_NOBANNER);
return;
}
if (!context.fPlayer.hasMoney(FactionsPlugin.getInstance().getConfig().getInt("fbanners.Banner-Cost", 5000))) { if (!context.fPlayer.hasMoney(FactionsPlugin.getInstance().getConfig().getInt("fbanners.Banner-Cost", 5000))) {
context.msg(TL.COMMAND_BANNER_NOTENOUGHMONEY); context.msg(TL.COMMAND_BANNER_NOTENOUGHMONEY);
return; return;
} }
takeMoney(context.fPlayer, FactionsPlugin.getInstance().getConfig().getInt("fbanners.Banner-Cost", 5000)); 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 = FactionsPlugin.getInstance().createItem(Material.BANNER, 1, (short) 1, FactionsPlugin.getInstance().getConfig().getString("fbanners.Item.Name"), FactionsPlugin.getInstance().getConfig().getStringList("fbanners.Item.Lore"));
//BannerMeta bannerMeta = (BannerMeta) warBanner.getItemMeta();
ItemStack warBanner = context.fPlayer.getFaction().getBanner(); ItemStack warBanner = context.fPlayer.getFaction().getBanner();
if (warBanner != null) {
ItemMeta warmeta = warBanner.getItemMeta(); ItemMeta warmeta = warBanner.getItemMeta();
warmeta.setDisplayName(FactionsPlugin.getInstance().color(FactionsPlugin.getInstance().getConfig().getString("fbanners.Item.Name"))); warmeta.setDisplayName(FactionsPlugin.getInstance().color(FactionsPlugin.getInstance().getConfig().getString("fbanners.Item.Name")));
warmeta.setLore(FactionsPlugin.getInstance().colorList(FactionsPlugin.getInstance().getConfig().getStringList("fbanners.Item.Lore"))); warmeta.setLore(FactionsPlugin.getInstance().colorList(FactionsPlugin.getInstance().getConfig().getStringList("fbanners.Item.Lore")));
warBanner.setItemMeta(warmeta); warBanner.setItemMeta(warmeta);
} else {
warBanner = FactionsPlugin.getInstance().createItem(XMaterial.BLACK_BANNER.parseMaterial(), 1, (short) 1, FactionsPlugin.getInstance().getConfig().getString("fbanners.Item.Name"), FactionsPlugin.getInstance().getConfig().getStringList("fbanners.Item.Lore"));
}
context.msg(TL.COMMAND_BANNER_SUCCESS); context.msg(TL.COMMAND_BANNER_SUCCESS);
warBanner.setAmount(1); warBanner.setAmount(1);
context.player.getInventory().addItem(warBanner); context.player.getInventory().addItem(warBanner);
} }
public boolean hasMoney(FPlayer fme, int amt) { public boolean hasMoney(FPlayer fme, int amt) {
Economy econ = FactionsPlugin.getInstance().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); fme.msg(TL.COMMAND_BANNER_NOTENOUGHMONEY);
return false; 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 = FactionsPlugin.getInstance().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 + ""));
} }
} }
@@ -78,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;
@@ -89,24 +76,23 @@ 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(); amt -= items[i].getAmount();
items[i] = null; items[i] = null;
} }
} }
}
inventory.setContents(items); inventory.setContents(items);
} }
@@ -114,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

@@ -90,7 +90,7 @@ public class CmdCreate extends FCommand {
follower.msg(TL.COMMAND_CREATE_CREATED, context.fPlayer.getName(), faction.getTag(follower)); follower.msg(TL.COMMAND_CREATE_CREATED, context.fPlayer.getName(), faction.getTag(follower));
} }
} }
context.msg(TL.COMMAND_CREATE_YOUSHOULD, FactionsPlugin.getInstance().cmdBase.cmdDescription.getUseageTemplate(context)); 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)
FactionsPlugin.getInstance().log(context.fPlayer.getName() + TL.COMMAND_CREATE_CREATEDLOG.toString() + tag); FactionsPlugin.getInstance().log(context.fPlayer.getName() + TL.COMMAND_CREATE_CREATEDLOG.toString() + tag);

View File

@@ -64,7 +64,7 @@ public class CmdDeinvite extends FCommand {
if (you.getFaction() == context.faction) { if (you.getFaction() == context.faction) {
context.msg(TL.COMMAND_DEINVITE_ALREADYMEMBER, you.getName(), context.faction.getTag()); context.msg(TL.COMMAND_DEINVITE_ALREADYMEMBER, you.getName(), context.faction.getTag());
context.msg(TL.COMMAND_DEINVITE_MIGHTWANT, FactionsPlugin.getInstance().cmdBase.cmdKick.getUseageTemplate(context)); context.msg(TL.COMMAND_DEINVITE_MIGHTWANT, FactionsPlugin.getInstance().cmdBase.cmdKick.getUsageTemplate(context));
return; return;
} }

View File

@@ -75,28 +75,28 @@ public class CmdHelp extends FCommand {
ArrayList<String> pageLines; ArrayList<String> pageLines;
pageLines = new ArrayList<>(); pageLines = new ArrayList<>();
pageLines.add(FactionsPlugin.getInstance().cmdBase.cmdHelp.getUseageTemplate(context)); pageLines.add(FactionsPlugin.getInstance().cmdBase.cmdHelp.getUsageTemplate(context));
pageLines.add(FactionsPlugin.getInstance().cmdBase.cmdList.getUseageTemplate(context)); pageLines.add(FactionsPlugin.getInstance().cmdBase.cmdList.getUsageTemplate(context));
pageLines.add(FactionsPlugin.getInstance().cmdBase.cmdShow.getUseageTemplate(context)); pageLines.add(FactionsPlugin.getInstance().cmdBase.cmdShow.getUsageTemplate(context));
pageLines.add(FactionsPlugin.getInstance().cmdBase.cmdPower.getUseageTemplate(context)); pageLines.add(FactionsPlugin.getInstance().cmdBase.cmdPower.getUsageTemplate(context));
pageLines.add(FactionsPlugin.getInstance().cmdBase.cmdJoin.getUseageTemplate(context)); pageLines.add(FactionsPlugin.getInstance().cmdBase.cmdJoin.getUsageTemplate(context));
pageLines.add(FactionsPlugin.getInstance().cmdBase.cmdLeave.getUseageTemplate(context)); pageLines.add(FactionsPlugin.getInstance().cmdBase.cmdLeave.getUsageTemplate(context));
pageLines.add(FactionsPlugin.getInstance().cmdBase.cmdChat.getUseageTemplate(context)); pageLines.add(FactionsPlugin.getInstance().cmdBase.cmdChat.getUsageTemplate(context));
pageLines.add(FactionsPlugin.getInstance().cmdBase.cmdToggleAllianceChat.getUseageTemplate(context)); pageLines.add(FactionsPlugin.getInstance().cmdBase.cmdToggleAllianceChat.getUsageTemplate(context));
pageLines.add(FactionsPlugin.getInstance().cmdBase.cmdHome.getUseageTemplate(context)); pageLines.add(FactionsPlugin.getInstance().cmdBase.cmdHome.getUsageTemplate(context));
pageLines.add(FactionsPlugin.getInstance().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(FactionsPlugin.getInstance().cmdBase.cmdCreate.getUseageTemplate(context)); pageLines.add(FactionsPlugin.getInstance().cmdBase.cmdCreate.getUsageTemplate(context));
pageLines.add(FactionsPlugin.getInstance().cmdBase.cmdDescription.getUseageTemplate(context)); pageLines.add(FactionsPlugin.getInstance().cmdBase.cmdDescription.getUsageTemplate(context));
pageLines.add(FactionsPlugin.getInstance().cmdBase.cmdTag.getUseageTemplate(context)); pageLines.add(FactionsPlugin.getInstance().cmdBase.cmdTag.getUsageTemplate(context));
pageLines.add(FactionsPlugin.getInstance().txt.parse(TL.COMMAND_HELP_INVITATIONS.toString())); pageLines.add(FactionsPlugin.getInstance().txt.parse(TL.COMMAND_HELP_INVITATIONS.toString()));
pageLines.add(FactionsPlugin.getInstance().cmdBase.cmdOpen.getUseageTemplate(context)); pageLines.add(FactionsPlugin.getInstance().cmdBase.cmdOpen.getUsageTemplate(context));
pageLines.add(FactionsPlugin.getInstance().cmdBase.cmdInvite.getUseageTemplate(context)); pageLines.add(FactionsPlugin.getInstance().cmdBase.cmdInvite.getUsageTemplate(context));
pageLines.add(FactionsPlugin.getInstance().cmdBase.cmdDeinvite.getUseageTemplate(context)); pageLines.add(FactionsPlugin.getInstance().cmdBase.cmdDeinvite.getUsageTemplate(context));
pageLines.add(FactionsPlugin.getInstance().txt.parse(TL.COMMAND_HELP_HOME.toString())); pageLines.add(FactionsPlugin.getInstance().txt.parse(TL.COMMAND_HELP_HOME.toString()));
pageLines.add(FactionsPlugin.getInstance().cmdBase.cmdSethome.getUseageTemplate(context)); 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) {
@@ -106,7 +106,7 @@ public class CmdHelp extends FCommand {
pageLines.add(FactionsPlugin.getInstance().txt.parse(TL.COMMAND_HELP_BANK_2.toString())); pageLines.add(FactionsPlugin.getInstance().txt.parse(TL.COMMAND_HELP_BANK_2.toString()));
pageLines.add(FactionsPlugin.getInstance().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(FactionsPlugin.getInstance().cmdBase.cmdMoney.getUseageTemplate(context)); pageLines.add(FactionsPlugin.getInstance().cmdBase.cmdMoney.getUsageTemplate(context));
pageLines.add(""); pageLines.add("");
pageLines.add(""); pageLines.add("");
pageLines.add(""); pageLines.add("");
@@ -114,36 +114,36 @@ public class CmdHelp extends FCommand {
} }
pageLines = new ArrayList<>(); pageLines = new ArrayList<>();
pageLines.add(FactionsPlugin.getInstance().cmdBase.cmdClaim.getUseageTemplate(context)); pageLines.add(FactionsPlugin.getInstance().cmdBase.cmdClaim.getUsageTemplate(context));
pageLines.add(FactionsPlugin.getInstance().cmdBase.cmdAutoClaim.getUseageTemplate(context)); pageLines.add(FactionsPlugin.getInstance().cmdBase.cmdAutoClaim.getUsageTemplate(context));
pageLines.add(FactionsPlugin.getInstance().cmdBase.cmdUnclaim.getUseageTemplate(context)); pageLines.add(FactionsPlugin.getInstance().cmdBase.cmdUnclaim.getUsageTemplate(context));
pageLines.add(FactionsPlugin.getInstance().cmdBase.cmdUnclaimall.getUseageTemplate(context)); pageLines.add(FactionsPlugin.getInstance().cmdBase.cmdUnclaimall.getUsageTemplate(context));
pageLines.add(FactionsPlugin.getInstance().cmdBase.cmdKick.getUseageTemplate(context)); pageLines.add(FactionsPlugin.getInstance().cmdBase.cmdKick.getUsageTemplate(context));
pageLines.add(FactionsPlugin.getInstance().cmdBase.cmdMod.getUseageTemplate(context)); pageLines.add(FactionsPlugin.getInstance().cmdBase.cmdMod.getUsageTemplate(context));
pageLines.add(FactionsPlugin.getInstance().cmdBase.cmdAdmin.getUseageTemplate(context)); pageLines.add(FactionsPlugin.getInstance().cmdBase.cmdAdmin.getUsageTemplate(context));
pageLines.add(FactionsPlugin.getInstance().cmdBase.cmdTitle.getUseageTemplate(context)); pageLines.add(FactionsPlugin.getInstance().cmdBase.cmdTitle.getUsageTemplate(context));
pageLines.add(FactionsPlugin.getInstance().cmdBase.cmdSB.getUseageTemplate(context)); pageLines.add(FactionsPlugin.getInstance().cmdBase.cmdSB.getUsageTemplate(context));
pageLines.add(FactionsPlugin.getInstance().cmdBase.cmdSeeChunk.getUseageTemplate(context)); pageLines.add(FactionsPlugin.getInstance().cmdBase.cmdSeeChunk.getUsageTemplate(context));
pageLines.add(FactionsPlugin.getInstance().cmdBase.cmdStatus.getUseageTemplate(context)); pageLines.add(FactionsPlugin.getInstance().cmdBase.cmdStatus.getUsageTemplate(context));
pageLines.add(FactionsPlugin.getInstance().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(FactionsPlugin.getInstance().cmdBase.cmdMap.getUseageTemplate(context)); pageLines.add(FactionsPlugin.getInstance().cmdBase.cmdMap.getUsageTemplate(context));
pageLines.add(FactionsPlugin.getInstance().cmdBase.cmdBoom.getUseageTemplate(context)); pageLines.add(FactionsPlugin.getInstance().cmdBase.cmdBoom.getUsageTemplate(context));
pageLines.add(FactionsPlugin.getInstance().cmdBase.cmdOwner.getUseageTemplate(context)); pageLines.add(FactionsPlugin.getInstance().cmdBase.cmdOwner.getUsageTemplate(context));
pageLines.add(FactionsPlugin.getInstance().cmdBase.cmdOwnerList.getUseageTemplate(context)); pageLines.add(FactionsPlugin.getInstance().cmdBase.cmdOwnerList.getUsageTemplate(context));
pageLines.add(FactionsPlugin.getInstance().txt.parse(TL.COMMAND_HELP_OWNERSHIP_1.toString())); pageLines.add(FactionsPlugin.getInstance().txt.parse(TL.COMMAND_HELP_OWNERSHIP_1.toString()));
pageLines.add(FactionsPlugin.getInstance().txt.parse(TL.COMMAND_HELP_OWNERSHIP_2.toString())); pageLines.add(FactionsPlugin.getInstance().txt.parse(TL.COMMAND_HELP_OWNERSHIP_2.toString()));
pageLines.add(FactionsPlugin.getInstance().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(FactionsPlugin.getInstance().cmdBase.cmdDisband.getUseageTemplate(context)); pageLines.add(FactionsPlugin.getInstance().cmdBase.cmdDisband.getUsageTemplate(context));
pageLines.add(""); pageLines.add("");
pageLines.add(FactionsPlugin.getInstance().cmdBase.cmdRelationAlly.getUseageTemplate(context)); pageLines.add(FactionsPlugin.getInstance().cmdBase.cmdRelationAlly.getUsageTemplate(context));
pageLines.add(FactionsPlugin.getInstance().cmdBase.cmdRelationNeutral.getUseageTemplate(context)); pageLines.add(FactionsPlugin.getInstance().cmdBase.cmdRelationNeutral.getUsageTemplate(context));
pageLines.add(FactionsPlugin.getInstance().cmdBase.cmdRelationEnemy.getUseageTemplate(context)); pageLines.add(FactionsPlugin.getInstance().cmdBase.cmdRelationEnemy.getUsageTemplate(context));
pageLines.add(FactionsPlugin.getInstance().txt.parse(TL.COMMAND_HELP_RELATIONS_1.toString())); pageLines.add(FactionsPlugin.getInstance().txt.parse(TL.COMMAND_HELP_RELATIONS_1.toString()));
pageLines.add(FactionsPlugin.getInstance().txt.parse(TL.COMMAND_HELP_RELATIONS_2.toString())); pageLines.add(FactionsPlugin.getInstance().txt.parse(TL.COMMAND_HELP_RELATIONS_2.toString()));
pageLines.add(FactionsPlugin.getInstance().txt.parse(TL.COMMAND_HELP_RELATIONS_3.toString())); pageLines.add(FactionsPlugin.getInstance().txt.parse(TL.COMMAND_HELP_RELATIONS_3.toString()));
@@ -176,32 +176,32 @@ public class CmdHelp extends FCommand {
pageLines = new ArrayList<>(); pageLines = new ArrayList<>();
pageLines.add(TL.COMMAND_HELP_MOAR_1.toString()); pageLines.add(TL.COMMAND_HELP_MOAR_1.toString());
pageLines.add(FactionsPlugin.getInstance().cmdBase.cmdBypass.getUseageTemplate(context)); pageLines.add(FactionsPlugin.getInstance().cmdBase.cmdBypass.getUsageTemplate(context));
pageLines.add(FactionsPlugin.getInstance().txt.parse(TL.COMMAND_HELP_ADMIN_1.toString())); pageLines.add(FactionsPlugin.getInstance().txt.parse(TL.COMMAND_HELP_ADMIN_1.toString()));
pageLines.add(FactionsPlugin.getInstance().txt.parse(TL.COMMAND_HELP_ADMIN_2.toString())); pageLines.add(FactionsPlugin.getInstance().txt.parse(TL.COMMAND_HELP_ADMIN_2.toString()));
pageLines.add(FactionsPlugin.getInstance().txt.parse(TL.COMMAND_HELP_ADMIN_3.toString())); pageLines.add(FactionsPlugin.getInstance().txt.parse(TL.COMMAND_HELP_ADMIN_3.toString()));
pageLines.add(FactionsPlugin.getInstance().cmdBase.cmdSafeunclaimall.getUseageTemplate(context)); pageLines.add(FactionsPlugin.getInstance().cmdBase.cmdSafeunclaimall.getUsageTemplate(context));
pageLines.add(FactionsPlugin.getInstance().cmdBase.cmdWarunclaimall.getUseageTemplate(context)); pageLines.add(FactionsPlugin.getInstance().cmdBase.cmdWarunclaimall.getUsageTemplate(context));
//TODO:TL //TODO:TL
pageLines.add(FactionsPlugin.getInstance().txt.parse("<i>Note: " + FactionsPlugin.getInstance().cmdBase.cmdUnclaim.getUseageTemplate(context) + FactionsPlugin.getInstance().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(FactionsPlugin.getInstance().cmdBase.cmdPeaceful.getUseageTemplate(context)); pageLines.add(FactionsPlugin.getInstance().cmdBase.cmdPeaceful.getUsageTemplate(context));
helpPages.add(pageLines); helpPages.add(pageLines);
pageLines = new ArrayList<>(); pageLines = new ArrayList<>();
pageLines.add(FactionsPlugin.getInstance().txt.parse(TL.COMMAND_HELP_MOAR_2.toString())); pageLines.add(FactionsPlugin.getInstance().txt.parse(TL.COMMAND_HELP_MOAR_2.toString()));
pageLines.add(FactionsPlugin.getInstance().cmdBase.cmdChatSpy.getUseageTemplate(context)); pageLines.add(FactionsPlugin.getInstance().cmdBase.cmdChatSpy.getUsageTemplate(context));
pageLines.add(FactionsPlugin.getInstance().cmdBase.cmdPermanent.getUseageTemplate(context)); pageLines.add(FactionsPlugin.getInstance().cmdBase.cmdPermanent.getUsageTemplate(context));
pageLines.add(FactionsPlugin.getInstance().cmdBase.cmdPermanentPower.getUseageTemplate(context)); pageLines.add(FactionsPlugin.getInstance().cmdBase.cmdPermanentPower.getUsageTemplate(context));
pageLines.add(FactionsPlugin.getInstance().cmdBase.cmdPowerBoost.getUseageTemplate(context)); pageLines.add(FactionsPlugin.getInstance().cmdBase.cmdPowerBoost.getUsageTemplate(context));
pageLines.add(FactionsPlugin.getInstance().cmdBase.cmdConfig.getUseageTemplate(context)); pageLines.add(FactionsPlugin.getInstance().cmdBase.cmdConfig.getUsageTemplate(context));
helpPages.add(pageLines); helpPages.add(pageLines);
pageLines = new ArrayList<>(); pageLines = new ArrayList<>();
pageLines.add(FactionsPlugin.getInstance().txt.parse(TL.COMMAND_HELP_MOAR_3.toString())); pageLines.add(FactionsPlugin.getInstance().txt.parse(TL.COMMAND_HELP_MOAR_3.toString()));
pageLines.add(FactionsPlugin.getInstance().cmdBase.cmdLock.getUseageTemplate(context)); pageLines.add(FactionsPlugin.getInstance().cmdBase.cmdLock.getUsageTemplate(context));
pageLines.add(FactionsPlugin.getInstance().cmdBase.cmdReload.getUseageTemplate(context)); pageLines.add(FactionsPlugin.getInstance().cmdBase.cmdReload.getUsageTemplate(context));
pageLines.add(FactionsPlugin.getInstance().cmdBase.cmdSaveAll.getUseageTemplate(context)); pageLines.add(FactionsPlugin.getInstance().cmdBase.cmdSaveAll.getUsageTemplate(context));
pageLines.add(FactionsPlugin.getInstance().cmdBase.cmdVersion.getUseageTemplate(context)); pageLines.add(FactionsPlugin.getInstance().cmdBase.cmdVersion.getUsageTemplate(context));
helpPages.add(pageLines); helpPages.add(pageLines);
} }

View File

@@ -46,7 +46,7 @@ public class CmdHome extends FCommand {
if (!context.faction.hasHome()) { 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())); context.msg(TL.COMMAND_HOME_NOHOME.toString() + (context.fPlayer.getRole().value < Role.MODERATOR.value ? TL.GENERIC_ASKYOURLEADER.toString() : TL.GENERIC_YOUSHOULD.toString()));
context.sendMessage(FactionsPlugin.getInstance().cmdBase.cmdSethome.getUseageTemplate(context)); context.sendMessage(FactionsPlugin.getInstance().cmdBase.cmdSethome.getUsageTemplate(context));
return; return;
} }

View File

@@ -38,7 +38,7 @@ public class CmdInventorySee extends FCommand {
Access use = context.fPlayer.getFaction().getAccess(context.fPlayer, PermissableAction.TERRITORY); Access use = context.fPlayer.getFaction().getAccess(context.fPlayer, PermissableAction.TERRITORY);
if (use == Access.DENY || (use == Access.UNDEFINED && !context.assertMinRole(Role.MODERATOR))) { if (use == Access.DENY || (use == Access.UNDEFINED && !context.assertMinRole(Role.MODERATOR))) {
context.msg(TL.GENERIC_NOPERMISSION, "territory"); context.msg(TL.GENERIC_NOPERMISSION, "see other faction members inventories");
return; return;
} }
@@ -46,7 +46,7 @@ public class CmdInventorySee extends FCommand {
FPlayer targetInv = context.argAsFPlayer(0); FPlayer targetInv = context.argAsFPlayer(0);
if (targetInv == null || !fplayers.contains(targetInv.getPlayer())) { if (targetInv == null || !fplayers.contains(targetInv.getPlayer())) {
context.msg(TL.PLAYER_NOT_FOUND, Objects.requireNonNull(targetInv).toString()); context.msg(TL.PLAYER_NOT_FOUND, Objects.requireNonNull(targetInv.getName()));
return; return;
} }

View File

@@ -33,7 +33,7 @@ public class CmdInvite extends FCommand {
if (target.getFaction() == context.faction) { if (target.getFaction() == context.faction) {
context.msg(TL.COMMAND_INVITE_ALREADYMEMBER, target.getName(), context.faction.getTag()); context.msg(TL.COMMAND_INVITE_ALREADYMEMBER, target.getName(), context.faction.getTag());
context.msg(TL.GENERIC_YOUMAYWANT.toString() + FactionsPlugin.getInstance().cmdBase.cmdKick.getUseageTemplate(context)); context.msg(TL.GENERIC_YOUMAYWANT.toString() + FactionsPlugin.getInstance().cmdBase.cmdKick.getUsageTemplate(context));
return; return;
} }

View File

@@ -58,7 +58,7 @@ public class CmdKick extends FCommand {
if (context.fPlayer == toKick) { if (context.fPlayer == toKick) {
context.msg(TL.COMMAND_KICK_SELF); context.msg(TL.COMMAND_KICK_SELF);
context.msg(TL.GENERIC_YOUMAYWANT.toString() + FactionsPlugin.getInstance().cmdBase.cmdLeave.getUseageTemplate(context)); context.msg(TL.GENERIC_YOUMAYWANT.toString() + FactionsPlugin.getInstance().cmdBase.cmdLeave.getUsageTemplate(context));
return; return;
} }

View File

@@ -24,8 +24,10 @@ public class CmdPaypalSee extends FCommand {
return; return;
} }
if (context.args.size() == 0) { if (context.args.size() == 0) {
if (context.fPlayer.getFaction().getPaypal().isEmpty()) { if (context.fPlayer.getFaction().getPaypal() == null) {
context.msg(TL.COMMAND_PAYPAL_NOTSET); context.msg(TL.COMMAND_PAYPAL_NOTSET);
} else { } else {
context.msg(TL.PAYPALSEE_PLAYER_PAYPAL, context.fPlayer.getFaction().getPaypal()); context.msg(TL.PAYPALSEE_PLAYER_PAYPAL, context.fPlayer.getFaction().getPaypal());
@@ -34,7 +36,7 @@ public class CmdPaypalSee extends FCommand {
if (context.fPlayer.isAdminBypassing()) { if (context.fPlayer.isAdminBypassing()) {
Faction faction = context.argAsFaction(0); Faction faction = context.argAsFaction(0);
if (faction != null) { if (faction != null) {
if (faction.getPaypal().isEmpty()) { if (faction.getPaypal() == null) {
context.msg(TL.COMMAND_PAYPALSEE_FACTION_NOTSET, faction.getTag()); context.msg(TL.COMMAND_PAYPALSEE_FACTION_NOTSET, faction.getTag());
} else { } else {
context.msg(TL.COMMAND_PAYPALSEE_FACTION_PAYPAL.toString(), faction.getTag(), faction.getPaypal()); context.msg(TL.COMMAND_PAYPALSEE_FACTION_PAYPAL.toString(), faction.getTag(), faction.getPaypal());
@@ -44,7 +46,7 @@ public class CmdPaypalSee extends FCommand {
context.msg(TL.GENERIC_NOPERMISSION, "see another factions paypal."); context.msg(TL.GENERIC_NOPERMISSION, "see another factions paypal.");
} }
} else { } else {
context.msg(FactionsPlugin.getInstance().cmdBase.cmdPaypalSee.getUseageTemplate(context)); context.msg(FactionsPlugin.getInstance().cmdBase.cmdPaypalSee.getUsageTemplate(context));
} }
} }

View File

@@ -50,7 +50,7 @@ public class CmdPaypalSet extends FCommand {
context.msg(TL.GENERIC_NOPERMISSION, "set another factions paypal!"); context.msg(TL.GENERIC_NOPERMISSION, "set another factions paypal!");
} }
} else { } else {
context.msg(FactionsPlugin.getInstance().cmdBase.cmdPaypalSet.getUseageTemplate(context)); context.msg(FactionsPlugin.getInstance().cmdBase.cmdPaypalSet.getUsageTemplate(context));
} }
} }

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.FactionsPlugin; import com.massivecraft.factions.FactionsPlugin;
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;
@@ -19,6 +20,7 @@ public class CmdReload extends FCommand {
long timeInitStart = System.currentTimeMillis(); long timeInitStart = System.currentTimeMillis();
Conf.load(); Conf.load();
Conf.save(); Conf.save();
ShopConfig.loadShop();
FactionsPlugin.getInstance().reloadConfig(); FactionsPlugin.getInstance().reloadConfig();
FactionsPlugin.getInstance().loadLang(); FactionsPlugin.getInstance().loadLang();

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

@@ -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

@@ -9,57 +9,42 @@ 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.requirements = new CommandRequirements.Builder(Permission.SETWARP)
.playerOnly()
.memberOnly()
.withAction(PermissableAction.SETWARP)
.build();
} }
@Override @Override
public void perform(CommandContext context) { public void perform(CommandContext context) {
if (!(context.fPlayer.getRelationToLocation() == Relation.MEMBER)) { if (context.fPlayer.getRelationToLocation() != Relation.MEMBER) {
context.msg(TL.COMMAND_SETFWARP_NOTCLAIMED); context.msg(TL.COMMAND_SETFWARP_NOTCLAIMED);
return; return;
} }
String warp = context.argAsString(0); String warp = context.argAsString(0);
// Checks if warp with same name already exists and ignores maxWarp check if it does.
boolean warpExists = context.faction.isWarp(warp); boolean warpExists = context.faction.isWarp(warp);
int maxWarps = context.faction.getWarpsLimit();
int maxWarps = FactionsPlugin.getInstance().getConfig().getInt("max-warps", 5);
boolean tooManyWarps = maxWarps <= context.faction.getWarps().size(); boolean tooManyWarps = maxWarps <= context.faction.getWarps().size();
if (tooManyWarps && !warpExists) { if (tooManyWarps && !warpExists) {
context.msg(TL.COMMAND_SETFWARP_LIMIT, maxWarps); context.msg(TL.COMMAND_SETFWARP_LIMIT, maxWarps);
return; return;
} }
if (!this.transact(context.fPlayer, context)) {
if (!transact(context.fPlayer, context)) {
return; return;
} }
String password = context.argAsString(1); String password = context.argAsString(1);
LazyLocation loc = new LazyLocation(context.player.getLocation()); LazyLocation loc = new LazyLocation(context.player.getLocation());
context.faction.setWarp(warp, loc); context.faction.setWarp(warp, loc);
if (password != null) { if (password != null) {
context.faction.setWarpPassword(warp, password); context.faction.setWarpPassword(warp, password);
} }
context.msg(TL.COMMAND_SETFWARP_SET, warp, password != null ? password : ""); context.msg(TL.COMMAND_SETFWARP_SET, warp, (password != null) ? password : "");
} }
private boolean transact(FPlayer player, CommandContext context) { private boolean transact(FPlayer player, CommandContext context) {
return !FactionsPlugin.getInstance().getConfig().getBoolean("warp-cost.enabled", false) || player.isAdminBypassing() || context.payForCommand(FactionsPlugin.getInstance().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

View File

@@ -46,7 +46,7 @@ public class CmdSethome extends FCommand {
faction.setHome(context.player.getLocation()); faction.setHome(context.player.getLocation());
faction.msg(TL.COMMAND_SETHOME_SET, context.fPlayer.describeTo(context.faction, true)); faction.msg(TL.COMMAND_SETHOME_SET, context.fPlayer.describeTo(context.faction, true));
faction.sendMessage(FactionsPlugin.getInstance().cmdBase.cmdHome.getUseageTemplate(context)); faction.sendMessage(FactionsPlugin.getInstance().cmdBase.cmdHome.getUsageTemplate(context));
if (faction != context.faction) { if (faction != context.faction) {
context.msg(TL.COMMAND_SETHOME_SETOTHER, faction.getTag(context.fPlayer)); context.msg(TL.COMMAND_SETHOME_SETOTHER, faction.getTag(context.fPlayer));
} }

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

@@ -31,7 +31,7 @@ public class CmdUnban extends FCommand {
if (target.getFaction() != context.fPlayer.getFaction()) { if (target.getFaction() != context.fPlayer.getFaction()) {
if (target.getFaction().getAccess(context.fPlayer, PermissableAction.BAN) != Access.ALLOW) { if (target.getFaction().getAccess(context.fPlayer, PermissableAction.BAN) != Access.ALLOW) {
if (!context.fPlayer.isAdminBypassing()) { if (!context.fPlayer.isAdminBypassing()) {
context.fPlayer.msg(TL.COMMAND_UNBAN_TARGET_IN_OTHER_FACTION); context.fPlayer.msg(TL.COMMAND_UNBAN_TARGET_IN_OTHER_FACTION, target.getName());
} }
} }
} }

View File

@@ -20,6 +20,8 @@ import com.massivecraft.factions.cmd.roles.CmdDemote;
import com.massivecraft.factions.cmd.roles.CmdPromote; import com.massivecraft.factions.cmd.roles.CmdPromote;
import com.massivecraft.factions.cmd.tnt.CmdTnt; import com.massivecraft.factions.cmd.tnt.CmdTnt;
import com.massivecraft.factions.cmd.tnt.CmdTntFill; import com.massivecraft.factions.cmd.tnt.CmdTntFill;
import com.massivecraft.factions.discord.CmdInviteBot;
import com.massivecraft.factions.discord.CmdSetGuild;
import com.massivecraft.factions.missions.CmdMissions; import com.massivecraft.factions.missions.CmdMissions;
import com.massivecraft.factions.shop.CmdShop; import com.massivecraft.factions.shop.CmdShop;
import com.massivecraft.factions.zcore.util.TL; import com.massivecraft.factions.zcore.util.TL;
@@ -146,6 +148,11 @@ public class FCmdRoot extends FCommand implements CommandExecutor {
public CmdCheck cmdCheck = new CmdCheck(); public CmdCheck cmdCheck = new CmdCheck();
public CmdWeeWoo cmdWeeWoo = new CmdWeeWoo(); public CmdWeeWoo cmdWeeWoo = new CmdWeeWoo();
public CmdConvertConfig cmdConvertConfig = new CmdConvertConfig(); public CmdConvertConfig cmdConvertConfig = new CmdConvertConfig();
public CmdSpawnerLock cmdSpawnerLock = new CmdSpawnerLock();
public CmdSetDiscord cmdSetDiscord = new CmdSetDiscord();
public CmdSeeDiscord cmdSeeDiscord = new CmdSeeDiscord();
public CmdInviteBot cmdInviteBot = new CmdInviteBot();
public CmdSetGuild cmdSetGuild = new CmdSetGuild();
public FCmdRoot() { public FCmdRoot() {
super(); super();
@@ -255,6 +262,12 @@ public class FCmdRoot extends FCommand implements CommandExecutor {
this.addSubCommand(this.cmdFGlobal); this.addSubCommand(this.cmdFGlobal);
this.addSubCommand(this.cmdViewChest); this.addSubCommand(this.cmdViewChest);
this.addSubCommand(this.cmdConvertConfig); this.addSubCommand(this.cmdConvertConfig);
this.addSubCommand(this.cmdSpawnerLock);
if(Conf.useDiscordSystem){
this.addSubCommand(this.cmdInviteBot);
this.addSubCommand(this.cmdSetGuild);
}
if (Conf.useCheckSystem) { if (Conf.useCheckSystem) {
this.addSubCommand(this.cmdCheck); this.addSubCommand(this.cmdCheck);
@@ -305,6 +318,12 @@ public class FCmdRoot extends FCommand implements CommandExecutor {
FactionsPlugin.getInstance().log(Level.INFO, "Enabling FactionsTop command, this is a very basic /f top please get a dedicated /f top resource if you want land calculation etc."); FactionsPlugin.getInstance().log(Level.INFO, "Enabling FactionsTop command, this is a very basic /f top please get a dedicated /f top resource if you want land calculation etc.");
this.addSubCommand(this.cmdTop); this.addSubCommand(this.cmdTop);
} }
if (FactionsPlugin.getInstance().getConfig().getBoolean("fdiscord.Enabled")) {
this.addSubCommand(this.cmdSetDiscord);
this.addSubCommand(this.cmdSeeDiscord);
}
if (FactionsPlugin.getInstance().getConfig().getBoolean("fpaypal.Enabled")) { if (FactionsPlugin.getInstance().getConfig().getBoolean("fpaypal.Enabled")) {
this.addSubCommand(this.cmdPaypalSet); this.addSubCommand(this.cmdPaypalSet);
this.addSubCommand(this.cmdPaypalSee); this.addSubCommand(this.cmdPaypalSee);

View File

@@ -96,7 +96,7 @@ public abstract class FCommand {
if (context.args.size() < this.requiredArgs.size()) { if (context.args.size() < this.requiredArgs.size()) {
if (context.sender != null) { if (context.sender != null) {
context.msg(TL.GENERIC_ARGS_TOOFEW); context.msg(TL.GENERIC_ARGS_TOOFEW);
context.sender.sendMessage(this.getUseageTemplate(context)); context.sender.sendMessage(this.getUsageTemplate(context));
} }
return false; return false;
} }
@@ -106,7 +106,7 @@ public abstract class FCommand {
// Get the to many string slice // Get the to many string slice
List<String> theToMany = context.args.subList(this.requiredArgs.size() + this.optionalArgs.size(), context.args.size()); List<String> theToMany = context.args.subList(this.requiredArgs.size() + this.optionalArgs.size(), context.args.size());
context.msg(TL.GENERIC_ARGS_TOOMANY, TextUtil.implode(theToMany, " ")); context.msg(TL.GENERIC_ARGS_TOOMANY, TextUtil.implode(theToMany, " "));
context.sender.sendMessage(this.getUseageTemplate(context)); context.sender.sendMessage(this.getUsageTemplate(context));
} }
return false; return false;
} }
@@ -200,7 +200,7 @@ public abstract class FCommand {
/* /*
Help and Usage information Help and Usage information
*/ */
public String getUseageTemplate(CommandContext context, boolean addShortHelp) { public String getUsageTemplate(CommandContext context, boolean addShortHelp) {
StringBuilder ret = new StringBuilder(); StringBuilder ret = new StringBuilder();
ret.append(FactionsPlugin.getInstance().color(TL.COMMAND_USEAGE_TEMPLATE_COLOR.toString())); ret.append(FactionsPlugin.getInstance().color(TL.COMMAND_USEAGE_TEMPLATE_COLOR.toString()));
ret.append('/'); ret.append('/');
@@ -241,8 +241,8 @@ public abstract class FCommand {
return ret.toString(); return ret.toString();
} }
public String getUseageTemplate(CommandContext context) { public String getUsageTemplate(CommandContext context) {
return getUseageTemplate(context, false); return getUsageTemplate(context, false);
} }
} }

View File

@@ -5,10 +5,18 @@ 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.FactionsPlugin; import com.massivecraft.factions.FactionsPlugin;
import com.massivecraft.factions.discord.FactionChatHandler;
import com.massivecraft.factions.zcore.util.TL; import com.massivecraft.factions.zcore.util.TL;
import net.dv8tion.jda.core.EmbedBuilder;
import net.dv8tion.jda.core.MessageBuilder;
import net.dv8tion.jda.core.Permission;
import net.dv8tion.jda.core.entities.MessageEmbed;
import net.dv8tion.jda.core.entities.TextChannel;
import java.awt.*;
import java.text.SimpleDateFormat; import java.text.SimpleDateFormat;
import java.util.ArrayList; import java.util.ArrayList;
import java.util.Date;
import java.util.List; import java.util.List;
import java.util.concurrent.CopyOnWriteArrayList; import java.util.concurrent.CopyOnWriteArrayList;
@@ -68,6 +76,29 @@ public class CheckTask implements Runnable {
CheckTask.wallChecks.add(faction.getId()); CheckTask.wallChecks.add(faction.getId());
} }
faction.msg(TL.CHECK_WALLS_CHECK); faction.msg(TL.CHECK_WALLS_CHECK);
String channelId = faction.getWallNotifyChannelId();
if (channelId == null) {
continue;
}
if (channelId.isEmpty()) {
continue;
}
TextChannel textChannel = FactionChatHandler.jda.getTextChannelById(channelId);
if (textChannel == null) {
continue;
}
if (!textChannel.getGuild().getSelfMember().hasPermission(textChannel, Permission.MESSAGE_READ, Permission.MESSAGE_WRITE)) {
textChannel.getGuild().getOwner().getUser().openPrivateChannel().queue(privateChannel -> privateChannel.sendMessage((":x: Missing read/write in " + textChannel.getAsMention())).queue());
} else {
String format = faction.getNotifyFormat();
if (format == null || format.isEmpty()) {
format = "@everyone, check %type%";
}
format = format.replace("%type%", "walls");
MessageEmbed embed = new EmbedBuilder().setColor(Color.WHITE).setFooter(this.simpleDateFormat.format(new Date(currentTime)), null).build();
textChannel.sendMessage(new MessageBuilder(embed).setContent(format).build()).queue();
}
} }
@@ -91,8 +122,29 @@ public class CheckTask implements Runnable {
CheckTask.bufferChecks.add(faction.getId()); CheckTask.bufferChecks.add(faction.getId());
} }
faction.msg(TL.CHECK_BUFFERS_CHECK); faction.msg(TL.CHECK_BUFFERS_CHECK);
String channelId = faction.getBufferNotifyChannelId();
if (channelId == null) {
continue;
}
if (channelId.isEmpty()) {
continue;
}
TextChannel textChannel = FactionChatHandler.jda.getTextChannelById(channelId);
if (textChannel == null) {
continue;
}
if (!textChannel.getGuild().getSelfMember().hasPermission(textChannel, Permission.MESSAGE_READ, Permission.MESSAGE_WRITE)) {
textChannel.getGuild().getOwner().getUser().openPrivateChannel().queue(privateChannel -> privateChannel.sendMessage((":x: Missing read/write in " + textChannel.getAsMention())).queue());
} else {
String format = faction.getNotifyFormat();
if (format == null || format.isEmpty()) {
format = "@everyone, check %type%";
}
format = format.replace("%type%", "buffers");
MessageEmbed embed = new EmbedBuilder().setColor(Color.WHITE).setFooter(this.simpleDateFormat.format(new Date(currentTime)), null).build();
textChannel.sendMessage(new MessageBuilder(embed).setContent(format).build()).queue();
}
} }
} }
} }

View File

@@ -1,17 +1,25 @@
package com.massivecraft.factions.cmd.check; package com.massivecraft.factions.cmd.check;
import com.massivecraft.factions.Conf; import com.massivecraft.factions.Conf;
import com.massivecraft.factions.Faction;
import com.massivecraft.factions.FactionsPlugin; import com.massivecraft.factions.FactionsPlugin;
import com.massivecraft.factions.cmd.CommandContext; import com.massivecraft.factions.cmd.CommandContext;
import com.massivecraft.factions.cmd.CommandRequirements; import com.massivecraft.factions.cmd.CommandRequirements;
import com.massivecraft.factions.cmd.FCommand; import com.massivecraft.factions.cmd.FCommand;
import com.massivecraft.factions.discord.FactionChatHandler;
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.PermissableAction; import com.massivecraft.factions.zcore.fperms.PermissableAction;
import com.massivecraft.factions.zcore.util.TL; import com.massivecraft.factions.zcore.util.TL;
import net.dv8tion.jda.core.EmbedBuilder;
import net.dv8tion.jda.core.entities.Channel;
import net.dv8tion.jda.core.entities.MessageEmbed;
import net.dv8tion.jda.core.entities.TextChannel;
import org.bukkit.OfflinePlayer; import org.bukkit.OfflinePlayer;
import java.awt.*;
import java.text.SimpleDateFormat; import java.text.SimpleDateFormat;
import java.util.List;
import java.util.*; import java.util.*;
import java.util.stream.Collectors; import java.util.stream.Collectors;
@@ -76,6 +84,21 @@ public class CmdCheck extends FCommand {
} }
context.faction.getChecks().put(currentTime, "U" + context.fPlayer.getNameAndTag()); context.faction.getChecks().put(currentTime, "U" + context.fPlayer.getNameAndTag());
context.msg(TL.CHECK_WALLS_MARKED_CHECKED); context.msg(TL.CHECK_WALLS_MARKED_CHECKED);
if (!Conf.useDiscordSystem) return;
String channelId = context.faction.getWallNotifyChannelId();
if (channelId == null || channelId.isEmpty()) {
return;
}
TextChannel textChannel = FactionChatHandler.jda.getTextChannelById(channelId);
if (textChannel == null) {
return;
}
if (!textChannel.getGuild().getSelfMember().hasPermission(textChannel, net.dv8tion.jda.core.Permission.MESSAGE_READ, net.dv8tion.jda.core.Permission.MESSAGE_WRITE)) {
textChannel.getGuild().getOwner().getUser().openPrivateChannel().queue(privateChannel -> privateChannel.sendMessage((":x: Missing read/write in " + textChannel.getAsMention())).queue());
return;
}
MessageEmbed embed = new EmbedBuilder().setColor(Color.MAGENTA).setTitle("Walls checked by " + context.fPlayer.getNameAndTag()).setFooter(simpleDateFormat.format(new Date(currentTime)), null).build();
textChannel.sendMessage(embed).queue();
} }
} else if (subCommand.equalsIgnoreCase("buffers")) { } else if (subCommand.equalsIgnoreCase("buffers")) {
if (!CheckTask.bufferCheck(context.faction.getId())) { if (!CheckTask.bufferCheck(context.faction.getId())) {
@@ -93,6 +116,21 @@ public class CmdCheck extends FCommand {
} }
context.faction.getChecks().put(System.currentTimeMillis(), "Y" + context.fPlayer.getNameAndTag()); context.faction.getChecks().put(System.currentTimeMillis(), "Y" + context.fPlayer.getNameAndTag());
context.msg(TL.CHECK_BUFFERS_MARKED_CHECKED); context.msg(TL.CHECK_BUFFERS_MARKED_CHECKED);
if (!Conf.useDiscordSystem) return;
String channelId = context.faction.getBufferNotifyChannelId();
if (channelId == null || channelId.isEmpty()) {
return;
}
TextChannel textChannel = FactionChatHandler.jda.getTextChannelById(channelId);
if (textChannel == null) {
return;
}
if (!textChannel.getGuild().getSelfMember().hasPermission(textChannel, net.dv8tion.jda.core.Permission.MESSAGE_READ, net.dv8tion.jda.core.Permission.MESSAGE_WRITE)) {
textChannel.getGuild().getOwner().getUser().openPrivateChannel().queue(privateChannel -> privateChannel.sendMessage((":x: Missing read/write in " + textChannel.getAsMention())).queue());
return;
}
MessageEmbed embed = new EmbedBuilder().setColor(Color.MAGENTA).setTitle("Buffers checked by " + context.fPlayer.getNameAndTag()).setFooter(simpleDateFormat.format(new Date(currentTime)), null).build();
textChannel.sendMessage(embed).queue();
} }
} else if (subCommand.equalsIgnoreCase("settings")) { } else if (subCommand.equalsIgnoreCase("settings")) {
if (!context.fPlayer.getRole().isAtLeast(Role.COLEADER)) { if (!context.fPlayer.getRole().isAtLeast(Role.COLEADER)) {

View File

@@ -1,10 +1,14 @@
package com.massivecraft.factions.cmd.check; package com.massivecraft.factions.cmd.check;
import com.massivecraft.factions.Conf;
import com.massivecraft.factions.cmd.CommandContext; import com.massivecraft.factions.cmd.CommandContext;
import com.massivecraft.factions.cmd.CommandRequirements; import com.massivecraft.factions.cmd.CommandRequirements;
import com.massivecraft.factions.cmd.FCommand; import com.massivecraft.factions.cmd.FCommand;
import com.massivecraft.factions.discord.FactionChatHandler;
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 net.dv8tion.jda.core.entities.Channel;
import net.dv8tion.jda.core.entities.TextChannel;
public class CmdWeeWoo extends FCommand { public class CmdWeeWoo extends FCommand {
public CmdWeeWoo() { public CmdWeeWoo() {
@@ -30,7 +34,19 @@ public class CmdWeeWoo extends FCommand {
} }
context.faction.setWeeWoo(true); context.faction.setWeeWoo(true);
context.msg(TL.COMMAND_WEEWOO_STARTED, context.fPlayer.getNameAndTag()); context.msg(TL.COMMAND_WEEWOO_STARTED, context.fPlayer.getNameAndTag());
if (!Conf.useDiscordSystem) return;
String discordChannelId = context.faction.getWeeWooChannelId();
if (discordChannelId != null && !discordChannelId.isEmpty()) {
TextChannel textChannel = FactionChatHandler.jda.getTextChannelById(discordChannelId);
if (textChannel == null) {
return;
}
if (!textChannel.getGuild().getSelfMember().hasPermission(textChannel, net.dv8tion.jda.core.Permission.MESSAGE_READ, net.dv8tion.jda.core.Permission.MESSAGE_WRITE)) {
textChannel.getGuild().getOwner().getUser().openPrivateChannel().queue(privateChannel -> privateChannel.sendMessage((":x: Missing read/write in " + textChannel.getAsMention())).queue());
return;
}
textChannel.sendMessage(TL.WEEWOO_STARTED_DISCORD.format(context.fPlayer.getNameAndTag())).queue();
}
} else if (argument.equalsIgnoreCase("stop")) { } else if (argument.equalsIgnoreCase("stop")) {
if (!weewoo) { if (!weewoo) {
context.msg(TL.COMMAND_WEEWOO_ALREADY_STOPPED); context.msg(TL.COMMAND_WEEWOO_ALREADY_STOPPED);
@@ -38,6 +54,19 @@ public class CmdWeeWoo extends FCommand {
} }
context.faction.setWeeWoo(false); context.faction.setWeeWoo(false);
context.msg(TL.COMMAND_WEEWOO_STOPPED, context.fPlayer.getNameAndTag()); context.msg(TL.COMMAND_WEEWOO_STOPPED, context.fPlayer.getNameAndTag());
if(!Conf.useDiscordSystem) return;
String discordChannelId = context.faction.getWeeWooChannelId();
if (discordChannelId != null && !discordChannelId.isEmpty()) {
TextChannel textChannel = FactionChatHandler.jda.getTextChannelById(discordChannelId);
if (textChannel == null) {
return;
}
if (!textChannel.getGuild().getSelfMember().hasPermission(textChannel, net.dv8tion.jda.core.Permission.MESSAGE_READ, net.dv8tion.jda.core.Permission.MESSAGE_WRITE)) {
textChannel.getGuild().getOwner().getUser().openPrivateChannel().queue(privateChannel -> privateChannel.sendMessage((":x: Missing read/write in " + textChannel.getAsMention())).queue());
return;
}
textChannel.sendMessage(TL.WEEWOO_STOPPED_DISCORD.format(context.fPlayer.getNameAndTag())).queue();
}
} else { } else {
context.msg("/f weewoo <start/stop>"); context.msg("/f weewoo <start/stop>");
} }

View File

@@ -3,7 +3,11 @@ package com.massivecraft.factions.cmd.check;
import com.massivecraft.factions.Faction; import com.massivecraft.factions.Faction;
import com.massivecraft.factions.Factions; import com.massivecraft.factions.Factions;
import com.massivecraft.factions.FactionsPlugin; import com.massivecraft.factions.FactionsPlugin;
import com.massivecraft.factions.discord.FactionChatHandler;
import com.massivecraft.factions.zcore.util.TL; import com.massivecraft.factions.zcore.util.TL;
import net.dv8tion.jda.core.JDA;
import net.dv8tion.jda.core.Permission;
import net.dv8tion.jda.core.entities.TextChannel;
public class WeeWooTask implements Runnable { public class WeeWooTask implements Runnable {
@@ -20,6 +24,26 @@ public class WeeWooTask implements Runnable {
continue; continue;
} }
faction.msg(TL.WEE_WOO_MESSAGE); faction.msg(TL.WEE_WOO_MESSAGE);
if (!FactionChatHandler.jda.getStatus().equals(JDA.Status.CONNECTED)) {
continue;
}
String discordChannelId = faction.getWeeWooChannelId();
if (discordChannelId == null || discordChannelId.isEmpty()) {
continue;
}
TextChannel textChannel = FactionChatHandler.jda.getTextChannelById(discordChannelId);
if (textChannel == null) {
continue;
}
if (!textChannel.getGuild().getSelfMember().hasPermission(textChannel, Permission.MESSAGE_READ, Permission.MESSAGE_WRITE)) {
textChannel.getGuild().getOwner().getUser().openPrivateChannel().queue(privateChannel -> privateChannel.sendMessage((":x: Missing read/write in " + textChannel.getAsMention())).queue());
} else {
String format = faction.getWeeWooFormat();
if (format == null || format.isEmpty()) {
format = "@everyone, we're being raided! Get online!";
}
textChannel.sendMessage(format).queue();
}
} }
} }
} }

View File

@@ -0,0 +1,67 @@
package com.massivecraft.factions.cmd.chest;
import com.massivecraft.factions.FPlayer;
import com.massivecraft.factions.FPlayers;
import com.massivecraft.factions.FactionsPlugin;
import com.massivecraft.factions.zcore.util.TL;
import org.bukkit.entity.Player;
import org.bukkit.event.EventHandler;
import org.bukkit.event.Listener;
import org.bukkit.event.inventory.InventoryClickEvent;
import org.bukkit.event.inventory.InventoryDragEvent;
import org.bukkit.inventory.Inventory;
import org.bukkit.inventory.ItemStack;
public class AntiChestListener implements Listener {
@EventHandler
public void onInventoryClick(InventoryClickEvent e) {
Player player = (Player) e.getWhoClicked();
FPlayer fPlayer = FPlayers.getInstance().getByPlayer(player);
if (!e.getView().getTopInventory().getTitle().equalsIgnoreCase(FactionsPlugin.getInstance().color(FactionsPlugin.getInstance().getConfig().getString("fchest.Inventory-Title")))) return;
if (e.isCancelled()) return;
Inventory clicked = e.getClickedInventory();
if (e.getClick().isShiftClick()) {
if (clicked == e.getWhoClicked().getInventory()) {
ItemStack clickedOn = e.getCurrentItem();
if (clickedOn != null && FactionsPlugin.getInstance().itemList.contains(clickedOn.getType().toString())) {
fPlayer.msg(TL.CHEST_ITEM_DENIED_TRANSFER, clickedOn.getType().toString());
e.setCancelled(true);
}
}
}
if (clicked != e.getWhoClicked().getInventory()) {
ItemStack onCursor = e.getCursor();
if (onCursor != null && FactionsPlugin.getInstance().itemList.contains(onCursor.getType().toString())) {
fPlayer.msg(TL.CHEST_ITEM_DENIED_TRANSFER, onCursor.getType().toString());
e.setCancelled(true);
}
}
}
@EventHandler
public void onInventoryDrag(InventoryDragEvent e) {
Player p = (Player) e.getWhoClicked();
FPlayer fPlayer = FPlayers.getInstance().getByPlayer(p);
if (!e.getView().getTopInventory().getTitle().equalsIgnoreCase(FactionsPlugin.getInstance().color(FactionsPlugin.getInstance().getConfig().getString("fchest.Inventory-Title")))) return;
if (e.isCancelled()) return;
ItemStack dragged = e.getOldCursor();
if (FactionsPlugin.getInstance().itemList.contains(dragged.getType().toString())) {
int inventorySize = e.getInventory().getSize();
for (int i : e.getRawSlots()) {
if (i < inventorySize) {
fPlayer.msg(TL.CHEST_ITEM_DENIED_TRANSFER, dragged.getType().toString());
e.setCancelled(true);
break;
}
}
}
}
}

View File

@@ -23,20 +23,25 @@ public class ConvertConfigHandler {
static FileConfiguration sv = YamlConfiguration.loadConfiguration(savageConfigFile); static FileConfiguration sv = YamlConfiguration.loadConfiguration(savageConfigFile);
static File configFile = new File("plugins/Factions/config.yml"); static File configFile = new File("plugins/Factions/config.yml");
static FileConfiguration sb = YamlConfiguration.loadConfiguration(configFile); static FileConfiguration sb = YamlConfiguration.loadConfiguration(configFile);
public static void setString(String s){ static JavaPlugin plugin = JavaPlugin.getProvidingPlugin(FactionsPlugin.class);
public static void setString(String s) {
sb.set(s, sv.getString(s)); sb.set(s, sv.getString(s));
} }
public static void setInt(String s){
public static void setInt(String s) {
sb.set(s, sv.getInt(s)); sb.set(s, sv.getInt(s));
} }
public static void setConfigSec(String s){
public static void setConfigSec(String s) {
ConfigurationSection cs = sv.getConfigurationSection(s); ConfigurationSection cs = sv.getConfigurationSection(s);
sb.set(s, cs); sb.set(s, cs);
} }
static JavaPlugin plugin = JavaPlugin.getProvidingPlugin(FactionsPlugin.class);
public static void setBoolean(String s){ public static void setBoolean(String s) {
sb.set(s, sv.getBoolean(s)); sb.set(s, sv.getBoolean(s));
} }
public static void convertconfig(Player player) { public static void convertconfig(Player player) {
if (new File("plugins/Factions/SavageFactions/config.yml").exists()) { if (new File("plugins/Factions/SavageFactions/config.yml").exists()) {
BukkitScheduler scheduler = plugin.getServer().getScheduler(); BukkitScheduler scheduler = plugin.getServer().getScheduler();

View File

@@ -35,7 +35,7 @@ public class CmdMoney extends FCommand {
@Override @Override
public void perform(CommandContext context) { public void perform(CommandContext context) {
if (!Conf.econEnabled) { if (!Conf.econEnabled || !Conf.bankEnabled) {
context.msg(TL.ECON_OFF, "economy option is enabled, please set \'econEnabled\' to true in conf.json"); context.msg(TL.ECON_OFF, "economy option is enabled, please set \'econEnabled\' to true in conf.json");
return; return;
} }

View File

@@ -1,6 +1,7 @@
package com.massivecraft.factions.cmd.grace; package com.massivecraft.factions.cmd.grace;
import com.massivecraft.factions.Conf; import com.massivecraft.factions.Conf;
import com.massivecraft.factions.FactionsPlugin;
import com.massivecraft.factions.cmd.CommandContext; import com.massivecraft.factions.cmd.CommandContext;
import com.massivecraft.factions.cmd.CommandRequirements; import com.massivecraft.factions.cmd.CommandRequirements;
import com.massivecraft.factions.cmd.FCommand; import com.massivecraft.factions.cmd.FCommand;
@@ -14,14 +15,13 @@ public class CmdGrace extends FCommand {
this.aliases.add("grace"); this.aliases.add("grace");
this.requirements = new CommandRequirements.Builder(Permission.GRACE) this.requirements = new CommandRequirements.Builder(Permission.GRACE)
.playerOnly()
.build(); .build();
} }
@Override @Override
public void perform(CommandContext context) { public void perform(CommandContext context) {
Conf.gracePeriod = !Conf.gracePeriod; Conf.gracePeriod = !Conf.gracePeriod;
context.msg(TL.COMMAND_GRACE_TOGGLE, Conf.gracePeriod ? TL.GENERIC_ENABLED : TL.GENERIC_DISABLED); context.msg(TL.COMMAND_GRACE_TOGGLE, Conf.gracePeriod ? FactionsPlugin.getInstance().color("&aEnabled") : FactionsPlugin.getInstance().color("&4Disabled"));
} }

View File

@@ -115,7 +115,7 @@ public class CmdTnt extends FCommand {
context.msg(TL.GENERIC_ARGS_TOOFEW); context.msg(TL.GENERIC_ARGS_TOOFEW);
context.msg(context.args.get(0).equalsIgnoreCase("take") || context.args.get(0).equalsIgnoreCase("t") ? TL.COMMAND_TNT_TAKE_DESCRIPTION : TL.COMMAND_TNT_ADD_DESCRIPTION); context.msg(context.args.get(0).equalsIgnoreCase("take") || context.args.get(0).equalsIgnoreCase("t") ? TL.COMMAND_TNT_TAKE_DESCRIPTION : TL.COMMAND_TNT_ADD_DESCRIPTION);
} }
context.sendMessage(TL.COMMAND_TNT_AMOUNT.toString().replace("{amount}", context.faction.getTnt() + "")); context.sendMessage(TL.COMMAND_TNT_AMOUNT.toString().replace("{amount}", context.faction.getTnt() + "").replace("{bankSize}", context.faction.getTntBankLimit() + ""));
} }

View File

@@ -0,0 +1,31 @@
package com.massivecraft.factions.discord;
import com.massivecraft.factions.FactionsPlugin;
import com.massivecraft.factions.cmd.CommandContext;
import com.massivecraft.factions.cmd.FCommand;
import com.massivecraft.factions.zcore.util.TL;
import mkremins.fanciful.FancyMessage;
import net.dv8tion.jda.core.JDA;
import net.dv8tion.jda.core.Permission;
public class CmdInviteBot extends FCommand {
public CmdInviteBot(){
super();
this.aliases.add("invitebot");
}
@Override
public void perform(CommandContext context) {
JDA jda = FactionChatHandler.jda;
FancyMessage fancyMessage = new FancyMessage();
fancyMessage.link(jda.asBot().getInviteUrl(Permission.MESSAGE_READ, Permission.MESSAGE_WRITE, Permission.MESSAGE_HISTORY, Permission.MESSAGE_ADD_REACTION, Permission.MESSAGE_EMBED_LINKS));
fancyMessage.text(FactionsPlugin.getInstance().color("&c&lFactions Bot - &2Click here to invite the bot"));
fancyMessage.send(context.fPlayer.getPlayer());
}
@Override
public TL getUsageTranslation() {
return TL.INVITE_BOT_USAGE;
}
}

View File

@@ -0,0 +1,96 @@
package com.massivecraft.factions.discord;
import com.jagrosh.jdautilities.commons.waiter.EventWaiter;
import com.massivecraft.factions.Faction;
import com.massivecraft.factions.Factions;
import com.massivecraft.factions.cmd.CommandContext;
import com.massivecraft.factions.cmd.CommandRequirements;
import com.massivecraft.factions.cmd.FCommand;
import com.massivecraft.factions.struct.Permission;
import com.massivecraft.factions.zcore.util.TL;
import net.dv8tion.jda.core.JDA;
import net.dv8tion.jda.core.entities.Guild;
import net.dv8tion.jda.core.entities.User;
import net.dv8tion.jda.core.events.message.priv.react.PrivateMessageReactionAddEvent;
import org.bukkit.ChatColor;
import java.util.concurrent.TimeUnit;
public class CmdSetGuild extends FCommand {
private EventWaiter eventWaiter;
private boolean waiterAdded;
public CmdSetGuild() {
super();
this.eventWaiter = new EventWaiter();
this.waiterAdded = false;
this.aliases.add("setguild");
this.optionalArgs.put("id", "none");
this.optionalArgs.put("faction", "you");
this.requirements = new CommandRequirements.Builder(Permission.SET_GUILD)
.playerOnly()
.memberOnly()
.build();
}
@Override
public void perform(CommandContext context) {
String guildId = context.argAsString(0, null);
Faction faction = context.argAsFaction(1, context.faction);
JDA jda = FactionChatHandler.jda;
if (jda != null) {
if (!this.waiterAdded) {
jda.addEventListener(new EventWaiter[]{this.eventWaiter});
this.waiterAdded = true;
}
if (guildId != null && !guildId.equalsIgnoreCase("null")) {
Guild guild = null;
try {
guild = jda.getGuildById(guildId);
} catch (NumberFormatException var7) {
}
if (guild == null) {
context.msg(TL.SET_GUILD_ID_INVALID_ID);
} else if (Factions.getInstance().getAllFactions().stream().anyMatch((f) -> guildId.equals(f.getGuildId()))) {
context.msg(TL.SET_GUILD_ID_GUILD_ALREADY_LINKED);
} else {
context.msg(TL.SET_GUILD_ID_PMING_OWNER);
User user = guild.getOwner().getUser();
Guild finalGuild = guild;
Guild finalGuild1 = guild;
user.openPrivateChannel().queue((privateChannel) -> privateChannel.sendMessage("Link guild **" + finalGuild1.getName() + "** to faction **" + ChatColor.stripColor(faction.getTag()) + "**?").queue((message) -> {
String checkMark = "âś…";
message.addReaction(checkMark).queue();
this.eventWaiter.waitForEvent(PrivateMessageReactionAddEvent.class, (event) -> event.getReactionEmote().getName().equals(checkMark) && event.getUser().getId().equals(user.getId()) && event.getMessageId().equals(message.getId()), (event) -> {
faction.setGuildId(context.argAsString(0));
context.msg(TL.SET_GUILD_ID_SUCCESS);
privateChannel.sendMessage("Successfully linked **" + finalGuild.getName() + " & " + ChatColor.stripColor(faction.getTag()) + "**").queue();
}, 15L, TimeUnit.SECONDS, () -> {
privateChannel.sendMessage(TL.SET_GUILD_ID_TIMED_OUT_DISCORD.toString()).queue();
context.msg(TL.SET_GUILD_ID_TIMED_OUT_MINECRAFT);
});
}, (t) -> {
context.msg(TL.SET_GUILD_ID_UNABLE_TO_MESSAGE_GUILD_OWNER);
}), (t) -> context.msg(TL.SET_GUILD_ID_UNABLE_TO_MESSAGE_GUILD_OWNER));
}
} else {
faction.setGuildId(null);
faction.setWeeWooChannelId(null);
faction.setBufferNotifyChannelId(null);
faction.setWallNotifyChannelId(null);
faction.setFactionChatChannelId(null);
context.msg(TL.SET_GUILD_ID_RESET_ID);
}
}
}
@Override
public TL getUsageTranslation() {
return TL.SET_GUILD_ID_USAGE;
}
}

View File

@@ -0,0 +1,528 @@
package com.massivecraft.factions.discord;
import com.massivecraft.factions.*;
import com.massivecraft.factions.discord.json.JSONGuilds;
import com.massivecraft.factions.zcore.util.TL;
import net.dv8tion.jda.core.EmbedBuilder;
import net.dv8tion.jda.core.Permission;
import net.dv8tion.jda.core.entities.*;
import net.dv8tion.jda.core.events.message.guild.GuildMessageReceivedEvent;
import net.dv8tion.jda.core.exceptions.PermissionException;
import net.dv8tion.jda.core.hooks.ListenerAdapter;
import org.bukkit.ChatColor;
import org.bukkit.OfflinePlayer;
import java.awt.*;
import java.io.File;
import java.io.IOException;
import java.nio.file.Files;
import java.text.DecimalFormat;
import java.util.List;
import java.util.*;
import java.util.stream.Collectors;
public class DiscordListener extends ListenerAdapter {
private static File file = new File(FactionsPlugin.getInstance().getDataFolder(), "discord_guilds.json");
public static JSONGuilds guilds = loadGuilds();
private final DecimalFormat decimalFormat;
private FactionsPlugin plugin;
public DiscordListener(FactionsPlugin plugin) {
this.decimalFormat = new DecimalFormat("$#,###.##");
this.plugin = plugin;
int minute = 3600;
plugin.getServer().getScheduler().runTaskTimerAsynchronously(plugin, DiscordListener::saveGuilds, (long) (minute * 15), (long) (minute * 15));
}
private static JSONGuilds loadGuilds() {
try {
if (file.exists())
return FactionsPlugin.getInstance().gson.fromJson(String.join("\n", Files.readAllLines(file.toPath())), JSONGuilds.class);
Files.createFile(file.toPath());
Files.write(file.toPath(), "{}".getBytes());
return FactionsPlugin.getInstance().gson.fromJson(String.join("\n", Files.readAllLines(file.toPath())), JSONGuilds.class);
} catch (IOException e) {
e.printStackTrace();
throw new NullPointerException();
}
}
public static void saveGuilds() {
try {
String content = FactionsPlugin.getInstance().gson.toJson(guilds);
Files.write(file.toPath(), content.getBytes());
}
catch (IOException e) {
e.printStackTrace();
throw new NullPointerException();
}
}
public void onGuildMessageReceived(GuildMessageReceivedEvent event) {
try {
if (event.getMessage().isWebhookMessage() || event.getAuthor().isBot()) {
return;
}
String prefix = DiscordListener.guilds.getGuildById(event.getGuild().getId()).getPrefix();
if (prefix == null || prefix.isEmpty()) {
prefix = ".";
}
String content = event.getMessage().getContentRaw();
if (!content.startsWith(prefix) && !content.startsWith(event.getGuild().getSelfMember().getAsMention())) {
return;
}
if (content.startsWith(prefix + "help") || content.startsWith(event.getGuild().getSelfMember().getAsMention() + " help")) {
this.help(event, content, prefix);
} else if (content.startsWith(prefix + "stats")) {
this.stats(event, content, prefix);
} else if (content.startsWith(prefix + "fstats")) {
this.fstats(event, content, prefix);
} else if (content.startsWith(event.getGuild().getSelfMember().getAsMention() + " setprefix")) {
this.setPrefix(event, content);
} else if (content.startsWith(prefix + "setfchatchannel")) {
this.setFChatChannel(event);
} else if (content.startsWith(prefix + "setwallnotifychannel") || content.startsWith(prefix + "swnc")) {
this.setWallNotifyChannel(event);
} else if (content.startsWith(prefix + "setbuffernotifychannel") || content.startsWith(prefix + "sbnf")) {
this.setBufferNotifyChannel(event);
} else if (content.startsWith(prefix + "setweewoochannel")) {
this.setWeewooChannel(event);
} else if (content.startsWith(prefix + "setnotifyformat")) {
this.setNotifyFormat(event, content, prefix);
} else if (content.startsWith(prefix + "setweewooformat")) {
this.setWeewooFormat(event, content, prefix);
} else if (content.startsWith(prefix + "setmemberrole")) {
this.setMemberRole(event, content, prefix);
} else if (content.startsWith(prefix + "checkleaderboard") || content.startsWith(prefix + "cl")) {
this.checkLeaderboard(event);
} else if (content.startsWith(prefix + "weewoo")) {
this.weewoo(event, content, prefix);
} else if (content.startsWith(prefix + "settings")) {
this.settings(event);
}
} catch (PermissionException exception) {
if (!event.getGuild().getSelfMember().hasPermission(event.getChannel(), Permission.MESSAGE_READ, Permission.MESSAGE_WRITE)) {
return;
}
event.getChannel().sendMessage((":x: Missing permission, `" + exception.getPermission().toString() + "`")).queue();
}
}
private Faction getFaction(Guild guild) {
return Factions.getInstance().getAllFactions().stream().filter(faction -> guild.getId().equals(faction.getGuildId())).findAny().orElse(null);
}
private Faction getFactionWithWarning(TextChannel textChannel) {
Faction faction = this.getFaction(textChannel.getGuild());
if (faction == null) {
textChannel.sendMessage((":x: This guild isn't linked to a faction, use `/f setguild " + textChannel.getGuild().getId() + "` in game")).queue();
}
return faction;
}
private boolean cantAccessPermissionWithWarning(TextChannel textChannel, Member member) {
boolean can = member.hasPermission(Permission.MANAGE_SERVER);
if (!can) {
textChannel.sendMessage(":x: You need to have the Manage Server permission to do that").queue();
}
return !can;
}
private boolean canAccessRole(Faction faction, Member member) {
if (member.hasPermission(Permission.MANAGE_SERVER)) {
return true;
}
Role role = member.getGuild().getRoleById(faction.getMemberRoleId());
return role != null && member.getRoles().stream().anyMatch(r -> r.getPosition() >= role.getPosition());
}
private boolean cantAccessRoleWithWarning(TextChannel textChannel, Faction faction, Member member) {
boolean can = this.canAccessRole(faction, member);
if (!can) {
textChannel.sendMessage(":x: You don't have a faction member role").queue();
}
return !can;
}
private void help(GuildMessageReceivedEvent event, String content, String prefix) {
if (content.contains("help ")) {
content = content.substring(content.indexOf("help") + 5).trim();
EmbedBuilder embedBuilder = new EmbedBuilder().setColor(Color.MAGENTA);
if (content.equalsIgnoreCase("help")) {
embedBuilder.setTitle("Help | Help command").setDescription("Provides a list of commands & docs about commands").addField("Usage", "`" + prefix + "help [command]`", false);
} else if (content.equalsIgnoreCase("stats")) {
embedBuilder.setTitle("Help | Stats command").setDescription("Provides stats about the given player").addField("Usage", "`" + prefix + "stats <player name>`", false);
} else if (content.equalsIgnoreCase("fstats")) {
embedBuilder.setTitle("Help | Fstats command").setDescription("Provides stats about the give faction").addField("Usage", "`" + prefix + "fstats <faction name>`", false);
} else if (content.equalsIgnoreCase("setprefix")) {
embedBuilder.setTitle("Help | Setprefix command").setDescription("Changes the bot's prefix for all commands in the current guild").addField("Usage", "`@" + event.getGuild().getSelfMember().getEffectiveName() + " setprefix <new prefix>`", false);
} else if (content.equalsIgnoreCase("setfchatchannel")) {
embedBuilder.setTitle("Help | Setfchatchannel").setDescription("Sets or removes the channel for Faction chat \"mirroring\", where messages sent in in-game faction chat are sent in the channel & messages sent in the channel are sent to in-game faction chat").addField("Usage", "`" + prefix + "setfchatchannel [#channel]`", false);
} else if (content.equalsIgnoreCase("setwallnotifychannel")) {
embedBuilder.setTitle("Help | Setwallnotifychanel").setDescription("Sets or removes the wall check notification channel").addField("Usage", "`" + prefix + "setwallnotifychannel [#channel]`", false);
} else if (content.equalsIgnoreCase("setbuffernotifychannel")) {
embedBuilder.setTitle("Help | Setbuffernotifychannel").setDescription("Sets or removes the buffer check notification channel").addField("Usage", "`" + prefix + "setbuffernotifychannel [#channel]`", false);
} else if (content.equalsIgnoreCase("setweewoochannel")) {
embedBuilder.setTitle("Help | Setweewoochannel").setDescription("Sets or removes the weewoo (raid alert) channel").addField("Usage", "`" + prefix + "setweewoochannel [#channel>`", false);
} else if (content.equalsIgnoreCase("setnotifyformat")) {
embedBuilder.setTitle("Help | Setnotifyformat").setDescription("Sets the wall & buffer notification format, where `%type%` will be replaced with `walls` or `buffers`").addField("Usage", "`" + prefix + "setnotifyformat <format>`", false).addField("Default", "`@everyone, check %type%`", false);
} else if (content.equalsIgnoreCase("setweewooformat")) {
embedBuilder.setTitle("Help | Setweewooformat").setDescription("Sets the weewoo (raid alert) format").addField("Usage", "`" + prefix + "setweewooformat <fomat>`", false).addField("Default", "`@everyone, we're being raided! Get online!`", false);
} else if (content.equalsIgnoreCase("setmemberrole")) {
embedBuilder.setTitle("Help | Setmemberrole").setDescription("Sets the __lowest__ member role, where the specified role & any roles above it will be counted as members").addField("Usage", "`" + prefix + "setmemberrole <@role/role name/role id>`", false);
} else if (content.equalsIgnoreCase("checkleaderboard")) {
embedBuilder.setTitle("Help | Checkleaderboard").setDescription("Gets the leaderboard for wall & buffer checks").addField("Usage", "`" + prefix + "checkleaderboard`", false);
} else if (content.equalsIgnoreCase("weewoo")) {
embedBuilder.setTitle("Help | Weewoo").setDescription("Starts/stops the weewoo (raid alert").addField("Usage", "`" + prefix + "weewoo <start/stop>`", false);
} else if (content.equalsIgnoreCase("settings")) {
embedBuilder.setTitle("Help | Settings").setDescription("Gets the current settings").addField("Usage", "`" + prefix + "settings`", false);
} else {
embedBuilder.setColor(Color.RED).setTitle("Command not found");
}
event.getChannel().sendMessage(embedBuilder.build()).queue();
} else {
event.getChannel().sendMessage(("`" + prefix + "help [command]` This list or documentation of a command\n"
+ prefix + "stats <player name>` Get stats for a player\n`"
+ prefix + "fstats <faction name>` Get stats for a faction`\n__Requires Manage Server permission__\n@" + event.getGuild().getSelfMember().getEffectiveName() + " setprefix <prefix>` Change the bot's prefix for this guild`\n" +
"\n**Requires a linked faction**\n__Requires Manage Server permission__\n`" + prefix + "setfchatchannel [#channel]` Set or reset the fchat channel\n`" +
prefix + "setwallnotifychannel [#channel]` Set or reset the wall check notification channel\n`" + prefix + "setbuffernotifychannel [#channel]` Set or reset the buffer check notification channel\n`" +
prefix + "setweewoochannel [#channel]` Set or reset the weewoo channel\n`" + prefix + "setnotifyformat <format>` Changes the notification format (`%type%` -> `walls/buffers`)\n`" + prefix + "setweewooformat <format>` Changes the weewoo format\n`" +
prefix + "setmemberrole <@role/role name/role id>` Changes the *lowest* member role\n__Member role only__\n`" +
prefix + "checkleaderboard` Wall & buffer check leaderboard\n`" +
prefix + "weewoo <start/stop>` Starts/stops the weewoo\n`" +
prefix + "settings` Displays the current settings")).queue();
}
}
private void fstats(GuildMessageReceivedEvent event, String content, String prefix) {
if (!content.contains(" ")) {
event.getChannel().sendMessage((":x: Usage, `" + prefix + "fstats <faction name>`")).queue();
return;
}
String[] args = content.split(" ");
Faction faction = Factions.getInstance().getByTag(args[1]);
if (faction == null) {
event.getChannel().sendMessage(":x: Faction not found").queue();
return;
}
EmbedBuilder embedBuilder = new EmbedBuilder().setColor(Color.MAGENTA).setTitle("Faction Stats").setAuthor(ChatColor.stripColor(faction.getTag())).addField("Description", faction.getDescription(), false).addField("Players Online", String.valueOf(faction.getOnlinePlayers().size()), true).addField("Total players", String.valueOf(faction.getFPlayers().size()), true).addField("Alts", String.valueOf(faction.getAltPlayers().size()), true).addField("Land", String.valueOf(faction.getLandRounded()), true).addField("Power", faction.getPowerRounded() + "/" + faction.getPowerMaxRounded(), true);
Faction guildFaction = this.getFaction(event.getGuild());
if (guildFaction != null && guildFaction.getId().equals(faction.getId()) && this.canAccessRole(guildFaction, event.getMember())) {
embedBuilder.addField("Kills", String.valueOf(faction.getKills()), true).addField("Points", String.valueOf(faction.getPoints()), true).addField("Deaths", String.valueOf(faction.getDeaths()), true);
}
event.getChannel().sendMessage(embedBuilder.build()).queue();
}
private void stats(GuildMessageReceivedEvent event, String content, String prefix) {
if (!content.contains(" ")) {
event.getChannel().sendMessage((":x: Usage, `" + prefix + "stats <player name>`")).queue();
return;
}
String[] args = content.split(" ");
OfflinePlayer offlinePlayer = this.plugin.getServer().getOfflinePlayer(args[1]);
FPlayer fPlayer = FPlayers.getInstance().getByOfflinePlayer(offlinePlayer);
String role = fPlayer.getRole().toString();
role = role.substring(0, 1).toUpperCase() + role.substring(1).toLowerCase();
EmbedBuilder embedBuilder = new EmbedBuilder().setColor(Color.MAGENTA).setTitle("Player Stats").setAuthor(offlinePlayer.getName(), null, Conf.avatarUrl.replace("%uuid%", offlinePlayer.getUniqueId().toString())).addField("Balance", this.decimalFormat.format(this.plugin.getEcon().getBalance(offlinePlayer)), false).addField("Faction", ChatColor.stripColor(fPlayer.getFaction().getTag()), true).addField("Faction Role", role, true).addField("Power", fPlayer.getPower() + "/" + fPlayer.getPowerMax(), true).addField("Online", offlinePlayer.isOnline() ? "Yes" : "No", true);
Faction faction = this.getFaction(event.getGuild());
if (faction != null && fPlayer.getFactionId().equals(faction.getId())) {
embedBuilder.addField("Wall checks", String.valueOf(faction.getPlayerWallCheckCount().getOrDefault(offlinePlayer.getUniqueId(), 0)), true).addField("Buffer checks", String.valueOf(faction.getPlayerBufferCheckCount().getOrDefault(offlinePlayer.getUniqueId(), 0)), true).addField("Kills", String.valueOf(fPlayer.getKills()), true).addField("Deaths", String.valueOf(fPlayer.getDeaths()), true);
}
event.getChannel().sendMessage(embedBuilder.build()).queue();
}
private void setPrefix(GuildMessageReceivedEvent event, String content) {
if (this.cantAccessPermissionWithWarning(event.getChannel(), event.getMember())) {
return;
}
String[] split = content.split(" ");
if (split.length != 3) {
event.getChannel().sendMessage((":x: Usage, `@" + event.getGuild().getSelfMember().getEffectiveName() + " setprefix <prefix>`")).queue();
return;
}
String newPrefix = split[2];
if (newPrefix.length() > 16) {
event.getChannel().sendMessage(":x: Prefix may not be longer than 16 characters").queue();
return;
}
DiscordListener.guilds.getGuildById(event.getGuild().getId()).setPrefix(newPrefix);
event.getMessage().addReaction("\u2705").queue();
}
private void setFChatChannel(GuildMessageReceivedEvent event) {
Faction faction = this.getFactionWithWarning(event.getChannel());
if (faction == null) {
return;
}
if (this.cantAccessPermissionWithWarning(event.getChannel(), event.getMember())) {
return;
}
List<TextChannel> mentionedChannels = event.getMessage().getMentionedChannels();
if (mentionedChannels.isEmpty()) {
faction.setFactionChatChannelId(null);
event.getChannel().sendMessage("Cleared fchat channel").queue();
} else {
TextChannel textChannel = mentionedChannels.get(0);
if (!event.getGuild().getSelfMember().hasPermission(textChannel, Permission.MESSAGE_READ, Permission.MESSAGE_WRITE)) {
event.getChannel().sendMessage((":x: Missing read/write permission in " + textChannel.getAsMention())).queue();
return;
}
faction.setFactionChatChannelId(textChannel.getId());
event.getChannel().sendMessage(("New fchat channel set to " + textChannel.getAsMention())).queue();
}
}
private void setWallNotifyChannel(GuildMessageReceivedEvent event) {
Faction faction = this.getFactionWithWarning(event.getChannel());
if (faction == null) {
return;
}
if (this.cantAccessPermissionWithWarning(event.getChannel(), event.getMember())) {
return;
}
List<TextChannel> mentionedChannels = event.getMessage().getMentionedChannels();
if (mentionedChannels.isEmpty()) {
faction.setWallNotifyChannelId(null);
event.getChannel().sendMessage("Cleared wall notify channel").queue();
} else {
TextChannel textChannel = mentionedChannels.get(0);
if (!event.getGuild().getSelfMember().hasPermission(textChannel, Permission.MESSAGE_READ, Permission.MESSAGE_WRITE)) {
event.getChannel().sendMessage((":x: Missing read/write permission in " + textChannel.getAsMention())).queue();
return;
}
faction.setWallNotifyChannelId(textChannel.getId());
event.getChannel().sendMessage(("New wall notify channel set to " + textChannel.getAsMention())).queue();
}
}
private void setBufferNotifyChannel(GuildMessageReceivedEvent event) {
Faction faction = this.getFactionWithWarning(event.getChannel());
if (faction == null) {
return;
}
if (this.cantAccessPermissionWithWarning(event.getChannel(), event.getMember())) {
return;
}
List<TextChannel> mentionedChannels = event.getMessage().getMentionedChannels();
if (mentionedChannels.isEmpty()) {
faction.setBufferNotifyChannelId(null);
event.getChannel().sendMessage("Cleared buffer notify channel").queue();
} else {
TextChannel textChannel = mentionedChannels.get(0);
if (!event.getGuild().getSelfMember().hasPermission(textChannel, Permission.MESSAGE_READ, Permission.MESSAGE_WRITE)) {
event.getChannel().sendMessage((":x: Missing read/write permission in " + textChannel.getAsMention())).queue();
return;
}
faction.setBufferNotifyChannelId(textChannel.getId());
event.getChannel().sendMessage(("New buffer notify channel set to " + textChannel.getAsMention())).queue();
}
}
private void setWeewooChannel(GuildMessageReceivedEvent event) {
Faction faction = this.getFactionWithWarning(event.getChannel());
if (faction == null) {
return;
}
if (!event.getMember().hasPermission(Permission.MANAGE_SERVER)) {
event.getChannel().sendMessage(":x: You need to have the Manage Server permission to do that").queue();
return;
}
List<TextChannel> mentionedChannels = event.getMessage().getMentionedChannels();
if (mentionedChannels.isEmpty()) {
faction.setWeeWooChannelId(null);
event.getChannel().sendMessage("Cleared weewoo channel").queue();
} else {
TextChannel textChannel = mentionedChannels.get(0);
if (!event.getGuild().getSelfMember().hasPermission(textChannel, Permission.MESSAGE_READ, Permission.MESSAGE_WRITE)) {
event.getChannel().sendMessage((":x: Missing read/write permission in " + textChannel.getAsMention())).queue();
return;
}
faction.setWeeWooChannelId(textChannel.getId());
event.getChannel().sendMessage(("New weewoo channel set to " + textChannel.getAsMention())).queue();
}
}
private void setNotifyFormat(GuildMessageReceivedEvent event, String content, String prefix) {
Faction faction = this.getFactionWithWarning(event.getChannel());
if (faction == null) {
return;
}
if (this.cantAccessPermissionWithWarning(event.getChannel(), event.getMember())) {
return;
}
if (!content.contains(" ")) {
event.getChannel().sendMessage((":x: Usage, `" + prefix + "setnotifyformat <format>` (%type%)")).queue();
return;
}
List<String> arguments = new ArrayList<>(Arrays.asList(content.split(" ")));
arguments.remove(0);
String format = String.join(" ", arguments);
if (format.length() > 1000) {
event.getChannel().sendMessage(":x: The notify format may not be longer than 1000 characters").queue();
return;
}
faction.setNotifyFormat(format);
event.getChannel().sendMessage(("New notify format set to `" + format + "`")).queue();
}
private void setWeewooFormat(GuildMessageReceivedEvent event, String content, String prefix) {
Faction faction = this.getFactionWithWarning(event.getChannel());
if (faction == null) {
return;
}
if (this.cantAccessPermissionWithWarning(event.getChannel(), event.getMember())) {
return;
}
if (!content.contains(" ")) {
event.getChannel().sendMessage((":x: Usage, `" + prefix + "setweewooformat <format>`")).queue();
return;
}
List<String> arguments = new ArrayList<>(Arrays.asList(content.split(" ")));
arguments.remove(0);
String format = String.join(" ", arguments);
if (format.length() > 1000) {
event.getChannel().sendMessage(":x: The weewoo format may not be longer than 1000 characters").queue();
return;
}
faction.setWeeWooFormat(format);
event.getChannel().sendMessage(("New weewoo format set to `" + format + "`")).queue();
}
private void setMemberRole(GuildMessageReceivedEvent event, String content, String prefix) {
Faction faction = this.getFactionWithWarning(event.getChannel());
if (faction == null) {
return;
}
if (this.cantAccessPermissionWithWarning(event.getChannel(), event.getMember())) {
return;
}
List<String> split = new ArrayList<>(Arrays.asList(content.split(" ")));
if (split.size() < 2) {
event.getChannel().sendMessage((":x: Usage, `" + prefix + "setmemberrole <@role/role name/role id>`")).queue();
return;
}
split.remove(0);
Role role = event.getMessage().getMentionedRoles().stream().findFirst().orElse(null);
if (role == null) {
role = event.getGuild().getRolesByName(String.join(" ", split), true).stream().findAny().orElse(null);
}
if (role == null) {
try {
role = event.getGuild().getRoleById(split.get(0));
} catch (NumberFormatException ex) {
}
}
if (role == null) {
event.getChannel().sendMessage(":x: Role not found").queue();
return;
}
faction.setMemberRoleId(role.getId());
event.getChannel().sendMessage(("New *lowest* member role set to `" + role.getName() + "`")).queue();
}
private void checkLeaderboard(GuildMessageReceivedEvent event) {
Faction faction = this.getFactionWithWarning(event.getChannel());
if (faction == null) {
return;
}
if (this.cantAccessRoleWithWarning(event.getChannel(), faction, event.getMember())) {
return;
}
Map<UUID, Integer> players = new HashMap<>();
for (Map.Entry<UUID, Integer> entry : faction.getPlayerWallCheckCount().entrySet()) {
players.put(entry.getKey(), entry.getValue());
}
for (Map.Entry<UUID, Integer> entry : faction.getPlayerBufferCheckCount().entrySet()) {
if (players.containsKey(entry.getKey())) {
players.replace(entry.getKey(), players.get(entry.getKey()) + entry.getValue());
} else {
players.put(entry.getKey(), entry.getValue());
}
}
List<Map.Entry<UUID, Integer>> entryList = players.entrySet().stream().sorted(Comparator.comparingInt(Map.Entry::getValue)).collect(Collectors.toList());
EmbedBuilder embedBuilder = new EmbedBuilder().setTitle("Check Leaderboard").setColor(Color.MAGENTA);
StringBuilder stringBuilder = new StringBuilder();
for (int max = (entryList.size() > 10) ? 10 : entryList.size(), current = 0; current < max; ++current) {
Map.Entry<UUID, Integer> entry2 = entryList.get(current);
OfflinePlayer offlinePlayer = this.plugin.getServer().getOfflinePlayer(entry2.getKey());
stringBuilder.append("**").append(current + 1).append(".** ").append(offlinePlayer.getName()).append(" __").append(entry2.getValue()).append(" Total (").append(faction.getPlayerBufferCheckCount().getOrDefault(entry2.getKey(), 0)).append(" Buffer, ").append(faction.getPlayerWallCheckCount().getOrDefault(entry2.getKey(), 0)).append(" Wall)__\n");
}
if (entryList.isEmpty()) {
stringBuilder.append("_No data_");
}
event.getChannel().sendMessage(embedBuilder.setDescription(stringBuilder.toString()).build()).queue();
}
private void weewoo(GuildMessageReceivedEvent event, String content, String prefix) {
Faction faction = this.getFactionWithWarning(event.getChannel());
if (faction == null) {
return;
}
if (this.cantAccessRoleWithWarning(event.getChannel(), faction, event.getMember())) {
return;
}
if (!content.contains(" ")) {
event.getChannel().sendMessage((":x: Usage, `" + prefix + "weewoo <start/stop>`")).queue();
return;
}
List<String> arguments = new ArrayList<>(Arrays.asList(content.split(" ")));
boolean weeWoo = faction.isWeeWoo();
if (arguments.get(1).equalsIgnoreCase("start")) {
if (weeWoo) {
event.getChannel().sendMessage(TL.WEEWOO_ALREADY_STARTED_DISCORD.toString()).queue();
return;
}
faction.setWeeWoo(true);
event.getMessage().addReaction("\u2705").queue();
faction.msg(TL.COMMAND_WEEWOO_STARTED, event.getAuthor().getAsTag());
String discordChannelId = faction.getWeeWooChannelId();
if (discordChannelId != null && !discordChannelId.isEmpty()) {
TextChannel textChannel = event.getJDA().getTextChannelById(discordChannelId);
if (textChannel == null) {
return;
}
textChannel.sendMessage(TL.WEEWOO_STARTED_DISCORD.format(event.getAuthor().getAsTag())).queue();
}
} else if (arguments.get(1).equalsIgnoreCase("stop")) {
if (!weeWoo) {
event.getChannel().sendMessage(TL.WEEWOO_ALREADY_STOPPED_DISCORD.toString()).queue();
return;
}
faction.setWeeWoo(false);
event.getMessage().addReaction("\u2705").queue();
faction.msg(TL.COMMAND_WEEWOO_STARTED, event.getAuthor().getAsTag());
String discordChannelId = faction.getWeeWooChannelId();
if (discordChannelId != null && !discordChannelId.isEmpty()) {
TextChannel textChannel = event.getJDA().getTextChannelById(discordChannelId);
if (textChannel == null) {
return;
}
textChannel.sendMessage(TL.WEEWOO_STOPPED_DISCORD.format(event.getAuthor().getAsTag())).queue();
}
} else {
event.getChannel().sendMessage(":x: Usage, `.weewoo <start/stop>`").queue();
}
}
private void settings(GuildMessageReceivedEvent event) {
Faction faction = this.getFactionWithWarning(event.getChannel());
if (faction == null) {
return;
}
if (this.cantAccessRoleWithWarning(event.getChannel(), faction, event.getMember())) {
return;
}
int wallCheck = faction.getWallCheckMinutes();
int bufferCheck = faction.getBufferCheckMinutes();
String wallChannel = faction.getWallNotifyChannelId();
String bufferChannel = faction.getBufferNotifyChannelId();
String weeWooChannel = faction.getWeeWooChannelId();
String fChatChannel = faction.getFactionChatChannelId();
MessageEmbed embed = new EmbedBuilder().setTitle("Settings").setColor(Color.MAGENTA).addField("WeeWoo channel", (weeWooChannel != null && !weeWooChannel.isEmpty()) ? ("<#" + weeWooChannel + ">") : "None", true).addField("Wall check channel", (wallChannel != null && !wallChannel.isEmpty()) ? ("<#" + wallChannel + ">") : "None", true).addField("Buffer check channel", (bufferChannel != null && !bufferChannel.isEmpty()) ? ("<#" + bufferChannel + ">") : "None", true).addField("Faction Chat channel", (fChatChannel != null && !fChatChannel.isEmpty()) ? ("<#" + fChatChannel + ">") : "None", true).addField("Wall check notifications", (wallCheck <= 0) ? "Offline" : (wallCheck + " Minutes"), true).addField("Buffer check notifications", (bufferCheck <= 0) ? "Offline" : (bufferCheck + " Minutes"), true).addField("Notify format", "`" + faction.getNotifyFormat() + "`", false).addField("WeeWoo format", "`" + faction.getWeeWooFormat() + "`", false).build();
event.getChannel().sendMessage(embed).queue();
}
}

View File

@@ -0,0 +1,123 @@
package com.massivecraft.factions.discord;
import com.massivecraft.factions.Conf;
import com.massivecraft.factions.Faction;
import com.massivecraft.factions.Factions;
import com.massivecraft.factions.FactionsPlugin;
import mkremins.fanciful.FancyMessage;
import net.dv8tion.jda.core.AccountType;
import net.dv8tion.jda.core.JDA;
import net.dv8tion.jda.core.JDABuilder;
import net.dv8tion.jda.core.Permission;
import net.dv8tion.jda.core.entities.Message;
import net.dv8tion.jda.core.entities.TextChannel;
import net.dv8tion.jda.core.entities.User;
import net.dv8tion.jda.core.entities.Webhook;
import net.dv8tion.jda.core.events.message.guild.GuildMessageReceivedEvent;
import net.dv8tion.jda.core.hooks.ListenerAdapter;
import net.dv8tion.jda.webhook.WebhookClient;
import net.dv8tion.jda.webhook.WebhookMessage;
import net.dv8tion.jda.webhook.WebhookMessageBuilder;
import org.bukkit.ChatColor;
import javax.security.auth.login.LoginException;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.List;
import java.util.UUID;
public class FactionChatHandler extends ListenerAdapter {
public static JDA jda;
private FactionsPlugin plugin;
public FactionChatHandler(FactionsPlugin plugin) {
this.plugin = plugin;
startBot();
jda.addEventListener(this);
jda.addEventListener(new DiscordListener(plugin));
}
private void startBot() {
try {
jda = new JDABuilder(AccountType.BOT).setToken(Conf.discordBotToken).buildBlocking();
if(jda == null) {
System.out.println("\n\n\n SABER-FACTIONS-DISCORD-INTEGRATION - Please Make a Valid Token To Use Discord Features! Location Conf.json discordBotToken.\n\n\n");
}
} catch (LoginException | InterruptedException e) {
e.printStackTrace();
}
}
public static void sendMessage(FactionsPlugin plugin, Faction faction, UUID uuid, String username, String message) {
String factionsChatChannelId = faction.getFactionChatChannelId();
String messageWithMentions = null;
if (factionsChatChannelId == null || factionsChatChannelId.isEmpty()) {
return;
}
if (jda == null) {
return;
}
TextChannel textChannel = jda.getTextChannelById(factionsChatChannelId);
if (textChannel == null) {
return;
}
if (!textChannel.getGuild().getSelfMember().hasPermission(textChannel, Permission.MANAGE_WEBHOOKS)) {
textChannel.sendMessage("Missing `Manage Webhooks` permission in this channel").queue();
return;
}
Webhook webhook = (textChannel.getWebhooks().complete()).stream().filter(w -> w.getName().equals(Conf.webhookName)).findAny().orElse(null);
WebhookClient webhookClient;
if (webhook != null) {
webhookClient = webhook.newClient().build();
} else {
webhookClient = textChannel.createWebhook(Conf.webhookName).complete().newClient().build();
}
if (message.contains("@")) {
List<String> x = new ArrayList<>(Arrays.asList(message.split(" ")));
for (String y : x) {
if (y.contains("@")) {
if (!jda.getUsersByName(y.replace("@", ""), false).isEmpty() && jda.getUsersByName(y.replace("@", ""), false).size() < 2) {
x.set(x.indexOf(y), jda.getUsersByName(y.replace("@", ""), false).get(0).getAsMention());
}
}
}
StringBuilder sB = new StringBuilder();
for (String s : x) {
sB.append(s);
sB.append(" ");
}
messageWithMentions = sB.toString();
}
if (messageWithMentions != null) {
WebhookMessage webhookMessage = new WebhookMessageBuilder().setUsername(ChatColor.stripColor(username)).setAvatarUrl(Conf.avatarUrl.replace("%uuid%", uuid.toString())).setContent(ChatColor.stripColor(messageWithMentions)).build();
webhookClient.send(webhookMessage).join();
webhookClient.close();
return;
}
WebhookMessage webhookMessage = new WebhookMessageBuilder().setUsername(ChatColor.stripColor(username)).setAvatarUrl(Conf.avatarUrl.replace("%uuid%", uuid.toString())).setContent(ChatColor.stripColor(message)).build();
webhookClient.send(webhookMessage).join();
webhookClient.close();
}
@Override
public void onGuildMessageReceived(GuildMessageReceivedEvent event) {
if (event.isWebhookMessage() || event.getAuthor().isBot()) {
return;
}
Faction faction = Factions.getInstance().getAllFactions().stream().filter(f -> event.getChannel().getId().equals(f.getFactionChatChannelId())).findAny().orElse(null);
if (faction == null) {
return;
}
String content = event.getMessage().getContentDisplay();
String message = (content.length() > 500) ? content.substring(0, 500) : content;
FancyMessage fancyMessage = new FancyMessage();
fancyMessage.text(ChatColor.translateAlternateColorCodes('&', Conf.fromDiscordFactionChatPrefix + String.format(Conf.factionChatFormat, event.getAuthor().getAsTag(), message)));
List<FancyMessage> messages = new ArrayList<>();
messages.add(fancyMessage);
for (Message.Attachment attachment : event.getMessage().getAttachments()) {
messages.add(new FancyMessage().text(" [Attachment]").color(ChatColor.AQUA).link(attachment.getUrl()).tooltip(attachment.getFileName()));
}
plugin.getServer().getScheduler().runTask(plugin, () -> messages.forEach(msg -> faction.getOnlinePlayers().forEach(fancyMessage::send)));
}
}

View File

@@ -0,0 +1,18 @@
package com.massivecraft.factions.discord.json;
public class JSONGuild {
private String prefix;
public JSONGuild() {
this.prefix = null;
}
public String getPrefix() {
return this.prefix;
}
public void setPrefix(final String prefix) {
this.prefix = prefix;
}
}

View File

@@ -0,0 +1,26 @@
package com.massivecraft.factions.discord.json;
import java.util.Map;
import java.util.concurrent.ConcurrentHashMap;
public class JSONGuilds {
private Map<String, JSONGuild> guilds;
public JSONGuilds() {
this.guilds = new ConcurrentHashMap<>();
}
public JSONGuild getGuildById(String id) {
JSONGuild[] newGuild = new JSONGuild[1];
return guilds.computeIfAbsent(id, i -> {
newGuild[0] = new JSONGuild();
guilds.put(i, newGuild[0]);
return newGuild[0];
});
}
public Map<String, JSONGuild> getAllGuilds() {
return this.guilds;
}
}

View File

@@ -37,7 +37,7 @@ public class EssentialsHomeHandler implements Listener {
Faction factionAt = Board.getInstance().getFactionAt(floc); Faction factionAt = Board.getInstance().getFactionAt(floc);
if (factionAt.equals(faction) && factionAt.isNormal()) { if (factionAt.equals(faction) && factionAt.isNormal()) {
user.delHome(homeName); user.delHome(homeName);
FactionsPlugin.getInstance().log(Level.INFO, "FactionLeaveEvent: Removing home %s, player %s, in territory of %s", homeName, event.getfPlayer().getName(), faction.getTag()); FactionsPlugin.getInstance().log(Level.INFO, "Removing home %s, player %s, in territory of %s", homeName, event.getfPlayer().getName(), faction.getTag());
} }
} }
} }

View File

@@ -101,9 +101,6 @@ public class FactionsBlockListener implements Listener {
return false; return false;
} }
public static boolean graceisEnabled() {
return Conf.gracePeriod;
}
private static boolean CheckPlayerAccess(Player player, FPlayer me, FLocation loc, Faction myFaction, Access access, PermissableAction action, boolean shouldHurt) { private static boolean CheckPlayerAccess(Player player, FPlayer me, FLocation loc, Faction myFaction, Access access, PermissableAction action, boolean shouldHurt) {
boolean landOwned = (myFaction.doesLocationHaveOwnersSet(loc) && !myFaction.getOwnerList(loc).isEmpty()); boolean landOwned = (myFaction.doesLocationHaveOwnersSet(loc) && !myFaction.getOwnerList(loc).isEmpty());
@@ -155,6 +152,14 @@ public class FactionsBlockListener implements Listener {
if (!playerCanBuildDestroyBlock(event.getPlayer(), event.getBlock().getLocation(), "build", false)) { if (!playerCanBuildDestroyBlock(event.getPlayer(), event.getBlock().getLocation(), "build", false)) {
event.setCancelled(true); event.setCancelled(true);
return;
}
if (event.getBlock().getType().equals(XMaterial.SPAWNER.parseMaterial())) {
if (Conf.spawnerLock) {
event.setCancelled(true);
event.getPlayer().sendMessage(FactionsPlugin.getInstance().color(TL.COMMAND_SPAWNER_LOCK_CANNOT_PLACE.toString()));
}
} }
} }
@@ -259,7 +264,6 @@ public class FactionsBlockListener implements Listener {
@EventHandler @EventHandler
public void onHopperPlace(BlockPlaceEvent e) { public void onHopperPlace(BlockPlaceEvent e) {
if (e.getItemInHand().getType() != Material.HOPPER && !FactionsPlugin.getInstance().getConfig().getBoolean("fvault.No-Hoppers-near-vault")) { if (e.getItemInHand().getType() != Material.HOPPER && !FactionsPlugin.getInstance().getConfig().getBoolean("fvault.No-Hoppers-near-vault")) {
return; return;
} }
@@ -327,6 +331,21 @@ public class FactionsBlockListener implements Listener {
} }
} }
@EventHandler
public void onBannerBreak(BlockBreakEvent e) {
FPlayer fme = FPlayers.getInstance().getByPlayer(e.getPlayer());
if (FactionsPlugin.getInstance().mc17) {
return;
}
if (bannerLocations.containsValue(e.getBlock().getLocation())) {
if (e.getBlock().getType().name().contains("BANNER")) {
e.setCancelled(true);
fme.msg(TL.BANNER_CANNOT_BREAK);
}
}
}
@EventHandler @EventHandler
public void onBannerPlace(BlockPlaceEvent e) { public void onBannerPlace(BlockPlaceEvent e) {
if (FactionsPlugin.getInstance().mc17) { if (FactionsPlugin.getInstance().mc17) {
@@ -455,35 +474,28 @@ public class FactionsBlockListener implements Listener {
//Grace //Grace
@EventHandler @EventHandler
public void onBreak(EntityExplodeEvent e) { public void onBreak(EntityExplodeEvent e) {
if (!FactionsPlugin.getInstance().getConfig().getBoolean("f-grace.Enabled")) if (!Conf.gracePeriod) return;
return;
if (!graceisEnabled()) {
e.setCancelled(true); e.setCancelled(true);
} }
}
@EventHandler @EventHandler
public void entityDamage(EntityDamageEvent e) { public void entityDamage(EntityDamageEvent e) {
if (!FactionsPlugin.getInstance().getConfig().getBoolean("f-grace.Enabled")) if (!Conf.gracePeriod) return;
return;
if (!graceisEnabled()) {
if (e.getEntity() instanceof Player) { if (e.getEntity() instanceof Player) {
if (e.getCause() == EntityDamageEvent.DamageCause.PROJECTILE) { if (e.getCause() == EntityDamageEvent.DamageCause.PROJECTILE) {
e.setCancelled(true); e.setCancelled(true);
} }
} }
} }
}
@EventHandler @EventHandler
public void onTNTPlace(BlockPlaceEvent e1) { public void onTNTPlace(BlockPlaceEvent e1) {
FPlayer fp = FPlayers.getInstance().getByPlayer(e1.getPlayer()); FPlayer fp = FPlayers.getInstance().getByPlayer(e1.getPlayer());
if (!FactionsPlugin.getInstance().getConfig().getBoolean("f-grace.Enabled")) if (!Conf.gracePeriod) return;
return;
if (!graceisEnabled() && !fp.isAdminBypassing()) { if (!fp.isAdminBypassing()) {
if (e1.getBlock().getType().equals(Material.TNT)) { if (e1.getBlock().getType().equals(Material.TNT)) {
e1.setCancelled(true); e1.setCancelled(true);

View File

@@ -1,6 +1,7 @@
package com.massivecraft.factions.listeners; package com.massivecraft.factions.listeners;
import com.massivecraft.factions.*; import com.massivecraft.factions.*;
import com.massivecraft.factions.discord.FactionChatHandler;
import com.massivecraft.factions.struct.ChatMode; import com.massivecraft.factions.struct.ChatMode;
import com.massivecraft.factions.struct.Relation; import com.massivecraft.factions.struct.Relation;
import com.massivecraft.factions.struct.Role; import com.massivecraft.factions.struct.Role;
@@ -82,7 +83,7 @@ public class FactionsChatListener implements Listener {
fplayer.sendMessage("[FCspy] " + myFaction.getTag() + ": " + message); fplayer.sendMessage("[FCspy] " + myFaction.getTag() + ": " + message);
} }
} }
FactionChatHandler.sendMessage(FactionsPlugin.getInstance(), myFaction, me.getPlayer().getUniqueId(), me.getPlayer().getName(), event.getMessage());
event.setCancelled(true); event.setCancelled(true);
} else if (chat == ChatMode.ALLIANCE) { } else if (chat == ChatMode.ALLIANCE) {
Faction myFaction = me.getFaction(); Faction myFaction = me.getFaction();

View File

@@ -32,6 +32,16 @@ public class FactionsEntityListener implements Listener {
private static final Set<PotionEffectType> badPotionEffects = new LinkedHashSet<>(Arrays.asList(PotionEffectType.BLINDNESS, PotionEffectType.CONFUSION, PotionEffectType.HARM, PotionEffectType.HUNGER, PotionEffectType.POISON, PotionEffectType.SLOW, PotionEffectType.SLOW_DIGGING, PotionEffectType.WEAKNESS, PotionEffectType.WITHER)); private static final Set<PotionEffectType> badPotionEffects = new LinkedHashSet<>(Arrays.asList(PotionEffectType.BLINDNESS, PotionEffectType.CONFUSION, PotionEffectType.HARM, PotionEffectType.HUNGER, PotionEffectType.POISON, PotionEffectType.SLOW, PotionEffectType.SLOW_DIGGING, PotionEffectType.WEAKNESS, PotionEffectType.WITHER));
@EventHandler
public void onCreeperGlitch(EntityDamageEvent e) {
if (!e.getEntity().getType().equals(EntityType.CREEPER)) {
return;
}
if (e.getCause().equals(EntityDamageEvent.DamageCause.DROWNING) || e.getCause().equals(EntityDamageEvent.DamageCause.SUFFOCATION)) {
e.getEntity().remove();
}
}
@EventHandler(priority = EventPriority.NORMAL) @EventHandler(priority = EventPriority.NORMAL)
public void onEntityDeath(EntityDeathEvent event) { public void onEntityDeath(EntityDeathEvent event) {
Entity entity = event.getEntity(); Entity entity = event.getEntity();

View File

@@ -288,19 +288,6 @@ public class FactionsPlayerListener implements Listener {
return false; return false;
} }
/// <summary>
/// This checks if the current player can execute an action based on it's factions access and surroundings
/// It will grant access in the following priorities:
/// - If Faction Land is Owned and the Owner is the current player, or player is faction leader.
/// - If Faction Land is not Owned and my access value is not set to DENY
/// - If none of the filters above matches, then we consider access is set to ALLOW|UNDEFINED
/// This check does not performs any kind of bypass check (i.e.: me.isAdminBypassing())
/// </summary>
/// <param name="player">The player entity which the check will be made upon</param>
/// <param name="me">The Faction player object related to the player</param>
/// <param name="loc">The World location where the action is being executed</param>
/// <param name="myFaction">The faction of the player being checked</param>
/// <param name="access">The current's faction access permission for the action</param>
private static boolean CheckPlayerAccess(Player player, FPlayer me, FLocation loc, Faction factionToCheck, Access access, PermissableAction action, boolean pain) { private static boolean CheckPlayerAccess(Player player, FPlayer me, FLocation loc, Faction factionToCheck, Access access, PermissableAction action, boolean pain) {
boolean doPain = pain && Conf.handleExploitInteractionSpam; boolean doPain = pain && Conf.handleExploitInteractionSpam;
if (access != null && access != Access.UNDEFINED) { if (access != null && access != Access.UNDEFINED) {
@@ -736,7 +723,8 @@ public class FactionsPlayerListener implements Listener {
} }
if (me.getAutoClaimFor() != null) { if (me.getAutoClaimFor() != null) {
me.attemptClaim(me.getAutoClaimFor(), event.getTo(), true); me.attemptClaim(me.getAutoClaimFor(), event.getTo(), true);
if (Conf.disableFlightOnFactionClaimChange && event.getPlayer().getGameMode() != GameMode.CREATIVE) CmdFly.disableFlight(me); if (Conf.disableFlightOnFactionClaimChange && event.getPlayer().getGameMode() != GameMode.CREATIVE)
CmdFly.disableFlight(me);
} else if (me.isAutoSafeClaimEnabled()) { } else if (me.isAutoSafeClaimEnabled()) {
if (!Permission.MANAGE_SAFE_ZONE.has(player)) { if (!Permission.MANAGE_SAFE_ZONE.has(player)) {
me.setIsAutoSafeClaimEnabled(false); me.setIsAutoSafeClaimEnabled(false);
@@ -805,9 +793,8 @@ public class FactionsPlayerListener implements Listener {
Player player = event.getPlayer(); Player player = event.getPlayer();
// Check if the material is bypassing protection // Check if the material is bypassing protection
if (block == null) return; // clicked in air, apparently if (block == null) return; // clicked in air, apparently
if(event.getItem() != null) { if (Conf.territoryBypassProtectedMaterials.contains(block.getType())) return;
if (Conf.territoryBypassProtectedMaterials.contains(event.getItem().getType())) return;
}
if (GetPermissionFromUsableBlock(event.getClickedBlock().getType()) != null) { if (GetPermissionFromUsableBlock(event.getClickedBlock().getType()) != null) {
if (!canPlayerUseBlock(player, block, false)) { if (!canPlayerUseBlock(player, block, false)) {
event.setCancelled(true); event.setCancelled(true);
@@ -824,6 +811,7 @@ public class FactionsPlayerListener implements Listener {
return; return;
} }
} }
if (event.getItem() == null) return; if (event.getItem() == null) return;
if (!playerCanUseItemHere(player, block.getLocation(), event.getItem().getType(), false)) { if (!playerCanUseItemHere(player, block.getLocation(), event.getItem().getType(), false)) {
event.setCancelled(true); event.setCancelled(true);
@@ -850,7 +838,6 @@ public class FactionsPlayerListener implements Listener {
&& event.hasItem() && event.getItem().getType() == XMaterial.BONE_MEAL.parseMaterial()) { && event.hasItem() && event.getItem().getType() == XMaterial.BONE_MEAL.parseMaterial()) {
if (!FactionsBlockListener.playerCanBuildDestroyBlock(event.getPlayer(), block.getLocation(), PermissableAction.BUILD.name(), true)) { if (!FactionsBlockListener.playerCanBuildDestroyBlock(event.getPlayer(), block.getLocation(), PermissableAction.BUILD.name(), true)) {
FPlayer me = FPlayers.getInstance().getById(event.getPlayer().getUniqueId().toString()); FPlayer me = FPlayers.getInstance().getById(event.getPlayer().getUniqueId().toString());
Faction otherFaction = Board.getInstance().getFactionAt(new FLocation(block.getLocation()));
Faction myFaction = me.getFaction(); Faction myFaction = me.getFaction();
me.msg(TL.ACTIONS_NOPERMISSION.toString().replace("{faction}", myFaction.getTag(me.getFaction())).replace("{action}", "use bone meal")); me.msg(TL.ACTIONS_NOPERMISSION.toString().replace("{faction}", myFaction.getTag(me.getFaction())).replace("{action}", "use bone meal"));

View File

@@ -55,6 +55,13 @@ public class MissionGUI implements FactionGUI {
if (section == null) { if (section == null) {
return; return;
} }
if(FactionsPlugin.getInstance().getConfig().getBoolean("DenyMissionsMoreThenOnce")) {
if (fPlayer.getFaction().getCompletedMissions().contains(missionName)) {
fPlayer.msg(TL.MISSION_ALREAD_COMPLETED);
return;
}
}
ConfigurationSection missionSection = section.getConfigurationSection("Mission"); ConfigurationSection missionSection = section.getConfigurationSection("Mission");
if (missionSection == null) { if (missionSection == null) {
return; return;

View File

@@ -5,14 +5,17 @@ import com.massivecraft.factions.FPlayers;
import com.massivecraft.factions.FactionsPlugin; import com.massivecraft.factions.FactionsPlugin;
import com.massivecraft.factions.zcore.util.TL; import com.massivecraft.factions.zcore.util.TL;
import org.bukkit.configuration.ConfigurationSection; import org.bukkit.configuration.ConfigurationSection;
import org.bukkit.entity.Player;
import org.bukkit.event.EventHandler; import org.bukkit.event.EventHandler;
import org.bukkit.event.EventPriority; import org.bukkit.event.EventPriority;
import org.bukkit.event.Listener; import org.bukkit.event.Listener;
import org.bukkit.event.block.BlockBreakEvent; import org.bukkit.event.block.BlockBreakEvent;
import org.bukkit.event.block.BlockPlaceEvent; import org.bukkit.event.block.BlockPlaceEvent;
import org.bukkit.event.entity.EntityBreedEvent; import org.bukkit.event.enchantment.EnchantItemEvent;
import org.bukkit.event.entity.EntityDeathEvent; import org.bukkit.event.entity.EntityDeathEvent;
import org.bukkit.event.entity.EntityTameEvent;
import org.bukkit.event.player.PlayerFishEvent; import org.bukkit.event.player.PlayerFishEvent;
import org.bukkit.event.player.PlayerItemConsumeEvent;
import java.util.List; import java.util.List;
import java.util.stream.Collectors; import java.util.stream.Collectors;
@@ -26,18 +29,18 @@ public class MissionHandler implements Listener {
} }
@EventHandler(priority = EventPriority.HIGHEST, ignoreCancelled = true) @EventHandler(priority = EventPriority.HIGHEST, ignoreCancelled = true)
public void onEntityBreed(EntityBreedEvent event) { public void onPlayerTame(EntityTameEvent event) {
if (event.getEntity() == null) { if (!(event.getOwner() instanceof Player)) {
return; return;
} }
FPlayer fPlayer = FPlayers.getInstance().getByPlayer(event.getEntity().getKiller()); FPlayer fPlayer = FPlayers.getInstance().getByPlayer((Player) event.getOwner());
if (fPlayer == null) { if (fPlayer == null) {
return; return;
} }
List<Mission> missions = fPlayer.getFaction().getMissions().values().stream().filter(mission -> mission.getType().equalsIgnoreCase("breed")).collect(Collectors.toList()); List<Mission> missions = fPlayer.getFaction().getMissions().values().stream().filter(mission -> mission.getType().equalsIgnoreCase("tame")).collect(Collectors.toList());
for (Mission mission2 : missions) { for (Mission mission2 : missions) {
ConfigurationSection section = plugin.getConfig().getConfigurationSection("Missions").getConfigurationSection(mission2.getName()); ConfigurationSection section = plugin.getConfig().getConfigurationSection("Missions").getConfigurationSection(mission2.getName());
if (!event.getEntityType().toString().equals(section.getConfigurationSection("Mission").getString("EntityType"))) { if (!event.getEntityType().toString().equals(section.getConfigurationSection("Mission").getString("EntityType")) && !section.getConfigurationSection("Mission").getString("EntityType").equalsIgnoreCase("ALL")) {
continue; continue;
} }
mission2.incrementProgress(); mission2.incrementProgress();
@@ -116,6 +119,37 @@ public class MissionHandler implements Listener {
} }
} }
@EventHandler
public void onPlayerEnchant(EnchantItemEvent e) {
FPlayer fPlayer = FPlayers.getInstance().getByPlayer(e.getEnchanter());
if (fPlayer == null) {
return;
}
List<Mission> missions = fPlayer.getFaction().getMissions().values().stream().filter(mission -> mission.getType().equalsIgnoreCase("enchant")).collect(Collectors.toList());
for (Mission mission2 : missions) {
ConfigurationSection section = plugin.getConfig().getConfigurationSection("Missions").getConfigurationSection(mission2.getName());
mission2.incrementProgress();
checkIfDone(fPlayer, mission2, section);
}
}
@EventHandler
public void onPlayerConsume(PlayerItemConsumeEvent e) {
FPlayer fPlayer = FPlayers.getInstance().getByPlayer(e.getPlayer());
if (fPlayer == null) {
return;
}
List<Mission> missions = fPlayer.getFaction().getMissions().values().stream().filter(mission -> mission.getType().equalsIgnoreCase("consume")).collect(Collectors.toList());
for (Mission mission2 : missions) {
ConfigurationSection section = plugin.getConfig().getConfigurationSection("Missions").getConfigurationSection(mission2.getName());
if (!e.getItem().toString().contains(section.getConfigurationSection("Mission").getString("Item")) && !section.getConfigurationSection("Mission").getString("Item").equalsIgnoreCase("ALL")) {
continue;
}
mission2.incrementProgress();
checkIfDone(fPlayer, mission2, section);
}
}
private void checkIfDone(FPlayer fPlayer, Mission mission, ConfigurationSection section) { private void checkIfDone(FPlayer fPlayer, Mission mission, ConfigurationSection section) {
if (mission.getProgress() < section.getConfigurationSection("Mission").getLong("Amount")) { if (mission.getProgress() < section.getConfigurationSection("Mission").getLong("Amount")) {
return; return;
@@ -125,5 +159,6 @@ public class MissionHandler implements Listener {
} }
fPlayer.getFaction().getMissions().remove(mission.getName()); fPlayer.getFaction().getMissions().remove(mission.getName());
fPlayer.getFaction().msg(TL.MISSION_MISSION_FINISHED, plugin.color(section.getString("Name"))); fPlayer.getFaction().msg(TL.MISSION_MISSION_FINISHED, plugin.color(section.getString("Name")));
fPlayer.getFaction().getCompletedMissions().add(mission.getName());
} }
} }

View File

@@ -24,7 +24,7 @@ public class CmdShop extends FCommand {
if (!FactionsPlugin.getInstance().getConfig().getBoolean("F-Shop.Enabled")) { if (!FactionsPlugin.getInstance().getConfig().getBoolean("F-Shop.Enabled")) {
return; return;
} }
ShopGUI.openShop(context.fPlayer); new ShopGUIFrame(context.faction).buildGUI(context.fPlayer);
} }
@Override @Override

View File

@@ -1,93 +0,0 @@
package com.massivecraft.factions.shop;
import com.massivecraft.factions.FPlayer;
import com.massivecraft.factions.FPlayers;
import com.massivecraft.factions.FactionsPlugin;
import com.massivecraft.factions.zcore.util.TL;
import org.bukkit.Bukkit;
import org.bukkit.ChatColor;
import org.bukkit.configuration.file.FileConfiguration;
import org.bukkit.entity.Player;
import org.bukkit.event.EventHandler;
import org.bukkit.event.Listener;
import org.bukkit.event.inventory.InventoryClickEvent;
import org.bukkit.inventory.Inventory;
import org.bukkit.inventory.ItemStack;
import java.util.List;
public class ShopClickPersistence implements Listener {
public static String color(String line) {
line = ChatColor.translateAlternateColorCodes('&', line);
return line;
}
public static List<String> colorList(List<String> lore) {
for (int i = 0; i <= lore.size() - 1; i++) {
lore.set(i, color(lore.get(i)));
}
return lore;
}
public void runCommands(List<String> list, Player p) {
for (String cmd : list) {
cmd = cmd.replace("%player%", p.getName());
Bukkit.dispatchCommand(Bukkit.getConsoleSender(), cmd);
}
}
@EventHandler
public void click(InventoryClickEvent e) {
Inventory i = e.getClickedInventory();
Player p = (Player) e.getWhoClicked();
FileConfiguration config = FactionsPlugin.getInstance().getConfig();
FPlayer fplayer = FPlayers.getInstance().getByPlayer(p);
if (e.getView().getTitle().equalsIgnoreCase(color(config.getString("F-Shop.GUI.Name")))) {
ItemStack item = e.getCurrentItem();
if (item == null) return;
String name = color(item.getItemMeta().getDisplayName());
e.setCancelled(true);
int t = e.getSlot();
int items = ShopConfig.getShop().getConfigurationSection("items").getKeys(false).size();
for (int a = 1; a <= items; a++) {
String s = a + "";
int slot = ShopConfig.getShop().getInt("items." + s + ".slot");
if (t == slot) {
String n = ShopConfig.getShop().getString("items." + s + ".name");
if (name.contains(color(n))) {
String c = ChatColor.stripColor(color(name));
c = c.replace(ChatColor.stripColor(color(n)), "");
c = c.replace(color(" ("), "");
c = c.replace(color(" Points)"), "");
int cost = Integer.parseInt(c);
if (fplayer.getFaction().getPoints() >= cost) {
fplayer.getFaction().setPoints(fplayer.getFaction().getPoints() - cost);
runCommands(ShopConfig.getShop().getStringList("items." + s + ".cmds"), fplayer.getPlayer());
for (FPlayer fplayerBuy : fplayer.getFaction().getFPlayers()) {
// if (fplayer == fme) { continue; } //Idk if I wanna not send the title to the player
fplayerBuy.getPlayer().sendMessage(TL.SHOP_BOUGHT_BROADCAST_FACTION.toString()
.replace("{player}", fplayer.getPlayer().getName())
.replace("{item}", name));
}
fplayer.sendMessage(color(ShopConfig.getShop().getString("prefix").replace("%item%", n).replace("%points%", cost + "")));
p.closeInventory();
} else {
fplayer.sendMessage(TL.SHOP_NOT_ENOUGH_POINTS.toString());
p.closeInventory();
}
} else {
e.setCancelled(true);
return;
}
}
}
}
}
}

View File

@@ -40,6 +40,7 @@ public class ShopConfig {
getShop().set("items.1.name", "&aTest Shop"); getShop().set("items.1.name", "&aTest Shop");
ArrayList lore = new ArrayList(); ArrayList lore = new ArrayList();
lore.add("&cFully Customizable Lore!"); lore.add("&cFully Customizable Lore!");
lore.add("&b&l{cost} &7Points");
getShop().set("items.1.lore", lore); getShop().set("items.1.lore", lore);
ArrayList t = new ArrayList(); ArrayList t = new ArrayList();
t.add("broadcast %player% bought Test Shop!"); t.add("broadcast %player% bought Test Shop!");

View File

@@ -1,100 +0,0 @@
package com.massivecraft.factions.shop;
import com.massivecraft.factions.FPlayer;
import com.massivecraft.factions.Faction;
import com.massivecraft.factions.FactionsPlugin;
import com.massivecraft.factions.util.XMaterial;
import org.bukkit.Bukkit;
import org.bukkit.ChatColor;
import org.bukkit.configuration.file.FileConfiguration;
import org.bukkit.enchantments.Enchantment;
import org.bukkit.inventory.Inventory;
import org.bukkit.inventory.ItemFlag;
import org.bukkit.inventory.ItemStack;
import org.bukkit.inventory.meta.ItemMeta;
import java.util.LinkedList;
import java.util.List;
public class ShopGUI {
/*
TODO: OOP Shop, and Clean it Up.
Made simplistic format for shop for the time being until I get time.
*/
public static void openShop(FPlayer p) {
FileConfiguration config = FactionsPlugin.getInstance().getConfig();
Faction fac = p.getFaction();
Inventory i = Bukkit.createInventory(null, FactionsPlugin.getInstance().getConfig().getInt("F-Shop.GUI.Size"), color(config.getString("F-Shop.GUI.Name")));
ItemStack glass = new ItemStack(XMaterial.BLACK_STAINED_GLASS_PANE.parseMaterial(), 1, (short) 7);
ItemMeta glassmeta = glass.getItemMeta();
glassmeta.setDisplayName(ChatColor.GOLD + " ");
glass.setItemMeta(glassmeta);
for (int fill = 0; fill < FactionsPlugin.getInstance().getConfig().getInt("F-Shop.GUI.Size"); ++fill) {
i.setItem(fill, glass);
}
int items = ShopConfig.getShop().getConfigurationSection("items").getKeys(false).size();
for (int shopitems = 1; shopitems <= items; shopitems++) {
String s = shopitems + "";
int slot = ShopConfig.getShop().getInt("items." + s + ".slot");
ItemStack material = XMaterial.matchXMaterial(ShopConfig.getShop().getString("items." + s + ".block")).parseItem();
// int size = ShopConfig.getShop().getInt("items." + s + ".size");
int cost = ShopConfig.getShop().getInt("items." + s + ".cost");
String name = ShopConfig.getShop().getString("items." + s + ".name") + " &f(" + cost + " Points)";
List<String> lore = ShopConfig.getShop().getStringList("items." + s + ".lore");
String command = ShopConfig.getShop().getString("items." + s + ".cmd");
String type = ShopConfig.getShop().getString("items." + s + ".type");
boolean glowing = ShopConfig.getShop().getBoolean("items." + s + ".glowing");
ItemStack count = new ItemStack(XMaterial.PAPER.parseMaterial(), 1);
ItemMeta countmeta = count.getItemMeta();
countmeta.setDisplayName(color(config.getString("F-Shop.GUI.Information.name")));
List<String> PointInfo = new LinkedList<>();
for (String list : config.getStringList("F-Shop.GUI.Information.lore")) {
PointInfo.add(list.replace("%points%", fac.getPoints() + ""));
}
countmeta.setLore(colorList(PointInfo));
count.setItemMeta(countmeta);
i.setItem(FactionsPlugin.getInstance().getConfig().getInt("F-Shop.GUI.Information.slot"), count);
ItemStack item = new ItemStack(material);
ItemMeta meta = item.getItemMeta();
meta.setDisplayName(color(name));
meta.addItemFlags();
if (glowing) {
meta.addItemFlags(ItemFlag.HIDE_ENCHANTS);
meta.addEnchant(Enchantment.DURABILITY, 1, true);
}
if (!glowing) {
meta.removeEnchant(Enchantment.DURABILITY);
}
if (lore.contains("")) {
meta.setLore(null);
} else {
meta.setLore(FactionsPlugin.getInstance().colorList(lore));
}
item.setItemMeta(meta);
i.setItem(slot, item);
}
p.getPlayer().openInventory(i);
}
public static String color(String line) {
line = ChatColor.translateAlternateColorCodes('&', line);
return line;
}
public static List<String> colorList(List<String> lore) {
for (int i = 0; i <= lore.size() - 1; i++) {
lore.set(i, color(lore.get(i)));
}
return lore;
}
}

View File

@@ -0,0 +1,117 @@
package com.massivecraft.factions.shop;
import com.github.stefvanschie.inventoryframework.Gui;
import com.github.stefvanschie.inventoryframework.GuiItem;
import com.github.stefvanschie.inventoryframework.pane.PaginatedPane;
import com.massivecraft.factions.FPlayer;
import com.massivecraft.factions.FPlayers;
import com.massivecraft.factions.Faction;
import com.massivecraft.factions.FactionsPlugin;
import com.massivecraft.factions.util.XMaterial;
import com.massivecraft.factions.zcore.util.TL;
import org.bukkit.Bukkit;
import org.bukkit.ChatColor;
import org.bukkit.Material;
import org.bukkit.configuration.ConfigurationSection;
import org.bukkit.enchantments.Enchantment;
import org.bukkit.entity.Player;
import org.bukkit.inventory.ItemFlag;
import org.bukkit.inventory.ItemStack;
import org.bukkit.inventory.meta.ItemMeta;
import java.util.ArrayList;
import java.util.List;
import java.util.stream.Collectors;
public class ShopGUIFrame {
private Gui gui;
private String s;
public ShopGUIFrame(Faction f) {
gui = new Gui(FactionsPlugin.getInstance(),
FactionsPlugin.getInstance().getConfig().getInt("F-Shop.GUI.Rows", 4),
FactionsPlugin.getInstance().color(FactionsPlugin.getInstance().getConfig().getString("F-Shop.GUI.Name")));
this.s = s;
}
public void buildGUI(FPlayer fplayer) {
PaginatedPane pane = new PaginatedPane(0, 0, 9, gui.getRows());
List<GuiItem> GUIItems = new ArrayList<>();
ItemStack dummy = buildDummyItem(fplayer.getFaction());
for (int x = 0; x <= (gui.getRows() * 9) - 1; x++) GUIItems.add(new GuiItem(dummy, e -> e.setCancelled(true)));
int items = ShopConfig.getShop().getConfigurationSection("items").getKeys(false).size();
for (int a = 1; a <= items; a++) {
String s = a + "";
int slot = ShopConfig.getShop().getInt("items." + s + ".slot");
Material material = XMaterial.matchXMaterial(ShopConfig.getShop().getString("items." + s + ".block")).parseMaterial();
int cost = ShopConfig.getShop().getInt("items." + s + ".cost");
String name = ShopConfig.getShop().getString("items." + s + ".name");
boolean glowing = ShopConfig.getShop().getBoolean("items." + s + ".glowing");
List<String> lore = ShopConfig.getShop().getStringList("items." + s + ".lore");
ItemStack item = new ItemStack(material);
ItemMeta meta = item.getItemMeta();
meta.setDisplayName(FactionsPlugin.instance.color(name));
meta.addItemFlags();
if (glowing) {
meta.addItemFlags(ItemFlag.HIDE_ENCHANTS);
meta.addEnchant(Enchantment.DURABILITY, 1, true);
}
if (!glowing) {
meta.removeEnchant(Enchantment.DURABILITY);
}
List<String> replacedLore = lore.stream().map(t -> t.replace("{cost}", cost + "")).collect(Collectors.toList());
meta.setLore(FactionsPlugin.instance.colorList(replacedLore));
item.setItemMeta(meta);
GUIItems.set(slot, new GuiItem(item, e -> {
e.setCancelled(true);
FPlayer fme = FPlayers.getInstance().getByPlayer((Player) e.getWhoClicked());
if (fplayer.getFaction().getPoints() >= cost) {
fplayer.getFaction().setPoints(fplayer.getFaction().getPoints() - cost);
runCommands(ShopConfig.getShop().getStringList("items." + s + ".cmds"), fplayer.getPlayer());
for (FPlayer fplayerBuy : fplayer.getFaction().getFPlayers()) {
fplayerBuy.getPlayer().sendMessage(TL.SHOP_BOUGHT_BROADCAST_FACTION.toString()
.replace("{player}", fplayer.getPlayer().getName())
.replace("{item}", ChatColor.stripColor(FactionsPlugin.getInstance().color(name)))
.replace("{cost}", cost + ""));
}
buildGUI(fme);
} else {
fplayer.msg(TL.SHOP_NOT_ENOUGH_POINTS);
}
}));
pane.populateWithGuiItems(GUIItems);
gui.addPane(pane);
gui.update();
gui.show(fplayer.getPlayer());
}
}
private ItemStack buildDummyItem(Faction f) {
ConfigurationSection config = FactionsPlugin.getInstance().getConfig().getConfigurationSection("F-Shop.GUI.dummy-item");
ItemStack item = XMaterial.matchXMaterial(config.getString("Type")).parseItem();
ItemMeta meta = item.getItemMeta();
if (meta != null) {
meta.setLore(FactionsPlugin.getInstance().colorList(config.getStringList("Lore")));
meta.setDisplayName(FactionsPlugin.getInstance().color(config.getString("Name").replace("{points}", f.getPoints() + "")));
item.setItemMeta(meta);
}
return item;
}
public void runCommands(List<String> list, Player p) {
for (String cmd : list) {
cmd = cmd.replace("%player%", p.getName());
Bukkit.dispatchCommand(Bukkit.getConsoleSender(), cmd);
}
}
}

View File

@@ -34,6 +34,7 @@ public enum Permission {
DESCRIPTION("description"), DESCRIPTION("description"),
DISBAND("disband"), DISBAND("disband"),
DISBAND_ANY("disband.any"), DISBAND_ANY("disband.any"),
DISCORD("discord"),
FLY("fly"), FLY("fly"),
FOCUS("focus"), FOCUS("focus"),
GLOBALCHAT("globalchat"), GLOBALCHAT("globalchat"),
@@ -50,6 +51,7 @@ public enum Permission {
LEAVE("leave"), LEAVE("leave"),
LIST("list"), LIST("list"),
LOCK("lock"), LOCK("lock"),
LOCKSPAWNERS("lockspawners"),
LOGOUT("logout"), LOGOUT("logout"),
MAP("map"), MAP("map"),
MAPHEIGHT("mapheight"), MAPHEIGHT("mapheight"),
@@ -73,6 +75,7 @@ public enum Permission {
OPEN("open"), OPEN("open"),
OWNER("owner"), OWNER("owner"),
OWNERLIST("ownerlist"), OWNERLIST("ownerlist"),
SET_GUILD("setguild"),
SET_PEACEFUL("setpeaceful"), SET_PEACEFUL("setpeaceful"),
SET_PERMANENT("setpermanent"), SET_PERMANENT("setpermanent"),
SET_PERMANENTPOWER("setpermanentpower"), SET_PERMANENTPOWER("setpermanentpower"),
@@ -89,6 +92,7 @@ public enum Permission {
RELOAD("reload"), RELOAD("reload"),
SAVE("save"), SAVE("save"),
SPAM("spam"), SPAM("spam"),
SETDISCORD("setdiscord"),
SETHOME("sethome"), SETHOME("sethome"),
SETHOME_ANY("sethome.any"), SETHOME_ANY("sethome.any"),
SETSTRIKES("setstrikes"), SETSTRIKES("setstrikes"),

View File

@@ -67,7 +67,14 @@ public enum FactionTag implements Tag {
return String.valueOf(fac.getFPlayersWhereOnline(true).size()); return String.valueOf(fac.getFPlayersWhereOnline(true).size());
} }
}), }),
OFFLINE_COUNT("{offline}", (fac) -> String.valueOf(fac.getFPlayers().size() - fac.getOnlinePlayers().size())), OFFLINE_COUNT("offline", (fac, fp) -> {
if (fp != null && fp.isOnline()) {
return String.valueOf(fac.getFPlayers().size() - fac.getFPlayersWhereOnline(true, fp).size());
} else {
// Only console should ever get here.
return String.valueOf(fac.getFPlayersWhereOnline(false).size());
}
}),
FACTION_SIZE("{members}", (fac) -> String.valueOf(fac.getFPlayers().size())), FACTION_SIZE("{members}", (fac) -> String.valueOf(fac.getFPlayers().size())),
FACTION_KILLS("{faction-kills}", (fac) -> String.valueOf(fac.getKills())), FACTION_KILLS("{faction-kills}", (fac) -> String.valueOf(fac.getKills())),
FACTION_DEATHS("{faction-deaths}", (fac) -> String.valueOf(fac.getDeaths())), FACTION_DEATHS("{faction-deaths}", (fac) -> String.valueOf(fac.getDeaths())),
@@ -118,18 +125,15 @@ public enum FactionTag implements Tag {
if (!this.foundInString(text)) { if (!this.foundInString(text)) {
return text; return text;
} }
if (this.biFunction == null) { String result = null;
return this.replace(text, faction); if (this.biFunction != null) {
result = this.function == null ? this.biFunction.apply(faction, player) : this.function.apply(faction);
} }
String result = this.biFunction.apply(faction, player);
return result == null ? null : text.replace(this.tag, result); return result == null ? null : text.replace(this.tag, result);
} }
public String replace(String text, Faction faction) { public String replace(String text, Faction faction) {
if (this.function == null || !this.foundInString(text)) { return this.replace(text, faction, null);
return text;
}
String result = this.function.apply(faction);
return result == null ? null : text.replace(this.tag, result);
} }
} }

View File

@@ -4,7 +4,9 @@ import com.massivecraft.factions.FPlayer;
import com.massivecraft.factions.integration.Econ; import com.massivecraft.factions.integration.Econ;
import com.massivecraft.factions.zcore.util.TL; import com.massivecraft.factions.zcore.util.TL;
import org.apache.commons.lang.time.DurationFormatUtils; import org.apache.commons.lang.time.DurationFormatUtils;
import org.bukkit.Bukkit;
import org.bukkit.ChatColor; import org.bukkit.ChatColor;
import org.bukkit.entity.Player;
import java.util.function.Function; import java.util.function.Function;
@@ -19,6 +21,19 @@ public enum PlayerTag implements Tag {
PLAYER_KILLS("{player-kills}", (fp) -> String.valueOf(fp.getKills())), PLAYER_KILLS("{player-kills}", (fp) -> String.valueOf(fp.getKills())),
PLAYER_DEATHS("{player-deaths}", (fp) -> String.valueOf(fp.getDeaths())), PLAYER_DEATHS("{player-deaths}", (fp) -> String.valueOf(fp.getDeaths())),
PLAYER_NAME("{name}", FPlayer::getName), PLAYER_NAME("{name}", FPlayer::getName),
TOTAL_ONLINE_VISIBLE("total-online-visible", (fp) -> {
if (fp == null) {
return String.valueOf(Bukkit.getOnlinePlayers().size());
}
int count = 0;
Player me = fp.getPlayer();
for (Player player : Bukkit.getOnlinePlayers()) {
if (me.canSee(player)) {
count++;
}
}
return String.valueOf(count);
}),
; ;
private final String tag; private final String tag;

View File

@@ -1,6 +1,8 @@
package com.massivecraft.factions.util; package com.massivecraft.factions.util;
import com.google.gson.*; import com.google.gson.*;
import com.massivecraft.factions.Conf;
import com.massivecraft.factions.FactionsPlugin;
import org.bukkit.inventory.Inventory; import org.bukkit.inventory.Inventory;
import java.lang.reflect.Type; import java.lang.reflect.Type;
@@ -20,8 +22,6 @@ public class InventoryTypeAdapter implements JsonSerializer<Inventory>, JsonDese
@Override @Override
public Inventory deserialize(JsonElement jsonElement, Type type, JsonDeserializationContext jsonDeserializationContext) { public Inventory deserialize(JsonElement jsonElement, Type type, JsonDeserializationContext jsonDeserializationContext) {
JsonObject object = jsonElement.getAsJsonObject(); JsonObject object = jsonElement.getAsJsonObject();
return InventoryUtil.fromBase64(object.get("contents").getAsString()); return InventoryUtil.fromBase64(object.get("contents").getAsString(), FactionsPlugin.getInstance().color(FactionsPlugin.getInstance().getConfig().getString("fchest.Inventory-Title")));
} }
} }

View File

@@ -1,5 +1,6 @@
package com.massivecraft.factions.util; package com.massivecraft.factions.util;
import com.massivecraft.factions.FactionsPlugin;
import org.bukkit.Bukkit; import org.bukkit.Bukkit;
import org.bukkit.inventory.Inventory; import org.bukkit.inventory.Inventory;
import org.bukkit.inventory.ItemStack; import org.bukkit.inventory.ItemStack;
@@ -71,11 +72,11 @@ public class InventoryUtil {
return toBase64(inventory); return toBase64(inventory);
} }
public static Inventory fromBase64(String data) { public static Inventory fromBase64(String data, String invName) {
try { try {
ByteArrayInputStream inputStream = new ByteArrayInputStream(Base64Coder.decodeLines(data)); ByteArrayInputStream inputStream = new ByteArrayInputStream(Base64Coder.decodeLines(data));
BukkitObjectInputStream dataInput = new BukkitObjectInputStream(inputStream); BukkitObjectInputStream dataInput = new BukkitObjectInputStream(inputStream);
Inventory inventory = Bukkit.getServer().createInventory(null, dataInput.readInt()); Inventory inventory = Bukkit.getServer().createInventory(null, dataInput.readInt(), FactionsPlugin.getInstance().color(invName));
// Read the serialized inventory // Read the serialized inventory
for (int i = 0; i < inventory.getSize(); i++) { for (int i = 0; i < inventory.getSize(); i++) {

View File

@@ -329,6 +329,6 @@ public abstract class MPlugin extends JavaPlugin {
} }
public void log(Level level, Object msg) { public void log(Level level, Object msg) {
getLogger().log(level, "[" + this.getDescription().getFullName() + "] " + msg); getLogger().log(level, "[" + this.getDescription().getVersion() + "] " + msg); // Full name is really ugly
} }
} }

View File

@@ -34,7 +34,8 @@ public class PermissableActionFrame {
List<GuiItem> GUIItems = new ArrayList<>(); List<GuiItem> GUIItems = new ArrayList<>();
ItemStack dumby = buildDummyItem(); ItemStack dumby = buildDummyItem();
// Fill background of GUI with dumbyitem & replace GUI assets after // Fill background of GUI with dumbyitem & replace GUI assets after
for (int x = 0; x <= (gui.getRows() * 9) - 1; x++) GUIItems.add(new GuiItem(dumby, e -> e.setCancelled(true))); for (int x = 0; x <= (gui.getRows() * 9) - 1; x++)
GUIItems.add(new GuiItem(dumby, e -> e.setCancelled(true)));
for (PermissableAction action : PermissableAction.values()) { for (PermissableAction action : PermissableAction.values()) {
if (action.getSlot() == -1) continue; if (action.getSlot() == -1) continue;
GUIItems.set(action.getSlot(), new GuiItem(action.buildAsset(fplayer, perm), e -> { GUIItems.set(action.getSlot(), new GuiItem(action.buildAsset(fplayer, perm), e -> {

View File

@@ -33,7 +33,8 @@ public class PermissableRelationFrame {
List<GuiItem> GUIItems = new ArrayList<>(); List<GuiItem> GUIItems = new ArrayList<>();
ItemStack dumby = buildDummyItem(); ItemStack dumby = buildDummyItem();
// Fill background of GUI with dumbyitem & replace GUI assets after // Fill background of GUI with dumbyitem & replace GUI assets after
for (int x = 0; x <= (gui.getRows() * 9) - 1; x++) GUIItems.add(new GuiItem(dumby, e -> e.setCancelled(true))); for (int x = 0; x <= (gui.getRows() * 9) - 1; x++)
GUIItems.add(new GuiItem(dumby, e -> e.setCancelled(true)));
ConfigurationSection sec = FactionsPlugin.getInstance().getConfig().getConfigurationSection("fperm-gui.relation"); ConfigurationSection sec = FactionsPlugin.getInstance().getConfig().getConfigurationSection("fperm-gui.relation");
for (String key : sec.getConfigurationSection("slots").getKeys(false)) { for (String key : sec.getConfigurationSection("slots").getKeys(false)) {
GUIItems.set(sec.getInt("slots." + key), new GuiItem(buildAsset("fperm-gui.relation.materials." + key, key), e -> { GUIItems.set(sec.getInt("slots." + key), new GuiItem(buildAsset("fperm-gui.relation.materials." + key, key), e -> {

View File

@@ -1,79 +0,0 @@
package com.massivecraft.factions.zcore.fupgrades;
import com.massivecraft.factions.Board;
import com.massivecraft.factions.FLocation;
import com.massivecraft.factions.Faction;
import com.massivecraft.factions.FactionsPlugin;
import com.massivecraft.factions.util.XMaterial;
import org.bukkit.CropState;
import org.bukkit.Material;
import org.bukkit.block.Block;
import org.bukkit.block.BlockState;
import org.bukkit.event.EventHandler;
import org.bukkit.event.Listener;
import org.bukkit.event.block.BlockGrowEvent;
import org.bukkit.material.Crops;
import java.util.concurrent.ThreadLocalRandom;
public class CropUpgrades implements Listener {
@EventHandler
public void onCropGrow(BlockGrowEvent e) {
FLocation floc = new FLocation(e.getBlock().getLocation());
Faction factionAtLoc = Board.getInstance().getFactionAt(floc);
if (!factionAtLoc.isWilderness()) {
int level = factionAtLoc.getUpgrade(UpgradeType.CROP);
if (level != 0) {
int chance = -1;
switch (level) {
case 1:
chance = FactionsPlugin.getInstance().getConfig().getInt("fupgrades.MainMenu.Crops.Crop-Boost.level-1");
break;
case 2:
chance = FactionsPlugin.getInstance().getConfig().getInt("fupgrades.MainMenu.Crops.Crop-Boost.level-2");
break;
case 3:
chance = FactionsPlugin.getInstance().getConfig().getInt("fupgrades.MainMenu.Crops.Crop-Boost.level-3");
break;
}
if (chance >= 0) {
int randomNum = ThreadLocalRandom.current().nextInt(1, 100 + 1);
if (randomNum <= chance)
growCrop(e);
}
}
}
}
private void growCrop(BlockGrowEvent e) {
if (e.getBlock().getType().equals(XMaterial.WHEAT.parseMaterial())) {
e.setCancelled(true);
Crops c = new Crops(CropState.RIPE);
BlockState bs = e.getBlock().getState();
bs.setData(c);
bs.update();
}
Block below = e.getBlock().getLocation().subtract(0, 1, 0).getBlock();
if (below.getType() == XMaterial.SUGAR_CANE.parseMaterial()) {
Block above = e.getBlock().getLocation().add(0, 1, 0).getBlock();
if (above.getType() == Material.AIR && above.getLocation().add(0, -2, 0).getBlock().getType() != Material.AIR) {
above.setType(XMaterial.SUGAR_CANE.parseMaterial());
}
} else if (below.getType() == Material.CACTUS) {
Block above = e.getBlock().getLocation().add(0, 1, 0).getBlock();
if (above.getType() == Material.AIR && above.getLocation().add(0, -2, 0).getBlock().getType() != Material.AIR) {
above.setType(Material.CACTUS);
}
}
}
}

View File

@@ -1,52 +0,0 @@
package com.massivecraft.factions.zcore.fupgrades;
import com.massivecraft.factions.Board;
import com.massivecraft.factions.FLocation;
import com.massivecraft.factions.Faction;
import com.massivecraft.factions.FactionsPlugin;
import org.bukkit.entity.Entity;
import org.bukkit.event.EventHandler;
import org.bukkit.event.Listener;
import org.bukkit.event.entity.EntityDeathEvent;
public class EXPUpgrade implements Listener {
@EventHandler
public void onDeath(EntityDeathEvent e) {
Entity killer = e.getEntity().getKiller();
if (killer == null)
return;
FLocation floc = new FLocation(e.getEntity().getLocation());
Faction faction = Board.getInstance().getFactionAt(floc);
if (!faction.isWilderness()) {
int level = faction.getUpgrade(UpgradeType.EXP);
if (level != 0) {
double multiplier = -1;
switch (level) {
case 1:
multiplier = FactionsPlugin.getInstance().getConfig().getDouble("fupgrades.MainMenu.EXP.EXP-Boost.level-1");
break;
case 2:
multiplier = FactionsPlugin.getInstance().getConfig().getDouble("fupgrades.MainMenu.EXP.EXP-Boost.level-2");
break;
case 3:
multiplier = FactionsPlugin.getInstance().getConfig().getDouble("fupgrades.MainMenu.EXP.EXP-Boost.level-3");
break;
}
if (multiplier >= 0)
spawnMoreExp(e, multiplier);
}
}
}
private void spawnMoreExp(EntityDeathEvent e, double multiplier) {
double newExp = e.getDroppedExp() * multiplier;
e.setDroppedExp((int) newExp);
}
}

View File

@@ -8,6 +8,7 @@ import com.massivecraft.factions.util.XMaterial;
import org.bukkit.Bukkit; import org.bukkit.Bukkit;
import org.bukkit.Material; import org.bukkit.Material;
import org.bukkit.enchantments.Enchantment; import org.bukkit.enchantments.Enchantment;
import org.bukkit.entity.HumanEntity;
import org.bukkit.entity.Player; import org.bukkit.entity.Player;
import org.bukkit.event.EventHandler; import org.bukkit.event.EventHandler;
import org.bukkit.event.Listener; import org.bukkit.event.Listener;
@@ -41,6 +42,11 @@ public class FUpgradesGUI implements Listener {
List<Integer> powerSlots = FactionsPlugin.getInstance().getConfig().getIntegerList("fupgrades.MainMenu.Power.PowerItem.slots"); List<Integer> powerSlots = FactionsPlugin.getInstance().getConfig().getIntegerList("fupgrades.MainMenu.Power.PowerItem.slots");
List<Integer> redSlots = FactionsPlugin.getInstance().getConfig().getIntegerList("fupgrades.MainMenu.Redstone.RedstoneItem.slots"); List<Integer> redSlots = FactionsPlugin.getInstance().getConfig().getIntegerList("fupgrades.MainMenu.Redstone.RedstoneItem.slots");
List<Integer> memberSlots = FactionsPlugin.getInstance().getConfig().getIntegerList("fupgrades.MainMenu.Members.MembersItem.slots"); List<Integer> memberSlots = FactionsPlugin.getInstance().getConfig().getIntegerList("fupgrades.MainMenu.Members.MembersItem.slots");
List<Integer> reductSlots = FactionsPlugin.getInstance().getConfig().getIntegerList("fupgrades.MainMenu.DamageReduct.ReduceItem.slots");
List<Integer> increaseSlots = FactionsPlugin.getInstance().getConfig().getIntegerList("fupgrades.MainMenu.DamageIncrease.IncreaseItem.slots");
List<Integer> tntSlots = FactionsPlugin.getInstance().getConfig().getIntegerList("fupgrades.MainMenu.TNT.TntItem.slots");
List<Integer> warpSlots = FactionsPlugin.getInstance().getConfig().getIntegerList("fupgrades.MainMenu.Warps.WarpItem.slots");
List<Integer> armorSlots = FactionsPlugin.getInstance().getConfig().getIntegerList("fupgrades.MainMenu.Armor.ArmorItem.slots");
for (Integer cropSlot : cropSlots) if (cropSlot != -1) inventory.setItem(cropSlot, items[2]); for (Integer cropSlot : cropSlots) if (cropSlot != -1) inventory.setItem(cropSlot, items[2]);
@@ -56,6 +62,16 @@ public class FUpgradesGUI implements Listener {
for (Integer memberSlot : memberSlots) if (memberSlot != -1) inventory.setItem(memberSlot, items[6]); for (Integer memberSlot : memberSlots) if (memberSlot != -1) inventory.setItem(memberSlot, items[6]);
for (Integer reduceSlot : reductSlots) if (reduceSlot != -1) inventory.setItem(reduceSlot, items[7]);
for (Integer increaseSlot : increaseSlots) if (increaseSlot != -1) inventory.setItem(increaseSlot, items[8]);
for(Integer tntSlot : tntSlots) if(tntSlot != -1) inventory.setItem(tntSlot, items[9]);
for(Integer warpSlot : warpSlots) if(warpSlot != -1) inventory.setItem(warpSlot, items[10]);
for(Integer armorSlot : armorSlots) if(armorSlot != -1) inventory.setItem(armorSlot, items[11]);
fme.getPlayer().openInventory(inventory); fme.getPlayer().openInventory(inventory);
} }
@@ -75,6 +91,11 @@ public class FUpgradesGUI implements Listener {
ItemStack powerItem = items[4]; ItemStack powerItem = items[4];
ItemStack redItem = items[5]; ItemStack redItem = items[5];
ItemStack memberItem = items[6]; ItemStack memberItem = items[6];
ItemStack reduceItem = items[7];
ItemStack increaseItem = items[8];
ItemStack tntItem = items[9];
ItemStack warpItem = items[10];
ItemStack armorItem = items[11];
if (e.getCurrentItem().equals(cropItem)) { if (e.getCurrentItem().equals(cropItem)) {
int cropLevel = fme.getFaction().getUpgrade(UpgradeType.CROP); int cropLevel = fme.getFaction().getUpgrade(UpgradeType.CROP);
@@ -170,6 +191,24 @@ public class FUpgradesGUI implements Listener {
break; break;
} }
} }
} else if (e.getCurrentItem().equals(armorItem)) {
int armorLevel = fme.getFaction().getUpgrade(UpgradeType.REINFORCEDARMOR);
switch (armorLevel) {
case 3:
return;
case 2: {
if (upgradeItem(fme, UpgradeType.REINFORCEDARMOR, 3, FactionsPlugin.getInstance().getConfig().getInt("fupgrades.MainMenu.Armor.Cost.level-3")))
break;
}
case 1: {
if (upgradeItem(fme, UpgradeType.REINFORCEDARMOR, 2, FactionsPlugin.getInstance().getConfig().getInt("fupgrades.MainMenu.Armor.Cost.level-2")))
break;
}
case 0: {
if (upgradeItem(fme, UpgradeType.REINFORCEDARMOR, 1, FactionsPlugin.getInstance().getConfig().getInt("fupgrades.MainMenu.Armor.Cost.level-1")))
break;
}
}
} else if (e.getCurrentItem().equals(memberItem)) { } else if (e.getCurrentItem().equals(memberItem)) {
int memberLevel = fme.getFaction().getUpgrade(UpgradeType.MEMBERS) + 1; int memberLevel = fme.getFaction().getUpgrade(UpgradeType.MEMBERS) + 1;
if (!FactionsPlugin.getInstance().getConfig().isSet("fupgrades.MainMenu.Members.Cost.level-" + memberLevel)) { if (!FactionsPlugin.getInstance().getConfig().isSet("fupgrades.MainMenu.Members.Cost.level-" + memberLevel)) {
@@ -181,6 +220,52 @@ public class FUpgradesGUI implements Listener {
fme.getPlayer().closeInventory(); fme.getPlayer().closeInventory();
takeMoney(fme, cost); takeMoney(fme, cost);
} }
} else if (e.getCurrentItem().equals(reduceItem)) {
int reduceLevel = fme.getFaction().getUpgrade(UpgradeType.DAMAGEDECREASE) + 1;
if (!FactionsPlugin.getInstance().getConfig().isSet("fupgrades.MainMenu.DamageReduct.Cost.level-" + reduceLevel)) {
return;
}
int cost = FactionsPlugin.getInstance().getConfig().getInt("fupgrades.MainMenu.DamageReduct.Cost.level-" + reduceLevel);
if (hasMoney(fme, cost)) {
fme.getFaction().setUpgrade(UpgradeType.DAMAGEDECREASE, reduceLevel);
fme.getPlayer().closeInventory();
takeMoney(fme, cost);
}
} else if (e.getCurrentItem().equals(increaseItem)) {
int increaseLevel = fme.getFaction().getUpgrade(UpgradeType.DAMAGEINCREASE) + 1;
if (!FactionsPlugin.getInstance().getConfig().isSet("fupgrades.MainMenu.DamageIncrease.Cost.level-" + increaseLevel)) {
return;
}
int cost = FactionsPlugin.getInstance().getConfig().getInt("fupgrades.MainMenu.DamageIncrease.Cost.level-" + increaseLevel);
if (hasMoney(fme, cost)) {
fme.getFaction().setUpgrade(UpgradeType.DAMAGEINCREASE, increaseLevel);
fme.getPlayer().closeInventory();
takeMoney(fme, cost);
}
} else if(e.getCurrentItem().equals(tntItem)){
int tntLevel = fme.getFaction().getUpgrade(UpgradeType.TNT) + 1;
if (!FactionsPlugin.getInstance().getConfig().isSet("fupgrades.MainMenu.TNT.Cost.level-" + tntLevel)) {
return;
}
int cost = FactionsPlugin.getInstance().getConfig().getInt("fupgrades.MainMenu.TNT.Cost.level-" + tntLevel);
if (hasMoney(fme, cost)) {
fme.getFaction().setUpgrade(UpgradeType.TNT, tntLevel);
fme.getPlayer().closeInventory();
takeMoney(fme, cost);
updateTntBanks(fme.getFaction());
}
} else if(e.getCurrentItem().equals(warpItem)){
int warpLevel = fme.getFaction().getUpgrade(UpgradeType.WARP) + 1;
if (!FactionsPlugin.getInstance().getConfig().isSet("fupgrades.MainMenu.Warps.Cost.level-" + warpLevel)) {
return;
}
int cost = FactionsPlugin.getInstance().getConfig().getInt("fupgrades.MainMenu.Warps.Cost.level-" + warpLevel);
if (hasMoney(fme, cost)) {
fme.getFaction().setUpgrade(UpgradeType.WARP, warpLevel);
fme.getPlayer().closeInventory();
takeMoney(fme, cost);
setWarpLimit(fme.getFaction());
}
} }
} }
} }
@@ -188,7 +273,7 @@ public class FUpgradesGUI implements Listener {
private void updateChests(Faction faction) { private void updateChests(Faction faction) {
String invName = FactionsPlugin.getInstance().color(FactionsPlugin.getInstance().getConfig().getString("fchest.Inventory-Title")); String invName = FactionsPlugin.getInstance().color(FactionsPlugin.getInstance().getConfig().getString("fchest.Inventory-Title"));
for (Player player : faction.getOnlinePlayers()) { for (HumanEntity player : faction.getChestInventory().getViewers()) {
if (player.getInventory().getTitle() != null && player.getInventory().getTitle().equalsIgnoreCase(invName)) if (player.getInventory().getTitle() != null && player.getInventory().getTitle().equalsIgnoreCase(invName))
player.closeInventory(); player.closeInventory();
} }
@@ -230,9 +315,9 @@ public class FUpgradesGUI implements Listener {
@SuppressWarnings("Duplicates") @SuppressWarnings("Duplicates")
private ItemStack[] buildItems(FPlayer fme) { private ItemStack[] buildItems(FPlayer fme) {
Material expMaterial = Material.getMaterial(FactionsPlugin.getInstance().getConfig().getString("fupgrades.MainMenu.EXP.EXPItem.Type")); byte expData = (byte) (FactionsPlugin.getInstance().getConfig().getInt("fupgrades.MainMenu.EXP.EXPItem.Damage"));
Material expMaterial = XMaterial.parseMaterial(FactionsPlugin.getInstance().getConfig().getString("fupgrades.MainMenu.EXP.EXPItem.Type"), expData);
int expAmt = FactionsPlugin.getInstance().getConfig().getInt("fupgrades.MainMenu.EXP.EXPItem.Amount"); int expAmt = FactionsPlugin.getInstance().getConfig().getInt("fupgrades.MainMenu.EXP.EXPItem.Amount");
short expData = Short.parseShort(FactionsPlugin.getInstance().getConfig().getInt("fupgrades.MainMenu.EXP.EXPItem.Damage") + "");
String expName = FactionsPlugin.getInstance().color(FactionsPlugin.getInstance().getConfig().getString("fupgrades.MainMenu.EXP.EXPItem.Name")); String expName = FactionsPlugin.getInstance().color(FactionsPlugin.getInstance().getConfig().getString("fupgrades.MainMenu.EXP.EXPItem.Name"));
List<String> expLore = FactionsPlugin.getInstance().colorList(FactionsPlugin.getInstance().getConfig().getStringList("fupgrades.MainMenu.EXP.EXPItem.Lore")); List<String> expLore = FactionsPlugin.getInstance().colorList(FactionsPlugin.getInstance().getConfig().getStringList("fupgrades.MainMenu.EXP.EXPItem.Lore"));
int expLevel = fme.getFaction().getUpgrade(UpgradeType.EXP); int expLevel = fme.getFaction().getUpgrade(UpgradeType.EXP);
@@ -253,9 +338,9 @@ public class FUpgradesGUI implements Listener {
expItem.setAmount(expLevel); expItem.setAmount(expLevel);
} }
Material spawnerMaterial = Material.getMaterial(FactionsPlugin.getInstance().getConfig().getString("fupgrades.MainMenu.Spawners.SpawnerItem.Type")); byte spawnerData = (byte) (FactionsPlugin.getInstance().getConfig().getInt("fupgrades.MainMenu.Spawners.SpawnerItem.Damage"));
Material spawnerMaterial = XMaterial.parseMaterial(FactionsPlugin.getInstance().getConfig().getString("fupgrades.MainMenu.Spawners.SpawnerItem.Type"), spawnerData);
int spawnerAmt = FactionsPlugin.getInstance().getConfig().getInt("fupgrades.MainMenu.Spawners.SpawnerItem.Amount"); int spawnerAmt = FactionsPlugin.getInstance().getConfig().getInt("fupgrades.MainMenu.Spawners.SpawnerItem.Amount");
short spawnerData = Short.parseShort(FactionsPlugin.getInstance().getConfig().getInt("fupgrades.MainMenu.Spawners.SpawnerItem.Damage") + "");
String spawnerName = FactionsPlugin.getInstance().color(FactionsPlugin.getInstance().getConfig().getString("fupgrades.MainMenu.Spawners.SpawnerItem.Name")); String spawnerName = FactionsPlugin.getInstance().color(FactionsPlugin.getInstance().getConfig().getString("fupgrades.MainMenu.Spawners.SpawnerItem.Name"));
List<String> spawnerLore = FactionsPlugin.getInstance().colorList(FactionsPlugin.getInstance().getConfig().getStringList("fupgrades.MainMenu.Spawners.SpawnerItem.Lore")); List<String> spawnerLore = FactionsPlugin.getInstance().colorList(FactionsPlugin.getInstance().getConfig().getStringList("fupgrades.MainMenu.Spawners.SpawnerItem.Lore"));
int spawnerLevel = fme.getFaction().getUpgrade(UpgradeType.SPAWNER); int spawnerLevel = fme.getFaction().getUpgrade(UpgradeType.SPAWNER);
@@ -265,9 +350,9 @@ public class FUpgradesGUI implements Listener {
} }
Material cropMaterial = Material.getMaterial(FactionsPlugin.getInstance().getConfig().getString("fupgrades.MainMenu.Crops.CropItem.Type")); byte cropData = (byte) (FactionsPlugin.getInstance().getConfig().getInt("fupgrades.MainMenu.Crops.CropItem.Damage"));
Material cropMaterial = XMaterial.parseMaterial(FactionsPlugin.getInstance().getConfig().getString("fupgrades.MainMenu.Crops.CropItem.Type"), cropData);
int cropAmt = FactionsPlugin.getInstance().getConfig().getInt("fupgrades.MainMenu.Crops.CropItem.Amount"); int cropAmt = FactionsPlugin.getInstance().getConfig().getInt("fupgrades.MainMenu.Crops.CropItem.Amount");
short cropData = Short.parseShort(FactionsPlugin.getInstance().getConfig().getInt("fupgrades.MainMenu.Crops.CropItem.Damage") + "");
String cropName = FactionsPlugin.getInstance().color(FactionsPlugin.getInstance().getConfig().getString("fupgrades.MainMenu.Crops.CropItem.Name")); String cropName = FactionsPlugin.getInstance().color(FactionsPlugin.getInstance().getConfig().getString("fupgrades.MainMenu.Crops.CropItem.Name"));
List<String> cropLore = FactionsPlugin.getInstance().colorList(FactionsPlugin.getInstance().getConfig().getStringList("fupgrades.MainMenu.Crops.CropItem.Lore")); List<String> cropLore = FactionsPlugin.getInstance().colorList(FactionsPlugin.getInstance().getConfig().getStringList("fupgrades.MainMenu.Crops.CropItem.Lore"));
int cropLevel = fme.getFaction().getUpgrade(UpgradeType.CROP); int cropLevel = fme.getFaction().getUpgrade(UpgradeType.CROP);
@@ -304,10 +389,9 @@ public class FUpgradesGUI implements Listener {
spawnerItem.setItemMeta(itemMeta); spawnerItem.setItemMeta(itemMeta);
spawnerItem.setAmount(spawnerLevel); spawnerItem.setAmount(spawnerLevel);
} }
byte chestData = (byte) (FactionsPlugin.getInstance().getConfig().getInt("fupgrades.MainMenu.Chest.ChestItem.Damage"));
Material chestMaterial = Material.getMaterial(FactionsPlugin.getInstance().getConfig().getString("fupgrades.MainMenu.Chest.ChestItem.Type")); Material chestMaterial = XMaterial.parseMaterial(FactionsPlugin.getInstance().getConfig().getString("fupgrades.MainMenu.Chest.ChestItem.Type"), chestData);
int chesttAmt = FactionsPlugin.getInstance().getConfig().getInt("fupgrades.MainMenu.Chest.ChestItem.Amount"); int chestAmt = FactionsPlugin.getInstance().getConfig().getInt("fupgrades.MainMenu.Chest.ChestItem.Amount");
short chestData = Short.parseShort(FactionsPlugin.getInstance().getConfig().getInt("fupgrades.MainMenu.Chest.ChestItem.Damage") + "");
String chestName = FactionsPlugin.getInstance().color(FactionsPlugin.getInstance().getConfig().getString("fupgrades.MainMenu.Chest.ChestItem.Name", "&e&lUpgrade Chest Size")); String chestName = FactionsPlugin.getInstance().color(FactionsPlugin.getInstance().getConfig().getString("fupgrades.MainMenu.Chest.ChestItem.Name", "&e&lUpgrade Chest Size"));
List<String> chestLore = FactionsPlugin.getInstance().colorList(FactionsPlugin.getInstance().getConfig().getStringList("fupgrades.MainMenu.Chest.ChestItem.Lore")); List<String> chestLore = FactionsPlugin.getInstance().colorList(FactionsPlugin.getInstance().getConfig().getStringList("fupgrades.MainMenu.Chest.ChestItem.Lore"));
int chestlevel = fme.getFaction().getUpgrade(UpgradeType.CHEST); int chestlevel = fme.getFaction().getUpgrade(UpgradeType.CHEST);
@@ -318,7 +402,7 @@ public class FUpgradesGUI implements Listener {
chestLore.set(i, line); chestLore.set(i, line);
} }
ItemStack chestItem = FactionsPlugin.getInstance().createItem(chestMaterial, chesttAmt, chestData, chestName, chestLore); ItemStack chestItem = FactionsPlugin.getInstance().createItem(chestMaterial, chestAmt, chestData, chestName, chestLore);
if (chestlevel >= 1) { if (chestlevel >= 1) {
ItemMeta itemMeta = chestItem.getItemMeta(); ItemMeta itemMeta = chestItem.getItemMeta();
@@ -331,9 +415,9 @@ public class FUpgradesGUI implements Listener {
chestItem.setAmount(chestlevel); chestItem.setAmount(chestlevel);
} }
Material memberMaterial = Material.getMaterial(FactionsPlugin.getInstance().getConfig().getString("fupgrades.MainMenu.Members.MembersItem.Type")); byte memberData = (byte) (FactionsPlugin.getInstance().getConfig().getInt("fupgrades.MainMenu.Members.MembersItem.Damage"));
Material memberMaterial = XMaterial.parseMaterial(FactionsPlugin.getInstance().getConfig().getString("fupgrades.MainMenu.Members.MembersItem.Type"), memberData);
int memberAmt = FactionsPlugin.getInstance().getConfig().getInt("fupgrades.MainMenu.Members.MembersItem.Amount"); int memberAmt = FactionsPlugin.getInstance().getConfig().getInt("fupgrades.MainMenu.Members.MembersItem.Amount");
short memberData = Short.parseShort(FactionsPlugin.getInstance().getConfig().getInt("fupgrades.MainMenu.Members.MembersItem.Damage") + "");
String memberName = FactionsPlugin.getInstance().color(FactionsPlugin.getInstance().getConfig().getString("fupgrades.MainMenu.Members.MembersItem.Name", "&e&lUpgrade Member Size")); String memberName = FactionsPlugin.getInstance().color(FactionsPlugin.getInstance().getConfig().getString("fupgrades.MainMenu.Members.MembersItem.Name", "&e&lUpgrade Member Size"));
List<String> memberLore = FactionsPlugin.getInstance().colorList(FactionsPlugin.getInstance().getConfig().getStringList("fupgrades.MainMenu.Members.MembersItem.Lore")); List<String> memberLore = FactionsPlugin.getInstance().colorList(FactionsPlugin.getInstance().getConfig().getStringList("fupgrades.MainMenu.Members.MembersItem.Lore"));
int memberlevel = fme.getFaction().getUpgrade(UpgradeType.MEMBERS); int memberlevel = fme.getFaction().getUpgrade(UpgradeType.MEMBERS);
@@ -357,9 +441,9 @@ public class FUpgradesGUI implements Listener {
memberItem.setAmount(memberlevel); memberItem.setAmount(memberlevel);
} }
Material powerMaterial = Material.getMaterial(FactionsPlugin.getInstance().getConfig().getString("fupgrades.MainMenu.Power.PowerItem.Type")); byte powerData = (byte) (FactionsPlugin.getInstance().getConfig().getInt("fupgrades.MainMenu.Power.PowerItem.Damage"));
Material powerMaterial = XMaterial.parseMaterial(FactionsPlugin.getInstance().getConfig().getString("fupgrades.MainMenu.Power.PowerItem.Type"), powerData);
int powerAmt = FactionsPlugin.getInstance().getConfig().getInt("fupgrades.MainMenu.Power.PowerItem.Amount"); int powerAmt = FactionsPlugin.getInstance().getConfig().getInt("fupgrades.MainMenu.Power.PowerItem.Amount");
short powerData = Short.parseShort(FactionsPlugin.getInstance().getConfig().getInt("fupgrades.MainMenu.Power.PowerItem.Damage") + "");
String powerName = FactionsPlugin.getInstance().color(FactionsPlugin.getInstance().getConfig().getString("fupgrades.MainMenu.Power.PowerItem.Name")); String powerName = FactionsPlugin.getInstance().color(FactionsPlugin.getInstance().getConfig().getString("fupgrades.MainMenu.Power.PowerItem.Name"));
List<String> powerLore = FactionsPlugin.getInstance().colorList(FactionsPlugin.getInstance().getConfig().getStringList("fupgrades.MainMenu.Power.PowerItem.Lore")); List<String> powerLore = FactionsPlugin.getInstance().colorList(FactionsPlugin.getInstance().getConfig().getStringList("fupgrades.MainMenu.Power.PowerItem.Lore"));
int powerLevel = fme.getFaction().getUpgrade(UpgradeType.POWER); int powerLevel = fme.getFaction().getUpgrade(UpgradeType.POWER);
@@ -384,9 +468,9 @@ public class FUpgradesGUI implements Listener {
powerItem.setAmount(powerLevel); powerItem.setAmount(powerLevel);
} }
Material redMaterial = Material.getMaterial(FactionsPlugin.getInstance().getConfig().getString("fupgrades.MainMenu.Redstone.RedstoneItem.Type")); byte redData = (byte) (FactionsPlugin.getInstance().getConfig().getInt("fupgrades.MainMenu.Redstone.RedstoneItem.Damage"));
Material redMaterial = XMaterial.parseMaterial(FactionsPlugin.getInstance().getConfig().getString("fupgrades.MainMenu.Redstone.RedstoneItem.Type"), redData);
int redAmt = FactionsPlugin.getInstance().getConfig().getInt("fupgrades.MainMenu.Redstone.RedstoneItem.Amount"); int redAmt = FactionsPlugin.getInstance().getConfig().getInt("fupgrades.MainMenu.Redstone.RedstoneItem.Amount");
short redData = Short.parseShort(FactionsPlugin.getInstance().getConfig().getInt("fupgrades.MainMenu.Redstone.RedstoneItem.Damage") + "");
String redName = FactionsPlugin.getInstance().color(FactionsPlugin.getInstance().getConfig().getString("fupgrades.MainMenu.Redstone.RedstoneItem.Name")); String redName = FactionsPlugin.getInstance().color(FactionsPlugin.getInstance().getConfig().getString("fupgrades.MainMenu.Redstone.RedstoneItem.Name"));
List<String> redLore = FactionsPlugin.getInstance().colorList(FactionsPlugin.getInstance().getConfig().getStringList("fupgrades.MainMenu.Redstone.RedstoneItem.Lore")); List<String> redLore = FactionsPlugin.getInstance().colorList(FactionsPlugin.getInstance().getConfig().getStringList("fupgrades.MainMenu.Redstone.RedstoneItem.Lore"));
int redLevel = fme.getFaction().getUpgrade(UpgradeType.REDSTONE); int redLevel = fme.getFaction().getUpgrade(UpgradeType.REDSTONE);
@@ -407,11 +491,155 @@ public class FUpgradesGUI implements Listener {
} }
itemMeta.addEnchant(Enchantment.DURABILITY, 3, true); itemMeta.addEnchant(Enchantment.DURABILITY, 3, true);
redItem.setItemMeta(itemMeta); redItem.setItemMeta(itemMeta);
redItem.setAmount(redLevel); redItem.setAmount(redLevel);
} }
return new ItemStack[]{expItem, spawnerItem, cropItem, chestItem, powerItem, redItem, memberItem}; byte reduceData = (byte) (FactionsPlugin.getInstance().getConfig().getInt("fupgrades.MainMenu.DamageReduct.ReduceItem.Damage"));
Material reduceMaterial = XMaterial.parseMaterial(FactionsPlugin.getInstance().getConfig().getString("fupgrades.MainMenu.DamageReduct.ReduceItem.Type"), reduceData);
int reduceAmt = FactionsPlugin.getInstance().getConfig().getInt("fupgrades.MainMenu.DamageReduct.ReduceItem.Amount");
String reduceName = FactionsPlugin.getInstance().color(FactionsPlugin.getInstance().getConfig().getString("fupgrades.MainMenu.DamageReduct.ReduceItem.Name"));
List<String> reduceLore = FactionsPlugin.getInstance().colorList(FactionsPlugin.getInstance().getConfig().getStringList("fupgrades.MainMenu.DamageReduct.ReduceItem.Lore"));
int reduceLevel = fme.getFaction().getUpgrade(UpgradeType.DAMAGEDECREASE);
for (int i = 0; i <= reduceLore.size() - 1; i++) {
String line = reduceLore.get(i);
line = line.replace("{level}", reduceLevel + "");
reduceLore.set(i, line);
}
ItemStack reduceItem = FactionsPlugin.getInstance().createItem(reduceMaterial, reduceAmt, reduceData, reduceName, reduceLore);
reduceItem.getItemMeta().setLore(reduceLore);
if (reduceLevel >= 1) {
ItemMeta itemMeta = reduceItem.getItemMeta();
if (!FactionsPlugin.getInstance().mc17) {
itemMeta.addItemFlags(ItemFlag.HIDE_ENCHANTS);
}
itemMeta.addEnchant(Enchantment.DURABILITY, 3, true);
reduceItem.setItemMeta(itemMeta);
reduceItem.setAmount(reduceLevel);
}
byte increaseData = (byte) (FactionsPlugin.getInstance().getConfig().getInt("fupgrades.MainMenu.DamageIncrease.IncreaseItem.Damage"));
Material increaseMaterial = XMaterial.parseMaterial(FactionsPlugin.getInstance().getConfig().getString("fupgrades.MainMenu.DamageIncrease.IncreaseItem.Type"), increaseData);
int increaseAmt = FactionsPlugin.getInstance().getConfig().getInt("fupgrades.MainMenu.DamageIncrease.IncreaseItem.Amount");
String increaseName = FactionsPlugin.getInstance().color(FactionsPlugin.getInstance().getConfig().getString("fupgrades.MainMenu.DamageIncrease.IncreaseItem.Name"));
List<String> increaseLore = FactionsPlugin.getInstance().colorList(FactionsPlugin.getInstance().getConfig().getStringList("fupgrades.MainMenu.DamageIncrease.IncreaseItem.Lore"));
int increaseLevel = fme.getFaction().getUpgrade(UpgradeType.DAMAGEINCREASE);
for (int i = 0; i <= increaseLore.size() - 1; i++) {
String line = increaseLore.get(i);
line = line.replace("{level}", increaseLevel + "");
increaseLore.set(i, line);
}
ItemStack increaseItem = FactionsPlugin.getInstance().createItem(increaseMaterial, increaseAmt, increaseData, increaseName, increaseLore);
increaseItem.getItemMeta().setLore(increaseLore);
if (increaseLevel >= 1) {
ItemMeta itemMeta = increaseItem.getItemMeta();
if (!FactionsPlugin.getInstance().mc17) {
itemMeta.addItemFlags(ItemFlag.HIDE_ENCHANTS);
}
itemMeta.addEnchant(Enchantment.DURABILITY, 3, true);
increaseItem.setItemMeta(itemMeta);
increaseItem.setAmount(increaseLevel);
}
byte tntData = (byte) (FactionsPlugin.getInstance().getConfig().getInt("fupgrades.MainMenu.TNT.TntItem.Damage"));
Material tntMaterial = XMaterial.parseMaterial(FactionsPlugin.getInstance().getConfig().getString("fupgrades.MainMenu.TNT.TntItem.Type"), tntData);
int tntAmt = FactionsPlugin.getInstance().getConfig().getInt("fupgrades.MainMenu.TNT.TntItem.Amount");
String tntName = FactionsPlugin.getInstance().color(FactionsPlugin.getInstance().getConfig().getString("fupgrades.MainMenu.TNT.TntItem.Name"));
List<String> tntLore = FactionsPlugin.getInstance().colorList(FactionsPlugin.getInstance().getConfig().getStringList("fupgrades.MainMenu.TNT.TntItem.Lore"));
int tntLevel = fme.getFaction().getUpgrade(UpgradeType.TNT);
for (int i = 0; i <= tntLore.size() - 1; i++) {
String line = tntLore.get(i);
line = line.replace("{level}", tntLevel + "");
tntLore.set(i, line);
}
ItemStack tntItem = FactionsPlugin.getInstance().createItem(tntMaterial, tntAmt, tntData, tntName, tntLore);
tntItem.getItemMeta().setLore(tntLore);
if (tntLevel >= 1) {
ItemMeta itemMeta = tntItem.getItemMeta();
if (!FactionsPlugin.getInstance().mc17) {
itemMeta.addItemFlags(ItemFlag.HIDE_ENCHANTS);
}
itemMeta.addEnchant(Enchantment.DURABILITY, 3, true);
tntItem.setItemMeta(itemMeta);
tntItem.setAmount(tntLevel);
}
byte warpData = (byte) (FactionsPlugin.getInstance().getConfig().getInt("fupgrades.MainMenu.Warps.WarpItem.Damage"));
Material warpMaterial = XMaterial.parseMaterial(FactionsPlugin.getInstance().getConfig().getString("fupgrades.MainMenu.Warps.WarpItem.Type"), warpData);
int warpAmt = FactionsPlugin.getInstance().getConfig().getInt("fupgrades.MainMenu.Warps.WarpItem.Amount");
String warpName = FactionsPlugin.getInstance().color(FactionsPlugin.getInstance().getConfig().getString("fupgrades.MainMenu.Warps.WarpItem.Name"));
List<String> warpLore = FactionsPlugin.getInstance().colorList(FactionsPlugin.getInstance().getConfig().getStringList("fupgrades.MainMenu.Warps.WarpItem.Lore"));
int warpLevel = fme.getFaction().getUpgrade(UpgradeType.WARP);
for (int i = 0; i <= warpLore.size() - 1; i++) {
String line = warpLore.get(i);
line = line.replace("{level}", warpLevel + "");
warpLore.set(i, line);
}
ItemStack warpItem = FactionsPlugin.getInstance().createItem(warpMaterial, warpAmt, warpData, warpName, warpLore);
warpItem.getItemMeta().setLore(warpLore);
if (warpLevel >= 1) {
ItemMeta itemMeta = warpItem.getItemMeta();
if (!FactionsPlugin.getInstance().mc17) {
itemMeta.addItemFlags(ItemFlag.HIDE_ENCHANTS);
}
itemMeta.addEnchant(Enchantment.DURABILITY, 3, true);
warpItem.setItemMeta(itemMeta);
warpItem.setAmount(warpLevel);
}
byte armorData = (byte) (FactionsPlugin.getInstance().getConfig().getInt("fupgrades.MainMenu.Armor.ArmorItem.Damage"));
Material armorMaterial = XMaterial.parseMaterial(FactionsPlugin.getInstance().getConfig().getString("fupgrades.MainMenu.Armor.ArmorItem.Type"), warpData);
int armorAmt = FactionsPlugin.getInstance().getConfig().getInt("fupgrades.MainMenu.Armor.ArmorItem.Amount");
String armorName = FactionsPlugin.getInstance().color(FactionsPlugin.getInstance().getConfig().getString("fupgrades.MainMenu.Armor.ArmorItem.Name"));
List<String> armorLore = FactionsPlugin.getInstance().colorList(FactionsPlugin.getInstance().getConfig().getStringList("fupgrades.MainMenu.Armor.ArmorItem.Lore"));
int armorLevel = fme.getFaction().getUpgrade(UpgradeType.REINFORCEDARMOR);
for (int i = 0; i <= armorLore.size() - 1; i++) {
String line = armorLore.get(i);
line = line.replace("{level}", armorLevel + "");
armorLore.set(i, line);
}
ItemStack armorItem = FactionsPlugin.getInstance().createItem(armorMaterial, armorAmt, armorData, armorName, armorLore);
armorItem.getItemMeta().setLore(armorLore);
if (armorLevel >= 1) {
ItemMeta itemMeta = armorItem.getItemMeta();
if (!FactionsPlugin.getInstance().mc17) {
itemMeta.addItemFlags(ItemFlag.HIDE_ENCHANTS);
}
itemMeta.addEnchant(Enchantment.DURABILITY, 3, true);
armorItem.setItemMeta(itemMeta);
armorItem.setAmount(armorLevel);
}
return new ItemStack[]{expItem, spawnerItem, cropItem, chestItem, powerItem, redItem, memberItem, reduceItem, increaseItem, tntItem, warpItem, armorItem};
}
private void updateTntBanks(Faction faction) {
int level = faction.getUpgrade(UpgradeType.TNT);
int size = FactionsPlugin.getInstance().getConfig().getInt("fupgrades.MainMenu.TNT.tnt-limit.level-" + (level));
faction.setTntBankLimit(size);
}
private void setWarpLimit(Faction faction) {
int level = faction.getUpgrade(UpgradeType.WARP);
int size = FactionsPlugin.getInstance().getConfig().getInt("fupgrades.MainMenu.Warps.warp-limit.level-" + (level));
faction.setWarpsLimit(size);
} }
private boolean hasMoney(FPlayer fme, int amt) { private boolean hasMoney(FPlayer fme, int amt) {

View File

@@ -1,34 +0,0 @@
package com.massivecraft.factions.zcore.fupgrades;
import com.massivecraft.factions.Board;
import com.massivecraft.factions.FLocation;
import com.massivecraft.factions.Faction;
import com.massivecraft.factions.FactionsPlugin;
import org.bukkit.event.EventHandler;
import org.bukkit.event.Listener;
import org.bukkit.event.block.BlockFromToEvent;
import java.util.List;
public class RedstoneUpgrade implements Listener {
@EventHandler
public void onWaterRedstone(BlockFromToEvent e) {
List<String> unbreakable = FactionsPlugin.getInstance().getConfig().getStringList("no-water-destroy.Item-List");
String block = e.getToBlock().getType().toString();
FLocation floc = new FLocation(e.getToBlock().getLocation());
Faction factionAtLoc = Board.getInstance().getFactionAt(floc);
if (!factionAtLoc.isWilderness()) {
int level = factionAtLoc.getUpgrade(UpgradeType.REDSTONE);
if (level != 0) {
if (level == 1) {
FactionsPlugin.getInstance().getConfig().getInt("fupgrades.MainMenu.Redstone.Cost");
}
if (unbreakable.contains(block)) {
e.setCancelled(true);
}
}
}
}
}

View File

@@ -1,41 +0,0 @@
package com.massivecraft.factions.zcore.fupgrades;
import com.massivecraft.factions.Board;
import com.massivecraft.factions.FLocation;
import com.massivecraft.factions.Faction;
import com.massivecraft.factions.FactionsPlugin;
import org.bukkit.event.EventHandler;
import org.bukkit.event.Listener;
import org.bukkit.event.entity.SpawnerSpawnEvent;
public class SpawnerUpgrades implements Listener {
@EventHandler
public void onSpawn(SpawnerSpawnEvent e) {
FLocation floc = new FLocation(e.getLocation());
Faction factionAtLoc = Board.getInstance().getFactionAt(floc);
if (!factionAtLoc.isWilderness()) {
int level = factionAtLoc.getUpgrade(UpgradeType.SPAWNER);
if (level != 0) {
switch (level) {
case 1:
lowerSpawnerDelay(e, FactionsPlugin.getInstance().getConfig().getInt("fupgrades.MainMenu.Spawners.Spawner-Boost.level-1"));
break;
case 2:
lowerSpawnerDelay(e, FactionsPlugin.getInstance().getConfig().getInt("fupgrades.MainMenu.Spawners.Spawner-Boost.level-2"));
break;
case 3:
lowerSpawnerDelay(e, FactionsPlugin.getInstance().getConfig().getInt("fupgrades.MainMenu.Spawners.Spawner-Boost.level-3"));
break;
}
}
}
}
private void lowerSpawnerDelay(SpawnerSpawnEvent e, double multiplier) {
int lowerby = (int) Math.round(e.getSpawner().getDelay() * multiplier);
e.getSpawner().setDelay(e.getSpawner().getDelay() - lowerby);
}
}

View File

@@ -2,7 +2,18 @@ package com.massivecraft.factions.zcore.fupgrades;
public enum UpgradeType { public enum UpgradeType {
CHEST("Chest"), SPAWNER("Spawner"), EXP("Exp"), CROP("Crop"), POWER("Power"), REDSTONE("Redstone"), MEMBERS("Members"); CHEST("Chest"),
SPAWNER("Spawner"),
EXP("Exp"),
CROP("Crop"),
POWER("Power"),
REDSTONE("Redstone"),
MEMBERS("Members"),
TNT("TNT"),
WARP("Warps"),
DAMAGEINCREASE("DamageIncrease"),
DAMAGEDECREASE("DamageDecrease"),
REINFORCEDARMOR("ReinforcedArmor");
private String id; private String id;

View File

@@ -0,0 +1,194 @@
package com.massivecraft.factions.zcore.fupgrades;
import com.massivecraft.factions.*;
import com.massivecraft.factions.util.XMaterial;
import org.bukkit.CropState;
import org.bukkit.Material;
import org.bukkit.block.Block;
import org.bukkit.block.BlockState;
import org.bukkit.entity.Entity;
import org.bukkit.entity.Player;
import org.bukkit.event.EventHandler;
import org.bukkit.event.Listener;
import org.bukkit.event.block.BlockFromToEvent;
import org.bukkit.event.block.BlockGrowEvent;
import org.bukkit.event.entity.EntityDamageByEntityEvent;
import org.bukkit.event.entity.EntityDeathEvent;
import org.bukkit.event.entity.SpawnerSpawnEvent;
import org.bukkit.event.player.PlayerItemDamageEvent;
import org.bukkit.material.Crops;
import java.util.List;
import java.util.concurrent.ThreadLocalRandom;
public class UpgradesListener implements Listener {
@EventHandler
public void onDeath(EntityDeathEvent e) {
Entity killer = e.getEntity().getKiller();
if (killer == null || !(killer instanceof Player)) {
return;
}
FLocation floc = new FLocation(e.getEntity().getLocation());
Faction faction = Board.getInstance().getFactionAt(floc);
if (!faction.isWilderness()) {
int level = faction.getUpgrade(UpgradeType.EXP);
double multiplier = FactionsPlugin.getInstance().getConfig().getDouble("fupgrades.MainMenu.EXP.EXP-Boost.level-" + level);
if (level != 0 && multiplier > 0.0) {
this.spawnMoreExp(e, multiplier);
}
}
}
private void spawnMoreExp(EntityDeathEvent e, double multiplier) {
double newExp = e.getDroppedExp() * multiplier;
e.setDroppedExp((int) newExp);
}
@EventHandler
public void onSpawn(SpawnerSpawnEvent e) {
FLocation floc = new FLocation(e.getLocation());
Faction factionAtLoc = Board.getInstance().getFactionAt(floc);
if (!factionAtLoc.isWilderness()) {
int level = factionAtLoc.getUpgrade(UpgradeType.SPAWNER);
if (level == 0) {
return;
}
this.lowerSpawnerDelay(e, FactionsPlugin.getInstance().getConfig().getDouble("fupgrades.MainMenu.Spawners.Spawner-Boost.level-" + level));
}
}
private void lowerSpawnerDelay(SpawnerSpawnEvent e, double multiplier) {
int lowerby = (int) Math.round(e.getSpawner().getDelay() * multiplier);
e.getSpawner().setDelay(e.getSpawner().getDelay() - lowerby);
}
@EventHandler
public void onCropGrow( BlockGrowEvent e) {
FLocation floc = new FLocation(e.getBlock().getLocation());
Faction factionAtLoc = Board.getInstance().getFactionAt(floc);
if (!factionAtLoc.isWilderness()) {
int level = factionAtLoc.getUpgrade(UpgradeType.CROP);
int chance = FactionsPlugin.getInstance().getConfig().getInt("fupgrades.MainMenu.Crops.Crop-Boost.level-" + level);
if (level == 0 || chance == 0) {
return;
}
int randomNum = ThreadLocalRandom.current().nextInt(1, 101);
if (randomNum <= chance) {
this.growCrop(e);
}
}
}
private void growCrop( BlockGrowEvent e) {
if (e.getBlock().getType().equals(XMaterial.WHEAT.parseMaterial())) {
e.setCancelled(true);
Crops c = new Crops(CropState.RIPE);
BlockState bs = e.getBlock().getState();
bs.setData(c);
bs.update();
}
Block below = e.getBlock().getLocation().subtract(0.0, 1.0, 0.0).getBlock();
if (below.getType() == XMaterial.SUGAR_CANE.parseMaterial()) {
Block above = e.getBlock().getLocation().add(0.0, 1.0, 0.0).getBlock();
if (above.getType() == Material.AIR && above.getLocation().add(0.0, -2.0, 0.0).getBlock().getType() != Material.AIR) {
above.setType(XMaterial.SUGAR_CANE.parseMaterial());
}
}
else if (below.getType() == Material.CACTUS) {
Block above = e.getBlock().getLocation().add(0.0, 1.0, 0.0).getBlock();
if (above.getType() == Material.AIR && above.getLocation().add(0.0, -2.0, 0.0).getBlock().getType() != Material.AIR) {
above.setType(Material.CACTUS);
}
}
}
@EventHandler
public static void onDamageReduction(EntityDamageByEntityEvent e) {
if (e.isCancelled()) {
return;
}
if (!(e.getDamager() instanceof Player) || !(e.getEntity() instanceof Player)) {
return;
}
FPlayer fme = FPlayers.getInstance().getByPlayer((Player) e.getEntity());
FPlayer dame = FPlayers.getInstance().getByPlayer((Player) e.getDamager());
if (fme == null || dame == null) {
return;
}
FLocation floc = new FLocation(fme.getPlayer().getLocation());
if (Board.getInstance().getFactionAt(floc) == fme.getFaction()) {
if (dame.getFaction() == fme.getFaction()) {
return;
}
double damage = e.getDamage();
int level = fme.getFaction().getUpgrade(UpgradeType.DAMAGEDECREASE);
double increase = FactionsPlugin.getInstance().getConfig().getDouble("fupgrades.MainMenu.DamageReduction.DamageReductionPercent.level-" + level);
e.setDamage(damage - damage / 100.0 * increase);
}
}
@EventHandler
public void onWaterRedstone(BlockFromToEvent e) {
List<String> unbreakable = FactionsPlugin.getInstance().getConfig().getStringList("no-water-destroy.Item-List");
String block = e.getToBlock().getType().toString();
FLocation floc = new FLocation(e.getToBlock().getLocation());
Faction factionAtLoc = Board.getInstance().getFactionAt(floc);
if (!factionAtLoc.isWilderness()) {
int level = factionAtLoc.getUpgrade(UpgradeType.REDSTONE);
if (level != 0) {
if (level == 1) {
FactionsPlugin.getInstance().getConfig().getInt("fupgrades.MainMenu.Redstone.Cost");
}
if (unbreakable.contains(block)) {
e.setCancelled(true);
}
}
}
}
@EventHandler
public static void onDamageIncrease(EntityDamageByEntityEvent e) {
if (e == null) {
return;
}
if (!(e.getDamager() instanceof Player) || !(e.getEntity() instanceof Player)) {
return;
}
if(e.getDamager().hasMetadata("NPC") || e.getEntity().hasMetadata("NPC")) return;
FPlayer fme = FPlayers.getInstance().getByPlayer((Player) e.getEntity());
FPlayer dame = FPlayers.getInstance().getByPlayer((Player) e.getDamager());
if (fme == null || dame == null) {
return;
}
FLocation floc = new FLocation(fme.getPlayer().getLocation());
if(floc == null) return;
if (Board.getInstance().getFactionAt(floc) == fme.getFaction()) {
if (dame.getFaction() == fme.getFaction()) {
return;
}
double damage = e.getDamage();
int level = fme.getFaction().getUpgrade(UpgradeType.DAMAGEINCREASE);
double increase = FactionsPlugin.getInstance().getConfig().getDouble("fupgrades.MainMenu.DamageIncrease.DamageIncreasePercent.level-" + level);
e.setDamage(damage + damage / 100.0 * increase);
}
}
@EventHandler
public void onArmorDamage(PlayerItemDamageEvent e) {
if (FPlayers.getInstance().getByPlayer(e.getPlayer()) == null) {
return;
}
if (e.getItem().getType().toString().contains("LEGGINGS") || e.getItem().getType().toString().contains("CHESTPLATE") || e.getItem().getType().toString().contains("HELMET") || e.getItem().getType().toString().contains("BOOTS")) {
int lvl = FPlayers.getInstance().getByPlayer(e.getPlayer()).getFaction().getUpgrade(UpgradeType.REINFORCEDARMOR);
double drop = FactionsPlugin.getInstance().getConfig().getDouble("fupgrades.MainMenu.Armor.Armor-HP-Drop.level-" + lvl);
int newDamage = (int) Math.round(e.getDamage() - e.getDamage() * drop);
e.setDamage(newDamage);
}
}
}

View File

@@ -80,6 +80,19 @@ public abstract class MemoryFaction implements Faction, EconomyParticipator {
private Map<UUID, Integer> playerWallCheckCount; private Map<UUID, Integer> playerWallCheckCount;
private Map<UUID, Integer> playerBufferCheckCount; private Map<UUID, Integer> playerBufferCheckCount;
private boolean weeWoo; private boolean weeWoo;
private int tntBankSize;
private int warpLimit;
private double reinforcedArmor;
private List<String> completedMissions;
protected String discord;
private String factionChatChannelId;
private String wallNotifyChannelId;
private String bufferNotifyChannelId;
private String weeWooChannelId;
private String notifyFormat;
private String weeWooFormat;
private String guildId;
private String memberRoleId;
// -------------------------------------------- // // -------------------------------------------- //
@@ -109,6 +122,12 @@ public abstract class MemoryFaction implements Faction, EconomyParticipator {
this.checks = new ConcurrentHashMap<>(); this.checks = new ConcurrentHashMap<>();
this.playerWallCheckCount = new ConcurrentHashMap<>(); this.playerWallCheckCount = new ConcurrentHashMap<>();
this.playerBufferCheckCount = new ConcurrentHashMap<>(); this.playerBufferCheckCount = new ConcurrentHashMap<>();
this.completedMissions = new ArrayList<>();
this.wallNotifyChannelId = null;
this.bufferNotifyChannelId = null;
this.notifyFormat = "@everyone, check %type%";
this.weeWooFormat = "@everyone, we're being raided! Get online!";
this.memberRoleId = null;
resetPerms(); // Reset on new Faction so it has default values. resetPerms(); // Reset on new Faction so it has default values.
} }
@@ -127,6 +146,7 @@ public abstract class MemoryFaction implements Faction, EconomyParticipator {
money = old.money; money = old.money;
powerBoost = old.powerBoost; powerBoost = old.powerBoost;
missions = new ConcurrentHashMap<>(); missions = new ConcurrentHashMap<>();
this.completedMissions = new ArrayList<>();
relationWish = old.relationWish; relationWish = old.relationWish;
claimOwnership = old.claimOwnership; claimOwnership = old.claimOwnership;
fplayers = new HashSet<>(); fplayers = new HashSet<>();
@@ -211,6 +231,14 @@ public abstract class MemoryFaction implements Faction, EconomyParticipator {
return hasWarpPassword(warp) && warpPasswords.get(warp.toLowerCase()).equals(password); return hasWarpPassword(warp) && warpPasswords.get(warp.toLowerCase()).equals(password);
} }
public String getDiscord() {
return this.discord;
}
public void setDiscord(String link) {
this.discord = link;
}
public String getPaypal() { public String getPaypal() {
return this.paypal; return this.paypal;
} }
@@ -420,8 +448,14 @@ public abstract class MemoryFaction implements Faction, EconomyParticipator {
@Override @Override
public Inventory getChestInventory() { public Inventory getChestInventory() {
if (chest != null) return chest; if (chest == null) {
this.chest = Bukkit.createInventory(null, getChestSize(), FactionsPlugin.getInstance().color(FactionsPlugin.getInstance().getConfig().getString("fchest.Inventory-Title")));
return chest;
}
return chest;
}
private int getChestSize() {
int size = 9; int size = 9;
switch (getUpgrade(UpgradeType.CHEST)) { switch (getUpgrade(UpgradeType.CHEST)) {
case 1: case 1:
@@ -434,8 +468,7 @@ public abstract class MemoryFaction implements Faction, EconomyParticipator {
size = FactionsPlugin.getInstance().getConfig().getInt("fupgrades.MainMenu.Chest.Chest-Size.level-3") * 9; size = FactionsPlugin.getInstance().getConfig().getInt("fupgrades.MainMenu.Chest.Chest-Size.level-3") * 9;
break; break;
} }
chest = Bukkit.createInventory(null, size, FactionsPlugin.getInstance().color(FactionsPlugin.getInstance().getConfig().getString("fchest.Inventory-Title"))); return size;
return chest;
} }
@@ -452,6 +485,39 @@ public abstract class MemoryFaction implements Faction, EconomyParticipator {
bannerSerialized = banner.serialize(); bannerSerialized = banner.serialize();
} }
@Override
public int getWarpsLimit() {
if (warpLimit == 0) {
return FactionsPlugin.getInstance().getConfig().getInt("max-warps");
}
return warpLimit;
}
@Override
public void setWarpsLimit(int warpLimit) {
this.warpLimit = warpLimit;
}
@Override
public int getTntBankLimit() {
if (tntBankSize == 0) {
return FactionsPlugin.getInstance().getConfig().getInt("ftnt.Bank-Limit");
}
return tntBankSize;
}
@Override
public void setTntBankLimit(int newLimit) {
tntBankSize = newLimit;
}
@Override
public double getReinforcedArmor() { return this.reinforcedArmor; }
@Override
public void setReinforcedArmor(double newPercent) { reinforcedArmor = newPercent; }
@Override @Override
public ItemStack getBanner() { public ItemStack getBanner() {
if (bannerSerialized == null) { if (bannerSerialized == null) {
@@ -468,7 +534,7 @@ public abstract class MemoryFaction implements Faction, EconomyParticipator {
return this.wallCheckMinutes; return this.wallCheckMinutes;
} }
public void setWallCheckMinutes(final int wallCheckMinutes) { public void setWallCheckMinutes(int wallCheckMinutes) {
this.wallCheckMinutes = wallCheckMinutes; this.wallCheckMinutes = wallCheckMinutes;
} }
@@ -476,7 +542,7 @@ public abstract class MemoryFaction implements Faction, EconomyParticipator {
return this.bufferCheckMinutes; return this.bufferCheckMinutes;
} }
public void setBufferCheckMinutes(final int bufferCheckMinutes) { public void setBufferCheckMinutes(int bufferCheckMinutes) {
this.bufferCheckMinutes = bufferCheckMinutes; this.bufferCheckMinutes = bufferCheckMinutes;
} }
@@ -492,11 +558,91 @@ public abstract class MemoryFaction implements Faction, EconomyParticipator {
return this.playerWallCheckCount; return this.playerWallCheckCount;
} }
@Override
public String getGuildId() {
return this.guildId;
}
@Override
public void setGuildId(final String guildId) {
this.guildId = guildId;
}
@Override
public String getMemberRoleId() {
return this.memberRoleId;
}
@Override
public String getFactionChatChannelId() {
return this.factionChatChannelId;
}
@Override
public String getWallNotifyChannelId() {
return this.wallNotifyChannelId;
}
@Override
public void setWallNotifyChannelId(final String wallNotifyChannelId) {
this.wallNotifyChannelId = wallNotifyChannelId;
}
@Override
public String getBufferNotifyChannelId() {
return this.bufferNotifyChannelId;
}
@Override
public void setBufferNotifyChannelId(final String bufferNotifyChannelId) {
this.bufferNotifyChannelId = bufferNotifyChannelId;
}
@Override
public String getWeeWooChannelId() {
return this.weeWooChannelId;
}
@Override
public void setWeeWooChannelId(final String weeWooChannelId) {
this.weeWooChannelId = weeWooChannelId;
}
@Override
public String getNotifyFormat() {
return this.notifyFormat;
}
@Override
public void setNotifyFormat(final String notifyFormat) {
this.notifyFormat = notifyFormat;
}
@Override
public String getWeeWooFormat() {
return this.weeWooFormat;
}
@Override
public void setWeeWooFormat(final String weeWooFormat) {
this.weeWooFormat = weeWooFormat;
}
@Override
public void setFactionChatChannelId(final String factionChatChannelId) {
this.factionChatChannelId = factionChatChannelId;
}
@Override
public void setMemberRoleId(final String memberRoleId) {
this.memberRoleId = memberRoleId;
}
public boolean isWeeWoo() { public boolean isWeeWoo() {
return this.weeWoo; return this.weeWoo;
} }
public void setWeeWoo(final boolean weeWoo) { public void setWeeWoo(boolean weeWoo) {
this.weeWoo = weeWoo; this.weeWoo = weeWoo;
} }
@@ -556,6 +702,12 @@ public abstract class MemoryFaction implements Faction, EconomyParticipator {
return this.tag; return this.tag;
} }
public void checkPerms() {
if (this.permissions == null || this.permissions.isEmpty()) {
this.resetPerms();
}
}
public void setTag(String str) { public void setTag(String str) {
if (Conf.factionTagForceUpperCase) { if (Conf.factionTagForceUpperCase) {
str = str.toUpperCase(); str = str.toUpperCase();
@@ -1219,6 +1371,9 @@ public abstract class MemoryFaction implements Faction, EconomyParticipator {
return this.missions; return this.missions;
} }
@Override
public List<String> getCompletedMissions() {return this.completedMissions;}
public void clearAllClaimOwnership() { public void clearAllClaimOwnership() {
claimOwnership.clear(); claimOwnership.clear();
} }

View File

@@ -33,7 +33,7 @@ public class JSONBoard extends MemoryBoard {
coords = entry.getKey().getCoordString(); coords = entry.getKey().getCoordString();
id = entry.getValue(); id = entry.getValue();
if (!worldCoordIds.containsKey(worldName)) { if (!worldCoordIds.containsKey(worldName)) {
worldCoordIds.put(worldName, new TreeMap<String, String>()); worldCoordIds.put(worldName, new TreeMap<>());
} }
worldCoordIds.get(worldName).put(coords, id); worldCoordIds.get(worldName).put(coords, id);

View File

@@ -1,6 +1,5 @@
package com.massivecraft.factions.zcore.persist.json; package com.massivecraft.factions.zcore.persist.json;
import com.google.common.base.Function;
import com.google.common.collect.Maps; import com.google.common.collect.Maps;
import com.google.gson.Gson; import com.google.gson.Gson;
import com.google.gson.reflect.TypeToken; import com.google.gson.reflect.TypeToken;
@@ -39,12 +38,7 @@ public class JSONFPlayers extends MemoryFPlayers {
} }
public void convertFrom(MemoryFPlayers old) { public void convertFrom(MemoryFPlayers old) {
this.fPlayers.putAll(Maps.transformValues(old.fPlayers, new Function<FPlayer, JSONFPlayer>() { this.fPlayers.putAll(Maps.transformValues(old.fPlayers, arg0 -> new JSONFPlayer((MemoryFPlayer) arg0)));
@Override
public JSONFPlayer apply(FPlayer arg0) {
return new JSONFPlayer((MemoryFPlayer) arg0);
}
}));
forceSave(); forceSave();
FPlayers.instance = this; FPlayers.instance = this;
} }

View File

@@ -91,6 +91,7 @@ public class JSONFactions extends MemoryFactions {
for (Entry<String, JSONFaction> entry : data.entrySet()) { for (Entry<String, JSONFaction> entry : data.entrySet()) {
String id = entry.getKey(); String id = entry.getKey();
Faction f = entry.getValue(); Faction f = entry.getValue();
f.checkPerms();
f.setId(id); f.setId(id);
this.updateNextIdForId(id); this.updateNextIdForId(id);
needsUpdate += whichKeysNeedMigration(f.getInvites()).size(); needsUpdate += whichKeysNeedMigration(f.getInvites()).size();
@@ -240,12 +241,7 @@ public class JSONFactions extends MemoryFactions {
@Override @Override
public void convertFrom(MemoryFactions old) { public void convertFrom(MemoryFactions old) {
this.factions.putAll(Maps.transformValues(old.factions, new Function<Faction, JSONFaction>() { this.factions.putAll(Maps.transformValues(old.factions, arg0 -> new JSONFaction((MemoryFaction) arg0)));
@Override
public JSONFaction apply(Faction arg0) {
return new JSONFaction((MemoryFaction) arg0);
}
}));
this.nextId = old.nextId; this.nextId = old.nextId;
forceSave(); forceSave();
Factions.instance = this; Factions.instance = this;

View File

@@ -200,6 +200,8 @@ public enum TL {
COMMAND_BYPASS_DESCRIPTION("Enable admin bypass mode"), COMMAND_BYPASS_DESCRIPTION("Enable admin bypass mode"),
COMMAND_BANNER_DESCRIPTION("Turn a held banner into a war banner"), COMMAND_BANNER_DESCRIPTION("Turn a held banner into a war banner"),
BANNER_CANNOT_BREAK("&c&l[!] &7You may not break a faction banner!"),
COMMAND_BANNER_NOBANNER("&c&l[!] &cPlease set a banner using /f setbanner"),
COMMAND_BANNER_NOTENOUGHMONEY("&c&l[!] &7You do&c not&7 have enough money"), COMMAND_BANNER_NOTENOUGHMONEY("&c&l[!] &7You do&c not&7 have enough money"),
COMMAND_BANNER_MONEYTAKE("&c&l[!] $&c{amount} &7has been taken from your account."), COMMAND_BANNER_MONEYTAKE("&c&l[!] $&c{amount} &7has been taken from your account."),
COMMAND_BANNER_SUCCESS("&c&l[!] &7You have created a &c&lWarBanner!"), COMMAND_BANNER_SUCCESS("&c&l[!] &7You have created a &c&lWarBanner!"),
@@ -237,6 +239,8 @@ public enum TL {
COMMAND_CLAIMLINE_ABOVEMAX("&c&l[!]&7 The &cmaximum&7 limit for claim line is &c%s&7."), COMMAND_CLAIMLINE_ABOVEMAX("&c&l[!]&7 The &cmaximum&7 limit for claim line is &c%s&7."),
COMMAND_CLAIMLINE_NOTVALID("&c&l[!]&7 &c%s&7 is not a &ccardinal &7direction. You may use &cnorth&7, &ceast&7, &csouth &7or &cwest&7."), COMMAND_CLAIMLINE_NOTVALID("&c&l[!]&7 &c%s&7 is not a &ccardinal &7direction. You may use &cnorth&7, &ceast&7, &csouth &7or &cwest&7."),
CHEST_ITEM_DENIED_TRANSFER("&c&l[!] &7You may not transfer &b%1$s &7into your factions chest!"),
COMMAND_CONFIG_NOEXIST("&c&l[!]&7 No configuration setting \"&c%1$s&7\" exists."), COMMAND_CONFIG_NOEXIST("&c&l[!]&7 No configuration setting \"&c%1$s&7\" exists."),
COMMAND_CONFIG_SET_TRUE("\" option set to true (enabled)."), COMMAND_CONFIG_SET_TRUE("\" option set to true (enabled)."),
COMMAND_CONFIG_SET_FALSE("\" option set to false (disabled)."), COMMAND_CONFIG_SET_FALSE("\" option set to false (disabled)."),
@@ -315,6 +319,25 @@ public enum TL {
CHECK_LEADERBOARD_LINE("&f%1$s. &d%2$s: &f%3$s (%4$s Buffer, %5$s Walls)"), CHECK_LEADERBOARD_LINE("&f%1$s. &d%2$s: &f%3$s (%4$s Buffer, %5$s Walls)"),
CHECK_LEADERBOARD_NO_DATA("&8No data"), CHECK_LEADERBOARD_NO_DATA("&8No data"),
//DISCORD
WEEWOO_ALREADY_STARTED_DISCORD("Weewoo already started"),
WEEWOO_ALREADY_STARTED_INGAME("&cWeewoo already started"),
WEEWOO_STARTED_DISCORD("Weewoo started by %1$s"),
WEEWOO_ALREADY_STOPPED_DISCORD("Weewoo already stopped"),
WEEWOO_STOPPED_DISCORD("Weewoo stopped by %1$s"),
INVITE_BOT_USAGE("Gets the invite for the Discord bot"),
SET_GUILD_ID_USAGE("Sets the guild id for the faction"),
SET_GUILD_ID_SUCCESS("&aSuccesfully set guild id"),
SET_GUILD_ID_INVALID_ID("&cInvalid guild id (is the bot in the guild?)"),
SET_GUILD_ID_UNABLE_TO_MESSAGE_GUILD_OWNER("&cUnable to message guild owner"),
SET_GUILD_ID_TIMED_OUT_MINECRAFT("&cTimed out"),
SET_GUILD_ID_TIMED_OUT_DISCORD("Timed out"),
SET_GUILD_ID_GUILD_ALREADY_LINKED("&cThat guild is already linked to a faction"),
SET_GUILD_ID_RESET_ID("&cGuild id removed"),
SET_GUILD_ID_PMING_OWNER("&aNow Direct messaging the Discord server owner to approve the link, times out in 15 seconds."),
CANT_FORCE_SET_GUILD_ID("&cYou cannot forcefully set guild ids for other guilds."),
COMMAND_DEINVITE_CANDEINVITE("&c&l[!]&7 Players you can &cdeinvite: "), COMMAND_DEINVITE_CANDEINVITE("&c&l[!]&7 Players you can &cdeinvite: "),
COMMAND_DEINVITE_CLICKTODEINVITE("&c&l[!]&7 Click to &crevoke&7 invite for &c%1$s"), COMMAND_DEINVITE_CLICKTODEINVITE("&c&l[!]&7 Click to &crevoke&7 invite for &c%1$s"),
COMMAND_DEINVITE_ALREADYMEMBER("&c&l[!]&7 &c%1$s&7 is already a member of &c%2$s"), COMMAND_DEINVITE_ALREADYMEMBER("&c&l[!]&7 &c%1$s&7 is already a member of &c%2$s"),
@@ -564,6 +587,18 @@ public enum TL {
COMMAND_OWNERLIST_OWNERS("&c&l[!]&7 Current owner(s) of this land: %1$s"), COMMAND_OWNERLIST_OWNERS("&c&l[!]&7 Current owner(s) of this land: %1$s"),
COMMAND_OWNERLIST_DESCRIPTION("List owner(s) of this claimed land"), COMMAND_OWNERLIST_DESCRIPTION("List owner(s) of this claimed land"),
COMMAND_DISCORDSET_ADMIN_SUCCESSFUL("&c&l[!] &7You have set &b%1$s's &7discord to &b%2$s&7."),
COMMAND_DISCORDSET_ADMIN_FAILED("&c&l[!] &b%1$s &7is not an discord link!"),
COMMAND_DISCORDSET_NOTEMAIL("&c&l[!] &b%1$s &7is not an discord link!"),
COMMAND_DISCORDSET_DESCRIPTION("&c&l[!] &7Set the link of your factions discord."),
COMMAND_DISCORDSET_SUCCESSFUL("&c&l[!] &7Successfully set your factions discord link - &b%1$s&7."),
DISCORD_PLAYER_DISCORD("&c&l[!] &7You're factions discord link is: &b%1$s&7."),
COMMAND_DISCORD_NOTSET("&c&l[!] &7Your faction does not have their discord set!"),
COMMAND_DISCORDSEE_FACTION_NOTSET("&c&l[!] &b%1$s's &7discord has not yet been set!"),
COMMAND_DISCORDSEE_FACTION_DISCORD("&c&l[!] &b%1$s's &7faction has their discord link set to &b%2$s&7."),
COMMAND_DISCORDSEE_DESCRIPTION("&c&l[!] &7View a specific factions discord link with &b/f discord <faction>&b."),
PAYPALSEE_PLAYER_PAYPAL("&c&l[!] &7You're factions paypal is: &b%1$s&7."), PAYPALSEE_PLAYER_PAYPAL("&c&l[!] &7You're factions paypal is: &b%1$s&7."),
COMMAND_PAYPAL_NOTSET("&c&l[!] &7Your faction does not have their paypal set!"), COMMAND_PAYPAL_NOTSET("&c&l[!] &7Your faction does not have their paypal set!"),
COMMAND_PAYPALSET_ADMIN_SUCCESSFUL("&c&l[!] &7You have set &b%1$s's &7paypal to &b%2$s&7."), COMMAND_PAYPALSET_ADMIN_SUCCESSFUL("&c&l[!] &7You have set &b%1$s's &7paypal to &b%2$s&7."),
@@ -704,6 +739,10 @@ public enum TL {
COMMAND_SETMAXVAULTS_SUCCESS("&aSet max vaults for &e%s &ato &b%d"), COMMAND_SETMAXVAULTS_SUCCESS("&aSet max vaults for &e%s &ato &b%d"),
COMMAND_ONCOOOLDOWN("&c&l[!] &7You cannot use this command for another &b%1$s &7seconds."), COMMAND_ONCOOOLDOWN("&c&l[!] &7You cannot use this command for another &b%1$s &7seconds."),
COMMAND_SPAWNER_LOCK_TOGGLED("&c&l[!] &7You have set placement of spawners to %1$s"),
COMMAND_SPAWNER_LOCK_DESCRIPTION("enable/disable placement of spawners"),
COMMAND_SPAWNER_LOCK_CANNOT_PLACE("&c&l[!] &7Placement of spawners has been temporarily disabled!"),
COMMAND_STRIKES_CHANGED("&c&l[!] &7You have set &c%1$s's &7strikes to &c%2$s"), COMMAND_STRIKES_CHANGED("&c&l[!] &7You have set &c%1$s's &7strikes to &c%2$s"),
COMMAND_STRIKES_INFO("&c&l[!] &7%1$s has %2$s strikes"), COMMAND_STRIKES_INFO("&c&l[!] &7%1$s has %2$s strikes"),
COMMAND_STRIKES_TARGET_INVALID("&c&l[!] &7The faction %1$s is invalid."), COMMAND_STRIKES_TARGET_INVALID("&c&l[!] &7The faction %1$s is invalid."),
@@ -715,7 +754,7 @@ public enum TL {
COMMAND_STRIKESINFO_DESCRIPTION("Get a faction's strikes"), COMMAND_STRIKESINFO_DESCRIPTION("Get a faction's strikes"),
SHOP_NOT_ENOUGH_POINTS("&c&l[!] &7Your faction does not have enough points to purchase this!"), SHOP_NOT_ENOUGH_POINTS("&c&l[!] &7Your faction does not have enough points to purchase this!"),
SHOP_BOUGHT_BROADCAST_FACTION("\n&c&l[!] &e&lFactionShop » &b{player} &7bought &b{item}&7!\n"), SHOP_BOUGHT_BROADCAST_FACTION("\n&c&l[!] &e&lFactionShop » &b{player} &7bought &b{item}&7 for &b{cost} &7points!\n"),
COMMAND_VIEWCHEST_DESCRIPTION("view a factions chest/pv"), COMMAND_VIEWCHEST_DESCRIPTION("view a factions chest/pv"),
@@ -842,7 +881,7 @@ public enum TL {
COMMAND_TNT_WIDTHDRAW_SUCCESS("&cSuccessfully withdrew tnt."), COMMAND_TNT_WIDTHDRAW_SUCCESS("&cSuccessfully withdrew tnt."),
COMMAND_TNT_WIDTHDRAW_NOTENOUGH("&cNot enough tnt in bank."), COMMAND_TNT_WIDTHDRAW_NOTENOUGH("&cNot enough tnt in bank."),
COMMAND_TNT_DEPOSIT_NOTENOUGH("&cNot enough tnt in tnt inventory."), COMMAND_TNT_DEPOSIT_NOTENOUGH("&cNot enough tnt in tnt inventory."),
COMMAND_TNT_AMOUNT("&cYour faction has {amount} tnt in the tnt bank."), COMMAND_TNT_AMOUNT("&cYour faction has {amount} tnt out of {bankSize} in the tnt bank."),
COMMAND_TNT_POSITIVE("&cPlease use positive numbers!"), COMMAND_TNT_POSITIVE("&cPlease use positive numbers!"),
COMMAND_TNT_DESCRIPTION("add/widthraw from faction's tnt bank"), COMMAND_TNT_DESCRIPTION("add/widthraw from faction's tnt bank"),
COMMAND_TNT_WIDTHDRAW_NOTENOUGH_SPACE("&cNot enough space in your inventory."), COMMAND_TNT_WIDTHDRAW_NOTENOUGH_SPACE("&cNot enough space in your inventory."),
@@ -993,6 +1032,7 @@ public enum TL {
MISSION_MISSION_STARTED("&f%1$s &dstarted the %2$s &fmission"), MISSION_MISSION_STARTED("&f%1$s &dstarted the %2$s &fmission"),
MISSION_ALREAD_COMPLETED("&c&l[!] &7You may not restart a mission you have already completed"),
MISSION_MISSION_ACTIVE("&c&l[!] &7This mission is currently active!"), MISSION_MISSION_ACTIVE("&c&l[!] &7This mission is currently active!"),
MISSION_MISSION_MAX_ALLOWED("&c&l[!] &7You may not have more then &b%1$s &7missions active at once."), MISSION_MISSION_MAX_ALLOWED("&c&l[!] &7You may not have more then &b%1$s &7missions active at once."),
MISSION_MISSION_FINISHED("&c&l[!] &7Your faction has successfully completed %1$s mission!"), MISSION_MISSION_FINISHED("&c&l[!] &7Your faction has successfully completed %1$s mission!"),

View File

@@ -649,6 +649,14 @@ ftnt:
Enabled: true Enabled: true
Bank-Limit: 250000 Bank-Limit: 250000
############################################################
# +------------------------------------------------------+ #
# | Faction Discord | #
# +------------------------------------------------------+ #
############################################################
fdiscord:
Enabled: true
############################################################ ############################################################
# +------------------------------------------------------+ # # +------------------------------------------------------+ #
# | Faction PayPal | # # | Faction PayPal | #
@@ -683,15 +691,12 @@ F-Shop:
Enabled: true Enabled: true
GUI: GUI:
Name: '&b&lFaction Shop' Name: '&b&lFaction Shop'
Size: 36 Rows: 4
Information: dummy-item:
name: '&b&lInformation' Type: BLACK_STAINED_GLASS_PANE
lore: Name: '&cFaction Points: &b{points}'
- '&bPoints &7are gained by capturing koths/conquests.' Lore:
- '' - ' '
- '&b&l[!] &bFaction Points: &f%points%'
slot: 22
############################################################ ############################################################
# +------------------------------------------------------+ # # +------------------------------------------------------+ #
# | Faction Command Cooldowns | # # | Faction Command Cooldowns | #
@@ -740,8 +745,9 @@ Missions-Enabled: true
Missions-GUI-Title: '&bFaction Missions' Missions-GUI-Title: '&bFaction Missions'
MaximumMissionsAllowedAtOnce: 1 MaximumMissionsAllowedAtOnce: 1
Mission-Progress-Format: '&b&lProgression: &f{progress}&7/&e{total}' Mission-Progress-Format: '&b&lProgression: &f{progress}&7/&e{total}'
DenyMissionsMoreThenOnce: true #this setting to true, means that if they complete a mission they cannot redo the same mission
#Mission Types: KILL, MINE, FISH #Mission Types: KILL, MINE, PLACE, FISH, TAME, ENCHANT, CONSUME
Missions: Missions:
sugarcane: sugarcane:
Slot: 11 Slot: 11
@@ -778,6 +784,42 @@ Missions:
Amount: 100 Amount: 100
Reward: Reward:
Commands: ["f points add %faction% 100"] Commands: ["f points add %faction% 100"]
animaltaming:
Slot: 20
Material: "BONE"
Name: "&f100 &cTamed Animals"
Lore:
- "&b&lTame an animal &n100&r &d&ltimes"
Mission:
Type: "TAME"
EntityType: "ALL"
Amount: 100
Reward:
Commands: ["f points add %faction% 100"]
enchant:
Slot: 22
Material: "BOOK"
Name: "&f100 &dEnchants"
Lore:
- "&b&lEnchant &n100&r &d&litems"
Mission:
Type: "ENCHANT"
Amount: 100
Reward:
Commands: ["f points add %faction% 100"]
consume:
Slot: 24
Material: "COOKED_BEEF"
Name: "&f100 &dSteak"
Lore:
- "&b&lConsume &n100&r &d&lsteak"
Mission:
Type: "CONSUME"
# "ALL" can also be used for item
Item: "COOKED_BEEF"
Amount: 100
Reward:
Commands: ["f points add %faction% 100"]
############################################################ ############################################################
# +------------------------------------------------------+ # # +------------------------------------------------------+ #
@@ -815,6 +857,9 @@ fvault:
fchest: fchest:
Enabled: true Enabled: true
Inventory-Title: '&2&lFaction Chest' Inventory-Title: '&2&lFaction Chest'
Items-Not-Allowed:
- 'MOB_SPAWNER'
- 'COOKIE'
# Chest size upgrades can be configured in the upgrades section of config # Chest size upgrades can be configured in the upgrades section of config
############################################################ ############################################################
@@ -863,7 +908,7 @@ fupgrades:
- '' - ''
- '&e&lClick to &nUnlock' - '&e&lClick to &nUnlock'
slots: slots:
- 18 - 31
EXP: EXP:
EXP-Boost: EXP-Boost:
level-1: 1.5 level-1: 1.5
@@ -894,7 +939,7 @@ fupgrades:
- '' - ''
- '&e&lClick to &nUnlock' - '&e&lClick to &nUnlock'
slots: slots:
- 20 - 32
Power: Power:
Power-Boost: Power-Boost:
level-1: 100.0 level-1: 100.0
@@ -906,7 +951,7 @@ fupgrades:
level-3: 3000000 level-3: 3000000
PowerItem: PowerItem:
Name: '&c&lFaction Power' Name: '&c&lFaction Power'
Type: DIAMOND_SWORD Type: NETHER_STAR
Amount: 1 Amount: 1
Damage: 0 Damage: 0
Lore: Lore:
@@ -926,7 +971,7 @@ fupgrades:
- '' - ''
- '&e&lClick to &nUnlock' - '&e&lClick to &nUnlock'
slots: slots:
- 4 - 22
Redstone: Redstone:
Cost: 1000000 Cost: 1000000
RedstoneItem: RedstoneItem:
@@ -943,7 +988,7 @@ fupgrades:
- '&7 - Cost: $1,000,000' - '&7 - Cost: $1,000,000'
- '&e&lClick to &nUnlock' - '&e&lClick to &nUnlock'
slots: slots:
- 26 - 23
Spawners: Spawners:
Spawner-Boost: Spawner-Boost:
# This is a Percentage so .10 means 10% lowered spawner delay! # This is a Percentage so .10 means 10% lowered spawner delay!
@@ -974,6 +1019,134 @@ fupgrades:
- '&7 - Cost: $3,000,000' - '&7 - Cost: $3,000,000'
- '' - ''
- '&e&lClick to &nUnlock' - '&e&lClick to &nUnlock'
slots:
- 30
DamageReduct:
DamageReductPercent:
level-1: 3
level-2: 5
level-3: 7
Cost:
level-1: 2000000
level-2: 4000000
level-3: 6000000
ReduceItem:
Name: '&c&lDamage Reduction Upgrade'
Type: GOLD_CHESTPLATE
Amount: 1
Damage: 0
Lore:
- '&7Reduce the amount of damage taken'
- '&7in your faction claims.'
- ''
- '&c&lTier'
- '&f&l* &7Current Level: &3{level}/3'
- ''
- '&c&lPerks'
- '&f&l* &7Level 1 - &7((&f-3% Damage Per Hit&7))'
- '&7 - Cost: $2,000,000'
- '&f&l* &7Level 2 - &7((&f-5% Damage Per Hit&7))'
- '&7 - Cost: $4,000,000'
- '&f&l* &7Level 3 - &7((&f-7% Damage Per Hit&7))'
- '&7 - Cost: $6,000,000'
- ''
- '&e&lClick to &nUnlock'
slots:
- 7
DamageIncrease:
DamageIncreasePercent:
level-1: 3
level-2: 5
level-3: 7
Cost:
level-1: 2000000
level-2: 4000000
level-3: 6000000
IncreaseItem:
Name: '&c&lDamage Increase Upgrade'
Type: DIAMOND_SWORD
Amount: 1
Damage: 0
Lore:
- '&7Increase the amount of damage given'
- '&7in your faction claims.'
- ''
- '&c&lTier'
- '&f&l* &7Current Level: &3{level}/3'
- ''
- '&c&lPerks'
- '&f&l* &7Level 1 - &7((&f+3% Damage Per Hit&7))'
- '&7 - Cost: $2,000,000'
- '&f&l* &7Level 2 - &7((&f+5% Damage Per Hit&7))'
- '&7 - Cost: $4,000,000'
- '&f&l* &7Level 3 - &7((&f+7% Damage Per Hit&7))'
- '&7 - Cost: $6,000,000'
- ''
- '&e&lClick to &nUnlock'
slots:
- 1
TNT:
tnt-limit:
level-1: 500000
level-2: 1000000
level-3: 2000000
Cost:
level-1: 2000000
level-2: 4000000
level-3: 6000000
TntItem:
Name: '&c&lTNT Bank Upgrade'
Type: TNT
Amount: 1
Damage: 0
Lore:
- '&7Upgrade Your tnt bank limit,'
- '&7to be eligible to store more tnt.'
- ''
- '&c&lTier'
- '&f&l* &7Current Level: &3{level}/3'
- ''
- '&c&lPerks'
- '&f&l* &7Level 1 - &f500,000 TNT'
- '&7 - Cost: $2,000,000'
- '&f&l* &7Level 2 - &f1,000,000 TNT'
- '&7 - Cost: $4,000,000'
- '&f&l* &7Level 3 - &f2,000,000 TNT'
- '&7 - Cost: $6,000,000'
- ''
- '&e&lClick to &nUnlock'
slots:
- 21
Warps:
warp-limit:
level-1: 3
level-2: 4
level-3: 5
Cost:
level-1: 1000000
level-2: 2000000
level-3: 3000000
WarpItem:
Name: '&c&lWarp Upgrade'
Type: EYE_OF_ENDER
Amount: 1
Damage: 0
Lore:
- '&7Upgrade Your warp limit,'
- '&7to be able to set more warps.'
- ''
- '&c&lTier'
- '&f&l* &7Current Level: &3{level}/3'
- ''
- '&c&lPerks'
- '&f&l* &7Level 1 - &f3 Warps'
- '&7 - Cost: $1,000,000'
- '&f&l* &7Level 2 - &f4 Warps'
- '&7 - Cost: $2,000,000'
- '&f&l* &7Level 3 - &f5 Warps'
- '&7 - Cost: $3,000,000'
- ''
- '&e&lClick to &nUnlock'
slots: slots:
- 24 - 24
Chest: Chest:
@@ -1007,7 +1180,7 @@ fupgrades:
- '' - ''
- '&e&lClick to &nUnlock' - '&e&lClick to &nUnlock'
slots: slots:
- 40 - 20
Members: Members:
Members-Limit: Members-Limit:
level-1: 30 level-1: 30
@@ -1038,7 +1211,39 @@ fupgrades:
- '' - ''
- '&e&lClick to &nUnlock' - '&e&lClick to &nUnlock'
slots: slots:
- 22 - 40
Armor:
Armor-HP-Drop:
# HP Drop is in percent so .10 would mean it would drop 10% of the damage to the armor
level-1: .10
level-2: .15
level-3: .20
Cost:
level-1: 1000000
level-2: 2000000
level-3: 3000000
ArmorItem:
Name: '&c&lReinforced Armor Upgrade'
Type: DIAMOND_CHESTPLATE
Amount: 1
Damage: 0
Lore:
- '&7Decreases damage to armor.'
- ''
- '&c&lTier'
- '&f&l* &7Current Level: &3{level}/3'
- ''
- '&c&lPerks'
- '&f&l* &7Level 1 - &f10% Reduction'
- '&7 - Cost: $1,000,000'
- '&f&l* &7Level 2 - &f15% Reduction'
- '&7 - Cost: $2,000,000'
- '&f&l* &7Level 3 - &f20% Reduction'
- '&7 - Cost: $3,000,000'
- ''
- '&e&lClick to &nUnlock'
slots:
- 4
############################################################ ############################################################
# +------------------------------------------------------+ # # +------------------------------------------------------+ #
@@ -1127,6 +1332,7 @@ Tntfill:
# - {player-maxpower} : Player max power # - {player-maxpower} : Player max power
# - {player-kills} : # of kills the player has # - {player-kills} : # of kills the player has
# - {player-deaths}: # of deaths the player has # - {player-deaths}: # of deaths the player has
# - {total-online-visible}: # of players online from the perspective of the current player
# Faction variables. Can be used in tooltips.list, scoreboards, or /f show # Faction variables. Can be used in tooltips.list, scoreboards, or /f show
# - {header} : Default factions header (ex. /f show) # - {header} : Default factions header (ex. /f show)
# - {faction} : Factions tag (if none, uses lang.yml for factionless name) # - {faction} : Factions tag (if none, uses lang.yml for factionless name)

View File

@@ -22,6 +22,7 @@ permissions:
factions.modifypower: true factions.modifypower: true
factions.ahome: true factions.ahome: true
factions.setmaxvaults: true factions.setmaxvaults: true
factions.convertconfig: true
factions.*: factions.*:
description: This is just an alias for factions.kit.admin description: This is just an alias for factions.kit.admin
children: children:
@@ -157,6 +158,10 @@ permissions:
description: create a new faction description: create a new faction
factions.deinvite: factions.deinvite:
description: remove a pending invitation description: remove a pending invitation
factions.setdiscord:
description: set discord link
factions.discord:
description: view factions discord
factions.description: factions.description:
description: change the faction description description: change the faction description
factions.disband: factions.disband:
@@ -187,6 +192,8 @@ permissions:
description: see a list of the factions description: see a list of the factions
factions.lock: factions.lock:
description: lock all write stuff description: lock all write stuff
factions.lockspawners:
description: toggle placement of spawners
factions.managesafezone: factions.managesafezone:
description: claim land as a safe zone and build/destroy within safe zones description: claim land as a safe zone and build/destroy within safe zones
factions.managewarzone: factions.managewarzone: