Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add setpack subchannel to allow a pack to be set for a player from a … #18

Closed
wants to merge 1 commit into from
Closed
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
import com.google.common.io.ByteArrayDataInput;
import com.google.common.io.ByteStreams;
import de.themoep.resourcepacksplugin.bungee.BungeeResourcepacks;
import de.themoep.resourcepacksplugin.core.ResourcePack;
import net.md_5.bungee.api.connection.ProxiedPlayer;
import net.md_5.bungee.api.connection.Server;
import net.md_5.bungee.api.event.PluginMessageEvent;
Expand All @@ -29,21 +30,33 @@ public void pluginMessageReceived(PluginMessageEvent event) {

ByteArrayDataInput in = ByteStreams.newDataInput(event.getData());
String subchannel = in.readUTF();
if("authMeLogin".equals(subchannel)) {
String playerName = in.readUTF();
UUID playerId = UUID.fromString(in.readUTF());

plugin.setAuthenticated(playerId, true);
if(!plugin.hasBackend(playerId) && plugin.getConfig().getBoolean("useauth", false)) {
ProxiedPlayer player = plugin.getProxy().getPlayer(playerId);
if(player != null) {
String serverName = "";
if(player.getServer() != null) {
serverName = player.getServer().getInfo().getName();

switch(subchannel) {
case "authMeLogin":
String playerName = in.readUTF();
UUID playerId = UUID.fromString(in.readUTF());

plugin.setAuthenticated(playerId, true);
if(!plugin.hasBackend(playerId) && plugin.getConfig().getBoolean("useauth", false)) {
ProxiedPlayer player = plugin.getProxy().getPlayer(playerId);
if(player != null) {
String serverName = "";
if(player.getServer() != null) {
serverName = player.getServer().getInfo().getName();
}
plugin.getPackManager().applyPack(playerId, serverName);
}
}
break;
case "setpack":
ProxiedPlayer player = plugin.getProxy().getPlayer(UUID.fromString(in.readUTF()));
if (player != null) {
ResourcePack pack = plugin.getPackManager().getByName(in.readUTF());
if (pack != null) {
plugin.getPackManager().setPack(player.getUniqueId(), pack, false);
}
plugin.getPackManager().applyPack(playerId, serverName);
}
}
break;
}
}
}