From 1ed722c299afd7caa2760e459784dc9287ee854a Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?K=C3=A4seToatz?= Date: Mon, 11 Aug 2025 22:01:28 +0200 Subject: [PATCH] Add leash protection --- build.gradle | 8 ++++---- src/main/java/com/kasetoatz/fastGhast/FastGhast.java | 12 ++++++++++-- src/main/resources/plugin.yml | 2 +- 3 files changed, 15 insertions(+), 7 deletions(-) diff --git a/build.gradle b/build.gradle index 183a50d..a969d45 100644 --- a/build.gradle +++ b/build.gradle @@ -4,18 +4,18 @@ plugins { } group = 'com.kasetoatz' -version = '1.0' +version = '1.1' repositories { mavenCentral() maven { - name = "spigotmc-repo" - url = "https://hub.spigotmc.org/nexus/content/repositories/snapshots/" + name = "papermc" + url = "https://repo.papermc.io/repository/maven-public/" } } dependencies { - compileOnly("org.spigotmc:spigot-api:1.21.8-R0.1-SNAPSHOT") + compileOnly("io.papermc.paper:paper-api:1.21.8-R0.1-SNAPSHOT") } tasks { diff --git a/src/main/java/com/kasetoatz/fastGhast/FastGhast.java b/src/main/java/com/kasetoatz/fastGhast/FastGhast.java index 62007ff..04f4adc 100644 --- a/src/main/java/com/kasetoatz/fastGhast/FastGhast.java +++ b/src/main/java/com/kasetoatz/fastGhast/FastGhast.java @@ -1,14 +1,15 @@ package com.kasetoatz.fastGhast; +import org.bukkit.Bukkit; import org.bukkit.attribute.Attribute; import org.bukkit.attribute.AttributeInstance; -import org.bukkit.entity.Entity; -import org.bukkit.entity.HappyGhast; +import org.bukkit.entity.*; import org.bukkit.event.EventHandler; import org.bukkit.event.Listener; import org.bukkit.event.entity.EntityDismountEvent; import org.bukkit.event.entity.EntityMountEvent; import org.bukkit.plugin.java.JavaPlugin; +import io.papermc.paper.entity.Leashable; public final class FastGhast extends JavaPlugin implements Listener { @@ -21,6 +22,13 @@ public final class FastGhast extends JavaPlugin implements Listener saveDefaultConfig(); SPEED = getConfig().getDouble("speed"); getServer().getPluginManager().registerEvents(this, this); + Bukkit.getScheduler().runTaskTimer(this, () -> { + getServer().getWorlds().forEach(world -> world.getEntities().forEach(entity -> { + if (entity instanceof Leashable leashed && leashed.isLeashed() && leashed.getLeashHolder() instanceof HappyGhast ghast && leashed.getLocation().distance(ghast.getLocation()) > 8) { + leashed.teleport(ghast.getLocation()); + } + })); + }, 0, 1); } private void setSpeed(Entity entity, double speed) diff --git a/src/main/resources/plugin.yml b/src/main/resources/plugin.yml index 333c4dd..c505c09 100644 --- a/src/main/resources/plugin.yml +++ b/src/main/resources/plugin.yml @@ -1,4 +1,4 @@ name: FastGhast -version: '1.0' +version: '1.1' main: com.kasetoatz.fastGhast.FastGhast api-version: '1.21'