Search in sources :

Example 1 with MessageConfig

use of net.blay09.mods.waystones.network.message.MessageConfig in project Waystones by blay09.

the class CommonProxy method onPlayerLoggedIn.

@SubscribeEvent
public void onPlayerLoggedIn(PlayerEvent.PlayerLoggedInEvent event) {
    GlobalWaystones globalWaystones = GlobalWaystones.get(event.player.world);
    PlayerWaystoneData waystoneData = PlayerWaystoneData.fromPlayer(event.player);
    List<WaystoneEntry> validWaystones = Lists.newArrayList();
    for (WaystoneEntry waystone : waystoneData.getWaystones()) {
        if (waystone.isGlobal()) {
            if (globalWaystones.getGlobalWaystone(waystone.getName()) == null) {
                continue;
            }
        }
        validWaystones.add(waystone);
    }
    for (WaystoneEntry waystone : globalWaystones.getGlobalWaystones()) {
        if (!validWaystones.contains(waystone)) {
            validWaystones.add(waystone);
        }
    }
    PlayerWaystoneHelper.store(event.player, validWaystones.toArray(new WaystoneEntry[validWaystones.size()]), waystoneData.getLastFreeWarp(), waystoneData.getLastWarpStoneUse());
    NetworkHandler.channel.sendTo(new MessageConfig(), (EntityPlayerMP) event.player);
    WaystoneManager.sendPlayerWaystones(event.player);
}
Also used : MessageConfig(net.blay09.mods.waystones.network.message.MessageConfig) WaystoneEntry(net.blay09.mods.waystones.util.WaystoneEntry) SubscribeEvent(net.minecraftforge.fml.common.eventhandler.SubscribeEvent)

Aggregations

MessageConfig (net.blay09.mods.waystones.network.message.MessageConfig)1 WaystoneEntry (net.blay09.mods.waystones.util.WaystoneEntry)1 SubscribeEvent (net.minecraftforge.fml.common.eventhandler.SubscribeEvent)1