feat(hamster-protect-farmland): 完成 hamster-protect-farmland 插件
This commit is contained in:
2
hamster-protect-farmland/build.gradle
Normal file
2
hamster-protect-farmland/build.gradle
Normal file
@@ -0,0 +1,2 @@
|
||||
version '1.0.0'
|
||||
setArchivesBaseName("HamsterProtect-Farmland")
|
@@ -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);
|
||||
}
|
||||
}
|
8
hamster-protect-farmland/src/main/resources/plugin.yml
Normal file
8
hamster-protect-farmland/src/main/resources/plugin.yml
Normal 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: 耕地践踏保护
|
@@ -12,4 +12,5 @@ include 'hamster-tpa'
|
||||
include 'hamster-join-message'
|
||||
include 'hamster-protect-explosion'
|
||||
include 'hamster-protect-piston-wool-carpet'
|
||||
include 'hamster-protect-farmland'
|
||||
|
||||
|
Reference in New Issue
Block a user