Minor refactors and tweaks, update README

This commit is contained in:
RednedEpic 2019-08-03 22:24:53 -05:00
parent bfa4abf9c8
commit 128769dee8
13 changed files with 161 additions and 51 deletions

View file

@ -24,9 +24,14 @@ Links:
- [x] Join detection from remote - [x] Join detection from remote
- [x] Online mode/auth support - [x] Online mode/auth support
- [x] Chat/command support - [x] Chat/command support
- [ ] Scoreboard
- [x] Objective-based scoreboards
- [ ] Team-based scoreboards
- [ ] Inventory support - [ ] Inventory support
- [ ] Movement support - [x] Inventory viewing
- [ ] Entity support - [ ] Inventory movement (transactions)
- [ ] Player movement support
- [x] Entity support (experimental)
- [ ] Chunks - [ ] Chunks
- [ ] Block break/place support - [ ] Block break/place support

View file

@ -150,11 +150,12 @@ public class GeyserSession implements PlayerSession, Player {
public void disconnected(DisconnectedEvent event) { public void disconnected(DisconnectedEvent event) {
loggedIn = false; loggedIn = false;
connector.getLogger().info(authenticationData.getName() + " has disconnected from remote java server on address " + remoteServer.getAddress() + " because of " + event.getReason()); connector.getLogger().info(authenticationData.getName() + " has disconnected from remote java server on address " + remoteServer.getAddress() + " because of " + event.getReason());
upstream.disconnect(event.getReason()); disconnect(event.getReason());
} }
@Override @Override
public void packetReceived(PacketReceivedEvent event) { public void packetReceived(PacketReceivedEvent event) {
if (!closed)
Registry.JAVA.translate(event.getPacket().getClass(), event.getPacket(), GeyserSession.this); Registry.JAVA.translate(event.getPacket().getClass(), event.getPacket(), GeyserSession.this);
} }
}); });
@ -175,6 +176,8 @@ public class GeyserSession implements PlayerSession, Player {
upstream.disconnect(reason); upstream.disconnect(reason);
} }
} }
closed = true;
} }
@Override @Override

View file

