mod version

This commit is contained in:
2025-08-20 20:37:02 +02:00
parent 1ed722c299
commit 799d7075ac
24 changed files with 724 additions and 93 deletions

View File

@@ -0,0 +1,58 @@
package com.kasetoatz.fastGhast;
import org.bukkit.Bukkit;
import org.bukkit.attribute.Attribute;
import org.bukkit.attribute.AttributeInstance;
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
{
private static final double UNMOUNTED_SPEED;
private double MOUNTED_SPEED;
@Override
public void onEnable()
{
saveDefaultConfig();
UNMOUNTED_SPEED = getConfig().getDouble("unmounted-speed");
MOUNTED_SPEED = getConfig().getDouble("mounted-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)
{
if (entity instanceof HappyGhast ghast)
{
AttributeInstance attr = ghast.getAttribute(Attribute.FLYING_SPEED);
if (attr != null)
{
attr.setBaseValue(speed);
}
}
}
@EventHandler
public void onEntityMount(EntityMountEvent event)
{
setSpeed(event.getMount(), MOUNTED_SPEED);
}
@EventHandler
public void onEntityDismount(EntityDismountEvent event)
{
setSpeed(event.getDismounted(), UNMOUNTED_SPEED);
}
}

View File

@@ -0,0 +1,4 @@
# Default flying speed.
unmounted-speed: 0.05
# Flying speed of mounted Happy Ghasts, default speed is 0.05 so 0.15 is 3 times as fast.
mounted-speed: 0.15

View File

@@ -0,0 +1,4 @@
name: FastGhast
version: '1.2'
main: com.kasetoatz.fastGhast.FastGhast
api-version: '1.21'