mirror of
https://github.com/mcMMO-Dev/mcMMO.git
synced 2024-11-24 06:06:45 +01:00
Merge branch 'mcMMO-Dev:master' into master
This commit is contained in:
commit
33b801b3e5
52
.github/workflows/maven.yml
vendored
Normal file
52
.github/workflows/maven.yml
vendored
Normal 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
11
1
@ -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
|
||||
#
|
1163
Changelog.txt
1163
Changelog.txt
File diff suppressed because it is too large
Load Diff
@ -99,10 +99,6 @@ Woodcutting:
|
||||
Double_Drops_Enabled: true
|
||||
Is_Log: true
|
||||
# Fir Quarters
|
||||
X2209|1:
|
||||
XP_Gain: 80
|
||||
Double_Drops_Enabled: true
|
||||
Is_Log: true
|
||||
X2211|1:
|
||||
XP_Gain: 100
|
||||
Double_Drops_Enabled: true
|
||||
@ -116,10 +112,6 @@ Woodcutting:
|
||||
Double_Drops_Enabled: true
|
||||
Is_Log: true
|
||||
# Oak Quarters
|
||||
X2209|2:
|
||||
XP_Gain: 70
|
||||
Double_Drops_Enabled: true
|
||||
Is_Log: true
|
||||
X2211|2:
|
||||
XP_Gain: 100
|
||||
Double_Drops_Enabled: true
|
||||
@ -133,15 +125,7 @@ Woodcutting:
|
||||
Double_Drops_Enabled: true
|
||||
Is_Log: true
|
||||
# Acacia
|
||||
X2209|1:
|
||||
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
|
||||
X2225|0:
|
||||
XP_Gain: 90
|
||||
|
@ -366,25 +366,7 @@ Axes:
|
||||
###
|
||||
Bows:
|
||||
#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
|
||||
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
|
||||
|
@ -68,17 +68,7 @@ Chestplates:
|
||||
Repair_Material_Quantity: 8
|
||||
Durability: 320
|
||||
# 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
|
||||
X28035:
|
||||
Repairable: false
|
||||
Durability: 480
|
||||
|
||||
Helmets:
|
||||
# Ironwood
|
||||
@ -106,17 +96,7 @@ Helmets:
|
||||
Repair_Material_Quantity: 5
|
||||
Durability: 220
|
||||
# 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
|
||||
X28034:
|
||||
Repairable: false
|
||||
Durability: 330
|
||||
|
||||
Leggings:
|
||||
# Ironwood
|
||||
|
196
pom.xml
196
pom.xml
@ -2,7 +2,7 @@
|
||||
<modelVersion>4.0.0</modelVersion>
|
||||
<groupId>com.gmail.nossr50.mcMMO</groupId>
|
||||
<artifactId>mcMMO</artifactId>
|
||||
<version>2.1.126-SNAPSHOT</version>
|
||||
<version>2.1.210-SNAPSHOT</version>
|
||||
<name>mcMMO</name>
|
||||
<url>https://github.com/mcMMO-Dev/mcMMO</url>
|
||||
<scm>
|
||||
@ -11,11 +11,29 @@
|
||||
<developerConnection>scm:git:git@github.com:mcMMO-Dev/mcMMO.git</developerConnection>
|
||||
<tag>HEAD</tag>
|
||||
</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>
|
||||
<url>https://github.com/mcMMO-Dev/mcMMO/issues</url>
|
||||
<system>GitHub</system>
|
||||
</issueManagement>
|
||||
<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>
|
||||
<finalName>${project.artifactId}</finalName>
|
||||
<sourceDirectory>${basedir}/src/main/java</sourceDirectory>
|
||||
@ -55,6 +73,25 @@
|
||||
</resource>
|
||||
</resources>
|
||||
<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>
|
||||
<groupId>org.apache.maven.plugins</groupId>
|
||||
<artifactId>maven-release-plugin</artifactId>
|
||||
@ -63,10 +100,12 @@
|
||||
<plugin>
|
||||
<groupId>org.apache.maven.plugins</groupId>
|
||||
<artifactId>maven-compiler-plugin</artifactId>
|
||||
<version>2.3.2</version>
|
||||
<version>3.8.1</version>
|
||||
<configuration>
|
||||
<source>1.8</source>
|
||||
<target>1.8</target>
|
||||
<release>16</release>
|
||||
<compilerArgs>
|
||||
<arg>-parameters</arg> <!-- used for ACF syntax stuff -->
|
||||
</compilerArgs>
|
||||
<excludes>
|
||||
</excludes>
|
||||
</configuration>
|
||||
@ -91,32 +130,64 @@
|
||||
<plugin>
|
||||
<groupId>org.apache.maven.plugins</groupId>
|
||||
<artifactId>maven-shade-plugin</artifactId>
|
||||
<version>3.1.1</version>
|
||||
<version>3.3.0-SNAPSHOT</version>
|
||||
<configuration>
|
||||
<artifactSet>
|
||||
<includes>
|
||||
<include>commons-logging:commons-logging</include>
|
||||
<include>org.apache.tomcat:tomcat-jdbc</include>
|
||||
<include>org.apache.tomcat:tomcat-juli</include>
|
||||
<include>org.bstats:bstats-base</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>
|
||||
</artifactSet>
|
||||
<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>
|
||||
<pattern>org.apache.commons.logging</pattern>
|
||||
<shadedPattern>com.gmail.nossr50.commons.logging</shadedPattern>
|
||||
<shadedPattern>com.gmail.nossr50.mcmmo.commons.logging</shadedPattern>
|
||||
</relocation>
|
||||
<relocation>
|
||||
<pattern>org.apache.juli</pattern>
|
||||
<shadedPattern>com.gmail.nossr50.database.tomcat.juli</shadedPattern>
|
||||
<shadedPattern>com.gmail.nossr50.mcmmo.database.tomcat.juli</shadedPattern>
|
||||
</relocation>
|
||||
<relocation>
|
||||
<pattern>org.apache.tomcat</pattern>
|
||||
<shadedPattern>com.gmail.nossr50.database.tomcat</shadedPattern>
|
||||
<shadedPattern>com.gmail.nossr50.mcmmo.database.tomcat</shadedPattern>
|
||||
</relocation>
|
||||
<relocation>
|
||||
<pattern>org.bstats</pattern>
|
||||
<shadedPattern>com.gmail.nossr50.metrics.bstat</shadedPattern>
|
||||
<shadedPattern>com.gmail.nossr50.mcmmo.metrics.bstats</shadedPattern>
|
||||
</relocation>
|
||||
</relocations>
|
||||
</configuration>
|
||||
@ -138,6 +209,13 @@
|
||||
</extension>
|
||||
</extensions>
|
||||
</build>
|
||||
<pluginRepositories>
|
||||
<pluginRepository>
|
||||
<id>maven-snapshots</id>
|
||||
<url>https://repository.apache.org/content/repositories/snapshots/</url>
|
||||
</pluginRepository>
|
||||
</pluginRepositories>
|
||||
|
||||
<repositories>
|
||||
<repository>
|
||||
<id>spigot-repo</id>
|
||||
@ -149,31 +227,90 @@
|
||||
</repository>
|
||||
<repository>
|
||||
<id>sk89q-repo</id>
|
||||
<url>http://maven.sk89q.com/repo/</url>
|
||||
<url>https://maven.sk89q.com/repo/</url>
|
||||
</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>
|
||||
<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>
|
||||
<groupId>org.apache.maven.scm</groupId>
|
||||
<artifactId>maven-scm-provider-gitexe</artifactId>
|
||||
<version>1.8.1</version>
|
||||
<version>1.12.0</version>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>org.bstats</groupId>
|
||||
<artifactId>bstats-bukkit</artifactId>
|
||||
<version>1.4</version>
|
||||
<version>2.2.1</version>
|
||||
<scope>compile</scope>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>org.spigotmc</groupId>
|
||||
<artifactId>spigot-api</artifactId>
|
||||
<version>1.15.2-R0.1-SNAPSHOT</version>
|
||||
<version>1.18.1-R0.1-SNAPSHOT</version>
|
||||
<scope>provided</scope>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>com.sk89q.worldguard</groupId>
|
||||
<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>
|
||||
<groupId>com.sk89q.worldguard</groupId>
|
||||
@ -187,24 +324,39 @@
|
||||
</exclusions>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>junit</groupId>
|
||||
<artifactId>junit-dep</artifactId>
|
||||
<version>4.10</version>
|
||||
<groupId>org.junit.jupiter</groupId>
|
||||
<artifactId>junit-jupiter</artifactId>
|
||||
<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>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>org.apache.tomcat</groupId>
|
||||
<artifactId>tomcat-jdbc</artifactId>
|
||||
<version>7.0.52</version>
|
||||
<version>10.0.14</version>
|
||||
<scope>compile</scope>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>org.jetbrains</groupId>
|
||||
<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>
|
||||
</dependencies>
|
||||
<properties>
|
||||
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
|
||||
</properties>
|
||||
</project>
|
||||
|
@ -2,7 +2,7 @@ package com.gmail.nossr50.api;
|
||||
|
||||
import com.gmail.nossr50.datatypes.player.McMMOPlayer;
|
||||
import com.gmail.nossr50.datatypes.skills.SuperAbilityType;
|
||||
import com.gmail.nossr50.runnables.skills.BleedTimerTask;
|
||||
import com.gmail.nossr50.util.MetadataConstants;
|
||||
import com.gmail.nossr50.util.player.UserManager;
|
||||
import org.bukkit.entity.LivingEntity;
|
||||
import org.bukkit.entity.Player;
|
||||
@ -83,6 +83,12 @@ public final class AbilityAPI {
|
||||
}
|
||||
|
||||
public static boolean isBleeding(LivingEntity entity) {
|
||||
return BleedTimerTask.isBleeding(entity);
|
||||
if(entity.isValid()) {
|
||||
if(entity.hasMetadata(MetadataConstants.METADATA_KEY_RUPTURE)) {
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
@ -1,72 +1,68 @@
|
||||
package com.gmail.nossr50.api;
|
||||
|
||||
import com.gmail.nossr50.chat.ChatManager;
|
||||
import com.gmail.nossr50.chat.ChatManagerFactory;
|
||||
import com.gmail.nossr50.chat.PartyChatManager;
|
||||
import com.gmail.nossr50.datatypes.chat.ChatMode;
|
||||
import com.gmail.nossr50.party.PartyManager;
|
||||
import com.gmail.nossr50.datatypes.chat.ChatChannel;
|
||||
import com.gmail.nossr50.mcMMO;
|
||||
import com.gmail.nossr50.util.player.UserManager;
|
||||
import org.bukkit.entity.Player;
|
||||
import org.bukkit.plugin.Plugin;
|
||||
|
||||
public final class ChatAPI {
|
||||
private ChatAPI() {}
|
||||
|
||||
/**
|
||||
* Send a message to all members of a party
|
||||
* </br>
|
||||
* This function is designed for API usage.
|
||||
*
|
||||
* @param plugin The plugin sending the message
|
||||
* @param sender The name of the sender
|
||||
* @param displayName The display name of the sender
|
||||
* @param party The name of the party to send to
|
||||
* @param message The message to send
|
||||
*/
|
||||
public static void sendPartyChat(Plugin plugin, String sender, String displayName, String party, String message) {
|
||||
getPartyChatManager(plugin, party).handleChat(sender, displayName, message);
|
||||
}
|
||||
|
||||
/**
|
||||
* Send a message to all members of a party
|
||||
* </br>
|
||||
* This function is designed for API usage.
|
||||
*
|
||||
* @param plugin The plugin sending the message
|
||||
* @param sender The name of the sender to display in the chat
|
||||
* @param party The name of the party to send to
|
||||
* @param message The message to send
|
||||
*/
|
||||
public static void sendPartyChat(Plugin plugin, String sender, String party, String message) {
|
||||
getPartyChatManager(plugin, party).handleChat(sender, message);
|
||||
}
|
||||
|
||||
/**
|
||||
* Send a message to administrators
|
||||
* </br>
|
||||
* This function is designed for API usage.
|
||||
*
|
||||
* @param plugin The plugin sending the message
|
||||
* @param sender The name of the sender
|
||||
* @param displayName The display name of the sender
|
||||
* @param message The message to send
|
||||
*/
|
||||
public static void sendAdminChat(Plugin plugin, String sender, String displayName, String message) {
|
||||
ChatManagerFactory.getChatManager(plugin, ChatMode.ADMIN).handleChat(sender, displayName, message);
|
||||
}
|
||||
|
||||
/**
|
||||
* Send a message to administrators
|
||||
* </br>
|
||||
* This function is designed for API usage.
|
||||
*
|
||||
* @param plugin The plugin sending the message
|
||||
* @param sender The name of the sender to display in the chat
|
||||
* @param message The message to send
|
||||
*/
|
||||
public static void sendAdminChat(Plugin plugin, String sender, String message) {
|
||||
ChatManagerFactory.getChatManager(plugin, ChatMode.ADMIN).handleChat(sender, message);
|
||||
}
|
||||
// /**
|
||||
// * Send a message to all members of a party
|
||||
// * </br>
|
||||
// * This function is designed for API usage.
|
||||
// *
|
||||
// * @param plugin The plugin sending the message
|
||||
// * @param sender The name of the sender
|
||||
// * @param displayName The display name of the sender
|
||||
// * @param party The name of the party to send to
|
||||
// * @param message The message to send
|
||||
// */
|
||||
// public static void sendPartyChat(Plugin plugin, String sender, String displayName, String party, String message) {
|
||||
// getPartyChatManager(plugin, party).handleChat(sender, displayName, message);
|
||||
// }
|
||||
//
|
||||
// /**
|
||||
// * Send a message to all members of a party
|
||||
// * </br>
|
||||
// * This function is designed for API usage.
|
||||
// *
|
||||
// * @param plugin The plugin sending the message
|
||||
// * @param sender The name of the sender to display in the chat
|
||||
// * @param party The name of the party to send to
|
||||
// * @param message The message to send
|
||||
// */
|
||||
// public static void sendPartyChat(Plugin plugin, String sender, String party, String message) {
|
||||
// getPartyChatManager(plugin, party).handleChat(sender, message);
|
||||
// }
|
||||
//
|
||||
// /**
|
||||
// * Send a message to administrators
|
||||
// * </br>
|
||||
// * This function is designed for API usage.
|
||||
// *
|
||||
// * @param plugin The plugin sending the message
|
||||
// * @param sender The name of the sender
|
||||
// * @param displayName The display name of the sender
|
||||
// * @param message The message to send
|
||||
// */
|
||||
// public static void sendAdminChat(Plugin plugin, String sender, String displayName, String message) {
|
||||
// ChatManagerFactory.getChatManager(plugin, ChatChannel.ADMIN).handleChat(sender, displayName, message);
|
||||
// }
|
||||
//
|
||||
// /**
|
||||
// * Send a message to administrators
|
||||
// * </br>
|
||||
// * This function is designed for API usage.
|
||||
// *
|
||||
// * @param plugin The plugin sending the message
|
||||
// * @param sender The name of the sender to display in the chat
|
||||
// * @param message The message to send
|
||||
// */
|
||||
// public static void sendAdminChat(Plugin plugin, String sender, String message) {
|
||||
// ChatManagerFactory.getChatManager(plugin, ChatChannel.ADMIN).handleChat(sender, message);
|
||||
// }
|
||||
|
||||
/**
|
||||
* 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
|
||||
*/
|
||||
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
|
||||
*/
|
||||
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
|
||||
*/
|
||||
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
|
||||
*/
|
||||
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.
|
||||
*/
|
||||
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.
|
||||
*/
|
||||
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.
|
||||
*/
|
||||
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.
|
||||
*/
|
||||
public static void toggleAdminChat(String playerName) {
|
||||
UserManager.getPlayer(playerName).toggleChat(ChatMode.ADMIN);
|
||||
}
|
||||
|
||||
private static ChatManager getPartyChatManager(Plugin plugin, String party) {
|
||||
ChatManager chatManager = ChatManagerFactory.getChatManager(plugin, ChatMode.PARTY);
|
||||
((PartyChatManager) chatManager).setParty(PartyManager.getParty(party));
|
||||
|
||||
return chatManager;
|
||||
mcMMO.p.getChatManager().setOrToggleChatChannel(UserManager.getPlayer(playerName), ChatChannel.ADMIN);
|
||||
}
|
||||
}
|
||||
|
@ -2,6 +2,8 @@ package com.gmail.nossr50.api;
|
||||
|
||||
import com.gmail.nossr50.datatypes.player.PlayerProfile;
|
||||
import com.gmail.nossr50.mcMMO;
|
||||
import org.bukkit.OfflinePlayer;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
|
||||
import java.util.UUID;
|
||||
|
||||
@ -9,20 +11,38 @@ public class DatabaseAPI {
|
||||
|
||||
/**
|
||||
* 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
|
||||
*/
|
||||
public boolean doesPlayerExistInDB(String uuid) {
|
||||
return doesPlayerExistInDB(UUID.fromString(uuid));
|
||||
public boolean doesPlayerExistInDB(@NotNull OfflinePlayer offlinePlayer) {
|
||||
PlayerProfile playerProfile = mcMMO.getDatabaseManager().loadPlayerProfile(offlinePlayer);
|
||||
|
||||
return playerProfile.isLoaded();
|
||||
}
|
||||
|
||||
/**
|
||||
* 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
|
||||
*/
|
||||
public boolean doesPlayerExistInDB(UUID uuid) {
|
||||
PlayerProfile playerProfile = mcMMO.getDatabaseManager().loadPlayerProfile(uuid);
|
||||
public boolean doesPlayerExistInDB(@NotNull UUID 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();
|
||||
}
|
||||
|
@ -1,7 +1,6 @@
|
||||
package com.gmail.nossr50.api;
|
||||
|
||||
import com.gmail.nossr50.api.exceptions.*;
|
||||
import com.gmail.nossr50.config.Config;
|
||||
import com.gmail.nossr50.config.experience.ExperienceConfig;
|
||||
import com.gmail.nossr50.datatypes.experience.FormulaType;
|
||||
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.skills.child.FamilyTree;
|
||||
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.entity.LivingEntity;
|
||||
import org.bukkit.entity.Player;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.Set;
|
||||
@ -32,7 +36,36 @@ public final class ExperienceAPI {
|
||||
* @return true if this is a valid mcMMO skill
|
||||
*/
|
||||
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
|
||||
*/
|
||||
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
|
||||
@ -262,11 +295,12 @@ public final class ExperienceAPI {
|
||||
PrimarySkillType skill = getSkillType(skillType);
|
||||
|
||||
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;
|
||||
}
|
||||
|
||||
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) {
|
||||
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));
|
||||
}
|
||||
|
||||
/**
|
||||
* 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.
|
||||
* </br>
|
||||
@ -449,6 +500,30 @@ public final class ExperienceAPI {
|
||||
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.
|
||||
* </br>
|
||||
@ -496,10 +571,27 @@ public final class ExperienceAPI {
|
||||
* @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(UUID uuid, String skillType) {
|
||||
public static int getOfflineXPToNextLevel(@NotNull UUID uuid, @NotNull String 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.
|
||||
* </br>
|
||||
@ -561,6 +653,26 @@ public final class ExperienceAPI {
|
||||
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.
|
||||
* </br>
|
||||
@ -593,7 +705,7 @@ public final class ExperienceAPI {
|
||||
PlayerProfile profile = getOfflineProfile(playerName);
|
||||
PrimarySkillType skill = getSkillType(skillType);
|
||||
|
||||
if (skill.isChildSkill()) {
|
||||
if (SkillTools.isChildSkill(skill)) {
|
||||
Set<PrimarySkillType> parentSkills = FamilyTree.getParents(skill);
|
||||
|
||||
for (PrimarySkillType parentSkill : parentSkills) {
|
||||
@ -624,7 +736,7 @@ public final class ExperienceAPI {
|
||||
PlayerProfile profile = getOfflineProfile(uuid);
|
||||
PrimarySkillType skill = getSkillType(skillType);
|
||||
|
||||
if (skill.isChildSkill()) {
|
||||
if (SkillTools.isChildSkill(skill)) {
|
||||
Set<PrimarySkillType> parentSkills = FamilyTree.getParents(skill);
|
||||
|
||||
for (PrimarySkillType parentSkill : parentSkills) {
|
||||
@ -683,7 +795,6 @@ public final class ExperienceAPI {
|
||||
* @throws InvalidSkillException if the given skill is not valid
|
||||
* @throws InvalidPlayerException if the given player does not exist in the database
|
||||
*/
|
||||
@Deprecated
|
||||
public static int getLevelOffline(String playerName, String skillType) {
|
||||
return getOfflineProfile(playerName).getSkillLevel(getSkillType(skillType));
|
||||
}
|
||||
@ -731,7 +842,7 @@ public final class ExperienceAPI {
|
||||
int powerLevel = 0;
|
||||
PlayerProfile profile = getOfflineProfile(playerName);
|
||||
|
||||
for (PrimarySkillType type : PrimarySkillType.NON_CHILD_SKILLS) {
|
||||
for (PrimarySkillType type : SkillTools.NON_CHILD_SKILLS) {
|
||||
powerLevel += profile.getSkillLevel(type);
|
||||
}
|
||||
|
||||
@ -752,7 +863,7 @@ public final class ExperienceAPI {
|
||||
int powerLevel = 0;
|
||||
PlayerProfile profile = getOfflineProfile(uuid);
|
||||
|
||||
for (PrimarySkillType type : PrimarySkillType.NON_CHILD_SKILLS) {
|
||||
for (PrimarySkillType type : SkillTools.NON_CHILD_SKILLS) {
|
||||
powerLevel += profile.getSkillLevel(type);
|
||||
}
|
||||
|
||||
@ -770,7 +881,7 @@ public final class ExperienceAPI {
|
||||
* @throws InvalidSkillException if the given skill is not valid
|
||||
*/
|
||||
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
|
||||
*/
|
||||
public static int getPowerLevelCap() {
|
||||
return Config.getInstance().getPowerLevelCap();
|
||||
return mcMMO.p.getGeneralConfig().getPowerLevelCap();
|
||||
}
|
||||
|
||||
/**
|
||||
@ -1095,25 +1206,22 @@ public final class ExperienceAPI {
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
// 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);
|
||||
|
||||
profile.addXp(skill, XP);
|
||||
profile.save(true);
|
||||
}
|
||||
|
||||
@Deprecated
|
||||
private static void addOfflineXP(String playerName, PrimarySkillType skill, int XP) {
|
||||
private static void addOfflineXP(@NotNull String playerName, @NotNull PrimarySkillType skill, int XP) {
|
||||
PlayerProfile profile = getOfflineProfile(playerName);
|
||||
|
||||
profile.addXp(skill, XP);
|
||||
profile.scheduleAsyncSave();
|
||||
}
|
||||
|
||||
private static PlayerProfile getOfflineProfile(UUID uuid) {
|
||||
private static @NotNull PlayerProfile getOfflineProfile(@NotNull UUID uuid) throws InvalidPlayerException {
|
||||
PlayerProfile profile = mcMMO.getDatabaseManager().loadPlayerProfile(uuid);
|
||||
|
||||
if (!profile.isLoaded()) {
|
||||
@ -1123,10 +1231,18 @@ public final class ExperienceAPI {
|
||||
return profile;
|
||||
}
|
||||
|
||||
@Deprecated
|
||||
private static PlayerProfile getOfflineProfile(String playerName) {
|
||||
UUID uuid = mcMMO.p.getServer().getOfflinePlayer(playerName).getUniqueId();
|
||||
PlayerProfile profile = mcMMO.getDatabaseManager().loadPlayerProfile(uuid);
|
||||
private static @NotNull PlayerProfile getOfflineProfile(@NotNull OfflinePlayer offlinePlayer) throws InvalidPlayerException {
|
||||
PlayerProfile profile = mcMMO.getDatabaseManager().loadPlayerProfile(offlinePlayer);
|
||||
|
||||
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()) {
|
||||
throw new InvalidPlayerException();
|
||||
@ -1136,7 +1252,7 @@ public final class ExperienceAPI {
|
||||
}
|
||||
|
||||
private static PrimarySkillType getSkillType(String skillType) throws InvalidSkillException {
|
||||
PrimarySkillType skill = PrimarySkillType.getSkill(skillType);
|
||||
PrimarySkillType skill = mcMMO.p.getSkillTools().matchSkill(skillType);
|
||||
|
||||
if (skill == null) {
|
||||
throw new InvalidSkillException();
|
||||
@ -1148,7 +1264,7 @@ public final class ExperienceAPI {
|
||||
private static PrimarySkillType getNonChildSkillType(String skillType) throws InvalidSkillException, UnsupportedOperationException {
|
||||
PrimarySkillType skill = getSkillType(skillType);
|
||||
|
||||
if (skill.isChildSkill()) {
|
||||
if (SkillTools.isChildSkill(skill)) {
|
||||
throw new UnsupportedOperationException("Child skills do not have XP");
|
||||
}
|
||||
|
||||
|
17
src/main/java/com/gmail/nossr50/api/ItemSpawnReason.java
Normal file
17
src/main/java/com/gmail/nossr50/api/ItemSpawnReason.java
Normal 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
|
||||
}
|
@ -1,6 +1,5 @@
|
||||
package com.gmail.nossr50.api;
|
||||
|
||||
import com.gmail.nossr50.config.Config;
|
||||
import com.gmail.nossr50.datatypes.interactions.NotificationType;
|
||||
import com.gmail.nossr50.datatypes.party.Party;
|
||||
import com.gmail.nossr50.datatypes.party.PartyLeader;
|
||||
@ -108,7 +107,7 @@ public final class PartyAPI {
|
||||
*/
|
||||
public static int getMaxPartySize()
|
||||
{
|
||||
return Config.getInstance().getPartyMaxSize();
|
||||
return mcMMO.p.getGeneralConfig().getPartyMaxSize();
|
||||
}
|
||||
|
||||
/**
|
||||
@ -185,7 +184,7 @@ public final class PartyAPI {
|
||||
*/
|
||||
@Deprecated
|
||||
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()) {
|
||||
OfflinePlayer member = mcMMO.p.getServer().getOfflinePlayer(memberUniqueId);
|
||||
|
@ -1,6 +1,8 @@
|
||||
package com.gmail.nossr50.api;
|
||||
|
||||
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.Arrays;
|
||||
@ -30,7 +32,7 @@ public final class SkillAPI {
|
||||
* @return a list of strings with valid skill names
|
||||
*/
|
||||
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
|
||||
*/
|
||||
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
|
||||
*/
|
||||
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
|
||||
*/
|
||||
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
|
||||
*/
|
||||
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) {
|
||||
List<String> skills = new ArrayList<String>();
|
||||
List<String> skills = new ArrayList<>();
|
||||
|
||||
for (PrimarySkillType primarySkillType : skillsTypes) {
|
||||
skills.add(primarySkillType.name());
|
||||
|
@ -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);
|
||||
}
|
||||
}
|
@ -6,4 +6,8 @@ public class InvalidSkillException extends RuntimeException {
|
||||
public InvalidSkillException() {
|
||||
super("That is not a valid skill.");
|
||||
}
|
||||
|
||||
public InvalidSkillException(String msg) {
|
||||
super(msg);
|
||||
}
|
||||
}
|
||||
|
@ -1,11 +1,12 @@
|
||||
package com.gmail.nossr50.api.exceptions;
|
||||
|
||||
import org.bukkit.entity.Player;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
|
||||
public class McMMOPlayerNotFoundException extends RuntimeException {
|
||||
private static final long serialVersionUID = 761917904993202836L;
|
||||
|
||||
public McMMOPlayerNotFoundException(Player player) {
|
||||
super("McMMOPlayer object was not found for [NOTE: This can mean the profile is not loaded yet!] : " + player.getName() + " " + player.getUniqueId());
|
||||
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());
|
||||
}
|
||||
}
|
||||
|
@ -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");
|
||||
}
|
||||
}
|
@ -1,88 +1,225 @@
|
||||
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.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.util.player.UserManager;
|
||||
import org.bukkit.entity.Player;
|
||||
import org.bukkit.plugin.Plugin;
|
||||
import com.gmail.nossr50.mcMMO;
|
||||
import com.gmail.nossr50.util.Misc;
|
||||
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 {
|
||||
protected Plugin plugin;
|
||||
protected boolean useDisplayNames;
|
||||
protected String chatPrefix;
|
||||
//TODO: Micro optimization - Cache audiences and update cache when needed
|
||||
public class ChatManager {
|
||||
|
||||
protected String senderName;
|
||||
protected String displayName;
|
||||
protected String message;
|
||||
private final @NotNull AdminChatMailer adminChatMailer;
|
||||
private final @NotNull PartyChatMailer partyChatMailer;
|
||||
|
||||
protected ChatManager(Plugin plugin, boolean useDisplayNames, String chatPrefix) {
|
||||
this.plugin = plugin;
|
||||
this.useDisplayNames = useDisplayNames;
|
||||
this.chatPrefix = chatPrefix;
|
||||
private final @NotNull ConsoleAuthor consoleAuthor;
|
||||
private final @NotNull Audience consoleAudience;
|
||||
|
||||
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();
|
||||
displayName = useDisplayNames ? event.getDisplayName() : senderName;
|
||||
message = LocaleLoader.formatString(chatPrefix, displayName) + " " + event.getMessage();
|
||||
return stringBuilder.toString();
|
||||
}
|
||||
|
||||
sendMessage();
|
||||
|
||||
/*
|
||||
* Party Chat Spying
|
||||
* Party messages will be copied to people with the mcmmo.admin.chatspy permission node
|
||||
*/
|
||||
if(event instanceof McMMOPartyChatEvent)
|
||||
{
|
||||
//We need to grab the party chat name
|
||||
McMMOPartyChatEvent partyChatEvent = (McMMOPartyChatEvent) event;
|
||||
|
||||
//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));
|
||||
}
|
||||
/**
|
||||
* Whether or not the player is allowed to send a message to the chat channel they are targeting
|
||||
* @param mmoPlayer target player
|
||||
* @return true if the player can send messages to that chat channel
|
||||
*/
|
||||
public boolean isMessageAllowed(@NotNull McMMOPlayer mmoPlayer) {
|
||||
switch (mmoPlayer.getChatChannel()) {
|
||||
case ADMIN:
|
||||
if(mmoPlayer.getPlayer().isOp() || Permissions.adminChat(mmoPlayer.getPlayer())) {
|
||||
return true;
|
||||
}
|
||||
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();
|
||||
}
|
@ -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;
|
||||
}
|
||||
}
|
||||
}
|
@ -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);
|
||||
}
|
||||
}
|
36
src/main/java/com/gmail/nossr50/chat/SamePartyPredicate.java
Normal file
36
src/main/java/com/gmail/nossr50/chat/SamePartyPredicate.java
Normal 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;
|
||||
}
|
||||
}
|
@ -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);
|
||||
}
|
||||
}
|
31
src/main/java/com/gmail/nossr50/chat/author/Author.java
Normal file
31
src/main/java/com/gmail/nossr50/chat/author/Author.java
Normal 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();
|
||||
}
|
@ -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;
|
||||
}
|
||||
}
|
@ -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));
|
||||
}
|
||||
|
||||
}
|
@ -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;
|
||||
}
|
||||
}
|
@ -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);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
}
|
12
src/main/java/com/gmail/nossr50/chat/mailer/ChatMailer.java
Normal file
12
src/main/java/com/gmail/nossr50/chat/mailer/ChatMailer.java
Normal 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);
|
||||
}
|
@ -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();
|
||||
}
|
||||
}
|
@ -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);
|
||||
}
|
||||
}
|
@ -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);
|
||||
}
|
||||
}
|
@ -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();
|
||||
}
|
@ -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);
|
||||
}
|
||||
}
|
116
src/main/java/com/gmail/nossr50/commands/CommandManager.java
Normal file
116
src/main/java/com/gmail/nossr50/commands/CommandManager.java
Normal 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;
|
||||
}
|
||||
}
|
@ -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();
|
||||
}
|
||||
}
|
@ -7,6 +7,7 @@ import org.bukkit.Material;
|
||||
import org.bukkit.command.Command;
|
||||
import org.bukkit.command.CommandExecutor;
|
||||
import org.bukkit.command.CommandSender;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
|
||||
import java.io.*;
|
||||
import java.util.ArrayList;
|
||||
@ -17,15 +18,12 @@ public class McImportCommand implements CommandExecutor {
|
||||
int fileAmount;
|
||||
|
||||
@Override
|
||||
public boolean onCommand(CommandSender sender, Command command, String label, String[] args) {
|
||||
switch (args.length) {
|
||||
case 0:
|
||||
importModConfig();
|
||||
return true;
|
||||
|
||||
default:
|
||||
return false;
|
||||
public boolean onCommand(@NotNull CommandSender sender, @NotNull Command command, @NotNull String label, String[] args) {
|
||||
if (args.length == 0) {
|
||||
importModConfig();
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
public boolean importModConfig() {
|
||||
@ -34,7 +32,7 @@ public class McImportCommand implements CommandExecutor {
|
||||
mcMMO.p.getLogger().info("Starting import of mod materials...");
|
||||
fileAmount = 0;
|
||||
|
||||
HashMap<ModConfigType, ArrayList<String>> materialNames = new HashMap<ModConfigType, ArrayList<String>>();
|
||||
HashMap<ModConfigType, ArrayList<String>> materialNames = new HashMap<>();
|
||||
|
||||
BufferedReader in = null;
|
||||
|
||||
@ -66,11 +64,10 @@ public class McImportCommand implements CommandExecutor {
|
||||
ModConfigType type = ModConfigType.getModConfigType(materialName);
|
||||
|
||||
if (!materialNames.containsKey(type)) {
|
||||
materialNames.put(type, new ArrayList<String>());
|
||||
materialNames.put(type, new ArrayList<>());
|
||||
}
|
||||
|
||||
materialNames.get(type).add(materialName);
|
||||
continue;
|
||||
}
|
||||
}
|
||||
catch (FileNotFoundException e) {
|
||||
@ -94,13 +91,13 @@ public class McImportCommand implements CommandExecutor {
|
||||
|
||||
private void createOutput(HashMap<ModConfigType, ArrayList<String>> materialNames) {
|
||||
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)) {
|
||||
String modName = Misc.getModName(materialName);
|
||||
|
||||
if (!materialNamesType.containsKey(modName)) {
|
||||
materialNamesType.put(modName, new ArrayList<String>());
|
||||
materialNamesType.put(modName, new ArrayList<>());
|
||||
}
|
||||
|
||||
materialNamesType.get(modName).add(materialName);
|
||||
@ -170,16 +167,10 @@ public class McImportCommand implements CommandExecutor {
|
||||
|
||||
out = new FileWriter(outputFile);
|
||||
out.write(writer.toString());
|
||||
}
|
||||
catch (IOException e) {
|
||||
} catch (Exception e) {
|
||||
e.printStackTrace();
|
||||
return;
|
||||
}
|
||||
catch (Exception e) {
|
||||
e.printStackTrace();
|
||||
return;
|
||||
}
|
||||
finally {
|
||||
} finally {
|
||||
tryClose(out);
|
||||
fileAmount++;
|
||||
}
|
||||
@ -202,7 +193,7 @@ public class McImportCommand implements CommandExecutor {
|
||||
}
|
||||
|
||||
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
|
||||
for (String materialName : materialNames.get(modName)) {
|
||||
@ -221,7 +212,7 @@ public class McImportCommand implements CommandExecutor {
|
||||
}
|
||||
|
||||
if (!configSections.containsKey(skillName)) {
|
||||
configSections.put(skillName, new ArrayList<String>());
|
||||
configSections.put(skillName, new ArrayList<>());
|
||||
}
|
||||
|
||||
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) {
|
||||
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
|
||||
for (String materialName : materialNames.get(modName)) {
|
||||
@ -266,7 +257,7 @@ public class McImportCommand implements CommandExecutor {
|
||||
}
|
||||
|
||||
if (!configSections.containsKey(toolType)) {
|
||||
configSections.put(toolType, new ArrayList<String>());
|
||||
configSections.put(toolType, new ArrayList<>());
|
||||
}
|
||||
|
||||
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) {
|
||||
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
|
||||
for (String materialName : materialNames.get(modName)) {
|
||||
@ -300,7 +291,7 @@ public class McImportCommand implements CommandExecutor {
|
||||
}
|
||||
|
||||
if (!configSections.containsKey(toolType)) {
|
||||
configSections.put(toolType, new ArrayList<String>());
|
||||
configSections.put(toolType, new ArrayList<>());
|
||||
}
|
||||
|
||||
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) {
|
||||
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
|
||||
for (String materialName : materialNames.get(modName)) {
|
||||
String configKey = "UNIDENTIFIED";
|
||||
|
||||
if (!configSections.containsKey(configKey)) {
|
||||
configSections.put(configKey, new ArrayList<String>());
|
||||
configSections.put(configKey, new ArrayList<>());
|
||||
}
|
||||
|
||||
ArrayList<String> skillContents = configSections.get(configKey);
|
||||
|
@ -12,6 +12,7 @@ import org.bukkit.command.CommandExecutor;
|
||||
import org.bukkit.command.CommandSender;
|
||||
import org.bukkit.command.TabExecutor;
|
||||
import org.bukkit.util.StringUtil;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
|
||||
import java.util.ArrayList;
|
||||
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> SUBCOMMANDS = ImmutableList.of("database", "experience");
|
||||
|
||||
private CommandExecutor databaseConvertCommand = new ConvertDatabaseCommand();
|
||||
private CommandExecutor experienceConvertCommand = new ConvertExperienceCommand();
|
||||
private final CommandExecutor databaseConvertCommand = new ConvertDatabaseCommand();
|
||||
private final CommandExecutor experienceConvertCommand = new ConvertExperienceCommand();
|
||||
|
||||
static {
|
||||
ArrayList<String> formulaTypes = new ArrayList<String>();
|
||||
ArrayList<String> databaseTypes = new ArrayList<String>();
|
||||
ArrayList<String> formulaTypes = new ArrayList<>();
|
||||
ArrayList<String> databaseTypes = new ArrayList<>();
|
||||
|
||||
for (FormulaType type : FormulaType.values()) {
|
||||
formulaTypes.add(type.toString());
|
||||
@ -53,34 +54,31 @@ public class McconvertCommand implements TabExecutor {
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean onCommand(CommandSender sender, Command command, String label, String[] args) {
|
||||
switch (args.length) {
|
||||
case 2:
|
||||
if (args[0].equalsIgnoreCase("database") || args[0].equalsIgnoreCase("db")) {
|
||||
return databaseConvertCommand.onCommand(sender, command, label, args);
|
||||
}
|
||||
else if (args[0].equalsIgnoreCase("experience") || args[0].equalsIgnoreCase("xp") || args[1].equalsIgnoreCase("exp")) {
|
||||
return experienceConvertCommand.onCommand(sender, command, label, args);
|
||||
}
|
||||
public boolean onCommand(@NotNull CommandSender sender, @NotNull Command command, @NotNull String label, String[] args) {
|
||||
if (args.length == 2) {
|
||||
if (args[0].equalsIgnoreCase("database") || args[0].equalsIgnoreCase("db")) {
|
||||
return databaseConvertCommand.onCommand(sender, command, label, args);
|
||||
} else if (args[0].equalsIgnoreCase("experience") || args[0].equalsIgnoreCase("xp") || args[1].equalsIgnoreCase("exp")) {
|
||||
return experienceConvertCommand.onCommand(sender, command, label, args);
|
||||
}
|
||||
|
||||
return false;
|
||||
default:
|
||||
return false;
|
||||
return false;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
@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) {
|
||||
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:
|
||||
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")) {
|
||||
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();
|
||||
|
@ -1,7 +1,6 @@
|
||||
package com.gmail.nossr50.commands;
|
||||
|
||||
import com.gmail.nossr50.commands.party.PartySubcommandType;
|
||||
import com.gmail.nossr50.config.Config;
|
||||
import com.gmail.nossr50.locale.LocaleLoader;
|
||||
import com.gmail.nossr50.mcMMO;
|
||||
import com.gmail.nossr50.util.Permissions;
|
||||
@ -9,10 +8,11 @@ import org.bukkit.ChatColor;
|
||||
import org.bukkit.command.Command;
|
||||
import org.bukkit.command.CommandExecutor;
|
||||
import org.bukkit.command.CommandSender;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
|
||||
public class McmmoCommand implements CommandExecutor {
|
||||
@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) {
|
||||
case 0:
|
||||
if (!Permissions.mcmmoDescription(sender)) {
|
||||
@ -25,7 +25,7 @@ public class McmmoCommand implements CommandExecutor {
|
||||
sender.sendMessage(mcSplit);
|
||||
sender.sendMessage(LocaleLoader.getString("mcMMO.Description.FormerDevs"));
|
||||
|
||||
if (Config.getInstance().getDonateMessageEnabled()) {
|
||||
if (mcMMO.p.getGeneralConfig().getDonateMessageEnabled()) {
|
||||
sender.sendMessage(LocaleLoader.getString("MOTD.Donate"));
|
||||
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()));
|
||||
}
|
||||
|
||||
mcMMO.getHolidayManager().anniversaryCheck(sender);
|
||||
// mcMMO.getHolidayManager().anniversaryCheck(sender);
|
||||
return true;
|
||||
|
||||
case 1:
|
||||
|
@ -9,35 +9,33 @@ import org.bukkit.command.Command;
|
||||
import org.bukkit.command.CommandSender;
|
||||
import org.bukkit.command.TabExecutor;
|
||||
import org.bukkit.entity.Player;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
public class McnotifyCommand implements TabExecutor {
|
||||
@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)) {
|
||||
return true;
|
||||
}
|
||||
|
||||
switch (args.length) {
|
||||
case 0:
|
||||
McMMOPlayer mcMMOPlayer = UserManager.getPlayer((Player) sender);
|
||||
if (args.length == 0) {
|
||||
McMMOPlayer mcMMOPlayer = UserManager.getPlayer((Player) sender);
|
||||
|
||||
//Not Loaded yet
|
||||
if(mcMMOPlayer == null)
|
||||
sender.sendMessage(LocaleLoader.getString("Profile.PendingLoad"));
|
||||
//Not Loaded yet
|
||||
if (mcMMOPlayer == null)
|
||||
sender.sendMessage(LocaleLoader.getString("Profile.PendingLoad"));
|
||||
|
||||
sender.sendMessage(LocaleLoader.getString("Commands.Notifications." + (mcMMOPlayer.useChatNotifications() ? "Off" : "On")));
|
||||
mcMMOPlayer.toggleChatNotifications();
|
||||
return true;
|
||||
|
||||
default:
|
||||
return false;
|
||||
sender.sendMessage(LocaleLoader.getString("Commands.Notifications." + (mcMMOPlayer.useChatNotifications() ? "Off" : "On")));
|
||||
mcMMOPlayer.toggleChatNotifications();
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
@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();
|
||||
}
|
||||
}
|
||||
|
@ -1,7 +1,7 @@
|
||||
package com.gmail.nossr50.commands;
|
||||
|
||||
import com.gmail.nossr50.config.Config;
|
||||
import com.gmail.nossr50.locale.LocaleLoader;
|
||||
import com.gmail.nossr50.mcMMO;
|
||||
import com.gmail.nossr50.util.commands.CommandUtils;
|
||||
import com.gmail.nossr50.util.scoreboards.ScoreboardManager;
|
||||
import com.google.common.collect.ImmutableList;
|
||||
@ -9,6 +9,7 @@ import org.bukkit.command.Command;
|
||||
import org.bukkit.command.CommandSender;
|
||||
import org.bukkit.command.TabExecutor;
|
||||
import org.bukkit.util.StringUtil;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
|
||||
import java.util.ArrayList;
|
||||
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");
|
||||
|
||||
@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)) {
|
||||
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) {
|
||||
case 1:
|
||||
if (args[0].equalsIgnoreCase("clear") || args[0].equalsIgnoreCase("reset")) {
|
||||
@ -31,7 +42,7 @@ public class McscoreboardCommand implements TabExecutor {
|
||||
}
|
||||
|
||||
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"));
|
||||
return true;
|
||||
}
|
||||
@ -69,13 +80,11 @@ public class McscoreboardCommand implements TabExecutor {
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<String> onTabComplete(CommandSender sender, Command command, String alias, String[] args) {
|
||||
switch (args.length) {
|
||||
case 1:
|
||||
return StringUtil.copyPartialMatches(args[0], FIRST_ARGS, new ArrayList<String>(FIRST_ARGS.size()));
|
||||
default:
|
||||
return ImmutableList.of();
|
||||
public List<String> onTabComplete(@NotNull CommandSender sender, @NotNull Command command, @NotNull String alias, String[] args) {
|
||||
if (args.length == 1) {
|
||||
return StringUtil.copyPartialMatches(args[0], FIRST_ARGS, new ArrayList<>(FIRST_ARGS.size()));
|
||||
}
|
||||
return ImmutableList.of();
|
||||
}
|
||||
|
||||
private boolean help(CommandSender sender) {
|
||||
|
@ -8,13 +8,14 @@ import org.bukkit.command.Command;
|
||||
import org.bukkit.command.CommandSender;
|
||||
import org.bukkit.command.TabExecutor;
|
||||
import org.bukkit.util.StringUtil;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
public abstract class ToggleCommand implements TabExecutor {
|
||||
@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) {
|
||||
case 0:
|
||||
if (CommandUtils.noConsoleUsage(sender)) {
|
||||
@ -60,14 +61,12 @@ public abstract class ToggleCommand implements TabExecutor {
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<String> onTabComplete(CommandSender sender, Command command, String alias, String[] args) {
|
||||
switch (args.length) {
|
||||
case 1:
|
||||
List<String> playerNames = CommandUtils.getOnlinePlayerNames(sender);
|
||||
return StringUtil.copyPartialMatches(args[0], playerNames, new ArrayList<String>(playerNames.size()));
|
||||
default:
|
||||
return ImmutableList.of();
|
||||
public List<String> onTabComplete(@NotNull CommandSender sender, @NotNull Command command, @NotNull String alias, String[] args) {
|
||||
if (args.length == 1) {
|
||||
List<String> playerNames = CommandUtils.getOnlinePlayerNames(sender);
|
||||
return StringUtil.copyPartialMatches(args[0], playerNames, new ArrayList<>(playerNames.size()));
|
||||
}
|
||||
return ImmutableList.of();
|
||||
}
|
||||
|
||||
protected abstract boolean hasOtherPermission(CommandSender sender);
|
||||
|
@ -1,21 +1,20 @@
|
||||
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.datatypes.notifications.SensitiveCommandType;
|
||||
import com.gmail.nossr50.locale.LocaleLoader;
|
||||
import com.gmail.nossr50.mcMMO;
|
||||
import com.gmail.nossr50.util.Permissions;
|
||||
import com.gmail.nossr50.util.StringUtils;
|
||||
import com.gmail.nossr50.util.commands.CommandUtils;
|
||||
import com.gmail.nossr50.util.player.NotificationManager;
|
||||
import com.gmail.nossr50.util.text.StringUtils;
|
||||
import com.google.common.collect.ImmutableList;
|
||||
import org.bukkit.ChatColor;
|
||||
import org.bukkit.command.Command;
|
||||
import org.bukkit.command.CommandSender;
|
||||
import org.bukkit.command.TabExecutor;
|
||||
import org.bukkit.util.StringUtil;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
@ -24,7 +23,7 @@ public class XprateCommand implements TabExecutor {
|
||||
private final double ORIGINAL_XP_RATE = ExperienceConfig.getInstance().getExperienceGainsGlobalMultiplier();
|
||||
|
||||
@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) {
|
||||
case 1:
|
||||
if (!args[0].equalsIgnoreCase("reset") && !args[0].equalsIgnoreCase("clear")) {
|
||||
@ -38,7 +37,7 @@ public class XprateCommand implements TabExecutor {
|
||||
|
||||
if (mcMMO.p.isXPEventEnabled()) {
|
||||
|
||||
if(AdvancedConfig.getInstance().useTitlesForXPEvent())
|
||||
if(mcMMO.p.getAdvancedConfig().useTitlesForXPEvent())
|
||||
{
|
||||
NotificationManager.broadcastTitle(mcMMO.p.getServer(),
|
||||
LocaleLoader.getString("Commands.Event.Stop"),
|
||||
@ -46,7 +45,7 @@ public class XprateCommand implements TabExecutor {
|
||||
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.Subtitle"));
|
||||
@ -91,7 +90,7 @@ public class XprateCommand implements TabExecutor {
|
||||
|
||||
ExperienceConfig.getInstance().setExperienceGainsGlobalMultiplier(newXpRate);
|
||||
|
||||
if(AdvancedConfig.getInstance().useTitlesForXPEvent())
|
||||
if(mcMMO.p.getAdvancedConfig().useTitlesForXPEvent())
|
||||
{
|
||||
NotificationManager.broadcastTitle(mcMMO.p.getServer(),
|
||||
LocaleLoader.getString("Commands.Event.Start"),
|
||||
@ -99,7 +98,7 @@ public class XprateCommand implements TabExecutor {
|
||||
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.XP", newXpRate));
|
||||
@ -116,16 +115,16 @@ public class XprateCommand implements TabExecutor {
|
||||
}
|
||||
|
||||
@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) {
|
||||
case 1:
|
||||
if (StringUtils.isInt(args[0])) {
|
||||
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:
|
||||
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:
|
||||
return ImmutableList.of();
|
||||
}
|
||||
|
@ -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;
|
||||
// }
|
||||
// }
|
||||
//}
|
@ -5,26 +5,25 @@ import com.gmail.nossr50.util.Permissions;
|
||||
import org.bukkit.command.Command;
|
||||
import org.bukkit.command.CommandExecutor;
|
||||
import org.bukkit.command.CommandSender;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
|
||||
/**
|
||||
* @author Mark Vainomaa
|
||||
*/
|
||||
public final class McmmoReloadLocaleCommand implements CommandExecutor {
|
||||
@Override
|
||||
public boolean onCommand(CommandSender sender, Command command, String label, String[] args) {
|
||||
switch (args.length) {
|
||||
case 0:
|
||||
if (!Permissions.reloadlocale(sender)) {
|
||||
sender.sendMessage(command.getPermissionMessage());
|
||||
return true;
|
||||
}
|
||||
|
||||
LocaleLoader.reloadLocale();
|
||||
sender.sendMessage(LocaleLoader.getString("Locale.Reloaded"));
|
||||
|
||||
public boolean onCommand(@NotNull CommandSender sender, @NotNull Command command, @NotNull String label, String[] args) {
|
||||
if (args.length == 0) {
|
||||
if (!Permissions.reloadlocale(sender)) {
|
||||
sender.sendMessage(command.getPermissionMessage());
|
||||
return true;
|
||||
default:
|
||||
return false;
|
||||
}
|
||||
|
||||
LocaleLoader.reloadLocale();
|
||||
sender.sendMessage(LocaleLoader.getString("Locale.Reloaded"));
|
||||
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
@ -7,11 +7,12 @@ 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 PlayerDebugCommand implements CommandExecutor {
|
||||
|
||||
@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) {
|
||||
McMMOPlayer mcMMOPlayer = UserManager.getPlayer((Player) sender);
|
||||
mcMMOPlayer.toggleDebugMode(); //Toggle debug mode
|
||||
|
@ -1,15 +1,52 @@
|
||||
package com.gmail.nossr50.commands.chat;
|
||||
|
||||
import com.gmail.nossr50.datatypes.chat.ChatMode;
|
||||
import org.bukkit.command.CommandSender;
|
||||
import co.aikar.commands.BaseCommand;
|
||||
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 {
|
||||
public AdminChatCommand() {
|
||||
super(ChatMode.ADMIN);
|
||||
@CommandPermission("mcmmo.chat.adminchat")
|
||||
@CommandAlias("ac|a|adminchat|achat") //Kept for historical reasons
|
||||
public class AdminChatCommand extends BaseCommand {
|
||||
private final @NotNull mcMMO pluginRef;
|
||||
|
||||
public AdminChatCommand(@NotNull mcMMO pluginRef) {
|
||||
this.pluginRef = pluginRef;
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void handleChatSending(CommandSender sender, String[] args) {
|
||||
chatManager.handleChat(sender.getName(), getDisplayName(sender), buildChatMessage(args, 0));
|
||||
@Default @Conditions(CommandManager.ADMIN_CONDITION)
|
||||
public void processCommand(String[] args) {
|
||||
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
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -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());
|
||||
}
|
||||
}
|
@ -1,62 +1,90 @@
|
||||
package com.gmail.nossr50.commands.chat;
|
||||
|
||||
import com.gmail.nossr50.chat.PartyChatManager;
|
||||
import com.gmail.nossr50.config.Config;
|
||||
import com.gmail.nossr50.datatypes.chat.ChatMode;
|
||||
import co.aikar.commands.BaseCommand;
|
||||
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.party.Party;
|
||||
import com.gmail.nossr50.datatypes.party.PartyFeature;
|
||||
import com.gmail.nossr50.locale.LocaleLoader;
|
||||
import com.gmail.nossr50.datatypes.player.McMMOPlayer;
|
||||
import com.gmail.nossr50.mcMMO;
|
||||
import com.gmail.nossr50.party.PartyManager;
|
||||
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.jetbrains.annotations.NotNull;
|
||||
|
||||
public class PartyChatCommand extends ChatCommand {
|
||||
public PartyChatCommand() {
|
||||
super(ChatMode.PARTY);
|
||||
@CommandPermission("mcmmo.chat.partychat")
|
||||
@CommandAlias("pc|p|partychat|pchat") //Kept for historical reasons
|
||||
public class PartyChatCommand extends BaseCommand {
|
||||
private final @NotNull mcMMO pluginRef;
|
||||
|
||||
public PartyChatCommand(@NotNull mcMMO pluginRef) {
|
||||
this.pluginRef = pluginRef;
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void handleChatSending(CommandSender sender, String[] args) {
|
||||
Party party;
|
||||
String message;
|
||||
@Default
|
||||
@Conditions(CommandManager.PARTY_CONDITION)
|
||||
public void processCommand(String[] args) {
|
||||
BukkitCommandIssuer bukkitCommandIssuer = (BukkitCommandIssuer) getCurrentCommandIssuer();
|
||||
|
||||
if (sender instanceof Player) {
|
||||
//Check if player profile is loaded
|
||||
if(UserManager.getPlayer((Player) sender) == null)
|
||||
return;
|
||||
|
||||
party = UserManager.getPlayer((Player) sender).getParty();
|
||||
|
||||
if (party == null) {
|
||||
sender.sendMessage(LocaleLoader.getString("Commands.Party.None"));
|
||||
return;
|
||||
if(args == null || args.length == 0) {
|
||||
//Process with no arguments
|
||||
if(bukkitCommandIssuer.isPlayer()) {
|
||||
McMMOPlayer mmoPlayer = UserManager.getPlayer(bukkitCommandIssuer.getPlayer());
|
||||
pluginRef.getChatManager().setOrToggleChatChannel(mmoPlayer, ChatChannel.PARTY);
|
||||
} else {
|
||||
//Not support for console
|
||||
mcMMO.p.getLogger().info("You cannot switch chat channels as console, please provide full arguments.");
|
||||
}
|
||||
} 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"));
|
||||
return;
|
||||
/*
|
||||
* Player Logic
|
||||
*/
|
||||
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);
|
||||
}
|
||||
}
|
||||
|
@ -13,62 +13,63 @@ 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 ConvertDatabaseCommand implements CommandExecutor {
|
||||
@Override
|
||||
public boolean onCommand(CommandSender sender, Command command, String label, String[] args) {
|
||||
switch (args.length) {
|
||||
case 2:
|
||||
DatabaseType previousType = DatabaseType.getDatabaseType(args[1]);
|
||||
DatabaseType newType = mcMMO.getDatabaseManager().getDatabaseType();
|
||||
public boolean onCommand(@NotNull CommandSender sender, @NotNull Command command, @NotNull String label, String[] args) {
|
||||
if (args.length == 2) {
|
||||
DatabaseType previousType = DatabaseType.getDatabaseType(args[1]);
|
||||
DatabaseType newType = mcMMO.getDatabaseManager().getDatabaseType();
|
||||
|
||||
if (previousType == newType || (newType == DatabaseType.CUSTOM && DatabaseManagerFactory.getCustomDatabaseManagerClass().getSimpleName().equalsIgnoreCase(args[1]))) {
|
||||
sender.sendMessage(LocaleLoader.getString("Commands.mcconvert.Database.Same", newType.toString()));
|
||||
return true;
|
||||
}
|
||||
if (previousType == newType || (newType == DatabaseType.CUSTOM && DatabaseManagerFactory.getCustomDatabaseManagerClass().getSimpleName().equalsIgnoreCase(args[1]))) {
|
||||
sender.sendMessage(LocaleLoader.getString("Commands.mcconvert.Database.Same", newType.toString()));
|
||||
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) {
|
||||
Class<?> clazz;
|
||||
if (previousType == DatabaseType.CUSTOM) {
|
||||
Class<?> clazz;
|
||||
|
||||
try {
|
||||
clazz = Class.forName(args[1]);
|
||||
try {
|
||||
clazz = Class.forName(args[1]);
|
||||
|
||||
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();
|
||||
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]));
|
||||
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();
|
||||
UserManager.clearAll();
|
||||
|
||||
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;
|
||||
new DatabaseConversionTask(oldDatabase, sender, previousType.toString(), newType.toString()).runTaskAsynchronously(mcMMO.p);
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
@ -1,36 +1,33 @@
|
||||
package com.gmail.nossr50.commands.database;
|
||||
|
||||
import com.gmail.nossr50.config.Config;
|
||||
import com.gmail.nossr50.locale.LocaleLoader;
|
||||
import com.gmail.nossr50.mcMMO;
|
||||
import com.google.common.collect.ImmutableList;
|
||||
import org.bukkit.command.Command;
|
||||
import org.bukkit.command.CommandSender;
|
||||
import org.bukkit.command.TabExecutor;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
public class McpurgeCommand implements TabExecutor {
|
||||
@Override
|
||||
public boolean onCommand(CommandSender sender, Command command, String label, String[] args) {
|
||||
switch (args.length) {
|
||||
case 0:
|
||||
mcMMO.getDatabaseManager().purgePowerlessUsers();
|
||||
public boolean onCommand(@NotNull CommandSender sender, @NotNull Command command, @NotNull String label, String[] args) {
|
||||
if (args.length == 0) {
|
||||
mcMMO.getDatabaseManager().purgePowerlessUsers();
|
||||
|
||||
if (Config.getInstance().getOldUsersCutoff() != -1) {
|
||||
mcMMO.getDatabaseManager().purgeOldUsers();
|
||||
}
|
||||
if (mcMMO.p.getGeneralConfig().getOldUsersCutoff() != -1) {
|
||||
mcMMO.getDatabaseManager().purgeOldUsers();
|
||||
}
|
||||
|
||||
sender.sendMessage(LocaleLoader.getString("Commands.mcpurge.Success"));
|
||||
return true;
|
||||
|
||||
default:
|
||||
return false;
|
||||
sender.sendMessage(LocaleLoader.getString("Commands.mcpurge.Success"));
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
@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();
|
||||
}
|
||||
}
|
||||
|
@ -10,6 +10,7 @@ import org.bukkit.command.Command;
|
||||
import org.bukkit.command.CommandSender;
|
||||
import org.bukkit.command.TabExecutor;
|
||||
import org.bukkit.util.StringUtil;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
@ -17,43 +18,37 @@ import java.util.UUID;
|
||||
|
||||
public class McremoveCommand implements TabExecutor {
|
||||
@Override
|
||||
public boolean onCommand(CommandSender sender, Command command, String label, String[] args) {
|
||||
switch (args.length) {
|
||||
case 1:
|
||||
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.
|
||||
}
|
||||
public boolean onCommand(@NotNull CommandSender sender, @NotNull Command command, @NotNull String label, String[] args) {
|
||||
if (args.length == 1) {
|
||||
String playerName = CommandUtils.getMatchedPlayerName(args[0]);
|
||||
|
||||
if (UserManager.getOfflinePlayer(playerName) == null && CommandUtils.unloadedProfile(sender, mcMMO.getDatabaseManager().loadPlayerProfile(playerName))) {
|
||||
return true;
|
||||
}
|
||||
|
||||
default:
|
||||
return false;
|
||||
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.
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<String> onTabComplete(CommandSender sender, Command command, String alias, String[] args) {
|
||||
switch (args.length) {
|
||||
case 1:
|
||||
List<String> playerNames = CommandUtils.getOnlinePlayerNames(sender);
|
||||
return StringUtil.copyPartialMatches(args[0], playerNames, new ArrayList<String>(playerNames.size()));
|
||||
default:
|
||||
return ImmutableList.of();
|
||||
public List<String> onTabComplete(@NotNull CommandSender sender, @NotNull Command command, @NotNull String alias, String[] args) {
|
||||
if (args.length == 1) {
|
||||
List<String> playerNames = CommandUtils.getOnlinePlayerNames(sender);
|
||||
return StringUtil.copyPartialMatches(args[0], playerNames, new ArrayList<>(playerNames.size()));
|
||||
}
|
||||
return ImmutableList.of();
|
||||
}
|
||||
}
|
||||
|
@ -1,37 +1,35 @@
|
||||
package com.gmail.nossr50.commands.database;
|
||||
|
||||
import com.gmail.nossr50.config.Config;
|
||||
import com.gmail.nossr50.database.DatabaseManagerFactory;
|
||||
import com.gmail.nossr50.locale.LocaleLoader;
|
||||
import com.gmail.nossr50.mcMMO;
|
||||
import com.google.common.collect.ImmutableList;
|
||||
import org.bukkit.command.Command;
|
||||
import org.bukkit.command.CommandSender;
|
||||
import org.bukkit.command.TabExecutor;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
public class MmoshowdbCommand implements TabExecutor {
|
||||
@Override
|
||||
public boolean onCommand(CommandSender sender, Command command, String label, String[] args) {
|
||||
switch (args.length) {
|
||||
case 0:
|
||||
Class<?> clazz = DatabaseManagerFactory.getCustomDatabaseManagerClass();
|
||||
public boolean onCommand(@NotNull CommandSender sender, @NotNull Command command, @NotNull String label, String[] args) {
|
||||
if (args.length == 0) {
|
||||
Class<?> clazz = DatabaseManagerFactory.getCustomDatabaseManagerClass();
|
||||
|
||||
if (clazz != null) {
|
||||
sender.sendMessage(LocaleLoader.getString("Commands.mmoshowdb", clazz.getName()));
|
||||
return true;
|
||||
}
|
||||
|
||||
sender.sendMessage(LocaleLoader.getString("Commands.mmoshowdb", (Config.getInstance().getUseMySQL() ? "sql" : "flatfile")));
|
||||
if (clazz != null) {
|
||||
sender.sendMessage(LocaleLoader.getString("Commands.mmoshowdb", clazz.getName()));
|
||||
return true;
|
||||
}
|
||||
|
||||
default:
|
||||
return false;
|
||||
sender.sendMessage(LocaleLoader.getString("Commands.mmoshowdb", (mcMMO.p.getGeneralConfig().getUseMySQL() ? "sql" : "flatfile")));
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
@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();
|
||||
}
|
||||
}
|
||||
|
@ -1,11 +1,14 @@
|
||||
package com.gmail.nossr50.commands.experience;
|
||||
|
||||
import com.gmail.nossr50.datatypes.experience.XPGainReason;
|
||||
import com.gmail.nossr50.datatypes.player.McMMOPlayer;
|
||||
import com.gmail.nossr50.datatypes.player.PlayerProfile;
|
||||
import com.gmail.nossr50.datatypes.skills.PrimarySkillType;
|
||||
import com.gmail.nossr50.locale.LocaleLoader;
|
||||
import com.gmail.nossr50.mcMMO;
|
||||
import com.gmail.nossr50.util.EventUtils;
|
||||
import com.gmail.nossr50.util.Permissions;
|
||||
import com.gmail.nossr50.util.player.UserManager;
|
||||
import org.bukkit.command.CommandSender;
|
||||
import org.bukkit.entity.Player;
|
||||
|
||||
@ -30,16 +33,29 @@ public class AddlevelsCommand extends ExperienceCommand {
|
||||
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
|
||||
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));
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void handlePlayerMessageSkill(Player player, int value, PrimarySkillType skill) {
|
||||
player.sendMessage(LocaleLoader.getString("Commands.addlevels.AwardSkill.1", value, skill.getName()));
|
||||
protected void handlePlayerMessageSkill(Player player, int value, PrimarySkillType skill, boolean isSilent) {
|
||||
if(isSilent)
|
||||
return;
|
||||
|
||||
player.sendMessage(LocaleLoader.getString("Commands.addlevels.AwardSkill.1", value, mcMMO.p.getSkillTools().getLocalizedSkillName(skill)));
|
||||
}
|
||||
}
|
||||
|
@ -5,6 +5,7 @@ import com.gmail.nossr50.datatypes.experience.XPGainSource;
|
||||
import com.gmail.nossr50.datatypes.player.PlayerProfile;
|
||||
import com.gmail.nossr50.datatypes.skills.PrimarySkillType;
|
||||
import com.gmail.nossr50.locale.LocaleLoader;
|
||||
import com.gmail.nossr50.mcMMO;
|
||||
import com.gmail.nossr50.util.Permissions;
|
||||
import com.gmail.nossr50.util.player.UserManager;
|
||||
import org.bukkit.command.CommandSender;
|
||||
@ -37,12 +38,18 @@ public class AddxpCommand extends ExperienceCommand {
|
||||
}
|
||||
|
||||
@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));
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void handlePlayerMessageSkill(Player player, int value, PrimarySkillType skill) {
|
||||
player.sendMessage(LocaleLoader.getString("Commands.addxp.AwardSkill", value, skill.getName()));
|
||||
protected void handlePlayerMessageSkill(Player player, int value, PrimarySkillType skill, boolean isSilent) {
|
||||
if(isSilent)
|
||||
return;
|
||||
|
||||
player.sendMessage(LocaleLoader.getString("Commands.addxp.AwardSkill", value, mcMMO.p.getSkillTools().getLocalizedSkillName(skill)));
|
||||
}
|
||||
}
|
||||
|
@ -10,42 +10,40 @@ 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;
|
||||
|
||||
import java.util.Locale;
|
||||
|
||||
public class ConvertExperienceCommand implements CommandExecutor {
|
||||
@Override
|
||||
public boolean onCommand(CommandSender sender, Command command, String label, String[] args) {
|
||||
switch (args.length) {
|
||||
case 2:
|
||||
FormulaType previousType = mcMMO.getFormulaManager().getPreviousFormulaType();
|
||||
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
|
||||
}
|
||||
public boolean onCommand(@NotNull CommandSender sender, @NotNull Command command, @NotNull String label, String[] args) {
|
||||
if (args.length == 2) {
|
||||
FormulaType previousType = mcMMO.getFormulaManager().getPreviousFormulaType();
|
||||
FormulaType newType = FormulaType.getFormulaType(args[1].toUpperCase(Locale.ENGLISH));
|
||||
|
||||
if (newType == FormulaType.UNKNOWN) {
|
||||
sender.sendMessage(LocaleLoader.getString("Commands.mcconvert.Experience.Invalid"));
|
||||
return true;
|
||||
}
|
||||
|
||||
default:
|
||||
return false;
|
||||
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
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
@ -7,31 +7,35 @@ 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.gmail.nossr50.util.skills.SkillTools;
|
||||
import com.google.common.collect.ImmutableList;
|
||||
import org.bukkit.OfflinePlayer;
|
||||
import org.bukkit.command.Command;
|
||||
import org.bukkit.command.CommandSender;
|
||||
import org.bukkit.command.TabExecutor;
|
||||
import org.bukkit.entity.Player;
|
||||
import org.bukkit.util.StringUtil;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
import java.util.UUID;
|
||||
|
||||
public abstract class ExperienceCommand implements TabExecutor {
|
||||
@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;
|
||||
|
||||
switch (args.length) {
|
||||
case 2:
|
||||
if(args.length < 2) {
|
||||
return false;
|
||||
} else {
|
||||
if(args.length == 2 && !isSilent(args) || args.length == 3 && isSilent(args)) {
|
||||
if (CommandUtils.noConsoleUsage(sender)) {
|
||||
return true;
|
||||
}
|
||||
|
||||
if (!permissionsCheckSelf(sender)) {
|
||||
sender.sendMessage(command.getPermissionMessage());
|
||||
if(command.getPermissionMessage() != null)
|
||||
sender.sendMessage(command.getPermissionMessage());
|
||||
sender.sendMessage("(mcMMO) No permission!");
|
||||
return true;
|
||||
}
|
||||
|
||||
@ -39,13 +43,13 @@ public abstract class ExperienceCommand implements TabExecutor {
|
||||
return true;
|
||||
}
|
||||
|
||||
skill = PrimarySkillType.getSkill(args[0]);
|
||||
skill = mcMMO.p.getSkillTools().matchSkill(args[0]);
|
||||
|
||||
if (args[1].equalsIgnoreCase("all")) {
|
||||
skill = null;
|
||||
}
|
||||
|
||||
if (skill != null && skill.isChildSkill())
|
||||
if (skill != null && SkillTools.isChildSkill(skill))
|
||||
{
|
||||
sender.sendMessage(LocaleLoader.getString("Commands.Skill.ChildSkill"));
|
||||
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;
|
||||
|
||||
case 3:
|
||||
} else if((args.length == 3 && !isSilent(args))
|
||||
|| (args.length == 4 && isSilent(args))) {
|
||||
if (!permissionsCheckOthers(sender)) {
|
||||
sender.sendMessage(command.getPermissionMessage());
|
||||
return true;
|
||||
@ -72,13 +76,13 @@ public abstract class ExperienceCommand implements TabExecutor {
|
||||
return true;
|
||||
}
|
||||
|
||||
skill = PrimarySkillType.getSkill(args[1]);
|
||||
skill = mcMMO.p.getSkillTools().matchSkill(args[1]);
|
||||
|
||||
if (args[1].equalsIgnoreCase("all")) {
|
||||
skill = null;
|
||||
}
|
||||
|
||||
if (skill != null && skill.isChildSkill())
|
||||
if (skill != null && SkillTools.isChildSkill(skill))
|
||||
{
|
||||
sender.sendMessage(LocaleLoader.getString("Commands.Skill.ChildSkill"));
|
||||
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 (mcMMOPlayer == null) {
|
||||
UUID uuid = null;
|
||||
OfflinePlayer player = mcMMO.p.getServer().getOfflinePlayer(playerName);
|
||||
if (player != null) {
|
||||
uuid = player.getUniqueId();
|
||||
}
|
||||
PlayerProfile profile = mcMMO.getDatabaseManager().loadPlayerProfile(playerName, uuid, false);
|
||||
PlayerProfile profile;
|
||||
|
||||
profile = mcMMO.getDatabaseManager().loadPlayerProfile(playerName);
|
||||
|
||||
//Check loading by UUID
|
||||
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 {
|
||||
editValues(mcMMOPlayer.getPlayer(), mcMMOPlayer.getProfile(), skill, value);
|
||||
editValues(mcMMOPlayer.getPlayer(), mcMMOPlayer.getProfile(), skill, value, isSilent(args));
|
||||
}
|
||||
|
||||
handleSenderMessage(sender, playerName, skill);
|
||||
return true;
|
||||
|
||||
default:
|
||||
} else {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private boolean isSilent(String[] args) {
|
||||
int length = args.length;
|
||||
|
||||
if(length == 0)
|
||||
return false;
|
||||
|
||||
return args[length-1].equalsIgnoreCase("-s");
|
||||
}
|
||||
|
||||
|
||||
@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) {
|
||||
case 1:
|
||||
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:
|
||||
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:
|
||||
return ImmutableList.of();
|
||||
}
|
||||
@ -132,8 +149,8 @@ public abstract class ExperienceCommand implements TabExecutor {
|
||||
protected abstract boolean permissionsCheckSelf(CommandSender sender);
|
||||
protected abstract boolean permissionsCheckOthers(CommandSender sender);
|
||||
protected abstract void handleCommand(Player player, PlayerProfile profile, PrimarySkillType skill, int value);
|
||||
protected abstract void handlePlayerMessageAll(Player player, int value);
|
||||
protected abstract void handlePlayerMessageSkill(Player player, int value, PrimarySkillType skill);
|
||||
protected abstract void handlePlayerMessageAll(Player player, int value, boolean isSilent);
|
||||
protected abstract void handlePlayerMessageSkill(Player player, int value, PrimarySkillType skill, boolean isSilent);
|
||||
|
||||
private boolean validateArguments(CommandSender sender, String skillName, String value) {
|
||||
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));
|
||||
}
|
||||
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) {
|
||||
for (PrimarySkillType primarySkillType : PrimarySkillType.NON_CHILD_SKILLS) {
|
||||
for (PrimarySkillType primarySkillType : SkillTools.NON_CHILD_SKILLS) {
|
||||
handleCommand(player, profile, primarySkillType, value);
|
||||
}
|
||||
|
||||
if (player != null) {
|
||||
handlePlayerMessageAll(player, value);
|
||||
handlePlayerMessageAll(player, value, isSilent);
|
||||
}
|
||||
}
|
||||
else {
|
||||
handleCommand(player, profile, skill, value);
|
||||
|
||||
if (player != null) {
|
||||
handlePlayerMessageSkill(player, value, skill);
|
||||
handlePlayerMessageSkill(player, value, skill, isSilent);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -1,11 +1,14 @@
|
||||
package com.gmail.nossr50.commands.experience;
|
||||
|
||||
import com.gmail.nossr50.datatypes.experience.XPGainReason;
|
||||
import com.gmail.nossr50.datatypes.player.McMMOPlayer;
|
||||
import com.gmail.nossr50.datatypes.player.PlayerProfile;
|
||||
import com.gmail.nossr50.datatypes.skills.PrimarySkillType;
|
||||
import com.gmail.nossr50.locale.LocaleLoader;
|
||||
import com.gmail.nossr50.mcMMO;
|
||||
import com.gmail.nossr50.util.EventUtils;
|
||||
import com.gmail.nossr50.util.Permissions;
|
||||
import com.gmail.nossr50.util.player.UserManager;
|
||||
import org.bukkit.command.CommandSender;
|
||||
import org.bukkit.entity.Player;
|
||||
|
||||
@ -36,16 +39,29 @@ public class MmoeditCommand extends ExperienceCommand {
|
||||
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
|
||||
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));
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void handlePlayerMessageSkill(Player player, int value, PrimarySkillType skill) {
|
||||
player.sendMessage(LocaleLoader.getString("Commands.mmoedit.Modified.1", skill.getName(), value));
|
||||
protected void handlePlayerMessageSkill(Player player, int value, PrimarySkillType skill, boolean isSilent) {
|
||||
if(isSilent)
|
||||
return;
|
||||
|
||||
player.sendMessage(LocaleLoader.getString("Commands.mmoedit.Modified.1", mcMMO.p.getSkillTools().getLocalizedSkillName(skill), value));
|
||||
}
|
||||
}
|
||||
|
@ -10,6 +10,7 @@ import com.gmail.nossr50.util.EventUtils;
|
||||
import com.gmail.nossr50.util.Permissions;
|
||||
import com.gmail.nossr50.util.commands.CommandUtils;
|
||||
import com.gmail.nossr50.util.player.UserManager;
|
||||
import com.gmail.nossr50.util.skills.SkillTools;
|
||||
import com.google.common.collect.ImmutableList;
|
||||
import org.bukkit.OfflinePlayer;
|
||||
import org.bukkit.command.Command;
|
||||
@ -17,10 +18,10 @@ 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 java.util.ArrayList;
|
||||
import java.util.List;
|
||||
import java.util.UUID;
|
||||
|
||||
/**
|
||||
* This class mirrors the structure of ExperienceCommand, except the
|
||||
@ -28,7 +29,7 @@ import java.util.UUID;
|
||||
*/
|
||||
public class SkillresetCommand implements TabExecutor {
|
||||
@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;
|
||||
switch (args.length) {
|
||||
case 1:
|
||||
@ -49,7 +50,7 @@ public class SkillresetCommand implements TabExecutor {
|
||||
skill = null;
|
||||
}
|
||||
else {
|
||||
skill = PrimarySkillType.getSkill(args[1]);
|
||||
skill = mcMMO.p.getSkillTools().matchSkill(args[0]);
|
||||
}
|
||||
|
||||
editValues((Player) sender, UserManager.getPlayer(sender.getName()).getProfile(), skill);
|
||||
@ -69,7 +70,7 @@ public class SkillresetCommand implements TabExecutor {
|
||||
skill = null;
|
||||
}
|
||||
else {
|
||||
skill = PrimarySkillType.getSkill(args[1]);
|
||||
skill = mcMMO.p.getSkillTools().matchSkill(args[1]);
|
||||
}
|
||||
|
||||
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 (mcMMOPlayer == null) {
|
||||
UUID uuid = null;
|
||||
OfflinePlayer player = mcMMO.p.getServer().getOfflinePlayer(playerName);
|
||||
if (player != null) {
|
||||
uuid = player.getUniqueId();
|
||||
}
|
||||
PlayerProfile profile = mcMMO.getDatabaseManager().loadPlayerProfile(playerName, uuid, false);
|
||||
OfflinePlayer offlinePlayer = mcMMO.p.getServer().getOfflinePlayer(playerName);
|
||||
PlayerProfile profile = mcMMO.getDatabaseManager().loadPlayerProfile(offlinePlayer);
|
||||
|
||||
//Check loading by UUID
|
||||
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);
|
||||
@ -103,13 +107,13 @@ public class SkillresetCommand implements TabExecutor {
|
||||
}
|
||||
|
||||
@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) {
|
||||
case 1:
|
||||
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:
|
||||
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:
|
||||
return ImmutableList.of();
|
||||
}
|
||||
@ -142,7 +146,7 @@ public class SkillresetCommand implements TabExecutor {
|
||||
}
|
||||
|
||||
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) {
|
||||
@ -154,13 +158,13 @@ public class SkillresetCommand implements TabExecutor {
|
||||
sender.sendMessage(LocaleLoader.getString("Commands.addlevels.AwardAll.2", playerName));
|
||||
}
|
||||
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) {
|
||||
if (skill == null) {
|
||||
for (PrimarySkillType primarySkillType : PrimarySkillType.NON_CHILD_SKILLS) {
|
||||
for (PrimarySkillType primarySkillType : SkillTools.NON_CHILD_SKILLS) {
|
||||
handleCommand(player, profile, primarySkillType);
|
||||
}
|
||||
|
||||
|
@ -1,64 +1,64 @@
|
||||
package com.gmail.nossr50.commands.hardcore;
|
||||
|
||||
import com.gmail.nossr50.config.Config;
|
||||
import com.gmail.nossr50.datatypes.skills.PrimarySkillType;
|
||||
import com.gmail.nossr50.locale.LocaleLoader;
|
||||
import com.gmail.nossr50.mcMMO;
|
||||
import com.gmail.nossr50.util.Permissions;
|
||||
import org.bukkit.command.CommandSender;
|
||||
|
||||
public class HardcoreCommand extends HardcoreModeCommand {
|
||||
@Override
|
||||
protected boolean checkTogglePermissions(CommandSender sender) {
|
||||
return Permissions.hardcoreToggle(sender);
|
||||
}
|
||||
|
||||
@Override
|
||||
protected boolean checkModifyPermissions(CommandSender sender) {
|
||||
return Permissions.hardcoreModify(sender);
|
||||
}
|
||||
|
||||
@Override
|
||||
protected boolean checkEnabled(PrimarySkillType skill) {
|
||||
if (skill == null) {
|
||||
for (PrimarySkillType primarySkillType : PrimarySkillType.values()) {
|
||||
if (!primarySkillType.getHardcoreStatLossEnabled()) {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
return skill.getHardcoreStatLossEnabled();
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void enable(PrimarySkillType skill) {
|
||||
toggle(true, skill);
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void disable(PrimarySkillType skill) {
|
||||
toggle(false, skill);
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void modify(CommandSender sender, double newPercentage) {
|
||||
Config.getInstance().setHardcoreDeathStatPenaltyPercentage(newPercentage);
|
||||
sender.sendMessage(LocaleLoader.getString("Hardcore.DeathStatLoss.PercentageChanged", percent.format(newPercentage / 100.0D)));
|
||||
}
|
||||
|
||||
private void toggle(boolean enable, PrimarySkillType skill) {
|
||||
if (skill == null) {
|
||||
for (PrimarySkillType primarySkillType : PrimarySkillType.NON_CHILD_SKILLS) {
|
||||
primarySkillType.setHardcoreStatLossEnabled(enable);
|
||||
}
|
||||
}
|
||||
else {
|
||||
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())));
|
||||
}
|
||||
}
|
||||
//package com.gmail.nossr50.commands.hardcore;
|
||||
//
|
||||
//import com.gmail.nossr50.config.Config;
|
||||
//import com.gmail.nossr50.datatypes.skills.PrimarySkillType;
|
||||
//import com.gmail.nossr50.locale.LocaleLoader;
|
||||
//import com.gmail.nossr50.mcMMO;
|
||||
//import com.gmail.nossr50.util.Permissions;
|
||||
//import org.bukkit.command.CommandSender;
|
||||
//
|
||||
//public class HardcoreCommand extends HardcoreModeCommand {
|
||||
// @Override
|
||||
// protected boolean checkTogglePermissions(CommandSender sender) {
|
||||
// return Permissions.hardcoreToggle(sender);
|
||||
// }
|
||||
//
|
||||
// @Override
|
||||
// protected boolean checkModifyPermissions(CommandSender sender) {
|
||||
// return Permissions.hardcoreModify(sender);
|
||||
// }
|
||||
//
|
||||
// @Override
|
||||
// protected boolean checkEnabled(PrimarySkillType skill) {
|
||||
// if (skill == null) {
|
||||
// for (PrimarySkillType primarySkillType : PrimarySkillType.values()) {
|
||||
// if (!primarySkillType.getHardcoreStatLossEnabled()) {
|
||||
// return false;
|
||||
// }
|
||||
// }
|
||||
//
|
||||
// return true;
|
||||
// }
|
||||
//
|
||||
// return skill.getHardcoreStatLossEnabled();
|
||||
// }
|
||||
//
|
||||
// @Override
|
||||
// protected void enable(PrimarySkillType skill) {
|
||||
// toggle(true, skill);
|
||||
// }
|
||||
//
|
||||
// @Override
|
||||
// protected void disable(PrimarySkillType skill) {
|
||||
// toggle(false, skill);
|
||||
// }
|
||||
//
|
||||
// @Override
|
||||
// protected void modify(CommandSender sender, double newPercentage) {
|
||||
// Config.getInstance().setHardcoreDeathStatPenaltyPercentage(newPercentage);
|
||||
// sender.sendMessage(LocaleLoader.getString("Hardcore.DeathStatLoss.PercentageChanged", percent.format(newPercentage / 100.0D)));
|
||||
// }
|
||||
//
|
||||
// private void toggle(boolean enable, PrimarySkillType skill) {
|
||||
// if (skill == null) {
|
||||
// for (PrimarySkillType primarySkillType : SkillTools.NON_CHILD_SKILLS) {
|
||||
// primarySkillType.setHardcoreStatLossEnabled(enable);
|
||||
// }
|
||||
// }
|
||||
// else {
|
||||
// skill.setHardcoreStatLossEnabled(enable);
|
||||
// }
|
||||
//
|
||||
// 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))));
|
||||
// }
|
||||
//}
|
@ -1,130 +1,129 @@
|
||||
package com.gmail.nossr50.commands.hardcore;
|
||||
|
||||
import com.gmail.nossr50.datatypes.skills.PrimarySkillType;
|
||||
import com.gmail.nossr50.util.Permissions;
|
||||
import com.gmail.nossr50.util.StringUtils;
|
||||
import com.gmail.nossr50.util.commands.CommandUtils;
|
||||
import com.google.common.collect.ImmutableList;
|
||||
import org.bukkit.command.Command;
|
||||
import org.bukkit.command.CommandSender;
|
||||
import org.bukkit.command.TabExecutor;
|
||||
import org.bukkit.util.StringUtil;
|
||||
|
||||
import java.text.DecimalFormat;
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
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) {
|
||||
switch (args.length) {
|
||||
case 0:
|
||||
if (!checkTogglePermissions(sender)) {
|
||||
sender.sendMessage(command.getPermissionMessage());
|
||||
return true;
|
||||
}
|
||||
|
||||
if (checkEnabled(null)) {
|
||||
disable(null);
|
||||
}
|
||||
else {
|
||||
enable(null);
|
||||
}
|
||||
|
||||
return true;
|
||||
|
||||
case 1:
|
||||
if (CommandUtils.shouldEnableToggle(args[0])) {
|
||||
if (!Permissions.hardcoreToggle(sender)) {
|
||||
sender.sendMessage(command.getPermissionMessage());
|
||||
return true;
|
||||
}
|
||||
|
||||
enable(null);
|
||||
return true;
|
||||
}
|
||||
|
||||
if (CommandUtils.shouldDisableToggle(args[0])) {
|
||||
if (!Permissions.hardcoreToggle(sender)) {
|
||||
sender.sendMessage(command.getPermissionMessage());
|
||||
return true;
|
||||
}
|
||||
|
||||
disable(null);
|
||||
return true;
|
||||
}
|
||||
|
||||
if (CommandUtils.isInvalidDouble(sender, args[0])) {
|
||||
return true;
|
||||
}
|
||||
|
||||
if (!Permissions.hardcoreModify(sender)) {
|
||||
sender.sendMessage(command.getPermissionMessage());
|
||||
return true;
|
||||
}
|
||||
|
||||
modify(sender, Double.parseDouble(args[0]));
|
||||
return true;
|
||||
|
||||
|
||||
case 2:
|
||||
if (CommandUtils.isInvalidSkill(sender, args[0])) {
|
||||
return true;
|
||||
}
|
||||
|
||||
PrimarySkillType skill = PrimarySkillType.getSkill(args[0]);
|
||||
|
||||
if (!CommandUtils.isChildSkill(sender, skill)) {
|
||||
return true;
|
||||
}
|
||||
|
||||
if (CommandUtils.shouldEnableToggle(args[1])) {
|
||||
if (!Permissions.hardcoreToggle(sender)) {
|
||||
sender.sendMessage(command.getPermissionMessage());
|
||||
return true;
|
||||
}
|
||||
|
||||
enable(skill);
|
||||
return true;
|
||||
}
|
||||
|
||||
if (CommandUtils.shouldDisableToggle(args[1])) {
|
||||
if (!Permissions.hardcoreToggle(sender)) {
|
||||
sender.sendMessage(command.getPermissionMessage());
|
||||
return true;
|
||||
}
|
||||
|
||||
enable(skill);
|
||||
return true;
|
||||
}
|
||||
|
||||
return true;
|
||||
|
||||
default:
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<String> onTabComplete(CommandSender sender, Command command, String alias, String[] args) {
|
||||
switch (args.length) {
|
||||
case 1:
|
||||
if (StringUtils.isDouble(args[0])) {
|
||||
return ImmutableList.of();
|
||||
}
|
||||
|
||||
return StringUtil.copyPartialMatches(args[0], CommandUtils.TRUE_FALSE_OPTIONS, new ArrayList<String>(CommandUtils.TRUE_FALSE_OPTIONS.size()));
|
||||
default:
|
||||
return ImmutableList.of();
|
||||
}
|
||||
}
|
||||
|
||||
protected abstract boolean checkTogglePermissions(CommandSender sender);
|
||||
protected abstract boolean checkModifyPermissions(CommandSender sender);
|
||||
protected abstract boolean checkEnabled(PrimarySkillType skill);
|
||||
protected abstract void enable(PrimarySkillType skill);
|
||||
protected abstract void disable(PrimarySkillType skill);
|
||||
protected abstract void modify(CommandSender sender, double newPercentage);
|
||||
}
|
||||
//package com.gmail.nossr50.commands.hardcore;
|
||||
//
|
||||
//import com.gmail.nossr50.datatypes.skills.PrimarySkillType;
|
||||
//import com.gmail.nossr50.util.Permissions;
|
||||
//import com.gmail.nossr50.util.commands.CommandUtils;
|
||||
//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.util.StringUtil;
|
||||
//import org.jetbrains.annotations.NotNull;
|
||||
//
|
||||
//import java.text.DecimalFormat;
|
||||
//import java.util.ArrayList;
|
||||
//import java.util.List;
|
||||
//
|
||||
//public abstract class HardcoreModeCommand implements TabExecutor {
|
||||
// protected final DecimalFormat percent = new DecimalFormat("##0.00%");
|
||||
//
|
||||
// @Override
|
||||
// public boolean onCommand(@NotNull CommandSender sender, @NotNull Command command, @NotNull String label, String[] args) {
|
||||
// switch (args.length) {
|
||||
// case 0:
|
||||
// if (!checkTogglePermissions(sender)) {
|
||||
// sender.sendMessage(command.getPermissionMessage());
|
||||
// return true;
|
||||
// }
|
||||
//
|
||||
// if (checkEnabled(null)) {
|
||||
// disable(null);
|
||||
// }
|
||||
// else {
|
||||
// enable(null);
|
||||
// }
|
||||
//
|
||||
// return true;
|
||||
//
|
||||
// case 1:
|
||||
// if (CommandUtils.shouldEnableToggle(args[0])) {
|
||||
// if (!Permissions.hardcoreToggle(sender)) {
|
||||
// sender.sendMessage(command.getPermissionMessage());
|
||||
// return true;
|
||||
// }
|
||||
//
|
||||
// enable(null);
|
||||
// return true;
|
||||
// }
|
||||
//
|
||||
// if (CommandUtils.shouldDisableToggle(args[0])) {
|
||||
// if (!Permissions.hardcoreToggle(sender)) {
|
||||
// sender.sendMessage(command.getPermissionMessage());
|
||||
// return true;
|
||||
// }
|
||||
//
|
||||
// disable(null);
|
||||
// return true;
|
||||
// }
|
||||
//
|
||||
// if (CommandUtils.isInvalidDouble(sender, args[0])) {
|
||||
// return true;
|
||||
// }
|
||||
//
|
||||
// if (!Permissions.hardcoreModify(sender)) {
|
||||
// sender.sendMessage(command.getPermissionMessage());
|
||||
// return true;
|
||||
// }
|
||||
//
|
||||
// modify(sender, Double.parseDouble(args[0]));
|
||||
// return true;
|
||||
//
|
||||
//
|
||||
// case 2:
|
||||
// if (CommandUtils.isInvalidSkill(sender, args[0])) {
|
||||
// return true;
|
||||
// }
|
||||
//
|
||||
// PrimarySkillType skill = PrimarySkillType.getSkill(args[0]);
|
||||
//
|
||||
// if (!CommandUtils.isChildSkill(sender, skill)) {
|
||||
// return true;
|
||||
// }
|
||||
//
|
||||
// if (CommandUtils.shouldEnableToggle(args[1])) {
|
||||
// if (!Permissions.hardcoreToggle(sender)) {
|
||||
// sender.sendMessage(command.getPermissionMessage());
|
||||
// return true;
|
||||
// }
|
||||
//
|
||||
// enable(skill);
|
||||
// return true;
|
||||
// }
|
||||
//
|
||||
// if (CommandUtils.shouldDisableToggle(args[1])) {
|
||||
// if (!Permissions.hardcoreToggle(sender)) {
|
||||
// sender.sendMessage(command.getPermissionMessage());
|
||||
// return true;
|
||||
// }
|
||||
//
|
||||
// enable(skill);
|
||||
// return true;
|
||||
// }
|
||||
//
|
||||
// return true;
|
||||
//
|
||||
// default:
|
||||
// return false;
|
||||
// }
|
||||
// }
|
||||
//
|
||||
// @Override
|
||||
// public List<String> onTabComplete(@NotNull CommandSender sender, @NotNull Command command, @NotNull String alias, String[] args) {
|
||||
// if (args.length == 1) {
|
||||
// if (StringUtils.isDouble(args[0])) {
|
||||
// return ImmutableList.of();
|
||||
// }
|
||||
//
|
||||
// return StringUtil.copyPartialMatches(args[0], CommandUtils.TRUE_FALSE_OPTIONS, new ArrayList<>(CommandUtils.TRUE_FALSE_OPTIONS.size()));
|
||||
// }
|
||||
// return ImmutableList.of();
|
||||
// }
|
||||
//
|
||||
// protected abstract boolean checkTogglePermissions(CommandSender sender);
|
||||
// protected abstract boolean checkModifyPermissions(CommandSender sender);
|
||||
// protected abstract boolean checkEnabled(PrimarySkillType skill);
|
||||
// protected abstract void enable(PrimarySkillType skill);
|
||||
// protected abstract void disable(PrimarySkillType skill);
|
||||
// protected abstract void modify(CommandSender sender, double newPercentage);
|
||||
//}
|
||||
|
@ -1,64 +1,64 @@
|
||||
package com.gmail.nossr50.commands.hardcore;
|
||||
|
||||
import com.gmail.nossr50.config.Config;
|
||||
import com.gmail.nossr50.datatypes.skills.PrimarySkillType;
|
||||
import com.gmail.nossr50.locale.LocaleLoader;
|
||||
import com.gmail.nossr50.mcMMO;
|
||||
import com.gmail.nossr50.util.Permissions;
|
||||
import org.bukkit.command.CommandSender;
|
||||
|
||||
public class VampirismCommand extends HardcoreModeCommand {
|
||||
@Override
|
||||
protected boolean checkTogglePermissions(CommandSender sender) {
|
||||
return Permissions.vampirismToggle(sender);
|
||||
}
|
||||
|
||||
@Override
|
||||
protected boolean checkModifyPermissions(CommandSender sender) {
|
||||
return Permissions.vampirismModify(sender);
|
||||
}
|
||||
|
||||
@Override
|
||||
protected boolean checkEnabled(PrimarySkillType skill) {
|
||||
if (skill == null) {
|
||||
for (PrimarySkillType primarySkillType : PrimarySkillType.values()) {
|
||||
if (!primarySkillType.getHardcoreVampirismEnabled()) {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
return skill.getHardcoreVampirismEnabled();
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void enable(PrimarySkillType skill) {
|
||||
toggle(true, skill);
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void disable(PrimarySkillType skill) {
|
||||
toggle(false, skill);
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void modify(CommandSender sender, double newPercentage) {
|
||||
Config.getInstance().setHardcoreVampirismStatLeechPercentage(newPercentage);
|
||||
sender.sendMessage(LocaleLoader.getString("Hardcore.Vampirism.PercentageChanged", percent.format(newPercentage / 100.0D)));
|
||||
}
|
||||
|
||||
private void toggle(boolean enable, PrimarySkillType skill) {
|
||||
if (skill == null) {
|
||||
for (PrimarySkillType primarySkillType : PrimarySkillType.NON_CHILD_SKILLS) {
|
||||
primarySkillType.setHardcoreVampirismEnabled(enable);
|
||||
}
|
||||
}
|
||||
else {
|
||||
skill.setHardcoreVampirismEnabled(enable);
|
||||
}
|
||||
|
||||
mcMMO.p.getServer().broadcastMessage(LocaleLoader.getString("Hardcore.Mode." + (enable ? "Enabled" : "Disabled"), LocaleLoader.getString("Hardcore.Vampirism.Name"), (skill == null ? "all skills" : skill)));
|
||||
}
|
||||
}
|
||||
//package com.gmail.nossr50.commands.hardcore;
|
||||
//
|
||||
//import com.gmail.nossr50.config.Config;
|
||||
//import com.gmail.nossr50.datatypes.skills.PrimarySkillType;
|
||||
//import com.gmail.nossr50.locale.LocaleLoader;
|
||||
//import com.gmail.nossr50.mcMMO;
|
||||
//import com.gmail.nossr50.util.Permissions;
|
||||
//import org.bukkit.command.CommandSender;
|
||||
//
|
||||
//public class VampirismCommand extends HardcoreModeCommand {
|
||||
// @Override
|
||||
// protected boolean checkTogglePermissions(CommandSender sender) {
|
||||
// return Permissions.vampirismToggle(sender);
|
||||
// }
|
||||
//
|
||||
// @Override
|
||||
// protected boolean checkModifyPermissions(CommandSender sender) {
|
||||
// return Permissions.vampirismModify(sender);
|
||||
// }
|
||||
//
|
||||
// @Override
|
||||
// protected boolean checkEnabled(PrimarySkillType skill) {
|
||||
// if (skill == null) {
|
||||
// for (PrimarySkillType primarySkillType : PrimarySkillType.values()) {
|
||||
// if (!primarySkillType.getHardcoreVampirismEnabled()) {
|
||||
// return false;
|
||||
// }
|
||||
// }
|
||||
//
|
||||
// return true;
|
||||
// }
|
||||
//
|
||||
// return skill.getHardcoreVampirismEnabled();
|
||||
// }
|
||||
//
|
||||
// @Override
|
||||
// protected void enable(PrimarySkillType skill) {
|
||||
// toggle(true, skill);
|
||||
// }
|
||||
//
|
||||
// @Override
|
||||
// protected void disable(PrimarySkillType skill) {
|
||||
// toggle(false, skill);
|
||||
// }
|
||||
//
|
||||
// @Override
|
||||
// protected void modify(CommandSender sender, double newPercentage) {
|
||||
// Config.getInstance().setHardcoreVampirismStatLeechPercentage(newPercentage);
|
||||
// sender.sendMessage(LocaleLoader.getString("Hardcore.Vampirism.PercentageChanged", percent.format(newPercentage / 100.0D)));
|
||||
// }
|
||||
//
|
||||
// private void toggle(boolean enable, PrimarySkillType skill) {
|
||||
// if (skill == null) {
|
||||
// for (PrimarySkillType primarySkillType : SkillTools.NON_CHILD_SKILLS) {
|
||||
// primarySkillType.setHardcoreVampirismEnabled(enable);
|
||||
// }
|
||||
// }
|
||||
// else {
|
||||
// skill.setHardcoreVampirismEnabled(enable);
|
||||
// }
|
||||
//
|
||||
// mcMMO.p.getServer().broadcastMessage(LocaleLoader.getString("Hardcore.Mode." + (enable ? "Enabled" : "Disabled"), LocaleLoader.getString("Hardcore.Vampirism.Name"), (skill == null ? "all skills" : skill)));
|
||||
// }
|
||||
//}
|
@ -8,40 +8,37 @@ 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 PartyAcceptCommand implements CommandExecutor {
|
||||
@Override
|
||||
public boolean onCommand(CommandSender sender, Command command, String label, String[] args) {
|
||||
switch (args.length) {
|
||||
case 1:
|
||||
Player player = (Player) sender;
|
||||
public boolean onCommand(@NotNull CommandSender sender, @NotNull Command command, @NotNull String label, String[] args) {
|
||||
if (args.length == 1) {
|
||||
Player player = (Player) sender;
|
||||
|
||||
//Check if player profile is loaded
|
||||
if(UserManager.getPlayer(player) == null)
|
||||
{
|
||||
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);
|
||||
//Check if player profile is loaded
|
||||
if (UserManager.getPlayer(player) == null) {
|
||||
sender.sendMessage(LocaleLoader.getString("Profile.PendingLoad"));
|
||||
return true;
|
||||
}
|
||||
|
||||
default:
|
||||
sender.sendMessage(LocaleLoader.getString("Commands.Usage.1", "party", "accept"));
|
||||
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;
|
||||
}
|
||||
sender.sendMessage(LocaleLoader.getString("Commands.Usage.1", "party", "accept"));
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
@ -11,34 +11,30 @@ 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 PartyChangeOwnerCommand implements CommandExecutor {
|
||||
@Override
|
||||
public boolean onCommand(CommandSender sender, Command command, String label, String[] args) {
|
||||
switch (args.length) {
|
||||
case 2:
|
||||
//Check if player profile is loaded
|
||||
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);
|
||||
public boolean onCommand(@NotNull CommandSender sender, @NotNull Command command, @NotNull String label, String[] args) {
|
||||
if (args.length == 2) {//Check if player profile is loaded
|
||||
if (UserManager.getPlayer((Player) sender) == null) {
|
||||
sender.sendMessage(LocaleLoader.getString("Profile.PendingLoad"));
|
||||
return true;
|
||||
}
|
||||
|
||||
default:
|
||||
sender.sendMessage(LocaleLoader.getString("Commands.Usage.2", "party", "owner", "<" + LocaleLoader.getString("Commands.Usage.Player") + ">"));
|
||||
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;
|
||||
}
|
||||
sender.sendMessage(LocaleLoader.getString("Commands.Usage.2", "party", "owner", "<" + LocaleLoader.getString("Commands.Usage.Player") + ">"));
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
@ -7,10 +7,11 @@ 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 PartyChangePasswordCommand implements CommandExecutor {
|
||||
@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)
|
||||
{
|
||||
sender.sendMessage(LocaleLoader.getString("Profile.PendingLoad"));
|
||||
|
@ -1,6 +1,5 @@
|
||||
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.teleport.PtpCommand;
|
||||
import com.gmail.nossr50.datatypes.party.Party;
|
||||
@ -16,6 +15,7 @@ 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 java.util.ArrayList;
|
||||
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");
|
||||
|
||||
static {
|
||||
ArrayList<String> subcommands = new ArrayList<String>();
|
||||
ArrayList<String> subcommands = new ArrayList<>();
|
||||
|
||||
for (PartySubcommandType subcommand : PartySubcommandType.values()) {
|
||||
subcommands.add(subcommand.toString());
|
||||
@ -38,27 +38,26 @@ public class PartyCommand implements TabExecutor {
|
||||
PARTY_SUBCOMMANDS = ImmutableList.copyOf(subcommands);
|
||||
}
|
||||
|
||||
private CommandExecutor partyJoinCommand = new PartyJoinCommand();
|
||||
private CommandExecutor partyAcceptCommand = new PartyAcceptCommand();
|
||||
private CommandExecutor partyCreateCommand = new PartyCreateCommand();
|
||||
private CommandExecutor partyQuitCommand = new PartyQuitCommand();
|
||||
private CommandExecutor partyXpShareCommand = new PartyXpShareCommand();
|
||||
private CommandExecutor partyItemShareCommand = new PartyItemShareCommand();
|
||||
private CommandExecutor partyInviteCommand = new PartyInviteCommand();
|
||||
private CommandExecutor partyKickCommand = new PartyKickCommand();
|
||||
private CommandExecutor partyDisbandCommand = new PartyDisbandCommand();
|
||||
private CommandExecutor partyChangeOwnerCommand = new PartyChangeOwnerCommand();
|
||||
private CommandExecutor partyLockCommand = new PartyLockCommand();
|
||||
private CommandExecutor partyChangePasswordCommand = new PartyChangePasswordCommand();
|
||||
private CommandExecutor partyRenameCommand = new PartyRenameCommand();
|
||||
private CommandExecutor partyInfoCommand = new PartyInfoCommand();
|
||||
private CommandExecutor partyHelpCommand = new PartyHelpCommand();
|
||||
private CommandExecutor partyTeleportCommand = new PtpCommand();
|
||||
private CommandExecutor partyChatCommand = new PartyChatCommand();
|
||||
private CommandExecutor partyAllianceCommand = new PartyAllianceCommand();
|
||||
private final CommandExecutor partyJoinCommand = new PartyJoinCommand();
|
||||
private final CommandExecutor partyAcceptCommand = new PartyAcceptCommand();
|
||||
private final CommandExecutor partyCreateCommand = new PartyCreateCommand();
|
||||
private final CommandExecutor partyQuitCommand = new PartyQuitCommand();
|
||||
private final CommandExecutor partyXpShareCommand = new PartyXpShareCommand();
|
||||
private final CommandExecutor partyItemShareCommand = new PartyItemShareCommand();
|
||||
private final CommandExecutor partyInviteCommand = new PartyInviteCommand();
|
||||
private final CommandExecutor partyKickCommand = new PartyKickCommand();
|
||||
private final CommandExecutor partyDisbandCommand = new PartyDisbandCommand();
|
||||
private final CommandExecutor partyChangeOwnerCommand = new PartyChangeOwnerCommand();
|
||||
private final CommandExecutor partyLockCommand = new PartyLockCommand();
|
||||
private final CommandExecutor partyChangePasswordCommand = new PartyChangePasswordCommand();
|
||||
private final CommandExecutor partyRenameCommand = new PartyRenameCommand();
|
||||
private final CommandExecutor partyInfoCommand = new PartyInfoCommand();
|
||||
private final CommandExecutor partyHelpCommand = new PartyHelpCommand();
|
||||
private final CommandExecutor partyTeleportCommand = new PtpCommand();
|
||||
private final CommandExecutor partyAllianceCommand = new PartyAllianceCommand();
|
||||
|
||||
@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)) {
|
||||
return true;
|
||||
}
|
||||
@ -131,8 +130,6 @@ public class PartyCommand implements TabExecutor {
|
||||
return partyInviteCommand.onCommand(sender, command, label, args);
|
||||
case TELEPORT:
|
||||
return partyTeleportCommand.onCommand(sender, command, label, extractArgs(args));
|
||||
case CHAT:
|
||||
return partyChatCommand.onCommand(sender, command, label, extractArgs(args));
|
||||
default:
|
||||
break;
|
||||
}
|
||||
@ -171,10 +168,10 @@ public class PartyCommand implements TabExecutor {
|
||||
}
|
||||
|
||||
@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) {
|
||||
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:
|
||||
PartySubcommandType subcommand = PartySubcommandType.getSubcommand(args[0]);
|
||||
|
||||
@ -188,18 +185,18 @@ public class PartyCommand implements TabExecutor {
|
||||
case KICK:
|
||||
case OWNER:
|
||||
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:
|
||||
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:
|
||||
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 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:
|
||||
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:
|
||||
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) {
|
||||
Player player = (Player) sender;
|
||||
@ -214,7 +211,7 @@ public class PartyCommand implements TabExecutor {
|
||||
Party party = UserManager.getPlayer(player).getParty();
|
||||
|
||||
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;
|
||||
@ -223,7 +220,7 @@ public class PartyCommand implements TabExecutor {
|
||||
}
|
||||
case 3:
|
||||
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();
|
||||
|
@ -8,10 +8,11 @@ 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 PartyCreateCommand implements CommandExecutor {
|
||||
@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) {
|
||||
case 2:
|
||||
case 3:
|
||||
|
@ -1,6 +1,7 @@
|
||||
package com.gmail.nossr50.commands.party;
|
||||
|
||||
import com.gmail.nossr50.datatypes.party.Party;
|
||||
import com.gmail.nossr50.datatypes.player.McMMOPlayer;
|
||||
import com.gmail.nossr50.events.party.McMMOPartyChangeEvent.EventReason;
|
||||
import com.gmail.nossr50.locale.LocaleLoader;
|
||||
import com.gmail.nossr50.party.PartyManager;
|
||||
@ -9,35 +10,33 @@ 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 PartyDisbandCommand implements CommandExecutor {
|
||||
@Override
|
||||
public boolean onCommand(CommandSender sender, Command command, String label, String[] args) {
|
||||
switch (args.length) {
|
||||
case 1:
|
||||
if(UserManager.getPlayer((Player) sender) == null)
|
||||
{
|
||||
sender.sendMessage(LocaleLoader.getString("Profile.PendingLoad"));
|
||||
public boolean onCommand(@NotNull CommandSender sender, @NotNull Command command, @NotNull String label, String[] args) {
|
||||
if (args.length == 1) {
|
||||
final McMMOPlayer mcMMOPlayer = UserManager.getPlayer((Player) sender);
|
||||
if (mcMMOPlayer == null) {
|
||||
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;
|
||||
}
|
||||
|
||||
Party playerParty = UserManager.getPlayer((Player) sender).getParty();
|
||||
String partyName = playerParty.getName();
|
||||
member.sendMessage(LocaleLoader.getString("Party.Disband"));
|
||||
}
|
||||
|
||||
for (Player member : playerParty.getOnlineMembers()) {
|
||||
if (!PartyManager.handlePartyChangeEvent(member, partyName, null, EventReason.KICKED_FROM_PARTY)) {
|
||||
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;
|
||||
PartyManager.disbandParty(mcMMOPlayer, playerParty);
|
||||
return true;
|
||||
}
|
||||
sender.sendMessage(LocaleLoader.getString("Commands.Usage.1", "party", "disband"));
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
@ -4,27 +4,25 @@ import com.gmail.nossr50.locale.LocaleLoader;
|
||||
import org.bukkit.command.Command;
|
||||
import org.bukkit.command.CommandExecutor;
|
||||
import org.bukkit.command.CommandSender;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
|
||||
public class PartyHelpCommand implements CommandExecutor {
|
||||
|
||||
@Override
|
||||
public boolean onCommand(CommandSender sender, Command command, String label, String[] args) {
|
||||
switch (args.length) {
|
||||
case 1:
|
||||
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.4", "/party <lock|unlock>"));
|
||||
sender.sendMessage(LocaleLoader.getString("Party.Help.5", "/party password"));
|
||||
sender.sendMessage(LocaleLoader.getString("Party.Help.6", "/party kick"));
|
||||
sender.sendMessage(LocaleLoader.getString("Party.Help.7", "/party leader"));
|
||||
sender.sendMessage(LocaleLoader.getString("Party.Help.8", "/party disband"));
|
||||
sender.sendMessage(LocaleLoader.getString("Party.Help.9", "/party itemshare"));
|
||||
sender.sendMessage(LocaleLoader.getString("Party.Help.10", "/party xpshare"));
|
||||
return true;
|
||||
|
||||
default:
|
||||
sender.sendMessage(LocaleLoader.getString("Commands.Usage.1", "party", "help"));
|
||||
return true;
|
||||
public boolean onCommand(@NotNull CommandSender sender, @NotNull Command command, @NotNull String label, String[] args) {
|
||||
if (args.length == 1) {
|
||||
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.4", "/party <lock|unlock>"));
|
||||
sender.sendMessage(LocaleLoader.getString("Party.Help.5", "/party password"));
|
||||
sender.sendMessage(LocaleLoader.getString("Party.Help.6", "/party kick"));
|
||||
sender.sendMessage(LocaleLoader.getString("Party.Help.7", "/party leader"));
|
||||
sender.sendMessage(LocaleLoader.getString("Party.Help.8", "/party disband"));
|
||||
sender.sendMessage(LocaleLoader.getString("Party.Help.9", "/party itemshare"));
|
||||
sender.sendMessage(LocaleLoader.getString("Party.Help.10", "/party xpshare"));
|
||||
return true;
|
||||
}
|
||||
sender.sendMessage(LocaleLoader.getString("Commands.Usage.1", "party", "help"));
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
@ -1,11 +1,11 @@
|
||||
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.PartyFeature;
|
||||
import com.gmail.nossr50.datatypes.party.ShareMode;
|
||||
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.util.player.UserManager;
|
||||
import org.bukkit.ChatColor;
|
||||
@ -13,13 +13,14 @@ 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;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
public class PartyInfoCommand implements CommandExecutor {
|
||||
@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) {
|
||||
case 0:
|
||||
case 1:
|
||||
@ -60,8 +61,8 @@ public class PartyInfoCommand implements CommandExecutor {
|
||||
private void displayPartyFeatures(Player player, Party party) {
|
||||
player.sendMessage(LocaleLoader.getString("Commands.Party.Features.Header"));
|
||||
|
||||
List<String> unlockedPartyFeatures = new ArrayList<String>();
|
||||
List<String> lockedPartyFeatures = new ArrayList<String>();
|
||||
List<String> unlockedPartyFeatures = new ArrayList<>();
|
||||
List<String> lockedPartyFeatures = new ArrayList<>();
|
||||
|
||||
for (PartyFeature partyFeature : PartyFeature.values()) {
|
||||
if (!partyFeature.hasPermission(player)) {
|
||||
@ -84,7 +85,7 @@ public class PartyInfoCommand implements CommandExecutor {
|
||||
}
|
||||
|
||||
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) {
|
||||
|
@ -1,9 +1,9 @@
|
||||
package com.gmail.nossr50.commands.party;
|
||||
|
||||
import com.gmail.nossr50.config.Config;
|
||||
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.party.PartyManager;
|
||||
import com.gmail.nossr50.util.commands.CommandUtils;
|
||||
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.CommandSender;
|
||||
import org.bukkit.entity.Player;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
|
||||
public class PartyInviteCommand implements CommandExecutor {
|
||||
@Override
|
||||
public boolean onCommand(CommandSender sender, Command command, String label, String[] args) {
|
||||
switch (args.length) {
|
||||
case 2:
|
||||
String targetName = CommandUtils.getMatchedPlayerName(args[1]);
|
||||
McMMOPlayer mcMMOTarget = UserManager.getOfflinePlayer(targetName);
|
||||
public boolean onCommand(@NotNull CommandSender sender, @NotNull Command command, @NotNull String label, String[] args) {
|
||||
if (args.length == 2) {
|
||||
String targetName = CommandUtils.getMatchedPlayerName(args[1]);
|
||||
McMMOPlayer mcMMOTarget = UserManager.getOfflinePlayer(targetName);
|
||||
|
||||
if (!CommandUtils.checkPlayerExistence(sender, targetName, mcMMOTarget)) {
|
||||
return false;
|
||||
}
|
||||
if (!CommandUtils.checkPlayerExistence(sender, targetName, mcMMOTarget)) {
|
||||
return false;
|
||||
}
|
||||
|
||||
Player target = mcMMOTarget.getPlayer();
|
||||
Player target = mcMMOTarget.getPlayer();
|
||||
|
||||
if(UserManager.getPlayer((Player) sender) == null)
|
||||
{
|
||||
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"));
|
||||
if (UserManager.getPlayer((Player) sender) == null) {
|
||||
sender.sendMessage(LocaleLoader.getString("Profile.PendingLoad"));
|
||||
return true;
|
||||
}
|
||||
|
||||
default:
|
||||
sender.sendMessage(LocaleLoader.getString("Commands.Usage.2", "party", "invite", "<" + LocaleLoader.getString("Commands.Usage.Player") + ">"));
|
||||
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(), 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;
|
||||
}
|
||||
}
|
||||
|
@ -1,24 +1,25 @@
|
||||
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.Party;
|
||||
import com.gmail.nossr50.datatypes.party.PartyFeature;
|
||||
import com.gmail.nossr50.datatypes.party.ShareMode;
|
||||
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.player.UserManager;
|
||||
import com.gmail.nossr50.util.text.StringUtils;
|
||||
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;
|
||||
|
||||
import java.util.Locale;
|
||||
|
||||
public class PartyItemShareCommand implements CommandExecutor {
|
||||
@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)
|
||||
{
|
||||
sender.sendMessage(LocaleLoader.getString("Profile.PendingLoad"));
|
||||
@ -27,7 +28,7 @@ public class PartyItemShareCommand implements CommandExecutor {
|
||||
|
||||
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"));
|
||||
return true;
|
||||
}
|
||||
|
@ -10,10 +10,11 @@ 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 PartyJoinCommand implements CommandExecutor {
|
||||
@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) {
|
||||
case 2:
|
||||
case 3:
|
||||
|
@ -12,46 +12,43 @@ 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 PartyKickCommand implements CommandExecutor {
|
||||
@Override
|
||||
public boolean onCommand(CommandSender sender, Command command, String label, String[] args) {
|
||||
switch (args.length) {
|
||||
case 2:
|
||||
if(UserManager.getPlayer((Player) sender) == null)
|
||||
{
|
||||
sender.sendMessage(LocaleLoader.getString("Profile.PendingLoad"));
|
||||
public boolean onCommand(@NotNull CommandSender sender, @NotNull Command command, @NotNull String label, String[] args) {
|
||||
if (args.length == 2) {
|
||||
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]);
|
||||
|
||||
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;
|
||||
}
|
||||
|
||||
Party playerParty = UserManager.getPlayer((Player) sender).getParty();
|
||||
String targetName = CommandUtils.getMatchedPlayerName(args[1]);
|
||||
PartyManager.processPartyLeaving(UserManager.getPlayer(onlineTarget));
|
||||
onlineTarget.sendMessage(LocaleLoader.getString("Commands.Party.Kick", partyName));
|
||||
}
|
||||
|
||||
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;
|
||||
}
|
||||
|
||||
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;
|
||||
PartyManager.removeFromParty(target, playerParty);
|
||||
return true;
|
||||
}
|
||||
sender.sendMessage(LocaleLoader.getString("Commands.Usage.2", "party", "kick", "<" + LocaleLoader.getString("Commands.Usage.Player") + ">"));
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
@ -9,10 +9,11 @@ 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 PartyLockCommand implements CommandExecutor {
|
||||
@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) {
|
||||
case 1:
|
||||
if (args[0].equalsIgnoreCase("lock")) {
|
||||
@ -67,7 +68,7 @@ public class PartyLockCommand implements CommandExecutor {
|
||||
return;
|
||||
}
|
||||
|
||||
if (lock ? party.isLocked() : !party.isLocked()) {
|
||||
if (lock == party.isLocked()) {
|
||||
sender.sendMessage(LocaleLoader.getString("Party." + (lock ? "IsLocked" : "IsntLocked")));
|
||||
return;
|
||||
}
|
||||
|
@ -10,34 +10,31 @@ 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 PartyQuitCommand implements CommandExecutor {
|
||||
@Override
|
||||
public boolean onCommand(CommandSender sender, Command command, String label, String[] args) {
|
||||
switch (args.length) {
|
||||
case 1:
|
||||
Player player = (Player) sender;
|
||||
public boolean onCommand(@NotNull CommandSender sender, @NotNull Command command, @NotNull String label, String[] args) {
|
||||
if (args.length == 1) {
|
||||
Player player = (Player) sender;
|
||||
|
||||
if(UserManager.getPlayer((Player) sender) == null)
|
||||
{
|
||||
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"));
|
||||
if (UserManager.getPlayer((Player) sender) == null) {
|
||||
sender.sendMessage(LocaleLoader.getString("Profile.PendingLoad"));
|
||||
return true;
|
||||
}
|
||||
|
||||
default:
|
||||
sender.sendMessage(LocaleLoader.getString("Commands.Usage.1", "party", "quit"));
|
||||
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;
|
||||
}
|
||||
sender.sendMessage(LocaleLoader.getString("Commands.Usage.1", "party", "quit"));
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
@ -10,57 +10,54 @@ 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 PartyRenameCommand implements CommandExecutor {
|
||||
@Override
|
||||
public boolean onCommand(CommandSender sender, Command command, String label, String[] args) {
|
||||
switch (args.length) {
|
||||
case 2:
|
||||
if(UserManager.getPlayer((Player) sender) == null)
|
||||
{
|
||||
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));
|
||||
public boolean onCommand(@NotNull CommandSender sender, @NotNull Command command, @NotNull String label, String[] args) {
|
||||
if (args.length == 2) {
|
||||
if (UserManager.getPlayer((Player) sender) == null) {
|
||||
sender.sendMessage(LocaleLoader.getString("Profile.PendingLoad"));
|
||||
return true;
|
||||
}
|
||||
|
||||
default:
|
||||
sender.sendMessage(LocaleLoader.getString("Commands.Usage.2", "party", "rename", "<" + LocaleLoader.getString("Commands.Usage.PartyName") + ">"));
|
||||
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;
|
||||
}
|
||||
sender.sendMessage(LocaleLoader.getString("Commands.Usage.2", "party", "rename", "<" + LocaleLoader.getString("Commands.Usage.PartyName") + ">"));
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
@ -1,21 +1,22 @@
|
||||
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.PartyFeature;
|
||||
import com.gmail.nossr50.datatypes.party.ShareMode;
|
||||
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.player.UserManager;
|
||||
import com.gmail.nossr50.util.text.StringUtils;
|
||||
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 PartyXpShareCommand implements CommandExecutor {
|
||||
@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)
|
||||
{
|
||||
sender.sendMessage(LocaleLoader.getString("Profile.PendingLoad"));
|
||||
@ -24,29 +25,24 @@ public class PartyXpShareCommand implements CommandExecutor {
|
||||
|
||||
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"));
|
||||
return true;
|
||||
}
|
||||
|
||||
switch (args.length) {
|
||||
case 2:
|
||||
if (args[1].equalsIgnoreCase("none") || CommandUtils.shouldDisableToggle(args[1])) {
|
||||
handleChangingShareMode(party, ShareMode.NONE);
|
||||
}
|
||||
else if (args[1].equalsIgnoreCase("equal") || args[1].equalsIgnoreCase("even") || CommandUtils.shouldEnableToggle(args[1])) {
|
||||
handleChangingShareMode(party, ShareMode.EQUAL);
|
||||
}
|
||||
else {
|
||||
sender.sendMessage(LocaleLoader.getString("Commands.Usage.2", "party", "xpshare", "<NONE | EQUAL>"));
|
||||
}
|
||||
|
||||
return true;
|
||||
|
||||
default:
|
||||
if (args.length == 2) {
|
||||
if (args[1].equalsIgnoreCase("none") || CommandUtils.shouldDisableToggle(args[1])) {
|
||||
handleChangingShareMode(party, ShareMode.NONE);
|
||||
} else if (args[1].equalsIgnoreCase("equal") || args[1].equalsIgnoreCase("even") || CommandUtils.shouldEnableToggle(args[1])) {
|
||||
handleChangingShareMode(party, ShareMode.EQUAL);
|
||||
} else {
|
||||
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) {
|
||||
|
@ -8,36 +8,33 @@ 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 PartyAllianceAcceptCommand implements CommandExecutor {
|
||||
@Override
|
||||
public boolean onCommand(CommandSender sender, Command command, String label, String[] args) {
|
||||
switch (args.length) {
|
||||
case 2:
|
||||
if(UserManager.getPlayer((Player) sender) == null)
|
||||
{
|
||||
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);
|
||||
public boolean onCommand(@NotNull CommandSender sender, @NotNull Command command, @NotNull String label, String[] args) {
|
||||
if (args.length == 2) {
|
||||
if (UserManager.getPlayer((Player) sender) == null) {
|
||||
sender.sendMessage(LocaleLoader.getString("Profile.PendingLoad"));
|
||||
return true;
|
||||
}
|
||||
Player player = (Player) sender;
|
||||
McMMOPlayer mcMMOPlayer = UserManager.getPlayer(player);
|
||||
|
||||
default:
|
||||
sender.sendMessage(LocaleLoader.getString("Commands.Usage.2", "party", "alliance", "accept"));
|
||||
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;
|
||||
}
|
||||
sender.sendMessage(LocaleLoader.getString("Commands.Usage.2", "party", "alliance", "accept"));
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
@ -1,10 +1,10 @@
|
||||
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.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.util.commands.CommandUtils;
|
||||
import com.gmail.nossr50.util.player.UserManager;
|
||||
@ -16,6 +16,7 @@ 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 java.util.ArrayList;
|
||||
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");
|
||||
|
||||
private CommandExecutor partyAllianceInviteCommand = new PartyAllianceInviteCommand();
|
||||
private CommandExecutor partyAllianceAcceptCommand = new PartyAllianceAcceptCommand();
|
||||
private CommandExecutor partyAllianceDisbandCommand = new PartyAllianceDisbandCommand();
|
||||
private final CommandExecutor partyAllianceInviteCommand = new PartyAllianceInviteCommand();
|
||||
private final CommandExecutor partyAllianceAcceptCommand = new PartyAllianceAcceptCommand();
|
||||
private final CommandExecutor partyAllianceDisbandCommand = new PartyAllianceDisbandCommand();
|
||||
|
||||
@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)) {
|
||||
return true;
|
||||
}
|
||||
@ -50,7 +51,7 @@ public class PartyAllianceCommand implements TabExecutor {
|
||||
|
||||
switch (args.length) {
|
||||
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"));
|
||||
return true;
|
||||
}
|
||||
@ -68,7 +69,7 @@ public class PartyAllianceCommand implements TabExecutor {
|
||||
|
||||
case 2:
|
||||
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"));
|
||||
return true;
|
||||
}
|
||||
@ -108,20 +109,18 @@ public class PartyAllianceCommand implements TabExecutor {
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<String> onTabComplete(CommandSender commandSender, Command command, String label, String[] args) {
|
||||
switch (args.length) {
|
||||
case 1:
|
||||
List<String> matches = StringUtil.copyPartialMatches(args[0], ALLIANCE_SUBCOMMANDS, new ArrayList<String>(ALLIANCE_SUBCOMMANDS.size()));
|
||||
public List<String> onTabComplete(@NotNull CommandSender commandSender, @NotNull Command command, @NotNull String label, String[] args) {
|
||||
if (args.length == 1) {
|
||||
List<String> matches = StringUtil.copyPartialMatches(args[0], ALLIANCE_SUBCOMMANDS, new ArrayList<>(ALLIANCE_SUBCOMMANDS.size()));
|
||||
|
||||
if (matches.size() == 0) {
|
||||
List<String> playerNames = CommandUtils.getOnlinePlayerNames(commandSender);
|
||||
return StringUtil.copyPartialMatches(args[0], playerNames, new ArrayList<String>(playerNames.size()));
|
||||
}
|
||||
if (matches.size() == 0) {
|
||||
List<String> playerNames = CommandUtils.getOnlinePlayerNames(commandSender);
|
||||
return StringUtil.copyPartialMatches(args[0], playerNames, new ArrayList<>(playerNames.size()));
|
||||
}
|
||||
|
||||
return matches;
|
||||
default:
|
||||
return ImmutableList.of();
|
||||
return matches;
|
||||
}
|
||||
return ImmutableList.of();
|
||||
}
|
||||
|
||||
private void displayPartyHeader() {
|
||||
|
@ -9,32 +9,29 @@ 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 PartyAllianceDisbandCommand implements CommandExecutor {
|
||||
@Override
|
||||
public boolean onCommand(CommandSender sender, Command command, String label, String[] args) {
|
||||
switch (args.length) {
|
||||
case 2:
|
||||
if(UserManager.getPlayer((Player) sender) == null)
|
||||
{
|
||||
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());
|
||||
public boolean onCommand(@NotNull CommandSender sender, @NotNull Command command, @NotNull String label, String[] args) {
|
||||
if (args.length == 2) {
|
||||
if (UserManager.getPlayer((Player) sender) == null) {
|
||||
sender.sendMessage(LocaleLoader.getString("Profile.PendingLoad"));
|
||||
return true;
|
||||
}
|
||||
Player player = (Player) sender;
|
||||
McMMOPlayer mcMMOPlayer = UserManager.getPlayer(player);
|
||||
Party party = mcMMOPlayer.getParty();
|
||||
|
||||
default:
|
||||
sender.sendMessage(LocaleLoader.getString("Commands.Usage.2", "party", "alliance", "disband"));
|
||||
if (party.getAlly() == null) {
|
||||
sender.sendMessage(LocaleLoader.getString("Commands.Party.Alliance.None"));
|
||||
return true;
|
||||
}
|
||||
|
||||
PartyManager.disbandAlliance(player, party, party.getAlly());
|
||||
return true;
|
||||
}
|
||||
sender.sendMessage(LocaleLoader.getString("Commands.Usage.2", "party", "alliance", "disband"));
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
@ -10,68 +10,65 @@ 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 PartyAllianceInviteCommand implements CommandExecutor {
|
||||
@Override
|
||||
public boolean onCommand(CommandSender sender, Command command, String label, String[] args) {
|
||||
switch (args.length) {
|
||||
case 3:
|
||||
String targetName = CommandUtils.getMatchedPlayerName(args[2]);
|
||||
McMMOPlayer mcMMOTarget = UserManager.getOfflinePlayer(targetName);
|
||||
public boolean onCommand(@NotNull CommandSender sender, @NotNull Command command, @NotNull String label, String[] args) {
|
||||
if (args.length == 3) {
|
||||
String targetName = CommandUtils.getMatchedPlayerName(args[2]);
|
||||
McMMOPlayer mcMMOTarget = UserManager.getOfflinePlayer(targetName);
|
||||
|
||||
if (!CommandUtils.checkPlayerExistence(sender, targetName, mcMMOTarget)) {
|
||||
return false;
|
||||
}
|
||||
if (!CommandUtils.checkPlayerExistence(sender, targetName, mcMMOTarget)) {
|
||||
return false;
|
||||
}
|
||||
|
||||
Player target = mcMMOTarget.getPlayer();
|
||||
Player target = mcMMOTarget.getPlayer();
|
||||
|
||||
if(UserManager.getPlayer((Player) sender) == null)
|
||||
{
|
||||
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"));
|
||||
if (UserManager.getPlayer((Player) sender) == null) {
|
||||
sender.sendMessage(LocaleLoader.getString("Profile.PendingLoad"));
|
||||
return true;
|
||||
}
|
||||
|
||||
default:
|
||||
sender.sendMessage(LocaleLoader.getString("Commands.Usage.3", "party", "alliance", "invite", "<" + LocaleLoader.getString("Commands.Usage.Player") + ">"));
|
||||
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;
|
||||
}
|
||||
sender.sendMessage(LocaleLoader.getString("Commands.Usage.3", "party", "alliance", "invite", "<" + LocaleLoader.getString("Commands.Usage.Player") + ">"));
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
@ -7,10 +7,11 @@ import com.gmail.nossr50.util.player.UserManager;
|
||||
import org.bukkit.command.Command;
|
||||
import org.bukkit.command.CommandExecutor;
|
||||
import org.bukkit.command.CommandSender;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
|
||||
public class PtpAcceptAnyCommand implements CommandExecutor {
|
||||
@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)) {
|
||||
sender.sendMessage(command.getPermissionMessage());
|
||||
return true;
|
||||
|
@ -1,8 +1,8 @@
|
||||
package com.gmail.nossr50.commands.party.teleport;
|
||||
|
||||
import com.gmail.nossr50.config.Config;
|
||||
import com.gmail.nossr50.datatypes.party.PartyTeleportRecord;
|
||||
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 com.gmail.nossr50.util.skills.SkillUtils;
|
||||
@ -11,10 +11,11 @@ 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 PtpAcceptCommand implements CommandExecutor {
|
||||
@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)) {
|
||||
sender.sendMessage(command.getPermissionMessage());
|
||||
return true;
|
||||
@ -34,7 +35,7 @@ public class PtpAcceptCommand implements CommandExecutor {
|
||||
return true;
|
||||
}
|
||||
|
||||
if (SkillUtils.cooldownExpired(ptpRecord.getTimeout(), Config.getInstance().getPTPCommandTimeout())) {
|
||||
if (SkillUtils.cooldownExpired(ptpRecord.getTimeout(), mcMMO.p.getGeneralConfig().getPTPCommandTimeout())) {
|
||||
ptpRecord.removeRequest();
|
||||
player.sendMessage(LocaleLoader.getString("Commands.ptp.RequestExpired"));
|
||||
return true;
|
||||
@ -47,7 +48,7 @@ public class PtpAcceptCommand implements CommandExecutor {
|
||||
return true;
|
||||
}
|
||||
|
||||
if (Config.getInstance().getPTPCommandWorldPermissions()) {
|
||||
if (mcMMO.p.getGeneralConfig().getPTPCommandWorldPermissions()) {
|
||||
World targetWorld = target.getWorld();
|
||||
World playerWorld = player.getWorld();
|
||||
|
||||
|
@ -1,6 +1,5 @@
|
||||
package com.gmail.nossr50.commands.party.teleport;
|
||||
|
||||
import com.gmail.nossr50.config.Config;
|
||||
import com.gmail.nossr50.config.WorldBlacklist;
|
||||
import com.gmail.nossr50.datatypes.party.Party;
|
||||
import com.gmail.nossr50.datatypes.party.PartyFeature;
|
||||
@ -26,6 +25,7 @@ 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 java.util.ArrayList;
|
||||
import java.util.List;
|
||||
@ -33,12 +33,12 @@ import java.util.List;
|
||||
public class PtpCommand implements TabExecutor {
|
||||
public static final List<String> TELEPORT_SUBCOMMANDS = ImmutableList.of("toggle", "accept", "acceptany", "acceptall");
|
||||
|
||||
private CommandExecutor ptpToggleCommand = new PtpToggleCommand();
|
||||
private CommandExecutor ptpAcceptAnyCommand = new PtpAcceptAnyCommand();
|
||||
private CommandExecutor ptpAcceptCommand = new PtpAcceptCommand();
|
||||
private final CommandExecutor ptpToggleCommand = new PtpToggleCommand();
|
||||
private final CommandExecutor ptpAcceptAnyCommand = new PtpAcceptAnyCommand();
|
||||
private final CommandExecutor ptpAcceptCommand = new PtpAcceptCommand();
|
||||
|
||||
@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)) {
|
||||
return true;
|
||||
}
|
||||
@ -75,90 +75,84 @@ public class PtpCommand implements TabExecutor {
|
||||
|
||||
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"));
|
||||
return true;
|
||||
}
|
||||
|
||||
switch (args.length) {
|
||||
case 1:
|
||||
if (args[0].equalsIgnoreCase("toggle")) {
|
||||
return ptpToggleCommand.onCommand(sender, command, label, args);
|
||||
}
|
||||
if (args.length == 1) {
|
||||
if (args[0].equalsIgnoreCase("toggle")) {
|
||||
return ptpToggleCommand.onCommand(sender, command, label, args);
|
||||
}
|
||||
|
||||
if (args[0].equalsIgnoreCase("acceptany") || args[0].equalsIgnoreCase("acceptall")) {
|
||||
return ptpAcceptAnyCommand.onCommand(sender, command, label, args);
|
||||
}
|
||||
if (args[0].equalsIgnoreCase("acceptany") || args[0].equalsIgnoreCase("acceptall")) {
|
||||
return ptpAcceptAnyCommand.onCommand(sender, command, label, args);
|
||||
}
|
||||
|
||||
long recentlyHurt = mcMMOPlayer.getRecentlyHurt();
|
||||
int hurtCooldown = Config.getInstance().getPTPCommandRecentlyHurtCooldown();
|
||||
long recentlyHurt = mcMMOPlayer.getRecentlyHurt();
|
||||
int hurtCooldown = mcMMO.p.getGeneralConfig().getPTPCommandRecentlyHurtCooldown();
|
||||
|
||||
if (hurtCooldown > 0) {
|
||||
int timeRemaining = SkillUtils.calculateTimeLeft(recentlyHurt * Misc.TIME_CONVERSION_FACTOR, hurtCooldown, player);
|
||||
if (hurtCooldown > 0) {
|
||||
int timeRemaining = SkillUtils.calculateTimeLeft(recentlyHurt * Misc.TIME_CONVERSION_FACTOR, hurtCooldown, player);
|
||||
|
||||
if (timeRemaining > 0) {
|
||||
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());
|
||||
if (timeRemaining > 0) {
|
||||
player.sendMessage(LocaleLoader.getString("Item.Injured.Wait", timeRemaining));
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
||||
int ptpCooldown = Config.getInstance().getPTPCommandCooldown();
|
||||
long ptpLastUse = mcMMOPlayer.getPartyTeleportRecord().getLastUse();
|
||||
if (args[0].equalsIgnoreCase("accept")) {
|
||||
return ptpAcceptCommand.onCommand(sender, command, label, args);
|
||||
}
|
||||
|
||||
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]));
|
||||
if (!Permissions.partyTeleportSend(sender)) {
|
||||
sender.sendMessage(command.getPermissionMessage());
|
||||
return true;
|
||||
}
|
||||
|
||||
default:
|
||||
return false;
|
||||
int ptpCooldown = mcMMO.p.getGeneralConfig().getPTPCommandCooldown();
|
||||
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
|
||||
public List<String> onTabComplete(CommandSender sender, Command command, String alias, String[] args) {
|
||||
switch (args.length) {
|
||||
case 1:
|
||||
List<String> matches = StringUtil.copyPartialMatches(args[0], TELEPORT_SUBCOMMANDS, new ArrayList<String>(TELEPORT_SUBCOMMANDS.size()));
|
||||
public List<String> onTabComplete(@NotNull CommandSender sender, @NotNull Command command, @NotNull String alias, String[] args) {
|
||||
if (args.length == 1) {
|
||||
List<String> matches = StringUtil.copyPartialMatches(args[0], TELEPORT_SUBCOMMANDS, new ArrayList<>(TELEPORT_SUBCOMMANDS.size()));
|
||||
|
||||
if (matches.size() == 0) {
|
||||
if(UserManager.getPlayer((Player) sender) == null)
|
||||
{
|
||||
sender.sendMessage(LocaleLoader.getString("Profile.PendingLoad"));
|
||||
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()));
|
||||
if (matches.size() == 0) {
|
||||
if (UserManager.getPlayer((Player) sender) == null) {
|
||||
sender.sendMessage(LocaleLoader.getString("Profile.PendingLoad"));
|
||||
return ImmutableList.of();
|
||||
}
|
||||
|
||||
return matches;
|
||||
default:
|
||||
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<>(playerNames.size()));
|
||||
}
|
||||
|
||||
return matches;
|
||||
}
|
||||
return ImmutableList.of();
|
||||
}
|
||||
|
||||
private void sendTeleportRequest(CommandSender sender, Player player, String targetName) {
|
||||
@ -170,7 +164,7 @@ public class PtpCommand implements TabExecutor {
|
||||
Player target = mcMMOTarget.getPlayer();
|
||||
|
||||
|
||||
if (Config.getInstance().getPTPCommandWorldPermissions()) {
|
||||
if (mcMMO.p.getGeneralConfig().getPTPCommandWorldPermissions()) {
|
||||
World targetWorld = target.getWorld();
|
||||
World playerWorld = player.getWorld();
|
||||
|
||||
@ -199,7 +193,7 @@ public class PtpCommand implements TabExecutor {
|
||||
player.sendMessage(LocaleLoader.getString("Commands.Invite.Success"));
|
||||
|
||||
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) {
|
||||
@ -250,7 +244,7 @@ public class PtpCommand implements TabExecutor {
|
||||
McMMOPlayer mcMMOPlayer = UserManager.getPlayer(teleportingPlayer);
|
||||
McMMOPlayer mcMMOTarget = UserManager.getPlayer(targetPlayer);
|
||||
|
||||
long warmup = Config.getInstance().getPTPCommandWarmup();
|
||||
long warmup = mcMMO.p.getGeneralConfig().getPTPCommandWarmup();
|
||||
|
||||
mcMMOPlayer.actualizeTeleportCommenceLocation(teleportingPlayer);
|
||||
|
||||
|
@ -7,10 +7,11 @@ import com.gmail.nossr50.util.player.UserManager;
|
||||
import org.bukkit.command.Command;
|
||||
import org.bukkit.command.CommandExecutor;
|
||||
import org.bukkit.command.CommandSender;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
|
||||
public class PtpToggleCommand implements CommandExecutor {
|
||||
@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)) {
|
||||
sender.sendMessage(command.getPermissionMessage());
|
||||
return true;
|
||||
|
@ -1,6 +1,5 @@
|
||||
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.PlayerProfile;
|
||||
import com.gmail.nossr50.datatypes.skills.PrimarySkillType;
|
||||
@ -16,93 +15,94 @@ 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 java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
public class InspectCommand implements TabExecutor {
|
||||
@Override
|
||||
public boolean onCommand(CommandSender sender, Command command, String label, String[] args) {
|
||||
switch (args.length) {
|
||||
case 1:
|
||||
String playerName = CommandUtils.getMatchedPlayerName(args[0]);
|
||||
McMMOPlayer mcMMOPlayer = UserManager.getOfflinePlayer(playerName);
|
||||
public boolean onCommand(@NotNull CommandSender sender, @NotNull Command command, @NotNull String label, String[] args) {
|
||||
if (args.length == 1) {
|
||||
String playerName = CommandUtils.getMatchedPlayerName(args[0]);
|
||||
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 (mcMMOPlayer == null) {
|
||||
PlayerProfile profile = mcMMO.getDatabaseManager().loadPlayerProfile(playerName, false); // Temporary Profile
|
||||
// If the mcMMOPlayer doesn't exist, create a temporary profile and check if it's present in the database. If it's not, abort the process.
|
||||
if (mcMMOPlayer == null) {
|
||||
PlayerProfile profile = mcMMO.getDatabaseManager().loadPlayerProfile(playerName); // Temporary Profile
|
||||
|
||||
if (!CommandUtils.isLoaded(sender, profile)) {
|
||||
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()));
|
||||
if (!CommandUtils.isLoaded(sender, profile)) {
|
||||
return true;
|
||||
}
|
||||
|
||||
return true;
|
||||
if (mcMMO.p.getGeneralConfig().getScoreboardsEnabled()
|
||||
&& sender instanceof Player
|
||||
&& mcMMO.p.getGeneralConfig().getInspectUseBoard()) {
|
||||
ScoreboardManager.enablePlayerInspectScoreboard((Player) sender, profile);
|
||||
|
||||
default:
|
||||
return false;
|
||||
if (!mcMMO.p.getGeneralConfig().getInspectUseChat()) {
|
||||
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
|
||||
public List<String> onTabComplete(CommandSender sender, Command command, String alias, String[] args) {
|
||||
switch (args.length) {
|
||||
case 1:
|
||||
List<String> playerNames = CommandUtils.getOnlinePlayerNames(sender);
|
||||
return StringUtil.copyPartialMatches(args[0], playerNames, new ArrayList<String>(playerNames.size()));
|
||||
default:
|
||||
return ImmutableList.of();
|
||||
public List<String> onTabComplete(@NotNull CommandSender sender, @NotNull Command command, @NotNull String alias, String[] args) {
|
||||
if (args.length == 1) {
|
||||
List<String> playerNames = CommandUtils.getOnlinePlayerNames(sender);
|
||||
return StringUtil.copyPartialMatches(args[0], playerNames, new ArrayList<>(playerNames.size()));
|
||||
}
|
||||
return ImmutableList.of();
|
||||
}
|
||||
}
|
||||
|
@ -1,9 +1,9 @@
|
||||
package com.gmail.nossr50.commands.player;
|
||||
|
||||
import com.gmail.nossr50.config.Config;
|
||||
import com.gmail.nossr50.datatypes.player.McMMOPlayer;
|
||||
import com.gmail.nossr50.datatypes.skills.SuperAbilityType;
|
||||
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.gmail.nossr50.util.scoreboards.ScoreboardManager;
|
||||
@ -12,12 +12,13 @@ import org.bukkit.command.Command;
|
||||
import org.bukkit.command.CommandSender;
|
||||
import org.bukkit.command.TabExecutor;
|
||||
import org.bukkit.entity.Player;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
public class MccooldownCommand implements TabExecutor {
|
||||
@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)) {
|
||||
return true;
|
||||
}
|
||||
@ -26,53 +27,48 @@ public class MccooldownCommand implements TabExecutor {
|
||||
return true;
|
||||
}
|
||||
|
||||
switch (args.length) {
|
||||
case 0:
|
||||
Player player = (Player) sender;
|
||||
if (args.length == 0) {
|
||||
Player player = (Player) sender;
|
||||
|
||||
if (Config.getInstance().getScoreboardsEnabled() && Config.getInstance().getCooldownUseBoard()) {
|
||||
ScoreboardManager.enablePlayerCooldownScoreboard(player);
|
||||
if (mcMMO.p.getGeneralConfig().getScoreboardsEnabled() && mcMMO.p.getGeneralConfig().getCooldownUseBoard()) {
|
||||
ScoreboardManager.enablePlayerCooldownScoreboard(player);
|
||||
|
||||
if (!Config.getInstance().getCooldownUseChat()) {
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
||||
if(UserManager.getPlayer(player) == null)
|
||||
{
|
||||
player.sendMessage(LocaleLoader.getString("Profile.PendingLoad"));
|
||||
if (!mcMMO.p.getGeneralConfig().getCooldownUseChat()) {
|
||||
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"));
|
||||
player.sendMessage(LocaleLoader.getString("mcMMO.NoSkillNote"));
|
||||
McMMOPlayer mcMMOPlayer = UserManager.getPlayer(player);
|
||||
|
||||
for (SuperAbilityType ability : SuperAbilityType.values()) {
|
||||
if (!ability.getPermissions(player)) {
|
||||
continue;
|
||||
}
|
||||
player.sendMessage(LocaleLoader.getString("Commands.Cooldowns.Header"));
|
||||
player.sendMessage(LocaleLoader.getString("mcMMO.NoSkillNote"));
|
||||
|
||||
int seconds = mcMMOPlayer.calculateTimeRemaining(ability);
|
||||
|
||||
if (seconds <= 0) {
|
||||
player.sendMessage(LocaleLoader.getString("Commands.Cooldowns.Row.Y", ability.getName()));
|
||||
}
|
||||
else {
|
||||
player.sendMessage(LocaleLoader.getString("Commands.Cooldowns.Row.N", ability.getName(), seconds));
|
||||
}
|
||||
for (SuperAbilityType ability : SuperAbilityType.values()) {
|
||||
if (!ability.getPermissions(player)) {
|
||||
continue;
|
||||
}
|
||||
|
||||
return true;
|
||||
int seconds = mcMMOPlayer.calculateTimeRemaining(ability);
|
||||
|
||||
default:
|
||||
return false;
|
||||
if (seconds <= 0) {
|
||||
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
|
||||
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();
|
||||
}
|
||||
}
|
||||
|
@ -1,10 +1,10 @@
|
||||
package com.gmail.nossr50.commands.player;
|
||||
|
||||
import com.gmail.nossr50.config.Config;
|
||||
import com.gmail.nossr50.datatypes.player.McMMOPlayer;
|
||||
import com.gmail.nossr50.locale.LocaleLoader;
|
||||
import com.gmail.nossr50.mcMMO;
|
||||
import com.gmail.nossr50.runnables.commands.McrankCommandAsyncTask;
|
||||
import com.gmail.nossr50.util.MetadataConstants;
|
||||
import com.gmail.nossr50.util.Permissions;
|
||||
import com.gmail.nossr50.util.commands.CommandUtils;
|
||||
import com.gmail.nossr50.util.player.UserManager;
|
||||
@ -15,13 +15,14 @@ import org.bukkit.command.TabExecutor;
|
||||
import org.bukkit.entity.Player;
|
||||
import org.bukkit.metadata.FixedMetadataValue;
|
||||
import org.bukkit.util.StringUtil;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
public class McrankCommand implements TabExecutor {
|
||||
@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) {
|
||||
case 0:
|
||||
if (CommandUtils.noConsoleUsage(sender)) {
|
||||
@ -72,14 +73,12 @@ public class McrankCommand implements TabExecutor {
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<String> onTabComplete(CommandSender sender, Command command, String alias, String[] args) {
|
||||
switch (args.length) {
|
||||
case 1:
|
||||
List<String> playerNames = CommandUtils.getOnlinePlayerNames(sender);
|
||||
return StringUtil.copyPartialMatches(args[0], playerNames, new ArrayList<String>(playerNames.size()));
|
||||
default:
|
||||
return ImmutableList.of();
|
||||
public List<String> onTabComplete(@NotNull CommandSender sender, @NotNull Command command, @NotNull String alias, String[] args) {
|
||||
if (args.length == 1) {
|
||||
List<String> playerNames = CommandUtils.getOnlinePlayerNames(sender);
|
||||
return StringUtil.copyPartialMatches(args[0], playerNames, new ArrayList<>(playerNames.size()));
|
||||
}
|
||||
return ImmutableList.of();
|
||||
}
|
||||
|
||||
private void display(CommandSender sender, String playerName) {
|
||||
@ -92,25 +91,25 @@ public class McrankCommand implements TabExecutor {
|
||||
return;
|
||||
}
|
||||
|
||||
long cooldownMillis = Math.min(Config.getInstance().getDatabasePlayerCooldown(), 1750);
|
||||
long cooldownMillis = Math.min(mcMMO.p.getGeneralConfig().getDatabasePlayerCooldown(), 1750);
|
||||
|
||||
if (mcMMOPlayer.getDatabaseATS() + cooldownMillis > System.currentTimeMillis()) {
|
||||
sender.sendMessage(LocaleLoader.getString("Commands.Database.CooldownMS", getCDSeconds(mcMMOPlayer, cooldownMillis)));
|
||||
return;
|
||||
}
|
||||
|
||||
if (((Player) sender).hasMetadata(mcMMO.databaseCommandKey)) {
|
||||
if (((Player) sender).hasMetadata(MetadataConstants.METADATA_KEY_DATABASE_COMMAND)) {
|
||||
sender.sendMessage(LocaleLoader.getString("Commands.Database.Processing"));
|
||||
return;
|
||||
} 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();
|
||||
}
|
||||
|
||||
boolean useBoard = Config.getInstance().getScoreboardsEnabled() && (sender instanceof Player) && (Config.getInstance().getRankUseBoard());
|
||||
boolean useChat = !useBoard || Config.getInstance().getRankUseChat();
|
||||
boolean useBoard = mcMMO.p.getGeneralConfig().getScoreboardsEnabled() && (sender instanceof Player) && (mcMMO.p.getGeneralConfig().getRankUseBoard());
|
||||
boolean useChat = !useBoard || mcMMO.p.getGeneralConfig().getRankUseChat();
|
||||
|
||||
new McrankCommandAsyncTask(playerName, sender, useBoard, useChat).runTaskAsynchronously(mcMMO.p);
|
||||
}
|
||||
|
@ -1,7 +1,7 @@
|
||||
package com.gmail.nossr50.commands.player;
|
||||
|
||||
import com.gmail.nossr50.config.Config;
|
||||
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.gmail.nossr50.util.scoreboards.ScoreboardManager;
|
||||
@ -10,12 +10,13 @@ import org.bukkit.command.Command;
|
||||
import org.bukkit.command.CommandSender;
|
||||
import org.bukkit.command.TabExecutor;
|
||||
import org.bukkit.entity.Player;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
public class McstatsCommand implements TabExecutor {
|
||||
@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)) {
|
||||
return true;
|
||||
}
|
||||
@ -24,49 +25,44 @@ public class McstatsCommand implements TabExecutor {
|
||||
return true;
|
||||
}
|
||||
|
||||
switch (args.length) {
|
||||
case 0:
|
||||
if(UserManager.getPlayer((Player) sender) == null)
|
||||
{
|
||||
sender.sendMessage(LocaleLoader.getString("Profile.PendingLoad"));
|
||||
if (args.length == 0) {
|
||||
if (UserManager.getPlayer((Player) sender) == null) {
|
||||
sender.sendMessage(LocaleLoader.getString("Profile.PendingLoad"));
|
||||
return true;
|
||||
}
|
||||
|
||||
Player player = (Player) sender;
|
||||
|
||||
if (mcMMO.p.getGeneralConfig().getStatsUseBoard() && mcMMO.p.getGeneralConfig().getScoreboardsEnabled()) {
|
||||
ScoreboardManager.enablePlayerStatsScoreboard(player);
|
||||
|
||||
if (!mcMMO.p.getGeneralConfig().getStatsUseChat()) {
|
||||
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()) {
|
||||
ScoreboardManager.enablePlayerStatsScoreboard(player);
|
||||
CommandUtils.printGatheringSkills(player);
|
||||
CommandUtils.printCombatSkills(player);
|
||||
CommandUtils.printMiscSkills(player);
|
||||
|
||||
if (!Config.getInstance().getStatsUseChat()) {
|
||||
return true;
|
||||
}
|
||||
}
|
||||
int powerLevelCap = mcMMO.p.getGeneralConfig().getPowerLevelCap();
|
||||
|
||||
player.sendMessage(LocaleLoader.getString("Stats.Own.Stats"));
|
||||
player.sendMessage(LocaleLoader.getString("mcMMO.NoSkillNote"));
|
||||
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()));
|
||||
}
|
||||
|
||||
CommandUtils.printGatheringSkills(player);
|
||||
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 true;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
@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();
|
||||
}
|
||||
}
|
||||
|
@ -1,15 +1,15 @@
|
||||
package com.gmail.nossr50.commands.player;
|
||||
|
||||
import com.gmail.nossr50.config.Config;
|
||||
import com.gmail.nossr50.datatypes.player.McMMOPlayer;
|
||||
import com.gmail.nossr50.datatypes.skills.PrimarySkillType;
|
||||
import com.gmail.nossr50.locale.LocaleLoader;
|
||||
import com.gmail.nossr50.mcMMO;
|
||||
import com.gmail.nossr50.runnables.commands.MctopCommandAsyncTask;
|
||||
import com.gmail.nossr50.util.MetadataConstants;
|
||||
import com.gmail.nossr50.util.Permissions;
|
||||
import com.gmail.nossr50.util.StringUtils;
|
||||
import com.gmail.nossr50.util.commands.CommandUtils;
|
||||
import com.gmail.nossr50.util.player.UserManager;
|
||||
import com.gmail.nossr50.util.text.StringUtils;
|
||||
import com.google.common.collect.ImmutableList;
|
||||
import org.bukkit.command.Command;
|
||||
import org.bukkit.command.CommandSender;
|
||||
@ -17,13 +17,14 @@ import org.bukkit.command.TabExecutor;
|
||||
import org.bukkit.entity.Player;
|
||||
import org.bukkit.metadata.FixedMetadataValue;
|
||||
import org.bukkit.util.StringUtil;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
public class MctopCommand implements TabExecutor {
|
||||
@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;
|
||||
|
||||
switch (args.length) {
|
||||
@ -66,13 +67,11 @@ public class MctopCommand implements TabExecutor {
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<String> onTabComplete(CommandSender sender, Command command, String alias, String[] args) {
|
||||
switch (args.length) {
|
||||
case 1:
|
||||
return StringUtil.copyPartialMatches(args[0], PrimarySkillType.SKILL_NAMES, new ArrayList<String>(PrimarySkillType.SKILL_NAMES.size()));
|
||||
default:
|
||||
return ImmutableList.of();
|
||||
public List<String> onTabComplete(@NotNull CommandSender sender, @NotNull Command command, @NotNull String alias, String[] args) {
|
||||
if (args.length == 1) {
|
||||
return StringUtil.copyPartialMatches(args[0], mcMMO.p.getSkillTools().LOCALIZED_SKILL_NAMES, new ArrayList<>(mcMMO.p.getSkillTools().LOCALIZED_SKILL_NAMES.size()));
|
||||
}
|
||||
return ImmutableList.of();
|
||||
}
|
||||
|
||||
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());
|
||||
long cooldownMillis = Math.max(Config.getInstance().getDatabasePlayerCooldown(), 1750);
|
||||
long cooldownMillis = Math.max(mcMMO.p.getGeneralConfig().getDatabasePlayerCooldown(), 1750);
|
||||
|
||||
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) {
|
||||
seconds = 1;
|
||||
}
|
||||
@ -99,11 +98,11 @@ public class MctopCommand implements TabExecutor {
|
||||
return;
|
||||
}
|
||||
|
||||
if (((Player) sender).hasMetadata(mcMMO.databaseCommandKey)) {
|
||||
if (((Player) sender).hasMetadata(MetadataConstants.METADATA_KEY_DATABASE_COMMAND)) {
|
||||
sender.sendMessage(LocaleLoader.getString("Commands.Database.Processing"));
|
||||
return;
|
||||
} 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();
|
||||
@ -113,8 +112,8 @@ public class MctopCommand implements TabExecutor {
|
||||
}
|
||||
|
||||
private void display(int page, PrimarySkillType skill, CommandSender sender) {
|
||||
boolean useBoard = (sender instanceof Player) && (Config.getInstance().getTopUseBoard());
|
||||
boolean useChat = !useBoard || Config.getInstance().getTopUseChat();
|
||||
boolean useBoard = (sender instanceof Player) && (mcMMO.p.getGeneralConfig().getTopUseBoard());
|
||||
boolean useChat = !useBoard || mcMMO.p.getGeneralConfig().getTopUseChat();
|
||||
|
||||
new MctopCommandAsyncTask(page, skill, sender, useBoard, useChat).runTaskAsynchronously(mcMMO.p);
|
||||
}
|
||||
@ -124,7 +123,7 @@ public class MctopCommand implements TabExecutor {
|
||||
return null;
|
||||
}
|
||||
|
||||
PrimarySkillType skill = PrimarySkillType.getSkill(skillName);
|
||||
PrimarySkillType skill = mcMMO.p.getSkillTools().matchSkill(skillName);
|
||||
|
||||
if (CommandUtils.isChildSkill(sender, skill)) {
|
||||
return null;
|
||||
|
@ -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();
|
||||
}
|
||||
}
|
||||
}
|
@ -3,13 +3,14 @@ package com.gmail.nossr50.commands.server;
|
||||
import org.bukkit.command.Command;
|
||||
import org.bukkit.command.CommandExecutor;
|
||||
import org.bukkit.command.CommandSender;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
|
||||
/**
|
||||
* This command facilitates switching the skill system scale between classic and modern scale
|
||||
*/
|
||||
public class Mcmmoupgrade implements CommandExecutor {
|
||||
@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;
|
||||
}
|
||||
}
|
||||
|
@ -5,11 +5,11 @@ import com.gmail.nossr50.datatypes.skills.SubSkillType;
|
||||
import com.gmail.nossr50.datatypes.skills.subskills.AbstractSubSkill;
|
||||
import com.gmail.nossr50.listeners.InteractionManager;
|
||||
import com.gmail.nossr50.locale.LocaleLoader;
|
||||
import com.gmail.nossr50.util.TextComponentFactory;
|
||||
import com.gmail.nossr50.util.random.RandomChanceSkill;
|
||||
import com.gmail.nossr50.util.random.RandomChanceUtil;
|
||||
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 java.util.ArrayList;
|
||||
@ -44,7 +44,7 @@ public class AcrobaticsCommand extends SkillCommand {
|
||||
|
||||
@Override
|
||||
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) {
|
||||
messages.add(getStatMessage(SubSkillType.ACROBATICS_DODGE, dodgeChance)
|
||||
@ -69,9 +69,9 @@ public class AcrobaticsCommand extends SkillCommand {
|
||||
//Chance Stat Calculations
|
||||
rollChance = RandomChanceUtil.getRandomChanceExecutionChance(roll_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
|
||||
double rollChanceLucky = rollChance * 1.333D;
|
||||
@ -89,8 +89,8 @@ public class AcrobaticsCommand extends SkillCommand {
|
||||
}
|
||||
|
||||
@Override
|
||||
protected List<TextComponent> getTextComponents(Player player) {
|
||||
List<TextComponent> textComponents = new ArrayList<>();
|
||||
protected List<Component> getTextComponents(Player player) {
|
||||
List<Component> textComponents = new ArrayList<>();
|
||||
|
||||
TextComponentFactory.getSubSkillTextComponents(player, textComponents, PrimarySkillType.ACROBATICS);
|
||||
|
||||
|
@ -5,10 +5,10 @@ import com.gmail.nossr50.datatypes.skills.SubSkillType;
|
||||
import com.gmail.nossr50.locale.LocaleLoader;
|
||||
import com.gmail.nossr50.skills.alchemy.AlchemyManager;
|
||||
import com.gmail.nossr50.util.Permissions;
|
||||
import com.gmail.nossr50.util.TextComponentFactory;
|
||||
import com.gmail.nossr50.util.player.UserManager;
|
||||
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 java.util.ArrayList;
|
||||
@ -74,7 +74,7 @@ public class AlchemyCommand extends SkillCommand {
|
||||
|
||||
@Override
|
||||
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) {
|
||||
messages.add(getStatMessage(SubSkillType.ALCHEMY_CATALYSIS, brewSpeed)
|
||||
@ -93,8 +93,8 @@ public class AlchemyCommand extends SkillCommand {
|
||||
}
|
||||
|
||||
@Override
|
||||
protected List<TextComponent> getTextComponents(Player player) {
|
||||
List<TextComponent> textComponents = new ArrayList<>();
|
||||
protected List<Component> getTextComponents(Player player) {
|
||||
List<Component> textComponents = new ArrayList<>();
|
||||
|
||||
TextComponentFactory.getSubSkillTextComponents(player, textComponents, PrimarySkillType.ALCHEMY);
|
||||
|
||||
|
@ -1,203 +1,199 @@
|
||||
package com.gmail.nossr50.commands.skills;
|
||||
|
||||
import com.gmail.nossr50.locale.LocaleLoader;
|
||||
import com.gmail.nossr50.util.HolidayManager.FakeSkillType;
|
||||
import com.gmail.nossr50.util.Misc;
|
||||
import com.gmail.nossr50.util.StringUtils;
|
||||
import com.gmail.nossr50.util.commands.CommandUtils;
|
||||
import com.google.common.collect.ImmutableList;
|
||||
import org.bukkit.command.Command;
|
||||
import org.bukkit.command.CommandSender;
|
||||
import org.bukkit.command.TabExecutor;
|
||||
import org.bukkit.entity.Player;
|
||||
|
||||
import java.text.DecimalFormat;
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
public class AprilCommand implements TabExecutor {
|
||||
private String skillName;
|
||||
|
||||
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) {
|
||||
if (CommandUtils.noConsoleUsage(sender)) {
|
||||
return true;
|
||||
}
|
||||
|
||||
skillName = StringUtils.getCapitalized(label);
|
||||
|
||||
switch (args.length) {
|
||||
case 0:
|
||||
Player player = (Player) sender;
|
||||
FakeSkillType fakeSkillType = FakeSkillType.getByName(skillName);
|
||||
|
||||
float skillValue = Misc.getRandom().nextInt(99);
|
||||
|
||||
player.sendMessage(LocaleLoader.getString("Skills.Header", skillName));
|
||||
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)));
|
||||
|
||||
|
||||
List<String> effectMessages = effectsDisplay(fakeSkillType);
|
||||
|
||||
if (!effectMessages.isEmpty()) {
|
||||
player.sendMessage(LocaleLoader.getString("Skills.Header", LocaleLoader.getString("Effects.Effects")));
|
||||
|
||||
for (String message : effectMessages) {
|
||||
player.sendMessage(message);
|
||||
}
|
||||
}
|
||||
|
||||
List<String> statsMessages = statsDisplay(fakeSkillType);
|
||||
|
||||
if (!statsMessages.isEmpty()) {
|
||||
player.sendMessage(LocaleLoader.getString("Skills.Header", LocaleLoader.getString("Commands.Stats.Self")));
|
||||
|
||||
for (String message : statsMessages) {
|
||||
player.sendMessage(message);
|
||||
}
|
||||
}
|
||||
|
||||
player.sendMessage(LocaleLoader.formatString("[[DARK_AQUA]]Guide for {0} available - type /APRIL FOOLS ! :D", skillName));
|
||||
return true;
|
||||
|
||||
default:
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
||||
private String getXPGainString(FakeSkillType fakeSkillType) {
|
||||
switch (fakeSkillType) {
|
||||
case MACHO:
|
||||
return "Get beaten up";
|
||||
case JUMPING:
|
||||
return "Kris Kross will make ya Jump Jump";
|
||||
case THROWING:
|
||||
return "Chuck your items on the floor";
|
||||
case WRECKING:
|
||||
return "I'M GONNA WRECK IT!";
|
||||
case CRAFTING:
|
||||
return "Craft apple pies";
|
||||
case WALKING:
|
||||
return "Walk around the park";
|
||||
case SWIMMING:
|
||||
return "Like a fish on a bicycle";
|
||||
case FALLING:
|
||||
return "Faceplant the floor, headbutt the ground";
|
||||
case CLIMBING:
|
||||
return "Climb the highest mountain";
|
||||
case FLYING:
|
||||
return "I believe I can fly";
|
||||
case DIVING:
|
||||
return "Scuba club 4000";
|
||||
case PIGGY:
|
||||
return "OINK! OINK!";
|
||||
default:
|
||||
return "Sit and wait?";
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<String> onTabComplete(CommandSender sender, Command command, String alias, String[] args) {
|
||||
switch (args.length) {
|
||||
case 1:
|
||||
return ImmutableList.of("?");
|
||||
default:
|
||||
return ImmutableList.of();
|
||||
}
|
||||
}
|
||||
|
||||
private List<String> effectsDisplay(FakeSkillType fakeSkillType) {
|
||||
List<String> messages = new ArrayList<String>();
|
||||
|
||||
switch (fakeSkillType) {
|
||||
case MACHO:
|
||||
messages.add(LocaleLoader.getString("Effects.Template", "Punching bag", "Absorb damage, like a bag of sand"));
|
||||
break;
|
||||
case JUMPING:
|
||||
messages.add(LocaleLoader.getString("Effects.Template", "Jump", "PRESS SPACE TO JUMP"));
|
||||
messages.add(LocaleLoader.getString("Effects.Template", "Jump Twice", "PRESS SPACE TWICE TO JUMP TWICE"));
|
||||
break;
|
||||
case THROWING:
|
||||
messages.add(LocaleLoader.getString("Effects.Template", "Drop Item", "Randomly drop items, at random"));
|
||||
break;
|
||||
case WRECKING:
|
||||
messages.add(LocaleLoader.getString("Effects.Template", "Ralphinator", "Smash windows with your fists"));
|
||||
break;
|
||||
case CRAFTING:
|
||||
messages.add(LocaleLoader.getString("Effects.Template", "Crafting", "Chance of successful craft"));
|
||||
break;
|
||||
case WALKING:
|
||||
messages.add(LocaleLoader.getString("Effects.Template", "Walk", "Traveling gracefully by foot"));
|
||||
break;
|
||||
case SWIMMING:
|
||||
messages.add(LocaleLoader.getString("Effects.Template", "Swim", "Just keep swimming, swimming, swimming"));
|
||||
break;
|
||||
case FALLING:
|
||||
messages.add(LocaleLoader.getString("Effects.Template", "Skydiving", "Go jump of a cliff. No, seriously."));
|
||||
break;
|
||||
case CLIMBING:
|
||||
messages.add(LocaleLoader.getString("Effects.Template", "Rock Climber", "Use string to climb mountains faster"));
|
||||
break;
|
||||
case FLYING:
|
||||
messages.add(LocaleLoader.getString("Effects.Template", "Fly", "Throw yourself at the ground and miss"));
|
||||
break;
|
||||
case DIVING:
|
||||
messages.add(LocaleLoader.getString("Effects.Template", "Hold Breath", "Press shift to hold your breath longer"));
|
||||
break;
|
||||
case PIGGY:
|
||||
messages.add(LocaleLoader.getString("Effects.Template", "Carrot Turbo", "Supercharge your pigs with carrots"));
|
||||
break;
|
||||
}
|
||||
|
||||
return messages;
|
||||
}
|
||||
|
||||
private List<String> statsDisplay(FakeSkillType fakeSkillType) {
|
||||
List<String> messages = new ArrayList<String>();
|
||||
|
||||
switch (fakeSkillType) {
|
||||
case MACHO:
|
||||
messages.add(LocaleLoader.formatString("[[RED]]Damage Taken: [[YELLOW]]{0}%", decimal.format(Misc.getRandom().nextInt(77))));
|
||||
break;
|
||||
case JUMPING:
|
||||
messages.add(LocaleLoader.formatString("[[RED]]Double Jump Chance: [[YELLOW]]{0}%", decimal.format(Misc.getRandom().nextInt(27))));
|
||||
break;
|
||||
case THROWING:
|
||||
messages.add(LocaleLoader.formatString("[[RED]]Drop Item Chance: [[YELLOW]]{0}%", decimal.format(Misc.getRandom().nextInt(87))));
|
||||
break;
|
||||
case WRECKING:
|
||||
messages.add(LocaleLoader.formatString("[[RED]]Wrecking Chance: [[YELLOW]]{0}%", decimal.format(Misc.getRandom().nextInt(14))));
|
||||
break;
|
||||
case CRAFTING:
|
||||
messages.add(LocaleLoader.formatString("[[RED]]Crafting Success: [[YELLOW]]{0}%", decimal.format(Misc.getRandom().nextInt(27))));
|
||||
break;
|
||||
case WALKING:
|
||||
messages.add(LocaleLoader.formatString("[[RED]]Walk Chance: [[YELLOW]]{0}%", decimal.format(Misc.getRandom().nextInt(27))));
|
||||
break;
|
||||
case SWIMMING:
|
||||
messages.add(LocaleLoader.formatString("[[RED]]Swim Chance: [[YELLOW]]{0}%", decimal.format(Misc.getRandom().nextInt(27))));
|
||||
break;
|
||||
case FALLING:
|
||||
messages.add(LocaleLoader.formatString("[[RED]]Skydiving Success: [[YELLOW]]{0}%", decimal.format(Misc.getRandom().nextInt(37))));
|
||||
break;
|
||||
case CLIMBING:
|
||||
messages.add(LocaleLoader.formatString("[[RED]]Rock Climber Chance: [[YELLOW]]{0}%", decimal.format(Misc.getRandom().nextInt(27))));
|
||||
break;
|
||||
case FLYING:
|
||||
messages.add(LocaleLoader.formatString("[[RED]]Fly Chance: [[YELLOW]]{0}%", decimal.format(Misc.getRandom().nextInt(27))));
|
||||
break;
|
||||
case DIVING:
|
||||
messages.add(LocaleLoader.formatString("[[RED]]Hold Breath Chance: [[YELLOW]]{0}%", decimal.format(Misc.getRandom().nextInt(27))));
|
||||
break;
|
||||
case PIGGY:
|
||||
messages.add(LocaleLoader.formatString("[[RED]]Carrot Turbo Boost: [[YELLOW]]{0}%", decimal.format(Misc.getRandom().nextInt(80)) + 10));
|
||||
break;
|
||||
}
|
||||
|
||||
return messages;
|
||||
}
|
||||
}
|
||||
//package com.gmail.nossr50.commands.skills;
|
||||
//
|
||||
//import com.gmail.nossr50.locale.LocaleLoader;
|
||||
//import com.gmail.nossr50.util.HolidayManager.FakeSkillType;
|
||||
//import com.gmail.nossr50.util.Misc;
|
||||
//import com.gmail.nossr50.util.commands.CommandUtils;
|
||||
//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.jetbrains.annotations.NotNull;
|
||||
//
|
||||
//import java.text.DecimalFormat;
|
||||
//import java.util.ArrayList;
|
||||
//import java.util.List;
|
||||
//
|
||||
//public class AprilCommand implements TabExecutor {
|
||||
// private String skillName;
|
||||
//
|
||||
// protected DecimalFormat percent = new DecimalFormat("##0.00%");
|
||||
// protected DecimalFormat decimal = new DecimalFormat("##0.00");
|
||||
//
|
||||
// @Override
|
||||
// public boolean onCommand(@NotNull CommandSender sender, @NotNull Command command, @NotNull String label, String[] args) {
|
||||
// if (CommandUtils.noConsoleUsage(sender)) {
|
||||
// return true;
|
||||
// }
|
||||
//
|
||||
// skillName = StringUtils.getCapitalized(label);
|
||||
//
|
||||
// if (args.length == 0) {
|
||||
// Player player = (Player) sender;
|
||||
// FakeSkillType fakeSkillType = FakeSkillType.getByName(skillName);
|
||||
//
|
||||
// float skillValue = Misc.getRandom().nextInt(99);
|
||||
//
|
||||
// player.sendMessage(LocaleLoader.getString("Skills.Header", skillName));
|
||||
// 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)));
|
||||
//
|
||||
//
|
||||
// List<String> effectMessages = effectsDisplay(fakeSkillType);
|
||||
//
|
||||
// if (!effectMessages.isEmpty()) {
|
||||
// player.sendMessage(LocaleLoader.getString("Skills.Header", LocaleLoader.getString("Effects.Effects")));
|
||||
//
|
||||
// for (String message : effectMessages) {
|
||||
// player.sendMessage(message);
|
||||
// }
|
||||
// }
|
||||
//
|
||||
// List<String> statsMessages = statsDisplay(fakeSkillType);
|
||||
//
|
||||
// if (!statsMessages.isEmpty()) {
|
||||
// player.sendMessage(LocaleLoader.getString("Skills.Header", LocaleLoader.getString("Commands.Stats.Self")));
|
||||
//
|
||||
// for (String message : statsMessages) {
|
||||
// player.sendMessage(message);
|
||||
// }
|
||||
// }
|
||||
//
|
||||
// player.sendMessage(LocaleLoader.formatString("[[DARK_AQUA]]Guide for {0} available - type /APRIL FOOLS ! :D", skillName));
|
||||
// return true;
|
||||
// }
|
||||
// return true;
|
||||
// }
|
||||
//
|
||||
// private String getXPGainString(FakeSkillType fakeSkillType) {
|
||||
// switch (fakeSkillType) {
|
||||
// case MACHO:
|
||||
// return "Get beaten up";
|
||||
// case JUMPING:
|
||||
// return "Kris Kross will make ya Jump Jump";
|
||||
// case THROWING:
|
||||
// return "Chuck your items on the floor";
|
||||
// case WRECKING:
|
||||
// return "I'M GONNA WRECK IT!";
|
||||
// case CRAFTING:
|
||||
// return "Craft apple pies";
|
||||
// case WALKING:
|
||||
// return "Walk around the park";
|
||||
// case SWIMMING:
|
||||
// return "Like a fish on a bicycle";
|
||||
// case FALLING:
|
||||
// return "Faceplant the floor, headbutt the ground";
|
||||
// case CLIMBING:
|
||||
// return "Climb the highest mountain";
|
||||
// case FLYING:
|
||||
// return "I believe I can fly";
|
||||
// case DIVING:
|
||||
// return "Scuba club 4000";
|
||||
// case PIGGY:
|
||||
// return "OINK! OINK!";
|
||||
// default:
|
||||
// return "Sit and wait?";
|
||||
// }
|
||||
// }
|
||||
//
|
||||
// @Override
|
||||
// public List<String> onTabComplete(@NotNull CommandSender sender, @NotNull Command command, @NotNull String alias, String[] args) {
|
||||
// if (args.length == 1) {
|
||||
// return ImmutableList.of("?");
|
||||
// }
|
||||
// return ImmutableList.of();
|
||||
// }
|
||||
//
|
||||
// private List<String> effectsDisplay(FakeSkillType fakeSkillType) {
|
||||
// List<String> messages = new ArrayList<>();
|
||||
//
|
||||
// switch (fakeSkillType) {
|
||||
// case MACHO:
|
||||
// messages.add(LocaleLoader.getString("Effects.Template", "Punching bag", "Absorb damage, like a bag of sand"));
|
||||
// break;
|
||||
// case JUMPING:
|
||||
// messages.add(LocaleLoader.getString("Effects.Template", "Jump", "PRESS SPACE TO JUMP"));
|
||||
// messages.add(LocaleLoader.getString("Effects.Template", "Jump Twice", "PRESS SPACE TWICE TO JUMP TWICE"));
|
||||
// break;
|
||||
// case THROWING:
|
||||
// messages.add(LocaleLoader.getString("Effects.Template", "Drop Item", "Randomly drop items, at random"));
|
||||
// break;
|
||||
// case WRECKING:
|
||||
// messages.add(LocaleLoader.getString("Effects.Template", "Ralphinator", "Smash windows with your fists"));
|
||||
// break;
|
||||
// case CRAFTING:
|
||||
// messages.add(LocaleLoader.getString("Effects.Template", "Crafting", "Chance of successful craft"));
|
||||
// break;
|
||||
// case WALKING:
|
||||
// messages.add(LocaleLoader.getString("Effects.Template", "Walk", "Traveling gracefully by foot"));
|
||||
// break;
|
||||
// case SWIMMING:
|
||||
// messages.add(LocaleLoader.getString("Effects.Template", "Swim", "Just keep swimming, swimming, swimming"));
|
||||
// break;
|
||||
// case FALLING:
|
||||
// messages.add(LocaleLoader.getString("Effects.Template", "Skydiving", "Go jump of a cliff. No, seriously."));
|
||||
// break;
|
||||
// case CLIMBING:
|
||||
// messages.add(LocaleLoader.getString("Effects.Template", "Rock Climber", "Use string to climb mountains faster"));
|
||||
// break;
|
||||
// case FLYING:
|
||||
// messages.add(LocaleLoader.getString("Effects.Template", "Fly", "Throw yourself at the ground and miss"));
|
||||
// break;
|
||||
// case DIVING:
|
||||
// messages.add(LocaleLoader.getString("Effects.Template", "Hold Breath", "Press shift to hold your breath longer"));
|
||||
// break;
|
||||
// case PIGGY:
|
||||
// messages.add(LocaleLoader.getString("Effects.Template", "Carrot Turbo", "Supercharge your pigs with carrots"));
|
||||
// break;
|
||||
// }
|
||||
//
|
||||
// return messages;
|
||||
// }
|
||||
//
|
||||
// private List<String> statsDisplay(FakeSkillType fakeSkillType) {
|
||||
// List<String> messages = new ArrayList<>();
|
||||
//
|
||||
// switch (fakeSkillType) {
|
||||
// case MACHO:
|
||||
// messages.add(LocaleLoader.formatString("&cDamage Taken: &e{0}%", decimal.format(Misc.getRandom().nextInt(77))));
|
||||
// break;
|
||||
// case JUMPING:
|
||||
// messages.add(LocaleLoader.formatString("&cDouble Jump Chance: &e{0}%", decimal.format(Misc.getRandom().nextInt(27))));
|
||||
// break;
|
||||
// case THROWING:
|
||||
// messages.add(LocaleLoader.formatString("&cDrop Item Chance: &e{0}%", decimal.format(Misc.getRandom().nextInt(87))));
|
||||
// break;
|
||||
// case WRECKING:
|
||||
// messages.add(LocaleLoader.formatString("&cWrecking Chance: &e{0}%", decimal.format(Misc.getRandom().nextInt(14))));
|
||||
// break;
|
||||
// case CRAFTING:
|
||||
// messages.add(LocaleLoader.formatString("&cCrafting Success: &e{0}%", decimal.format(Misc.getRandom().nextInt(27))));
|
||||
// break;
|
||||
// case WALKING:
|
||||
// messages.add(LocaleLoader.formatString("&cWalk Chance: &e{0}%", decimal.format(Misc.getRandom().nextInt(27))));
|
||||
// break;
|
||||
// case SWIMMING:
|
||||
// messages.add(LocaleLoader.formatString("&cSwim Chance: &e{0}%", decimal.format(Misc.getRandom().nextInt(27))));
|
||||
// break;
|
||||
// case FALLING:
|
||||
// messages.add(LocaleLoader.formatString("&cSkydiving Success: &e{0}%", decimal.format(Misc.getRandom().nextInt(37))));
|
||||
// break;
|
||||
// case CLIMBING:
|
||||
// messages.add(LocaleLoader.formatString("&cRock Climber Chance: &e{0}%", decimal.format(Misc.getRandom().nextInt(27))));
|
||||
// break;
|
||||
// case FLYING:
|
||||
// messages.add(LocaleLoader.formatString("&cFly Chance: &e{0}%", decimal.format(Misc.getRandom().nextInt(27))));
|
||||
// break;
|
||||
// case DIVING:
|
||||
// messages.add(LocaleLoader.formatString("&cHold Breath Chance: &e{0}%", decimal.format(Misc.getRandom().nextInt(27))));
|
||||
// break;
|
||||
// case PIGGY:
|
||||
// messages.add(LocaleLoader.formatString("&cCarrot Turbo Boost: &e{0}%", decimal.format(Misc.getRandom().nextInt(80)) + 10));
|
||||
// break;
|
||||
// }
|
||||
//
|
||||
// return messages;
|
||||
// }
|
||||
//}
|
||||
|
@ -4,10 +4,10 @@ import com.gmail.nossr50.datatypes.skills.PrimarySkillType;
|
||||
import com.gmail.nossr50.datatypes.skills.SubSkillType;
|
||||
import com.gmail.nossr50.locale.LocaleLoader;
|
||||
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.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 java.util.ArrayList;
|
||||
@ -59,7 +59,7 @@ public class ArcheryCommand extends SkillCommand {
|
||||
|
||||
@Override
|
||||
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) {
|
||||
messages.add(getStatMessage(SubSkillType.ARCHERY_ARROW_RETRIEVAL, retrieveChance)
|
||||
@ -84,8 +84,8 @@ public class ArcheryCommand extends SkillCommand {
|
||||
}
|
||||
|
||||
@Override
|
||||
protected List<TextComponent> getTextComponents(Player player) {
|
||||
List<TextComponent> textComponents = new ArrayList<>();
|
||||
protected List<Component> getTextComponents(Player player) {
|
||||
List<Component> textComponents = new ArrayList<>();
|
||||
|
||||
TextComponentFactory.getSubSkillTextComponents(player, textComponents, PrimarySkillType.ARCHERY);
|
||||
|
||||
|
@ -5,12 +5,12 @@ import com.gmail.nossr50.datatypes.skills.SubSkillType;
|
||||
import com.gmail.nossr50.locale.LocaleLoader;
|
||||
import com.gmail.nossr50.skills.axes.Axes;
|
||||
import com.gmail.nossr50.util.Permissions;
|
||||
import com.gmail.nossr50.util.TextComponentFactory;
|
||||
import com.gmail.nossr50.util.player.UserManager;
|
||||
import com.gmail.nossr50.util.skills.CombatUtils;
|
||||
import com.gmail.nossr50.util.skills.RankUtils;
|
||||
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 java.util.ArrayList;
|
||||
@ -72,7 +72,7 @@ public class AxesCommand extends SkillCommand {
|
||||
|
||||
@Override
|
||||
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) {
|
||||
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
|
||||
protected List<TextComponent> getTextComponents(Player player) {
|
||||
List<TextComponent> textComponents = new ArrayList<>();
|
||||
protected List<Component> getTextComponents(Player player) {
|
||||
List<Component> textComponents = new ArrayList<>();
|
||||
|
||||
TextComponentFactory.getSubSkillTextComponents(player, textComponents, PrimarySkillType.AXES);
|
||||
|
||||
|
@ -5,10 +5,10 @@ import com.gmail.nossr50.datatypes.skills.SubSkillType;
|
||||
import com.gmail.nossr50.locale.LocaleLoader;
|
||||
import com.gmail.nossr50.skills.excavation.ExcavationManager;
|
||||
import com.gmail.nossr50.util.Permissions;
|
||||
import com.gmail.nossr50.util.TextComponentFactory;
|
||||
import com.gmail.nossr50.util.player.UserManager;
|
||||
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 java.util.ArrayList;
|
||||
@ -29,7 +29,7 @@ public class ExcavationCommand extends SkillCommand {
|
||||
protected void dataCalculations(Player player, float skillValue) {
|
||||
// GIGA DRILL BREAKER
|
||||
if (canGigaDrill) {
|
||||
String gigaDrillStrings[] = calculateLengthDisplayValues(player, skillValue);
|
||||
String[] gigaDrillStrings = calculateLengthDisplayValues(player, skillValue);
|
||||
gigaDrillBreakerLength = gigaDrillStrings[0];
|
||||
gigaDrillBreakerLengthEndurance = gigaDrillStrings[1];
|
||||
}
|
||||
@ -43,7 +43,7 @@ public class ExcavationCommand extends SkillCommand {
|
||||
|
||||
@Override
|
||||
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();
|
||||
|
||||
@ -66,8 +66,8 @@ public class ExcavationCommand extends SkillCommand {
|
||||
}
|
||||
|
||||
@Override
|
||||
protected List<TextComponent> getTextComponents(Player player) {
|
||||
List<TextComponent> textComponents = new ArrayList<>();
|
||||
protected List<Component> getTextComponents(Player player) {
|
||||
List<Component> textComponents = new ArrayList<>();
|
||||
|
||||
TextComponentFactory.getSubSkillTextComponents(player, textComponents, PrimarySkillType.EXCAVATION);
|
||||
|
||||
|
@ -1,21 +1,18 @@
|
||||
package com.gmail.nossr50.commands.skills;
|
||||
|
||||
import com.gmail.nossr50.config.AdvancedConfig;
|
||||
import com.gmail.nossr50.config.treasure.TreasureConfig;
|
||||
import com.gmail.nossr50.config.treasure.FishingTreasureConfig;
|
||||
import com.gmail.nossr50.datatypes.skills.PrimarySkillType;
|
||||
import com.gmail.nossr50.datatypes.skills.SubSkillType;
|
||||
import com.gmail.nossr50.datatypes.treasure.Rarity;
|
||||
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.util.Permissions;
|
||||
import com.gmail.nossr50.util.TextComponentFactory;
|
||||
import com.gmail.nossr50.util.player.UserManager;
|
||||
import com.gmail.nossr50.util.random.RandomChanceUtil;
|
||||
import com.gmail.nossr50.util.skills.RankUtils;
|
||||
import net.md_5.bungee.api.chat.TextComponent;
|
||||
import org.bukkit.Location;
|
||||
import org.bukkit.entity.EntityType;
|
||||
import com.gmail.nossr50.util.text.StringUtils;
|
||||
import com.gmail.nossr50.util.text.TextComponentFactory;
|
||||
import net.kyori.adventure.text.Component;
|
||||
import org.bukkit.entity.Player;
|
||||
|
||||
import java.util.ArrayList;
|
||||
@ -26,15 +23,13 @@ public class FishingCommand extends SkillCommand {
|
||||
private String shakeChance;
|
||||
private String shakeChanceLucky;
|
||||
private int fishermansDietRank;
|
||||
private String biteChance;
|
||||
|
||||
private String trapTreasure;
|
||||
private String commonTreasure;
|
||||
private String uncommonTreasure;
|
||||
private String rareTreasure;
|
||||
private String epicTreasure;
|
||||
private String legendaryTreasure;
|
||||
private String recordTreasure;
|
||||
private String mythicTreasure;
|
||||
|
||||
private String magicChance;
|
||||
|
||||
@ -45,6 +40,8 @@ public class FishingCommand extends SkillCommand {
|
||||
private boolean canMasterAngler;
|
||||
private boolean canIceFish;
|
||||
|
||||
private String maMinWaitTime, maMaxWaitTime;
|
||||
|
||||
public FishingCommand() {
|
||||
super(PrimarySkillType.FISHING);
|
||||
}
|
||||
@ -58,19 +55,19 @@ public class FishingCommand extends SkillCommand {
|
||||
lootTier = fishingManager.getLootTier();
|
||||
|
||||
// Item drop rates
|
||||
commonTreasure = percent.format(TreasureConfig.getInstance().getItemDropRate(lootTier, Rarity.COMMON) / 100.0);
|
||||
uncommonTreasure = percent.format(TreasureConfig.getInstance().getItemDropRate(lootTier, Rarity.UNCOMMON) / 100.0);
|
||||
rareTreasure = percent.format(TreasureConfig.getInstance().getItemDropRate(lootTier, Rarity.RARE) / 100.0);
|
||||
epicTreasure = percent.format(TreasureConfig.getInstance().getItemDropRate(lootTier, Rarity.EPIC) / 100.0);
|
||||
legendaryTreasure = percent.format(TreasureConfig.getInstance().getItemDropRate(lootTier, Rarity.LEGENDARY) / 100.0);
|
||||
recordTreasure = percent.format(TreasureConfig.getInstance().getItemDropRate(lootTier, Rarity.RECORD) / 100.0);
|
||||
commonTreasure = percent.format(FishingTreasureConfig.getInstance().getItemDropRate(lootTier, Rarity.COMMON) / 100.0);
|
||||
uncommonTreasure = percent.format(FishingTreasureConfig.getInstance().getItemDropRate(lootTier, Rarity.UNCOMMON) / 100.0);
|
||||
rareTreasure = percent.format(FishingTreasureConfig.getInstance().getItemDropRate(lootTier, Rarity.RARE) / 100.0);
|
||||
epicTreasure = percent.format(FishingTreasureConfig.getInstance().getItemDropRate(lootTier, Rarity.EPIC) / 100.0);
|
||||
legendaryTreasure = percent.format(FishingTreasureConfig.getInstance().getItemDropRate(lootTier, Rarity.LEGENDARY) / 100.0);
|
||||
mythicTreasure = percent.format(FishingTreasureConfig.getInstance().getItemDropRate(lootTier, Rarity.MYTHIC) / 100.0);
|
||||
|
||||
// Magic hunter drop rates
|
||||
double totalEnchantChance = 0;
|
||||
|
||||
for (Rarity rarity : Rarity.values()) {
|
||||
if (rarity != Rarity.RECORD) {
|
||||
totalEnchantChance += TreasureConfig.getInstance().getEnchantmentDropRate(lootTier, rarity);
|
||||
if (rarity != Rarity.MYTHIC) {
|
||||
totalEnchantChance += FishingTreasureConfig.getInstance().getEnchantmentDropRate(lootTier, rarity);
|
||||
}
|
||||
}
|
||||
|
||||
@ -94,25 +91,8 @@ public class FishingCommand extends SkillCommand {
|
||||
|
||||
// MASTER ANGLER
|
||||
if (canMasterAngler) {
|
||||
double rawBiteChance = 1.0 / (player.getWorld().hasStorm() ? 300 : 500);
|
||||
|
||||
Location location = fishingManager.getHookLocation();
|
||||
|
||||
if (location == null) {
|
||||
location = player.getLocation();
|
||||
}
|
||||
|
||||
if (Fishing.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);
|
||||
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));
|
||||
}
|
||||
}
|
||||
|
||||
@ -122,13 +102,13 @@ public class FishingCommand extends SkillCommand {
|
||||
canMagicHunt = canUseSubskill(player, SubSkillType.FISHING_MAGIC_HUNTER) && canUseSubskill(player, SubSkillType.FISHING_TREASURE_HUNTER);
|
||||
canShake = canUseSubskill(player, SubSkillType.FISHING_SHAKE);
|
||||
canFishermansDiet = canUseSubskill(player, SubSkillType.FISHING_FISHERMANS_DIET);
|
||||
canMasterAngler = canUseSubskill(player, SubSkillType.FISHING_MASTER_ANGLER);
|
||||
canMasterAngler = mcMMO.getCompatibilityManager().getMasterAnglerCompatibilityLayer() != null && canUseSubskill(player, SubSkillType.FISHING_MASTER_ANGLER);
|
||||
canIceFish = canUseSubskill(player, SubSkillType.FISHING_ICE_FISHING);
|
||||
}
|
||||
|
||||
@Override
|
||||
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) {
|
||||
messages.add(getStatMessage(false, true, SubSkillType.FISHING_FISHERMANS_DIET, String.valueOf(fishermansDietRank)));
|
||||
@ -143,8 +123,13 @@ public class FishingCommand extends SkillCommand {
|
||||
}
|
||||
|
||||
if (canMasterAngler) {
|
||||
//TODO: Update this with more details
|
||||
messages.add(getStatMessage(false, true, SubSkillType.FISHING_MASTER_ANGLER, biteChance));
|
||||
messages.add(getStatMessage(false,true,
|
||||
SubSkillType.FISHING_MASTER_ANGLER,
|
||||
maMinWaitTime));
|
||||
|
||||
messages.add(getStatMessage(true,true,
|
||||
SubSkillType.FISHING_MASTER_ANGLER,
|
||||
maMaxWaitTime));
|
||||
}
|
||||
|
||||
if (canShake) {
|
||||
@ -160,15 +145,15 @@ public class FishingCommand extends SkillCommand {
|
||||
String.valueOf(rareTreasure),
|
||||
String.valueOf(epicTreasure),
|
||||
String.valueOf(legendaryTreasure),
|
||||
String.valueOf(recordTreasure)));
|
||||
String.valueOf(mythicTreasure)));
|
||||
}
|
||||
|
||||
return messages;
|
||||
}
|
||||
|
||||
@Override
|
||||
protected List<TextComponent> getTextComponents(Player player) {
|
||||
List<TextComponent> textComponents = new ArrayList<>();
|
||||
protected List<Component> getTextComponents(Player player) {
|
||||
List<Component> textComponents = new ArrayList<>();
|
||||
|
||||
TextComponentFactory.getSubSkillTextComponents(player, textComponents, PrimarySkillType.FISHING);
|
||||
|
||||
|
Some files were not shown because too many files have changed in this diff Show More
Loading…
Reference in New Issue
Block a user