Compare commits

..

No commits in common. "master" and "1.2-1.21" have entirely different histories.

21 changed files with 41 additions and 47 deletions

5
.gitignore vendored

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

Binary file not shown.

Binary file not shown.

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

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

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

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

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

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

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

@ -1,10 +0,0 @@
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.