Loading in boosters (still untested) started on having proxy communicate booster updates to the server
This commit is contained in:
@@ -8,6 +8,7 @@ import com.alttd.boosters.listeners.MyPetListener;
|
||||
import com.alttd.boosters.listeners.PhantomSpawnListener;
|
||||
import com.alttd.boosters.listeners.PluginMessage;
|
||||
import com.alttd.boosters.managers.BoosterManager;
|
||||
import com.alttd.boosters.storage.ServerBoosterStorage;
|
||||
import org.bukkit.command.CommandExecutor;
|
||||
import org.bukkit.event.Listener;
|
||||
import org.bukkit.plugin.java.JavaPlugin;
|
||||
@@ -36,6 +37,7 @@ public final class BoostersPlugin extends JavaPlugin {
|
||||
|
||||
getServer().getMessenger().registerOutgoingPluginChannel(this, Config.pluginMessageChannel);
|
||||
getServer().getMessenger().registerIncomingPluginChannel(this, Config.pluginMessageChannel, new PluginMessage());
|
||||
ServerBoosterStorage.getServerBoosterStorage(); //this loads the boosters in
|
||||
}
|
||||
|
||||
@Override
|
||||
|
||||
@@ -1,11 +1,16 @@
|
||||
package com.alttd.boosters.listeners;
|
||||
|
||||
import com.alttd.boosterapi.Booster;
|
||||
import com.alttd.boosterapi.config.Config;
|
||||
import com.alttd.boosterapi.util.ALogger;
|
||||
import com.alttd.boosters.storage.ServerBoosterStorage;
|
||||
import com.google.common.io.ByteArrayDataInput;
|
||||
import com.google.common.io.ByteStreams;
|
||||
import org.bukkit.entity.Player;
|
||||
import org.bukkit.plugin.messaging.PluginMessageListener;
|
||||
|
||||
import java.util.UUID;
|
||||
|
||||
public class PluginMessage implements PluginMessageListener {
|
||||
|
||||
@Override
|
||||
@@ -15,8 +20,30 @@ public class PluginMessage implements PluginMessageListener {
|
||||
String subChannel = in.readUTF();
|
||||
// Listen to plugin messages from velocity to either activate or deactive a booster.
|
||||
switch (subChannel) {
|
||||
default:
|
||||
break;
|
||||
case "activate" -> {
|
||||
ServerBoosterStorage.getServerBoosterStorage().reload();
|
||||
//TODO maybe make this add one thing to the map without resetting it to avoid having to clear it
|
||||
// (still need to load it all to get that one booster though)
|
||||
}
|
||||
case "finish" -> {
|
||||
UUID uuid = UUID.fromString(in.readUTF());
|
||||
Booster booster = ServerBoosterStorage.getServerBoosterStorage().getBoosters().get(uuid);
|
||||
if (booster == null) {
|
||||
ALogger.error("Tried to finish booster that was never loaded [" + uuid + "]");
|
||||
break;
|
||||
}
|
||||
booster.finish();
|
||||
}
|
||||
case "stop" -> {
|
||||
UUID uuid = UUID.fromString(in.readUTF());
|
||||
Booster booster = ServerBoosterStorage.getServerBoosterStorage().getBoosters().get(uuid);
|
||||
if (booster == null) {
|
||||
ALogger.error("Tried to stop booster that was never loaded [" + uuid + "]");
|
||||
break;
|
||||
}
|
||||
booster.stopBooster();
|
||||
}
|
||||
default -> {}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user