测试版
This commit is contained in:
commit
74cc9bac06
40
.gitignore
vendored
Normal file
40
.gitignore
vendored
Normal file
|
@ -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/
|
32
pom.xml
Normal file
32
pom.xml
Normal file
|
@ -0,0 +1,32 @@
|
|||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<project xmlns="http://maven.apache.org/POM/4.0.0"
|
||||
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
|
||||
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
|
||||
<modelVersion>4.0.0</modelVersion>
|
||||
|
||||
<groupId>org.example</groupId>
|
||||
<artifactId>DemonHidePlayer</artifactId>
|
||||
<version>1.0-SNAPSHOT</version>
|
||||
|
||||
<properties>
|
||||
<maven.compiler.source>8</maven.compiler.source>
|
||||
<maven.compiler.target>8</maven.compiler.target>
|
||||
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
|
||||
</properties>
|
||||
|
||||
<repositories>
|
||||
<repository>
|
||||
<id>public-rpg</id>
|
||||
<url>https://repo.aurora-pixels.com/repository/public-rpg/</url>
|
||||
</repository>
|
||||
</repositories>
|
||||
|
||||
<dependencies>
|
||||
<dependency>
|
||||
<groupId>org.spigotmc</groupId>
|
||||
<artifactId>spigot-api</artifactId>
|
||||
<version>1.12.2</version>
|
||||
</dependency>
|
||||
</dependencies>
|
||||
|
||||
</project>
|
102
src/main/java/me/Demon/DemonHidePlayer/Gui.java
Normal file
102
src/main/java/me/Demon/DemonHidePlayer/Gui.java
Normal file
|
@ -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<UUID> 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<String> 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;
|
||||
}
|
||||
}
|
40
src/main/java/me/Demon/DemonHidePlayer/Main.java
Normal file
40
src/main/java/me/Demon/DemonHidePlayer/Main.java
Normal file
|
@ -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;
|
||||
}
|
||||
}
|
3
src/main/resources/config.yml
Normal file
3
src/main/resources/config.yml
Normal file
|
@ -0,0 +1,3 @@
|
|||
menu:
|
||||
button: false
|
||||
command: menu
|
5
src/main/resources/plugin.yml
Normal file
5
src/main/resources/plugin.yml
Normal file
|
@ -0,0 +1,5 @@
|
|||
name: DemonHidePlayer
|
||||
main: me.Demon.DemonHidePlayer.Main
|
||||
version: 1.0.1
|
||||
commands:
|
||||
hideplayer:
|
Loading…
Reference in New Issue
Block a user