Mod Mcpe

In this there are 1 bug when u do the normal /kill snd click confirm it dosnt kill your characters but it works if used /dialogkill is there an error on command or what

Kodari AI
KodariSep 26 at 4:21 am 1
  1. Replace the unsupported console action on /kill’s confirmation button with the existing [kill] action, which applies the plugin’s normal kill checks.

The /kill GUI confirm was configured with [console] minecraft:kill ..., but the GUI command handler doesn’t support [console], so it silently ignored the kill command. I changed it to [kill], which uses the plugin’s existing kill flow and checks. /dialogkill worked because it kills directly in its confirm callback.

Kodari can make mistakes. Review important code before using.
Files
src
build.gradle
settings.gradle
Code
34 2,550
src/main/java/com/soulshard/simplecore/SoulShardSimpleCore.java
package com.soulshard.simplecore;

import com.soulshard.simplecore.command.CoreCommands;
import com.soulshard.simplecore.data.PlayerDataStore;
import com.soulshard.simplecore.listener.CoreListener;
import com.soulshard.simplecore.service.CoreEconomy;
import com.soulshard.simplecore.service.CoreFiles;
import com.soulshard.simplecore.service.MessageService;
import com.soulshard.simplecore.service.TeleportService;
import com.soulshard.simplecore.service.VaultService;
import me.clip.placeholderapi.PlaceholderAPI;
import net.milkbowl.vault.economy.Economy;
import org.bukkit.Bukkit;
import org.bukkit.OfflinePlayer;
import org.bukkit.command.PluginCommand;
import org.bukkit.entity.Player;
import org.bukkit.plugin.ServicePriority;
import org.bukkit.plugin.java.JavaPlugin;

import java.lang.reflect.Field;
import java.lang.reflect.Method;
import java.util.Locale;
import java.util.Map;
import java.util.UUID;

public final class SoulShardSimpleCore extends JavaPlugin {
    private CoreFiles files;
    private PlayerDataStore playerData;
    private MessageService messages;
    private TeleportService teleports;
    private VaultService vaults;
    private Economy economy;
    private CoreCommands commands;

    @Override
    public void onEnable() {
        files = new CoreFiles(this);
        files.loadAll();
        playerData = new PlayerDataStore(this);
        messages = new MessageService(this);
        teleports = new TeleportService(this);
        vaults = new VaultService(this);
        economy = new CoreEconomy(this);
        getServer().getServicesManager().register(Economy.class, economy, this, ServicePriority.High);
        commands = new CoreCommands(this);
        CoreListener listener = new CoreListener(this);
        getServer().getPluginManager().registerEvents(listener, this);
        registerCommands();
        Bukkit.getScheduler().runTask(this, this::prioritizeKillCommand);
        if (Bukkit.getPluginManager().isPluginEnabled("PlaceholderAPI")) new SoulShardExpansion(this).register();
        long interval = Math.max(1, files.config("phantomtoggle").getLong("phantomtoggle.interval-seconds", 60)) * 20L;
        Bukkit.getScheduler().runTaskTimer(this, () -> {
            for (Player player : Bukkit.getOnlinePlayers()) {
                if (playerData.get(player, "phantomtoggle", true)) player.setStatistic(org.bukkit.Statistic.TIME_SINCE_REST, 0);
            }
        }, interval, interval);
    }

    @Override
    public void onDisable() {
        if (vaults != null) vaults.saveAll();
        if (economy != null) getServer().getServicesManager().unregister(Economy.class, economy);
    }

    private void registerCommands() {
        String[] names = {"bal", "pay", "paymenttoggle", "chainmailtoggle", "mobtoggle", "phantomtoggle", "nightvision", "fly", "doublejump", "find", "ping", "spawn", "setspawn", "warp", "warps", "dialogwarp", "setwarp", "delwarp", "pv", "kill", "dialogkill", "broadcast", "broadcastworld", "announcement", "announcementworld", "soulshardcore", "eco"};
        for (String name : names) {
            PluginCommand command = getCommand(name);
            if (command != null) {
                command.setExecutor(commands);
                command.setTabCompleter(commands);
            }
        }
    }

    @SuppressWarnings("unchecked")
    private void prioritizeKillCommand() {
        PluginCommand kill = getCommand("kill");
        if (kill == null) return;
        try {
            Method accessor = getServer().getClass().getMethod("getCommandMap");
            Object commandMap = accessor.invoke(getServer());
            Field knownCommands = null;
            for (Class<?> type = commandMap.getClass(); type != null && knownCommands == null; type = type.getSuperclass()) {
                try { knownCommands = type.getDeclaredField("knownCommands"); }
                catch (NoSuchFieldException ignored) { }
            }
            if (knownCommands == null) throw new NoSuchFieldException("knownCommands");
            knownCommands.setAccessible(true);
            ((Map<String, org.bukkit.command.Command>) knownCommands.get(commandMap)).put("kill", kill);
        } catch (ReflectiveOperationException | RuntimeException exception) {
            getLogger().warning("Could not give /kill command priority over other plugins: " + exception.getMessage());
        }
    }

    public CoreFiles files() { return files; }
    public PlayerDataStore playerData() { return playerData; }
    public MessageService messages() { return messages; }
    public TeleportService teleports() { return teleports; }
    public VaultService vaults() { return vaults; }
    public Economy economy() { return economy; }

    public OfflinePlayer findPlayer(String name) {
        for (Player online : Bukkit.getOnlinePlayers()) if (online.getName().equalsIgnoreCase(name)) return online;
        for (OfflinePlayer offline : Bukkit.getOfflinePlayers()) {
            if (offline.hasPlayedBefore() && offline.getName() != null && offline.getName().equalsIgnoreCase(name)) return offline;
        }
        return null;
    }

    public String toggleStatus(Player player, String key) {
        boolean enabled = switch (key.toLowerCase(Locale.ROOT)) {
            case "paytoggle" -> playerData.get(player, key, true);
            case "chainmailtoggle" -> playerData.get(player, key, true);
            case "mobtoggle" -> playerData.get(player, key, false);
            case "doublejumptoggle" -> playerData.get(player, key, true);
            case "phantomtoggle" -> playerData.get(player, key, true);
            case "nightvisiontoggle" -> playerData.get(player, key, false);
            default -> false;
        };
        return files.config("settings").getString("placeholder-text." + (enabled ? "enabled" : "disabled"), enabled ? "&aEnabled" : "&cDisabled");
    }
}