mirror of
https://github.com/mcMMO-Dev/mcMMO.git
synced 2024-11-24 14:16:45 +01:00
Add back some missing commands
This commit is contained in:
parent
9b856f456c
commit
062665ded4
@ -0,0 +1,29 @@
|
|||||||
|
package com.gmail.nossr50.commands;
|
||||||
|
|
||||||
|
import com.gmail.nossr50.datatypes.player.McMMOPlayer;
|
||||||
|
import com.gmail.nossr50.locale.LocaleLoader;
|
||||||
|
import com.gmail.nossr50.util.Permissions;
|
||||||
|
import org.bukkit.command.CommandSender;
|
||||||
|
|
||||||
|
public class AbilityToggleCommand extends ToggleCommand {
|
||||||
|
@Override
|
||||||
|
protected boolean hasOtherPermission(CommandSender sender) {
|
||||||
|
return Permissions.mcabilityOthers(sender);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
protected boolean hasSelfPermission(CommandSender sender) {
|
||||||
|
return Permissions.mcability(sender);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
protected void applyCommandAction(McMMOPlayer mcMMOPlayer) {
|
||||||
|
mcMMOPlayer.getPlayer().sendMessage(LocaleLoader.getString("Commands.Ability." + (mcMMOPlayer.getAbilityUse() ? "Off" : "On")));
|
||||||
|
mcMMOPlayer.toggleAbilityUse();
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
protected void sendSuccessMessage(CommandSender sender, String playerName) {
|
||||||
|
sender.sendMessage(LocaleLoader.getString("Commands.Ability.Toggle", playerName));
|
||||||
|
}
|
||||||
|
}
|
@ -0,0 +1,54 @@
|
|||||||
|
package com.gmail.nossr50.commands.database;
|
||||||
|
|
||||||
|
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.Bukkit;
|
||||||
|
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;
|
||||||
|
import java.util.UUID;
|
||||||
|
|
||||||
|
public class RemoveCommand implements TabExecutor {
|
||||||
|
@Override
|
||||||
|
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;
|
||||||
|
}
|
||||||
|
|
||||||
|
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(@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();
|
||||||
|
}
|
||||||
|
}
|
@ -7,6 +7,7 @@ import com.gmail.nossr50.locale.LocaleLoader;
|
|||||||
import com.gmail.nossr50.util.EventUtils;
|
import com.gmail.nossr50.util.EventUtils;
|
||||||
import com.gmail.nossr50.util.Permissions;
|
import com.gmail.nossr50.util.Permissions;
|
||||||
import com.gmail.nossr50.util.player.UserManager;
|
import com.gmail.nossr50.util.player.UserManager;
|
||||||
|
import com.neetgames.mcmmo.experience.XPGainReason;
|
||||||
import org.bukkit.command.CommandSender;
|
import org.bukkit.command.CommandSender;
|
||||||
import org.bukkit.entity.Player;
|
import org.bukkit.entity.Player;
|
||||||
|
|
||||||
|
@ -8,6 +8,7 @@ import com.gmail.nossr50.locale.LocaleLoader;
|
|||||||
import com.gmail.nossr50.util.EventUtils;
|
import com.gmail.nossr50.util.EventUtils;
|
||||||
import com.gmail.nossr50.util.Permissions;
|
import com.gmail.nossr50.util.Permissions;
|
||||||
import com.gmail.nossr50.util.player.UserManager;
|
import com.gmail.nossr50.util.player.UserManager;
|
||||||
|
import com.neetgames.mcmmo.experience.XPGainReason;
|
||||||
import org.bukkit.command.CommandSender;
|
import org.bukkit.command.CommandSender;
|
||||||
import org.bukkit.entity.Player;
|
import org.bukkit.entity.Player;
|
||||||
|
|
||||||
|
@ -1,6 +1,5 @@
|
|||||||
package com.gmail.nossr50.commands.experience;
|
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.McMMOPlayer;
|
||||||
import com.gmail.nossr50.datatypes.player.PlayerProfile;
|
import com.gmail.nossr50.datatypes.player.PlayerProfile;
|
||||||
import com.gmail.nossr50.datatypes.skills.PrimarySkillType;
|
import com.gmail.nossr50.datatypes.skills.PrimarySkillType;
|
||||||
@ -27,7 +26,7 @@ import java.util.UUID;
|
|||||||
* This class mirrors the structure of ExperienceCommand, except the
|
* This class mirrors the structure of ExperienceCommand, except the
|
||||||
* value/quantity argument is removed.
|
* value/quantity argument is removed.
|
||||||
*/
|
*/
|
||||||
public class SkillresetCommand implements TabExecutor {
|
public class SkillResetCommand implements TabExecutor {
|
||||||
@Override
|
@Override
|
||||||
public boolean onCommand(@NotNull CommandSender sender, @NotNull Command command, @NotNull String label, String[] args) {
|
public boolean onCommand(@NotNull CommandSender sender, @NotNull Command command, @NotNull String label, String[] args) {
|
||||||
PrimarySkillType skill;
|
PrimarySkillType skill;
|
@ -708,10 +708,6 @@ public class mcMMO extends JavaPlugin {
|
|||||||
return spawnedProjectileTracker;
|
return spawnedProjectileTracker;
|
||||||
}
|
}
|
||||||
|
|
||||||
public static @NotNull UserManager getUserManager() {
|
|
||||||
return userManager;
|
|
||||||
}
|
|
||||||
|
|
||||||
public static @NotNull PartyManager getPartyManager() {
|
public static @NotNull PartyManager getPartyManager() {
|
||||||
return partyManager;
|
return partyManager;
|
||||||
}
|
}
|
||||||
|
@ -1,6 +1,7 @@
|
|||||||
package com.gmail.nossr50.util;
|
package com.gmail.nossr50.util;
|
||||||
|
|
||||||
import com.gmail.nossr50.config.Config;
|
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.player.PlayerProfile;
|
||||||
import com.gmail.nossr50.datatypes.skills.PrimarySkillType;
|
import com.gmail.nossr50.datatypes.skills.PrimarySkillType;
|
||||||
import com.gmail.nossr50.datatypes.skills.SubSkillType;
|
import com.gmail.nossr50.datatypes.skills.SubSkillType;
|
||||||
@ -31,6 +32,7 @@ import com.gmail.nossr50.locale.LocaleLoader;
|
|||||||
import com.gmail.nossr50.mcMMO;
|
import com.gmail.nossr50.mcMMO;
|
||||||
import com.gmail.nossr50.util.player.NotificationManager;
|
import com.gmail.nossr50.util.player.NotificationManager;
|
||||||
import com.gmail.nossr50.util.skills.CombatUtils;
|
import com.gmail.nossr50.util.skills.CombatUtils;
|
||||||
|
import com.neetgames.mcmmo.experience.XPGainReason;
|
||||||
import com.neetgames.mcmmo.party.Party;
|
import com.neetgames.mcmmo.party.Party;
|
||||||
import com.neetgames.mcmmo.player.OnlineMMOPlayer;
|
import com.neetgames.mcmmo.player.OnlineMMOPlayer;
|
||||||
import org.bukkit.block.Block;
|
import org.bukkit.block.Block;
|
||||||
|
@ -6,11 +6,12 @@ import com.gmail.nossr50.commands.admin.McmmoReloadLocaleCommand;
|
|||||||
import com.gmail.nossr50.commands.admin.PlayerDebugCommand;
|
import com.gmail.nossr50.commands.admin.PlayerDebugCommand;
|
||||||
import com.gmail.nossr50.commands.chat.McChatSpy;
|
import com.gmail.nossr50.commands.chat.McChatSpy;
|
||||||
import com.gmail.nossr50.commands.database.McpurgeCommand;
|
import com.gmail.nossr50.commands.database.McpurgeCommand;
|
||||||
|
import com.gmail.nossr50.commands.database.RemoveCommand;
|
||||||
import com.gmail.nossr50.commands.database.MmoshowdbCommand;
|
import com.gmail.nossr50.commands.database.MmoshowdbCommand;
|
||||||
import com.gmail.nossr50.commands.experience.AddlevelsCommand;
|
import com.gmail.nossr50.commands.experience.AddlevelsCommand;
|
||||||
import com.gmail.nossr50.commands.experience.AddxpCommand;
|
import com.gmail.nossr50.commands.experience.AddxpCommand;
|
||||||
import com.gmail.nossr50.commands.experience.MmoeditCommand;
|
import com.gmail.nossr50.commands.experience.MmoeditCommand;
|
||||||
import com.gmail.nossr50.commands.experience.SkillresetCommand;
|
import com.gmail.nossr50.commands.experience.SkillResetCommand;
|
||||||
import com.gmail.nossr50.commands.party.PartyCommand;
|
import com.gmail.nossr50.commands.party.PartyCommand;
|
||||||
import com.gmail.nossr50.commands.party.teleport.PtpCommand;
|
import com.gmail.nossr50.commands.party.teleport.PtpCommand;
|
||||||
import com.gmail.nossr50.commands.player.*;
|
import com.gmail.nossr50.commands.player.*;
|
||||||
@ -206,7 +207,7 @@ public final class CommandRegistrationManager {
|
|||||||
command.setPermission("mcmmo.commands.skillreset;mcmmo.commands.skillreset.others"); // Only need the main ones, not the individual skill ones
|
command.setPermission("mcmmo.commands.skillreset;mcmmo.commands.skillreset.others"); // Only need the main ones, not the individual skill ones
|
||||||
command.setPermissionMessage(permissionsMessage);
|
command.setPermissionMessage(permissionsMessage);
|
||||||
command.setUsage(LocaleLoader.getString("Commands.Usage.2", "skillreset", "[" + LocaleLoader.getString("Commands.Usage.Player") + "]", "<" + LocaleLoader.getString("Commands.Usage.Skill") + ">"));
|
command.setUsage(LocaleLoader.getString("Commands.Usage.2", "skillreset", "[" + LocaleLoader.getString("Commands.Usage.Player") + "]", "<" + LocaleLoader.getString("Commands.Usage.Skill") + ">"));
|
||||||
command.setExecutor(new SkillresetCommand());
|
command.setExecutor(new SkillResetCommand());
|
||||||
}
|
}
|
||||||
|
|
||||||
private static void registerXprateCommand() {
|
private static void registerXprateCommand() {
|
||||||
@ -302,7 +303,7 @@ public final class CommandRegistrationManager {
|
|||||||
command.setPermission("mcmmo.commands.mcremove");
|
command.setPermission("mcmmo.commands.mcremove");
|
||||||
command.setPermissionMessage(permissionsMessage);
|
command.setPermissionMessage(permissionsMessage);
|
||||||
command.setUsage(LocaleLoader.getString("Commands.Usage.1", "mcremove", "<" + LocaleLoader.getString("Commands.Usage.Player") + ">"));
|
command.setUsage(LocaleLoader.getString("Commands.Usage.1", "mcremove", "<" + LocaleLoader.getString("Commands.Usage.Player") + ">"));
|
||||||
command.setExecutor(new DatabaseRemovePlayerCommand());
|
command.setExecutor(new RemoveCommand());
|
||||||
}
|
}
|
||||||
|
|
||||||
private static void registerMmoshowdbCommand() {
|
private static void registerMmoshowdbCommand() {
|
||||||
|
@ -1,11 +1,13 @@
|
|||||||
package com.gmail.nossr50.util.commands;
|
package com.gmail.nossr50.util.commands;
|
||||||
|
|
||||||
import com.gmail.nossr50.config.Config;
|
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.player.PlayerProfile;
|
||||||
import com.gmail.nossr50.datatypes.skills.PrimarySkillType;
|
import com.gmail.nossr50.datatypes.skills.PrimarySkillType;
|
||||||
import com.gmail.nossr50.locale.LocaleLoader;
|
import com.gmail.nossr50.locale.LocaleLoader;
|
||||||
import com.gmail.nossr50.mcMMO;
|
import com.gmail.nossr50.mcMMO;
|
||||||
import com.gmail.nossr50.util.Misc;
|
import com.gmail.nossr50.util.Misc;
|
||||||
|
import com.gmail.nossr50.util.player.UserManager;
|
||||||
import com.gmail.nossr50.util.skills.SkillUtils;
|
import com.gmail.nossr50.util.skills.SkillUtils;
|
||||||
import com.gmail.nossr50.util.text.StringUtils;
|
import com.gmail.nossr50.util.text.StringUtils;
|
||||||
import com.google.common.collect.ImmutableList;
|
import com.google.common.collect.ImmutableList;
|
||||||
@ -77,9 +79,9 @@ public final class CommandUtils {
|
|||||||
*
|
*
|
||||||
* @return true if the player is online and a valid mmoPlayer object was found
|
* @return true if the player is online and a valid mmoPlayer object was found
|
||||||
*/
|
*/
|
||||||
public static boolean checkPlayerExistence(CommandSender sender, String playerName, OnlineMMOPlayer mmoPlayer) {
|
public static boolean checkPlayerExistence(CommandSender sender, String playerName, McMMOPlayer mcMMOPlayer) {
|
||||||
if (mmoPlayer != null) {
|
if (mcMMOPlayer != null) {
|
||||||
if (CommandUtils.hidden(sender, Misc.adaptPlayer(mmoPlayer), false)) {
|
if (CommandUtils.hidden(sender, mcMMOPlayer.getPlayer(), false)) {
|
||||||
sender.sendMessage(LocaleLoader.getString("Commands.Offline"));
|
sender.sendMessage(LocaleLoader.getString("Commands.Offline"));
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
@ -88,7 +90,7 @@ public final class CommandUtils {
|
|||||||
|
|
||||||
PlayerProfile profile = new PlayerProfile(playerName, false);
|
PlayerProfile profile = new PlayerProfile(playerName, false);
|
||||||
|
|
||||||
if (hasNoProfile(sender, profile)) {
|
if (unloadedProfile(sender, profile)) {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -96,12 +98,12 @@ public final class CommandUtils {
|
|||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
public static boolean hasNoProfile(CommandSender sender, PlayerProfile profile) {
|
public static boolean unloadedProfile(CommandSender sender, PlayerProfile profile) {
|
||||||
if (profile.isLoaded()) {
|
if (profile.isLoaded()) {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
sender.sendMessage(LocaleLoader.getString("Commands.Offline"));
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -119,6 +121,15 @@ public final class CommandUtils {
|
|||||||
return hasPlayerDataKey;
|
return hasPlayerDataKey;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public static boolean isLoaded(CommandSender sender, PlayerProfile profile) {
|
||||||
|
if (profile.isLoaded()) {
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
sender.sendMessage(LocaleLoader.getString("Commands.NotLoaded"));
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
public static boolean isInvalidInteger(CommandSender sender, String value) {
|
public static boolean isInvalidInteger(CommandSender sender, String value) {
|
||||||
if (StringUtils.isInt(value)) {
|
if (StringUtils.isInt(value)) {
|
||||||
return false;
|
return false;
|
||||||
@ -207,10 +218,10 @@ public final class CommandUtils {
|
|||||||
}
|
}
|
||||||
|
|
||||||
private static void printGroupedSkillData(Player inspect, CommandSender display, String header, List<PrimarySkillType> skillGroup) {
|
private static void printGroupedSkillData(Player inspect, CommandSender display, String header, List<PrimarySkillType> skillGroup) {
|
||||||
if(UserManager.queryPlayer(inspect) == null)
|
if(UserManager.getPlayer(inspect) == null)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
PlayerProfile profile = UserManager.queryPlayer(inspect);
|
PlayerProfile profile = UserManager.getPlayer(inspect).getProfile();
|
||||||
|
|
||||||
List<String> displayData = new ArrayList<>();
|
List<String> displayData = new ArrayList<>();
|
||||||
displayData.add(header);
|
displayData.add(header);
|
||||||
|
Loading…
Reference in New Issue
Block a user