-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
a5d3b48
commit b4a3f12
Showing
2 changed files
with
107 additions
and
70 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
21 changes: 17 additions & 4 deletions
21
src/main/java/xyz/nifeather/morph/network/server/handlers/LegacyCommandPacketHandler.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,24 +1,37 @@ | ||
package xyz.nifeather.morph.network.server.handlers; | ||
|
||
import org.apache.commons.lang.NotImplementedException; | ||
import org.bukkit.entity.Player; | ||
import org.jetbrains.annotations.NotNull; | ||
import xyz.nifeather.morph.network.server.handlers.results.CommandHandleResult; | ||
import xyz.nifeather.morph.network.server.handlers.results.VersionHandleResult; | ||
|
||
public class LegacyCommandPacketHandler implements ICommandPacketHandler | ||
import java.nio.charset.StandardCharsets; | ||
|
||
public class LegacyCommandPacketHandler extends AbstractCommandPacketHandler | ||
{ | ||
public static final LegacyCommandPacketHandler INSTANCE = new LegacyCommandPacketHandler(); | ||
|
||
@Override | ||
@NotNull | ||
public VersionHandleResult handleVersionData(Player player, byte @NotNull [] rawData) | ||
{ | ||
throw new NotImplementedException(); | ||
try | ||
{ | ||
var clientVersionStr = new String(rawData, StandardCharsets.UTF_8); | ||
|
||
return VersionHandleResult.from(Integer.parseInt(clientVersionStr)); | ||
} | ||
catch (Throwable t) | ||
{ | ||
logger.error("Failed to decode client version from legacy buffer: " + t.getMessage()); | ||
return VersionHandleResult.fail(); | ||
} | ||
} | ||
|
||
@Override | ||
@NotNull | ||
public CommandHandleResult handleCommandData(Player player, byte @NotNull [] rawData) | ||
{ | ||
throw new NotImplementedException(); | ||
return CommandHandleResult.from(new String(rawData, StandardCharsets.UTF_8)); | ||
} | ||
} |