Skip to content

Commit

Permalink
Fix SkylliaInfo
Browse files Browse the repository at this point in the history
  • Loading branch information
Euphillya committed Jan 6, 2025
1 parent 6f3b53c commit 7610db4
Show file tree
Hide file tree
Showing 15 changed files with 242 additions and 41 deletions.
1 change: 1 addition & 0 deletions .idea/gradle.xml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

3 changes: 2 additions & 1 deletion addons/SkylliaInfo/build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ plugins {
}

group = "fr.euphyllia.skyllia";
version = "1.1";
version = "1.2";

repositories {
maven("https://repo.oraxen.com/releases")
Expand All @@ -18,6 +18,7 @@ dependencies {
// Addons
compileOnly(project(":addons:SkylliaOre"))
compileOnly(project(":addons:SkylliaBank"))
compileOnly(project(":addons:SkylliaValueAPI"))
}

java {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -30,8 +30,14 @@
public class IslandInfoCommand implements SubCommandInterface {

private final MiniMessage miniMessage = MiniMessage.miniMessage();
private final boolean skylliaBank;
private final boolean skylliaValue;
private final boolean skylliaOre;

public IslandInfoCommand(Main main) {
this.skylliaBank = Bukkit.getPluginManager().getPlugin("SkylliaBank") != null;
this.skylliaValue = Bukkit.getPluginManager().getPlugin("SkylliaValue") != null;
this.skylliaOre = Bukkit.getPluginManager().getPlugin("SkylliaOre") != null;
}


Expand Down Expand Up @@ -71,10 +77,10 @@ public boolean onCommand(@NotNull Plugin plugin, @NotNull CommandSender sender,
player.sendMessage(miniMessage.deserialize("<gold>=== Island Information ===</gold>"));
player.sendMessage(miniMessage.deserialize(
"<yellow>Island ID: </yellow><white>" + islandName + "</white>"));
if (Bukkit.getPluginManager().isPluginEnabled("SkylliaBank")) {
if (this.skylliaBank) {
SkylliaBankHook.sendMessage(miniMessage, player, islandId);
}
if (Bukkit.getPluginManager().isPluginEnabled("SkylliaValue")) {
if (this.skylliaValue) {
// This plugin is not made public, because it belongs to www.excalia.fr
// If you want to have the plugin, you will have to see with
// their Excalia administrator (https://discord.gg/excalia)
Expand All @@ -92,7 +98,7 @@ public boolean onCommand(@NotNull Plugin plugin, @NotNull CommandSender sender,
"<yellow>Online Members: </yellow><white>"
+ members.stream().filter(players -> Bukkit.getOfflinePlayer(players.getMojangId()).isOnline()).count()
+ "/" + members.size() + "</white>"));
if (Bukkit.getPluginManager().isPluginEnabled("SkylliaOre")) {
if (this.skylliaOre) {
SkylliaOreHook.sendMessage(miniMessage, player, islandId);
}

Expand All @@ -109,8 +115,6 @@ public boolean onCommand(@NotNull Plugin plugin, @NotNull CommandSender sender,
}

});


return true;
}

Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
package fr.euphyllia.skylliainfo.hook;

import fr.euphyllia.skylliabank.SkylliaBank;
import net.kyori.adventure.text.minimessage.MiniMessage;
import org.bukkit.entity.Player;

Expand All @@ -9,7 +8,7 @@
public class SkylliaBankHook {

public static void sendMessage(MiniMessage miniMessage, Player player, UUID islandId) {
SkylliaBank.getBankManager().getBankAccount(islandId).thenAcceptAsync(bankAccount -> {
fr.euphyllia.skylliabank.SkylliaBank.getBankManager().getBankAccount(islandId).thenAcceptAsync(bankAccount -> {
player.sendMessage(miniMessage.deserialize(
"<yellow>Bank: </yellow><white>" + bankAccount.balance() + "</white>"));
});
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,41 +3,15 @@
import net.kyori.adventure.text.minimessage.MiniMessage;
import org.bukkit.entity.Player;

import java.lang.reflect.InvocationTargetException;
import java.lang.reflect.Method;
import java.util.UUID;

public class SkylliaValueHook {
public static void sendMessage(MiniMessage miniMessage, Player player, UUID islandId) {
try {
Class<?> mainClass = Class.forName("fr.excaliamc.skyllia_value.Main");

Method getPluginMethod = mainClass.getMethod("getPlugin", Class.class);

Object mainInstance = getPluginMethod.invoke(null, mainClass);

Method getAPIMethod = mainClass.getMethod("getAPI");

Object apiInstance = getAPIMethod.invoke(mainInstance);

Class<?> apiClass = Class.forName("fr.excaliamc.skyllia_value.api.API");

Method getCacheValueMethod = apiClass.getMethod("getCacheValue");

Object cacheValue = getCacheValueMethod.invoke(apiInstance);

Class<?> cacheValueClass = Class.forName("fr.excaliamc.skyllia_value.database.cache.CacheValue");

Method getValueIslandMethod = cacheValueClass.getMethod("getValueIslandBySkyblockId", UUID.class);

Object islandValue = getValueIslandMethod.invoke(cacheValue, islandId);

player.sendMessage(miniMessage.deserialize(
"<yellow>Island Value: </yellow><white>" + islandValue + "</white>"));
public static void sendMessage(MiniMessage miniMessage, Player player, UUID islandId) {
fr.excaliamc.skyllia_value.database.cache.CacheValue cacheValue = fr.excaliamc.skyllia_value.Main.getPlugin(fr.excaliamc.skyllia_value.Main.class)
.getAPI().getCacheValue();

} catch (ClassNotFoundException | NoSuchMethodException | IllegalAccessException |
InvocationTargetException e) {
e.printStackTrace();
}
player.sendMessage(miniMessage.deserialize(
"<yellow>Island Value: </yellow><white>" + cacheValue.getValueIslandBySkyblockId(islandId) + "</white>"));
}
}
2 changes: 1 addition & 1 deletion addons/SkylliaInfo/src/main/resources/paper-plugin.yml
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ dependencies:
load: BEFORE
required: false
join-classpath: true
SkylliaBankAddon:
SkylliaBank:
load: BEFORE
required: false
join-classpath: true
Expand Down
28 changes: 28 additions & 0 deletions addons/SkylliaValueAPI/build.gradle.kts
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
plugins {
id("java")
}

group = "fr.excaliamc.skyllia_value";
version = "1.1";

repositories {
maven("https://repo.oraxen.com/releases")
}

dependencies {
compileOnly("io.papermc.paper:paper-api:1.21.3-R0.1-SNAPSHOT")
compileOnly(project(":database"))
compileOnly(project(":api"))
compileOnly(project(":plugin"))
}

java {
sourceCompatibility = JavaVersion.VERSION_21
targetCompatibility = JavaVersion.VERSION_21
}

tasks {
compileJava {
options.encoding = "UTF-8"
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
package fr.excaliamc.skyllia_value.API;

import fr.excaliamc.skyllia_value.database.cache.CacheValue;

import java.util.Map;

public class API {
public API() {
}

public CacheValue getCacheValue() {
throw new RuntimeException();
}

public Map<String, Double> getMaterialValue() {
throw new RuntimeException();
}

public void setMaterialValue(Map<String, Double> materialValue) {
throw new RuntimeException();
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,40 @@
package fr.excaliamc.skyllia_value.API.event;

import fr.euphyllia.skyllia.api.skyblock.Island;
import org.bukkit.event.Event;
import org.bukkit.event.HandlerList;
import org.jetbrains.annotations.NotNull;

public class GainValueEvent extends Event {
private static final HandlerList handlerList = new HandlerList();
private final Island skyblockPlayer;
private final double islandValue;
private final double gainValue;

public GainValueEvent(Island skyblock, double islandValue, double gainValue) {
super(true);
this.skyblockPlayer = skyblock;
this.islandValue = islandValue;
this.gainValue = gainValue;
}

public static HandlerList getHandlerList() {
return handlerList;
}

public @NotNull HandlerList getHandlers() {
return handlerList;
}

public Island getSkyblockPlayer() {
return this.skyblockPlayer;
}

public double getIslandValue() {
return this.islandValue;
}

public double getGainValue() {
return gainValue;
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
package fr.excaliamc.skyllia_value;

import fr.excaliamc.skyllia_value.API.API;
import org.bukkit.plugin.java.JavaPlugin;

public final class Main extends JavaPlugin {

public API getAPI() {
throw new RuntimeException();
}

public void onEnable() {
throw new RuntimeException();
}

public void onDisable() {
throw new RuntimeException();
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
package fr.excaliamc.skyllia_value.database;

import fr.euphyllia.skyllia.api.database.DatabaseInitializeQuery;
import fr.euphyllia.skyllia.configuration.ConfigToml;
import fr.euphyllia.skyllia.sgbd.DatabaseLoader;
import fr.euphyllia.skyllia.sgbd.MariaDB;
import fr.euphyllia.skyllia.sgbd.exceptions.DatabaseException;
import fr.euphyllia.skyllia.sgbd.execute.MariaDBExecute;
import fr.excaliamc.skyllia_value.Main;

public class MariaDBInit extends DatabaseInitializeQuery {

public MariaDBInit() {
this.initializeDatabase();
}

public static DatabaseLoader getDatabaseLoader() {
throw new RuntimeException();
}

private void initializeDatabase() {
throw new RuntimeException();
}

public boolean init() throws DatabaseException {
throw new RuntimeException();
}

public void createTable() throws DatabaseException {
throw new RuntimeException();
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
package fr.excaliamc.skyllia_value.database;

import fr.excaliamc.skyllia_value.models.ItemBrutStock;

import java.sql.Timestamp;
import java.util.*;
import java.util.concurrent.CompletableFuture;

public class ValueQuery {

public ValueQuery() {
}

public CompletableFuture<Boolean> hasIncrement(UUID islandId, String material, byte[] itemStackBytes, int incrementValue) {
throw new RuntimeException();
}

public CompletableFuture<Boolean> hasDecrement(UUID islandId, String material, byte[] itemStackBytes, int decrementValue, Timestamp timestamp) {
throw new RuntimeException();
}

public CompletableFuture<List<ItemBrutStock>> allMaterialOnIsland(UUID islandId) {
throw new RuntimeException();
}

public CompletableFuture<Boolean> updateBlockValuePlot(String material, double value) {
throw new RuntimeException();
}

public CompletableFuture<Map<String, Double>> getValueMaterial() {
throw new RuntimeException();
}

public CompletableFuture<Double> getValueIsland(UUID islandId) {
throw new RuntimeException();
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
package fr.excaliamc.skyllia_value.database.cache;

import java.util.UUID;

public class CacheValue {

public CacheValue() {
}

public Double getValueIslandBySkyblockId(UUID skyblockId) {
throw new RuntimeException();
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
package fr.excaliamc.skyllia_value.models;

import java.sql.Timestamp;

public record ItemBrutStock(String material, byte[] brut, int stock, Timestamp timestamp) {
public ItemBrutStock(String material, byte[] brut, int stock, Timestamp timestamp) {
this.material = material;
this.brut = brut;
this.stock = stock;
this.timestamp = timestamp;
}

public String material() {
return this.material;
}

public byte[] brut() {
return this.brut;
}

public int stock() {
return this.stock;
}

public Timestamp timestamp() {
return this.timestamp;
}
}
5 changes: 4 additions & 1 deletion settings.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -17,4 +17,7 @@ include("addons:PapiSkyllia")
include("addons:InsightsSkyllia")
include("addons:SkylliaChat")
include("addons:SkylliaBank")
include("addons:SkylliaInfo")
include("addons:SkylliaInfo")

// API Addon interne
include("addons:SkylliaValueAPI")

0 comments on commit 7610db4

Please sign in to comment.