Merge branch 'mcMMO-Dev:master' into master

This commit is contained in:
Mads U. Jensen 2022-02-09 21:33:28 +01:00 committed by GitHub
commit 33b801b3e5
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
488 changed files with 39766 additions and 28203 deletions

52
.github/workflows/maven.yml vendored Normal file
View File

@ -0,0 +1,52 @@
# This workflow automatically tests new commits and pull requests as they come in.
# Note that this does not upload any artifacts, you will need to compile mcMMO manually
# if you wish to create the actual jar.
name: Compile and test
on:
# We run our tests whenever the pom or a source file was touched.
# There is no need to run Maven when only the changelog was touched.
# We may also want to re-run this workflow when the workflow file itself
# was updated too.
push:
paths:
- 'src/**'
- 'pom.xml'
- '.github/workflows/maven.yml'
# Whenever someone submits a new pull request which modified the pom or a source file,
# we want to ensure it compiles successfully and that all tests will pass.
pull_request:
paths:
- 'src/**'
- 'pom.xml'
jobs:
compile:
name: Maven compiler
runs-on: ubuntu-latest
steps:
# 1. Check out the current working tree
- name: Checkout repository
uses: actions/checkout@v2
# 2. Setup Java 17 JDK (Adopt)
- name: Java 17 setup
uses: actions/setup-java@v2
with:
distribution: 'adopt'
java-package: jdk
java-version: '17'
# 3. Setup local Maven package cache to speed up building
- name: Cache Maven packages
uses: actions/cache@v2
with:
path: ~/.m2
key: ${{ runner.os }}-m2-${{ hashFiles('**/pom.xml') }}
restore-keys: ${{ runner.os }}-m2
# 4. Build via Maven
- name: Build via Maven
run: mvn verify -B --file pom.xml

11
1
View File

@ -1,11 +0,0 @@
SkillShot tweaks
# Please enter the commit message for your changes. Lines starting
# with '#' will be ignored, and an empty message aborts the commit.
#
# On branch master
# Your branch is up to date with 'origin/master'.
#
# Changes to be committed:
# modified: src/main/java/com/gmail/nossr50/skills/archery/Archery.java
# modified: src/main/java/com/gmail/nossr50/util/skills/CombatUtils.java
#

File diff suppressed because it is too large Load Diff

View File

@ -99,10 +99,6 @@ Woodcutting:
Double_Drops_Enabled: true Double_Drops_Enabled: true
Is_Log: true Is_Log: true
# Fir Quarters # Fir Quarters
X2209|1:
XP_Gain: 80
Double_Drops_Enabled: true
Is_Log: true
X2211|1: X2211|1:
XP_Gain: 100 XP_Gain: 100
Double_Drops_Enabled: true Double_Drops_Enabled: true
@ -116,10 +112,6 @@ Woodcutting:
Double_Drops_Enabled: true Double_Drops_Enabled: true
Is_Log: true Is_Log: true
# Oak Quarters # Oak Quarters
X2209|2:
XP_Gain: 70
Double_Drops_Enabled: true
Is_Log: true
X2211|2: X2211|2:
XP_Gain: 100 XP_Gain: 100
Double_Drops_Enabled: true Double_Drops_Enabled: true
@ -133,15 +125,7 @@ Woodcutting:
Double_Drops_Enabled: true Double_Drops_Enabled: true
Is_Log: true Is_Log: true
# Acacia # Acacia
X2209|1: # Cypress
XP_Gain: 80
Double_Drops_Enabled: true
Is_Log: true
# Cypress
X2209|2:
XP_Gain: 90
Double_Drops_Enabled: true
Is_Log: true
# Bald Cypress Quarter # Bald Cypress Quarter
X2225|0: X2225|0:
XP_Gain: 90 XP_Gain: 90

View File

@ -366,25 +366,7 @@ Axes:
### ###
Bows: Bows:
#Bow_1 #Bow_1
X999:
XP_Modifer: 1.0
Ability_Enabled: true
Tier: 1
Repairable: true
Repair_Material: X99
Repair_Material_Data_Value: 0
Repair_Material_Quantity: 9
Durability: 9999
#Bow_2 #Bow_2
X999:
XP_Modifer: 1.0
Ability_Enabled: true
Tier: 1
Repairable: true
Repair_Material: X99
Repair_Material_Data_Value: 0
Repair_Material_Quantity: 9
Durability: 9999
# #
# Settings for Hoes # Settings for Hoes

View File

@ -68,17 +68,7 @@ Chestplates:
Repair_Material_Quantity: 8 Repair_Material_Quantity: 8
Durability: 320 Durability: 320
# Knightmetal # Knightmetal
X28035:
Repairable: true
Repair_Material: X28032
Repair_Material_Pretty_Name: "Knightmetal Ingot"
Repair_Material_Data_Value: 0
Repair_Material_Quantity: 8
Durability: 320
# Phantom # Phantom
X28035:
Repairable: false
Durability: 480
Helmets: Helmets:
# Ironwood # Ironwood
@ -106,17 +96,7 @@ Helmets:
Repair_Material_Quantity: 5 Repair_Material_Quantity: 5
Durability: 220 Durability: 220
# Knightmetal # Knightmetal
X28034:
Repairable: true
Repair_Material: X28032
Repair_Material_Pretty_Name: "Knightmetal Ingot"
Repair_Material_Data_Value: 0
Repair_Material_Quantity: 5
Durability: 220
# Phantom # Phantom
X28034:
Repairable: false
Durability: 330
Leggings: Leggings:
# Ironwood # Ironwood

196
pom.xml
View File

@ -2,7 +2,7 @@
<modelVersion>4.0.0</modelVersion> <modelVersion>4.0.0</modelVersion>
<groupId>com.gmail.nossr50.mcMMO</groupId> <groupId>com.gmail.nossr50.mcMMO</groupId>
<artifactId>mcMMO</artifactId> <artifactId>mcMMO</artifactId>
<version>2.1.126-SNAPSHOT</version> <version>2.1.210-SNAPSHOT</version>
<name>mcMMO</name> <name>mcMMO</name>
<url>https://github.com/mcMMO-Dev/mcMMO</url> <url>https://github.com/mcMMO-Dev/mcMMO</url>
<scm> <scm>
@ -11,11 +11,29 @@
<developerConnection>scm:git:git@github.com:mcMMO-Dev/mcMMO.git</developerConnection> <developerConnection>scm:git:git@github.com:mcMMO-Dev/mcMMO.git</developerConnection>
<tag>HEAD</tag> <tag>HEAD</tag>
</scm> </scm>
<properties>
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
<maven.compiler.source>16</maven.compiler.source>
<maven.compiler.target>16</maven.compiler.target>
<java.version>16</java.version>
</properties>
<issueManagement> <issueManagement>
<url>https://github.com/mcMMO-Dev/mcMMO/issues</url> <url>https://github.com/mcMMO-Dev/mcMMO/issues</url>
<system>GitHub</system> <system>GitHub</system>
</issueManagement> </issueManagement>
<packaging>jar</packaging> <packaging>jar</packaging>
<distributionManagement>
<repository>
<id>neetgames</id>
<url>https://nexus.neetgames.com/repository/maven-releases/</url>
</repository>
<snapshotRepository>
<id>neetgames</id>
<url>https://nexus.neetgames.com/repository/maven-snapshots/</url>
</snapshotRepository>
</distributionManagement>
<build> <build>
<finalName>${project.artifactId}</finalName> <finalName>${project.artifactId}</finalName>
<sourceDirectory>${basedir}/src/main/java</sourceDirectory> <sourceDirectory>${basedir}/src/main/java</sourceDirectory>
@ -55,6 +73,25 @@
</resource> </resource>
</resources> </resources>
<plugins> <plugins>
<plugin>
<artifactId>maven-surefire-plugin</artifactId>
<version>3.0.0-M5</version>
<configuration>
<junitArtifactName>org.junit.jupiter:junit-jupiter</junitArtifactName>
<trimStackTrace>false</trimStackTrace>
</configuration>
</plugin>
<plugin>
<artifactId>maven-failsafe-plugin</artifactId>
<version>3.0.0-M5</version>
<configuration>
<junitArtifactName>org.junit.jupiter:junit-jupiter</junitArtifactName>
<trimStackTrace>false</trimStackTrace>
</configuration>
</plugin>
<plugin> <plugin>
<groupId>org.apache.maven.plugins</groupId> <groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-release-plugin</artifactId> <artifactId>maven-release-plugin</artifactId>
@ -63,10 +100,12 @@
<plugin> <plugin>
<groupId>org.apache.maven.plugins</groupId> <groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-compiler-plugin</artifactId> <artifactId>maven-compiler-plugin</artifactId>
<version>2.3.2</version> <version>3.8.1</version>
<configuration> <configuration>
<source>1.8</source> <release>16</release>
<target>1.8</target> <compilerArgs>
<arg>-parameters</arg> <!-- used for ACF syntax stuff -->
</compilerArgs>
<excludes> <excludes>
</excludes> </excludes>
</configuration> </configuration>
@ -91,32 +130,64 @@
<plugin> <plugin>
<groupId>org.apache.maven.plugins</groupId> <groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-shade-plugin</artifactId> <artifactId>maven-shade-plugin</artifactId>
<version>3.1.1</version> <version>3.3.0-SNAPSHOT</version>
<configuration> <configuration>
<artifactSet> <artifactSet>
<includes> <includes>
<include>commons-logging:commons-logging</include> <include>commons-logging:commons-logging</include>
<include>org.apache.tomcat:tomcat-jdbc</include> <include>org.apache.tomcat:tomcat-jdbc</include>
<include>org.apache.tomcat:tomcat-juli</include> <include>org.apache.tomcat:tomcat-juli</include>
<include>org.bstats:bstats-base</include>
<include>org.bstats:bstats-bukkit</include> <include>org.bstats:bstats-bukkit</include>
<include>net.kyori:adventure-api</include>
<include>net.kyori:adventure-text-serializer-gson</include>
<include>net.kyori:adventure-platform-bukkit</include>
<include>net.kyori:adventure-platform-api</include>
<include>net.kyori:adventure-platform-viaversion</include>
<include>net.kyori:adventure-platform-facet</include>
<include>net.kyori:adventure-nbt</include>
<include>net.kyori:adventure-key</include>
<include>net.kyori:examination-api</include>
<include>net.kyori:examination-string</include>
<include>net.kyori:adventure-text-serializer-legacy</include>
<include>net.kyori:adventure-text-serializer-bungeecord</include>
<include>net.kyori:adventure-text-serializer-craftbukkit</include>
<include>net.kyori:adventure-text-serializer-gson-legacy-impl</include>
<include>co.aikar:acf-bukkit</include>
</includes> </includes>
</artifactSet> </artifactSet>
<relocations> <relocations>
<relocation>
<pattern>net.kyori.examination</pattern>
<shadedPattern>com.gmail.nossr50.mcmmo.kyori.examination</shadedPattern>
</relocation>
<relocation>
<pattern>net.kyori.adventure</pattern>
<shadedPattern>com.gmail.nossr50.mcmmo.kyori.adventure</shadedPattern>
</relocation>
<relocation>
<pattern>co.aikar.commands</pattern>
<shadedPattern>com.gmail.nossr50.mcmmo.acf</shadedPattern> <!-- Replace this -->
</relocation>
<relocation>
<pattern>co.aikar.locales</pattern>
<shadedPattern>com.gmail.nossr50.mcmmo.locales</shadedPattern> <!-- Replace this -->
</relocation>
<relocation> <relocation>
<pattern>org.apache.commons.logging</pattern> <pattern>org.apache.commons.logging</pattern>
<shadedPattern>com.gmail.nossr50.commons.logging</shadedPattern> <shadedPattern>com.gmail.nossr50.mcmmo.commons.logging</shadedPattern>
</relocation> </relocation>
<relocation> <relocation>
<pattern>org.apache.juli</pattern> <pattern>org.apache.juli</pattern>
<shadedPattern>com.gmail.nossr50.database.tomcat.juli</shadedPattern> <shadedPattern>com.gmail.nossr50.mcmmo.database.tomcat.juli</shadedPattern>
</relocation> </relocation>
<relocation> <relocation>
<pattern>org.apache.tomcat</pattern> <pattern>org.apache.tomcat</pattern>
<shadedPattern>com.gmail.nossr50.database.tomcat</shadedPattern> <shadedPattern>com.gmail.nossr50.mcmmo.database.tomcat</shadedPattern>
</relocation> </relocation>
<relocation> <relocation>
<pattern>org.bstats</pattern> <pattern>org.bstats</pattern>
<shadedPattern>com.gmail.nossr50.metrics.bstat</shadedPattern> <shadedPattern>com.gmail.nossr50.mcmmo.metrics.bstats</shadedPattern>
</relocation> </relocation>
</relocations> </relocations>
</configuration> </configuration>
@ -138,6 +209,13 @@
</extension> </extension>
</extensions> </extensions>
</build> </build>
<pluginRepositories>
<pluginRepository>
<id>maven-snapshots</id>
<url>https://repository.apache.org/content/repositories/snapshots/</url>
</pluginRepository>
</pluginRepositories>
<repositories> <repositories>
<repository> <repository>
<id>spigot-repo</id> <id>spigot-repo</id>
@ -149,31 +227,90 @@
</repository> </repository>
<repository> <repository>
<id>sk89q-repo</id> <id>sk89q-repo</id>
<url>http://maven.sk89q.com/repo/</url> <url>https://maven.sk89q.com/repo/</url>
</repository> </repository>
<repository> <!-- for development builds -->
<id>sonatype-oss</id>
<url>https://oss.sonatype.org/content/repositories/snapshots/</url>
</repository>
<repository>
<id>aikar</id>
<url>https://repo.aikar.co/content/groups/aikar/</url>
</repository>
<!-- ... -->
<!-- ... -->
</repositories> </repositories>
<dependencies> <dependencies>
<dependency>
<groupId>co.aikar</groupId>
<artifactId>acf-bukkit</artifactId> <!-- Don't forget to replace this -->
<version>0.5.0-SNAPSHOT</version> <!-- Replace this as well -->
</dependency>
<!-- adventure-api, adventure-text-serializer-gson, adventure-platform-bukkit-->
<dependency>
<groupId>net.kyori</groupId>
<artifactId>adventure-text-serializer-gson</artifactId>
<version>4.9.3</version>
</dependency>
<dependency>
<groupId>net.kyori</groupId>
<artifactId>adventure-api</artifactId>
<version>4.9.3</version>
</dependency>
<dependency>
<groupId>net.kyori</groupId>
<artifactId>adventure-nbt</artifactId>
<version>4.9.3</version>
</dependency>
<dependency>
<groupId>net.kyori</groupId>
<artifactId>adventure-key</artifactId>
<version>4.9.3</version>
</dependency>
<dependency>
<groupId>net.kyori</groupId>
<artifactId>adventure-text-serializer-gson-legacy-impl</artifactId>
<version>4.9.3</version>
</dependency>
<dependency>
<groupId>net.kyori</groupId>
<artifactId>adventure-platform-bukkit</artifactId>
<version>4.0.1</version>
</dependency>
<dependency>
<groupId>net.kyori</groupId>
<artifactId>adventure-platform-api</artifactId>
<version>4.0.1</version>
</dependency>
<dependency> <dependency>
<groupId>org.apache.maven.scm</groupId> <groupId>org.apache.maven.scm</groupId>
<artifactId>maven-scm-provider-gitexe</artifactId> <artifactId>maven-scm-provider-gitexe</artifactId>
<version>1.8.1</version> <version>1.12.0</version>
</dependency> </dependency>
<dependency> <dependency>
<groupId>org.bstats</groupId> <groupId>org.bstats</groupId>
<artifactId>bstats-bukkit</artifactId> <artifactId>bstats-bukkit</artifactId>
<version>1.4</version> <version>2.2.1</version>
<scope>compile</scope> <scope>compile</scope>
</dependency> </dependency>
<dependency> <dependency>
<groupId>org.spigotmc</groupId> <groupId>org.spigotmc</groupId>
<artifactId>spigot-api</artifactId> <artifactId>spigot-api</artifactId>
<version>1.15.2-R0.1-SNAPSHOT</version> <version>1.18.1-R0.1-SNAPSHOT</version>
<scope>provided</scope> <scope>provided</scope>
</dependency> </dependency>
<dependency> <dependency>
<groupId>com.sk89q.worldguard</groupId> <groupId>com.sk89q.worldguard</groupId>
<artifactId>worldguard-core</artifactId> <artifactId>worldguard-core</artifactId>
<version>7.0.1-SNAPSHOT</version> <version>7.0.4</version>
<exclusions>
<exclusion>
<!-- We use jetbrains instead. Excluding this -->
<!-- prevents us from using inconsistent annotations -->
<groupId>com.google.code.findbugs</groupId>
<artifactId>jsr305</artifactId>
</exclusion>
</exclusions>
</dependency> </dependency>
<dependency> <dependency>
<groupId>com.sk89q.worldguard</groupId> <groupId>com.sk89q.worldguard</groupId>
@ -187,24 +324,39 @@
</exclusions> </exclusions>
</dependency> </dependency>
<dependency> <dependency>
<groupId>junit</groupId> <groupId>org.junit.jupiter</groupId>
<artifactId>junit-dep</artifactId> <artifactId>junit-jupiter</artifactId>
<version>4.10</version> <version>5.8.2</version>
<scope>test</scope>
</dependency>
<dependency>
<groupId>org.mockito</groupId>
<artifactId>mockito-core</artifactId>
<version>4.2.0</version>
<scope>test</scope>
</dependency>
<dependency>
<groupId>org.mockito</groupId>
<artifactId>mockito-inline</artifactId>
<version>4.2.0</version>
<scope>test</scope> <scope>test</scope>
</dependency> </dependency>
<dependency> <dependency>
<groupId>org.apache.tomcat</groupId> <groupId>org.apache.tomcat</groupId>
<artifactId>tomcat-jdbc</artifactId> <artifactId>tomcat-jdbc</artifactId>
<version>7.0.52</version> <version>10.0.14</version>
<scope>compile</scope> <scope>compile</scope>
</dependency> </dependency>
<dependency> <dependency>
<groupId>org.jetbrains</groupId> <groupId>org.jetbrains</groupId>
<artifactId>annotations</artifactId> <artifactId>annotations</artifactId>
<version>19.0.0</version> <version>22.0.0</version>
</dependency>
<dependency>
<groupId>com.google.guava</groupId>
<artifactId>guava</artifactId>
<version>31.0.1-jre</version> <!-- At this time Spigot is including 29.0 Guava classes that we are using -->
<scope>compile</scope>
</dependency> </dependency>
</dependencies> </dependencies>
<properties>
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
</properties>
</project> </project>

View File

@ -2,7 +2,7 @@ package com.gmail.nossr50.api;
import com.gmail.nossr50.datatypes.player.McMMOPlayer; import com.gmail.nossr50.datatypes.player.McMMOPlayer;
import com.gmail.nossr50.datatypes.skills.SuperAbilityType; import com.gmail.nossr50.datatypes.skills.SuperAbilityType;
import com.gmail.nossr50.runnables.skills.BleedTimerTask; import com.gmail.nossr50.util.MetadataConstants;
import com.gmail.nossr50.util.player.UserManager; import com.gmail.nossr50.util.player.UserManager;
import org.bukkit.entity.LivingEntity; import org.bukkit.entity.LivingEntity;
import org.bukkit.entity.Player; import org.bukkit.entity.Player;
@ -83,6 +83,12 @@ public final class AbilityAPI {
} }
public static boolean isBleeding(LivingEntity entity) { public static boolean isBleeding(LivingEntity entity) {
return BleedTimerTask.isBleeding(entity); if(entity.isValid()) {
if(entity.hasMetadata(MetadataConstants.METADATA_KEY_RUPTURE)) {
return true;
}
}
return false;
} }
} }

View File

@ -1,72 +1,68 @@
package com.gmail.nossr50.api; package com.gmail.nossr50.api;
import com.gmail.nossr50.chat.ChatManager; import com.gmail.nossr50.datatypes.chat.ChatChannel;
import com.gmail.nossr50.chat.ChatManagerFactory; import com.gmail.nossr50.mcMMO;
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 com.gmail.nossr50.util.player.UserManager;
import org.bukkit.entity.Player; import org.bukkit.entity.Player;
import org.bukkit.plugin.Plugin;
public final class ChatAPI { public final class ChatAPI {
private ChatAPI() {} private ChatAPI() {}
/** // /**
* Send a message to all members of a party // * Send a message to all members of a party
* </br> // * </br>
* This function is designed for API usage. // * This function is designed for API usage.
* // *
* @param plugin The plugin sending the message // * @param plugin The plugin sending the message
* @param sender The name of the sender // * @param sender The name of the sender
* @param displayName The display name of the sender // * @param displayName The display name of the sender
* @param party The name of the party to send to // * @param party The name of the party to send to
* @param message The message to send // * @param message The message to send
*/ // */
public static void sendPartyChat(Plugin plugin, String sender, String displayName, String party, String message) { // public static void sendPartyChat(Plugin plugin, String sender, String displayName, String party, String message) {
getPartyChatManager(plugin, party).handleChat(sender, displayName, message); // getPartyChatManager(plugin, party).handleChat(sender, displayName, message);
} // }
//
/** // /**
* Send a message to all members of a party // * Send a message to all members of a party
* </br> // * </br>
* This function is designed for API usage. // * This function is designed for API usage.
* // *
* @param plugin The plugin sending the message // * @param plugin The plugin sending the message
* @param sender The name of the sender to display in the chat // * @param sender The name of the sender to display in the chat
* @param party The name of the party to send to // * @param party The name of the party to send to
* @param message The message to send // * @param message The message to send
*/ // */
public static void sendPartyChat(Plugin plugin, String sender, String party, String message) { // public static void sendPartyChat(Plugin plugin, String sender, String party, String message) {
getPartyChatManager(plugin, party).handleChat(sender, message); // getPartyChatManager(plugin, party).handleChat(sender, message);
} // }
//
/** // /**
* Send a message to administrators // * Send a message to administrators
* </br> // * </br>
* This function is designed for API usage. // * This function is designed for API usage.
* // *
* @param plugin The plugin sending the message // * @param plugin The plugin sending the message
* @param sender The name of the sender // * @param sender The name of the sender
* @param displayName The display name of the sender // * @param displayName The display name of the sender
* @param message The message to send // * @param message The message to send
*/ // */
public static void sendAdminChat(Plugin plugin, String sender, String displayName, String message) { // public static void sendAdminChat(Plugin plugin, String sender, String displayName, String message) {
ChatManagerFactory.getChatManager(plugin, ChatMode.ADMIN).handleChat(sender, displayName, message); // ChatManagerFactory.getChatManager(plugin, ChatChannel.ADMIN).handleChat(sender, displayName, message);
} // }
//
/** // /**
* Send a message to administrators // * Send a message to administrators
* </br> // * </br>
* This function is designed for API usage. // * This function is designed for API usage.
* // *
* @param plugin The plugin sending the message // * @param plugin The plugin sending the message
* @param sender The name of the sender to display in the chat // * @param sender The name of the sender to display in the chat
* @param message The message to send // * @param message The message to send
*/ // */
public static void sendAdminChat(Plugin plugin, String sender, String message) { // public static void sendAdminChat(Plugin plugin, String sender, String message) {
ChatManagerFactory.getChatManager(plugin, ChatMode.ADMIN).handleChat(sender, message); // ChatManagerFactory.getChatManager(plugin, ChatChannel.ADMIN).handleChat(sender, message);
} // }
/** /**
* Check if a player is currently talking in party chat. * Check if a player is currently talking in party chat.
@ -75,7 +71,7 @@ public final class ChatAPI {
* @return true if the player is using party chat, false otherwise * @return true if the player is using party chat, false otherwise
*/ */
public static boolean isUsingPartyChat(Player player) { public static boolean isUsingPartyChat(Player player) {
return UserManager.getPlayer(player).isChatEnabled(ChatMode.PARTY); return UserManager.getPlayer(player).getChatChannel() == ChatChannel.PARTY;
} }
/** /**
@ -85,7 +81,7 @@ public final class ChatAPI {
* @return true if the player is using party chat, false otherwise * @return true if the player is using party chat, false otherwise
*/ */
public static boolean isUsingPartyChat(String playerName) { public static boolean isUsingPartyChat(String playerName) {
return UserManager.getPlayer(playerName).isChatEnabled(ChatMode.PARTY); return UserManager.getPlayer(playerName).getChatChannel() == ChatChannel.PARTY;
} }
/** /**
@ -95,7 +91,7 @@ public final class ChatAPI {
* @return true if the player is using admin chat, false otherwise * @return true if the player is using admin chat, false otherwise
*/ */
public static boolean isUsingAdminChat(Player player) { public static boolean isUsingAdminChat(Player player) {
return UserManager.getPlayer(player).isChatEnabled(ChatMode.ADMIN); return UserManager.getPlayer(player).getChatChannel() == ChatChannel.ADMIN;
} }
/** /**
@ -105,7 +101,7 @@ public final class ChatAPI {
* @return true if the player is using admin chat, false otherwise * @return true if the player is using admin chat, false otherwise
*/ */
public static boolean isUsingAdminChat(String playerName) { public static boolean isUsingAdminChat(String playerName) {
return UserManager.getPlayer(playerName).isChatEnabled(ChatMode.ADMIN); return UserManager.getPlayer(playerName).getChatChannel() == ChatChannel.ADMIN;
} }
/** /**
@ -114,7 +110,7 @@ public final class ChatAPI {
* @param player The player to toggle party chat on. * @param player The player to toggle party chat on.
*/ */
public static void togglePartyChat(Player player) { public static void togglePartyChat(Player player) {
UserManager.getPlayer(player).toggleChat(ChatMode.PARTY); mcMMO.p.getChatManager().setOrToggleChatChannel(UserManager.getPlayer(player), ChatChannel.PARTY);
} }
/** /**
@ -123,7 +119,7 @@ public final class ChatAPI {
* @param playerName The name of the player to toggle party chat on. * @param playerName The name of the player to toggle party chat on.
*/ */
public static void togglePartyChat(String playerName) { public static void togglePartyChat(String playerName) {
UserManager.getPlayer(playerName).toggleChat(ChatMode.PARTY); mcMMO.p.getChatManager().setOrToggleChatChannel(UserManager.getPlayer(playerName), ChatChannel.PARTY);
} }
/** /**
@ -132,7 +128,7 @@ public final class ChatAPI {
* @param player The player to toggle admin chat on. * @param player The player to toggle admin chat on.
*/ */
public static void toggleAdminChat(Player player) { public static void toggleAdminChat(Player player) {
UserManager.getPlayer(player).toggleChat(ChatMode.ADMIN); mcMMO.p.getChatManager().setOrToggleChatChannel(UserManager.getPlayer(player), ChatChannel.ADMIN);
} }
/** /**
@ -141,13 +137,6 @@ public final class ChatAPI {
* @param playerName The name of the player to toggle party chat on. * @param playerName The name of the player to toggle party chat on.
*/ */
public static void toggleAdminChat(String playerName) { public static void toggleAdminChat(String playerName) {
UserManager.getPlayer(playerName).toggleChat(ChatMode.ADMIN); mcMMO.p.getChatManager().setOrToggleChatChannel(UserManager.getPlayer(playerName), ChatChannel.ADMIN);
}
private static ChatManager getPartyChatManager(Plugin plugin, String party) {
ChatManager chatManager = ChatManagerFactory.getChatManager(plugin, ChatMode.PARTY);
((PartyChatManager) chatManager).setParty(PartyManager.getParty(party));
return chatManager;
} }
} }

View File

@ -2,6 +2,8 @@ package com.gmail.nossr50.api;
import com.gmail.nossr50.datatypes.player.PlayerProfile; import com.gmail.nossr50.datatypes.player.PlayerProfile;
import com.gmail.nossr50.mcMMO; import com.gmail.nossr50.mcMMO;
import org.bukkit.OfflinePlayer;
import org.jetbrains.annotations.NotNull;
import java.util.UUID; import java.util.UUID;
@ -9,20 +11,38 @@ public class DatabaseAPI {
/** /**
* Checks if a player exists in the mcMMO Database * Checks if a player exists in the mcMMO Database
* @param uuid player UUID * @param offlinePlayer target player
* @return true if the player exists in the DB, false if they do not * @return true if the player exists in the DB, false if they do not
*/ */
public boolean doesPlayerExistInDB(String uuid) { public boolean doesPlayerExistInDB(@NotNull OfflinePlayer offlinePlayer) {
return doesPlayerExistInDB(UUID.fromString(uuid)); PlayerProfile playerProfile = mcMMO.getDatabaseManager().loadPlayerProfile(offlinePlayer);
return playerProfile.isLoaded();
} }
/** /**
* Checks if a player exists in the mcMMO Database * Checks if a player exists in the mcMMO Database
* @param uuid player UUID * @param uuid target player
* @return true if the player exists in the DB, false if they do not * @return true if the player exists in the DB, false if they do not
*/ */
public boolean doesPlayerExistInDB(UUID uuid) { public boolean doesPlayerExistInDB(@NotNull UUID uuid) {
PlayerProfile playerProfile = mcMMO.getDatabaseManager().loadPlayerProfile(uuid); PlayerProfile playerProfile = null;
try {
playerProfile = mcMMO.getDatabaseManager().loadPlayerProfile(uuid);
} catch (Exception e) {
return false;
}
return playerProfile.isLoaded();
}
/**
* Checks if a player exists in the mcMMO Database
* @param playerName target player
* @return true if the player exists in the DB, false if they do not
*/
public boolean doesPlayerExistInDB(@NotNull String playerName) {
PlayerProfile playerProfile = mcMMO.getDatabaseManager().loadPlayerProfile(playerName);
return playerProfile.isLoaded(); return playerProfile.isLoaded();
} }

View File

@ -1,7 +1,6 @@
package com.gmail.nossr50.api; package com.gmail.nossr50.api;
import com.gmail.nossr50.api.exceptions.*; import com.gmail.nossr50.api.exceptions.*;
import com.gmail.nossr50.config.Config;
import com.gmail.nossr50.config.experience.ExperienceConfig; import com.gmail.nossr50.config.experience.ExperienceConfig;
import com.gmail.nossr50.datatypes.experience.FormulaType; import com.gmail.nossr50.datatypes.experience.FormulaType;
import com.gmail.nossr50.datatypes.experience.XPGainReason; import com.gmail.nossr50.datatypes.experience.XPGainReason;
@ -12,8 +11,13 @@ import com.gmail.nossr50.datatypes.skills.PrimarySkillType;
import com.gmail.nossr50.mcMMO; import com.gmail.nossr50.mcMMO;
import com.gmail.nossr50.skills.child.FamilyTree; import com.gmail.nossr50.skills.child.FamilyTree;
import com.gmail.nossr50.util.player.UserManager; import com.gmail.nossr50.util.player.UserManager;
import com.gmail.nossr50.util.skills.CombatUtils;
import com.gmail.nossr50.util.skills.SkillTools;
import org.bukkit.OfflinePlayer;
import org.bukkit.block.BlockState; import org.bukkit.block.BlockState;
import org.bukkit.entity.LivingEntity;
import org.bukkit.entity.Player; import org.bukkit.entity.Player;
import org.jetbrains.annotations.NotNull;
import java.util.ArrayList; import java.util.ArrayList;
import java.util.Set; import java.util.Set;
@ -32,7 +36,36 @@ public final class ExperienceAPI {
* @return true if this is a valid mcMMO skill * @return true if this is a valid mcMMO skill
*/ */
public static boolean isValidSkillType(String skillType) { public static boolean isValidSkillType(String skillType) {
return PrimarySkillType.getSkill(skillType) != null; return mcMMO.p.getSkillTools().matchSkill(skillType) != null;
}
/**
* Start the task that gives combat XP.
* Processes combat XP like mcMMO normally would, so mcMMO will check whether or not the entity should reward XP when giving out the XP
*
* @param mcMMOPlayer The attacking player
* @param target The defending entity
* @param primarySkillType The skill being used
* @param multiplier final XP result will be multiplied by this
* @deprecated Draft API
*/
@Deprecated
public static void addCombatXP(McMMOPlayer mcMMOPlayer, LivingEntity target, PrimarySkillType primarySkillType, double multiplier) {
CombatUtils.processCombatXP(mcMMOPlayer, target, primarySkillType, multiplier);
}
/**
* Start the task that gives combat XP.
* Processes combat XP like mcMMO normally would, so mcMMO will check whether or not the entity should reward XP when giving out the XP
*
* @param mcMMOPlayer The attacking player
* @param target The defending entity
* @param primarySkillType The skill being used
* @deprecated Draft API
*/
@Deprecated
public static void addCombatXP(McMMOPlayer mcMMOPlayer, LivingEntity target, PrimarySkillType primarySkillType) {
CombatUtils.processCombatXP(mcMMOPlayer, target, primarySkillType);
} }
/** /**
@ -46,9 +79,9 @@ public final class ExperienceAPI {
* @return true if this is a valid, non-child mcMMO skill * @return true if this is a valid, non-child mcMMO skill
*/ */
public static boolean isNonChildSkill(String skillType) { public static boolean isNonChildSkill(String skillType) {
PrimarySkillType skill = PrimarySkillType.getSkill(skillType); PrimarySkillType skill = mcMMO.p.getSkillTools().matchSkill(skillType);
return skill != null && !skill.isChildSkill(); return skill != null && !SkillTools.isChildSkill(skill);
} }
@Deprecated @Deprecated
@ -262,11 +295,12 @@ public final class ExperienceAPI {
PrimarySkillType skill = getSkillType(skillType); PrimarySkillType skill = getSkillType(skillType);
if (isUnshared) { if (isUnshared) {
getPlayer(player).beginUnsharedXpGain(skill, (int) (XP / skill.getXpModifier() * ExperienceConfig.getInstance().getExperienceGainsGlobalMultiplier()), getXPGainReason(xpGainReason), XPGainSource.CUSTOM); getPlayer(player).beginUnsharedXpGain(skill,
(int) (XP / ExperienceConfig.getInstance().getFormulaSkillModifier(skill) * ExperienceConfig.getInstance().getExperienceGainsGlobalMultiplier()), getXPGainReason(xpGainReason), XPGainSource.CUSTOM);
return; return;
} }
getPlayer(player).applyXpGain(skill, (int) (XP / skill.getXpModifier() * ExperienceConfig.getInstance().getExperienceGainsGlobalMultiplier()), getXPGainReason(xpGainReason), XPGainSource.CUSTOM); getPlayer(player).applyXpGain(skill, (int) (XP / ExperienceConfig.getInstance().getFormulaSkillModifier(skill) * ExperienceConfig.getInstance().getExperienceGainsGlobalMultiplier()), getXPGainReason(xpGainReason), XPGainSource.CUSTOM);
} }
/** /**
@ -285,7 +319,7 @@ public final class ExperienceAPI {
public static void addModifiedXPOffline(String playerName, String skillType, int XP) { public static void addModifiedXPOffline(String playerName, String skillType, int XP) {
PrimarySkillType skill = getSkillType(skillType); PrimarySkillType skill = getSkillType(skillType);
addOfflineXP(playerName, skill, (int) (XP / skill.getXpModifier() * ExperienceConfig.getInstance().getExperienceGainsGlobalMultiplier())); addOfflineXP(playerName, skill, (int) (XP / ExperienceConfig.getInstance().getFormulaSkillModifier(skill) * ExperienceConfig.getInstance().getExperienceGainsGlobalMultiplier()));
} }
/** /**
@ -398,6 +432,23 @@ public final class ExperienceAPI {
return getOfflineProfile(uuid).getSkillXpLevel(getNonChildSkillType(skillType)); return getOfflineProfile(uuid).getSkillXpLevel(getNonChildSkillType(skillType));
} }
/**
* Get the amount of XP an offline player has in a specific skill.
* </br>
* This function is designed for API usage.
*
* @param offlinePlayer The player to get XP for
* @param skillType The skill to get XP for
* @return the amount of XP in a given skill
*
* @throws InvalidSkillException if the given skill is not valid
* @throws InvalidPlayerException if the given player does not exist in the database
* @throws UnsupportedOperationException if the given skill is a child skill
*/
public static int getOfflineXP(@NotNull OfflinePlayer offlinePlayer, @NotNull String skillType) throws InvalidPlayerException {
return getOfflineProfile(offlinePlayer).getSkillXpLevel(getNonChildSkillType(skillType));
}
/** /**
* Get the raw amount of XP a player has in a specific skill. * Get the raw amount of XP a player has in a specific skill.
* </br> * </br>
@ -449,6 +500,30 @@ public final class ExperienceAPI {
return getOfflineProfile(uuid).getSkillXpLevelRaw(getNonChildSkillType(skillType)); return getOfflineProfile(uuid).getSkillXpLevelRaw(getNonChildSkillType(skillType));
} }
/**
* Get the raw amount of XP an offline player has in a specific skill.
* </br>
* This function is designed for API usage.
*
* @param offlinePlayer The player to get XP for
* @param skillType The skill to get XP for
* @return the amount of XP in a given skill
*
* @throws InvalidSkillException if the given skill is not valid
* @throws InvalidPlayerException if the given player does not exist in the database
* @throws UnsupportedOperationException if the given skill is a child skill
*/
public static float getOfflineXPRaw(@NotNull OfflinePlayer offlinePlayer, @NotNull String skillType) throws InvalidPlayerException, UnsupportedOperationException, InvalidSkillException {
return getOfflineProfile(offlinePlayer).getSkillXpLevelRaw(getNonChildSkillType(skillType));
}
public static float getOfflineXPRaw(@NotNull OfflinePlayer offlinePlayer, @NotNull PrimarySkillType skillType) throws InvalidPlayerException, UnsupportedOperationException {
if(SkillTools.isChildSkill(skillType))
throw new UnsupportedOperationException();
return getOfflineProfile(offlinePlayer).getSkillXpLevelRaw(skillType);
}
/** /**
* Get the total amount of XP needed to reach the next level. * Get the total amount of XP needed to reach the next level.
* </br> * </br>
@ -496,10 +571,27 @@ public final class ExperienceAPI {
* @throws InvalidPlayerException if the given player does not exist in the database * @throws InvalidPlayerException if the given player does not exist in the database
* @throws UnsupportedOperationException if the given skill is a child skill * @throws UnsupportedOperationException if the given skill is a child skill
*/ */
public static int getOfflineXPToNextLevel(UUID uuid, String skillType) { public static int getOfflineXPToNextLevel(@NotNull UUID uuid, @NotNull String skillType) {
return getOfflineProfile(uuid).getXpToLevel(getNonChildSkillType(skillType)); return getOfflineProfile(uuid).getXpToLevel(getNonChildSkillType(skillType));
} }
/**
* Get the total amount of XP an offline player needs to reach the next level.
* </br>
* This function is designed for API usage.
*
* @param offlinePlayer The player to get XP for
* @param skillType The skill to get XP for
* @return the total amount of XP needed to reach the next level
*
* @throws InvalidSkillException if the given skill is not valid
* @throws InvalidPlayerException if the given player does not exist in the database
* @throws UnsupportedOperationException if the given skill is a child skill
*/
public static int getOfflineXPToNextLevel(@NotNull OfflinePlayer offlinePlayer, @NotNull String skillType) throws UnsupportedOperationException, InvalidSkillException, InvalidPlayerException {
return getOfflineProfile(offlinePlayer).getXpToLevel(getNonChildSkillType(skillType));
}
/** /**
* Get the amount of XP remaining until the next level. * Get the amount of XP remaining until the next level.
* </br> * </br>
@ -561,6 +653,26 @@ public final class ExperienceAPI {
return profile.getXpToLevel(skill) - profile.getSkillXpLevelRaw(skill); return profile.getXpToLevel(skill) - profile.getSkillXpLevelRaw(skill);
} }
/**
* Get the amount of XP an offline player has left before leveling up.
* </br>
* This function is designed for API usage.
*
* @param offlinePlayer The player to get XP for
* @param skillType The skill to get XP for
* @return the amount of XP needed to reach the next level
*
* @throws InvalidSkillException if the given skill is not valid
* @throws InvalidPlayerException if the given player does not exist in the database
* @throws UnsupportedOperationException if the given skill is a child skill
*/
public static float getOfflineXPRemaining(OfflinePlayer offlinePlayer, String skillType) throws InvalidSkillException, InvalidPlayerException, UnsupportedOperationException {
PrimarySkillType skill = getNonChildSkillType(skillType);
PlayerProfile profile = getOfflineProfile(offlinePlayer);
return profile.getXpToLevel(skill) - profile.getSkillXpLevelRaw(skill);
}
/** /**
* Add levels to a skill. * Add levels to a skill.
* </br> * </br>
@ -593,7 +705,7 @@ public final class ExperienceAPI {
PlayerProfile profile = getOfflineProfile(playerName); PlayerProfile profile = getOfflineProfile(playerName);
PrimarySkillType skill = getSkillType(skillType); PrimarySkillType skill = getSkillType(skillType);
if (skill.isChildSkill()) { if (SkillTools.isChildSkill(skill)) {
Set<PrimarySkillType> parentSkills = FamilyTree.getParents(skill); Set<PrimarySkillType> parentSkills = FamilyTree.getParents(skill);
for (PrimarySkillType parentSkill : parentSkills) { for (PrimarySkillType parentSkill : parentSkills) {
@ -624,7 +736,7 @@ public final class ExperienceAPI {
PlayerProfile profile = getOfflineProfile(uuid); PlayerProfile profile = getOfflineProfile(uuid);
PrimarySkillType skill = getSkillType(skillType); PrimarySkillType skill = getSkillType(skillType);
if (skill.isChildSkill()) { if (SkillTools.isChildSkill(skill)) {
Set<PrimarySkillType> parentSkills = FamilyTree.getParents(skill); Set<PrimarySkillType> parentSkills = FamilyTree.getParents(skill);
for (PrimarySkillType parentSkill : parentSkills) { for (PrimarySkillType parentSkill : parentSkills) {
@ -683,7 +795,6 @@ public final class ExperienceAPI {
* @throws InvalidSkillException if the given skill is not valid * @throws InvalidSkillException if the given skill is not valid
* @throws InvalidPlayerException if the given player does not exist in the database * @throws InvalidPlayerException if the given player does not exist in the database
*/ */
@Deprecated
public static int getLevelOffline(String playerName, String skillType) { public static int getLevelOffline(String playerName, String skillType) {
return getOfflineProfile(playerName).getSkillLevel(getSkillType(skillType)); return getOfflineProfile(playerName).getSkillLevel(getSkillType(skillType));
} }
@ -731,7 +842,7 @@ public final class ExperienceAPI {
int powerLevel = 0; int powerLevel = 0;
PlayerProfile profile = getOfflineProfile(playerName); PlayerProfile profile = getOfflineProfile(playerName);
for (PrimarySkillType type : PrimarySkillType.NON_CHILD_SKILLS) { for (PrimarySkillType type : SkillTools.NON_CHILD_SKILLS) {
powerLevel += profile.getSkillLevel(type); powerLevel += profile.getSkillLevel(type);
} }
@ -752,7 +863,7 @@ public final class ExperienceAPI {
int powerLevel = 0; int powerLevel = 0;
PlayerProfile profile = getOfflineProfile(uuid); PlayerProfile profile = getOfflineProfile(uuid);
for (PrimarySkillType type : PrimarySkillType.NON_CHILD_SKILLS) { for (PrimarySkillType type : SkillTools.NON_CHILD_SKILLS) {
powerLevel += profile.getSkillLevel(type); powerLevel += profile.getSkillLevel(type);
} }
@ -770,7 +881,7 @@ public final class ExperienceAPI {
* @throws InvalidSkillException if the given skill is not valid * @throws InvalidSkillException if the given skill is not valid
*/ */
public static int getLevelCap(String skillType) { public static int getLevelCap(String skillType) {
return Config.getInstance().getLevelCap(getSkillType(skillType)); return mcMMO.p.getSkillTools().getLevelCap(getSkillType(skillType));
} }
/** /**
@ -781,7 +892,7 @@ public final class ExperienceAPI {
* @return the overall power level cap * @return the overall power level cap
*/ */
public static int getPowerLevelCap() { public static int getPowerLevelCap() {
return Config.getInstance().getPowerLevelCap(); return mcMMO.p.getGeneralConfig().getPowerLevelCap();
} }
/** /**
@ -1095,25 +1206,22 @@ public final class ExperienceAPI {
} }
} }
// Utility methods follow. // Utility methods follow.
private static void addOfflineXP(UUID playerUniqueId, PrimarySkillType skill, int XP) { private static void addOfflineXP(@NotNull UUID playerUniqueId, @NotNull PrimarySkillType skill, int XP) {
PlayerProfile profile = getOfflineProfile(playerUniqueId); PlayerProfile profile = getOfflineProfile(playerUniqueId);
profile.addXp(skill, XP); profile.addXp(skill, XP);
profile.save(true); profile.save(true);
} }
@Deprecated private static void addOfflineXP(@NotNull String playerName, @NotNull PrimarySkillType skill, int XP) {
private static void addOfflineXP(String playerName, PrimarySkillType skill, int XP) {
PlayerProfile profile = getOfflineProfile(playerName); PlayerProfile profile = getOfflineProfile(playerName);
profile.addXp(skill, XP); profile.addXp(skill, XP);
profile.scheduleAsyncSave(); profile.scheduleAsyncSave();
} }
private static PlayerProfile getOfflineProfile(UUID uuid) { private static @NotNull PlayerProfile getOfflineProfile(@NotNull UUID uuid) throws InvalidPlayerException {
PlayerProfile profile = mcMMO.getDatabaseManager().loadPlayerProfile(uuid); PlayerProfile profile = mcMMO.getDatabaseManager().loadPlayerProfile(uuid);
if (!profile.isLoaded()) { if (!profile.isLoaded()) {
@ -1123,10 +1231,18 @@ public final class ExperienceAPI {
return profile; return profile;
} }
@Deprecated private static @NotNull PlayerProfile getOfflineProfile(@NotNull OfflinePlayer offlinePlayer) throws InvalidPlayerException {
private static PlayerProfile getOfflineProfile(String playerName) { PlayerProfile profile = mcMMO.getDatabaseManager().loadPlayerProfile(offlinePlayer);
UUID uuid = mcMMO.p.getServer().getOfflinePlayer(playerName).getUniqueId();
PlayerProfile profile = mcMMO.getDatabaseManager().loadPlayerProfile(uuid); if (!profile.isLoaded()) {
throw new InvalidPlayerException();
}
return profile;
}
private static @NotNull PlayerProfile getOfflineProfile(@NotNull String playerName) throws InvalidPlayerException {
PlayerProfile profile = mcMMO.getDatabaseManager().loadPlayerProfile(playerName);
if (!profile.isLoaded()) { if (!profile.isLoaded()) {
throw new InvalidPlayerException(); throw new InvalidPlayerException();
@ -1136,7 +1252,7 @@ public final class ExperienceAPI {
} }
private static PrimarySkillType getSkillType(String skillType) throws InvalidSkillException { private static PrimarySkillType getSkillType(String skillType) throws InvalidSkillException {
PrimarySkillType skill = PrimarySkillType.getSkill(skillType); PrimarySkillType skill = mcMMO.p.getSkillTools().matchSkill(skillType);
if (skill == null) { if (skill == null) {
throw new InvalidSkillException(); throw new InvalidSkillException();
@ -1148,7 +1264,7 @@ public final class ExperienceAPI {
private static PrimarySkillType getNonChildSkillType(String skillType) throws InvalidSkillException, UnsupportedOperationException { private static PrimarySkillType getNonChildSkillType(String skillType) throws InvalidSkillException, UnsupportedOperationException {
PrimarySkillType skill = getSkillType(skillType); PrimarySkillType skill = getSkillType(skillType);
if (skill.isChildSkill()) { if (SkillTools.isChildSkill(skill)) {
throw new UnsupportedOperationException("Child skills do not have XP"); throw new UnsupportedOperationException("Child skills do not have XP");
} }

View File

@ -0,0 +1,17 @@
package com.gmail.nossr50.api;
public enum ItemSpawnReason {
ARROW_RETRIEVAL_ACTIVATED, //Players sometimes can retrieve arrows instead of losing them when hitting a mob
EXCAVATION_TREASURE, //Any drops when excavation treasures activate fall under this
FISHING_EXTRA_FISH, //A config setting allows more fish to be found when fishing, the extra fish are part of this
FISHING_SHAKE_TREASURE, //When using a fishing rod on a mob and finding a treasure via Shake
HYLIAN_LUCK_TREASURE, //When finding a treasure in grass via hylian luck
BLAST_MINING_DEBRIS_NON_ORES, //The non-ore debris that are dropped from blast mining
BLAST_MINING_ORES, //The ore(s) which may include player placed ores being dropped from blast mining
BLAST_MINING_ORES_BONUS_DROP, //Any bonus ores that drop from a result of a players Mining skills
UNARMED_DISARMED_ITEM, //When you disarm an opponent and they drop their weapon
SALVAGE_ENCHANTMENT_BOOK, //When you salvage an enchanted item and get the enchantment back in book form
SALVAGE_MATERIALS, //When you salvage an item and get materials back
TREE_FELLER_DISPLACED_BLOCK,
BONUS_DROPS, //Can be from Mining, Woodcutting, Herbalism, etc
}

View File

@ -1,6 +1,5 @@
package com.gmail.nossr50.api; package com.gmail.nossr50.api;
import com.gmail.nossr50.config.Config;
import com.gmail.nossr50.datatypes.interactions.NotificationType; import com.gmail.nossr50.datatypes.interactions.NotificationType;
import com.gmail.nossr50.datatypes.party.Party; import com.gmail.nossr50.datatypes.party.Party;
import com.gmail.nossr50.datatypes.party.PartyLeader; import com.gmail.nossr50.datatypes.party.PartyLeader;
@ -108,7 +107,7 @@ public final class PartyAPI {
*/ */
public static int getMaxPartySize() public static int getMaxPartySize()
{ {
return Config.getInstance().getPartyMaxSize(); return mcMMO.p.getGeneralConfig().getPartyMaxSize();
} }
/** /**
@ -185,7 +184,7 @@ public final class PartyAPI {
*/ */
@Deprecated @Deprecated
public static List<OfflinePlayer> getOnlineAndOfflineMembers(Player player) { public static List<OfflinePlayer> getOnlineAndOfflineMembers(Player player) {
List<OfflinePlayer> members = new ArrayList<OfflinePlayer>(); List<OfflinePlayer> members = new ArrayList<>();
for (UUID memberUniqueId : PartyManager.getAllMembers(player).keySet()) { for (UUID memberUniqueId : PartyManager.getAllMembers(player).keySet()) {
OfflinePlayer member = mcMMO.p.getServer().getOfflinePlayer(memberUniqueId); OfflinePlayer member = mcMMO.p.getServer().getOfflinePlayer(memberUniqueId);

View File

@ -1,6 +1,8 @@
package com.gmail.nossr50.api; package com.gmail.nossr50.api;
import com.gmail.nossr50.datatypes.skills.PrimarySkillType; import com.gmail.nossr50.datatypes.skills.PrimarySkillType;
import com.gmail.nossr50.mcMMO;
import com.gmail.nossr50.util.skills.SkillTools;
import java.util.ArrayList; import java.util.ArrayList;
import java.util.Arrays; import java.util.Arrays;
@ -30,7 +32,7 @@ public final class SkillAPI {
* @return a list of strings with valid skill names * @return a list of strings with valid skill names
*/ */
public static List<String> getNonChildSkills() { public static List<String> getNonChildSkills() {
return getListFromEnum(PrimarySkillType.NON_CHILD_SKILLS); return getListFromEnum(SkillTools.NON_CHILD_SKILLS);
} }
/** /**
@ -42,7 +44,7 @@ public final class SkillAPI {
* @return a list of strings with valid skill names * @return a list of strings with valid skill names
*/ */
public static List<String> getChildSkills() { public static List<String> getChildSkills() {
return getListFromEnum(PrimarySkillType.CHILD_SKILLS); return getListFromEnum(mcMMO.p.getSkillTools().CHILD_SKILLS);
} }
/** /**
@ -54,7 +56,7 @@ public final class SkillAPI {
* @return a list of strings with valid skill names * @return a list of strings with valid skill names
*/ */
public static List<String> getCombatSkills() { public static List<String> getCombatSkills() {
return getListFromEnum(PrimarySkillType.COMBAT_SKILLS); return getListFromEnum(mcMMO.p.getSkillTools().COMBAT_SKILLS);
} }
/** /**
@ -66,7 +68,7 @@ public final class SkillAPI {
* @return a list of strings with valid skill names * @return a list of strings with valid skill names
*/ */
public static List<String> getGatheringSkills() { public static List<String> getGatheringSkills() {
return getListFromEnum(PrimarySkillType.GATHERING_SKILLS); return getListFromEnum(mcMMO.p.getSkillTools().GATHERING_SKILLS);
} }
/** /**
@ -78,11 +80,11 @@ public final class SkillAPI {
* @return a list of strings with valid skill names * @return a list of strings with valid skill names
*/ */
public static List<String> getMiscSkills() { public static List<String> getMiscSkills() {
return getListFromEnum(PrimarySkillType.MISC_SKILLS); return getListFromEnum(mcMMO.p.getSkillTools().MISC_SKILLS);
} }
private static List<String> getListFromEnum(List<PrimarySkillType> skillsTypes) { private static List<String> getListFromEnum(List<PrimarySkillType> skillsTypes) {
List<String> skills = new ArrayList<String>(); List<String> skills = new ArrayList<>();
for (PrimarySkillType primarySkillType : skillsTypes) { for (PrimarySkillType primarySkillType : skillsTypes) {
skills.add(primarySkillType.name()); skills.add(primarySkillType.name());

View File

@ -0,0 +1,11 @@
package com.gmail.nossr50.api.exceptions;
import org.jetbrains.annotations.NotNull;
public class IncompleteNamespacedKeyRegister extends RuntimeException {
private static final long serialVersionUID = -6905157273569301219L;
public IncompleteNamespacedKeyRegister(@NotNull String message) {
super(message);
}
}

View File

@ -6,4 +6,8 @@ public class InvalidSkillException extends RuntimeException {
public InvalidSkillException() { public InvalidSkillException() {
super("That is not a valid skill."); super("That is not a valid skill.");
} }
public InvalidSkillException(String msg) {
super(msg);
}
} }

View File

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

View File

@ -1,21 +0,0 @@
package com.gmail.nossr50.chat;
import com.gmail.nossr50.config.Config;
import com.gmail.nossr50.events.chat.McMMOAdminChatEvent;
import org.bukkit.plugin.Plugin;
public class AdminChatManager extends ChatManager {
protected AdminChatManager(Plugin plugin) {
super(plugin, Config.getInstance().getAdminDisplayNames(), Config.getInstance().getAdminChatPrefix());
}
@Override
public void handleChat(String senderName, String displayName, String message, boolean isAsync) {
handleChat(new McMMOAdminChatEvent(plugin, senderName, displayName, message, isAsync));
}
@Override
protected void sendMessage() {
plugin.getServer().broadcast(message, "mcmmo.chat.adminchat");
}
}

View File

@ -1,88 +1,225 @@
package com.gmail.nossr50.chat; package com.gmail.nossr50.chat;
import com.gmail.nossr50.chat.author.Author;
import com.gmail.nossr50.chat.author.ConsoleAuthor;
import com.gmail.nossr50.chat.mailer.AdminChatMailer;
import com.gmail.nossr50.chat.mailer.PartyChatMailer;
import com.gmail.nossr50.config.ChatConfig;
import com.gmail.nossr50.datatypes.chat.ChatChannel;
import com.gmail.nossr50.datatypes.party.Party; import com.gmail.nossr50.datatypes.party.Party;
import com.gmail.nossr50.datatypes.player.McMMOPlayer; import com.gmail.nossr50.datatypes.player.McMMOPlayer;
import com.gmail.nossr50.events.chat.McMMOChatEvent;
import com.gmail.nossr50.events.chat.McMMOPartyChatEvent;
import com.gmail.nossr50.locale.LocaleLoader; import com.gmail.nossr50.locale.LocaleLoader;
import com.gmail.nossr50.util.player.UserManager; import com.gmail.nossr50.mcMMO;
import org.bukkit.entity.Player; import com.gmail.nossr50.util.Misc;
import org.bukkit.plugin.Plugin; import com.gmail.nossr50.util.Permissions;
import com.gmail.nossr50.util.text.StringUtils;
import net.kyori.adventure.audience.Audience;
import net.kyori.adventure.text.TextComponent;
import org.bukkit.command.ConsoleCommandSender;
import org.jetbrains.annotations.NotNull;
public abstract class ChatManager { //TODO: Micro optimization - Cache audiences and update cache when needed
protected Plugin plugin; public class ChatManager {
protected boolean useDisplayNames;
protected String chatPrefix;
protected String senderName; private final @NotNull AdminChatMailer adminChatMailer;
protected String displayName; private final @NotNull PartyChatMailer partyChatMailer;
protected String message;
protected ChatManager(Plugin plugin, boolean useDisplayNames, String chatPrefix) { private final @NotNull ConsoleAuthor consoleAuthor;
this.plugin = plugin; private final @NotNull Audience consoleAudience;
this.useDisplayNames = useDisplayNames;
this.chatPrefix = chatPrefix; private final boolean isChatEnabled;
public ChatManager(@NotNull mcMMO pluginRef) {
adminChatMailer = new AdminChatMailer(pluginRef);
partyChatMailer = new PartyChatMailer(pluginRef);
this.consoleAuthor = new ConsoleAuthor(LocaleLoader.getString("Chat.Identity.Console"));
this.consoleAudience = mcMMO.getAudiences().filter((cs) -> cs instanceof ConsoleCommandSender);
this.isChatEnabled = ChatConfig.getInstance().isChatEnabled();
} }
protected void handleChat(McMMOChatEvent event) { /**
plugin.getServer().getPluginManager().callEvent(event); * Handles player messaging when they are either in party chat or admin chat modes
*
* @param mmoPlayer target player
* @param rawMessage the raw message from the player as it was typed
* @param isAsync whether or not this is getting processed via async
*/
public void processPlayerMessage(@NotNull McMMOPlayer mmoPlayer, @NotNull String rawMessage, boolean isAsync) {
processPlayerMessage(mmoPlayer, mmoPlayer.getChatChannel(), rawMessage, isAsync);
}
if (event.isCancelled()) { /**
return; * Handles player messaging for a specific chat channel
*
* @param mmoPlayer target player
* @param args the raw command arguments from the player
* @param chatChannel target channel
*/
public void processPlayerMessage(@NotNull McMMOPlayer mmoPlayer, @NotNull String[] args, @NotNull ChatChannel chatChannel) {
String chatMessageWithoutCommand = buildChatMessage(args);
//Commands are never async
processPlayerMessage(mmoPlayer, chatChannel, chatMessageWithoutCommand, false);
}
/**
* Handles player messaging for a specific chat channel
*
* @param mmoPlayer target player
* @param chatChannel target chat channel
* @param rawMessage raw chat message as it was typed
* @param isAsync whether or not this is getting processed via async
*/
private void processPlayerMessage(@NotNull McMMOPlayer mmoPlayer, @NotNull ChatChannel chatChannel, @NotNull String rawMessage, boolean isAsync) {
switch (chatChannel) {
case ADMIN:
adminChatMailer.processChatMessage(mmoPlayer.getPlayerAuthor(), rawMessage, isAsync, Permissions.colorChat(mmoPlayer.getPlayer()));
break;
case PARTY:
partyChatMailer.processChatMessage(mmoPlayer.getPlayerAuthor(), rawMessage, mmoPlayer.getParty(), isAsync, Permissions.colorChat(mmoPlayer.getPlayer()), Misc.isPartyLeader(mmoPlayer));
break;
case PARTY_OFFICER:
case NONE:
break;
}
}
/**
* Handles console messaging to admins
* @param rawMessage raw message from the console
*/
public void processConsoleMessage(@NotNull String rawMessage) {
adminChatMailer.processChatMessage(getConsoleAuthor(), rawMessage, false, true);
}
/**
* Handles console messaging to admins
* @param args raw command args from the console
*/
public void processConsoleMessage(@NotNull String[] args) {
processConsoleMessage(buildChatMessage(args));
}
/**
* Handles console messaging to a specific party
* @param rawMessage raw message from the console
* @param party target party
*/
public void processConsoleMessage(@NotNull String rawMessage, @NotNull Party party) {
partyChatMailer.processChatMessage(getConsoleAuthor(), rawMessage, party, false, true, false);
}
/**
* Gets a console author
* @return a {@link ConsoleAuthor}
*/
private @NotNull Author getConsoleAuthor() {
return consoleAuthor;
}
/**
* Change the chat channel of a {@link McMMOPlayer}
* Targeting the channel a player is already in will remove that player from the chat channel
* @param mmoPlayer target player
* @param targetChatChannel target chat channel
*/
public void setOrToggleChatChannel(@NotNull McMMOPlayer mmoPlayer, @NotNull ChatChannel targetChatChannel) {
if(targetChatChannel == mmoPlayer.getChatChannel()) {
//Disabled message
mmoPlayer.getPlayer().sendMessage(LocaleLoader.getString("Chat.Channel.Off", StringUtils.getCapitalized(targetChatChannel.toString())));
mmoPlayer.setChatMode(ChatChannel.NONE);
} else {
mmoPlayer.setChatMode(targetChatChannel);
mmoPlayer.getPlayer().sendMessage(LocaleLoader.getString("Chat.Channel.On", StringUtils.getCapitalized(targetChatChannel.toString())));
}
}
/**
* Create a chat message from an array of {@link String}
* @param args array of {@link String}
* @return a String built from the array
*/
private @NotNull String buildChatMessage(@NotNull String[] args) {
StringBuilder stringBuilder = new StringBuilder();
for(int i = 0; i < args.length; i++) {
if(i + 1 >= args.length) {
stringBuilder.append(args[i]);
} else {
stringBuilder.append(args[i]).append(" ");
}
} }
senderName = event.getSender(); return stringBuilder.toString();
displayName = useDisplayNames ? event.getDisplayName() : senderName; }
message = LocaleLoader.formatString(chatPrefix, displayName) + " " + event.getMessage();
sendMessage(); /**
* Whether or not the player is allowed to send a message to the chat channel they are targeting
/* * @param mmoPlayer target player
* Party Chat Spying * @return true if the player can send messages to that chat channel
* Party messages will be copied to people with the mcmmo.admin.chatspy permission node */
*/ public boolean isMessageAllowed(@NotNull McMMOPlayer mmoPlayer) {
if(event instanceof McMMOPartyChatEvent) switch (mmoPlayer.getChatChannel()) {
{ case ADMIN:
//We need to grab the party chat name if(mmoPlayer.getPlayer().isOp() || Permissions.adminChat(mmoPlayer.getPlayer())) {
McMMOPartyChatEvent partyChatEvent = (McMMOPartyChatEvent) event; return true;
//Find the people with permissions
for(McMMOPlayer mcMMOPlayer : UserManager.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.getName().equalsIgnoreCase(partyChatEvent.getParty()))
player.sendMessage(LocaleLoader.getString("Commands.AdminChatSpy.Chat", partyChatEvent.getParty(), message));
} else {
player.sendMessage(LocaleLoader.getString("Commands.AdminChatSpy.Chat", partyChatEvent.getParty(), message));
}
} }
break;
case PARTY:
if(mmoPlayer.getParty() != null && Permissions.partyChat(mmoPlayer.getPlayer())) {
return true;
}
break;
case PARTY_OFFICER:
case NONE:
return false;
}
return false;
}
/**
* Sends just the console a message
* @param author author of the message
* @param message message contents in component form
*/
public void sendConsoleMessage(@NotNull Author author, @NotNull TextComponent message) {
consoleAudience.sendMessage(author, message);
}
/**
* Whether the mcMMO chat system which handles party and admin chat is enabled or disabled
* @return true if mcMMO chat processing (for party/admin chat) is enabled
*/
public boolean isChatEnabled() {
return isChatEnabled;
}
/**
* Whether or not a specific chat channel is enabled
* ChatChannels are enabled/disabled via user config
*
* If chat is disabled, this always returns false
* If NONE is passed as a {@link ChatChannel} it will return true
* @param chatChannel target chat channel
* @return true if the chat channel is enabled
*/
public boolean isChatChannelEnabled(@NotNull ChatChannel chatChannel) {
if(!isChatEnabled) {
return false;
} else {
switch(chatChannel) {
case ADMIN:
case PARTY:
case PARTY_OFFICER:
return ChatConfig.getInstance().isChatChannelEnabled(chatChannel);
case NONE:
return true;
default:
return false;
} }
} }
} }
public void handleChat(String senderName, String message) { }
handleChat(senderName, senderName, message, false);
}
public void handleChat(Player player, String message, boolean isAsync) {
handleChat(player.getName(), player.getDisplayName(), message, isAsync);
}
public void handleChat(String senderName, String displayName, String message) {
handleChat(senderName, displayName, message, false);
}
public abstract void handleChat(String senderName, String displayName, String message, boolean isAsync);
protected abstract void sendMessage();
}

View File

@ -1,30 +0,0 @@
package com.gmail.nossr50.chat;
import com.gmail.nossr50.datatypes.chat.ChatMode;
import org.bukkit.plugin.Plugin;
import java.util.HashMap;
public class ChatManagerFactory {
private static final HashMap<Plugin, AdminChatManager> adminChatManagers = new HashMap<Plugin, AdminChatManager>();
private static final HashMap<Plugin, PartyChatManager> partyChatManagers = new HashMap<Plugin, PartyChatManager>();
public static ChatManager getChatManager(Plugin plugin, ChatMode mode) {
switch (mode) {
case ADMIN:
if (!adminChatManagers.containsKey(plugin)) {
adminChatManagers.put(plugin, new AdminChatManager(plugin));
}
return adminChatManagers.get(plugin);
case PARTY:
if (!partyChatManagers.containsKey(plugin)) {
partyChatManagers.put(plugin, new PartyChatManager(plugin));
}
return partyChatManagers.get(plugin);
default:
return null;
}
}
}

View File

@ -1,29 +0,0 @@
package com.gmail.nossr50.chat;
import com.gmail.nossr50.config.Config;
import com.gmail.nossr50.datatypes.party.Party;
import com.gmail.nossr50.events.chat.McMMOPartyChatEvent;
import com.gmail.nossr50.runnables.party.PartyChatTask;
import org.bukkit.plugin.Plugin;
public class PartyChatManager extends ChatManager {
private Party party;
protected PartyChatManager(Plugin plugin) {
super(plugin, Config.getInstance().getPartyDisplayNames(), Config.getInstance().getPartyChatPrefix());
}
public void setParty(Party party) {
this.party = party;
}
@Override
public void handleChat(String senderName, String displayName, String message, boolean isAsync) {
handleChat(new McMMOPartyChatEvent(plugin, senderName, displayName, party.getName(), message, isAsync));
}
@Override
protected void sendMessage() {
new PartyChatTask(plugin, party, senderName, displayName, message).runTask(plugin);
}
}

View File

@ -0,0 +1,36 @@
package com.gmail.nossr50.chat;
import com.gmail.nossr50.datatypes.party.Party;
import com.gmail.nossr50.datatypes.player.McMMOPlayer;
import com.gmail.nossr50.util.player.UserManager;
import org.bukkit.command.CommandSender;
import org.bukkit.command.ConsoleCommandSender;
import org.bukkit.entity.Player;
import java.util.function.Predicate;
public class SamePartyPredicate<T extends CommandSender> implements Predicate<T> {
final Party party;
public SamePartyPredicate(Party party) {
this.party = party;
}
@Override
public boolean test(T t) {
//Include the console in the audience
if(t instanceof ConsoleCommandSender) {
return false; //Party audiences are special, we exclude console from them to avoid double messaging since we send a more verbose version to consoles
} else {
if(t instanceof Player) {
Player player = (Player) t;
McMMOPlayer mcMMOPlayer = UserManager.getPlayer(player);
if(mcMMOPlayer != null) {
return mcMMOPlayer.getParty() == party;
}
}
}
return false;
}
}

View File

@ -0,0 +1,120 @@
package com.gmail.nossr50.chat.author;
import com.gmail.nossr50.datatypes.chat.ChatChannel;
import com.gmail.nossr50.util.text.TextUtils;
import com.google.common.base.Objects;
import org.bukkit.entity.Player;
import org.checkerframework.checker.nullness.qual.NonNull;
import org.jetbrains.annotations.NotNull;
import java.util.HashMap;
import java.util.UUID;
public abstract class AbstractPlayerAuthor implements Author {
private final @NotNull Player player;
private @NotNull String lastKnownDisplayName;
private final @NotNull HashMap<ChatChannel, String> sanitizedNameCache;
public AbstractPlayerAuthor(@NotNull Player player) {
this.player = player;
this.lastKnownDisplayName = player.getDisplayName();
this.sanitizedNameCache = new HashMap<>();
}
/**
* Returns true if a players display name has changed
*
* @return true if the players display name has changed
*/
private boolean hasPlayerDisplayNameChanged() {
return !player.getDisplayName().equals(lastKnownDisplayName);
}
/**
* Player display names can change and this method will update the last known display name of this player
*/
private void updateLastKnownDisplayName() {
lastKnownDisplayName = player.getDisplayName();
}
/**
* Gets a sanitized name for a channel
* Sanitized names are names that are friendly to the {@link net.kyori.adventure.text.serializer.legacy.LegacyComponentSerializer}
* Sanitized names for authors are cached by channel and are only created as needed
* Sanitized names will update if a players display name has updated
*
* @param chatChannel target chat channel
* @return the sanitized name for a player
*/
protected @NotNull String getSanitizedName(@NotNull ChatChannel chatChannel, boolean useDisplayName) {
//Already in cache
if(sanitizedNameCache.containsKey(chatChannel)) {
//Update cache
if(useDisplayName && hasPlayerDisplayNameChanged()) {
updateLastKnownDisplayName();
updateSanitizedNameCache(chatChannel, true);
}
} else {
//Update last known display name
if(useDisplayName && hasPlayerDisplayNameChanged()) {
updateLastKnownDisplayName();
}
//Add cache entry
updateSanitizedNameCache(chatChannel, useDisplayName);
}
return sanitizedNameCache.get(chatChannel);
}
/**
* Update the sanitized name cache
* This will add entries if one didn't exit
* Sanitized names are associated with a {@link ChatChannel} as different chat channels have different chat name settings
*
* @param chatChannel target chat channel
* @param useDisplayName whether or not to use this authors display name
*/
private void updateSanitizedNameCache(@NotNull ChatChannel chatChannel, boolean useDisplayName) {
if(useDisplayName) {
sanitizedNameCache.put(chatChannel, TextUtils.sanitizeForSerializer(player.getDisplayName()));
} else {
//No need to sanitize a basic String
sanitizedNameCache.put(chatChannel, player.getName());
}
}
@Override
public boolean isConsole() {
return false;
}
@Override
public boolean isPlayer() {
return true;
}
public @NotNull Player getPlayer() {
return player;
}
@Override
public @NonNull UUID uuid() {
return player.getUniqueId();
}
@Override
public boolean equals(Object o) {
if (this == o) return true;
if (o == null || getClass() != o.getClass()) return false;
AbstractPlayerAuthor that = (AbstractPlayerAuthor) o;
return Objects.equal(player, that.player) &&
Objects.equal(lastKnownDisplayName, that.lastKnownDisplayName) &&
Objects.equal(sanitizedNameCache, that.sanitizedNameCache);
}
@Override
public int hashCode() {
return Objects.hashCode(player, lastKnownDisplayName, sanitizedNameCache);
}
}

View File

@ -0,0 +1,31 @@
package com.gmail.nossr50.chat.author;
import com.gmail.nossr50.datatypes.chat.ChatChannel;
import net.kyori.adventure.identity.Identity;
import org.jetbrains.annotations.NotNull;
public interface Author extends Identity {
/**
* The name of this author as used in mcMMO chat
* This is the {@link String} representation of the users current chat username
* This can either be the player's display name or the player's official registered nickname with Mojang it depends on the servers chat settings for mcMMO
*
* @param chatChannel which chat channel this is going to
* @return The name of this author as used in mcMMO chat
*/
@NotNull String getAuthoredName(@NotNull ChatChannel chatChannel);
/**
* Whether or not this author is a {@link org.bukkit.command.ConsoleCommandSender}
*
* @return true if this author is the console
*/
boolean isConsole();
/**
* Whether or not this author is a {@link org.bukkit.entity.Player}
* @return true if this author is a player
*/
boolean isPlayer();
}

View File

@ -0,0 +1,39 @@
package com.gmail.nossr50.chat.author;
import com.gmail.nossr50.datatypes.chat.ChatChannel;
import com.gmail.nossr50.util.text.TextUtils;
import org.checkerframework.checker.nullness.qual.NonNull;
import org.jetbrains.annotations.NotNull;
import java.util.UUID;
public class ConsoleAuthor implements Author {
private final UUID uuid;
private final @NotNull String name;
public ConsoleAuthor(@NotNull String name) {
this.uuid = new UUID(0, 0);
this.name = TextUtils.sanitizeForSerializer(name);
}
//TODO: Think of a less clunky solution later
@Override
public @NotNull String getAuthoredName(@NotNull ChatChannel chatChannel) {
return name;
}
@Override
public boolean isConsole() {
return true;
}
@Override
public boolean isPlayer() {
return false;
}
@Override
public @NonNull UUID uuid() {
return uuid;
}
}

View File

@ -0,0 +1,19 @@
package com.gmail.nossr50.chat.author;
import com.gmail.nossr50.config.ChatConfig;
import com.gmail.nossr50.datatypes.chat.ChatChannel;
import org.bukkit.entity.Player;
import org.jetbrains.annotations.NotNull;
public class PlayerAuthor extends AbstractPlayerAuthor {
public PlayerAuthor(@NotNull Player player) {
super(player);
}
@Override
public @NotNull String getAuthoredName(@NotNull ChatChannel chatChannel) {
return getSanitizedName(chatChannel, ChatConfig.getInstance().useDisplayNames(chatChannel));
}
}

View File

@ -0,0 +1,13 @@
package com.gmail.nossr50.chat.mailer;
import org.bukkit.plugin.Plugin;
import org.jetbrains.annotations.NotNull;
public abstract class AbstractChatMailer implements ChatMailer {
protected final @NotNull Plugin pluginRef;
public AbstractChatMailer(@NotNull Plugin pluginRef) {
this.pluginRef = pluginRef;
}
}

View File

@ -0,0 +1,91 @@
package com.gmail.nossr50.chat.mailer;
import com.gmail.nossr50.chat.author.Author;
import com.gmail.nossr50.chat.message.AdminChatMessage;
import com.gmail.nossr50.chat.message.ChatMessage;
import com.gmail.nossr50.datatypes.chat.ChatChannel;
import com.gmail.nossr50.events.chat.McMMOAdminChatEvent;
import com.gmail.nossr50.events.chat.McMMOChatEvent;
import com.gmail.nossr50.locale.LocaleLoader;
import com.gmail.nossr50.mcMMO;
import com.gmail.nossr50.util.text.TextUtils;
import net.kyori.adventure.audience.Audience;
import net.kyori.adventure.text.TextComponent;
import org.bukkit.Bukkit;
import org.bukkit.command.CommandSender;
import org.bukkit.command.ConsoleCommandSender;
import org.bukkit.plugin.Plugin;
import org.jetbrains.annotations.NotNull;
import java.util.function.Predicate;
public class AdminChatMailer extends AbstractChatMailer {
public AdminChatMailer(Plugin pluginRef) {
super(pluginRef);
}
public static final @NotNull String MCMMO_CHAT_ADMINCHAT_PERMISSION = "mcmmo.chat.adminchat";
/**
* Constructs an audience of admins
*
* @return an audience of admins
*/
public @NotNull Audience constructAudience() {
return mcMMO.getAudiences().filter(predicate());
}
/**
* Predicate used to filter the audience
*
* @return admin chat audience predicate
*/
public @NotNull Predicate<CommandSender> predicate() {
return (commandSender) -> commandSender.isOp()
|| commandSender.hasPermission(MCMMO_CHAT_ADMINCHAT_PERMISSION)
|| commandSender instanceof ConsoleCommandSender;
}
/**
* Styles a string using a locale entry
*
* @param author message author
* @param message message contents
* @param canColor whether to replace colors codes with colors in the raw message
* @return the styled string, based on a locale entry
*/
public @NotNull TextComponent addStyle(@NotNull Author author, @NotNull String message, boolean canColor) {
if(canColor) {
return LocaleLoader.getTextComponent("Chat.Style.Admin", author.getAuthoredName(ChatChannel.ADMIN), message);
} else {
return TextUtils.ofLegacyTextRaw(LocaleLoader.getString("Chat.Style.Admin", author.getAuthoredName(ChatChannel.ADMIN), message));
}
}
@Override
public void sendMail(@NotNull ChatMessage chatMessage) {
chatMessage.sendMessage();
}
/**
* Processes a chat message from an author to an audience of admins
*
* @param author the author
* @param rawString the raw message as the author typed it before any styling
* @param isAsync whether or not this is being processed asynchronously
* @param canColor whether or not the author can use colors in chat
*/
public void processChatMessage(@NotNull Author author, @NotNull String rawString, boolean isAsync, boolean canColor) {
AdminChatMessage chatMessage = new AdminChatMessage(pluginRef, author, constructAudience(), rawString, addStyle(author, rawString, canColor));
McMMOChatEvent chatEvent = new McMMOAdminChatEvent(pluginRef, chatMessage, isAsync);
Bukkit.getPluginManager().callEvent(chatEvent);
if(!chatEvent.isCancelled()) {
sendMail(chatMessage);
}
}
}

View File

@ -0,0 +1,12 @@
package com.gmail.nossr50.chat.mailer;
import com.gmail.nossr50.chat.message.ChatMessage;
import org.jetbrains.annotations.NotNull;
public interface ChatMailer {
/**
* Send out a chat message
* @param chatMessage the {@link ChatMessage}
*/
void sendMail(@NotNull ChatMessage chatMessage);
}

View File

@ -0,0 +1,82 @@
package com.gmail.nossr50.chat.mailer;
import com.gmail.nossr50.chat.author.Author;
import com.gmail.nossr50.chat.message.ChatMessage;
import com.gmail.nossr50.chat.message.PartyChatMessage;
import com.gmail.nossr50.datatypes.chat.ChatChannel;
import com.gmail.nossr50.datatypes.party.Party;
import com.gmail.nossr50.events.chat.McMMOChatEvent;
import com.gmail.nossr50.events.chat.McMMOPartyChatEvent;
import com.gmail.nossr50.locale.LocaleLoader;
import com.gmail.nossr50.mcMMO;
import com.gmail.nossr50.util.text.TextUtils;
import net.kyori.adventure.audience.Audience;
import net.kyori.adventure.text.TextComponent;
import org.bukkit.Bukkit;
import org.bukkit.plugin.Plugin;
import org.jetbrains.annotations.NotNull;
public class PartyChatMailer extends AbstractChatMailer {
public PartyChatMailer(@NotNull Plugin pluginRef) {
super(pluginRef);
}
/**
* Processes a chat message from an author to an audience of party members
*
* @param author the author
* @param rawString the raw message as the author typed it before any styling
* @param isAsync whether or not this is being processed asynchronously
* @param canColor whether or not the author can use colors in chat
*/
public void processChatMessage(@NotNull Author author, @NotNull String rawString, @NotNull Party party, boolean isAsync, boolean canColor, boolean isLeader) {
PartyChatMessage chatMessage = new PartyChatMessage(pluginRef, author, constructPartyAudience(party), rawString, addStyle(author, rawString, canColor, isLeader), party);
McMMOChatEvent chatEvent = new McMMOPartyChatEvent(pluginRef, chatMessage, party, isAsync);
Bukkit.getPluginManager().callEvent(chatEvent);
if(!chatEvent.isCancelled()) {
sendMail(chatMessage);
}
}
/**
* Constructs an {@link Audience} of party members
*
* @param party target party
* @return an {@link Audience} of party members
*/
public @NotNull Audience constructPartyAudience(@NotNull Party party) {
return mcMMO.getAudiences().filter(party.getSamePartyPredicate());
}
/**
* Styles a string using a locale entry
*
* @param author message author
* @param message message contents
* @param canColor whether to replace colors codes with colors in the raw message
* @return the styled string, based on a locale entry
*/
public @NotNull TextComponent addStyle(@NotNull Author author, @NotNull String message, boolean canColor, boolean isLeader) {
if(canColor) {
if(isLeader) {
return LocaleLoader.getTextComponent("Chat.Style.Party.Leader", author.getAuthoredName(ChatChannel.PARTY), message);
} else {
return LocaleLoader.getTextComponent("Chat.Style.Party", author.getAuthoredName(ChatChannel.PARTY), message);
}
} else {
if(isLeader) {
return TextUtils.ofLegacyTextRaw(LocaleLoader.getString("Chat.Style.Party.Leader", author.getAuthoredName(ChatChannel.PARTY), message));
} else {
return TextUtils.ofLegacyTextRaw(LocaleLoader.getString("Chat.Style.Party", author.getAuthoredName(ChatChannel.PARTY), message));
}
}
}
@Override
public void sendMail(@NotNull ChatMessage chatMessage) {
chatMessage.sendMessage();
}
}

View File

@ -0,0 +1,72 @@
package com.gmail.nossr50.chat.message;
import com.gmail.nossr50.chat.author.Author;
import com.google.common.base.Objects;
import net.kyori.adventure.audience.Audience;
import net.kyori.adventure.text.TextComponent;
import org.bukkit.plugin.Plugin;
import org.jetbrains.annotations.NotNull;
public abstract class AbstractChatMessage implements ChatMessage {
protected final @NotNull Plugin pluginRef;
protected final @NotNull Author author;
protected final @NotNull String rawMessage;
protected @NotNull TextComponent componentMessage;
protected @NotNull Audience audience;
public AbstractChatMessage(@NotNull Plugin pluginRef, @NotNull Author author, @NotNull Audience audience, @NotNull String rawMessage, @NotNull TextComponent componentMessage) {
this.pluginRef = pluginRef;
this.author = author;
this.audience = audience;
this.rawMessage = rawMessage;
this.componentMessage = componentMessage;
}
@Override
public @NotNull String rawMessage() {
return rawMessage;
}
@Override
public @NotNull Author getAuthor() {
return author;
}
@Override
public @NotNull Audience getAudience() {
return audience;
}
@Override
public @NotNull TextComponent getChatMessage() {
return componentMessage;
}
@Override
public void setChatMessage(@NotNull TextComponent textComponent) {
this.componentMessage = textComponent;
}
@Override
public void setAudience(@NotNull Audience newAudience) {
audience = newAudience;
}
@Override
public boolean equals(Object o) {
if (this == o) return true;
if (o == null || getClass() != o.getClass()) return false;
AbstractChatMessage that = (AbstractChatMessage) o;
return Objects.equal(pluginRef, that.pluginRef) &&
Objects.equal(author, that.author) &&
Objects.equal(rawMessage, that.rawMessage) &&
Objects.equal(componentMessage, that.componentMessage) &&
Objects.equal(audience, that.audience);
}
@Override
public int hashCode() {
return Objects.hashCode(pluginRef, author, rawMessage, componentMessage, audience);
}
}

View File

@ -0,0 +1,24 @@
package com.gmail.nossr50.chat.message;
import com.gmail.nossr50.chat.author.Author;
import com.gmail.nossr50.datatypes.chat.ChatChannel;
import net.kyori.adventure.audience.Audience;
import net.kyori.adventure.text.TextComponent;
import org.bukkit.plugin.Plugin;
import org.jetbrains.annotations.NotNull;
public class AdminChatMessage extends AbstractChatMessage {
public AdminChatMessage(@NotNull Plugin pluginRef, @NotNull Author author, @NotNull Audience audience, @NotNull String rawMessage, @NotNull TextComponent componentMessage) {
super(pluginRef, author, audience, rawMessage, componentMessage);
}
@Override
public void sendMessage() {
audience.sendMessage(author, componentMessage);
}
@Override
public @NotNull String getAuthorDisplayName() {
return author.getAuthoredName(ChatChannel.ADMIN);
}
}

View File

@ -0,0 +1,73 @@
package com.gmail.nossr50.chat.message;
import com.gmail.nossr50.chat.author.Author;
import net.kyori.adventure.audience.Audience;
import net.kyori.adventure.text.TextComponent;
import org.jetbrains.annotations.NotNull;
public interface ChatMessage {
/**
* The original message from the {@link Author}
* This is formatted and styled before being sent out to players by mcMMO
*
* @return the original message without any formatting or alterations
* @see #getChatMessage()
*/
@NotNull String rawMessage();
/**
* The {@link Author} from which this payload originated
*
* @see #getChatMessage()
* @return the source of the chat message
*/
@NotNull Author getAuthor();
/**
* The authors display name which is used in the initial creation of the message payload, it is provided for convenience.
*
* This is a name generated by mcMMO during the creation of the {@link ChatMessage}
*
* This is used by mcMMO when generating the message payload
*
* This method provides the display name for the convenience of plugins constructing their own {@link TextComponent payloads}
*
* @see #getChatMessage()
* @return the author display name as generated by mcMMO
*/
@NotNull String getAuthorDisplayName();
/**
* The target audience of this chat message
* Unless modified, this will include the {@link Author}
*
* @return target audience
*/
@NotNull Audience getAudience();
/**
* The {@link TextComponent message} being sent to the audience
*
* @return the {@link TextComponent message} that will be sent to the audience
*/
@NotNull TextComponent getChatMessage();
/**
* Change the value of the {@link TextComponent message}
*
* @param textComponent new message value
*/
void setChatMessage(@NotNull TextComponent textComponent);
/**
* Changes the audience
*
* @param newAudience the replacement audience
*/
void setAudience(@NotNull Audience newAudience);
/**
* Deliver the message to the audience
*/
void sendMessage();
}

View File

@ -0,0 +1,94 @@
package com.gmail.nossr50.chat.message;
import com.gmail.nossr50.chat.author.Author;
import com.gmail.nossr50.datatypes.chat.ChatChannel;
import com.gmail.nossr50.datatypes.party.Party;
import com.gmail.nossr50.datatypes.player.McMMOPlayer;
import com.gmail.nossr50.locale.LocaleLoader;
import com.gmail.nossr50.mcMMO;
import com.gmail.nossr50.util.player.UserManager;
import com.google.common.base.Objects;
import net.kyori.adventure.audience.Audience;
import net.kyori.adventure.text.TextComponent;
import org.bukkit.entity.Player;
import org.bukkit.plugin.Plugin;
import org.jetbrains.annotations.NotNull;
public class PartyChatMessage extends AbstractChatMessage {
private final @NotNull Party party;
public PartyChatMessage(@NotNull Plugin pluginRef, @NotNull Author author, @NotNull Audience audience, @NotNull String rawMessage, @NotNull TextComponent componentMessage, @NotNull Party party) {
super(pluginRef, author, audience, rawMessage, componentMessage);
this.party = party;
}
/**
* The party that this chat message was intended for
* @return the party that this message was intended for
*/
public @NotNull Party getParty() {
return party;
}
@Override
public @NotNull String getAuthorDisplayName() {
return author.getAuthoredName(ChatChannel.PARTY);
}
@Override
public void sendMessage() {
/*
* It should be noted that Party messages don't include console as part of the audience to avoid double messaging
* The console gets a message that has the party name included, player parties do not
*/
//Sends to everyone but console
audience.sendMessage(author, componentMessage);
TextComponent spyMessage = LocaleLoader.getTextComponent("Chat.Spy.Party", author.getAuthoredName(ChatChannel.PARTY), rawMessage, party.getName());
//Relay to spies
messagePartyChatSpies(spyMessage);
//Console message
mcMMO.p.getChatManager().sendConsoleMessage(author, spyMessage);
}
/**
* Console and Party Chat Spies get a more verbose version of the message
* Party Chat Spies will get a copy of the message as well
* @param spyMessage the message to copy to spies
*/
private void messagePartyChatSpies(@NotNull TextComponent spyMessage) {
//Find the people with permissions
for(McMMOPlayer mcMMOPlayer : UserManager.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 || adminParty != getParty()) {
//TODO: Hacky, rewrite later
Audience audience = mcMMO.getAudiences().player(player);
audience.sendMessage(spyMessage);
}
}
}
}
@Override
public boolean equals(Object o) {
if (this == o) return true;
if (o == null || getClass() != o.getClass()) return false;
if (!super.equals(o)) return false;
PartyChatMessage that = (PartyChatMessage) o;
return Objects.equal(party, that.party);
}
@Override
public int hashCode() {
return Objects.hashCode(super.hashCode(), party);
}
}

View File

@ -0,0 +1,116 @@
package com.gmail.nossr50.commands;
import co.aikar.commands.BukkitCommandIssuer;
import co.aikar.commands.BukkitCommandManager;
import co.aikar.commands.ConditionFailedException;
import com.gmail.nossr50.commands.chat.AdminChatCommand;
import com.gmail.nossr50.commands.chat.PartyChatCommand;
import com.gmail.nossr50.config.ChatConfig;
import com.gmail.nossr50.datatypes.chat.ChatChannel;
import com.gmail.nossr50.datatypes.player.McMMOPlayer;
import com.gmail.nossr50.locale.LocaleLoader;
import com.gmail.nossr50.mcMMO;
import com.gmail.nossr50.util.Permissions;
import com.gmail.nossr50.util.player.UserManager;
import org.bukkit.entity.Player;
import org.bukkit.permissions.Permissible;
import org.jetbrains.annotations.NotNull;
/*
* For now this class will only handle ACF converted commands, all other commands will be handled elsewhere
*/
public class CommandManager {
public static final @NotNull String ADMIN_CONDITION = "adminCondition";
public static final @NotNull String PARTY_CONDITION = "partyCondition";
public static final @NotNull String MMO_DATA_LOADED = "mmoDataLoaded";
private final @NotNull mcMMO pluginRef;
private final @NotNull BukkitCommandManager bukkitCommandManager;
public CommandManager(@NotNull mcMMO pluginRef) {
this.pluginRef = pluginRef;
bukkitCommandManager = new BukkitCommandManager(pluginRef);
registerConditions();
registerCommands();
}
private void registerCommands() {
registerChatCommands();
}
/**
* Registers chat commands if the chat system is enabled
*/
private void registerChatCommands() {
if(ChatConfig.getInstance().isChatEnabled()) {
if(ChatConfig.getInstance().isChatChannelEnabled(ChatChannel.ADMIN)) {
bukkitCommandManager.registerCommand(new AdminChatCommand(pluginRef));
}
if(ChatConfig.getInstance().isChatChannelEnabled(ChatChannel.PARTY)) {
bukkitCommandManager.registerCommand(new PartyChatCommand(pluginRef));
}
}
}
public void registerConditions() {
// Method or Class based - Can only be used on methods
bukkitCommandManager.getCommandConditions().addCondition(ADMIN_CONDITION, (context) -> {
BukkitCommandIssuer issuer = context.getIssuer();
if(issuer.getIssuer() instanceof Player) {
validateLoadedData(issuer.getPlayer());
validateAdmin(issuer.getPlayer());
}
});
bukkitCommandManager.getCommandConditions().addCondition(MMO_DATA_LOADED, (context) -> {
BukkitCommandIssuer bukkitCommandIssuer = context.getIssuer();
if(bukkitCommandIssuer.getIssuer() instanceof Player) {
validateLoadedData(bukkitCommandIssuer.getPlayer());
}
});
bukkitCommandManager.getCommandConditions().addCondition(PARTY_CONDITION, (context) -> {
BukkitCommandIssuer bukkitCommandIssuer = context.getIssuer();
if(bukkitCommandIssuer.getIssuer() instanceof Player) {
validateLoadedData(bukkitCommandIssuer.getPlayer());
validatePlayerParty(bukkitCommandIssuer.getPlayer());
validatePermission("mcmmo.chat.partychat", bukkitCommandIssuer.getPlayer());
}
});
}
private void validatePermission(@NotNull String permissionNode, @NotNull Permissible permissible) {
if(!permissible.hasPermission(permissionNode)) {
throw new ConditionFailedException(LocaleLoader.getString("mcMMO.NoPermission"));
}
}
public void validateAdmin(@NotNull Player player) {
if(!player.isOp() && !Permissions.adminChat(player)) {
throw new ConditionFailedException("You are lacking the correct permissions to use this command.");
}
}
public void validateLoadedData(@NotNull Player player) {
if(UserManager.getPlayer(player) == null) {
throw new ConditionFailedException(LocaleLoader.getString("Profile.PendingLoad"));
}
}
public void validatePlayerParty(@NotNull Player player) {
McMMOPlayer mmoPlayer = UserManager.getPlayer(player);
if(mmoPlayer.getParty() == null) {
throw new ConditionFailedException(LocaleLoader.getString("Commands.Party.None"));
}
}
public @NotNull BukkitCommandManager getBukkitCommandManager() {
return bukkitCommandManager;
}
}

View File

@ -1,45 +0,0 @@
package com.gmail.nossr50.commands;
import com.gmail.nossr50.config.Config;
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.gmail.nossr50.util.player.UserManager;
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 MHDCommand implements TabExecutor {
@Override
public boolean onCommand(CommandSender sender, Command command, String label, String[] args) {
if (mcMMO.getDatabaseManager() instanceof SQLDatabaseManager) {
SQLDatabaseManager m = (SQLDatabaseManager) mcMMO.getDatabaseManager();
m.resetMobHealthSettings();
for (McMMOPlayer player : UserManager.getPlayers()) {
player.getProfile().setMobHealthbarType(Config.getInstance().getMobHealthbarDefault());
}
sender.sendMessage("Mob health reset");
return true;
}
if (mcMMO.getDatabaseManager() instanceof FlatfileDatabaseManager) {
FlatfileDatabaseManager m = (FlatfileDatabaseManager) mcMMO.getDatabaseManager();
m.resetMobHealthSettings();
for (McMMOPlayer player : UserManager.getPlayers()) {
player.getProfile().setMobHealthbarType(Config.getInstance().getMobHealthbarDefault());
}
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

@ -7,6 +7,7 @@ import org.bukkit.Material;
import org.bukkit.command.Command; import org.bukkit.command.Command;
import org.bukkit.command.CommandExecutor; import org.bukkit.command.CommandExecutor;
import org.bukkit.command.CommandSender; import org.bukkit.command.CommandSender;
import org.jetbrains.annotations.NotNull;
import java.io.*; import java.io.*;
import java.util.ArrayList; import java.util.ArrayList;
@ -17,15 +18,12 @@ public class McImportCommand implements CommandExecutor {
int fileAmount; int fileAmount;
@Override @Override
public boolean onCommand(CommandSender sender, Command command, String label, String[] args) { public boolean onCommand(@NotNull CommandSender sender, @NotNull Command command, @NotNull String label, String[] args) {
switch (args.length) { if (args.length == 0) {
case 0: importModConfig();
importModConfig(); return true;
return true;
default:
return false;
} }
return false;
} }
public boolean importModConfig() { public boolean importModConfig() {
@ -34,7 +32,7 @@ public class McImportCommand implements CommandExecutor {
mcMMO.p.getLogger().info("Starting import of mod materials..."); mcMMO.p.getLogger().info("Starting import of mod materials...");
fileAmount = 0; fileAmount = 0;
HashMap<ModConfigType, ArrayList<String>> materialNames = new HashMap<ModConfigType, ArrayList<String>>(); HashMap<ModConfigType, ArrayList<String>> materialNames = new HashMap<>();
BufferedReader in = null; BufferedReader in = null;
@ -66,11 +64,10 @@ public class McImportCommand implements CommandExecutor {
ModConfigType type = ModConfigType.getModConfigType(materialName); ModConfigType type = ModConfigType.getModConfigType(materialName);
if (!materialNames.containsKey(type)) { if (!materialNames.containsKey(type)) {
materialNames.put(type, new ArrayList<String>()); materialNames.put(type, new ArrayList<>());
} }
materialNames.get(type).add(materialName); materialNames.get(type).add(materialName);
continue;
} }
} }
catch (FileNotFoundException e) { catch (FileNotFoundException e) {
@ -94,13 +91,13 @@ public class McImportCommand implements CommandExecutor {
private void createOutput(HashMap<ModConfigType, ArrayList<String>> materialNames) { private void createOutput(HashMap<ModConfigType, ArrayList<String>> materialNames) {
for (ModConfigType modConfigType : materialNames.keySet()) { for (ModConfigType modConfigType : materialNames.keySet()) {
HashMap<String, ArrayList<String>> materialNamesType = new HashMap<String, ArrayList<String>>(); HashMap<String, ArrayList<String>> materialNamesType = new HashMap<>();
for (String materialName : materialNames.get(modConfigType)) { for (String materialName : materialNames.get(modConfigType)) {
String modName = Misc.getModName(materialName); String modName = Misc.getModName(materialName);
if (!materialNamesType.containsKey(modName)) { if (!materialNamesType.containsKey(modName)) {
materialNamesType.put(modName, new ArrayList<String>()); materialNamesType.put(modName, new ArrayList<>());
} }
materialNamesType.get(modName).add(materialName); materialNamesType.get(modName).add(materialName);
@ -170,16 +167,10 @@ public class McImportCommand implements CommandExecutor {
out = new FileWriter(outputFile); out = new FileWriter(outputFile);
out.write(writer.toString()); out.write(writer.toString());
} } catch (Exception e) {
catch (IOException e) {
e.printStackTrace(); e.printStackTrace();
return; return;
} } finally {
catch (Exception e) {
e.printStackTrace();
return;
}
finally {
tryClose(out); tryClose(out);
fileAmount++; fileAmount++;
} }
@ -202,7 +193,7 @@ public class McImportCommand implements CommandExecutor {
} }
private HashMap<String, ArrayList<String>> getConfigSectionsBlocks(String modName, HashMap<String, ArrayList<String>> materialNames) { private HashMap<String, ArrayList<String>> getConfigSectionsBlocks(String modName, HashMap<String, ArrayList<String>> materialNames) {
HashMap<String, ArrayList<String>> configSections = new HashMap<String, ArrayList<String>>(); HashMap<String, ArrayList<String>> configSections = new HashMap<>();
// Go through all the materials and categorise them under a skill // Go through all the materials and categorise them under a skill
for (String materialName : materialNames.get(modName)) { for (String materialName : materialNames.get(modName)) {
@ -221,7 +212,7 @@ public class McImportCommand implements CommandExecutor {
} }
if (!configSections.containsKey(skillName)) { if (!configSections.containsKey(skillName)) {
configSections.put(skillName, new ArrayList<String>()); configSections.put(skillName, new ArrayList<>());
} }
ArrayList<String> skillContents = configSections.get(skillName); ArrayList<String> skillContents = configSections.get(skillName);
@ -241,7 +232,7 @@ public class McImportCommand implements CommandExecutor {
} }
private HashMap<String, ArrayList<String>> getConfigSectionsTools(String modName, HashMap<String, ArrayList<String>> materialNames) { private HashMap<String, ArrayList<String>> getConfigSectionsTools(String modName, HashMap<String, ArrayList<String>> materialNames) {
HashMap<String, ArrayList<String>> configSections = new HashMap<String, ArrayList<String>>(); HashMap<String, ArrayList<String>> configSections = new HashMap<>();
// Go through all the materials and categorise them under a tool type // Go through all the materials and categorise them under a tool type
for (String materialName : materialNames.get(modName)) { for (String materialName : materialNames.get(modName)) {
@ -266,7 +257,7 @@ public class McImportCommand implements CommandExecutor {
} }
if (!configSections.containsKey(toolType)) { if (!configSections.containsKey(toolType)) {
configSections.put(toolType, new ArrayList<String>()); configSections.put(toolType, new ArrayList<>());
} }
ArrayList<String> skillContents = configSections.get(toolType); ArrayList<String> skillContents = configSections.get(toolType);
@ -281,7 +272,7 @@ public class McImportCommand implements CommandExecutor {
} }
private HashMap<String, ArrayList<String>> getConfigSectionsArmor(String modName, HashMap<String, ArrayList<String>> materialNames) { private HashMap<String, ArrayList<String>> getConfigSectionsArmor(String modName, HashMap<String, ArrayList<String>> materialNames) {
HashMap<String, ArrayList<String>> configSections = new HashMap<String, ArrayList<String>>(); HashMap<String, ArrayList<String>> configSections = new HashMap<>();
// Go through all the materials and categorise them under an armor type // Go through all the materials and categorise them under an armor type
for (String materialName : materialNames.get(modName)) { for (String materialName : materialNames.get(modName)) {
@ -300,7 +291,7 @@ public class McImportCommand implements CommandExecutor {
} }
if (!configSections.containsKey(toolType)) { if (!configSections.containsKey(toolType)) {
configSections.put(toolType, new ArrayList<String>()); configSections.put(toolType, new ArrayList<>());
} }
ArrayList<String> skillContents = configSections.get(toolType); ArrayList<String> skillContents = configSections.get(toolType);
@ -326,14 +317,14 @@ public class McImportCommand implements CommandExecutor {
} }
private HashMap<String, ArrayList<String>> getConfigSectionsUnknown(String modName, HashMap<String, ArrayList<String>> materialNames) { private HashMap<String, ArrayList<String>> getConfigSectionsUnknown(String modName, HashMap<String, ArrayList<String>> materialNames) {
HashMap<String, ArrayList<String>> configSections = new HashMap<String, ArrayList<String>>(); HashMap<String, ArrayList<String>> configSections = new HashMap<>();
// Go through all the materials and print them // Go through all the materials and print them
for (String materialName : materialNames.get(modName)) { for (String materialName : materialNames.get(modName)) {
String configKey = "UNIDENTIFIED"; String configKey = "UNIDENTIFIED";
if (!configSections.containsKey(configKey)) { if (!configSections.containsKey(configKey)) {
configSections.put(configKey, new ArrayList<String>()); configSections.put(configKey, new ArrayList<>());
} }
ArrayList<String> skillContents = configSections.get(configKey); ArrayList<String> skillContents = configSections.get(configKey);

View File

@ -12,6 +12,7 @@ import org.bukkit.command.CommandExecutor;
import org.bukkit.command.CommandSender; import org.bukkit.command.CommandSender;
import org.bukkit.command.TabExecutor; import org.bukkit.command.TabExecutor;
import org.bukkit.util.StringUtil; import org.bukkit.util.StringUtil;
import org.jetbrains.annotations.NotNull;
import java.util.ArrayList; import java.util.ArrayList;
import java.util.Collections; import java.util.Collections;
@ -22,12 +23,12 @@ public class McconvertCommand implements TabExecutor {
private static final List<String> DATABASE_TYPES; private static final List<String> DATABASE_TYPES;
private static final List<String> SUBCOMMANDS = ImmutableList.of("database", "experience"); private static final List<String> SUBCOMMANDS = ImmutableList.of("database", "experience");
private CommandExecutor databaseConvertCommand = new ConvertDatabaseCommand(); private final CommandExecutor databaseConvertCommand = new ConvertDatabaseCommand();
private CommandExecutor experienceConvertCommand = new ConvertExperienceCommand(); private final CommandExecutor experienceConvertCommand = new ConvertExperienceCommand();
static { static {
ArrayList<String> formulaTypes = new ArrayList<String>(); ArrayList<String> formulaTypes = new ArrayList<>();
ArrayList<String> databaseTypes = new ArrayList<String>(); ArrayList<String> databaseTypes = new ArrayList<>();
for (FormulaType type : FormulaType.values()) { for (FormulaType type : FormulaType.values()) {
formulaTypes.add(type.toString()); formulaTypes.add(type.toString());
@ -53,34 +54,31 @@ public class McconvertCommand implements TabExecutor {
} }
@Override @Override
public boolean onCommand(CommandSender sender, Command command, String label, String[] args) { public boolean onCommand(@NotNull CommandSender sender, @NotNull Command command, @NotNull String label, String[] args) {
switch (args.length) { if (args.length == 2) {
case 2: if (args[0].equalsIgnoreCase("database") || args[0].equalsIgnoreCase("db")) {
if (args[0].equalsIgnoreCase("database") || args[0].equalsIgnoreCase("db")) { return databaseConvertCommand.onCommand(sender, command, label, args);
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);
else if (args[0].equalsIgnoreCase("experience") || args[0].equalsIgnoreCase("xp") || args[1].equalsIgnoreCase("exp")) { }
return experienceConvertCommand.onCommand(sender, command, label, args);
}
return false; return false;
default:
return false;
} }
return false;
} }
@Override @Override
public List<String> onTabComplete(CommandSender sender, Command command, String alias, String[] args) { public List<String> onTabComplete(@NotNull CommandSender sender, @NotNull Command command, @NotNull String alias, String[] args) {
switch (args.length) { switch (args.length) {
case 1: case 1:
return StringUtil.copyPartialMatches(args[0], SUBCOMMANDS, new ArrayList<String>(SUBCOMMANDS.size())); return StringUtil.copyPartialMatches(args[0], SUBCOMMANDS, new ArrayList<>(SUBCOMMANDS.size()));
case 2: case 2:
if (args[0].equalsIgnoreCase("database") || args[0].equalsIgnoreCase("db")) { if (args[0].equalsIgnoreCase("database") || args[0].equalsIgnoreCase("db")) {
return StringUtil.copyPartialMatches(args[0], DATABASE_TYPES, new ArrayList<String>(DATABASE_TYPES.size())); return StringUtil.copyPartialMatches(args[0], DATABASE_TYPES, new ArrayList<>(DATABASE_TYPES.size()));
} }
if (args[0].equalsIgnoreCase("experience") || args[0].equalsIgnoreCase("xp") || args[0].equalsIgnoreCase("exp")) { if (args[0].equalsIgnoreCase("experience") || args[0].equalsIgnoreCase("xp") || args[0].equalsIgnoreCase("exp")) {
return StringUtil.copyPartialMatches(args[0], FORMULA_TYPES, new ArrayList<String>(FORMULA_TYPES.size())); return StringUtil.copyPartialMatches(args[0], FORMULA_TYPES, new ArrayList<>(FORMULA_TYPES.size()));
} }
return ImmutableList.of(); return ImmutableList.of();

View File

@ -1,7 +1,6 @@
package com.gmail.nossr50.commands; package com.gmail.nossr50.commands;
import com.gmail.nossr50.commands.party.PartySubcommandType; import com.gmail.nossr50.commands.party.PartySubcommandType;
import com.gmail.nossr50.config.Config;
import com.gmail.nossr50.locale.LocaleLoader; import com.gmail.nossr50.locale.LocaleLoader;
import com.gmail.nossr50.mcMMO; import com.gmail.nossr50.mcMMO;
import com.gmail.nossr50.util.Permissions; import com.gmail.nossr50.util.Permissions;
@ -9,10 +8,11 @@ import org.bukkit.ChatColor;
import org.bukkit.command.Command; import org.bukkit.command.Command;
import org.bukkit.command.CommandExecutor; import org.bukkit.command.CommandExecutor;
import org.bukkit.command.CommandSender; import org.bukkit.command.CommandSender;
import org.jetbrains.annotations.NotNull;
public class McmmoCommand implements CommandExecutor { public class McmmoCommand implements CommandExecutor {
@Override @Override
public boolean onCommand(CommandSender sender, Command command, String label, String[] args) { public boolean onCommand(@NotNull CommandSender sender, @NotNull Command command, @NotNull String label, String[] args) {
switch (args.length) { switch (args.length) {
case 0: case 0:
if (!Permissions.mcmmoDescription(sender)) { if (!Permissions.mcmmoDescription(sender)) {
@ -25,7 +25,7 @@ public class McmmoCommand implements CommandExecutor {
sender.sendMessage(mcSplit); sender.sendMessage(mcSplit);
sender.sendMessage(LocaleLoader.getString("mcMMO.Description.FormerDevs")); sender.sendMessage(LocaleLoader.getString("mcMMO.Description.FormerDevs"));
if (Config.getInstance().getDonateMessageEnabled()) { if (mcMMO.p.getGeneralConfig().getDonateMessageEnabled()) {
sender.sendMessage(LocaleLoader.getString("MOTD.Donate")); sender.sendMessage(LocaleLoader.getString("MOTD.Donate"));
sender.sendMessage(ChatColor.GOLD + " - " + ChatColor.GREEN + "nossr50@gmail.com" + ChatColor.GOLD + " Paypal"); sender.sendMessage(ChatColor.GOLD + " - " + ChatColor.GREEN + "nossr50@gmail.com" + ChatColor.GOLD + " Paypal");
} }
@ -34,7 +34,7 @@ public class McmmoCommand implements CommandExecutor {
sender.sendMessage(LocaleLoader.getString("MOTD.Version", mcMMO.p.getDescription().getVersion())); sender.sendMessage(LocaleLoader.getString("MOTD.Version", mcMMO.p.getDescription().getVersion()));
} }
mcMMO.getHolidayManager().anniversaryCheck(sender); // mcMMO.getHolidayManager().anniversaryCheck(sender);
return true; return true;
case 1: case 1:

View File

@ -9,35 +9,33 @@ import org.bukkit.command.Command;
import org.bukkit.command.CommandSender; import org.bukkit.command.CommandSender;
import org.bukkit.command.TabExecutor; import org.bukkit.command.TabExecutor;
import org.bukkit.entity.Player; import org.bukkit.entity.Player;
import org.jetbrains.annotations.NotNull;
import java.util.List; import java.util.List;
public class McnotifyCommand implements TabExecutor { public class McnotifyCommand implements TabExecutor {
@Override @Override
public boolean onCommand(CommandSender sender, Command command, String label, String[] args) { public boolean onCommand(@NotNull CommandSender sender, @NotNull Command command, @NotNull String label, String[] args) {
if (CommandUtils.noConsoleUsage(sender)) { if (CommandUtils.noConsoleUsage(sender)) {
return true; return true;
} }
switch (args.length) { if (args.length == 0) {
case 0: McMMOPlayer mcMMOPlayer = UserManager.getPlayer((Player) sender);
McMMOPlayer mcMMOPlayer = UserManager.getPlayer((Player) sender);
//Not Loaded yet //Not Loaded yet
if(mcMMOPlayer == null) if (mcMMOPlayer == null)
sender.sendMessage(LocaleLoader.getString("Profile.PendingLoad")); sender.sendMessage(LocaleLoader.getString("Profile.PendingLoad"));
sender.sendMessage(LocaleLoader.getString("Commands.Notifications." + (mcMMOPlayer.useChatNotifications() ? "Off" : "On"))); sender.sendMessage(LocaleLoader.getString("Commands.Notifications." + (mcMMOPlayer.useChatNotifications() ? "Off" : "On")));
mcMMOPlayer.toggleChatNotifications(); mcMMOPlayer.toggleChatNotifications();
return true; return true;
default:
return false;
} }
return false;
} }
@Override @Override
public List<String> onTabComplete(CommandSender sender, Command command, String alias, String[] args) { public List<String> onTabComplete(@NotNull CommandSender sender, @NotNull Command command, @NotNull String alias, String[] args) {
return ImmutableList.of(); return ImmutableList.of();
} }
} }

View File

@ -1,7 +1,7 @@
package com.gmail.nossr50.commands; package com.gmail.nossr50.commands;
import com.gmail.nossr50.config.Config;
import com.gmail.nossr50.locale.LocaleLoader; import com.gmail.nossr50.locale.LocaleLoader;
import com.gmail.nossr50.mcMMO;
import com.gmail.nossr50.util.commands.CommandUtils; import com.gmail.nossr50.util.commands.CommandUtils;
import com.gmail.nossr50.util.scoreboards.ScoreboardManager; import com.gmail.nossr50.util.scoreboards.ScoreboardManager;
import com.google.common.collect.ImmutableList; import com.google.common.collect.ImmutableList;
@ -9,6 +9,7 @@ import org.bukkit.command.Command;
import org.bukkit.command.CommandSender; import org.bukkit.command.CommandSender;
import org.bukkit.command.TabExecutor; import org.bukkit.command.TabExecutor;
import org.bukkit.util.StringUtil; import org.bukkit.util.StringUtil;
import org.jetbrains.annotations.NotNull;
import java.util.ArrayList; import java.util.ArrayList;
import java.util.List; import java.util.List;
@ -17,11 +18,21 @@ public class McscoreboardCommand implements TabExecutor {
private static final List<String> FIRST_ARGS = ImmutableList.of("keep", "time", "clear"); private static final List<String> FIRST_ARGS = ImmutableList.of("keep", "time", "clear");
@Override @Override
public boolean onCommand(CommandSender sender, Command command, String label, String[] args) { public boolean onCommand(@NotNull CommandSender sender, @NotNull Command command, @NotNull String label, String[] args) {
if (CommandUtils.noConsoleUsage(sender)) { if (CommandUtils.noConsoleUsage(sender)) {
return true; return true;
} }
if(!mcMMO.p.getGeneralConfig().getScoreboardsEnabled()) {
sender.sendMessage(LocaleLoader.getString("Scoreboard.Disabled"));
return true;
}
if(!ScoreboardManager.isPlayerBoardSetup(sender.getName())) {
sender.sendMessage(LocaleLoader.getString("Scoreboard.NotSetupYet"));
return true;
}
switch (args.length) { switch (args.length) {
case 1: case 1:
if (args[0].equalsIgnoreCase("clear") || args[0].equalsIgnoreCase("reset")) { if (args[0].equalsIgnoreCase("clear") || args[0].equalsIgnoreCase("reset")) {
@ -31,7 +42,7 @@ public class McscoreboardCommand implements TabExecutor {
} }
if (args[0].equalsIgnoreCase("keep")) { if (args[0].equalsIgnoreCase("keep")) {
if (!Config.getInstance().getAllowKeepBoard() || !Config.getInstance().getScoreboardsEnabled()) { if (!mcMMO.p.getGeneralConfig().getAllowKeepBoard() || !mcMMO.p.getGeneralConfig().getScoreboardsEnabled()) {
sender.sendMessage(LocaleLoader.getString("Commands.Disabled")); sender.sendMessage(LocaleLoader.getString("Commands.Disabled"));
return true; return true;
} }
@ -69,13 +80,11 @@ public class McscoreboardCommand implements TabExecutor {
} }
@Override @Override
public List<String> onTabComplete(CommandSender sender, Command command, String alias, String[] args) { public List<String> onTabComplete(@NotNull CommandSender sender, @NotNull Command command, @NotNull String alias, String[] args) {
switch (args.length) { if (args.length == 1) {
case 1: return StringUtil.copyPartialMatches(args[0], FIRST_ARGS, new ArrayList<>(FIRST_ARGS.size()));
return StringUtil.copyPartialMatches(args[0], FIRST_ARGS, new ArrayList<String>(FIRST_ARGS.size()));
default:
return ImmutableList.of();
} }
return ImmutableList.of();
} }
private boolean help(CommandSender sender) { private boolean help(CommandSender sender) {

View File

@ -8,13 +8,14 @@ import org.bukkit.command.Command;
import org.bukkit.command.CommandSender; import org.bukkit.command.CommandSender;
import org.bukkit.command.TabExecutor; import org.bukkit.command.TabExecutor;
import org.bukkit.util.StringUtil; import org.bukkit.util.StringUtil;
import org.jetbrains.annotations.NotNull;
import java.util.ArrayList; import java.util.ArrayList;
import java.util.List; import java.util.List;
public abstract class ToggleCommand implements TabExecutor { public abstract class ToggleCommand implements TabExecutor {
@Override @Override
public boolean onCommand(CommandSender sender, Command command, String label, String[] args) { public boolean onCommand(@NotNull CommandSender sender, @NotNull Command command, @NotNull String label, String[] args) {
switch (args.length) { switch (args.length) {
case 0: case 0:
if (CommandUtils.noConsoleUsage(sender)) { if (CommandUtils.noConsoleUsage(sender)) {
@ -60,14 +61,12 @@ public abstract class ToggleCommand implements TabExecutor {
} }
@Override @Override
public List<String> onTabComplete(CommandSender sender, Command command, String alias, String[] args) { public List<String> onTabComplete(@NotNull CommandSender sender, @NotNull Command command, @NotNull String alias, String[] args) {
switch (args.length) { if (args.length == 1) {
case 1: List<String> playerNames = CommandUtils.getOnlinePlayerNames(sender);
List<String> playerNames = CommandUtils.getOnlinePlayerNames(sender); return StringUtil.copyPartialMatches(args[0], playerNames, new ArrayList<>(playerNames.size()));
return StringUtil.copyPartialMatches(args[0], playerNames, new ArrayList<String>(playerNames.size()));
default:
return ImmutableList.of();
} }
return ImmutableList.of();
} }
protected abstract boolean hasOtherPermission(CommandSender sender); protected abstract boolean hasOtherPermission(CommandSender sender);

View File

@ -1,21 +1,20 @@
package com.gmail.nossr50.commands; package com.gmail.nossr50.commands;
import com.gmail.nossr50.config.AdvancedConfig;
import com.gmail.nossr50.config.Config;
import com.gmail.nossr50.config.experience.ExperienceConfig; import com.gmail.nossr50.config.experience.ExperienceConfig;
import com.gmail.nossr50.datatypes.notifications.SensitiveCommandType; import com.gmail.nossr50.datatypes.notifications.SensitiveCommandType;
import com.gmail.nossr50.locale.LocaleLoader; import com.gmail.nossr50.locale.LocaleLoader;
import com.gmail.nossr50.mcMMO; import com.gmail.nossr50.mcMMO;
import com.gmail.nossr50.util.Permissions; import com.gmail.nossr50.util.Permissions;
import com.gmail.nossr50.util.StringUtils;
import com.gmail.nossr50.util.commands.CommandUtils; import com.gmail.nossr50.util.commands.CommandUtils;
import com.gmail.nossr50.util.player.NotificationManager; import com.gmail.nossr50.util.player.NotificationManager;
import com.gmail.nossr50.util.text.StringUtils;
import com.google.common.collect.ImmutableList; import com.google.common.collect.ImmutableList;
import org.bukkit.ChatColor; import org.bukkit.ChatColor;
import org.bukkit.command.Command; import org.bukkit.command.Command;
import org.bukkit.command.CommandSender; import org.bukkit.command.CommandSender;
import org.bukkit.command.TabExecutor; import org.bukkit.command.TabExecutor;
import org.bukkit.util.StringUtil; import org.bukkit.util.StringUtil;
import org.jetbrains.annotations.NotNull;
import java.util.ArrayList; import java.util.ArrayList;
import java.util.List; import java.util.List;
@ -24,7 +23,7 @@ public class XprateCommand implements TabExecutor {
private final double ORIGINAL_XP_RATE = ExperienceConfig.getInstance().getExperienceGainsGlobalMultiplier(); private final double ORIGINAL_XP_RATE = ExperienceConfig.getInstance().getExperienceGainsGlobalMultiplier();
@Override @Override
public boolean onCommand(CommandSender sender, Command command, String label, String[] args) { public boolean onCommand(@NotNull CommandSender sender, @NotNull Command command, @NotNull String label, String[] args) {
switch (args.length) { switch (args.length) {
case 1: case 1:
if (!args[0].equalsIgnoreCase("reset") && !args[0].equalsIgnoreCase("clear")) { if (!args[0].equalsIgnoreCase("reset") && !args[0].equalsIgnoreCase("clear")) {
@ -38,7 +37,7 @@ public class XprateCommand implements TabExecutor {
if (mcMMO.p.isXPEventEnabled()) { if (mcMMO.p.isXPEventEnabled()) {
if(AdvancedConfig.getInstance().useTitlesForXPEvent()) if(mcMMO.p.getAdvancedConfig().useTitlesForXPEvent())
{ {
NotificationManager.broadcastTitle(mcMMO.p.getServer(), NotificationManager.broadcastTitle(mcMMO.p.getServer(),
LocaleLoader.getString("Commands.Event.Stop"), LocaleLoader.getString("Commands.Event.Stop"),
@ -46,7 +45,7 @@ public class XprateCommand implements TabExecutor {
10, 10*20, 20); 10, 10*20, 20);
} }
if(Config.getInstance().broadcastEventMessages()) if(mcMMO.p.getGeneralConfig().broadcastEventMessages())
{ {
mcMMO.p.getServer().broadcastMessage(LocaleLoader.getString("Commands.Event.Stop")); mcMMO.p.getServer().broadcastMessage(LocaleLoader.getString("Commands.Event.Stop"));
mcMMO.p.getServer().broadcastMessage(LocaleLoader.getString("Commands.Event.Stop.Subtitle")); mcMMO.p.getServer().broadcastMessage(LocaleLoader.getString("Commands.Event.Stop.Subtitle"));
@ -91,7 +90,7 @@ public class XprateCommand implements TabExecutor {
ExperienceConfig.getInstance().setExperienceGainsGlobalMultiplier(newXpRate); ExperienceConfig.getInstance().setExperienceGainsGlobalMultiplier(newXpRate);
if(AdvancedConfig.getInstance().useTitlesForXPEvent()) if(mcMMO.p.getAdvancedConfig().useTitlesForXPEvent())
{ {
NotificationManager.broadcastTitle(mcMMO.p.getServer(), NotificationManager.broadcastTitle(mcMMO.p.getServer(),
LocaleLoader.getString("Commands.Event.Start"), LocaleLoader.getString("Commands.Event.Start"),
@ -99,7 +98,7 @@ public class XprateCommand implements TabExecutor {
10, 10*20, 20); 10, 10*20, 20);
} }
if(Config.getInstance().broadcastEventMessages()) if(mcMMO.p.getGeneralConfig().broadcastEventMessages())
{ {
mcMMO.p.getServer().broadcastMessage(LocaleLoader.getString("Commands.Event.Start")); mcMMO.p.getServer().broadcastMessage(LocaleLoader.getString("Commands.Event.Start"));
mcMMO.p.getServer().broadcastMessage(LocaleLoader.getString("Commands.Event.XP", newXpRate)); mcMMO.p.getServer().broadcastMessage(LocaleLoader.getString("Commands.Event.XP", newXpRate));
@ -116,16 +115,16 @@ public class XprateCommand implements TabExecutor {
} }
@Override @Override
public List<String> onTabComplete(CommandSender sender, Command command, String alias, String[] args) { public List<String> onTabComplete(@NotNull CommandSender sender, @NotNull Command command, @NotNull String alias, String[] args) {
switch (args.length) { switch (args.length) {
case 1: case 1:
if (StringUtils.isInt(args[0])) { if (StringUtils.isInt(args[0])) {
return ImmutableList.of(); return ImmutableList.of();
} }
return StringUtil.copyPartialMatches(args[0], CommandUtils.RESET_OPTIONS, new ArrayList<String>(CommandUtils.RESET_OPTIONS.size())); return StringUtil.copyPartialMatches(args[0], CommandUtils.RESET_OPTIONS, new ArrayList<>(CommandUtils.RESET_OPTIONS.size()));
case 2: case 2:
return StringUtil.copyPartialMatches(args[1], CommandUtils.TRUE_FALSE_OPTIONS, new ArrayList<String>(CommandUtils.TRUE_FALSE_OPTIONS.size())); return StringUtil.copyPartialMatches(args[1], CommandUtils.TRUE_FALSE_OPTIONS, new ArrayList<>(CommandUtils.TRUE_FALSE_OPTIONS.size()));
default: default:
return ImmutableList.of(); return ImmutableList.of();
} }

View File

@ -0,0 +1,57 @@
//package com.gmail.nossr50.commands.admin;
//
//import com.gmail.nossr50.config.treasure.FishingTreasureConfig;
//import com.gmail.nossr50.datatypes.player.McMMOPlayer;
//import com.gmail.nossr50.datatypes.treasure.FishingTreasure;
//import com.gmail.nossr50.datatypes.treasure.Rarity;
//import com.gmail.nossr50.mcMMO;
//import com.gmail.nossr50.skills.fishing.FishingManager;
//import com.gmail.nossr50.util.player.UserManager;
//import org.bukkit.Location;
//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 DropTreasureCommand implements CommandExecutor {
// @Override
// public boolean onCommand(@NotNull CommandSender sender, @NotNull Command command, @NotNull String label, @NotNull String[] args) {
// if(sender instanceof Player) {
// if(!sender.isOp()) {
// sender.sendMessage("This command is for Operators only");
// return false;
// }
//
// Player player = (Player) sender;
// Location location = player.getLocation();
// McMMOPlayer mmoPlayer = UserManager.getPlayer(player);
//
// if(mmoPlayer == null) {
// //TODO: Localize
// player.sendMessage("Your player data is not loaded yet");
// return false;
// }
//
// if(args.length == 0) {
// mcMMO.p.getLogger().info(player.toString() +" is dropping all mcMMO treasures via admin command at location "+location.toString());
// for(Rarity rarity : FishingTreasureConfig.getInstance().fishingRewards.keySet()) {
// for(FishingTreasure fishingTreasure : FishingTreasureConfig.getInstance().fishingRewards.get(rarity)) {
// FishingManager fishingManager = mmoPlayer.getFishingManager();
// }
// }
// //TODO: impl
// } else {
// String targetTreasure = args[1];
//
// //Drop all treasures matching the name
// //TODO: impl
// }
//
// return true;
// } else {
// sender.sendMessage("No console support for this command");
// return false;
// }
// }
//}

View File

@ -5,26 +5,25 @@ import com.gmail.nossr50.util.Permissions;
import org.bukkit.command.Command; import org.bukkit.command.Command;
import org.bukkit.command.CommandExecutor; import org.bukkit.command.CommandExecutor;
import org.bukkit.command.CommandSender; import org.bukkit.command.CommandSender;
import org.jetbrains.annotations.NotNull;
/** /**
* @author Mark Vainomaa * @author Mark Vainomaa
*/ */
public final class McmmoReloadLocaleCommand implements CommandExecutor { public final class McmmoReloadLocaleCommand implements CommandExecutor {
@Override @Override
public boolean onCommand(CommandSender sender, Command command, String label, String[] args) { public boolean onCommand(@NotNull CommandSender sender, @NotNull Command command, @NotNull String label, String[] args) {
switch (args.length) { if (args.length == 0) {
case 0: if (!Permissions.reloadlocale(sender)) {
if (!Permissions.reloadlocale(sender)) { sender.sendMessage(command.getPermissionMessage());
sender.sendMessage(command.getPermissionMessage());
return true;
}
LocaleLoader.reloadLocale();
sender.sendMessage(LocaleLoader.getString("Locale.Reloaded"));
return true; return true;
default: }
return false;
LocaleLoader.reloadLocale();
sender.sendMessage(LocaleLoader.getString("Locale.Reloaded"));
return true;
} }
return false;
} }
} }

View File

@ -7,11 +7,12 @@ import org.bukkit.command.Command;
import org.bukkit.command.CommandExecutor; import org.bukkit.command.CommandExecutor;
import org.bukkit.command.CommandSender; import org.bukkit.command.CommandSender;
import org.bukkit.entity.Player; import org.bukkit.entity.Player;
import org.jetbrains.annotations.NotNull;
public class PlayerDebugCommand implements CommandExecutor { public class PlayerDebugCommand implements CommandExecutor {
@Override @Override
public boolean onCommand(CommandSender sender, Command command, String label, String[] args) { public boolean onCommand(@NotNull CommandSender sender, @NotNull Command command, @NotNull String label, String[] args) {
if(sender instanceof Player) { if(sender instanceof Player) {
McMMOPlayer mcMMOPlayer = UserManager.getPlayer((Player) sender); McMMOPlayer mcMMOPlayer = UserManager.getPlayer((Player) sender);
mcMMOPlayer.toggleDebugMode(); //Toggle debug mode mcMMOPlayer.toggleDebugMode(); //Toggle debug mode

View File

@ -1,15 +1,52 @@
package com.gmail.nossr50.commands.chat; package com.gmail.nossr50.commands.chat;
import com.gmail.nossr50.datatypes.chat.ChatMode; import co.aikar.commands.BaseCommand;
import org.bukkit.command.CommandSender; import co.aikar.commands.BukkitCommandIssuer;
import co.aikar.commands.annotation.CommandAlias;
import co.aikar.commands.annotation.CommandPermission;
import co.aikar.commands.annotation.Conditions;
import co.aikar.commands.annotation.Default;
import com.gmail.nossr50.commands.CommandManager;
import com.gmail.nossr50.datatypes.chat.ChatChannel;
import com.gmail.nossr50.datatypes.player.McMMOPlayer;
import com.gmail.nossr50.mcMMO;
import com.gmail.nossr50.util.player.UserManager;
import org.jetbrains.annotations.NotNull;
public class AdminChatCommand extends ChatCommand { @CommandPermission("mcmmo.chat.adminchat")
public AdminChatCommand() { @CommandAlias("ac|a|adminchat|achat") //Kept for historical reasons
super(ChatMode.ADMIN); public class AdminChatCommand extends BaseCommand {
private final @NotNull mcMMO pluginRef;
public AdminChatCommand(@NotNull mcMMO pluginRef) {
this.pluginRef = pluginRef;
} }
@Override @Default @Conditions(CommandManager.ADMIN_CONDITION)
protected void handleChatSending(CommandSender sender, String[] args) { public void processCommand(String[] args) {
chatManager.handleChat(sender.getName(), getDisplayName(sender), buildChatMessage(args, 0)); BukkitCommandIssuer bukkitCommandIssuer = (BukkitCommandIssuer) getCurrentCommandIssuer();
if(args == null || args.length == 0) {
//Process with no arguments
if(bukkitCommandIssuer.isPlayer()) {
McMMOPlayer mmoPlayer = UserManager.getPlayer(bukkitCommandIssuer.getPlayer());
pluginRef.getChatManager().setOrToggleChatChannel(mmoPlayer, ChatChannel.ADMIN);
} else {
//Not support for console
mcMMO.p.getLogger().info("You cannot switch chat channels as console, please provide full arguments.");
}
} else {
if(bukkitCommandIssuer.isPlayer()) {
McMMOPlayer mmoPlayer = UserManager.getPlayer(bukkitCommandIssuer.getPlayer());
if(mmoPlayer == null)
return;
//Message contains the original command so it needs to be passed to this method to trim it
pluginRef.getChatManager().processPlayerMessage(mmoPlayer, args, ChatChannel.ADMIN);
} else {
pluginRef.getChatManager().processConsoleMessage(args);
}
//Arguments are greater than 0, therefore directly send message and skip toggles
}
} }
} }

View File

@ -1,142 +0,0 @@
package com.gmail.nossr50.commands.chat;
import com.gmail.nossr50.chat.ChatManager;
import com.gmail.nossr50.chat.ChatManagerFactory;
import com.gmail.nossr50.config.Config;
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.locale.LocaleLoader;
import com.gmail.nossr50.mcMMO;
import com.gmail.nossr50.util.commands.CommandUtils;
import com.gmail.nossr50.util.player.UserManager;
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 ChatManager chatManager;
public ChatCommand(ChatMode chatMode) {
this.chatMode = chatMode;
this.chatManager = ChatManagerFactory.getChatManager(mcMMO.p, chatMode);
}
@Override
public boolean onCommand(CommandSender sender, Command command, String label, String[] args) {
McMMOPlayer mcMMOPlayer;
switch (args.length) {
case 0:
if (CommandUtils.noConsoleUsage(sender)) {
return true;
}
if (!CommandUtils.hasPlayerDataKey(sender)) {
return true;
}
mcMMOPlayer = UserManager.getPlayer(sender.getName());
if (mcMMOPlayer.isChatEnabled(chatMode)) {
disableChatMode(mcMMOPlayer, sender);
}
else {
enableChatMode(mcMMOPlayer, sender);
}
return true;
case 1:
if (CommandUtils.shouldEnableToggle(args[0])) {
if (CommandUtils.noConsoleUsage(sender)) {
return true;
}
if (!CommandUtils.hasPlayerDataKey(sender)) {
return true;
}
enableChatMode(UserManager.getPlayer(sender.getName()), sender);
return true;
}
if (CommandUtils.shouldDisableToggle(args[0])) {
if (CommandUtils.noConsoleUsage(sender)) {
return true;
}
if (!CommandUtils.hasPlayerDataKey(sender)) {
return true;
}
disableChatMode(UserManager.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], CommandUtils.TRUE_FALSE_OPTIONS, new ArrayList<String>(CommandUtils.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() : LocaleLoader.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(LocaleLoader.getString("Commands.Party.None"));
return;
}
if (chatMode == ChatMode.PARTY && (mcMMOPlayer.getParty().getLevel() < Config.getInstance().getPartyFeatureUnlockLevel(PartyFeature.CHAT))) {
sender.sendMessage(LocaleLoader.getString("Party.Feature.Disabled.1"));
return;
}
mcMMOPlayer.enableChat(chatMode);
sender.sendMessage(chatMode.getEnabledMessage());
}
private void disableChatMode(McMMOPlayer mcMMOPlayer, CommandSender sender) {
if (chatMode == ChatMode.PARTY && mcMMOPlayer.getParty() == null) {
sender.sendMessage(LocaleLoader.getString("Commands.Party.None"));
return;
}
mcMMOPlayer.disableChat(chatMode);
sender.sendMessage(chatMode.getDisabledMessage());
}
}

View File

@ -1,62 +1,90 @@
package com.gmail.nossr50.commands.chat; package com.gmail.nossr50.commands.chat;
import com.gmail.nossr50.chat.PartyChatManager; import co.aikar.commands.BaseCommand;
import com.gmail.nossr50.config.Config; import co.aikar.commands.BukkitCommandIssuer;
import com.gmail.nossr50.datatypes.chat.ChatMode; import co.aikar.commands.annotation.CommandAlias;
import co.aikar.commands.annotation.CommandPermission;
import co.aikar.commands.annotation.Conditions;
import co.aikar.commands.annotation.Default;
import com.gmail.nossr50.commands.CommandManager;
import com.gmail.nossr50.datatypes.chat.ChatChannel;
import com.gmail.nossr50.datatypes.party.Party; 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.locale.LocaleLoader; import com.gmail.nossr50.mcMMO;
import com.gmail.nossr50.party.PartyManager; import com.gmail.nossr50.party.PartyManager;
import com.gmail.nossr50.util.player.UserManager; import com.gmail.nossr50.util.player.UserManager;
import org.bukkit.command.CommandSender; import com.gmail.nossr50.util.text.StringUtils;
import org.bukkit.entity.Player; import org.bukkit.entity.Player;
import org.jetbrains.annotations.NotNull;
public class PartyChatCommand extends ChatCommand { @CommandPermission("mcmmo.chat.partychat")
public PartyChatCommand() { @CommandAlias("pc|p|partychat|pchat") //Kept for historical reasons
super(ChatMode.PARTY); public class PartyChatCommand extends BaseCommand {
private final @NotNull mcMMO pluginRef;
public PartyChatCommand(@NotNull mcMMO pluginRef) {
this.pluginRef = pluginRef;
} }
@Override @Default
protected void handleChatSending(CommandSender sender, String[] args) { @Conditions(CommandManager.PARTY_CONDITION)
Party party; public void processCommand(String[] args) {
String message; BukkitCommandIssuer bukkitCommandIssuer = (BukkitCommandIssuer) getCurrentCommandIssuer();
if (sender instanceof Player) { if(args == null || args.length == 0) {
//Check if player profile is loaded //Process with no arguments
if(UserManager.getPlayer((Player) sender) == null) if(bukkitCommandIssuer.isPlayer()) {
return; McMMOPlayer mmoPlayer = UserManager.getPlayer(bukkitCommandIssuer.getPlayer());
pluginRef.getChatManager().setOrToggleChatChannel(mmoPlayer, ChatChannel.PARTY);
party = UserManager.getPlayer((Player) sender).getParty(); } else {
//Not support for console
if (party == null) { mcMMO.p.getLogger().info("You cannot switch chat channels as console, please provide full arguments.");
sender.sendMessage(LocaleLoader.getString("Commands.Party.None"));
return;
} }
} else {
//Here we split the logic, consoles need to target a party name and players do not
if (party.getLevel() < Config.getInstance().getPartyFeatureUnlockLevel(PartyFeature.CHAT)) { /*
sender.sendMessage(LocaleLoader.getString("Party.Feature.Disabled.1")); * Player Logic
return; */
if(bukkitCommandIssuer.getIssuer() instanceof Player) {
McMMOPlayer mmoPlayer = UserManager.getPlayer(bukkitCommandIssuer.getPlayer());
processCommandArgsPlayer(mmoPlayer, args);
/*
* Console Logic
*/
} else {
processCommandArgsConsole(args);
} }
message = buildChatMessage(args, 0);
} }
else { }
if (args.length < 2) {
sender.sendMessage(LocaleLoader.getString("Party.Specify")); /**
return; * Processes the command with arguments for a {@link McMMOPlayer}
* @param mmoPlayer target player
* @param args command arguments
*/
private void processCommandArgsPlayer(@NotNull McMMOPlayer mmoPlayer, @NotNull String[] args) {
//Player is not toggling and is chatting directly to party
pluginRef.getChatManager().processPlayerMessage(mmoPlayer, args, ChatChannel.PARTY);
}
/**
* Processes the command with arguments for a {@link com.gmail.nossr50.chat.author.ConsoleAuthor}
* @param args command arguments
*/
private void processCommandArgsConsole(@NotNull String[] args) {
if(args.length <= 1) {
//Only specific a party and not the message
mcMMO.p.getLogger().severe("You need to specify a party name and then write a message afterwards.");
} else {
//Grab party
Party targetParty = PartyManager.getParty(args[0]);
if(targetParty != null) {
pluginRef.getChatManager().processConsoleMessage(StringUtils.buildStringAfterNthElement(args, 1), targetParty);
} else {
mcMMO.p.getLogger().severe("A party with that name doesn't exist!");
} }
party = PartyManager.getParty(args[0]);
if (party == null) {
sender.sendMessage(LocaleLoader.getString("Party.InvalidName"));
return;
}
message = buildChatMessage(args, 1);
} }
((PartyChatManager) chatManager).setParty(party);
chatManager.handleChat(sender.getName(), getDisplayName(sender), message);
} }
} }

View File

@ -13,62 +13,63 @@ import org.bukkit.command.Command;
import org.bukkit.command.CommandExecutor; import org.bukkit.command.CommandExecutor;
import org.bukkit.command.CommandSender; import org.bukkit.command.CommandSender;
import org.bukkit.entity.Player; import org.bukkit.entity.Player;
import org.jetbrains.annotations.NotNull;
public class ConvertDatabaseCommand implements CommandExecutor { public class ConvertDatabaseCommand implements CommandExecutor {
@Override @Override
public boolean onCommand(CommandSender sender, Command command, String label, String[] args) { public boolean onCommand(@NotNull CommandSender sender, @NotNull Command command, @NotNull String label, String[] args) {
switch (args.length) { if (args.length == 2) {
case 2: DatabaseType previousType = DatabaseType.getDatabaseType(args[1]);
DatabaseType previousType = DatabaseType.getDatabaseType(args[1]); DatabaseType newType = mcMMO.getDatabaseManager().getDatabaseType();
DatabaseType newType = mcMMO.getDatabaseManager().getDatabaseType();
if (previousType == newType || (newType == DatabaseType.CUSTOM && DatabaseManagerFactory.getCustomDatabaseManagerClass().getSimpleName().equalsIgnoreCase(args[1]))) { if (previousType == newType || (newType == DatabaseType.CUSTOM && DatabaseManagerFactory.getCustomDatabaseManagerClass().getSimpleName().equalsIgnoreCase(args[1]))) {
sender.sendMessage(LocaleLoader.getString("Commands.mcconvert.Database.Same", newType.toString())); sender.sendMessage(LocaleLoader.getString("Commands.mcconvert.Database.Same", newType.toString()));
return true; return true;
} }
DatabaseManager oldDatabase = DatabaseManagerFactory.createDatabaseManager(previousType); DatabaseManager oldDatabase = DatabaseManagerFactory.createDatabaseManager(previousType, mcMMO.getUsersFilePath(), mcMMO.p.getLogger(), mcMMO.p.getPurgeTime(), mcMMO.p.getAdvancedConfig().getStartingLevel());
if(oldDatabase == null) {
sender.sendMessage("Unable to load the old database! Check your log for errors.");
return true;
}
if (previousType == DatabaseType.CUSTOM) { if (previousType == DatabaseType.CUSTOM) {
Class<?> clazz; Class<?> clazz;
try { try {
clazz = Class.forName(args[1]); clazz = Class.forName(args[1]);
if (!DatabaseManager.class.isAssignableFrom(clazz)) { if (!DatabaseManager.class.isAssignableFrom(clazz)) {
sender.sendMessage(LocaleLoader.getString("Commands.mcconvert.Database.InvalidType", args[1]));
return true;
}
oldDatabase = DatabaseManagerFactory.createCustomDatabaseManager((Class<? extends DatabaseManager>) clazz);
}
catch (Throwable e) {
e.printStackTrace();
sender.sendMessage(LocaleLoader.getString("Commands.mcconvert.Database.InvalidType", args[1])); sender.sendMessage(LocaleLoader.getString("Commands.mcconvert.Database.InvalidType", args[1]));
return true; return true;
} }
oldDatabase = DatabaseManagerFactory.createCustomDatabaseManager((Class<? extends DatabaseManager>) clazz);
} catch (Throwable e) {
e.printStackTrace();
sender.sendMessage(LocaleLoader.getString("Commands.mcconvert.Database.InvalidType", args[1]));
return true;
}
}
sender.sendMessage(LocaleLoader.getString("Commands.mcconvert.Database.Start", previousType.toString(), newType.toString()));
UserManager.saveAll();
UserManager.clearAll();
for (Player player : mcMMO.p.getServer().getOnlinePlayers()) {
PlayerProfile profile = oldDatabase.loadPlayerProfile(player);
if (profile.isLoaded()) {
mcMMO.getDatabaseManager().saveUser(profile);
} }
sender.sendMessage(LocaleLoader.getString("Commands.mcconvert.Database.Start", previousType.toString(), newType.toString())); new PlayerProfileLoadingTask(player).runTaskLaterAsynchronously(mcMMO.p, 1); // 1 Tick delay to ensure the player is marked as online before we begin loading
}
UserManager.saveAll(); new DatabaseConversionTask(oldDatabase, sender, previousType.toString(), newType.toString()).runTaskAsynchronously(mcMMO.p);
UserManager.clearAll(); return true;
for (Player player : mcMMO.p.getServer().getOnlinePlayers()) {
PlayerProfile profile = oldDatabase.loadPlayerProfile(player.getUniqueId());
if (profile.isLoaded()) {
mcMMO.getDatabaseManager().saveUser(profile);
}
new PlayerProfileLoadingTask(player).runTaskLaterAsynchronously(mcMMO.p, 1); // 1 Tick delay to ensure the player is marked as online before we begin loading
}
new DatabaseConversionTask(oldDatabase, sender, previousType.toString(), newType.toString()).runTaskAsynchronously(mcMMO.p);
return true;
default:
return false;
} }
return false;
} }
} }

View File

@ -1,36 +1,33 @@
package com.gmail.nossr50.commands.database; package com.gmail.nossr50.commands.database;
import com.gmail.nossr50.config.Config;
import com.gmail.nossr50.locale.LocaleLoader; import com.gmail.nossr50.locale.LocaleLoader;
import com.gmail.nossr50.mcMMO; import com.gmail.nossr50.mcMMO;
import com.google.common.collect.ImmutableList; import com.google.common.collect.ImmutableList;
import org.bukkit.command.Command; import org.bukkit.command.Command;
import org.bukkit.command.CommandSender; import org.bukkit.command.CommandSender;
import org.bukkit.command.TabExecutor; import org.bukkit.command.TabExecutor;
import org.jetbrains.annotations.NotNull;
import java.util.List; import java.util.List;
public class McpurgeCommand implements TabExecutor { public class McpurgeCommand implements TabExecutor {
@Override @Override
public boolean onCommand(CommandSender sender, Command command, String label, String[] args) { public boolean onCommand(@NotNull CommandSender sender, @NotNull Command command, @NotNull String label, String[] args) {
switch (args.length) { if (args.length == 0) {
case 0: mcMMO.getDatabaseManager().purgePowerlessUsers();
mcMMO.getDatabaseManager().purgePowerlessUsers();
if (Config.getInstance().getOldUsersCutoff() != -1) { if (mcMMO.p.getGeneralConfig().getOldUsersCutoff() != -1) {
mcMMO.getDatabaseManager().purgeOldUsers(); mcMMO.getDatabaseManager().purgeOldUsers();
} }
sender.sendMessage(LocaleLoader.getString("Commands.mcpurge.Success")); sender.sendMessage(LocaleLoader.getString("Commands.mcpurge.Success"));
return true; return true;
default:
return false;
} }
return false;
} }
@Override @Override
public List<String> onTabComplete(CommandSender sender, Command command, String alias, String[] args) { public List<String> onTabComplete(@NotNull CommandSender sender, @NotNull Command command, @NotNull String alias, String[] args) {
return ImmutableList.of(); return ImmutableList.of();
} }
} }

View File

@ -10,6 +10,7 @@ import org.bukkit.command.Command;
import org.bukkit.command.CommandSender; import org.bukkit.command.CommandSender;
import org.bukkit.command.TabExecutor; import org.bukkit.command.TabExecutor;
import org.bukkit.util.StringUtil; import org.bukkit.util.StringUtil;
import org.jetbrains.annotations.NotNull;
import java.util.ArrayList; import java.util.ArrayList;
import java.util.List; import java.util.List;
@ -17,43 +18,37 @@ import java.util.UUID;
public class McremoveCommand implements TabExecutor { public class McremoveCommand implements TabExecutor {
@Override @Override
public boolean onCommand(CommandSender sender, Command command, String label, String[] args) { public boolean onCommand(@NotNull CommandSender sender, @NotNull Command command, @NotNull String label, String[] args) {
switch (args.length) { if (args.length == 1) {
case 1: String playerName = CommandUtils.getMatchedPlayerName(args[0]);
String playerName = CommandUtils.getMatchedPlayerName(args[0]);
if (UserManager.getOfflinePlayer(playerName) == null && CommandUtils.unloadedProfile(sender, mcMMO.getDatabaseManager().loadPlayerProfile(playerName, false))) {
return true;
}
UUID uuid = null;
if(Bukkit.getPlayer(playerName) != null) {
uuid = Bukkit.getPlayer(playerName).getUniqueId();
}
if (mcMMO.getDatabaseManager().removeUser(playerName, uuid)) {
sender.sendMessage(LocaleLoader.getString("Commands.mcremove.Success", playerName));
}
else {
sender.sendMessage(playerName + " could not be removed from the database."); // Pretty sure this should NEVER happen.
}
if (UserManager.getOfflinePlayer(playerName) == null && CommandUtils.unloadedProfile(sender, mcMMO.getDatabaseManager().loadPlayerProfile(playerName))) {
return true; return true;
}
default: UUID uuid = null;
return false;
if (Bukkit.getPlayer(playerName) != null) {
uuid = Bukkit.getPlayer(playerName).getUniqueId();
}
if (mcMMO.getDatabaseManager().removeUser(playerName, uuid)) {
sender.sendMessage(LocaleLoader.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 @Override
public List<String> onTabComplete(CommandSender sender, Command command, String alias, String[] args) { public List<String> onTabComplete(@NotNull CommandSender sender, @NotNull Command command, @NotNull String alias, String[] args) {
switch (args.length) { if (args.length == 1) {
case 1: List<String> playerNames = CommandUtils.getOnlinePlayerNames(sender);
List<String> playerNames = CommandUtils.getOnlinePlayerNames(sender); return StringUtil.copyPartialMatches(args[0], playerNames, new ArrayList<>(playerNames.size()));
return StringUtil.copyPartialMatches(args[0], playerNames, new ArrayList<String>(playerNames.size()));
default:
return ImmutableList.of();
} }
return ImmutableList.of();
} }
} }

View File

@ -1,37 +1,35 @@
package com.gmail.nossr50.commands.database; package com.gmail.nossr50.commands.database;
import com.gmail.nossr50.config.Config;
import com.gmail.nossr50.database.DatabaseManagerFactory; import com.gmail.nossr50.database.DatabaseManagerFactory;
import com.gmail.nossr50.locale.LocaleLoader; import com.gmail.nossr50.locale.LocaleLoader;
import com.gmail.nossr50.mcMMO;
import com.google.common.collect.ImmutableList; import com.google.common.collect.ImmutableList;
import org.bukkit.command.Command; import org.bukkit.command.Command;
import org.bukkit.command.CommandSender; import org.bukkit.command.CommandSender;
import org.bukkit.command.TabExecutor; import org.bukkit.command.TabExecutor;
import org.jetbrains.annotations.NotNull;
import java.util.List; import java.util.List;
public class MmoshowdbCommand implements TabExecutor { public class MmoshowdbCommand implements TabExecutor {
@Override @Override
public boolean onCommand(CommandSender sender, Command command, String label, String[] args) { public boolean onCommand(@NotNull CommandSender sender, @NotNull Command command, @NotNull String label, String[] args) {
switch (args.length) { if (args.length == 0) {
case 0: Class<?> clazz = DatabaseManagerFactory.getCustomDatabaseManagerClass();
Class<?> clazz = DatabaseManagerFactory.getCustomDatabaseManagerClass();
if (clazz != null) { if (clazz != null) {
sender.sendMessage(LocaleLoader.getString("Commands.mmoshowdb", clazz.getName())); sender.sendMessage(LocaleLoader.getString("Commands.mmoshowdb", clazz.getName()));
return true;
}
sender.sendMessage(LocaleLoader.getString("Commands.mmoshowdb", (Config.getInstance().getUseMySQL() ? "sql" : "flatfile")));
return true; return true;
}
default: sender.sendMessage(LocaleLoader.getString("Commands.mmoshowdb", (mcMMO.p.getGeneralConfig().getUseMySQL() ? "sql" : "flatfile")));
return false; return true;
} }
return false;
} }
@Override @Override
public List<String> onTabComplete(CommandSender sender, Command command, String alias, String[] args) { public List<String> onTabComplete(@NotNull CommandSender sender, @NotNull Command command, @NotNull String alias, String[] args) {
return ImmutableList.of(); return ImmutableList.of();
} }
} }

View File

@ -1,11 +1,14 @@
package com.gmail.nossr50.commands.experience; package com.gmail.nossr50.commands.experience;
import com.gmail.nossr50.datatypes.experience.XPGainReason; 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.player.PlayerProfile;
import com.gmail.nossr50.datatypes.skills.PrimarySkillType; import com.gmail.nossr50.datatypes.skills.PrimarySkillType;
import com.gmail.nossr50.locale.LocaleLoader; import com.gmail.nossr50.locale.LocaleLoader;
import com.gmail.nossr50.mcMMO;
import com.gmail.nossr50.util.EventUtils; import com.gmail.nossr50.util.EventUtils;
import com.gmail.nossr50.util.Permissions; import com.gmail.nossr50.util.Permissions;
import com.gmail.nossr50.util.player.UserManager;
import org.bukkit.command.CommandSender; import org.bukkit.command.CommandSender;
import org.bukkit.entity.Player; import org.bukkit.entity.Player;
@ -30,16 +33,29 @@ public class AddlevelsCommand extends ExperienceCommand {
return; return;
} }
EventUtils.tryLevelChangeEvent(player, skill, value, xpRemoved, true, XPGainReason.COMMAND); McMMOPlayer mmoPlayer = UserManager.getPlayer(player);
if(mmoPlayer == null) {
EventUtils.tryLevelChangeEvent(player, skill, value, xpRemoved, true, XPGainReason.COMMAND);
} else {
EventUtils.tryLevelChangeEvent(mmoPlayer, skill, value, xpRemoved, true, XPGainReason.COMMAND);
}
} }
@Override @Override
protected void handlePlayerMessageAll(Player player, int value) { protected void handlePlayerMessageAll(Player player, int value, boolean isSilent) {
if(isSilent)
return;
player.sendMessage(LocaleLoader.getString("Commands.addlevels.AwardAll.1", value)); player.sendMessage(LocaleLoader.getString("Commands.addlevels.AwardAll.1", value));
} }
@Override @Override
protected void handlePlayerMessageSkill(Player player, int value, PrimarySkillType skill) { protected void handlePlayerMessageSkill(Player player, int value, PrimarySkillType skill, boolean isSilent) {
player.sendMessage(LocaleLoader.getString("Commands.addlevels.AwardSkill.1", value, skill.getName())); if(isSilent)
return;
player.sendMessage(LocaleLoader.getString("Commands.addlevels.AwardSkill.1", value, mcMMO.p.getSkillTools().getLocalizedSkillName(skill)));
} }
} }

View File

@ -5,6 +5,7 @@ import com.gmail.nossr50.datatypes.experience.XPGainSource;
import com.gmail.nossr50.datatypes.player.PlayerProfile; import com.gmail.nossr50.datatypes.player.PlayerProfile;
import com.gmail.nossr50.datatypes.skills.PrimarySkillType; import com.gmail.nossr50.datatypes.skills.PrimarySkillType;
import com.gmail.nossr50.locale.LocaleLoader; import com.gmail.nossr50.locale.LocaleLoader;
import com.gmail.nossr50.mcMMO;
import com.gmail.nossr50.util.Permissions; import com.gmail.nossr50.util.Permissions;
import com.gmail.nossr50.util.player.UserManager; import com.gmail.nossr50.util.player.UserManager;
import org.bukkit.command.CommandSender; import org.bukkit.command.CommandSender;
@ -37,12 +38,18 @@ public class AddxpCommand extends ExperienceCommand {
} }
@Override @Override
protected void handlePlayerMessageAll(Player player, int value) { protected void handlePlayerMessageAll(Player player, int value, boolean isSilent) {
if(isSilent)
return;
player.sendMessage(LocaleLoader.getString("Commands.addxp.AwardAll", value)); player.sendMessage(LocaleLoader.getString("Commands.addxp.AwardAll", value));
} }
@Override @Override
protected void handlePlayerMessageSkill(Player player, int value, PrimarySkillType skill) { protected void handlePlayerMessageSkill(Player player, int value, PrimarySkillType skill, boolean isSilent) {
player.sendMessage(LocaleLoader.getString("Commands.addxp.AwardSkill", value, skill.getName())); if(isSilent)
return;
player.sendMessage(LocaleLoader.getString("Commands.addxp.AwardSkill", value, mcMMO.p.getSkillTools().getLocalizedSkillName(skill)));
} }
} }

View File

@ -10,42 +10,40 @@ import org.bukkit.command.Command;
import org.bukkit.command.CommandExecutor; import org.bukkit.command.CommandExecutor;
import org.bukkit.command.CommandSender; import org.bukkit.command.CommandSender;
import org.bukkit.entity.Player; import org.bukkit.entity.Player;
import org.jetbrains.annotations.NotNull;
import java.util.Locale; import java.util.Locale;
public class ConvertExperienceCommand implements CommandExecutor { public class ConvertExperienceCommand implements CommandExecutor {
@Override @Override
public boolean onCommand(CommandSender sender, Command command, String label, String[] args) { public boolean onCommand(@NotNull CommandSender sender, @NotNull Command command, @NotNull String label, String[] args) {
switch (args.length) { if (args.length == 2) {
case 2: FormulaType previousType = mcMMO.getFormulaManager().getPreviousFormulaType();
FormulaType previousType = mcMMO.getFormulaManager().getPreviousFormulaType(); FormulaType newType = FormulaType.getFormulaType(args[1].toUpperCase(Locale.ENGLISH));
FormulaType newType = FormulaType.getFormulaType(args[1].toUpperCase(Locale.ENGLISH));
if (newType == FormulaType.UNKNOWN) {
sender.sendMessage(LocaleLoader.getString("Commands.mcconvert.Experience.Invalid"));
return true;
}
if (previousType == newType) {
sender.sendMessage(LocaleLoader.getString("Commands.mcconvert.Experience.Same", newType.toString()));
return true;
}
sender.sendMessage(LocaleLoader.getString("Commands.mcconvert.Experience.Start", previousType.toString(), newType.toString()));
UserManager.saveAll();
UserManager.clearAll();
new FormulaConversionTask(sender, newType).runTaskLater(mcMMO.p, 1);
for (Player player : mcMMO.p.getServer().getOnlinePlayers()) {
new PlayerProfileLoadingTask(player).runTaskLaterAsynchronously(mcMMO.p, 1); // 1 Tick delay to ensure the player is marked as online before we begin loading
}
if (newType == FormulaType.UNKNOWN) {
sender.sendMessage(LocaleLoader.getString("Commands.mcconvert.Experience.Invalid"));
return true; return true;
}
default: if (previousType == newType) {
return false; sender.sendMessage(LocaleLoader.getString("Commands.mcconvert.Experience.Same", newType.toString()));
return true;
}
sender.sendMessage(LocaleLoader.getString("Commands.mcconvert.Experience.Start", previousType.toString(), newType.toString()));
UserManager.saveAll();
UserManager.clearAll();
new FormulaConversionTask(sender, newType).runTaskLater(mcMMO.p, 1);
for (Player player : mcMMO.p.getServer().getOnlinePlayers()) {
new PlayerProfileLoadingTask(player).runTaskLaterAsynchronously(mcMMO.p, 1); // 1 Tick delay to ensure the player is marked as online before we begin loading
}
return true;
} }
return false;
} }
} }

View File

@ -7,31 +7,35 @@ import com.gmail.nossr50.locale.LocaleLoader;
import com.gmail.nossr50.mcMMO; import com.gmail.nossr50.mcMMO;
import com.gmail.nossr50.util.commands.CommandUtils; import com.gmail.nossr50.util.commands.CommandUtils;
import com.gmail.nossr50.util.player.UserManager; import com.gmail.nossr50.util.player.UserManager;
import com.gmail.nossr50.util.skills.SkillTools;
import com.google.common.collect.ImmutableList; import com.google.common.collect.ImmutableList;
import org.bukkit.OfflinePlayer;
import org.bukkit.command.Command; import org.bukkit.command.Command;
import org.bukkit.command.CommandSender; import org.bukkit.command.CommandSender;
import org.bukkit.command.TabExecutor; import org.bukkit.command.TabExecutor;
import org.bukkit.entity.Player; import org.bukkit.entity.Player;
import org.bukkit.util.StringUtil; import org.bukkit.util.StringUtil;
import org.jetbrains.annotations.NotNull;
import java.util.ArrayList; import java.util.ArrayList;
import java.util.List; import java.util.List;
import java.util.UUID;
public abstract class ExperienceCommand implements TabExecutor { public abstract class ExperienceCommand implements TabExecutor {
@Override @Override
public boolean onCommand(CommandSender sender, Command command, String label, String[] args) { public boolean onCommand(@NotNull CommandSender sender, @NotNull Command command, @NotNull String label, String[] args) {
PrimarySkillType skill; PrimarySkillType skill;
switch (args.length) { if(args.length < 2) {
case 2: return false;
} else {
if(args.length == 2 && !isSilent(args) || args.length == 3 && isSilent(args)) {
if (CommandUtils.noConsoleUsage(sender)) { if (CommandUtils.noConsoleUsage(sender)) {
return true; return true;
} }
if (!permissionsCheckSelf(sender)) { if (!permissionsCheckSelf(sender)) {
sender.sendMessage(command.getPermissionMessage()); if(command.getPermissionMessage() != null)
sender.sendMessage(command.getPermissionMessage());
sender.sendMessage("(mcMMO) No permission!");
return true; return true;
} }
@ -39,13 +43,13 @@ public abstract class ExperienceCommand implements TabExecutor {
return true; return true;
} }
skill = PrimarySkillType.getSkill(args[0]); skill = mcMMO.p.getSkillTools().matchSkill(args[0]);
if (args[1].equalsIgnoreCase("all")) { if (args[1].equalsIgnoreCase("all")) {
skill = null; skill = null;
} }
if (skill != null && skill.isChildSkill()) if (skill != null && SkillTools.isChildSkill(skill))
{ {
sender.sendMessage(LocaleLoader.getString("Commands.Skill.ChildSkill")); sender.sendMessage(LocaleLoader.getString("Commands.Skill.ChildSkill"));
return true; return true;
@ -59,10 +63,10 @@ public abstract class ExperienceCommand implements TabExecutor {
} }
editValues((Player) sender, UserManager.getPlayer(sender.getName()).getProfile(), skill, Integer.parseInt(args[1])); editValues((Player) sender, UserManager.getPlayer(sender.getName()).getProfile(), skill, Integer.parseInt(args[1]), isSilent(args));
return true; return true;
} else if((args.length == 3 && !isSilent(args))
case 3: || (args.length == 4 && isSilent(args))) {
if (!permissionsCheckOthers(sender)) { if (!permissionsCheckOthers(sender)) {
sender.sendMessage(command.getPermissionMessage()); sender.sendMessage(command.getPermissionMessage());
return true; return true;
@ -72,13 +76,13 @@ public abstract class ExperienceCommand implements TabExecutor {
return true; return true;
} }
skill = PrimarySkillType.getSkill(args[1]); skill = mcMMO.p.getSkillTools().matchSkill(args[1]);
if (args[1].equalsIgnoreCase("all")) { if (args[1].equalsIgnoreCase("all")) {
skill = null; skill = null;
} }
if (skill != null && skill.isChildSkill()) if (skill != null && SkillTools.isChildSkill(skill))
{ {
sender.sendMessage(LocaleLoader.getString("Commands.Skill.ChildSkill")); sender.sendMessage(LocaleLoader.getString("Commands.Skill.ChildSkill"));
return true; return true;
@ -91,39 +95,52 @@ public abstract class ExperienceCommand implements TabExecutor {
// 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 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) { if (mcMMOPlayer == null) {
UUID uuid = null; PlayerProfile profile;
OfflinePlayer player = mcMMO.p.getServer().getOfflinePlayer(playerName);
if (player != null) {
uuid = player.getUniqueId();
}
PlayerProfile profile = mcMMO.getDatabaseManager().loadPlayerProfile(playerName, uuid, false);
profile = mcMMO.getDatabaseManager().loadPlayerProfile(playerName);
//Check loading by UUID
if (CommandUtils.unloadedProfile(sender, profile)) { if (CommandUtils.unloadedProfile(sender, profile)) {
return true; //Check loading by name
profile = mcMMO.getDatabaseManager().loadPlayerProfile(playerName);
if(CommandUtils.unloadedProfile(sender, profile)) {
return true;
}
} }
editValues(null, profile, skill, value); editValues(null, profile, skill, value, isSilent(args));
} }
else { else {
editValues(mcMMOPlayer.getPlayer(), mcMMOPlayer.getProfile(), skill, value); editValues(mcMMOPlayer.getPlayer(), mcMMOPlayer.getProfile(), skill, value, isSilent(args));
} }
handleSenderMessage(sender, playerName, skill); handleSenderMessage(sender, playerName, skill);
return true; return true;
} else {
default:
return false; return false;
}
} }
} }
private boolean isSilent(String[] args) {
int length = args.length;
if(length == 0)
return false;
return args[length-1].equalsIgnoreCase("-s");
}
@Override @Override
public List<String> onTabComplete(CommandSender sender, Command command, String alias, String[] args) { public List<String> onTabComplete(@NotNull CommandSender sender, @NotNull Command command, @NotNull String alias, String[] args) {
switch (args.length) { switch (args.length) {
case 1: case 1:
List<String> playerNames = CommandUtils.getOnlinePlayerNames(sender); List<String> playerNames = CommandUtils.getOnlinePlayerNames(sender);
return StringUtil.copyPartialMatches(args[0], playerNames, new ArrayList<String>(playerNames.size())); return StringUtil.copyPartialMatches(args[0], playerNames, new ArrayList<>(playerNames.size()));
case 2: case 2:
return StringUtil.copyPartialMatches(args[1], PrimarySkillType.SKILL_NAMES, new ArrayList<String>(PrimarySkillType.SKILL_NAMES.size())); return StringUtil.copyPartialMatches(args[1], mcMMO.p.getSkillTools().LOCALIZED_SKILL_NAMES, new ArrayList<>(mcMMO.p.getSkillTools().LOCALIZED_SKILL_NAMES.size()));
default: default:
return ImmutableList.of(); return ImmutableList.of();
} }
@ -132,8 +149,8 @@ public abstract class ExperienceCommand implements TabExecutor {
protected abstract boolean permissionsCheckSelf(CommandSender sender); protected abstract boolean permissionsCheckSelf(CommandSender sender);
protected abstract boolean permissionsCheckOthers(CommandSender sender); protected abstract boolean permissionsCheckOthers(CommandSender sender);
protected abstract void handleCommand(Player player, PlayerProfile profile, PrimarySkillType skill, int value); protected abstract void handleCommand(Player player, PlayerProfile profile, PrimarySkillType skill, int value);
protected abstract void handlePlayerMessageAll(Player player, int value); protected abstract void handlePlayerMessageAll(Player player, int value, boolean isSilent);
protected abstract void handlePlayerMessageSkill(Player player, int value, PrimarySkillType skill); protected abstract void handlePlayerMessageSkill(Player player, int value, PrimarySkillType skill, boolean isSilent);
private boolean validateArguments(CommandSender sender, String skillName, String value) { private boolean validateArguments(CommandSender sender, String skillName, String value) {
return !(CommandUtils.isInvalidInteger(sender, value) || (!skillName.equalsIgnoreCase("all") && CommandUtils.isInvalidSkill(sender, skillName))); return !(CommandUtils.isInvalidInteger(sender, value) || (!skillName.equalsIgnoreCase("all") && CommandUtils.isInvalidSkill(sender, skillName)));
@ -144,25 +161,25 @@ public abstract class ExperienceCommand implements TabExecutor {
sender.sendMessage(LocaleLoader.getString("Commands.addlevels.AwardAll.2", playerName)); sender.sendMessage(LocaleLoader.getString("Commands.addlevels.AwardAll.2", playerName));
} }
else { else {
sender.sendMessage(LocaleLoader.getString("Commands.addlevels.AwardSkill.2", skill.getName(), playerName)); sender.sendMessage(LocaleLoader.getString("Commands.addlevels.AwardSkill.2", mcMMO.p.getSkillTools().getLocalizedSkillName(skill), playerName));
} }
} }
protected void editValues(Player player, PlayerProfile profile, PrimarySkillType skill, int value) { protected void editValues(Player player, PlayerProfile profile, PrimarySkillType skill, int value, boolean isSilent) {
if (skill == null) { if (skill == null) {
for (PrimarySkillType primarySkillType : PrimarySkillType.NON_CHILD_SKILLS) { for (PrimarySkillType primarySkillType : SkillTools.NON_CHILD_SKILLS) {
handleCommand(player, profile, primarySkillType, value); handleCommand(player, profile, primarySkillType, value);
} }
if (player != null) { if (player != null) {
handlePlayerMessageAll(player, value); handlePlayerMessageAll(player, value, isSilent);
} }
} }
else { else {
handleCommand(player, profile, skill, value); handleCommand(player, profile, skill, value);
if (player != null) { if (player != null) {
handlePlayerMessageSkill(player, value, skill); handlePlayerMessageSkill(player, value, skill, isSilent);
} }
} }
} }

View File

@ -1,11 +1,14 @@
package com.gmail.nossr50.commands.experience; package com.gmail.nossr50.commands.experience;
import com.gmail.nossr50.datatypes.experience.XPGainReason; 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.player.PlayerProfile;
import com.gmail.nossr50.datatypes.skills.PrimarySkillType; import com.gmail.nossr50.datatypes.skills.PrimarySkillType;
import com.gmail.nossr50.locale.LocaleLoader; import com.gmail.nossr50.locale.LocaleLoader;
import com.gmail.nossr50.mcMMO;
import com.gmail.nossr50.util.EventUtils; import com.gmail.nossr50.util.EventUtils;
import com.gmail.nossr50.util.Permissions; import com.gmail.nossr50.util.Permissions;
import com.gmail.nossr50.util.player.UserManager;
import org.bukkit.command.CommandSender; import org.bukkit.command.CommandSender;
import org.bukkit.entity.Player; import org.bukkit.entity.Player;
@ -36,16 +39,29 @@ public class MmoeditCommand extends ExperienceCommand {
return; return;
} }
EventUtils.tryLevelEditEvent(player, skill, value, xpRemoved, value > skillLevel, XPGainReason.COMMAND, skillLevel); McMMOPlayer mmoPlayer = UserManager.getPlayer(player);
if(mmoPlayer != null) {
EventUtils.tryLevelEditEvent(mmoPlayer, skill, value, xpRemoved, value > skillLevel, XPGainReason.COMMAND, skillLevel);
} else {
EventUtils.tryLevelEditEvent(player, skill, value, xpRemoved, value > skillLevel, XPGainReason.COMMAND, skillLevel);
}
} }
@Override @Override
protected void handlePlayerMessageAll(Player player, int value) { protected void handlePlayerMessageAll(Player player, int value, boolean isSilent) {
if(isSilent)
return;
player.sendMessage(LocaleLoader.getString("Commands.mmoedit.AllSkills.1", value)); player.sendMessage(LocaleLoader.getString("Commands.mmoedit.AllSkills.1", value));
} }
@Override @Override
protected void handlePlayerMessageSkill(Player player, int value, PrimarySkillType skill) { protected void handlePlayerMessageSkill(Player player, int value, PrimarySkillType skill, boolean isSilent) {
player.sendMessage(LocaleLoader.getString("Commands.mmoedit.Modified.1", skill.getName(), value)); if(isSilent)
return;
player.sendMessage(LocaleLoader.getString("Commands.mmoedit.Modified.1", mcMMO.p.getSkillTools().getLocalizedSkillName(skill), value));
} }
} }

View File

@ -10,6 +10,7 @@ import com.gmail.nossr50.util.EventUtils;
import com.gmail.nossr50.util.Permissions; import com.gmail.nossr50.util.Permissions;
import com.gmail.nossr50.util.commands.CommandUtils; import com.gmail.nossr50.util.commands.CommandUtils;
import com.gmail.nossr50.util.player.UserManager; import com.gmail.nossr50.util.player.UserManager;
import com.gmail.nossr50.util.skills.SkillTools;
import com.google.common.collect.ImmutableList; import com.google.common.collect.ImmutableList;
import org.bukkit.OfflinePlayer; import org.bukkit.OfflinePlayer;
import org.bukkit.command.Command; import org.bukkit.command.Command;
@ -17,10 +18,10 @@ import org.bukkit.command.CommandSender;
import org.bukkit.command.TabExecutor; import org.bukkit.command.TabExecutor;
import org.bukkit.entity.Player; import org.bukkit.entity.Player;
import org.bukkit.util.StringUtil; import org.bukkit.util.StringUtil;
import org.jetbrains.annotations.NotNull;
import java.util.ArrayList; import java.util.ArrayList;
import java.util.List; import java.util.List;
import java.util.UUID;
/** /**
* This class mirrors the structure of ExperienceCommand, except the * This class mirrors the structure of ExperienceCommand, except the
@ -28,7 +29,7 @@ import java.util.UUID;
*/ */
public class SkillresetCommand implements TabExecutor { public class SkillresetCommand implements TabExecutor {
@Override @Override
public boolean onCommand(CommandSender sender, Command command, String label, String[] args) { public boolean onCommand(@NotNull CommandSender sender, @NotNull Command command, @NotNull String label, String[] args) {
PrimarySkillType skill; PrimarySkillType skill;
switch (args.length) { switch (args.length) {
case 1: case 1:
@ -49,7 +50,7 @@ public class SkillresetCommand implements TabExecutor {
skill = null; skill = null;
} }
else { else {
skill = PrimarySkillType.getSkill(args[1]); skill = mcMMO.p.getSkillTools().matchSkill(args[0]);
} }
editValues((Player) sender, UserManager.getPlayer(sender.getName()).getProfile(), skill); editValues((Player) sender, UserManager.getPlayer(sender.getName()).getProfile(), skill);
@ -69,7 +70,7 @@ public class SkillresetCommand implements TabExecutor {
skill = null; skill = null;
} }
else { else {
skill = PrimarySkillType.getSkill(args[1]); skill = mcMMO.p.getSkillTools().matchSkill(args[1]);
} }
String playerName = CommandUtils.getMatchedPlayerName(args[0]); String playerName = CommandUtils.getMatchedPlayerName(args[0]);
@ -77,15 +78,18 @@ public class SkillresetCommand implements TabExecutor {
// 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 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) { if (mcMMOPlayer == null) {
UUID uuid = null; OfflinePlayer offlinePlayer = mcMMO.p.getServer().getOfflinePlayer(playerName);
OfflinePlayer player = mcMMO.p.getServer().getOfflinePlayer(playerName); PlayerProfile profile = mcMMO.getDatabaseManager().loadPlayerProfile(offlinePlayer);
if (player != null) {
uuid = player.getUniqueId();
}
PlayerProfile profile = mcMMO.getDatabaseManager().loadPlayerProfile(playerName, uuid, false);
//Check loading by UUID
if (CommandUtils.unloadedProfile(sender, profile)) { if (CommandUtils.unloadedProfile(sender, profile)) {
return true; //Didn't find it by UUID so try to find it by name
profile = mcMMO.getDatabaseManager().loadPlayerProfile(playerName);
//Check if it was present in DB
if(CommandUtils.unloadedProfile(sender, profile)) {
return true;
}
} }
editValues(null, profile, skill); editValues(null, profile, skill);
@ -103,13 +107,13 @@ public class SkillresetCommand implements TabExecutor {
} }
@Override @Override
public List<String> onTabComplete(CommandSender sender, Command command, String alias, String[] args) { public List<String> onTabComplete(@NotNull CommandSender sender, @NotNull Command command, @NotNull String alias, String[] args) {
switch (args.length) { switch (args.length) {
case 1: case 1:
List<String> playerNames = CommandUtils.getOnlinePlayerNames(sender); List<String> playerNames = CommandUtils.getOnlinePlayerNames(sender);
return StringUtil.copyPartialMatches(args[0], playerNames, new ArrayList<String>(playerNames.size())); return StringUtil.copyPartialMatches(args[0], playerNames, new ArrayList<>(playerNames.size()));
case 2: case 2:
return StringUtil.copyPartialMatches(args[1], PrimarySkillType.SKILL_NAMES, new ArrayList<String>(PrimarySkillType.SKILL_NAMES.size())); return StringUtil.copyPartialMatches(args[1], mcMMO.p.getSkillTools().LOCALIZED_SKILL_NAMES, new ArrayList<>(mcMMO.p.getSkillTools().LOCALIZED_SKILL_NAMES.size()));
default: default:
return ImmutableList.of(); return ImmutableList.of();
} }
@ -142,7 +146,7 @@ public class SkillresetCommand implements TabExecutor {
} }
protected void handlePlayerMessageSkill(Player player, PrimarySkillType skill) { protected void handlePlayerMessageSkill(Player player, PrimarySkillType skill) {
player.sendMessage(LocaleLoader.getString("Commands.Reset.Single", skill.getName())); player.sendMessage(LocaleLoader.getString("Commands.Reset.Single", mcMMO.p.getSkillTools().getLocalizedSkillName(skill)));
} }
private boolean validateArguments(CommandSender sender, String skillName) { private boolean validateArguments(CommandSender sender, String skillName) {
@ -154,13 +158,13 @@ public class SkillresetCommand implements TabExecutor {
sender.sendMessage(LocaleLoader.getString("Commands.addlevels.AwardAll.2", playerName)); sender.sendMessage(LocaleLoader.getString("Commands.addlevels.AwardAll.2", playerName));
} }
else { else {
sender.sendMessage(LocaleLoader.getString("Commands.addlevels.AwardSkill.2", skill.getName(), playerName)); sender.sendMessage(LocaleLoader.getString("Commands.addlevels.AwardSkill.2", mcMMO.p.getSkillTools().getLocalizedSkillName(skill), playerName));
} }
} }
protected void editValues(Player player, PlayerProfile profile, PrimarySkillType skill) { protected void editValues(Player player, PlayerProfile profile, PrimarySkillType skill) {
if (skill == null) { if (skill == null) {
for (PrimarySkillType primarySkillType : PrimarySkillType.NON_CHILD_SKILLS) { for (PrimarySkillType primarySkillType : SkillTools.NON_CHILD_SKILLS) {
handleCommand(player, profile, primarySkillType); handleCommand(player, profile, primarySkillType);
} }

View File

@ -1,64 +1,64 @@
package com.gmail.nossr50.commands.hardcore; //package com.gmail.nossr50.commands.hardcore;
//
import com.gmail.nossr50.config.Config; //import com.gmail.nossr50.config.Config;
import com.gmail.nossr50.datatypes.skills.PrimarySkillType; //import com.gmail.nossr50.datatypes.skills.PrimarySkillType;
import com.gmail.nossr50.locale.LocaleLoader; //import com.gmail.nossr50.locale.LocaleLoader;
import com.gmail.nossr50.mcMMO; //import com.gmail.nossr50.mcMMO;
import com.gmail.nossr50.util.Permissions; //import com.gmail.nossr50.util.Permissions;
import org.bukkit.command.CommandSender; //import org.bukkit.command.CommandSender;
//
public class HardcoreCommand extends HardcoreModeCommand { //public class HardcoreCommand extends HardcoreModeCommand {
@Override // @Override
protected boolean checkTogglePermissions(CommandSender sender) { // protected boolean checkTogglePermissions(CommandSender sender) {
return Permissions.hardcoreToggle(sender); // return Permissions.hardcoreToggle(sender);
} // }
//
@Override // @Override
protected boolean checkModifyPermissions(CommandSender sender) { // protected boolean checkModifyPermissions(CommandSender sender) {
return Permissions.hardcoreModify(sender); // return Permissions.hardcoreModify(sender);
} // }
//
@Override // @Override
protected boolean checkEnabled(PrimarySkillType skill) { // protected boolean checkEnabled(PrimarySkillType skill) {
if (skill == null) { // if (skill == null) {
for (PrimarySkillType primarySkillType : PrimarySkillType.values()) { // for (PrimarySkillType primarySkillType : PrimarySkillType.values()) {
if (!primarySkillType.getHardcoreStatLossEnabled()) { // if (!primarySkillType.getHardcoreStatLossEnabled()) {
return false; // return false;
} // }
} // }
//
return true; // return true;
} // }
//
return skill.getHardcoreStatLossEnabled(); // return skill.getHardcoreStatLossEnabled();
} // }
//
@Override // @Override
protected void enable(PrimarySkillType skill) { // protected void enable(PrimarySkillType skill) {
toggle(true, skill); // toggle(true, skill);
} // }
//
@Override // @Override
protected void disable(PrimarySkillType skill) { // protected void disable(PrimarySkillType skill) {
toggle(false, skill); // toggle(false, skill);
} // }
//
@Override // @Override
protected void modify(CommandSender sender, double newPercentage) { // protected void modify(CommandSender sender, double newPercentage) {
Config.getInstance().setHardcoreDeathStatPenaltyPercentage(newPercentage); // Config.getInstance().setHardcoreDeathStatPenaltyPercentage(newPercentage);
sender.sendMessage(LocaleLoader.getString("Hardcore.DeathStatLoss.PercentageChanged", percent.format(newPercentage / 100.0D))); // sender.sendMessage(LocaleLoader.getString("Hardcore.DeathStatLoss.PercentageChanged", percent.format(newPercentage / 100.0D)));
} // }
//
private void toggle(boolean enable, PrimarySkillType skill) { // private void toggle(boolean enable, PrimarySkillType skill) {
if (skill == null) { // if (skill == null) {
for (PrimarySkillType primarySkillType : PrimarySkillType.NON_CHILD_SKILLS) { // for (PrimarySkillType primarySkillType : SkillTools.NON_CHILD_SKILLS) {
primarySkillType.setHardcoreStatLossEnabled(enable); // primarySkillType.setHardcoreStatLossEnabled(enable);
} // }
} // }
else { // else {
skill.setHardcoreStatLossEnabled(enable); // skill.setHardcoreStatLossEnabled(enable);
} // }
//
mcMMO.p.getServer().broadcastMessage(LocaleLoader.getString("Hardcore.Mode." + (enable ? "Enabled" : "Disabled"), LocaleLoader.getString("Hardcore.DeathStatLoss.Name"), (skill == null ? "all skills" : skill.getName()))); // mcMMO.p.getServer().broadcastMessage(LocaleLoader.getString("Hardcore.Mode." + (enable ? "Enabled" : "Disabled"), LocaleLoader.getString("Hardcore.DeathStatLoss.Name"), (skill == null ? "all skills" : mcMMO.p.getSkillTools().getLocalizedSkillName(skill))));
} // }
} //}

View File

@ -1,130 +1,129 @@
package com.gmail.nossr50.commands.hardcore; //package com.gmail.nossr50.commands.hardcore;
//
import com.gmail.nossr50.datatypes.skills.PrimarySkillType; //import com.gmail.nossr50.datatypes.skills.PrimarySkillType;
import com.gmail.nossr50.util.Permissions; //import com.gmail.nossr50.util.Permissions;
import com.gmail.nossr50.util.StringUtils; //import com.gmail.nossr50.util.commands.CommandUtils;
import com.gmail.nossr50.util.commands.CommandUtils; //import com.gmail.nossr50.util.text.StringUtils;
import com.google.common.collect.ImmutableList; //import com.google.common.collect.ImmutableList;
import org.bukkit.command.Command; //import org.bukkit.command.Command;
import org.bukkit.command.CommandSender; //import org.bukkit.command.CommandSender;
import org.bukkit.command.TabExecutor; //import org.bukkit.command.TabExecutor;
import org.bukkit.util.StringUtil; //import org.bukkit.util.StringUtil;
//import org.jetbrains.annotations.NotNull;
import java.text.DecimalFormat; //
import java.util.ArrayList; //import java.text.DecimalFormat;
import java.util.List; //import java.util.ArrayList;
//import java.util.List;
public abstract class HardcoreModeCommand implements TabExecutor { //
protected final DecimalFormat percent = new DecimalFormat("##0.00%"); //public abstract class HardcoreModeCommand implements TabExecutor {
// protected final DecimalFormat percent = new DecimalFormat("##0.00%");
@Override //
public boolean onCommand(CommandSender sender, Command command, String label, String[] args) { // @Override
switch (args.length) { // public boolean onCommand(@NotNull CommandSender sender, @NotNull Command command, @NotNull String label, String[] args) {
case 0: // switch (args.length) {
if (!checkTogglePermissions(sender)) { // case 0:
sender.sendMessage(command.getPermissionMessage()); // if (!checkTogglePermissions(sender)) {
return true; // sender.sendMessage(command.getPermissionMessage());
} // return true;
// }
if (checkEnabled(null)) { //
disable(null); // if (checkEnabled(null)) {
} // disable(null);
else { // }
enable(null); // else {
} // enable(null);
// }
return true; //
// return true;
case 1: //
if (CommandUtils.shouldEnableToggle(args[0])) { // case 1:
if (!Permissions.hardcoreToggle(sender)) { // if (CommandUtils.shouldEnableToggle(args[0])) {
sender.sendMessage(command.getPermissionMessage()); // if (!Permissions.hardcoreToggle(sender)) {
return true; // sender.sendMessage(command.getPermissionMessage());
} // return true;
// }
enable(null); //
return true; // enable(null);
} // return true;
// }
if (CommandUtils.shouldDisableToggle(args[0])) { //
if (!Permissions.hardcoreToggle(sender)) { // if (CommandUtils.shouldDisableToggle(args[0])) {
sender.sendMessage(command.getPermissionMessage()); // if (!Permissions.hardcoreToggle(sender)) {
return true; // sender.sendMessage(command.getPermissionMessage());
} // return true;
// }
disable(null); //
return true; // disable(null);
} // return true;
// }
if (CommandUtils.isInvalidDouble(sender, args[0])) { //
return true; // if (CommandUtils.isInvalidDouble(sender, args[0])) {
} // return true;
// }
if (!Permissions.hardcoreModify(sender)) { //
sender.sendMessage(command.getPermissionMessage()); // if (!Permissions.hardcoreModify(sender)) {
return true; // sender.sendMessage(command.getPermissionMessage());
} // return true;
// }
modify(sender, Double.parseDouble(args[0])); //
return true; // modify(sender, Double.parseDouble(args[0]));
// return true;
//
case 2: //
if (CommandUtils.isInvalidSkill(sender, args[0])) { // case 2:
return true; // if (CommandUtils.isInvalidSkill(sender, args[0])) {
} // return true;
// }
PrimarySkillType skill = PrimarySkillType.getSkill(args[0]); //
// PrimarySkillType skill = PrimarySkillType.getSkill(args[0]);
if (!CommandUtils.isChildSkill(sender, skill)) { //
return true; // if (!CommandUtils.isChildSkill(sender, skill)) {
} // return true;
// }
if (CommandUtils.shouldEnableToggle(args[1])) { //
if (!Permissions.hardcoreToggle(sender)) { // if (CommandUtils.shouldEnableToggle(args[1])) {
sender.sendMessage(command.getPermissionMessage()); // if (!Permissions.hardcoreToggle(sender)) {
return true; // sender.sendMessage(command.getPermissionMessage());
} // return true;
// }
enable(skill); //
return true; // enable(skill);
} // return true;
// }
if (CommandUtils.shouldDisableToggle(args[1])) { //
if (!Permissions.hardcoreToggle(sender)) { // if (CommandUtils.shouldDisableToggle(args[1])) {
sender.sendMessage(command.getPermissionMessage()); // if (!Permissions.hardcoreToggle(sender)) {
return true; // sender.sendMessage(command.getPermissionMessage());
} // return true;
// }
enable(skill); //
return true; // enable(skill);
} // return true;
// }
return true; //
// return true;
default: //
return false; // default:
} // return false;
} // }
// }
@Override //
public List<String> onTabComplete(CommandSender sender, Command command, String alias, String[] args) { // @Override
switch (args.length) { // public List<String> onTabComplete(@NotNull CommandSender sender, @NotNull Command command, @NotNull String alias, String[] args) {
case 1: // if (args.length == 1) {
if (StringUtils.isDouble(args[0])) { // if (StringUtils.isDouble(args[0])) {
return ImmutableList.of(); // return ImmutableList.of();
} // }
//
return StringUtil.copyPartialMatches(args[0], CommandUtils.TRUE_FALSE_OPTIONS, new ArrayList<String>(CommandUtils.TRUE_FALSE_OPTIONS.size())); // return StringUtil.copyPartialMatches(args[0], CommandUtils.TRUE_FALSE_OPTIONS, new ArrayList<>(CommandUtils.TRUE_FALSE_OPTIONS.size()));
default: // }
return ImmutableList.of(); // return ImmutableList.of();
} // }
} //
// protected abstract boolean checkTogglePermissions(CommandSender sender);
protected abstract boolean checkTogglePermissions(CommandSender sender); // protected abstract boolean checkModifyPermissions(CommandSender sender);
protected abstract boolean checkModifyPermissions(CommandSender sender); // protected abstract boolean checkEnabled(PrimarySkillType skill);
protected abstract boolean checkEnabled(PrimarySkillType skill); // protected abstract void enable(PrimarySkillType skill);
protected abstract void enable(PrimarySkillType skill); // protected abstract void disable(PrimarySkillType skill);
protected abstract void disable(PrimarySkillType skill); // protected abstract void modify(CommandSender sender, double newPercentage);
protected abstract void modify(CommandSender sender, double newPercentage); //}
}

View File

@ -1,64 +1,64 @@
package com.gmail.nossr50.commands.hardcore; //package com.gmail.nossr50.commands.hardcore;
//
import com.gmail.nossr50.config.Config; //import com.gmail.nossr50.config.Config;
import com.gmail.nossr50.datatypes.skills.PrimarySkillType; //import com.gmail.nossr50.datatypes.skills.PrimarySkillType;
import com.gmail.nossr50.locale.LocaleLoader; //import com.gmail.nossr50.locale.LocaleLoader;
import com.gmail.nossr50.mcMMO; //import com.gmail.nossr50.mcMMO;
import com.gmail.nossr50.util.Permissions; //import com.gmail.nossr50.util.Permissions;
import org.bukkit.command.CommandSender; //import org.bukkit.command.CommandSender;
//
public class VampirismCommand extends HardcoreModeCommand { //public class VampirismCommand extends HardcoreModeCommand {
@Override // @Override
protected boolean checkTogglePermissions(CommandSender sender) { // protected boolean checkTogglePermissions(CommandSender sender) {
return Permissions.vampirismToggle(sender); // return Permissions.vampirismToggle(sender);
} // }
//
@Override // @Override
protected boolean checkModifyPermissions(CommandSender sender) { // protected boolean checkModifyPermissions(CommandSender sender) {
return Permissions.vampirismModify(sender); // return Permissions.vampirismModify(sender);
} // }
//
@Override // @Override
protected boolean checkEnabled(PrimarySkillType skill) { // protected boolean checkEnabled(PrimarySkillType skill) {
if (skill == null) { // if (skill == null) {
for (PrimarySkillType primarySkillType : PrimarySkillType.values()) { // for (PrimarySkillType primarySkillType : PrimarySkillType.values()) {
if (!primarySkillType.getHardcoreVampirismEnabled()) { // if (!primarySkillType.getHardcoreVampirismEnabled()) {
return false; // return false;
} // }
} // }
//
return true; // return true;
} // }
//
return skill.getHardcoreVampirismEnabled(); // return skill.getHardcoreVampirismEnabled();
} // }
//
@Override // @Override
protected void enable(PrimarySkillType skill) { // protected void enable(PrimarySkillType skill) {
toggle(true, skill); // toggle(true, skill);
} // }
//
@Override // @Override
protected void disable(PrimarySkillType skill) { // protected void disable(PrimarySkillType skill) {
toggle(false, skill); // toggle(false, skill);
} // }
//
@Override // @Override
protected void modify(CommandSender sender, double newPercentage) { // protected void modify(CommandSender sender, double newPercentage) {
Config.getInstance().setHardcoreVampirismStatLeechPercentage(newPercentage); // Config.getInstance().setHardcoreVampirismStatLeechPercentage(newPercentage);
sender.sendMessage(LocaleLoader.getString("Hardcore.Vampirism.PercentageChanged", percent.format(newPercentage / 100.0D))); // sender.sendMessage(LocaleLoader.getString("Hardcore.Vampirism.PercentageChanged", percent.format(newPercentage / 100.0D)));
} // }
//
private void toggle(boolean enable, PrimarySkillType skill) { // private void toggle(boolean enable, PrimarySkillType skill) {
if (skill == null) { // if (skill == null) {
for (PrimarySkillType primarySkillType : PrimarySkillType.NON_CHILD_SKILLS) { // for (PrimarySkillType primarySkillType : SkillTools.NON_CHILD_SKILLS) {
primarySkillType.setHardcoreVampirismEnabled(enable); // primarySkillType.setHardcoreVampirismEnabled(enable);
} // }
} // }
else { // else {
skill.setHardcoreVampirismEnabled(enable); // skill.setHardcoreVampirismEnabled(enable);
} // }
//
mcMMO.p.getServer().broadcastMessage(LocaleLoader.getString("Hardcore.Mode." + (enable ? "Enabled" : "Disabled"), LocaleLoader.getString("Hardcore.Vampirism.Name"), (skill == null ? "all skills" : skill))); // mcMMO.p.getServer().broadcastMessage(LocaleLoader.getString("Hardcore.Mode." + (enable ? "Enabled" : "Disabled"), LocaleLoader.getString("Hardcore.Vampirism.Name"), (skill == null ? "all skills" : skill)));
} // }
} //}

View File

@ -8,40 +8,37 @@ import org.bukkit.command.Command;
import org.bukkit.command.CommandExecutor; import org.bukkit.command.CommandExecutor;
import org.bukkit.command.CommandSender; import org.bukkit.command.CommandSender;
import org.bukkit.entity.Player; import org.bukkit.entity.Player;
import org.jetbrains.annotations.NotNull;
public class PartyAcceptCommand implements CommandExecutor { public class PartyAcceptCommand implements CommandExecutor {
@Override @Override
public boolean onCommand(CommandSender sender, Command command, String label, String[] args) { public boolean onCommand(@NotNull CommandSender sender, @NotNull Command command, @NotNull String label, String[] args) {
switch (args.length) { if (args.length == 1) {
case 1: Player player = (Player) sender;
Player player = (Player) sender;
//Check if player profile is loaded //Check if player profile is loaded
if(UserManager.getPlayer(player) == null) if (UserManager.getPlayer(player) == null) {
{ sender.sendMessage(LocaleLoader.getString("Profile.PendingLoad"));
sender.sendMessage(LocaleLoader.getString("Profile.PendingLoad"));
return true;
}
McMMOPlayer mcMMOPlayer = UserManager.getPlayer(player);
if (!mcMMOPlayer.hasPartyInvite()) {
sender.sendMessage(LocaleLoader.getString("mcMMO.NoInvites"));
return true;
}
// Changing parties
if (!PartyManager.changeOrJoinParty(mcMMOPlayer, mcMMOPlayer.getPartyInvite().getName())) {
return true;
}
PartyManager.joinInvitedParty(mcMMOPlayer);
return true; return true;
}
default: McMMOPlayer mcMMOPlayer = UserManager.getPlayer(player);
sender.sendMessage(LocaleLoader.getString("Commands.Usage.1", "party", "accept"));
if (!mcMMOPlayer.hasPartyInvite()) {
sender.sendMessage(LocaleLoader.getString("mcMMO.NoInvites"));
return true; return true;
}
// Changing parties
if (!PartyManager.changeOrJoinParty(mcMMOPlayer, mcMMOPlayer.getPartyInvite().getName())) {
return true;
}
PartyManager.joinInvitedParty(mcMMOPlayer);
return true;
} }
sender.sendMessage(LocaleLoader.getString("Commands.Usage.1", "party", "accept"));
return true;
} }
} }

View File

@ -11,34 +11,30 @@ import org.bukkit.command.Command;
import org.bukkit.command.CommandExecutor; import org.bukkit.command.CommandExecutor;
import org.bukkit.command.CommandSender; import org.bukkit.command.CommandSender;
import org.bukkit.entity.Player; import org.bukkit.entity.Player;
import org.jetbrains.annotations.NotNull;
public class PartyChangeOwnerCommand implements CommandExecutor { public class PartyChangeOwnerCommand implements CommandExecutor {
@Override @Override
public boolean onCommand(CommandSender sender, Command command, String label, String[] args) { public boolean onCommand(@NotNull CommandSender sender, @NotNull Command command, @NotNull String label, String[] args) {
switch (args.length) { if (args.length == 2) {//Check if player profile is loaded
case 2: if (UserManager.getPlayer((Player) sender) == null) {
//Check if player profile is loaded sender.sendMessage(LocaleLoader.getString("Profile.PendingLoad"));
if(UserManager.getPlayer((Player) sender) == null)
{
sender.sendMessage(LocaleLoader.getString("Profile.PendingLoad"));
return true;
}
Party playerParty = UserManager.getPlayer((Player) sender).getParty();
String targetName = CommandUtils.getMatchedPlayerName(args[1]);
OfflinePlayer target = mcMMO.p.getServer().getOfflinePlayer(targetName);
if (!playerParty.hasMember(target.getUniqueId())) {
sender.sendMessage(LocaleLoader.getString("Party.NotInYourParty", targetName));
return true;
}
PartyManager.setPartyLeader(target.getUniqueId(), playerParty);
return true; return true;
}
default: Party playerParty = UserManager.getPlayer((Player) sender).getParty();
sender.sendMessage(LocaleLoader.getString("Commands.Usage.2", "party", "owner", "<" + LocaleLoader.getString("Commands.Usage.Player") + ">")); String targetName = CommandUtils.getMatchedPlayerName(args[1]);
OfflinePlayer target = mcMMO.p.getServer().getOfflinePlayer(targetName);
if (!playerParty.hasMember(target.getUniqueId())) {
sender.sendMessage(LocaleLoader.getString("Party.NotInYourParty", targetName));
return true; return true;
}
PartyManager.setPartyLeader(target.getUniqueId(), playerParty);
return true;
} }
sender.sendMessage(LocaleLoader.getString("Commands.Usage.2", "party", "owner", "<" + LocaleLoader.getString("Commands.Usage.Player") + ">"));
return true;
} }
} }

View File

@ -7,10 +7,11 @@ import org.bukkit.command.Command;
import org.bukkit.command.CommandExecutor; import org.bukkit.command.CommandExecutor;
import org.bukkit.command.CommandSender; import org.bukkit.command.CommandSender;
import org.bukkit.entity.Player; import org.bukkit.entity.Player;
import org.jetbrains.annotations.NotNull;
public class PartyChangePasswordCommand implements CommandExecutor { public class PartyChangePasswordCommand implements CommandExecutor {
@Override @Override
public boolean onCommand(CommandSender sender, Command command, String label, String[] args) { public boolean onCommand(@NotNull CommandSender sender, @NotNull Command command, @NotNull String label, String[] args) {
if(UserManager.getPlayer((Player) sender) == null) if(UserManager.getPlayer((Player) sender) == null)
{ {
sender.sendMessage(LocaleLoader.getString("Profile.PendingLoad")); sender.sendMessage(LocaleLoader.getString("Profile.PendingLoad"));

View File

@ -1,6 +1,5 @@
package com.gmail.nossr50.commands.party; package com.gmail.nossr50.commands.party;
import com.gmail.nossr50.commands.chat.PartyChatCommand;
import com.gmail.nossr50.commands.party.alliance.PartyAllianceCommand; import com.gmail.nossr50.commands.party.alliance.PartyAllianceCommand;
import com.gmail.nossr50.commands.party.teleport.PtpCommand; import com.gmail.nossr50.commands.party.teleport.PtpCommand;
import com.gmail.nossr50.datatypes.party.Party; import com.gmail.nossr50.datatypes.party.Party;
@ -16,6 +15,7 @@ import org.bukkit.command.CommandSender;
import org.bukkit.command.TabExecutor; import org.bukkit.command.TabExecutor;
import org.bukkit.entity.Player; import org.bukkit.entity.Player;
import org.bukkit.util.StringUtil; import org.bukkit.util.StringUtil;
import org.jetbrains.annotations.NotNull;
import java.util.ArrayList; import java.util.ArrayList;
import java.util.Arrays; import java.util.Arrays;
@ -28,7 +28,7 @@ public class PartyCommand implements TabExecutor {
private static final List<String> ITEMSHARE_COMPLETIONS = ImmutableList.of("none", "equal", "random", "loot", "mining", "herbalism", "woodcutting", "misc"); private static final List<String> ITEMSHARE_COMPLETIONS = ImmutableList.of("none", "equal", "random", "loot", "mining", "herbalism", "woodcutting", "misc");
static { static {
ArrayList<String> subcommands = new ArrayList<String>(); ArrayList<String> subcommands = new ArrayList<>();
for (PartySubcommandType subcommand : PartySubcommandType.values()) { for (PartySubcommandType subcommand : PartySubcommandType.values()) {
subcommands.add(subcommand.toString()); subcommands.add(subcommand.toString());
@ -38,27 +38,26 @@ public class PartyCommand implements TabExecutor {
PARTY_SUBCOMMANDS = ImmutableList.copyOf(subcommands); PARTY_SUBCOMMANDS = ImmutableList.copyOf(subcommands);
} }
private CommandExecutor partyJoinCommand = new PartyJoinCommand(); private final CommandExecutor partyJoinCommand = new PartyJoinCommand();
private CommandExecutor partyAcceptCommand = new PartyAcceptCommand(); private final CommandExecutor partyAcceptCommand = new PartyAcceptCommand();
private CommandExecutor partyCreateCommand = new PartyCreateCommand(); private final CommandExecutor partyCreateCommand = new PartyCreateCommand();
private CommandExecutor partyQuitCommand = new PartyQuitCommand(); private final CommandExecutor partyQuitCommand = new PartyQuitCommand();
private CommandExecutor partyXpShareCommand = new PartyXpShareCommand(); private final CommandExecutor partyXpShareCommand = new PartyXpShareCommand();
private CommandExecutor partyItemShareCommand = new PartyItemShareCommand(); private final CommandExecutor partyItemShareCommand = new PartyItemShareCommand();
private CommandExecutor partyInviteCommand = new PartyInviteCommand(); private final CommandExecutor partyInviteCommand = new PartyInviteCommand();
private CommandExecutor partyKickCommand = new PartyKickCommand(); private final CommandExecutor partyKickCommand = new PartyKickCommand();
private CommandExecutor partyDisbandCommand = new PartyDisbandCommand(); private final CommandExecutor partyDisbandCommand = new PartyDisbandCommand();
private CommandExecutor partyChangeOwnerCommand = new PartyChangeOwnerCommand(); private final CommandExecutor partyChangeOwnerCommand = new PartyChangeOwnerCommand();
private CommandExecutor partyLockCommand = new PartyLockCommand(); private final CommandExecutor partyLockCommand = new PartyLockCommand();
private CommandExecutor partyChangePasswordCommand = new PartyChangePasswordCommand(); private final CommandExecutor partyChangePasswordCommand = new PartyChangePasswordCommand();
private CommandExecutor partyRenameCommand = new PartyRenameCommand(); private final CommandExecutor partyRenameCommand = new PartyRenameCommand();
private CommandExecutor partyInfoCommand = new PartyInfoCommand(); private final CommandExecutor partyInfoCommand = new PartyInfoCommand();
private CommandExecutor partyHelpCommand = new PartyHelpCommand(); private final CommandExecutor partyHelpCommand = new PartyHelpCommand();
private CommandExecutor partyTeleportCommand = new PtpCommand(); private final CommandExecutor partyTeleportCommand = new PtpCommand();
private CommandExecutor partyChatCommand = new PartyChatCommand(); private final CommandExecutor partyAllianceCommand = new PartyAllianceCommand();
private CommandExecutor partyAllianceCommand = new PartyAllianceCommand();
@Override @Override
public boolean onCommand(CommandSender sender, Command command, String label, String[] args) { public boolean onCommand(@NotNull CommandSender sender, @NotNull Command command, @NotNull String label, String[] args) {
if (CommandUtils.noConsoleUsage(sender)) { if (CommandUtils.noConsoleUsage(sender)) {
return true; return true;
} }
@ -131,8 +130,6 @@ public class PartyCommand implements TabExecutor {
return partyInviteCommand.onCommand(sender, command, label, args); return partyInviteCommand.onCommand(sender, command, label, args);
case TELEPORT: case TELEPORT:
return partyTeleportCommand.onCommand(sender, command, label, extractArgs(args)); return partyTeleportCommand.onCommand(sender, command, label, extractArgs(args));
case CHAT:
return partyChatCommand.onCommand(sender, command, label, extractArgs(args));
default: default:
break; break;
} }
@ -171,10 +168,10 @@ public class PartyCommand implements TabExecutor {
} }
@Override @Override
public List<String> onTabComplete(CommandSender sender, Command command, String alias, String[] args) { public List<String> onTabComplete(@NotNull CommandSender sender, @NotNull Command command, @NotNull String alias, String[] args) {
switch (args.length) { switch (args.length) {
case 1: case 1:
return StringUtil.copyPartialMatches(args[0], PARTY_SUBCOMMANDS, new ArrayList<String>(PARTY_SUBCOMMANDS.size())); return StringUtil.copyPartialMatches(args[0], PARTY_SUBCOMMANDS, new ArrayList<>(PARTY_SUBCOMMANDS.size()));
case 2: case 2:
PartySubcommandType subcommand = PartySubcommandType.getSubcommand(args[0]); PartySubcommandType subcommand = PartySubcommandType.getSubcommand(args[0]);
@ -188,18 +185,18 @@ public class PartyCommand implements TabExecutor {
case KICK: case KICK:
case OWNER: case OWNER:
List<String> playerNames = CommandUtils.getOnlinePlayerNames(sender); List<String> playerNames = CommandUtils.getOnlinePlayerNames(sender);
return StringUtil.copyPartialMatches(args[1], playerNames, new ArrayList<String>(playerNames.size())); return StringUtil.copyPartialMatches(args[1], playerNames, new ArrayList<>(playerNames.size()));
case XPSHARE: case XPSHARE:
return StringUtil.copyPartialMatches(args[1], XPSHARE_COMPLETIONS, new ArrayList<String>(XPSHARE_COMPLETIONS.size())); return StringUtil.copyPartialMatches(args[1], XPSHARE_COMPLETIONS, new ArrayList<>(XPSHARE_COMPLETIONS.size()));
case ITEMSHARE: case ITEMSHARE:
return StringUtil.copyPartialMatches(args[1], ITEMSHARE_COMPLETIONS, new ArrayList<String>(ITEMSHARE_COMPLETIONS.size())); return StringUtil.copyPartialMatches(args[1], ITEMSHARE_COMPLETIONS, new ArrayList<>(ITEMSHARE_COMPLETIONS.size()));
case LOCK: case LOCK:
case CHAT: case CHAT:
return StringUtil.copyPartialMatches(args[1], CommandUtils.TRUE_FALSE_OPTIONS, new ArrayList<String>(CommandUtils.TRUE_FALSE_OPTIONS.size())); return StringUtil.copyPartialMatches(args[1], CommandUtils.TRUE_FALSE_OPTIONS, new ArrayList<>(CommandUtils.TRUE_FALSE_OPTIONS.size()));
case PASSWORD: case PASSWORD:
return StringUtil.copyPartialMatches(args[1], CommandUtils.RESET_OPTIONS, new ArrayList<String>(CommandUtils.RESET_OPTIONS.size())); return StringUtil.copyPartialMatches(args[1], CommandUtils.RESET_OPTIONS, new ArrayList<>(CommandUtils.RESET_OPTIONS.size()));
case TELEPORT: case TELEPORT:
List<String> matches = StringUtil.copyPartialMatches(args[1], PtpCommand.TELEPORT_SUBCOMMANDS, new ArrayList<String>(PtpCommand.TELEPORT_SUBCOMMANDS.size())); List<String> matches = StringUtil.copyPartialMatches(args[1], PtpCommand.TELEPORT_SUBCOMMANDS, new ArrayList<>(PtpCommand.TELEPORT_SUBCOMMANDS.size()));
if (matches.size() == 0) { if (matches.size() == 0) {
Player player = (Player) sender; Player player = (Player) sender;
@ -214,7 +211,7 @@ public class PartyCommand implements TabExecutor {
Party party = UserManager.getPlayer(player).getParty(); Party party = UserManager.getPlayer(player).getParty();
playerNames = party.getOnlinePlayerNames(player); playerNames = party.getOnlinePlayerNames(player);
return StringUtil.copyPartialMatches(args[1], playerNames, new ArrayList<String>(playerNames.size())); return StringUtil.copyPartialMatches(args[1], playerNames, new ArrayList<>(playerNames.size()));
} }
return matches; return matches;
@ -223,7 +220,7 @@ public class PartyCommand implements TabExecutor {
} }
case 3: case 3:
if (PartySubcommandType.getSubcommand(args[0]) == PartySubcommandType.ITEMSHARE && isItemShareCategory(args[1])) { if (PartySubcommandType.getSubcommand(args[0]) == PartySubcommandType.ITEMSHARE && isItemShareCategory(args[1])) {
return StringUtil.copyPartialMatches(args[2], CommandUtils.TRUE_FALSE_OPTIONS, new ArrayList<String>(CommandUtils.TRUE_FALSE_OPTIONS.size())); return StringUtil.copyPartialMatches(args[2], CommandUtils.TRUE_FALSE_OPTIONS, new ArrayList<>(CommandUtils.TRUE_FALSE_OPTIONS.size()));
} }
return ImmutableList.of(); return ImmutableList.of();

View File

@ -8,10 +8,11 @@ import org.bukkit.command.Command;
import org.bukkit.command.CommandExecutor; import org.bukkit.command.CommandExecutor;
import org.bukkit.command.CommandSender; import org.bukkit.command.CommandSender;
import org.bukkit.entity.Player; import org.bukkit.entity.Player;
import org.jetbrains.annotations.NotNull;
public class PartyCreateCommand implements CommandExecutor { public class PartyCreateCommand implements CommandExecutor {
@Override @Override
public boolean onCommand(CommandSender sender, Command command, String label, String[] args) { public boolean onCommand(@NotNull CommandSender sender, @NotNull Command command, @NotNull String label, String[] args) {
switch (args.length) { switch (args.length) {
case 2: case 2:
case 3: case 3:

View File

@ -1,6 +1,7 @@
package com.gmail.nossr50.commands.party; package com.gmail.nossr50.commands.party;
import com.gmail.nossr50.datatypes.party.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.events.party.McMMOPartyChangeEvent.EventReason;
import com.gmail.nossr50.locale.LocaleLoader; import com.gmail.nossr50.locale.LocaleLoader;
import com.gmail.nossr50.party.PartyManager; import com.gmail.nossr50.party.PartyManager;
@ -9,35 +10,33 @@ import org.bukkit.command.Command;
import org.bukkit.command.CommandExecutor; import org.bukkit.command.CommandExecutor;
import org.bukkit.command.CommandSender; import org.bukkit.command.CommandSender;
import org.bukkit.entity.Player; import org.bukkit.entity.Player;
import org.jetbrains.annotations.NotNull;
public class PartyDisbandCommand implements CommandExecutor { public class PartyDisbandCommand implements CommandExecutor {
@Override @Override
public boolean onCommand(CommandSender sender, Command command, String label, String[] args) { public boolean onCommand(@NotNull CommandSender sender, @NotNull Command command, @NotNull String label, String[] args) {
switch (args.length) { if (args.length == 1) {
case 1: final McMMOPlayer mcMMOPlayer = UserManager.getPlayer((Player) sender);
if(UserManager.getPlayer((Player) sender) == null) if (mcMMOPlayer == null) {
{ sender.sendMessage(LocaleLoader.getString("Profile.PendingLoad"));
sender.sendMessage(LocaleLoader.getString("Profile.PendingLoad")); return true;
}
final Party playerParty = mcMMOPlayer.getParty();
final String partyName = playerParty.getName();
for (Player member : playerParty.getOnlineMembers()) {
if (!PartyManager.handlePartyChangeEvent(member, partyName, null, EventReason.KICKED_FROM_PARTY)) {
return true; return true;
} }
Party playerParty = UserManager.getPlayer((Player) sender).getParty(); member.sendMessage(LocaleLoader.getString("Party.Disband"));
String partyName = playerParty.getName(); }
for (Player member : playerParty.getOnlineMembers()) { PartyManager.disbandParty(mcMMOPlayer, playerParty);
if (!PartyManager.handlePartyChangeEvent(member, partyName, null, EventReason.KICKED_FROM_PARTY)) { return true;
return true;
}
member.sendMessage(LocaleLoader.getString("Party.Disband"));
}
PartyManager.disbandParty(playerParty);
return true;
default:
sender.sendMessage(LocaleLoader.getString("Commands.Usage.1", "party", "disband"));
return true;
} }
sender.sendMessage(LocaleLoader.getString("Commands.Usage.1", "party", "disband"));
return true;
} }
} }

View File

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

View File

@ -1,11 +1,11 @@
package com.gmail.nossr50.commands.party; package com.gmail.nossr50.commands.party;
import com.gmail.nossr50.config.Config;
import com.gmail.nossr50.datatypes.party.Party; import com.gmail.nossr50.datatypes.party.Party;
import com.gmail.nossr50.datatypes.party.PartyFeature; import com.gmail.nossr50.datatypes.party.PartyFeature;
import com.gmail.nossr50.datatypes.party.ShareMode; import com.gmail.nossr50.datatypes.party.ShareMode;
import com.gmail.nossr50.datatypes.player.McMMOPlayer; import com.gmail.nossr50.datatypes.player.McMMOPlayer;
import com.gmail.nossr50.locale.LocaleLoader; import com.gmail.nossr50.locale.LocaleLoader;
import com.gmail.nossr50.mcMMO;
import com.gmail.nossr50.party.PartyManager; import com.gmail.nossr50.party.PartyManager;
import com.gmail.nossr50.util.player.UserManager; import com.gmail.nossr50.util.player.UserManager;
import org.bukkit.ChatColor; import org.bukkit.ChatColor;
@ -13,13 +13,14 @@ import org.bukkit.command.Command;
import org.bukkit.command.CommandExecutor; import org.bukkit.command.CommandExecutor;
import org.bukkit.command.CommandSender; import org.bukkit.command.CommandSender;
import org.bukkit.entity.Player; import org.bukkit.entity.Player;
import org.jetbrains.annotations.NotNull;
import java.util.ArrayList; import java.util.ArrayList;
import java.util.List; import java.util.List;
public class PartyInfoCommand implements CommandExecutor { public class PartyInfoCommand implements CommandExecutor {
@Override @Override
public boolean onCommand(CommandSender sender, Command command, String label, String[] args) { public boolean onCommand(@NotNull CommandSender sender, @NotNull Command command, @NotNull String label, String[] args) {
switch (args.length) { switch (args.length) {
case 0: case 0:
case 1: case 1:
@ -60,8 +61,8 @@ public class PartyInfoCommand implements CommandExecutor {
private void displayPartyFeatures(Player player, Party party) { private void displayPartyFeatures(Player player, Party party) {
player.sendMessage(LocaleLoader.getString("Commands.Party.Features.Header")); player.sendMessage(LocaleLoader.getString("Commands.Party.Features.Header"));
List<String> unlockedPartyFeatures = new ArrayList<String>(); List<String> unlockedPartyFeatures = new ArrayList<>();
List<String> lockedPartyFeatures = new ArrayList<String>(); List<String> lockedPartyFeatures = new ArrayList<>();
for (PartyFeature partyFeature : PartyFeature.values()) { for (PartyFeature partyFeature : PartyFeature.values()) {
if (!partyFeature.hasPermission(player)) { if (!partyFeature.hasPermission(player)) {
@ -84,7 +85,7 @@ public class PartyInfoCommand implements CommandExecutor {
} }
private boolean isUnlockedFeature(Party party, PartyFeature partyFeature) { private boolean isUnlockedFeature(Party party, PartyFeature partyFeature) {
return party.getLevel() >= Config.getInstance().getPartyFeatureUnlockLevel(partyFeature); return party.getLevel() >= mcMMO.p.getGeneralConfig().getPartyFeatureUnlockLevel(partyFeature);
} }
private void displayShareModeInfo(Player player, Party party) { private void displayShareModeInfo(Player player, Party party) {

View File

@ -1,9 +1,9 @@
package com.gmail.nossr50.commands.party; package com.gmail.nossr50.commands.party;
import com.gmail.nossr50.config.Config;
import com.gmail.nossr50.datatypes.party.Party; import com.gmail.nossr50.datatypes.party.Party;
import com.gmail.nossr50.datatypes.player.McMMOPlayer; import com.gmail.nossr50.datatypes.player.McMMOPlayer;
import com.gmail.nossr50.locale.LocaleLoader; import com.gmail.nossr50.locale.LocaleLoader;
import com.gmail.nossr50.mcMMO;
import com.gmail.nossr50.party.PartyManager; import com.gmail.nossr50.party.PartyManager;
import com.gmail.nossr50.util.commands.CommandUtils; import com.gmail.nossr50.util.commands.CommandUtils;
import com.gmail.nossr50.util.player.UserManager; import com.gmail.nossr50.util.player.UserManager;
@ -11,64 +11,60 @@ import org.bukkit.command.Command;
import org.bukkit.command.CommandExecutor; import org.bukkit.command.CommandExecutor;
import org.bukkit.command.CommandSender; import org.bukkit.command.CommandSender;
import org.bukkit.entity.Player; import org.bukkit.entity.Player;
import org.jetbrains.annotations.NotNull;
public class PartyInviteCommand implements CommandExecutor { public class PartyInviteCommand implements CommandExecutor {
@Override @Override
public boolean onCommand(CommandSender sender, Command command, String label, String[] args) { public boolean onCommand(@NotNull CommandSender sender, @NotNull Command command, @NotNull String label, String[] args) {
switch (args.length) { if (args.length == 2) {
case 2: String targetName = CommandUtils.getMatchedPlayerName(args[1]);
String targetName = CommandUtils.getMatchedPlayerName(args[1]); McMMOPlayer mcMMOTarget = UserManager.getOfflinePlayer(targetName);
McMMOPlayer mcMMOTarget = UserManager.getOfflinePlayer(targetName);
if (!CommandUtils.checkPlayerExistence(sender, targetName, mcMMOTarget)) { if (!CommandUtils.checkPlayerExistence(sender, targetName, mcMMOTarget)) {
return false; return false;
} }
Player target = mcMMOTarget.getPlayer(); Player target = mcMMOTarget.getPlayer();
if(UserManager.getPlayer((Player) sender) == null) if (UserManager.getPlayer((Player) sender) == null) {
{ sender.sendMessage(LocaleLoader.getString("Profile.PendingLoad"));
sender.sendMessage(LocaleLoader.getString("Profile.PendingLoad"));
return true;
}
Player player = (Player) sender;
McMMOPlayer mcMMOPlayer = UserManager.getPlayer(player);
String playerName = player.getName();
if (player.equals(target)) {
sender.sendMessage(LocaleLoader.getString("Party.Invite.Self"));
return true;
}
if (PartyManager.inSameParty(player, target)) {
sender.sendMessage(LocaleLoader.getString("Party.Player.InSameParty", targetName));
return true;
}
if (!PartyManager.canInvite(mcMMOPlayer)) {
player.sendMessage(LocaleLoader.getString("Party.Locked"));
return true;
}
Party playerParty = mcMMOPlayer.getParty();
if(PartyManager.isPartyFull(target, playerParty))
{
player.sendMessage(LocaleLoader.getString("Commands.Party.PartyFull.Invite", target.getName(), playerParty.toString(), Config.getInstance().getPartyMaxSize()));
return true;
}
mcMMOTarget.setPartyInvite(playerParty);
sender.sendMessage(LocaleLoader.getString("Commands.Invite.Success"));
target.sendMessage(LocaleLoader.getString("Commands.Party.Invite.0", playerParty.getName(), playerName));
target.sendMessage(LocaleLoader.getString("Commands.Party.Invite.1"));
return true; return true;
}
default: Player player = (Player) sender;
sender.sendMessage(LocaleLoader.getString("Commands.Usage.2", "party", "invite", "<" + LocaleLoader.getString("Commands.Usage.Player") + ">")); McMMOPlayer mcMMOPlayer = UserManager.getPlayer(player);
String playerName = player.getName();
if (player.equals(target)) {
sender.sendMessage(LocaleLoader.getString("Party.Invite.Self"));
return true; return true;
}
if (PartyManager.inSameParty(player, target)) {
sender.sendMessage(LocaleLoader.getString("Party.Player.InSameParty", targetName));
return true;
}
if (!PartyManager.canInvite(mcMMOPlayer)) {
player.sendMessage(LocaleLoader.getString("Party.Locked"));
return true;
}
Party playerParty = mcMMOPlayer.getParty();
if (PartyManager.isPartyFull(target, playerParty)) {
player.sendMessage(LocaleLoader.getString("Commands.Party.PartyFull.Invite", target.getName(), playerParty.toString(), mcMMO.p.getGeneralConfig().getPartyMaxSize()));
return true;
}
mcMMOTarget.setPartyInvite(playerParty);
sender.sendMessage(LocaleLoader.getString("Commands.Invite.Success"));
target.sendMessage(LocaleLoader.getString("Commands.Party.Invite.0", playerParty.getName(), playerName));
target.sendMessage(LocaleLoader.getString("Commands.Party.Invite.1"));
return true;
} }
sender.sendMessage(LocaleLoader.getString("Commands.Usage.2", "party", "invite", "<" + LocaleLoader.getString("Commands.Usage.Player") + ">"));
return true;
} }
} }

View File

@ -1,24 +1,25 @@
package com.gmail.nossr50.commands.party; package com.gmail.nossr50.commands.party;
import com.gmail.nossr50.config.Config;
import com.gmail.nossr50.datatypes.party.ItemShareType; import com.gmail.nossr50.datatypes.party.ItemShareType;
import com.gmail.nossr50.datatypes.party.Party; import com.gmail.nossr50.datatypes.party.Party;
import com.gmail.nossr50.datatypes.party.PartyFeature; import com.gmail.nossr50.datatypes.party.PartyFeature;
import com.gmail.nossr50.datatypes.party.ShareMode; import com.gmail.nossr50.datatypes.party.ShareMode;
import com.gmail.nossr50.locale.LocaleLoader; import com.gmail.nossr50.locale.LocaleLoader;
import com.gmail.nossr50.util.StringUtils; import com.gmail.nossr50.mcMMO;
import com.gmail.nossr50.util.commands.CommandUtils; import com.gmail.nossr50.util.commands.CommandUtils;
import com.gmail.nossr50.util.player.UserManager; import com.gmail.nossr50.util.player.UserManager;
import com.gmail.nossr50.util.text.StringUtils;
import org.bukkit.command.Command; import org.bukkit.command.Command;
import org.bukkit.command.CommandExecutor; import org.bukkit.command.CommandExecutor;
import org.bukkit.command.CommandSender; import org.bukkit.command.CommandSender;
import org.bukkit.entity.Player; import org.bukkit.entity.Player;
import org.jetbrains.annotations.NotNull;
import java.util.Locale; import java.util.Locale;
public class PartyItemShareCommand implements CommandExecutor { public class PartyItemShareCommand implements CommandExecutor {
@Override @Override
public boolean onCommand(CommandSender sender, Command command, String label, String[] args) { public boolean onCommand(@NotNull CommandSender sender, @NotNull Command command, @NotNull String label, String[] args) {
if(UserManager.getPlayer((Player) sender) == null) if(UserManager.getPlayer((Player) sender) == null)
{ {
sender.sendMessage(LocaleLoader.getString("Profile.PendingLoad")); sender.sendMessage(LocaleLoader.getString("Profile.PendingLoad"));
@ -27,7 +28,7 @@ public class PartyItemShareCommand implements CommandExecutor {
Party party = UserManager.getPlayer((Player) sender).getParty(); Party party = UserManager.getPlayer((Player) sender).getParty();
if (party.getLevel() < Config.getInstance().getPartyFeatureUnlockLevel(PartyFeature.ITEM_SHARE)) { if (party.getLevel() < mcMMO.p.getGeneralConfig().getPartyFeatureUnlockLevel(PartyFeature.ITEM_SHARE)) {
sender.sendMessage(LocaleLoader.getString("Party.Feature.Disabled.4")); sender.sendMessage(LocaleLoader.getString("Party.Feature.Disabled.4"));
return true; return true;
} }

View File

@ -10,10 +10,11 @@ import org.bukkit.command.Command;
import org.bukkit.command.CommandExecutor; import org.bukkit.command.CommandExecutor;
import org.bukkit.command.CommandSender; import org.bukkit.command.CommandSender;
import org.bukkit.entity.Player; import org.bukkit.entity.Player;
import org.jetbrains.annotations.NotNull;
public class PartyJoinCommand implements CommandExecutor { public class PartyJoinCommand implements CommandExecutor {
@Override @Override
public boolean onCommand(CommandSender sender, Command command, String label, String[] args) { public boolean onCommand(@NotNull CommandSender sender, @NotNull Command command, @NotNull String label, String[] args) {
switch (args.length) { switch (args.length) {
case 2: case 2:
case 3: case 3:

View File

@ -12,46 +12,43 @@ import org.bukkit.command.Command;
import org.bukkit.command.CommandExecutor; import org.bukkit.command.CommandExecutor;
import org.bukkit.command.CommandSender; import org.bukkit.command.CommandSender;
import org.bukkit.entity.Player; import org.bukkit.entity.Player;
import org.jetbrains.annotations.NotNull;
public class PartyKickCommand implements CommandExecutor { public class PartyKickCommand implements CommandExecutor {
@Override @Override
public boolean onCommand(CommandSender sender, Command command, String label, String[] args) { public boolean onCommand(@NotNull CommandSender sender, @NotNull Command command, @NotNull String label, String[] args) {
switch (args.length) { if (args.length == 2) {
case 2: if (UserManager.getPlayer((Player) sender) == null) {
if(UserManager.getPlayer((Player) sender) == null) sender.sendMessage(LocaleLoader.getString("Profile.PendingLoad"));
{ return true;
sender.sendMessage(LocaleLoader.getString("Profile.PendingLoad")); }
Party playerParty = UserManager.getPlayer((Player) sender).getParty();
String targetName = CommandUtils.getMatchedPlayerName(args[1]);
if (!playerParty.hasMember(targetName)) {
sender.sendMessage(LocaleLoader.getString("Party.NotInYourParty", targetName));
return true;
}
OfflinePlayer target = mcMMO.p.getServer().getOfflinePlayer(targetName);
if (target.isOnline()) {
Player onlineTarget = target.getPlayer();
String partyName = playerParty.getName();
if (!PartyManager.handlePartyChangeEvent(onlineTarget, partyName, null, EventReason.KICKED_FROM_PARTY)) {
return true; return true;
} }
Party playerParty = UserManager.getPlayer((Player) sender).getParty(); PartyManager.processPartyLeaving(UserManager.getPlayer(onlineTarget));
String targetName = CommandUtils.getMatchedPlayerName(args[1]); onlineTarget.sendMessage(LocaleLoader.getString("Commands.Party.Kick", partyName));
}
if (!playerParty.hasMember(targetName)) { PartyManager.removeFromParty(target, playerParty);
sender.sendMessage(LocaleLoader.getString("Party.NotInYourParty", targetName)); return true;
return true;
}
OfflinePlayer target = mcMMO.p.getServer().getOfflinePlayer(targetName);
if (target.isOnline()) {
Player onlineTarget = target.getPlayer();
String partyName = playerParty.getName();
if (!PartyManager.handlePartyChangeEvent(onlineTarget, partyName, null, EventReason.KICKED_FROM_PARTY)) {
return true;
}
PartyManager.processPartyLeaving(UserManager.getPlayer(onlineTarget));
onlineTarget.sendMessage(LocaleLoader.getString("Commands.Party.Kick", partyName));
}
PartyManager.removeFromParty(target, playerParty);
return true;
default:
sender.sendMessage(LocaleLoader.getString("Commands.Usage.2", "party", "kick", "<" + LocaleLoader.getString("Commands.Usage.Player") + ">"));
return true;
} }
sender.sendMessage(LocaleLoader.getString("Commands.Usage.2", "party", "kick", "<" + LocaleLoader.getString("Commands.Usage.Player") + ">"));
return true;
} }
} }

View File

@ -9,10 +9,11 @@ import org.bukkit.command.Command;
import org.bukkit.command.CommandExecutor; import org.bukkit.command.CommandExecutor;
import org.bukkit.command.CommandSender; import org.bukkit.command.CommandSender;
import org.bukkit.entity.Player; import org.bukkit.entity.Player;
import org.jetbrains.annotations.NotNull;
public class PartyLockCommand implements CommandExecutor { public class PartyLockCommand implements CommandExecutor {
@Override @Override
public boolean onCommand(CommandSender sender, Command command, String label, String[] args) { public boolean onCommand(@NotNull CommandSender sender, @NotNull Command command, @NotNull String label, String[] args) {
switch (args.length) { switch (args.length) {
case 1: case 1:
if (args[0].equalsIgnoreCase("lock")) { if (args[0].equalsIgnoreCase("lock")) {
@ -67,7 +68,7 @@ public class PartyLockCommand implements CommandExecutor {
return; return;
} }
if (lock ? party.isLocked() : !party.isLocked()) { if (lock == party.isLocked()) {
sender.sendMessage(LocaleLoader.getString("Party." + (lock ? "IsLocked" : "IsntLocked"))); sender.sendMessage(LocaleLoader.getString("Party." + (lock ? "IsLocked" : "IsntLocked")));
return; return;
} }

View File

@ -10,34 +10,31 @@ import org.bukkit.command.Command;
import org.bukkit.command.CommandExecutor; import org.bukkit.command.CommandExecutor;
import org.bukkit.command.CommandSender; import org.bukkit.command.CommandSender;
import org.bukkit.entity.Player; import org.bukkit.entity.Player;
import org.jetbrains.annotations.NotNull;
public class PartyQuitCommand implements CommandExecutor { public class PartyQuitCommand implements CommandExecutor {
@Override @Override
public boolean onCommand(CommandSender sender, Command command, String label, String[] args) { public boolean onCommand(@NotNull CommandSender sender, @NotNull Command command, @NotNull String label, String[] args) {
switch (args.length) { if (args.length == 1) {
case 1: Player player = (Player) sender;
Player player = (Player) sender;
if(UserManager.getPlayer((Player) sender) == null) if (UserManager.getPlayer((Player) sender) == null) {
{ sender.sendMessage(LocaleLoader.getString("Profile.PendingLoad"));
sender.sendMessage(LocaleLoader.getString("Profile.PendingLoad"));
return true;
}
McMMOPlayer mcMMOPlayer = UserManager.getPlayer(player);
Party playerParty = mcMMOPlayer.getParty();
if (!PartyManager.handlePartyChangeEvent(player, playerParty.getName(), null, EventReason.LEFT_PARTY)) {
return true;
}
PartyManager.removeFromParty(mcMMOPlayer);
sender.sendMessage(LocaleLoader.getString("Commands.Party.Leave"));
return true; return true;
}
default: McMMOPlayer mcMMOPlayer = UserManager.getPlayer(player);
sender.sendMessage(LocaleLoader.getString("Commands.Usage.1", "party", "quit")); Party playerParty = mcMMOPlayer.getParty();
if (!PartyManager.handlePartyChangeEvent(player, playerParty.getName(), null, EventReason.LEFT_PARTY)) {
return true; return true;
}
PartyManager.removeFromParty(mcMMOPlayer);
sender.sendMessage(LocaleLoader.getString("Commands.Party.Leave"));
return true;
} }
sender.sendMessage(LocaleLoader.getString("Commands.Usage.1", "party", "quit"));
return true;
} }
} }

View File

@ -10,57 +10,54 @@ import org.bukkit.command.Command;
import org.bukkit.command.CommandExecutor; import org.bukkit.command.CommandExecutor;
import org.bukkit.command.CommandSender; import org.bukkit.command.CommandSender;
import org.bukkit.entity.Player; import org.bukkit.entity.Player;
import org.jetbrains.annotations.NotNull;
public class PartyRenameCommand implements CommandExecutor { public class PartyRenameCommand implements CommandExecutor {
@Override @Override
public boolean onCommand(CommandSender sender, Command command, String label, String[] args) { public boolean onCommand(@NotNull CommandSender sender, @NotNull Command command, @NotNull String label, String[] args) {
switch (args.length) { if (args.length == 2) {
case 2: if (UserManager.getPlayer((Player) sender) == null) {
if(UserManager.getPlayer((Player) sender) == null) sender.sendMessage(LocaleLoader.getString("Profile.PendingLoad"));
{
sender.sendMessage(LocaleLoader.getString("Profile.PendingLoad"));
return true;
}
McMMOPlayer mcMMOPlayer = UserManager.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(LocaleLoader.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 (PartyManager.checkPartyExistence(player, newPartyName)) {
return true;
}
String leaderName = playerParty.getLeader().getPlayerName();
for (Player member : playerParty.getOnlineMembers()) {
if (!PartyManager.handlePartyChangeEvent(member, oldPartyName, newPartyName, EventReason.CHANGED_PARTIES)) {
return true;
}
if (!member.getName().equalsIgnoreCase(leaderName)) {
member.sendMessage(LocaleLoader.getString("Party.InformedOnNameChange", leaderName, newPartyName));
}
}
playerParty.setName(newPartyName);
sender.sendMessage(LocaleLoader.getString("Commands.Party.Rename", newPartyName));
return true; return true;
}
default: McMMOPlayer mcMMOPlayer = UserManager.getPlayer((Player) sender);
sender.sendMessage(LocaleLoader.getString("Commands.Usage.2", "party", "rename", "<" + LocaleLoader.getString("Commands.Usage.PartyName") + ">")); 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(LocaleLoader.getString("Party.Rename.Same"));
return true; return true;
}
Player player = mcMMOPlayer.getPlayer();
// Check to see if the party exists, and if it does cancel renaming the party
if (PartyManager.checkPartyExistence(player, newPartyName)) {
return true;
}
String leaderName = playerParty.getLeader().getPlayerName();
for (Player member : playerParty.getOnlineMembers()) {
if (!PartyManager.handlePartyChangeEvent(member, oldPartyName, newPartyName, EventReason.CHANGED_PARTIES)) {
return true;
}
if (!member.getName().equalsIgnoreCase(leaderName)) {
member.sendMessage(LocaleLoader.getString("Party.InformedOnNameChange", leaderName, newPartyName));
}
}
playerParty.setName(newPartyName);
sender.sendMessage(LocaleLoader.getString("Commands.Party.Rename", newPartyName));
return true;
} }
sender.sendMessage(LocaleLoader.getString("Commands.Usage.2", "party", "rename", "<" + LocaleLoader.getString("Commands.Usage.PartyName") + ">"));
return true;
} }
} }

View File

@ -1,21 +1,22 @@
package com.gmail.nossr50.commands.party; package com.gmail.nossr50.commands.party;
import com.gmail.nossr50.config.Config;
import com.gmail.nossr50.datatypes.party.Party; import com.gmail.nossr50.datatypes.party.Party;
import com.gmail.nossr50.datatypes.party.PartyFeature; import com.gmail.nossr50.datatypes.party.PartyFeature;
import com.gmail.nossr50.datatypes.party.ShareMode; import com.gmail.nossr50.datatypes.party.ShareMode;
import com.gmail.nossr50.locale.LocaleLoader; import com.gmail.nossr50.locale.LocaleLoader;
import com.gmail.nossr50.util.StringUtils; import com.gmail.nossr50.mcMMO;
import com.gmail.nossr50.util.commands.CommandUtils; import com.gmail.nossr50.util.commands.CommandUtils;
import com.gmail.nossr50.util.player.UserManager; import com.gmail.nossr50.util.player.UserManager;
import com.gmail.nossr50.util.text.StringUtils;
import org.bukkit.command.Command; import org.bukkit.command.Command;
import org.bukkit.command.CommandExecutor; import org.bukkit.command.CommandExecutor;
import org.bukkit.command.CommandSender; import org.bukkit.command.CommandSender;
import org.bukkit.entity.Player; import org.bukkit.entity.Player;
import org.jetbrains.annotations.NotNull;
public class PartyXpShareCommand implements CommandExecutor { public class PartyXpShareCommand implements CommandExecutor {
@Override @Override
public boolean onCommand(CommandSender sender, Command command, String label, String[] args) { public boolean onCommand(@NotNull CommandSender sender, @NotNull Command command, @NotNull String label, String[] args) {
if(UserManager.getPlayer((Player) sender) == null) if(UserManager.getPlayer((Player) sender) == null)
{ {
sender.sendMessage(LocaleLoader.getString("Profile.PendingLoad")); sender.sendMessage(LocaleLoader.getString("Profile.PendingLoad"));
@ -24,29 +25,24 @@ public class PartyXpShareCommand implements CommandExecutor {
Party party = UserManager.getPlayer((Player) sender).getParty(); Party party = UserManager.getPlayer((Player) sender).getParty();
if (party.getLevel() < Config.getInstance().getPartyFeatureUnlockLevel(PartyFeature.XP_SHARE)) { if (party.getLevel() < mcMMO.p.getGeneralConfig().getPartyFeatureUnlockLevel(PartyFeature.XP_SHARE)) {
sender.sendMessage(LocaleLoader.getString("Party.Feature.Disabled.5")); sender.sendMessage(LocaleLoader.getString("Party.Feature.Disabled.5"));
return true; return true;
} }
switch (args.length) { if (args.length == 2) {
case 2: if (args[1].equalsIgnoreCase("none") || CommandUtils.shouldDisableToggle(args[1])) {
if (args[1].equalsIgnoreCase("none") || CommandUtils.shouldDisableToggle(args[1])) { handleChangingShareMode(party, ShareMode.NONE);
handleChangingShareMode(party, ShareMode.NONE); } else if (args[1].equalsIgnoreCase("equal") || args[1].equalsIgnoreCase("even") || CommandUtils.shouldEnableToggle(args[1])) {
} handleChangingShareMode(party, ShareMode.EQUAL);
else if (args[1].equalsIgnoreCase("equal") || args[1].equalsIgnoreCase("even") || CommandUtils.shouldEnableToggle(args[1])) { } else {
handleChangingShareMode(party, ShareMode.EQUAL);
}
else {
sender.sendMessage(LocaleLoader.getString("Commands.Usage.2", "party", "xpshare", "<NONE | EQUAL>"));
}
return true;
default:
sender.sendMessage(LocaleLoader.getString("Commands.Usage.2", "party", "xpshare", "<NONE | EQUAL>")); sender.sendMessage(LocaleLoader.getString("Commands.Usage.2", "party", "xpshare", "<NONE | EQUAL>"));
return true; }
return true;
} }
sender.sendMessage(LocaleLoader.getString("Commands.Usage.2", "party", "xpshare", "<NONE | EQUAL>"));
return true;
} }
private void handleChangingShareMode(Party party, ShareMode mode) { private void handleChangingShareMode(Party party, ShareMode mode) {

View File

@ -8,36 +8,33 @@ import org.bukkit.command.Command;
import org.bukkit.command.CommandExecutor; import org.bukkit.command.CommandExecutor;
import org.bukkit.command.CommandSender; import org.bukkit.command.CommandSender;
import org.bukkit.entity.Player; import org.bukkit.entity.Player;
import org.jetbrains.annotations.NotNull;
public class PartyAllianceAcceptCommand implements CommandExecutor { public class PartyAllianceAcceptCommand implements CommandExecutor {
@Override @Override
public boolean onCommand(CommandSender sender, Command command, String label, String[] args) { public boolean onCommand(@NotNull CommandSender sender, @NotNull Command command, @NotNull String label, String[] args) {
switch (args.length) { if (args.length == 2) {
case 2: if (UserManager.getPlayer((Player) sender) == null) {
if(UserManager.getPlayer((Player) sender) == null) sender.sendMessage(LocaleLoader.getString("Profile.PendingLoad"));
{
sender.sendMessage(LocaleLoader.getString("Profile.PendingLoad"));
return true;
}
Player player = (Player) sender;
McMMOPlayer mcMMOPlayer = UserManager.getPlayer(player);
if (!mcMMOPlayer.hasPartyAllianceInvite()) {
sender.sendMessage(LocaleLoader.getString("mcMMO.NoInvites"));
return true;
}
if (mcMMOPlayer.getParty().getAlly() != null) {
player.sendMessage(LocaleLoader.getString("Commands.Party.Alliance.AlreadyAllies"));
return true;
}
PartyManager.acceptAllianceInvite(mcMMOPlayer);
return true; return true;
}
Player player = (Player) sender;
McMMOPlayer mcMMOPlayer = UserManager.getPlayer(player);
default: if (!mcMMOPlayer.hasPartyAllianceInvite()) {
sender.sendMessage(LocaleLoader.getString("Commands.Usage.2", "party", "alliance", "accept")); sender.sendMessage(LocaleLoader.getString("mcMMO.NoInvites"));
return true; return true;
}
if (mcMMOPlayer.getParty().getAlly() != null) {
player.sendMessage(LocaleLoader.getString("Commands.Party.Alliance.AlreadyAllies"));
return true;
}
PartyManager.acceptAllianceInvite(mcMMOPlayer);
return true;
} }
sender.sendMessage(LocaleLoader.getString("Commands.Usage.2", "party", "alliance", "accept"));
return true;
} }
} }

View File

@ -1,10 +1,10 @@
package com.gmail.nossr50.commands.party.alliance; package com.gmail.nossr50.commands.party.alliance;
import com.gmail.nossr50.config.Config;
import com.gmail.nossr50.datatypes.party.Party; import com.gmail.nossr50.datatypes.party.Party;
import com.gmail.nossr50.datatypes.party.PartyFeature; import com.gmail.nossr50.datatypes.party.PartyFeature;
import com.gmail.nossr50.datatypes.player.McMMOPlayer; import com.gmail.nossr50.datatypes.player.McMMOPlayer;
import com.gmail.nossr50.locale.LocaleLoader; import com.gmail.nossr50.locale.LocaleLoader;
import com.gmail.nossr50.mcMMO;
import com.gmail.nossr50.party.PartyManager; import com.gmail.nossr50.party.PartyManager;
import com.gmail.nossr50.util.commands.CommandUtils; import com.gmail.nossr50.util.commands.CommandUtils;
import com.gmail.nossr50.util.player.UserManager; import com.gmail.nossr50.util.player.UserManager;
@ -16,6 +16,7 @@ import org.bukkit.command.CommandSender;
import org.bukkit.command.TabExecutor; import org.bukkit.command.TabExecutor;
import org.bukkit.entity.Player; import org.bukkit.entity.Player;
import org.bukkit.util.StringUtil; import org.bukkit.util.StringUtil;
import org.jetbrains.annotations.NotNull;
import java.util.ArrayList; import java.util.ArrayList;
import java.util.List; import java.util.List;
@ -27,12 +28,12 @@ public class PartyAllianceCommand implements TabExecutor {
public static final List<String> ALLIANCE_SUBCOMMANDS = ImmutableList.of("invite", "accept", "disband"); public static final List<String> ALLIANCE_SUBCOMMANDS = ImmutableList.of("invite", "accept", "disband");
private CommandExecutor partyAllianceInviteCommand = new PartyAllianceInviteCommand(); private final CommandExecutor partyAllianceInviteCommand = new PartyAllianceInviteCommand();
private CommandExecutor partyAllianceAcceptCommand = new PartyAllianceAcceptCommand(); private final CommandExecutor partyAllianceAcceptCommand = new PartyAllianceAcceptCommand();
private CommandExecutor partyAllianceDisbandCommand = new PartyAllianceDisbandCommand(); private final CommandExecutor partyAllianceDisbandCommand = new PartyAllianceDisbandCommand();
@Override @Override
public boolean onCommand(CommandSender sender, Command command, String label, String[] args) { public boolean onCommand(@NotNull CommandSender sender, @NotNull Command command, @NotNull String label, String[] args) {
if (CommandUtils.noConsoleUsage(sender)) { if (CommandUtils.noConsoleUsage(sender)) {
return true; return true;
} }
@ -50,7 +51,7 @@ public class PartyAllianceCommand implements TabExecutor {
switch (args.length) { switch (args.length) {
case 1: case 1:
if (playerParty.getLevel() < Config.getInstance().getPartyFeatureUnlockLevel(PartyFeature.ALLIANCE)) { if (playerParty.getLevel() < mcMMO.p.getGeneralConfig().getPartyFeatureUnlockLevel(PartyFeature.ALLIANCE)) {
sender.sendMessage(LocaleLoader.getString("Party.Feature.Disabled.3")); sender.sendMessage(LocaleLoader.getString("Party.Feature.Disabled.3"));
return true; return true;
} }
@ -68,7 +69,7 @@ public class PartyAllianceCommand implements TabExecutor {
case 2: case 2:
case 3: case 3:
if (playerParty.getLevel() < Config.getInstance().getPartyFeatureUnlockLevel(PartyFeature.ALLIANCE)) { if (playerParty.getLevel() < mcMMO.p.getGeneralConfig().getPartyFeatureUnlockLevel(PartyFeature.ALLIANCE)) {
sender.sendMessage(LocaleLoader.getString("Party.Feature.Disabled.3")); sender.sendMessage(LocaleLoader.getString("Party.Feature.Disabled.3"));
return true; return true;
} }
@ -108,20 +109,18 @@ public class PartyAllianceCommand implements TabExecutor {
} }
@Override @Override
public List<String> onTabComplete(CommandSender commandSender, Command command, String label, String[] args) { public List<String> onTabComplete(@NotNull CommandSender commandSender, @NotNull Command command, @NotNull String label, String[] args) {
switch (args.length) { if (args.length == 1) {
case 1: List<String> matches = StringUtil.copyPartialMatches(args[0], ALLIANCE_SUBCOMMANDS, new ArrayList<>(ALLIANCE_SUBCOMMANDS.size()));
List<String> matches = StringUtil.copyPartialMatches(args[0], ALLIANCE_SUBCOMMANDS, new ArrayList<String>(ALLIANCE_SUBCOMMANDS.size()));
if (matches.size() == 0) { if (matches.size() == 0) {
List<String> playerNames = CommandUtils.getOnlinePlayerNames(commandSender); List<String> playerNames = CommandUtils.getOnlinePlayerNames(commandSender);
return StringUtil.copyPartialMatches(args[0], playerNames, new ArrayList<String>(playerNames.size())); return StringUtil.copyPartialMatches(args[0], playerNames, new ArrayList<>(playerNames.size()));
} }
return matches; return matches;
default:
return ImmutableList.of();
} }
return ImmutableList.of();
} }
private void displayPartyHeader() { private void displayPartyHeader() {

View File

@ -9,32 +9,29 @@ import org.bukkit.command.Command;
import org.bukkit.command.CommandExecutor; import org.bukkit.command.CommandExecutor;
import org.bukkit.command.CommandSender; import org.bukkit.command.CommandSender;
import org.bukkit.entity.Player; import org.bukkit.entity.Player;
import org.jetbrains.annotations.NotNull;
public class PartyAllianceDisbandCommand implements CommandExecutor { public class PartyAllianceDisbandCommand implements CommandExecutor {
@Override @Override
public boolean onCommand(CommandSender sender, Command command, String label, String[] args) { public boolean onCommand(@NotNull CommandSender sender, @NotNull Command command, @NotNull String label, String[] args) {
switch (args.length) { if (args.length == 2) {
case 2: if (UserManager.getPlayer((Player) sender) == null) {
if(UserManager.getPlayer((Player) sender) == null) sender.sendMessage(LocaleLoader.getString("Profile.PendingLoad"));
{
sender.sendMessage(LocaleLoader.getString("Profile.PendingLoad"));
return true;
}
Player player = (Player) sender;
McMMOPlayer mcMMOPlayer = UserManager.getPlayer(player);
Party party = mcMMOPlayer.getParty();
if (party.getAlly() == null) {
sender.sendMessage(LocaleLoader.getString("Commands.Party.Alliance.None"));
return true;
}
PartyManager.disbandAlliance(player, party, party.getAlly());
return true; return true;
}
Player player = (Player) sender;
McMMOPlayer mcMMOPlayer = UserManager.getPlayer(player);
Party party = mcMMOPlayer.getParty();
default: if (party.getAlly() == null) {
sender.sendMessage(LocaleLoader.getString("Commands.Usage.2", "party", "alliance", "disband")); sender.sendMessage(LocaleLoader.getString("Commands.Party.Alliance.None"));
return true; return true;
}
PartyManager.disbandAlliance(player, party, party.getAlly());
return true;
} }
sender.sendMessage(LocaleLoader.getString("Commands.Usage.2", "party", "alliance", "disband"));
return true;
} }
} }

View File

@ -10,68 +10,65 @@ import org.bukkit.command.Command;
import org.bukkit.command.CommandExecutor; import org.bukkit.command.CommandExecutor;
import org.bukkit.command.CommandSender; import org.bukkit.command.CommandSender;
import org.bukkit.entity.Player; import org.bukkit.entity.Player;
import org.jetbrains.annotations.NotNull;
public class PartyAllianceInviteCommand implements CommandExecutor { public class PartyAllianceInviteCommand implements CommandExecutor {
@Override @Override
public boolean onCommand(CommandSender sender, Command command, String label, String[] args) { public boolean onCommand(@NotNull CommandSender sender, @NotNull Command command, @NotNull String label, String[] args) {
switch (args.length) { if (args.length == 3) {
case 3: String targetName = CommandUtils.getMatchedPlayerName(args[2]);
String targetName = CommandUtils.getMatchedPlayerName(args[2]); McMMOPlayer mcMMOTarget = UserManager.getOfflinePlayer(targetName);
McMMOPlayer mcMMOTarget = UserManager.getOfflinePlayer(targetName);
if (!CommandUtils.checkPlayerExistence(sender, targetName, mcMMOTarget)) { if (!CommandUtils.checkPlayerExistence(sender, targetName, mcMMOTarget)) {
return false; return false;
} }
Player target = mcMMOTarget.getPlayer(); Player target = mcMMOTarget.getPlayer();
if(UserManager.getPlayer((Player) sender) == null) if (UserManager.getPlayer((Player) sender) == null) {
{ sender.sendMessage(LocaleLoader.getString("Profile.PendingLoad"));
sender.sendMessage(LocaleLoader.getString("Profile.PendingLoad"));
return true;
}
Player player = (Player) sender;
McMMOPlayer mcMMOPlayer = UserManager.getPlayer(player);
String playerName = player.getName();
if (player.equals(target)) {
sender.sendMessage(LocaleLoader.getString("Party.Invite.Self"));
return true;
}
if (!mcMMOTarget.inParty()) {
player.sendMessage(LocaleLoader.getString("Party.PlayerNotInParty", targetName));
return true;
}
if (PartyManager.inSameParty(player, target)) {
sender.sendMessage(LocaleLoader.getString("Party.Player.InSameParty", targetName));
return true;
}
if (!mcMMOTarget.getParty().getLeader().getUniqueId().equals(target.getUniqueId())) {
player.sendMessage(LocaleLoader.getString("Party.Target.NotOwner", targetName));
return true;
}
Party playerParty = mcMMOPlayer.getParty();
if (playerParty.getAlly() != null) {
player.sendMessage(LocaleLoader.getString("Commands.Party.Alliance.AlreadyAllies"));
return true;
}
mcMMOTarget.setPartyAllianceInvite(playerParty);
sender.sendMessage(LocaleLoader.getString("Commands.Invite.Success"));
target.sendMessage(LocaleLoader.getString("Commands.Party.Alliance.Invite.0", playerParty.getName(), playerName));
target.sendMessage(LocaleLoader.getString("Commands.Party.Alliance.Invite.1"));
return true; return true;
}
default: Player player = (Player) sender;
sender.sendMessage(LocaleLoader.getString("Commands.Usage.3", "party", "alliance", "invite", "<" + LocaleLoader.getString("Commands.Usage.Player") + ">")); McMMOPlayer mcMMOPlayer = UserManager.getPlayer(player);
String playerName = player.getName();
if (player.equals(target)) {
sender.sendMessage(LocaleLoader.getString("Party.Invite.Self"));
return true; return true;
}
if (!mcMMOTarget.inParty()) {
player.sendMessage(LocaleLoader.getString("Party.PlayerNotInParty", targetName));
return true;
}
if (PartyManager.inSameParty(player, target)) {
sender.sendMessage(LocaleLoader.getString("Party.Player.InSameParty", targetName));
return true;
}
if (!mcMMOTarget.getParty().getLeader().getUniqueId().equals(target.getUniqueId())) {
player.sendMessage(LocaleLoader.getString("Party.Target.NotOwner", targetName));
return true;
}
Party playerParty = mcMMOPlayer.getParty();
if (playerParty.getAlly() != null) {
player.sendMessage(LocaleLoader.getString("Commands.Party.Alliance.AlreadyAllies"));
return true;
}
mcMMOTarget.setPartyAllianceInvite(playerParty);
sender.sendMessage(LocaleLoader.getString("Commands.Invite.Success"));
target.sendMessage(LocaleLoader.getString("Commands.Party.Alliance.Invite.0", playerParty.getName(), playerName));
target.sendMessage(LocaleLoader.getString("Commands.Party.Alliance.Invite.1"));
return true;
} }
sender.sendMessage(LocaleLoader.getString("Commands.Usage.3", "party", "alliance", "invite", "<" + LocaleLoader.getString("Commands.Usage.Player") + ">"));
return true;
} }
} }

View File

@ -7,10 +7,11 @@ import com.gmail.nossr50.util.player.UserManager;
import org.bukkit.command.Command; import org.bukkit.command.Command;
import org.bukkit.command.CommandExecutor; import org.bukkit.command.CommandExecutor;
import org.bukkit.command.CommandSender; import org.bukkit.command.CommandSender;
import org.jetbrains.annotations.NotNull;
public class PtpAcceptAnyCommand implements CommandExecutor { public class PtpAcceptAnyCommand implements CommandExecutor {
@Override @Override
public boolean onCommand(CommandSender sender, Command command, String label, String[] args) { public boolean onCommand(@NotNull CommandSender sender, @NotNull Command command, @NotNull String label, String[] args) {
if (!Permissions.partyTeleportAcceptAll(sender)) { if (!Permissions.partyTeleportAcceptAll(sender)) {
sender.sendMessage(command.getPermissionMessage()); sender.sendMessage(command.getPermissionMessage());
return true; return true;

View File

@ -1,8 +1,8 @@
package com.gmail.nossr50.commands.party.teleport; package com.gmail.nossr50.commands.party.teleport;
import com.gmail.nossr50.config.Config;
import com.gmail.nossr50.datatypes.party.PartyTeleportRecord; import com.gmail.nossr50.datatypes.party.PartyTeleportRecord;
import com.gmail.nossr50.locale.LocaleLoader; import com.gmail.nossr50.locale.LocaleLoader;
import com.gmail.nossr50.mcMMO;
import com.gmail.nossr50.util.Permissions; import com.gmail.nossr50.util.Permissions;
import com.gmail.nossr50.util.player.UserManager; import com.gmail.nossr50.util.player.UserManager;
import com.gmail.nossr50.util.skills.SkillUtils; import com.gmail.nossr50.util.skills.SkillUtils;
@ -11,10 +11,11 @@ import org.bukkit.command.Command;
import org.bukkit.command.CommandExecutor; import org.bukkit.command.CommandExecutor;
import org.bukkit.command.CommandSender; import org.bukkit.command.CommandSender;
import org.bukkit.entity.Player; import org.bukkit.entity.Player;
import org.jetbrains.annotations.NotNull;
public class PtpAcceptCommand implements CommandExecutor { public class PtpAcceptCommand implements CommandExecutor {
@Override @Override
public boolean onCommand(CommandSender sender, Command command, String label, String[] args) { public boolean onCommand(@NotNull CommandSender sender, @NotNull Command command, @NotNull String label, String[] args) {
if (!Permissions.partyTeleportAccept(sender)) { if (!Permissions.partyTeleportAccept(sender)) {
sender.sendMessage(command.getPermissionMessage()); sender.sendMessage(command.getPermissionMessage());
return true; return true;
@ -34,7 +35,7 @@ public class PtpAcceptCommand implements CommandExecutor {
return true; return true;
} }
if (SkillUtils.cooldownExpired(ptpRecord.getTimeout(), Config.getInstance().getPTPCommandTimeout())) { if (SkillUtils.cooldownExpired(ptpRecord.getTimeout(), mcMMO.p.getGeneralConfig().getPTPCommandTimeout())) {
ptpRecord.removeRequest(); ptpRecord.removeRequest();
player.sendMessage(LocaleLoader.getString("Commands.ptp.RequestExpired")); player.sendMessage(LocaleLoader.getString("Commands.ptp.RequestExpired"));
return true; return true;
@ -47,7 +48,7 @@ public class PtpAcceptCommand implements CommandExecutor {
return true; return true;
} }
if (Config.getInstance().getPTPCommandWorldPermissions()) { if (mcMMO.p.getGeneralConfig().getPTPCommandWorldPermissions()) {
World targetWorld = target.getWorld(); World targetWorld = target.getWorld();
World playerWorld = player.getWorld(); World playerWorld = player.getWorld();

View File

@ -1,6 +1,5 @@
package com.gmail.nossr50.commands.party.teleport; package com.gmail.nossr50.commands.party.teleport;
import com.gmail.nossr50.config.Config;
import com.gmail.nossr50.config.WorldBlacklist; import com.gmail.nossr50.config.WorldBlacklist;
import com.gmail.nossr50.datatypes.party.Party; import com.gmail.nossr50.datatypes.party.Party;
import com.gmail.nossr50.datatypes.party.PartyFeature; import com.gmail.nossr50.datatypes.party.PartyFeature;
@ -26,6 +25,7 @@ import org.bukkit.command.CommandSender;
import org.bukkit.command.TabExecutor; import org.bukkit.command.TabExecutor;
import org.bukkit.entity.Player; import org.bukkit.entity.Player;
import org.bukkit.util.StringUtil; import org.bukkit.util.StringUtil;
import org.jetbrains.annotations.NotNull;
import java.util.ArrayList; import java.util.ArrayList;
import java.util.List; import java.util.List;
@ -33,12 +33,12 @@ import java.util.List;
public class PtpCommand implements TabExecutor { public class PtpCommand implements TabExecutor {
public static final List<String> TELEPORT_SUBCOMMANDS = ImmutableList.of("toggle", "accept", "acceptany", "acceptall"); public static final List<String> TELEPORT_SUBCOMMANDS = ImmutableList.of("toggle", "accept", "acceptany", "acceptall");
private CommandExecutor ptpToggleCommand = new PtpToggleCommand(); private final CommandExecutor ptpToggleCommand = new PtpToggleCommand();
private CommandExecutor ptpAcceptAnyCommand = new PtpAcceptAnyCommand(); private final CommandExecutor ptpAcceptAnyCommand = new PtpAcceptAnyCommand();
private CommandExecutor ptpAcceptCommand = new PtpAcceptCommand(); private final CommandExecutor ptpAcceptCommand = new PtpAcceptCommand();
@Override @Override
public boolean onCommand(CommandSender sender, Command command, String label, String[] args) { public boolean onCommand(@NotNull CommandSender sender, @NotNull Command command, @NotNull String label, String[] args) {
if (CommandUtils.noConsoleUsage(sender)) { if (CommandUtils.noConsoleUsage(sender)) {
return true; return true;
} }
@ -75,90 +75,84 @@ public class PtpCommand implements TabExecutor {
Party party = mcMMOPlayer.getParty(); Party party = mcMMOPlayer.getParty();
if (party.getLevel() < Config.getInstance().getPartyFeatureUnlockLevel(PartyFeature.TELEPORT)) { if (party.getLevel() < mcMMO.p.getGeneralConfig().getPartyFeatureUnlockLevel(PartyFeature.TELEPORT)) {
sender.sendMessage(LocaleLoader.getString("Party.Feature.Disabled.2")); sender.sendMessage(LocaleLoader.getString("Party.Feature.Disabled.2"));
return true; return true;
} }
switch (args.length) { if (args.length == 1) {
case 1: if (args[0].equalsIgnoreCase("toggle")) {
if (args[0].equalsIgnoreCase("toggle")) { return ptpToggleCommand.onCommand(sender, command, label, args);
return ptpToggleCommand.onCommand(sender, command, label, args); }
}
if (args[0].equalsIgnoreCase("acceptany") || args[0].equalsIgnoreCase("acceptall")) { if (args[0].equalsIgnoreCase("acceptany") || args[0].equalsIgnoreCase("acceptall")) {
return ptpAcceptAnyCommand.onCommand(sender, command, label, args); return ptpAcceptAnyCommand.onCommand(sender, command, label, args);
} }
long recentlyHurt = mcMMOPlayer.getRecentlyHurt(); long recentlyHurt = mcMMOPlayer.getRecentlyHurt();
int hurtCooldown = Config.getInstance().getPTPCommandRecentlyHurtCooldown(); int hurtCooldown = mcMMO.p.getGeneralConfig().getPTPCommandRecentlyHurtCooldown();
if (hurtCooldown > 0) { if (hurtCooldown > 0) {
int timeRemaining = SkillUtils.calculateTimeLeft(recentlyHurt * Misc.TIME_CONVERSION_FACTOR, hurtCooldown, player); int timeRemaining = SkillUtils.calculateTimeLeft(recentlyHurt * Misc.TIME_CONVERSION_FACTOR, hurtCooldown, player);
if (timeRemaining > 0) { if (timeRemaining > 0) {
player.sendMessage(LocaleLoader.getString("Item.Injured.Wait", timeRemaining)); player.sendMessage(LocaleLoader.getString("Item.Injured.Wait", timeRemaining));
return true;
}
}
if (args[0].equalsIgnoreCase("accept")) {
return ptpAcceptCommand.onCommand(sender, command, label, args);
}
if (!Permissions.partyTeleportSend(sender)) {
sender.sendMessage(command.getPermissionMessage());
return true; return true;
} }
}
int ptpCooldown = Config.getInstance().getPTPCommandCooldown(); if (args[0].equalsIgnoreCase("accept")) {
long ptpLastUse = mcMMOPlayer.getPartyTeleportRecord().getLastUse(); return ptpAcceptCommand.onCommand(sender, command, label, args);
}
if (ptpCooldown > 0) { if (!Permissions.partyTeleportSend(sender)) {
int timeRemaining = SkillUtils.calculateTimeLeft(ptpLastUse * Misc.TIME_CONVERSION_FACTOR, ptpCooldown, player); sender.sendMessage(command.getPermissionMessage());
if (timeRemaining > 0) {
player.sendMessage(LocaleLoader.getString("Item.Generic.Wait", timeRemaining));
return true;
}
}
sendTeleportRequest(sender, player, CommandUtils.getMatchedPlayerName(args[0]));
return true; return true;
}
default: int ptpCooldown = mcMMO.p.getGeneralConfig().getPTPCommandCooldown();
return false; long ptpLastUse = mcMMOPlayer.getPartyTeleportRecord().getLastUse();
if (ptpCooldown > 0) {
int timeRemaining = SkillUtils.calculateTimeLeft(ptpLastUse * Misc.TIME_CONVERSION_FACTOR, ptpCooldown, player);
if (timeRemaining > 0) {
player.sendMessage(LocaleLoader.getString("Item.Generic.Wait", timeRemaining));
return true;
}
}
sendTeleportRequest(sender, player, CommandUtils.getMatchedPlayerName(args[0]));
return true;
} }
return false;
} }
@Override @Override
public List<String> onTabComplete(CommandSender sender, Command command, String alias, String[] args) { public List<String> onTabComplete(@NotNull CommandSender sender, @NotNull Command command, @NotNull String alias, String[] args) {
switch (args.length) { if (args.length == 1) {
case 1: List<String> matches = StringUtil.copyPartialMatches(args[0], TELEPORT_SUBCOMMANDS, new ArrayList<>(TELEPORT_SUBCOMMANDS.size()));
List<String> matches = StringUtil.copyPartialMatches(args[0], TELEPORT_SUBCOMMANDS, new ArrayList<String>(TELEPORT_SUBCOMMANDS.size()));
if (matches.size() == 0) { if (matches.size() == 0) {
if(UserManager.getPlayer((Player) sender) == null) if (UserManager.getPlayer((Player) sender) == null) {
{ sender.sendMessage(LocaleLoader.getString("Profile.PendingLoad"));
sender.sendMessage(LocaleLoader.getString("Profile.PendingLoad")); return ImmutableList.of();
return ImmutableList.of();
}
Player player = (Player) sender;
McMMOPlayer mcMMOPlayer = UserManager.getPlayer(player);
if (!mcMMOPlayer.inParty()) {
return ImmutableList.of();
}
List<String> playerNames = mcMMOPlayer.getParty().getOnlinePlayerNames(player);
return StringUtil.copyPartialMatches(args[0], playerNames, new ArrayList<String>(playerNames.size()));
} }
return matches; Player player = (Player) sender;
default: McMMOPlayer mcMMOPlayer = UserManager.getPlayer(player);
return ImmutableList.of();
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;
} }
return ImmutableList.of();
} }
private void sendTeleportRequest(CommandSender sender, Player player, String targetName) { private void sendTeleportRequest(CommandSender sender, Player player, String targetName) {
@ -170,7 +164,7 @@ public class PtpCommand implements TabExecutor {
Player target = mcMMOTarget.getPlayer(); Player target = mcMMOTarget.getPlayer();
if (Config.getInstance().getPTPCommandWorldPermissions()) { if (mcMMO.p.getGeneralConfig().getPTPCommandWorldPermissions()) {
World targetWorld = target.getWorld(); World targetWorld = target.getWorld();
World playerWorld = player.getWorld(); World playerWorld = player.getWorld();
@ -199,7 +193,7 @@ public class PtpCommand implements TabExecutor {
player.sendMessage(LocaleLoader.getString("Commands.Invite.Success")); player.sendMessage(LocaleLoader.getString("Commands.Invite.Success"));
target.sendMessage(LocaleLoader.getString("Commands.ptp.Request1", player.getName())); target.sendMessage(LocaleLoader.getString("Commands.ptp.Request1", player.getName()));
target.sendMessage(LocaleLoader.getString("Commands.ptp.Request2", Config.getInstance().getPTPCommandTimeout())); target.sendMessage(LocaleLoader.getString("Commands.ptp.Request2", mcMMO.p.getGeneralConfig().getPTPCommandTimeout()));
} }
protected static boolean canTeleport(CommandSender sender, Player player, String targetName) { protected static boolean canTeleport(CommandSender sender, Player player, String targetName) {
@ -250,7 +244,7 @@ public class PtpCommand implements TabExecutor {
McMMOPlayer mcMMOPlayer = UserManager.getPlayer(teleportingPlayer); McMMOPlayer mcMMOPlayer = UserManager.getPlayer(teleportingPlayer);
McMMOPlayer mcMMOTarget = UserManager.getPlayer(targetPlayer); McMMOPlayer mcMMOTarget = UserManager.getPlayer(targetPlayer);
long warmup = Config.getInstance().getPTPCommandWarmup(); long warmup = mcMMO.p.getGeneralConfig().getPTPCommandWarmup();
mcMMOPlayer.actualizeTeleportCommenceLocation(teleportingPlayer); mcMMOPlayer.actualizeTeleportCommenceLocation(teleportingPlayer);

View File

@ -7,10 +7,11 @@ import com.gmail.nossr50.util.player.UserManager;
import org.bukkit.command.Command; import org.bukkit.command.Command;
import org.bukkit.command.CommandExecutor; import org.bukkit.command.CommandExecutor;
import org.bukkit.command.CommandSender; import org.bukkit.command.CommandSender;
import org.jetbrains.annotations.NotNull;
public class PtpToggleCommand implements CommandExecutor { public class PtpToggleCommand implements CommandExecutor {
@Override @Override
public boolean onCommand(CommandSender sender, Command command, String label, String[] args) { public boolean onCommand(@NotNull CommandSender sender, @NotNull Command command, @NotNull String label, String[] args) {
if (!Permissions.partyTeleportToggle(sender)) { if (!Permissions.partyTeleportToggle(sender)) {
sender.sendMessage(command.getPermissionMessage()); sender.sendMessage(command.getPermissionMessage());
return true; return true;

View File

@ -1,6 +1,5 @@
package com.gmail.nossr50.commands.player; package com.gmail.nossr50.commands.player;
import com.gmail.nossr50.config.Config;
import com.gmail.nossr50.datatypes.player.McMMOPlayer; import com.gmail.nossr50.datatypes.player.McMMOPlayer;
import com.gmail.nossr50.datatypes.player.PlayerProfile; import com.gmail.nossr50.datatypes.player.PlayerProfile;
import com.gmail.nossr50.datatypes.skills.PrimarySkillType; import com.gmail.nossr50.datatypes.skills.PrimarySkillType;
@ -16,93 +15,94 @@ import org.bukkit.command.CommandSender;
import org.bukkit.command.TabExecutor; import org.bukkit.command.TabExecutor;
import org.bukkit.entity.Player; import org.bukkit.entity.Player;
import org.bukkit.util.StringUtil; import org.bukkit.util.StringUtil;
import org.jetbrains.annotations.NotNull;
import java.util.ArrayList; import java.util.ArrayList;
import java.util.List; import java.util.List;
public class InspectCommand implements TabExecutor { public class InspectCommand implements TabExecutor {
@Override @Override
public boolean onCommand(CommandSender sender, Command command, String label, String[] args) { public boolean onCommand(@NotNull CommandSender sender, @NotNull Command command, @NotNull String label, String[] args) {
switch (args.length) { if (args.length == 1) {
case 1: String playerName = CommandUtils.getMatchedPlayerName(args[0]);
String playerName = CommandUtils.getMatchedPlayerName(args[0]); McMMOPlayer mcMMOPlayer = UserManager.getOfflinePlayer(playerName);
McMMOPlayer mcMMOPlayer = UserManager.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 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) { if (mcMMOPlayer == null) {
PlayerProfile profile = mcMMO.getDatabaseManager().loadPlayerProfile(playerName, false); // Temporary Profile PlayerProfile profile = mcMMO.getDatabaseManager().loadPlayerProfile(playerName); // Temporary Profile
if (!CommandUtils.isLoaded(sender, profile)) { if (!CommandUtils.isLoaded(sender, profile)) {
return true; return true;
}
if (Config.getInstance().getScoreboardsEnabled() && sender instanceof Player && Config.getInstance().getInspectUseBoard()) {
ScoreboardManager.enablePlayerInspectScoreboard((Player) sender, profile);
if (!Config.getInstance().getInspectUseChat()) {
return true;
}
}
sender.sendMessage(LocaleLoader.getString("Inspect.OfflineStats", playerName));
sender.sendMessage(LocaleLoader.getString("Stats.Header.Gathering"));
for (PrimarySkillType skill : PrimarySkillType.GATHERING_SKILLS) {
sender.sendMessage(CommandUtils.displaySkill(profile, skill));
}
sender.sendMessage(LocaleLoader.getString("Stats.Header.Combat"));
for (PrimarySkillType skill : PrimarySkillType.COMBAT_SKILLS) {
sender.sendMessage(CommandUtils.displaySkill(profile, skill));
}
sender.sendMessage(LocaleLoader.getString("Stats.Header.Misc"));
for (PrimarySkillType skill : PrimarySkillType.MISC_SKILLS) {
sender.sendMessage(CommandUtils.displaySkill(profile, skill));
}
}
else {
Player target = mcMMOPlayer.getPlayer();
if (CommandUtils.hidden(sender, target, Permissions.inspectHidden(sender))) {
sender.sendMessage(LocaleLoader.getString("Inspect.Offline"));
return true;
}
else if (CommandUtils.tooFar(sender, target, Permissions.inspectFar(sender))) {
return true;
}
if (Config.getInstance().getScoreboardsEnabled() && sender instanceof Player && Config.getInstance().getInspectUseBoard()) {
ScoreboardManager.enablePlayerInspectScoreboard((Player) sender, mcMMOPlayer.getProfile());
if (!Config.getInstance().getInspectUseChat()) {
return true;
}
}
sender.sendMessage(LocaleLoader.getString("Inspect.Stats", target.getName()));
CommandUtils.printGatheringSkills(target, sender);
CommandUtils.printCombatSkills(target, sender);
CommandUtils.printMiscSkills(target, sender);
sender.sendMessage(LocaleLoader.getString("Commands.PowerLevel", mcMMOPlayer.getPowerLevel()));
} }
return true; if (mcMMO.p.getGeneralConfig().getScoreboardsEnabled()
&& sender instanceof Player
&& mcMMO.p.getGeneralConfig().getInspectUseBoard()) {
ScoreboardManager.enablePlayerInspectScoreboard((Player) sender, profile);
default: if (!mcMMO.p.getGeneralConfig().getInspectUseChat()) {
return false; return true;
}
}
sender.sendMessage(LocaleLoader.getString("Inspect.OfflineStats", playerName));
sender.sendMessage(LocaleLoader.getString("Stats.Header.Gathering"));
for (PrimarySkillType skill : mcMMO.p.getSkillTools().GATHERING_SKILLS) {
sender.sendMessage(CommandUtils.displaySkill(profile, skill));
}
sender.sendMessage(LocaleLoader.getString("Stats.Header.Combat"));
for (PrimarySkillType skill : mcMMO.p.getSkillTools().COMBAT_SKILLS) {
sender.sendMessage(CommandUtils.displaySkill(profile, skill));
}
sender.sendMessage(LocaleLoader.getString("Stats.Header.Misc"));
for (PrimarySkillType skill : mcMMO.p.getSkillTools().MISC_SKILLS) {
sender.sendMessage(CommandUtils.displaySkill(profile, skill));
}
} else {
Player target = mcMMOPlayer.getPlayer();
boolean isVanished = false;
if (CommandUtils.hidden(sender, target, Permissions.inspectHidden(sender))) {
isVanished = true;
}
//Only distance check players who are online and not vanished
if (!isVanished && CommandUtils.tooFar(sender, target, Permissions.inspectFar(sender))) {
return true;
}
if (mcMMO.p.getGeneralConfig().getScoreboardsEnabled()
&& sender instanceof Player
&& mcMMO.p.getGeneralConfig().getInspectUseBoard()) {
ScoreboardManager.enablePlayerInspectScoreboard((Player) sender, mcMMOPlayer);
if (!mcMMO.p.getGeneralConfig().getInspectUseChat()) {
return true;
}
}
sender.sendMessage(LocaleLoader.getString("Inspect.Stats", target.getName()));
CommandUtils.printGatheringSkills(target, sender);
CommandUtils.printCombatSkills(target, sender);
CommandUtils.printMiscSkills(target, sender);
sender.sendMessage(LocaleLoader.getString("Commands.PowerLevel", mcMMOPlayer.getPowerLevel()));
}
return true;
} }
return false;
} }
@Override @Override
public List<String> onTabComplete(CommandSender sender, Command command, String alias, String[] args) { public List<String> onTabComplete(@NotNull CommandSender sender, @NotNull Command command, @NotNull String alias, String[] args) {
switch (args.length) { if (args.length == 1) {
case 1: List<String> playerNames = CommandUtils.getOnlinePlayerNames(sender);
List<String> playerNames = CommandUtils.getOnlinePlayerNames(sender); return StringUtil.copyPartialMatches(args[0], playerNames, new ArrayList<>(playerNames.size()));
return StringUtil.copyPartialMatches(args[0], playerNames, new ArrayList<String>(playerNames.size()));
default:
return ImmutableList.of();
} }
return ImmutableList.of();
} }
} }

View File

@ -1,9 +1,9 @@
package com.gmail.nossr50.commands.player; package com.gmail.nossr50.commands.player;
import com.gmail.nossr50.config.Config;
import com.gmail.nossr50.datatypes.player.McMMOPlayer; import com.gmail.nossr50.datatypes.player.McMMOPlayer;
import com.gmail.nossr50.datatypes.skills.SuperAbilityType; import com.gmail.nossr50.datatypes.skills.SuperAbilityType;
import com.gmail.nossr50.locale.LocaleLoader; import com.gmail.nossr50.locale.LocaleLoader;
import com.gmail.nossr50.mcMMO;
import com.gmail.nossr50.util.commands.CommandUtils; import com.gmail.nossr50.util.commands.CommandUtils;
import com.gmail.nossr50.util.player.UserManager; import com.gmail.nossr50.util.player.UserManager;
import com.gmail.nossr50.util.scoreboards.ScoreboardManager; import com.gmail.nossr50.util.scoreboards.ScoreboardManager;
@ -12,12 +12,13 @@ import org.bukkit.command.Command;
import org.bukkit.command.CommandSender; import org.bukkit.command.CommandSender;
import org.bukkit.command.TabExecutor; import org.bukkit.command.TabExecutor;
import org.bukkit.entity.Player; import org.bukkit.entity.Player;
import org.jetbrains.annotations.NotNull;
import java.util.List; import java.util.List;
public class MccooldownCommand implements TabExecutor { public class MccooldownCommand implements TabExecutor {
@Override @Override
public boolean onCommand(CommandSender sender, Command command, String label, String[] args) { public boolean onCommand(@NotNull CommandSender sender, @NotNull Command command, @NotNull String label, String[] args) {
if (CommandUtils.noConsoleUsage(sender)) { if (CommandUtils.noConsoleUsage(sender)) {
return true; return true;
} }
@ -26,53 +27,48 @@ public class MccooldownCommand implements TabExecutor {
return true; return true;
} }
switch (args.length) { if (args.length == 0) {
case 0: Player player = (Player) sender;
Player player = (Player) sender;
if (Config.getInstance().getScoreboardsEnabled() && Config.getInstance().getCooldownUseBoard()) { if (mcMMO.p.getGeneralConfig().getScoreboardsEnabled() && mcMMO.p.getGeneralConfig().getCooldownUseBoard()) {
ScoreboardManager.enablePlayerCooldownScoreboard(player); ScoreboardManager.enablePlayerCooldownScoreboard(player);
if (!Config.getInstance().getCooldownUseChat()) { if (!mcMMO.p.getGeneralConfig().getCooldownUseChat()) {
return true;
}
}
if(UserManager.getPlayer(player) == null)
{
player.sendMessage(LocaleLoader.getString("Profile.PendingLoad"));
return true; return true;
} }
}
McMMOPlayer mcMMOPlayer = UserManager.getPlayer(player); if (UserManager.getPlayer(player) == null) {
player.sendMessage(LocaleLoader.getString("Profile.PendingLoad"));
return true;
}
player.sendMessage(LocaleLoader.getString("Commands.Cooldowns.Header")); McMMOPlayer mcMMOPlayer = UserManager.getPlayer(player);
player.sendMessage(LocaleLoader.getString("mcMMO.NoSkillNote"));
for (SuperAbilityType ability : SuperAbilityType.values()) { player.sendMessage(LocaleLoader.getString("Commands.Cooldowns.Header"));
if (!ability.getPermissions(player)) { player.sendMessage(LocaleLoader.getString("mcMMO.NoSkillNote"));
continue;
}
int seconds = mcMMOPlayer.calculateTimeRemaining(ability); for (SuperAbilityType ability : SuperAbilityType.values()) {
if (!ability.getPermissions(player)) {
if (seconds <= 0) { continue;
player.sendMessage(LocaleLoader.getString("Commands.Cooldowns.Row.Y", ability.getName()));
}
else {
player.sendMessage(LocaleLoader.getString("Commands.Cooldowns.Row.N", ability.getName(), seconds));
}
} }
return true; int seconds = mcMMOPlayer.calculateTimeRemaining(ability);
default: if (seconds <= 0) {
return false; player.sendMessage(LocaleLoader.getString("Commands.Cooldowns.Row.Y", ability.getLocalizedName()));
} else {
player.sendMessage(LocaleLoader.getString("Commands.Cooldowns.Row.N", ability.getLocalizedName(), seconds));
}
}
return true;
} }
return false;
} }
@Override @Override
public List<String> onTabComplete(CommandSender sender, Command command, String alias, String[] args) { public List<String> onTabComplete(@NotNull CommandSender sender, @NotNull Command command, @NotNull String alias, String[] args) {
return ImmutableList.of(); return ImmutableList.of();
} }
} }

View File

@ -1,10 +1,10 @@
package com.gmail.nossr50.commands.player; package com.gmail.nossr50.commands.player;
import com.gmail.nossr50.config.Config;
import com.gmail.nossr50.datatypes.player.McMMOPlayer; import com.gmail.nossr50.datatypes.player.McMMOPlayer;
import com.gmail.nossr50.locale.LocaleLoader; import com.gmail.nossr50.locale.LocaleLoader;
import com.gmail.nossr50.mcMMO; import com.gmail.nossr50.mcMMO;
import com.gmail.nossr50.runnables.commands.McrankCommandAsyncTask; import com.gmail.nossr50.runnables.commands.McrankCommandAsyncTask;
import com.gmail.nossr50.util.MetadataConstants;
import com.gmail.nossr50.util.Permissions; import com.gmail.nossr50.util.Permissions;
import com.gmail.nossr50.util.commands.CommandUtils; import com.gmail.nossr50.util.commands.CommandUtils;
import com.gmail.nossr50.util.player.UserManager; import com.gmail.nossr50.util.player.UserManager;
@ -15,13 +15,14 @@ import org.bukkit.command.TabExecutor;
import org.bukkit.entity.Player; import org.bukkit.entity.Player;
import org.bukkit.metadata.FixedMetadataValue; import org.bukkit.metadata.FixedMetadataValue;
import org.bukkit.util.StringUtil; import org.bukkit.util.StringUtil;
import org.jetbrains.annotations.NotNull;
import java.util.ArrayList; import java.util.ArrayList;
import java.util.List; import java.util.List;
public class McrankCommand implements TabExecutor { public class McrankCommand implements TabExecutor {
@Override @Override
public boolean onCommand(CommandSender sender, Command command, String label, String[] args) { public boolean onCommand(@NotNull CommandSender sender, @NotNull Command command, @NotNull String label, String[] args) {
switch (args.length) { switch (args.length) {
case 0: case 0:
if (CommandUtils.noConsoleUsage(sender)) { if (CommandUtils.noConsoleUsage(sender)) {
@ -72,14 +73,12 @@ public class McrankCommand implements TabExecutor {
} }
@Override @Override
public List<String> onTabComplete(CommandSender sender, Command command, String alias, String[] args) { public List<String> onTabComplete(@NotNull CommandSender sender, @NotNull Command command, @NotNull String alias, String[] args) {
switch (args.length) { if (args.length == 1) {
case 1: List<String> playerNames = CommandUtils.getOnlinePlayerNames(sender);
List<String> playerNames = CommandUtils.getOnlinePlayerNames(sender); return StringUtil.copyPartialMatches(args[0], playerNames, new ArrayList<>(playerNames.size()));
return StringUtil.copyPartialMatches(args[0], playerNames, new ArrayList<String>(playerNames.size()));
default:
return ImmutableList.of();
} }
return ImmutableList.of();
} }
private void display(CommandSender sender, String playerName) { private void display(CommandSender sender, String playerName) {
@ -92,25 +91,25 @@ public class McrankCommand implements TabExecutor {
return; return;
} }
long cooldownMillis = Math.min(Config.getInstance().getDatabasePlayerCooldown(), 1750); long cooldownMillis = Math.min(mcMMO.p.getGeneralConfig().getDatabasePlayerCooldown(), 1750);
if (mcMMOPlayer.getDatabaseATS() + cooldownMillis > System.currentTimeMillis()) { if (mcMMOPlayer.getDatabaseATS() + cooldownMillis > System.currentTimeMillis()) {
sender.sendMessage(LocaleLoader.getString("Commands.Database.CooldownMS", getCDSeconds(mcMMOPlayer, cooldownMillis))); sender.sendMessage(LocaleLoader.getString("Commands.Database.CooldownMS", getCDSeconds(mcMMOPlayer, cooldownMillis)));
return; return;
} }
if (((Player) sender).hasMetadata(mcMMO.databaseCommandKey)) { if (((Player) sender).hasMetadata(MetadataConstants.METADATA_KEY_DATABASE_COMMAND)) {
sender.sendMessage(LocaleLoader.getString("Commands.Database.Processing")); sender.sendMessage(LocaleLoader.getString("Commands.Database.Processing"));
return; return;
} else { } else {
((Player) sender).setMetadata(mcMMO.databaseCommandKey, new FixedMetadataValue(mcMMO.p, null)); ((Player) sender).setMetadata(MetadataConstants.METADATA_KEY_DATABASE_COMMAND, new FixedMetadataValue(mcMMO.p, null));
} }
mcMMOPlayer.actualizeDatabaseATS(); mcMMOPlayer.actualizeDatabaseATS();
} }
boolean useBoard = Config.getInstance().getScoreboardsEnabled() && (sender instanceof Player) && (Config.getInstance().getRankUseBoard()); boolean useBoard = mcMMO.p.getGeneralConfig().getScoreboardsEnabled() && (sender instanceof Player) && (mcMMO.p.getGeneralConfig().getRankUseBoard());
boolean useChat = !useBoard || Config.getInstance().getRankUseChat(); boolean useChat = !useBoard || mcMMO.p.getGeneralConfig().getRankUseChat();
new McrankCommandAsyncTask(playerName, sender, useBoard, useChat).runTaskAsynchronously(mcMMO.p); new McrankCommandAsyncTask(playerName, sender, useBoard, useChat).runTaskAsynchronously(mcMMO.p);
} }

View File

@ -1,7 +1,7 @@
package com.gmail.nossr50.commands.player; package com.gmail.nossr50.commands.player;
import com.gmail.nossr50.config.Config;
import com.gmail.nossr50.locale.LocaleLoader; import com.gmail.nossr50.locale.LocaleLoader;
import com.gmail.nossr50.mcMMO;
import com.gmail.nossr50.util.commands.CommandUtils; import com.gmail.nossr50.util.commands.CommandUtils;
import com.gmail.nossr50.util.player.UserManager; import com.gmail.nossr50.util.player.UserManager;
import com.gmail.nossr50.util.scoreboards.ScoreboardManager; import com.gmail.nossr50.util.scoreboards.ScoreboardManager;
@ -10,12 +10,13 @@ import org.bukkit.command.Command;
import org.bukkit.command.CommandSender; import org.bukkit.command.CommandSender;
import org.bukkit.command.TabExecutor; import org.bukkit.command.TabExecutor;
import org.bukkit.entity.Player; import org.bukkit.entity.Player;
import org.jetbrains.annotations.NotNull;
import java.util.List; import java.util.List;
public class McstatsCommand implements TabExecutor { public class McstatsCommand implements TabExecutor {
@Override @Override
public boolean onCommand(CommandSender sender, Command command, String label, String[] args) { public boolean onCommand(@NotNull CommandSender sender, @NotNull Command command, @NotNull String label, String[] args) {
if (CommandUtils.noConsoleUsage(sender)) { if (CommandUtils.noConsoleUsage(sender)) {
return true; return true;
} }
@ -24,49 +25,44 @@ public class McstatsCommand implements TabExecutor {
return true; return true;
} }
switch (args.length) { if (args.length == 0) {
case 0: if (UserManager.getPlayer((Player) sender) == null) {
if(UserManager.getPlayer((Player) sender) == null) sender.sendMessage(LocaleLoader.getString("Profile.PendingLoad"));
{ return true;
sender.sendMessage(LocaleLoader.getString("Profile.PendingLoad")); }
Player player = (Player) sender;
if (mcMMO.p.getGeneralConfig().getStatsUseBoard() && mcMMO.p.getGeneralConfig().getScoreboardsEnabled()) {
ScoreboardManager.enablePlayerStatsScoreboard(player);
if (!mcMMO.p.getGeneralConfig().getStatsUseChat()) {
return true; return true;
} }
}
Player player = (Player) sender; player.sendMessage(LocaleLoader.getString("Stats.Own.Stats"));
player.sendMessage(LocaleLoader.getString("mcMMO.NoSkillNote"));
if (Config.getInstance().getStatsUseBoard() && Config.getInstance().getScoreboardsEnabled()) { CommandUtils.printGatheringSkills(player);
ScoreboardManager.enablePlayerStatsScoreboard(player); CommandUtils.printCombatSkills(player);
CommandUtils.printMiscSkills(player);
if (!Config.getInstance().getStatsUseChat()) { int powerLevelCap = mcMMO.p.getGeneralConfig().getPowerLevelCap();
return true;
}
}
player.sendMessage(LocaleLoader.getString("Stats.Own.Stats")); if (powerLevelCap != Integer.MAX_VALUE) {
player.sendMessage(LocaleLoader.getString("mcMMO.NoSkillNote")); player.sendMessage(LocaleLoader.getString("Commands.PowerLevel.Capped", UserManager.getPlayer(player).getPowerLevel(), powerLevelCap));
} else {
player.sendMessage(LocaleLoader.getString("Commands.PowerLevel", UserManager.getPlayer(player).getPowerLevel()));
}
CommandUtils.printGatheringSkills(player); return true;
CommandUtils.printCombatSkills(player);
CommandUtils.printMiscSkills(player);
int powerLevelCap = Config.getInstance().getPowerLevelCap();
if (powerLevelCap != Integer.MAX_VALUE) {
player.sendMessage(LocaleLoader.getString("Commands.PowerLevel.Capped", UserManager.getPlayer(player).getPowerLevel(), powerLevelCap));
}
else {
player.sendMessage(LocaleLoader.getString("Commands.PowerLevel", UserManager.getPlayer(player).getPowerLevel()));
}
return true;
default:
return false;
} }
return false;
} }
@Override @Override
public List<String> onTabComplete(CommandSender sender, Command command, String alias, String[] args) { public List<String> onTabComplete(@NotNull CommandSender sender, @NotNull Command command, @NotNull String alias, String[] args) {
return ImmutableList.of(); return ImmutableList.of();
} }
} }

View File

@ -1,15 +1,15 @@
package com.gmail.nossr50.commands.player; package com.gmail.nossr50.commands.player;
import com.gmail.nossr50.config.Config;
import com.gmail.nossr50.datatypes.player.McMMOPlayer; import com.gmail.nossr50.datatypes.player.McMMOPlayer;
import com.gmail.nossr50.datatypes.skills.PrimarySkillType; import com.gmail.nossr50.datatypes.skills.PrimarySkillType;
import com.gmail.nossr50.locale.LocaleLoader; import com.gmail.nossr50.locale.LocaleLoader;
import com.gmail.nossr50.mcMMO; import com.gmail.nossr50.mcMMO;
import com.gmail.nossr50.runnables.commands.MctopCommandAsyncTask; import com.gmail.nossr50.runnables.commands.MctopCommandAsyncTask;
import com.gmail.nossr50.util.MetadataConstants;
import com.gmail.nossr50.util.Permissions; import com.gmail.nossr50.util.Permissions;
import com.gmail.nossr50.util.StringUtils;
import com.gmail.nossr50.util.commands.CommandUtils; import com.gmail.nossr50.util.commands.CommandUtils;
import com.gmail.nossr50.util.player.UserManager; import com.gmail.nossr50.util.player.UserManager;
import com.gmail.nossr50.util.text.StringUtils;
import com.google.common.collect.ImmutableList; import com.google.common.collect.ImmutableList;
import org.bukkit.command.Command; import org.bukkit.command.Command;
import org.bukkit.command.CommandSender; import org.bukkit.command.CommandSender;
@ -17,13 +17,14 @@ import org.bukkit.command.TabExecutor;
import org.bukkit.entity.Player; import org.bukkit.entity.Player;
import org.bukkit.metadata.FixedMetadataValue; import org.bukkit.metadata.FixedMetadataValue;
import org.bukkit.util.StringUtil; import org.bukkit.util.StringUtil;
import org.jetbrains.annotations.NotNull;
import java.util.ArrayList; import java.util.ArrayList;
import java.util.List; import java.util.List;
public class MctopCommand implements TabExecutor { public class MctopCommand implements TabExecutor {
@Override @Override
public boolean onCommand(CommandSender sender, Command command, String label, String[] args) { public boolean onCommand(@NotNull CommandSender sender, @NotNull Command command, @NotNull String label, String[] args) {
PrimarySkillType skill = null; PrimarySkillType skill = null;
switch (args.length) { switch (args.length) {
@ -66,13 +67,11 @@ public class MctopCommand implements TabExecutor {
} }
@Override @Override
public List<String> onTabComplete(CommandSender sender, Command command, String alias, String[] args) { public List<String> onTabComplete(@NotNull CommandSender sender, @NotNull Command command, @NotNull String alias, String[] args) {
switch (args.length) { if (args.length == 1) {
case 1: return StringUtil.copyPartialMatches(args[0], mcMMO.p.getSkillTools().LOCALIZED_SKILL_NAMES, new ArrayList<>(mcMMO.p.getSkillTools().LOCALIZED_SKILL_NAMES.size()));
return StringUtil.copyPartialMatches(args[0], PrimarySkillType.SKILL_NAMES, new ArrayList<String>(PrimarySkillType.SKILL_NAMES.size()));
default:
return ImmutableList.of();
} }
return ImmutableList.of();
} }
private void display(int page, PrimarySkillType skill, CommandSender sender, Command command) { private void display(int page, PrimarySkillType skill, CommandSender sender, Command command) {
@ -87,10 +86,10 @@ public class MctopCommand implements TabExecutor {
} }
McMMOPlayer mcMMOPlayer = UserManager.getPlayer(sender.getName()); McMMOPlayer mcMMOPlayer = UserManager.getPlayer(sender.getName());
long cooldownMillis = Math.max(Config.getInstance().getDatabasePlayerCooldown(), 1750); long cooldownMillis = Math.max(mcMMO.p.getGeneralConfig().getDatabasePlayerCooldown(), 1750);
if (mcMMOPlayer.getDatabaseATS() + cooldownMillis > System.currentTimeMillis()) { if (mcMMOPlayer.getDatabaseATS() + cooldownMillis > System.currentTimeMillis()) {
double seconds = ((mcMMOPlayer.getDatabaseATS() + cooldownMillis) - System.currentTimeMillis()) / 1000; double seconds = ((mcMMOPlayer.getDatabaseATS() + cooldownMillis) - System.currentTimeMillis()) / 1000.0D;
if (seconds < 1) { if (seconds < 1) {
seconds = 1; seconds = 1;
} }
@ -99,11 +98,11 @@ public class MctopCommand implements TabExecutor {
return; return;
} }
if (((Player) sender).hasMetadata(mcMMO.databaseCommandKey)) { if (((Player) sender).hasMetadata(MetadataConstants.METADATA_KEY_DATABASE_COMMAND)) {
sender.sendMessage(LocaleLoader.getString("Commands.Database.Processing")); sender.sendMessage(LocaleLoader.getString("Commands.Database.Processing"));
return; return;
} else { } else {
((Player) sender).setMetadata(mcMMO.databaseCommandKey, new FixedMetadataValue(mcMMO.p, null)); ((Player) sender).setMetadata(MetadataConstants.METADATA_KEY_DATABASE_COMMAND, new FixedMetadataValue(mcMMO.p, null));
} }
mcMMOPlayer.actualizeDatabaseATS(); mcMMOPlayer.actualizeDatabaseATS();
@ -113,8 +112,8 @@ public class MctopCommand implements TabExecutor {
} }
private void display(int page, PrimarySkillType skill, CommandSender sender) { private void display(int page, PrimarySkillType skill, CommandSender sender) {
boolean useBoard = (sender instanceof Player) && (Config.getInstance().getTopUseBoard()); boolean useBoard = (sender instanceof Player) && (mcMMO.p.getGeneralConfig().getTopUseBoard());
boolean useChat = !useBoard || Config.getInstance().getTopUseChat(); boolean useChat = !useBoard || mcMMO.p.getGeneralConfig().getTopUseChat();
new MctopCommandAsyncTask(page, skill, sender, useBoard, useChat).runTaskAsynchronously(mcMMO.p); new MctopCommandAsyncTask(page, skill, sender, useBoard, useChat).runTaskAsynchronously(mcMMO.p);
} }
@ -124,7 +123,7 @@ public class MctopCommand implements TabExecutor {
return null; return null;
} }
PrimarySkillType skill = PrimarySkillType.getSkill(skillName); PrimarySkillType skill = mcMMO.p.getSkillTools().matchSkill(skillName);
if (CommandUtils.isChildSkill(sender, skill)) { if (CommandUtils.isChildSkill(sender, skill)) {
return null; return null;

View File

@ -0,0 +1,112 @@
package com.gmail.nossr50.commands.player;
import com.gmail.nossr50.datatypes.player.McMMOPlayer;
import com.gmail.nossr50.datatypes.skills.PrimarySkillType;
import com.gmail.nossr50.mcMMO;
import com.gmail.nossr50.util.experience.ExperienceBarManager;
import com.gmail.nossr50.util.player.NotificationManager;
import com.gmail.nossr50.util.player.UserManager;
import com.gmail.nossr50.util.skills.SkillUtils;
import com.gmail.nossr50.util.text.StringUtils;
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 org.jetbrains.annotations.NotNull;
import org.jetbrains.annotations.Nullable;
import java.util.ArrayList;
import java.util.List;
public class XPBarCommand implements TabExecutor {
@Override
public boolean onCommand(@NotNull CommandSender sender, @NotNull Command command, @NotNull String label, @NotNull String[] args) {
if(sender instanceof Player) {
McMMOPlayer mmoPlayer = UserManager.getPlayer((Player) sender);
if(mmoPlayer == null) {
NotificationManager.sendPlayerInformationChatOnlyPrefixed(mmoPlayer.getPlayer(), "Profile.PendingLoad");
return false;
}
if(args.length == 0) {
return false;
} else if(args.length < 2) {
String option = args[0];
if(option.equalsIgnoreCase(ExperienceBarManager.XPBarSettingTarget.RESET.toString())) {
mmoPlayer.getExperienceBarManager().xpBarSettingToggle(ExperienceBarManager.XPBarSettingTarget.RESET, null);
return true;
} else if(option.equalsIgnoreCase(ExperienceBarManager.XPBarSettingTarget.DISABLE.toString())) {
mmoPlayer.getExperienceBarManager().disableAllBars();
return true;
} else {
return false;
}
//Per skill Settings path
} else if (args.length == 2) {
String skillName = args[1];
if(SkillUtils.isSkill(skillName)) {
PrimarySkillType targetSkill = mcMMO.p.getSkillTools().matchSkill(skillName);
//Target setting
String option = args[0].toLowerCase();
ExperienceBarManager.XPBarSettingTarget settingTarget = getSettingTarget(option);
if(settingTarget != null && settingTarget != ExperienceBarManager.XPBarSettingTarget.RESET) {
//Change setting
mmoPlayer.getExperienceBarManager().xpBarSettingToggle(settingTarget, targetSkill);
return true;
} else {
return false;
}
} else {
return false;
}
} else {
return false;
}
} else {
return false;
}
}
private @Nullable ExperienceBarManager.XPBarSettingTarget getSettingTarget(String string) {
switch (string.toLowerCase()) {
case "hide":
return ExperienceBarManager.XPBarSettingTarget.HIDE;
case "show":
return ExperienceBarManager.XPBarSettingTarget.SHOW;
case "reset":
return ExperienceBarManager.XPBarSettingTarget.RESET;
case "disable":
return ExperienceBarManager.XPBarSettingTarget.DISABLE;
}
return null;
}
@Override
public List<String> onTabComplete(@NotNull CommandSender sender, @NotNull Command command, @NotNull String alias, String[] args) {
switch (args.length) {
case 1:
List<String> options = new ArrayList<>();
for(ExperienceBarManager.XPBarSettingTarget settingTarget : ExperienceBarManager.XPBarSettingTarget.values()) {
options.add(StringUtils.getCapitalized(settingTarget.toString()));
}
return StringUtil.copyPartialMatches(args[0], options, new ArrayList<>(ExperienceBarManager.XPBarSettingTarget.values().length));
case 2:
if(!args[0].equalsIgnoreCase(ExperienceBarManager.XPBarSettingTarget.RESET.toString()))
return StringUtil.copyPartialMatches(args[1], mcMMO.p.getSkillTools().LOCALIZED_SKILL_NAMES, new ArrayList<>(mcMMO.p.getSkillTools().LOCALIZED_SKILL_NAMES.size()));
default:
return ImmutableList.of();
}
}
}

View File

@ -3,13 +3,14 @@ package com.gmail.nossr50.commands.server;
import org.bukkit.command.Command; import org.bukkit.command.Command;
import org.bukkit.command.CommandExecutor; import org.bukkit.command.CommandExecutor;
import org.bukkit.command.CommandSender; import org.bukkit.command.CommandSender;
import org.jetbrains.annotations.NotNull;
/** /**
* This command facilitates switching the skill system scale between classic and modern scale * This command facilitates switching the skill system scale between classic and modern scale
*/ */
public class Mcmmoupgrade implements CommandExecutor { public class Mcmmoupgrade implements CommandExecutor {
@Override @Override
public boolean onCommand(CommandSender sender, Command command, String label, String[] args) { public boolean onCommand(@NotNull CommandSender sender, @NotNull Command command, @NotNull String label, String[] args) {
return false; return false;
} }
} }

View File

@ -5,11 +5,11 @@ import com.gmail.nossr50.datatypes.skills.SubSkillType;
import com.gmail.nossr50.datatypes.skills.subskills.AbstractSubSkill; import com.gmail.nossr50.datatypes.skills.subskills.AbstractSubSkill;
import com.gmail.nossr50.listeners.InteractionManager; import com.gmail.nossr50.listeners.InteractionManager;
import com.gmail.nossr50.locale.LocaleLoader; import com.gmail.nossr50.locale.LocaleLoader;
import com.gmail.nossr50.util.TextComponentFactory;
import com.gmail.nossr50.util.random.RandomChanceSkill; import com.gmail.nossr50.util.random.RandomChanceSkill;
import com.gmail.nossr50.util.random.RandomChanceUtil; import com.gmail.nossr50.util.random.RandomChanceUtil;
import com.gmail.nossr50.util.skills.SkillActivationType; import com.gmail.nossr50.util.skills.SkillActivationType;
import net.md_5.bungee.api.chat.TextComponent; import com.gmail.nossr50.util.text.TextComponentFactory;
import net.kyori.adventure.text.Component;
import org.bukkit.entity.Player; import org.bukkit.entity.Player;
import java.util.ArrayList; import java.util.ArrayList;
@ -44,7 +44,7 @@ public class AcrobaticsCommand extends SkillCommand {
@Override @Override
protected List<String> statsDisplay(Player player, float skillValue, boolean hasEndurance, boolean isLucky) { protected List<String> statsDisplay(Player player, float skillValue, boolean hasEndurance, boolean isLucky) {
List<String> messages = new ArrayList<String>(); List<String> messages = new ArrayList<>();
if (canDodge) { if (canDodge) {
messages.add(getStatMessage(SubSkillType.ACROBATICS_DODGE, dodgeChance) messages.add(getStatMessage(SubSkillType.ACROBATICS_DODGE, dodgeChance)
@ -69,9 +69,9 @@ public class AcrobaticsCommand extends SkillCommand {
//Chance Stat Calculations //Chance Stat Calculations
rollChance = RandomChanceUtil.getRandomChanceExecutionChance(roll_rcs); rollChance = RandomChanceUtil.getRandomChanceExecutionChance(roll_rcs);
graceChance = RandomChanceUtil.getRandomChanceExecutionChance(grace_rcs); graceChance = RandomChanceUtil.getRandomChanceExecutionChance(grace_rcs);
//damageThreshold = AdvancedConfig.getInstance().getRollDamageThreshold(); //damageThreshold = mcMMO.p.getAdvancedConfig().getRollDamageThreshold();
String rollStrings[] = getAbilityDisplayValues(SkillActivationType.RANDOM_LINEAR_100_SCALE_WITH_CAP, player, SubSkillType.ACROBATICS_ROLL); String[] rollStrings = getAbilityDisplayValues(SkillActivationType.RANDOM_LINEAR_100_SCALE_WITH_CAP, player, SubSkillType.ACROBATICS_ROLL);
//Format //Format
double rollChanceLucky = rollChance * 1.333D; double rollChanceLucky = rollChance * 1.333D;
@ -89,8 +89,8 @@ public class AcrobaticsCommand extends SkillCommand {
} }
@Override @Override
protected List<TextComponent> getTextComponents(Player player) { protected List<Component> getTextComponents(Player player) {
List<TextComponent> textComponents = new ArrayList<>(); List<Component> textComponents = new ArrayList<>();
TextComponentFactory.getSubSkillTextComponents(player, textComponents, PrimarySkillType.ACROBATICS); TextComponentFactory.getSubSkillTextComponents(player, textComponents, PrimarySkillType.ACROBATICS);

View File

@ -5,10 +5,10 @@ import com.gmail.nossr50.datatypes.skills.SubSkillType;
import com.gmail.nossr50.locale.LocaleLoader; import com.gmail.nossr50.locale.LocaleLoader;
import com.gmail.nossr50.skills.alchemy.AlchemyManager; import com.gmail.nossr50.skills.alchemy.AlchemyManager;
import com.gmail.nossr50.util.Permissions; import com.gmail.nossr50.util.Permissions;
import com.gmail.nossr50.util.TextComponentFactory;
import com.gmail.nossr50.util.player.UserManager; import com.gmail.nossr50.util.player.UserManager;
import com.gmail.nossr50.util.skills.RankUtils; import com.gmail.nossr50.util.skills.RankUtils;
import net.md_5.bungee.api.chat.TextComponent; import com.gmail.nossr50.util.text.TextComponentFactory;
import net.kyori.adventure.text.Component;
import org.bukkit.entity.Player; import org.bukkit.entity.Player;
import java.util.ArrayList; import java.util.ArrayList;
@ -74,7 +74,7 @@ public class AlchemyCommand extends SkillCommand {
@Override @Override
protected List<String> statsDisplay(Player player, float skillValue, boolean hasEndurance, boolean isLucky) { protected List<String> statsDisplay(Player player, float skillValue, boolean hasEndurance, boolean isLucky) {
List<String> messages = new ArrayList<String>(); List<String> messages = new ArrayList<>();
if (canCatalysis) { if (canCatalysis) {
messages.add(getStatMessage(SubSkillType.ALCHEMY_CATALYSIS, brewSpeed) messages.add(getStatMessage(SubSkillType.ALCHEMY_CATALYSIS, brewSpeed)
@ -93,8 +93,8 @@ public class AlchemyCommand extends SkillCommand {
} }
@Override @Override
protected List<TextComponent> getTextComponents(Player player) { protected List<Component> getTextComponents(Player player) {
List<TextComponent> textComponents = new ArrayList<>(); List<Component> textComponents = new ArrayList<>();
TextComponentFactory.getSubSkillTextComponents(player, textComponents, PrimarySkillType.ALCHEMY); TextComponentFactory.getSubSkillTextComponents(player, textComponents, PrimarySkillType.ALCHEMY);

View File

@ -1,203 +1,199 @@
package com.gmail.nossr50.commands.skills; //package com.gmail.nossr50.commands.skills;
//
import com.gmail.nossr50.locale.LocaleLoader; //import com.gmail.nossr50.locale.LocaleLoader;
import com.gmail.nossr50.util.HolidayManager.FakeSkillType; //import com.gmail.nossr50.util.HolidayManager.FakeSkillType;
import com.gmail.nossr50.util.Misc; //import com.gmail.nossr50.util.Misc;
import com.gmail.nossr50.util.StringUtils; //import com.gmail.nossr50.util.commands.CommandUtils;
import com.gmail.nossr50.util.commands.CommandUtils; //import com.gmail.nossr50.util.text.StringUtils;
import com.google.common.collect.ImmutableList; //import com.google.common.collect.ImmutableList;
import org.bukkit.command.Command; //import org.bukkit.command.Command;
import org.bukkit.command.CommandSender; //import org.bukkit.command.CommandSender;
import org.bukkit.command.TabExecutor; //import org.bukkit.command.TabExecutor;
import org.bukkit.entity.Player; //import org.bukkit.entity.Player;
//import org.jetbrains.annotations.NotNull;
import java.text.DecimalFormat; //
import java.util.ArrayList; //import java.text.DecimalFormat;
import java.util.List; //import java.util.ArrayList;
//import java.util.List;
public class AprilCommand implements TabExecutor { //
private String skillName; //public class AprilCommand implements TabExecutor {
// private String skillName;
protected DecimalFormat percent = new DecimalFormat("##0.00%"); //
protected DecimalFormat decimal = new DecimalFormat("##0.00"); // protected DecimalFormat percent = new DecimalFormat("##0.00%");
// protected DecimalFormat decimal = new DecimalFormat("##0.00");
@Override //
public boolean onCommand(CommandSender sender, Command command, String label, String[] args) { // @Override
if (CommandUtils.noConsoleUsage(sender)) { // public boolean onCommand(@NotNull CommandSender sender, @NotNull Command command, @NotNull String label, String[] args) {
return true; // if (CommandUtils.noConsoleUsage(sender)) {
} // return true;
// }
skillName = StringUtils.getCapitalized(label); //
// skillName = StringUtils.getCapitalized(label);
switch (args.length) { //
case 0: // if (args.length == 0) {
Player player = (Player) sender; // Player player = (Player) sender;
FakeSkillType fakeSkillType = FakeSkillType.getByName(skillName); // FakeSkillType fakeSkillType = FakeSkillType.getByName(skillName);
//
float skillValue = Misc.getRandom().nextInt(99); // float skillValue = Misc.getRandom().nextInt(99);
//
player.sendMessage(LocaleLoader.getString("Skills.Header", skillName)); // player.sendMessage(LocaleLoader.getString("Skills.Header", skillName));
player.sendMessage(LocaleLoader.getString("Commands.XPGain", getXPGainString(fakeSkillType))); // player.sendMessage(LocaleLoader.getString("Commands.XPGain", getXPGainString(fakeSkillType)));
player.sendMessage(LocaleLoader.getString("Effects.Level", (int) skillValue, Misc.getRandom().nextInt(1000), 1000 + Misc.getRandom().nextInt(1000))); // player.sendMessage(LocaleLoader.getString("Effects.Level", (int) skillValue, Misc.getRandom().nextInt(1000), 1000 + Misc.getRandom().nextInt(1000)));
//
//
List<String> effectMessages = effectsDisplay(fakeSkillType); // List<String> effectMessages = effectsDisplay(fakeSkillType);
//
if (!effectMessages.isEmpty()) { // if (!effectMessages.isEmpty()) {
player.sendMessage(LocaleLoader.getString("Skills.Header", LocaleLoader.getString("Effects.Effects"))); // player.sendMessage(LocaleLoader.getString("Skills.Header", LocaleLoader.getString("Effects.Effects")));
//
for (String message : effectMessages) { // for (String message : effectMessages) {
player.sendMessage(message); // player.sendMessage(message);
} // }
} // }
//
List<String> statsMessages = statsDisplay(fakeSkillType); // List<String> statsMessages = statsDisplay(fakeSkillType);
//
if (!statsMessages.isEmpty()) { // if (!statsMessages.isEmpty()) {
player.sendMessage(LocaleLoader.getString("Skills.Header", LocaleLoader.getString("Commands.Stats.Self"))); // player.sendMessage(LocaleLoader.getString("Skills.Header", LocaleLoader.getString("Commands.Stats.Self")));
//
for (String message : statsMessages) { // for (String message : statsMessages) {
player.sendMessage(message); // player.sendMessage(message);
} // }
} // }
//
player.sendMessage(LocaleLoader.formatString("[[DARK_AQUA]]Guide for {0} available - type /APRIL FOOLS ! :D", skillName)); // player.sendMessage(LocaleLoader.formatString("[[DARK_AQUA]]Guide for {0} available - type /APRIL FOOLS ! :D", skillName));
return true; // return true;
// }
default: // return true;
return true; // }
} //
} // private String getXPGainString(FakeSkillType fakeSkillType) {
// switch (fakeSkillType) {
private String getXPGainString(FakeSkillType fakeSkillType) { // case MACHO:
switch (fakeSkillType) { // return "Get beaten up";
case MACHO: // case JUMPING:
return "Get beaten up"; // return "Kris Kross will make ya Jump Jump";
case JUMPING: // case THROWING:
return "Kris Kross will make ya Jump Jump"; // return "Chuck your items on the floor";
case THROWING: // case WRECKING:
return "Chuck your items on the floor"; // return "I'M GONNA WRECK IT!";
case WRECKING: // case CRAFTING:
return "I'M GONNA WRECK IT!"; // return "Craft apple pies";
case CRAFTING: // case WALKING:
return "Craft apple pies"; // return "Walk around the park";
case WALKING: // case SWIMMING:
return "Walk around the park"; // return "Like a fish on a bicycle";
case SWIMMING: // case FALLING:
return "Like a fish on a bicycle"; // return "Faceplant the floor, headbutt the ground";
case FALLING: // case CLIMBING:
return "Faceplant the floor, headbutt the ground"; // return "Climb the highest mountain";
case CLIMBING: // case FLYING:
return "Climb the highest mountain"; // return "I believe I can fly";
case FLYING: // case DIVING:
return "I believe I can fly"; // return "Scuba club 4000";
case DIVING: // case PIGGY:
return "Scuba club 4000"; // return "OINK! OINK!";
case PIGGY: // default:
return "OINK! OINK!"; // return "Sit and wait?";
default: // }
return "Sit and wait?"; // }
} //
} // @Override
// public List<String> onTabComplete(@NotNull CommandSender sender, @NotNull Command command, @NotNull String alias, String[] args) {
@Override // if (args.length == 1) {
public List<String> onTabComplete(CommandSender sender, Command command, String alias, String[] args) { // return ImmutableList.of("?");
switch (args.length) { // }
case 1: // return ImmutableList.of();
return ImmutableList.of("?"); // }
default: //
return ImmutableList.of(); // private List<String> effectsDisplay(FakeSkillType fakeSkillType) {
} // List<String> messages = new ArrayList<>();
} //
// switch (fakeSkillType) {
private List<String> effectsDisplay(FakeSkillType fakeSkillType) { // case MACHO:
List<String> messages = new ArrayList<String>(); // messages.add(LocaleLoader.getString("Effects.Template", "Punching bag", "Absorb damage, like a bag of sand"));
// break;
switch (fakeSkillType) { // case JUMPING:
case MACHO: // messages.add(LocaleLoader.getString("Effects.Template", "Jump", "PRESS SPACE TO JUMP"));
messages.add(LocaleLoader.getString("Effects.Template", "Punching bag", "Absorb damage, like a bag of sand")); // messages.add(LocaleLoader.getString("Effects.Template", "Jump Twice", "PRESS SPACE TWICE TO JUMP TWICE"));
break; // break;
case JUMPING: // case THROWING:
messages.add(LocaleLoader.getString("Effects.Template", "Jump", "PRESS SPACE TO JUMP")); // messages.add(LocaleLoader.getString("Effects.Template", "Drop Item", "Randomly drop items, at random"));
messages.add(LocaleLoader.getString("Effects.Template", "Jump Twice", "PRESS SPACE TWICE TO JUMP TWICE")); // break;
break; // case WRECKING:
case THROWING: // messages.add(LocaleLoader.getString("Effects.Template", "Ralphinator", "Smash windows with your fists"));
messages.add(LocaleLoader.getString("Effects.Template", "Drop Item", "Randomly drop items, at random")); // break;
break; // case CRAFTING:
case WRECKING: // messages.add(LocaleLoader.getString("Effects.Template", "Crafting", "Chance of successful craft"));
messages.add(LocaleLoader.getString("Effects.Template", "Ralphinator", "Smash windows with your fists")); // break;
break; // case WALKING:
case CRAFTING: // messages.add(LocaleLoader.getString("Effects.Template", "Walk", "Traveling gracefully by foot"));
messages.add(LocaleLoader.getString("Effects.Template", "Crafting", "Chance of successful craft")); // break;
break; // case SWIMMING:
case WALKING: // messages.add(LocaleLoader.getString("Effects.Template", "Swim", "Just keep swimming, swimming, swimming"));
messages.add(LocaleLoader.getString("Effects.Template", "Walk", "Traveling gracefully by foot")); // break;
break; // case FALLING:
case SWIMMING: // messages.add(LocaleLoader.getString("Effects.Template", "Skydiving", "Go jump of a cliff. No, seriously."));
messages.add(LocaleLoader.getString("Effects.Template", "Swim", "Just keep swimming, swimming, swimming")); // break;
break; // case CLIMBING:
case FALLING: // messages.add(LocaleLoader.getString("Effects.Template", "Rock Climber", "Use string to climb mountains faster"));
messages.add(LocaleLoader.getString("Effects.Template", "Skydiving", "Go jump of a cliff. No, seriously.")); // break;
break; // case FLYING:
case CLIMBING: // messages.add(LocaleLoader.getString("Effects.Template", "Fly", "Throw yourself at the ground and miss"));
messages.add(LocaleLoader.getString("Effects.Template", "Rock Climber", "Use string to climb mountains faster")); // break;
break; // case DIVING:
case FLYING: // messages.add(LocaleLoader.getString("Effects.Template", "Hold Breath", "Press shift to hold your breath longer"));
messages.add(LocaleLoader.getString("Effects.Template", "Fly", "Throw yourself at the ground and miss")); // break;
break; // case PIGGY:
case DIVING: // messages.add(LocaleLoader.getString("Effects.Template", "Carrot Turbo", "Supercharge your pigs with carrots"));
messages.add(LocaleLoader.getString("Effects.Template", "Hold Breath", "Press shift to hold your breath longer")); // break;
break; // }
case PIGGY: //
messages.add(LocaleLoader.getString("Effects.Template", "Carrot Turbo", "Supercharge your pigs with carrots")); // return messages;
break; // }
} //
// private List<String> statsDisplay(FakeSkillType fakeSkillType) {
return messages; // List<String> messages = new ArrayList<>();
} //
// switch (fakeSkillType) {
private List<String> statsDisplay(FakeSkillType fakeSkillType) { // case MACHO:
List<String> messages = new ArrayList<String>(); // messages.add(LocaleLoader.formatString("&cDamage Taken: &e{0}%", decimal.format(Misc.getRandom().nextInt(77))));
// break;
switch (fakeSkillType) { // case JUMPING:
case MACHO: // messages.add(LocaleLoader.formatString("&cDouble Jump Chance: &e{0}%", decimal.format(Misc.getRandom().nextInt(27))));
messages.add(LocaleLoader.formatString("[[RED]]Damage Taken: [[YELLOW]]{0}%", decimal.format(Misc.getRandom().nextInt(77)))); // break;
break; // case THROWING:
case JUMPING: // messages.add(LocaleLoader.formatString("&cDrop Item Chance: &e{0}%", decimal.format(Misc.getRandom().nextInt(87))));
messages.add(LocaleLoader.formatString("[[RED]]Double Jump Chance: [[YELLOW]]{0}%", decimal.format(Misc.getRandom().nextInt(27)))); // break;
break; // case WRECKING:
case THROWING: // messages.add(LocaleLoader.formatString("&cWrecking Chance: &e{0}%", decimal.format(Misc.getRandom().nextInt(14))));
messages.add(LocaleLoader.formatString("[[RED]]Drop Item Chance: [[YELLOW]]{0}%", decimal.format(Misc.getRandom().nextInt(87)))); // break;
break; // case CRAFTING:
case WRECKING: // messages.add(LocaleLoader.formatString("&cCrafting Success: &e{0}%", decimal.format(Misc.getRandom().nextInt(27))));
messages.add(LocaleLoader.formatString("[[RED]]Wrecking Chance: [[YELLOW]]{0}%", decimal.format(Misc.getRandom().nextInt(14)))); // break;
break; // case WALKING:
case CRAFTING: // messages.add(LocaleLoader.formatString("&cWalk Chance: &e{0}%", decimal.format(Misc.getRandom().nextInt(27))));
messages.add(LocaleLoader.formatString("[[RED]]Crafting Success: [[YELLOW]]{0}%", decimal.format(Misc.getRandom().nextInt(27)))); // break;
break; // case SWIMMING:
case WALKING: // messages.add(LocaleLoader.formatString("&cSwim Chance: &e{0}%", decimal.format(Misc.getRandom().nextInt(27))));
messages.add(LocaleLoader.formatString("[[RED]]Walk Chance: [[YELLOW]]{0}%", decimal.format(Misc.getRandom().nextInt(27)))); // break;
break; // case FALLING:
case SWIMMING: // messages.add(LocaleLoader.formatString("&cSkydiving Success: &e{0}%", decimal.format(Misc.getRandom().nextInt(37))));
messages.add(LocaleLoader.formatString("[[RED]]Swim Chance: [[YELLOW]]{0}%", decimal.format(Misc.getRandom().nextInt(27)))); // break;
break; // case CLIMBING:
case FALLING: // messages.add(LocaleLoader.formatString("&cRock Climber Chance: &e{0}%", decimal.format(Misc.getRandom().nextInt(27))));
messages.add(LocaleLoader.formatString("[[RED]]Skydiving Success: [[YELLOW]]{0}%", decimal.format(Misc.getRandom().nextInt(37)))); // break;
break; // case FLYING:
case CLIMBING: // messages.add(LocaleLoader.formatString("&cFly Chance: &e{0}%", decimal.format(Misc.getRandom().nextInt(27))));
messages.add(LocaleLoader.formatString("[[RED]]Rock Climber Chance: [[YELLOW]]{0}%", decimal.format(Misc.getRandom().nextInt(27)))); // break;
break; // case DIVING:
case FLYING: // messages.add(LocaleLoader.formatString("&cHold Breath Chance: &e{0}%", decimal.format(Misc.getRandom().nextInt(27))));
messages.add(LocaleLoader.formatString("[[RED]]Fly Chance: [[YELLOW]]{0}%", decimal.format(Misc.getRandom().nextInt(27)))); // break;
break; // case PIGGY:
case DIVING: // messages.add(LocaleLoader.formatString("&cCarrot Turbo Boost: &e{0}%", decimal.format(Misc.getRandom().nextInt(80)) + 10));
messages.add(LocaleLoader.formatString("[[RED]]Hold Breath Chance: [[YELLOW]]{0}%", decimal.format(Misc.getRandom().nextInt(27)))); // break;
break; // }
case PIGGY: //
messages.add(LocaleLoader.formatString("[[RED]]Carrot Turbo Boost: [[YELLOW]]{0}%", decimal.format(Misc.getRandom().nextInt(80)) + 10)); // return messages;
break; // }
} //}
return messages;
}
}

View File

@ -4,10 +4,10 @@ import com.gmail.nossr50.datatypes.skills.PrimarySkillType;
import com.gmail.nossr50.datatypes.skills.SubSkillType; import com.gmail.nossr50.datatypes.skills.SubSkillType;
import com.gmail.nossr50.locale.LocaleLoader; import com.gmail.nossr50.locale.LocaleLoader;
import com.gmail.nossr50.skills.archery.Archery; import com.gmail.nossr50.skills.archery.Archery;
import com.gmail.nossr50.util.TextComponentFactory;
import com.gmail.nossr50.util.skills.CombatUtils; import com.gmail.nossr50.util.skills.CombatUtils;
import com.gmail.nossr50.util.skills.SkillActivationType; import com.gmail.nossr50.util.skills.SkillActivationType;
import net.md_5.bungee.api.chat.TextComponent; import com.gmail.nossr50.util.text.TextComponentFactory;
import net.kyori.adventure.text.Component;
import org.bukkit.entity.Player; import org.bukkit.entity.Player;
import java.util.ArrayList; import java.util.ArrayList;
@ -59,7 +59,7 @@ public class ArcheryCommand extends SkillCommand {
@Override @Override
protected List<String> statsDisplay(Player player, float skillValue, boolean hasEndurance, boolean isLucky) { protected List<String> statsDisplay(Player player, float skillValue, boolean hasEndurance, boolean isLucky) {
List<String> messages = new ArrayList<String>(); List<String> messages = new ArrayList<>();
if (canRetrieve) { if (canRetrieve) {
messages.add(getStatMessage(SubSkillType.ARCHERY_ARROW_RETRIEVAL, retrieveChance) messages.add(getStatMessage(SubSkillType.ARCHERY_ARROW_RETRIEVAL, retrieveChance)
@ -84,8 +84,8 @@ public class ArcheryCommand extends SkillCommand {
} }
@Override @Override
protected List<TextComponent> getTextComponents(Player player) { protected List<Component> getTextComponents(Player player) {
List<TextComponent> textComponents = new ArrayList<>(); List<Component> textComponents = new ArrayList<>();
TextComponentFactory.getSubSkillTextComponents(player, textComponents, PrimarySkillType.ARCHERY); TextComponentFactory.getSubSkillTextComponents(player, textComponents, PrimarySkillType.ARCHERY);

View File

@ -5,12 +5,12 @@ import com.gmail.nossr50.datatypes.skills.SubSkillType;
import com.gmail.nossr50.locale.LocaleLoader; import com.gmail.nossr50.locale.LocaleLoader;
import com.gmail.nossr50.skills.axes.Axes; import com.gmail.nossr50.skills.axes.Axes;
import com.gmail.nossr50.util.Permissions; import com.gmail.nossr50.util.Permissions;
import com.gmail.nossr50.util.TextComponentFactory;
import com.gmail.nossr50.util.player.UserManager; import com.gmail.nossr50.util.player.UserManager;
import com.gmail.nossr50.util.skills.CombatUtils; import com.gmail.nossr50.util.skills.CombatUtils;
import com.gmail.nossr50.util.skills.RankUtils; import com.gmail.nossr50.util.skills.RankUtils;
import com.gmail.nossr50.util.skills.SkillActivationType; import com.gmail.nossr50.util.skills.SkillActivationType;
import net.md_5.bungee.api.chat.TextComponent; import com.gmail.nossr50.util.text.TextComponentFactory;
import net.kyori.adventure.text.Component;
import org.bukkit.entity.Player; import org.bukkit.entity.Player;
import java.util.ArrayList; import java.util.ArrayList;
@ -72,7 +72,7 @@ public class AxesCommand extends SkillCommand {
@Override @Override
protected List<String> statsDisplay(Player player, float skillValue, boolean hasEndurance, boolean isLucky) { protected List<String> statsDisplay(Player player, float skillValue, boolean hasEndurance, boolean isLucky) {
List<String> messages = new ArrayList<String>(); List<String> messages = new ArrayList<>();
if (canImpact) { if (canImpact) {
messages.add(LocaleLoader.getString("Ability.Generic.Template", LocaleLoader.getString("Axes.Ability.Bonus.2"), LocaleLoader.getString("Axes.Ability.Bonus.3", impactDamage))); messages.add(LocaleLoader.getString("Ability.Generic.Template", LocaleLoader.getString("Axes.Ability.Bonus.2"), LocaleLoader.getString("Axes.Ability.Bonus.3", impactDamage)));
@ -105,8 +105,8 @@ public class AxesCommand extends SkillCommand {
} }
@Override @Override
protected List<TextComponent> getTextComponents(Player player) { protected List<Component> getTextComponents(Player player) {
List<TextComponent> textComponents = new ArrayList<>(); List<Component> textComponents = new ArrayList<>();
TextComponentFactory.getSubSkillTextComponents(player, textComponents, PrimarySkillType.AXES); TextComponentFactory.getSubSkillTextComponents(player, textComponents, PrimarySkillType.AXES);

View File

@ -5,10 +5,10 @@ import com.gmail.nossr50.datatypes.skills.SubSkillType;
import com.gmail.nossr50.locale.LocaleLoader; import com.gmail.nossr50.locale.LocaleLoader;
import com.gmail.nossr50.skills.excavation.ExcavationManager; import com.gmail.nossr50.skills.excavation.ExcavationManager;
import com.gmail.nossr50.util.Permissions; import com.gmail.nossr50.util.Permissions;
import com.gmail.nossr50.util.TextComponentFactory;
import com.gmail.nossr50.util.player.UserManager; import com.gmail.nossr50.util.player.UserManager;
import com.gmail.nossr50.util.skills.RankUtils; import com.gmail.nossr50.util.skills.RankUtils;
import net.md_5.bungee.api.chat.TextComponent; import com.gmail.nossr50.util.text.TextComponentFactory;
import net.kyori.adventure.text.Component;
import org.bukkit.entity.Player; import org.bukkit.entity.Player;
import java.util.ArrayList; import java.util.ArrayList;
@ -29,7 +29,7 @@ public class ExcavationCommand extends SkillCommand {
protected void dataCalculations(Player player, float skillValue) { protected void dataCalculations(Player player, float skillValue) {
// GIGA DRILL BREAKER // GIGA DRILL BREAKER
if (canGigaDrill) { if (canGigaDrill) {
String gigaDrillStrings[] = calculateLengthDisplayValues(player, skillValue); String[] gigaDrillStrings = calculateLengthDisplayValues(player, skillValue);
gigaDrillBreakerLength = gigaDrillStrings[0]; gigaDrillBreakerLength = gigaDrillStrings[0];
gigaDrillBreakerLengthEndurance = gigaDrillStrings[1]; gigaDrillBreakerLengthEndurance = gigaDrillStrings[1];
} }
@ -43,7 +43,7 @@ public class ExcavationCommand extends SkillCommand {
@Override @Override
protected List<String> statsDisplay(Player player, float skillValue, boolean hasEndurance, boolean isLucky) { protected List<String> statsDisplay(Player player, float skillValue, boolean hasEndurance, boolean isLucky) {
List<String> messages = new ArrayList<String>(); List<String> messages = new ArrayList<>();
ExcavationManager excavationManager = UserManager.getPlayer(player).getExcavationManager(); ExcavationManager excavationManager = UserManager.getPlayer(player).getExcavationManager();
@ -66,8 +66,8 @@ public class ExcavationCommand extends SkillCommand {
} }
@Override @Override
protected List<TextComponent> getTextComponents(Player player) { protected List<Component> getTextComponents(Player player) {
List<TextComponent> textComponents = new ArrayList<>(); List<Component> textComponents = new ArrayList<>();
TextComponentFactory.getSubSkillTextComponents(player, textComponents, PrimarySkillType.EXCAVATION); TextComponentFactory.getSubSkillTextComponents(player, textComponents, PrimarySkillType.EXCAVATION);

View File

@ -1,21 +1,18 @@
package com.gmail.nossr50.commands.skills; package com.gmail.nossr50.commands.skills;
import com.gmail.nossr50.config.AdvancedConfig; import com.gmail.nossr50.config.treasure.FishingTreasureConfig;
import com.gmail.nossr50.config.treasure.TreasureConfig;
import com.gmail.nossr50.datatypes.skills.PrimarySkillType; import com.gmail.nossr50.datatypes.skills.PrimarySkillType;
import com.gmail.nossr50.datatypes.skills.SubSkillType; import com.gmail.nossr50.datatypes.skills.SubSkillType;
import com.gmail.nossr50.datatypes.treasure.Rarity; import com.gmail.nossr50.datatypes.treasure.Rarity;
import com.gmail.nossr50.locale.LocaleLoader; import com.gmail.nossr50.locale.LocaleLoader;
import com.gmail.nossr50.skills.fishing.Fishing; import com.gmail.nossr50.mcMMO;
import com.gmail.nossr50.skills.fishing.FishingManager; import com.gmail.nossr50.skills.fishing.FishingManager;
import com.gmail.nossr50.util.Permissions;
import com.gmail.nossr50.util.TextComponentFactory;
import com.gmail.nossr50.util.player.UserManager; import com.gmail.nossr50.util.player.UserManager;
import com.gmail.nossr50.util.random.RandomChanceUtil; import com.gmail.nossr50.util.random.RandomChanceUtil;
import com.gmail.nossr50.util.skills.RankUtils; import com.gmail.nossr50.util.skills.RankUtils;
import net.md_5.bungee.api.chat.TextComponent; import com.gmail.nossr50.util.text.StringUtils;
import org.bukkit.Location; import com.gmail.nossr50.util.text.TextComponentFactory;
import org.bukkit.entity.EntityType; import net.kyori.adventure.text.Component;
import org.bukkit.entity.Player; import org.bukkit.entity.Player;
import java.util.ArrayList; import java.util.ArrayList;
@ -26,15 +23,13 @@ public class FishingCommand extends SkillCommand {
private String shakeChance; private String shakeChance;
private String shakeChanceLucky; private String shakeChanceLucky;
private int fishermansDietRank; private int fishermansDietRank;
private String biteChance;
private String trapTreasure;
private String commonTreasure; private String commonTreasure;
private String uncommonTreasure; private String uncommonTreasure;
private String rareTreasure; private String rareTreasure;
private String epicTreasure; private String epicTreasure;
private String legendaryTreasure; private String legendaryTreasure;
private String recordTreasure; private String mythicTreasure;
private String magicChance; private String magicChance;
@ -45,6 +40,8 @@ public class FishingCommand extends SkillCommand {
private boolean canMasterAngler; private boolean canMasterAngler;
private boolean canIceFish; private boolean canIceFish;
private String maMinWaitTime, maMaxWaitTime;
public FishingCommand() { public FishingCommand() {
super(PrimarySkillType.FISHING); super(PrimarySkillType.FISHING);
} }
@ -58,19 +55,19 @@ public class FishingCommand extends SkillCommand {
lootTier = fishingManager.getLootTier(); lootTier = fishingManager.getLootTier();
// Item drop rates // Item drop rates
commonTreasure = percent.format(TreasureConfig.getInstance().getItemDropRate(lootTier, Rarity.COMMON) / 100.0); commonTreasure = percent.format(FishingTreasureConfig.getInstance().getItemDropRate(lootTier, Rarity.COMMON) / 100.0);
uncommonTreasure = percent.format(TreasureConfig.getInstance().getItemDropRate(lootTier, Rarity.UNCOMMON) / 100.0); uncommonTreasure = percent.format(FishingTreasureConfig.getInstance().getItemDropRate(lootTier, Rarity.UNCOMMON) / 100.0);
rareTreasure = percent.format(TreasureConfig.getInstance().getItemDropRate(lootTier, Rarity.RARE) / 100.0); rareTreasure = percent.format(FishingTreasureConfig.getInstance().getItemDropRate(lootTier, Rarity.RARE) / 100.0);
epicTreasure = percent.format(TreasureConfig.getInstance().getItemDropRate(lootTier, Rarity.EPIC) / 100.0); epicTreasure = percent.format(FishingTreasureConfig.getInstance().getItemDropRate(lootTier, Rarity.EPIC) / 100.0);
legendaryTreasure = percent.format(TreasureConfig.getInstance().getItemDropRate(lootTier, Rarity.LEGENDARY) / 100.0); legendaryTreasure = percent.format(FishingTreasureConfig.getInstance().getItemDropRate(lootTier, Rarity.LEGENDARY) / 100.0);
recordTreasure = percent.format(TreasureConfig.getInstance().getItemDropRate(lootTier, Rarity.RECORD) / 100.0); mythicTreasure = percent.format(FishingTreasureConfig.getInstance().getItemDropRate(lootTier, Rarity.MYTHIC) / 100.0);
// Magic hunter drop rates // Magic hunter drop rates
double totalEnchantChance = 0; double totalEnchantChance = 0;
for (Rarity rarity : Rarity.values()) { for (Rarity rarity : Rarity.values()) {
if (rarity != Rarity.RECORD) { if (rarity != Rarity.MYTHIC) {
totalEnchantChance += TreasureConfig.getInstance().getEnchantmentDropRate(lootTier, rarity); totalEnchantChance += FishingTreasureConfig.getInstance().getEnchantmentDropRate(lootTier, rarity);
} }
} }
@ -94,25 +91,8 @@ public class FishingCommand extends SkillCommand {
// MASTER ANGLER // MASTER ANGLER
if (canMasterAngler) { if (canMasterAngler) {
double rawBiteChance = 1.0 / (player.getWorld().hasStorm() ? 300 : 500); maMinWaitTime = StringUtils.ticksToSeconds(fishingManager.getMasterAnglerTickMinWaitReduction(RankUtils.getRank(player, SubSkillType.FISHING_MASTER_ANGLER), false));
maMaxWaitTime = StringUtils.ticksToSeconds(fishingManager.getMasterAnglerTickMaxWaitReduction(RankUtils.getRank(player, SubSkillType.FISHING_MASTER_ANGLER), false, 0));
Location location = fishingManager.getHookLocation();
if (location == null) {
location = player.getLocation();
}
if (Fishing.masterAnglerBiomes.contains(location.getBlock().getBiome())) {
rawBiteChance = rawBiteChance * AdvancedConfig.getInstance().getMasterAnglerBiomeModifier();
}
if (player.isInsideVehicle() && player.getVehicle().getType() == EntityType.BOAT) {
rawBiteChance = rawBiteChance * AdvancedConfig.getInstance().getMasterAnglerBoatModifier();
}
double luckyModifier = Permissions.lucky(player, PrimarySkillType.FISHING) ? 1.333D : 1.0D;
biteChance = percent.format((rawBiteChance * 100.0D) * luckyModifier);
} }
} }
@ -122,13 +102,13 @@ public class FishingCommand extends SkillCommand {
canMagicHunt = canUseSubskill(player, SubSkillType.FISHING_MAGIC_HUNTER) && 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); canShake = canUseSubskill(player, SubSkillType.FISHING_SHAKE);
canFishermansDiet = canUseSubskill(player, SubSkillType.FISHING_FISHERMANS_DIET); canFishermansDiet = canUseSubskill(player, SubSkillType.FISHING_FISHERMANS_DIET);
canMasterAngler = canUseSubskill(player, SubSkillType.FISHING_MASTER_ANGLER); canMasterAngler = mcMMO.getCompatibilityManager().getMasterAnglerCompatibilityLayer() != null && canUseSubskill(player, SubSkillType.FISHING_MASTER_ANGLER);
canIceFish = canUseSubskill(player, SubSkillType.FISHING_ICE_FISHING); canIceFish = canUseSubskill(player, SubSkillType.FISHING_ICE_FISHING);
} }
@Override @Override
protected List<String> statsDisplay(Player player, float skillValue, boolean hasEndurance, boolean isLucky) { protected List<String> statsDisplay(Player player, float skillValue, boolean hasEndurance, boolean isLucky) {
List<String> messages = new ArrayList<String>(); List<String> messages = new ArrayList<>();
if (canFishermansDiet) { if (canFishermansDiet) {
messages.add(getStatMessage(false, true, SubSkillType.FISHING_FISHERMANS_DIET, String.valueOf(fishermansDietRank))); messages.add(getStatMessage(false, true, SubSkillType.FISHING_FISHERMANS_DIET, String.valueOf(fishermansDietRank)));
@ -143,8 +123,13 @@ public class FishingCommand extends SkillCommand {
} }
if (canMasterAngler) { if (canMasterAngler) {
//TODO: Update this with more details messages.add(getStatMessage(false,true,
messages.add(getStatMessage(false, true, SubSkillType.FISHING_MASTER_ANGLER, biteChance)); SubSkillType.FISHING_MASTER_ANGLER,
maMinWaitTime));
messages.add(getStatMessage(true,true,
SubSkillType.FISHING_MASTER_ANGLER,
maMaxWaitTime));
} }
if (canShake) { if (canShake) {
@ -160,15 +145,15 @@ public class FishingCommand extends SkillCommand {
String.valueOf(rareTreasure), String.valueOf(rareTreasure),
String.valueOf(epicTreasure), String.valueOf(epicTreasure),
String.valueOf(legendaryTreasure), String.valueOf(legendaryTreasure),
String.valueOf(recordTreasure))); String.valueOf(mythicTreasure)));
} }
return messages; return messages;
} }
@Override @Override
protected List<TextComponent> getTextComponents(Player player) { protected List<Component> getTextComponents(Player player) {
List<TextComponent> textComponents = new ArrayList<>(); List<Component> textComponents = new ArrayList<>();
TextComponentFactory.getSubSkillTextComponents(player, textComponents, PrimarySkillType.FISHING); TextComponentFactory.getSubSkillTextComponents(player, textComponents, PrimarySkillType.FISHING);

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