Remove YAML-only pointsall subcommand

This commit is contained in:
PikaMug 2024-02-15 14:32:46 -05:00
parent 0cc6d7770b
commit 8eae46ad07
4 changed files with 0 additions and 148 deletions

View File

@ -16,7 +16,6 @@ import me.pikamug.quests.commands.questadmin.subcommands.BukkitQuestadminGiveCom
import me.pikamug.quests.commands.questadmin.subcommands.BukkitQuestadminGivepointsCommand;
import me.pikamug.quests.commands.questadmin.subcommands.BukkitQuestadminNextstageCommand;
import me.pikamug.quests.commands.questadmin.subcommands.BukkitQuestadminPointsCommand;
import me.pikamug.quests.commands.questadmin.subcommands.BukkitQuestadminPointsallCommand;
import me.pikamug.quests.commands.questadmin.subcommands.BukkitQuestadminQuitCommand;
import me.pikamug.quests.commands.questadmin.subcommands.BukkitQuestadminReloadCommand;
import me.pikamug.quests.commands.questadmin.subcommands.BukkitQuestadminRemoveCommand;
@ -50,7 +49,6 @@ public class BukkitQuestadminCommandHandler {
new BukkitQuestadminPointsCommand(plugin),
new BukkitQuestadminTakepointsCommand(plugin),
new BukkitQuestadminGivepointsCommand(plugin),
new BukkitQuestadminPointsallCommand(plugin),
new BukkitQuestadminFinishCommand(plugin),
new BukkitQuestadminNextstageCommand(plugin),
new BukkitQuestadminSetstageCommand(plugin),
@ -142,13 +140,6 @@ public class BukkitQuestadminCommandHandler {
+ (translateSubCommands ? BukkitLang.get("COMMAND_QUESTADMIN_GIVEPOINTS") : "givepoints")
+ ChatColor.RED));
}
if (cs.hasPermission("quests.admin.*") || cs.hasPermission("quests.admin.pointsall")) {
cs.sendMessage(ChatColor.YELLOW + "/questadmin " + ChatColor.RED
+ BukkitLang.get("COMMAND_QUESTADMIN_POINTSALL_HELP")
.replace("<points>", BukkitLang.get("questPoints"))
.replace("<command>", ChatColor.GOLD
+ (translateSubCommands ? BukkitLang.get("COMMAND_QUESTADMIN_POINTSALL") : "pointsall") + ChatColor.RED));
}
if (cs.hasPermission("quests.admin.*") || cs.hasPermission("quests.admin.finish")) {
cs.sendMessage(ChatColor.YELLOW + "/questadmin " + ChatColor.RED
+ BukkitLang.get("COMMAND_QUESTADMIN_FINISH_HELP").replace("<command>", ChatColor.GOLD

View File

@ -1,128 +0,0 @@
/*
* Copyright (c) PikaMug and contributors
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT
* LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
* IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
* WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
* SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
*/
package me.pikamug.quests.commands.questadmin.subcommands;
import me.pikamug.quests.BukkitQuestsPlugin;
import me.pikamug.quests.commands.BukkitQuestsSubCommand;
import me.pikamug.quests.player.Quester;
import me.pikamug.quests.util.BukkitLang;
import org.bukkit.Bukkit;
import org.bukkit.ChatColor;
import org.bukkit.command.CommandSender;
import org.bukkit.configuration.InvalidConfigurationException;
import org.bukkit.configuration.file.FileConfiguration;
import org.bukkit.configuration.file.YamlConfiguration;
import java.io.File;
import java.io.IOException;
public class BukkitQuestadminPointsallCommand extends BukkitQuestsSubCommand {
private final BukkitQuestsPlugin plugin;
public BukkitQuestadminPointsallCommand(BukkitQuestsPlugin plugin) {
this.plugin = plugin;
}
@Override
public String getName() {
return "pointsall";
}
@Override
public String getNameI18N() {
return BukkitLang.get("COMMAND_QUESTADMIN_POINTSALL");
}
@Override
public String getDescription() {
return BukkitLang.get("COMMAND_QUESTADMIN_POINTSALL_HELP");
}
@Override
public String getPermission() {
return "quests.admin.pointsall";
}
@Override
public String getSyntax() {
return "/questadmin pointsall";
}
@Override
public int getMaxArguments() {
return 2;
}
@Override
public void execute(CommandSender cs, String[] args) {
if (args.length == 1) {
// Shows command usage
return;
}
if (cs.hasPermission("quests.admin.*") || cs.hasPermission("quests.admin.pointsall")) {
final int amount;
try {
amount = Integer.parseInt(args[1]);
if (amount < 0) {
cs.sendMessage(ChatColor.RED + BukkitLang.get("inputPosNum"));
return;
}
} catch (final NumberFormatException e) {
cs.sendMessage(ChatColor.RED + BukkitLang.get("inputNum"));
return;
}
cs.sendMessage(ChatColor.YELLOW + BukkitLang.get("settingAllQuestPoints")
.replace("<points>", BukkitLang.get("questPoints")));
for (final Quester q : plugin.getOfflineQuesters()) {
q.setQuestPoints(amount);
}
Bukkit.getScheduler().runTaskAsynchronously(plugin, () -> {
final File questerFolder = new File(plugin.getDataFolder(), "data");
if (questerFolder.exists() && questerFolder.isDirectory()) {
final FileConfiguration data = new YamlConfiguration();
final File[] files = questerFolder.listFiles();
int failCount = 0;
boolean suppressed = false;
if (files != null) {
for (final File f : files) {
try {
data.load(f);
data.set("quest-points", amount);
data.save(f);
} catch (final IOException | InvalidConfigurationException e) {
if (failCount < 10) {
String msg = BukkitLang.get("errorReading");
msg = msg.replace("<file>", ChatColor.DARK_AQUA + f.getName() + ChatColor.RED);
cs.sendMessage(ChatColor.RED + msg);
failCount++;
} else if (!suppressed) {
String msg = BukkitLang.get("errorReadingSuppress");
msg = msg.replace("<file>", ChatColor.DARK_AQUA + f.getName() + ChatColor.RED);
cs.sendMessage(ChatColor.RED + msg);
suppressed = true;
}
}
}
}
cs.sendMessage(ChatColor.GREEN + BukkitLang.get("done"));
String msg = BukkitLang.get("allQuestPointsSet").replace("<points>", BukkitLang.get("questPoints"));
msg = msg.replace("<number>", ChatColor.AQUA + "" + amount + ChatColor.GOLD);
plugin.getServer().broadcastMessage(ChatColor.YELLOW + "" + ChatColor.GOLD + msg);
} else {
cs.sendMessage(ChatColor.RED + BukkitLang.get("errorDataFolder"));
}
});
} else {
cs.sendMessage(ChatColor.RED + BukkitLang.get("noPermission"));
}
}
}

View File

@ -75,7 +75,6 @@ permissions:
quests.admin.points: true
quests.admin.takepoints: true
quests.admin.givepoints: true
quests.admin.pointsall: true
quests.admin.finish: true
quests.admin.nextstage: true
quests.admin.setstage: true
@ -105,9 +104,6 @@ permissions:
quests.admin.givepoints:
description: Add to a player's Quest Points
default: op
quests.admin.pointsall:
description: Set ALL players' Quest Points
default: op
quests.admin.finish:
description: Force a player to complete a quest
default: op

View File

@ -35,8 +35,6 @@ COMMAND_QUESTADMIN_TAKEPOINTS: "takepoints"
COMMAND_QUESTADMIN_TAKEPOINTS_HELP: "<command> [player] [amount] - Take away a player's <points>"
COMMAND_QUESTADMIN_GIVEPOINTS: "givepoints"
COMMAND_QUESTADMIN_GIVEPOINTS_HELP: "<command> [player] [amount] - Add to a player's <points>"
COMMAND_QUESTADMIN_POINTSALL: "pointsall"
COMMAND_QUESTADMIN_POINTSALL_HELP: "<command> [amount] - Set ALL players' <points>"
COMMAND_QUESTADMIN_FINISH: "finish"
COMMAND_QUESTADMIN_FINISH_HELP: "<command> [player] [quest] - Force a player to complete a quest"
COMMAND_QUESTADMIN_NEXTSTAGE: "nextstage"
@ -701,8 +699,6 @@ questForceNextStage: "<player> has advanced to the next stage in the quest <ques
questForcedNextStage: "<player> has advanced you to the next stage in your quest <quest>."
questReset: "<player> has been reset."
questRemoved: "Quest <quest> has been removed from player <player>'s completed quests."
settingAllQuestPoints: "Setting all players' <points>..."
allQuestPointsSet: "All players' <points> have been set to <number>!"
setQuestPoints: "<player>'s <points> have been set to <number>."
questPointsSet: "<player> has set your <points> to <number>."
takeQuestPoints: "Took away <number> <points> from <player>."
@ -719,9 +715,6 @@ questsUnknownAdminCommand: "Unknown command. Type /questsadmin for help."
errorNPCID: 'Error: There is no NPC with ID <number>'
questSaveError: "An error occurred while saving."
questErrorReadingFile: "Error reading <file>."
errorReading: "Error reading <file>, skipping..."
errorReadingSuppress: "Error reading <file>, suppressing further errors."
errorDataFolder: "Error: Unable to read from data folder!"
errorLoading: "Plugin is currently loading. Please try again later!"
unknownError: "An unknown error occurred. See console output."
journalTitle: "Quest Journal"