1.5 Update

This commit is contained in:
NotAlexNoyle committed 2024-10-25 17:37:49 +00:00
1 parent 92126c62df
commit 1c624cd02b
25 files changed
+1805 -1690

No files matched your search

+23
View File
@@ -0,0 +1,23 @@
<?xml version="1.0" encoding="UTF-8"?>
<classpath>
<classpathentry kind="src" output="bin/main" path="src/main/java">
<attributes>
<attribute name="gradle_scope" value="main"/>
<attribute name="gradle_used_by_scope" value="main,test"/>
</attributes>
</classpathentry>
<classpathentry kind="src" output="bin/main" path="src/main/resources">
<attributes>
<attribute name="gradle_scope" value="main"/>
<attribute name="gradle_used_by_scope" value="main,test"/>
</attributes>
</classpathentry>
<classpathentry kind="con" path="org.eclipse.jdt.launching.JRE_CONTAINER/org.eclipse.jdt.internal.debug.ui.launcher.StandardVMType/JavaSE-17/"/>
<classpathentry kind="con" path="org.eclipse.buildship.core.gradleclasspathcontainer"/>
<classpathentry kind="src" path="/Utilities-OG">
<attributes>
<attribute name="without_test_code" value="true"/>
</attributes>
</classpathentry>
<classpathentry kind="output" path="bin/default"/>
</classpath>
+23
View File
@@ -0,0 +1,23 @@
<?xml version="1.0" encoding="UTF-8"?>
<projectDescription>
<name>LaunchPads-OG</name>
<comment></comment>
<projects>
</projects>
<buildSpec>
<buildCommand>
<name>org.eclipse.jdt.core.javabuilder</name>
<arguments>
</arguments>
</buildCommand>
<buildCommand>
<name>org.eclipse.buildship.core.gradleprojectbuilder</name>
<arguments>
</arguments>
</buildCommand>
</buildSpec>
<natures>
<nature>org.eclipse.jdt.core.javanature</nature>
<nature>org.eclipse.buildship.core.gradleprojectnature</nature>
</natures>
</projectDescription>
@@ -0,0 +1,13 @@
arguments=
auto.sync=false
build.scans.enabled=true
connection.gradle.distribution=GRADLE_DISTRIBUTION(WRAPPER)
connection.project.dir=
eclipse.preferences.version=1
gradle.user.home=
java.home=
jvm.arguments=
offline.mode=true
override.workspace.settings=false
show.console.view=false
show.executions.view=false
+13
View File
@@ -0,0 +1,13 @@
#
#Fri Oct 25 06:52:03 UTC 2024
org.eclipse.jdt.core.compiler.codegen.inlineJsrBytecode=enabled
org.eclipse.jdt.core.compiler.problem.assertIdentifier=error
org.eclipse.jdt.core.compiler.codegen.targetPlatform=17
org.eclipse.jdt.core.compiler.source=17
org.eclipse.jdt.core.compiler.debug.localVariable=generate
org.eclipse.jdt.core.compiler.codegen.unusedLocal=preserve
eclipse.preferences.version=1
org.eclipse.jdt.core.compiler.problem.enumIdentifier=error
org.eclipse.jdt.core.compiler.debug.lineNumber=generate
org.eclipse.jdt.core.compiler.compliance=17
org.eclipse.jdt.core.compiler.debug.sourceFile=generate
Executable
+4
View File
@@ -0,0 +1,4 @@
#!/usr/bin/bash
# Fetch all submodule content.
git submodule update --force --recursive --init --remote
-80
View File
@@ -1,80 +0,0 @@
plugins {
id "java" // Tell gradle this is a java project.
id "com.github.johnrengelman.shadow" version "7.1.2" // Import utility to package libraries into .jar file.
}
group = "me.Barny1094875"
version = "1.4"
def apiVersion = "1.19.4" // Declare minecraft server target version.
def targetJavaVersion = 17 // Declare java compatibility minimum.
apply plugin: "eclipse" // Enable integration with Eclipse IDE for development.
processResources {
def props = [
version: version,
apiVersion: apiVersion,
]
inputs.properties props // Indicates to rerun if version changes.
filesMatching("plugin.yml") {
expand props
}
}
repositories {
mavenCentral()
maven {
url "https://repo.purpurmc.org/snapshots" // Get purpur API from purpur maven repository.
}
}
dependencies {
implementation 'org.projectlombok:lombok:1.18.22'
compileOnly "org.purpurmc.purpur:purpur-api:1.19.4-R0.1-SNAPSHOT" // Declare purpur API version to be packaged.
implementation 'com.google.code.gson:gson:2.10.1'
implementation "net.kyori:adventure-text-minimessage:4.13.1"
}
shadowJar {
minimize()
}
jar.dependsOn shadowJar
tasks.jar.configure {
classifier = "part"
}
tasks.shadowJar.configure {
classifier = null
}
compileJava {
options.compilerArgs += ["-parameters"]
options.fork = true
options.forkOptions.executable = 'javac'
}
+83
View File
@@ -0,0 +1,83 @@
plugins {
id("com.gradleup.shadow") version "8.3.2" // Import shadow API.
java // Tell gradle this is a java project.
eclipse // Import eclipse plugin for IDE integration.
kotlin("jvm") version "2.0.20" // Import kotlin jvm plugin for kotlin/java integration.
}
java {
// Declare java version.
sourceCompatibility = JavaVersion.VERSION_17
}
group = "net.trueog.launchpadsog" // Declare bundle identifier.
version = "1.5" // Declare plugin version (will be in .jar).
val apiVersion = "1.19" // Declare minecraft server target version.
tasks.named<ProcessResources>("processResources") {
val props = mapOf(
"version" to version,
"apiVersion" to apiVersion
)
inputs.properties(props) // Indicates to rerun if version changes.
filesMatching("plugin.yml") {
expand(props)
}
}
repositories {
mavenCentral()
gradlePluginPortal()
maven {
url = uri("https://repo.purpurmc.org/snapshots")
}
}
dependencies {
compileOnly("org.purpurmc.purpur:purpur-api:1.19.4-R0.1-SNAPSHOT") // Declare purpur API version to be packaged.
compileOnly("io.github.miniplaceholders:miniplaceholders-api:2.2.3") // Import MiniPlaceholders API.
implementation("com.google.code.gson:gson:2.10.1")
implementation(project(":libs:Utilities-OG"))
}
tasks.withType<AbstractArchiveTask>().configureEach { // Ensure reproducible builds.
isPreserveFileTimestamps = false
isReproducibleFileOrder = true
}
tasks.shadowJar {
archiveClassifier.set("") // Use empty string instead of null
from("LICENSE") {
into("/")
}
exclude("io.github.miniplaceholders.*") // Exclude the MiniPlaceholders package from being shadowed.
minimize()
}
tasks.build {
dependsOn(tasks.shadowJar)
}
tasks.jar {
archiveClassifier.set("part")
}
tasks.withType<JavaCompile>().configureEach {
options.compilerArgs.add("-parameters")
options.compilerArgs.add("-Xlint:deprecation") // Triggers deprecation warning messages.
options.encoding = "UTF-8"
options.isFork = true
}
kotlin {
jvmToolchain(17)
}
java {
toolchain {
languageVersion = JavaLanguageVersion.of(17)
vendor = JvmVendorSpec.GRAAL_VM
}
}
+1 -1
View File
@@ -1,5 +1,5 @@
distributionBase=GRADLE_USER_HOME
distributionPath=wrapper/dists
distributionUrl=https\://services.gradle.org/distributions/gradle-7.3.3-bin.zip
distributionUrl=https\://services.gradle.org/distributions/gradle-8.8-bin.zip
zipStoreBase=GRADLE_USER_HOME
zipStorePath=wrapper/dists
Vendored Regular → Executable
+5 -5
View File
@@ -1,7 +1,7 @@
#!/bin/sh
#
# Copyright © 2015-2021 the original authors.
# Copyright © 2015-2021 the original authors.
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
@@ -32,10 +32,10 @@
# Busybox and similar reduced shells will NOT work, because this script
# requires all of these POSIX shell features:
# * functions;
# * expansions «$var», «${var}», «${var:-default}», «${var+SET}»,
# «${var#prefix}», «${var%suffix}», and «$( cmd )»;
# * compound commands having a testable exit status, especially «case»;
# * various built-in commands including «command», «set», and «ulimit».
# * expansions «$var», «${var}», «${var:-default}», «${var+SET}»,
# «${var#prefix}», «${var%suffix}», and «$( cmd )»;
# * compound commands having a testable exit status, especially «case»;
# * various built-in commands including «command», «set», and «ulimit».
#
# Important for patching:
#
Vendored
+89 -89
View File
@@ -1,89 +1,89 @@
@rem
@rem Copyright 2015 the original author or authors.
@rem
@rem Licensed under the Apache License, Version 2.0 (the "License");
@rem you may not use this file except in compliance with the License.
@rem You may obtain a copy of the License at
@rem
@rem https://www.apache.org/licenses/LICENSE-2.0
@rem
@rem Unless required by applicable law or agreed to in writing, software
@rem distributed under the License is distributed on an "AS IS" BASIS,
@rem WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
@rem See the License for the specific language governing permissions and
@rem limitations under the License.
@rem
@if "%DEBUG%" == "" @echo off
@rem ##########################################################################
@rem
@rem Gradle startup script for Windows
@rem
@rem ##########################################################################
@rem Set local scope for the variables with windows NT shell
if "%OS%"=="Windows_NT" setlocal
set DIRNAME=%~dp0
if "%DIRNAME%" == "" set DIRNAME=.
set APP_BASE_NAME=%~n0
set APP_HOME=%DIRNAME%
@rem Resolve any "." and ".." in APP_HOME to make it shorter.
for %%i in ("%APP_HOME%") do set APP_HOME=%%~fi
@rem Add default JVM options here. You can also use JAVA_OPTS and GRADLE_OPTS to pass JVM options to this script.
set DEFAULT_JVM_OPTS="-Xmx64m" "-Xms64m"
@rem Find java.exe
if defined JAVA_HOME goto findJavaFromJavaHome
set JAVA_EXE=java.exe
%JAVA_EXE% -version >NUL 2>&1
if "%ERRORLEVEL%" == "0" goto execute
echo.
echo ERROR: JAVA_HOME is not set and no 'java' command could be found in your PATH.
echo.
echo Please set the JAVA_HOME variable in your environment to match the
echo location of your Java installation.
goto fail
:findJavaFromJavaHome
set JAVA_HOME=%JAVA_HOME:"=%
set JAVA_EXE=%JAVA_HOME%/bin/java.exe
if exist "%JAVA_EXE%" goto execute
echo.
echo ERROR: JAVA_HOME is set to an invalid directory: %JAVA_HOME%
echo.
echo Please set the JAVA_HOME variable in your environment to match the
echo location of your Java installation.
goto fail
:execute
@rem Setup the command line
set CLASSPATH=%APP_HOME%\gradle\wrapper\gradle-wrapper.jar
@rem Execute Gradle
"%JAVA_EXE%" %DEFAULT_JVM_OPTS% %JAVA_OPTS% %GRADLE_OPTS% "-Dorg.gradle.appname=%APP_BASE_NAME%" -classpath "%CLASSPATH%" org.gradle.wrapper.GradleWrapperMain %*
:end
@rem End local scope for the variables with windows NT shell
if "%ERRORLEVEL%"=="0" goto mainEnd
:fail
rem Set variable GRADLE_EXIT_CONSOLE if you need the _script_ return code instead of
rem the _cmd.exe /c_ return code!
if not "" == "%GRADLE_EXIT_CONSOLE%" exit 1
exit /b 1
:mainEnd
if "%OS%"=="Windows_NT" endlocal
:omega
@rem
@rem Copyright 2015 the original author or authors.
@rem
@rem Licensed under the Apache License, Version 2.0 (the "License");
@rem you may not use this file except in compliance with the License.
@rem You may obtain a copy of the License at
@rem
@rem https://www.apache.org/licenses/LICENSE-2.0
@rem
@rem Unless required by applicable law or agreed to in writing, software
@rem distributed under the License is distributed on an "AS IS" BASIS,
@rem WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
@rem See the License for the specific language governing permissions and
@rem limitations under the License.
@rem
@if "%DEBUG%" == "" @echo off
@rem ##########################################################################
@rem
@rem Gradle startup script for Windows
@rem
@rem ##########################################################################
@rem Set local scope for the variables with windows NT shell
if "%OS%"=="Windows_NT" setlocal
set DIRNAME=%~dp0
if "%DIRNAME%" == "" set DIRNAME=.
set APP_BASE_NAME=%~n0
set APP_HOME=%DIRNAME%
@rem Resolve any "." and ".." in APP_HOME to make it shorter.
for %%i in ("%APP_HOME%") do set APP_HOME=%%~fi
@rem Add default JVM options here. You can also use JAVA_OPTS and GRADLE_OPTS to pass JVM options to this script.
set DEFAULT_JVM_OPTS="-Xmx64m" "-Xms64m"
@rem Find java.exe
if defined JAVA_HOME goto findJavaFromJavaHome
set JAVA_EXE=java.exe
%JAVA_EXE% -version >NUL 2>&1
if "%ERRORLEVEL%" == "0" goto execute
echo.
echo ERROR: JAVA_HOME is not set and no 'java' command could be found in your PATH.
echo.
echo Please set the JAVA_HOME variable in your environment to match the
echo location of your Java installation.
goto fail
:findJavaFromJavaHome
set JAVA_HOME=%JAVA_HOME:"=%
set JAVA_EXE=%JAVA_HOME%/bin/java.exe
if exist "%JAVA_EXE%" goto execute
echo.
echo ERROR: JAVA_HOME is set to an invalid directory: %JAVA_HOME%
echo.
echo Please set the JAVA_HOME variable in your environment to match the
echo location of your Java installation.
goto fail
:execute
@rem Setup the command line
set CLASSPATH=%APP_HOME%\gradle\wrapper\gradle-wrapper.jar
@rem Execute Gradle
"%JAVA_EXE%" %DEFAULT_JVM_OPTS% %JAVA_OPTS% %GRADLE_OPTS% "-Dorg.gradle.appname=%APP_BASE_NAME%" -classpath "%CLASSPATH%" org.gradle.wrapper.GradleWrapperMain %*
:end
@rem End local scope for the variables with windows NT shell
if "%ERRORLEVEL%"=="0" goto mainEnd
:fail
rem Set variable GRADLE_EXIT_CONSOLE if you need the _script_ return code instead of
rem the _cmd.exe /c_ return code!
if not "" == "%GRADLE_EXIT_CONSOLE%" exit 1
exit /b 1
:mainEnd
if "%OS%"=="Windows_NT" endlocal
:omega
+17
View File
@@ -0,0 +1,17 @@
<?xml version="1.0" encoding="UTF-8"?>
<projectDescription>
<name>LaunchPads-OG-libs</name>
<comment>Project LaunchPads-OG-libs created by Buildship.</comment>
<projects>
</projects>
<buildSpec>
<buildCommand>
<name>org.eclipse.buildship.core.gradleprojectbuilder</name>
<arguments>
</arguments>
</buildCommand>
</buildSpec>
<natures>
<nature>org.eclipse.buildship.core.gradleprojectnature</nature>
</natures>
</projectDescription>
@@ -0,0 +1,2 @@
connection.project.dir=..
eclipse.preferences.version=1
-1
View File
@@ -1 +0,0 @@
rootProject.name = 'LaunchPad'
+9
View File
@@ -0,0 +1,9 @@
rootProject.name = "LaunchPads-OG"
// Execute bootstrap.sh
exec {
workingDir(rootDir)
commandLine("sh", "bootstrap.sh")
}
include("libs:Utilities-OG")
@@ -1,4 +1,8 @@
package me.barny1094875.launchpad.Commands;
package net.trueog.launchpadsog.Commands;
import java.util.ArrayList;
import java.util.Collections;
import java.util.List;
import org.bukkit.command.Command;
import org.bukkit.command.CommandSender;
@@ -6,46 +10,42 @@ import org.bukkit.command.TabCompleter;
import org.jetbrains.annotations.NotNull;
import org.jetbrains.annotations.Nullable;
import java.util.ArrayList;
import java.util.Collections;
import java.util.List;
public class LaunchPadCommandCompleter implements TabCompleter {
@Override
public @Nullable List<String> onTabComplete(@NotNull CommandSender sender, @NotNull Command command, @NotNull String label, @NotNull String[] args) {
@Override
public @Nullable List<String> onTabComplete(@NotNull CommandSender sender, @NotNull Command command, @NotNull String label, @NotNull String[] args) {
if(args.length == 1){
if(args.length == 1){
// build the list to return
ArrayList<String> result = new ArrayList<>();
result.add("set");
result.add("give");
result.add("delete");
result.add("reloadconfig");
result.add("help");
// build the list to return
ArrayList<String> result = new ArrayList<>();
result.add("set");
result.add("give");
result.add("delete");
result.add("reloadconfig");
result.add("help");
// sort the list
Collections.sort(result);
// sort the list
Collections.sort(result);
return result;
return result;
}
else if(args.length == 2){
if(args[0].equalsIgnoreCase("help")){
// build the list to return
ArrayList<String> result = new ArrayList<>();
result.add("set");
result.add("delete");
}
else if(args.length == 2){
if(args[0].equalsIgnoreCase("help")){
// build the list to return
ArrayList<String> result = new ArrayList<>();
result.add("set");
result.add("delete");
// sort the list
Collections.sort(result);
// sort the list
Collections.sort(result);
return result;
}
}
return result;
}
}
return null;
}
return null;
}
}
}
File diff suppressed because it is too large. Load diff
@@ -1,9 +1,7 @@
package me.barny1094875.launchpad;
package net.trueog.launchpadsog;
import java.util.ArrayList;
import me.barny1094875.launchpad.Commands.LaunchPadCommandCompleter;
import me.barny1094875.launchpad.Commands.LaunchPadCommands;
import me.barny1094875.launchpad.Listeners.*;
import me.barny1094875.launchpad.config.Config;
import org.bukkit.Bukkit;
import org.bukkit.Location;
import org.bukkit.Particle;
@@ -11,134 +9,141 @@ import org.bukkit.World;
import org.bukkit.entity.Player;
import org.bukkit.plugin.java.JavaPlugin;
import java.util.ArrayList;
import net.trueog.launchpadsog.Commands.LaunchPadCommandCompleter;
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.OnPlayerMove;
import net.trueog.launchpadsog.config.Config;
public final class LaunchPad extends JavaPlugin {
public final class LaunchPadsOG extends JavaPlugin {
private static LaunchPad plugin;
private static Config config;
private static LaunchPadsOG plugin;
private static Config config;
// 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>();
// 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>();
@Override
public void onEnable() {
plugin = this;
@Override
public void onEnable() {
plugin = this;
// config stuff
config = new Config(this, this.getDataFolder(), "config", true, false);
// config stuff
config = new Config(this, this.getDataFolder(), "config", true, false);
// if this is the first time the plugin is run, set cancraft to false
if(config.getConfig().get("cancraft") == null){
config.getConfig().set("cancraft", false);
config.save();
}
// if this is the first time the plugin is run, set power values to defaults
// check for defaultXpower, defaultYpower, defaultZpower, and numberOfPads
if(config.getConfig().get("defaultXpower") == null){
config.getConfig().set("defaultXpower", 3.0);
config.save();
}
if(config.getConfig().get("defaultYpower") == null){
config.getConfig().set("defaultYpower", 4.0);
config.save();
}
if(config.getConfig().get("defaultZpower") == null){
config.getConfig().set("defaultZpower", 3.0);
config.save();
}
if(config.getConfig().get("numberOfPads") == null){
config.getConfig().set("numberOfPads", 0);
config.save();
}
// check for ambientParticleCount and ambientParticlePower
if(config.getConfig().get("idleParticleCount") == null){
config.getConfig().set("idleParticleCount", 4);
config.save();
}
if(config.getConfig().get("idleParticlePower") == null){
config.getConfig().set("idleParticlePower", 1.5);
config.save();
}
// check for padLaunchParticleCount and padLaunchParticlePower
if(config.getConfig().get("padLaunchParticleCount") == null){
config.getConfig().set("padLaunchParticleCount", 80);
config.save();
}
if(config.getConfig().get("padLaunchParticlePower") == null){
config.getConfig().set("padLaunchParticlePower", 1.0);
config.save();
}
// check for playerLaunchParticleCountMultiplier
if(config.getConfig().get("playerLaunchParticleCountMultipier") == null){
config.getConfig().set("playerLaunchParticleCountMultipier", 1.0);
config.save();
}
// if this is the first time the plugin is run, set cancraft to false
if(config.getConfig().get("cancraft") == null){
config.getConfig().set("cancraft", false);
config.save();
}
// if this is the first time the plugin is run, set power values to defaults
// check for defaultXpower, defaultYpower, defaultZpower, and numberOfPads
if(config.getConfig().get("defaultXpower") == null){
config.getConfig().set("defaultXpower", 3.0);
config.save();
}
if(config.getConfig().get("defaultYpower") == null){
config.getConfig().set("defaultYpower", 4.0);
config.save();
}
if(config.getConfig().get("defaultZpower") == null){
config.getConfig().set("defaultZpower", 3.0);
config.save();
}
if(config.getConfig().get("numberOfPads") == null){
config.getConfig().set("numberOfPads", 0);
config.save();
}
// check for ambientParticleCount and ambientParticlePower
if(config.getConfig().get("idleParticleCount") == null){
config.getConfig().set("idleParticleCount", 4);
config.save();
}
if(config.getConfig().get("idleParticlePower") == null){
config.getConfig().set("idleParticlePower", 1.5);
config.save();
}
// check for padLaunchParticleCount and padLaunchParticlePower
if(config.getConfig().get("padLaunchParticleCount") == null){
config.getConfig().set("padLaunchParticleCount", 80);
config.save();
}
if(config.getConfig().get("padLaunchParticlePower") == null){
config.getConfig().set("padLaunchParticlePower", 1.0);
config.save();
}
// check for playerLaunchParticleCountMultiplier
if(config.getConfig().get("playerLaunchParticleCountMultipier") == null){
config.getConfig().set("playerLaunchParticleCountMultipier", 1.0);
config.save();
}
// if the launchpad is craftable, add the recipe to the server
if((boolean) config.getConfig().get("cancraft")) {
// create the recipe for the launchpad
// make it really expensive by locking it
// behind many other crafting items
// if the launchpad is craftable, add the recipe to the server
if((boolean) config.getConfig().get("cancraft")) {
// create the recipe for the launchpad
// make it really expensive by locking it
// behind many other crafting items
// launcher base
Recipes.addLauncherBase();
// launcher launcher
Recipes.addLauncherLauncher();
// launcher explosion
Recipes.addLauncherExploder();
// launcher activator
Recipes.addLauncherActivator();
// final Launch Pad
Recipes.addLaunchPad();
}
// launcher base
Recipes.addLauncherBase();
// launcher launcher
Recipes.addLauncherLauncher();
// launcher explosion
Recipes.addLauncherExploder();
// launcher activator
Recipes.addLauncherActivator();
// final Launch Pad
Recipes.addLaunchPad();
}
getServer().getPluginManager().registerEvents(new OnPlayerMove(), 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());
getServer().getPluginManager().registerEvents(new OnPlayerMove(), 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
Bukkit.getScheduler().runTaskTimer(this, () -> {
for(int i = 1; i < config.getConfig().getInt("numberOfPads") + 1; i++){
// 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.getConfig().getInt("numberOfPads") + 1; i++){
String worldName = config.getConfig().getString(i + ".world");
World world = Bukkit.getWorld(worldName);
double padX = config.getConfig().getInt(i + ".x") + 0.5;
double padY = config.getConfig().getInt(i + ".y");
double padZ = config.getConfig().getInt(i + ".z") + 0.5;
Location padLocation = new Location(world, padX, padY, padZ);
int idleParticleCount = config.getConfig().getInt("idleParticleCount");
double idleParticlePower = config.getConfig().getDouble("idleParticlePower");
String worldName = config.getConfig().getString(i + ".world");
World world = Bukkit.getWorld(worldName);
double padX = config.getConfig().getInt(i + ".x") + 0.5;
double padY = config.getConfig().getInt(i + ".y");
double padZ = config.getConfig().getInt(i + ".z") + 0.5;
Location padLocation = new Location(world, padX, padY, padZ);
int idleParticleCount = config.getConfig().getInt("idleParticleCount");
double idleParticlePower = config.getConfig().getDouble("idleParticlePower");
// 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, 0.05 * idleParticlePower);
}
// 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, 0.05 * idleParticlePower);
}
}
}, 1, 30);
}
}, 1, 30);
}
}
public static LaunchPad getPlugin(){
return plugin;
}
public static LaunchPadsOG getPlugin(){
return plugin;
}
public static Config config(){
return config;
}
public static Config config(){
return config;
}
public static ArrayList<Player> getLaunchedPlayers(){
return launchedPlayers;
}
}
public static ArrayList<Player> getLaunchedPlayers(){
return launchedPlayers;
}
}
@@ -1,9 +1,8 @@
package me.barny1094875.launchpad.Listeners;
package net.trueog.launchpadsog.Listeners;
import java.util.Collections;
import java.util.Vector;
import me.barny1094875.launchpad.LaunchPad;
import me.barny1094875.launchpad.config.Config;
import net.kyori.adventure.text.Component;
import net.kyori.adventure.text.format.TextDecoration;
import org.bukkit.Material;
import org.bukkit.World;
import org.bukkit.block.Block;
@@ -16,98 +15,100 @@ import org.bukkit.event.block.BlockBreakEvent;
import org.bukkit.inventory.ItemStack;
import org.bukkit.inventory.meta.ItemMeta;
import java.util.Collections;
import java.util.Vector;
import net.kyori.adventure.text.Component;
import net.kyori.adventure.text.format.TextDecoration;
import net.trueog.launchpadsog.LaunchPadsOG;
import net.trueog.launchpadsog.config.Config;
public class OnBlockBreak implements Listener {
// check to see if the block broken was a launch pad
// if so, remove the launch pad from the config list
// and update all id numbers after that one
@EventHandler
public void onBlockBreakEvent(BlockBreakEvent event){
Config padConfig = LaunchPad.config();
FileConfiguration padCoords = padConfig.getConfig();
Block block = event.getBlock();
World world = block.getWorld();
Player player = event.getPlayer();
int numberOfPads = padCoords.getInt("numberOfPads");
// check to see if the block broken was a launch pad
// if so, remove the launch pad from the config list
// and update all id numbers after that one
@EventHandler
public void onBlockBreakEvent(BlockBreakEvent event){
Config padConfig = LaunchPadsOG.config();
FileConfiguration padCoords = padConfig.getConfig();
Block block = event.getBlock();
World world = block.getWorld();
Player player = event.getPlayer();
int numberOfPads = padCoords.getInt("numberOfPads");
// check if the launch pad is craftable. If so, then players can break launchpads
// to get them back/remove them
// also check if the player has the permission launchpad.canbreak
// if either of these are true, then allow the pad to be broken
// if(padCoords.getBoolean("cancraft") || player.hasPermission("launchpad.canbreak")) {
// check if the launch pad is craftable. If so, then players can break launchpads
// to get them back/remove them
// also check if the player has the permission launchpad.canbreak
// if either of these are true, then allow the pad to be broken
// if(padCoords.getBoolean("cancraft") || player.hasPermission("launchpad.canbreak")) {
for (int i = 1; i < numberOfPads + 1; i++) {
if (padCoords.getString("" + i + ".world").equals(world.getName())) {
if (padCoords.getInt("" + i + ".x") == block.getX()) {
if (padCoords.getInt("" + i + ".z") == block.getZ()) {
if (padCoords.getInt("" + i + ".y") == block.getY()) {
for (int i = 1; i < numberOfPads + 1; i++) {
if (padCoords.getString("" + i + ".world").equals(world.getName())) {
if (padCoords.getInt("" + i + ".x") == block.getX()) {
if (padCoords.getInt("" + i + ".z") == block.getZ()) {
if (padCoords.getInt("" + i + ".y") == block.getY()) {
// check if the launch pad is craftable. If so, then players can break launchpads
// to get them back/remove them
// also check if the player has the permission launchpad.canbreak
// if either of these are true, then allow the pad to be broken
if(padCoords.getBoolean("cancraft") || player.hasPermission("launchpad.canbreak")) {
// the block has the coordinates of this pad
// remove the pad from the list and move
// all other pads up one id number
for (int j = i; j < padCoords.getInt("numberOfPads") + 1; j++) {
padCoords.set("" + j + ".x", padCoords.getInt("" + (j + 1) + ".x"));
padCoords.set("" + j + ".y", padCoords.getInt("" + (j + 1) + ".y"));
padCoords.set("" + j + ".z", padCoords.getInt("" + (j + 1) + ".z"));
padCoords.set("" + j + ".world", padCoords.getString("" + (j + 1) + ".world"));
padCoords.set("" + j + ".xpower", padCoords.getDouble("" + (j + 1) + ".xpower"));
padCoords.set("" + j + ".ypower", padCoords.getDouble("" + (j + 1) + ".ypower"));
padCoords.set("" + j + ".zpower", padCoords.getDouble("" + (j + 1) + ".zpower"));
// this makes it easier to search the config file
// use CTRL+F and search for the coords of the pad
padCoords.set("" + j + ".searchID", padCoords.getString("" + (j + 1) + ".searchID"));
}
padCoords.set("" + numberOfPads, null);
padCoords.set("numberOfPads", numberOfPads - 1);
padConfig.save();
// check if the launch pad is craftable. If so, then players can break launchpads
// to get them back/remove them
// also check if the player has the permission launchpad.canbreak
// if either of these are true, then allow the pad to be broken
if(padCoords.getBoolean("cancraft") || player.hasPermission("launchpad.canbreak")) {
// the block has the coordinates of this pad
// remove the pad from the list and move
// all other pads up one id number
for (int j = i; j < padCoords.getInt("numberOfPads") + 1; j++) {
padCoords.set("" + j + ".x", padCoords.getInt("" + (j + 1) + ".x"));
padCoords.set("" + j + ".y", padCoords.getInt("" + (j + 1) + ".y"));
padCoords.set("" + j + ".z", padCoords.getInt("" + (j + 1) + ".z"));
padCoords.set("" + j + ".world", padCoords.getString("" + (j + 1) + ".world"));
padCoords.set("" + j + ".xpower", padCoords.getDouble("" + (j + 1) + ".xpower"));
padCoords.set("" + j + ".ypower", padCoords.getDouble("" + (j + 1) + ".ypower"));
padCoords.set("" + j + ".zpower", padCoords.getDouble("" + (j + 1) + ".zpower"));
// this makes it easier to search the config file
// use CTRL+F and search for the coords of the pad
padCoords.set("" + j + ".searchID", padCoords.getString("" + (j + 1) + ".searchID"));
}
padCoords.set("" + numberOfPads, null);
padCoords.set("numberOfPads", numberOfPads - 1);
padConfig.save();
// if the block there was a pressure plate,
// then a launch pad item was placed
// and therefore should be dropped
if (event.getBlock().getType() == Material.STONE_PRESSURE_PLATE) {
// create the launchpad item
Vector<Component> loreList = new java.util.Vector<>();
// if the block there was a pressure plate,
// then a launch pad item was placed
// and therefore should be dropped
if (event.getBlock().getType() == Material.STONE_PRESSURE_PLATE) {
// create the launchpad item
Vector<Component> loreList = new java.util.Vector<>();
ItemStack launchPad = new ItemStack(Material.STONE_PRESSURE_PLATE);
ItemMeta padMeta = launchPad.getItemMeta();
ItemStack launchPad = new ItemStack(Material.STONE_PRESSURE_PLATE);
ItemMeta padMeta = launchPad.getItemMeta();
padMeta.displayName(Component.text("Launch Pad")
.decorate(TextDecoration.ITALIC));
padMeta.displayName(Component.text("Launch Pad")
.decorate(TextDecoration.ITALIC));
loreList.add(Component.text("Launches you in the"));
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
padMeta.addEnchant(Enchantment.PROTECTION_ENVIRONMENTAL, 1, false);
launchPad.setItemMeta(padMeta);
loreList.add(Component.text("Launches you in the"));
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
padMeta.addEnchant(Enchantment.PROTECTION_ENVIRONMENTAL, 1, false);
launchPad.setItemMeta(padMeta);
// make sure that the pressure plate is not dropped
event.setDropItems(false);
// drop the launch pad item
world.dropItem(block.getLocation(), launchPad);
}
// make sure that the pressure plate is not dropped
event.setDropItems(false);
// drop the launch pad item
world.dropItem(block.getLocation(), launchPad);
}
break;
}
// if the player is not allowed to break the launchpad, cancel the event
else {
event.setCancelled(true);
}
}
}
}
}
}
// }
}
break;
}
// if the player is not allowed to break the launchpad, cancel the event
else {
event.setCancelled(true);
}
}
}
}
}
}
// }
}
}
}
@@ -1,8 +1,7 @@
package me.barny1094875.launchpad.Listeners;
package net.trueog.launchpadsog.Listeners;
import java.util.Vector;
import me.barny1094875.launchpad.LaunchPad;
import me.barny1094875.launchpad.config.Config;
import net.kyori.adventure.text.Component;
import org.bukkit.block.Block;
import org.bukkit.configuration.file.FileConfiguration;
import org.bukkit.event.EventHandler;
@@ -10,43 +9,45 @@ import org.bukkit.event.Listener;
import org.bukkit.event.block.BlockPlaceEvent;
import org.bukkit.inventory.ItemStack;
import java.util.Vector;
import net.kyori.adventure.text.Component;
import net.trueog.launchpadsog.LaunchPadsOG;
import net.trueog.launchpadsog.config.Config;
public class OnBlockPlace implements Listener {
@EventHandler
public void onBlockPlace(BlockPlaceEvent event){
ItemStack item = event.getItemInHand();
Block block = event.getBlockPlaced();
@EventHandler
public void onBlockPlace(BlockPlaceEvent event){
ItemStack item = event.getItemInHand();
Block block = event.getBlockPlaced();
Vector<Component> loreList = new Vector<>();
loreList.add(Component.text("Launches you in the"));
loreList.add(Component.text("direction you are facing"));
Vector<Component> loreList = new Vector<>();
loreList.add(Component.text("Launches you in the"));
loreList.add(Component.text("direction you are facing"));
// if the item placed was a launch pad
if(item.lore() != null) {
if (item.lore().equals(loreList)) {
Config padConfig = LaunchPad.config();
FileConfiguration padCoords = padConfig.getConfig();
int padNumber = padCoords.getInt("numberOfPads") + 1;
// if the item placed was a launch pad
if(item.lore() != null) {
if (item.lore().equals(loreList)) {
Config padConfig = LaunchPadsOG.config();
FileConfiguration padCoords = padConfig.getConfig();
int padNumber = padCoords.getInt("numberOfPads") + 1;
padCoords.set(padNumber + ".world", block.getWorld().getName());
padCoords.set(padNumber + ".x", block.getX());
padCoords.set(padNumber + ".y", block.getY());
padCoords.set(padNumber + ".z", block.getZ());
padCoords.set(padNumber + ".xpower", padCoords.getDouble("defaultXpower"));
padCoords.set(padNumber + ".ypower", padCoords.getDouble("defaultYpower"));
padCoords.set(padNumber + ".zpower", padCoords.getDouble("defaultZpower"));
// this makes it easier to search the config file
// use CTRL+F and search for the coords of the pad
padCoords.set(padNumber + ".searchID", block.getX() + " " + block.getY() + " " + block.getZ());
padCoords.set(padNumber + ".world", block.getWorld().getName());
padCoords.set(padNumber + ".x", block.getX());
padCoords.set(padNumber + ".y", block.getY());
padCoords.set(padNumber + ".z", block.getZ());
padCoords.set(padNumber + ".xpower", padCoords.getDouble("defaultXpower"));
padCoords.set(padNumber + ".ypower", padCoords.getDouble("defaultYpower"));
padCoords.set(padNumber + ".zpower", padCoords.getDouble("defaultZpower"));
// this makes it easier to search the config file
// use CTRL+F and search for the coords of the pad
padCoords.set(padNumber + ".searchID", block.getX() + " " + block.getY() + " " + block.getZ());
padCoords.set("numberOfPads", padNumber);
padCoords.set("numberOfPads", padNumber);
padConfig.save();
padConfig.save();
}
}
}
}
}
}
}
}
@@ -1,39 +1,36 @@
package me.barny1094875.launchpad.Listeners;
import me.barny1094875.launchpad.LaunchPad;
import org.bukkit.Bukkit;
import org.bukkit.entity.Player;
import org.bukkit.event.EventHandler;
import org.bukkit.event.EventPriority;
import org.bukkit.event.Listener;
import org.bukkit.event.entity.EntityDamageEvent;
import org.bukkit.potion.PotionEffect;
import org.bukkit.potion.PotionEffectType;
package net.trueog.launchpadsog.Listeners;
import java.util.ArrayList;
import org.bukkit.entity.Player;
import org.bukkit.event.EventHandler;
import org.bukkit.event.Listener;
import org.bukkit.event.entity.EntityDamageEvent;
import net.trueog.launchpadsog.LaunchPadsOG;
public class OnEntityDamage implements Listener {
// @EventHandler(priority = EventPriority.HIGHEST)
@EventHandler
public void onEntityDamage(EntityDamageEvent event){
// @EventHandler(priority = EventPriority.HIGHEST)
@EventHandler
public void onEntityDamage(EntityDamageEvent event){
// check if the damage was fall damage
if(event.getCause().equals(EntityDamageEvent.DamageCause.FALL)){
// check if the entity was a player
if(event.getEntity() instanceof Player) {
// check the entity was in the launchedPlayers list
ArrayList<Player> launchedList = LaunchPad.getLaunchedPlayers();
Player eventPlayer = (Player) event.getEntity();
if (launchedList.contains(eventPlayer)) {
event.setCancelled(true);
// check if the damage was fall damage
if(event.getCause().equals(EntityDamageEvent.DamageCause.FALL)){
// check if the entity was a player
if(event.getEntity() instanceof Player) {
// check the entity was in the launchedPlayers list
ArrayList<Player> launchedList = LaunchPadsOG.getLaunchedPlayers();
Player eventPlayer = (Player) event.getEntity();
if (launchedList.contains(eventPlayer)) {
event.setCancelled(true);
launchedList.remove(eventPlayer);
}
}
}
launchedList.remove(eventPlayer);
}
}
}
}
}
}
}
@@ -1,4 +1,4 @@
package me.barny1094875.launchpad.Listeners;
package net.trueog.launchpadsog.Listeners;
import org.bukkit.GameEvent;
import org.bukkit.entity.Player;
@@ -6,32 +6,31 @@ import org.bukkit.event.EventHandler;
import org.bukkit.event.Listener;
import org.bukkit.event.world.GenericGameEvent;
import me.barny1094875.launchpad.LaunchPad;
import net.trueog.launchpadsog.LaunchPadsOG;
public class OnGenericGameEvent implements Listener {
// use this event to see if the player hit the ground
// if they did, then we can check if they were launched
// this way, even if they don't take fall damage from the fall
// say, they were using an elytra,
// this will ensure that the OnEntityDamage event is still called
// to remove them from the launched player List
@EventHandler
public void onGenericGameEvent(GenericGameEvent event){
// check if the event was an entity hitting the ground
if(event.getEvent().equals(GameEvent.HIT_GROUND)){
// if the entity was a player
if(event.getEntity() instanceof Player){
Player player = (Player) event.getEntity();
// use this event to see if the player hit the ground
// if they did, then we can check if they were launched
// this way, even if they don't take fall damage from the fall
// say, they were using an elytra,
// this will ensure that the OnEntityDamage event is still called
// to remove them from the launched player List
@EventHandler
public void onGenericGameEvent(GenericGameEvent event){
// check if the event was an entity hitting the ground
if(event.getEvent().equals(GameEvent.HIT_GROUND)){
// if the entity was a player
if(event.getEntity() instanceof Player){
Player player = (Player) event.getEntity();
// if the player was in the launched list
if(LaunchPad.getLaunchedPlayers().contains(player)) {
// set the player's fall distance to 4
player.setFallDistance(4.0f);
}
}
}
}
// if the player was in the launched list
if(LaunchPadsOG.getLaunchedPlayers().contains(player)) {
// set the player's fall distance to 4
player.setFallDistance(4.0f);
}
}
}
}
}
}
@@ -1,8 +1,10 @@
package me.barny1094875.launchpad.Listeners;
package net.trueog.launchpadsog.Listeners;
import me.barny1094875.launchpad.LaunchPad;
import org.bukkit.*;
import org.bukkit.block.Block;
import org.bukkit.Bukkit;
import org.bukkit.GameMode;
import org.bukkit.Location;
import org.bukkit.Particle;
import org.bukkit.Sound;
import org.bukkit.configuration.file.FileConfiguration;
import org.bukkit.entity.Player;
import org.bukkit.event.EventHandler;
@@ -10,115 +12,117 @@ import org.bukkit.event.Listener;
import org.bukkit.event.player.PlayerMoveEvent;
import org.bukkit.util.Vector;
import net.trueog.launchpadsog.LaunchPadsOG;
public class OnPlayerMove implements Listener {
@EventHandler
public void onPlayerMoveEvent(PlayerMoveEvent event){
if(event.hasChangedBlock()){
// loop through every launch pad and look for one that has the same coords as the player
FileConfiguration padConfig = LaunchPad.config().getConfig();
Player player = event.getPlayer();
String worldName = player.getWorld().getName();
for(int i = 1; i < padConfig.getInt("numberOfPads") + 1; i++){
// 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()){
// check y location
if(padConfig.getInt("" + i + ".y") == playerLocation.getBlockY()){
// check z location
if(padConfig.getInt("" + i + ".z") == playerLocation.getBlockZ()){
// 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();
@EventHandler
public void onPlayerMoveEvent(PlayerMoveEvent event){
if(event.hasChangedBlock()){
// loop through every launch pad and look for one that has the same coords as the player
FileConfiguration padConfig = LaunchPadsOG.config().getConfig();
Player player = event.getPlayer();
String worldName = player.getWorld().getName();
for(int i = 1; i < padConfig.getInt("numberOfPads") + 1; i++){
// 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()){
// check y location
if(padConfig.getInt("" + i + ".y") == playerLocation.getBlockY()){
// check z location
if(padConfig.getInt("" + i + ".z") == playerLocation.getBlockZ()){
// 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();
// 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){
ySpeed = 0.15;
}
// 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){
ySpeed = 0.15;
}
// add 0.25 to the ySpeed so that there is more movement,
// without reducing the effect of a jump
ySpeed += 0.25;
// add 0.25 to the ySpeed so that there is more movement,
// without reducing the effect of a jump
ySpeed += 0.25;
// if the player is crouching, reduce the velocity to 1/3
if(player.isSneaking()){
ySpeed /= 3;
}
// if the player is crouching, reduce the velocity to 1/3
if(player.isSneaking()){
ySpeed /= 3;
}
// 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;
// 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;
// get the unit vector for the x,z directions
Vector directionVector = playerLocation.getDirection();
// get the unit vector for the x,z directions
Vector directionVector = playerLocation.getDirection();
FileConfiguration launchConfig = LaunchPad.config().getConfig();
// get the xpower, ypower, and zpower
double xPower = launchConfig.getDouble(i + ".xpower");
double yPower = launchConfig.getDouble(i + ".ypower");
double zPower = launchConfig.getDouble(i + ".zpower");
FileConfiguration launchConfig = LaunchPadsOG.config().getConfig();
// get the xpower, ypower, and zpower
double xPower = launchConfig.getDouble(i + ".xpower");
double yPower = launchConfig.getDouble(i + ".ypower");
double zPower = launchConfig.getDouble(i + ".zpower");
player.setVelocity(new Vector(
/* x */ xPower * directionVector.getX() * velocityMult,
/* y */ yPower * ySpeed,
/* z */ zPower * directionVector.getZ() * velocityMult));
player.setVelocity(new Vector(
/* x */ xPower * directionVector.getX() * velocityMult,
/* y */ yPower * ySpeed,
/* z */ zPower * directionVector.getZ() * velocityMult));
// 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(),
launchConfig.getInt(i + ".x") + 0.5,
launchConfig.getInt(i + ".y"),
launchConfig.getInt(i + ".z") + 0.5);
double padParticleCount = launchConfig.getDouble("padLaunchParticleCount");
double padParticlePower = launchConfig.getDouble("padLaunchParticlePower");
player.spawnParticle(Particle.FIREWORKS_SPARK, padLocation, (int) padParticleCount, 0, 0, 0, 0.2 * padParticlePower);
// 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(),
launchConfig.getInt(i + ".x") + 0.5,
launchConfig.getInt(i + ".y"),
launchConfig.getInt(i + ".z") + 0.5);
double padParticleCount = launchConfig.getDouble("padLaunchParticleCount");
double padParticlePower = launchConfig.getDouble("padLaunchParticlePower");
player.spawnParticle(Particle.FIREWORKS_SPARK, padLocation, (int) padParticleCount, 0, 0, 0, 0.2 * padParticlePower);
double playerParticleMult = launchConfig.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(LaunchPad.getPlugin(), () -> {
// max out the number of particles at 50
player.getWorld().spawnParticle(Particle.SPELL, player.getLocation(), (int) Math.min(xPower * zPower * playerParticleMult, 50));
}, j);
}
double playerParticleMult = launchConfig.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(), () -> {
// max out the number of particles at 50
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(LaunchPad.getPlugin(), () -> {
// check if the player is in survival. Otherwise, don't add them
if(player.getGameMode().equals(GameMode.SURVIVAL)) {
LaunchPad.getLaunchedPlayers().add(player);
}
}, 1);
// 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);
}
}
}
}
}
}
}
}
}
}
}
}
}
}
}
}
+117 -116
View File
@@ -1,7 +1,7 @@
package me.barny1094875.launchpad;
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;
@@ -10,163 +10,164 @@ import org.bukkit.inventory.ItemStack;
import org.bukkit.inventory.ShapedRecipe;
import org.bukkit.inventory.meta.ItemMeta;
import java.util.Collections;
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 ItemStack launcherBase;
private static ItemStack launcherLaunch;
private static ItemStack launcherExploder;
private static ItemStack launcherActivator;
private static java.util.Vector<Component> loreList = new java.util.Vector<>();
private static ItemStack launcherBase;
private static ItemStack launcherLaunch;
private static ItemStack launcherExploder;
private static ItemStack launcherActivator;
public static void addLauncherBase(){
public static void addLauncherBase(){
launcherBase = new ItemStack(Material.PISTON);
ItemMeta baseMeta = launcherBase.getItemMeta();
launcherBase = new ItemStack(Material.PISTON);
ItemMeta baseMeta = launcherBase.getItemMeta();
baseMeta.displayName(Component.text("Launcher Base")
.decorate(TextDecoration.ITALIC));
baseMeta.displayName(Component.text("Launcher Base")
.decorate(TextDecoration.ITALIC));
loreList.clear();
loreList.add((Component.text("The base component for")));
loreList.add((Component.text("making a launchpad")));
baseMeta.lore(Collections.list(loreList.elements()));
loreList.clear();
loreList.add((Component.text("The base component for")));
loreList.add((Component.text("making a launchpad")));
baseMeta.lore(Collections.list(loreList.elements()));
// add a useless enchantment to the item to make it
// stand out in the inventory
baseMeta.addEnchant(Enchantment.PROTECTION_ENVIRONMENTAL, 1, false);
// add a useless enchantment to the item to make it
// stand out in the inventory
baseMeta.addEnchant(Enchantment.PROTECTION_ENVIRONMENTAL, 1, false);
launcherBase.setItemMeta(baseMeta);
launcherBase.setItemMeta(baseMeta);
NamespacedKey baseKey = new NamespacedKey(LaunchPad.getPlugin(), "launcherBase");
ShapedRecipe baseRecipe = new ShapedRecipe(baseKey, launcherBase);
baseRecipe.shape("iii", "grg");
baseRecipe.setIngredient('i', Material.IRON_BLOCK);
baseRecipe.setIngredient('g', Material.GOLD_BLOCK);
baseRecipe.setIngredient('r', Material.REDSTONE_BLOCK);
NamespacedKey baseKey = new NamespacedKey(LaunchPadsOG.getPlugin(), "launcherBase");
ShapedRecipe baseRecipe = new ShapedRecipe(baseKey, launcherBase);
baseRecipe.shape("iii", "grg");
baseRecipe.setIngredient('i', Material.IRON_BLOCK);
baseRecipe.setIngredient('g', Material.GOLD_BLOCK);
baseRecipe.setIngredient('r', Material.REDSTONE_BLOCK);
Bukkit.addRecipe(baseRecipe);
}
Bukkit.addRecipe(baseRecipe);
}
public static void addLauncherLauncher(){
public static void addLauncherLauncher(){
launcherLaunch = new ItemStack(Material.DISPENSER);
ItemMeta launchMeta = launcherLaunch.getItemMeta();
launcherLaunch = new ItemStack(Material.DISPENSER);
ItemMeta launchMeta = launcherLaunch.getItemMeta();
launchMeta.displayName(Component.text("Launcher")
.decorate(TextDecoration.ITALIC));
launchMeta.displayName(Component.text("Launcher")
.decorate(TextDecoration.ITALIC));
loreList.clear();
loreList.add(Component.text("The launcher for"));
loreList.add(Component.text("a launchpad"));
launchMeta.lore(Collections.list(loreList.elements()));
loreList.clear();
loreList.add(Component.text("The launcher for"));
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
launchMeta.addEnchant(Enchantment.PROTECTION_ENVIRONMENTAL, 1, false);
// 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);
launcherLaunch.setItemMeta(launchMeta);
NamespacedKey armKey = new NamespacedKey(LaunchPad.getPlugin(), "launcherArm");
ShapedRecipe armRecipe = new ShapedRecipe(armKey, launcherLaunch);
armRecipe.shape(" s", " ib", "i ");
armRecipe.setIngredient('s', Material.STRING);
armRecipe.setIngredient('i', Material.IRON_BLOCK);
armRecipe.setIngredient('b', Material.BUCKET);
NamespacedKey armKey = new NamespacedKey(LaunchPadsOG.getPlugin(), "launcherArm");
ShapedRecipe armRecipe = new ShapedRecipe(armKey, launcherLaunch);
armRecipe.shape(" s", " ib", "i ");
armRecipe.setIngredient('s', Material.STRING);
armRecipe.setIngredient('i', Material.IRON_BLOCK);
armRecipe.setIngredient('b', Material.BUCKET);
Bukkit.addRecipe(armRecipe);
Bukkit.addRecipe(armRecipe);
}
}
public static void addLauncherExploder(){
public static void addLauncherExploder(){
launcherExploder = new ItemStack(Material.TNT);
ItemMeta exploderMeta = launcherExploder.getItemMeta();
launcherExploder = new ItemStack(Material.TNT);
ItemMeta exploderMeta = launcherExploder.getItemMeta();
exploderMeta.displayName(Component.text("Launcher Exploder")
.decorate(TextDecoration.ITALIC));
exploderMeta.displayName(Component.text("Launcher Exploder")
.decorate(TextDecoration.ITALIC));
loreList.clear();
loreList.add(Component.text("The launcher arm for"));
loreList.add(Component.text("a launchpad"));
exploderMeta.lore(Collections.list(loreList.elements()));
loreList.clear();
loreList.add(Component.text("The launcher arm for"));
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
exploderMeta.addEnchant(Enchantment.PROTECTION_ENVIRONMENTAL, 1, false);
// 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);
launcherExploder.setItemMeta(exploderMeta);
NamespacedKey exploderKey = new NamespacedKey(LaunchPad.getPlugin(), "launcherExploder");
ShapedRecipe exploderRecipe = new ShapedRecipe(exploderKey, launcherExploder);
exploderRecipe.shape("ttt", "tbt", "ttt");
exploderRecipe.setIngredient('t', Material.TNT);
exploderRecipe.setIngredient('b', Material.TARGET);
NamespacedKey exploderKey = new NamespacedKey(LaunchPadsOG.getPlugin(), "launcherExploder");
ShapedRecipe exploderRecipe = new ShapedRecipe(exploderKey, launcherExploder);
exploderRecipe.shape("ttt", "tbt", "ttt");
exploderRecipe.setIngredient('t', Material.TNT);
exploderRecipe.setIngredient('b', Material.TARGET);
Bukkit.addRecipe(exploderRecipe);
Bukkit.addRecipe(exploderRecipe);
}
}
public static void addLauncherActivator(){
public static void addLauncherActivator(){
launcherActivator = new ItemStack(Material.TRIPWIRE_HOOK);
ItemMeta activatorMeta = launcherActivator.getItemMeta();
launcherActivator = new ItemStack(Material.TRIPWIRE_HOOK);
ItemMeta activatorMeta = launcherActivator.getItemMeta();
activatorMeta.displayName(Component.text("Launcher Activator")
.decorate(TextDecoration.ITALIC));
activatorMeta.displayName(Component.text("Launcher Activator")
.decorate(TextDecoration.ITALIC));
loreList.clear();
loreList.add(Component.text("The activator for"));
loreList.add(Component.text("a launchpad"));
activatorMeta.lore(Collections.list(loreList.elements()));
loreList.clear();
loreList.add(Component.text("The activator for"));
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
activatorMeta.addEnchant(Enchantment.PROTECTION_ENVIRONMENTAL, 1, false);
// 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);
launcherActivator.setItemMeta(activatorMeta);
NamespacedKey activatorKey = new NamespacedKey(LaunchPad.getPlugin(), "launcherActivator");
ShapedRecipe activatorRecipe = new ShapedRecipe(activatorKey, launcherActivator);
activatorRecipe.shape("rrr", "rdr", "rrr");
activatorRecipe.setIngredient('r', Material.REDSTONE_BLOCK);
activatorRecipe.setIngredient('d', Material.DIAMOND_BLOCK);
NamespacedKey activatorKey = new NamespacedKey(LaunchPadsOG.getPlugin(), "launcherActivator");
ShapedRecipe activatorRecipe = new ShapedRecipe(activatorKey, launcherActivator);
activatorRecipe.shape("rrr", "rdr", "rrr");
activatorRecipe.setIngredient('r', Material.REDSTONE_BLOCK);
activatorRecipe.setIngredient('d', Material.DIAMOND_BLOCK);
Bukkit.addRecipe(activatorRecipe);
Bukkit.addRecipe(activatorRecipe);
}
}
public static void addLaunchPad(){
public static void addLaunchPad(){
ItemStack launchPad = new ItemStack(Material.STONE_PRESSURE_PLATE);
ItemMeta padMeta = launchPad.getItemMeta();
ItemStack launchPad = new ItemStack(Material.STONE_PRESSURE_PLATE);
ItemMeta padMeta = launchPad.getItemMeta();
padMeta.displayName(Component.text("Launch Pad")
.decorate(TextDecoration.ITALIC));
padMeta.displayName(Component.text("Launch Pad")
.decorate(TextDecoration.ITALIC));
loreList.clear();
loreList.add(Component.text("Launches you in the"));
loreList.add(Component.text("direction you are facing"));
padMeta.lore(Collections.list(loreList.elements()));
loreList.clear();
loreList.add(Component.text("Launches you in the"));
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
padMeta.addEnchant(Enchantment.PROTECTION_ENVIRONMENTAL, 1, false);
// 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);
launchPad.setItemMeta(padMeta);
NamespacedKey padKey = new NamespacedKey(LaunchPad.getPlugin(), "launchPad");
ShapedRecipe padRecipe = new ShapedRecipe(padKey, launchPad);
padRecipe.shape("gng", "geg", "lba");
padRecipe.setIngredient('g', Material.GOLD_BLOCK);
padRecipe.setIngredient('n', Material.NOTE_BLOCK);
padRecipe.setIngredient('e', launcherExploder);
padRecipe.setIngredient('l', launcherLaunch);
padRecipe.setIngredient('b', launcherBase);
padRecipe.setIngredient('a', launcherActivator);
NamespacedKey padKey = new NamespacedKey(LaunchPadsOG.getPlugin(), "launchPad");
ShapedRecipe padRecipe = new ShapedRecipe(padKey, launchPad);
padRecipe.shape("gng", "geg", "lba");
padRecipe.setIngredient('g', Material.GOLD_BLOCK);
padRecipe.setIngredient('n', Material.NOTE_BLOCK);
padRecipe.setIngredient('e', launcherExploder);
padRecipe.setIngredient('l', launcherLaunch);
padRecipe.setIngredient('b', launcherBase);
padRecipe.setIngredient('a', launcherActivator);
Bukkit.addRecipe(padRecipe);
}
Bukkit.addRecipe(padRecipe);
}
}
}
@@ -1,4 +1,6 @@
package me.barny1094875.launchpad.config;
package net.trueog.launchpadsog.config;
import java.io.File;
/*
@@ -12,79 +14,76 @@ import org.bukkit.configuration.file.FileConfiguration;
import org.bukkit.configuration.file.YamlConfiguration;
import org.bukkit.plugin.java.JavaPlugin;
import java.io.File;
public class Config {
protected final boolean createIfNotExist, resource;
protected final JavaPlugin plugin;
protected final boolean createIfNotExist, resource;
protected final JavaPlugin plugin;
public FileConfiguration config;
protected File file, path;
protected String name;
public FileConfiguration config;
protected File file, path;
protected String name;
public Config(JavaPlugin instance, File path, String name, boolean createIfNotExist, boolean resource) {
this.plugin = instance;
this.path = path;
this.name = name + ".yml";
this.createIfNotExist = createIfNotExist;
this.resource = resource;
create();
reloadConfig();
}
public Config(JavaPlugin instance, File path, String name, boolean createIfNotExist, boolean resource) {
this.plugin = instance;
this.path = path;
this.name = name + ".yml";
this.createIfNotExist = createIfNotExist;
this.resource = resource;
create();
reloadConfig();
}
public Config(JavaPlugin instance, String path, String name, boolean createIfNotExist, boolean resource) {
this(instance, new File(path), name, createIfNotExist, resource);
}
public Config(JavaPlugin instance, String path, String name, boolean createIfNotExist, boolean resource) {
this(instance, new File(path), name, createIfNotExist, resource);
}
public FileConfiguration getConfig() {
return config;
}
public FileConfiguration getConfig() {
return config;
}
//Getters, variables and constructors
public void save() {
try {
config.save(file);
} catch (Exception exc) {
exc.printStackTrace();
}
}
public void save() {
try {
config.save(file);
} catch (Exception exc) {
exc.printStackTrace();
}
}
public File reloadFile() {
file = new File(path, name);
return file;
}
public File reloadFile() {
file = new File(path, name);
return file;
}
public FileConfiguration reloadConfig() {
config = YamlConfiguration.loadConfiguration(file);
return config;
}
public FileConfiguration reloadConfig() {
config = YamlConfiguration.loadConfiguration(file);
return config;
}
public void reload() {
reloadFile();
reloadConfig();
}
public void reload() {
reloadFile();
reloadConfig();
}
public void create() {
if (file == null) {
reloadFile();
}
if (!createIfNotExist || file.exists()) {
return;
}
file.getParentFile().mkdirs();
if (resource) {
plugin.saveResource(name, false);
} else {
try {
file.createNewFile();
} catch (Exception exc) {
exc.printStackTrace();
}
}
if (config == null) {
reloadConfig();
}
}
public void create() {
if (file == null) {
reloadFile();
}
if (!createIfNotExist || file.exists()) {
return;
}
file.getParentFile().mkdirs();
if (resource) {
plugin.saveResource(name, false);
} else {
try {
file.createNewFile();
} catch (Exception exc) {
exc.printStackTrace();
}
}
if (config == null) {
reloadConfig();
}
}
}
}
+4 -4
View File
@@ -1,7 +1,7 @@
name: LaunchPad-OG
version: '2.0'
main: me.barny1094875.launchpad.LaunchPad
api-version: 1.19
name: LaunchPads-OG
version: '${version}'
main: net.trueog.launchpadsog.LaunchPadsOG
api-version: '${apiVersion}'
commands:
launchpad:
usage: /launchpad