mirror of
https://github.com/EssentialsX/Essentials.git
synced 2025-02-01 21:11:44 +01:00
Merge remote-tracking branch 'upstream/2.x' into rework/providers
This commit is contained in:
commit
92c71f2568
@ -138,6 +138,7 @@ import java.util.LinkedHashSet;
|
|||||||
import java.util.List;
|
import java.util.List;
|
||||||
import java.util.Locale;
|
import java.util.Locale;
|
||||||
import java.util.Map;
|
import java.util.Map;
|
||||||
|
import java.util.MissingResourceException;
|
||||||
import java.util.Set;
|
import java.util.Set;
|
||||||
import java.util.UUID;
|
import java.util.UUID;
|
||||||
import java.util.function.Predicate;
|
import java.util.function.Predicate;
|
||||||
@ -830,7 +831,11 @@ public class Essentials extends JavaPlugin implements net.ess3.api.IEssentials {
|
|||||||
} catch (final NotEnoughArgumentsException ex) {
|
} catch (final NotEnoughArgumentsException ex) {
|
||||||
if (getSettings().isVerboseCommandUsages() && !cmd.getUsageStrings().isEmpty()) {
|
if (getSettings().isVerboseCommandUsages() && !cmd.getUsageStrings().isEmpty()) {
|
||||||
sender.sendTl("commandHelpLine1", commandLabel);
|
sender.sendTl("commandHelpLine1", commandLabel);
|
||||||
sender.sendTl("commandHelpLine2", command.getDescription());
|
String description = command.getDescription();
|
||||||
|
try {
|
||||||
|
description = sender.tl(command.getName() + "CommandDescription");
|
||||||
|
} catch (MissingResourceException ignored) {}
|
||||||
|
sender.sendTl("commandHelpLine2", description);
|
||||||
sender.sendTl("commandHelpLine3");
|
sender.sendTl("commandHelpLine3");
|
||||||
for (Map.Entry<String, String> usage : cmd.getUsageStrings().entrySet()) {
|
for (Map.Entry<String, String> usage : cmd.getUsageStrings().entrySet()) {
|
||||||
sender.sendTl("commandHelpLineUsage", AdventureUtil.parsed(usage.getKey().replace("<command>", commandLabel)), AdventureUtil.parsed(usage.getValue()));
|
sender.sendTl("commandHelpLineUsage", AdventureUtil.parsed(usage.getKey().replace("<command>", commandLabel)), AdventureUtil.parsed(usage.getValue()));
|
||||||
|
@ -18,6 +18,24 @@ public class Commanddelhome extends EssentialsCommand {
|
|||||||
super("delhome");
|
super("delhome");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private void deleteHome(CommandSource sender, User user, String home) {
|
||||||
|
final HomeModifyEvent event = new HomeModifyEvent(sender.getUser(), user, home, user.getHome(home), false);
|
||||||
|
Bukkit.getServer().getPluginManager().callEvent(event);
|
||||||
|
if (event.isCancelled()) {
|
||||||
|
if (ess.getSettings().isDebug()) {
|
||||||
|
ess.getLogger().info("HomeModifyEvent canceled for /delhome execution by " + sender.getDisplayName());
|
||||||
|
}
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
try {
|
||||||
|
user.delHome(home);
|
||||||
|
} catch (Exception e) {
|
||||||
|
sender.sendTl("invalidHome", home);
|
||||||
|
}
|
||||||
|
sender.sendTl("deleteHome", home);
|
||||||
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void run(final Server server, final CommandSource sender, final String commandLabel, final String[] args) throws Exception {
|
public void run(final Server server, final CommandSource sender, final String commandLabel, final String[] args) throws Exception {
|
||||||
if (args.length < 1) {
|
if (args.length < 1) {
|
||||||
@ -45,21 +63,19 @@ public class Commanddelhome extends EssentialsCommand {
|
|||||||
name = expandedArg[0].toLowerCase(Locale.ENGLISH);
|
name = expandedArg[0].toLowerCase(Locale.ENGLISH);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (name.equals("bed")) {
|
switch (name) {
|
||||||
|
case "bed":
|
||||||
throw new TranslatableException("invalidHomeName");
|
throw new TranslatableException("invalidHomeName");
|
||||||
|
case "*":
|
||||||
|
final List<String> homes = user.getHomes();
|
||||||
|
for (String home : homes) {
|
||||||
|
deleteHome(sender, user, home);
|
||||||
}
|
}
|
||||||
|
break;
|
||||||
final HomeModifyEvent event = new HomeModifyEvent(sender.getUser(), user, name, user.getHome(name), false);
|
default:
|
||||||
Bukkit.getServer().getPluginManager().callEvent(event);
|
deleteHome(sender, user, name);
|
||||||
if (event.isCancelled()) {
|
break;
|
||||||
if (ess.getSettings().isDebug()) {
|
|
||||||
ess.getLogger().info("HomeModifyEvent canceled for /delhome execution by " + sender.getDisplayName());
|
|
||||||
}
|
}
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
user.delHome(name);
|
|
||||||
sender.sendTl("deleteHome", name);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
@ -81,6 +97,7 @@ public class Commanddelhome extends EssentialsCommand {
|
|||||||
return homes;
|
return homes;
|
||||||
}
|
}
|
||||||
otherUser.getHomes().forEach(home -> homes.add(namePart + ":" + home));
|
otherUser.getHomes().forEach(home -> homes.add(namePart + ":" + home));
|
||||||
|
homes.add(namePart + ":" + "*");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return homes;
|
return homes;
|
||||||
|
@ -19,6 +19,7 @@ import java.util.Collections;
|
|||||||
import java.util.List;
|
import java.util.List;
|
||||||
import java.util.Locale;
|
import java.util.Locale;
|
||||||
import java.util.Map;
|
import java.util.Map;
|
||||||
|
import java.util.MissingResourceException;
|
||||||
|
|
||||||
public class Commandhelp extends EssentialsCommand {
|
public class Commandhelp extends EssentialsCommand {
|
||||||
public Commandhelp() {
|
public Commandhelp() {
|
||||||
@ -38,18 +39,25 @@ public class Commandhelp extends EssentialsCommand {
|
|||||||
final String cmd = pageStr.substring(1);
|
final String cmd = pageStr.substring(1);
|
||||||
for (final Map.Entry<String, Command> knownCmd : ess.provider(KnownCommandsProvider.class).getKnownCommands().entrySet()) {
|
for (final Map.Entry<String, Command> knownCmd : ess.provider(KnownCommandsProvider.class).getKnownCommands().entrySet()) {
|
||||||
if (knownCmd.getKey().equalsIgnoreCase(cmd)) {
|
if (knownCmd.getKey().equalsIgnoreCase(cmd)) {
|
||||||
|
final Command bukkit = knownCmd.getValue();
|
||||||
|
final boolean isEssCommand = bukkit instanceof PluginIdentifiableCommand && ((PluginIdentifiableCommand) bukkit).getPlugin().equals(ess);
|
||||||
|
final IEssentialsCommand essCommand = isEssCommand ? ess.getCommandMap().get(bukkit.getName()) : null;
|
||||||
user.sendTl("commandHelpLine1", cmd);
|
user.sendTl("commandHelpLine1", cmd);
|
||||||
user.sendTl("commandHelpLine2", knownCmd.getValue().getDescription());
|
String description = bukkit.getDescription();
|
||||||
user.sendTl("commandHelpLine4", knownCmd.getValue().getAliases().toString());
|
if (essCommand != null) {
|
||||||
|
try {
|
||||||
|
description = user.playerTl(bukkit.getName() + "CommandDescription");
|
||||||
|
} catch (MissingResourceException ignored) {}
|
||||||
|
}
|
||||||
|
user.sendTl("commandHelpLine2", description);
|
||||||
|
user.sendTl("commandHelpLine4", bukkit.getAliases().toString());
|
||||||
user.sendTl("commandHelpLine3");
|
user.sendTl("commandHelpLine3");
|
||||||
final boolean isEssCommand = knownCmd.getValue() instanceof PluginIdentifiableCommand && ((PluginIdentifiableCommand) knownCmd.getValue()).getPlugin().equals(ess);
|
|
||||||
final IEssentialsCommand essCommand = isEssCommand ? ess.getCommandMap().get(knownCmd.getValue().getName()) : null;
|
|
||||||
if (essCommand != null && !essCommand.getUsageStrings().isEmpty()) {
|
if (essCommand != null && !essCommand.getUsageStrings().isEmpty()) {
|
||||||
for (Map.Entry<String, String> usage : essCommand.getUsageStrings().entrySet()) {
|
for (Map.Entry<String, String> usage : essCommand.getUsageStrings().entrySet()) {
|
||||||
user.sendTl("commandHelpLineUsage", AdventureUtil.parsed(usage.getKey().replace("<command>", cmd)), AdventureUtil.parsed(usage.getValue()));
|
user.sendTl("commandHelpLineUsage", AdventureUtil.parsed(usage.getKey().replace("<command>", cmd)), AdventureUtil.parsed(usage.getValue()));
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
user.sendMessage(knownCmd.getValue().getUsage());
|
user.sendMessage(bukkit.getUsage());
|
||||||
}
|
}
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user