Search in sources :

Example 1 with PlayerConfiguration

use of network.rs485.logisticspipes.config.PlayerConfiguration in project LogisticsPipes by RS485.

the class LogisticsEventListener method onItemCrafting.

@SubscribeEvent
public void onItemCrafting(PlayerEvent.ItemCraftedEvent event) {
    if (event.player.isServerWorld() && !event.crafting.isEmpty()) {
        if (event.crafting.getItem().getRegistryName().getResourceDomain().equals(LPConstants.LP_MOD_ID)) {
            PlayerIdentifier identifier = PlayerIdentifier.get(event.player);
            PlayerConfiguration config = LogisticsPipes.getServerConfigManager().getPlayerConfiguration(identifier);
            if (!config.getHasCraftedLPItem() && !LogisticsPipes.isDEBUG()) {
                ItemStack book = new ItemStack(LPItems.itemGuideBook, 1);
                event.player.addItemStackToInventory(book);
                config.setHasCraftedLPItem(true);
                LogisticsPipes.getServerConfigManager().setPlayerConfiguration(identifier, config);
            }
        }
    }
}
Also used : PlayerConfiguration(network.rs485.logisticspipes.config.PlayerConfiguration) PlayerIdentifier(logisticspipes.utils.PlayerIdentifier) ItemStack(net.minecraft.item.ItemStack) SubscribeEvent(net.minecraftforge.fml.common.eventhandler.SubscribeEvent)

Aggregations

PlayerIdentifier (logisticspipes.utils.PlayerIdentifier)1 ItemStack (net.minecraft.item.ItemStack)1 SubscribeEvent (net.minecraftforge.fml.common.eventhandler.SubscribeEvent)1 PlayerConfiguration (network.rs485.logisticspipes.config.PlayerConfiguration)1