测试版

This commit is contained in:
tianyu 2024-07-25 04:39:47 +08:00
commit 6526ee66e1
13 changed files with 559 additions and 0 deletions

38
.gitignore vendored Normal file
View File

@ -0,0 +1,38 @@
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

37
pom.xml Normal file
View File

@ -0,0 +1,37 @@
<?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>DemonAntiEvent</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>
<dependency>
<groupId>me.Demon.DemonPlugin</groupId>
<artifactId>DemonAPI</artifactId>
<version>1.2.0</version>
</dependency>
</dependencies>
</project>

View File

@ -0,0 +1,34 @@
package me.Demon.DemonAntiEvent.Listener;
import org.bukkit.Material;
import org.bukkit.entity.Player;
import org.bukkit.event.EventHandler;
import org.bukkit.event.Listener;
import org.bukkit.event.block.BlockBreakEvent;
import org.bukkit.event.player.PlayerInteractEvent;
public class AntiChangeSpawn implements Listener {
@EventHandler
public void onTryChangeSpanwerType(PlayerInteractEvent e) {
Player p = e.getPlayer();
if (e.isCancelled()) {return;}
if (!e.hasItem() || !e.hasBlock()) {return;}
if (e.getClickedBlock().getType() == Material.MOB_SPAWNER) {
e.setCancelled(true);
p.sendMessage("§7[§6财产保护§7] §f目标方块已受财产保护禁止修改.");
}
}
@EventHandler
public void AntiBreakMob_Spawner(BlockBreakEvent e) {
Player p = e.getPlayer();
if (e.isCancelled()) {return;}
if (!p.isOp()) {return;}
if(e.getBlock().getType() == Material.MOB_SPAWNER){
e.setCancelled(true);
p.sendMessage("§7[§6财产保护§7] §f目标方块已受财产保护无法拆除.");
}
}
}

View File

@ -0,0 +1,22 @@
package me.Demon.DemonAntiEvent.Listener;
import org.bukkit.entity.Player;
import org.bukkit.event.EventHandler;
import org.bukkit.event.EventPriority;
import org.bukkit.event.Listener;
import org.bukkit.event.player.PlayerCommandPreprocessEvent;
import java.util.List;
public class AntiCommand implements Listener {
@EventHandler(priority= EventPriority.HIGHEST)
public void onCommand(PlayerCommandPreprocessEvent e) {
Player p = e.getPlayer();
if(p.isOp()){return;}
String commands = e.getMessage().toLowerCase();
if(commands.contains("mv") || commands.contains("multiverse-core:mv") || commands.contains("multiverse-core")){
e.setCancelled(true);
p.sendMessage("§7[§6战争领域§7] §f该命令已被管理员禁止.");
}
}
}

View File

@ -0,0 +1,31 @@
package me.Demon.DemonAntiEvent.Listener;
import org.bukkit.Material;
import org.bukkit.event.EventHandler;
import org.bukkit.event.Listener;
import org.bukkit.event.inventory.PrepareItemCraftEvent;
import org.bukkit.inventory.ItemStack;
public class AntiCraft implements Listener {
@EventHandler
public void onClick(PrepareItemCraftEvent e) {
if ((e.getRecipe() == null) || (e.getRecipe().getResult() == null)) {
return;
}
if (CheckISBlock(e.getRecipe().getResult())) {
ItemStack item = e.getRecipe().getResult();
item.setAmount(2);
e.getInventory().setItem(0, item);
}
}
/*判断合成物品的Type类型是否存在禁止合成列表中*/
public static boolean CheckISBlock(ItemStack item){
if(item.getType() == Material.DIRT){
if(item.getDurability() == 1) {
return true;
}
}
return false;
}
}

View File

@ -0,0 +1,30 @@
package me.Demon.DemonAntiEvent.Listener;
import me.Demon.DemonAntiEvent.Main;
import me.Demon.DemonPlugin.DemonAPI;
import org.bukkit.Material;
import org.bukkit.Sound;
import org.bukkit.entity.Player;
import org.bukkit.event.EventHandler;
import org.bukkit.event.EventPriority;
import org.bukkit.event.Listener;
import org.bukkit.event.block.Action;
import org.bukkit.event.player.PlayerInteractEvent;
import org.bukkit.inventory.ItemStack;
public class AntiEgg implements Listener {
@EventHandler
public void onUseEgg(PlayerInteractEvent e) {
Player p = e.getPlayer();
if(!p.getWorld().getName().contains("ASkyBlock")){
ItemStack item = p.getItemInHand();
if(!DemonAPI.itemIsNull(item) && item.getType() == Material.EGG){
e.setCancelled(true);
p.sendMessage( "§7[§6战争领域§7] §f怎么能把哥哥的蛋乱扔呢" );
p.playSound(p.getLocation(), Sound.ENTITY_BLAZE_DEATH, 0.5F, 1.5F);
}
}
}
}

