added a reload command

This commit is contained in:
Richard Mikloš 2024-08-13 00:29:05 +02:00
parent 981006b39b
commit f7e7f32327
14 changed files with 15 additions and 16 deletions

Binary file not shown.

@ -1,4 +1,10 @@
name: RocketJumping name: RocketJumping
version: '1.3-1.21' version: '1.4-1.21'
main: org.twipnetwork.rocketJumping.RocketJumping main: org.twipnetwork.rocketJumping.RocketJumping
api-version: '1.21' api-version: '1.21'
commands:
rocketlauncher:
description: Reloads the RocketJumping configuration.
usage: /<command> reload
permission: rocketlauncher.reload
permission-message: You do not have permission to execute this command.

@ -22,9 +22,7 @@ public final class RocketJumping extends JavaPlugin implements Listener {
@Override @Override
public void onEnable() { public void onEnable() {
saveDefaultConfig(); saveDefaultConfig();
FileConfiguration config = getConfig(); loadConfigValues();
boostPower = config.getDouble("boostPower", 4.0);
damageShooter = config.getBoolean("damageShooter", false);
Bukkit.getPluginManager().registerEvents(this, this); Bukkit.getPluginManager().registerEvents(this, this);
} }
@ -38,7 +36,6 @@ public final class RocketJumping extends JavaPlugin implements Listener {
damageShooter = config.getBoolean("damageShooter", false); damageShooter = config.getBoolean("damageShooter", false);
} }
@EventHandler @EventHandler
public void onProjectileHit(ProjectileHitEvent event) { public void onProjectileHit(ProjectileHitEvent event) {
Projectile projectile = event.getEntity(); Projectile projectile = event.getEntity();
@ -47,16 +44,11 @@ public final class RocketJumping extends JavaPlugin implements Listener {
Entity shooter = (Entity) firework.getShooter(); Entity shooter = (Entity) firework.getShooter();
for (Entity entity : firework.getNearbyEntities(5, 5, 5)) { for (Entity entity : firework.getNearbyEntities(5, 5, 5)) {
if (entity instanceof Player player) {
Vector boostDirection = player.getLocation().toVector().subtract(firework.getLocation().toVector()).normalize();
player.setVelocity(player.getVelocity().add(boostDirection.multiply(boostPower)));
if (!damageShooter && player.equals(shooter)) {
player.setNoDamageTicks(1);
}
} else {
Vector boostDirection = entity.getLocation().toVector().subtract(firework.getLocation().toVector()).normalize(); Vector boostDirection = entity.getLocation().toVector().subtract(firework.getLocation().toVector()).normalize();
entity.setVelocity(entity.getVelocity().add(boostDirection.multiply(boostPower))); entity.setVelocity(entity.getVelocity().add(boostDirection.multiply(boostPower)));
if (entity instanceof Player player && !damageShooter && player.equals(shooter)) {
player.setNoDamageTicks(1);
} }
} }
} }
@ -74,4 +66,5 @@ public final class RocketJumping extends JavaPlugin implements Listener {
} }
return false; return false;
} }
} }

@ -1,7 +1,7 @@
name: RocketJumping name: RocketJumping
version: '1.4-1.21' version: '1.4-1.21'
main: org.twipnetwork.rocketJumping.RocketJumping main: org.twipnetwork.rocketJumping.RocketJumping
api-version: '1.21' api-version: 1.21
commands: commands:
rocketlauncher: rocketlauncher:
description: Reloads the RocketJumping configuration. description: Reloads the RocketJumping configuration.