Mirror von
https://github.com/GeyserMC/Geyser.git
synchronisiert 2024-12-25 15:50:14 +01:00
Fix player table throwing errors on interaction
Dieser Commit ist enthalten in:
Ursprung
cfaf4051b7
Commit
6cdf1eaf43
@ -47,20 +47,19 @@ import java.net.URL;
|
|||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
import java.util.Map;
|
import java.util.Map;
|
||||||
|
import java.util.Vector;
|
||||||
import java.util.concurrent.Executors;
|
import java.util.concurrent.Executors;
|
||||||
import java.util.concurrent.ScheduledExecutorService;
|
import java.util.concurrent.ScheduledExecutorService;
|
||||||
import java.util.concurrent.TimeUnit;
|
import java.util.concurrent.TimeUnit;
|
||||||
|
|
||||||
public class GeyserStandaloneGUI {
|
public class GeyserStandaloneGUI {
|
||||||
|
|
||||||
private static final String[] playerTableHeadings = new String[] {
|
private static final DefaultTableModel playerTableModel = new DefaultTableModel();
|
||||||
LanguageUtils.getLocaleStringLog("geyser.gui.table.ip"),
|
|
||||||
LanguageUtils.getLocaleStringLog("geyser.gui.table.username")};
|
|
||||||
private static final List<Integer> ramValues = new ArrayList<>();
|
private static final List<Integer> ramValues = new ArrayList<>();
|
||||||
|
|
||||||
private static final ColorPane consolePane = new ColorPane();
|
private static final ColorPane consolePane = new ColorPane();
|
||||||
private static final GraphPanel ramGraph = new GraphPanel();
|
private static final GraphPanel ramGraph = new GraphPanel();
|
||||||
private static final JTable playerTable = new JTable(new String[][] { }, playerTableHeadings);
|
private static final JTable playerTable = new JTable(playerTableModel);
|
||||||
private static final int originalFontSize = consolePane.getFont().getSize();
|
private static final int originalFontSize = consolePane.getFont().getSize();
|
||||||
|
|
||||||
private static final long MEGABYTE = 1024L * 1024L;
|
private static final long MEGABYTE = 1024L * 1024L;
|
||||||
@ -201,6 +200,9 @@ public class GeyserStandaloneGUI {
|
|||||||
ramGraph.setXLabel(LanguageUtils.getLocaleStringLog("geyser.gui.graph.loading"));
|
ramGraph.setXLabel(LanguageUtils.getLocaleStringLog("geyser.gui.graph.loading"));
|
||||||
rightContentPane.add(ramGraph);
|
rightContentPane.add(ramGraph);
|
||||||
|
|
||||||
|
playerTableModel.addColumn(LanguageUtils.getLocaleStringLog("geyser.gui.table.ip"));
|
||||||
|
playerTableModel.addColumn(LanguageUtils.getLocaleStringLog("geyser.gui.table.username"));
|
||||||
|
|
||||||
JScrollPane playerScrollPane = new JScrollPane(playerTable);
|
JScrollPane playerScrollPane = new JScrollPane(playerTable);
|
||||||
rightContentPane.add(playerScrollPane);
|
rightContentPane.add(playerScrollPane);
|
||||||
|
|
||||||
@ -288,18 +290,17 @@ public class GeyserStandaloneGUI {
|
|||||||
Runnable periodicTask = () -> {
|
Runnable periodicTask = () -> {
|
||||||
if (GeyserConnector.getInstance() != null) {
|
if (GeyserConnector.getInstance() != null) {
|
||||||
// Update player table
|
// Update player table
|
||||||
String[][] playerNames = new String[GeyserConnector.getInstance().getPlayers().size()][2];
|
playerTableModel.getDataVector().removeAllElements();
|
||||||
int i = 0;
|
|
||||||
for (Map.Entry<InetSocketAddress, GeyserSession> player : GeyserConnector.getInstance().getPlayers().entrySet()) {
|
|
||||||
playerNames[i][0] = player.getKey().getHostName();
|
|
||||||
playerNames[i][1] = player.getValue().getPlayerEntity().getUsername();
|
|
||||||
|
|
||||||
i++;
|
for (Map.Entry<InetSocketAddress, GeyserSession> player : GeyserConnector.getInstance().getPlayers().entrySet()) {
|
||||||
|
Vector row = new Vector();
|
||||||
|
row.add(player.getKey().getHostName());
|
||||||
|
row.add(player.getValue().getPlayerEntity().getUsername());
|
||||||
|
|
||||||
|
playerTableModel.addRow(row);
|
||||||
}
|
}
|
||||||
|
|
||||||
DefaultTableModel model = new DefaultTableModel(playerNames, playerTableHeadings);
|
playerTableModel.fireTableDataChanged();
|
||||||
playerTable.setModel(model);
|
|
||||||
model.fireTableDataChanged();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// Update ram graph
|
// Update ram graph
|
||||||
|
Laden…
In neuem Issue referenzieren
Einen Benutzer sperren