Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Melhorias diversas #27

Closed
wants to merge 130 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
130 commits
Select commit Hold shift + click to select a range
c6873e0
Update maven.yml
SrBedrock Dec 20, 2021
eefb182
Update maven.yml
SrBedrock Dec 20, 2021
37c24ff
Update maven.yml
SrBedrock Dec 20, 2021
5eede42
Update pom.xml
SrBedrock Dec 20, 2021
3d61905
Update pom.xml
SrBedrock Dec 20, 2021
a4fe7af
Merge branch 'mcMMO-Dev:master' into update
SrBedrock Dec 28, 2021
393810d
Merge branch 'mcMMO-Dev:master' into update
SrBedrock Dec 31, 2021
b5bf10b
Merge branch 'mcMMO-Dev:master' into update
SrBedrock Jan 12, 2022
87b9b8b
Merge branch 'mcMMO-Dev:master' into update
SrBedrock Mar 18, 2022
5c92ea8
Adicionado comandos em português
SrBedrock Mar 18, 2022
a70b0bc
Atualizando para versão 1.18.1
SrBedrock Mar 18, 2022
2afc401
Atualizando para Java 17
SrBedrock Mar 18, 2022
daaf98b
Merge branch 'mcMMO-Dev:master' into update
SrBedrock Mar 18, 2022
b451d30
Adicionado versão no artefato
SrBedrock Mar 18, 2022
a707157
Atualizado nome do .zip
SrBedrock Mar 18, 2022
c499bfb
Adicionado versão no nome do plugin
SrBedrock Mar 18, 2022
658bc53
Merge branch 'mcMMO-Dev:master' into update
SrBedrock Apr 28, 2022
b355b58
Merge branch 'mcMMO-Dev:master' into update
SrBedrock Apr 29, 2022
bdb0e1d
Merge branch 'mcMMO-Dev:master' into update
SrBedrock Jun 9, 2022
e511c09
Merge branch 'mcMMO-Dev:master' into update
SrBedrock Jun 10, 2022
c09deb3
Merge branch 'mcMMO-Dev:master' into update
SrBedrock Jun 10, 2022
d956439
Merge branch 'mcMMO-Dev:master' into update
SrBedrock Jun 12, 2022
02a323c
Adicionado versão no plugin
SrBedrock Jun 12, 2022
7800692
Adicionado versão no plugin II
SrBedrock Jun 12, 2022
c735eff
Adicionado versão no plugin III
SrBedrock Jun 12, 2022
18816b2
Merge branch 'mcMMO-Dev:master' into update
SrBedrock Jul 10, 2022
92bd4bf
Merge branch 'mcMMO-Dev:master' into update
SrBedrock Jul 24, 2022
61c7122
tradução do hover do LevelUpBroadcast
SrBedrock Jul 24, 2022
b2a0959
Resolvido erro do ultimo commit
SrBedrock Jul 25, 2022
88d066f
Merge branch 'mcMMO-Dev:master' into update
SrBedrock Jul 26, 2022
8bd9a74
Merge branch 'mcMMO-Dev:master' into update
SrBedrock Aug 5, 2022
951f582
Tradução do processPowerLevelUpBroadcasting
SrBedrock Aug 5, 2022
5199f51
Merge branch 'mcMMO-Dev:master' into update
SrBedrock Aug 8, 2022
248251b
Merge branch 'mcMMO-Dev:master' into update
SrBedrock Aug 13, 2022
db78c0a
Merge branch 'mcMMO-Dev:master' into update
SrBedrock Dec 5, 2022
f4f1fa5
Merge branch 'mcMMO-Dev:master' into update
SrBedrock Jan 29, 2023
0ed184b
Merge branch 'mcMMO-Dev:master' into update
SrBedrock Feb 10, 2023
c7b32bb
Merge branch 'mcMMO-Dev:master' into update
SrBedrock Feb 26, 2023
405e9b8
Update maven.yml
SrBedrock Apr 3, 2023
5aa304a
Merge branch 'update' into fix-maven
SrBedrock Apr 3, 2023
6b08406
Merge pull request #1 from ArmaRealms/fix-maven
SrBedrock Apr 3, 2023
85bc6a6
Merge branch 'mcMMO-Dev:master' into update
SrBedrock Apr 8, 2023
79be748
Revert "Added smithing_table to tool readiness blacklist"
SrBedrock Apr 10, 2023
9335d3b
Update PlayerListener.java
SrBedrock Apr 10, 2023
6a73020
Merge branch 'dev-onPlayerInteractLowest' into update
SrBedrock Apr 10, 2023
d862969
Revert "Revert "Added smithing_table to tool readiness blacklist""
SrBedrock Apr 10, 2023
ef27dbd
Update PlayerListener.java
SrBedrock Apr 10, 2023
97978a0
Merge branch 'master' into update
SrBedrock May 5, 2023
580bac2
Merge branch 'mcMMO-Dev:master' into update
SrBedrock May 14, 2023
a6444f5
Removido comando adminchat
SrBedrock May 15, 2023
7d7b70e
Removido comando partychat
SrBedrock May 16, 2023
84fd1a7
Tradução de comandos do sistema de party
SrBedrock May 16, 2023
34f3308
Update maven.yml
SrBedrock May 16, 2023
45bfc25
Merge branch 'mcMMO-Dev:master' into update
SrBedrock May 29, 2023
8beb648
Merge branch 'mcMMO-Dev:master' into update
SrBedrock May 29, 2023
74a6e92
Merge branch 'mcMMO-Dev:master' into update
SrBedrock Jun 18, 2023
677c114
Bump guava from 31.1-jre to 32.0.0-jre (#4)
dependabot[bot] Jun 18, 2023
97b1cff
Merge branch 'mcMMO-Dev:master' into update
SrBedrock Jun 20, 2023
dc43ec6
Merge branch 'mcMMO-Dev:master' into update
SrBedrock Jun 20, 2023
8eff37b
Merge branch 'mcMMO-Dev:master' into update
SrBedrock Jul 10, 2023
64d2010
Merge branch 'mcMMO-Dev:master' into update
SrBedrock Aug 19, 2023
eedf3a6
Merge branch 'mcMMO-Dev:master' into update
SrBedrock Sep 15, 2023
5bcdb16
Merge branch 'mcMMO-Dev:master' into update
SrBedrock Oct 1, 2023
9901b4c
Merge branch 'mcMMO-Dev:master' into update
SrBedrock Oct 3, 2023
63e6ead
Merge remote-tracking branch 'upstream/master' into update
SrBedrock Oct 15, 2023
8bc68eb
Merge branch 'mcMMO-Dev:master' into update
SrBedrock Oct 27, 2023
a83968a
Merge branch 'mcMMO-Dev:master' into update
SrBedrock Dec 17, 2023
46f6065
Merge branch 'mcMMO-Dev:master' into update
SrBedrock Dec 22, 2023
0158c8f
Merge branch 'mcMMO-Dev:master' into update
SrBedrock Jan 3, 2024
064175c
Merge branch 'mcMMO-Dev:master' into update
SrBedrock Feb 14, 2024
a6e7778
Merge branch 'mcMMO-Dev:master' into update
SrBedrock Feb 20, 2024
cd690fd
Merge branch 'mcMMO-Dev:master' into update
SrBedrock Feb 20, 2024
be04ebc
Merge branch 'mcMMO-Dev:master' into update
SrBedrock Feb 20, 2024
5d3abaf
Não remover seed ao replantar (#6)
SrBedrock Feb 20, 2024
76a2a59
Melhorias diversas do comando de party (#7)
SrBedrock Feb 20, 2024
092da34
Melhorias diversas de comandos (#8)
SrBedrock Feb 21, 2024
003aa79
Merge branch 'mcMMO-Dev:master' into update
SrBedrock Feb 23, 2024
a44c4e9
Add Cleaned up PAPI Expansion PR-4906 (10)
SrBedrock Mar 6, 2024
318c047
Melhoria do EntityListener
SrBedrock Mar 9, 2024
eee0d6e
Merge branch 'mcMMO-Dev:master' into update
SrBedrock Mar 10, 2024
7feef88
Add Cleaned up PAPI Expansion PR-4906 (#9) (#11)
SrBedrock Mar 10, 2024
6c0eef4
Merge branch 'mcMMO-Dev:master' into update
SrBedrock Mar 11, 2024
682a1cc
Adicionado placeholder top_power (#13)
SrBedrock Mar 14, 2024
083801e
Otimizado CombatUtils#applyAbilityAoE() (#14)
SrBedrock Mar 16, 2024
cf7f67a
Melhoria de formatação de leveis (#18)
SrBedrock Mar 20, 2024
97a43d8
Merge branch 'master' into update
SrBedrock Apr 1, 2024
4cc38ec
Resolvido problema ao compilar plugin
SrBedrock Apr 1, 2024
81c7278
Readicionado comandos desativados
SrBedrock Apr 1, 2024
65b507c
Merge branch 'mcMMO-Dev:master' into update
SrBedrock Apr 2, 2024
17a2596
Merge branch 'mcMMO-Dev:master' into update
SrBedrock Apr 6, 2024
abab3bf
Traduzindo novos comandos
SrBedrock Apr 10, 2024
4115276
Merge branch 'mcMMO-Dev:master' into update
SrBedrock Apr 10, 2024
76de5a9
Melhoria do HerbalismManager#processGreenThumbPlants()
SrBedrock Apr 11, 2024
bbd584a
Merge branch 'master' into update
SrBedrock Apr 14, 2024
cfd31f4
Merge branch 'mcMMO-Dev:master' into update
SrBedrock Apr 18, 2024
19c88a3
Merge branch 'mcMMO-Dev:master' into update
SrBedrock Apr 25, 2024
b15ca60
Merge branch 'master' into update
SrBedrock May 4, 2024
8d11854
Merge branch 'master' into update
SrBedrock May 14, 2024
515676e
Merge branch 'mcMMO-Dev:master' into update
SrBedrock May 17, 2024
b067953
Merge branch 'mcMMO-Dev:master' into update
SrBedrock May 19, 2024
fc0ab68
Merge branch 'master' into update
SrBedrock May 22, 2024
72ea7cb
Merge branch 'mcMMO-Dev:master' into update
SrBedrock May 27, 2024
f726596
Merge branch 'mcMMO-Dev:master' into update
SrBedrock Jun 8, 2024
d3b5a28
Close #20
SrBedrock Jun 19, 2024
60fd283
Merge branch 'master' into update
SrBedrock Jun 23, 2024
fb66f0c
Resolvido problema com comando de habiliade
SrBedrock Jun 26, 2024
4fcd68d
EntityListener cleanup
SrBedrock Jun 27, 2024
91db5a4
Merge branch 'mcMMO-Dev:master' into update
SrBedrock Jun 29, 2024
bd6bb5e
InventoryListener cleanup
SrBedrock Jun 30, 2024
ce72945
CombatUtils cleanup
SrBedrock Jun 30, 2024
26d2fd4
EntityListener cleanup
SrBedrock Jun 30, 2024
6855da3
Merge branch 'mcMMO-Dev:master' into update
SrBedrock Jul 1, 2024
2bc6afd
Cache mmoPlayer in McMMOPlayerExperienceEvent
SrBedrock Jul 8, 2024
561966c
Merge branch 'mcMMO-Dev:master' into update
SrBedrock Jul 9, 2024
d253cc0
Merge branch 'mcMMO-Dev:master' into update
SrBedrock Jul 15, 2024
c2a465e
Merge branch 'master' into update
SrBedrock Jul 29, 2024
8945a7b
Fix GH-21 (#22)
SrBedrock Aug 10, 2024
c0ff539
Merge branch 'mcMMO-Dev:master' into update
SrBedrock Aug 26, 2024
12a139e
Melhorias diversas do HerbalismManager (#25)
SrBedrock Aug 28, 2024
bc03777
Merge branch 'mcMMO-Dev:master' into update
SrBedrock Aug 28, 2024
edb9b65
Merge branch 'mcMMO-Dev:master' into update
SrBedrock Aug 31, 2024
22fd6a8
Resolvido NPE no AlchemyBrewTask#finish()
SrBedrock Sep 1, 2024
695559e
Merge branch 'master' into update
SrBedrock Sep 15, 2024
55fe900
Merge branch 'mcMMO-Dev:master' into update
SrBedrock Sep 16, 2024
77cbc93
Merge branch 'mcMMO-Dev:master' into update
SrBedrock Sep 20, 2024
694ad01
Merge branch 'mcMMO-Dev:master' into update
SrBedrock Sep 21, 2024
44703d6
Melhoria do comando /mmopower
SrBedrock Sep 27, 2024
23b0272
Merge branch 'master' into update
SrBedrock Sep 29, 2024
9943e47
Merge branch 'master' into update
SrBedrock Oct 25, 2024
d289720
Merge branch 'master' into update
SrBedrock Nov 1, 2024
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
23 changes: 12 additions & 11 deletions .github/workflows/maven.yml
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
# 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
name: Maven Build and Upload

on:
# We run our tests whenever the pom or a source file was touched.
Expand Down Expand Up @@ -29,24 +29,25 @@ jobs:

# 1. Check out the current working tree
- name: Checkout repository
uses: actions/checkout@v2
uses: actions/checkout@v4.1.1

# 2. Setup Java 17 JDK (Adopt)
- name: Java 17 setup
uses: actions/setup-java@v2
uses: actions/setup-java@v4.2.0
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
check-latest: true
cache: 'maven'

# 4. Build via Maven
- name: Build via Maven
run: mvn verify -B --file pom.xml -DdisableXmlReport=true

# 5. Upload via Github Actions
- name: Upload
uses: actions/upload-artifact@v4.3.1
with:
name: mcMMO
path: target/mcMMO-*.jar
16 changes: 11 additions & 5 deletions pom.xml
Original file line number Diff line number Diff line change
@@ -1,4 +1,6 @@
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
<project xmlns="http://maven.apache.org/POM/4.0.0"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
<modelVersion>4.0.0</modelVersion>
<groupId>com.gmail.nossr50.mcMMO</groupId>
<artifactId>mcMMO</artifactId>
Expand Down Expand Up @@ -37,7 +39,7 @@
</snapshotRepository>
</distributionManagement>
<build>
<finalName>${project.artifactId}</finalName>
<finalName>${project.artifactId}-${project.version}</finalName>
<sourceDirectory>${basedir}/src/main/java</sourceDirectory>
<resources>
<resource>
Expand Down Expand Up @@ -117,6 +119,7 @@
<artifactId>maven-assembly-plugin</artifactId>
<version>3.7.1</version>
<configuration>
<finalName>${project.name}-${project.version}</finalName>
<descriptors>
<descriptor>src/main/assembly/package.xml</descriptor>
</descriptors>
Expand Down Expand Up @@ -171,11 +174,13 @@
</relocation>
<relocation>
<pattern>co.aikar.commands</pattern>
<shadedPattern>com.gmail.nossr50.mcmmo.acf</shadedPattern> <!-- Replace this -->
<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 -->
<shadedPattern>com.gmail.nossr50.mcmmo.locales</shadedPattern> <!--
Replace this -->
</relocation>
<relocation>
<pattern>org.apache.commons.logging</pattern>
Expand Down Expand Up @@ -449,7 +454,8 @@
<dependency>
<groupId>com.google.guava</groupId>
<artifactId>guava</artifactId>
<version>33.2.0-jre</version> <!-- At this time Spigot is including 29.0 Guava classes that we are using -->
<version>33.2.0-jre</version> <!-- At this time Spigot is including 29.0 Guava classes that we are
using -->
<scope>compile</scope>
</dependency>
<dependency>
Expand Down
4 changes: 2 additions & 2 deletions src/main/assembly/package.xml
Original file line number Diff line number Diff line change
Expand Up @@ -6,9 +6,9 @@
</formats>
<files>
<file>
<source>${project.build.directory}/${artifactId}.jar</source>
<source>${project.build.directory}/${artifactId}-${project.version}.jar</source>
<outputDirectory>/</outputDirectory>
<destName>mcMMO.jar</destName>
<destName>mcMMO-${project.version}.jar</destName>
</file>
</files>
</assembly>
Original file line number Diff line number Diff line change
Expand Up @@ -136,7 +136,7 @@ public void validateLoadedData(@NotNull Player player) {
public void validatePlayerParty(@NotNull Player player) {
McMMOPlayer mmoPlayer = UserManager.getPlayer(player);

if (!pluginRef.getPartyConfig().isPartyEnabled() || mmoPlayer.getParty() == null) {
if (!pluginRef.getPartyConfig().isPartyEnabled() || mmoPlayer == null || mmoPlayer.getParty() == null) {
throw new ConditionFailedException(LocaleLoader.getString("Commands.Party.None"));
}
}
Expand Down
27 changes: 14 additions & 13 deletions src/main/java/com/gmail/nossr50/commands/McconvertCommand.java
Original file line number Diff line number Diff line change
Expand Up @@ -6,12 +6,10 @@
import com.gmail.nossr50.datatypes.database.DatabaseType;
import com.gmail.nossr50.datatypes.experience.FormulaType;
import com.gmail.nossr50.mcMMO;
import com.google.common.collect.ImmutableList;
import org.bukkit.command.Command;
import org.bukkit.command.CommandExecutor;
import org.bukkit.command.CommandSender;
import org.bukkit.command.TabExecutor;
import org.bukkit.util.StringUtil;
import org.jetbrains.annotations.NotNull;

import java.util.ArrayList;
Expand All @@ -21,7 +19,7 @@
public class McconvertCommand implements TabExecutor {
private static final List<String> FORMULA_TYPES;
private static final List<String> DATABASE_TYPES;
private static final List<String> SUBCOMMANDS = ImmutableList.of("database", "experience");
private static final List<String> SUBCOMMANDS = List.of("database", "experience");

private final CommandExecutor databaseConvertCommand = new ConvertDatabaseCommand();
private final CommandExecutor experienceConvertCommand = new ConvertExperienceCommand();
Expand All @@ -48,8 +46,8 @@ public class McconvertCommand implements TabExecutor {
Collections.sort(formulaTypes);
Collections.sort(databaseTypes);

FORMULA_TYPES = ImmutableList.copyOf(formulaTypes);
DATABASE_TYPES = ImmutableList.copyOf(databaseTypes);
FORMULA_TYPES = List.copyOf(formulaTypes);
DATABASE_TYPES = List.copyOf(databaseTypes);

}

Expand All @@ -70,20 +68,23 @@ public boolean onCommand(@NotNull CommandSender sender, @NotNull Command command
@Override
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<>(SUBCOMMANDS.size()));
case 2:
case 1 -> {
return SUBCOMMANDS.stream().filter(s -> s.startsWith(args[0])).toList();
}
case 2 -> {
if (args[0].equalsIgnoreCase("database") || args[0].equalsIgnoreCase("db")) {
return StringUtil.copyPartialMatches(args[0], DATABASE_TYPES, new ArrayList<>(DATABASE_TYPES.size()));
return DATABASE_TYPES.stream().filter(s -> s.startsWith(args[1])).toList();
}

if (args[0].equalsIgnoreCase("experience") || args[0].equalsIgnoreCase("xp") || args[0].equalsIgnoreCase("exp")) {
return StringUtil.copyPartialMatches(args[0], FORMULA_TYPES, new ArrayList<>(FORMULA_TYPES.size()));
return FORMULA_TYPES.stream().filter(s -> s.startsWith(args[1])).toList();
}

return ImmutableList.of();
default:
return ImmutableList.of();
return List.of();
}
default -> {
return List.of();
}
}
}
}
9 changes: 4 additions & 5 deletions src/main/java/com/gmail/nossr50/commands/McnotifyCommand.java
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,7 @@

import com.gmail.nossr50.datatypes.player.McMMOPlayer;
import com.gmail.nossr50.locale.LocaleLoader;
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;
Expand All @@ -16,12 +14,13 @@
public class McnotifyCommand implements TabExecutor {
@Override
public boolean onCommand(@NotNull CommandSender sender, @NotNull Command command, @NotNull String label, String[] args) {
if (CommandUtils.noConsoleUsage(sender)) {
if (!(sender instanceof Player player)) {
sender.sendMessage(LocaleLoader.getString("Commands.NoConsole"));
return true;
}

if (args.length == 0) {
McMMOPlayer mcMMOPlayer = UserManager.getPlayer((Player) sender);
McMMOPlayer mcMMOPlayer = UserManager.getPlayer(player);

//Not Loaded yet
if (mcMMOPlayer == null) {
Expand All @@ -38,6 +37,6 @@ public boolean onCommand(@NotNull CommandSender sender, @NotNull Command command

@Override
public List<String> onTabComplete(@NotNull CommandSender sender, @NotNull Command command, @NotNull String alias, String[] args) {
return ImmutableList.of();
return List.of();
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -4,22 +4,21 @@
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;
import org.bukkit.command.Command;
import org.bukkit.command.CommandSender;
import org.bukkit.command.TabExecutor;
import org.bukkit.util.StringUtil;
import org.bukkit.entity.Player;
import org.jetbrains.annotations.NotNull;

import java.util.ArrayList;
import java.util.List;

public class McscoreboardCommand implements TabExecutor {
private static final List<String> FIRST_ARGS = ImmutableList.of("keep", "time", "clear");
private static final List<String> FIRST_ARGS = List.of("keep", "time", "clear");

@Override
public boolean onCommand(@NotNull CommandSender sender, @NotNull Command command, @NotNull String label, String[] args) {
if (CommandUtils.noConsoleUsage(sender)) {
if (!(sender instanceof Player)) {
sender.sendMessage(LocaleLoader.getString("Commands.NoConsole"));
return true;
}

Expand Down Expand Up @@ -82,9 +81,9 @@ public boolean onCommand(@NotNull CommandSender sender, @NotNull Command command
@Override
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 FIRST_ARGS.stream().filter(s -> s.startsWith(args[0])).toList();
}
return ImmutableList.of();
return List.of();
}

private boolean help(CommandSender sender) {
Expand Down
23 changes: 14 additions & 9 deletions src/main/java/com/gmail/nossr50/commands/ToggleCommand.java
Original file line number Diff line number Diff line change
@@ -1,29 +1,32 @@
package com.gmail.nossr50.commands;

import com.gmail.nossr50.datatypes.player.McMMOPlayer;
import com.gmail.nossr50.locale.LocaleLoader;
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.util.StringUtil;
import org.bukkit.entity.Player;
import org.jetbrains.annotations.NotNull;

import java.util.ArrayList;
import java.util.List;

public abstract class ToggleCommand implements TabExecutor {
@Override
public boolean onCommand(@NotNull CommandSender sender, @NotNull Command command, @NotNull String label, String[] args) {
switch (args.length) {
case 0:
if (CommandUtils.noConsoleUsage(sender)) {
if (!(sender instanceof Player)) {
sender.sendMessage(LocaleLoader.getString("Commands.NoConsole"));
return true;
}

if (!hasSelfPermission(sender)) {
sender.sendMessage(command.getPermissionMessage());
String commandPermissionMessage = command.getPermissionMessage();
if (commandPermissionMessage != null) {
sender.sendMessage(commandPermissionMessage);
}
return true;
}

Expand All @@ -36,7 +39,10 @@ public boolean onCommand(@NotNull CommandSender sender, @NotNull Command command

case 1:
if (!hasOtherPermission(sender)) {
sender.sendMessage(command.getPermissionMessage());
String commandPermissionMessage = command.getPermissionMessage();
if (commandPermissionMessage != null) {
sender.sendMessage(commandPermissionMessage);
}
return true;
}

Expand All @@ -63,10 +69,9 @@ public boolean onCommand(@NotNull CommandSender sender, @NotNull Command command
@Override
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 CommandUtils.getOnlinePlayerNames(sender).stream().filter(s -> s.startsWith(args[0])).toList();
}
return ImmutableList.of();
return List.of();
}

protected abstract boolean hasOtherPermission(CommandSender sender);
Expand Down
Loading