View File

@ -0,0 +1,92 @@
package me.Demon.DemonAntiEvent.Listener;
import me.Demon.DemonAntiEvent.Main;
import me.Demon.DemonPlugin.DemonAPI;
import me.Demon.DemonPlugin.Util.ItemNameUtil;
import org.bukkit.Sound;
import org.bukkit.enchantments.Enchantment;
import org.bukkit.entity.Player;
import org.bukkit.event.EventHandler;
import org.bukkit.event.Listener;
import org.bukkit.event.player.PlayerInteractEvent;
import org.bukkit.inventory.ItemFlag;
import org.bukkit.inventory.ItemStack;
import org.bukkit.inventory.meta.ItemMeta;
import java.util.ArrayList;
import java.util.List;
public class AntiEnchant implements Listener {
public static String getItemName(ItemStack item) {
ItemStack items = item.clone();
return ItemNameUtil.getChineseName(items);
}
@EventHandler
public void onPlayerUse(PlayerInteractEvent e) {
Player p = e.getPlayer();
ItemStack item = p.getItemInHand();
if (!DemonAPI.itemIsNull(item) && DemonAPI.itemIsName(item)) {
String name = item.getType().name();
boolean butt = false;
if (name.contains("_AXE")) {
butt = true;
} else if (name.contains("_SPADE")) {
butt = true;
} else if (name.contains("_PICKAXE")) {
butt = true;
}
if (butt) {
if (item.getEnchantments().size() >= 1) {
ItemMeta meta = item.getItemMeta();
if (!meta.spigot().isUnbreakable()) {
item.setDurability((short) 0);
meta.spigot().setUnbreakable(true);
}
String itemName = getItemName(item);
meta.setDisplayName("§7[§f普通§7]§r" + itemName);
List<String> lore = new ArrayList<>();
lore.add("§7§0§1§r§7§7耐久§0§1§r§7§f§l: §0§2§r§a" + 512 + "§7/§a" + 512);
meta.setLore(lore);
meta.addItemFlags(ItemFlag.HIDE_UNBREAKABLE);
meta.addItemFlags(ItemFlag.HIDE_ATTRIBUTES);
item.setItemMeta(meta);
for (Enchantment enchant : item.getEnchantments().keySet()) {
if (enchant.getId() == 34) {
item.removeEnchantment(enchant);
}
}
p.playSound(p.getLocation(), Sound.ENTITY_EXPERIENCE_ORB_PICKUP, 0.5F, 1.5F);
p.sendMessage("§7[§6战争领域§7] §f您的工具已完成RPG属性升级.");
}
}
}
}
@EventHandler
public void onUnbreakable(PlayerInteractEvent e) {
Player p = e.getPlayer();
ItemStack item = p.getItemInHand();
if (!DemonAPI.itemIsNull(item) && !DemonAPI.itemIsLore(item)) {
ItemMeta meta = item.getItemMeta();
if (meta.getDisplayName().contains(":")) {
String itemName = getItemName(item);
meta.setDisplayName("§7[§f普通§7]§r" + itemName);
if (!meta.spigot().isUnbreakable()) {
item.setDurability((short) 0);
meta.spigot().setUnbreakable(true);
}
meta.addItemFlags(ItemFlag.HIDE_UNBREAKABLE);
item.setItemMeta(meta);
for (Enchantment enchant : item.getEnchantments().keySet()) {
if (enchant.getId() == 34) {
item.removeEnchantment(enchant);
}
}
p.playSound(p.getLocation(), Sound.ENTITY_EXPERIENCE_ORB_PICKUP, 0.5F, 1.5F);
p.sendMessage("§7[§6战争领域§7] §f您的工具已完成RPG属性升级.");
}
}
}
}

View File

