use of com.mraof.minestuck.inventory.captchalouge.Modus in project Minestuck by mraof.
the class MinestuckPlayerTracker method onPlayerRespawn.
@SubscribeEvent
public void onPlayerRespawn(PlayerEvent.PlayerRespawnEvent event) {
MinestuckPlayerData.getData(event.player).echeladder.updateEcheladderBonuses(event.player);
Modus modus = MinestuckPlayerData.getData(event.player).modus;
if (modus != null)
modus.player = event.player;
}
use of com.mraof.minestuck.inventory.captchalouge.Modus in project Minestuck by mraof.
the class MinestuckPlayerTracker method onPlayerLogout.
// Editmode players need to be reset before nei handles the event
@SubscribeEvent(priority = EventPriority.HIGH)
public void onPlayerLogout(PlayerEvent.PlayerLoggedOutEvent event) {
ServerEditHandler.onPlayerExit(event.player);
Modus modus = CaptchaDeckHandler.getModus(event.player);
if (modus != null)
modus.player = null;
dataCheckerPermission.remove(event.player.getName());
}
use of com.mraof.minestuck.inventory.captchalouge.Modus 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));
}
use of com.mraof.minestuck.inventory.captchalouge.Modus in project Minestuck by mraof.
the class GuiCaptchaDeck method actionPerformed.
@Override
protected void actionPerformed(GuiButton button) {
if (button == this.modusButton && !container.inventory.getStackInSlot(0).isEmpty()) {
ItemStack stack = container.inventory.getStackInSlot(0);
if (!(stack.getItem() instanceof ItemCaptchaCard)) {
Modus newModus = CaptchaDeckHandler.createInstance(CaptchaDeckHandler.getType(stack), Side.CLIENT);
if (newModus != null && CaptchaDeckHandler.clientSideModus != null && newModus.getClass() != CaptchaDeckHandler.clientSideModus.getClass() && !newModus.canSwitchFrom(CaptchaDeckHandler.clientSideModus)) {
mc.currentScreen = new GuiYesNo(this, I18n.format("gui.emptySylladex1"), I18n.format("gui.emptySylladex2"), 0) {
@Override
public void onGuiClosed() {
mc.currentScreen = (GuiScreen) parentScreen;
mc.player.closeScreen();
}
};
mc.currentScreen.setWorldAndResolution(mc, width, height);
return;
}
}
MinestuckChannelHandler.sendToServer(MinestuckPacket.makePacket(Type.CAPTCHA, CaptchaDeckPacket.MODUS));
} else if (button == this.sylladexMap && CaptchaDeckHandler.clientSideModus != null) {
mc.player.connection.sendPacket(new CPacketCloseWindow(mc.player.openContainer.windowId));
mc.player.inventory.setItemStack(ItemStack.EMPTY);
mc.displayGuiScreen(CaptchaDeckHandler.clientSideModus.getGuiHandler());
mc.player.openContainer = mc.player.inventoryContainer;
}
}
Aggregations