feat(hamster-protect-farmland): 完成 hamster-protect-farmland 插件

This commit is contained in:
2023-06-06 22:58:20 +08:00
parent 97a234d75a
commit 7d1e575a8c
4 changed files with 46 additions and 0 deletions

View File

@@ -0,0 +1,2 @@
version '1.0.0'
setArchivesBaseName("HamsterProtect-Farmland")

View File

@@ -0,0 +1,35 @@
package cn.hamster3.mc.plugin.protect.farmland;
import org.bukkit.Bukkit;
import org.bukkit.block.Block;
import org.bukkit.entity.EntityType;
import org.bukkit.event.EventHandler;
import org.bukkit.event.EventPriority;
import org.bukkit.event.Listener;
import org.bukkit.event.entity.EntityInteractEvent;
import org.bukkit.plugin.java.JavaPlugin;
public class FarmlandProtectPlugin extends JavaPlugin implements Listener {
@Override
public void onEnable() {
Bukkit.getPluginManager().registerEvents(this, this);
}
@EventHandler(ignoreCancelled = true, priority = EventPriority.LOW)
public void trampleProtect(EntityInteractEvent event) {
if (event.getEntityType() == EntityType.FALLING_BLOCK) {
return;
}
Block block = event.getBlock();
switch (block.getType()) {
case FARMLAND:
case SOUL_SAND: {
break;
}
default: {
return;
}
}
event.setCancelled(true);
}
}

View File

@@ -0,0 +1,8 @@
name: HamsterProtect-Farmland
main: cn.hamster3.mc.plugin.protect.farmland.FarmlandProtectPlugin
version: ${version}
api-version: 1.13
author: MiniDay
website: https://github.com/MiniDay/hamster-little-plugins
description: 耕地践踏保护

View File

@@ -12,4 +12,5 @@ include 'hamster-tpa'
include 'hamster-join-message' include 'hamster-join-message'
include 'hamster-protect-explosion' include 'hamster-protect-explosion'
include 'hamster-protect-piston-wool-carpet' include 'hamster-protect-piston-wool-carpet'
include 'hamster-protect-farmland'