@ -0,0 +1,86 @@
package me.Demon.DemonAntiEvent.Listener;
import me.Demon.DemonAntiEvent.Main;
import me.jet315.minions.events.MinerBlockBreakEvent;
import org.bukkit.Bukkit;
import org.bukkit.entity.Player;
import org.bukkit.event.EventHandler;
import org.bukkit.event.EventPriority;
import org.bukkit.event.Listener;
import org.bukkit.event.block.BlockBreakEvent;
import org.bukkit.event.block.BlockPlaceEvent;
import org.bukkit.event.inventory.InventoryClickEvent;
import org.bukkit.event.player.PlayerCommandPreprocessEvent;
import org.bukkit.event.player.PlayerInteractEvent;
import org.bukkit.event.player.PlayerJoinEvent;
import java.util.ArrayList;
import java.util.List;
import java.util.UUID;
public class AntiLagLimit implements Listener {
@EventHandler
public void onmini(MinerBlockBreakEvent e){
e.setCancelled(true);
}
public static List<UUID> lockPlayer = new ArrayList<>();
@EventHandler(priority= EventPriority.HIGHEST)
public void onJoin(PlayerJoinEvent e) {
Player p = e.getPlayer();
lockPlayer.add(p.getUniqueId());
Bukkit.getScheduler().runTaskLater(Main.plugin, (Runnable) new Runnable() {
@Override
public void run() {
lockPlayer.remove(p.getUniqueId());
if(p.isOp()) {
p.sendMessage("§c[系统] §a数据已读取完成.");
}
}
}, (long) 60L);
}
@EventHandler(priority= EventPriority.HIGHEST)
public void onCommand(PlayerCommandPreprocessEvent e) {
Player p = e.getPlayer();
if(lockPlayer.contains(p.getUniqueId())){
e.setCancelled(true);
}
}
@EventHandler(priority= EventPriority.HIGHEST)
public void onClick(InventoryClickEvent e) {
Player p = (Player) e.getWhoClicked();
if(lockPlayer.contains(p.getUniqueId())){
e.setCancelled(true);
}
}
@EventHandler(priority= EventPriority.HIGHEST)
public void onInteract(PlayerInteractEvent e) {
Player p = e.getPlayer();
if(lockPlayer.contains(p.getUniqueId())){
e.setCancelled(true);
}
}
@EventHandler(priority= EventPriority.HIGHEST)
public void onBlockp(BlockPlaceEvent e) {
Player p = e.getPlayer();
if(lockPlayer.contains(p.getUniqueId())){
e.setCancelled(true);
}
}
@EventHandler(priority= EventPriority.HIGHEST)
public void onBlockb(BlockBreakEvent e) {
Player p = e.getPlayer();
if(lockPlayer.contains(p.getUniqueId())){
e.setCancelled(true);
}
}
}

View File

@ -0,0 +1,72 @@
package me.Demon.DemonAntiEvent.Listener;
import me.Demon.DemonAntiEvent.Main;
import org.bukkit.Bukkit;
import org.bukkit.Location;
import org.bukkit.Material;
import org.bukkit.Sound;
import org.bukkit.block.Block;
import org.bukkit.entity.Entity;
import org.bukkit.entity.EntityType;
import org.bukkit.entity.Player;
import org.bukkit.event.EventHandler;
import org.bukkit.event.Listener;
import org.bukkit.event.block.BlockPlaceEvent;
import org.bukkit.event.entity.EntitySpawnEvent;
import org.bukkit.event.player.PlayerInteractEvent;
import org.bukkit.inventory.ItemStack;
public class AntiRedStone implements Listener {
@EventHandler
public void onplace(BlockPlaceEvent e){
Player p = e.getPlayer();
Block block = e.getBlock();
Location location = block.getLocation();
if(location.getWorld().getName().equalsIgnoreCase("ASkyBlock_nether")){
if(isRedStone(block.getType())){
e.setCancelled(true);
p.sendMessage( "§7[§6战争领域§7] §f因有玩家在该领域建造红石机造成卡服,故已停止建设红石项目." );
p.playSound(p.getLocation(), Sound.ENTITY_BLAZE_DEATH, 0.5F, 1.5F);
}
}
}
public boolean isRedStone(Material material){
if(material == Material.REDSTONE_BLOCK){
return true;
}
if(material == Material.PISTON_BASE){
return true;
}
if(material == Material.PISTON_STICKY_BASE){
return true;
}
if(material == Material.REDSTONE_COMPARATOR_OFF){
return true;
}
if(material == Material.REDSTONE_TORCH_ON){
return true;
}
if(material == Material.DIODE_BLOCK_OFF){
return true;
}
return false;
}
/*@EventHandler
public void onEntitySpawn(EntitySpawnEvent event) {
if (event.getEntityType() == EntityType.PIG_ZOMBIE) {
int maxSpawnCount = 3;
int currentSpawnCount = 0;
for (Entity entity : event.getLocation().getChunk().getEntities()) {
if (entity.getType() == EntityType.PIG_ZOMBIE) {
currentSpawnCount++;
}
}
if (currentSpawnCount >= maxSpawnCount) {
event.setCancelled(true);
}
}
}*/
}

View File

