Skip to content

Commit

Permalink
BukkitVendor: minor code formatting changes for #285
Browse files Browse the repository at this point in the history
  • Loading branch information
lokka30 committed Jul 4, 2023
1 parent b8dad4b commit 6986583
Showing 1 changed file with 12 additions and 10 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
package me.lokka30.treasury.plugin.bukkit.vendor;

import me.lokka30.treasury.plugin.core.Platform;
import org.jetbrains.annotations.NotNull;

/**
* Represents a handler for determining on what server vendor we're running. This is in order
Expand All @@ -24,7 +25,7 @@ public final class BukkitVendor {

private static Platform platform;

public static Platform getPlatformClass() {
public static @NotNull Platform getPlatformClass() {
if (platform == null) {
String specificationName;
if (isFolia()) {
Expand All @@ -43,15 +44,16 @@ public static Platform getPlatformClass() {
}

/**
* Returns whether we're running any of the specified classes.
* Returns whether any of the specified classpaths are currently loaded by the JVM. Useful for
* checking for server software implementations.
*
* @param classNames the class names to check for
* @return any of the specified classes?
* @param classpaths classpaths to check the existence of
* @return whether any of the specified classpaths are currently loaded by the JVM
*/
private static boolean hasClass(String... classNames) {
for (String className : classNames) {
private static boolean hasAnyClasspath(@NotNull String @NotNull... classpaths) {
for (final String classpath : classpaths) {
try {
Class.forName(className);
Class.forName(classpath);
return true;
} catch (ClassNotFoundException ignored) {
}
Expand All @@ -66,7 +68,7 @@ private static boolean hasClass(String... classNames) {
*/
public static boolean isSpigot() {
if (!ranSpigotCheck) {
spigot = hasClass("org.spigotmc.SpigotConfig");
spigot = hasAnyClasspath("org.spigotmc.SpigotConfig");
ranSpigotCheck = true;
}
return spigot;
Expand All @@ -79,7 +81,7 @@ public static boolean isSpigot() {
*/
public static boolean isPaper() {
if (!ranPaperCheck) {
paper = hasClass(
paper = hasAnyClasspath(
"com.destroystokyo.paper.PaperConfig",
"io.papermc.paper.configuration.Configuration"
);
Expand All @@ -95,7 +97,7 @@ public static boolean isPaper() {
*/
public static boolean isFolia() {
if (!ranFoliaCheck) {
folia = hasClass("io.papermc.paper.threadedregions.RegionizedServer");
folia = hasAnyClasspath("io.papermc.paper.threadedregions.RegionizedServer");
ranFoliaCheck = true;
}
return folia;
Expand Down

0 comments on commit 6986583

Please sign in to comment.