added a reload command

This commit is contained in:
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.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
+7 -1
View File
@@ -1,4 +1,10 @@
name: RocketJumping
version: '1.3-1.21'
version: '1.4-1.21'
main: org.twipnetwork.rocketJumping.RocketJumping
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.
Binary file not shown.
@@ -22,9 +22,7 @@ public final class RocketJumping extends JavaPlugin implements Listener {
@Override
public void onEnable() {
saveDefaultConfig();
FileConfiguration config = getConfig();
boostPower = config.getDouble("boostPower", 4.0);
damageShooter = config.getBoolean("damageShooter", false);
loadConfigValues();
Bukkit.getPluginManager().registerEvents(this, this);
}
@@ -38,7 +36,6 @@ public final class RocketJumping extends JavaPlugin implements Listener {
damageShooter = config.getBoolean("damageShooter", false);
}
@EventHandler
public void onProjectileHit(ProjectileHitEvent event) {
Projectile projectile = event.getEntity();
@@ -47,16 +44,11 @@ public final class RocketJumping extends JavaPlugin implements Listener {
Entity shooter = (Entity) firework.getShooter();
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)));
Vector boostDirection = entity.getLocation().toVector().subtract(firework.getLocation().toVector()).normalize();
entity.setVelocity(entity.getVelocity().add(boostDirection.multiply(boostPower)));
if (!damageShooter && player.equals(shooter)) {
player.setNoDamageTicks(1);
}
} else {
Vector boostDirection = entity.getLocation().toVector().subtract(firework.getLocation().toVector()).normalize();
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;
}
}
}
+1 -1
View File
@@ -1,7 +1,7 @@
name: RocketJumping
version: '1.4-1.21'
main: org.twipnetwork.rocketJumping.RocketJumping
api-version: '1.21'
api-version: 1.21
commands:
rocketlauncher:
description: Reloads the RocketJumping configuration.