Move mcmmo into submodule

Goal will be to slowly move out the bukkit* dependencies from -core,
but, we have our starting point
This commit is contained in:
Shane Freeder
2019-09-30 20:53:44 +01:00
parent 3700128b21
commit 83373275f7
697 changed files with 74 additions and 60 deletions

View File

@ -0,0 +1,50 @@
import org.apache.tools.ant.filters.ReplaceTokens
plugins {
`java-library`
id("com.github.johnrengelman.shadow") version "5.1.0"
}
tasks {
shadowJar {
dependencies {
include(dependency("org.spongepowered:configurate-yaml"))
include(dependency("org.spongepowered:configurate-hocon"))
include(dependency("org.spongepowered:configurate-core"))
include(dependency("org.bstats:bstats-bukkit"))
include(dependency("org.apache.tomcat:tomcat-jdbc"))
include(dependency("org.apache.tomcat:tomcat-juli"))
include(dependency("com.typesafe:config"))
exclude(dependency("org.spigotmc:spigot"))
}
relocate("org.apache.commons.logging", "com.gmail.nossr50.commons.logging")
relocate("org.apache.juli", "com.gmail.nossr50.database.tomcat.juli")
relocate("org.apache.tomcat", "com.gmail.nossr50.database.tomcat")
relocate("org.bstats", "com.gmail.nossr50.metrics.bstat")
}
processResources {
filter<ReplaceTokens>("tokens" to mapOf("project.version" to project.version))
filesMatching("**/locales/*") {
}
}
}
dependencies {
api("org.apache.tomcat:tomcat-jdbc:7.0.52")
api("com.typesafe:config:1.3.2")
api("org.spongepowered:configurate-core:3.7-SNAPSHOT")
api("org.spongepowered:configurate-yaml:3.7-SNAPSHOT")
api("org.spongepowered:configurate-hocon:3.7-SNAPSHOT")
implementation("org.jetbrains:annotations:17.0.0")
implementation("org.apache.maven.scm:maven-scm-provider-gitexe:1.8.1")
implementation("org.bstats:bstats-bukkit:1.4")
implementation("org.spigotmc:spigot:1.14.4-R0.1-SNAPSHOT")
implementation("com.sk89q.worldguard:worldguard-legacy:7.0.0-SNAPSHOT")
testImplementation("junit:junit:4.10")
}

View File

@ -0,0 +1,16 @@
<assembly xmlns="http://maven.apache.org/plugins/maven-assembly-plugin/assembly/1.1.0"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://maven.apache.org/plugins/maven-assembly-plugin/assembly/1.1.0 http://maven.apache.org/xsd/assembly-1.1.0.xsd">
<id>bin</id>
<includeBaseDirectory>false</includeBaseDirectory>
<formats>
<format>zip</format>
</formats>
<files>
<file>
<source>${project.build.directory}/${artifactId}.jar</source>
<outputDirectory>/</outputDirectory>
<destName>mcMMO.jar</destName>
</file>
</files>
</assembly>

View File

@ -0,0 +1,3 @@
Manifest-Version: 1.0
Main-Class: com.gmail.nossr50.mcMMO

View File

@ -0,0 +1,89 @@
//package com.gmail.nossr50.api;
//
//import com.gmail.nossr50.datatypes.player.McMMOPlayer;
//import com.gmail.nossr50.datatypes.skills.SuperAbilityType;
//import com.gmail.nossr50.runnables.skills.BleedTimerTask;
//import com.gmail.nossr50.util.player.UserManager;
//import org.bukkit.entity.LivingEntity;
//import org.bukkit.entity.Player;
//
//public final class AbilityAPI {
// private AbilityAPI() {
// }
//
// public static boolean berserkEnabled(Player player) {
// return pluginRef.getUserManager().getPlayer(player).getAbilityMode(SuperAbilityType.BERSERK);
// }
//
// public static boolean gigaDrillBreakerEnabled(Player player) {
// return pluginRef.getUserManager().getPlayer(player).getAbilityMode(SuperAbilityType.GIGA_DRILL_BREAKER);
// }
//
// public static boolean greenTerraEnabled(Player player) {
// return pluginRef.getUserManager().getPlayer(player).getAbilityMode(SuperAbilityType.GREEN_TERRA);
// }
//
// public static boolean serratedStrikesEnabled(Player player) {
// return pluginRef.getUserManager().getPlayer(player).getAbilityMode(SuperAbilityType.SERRATED_STRIKES);
// }
//
// public static boolean skullSplitterEnabled(Player player) {
// return pluginRef.getUserManager().getPlayer(player).getAbilityMode(SuperAbilityType.SKULL_SPLITTER);
// }
//
// public static boolean superBreakerEnabled(Player player) {
// return pluginRef.getUserManager().getPlayer(player).getAbilityMode(SuperAbilityType.SUPER_BREAKER);
// }
//
// public static boolean treeFellerEnabled(Player player) {
// return pluginRef.getUserManager().getPlayer(player).getAbilityMode(SuperAbilityType.TREE_FELLER);
// }
//
// public static boolean isAnyAbilityEnabled(Player player) {
// McMMOPlayer mcMMOPlayer = pluginRef.getUserManager().getPlayer(player);
//
// for (SuperAbilityType ability : SuperAbilityType.values()) {
// if (mcMMOPlayer.getAbilityMode(ability)) {
// return true;
// }
// }
//
// return false;
// }
//
// public static void resetCooldowns(Player player) {
// pluginRef.getUserManager().getPlayer(player).resetCooldowns();
// }
//
// public static void setBerserkCooldown(Player player, long cooldown) {
// pluginRef.getUserManager().getPlayer(player).setAbilityDATS(SuperAbilityType.BERSERK, cooldown);
// }
//
// public static void setGigaDrillBreakerCooldown(Player player, long cooldown) {
// pluginRef.getUserManager().getPlayer(player).setAbilityDATS(SuperAbilityType.GIGA_DRILL_BREAKER, cooldown);
// }
//
// public static void setGreenTerraCooldown(Player player, long cooldown) {
// pluginRef.getUserManager().getPlayer(player).setAbilityDATS(SuperAbilityType.GREEN_TERRA, cooldown);
// }
//
// public static void setSerratedStrikesCooldown(Player player, long cooldown) {
// pluginRef.getUserManager().getPlayer(player).setAbilityDATS(SuperAbilityType.SERRATED_STRIKES, cooldown);
// }
//
// public static void setSkullSplitterCooldown(Player player, long cooldown) {
// pluginRef.getUserManager().getPlayer(player).setAbilityDATS(SuperAbilityType.SKULL_SPLITTER, cooldown);
// }
//
// public static void setSuperBreakerCooldown(Player player, long cooldown) {
// pluginRef.getUserManager().getPlayer(player).setAbilityDATS(SuperAbilityType.SUPER_BREAKER, cooldown);
// }
//
// public static void setTreeFellerCooldown(Player player, long cooldown) {
// pluginRef.getUserManager().getPlayer(player).setAbilityDATS(SuperAbilityType.TREE_FELLER, cooldown);
// }
//
// public static boolean isBleeding(LivingEntity entity) {
// return pluginRef.getBleedTimerTask().isBleeding(entity);
// }
//}

View File

@ -0,0 +1,154 @@
//package com.gmail.nossr50.api;
//
//import com.gmail.nossr50.chat.ChatManager;
//import com.gmail.nossr50.chat.ChatManagerFactory;
//import com.gmail.nossr50.chat.PartyChatManager;
//import com.gmail.nossr50.datatypes.chat.ChatMode;
//import com.gmail.nossr50.party.PartyManager;
//import com.gmail.nossr50.util.player.UserManager;
//import org.bukkit.entity.Player;
//import org.bukkit.plugin.Plugin;
//
//public final class ChatAPI {
// private ChatAPI() {
// }
//
// /**
// * Send a message to all members of a party
// * </br>
// * This function is designed for API usage.
// *
// * @param plugin The plugin sending the message
// * @param sender The name of the sender
// * @param displayName The display name of the sender
// * @param party The name of the party to send to
// * @param message The message to send
// */
// public static void sendPartyChat(Plugin plugin, String sender, String displayName, String party, String message) {
// getPartyChatManager(plugin, party).handleChat(sender, displayName, message);
// }
//
// /**
// * Send a message to all members of a party
// * </br>
// * This function is designed for API usage.
// *
// * @param plugin The plugin sending the message
// * @param sender The name of the sender to display in the chat
// * @param party The name of the party to send to
// * @param message The message to send
// */
// public static void sendPartyChat(Plugin plugin, String sender, String party, String message) {
// getPartyChatManager(plugin, party).handleChat(sender, message);
// }
//
// /**
// * Send a message to administrators
// * </br>
// * This function is designed for API usage.
// *
// * @param plugin The plugin sending the message
// * @param sender The name of the sender
// * @param displayName The display name of the sender
// * @param message The message to send
// */
// public static void sendAdminChat(Plugin plugin, String sender, String displayName, String message) {
// ChatManagerFactory.getChatManager(plugin, ChatMode.ADMIN).handleChat(sender, displayName, message);
// }
//
// /**
// * Send a message to administrators
// * </br>
// * This function is designed for API usage.
// *
// * @param plugin The plugin sending the message
// * @param sender The name of the sender to display in the chat
// * @param message The message to send
// */
// public static void sendAdminChat(Plugin plugin, String sender, String message) {
// ChatManagerFactory.getChatManager(plugin, ChatMode.ADMIN).handleChat(sender, message);
// }
//
// /**
// * Check if a player is currently talking in party chat.
// *
// * @param player The player to check
// * @return true if the player is using party chat, false otherwise
// */
// public static boolean isUsingPartyChat(Player player) {
// return pluginRef.getUserManager().getPlayer(player).isChatEnabled(ChatMode.PARTY);
// }
//
// /**
// * Check if a player is currently talking in party chat.
// *
// * @param playerName The name of the player to check
// * @return true if the player is using party chat, false otherwise
// */
// public static boolean isUsingPartyChat(String playerName) {
// return pluginRef.getUserManager().getPlayer(playerName).isChatEnabled(ChatMode.PARTY);
// }
//
// /**
// * Check if a player is currently talking in admin chat.
// *
// * @param player The player to check
// * @return true if the player is using admin chat, false otherwise
// */
// public static boolean isUsingAdminChat(Player player) {
// return pluginRef.getUserManager().getPlayer(player).isChatEnabled(ChatMode.ADMIN);
// }
//
// /**
// * Check if a player is currently talking in admin chat.
// *
// * @param playerName The name of the player to check
// * @return true if the player is using admin chat, false otherwise
// */
// public static boolean isUsingAdminChat(String playerName) {
// return pluginRef.getUserManager().getPlayer(playerName).isChatEnabled(ChatMode.ADMIN);
// }
//
// /**
// * Toggle the party chat mode of a player.
// *
// * @param player The player to toggle party chat on.
// */
// public static void togglePartyChat(Player player) {
// pluginRef.getUserManager().getPlayer(player).toggleChat(ChatMode.PARTY);
// }
//
// /**
// * Toggle the party chat mode of a player.
// *
// * @param playerName The name of the player to toggle party chat on.
// */
// public static void togglePartyChat(String playerName) {
// pluginRef.getUserManager().getPlayer(playerName).toggleChat(ChatMode.PARTY);
// }
//
// /**
// * Toggle the admin chat mode of a player.
// *
// * @param player The player to toggle admin chat on.
// */
// public static void toggleAdminChat(Player player) {
// pluginRef.getUserManager().getPlayer(player).toggleChat(ChatMode.ADMIN);
// }
//
// /**
// * Toggle the admin chat mode of a player.
// *
// * @param playerName The name of the player to toggle party chat on.
// */
// public static void toggleAdminChat(String playerName) {
// pluginRef.getUserManager().getPlayer(playerName).toggleChat(ChatMode.ADMIN);
// }
//
// private static ChatManager getPartyChatManager(Plugin plugin, String party) {
// ChatManager chatManager = ChatManagerFactory.getChatManager(plugin, ChatMode.PARTY);
// ((PartyChatManager) chatManager).setParty(pluginRef.getPartyManager().getParty(party));
//
// return chatManager;
// }
//}

View File

@ -0,0 +1,30 @@
//package com.gmail.nossr50.api;
//
//import com.gmail.nossr50.datatypes.player.PlayerProfile;
//import com.gmail.nossr50.mcMMO;
//
//import java.util.UUID;
//
//public class DatabaseAPI {
//
// /**
// * Checks if a player exists in the mcMMO Database
// * @param uuid player UUID
// * @return true if the player exists in the DB, false if they do not
// */
// public boolean doesPlayerExistInDB(String uuid) {
// return doesPlayerExistInDB(UUID.fromString(uuid));
// }
//
// /**
// * Checks if a player exists in the mcMMO Database
// * @param uuid player UUID
// * @return true if the player exists in the DB, false if they do not
// */
// public boolean doesPlayerExistInDB(UUID uuid) {
// PlayerProfile playerProfile = mcMMO.getDatabaseManager().loadPlayerProfile(uuid);
//
// return playerProfile.isLoaded();
// }
//
//}

File diff suppressed because it is too large Load Diff

View File

@ -0,0 +1,265 @@
//package com.gmail.nossr50.api;
//
//import com.gmail.nossr50.datatypes.interactions.NotificationType;
//import com.gmail.nossr50.datatypes.party.Party;
//import com.gmail.nossr50.datatypes.party.PartyLeader;
//import com.gmail.nossr50.mcMMO;
//import com.gmail.nossr50.party.PartyManager;
//import com.gmail.nossr50.util.player.UserManager;
//import org.bukkit.OfflinePlayer;
//import org.bukkit.entity.Player;
//
//import java.util.*;
//
//public final class PartyAPI {
// private PartyAPI() {
// }
//
// /**
// * Get the name of the party a player is in.
// * </br>
// * This function is designed for API usage.
// *
// * @param player The player to check the party name of
// * @return the name of the player's party, or null if not in a party
// */
// public static String getPartyName(Player player) {
// if (!inParty(player)) {
// return null;
// }
//
// return pluginRef.getUserManager().getPlayer(player).getParty().getName();
// }
//
// /**
// * Checks if a player is in a party.
// * </br>
// * This function is designed for API usage.
// *
// * @param player The player to check
// * @return true if the player is in a party, false otherwise
// */
// public static boolean inParty(Player player) {
// if (pluginRef.getUserManager().getPlayer(player) == null)
// return false;
//
// return pluginRef.getUserManager().getPlayer(player).inParty();
// }
//
// /**
// * Check if two players are in the same party.
// * </br>
// * This function is designed for API usage.
// *
// * @param playera The first player to check
// * @param playerb The second player to check
// * @return true if the two players are in the same party, false otherwise
// */
// public static boolean inSameParty(Player playera, Player playerb) {
// return pluginRef.getPartyManager().inSameParty(playera, playerb);
// }
//
// /**
// * Get a list of all current parties.
// * </br>
// * This function is designed for API usage.
// *
// * @return the list of parties.
// */
// public static List<Party> getParties() {
// return pluginRef.getPartyManager().getParties();
// }
//
// /**
// * Add a player to a party.
// * </br>
// * This function is designed for API usage.
// *
// * @param player The player to add to the party
// * @param partyName The party to add the player to
// * @deprecated parties can have limits, use the other method
// */
// @Deprecated
// public static void addToParty(Player player, String partyName) {
// //Check if player profile is loaded
// if (pluginRef.getUserManager().getPlayer(player) == null)
// return;
//
// Party party = pluginRef.getPartyManager().getParty(partyName);
//
// if (party == null) {
// party = new Party(new PartyLeader(player.getUniqueId(), player.getName()), partyName);
// } else if (mcMMO.getConfigManager().getConfigParty().getPartyGeneral().isPartySizeCapped()) {
// if (pluginRef.getPartyManager().isPartyFull(player, party)) {
// mcMMO.getNotificationManager().sendPlayerInformation(player, NotificationType.PARTY_MESSAGE, "Commands.Party.PartyFull", party.toString());
// return;
// }
// }
//
// pluginRef.getPartyManager().addToParty(pluginRef.getUserManager().getPlayer(player), party);
// }
//
// /**
// * The max party size of the server
// * Limits are only enforced if the enforcement setting is on
// *
// * @return the max party size on this server
// */
// public static int getMaxPartySize() {
// return mcMMO.getConfigManager().getConfigParty().getPartySizeLimit();
// }
//
// /**
// * Checks if parties are currently size capped which is determined by the user config
// *
// * @return true if parties are size capped
// */
// public static boolean isPartySizeCapped() {
// return mcMMO.getConfigManager().getConfigParty().isPartySizeCapped();
// }
//
// /**
// * Add a player to a party.
// * </br>
// * This function is designed for API usage.
// *
// * @param player The player to add to the party
// * @param partyName The party to add the player to
// * @param bypassLimit if true bypasses party size limits
// */
// //TODO: bypasslimit not used?
// public static void addToParty(Player player, String partyName, boolean bypassLimit) {
// //Check if player profile is loaded
// if (pluginRef.getUserManager().getPlayer(player) == null)
// return;
//
// Party party = pluginRef.getPartyManager().getParty(partyName);
//
// if (party == null) {
// party = new Party(new PartyLeader(player.getUniqueId(), player.getName()), partyName);
// }
//
// pluginRef.getPartyManager().addToParty(pluginRef.getUserManager().getPlayer(player), party);
// }
//
// /**
// * Remove a player from a party.
// * </br>
// * This function is designed for API usage.
// *
// * @param player The player to remove
// */
// public static void removeFromParty(Player player) {
// //Check if player profile is loaded
// if (pluginRef.getUserManager().getPlayer(player) == null)
// return;
//
// pluginRef.getPartyManager().removeFromParty(pluginRef.getUserManager().getPlayer(player));
// }
//
// /**
// * Get the leader of a party.
// * </br>
// * This function is designed for API usage.
// *
// * @param partyName The party name
// * @return the leader of the party
// */
// public static String getPartyLeader(String partyName) {
// return pluginRef.getPartyManager().getPartyLeaderName(partyName);
// }
//
// /**
// * Set the leader of a party.
// * </br>
// * This function is designed for API usage.
// *
// * @param partyName The name of the party to set the leader of
// * @param playerName The playerName to set as leader
// */
// @Deprecated
// public static void setPartyLeader(String partyName, String playerName) {
// pluginRef.getPartyManager().setPartyLeader(mcMMO.p.getServer().getOfflinePlayer(playerName).getUniqueId(), pluginRef.getPartyManager().getParty(partyName));
// }
//
// /**
// * Get a list of all players in this player's party.
// * </br>
// * This function is designed for API usage.
// *
// * @param player The player to check
// * @return all the players in the player's party
// */
// @Deprecated
// public static List<OfflinePlayer> getOnlineAndOfflineMembers(Player player) {
// List<OfflinePlayer> members = new ArrayList<>();
//
// for (UUID memberUniqueId : pluginRef.getPartyManager().getAllMembers(player).keySet()) {
// OfflinePlayer member = mcMMO.p.getServer().getOfflinePlayer(memberUniqueId);
// members.add(member);
// }
// return members;
// }
//
// /**
// * Get a list of all player names in this player's party.
// * </br>
// * This function is designed for API usage.
// *
// * @param player The player to check
// * @return all the player names in the player's party
// */
// @Deprecated
// public static LinkedHashSet<String> getMembers(Player player) {
// return (LinkedHashSet<String>) pluginRef.getPartyManager().getAllMembers(player).values();
// }
//
// /**
// * Get a list of all player names and uuids in this player's party.
// * </br>
// * This function is designed for API usage.
// *
// * @param player The player to check
// * @return all the player names and uuids in the player's party
// */
// public static LinkedHashMap<UUID, String> getMembersMap(Player player) {
// return pluginRef.getPartyManager().getAllMembers(player);
// }
//
// /**
// * Get a list of all online players in this party.
// * </br>
// * This function is designed for API usage.
// *
// * @param partyName The party to check
// * @return all online players in this party
// */
// public static List<Player> getOnlineMembers(String partyName) {
// return pluginRef.getPartyManager().getOnlineMembers(partyName);
// }
//
// /**
// * Get a list of all online players in this player's party.
// * </br>
// * This function is designed for API usage.
// *
// * @param player The player to check
// * @return all online players in the player's party
// */
// public static List<Player> getOnlineMembers(Player player) {
// return pluginRef.getPartyManager().getOnlineMembers(player);
// }
//
// public static boolean hasAlly(String partyName) {
// return getAllyName(partyName) != null;
// }
//
// public static String getAllyName(String partyName) {
// Party ally = pluginRef.getPartyManager().getParty(partyName).getAlly();
// if (ally != null) {
// return ally.getName();
// }
//
// return null;
// }
//}

View File

@ -0,0 +1,94 @@
//package com.gmail.nossr50.api;
//
//import com.gmail.nossr50.datatypes.skills.PrimarySkillType;
//
//import java.util.ArrayList;
//import java.util.Arrays;
//import java.util.List;
//
//public final class SkillAPI {
// private SkillAPI() {
// }
//
// /**
// * Returns a list of strings with mcMMO's skills
// * This includes parent and child skills
// * </br>
// * This function is designed for API usage.
// *
// * @return a list of strings with valid skill names
// */
// public static List<String> getSkills() {
// return getListFromEnum(Arrays.asList(PrimarySkillType.values()));
// }
//
// /**
// * Returns a list of strings with mcMMO's skills
// * This only includes parent skills
// * </br>
// * This function is designed for API usage.
// *
// * @return a list of strings with valid skill names
// */
// public static List<String> getNonChildSkills() {
// return getListFromEnum(pluginRef.getSkillTools().NON_CHILD_SKILLS);
// }
//
// /**
// * Returns a list of strings with mcMMO's skills
// * This only includes child skills
// * </br>
// * This function is designed for API usage.
// *
// * @return a list of strings with valid skill names
// */
// public static List<String> getChildSkills() {
// return getListFromEnum(PrimarySkillType.CHILD_SKILLS);
// }
//
// /**
// * Returns a list of strings with mcMMO's skills
// * This only includes combat skills
// * </br>
// * This function is designed for API usage.
// *
// * @return a list of strings with valid skill names
// */
// public static List<String> getCombatSkills() {
// return getListFromEnum(PrimarySkillType.COMBAT_SKILLS);
// }
//
// /**
// * Returns a list of strings with mcMMO's skills
// * This only includes gathering skills
// * </br>
// * This function is designed for API usage.
// *
// * @return a list of strings with valid skill names
// */
// public static List<String> getGatheringSkills() {
// return getListFromEnum(PrimarySkillType.GATHERING_SKILLS);
// }
//
// /**
// * Returns a list of strings with mcMMO's skills
// * This only includes misc skills
// * </br>
// * This function is designed for API usage.
// *
// * @return a list of strings with valid skill names
// */
// public static List<String> getMiscSkills() {
// return getListFromEnum(PrimarySkillType.MISC_SKILLS);
// }
//
// private static List<String> getListFromEnum(List<PrimarySkillType> skillsTypes) {
// List<String> skills = new ArrayList<>();
//
// for (PrimarySkillType primarySkillType : skillsTypes) {
// skills.add(primarySkillType.name());
// }
//
// return skills;
// }
//}

View File

@ -0,0 +1,9 @@
package com.gmail.nossr50.api.exceptions;
public class InvalidFormulaTypeException extends RuntimeException {
private static final long serialVersionUID = 3368670229490121886L;
public InvalidFormulaTypeException() {
super("That is not a valid FormulaType.");
}
}

View File

@ -0,0 +1,9 @@
package com.gmail.nossr50.api.exceptions;
public class InvalidPlayerException extends RuntimeException {
private static final long serialVersionUID = 907213002618581385L;
public InvalidPlayerException() {
super("That player does not exist in the database.");
}
}

View File

@ -0,0 +1,9 @@
package com.gmail.nossr50.api.exceptions;
public class InvalidSkillException extends RuntimeException {
private static final long serialVersionUID = 942705284195791157L;
public InvalidSkillException(String s) {
super(s + " does not match a valid skill.");
}
}

View File

@ -0,0 +1,9 @@
package com.gmail.nossr50.api.exceptions;
public class InvalidXPGainReasonException extends RuntimeException {
private static final long serialVersionUID = 4427052841957931157L;
public InvalidXPGainReasonException() {
super("That is not a valid XPGainReason.");
}
}

View File

@ -0,0 +1,11 @@
package com.gmail.nossr50.api.exceptions;
import org.bukkit.entity.Player;
public class McMMOPlayerNotFoundException extends RuntimeException {
private static final long serialVersionUID = 761917904993202836L;
public McMMOPlayerNotFoundException(Player player) {
super("McMMOPlayer object was not found for [NOTE: This can mean the profile is not loaded yet!] : " + player.getName() + " " + player.getUniqueId());
}
}

View File

@ -0,0 +1,7 @@
package com.gmail.nossr50.api.exceptions;
public class MissingSkillPropertyDefinition extends RuntimeException {
public MissingSkillPropertyDefinition(String details) {
super("A skill property is undefined! Details: " + details);
}
}

View File

@ -0,0 +1,9 @@
package com.gmail.nossr50.api.exceptions;
import com.gmail.nossr50.datatypes.skills.PrimarySkillType;
public class UndefinedSkillBehaviour extends RuntimeException {
public UndefinedSkillBehaviour(PrimarySkillType primarySkillType) {
super("Undefined behaviour for skill! - " + primarySkillType.toString());
}
}

View File

@ -0,0 +1,26 @@
package com.gmail.nossr50.bukkit;
import com.gmail.nossr50.datatypes.items.BukkitMMOItem;
import com.gmail.nossr50.datatypes.items.MMOItem;
import com.gmail.nossr50.util.nbt.NBTManager;
import com.gmail.nossr50.util.nbt.RawNBT;
import org.bukkit.inventory.ItemStack;
/**
* Used to convert or construct platform independent types into Bukkit types
*/
public class BukkitFactory {
/**
* Creates a BukkitMMOItem which contains Bukkit implementations for the type MMOItem
* @return a new BukkitMMOItem
*/
public static MMOItem<?> createItem(String namespaceKey, int amount, RawNBT rawNBT) {
return new BukkitMMOItem(namespaceKey, amount, rawNBT);
}
public static MMOItem<?> createItem(ItemStack itemStack) {
return createItem(itemStack.getType().getKey().toString(), itemStack.getAmount(), new RawNBT(NBTManager.getNBT(itemStack).toString()));
}
}

View File

@ -0,0 +1,105 @@
package com.gmail.nossr50.chat;
import com.gmail.nossr50.datatypes.party.Party;
import com.gmail.nossr50.datatypes.player.McMMOPlayer;
import com.gmail.nossr50.events.chat.McMMOAdminChatEvent;
import com.gmail.nossr50.events.chat.McMMOPartyChatEvent;
import com.gmail.nossr50.mcMMO;
import org.bukkit.ChatColor;
import org.bukkit.entity.Player;
import java.util.regex.Matcher;
import java.util.regex.Pattern;
public class ChatManager {
private final String ADMIN_CHAT_PERMISSION = "mcmmo.chat.adminchat";
private final mcMMO pluginRef;
public ChatManager(mcMMO pluginRef) {
this.pluginRef = pluginRef;
}
public void processAdminChat(Player player, String message) {
sendAdminChatMessage(new McMMOAdminChatEvent(pluginRef, player.getName(), player.getDisplayName(), message));
}
public void processAdminChat(String senderName, String displayName, String message) {
sendAdminChatMessage(new McMMOAdminChatEvent(pluginRef, senderName, displayName, message));
}
public void processPartyChat(Party party, Player sender, String message) {
sendPartyChatMessage(new McMMOPartyChatEvent(pluginRef, sender.getName(), sender.getDisplayName(), party, message));
}
public void processPartyChat(Party party, String senderName, String message) {
sendPartyChatMessage(new McMMOPartyChatEvent(pluginRef, senderName, senderName, party, message));
}
private void sendAdminChatMessage(McMMOAdminChatEvent event) {
pluginRef.getServer().getPluginManager().callEvent(event);
if (event.isCancelled()) {
return;
}
String chatPrefix = pluginRef.getConfigManager().getConfigCommands().getAdminChatPrefix();
String senderName = event.getSender();
String displayName = pluginRef.getConfigManager().getConfigCommands().isUseDisplayNames() ? event.getDisplayName() : senderName;
String message = pluginRef.getLocaleManager().formatString(chatPrefix, displayName) + " " + event.getMessage();
pluginRef.getServer().broadcast(message, ADMIN_CHAT_PERMISSION);
}
private void sendPartyChatMessage(McMMOPartyChatEvent event) {
pluginRef.getServer().getPluginManager().callEvent(event);
if (event.isCancelled()) {
return;
}
Party party = event.getParty();
String chatPrefix = pluginRef.getConfigManager().getConfigParty().getPartyChatPrefixFormat();
String senderName = event.getSender();
String displayName = pluginRef.getConfigManager().getConfigCommands().isUseDisplayNames() ? event.getDisplayName() : senderName;
String message = pluginRef.getLocaleManager().formatString(chatPrefix, displayName) + " " + event.getMessage();
if (pluginRef.getConfigManager().getConfigParty().isPartyLeaderColoredGold()
&& senderName.equalsIgnoreCase(party.getLeader().getPlayerName())) {
message = message.replaceFirst(Pattern.quote(displayName), ChatColor.GOLD + Matcher.quoteReplacement(displayName) + ChatColor.RESET);
}
for (Player member : party.getOnlineMembers()) {
member.sendMessage(message);
}
if (party.getAlly() != null) {
for (Player member : party.getAlly().getOnlineMembers()) {
String allyPrefix = pluginRef.getLocaleManager().formatString(pluginRef.getConfigManager().getConfigParty().getPartyChatPrefixAlly());
member.sendMessage(allyPrefix + message);
}
}
pluginRef.getServer().getConsoleSender().sendMessage(ChatColor.stripColor("[mcMMO] [P]<" + party.getName() + ">" + message));
/*
* Party Chat Spying
*/
for (McMMOPlayer mcMMOPlayer : pluginRef.getUserManager().getPlayers()) {
Player player = mcMMOPlayer.getPlayer();
//Check for toggled players
if (mcMMOPlayer.isPartyChatSpying()) {
Party adminParty = mcMMOPlayer.getParty();
//Only message admins not part of this party
if (adminParty != null) {
//TODO: Incorporate JSON
if (adminParty != event.getParty())
player.sendMessage(pluginRef.getLocaleManager().getString("Commands.AdminChatSpy.Chat", event.getParty(), message));
} else {
player.sendMessage(pluginRef.getLocaleManager().getString("Commands.AdminChatSpy.Chat", event.getParty(), message));
}
}
}
}
}

View File

@ -0,0 +1,33 @@
package com.gmail.nossr50.commands;
import com.gmail.nossr50.datatypes.player.McMMOPlayer;
import com.gmail.nossr50.mcMMO;
import org.bukkit.command.CommandSender;
public class AbilityToggleCommand extends ToggleCommand {
public AbilityToggleCommand(mcMMO pluginRef) {
super(pluginRef);
}
@Override
protected boolean hasOtherPermission(CommandSender sender) {
return pluginRef.getPermissionTools().mcabilityOthers(sender);
}
@Override
protected boolean hasSelfPermission(CommandSender sender) {
return pluginRef.getPermissionTools().mcability(sender);
}
@Override
protected void applyCommandAction(McMMOPlayer mcMMOPlayer) {
mcMMOPlayer.getPlayer().sendMessage(pluginRef.getLocaleManager().getString("Commands.Ability." + (mcMMOPlayer.getAllowAbilityUse() ? "Off" : "On")));
mcMMOPlayer.toggleAbilityUse();
}
@Override
protected void sendSuccessMessage(CommandSender sender, String playerName) {
sender.sendMessage(pluginRef.getLocaleManager().getString("Commands.Ability.Toggle", playerName));
}
}

View File

@ -0,0 +1,48 @@
package com.gmail.nossr50.commands;
import com.gmail.nossr50.datatypes.player.McMMOPlayer;
import com.gmail.nossr50.mcMMO;
import com.google.common.collect.ImmutableList;
import org.bukkit.command.Command;
import org.bukkit.command.CommandSender;
import org.bukkit.command.TabExecutor;
import org.bukkit.entity.Player;
import java.util.List;
public class ChatNotificationToggleCommand implements TabExecutor {
private final mcMMO pluginRef;
public ChatNotificationToggleCommand(mcMMO pluginRef) {
this.pluginRef = pluginRef;
}
@Override
public boolean onCommand(CommandSender sender, Command command, String label, String[] args) {
if (pluginRef.getCommandTools().noConsoleUsage(sender)) {
return true;
}
switch (args.length) {
case 0:
McMMOPlayer mcMMOPlayer = pluginRef.getUserManager().getPlayer((Player) sender);
//Not Loaded yet
if (mcMMOPlayer == null)
sender.sendMessage(pluginRef.getLocaleManager().getString("Profile.PendingLoad"));
sender.sendMessage(pluginRef.getLocaleManager().getString("Commands.Notifications." + (mcMMOPlayer.useChatNotifications() ? "Off" : "On")));
mcMMOPlayer.toggleChatNotifications();
return true;
default:
return false;
}
}
@Override
public List<String> onTabComplete(CommandSender sender, Command command, String alias, String[] args) {
return ImmutableList.of();
}
}

View File

@ -0,0 +1,12 @@
package com.gmail.nossr50.commands;
import com.google.common.collect.ImmutableList;
import java.util.List;
public class CommandConstants {
public static final List<String> TELEPORT_SUBCOMMANDS = ImmutableList.of("toggle", "accept", "acceptany", "acceptall");
public static final List<String> ALLIANCE_SUBCOMMANDS = ImmutableList.of("invite", "accept", "disband");
public static final List<String> TRUE_FALSE_OPTIONS = ImmutableList.of("on", "off", "true", "false", "enabled", "disabled");
public static final List<String> RESET_OPTIONS = ImmutableList.of("clear", "reset");
}

View File

@ -0,0 +1,96 @@
package com.gmail.nossr50.commands;
import com.gmail.nossr50.commands.database.ConvertDatabaseCommand;
import com.gmail.nossr50.commands.experience.ConvertExperienceCommand;
import com.gmail.nossr50.datatypes.database.DatabaseType;
import com.gmail.nossr50.datatypes.experience.FormulaType;
import com.gmail.nossr50.mcMMO;
import com.google.common.collect.ImmutableList;
import org.bukkit.command.Command;
import org.bukkit.command.CommandExecutor;
import org.bukkit.command.CommandSender;
import org.bukkit.command.TabExecutor;
import org.bukkit.util.StringUtil;
import java.util.ArrayList;
import java.util.Collections;
import java.util.List;
public class ConvertCommand implements TabExecutor {
private List<String> FORMULA_TYPES;
private List<String> DATABASE_TYPES;
private final List<String> CONVERSION_SUBCOMMANDS = ImmutableList.of("database", "experience");
private CommandExecutor databaseConvertCommand;
private CommandExecutor experienceConvertCommand;
private final mcMMO pluginRef;
public ConvertCommand(mcMMO pluginRef) {
this.pluginRef = pluginRef;
databaseConvertCommand = new ConvertDatabaseCommand(pluginRef);
experienceConvertCommand = new ConvertExperienceCommand(pluginRef);
initTypes();
}
private void initTypes() {
ArrayList<String> formulaTypes = new ArrayList<>();
ArrayList<String> databaseTypes = new ArrayList<>();
for (FormulaType type : FormulaType.values()) {
formulaTypes.add(type.toString());
}
for (DatabaseType type : DatabaseType.values()) {
databaseTypes.add(type.toString());
}
// Custom stuff
databaseTypes.remove(DatabaseType.CUSTOM.toString());
if (pluginRef.getDatabaseManager().getDatabaseType() == DatabaseType.CUSTOM) {
databaseTypes.add(pluginRef.getDatabaseManagerFactory().getCustomDatabaseManagerClass().getName());
}
Collections.sort(formulaTypes);
Collections.sort(databaseTypes);
FORMULA_TYPES = ImmutableList.copyOf(formulaTypes);
DATABASE_TYPES = ImmutableList.copyOf(databaseTypes);
}
@Override
public boolean onCommand(CommandSender sender, Command command, String label, String[] args) {
switch (args.length) {
case 2:
if (args[0].equalsIgnoreCase("database") || args[0].equalsIgnoreCase("db")) {
return databaseConvertCommand.onCommand(sender, command, label, args);
} else if (args[0].equalsIgnoreCase("experience") || args[0].equalsIgnoreCase("xp") || args[1].equalsIgnoreCase("exp")) {
return experienceConvertCommand.onCommand(sender, command, label, args);
}
return false;
default:
return false;
}
}
@Override
public List<String> onTabComplete(CommandSender sender, Command command, String alias, String[] args) {
switch (args.length) {
case 1:
return StringUtil.copyPartialMatches(args[0], CONVERSION_SUBCOMMANDS, new ArrayList<>(CONVERSION_SUBCOMMANDS.size()));
case 2:
if (args[1].equalsIgnoreCase("database") || args[1].equalsIgnoreCase("db")) {
return StringUtil.copyPartialMatches(args[0], DATABASE_TYPES, new ArrayList<>(DATABASE_TYPES.size()));
}
if (args[1].equalsIgnoreCase("experience") || args[1].equalsIgnoreCase("xp") || args[1].equalsIgnoreCase("exp")) {
return StringUtil.copyPartialMatches(args[0], FORMULA_TYPES, new ArrayList<>(FORMULA_TYPES.size()));
}
return ImmutableList.of();
default:
return ImmutableList.of();
}
}
}

View File

@ -0,0 +1,124 @@
package com.gmail.nossr50.commands;
import com.gmail.nossr50.datatypes.notifications.SensitiveCommandType;
import com.gmail.nossr50.mcMMO;
import com.gmail.nossr50.util.StringUtils;
import com.google.common.collect.ImmutableList;
import org.bukkit.ChatColor;
import org.bukkit.command.Command;
import org.bukkit.command.CommandSender;
import org.bukkit.command.TabExecutor;
import org.bukkit.util.StringUtil;
import java.util.ArrayList;
import java.util.List;
public class ExperienceRateCommand implements TabExecutor {
private final mcMMO pluginRef;
public ExperienceRateCommand(mcMMO pluginRef) {
this.pluginRef = pluginRef;
}
@Override
public boolean onCommand(CommandSender sender, Command command, String label, String[] args) {
switch (args.length) {
case 1:
if (!args[0].equalsIgnoreCase("reset") && !args[0].equalsIgnoreCase("clear")) {
return false;
}
if (!pluginRef.getPermissionTools().xprateReset(sender)) {
sender.sendMessage(command.getPermissionMessage());
return true;
}
if (pluginRef.isXPEventEnabled()) {
if (pluginRef.getConfigManager().getConfigEvent().isSendTitleMessages()) {
pluginRef.getNotificationManager().broadcastTitle(pluginRef.getServer(),
pluginRef.getLocaleManager().getString("Commands.Event.Stop"),
pluginRef.getLocaleManager().getString("Commands.Event.Stop.Subtitle"),
10, 10 * 20, 20);
}
if (pluginRef.getConfigManager().getConfigEvent().isBroadcastXPRateEventMessages()) {
pluginRef.getServer().broadcastMessage(pluginRef.getLocaleManager().getString("Commands.Event.Stop"));
pluginRef.getServer().broadcastMessage(pluginRef.getLocaleManager().getString("Commands.Event.Stop.Subtitle"));
}
//Admin notification
pluginRef.getNotificationManager().processSensitiveCommandNotification(sender, SensitiveCommandType.XPRATE_END);
pluginRef.toggleXpEventEnabled();
}
pluginRef.getDynamicSettingsManager().getExperienceManager().resetGlobalXpMult();
return true;
case 2:
if (pluginRef.getCommandTools().isInvalidInteger(sender, args[0])) {
return true;
}
if (!pluginRef.getPermissionTools().xprateSet(sender)) {
sender.sendMessage(command.getPermissionMessage());
return true;
}
if (pluginRef.getCommandTools().shouldDisableToggle(args[1])) {
pluginRef.setXPEventEnabled(false);
} else if (pluginRef.getCommandTools().shouldEnableToggle(args[1])) {
pluginRef.setXPEventEnabled(true);
} else {
return false;
}
int newXpRate = Integer.parseInt(args[0]);
if (newXpRate < 0) {
sender.sendMessage(ChatColor.RED + pluginRef.getLocaleManager().getString("Commands.NegativeNumberWarn"));
return true;
}
pluginRef.getDynamicSettingsManager().getExperienceManager().setGlobalXpMult(newXpRate);
if (pluginRef.getConfigManager().getConfigEvent().isSendTitleMessages()) {
pluginRef.getNotificationManager().broadcastTitle(pluginRef.getServer(),
pluginRef.getLocaleManager().getString("Commands.Event.Start"),
pluginRef.getLocaleManager().getString("Commands.Event.XP", newXpRate),
10, 10 * 20, 20);
}
if (pluginRef.getConfigManager().getConfigEvent().isBroadcastXPRateEventMessages()) {
pluginRef.getServer().broadcastMessage(pluginRef.getLocaleManager().getString("Commands.Event.Start"));
pluginRef.getServer().broadcastMessage(pluginRef.getLocaleManager().getString("Commands.Event.XP", newXpRate));
}
//Admin notification
pluginRef.getNotificationManager().processSensitiveCommandNotification(sender, SensitiveCommandType.XPRATE_MODIFY, String.valueOf(newXpRate));
return true;
default:
return false;
}
}
@Override
public List<String> onTabComplete(CommandSender sender, Command command, String alias, String[] args) {
switch (args.length) {
case 1:
if (StringUtils.isInt(args[0])) {
return ImmutableList.of();
}
return StringUtil.copyPartialMatches(args[0], CommandConstants.RESET_OPTIONS, new ArrayList<>(CommandConstants.RESET_OPTIONS.size()));
case 2:
return StringUtil.copyPartialMatches(args[1], CommandConstants.TRUE_FALSE_OPTIONS, new ArrayList<>(CommandConstants.TRUE_FALSE_OPTIONS.size()));
default:
return ImmutableList.of();
}
}
}

View File

@ -0,0 +1,33 @@
package com.gmail.nossr50.commands;
import com.gmail.nossr50.datatypes.player.McMMOPlayer;
import com.gmail.nossr50.mcMMO;
import org.bukkit.command.CommandSender;
public class GodModeCommand extends ToggleCommand {
public GodModeCommand(mcMMO pluginRef) {
super(pluginRef);
}
@Override
protected boolean hasOtherPermission(CommandSender sender) {
return pluginRef.getPermissionTools().mcgodOthers(sender);
}
@Override
protected boolean hasSelfPermission(CommandSender sender) {
return pluginRef.getPermissionTools().mcgod(sender);
}
@Override
protected void applyCommandAction(McMMOPlayer mcMMOPlayer) {
mcMMOPlayer.getPlayer().sendMessage(pluginRef.getLocaleManager().getString("Commands.GodMode." + (mcMMOPlayer.getGodMode() ? "Disabled" : "Enabled")));
mcMMOPlayer.toggleGodMode();
}
@Override
protected void sendSuccessMessage(CommandSender sender, String playerName) {
sender.sendMessage(pluginRef.getLocaleManager().getString("Commands.GodMode.Toggle", playerName));
}
}

View File

@ -0,0 +1,118 @@
package com.gmail.nossr50.commands;
import com.gmail.nossr50.commands.party.PartySubcommandType;
import com.gmail.nossr50.mcMMO;
import org.bukkit.ChatColor;
import org.bukkit.command.Command;
import org.bukkit.command.CommandExecutor;
import org.bukkit.command.CommandSender;
public class McMMOCommand implements CommandExecutor {
private final mcMMO pluginRef;
public McMMOCommand(mcMMO pluginRef) {
this.pluginRef = pluginRef;
}
@Override
public boolean onCommand(CommandSender sender, Command command, String label, String[] args) {
switch (args.length) {
case 0:
if (!pluginRef.getPermissionTools().mcmmoDescription(sender)) {
sender.sendMessage(command.getPermissionMessage());
return true;
}
String description = pluginRef.getLocaleManager().getString("mcMMO.Description");
String[] mcSplit = description.split(",");
sender.sendMessage(mcSplit);
sender.sendMessage(pluginRef.getLocaleManager().getString("mcMMO.Description.FormerDevs"));
if (pluginRef.getConfigManager().getConfigAds().isShowDonationInfo()) {
sender.sendMessage(pluginRef.getLocaleManager().getString("MOTD.Donate"));
sender.sendMessage(ChatColor.GOLD + " - " + ChatColor.GREEN + "nossr50@gmail.com" + ChatColor.GOLD + " Paypal");
}
sender.sendMessage(pluginRef.getLocaleManager().getString("MOTD.Version", pluginRef.getDescription().getVersion()));
// mcMMO.getHolidayManager().anniversaryCheck(sender);
return true;
case 1:
if (args[0].equalsIgnoreCase("?") || args[0].equalsIgnoreCase("help") || args[0].equalsIgnoreCase("commands")) {
if (!pluginRef.getPermissionTools().mcmmoHelp(sender)) {
sender.sendMessage(command.getPermissionMessage());
return true;
}
sender.sendMessage(pluginRef.getLocaleManager().getString("Commands.mcc.Header"));
displayGeneralCommands(sender);
displayOtherCommands(sender);
displayPartyCommands(sender);
}
return true;
default:
return false;
}
}
private void displayGeneralCommands(CommandSender sender) {
sender.sendMessage(ChatColor.DARK_AQUA + " /mcstats " + pluginRef.getLocaleManager().getString("Commands.Stats"));
sender.sendMessage(ChatColor.DARK_AQUA + " /<skill>" + pluginRef.getLocaleManager().getString("Commands.SkillInfo"));
sender.sendMessage(ChatColor.DARK_AQUA + " /mctop " + pluginRef.getLocaleManager().getString("Commands.Leaderboards"));
if (pluginRef.getPermissionTools().inspect(sender)) {
sender.sendMessage(ChatColor.DARK_AQUA + " /inspect " + pluginRef.getLocaleManager().getString("Commands.Inspect"));
}
if (pluginRef.getPermissionTools().mcability(sender)) {
sender.sendMessage(ChatColor.DARK_AQUA + " /mcability " + pluginRef.getLocaleManager().getString("Commands.ToggleAbility"));
}
}
private void displayOtherCommands(CommandSender sender) {
//Don't show them this category if they have none of the permissions
if (!pluginRef.getPermissionTools().skillreset(sender) && !pluginRef.getPermissionTools().mmoedit(sender) && !pluginRef.getPermissionTools().adminChat(sender) && !pluginRef.getPermissionTools().mcgod(sender))
return;
sender.sendMessage(pluginRef.getLocaleManager().getString("Commands.Other"));
if (pluginRef.getPermissionTools().skillreset(sender)) {
sender.sendMessage(ChatColor.DARK_AQUA + " /skillreset <skill|all> " + pluginRef.getLocaleManager().getString("Commands.Reset"));
}
if (pluginRef.getPermissionTools().mmoedit(sender)) {
sender.sendMessage(ChatColor.DARK_AQUA + " /mmoedit " + pluginRef.getLocaleManager().getString("Commands.mmoedit"));
}
if (pluginRef.getPermissionTools().adminChat(sender)) {
sender.sendMessage(ChatColor.DARK_AQUA + " /adminchat " + pluginRef.getLocaleManager().getString("Commands.AdminToggle"));
}
if (pluginRef.getPermissionTools().mcgod(sender)) {
sender.sendMessage(ChatColor.DARK_AQUA + " /mcgod " + pluginRef.getLocaleManager().getString("Commands.mcgod"));
}
}
private void displayPartyCommands(CommandSender sender) {
if (pluginRef.getPermissionTools().party(sender)) {
sender.sendMessage(pluginRef.getLocaleManager().getString("Commands.Party.Commands"));
sender.sendMessage(ChatColor.DARK_AQUA + " /party create <" + pluginRef.getLocaleManager().getString("Commands.Usage.PartyName") + "> " + pluginRef.getLocaleManager().getString("Commands.Party1"));
sender.sendMessage(ChatColor.DARK_AQUA + " /party join <" + pluginRef.getLocaleManager().getString("Commands.Usage.Player") + "> " + pluginRef.getLocaleManager().getString("Commands.Party2"));
sender.sendMessage(ChatColor.DARK_AQUA + " /party quit " + pluginRef.getLocaleManager().getString("Commands.Party.Quit"));
if (pluginRef.getPermissionTools().partyChat(sender)) {
sender.sendMessage(ChatColor.DARK_AQUA + " /party chat " + pluginRef.getLocaleManager().getString("Commands.Party.Toggle"));
}
sender.sendMessage(ChatColor.DARK_AQUA + " /party invite <" + pluginRef.getLocaleManager().getString("Commands.Usage.Player") + "> " + pluginRef.getLocaleManager().getString("Commands.Party.Invite"));
sender.sendMessage(ChatColor.DARK_AQUA + " /party accept " + pluginRef.getLocaleManager().getString("Commands.Party.Accept"));
if (pluginRef.getPermissionTools().partySubcommand(sender, PartySubcommandType.TELEPORT)) {
sender.sendMessage(ChatColor.DARK_AQUA + " /party teleport <" + pluginRef.getLocaleManager().getString("Commands.Usage.Player") + "> " + pluginRef.getLocaleManager().getString("Commands.Party.Teleport"));
}
}
}
}

View File

@ -0,0 +1,37 @@
package com.gmail.nossr50.commands;
import com.gmail.nossr50.datatypes.player.McMMOPlayer;
import com.gmail.nossr50.mcMMO;
import org.bukkit.command.CommandSender;
public class RefreshCooldownsCommand extends ToggleCommand {
public RefreshCooldownsCommand(mcMMO pluginRef) {
super(pluginRef);
}
@Override
protected boolean hasOtherPermission(CommandSender sender) {
return pluginRef.getPermissionTools().mcrefreshOthers(sender);
}
@Override
protected boolean hasSelfPermission(CommandSender sender) {
return pluginRef.getPermissionTools().mcrefresh(sender);
}
@Override
protected void applyCommandAction(McMMOPlayer mcMMOPlayer) {
mcMMOPlayer.setRecentlyHurt(0);
mcMMOPlayer.resetCooldowns();
mcMMOPlayer.resetToolPrepMode();
mcMMOPlayer.resetSuperAbilityMode();
mcMMOPlayer.getPlayer().sendMessage(pluginRef.getLocaleManager().getString("Ability.Generic.Refresh"));
}
@Override
protected void sendSuccessMessage(CommandSender sender, String playerName) {
sender.sendMessage(pluginRef.getLocaleManager().getString("Commands.mcrefresh.Success", playerName));
}
}

View File

@ -0,0 +1,49 @@
package com.gmail.nossr50.commands;
import com.gmail.nossr50.database.FlatFileDatabaseManager;
import com.gmail.nossr50.database.SQLDatabaseManager;
import com.gmail.nossr50.datatypes.player.McMMOPlayer;
import com.gmail.nossr50.mcMMO;
import com.google.common.collect.ImmutableList;
import org.bukkit.command.Command;
import org.bukkit.command.CommandSender;
import org.bukkit.command.TabExecutor;
import java.util.List;
public class ResetUserHealthBarSettingsCommand implements TabExecutor {
private final mcMMO pluginRef;
public ResetUserHealthBarSettingsCommand(mcMMO pluginRef) {
this.pluginRef = pluginRef;
}
@Override
public boolean onCommand(CommandSender sender, Command command, String label, String[] args) {
if (pluginRef.getDatabaseManager() instanceof SQLDatabaseManager) {
SQLDatabaseManager sqlDatabaseManager = (SQLDatabaseManager) pluginRef.getDatabaseManager();
sqlDatabaseManager.resetMobHealthSettings();
for (McMMOPlayer player : pluginRef.getUserManager().getPlayers()) {
player.getProfile().setMobHealthbarType(pluginRef.getConfigManager().getConfigMobs().getCombat().getHealthBars().getDisplayBarType());
}
sender.sendMessage("Mob health reset");
return true;
}
if (pluginRef.getDatabaseManager() instanceof FlatFileDatabaseManager) {
FlatFileDatabaseManager flatFileDatabaseManager = (FlatFileDatabaseManager) pluginRef.getDatabaseManager();
flatFileDatabaseManager.resetMobHealthSettings();
for (McMMOPlayer player : pluginRef.getUserManager().getPlayers()) {
player.getProfile().setMobHealthbarType(pluginRef.getConfigManager().getConfigMobs().getCombat().getHealthBars().getDisplayBarType());
}
sender.sendMessage("Mob health reset");
return true;
}
return false;
}
@Override
public List<String> onTabComplete(CommandSender sender, Command command, String alias, String[] args) {
return ImmutableList.of();
}
}

View File

@ -0,0 +1,92 @@
package com.gmail.nossr50.commands;
import com.gmail.nossr50.mcMMO;
import com.google.common.collect.ImmutableList;
import org.bukkit.command.Command;
import org.bukkit.command.CommandSender;
import org.bukkit.command.TabExecutor;
import org.bukkit.util.StringUtil;
import java.util.ArrayList;
import java.util.List;
public class ScoreboardCommand implements TabExecutor {
private final mcMMO pluginRef;
public ScoreboardCommand(mcMMO pluginRef) {
this.pluginRef = pluginRef;
}
private static final List<String> FIRST_ARGS = ImmutableList.of("keep", "time", "clear");
@Override
public boolean onCommand(CommandSender sender, Command command, String label, String[] args) {
if (pluginRef.getCommandTools().noConsoleUsage(sender)) {
return true;
}
switch (args.length) {
case 1:
if (args[0].equalsIgnoreCase("clear") || args[0].equalsIgnoreCase("reset")) {
pluginRef.getScoreboardManager().clearBoard(sender.getName());
sender.sendMessage(pluginRef.getLocaleManager().getString("Commands.Scoreboard.Clear"));
return true;
}
if (args[0].equalsIgnoreCase("keep")) {
if (!pluginRef.getScoreboardSettings().getScoreboardsEnabled()) {
sender.sendMessage(pluginRef.getLocaleManager().getString("Commands.Disabled"));
return true;
}
if (!pluginRef.getScoreboardManager().isBoardShown(sender.getName())) {
sender.sendMessage(pluginRef.getLocaleManager().getString("Commands.Scoreboard.NoBoard"));
return true;
}
pluginRef.getScoreboardManager().keepBoard(sender.getName());
sender.sendMessage(pluginRef.getLocaleManager().getString("Commands.Scoreboard.Keep"));
return true;
}
return help(sender);
case 2:
if (args[0].equalsIgnoreCase("time") || args[0].equalsIgnoreCase("timer")) {
if (pluginRef.getCommandTools().isInvalidInteger(sender, args[1])) {
return true;
}
int time = Math.abs(Integer.parseInt(args[1]));
pluginRef.getScoreboardManager().setRevertTimer(sender.getName(), time);
sender.sendMessage(pluginRef.getLocaleManager().getString("Commands.Scoreboard.Timer", time));
return true;
}
return help(sender);
default:
return help(sender);
}
}
@Override
public List<String> onTabComplete(CommandSender sender, Command command, String alias, String[] args) {
switch (args.length) {
case 1:
return StringUtil.copyPartialMatches(args[0], FIRST_ARGS, new ArrayList<>(FIRST_ARGS.size()));
default:
return ImmutableList.of();
}
}
private boolean help(CommandSender sender) {
sender.sendMessage(pluginRef.getLocaleManager().getString("Commands.Scoreboard.Help.0"));
sender.sendMessage(pluginRef.getLocaleManager().getString("Commands.Scoreboard.Help.1"));
sender.sendMessage(pluginRef.getLocaleManager().getString("Commands.Scoreboard.Help.2"));
sender.sendMessage(pluginRef.getLocaleManager().getString("Commands.Scoreboard.Help.3"));
return true;
}
}

View File

@ -0,0 +1,87 @@
package com.gmail.nossr50.commands;
import com.gmail.nossr50.datatypes.player.McMMOPlayer;
import com.gmail.nossr50.mcMMO;
import com.google.common.collect.ImmutableList;
import org.bukkit.command.Command;
import org.bukkit.command.CommandSender;
import org.bukkit.command.TabExecutor;
import org.bukkit.util.StringUtil;
import java.util.ArrayList;
import java.util.List;
public abstract class ToggleCommand implements TabExecutor {
protected mcMMO pluginRef;
public ToggleCommand(mcMMO pluginRef) {
this.pluginRef = pluginRef;
}
@Override
public boolean onCommand(CommandSender sender, Command command, String label, String[] args) {
switch (args.length) {
case 0:
if (pluginRef.getCommandTools().noConsoleUsage(sender)) {
return true;
}
if (!hasSelfPermission(sender)) {
sender.sendMessage(command.getPermissionMessage());
return true;
}
if (!pluginRef.getCommandTools().hasPlayerDataKey(sender)) {
return true;
}
applyCommandAction(pluginRef.getUserManager().getPlayer(sender.getName()));
return true;
case 1:
if (!hasOtherPermission(sender)) {
sender.sendMessage(command.getPermissionMessage());
return true;
}
String playerName = pluginRef.getCommandTools().getMatchedPlayerName(args[0]);
McMMOPlayer mcMMOPlayer = pluginRef.getUserManager().getPlayer(playerName);
if (!pluginRef.getCommandTools().checkPlayerExistence(sender, playerName, mcMMOPlayer)) {
return true;
}
//TODO: Does it matter if they are offline?
/*if (pluginRef.getCommandTools().isOffline(sender, mcMMOPlayer.getPlayer())) {
return true;
}*/
applyCommandAction(mcMMOPlayer);
sendSuccessMessage(sender, playerName);
return true;
default:
return false;
}
}
@Override
public List<String> onTabComplete(CommandSender sender, Command command, String alias, String[] args) {
switch (args.length) {
case 1:
List<String> playerNames = pluginRef.getCommandTools().getOnlinePlayerNames(sender);
return StringUtil.copyPartialMatches(args[0], playerNames, new ArrayList<>(playerNames.size()));
default:
return ImmutableList.of();
}
}
protected abstract boolean hasOtherPermission(CommandSender sender);
protected abstract boolean hasSelfPermission(CommandSender sender);
protected abstract void applyCommandAction(McMMOPlayer mcMMOPlayer);
protected abstract void sendSuccessMessage(CommandSender sender, String playerName);
}

View File

@ -0,0 +1,20 @@
package com.gmail.nossr50.commands.admin;
import com.gmail.nossr50.mcMMO;
import org.bukkit.command.Command;
import org.bukkit.command.CommandExecutor;
import org.bukkit.command.CommandSender;
public class PlayerDebug implements CommandExecutor {
private final mcMMO pluginRef;
public PlayerDebug(mcMMO pluginRef) {
this.pluginRef = pluginRef;
}
@Override
public boolean onCommand(CommandSender sender, Command command, String label, String[] args) {
return false;
}
}

View File

@ -0,0 +1,30 @@
package com.gmail.nossr50.commands.admin;
import com.gmail.nossr50.datatypes.player.McMMOPlayer;
import com.gmail.nossr50.mcMMO;
import org.bukkit.command.Command;
import org.bukkit.command.CommandExecutor;
import org.bukkit.command.CommandSender;
import org.bukkit.entity.Player;
public class PlayerDebugCommand implements CommandExecutor {
private final mcMMO pluginRef;
public PlayerDebugCommand(mcMMO pluginRef) {
this.pluginRef = pluginRef;
}
@Override
public boolean onCommand(CommandSender sender, Command command, String label, String[] args) {
if(sender instanceof Player) {
McMMOPlayer mcMMOPlayer = pluginRef.getUserManager().getPlayer((Player) sender);
mcMMOPlayer.toggleDebugMode(); //Toggle debug mode
pluginRef.getNotificationManager().sendPlayerInformationChatOnlyPrefixed(mcMMOPlayer.getPlayer(), "Commands.Mmodebug.Toggle", String.valueOf(mcMMOPlayer.isDebugMode()));
return true;
} else {
return false;
}
}
}

View File

@ -0,0 +1,36 @@
package com.gmail.nossr50.commands.admin;
import com.gmail.nossr50.mcMMO;
import org.bukkit.command.Command;
import org.bukkit.command.CommandExecutor;
import org.bukkit.command.CommandSender;
/**
* @author Mark Vainomaa
*/
public final class ReloadLocaleCommand implements CommandExecutor {
private final mcMMO pluginRef;
public ReloadLocaleCommand(mcMMO pluginRef) {
this.pluginRef = pluginRef;
}
@Override
public boolean onCommand(CommandSender sender, Command command, String label, String[] args) {
if (args.length == 0) {
if (!pluginRef.getPermissionTools().reloadlocale(sender)) {
if(command.getPermissionMessage() != null)
sender.sendMessage(command.getPermissionMessage());
return true;
}
pluginRef.getLocaleManager().reloadLocale();
sender.sendMessage(pluginRef.getLocaleManager().getString("Locale.Reloaded"));
return true;
}
return false;
}
}

View File

@ -0,0 +1,16 @@
package com.gmail.nossr50.commands.chat;
import com.gmail.nossr50.datatypes.chat.ChatMode;
import com.gmail.nossr50.mcMMO;
import org.bukkit.command.CommandSender;
public class AdminChatCommand extends ChatCommand {
public AdminChatCommand(mcMMO pluginRef) {
super(ChatMode.ADMIN, pluginRef);
}
@Override
protected void handleChatSending(CommandSender sender, String[] args) {
pluginRef.getChatManager().processAdminChat(sender.getName(), getDisplayName(sender), buildChatMessage(args, 0));
}
}

View File

@ -0,0 +1,159 @@
package com.gmail.nossr50.commands.chat;
import com.gmail.nossr50.commands.CommandConstants;
import com.gmail.nossr50.datatypes.chat.ChatMode;
import com.gmail.nossr50.datatypes.party.PartyFeature;
import com.gmail.nossr50.datatypes.player.McMMOPlayer;
import com.gmail.nossr50.mcMMO;
import com.google.common.collect.ImmutableList;
import org.bukkit.command.Command;
import org.bukkit.command.CommandSender;
import org.bukkit.command.TabExecutor;
import org.bukkit.entity.Player;
import org.bukkit.util.StringUtil;
import java.util.ArrayList;
import java.util.List;
public abstract class ChatCommand implements TabExecutor {
private ChatMode chatMode;
protected mcMMO pluginRef;
ChatCommand(ChatMode chatMode, mcMMO pluginRef) {
this.chatMode = chatMode;
this.pluginRef = pluginRef;
}
@Override
public boolean onCommand(CommandSender sender, Command command, String label, String[] args) {
McMMOPlayer mcMMOPlayer;
switch (args.length) {
case 0:
if (pluginRef.getCommandTools().noConsoleUsage(sender)) {
return true;
}
if (!pluginRef.getCommandTools().hasPlayerDataKey(sender)) {
return true;
}
mcMMOPlayer = pluginRef.getUserManager().getPlayer(sender.getName());
if (mcMMOPlayer.isChatEnabled(chatMode)) {
disableChatMode(mcMMOPlayer, sender);
} else {
enableChatMode(mcMMOPlayer, sender);
}
return true;
case 1:
if (pluginRef.getCommandTools().shouldEnableToggle(args[0])) {
if (pluginRef.getCommandTools().noConsoleUsage(sender)) {
return true;
}
if (!pluginRef.getCommandTools().hasPlayerDataKey(sender)) {
return true;
}
enableChatMode(pluginRef.getUserManager().getPlayer(sender.getName()), sender);
return true;
}
if (pluginRef.getCommandTools().shouldDisableToggle(args[0])) {
if (pluginRef.getCommandTools().noConsoleUsage(sender)) {
return true;
}
if (!pluginRef.getCommandTools().hasPlayerDataKey(sender)) {
return true;
}
disableChatMode(pluginRef.getUserManager().getPlayer(sender.getName()), sender);
return true;
}
// Fallthrough
default:
handleChatSending(sender, args);
return true;
}
}
@Override
public List<String> onTabComplete(CommandSender sender, Command command, String alias, String[] args) {
switch (args.length) {
case 1:
return StringUtil.copyPartialMatches(args[0], CommandConstants.TRUE_FALSE_OPTIONS, new ArrayList<>(CommandConstants.TRUE_FALSE_OPTIONS.size()));
default:
return ImmutableList.of();
}
}
protected String buildChatMessage(String[] args, int index) {
StringBuilder builder = new StringBuilder();
builder.append(args[index]);
for (int i = index + 1; i < args.length; i++) {
builder.append(" ");
builder.append(args[i]);
}
return builder.toString();
}
protected String getDisplayName(CommandSender sender) {
return (sender instanceof Player) ? ((Player) sender).getDisplayName() : pluginRef.getLocaleManager().getString("Commands.Chat.Console");
}
protected abstract void handleChatSending(CommandSender sender, String[] args);
private void enableChatMode(McMMOPlayer mcMMOPlayer, CommandSender sender) {
if (chatMode == ChatMode.PARTY && mcMMOPlayer.getParty() == null) {
sender.sendMessage(pluginRef.getLocaleManager().getString("Commands.Party.None"));
return;
}
if (chatMode == ChatMode.PARTY && (mcMMOPlayer.getParty().getLevel() < pluginRef.getPartyManager().getPartyFeatureUnlockLevel(PartyFeature.CHAT))) {
sender.sendMessage(pluginRef.getLocaleManager().getString("Party.Feature.Disabled.1"));
return;
}
mcMMOPlayer.enableChat(chatMode);
sender.sendMessage(getChatModeEnabledMessage(chatMode, true));
}
private void disableChatMode(McMMOPlayer mcMMOPlayer, CommandSender sender) {
if (chatMode == ChatMode.PARTY && mcMMOPlayer.getParty() == null) {
sender.sendMessage(pluginRef.getLocaleManager().getString("Commands.Party.None"));
return;
}
mcMMOPlayer.disableChat(chatMode);
sender.sendMessage(getChatModeEnabledMessage(chatMode, false));
}
private String getChatModeEnabledMessage(ChatMode chatMode, boolean enabled) {
switch(chatMode) {
case ADMIN:
return getAdminMessage(enabled);
default:
return getPartyMessage(enabled);
}
}
private String getAdminMessage(boolean enabled) {
if(enabled)
return pluginRef.getLocaleManager().getString("Commands.AdminChat.On");
else
return pluginRef.getLocaleManager().getString("Commands.AdminChat.Off");
}
private String getPartyMessage(boolean enabled) {
if(enabled)
return pluginRef.getLocaleManager().getString("Commands.Party.Chat.On");
else
return pluginRef.getLocaleManager().getString("Commands.Party.Chat.Off");
}
}

View File

@ -0,0 +1,34 @@
package com.gmail.nossr50.commands.chat;
import com.gmail.nossr50.commands.ToggleCommand;
import com.gmail.nossr50.datatypes.player.McMMOPlayer;
import com.gmail.nossr50.mcMMO;
import org.bukkit.command.CommandSender;
public class ChatSpyCommand extends ToggleCommand {
public ChatSpyCommand(mcMMO pluginRef) {
super(pluginRef);
}
@Override
protected boolean hasOtherPermission(CommandSender sender) {
return pluginRef.getPermissionTools().adminChatSpyOthers(sender);
}
@Override
protected boolean hasSelfPermission(CommandSender sender) {
return pluginRef.getPermissionTools().adminChatSpy(sender);
}
@Override
protected void applyCommandAction(McMMOPlayer mcMMOPlayer) {
mcMMOPlayer.getPlayer().sendMessage(pluginRef.getLocaleManager().getString("Commands.AdminChatSpy." + (mcMMOPlayer.isPartyChatSpying() ? "Disabled" : "Enabled")));
mcMMOPlayer.togglePartyChatSpying();
}
@Override
protected void sendSuccessMessage(CommandSender sender, String playerName) {
sender.sendMessage(pluginRef.getLocaleManager().getString("Commands.AdminChatSpy.Toggle", playerName));
}
}

View File

@ -0,0 +1,56 @@
package com.gmail.nossr50.commands.chat;
import com.gmail.nossr50.datatypes.chat.ChatMode;
import com.gmail.nossr50.datatypes.party.Party;
import com.gmail.nossr50.datatypes.party.PartyFeature;
import com.gmail.nossr50.mcMMO;
import org.bukkit.command.CommandSender;
import org.bukkit.entity.Player;
public class PartyChatCommand extends ChatCommand {
public PartyChatCommand(mcMMO pluginRef) {
super(ChatMode.PARTY, pluginRef);
}
@Override
protected void handleChatSending(CommandSender sender, String[] args) {
Party party;
String message;
if (sender instanceof Player) {
//Check if player profile is loaded
if (pluginRef.getUserManager().getPlayer((Player) sender) == null)
return;
party = pluginRef.getUserManager().getPlayer((Player) sender).getParty();
if (party == null) {
sender.sendMessage(pluginRef.getLocaleManager().getString("Commands.Party.None"));
return;
}
if (party.getLevel() < pluginRef.getPartyManager().getPartyFeatureUnlockLevel(PartyFeature.CHAT)) {
sender.sendMessage(pluginRef.getLocaleManager().getString("Party.Feature.Disabled.1"));
return;
}
message = buildChatMessage(args, 0);
} else {
if (args.length < 2) {
sender.sendMessage(pluginRef.getLocaleManager().getString("Party.Specify"));
return;
}
party = pluginRef.getPartyManager().getParty(args[0]);
if (party == null) {
sender.sendMessage(pluginRef.getLocaleManager().getString("Party.InvalidName"));
return;
}
message = buildChatMessage(args, 1);
}
pluginRef.getChatManager().processPartyChat(party, getDisplayName(sender), message);
}
}

View File

@ -0,0 +1,93 @@
package com.gmail.nossr50.commands.database;
import com.gmail.nossr50.database.DatabaseManager;
import com.gmail.nossr50.datatypes.database.DatabaseType;
import com.gmail.nossr50.datatypes.player.PlayerProfile;
import com.gmail.nossr50.mcMMO;
import com.gmail.nossr50.runnables.database.DatabaseConversionTask;
import com.gmail.nossr50.runnables.player.PlayerProfileLoadingTask;
import org.bukkit.command.Command;
import org.bukkit.command.CommandExecutor;
import org.bukkit.command.CommandSender;
import org.bukkit.entity.Player;
public class ConvertDatabaseCommand implements CommandExecutor {
private final mcMMO pluginRef;
public ConvertDatabaseCommand(mcMMO pluginRef) {
this.pluginRef = pluginRef;
}
@Override
public boolean onCommand(CommandSender sender, Command command, String label, String[] args) {
switch (args.length) {
case 2:
DatabaseType previousType = getDatabaseType(args[1]);
DatabaseType newType = pluginRef.getDatabaseManager().getDatabaseType();
if (previousType == newType || (newType == DatabaseType.CUSTOM && pluginRef.getDatabaseManagerFactory().getCustomDatabaseManagerClass().getSimpleName().equalsIgnoreCase(args[1]))) {
sender.sendMessage(pluginRef.getLocaleManager().getString("Commands.mcconvert.Database.Same", newType.toString()));
return true;
}
DatabaseManager oldDatabase = pluginRef.getDatabaseManagerFactory().createDatabaseManager(previousType);
if (previousType == DatabaseType.CUSTOM) {
Class<?> clazz;
try {
clazz = Class.forName(args[1]);
if (!DatabaseManager.class.isAssignableFrom(clazz)) {
sender.sendMessage(pluginRef.getLocaleManager().getString("Commands.mcconvert.Database.InvalidType", args[1]));
return true;
}
oldDatabase = pluginRef.getDatabaseManagerFactory().createCustomDatabaseManager((Class<? extends DatabaseManager>) clazz);
} catch (Throwable e) {
e.printStackTrace();
sender.sendMessage(pluginRef.getLocaleManager().getString("Commands.mcconvert.Database.InvalidType", args[1]));
return true;
}
}
sender.sendMessage(pluginRef.getLocaleManager().getString("Commands.mcconvert.Database.Start", previousType.toString(), newType.toString()));
pluginRef.getUserManager().saveAll();
pluginRef.getUserManager().clearAll();
for (Player player : pluginRef.getServer().getOnlinePlayers()) {
PlayerProfile profile = oldDatabase.loadPlayerProfile(player.getUniqueId());
if (profile.isLoaded()) {
pluginRef.getDatabaseManager().saveUser(profile);
}
new PlayerProfileLoadingTask(pluginRef, player).runTaskLaterAsynchronously(pluginRef, 1); // 1 Tick delay to ensure the player is marked as online before we begin loading
}
new DatabaseConversionTask(pluginRef, oldDatabase, sender, previousType.toString(), newType.toString()).runTaskAsynchronously(pluginRef);
return true;
default:
return false;
}
}
public DatabaseType getDatabaseType(String typeName) {
for (DatabaseType type : DatabaseType.values()) {
if (type.name().equalsIgnoreCase(typeName)) {
return type;
}
}
if (typeName.equalsIgnoreCase("file")) {
return DatabaseType.FLATFILE;
} else if (typeName.equalsIgnoreCase("mysql")) {
return DatabaseType.SQL;
}
return DatabaseType.CUSTOM;
}
}

View File

@ -0,0 +1,59 @@
package com.gmail.nossr50.commands.database;
import com.gmail.nossr50.mcMMO;
import com.google.common.collect.ImmutableList;
import org.bukkit.Bukkit;
import org.bukkit.command.Command;
import org.bukkit.command.CommandSender;
import org.bukkit.command.TabExecutor;
import org.bukkit.util.StringUtil;
import java.util.ArrayList;
import java.util.List;
import java.util.UUID;
public class McremoveCommand implements TabExecutor {
private final mcMMO pluginRef;
public McremoveCommand(mcMMO pluginRef) {
this.pluginRef = pluginRef;
}
@Override
public boolean onCommand(CommandSender sender, Command command, String label, String[] args) {
if (args.length == 1) {
String playerName = pluginRef.getCommandTools().getMatchedPlayerName(args[0]);
if (pluginRef.getUserManager().getOfflinePlayer(playerName) == null && pluginRef.getCommandTools().unloadedProfile(sender, pluginRef.getDatabaseManager().loadPlayerProfile(playerName, false))) {
return true;
}
UUID uuid = null;
if (Bukkit.getPlayer(playerName) != null) {
uuid = Bukkit.getPlayer(playerName).getUniqueId();
}
if (pluginRef.getDatabaseManager().removeUser(playerName, uuid)) {
sender.sendMessage(pluginRef.getLocaleManager().getString("Commands.mcremove.Success", playerName));
} else {
sender.sendMessage(playerName + " could not be removed from the database."); // Pretty sure this should NEVER happen.
}
return true;
}
return false;
}
@Override
public List<String> onTabComplete(CommandSender sender, Command command, String alias, String[] args) {
switch (args.length) {
case 1:
List<String> playerNames = pluginRef.getCommandTools().getOnlinePlayerNames(sender);
return StringUtil.copyPartialMatches(args[0], playerNames, new ArrayList<>(playerNames.size()));
default:
return ImmutableList.of();
}
}
}

View File

@ -0,0 +1,41 @@
package com.gmail.nossr50.commands.database;
import com.gmail.nossr50.mcMMO;
import com.google.common.collect.ImmutableList;
import org.bukkit.command.Command;
import org.bukkit.command.CommandSender;
import org.bukkit.command.TabExecutor;
import java.util.List;
public class PurgeCommand implements TabExecutor {
private final mcMMO pluginRef;
public PurgeCommand(mcMMO pluginRef) {
this.pluginRef = pluginRef;
}
@Override
public boolean onCommand(CommandSender sender, Command command, String label, String[] args) {
switch (args.length) {
case 0:
pluginRef.getDatabaseManager().purgePowerlessUsers();
if (pluginRef.getDatabaseCleaningSettings().getOldUserCutoffMonths() != -1) {
pluginRef.getDatabaseManager().purgeOldUsers();
}
sender.sendMessage(pluginRef.getLocaleManager().getString("Commands.mcpurge.Success"));
return true;
default:
return false;
}
}
@Override
public List<String> onTabComplete(CommandSender sender, Command command, String alias, String[] args) {
return ImmutableList.of();
}
}

View File

@ -0,0 +1,39 @@
package com.gmail.nossr50.commands.database;
import com.gmail.nossr50.mcMMO;
import com.google.common.collect.ImmutableList;
import org.bukkit.command.Command;
import org.bukkit.command.CommandSender;
import org.bukkit.command.TabExecutor;
import java.util.List;
public class ShowDatabaseCommand implements TabExecutor {
private final mcMMO pluginRef;
public ShowDatabaseCommand(mcMMO pluginRef) {
this.pluginRef = pluginRef;
}
@Override
public boolean onCommand(CommandSender sender, Command command, String label, String[] args) {
if (args.length == 0) {
Class<?> clazz = pluginRef.getDatabaseManagerFactory().getCustomDatabaseManagerClass();
if (clazz != null) {
sender.sendMessage(pluginRef.getLocaleManager().getString("Commands.mmoshowdb", clazz.getName()));
return true;
}
sender.sendMessage(pluginRef.getLocaleManager().getString("Commands.mmoshowdb", (pluginRef.getMySQLConfigSettings().isMySQLEnabled() ? "sql" : "flatfile")));
return true;
}
return false;
}
@Override
public List<String> onTabComplete(CommandSender sender, Command command, String alias, String[] args) {
return ImmutableList.of();
}
}

View File

@ -0,0 +1,48 @@
package com.gmail.nossr50.commands.experience;
import com.gmail.nossr50.datatypes.experience.XPGainReason;
import com.gmail.nossr50.datatypes.player.PlayerProfile;
import com.gmail.nossr50.datatypes.skills.PrimarySkillType;
import com.gmail.nossr50.mcMMO;
import org.bukkit.command.CommandSender;
import org.bukkit.entity.Player;
public class AddLevelsCommand extends ExperienceCommand {
public AddLevelsCommand(mcMMO pluginRef) {
super(pluginRef);
}
@Override
protected boolean permissionsCheckSelf(CommandSender sender) {
return pluginRef.getPermissionTools().addlevels(sender);
}
@Override
protected boolean permissionsCheckOthers(CommandSender sender) {
return pluginRef.getPermissionTools().addlevelsOthers(sender);
}
@Override
protected void handleCommand(Player player, PlayerProfile profile, PrimarySkillType skill, int value) {
double xpRemoved = profile.getSkillXpLevelRaw(skill);
profile.addLevels(skill, value);
if (player == null) {
profile.scheduleAsyncSave();
return;
}
pluginRef.getEventManager().tryLevelChangeEvent(player, skill, value, xpRemoved, true, XPGainReason.COMMAND);
}
@Override
protected void handlePlayerMessageAll(Player player, int value) {
player.sendMessage(pluginRef.getLocaleManager().getString("Commands.addlevels.AwardAll.1", value));
}
@Override
protected void handlePlayerMessageSkill(Player player, int value, PrimarySkillType skill) {
player.sendMessage(pluginRef.getLocaleManager().getString("Commands.addlevels.AwardSkill.1", value, pluginRef.getSkillTools().getLocalizedSkillName(skill)));
}
}

View File

@ -0,0 +1,50 @@
package com.gmail.nossr50.commands.experience;
import com.gmail.nossr50.datatypes.experience.XPGainReason;
import com.gmail.nossr50.datatypes.experience.XPGainSource;
import com.gmail.nossr50.datatypes.player.PlayerProfile;
import com.gmail.nossr50.datatypes.skills.PrimarySkillType;
import com.gmail.nossr50.mcMMO;
import org.bukkit.command.CommandSender;
import org.bukkit.entity.Player;
public class AddXPCommand extends ExperienceCommand {
public AddXPCommand(mcMMO pluginRef) {
super(pluginRef);
}
@Override
protected boolean permissionsCheckSelf(CommandSender sender) {
return pluginRef.getPermissionTools().addxp(sender);
}
@Override
protected boolean permissionsCheckOthers(CommandSender sender) {
return pluginRef.getPermissionTools().addxpOthers(sender);
}
@Override
protected void handleCommand(Player player, PlayerProfile profile, PrimarySkillType skill, int value) {
if (player != null) {
//Check if player profile is loaded
if (pluginRef.getUserManager().getPlayer(player) == null)
return;
pluginRef.getUserManager().getPlayer(player).applyXpGain(skill, value, XPGainReason.COMMAND, XPGainSource.COMMAND);
} else {
profile.addXp(skill, value);
profile.scheduleAsyncSave();
}
}
@Override
protected void handlePlayerMessageAll(Player player, int value) {
player.sendMessage(pluginRef.getLocaleManager().getString("Commands.addxp.AwardAll", value));
}
@Override
protected void handlePlayerMessageSkill(Player player, int value, PrimarySkillType skill) {
player.sendMessage(pluginRef.getLocaleManager().getString("Commands.addxp.AwardSkill", value, pluginRef.getSkillTools().getLocalizedSkillName(skill)));
}
}

View File

@ -0,0 +1,51 @@
package com.gmail.nossr50.commands.experience;
import com.gmail.nossr50.datatypes.experience.FormulaType;
import com.gmail.nossr50.mcMMO;
import com.gmail.nossr50.runnables.database.FormulaConversionTask;
import com.gmail.nossr50.runnables.player.PlayerProfileLoadingTask;
import org.bukkit.command.Command;
import org.bukkit.command.CommandExecutor;
import org.bukkit.command.CommandSender;
import org.bukkit.entity.Player;
public class ConvertExperienceCommand implements CommandExecutor {
private final mcMMO pluginRef;
public ConvertExperienceCommand(mcMMO pluginRef) {
this.pluginRef = pluginRef;
}
@Override
public boolean onCommand(CommandSender sender, Command command, String label, String[] args) {
switch (args.length) {
case 2:
for(FormulaType formulaType : FormulaType.values()) {
if(formulaType.toString().equalsIgnoreCase(args[1])) {
FormulaType previousType = formulaType;
sender.sendMessage(pluginRef.getLocaleManager().getString("Commands.mcconvert.Experience.Start", previousType.toString(), pluginRef.getConfigManager().getConfigLeveling().getFormulaType().toString()));
pluginRef.getUserManager().saveAll();
pluginRef.getUserManager().clearAll();
new FormulaConversionTask(pluginRef, sender, previousType).runTaskLater(pluginRef, 1);
for (Player player : pluginRef.getServer().getOnlinePlayers()) {
new PlayerProfileLoadingTask(pluginRef, player).runTaskLaterAsynchronously(pluginRef, 1); // 1 Tick delay to ensure the player is marked as online before we begin loading
}
return true;
}
}
sender.sendMessage(pluginRef.getLocaleManager().getString("Commands.mcconvert.Experience.Invalid"));
return true;
default:
return false;
}
}
}

View File

@ -0,0 +1,171 @@
package com.gmail.nossr50.commands.experience;
import com.gmail.nossr50.datatypes.player.McMMOPlayer;
import com.gmail.nossr50.datatypes.player.PlayerProfile;
import com.gmail.nossr50.datatypes.skills.PrimarySkillType;
import com.gmail.nossr50.mcMMO;
import com.google.common.collect.ImmutableList;
import org.bukkit.OfflinePlayer;
import org.bukkit.command.Command;
import org.bukkit.command.CommandSender;
import org.bukkit.command.TabExecutor;
import org.bukkit.entity.Player;
import org.bukkit.util.StringUtil;
import java.util.ArrayList;
import java.util.List;
import java.util.UUID;
public abstract class ExperienceCommand implements TabExecutor {
protected mcMMO pluginRef;
public ExperienceCommand(mcMMO pluginRef) {
this.pluginRef = pluginRef;
}
protected void handleSenderMessage(CommandSender sender, String playerName, PrimarySkillType skill) {
if (skill == null) {
sender.sendMessage(pluginRef.getLocaleManager().getString("Commands.addlevels.AwardAll.2", playerName));
} else {
sender.sendMessage(pluginRef.getLocaleManager().getString("Commands.addlevels.AwardSkill.2", pluginRef.getSkillTools().getLocalizedSkillName(skill), playerName));
}
}
@Override
public boolean onCommand(CommandSender sender, Command command, String label, String[] args) {
PrimarySkillType skill;
switch (args.length) {
case 2:
if (pluginRef.getCommandTools().noConsoleUsage(sender)) {
return true;
}
if (!permissionsCheckSelf(sender)) {
sender.sendMessage(command.getPermissionMessage());
return true;
}
if (!validateArguments(sender, args[0], args[1])) {
return true;
}
skill = pluginRef.getSkillTools().matchSkill(args[0]);
if (args[1].equalsIgnoreCase("all")) {
skill = null;
}
if (skill != null && pluginRef.getSkillTools().isChildSkill(skill)) {
sender.sendMessage(pluginRef.getLocaleManager().getString("Commands.Skill.ChildSkill"));
return true;
}
//Profile not loaded
if (pluginRef.getUserManager().getPlayer(sender.getName()) == null) {
sender.sendMessage(pluginRef.getLocaleManager().getString("Profile.PendingLoad"));
return true;
}
editValues((Player) sender, pluginRef.getUserManager().getPlayer(sender.getName()).getProfile(), skill, Integer.parseInt(args[1]));
return true;
case 3:
if (!permissionsCheckOthers(sender)) {
sender.sendMessage(command.getPermissionMessage());
return true;
}
if (!validateArguments(sender, args[1], args[2])) {
return true;
}
skill = pluginRef.getSkillTools().matchSkill(args[1]);
if (args[1].equalsIgnoreCase("all")) {
skill = null;
}
if (skill != null && pluginRef.getSkillTools().isChildSkill(skill)) {
sender.sendMessage(pluginRef.getLocaleManager().getString("Commands.Skill.ChildSkill"));
return true;
}
int value = Integer.parseInt(args[2]);
String playerName = pluginRef.getCommandTools().getMatchedPlayerName(args[0]);
McMMOPlayer mcMMOPlayer = pluginRef.getUserManager().getOfflinePlayer(playerName);
// If the mcMMOPlayer doesn't exist, create a temporary profile and check if it's present in the database. If it's not, abort the process.
if (mcMMOPlayer == null) {
UUID uuid = null;
OfflinePlayer player = pluginRef.getServer().getOfflinePlayer(playerName);
if (player != null) {
uuid = player.getUniqueId();
}
PlayerProfile profile = pluginRef.getDatabaseManager().loadPlayerProfile(playerName, uuid, false);
if (pluginRef.getCommandTools().unloadedProfile(sender, profile)) {
return true;
}
editValues(null, profile, skill, value);
} else {
editValues(mcMMOPlayer.getPlayer(), mcMMOPlayer.getProfile(), skill, value);
}
handleSenderMessage(sender, playerName, skill);
return true;
default:
return false;
}
}
@Override
public List<String> onTabComplete(CommandSender sender, Command command, String alias, String[] args) {
switch (args.length) {
case 1:
List<String> playerNames = pluginRef.getCommandTools().getOnlinePlayerNames(sender);
return StringUtil.copyPartialMatches(args[0], playerNames, new ArrayList<>(playerNames.size()));
case 2:
return StringUtil.copyPartialMatches(args[1], pluginRef.getSkillTools().LOCALIZED_SKILL_NAMES, new ArrayList<>(pluginRef.getSkillTools().LOCALIZED_SKILL_NAMES.size()));
default:
return ImmutableList.of();
}
}
protected abstract boolean permissionsCheckSelf(CommandSender sender);
protected abstract boolean permissionsCheckOthers(CommandSender sender);
protected abstract void handleCommand(Player player, PlayerProfile profile, PrimarySkillType skill, int value);
protected abstract void handlePlayerMessageAll(Player player, int value);
protected abstract void handlePlayerMessageSkill(Player player, int value, PrimarySkillType skill);
private boolean validateArguments(CommandSender sender, String skillName, String value) {
return !(pluginRef.getCommandTools().isInvalidInteger(sender, value) || (!skillName.equalsIgnoreCase("all") && pluginRef.getCommandTools().isInvalidSkill(sender, skillName)));
}
protected void editValues(Player player, PlayerProfile profile, PrimarySkillType skill, int value) {
if (skill == null) {
for (PrimarySkillType primarySkillType : pluginRef.getSkillTools().NON_CHILD_SKILLS) {
handleCommand(player, profile, primarySkillType, value);
}
if (player != null) {
handlePlayerMessageAll(player, value);
}
} else {
handleCommand(player, profile, skill, value);
if (player != null) {
handlePlayerMessageSkill(player, value, skill);
}
}
}
}

View File

@ -0,0 +1,53 @@
package com.gmail.nossr50.commands.experience;
import com.gmail.nossr50.datatypes.experience.XPGainReason;
import com.gmail.nossr50.datatypes.player.PlayerProfile;
import com.gmail.nossr50.datatypes.skills.PrimarySkillType;
import com.gmail.nossr50.mcMMO;
import org.bukkit.command.CommandSender;
import org.bukkit.entity.Player;
public class SkillEditCommand extends ExperienceCommand {
public SkillEditCommand(mcMMO pluginRef) {
super(pluginRef);
}
@Override
protected boolean permissionsCheckSelf(CommandSender sender) {
return pluginRef.getPermissionTools().mmoedit(sender);
}
@Override
protected boolean permissionsCheckOthers(CommandSender sender) {
return pluginRef.getPermissionTools().mmoeditOthers(sender);
}
@Override
protected void handleCommand(Player player, PlayerProfile profile, PrimarySkillType skill, int value) {
int skillLevel = profile.getSkillLevel(skill);
double xpRemoved = profile.getSkillXpLevelRaw(skill);
profile.modifySkill(skill, value);
if (player == null) {
profile.scheduleAsyncSave();
return;
}
if (value == skillLevel) {
return;
}
pluginRef.getEventManager().tryLevelEditEvent(player, skill, value, xpRemoved, value > skillLevel, XPGainReason.COMMAND, skillLevel);
}
@Override
protected void handlePlayerMessageAll(Player player, int value) {
player.sendMessage(pluginRef.getLocaleManager().getString("Commands.mmoedit.AllSkills.1", value));
}
@Override
protected void handlePlayerMessageSkill(Player player, int value, PrimarySkillType skill) {
player.sendMessage(pluginRef.getLocaleManager().getString("Commands.mmoedit.Modified.1", pluginRef.getSkillTools().getLocalizedSkillName(skill), value));
}
}

View File

@ -0,0 +1,176 @@
package com.gmail.nossr50.commands.experience;
import com.gmail.nossr50.datatypes.experience.XPGainReason;
import com.gmail.nossr50.datatypes.player.McMMOPlayer;
import com.gmail.nossr50.datatypes.player.PlayerProfile;
import com.gmail.nossr50.datatypes.skills.PrimarySkillType;
import com.gmail.nossr50.mcMMO;
import com.google.common.collect.ImmutableList;
import org.bukkit.OfflinePlayer;
import org.bukkit.command.Command;
import org.bukkit.command.CommandSender;
import org.bukkit.command.TabExecutor;
import org.bukkit.entity.Player;
import org.bukkit.util.StringUtil;
import java.util.ArrayList;
import java.util.List;
import java.util.UUID;
/**
* This class mirrors the structure of ExperienceCommand, except the
* value/quantity argument is removed.
*/
public class SkillResetCommand implements TabExecutor {
private final mcMMO pluginRef;
public SkillResetCommand(mcMMO pluginRef) {
this.pluginRef = pluginRef;
}
protected void handleSenderMessage(CommandSender sender, String playerName, PrimarySkillType skill) {
if (skill == null) {
sender.sendMessage(pluginRef.getLocaleManager().getString("Commands.addlevels.AwardAll.2", playerName));
} else {
sender.sendMessage(pluginRef.getLocaleManager().getString("Commands.addlevels.AwardSkill.2", pluginRef.getSkillTools().getLocalizedSkillName(skill), playerName));
}
}
@Override
public boolean onCommand(CommandSender sender, Command command, String label, String[] args) {
PrimarySkillType skill;
switch (args.length) {
case 1:
if (pluginRef.getCommandTools().noConsoleUsage(sender)) {
return true;
}
if (!permissionsCheckSelf(sender)) {
sender.sendMessage(command.getPermissionMessage());
return true;
}
if (!validateArguments(sender, args[0])) {
return true;
}
if (args[0].equalsIgnoreCase("all")) {
skill = null;
} else {
skill = pluginRef.getSkillTools().matchSkill(args[1]);
}
editValues((Player) sender, pluginRef.getUserManager().getPlayer(sender.getName()).getProfile(), skill);
return true;
case 2:
if (!permissionsCheckOthers(sender)) {
sender.sendMessage(command.getPermissionMessage());
return true;
}
if (!validateArguments(sender, args[1])) {
return true;
}
if (args[1].equalsIgnoreCase("all")) {
skill = null;
} else {
skill = pluginRef.getSkillTools().matchSkill(args[1]);
}
String playerName = pluginRef.getCommandTools().getMatchedPlayerName(args[0]);
McMMOPlayer mcMMOPlayer = pluginRef.getUserManager().getOfflinePlayer(playerName);
// If the mcMMOPlayer doesn't exist, create a temporary profile and check if it's present in the database. If it's not, abort the process.
if (mcMMOPlayer == null) {
UUID uuid = null;
OfflinePlayer player = pluginRef.getServer().getOfflinePlayer(playerName);
if (player != null) {
uuid = player.getUniqueId();
}
PlayerProfile profile = pluginRef.getDatabaseManager().loadPlayerProfile(playerName, uuid, false);
if (pluginRef.getCommandTools().unloadedProfile(sender, profile)) {
return true;
}
editValues(null, profile, skill);
} else {
editValues(mcMMOPlayer.getPlayer(), mcMMOPlayer.getProfile(), skill);
}
handleSenderMessage(sender, playerName, skill);
return true;
default:
return false;
}
}
@Override
public List<String> onTabComplete(CommandSender sender, Command command, String alias, String[] args) {
switch (args.length) {
case 1:
List<String> playerNames = pluginRef.getCommandTools().getOnlinePlayerNames(sender);
return StringUtil.copyPartialMatches(args[0], playerNames, new ArrayList<>(playerNames.size()));
case 2:
return StringUtil.copyPartialMatches(args[1], pluginRef.getSkillTools().LOCALIZED_SKILL_NAMES, new ArrayList<>(pluginRef.getSkillTools().LOCALIZED_SKILL_NAMES.size()));
default:
return ImmutableList.of();
}
}
protected void handleCommand(Player player, PlayerProfile profile, PrimarySkillType skill) {
int levelsRemoved = profile.getSkillLevel(skill);
double xpRemoved = profile.getSkillXpLevelRaw(skill);
profile.modifySkill(skill, 0);
if (player == null) {
profile.scheduleAsyncSave();
return;
}
pluginRef.getEventManager().tryLevelChangeEvent(player, skill, levelsRemoved, xpRemoved, false, XPGainReason.COMMAND);
}
protected boolean permissionsCheckSelf(CommandSender sender) {
return pluginRef.getPermissionTools().skillreset(sender);
}
protected boolean permissionsCheckOthers(CommandSender sender) {
return pluginRef.getPermissionTools().skillresetOthers(sender);
}
protected void handlePlayerMessageAll(Player player) {
player.sendMessage(pluginRef.getLocaleManager().getString("Commands.Reset.All"));
}
protected void handlePlayerMessageSkill(Player player, PrimarySkillType skill) {
player.sendMessage(pluginRef.getLocaleManager().getString("Commands.Reset.Single", pluginRef.getSkillTools().getLocalizedSkillName(skill)));
}
private boolean validateArguments(CommandSender sender, String skillName) {
return skillName.equalsIgnoreCase("all") || !pluginRef.getCommandTools().isInvalidSkill(sender, skillName);
}
protected void editValues(Player player, PlayerProfile profile, PrimarySkillType skill) {
if (skill == null) {
for (PrimarySkillType primarySkillType : pluginRef.getSkillTools().NON_CHILD_SKILLS) {
handleCommand(player, profile, primarySkillType);
}
if (player != null) {
handlePlayerMessageAll(player);
}
} else {
handleCommand(player, profile, skill);
if (player != null) {
handlePlayerMessageSkill(player, skill);
}
}
}
}

View File

@ -0,0 +1,48 @@
package com.gmail.nossr50.commands.party;
import com.gmail.nossr50.datatypes.player.McMMOPlayer;
import com.gmail.nossr50.mcMMO;
import org.bukkit.command.Command;
import org.bukkit.command.CommandExecutor;
import org.bukkit.command.CommandSender;
import org.bukkit.entity.Player;
public class PartyAcceptCommand implements CommandExecutor {
private final mcMMO pluginRef;
public PartyAcceptCommand(mcMMO pluginRef) {
this.pluginRef = pluginRef;
}
@Override
public boolean onCommand(CommandSender sender, Command command, String label, String[] args) {
if (args.length == 1) {
Player player = (Player) sender;
//Check if player profile is loaded
if (pluginRef.getUserManager().getPlayer(player) == null) {
sender.sendMessage(pluginRef.getLocaleManager().getString("Profile.PendingLoad"));
return true;
}
McMMOPlayer mcMMOPlayer = pluginRef.getUserManager().getPlayer(player);
if (!mcMMOPlayer.hasPartyInvite()) {
sender.sendMessage(pluginRef.getLocaleManager().getString("mcMMO.NoInvites"));
return true;
}
// Changing parties
if (!pluginRef.getPartyManager().changeOrJoinParty(mcMMOPlayer, mcMMOPlayer.getPartyInvite().getName())) {
return true;
}
pluginRef.getPartyManager().joinInvitedParty(mcMMOPlayer);
return true;
}
sender.sendMessage(pluginRef.getLocaleManager().getString("Commands.Usage.1", "party", "accept"));
return true;
}
}

View File

@ -0,0 +1,46 @@
package com.gmail.nossr50.commands.party;
import com.gmail.nossr50.datatypes.party.Party;
import com.gmail.nossr50.mcMMO;
import org.bukkit.OfflinePlayer;
import org.bukkit.command.Command;
import org.bukkit.command.CommandExecutor;
import org.bukkit.command.CommandSender;
import org.bukkit.entity.Player;
public class PartyChangeOwnerCommand implements CommandExecutor {
private final mcMMO pluginRef;
public PartyChangeOwnerCommand(mcMMO pluginRef) {
this.pluginRef = pluginRef;
}
@Override
public boolean onCommand(CommandSender sender, Command command, String label, String[] args) {
switch (args.length) {
case 2:
//Check if player profile is loaded
if (pluginRef.getUserManager().getPlayer((Player) sender) == null) {
sender.sendMessage(pluginRef.getLocaleManager().getString("Profile.PendingLoad"));
return true;
}
Party playerParty = pluginRef.getUserManager().getPlayer((Player) sender).getParty();
String targetName = pluginRef.getCommandTools().getMatchedPlayerName(args[1]);
OfflinePlayer target = pluginRef.getServer().getOfflinePlayer(targetName);
if (!playerParty.hasMember(target.getUniqueId())) {
sender.sendMessage(pluginRef.getLocaleManager().getString("Party.NotInYourParty", targetName));
return true;
}
pluginRef.getPartyManager().setPartyLeader(target.getUniqueId(), playerParty);
return true;
default:
sender.sendMessage(pluginRef.getLocaleManager().getString("Commands.Usage.2", "party", "owner", "<" + pluginRef.getLocaleManager().getString("Commands.Usage.Player") + ">"));
return true;
}
}
}

View File

@ -0,0 +1,59 @@
package com.gmail.nossr50.commands.party;
import com.gmail.nossr50.datatypes.party.Party;
import com.gmail.nossr50.mcMMO;
import org.bukkit.command.Command;
import org.bukkit.command.CommandExecutor;
import org.bukkit.command.CommandSender;
import org.bukkit.entity.Player;
public class PartyChangePasswordCommand implements CommandExecutor {
private final mcMMO pluginRef;
public PartyChangePasswordCommand(mcMMO pluginRef) {
this.pluginRef = pluginRef;
}
@Override
public boolean onCommand(CommandSender sender, Command command, String label, String[] args) {
if (pluginRef.getUserManager().getPlayer((Player) sender) == null) {
sender.sendMessage(pluginRef.getLocaleManager().getString("Profile.PendingLoad"));
return true;
}
Party party = pluginRef.getUserManager().getPlayer((Player) sender).getParty();
switch (args.length) {
case 1:
unprotectParty(party, sender);
return true;
case 2:
if (args[1].equalsIgnoreCase("clear") || args[1].equalsIgnoreCase("reset")) {
unprotectParty(party, sender);
return true;
}
protectParty(party, sender, args[1]);
return true;
default:
sender.sendMessage(pluginRef.getLocaleManager().getString("Commands.Usage.2", "party", "password", "[clear|reset]"));
sender.sendMessage(pluginRef.getLocaleManager().getString("Commands.Usage.2", "party", "password", "<" + pluginRef.getLocaleManager().getString("Commands.Usage.Password") + ">"));
return true;
}
}
private void unprotectParty(Party party, CommandSender sender) {
party.setLocked(true);
party.setPassword(null);
sender.sendMessage(pluginRef.getLocaleManager().getString("Party.Password.Removed"));
}
private void protectParty(Party party, CommandSender sender, String password) {
party.setLocked(true);
party.setPassword(password);
sender.sendMessage(pluginRef.getLocaleManager().getString("Party.Password.Set", password));
}
}

View File

@ -0,0 +1,279 @@
package com.gmail.nossr50.commands.party;
import com.gmail.nossr50.commands.CommandConstants;
import com.gmail.nossr50.commands.chat.PartyChatCommand;
import com.gmail.nossr50.commands.party.alliance.PartyAllianceCommand;
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.mcMMO;
import com.google.common.collect.ImmutableList;
import org.bukkit.command.Command;
import org.bukkit.command.CommandExecutor;
import org.bukkit.command.CommandSender;
import org.bukkit.command.TabExecutor;
import org.bukkit.entity.Player;
import org.bukkit.util.StringUtil;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.Collections;
import java.util.List;
//TODO: This class horrifies me, rewrite it at some point
public class PartyCommand implements TabExecutor {
private final mcMMO pluginRef;
private CommandExecutor partyJoinCommand;
private CommandExecutor partyAcceptCommand;
private CommandExecutor partyCreateCommand;
private CommandExecutor partyQuitCommand;
private CommandExecutor partyXpShareCommand;
private CommandExecutor partyItemShareCommand;
private CommandExecutor partyInviteCommand;
private CommandExecutor partyKickCommand;
private CommandExecutor partyDisbandCommand;
private CommandExecutor partyChangeOwnerCommand;
private CommandExecutor partyLockCommand;
private CommandExecutor partyChangePasswordCommand;
private CommandExecutor partyRenameCommand;
private CommandExecutor partyInfoCommand;
private CommandExecutor partyHelpCommand;
private CommandExecutor partyTeleportCommand;
private CommandExecutor partyChatCommand;
private CommandExecutor partyAllianceCommand;
public PartyCommand(mcMMO pluginRef) {
this.pluginRef = pluginRef;
initSubCommandList();
partyJoinCommand = new PartyJoinCommand(pluginRef);
partyAcceptCommand = new PartyAcceptCommand(pluginRef);
partyCreateCommand = new PartyCreateCommand(pluginRef);
partyQuitCommand = new PartyQuitCommand(pluginRef);
partyXpShareCommand = new PartyXpShareCommand(pluginRef);
partyItemShareCommand = new PartyItemShareCommand(pluginRef);
partyInviteCommand = new PartyInviteCommand(pluginRef);
partyKickCommand = new PartyKickCommand(pluginRef);
partyDisbandCommand = new PartyDisbandCommand(pluginRef);
partyChangeOwnerCommand = new PartyChangeOwnerCommand(pluginRef);
partyLockCommand = new PartyLockCommand(pluginRef);
partyChangePasswordCommand = new PartyChangePasswordCommand(pluginRef);
partyRenameCommand = new PartyRenameCommand(pluginRef);
partyInfoCommand = new PartyInfoCommand(pluginRef);
partyHelpCommand = new PartyHelpCommand(pluginRef);
partyTeleportCommand = new PtpCommand(pluginRef);
partyChatCommand = new PartyChatCommand(pluginRef);
partyAllianceCommand = new PartyAllianceCommand(pluginRef);
}
private List<String> PARTY_SUBCOMMANDS;
private final List<String> XPSHARE_COMPLETIONS = ImmutableList.of("none", "equal");
private final List<String> ITEMSHARE_COMPLETIONS = ImmutableList.of("none", "equal", "random", "loot", "mining", "herbalism", "woodcutting", "misc");
private void initSubCommandList() {
ArrayList<String> subcommands = new ArrayList<>();
for (PartySubcommandType subcommand : PartySubcommandType.values()) {
subcommands.add(subcommand.toString());
}
Collections.sort(subcommands);
PARTY_SUBCOMMANDS = ImmutableList.copyOf(subcommands);
}
@Override
public boolean onCommand(CommandSender sender, Command command, String label, String[] args) {
//If the party system is disabled, don't fire this command
if (!pluginRef.getConfigManager().getConfigParty().isPartySystemEnabled())
return true;
if (pluginRef.getCommandTools().noConsoleUsage(sender)) {
return true;
}
if (!pluginRef.getPermissionTools().party(sender)) {
sender.sendMessage(command.getPermissionMessage());
return true;
}
Player player = (Player) sender;
if (!pluginRef.getUserManager().hasPlayerDataKey(player)) {
return true;
}
if (pluginRef.getUserManager().getPlayer(player) == null) {
player.sendMessage(pluginRef.getLocaleManager().getString("Profile.PendingLoad"));
return true;
}
McMMOPlayer mcMMOPlayer = pluginRef.getUserManager().getPlayer(player);
if (args.length < 1) {
if (!mcMMOPlayer.inParty()) {
sender.sendMessage(pluginRef.getLocaleManager().getString("Commands.Party.None"));
return printUsage(player);
}
return partyInfoCommand.onCommand(sender, command, label, args);
}
PartySubcommandType subcommand = PartySubcommandType.getSubcommand(args[0]);
if (subcommand == null) {
return printUsage(player);
}
// Can't use this for lock/unlock since they're handled by the same command
if (subcommand != PartySubcommandType.LOCK && subcommand != PartySubcommandType.UNLOCK && !pluginRef.getPermissionTools().partySubcommand(sender, subcommand)) {
sender.sendMessage(command.getPermissionMessage());
return true;
}
switch (subcommand) {
case JOIN:
return partyJoinCommand.onCommand(sender, command, label, args);
case ACCEPT:
return partyAcceptCommand.onCommand(sender, command, label, args);
case CREATE:
return partyCreateCommand.onCommand(sender, command, label, args);
case HELP:
return partyHelpCommand.onCommand(sender, command, label, args);
default:
break;
}
// Party member commands
if (!mcMMOPlayer.inParty()) {
sender.sendMessage(pluginRef.getLocaleManager().getString("Commands.Party.None"));
return printUsage(player);
}
switch (subcommand) {
case INFO:
return partyInfoCommand.onCommand(sender, command, label, args);
case QUIT:
return partyQuitCommand.onCommand(sender, command, label, args);
case INVITE:
return partyInviteCommand.onCommand(sender, command, label, args);
case TELEPORT:
return partyTeleportCommand.onCommand(sender, command, label, extractArgs(args));
case CHAT:
return partyChatCommand.onCommand(sender, command, label, extractArgs(args));
default:
break;
}
// Party leader commands
if (!mcMMOPlayer.getParty().getLeader().getUniqueId().equals(player.getUniqueId())) {
sender.sendMessage(pluginRef.getLocaleManager().getString("Party.NotOwner"));
return true;
}
switch (subcommand) {
case XPSHARE:
return partyXpShareCommand.onCommand(sender, command, label, args);
case ITEMSHARE:
return partyItemShareCommand.onCommand(sender, command, label, args);
case KICK:
return partyKickCommand.onCommand(sender, command, label, args);
case DISBAND:
return partyDisbandCommand.onCommand(sender, command, label, args);
case OWNER:
return partyChangeOwnerCommand.onCommand(sender, command, label, args);
case LOCK:
case UNLOCK:
return partyLockCommand.onCommand(sender, command, label, args);
case PASSWORD:
return partyChangePasswordCommand.onCommand(sender, command, label, args);
case RENAME:
return partyRenameCommand.onCommand(sender, command, label, args);
case ALLIANCE:
return partyAllianceCommand.onCommand(sender, command, label, args);
default:
break;
}
return true;
}
@Override
public List<String> onTabComplete(CommandSender sender, Command command, String alias, String[] args) {
switch (args.length) {
case 1:
return StringUtil.copyPartialMatches(args[0], PARTY_SUBCOMMANDS, new ArrayList<>(PARTY_SUBCOMMANDS.size()));
case 2:
PartySubcommandType subcommand = PartySubcommandType.getSubcommand(args[0]);
if (subcommand == null) {
return ImmutableList.of();
}
switch (subcommand) {
case JOIN:
case INVITE:
case KICK:
case OWNER:
List<String> playerNames = pluginRef.getCommandTools().getOnlinePlayerNames(sender);
return StringUtil.copyPartialMatches(args[1], playerNames, new ArrayList<>(playerNames.size()));
case XPSHARE:
return StringUtil.copyPartialMatches(args[1], XPSHARE_COMPLETIONS, new ArrayList<>(XPSHARE_COMPLETIONS.size()));
case ITEMSHARE:
return StringUtil.copyPartialMatches(args[1], ITEMSHARE_COMPLETIONS, new ArrayList<>(ITEMSHARE_COMPLETIONS.size()));
case LOCK:
case CHAT:
return StringUtil.copyPartialMatches(args[1], CommandConstants.TRUE_FALSE_OPTIONS, new ArrayList<>(CommandConstants.TRUE_FALSE_OPTIONS.size()));
case PASSWORD:
return StringUtil.copyPartialMatches(args[1], CommandConstants.RESET_OPTIONS, new ArrayList<>(CommandConstants.RESET_OPTIONS.size()));
case TELEPORT:
List<String> matches = StringUtil.copyPartialMatches(args[1], CommandConstants.TELEPORT_SUBCOMMANDS, new ArrayList<>(CommandConstants.TELEPORT_SUBCOMMANDS.size()));
if (matches.size() == 0) {
Player player = (Player) sender;
//Not Loaded
if (pluginRef.getUserManager().getPlayer(player) == null) {
sender.sendMessage(pluginRef.getLocaleManager().getString("Profile.PendingLoad"));
return ImmutableList.of();
}
Party party = pluginRef.getUserManager().getPlayer(player).getParty();
playerNames = party.getOnlinePlayerNames(player);
return StringUtil.copyPartialMatches(args[1], playerNames, new ArrayList<>(playerNames.size()));
}
return matches;
default:
return ImmutableList.of();
}
case 3:
if (PartySubcommandType.getSubcommand(args[0]) == PartySubcommandType.ITEMSHARE && isItemShareCategory(args[1])) {
return StringUtil.copyPartialMatches(args[2], CommandConstants.TRUE_FALSE_OPTIONS, new ArrayList<>(CommandConstants.TRUE_FALSE_OPTIONS.size()));
}
return ImmutableList.of();
default:
return ImmutableList.of();
}
}
private boolean printUsage(Player player) {
player.sendMessage(pluginRef.getLocaleManager().getString("Party.Help.0", "/party join"));
player.sendMessage(pluginRef.getLocaleManager().getString("Party.Help.1", "/party create"));
player.sendMessage(pluginRef.getLocaleManager().getString("Party.Help.2", "/party ?"));
return true;
}
private String[] extractArgs(String[] args) {
return Arrays.copyOfRange(args, 1, args.length);
}
private boolean isItemShareCategory(String category) {
return category.equalsIgnoreCase("loot") || category.equalsIgnoreCase("mining") || category.equalsIgnoreCase("herbalism") || category.equalsIgnoreCase("woodcutting") || category.equalsIgnoreCase("misc");
}
}

View File

@ -0,0 +1,57 @@
package com.gmail.nossr50.commands.party;
import com.gmail.nossr50.datatypes.player.McMMOPlayer;
import com.gmail.nossr50.mcMMO;
import org.bukkit.command.Command;
import org.bukkit.command.CommandExecutor;
import org.bukkit.command.CommandSender;
import org.bukkit.entity.Player;
public class PartyCreateCommand implements CommandExecutor {
private final mcMMO pluginRef;
public PartyCreateCommand(mcMMO pluginRef) {
this.pluginRef = pluginRef;
}
@Override
public boolean onCommand(CommandSender sender, Command command, String label, String[] args) {
switch (args.length) {
case 2:
case 3:
Player player = (Player) sender;
McMMOPlayer mcMMOPlayer = pluginRef.getUserManager().getPlayer(player);
if (pluginRef.getUserManager().getPlayer(player) == null) {
player.sendMessage(pluginRef.getLocaleManager().getString("Profile.PendingLoad"));
return true;
}
// Check to see if the party exists, and if it does cancel creating a new party
if (pluginRef.getPartyManager().checkPartyExistence(player, args[1])) {
return true;
}
// Changing parties
if (!pluginRef.getPartyManager().changeOrJoinParty(mcMMOPlayer, args[1])) {
return true;
}
pluginRef.getPartyManager().createParty(mcMMOPlayer, args[1], getPassword(args));
return true;
default:
sender.sendMessage(pluginRef.getLocaleManager().getString("Commands.Usage.3", "party", "create", "<" + pluginRef.getLocaleManager().getString("Commands.Usage.PartyName") + ">", "[" + pluginRef.getLocaleManager().getString("Commands.Usage.Password") + "]"));
return true;
}
}
private String getPassword(String[] args) {
if (args.length == 3) {
return args[2];
}
return null;
}
}

View File

@ -0,0 +1,47 @@
package com.gmail.nossr50.commands.party;
import com.gmail.nossr50.datatypes.party.Party;
import com.gmail.nossr50.events.party.McMMOPartyChangeEvent.EventReason;
import com.gmail.nossr50.mcMMO;
import org.bukkit.command.Command;
import org.bukkit.command.CommandExecutor;
import org.bukkit.command.CommandSender;
import org.bukkit.entity.Player;
public class PartyDisbandCommand implements CommandExecutor {
private final mcMMO pluginRef;
public PartyDisbandCommand(mcMMO pluginRef) {
this.pluginRef = pluginRef;
}
@Override
public boolean onCommand(CommandSender sender, Command command, String label, String[] args) {
switch (args.length) {
case 1:
if (pluginRef.getUserManager().getPlayer((Player) sender) == null) {
sender.sendMessage(pluginRef.getLocaleManager().getString("Profile.PendingLoad"));
return true;
}
Party playerParty = pluginRef.getUserManager().getPlayer((Player) sender).getParty();
String partyName = playerParty.getName();
for (Player member : playerParty.getOnlineMembers()) {
if (!pluginRef.getPartyManager().handlePartyChangeEvent(member, partyName, null, EventReason.KICKED_FROM_PARTY)) {
return true;
}
member.sendMessage(pluginRef.getLocaleManager().getString("Party.Disband"));
}
pluginRef.getPartyManager().disbandParty(playerParty);
return true;
default:
sender.sendMessage(pluginRef.getLocaleManager().getString("Commands.Usage.1", "party", "disband"));
return true;
}
}
}

View File

@ -0,0 +1,36 @@
package com.gmail.nossr50.commands.party;
import com.gmail.nossr50.mcMMO;
import org.bukkit.command.Command;
import org.bukkit.command.CommandExecutor;
import org.bukkit.command.CommandSender;
public class PartyHelpCommand implements CommandExecutor {
private final mcMMO pluginRef;
public PartyHelpCommand(mcMMO pluginRef) {
this.pluginRef = pluginRef;
}
@Override
public boolean onCommand(CommandSender sender, Command command, String label, String[] args) {
switch (args.length) {
case 1:
sender.sendMessage(pluginRef.getLocaleManager().getString("Party.Help.3", "/party join", "/party quit"));
sender.sendMessage(pluginRef.getLocaleManager().getString("Party.Help.1", "/party create"));
sender.sendMessage(pluginRef.getLocaleManager().getString("Party.Help.4", "/party <lock|unlock>"));
sender.sendMessage(pluginRef.getLocaleManager().getString("Party.Help.5", "/party password"));
sender.sendMessage(pluginRef.getLocaleManager().getString("Party.Help.6", "/party kick"));
sender.sendMessage(pluginRef.getLocaleManager().getString("Party.Help.7", "/party leader"));
sender.sendMessage(pluginRef.getLocaleManager().getString("Party.Help.8", "/party disband"));
sender.sendMessage(pluginRef.getLocaleManager().getString("Party.Help.9", "/party itemshare"));
sender.sendMessage(pluginRef.getLocaleManager().getString("Party.Help.10", "/party xpshare"));
return true;
default:
sender.sendMessage(pluginRef.getLocaleManager().getString("Commands.Usage.1", "party", "help"));
return true;
}
}
}

View File

@ -0,0 +1,148 @@
package com.gmail.nossr50.commands.party;
import com.gmail.nossr50.datatypes.party.Party;
import com.gmail.nossr50.datatypes.party.PartyFeature;
import com.gmail.nossr50.datatypes.party.ShareMode;
import com.gmail.nossr50.datatypes.player.McMMOPlayer;
import com.gmail.nossr50.mcMMO;
import com.gmail.nossr50.util.StringUtils;
import org.bukkit.ChatColor;
import org.bukkit.command.Command;
import org.bukkit.command.CommandExecutor;
import org.bukkit.command.CommandSender;
import org.bukkit.entity.Player;
import java.util.ArrayList;
import java.util.List;
public class PartyInfoCommand implements CommandExecutor {
private final mcMMO pluginRef;
public PartyInfoCommand(mcMMO pluginRef) {
this.pluginRef = pluginRef;
}
@Override
public boolean onCommand(CommandSender sender, Command command, String label, String[] args) {
switch (args.length) {
case 0:
case 1:
if (pluginRef.getUserManager().getPlayer((Player) sender) == null) {
sender.sendMessage(pluginRef.getLocaleManager().getString("Profile.PendingLoad"));
return true;
}
Player player = (Player) sender;
McMMOPlayer mcMMOPlayer = pluginRef.getUserManager().getPlayer(player);
Party party = mcMMOPlayer.getParty();
displayPartyHeader(player, party);
displayShareModeInfo(player, party);
displayPartyFeatures(player, party);
displayMemberInfo(player, mcMMOPlayer, party);
return true;
default:
sender.sendMessage(pluginRef.getLocaleManager().getString("Commands.Usage.1", "party", "info"));
return true;
}
}
private void displayPartyHeader(Player player, Party party) {
player.sendMessage(pluginRef.getLocaleManager().getString("Commands.Party.Header"));
/*if (!party.hasReachedLevelCap()) {
status.append(" (").append(party.getXpToLevelPercentage()).append(")");
}*/
player.sendMessage(pluginRef.getLocaleManager().getString("Commands.Party.Status", party.getName(), pluginRef.getLocaleManager().getString("Party.Status." + (party.isLocked() ? "Locked" : "Unlocked")), party.getLevel())
/*if (!party.hasReachedLevelCap()) {
status.append(" (").append(party.getXpToLevelPercentage()).append(")");
}*/);
}
private void displayPartyFeatures(Player player, Party party) {
player.sendMessage(pluginRef.getLocaleManager().getString("Commands.Party.Features.Header"));
List<String> unlockedPartyFeatures = new ArrayList<>();
List<String> lockedPartyFeatures = new ArrayList<>();
for (PartyFeature partyFeature : PartyFeature.values()) {
if (!partyFeature.hasPermission(pluginRef, player)) {
continue;
}
if (isUnlockedFeature(party, partyFeature)) {
unlockedPartyFeatures.add(getPartyFeatureLocaleString(partyFeature));
} else {
lockedPartyFeatures.add(getFeatureLockedLocaleString(partyFeature));
}
}
player.sendMessage(pluginRef.getLocaleManager().getString("Commands.Party.UnlockedFeatures", unlockedPartyFeatures.isEmpty() ? "None" : unlockedPartyFeatures));
for (String message : lockedPartyFeatures) {
player.sendMessage(message);
}
}
public String getPartyFeatureLocaleString(PartyFeature partyFeature) {
return pluginRef.getLocaleManager().getString("Party.Feature." + StringUtils.getPrettyPartyFeatureString(partyFeature).replace(" ", ""));
}
public String getFeatureLockedLocaleString(PartyFeature partyFeature) {
return pluginRef.getLocaleManager().getString("Ability.Generic.Template.Lock",
pluginRef.getLocaleManager().getString("Party.Feature.Locked."
+ StringUtils.getPrettyPartyFeatureString(partyFeature).replace(" ", ""),
pluginRef.getPartyManager().getPartyFeatureUnlockLevel(partyFeature)));
}
private boolean isUnlockedFeature(Party party, PartyFeature partyFeature) {
return party.getLevel() >= pluginRef.getPartyManager().getPartyFeatureUnlockLevel(partyFeature);
}
private void displayShareModeInfo(Player player, Party party) {
boolean xpShareEnabled = isUnlockedFeature(party, PartyFeature.XP_SHARE);
boolean itemShareEnabled = isUnlockedFeature(party, PartyFeature.ITEM_SHARE);
boolean itemSharingActive = (party.getItemShareMode() != ShareMode.NONE);
if (!xpShareEnabled && !itemShareEnabled) {
return;
}
String expShareInfo = "";
String itemShareInfo = "";
String separator = "";
if (xpShareEnabled) {
expShareInfo = pluginRef.getLocaleManager().getString("Commands.Party.ExpShare", party.getXpShareMode().toString());
}
if (itemShareEnabled) {
itemShareInfo = pluginRef.getLocaleManager().getString("Commands.Party.ItemShare", party.getItemShareMode().toString());
}
if (xpShareEnabled && itemShareEnabled) {
separator = ChatColor.DARK_GRAY + " || ";
}
player.sendMessage(pluginRef.getLocaleManager().getString("Commands.Party.ShareMode") + expShareInfo + separator + itemShareInfo);
if (itemSharingActive) {
player.sendMessage(pluginRef.getLocaleManager().getString("Commands.Party.ItemShareCategories", party.getItemShareCategories()));
}
}
private void displayMemberInfo(Player player, McMMOPlayer mcMMOPlayer, Party party) {
/*
* Only show members of the party that this member can see
*/
List<Player> nearMembers = pluginRef.getPartyManager().getNearVisibleMembers(mcMMOPlayer);
int membersOnline = party.getVisibleMembers(player).size();
player.sendMessage(pluginRef.getLocaleManager().getString("Commands.Party.Members.Header"));
player.sendMessage(pluginRef.getLocaleManager().getString("Commands.Party.MembersNear", nearMembers.size() + 1, membersOnline));
player.sendMessage(party.createMembersList(player));
}
}

View File

@ -0,0 +1,78 @@
package com.gmail.nossr50.commands.party;
import com.gmail.nossr50.datatypes.party.Party;
import com.gmail.nossr50.datatypes.player.McMMOPlayer;
import com.gmail.nossr50.mcMMO;
import org.bukkit.command.Command;
import org.bukkit.command.CommandExecutor;
import org.bukkit.command.CommandSender;
import org.bukkit.entity.Player;
public class PartyInviteCommand implements CommandExecutor {
private final mcMMO pluginRef;
public PartyInviteCommand(mcMMO pluginRef) {
this.pluginRef = pluginRef;
}
@Override
public boolean onCommand(CommandSender sender, Command command, String label, String[] args) {
switch (args.length) {
case 2:
String targetName = pluginRef.getCommandTools().getMatchedPlayerName(args[1]);
McMMOPlayer mcMMOTarget = pluginRef.getUserManager().getOfflinePlayer(targetName);
if (!pluginRef.getCommandTools().checkPlayerExistence(sender, targetName, mcMMOTarget)) {
return false;
}
Player target = mcMMOTarget.getPlayer();
if (pluginRef.getUserManager().getPlayer((Player) sender) == null) {
sender.sendMessage(pluginRef.getLocaleManager().getString("Profile.PendingLoad"));
return true;
}
Player player = (Player) sender;
McMMOPlayer mcMMOPlayer = pluginRef.getUserManager().getPlayer(player);
String playerName = player.getName();
if (player.equals(target)) {
sender.sendMessage(pluginRef.getLocaleManager().getString("Party.Invite.Self"));
return true;
}
if (pluginRef.getPartyManager().inSameParty(player, target)) {
sender.sendMessage(pluginRef.getLocaleManager().getString("Party.Player.InSameParty", targetName));
return true;
}
if (!pluginRef.getPartyManager().canInvite(mcMMOPlayer)) {
player.sendMessage(pluginRef.getLocaleManager().getString("Party.Locked"));
return true;
}
Party playerParty = mcMMOPlayer.getParty();
if (pluginRef.getConfigManager().getConfigParty().getPartyGeneral().isPartySizeCapped())
if (pluginRef.getPartyManager().isPartyFull(target, playerParty)) {
player.sendMessage(pluginRef.getLocaleManager().getString("Commands.Party.PartyFull.Invite",
target.getName(), playerParty.toString(),
pluginRef.getConfigManager().getConfigParty().getPartySizeLimit()));
return true;
}
mcMMOTarget.setPartyInvite(playerParty);
sender.sendMessage(pluginRef.getLocaleManager().getString("Commands.Invite.Success"));
target.sendMessage(pluginRef.getLocaleManager().getString("Commands.Party.Invite.0", playerParty.getName(), playerName));
target.sendMessage(pluginRef.getLocaleManager().getString("Commands.Party.Invite.1"));
return true;
default:
sender.sendMessage(pluginRef.getLocaleManager().getString("Commands.Usage.2", "party", "invite", "<" + pluginRef.getLocaleManager().getString("Commands.Usage.Player") + ">"));
return true;
}
}
}

View File

@ -0,0 +1,94 @@
package com.gmail.nossr50.commands.party;
import com.gmail.nossr50.datatypes.party.ItemShareType;
import com.gmail.nossr50.datatypes.party.Party;
import com.gmail.nossr50.datatypes.party.PartyFeature;
import com.gmail.nossr50.datatypes.party.ShareMode;
import com.gmail.nossr50.mcMMO;
import com.gmail.nossr50.util.StringUtils;
import org.bukkit.command.Command;
import org.bukkit.command.CommandExecutor;
import org.bukkit.command.CommandSender;
import org.bukkit.entity.Player;
public class PartyItemShareCommand implements CommandExecutor {
private final mcMMO pluginRef;
public PartyItemShareCommand(mcMMO pluginRef) {
this.pluginRef = pluginRef;
}
@Override
public boolean onCommand(CommandSender sender, Command command, String label, String[] args) {
if (pluginRef.getUserManager().getPlayer((Player) sender) == null) {
sender.sendMessage(pluginRef.getLocaleManager().getString("Profile.PendingLoad"));
return true;
}
Party party = pluginRef.getUserManager().getPlayer((Player) sender).getParty();
if (party.getLevel() < pluginRef.getPartyManager().getPartyFeatureUnlockLevel(PartyFeature.ITEM_SHARE)) {
sender.sendMessage(pluginRef.getLocaleManager().getString("Party.Feature.Disabled.4"));
return true;
}
switch (args.length) {
case 2:
ShareMode mode = ShareMode.getShareMode(args[1].toUpperCase());
if (mode == null) {
sender.sendMessage(pluginRef.getLocaleManager().getString("Commands.Usage.2", "party", "itemshare", "<NONE | EQUAL | RANDOM>"));
return true;
}
handleChangingShareMode(party, mode);
return true;
case 3:
boolean toggle;
if (pluginRef.getCommandTools().shouldEnableToggle(args[2])) {
toggle = true;
} else if (pluginRef.getCommandTools().shouldDisableToggle(args[2])) {
toggle = false;
} else {
sender.sendMessage(pluginRef.getLocaleManager().getString("Commands.Usage.2", "party", "itemshare", "<loot | mining | herbalism | woodcutting | misc> <true | false>"));
return true;
}
try {
handleToggleItemShareCategory(party, ItemShareType.valueOf(args[1].toUpperCase()), toggle);
} catch (IllegalArgumentException ex) {
sender.sendMessage(pluginRef.getLocaleManager().getString("Commands.Usage.2", "party", "itemshare", "<loot | mining | herbalism | woodcutting | misc> <true | false>"));
}
return true;
default:
sender.sendMessage(pluginRef.getLocaleManager().getString("Commands.Usage.2", "party", "itemshare", "<NONE | EQUAL | RANDOM>"));
sender.sendMessage(pluginRef.getLocaleManager().getString("Commands.Usage.2", "party", "itemshare", "<loot | mining | herbalism | woodcutting | misc> <true | false>"));
return true;
}
}
private void handleChangingShareMode(Party party, ShareMode mode) {
party.setItemShareMode(mode);
String changeModeMessage = pluginRef.getLocaleManager().getString("Commands.Party.SetSharing", pluginRef.getLocaleManager().getString("Party.ShareType.Item"), pluginRef.getLocaleManager().getString("Party.ShareMode." + StringUtils.getCapitalized(mode.toString())));
for (Player member : party.getOnlineMembers()) {
member.sendMessage(changeModeMessage);
}
}
private void handleToggleItemShareCategory(Party party, ItemShareType type, boolean toggle) {
party.setSharingDrops(type, toggle);
String toggleMessage = pluginRef.getLocaleManager().getString("Commands.Party.ToggleShareCategory", StringUtils.getCapitalized(type.toString()), toggle ? "enabled" : "disabled");
for (Player member : party.getOnlineMembers()) {
member.sendMessage(toggleMessage);
}
}
}

View File

@ -0,0 +1,90 @@
package com.gmail.nossr50.commands.party;
import com.gmail.nossr50.datatypes.party.Party;
import com.gmail.nossr50.datatypes.player.McMMOPlayer;
import com.gmail.nossr50.mcMMO;
import org.bukkit.command.Command;
import org.bukkit.command.CommandExecutor;
import org.bukkit.command.CommandSender;
import org.bukkit.entity.Player;
public class PartyJoinCommand implements CommandExecutor {
private final mcMMO pluginRef;
public PartyJoinCommand(mcMMO pluginRef) {
this.pluginRef = pluginRef;
}
@Override
public boolean onCommand(CommandSender sender, Command command, String label, String[] args) {
switch (args.length) {
case 2:
case 3:
String targetName = pluginRef.getCommandTools().getMatchedPlayerName(args[1]);
McMMOPlayer mcMMOTarget = pluginRef.getUserManager().getPlayer(targetName);
if (!pluginRef.getCommandTools().checkPlayerExistence(sender, targetName, mcMMOTarget)) {
return true;
}
Player target = mcMMOTarget.getPlayer();
if (!mcMMOTarget.inParty()) {
sender.sendMessage(pluginRef.getLocaleManager().getString("Party.PlayerNotInParty", targetName));
return true;
}
Player player = (Player) sender;
if (pluginRef.getUserManager().getPlayer((Player) sender) == null) {
sender.sendMessage(pluginRef.getLocaleManager().getString("Profile.PendingLoad"));
return true;
}
McMMOPlayer mcMMOPlayer = pluginRef.getUserManager().getPlayer(player);
Party targetParty = mcMMOTarget.getParty();
if (player.equals(target) || (mcMMOPlayer.inParty() && mcMMOPlayer.getParty().equals(targetParty))) {
sender.sendMessage(pluginRef.getLocaleManager().getString("Party.Join.Self"));
return true;
}
String password = getPassword(args);
// Make sure party passwords match
if (!pluginRef.getPartyManager().checkPartyPassword(player, targetParty, password)) {
return true;
}
String partyName = targetParty.getName();
// Changing parties
if (!pluginRef.getPartyManager().changeOrJoinParty(mcMMOPlayer, partyName)) {
return true;
}
if (pluginRef.getConfigManager().getConfigParty().getPartyGeneral().isPartySizeCapped())
if (pluginRef.getPartyManager().isPartyFull(player, targetParty)) {
player.sendMessage(pluginRef.getLocaleManager().getString("Commands.Party.PartyFull", targetParty.toString()));
return true;
}
player.sendMessage(pluginRef.getLocaleManager().getString("Commands.Party.Join", partyName));
pluginRef.getPartyManager().addToParty(mcMMOPlayer, targetParty);
return true;
default:
sender.sendMessage(pluginRef.getLocaleManager().getString("Commands.Usage.3", "party", "join", "<" + pluginRef.getLocaleManager().getString("Commands.Usage.Player") + ">", "[" + pluginRef.getLocaleManager().getString("Commands.Usage.Password") + "]"));
return true;
}
}
private String getPassword(String[] args) {
if (args.length == 3) {
return args[2];
}
return null;
}
}

View File

@ -0,0 +1,59 @@
package com.gmail.nossr50.commands.party;
import com.gmail.nossr50.datatypes.party.Party;
import com.gmail.nossr50.events.party.McMMOPartyChangeEvent.EventReason;
import com.gmail.nossr50.mcMMO;
import org.bukkit.OfflinePlayer;
import org.bukkit.command.Command;
import org.bukkit.command.CommandExecutor;
import org.bukkit.command.CommandSender;
import org.bukkit.entity.Player;
public class PartyKickCommand implements CommandExecutor {
private final mcMMO pluginRef;
public PartyKickCommand(mcMMO pluginRef) {
this.pluginRef = pluginRef;
}
@Override
public boolean onCommand(CommandSender sender, Command command, String label, String[] args) {
switch (args.length) {
case 2:
if (pluginRef.getUserManager().getPlayer((Player) sender) == null) {
sender.sendMessage(pluginRef.getLocaleManager().getString("Profile.PendingLoad"));
return true;
}
Party playerParty = pluginRef.getUserManager().getPlayer((Player) sender).getParty();
String targetName = pluginRef.getCommandTools().getMatchedPlayerName(args[1]);
if (!playerParty.hasMember(targetName)) {
sender.sendMessage(pluginRef.getLocaleManager().getString("Party.NotInYourParty", targetName));
return true;
}
OfflinePlayer target = pluginRef.getServer().getOfflinePlayer(targetName);
if (target.isOnline()) {
Player onlineTarget = target.getPlayer();
String partyName = playerParty.getName();
if (!pluginRef.getPartyManager().handlePartyChangeEvent(onlineTarget, partyName, null, EventReason.KICKED_FROM_PARTY)) {
return true;
}
pluginRef.getPartyManager().processPartyLeaving(pluginRef.getUserManager().getPlayer(onlineTarget));
onlineTarget.sendMessage(pluginRef.getLocaleManager().getString("Commands.Party.Kick", partyName));
}
pluginRef.getPartyManager().removeFromParty(target, playerParty);
return true;
default:
sender.sendMessage(pluginRef.getLocaleManager().getString("Commands.Usage.2", "party", "kick", "<" + pluginRef.getLocaleManager().getString("Commands.Usage.Player") + ">"));
return true;
}
}
}

View File

@ -0,0 +1,78 @@
package com.gmail.nossr50.commands.party;
import com.gmail.nossr50.datatypes.party.Party;
import com.gmail.nossr50.mcMMO;
import org.bukkit.command.Command;
import org.bukkit.command.CommandExecutor;
import org.bukkit.command.CommandSender;
import org.bukkit.entity.Player;
public class PartyLockCommand implements CommandExecutor {
private final mcMMO pluginRef;
public PartyLockCommand(mcMMO pluginRef) {
this.pluginRef = pluginRef;
}
@Override
public boolean onCommand(CommandSender sender, Command command, String label, String[] args) {
switch (args.length) {
case 1:
if (args[0].equalsIgnoreCase("lock")) {
togglePartyLock(sender, true);
} else if (args[0].equalsIgnoreCase("unlock")) {
togglePartyLock(sender, false);
}
return true;
case 2:
if (!args[0].equalsIgnoreCase("lock")) {
sendUsageStrings(sender);
return true;
}
if (pluginRef.getCommandTools().shouldEnableToggle(args[1])) {
togglePartyLock(sender, true);
} else if (pluginRef.getCommandTools().shouldDisableToggle(args[1])) {
togglePartyLock(sender, false);
} else {
sendUsageStrings(sender);
}
return true;
default:
sendUsageStrings(sender);
return true;
}
}
private void sendUsageStrings(CommandSender sender) {
sender.sendMessage(pluginRef.getLocaleManager().getString("Commands.Usage.2", "party", "lock", "[on|off]"));
sender.sendMessage(pluginRef.getLocaleManager().getString("Commands.Usage.1", "party", "unlock"));
}
private void togglePartyLock(CommandSender sender, boolean lock) {
if (pluginRef.getUserManager().getPlayer((Player) sender) == null) {
sender.sendMessage(pluginRef.getLocaleManager().getString("Profile.PendingLoad"));
return;
}
Party party = pluginRef.getUserManager().getPlayer((Player) sender).getParty();
if (!pluginRef.getPermissionTools().partySubcommand(sender, lock ? PartySubcommandType.LOCK : PartySubcommandType.UNLOCK)) {
sender.sendMessage(pluginRef.getLocaleManager().getString("mcMMO.NoPermission"));
return;
}
if (lock ? party.isLocked() : !party.isLocked()) {
sender.sendMessage(pluginRef.getLocaleManager().getString("Party." + (lock ? "IsLocked" : "IsntLocked")));
return;
}
party.setLocked(lock);
sender.sendMessage(pluginRef.getLocaleManager().getString("Party." + (lock ? "Locked" : "Unlocked")));
}
}

View File

@ -0,0 +1,47 @@
package com.gmail.nossr50.commands.party;
import com.gmail.nossr50.datatypes.party.Party;
import com.gmail.nossr50.datatypes.player.McMMOPlayer;
import com.gmail.nossr50.events.party.McMMOPartyChangeEvent.EventReason;
import com.gmail.nossr50.mcMMO;
import org.bukkit.command.Command;
import org.bukkit.command.CommandExecutor;
import org.bukkit.command.CommandSender;
import org.bukkit.entity.Player;
public class PartyQuitCommand implements CommandExecutor {
private final mcMMO pluginRef;
public PartyQuitCommand(mcMMO pluginRef) {
this.pluginRef = pluginRef;
}
@Override
public boolean onCommand(CommandSender sender, Command command, String label, String[] args) {
switch (args.length) {
case 1:
Player player = (Player) sender;
if (pluginRef.getUserManager().getPlayer((Player) sender) == null) {
sender.sendMessage(pluginRef.getLocaleManager().getString("Profile.PendingLoad"));
return true;
}
McMMOPlayer mcMMOPlayer = pluginRef.getUserManager().getPlayer(player);
Party playerParty = mcMMOPlayer.getParty();
if (!pluginRef.getPartyManager().handlePartyChangeEvent(player, playerParty.getName(), null, EventReason.LEFT_PARTY)) {
return true;
}
pluginRef.getPartyManager().removeFromParty(mcMMOPlayer);
sender.sendMessage(pluginRef.getLocaleManager().getString("Commands.Party.Leave"));
return true;
default:
sender.sendMessage(pluginRef.getLocaleManager().getString("Commands.Usage.1", "party", "quit"));
return true;
}
}
}

View File

@ -0,0 +1,70 @@
package com.gmail.nossr50.commands.party;
import com.gmail.nossr50.datatypes.party.Party;
import com.gmail.nossr50.datatypes.player.McMMOPlayer;
import com.gmail.nossr50.events.party.McMMOPartyChangeEvent.EventReason;
import com.gmail.nossr50.mcMMO;
import org.bukkit.command.Command;
import org.bukkit.command.CommandExecutor;
import org.bukkit.command.CommandSender;
import org.bukkit.entity.Player;
public class PartyRenameCommand implements CommandExecutor {
private final mcMMO pluginRef;
public PartyRenameCommand(mcMMO pluginRef) {
this.pluginRef = pluginRef;
}
@Override
public boolean onCommand(CommandSender sender, Command command, String label, String[] args) {
switch (args.length) {
case 2:
if (pluginRef.getUserManager().getPlayer((Player) sender) == null) {
sender.sendMessage(pluginRef.getLocaleManager().getString("Profile.PendingLoad"));
return true;
}
McMMOPlayer mcMMOPlayer = pluginRef.getUserManager().getPlayer((Player) sender);
Party playerParty = mcMMOPlayer.getParty();
String oldPartyName = playerParty.getName();
String newPartyName = args[1];
// This is to prevent party leaders from spamming other players with the rename message
if (oldPartyName.equalsIgnoreCase(newPartyName)) {
sender.sendMessage(pluginRef.getLocaleManager().getString("Party.Rename.Same"));
return true;
}
Player player = mcMMOPlayer.getPlayer();
// Check to see if the party exists, and if it does cancel renaming the party
if (pluginRef.getPartyManager().checkPartyExistence(player, newPartyName)) {
return true;
}
String leaderName = playerParty.getLeader().getPlayerName();
for (Player member : playerParty.getOnlineMembers()) {
if (!pluginRef.getPartyManager().handlePartyChangeEvent(member, oldPartyName, newPartyName, EventReason.CHANGED_PARTIES)) {
return true;
}
if (!member.getName().equalsIgnoreCase(leaderName)) {
member.sendMessage(pluginRef.getLocaleManager().getString("Party.InformedOnNameChange", leaderName, newPartyName));
}
}
playerParty.setName(newPartyName);
sender.sendMessage(pluginRef.getLocaleManager().getString("Commands.Party.Rename", newPartyName));
return true;
default:
sender.sendMessage(pluginRef.getLocaleManager().getString("Commands.Usage.2", "party", "rename", "<" + pluginRef.getLocaleManager().getString("Commands.Usage.PartyName") + ">"));
return true;
}
}
}

View File

@ -0,0 +1,47 @@
package com.gmail.nossr50.commands.party;
public enum PartySubcommandType {
JOIN,
ACCEPT,
CREATE,
HELP,
INFO,
QUIT,
XPSHARE,
ITEMSHARE,
INVITE,
KICK,
DISBAND,
OWNER,
LOCK,
UNLOCK,
PASSWORD,
RENAME,
TELEPORT,
CHAT,
ALLIANCE;
public static PartySubcommandType getSubcommand(String commandName) {
for (PartySubcommandType command : values()) {
if (command.name().equalsIgnoreCase(commandName)) {
return command;
}
}
if (commandName.equalsIgnoreCase("?")) {
return HELP;
} else if (commandName.equalsIgnoreCase("q") || commandName.equalsIgnoreCase("leave")) {
return QUIT;
} else if (commandName.equalsIgnoreCase("leader")) {
return OWNER;
} else if (commandName.equalsIgnoreCase("xpshare") || commandName.equalsIgnoreCase("shareexp") || commandName.equalsIgnoreCase("sharexp")) {
return XPSHARE;
} else if (commandName.equalsIgnoreCase("shareitem") || commandName.equalsIgnoreCase("shareitems")) {
return ITEMSHARE;
} else if (commandName.equalsIgnoreCase("ally")) {
return ALLIANCE;
}
return null;
}
}

View File

@ -0,0 +1,62 @@
package com.gmail.nossr50.commands.party;
import com.gmail.nossr50.datatypes.party.Party;
import com.gmail.nossr50.datatypes.party.PartyFeature;
import com.gmail.nossr50.datatypes.party.ShareMode;
import com.gmail.nossr50.mcMMO;
import com.gmail.nossr50.util.StringUtils;
import org.bukkit.command.Command;
import org.bukkit.command.CommandExecutor;
import org.bukkit.command.CommandSender;
import org.bukkit.entity.Player;
public class PartyXpShareCommand implements CommandExecutor {
private final mcMMO pluginRef;
public PartyXpShareCommand(mcMMO pluginRef) {
this.pluginRef = pluginRef;
}
@Override
public boolean onCommand(CommandSender sender, Command command, String label, String[] args) {
if (pluginRef.getUserManager().getPlayer((Player) sender) == null) {
sender.sendMessage(pluginRef.getLocaleManager().getString("Profile.PendingLoad"));
return true;
}
Party party = pluginRef.getUserManager().getPlayer((Player) sender).getParty();
if (party.getLevel() < pluginRef.getPartyManager().getPartyFeatureUnlockLevel(PartyFeature.XP_SHARE)) {
sender.sendMessage(pluginRef.getLocaleManager().getString("Party.Feature.Disabled.5"));
return true;
}
switch (args.length) {
case 2:
if (args[1].equalsIgnoreCase("none") || pluginRef.getCommandTools().shouldDisableToggle(args[1])) {
handleChangingShareMode(party, ShareMode.NONE);
} else if (args[1].equalsIgnoreCase("equal") || args[1].equalsIgnoreCase("even") || pluginRef.getCommandTools().shouldEnableToggle(args[1])) {
handleChangingShareMode(party, ShareMode.EQUAL);
} else {
sender.sendMessage(pluginRef.getLocaleManager().getString("Commands.Usage.2", "party", "xpshare", "<NONE | EQUAL>"));
}
return true;
default:
sender.sendMessage(pluginRef.getLocaleManager().getString("Commands.Usage.2", "party", "xpshare", "<NONE | EQUAL>"));
return true;
}
}
private void handleChangingShareMode(Party party, ShareMode mode) {
party.setXpShareMode(mode);
String changeModeMessage = pluginRef.getLocaleManager().getString("Commands.Party.SetSharing", pluginRef.getLocaleManager().getString("Party.ShareType.Xp"), pluginRef.getLocaleManager().getString("Party.ShareMode." + StringUtils.getCapitalized(mode.toString())));
for (Player member : party.getOnlineMembers()) {
member.sendMessage(changeModeMessage);
}
}
}

View File

@ -0,0 +1,47 @@
package com.gmail.nossr50.commands.party.alliance;
import com.gmail.nossr50.datatypes.player.McMMOPlayer;
import com.gmail.nossr50.mcMMO;
import org.bukkit.command.Command;
import org.bukkit.command.CommandExecutor;
import org.bukkit.command.CommandSender;
import org.bukkit.entity.Player;
public class PartyAllianceAcceptCommand implements CommandExecutor {
private final mcMMO pluginRef;
public PartyAllianceAcceptCommand(mcMMO pluginRef) {
this.pluginRef = pluginRef;
}
@Override
public boolean onCommand(CommandSender sender, Command command, String label, String[] args) {
switch (args.length) {
case 2:
if (pluginRef.getUserManager().getPlayer((Player) sender) == null) {
sender.sendMessage(pluginRef.getLocaleManager().getString("Profile.PendingLoad"));
return true;
}
Player player = (Player) sender;
McMMOPlayer mcMMOPlayer = pluginRef.getUserManager().getPlayer(player);
if (!mcMMOPlayer.hasPartyAllianceInvite()) {
sender.sendMessage(pluginRef.getLocaleManager().getString("mcMMO.NoInvites"));
return true;
}
if (mcMMOPlayer.getParty().getAlly() != null) {
player.sendMessage(pluginRef.getLocaleManager().getString("Commands.Party.Alliance.AlreadyAllies"));
return true;
}
pluginRef.getPartyManager().acceptAllianceInvite(mcMMOPlayer);
return true;
default:
sender.sendMessage(pluginRef.getLocaleManager().getString("Commands.Usage.2", "party", "alliance", "accept"));
return true;
}
}
}

View File

@ -0,0 +1,141 @@
package com.gmail.nossr50.commands.party.alliance;
import com.gmail.nossr50.commands.CommandConstants;
import com.gmail.nossr50.datatypes.party.Party;
import com.gmail.nossr50.datatypes.party.PartyFeature;
import com.gmail.nossr50.datatypes.player.McMMOPlayer;
import com.gmail.nossr50.mcMMO;
import com.google.common.collect.ImmutableList;
import org.bukkit.ChatColor;
import org.bukkit.command.Command;
import org.bukkit.command.CommandExecutor;
import org.bukkit.command.CommandSender;
import org.bukkit.command.TabExecutor;
import org.bukkit.entity.Player;
import org.bukkit.util.StringUtil;
import java.util.ArrayList;
import java.util.List;
public class PartyAllianceCommand implements TabExecutor {
private final mcMMO pluginRef;
private Player player;
private Party playerParty;
private Party targetParty;
private CommandExecutor partyAllianceInviteCommand;
private CommandExecutor partyAllianceAcceptCommand;
private CommandExecutor partyAllianceDisbandCommand;
public PartyAllianceCommand(mcMMO pluginRef) {
this.pluginRef = pluginRef;
//Init SubCommands
partyAllianceInviteCommand = new PartyAllianceInviteCommand(pluginRef);
partyAllianceAcceptCommand = new PartyAllianceAcceptCommand(pluginRef);
partyAllianceDisbandCommand = new PartyAllianceDisbandCommand(pluginRef);
}
@Override
public boolean onCommand(CommandSender sender, Command command, String label, String[] args) {
if (pluginRef.getCommandTools().noConsoleUsage(sender)) {
return true;
}
if (pluginRef.getUserManager().getPlayer((Player) sender) == null) {
sender.sendMessage(pluginRef.getLocaleManager().getString("Profile.PendingLoad"));
return true;
}
player = (Player) sender;
McMMOPlayer mcMMOPlayer = pluginRef.getUserManager().getPlayer(player);
playerParty = mcMMOPlayer.getParty();
switch (args.length) {
case 1:
if (playerParty.getLevel() < pluginRef.getPartyManager().getPartyFeatureUnlockLevel(PartyFeature.ALLIANCE)) {
sender.sendMessage(pluginRef.getLocaleManager().getString("Party.Feature.Disabled.3"));
return true;
}
if (playerParty.getAlly() == null) {
printUsage();
return true;
}
targetParty = playerParty.getAlly();
displayPartyHeader();
displayMemberInfo(mcMMOPlayer);
return true;
case 2:
case 3:
if (playerParty.getLevel() < pluginRef.getPartyManager().getPartyFeatureUnlockLevel(PartyFeature.ALLIANCE)) {
sender.sendMessage(pluginRef.getLocaleManager().getString("Party.Feature.Disabled.3"));
return true;
}
if (args[1].equalsIgnoreCase("invite")) {
return partyAllianceInviteCommand.onCommand(sender, command, label, args);
}
if (args[1].equalsIgnoreCase("accept")) {
return partyAllianceAcceptCommand.onCommand(sender, command, label, args);
}
if (args[1].equalsIgnoreCase("disband")) {
return partyAllianceDisbandCommand.onCommand(sender, command, label, args);
}
if (playerParty.getAlly() == null) {
printUsage();
return true;
}
targetParty = playerParty.getAlly();
displayPartyHeader();
displayMemberInfo(mcMMOPlayer);
return true;
default:
return false;
}
}
private void printUsage() {
player.sendMessage(pluginRef.getLocaleManager().getString("Commands.Party.Alliance.Help.0"));
player.sendMessage(pluginRef.getLocaleManager().getString("Commands.Party.Alliance.Help.1"));
}
@Override
public List<String> onTabComplete(CommandSender commandSender, Command command, String label, String[] args) {
switch (args.length) {
case 1:
List<String> matches = StringUtil.copyPartialMatches(args[0], CommandConstants.ALLIANCE_SUBCOMMANDS, new ArrayList<>(CommandConstants.ALLIANCE_SUBCOMMANDS.size()));
if (matches.size() == 0) {
List<String> playerNames = pluginRef.getCommandTools().getOnlinePlayerNames(commandSender);
return StringUtil.copyPartialMatches(args[0], playerNames, new ArrayList<>(playerNames.size()));
}
return matches;
default:
return ImmutableList.of();
}
}
private void displayPartyHeader() {
player.sendMessage(pluginRef.getLocaleManager().getString("Commands.Party.Alliance.Header"));
player.sendMessage(pluginRef.getLocaleManager().getString("Commands.Party.Alliance.Ally", playerParty.getName(), targetParty.getName()));
}
private void displayMemberInfo(McMMOPlayer mcMMOPlayer) {
player.sendMessage(pluginRef.getLocaleManager().getString("Commands.Party.Alliance.Members.Header"));
player.sendMessage(playerParty.createMembersList(player));
player.sendMessage(ChatColor.DARK_GRAY + "----------------------------");
player.sendMessage(targetParty.createMembersList(player));
}
}

View File

@ -0,0 +1,44 @@
package com.gmail.nossr50.commands.party.alliance;
import com.gmail.nossr50.datatypes.party.Party;
import com.gmail.nossr50.datatypes.player.McMMOPlayer;
import com.gmail.nossr50.mcMMO;
import org.bukkit.command.Command;
import org.bukkit.command.CommandExecutor;
import org.bukkit.command.CommandSender;
import org.bukkit.entity.Player;
public class PartyAllianceDisbandCommand implements CommandExecutor {
private final mcMMO pluginRef;
public PartyAllianceDisbandCommand(mcMMO pluginRef) {
this.pluginRef = pluginRef;
}
@Override
public boolean onCommand(CommandSender sender, Command command, String label, String[] args) {
switch (args.length) {
case 2:
if (pluginRef.getUserManager().getPlayer((Player) sender) == null) {
sender.sendMessage(pluginRef.getLocaleManager().getString("Profile.PendingLoad"));
return true;
}
Player player = (Player) sender;
McMMOPlayer mcMMOPlayer = pluginRef.getUserManager().getPlayer(player);
Party party = mcMMOPlayer.getParty();
if (party.getAlly() == null) {
sender.sendMessage(pluginRef.getLocaleManager().getString("Commands.Party.Alliance.None"));
return true;
}
pluginRef.getPartyManager().disbandAlliance(player, party, party.getAlly());
return true;
default:
sender.sendMessage(pluginRef.getLocaleManager().getString("Commands.Usage.2", "party", "alliance", "disband"));
return true;
}
}
}

View File

@ -0,0 +1,80 @@
package com.gmail.nossr50.commands.party.alliance;
import com.gmail.nossr50.datatypes.party.Party;
import com.gmail.nossr50.datatypes.player.McMMOPlayer;
import com.gmail.nossr50.mcMMO;
import org.bukkit.command.Command;
import org.bukkit.command.CommandExecutor;
import org.bukkit.command.CommandSender;
import org.bukkit.entity.Player;
public class PartyAllianceInviteCommand implements CommandExecutor {
private final mcMMO pluginRef;
public PartyAllianceInviteCommand(mcMMO pluginRef) {
this.pluginRef = pluginRef;
}
@Override
public boolean onCommand(CommandSender sender, Command command, String label, String[] args) {
switch (args.length) {
case 3:
String targetName = pluginRef.getCommandTools().getMatchedPlayerName(args[2]);
McMMOPlayer mcMMOTarget = pluginRef.getUserManager().getOfflinePlayer(targetName);
if (!pluginRef.getCommandTools().checkPlayerExistence(sender, targetName, mcMMOTarget)) {
return false;
}
Player target = mcMMOTarget.getPlayer();
if (pluginRef.getUserManager().getPlayer((Player) sender) == null) {
sender.sendMessage(pluginRef.getLocaleManager().getString("Profile.PendingLoad"));
return true;
}
Player player = (Player) sender;
McMMOPlayer mcMMOPlayer = pluginRef.getUserManager().getPlayer(player);
String playerName = player.getName();
if (player.equals(target)) {
sender.sendMessage(pluginRef.getLocaleManager().getString("Party.Invite.Self"));
return true;
}
if (!mcMMOTarget.inParty()) {
player.sendMessage(pluginRef.getLocaleManager().getString("Party.PlayerNotInParty", targetName));
return true;
}
if (pluginRef.getPartyManager().inSameParty(player, target)) {
sender.sendMessage(pluginRef.getLocaleManager().getString("Party.Player.InSameParty", targetName));
return true;
}
if (!mcMMOTarget.getParty().getLeader().getUniqueId().equals(target.getUniqueId())) {
player.sendMessage(pluginRef.getLocaleManager().getString("Party.Target.NotOwner", targetName));
return true;
}
Party playerParty = mcMMOPlayer.getParty();
if (playerParty.getAlly() != null) {
player.sendMessage(pluginRef.getLocaleManager().getString("Commands.Party.Alliance.AlreadyAllies"));
return true;
}
mcMMOTarget.setPartyAllianceInvite(playerParty);
sender.sendMessage(pluginRef.getLocaleManager().getString("Commands.Invite.Success"));
target.sendMessage(pluginRef.getLocaleManager().getString("Commands.Party.Alliance.Invite.0", playerParty.getName(), playerName));
target.sendMessage(pluginRef.getLocaleManager().getString("Commands.Party.Alliance.Invite.1"));
return true;
default:
sender.sendMessage(pluginRef.getLocaleManager().getString("Commands.Usage.3", "party", "alliance", "invite", "<" + pluginRef.getLocaleManager().getString("Commands.Usage.Player") + ">"));
return true;
}
}
}

View File

@ -0,0 +1,34 @@
package com.gmail.nossr50.commands.party.teleport;
import com.gmail.nossr50.datatypes.party.PartyTeleportRecord;
import com.gmail.nossr50.mcMMO;
import org.bukkit.command.Command;
import org.bukkit.command.CommandExecutor;
import org.bukkit.command.CommandSender;
public class PtpAcceptAnyCommand implements CommandExecutor {
private final mcMMO pluginRef;
public PtpAcceptAnyCommand(mcMMO pluginRef) {
this.pluginRef = pluginRef;
}
@Override
public boolean onCommand(CommandSender sender, Command command, String label, String[] args) {
if (!pluginRef.getPermissionTools().partyTeleportAcceptAll(sender)) {
sender.sendMessage(command.getPermissionMessage());
return true;
}
PartyTeleportRecord ptpRecord = pluginRef.getUserManager().getPlayer(sender.getName()).getPartyTeleportRecord();
if (ptpRecord.isConfirmRequired()) {
sender.sendMessage(pluginRef.getLocaleManager().getString("Commands.ptp.AcceptAny.Disabled"));
} else {
sender.sendMessage(pluginRef.getLocaleManager().getString("Commands.ptp.AcceptAny.Enabled"));
}
ptpRecord.toggleConfirmRequired();
return true;
}
}

View File

@ -0,0 +1,70 @@
package com.gmail.nossr50.commands.party.teleport;
import com.gmail.nossr50.datatypes.party.PartyTeleportRecord;
import com.gmail.nossr50.mcMMO;
import org.bukkit.World;
import org.bukkit.command.Command;
import org.bukkit.command.CommandExecutor;
import org.bukkit.command.CommandSender;
import org.bukkit.entity.Player;
public class PtpAcceptCommand implements CommandExecutor {
private final mcMMO pluginRef;
public PtpAcceptCommand(mcMMO pluginRef) {
this.pluginRef = pluginRef;
}
@Override
public boolean onCommand(CommandSender sender, Command command, String label, String[] args) {
if (!pluginRef.getPermissionTools().partyTeleportAccept(sender)) {
sender.sendMessage(command.getPermissionMessage());
return true;
}
if (pluginRef.getUserManager().getPlayer((Player) sender) == null) {
sender.sendMessage(pluginRef.getLocaleManager().getString("Profile.PendingLoad"));
return true;
}
Player player = (Player) sender;
PartyTeleportRecord ptpRecord = pluginRef.getUserManager().getPlayer(player).getPartyTeleportRecord();
if (!ptpRecord.hasRequest()) {
player.sendMessage(pluginRef.getLocaleManager().getString("Commands.ptp.NoRequests"));
return true;
}
if (pluginRef.getSkillTools().cooldownExpired(ptpRecord.getTimeout(), pluginRef.getConfigManager().getConfigParty().getPTP().getPtpRequestTimeout())) {
ptpRecord.removeRequest();
player.sendMessage(pluginRef.getLocaleManager().getString("Commands.ptp.RequestExpired"));
return true;
}
Player target = ptpRecord.getRequestor();
ptpRecord.removeRequest();
if (!pluginRef.getPartyManager().canTeleport(sender, player, target.getName())) {
return true;
}
if (pluginRef.getConfigManager().getConfigParty().getPTP().isPtpWorldBasedPermissions()) {
World targetWorld = target.getWorld();
World playerWorld = player.getWorld();
if (!pluginRef.getPermissionTools().partyTeleportAllWorlds(target)) {
if (!pluginRef.getPermissionTools().partyTeleportWorld(target, targetWorld)) {
target.sendMessage(pluginRef.getLocaleManager().getString("Commands.ptp.NoWorldPermissions", targetWorld.getName()));
return true;
} else if (targetWorld != playerWorld && !pluginRef.getPermissionTools().partyTeleportWorld(target, playerWorld)) {
target.sendMessage(pluginRef.getLocaleManager().getString("Commands.ptp.NoWorldPermissions", playerWorld.getName()));
return true;
}
}
}
pluginRef.getPartyManager().handleTeleportWarmup(target, player);
return true;
}
}

View File

@ -0,0 +1,177 @@
package com.gmail.nossr50.commands.party.teleport;
import com.gmail.nossr50.commands.CommandConstants;
import com.gmail.nossr50.datatypes.party.Party;
import com.gmail.nossr50.datatypes.party.PartyFeature;
import com.gmail.nossr50.datatypes.party.PartyTeleportRecord;
import com.gmail.nossr50.datatypes.player.McMMOPlayer;
import com.gmail.nossr50.mcMMO;
import com.google.common.collect.ImmutableList;
import org.bukkit.command.Command;
import org.bukkit.command.CommandExecutor;
import org.bukkit.command.CommandSender;
import org.bukkit.command.TabExecutor;
import org.bukkit.entity.Player;
import org.bukkit.util.StringUtil;
import java.util.ArrayList;
import java.util.List;
public class PtpCommand implements TabExecutor {
private final mcMMO pluginRef;
private CommandExecutor ptpToggleCommand;
private CommandExecutor ptpAcceptAnyCommand;
private CommandExecutor ptpAcceptCommand;
public PtpCommand(mcMMO pluginRef) {
this.pluginRef = pluginRef;
//Init SubCommands
ptpToggleCommand = new PtpToggleCommand(pluginRef);
ptpAcceptAnyCommand = new PtpAcceptAnyCommand(pluginRef);
ptpAcceptCommand = new PtpAcceptCommand(pluginRef);
}
@Override
public boolean onCommand(CommandSender sender, Command command, String label, String[] args) {
if (pluginRef.getCommandTools().noConsoleUsage(sender)) {
return true;
}
Player player = (Player) sender;
/* WORLD GUARD MAIN FLAG CHECK */
if (pluginRef.getWorldGuardUtils().isWorldGuardLoaded()) {
if (!pluginRef.getWorldGuardManager().hasMainFlag(player))
return true;
}
/* WORLD BLACKLIST CHECK */
if (pluginRef.getDynamicSettingsManager().isWorldBlacklisted(player.getWorld().getName()))
return true;
if (!pluginRef.getUserManager().hasPlayerDataKey(player)) {
return true;
}
if (pluginRef.getUserManager().getPlayer((Player) sender) == null) {
sender.sendMessage(pluginRef.getLocaleManager().getString("Profile.PendingLoad"));
return true;
}
McMMOPlayer mcMMOPlayer = pluginRef.getUserManager().getPlayer(player);
if (!mcMMOPlayer.inParty()) {
sender.sendMessage(pluginRef.getLocaleManager().getString("Commands.Party.None"));
return true;
}
Party party = mcMMOPlayer.getParty();
if (party.getLevel() < pluginRef.getPartyManager().getPartyFeatureUnlockLevel(PartyFeature.TELEPORT)) {
sender.sendMessage(pluginRef.getLocaleManager().getString("Party.Feature.Disabled.2"));
return true;
}
if (args.length == 1) {
if (args[0].equalsIgnoreCase("toggle")) {
return ptpToggleCommand.onCommand(sender, command, label, args);
}
if (args[0].equalsIgnoreCase("acceptany") || args[0].equalsIgnoreCase("acceptall")) {
return ptpAcceptAnyCommand.onCommand(sender, command, label, args);
}
long recentlyHurt = mcMMOPlayer.getRecentlyHurt();
int hurtCooldown = pluginRef.getConfigManager().getConfigParty().getPTP().getPtpRecentlyHurtCooldown();
if (hurtCooldown > 0) {
int timeRemaining = pluginRef.getSkillTools().calculateTimeLeft(recentlyHurt * pluginRef.getMiscTools().TIME_CONVERSION_FACTOR, hurtCooldown, player);
if (timeRemaining > 0) {
player.sendMessage(pluginRef.getLocaleManager().getString("Item.Injured.Wait", timeRemaining));
return true;
}
}
if (args[0].equalsIgnoreCase("accept")) {
return ptpAcceptCommand.onCommand(sender, command, label, args);
}
if (!pluginRef.getPermissionTools().partyTeleportSend(sender)) {
sender.sendMessage(command.getPermissionMessage());
return true;
}
int ptpCooldown = pluginRef.getConfigManager().getConfigParty().getPTP().getPtpCooldown();
long ptpLastUse = mcMMOPlayer.getPartyTeleportRecord().getLastUse();
if (ptpCooldown > 0) {
int timeRemaining = pluginRef.getSkillTools().calculateTimeLeft(ptpLastUse * pluginRef.getMiscTools().TIME_CONVERSION_FACTOR, ptpCooldown, player);
if (timeRemaining > 0) {
player.sendMessage(pluginRef.getLocaleManager().getString("Item.Generic.Wait", timeRemaining));
return true;
}
}
sendTeleportRequest(sender, player, pluginRef.getCommandTools().getMatchedPlayerName(args[0]));
return true;
}
return false;
}
@Override
public List<String> onTabComplete(CommandSender sender, Command command, String alias, String[] args) {
switch (args.length) {
case 1:
List<String> matches = StringUtil.copyPartialMatches(args[0], CommandConstants.TELEPORT_SUBCOMMANDS, new ArrayList<>(CommandConstants.TELEPORT_SUBCOMMANDS.size()));
if (matches.size() == 0) {
if (pluginRef.getUserManager().getPlayer((Player) sender) == null) {
sender.sendMessage(pluginRef.getLocaleManager().getString("Profile.PendingLoad"));
return ImmutableList.of();
}
Player player = (Player) sender;
McMMOPlayer mcMMOPlayer = pluginRef.getUserManager().getPlayer(player);
if (!mcMMOPlayer.inParty()) {
return ImmutableList.of();
}
List<String> playerNames = mcMMOPlayer.getParty().getOnlinePlayerNames(player);
return StringUtil.copyPartialMatches(args[0], playerNames, new ArrayList<>(playerNames.size()));
}
return matches;
default:
return ImmutableList.of();
}
}
private void sendTeleportRequest(CommandSender sender, Player player, String targetName) {
if (!pluginRef.getPartyManager().canTeleport(sender, player, targetName)) {
return;
}
McMMOPlayer mcMMOTarget = pluginRef.getUserManager().getPlayer(targetName);
Player target = mcMMOTarget.getPlayer();
PartyTeleportRecord ptpRecord = mcMMOTarget.getPartyTeleportRecord();
if (!ptpRecord.isConfirmRequired()) {
pluginRef.getPartyManager().handleTeleportWarmup(player, target);
return;
}
ptpRecord.setRequestor(player);
ptpRecord.actualizeTimeout();
player.sendMessage(pluginRef.getLocaleManager().getString("Commands.Invite.Success"));
target.sendMessage(pluginRef.getLocaleManager().getString("Commands.ptp.Request1", player.getName()));
target.sendMessage(pluginRef.getLocaleManager().getString("Commands.ptp.Request2", pluginRef.getConfigManager().getConfigParty().getPTP().getPtpRequestTimeout()));
}
}

View File

@ -0,0 +1,35 @@
package com.gmail.nossr50.commands.party.teleport;
import com.gmail.nossr50.datatypes.party.PartyTeleportRecord;
import com.gmail.nossr50.mcMMO;
import org.bukkit.command.Command;
import org.bukkit.command.CommandExecutor;
import org.bukkit.command.CommandSender;
public class PtpToggleCommand implements CommandExecutor {
private final mcMMO pluginRef;
public PtpToggleCommand(mcMMO pluginRef) {
this.pluginRef = pluginRef;
}
@Override
public boolean onCommand(CommandSender sender, Command command, String label, String[] args) {
if (!pluginRef.getPermissionTools().partyTeleportToggle(sender)) {
sender.sendMessage(command.getPermissionMessage());
return true;
}
PartyTeleportRecord ptpRecord = pluginRef.getUserManager().getPlayer(sender.getName()).getPartyTeleportRecord();
if (ptpRecord.isEnabled()) {
sender.sendMessage(pluginRef.getLocaleManager().getString("Commands.ptp.Disabled"));
} else {
sender.sendMessage(pluginRef.getLocaleManager().getString("Commands.ptp.Enabled"));
}
ptpRecord.toggleEnabled();
return true;
}
}

View File

@ -0,0 +1,80 @@
package com.gmail.nossr50.commands.player;
import com.gmail.nossr50.datatypes.player.McMMOPlayer;
import com.gmail.nossr50.datatypes.skills.SuperAbilityType;
import com.gmail.nossr50.mcMMO;
import com.gmail.nossr50.util.scoreboards.SidebarType;
import com.google.common.collect.ImmutableList;
import org.bukkit.command.Command;
import org.bukkit.command.CommandSender;
import org.bukkit.command.TabExecutor;
import org.bukkit.entity.Player;
import java.util.List;
public class CooldownCommand implements TabExecutor {
private final mcMMO pluginRef;
public CooldownCommand(mcMMO pluginRef) {
this.pluginRef = pluginRef;
}
@Override
public boolean onCommand(CommandSender sender, Command command, String label, String[] args) {
if (pluginRef.getCommandTools().noConsoleUsage(sender)) {
return true;
}
if (!pluginRef.getCommandTools().hasPlayerDataKey(sender)) {
return true;
}
switch (args.length) {
case 0:
Player player = (Player) sender;
if (pluginRef.getScoreboardSettings().getScoreboardsEnabled() && pluginRef.getScoreboardSettings().isScoreboardEnabled(SidebarType.COOLDOWNS_BOARD)) {
pluginRef.getScoreboardManager().enablePlayerCooldownScoreboard(player);
if (!pluginRef.getScoreboardSettings().isScoreboardPrinting(SidebarType.COOLDOWNS_BOARD)) {
return true;
}
}
if (pluginRef.getUserManager().getPlayer(player) == null) {
player.sendMessage(pluginRef.getLocaleManager().getString("Profile.PendingLoad"));
return true;
}
McMMOPlayer mcMMOPlayer = pluginRef.getUserManager().getPlayer(player);
player.sendMessage(pluginRef.getLocaleManager().getString("Commands.Cooldowns.Header"));
player.sendMessage(pluginRef.getLocaleManager().getString("mcMMO.NoSkillNote"));
for (SuperAbilityType superAbilityType : SuperAbilityType.values()) {
if (!pluginRef.getSkillTools().superAbilityPermissionCheck(superAbilityType, player)) {
continue;
}
int seconds = mcMMOPlayer.calculateTimeRemaining(superAbilityType);
if (seconds <= 0) {
player.sendMessage(pluginRef.getLocaleManager().getString("Commands.Cooldowns.Row.Y", pluginRef.getSkillTools().getPrettySuperAbilityName(superAbilityType)));
} else {
player.sendMessage(pluginRef.getLocaleManager().getString("Commands.Cooldowns.Row.N", pluginRef.getSkillTools().getPrettySuperAbilityName(superAbilityType), seconds));
}
}
return true;
default:
return false;
}
}
@Override
public List<String> onTabComplete(CommandSender sender, Command command, String alias, String[] args) {
return ImmutableList.of();
}
}

View File

@ -0,0 +1,110 @@
package com.gmail.nossr50.commands.player;
import com.gmail.nossr50.datatypes.player.McMMOPlayer;
import com.gmail.nossr50.datatypes.player.PlayerProfile;
import com.gmail.nossr50.datatypes.skills.PrimarySkillType;
import com.gmail.nossr50.mcMMO;
import com.google.common.collect.ImmutableList;
import org.bukkit.command.Command;
import org.bukkit.command.CommandSender;
import org.bukkit.command.TabExecutor;
import org.bukkit.entity.Player;
import org.bukkit.util.StringUtil;
import java.util.ArrayList;
import java.util.List;
public class InspectCommand implements TabExecutor {
private final mcMMO pluginRef;
public InspectCommand(mcMMO pluginRef) {
this.pluginRef = pluginRef;
}
@Override
public boolean onCommand(CommandSender sender, Command command, String label, String[] args) {
switch (args.length) {
case 1:
String playerName = pluginRef.getCommandTools().getMatchedPlayerName(args[0]);
McMMOPlayer mcMMOPlayer = pluginRef.getUserManager().getOfflinePlayer(playerName);
// If the mcMMOPlayer doesn't exist, create a temporary profile and check if it's present in the database. If it's not, abort the process.
if (mcMMOPlayer == null) {
PlayerProfile profile = pluginRef.getDatabaseManager().loadPlayerProfile(playerName, false); // Temporary Profile
if (!pluginRef.getCommandTools().isLoaded(sender, profile)) {
return true;
}
if (pluginRef.getScoreboardSettings().getScoreboardsEnabled() && sender instanceof Player
&& pluginRef.getScoreboardSettings().getConfigSectionScoreboardTypes().getConfigSectionInspectBoard().isUseThisBoard()) {
pluginRef.getScoreboardManager().enablePlayerInspectScoreboard((Player) sender, profile);
if (!pluginRef.getScoreboardSettings().getConfigSectionScoreboardTypes().getConfigSectionInspectBoard().isPrintToChat()) {
return true;
}
}
sender.sendMessage(pluginRef.getLocaleManager().getString("Inspect.OfflineStats", playerName));
sender.sendMessage(pluginRef.getLocaleManager().getString("Stats.Header.Gathering"));
for (PrimarySkillType skill : pluginRef.getSkillTools().GATHERING_SKILLS) {
sender.sendMessage(pluginRef.getCommandTools().displaySkill(profile, skill));
}
sender.sendMessage(pluginRef.getLocaleManager().getString("Stats.Header.Combat"));
for (PrimarySkillType skill : pluginRef.getSkillTools().COMBAT_SKILLS) {
sender.sendMessage(pluginRef.getCommandTools().displaySkill(profile, skill));
}
sender.sendMessage(pluginRef.getLocaleManager().getString("Stats.Header.Misc"));
for (PrimarySkillType skill : pluginRef.getSkillTools().MISC_SKILLS) {
sender.sendMessage(pluginRef.getCommandTools().displaySkill(profile, skill));
}
} else {
Player target = mcMMOPlayer.getPlayer();
if (pluginRef.getCommandTools().hidden(sender, target, pluginRef.getPermissionTools().inspectHidden(sender))) {
sender.sendMessage(pluginRef.getLocaleManager().getString("Inspect.Offline"));
return true;
}
else if (pluginRef.getCommandTools().tooFar(sender, target, pluginRef.getPermissionTools().inspectFar(sender))) {
return true;
}
if (pluginRef.getScoreboardSettings().getScoreboardsEnabled() && sender instanceof Player && pluginRef.getScoreboardSettings().getConfigSectionScoreboardTypes().getConfigSectionInspectBoard().isUseThisBoard()) {
pluginRef.getScoreboardManager().enablePlayerInspectScoreboard((Player) sender, mcMMOPlayer.getProfile());
if (!pluginRef.getScoreboardSettings().getConfigSectionScoreboardTypes().getConfigSectionInspectBoard().isPrintToChat()) {
return true;
}
}
sender.sendMessage(pluginRef.getLocaleManager().getString("Inspect.Stats", target.getName()));
pluginRef.getCommandTools().printGatheringSkills(target, sender);
pluginRef.getCommandTools().printCombatSkills(target, sender);
pluginRef.getCommandTools().printMiscSkills(target, sender);
sender.sendMessage(pluginRef.getLocaleManager().getString("Commands.PowerLevel", mcMMOPlayer.getPowerLevel()));
}
return true;
default:
return false;
}
}
@Override
public List<String> onTabComplete(CommandSender sender, Command command, String alias, String[] args) {
switch (args.length) {
case 1:
List<String> playerNames = pluginRef.getCommandTools().getOnlinePlayerNames(sender);
return StringUtil.copyPartialMatches(args[0], playerNames, new ArrayList<>(playerNames.size()));
default:
return ImmutableList.of();
}
}
}

View File

@ -0,0 +1,139 @@
package com.gmail.nossr50.commands.player;
import com.gmail.nossr50.core.MetadataConstants;
import com.gmail.nossr50.datatypes.player.McMMOPlayer;
import com.gmail.nossr50.datatypes.skills.PrimarySkillType;
import com.gmail.nossr50.mcMMO;
import com.gmail.nossr50.runnables.commands.LeaderboardsCommandAsyncTask;
import com.gmail.nossr50.util.StringUtils;
import com.gmail.nossr50.util.scoreboards.SidebarType;
import com.google.common.collect.ImmutableList;
import org.bukkit.command.Command;
import org.bukkit.command.CommandSender;
import org.bukkit.command.TabExecutor;
import org.bukkit.entity.Player;
import org.bukkit.metadata.FixedMetadataValue;
import org.bukkit.util.StringUtil;
import java.util.ArrayList;
import java.util.List;
public class LeaderboardCommand implements TabExecutor {
private final mcMMO pluginRef;
public LeaderboardCommand(mcMMO pluginRef) {
this.pluginRef = pluginRef;
}
@Override
public boolean onCommand(CommandSender sender, Command command, String label, String[] args) {
PrimarySkillType skill = null;
switch (args.length) {
case 0:
display(1, skill, sender, command);
return true;
case 1:
if (StringUtils.isInt(args[0])) {
display(Math.abs(Integer.parseInt(args[0])), skill, sender, command);
return true;
}
skill = extractSkill(sender, args[0]);
if (skill == null) {
return true;
}
display(1, skill, sender, command);
return true;
case 2:
if (pluginRef.getCommandTools().isInvalidInteger(sender, args[1])) {
return true;
}
skill = extractSkill(sender, args[0]);
if (skill == null) {
return true;
}
display(Math.abs(Integer.parseInt(args[1])), skill, sender, command);
return true;
default:
return false;
}
}
@Override
public List<String> onTabComplete(CommandSender sender, Command command, String alias, String[] args) {
switch (args.length) {
case 1:
return StringUtil.copyPartialMatches(args[0], pluginRef.getSkillTools().LOCALIZED_SKILL_NAMES, new ArrayList<>(pluginRef.getSkillTools().LOCALIZED_SKILL_NAMES.size()));
default:
return ImmutableList.of();
}
}
private void display(int page, PrimarySkillType skill, CommandSender sender, Command command) {
if (skill != null && !pluginRef.getPermissionTools().mctop(sender, skill)) {
sender.sendMessage(command.getPermissionMessage());
return;
}
if (sender instanceof Player) {
if (!pluginRef.getCommandTools().hasPlayerDataKey(sender)) {
return;
}
McMMOPlayer mcMMOPlayer = pluginRef.getUserManager().getPlayer(sender.getName());
long cooldownMillis = 5000;
if (mcMMOPlayer.getDatabaseATS() + cooldownMillis > System.currentTimeMillis()) {
double seconds = ((mcMMOPlayer.getDatabaseATS() + cooldownMillis) - System.currentTimeMillis()) / 1000;
if (seconds < 1) {
seconds = 1;
}
sender.sendMessage(pluginRef.getLocaleManager().formatString(pluginRef.getLocaleManager().getString("Commands.Database.Cooldown"), seconds));
return;
}
if (((Player) sender).hasMetadata(MetadataConstants.DATABASE_PROCESSING_COMMAND_METAKEY)) {
sender.sendMessage(pluginRef.getLocaleManager().getString("Commands.Database.Processing"));
return;
} else {
((Player) sender).setMetadata(MetadataConstants.DATABASE_PROCESSING_COMMAND_METAKEY, new FixedMetadataValue(pluginRef, null));
}
mcMMOPlayer.actualizeDatabaseATS();
}
display(page, skill, sender);
}
private void display(int page, PrimarySkillType skill, CommandSender sender) {
boolean useBoard = (sender instanceof Player) && (pluginRef.getScoreboardSettings().isScoreboardEnabled(SidebarType.TOP_BOARD));
boolean useChat = !useBoard || pluginRef.getScoreboardSettings().isScoreboardPrinting(SidebarType.TOP_BOARD);
new LeaderboardsCommandAsyncTask(pluginRef, page, skill, sender, useBoard, useChat).runTaskAsynchronously(pluginRef);
}
private PrimarySkillType extractSkill(CommandSender sender, String skillName) {
if (pluginRef.getCommandTools().isInvalidSkill(sender, skillName)) {
return null;
}
PrimarySkillType skill = pluginRef.getSkillTools().matchSkill(skillName);
if (pluginRef.getCommandTools().isChildSkill(sender, skill)) {
return null;
}
return skill;
}
}

View File

@ -0,0 +1,126 @@
package com.gmail.nossr50.commands.player;
import com.gmail.nossr50.core.MetadataConstants;
import com.gmail.nossr50.datatypes.player.McMMOPlayer;
import com.gmail.nossr50.mcMMO;
import com.gmail.nossr50.runnables.commands.RankCommandAsyncTask;
import com.gmail.nossr50.util.scoreboards.SidebarType;
import com.google.common.collect.ImmutableList;
import org.bukkit.command.Command;
import org.bukkit.command.CommandSender;
import org.bukkit.command.TabExecutor;
import org.bukkit.entity.Player;
import org.bukkit.metadata.FixedMetadataValue;
import org.bukkit.util.StringUtil;
import java.util.ArrayList;
import java.util.List;
public class RankCommand implements TabExecutor {
private final mcMMO pluginRef;
public RankCommand(mcMMO pluginRef) {
this.pluginRef = pluginRef;
}
@Override
public boolean onCommand(CommandSender sender, Command command, String label, String[] args) {
switch (args.length) {
case 0:
if (pluginRef.getCommandTools().noConsoleUsage(sender)) {
return true;
}
if (!pluginRef.getPermissionTools().mcrank(sender)) {
sender.sendMessage(command.getPermissionMessage());
return true;
}
if (!pluginRef.getCommandTools().hasPlayerDataKey(sender)) {
return true;
}
display(sender, sender.getName());
return true;
case 1:
if (!pluginRef.getPermissionTools().mcrankOthers(sender)) {
sender.sendMessage(command.getPermissionMessage());
return true;
}
if (!pluginRef.getCommandTools().hasPlayerDataKey(sender)) {
return true;
}
String playerName = pluginRef.getCommandTools().getMatchedPlayerName(args[0]);
McMMOPlayer mcMMOPlayer = pluginRef.getUserManager().getOfflinePlayer(playerName);
if (mcMMOPlayer != null) {
Player player = mcMMOPlayer.getPlayer();
playerName = player.getName();
if (pluginRef.getCommandTools().tooFar(sender, player, pluginRef.getPermissionTools().mcrankFar(sender))) {
return true;
}
}
display(sender, playerName);
return true;
default:
return false;
}
}
@Override
public List<String> onTabComplete(CommandSender sender, Command command, String alias, String[] args) {
switch (args.length) {
case 1:
List<String> playerNames = pluginRef.getCommandTools().getOnlinePlayerNames(sender);
return StringUtil.copyPartialMatches(args[0], playerNames, new ArrayList<>(playerNames.size()));
default:
return ImmutableList.of();
}
}
private void display(CommandSender sender, String playerName) {
if (sender instanceof Player) {
McMMOPlayer mcMMOPlayer = pluginRef.getUserManager().getPlayer(sender.getName());
if (mcMMOPlayer == null) {
sender.sendMessage(pluginRef.getLocaleManager().getString("Profile.PendingLoad"));
return;
}
long cooldownMillis = 5000;
if (mcMMOPlayer.getDatabaseATS() + cooldownMillis > System.currentTimeMillis()) {
sender.sendMessage(pluginRef.getLocaleManager().getString("Commands.Database.CooldownMS", getCDSeconds(mcMMOPlayer, cooldownMillis)));
return;
}
if (((Player) sender).hasMetadata(MetadataConstants.DATABASE_PROCESSING_COMMAND_METAKEY)) {
sender.sendMessage(pluginRef.getLocaleManager().getString("Commands.Database.Processing"));
return;
} else {
((Player) sender).setMetadata(MetadataConstants.DATABASE_PROCESSING_COMMAND_METAKEY, new FixedMetadataValue(pluginRef, null));
}
mcMMOPlayer.actualizeDatabaseATS();
}
boolean useBoard = pluginRef.getScoreboardSettings().getScoreboardsEnabled() && (sender instanceof Player)
&& (pluginRef.getScoreboardSettings().isScoreboardEnabled(SidebarType.RANK_BOARD));
boolean useChat = !useBoard || pluginRef.getScoreboardSettings().isScoreboardPrinting(SidebarType.RANK_BOARD);
new RankCommandAsyncTask(pluginRef, playerName, sender, useBoard, useChat).runTaskAsynchronously(pluginRef);
}
private long getCDSeconds(McMMOPlayer mcMMOPlayer, long cooldownMillis) {
return ((mcMMOPlayer.getDatabaseATS() + cooldownMillis) - System.currentTimeMillis());
}
}

View File

@ -0,0 +1,74 @@
package com.gmail.nossr50.commands.player;
import com.gmail.nossr50.mcMMO;
import com.gmail.nossr50.util.scoreboards.SidebarType;
import com.google.common.collect.ImmutableList;
import org.bukkit.command.Command;
import org.bukkit.command.CommandSender;
import org.bukkit.command.TabExecutor;
import org.bukkit.entity.Player;
import java.util.List;
public class SkillStatsCommand implements TabExecutor {
private final mcMMO pluginRef;
public SkillStatsCommand(mcMMO pluginRef) {
this.pluginRef = pluginRef;
}
@Override
public boolean onCommand(CommandSender sender, Command command, String label, String[] args) {
if (pluginRef.getCommandTools().noConsoleUsage(sender)) {
return true;
}
if (!pluginRef.getCommandTools().hasPlayerDataKey(sender)) {
return true;
}
switch (args.length) {
case 0:
if (pluginRef.getUserManager().getPlayer((Player) sender) == null) {
sender.sendMessage(pluginRef.getLocaleManager().getString("Profile.PendingLoad"));
return true;
}
Player player = (Player) sender;
if (pluginRef.getScoreboardSettings().isScoreboardEnabled(SidebarType.STATS_BOARD) && pluginRef.getScoreboardSettings().getScoreboardsEnabled()) {
pluginRef.getScoreboardManager().enablePlayerStatsScoreboard(player);
if (!pluginRef.getScoreboardSettings().isScoreboardPrinting(SidebarType.STATS_BOARD)) {
return true;
}
}
player.sendMessage(pluginRef.getLocaleManager().getString("Stats.Own.Stats"));
player.sendMessage(pluginRef.getLocaleManager().getString("mcMMO.NoSkillNote"));
pluginRef.getCommandTools().printGatheringSkills(player);
pluginRef.getCommandTools().printCombatSkills(player);
pluginRef.getCommandTools().printMiscSkills(player);
int powerLevelCap = pluginRef.getPlayerLevelingSettings().getConfigSectionLevelCaps().getPowerLevelSettings().getLevelCap();
if (pluginRef.getPlayerLevelingSettings().getConfigSectionLevelCaps().getPowerLevelSettings().isLevelCapEnabled()) {
player.sendMessage(pluginRef.getLocaleManager().getString("Commands.PowerLevel.Capped", pluginRef.getUserManager().getPlayer(player).getPowerLevel(), powerLevelCap));
} else {
player.sendMessage(pluginRef.getLocaleManager().getString("Commands.PowerLevel", pluginRef.getUserManager().getPlayer(player).getPowerLevel()));
}
return true;
default:
return false;
}
}
@Override
public List<String> onTabComplete(CommandSender sender, Command command, String alias, String[] args) {
return ImmutableList.of();
}
}

View File

@ -0,0 +1,32 @@
package com.gmail.nossr50.commands.server;
import com.gmail.nossr50.mcMMO;
import org.bukkit.Bukkit;
import org.bukkit.command.Command;
import org.bukkit.command.CommandExecutor;
import org.bukkit.command.CommandSender;
import org.bukkit.entity.Player;
import org.jetbrains.annotations.NotNull;
public class ReloadPluginCommand implements CommandExecutor {
private final mcMMO pluginRef;
public ReloadPluginCommand(mcMMO plugin) {
this.pluginRef = plugin;
}
@Override
public boolean onCommand(@NotNull CommandSender sender, @NotNull Command command, @NotNull String label, @NotNull String[] args) {
if (sender instanceof Player) {
if (!pluginRef.getPermissionTools().reload(sender))
return false;
}
Bukkit.broadcastMessage(pluginRef.getLocaleManager().getString("Commands.Reload.Start"));
pluginRef.reload();
Bukkit.broadcastMessage(pluginRef.getLocaleManager().getString("Commands.Reload.Finished"));
return true;
}
}

View File

@ -0,0 +1,95 @@
package com.gmail.nossr50.commands.skills;
import com.gmail.nossr50.datatypes.skills.PrimarySkillType;
import com.gmail.nossr50.datatypes.skills.SubSkillType;
import com.gmail.nossr50.datatypes.skills.subskills.AbstractSubSkill;
import com.gmail.nossr50.listeners.InteractionManager;
import com.gmail.nossr50.mcMMO;
import com.gmail.nossr50.util.random.RandomChanceSkill;
import net.md_5.bungee.api.chat.TextComponent;
import org.bukkit.entity.Player;
import java.util.ArrayList;
import java.util.List;
public class AcrobaticsCommand extends SkillCommand {
private String dodgeChance;
private String dodgeChanceLucky;
private boolean canDodge;
private boolean canRoll;
public AcrobaticsCommand(mcMMO pluginRef) {
super(PrimarySkillType.ACROBATICS, pluginRef);
}
@Override
protected void dataCalculations(Player player, double skillValue) {
// ACROBATICS_DODGE
if (canDodge) {
String[] dodgeStrings = getAbilityDisplayValues(player, SubSkillType.ACROBATICS_DODGE);
dodgeChance = dodgeStrings[0];
dodgeChanceLucky = dodgeStrings[1];
}
}
@Override
protected void permissionsCheck(Player player) {
canDodge = canUseSubSkill(player, SubSkillType.ACROBATICS_DODGE);
canRoll = canUseSubSkill(player, SubSkillType.ACROBATICS_ROLL);
}
@Override
protected List<String> statsDisplay(Player player, double skillValue, boolean hasEndurance, boolean isLucky) {
List<String> messages = new ArrayList<>();
if (canDodge) {
messages.add(getStatMessage(SubSkillType.ACROBATICS_DODGE, dodgeChance)
+ (isLucky ? pluginRef.getLocaleManager().getString("Perks.Lucky.Bonus", dodgeChanceLucky) : ""));
}
if (canRoll) {
AbstractSubSkill abstractSubSkill = InteractionManager.getAbstractByName("Roll");
if (abstractSubSkill != null) {
double rollChance, graceChance;
//Chance to roll at half
RandomChanceSkill roll_rcs = new RandomChanceSkill(pluginRef, player, SubSkillType.ACROBATICS_ROLL);
//Chance to graceful roll
RandomChanceSkill grace_rcs = new RandomChanceSkill(pluginRef, player, SubSkillType.ACROBATICS_ROLL);
grace_rcs.setSkillLevel(grace_rcs.getSkillLevel() * 2); //Double Odds
//Chance Stat Calculations
rollChance = pluginRef.getRandomChanceTools().getRandomChanceExecutionChance(roll_rcs);
graceChance = pluginRef.getRandomChanceTools().getRandomChanceExecutionChance(grace_rcs);
//damageThreshold = AdvancedConfig.getInstance().getRollDamageThreshold();
String[] rollStrings = getAbilityDisplayValues(player, SubSkillType.ACROBATICS_ROLL);
//Format
double rollChanceLucky = rollChance * 1.333D;
double graceChanceLucky = graceChance * 1.333D;
messages.add(getStatMessage(SubSkillType.ACROBATICS_ROLL, rollStrings[0])
+ (isLucky ? pluginRef.getLocaleManager().getString("Perks.Lucky.Bonus", rollStrings[1]) : ""));
/*messages.add(getStatMessage(true, false, SubSkillType.ACROBATICS_ROLL, String.valueOf(graceChance))
+ (isLucky ? pluginRef.getLocaleManager().getString("Perks.Lucky.Bonus", String.valueOf(graceChanceLucky)) : ""));*/
}
}
return messages;
}
@Override
protected List<TextComponent> getTextComponents(Player player) {
List<TextComponent> textComponents = new ArrayList<>();
pluginRef.getTextComponentFactory().getSubSkillTextComponents(player, textComponents, PrimarySkillType.ACROBATICS);
return textComponents;
}
}

View File

@ -0,0 +1,96 @@
//package com.gmail.nossr50.commands.skills;
//
//import com.gmail.nossr50.datatypes.skills.PrimarySkillType;
//import com.gmail.nossr50.util.TextComponentFactory;
//import net.md_5.bungee.api.chat.TextComponent;
//import org.bukkit.entity.Player;
//
//import java.util.ArrayList;
//import java.util.List;
//
//public class AlchemyCommand extends SkillCommand {
//// private String brewSpeed;
//// private String brewSpeedLucky;
////
//// private int tier;
//// private int ingredientCount;
//// private String ingredientList;
////
//// private boolean canCatalysis;
//// private boolean canConcoctions;
//
// public AlchemyCommand() {
// super(PrimarySkillType.ALCHEMY);
// }
//
//// protected String[] calculateAbilityDisplayValues(Player player) {
//// //TODO: Needed?
//// if (pluginRef.getUserManager().getPlayer(player) == null) {
//// player.sendMessage(pluginRef.getLocaleManager().getString("Profile.PendingLoad"));
//// return new String[]{"DATA NOT LOADED", "DATA NOT LOADED"};
//// }
////
//// AlchemyManager alchemyManager = pluginRef.getUserManager().getPlayer(player).getAlchemyManager();
//// String[] displayValues = new String[2];
////
//// boolean isLucky = Permissions.lucky(player, PrimarySkillType.ALCHEMY);
////
//// displayValues[0] = decimal.format(alchemyManager.calculateBrewSpeed(false)) + "x";
//// displayValues[1] = isLucky ? decimal.format(alchemyManager.calculateBrewSpeed(true)) + "x" : null;
////
//// return displayValues;
//// }
//
// @Override
// protected void dataCalculations(Player player, double skillValue) {
// // ALCHEMY_CATALYSIS
//// if (canCatalysis) {
//// String[] catalysisStrings = calculateAbilityDisplayValues(player);
//// brewSpeed = catalysisStrings[0];
//// brewSpeedLucky = catalysisStrings[1];
//// }
////
//// // ALCHEMY_CONCOCTIONS
//// if (canConcoctions) {
//// AlchemyManager alchemyManager = pluginRef.getUserManager().getPlayer(player).getAlchemyManager();
//// tier = alchemyManager.getTier();
//// ingredientCount = alchemyManager.getIngredients().size();
//// ingredientList = alchemyManager.getIngredientList();
//// }
// }
//
// @Override
// protected void permissionsCheck(Player player) {
//// canCatalysis = canUseSubskill(player, SubSkillType.ALCHEMY_CATALYSIS);
//// canConcoctions = canUseSubskill(player, SubSkillType.ALCHEMY_CONCOCTIONS);
// }
//
// @Override
// protected List<String> statsDisplay(Player player, double skillValue, boolean hasEndurance, boolean isLucky) {
// List<String> messages = new ArrayList<>();
//
//// if (canCatalysis) {
//// messages.add(getStatMessage(SubSkillType.ALCHEMY_CATALYSIS, brewSpeed)
//// + (isLucky ? pluginRef.getLocaleManager().getString("Perks.Lucky.Bonus", brewSpeedLucky) : ""));
//// }
////
//// if (canConcoctions) {
//// messages.add(getStatMessage(false, true, SubSkillType.ALCHEMY_CONCOCTIONS, String.valueOf(tier), String.valueOf(RankUtils.getHighestRank(SubSkillType.ALCHEMY_CONCOCTIONS))));
//// messages.add(getStatMessage(true, true, SubSkillType.ALCHEMY_CONCOCTIONS, String.valueOf(ingredientCount), ingredientList));
////
//// //messages.add(pluginRef.getLocaleManager().getString("Alchemy.Concoctions.Rank", tier, RankUtils.getHighestRank(SubSkillType.ALCHEMY_CONCOCTIONS)));
//// //messages.add(pluginRef.getLocaleManager().getString("Alchemy.Concoctions.Ingredients", ingredientCount, ingredientList));
//// }
//
// return messages;
// }
//
// @Override
// protected List<TextComponent> getTextComponents(Player player) {
// List<TextComponent> textComponents = new ArrayList<>();
//
// pluginRef.getTextComponentFactory().getSubSkillTextComponents(player, textComponents, PrimarySkillType.ALCHEMY);
//
// return textComponents;
// }
//}

View File

@ -0,0 +1,90 @@
package com.gmail.nossr50.commands.skills;
import com.gmail.nossr50.datatypes.skills.PrimarySkillType;
import com.gmail.nossr50.datatypes.skills.SubSkillType;
import com.gmail.nossr50.mcMMO;
import net.md_5.bungee.api.chat.TextComponent;
import org.bukkit.entity.Player;
import java.util.ArrayList;
import java.util.List;
public class ArcheryCommand extends SkillCommand {
private String skillShotBonus;
private String dazeChance;
private String dazeChanceLucky;
private String retrieveChance;
private String retrieveChanceLucky;
private boolean canSkillShot;
private boolean canDaze;
private boolean canRetrieve;
public ArcheryCommand(mcMMO pluginRef) {
super(PrimarySkillType.ARCHERY, pluginRef);
}
@Override
protected void dataCalculations(Player player, double skillValue) {
// ARCHERY_ARROW_RETRIEVAL
if (canRetrieve) {
String[] retrieveStrings = getAbilityDisplayValues(player, SubSkillType.ARCHERY_ARROW_RETRIEVAL);
retrieveChance = retrieveStrings[0];
retrieveChanceLucky = retrieveStrings[1];
}
// ARCHERY_DAZE
if (canDaze) {
String[] dazeStrings = getAbilityDisplayValues(player, SubSkillType.ARCHERY_DAZE);
dazeChance = dazeStrings[0];
dazeChanceLucky = dazeStrings[1];
}
// SKILL SHOT
if (canSkillShot) {
skillShotBonus = percent.format(pluginRef.getDynamicSettingsManager().getSkillBehaviourManager().getArcheryBehaviour().getSkillShotDamageBonusPercent(player));
}
}
@Override
protected void permissionsCheck(Player player) {
canSkillShot = canUseSubSkill(player, SubSkillType.ARCHERY_SKILL_SHOT);
canDaze = canUseSubSkill(player, SubSkillType.ARCHERY_DAZE);
canRetrieve = canUseSubSkill(player, SubSkillType.ARCHERY_ARROW_RETRIEVAL);
}
@Override
protected List<String> statsDisplay(Player player, double skillValue, boolean hasEndurance, boolean isLucky) {
List<String> messages = new ArrayList<>();
if (canRetrieve) {
messages.add(getStatMessage(SubSkillType.ARCHERY_ARROW_RETRIEVAL, retrieveChance)
+ (isLucky ? pluginRef.getLocaleManager().getString("Perks.Lucky.Bonus", retrieveChanceLucky) : ""));
}
if (canDaze) {
messages.add(getStatMessage(SubSkillType.ARCHERY_DAZE, dazeChance)
+ (isLucky ? pluginRef.getLocaleManager().getString("Perks.Lucky.Bonus", dazeChanceLucky) : ""));
}
if (canSkillShot) {
messages.add(getStatMessage(SubSkillType.ARCHERY_SKILL_SHOT, skillShotBonus));
}
if (canUseSubSkill(player, SubSkillType.ARCHERY_ARCHERY_LIMIT_BREAK)) {
messages.add(getStatMessage(SubSkillType.ARCHERY_ARCHERY_LIMIT_BREAK,
String.valueOf(pluginRef.getCombatTools().getLimitBreakDamageAgainstQuality(player, SubSkillType.ARCHERY_ARCHERY_LIMIT_BREAK, 1000))));
}
return messages;
}
@Override
protected List<TextComponent> getTextComponents(Player player) {
List<TextComponent> textComponents = new ArrayList<>();
pluginRef.getTextComponentFactory().getSubSkillTextComponents(player, textComponents, PrimarySkillType.ARCHERY);
return textComponents;
}
}

View File

@ -0,0 +1,108 @@
package com.gmail.nossr50.commands.skills;
import com.gmail.nossr50.datatypes.skills.PrimarySkillType;
import com.gmail.nossr50.datatypes.skills.SubSkillType;
import com.gmail.nossr50.mcMMO;
import net.md_5.bungee.api.chat.TextComponent;
import org.bukkit.entity.Player;
import java.util.ArrayList;
import java.util.List;
public class AxesCommand extends SkillCommand {
private String critChance;
private String critChanceLucky;
private double axeMasteryDamage;
private double impactDamage;
private String skullSplitterLength;
private String skullSplitterLengthEndurance;
private boolean canSkullSplitter;
private boolean canCritical;
private boolean canAxeMastery;
private boolean canImpact;
private boolean canGreaterImpact;
public AxesCommand(mcMMO pluginRef) {
super(PrimarySkillType.AXES, pluginRef);
}
@Override
protected void dataCalculations(Player player, double skillValue) {
// ARMOR IMPACT
if (canImpact) {
impactDamage = pluginRef.getUserManager().getPlayer(player).getAxesManager().getImpactDurabilityDamage();
}
// AXE MASTERY
if (canAxeMastery) {
axeMasteryDamage = pluginRef.getDynamicSettingsManager().getSkillBehaviourManager().getAxesBehaviour().getAxeMasteryBonusDamage(player);
}
// CRITICAL HIT
if (canCritical) {
String[] criticalHitStrings = getAbilityDisplayValues(player, SubSkillType.AXES_CRITICAL_STRIKES);
critChance = criticalHitStrings[0];
critChanceLucky = criticalHitStrings[1];
}
// SKULL SPLITTER
if (canSkullSplitter) {
String[] skullSplitterStrings = formatLengthDisplayValues(player, skillValue);
skullSplitterLength = skullSplitterStrings[0];
skullSplitterLengthEndurance = skullSplitterStrings[1];
}
}
@Override
protected void permissionsCheck(Player player) {
canSkullSplitter = pluginRef.getPermissionTools().skullSplitter(player) && pluginRef.getRankTools().hasUnlockedSubskill(player, SubSkillType.AXES_SKULL_SPLITTER);
canCritical = canUseSubSkill(player, SubSkillType.AXES_CRITICAL_STRIKES);
canAxeMastery = canUseSubSkill(player, SubSkillType.AXES_AXE_MASTERY);
canImpact = canUseSubSkill(player, SubSkillType.AXES_ARMOR_IMPACT);
canGreaterImpact = canUseSubSkill(player, SubSkillType.AXES_GREATER_IMPACT);
}
@Override
protected List<String> statsDisplay(Player player, double skillValue, boolean hasEndurance, boolean isLucky) {
List<String> messages = new ArrayList<>();
if (canImpact) {
messages.add(pluginRef.getLocaleManager().getString("Ability.Generic.Template", pluginRef.getLocaleManager().getString("Axes.Ability.Bonus.2"), pluginRef.getLocaleManager().getString("Axes.Ability.Bonus.3", impactDamage)));
}
if (canAxeMastery) {
messages.add(pluginRef.getLocaleManager().getString("Ability.Generic.Template", pluginRef.getLocaleManager().getString("Axes.Ability.Bonus.0"), pluginRef.getLocaleManager().getString("Axes.Ability.Bonus.1", axeMasteryDamage)));
}
if (canCritical) {
messages.add(getStatMessage(SubSkillType.AXES_CRITICAL_STRIKES, critChance)
+ (isLucky ? pluginRef.getLocaleManager().getString("Perks.Lucky.Bonus", critChanceLucky) : ""));
}
if (canGreaterImpact) {
messages.add(pluginRef.getLocaleManager().getString("Ability.Generic.Template", pluginRef.getLocaleManager().getString("Axes.Ability.Bonus.4"), pluginRef.getLocaleManager().getString("Axes.Ability.Bonus.5", pluginRef.getConfigManager().getConfigAxes().getGreaterImpactBonusDamage())));
}
if (canSkullSplitter) {
messages.add(getStatMessage(SubSkillType.AXES_SKULL_SPLITTER, skullSplitterLength)
+ (hasEndurance ? pluginRef.getLocaleManager().getString("Perks.ActivationTime.Bonus", skullSplitterLengthEndurance) : ""));
}
if (canUseSubSkill(player, SubSkillType.AXES_AXES_LIMIT_BREAK)) {
messages.add(getStatMessage(SubSkillType.AXES_AXES_LIMIT_BREAK,
String.valueOf(pluginRef.getCombatTools().getLimitBreakDamageAgainstQuality(player, SubSkillType.AXES_AXES_LIMIT_BREAK, 1000))));
}
return messages;
}
@Override
protected List<TextComponent> getTextComponents(Player player) {
List<TextComponent> textComponents = new ArrayList<>();
pluginRef.getTextComponentFactory().getSubSkillTextComponents(player, textComponents, PrimarySkillType.AXES);
return textComponents;
}
}

View File

@ -0,0 +1,72 @@
package com.gmail.nossr50.commands.skills;
import com.gmail.nossr50.datatypes.skills.PrimarySkillType;
import com.gmail.nossr50.datatypes.skills.SubSkillType;
import com.gmail.nossr50.mcMMO;
import com.gmail.nossr50.skills.excavation.ExcavationManager;
import net.md_5.bungee.api.chat.TextComponent;
import org.bukkit.entity.Player;
import java.util.ArrayList;
import java.util.List;
public class ExcavationCommand extends SkillCommand {
private String gigaDrillBreakerLength;
private String gigaDrillBreakerLengthEndurance;
private boolean canGigaDrill;
private boolean canTreasureHunt;
public ExcavationCommand(mcMMO pluginRef) {
super(PrimarySkillType.EXCAVATION, pluginRef);
}
@Override
protected void dataCalculations(Player player, double skillValue) {
// GIGA DRILL BREAKER
if (canGigaDrill) {
String[] gigaDrillStrings = formatLengthDisplayValues(player, skillValue);
gigaDrillBreakerLength = gigaDrillStrings[0];
gigaDrillBreakerLengthEndurance = gigaDrillStrings[1];
}
}
@Override
protected void permissionsCheck(Player player) {
canGigaDrill = pluginRef.getPermissionTools().gigaDrillBreaker(player) && pluginRef.getRankTools().hasUnlockedSubskill(player, SubSkillType.EXCAVATION_GIGA_DRILL_BREAKER);
canTreasureHunt = canUseSubSkill(player, SubSkillType.EXCAVATION_ARCHAEOLOGY);
}
@Override
protected List<String> statsDisplay(Player player, double skillValue, boolean hasEndurance, boolean isLucky) {
List<String> messages = new ArrayList<>();
ExcavationManager excavationManager = pluginRef.getUserManager().getPlayer(player).getExcavationManager();
if (canGigaDrill) {
messages.add(getStatMessage(SubSkillType.EXCAVATION_GIGA_DRILL_BREAKER, gigaDrillBreakerLength)
+ (hasEndurance ? pluginRef.getLocaleManager().getString("Perks.ActivationTime.Bonus", gigaDrillBreakerLengthEndurance) : ""));
//messages.add(pluginRef.getLocaleManager().getString("Excavation.Effect.Length", gigaDrillBreakerLength) + (hasEndurance ? pluginRef.getLocaleManager().getString("Perks.ActivationTime.Bonus", gigaDrillBreakerLengthEndurance) : ""));
}
if(canUseSubSkill(player, SubSkillType.EXCAVATION_ARCHAEOLOGY)) {
messages.add(getStatMessage(false, false, SubSkillType.EXCAVATION_ARCHAEOLOGY,
percent.format(excavationManager.getArchaelogyExperienceOrbChance() / 100.0D)));
messages.add(getStatMessage(true, false, SubSkillType.EXCAVATION_ARCHAEOLOGY,
String.valueOf(excavationManager.getExperienceOrbsReward())));
}
return messages;
}
@Override
protected List<TextComponent> getTextComponents(Player player) {
List<TextComponent> textComponents = new ArrayList<>();
pluginRef.getTextComponentFactory().getSubSkillTextComponents(player, textComponents, PrimarySkillType.EXCAVATION);
return textComponents;
}
}

View File

@ -0,0 +1,177 @@
package com.gmail.nossr50.commands.skills;
import com.gmail.nossr50.datatypes.skills.PrimarySkillType;
import com.gmail.nossr50.datatypes.skills.SubSkillType;
import com.gmail.nossr50.mcMMO;
import com.gmail.nossr50.skills.fishing.FishingManager;
import net.md_5.bungee.api.chat.TextComponent;
import org.bukkit.Location;
import org.bukkit.entity.Player;
import java.util.ArrayList;
import java.util.List;
public class FishingCommand extends SkillCommand {
private int lootTier;
private String shakeChance;
private String shakeChanceLucky;
private int fishermansDietRank;
private String biteChance;
private String innerPeaceMult;
private String commonTreasure;
private String uncommonTreasure;
private String rareTreasure;
private String epicTreasure;
private String legendaryTreasure;
private String recordTreasure;
private String magicChance;
private boolean canTreasureHunt;
private boolean canMagicHunt;
private boolean canShake;
private boolean canFishermansDiet;
private boolean canMasterAngler;
private boolean canIceFish;
private boolean canInnerPeace;
public FishingCommand(mcMMO pluginRef) {
super(PrimarySkillType.FISHING, pluginRef);
}
@Override
protected void dataCalculations(Player player, double skillValue) {
FishingManager fishingManager = pluginRef.getUserManager().getPlayer(player).getFishingManager();
// TREASURE HUNTER
if (canTreasureHunt) {
lootTier = fishingManager.getLootTier();
// Item drop rates
// commonTreasure = percent.format(FishingTreasureConfig.getInstance().getItemDropRate(lootTier, Rarity.COMMON) / 100.0);
// uncommonTreasure = percent.format(FishingTreasureConfig.getInstance().getItemDropRate(lootTier, Rarity.UNCOMMON) / 100.0);
// rareTreasure = percent.format(FishingTreasureConfig.getInstance().getItemDropRate(lootTier, Rarity.RARE) / 100.0);
// epicTreasure = percent.format(FishingTreasureConfig.getInstance().getItemDropRate(lootTier, Rarity.EPIC) / 100.0);
// legendaryTreasure = percent.format(FishingTreasureConfig.getInstance().getItemDropRate(lootTier, Rarity.LEGENDARY) / 100.0);
// recordTreasure = percent.format(FishingTreasureConfig.getInstance().getItemDropRate(lootTier, Rarity.RECORD) / 100.0);
//
// // Magic hunter drop rates
// double totalEnchantChance = 0;
//
// for (Rarity rarity : Rarity.values()) {
// if (rarity != Rarity.RECORD) {
// totalEnchantChance += FishingTreasureConfig.getInstance().getEnchantmentDropRate(lootTier, rarity);
// }
// }
// if (totalEnchantChance >= 1)
// magicChance = percent.format(totalEnchantChance / 100.0);
// else
// magicChance = percent.format(0);
}
// FISHING_SHAKE
// if (canShake) {
// String[] shakeStrings = pluginRef.getRandomChanceTools().calculateAbilityDisplayValuesStatic(player, PrimarySkillType.FISHING, fishingManager.getShakeChance());
// shakeChance = shakeStrings[0];
// shakeChanceLucky = shakeStrings[1];
// }
// FISHERMAN'S DIET
if (canFishermansDiet) {
fishermansDietRank = pluginRef.getRankTools().getRank(player, SubSkillType.FISHING_FISHERMANS_DIET);
}
// MASTER ANGLER
if (canMasterAngler) {
double rawBiteChance = 1.0 / (player.getWorld().hasStorm() ? 300 : 500);
Location location = fishingManager.getHookLocation();
if (location == null) {
location = player.getLocation();
}
// if (Fishing.getInstance().getMasterAnglerBiomes().contains(location.getBlock().getBiome())) {
// rawBiteChance = rawBiteChance * AdvancedConfig.getInstance().getMasterAnglerBiomeModifier();
// }
// if (player.isInsideVehicle() && player.getVehicle().getType() == EntityType.BOAT) {
// rawBiteChance = rawBiteChance * AdvancedConfig.getInstance().getMasterAnglerBoatModifier();
// }
double luckyModifier = pluginRef.getPermissionTools().lucky(player, PrimarySkillType.FISHING) ? 1.333D : 1.0D;
biteChance = percent.format((rawBiteChance * 100.0D) * luckyModifier);
}
if (canInnerPeace) {
innerPeaceMult = String.valueOf(fishingManager.getInnerPeaceMultiplier());
}
}
@Override
protected void permissionsCheck(Player player) {
canTreasureHunt = canUseSubSkill(player, SubSkillType.FISHING_TREASURE_HUNTER);
canMagicHunt = canUseSubSkill(player, SubSkillType.FISHING_MAGIC_HUNTER) && canUseSubSkill(player, SubSkillType.FISHING_TREASURE_HUNTER);
canShake = canUseSubSkill(player, SubSkillType.FISHING_SHAKE);
canFishermansDiet = canUseSubSkill(player, SubSkillType.FISHING_FISHERMANS_DIET);
canMasterAngler = canUseSubSkill(player, SubSkillType.FISHING_MASTER_ANGLER);
canIceFish = canUseSubSkill(player, SubSkillType.FISHING_ICE_FISHING);
canInnerPeace = canUseSubSkill(player, SubSkillType.FISHING_INNER_PEACE);
}
@Override
protected List<String> statsDisplay(Player player, double skillValue, boolean hasEndurance, boolean isLucky) {
List<String> messages = new ArrayList<>();
if (canFishermansDiet) {
messages.add(getStatMessage(false, true, SubSkillType.FISHING_FISHERMANS_DIET, String.valueOf(fishermansDietRank)));
}
// if (canIceFish) {
// messages.add(getStatMessage(SubSkillType.FISHING_ICE_FISHING, SubSkillType.FISHING_ICE_FISHING.getLocaleStatDescription()));
// }
if (canMagicHunt) {
messages.add(getStatMessage(SubSkillType.FISHING_MAGIC_HUNTER, magicChance));
}
if (canMasterAngler) {
//TODO: Update this with more details
messages.add(getStatMessage(false, true, SubSkillType.FISHING_MASTER_ANGLER, biteChance));
}
if (canShake) {
messages.add(getStatMessage(SubSkillType.FISHING_SHAKE, shakeChance)
+ (isLucky ? pluginRef.getLocaleManager().getString("Perks.Lucky.Bonus", shakeChanceLucky) : ""));
}
if (canTreasureHunt) {
messages.add(getStatMessage(false, true, SubSkillType.FISHING_TREASURE_HUNTER, String.valueOf(lootTier), String.valueOf(pluginRef.getRankTools().getHighestRank(SubSkillType.FISHING_TREASURE_HUNTER))));
messages.add(getStatMessage(true, true, SubSkillType.FISHING_TREASURE_HUNTER,
String.valueOf(commonTreasure),
String.valueOf(uncommonTreasure),
String.valueOf(rareTreasure),
String.valueOf(epicTreasure),
String.valueOf(legendaryTreasure),
String.valueOf(recordTreasure)));
}
if (canInnerPeace) {
messages.add(getStatMessage(SubSkillType.FISHING_INNER_PEACE, innerPeaceMult));
}
return messages;
}
@Override
protected List<TextComponent> getTextComponents(Player player) {
List<TextComponent> textComponents = new ArrayList<>();
pluginRef.getTextComponentFactory().getSubSkillTextComponents(player, textComponents, PrimarySkillType.FISHING);
return textComponents;
}
}

View File

@ -0,0 +1,147 @@
package com.gmail.nossr50.commands.skills;
import com.gmail.nossr50.datatypes.skills.PrimarySkillType;
import com.gmail.nossr50.datatypes.skills.SubSkillType;
import com.gmail.nossr50.mcMMO;
import net.md_5.bungee.api.chat.TextComponent;
import org.bukkit.Material;
import org.bukkit.entity.Player;
import java.util.ArrayList;
import java.util.List;
public class HerbalismCommand extends SkillCommand {
private String greenTerraLength;
private String greenTerraLengthEndurance;
private String greenThumbChance;
private String greenThumbChanceLucky;
private int greenThumbStage;
private int farmersDietRank;
private String doubleDropChance;
private String doubleDropChanceLucky;
private String hylianLuckChance;
private String hylianLuckChanceLucky;
private String shroomThumbChance;
private String shroomThumbChanceLucky;
private boolean hasHylianLuck;
private boolean canGreenTerra;
private boolean canGreenThumbPlants;
private boolean canGreenThumbBlocks;
private boolean canFarmersDiet;
private boolean canDoubleDrop;
private boolean canShroomThumb;
public HerbalismCommand(mcMMO pluginRef) {
super(PrimarySkillType.HERBALISM, pluginRef);
}
@Override
protected void dataCalculations(Player player, double skillValue) {
// DOUBLE DROPS
if (canDoubleDrop) {
String[] doubleDropStrings = getAbilityDisplayValues(player, SubSkillType.HERBALISM_DOUBLE_DROPS);
doubleDropChance = doubleDropStrings[0];
doubleDropChanceLucky = doubleDropStrings[1];
}
// FARMERS DIET
if (canFarmersDiet) {
farmersDietRank = pluginRef.getRankTools().getRank(player, SubSkillType.HERBALISM_FARMERS_DIET);
}
// GREEN TERRA
if (canGreenTerra) {
String[] greenTerraStrings = formatLengthDisplayValues(player, skillValue);
greenTerraLength = greenTerraStrings[0];
greenTerraLengthEndurance = greenTerraStrings[1];
}
// GREEN THUMB
if (canGreenThumbBlocks || canGreenThumbPlants) {
greenThumbStage = pluginRef.getRankTools().getRank(player, SubSkillType.HERBALISM_GREEN_THUMB);
String[] greenThumbStrings = getAbilityDisplayValues(player, SubSkillType.HERBALISM_GREEN_THUMB);
greenThumbChance = greenThumbStrings[0];
greenThumbChanceLucky = greenThumbStrings[1];
}
// HYLIAN LUCK
if (hasHylianLuck) {
String[] hylianLuckStrings = getAbilityDisplayValues(player, SubSkillType.HERBALISM_HYLIAN_LUCK);
hylianLuckChance = hylianLuckStrings[0];
hylianLuckChanceLucky = hylianLuckStrings[1];
}
// SHROOM THUMB
if (canShroomThumb) {
String[] shroomThumbStrings = getAbilityDisplayValues(player, SubSkillType.HERBALISM_SHROOM_THUMB);
shroomThumbChance = shroomThumbStrings[0];
shroomThumbChanceLucky = shroomThumbStrings[1];
}
}
@Override
protected void permissionsCheck(Player player) {
hasHylianLuck = canUseSubSkill(player, SubSkillType.HERBALISM_HYLIAN_LUCK);
canGreenTerra = pluginRef.getPermissionTools().greenTerra(player);
canGreenThumbPlants = pluginRef.getRankTools().hasUnlockedSubskill(player, SubSkillType.HERBALISM_GREEN_THUMB) && (pluginRef.getPermissionTools().greenThumbPlant(player, Material.WHEAT) || pluginRef.getPermissionTools().greenThumbPlant(player, Material.CARROT) || pluginRef.getPermissionTools().greenThumbPlant(player, Material.POTATO) || pluginRef.getPermissionTools().greenThumbPlant(player, Material.BEETROOT) || pluginRef.getPermissionTools().greenThumbPlant(player, Material.NETHER_WART) || pluginRef.getPermissionTools().greenThumbPlant(player, Material.COCOA));
canGreenThumbBlocks = pluginRef.getRankTools().hasUnlockedSubskill(player, SubSkillType.HERBALISM_GREEN_THUMB) && (pluginRef.getPermissionTools().greenThumbBlock(player, Material.DIRT) || pluginRef.getPermissionTools().greenThumbBlock(player, Material.COBBLESTONE) || pluginRef.getPermissionTools().greenThumbBlock(player, Material.COBBLESTONE_WALL) || pluginRef.getPermissionTools().greenThumbBlock(player, Material.STONE_BRICKS));
canFarmersDiet = canUseSubSkill(player, SubSkillType.HERBALISM_FARMERS_DIET);
canDoubleDrop = canUseSubSkill(player, SubSkillType.HERBALISM_DOUBLE_DROPS);
canShroomThumb = canUseSubSkill(player, SubSkillType.HERBALISM_SHROOM_THUMB);
}
@Override
protected List<String> statsDisplay(Player player, double skillValue, boolean hasEndurance, boolean isLucky) {
List<String> messages = new ArrayList<>();
if (canDoubleDrop) {
messages.add(getStatMessage(SubSkillType.HERBALISM_DOUBLE_DROPS, doubleDropChance)
+ (isLucky ? pluginRef.getLocaleManager().getString("Perks.Lucky.Bonus", doubleDropChanceLucky) : ""));
}
if (canFarmersDiet) {
messages.add(getStatMessage(false, true, SubSkillType.HERBALISM_FARMERS_DIET, String.valueOf(farmersDietRank)));
}
if (canGreenTerra) {
messages.add(getStatMessage(SubSkillType.HERBALISM_GREEN_TERRA, greenTerraLength)
+ (hasEndurance ? pluginRef.getLocaleManager().getString("Perks.ActivationTime.Bonus", greenTerraLengthEndurance) : ""));
//messages.add(pluginRef.getLocaleManager().getString("Herbalism.Ability.GTe.Length", greenTerraLength) + (hasEndurance ? pluginRef.getLocaleManager().getString("Perks.ActivationTime.Bonus", greenTerraLengthEndurance) : ""));
}
if (canGreenThumbBlocks || canGreenThumbPlants) {
messages.add(getStatMessage(SubSkillType.HERBALISM_GREEN_THUMB, greenThumbChance)
+ (isLucky ? pluginRef.getLocaleManager().getString("Perks.Lucky.Bonus", greenThumbChanceLucky) : ""));
//messages.add(pluginRef.getLocaleManager().getString("Herbalism.Ability.GTh.Chance", greenThumbChance) + (isLucky ? pluginRef.getLocaleManager().getString("Perks.Lucky.Bonus", greenThumbChanceLucky) : ""));
}
if (canGreenThumbPlants) {
messages.add(getStatMessage(true, true, SubSkillType.HERBALISM_GREEN_THUMB, String.valueOf(greenThumbStage)));
}
if (hasHylianLuck) {
messages.add(getStatMessage(SubSkillType.HERBALISM_HYLIAN_LUCK, hylianLuckChance)
+ (isLucky ? pluginRef.getLocaleManager().getString("Perks.Lucky.Bonus", hylianLuckChanceLucky) : ""));
}
if (canShroomThumb) {
messages.add(getStatMessage(SubSkillType.HERBALISM_SHROOM_THUMB, shroomThumbChance)
+ (isLucky ? pluginRef.getLocaleManager().getString("Perks.Lucky.Bonus", shroomThumbChanceLucky) : ""));
}
return messages;
}
@Override
protected List<TextComponent> getTextComponents(Player player) {
List<TextComponent> textComponents = new ArrayList<>();
pluginRef.getTextComponentFactory().getSubSkillTextComponents(player, textComponents, PrimarySkillType.HERBALISM);
return textComponents;
}
}

View File

@ -0,0 +1,116 @@
package com.gmail.nossr50.commands.skills;
import com.gmail.nossr50.datatypes.skills.PrimarySkillType;
import com.gmail.nossr50.datatypes.skills.SubSkillType;
import com.gmail.nossr50.mcMMO;
import com.gmail.nossr50.skills.mining.MiningManager;
import net.md_5.bungee.api.chat.TextComponent;
import org.bukkit.entity.Player;
import java.util.ArrayList;
import java.util.List;
public class MiningCommand extends SkillCommand {
private String doubleDropChance;
private String doubleDropChanceLucky;
private String superBreakerLength;
private String superBreakerLengthEndurance;
private int blastMiningRank;
private int bonusTNTDrops;
private double blastRadiusIncrease;
private String oreBonus;
private String debrisReduction;
private String blastDamageDecrease;
private boolean canSuperBreaker;
private boolean canDoubleDrop;
private boolean canBlast;
private boolean canBiggerBombs;
private boolean canDemoExpert;
public MiningCommand(mcMMO pluginRef) {
super(PrimarySkillType.MINING, pluginRef);
}
@Override
protected void dataCalculations(Player player, double skillValue) {
// BLAST MINING
if (canBlast || canDemoExpert || canBiggerBombs) {
MiningManager miningManager = pluginRef.getUserManager().getPlayer(player).getMiningManager();
blastMiningRank = miningManager.getBlastMiningTier();
bonusTNTDrops = miningManager.getDropMultiplier();
oreBonus = percent.format(miningManager.getOreBonus() / 30.0D); // Base received in TNT is 30%
debrisReduction = percent.format(miningManager.getDebrisReduction() / 30.0D); // Base received in TNT is 30%
blastDamageDecrease = percent.format(miningManager.getBlastDamageModifier() / 100.0D);
blastRadiusIncrease = miningManager.getBlastRadiusModifier();
}
// DOUBLE DROPS
if (canDoubleDrop) {
String[] doubleDropStrings = getAbilityDisplayValues(player, SubSkillType.MINING_DOUBLE_DROPS);
doubleDropChance = doubleDropStrings[0];
doubleDropChanceLucky = doubleDropStrings[1];
}
// SUPER BREAKER
if (canSuperBreaker) {
String[] superBreakerStrings = formatLengthDisplayValues(player, skillValue);
superBreakerLength = superBreakerStrings[0];
superBreakerLengthEndurance = superBreakerStrings[1];
}
}
@Override
protected void permissionsCheck(Player player) {
canBiggerBombs = pluginRef.getRankTools().hasUnlockedSubskill(player, SubSkillType.MINING_BIGGER_BOMBS) && pluginRef.getPermissionTools().biggerBombs(player);
canBlast = pluginRef.getRankTools().hasUnlockedSubskill(player, SubSkillType.MINING_BLAST_MINING) && pluginRef.getPermissionTools().remoteDetonation(player);
canDemoExpert = pluginRef.getRankTools().hasUnlockedSubskill(player, SubSkillType.MINING_DEMOLITIONS_EXPERTISE) && pluginRef.getPermissionTools().demolitionsExpertise(player);
canDoubleDrop = canUseSubSkill(player, SubSkillType.MINING_DOUBLE_DROPS);
canSuperBreaker = pluginRef.getRankTools().hasUnlockedSubskill(player, SubSkillType.MINING_SUPER_BREAKER) && pluginRef.getPermissionTools().superBreaker(player);
}
@Override
protected List<String> statsDisplay(Player player, double skillValue, boolean hasEndurance, boolean isLucky) {
List<String> messages = new ArrayList<>();
if (canBiggerBombs) {
messages.add(getStatMessage(true, true, SubSkillType.MINING_BLAST_MINING, String.valueOf(blastRadiusIncrease)));
//messages.add(pluginRef.getLocaleManager().getString("SuperAbility.BlastMining.Radius.Increase", blastRadiusIncrease));
}
if (canBlast) {
messages.add(getStatMessage(false, true, SubSkillType.MINING_BLAST_MINING, String.valueOf(blastMiningRank), String.valueOf(pluginRef.getRankTools().getHighestRank(SubSkillType.MINING_BLAST_MINING)), pluginRef.getLocaleManager().getString("SuperAbility.BlastMining.Effect", oreBonus, debrisReduction, bonusTNTDrops)));
//messages.add(pluginRef.getLocaleManager().getString("SuperAbility.BlastMining.Rank", blastMiningRank, RankUtils.getHighestRank(SubSkillType.MINING_BLAST_MINING), pluginRef.getLocaleManager().getString("SuperAbility.BlastMining.Effect", oreBonus, debrisReduction, bonusTNTDrops)));
}
if (canDemoExpert) {
messages.add(getStatMessage(SubSkillType.MINING_DEMOLITIONS_EXPERTISE, blastDamageDecrease));
//messages.add(pluginRef.getLocaleManager().getString("Mining.Effect.Decrease", blastDamageDecrease));
}
if (canDoubleDrop) {
messages.add(getStatMessage(SubSkillType.MINING_DOUBLE_DROPS, doubleDropChance)
+ (isLucky ? pluginRef.getLocaleManager().getString("Perks.Lucky.Bonus", doubleDropChanceLucky) : ""));
//messages.add(pluginRef.getLocaleManager().getString("Mining.Effect.DropChance", doubleDropChance) + (isLucky ? pluginRef.getLocaleManager().getString("Perks.Lucky.Bonus", doubleDropChanceLucky) : ""));
}
if (canSuperBreaker) {
messages.add(getStatMessage(SubSkillType.MINING_SUPER_BREAKER, superBreakerLength)
+ (hasEndurance ? pluginRef.getLocaleManager().getString("Perks.ActivationTime.Bonus", superBreakerLengthEndurance) : ""));
//messages.add(pluginRef.getLocaleManager().getString("Mining.Ability.Length", superBreakerLength) + (hasEndurance ? pluginRef.getLocaleManager().getString("Perks.ActivationTime.Bonus", superBreakerLengthEndurance) : ""));
}
return messages;
}
@Override
protected List<TextComponent> getTextComponents(Player player) {
List<TextComponent> textComponents = new ArrayList<>();
pluginRef.getTextComponentFactory().getSubSkillTextComponents(player, textComponents, PrimarySkillType.MINING);
return textComponents;
}
}

View File

@ -0,0 +1,97 @@
package com.gmail.nossr50.commands.skills;
import com.gmail.nossr50.datatypes.skills.SubSkillType;
import com.gmail.nossr50.datatypes.skills.subskills.AbstractSubSkill;
import com.gmail.nossr50.listeners.InteractionManager;
import com.gmail.nossr50.mcMMO;
import com.google.common.collect.ImmutableList;
import org.bukkit.command.Command;
import org.bukkit.command.CommandSender;
import org.bukkit.command.TabExecutor;
import org.bukkit.entity.Player;
import org.bukkit.util.StringUtil;
import java.util.ArrayList;
import java.util.List;
/**
* This is the command that retrieves data about skills from in-game sources
*/
public class MmoInfoCommand implements TabExecutor {
private final mcMMO pluginRef;
public MmoInfoCommand(mcMMO pluginRef) {
this.pluginRef = pluginRef;
}
@Override
public boolean onCommand(CommandSender commandSender, Command command, String s, String[] args) {
/*
* Only allow players to use this command
*/
if (commandSender instanceof Player) {
if (args.length < 1)
return false;
Player player = (Player) commandSender;
if (pluginRef.getPermissionTools().mmoinfo(player)) {
if (args == null || args[0] == null)
return false;
if (args[0].equalsIgnoreCase("???")) {
player.sendMessage(pluginRef.getLocaleManager().getString("Commands.MmoInfo.Header"));
player.sendMessage(pluginRef.getLocaleManager().getString("Commands.MmoInfo.SubSkillHeader", "???"));
player.sendMessage(pluginRef.getLocaleManager().getString("Commands.MmoInfo.DetailsHeader"));
player.sendMessage(pluginRef.getLocaleManager().getString("Commands.MmoInfo.Mystery"));
return true;
} else if (InteractionManager.getAbstractByName(args[0]) != null || pluginRef.getSkillTools().isSubSkillNameExact(args[0])) {
displayInfo(player, args[0]);
return true;
}
//Not a real skill
player.sendMessage(pluginRef.getLocaleManager().getString("Commands.MmoInfo.NoMatch"));
return true;
}
}
return false;
}
@Override
public List<String> onTabComplete(CommandSender sender, Command command, String alias, String[] args) {
switch (args.length) {
case 1:
return StringUtil.copyPartialMatches(args[0], pluginRef.getSkillTools().EXACT_SUBSKILL_NAMES, new ArrayList<>(pluginRef.getSkillTools().EXACT_SUBSKILL_NAMES.size()));
default:
return ImmutableList.of();
}
}
private void displayInfo(Player player, String subSkillName) {
//Check to see if the skill exists in the new system
AbstractSubSkill abstractSubSkill = InteractionManager.getAbstractByName(subSkillName);
if (abstractSubSkill != null) {
/* New System Skills are programmable */
abstractSubSkill.printInfo(player);
//pluginRef.getTextComponentFactory().sendPlayerUrlHeader(player);
} else {
/*
* Skill is only in the old system
*/
player.sendMessage(pluginRef.getLocaleManager().getString("Commands.MmoInfo.Header"));
player.sendMessage(pluginRef.getLocaleManager().getString("Commands.MmoInfo.SubSkillHeader", subSkillName));
player.sendMessage(pluginRef.getLocaleManager().getString("Commands.MmoInfo.DetailsHeader"));
player.sendMessage(pluginRef.getLocaleManager().getString("Commands.MmoInfo.OldSkill"));
}
for (SubSkillType subSkillType : SubSkillType.values()) {
if (subSkillType.getNiceNameNoSpaces(subSkillType).equalsIgnoreCase(subSkillName))
subSkillName = subSkillType.getWikiName(subSkillType.toString());
}
//Send Player Wiki Link
pluginRef.getTextComponentFactory().sendPlayerSubSkillWikiLink(player, subSkillName);
}
}

View File

@ -0,0 +1,123 @@
package com.gmail.nossr50.commands.skills;
import com.gmail.nossr50.datatypes.skills.PrimarySkillType;
import com.gmail.nossr50.datatypes.skills.SubSkillType;
import com.gmail.nossr50.mcMMO;
import com.gmail.nossr50.skills.repair.RepairManager;
import net.md_5.bungee.api.chat.TextComponent;
import org.bukkit.entity.Player;
import java.util.ArrayList;
import java.util.List;
public class RepairCommand extends SkillCommand {
private String repairMasteryBonus;
private String superRepairChance;
private String superRepairChanceLucky;
private boolean canSuperRepair;
private boolean canMasterRepair;
private boolean canArcaneForge;
// private boolean canRepairStone;
// private boolean canRepairIron;
// private boolean canRepairGold;
// private boolean canRepairDiamond;
// private boolean canRepairString;
// private boolean canRepairLeather;
// private boolean canRepairWood;
private boolean arcaneBypass;
// private int diamondLevel;
// private int goldLevel;
// private int ironLevel;
// private int stoneLevel;
public RepairCommand(mcMMO pluginRef) {
super(PrimarySkillType.REPAIR, pluginRef);
}
@Override
protected void dataCalculations(Player player, double skillValue) {
// We're using pickaxes here, not the best but it works
// Repairable diamondRepairable = pluginRef.getRepairableManager().getRepairable(Material.DIAMOND_PICKAXE);
// Repairable goldRepairable = pluginRef.getRepairableManager().getRepairable(Material.GOLDEN_PICKAXE);
// Repairable ironRepairable = pluginRef.getRepairableManager().getRepairable(Material.IRON_PICKAXE);
// Repairable stoneRepairable = pluginRef.getRepairableManager().getRepairable(Material.STONE_PICKAXE);
// TODO: This isn't really accurate - if they don't have pickaxes loaded it doesn't always mean the repair level is 0
// diamondLevel = (diamondRepairable == null) ? 0 : diamondRepairable.getMinimumLevel();
// goldLevel = (goldRepairable == null) ? 0 : goldRepairable.getMinimumLevel();
// ironLevel = (ironRepairable == null) ? 0 : ironRepairable.getMinimumLevel();
// stoneLevel = (stoneRepairable == null) ? 0 : stoneRepairable.getMinimumLevel();
// REPAIR MASTERY
if (canMasterRepair) {
double maxBonus = pluginRef.getDynamicSettingsManager().getSkillPropertiesManager().getMaxBonus(SubSkillType.REPAIR_REPAIR_MASTERY);
int maxBonusLevel = pluginRef.getDynamicSettingsManager().getSkillPropertiesManager().getMaxBonusLevel(SubSkillType.REPAIR_REPAIR_MASTERY);
repairMasteryBonus = percent.format(Math.min(((maxBonus / maxBonusLevel) * skillValue), maxBonus) / 100D);
}
// SUPER REPAIR
if (canSuperRepair) {
String[] superRepairStrings = getAbilityDisplayValues(player, SubSkillType.REPAIR_SUPER_REPAIR);
superRepairChance = superRepairStrings[0];
superRepairChanceLucky = superRepairStrings[1];
}
}
@Override
protected void permissionsCheck(Player player) {
canSuperRepair = canUseSubSkill(player, SubSkillType.REPAIR_SUPER_REPAIR);
canMasterRepair = canUseSubSkill(player, SubSkillType.REPAIR_REPAIR_MASTERY);
canArcaneForge = canUseSubSkill(player, SubSkillType.REPAIR_ARCANE_FORGING);
// canRepairDiamond = Permissions.repairMaterialType(player, ItemMaterialCategory.DIAMOND);
// canRepairGold = Permissions.repairMaterialType(player, ItemMaterialCategory.GOLD);
// canRepairIron = Permissions.repairMaterialType(player, ItemMaterialCategory.IRON);
// canRepairStone = Permissions.repairMaterialType(player, ItemMaterialCategory.STONE);
// canRepairString = Permissions.repairMaterialType(player, ItemMaterialCategory.STRING);
// canRepairLeather = Permissions.repairMaterialType(player, ItemMaterialCategory.LEATHER);
// canRepairWood = Permissions.repairMaterialType(player, ItemMaterialCategory.WOOD);
arcaneBypass = (pluginRef.getPermissionTools().arcaneBypass(player) || pluginRef.getPermissionTools().hasRepairEnchantBypassPerk(player));
}
@Override
protected List<String> statsDisplay(Player player, double skillValue, boolean hasEndurance, boolean isLucky) {
List<String> messages = new ArrayList<>();
if (canArcaneForge) {
RepairManager repairManager = pluginRef.getUserManager().getPlayer(player).getRepairManager();
messages.add(getStatMessage(false, true,
SubSkillType.REPAIR_ARCANE_FORGING,
String.valueOf(pluginRef.getRankTools().getRank(player, SubSkillType.REPAIR_ARCANE_FORGING)),
pluginRef.getRankTools().getHighestRankStr(SubSkillType.REPAIR_ARCANE_FORGING)));
if (pluginRef.getConfigManager().getConfigRepair().getArcaneForging().isDowngradesEnabled() || pluginRef.getConfigManager().getConfigRepair().getArcaneForging().isMayLoseEnchants()) {
messages.add(getStatMessage(true, true, SubSkillType.REPAIR_ARCANE_FORGING,
String.valueOf(arcaneBypass ? 100 : repairManager.getKeepEnchantChance()),
String.valueOf(arcaneBypass ? 0 : repairManager.getDowngradeEnchantChance()))); //Jesus those parentheses
}
}
if (canMasterRepair) {
messages.add(getStatMessage(false, true, SubSkillType.REPAIR_REPAIR_MASTERY, repairMasteryBonus));
}
if (canSuperRepair) {
messages.add(getStatMessage(SubSkillType.REPAIR_SUPER_REPAIR, superRepairChance)
+ (isLucky ? pluginRef.getLocaleManager().getString("Perks.Lucky.Bonus", superRepairChanceLucky) : ""));
}
return messages;
}
@Override
protected List<TextComponent> getTextComponents(Player player) {
List<TextComponent> textComponents = new ArrayList<>();
pluginRef.getTextComponentFactory().getSubSkillTextComponents(player, textComponents, PrimarySkillType.REPAIR);
return textComponents;
}
}

View File

@ -0,0 +1,70 @@
package com.gmail.nossr50.commands.skills;
import com.gmail.nossr50.datatypes.skills.PrimarySkillType;
import com.gmail.nossr50.datatypes.skills.SubSkillType;
import com.gmail.nossr50.mcMMO;
import com.gmail.nossr50.skills.salvage.SalvageManager;
import net.md_5.bungee.api.chat.TextComponent;
import org.bukkit.entity.Player;
import java.util.ArrayList;
import java.util.List;
public class SalvageCommand extends SkillCommand {
private boolean canScrapCollector;
private boolean canArcaneSalvage;
public SalvageCommand(mcMMO pluginRef) {
super(PrimarySkillType.SALVAGE, pluginRef);
}
@Override
protected void dataCalculations(Player player, double skillValue) {
// TODO Auto-generated method stub
}
@Override
protected void permissionsCheck(Player player) {
canScrapCollector = canUseSubSkill(player, SubSkillType.SALVAGE_SCRAP_COLLECTOR);
canArcaneSalvage = canUseSubSkill(player, SubSkillType.SALVAGE_ARCANE_SALVAGE);
}
@Override
protected List<String> statsDisplay(Player player, double skillValue, boolean hasEndurance, boolean isLucky) {
List<String> messages = new ArrayList<>();
SalvageManager salvageManager = pluginRef.getUserManager().getPlayer(player).getSalvageManager();
if (canScrapCollector) {
messages.add(getStatMessage(false, true,
SubSkillType.SALVAGE_SCRAP_COLLECTOR,
String.valueOf(pluginRef.getRankTools().getRank(player, SubSkillType.SALVAGE_SCRAP_COLLECTOR)),
pluginRef.getRankTools().getHighestRankStr(SubSkillType.SALVAGE_SCRAP_COLLECTOR)));
}
if (canArcaneSalvage) {
messages.add(getStatMessage(false, true, SubSkillType.SALVAGE_ARCANE_SALVAGE,
String.valueOf(salvageManager.getArcaneSalvageRank()),
String.valueOf(pluginRef.getRankTools().getHighestRank(SubSkillType.SALVAGE_ARCANE_SALVAGE))));
if (pluginRef.getDynamicSettingsManager().getSkillBehaviourManager().getSalvageBehaviour().isArcaneSalvageEnchantLoss()) {
messages.add(pluginRef.getLocaleManager().getString("Ability.Generic.Template", pluginRef.getLocaleManager().getString("Salvage.Arcane.ExtractFull"), percent.format(salvageManager.getExtractFullEnchantChance() / 100)));
}
if (pluginRef.getDynamicSettingsManager().getSkillBehaviourManager().getSalvageBehaviour().isArcaneSalvageDowngrades()) {
messages.add(pluginRef.getLocaleManager().getString("Ability.Generic.Template", pluginRef.getLocaleManager().getString("Salvage.Arcane.ExtractPartial"), percent.format(salvageManager.getExtractPartialEnchantChance() / 100)));
}
}
return messages;
}
@Override
protected List<TextComponent> getTextComponents(Player player) {
List<TextComponent> textComponents = new ArrayList<>();
pluginRef.getTextComponentFactory().getSubSkillTextComponents(player, textComponents, PrimarySkillType.SALVAGE);
return textComponents;
}
}

View File

@ -0,0 +1,291 @@
package com.gmail.nossr50.commands.skills;
import com.gmail.nossr50.datatypes.player.McMMOPlayer;
import com.gmail.nossr50.datatypes.skills.PrimarySkillType;
import com.gmail.nossr50.datatypes.skills.SubSkillType;
import com.gmail.nossr50.mcMMO;
import com.gmail.nossr50.skills.child.FamilyTree;
import com.gmail.nossr50.util.StringUtils;
import com.gmail.nossr50.util.skills.SkillActivationType;
import com.google.common.collect.ImmutableList;
import net.md_5.bungee.api.ChatColor;
import net.md_5.bungee.api.chat.TextComponent;
import org.bukkit.command.Command;
import org.bukkit.command.CommandExecutor;
import org.bukkit.command.CommandSender;
import org.bukkit.command.TabExecutor;
import org.bukkit.entity.Player;
import java.text.DecimalFormat;
import java.util.ArrayList;
import java.util.List;
import java.util.Set;
public abstract class SkillCommand implements TabExecutor {
protected PrimarySkillType skill;
protected DecimalFormat percent = new DecimalFormat("##0.00%");
protected DecimalFormat decimal = new DecimalFormat("##0.00");
private String skillName;
private CommandExecutor skillGuideCommand;
protected mcMMO pluginRef;
public SkillCommand(PrimarySkillType primarySkillType, mcMMO pluginRef) {
this.pluginRef = pluginRef;
this.skill = primarySkillType;
skillName = pluginRef.getSkillTools().getLocalizedSkillName(primarySkillType);
skillGuideCommand = new SkillGuideCommand(primarySkillType, pluginRef);
}
public static String[] addItemToFirstPositionOfArray(String itemToAdd, String... existingArray) {
String[] newArray = new String[existingArray.length + 1];
newArray[0] = itemToAdd;
System.arraycopy(existingArray, 0, newArray, 1, existingArray.length);
return newArray;
}
@Override
public boolean onCommand(CommandSender sender, Command command, String label, String[] args) {
if (pluginRef.getCommandTools().noConsoleUsage(sender)) {
return true;
}
if (!pluginRef.getCommandTools().hasPlayerDataKey(sender)) {
return true;
}
if (pluginRef.getUserManager().getPlayer((Player) sender) == null) {
sender.sendMessage(pluginRef.getLocaleManager().getString("Profile.PendingLoad"));
return true;
}
switch (args.length) {
case 0:
Player player = (Player) sender;
McMMOPlayer mcMMOPlayer = pluginRef.getUserManager().getPlayer(player);
boolean isLucky = pluginRef.getPermissionTools().lucky(player, skill);
boolean hasEndurance = pluginRef.getSkillTools().getEnduranceLength(player) > 0;
double skillValue = mcMMOPlayer.getSkillLevel(skill);
//Send the players a few blank lines to make finding the top of the skill command easier
if (pluginRef.getConfigManager().getConfigCommands().isSendBlankLines())
for (int i = 0; i < 2; i++) {
player.sendMessage("");
}
permissionsCheck(player);
dataCalculations(player, skillValue);
sendSkillCommandHeader(player, mcMMOPlayer, (int) skillValue);
//Make JSON text components
List<TextComponent> subskillTextComponents = getTextComponents(player);
//Subskills Header
player.sendMessage(pluginRef.getLocaleManager().getString("Skills.Overhaul.Header", pluginRef.getLocaleManager().getString("Effects.SubSkills.Overhaul")));
//Send JSON text components
pluginRef.getTextComponentFactory().sendPlayerSubSkillList(player, subskillTextComponents);
/*for(TextComponent tc : subskillTextComponents)
{
player.spigot().sendMessage(new TextComponent[]{tc, new TextComponent(": TESTING")});
}*/
//Stats
getStatMessages(player, isLucky, hasEndurance, skillValue);
//Header
//Link Header
if (pluginRef.getConfigManager().getConfigAds().isShowWebsiteLinks()) {
player.sendMessage(pluginRef.getLocaleManager().getString("Overhaul.mcMMO.Header"));
pluginRef.getTextComponentFactory().sendPlayerUrlHeader(player);
}
if (pluginRef.getScoreboardSettings().getScoreboardsEnabled()
&& pluginRef.getScoreboardSettings().getConfigSectionScoreboardTypes()
.getConfigSectionSkillBoard().isUseThisBoard()) {
pluginRef.getScoreboardManager().enablePlayerSkillScoreboard(player, skill);
}
return true;
default:
return skillGuideCommand.onCommand(sender, command, label, args);
}
}
private void getStatMessages(Player player, boolean isLucky, boolean hasEndurance, double skillValue) {
List<String> statsMessages = statsDisplay(player, skillValue, hasEndurance, isLucky);
if (!statsMessages.isEmpty()) {
player.sendMessage(pluginRef.getLocaleManager().getString("Skills.Overhaul.Header", pluginRef.getLocaleManager().getString("Commands.Stats.Self.Overhaul")));
for (String message : statsMessages) {
player.sendMessage(message);
}
}
player.sendMessage(pluginRef.getLocaleManager().getString("Guides.Available", skillName, skillName.toLowerCase()));
}
private void sendSkillCommandHeader(Player player, McMMOPlayer mcMMOPlayer, int skillValue) {
ChatColor hd1 = ChatColor.DARK_AQUA;
ChatColor c1 = ChatColor.GOLD;
ChatColor c2 = ChatColor.RED;
player.sendMessage(pluginRef.getLocaleManager().getString("Skills.Overhaul.Header", skillName));
if (!pluginRef.getSkillTools().isChildSkill(skill)) {
/*
* NON-CHILD SKILLS
*/
//XP GAIN METHOD
player.sendMessage(pluginRef.getLocaleManager().getString("Commands.XPGain.Overhaul", pluginRef.getLocaleManager().getString("Commands.XPGain." + StringUtils.getCapitalized(skill.toString()))));
//LEVEL
player.sendMessage(pluginRef.getLocaleManager().getString("Effects.Level.Overhaul", skillValue, mcMMOPlayer.getSkillXpLevel(skill), mcMMOPlayer.getXpToLevel(skill)));
} else {
/*
* CHILD SKILLS
*/
Set<PrimarySkillType> parents = FamilyTree.getParents(skill);
ArrayList<PrimarySkillType> parentList = new ArrayList<>();
//TODO: Add JSON here
/*player.sendMessage(parent.getName() + " - " + pluginRef.getLocaleManager().getString("Effects.Level.Overhaul", mcMMOPlayer.getSkillLevel(parent), mcMMOPlayer.getSkillXpLevel(parent), mcMMOPlayer.getXpToLevel(parent)))*/
parentList.addAll(parents);
StringBuilder parentMessage = new StringBuilder();
for (int i = 0; i < parentList.size(); i++) {
if (i + 1 < parentList.size()) {
parentMessage.append(pluginRef.getLocaleManager().getString("Effects.Child.ParentList", pluginRef.getSkillTools().getLocalizedSkillName(parentList.get(i)), mcMMOPlayer.getSkillLevel(parentList.get(i))));
parentMessage.append(ChatColor.GRAY + ", ");
} else {
parentMessage.append(pluginRef.getLocaleManager().getString("Effects.Child.ParentList", pluginRef.getSkillTools().getLocalizedSkillName(parentList.get(i)), mcMMOPlayer.getSkillLevel(parentList.get(i))));
}
}
//XP GAIN METHOD
player.sendMessage(pluginRef.getLocaleManager().getString("Commands.XPGain.Overhaul", pluginRef.getLocaleManager().getString("Commands.XPGain.Child")));
player.sendMessage(pluginRef.getLocaleManager().getString("Effects.Child.Overhaul", skillValue, parentMessage.toString()));
//LEVEL
//player.sendMessage(pluginRef.getLocaleManager().getString("Effects.Child.Overhaul", skillValue, skillValue));
}
}
@Override
public List<String> onTabComplete(CommandSender sender, Command command, String alias, String[] args) {
switch (args.length) {
case 1:
return ImmutableList.of("?");
default:
return ImmutableList.of();
}
}
protected int calculateRank(double skillValue, int maxLevel, int rankChangeLevel) {
return Math.min((int) skillValue, maxLevel) / rankChangeLevel;
}
protected String[] getAbilityDisplayValues(Player player, SubSkillType subSkill) {
return pluginRef.getRandomChanceTools().calculateAbilityDisplayValues(SkillActivationType.RANDOM_LINEAR_100_SCALE_WITH_CAP, player, subSkill);
}
protected String[] formatLengthDisplayValues(Player player, double skillValue) {
int length = pluginRef.getSkillTools().calculateAbilityLength(pluginRef.getUserManager().getPlayer(player), skill, pluginRef.getSkillTools().getSuperAbility(skill));
int enduranceLength = pluginRef.getSkillTools().calculateAbilityLengthPerks(pluginRef.getUserManager().getPlayer(player), skill, pluginRef.getSkillTools().getSuperAbility(skill));
return new String[]{String.valueOf(length), String.valueOf(enduranceLength)};
}
protected String getStatMessage(SubSkillType subSkillType, String... vars) {
return getStatMessage(false, false, subSkillType, vars);
}
protected String getStatMessage(boolean isExtra, boolean isCustom, SubSkillType subSkillType, String... vars) {
String templateKey = isCustom ? "Ability.Generic.Template.Custom" : "Ability.Generic.Template";
String statDescriptionKey = !isExtra ? subSkillType.getLocaleKeyStatDescription(pluginRef) : subSkillType.getLocaleKeyStatExtraDescription(pluginRef);
if (isCustom)
return pluginRef.getLocaleManager().getString(templateKey, pluginRef.getLocaleManager().getString(statDescriptionKey, vars));
else {
String[] mergedList = pluginRef.getNotificationManager().addItemToFirstPositionOfArray(pluginRef.getLocaleManager().getString(statDescriptionKey), vars);
return pluginRef.getLocaleManager().getString(templateKey, mergedList);
}
}
protected abstract void dataCalculations(Player player, double skillValue);
protected String getLimitBreakDescriptionParameter(SubSkillType subSkillType) {
//TODO: Hacky gross code below
boolean pveAllowed = false;
switch(subSkillType) {
case ARCHERY_ARCHERY_LIMIT_BREAK:
if(pluginRef.getConfigManager().getConfigArchery().getLimitBreak().isEnabledForPVE()) {
pveAllowed = true;
}
break;
case AXES_AXES_LIMIT_BREAK:
if(pluginRef.getConfigManager().getConfigAxes().getSubSkills().getConfigAxesLimitBreak().isEnabledForPVE()) {
pveAllowed = true;
}
break;
case SWORDS_SWORDS_LIMIT_BREAK:
if(pluginRef.getConfigManager().getConfigSwords().getSubSkills().getSwordsLimitBreak().isEnabledForPVE()) {
pveAllowed = true;
}
break;
case UNARMED_UNARMED_LIMIT_BREAK:
if(pluginRef.getConfigManager().getConfigUnarmed().getSubSkills().getUnarmedLimitBreak().isEnabledForPVE()) {
pveAllowed = true;
}
break;
default:
pluginRef.getLogger().severe("This skill has no limit break PVE setting defined!");
}
if(pveAllowed) {
return "(PVP/PVE)";
} else {
return "(PVP)";
}
}
protected abstract void permissionsCheck(Player player);
//protected abstract List<String> effectsDisplay();
protected abstract List<String> statsDisplay(Player player, double skillValue, boolean hasEndurance, boolean isLucky);
protected abstract List<TextComponent> getTextComponents(Player player);
/**
* Checks if a player can use a skill
*
* @param player target player
* @param subSkillType target subskill
* @return true if the player has permission and has the skill unlocked
*/
protected boolean canUseSubSkill(Player player, SubSkillType subSkillType) {
return pluginRef.getPermissionTools().isSubSkillEnabled(player, subSkillType) && pluginRef.getRankTools().hasUnlockedSubskill(player, subSkillType);
}
}

View File

@ -0,0 +1,111 @@
package com.gmail.nossr50.commands.skills;
import com.gmail.nossr50.datatypes.skills.PrimarySkillType;
import com.gmail.nossr50.mcMMO;
import com.gmail.nossr50.util.StringUtils;
import org.bukkit.command.Command;
import org.bukkit.command.CommandExecutor;
import org.bukkit.command.CommandSender;
import java.util.ArrayList;
import java.util.Arrays;
public class SkillGuideCommand implements CommandExecutor {
private String header;
private ArrayList<String> guide;
private String invalidPage;
private final mcMMO pluginRef;
public SkillGuideCommand(PrimarySkillType primarySkillType, mcMMO pluginRef) {
header = pluginRef.getLocaleManager().getString("Guides.Header", pluginRef.getSkillTools().getLocalizedSkillName(primarySkillType));
guide = getGuide(primarySkillType);
invalidPage = pluginRef.getLocaleManager().getString("Guides.Page.Invalid");
this.pluginRef = pluginRef;
}
@Override
public boolean onCommand(CommandSender sender, Command command, String label, String[] args) {
switch (args.length) {
case 1:
if (!args[0].equals("?")) {
return false;
}
sendGuide(sender, 1);
return true;
case 2:
int totalPages = getTotalPageNumber();
if (!StringUtils.isInt(args[1])) {
sender.sendMessage(invalidPage);
return true;
}
int pageNumber = Integer.parseInt(args[1]);
if (pageNumber > totalPages || pageNumber <= 0) {
sender.sendMessage(pluginRef.getLocaleManager().getString("Guides.Page.OutOfRange", totalPages));
return true;
}
sendGuide(sender, pageNumber);
return true;
default:
return false;
}
}
private int getTotalPageNumber() {
return (int) Math.ceil(guide.size() / 8.0);
}
private void sendGuide(CommandSender sender, int pageNumber) {
for (String target : grabPageContents(pageNumber)) {
sender.sendMessage(target);
}
}
private ArrayList<String> grabPageContents(int page) {
int pageIndexStart = 8 * (page - 1); // Determine what string to start at
ArrayList<String> allStrings = new ArrayList<>();
allStrings.add(header);
// Add targeted strings
while (allStrings.size() < 9) {
if (pageIndexStart + allStrings.size() > guide.size()) {
allStrings.add("");
} else {
allStrings.add(guide.get(pageIndexStart + (allStrings.size() - 1)));
}
}
allStrings.add("Page " + page + " of " + getTotalPageNumber());
return allStrings;
}
private ArrayList<String> getGuide(PrimarySkillType skill) {
ArrayList<String> guide = new ArrayList<>();
for (int i = 0; i < 10; i++) {
String[] section = pluginRef.getLocaleManager().getString("Guides." + StringUtils.getCapitalized(skill.toString()) + ".Section." + i).split("\n");
if (section[0].startsWith("!")) {
break;
}
guide.addAll(Arrays.asList(section));
if (section.length < 8) {
for (int blankLine = 8 - section.length; blankLine > 0; blankLine--) {
guide.add("");
}
}
}
return guide;
}
}

View File

@ -0,0 +1,93 @@
package com.gmail.nossr50.commands.skills;
import com.gmail.nossr50.datatypes.skills.PrimarySkillType;
import com.gmail.nossr50.datatypes.skills.SubSkillType;
import com.gmail.nossr50.mcMMO;
import net.md_5.bungee.api.chat.TextComponent;
import org.bukkit.entity.Player;
import java.util.ArrayList;
import java.util.List;
public class SmeltingCommand extends SkillCommand {
private String burnTimeModifier;
private String str_secondSmeltChance;
private String str_secondSmeltChanceLucky;
private String str_fluxMiningChance;
private String str_fluxMiningChanceLucky;
private boolean canFuelEfficiency;
private boolean canSecondSmelt;
private boolean canFluxMine;
private boolean canUnderstandTheArt;
public SmeltingCommand(mcMMO pluginRef) {
super(PrimarySkillType.SMELTING, pluginRef);
}
@Override
protected void dataCalculations(Player player, double skillValue) {
// FUEL EFFICIENCY
if (canFuelEfficiency) {
burnTimeModifier = String.valueOf(pluginRef.getUserManager().getPlayer(player).getSmeltingManager().getFuelEfficiencyMultiplier());
}
// FLUX MINING
/*if (canFluxMine) {
String[] fluxMiningStrings = getAbilityDisplayValues(SkillActivationType.RANDOM_LINEAR_100_SCALE_WITH_CAP, player, SubSkillType.SMELTING_FLUX_MINING);
str_fluxMiningChance = fluxMiningStrings[0];
str_fluxMiningChanceLucky = fluxMiningStrings[1];
}*/
// SECOND SMELT
if (canSecondSmelt) {
String[] secondSmeltStrings = getAbilityDisplayValues(player, SubSkillType.SMELTING_SECOND_SMELT);
str_secondSmeltChance = secondSmeltStrings[0];
str_secondSmeltChanceLucky = secondSmeltStrings[1];
}
}
@Override
protected void permissionsCheck(Player player) {
canFuelEfficiency = canUseSubSkill(player, SubSkillType.SMELTING_FUEL_EFFICIENCY);
canSecondSmelt = canUseSubSkill(player, SubSkillType.SMELTING_SECOND_SMELT);
//canFluxMine = canUseSubskill(player, SubSkillType.SMELTING_FLUX_MINING);
canUnderstandTheArt = pluginRef.getPermissionTools().vanillaXpBoost(player, skill) && pluginRef.getRankTools().hasUnlockedSubskill(player, SubSkillType.SMELTING_UNDERSTANDING_THE_ART);
}
@Override
protected List<String> statsDisplay(Player player, double skillValue, boolean hasEndurance, boolean isLucky) {
List<String> messages = new ArrayList<>();
/*if (canFluxMine) {
messages.add(getStatMessage(SubSkillType.SMELTING_FLUX_MINING, str_fluxMiningChance)
+ (isLucky ? pluginRef.getLocaleManager().getString("Perks.Lucky.Bonus", str_fluxMiningChanceLucky) : ""));
//messages.add(pluginRef.getLocaleManager().getString("Smelting.Ability.FluxMining", str_fluxMiningChance) + (isLucky ? pluginRef.getLocaleManager().getString("Perks.Lucky.Bonus", str_fluxMiningChanceLucky) : ""));
}*/
if (canFuelEfficiency) {
messages.add(getStatMessage(false, true, SubSkillType.SMELTING_FUEL_EFFICIENCY, burnTimeModifier));
}
if (canSecondSmelt) {
messages.add(getStatMessage(SubSkillType.SMELTING_SECOND_SMELT, str_secondSmeltChance)
+ (isLucky ? pluginRef.getLocaleManager().getString("Perks.Lucky.Bonus", str_secondSmeltChanceLucky) : ""));
}
if (canUnderstandTheArt) {
messages.add(getStatMessage(false, true, SubSkillType.SMELTING_UNDERSTANDING_THE_ART,
String.valueOf(pluginRef.getUserManager().getPlayer(player).getSmeltingManager().getVanillaXpMultiplier())));
}
return messages;
}
@Override
protected List<TextComponent> getTextComponents(Player player) {
List<TextComponent> textComponents = new ArrayList<>();
pluginRef.getTextComponentFactory().getSubSkillTextComponents(player, textComponents, PrimarySkillType.SMELTING);
return textComponents;
}
}

View File

@ -0,0 +1,115 @@
package com.gmail.nossr50.commands.skills;
import com.gmail.nossr50.datatypes.skills.PrimarySkillType;
import com.gmail.nossr50.datatypes.skills.SubSkillType;
import com.gmail.nossr50.mcMMO;
import net.md_5.bungee.api.chat.TextComponent;
import org.bukkit.entity.Player;
import java.util.ArrayList;
import java.util.List;
public class SwordsCommand extends SkillCommand {
private String counterChance;
private String counterChanceLucky;
private int bleedLength;
private String bleedChance;
private String bleedChanceLucky;
private String serratedStrikesLength;
private String serratedStrikesLengthEndurance;
private boolean canCounter;
private boolean canSerratedStrike;
private boolean canBleed;
public SwordsCommand(mcMMO pluginRef) {
super(PrimarySkillType.SWORDS, pluginRef);
}
@Override
protected void dataCalculations(Player player, double skillValue) {
// SWORDS_COUNTER_ATTACK
if (canCounter) {
String[] counterStrings = getAbilityDisplayValues(player, SubSkillType.SWORDS_COUNTER_ATTACK);
counterChance = counterStrings[0];
counterChanceLucky = counterStrings[1];
}
// SWORDS_RUPTURE
if (canBleed) {
bleedLength = pluginRef.getUserManager().getPlayer(player).getSwordsManager().getRuptureBleedTicks();
String[] bleedStrings = getAbilityDisplayValues(player, SubSkillType.SWORDS_RUPTURE);
bleedChance = bleedStrings[0];
bleedChanceLucky = bleedStrings[1];
}
// SERRATED STRIKES
if (canSerratedStrike) {
String[] serratedStrikesStrings = formatLengthDisplayValues(player, skillValue);
serratedStrikesLength = serratedStrikesStrings[0];
serratedStrikesLengthEndurance = serratedStrikesStrings[1];
}
}
@Override
protected void permissionsCheck(Player player) {
canBleed = canUseSubSkill(player, SubSkillType.SWORDS_RUPTURE);
canCounter = canUseSubSkill(player, SubSkillType.SWORDS_COUNTER_ATTACK);
canSerratedStrike = pluginRef.getRankTools().hasUnlockedSubskill(player, SubSkillType.SWORDS_SERRATED_STRIKES) && pluginRef.getPermissionTools().serratedStrikes(player);
}
@Override
protected List<String> statsDisplay(Player player, double skillValue, boolean hasEndurance, boolean isLucky) {
List<String> messages = new ArrayList<>();
int ruptureTicks = pluginRef.getUserManager().getPlayer(player).getSwordsManager().getRuptureBleedTicks();
double ruptureDamagePlayer = pluginRef.getConfigManager().getConfigSwords().getRuptureDamagePlayer();
double pveRupture = pluginRef.getConfigManager().getConfigSwords().getRuptureDamageMobs();
double pvpDamageRupture = pluginRef.getRankTools().getRank(player, SubSkillType.SWORDS_RUPTURE) >= 3 ? ruptureDamagePlayer * 1.5D : ruptureDamagePlayer;
double ruptureDamageMobs = pluginRef.getRankTools().getRank(player, SubSkillType.SWORDS_RUPTURE) >= 3 ? pveRupture * 1.5D : pveRupture;
if (canCounter) {
messages.add(getStatMessage(SubSkillType.SWORDS_COUNTER_ATTACK, counterChance)
+ (isLucky ? pluginRef.getLocaleManager().getString("Perks.Lucky.Bonus", counterChanceLucky) : ""));
}
if (canBleed) {
messages.add(getStatMessage(SubSkillType.SWORDS_RUPTURE, bleedChance)
+ (isLucky ? pluginRef.getLocaleManager().getString("Perks.Lucky.Bonus", bleedChanceLucky) : ""));
messages.add(getStatMessage(true, true, SubSkillType.SWORDS_RUPTURE,
String.valueOf(ruptureTicks),
String.valueOf(pvpDamageRupture),
String.valueOf(ruptureDamageMobs)));
messages.add(pluginRef.getLocaleManager().getString("Swords.Combat.Rupture.Note"));
}
if (canSerratedStrike) {
messages.add(getStatMessage(SubSkillType.SWORDS_SERRATED_STRIKES, serratedStrikesLength)
+ (hasEndurance ? pluginRef.getLocaleManager().getString("Perks.ActivationTime.Bonus", serratedStrikesLengthEndurance) : ""));
}
if (canUseSubSkill(player, SubSkillType.SWORDS_STAB)) {
messages.add(getStatMessage(SubSkillType.SWORDS_STAB,
String.valueOf(pluginRef.getUserManager().getPlayer(player).getSwordsManager().getStabDamage())));
}
if (canUseSubSkill(player, SubSkillType.SWORDS_SWORDS_LIMIT_BREAK)) {
messages.add(getStatMessage(SubSkillType.SWORDS_SWORDS_LIMIT_BREAK,
String.valueOf(pluginRef.getCombatTools().getLimitBreakDamageAgainstQuality(player, SubSkillType.SWORDS_SWORDS_LIMIT_BREAK, 1000))));
}
return messages;
}
@Override
protected List<TextComponent> getTextComponents(Player player) {
List<TextComponent> textComponents = new ArrayList<>();
pluginRef.getTextComponentFactory().getSubSkillTextComponents(player, textComponents, PrimarySkillType.SWORDS);
return textComponents;
}
}

View File

@ -0,0 +1,112 @@
package com.gmail.nossr50.commands.skills;
import com.gmail.nossr50.datatypes.skills.PrimarySkillType;
import com.gmail.nossr50.datatypes.skills.SubSkillType;
import com.gmail.nossr50.mcMMO;
import net.md_5.bungee.api.chat.TextComponent;
import org.bukkit.entity.EntityType;
import org.bukkit.entity.Player;
import java.util.ArrayList;
import java.util.List;
public class TamingCommand extends SkillCommand {
private String goreChance;
private String goreChanceLucky;
private boolean canBeastLore;
private boolean canGore;
private boolean canSharpenedClaws;
private boolean canEnvironmentallyAware;
private boolean canThickFur;
private boolean canShockProof;
private boolean canCallWild;
private boolean canFastFood;
private boolean canHolyHound;
public TamingCommand(mcMMO pluginRef) {
super(PrimarySkillType.TAMING, pluginRef);
}
@Override
protected void dataCalculations(Player player, double skillValue) {
if (canGore) {
String[] goreStrings = getAbilityDisplayValues(player, SubSkillType.TAMING_GORE);
goreChance = goreStrings[0];
goreChanceLucky = goreStrings[1];
}
}
@Override
protected void permissionsCheck(Player player) {
canBeastLore = canUseSubSkill(player, SubSkillType.TAMING_BEAST_LORE);
canCallWild = pluginRef.getPermissionTools().callOfTheWild(player, EntityType.HORSE) || pluginRef.getPermissionTools().callOfTheWild(player, EntityType.WOLF) || pluginRef.getPermissionTools().callOfTheWild(player, EntityType.OCELOT);
canEnvironmentallyAware = canUseSubSkill(player, SubSkillType.TAMING_ENVIRONMENTALLY_AWARE);
canFastFood = canUseSubSkill(player, SubSkillType.TAMING_FAST_FOOD_SERVICE);
canGore = canUseSubSkill(player, SubSkillType.TAMING_GORE);
canSharpenedClaws = canUseSubSkill(player, SubSkillType.TAMING_SHARPENED_CLAWS);
canShockProof = canUseSubSkill(player, SubSkillType.TAMING_SHOCK_PROOF);
canThickFur = canUseSubSkill(player, SubSkillType.TAMING_THICK_FUR);
canHolyHound = canUseSubSkill(player, SubSkillType.TAMING_HOLY_HOUND);
}
@Override
protected List<String> statsDisplay(Player player, double skillValue, boolean hasEndurance, boolean isLucky) {
List<String> messages = new ArrayList<>();
if (canEnvironmentallyAware) {
messages.add(pluginRef.getLocaleManager().getString("Ability.Generic.Template", pluginRef.getLocaleManager().getString("Taming.Ability.Bonus.0"), pluginRef.getLocaleManager().getString("Taming.Ability.Bonus.1")));
}
if (canFastFood) {
messages.add(pluginRef.getLocaleManager().getString("Ability.Generic.Template",
pluginRef.getLocaleManager().getString("Taming.Ability.Bonus.8"),
pluginRef.getLocaleManager().getString("Taming.Ability.Bonus.9",
percent.format(pluginRef.getDynamicSettingsManager().getSkillStaticChance(SubSkillType.TAMING_FAST_FOOD_SERVICE) / 100D))));
}
if (canGore) {
messages.add(pluginRef.getLocaleManager().getString("Ability.Generic.Template",
pluginRef.getLocaleManager().getString("Taming.Combat.Chance.Gore"),
goreChance) + (isLucky ? pluginRef.getLocaleManager().getString("Perks.Lucky.Bonus", goreChanceLucky) : ""));
}
if (canHolyHound) {
messages.add(pluginRef.getLocaleManager().getString("Ability.Generic.Template",
pluginRef.getLocaleManager().getString("Taming.Ability.Bonus.10"),
pluginRef.getLocaleManager().getString("Taming.Ability.Bonus.11")));
}
if (canSharpenedClaws) {
messages.add(pluginRef.getLocaleManager().getString("Ability.Generic.Template",
pluginRef.getLocaleManager().getString("Taming.Ability.Bonus.6"),
pluginRef.getLocaleManager().getString("Taming.Ability.Bonus.7",
pluginRef.getDynamicSettingsManager().getSkillBehaviourManager().getTamingBehaviour().getSharpenedClawsBonusDamage(true))));
}
if (canShockProof) {
messages.add(pluginRef.getLocaleManager().getString("Ability.Generic.Template",
pluginRef.getLocaleManager().getString("Taming.Ability.Bonus.4"),
pluginRef.getLocaleManager().getString("Taming.Ability.Bonus.5",
pluginRef.getDynamicSettingsManager().getSkillBehaviourManager().getTamingBehaviour().getShockProofModifier())));
}
if (canThickFur) {
messages.add(pluginRef.getLocaleManager().getString("Ability.Generic.Template",
pluginRef.getLocaleManager().getString("Taming.Ability.Bonus.2"),
pluginRef.getLocaleManager().getString("Taming.Ability.Bonus.3",
pluginRef.getDynamicSettingsManager().getSkillBehaviourManager().getTamingBehaviour().getThickFurModifier())));
}
return messages;
}
@Override
protected List<TextComponent> getTextComponents(Player player) {
List<TextComponent> textComponents = new ArrayList<>();
pluginRef.getTextComponentFactory().getSubSkillTextComponents(player, textComponents, this.skill);
return textComponents;
}
}

View File

@ -0,0 +1,127 @@
package com.gmail.nossr50.commands.skills;
import com.gmail.nossr50.datatypes.skills.PrimarySkillType;
import com.gmail.nossr50.datatypes.skills.SubSkillType;
import com.gmail.nossr50.mcMMO;
import net.md_5.bungee.api.chat.TextComponent;
import org.bukkit.entity.Player;
import java.util.ArrayList;
import java.util.List;
public class UnarmedCommand extends SkillCommand {
private String berserkLength;
private String berserkLengthEndurance;
private String deflectChance;
private String deflectChanceLucky;
private String disarmChance;
private String disarmChanceLucky;
private String ironGripChance;
private String ironGripChanceLucky;
private double ironArmBonus;
private boolean canBerserk;
private boolean canDisarm;
private boolean canIronArm;
private boolean canDeflect;
private boolean canIronGrip;
public UnarmedCommand(mcMMO pluginRef) {
super(PrimarySkillType.UNARMED, pluginRef);
}
@Override
protected void dataCalculations(Player player, double skillValue) {
// UNARMED_ARROW_DEFLECT
if (canDeflect) {
String[] deflectStrings = getAbilityDisplayValues(player, SubSkillType.UNARMED_ARROW_DEFLECT);
deflectChance = deflectStrings[0];
deflectChanceLucky = deflectStrings[1];
}
// BERSERK
if (canBerserk) {
String[] berserkStrings = formatLengthDisplayValues(player, skillValue);
berserkLength = berserkStrings[0];
berserkLengthEndurance = berserkStrings[1];
}
// UNARMED_DISARM
if (canDisarm) {
String[] disarmStrings = getAbilityDisplayValues(player, SubSkillType.UNARMED_DISARM);
disarmChance = disarmStrings[0];
disarmChanceLucky = disarmStrings[1];
}
// IRON ARM
if (canIronArm) {
ironArmBonus = pluginRef.getUserManager().getPlayer(player).getUnarmedManager().getIronArmDamage();
}
// IRON GRIP
if (canIronGrip) {
String[] ironGripStrings = getAbilityDisplayValues(player, SubSkillType.UNARMED_IRON_GRIP);
ironGripChance = ironGripStrings[0];
ironGripChanceLucky = ironGripStrings[1];
}
}
@Override
protected void permissionsCheck(Player player) {
canBerserk = pluginRef.getRankTools().hasUnlockedSubskill(player, SubSkillType.UNARMED_BERSERK) && pluginRef.getPermissionTools().berserk(player);
canIronArm = canUseSubSkill(player, SubSkillType.UNARMED_IRON_ARM_STYLE);
canDeflect = canUseSubSkill(player, SubSkillType.UNARMED_ARROW_DEFLECT);
canDisarm = canUseSubSkill(player, SubSkillType.UNARMED_DISARM);
canIronGrip = canUseSubSkill(player, SubSkillType.UNARMED_IRON_GRIP);
// TODO: Apparently we forgot about block cracker?
}
@Override
protected List<String> statsDisplay(Player player, double skillValue, boolean hasEndurance, boolean isLucky) {
List<String> messages = new ArrayList<>();
if (canDeflect) {
messages.add(getStatMessage(SubSkillType.UNARMED_ARROW_DEFLECT, deflectChance)
+ (isLucky ? pluginRef.getLocaleManager().getString("Perks.Lucky.Bonus", deflectChanceLucky) : ""));
//messages.add(pluginRef.getLocaleManager().getString("Unarmed.Ability.Chance.ArrowDeflect", deflectChance) + (isLucky ? pluginRef.getLocaleManager().getString("Perks.Lucky.Bonus", deflectChanceLucky) : ""));
}
if (canBerserk) {
messages.add(getStatMessage(SubSkillType.UNARMED_BERSERK, berserkLength)
+ (hasEndurance ? pluginRef.getLocaleManager().getString("Perks.ActivationTime.Bonus", berserkLengthEndurance) : ""));
//messages.add(pluginRef.getLocaleManager().getString("Unarmed.Ability.Berserk.Length", berserkLength) + (hasEndurance ? pluginRef.getLocaleManager().getString("Perks.ActivationTime.Bonus", berserkLengthEndurance) : ""));
}
if (canDisarm) {
messages.add(getStatMessage(SubSkillType.UNARMED_DISARM, disarmChance)
+ (isLucky ? pluginRef.getLocaleManager().getString("Perks.Lucky.Bonus", disarmChanceLucky) : ""));
//messages.add(pluginRef.getLocaleManager().getString("Unarmed.Ability.Chance.Disarm", disarmChance) + (isLucky ? pluginRef.getLocaleManager().getString("Perks.Lucky.Bonus", disarmChanceLucky) : ""));
}
if (canIronArm) {
messages.add(pluginRef.getLocaleManager().getString("Ability.Generic.Template", pluginRef.getLocaleManager().getString("Unarmed.Ability.Bonus.0"), pluginRef.getLocaleManager().getString("Unarmed.Ability.Bonus.1", ironArmBonus)));
}
if (canIronGrip) {
messages.add(getStatMessage(SubSkillType.UNARMED_IRON_GRIP, ironGripChance)
+ (isLucky ? pluginRef.getLocaleManager().getString("Perks.Lucky.Bonus", ironGripChanceLucky) : ""));
//messages.add(pluginRef.getLocaleManager().getString("Unarmed.Ability.Chance.IronGrip", ironGripChance) + (isLucky ? pluginRef.getLocaleManager().getString("Perks.Lucky.Bonus", ironGripChanceLucky) : ""));
}
if (canUseSubSkill(player, SubSkillType.UNARMED_UNARMED_LIMIT_BREAK)) {
messages.add(getStatMessage(SubSkillType.UNARMED_UNARMED_LIMIT_BREAK,
String.valueOf(pluginRef.getCombatTools().getLimitBreakDamageAgainstQuality(player, SubSkillType.UNARMED_UNARMED_LIMIT_BREAK, 1000))));
}
return messages;
}
@Override
protected List<TextComponent> getTextComponents(Player player) {
List<TextComponent> textComponents = new ArrayList<>();
pluginRef.getTextComponentFactory().getSubSkillTextComponents(player, textComponents, PrimarySkillType.UNARMED);
return textComponents;
}
}

View File

@ -0,0 +1,91 @@
package com.gmail.nossr50.commands.skills;
import com.gmail.nossr50.datatypes.skills.PrimarySkillType;
import com.gmail.nossr50.datatypes.skills.SubSkillType;
import com.gmail.nossr50.mcMMO;
import net.md_5.bungee.api.chat.TextComponent;
import org.bukkit.entity.Player;
import java.util.ArrayList;
import java.util.List;
public class WoodcuttingCommand extends SkillCommand {
private String treeFellerLength;
private String treeFellerLengthEndurance;
private String doubleDropChance;
private String doubleDropChanceLucky;
private boolean canTreeFell;
private boolean canLeafBlow;
private boolean canDoubleDrop;
private boolean canSplinter;
private boolean canBarkSurgeon;
private boolean canNaturesBounty;
public WoodcuttingCommand(mcMMO pluginRef) {
super(PrimarySkillType.WOODCUTTING, pluginRef);
}
@Override
protected void dataCalculations(Player player, double skillValue) {
// DOUBLE DROPS
if (canDoubleDrop) {
setDoubleDropClassicChanceStrings(player);
}
// TREE FELLER
if (canTreeFell) {
String[] treeFellerStrings = formatLengthDisplayValues(player, skillValue);
treeFellerLength = treeFellerStrings[0];
treeFellerLengthEndurance = treeFellerStrings[1];
}
}
private void setDoubleDropClassicChanceStrings(Player player) {
String[] doubleDropStrings = getAbilityDisplayValues(player, SubSkillType.WOODCUTTING_HARVEST_LUMBER);
doubleDropChance = doubleDropStrings[0];
doubleDropChanceLucky = doubleDropStrings[1];
}
@Override
protected void permissionsCheck(Player player) {
canTreeFell = pluginRef.getRankTools().hasUnlockedSubskill(player, SubSkillType.WOODCUTTING_TREE_FELLER) && pluginRef.getPermissionTools().treeFeller(player);
canDoubleDrop = canUseSubSkill(player, SubSkillType.WOODCUTTING_HARVEST_LUMBER) && pluginRef.getRankTools().getRank(player, SubSkillType.WOODCUTTING_HARVEST_LUMBER) >= 1;
canLeafBlow = canUseSubSkill(player, SubSkillType.WOODCUTTING_LEAF_BLOWER);
/*canSplinter = canUseSubskill(player, SubSkillType.WOODCUTTING_SPLINTER);
canBarkSurgeon = canUseSubskill(player, SubSkillType.WOODCUTTING_BARK_SURGEON);
canNaturesBounty = canUseSubskill(player, SubSkillType.WOODCUTTING_NATURES_BOUNTY);*/
}
@Override
protected List<String> statsDisplay(Player player, double skillValue, boolean hasEndurance, boolean isLucky) {
List<String> messages = new ArrayList<>();
if (canDoubleDrop) {
messages.add(getStatMessage(SubSkillType.WOODCUTTING_HARVEST_LUMBER, doubleDropChance)
+ (isLucky ? pluginRef.getLocaleManager().getString("Perks.Lucky.Bonus", doubleDropChanceLucky) : ""));
}
if (canLeafBlow) {
messages.add(pluginRef.getLocaleManager().getString("Ability.Generic.Template", pluginRef.getLocaleManager().getString("Woodcutting.Ability.0"), pluginRef.getLocaleManager().getString("Woodcutting.Ability.1")));
}
if (canTreeFell) {
messages.add(getStatMessage(SubSkillType.WOODCUTTING_TREE_FELLER, treeFellerLength)
+ (hasEndurance ? pluginRef.getLocaleManager().getString("Perks.ActivationTime.Bonus", treeFellerLengthEndurance) : ""));
}
return messages;
}
@Override
protected List<TextComponent> getTextComponents(Player player) {
List<TextComponent> textComponents = new ArrayList<>();
pluginRef.getTextComponentFactory().getSubSkillTextComponents(player, textComponents, PrimarySkillType.WOODCUTTING);
return textComponents;
}
}

View File

@ -0,0 +1,113 @@
package com.gmail.nossr50.config;
import com.gmail.nossr50.mcMMO;
import java.io.File;
import java.util.ArrayList;
/**
* Constants relating to config folders and paths
*/
public class ConfigConstants {
public final static ArrayList<String> EXAMPLE_BLACKLIST_WORLDS_LIST_DEFAULT;
public final static String SKILL_SCALING_BENEFIT_EXPLANATION = "\nSub-Skills dynamically adjust their rewards to match the max bonus level, you can think of it as a curve that calculates what bonuses " +
"\n a player should have based on how far they are from the max bonus level value, and the other parameters used for the scaling of that sub-skill.";
/* FOLDER NAMES */
public static final String FOLDER_NAME_CONFIG = "config";
public static final String FOLDER_NAME_SKILLS = "skills";
public static final String FOLDER_NAME_EXPERIENCE = "Experience Settings";
public static final String FOLDER_NAME_DEFAULTS = "defaults";
/* RELATIVE PATHS */
public final static String RELATIVE_PATH_CONFIG_DIR = File.separator + FOLDER_NAME_CONFIG + File.separator;
public final static String RELATIVE_PATH_SKILLS_DIR = RELATIVE_PATH_CONFIG_DIR + FOLDER_NAME_SKILLS + File.separator;
public final static String RELATIVE_PATH_XP_DIR = RELATIVE_PATH_CONFIG_DIR + FOLDER_NAME_EXPERIENCE + File.separator;
private final static String[] EXAMPLE_BLACKLIST_WORLDS = {"Example_15434453", "Example_2324423", "Example_323423465"};
/* Field Names & Comments */
public static final String SUB_SKILL_NODE = "Sub-Skill";
public final static String MAX_CHANCE_FIELD_NAME = "Max-Chance";
public final static String STATIC_ACTIVATION_FIELD_NAME = "Activation-Chance";
public final static String MAX_BONUS_LEVEL_FIELD_NAME = "Max-Bonus-Level";
public final static String MAX_BONUS_LEVEL_DESCRIPTION = "This is the level at which full benefits for this skill will be reached." +
"\nProperties of this skill may or may not scale with level, but those that do will gradually increase until max level is achieved.";
public final static String MAX_BONUS_PERCENTAGE_FIELD_NAME = "Max-Bonus-Percentage";
public final static String MAX_CHANCE_FIELD_DESCRIPTION = "The maximum probability for this skill to succeed.";
//Add the worlds to the list
static {
EXAMPLE_BLACKLIST_WORLDS_LIST_DEFAULT = new ArrayList<>();
EXAMPLE_BLACKLIST_WORLDS_LIST_DEFAULT.add(EXAMPLE_BLACKLIST_WORLDS[0]);
EXAMPLE_BLACKLIST_WORLDS_LIST_DEFAULT.add(EXAMPLE_BLACKLIST_WORLDS[1]);
EXAMPLE_BLACKLIST_WORLDS_LIST_DEFAULT.add(EXAMPLE_BLACKLIST_WORLDS[2]);
}
/**
* Return the data folder for mcMMO
*
* @return the File for the data folder used by mcMMO
*/
public static File getDataFolder(mcMMO pluginRef) {
return pluginRef.getDataFolder();
}
public static File getConfigFolder(mcMMO pluginRef) {
return new File(getDataFolder(pluginRef), FOLDER_NAME_CONFIG);
}
public static File getDefaultsFolder(mcMMO pluginRef) {
return new File(getConfigFolder(pluginRef).getAbsolutePath(), FOLDER_NAME_DEFAULTS);
}
public static File getDefaultsConfigFolder(mcMMO pluginRef) {
return new File(getDefaultsFolder(pluginRef).getAbsolutePath(), FOLDER_NAME_CONFIG);
}
public static File getDefaultsSkillFolder(mcMMO pluginRef) {
return new File(getDefaultsConfigFolder(pluginRef).getAbsolutePath(), FOLDER_NAME_SKILLS);
}
public static File getDefaultsXPFolder(mcMMO pluginRef) {
return new File(getDefaultsConfigFolder(pluginRef).getAbsolutePath(), FOLDER_NAME_EXPERIENCE);
}
public static File getConfigSkillFolder(mcMMO pluginRef) {
return new File(getConfigFolder(pluginRef).getAbsolutePath(), FOLDER_NAME_SKILLS);
}
public static File getConfigXPFolder(mcMMO pluginRef) {
return new File(getConfigFolder(pluginRef).getAbsolutePath(), FOLDER_NAME_EXPERIENCE);
}
/**
* Creates all directories used by mcMMO config files
*/
public static void makeAllConfigDirectories(mcMMO pluginRef) {
/* CONFIG DIRECTORY */
if (!getConfigFolder(pluginRef).exists())
getConfigFolder(pluginRef).mkdirs();
/* DEFAULT DIRECTORIES */
if (!getDefaultsFolder(pluginRef).exists())
getDefaultsFolder(pluginRef).mkdirs();
if (!getDefaultsConfigFolder(pluginRef).exists())
getDefaultsConfigFolder(pluginRef).mkdirs();
if (!getDefaultsSkillFolder(pluginRef).exists())
getDefaultsSkillFolder(pluginRef).mkdirs();
if (!getDefaultsXPFolder(pluginRef).exists())
getDefaultsXPFolder(pluginRef).mkdirs();
/* CONFIG SUBDIRECTORIES */
if (!getConfigSkillFolder(pluginRef).exists())
getConfigSkillFolder(pluginRef).mkdirs();
if (!getConfigXPFolder(pluginRef).exists())
getConfigXPFolder(pluginRef).mkdirs();
}
}

View File

@ -0,0 +1,509 @@
package com.gmail.nossr50.config;
import com.gmail.nossr50.config.hocon.SerializedConfigLoader;
import com.gmail.nossr50.config.hocon.admin.ConfigAdmin;
import com.gmail.nossr50.config.hocon.antiexploit.ConfigExploitPrevention;
import com.gmail.nossr50.config.hocon.backup.ConfigAutomatedBackups;
import com.gmail.nossr50.config.hocon.commands.ConfigCommands;
import com.gmail.nossr50.config.hocon.database.ConfigDatabase;
import com.gmail.nossr50.config.hocon.donation.ConfigAuthorAdvertisements;
import com.gmail.nossr50.config.hocon.event.ConfigEvent;
import com.gmail.nossr50.config.hocon.experience.ConfigExperience;
import com.gmail.nossr50.config.hocon.hardcore.ConfigHardcore;
import com.gmail.nossr50.config.hocon.items.ConfigItems;
import com.gmail.nossr50.config.hocon.language.ConfigLanguage;
import com.gmail.nossr50.config.hocon.metrics.ConfigMetrics;
import com.gmail.nossr50.config.hocon.mobs.ConfigMobs;
import com.gmail.nossr50.config.hocon.motd.ConfigMOTD;
import com.gmail.nossr50.config.hocon.notifications.ConfigNotifications;
import com.gmail.nossr50.config.hocon.notifications.PlayerNotificationSettings;
import com.gmail.nossr50.config.hocon.particles.ConfigParticles;
import com.gmail.nossr50.config.hocon.party.ConfigParty;
import com.gmail.nossr50.config.hocon.party.data.ConfigPartyData;
import com.gmail.nossr50.config.hocon.playerleveling.ConfigLeveling;
import com.gmail.nossr50.config.hocon.scoreboard.ConfigScoreboard;
import com.gmail.nossr50.config.hocon.serializers.*;
import com.gmail.nossr50.config.hocon.skills.acrobatics.ConfigAcrobatics;
import com.gmail.nossr50.config.hocon.skills.alchemy.ConfigAlchemy;
import com.gmail.nossr50.config.hocon.skills.archery.ConfigArchery;
import com.gmail.nossr50.config.hocon.skills.axes.ConfigAxes;
import com.gmail.nossr50.config.hocon.skills.coreskills.ConfigCoreSkills;
import com.gmail.nossr50.config.hocon.skills.exampleconfigs.ConfigNameRegisterDefaults;
import com.gmail.nossr50.config.hocon.skills.exampleconfigs.MinecraftMaterialWrapper;
import com.gmail.nossr50.config.hocon.skills.excavation.ConfigExcavation;
import com.gmail.nossr50.config.hocon.skills.fishing.ConfigFishing;
import com.gmail.nossr50.config.hocon.skills.herbalism.ConfigHerbalism;
import com.gmail.nossr50.config.hocon.skills.mining.ConfigMining;
import com.gmail.nossr50.config.hocon.skills.ranks.ConfigRanks;
import com.gmail.nossr50.config.hocon.skills.ranks.SkillRankProperty;
import com.gmail.nossr50.config.hocon.skills.repair.ConfigRepair;
import com.gmail.nossr50.config.hocon.skills.salvage.ConfigSalvage;
import com.gmail.nossr50.config.hocon.skills.smelting.ConfigSmelting;
import com.gmail.nossr50.config.hocon.skills.swords.ConfigSwords;
import com.gmail.nossr50.config.hocon.skills.taming.ConfigTaming;
import com.gmail.nossr50.config.hocon.skills.unarmed.ConfigUnarmed;
import com.gmail.nossr50.config.hocon.skills.woodcutting.ConfigWoodcutting;
import com.gmail.nossr50.config.hocon.sound.ConfigSound;
import com.gmail.nossr50.config.hocon.sound.SoundSetting;
import com.gmail.nossr50.config.hocon.superabilities.ConfigSuperAbilities;
import com.gmail.nossr50.config.hocon.worldblacklist.ConfigWorldBlacklist;
import com.gmail.nossr50.datatypes.experience.CustomXPPerk;
import com.gmail.nossr50.datatypes.experience.FormulaType;
import com.gmail.nossr50.datatypes.items.ItemMatch;
import com.gmail.nossr50.datatypes.items.ItemWildcards;
import com.gmail.nossr50.datatypes.items.MMOItem;
import com.gmail.nossr50.datatypes.party.PartyFeature;
import com.gmail.nossr50.datatypes.skills.PrimarySkillType;
import com.gmail.nossr50.datatypes.skills.properties.DamageProperty;
import com.gmail.nossr50.datatypes.skills.properties.MaxBonusLevel;
import com.gmail.nossr50.datatypes.skills.subskills.taming.TamingSummon;
import com.gmail.nossr50.mcMMO;
import com.gmail.nossr50.skills.repair.RepairTransaction;
import com.gmail.nossr50.skills.repair.SimpleRepairCost;
import com.gmail.nossr50.skills.repair.repairables.Repairable;
import com.gmail.nossr50.skills.salvage.salvageables.Salvageable;
import com.gmail.nossr50.util.nbt.RawNBT;
import com.google.common.reflect.TypeToken;
import ninja.leaping.configurate.commented.CommentedConfigurationNode;
import ninja.leaping.configurate.objectmapping.serialize.TypeSerializerCollection;
import ninja.leaping.configurate.objectmapping.serialize.TypeSerializers;
import org.bukkit.Material;
import java.io.File;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.Set;
/**
* The Config Manager handles initializing, loading, and unloading registers for all configs that mcMMO uses
* This makes sure that mcMMO properly loads and unloads its values on reload
* Settings in configs are sometimes not platform-ready, you can find platform ready implementations in the {@link com.gmail.nossr50.core.DynamicSettingsManager DynamicSettingsManager}
*/
public final class ConfigManager {
private final mcMMO pluginRef;
/* File array - Used for backups */
private ArrayList<File> userFiles;
/* Custom Serialization */
private TypeSerializerCollection customSerializers;
/* CONFIG INSTANCES */
private SerializedConfigLoader<ConfigDatabase> configDatabase;
private SerializedConfigLoader<ConfigScoreboard> configScoreboard;
private SerializedConfigLoader<ConfigLeveling> configLeveling;
private SerializedConfigLoader<ConfigWorldBlacklist> configWorldBlacklist;
private SerializedConfigLoader<ConfigExploitPrevention> configExploitPrevention;
private SerializedConfigLoader<ConfigHardcore> configHardcore;
private SerializedConfigLoader<ConfigMetrics> configMetrics;
private SerializedConfigLoader<ConfigMOTD> configMOTD;
private SerializedConfigLoader<ConfigAuthorAdvertisements> configAuthorAdvertisements;
private SerializedConfigLoader<ConfigAutomatedBackups> configAutomatedBackups;
private SerializedConfigLoader<ConfigCommands> configCommands;
private SerializedConfigLoader<ConfigItems> configItems;
private SerializedConfigLoader<ConfigLanguage> configLanguage;
private SerializedConfigLoader<ConfigParticles> configParticles;
private SerializedConfigLoader<ConfigParty> configParty;
private SerializedConfigLoader<ConfigNotifications> configNotifications;
private SerializedConfigLoader<ConfigSuperAbilities> configSuperAbilities;
private SerializedConfigLoader<ConfigAdmin> configAdmin;
private SerializedConfigLoader<ConfigMobs> configMobs;
private SerializedConfigLoader<ConfigExperience> configExperience;
private SerializedConfigLoader<ConfigCoreSkills> configCoreSkills;
private SerializedConfigLoader<ConfigEvent> configEvent;
private SerializedConfigLoader<ConfigRanks> configRanks;
private SerializedConfigLoader<ConfigSound> configSound;
private SerializedConfigLoader<ConfigNameRegisterDefaults> configDefaultExamples;
private ConfigAcrobatics configAcrobatics;
private ConfigAlchemy configAlchemy;
private ConfigArchery configArchery;
private ConfigAxes configAxes;
private ConfigExcavation configExcavation;
private ConfigFishing configFishing;
private ConfigHerbalism configHerbalism;
private ConfigMining configMining;
private ConfigRepair configRepair;
private ConfigSwords configSwords;
private ConfigTaming configTaming;
private ConfigUnarmed configUnarmed;
private ConfigWoodcutting configWoodcutting;
private ConfigSmelting configSmelting;
private ConfigSalvage configSalvage;
private HashMap<PrimarySkillType, SerializedConfigLoader<?>> skillConfigLoaders;
//Data
private SerializedConfigLoader<ConfigPartyData> partyData;
public ConfigManager(mcMMO pluginRef) {
this.pluginRef = pluginRef;
userFiles = new ArrayList<>();
}
public void loadConfigs() {
//Register Custom Serializers
registerCustomTypeSerializers();
//Serialized Configs
initSerializedConfigs();
//Serialized Data
initSerializedDataFiles();
}
private void initSerializedDataFiles() {
partyData = new SerializedConfigLoader<>(pluginRef, ConfigPartyData.class, "partydata.conf", "PartyData", null);
}
private void initSerializedConfigs() {
//There's some race conditions here because mcMMO is goddamn spaghetti mess, language has to load first
configLanguage = new SerializedConfigLoader<>(pluginRef, ConfigLanguage.class, "language.conf", "Language", null);
/*
* No more race conditions
*/
configDatabase = new SerializedConfigLoader<>(pluginRef, ConfigDatabase.class, "database_settings.conf", "Database", null);
configScoreboard = new SerializedConfigLoader<>(pluginRef, ConfigScoreboard.class, "scoreboard.conf", "Scoreboard", null);
configLeveling = new SerializedConfigLoader<>(pluginRef, ConfigLeveling.class, "player_leveling.conf", "Player-Leveling", null);
configWorldBlacklist = new SerializedConfigLoader<>(pluginRef, ConfigWorldBlacklist.class, "world_blacklist.conf", "World-Blacklist", null);
configExploitPrevention = new SerializedConfigLoader<>(pluginRef, ConfigExploitPrevention.class, "anti_exploit.conf", "Anti-Exploit", null);
configMOTD = new SerializedConfigLoader<>(pluginRef, ConfigMOTD.class, "message_of_the_day.conf", "MOTD", null);
configHardcore = new SerializedConfigLoader<>(pluginRef, ConfigHardcore.class, "hardcore_mode.conf", "Hardcore-Mode", null);
configMetrics = new SerializedConfigLoader<>(pluginRef, ConfigMetrics.class, "analytics_reporting.conf", "Analytic-Reporting", null);
configAuthorAdvertisements = new SerializedConfigLoader<>(pluginRef, ConfigAuthorAdvertisements.class, "author_support_advertisements.conf", "mcMMO", null);
configAutomatedBackups = new SerializedConfigLoader<>(pluginRef, ConfigAutomatedBackups.class, "automated_backups.conf", "Automated-Backups", null);
configCommands = new SerializedConfigLoader<>(pluginRef, ConfigCommands.class, "commands.conf", "Commands", null);
configItems = new SerializedConfigLoader<>(pluginRef, ConfigItems.class, "custom_items.conf", "Items", null);
configParticles = new SerializedConfigLoader<>(pluginRef, ConfigParticles.class, "particle_spawning.conf", "Particles", null);
configParty = new SerializedConfigLoader<>(pluginRef, ConfigParty.class, "party.conf", "Party", null);
configNotifications = new SerializedConfigLoader<>(pluginRef, ConfigNotifications.class, "alerts_and_notifications.conf", "Notifications", null);
configSuperAbilities = new SerializedConfigLoader<>(pluginRef, ConfigSuperAbilities.class, "skill_super_abilities.conf", "Super-Abilities", null);
configAdmin = new SerializedConfigLoader<>(pluginRef, ConfigAdmin.class, "admin.conf", "Admin", null);
configMobs = new SerializedConfigLoader<>(pluginRef, ConfigMobs.class, "creatures.conf", "Creatures", null);
configExperience = new SerializedConfigLoader<>(pluginRef, ConfigExperience.class, "experience.conf", "Experience", null);
configCoreSkills = new SerializedConfigLoader<>(pluginRef, ConfigCoreSkills.class, "core_skills.conf", "Core-Skills", null);
configEvent = new SerializedConfigLoader<>(pluginRef, ConfigEvent.class, "events.conf", "Events", null);
configRanks = new SerializedConfigLoader<>(pluginRef, ConfigRanks.class, "ranks.conf", "Skill-Ranks", null);
configSound = new SerializedConfigLoader<>(pluginRef, ConfigSound.class, "sounds.conf", "Sounds", null);
configDefaultExamples = new SerializedConfigLoader<>(pluginRef, ConfigNameRegisterDefaults.class, "minecraft_item_block_name_examples.conf", "Minecraft", null);
initSerializedSkillConfigs();
}
@SuppressWarnings(value = "unchecked")
private void initSerializedSkillConfigs() {
//Init HashMap
skillConfigLoaders = new HashMap<>();
//Init and register serialized skill configs
registerSkillConfig(PrimarySkillType.ACROBATICS, ConfigAcrobatics.class);
registerSkillConfig(PrimarySkillType.ALCHEMY, ConfigAlchemy.class);
registerSkillConfig(PrimarySkillType.SALVAGE, ConfigSalvage.class);
registerSkillConfig(PrimarySkillType.ARCHERY, ConfigArchery.class);
registerSkillConfig(PrimarySkillType.AXES, ConfigAxes.class);
registerSkillConfig(PrimarySkillType.EXCAVATION, ConfigExcavation.class);
registerSkillConfig(PrimarySkillType.FISHING, ConfigFishing.class);
registerSkillConfig(PrimarySkillType.HERBALISM, ConfigHerbalism.class);
registerSkillConfig(PrimarySkillType.MINING, ConfigMining.class);
registerSkillConfig(PrimarySkillType.REPAIR, ConfigRepair.class);
registerSkillConfig(PrimarySkillType.SWORDS, ConfigSwords.class);
registerSkillConfig(PrimarySkillType.TAMING, ConfigTaming.class);
registerSkillConfig(PrimarySkillType.UNARMED, ConfigUnarmed.class);
registerSkillConfig(PrimarySkillType.WOODCUTTING, ConfigWoodcutting.class);
registerSkillConfig(PrimarySkillType.SMELTING, ConfigSmelting.class);
//Setup Typed refs
configAcrobatics = (ConfigAcrobatics) skillConfigLoaders.get(PrimarySkillType.ACROBATICS).getConfig();
configAlchemy = (ConfigAlchemy) skillConfigLoaders.get(PrimarySkillType.ALCHEMY).getConfig();
configSalvage = (ConfigSalvage) skillConfigLoaders.get(PrimarySkillType.SALVAGE).getConfig();
configArchery = (ConfigArchery) skillConfigLoaders.get(PrimarySkillType.ARCHERY).getConfig();
configAxes = (ConfigAxes) skillConfigLoaders.get(PrimarySkillType.AXES).getConfig();
configExcavation = (ConfigExcavation) skillConfigLoaders.get(PrimarySkillType.EXCAVATION).getConfig();
configFishing = (ConfigFishing) skillConfigLoaders.get(PrimarySkillType.FISHING).getConfig();
configHerbalism = (ConfigHerbalism) skillConfigLoaders.get(PrimarySkillType.HERBALISM).getConfig();
configMining = (ConfigMining) skillConfigLoaders.get(PrimarySkillType.MINING).getConfig();
configRepair = (ConfigRepair) skillConfigLoaders.get(PrimarySkillType.REPAIR).getConfig();
configSwords = (ConfigSwords) skillConfigLoaders.get(PrimarySkillType.SWORDS).getConfig();
configTaming = (ConfigTaming) skillConfigLoaders.get(PrimarySkillType.TAMING).getConfig();
configUnarmed = (ConfigUnarmed) skillConfigLoaders.get(PrimarySkillType.UNARMED).getConfig();
configWoodcutting = (ConfigWoodcutting) skillConfigLoaders.get(PrimarySkillType.WOODCUTTING).getConfig();
configSmelting = (ConfigSmelting) skillConfigLoaders.get(PrimarySkillType.SMELTING).getConfig();
}
private void registerCustomTypeSerializers() {
/*
TypeTokens are obtained in two ways
For Raw basic classes:
TypeToken<String> stringTok = TypeToken.of(String.class);
TypeToken<Integer> intTok = TypeToken.of(Integer.class);
For Generics:
TypeToken<List<String>> stringListTok = new TypeToken<List<String>>() {};
Wildcard example:
TypeToken<Map<?, ?>> wildMapTok = new TypeToken<Map<?, ?>>() {};
*/
customSerializers = TypeSerializers.getDefaultSerializers().newChild();
pluginRef.getLogger().info("Registering custom type serializers for Configurate...");
customSerializers.registerType(new TypeToken<PrimarySkillType>() {}, new CustomEnumValueSerializer());
customSerializers.registerType(new TypeToken<Material>() {}, new CustomEnumValueSerializer());
customSerializers.registerType(new TypeToken<PartyFeature>() {}, new CustomEnumValueSerializer());
customSerializers.registerType(new TypeToken<FormulaType>() {}, new CustomEnumValueSerializer());
customSerializers.registerType(new TypeToken<MMOItem<?>>() {}, new ItemStackSerializer());
customSerializers.registerType(new TypeToken<Set<?>>() {}, new SetSerializer());
customSerializers.registerType(new TypeToken<SimpleRepairCost>() {}, new SimpleRepairCostSerializer());
customSerializers.registerType(TypeToken.of(TamingSummon.class), new TamingSummonSerializer());
customSerializers.registerType(TypeToken.of(Repairable.class), new RepairableSerializer());
customSerializers.registerType(TypeToken.of(Salvageable.class), new SalvageableSerializer());
customSerializers.registerType(TypeToken.of(MinecraftMaterialWrapper.class), new MinecraftMaterialWrapperSerializer());
customSerializers.registerType(TypeToken.of(CustomXPPerk.class), new CustomXPPerkSerializer());
customSerializers.registerType(TypeToken.of(DamageProperty.class), new DamagePropertySerializer());
customSerializers.registerType(TypeToken.of(SkillRankProperty.class), new SkillRankPropertySerializer());
customSerializers.registerType(TypeToken.of(MaxBonusLevel.class), new MaxBonusLevelSerializer());
customSerializers.registerType(TypeToken.of(PlayerNotificationSettings.class), new PlayerNotificationSerializer());
customSerializers.registerType(TypeToken.of(SoundSetting.class), new SoundSettingSerializer());
customSerializers.registerType(TypeToken.of(ItemWildcards.class), new ItemWildcardSerializer());
customSerializers.registerType(TypeToken.of(ItemMatch.class), new CustomItemTargetSerializer());
customSerializers.registerType(TypeToken.of(RepairTransaction.class), new RepairTransactionSerializer());
customSerializers.registerType(TypeToken.of(RawNBT.class), new RawNBTSerializer());
}
/**
* Gets the serializers registered and used by mcMMO
* This includes all default serializers
*
* @return our custom serializers
*/
public TypeSerializerCollection getCustomSerializers() {
return customSerializers;
}
private void registerSkillConfig(PrimarySkillType primarySkillType, Class clazz) {
skillConfigLoaders.put(primarySkillType, SkillConfigFactory.initSkillConfig(pluginRef, primarySkillType, clazz));
}
/**
* Registers an unloadable
* Unloadables call unload() on plugin disable to cleanup registries
*/
public void registerUserFile(File userFile) {
if (!userFiles.contains(userFile))
userFiles.add(userFile);
}
public void validateConfigs() {
}
/**
* Reload the configs
* Technically this reloads a lot of stuff, not just configs
*/
public void reloadConfigs() {
pluginRef.getLogger().info("Reloading config values...");
loadConfigs(); //Load everything again
}
/*
* GETTER BOILER PLATE
*/
/**
* Used to back up our zip files real easily
*
* @return
*/
public ArrayList<File> getConfigFiles() {
return userFiles;
}
public ConfigCoreSkills getConfigCoreSkills() {
return configCoreSkills.getConfig();
}
public ConfigDatabase getConfigDatabase() {
return configDatabase.getConfig();
}
public ConfigScoreboard getConfigScoreboard() {
return configScoreboard.getConfig();
}
public ConfigLeveling getConfigLeveling() {
return configLeveling.getConfig();
}
public ConfigWorldBlacklist getConfigWorldBlacklist() {
return configWorldBlacklist.getConfig();
}
public ConfigExploitPrevention getConfigExploitPrevention() {
return configExploitPrevention.getConfig();
}
public ConfigMOTD getConfigMOTD() {
return configMOTD.getConfig();
}
public ConfigHardcore getConfigHardcore() {
return configHardcore.getConfig();
}
public ConfigMetrics getConfigMetrics() {
return configMetrics.getConfig();
}
public ConfigAuthorAdvertisements getConfigAds() {
return configAuthorAdvertisements.getConfig();
}
public ConfigAutomatedBackups getConfigAutomatedBackups() {
return configAutomatedBackups.getConfig();
}
public ConfigCommands getConfigCommands() {
return configCommands.getConfig();
}
public ConfigItems getConfigItems() {
return configItems.getConfig();
}
public ConfigLanguage getConfigLanguage() {
return configLanguage.getConfig();
}
public ConfigParticles getConfigParticles() {
return configParticles.getConfig();
}
public ConfigParty getConfigParty() {
return configParty.getConfig();
}
public ConfigNotifications getConfigNotifications() {
return configNotifications.getConfig();
}
public ConfigSuperAbilities getConfigSuperAbilities() {
return configSuperAbilities.getConfig();
}
public ConfigAdmin getConfigAdmin() {
return configAdmin.getConfig();
}
public ConfigMobs getConfigMobs() {
return configMobs.getConfig();
}
public ConfigAcrobatics getConfigAcrobatics() {
return configAcrobatics;
}
public ConfigAlchemy getConfigAlchemy() {
return configAlchemy;
}
public ConfigArchery getConfigArchery() {
return configArchery;
}
public ConfigAxes getConfigAxes() {
return configAxes;
}
public ConfigExcavation getConfigExcavation() {
return configExcavation;
}
public ConfigFishing getConfigFishing() {
return configFishing;
}
public ConfigHerbalism getConfigHerbalism() {
return configHerbalism;
}
public ConfigMining getConfigMining() {
return configMining;
}
public ConfigRepair getConfigRepair() {
return configRepair;
}
public ConfigSwords getConfigSwords() {
return configSwords;
}
public ConfigTaming getConfigTaming() {
return configTaming;
}
public ConfigUnarmed getConfigUnarmed() {
return configUnarmed;
}
public ConfigWoodcutting getConfigWoodcutting() {
return configWoodcutting;
}
public ConfigSmelting getConfigSmelting() {
return configSmelting;
}
public ConfigSalvage getConfigSalvage() {
return configSalvage;
}
public ConfigEvent getConfigEvent() {
return configEvent.getConfig();
}
public ConfigRanks getConfigRanks() {
return configRanks.getConfig();
}
public ConfigSound getConfigSound() {
return configSound.getConfig();
}
/**
* Used to programmatically grab rank data for skills
* @return root node for the ranks config file
*/
public CommentedConfigurationNode getConfigRanksRootNode() {
return configRanks.getRootNode();
}
/**
* Checks if this plugin is using retro mode
* Retro mode is a 0-1000 skill system
* Standard mode is scaled for 1-100
*
* @return true if retro mode is enabled
*/
public boolean isRetroMode() {
return getConfigLeveling().getConfigSectionLevelingGeneral().getConfigSectionLevelScaling().isRetroModeEnabled();
}
public ConfigExperience getConfigExperience() {
return configExperience.getConfig();
}
public SerializedConfigLoader<?> getSkillConfigLoader(PrimarySkillType primarySkillType) {
return skillConfigLoaders.get(primarySkillType);
}
}

View File

@ -0,0 +1,16 @@
package com.gmail.nossr50.config;
import com.gmail.nossr50.config.hocon.SerializedConfigLoader;
import com.gmail.nossr50.datatypes.skills.PrimarySkillType;
import com.gmail.nossr50.mcMMO;
import com.gmail.nossr50.util.StringUtils;
public class SkillConfigFactory {
protected static SerializedConfigLoader initSkillConfig(mcMMO pluginRef, PrimarySkillType primarySkillType, Class<?> clazz) {
return new SerializedConfigLoader(pluginRef, clazz,
primarySkillType.toString().toLowerCase() + ".conf",
StringUtils.getCapitalized(primarySkillType.toString()),
null);
}
}

View File

@ -0,0 +1,340 @@
//package com.gmail.nossr50.config.experience;
//
//import com.gmail.nossr50.config.AutoUpdateConfigLoader;
//import com.gmail.nossr50.datatypes.experience.FormulaType;
//import com.gmail.nossr50.datatypes.skills.MaterialType;
//import com.gmail.nossr50.datatypes.skills.PrimarySkillType;
//import com.gmail.nossr50.datatypes.skills.alchemy.PotionStage;
//import com.gmail.nossr50.util.StringUtils;
//import org.bukkit.Material;
//import org.bukkit.block.data.BlockData;
//import org.bukkit.boss.BarColor;
//import org.bukkit.boss.BarStyle;
//import org.bukkit.entity.EntityType;
//
//import java.util.ArrayList;
//import java.util.List;
//
//public class ExperienceConfig extends AutoUpdateConfigLoader {
// private static ExperienceConfig instance;
//
// private ExperienceConfig() {
// super("experience.yml");
// validate();
// }
//
// public static ExperienceConfig getInstance() {
// if (instance == null) {
// instance = new ExperienceConfig();
// }
//
// return instance;
// }
//
// @Override
// protected void loadKeys() {}
//
// @Override
// protected boolean validateKeys() {
// List<String> reason = new ArrayList<String>();
//
// /*
// * FORMULA SETTINGS
// */
//
// /* Curve values */
// if (getMultiplier(FormulaType.EXPONENTIAL) <= 0) {
// reason.add("Experience_Formula.Exponential_Values.multiplier should be greater than 0!");
// }
//
// if (getMultiplier(FormulaType.LINEAR) <= 0) {
// reason.add("Experience_Formula.Linear_Values.multiplier should be greater than 0!");
// }
//
// if (getExponent(FormulaType.EXPONENTIAL) <= 0) {
// reason.add("Experience_Formula.Exponential_Values.exponent should be greater than 0!");
// }
//
// /* Global modifier */
// if (getExperienceGainsGlobalMultiplier() <= 0) {
// reason.add("Experience_Formula.Multiplier.Global should be greater than 0!");
// }
//
// /* PVP modifier */
// if (getPlayerVersusPlayerXP() < 0) {
// reason.add("Experience_Formula.Multiplier.PVP should be at least 0!");
// }
//
// /* Spawned Mob modifier */
// if (getSpawnedMobXpMultiplier() < 0) {
// reason.add("Experience_Formula.Mobspawners.Multiplier should be at least 0!");
// }
//
// /* Bred Mob modifier */
// if (getBredMobXpMultiplier() < 0) {
// reason.add("Experience_Formula.Breeding.Multiplier should be at least 0!");
// }
//
// /* Conversion */
// if (getExpModifier() <= 0) {
// reason.add("Conversion.Exp_Modifier should be greater than 0!");
// }
//
// /*
// * XP SETTINGS
// */
//
// /* Alchemy */
// for (PotionStage potionStage : PotionStage.values()) {
// if (getPotionXP(potionStage) < 0) {
// reason.add("Experience_Values.Alchemy.Potion_Stage_" + potionStage.toNumerical() + " should be at least 0!");
// }
// }
//
// /* Archery */
// if (getArcheryDistanceMultiplier() < 0) {
// reason.add("Experience_Values.Archery.Distance_Multiplier should be at least 0!");
// }
//
// /* Combat XP Multipliers */
// if (getAnimalsXP() < 0) {
// reason.add("Experience_Values.Combat.Multiplier.Animals should be at least 0!");
// }
//
// if (getDodgeXPModifier() < 0) {
// reason.add("Skills.Acrobatics.Dodge_XP_Modifier should be at least 0!");
// }
//
// if (getRollXPModifier() < 0) {
// reason.add("Skills.Acrobatics.Roll_XP_Modifier should be at least 0!");
// }
//
// if (getFallXPModifier() < 0) {
// reason.add("Skills.Acrobatics.Fall_XP_Modifier should be at least 0!");
// }
//
// /* Fishing */
// // TODO: Add validation for each fish type once enum is available.
//
// if (getFishingShakeXP() <= 0) {
// reason.add("Experience_Values.Fishing.Shake should be greater than 0!");
// }
//
// /* Repair */
// if (getRepairXPBase() <= 0) {
// reason.add("Experience_Values.Repair.Base should be greater than 0!");
// }
//
// /* Taming */
// if (getTamingXP(EntityType.WOLF) <= 0) {
// reason.add("Experience_Values.Taming.Animal_Taming.Wolf should be greater than 0!");
// }
//
// if (getTamingXP(EntityType.OCELOT) <= 0) {
// reason.add("Experience_Values.Taming.Animal_Taming.Ocelot should be greater than 0!");
// }
//
// return noErrorsInConfig(reason);
// }
//
// public boolean isEarlyGameBoostEnabled() { return config.getBoolean("EarlyGameBoost.Enabled", true); }
//
// /*
// * FORMULA SETTINGS
// */
//
// /* EXPLOIT TOGGLES */
// public boolean isEndermanEndermiteFarmingPrevented() { return config.getBoolean("ExploitFix.EndermanEndermiteFarms", true); }
// public boolean isPistonCheatingPrevented() { return config.getBoolean("ExploitFix.PistonCheating", true); }
// public boolean isPistonExploitPrevented() { return config.getBoolean("ExploitFix.Pistons", false); }
// public boolean allowUnsafeEnchantments() { return config.getBoolean("ExploitFix.UnsafeEnchantments", false); }
// public boolean isCOTWBreedingPrevented() { return config.getBoolean("ExploitFix.COTWBreeding", true); }
//
// public boolean isFishingExploitingPrevented() { return config.getBoolean("ExploitFix.Fishing", true); }
// public boolean isAcrobaticsExploitingPrevented() { return config.getBoolean("ExploitFix.Acrobatics", true); }
// public boolean isTreeFellerXPReduced() { return config.getBoolean("ExploitFix.TreeFellerReducedXP", true); }
//
// /* Curve settings */
// public FormulaType getFormulaType() { return FormulaType.getFormulaType(config.getString("Experience_Formula.Curve")); }
// public boolean getCumulativeCurveEnabled() { return config.getBoolean("Experience_Formula.Cumulative_Curve", false); }
//
// /* Curve values */
// public double getMultiplier(FormulaType type) { return config.getDouble("Experience_Formula." + StringUtils.getCapitalized(type.toString()) + "_Values.multiplier"); }
// public int getBase(FormulaType type) { return config.getInt("Experience_Formula." + StringUtils.getCapitalized(type.toString()) + "_Values.base"); }
// public double getExponent(FormulaType type) { return config.getDouble("Experience_Formula." + StringUtils.getCapitalized(type.toString()) + "_Values.exponent"); }
//
// /* Global modifier */
// public double getExperienceGainsGlobalMultiplier() { return config.getDouble("Experience_Formula.Multiplier.Global", 1.0); }
// public void setExperienceGainsGlobalMultiplier(double value) { config.set("Experience_Formula.Multiplier.Global", value); }
//
// /* PVP modifier */
// public double getPlayerVersusPlayerXP() { return config.getDouble("Experience_Formula.Multiplier.PVP", 1.0); }
//
// /* Spawned Mob modifier */
// public double getSpawnedMobXpMultiplier() { return config.getDouble("Experience_Formula.Mobspawners.Multiplier", 0.0); }
// public double getBredMobXpMultiplier() { return config.getDouble("Experience_Formula.Breeding.Multiplier", 1.0); }
//
// /* Skill modifiers */
// public double getFormulaSkillModifier(PrimarySkillType skill) { return config.getDouble("Experience_Formula.Modifier." + StringUtils.getCapitalized(skill.toString())); }
//
// /* Custom XP perk */
// public double getCustomXpPerkBoost() { return config.getDouble("Experience_Formula.Custom_XP_Perk.Boost", 1.25); }
//
// /* Diminished Returns */
// public float getDiminishedReturnsCap() { return (float) config.getDouble("Dimished_Returns.Guaranteed_Minimum_Percentage", 0.05D); }
// public boolean getDiminishedReturnsEnabled() { return config.getBoolean("Diminished_Returns.Enabled", false); }
// public int getDiminishedReturnsThreshold(PrimarySkillType skill) { return config.getInt("Diminished_Returns.Threshold." + StringUtils.getCapitalized(skill.toString()), 20000); }
// public int getDiminishedReturnsTimeInterval() { return config.getInt("Diminished_Returns.Time_Interval", 10); }
//
// /* Conversion */
// public double getExpModifier() { return config.getDouble("Conversion.Exp_Modifier", 1); }
//
// /*
// * XP SETTINGS
// */
//
// /* General Settings */
// public boolean getExperienceGainsPlayerVersusPlayerEnabled() { return config.getBoolean("Experience_Values.PVP.Rewards", true); }
//
// /* Combat XP Multipliers */
// public double getCombatXP(EntityType entity) { return config.getDouble("Experience_Values.Combat.Multiplier." + StringUtils.getPrettyEntityTypeString(entity).replace(" ", "_")); }
// public double getAnimalsXP(EntityType entity) { return config.getDouble("Experience_Values.Combat.Multiplier." + StringUtils.getPrettyEntityTypeString(entity).replace(" ", "_"), getAnimalsXP()); }
// public double getAnimalsXP() { return config.getDouble("Experience_Values.Combat.Multiplier.Animals", 1.0); }
// public boolean hasCombatXP(EntityType entity) {return config.contains("Experience_Values.Combat.Multiplier." + StringUtils.getPrettyEntityTypeString(entity).replace(" ", "_")); }
//
// /* Materials */
// public int getXp(PrimarySkillType skill, Material data)
// {
// String baseString = "Experience_Values." + StringUtils.getCapitalized(skill.toString()) + ".";
// String explicitString = baseString + StringUtils.getExplicitConfigMaterialString(data);
// if (config.contains(explicitString))
// return config.getInt(explicitString);
// String friendlyString = baseString + StringUtils.getFriendlyConfigMaterialString(data);
// if (config.contains(friendlyString))
// return config.getInt(friendlyString);
// String wildcardString = baseString + StringUtils.getWildcardConfigMaterialString(data);
// if (config.contains(wildcardString))
// return config.getInt(wildcardString);
// return 0;
// }
//
// /* Materials */
// public int getXp(PrimarySkillType skill, BlockData data)
// {
// String baseString = "Experience_Values." + StringUtils.getCapitalized(skill.toString()) + ".";
// String explicitString = baseString + StringUtils.getExplicitConfigBlockDataString(data);
// if (config.contains(explicitString))
// return config.getInt(explicitString);
// String friendlyString = baseString + StringUtils.getFriendlyConfigBlockDataString(data);
// if (config.contains(friendlyString))
// return config.getInt(friendlyString);
// String wildcardString = baseString + StringUtils.getWildcardConfigBlockDataString(data);
// if (config.contains(wildcardString))
// return config.getInt(wildcardString);
// return 0;
// }
//
// public boolean doesBlockGiveSkillXP(PrimarySkillType skill, Material data)
// {
// String baseString = "Experience_Values." + StringUtils.getCapitalized(skill.toString()) + ".";
// String explicitString = baseString + StringUtils.getExplicitConfigMaterialString(data);
// if (config.contains(explicitString))
// return true;
// String friendlyString = baseString + StringUtils.getFriendlyConfigMaterialString(data);
// if (config.contains(friendlyString))
// return true;
// String wildcardString = baseString + StringUtils.getWildcardConfigMaterialString(data);
// return config.contains(wildcardString);
// }
//
// public boolean doesBlockGiveSkillXP(PrimarySkillType skill, BlockData data)
// {
// String baseString = "Experience_Values." + StringUtils.getCapitalized(skill.toString()) + ".";
// String explicitString = baseString + StringUtils.getExplicitConfigBlockDataString(data);
// if (config.contains(explicitString))
// return true;
// String friendlyString = baseString + StringUtils.getFriendlyConfigBlockDataString(data);
// if (config.contains(friendlyString))
// return true;
// String wildcardString = baseString + StringUtils.getWildcardConfigBlockDataString(data);
// return config.contains(wildcardString);
// }
//
// /*
// * Experience Bar Stuff
// */
//
// public boolean isPartyExperienceBarsEnabled()
// {
// return config.getBoolean("Experience_Bars.Update.Party", true);
// }
//
// public boolean isPassiveGainsExperienceBarsEnabled()
// {
// return config.getBoolean("Experience_Bars.Update.Passive", true);
// }
//
// public boolean getDoExperienceBarsAlwaysUpdateTitle()
// {
// return config.getBoolean("Experience_Bars.ThisMayCauseLag.AlwaysUpdateTitlesWhenXPIsGained.Enable", false) || getAddExtraDetails();
// }
//
// public boolean getAddExtraDetails() { return config.getBoolean("Experience_Bars.ThisMayCauseLag.AlwaysUpdateTitlesWhenXPIsGained.ExtraDetails", false);}
// public boolean isExperienceBarsEnabled() { return config.getBoolean("Experience_Bars.Enable", true); }
// public boolean isExperienceBarEnabled(PrimarySkillType primarySkillType) { return config.getBoolean("Experience_Bars."+StringUtils.getCapitalized(primarySkillType.toString())+".Enable", true);}
//
// public BarColor getExperienceBarColor(PrimarySkillType primarySkillType)
// {
// String colorValueFromConfig = config.getString("Experience_Bars."+StringUtils.getCapitalized(primarySkillType.toString())+".Color");
//
// for(BarColor barColor : BarColor.values())
// {
// if(barColor.toString().equalsIgnoreCase(colorValueFromConfig))
// return barColor;
// }
//
// //In case the value is invalid
// return BarColor.WHITE;
// }
//
// public BarStyle getExperienceBarStyle(PrimarySkillType primarySkillType)
// {
// String colorValueFromConfig = config.getString("Experience_Bars."+StringUtils.getCapitalized(primarySkillType.toString())+".BarStyle");
//
// for(BarStyle barStyle : BarStyle.values())
// {
// if(barStyle.toString().equalsIgnoreCase(colorValueFromConfig))
// return barStyle;
// }
//
// //In case the value is invalid
// return BarStyle.SOLID;
// }
//
// /* Acrobatics */
// public int getDodgeXPModifier() { return config.getInt("Experience_Values.Acrobatics.Dodge", 120); }
// public int getRollXPModifier() { return config.getInt("Experience_Values.Acrobatics.Roll", 80); }
// public int getFallXPModifier() { return config.getInt("Experience_Values.Acrobatics.Fall", 120); }
//
// public double getFeatherFallXPModifier() { return config.getDouble("Experience_Values.Acrobatics.FeatherFall_Multiplier", 2.0); }
//
// /* Alchemy */
// public double getPotionXP(PotionStage stage) { return config.getDouble("Experience_Values.Alchemy.Potion_Stage_" + stage.toNumerical(), 10D); }
//
// /* Archery */
// public double getArcheryDistanceMultiplier() { return config.getDouble("Experience_Values.Archery.Distance_Multiplier", 0.025); }
//
// public int getFishingShakeXP() { return config.getInt("Experience_Values.Fishing.Shake", 50); }
//
// /* Repair */
// public double getRepairXPBase() { return config.getDouble("Experience_Values.Repair.Base", 1000.0); }
// public double getRepairXP(MaterialType repairMaterialType) { return config.getDouble("Experience_Values.Repair." + StringUtils.getCapitalized(repairMaterialType.toString())); }
//
// /* Taming */
// public int getTamingXP(EntityType type)
// {
// return config.getInt("Experience_Values.Taming.Animal_Taming." + StringUtils.getPrettyEntityTypeString(type));
// }
//
// public boolean preventStoneLavaFarming() { return config.getBoolean("ExploitFix.LavaStoneAndCobbleFarming", true);}
//}

View File

@ -0,0 +1,9 @@
package com.gmail.nossr50.config.hocon;
import ninja.leaping.configurate.objectmapping.serialize.ConfigSerializable;
@ConfigSerializable
public class General {
}

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