From 97a234d75ad815c822a70730e20eb562b064bb22 Mon Sep 17 00:00:00 2001 From: MiniDay <372403923@qq.com> Date: Tue, 6 Jun 2023 21:56:19 +0800 Subject: [PATCH] =?UTF-8?q?feat(hamster-protect-piston-wool-carpet):=20?= =?UTF-8?q?=E5=AE=8C=E6=88=90=20hamster-protect-piston-wool-carpet=20?= =?UTF-8?q?=E6=8F=92=E4=BB=B6?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../build.gradle | 2 + .../carpet/PistonWoolCarpetProtectPlugin.java | 42 +++++++++++++++++++ .../src/main/resources/plugin.yml | 8 ++++ settings.gradle | 2 + 4 files changed, 54 insertions(+) create mode 100644 hamster-protect-piston-wool-carpet/build.gradle create mode 100644 hamster-protect-piston-wool-carpet/src/main/java/cn/hamster3/mc/plugin/protect/piston/wool/carpet/PistonWoolCarpetProtectPlugin.java create mode 100644 hamster-protect-piston-wool-carpet/src/main/resources/plugin.yml diff --git a/hamster-protect-piston-wool-carpet/build.gradle b/hamster-protect-piston-wool-carpet/build.gradle new file mode 100644 index 0000000..843b6f8 --- /dev/null +++ b/hamster-protect-piston-wool-carpet/build.gradle @@ -0,0 +1,2 @@ +version '1.0.0' +setArchivesBaseName("HamsterProtect-PistonWoolCarpet") diff --git a/hamster-protect-piston-wool-carpet/src/main/java/cn/hamster3/mc/plugin/protect/piston/wool/carpet/PistonWoolCarpetProtectPlugin.java b/hamster-protect-piston-wool-carpet/src/main/java/cn/hamster3/mc/plugin/protect/piston/wool/carpet/PistonWoolCarpetProtectPlugin.java new file mode 100644 index 0000000..39db44c --- /dev/null +++ b/hamster-protect-piston-wool-carpet/src/main/java/cn/hamster3/mc/plugin/protect/piston/wool/carpet/PistonWoolCarpetProtectPlugin.java @@ -0,0 +1,42 @@ +package cn.hamster3.mc.plugin.protect.piston.wool.carpet; + +import org.bukkit.Bukkit; +import org.bukkit.block.Block; +import org.bukkit.event.EventHandler; +import org.bukkit.event.Listener; +import org.bukkit.event.block.BlockPistonExtendEvent; +import org.bukkit.plugin.java.JavaPlugin; + +public class PistonWoolCarpetProtectPlugin extends JavaPlugin implements Listener { + @Override + public void onEnable() { + Bukkit.getPluginManager().registerEvents(this, this); + } + + @EventHandler(ignoreCancelled = true) + public void onBlockPistonExtend(BlockPistonExtendEvent event) { + for (Block block : event.getBlocks()) { + switch (block.getType()) { + case MOSS_CARPET: + case WHITE_CARPET: + case ORANGE_CARPET: + case MAGENTA_CARPET: + case LIGHT_BLUE_CARPET: + case YELLOW_CARPET: + case LIME_CARPET: + case PINK_CARPET: + case GRAY_CARPET: + case LIGHT_GRAY_CARPET: + case CYAN_CARPET: + case PURPLE_CARPET: + case BLUE_CARPET: + case BROWN_CARPET: + case GREEN_CARPET: + case RED_CARPET: { + event.setCancelled(true); + return; + } + } + } + } +} diff --git a/hamster-protect-piston-wool-carpet/src/main/resources/plugin.yml b/hamster-protect-piston-wool-carpet/src/main/resources/plugin.yml new file mode 100644 index 0000000..83ea128 --- /dev/null +++ b/hamster-protect-piston-wool-carpet/src/main/resources/plugin.yml @@ -0,0 +1,8 @@ +name: HamsterProtect-PistonWoolCarpet +main: cn.hamster3.mc.plugin.protect.piston.wool.carpet.PistonWoolCarpetProtectPlugin +version: ${version} +api-version: 1.13 + +author: MiniDay +website: https://github.com/MiniDay/hamster-little-plugins +description: 刷羊毛保护 diff --git a/settings.gradle b/settings.gradle index b7e99bf..bfb2f39 100644 --- a/settings.gradle +++ b/settings.gradle @@ -10,4 +10,6 @@ include 'hamster-spawn' include 'hamster-chain-break' include 'hamster-tpa' include 'hamster-join-message' +include 'hamster-protect-explosion' +include 'hamster-protect-piston-wool-carpet'