Added toggle to disable party system

This commit is contained in:
nossr50
2019-03-18 07:46:33 -07:00
parent b0b326d080
commit 3a21a913c6
6 changed files with 55 additions and 8 deletions

View File

@ -6,6 +6,7 @@ import com.gmail.nossr50.commands.party.teleport.PtpCommand;
import com.gmail.nossr50.datatypes.party.Party;
import com.gmail.nossr50.datatypes.player.McMMOPlayer;
import com.gmail.nossr50.locale.LocaleLoader;
import com.gmail.nossr50.mcMMO;
import com.gmail.nossr50.util.Permissions;
import com.gmail.nossr50.util.commands.CommandUtils;
import com.gmail.nossr50.util.player.UserManager;
@ -59,6 +60,10 @@ public class PartyCommand implements TabExecutor {
@Override
public boolean onCommand(CommandSender sender, Command command, String label, String[] args) {
//If the party system is disabled, don't fire this command
if(!mcMMO.getConfigManager().getConfigParty().isPartySystemEnabled())
return true;
if (CommandUtils.noConsoleUsage(sender)) {
return true;
}

View File

@ -91,6 +91,8 @@ public class ConfigParty {
return partyCombat.isPartyFriendlyFire();
}
public boolean isPartySystemEnabled() { return partyGeneral.isEnablePartySystem(); }
/*

View File

@ -6,9 +6,15 @@ import ninja.leaping.configurate.objectmapping.serialize.ConfigSerializable;
@ConfigSerializable
public class ConfigSectionPartyGeneral {
public static final boolean PARTY_SYSTEM_DEFAULT = true;
@Setting(value = "Party-Limitations")
private ConfigSectionPartyLimit configSectionPartyLimit = new ConfigSectionPartyLimit();
@Setting(value = "Enable-Party-System", comment = "Turn this off to completely disable the mcMMO party system." +
"\nDefault value: "+PARTY_SYSTEM_DEFAULT)
private boolean enablePartySystem = PARTY_SYSTEM_DEFAULT;
public int getPartySizeLimit() {
return configSectionPartyLimit.partyMaxSize;
}
@ -16,4 +22,8 @@ public class ConfigSectionPartyGeneral {
public boolean isPartySizeCapped() {
return configSectionPartyLimit.useCap;
}
public boolean isEnablePartySystem() {
return enablePartySystem;
}
}

View File

@ -137,7 +137,8 @@ public class mcMMO extends JavaPlugin {
registerCoreSkills();
registerCustomRecipes();
PartyManager.loadParties();
if(getConfigManager().getConfigParty().isPartySystemEnabled())
PartyManager.loadParties();
formulaManager = new FormulaManager();
holidayManager = new HolidayManager();
@ -499,16 +500,21 @@ public class mcMMO extends JavaPlugin {
new UserPurgeTask().runTaskTimerAsynchronously(this, purgeIntervalTicks, purgeIntervalTicks);
}
// Automatically remove old members from parties
long kickIntervalTicks = getConfigManager().getConfigParty().getPartyCleanup().getPartyAutoKickHoursInterval() * 60L * 60L * Misc.TICK_CONVERSION_FACTOR;
//Party System Stuff
if(mcMMO.configManager.getConfigParty().isPartySystemEnabled())
{
// Automatically remove old members from parties
long kickIntervalTicks = getConfigManager().getConfigParty().getPartyCleanup().getPartyAutoKickHoursInterval() * 60L * 60L * Misc.TICK_CONVERSION_FACTOR;
if (kickIntervalTicks == 0) {
new PartyAutoKickTask().runTaskLater(this, 2 * Misc.TICK_CONVERSION_FACTOR); // Start 2 seconds after startup.
}
else if (kickIntervalTicks > 0) {
new PartyAutoKickTask().runTaskTimer(this, kickIntervalTicks, kickIntervalTicks);
if (kickIntervalTicks == 0) {
new PartyAutoKickTask().runTaskLater(this, 2 * Misc.TICK_CONVERSION_FACTOR); // Start 2 seconds after startup.
}
else if (kickIntervalTicks > 0) {
new PartyAutoKickTask().runTaskTimer(this, kickIntervalTicks, kickIntervalTicks);
}
}
// Update power level tag scoreboards
new PowerLevelUpdatingTask().runTaskTimer(this, 2 * Misc.TICK_CONVERSION_FACTOR, 2 * Misc.TICK_CONVERSION_FACTOR);

View File

@ -108,6 +108,11 @@ public final class PartyManager {
* @return true if they are in the same party, false otherwise
*/
public static boolean inSameParty(Player firstPlayer, Player secondPlayer) {
//If the party system is disabled, return false
if(!mcMMO.getConfigManager().getConfigParty().isPartySystemEnabled())
return false;
Party firstParty = UserManager.getPlayer(firstPlayer).getParty();
Party secondParty = UserManager.getPlayer(secondPlayer).getParty();
@ -119,6 +124,11 @@ public final class PartyManager {
}
public static boolean areAllies(Player firstPlayer, Player secondPlayer) {
//If the party system is disabled, return false
if(!mcMMO.getConfigManager().getConfigParty().isPartySystemEnabled())
return false;
Party firstParty = UserManager.getPlayer(firstPlayer).getParty();
Party secondParty = UserManager.getPlayer(secondPlayer).getParty();
@ -217,6 +227,10 @@ public final class PartyManager {
* @return the existing party, null otherwise
*/
public static Party getParty(String partyName) {
//If the party system is disabled, return null
if(!mcMMO.getConfigManager().getConfigParty().isPartySystemEnabled())
return null;
for (Party party : parties) {
if (party.getName().equalsIgnoreCase(partyName)) {
return party;
@ -234,6 +248,10 @@ public final class PartyManager {
*/
@Deprecated
public static Party getPlayerParty(String playerName) {
//If the party system is disabled, return null
if(!mcMMO.getConfigManager().getConfigParty().isPartySystemEnabled())
return null;
for (Party party : parties) {
if (party.getMembers().keySet().contains(playerName)) {
return party;
@ -250,6 +268,10 @@ public final class PartyManager {
* @return the existing party, null otherwise
*/
public static Party getPlayerParty(String playerName, UUID uuid) {
//If the party system is disabled, return null
if(!mcMMO.getConfigManager().getConfigParty().isPartySystemEnabled())
return null;
for (Party party : parties) {
LinkedHashMap<UUID, String> members = party.getMembers();
if (members.keySet().contains(uuid) || members.values().contains(playerName)) {