From 74cc9bac066ecf53fd9e36a48efcaeb253c75cb3 Mon Sep 17 00:00:00 2001
From: tianyu <32282861@qq.com>
Date: Wed, 24 Jul 2024 06:55:15 +0800
Subject: [PATCH] =?UTF-8?q?=E6=B5=8B=E8=AF=95=E7=89=88?=
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
---
.gitignore | 40 +++++++
pom.xml | 32 ++++++
.../java/me/Demon/DemonHidePlayer/Gui.java | 102 ++++++++++++++++++
.../java/me/Demon/DemonHidePlayer/Main.java | 40 +++++++
src/main/resources/config.yml | 3 +
src/main/resources/plugin.yml | 5 +
6 files changed, 222 insertions(+)
create mode 100644 .gitignore
create mode 100644 pom.xml
create mode 100644 src/main/java/me/Demon/DemonHidePlayer/Gui.java
create mode 100644 src/main/java/me/Demon/DemonHidePlayer/Main.java
create mode 100644 src/main/resources/config.yml
create mode 100644 src/main/resources/plugin.yml
diff --git a/.gitignore b/.gitignore
new file mode 100644
index 0000000..c037f46
--- /dev/null
+++ b/.gitignore
@@ -0,0 +1,40 @@
+target/
+!.mvn/wrapper/maven-wrapper.jar
+!**/src/main/**/target/
+!**/src/test/**/target/
+
+### IntelliJ IDEA ###
+.idea/modules.xml
+.idea/jarRepositories.xml
+.idea/compiler.xml
+.idea/libraries/
+*.iws
+*.iml
+*.ipr
+
+### Eclipse ###
+.apt_generated
+.classpath
+.factorypath
+.project
+.settings
+.springBeans
+.sts4-cache
+
+### NetBeans ###
+/nbproject/private/
+/nbbuild/
+/dist/
+/nbdist/
+/.nb-gradle/
+build/
+!**/src/main/**/build/
+!**/src/test/**/build/
+
+### VS Code ###
+.vscode/
+
+### Mac OS ###
+.DS_Store
+/.idea/
+/out/
diff --git a/pom.xml b/pom.xml
new file mode 100644
index 0000000..88c7a62
--- /dev/null
+++ b/pom.xml
@@ -0,0 +1,32 @@
+
+
+ 4.0.0
+
+ org.example
+ DemonHidePlayer
+ 1.0-SNAPSHOT
+
+
+ 8
+ 8
+ UTF-8
+
+
+
+
+ public-rpg
+ https://repo.aurora-pixels.com/repository/public-rpg/
+
+
+
+
+
+ org.spigotmc
+ spigot-api
+ 1.12.2
+
+
+
+
\ No newline at end of file
diff --git a/src/main/java/me/Demon/DemonHidePlayer/Gui.java b/src/main/java/me/Demon/DemonHidePlayer/Gui.java
new file mode 100644
index 0000000..b213741
--- /dev/null
+++ b/src/main/java/me/Demon/DemonHidePlayer/Gui.java
@@ -0,0 +1,102 @@
+package me.Demon.DemonHidePlayer;
+
+import org.bukkit.Bukkit;
+import org.bukkit.Material;
+import org.bukkit.Sound;
+import org.bukkit.entity.Player;
+import org.bukkit.event.EventHandler;
+import org.bukkit.event.Listener;
+import org.bukkit.event.inventory.InventoryClickEvent;
+import org.bukkit.inventory.Inventory;
+import org.bukkit.inventory.ItemStack;
+import org.bukkit.inventory.meta.ItemMeta;
+import org.bukkit.scheduler.BukkitRunnable;
+
+import java.util.ArrayList;
+import java.util.List;
+import java.util.UUID;
+
+public class Gui implements Listener {
+
+ public static String inv_title = "战争领域 - 玩家隐藏";
+ public static List CmdCooldList = new ArrayList<>();
+
+ @EventHandler
+ public void onclick(InventoryClickEvent e) {
+ Player p = (Player) e.getWhoClicked();
+ if (e.getView().getTitle().equals(inv_title)) {
+ e.setCancelled(true);
+ if (e.getRawSlot() == 2) {
+ if (CmdCooldList.contains(p.getUniqueId())) {
+ p.sendMessage("操作冷却中...");
+ return;
+ }
+ CmdCooldList.add(p.getUniqueId());
+ new BukkitRunnable() {
+ public void run() {
+ CmdCooldList.remove(p.getUniqueId());
+ }
+ }.runTaskLater(Main.plugin, 120L);
+ p.closeInventory();
+ p.playSound(p.getLocation(), Sound.BLOCK_LEVER_CLICK, 1, 2);
+ for (Player player : Bukkit.getOnlinePlayers()) {
+ p.hidePlayer(player);
+ }
+ p.sendMessage(Main.prefix + "玩家隐藏: §a开启");
+ }
+ if (e.getRawSlot() == 6) {
+ if (CmdCooldList.contains(p.getUniqueId())) {
+ p.sendMessage("操作冷却中...");
+ return;
+ }
+ CmdCooldList.add(p.getUniqueId());
+ new BukkitRunnable() {
+ public void run() {
+ CmdCooldList.remove(p.getUniqueId());
+ }
+ }.runTaskLater(Main.plugin, 120L);
+ p.closeInventory();
+ p.playSound(p.getLocation(), Sound.BLOCK_LEVER_CLICK, 1, 2);
+ for (Player player : Bukkit.getOnlinePlayers()) {
+ p.showPlayer(player);
+ }
+ p.sendMessage(Main.prefix + "玩家隐藏: §c关闭");
+ }
+ if (Main.plugin.getConfig().getBoolean("menu.button")) {
+ if (e.getRawSlot() == 8) {
+ p.performCommand(Main.plugin.getConfig().getString("menu.command"));
+ }
+ }
+ }
+ }
+
+
+ public static void OpenGui(Player p) {
+ Inventory inv = Bukkit.createInventory(null, 9, inv_title);
+ inv.setItem(2, Glass_Pane("§a隐藏其他玩家", 5));
+ inv.setItem(6, Glass_Pane("§c显示其他玩家", 14));
+ if (Main.plugin.getConfig().getBoolean("menu.button")) {
+ inv.setItem(8, BackMenu());
+ }
+ p.openInventory(inv);
+ }
+
+ public static ItemStack BackMenu() {
+ ItemStack item = new ItemStack(Material.BOOK);
+ ItemMeta meta = item.getItemMeta();
+ meta.setDisplayName("§a返回选单");
+ List lore = new ArrayList<>();
+ lore.add("§7§l★§7返回上级菜单");
+ meta.setLore(lore);
+ item.setItemMeta(meta);
+ return item;
+ }
+
+ public static ItemStack Glass_Pane(String name, int date) {
+ ItemStack item = new ItemStack(160, 1, (short) date);
+ ItemMeta meta = item.getItemMeta();
+ meta.setDisplayName(name);
+ item.setItemMeta(meta);
+ return item;
+ }
+}
diff --git a/src/main/java/me/Demon/DemonHidePlayer/Main.java b/src/main/java/me/Demon/DemonHidePlayer/Main.java
new file mode 100644
index 0000000..1220914
--- /dev/null
+++ b/src/main/java/me/Demon/DemonHidePlayer/Main.java
@@ -0,0 +1,40 @@
+package me.Demon.DemonHidePlayer;
+
+import org.bukkit.Bukkit;
+import org.bukkit.command.Command;
+import org.bukkit.command.CommandSender;
+import org.bukkit.entity.Player;
+import org.bukkit.plugin.java.JavaPlugin;
+
+public class Main extends JavaPlugin {
+
+ public static Main plugin;
+ public static String prefix = "§7[§6战争领域§7] §f";
+
+ public void onEnable() {
+ plugin = this;
+ saveDefaultConfig();
+ Bukkit.getServer().getPluginManager().registerEvents(new Gui(), plugin);
+ Bukkit.getConsoleSender().sendMessage("§a[玩家隐藏] §f插件成功载入服务器.");
+ }
+
+ public void onDisable() {
+ Bukkit.getConsoleSender().sendMessage("§c[玩家隐藏] §f插件已经从服务器中卸载.");
+ }
+
+ public boolean onCommand(CommandSender sender, Command cmd, String CommandLabel, String[] args) {
+ if (CommandLabel.equalsIgnoreCase("hideplayer")) {
+ if (args.length == 0) {
+ Gui.OpenGui((Player) sender);
+ } else if (args.length == 1) {
+ Player p = Bukkit.getPlayer(args[0]);
+ if (p != null) {
+ Gui.OpenGui(p);
+ } else {
+ sender.sendMessage(prefix + "目标玩家不在线。");
+ }
+ }
+ }
+ return false;
+ }
+}
diff --git a/src/main/resources/config.yml b/src/main/resources/config.yml
new file mode 100644
index 0000000..3480e60
--- /dev/null
+++ b/src/main/resources/config.yml
@@ -0,0 +1,3 @@
+menu:
+ button: false
+ command: menu
\ No newline at end of file
diff --git a/src/main/resources/plugin.yml b/src/main/resources/plugin.yml
new file mode 100644
index 0000000..610c143
--- /dev/null
+++ b/src/main/resources/plugin.yml
@@ -0,0 +1,5 @@
+name: DemonHidePlayer
+main: me.Demon.DemonHidePlayer.Main
+version: 1.0.1
+commands:
+ hideplayer:
\ No newline at end of file