@ -0,0 +1,33 @@
package me.Demon.DemonAntiEvent.Listener;
import org.bukkit.Material;
import org.bukkit.Sound;
import org.bukkit.entity.Player;
import org.bukkit.event.EventHandler;
import org.bukkit.event.EventPriority;
import org.bukkit.event.Listener;
import org.bukkit.event.block.Action;
import org.bukkit.event.player.PlayerInteractEvent;
public class AntiUse implements Listener {
@EventHandler(ignoreCancelled = true, priority = EventPriority.LOWEST)
public void onUseBed(PlayerInteractEvent e) {
Player p = e.getPlayer();
if (e.getAction() == Action.RIGHT_CLICK_BLOCK) {
if (e.getClickedBlock().getType() == Material.ANVIL) {
e.setCancelled(true);
p.sendTitle("§7[§6属性保护§7] §f", "§f服务器禁止使用铁砧");
p.sendMessage("§7[§6属性保护§7] §f因担心RPG装备会被原版修改属性导致失效所以禁止");
p.playSound(p.getLocation(), Sound.ENTITY_BLAZE_DEATH, 0.5F, 1.5F);
}
if (e.getClickedBlock().getType() == Material.ENCHANTMENT_TABLE) {
e.setCancelled( true );
p.sendTitle( "§7[§6属性保护§7] §f", "§f服务器禁止使用附魔台" );
p.sendMessage( "§7[§6属性保护§7] §f因担心RPG装备会特殊的附魔导致失效所以禁止" );
p.playSound(p.getLocation(), Sound.ENTITY_BLAZE_DEATH, 0.5F, 1.5F);
}
}
}
}

View File

@ -0,0 +1,26 @@
package me.Demon.DemonAntiEvent.Listener;
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.player.PlayerMoveEvent;
import org.bukkit.util.Vector;
public class JumpPlate implements Listener {
@EventHandler
public void onJumpPlate(PlayerMoveEvent e) {
Player p = e.getPlayer();
if(p.getWorld().getName().equals("kuangqu")) {
if (e.getPlayer().getLocation().getBlock().getType() == Material.GOLD_PLATE) {
Vector vector = e.getPlayer().getLocation().getDirection().multiply(1.5D).setY(1.0D);
e.getPlayer().setVelocity(vector);
e.getPlayer().playSound(e.getPlayer().getLocation(), Sound.BLOCK_PISTON_EXTEND, 1.0F, 1.0F);
e.getPlayer().setFallDistance(-9999.0F);
}
}
}
}

View File

@ -0,0 +1,53 @@
package me.Demon.DemonAntiEvent;
import me.Demon.DemonAntiEvent.Listener.*;
import org.bukkit.Bukkit;
import org.bukkit.World;
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;
@Override
public void onEnable() {
plugin = this;
Bukkit.getConsoleSender().sendMessage("§c[生存禁止] §f事件注册-命令禁止");
Bukkit.getPluginManager().registerEvents(new AntiCommand(), plugin);
Bukkit.getConsoleSender().sendMessage("§c[生存禁止] §f事件注册-合成配方禁用");
Bukkit.getPluginManager().registerEvents(new AntiCraft(), plugin);
Bukkit.getConsoleSender().sendMessage("§c[生存禁止] §f事件注册-数据延迟保护");
Bukkit.getPluginManager().registerEvents(new AntiLagLimit(), plugin);
Bukkit.getPluginManager().registerEvents(new AntiEgg(), plugin);
Bukkit.getConsoleSender().sendMessage("§c[生存禁止] §f事件注册-扔鸡蛋保护");
Bukkit.getPluginManager().registerEvents(new AntiUse(), plugin);
Bukkit.getPluginManager().registerEvents(new AntiEnchant(), plugin);
Bukkit.getConsoleSender().sendMessage("§c[生存禁止] §f事件注册-铁砧保护");
Bukkit.getConsoleSender().sendMessage("§c[生存禁止] §f事件注册-附魔台保护");
Bukkit.getPluginManager().registerEvents(new JumpPlate(), plugin);
Bukkit.getConsoleSender().sendMessage("§c[生存禁止] §f事件注册-踏板跳跃");
Bukkit.getPluginManager().registerEvents(new AntiChangeSpawn(), plugin);
Bukkit.getConsoleSender().sendMessage("§c[生存禁止] §f事件注册-刷怪笼保护");
Bukkit.getPluginManager().registerEvents(new AntiRedStone(), plugin);
Bukkit.getConsoleSender().sendMessage("§c[生存禁止] §f事件注册-地狱红石禁止");
Bukkit.getConsoleSender().sendMessage("§c[生存禁止] §a插件成功载入Server");
Bukkit.getConsoleSender().sendMessage("§c[生存禁止] §a妖魂QQ:1763917516");
}
@Override
public void onDisable() {
Bukkit.getConsoleSender().sendMessage("§c[生存禁止] §f插件已关闭.");
}
public boolean onCommand(CommandSender sender, Command cmd, String Command, String[] args) {
if (Command.equalsIgnoreCase("antienent") && sender.isOp()) {
Player p = (Player) sender;
World world = p.getWorld();
sender.sendMessage("当前时间: " + world.getTime());
}
return false;
}
}

View File

@ -0,0 +1,5 @@
name: DemonAntiEvent
main: me.Demon.DemonAntiEvent.Main
version: 1.0.1
commands:
antienent: