镜像站点 · 本页由第三方 GitHub 只读镜像提供,非 GitHub 官方站点,不接受任何登录或凭据输入。前往 github.com
Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
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
Original file line number Diff line number Diff line change
Expand Up @@ -13,8 +13,10 @@
import com.google.common.collect.ImmutableMap;
import com.google.common.collect.Lists;
import org.bukkit.ChatColor;
import org.bukkit.Location;
import org.bukkit.Server;
import org.bukkit.Sound;
import org.bukkit.World;
import org.bukkit.entity.Player;
import org.bukkit.plugin.Plugin;
import org.bukkit.plugin.PluginDescriptionFile;
Expand All @@ -29,6 +31,7 @@
import java.util.Map;
import java.util.UUID;
import java.util.function.Supplier;
import java.util.stream.Collectors;

import static com.earth2me.essentials.I18n.tl;

Expand All @@ -38,6 +41,8 @@ public class Commandessentials extends EssentialsCommand {
private static final Sound NOTE_HARP = EnumUtil.valueOf(Sound.class, "BLOCK_NOTE_BLOCK_HARP", "BLOCK_NOTE_HARP", "NOTE_PIANO");
private static final Sound MOO_SOUND = EnumUtil.valueOf(Sound.class, "COW_IDLE", "ENTITY_COW_MILK");

private static final String HOMES_USAGE = "/<command> homes (fix | delete [world])";

private static final String NYAN_TUNE = "1D#,1E,2F#,,2A#,1E,1D#,1E,2F#,2B,2D#,2E,2D#,2A#,2B,,2F#,,1D#,1E,2F#,2B,2C#,2A#,2B,2C#,2E,2D#,2E,2C#,,2F#,,2G#,,1D,1D#,,1C#,1D,1C#,1B,,1B,,1C#,,1D,,1D,1C#,1B,1C#,1D#,2F#,2G#,1D#,2F#,1C#,1D#,1B,1C#,1B,1D#,,2F#,,2G#,1D#,2F#,1C#,1D#,1B,1D,1D#,1D,1C#,1B,1C#,1D,,1B,1C#,1D#,2F#,1C#,1D,1C#,1B,1C#,,1B,,1C#,,2F#,,2G#,,1D,1D#,,1C#,1D,1C#,1B,,1B,,1C#,,1D,,1D,1C#,1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1B,,1F#,1G#,1B,,1F#,1G#,1B,1B,1C#,1D#,1B,1F#,1G#,1F#,1B,,1B,1A#,1B,1F#,1G#,1B,1E,1D#,1E,2F#,1B,,1B,,";
private static final String[] CONSOLE_MOO = new String[] {" (__)", " (oo)", " /------\\/", " / | ||", " * /\\---/\\", " ~~ ~~", "....\"Have you mooed today?\"..."};
private static final String[] PLAYER_MOO = new String[] {" (__)", " (oo)", " /------\\/", " / | | |", " * /\\---/\\", " ~~ ~~", "....\"Have you mooed today?\"..."};
Expand Down Expand Up @@ -86,12 +91,10 @@ public void run(final Server server, final CommandSource sender, final String co
case "verbose":
runDebug(server, sender, commandLabel, args);
break;

case "ver":
case "version":
runVersion(server, sender, commandLabel, args);
break;

case "cmd":
case "commands":
runCommands(server, sender, commandLabel, args);
Expand All @@ -107,6 +110,9 @@ public void run(final Server server, final CommandSource sender, final String co
case "cleanup":
runCleanup(server, sender, commandLabel, args);
break;
case "homes":
runHomes(server, sender, commandLabel, args);
break;
case "uuidconvert":
runUUIDConvert(server, sender, commandLabel, args);
break;
Expand All @@ -130,7 +136,7 @@ public void run(final Server server, final CommandSource sender, final String co

// Displays the command's usage.
private void showUsage(final CommandSource sender) throws Exception {
throw new NotEnoughArgumentsException("/<command> <reload/debug/commands>");
throw new NotEnoughArgumentsException();
}

// Lists commands that are being handed over to other plugins.
Expand Down Expand Up @@ -253,7 +259,69 @@ private void runCleanup(final Server server, final CommandSource sender, final S
}
sender.sendMessage(tl("cleaned"));
});
}

private void runHomes(final Server server, final CommandSource sender, final String commandLabel, final String[] args) throws Exception {
if (args.length < 2) {
sender.sendMessage("This sub-command provides a utility to mass-delete homes based on user options:");
sender.sendMessage("Use \"fix\" to delete all homes inside non-existent or unloaded worlds.");
sender.sendMessage("Use \"delete\" to delete all existing homes.");
sender.sendMessage("Use \"delete <worldname>\" to delete all homes inside a specific world.");
throw new Exception(HOMES_USAGE);
Comment thread
triagonal marked this conversation as resolved.
}

final UserMap userMap = ess.getUserMap();
switch (args[1]) {
case "fix":
sender.sendMessage(tl("fixingHomes"));
ess.runTaskAsynchronously(() -> {
for (final UUID u : userMap.getAllUniqueUsers()) {
final User user = ess.getUserMap().getUser(u);
if (user == null) {
continue;
}
for (String homeName : user.getHomes()) {
try {
if (user.getHome(homeName) == null) {
user.delHome(homeName);
}
} catch (Exception e) {
ess.getLogger().info("Unable to delete home " + homeName + " for " + user.getName());
}
}
}
sender.sendMessage(tl("fixedHomes"));
});
break;
case "delete":
final boolean filterByWorld = args.length >= 3;
if (filterByWorld && server.getWorld(args[2]) == null) {
throw new Exception(tl("invalidWorld"));
}
sender.sendMessage(filterByWorld ? tl("deletingHomesWorld", args[2]) : tl("deletingHomes"));
ess.runTaskAsynchronously(() -> {
for (final UUID u : userMap.getAllUniqueUsers()) {
final User user = ess.getUserMap().getUser(u);
if (user == null) {
continue;
}
for (String homeName : user.getHomes()) {
try {
final Location home = user.getHome(homeName);
if (!filterByWorld || (home != null && home.getWorld() != null && home.getWorld().getName().equals(args[2]))) {
user.delHome(homeName);
}
} catch (Exception e) {
ess.getLogger().info("Unable to delete home " + homeName + " for " + user.getName());
Comment thread
JRoy marked this conversation as resolved.
}
}
}
sender.sendMessage(filterByWorld ? tl("deletedHomesWorld", args[2]) : tl("deletedHomes"));
});
break;
default:
throw new Exception(HOMES_USAGE);
Comment thread
triagonal marked this conversation as resolved.
}
}

// Forces a rerun of userdata UUID conversion.
Expand Down Expand Up @@ -406,12 +474,13 @@ private void runVersion(final Server server, final CommandSource sender, final S
protected List<String> getTabCompleteOptions(final Server server, final CommandSource sender, final String commandLabel, final String[] args) {
if (args.length == 1) {
final List<String> options = Lists.newArrayList();
options.add("debug");
options.add("commands");
options.add("version");
options.add("reload");
options.add("version");
options.add("commands");
options.add("debug");
options.add("reset");
options.add("cleanup");
options.add("homes");
//options.add("uuidconvert");
//options.add("uuidtest");
//options.add("nya");
Expand All @@ -438,6 +507,13 @@ protected List<String> getTabCompleteOptions(final Server server, final CommandS
return Lists.newArrayList("-1", "0");
}
break;
case "homes":
if (args.length == 2) {
return Lists.newArrayList("fix", "delete");
} else if (args.length == 3 && args[1].equalsIgnoreCase("delete")) {
return server.getWorlds().stream().map(World::getName).collect(Collectors.toList());
}
break;
case "uuidconvert":
if (args.length == 2) {
return Lists.newArrayList("ignoreUFCache");
Expand Down
10 changes: 10 additions & 0 deletions Essentials/src/main/resources/messages.properties
Original file line number Diff line number Diff line change
Expand Up @@ -191,11 +191,15 @@ customtextCommandUsage=/<alias> - Define in bukkit.yml
day=day
days=days
defaultBanReason=The Ban Hammer has spoken\!
deletedHomes=All homes deleted.
deletedHomesWorld=All homes in {0} deleted.
deleteFileError=Could not delete file\: {0}
deleteHome=\u00a76Home\u00a7c {0} \u00a76has been removed.
deleteJail=\u00a76Jail\u00a7c {0} \u00a76has been removed.
deleteKit=\u00a76Kit\u00a7c {0} \u00a76has been removed.
deleteWarp=\u00a76Warp\u00a7c {0} \u00a76has been removed.
deletingHomes=Deleting all homes...
deletingHomesWorld=Deleting all homes in {0}...
delhomeCommandDescription=Removes a home.
delhomeCommandUsage=/<command> [player:]<name>
delhomeCommandUsage1=/<command> <name>
Expand Down Expand Up @@ -278,6 +282,10 @@ essentialsCommandUsage4=/<command> debug
essentialsCommandUsage4Description=Toggles Essentials' "debug mode"
essentialsCommandUsage5=/<command> reset <player>
essentialsCommandUsage5Description=Resets the given player's userdata
essentialsCommandUsage6=/<command> cleanup
essentialsCommandUsage6Description=Cleans up old userdata
essentialsCommandUsage7=/<command> homes
essentialsCommandUsage7Description=Manages user homes
essentialsHelp1=The file is broken and Essentials can''t open it. Essentials is now disabled. If you can''t fix the file yourself, go to http\://tiny.cc/EssentialsChat
essentialsHelp2=The file is broken and Essentials can''t open it. Essentials is now disabled. If you can''t fix the file yourself, either type /essentialshelp in game or go to http\://tiny.cc/EssentialsChat
essentialsReload=\u00a76Essentials reloaded\u00a7c {0}.
Expand Down Expand Up @@ -329,6 +337,8 @@ fireworkCommandUsage4=/<command> <meta>
fireworkCommandUsage4Description=Adds the given effect to the held firework
fireworkEffectsCleared=\u00a76Removed all effects from held stack.
fireworkSyntax=\u00a76Firework parameters\:\u00a7c color\:<color> [fade\:<color>] [shape\:<shape>] [effect\:<effect>]\n\u00a76To use multiple colors/effects, separate values with commas\: \u00a7cred,blue,pink\n\u00a76Shapes\:\u00a7c star, ball, large, creeper, burst \u00a76Effects\:\u00a7c trail, twinkle.
fixedHomes=Invalid homes deleted.
fixingHomes=Deleting invalid homes...
flyCommandDescription=Take off, and soar!
flyCommandUsage=/<command> [player] [on|off]
flyCommandUsage1=/<command> [player]
Expand Down