feat: 准备 1.3.0 稳定版本
This commit is contained in:
@@ -3,6 +3,7 @@ package cn.infstar.essentialsC.commands;
|
||||
import org.bukkit.Material;
|
||||
import org.bukkit.Sound;
|
||||
import org.bukkit.entity.Player;
|
||||
import org.bukkit.inventory.MenuType;
|
||||
|
||||
public class AnvilCommand extends BaseCommand {
|
||||
|
||||
@@ -12,7 +13,7 @@ public class AnvilCommand extends BaseCommand {
|
||||
|
||||
@Override
|
||||
protected boolean execute(Player player, String[] args) {
|
||||
player.openAnvil(null, true);
|
||||
player.openInventory(MenuType.ANVIL.builder().checkReachable(false).build(player));
|
||||
playBlockShortcutSound(player, Material.ANVIL, Sound.BLOCK_ANVIL_USE);
|
||||
return true;
|
||||
}
|
||||
|
||||
@@ -31,7 +31,7 @@ public class BlocksMenuCommand extends BaseCommand implements Listener {
|
||||
private static final class BlocksMenuHolder implements InventoryHolder {
|
||||
private final Inventory inventory;
|
||||
|
||||
private BlocksMenuHolder(String title) {
|
||||
private BlocksMenuHolder(Component title) {
|
||||
this.inventory = Bukkit.createInventory(this, MENU_SIZE, title);
|
||||
}
|
||||
|
||||
@@ -44,7 +44,6 @@ public class BlocksMenuCommand extends BaseCommand implements Listener {
|
||||
public BlocksMenuCommand() {
|
||||
super("essentialsc.command.blocks");
|
||||
addConfigDefaults();
|
||||
plugin.getServer().getPluginManager().registerEvents(this, plugin);
|
||||
this.blockKey = new NamespacedKey(plugin, "block_key");
|
||||
}
|
||||
|
||||
@@ -55,7 +54,7 @@ public class BlocksMenuCommand extends BaseCommand implements Listener {
|
||||
}
|
||||
|
||||
private void openMenu(Player player) {
|
||||
Inventory menu = new BlocksMenuHolder(getLang().getString("blocks-menu.title")).getInventory();
|
||||
Inventory menu = new BlocksMenuHolder(getLang().getComponent("blocks-menu.title")).getInventory();
|
||||
|
||||
FileConfiguration menuConfig = plugin.getFeatureConfigManager().getBlocksMenuConfig();
|
||||
var sectionsConfig = menuConfig.getConfigurationSection("sections");
|
||||
|
||||
@@ -3,6 +3,7 @@ package cn.infstar.essentialsC.commands;
|
||||
import org.bukkit.Material;
|
||||
import org.bukkit.Sound;
|
||||
import org.bukkit.entity.Player;
|
||||
import org.bukkit.inventory.MenuType;
|
||||
|
||||
public class CartographyTableCommand extends BaseCommand {
|
||||
|
||||
@@ -12,7 +13,7 @@ public class CartographyTableCommand extends BaseCommand {
|
||||
|
||||
@Override
|
||||
protected boolean execute(Player player, String[] args) {
|
||||
player.openCartographyTable(null, true);
|
||||
player.openInventory(MenuType.CARTOGRAPHY_TABLE.builder().checkReachable(false).build(player));
|
||||
playBlockShortcutSound(player, Material.CARTOGRAPHY_TABLE, Sound.ENTITY_VILLAGER_WORK_CARTOGRAPHER);
|
||||
return true;
|
||||
}
|
||||
|
||||
@@ -24,7 +24,7 @@ public class FeedCommand extends BaseCommand {
|
||||
return true;
|
||||
}
|
||||
|
||||
Player target = Bukkit.getPlayer(args[0]);
|
||||
Player target = Bukkit.getPlayerExact(args[0]);
|
||||
if (target == null) {
|
||||
player.sendMessage(getLang().getPrefixedString("messages.player-not-found", Map.of("player", args[0])));
|
||||
return true;
|
||||
|
||||
@@ -10,15 +10,13 @@ public class FlyCommand extends BaseCommand {
|
||||
|
||||
@Override
|
||||
protected boolean execute(Player player, String[] args) {
|
||||
boolean currentFlyState = player.getAllowFlight();
|
||||
boolean currentFlyState = plugin.getPlayerStateManager().isFlyEnabled(player);
|
||||
|
||||
if (currentFlyState) {
|
||||
player.setAllowFlight(false);
|
||||
player.setFlying(false);
|
||||
plugin.getPlayerStateManager().disableFly(player);
|
||||
player.sendMessage(getLang().getPrefixedString("messages.fly-disabled"));
|
||||
} else {
|
||||
player.setAllowFlight(true);
|
||||
player.setFlying(true);
|
||||
plugin.getPlayerStateManager().enableFly(player);
|
||||
player.sendMessage(getLang().getPrefixedString("messages.fly-enabled"));
|
||||
}
|
||||
|
||||
|
||||
@@ -1,17 +1,12 @@
|
||||
package cn.infstar.essentialsC.commands;
|
||||
|
||||
import org.bukkit.NamespacedKey;
|
||||
import org.bukkit.Sound;
|
||||
import org.bukkit.entity.Player;
|
||||
import org.bukkit.persistence.PersistentDataType;
|
||||
|
||||
public class GlowCommand extends BaseCommand {
|
||||
|
||||
private final NamespacedKey enabledKey;
|
||||
|
||||
public GlowCommand() {
|
||||
super("essentialsc.command.glow");
|
||||
this.enabledKey = new NamespacedKey(plugin, "glow_enabled");
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -24,15 +19,11 @@ public class GlowCommand extends BaseCommand {
|
||||
}
|
||||
|
||||
if (targetState) {
|
||||
player.setGlowing(true);
|
||||
player.getPersistentDataContainer().set(enabledKey, PersistentDataType.BYTE, (byte) 1);
|
||||
plugin.getPlayerStateManager().enableGlow(player);
|
||||
playShortcutSound(player, Sound.BLOCK_AMETHYST_BLOCK_CHIME);
|
||||
player.sendMessage(getLang().getPrefixedString("messages.glow-enabled"));
|
||||
} else {
|
||||
if (currentState) {
|
||||
player.setGlowing(false);
|
||||
player.getPersistentDataContainer().remove(enabledKey);
|
||||
}
|
||||
plugin.getPlayerStateManager().disableGlow(player);
|
||||
playShortcutSound(player, Sound.BLOCK_AMETHYST_CLUSTER_FALL);
|
||||
player.sendMessage(getLang().getPrefixedString("messages.glow-disabled"));
|
||||
}
|
||||
@@ -53,12 +44,6 @@ public class GlowCommand extends BaseCommand {
|
||||
}
|
||||
|
||||
private boolean isPluginGlowEnabled(Player player) {
|
||||
Byte value = player.getPersistentDataContainer().get(enabledKey, PersistentDataType.BYTE);
|
||||
boolean enabled = value != null && value == (byte) 1;
|
||||
if (enabled && !player.isGlowing()) {
|
||||
player.getPersistentDataContainer().remove(enabledKey);
|
||||
return false;
|
||||
}
|
||||
return enabled;
|
||||
return plugin.getPlayerStateManager().isGlowEnabled(player);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -3,6 +3,7 @@ package cn.infstar.essentialsC.commands;
|
||||
import org.bukkit.Material;
|
||||
import org.bukkit.Sound;
|
||||
import org.bukkit.entity.Player;
|
||||
import org.bukkit.inventory.MenuType;
|
||||
|
||||
public class GrindstoneCommand extends BaseCommand {
|
||||
|
||||
@@ -12,7 +13,7 @@ public class GrindstoneCommand extends BaseCommand {
|
||||
|
||||
@Override
|
||||
protected boolean execute(Player player, String[] args) {
|
||||
player.openGrindstone(null, true);
|
||||
player.openInventory(MenuType.GRINDSTONE.builder().checkReachable(false).build(player));
|
||||
playBlockShortcutSound(player, Material.GRINDSTONE, Sound.BLOCK_GRINDSTONE_USE);
|
||||
return true;
|
||||
}
|
||||
|
||||
@@ -26,7 +26,7 @@ public class HealCommand extends BaseCommand {
|
||||
return true;
|
||||
}
|
||||
|
||||
Player target = Bukkit.getPlayer(args[0]);
|
||||
Player target = Bukkit.getPlayerExact(args[0]);
|
||||
if (target == null) {
|
||||
player.sendMessage(getLang().getPrefixedString("messages.player-not-found", Map.of("player", args[0])));
|
||||
return true;
|
||||
|
||||
@@ -43,9 +43,8 @@ public class HelpCommand extends BaseCommand implements TabCompleter {
|
||||
sendNoPermission(sender, "essentialsc.command.reload");
|
||||
return true;
|
||||
}
|
||||
plugin.reloadConfig();
|
||||
EssentialsC.getLangManager().reload();
|
||||
plugin.getFeatureConfigManager().reload();
|
||||
EssentialsC.getLangManager().reload();
|
||||
plugin.getModuleManager().reload();
|
||||
CommandRegistry.clearInitializationFailures();
|
||||
plugin.reloadRuntimeModules();
|
||||
@@ -65,9 +64,8 @@ public class HelpCommand extends BaseCommand implements TabCompleter {
|
||||
sendNoPermission(sender, "essentialsc.command.reload");
|
||||
return true;
|
||||
}
|
||||
plugin.reloadConfig();
|
||||
EssentialsC.getLangManager().reload();
|
||||
plugin.getFeatureConfigManager().reload();
|
||||
EssentialsC.getLangManager().reload();
|
||||
plugin.getModuleManager().reload();
|
||||
CommandRegistry.clearInitializationFailures();
|
||||
plugin.reloadRuntimeModules();
|
||||
@@ -95,7 +93,7 @@ public class HelpCommand extends BaseCommand implements TabCompleter {
|
||||
|
||||
if (subCommand.equals("version") || subCommand.equals("v")) {
|
||||
player.sendMessage(getLang().getPrefixedString("messages.version",
|
||||
Map.of("version", plugin.getDescription().getVersion())));
|
||||
Map.of("version", plugin.getPluginMeta().getVersion())));
|
||||
player.sendMessage(getLang().getPrefixedString("messages.paper-version",
|
||||
Map.of("version", Bukkit.getVersion())));
|
||||
return true;
|
||||
@@ -108,7 +106,7 @@ public class HelpCommand extends BaseCommand implements TabCompleter {
|
||||
}
|
||||
|
||||
LangManager lang = getLang();
|
||||
String version = plugin.getDescription().getVersion();
|
||||
String version = plugin.getPluginMeta().getVersion();
|
||||
|
||||
sendPrefixed(player, lang.getString("help.title"));
|
||||
sendPrefixed(player, lang.getString("help.version", Map.of("version", version)));
|
||||
|
||||
@@ -3,6 +3,7 @@ package cn.infstar.essentialsC.commands;
|
||||
import org.bukkit.Material;
|
||||
import org.bukkit.Sound;
|
||||
import org.bukkit.entity.Player;
|
||||
import org.bukkit.inventory.MenuType;
|
||||
|
||||
public class LoomCommand extends BaseCommand {
|
||||
|
||||
@@ -12,7 +13,7 @@ public class LoomCommand extends BaseCommand {
|
||||
|
||||
@Override
|
||||
protected boolean execute(Player player, String[] args) {
|
||||
player.openLoom(null, true);
|
||||
player.openInventory(MenuType.LOOM.builder().checkReachable(false).build(player));
|
||||
playBlockShortcutSound(player, Material.LOOM, Sound.UI_LOOM_SELECT_PATTERN);
|
||||
return true;
|
||||
}
|
||||
|
||||
@@ -22,7 +22,7 @@ public class MobDropCommand extends BaseCommand {
|
||||
public static final class MobDropMenuHolder implements InventoryHolder {
|
||||
private final Inventory inventory;
|
||||
|
||||
public MobDropMenuHolder(String title) {
|
||||
public MobDropMenuHolder(Component title) {
|
||||
this.inventory = Bukkit.createInventory(this, MENU_SIZE, title);
|
||||
}
|
||||
|
||||
@@ -49,7 +49,7 @@ public class MobDropCommand extends BaseCommand {
|
||||
? "mobdrops-menu.status.enabled"
|
||||
: "mobdrops-menu.status.disabled");
|
||||
|
||||
Inventory menu = new MobDropMenuHolder(lang.getString("mobdrops-menu.title")).getInventory();
|
||||
Inventory menu = new MobDropMenuHolder(lang.getComponent("mobdrops-menu.title")).getInventory();
|
||||
|
||||
ItemStack endermanItem = new ItemStack(Material.ENDER_PEARL);
|
||||
ItemMeta endermanMeta = endermanItem.getItemMeta();
|
||||
|
||||
@@ -1,19 +1,12 @@
|
||||
package cn.infstar.essentialsC.commands;
|
||||
|
||||
import org.bukkit.NamespacedKey;
|
||||
import org.bukkit.Sound;
|
||||
import org.bukkit.entity.Player;
|
||||
import org.bukkit.potion.PotionEffect;
|
||||
import org.bukkit.potion.PotionEffectType;
|
||||
import org.bukkit.persistence.PersistentDataType;
|
||||
|
||||
public class NightVisionCommand extends BaseCommand {
|
||||
|
||||
private final NamespacedKey enabledKey;
|
||||
|
||||
public NightVisionCommand() {
|
||||
super("essentialsc.command.nightvision");
|
||||
this.enabledKey = new NamespacedKey(plugin, "nightvision_enabled");
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -26,15 +19,11 @@ public class NightVisionCommand extends BaseCommand {
|
||||
}
|
||||
|
||||
if (targetState) {
|
||||
player.addPotionEffect(new PotionEffect(PotionEffectType.NIGHT_VISION, Integer.MAX_VALUE, 0, false, false, false));
|
||||
player.getPersistentDataContainer().set(enabledKey, PersistentDataType.BYTE, (byte) 1);
|
||||
plugin.getPlayerStateManager().enableNightVision(player);
|
||||
playShortcutSound(player, Sound.BLOCK_BEACON_POWER_SELECT);
|
||||
player.sendMessage(getLang().getPrefixedString("messages.nightvision-enabled"));
|
||||
} else {
|
||||
if (currentState) {
|
||||
player.removePotionEffect(PotionEffectType.NIGHT_VISION);
|
||||
player.getPersistentDataContainer().remove(enabledKey);
|
||||
}
|
||||
plugin.getPlayerStateManager().disableNightVision(player);
|
||||
playShortcutSound(player, Sound.BLOCK_BEACON_DEACTIVATE);
|
||||
player.sendMessage(getLang().getPrefixedString("messages.nightvision-disabled"));
|
||||
}
|
||||
@@ -55,12 +44,6 @@ public class NightVisionCommand extends BaseCommand {
|
||||
}
|
||||
|
||||
private boolean isPluginNightVisionEnabled(Player player) {
|
||||
Byte value = player.getPersistentDataContainer().get(enabledKey, PersistentDataType.BYTE);
|
||||
boolean enabled = value != null && value == (byte) 1;
|
||||
if (enabled && !player.hasPotionEffect(PotionEffectType.NIGHT_VISION)) {
|
||||
player.getPersistentDataContainer().remove(enabledKey);
|
||||
return false;
|
||||
}
|
||||
return enabled;
|
||||
return plugin.getPlayerStateManager().isNightVisionEnabled(player);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -3,6 +3,7 @@ package cn.infstar.essentialsC.commands;
|
||||
import org.bukkit.Material;
|
||||
import org.bukkit.Sound;
|
||||
import org.bukkit.entity.Player;
|
||||
import org.bukkit.inventory.MenuType;
|
||||
|
||||
public class SmithingTableCommand extends BaseCommand {
|
||||
|
||||
@@ -12,7 +13,7 @@ public class SmithingTableCommand extends BaseCommand {
|
||||
|
||||
@Override
|
||||
protected boolean execute(Player player, String[] args) {
|
||||
player.openSmithingTable(null, true);
|
||||
player.openInventory(MenuType.SMITHING.builder().checkReachable(false).build(player));
|
||||
playBlockShortcutSound(player, Material.SMITHING_TABLE, Sound.BLOCK_SMITHING_TABLE_USE);
|
||||
return true;
|
||||
}
|
||||
|
||||
@@ -3,6 +3,7 @@ package cn.infstar.essentialsC.commands;
|
||||
import org.bukkit.Material;
|
||||
import org.bukkit.Sound;
|
||||
import org.bukkit.entity.Player;
|
||||
import org.bukkit.inventory.MenuType;
|
||||
|
||||
public class StonecutterCommand extends BaseCommand {
|
||||
|
||||
@@ -12,7 +13,7 @@ public class StonecutterCommand extends BaseCommand {
|
||||
|
||||
@Override
|
||||
protected boolean execute(Player player, String[] args) {
|
||||
player.openStonecutter(null, true);
|
||||
player.openInventory(MenuType.STONECUTTER.builder().checkReachable(false).build(player));
|
||||
playBlockShortcutSound(player, Material.STONECUTTER, Sound.UI_STONECUTTER_SELECT_RECIPE);
|
||||
return true;
|
||||
}
|
||||
|
||||
@@ -3,10 +3,12 @@ package cn.infstar.essentialsC.commands;
|
||||
import cn.infstar.essentialsC.EssentialsC;
|
||||
import cn.infstar.essentialsC.util.AtomicYamlWriter;
|
||||
import org.bukkit.configuration.file.FileConfiguration;
|
||||
import org.bukkit.configuration.InvalidConfigurationException;
|
||||
import org.bukkit.configuration.file.YamlConfiguration;
|
||||
import org.bukkit.entity.Player;
|
||||
|
||||
import java.io.File;
|
||||
import java.io.IOException;
|
||||
import java.util.HashSet;
|
||||
import java.util.Set;
|
||||
import java.util.UUID;
|
||||
@@ -53,7 +55,13 @@ public class VanishCommand extends BaseCommand {
|
||||
if (!stateFile.exists()) {
|
||||
return;
|
||||
}
|
||||
FileConfiguration state = YamlConfiguration.loadConfiguration(stateFile);
|
||||
YamlConfiguration state = new YamlConfiguration();
|
||||
try {
|
||||
state.load(stateFile);
|
||||
} catch (IOException | InvalidConfigurationException exception) {
|
||||
plugin.getLogger().severe("加载 vanished-players.yml 失败: " + exception.getMessage());
|
||||
throw new IllegalStateException("无法加载 vanished-players.yml,请修复文件格式后重试。", exception);
|
||||
}
|
||||
for (String value : state.getStringList("players")) {
|
||||
try {
|
||||
vanishedPlayers.add(UUID.fromString(value));
|
||||
@@ -74,15 +82,22 @@ public class VanishCommand extends BaseCommand {
|
||||
}
|
||||
}
|
||||
|
||||
public static void restoreVisibility(EssentialsC plugin, Player player, boolean notify) {
|
||||
public static boolean restoreVisibility(EssentialsC plugin, Player player, boolean notify) {
|
||||
if (!vanishedPlayers.remove(player.getUniqueId())) {
|
||||
return;
|
||||
return true;
|
||||
}
|
||||
if (!saveState(plugin)) {
|
||||
vanishedPlayers.add(player.getUniqueId());
|
||||
if (notify) {
|
||||
player.sendMessage(EssentialsC.getLangManager().getPrefixedString("messages.vanish-save-failed"));
|
||||
}
|
||||
return false;
|
||||
}
|
||||
showPlayerToAll(plugin, player);
|
||||
saveState(plugin);
|
||||
if (notify) {
|
||||
player.sendMessage(EssentialsC.getLangManager().getPrefixedString("messages.vanish-permission-removed"));
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
public static void applyHiddenState(EssentialsC plugin, Player player) {
|
||||
|
||||
@@ -3,6 +3,7 @@ package cn.infstar.essentialsC.commands;
|
||||
import org.bukkit.Material;
|
||||
import org.bukkit.Sound;
|
||||
import org.bukkit.entity.Player;
|
||||
import org.bukkit.inventory.MenuType;
|
||||
|
||||
public class WorkbenchCommand extends BaseCommand {
|
||||
|
||||
@@ -12,7 +13,7 @@ public class WorkbenchCommand extends BaseCommand {
|
||||
|
||||
@Override
|
||||
protected boolean execute(Player player, String[] args) {
|
||||
player.openWorkbench(null, true);
|
||||
player.openInventory(MenuType.CRAFTING.builder().checkReachable(false).build(player));
|
||||
playBlockShortcutSound(player, Material.CRAFTING_TABLE, Sound.UI_BUTTON_CLICK);
|
||||
return true;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user