Update gradle to 8.14.2, add auto formatting
This commit is contained in:
1 parent
e676fa95a7
commit
de9ded8ed0
12 files changed
+148
-125
No files matched your search
@@ -0,0 +1,3 @@
|
||||
[submodule "libs/Utilities-OG"]
|
||||
path = libs/Utilities-OG
|
||||
url = https://github.com/true-og/Utilities-OG
|
||||
Executable
+4
@@ -0,0 +1,4 @@
|
||||
#!/usr/bin/bash
|
||||
|
||||
# Fetch all submodule content.
|
||||
git submodule update --force --recursive --init
|
||||
+27
-25
@@ -1,8 +1,9 @@
|
||||
plugins {
|
||||
id("java") // Tell gradle this is a java project.
|
||||
id("java-library") // Import helper for source-based libraries.
|
||||
id("com.diffplug.spotless") version "7.0.4" // Import auto-formatter.
|
||||
id("com.gradleup.shadow") version "8.3.6" // Import shadow API.
|
||||
java // Tell gradle this is a java project.
|
||||
eclipse // Import eclipse plugin for IDE integration.
|
||||
kotlin("jvm") version "2.1.21" // Import kotlin jvm plugin for kotlin/java integration.
|
||||
}
|
||||
|
||||
java {
|
||||
@@ -11,20 +12,17 @@ java {
|
||||
}
|
||||
|
||||
group = "net.trueog.holygrail-og" // Declare bundle identifier.
|
||||
|
||||
version = "1.2" // 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
|
||||
)
|
||||
val props = mapOf("version" to version, "apiVersion" to apiVersion)
|
||||
|
||||
inputs.properties(props) // Indicates to rerun if version changes.
|
||||
|
||||
filesMatching("plugin.yml") {
|
||||
expand(props)
|
||||
}
|
||||
filesMatching("plugin.yml") { expand(props) }
|
||||
from("LICENSE") { // Bundle license into .jars.
|
||||
into("/")
|
||||
}
|
||||
@@ -33,23 +31,21 @@ tasks.named<ProcessResources>("processResources") {
|
||||
repositories {
|
||||
mavenCentral()
|
||||
gradlePluginPortal()
|
||||
maven {
|
||||
url = uri("https://repo.purpurmc.org/snapshots")
|
||||
}
|
||||
maven { url = uri("https://repo.purpurmc.org/snapshots") }
|
||||
|
||||
maven {
|
||||
|
||||
url = uri("https://maven.enginehub.org/repo/")
|
||||
}
|
||||
maven { url = uri("https://maven.enginehub.org/repo/") }
|
||||
}
|
||||
|
||||
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.
|
||||
compileOnly("com.sk89q.worldedit:worldedit-bukkit:7.3.0-SNAPSHOT") // Import WorldEdit.
|
||||
compileOnly("com.sk89q.worldguard:worldguard-bukkit:7.0.9") { // Import WorldGuard but without its bundled WorldEdit.
|
||||
compileOnly(
|
||||
"com.sk89q.worldguard:worldguard-bukkit:7.0.9"
|
||||
) { // Import WorldGuard but without its bundled WorldEdit.
|
||||
exclude(group = "com.sk89q.worldedit")
|
||||
}
|
||||
compileOnlyApi(project(":libs:Utilities-OG"))
|
||||
}
|
||||
|
||||
tasks.withType<AbstractArchiveTask>().configureEach { // Ensure reproducible .jars
|
||||
@@ -58,18 +54,17 @@ tasks.withType<AbstractArchiveTask>().configureEach { // Ensure reproducible .ja
|
||||
}
|
||||
|
||||
tasks.shadowJar {
|
||||
archiveClassifier.set("") // Use empty string instead of null.
|
||||
exclude("io.github.miniplaceholders.*") // Exclude the MiniPlaceholders package from being shadowed.
|
||||
archiveClassifier.set("") // Use empty string instead of null.
|
||||
minimize()
|
||||
}
|
||||
|
||||
tasks.build {
|
||||
dependsOn(tasks.spotlessApply)
|
||||
dependsOn(tasks.shadowJar)
|
||||
}
|
||||
|
||||
tasks.jar {
|
||||
archiveClassifier.set("part")
|
||||
}
|
||||
tasks.jar { archiveClassifier.set("part") }
|
||||
|
||||
tasks.withType<JavaCompile>().configureEach {
|
||||
options.compilerArgs.add("-parameters")
|
||||
@@ -78,13 +73,20 @@ tasks.withType<JavaCompile>().configureEach {
|
||||
options.isFork = true
|
||||
}
|
||||
|
||||
kotlin {
|
||||
jvmToolchain(17)
|
||||
}
|
||||
|
||||
java {
|
||||
toolchain {
|
||||
languageVersion = JavaLanguageVersion.of(17)
|
||||
vendor = JvmVendorSpec.GRAAL_VM
|
||||
}
|
||||
}
|
||||
|
||||
spotless {
|
||||
java {
|
||||
removeUnusedImports()
|
||||
palantirJavaFormat()
|
||||
}
|
||||
kotlinGradle {
|
||||
ktfmt().kotlinlangStyle().configure { it.setMaxWidth(120) }
|
||||
target("build.gradle.kts", "settings.gradle.kts")
|
||||
}
|
||||
}
|
||||
Vendored
BIN
Binary file not shown.
+1
-1
@@ -1,6 +1,6 @@
|
||||
distributionBase=GRADLE_USER_HOME
|
||||
distributionPath=wrapper/dists
|
||||
distributionUrl=https\://services.gradle.org/distributions/gradle-8.14.1-bin.zip
|
||||
distributionUrl=https\://services.gradle.org/distributions/gradle-8.14.2-bin.zip
|
||||
networkTimeout=10000
|
||||
validateDistributionUrl=true
|
||||
zipStoreBase=GRADLE_USER_HOME
|
||||
|
||||
@@ -15,6 +15,8 @@
|
||||
# See the License for the specific language governing permissions and
|
||||
# limitations under the License.
|
||||
#
|
||||
# SPDX-License-Identifier: Apache-2.0
|
||||
#
|
||||
|
||||
##############################################################################
|
||||
#
|
||||
@@ -84,7 +86,7 @@ done
|
||||
# shellcheck disable=SC2034
|
||||
APP_BASE_NAME=${0##*/}
|
||||
# Discard cd standard output in case $CDPATH is set (https://github.com/gradle/gradle/issues/25036)
|
||||
APP_HOME=$( cd "${APP_HOME:-./}" > /dev/null && pwd -P ) || exit
|
||||
APP_HOME=$( cd -P "${APP_HOME:-./}" > /dev/null && printf '%s\n' "$PWD" ) || exit
|
||||
|
||||
# Use the maximum available, or set MAX_FD != -1 to use that value.
|
||||
MAX_FD=maximum
|
||||
@@ -112,7 +114,7 @@ case "$( uname )" in #(
|
||||
NONSTOP* ) nonstop=true ;;
|
||||
esac
|
||||
|
||||
CLASSPATH=$APP_HOME/gradle/wrapper/gradle-wrapper.jar
|
||||
CLASSPATH="\\\"\\\""
|
||||
|
||||
|
||||
# Determine the Java command to use to start the JVM.
|
||||
@@ -203,7 +205,7 @@ fi
|
||||
DEFAULT_JVM_OPTS='"-Xmx64m" "-Xms64m"'
|
||||
|
||||
# Collect all arguments for the java command:
|
||||
# * DEFAULT_JVM_OPTS, JAVA_OPTS, JAVA_OPTS, and optsEnvironmentVar are not allowed to contain shell fragments,
|
||||
# * DEFAULT_JVM_OPTS, JAVA_OPTS, and optsEnvironmentVar are not allowed to contain shell fragments,
|
||||
# and any embedded shellness will be escaped.
|
||||
# * For example: A user cannot expect ${Hostname} to be expanded, as it is an environment variable and will be
|
||||
# treated as '${Hostname}' itself on the command line.
|
||||
@@ -211,7 +213,7 @@ DEFAULT_JVM_OPTS='"-Xmx64m" "-Xms64m"'
|
||||
set -- \
|
||||
"-Dorg.gradle.appname=$APP_BASE_NAME" \
|
||||
-classpath "$CLASSPATH" \
|
||||
org.gradle.wrapper.GradleWrapperMain \
|
||||
-jar "$APP_HOME/gradle/wrapper/gradle-wrapper.jar" \
|
||||
"$@"
|
||||
|
||||
# Stop when "xargs" is not available.
|
||||
|
||||
Vendored
+4
-2
@@ -13,6 +13,8 @@
|
||||
@rem See the License for the specific language governing permissions and
|
||||
@rem limitations under the License.
|
||||
@rem
|
||||
@rem SPDX-License-Identifier: Apache-2.0
|
||||
@rem
|
||||
|
||||
@if "%DEBUG%"=="" @echo off
|
||||
@rem ##########################################################################
|
||||
@@ -68,11 +70,11 @@ goto fail
|
||||
:execute
|
||||
@rem Setup the command line
|
||||
|
||||
set CLASSPATH=%APP_HOME%\gradle\wrapper\gradle-wrapper.jar
|
||||
set CLASSPATH=
|
||||
|
||||
|
||||
@rem Execute Gradle
|
||||
"%JAVA_EXE%" %DEFAULT_JVM_OPTS% %JAVA_OPTS% %GRADLE_OPTS% "-Dorg.gradle.appname=%APP_BASE_NAME%" -classpath "%CLASSPATH%" org.gradle.wrapper.GradleWrapperMain %*
|
||||
"%JAVA_EXE%" %DEFAULT_JVM_OPTS% %JAVA_OPTS% %GRADLE_OPTS% "-Dorg.gradle.appname=%APP_BASE_NAME%" -classpath "%CLASSPATH%" -jar "%APP_HOME%\gradle\wrapper\gradle-wrapper.jar" %*
|
||||
|
||||
:end
|
||||
@rem End local scope for the variables with windows NT shell
|
||||
|
||||
Submodule
+1
Submodule libs/Utilities-OG added at e68d3fec7a.
@@ -1 +1,12 @@
|
||||
rootProject.name = "HolyGrail-OG"
|
||||
|
||||
// Run the bootstrap at configuration time.
|
||||
val process = ProcessBuilder("sh", "bootstrap.sh").directory(rootDir).start()
|
||||
|
||||
val exitValue = process.waitFor()
|
||||
|
||||
if (exitValue != 0) {
|
||||
throw GradleException("bootstrap.sh failed with exit code $exitValue")
|
||||
}
|
||||
|
||||
include("libs:Utilities-OG")
|
||||
@@ -5,7 +5,8 @@ package plugin;
|
||||
// Import required libraries.
|
||||
import org.bukkit.plugin.java.JavaPlugin;
|
||||
|
||||
// Extending this class is standard bukkit boilerplate for any plugin, or else the server software won't load the classes.
|
||||
// Extending this class is standard bukkit boilerplate for any plugin, or else the server software won't load the
|
||||
// classes.
|
||||
public class HolyGrailOG extends JavaPlugin {
|
||||
|
||||
// Declare variable to hold class for passing.
|
||||
@@ -19,7 +20,6 @@ public class HolyGrailOG extends JavaPlugin {
|
||||
|
||||
// Register the event.
|
||||
getServer().getPluginManager().registerEvents(new Listeners(), this);
|
||||
|
||||
}
|
||||
|
||||
// Class constructor.
|
||||
@@ -27,7 +27,5 @@ public class HolyGrailOG extends JavaPlugin {
|
||||
|
||||
// Pass instance of main to other classes.
|
||||
return plugin;
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
@@ -2,10 +2,24 @@
|
||||
// Author: NotAlexNoyle.
|
||||
package plugin;
|
||||
|
||||
import com.destroystokyo.paper.event.block.AnvilDamagedEvent;
|
||||
import com.destroystokyo.paper.event.block.AnvilDamagedEvent.DamageState;
|
||||
import com.google.common.collect.Lists;
|
||||
import com.sk89q.worldedit.bukkit.BukkitAdapter;
|
||||
import com.sk89q.worldedit.util.Location;
|
||||
import com.sk89q.worldguard.WorldGuard;
|
||||
import com.sk89q.worldguard.protection.ApplicableRegionSet;
|
||||
import com.sk89q.worldguard.protection.regions.ProtectedRegion;
|
||||
import com.sk89q.worldguard.protection.regions.RegionContainer;
|
||||
import com.sk89q.worldguard.protection.regions.RegionQuery;
|
||||
import java.util.ArrayList;
|
||||
// Import required libraries.
|
||||
import java.util.List;
|
||||
|
||||
import net.kyori.adventure.text.Component;
|
||||
import net.kyori.adventure.text.TextComponent;
|
||||
import net.kyori.adventure.text.event.ClickEvent;
|
||||
import net.kyori.adventure.text.format.NamedTextColor;
|
||||
import net.kyori.adventure.text.format.TextDecoration;
|
||||
import org.bukkit.Bukkit;
|
||||
import org.bukkit.Material;
|
||||
import org.bukkit.Particle;
|
||||
@@ -22,23 +36,6 @@ import org.bukkit.inventory.ItemStack;
|
||||
import org.bukkit.scheduler.BukkitTask;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
|
||||
import com.destroystokyo.paper.event.block.AnvilDamagedEvent;
|
||||
import com.destroystokyo.paper.event.block.AnvilDamagedEvent.DamageState;
|
||||
import com.google.common.collect.Lists;
|
||||
import com.sk89q.worldedit.bukkit.BukkitAdapter;
|
||||
import com.sk89q.worldedit.util.Location;
|
||||
import com.sk89q.worldguard.WorldGuard;
|
||||
import com.sk89q.worldguard.protection.ApplicableRegionSet;
|
||||
import com.sk89q.worldguard.protection.regions.ProtectedRegion;
|
||||
import com.sk89q.worldguard.protection.regions.RegionContainer;
|
||||
import com.sk89q.worldguard.protection.regions.RegionQuery;
|
||||
|
||||
import net.kyori.adventure.text.Component;
|
||||
import net.kyori.adventure.text.TextComponent;
|
||||
import net.kyori.adventure.text.event.ClickEvent;
|
||||
import net.kyori.adventure.text.format.NamedTextColor;
|
||||
import net.kyori.adventure.text.format.TextDecoration;
|
||||
|
||||
// Declare listener class.
|
||||
public class Listeners implements Listener {
|
||||
|
||||
@@ -49,16 +46,19 @@ public class Listeners implements Listener {
|
||||
public void onAnvilBreak(AnvilDamagedEvent event) {
|
||||
|
||||
// If the anvil is in the spawn region, do this...
|
||||
if(event.isBreaking() && getRegionNames(BukkitAdapter.adapt(event.getInventory().getLocation())).contains("spawn") ) {
|
||||
if (event.isBreaking()
|
||||
&& getRegionNames(BukkitAdapter.adapt(event.getInventory().getLocation()))
|
||||
.contains("spawn")) {
|
||||
|
||||
// Spawn a particle effect to indicate the anvil restoration.
|
||||
event.getInventory().getLocation().getWorld().spawnParticle(Particle.SPELL, event.getInventory().getLocation(), 5);
|
||||
event.getInventory()
|
||||
.getLocation()
|
||||
.getWorld()
|
||||
.spawnParticle(Particle.SPELL, event.getInventory().getLocation(), 5);
|
||||
|
||||
// Restore the anvil to unused status.
|
||||
event.setDamageState(DamageState.FULL);
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
// Listen for entities being damaged.
|
||||
@@ -69,33 +69,41 @@ public class Listeners implements Listener {
|
||||
// TODO: Test to make sure crystals only do damage to those in a duel match.
|
||||
|
||||
// If the entity that was damaged is an ender crystal, do this...
|
||||
if(event.getEntityType().equals(EntityType.ENDER_CRYSTAL)) {
|
||||
if (event.getEntityType().equals(EntityType.ENDER_CRYSTAL)) {
|
||||
|
||||
// Get a list of regions from WorldGuard.
|
||||
ArrayList<String> regionQuery = getRegionNames(BukkitAdapter.adapt(event.getEntity().getLocation()));
|
||||
ArrayList<String> regionQuery =
|
||||
getRegionNames(BukkitAdapter.adapt(event.getEntity().getLocation()));
|
||||
|
||||
// If the ender crystal that was damaged is in the spawn region, do this...
|
||||
if(regionQuery.contains("spawn")) {
|
||||
if (regionQuery.contains("spawn")) {
|
||||
|
||||
CharSequence arenaQuery = "arena";
|
||||
if(! doAnyRegionNamesContain(arenaQuery, event.getEntity())) {
|
||||
if (!doAnyRegionNamesContain(arenaQuery, event.getEntity())) {
|
||||
|
||||
event.setCancelled(true);
|
||||
|
||||
}
|
||||
else {
|
||||
} else {
|
||||
|
||||
// TODO: Test the pending restore particles.
|
||||
// Create a final array to capture the value of the remaining seconds (similar to a loop).
|
||||
final int[] secondsRemaining = { 5 };
|
||||
final int[] secondsRemaining = {5};
|
||||
|
||||
// Schedule a repeating task to show pending end crystal restore particles.
|
||||
task = Bukkit.getScheduler().runTaskTimer(HolyGrailOG.getPlugin(), new Runnable() {
|
||||
task = Bukkit.getScheduler()
|
||||
.runTaskTimer(
|
||||
HolyGrailOG.getPlugin(),
|
||||
new Runnable() {
|
||||
|
||||
@Override
|
||||
public void run() {
|
||||
|
||||
event.getEntity().getWorld().spawnParticle(Particle.FIREWORKS_SPARK, event.getEntity().getLocation(), 3);
|
||||
event.getEntity()
|
||||
.getWorld()
|
||||
.spawnParticle(
|
||||
Particle.FIREWORKS_SPARK,
|
||||
event.getEntity().getLocation(),
|
||||
3);
|
||||
|
||||
// Decrease the remaining time
|
||||
secondsRemaining[0] = secondsRemaining[0] - 1;
|
||||
@@ -104,40 +112,44 @@ public class Listeners implements Listener {
|
||||
if (secondsRemaining[0] <= 0) {
|
||||
|
||||
Bukkit.getScheduler().cancelTask(task.getTaskId()); // Cancel the task
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
}, 0L, 20L); // The '0L' means start immediately, and '20L' means run every 20 ticks (1 second).
|
||||
},
|
||||
0L,
|
||||
20L); // The '0L' means start immediately, and '20L' means run every 20 ticks (1
|
||||
// second).
|
||||
|
||||
// Wait 5 seconds, so that it doesn't appear that the crystal didn't get destroyed.
|
||||
Bukkit.getScheduler().runTaskLater(HolyGrailOG.getPlugin(), new Runnable() {
|
||||
Bukkit.getScheduler()
|
||||
.runTaskLater(
|
||||
HolyGrailOG.getPlugin(),
|
||||
new Runnable() {
|
||||
// Run a scheduled task.
|
||||
@Override
|
||||
public void run() {
|
||||
|
||||
// Delete existing crystals at the location.
|
||||
// TODO: Test this code...
|
||||
org.bukkit.@NotNull Location crystalLocation = event.getEntity().getLocation();
|
||||
for (Entity nearbyEntity : crystalLocation.getWorld().getNearbyEntities(crystalLocation, 2, 2, 2)) {
|
||||
org.bukkit.@NotNull Location crystalLocation =
|
||||
event.getEntity().getLocation();
|
||||
for (Entity nearbyEntity : crystalLocation
|
||||
.getWorld()
|
||||
.getNearbyEntities(crystalLocation, 2, 2, 2)) {
|
||||
if (nearbyEntity.getType() == EntityType.ENDER_CRYSTAL) {
|
||||
nearbyEntity.remove();
|
||||
}
|
||||
}
|
||||
|
||||
// Restore the ender crystal to its original location.
|
||||
event.getEntity().getWorld().spawnEntity(crystalLocation, EntityType.ENDER_CRYSTAL);
|
||||
|
||||
event.getEntity()
|
||||
.getWorld()
|
||||
.spawnEntity(crystalLocation, EntityType.ENDER_CRYSTAL);
|
||||
}
|
||||
}, 100L); // 100L = 5 seconds delay
|
||||
|
||||
|
||||
},
|
||||
100L); // 100L = 5 seconds delay
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
// Listen for entities exploding.
|
||||
@@ -161,7 +173,7 @@ public class Listeners implements Listener {
|
||||
Entity entityClicked = event.getRightClicked();
|
||||
|
||||
// If the player right clicked on an ender crystal, do this...
|
||||
if(entityClicked.getType().equals(EntityType.ENDER_CRYSTAL)) {
|
||||
if (entityClicked.getType().equals(EntityType.ENDER_CRYSTAL)) {
|
||||
|
||||
// Get the player who performed the interaction.
|
||||
Player player = event.getPlayer();
|
||||
@@ -169,8 +181,9 @@ public class Listeners implements Listener {
|
||||
// Get the item in the player's main hand.
|
||||
ItemStack itemInHand = player.getInventory().getItemInMainHand();
|
||||
|
||||
// If the player is holding an ender crystal in their hand, and they have permission, send them an ender crystal deletion confirmation prompt.
|
||||
if(itemInHand.getType().equals(Material.END_CRYSTAL) && player.hasPermission("holygrail.deletecrystals")) {
|
||||
// If the player is holding an ender crystal in their hand, and they have permission, send them an ender
|
||||
// crystal deletion confirmation prompt.
|
||||
if (itemInHand.getType().equals(Material.END_CRYSTAL) && player.hasPermission("holygrail.deletecrystals")) {
|
||||
|
||||
// TODO: Delete all crystals at the entity location according to player command.
|
||||
// TODO: Test this code...
|
||||
@@ -181,12 +194,13 @@ public class Listeners implements Listener {
|
||||
}
|
||||
}
|
||||
|
||||
sendClickableMessage(player, entityClicked.getLocation().getX(), entityClicked.getLocation().getY(), entityClicked.getLocation().getBlockZ());
|
||||
|
||||
sendClickableMessage(
|
||||
player,
|
||||
entityClicked.getLocation().getX(),
|
||||
entityClicked.getLocation().getY(),
|
||||
entityClicked.getLocation().getBlockZ());
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
// Listen for entities being spawned.
|
||||
@@ -194,7 +208,8 @@ public class Listeners implements Listener {
|
||||
public void onEntitySpawn(EntitySpawnEvent event) {
|
||||
|
||||
// If the entity that was spawned is an ender crystal, and it is in the spawn region, do this...
|
||||
if(event.getEntityType().equals(EntityType.ENDER_CRYSTAL) && getRegionNames(BukkitAdapter.adapt(event.getLocation())).contains("spawn")) {
|
||||
if (event.getEntityType().equals(EntityType.ENDER_CRYSTAL)
|
||||
&& getRegionNames(BukkitAdapter.adapt(event.getLocation())).contains("spawn")) {
|
||||
|
||||
// Make a list of to hold the nearby entities sized of the maximum reasonable amount of nearby entities.
|
||||
List<Entity> entityList = new ArrayList<Entity>(3457);
|
||||
@@ -203,7 +218,7 @@ public class Listeners implements Listener {
|
||||
ArrayList<String> entityTitles = new ArrayList<String>(3457);
|
||||
|
||||
// Iterate over the nearby entities with a pre-set maximum.
|
||||
for(int i = 0; i < entityList.size(); i++) {
|
||||
for (int i = 0; i < entityList.size(); i++) {
|
||||
|
||||
// Attempt to run error-throwing code.
|
||||
try {
|
||||
@@ -212,35 +227,37 @@ public class Listeners implements Listener {
|
||||
entityList.add(event.getEntity().getNearbyEntities(2, 2, 2).get(i));
|
||||
|
||||
// Get a list of nearby entities' titles.
|
||||
entityTitles.add(event.getEntity().getNearbyEntities(2, 2, 2).get(i).getType().toString().toLowerCase());
|
||||
entityTitles.add(event.getEntity()
|
||||
.getNearbyEntities(2, 2, 2)
|
||||
.get(i)
|
||||
.getType()
|
||||
.toString()
|
||||
.toLowerCase());
|
||||
|
||||
}
|
||||
// If the amount of entities is less than 3457, this error will be thrown.
|
||||
catch(IndexOutOfBoundsException error) {
|
||||
catch (IndexOutOfBoundsException error) {
|
||||
|
||||
// Stop the loop if maximum entity count was reached. The last value of i will be used as the list size.
|
||||
// Stop the loop if maximum entity count was reached. The last value of i will be used as the list
|
||||
// size.
|
||||
break;
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
// If an ender crystal already exists at the location, do this...
|
||||
if(entityTitles.contains("ender_crystal")) {
|
||||
if (entityTitles.contains("ender_crystal")) {
|
||||
|
||||
// Don't spawn in another crystal since there is one already.
|
||||
event.setCancelled(true);
|
||||
|
||||
}
|
||||
else {
|
||||
} else {
|
||||
|
||||
// Spawn particles to indicate the ender crystal being restored.
|
||||
event.getEntity().getWorld().spawnParticle(Particle.SPELL, event.getEntity().getLocation(), 6);
|
||||
|
||||
event.getEntity()
|
||||
.getWorld()
|
||||
.spawnParticle(Particle.SPELL, event.getEntity().getLocation(), 6);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
// Declare a function for searching for specific sequences of characters in region names.
|
||||
@@ -251,18 +268,15 @@ public class Listeners implements Listener {
|
||||
|
||||
boolean queryFound = false;
|
||||
|
||||
for(int i = 0; i < regionQuery.size(); i++) {
|
||||
for (int i = 0; i < regionQuery.size(); i++) {
|
||||
|
||||
if(regionQuery.get(i).contains(lookup)) {
|
||||
if (regionQuery.get(i).contains(lookup)) {
|
||||
|
||||
queryFound = true;
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
return queryFound;
|
||||
|
||||
}
|
||||
|
||||
// Declare a function for checking whether a location is in a region.
|
||||
@@ -276,15 +290,13 @@ public class Listeners implements Listener {
|
||||
List<ProtectedRegion> region = Lists.newArrayList(set);
|
||||
ArrayList<String> regionNames = new ArrayList<String>(region.size());
|
||||
regionNames.add("none");
|
||||
for(int i = 0; i < region.size(); i++) {
|
||||
for (int i = 0; i < region.size(); i++) {
|
||||
|
||||
regionNames.add(i, region.get(i).getId());
|
||||
|
||||
}
|
||||
|
||||
// Return a list of all applicable regions.
|
||||
return regionNames;
|
||||
|
||||
}
|
||||
|
||||
// Turns chat text into a command button.
|
||||
@@ -300,8 +312,8 @@ public class Listeners implements Listener {
|
||||
clickableText = clickableText.clickEvent(ClickEvent.clickEvent(ClickEvent.Action.RUN_COMMAND, "tps"));
|
||||
|
||||
// Send the clickable text to the player.
|
||||
player.sendMessage(Utils.legacySerializerAnyCase("&6Are you sure you want to &cdelete &6the ender crystal at X = &e\" + x + \"&6, Y = &e\" + y + \"&6, Z = &e\" + z + \"&6? To confirm: &B\"") + clickableText.content());
|
||||
|
||||
player.sendMessage(Utils.legacySerializerAnyCase(
|
||||
"&6Are you sure you want to &cdelete &6the ender crystal at X = &e\" + x + \"&6, Y = &e\" + y + \"&6, Z = &e\" + z + \"&6? To confirm: &B\"")
|
||||
+ clickableText.content());
|
||||
}
|
||||
|
||||
}
|
||||
@@ -14,9 +14,7 @@ public class Utils {
|
||||
if (c == '&') {
|
||||
|
||||
count++;
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
// Create an array to store the positions of '&' characters
|
||||
@@ -30,17 +28,13 @@ public class Utils {
|
||||
if (isUpperBukkitCode(subject.charAt(i + 1))) {
|
||||
|
||||
subject = replaceCharAtIndex(subject, (i + 1), Character.toLowerCase(subject.charAt(i + 1)));
|
||||
|
||||
}
|
||||
|
||||
positions[index++] = i;
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
return LegacyComponentSerializer.legacyAmpersand().deserialize(subject);
|
||||
|
||||
}
|
||||
|
||||
private static boolean isUpperBukkitCode(char input) {
|
||||
@@ -54,13 +48,10 @@ public class Utils {
|
||||
if (c == input) {
|
||||
|
||||
match = true;
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
return match;
|
||||
|
||||
}
|
||||
|
||||
private static String replaceCharAtIndex(String original, int index, char newChar) {
|
||||
@@ -70,12 +61,9 @@ public class Utils {
|
||||
|
||||
// Create a new string with the replaced character
|
||||
return original.substring(0, index) + newChar + original.substring(index + 1);
|
||||
|
||||
}
|
||||
|
||||
// If the index is invalid, return the original string
|
||||
return original;
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
Reference in new issue
Block a user