添加和修改了一些功能,Debug内容更详细
This commit is contained in:
@@ -9,6 +9,8 @@ import top.gtb520.java.minecraft.plugins.disableCreeperBoom.main;
|
|||||||
|
|
||||||
import java.util.Arrays;
|
import java.util.Arrays;
|
||||||
|
|
||||||
|
import static top.gtb520.java.minecraft.plugins.disableCreeperBoom.utils.unity.GetLoggerPlus;
|
||||||
|
|
||||||
public class creeperboom_Commands implements CommandExecutor {
|
public class creeperboom_Commands implements CommandExecutor {
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
@@ -22,13 +24,13 @@ public class creeperboom_Commands implements CommandExecutor {
|
|||||||
// Debug部分
|
// Debug部分
|
||||||
boolean debug = main.instance.getConfig().getBoolean("config.debug", false);
|
boolean debug = main.instance.getConfig().getBoolean("config.debug", false);
|
||||||
if (debug) {
|
if (debug) {
|
||||||
main.getInstance().getLogger().info("========DisableCreeperBoom Command Debug========\n" +
|
// 更美观的打印Debug信息
|
||||||
"sender: " + sender.toString() + "\n" +
|
GetLoggerPlus("========DisableCreeperBoom Command Debug========");
|
||||||
"command: " + command.toString() + "\n" +
|
GetLoggerPlus("sender: " + sender);
|
||||||
"label: " + label + "\n" +
|
GetLoggerPlus("command: " + command);
|
||||||
"args: " + Arrays.toString(args) + "\n" +
|
GetLoggerPlus("label: " + label);
|
||||||
"========DisableCreeperBoom Command Debug========"
|
GetLoggerPlus("args: " + Arrays.toString(args));
|
||||||
);
|
GetLoggerPlus("========DisableCreeperBoom Command Debug========");
|
||||||
}
|
}
|
||||||
|
|
||||||
// 没有参数时显示帮助信息
|
// 没有参数时显示帮助信息
|
||||||
@@ -66,7 +68,7 @@ public class creeperboom_Commands implements CommandExecutor {
|
|||||||
sender.sendMessage(ChatColor.YELLOW + "/" + "creeperboom" + " reload" + ChatColor.WHITE + " - 重新加载配置文件");
|
sender.sendMessage(ChatColor.YELLOW + "/" + "creeperboom" + " reload" + ChatColor.WHITE + " - 重新加载配置文件");
|
||||||
sender.sendMessage(ChatColor.YELLOW + "/" + "creeperboom" + " status" + ChatColor.WHITE + " - 查看当前配置状态");
|
sender.sendMessage(ChatColor.YELLOW + "/" + "creeperboom" + " status" + ChatColor.WHITE + " - 查看当前配置状态");
|
||||||
sender.sendMessage(ChatColor.YELLOW + "/" + "creeperboom" + " help" + ChatColor.WHITE + " - 显示此帮助信息");
|
sender.sendMessage(ChatColor.YELLOW + "/" + "creeperboom" + " help" + ChatColor.WHITE + " - 显示此帮助信息");
|
||||||
sender.sendMessage(ChatColor.GREEN + "====================================");
|
sender.sendMessage(ChatColor.GREEN + "======== DisableCreeperBoom 帮助 ========");
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -75,7 +77,7 @@ public class creeperboom_Commands implements CommandExecutor {
|
|||||||
private void handleReload(CommandSender sender) {
|
private void handleReload(CommandSender sender) {
|
||||||
main.instance.reloadConfig();
|
main.instance.reloadConfig();
|
||||||
sender.sendMessage(ChatColor.GREEN + "配置文件已重新加载!");
|
sender.sendMessage(ChatColor.GREEN + "配置文件已重新加载!");
|
||||||
|
|
||||||
// 如果开启debug模式,输出日志
|
// 如果开启debug模式,输出日志
|
||||||
if (main.instance.getConfig().getBoolean("config.debug", false)) {
|
if (main.instance.getConfig().getBoolean("config.debug", false)) {
|
||||||
main.getInstance().getLogger().info("配置文件已由 " + sender.getName() + " 重新加载");
|
main.getInstance().getLogger().info("配置文件已由 " + sender.getName() + " 重新加载");
|
||||||
@@ -96,6 +98,6 @@ public class creeperboom_Commands implements CommandExecutor {
|
|||||||
sender.sendMessage(ChatColor.WHITE + "阻止爆炸破坏: " + (preventExplode ? ChatColor.GREEN + "是" : ChatColor.RED + "否"));
|
sender.sendMessage(ChatColor.WHITE + "阻止爆炸破坏: " + (preventExplode ? ChatColor.GREEN + "是" : ChatColor.RED + "否"));
|
||||||
sender.sendMessage(ChatColor.WHITE + "阻止爆炸伤害: " + (preventDamage ? ChatColor.GREEN + "是" : ChatColor.RED + "否"));
|
sender.sendMessage(ChatColor.WHITE + "阻止爆炸伤害: " + (preventDamage ? ChatColor.GREEN + "是" : ChatColor.RED + "否"));
|
||||||
sender.sendMessage(ChatColor.WHITE + "调试模式: " + (debug ? ChatColor.GREEN + "开启" : ChatColor.RED + "关闭"));
|
sender.sendMessage(ChatColor.WHITE + "调试模式: " + (debug ? ChatColor.GREEN + "开启" : ChatColor.RED + "关闭"));
|
||||||
sender.sendMessage(ChatColor.GREEN + "====================================");
|
sender.sendMessage(ChatColor.GREEN + "======== DisableCreeperBoom 状态 ========");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -31,7 +31,7 @@ public class CreeperBoom implements Listener {
|
|||||||
if (preventBlockDamage) {
|
if (preventBlockDamage) {
|
||||||
// 取消方块破坏
|
// 取消方块破坏
|
||||||
event.setCancelled(true);
|
event.setCancelled(true);
|
||||||
|
|
||||||
// 如果开启debug模式,输出日志
|
// 如果开启debug模式,输出日志
|
||||||
if (main.instance.getConfig().getBoolean("config.debug", false)) {
|
if (main.instance.getConfig().getBoolean("config.debug", false)) {
|
||||||
main.getInstance().getLogger().info("已阻止苦力怕爆炸破坏方块 at " + event.getLocation());
|
main.getInstance().getLogger().info("已阻止苦力怕爆炸破坏方块 at " + event.getLocation());
|
||||||
@@ -64,7 +64,7 @@ public class CreeperBoom implements Listener {
|
|||||||
if (preventDamage) {
|
if (preventDamage) {
|
||||||
// 取消伤害
|
// 取消伤害
|
||||||
event.setCancelled(true);
|
event.setCancelled(true);
|
||||||
|
|
||||||
// 如果开启debug模式,输出日志
|
// 如果开启debug模式,输出日志
|
||||||
if (main.instance.getConfig().getBoolean("config.debug", false)) {
|
if (main.instance.getConfig().getBoolean("config.debug", false)) {
|
||||||
main.getInstance().getLogger().info("已阻止苦力怕对 " + event.getEntity().getType() + " 造成伤害");
|
main.getInstance().getLogger().info("已阻止苦力怕对 " + event.getEntity().getType() + " 造成伤害");
|
||||||
|
|||||||
@@ -19,13 +19,23 @@ public final class main extends JavaPlugin {
|
|||||||
public static YamlFile_Utils Yaml;
|
public static YamlFile_Utils Yaml;
|
||||||
public static main instance;
|
public static main instance;
|
||||||
private static PluginDescriptionFile descriptionFile;
|
private static PluginDescriptionFile descriptionFile;
|
||||||
|
|
||||||
public static PluginDescriptionFile getDescriptionFile() {
|
public static PluginDescriptionFile getDescriptionFile() {
|
||||||
return descriptionFile;
|
return descriptionFile;
|
||||||
}
|
}
|
||||||
|
|
||||||
public static main getInstance() {
|
public static main getInstance() {
|
||||||
return instance;
|
return instance;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private static void Makedirs(List<File> Folders) {
|
||||||
|
for (File EachFolder : Folders) {
|
||||||
|
if (!EachFolder.exists()) {
|
||||||
|
EachFolder.mkdirs();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void onEnable() {
|
public void onEnable() {
|
||||||
// Plugin startup logic
|
// Plugin startup logic
|
||||||
@@ -47,7 +57,7 @@ public final class main extends JavaPlugin {
|
|||||||
Yaml = new YamlFile_Utils();
|
Yaml = new YamlFile_Utils();
|
||||||
if (!Folder.exists() || !Config_File.exists()) {
|
if (!Folder.exists() || !Config_File.exists()) {
|
||||||
Folder.mkdirs();
|
Folder.mkdirs();
|
||||||
Yaml.saveYamlFile(getDataFolder().getPath(), "config.yml", "config.yml",true);
|
Yaml.saveYamlFile(getDataFolder().getPath(), "config.yml", "config.yml", true);
|
||||||
}
|
}
|
||||||
List<File> Folders = new ArrayList<>();
|
List<File> Folders = new ArrayList<>();
|
||||||
Folders.add(new File(getDataFolder().getPath()));
|
Folders.add(new File(getDataFolder().getPath()));
|
||||||
@@ -66,12 +76,4 @@ public final class main extends JavaPlugin {
|
|||||||
public void onDisable() {
|
public void onDisable() {
|
||||||
// Plugin shutdown logic
|
// Plugin shutdown logic
|
||||||
}
|
}
|
||||||
|
|
||||||
private static void Makedirs(List<File> Folders) {
|
|
||||||
for (File EachFolder : Folders) {
|
|
||||||
if (!EachFolder.exists()) {
|
|
||||||
EachFolder.mkdirs();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -20,7 +20,7 @@ public class YamlFile_Utils {
|
|||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public void saveYmlFile(String FilePath, String FileName, String ResourcePath) {
|
public void saveYmlFile(String FilePath, String FileName, String ResourcePath) {
|
||||||
File Folder = new File(FilePath);
|
File Folder = new File(FilePath);
|
||||||
if (!Folder.exists())
|
if (!Folder.exists())
|
||||||
@@ -28,7 +28,7 @@ public class YamlFile_Utils {
|
|||||||
saveResource(FilePath, ResourcePath, FileName, false);
|
saveResource(FilePath, ResourcePath, FileName, false);
|
||||||
}
|
}
|
||||||
|
|
||||||
public void saveYamlFile(String FilePath, String FileName, String ResourcePath,boolean Replace) {
|
public void saveYamlFile(String FilePath, String FileName, String ResourcePath, boolean Replace) {
|
||||||
File Folder = new File(FilePath);
|
File Folder = new File(FilePath);
|
||||||
if (!Folder.exists())
|
if (!Folder.exists())
|
||||||
Folder.mkdirs();
|
Folder.mkdirs();
|
||||||
|
|||||||
@@ -2,133 +2,22 @@ package top.gtb520.java.minecraft.plugins.disableCreeperBoom.utils;
|
|||||||
|
|
||||||
import org.bukkit.Bukkit;
|
import org.bukkit.Bukkit;
|
||||||
import org.bukkit.ChatColor;
|
import org.bukkit.ChatColor;
|
||||||
import org.bukkit.Location;
|
|
||||||
import org.bukkit.Material;
|
|
||||||
import org.bukkit.command.CommandSender;
|
import org.bukkit.command.CommandSender;
|
||||||
import org.bukkit.entity.Player;
|
|
||||||
import org.bukkit.inventory.Inventory;
|
|
||||||
import org.bukkit.inventory.ItemStack;
|
|
||||||
import org.bukkit.inventory.meta.ItemMeta;
|
|
||||||
import org.bukkit.inventory.meta.SkullMeta;
|
|
||||||
import top.gtb520.java.minecraft.plugins.disableCreeperBoom.main;
|
import top.gtb520.java.minecraft.plugins.disableCreeperBoom.main;
|
||||||
|
|
||||||
import java.util.ArrayList;
|
|
||||||
import java.util.HashMap;
|
|
||||||
import java.util.Objects;
|
|
||||||
|
|
||||||
public class unity {
|
public class unity {
|
||||||
|
|
||||||
public static void SaveAndReloadConfig() {
|
public static void SaveAndReloadConfig() {
|
||||||
main.instance.saveConfig();
|
main.instance.saveConfig();
|
||||||
main.instance.reloadConfig();
|
main.instance.reloadConfig();
|
||||||
}
|
}
|
||||||
public static String ColorMessage(String String1) {
|
|
||||||
return ChatColor.translateAlternateColorCodes('&',String1);
|
public static String ColorMessage(String Message) {
|
||||||
|
return ChatColor.translateAlternateColorCodes('&', Message);
|
||||||
}
|
}
|
||||||
|
|
||||||
public static void GetLoggerPlus(String String1) {
|
public static void GetLoggerPlus(String ConsoleMessage) {
|
||||||
CommandSender Console = Bukkit.getConsoleSender();
|
CommandSender Console = Bukkit.getConsoleSender();
|
||||||
Console.sendMessage(ColorMessage(String1));
|
Console.sendMessage(ColorMessage(ConsoleMessage));
|
||||||
}
|
|
||||||
|
|
||||||
static HashMap<String, Integer> IntTemp = new HashMap<>();
|
|
||||||
|
|
||||||
static HashMap<String, String> StringTemp = new HashMap<>();
|
|
||||||
|
|
||||||
static HashMap<String, Boolean> BooleanTemp = new HashMap<>();
|
|
||||||
|
|
||||||
static HashMap<String, Location> LocationTemp = new HashMap<>();
|
|
||||||
|
|
||||||
public static void SetLocationTempTemp(String String1, Location String2) {
|
|
||||||
LocationTemp.put(String1,String2);
|
|
||||||
}
|
|
||||||
|
|
||||||
public static Location getLocationTempTemp(String String1) {
|
|
||||||
return LocationTemp.get(String1);
|
|
||||||
}
|
|
||||||
|
|
||||||
public static void SetStringTemp(String String1,String String2) {
|
|
||||||
StringTemp.put(String1,String2);
|
|
||||||
}
|
|
||||||
|
|
||||||
public static String getStringTemp(String String1) {
|
|
||||||
return StringTemp.get(String1);
|
|
||||||
}
|
|
||||||
|
|
||||||
public static void SetIntTemp(String String1, Integer Int1) {
|
|
||||||
IntTemp.put(String1,Int1);
|
|
||||||
}
|
|
||||||
|
|
||||||
public static Integer GetIntTemp(String String1) {
|
|
||||||
return IntTemp.get(String1);
|
|
||||||
}
|
|
||||||
|
|
||||||
public static void SetBooleanTemp(String String1, boolean Boolean1) {
|
|
||||||
BooleanTemp.put(String1, Boolean1);
|
|
||||||
}
|
|
||||||
|
|
||||||
public static boolean getBooleanTemp(String String1) {
|
|
||||||
return BooleanTemp.get(String1);
|
|
||||||
}
|
|
||||||
|
|
||||||
public static void KickGui(Player player) {
|
|
||||||
Inventory UI = Bukkit.createInventory(player,45, ColorMessage("&a选择你要踢出的玩家"));
|
|
||||||
|
|
||||||
ItemStack Bk = new ItemStack(Material.ORANGE_STAINED_GLASS_PANE);
|
|
||||||
ItemMeta Bk_Meta = Bk.getItemMeta();
|
|
||||||
Objects.requireNonNull(Bk_Meta).setDisplayName(ColorMessage("&e这只是一个边框"));
|
|
||||||
ArrayList<String> Bk_Lore = new ArrayList<>();
|
|
||||||
Bk_Lore.add(null);
|
|
||||||
Bk_Lore.add(ColorMessage("&e这只是一个边框"));
|
|
||||||
Bk_Meta.setLore(Bk_Lore);
|
|
||||||
Bk.setItemMeta(Bk_Meta);
|
|
||||||
|
|
||||||
for (int i1 = 0 ; i1 <9 ; i1++) {
|
|
||||||
UI.setItem(i1,Bk);
|
|
||||||
}
|
|
||||||
|
|
||||||
for (int i2 = 36 ; i2 <40 ; i2++) {
|
|
||||||
UI.setItem(i2,Bk);
|
|
||||||
}
|
|
||||||
|
|
||||||
for (int i3 = 41 ; i3 <45 ; i3++) {
|
|
||||||
UI.setItem(i3,Bk);
|
|
||||||
}
|
|
||||||
|
|
||||||
UI.setItem(9,Bk);
|
|
||||||
UI.setItem(17,Bk);
|
|
||||||
|
|
||||||
UI.setItem(18,Bk);
|
|
||||||
UI.setItem(26,Bk);
|
|
||||||
|
|
||||||
UI.setItem(27,Bk);
|
|
||||||
UI.setItem(35,Bk);
|
|
||||||
|
|
||||||
ItemStack Gb = new ItemStack(Material.REDSTONE_BLOCK);
|
|
||||||
ItemMeta Gb_Meta = Gb.getItemMeta();
|
|
||||||
Objects.requireNonNull(Gb_Meta).setDisplayName(ColorMessage("&d关闭菜单"));
|
|
||||||
ArrayList<String> Gb_Lore = new ArrayList<>();
|
|
||||||
Gb_Lore.add(null);
|
|
||||||
Gb_Lore.add(ColorMessage("&e点击关闭菜单"));
|
|
||||||
Gb_Meta.setLore(Gb_Lore);
|
|
||||||
Gb.setItemMeta(Gb_Meta);
|
|
||||||
|
|
||||||
UI.setItem(40,Gb);
|
|
||||||
|
|
||||||
ArrayList<Player> players = new ArrayList<>(player.getServer().getOnlinePlayers());
|
|
||||||
for (Player value : players) {
|
|
||||||
ItemStack PlayerHead = new ItemStack(Material.PLAYER_HEAD);
|
|
||||||
SkullMeta PlayerHead_meta = (SkullMeta) PlayerHead.getItemMeta();
|
|
||||||
Objects.requireNonNull(PlayerHead_meta).setOwningPlayer(value);
|
|
||||||
Objects.requireNonNull(PlayerHead_meta).setDisplayName(ChatColor.RESET + value.getDisplayName() + ChatColor.RESET);
|
|
||||||
ArrayList<String> PlayerHead_Lore = new ArrayList<>();
|
|
||||||
PlayerHead_Lore.add(null);
|
|
||||||
PlayerHead_Lore.add(ColorMessage( "&e点击踢出玩家"));
|
|
||||||
PlayerHead_meta.setLore(PlayerHead_Lore);
|
|
||||||
PlayerHead.setItemMeta(PlayerHead_meta);
|
|
||||||
|
|
||||||
UI.addItem(PlayerHead);
|
|
||||||
}
|
|
||||||
player.openInventory(UI);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
BIN
target/DisableCreeperBoom-1.1-SNAPSHOT-shaded.jar
Normal file
BIN
target/DisableCreeperBoom-1.1-SNAPSHOT-shaded.jar
Normal file
Binary file not shown.
Binary file not shown.
@@ -10,7 +10,7 @@ commands:
|
|||||||
creeperboom:
|
creeperboom:
|
||||||
description: 苦力怕爆炸控制插件主命令
|
description: 苦力怕爆炸控制插件主命令
|
||||||
usage: /<command> [reload|status]
|
usage: /<command> [reload|status]
|
||||||
aliases: [cb, creeper]
|
aliases: [cboom, creeper]
|
||||||
permission: disablecreeperboom.admin
|
permission: disablecreeperboom.admin
|
||||||
permission-message: "你没有权限使用此命令"
|
permission-message: "你没有权限使用此命令"
|
||||||
|
|
||||||
|
|||||||
Binary file not shown.
Binary file not shown.
Reference in New Issue
Block a user