fix: some team stuff
This commit is contained in:
@@ -3,6 +3,7 @@ package me.chayapak1.chomens_bot.plugins;
|
||||
import me.chayapak1.chomens_bot.Bot;
|
||||
import me.chayapak1.chomens_bot.data.Team;
|
||||
import me.chayapak1.chomens_bot.util.UUIDUtilities;
|
||||
import org.geysermc.mcprotocollib.network.event.session.ConnectedEvent;
|
||||
|
||||
import java.util.ArrayList;
|
||||
|
||||
@@ -16,9 +17,20 @@ public class TeamJoinerPlugin extends TickPlugin.Listener {
|
||||
this.bot = bot;
|
||||
this.teamName = bot.config.teamName;
|
||||
|
||||
bot.addListener(new Bot.Listener() {
|
||||
@Override
|
||||
public void connected(ConnectedEvent event) {
|
||||
TeamJoinerPlugin.this.connected();
|
||||
}
|
||||
});
|
||||
|
||||
bot.tick.addListener(this);
|
||||
}
|
||||
|
||||
private void connected () {
|
||||
addTeam();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onTick () {
|
||||
try {
|
||||
|
||||
@@ -3,6 +3,7 @@ package me.chayapak1.chomens_bot.plugins;
|
||||
import me.chayapak1.chomens_bot.Bot;
|
||||
import me.chayapak1.chomens_bot.data.Team;
|
||||
import org.geysermc.mcprotocollib.network.Session;
|
||||
import org.geysermc.mcprotocollib.network.event.session.DisconnectedEvent;
|
||||
import org.geysermc.mcprotocollib.network.packet.Packet;
|
||||
import org.geysermc.mcprotocollib.protocol.packet.ingame.clientbound.scoreboard.ClientboundSetPlayerTeamPacket;
|
||||
|
||||
@@ -15,6 +16,11 @@ public class TeamPlugin extends Bot.Listener {
|
||||
bot.addListener(this);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void disconnected(DisconnectedEvent event) {
|
||||
teams.clear();
|
||||
}
|
||||
|
||||
public synchronized Team findTeamByName (String name) {
|
||||
for (Team team : new ArrayList<>(teams)) {
|
||||
if (team.teamName.equals(name)) return team;
|
||||
|
||||
Reference in New Issue
Block a user