Skip to content

Commit

Permalink
Cleanup
Browse files Browse the repository at this point in the history
  • Loading branch information
OliverSchlueter committed Sep 26, 2024
1 parent 32b94e5 commit 79fe19a
Show file tree
Hide file tree
Showing 8 changed files with 26 additions and 286 deletions.
4 changes: 3 additions & 1 deletion build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -15,13 +15,15 @@ java {
repositories {
mavenCentral()
maven("https://repo.papermc.io/repository/maven-public/")
maven("https://repo.fancyplugins.de/releases")
}

dependencies {
compileOnly("dev.folia:folia-api:1.20.4-R0.1-SNAPSHOT")
compileOnly("de.oliver.FancyAnalytics:logger:0.0.5")

// database drivers
compileOnly("org.xerial:sqlite-jdbc:3.42.0.1")
compileOnly("org.xerial:sqlite-jdbc:3.46.0.0")
compileOnly("mysql:mysql-connector-java:8.0.33")
}

Expand Down
113 changes: 0 additions & 113 deletions src/main/java/de/oliver/fancylib/DistributedWorkload.java

This file was deleted.

78 changes: 20 additions & 58 deletions src/main/java/de/oliver/fancylib/FancyLib.java
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
package de.oliver.fancylib;

import de.oliver.fancylib.checksumChecker.ChecksumFetcher;
import de.oliver.fancyanalytics.logger.ExtendedFancyLogger;
import de.oliver.fancylib.gui.inventoryClick.InventoryClickListener;
import de.oliver.fancylib.gui.inventoryClick.impl.CancelInventoryItemClick;
import de.oliver.fancylib.gui.inventoryClick.impl.ChangePageInventoryItemClick;
Expand All @@ -9,80 +9,38 @@
import de.oliver.fancylib.serverSoftware.schedulers.BukkitScheduler;
import de.oliver.fancylib.serverSoftware.schedulers.FancyScheduler;
import de.oliver.fancylib.serverSoftware.schedulers.FoliaScheduler;
import org.apache.maven.artifact.versioning.ComparableVersion;
import org.bukkit.Bukkit;
import org.bukkit.plugin.Plugin;
import org.bukkit.plugin.java.JavaPlugin;
import org.jetbrains.annotations.ApiStatus;

import java.io.File;

public class FancyLib {

public static final ComparableVersion VERSION = new ComparableVersion("1.0.3");

private static JavaPlugin plugin;
private static FancyScheduler scheduler;
private static FancyLib instance;
private static ExtendedFancyLogger logger = new ExtendedFancyLogger("FancyLib");

public static Plugin getPlugin() {
return plugin;
}
private final JavaPlugin plugin;
private final FancyScheduler scheduler;

/**
* @param pluginJarFile you can get this by calling JavaPlugin#getJarFile
*/
public static void setPlugin(JavaPlugin plugin, File pluginJarFile) {
if (FancyLib.plugin != null) {
return;
}

FancyLib.plugin = plugin;
scheduler = ServerSoftware.isFolia()
public FancyLib(JavaPlugin plugin) {
instance = this;
this.plugin = plugin;
this.scheduler = ServerSoftware.isFolia()
? new FoliaScheduler(plugin)
: new BukkitScheduler(plugin);
}

private static void checkChecksums() {
String actualChecksum = ChecksumFetcher.getChecksum(plugin.getName(), plugin.getDescription().getVersion());
String fileChecksum = FileUtils.getSHA256Checksum(FileUtils.findFirstFileByName(new File("plugins"), plugin.getName()));
public static FancyLib getInstance() {
return instance;
}

if (!actualChecksum.equals("N/A") && !fileChecksum.equals("N/A")) {
if (!actualChecksum.equals(fileChecksum)) {
plugin.getLogger().warning("""
----------------------------------------------------------------
[!]
[!]
[!]
[!] Potential security risk detected!!
[!]
[!]
[!]
[!] The checksum of the plugin jar does not match the official checksum!
[!] This version might be modified and could contain maleware!
[!] Please download the plugin from the official source!
[!] Official checksum: %actualChecksum%
[!] This file's checksum: %fileChecksum%
[!]
[!]
[!]
[!]
[!]
[!]
[!]
----------------------------------------------------------------
"""
.replace("%actualChecksum%", actualChecksum)
.replace("%fileChecksum%", fileChecksum)
);
Bukkit.getPluginManager().disablePlugin(plugin);
}
}
public static ExtendedFancyLogger getLogger() {
return logger;
}

/**
* Registers the listeners for the inventory click and player interact events.
*/
public static void registerListeners() {
public void registerListeners() {
CancelInventoryItemClick.INSTANCE.register();
ChangePageInventoryItemClick.INSTANCE.register();

Expand All @@ -91,7 +49,11 @@ public static void registerListeners() {
}

@ApiStatus.Internal
public static FancyScheduler getScheduler() {
public FancyScheduler getScheduler() {
return scheduler;
}

public JavaPlugin getPlugin() {
return plugin;
}
}
84 changes: 0 additions & 84 deletions src/main/java/de/oliver/fancylib/LanguageConfig.java

This file was deleted.

This file was deleted.

Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@

public interface PageInventory {

NamespacedKey PAGE_KEY = new NamespacedKey(FancyLib.getPlugin(), "page");
NamespacedKey PAGE_KEY = new NamespacedKey(FancyLib.getInstance().getPlugin(), "page");

static ItemStack previousPage(int currentPage) {
ItemStack previousPage = new ItemStack(Material.ARROW);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@

public interface InventoryItemClick {

NamespacedKey ON_CLICK_KEY = new NamespacedKey(FancyLib.getPlugin(), "onclick");
NamespacedKey ON_CLICK_KEY = new NamespacedKey(FancyLib.getInstance().getPlugin(), "onclick");

InventoryItemClick EMPTY = new InventoryItemClick() {
@Override
Expand Down
2 changes: 1 addition & 1 deletion src/main/java/de/oliver/fancylib/itemClick/ItemClick.java
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
import org.bukkit.event.player.PlayerInteractEvent;

public interface ItemClick {
NamespacedKey ON_CLICK_KEY = new NamespacedKey(FancyLib.getPlugin(), "oninteract");
NamespacedKey ON_CLICK_KEY = new NamespacedKey(FancyLib.getInstance().getPlugin(), "oninteract");

ItemClick EMPTY = new ItemClick() {
@Override
Expand Down

0 comments on commit 79fe19a

Please sign in to comment.