mirror of
https://github.com/mcMMO-Dev/mcMMO.git
synced 2024-11-23 05:36:46 +01:00
Make our commands support tab-complete.
This commit is contained in:
parent
f3c6346b95
commit
b391a53c6b
@ -1,74 +1,29 @@
|
||||
package com.gmail.nossr50.commands;
|
||||
|
||||
import org.bukkit.command.Command;
|
||||
import org.bukkit.command.CommandExecutor;
|
||||
import org.bukkit.command.CommandSender;
|
||||
import org.bukkit.entity.Player;
|
||||
|
||||
import com.gmail.nossr50.datatypes.player.McMMOPlayer;
|
||||
import com.gmail.nossr50.locale.LocaleLoader;
|
||||
import com.gmail.nossr50.util.Permissions;
|
||||
import com.gmail.nossr50.util.commands.CommandUtils;
|
||||
import com.gmail.nossr50.util.player.UserManager;
|
||||
|
||||
public class McabilityCommand implements CommandExecutor {
|
||||
private McMMOPlayer mcMMOPlayer;
|
||||
private Player player;
|
||||
public class McabilityCommand extends ToggleCommand {
|
||||
@Override
|
||||
protected boolean hasOtherPermission(CommandSender sender) {
|
||||
return Permissions.mcabilityOthers(sender);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean onCommand(CommandSender sender, Command command, String label, String[] args) {
|
||||
switch (args.length) {
|
||||
case 0:
|
||||
if (CommandUtils.noConsoleUsage(sender)) {
|
||||
return true;
|
||||
}
|
||||
|
||||
if (!Permissions.mcability(sender)) {
|
||||
sender.sendMessage(command.getPermissionMessage());
|
||||
return true;
|
||||
}
|
||||
|
||||
mcMMOPlayer = UserManager.getPlayer(sender.getName());
|
||||
player = mcMMOPlayer.getPlayer();
|
||||
|
||||
toggleAbilityUse();
|
||||
return true;
|
||||
|
||||
case 1:
|
||||
if (!Permissions.mcabilityOthers(sender)) {
|
||||
sender.sendMessage(command.getPermissionMessage());
|
||||
return true;
|
||||
}
|
||||
|
||||
mcMMOPlayer = UserManager.getPlayer(args[0]);
|
||||
|
||||
if (!CommandUtils.checkPlayerExistence(sender, args[0], mcMMOPlayer)) {
|
||||
return true;
|
||||
}
|
||||
|
||||
player = mcMMOPlayer.getPlayer();
|
||||
|
||||
if (CommandUtils.isOffline(sender, player)) {
|
||||
return true;
|
||||
}
|
||||
|
||||
toggleAbilityUse();
|
||||
sender.sendMessage("Ability use has been toggled for " + player.getName()); // TODO: Localize
|
||||
return true;
|
||||
|
||||
default:
|
||||
return false;
|
||||
}
|
||||
protected boolean hasSelfPermission(CommandSender sender) {
|
||||
return Permissions.mcability(sender);
|
||||
}
|
||||
|
||||
private void toggleAbilityUse() {
|
||||
if (mcMMOPlayer.getAbilityUse()) {
|
||||
player.sendMessage(LocaleLoader.getString("Commands.Ability.Off"));
|
||||
}
|
||||
else {
|
||||
player.sendMessage(LocaleLoader.getString("Commands.Ability.On"));
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void applyCommandAction() {
|
||||
player.sendMessage(LocaleLoader.getString("Commands.Ability." + (mcMMOPlayer.getAbilityUse() ? "Off" : "On")));
|
||||
mcMMOPlayer.toggleAbilityUse();
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void sendSuccessMessage(CommandSender sender) {
|
||||
sender.sendMessage("Ability use has been toggled for " + player.getName()); // TODO: Localize
|
||||
}
|
||||
}
|
||||
|
@ -1,74 +1,29 @@
|
||||
package com.gmail.nossr50.commands;
|
||||
|
||||
import org.bukkit.command.Command;
|
||||
import org.bukkit.command.CommandExecutor;
|
||||
import org.bukkit.command.CommandSender;
|
||||
import org.bukkit.entity.Player;
|
||||
|
||||
import com.gmail.nossr50.datatypes.player.McMMOPlayer;
|
||||
import com.gmail.nossr50.locale.LocaleLoader;
|
||||
import com.gmail.nossr50.util.Permissions;
|
||||
import com.gmail.nossr50.util.commands.CommandUtils;
|
||||
import com.gmail.nossr50.util.player.UserManager;
|
||||
|
||||
public class McgodCommand implements CommandExecutor {
|
||||
private McMMOPlayer mcMMOPlayer;
|
||||
private Player player;
|
||||
public class McgodCommand extends ToggleCommand {
|
||||
@Override
|
||||
protected boolean hasOtherPermission(CommandSender sender) {
|
||||
return Permissions.mcgodOthers(sender);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean onCommand(CommandSender sender, Command command, String label, String[] args) {
|
||||
switch (args.length) {
|
||||
case 0:
|
||||
if (CommandUtils.noConsoleUsage(sender)) {
|
||||
return true;
|
||||
}
|
||||
|
||||
if (!Permissions.mcgod(sender)) {
|
||||
sender.sendMessage(command.getPermissionMessage());
|
||||
return true;
|
||||
}
|
||||
|
||||
mcMMOPlayer = UserManager.getPlayer(sender.getName());
|
||||
player = mcMMOPlayer.getPlayer();
|
||||
|
||||
toggleGodMode();
|
||||
return true;
|
||||
|
||||
case 1:
|
||||
if (!Permissions.mcgodOthers(sender)) {
|
||||
sender.sendMessage(command.getPermissionMessage());
|
||||
return true;
|
||||
}
|
||||
|
||||
mcMMOPlayer = UserManager.getPlayer(args[0]);
|
||||
|
||||
if (!CommandUtils.checkPlayerExistence(sender, args[0], mcMMOPlayer)) {
|
||||
return true;
|
||||
}
|
||||
|
||||
player = mcMMOPlayer.getPlayer();
|
||||
|
||||
if (CommandUtils.isOffline(sender, player)) {
|
||||
return true;
|
||||
}
|
||||
|
||||
toggleGodMode();
|
||||
sender.sendMessage("God mode has been toggled for " + player.getName()); // TODO: Localize
|
||||
return true;
|
||||
|
||||
default:
|
||||
return false;
|
||||
}
|
||||
protected boolean hasSelfPermission(CommandSender sender) {
|
||||
return Permissions.mcgod(sender);
|
||||
}
|
||||
|
||||
private void toggleGodMode() {
|
||||
if (mcMMOPlayer.getGodMode()) {
|
||||
player.sendMessage(LocaleLoader.getString("Commands.GodMode.Disabled"));
|
||||
}
|
||||
else {
|
||||
player.sendMessage(LocaleLoader.getString("Commands.GodMode.Enabled"));
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void applyCommandAction() {
|
||||
player.sendMessage(LocaleLoader.getString("Commands.GodMode." + (mcMMOPlayer.getGodMode() ? "Disabled" : "Enabled")));
|
||||
mcMMOPlayer.toggleGodMode();
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void sendSuccessMessage(CommandSender sender) {
|
||||
sender.sendMessage("God mode has been toggled for " + player.getName()); // TODO: Localize
|
||||
}
|
||||
}
|
||||
|
@ -1,27 +1,25 @@
|
||||
package com.gmail.nossr50.commands;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
import org.bukkit.command.Command;
|
||||
import org.bukkit.command.CommandExecutor;
|
||||
import org.bukkit.command.CommandSender;
|
||||
import org.bukkit.command.TabExecutor;
|
||||
|
||||
import com.gmail.nossr50.datatypes.player.McMMOPlayer;
|
||||
import com.gmail.nossr50.locale.LocaleLoader;
|
||||
import com.gmail.nossr50.util.player.UserManager;
|
||||
|
||||
public class McnotifyCommand implements CommandExecutor {
|
||||
import com.google.common.collect.ImmutableList;
|
||||
|
||||
public class McnotifyCommand implements TabExecutor {
|
||||
@Override
|
||||
public boolean onCommand(CommandSender sender, Command command, String label, String[] args) {
|
||||
switch (args.length) {
|
||||
case 0:
|
||||
McMMOPlayer mcMMOPlayer = UserManager.getPlayer(sender.getName());
|
||||
|
||||
if (mcMMOPlayer.useChatNotifications()) {
|
||||
sender.sendMessage(LocaleLoader.getString("Commands.Notifications.Off"));
|
||||
}
|
||||
else {
|
||||
sender.sendMessage(LocaleLoader.getString("Commands.Notifications.On"));
|
||||
}
|
||||
|
||||
sender.sendMessage(LocaleLoader.getString("Commands.Notifications." + (mcMMOPlayer.useChatNotifications() ? "Off" : "On")));
|
||||
mcMMOPlayer.toggleChatNotifications();
|
||||
return true;
|
||||
|
||||
@ -29,4 +27,9 @@ public class McnotifyCommand implements CommandExecutor {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<String> onTabComplete(CommandSender sender, Command command, String alias, String[] args) {
|
||||
return ImmutableList.of();
|
||||
}
|
||||
}
|
||||
|
@ -1,74 +1,34 @@
|
||||
package com.gmail.nossr50.commands;
|
||||
|
||||
import org.bukkit.command.Command;
|
||||
import org.bukkit.command.CommandExecutor;
|
||||
import org.bukkit.command.CommandSender;
|
||||
import org.bukkit.entity.Player;
|
||||
|
||||
import com.gmail.nossr50.datatypes.player.McMMOPlayer;
|
||||
import com.gmail.nossr50.locale.LocaleLoader;
|
||||
import com.gmail.nossr50.util.Permissions;
|
||||
import com.gmail.nossr50.util.commands.CommandUtils;
|
||||
import com.gmail.nossr50.util.player.UserManager;
|
||||
|
||||
public class McrefreshCommand implements CommandExecutor {
|
||||
private McMMOPlayer mcMMOPlayer;
|
||||
private Player player;
|
||||
|
||||
public class McrefreshCommand extends ToggleCommand {
|
||||
@Override
|
||||
public boolean onCommand(CommandSender sender, Command command, String label, String[] args) {
|
||||
switch (args.length) {
|
||||
case 0:
|
||||
if (CommandUtils.noConsoleUsage(sender)) {
|
||||
return true;
|
||||
}
|
||||
|
||||
if (!Permissions.mcrefresh(sender)) {
|
||||
sender.sendMessage(command.getPermissionMessage());
|
||||
return true;
|
||||
}
|
||||
|
||||
mcMMOPlayer = UserManager.getPlayer(sender.getName());
|
||||
player = mcMMOPlayer.getPlayer();
|
||||
|
||||
refreshPlayer();
|
||||
return true;
|
||||
|
||||
case 1:
|
||||
if (!Permissions.mcrefreshOthers(sender)) {
|
||||
sender.sendMessage(command.getPermissionMessage());
|
||||
return true;
|
||||
}
|
||||
|
||||
mcMMOPlayer = UserManager.getPlayer(args[0]);
|
||||
|
||||
if (!CommandUtils.checkPlayerExistence(sender, args[0], mcMMOPlayer)) {
|
||||
return true;
|
||||
}
|
||||
|
||||
Player player = mcMMOPlayer.getPlayer();
|
||||
|
||||
if (CommandUtils.isOffline(sender, player)) {
|
||||
return true;
|
||||
}
|
||||
|
||||
refreshPlayer();
|
||||
sender.sendMessage(LocaleLoader.getString("Commands.mcrefresh.Success", player.getName()));
|
||||
return true;
|
||||
|
||||
default:
|
||||
return false;
|
||||
}
|
||||
protected boolean hasOtherPermission(CommandSender sender) {
|
||||
return Permissions.mcrefreshOthers(sender);
|
||||
}
|
||||
|
||||
private void refreshPlayer() {
|
||||
@Override
|
||||
protected boolean hasSelfPermission(CommandSender sender) {
|
||||
return Permissions.mcrefresh(sender);
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void applyCommandAction() {
|
||||
mcMMOPlayer.setRecentlyHurt(0);
|
||||
mcMMOPlayer.getProfile().resetCooldowns();
|
||||
mcMMOPlayer.resetToolPrepMode();
|
||||
mcMMOPlayer.resetAbilityMode();
|
||||
|
||||
player.setCanPickupItems(true);
|
||||
player = mcMMOPlayer.getPlayer();
|
||||
player.sendMessage(LocaleLoader.getString("Ability.Generic.Refresh"));
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void sendSuccessMessage(CommandSender sender) {
|
||||
sender.sendMessage(LocaleLoader.getString("Commands.mcrefresh.Success", player.getName()));
|
||||
}
|
||||
}
|
||||
|
@ -1,15 +1,34 @@
|
||||
package com.gmail.nossr50.commands;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.Collections;
|
||||
import java.util.List;
|
||||
|
||||
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 com.gmail.nossr50.datatypes.MobHealthbarType;
|
||||
import com.gmail.nossr50.datatypes.player.PlayerProfile;
|
||||
import com.gmail.nossr50.util.commands.CommandUtils;
|
||||
import com.gmail.nossr50.util.player.UserManager;
|
||||
|
||||
public class MobhealthCommand implements CommandExecutor {
|
||||
import com.google.common.collect.ImmutableList;
|
||||
|
||||
public class MobhealthCommand implements TabExecutor {
|
||||
private static final List<String> MOB_HEALTHBAR_TYPES;
|
||||
|
||||
static {
|
||||
ArrayList<String> types = new ArrayList<String>();
|
||||
|
||||
for (MobHealthbarType type : MobHealthbarType.values()) {
|
||||
types.add(type.toString());
|
||||
}
|
||||
|
||||
Collections.sort(types);
|
||||
MOB_HEALTHBAR_TYPES = ImmutableList.copyOf(types);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean onCommand(CommandSender sender, Command command, String label, String[] args) {
|
||||
@ -36,4 +55,14 @@ public class MobhealthCommand implements CommandExecutor {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<String> onTabComplete(CommandSender sender, Command command, String alias, String[] args) {
|
||||
switch (args.length) {
|
||||
case 1:
|
||||
return StringUtil.copyPartialMatches(args[0], MOB_HEALTHBAR_TYPES, new ArrayList<String>(MOB_HEALTHBAR_TYPES.size()));
|
||||
default:
|
||||
return ImmutableList.of();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
84
src/main/java/com/gmail/nossr50/commands/ToggleCommand.java
Normal file
84
src/main/java/com/gmail/nossr50/commands/ToggleCommand.java
Normal file
@ -0,0 +1,84 @@
|
||||
package com.gmail.nossr50.commands;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
import java.util.Set;
|
||||
|
||||
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 com.gmail.nossr50.datatypes.player.McMMOPlayer;
|
||||
import com.gmail.nossr50.util.commands.CommandUtils;
|
||||
import com.gmail.nossr50.util.player.UserManager;
|
||||
|
||||
import com.google.common.collect.ImmutableList;
|
||||
|
||||
public abstract class ToggleCommand implements TabExecutor {
|
||||
protected McMMOPlayer mcMMOPlayer;
|
||||
protected Player player;
|
||||
|
||||
@Override
|
||||
public boolean onCommand(CommandSender sender, Command command, String label, String[] args) {
|
||||
switch (args.length) {
|
||||
case 0:
|
||||
if (CommandUtils.noConsoleUsage(sender)) {
|
||||
return true;
|
||||
}
|
||||
|
||||
if (!hasSelfPermission(sender)) {
|
||||
sender.sendMessage(command.getPermissionMessage());
|
||||
return true;
|
||||
}
|
||||
|
||||
mcMMOPlayer = UserManager.getPlayer(sender.getName());
|
||||
player = mcMMOPlayer.getPlayer();
|
||||
|
||||
applyCommandAction();
|
||||
return true;
|
||||
|
||||
case 1:
|
||||
if (!hasOtherPermission(sender)) {
|
||||
sender.sendMessage(command.getPermissionMessage());
|
||||
return true;
|
||||
}
|
||||
|
||||
mcMMOPlayer = UserManager.getPlayer(args[0]);
|
||||
|
||||
if (!CommandUtils.checkPlayerExistence(sender, args[0], mcMMOPlayer)) {
|
||||
return true;
|
||||
}
|
||||
|
||||
player = mcMMOPlayer.getPlayer();
|
||||
|
||||
if (CommandUtils.isOffline(sender, player)) {
|
||||
return true;
|
||||
}
|
||||
|
||||
applyCommandAction();
|
||||
sendSuccessMessage(sender);
|
||||
return true;
|
||||
|
||||
default:
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<String> onTabComplete(CommandSender sender, Command command, String alias, String[] args) {
|
||||
switch (args.length) {
|
||||
case 1:
|
||||
Set<String> playerNames = UserManager.getPlayers().keySet();
|
||||
return StringUtil.copyPartialMatches(args[0], playerNames, new ArrayList<String>(playerNames.size()));
|
||||
default:
|
||||
return ImmutableList.of();
|
||||
}
|
||||
}
|
||||
|
||||
protected abstract boolean hasOtherPermission(CommandSender sender);
|
||||
protected abstract boolean hasSelfPermission(CommandSender sender);
|
||||
protected abstract void applyCommandAction();
|
||||
protected abstract void sendSuccessMessage(CommandSender sender);
|
||||
}
|
@ -1,16 +1,23 @@
|
||||
package com.gmail.nossr50.commands;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
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 com.gmail.nossr50.mcMMO;
|
||||
import com.gmail.nossr50.config.Config;
|
||||
import com.gmail.nossr50.locale.LocaleLoader;
|
||||
import com.gmail.nossr50.util.Permissions;
|
||||
import com.gmail.nossr50.util.StringUtils;
|
||||
import com.gmail.nossr50.util.commands.CommandUtils;
|
||||
|
||||
public class XprateCommand implements CommandExecutor {
|
||||
import com.google.common.collect.ImmutableList;
|
||||
|
||||
public class XprateCommand implements TabExecutor {
|
||||
private double originalRate;
|
||||
|
||||
public XprateCommand() {
|
||||
@ -75,4 +82,20 @@ public class XprateCommand implements CommandExecutor {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<String> onTabComplete(CommandSender sender, Command command, 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()));
|
||||
case 2:
|
||||
return StringUtil.copyPartialMatches(args[1], CommandUtils.TRUE_FALSE_OPTIONS, new ArrayList<String>(CommandUtils.TRUE_FALSE_OPTIONS.size()));
|
||||
default:
|
||||
return ImmutableList.of();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -1,8 +1,12 @@
|
||||
package com.gmail.nossr50.commands.chat;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
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 com.gmail.nossr50.chat.ChatMode;
|
||||
import com.gmail.nossr50.datatypes.player.McMMOPlayer;
|
||||
@ -10,7 +14,9 @@ import com.gmail.nossr50.locale.LocaleLoader;
|
||||
import com.gmail.nossr50.util.commands.CommandUtils;
|
||||
import com.gmail.nossr50.util.player.UserManager;
|
||||
|
||||
public abstract class ChatCommand implements CommandExecutor {
|
||||
import com.google.common.collect.ImmutableList;
|
||||
|
||||
public abstract class ChatCommand implements TabExecutor {
|
||||
protected ChatMode chatMode;
|
||||
private McMMOPlayer mcMMOPlayer;
|
||||
|
||||
@ -68,6 +74,16 @@ public abstract class ChatCommand implements CommandExecutor {
|
||||
}
|
||||
}
|
||||
|
||||
@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]);
|
||||
|
@ -1,8 +1,10 @@
|
||||
package com.gmail.nossr50.commands.database;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
import org.bukkit.command.Command;
|
||||
import org.bukkit.command.CommandExecutor;
|
||||
import org.bukkit.command.CommandSender;
|
||||
import org.bukkit.command.TabExecutor;
|
||||
|
||||
import com.gmail.nossr50.config.Config;
|
||||
import com.gmail.nossr50.database.DatabaseManager;
|
||||
@ -10,7 +12,9 @@ import com.gmail.nossr50.database.LeaderboardManager;
|
||||
import com.gmail.nossr50.locale.LocaleLoader;
|
||||
import com.gmail.nossr50.util.Permissions;
|
||||
|
||||
public class McpurgeCommand implements CommandExecutor {
|
||||
import com.google.common.collect.ImmutableList;
|
||||
|
||||
public class McpurgeCommand implements TabExecutor {
|
||||
@Override
|
||||
public boolean onCommand(CommandSender sender, Command command, String label, String[] args) {
|
||||
if (!Permissions.mcpurge(sender)) {
|
||||
@ -42,4 +46,9 @@ public class McpurgeCommand implements CommandExecutor {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<String> onTabComplete(CommandSender sender, Command command, String alias, String[] args) {
|
||||
return ImmutableList.of();
|
||||
}
|
||||
}
|
||||
|
@ -1,17 +1,27 @@
|
||||
package com.gmail.nossr50.commands.database;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
import java.util.Set;
|
||||
|
||||
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 com.gmail.nossr50.config.Config;
|
||||
import com.gmail.nossr50.database.DatabaseManager;
|
||||
import com.gmail.nossr50.database.LeaderboardManager;
|
||||
import com.gmail.nossr50.datatypes.player.PlayerProfile;
|
||||
import com.gmail.nossr50.locale.LocaleLoader;
|
||||
import com.gmail.nossr50.util.Misc;
|
||||
import com.gmail.nossr50.util.Permissions;
|
||||
import com.gmail.nossr50.util.commands.CommandUtils;
|
||||
import com.gmail.nossr50.util.player.UserManager;
|
||||
|
||||
public class McremoveCommand implements CommandExecutor {
|
||||
import com.google.common.collect.ImmutableList;
|
||||
|
||||
public class McremoveCommand implements TabExecutor {
|
||||
@Override
|
||||
public boolean onCommand(CommandSender sender, Command command, String label, String[] args) {
|
||||
if (!Permissions.mcremove(sender)) {
|
||||
@ -21,6 +31,10 @@ public class McremoveCommand implements CommandExecutor {
|
||||
|
||||
switch (args.length) {
|
||||
case 1:
|
||||
if (UserManager.getPlayer(args[0]) == null && CommandUtils.unloadedProfile(sender, new PlayerProfile(args[0], false))) {
|
||||
return true;
|
||||
}
|
||||
|
||||
/* MySQL */
|
||||
if (Config.getInstance().getUseMySQL()) {
|
||||
String tablePrefix = Config.getInstance().getMySQLTablePrefix();
|
||||
@ -29,18 +43,12 @@ public class McremoveCommand implements CommandExecutor {
|
||||
Misc.profileCleanup(args[0]);
|
||||
sender.sendMessage(LocaleLoader.getString("Commands.mcremove.Success", args[0]));
|
||||
}
|
||||
else {
|
||||
sender.sendMessage(LocaleLoader.getString("Commands.DoesNotExist"));
|
||||
}
|
||||
}
|
||||
else {
|
||||
if (LeaderboardManager.removeFlatFileUser(args[0])) {
|
||||
Misc.profileCleanup(args[0]);
|
||||
sender.sendMessage(LocaleLoader.getString("Commands.mcremove.Success", args[0]));
|
||||
}
|
||||
else {
|
||||
sender.sendMessage(LocaleLoader.getString("Commands.DoesNotExist"));
|
||||
}
|
||||
}
|
||||
|
||||
return true;
|
||||
@ -49,4 +57,15 @@ public class McremoveCommand implements CommandExecutor {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<String> onTabComplete(CommandSender sender, Command command, String alias, String[] args) {
|
||||
switch (args.length) {
|
||||
case 1:
|
||||
Set<String> playerNames = UserManager.getPlayers().keySet();
|
||||
return StringUtil.copyPartialMatches(args[0], playerNames, new ArrayList<String>(playerNames.size()));
|
||||
default:
|
||||
return ImmutableList.of();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -1,8 +1,10 @@
|
||||
package com.gmail.nossr50.commands.database;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
import org.bukkit.command.Command;
|
||||
import org.bukkit.command.CommandExecutor;
|
||||
import org.bukkit.command.CommandSender;
|
||||
import org.bukkit.command.TabExecutor;
|
||||
import org.bukkit.entity.Player;
|
||||
|
||||
import com.gmail.nossr50.mcMMO;
|
||||
@ -12,7 +14,9 @@ import com.gmail.nossr50.runnables.database.SQLConversionTask;
|
||||
import com.gmail.nossr50.util.Permissions;
|
||||
import com.gmail.nossr50.util.player.UserManager;
|
||||
|
||||
public class MmoupdateCommand implements CommandExecutor {
|
||||
import com.google.common.collect.ImmutableList;
|
||||
|
||||
public class MmoupdateCommand implements TabExecutor {
|
||||
@Override
|
||||
public boolean onCommand(CommandSender sender, Command command, String label, String[] args) {
|
||||
if (!Permissions.mmoupdate(sender)) {
|
||||
@ -20,12 +24,17 @@ public class MmoupdateCommand implements CommandExecutor {
|
||||
return true;
|
||||
}
|
||||
|
||||
if (!Config.getInstance().getUseMySQL()) {
|
||||
sender.sendMessage("SQL Mode is not enabled."); // TODO: Localize
|
||||
return true;
|
||||
}
|
||||
|
||||
switch (args.length) {
|
||||
case 0:
|
||||
sender.sendMessage(LocaleLoader.getString("Commands.mmoupdate.Start"));
|
||||
UserManager.saveAll();
|
||||
UserManager.clearAll();
|
||||
convertToMySQL();
|
||||
new SQLConversionTask().runTaskLaterAsynchronously(mcMMO.p, 1);
|
||||
|
||||
for (Player player : mcMMO.p.getServer().getOnlinePlayers()) {
|
||||
UserManager.addUser(player);
|
||||
@ -39,14 +48,8 @@ public class MmoupdateCommand implements CommandExecutor {
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Convert FlatFile data to MySQL data.
|
||||
*/
|
||||
private void convertToMySQL() {
|
||||
if (!Config.getInstance().getUseMySQL()) {
|
||||
return;
|
||||
}
|
||||
|
||||
new SQLConversionTask().runTaskLaterAsynchronously(mcMMO.p, 1);
|
||||
@Override
|
||||
public List<String> onTabComplete(CommandSender sender, Command command, String alias, String[] args) {
|
||||
return ImmutableList.of();
|
||||
}
|
||||
}
|
||||
|
@ -31,6 +31,5 @@ public class AddlevelsCommand extends ExperienceCommand {
|
||||
@Override
|
||||
protected void handlePlayerMessageSkill() {
|
||||
player.sendMessage(LocaleLoader.getString("Commands.addlevels.AwardSkill.1", value, SkillUtils.getSkillName(skill)));
|
||||
|
||||
}
|
||||
}
|
||||
|
@ -1,9 +1,14 @@
|
||||
package com.gmail.nossr50.commands.experience;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
import java.util.Set;
|
||||
|
||||
import org.bukkit.command.Command;
|
||||
import org.bukkit.command.CommandExecutor;
|
||||
import org.bukkit.command.CommandSender;
|
||||
import org.bukkit.command.TabExecutor;
|
||||
import org.bukkit.entity.Player;
|
||||
import org.bukkit.util.StringUtil;
|
||||
|
||||
import com.gmail.nossr50.datatypes.player.McMMOPlayer;
|
||||
import com.gmail.nossr50.datatypes.player.PlayerProfile;
|
||||
@ -13,8 +18,9 @@ import com.gmail.nossr50.util.commands.CommandUtils;
|
||||
import com.gmail.nossr50.util.player.UserManager;
|
||||
import com.gmail.nossr50.util.skills.SkillUtils;
|
||||
|
||||
import com.google.common.collect.ImmutableList;
|
||||
|
||||
public abstract class ExperienceCommand implements CommandExecutor {
|
||||
public abstract class ExperienceCommand implements TabExecutor {
|
||||
protected McMMOPlayer mcMMOPlayer;
|
||||
protected Player player;
|
||||
protected PlayerProfile profile;
|
||||
@ -84,6 +90,19 @@ public abstract class ExperienceCommand implements CommandExecutor {
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<String> onTabComplete(CommandSender sender, Command command, String alias, String[] args) {
|
||||
switch (args.length) {
|
||||
case 1:
|
||||
Set<String> playerNames = UserManager.getPlayers().keySet();
|
||||
return StringUtil.copyPartialMatches(args[0], playerNames, new ArrayList<String>(playerNames.size()));
|
||||
case 2:
|
||||
return StringUtil.copyPartialMatches(args[1], SkillType.SKILL_NAMES, new ArrayList<String>(SkillType.SKILL_NAMES.size()));
|
||||
default:
|
||||
return ImmutableList.of();
|
||||
}
|
||||
}
|
||||
|
||||
protected abstract boolean permissionsCheckSelf(CommandSender sender);
|
||||
protected abstract boolean permissionsCheckOthers(CommandSender sender);
|
||||
protected abstract void handleCommand(SkillType skill);
|
||||
|
@ -1,15 +1,21 @@
|
||||
package com.gmail.nossr50.commands.hardcore;
|
||||
|
||||
import java.text.DecimalFormat;
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
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 com.gmail.nossr50.util.Permissions;
|
||||
import com.gmail.nossr50.util.StringUtils;
|
||||
import com.gmail.nossr50.util.commands.CommandUtils;
|
||||
|
||||
public abstract class HardcoreModeCommand implements CommandExecutor {
|
||||
import com.google.common.collect.ImmutableList;
|
||||
|
||||
public abstract class HardcoreModeCommand implements TabExecutor {
|
||||
protected CommandSender sender;
|
||||
protected double newPercent;
|
||||
protected DecimalFormat percent;
|
||||
@ -76,6 +82,20 @@ public abstract class HardcoreModeCommand implements CommandExecutor {
|
||||
}
|
||||
}
|
||||
|
||||
@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();
|
||||
protected abstract boolean checkModifyPermissions();
|
||||
protected abstract boolean checkEnabled();
|
||||
|
@ -1,22 +1,46 @@
|
||||
package com.gmail.nossr50.commands.party;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.Collections;
|
||||
import java.util.List;
|
||||
import java.util.Set;
|
||||
|
||||
import org.bukkit.command.Command;
|
||||
import org.bukkit.command.CommandExecutor;
|
||||
import org.bukkit.command.CommandSender;
|
||||
import org.bukkit.command.TabExecutor;
|
||||
import org.bukkit.entity.Player;
|
||||
import org.bukkit.util.StringUtil;
|
||||
|
||||
import com.gmail.nossr50.mcMMO;
|
||||
import com.gmail.nossr50.commands.chat.PartyChatCommand;
|
||||
import com.gmail.nossr50.commands.party.teleport.PtpCommand;
|
||||
import com.gmail.nossr50.datatypes.player.McMMOPlayer;
|
||||
import com.gmail.nossr50.locale.LocaleLoader;
|
||||
import com.gmail.nossr50.util.Permissions;
|
||||
import com.gmail.nossr50.util.commands.CommandUtils;
|
||||
import com.gmail.nossr50.util.player.UserManager;
|
||||
import com.google.common.collect.ImmutableList;
|
||||
|
||||
public class PartyCommand implements CommandExecutor {
|
||||
public class PartyCommand implements TabExecutor {
|
||||
private McMMOPlayer mcMMOPlayer;
|
||||
private Player player;
|
||||
|
||||
private static final List<String> PARTY_SUBCOMMANDS;
|
||||
private static final List<String> EXPSHARE_COMPLETIONS = ImmutableList.of("none", "equal");
|
||||
private static final List<String> ITEMSHARE_COMPLETIONS = ImmutableList.of("none", "equal", "random", "loot", "mining", "herbalism", "woodcutting");
|
||||
|
||||
static {
|
||||
ArrayList<String> subcommands = new ArrayList<String>();
|
||||
|
||||
for (PartySubcommandType subcommand : PartySubcommandType.values()) {
|
||||
subcommands.add(subcommand.toString());
|
||||
}
|
||||
|
||||
Collections.sort(subcommands);
|
||||
PARTY_SUBCOMMANDS = ImmutableList.copyOf(subcommands);
|
||||
}
|
||||
|
||||
private CommandExecutor partyJoinCommand = new PartyJoinCommand();
|
||||
private CommandExecutor partyAcceptCommand = new PartyAcceptCommand();
|
||||
private CommandExecutor partyCreateCommand = new PartyCreateCommand();
|
||||
@ -135,6 +159,57 @@ public class PartyCommand implements CommandExecutor {
|
||||
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], PARTY_SUBCOMMANDS, new ArrayList<String>(PARTY_SUBCOMMANDS.size()));
|
||||
case 2:
|
||||
PartySubcommandType subcommand = PartySubcommandType.getSubcommand(args[0]);
|
||||
|
||||
if (subcommand == null) {
|
||||
return ImmutableList.of();
|
||||
}
|
||||
|
||||
switch (PartySubcommandType.valueOf(args[0].toUpperCase())) {
|
||||
case JOIN:
|
||||
case INVITE:
|
||||
case KICK:
|
||||
case OWNER:
|
||||
Set<String> playerNames = UserManager.getPlayers().keySet();
|
||||
return StringUtil.copyPartialMatches(args[1], playerNames, new ArrayList<String>(playerNames.size()));
|
||||
case EXPSHARE:
|
||||
return StringUtil.copyPartialMatches(args[1], EXPSHARE_COMPLETIONS, new ArrayList<String>(EXPSHARE_COMPLETIONS.size()));
|
||||
case ITEMSHARE:
|
||||
return StringUtil.copyPartialMatches(args[1], ITEMSHARE_COMPLETIONS, new ArrayList<String>(ITEMSHARE_COMPLETIONS.size()));
|
||||
case LOCK:
|
||||
case CHAT:
|
||||
return StringUtil.copyPartialMatches(args[1], CommandUtils.TRUE_FALSE_OPTIONS, new ArrayList<String>(CommandUtils.TRUE_FALSE_OPTIONS.size()));
|
||||
case PASSWORD:
|
||||
return StringUtil.copyPartialMatches(args[1], CommandUtils.RESET_OPTIONS, new ArrayList<String>(CommandUtils.RESET_OPTIONS.size()));
|
||||
case TELEPORT:
|
||||
List<String> matches = StringUtil.copyPartialMatches(args[1], PtpCommand.TELEPORT_SUBCOMMANDS, new ArrayList<String>(PtpCommand.TELEPORT_SUBCOMMANDS.size()));
|
||||
|
||||
if (matches.size() == 0) {
|
||||
playerNames = UserManager.getPlayers().keySet();
|
||||
return StringUtil.copyPartialMatches(args[1], playerNames, new ArrayList<String>(playerNames.size()));
|
||||
}
|
||||
|
||||
return matches;
|
||||
default:
|
||||
return ImmutableList.of();
|
||||
}
|
||||
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 ImmutableList.of();
|
||||
default:
|
||||
return ImmutableList.of();
|
||||
}
|
||||
}
|
||||
|
||||
private boolean printUsage() {
|
||||
player.sendMessage(LocaleLoader.getString("Party.Help.0", "/party join"));
|
||||
player.sendMessage(LocaleLoader.getString("Party.Help.1", "/party create"));
|
||||
@ -151,4 +226,9 @@ public class PartyCommand implements CommandExecutor {
|
||||
|
||||
return newArgs;
|
||||
}
|
||||
|
||||
private boolean isItemShareCategory(String category) {
|
||||
return category.equalsIgnoreCase("loot") || category.equalsIgnoreCase("mining") || category.equalsIgnoreCase("herbalism") || category.equalsIgnoreCase("woodcutting");
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -35,7 +35,7 @@ public class PartyExpShareCommand implements CommandExecutor {
|
||||
handleChangingShareMode(ShareMode.EQUAL);
|
||||
}
|
||||
else {
|
||||
sender.sendMessage(LocaleLoader.getString("Commands.Usage.2", "party", "expshare", "[NONE | EQUAL]"));
|
||||
sender.sendMessage(LocaleLoader.getString("Commands.Usage.2", "party", "expshare", "<NONE | EQUAL>"));
|
||||
}
|
||||
|
||||
return true;
|
||||
|
@ -21,14 +21,21 @@ public class PartyInfoCommand implements CommandExecutor {
|
||||
|
||||
@Override
|
||||
public boolean onCommand(CommandSender sender, Command command, String label, String[] args) {
|
||||
McMMOPlayer mcMMOPlayer = UserManager.getPlayer(sender.getName());
|
||||
player = mcMMOPlayer.getPlayer();
|
||||
playerParty = mcMMOPlayer.getParty();
|
||||
switch (args.length) {
|
||||
case 0:
|
||||
case 1:
|
||||
McMMOPlayer mcMMOPlayer = UserManager.getPlayer(sender.getName());
|
||||
player = mcMMOPlayer.getPlayer();
|
||||
playerParty = mcMMOPlayer.getParty();
|
||||
|
||||
displayPartyHeader();
|
||||
displayShareModeInfo();
|
||||
displayMemberInfo();
|
||||
return true;
|
||||
displayPartyHeader();
|
||||
displayShareModeInfo();
|
||||
displayMemberInfo();
|
||||
return true;
|
||||
default:
|
||||
sender.sendMessage(LocaleLoader.getString("Commands.Usage.1", "party", "info"));
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
||||
private String createMembersList() {
|
||||
|
@ -1,9 +1,15 @@
|
||||
package com.gmail.nossr50.commands.party.teleport;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
import java.util.Set;
|
||||
|
||||
import org.bukkit.command.Command;
|
||||
import org.bukkit.command.CommandExecutor;
|
||||
import org.bukkit.command.CommandSender;
|
||||
import org.bukkit.command.TabExecutor;
|
||||
import org.bukkit.entity.Player;
|
||||
import org.bukkit.util.StringUtil;
|
||||
|
||||
import com.gmail.nossr50.mcMMO;
|
||||
import com.gmail.nossr50.config.Config;
|
||||
@ -15,11 +21,14 @@ import com.gmail.nossr50.util.Misc;
|
||||
import com.gmail.nossr50.util.Permissions;
|
||||
import com.gmail.nossr50.util.commands.CommandUtils;
|
||||
import com.gmail.nossr50.util.player.UserManager;
|
||||
import com.google.common.collect.ImmutableList;
|
||||
|
||||
public class PtpCommand implements CommandExecutor {
|
||||
public class PtpCommand implements TabExecutor {
|
||||
private static Player target;
|
||||
private static McMMOPlayer mcMMOTarget;
|
||||
|
||||
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();
|
||||
@ -68,6 +77,23 @@ public class PtpCommand implements CommandExecutor {
|
||||
}
|
||||
}
|
||||
|
||||
@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()));
|
||||
|
||||
if (matches.size() == 0) {
|
||||
Set<String> playerNames = UserManager.getPlayers().keySet();
|
||||
return StringUtil.copyPartialMatches(args[0], playerNames, new ArrayList<String>(playerNames.size()));
|
||||
}
|
||||
|
||||
return matches;
|
||||
default:
|
||||
return ImmutableList.of();
|
||||
}
|
||||
}
|
||||
|
||||
private void sendTeleportRequest(CommandSender sender, Player player, String targetName) {
|
||||
if (!canTeleport(sender, player, targetName)) {
|
||||
return;
|
||||
|
@ -1,9 +1,14 @@
|
||||
package com.gmail.nossr50.commands.player;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
import java.util.Set;
|
||||
|
||||
import org.bukkit.command.Command;
|
||||
import org.bukkit.command.CommandExecutor;
|
||||
import org.bukkit.command.CommandSender;
|
||||
import org.bukkit.command.TabExecutor;
|
||||
import org.bukkit.entity.Player;
|
||||
import org.bukkit.util.StringUtil;
|
||||
|
||||
import com.gmail.nossr50.datatypes.player.McMMOPlayer;
|
||||
import com.gmail.nossr50.datatypes.player.PlayerProfile;
|
||||
@ -13,7 +18,9 @@ import com.gmail.nossr50.util.Permissions;
|
||||
import com.gmail.nossr50.util.commands.CommandUtils;
|
||||
import com.gmail.nossr50.util.player.UserManager;
|
||||
|
||||
public class InspectCommand implements CommandExecutor {
|
||||
import com.google.common.collect.ImmutableList;
|
||||
|
||||
public class InspectCommand implements TabExecutor {
|
||||
@Override
|
||||
public boolean onCommand(CommandSender sender, Command command, String label, String[] args) {
|
||||
switch (args.length) {
|
||||
@ -68,4 +75,15 @@ public class InspectCommand implements CommandExecutor {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<String> onTabComplete(CommandSender sender, Command command, String alias, String[] args) {
|
||||
switch (args.length) {
|
||||
case 1:
|
||||
Set<String> playerNames = UserManager.getPlayers().keySet();
|
||||
return StringUtil.copyPartialMatches(args[0], playerNames, new ArrayList<String>(playerNames.size()));
|
||||
default:
|
||||
return ImmutableList.of();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -1,8 +1,13 @@
|
||||
package com.gmail.nossr50.commands.player;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
import java.util.Set;
|
||||
|
||||
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 com.gmail.nossr50.mcMMO;
|
||||
import com.gmail.nossr50.config.Config;
|
||||
@ -17,7 +22,9 @@ import com.gmail.nossr50.util.commands.CommandUtils;
|
||||
import com.gmail.nossr50.util.player.UserManager;
|
||||
import com.gmail.nossr50.util.skills.SkillUtils;
|
||||
|
||||
public class McrankCommand implements CommandExecutor {
|
||||
import com.google.common.collect.ImmutableList;
|
||||
|
||||
public class McrankCommand implements TabExecutor {
|
||||
@Override
|
||||
public boolean onCommand(CommandSender sender, Command command, String label, String[] args) {
|
||||
switch (args.length) {
|
||||
@ -74,6 +81,17 @@ public class McrankCommand implements CommandExecutor {
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<String> onTabComplete(CommandSender sender, Command command, String alias, String[] args) {
|
||||
switch (args.length) {
|
||||
case 1:
|
||||
Set<String> playerNames = UserManager.getPlayers().keySet();
|
||||
return StringUtil.copyPartialMatches(args[0], playerNames, new ArrayList<String>(playerNames.size()));
|
||||
default:
|
||||
return ImmutableList.of();
|
||||
}
|
||||
}
|
||||
|
||||
private void flatfileDisplay(CommandSender sender, String playerName) {
|
||||
LeaderboardManager.updateLeaderboards(); // Make sure the information is up to date
|
||||
|
||||
|
@ -1,8 +1,10 @@
|
||||
package com.gmail.nossr50.commands.player;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
import org.bukkit.command.Command;
|
||||
import org.bukkit.command.CommandExecutor;
|
||||
import org.bukkit.command.CommandSender;
|
||||
import org.bukkit.command.TabExecutor;
|
||||
import org.bukkit.entity.Player;
|
||||
|
||||
import com.gmail.nossr50.config.Config;
|
||||
@ -11,7 +13,9 @@ import com.gmail.nossr50.locale.LocaleLoader;
|
||||
import com.gmail.nossr50.util.commands.CommandUtils;
|
||||
import com.gmail.nossr50.util.player.UserManager;
|
||||
|
||||
public class McstatsCommand implements CommandExecutor {
|
||||
import com.google.common.collect.ImmutableList;
|
||||
|
||||
public class McstatsCommand implements TabExecutor {
|
||||
@Override
|
||||
public boolean onCommand(CommandSender sender, Command command, String label, String[] args) {
|
||||
if (CommandUtils.noConsoleUsage(sender)) {
|
||||
@ -45,4 +49,9 @@ public class McstatsCommand implements CommandExecutor {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<String> onTabComplete(CommandSender sender, Command command, String alias, String[] args) {
|
||||
return ImmutableList.of();
|
||||
}
|
||||
}
|
||||
|
@ -1,9 +1,13 @@
|
||||
package com.gmail.nossr50.commands.player;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
import org.bukkit.ChatColor;
|
||||
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 com.gmail.nossr50.mcMMO;
|
||||
import com.gmail.nossr50.config.Config;
|
||||
@ -15,7 +19,9 @@ import com.gmail.nossr50.util.Permissions;
|
||||
import com.gmail.nossr50.util.StringUtils;
|
||||
import com.gmail.nossr50.util.commands.CommandUtils;
|
||||
|
||||
public class MctopCommand implements CommandExecutor {
|
||||
import com.google.common.collect.ImmutableList;
|
||||
|
||||
public class MctopCommand implements TabExecutor {
|
||||
private SkillType skill;
|
||||
|
||||
@Override
|
||||
@ -58,6 +64,16 @@ public class MctopCommand implements CommandExecutor {
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<String> onTabComplete(CommandSender sender, Command command, String alias, String[] args) {
|
||||
switch (args.length) {
|
||||
case 1:
|
||||
return StringUtil.copyPartialMatches(args[1], SkillType.SKILL_NAMES, new ArrayList<String>(SkillType.SKILL_NAMES.size()));
|
||||
default:
|
||||
return ImmutableList.of();
|
||||
}
|
||||
}
|
||||
|
||||
private void display(int page, String skill, CommandSender sender, boolean sql, Command command) {
|
||||
if (!skill.equalsIgnoreCase("all") && !Permissions.mctop(sender, this.skill)) {
|
||||
sender.sendMessage(command.getPermissionMessage());
|
||||
|
@ -1,11 +1,13 @@
|
||||
package com.gmail.nossr50.commands.skills;
|
||||
|
||||
import java.text.DecimalFormat;
|
||||
import java.util.List;
|
||||
import java.util.Set;
|
||||
|
||||
import org.bukkit.command.Command;
|
||||
import org.bukkit.command.CommandExecutor;
|
||||
import org.bukkit.command.CommandSender;
|
||||
import org.bukkit.command.TabExecutor;
|
||||
import org.bukkit.entity.Player;
|
||||
|
||||
import com.gmail.nossr50.config.AdvancedConfig;
|
||||
@ -21,7 +23,9 @@ import com.gmail.nossr50.util.player.UserManager;
|
||||
import com.gmail.nossr50.util.skills.PerksUtils;
|
||||
import com.gmail.nossr50.util.skills.SkillUtils;
|
||||
|
||||
public abstract class SkillCommand implements CommandExecutor {
|
||||
import com.google.common.collect.ImmutableList;
|
||||
|
||||
public abstract class SkillCommand implements TabExecutor {
|
||||
protected SkillType skill;
|
||||
protected String skillName;
|
||||
|
||||
@ -102,6 +106,16 @@ public abstract class SkillCommand implements CommandExecutor {
|
||||
}
|
||||
}
|
||||
|
||||
@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();
|
||||
}
|
||||
}
|
||||
|
||||
protected int calculateRank(int maxLevel, int rankChangeLevel) {
|
||||
return Math.min((int) skillValue, maxLevel) / rankChangeLevel;
|
||||
}
|
||||
|
@ -1,12 +1,41 @@
|
||||
package com.gmail.nossr50.commands.spout;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.Collections;
|
||||
import java.util.List;
|
||||
|
||||
import org.bukkit.command.Command;
|
||||
import org.bukkit.command.CommandSender;
|
||||
import org.bukkit.util.StringUtil;
|
||||
|
||||
import com.gmail.nossr50.datatypes.spout.huds.HudType;
|
||||
import com.gmail.nossr50.locale.LocaleLoader;
|
||||
import com.google.common.collect.ImmutableList;
|
||||
|
||||
public class MchudCommand extends SpoutCommand {
|
||||
private static final List<String> HUD_TYPES;
|
||||
|
||||
static {
|
||||
ArrayList<String> types = new ArrayList<String>();
|
||||
|
||||
for (HudType type : HudType.values()) {
|
||||
types.add(type.toString());
|
||||
}
|
||||
|
||||
Collections.sort(types);
|
||||
HUD_TYPES = ImmutableList.copyOf(types);
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<String> onTabComplete(CommandSender sender, Command command, String alias, String[] args) {
|
||||
switch (args.length) {
|
||||
case 1:
|
||||
return StringUtil.copyPartialMatches(args[0], HUD_TYPES, new ArrayList<String>(HUD_TYPES.size()));
|
||||
default:
|
||||
return ImmutableList.of();
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
protected boolean noArguments(Command command, CommandSender sender, String[] args) {
|
||||
return false;
|
||||
|
@ -1,8 +1,8 @@
|
||||
package com.gmail.nossr50.commands.spout;
|
||||
|
||||
import org.bukkit.command.Command;
|
||||
import org.bukkit.command.CommandExecutor;
|
||||
import org.bukkit.command.CommandSender;
|
||||
import org.bukkit.command.TabExecutor;
|
||||
|
||||
import com.gmail.nossr50.mcMMO;
|
||||
import com.gmail.nossr50.config.spout.SpoutConfig;
|
||||
@ -12,7 +12,7 @@ import com.gmail.nossr50.locale.LocaleLoader;
|
||||
import com.gmail.nossr50.util.commands.CommandUtils;
|
||||
import com.gmail.nossr50.util.player.UserManager;
|
||||
|
||||
public abstract class SpoutCommand implements CommandExecutor {
|
||||
public abstract class SpoutCommand implements TabExecutor {
|
||||
protected PlayerProfile playerProfile;
|
||||
protected McMMOHud spoutHud;
|
||||
|
||||
|
@ -1,15 +1,36 @@
|
||||
package com.gmail.nossr50.commands.spout;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
import org.bukkit.command.Command;
|
||||
import org.bukkit.command.CommandSender;
|
||||
import org.bukkit.util.StringUtil;
|
||||
|
||||
import com.gmail.nossr50.datatypes.skills.SkillType;
|
||||
import com.gmail.nossr50.locale.LocaleLoader;
|
||||
import com.gmail.nossr50.util.Permissions;
|
||||
import com.gmail.nossr50.util.commands.CommandUtils;
|
||||
import com.gmail.nossr50.util.skills.SkillUtils;
|
||||
import com.google.common.collect.ImmutableList;
|
||||
|
||||
public class XplockCommand extends SpoutCommand {
|
||||
@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], CommandUtils.TRUE_FALSE_OPTIONS, new ArrayList<String>(CommandUtils.TRUE_FALSE_OPTIONS.size()));
|
||||
|
||||
if (matches.size() == 0) {
|
||||
return StringUtil.copyPartialMatches(args[0], SkillType.SKILL_NAMES, new ArrayList<String>(SkillType.SKILL_NAMES.size()));
|
||||
}
|
||||
|
||||
return matches;
|
||||
default:
|
||||
return ImmutableList.of();
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
protected boolean noArguments(Command command, CommandSender sender, String[] args) {
|
||||
if (spoutHud.getXpBarLocked()) {
|
||||
|
@ -1,5 +1,9 @@
|
||||
package com.gmail.nossr50.datatypes.skills;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.Collections;
|
||||
import java.util.List;
|
||||
|
||||
import org.bukkit.Color;
|
||||
|
||||
import com.gmail.nossr50.mcMMO;
|
||||
@ -20,6 +24,8 @@ import com.gmail.nossr50.skills.taming.TamingManager;
|
||||
import com.gmail.nossr50.skills.unarmed.UnarmedManager;
|
||||
import com.gmail.nossr50.skills.woodcutting.WoodcuttingManager;
|
||||
import com.gmail.nossr50.util.StringUtils;
|
||||
import com.gmail.nossr50.util.skills.SkillUtils;
|
||||
import com.google.common.collect.ImmutableList;
|
||||
|
||||
public enum SkillType {
|
||||
ACROBATICS(AcrobaticsManager.class, Color.WHITE),
|
||||
@ -41,6 +47,19 @@ public enum SkillType {
|
||||
private AbilityType ability;
|
||||
private ToolType tool;
|
||||
|
||||
public static final List<String> SKILL_NAMES;
|
||||
|
||||
static {
|
||||
ArrayList<String> names = new ArrayList<String>();
|
||||
|
||||
for (SkillType skill : values()) {
|
||||
names.add(SkillUtils.getSkillName(skill));
|
||||
}
|
||||
|
||||
Collections.sort(names);
|
||||
SKILL_NAMES = ImmutableList.copyOf(names);
|
||||
}
|
||||
|
||||
private SkillType(Class<? extends SkillManager> managerClass, Color runescapeColor) {
|
||||
this.managerClass = managerClass;
|
||||
this.runescapeColor = runescapeColor;
|
||||
|
@ -1,5 +1,7 @@
|
||||
package com.gmail.nossr50.util.commands;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
import org.bukkit.command.CommandSender;
|
||||
import org.bukkit.entity.Player;
|
||||
|
||||
@ -13,7 +15,12 @@ import com.gmail.nossr50.util.StringUtils;
|
||||
import com.gmail.nossr50.util.player.UserManager;
|
||||
import com.gmail.nossr50.util.skills.SkillUtils;
|
||||
|
||||
import com.google.common.collect.ImmutableList;
|
||||
|
||||
public final class CommandUtils {
|
||||
public static final List<String> TRUE_FALSE_OPTIONS = ImmutableList.of("on", "off", "true", "false", "enabled", "disabled");
|
||||
public static final List<String> RESET_OPTIONS = ImmutableList.of("clear", "reset");
|
||||
|
||||
private CommandUtils() {}
|
||||
|
||||
public static boolean isChildSkill(CommandSender sender, SkillType skill) {
|
||||
|
Loading…
Reference in New Issue
Block a user