Skip to content

Commit

Permalink
fix(Sponge): Fixed commands on Sponge
Browse files Browse the repository at this point in the history
  • Loading branch information
GeorgeV220 committed Jan 15, 2023
1 parent c1fbc6e commit 78a72ab
Show file tree
Hide file tree
Showing 8 changed files with 49 additions and 47 deletions.
6 changes: 3 additions & 3 deletions build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -71,13 +71,13 @@ allprojects {
compileOnly 'net.md-5:bungeecord-api:1.19-R0.1-SNAPSHOT'
compileOnly 'net.md-5:bungeecord-proxy:1.19-R0.1-SNAPSHOT'
compileOnly 'com.velocitypowered:velocity-api:3.1.1'
compileOnly 'org.spongepowered:spongeapi:9.0.0'
compileOnly 'org.spongepowered:spongeapi:9.1.0-SNAPSHOT'

compileOnly 'co.aikar:acf-paper:0.5.1-G-1.0-SNAPSHOT'
compileOnly 'co.aikar:acf-bungee:0.5.1-G-1.0-SNAPSHOT'
compileOnly 'co.aikar:acf-velocity:0.5.1-G-1.0-SNAPSHOT'
compileOnly 'co.aikar:acf-sponge8:0.5.1-G-1.0-SNAPSHOT'
compileOnly 'com.georgev22:martexlibrary:8.11.0'
compileOnly 'com.georgev22:martexlibrary:8.11.2'
compileOnly 'com.georgev22.api:libraryloader:1.4.0'
compileOnly 'org.jetbrains:annotations:23.1.0'
compileOnly 'commons-codec:commons-codec:1.15'
Expand Down Expand Up @@ -106,7 +106,7 @@ dependencies {
implementation 'co.aikar:acf-bungee:0.5.1-G-1.0-SNAPSHOT'
implementation 'co.aikar:acf-velocity:0.5.1-G-1.0-SNAPSHOT'
implementation 'co.aikar:acf-sponge8:0.5.1-G-1.0-SNAPSHOT'
implementation 'com.georgev22:martexlibrary:8.11.0'
implementation 'com.georgev22:martexlibrary:8.11.2'
implementation 'com.georgev22.api:libraryloader:1.4.0'
implementation 'com.google.code.gson:gson:2.10.1'
implementation project(path: ':core')
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,7 @@ public void onLoad() {
} catch (InvalidDependencyException | UnknownDependencyException e) {
throw new RuntimeException(e);
}
SkinOverlay.getInstance().setCommandManager(new PaperCommandManager(this));
SkinOverlay.getInstance().onLoad(this);
}

Expand All @@ -52,7 +53,6 @@ public void onEnable() {
tick++;
SchedulerManager.getScheduler().mainThreadHeartbeat(tick);
}, 0, 1L);
SkinOverlay.getInstance().setCommandManager(new PaperCommandManager(this));
switch (getCurrentVersion()) {
case V1_17_R1 -> SkinOverlay.getInstance().setSkinHandler(new SkinHandler_1_17());
case V1_18_R1 -> SkinOverlay.getInstance().setSkinHandler(new SkinHandler_1_18());
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -51,13 +51,13 @@ public void onLoad() {
} catch (InvalidDependencyException | UnknownDependencyException e) {
throw new RuntimeException(e);
}
SkinOverlay.getInstance().setCommandManager(new BungeeCommandManager(this));
SkinOverlay.getInstance().onLoad(this);
}