@ -29,7 +29,7 @@ import com.nukkitx.protocol.bedrock.packet.RemoveObjectivePacket;
import lombok.Getter; import lombok.Getter;
import lombok.Setter; import lombok.Setter;
import org.geysermc.connector.network.session.GeyserSession; import org.geysermc.connector.network.session.GeyserSession;
import org.geysermc.connector.network.translators.scoreboard.Scoreboard; import org.geysermc.connector.scoreboard.Scoreboard;
public class ScoreboardCache { public class ScoreboardCache {

View file

@ -85,7 +85,7 @@ import org.geysermc.connector.network.translators.java.entity.spawn.JavaSpawnMob
import org.geysermc.connector.network.translators.java.entity.spawn.JavaSpawnObjectTranslator; import org.geysermc.connector.network.translators.java.entity.spawn.JavaSpawnObjectTranslator;
import org.geysermc.connector.network.translators.java.entity.spawn.JavaSpawnPaintingTranslator; import org.geysermc.connector.network.translators.java.entity.spawn.JavaSpawnPaintingTranslator;
import org.geysermc.connector.network.translators.java.entity.spawn.JavaSpawnPlayerTranslator; import org.geysermc.connector.network.translators.java.entity.spawn.JavaSpawnPlayerTranslator;
import org.geysermc.connector.network.translators.java.scoreboard.JavaScoreboardDisplayTranslator; import org.geysermc.connector.network.translators.java.scoreboard.JavaDisplayScoreboardTranslator;
import org.geysermc.connector.network.translators.java.scoreboard.JavaScoreboardObjectiveTranslator; import org.geysermc.connector.network.translators.java.scoreboard.JavaScoreboardObjectiveTranslator;
import org.geysermc.connector.network.translators.java.scoreboard.JavaUpdateScoreTranslator; import org.geysermc.connector.network.translators.java.scoreboard.JavaUpdateScoreTranslator;
import org.geysermc.connector.network.translators.java.world.JavaNotifyClientTranslator; import org.geysermc.connector.network.translators.java.world.JavaNotifyClientTranslator;
@ -155,7 +155,7 @@ public class TranslatorsInit {
Registry.registerJava(ServerOpenWindowPacket.class, new JavaOpenWindowTranslator()); Registry.registerJava(ServerOpenWindowPacket.class, new JavaOpenWindowTranslator());
Registry.registerJava(ServerSetSlotPacket.class, new JavaSetSlotTranslator()); Registry.registerJava(ServerSetSlotPacket.class, new JavaSetSlotTranslator());
Registry.registerJava(ServerScoreboardObjectivePacket.class, new JavaScoreboardObjectiveTranslator()); Registry.registerJava(ServerScoreboardObjectivePacket.class, new JavaScoreboardObjectiveTranslator());
Registry.registerJava(ServerDisplayScoreboardPacket.class, new JavaScoreboardDisplayTranslator()); Registry.registerJava(ServerDisplayScoreboardPacket.class, new JavaDisplayScoreboardTranslator());
Registry.registerJava(ServerUpdateScorePacket.class, new JavaUpdateScoreTranslator()); Registry.registerJava(ServerUpdateScorePacket.class, new JavaUpdateScoreTranslator());
Registry.registerBedrock(AnimatePacket.class, new BedrockAnimateTranslator()); Registry.registerBedrock(AnimatePacket.class, new BedrockAnimateTranslator());

View file

@ -0,0 +1,46 @@
/*
* Copyright (c) 2019 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.connector.network.translators.java.scoreboard;
import com.github.steveice10.mc.protocol.packet.ingame.server.scoreboard.ServerDisplayScoreboardPacket;
import org.geysermc.connector.network.session.GeyserSession;
import org.geysermc.connector.network.session.cache.ScoreboardCache;
import org.geysermc.connector.network.translators.PacketTranslator;
import org.geysermc.connector.scoreboard.Scoreboard;
public class JavaDisplayScoreboardTranslator extends PacketTranslator<ServerDisplayScoreboardPacket> {
@Override
public void translate(ServerDisplayScoreboardPacket packet, GeyserSession session) {
try {
ScoreboardCache cache = session.getScoreboardCache();
Scoreboard scoreboard = new Scoreboard(session);
cache.setScoreboard(scoreboard);
} catch (Exception ex) {
ex.printStackTrace();
}
}
}

View file

@ -1,19 +0,0 @@
package org.geysermc.connector.network.translators.java.scoreboard;
import com.github.steveice10.mc.protocol.packet.ingame.server.scoreboard.ServerDisplayScoreboardPacket;
import org.geysermc.connector.network.session.GeyserSession;
import org.geysermc.connector.network.session.cache.ScoreboardCache;
import org.geysermc.connector.network.translators.PacketTranslator;
import org.geysermc.connector.network.translators.scoreboard.Scoreboard;
public class JavaScoreboardDisplayTranslator extends PacketTranslator<ServerDisplayScoreboardPacket> {
@Override
public void translate(ServerDisplayScoreboardPacket packet, GeyserSession session) {
try {
ScoreboardCache cache = session.getScoreboardCache();
Scoreboard scoreboard = new Scoreboard(session);
} catch (Exception ex) {
ex.printStackTrace();
}
}
}

View file

@ -1,14 +1,40 @@
/*
* Copyright (c) 2019 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.connector.network.translators.java.scoreboard; package org.geysermc.connector.network.translators.java.scoreboard;
import com.github.steveice10.mc.protocol.packet.ingame.server.scoreboard.ServerScoreboardObjectivePacket; import com.github.steveice10.mc.protocol.packet.ingame.server.scoreboard.ServerScoreboardObjectivePacket;
import org.geysermc.connector.network.session.GeyserSession; import org.geysermc.connector.network.session.GeyserSession;
import org.geysermc.connector.network.session.cache.ScoreboardCache; import org.geysermc.connector.network.session.cache.ScoreboardCache;
import org.geysermc.connector.network.translators.PacketTranslator; import org.geysermc.connector.network.translators.PacketTranslator;
import org.geysermc.connector.network.translators.scoreboard.Scoreboard; import org.geysermc.connector.scoreboard.Scoreboard;
import org.geysermc.connector.network.translators.scoreboard.ScoreboardObjective; import org.geysermc.connector.scoreboard.ScoreboardObjective;
import org.geysermc.connector.utils.MessageUtils; import org.geysermc.connector.utils.MessageUtils;
public class JavaScoreboardObjectiveTranslator extends PacketTranslator<ServerScoreboardObjectivePacket> { public class JavaScoreboardObjectiveTranslator extends PacketTranslator<ServerScoreboardObjectivePacket> {
@Override @Override
public void translate(ServerScoreboardObjectivePacket packet, GeyserSession session) { public void translate(ServerScoreboardObjectivePacket packet, GeyserSession session) {
try { try {

View file

@ -1,17 +0,0 @@
package org.geysermc.connector.network.translators.java.scoreboard;
import com.github.steveice10.mc.protocol.packet.ingame.server.scoreboard.ServerTeamPacket;
import com.nukkitx.protocol.bedrock.packet.SetScorePacket;
import org.geysermc.connector.network.session.GeyserSession;
import org.geysermc.connector.network.session.cache.ScoreboardCache;
import org.geysermc.connector.network.translators.PacketTranslator;
import org.geysermc.connector.network.translators.scoreboard.Scoreboard;
import org.geysermc.connector.network.translators.scoreboard.ScoreboardObjective;
import org.geysermc.connector.utils.MessageUtils;
public class JavaScoreboardTeamTranslator extends PacketTranslator<ServerTeamPacket> {
@Override
public void translate(ServerTeamPacket packet, GeyserSession session) {
}
}

View file

@ -0,0 +1,38 @@
/*
* Copyright (c) 2019 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.connector.network.translators.java.scoreboard;
import com.github.steveice10.mc.protocol.packet.ingame.server.scoreboard.ServerTeamPacket;
import org.geysermc.connector.network.session.GeyserSession;
import org.geysermc.connector.network.translators.PacketTranslator;
public class JavaTeamTranslator extends PacketTranslator<ServerTeamPacket> {
@Override
public void translate(ServerTeamPacket packet, GeyserSession session) {
}
}

View file

@ -1,3 +1,28 @@
/*
* Copyright (c) 2019 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.connector.network.translators.java.scoreboard; package org.geysermc.connector.network.translators.java.scoreboard;
import com.github.steveice10.mc.protocol.packet.ingame.server.scoreboard.ServerUpdateScorePacket; import com.github.steveice10.mc.protocol.packet.ingame.server.scoreboard.ServerUpdateScorePacket;
@ -5,10 +30,11 @@ import com.nukkitx.protocol.bedrock.packet.SetScorePacket;
import org.geysermc.connector.network.session.GeyserSession; import org.geysermc.connector.network.session.GeyserSession;
import org.geysermc.connector.network.session.cache.ScoreboardCache; import org.geysermc.connector.network.session.cache.ScoreboardCache;
import org.geysermc.connector.network.translators.PacketTranslator; import org.geysermc.connector.network.translators.PacketTranslator;
import org.geysermc.connector.network.translators.scoreboard.Scoreboard; import org.geysermc.connector.scoreboard.Scoreboard;
import org.geysermc.connector.network.translators.scoreboard.ScoreboardObjective; import org.geysermc.connector.scoreboard.ScoreboardObjective;
public class JavaUpdateScoreTranslator extends PacketTranslator<ServerUpdateScorePacket> { public class JavaUpdateScoreTranslator extends PacketTranslator<ServerUpdateScorePacket> {
@Override @Override
public void translate(ServerUpdateScorePacket packet, GeyserSession session) { public void translate(ServerUpdateScorePacket packet, GeyserSession session) {
try { try {

View file

@ -23,7 +23,7 @@
* @link https://github.com/GeyserMC/Geyser * @link https://github.com/GeyserMC/Geyser
*/ */
package org.geysermc.connector.network.translators.scoreboard; package org.geysermc.connector.scoreboard;
import com.nukkitx.protocol.bedrock.packet.SetScorePacket; import com.nukkitx.protocol.bedrock.packet.SetScorePacket;
import lombok.Getter; import lombok.Getter;

View file

@ -23,7 +23,7 @@
* @link https://github.com/GeyserMC/Geyser * @link https://github.com/GeyserMC/Geyser
*/ */
package org.geysermc.connector.network.translators.scoreboard; package org.geysermc.connector.scoreboard;
import com.nukkitx.protocol.bedrock.data.ScoreInfo; import com.nukkitx.protocol.bedrock.data.ScoreInfo;
import com.nukkitx.protocol.bedrock.packet.RemoveObjectivePacket; import com.nukkitx.protocol.bedrock.packet.RemoveObjectivePacket;
@ -97,6 +97,9 @@ public class Scoreboard {
} }
public void onUpdate() { public void onUpdate() {
if (objective == null)
return;
RemoveObjectivePacket removeObjectivePacket = new RemoveObjectivePacket(); RemoveObjectivePacket removeObjectivePacket = new RemoveObjectivePacket();
removeObjectivePacket.setObjectiveId(objective.getObjectiveName()); removeObjectivePacket.setObjectiveId(objective.getObjectiveName());
session.getUpstream().sendPacket(removeObjectivePacket); session.getUpstream().sendPacket(removeObjectivePacket);

View file

@ -23,12 +23,11 @@
* @link https://github.com/GeyserMC/Geyser * @link https://github.com/GeyserMC/Geyser
*/ */
package org.geysermc.connector.network.translators.scoreboard; package org.geysermc.connector.scoreboard;
import com.nukkitx.protocol.bedrock.packet.SetScorePacket; import com.nukkitx.protocol.bedrock.packet.SetScorePacket;
import lombok.Getter; import lombok.Getter;
import lombok.Setter; import lombok.Setter;
import org.geysermc.connector.console.GeyserLogger;
import java.util.HashMap; import java.util.HashMap;
import java.util.Map; import java.util.Map;