Files
sayu
config.yml
manifest.kod
paper-plugin.yml
plugin.yml
Code
11 654
sayu/SayuStacker/ItemMerge.java
package org.sayu.SayuStacker;
import com.tcoded.folialib.FoliaLib;
import org.bukkit.plugin.java.JavaPlugin;
import org.sayu.SayuStacker.listener.ItemMergeTask;
import org.sayu.SayuStacker.listener.ItemSpawnListener;
import org.sayu.SayuStacker.listener.PlayerPickupListener;
import org.sayu.SayuStacker.manager.ItemMergeManager;
public class ItemMerge extends JavaPlugin {
private static ItemMerge instance;
private FoliaLib foliaLib;
public void onEnable() {
instance = this;
this.foliaLib = new FoliaLib(this);
this.saveDefaultConfig();
getServer().getPluginManager().registerEvents(new ItemSpawnListener(), this);
getServer().getPluginManager().registerEvents(new PlayerPickupListener(), this);
// Schedule merge task only for Spigot/Paper (not Folia)
// Folia uses event-based merging only due to region threading
if (!foliaLib.isFolia()) {
long mergeInterval = this.getConfig().getLong("merge-interval", 40L);
ItemMergeTask mergeTask = new ItemMergeTask(this);
this.foliaLib.getScheduler().runTimer(mergeTask::run, mergeInterval, mergeInterval);
this.getLogger().info("Periodic merge task enabled (interval: " + mergeInterval + " ticks)");
} else {
this.getLogger().info("Running on Folia - using event-based merging only");
}
this.getLogger().info("ItemMerge Plugin Enabled!");
this.getLogger().info("Running on: " + (foliaLib.isFolia() ? "Folia" : foliaLib.isPaper() ? "Paper" : "Spigot"));
}
public void onDisable() {
if (foliaLib != null) {
foliaLib.getScheduler().cancelAllTasks();
}
this.getLogger().info("ItemMerge Plugin Disabled!");
}
public static ItemMerge getInstance() {
return instance;
}
public FoliaLib getFoliaLib() {
return foliaLib;
}
public String getHologramFormat() {
return this.getConfig().getString("hologram.format", "<yellow>▶ <amount_color>x{amount} <white>{name}");
}
public int getMediumThreshold() {
return this.getConfig().getInt("hologram.thresholds.medium", 61);
}
public int getHighThreshold() {
return this.getConfig().getInt("hologram.thresholds.high", 251);
}
public double getMergeDistance() {
return this.getConfig().getDouble("merge-distance", 8.0);
}
public String getPickupSound() {
return this.getConfig().getString("pickup-sound", "ENTITY_ITEM_PICKUP");
}
public int getMaxStackAmount() {
return this.getConfig().getInt("max-stack-amount", 0);
}
}