use of com.mraof.minestuck.network.MinestuckPacket in project Minestuck by mraof.
the class MinestuckPlayerTracker method sendConfigPacket.
public static void sendConfigPacket(EntityPlayerMP player, boolean mode) {
MinestuckPacket packet;
if (mode)
packet = MinestuckPacket.makePacket(Type.CONFIG, true);
else {
boolean permission = MinestuckConfig.getDataCheckerPermissionFor(player);
packet = MinestuckPacket.makePacket(Type.CONFIG, false, permission);
if (permission)
dataCheckerPermission.add(player.getName());
else
dataCheckerPermission.remove(player.getName());
}
MinestuckChannelHandler.sendToPlayer(packet, player);
}
use of com.mraof.minestuck.network.MinestuckPacket in project Minestuck by mraof.
the class SburbServer method onButtonPressed.
@Override
public void onButtonPressed(TileEntityComputer te, String buttonName, Object[] data) {
if (buttonName.equals("computer.buttonEdit") || buttonName.equals("computer.buttonGive")) {
MinestuckPacket packet = MinestuckPacket.makePacket(MinestuckPacket.Type.CLIENT_EDIT, te.ownerId, te.getData(getId()).getInteger("connectedClient"));
MinestuckChannelHandler.sendToServer(packet);
} else if (buttonName.equals("computer.buttonResume"))
SkaiaClient.sendConnectRequest(te, SkaiaClient.getAssociatedPartner(te.ownerId, false), false);
else if (buttonName.equals("computer.buttonOpen"))
SkaiaClient.sendConnectRequest(te, -1, false);
else if (buttonName.equals("computer.buttonClose"))
SkaiaClient.sendCloseRequest(te, te.getData(getId()).getBoolean("isOpen") ? -1 : te.getData(getId()).getInteger("connectedClient"), false);
}
use of com.mraof.minestuck.network.MinestuckPacket in project Minestuck by mraof.
the class MinestuckPlayerTracker method updateTitle.
public static void updateTitle(EntityPlayer player) {
PlayerIdentifier identifier = IdentifierHandler.encode(player);
Title newTitle = MinestuckPlayerData.getTitle(identifier);
if (newTitle == null)
return;
MinestuckPacket packet = MinestuckPacket.makePacket(Type.PLAYER_DATA, PlayerDataPacket.TITLE, newTitle.getHeroClass(), newTitle.getHeroAspect());
MinestuckChannelHandler.sendToPlayer(packet, player);
}
use of com.mraof.minestuck.network.MinestuckPacket in project Minestuck by mraof.
the class MinestuckPlayerTracker method updateLands.
public static void updateLands(EntityPlayer player) {
MinestuckPacket packet = MinestuckPacket.makePacket(Type.LANDREGISTER);
Debug.debugf("Sending land packets to %s.", player == null ? "all players" : player.getName());
if (player == null)
MinestuckChannelHandler.sendToAllPlayers(packet);
else
MinestuckChannelHandler.sendToPlayer(packet, player);
}
use of com.mraof.minestuck.network.MinestuckPacket in project Minestuck by mraof.
the class MinestuckPlayerTracker method onPlayerLogin.
@SubscribeEvent
public void onPlayerLogin(PlayerEvent.PlayerLoggedInEvent event) {
EntityPlayer player = event.player;
Debug.debug(player.getName() + " joined the game. Sending packets.");
MinecraftServer server = player.getServer();
if (!server.isDedicatedServer() && IdentifierHandler.host == null)
IdentifierHandler.host = event.player.getName();
IdentifierHandler.playerLoggedIn(player);
PlayerIdentifier identifier = IdentifierHandler.encode(player);
sendConfigPacket((EntityPlayerMP) player, true);
sendConfigPacket((EntityPlayerMP) player, false);
SkaianetHandler.playerConnected(player);
boolean firstTime = false;
if (MinestuckPlayerData.getGristSet(identifier) == null) {
Debug.debugf("Grist set is null for player %s. Handling it as first time in this world.", player.getName());
MinestuckPlayerData.setGrist(identifier, new GristSet(GristType.Build, 20));
firstTime = true;
}
MinestuckPlayerData.getData(identifier).echeladder.updateEcheladderBonuses(player);
if (CaptchaDeckHandler.getModus(player) == null && MinestuckConfig.defaultModusTypes.length > 0 && !MinestuckPlayerData.getData(player).givenModus) {
int index = player.world.rand.nextInt(MinestuckConfig.defaultModusTypes.length);
Modus modus = CaptchaDeckHandler.createInstance(new ResourceLocation(MinestuckConfig.defaultModusTypes[index]), Side.SERVER);
if (modus != null) {
modus.player = player;
modus.initModus(null, MinestuckConfig.initialModusSize);
CaptchaDeckHandler.setModus(player, modus);
} else
Debug.warnf("Couldn't create a modus by the name %s.", MinestuckConfig.defaultModusTypes[index]);
}
if (CaptchaDeckHandler.getModus(player) != null) {
Modus modus = CaptchaDeckHandler.getModus(player);
modus.player = player;
MinestuckChannelHandler.sendToPlayer(MinestuckPacket.makePacket(Type.CAPTCHA, CaptchaDeckPacket.DATA, CaptchaDeckHandler.writeToNBT(modus)), player);
}
updateGristCache(identifier);
updateTitle(player);
updateEcheladder(player, true);
MinestuckChannelHandler.sendToPlayer(MinestuckPacket.makePacket(Type.PLAYER_DATA, PlayerDataPacket.BOONDOLLAR, MinestuckPlayerData.getData(identifier).boondollars), player);
ServerEditHandler.onPlayerLoggedIn((EntityPlayerMP) player);
if (firstTime)
MinestuckChannelHandler.sendToPlayer(MinestuckPacket.makePacket(Type.PLAYER_DATA, PlayerDataPacket.COLOR), player);
else {
MinestuckPacket packet = MinestuckPacket.makePacket(Type.PLAYER_DATA, PlayerDataPacket.COLOR, MinestuckPlayerData.getData(player).color);
MinestuckChannelHandler.sendToPlayer(packet, player);
}
if (UpdateChecker.outOfDate)
player.sendMessage(new TextComponentString("New version of Minestuck: " + UpdateChecker.latestVersion + "\nChanges: " + UpdateChecker.updateChanges));
}
Aggregations