Compare commits

...

12 Commits

21 changed files with 47 additions and 41 deletions

5
.gitignore vendored Normal file

@ -0,0 +1,5 @@
build
.idea
.gradle
gradle
.gradle/

Binary file not shown.

Binary file not shown.

@ -1,5 +1,6 @@
<?xml version="1.0" encoding="UTF-8"?>
<project version="4">
<component name="GradleMigrationSettings" migrationVersion="1" />
<component name="GradleSettings">
<option name="linkedExternalProjectsSettings">
<GradleProjectSettings>

@ -3,7 +3,7 @@ plugins {
}
group = 'org.twipnetwork'
version = '1.0-SNAPSHOT'
version = '1.6-1.21'
repositories {
mavenCentral()

@ -4,6 +4,3 @@ boostPower: 4.0
# damageShooter defines whether the shooter gets damages by their own fireworks (default: false)
damageShooter: false
# damageOthers defines whether other people (excluding the shooter) get damaged (default: true)
damageOthers: true

@ -1,4 +0,0 @@
name: RocketJumping
version: '1.0-SNAPSHOT'
main: org.twipnetwork.rocketJumping.RocketJumping
api-version: '1.21'

@ -1,6 +1,7 @@
package org.twipnetwork.rocketJumping;
import org.bukkit.Bukkit;
import org.bukkit.command.*;
import org.bukkit.configuration.file.FileConfiguration;
import org.bukkit.entity.Entity;
import org.bukkit.entity.Player;
@ -12,19 +13,17 @@ import org.bukkit.event.entity.ProjectileHitEvent;
import org.bukkit.plugin.java.JavaPlugin;
import org.bukkit.util.Vector;
import java.util.Objects;
public final class RocketJumping extends JavaPlugin implements Listener {
private double boostPower;
private boolean damageShooter;
private boolean damageOthers;
@Override
public void onEnable() {
saveDefaultConfig();
FileConfiguration config = getConfig();
boostPower = config.getDouble("boostPower", 4.0);
damageShooter = config.getBoolean("damageShooter", false);
damageOthers = config.getBoolean("damageOthers", true);
loadConfigValues();
Bukkit.getPluginManager().registerEvents(this, this);
}
@ -32,36 +31,41 @@ public final class RocketJumping extends JavaPlugin implements Listener {
public void onDisable() {
}
private void loadConfigValues() {
FileConfiguration config = getConfig();
boostPower = config.getDouble("boostPower", 4.0);
damageShooter = config.getBoolean("damageShooter", false);
}
@EventHandler
public void onProjectileHit(ProjectileHitEvent event) {
Projectile projectile = event.getEntity();
if (projectile instanceof Firework) {
Firework firework = (Firework) projectile;
if (projectile instanceof Firework firework) {
Entity shooter = (Entity) firework.getShooter();
for (Entity entity : firework.getNearbyEntities(5, 5, 5)) {
if (entity instanceof Player) {
Player player = (Player) entity;
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 (!damageOthers) {
for (Entity entity : firework.getNearbyEntities(5, 5, 5)) {
if (!(entity instanceof Player && entity.equals(shooter))) {
((Player) entity).setNoDamageTicks(1);
}
if (entity instanceof Player player && !damageShooter && player.equals(shooter)) {
player.setNoDamageTicks(1);
}
}
}
}
}
@Override
public boolean onCommand(CommandSender sender, Command command, String label, String[] args) {
if (command.getName().equalsIgnoreCase("rocketjumping")) {
if (args.length > 0 && args[0].equalsIgnoreCase("reload")) {
reloadConfig();
loadConfigValues();
sender.sendMessage("§aRocketJumping config reloaded!");
return true;
}
}
return false;
}
}

@ -4,6 +4,3 @@ boostPower: 4.0
# damageShooter defines whether the shooter gets damages by their own fireworks (default: false)
damageShooter: false
# damageOthers defines whether other people (excluding the shooter) get damaged (default: true)
damageOthers: true

@ -1,4 +0,0 @@
name: RocketJumping
version: '1.0-SNAPSHOT'
main: org.twipnetwork.rocketJumping.RocketJumping
api-version: '1.21'

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