mirror of
https://github.com/mcMMO-Dev/mcMMO.git
synced 2024-11-25 22:56:45 +01:00
Put ShareMode in its own class.
This commit is contained in:
parent
e518b58b23
commit
ee86f8244f
@ -7,9 +7,8 @@ import org.bukkit.entity.Player;
|
|||||||
|
|
||||||
import com.gmail.nossr50.config.Config;
|
import com.gmail.nossr50.config.Config;
|
||||||
import com.gmail.nossr50.datatypes.party.Party;
|
import com.gmail.nossr50.datatypes.party.Party;
|
||||||
|
import com.gmail.nossr50.datatypes.party.ShareMode;
|
||||||
import com.gmail.nossr50.locale.LocaleLoader;
|
import com.gmail.nossr50.locale.LocaleLoader;
|
||||||
import com.gmail.nossr50.party.ShareHandler;
|
|
||||||
import com.gmail.nossr50.party.ShareHandler.ShareMode;
|
|
||||||
import com.gmail.nossr50.util.StringUtils;
|
import com.gmail.nossr50.util.StringUtils;
|
||||||
import com.gmail.nossr50.util.commands.CommandUtils;
|
import com.gmail.nossr50.util.commands.CommandUtils;
|
||||||
import com.gmail.nossr50.util.player.UserManager;
|
import com.gmail.nossr50.util.player.UserManager;
|
||||||
@ -46,7 +45,7 @@ public class PartyExpShareCommand implements CommandExecutor {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private void handleChangingShareMode(ShareHandler.ShareMode mode) {
|
private void handleChangingShareMode(ShareMode mode) {
|
||||||
playerParty.setXpShareMode(mode);
|
playerParty.setXpShareMode(mode);
|
||||||
|
|
||||||
String changeModeMessage = LocaleLoader.getString("Commands.Party.SetSharing", LocaleLoader.getString("Party.ShareType.Exp"), LocaleLoader.getString("Party.ShareMode." + StringUtils.getCapitalized(mode.toString())));
|
String changeModeMessage = LocaleLoader.getString("Commands.Party.SetSharing", LocaleLoader.getString("Party.ShareType.Exp"), LocaleLoader.getString("Party.ShareMode." + StringUtils.getCapitalized(mode.toString())));
|
||||||
|
@ -9,10 +9,10 @@ import org.bukkit.entity.Player;
|
|||||||
import com.gmail.nossr50.mcMMO;
|
import com.gmail.nossr50.mcMMO;
|
||||||
import com.gmail.nossr50.config.Config;
|
import com.gmail.nossr50.config.Config;
|
||||||
import com.gmail.nossr50.datatypes.party.Party;
|
import com.gmail.nossr50.datatypes.party.Party;
|
||||||
|
import com.gmail.nossr50.datatypes.party.ShareMode;
|
||||||
import com.gmail.nossr50.datatypes.player.McMMOPlayer;
|
import com.gmail.nossr50.datatypes.player.McMMOPlayer;
|
||||||
import com.gmail.nossr50.locale.LocaleLoader;
|
import com.gmail.nossr50.locale.LocaleLoader;
|
||||||
import com.gmail.nossr50.party.PartyManager;
|
import com.gmail.nossr50.party.PartyManager;
|
||||||
import com.gmail.nossr50.party.ShareHandler;
|
|
||||||
import com.gmail.nossr50.util.player.UserManager;
|
import com.gmail.nossr50.util.player.UserManager;
|
||||||
|
|
||||||
public class PartyInfoCommand implements CommandExecutor {
|
public class PartyInfoCommand implements CommandExecutor {
|
||||||
@ -63,7 +63,7 @@ public class PartyInfoCommand implements CommandExecutor {
|
|||||||
private void displayShareModeInfo() {
|
private void displayShareModeInfo() {
|
||||||
boolean xpShareEnabled = Config.getInstance().getExpShareEnabled();
|
boolean xpShareEnabled = Config.getInstance().getExpShareEnabled();
|
||||||
boolean itemShareEnabled = Config.getInstance().getItemShareEnabled();
|
boolean itemShareEnabled = Config.getInstance().getItemShareEnabled();
|
||||||
boolean itemSharingActive = (playerParty.getItemShareMode() != ShareHandler.ShareMode.NONE);
|
boolean itemSharingActive = (playerParty.getItemShareMode() != ShareMode.NONE);
|
||||||
|
|
||||||
if (!xpShareEnabled && !itemShareEnabled) {
|
if (!xpShareEnabled && !itemShareEnabled) {
|
||||||
return;
|
return;
|
||||||
|
@ -8,8 +8,8 @@ import org.bukkit.entity.Player;
|
|||||||
import com.gmail.nossr50.config.Config;
|
import com.gmail.nossr50.config.Config;
|
||||||
import com.gmail.nossr50.datatypes.party.ItemShareType;
|
import com.gmail.nossr50.datatypes.party.ItemShareType;
|
||||||
import com.gmail.nossr50.datatypes.party.Party;
|
import com.gmail.nossr50.datatypes.party.Party;
|
||||||
|
import com.gmail.nossr50.datatypes.party.ShareMode;
|
||||||
import com.gmail.nossr50.locale.LocaleLoader;
|
import com.gmail.nossr50.locale.LocaleLoader;
|
||||||
import com.gmail.nossr50.party.ShareHandler.ShareMode;
|
|
||||||
import com.gmail.nossr50.util.StringUtils;
|
import com.gmail.nossr50.util.StringUtils;
|
||||||
import com.gmail.nossr50.util.commands.CommandUtils;
|
import com.gmail.nossr50.util.commands.CommandUtils;
|
||||||
import com.gmail.nossr50.util.player.UserManager;
|
import com.gmail.nossr50.util.player.UserManager;
|
||||||
|
@ -7,7 +7,6 @@ import java.util.List;
|
|||||||
import org.bukkit.entity.Player;
|
import org.bukkit.entity.Player;
|
||||||
|
|
||||||
import com.gmail.nossr50.mcMMO;
|
import com.gmail.nossr50.mcMMO;
|
||||||
import com.gmail.nossr50.party.ShareHandler.ShareMode;
|
|
||||||
|
|
||||||
public class Party {
|
public class Party {
|
||||||
private final LinkedHashSet<String> members = new LinkedHashSet<String>();
|
private final LinkedHashSet<String> members = new LinkedHashSet<String>();
|
||||||
|
@ -0,0 +1,25 @@
|
|||||||
|
package com.gmail.nossr50.datatypes.party;
|
||||||
|
|
||||||
|
import com.gmail.nossr50.util.commands.CommandUtils;
|
||||||
|
|
||||||
|
public enum ShareMode {
|
||||||
|
NONE,
|
||||||
|
EQUAL,
|
||||||
|
RANDOM;
|
||||||
|
|
||||||
|
public static ShareMode getShareMode(String string) {
|
||||||
|
try {
|
||||||
|
return valueOf(string);
|
||||||
|
}
|
||||||
|
catch (IllegalArgumentException ex) {
|
||||||
|
if (string.equalsIgnoreCase("even")) {
|
||||||
|
return EQUAL;
|
||||||
|
}
|
||||||
|
else if (CommandUtils.shouldDisableToggle(string)) {
|
||||||
|
return NONE;
|
||||||
|
}
|
||||||
|
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
};
|
@ -11,6 +11,8 @@ import org.bukkit.entity.Player;
|
|||||||
|
|
||||||
import com.gmail.nossr50.mcMMO;
|
import com.gmail.nossr50.mcMMO;
|
||||||
import com.gmail.nossr50.datatypes.party.Party;
|
import com.gmail.nossr50.datatypes.party.Party;
|
||||||
|
import com.gmail.nossr50.datatypes.party.ShareMode;
|
||||||
|
|
||||||
import com.gmail.nossr50.datatypes.player.McMMOPlayer;
|
import com.gmail.nossr50.datatypes.player.McMMOPlayer;
|
||||||
import com.gmail.nossr50.events.party.McMMOPartyChangeEvent;
|
import com.gmail.nossr50.events.party.McMMOPartyChangeEvent;
|
||||||
import com.gmail.nossr50.events.party.McMMOPartyChangeEvent.EventReason;
|
import com.gmail.nossr50.events.party.McMMOPartyChangeEvent.EventReason;
|
||||||
@ -410,8 +412,8 @@ public final class PartyManager {
|
|||||||
party.setLeader(partiesFile.getString(partyName + ".Leader"));
|
party.setLeader(partiesFile.getString(partyName + ".Leader"));
|
||||||
party.setPassword(partiesFile.getString(partyName + ".Password"));
|
party.setPassword(partiesFile.getString(partyName + ".Password"));
|
||||||
party.setLocked(partiesFile.getBoolean(partyName + ".Locked"));
|
party.setLocked(partiesFile.getBoolean(partyName + ".Locked"));
|
||||||
party.setXpShareMode(ShareHandler.ShareMode.getShareMode(partiesFile.getString(partyName + ".ExpShareMode", "NONE")));
|
party.setXpShareMode(ShareMode.getShareMode(partiesFile.getString(partyName + ".ExpShareMode", "NONE")));
|
||||||
party.setItemShareMode(ShareHandler.ShareMode.getShareMode(partiesFile.getString(partyName + ".ItemShareMode", "NONE")));
|
party.setItemShareMode(ShareMode.getShareMode(partiesFile.getString(partyName + ".ItemShareMode", "NONE")));
|
||||||
|
|
||||||
List<String> memberNames = partiesFile.getStringList(partyName + ".Members");
|
List<String> memberNames = partiesFile.getStringList(partyName + ".Members");
|
||||||
LinkedHashSet<String> members = party.getMembers();
|
LinkedHashSet<String> members = party.getMembers();
|
||||||
|
@ -10,35 +10,13 @@ import com.gmail.nossr50.config.Config;
|
|||||||
import com.gmail.nossr50.config.party.ItemWeightConfig;
|
import com.gmail.nossr50.config.party.ItemWeightConfig;
|
||||||
import com.gmail.nossr50.datatypes.party.ItemShareType;
|
import com.gmail.nossr50.datatypes.party.ItemShareType;
|
||||||
import com.gmail.nossr50.datatypes.party.Party;
|
import com.gmail.nossr50.datatypes.party.Party;
|
||||||
|
import com.gmail.nossr50.datatypes.party.ShareMode;
|
||||||
import com.gmail.nossr50.datatypes.player.McMMOPlayer;
|
import com.gmail.nossr50.datatypes.player.McMMOPlayer;
|
||||||
import com.gmail.nossr50.datatypes.skills.SkillType;
|
import com.gmail.nossr50.datatypes.skills.SkillType;
|
||||||
import com.gmail.nossr50.util.Misc;
|
import com.gmail.nossr50.util.Misc;
|
||||||
import com.gmail.nossr50.util.commands.CommandUtils;
|
|
||||||
import com.gmail.nossr50.util.player.UserManager;
|
import com.gmail.nossr50.util.player.UserManager;
|
||||||
|
|
||||||
public final class ShareHandler {
|
public final class ShareHandler {
|
||||||
public enum ShareMode {
|
|
||||||
NONE,
|
|
||||||
EQUAL,
|
|
||||||
RANDOM;
|
|
||||||
|
|
||||||
public static ShareMode getShareMode(String string) {
|
|
||||||
try {
|
|
||||||
return valueOf(string);
|
|
||||||
}
|
|
||||||
catch (IllegalArgumentException ex) {
|
|
||||||
if (string.equalsIgnoreCase("even")) {
|
|
||||||
return EQUAL;
|
|
||||||
}
|
|
||||||
else if (CommandUtils.shouldDisableToggle(string)) {
|
|
||||||
return NONE;
|
|
||||||
}
|
|
||||||
|
|
||||||
return null;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
};
|
|
||||||
|
|
||||||
private ShareHandler() {}
|
private ShareHandler() {}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
Loading…
Reference in New Issue
Block a user