1.7 update
This commit is contained in:
1 parent
4c3dae04f2
commit
4e5c9c4330
6 files changed
+285
-223
No files matched your search
+13
-1
@@ -25,7 +25,7 @@ kotlin { jvmToolchain(17) }
|
||||
/* ----------------------------- Metadata ------------------------------ */
|
||||
group = "net.trueog.launchpads-og" // Declare bundle identifier.
|
||||
|
||||
version = "1.6" // Declare plugin version (will be in .jar).
|
||||
version = "1.7" // Declare plugin version (will be in .jar).
|
||||
|
||||
val apiVersion = "1.19" // Declare minecraft server target version.
|
||||
|
||||
@@ -61,6 +61,8 @@ tasks.withType<AbstractArchiveTask>().configureEach { // Ensure reproducible .ja
|
||||
/* ----------------------------- Shadow -------------------------------- */
|
||||
tasks.shadowJar {
|
||||
exclude("io.github.miniplaceholders.*") // Exclude the MiniPlaceholders package from being shadowed.
|
||||
isEnableRelocation = true
|
||||
relocationPrefix = "${project.group}.shadow"
|
||||
archiveClassifier.set("") // Use empty string instead of null.
|
||||
minimize()
|
||||
}
|
||||
@@ -104,3 +106,13 @@ tasks.named("compileJava") {
|
||||
tasks.named("spotlessCheck") {
|
||||
dependsOn("spotlessApply") // Run spotless before checking if spotless ran.
|
||||
}
|
||||
|
||||
/* ------------------------------ Eclipse SHIM ------------------------- */
|
||||
|
||||
// This can't be put in eclipse.gradle.kts because Gradle is weird.
|
||||
subprojects {
|
||||
apply(plugin = "java-library")
|
||||
apply(plugin = "eclipse")
|
||||
eclipse.project.name = "${project.name}-${rootProject.name}"
|
||||
tasks.withType<Jar>().configureEach { archiveBaseName.set("${project.name}-${rootProject.name}") }
|
||||
}
|
||||
@@ -3,6 +3,8 @@ package net.trueog.launchpadsog.Commands;
|
||||
import java.util.ArrayList;
|
||||
import java.util.Collections;
|
||||
import java.util.List;
|
||||
|
||||
import org.apache.commons.lang3.StringUtils;
|
||||
import org.bukkit.command.Command;
|
||||
import org.bukkit.command.CommandSender;
|
||||
import org.bukkit.command.TabCompleter;
|
||||
@@ -33,14 +35,14 @@ public class LaunchPadCommandCompleter implements TabCompleter {
|
||||
|
||||
} else if (args.length == 2) {
|
||||
|
||||
if (args[0].equalsIgnoreCase("help")) {
|
||||
if (StringUtils.equalsIgnoreCase(args[0], "help")) {
|
||||
|
||||
// build the list to return
|
||||
ArrayList<String> result = new ArrayList<>();
|
||||
// Build the list to return.
|
||||
final ArrayList<String> result = new ArrayList<>();
|
||||
result.add("set");
|
||||
result.add("delete");
|
||||
|
||||
// sort the list
|
||||
// Sort the list.
|
||||
Collections.sort(result);
|
||||
|
||||
return result;
|
||||
@@ -53,4 +55,4 @@ public class LaunchPadCommandCompleter implements TabCompleter {
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
@@ -15,6 +15,7 @@ import net.trueog.launchpadsog.Commands.LaunchPadCommands;
|
||||
import net.trueog.launchpadsog.Listeners.OnBlockBreak;
|
||||
import net.trueog.launchpadsog.Listeners.OnBlockPlace;
|
||||
import net.trueog.launchpadsog.Listeners.OnEntityDamage;
|
||||
import net.trueog.launchpadsog.Listeners.OnPlayerInteract;
|
||||
import net.trueog.launchpadsog.Listeners.OnPlayerMove;
|
||||
|
||||
public final class LaunchPadsOG extends JavaPlugin {
|
||||
@@ -22,139 +23,65 @@ public final class LaunchPadsOG extends JavaPlugin {
|
||||
private static LaunchPadsOG plugin;
|
||||
private static FileConfiguration config;
|
||||
|
||||
// this list will hold the players that have used a launchpad and are flying
|
||||
// This list will hold the players that have used a launchpad and are flying
|
||||
// through the air
|
||||
// then, when they land, I remove them from the list, and stop them from taking
|
||||
// fall damage
|
||||
private static ArrayList<Player> launchedPlayers = new ArrayList<Player>();
|
||||
// fall damage.
|
||||
private static final ArrayList<Player> launchedPlayers = new ArrayList<>();
|
||||
|
||||
@Override
|
||||
public void onEnable() {
|
||||
|
||||
plugin = this;
|
||||
|
||||
saveDefaultConfig();
|
||||
config = this.getConfig();
|
||||
|
||||
reloadConfig();
|
||||
|
||||
// if this is the first time the plugin is run, set cancraft to false
|
||||
if (config.get("cancraft") == null) {
|
||||
|
||||
config.set("cancraft", false);
|
||||
saveConfig();
|
||||
|
||||
}
|
||||
|
||||
// if this is the first time the plugin is run, set power values to defaults
|
||||
// check for defaultXpower, defaultYpower, defaultZpower, and numberOfPads
|
||||
if (config.get("defaultXpower") == null) {
|
||||
|
||||
config.set("defaultXpower", 3.0);
|
||||
saveConfig();
|
||||
|
||||
}
|
||||
|
||||
if (config.get("defaultYpower") == null) {
|
||||
|
||||
config.set("defaultYpower", 4.0);
|
||||
saveConfig();
|
||||
|
||||
}
|
||||
|
||||
if (config.get("defaultZpower") == null) {
|
||||
|
||||
config.set("defaultZpower", 3.0);
|
||||
saveConfig();
|
||||
|
||||
}
|
||||
|
||||
if (config.get("numberOfPads") == null) {
|
||||
|
||||
config.set("numberOfPads", 0);
|
||||
saveConfig();
|
||||
|
||||
}
|
||||
|
||||
// check for ambientParticleCount and ambientParticlePower
|
||||
if (config.get("idleParticleCount") == null) {
|
||||
|
||||
config.set("idleParticleCount", 4);
|
||||
saveConfig();
|
||||
|
||||
}
|
||||
|
||||
if (config.get("idleParticlePower") == null) {
|
||||
|
||||
config.set("idleParticlePower", 1.5);
|
||||
saveConfig();
|
||||
|
||||
}
|
||||
|
||||
// check for padLaunchParticleCount and padLaunchParticlePower
|
||||
if (config.get("padLaunchParticleCount") == null) {
|
||||
|
||||
config.set("padLaunchParticleCount", 80);
|
||||
saveConfig();
|
||||
|
||||
}
|
||||
|
||||
if (config.get("padLaunchParticlePower") == null) {
|
||||
|
||||
config.set("padLaunchParticlePower", 1.0);
|
||||
saveConfig();
|
||||
|
||||
}
|
||||
|
||||
// check for playerLaunchParticleCountMultiplier
|
||||
if (config.get("playerLaunchParticleCountMultipier") == null) {
|
||||
|
||||
config.set("playerLaunchParticleCountMultipier", 1.0);
|
||||
saveConfig();
|
||||
|
||||
}
|
||||
|
||||
// if the launchpad is craftable, add the recipe to the server
|
||||
// If the launchpad is craftable, add the recipe to the server.
|
||||
if ((boolean) config.get("cancraft")) {
|
||||
// create the recipe for the launchpad
|
||||
// make it really expensive by locking it
|
||||
// behind many other crafting items
|
||||
|
||||
// launcher base
|
||||
// Create the recipe for the launchpad
|
||||
// make it really expensive by locking it
|
||||
// behind many other crafting items.
|
||||
// Launcher base.
|
||||
Recipes.addLauncherBase();
|
||||
// launcher launcher
|
||||
// Launcher launcher.
|
||||
Recipes.addLauncherLauncher();
|
||||
// launcher explosion
|
||||
// Launcher explosion.
|
||||
Recipes.addLauncherExploder();
|
||||
// launcher activator
|
||||
// Launcher activator.
|
||||
Recipes.addLauncherActivator();
|
||||
// final Launch Pad
|
||||
// Final launchpd.
|
||||
Recipes.addLaunchPad();
|
||||
|
||||
}
|
||||
|
||||
getServer().getPluginManager().registerEvents(new OnPlayerMove(), this);
|
||||
getServer().getPluginManager().registerEvents(new OnPlayerInteract(), this);
|
||||
getServer().getPluginManager().registerEvents(new OnBlockBreak(), this);
|
||||
getServer().getPluginManager().registerEvents(new OnBlockPlace(), this);
|
||||
getServer().getPluginManager().registerEvents(new OnEntityDamage(), this);
|
||||
getCommand("launchpad").setExecutor(new LaunchPadCommands());
|
||||
getCommand("launchpad").setTabCompleter(new LaunchPadCommandCompleter());
|
||||
|
||||
// make all launchpads emit particles when not in use
|
||||
// to signify that they are launchpads
|
||||
// Make all launchpads emit particles when not in use
|
||||
// to signify that they are launchpads.
|
||||
Bukkit.getScheduler().runTaskTimer(this, () -> {
|
||||
|
||||
for (int i = 1; i < config.getInt("numberOfPads") + 1; i++) {
|
||||
|
||||
String worldName = config.getString(i + ".world");
|
||||
World world = Bukkit.getWorld(worldName);
|
||||
double padX = config.getInt(i + ".x") + 0.5;
|
||||
double padY = config.getInt(i + ".y");
|
||||
double padZ = config.getInt(i + ".z") + 0.5;
|
||||
Location padLocation = new Location(world, padX, padY, padZ);
|
||||
int idleParticleCount = config.getInt("idleParticleCount");
|
||||
double idleParticlePower = config.getDouble("idleParticlePower");
|
||||
final String worldName = config.getString(i + ".world");
|
||||
final World world = Bukkit.getWorld(worldName);
|
||||
final double padX = config.getInt(i + ".x") + 0.5;
|
||||
final double padY = config.getInt(i + ".y");
|
||||
final double padZ = config.getInt(i + ".z") + 0.5;
|
||||
final Location padLocation = new Location(world, padX, padY, padZ);
|
||||
final int idleParticleCount = config.getInt("idleParticleCount");
|
||||
final double idleParticlePower = config.getDouble("idleParticlePower");
|
||||
|
||||
// spawn particles on the pad if the pad is loaded
|
||||
// Spawn particles on the pad if the pad is loaded.
|
||||
if (world.isChunkLoaded(padLocation.getChunk())) {
|
||||
|
||||
world.spawnParticle(Particle.DRAGON_BREATH, padLocation, idleParticleCount, 0, 0, 0,
|
||||
@@ -186,4 +113,4 @@ public final class LaunchPadsOG extends JavaPlugin {
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,85 @@
|
||||
package net.trueog.launchpadsog.Listeners;
|
||||
|
||||
import org.bukkit.Location;
|
||||
import org.bukkit.Material;
|
||||
import org.bukkit.block.Block;
|
||||
import org.bukkit.configuration.file.FileConfiguration;
|
||||
import org.bukkit.event.Event;
|
||||
import org.bukkit.event.EventHandler;
|
||||
import org.bukkit.event.EventPriority;
|
||||
import org.bukkit.event.Listener;
|
||||
import org.bukkit.event.block.Action;
|
||||
import org.bukkit.event.player.PlayerInteractEvent;
|
||||
|
||||
import net.trueog.launchpadsog.LaunchPadsOG;
|
||||
|
||||
public class OnPlayerInteract implements Listener {
|
||||
|
||||
@EventHandler(priority = EventPriority.HIGHEST, ignoreCancelled = false)
|
||||
public void onInteract(PlayerInteractEvent event) {
|
||||
|
||||
if (event.getAction() != Action.PHYSICAL) {
|
||||
|
||||
return;
|
||||
|
||||
}
|
||||
|
||||
final Block block = event.getClickedBlock();
|
||||
if (block == null) {
|
||||
|
||||
return;
|
||||
|
||||
}
|
||||
|
||||
if (block.getType() != Material.STONE_PRESSURE_PLATE) {
|
||||
|
||||
return;
|
||||
|
||||
}
|
||||
|
||||
final Location loc = block.getLocation();
|
||||
final String worldName = loc.getWorld().getName();
|
||||
final int x = loc.getBlockX();
|
||||
final int y = loc.getBlockY();
|
||||
final int z = loc.getBlockZ();
|
||||
|
||||
final FileConfiguration cfg = LaunchPadsOG.getConfiguration();
|
||||
final int count = cfg.getInt("numberOfPads");
|
||||
|
||||
for (int i = 1; i <= count; i++) {
|
||||
|
||||
final String padWorld = cfg.getString(i + ".world");
|
||||
if (!worldName.equals(padWorld)) {
|
||||
|
||||
continue;
|
||||
|
||||
}
|
||||
|
||||
if (cfg.getInt(i + ".x") != x) {
|
||||
|
||||
continue;
|
||||
|
||||
}
|
||||
|
||||
if (cfg.getInt(i + ".y") != y) {
|
||||
|
||||
continue;
|
||||
|
||||
}
|
||||
|
||||
if (cfg.getInt(i + ".z") != z) {
|
||||
|
||||
continue;
|
||||
|
||||
}
|
||||
|
||||
event.setUseInteractedBlock(Event.Result.DENY);
|
||||
event.setCancelled(true);
|
||||
|
||||
return;
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
@@ -19,128 +19,162 @@ public class OnPlayerMove implements Listener {
|
||||
@EventHandler
|
||||
public void onPlayerMoveEvent(PlayerMoveEvent event) {
|
||||
|
||||
if (event.hasChangedBlock()) {
|
||||
if (!event.hasChangedBlock()) {
|
||||
|
||||
// loop through every launch pad and look for one that has the same coords as
|
||||
// the player
|
||||
FileConfiguration padConfig = LaunchPadsOG.getConfiguration();
|
||||
Player player = event.getPlayer();
|
||||
String worldName = player.getWorld().getName();
|
||||
for (int i = 1; i < padConfig.getInt("numberOfPads") + 1; i++) {
|
||||
return;
|
||||
|
||||
// if the launch pad is in the same world as the player
|
||||
if (padConfig.getString("" + i + ".world").equals(worldName)) {
|
||||
}
|
||||
|
||||
Location playerLocation = event.getTo();
|
||||
// check each cardinal direction individually so that it can run faster
|
||||
// check x location
|
||||
if (padConfig.getInt("" + i + ".x") == playerLocation.getBlockX()) {
|
||||
// Loop through every launch pad and look for one that has the same coordinates
|
||||
// as
|
||||
// the player.
|
||||
final FileConfiguration padConfig = LaunchPadsOG.getConfiguration();
|
||||
final Player player = event.getPlayer();
|
||||
final String worldName = player.getWorld().getName();
|
||||
|
||||
// check y location
|
||||
if (padConfig.getInt("" + i + ".y") == playerLocation.getBlockY()) {
|
||||
final Location playerLocation = event.getTo();
|
||||
if (playerLocation == null) {
|
||||
|
||||
// check z location
|
||||
if (padConfig.getInt("" + i + ".z") == playerLocation.getBlockZ()) {
|
||||
return;
|
||||
|
||||
// calculate the player's y-speed using getFrom() and getTo()
|
||||
// y speed is the only one calculated so that a jump will affect
|
||||
// how far you get launched
|
||||
Location from = event.getFrom();
|
||||
Location to = event.getTo();
|
||||
}
|
||||
|
||||
// speed = distance/time
|
||||
// distance = abs(from-to)
|
||||
// time = 1 tick
|
||||
double ySpeed = to.getY() - from.getY();
|
||||
for (int i = 1; i < padConfig.getInt("numberOfPads") + 1; i++) {
|
||||
|
||||
// if the ySpeed is below a threshold of 0.15,
|
||||
// then set the ySpeed to 0.15 so that there is some y movement
|
||||
if (ySpeed < 0.15) {
|
||||
final String padWorld = padConfig.getString(i + ".world");
|
||||
if (!worldName.equals(padWorld)) {
|
||||
|
||||
ySpeed = 0.15;
|
||||
continue; // wrong world -> skip this pad
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
// add 0.25 to the ySpeed so that there is more movement,
|
||||
// without reducing the effect of a jump
|
||||
ySpeed += 0.25;
|
||||
final boolean condition = padConfig.getInt(Integer.toString(i) + ".x") == playerLocation.getBlockX()
|
||||
&& padConfig.getInt(Integer.toString(i) + ".y") == playerLocation.getBlockY()
|
||||
&& padConfig.getInt(Integer.toString(i) + ".z") == playerLocation.getBlockZ();
|
||||
// check y location
|
||||
// check z location
|
||||
// check each cardinal direction individually so that it can run faster
|
||||
// check x location
|
||||
if (condition) {
|
||||
|
||||
// if the player is crouching, reduce the velocity to 1/3
|
||||
if (player.isSneaking()) {
|
||||
// calculate the player's y-speed using getFrom() and getTo()
|
||||
// y speed is the only one calculated so that a jump will affect
|
||||
// how far you get launched
|
||||
final Location from = event.getFrom();
|
||||
final Location to = playerLocation;
|
||||
|
||||
ySpeed /= 3;
|
||||
// speed = distance/time
|
||||
// distance = abs(from-to)
|
||||
// time = 1 tick
|
||||
double ySpeed = to.getY() - from.getY();
|
||||
|
||||
}
|
||||
// if the ySpeed is below a threshold of 0.15,
|
||||
// then set the ySpeed to 0.15 so that there is some y movement
|
||||
if (ySpeed < 0.15) {
|
||||
|
||||
// reduce the x,z velocity depending on how straight
|
||||
// the player is facing
|
||||
// more straight, more distance
|
||||
double velocityMult;
|
||||
double pitch = Location.normalizePitch(playerLocation.getPitch());
|
||||
velocityMult = Math.abs(pitch - 90) / 90;
|
||||
ySpeed = 0.15;
|
||||
|
||||
// get the unit vector for the x,z directions
|
||||
Vector directionVector = playerLocation.getDirection();
|
||||
}
|
||||
|
||||
// get the xpower, ypower, and zpower
|
||||
double xPower = padConfig.getDouble(i + ".xpower");
|
||||
double yPower = padConfig.getDouble(i + ".ypower");
|
||||
double zPower = padConfig.getDouble(i + ".zpower");
|
||||
// add 0.25 to the ySpeed so that there is more movement,
|
||||
// without reducing the effect of a jump
|
||||
ySpeed += 0.25;
|
||||
|
||||
player.setVelocity(new Vector(/* x */ xPower * directionVector.getX() * velocityMult,
|
||||
/* y */ yPower * ySpeed,
|
||||
/* z */ zPower * directionVector.getZ() * velocityMult));
|
||||
// if the player is crouching, reduce the velocity to 1/3
|
||||
if (player.isSneaking()) {
|
||||
|
||||
// player a wither shoot sound
|
||||
player.playSound(playerLocation, Sound.ENTITY_WITHER_SHOOT, 1.0f, 1.0f);
|
||||
// spawn particles at the launch pad
|
||||
Location padLocation = new Location(player.getWorld(), padConfig.getInt(i + ".x") + 0.5,
|
||||
padConfig.getInt(i + ".y"), padConfig.getInt(i + ".z") + 0.5);
|
||||
double padParticleCount = padConfig.getDouble("padLaunchParticleCount");
|
||||
double padParticlePower = padConfig.getDouble("padLaunchParticlePower");
|
||||
player.spawnParticle(Particle.FIREWORKS_SPARK, padLocation, (int) padParticleCount, 0,
|
||||
0, 0, 0.2 * padParticlePower);
|
||||
ySpeed /= 3;
|
||||
|
||||
double playerParticleMult = padConfig.getDouble("playerLaunchParticleCountMultipier");
|
||||
// spawn particles on the player as they fly through the air
|
||||
// This equation was gotten with a linear regression on different amounts of
|
||||
// yPower
|
||||
// to find what the vertex of the player's jump is
|
||||
// maxes out at 25 ticks
|
||||
// \/ --------- \/
|
||||
for (int j = 0; j < Math.min(yPower * 8 - 15, 25); j++) {
|
||||
}
|
||||
|
||||
Bukkit.getScheduler().runTaskLater(LaunchPadsOG.getPlugin(), () -> {
|
||||
// Multiply the velocity by how far the player is looking up or down.
|
||||
final double velocityMult;
|
||||
final double lookPitch = Location.normalizePitch(playerLocation.getPitch());
|
||||
velocityMult = Math.abs(lookPitch - 90) / 90;
|
||||
|
||||
// max out the number of particles at 50
|
||||
player.getWorld().spawnParticle(Particle.SPELL, player.getLocation(),
|
||||
(int) Math.min(xPower * zPower * playerParticleMult, 50));
|
||||
// Get the unit vector for the x,z directions.
|
||||
final Vector directionVector = playerLocation.getDirection();
|
||||
|
||||
}, j);
|
||||
// Get the xpower, ypower, and zpower.
|
||||
final double xPower = padConfig.getDouble(i + ".xpower");
|
||||
final double yPower = padConfig.getDouble(i + ".ypower");
|
||||
final double zPower = padConfig.getDouble(i + ".zpower");
|
||||
|
||||
}
|
||||
final double vx = xPower * directionVector.getX() * velocityMult;
|
||||
final double vy = yPower * ySpeed;
|
||||
final double vz = zPower * directionVector.getZ() * velocityMult;
|
||||
|
||||
// add the player to the launchedPlayers list
|
||||
// 1 tick later so that the player is off the ground
|
||||
// and isn't removed immediately
|
||||
Bukkit.getScheduler().runTaskLater(LaunchPadsOG.getPlugin(), () -> {
|
||||
player.setVelocity(new Vector(/* x */ vx, /* y */ vy, /* z */ vz));
|
||||
|
||||
// check if the player is in survival. Otherwise, don't add them
|
||||
if (player.getGameMode().equals(GameMode.SURVIVAL)) {
|
||||
// Spawn particles at the launch pad.
|
||||
final Location padLocation = new Location(player.getWorld(), padConfig.getInt(i + ".x") + 0.5,
|
||||
padConfig.getInt(i + ".y"), padConfig.getInt(i + ".z") + 0.5);
|
||||
|
||||
LaunchPadsOG.getLaunchedPlayers().add(player);
|
||||
// Hive java style launchpad woosh (audible to nearby players, fades with
|
||||
// distance).
|
||||
final float basePitch = (float) Math.max(1.62, Math.min(1.99, 1.80 + (velocityMult * 0.18)));
|
||||
final float treblePitch = Math.min(2.0f, basePitch + 0.22f);
|
||||
|
||||
}
|
||||
for (int t = 0; t < 6; t++) {
|
||||
|
||||
}, 1);
|
||||
final int delay = t;
|
||||
|
||||
}
|
||||
Bukkit.getScheduler().runTaskLater(LaunchPadsOG.getPlugin(), () -> {
|
||||
|
||||
}
|
||||
final float falloff = Math.max(0.0f, 1.0f - (delay * 0.16f));
|
||||
|
||||
final float jitter = ((delay & 1) == 0) ? 0.06f : -0.03f;
|
||||
final float pMain = Math.max(0.5f, Math.min(2.0f, basePitch + jitter));
|
||||
final float pTreble = Math.max(0.5f, Math.min(2.0f, treblePitch + jitter));
|
||||
|
||||
player.getWorld().playSound(padLocation, Sound.ENTITY_WITHER_SHOOT, 0.34f * falloff, pMain);
|
||||
player.getWorld().playSound(padLocation, Sound.ENTITY_GHAST_SHOOT, 0.20f * falloff, pTreble);
|
||||
|
||||
player.getWorld().playSound(padLocation, Sound.ENTITY_BAT_TAKEOFF, 0.16f * falloff, 2.0f);
|
||||
player.getWorld().playSound(padLocation, Sound.ENTITY_BLAZE_SHOOT, 0.10f * falloff, 2.0f);
|
||||
|
||||
}, delay);
|
||||
|
||||
}
|
||||
|
||||
final double padParticleCount = padConfig.getDouble("padLaunchParticleCount");
|
||||
final double padParticlePower = padConfig.getDouble("padLaunchParticlePower");
|
||||
player.spawnParticle(Particle.FIREWORKS_SPARK, padLocation, (int) padParticleCount, 0, 0, 0,
|
||||
0.2 * padParticlePower);
|
||||
|
||||
final double playerParticleMult = padConfig.getDouble("playerLaunchParticleCountMultipier");
|
||||
|
||||
// Spawn particles on the player as they fly through the air
|
||||
// This equation was gotten with a linear regression on different amounts of
|
||||
// yPower
|
||||
// to find what the vertex of the player's jump is
|
||||
// maxes out at 25 ticks
|
||||
// \/ --------- \/
|
||||
for (int j = 0; j < Math.min(yPower * 8 - 15, 25); j++) {
|
||||
|
||||
// Max out the number of particles at 50
|
||||
Bukkit.getScheduler().runTaskLater(LaunchPadsOG.getPlugin(),
|
||||
() -> player.getWorld().spawnParticle(Particle.SPELL, player.getLocation(),
|
||||
(int) Math.min(xPower * zPower * playerParticleMult, 50)),
|
||||
j);
|
||||
|
||||
}
|
||||
|
||||
// Add the player to the launchedPlayers list
|
||||
// 1 tick later so that the player is off the ground
|
||||
// and isn't removed immediately,
|
||||
Bukkit.getScheduler().runTaskLater(LaunchPadsOG.getPlugin(), () -> {
|
||||
|
||||
// Check if the player is in survival. Otherwise, don't add them
|
||||
if (player.getGameMode().equals(GameMode.SURVIVAL)) {
|
||||
|
||||
LaunchPadsOG.getLaunchedPlayers().add(player);
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
}, 1);
|
||||
|
||||
break;
|
||||
|
||||
}
|
||||
|
||||
@@ -148,4 +182,4 @@ public class OnPlayerMove implements Listener {
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
@@ -1,8 +1,7 @@
|
||||
package net.trueog.launchpadsog;
|
||||
|
||||
import java.util.Collections;
|
||||
import net.kyori.adventure.text.Component;
|
||||
import net.kyori.adventure.text.format.TextDecoration;
|
||||
|
||||
import org.bukkit.Bukkit;
|
||||
import org.bukkit.Material;
|
||||
import org.bukkit.NamespacedKey;
|
||||
@@ -11,9 +10,12 @@ import org.bukkit.inventory.ItemStack;
|
||||
import org.bukkit.inventory.ShapedRecipe;
|
||||
import org.bukkit.inventory.meta.ItemMeta;
|
||||
|
||||
import net.kyori.adventure.text.Component;
|
||||
import net.kyori.adventure.text.format.TextDecoration;
|
||||
|
||||
public class Recipes {
|
||||
|
||||
private static java.util.Vector<Component> loreList = new java.util.Vector<>();
|
||||
private static final java.util.Vector<Component> loreList = new java.util.Vector<>();
|
||||
private static ItemStack launcherBase;
|
||||
private static ItemStack launcherLaunch;
|
||||
private static ItemStack launcherExploder;
|
||||
@@ -22,7 +24,7 @@ public class Recipes {
|
||||
public static void addLauncherBase() {
|
||||
|
||||
launcherBase = new ItemStack(Material.PISTON);
|
||||
ItemMeta baseMeta = launcherBase.getItemMeta();
|
||||
final ItemMeta baseMeta = launcherBase.getItemMeta();
|
||||
|
||||
baseMeta.displayName(Component.text("Launcher Base").decorate(TextDecoration.ITALIC));
|
||||
|
||||
@@ -37,8 +39,8 @@ public class Recipes {
|
||||
|
||||
launcherBase.setItemMeta(baseMeta);
|
||||
|
||||
NamespacedKey baseKey = new NamespacedKey(LaunchPadsOG.getPlugin(), "launcherBase");
|
||||
ShapedRecipe baseRecipe = new ShapedRecipe(baseKey, launcherBase);
|
||||
final NamespacedKey baseKey = new NamespacedKey(LaunchPadsOG.getPlugin(), "launcherBase");
|
||||
final ShapedRecipe baseRecipe = new ShapedRecipe(baseKey, launcherBase);
|
||||
baseRecipe.shape("iii", "grg");
|
||||
baseRecipe.setIngredient('i', Material.IRON_BLOCK);
|
||||
baseRecipe.setIngredient('g', Material.GOLD_BLOCK);
|
||||
@@ -51,7 +53,7 @@ public class Recipes {
|
||||
public static void addLauncherLauncher() {
|
||||
|
||||
launcherLaunch = new ItemStack(Material.DISPENSER);
|
||||
ItemMeta launchMeta = launcherLaunch.getItemMeta();
|
||||
final ItemMeta launchMeta = launcherLaunch.getItemMeta();
|
||||
|
||||
launchMeta.displayName(Component.text("Launcher").decorate(TextDecoration.ITALIC));
|
||||
|
||||
@@ -60,14 +62,14 @@ public class Recipes {
|
||||
loreList.add(Component.text("a launchpad"));
|
||||
launchMeta.lore(Collections.list(loreList.elements()));
|
||||
|
||||
// add a useless enchantment to the item to make it
|
||||
// stand out in the inventory
|
||||
// Add a useless enchantment to the item to make it
|
||||
// stand out in the inventory.
|
||||
launchMeta.addEnchant(Enchantment.PROTECTION_ENVIRONMENTAL, 1, false);
|
||||
|
||||
launcherLaunch.setItemMeta(launchMeta);
|
||||
|
||||
NamespacedKey armKey = new NamespacedKey(LaunchPadsOG.getPlugin(), "launcherArm");
|
||||
ShapedRecipe armRecipe = new ShapedRecipe(armKey, launcherLaunch);
|
||||
final NamespacedKey armKey = new NamespacedKey(LaunchPadsOG.getPlugin(), "launcherArm");
|
||||
final ShapedRecipe armRecipe = new ShapedRecipe(armKey, launcherLaunch);
|
||||
armRecipe.shape(" s", " ib", "i ");
|
||||
armRecipe.setIngredient('s', Material.STRING);
|
||||
armRecipe.setIngredient('i', Material.IRON_BLOCK);
|
||||
@@ -80,7 +82,7 @@ public class Recipes {
|
||||
public static void addLauncherExploder() {
|
||||
|
||||
launcherExploder = new ItemStack(Material.TNT);
|
||||
ItemMeta exploderMeta = launcherExploder.getItemMeta();
|
||||
final ItemMeta exploderMeta = launcherExploder.getItemMeta();
|
||||
|
||||
exploderMeta.displayName(Component.text("Launcher Exploder").decorate(TextDecoration.ITALIC));
|
||||
|
||||
@@ -89,14 +91,14 @@ public class Recipes {
|
||||
loreList.add(Component.text("a launchpad"));
|
||||
exploderMeta.lore(Collections.list(loreList.elements()));
|
||||
|
||||
// add a useless enchantment to the item to make it
|
||||
// stand out in the inventory
|
||||
// Add a useless enchantment to the item to make it
|
||||
// stand out in the inventory.
|
||||
exploderMeta.addEnchant(Enchantment.PROTECTION_ENVIRONMENTAL, 1, false);
|
||||
|
||||
launcherExploder.setItemMeta(exploderMeta);
|
||||
|
||||
NamespacedKey exploderKey = new NamespacedKey(LaunchPadsOG.getPlugin(), "launcherExploder");
|
||||
ShapedRecipe exploderRecipe = new ShapedRecipe(exploderKey, launcherExploder);
|
||||
final NamespacedKey exploderKey = new NamespacedKey(LaunchPadsOG.getPlugin(), "launcherExploder");
|
||||
final ShapedRecipe exploderRecipe = new ShapedRecipe(exploderKey, launcherExploder);
|
||||
exploderRecipe.shape("ttt", "tbt", "ttt");
|
||||
exploderRecipe.setIngredient('t', Material.TNT);
|
||||
exploderRecipe.setIngredient('b', Material.TARGET);
|
||||
@@ -108,7 +110,7 @@ public class Recipes {
|
||||
public static void addLauncherActivator() {
|
||||
|
||||
launcherActivator = new ItemStack(Material.TRIPWIRE_HOOK);
|
||||
ItemMeta activatorMeta = launcherActivator.getItemMeta();
|
||||
final ItemMeta activatorMeta = launcherActivator.getItemMeta();
|
||||
|
||||
activatorMeta.displayName(Component.text("Launcher Activator").decorate(TextDecoration.ITALIC));
|
||||
|
||||
@@ -117,14 +119,14 @@ public class Recipes {
|
||||
loreList.add(Component.text("a launchpad"));
|
||||
activatorMeta.lore(Collections.list(loreList.elements()));
|
||||
|
||||
// add a useless enchantment to the item to make it
|
||||
// stand out in the inventory
|
||||
// Add a useless enchantment to the item to make it
|
||||
// stand out in the inventory.
|
||||
activatorMeta.addEnchant(Enchantment.PROTECTION_ENVIRONMENTAL, 1, false);
|
||||
|
||||
launcherActivator.setItemMeta(activatorMeta);
|
||||
|
||||
NamespacedKey activatorKey = new NamespacedKey(LaunchPadsOG.getPlugin(), "launcherActivator");
|
||||
ShapedRecipe activatorRecipe = new ShapedRecipe(activatorKey, launcherActivator);
|
||||
final NamespacedKey activatorKey = new NamespacedKey(LaunchPadsOG.getPlugin(), "launcherActivator");
|
||||
final ShapedRecipe activatorRecipe = new ShapedRecipe(activatorKey, launcherActivator);
|
||||
activatorRecipe.shape("rrr", "rdr", "rrr");
|
||||
activatorRecipe.setIngredient('r', Material.REDSTONE_BLOCK);
|
||||
activatorRecipe.setIngredient('d', Material.DIAMOND_BLOCK);
|
||||
@@ -135,8 +137,8 @@ public class Recipes {
|
||||
|
||||
public static void addLaunchPad() {
|
||||
|
||||
ItemStack launchPad = new ItemStack(Material.STONE_PRESSURE_PLATE);
|
||||
ItemMeta padMeta = launchPad.getItemMeta();
|
||||
final ItemStack launchPad = new ItemStack(Material.STONE_PRESSURE_PLATE);
|
||||
final ItemMeta padMeta = launchPad.getItemMeta();
|
||||
|
||||
padMeta.displayName(Component.text("Launch Pad").decorate(TextDecoration.ITALIC));
|
||||
|
||||
@@ -145,14 +147,14 @@ public class Recipes {
|
||||
loreList.add(Component.text("direction you are facing"));
|
||||
padMeta.lore(Collections.list(loreList.elements()));
|
||||
|
||||
// add a useless enchantment to the item to make it
|
||||
// stand out in the inventory
|
||||
// Add a useless enchantment to the item to make it
|
||||
// stand out in the inventory.
|
||||
padMeta.addEnchant(Enchantment.PROTECTION_ENVIRONMENTAL, 1, false);
|
||||
|
||||
launchPad.setItemMeta(padMeta);
|
||||
|
||||
NamespacedKey padKey = new NamespacedKey(LaunchPadsOG.getPlugin(), "launchPad");
|
||||
ShapedRecipe padRecipe = new ShapedRecipe(padKey, launchPad);
|
||||
final NamespacedKey padKey = new NamespacedKey(LaunchPadsOG.getPlugin(), "launchPad");
|
||||
final ShapedRecipe padRecipe = new ShapedRecipe(padKey, launchPad);
|
||||
padRecipe.shape("gng", "geg", "lba");
|
||||
padRecipe.setIngredient('g', Material.GOLD_BLOCK);
|
||||
padRecipe.setIngredient('n', Material.NOTE_BLOCK);
|
||||
@@ -165,4 +167,4 @@ public class Recipes {
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
Reference in new issue
Block a user