@Override
public void onEnable() {
getProxy().getScheduler().schedule(this, () -> SchedulerManager.getScheduler().mainThreadHeartbeat(tick++), 0, 50L, TimeUnit.MILLISECONDS);
SkinOverlay.getInstance().setCommandManager(new BungeeCommandManager(this));
SkinOverlay.getInstance().setSkinHandler(new SkinHandler() {
@Override
public void updateSkin(@NotNull FileConfiguration fileConfiguration, @NotNull PlayerObject playerObject, boolean reset, @NotNull String skinName) {
Expand Down
9 changes: 4 additions & 5 deletions core/src/main/java/com/georgev22/skinoverlay/SkinOverlay.java
Original file line number Diff line number Diff line change
Expand Up @@ -91,18 +91,18 @@ public static SkinOverlay getInstance() {

public void onLoad(SkinOverlayImpl skinOverlay) {
this.skinOverlay = skinOverlay;
}


public void onEnable() {
fileManager = FileManager.getInstance();
try {
fileManager.loadFiles(getLogger(), this.getClass());
} catch (Exception e) {
throw new RuntimeException(e);
}
MessagesUtil.repairPaths(fileManager.getMessages());
setupCommands();
}


public void onEnable() {
this.skinsDataFolder = new File(this.getDataFolder(), "skins");
if (!this.skinsDataFolder.exists()) {
if (this.skinsDataFolder.mkdirs()) {
Expand All @@ -124,7 +124,6 @@ public void onEnable() {
} catch (Exception e) {
e.printStackTrace();
}
setupCommands();
}

public void onDisable() {
Expand Down
2 changes: 1 addition & 1 deletion sponge/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ dependencies {
}

sponge {
apiVersion("9.0.0")
apiVersion("9.1.0-SNAPSHOT")
loader {
name(PluginLoaders.JAVA_PLAIN)
version("1.0")
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,13 +5,13 @@
import com.georgev22.api.libraryloader.annotations.MavenLibrary;
import com.georgev22.api.libraryloader.exceptions.InvalidDependencyException;
import com.georgev22.api.libraryloader.exceptions.UnknownDependencyException;
import com.georgev22.library.minecraft.SpongeMinecraftUtils;
import com.georgev22.library.scheduler.SchedulerManager;
import com.georgev22.library.utilities.LoggerWrapper;
import com.georgev22.library.utilities.Utils;
import com.georgev22.skinoverlay.handler.SkinHandler;
import com.georgev22.skinoverlay.listeners.sponge.DeveloperInformListener;
import com.georgev22.skinoverlay.listeners.sponge.PlayerListeners;
import com.georgev22.skinoverlay.listeners.sponge.TestListener;
import com.georgev22.skinoverlay.utilities.interfaces.SkinOverlayImpl;
import com.georgev22.skinoverlay.utilities.player.PlayerObject;
import com.georgev22.skinoverlay.utilities.player.PlayerObjectSponge;
Expand Down Expand Up @@ -60,34 +60,49 @@ public SkinOverlaySponge(Logger logger, PluginContainer container, @ConfigDir(sh
this.pluginContainer = container;
this.dataFolder = new File(configDir.toUri());
this.pluginManager = Sponge.pluginManager();
onInit();
}

@Listener
public void onLoad(final @NotNull StartingEngineEvent<Server> event) {
this.server = event.engine();
public void onInit() {
try {
new LibraryLoader(this.getClass(), server.getClass().getClassLoader().getParent(), this.getDataFolder(), getLogger()).loadAll(false);
new LibraryLoader(this.getClass(), Sponge.game().getClass().getClassLoader().getParent(), this.getDataFolder(), getLogger()).loadAll(false);
} catch (InvalidDependencyException | UnknownDependencyException e) {
throw new RuntimeException(e);
}
server.scheduler().submit(Task.builder().plugin(pluginContainer).execute(() -> SchedulerManager.getScheduler().mainThreadHeartbeat(tick++)).interval(50L, TimeUnit.MILLISECONDS).build());
SkinOverlay.getInstance().onLoad(this);
Sponge.eventManager()
.registerListeners(pluginContainer, new TestListener())
.registerListeners(pluginContainer, new PlayerListeners())
.registerListeners(pluginContainer, new DeveloperInformListener());
SkinOverlay.getInstance().setCommandManager(new SpongeCommandManager(pluginContainer, getDataFolder()));
SkinOverlay.getInstance().onLoad(this);
SpongeMinecraftUtils.registerListeners(pluginContainer,
new PlayerListeners(),
new DeveloperInformListener());
}

@Listener
public void onEnable(final @NotNull StartedEngineEvent<Server> event) {
public void onStartingEngine(final @NotNull StartingEngineEvent<Server> event) {
this.server = event.engine();
onLoad();
}

@Listener
public void onStartedEngine(final @NotNull StartedEngineEvent<Server> event) {
onEnable();
}

@Listener
public void onStoppingEngine(final @NotNull StoppingEngineEvent<Server> event) {
onDisable();
}

public void onLoad() {
server.scheduler().submit(Task.builder().plugin(pluginContainer).execute(() -> SchedulerManager.getScheduler().mainThreadHeartbeat(tick++)).interval(50L, TimeUnit.MILLISECONDS).build());
}

public void onEnable() {
SkinOverlay.getInstance().setSkinHandler(new SkinHandler.SkinHandler_());
SkinOverlay.getInstance().onEnable();
this.isEnabled = true;
}

@Listener
public void onDisable(final @NotNull StoppingEngineEvent<Server> event) {
public void onDisable() {
SkinOverlay.getInstance().onDisable();
this.isEnabled = false;
}
Expand All @@ -114,7 +129,12 @@ public Description description() {

@Override
public boolean setEnable(boolean enable) {
return isEnabled = enable;
if (enable) {
onEnable();
} else {
onDisable();
}
return isEnabled();
}

@Override
Expand All @@ -139,9 +159,7 @@ public boolean isOnlineMode() {
@Override
public List<PlayerObject> onlinePlayers() {
List<PlayerObject> playerObjects = Lists.newArrayList();
server.onlinePlayers().forEach(serverPlayer -> {
playerObjects.add(new PlayerObjectSponge(serverPlayer.user()));
});
server.onlinePlayers().forEach(serverPlayer -> playerObjects.add(new PlayerObjectSponge(serverPlayer.user())));
return playerObjects;
}

Expand Down

This file was deleted.

Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
import com.georgev22.api.libraryloader.annotations.MavenLibrary;
import com.georgev22.api.libraryloader.exceptions.InvalidDependencyException;
import com.georgev22.api.libraryloader.exceptions.UnknownDependencyException;
import com.georgev22.library.minecraft.VelocityMinecraftUtils;
import com.georgev22.library.scheduler.SchedulerManager;
import com.georgev22.library.utilities.Utils;
import com.georgev22.library.yaml.file.FileConfiguration;
Expand Down Expand Up @@ -93,13 +94,13 @@ public void onLoad() {
} catch (InvalidDependencyException | UnknownDependencyException e) {
throw new RuntimeException(e);
}
SkinOverlay.getInstance().setCommandManager(new VelocityCommandManager(getProxy(), this, getDataFolder()));
SkinOverlay.getInstance().onLoad(this);
onEnable();
}

public void onEnable() {
getProxy().getScheduler().buildTask(this, () -> SchedulerManager.getScheduler().mainThreadHeartbeat(tick++)).repeat(Duration.ofMillis(50L)).schedule();
SkinOverlay.getInstance().setCommandManager(new VelocityCommandManager(getProxy(), this, getDataFolder()));
SkinOverlay.getInstance().setSkinHandler(new SkinHandler() {
@Override
public void updateSkin(@NotNull FileConfiguration fileConfiguration, @NotNull PlayerObject playerObject, boolean reset, @NotNull String skinName) {
Expand Down Expand Up @@ -129,9 +130,7 @@ protected <T> GameProfile getGameProfile0(@NotNull PlayerObject playerObject) {
}
});
SkinOverlay.getInstance().onEnable();
//BungeeMinecraftUtils.registerListeners(this, new PlayerListeners(), new DeveloperInformListener());
getProxy().getEventManager().register(this, new DeveloperInformListener());
getProxy().getEventManager().register(this, new PlayerListeners());
VelocityMinecraftUtils.registerListeners(getProxy(), this, new DeveloperInformListener(), new PlayerListeners());
enabled = true;
}

Expand Down

0 comments on commit 78a72ab

Please sign in to comment.