Merge pull request #5 from Driftay/1.6.x

Merge
This commit is contained in:
DroppingAnvil 2019-09-19 19:25:36 -05:00 committed by GitHub
commit 31c3cc538a
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
37 changed files with 299 additions and 287 deletions

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-1.9.4-BETA</version>
<packaging>jar</packaging> <packaging>jar</packaging>
<name>SaberFactions</name> <name>SaberFactions</name>

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;

View File

@ -23,6 +23,8 @@ import java.util.concurrent.ConcurrentHashMap;
public interface Faction extends EconomyParticipator { public interface Faction extends EconomyParticipator {
void checkPerms();
double getReinforcedArmor(); double getReinforcedArmor();
void setReinforcedArmor(double percent); void setReinforcedArmor(double percent);

View File

@ -16,7 +16,6 @@ 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;
@ -267,7 +266,6 @@ public class FactionsPlugin extends MPlugin {
new FactionsExploitListener(), new FactionsExploitListener(),
new FactionsBlockListener(), new FactionsBlockListener(),
new FUpgradesGUI(), new FUpgradesGUI(),
new ShopClickPersistence(),
new UpgradesListener(), new UpgradesListener(),
new MissionHandler(this), new MissionHandler(this),
new ChestLogsHandler() new ChestLogsHandler()

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

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

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

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

@ -146,6 +146,7 @@ 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 FCmdRoot() { public FCmdRoot() {
super(); super();
@ -255,6 +256,7 @@ 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.useCheckSystem) { if (Conf.useCheckSystem) {
this.addSubCommand(this.cmdCheck); this.addSubCommand(this.cmdCheck);

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

@ -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;
@ -20,7 +21,7 @@ public class CmdGrace extends FCommand {
@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

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

@ -155,6 +155,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 +267,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;
} }

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

@ -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,119 @@
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.google.common.collect.ImmutableList;
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.Collections;
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

@ -50,6 +50,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"),

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

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

@ -592,6 +592,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();

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

View File

@ -706,6 +706,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."),
@ -717,7 +721,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"),

View File

@ -683,15 +683,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 | #
@ -1323,6 +1320,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

@ -188,6 +188,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: