Search in sources :

Example 6 with ColonyEventTypeRegistryEntry

use of com.minecolonies.api.colony.colonyEvents.registry.ColonyEventTypeRegistryEntry in project minecolonies by Minecolonies.

the class CommandRaidAll method build.

@Override
public LiteralArgumentBuilder<CommandSource> build() {
    final List<String> raidTypes = new ArrayList<>();
    for (final ColonyEventTypeRegistryEntry type : IMinecoloniesAPI.getInstance().getColonyEventRegistry().getValues()) {
        if (!type.getRegistryName().getPath().equals(PirateGroundRaidEvent.PIRATE_GROUND_RAID_EVENT_TYPE_ID.getPath()) && !type.getRegistryName().getPath().equals(NorsemenShipRaidEvent.NORSEMEN_RAID_EVENT_TYPE_ID.getPath())) {
            raidTypes.add(type.getRegistryName().getPath());
        }
    }
    String[] opt = new String[2];
    opt[0] = RAID_NOW;
    opt[1] = RAID_TONIGHT;
    return IMCCommand.newLiteral(getName()).then(IMCCommand.newArgument(RAID_TIME_ARG, StringArgumentType.string()).suggests((ctx, builder) -> ISuggestionProvider.suggest(opt, builder)).then(IMCCommand.newArgument(RAID_TYPE_ARG, StringArgumentType.string()).suggests((ctx, builder) -> ISuggestionProvider.suggest(raidTypes, builder)).executes(this::onSpecificExecute)).executes(this::checkPreConditionAndExecute));
}
Also used : IMCCommand(com.minecolonies.coremod.commands.commandTypes.IMCCommand) CommandArgumentNames(com.minecolonies.coremod.commands.CommandArgumentNames) PirateGroundRaidEvent(com.minecolonies.coremod.colony.colonyEvents.raidEvents.pirateEvent.PirateGroundRaidEvent) CommandContext(com.mojang.brigadier.context.CommandContext) ISuggestionProvider(net.minecraft.command.ISuggestionProvider) IColonyManager(com.minecolonies.api.colony.IColonyManager) LiteralArgumentBuilder(com.mojang.brigadier.builder.LiteralArgumentBuilder) TranslationTextComponent(net.minecraft.util.text.TranslationTextComponent) ArrayList(java.util.ArrayList) CommandSource(net.minecraft.command.CommandSource) StringArgumentType(com.mojang.brigadier.arguments.StringArgumentType) List(java.util.List) IMinecoloniesAPI(com.minecolonies.api.IMinecoloniesAPI) COMMAND_RAID_TONIGHT_WARNING(com.minecolonies.api.util.constant.translation.CommandTranslationConstants.COMMAND_RAID_TONIGHT_WARNING) IColony(com.minecolonies.api.colony.IColony) ColonyEventTypeRegistryEntry(com.minecolonies.api.colony.colonyEvents.registry.ColonyEventTypeRegistryEntry) IMCOPCommand(com.minecolonies.coremod.commands.commandTypes.IMCOPCommand) NorsemenShipRaidEvent(com.minecolonies.coremod.colony.colonyEvents.raidEvents.norsemenevent.NorsemenShipRaidEvent) ArrayList(java.util.ArrayList) ColonyEventTypeRegistryEntry(com.minecolonies.api.colony.colonyEvents.registry.ColonyEventTypeRegistryEntry)

Example 7 with ColonyEventTypeRegistryEntry

use of com.minecolonies.api.colony.colonyEvents.registry.ColonyEventTypeRegistryEntry in project minecolonies by Minecolonies.

the class EventManager method readFromNBT.

@Override
public void readFromNBT(@NotNull final CompoundNBT compound) {
    if (compound.contains(TAG_EVENT_MANAGER)) {
        final CompoundNBT eventManagerNBT = compound.getCompound(TAG_EVENT_MANAGER);
        final ListNBT eventListNBT = eventManagerNBT.getList(TAG_EVENT_LIST, Constants.NBT.TAG_COMPOUND);
        for (final INBT base : eventListNBT) {
            final CompoundNBT tagCompound = (CompoundNBT) base;
            final ResourceLocation eventTypeID = new ResourceLocation(MOD_ID, tagCompound.getString(TAG_NAME));
            final ColonyEventTypeRegistryEntry registryEntry = MinecoloniesAPIProxy.getInstance().getColonyEventRegistry().getValue(eventTypeID);
            if (registryEntry == null) {
                Log.getLogger().warn("Event is missing registryEntry!:" + eventTypeID.getPath());
                continue;
            }
            final IColonyEvent colonyEvent = registryEntry.deserializeEvent(colony, tagCompound);
            events.put(colonyEvent.getID(), colonyEvent);
        }
        currentEventID = eventManagerNBT.getInt(TAG_EVENT_ID);
        structureManager.readFromNBT(compound);
    }
}
Also used : IColonyEvent(com.minecolonies.api.colony.colonyEvents.IColonyEvent) ListNBT(net.minecraft.nbt.ListNBT) CompoundNBT(net.minecraft.nbt.CompoundNBT) INBT(net.minecraft.nbt.INBT) ResourceLocation(net.minecraft.util.ResourceLocation) ColonyEventTypeRegistryEntry(com.minecolonies.api.colony.colonyEvents.registry.ColonyEventTypeRegistryEntry)

Example 8 with ColonyEventTypeRegistryEntry

use of com.minecolonies.api.colony.colonyEvents.registry.ColonyEventTypeRegistryEntry in project minecolonies by Minecolonies.

the class ModColonyEventTypeInitializer method init.

public static void init(final RegistryEvent.Register<ColonyEventTypeRegistryEntry> event) {
    final IForgeRegistry<ColonyEventTypeRegistryEntry> reg = event.getRegistry();
    reg.register(new ColonyEventTypeRegistryEntry(PirateRaidEvent::loadFromNBT, PirateRaidEvent.PIRATE_RAID_EVENT_TYPE_ID));
    reg.register(new ColonyEventTypeRegistryEntry(BarbarianRaidEvent::loadFromNBT, BarbarianRaidEvent.BARBARIAN_RAID_EVENT_TYPE_ID));
    reg.register(new ColonyEventTypeRegistryEntry(EgyptianRaidEvent::loadFromNBT, EgyptianRaidEvent.EGYPTIAN_RAID_EVENT_TYPE_ID));
    reg.register(new ColonyEventTypeRegistryEntry(AmazonRaidEvent::loadFromNBT, AmazonRaidEvent.AMAZON_RAID_EVENT_TYPE_ID));
    reg.register(new ColonyEventTypeRegistryEntry(NorsemenRaidEvent::loadFromNBT, NorsemenRaidEvent.NORSEMEN_RAID_EVENT_TYPE_ID));
    reg.register(new ColonyEventTypeRegistryEntry(NorsemenShipRaidEvent::loadFromNBT, NorsemenShipRaidEvent.NORSEMEN_RAID_EVENT_TYPE_ID));
    reg.register(new ColonyEventTypeRegistryEntry(PirateGroundRaidEvent::loadFromNBT, PirateGroundRaidEvent.PIRATE_GROUND_RAID_EVENT_TYPE_ID));
}
Also used : ColonyEventTypeRegistryEntry(com.minecolonies.api.colony.colonyEvents.registry.ColonyEventTypeRegistryEntry)

Example 9 with ColonyEventTypeRegistryEntry

use of com.minecolonies.api.colony.colonyEvents.registry.ColonyEventTypeRegistryEntry in project minecolonies by Minecolonies.

the class CommandRaid method build.

@Override
public LiteralArgumentBuilder<CommandSource> build() {
    final List<String> raidTypes = new ArrayList<>();
    for (final ColonyEventTypeRegistryEntry type : IMinecoloniesAPI.getInstance().getColonyEventRegistry().getValues()) {
        if (!type.getRegistryName().getPath().equals(PirateGroundRaidEvent.PIRATE_GROUND_RAID_EVENT_TYPE_ID.getPath()) && !type.getRegistryName().getPath().equals(NorsemenShipRaidEvent.NORSEMEN_RAID_EVENT_TYPE_ID.getPath())) {
            raidTypes.add(type.getRegistryName().getPath());
        }
    }
    String[] opt = new String[2];
    opt[0] = RAID_NOW;
    opt[1] = RAID_TONIGHT;
    return IMCCommand.newLiteral(getName()).then(IMCCommand.newArgument(RAID_TIME_ARG, StringArgumentType.string()).suggests((ctx, builder) -> ISuggestionProvider.suggest(opt, builder)).then(IMCCommand.newArgument(COLONYID_ARG, IntegerArgumentType.integer(1)).then(IMCCommand.newArgument(RAID_TYPE_ARG, StringArgumentType.string()).suggests((ctx, builder) -> ISuggestionProvider.suggest(raidTypes, builder)).executes(this::onSpecificExecute)).executes(this::checkPreConditionAndExecute)));
}
Also used : IMCCommand(com.minecolonies.coremod.commands.commandTypes.IMCCommand) CommandArgumentNames(com.minecolonies.coremod.commands.CommandArgumentNames) PirateGroundRaidEvent(com.minecolonies.coremod.colony.colonyEvents.raidEvents.pirateEvent.PirateGroundRaidEvent) CommandContext(com.mojang.brigadier.context.CommandContext) ISuggestionProvider(net.minecraft.command.ISuggestionProvider) IColonyManager(com.minecolonies.api.colony.IColonyManager) LiteralArgumentBuilder(com.mojang.brigadier.builder.LiteralArgumentBuilder) TranslationTextComponent(net.minecraft.util.text.TranslationTextComponent) ArrayList(java.util.ArrayList) CommandSource(net.minecraft.command.CommandSource) StringArgumentType(com.mojang.brigadier.arguments.StringArgumentType) List(java.util.List) IMinecoloniesAPI(com.minecolonies.api.IMinecoloniesAPI) IColony(com.minecolonies.api.colony.IColony) ColonyEventTypeRegistryEntry(com.minecolonies.api.colony.colonyEvents.registry.ColonyEventTypeRegistryEntry) IMCOPCommand(com.minecolonies.coremod.commands.commandTypes.IMCOPCommand) CommandTranslationConstants(com.minecolonies.api.util.constant.translation.CommandTranslationConstants) IntegerArgumentType(com.mojang.brigadier.arguments.IntegerArgumentType) NorsemenShipRaidEvent(com.minecolonies.coremod.colony.colonyEvents.raidEvents.norsemenevent.NorsemenShipRaidEvent) ArrayList(java.util.ArrayList) ColonyEventTypeRegistryEntry(com.minecolonies.api.colony.colonyEvents.registry.ColonyEventTypeRegistryEntry)

Example 10 with ColonyEventTypeRegistryEntry

use of com.minecolonies.api.colony.colonyEvents.registry.ColonyEventTypeRegistryEntry in project minecolonies by ldtteam.

the class CommandRaid method build.

@Override
public LiteralArgumentBuilder<CommandSource> build() {
    final List<String> raidTypes = new ArrayList<>();
    for (final ColonyEventTypeRegistryEntry type : IMinecoloniesAPI.getInstance().getColonyEventRegistry().getValues()) {
        if (!type.getRegistryName().getPath().equals(PirateGroundRaidEvent.PIRATE_GROUND_RAID_EVENT_TYPE_ID.getPath()) && !type.getRegistryName().getPath().equals(NorsemenShipRaidEvent.NORSEMEN_RAID_EVENT_TYPE_ID.getPath())) {
            raidTypes.add(type.getRegistryName().getPath());
        }
    }
    String[] opt = new String[2];
    opt[0] = RAID_NOW;
    opt[1] = RAID_TONIGHT;
    return IMCCommand.newLiteral(getName()).then(IMCCommand.newArgument(RAID_TIME_ARG, StringArgumentType.string()).suggests((ctx, builder) -> ISuggestionProvider.suggest(opt, builder)).then(IMCCommand.newArgument(COLONYID_ARG, IntegerArgumentType.integer(1)).then(IMCCommand.newArgument(RAID_TYPE_ARG, StringArgumentType.string()).suggests((ctx, builder) -> ISuggestionProvider.suggest(raidTypes, builder)).executes(this::onSpecificExecute)).executes(this::checkPreConditionAndExecute)));
}
Also used : IMCCommand(com.minecolonies.coremod.commands.commandTypes.IMCCommand) CommandArgumentNames(com.minecolonies.coremod.commands.CommandArgumentNames) LanguageHandler(com.ldtteam.structurize.util.LanguageHandler) PirateGroundRaidEvent(com.minecolonies.coremod.colony.colonyEvents.raidEvents.pirateEvent.PirateGroundRaidEvent) CommandContext(com.mojang.brigadier.context.CommandContext) ISuggestionProvider(net.minecraft.command.ISuggestionProvider) IColonyManager(com.minecolonies.api.colony.IColonyManager) LiteralArgumentBuilder(com.mojang.brigadier.builder.LiteralArgumentBuilder) ArrayList(java.util.ArrayList) CommandSource(net.minecraft.command.CommandSource) StringArgumentType(com.mojang.brigadier.arguments.StringArgumentType) List(java.util.List) IMinecoloniesAPI(com.minecolonies.api.IMinecoloniesAPI) IColony(com.minecolonies.api.colony.IColony) ColonyEventTypeRegistryEntry(com.minecolonies.api.colony.colonyEvents.registry.ColonyEventTypeRegistryEntry) IMCOPCommand(com.minecolonies.coremod.commands.commandTypes.IMCOPCommand) IntegerArgumentType(com.mojang.brigadier.arguments.IntegerArgumentType) NorsemenShipRaidEvent(com.minecolonies.coremod.colony.colonyEvents.raidEvents.norsemenevent.NorsemenShipRaidEvent) ArrayList(java.util.ArrayList) ColonyEventTypeRegistryEntry(com.minecolonies.api.colony.colonyEvents.registry.ColonyEventTypeRegistryEntry)

Aggregations

ColonyEventTypeRegistryEntry (com.minecolonies.api.colony.colonyEvents.registry.ColonyEventTypeRegistryEntry)10 IMinecoloniesAPI (com.minecolonies.api.IMinecoloniesAPI)4 IColony (com.minecolonies.api.colony.IColony)4 IColonyManager (com.minecolonies.api.colony.IColonyManager)4 NorsemenShipRaidEvent (com.minecolonies.coremod.colony.colonyEvents.raidEvents.norsemenevent.NorsemenShipRaidEvent)4 PirateGroundRaidEvent (com.minecolonies.coremod.colony.colonyEvents.raidEvents.pirateEvent.PirateGroundRaidEvent)4 CommandArgumentNames (com.minecolonies.coremod.commands.CommandArgumentNames)4 IMCCommand (com.minecolonies.coremod.commands.commandTypes.IMCCommand)4 IMCOPCommand (com.minecolonies.coremod.commands.commandTypes.IMCOPCommand)4 StringArgumentType (com.mojang.brigadier.arguments.StringArgumentType)4 LiteralArgumentBuilder (com.mojang.brigadier.builder.LiteralArgumentBuilder)4 CommandContext (com.mojang.brigadier.context.CommandContext)4 ArrayList (java.util.ArrayList)4 List (java.util.List)4 CommandSource (net.minecraft.command.CommandSource)4 ISuggestionProvider (net.minecraft.command.ISuggestionProvider)4 ResourceLocation (net.minecraft.util.ResourceLocation)4 LanguageHandler (com.ldtteam.structurize.util.LanguageHandler)2 BuildingEntry (com.minecolonies.api.colony.buildings.registry.BuildingEntry)2 IColonyEvent (com.minecolonies.api.colony.colonyEvents.IColonyEvent)2