mirror of
https://github.com/GeyserMC/Geyser.git
synced 2024-08-14 23:57:35 +00:00
Fixed remaining merge conflict issues
This commit is contained in:
parent
c8fd024e4a
commit
f1f30e5d19
5 changed files with 96 additions and 197 deletions
|
@ -51,7 +51,6 @@ import org.geysermc.cumulus.form.Form;
|
||||||
import org.geysermc.cumulus.form.util.FormBuilder;
|
import org.geysermc.cumulus.form.util.FormBuilder;
|
||||||
import org.geysermc.erosion.packet.Packets;
|
import org.geysermc.erosion.packet.Packets;
|
||||||
import org.geysermc.floodgate.core.FloodgatePlatform;
|
import org.geysermc.floodgate.core.FloodgatePlatform;
|
||||||
import org.geysermc.floodgate.news.NewsItemAction;
|
|
||||||
import org.geysermc.geyser.api.GeyserApi;
|
import org.geysermc.geyser.api.GeyserApi;
|
||||||
import org.geysermc.geyser.api.event.EventBus;
|
import org.geysermc.geyser.api.event.EventBus;
|
||||||
import org.geysermc.geyser.api.event.EventRegistrar;
|
import org.geysermc.geyser.api.event.EventRegistrar;
|
||||||
|
@ -139,7 +138,6 @@ public class GeyserImpl implements GeyserApi {
|
||||||
|
|
||||||
private final FloodgateProvider floodgateProvider;
|
private final FloodgateProvider floodgateProvider;
|
||||||
private BedrockSkinUploader skinUploader;
|
private BedrockSkinUploader skinUploader;
|
||||||
private NewsHandler newsHandler;
|
|
||||||
|
|
||||||
private UnixSocketClientListener erosionUnixListener;
|
private UnixSocketClientListener erosionUnixListener;
|
||||||
|
|
||||||
|
@ -388,8 +386,6 @@ public class GeyserImpl implements GeyserApi {
|
||||||
|
|
||||||
pendingMicrosoftAuthentication = new PendingMicrosoftAuthentication(config.getPendingAuthenticationTimeout());
|
pendingMicrosoftAuthentication = new PendingMicrosoftAuthentication(config.getPendingAuthenticationTimeout());
|
||||||
|
|
||||||
this.newsHandler = new NewsHandler(BRANCH, this.buildNumber());
|
|
||||||
|
|
||||||
Packets.initGeyser();
|
Packets.initGeyser();
|
||||||
|
|
||||||
if (Epoll.isAvailable()) {
|
if (Epoll.isAvailable()) {
|
||||||
|
@ -560,8 +556,6 @@ public class GeyserImpl implements GeyserApi {
|
||||||
savedRefreshTokens = null;
|
savedRefreshTokens = null;
|
||||||
}
|
}
|
||||||
|
|
||||||
newsHandler.handleNews(null, NewsItemAction.ON_SERVER_STARTED);
|
|
||||||
|
|
||||||
if (isReloading) {
|
if (isReloading) {
|
||||||
this.eventBus.fire(new GeyserPostReloadEvent(this.extensionManager, this.eventBus));
|
this.eventBus.fire(new GeyserPostReloadEvent(this.extensionManager, this.eventBus));
|
||||||
} else {
|
} else {
|
||||||
|
@ -643,7 +637,6 @@ public class GeyserImpl implements GeyserApi {
|
||||||
if (skinUploader != null) {
|
if (skinUploader != null) {
|
||||||
skinUploader.close();
|
skinUploader.close();
|
||||||
}
|
}
|
||||||
newsHandler.shutdown();
|
|
||||||
|
|
||||||
if (this.erosionUnixListener != null) {
|
if (this.erosionUnixListener != null) {
|
||||||
this.erosionUnixListener.close();
|
this.erosionUnixListener.close();
|
||||||
|
|
|
@ -112,8 +112,6 @@ import org.cloudburstmc.protocol.bedrock.data.Ability;
|
||||||
import org.cloudburstmc.protocol.bedrock.data.AbilityLayer;
|
import org.cloudburstmc.protocol.bedrock.data.AbilityLayer;
|
||||||
import org.cloudburstmc.protocol.bedrock.data.AttributeData;
|
import org.cloudburstmc.protocol.bedrock.data.AttributeData;
|
||||||
import org.cloudburstmc.protocol.bedrock.data.AuthoritativeMovementMode;
|
import org.cloudburstmc.protocol.bedrock.data.AuthoritativeMovementMode;
|
||||||
import org.cloudburstmc.protocol.bedrock.data.CameraShakeAction;
|
|
||||||
import org.cloudburstmc.protocol.bedrock.data.CameraShakeType;
|
|
||||||
import org.cloudburstmc.protocol.bedrock.data.ChatRestrictionLevel;
|
import org.cloudburstmc.protocol.bedrock.data.ChatRestrictionLevel;
|
||||||
import org.cloudburstmc.protocol.bedrock.data.ExperimentData;
|
import org.cloudburstmc.protocol.bedrock.data.ExperimentData;
|
||||||
import org.cloudburstmc.protocol.bedrock.data.GamePublishSetting;
|
import org.cloudburstmc.protocol.bedrock.data.GamePublishSetting;
|
||||||
|
@ -129,18 +127,16 @@ import org.cloudburstmc.protocol.bedrock.data.entity.EntityFlag;
|
||||||
import org.cloudburstmc.protocol.bedrock.packet.AvailableEntityIdentifiersPacket;
|
import org.cloudburstmc.protocol.bedrock.packet.AvailableEntityIdentifiersPacket;
|
||||||
import org.cloudburstmc.protocol.bedrock.packet.BedrockPacket;
|
import org.cloudburstmc.protocol.bedrock.packet.BedrockPacket;
|
||||||
import org.cloudburstmc.protocol.bedrock.packet.BiomeDefinitionListPacket;
|
import org.cloudburstmc.protocol.bedrock.packet.BiomeDefinitionListPacket;
|
||||||
import org.cloudburstmc.protocol.bedrock.packet.CameraShakePacket;
|
import org.cloudburstmc.protocol.bedrock.packet.CameraPresetsPacket;
|
||||||
import org.cloudburstmc.protocol.bedrock.packet.ChunkRadiusUpdatedPacket;
|
import org.cloudburstmc.protocol.bedrock.packet.ChunkRadiusUpdatedPacket;
|
||||||
import org.cloudburstmc.protocol.bedrock.packet.ClientboundMapItemDataPacket;
|
import org.cloudburstmc.protocol.bedrock.packet.ClientboundMapItemDataPacket;
|
||||||
import org.cloudburstmc.protocol.bedrock.packet.CraftingDataPacket;
|
import org.cloudburstmc.protocol.bedrock.packet.CraftingDataPacket;
|
||||||
import org.cloudburstmc.protocol.bedrock.packet.CreativeContentPacket;
|
import org.cloudburstmc.protocol.bedrock.packet.CreativeContentPacket;
|
||||||
import org.cloudburstmc.protocol.bedrock.packet.EmoteListPacket;
|
import org.cloudburstmc.protocol.bedrock.packet.EmoteListPacket;
|
||||||
import org.cloudburstmc.protocol.bedrock.packet.EmotePacket;
|
|
||||||
import org.cloudburstmc.protocol.bedrock.packet.GameRulesChangedPacket;
|
import org.cloudburstmc.protocol.bedrock.packet.GameRulesChangedPacket;
|
||||||
import org.cloudburstmc.protocol.bedrock.packet.ItemComponentPacket;
|
import org.cloudburstmc.protocol.bedrock.packet.ItemComponentPacket;
|
||||||
import org.cloudburstmc.protocol.bedrock.packet.LevelSoundEvent2Packet;
|
import org.cloudburstmc.protocol.bedrock.packet.LevelSoundEvent2Packet;
|
||||||
import org.cloudburstmc.protocol.bedrock.packet.PlayStatusPacket;
|
import org.cloudburstmc.protocol.bedrock.packet.PlayStatusPacket;
|
||||||
import org.cloudburstmc.protocol.bedrock.packet.PlayerFogPacket;
|
|
||||||
import org.cloudburstmc.protocol.bedrock.packet.SetTimePacket;
|
import org.cloudburstmc.protocol.bedrock.packet.SetTimePacket;
|
||||||
import org.cloudburstmc.protocol.bedrock.packet.StartGamePacket;
|
import org.cloudburstmc.protocol.bedrock.packet.StartGamePacket;
|
||||||
import org.cloudburstmc.protocol.bedrock.packet.TextPacket;
|
import org.cloudburstmc.protocol.bedrock.packet.TextPacket;
|
||||||
|
@ -148,6 +144,7 @@ import org.cloudburstmc.protocol.bedrock.packet.TransferPacket;
|
||||||
import org.cloudburstmc.protocol.bedrock.packet.UpdateAbilitiesPacket;
|
import org.cloudburstmc.protocol.bedrock.packet.UpdateAbilitiesPacket;
|
||||||
import org.cloudburstmc.protocol.bedrock.packet.UpdateAdventureSettingsPacket;
|
import org.cloudburstmc.protocol.bedrock.packet.UpdateAdventureSettingsPacket;
|
||||||
import org.cloudburstmc.protocol.bedrock.packet.UpdateAttributesPacket;
|
import org.cloudburstmc.protocol.bedrock.packet.UpdateAttributesPacket;
|
||||||
|
import org.cloudburstmc.protocol.bedrock.packet.UpdateClientInputLocksPacket;
|
||||||
import org.cloudburstmc.protocol.bedrock.packet.UpdateSoftEnumPacket;
|
import org.cloudburstmc.protocol.bedrock.packet.UpdateSoftEnumPacket;
|
||||||
import org.cloudburstmc.protocol.common.DefinitionRegistry;
|
import org.cloudburstmc.protocol.common.DefinitionRegistry;
|
||||||
import org.cloudburstmc.protocol.common.util.OptionalBoolean;
|
import org.cloudburstmc.protocol.common.util.OptionalBoolean;
|
||||||
|
@ -171,8 +168,6 @@ import org.geysermc.geyser.api.event.bedrock.SessionLoginEvent;
|
||||||
import org.geysermc.geyser.api.network.AuthType;
|
import org.geysermc.geyser.api.network.AuthType;
|
||||||
import org.geysermc.geyser.api.network.RemoteServer;
|
import org.geysermc.geyser.api.network.RemoteServer;
|
||||||
import org.geysermc.geyser.api.util.PlatformType;
|
import org.geysermc.geyser.api.util.PlatformType;
|
||||||
import org.geysermc.geyser.impl.camera.CameraDefinitions;
|
|
||||||
import org.geysermc.geyser.impl.camera.GeyserCameraData;
|
|
||||||
import org.geysermc.geyser.command.GeyserCommandSource;
|
import org.geysermc.geyser.command.GeyserCommandSource;
|
||||||
import org.geysermc.geyser.configuration.EmoteOffhandWorkaroundOption;
|
import org.geysermc.geyser.configuration.EmoteOffhandWorkaroundOption;
|
||||||
import org.geysermc.geyser.configuration.GeyserConfiguration;
|
import org.geysermc.geyser.configuration.GeyserConfiguration;
|
||||||
|
@ -186,6 +181,8 @@ import org.geysermc.geyser.entity.type.player.SessionPlayerEntity;
|
||||||
import org.geysermc.geyser.erosion.AbstractGeyserboundPacketHandler;
|
import org.geysermc.geyser.erosion.AbstractGeyserboundPacketHandler;
|
||||||
import org.geysermc.geyser.erosion.GeyserboundHandshakePacketHandler;
|
import org.geysermc.geyser.erosion.GeyserboundHandshakePacketHandler;
|
||||||
import org.geysermc.geyser.floodgate.FloodgateProvider;
|
import org.geysermc.geyser.floodgate.FloodgateProvider;
|
||||||
|
import org.geysermc.geyser.impl.camera.CameraDefinitions;
|
||||||
|
import org.geysermc.geyser.impl.camera.GeyserCameraData;
|
||||||
import org.geysermc.geyser.inventory.Inventory;
|
import org.geysermc.geyser.inventory.Inventory;
|
||||||
import org.geysermc.geyser.inventory.PlayerInventory;
|
import org.geysermc.geyser.inventory.PlayerInventory;
|
||||||
import org.geysermc.geyser.inventory.recipe.GeyserRecipe;
|
import org.geysermc.geyser.inventory.recipe.GeyserRecipe;
|
||||||
|
|
|
@ -31,11 +31,11 @@ import com.fasterxml.jackson.databind.ObjectMapper;
|
||||||
import com.fasterxml.jackson.databind.node.ArrayNode;
|
import com.fasterxml.jackson.databind.node.ArrayNode;
|
||||||
import com.fasterxml.jackson.databind.node.ObjectNode;
|
import com.fasterxml.jackson.databind.node.ObjectNode;
|
||||||
import lombok.Getter;
|
import lombok.Getter;
|
||||||
import org.geysermc.floodgate.core.util.WebsocketEventType;
|
|
||||||
import org.geysermc.geyser.Constants;
|
import org.geysermc.geyser.Constants;
|
||||||
import org.geysermc.geyser.GeyserImpl;
|
import org.geysermc.geyser.GeyserImpl;
|
||||||
import org.geysermc.geyser.GeyserLogger;
|
import org.geysermc.geyser.GeyserLogger;
|
||||||
import org.geysermc.geyser.session.GeyserSession;
|
import org.geysermc.geyser.session.GeyserSession;
|
||||||
|
import org.geysermc.geyser.util.WebsocketEventType;
|
||||||
import org.java_websocket.client.WebSocketClient;
|
import org.java_websocket.client.WebSocketClient;
|
||||||
import org.java_websocket.handshake.ServerHandshake;
|
import org.java_websocket.handshake.ServerHandshake;
|
||||||
|
|
||||||
|
|
|
@ -1,182 +0,0 @@
|
||||||
/*
|
|
||||||
* Copyright (c) 2019-2022 GeyserMC. http://geysermc.org
|
|
||||||
*
|
|
||||||
* Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
||||||
* of this software and associated documentation files (the "Software"), to deal
|
|
||||||
* in the Software without restriction, including without limitation the rights
|
|
||||||
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
||||||
* copies of the Software, and to permit persons to whom the Software is
|
|
||||||
* furnished to do so, subject to the following conditions:
|
|
||||||
*
|
|
||||||
* The above copyright notice and this permission notice shall be included in
|
|
||||||
* all copies or substantial portions of the Software.
|
|
||||||
*
|
|
||||||
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
||||||
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
||||||
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
||||||
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
||||||
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
||||||
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
|
|
||||||
* THE SOFTWARE.
|
|
||||||
*
|
|
||||||
* @author GeyserMC
|
|
||||||
* @link https://github.com/GeyserMC/Geyser
|
|
||||||
*/
|
|
||||||
|
|
||||||
package org.geysermc.geyser.util;
|
|
||||||
|
|
||||||
import com.google.gson.Gson;
|
|
||||||
import com.google.gson.JsonArray;
|
|
||||||
import com.google.gson.JsonElement;
|
|
||||||
import com.google.gson.JsonSyntaxException;
|
|
||||||
import org.geysermc.floodgate.news.NewsItem;
|
|
||||||
import org.geysermc.floodgate.news.NewsItemAction;
|
|
||||||
import org.geysermc.floodgate.news.data.AnnouncementData;
|
|
||||||
import org.geysermc.floodgate.news.data.BuildSpecificData;
|
|
||||||
import org.geysermc.floodgate.news.data.CheckAfterData;
|
|
||||||
import org.geysermc.geyser.Constants;
|
|
||||||
import org.geysermc.geyser.GeyserImpl;
|
|
||||||
import org.geysermc.geyser.GeyserLogger;
|
|
||||||
import org.geysermc.geyser.session.GeyserSession;
|
|
||||||
import org.geysermc.geyser.text.ChatColor;
|
|
||||||
|
|
||||||
import java.util.*;
|
|
||||||
import java.util.concurrent.Executors;
|
|
||||||
import java.util.concurrent.ScheduledExecutorService;
|
|
||||||
import java.util.concurrent.TimeUnit;
|
|
||||||
|
|
||||||
public class NewsHandler {
|
|
||||||
private final ScheduledExecutorService executorService = Executors.newScheduledThreadPool(1);
|
|
||||||
private final GeyserLogger logger = GeyserImpl.getInstance().getLogger();
|
|
||||||
private final Gson gson = new Gson();
|
|
||||||
|
|
||||||
private final Map<Integer, NewsItem> activeNewsItems = new HashMap<>();
|
|
||||||
private final String branch;
|
|
||||||
private final int build;
|
|
||||||
|
|
||||||
private boolean firstCheck = true;
|
|
||||||
|
|
||||||
public NewsHandler(String branch, int build) {
|
|
||||||
this.branch = branch;
|
|
||||||
this.build = build;
|
|
||||||
|
|
||||||
executorService.scheduleWithFixedDelay(this::checkNews, 0, 30, TimeUnit.MINUTES);
|
|
||||||
}
|
|
||||||
|
|
||||||
private void schedule(long delayMs) {
|
|
||||||
executorService.schedule(this::checkNews, delayMs, TimeUnit.MILLISECONDS);
|
|
||||||
}
|
|
||||||
|
|
||||||
private void checkNews() {
|
|
||||||
try {
|
|
||||||
String body = WebUtils.getBody(Constants.NEWS_OVERVIEW_URL + Constants.NEWS_PROJECT_NAME);
|
|
||||||
JsonArray array = gson.fromJson(body, JsonArray.class);
|
|
||||||
|
|
||||||
try {
|
|
||||||
for (JsonElement newsItemElement : array) {
|
|
||||||
NewsItem newsItem = NewsItem.readItem(newsItemElement.getAsJsonObject());
|
|
||||||
if (newsItem != null) {
|
|
||||||
addNews(newsItem);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
firstCheck = false;
|
|
||||||
} catch (Exception e) {
|
|
||||||
if (logger.isDebug()) {
|
|
||||||
logger.error("Error while reading news item", e);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
} catch (JsonSyntaxException ignored) {}
|
|
||||||
}
|
|
||||||
|
|
||||||
public void handleNews(GeyserSession session, NewsItemAction action) {
|
|
||||||
for (NewsItem news : getActiveNews(action)) {
|
|
||||||
handleNewsItem(session, news, action);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
private void handleNewsItem(GeyserSession session, NewsItem news, NewsItemAction action) {
|
|
||||||
switch (action) {
|
|
||||||
case ON_SERVER_STARTED:
|
|
||||||
if (!firstCheck) {
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
case BROADCAST_TO_CONSOLE:
|
|
||||||
logger.info(news.getMessage());
|
|
||||||
break;
|
|
||||||
case ON_OPERATOR_JOIN:
|
|
||||||
//todo doesn't work, it's called before we know the op level.
|
|
||||||
// if (session != null && session.getOpPermissionLevel() >= 2) {
|
|
||||||
// session.sendMessage(ChatColor.GREEN + news.getMessage());
|
|
||||||
// }
|
|
||||||
break;
|
|
||||||
case BROADCAST_TO_OPERATORS:
|
|
||||||
for (GeyserSession player : GeyserImpl.getInstance().getSessionManager().getSessions().values()) {
|
|
||||||
if (player.getOpPermissionLevel() >= 2) {
|
|
||||||
session.sendMessage(ChatColor.GREEN + news.getMessage());
|
|
||||||
}
|
|
||||||
}
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
public Collection<NewsItem> getActiveNews() {
|
|
||||||
return activeNewsItems.values();
|
|
||||||
}
|
|
||||||
|
|
||||||
public Collection<NewsItem> getActiveNews(NewsItemAction action) {
|
|
||||||
List<NewsItem> news = new ArrayList<>();
|
|
||||||
for (NewsItem item : getActiveNews()) {
|
|
||||||
if (item.getActions().contains(action)) {
|
|
||||||
news.add(item);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
return news;
|
|
||||||
}
|
|
||||||
|
|
||||||
public void addNews(NewsItem item) {
|
|
||||||
if (activeNewsItems.containsKey(item.getId())) {
|
|
||||||
if (!item.isActive()) {
|
|
||||||
activeNewsItems.remove(item.getId());
|
|
||||||
}
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (!item.isActive()) {
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
switch (item.getType()) {
|
|
||||||
case ANNOUNCEMENT:
|
|
||||||
if (!item.getDataAs(AnnouncementData.class).isAffected(Constants.NEWS_PROJECT_NAME)) {
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
break;
|
|
||||||
case BUILD_SPECIFIC:
|
|
||||||
if (!item.getDataAs(BuildSpecificData.class).isAffected(branch, build)) {
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
break;
|
|
||||||
case CHECK_AFTER:
|
|
||||||
long checkAfter = item.getDataAs(CheckAfterData.class).getCheckAfter();
|
|
||||||
long delayMs = System.currentTimeMillis() - checkAfter;
|
|
||||||
schedule(delayMs > 0 ? delayMs : 0);
|
|
||||||
break;
|
|
||||||
case CONFIG_SPECIFIC:
|
|
||||||
//todo implement
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
|
|
||||||
activeNewsItems.put(item.getId(), item);
|
|
||||||
activateNews(item);
|
|
||||||
}
|
|
||||||
|
|
||||||
private void activateNews(NewsItem item) {
|
|
||||||
for (NewsItemAction action : item.getActions()) {
|
|
||||||
handleNewsItem(null, item, action);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
public void shutdown() {
|
|
||||||
executorService.shutdown();
|
|
||||||
}
|
|
||||||
}
|
|
|
@ -0,0 +1,91 @@
|
||||||
|
/*
|
||||||
|
* Copyright (c) 2019-2024 GeyserMC. http://geysermc.org
|
||||||
|
*
|
||||||
|
* Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||||
|
* of this software and associated documentation files (the "Software"), to deal
|
||||||
|
* in the Software without restriction, including without limitation the rights
|
||||||
|
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
||||||
|
* copies of the Software, and to permit persons to whom the Software is
|
||||||
|
* furnished to do so, subject to the following conditions:
|
||||||
|
*
|
||||||
|
* The above copyright notice and this permission notice shall be included in
|
||||||
|
* all copies or substantial portions of the Software.
|
||||||
|
*
|
||||||
|
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||||
|
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||||
|
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
||||||
|
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
||||||
|
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
||||||
|
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
|
||||||
|
* THE SOFTWARE.
|
||||||
|
*
|
||||||
|
* @author GeyserMC
|
||||||
|
* @link https://github.com/GeyserMC/Geyser
|
||||||
|
*/
|
||||||
|
|
||||||
|
package org.geysermc.geyser.util;
|
||||||
|
|
||||||
|
public enum WebsocketEventType {
|
||||||
|
/**
|
||||||
|
* Sent once we successfully connected to the server
|
||||||
|
*/
|
||||||
|
SUBSCRIBER_CREATED(0),
|
||||||
|
/**
|
||||||
|
* Sent every time a subscriber got added or disconnected
|
||||||
|
*/
|
||||||
|
SUBSCRIBER_COUNT(1),
|
||||||
|
/**
|
||||||
|
* Sent once the creator disconnected. After this packet the server will automatically close the
|
||||||
|
* connection once the queue size (sent in {@link #ADDED_TO_QUEUE} and {@link #SKIN_UPLOADED}
|
||||||
|
* reaches 0.
|
||||||
|
*/
|
||||||
|
CREATOR_DISCONNECTED(4),
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Sent every time a skin got added to the upload queue
|
||||||
|
*/
|
||||||
|
ADDED_TO_QUEUE(2),
|
||||||
|
/**
|
||||||
|
* Sent every time a skin got successfully uploaded
|
||||||
|
*/
|
||||||
|
SKIN_UPLOADED(3),
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Sent every time a news item was added
|
||||||
|
*/
|
||||||
|
NEWS_ADDED(6),
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Sent when the server wants you to know something. Currently used for violations that aren't
|
||||||
|
* bad enough to close the connection
|
||||||
|
*/
|
||||||
|
LOG_MESSAGE(5);
|
||||||
|
|
||||||
|
private static final WebsocketEventType[] VALUES;
|
||||||
|
|
||||||
|
static {
|
||||||
|
WebsocketEventType[] values = values();
|
||||||
|
VALUES = new WebsocketEventType[values.length];
|
||||||
|
for (WebsocketEventType value : values) {
|
||||||
|
VALUES[value.id] = value;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* The ID is based of the time it got added. However, to keep the enum organized as time goes on,
|
||||||
|
* it looks nicer to sort the events based of categories.
|
||||||
|
*/
|
||||||
|
private final int id;
|
||||||
|
|
||||||
|
WebsocketEventType(int id) {
|
||||||
|
this.id = id;
|
||||||
|
}
|
||||||
|
|
||||||
|
public static WebsocketEventType fromId(int id) {
|
||||||
|
return VALUES.length > id ? VALUES[id] : null;
|
||||||
|
}
|
||||||
|
|
||||||
|
public int id() {
|
||||||
|
return id;
|
||||||
|
}
|
||||||
|
}
|
Loading…
Reference in a new issue