use of org.dragonet.protocol.packets.LevelEventPacket in project DragonProxy by DragonetMC.
the class PCNotifyClientPacketTranslator method translate.
public PEPacket[] translate(UpstreamSession session, ServerNotifyClientPacket packet) {
switch(packet.getNotification()) {
case CHANGE_GAMEMODE:
GameMode gm = (GameMode) packet.getValue();
SetPlayerGameTypePacket pkgm = new SetPlayerGameTypePacket();
pkgm.gamemode = gm == GameMode.CREATIVE ? 1 : 0;
AdventureSettingsPacket adv = new AdventureSettingsPacket();
adv.setFlag(AdventureSettingsPacket.WORLD_IMMUTABLE, gm.equals(GameMode.ADVENTURE));
adv.setFlag(AdventureSettingsPacket.ALLOW_FLIGHT, gm.equals(GameMode.CREATIVE) || gm.equals(GameMode.SPECTATOR));
adv.setFlag(AdventureSettingsPacket.NO_CLIP, gm.equals(GameMode.SPECTATOR));
adv.setFlag(AdventureSettingsPacket.WORLD_BUILDER, !gm.equals(GameMode.SPECTATOR) || !gm.equals(GameMode.ADVENTURE));
adv.setFlag(AdventureSettingsPacket.FLYING, gm.equals(GameMode.SPECTATOR));
adv.setFlag(AdventureSettingsPacket.MUTED, false);
adv.eid = session.getEntityCache().getClientEntity().proxyEid;
adv.commandsPermission = AdventureSettingsPacket.PERMISSION_NORMAL;
adv.playerPermission = AdventureSettingsPacket.LEVEL_PERMISSION_MEMBER;
session.sendPacket(pkgm);
session.sendPacket(adv);
if (gm == GameMode.CREATIVE)
session.sendCreativeInventory();
break;
case START_RAIN:
LevelEventPacket evtStartRain = new LevelEventPacket();
evtStartRain.eventId = LevelEventPacket.EVENT_START_RAIN;
return new PEPacket[] { evtStartRain };
case STOP_RAIN:
LevelEventPacket evtStopRain = new LevelEventPacket();
evtStopRain.eventId = LevelEventPacket.EVENT_STOP_RAIN;
return new PEPacket[] { evtStopRain };
}
return null;
}
Aggregations