Compare commits
No commits in common. "master" and "1.2-1.21" have entirely different histories.
5
.gitignore
vendored
5
.gitignore
vendored
@ -1,5 +0,0 @@
|
||||
build
|
||||
.idea
|
||||
.gradle
|
||||
gradle
|
||||
.gradle/
|
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.
Binary file not shown.
@ -1,6 +1,5 @@
|
||||
<?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.6-1.21'
|
||||
version = '1.0-SNAPSHOT'
|
||||
|
||||
repositories {
|
||||
mavenCentral()
|
||||
|
Binary file not shown.
@ -4,3 +4,6 @@ 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
|
4
build/resources/main/paper-plugin.yml
Normal file
4
build/resources/main/paper-plugin.yml
Normal file
@ -0,0 +1,4 @@
|
||||
name: RocketJumping
|
||||
version: '1.0-SNAPSHOT'
|
||||
main: org.twipnetwork.rocketJumping.RocketJumping
|
||||
api-version: '1.21'
|
Binary file not shown.
Binary file not shown.
@ -1,7 +1,6 @@
|
||||
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;
|
||||
@ -13,17 +12,19 @@ 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();
|
||||
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);
|
||||
}
|
||||
|
||||
@ -31,41 +32,36 @@ 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) {
|
||||
if (projectile instanceof Firework) {
|
||||
Firework firework = (Firework) projectile;
|
||||
Entity shooter = (Entity) firework.getShooter();
|
||||
|
||||
for (Entity entity : firework.getNearbyEntities(5, 5, 5)) {
|
||||
Vector boostDirection = entity.getLocation().toVector().subtract(firework.getLocation().toVector()).normalize();
|
||||
entity.setVelocity(entity.getVelocity().add(boostDirection.multiply(boostPower)));
|
||||
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)));
|
||||
|
||||
if (entity instanceof Player player && !damageShooter && player.equals(shooter)) {
|
||||
player.setNoDamageTicks(1);
|
||||
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);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@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,3 +4,6 @@ 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
|
4
src/main/resources/paper-plugin.yml
Normal file
4
src/main/resources/paper-plugin.yml
Normal file
@ -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.
|
Loading…
Reference in New Issue
Block a user