Compare commits
5 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
18e7548c23 | ||
|
|
40020b0503 | ||
|
|
830f92bbdb | ||
|
|
c6e39e89fd | ||
|
|
7d38d7db15 |
@@ -57,9 +57,6 @@ allprojects {
|
||||
|
||||
// IridiumSkyblock
|
||||
maven { url 'https://nexus.iridiumdevelopment.net/repository/maven-releases/' }
|
||||
|
||||
// Velocity
|
||||
maven { url 'https://repo.velocitypowered.com/snapshots/' }
|
||||
}
|
||||
|
||||
dependencies {
|
||||
|
||||
@@ -7,6 +7,7 @@ import com.willfp.eco.core.config.updating.ConfigHandler;
|
||||
import com.willfp.eco.core.display.Display;
|
||||
import com.willfp.eco.core.display.DisplayModule;
|
||||
import com.willfp.eco.core.events.EventManager;
|
||||
import com.willfp.eco.core.extensions.Extension;
|
||||
import com.willfp.eco.core.extensions.ExtensionLoader;
|
||||
import com.willfp.eco.core.factory.MetadataValueFactory;
|
||||
import com.willfp.eco.core.factory.NamespacedKeyFactory;
|
||||
@@ -469,6 +470,10 @@ public abstract class EcoPlugin extends JavaPlugin implements PluginLike {
|
||||
|
||||
this.reload();
|
||||
|
||||
for (Extension extension : this.getExtensionLoader().getLoadedExtensions()) {
|
||||
extension.handleAfterLoad();
|
||||
}
|
||||
|
||||
this.getLogger().info("Loaded " + this.color + this.getName());
|
||||
}
|
||||
|
||||
@@ -483,6 +488,10 @@ public abstract class EcoPlugin extends JavaPlugin implements PluginLike {
|
||||
this.getScheduler().cancelAll();
|
||||
|
||||
this.handleReload();
|
||||
|
||||
for (Extension extension : this.extensionLoader.getLoadedExtensions()) {
|
||||
extension.handleReload();
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
@@ -57,6 +57,20 @@ public abstract class Extension implements PluginLike {
|
||||
this.onDisable();
|
||||
}
|
||||
|
||||
/**
|
||||
* Method to handle after load.
|
||||
*/
|
||||
public final void handleAfterLoad() {
|
||||
this.onAfterLoad();
|
||||
}
|
||||
|
||||
/**
|
||||
* Method to handle plugin reloads.
|
||||
*/
|
||||
public final void handleReload() {
|
||||
this.onReload();
|
||||
}
|
||||
|
||||
/**
|
||||
* Called on enabling Extension.
|
||||
*/
|
||||
@@ -67,6 +81,16 @@ public abstract class Extension implements PluginLike {
|
||||
*/
|
||||
protected abstract void onDisable();
|
||||
|
||||
/**
|
||||
* Called the once the base plugin is done loading.
|
||||
*/
|
||||
protected abstract void onAfterLoad();
|
||||
|
||||
/**
|
||||
* Called on plugin reload.
|
||||
*/
|
||||
protected abstract void onReload();
|
||||
|
||||
/**
|
||||
* Set the metadata of the extension.
|
||||
* <p>
|
||||
|
||||
@@ -90,7 +90,17 @@ public class PlayerUtils {
|
||||
profile.write(PLAYER_NAME_KEY, onlinePlayer.getDisplayName());
|
||||
}
|
||||
|
||||
return profile.read(PLAYER_NAME_KEY);
|
||||
String saved = profile.read(PLAYER_NAME_KEY);
|
||||
|
||||
if (saved.equals(PLAYER_NAME_KEY.getDefaultValue())) {
|
||||
String name = player.getName();
|
||||
if (name != null) {
|
||||
profile.write(PLAYER_NAME_KEY, player.getName());
|
||||
return player.getName();
|
||||
}
|
||||
}
|
||||
|
||||
return saved;
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
@@ -42,7 +42,6 @@ dependencies {
|
||||
compileOnly 'com.google.guava:guava:31.0.1-jre'
|
||||
compileOnly 'com.iridium:IridiumSkyblock:3.1.2'
|
||||
compileOnly 'net.md-5:bungeecord-api:1.16-R0.5-SNAPSHOT'
|
||||
compileOnly 'com.velocitypowered:velocity-api:3.0.0-SNAPSHOT'
|
||||
|
||||
// CombatLogX V10 + NewbieHelper Expansion
|
||||
compileOnly 'com.SirBlobman.combatlogx:CombatLogX-API:10.0.0.0-SNAPSHOT'
|
||||
|
||||
@@ -24,7 +24,9 @@ import com.willfp.eco.proxy.FastItemStackFactoryProxy
|
||||
import com.willfp.eco.proxy.SkullProxy
|
||||
import com.willfp.eco.proxy.TPSProxy
|
||||
import com.willfp.eco.spigot.arrows.ArrowDataListener
|
||||
import com.willfp.eco.spigot.data.*
|
||||
import com.willfp.eco.spigot.data.DataListener
|
||||
import com.willfp.eco.spigot.data.EcoPlayerProfileHandler
|
||||
import com.willfp.eco.spigot.data.PlayerBlockListener
|
||||
import com.willfp.eco.spigot.data.storage.DataHandler
|
||||
import com.willfp.eco.spigot.data.storage.MySQLDataHandler
|
||||
import com.willfp.eco.spigot.data.storage.YamlDataHandler
|
||||
@@ -119,7 +121,16 @@ abstract class EcoSpigotPlugin : EcoPlugin(
|
||||
logger.severe("")
|
||||
}
|
||||
|
||||
// Init FIS
|
||||
this.getProxy(FastItemStackFactoryProxy::class.java).create(ItemStack(Material.AIR)).unwrap()
|
||||
|
||||
/*
|
||||
I'll figure this one out eventually...
|
||||
|
||||
if (Prerequisite.HAS_BUNGEECORD.isMet) {
|
||||
BungeeDataListener.register()
|
||||
}
|
||||
*/
|
||||
}
|
||||
|
||||
override fun handleDisable() {
|
||||
@@ -233,7 +244,7 @@ abstract class EcoSpigotPlugin : EcoPlugin(
|
||||
}
|
||||
|
||||
override fun loadListeners(): List<Listener> {
|
||||
val listeners = mutableListOf(
|
||||
return listOf(
|
||||
NaturalExpGainListeners(),
|
||||
ArmorListener(),
|
||||
EntityDeathByEntityListeners(this),
|
||||
@@ -245,15 +256,5 @@ abstract class EcoSpigotPlugin : EcoPlugin(
|
||||
DataListener(),
|
||||
PlayerBlockListener(this)
|
||||
)
|
||||
|
||||
if (Prerequisite.HAS_BUNGEECORD.isMet) {
|
||||
listeners.add(BungeeDataListener())
|
||||
}
|
||||
|
||||
if (Prerequisite.HAS_VELOCITY.isMet) {
|
||||
listeners.add(VelocityDataListener())
|
||||
}
|
||||
|
||||
return listeners
|
||||
}
|
||||
}
|
||||
@@ -1,11 +1,12 @@
|
||||
package com.willfp.eco.spigot.data
|
||||
|
||||
import com.willfp.eco.core.Eco
|
||||
import net.md_5.bungee.api.ProxyServer
|
||||
import net.md_5.bungee.api.event.ServerConnectedEvent
|
||||
import net.md_5.bungee.api.event.ServerDisconnectEvent
|
||||
import net.md_5.bungee.api.event.ServerSwitchEvent
|
||||
import org.bukkit.event.EventHandler
|
||||
import org.bukkit.event.Listener
|
||||
import net.md_5.bungee.api.plugin.Listener
|
||||
import net.md_5.bungee.event.EventHandler
|
||||
|
||||
class BungeeDataListener : Listener {
|
||||
@EventHandler
|
||||
@@ -22,4 +23,12 @@ class BungeeDataListener : Listener {
|
||||
fun onSwitch(event: ServerSwitchEvent) {
|
||||
(Eco.getHandler().playerProfileHandler as EcoPlayerProfileHandler).unloadPlayer(event.player.uniqueId)
|
||||
}
|
||||
|
||||
companion object {
|
||||
fun register() {
|
||||
ProxyServer.getInstance().pluginManager.registerListener(
|
||||
null, BungeeDataListener()
|
||||
)
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -16,7 +16,7 @@ class DataListener : Listener {
|
||||
|
||||
@EventHandler
|
||||
fun onJoin(event: PlayerJoinEvent) {
|
||||
(Eco.getHandler().playerProfileHandler as EcoPlayerProfileHandler).unloadPlayer(event.player.uniqueId)
|
||||
(Eco.getHandler().playerProfileHandler as EcoPlayerProfileHandler).unloadPlayerBlocking(event.player.uniqueId)
|
||||
PlayerUtils.updateSavedDisplayName(event.player)
|
||||
}
|
||||
}
|
||||
|
||||
@@ -7,7 +7,7 @@ import com.willfp.eco.core.data.keys.PersistentDataKey
|
||||
import com.willfp.eco.internal.data.EcoPlayerProfile
|
||||
import com.willfp.eco.spigot.EcoSpigotPlugin
|
||||
import org.bukkit.Bukkit
|
||||
import java.util.UUID
|
||||
import java.util.*
|
||||
|
||||
class EcoPlayerProfileHandler(
|
||||
private val plugin: EcoSpigotPlugin
|
||||
@@ -37,6 +37,11 @@ class EcoPlayerProfileHandler(
|
||||
loaded.remove(uuid)
|
||||
}
|
||||
|
||||
fun unloadPlayerBlocking(uuid: UUID) {
|
||||
handler.saveAllBlocking(listOf(uuid))
|
||||
loaded.remove(uuid)
|
||||
}
|
||||
|
||||
override fun savePlayer(uuid: UUID) {
|
||||
handler.savePlayer(uuid)
|
||||
}
|
||||
|
||||
@@ -1,19 +0,0 @@
|
||||
package com.willfp.eco.spigot.data
|
||||
|
||||
import com.velocitypowered.api.event.connection.DisconnectEvent
|
||||
import com.velocitypowered.api.event.player.ServerConnectedEvent
|
||||
import com.willfp.eco.core.Eco
|
||||
import org.bukkit.event.EventHandler
|
||||
import org.bukkit.event.Listener
|
||||
|
||||
class VelocityDataListener : Listener {
|
||||
@EventHandler
|
||||
fun onConnected(event: ServerConnectedEvent) {
|
||||
(Eco.getHandler().playerProfileHandler as EcoPlayerProfileHandler).unloadPlayer(event.player.uniqueId)
|
||||
}
|
||||
|
||||
@EventHandler
|
||||
fun onDisconnect(event: DisconnectEvent) {
|
||||
(Eco.getHandler().playerProfileHandler as EcoPlayerProfileHandler).unloadPlayer(event.player.uniqueId)
|
||||
}
|
||||
}
|
||||
@@ -1,2 +1,2 @@
|
||||
version = 6.13.2
|
||||
version = 6.13.4
|
||||
plugin-name = eco
|
||||
Reference in New Issue
Block a user