Search in sources :

Example 1 with BlacklistData

use of de.budschie.bmorph.capabilities.blacklist.BlacklistData in project BudschieMorphMod by Budschie.

the class BlacklistCommand method listBlacklist.

private static int listBlacklist(CommandContext<CommandSource> ctx) {
    BlacklistData blacklist = ConfigManager.INSTANCE.get(BlacklistData.class);
    String conc = String.join(", ", blacklist.getBlacklist().stream().map(rs -> rs.toString()).toArray(size -> new String[size]));
    StringBuilder builder = new StringBuilder();
    builder.append(TextFormatting.GREEN);
    boolean isSingular = blacklist.getBlacklist().size() == 1;
    builder.append("There ").append(isSingular ? "is" : "are").append(" currently ").append(blacklist.getBlacklist().size()).append(isSingular ? " entry" : " entries").append(" in the blacklist: ").append(conc);
    ctx.getSource().sendFeedback(new StringTextComponent(builder.toString()), false);
    return 0;
}
Also used : CommandSource(net.minecraft.command.CommandSource) ResourceLocationArgument(net.minecraft.command.arguments.ResourceLocationArgument) CommandDispatcher(com.mojang.brigadier.CommandDispatcher) BlacklistData(de.budschie.bmorph.capabilities.blacklist.BlacklistData) CommandContext(com.mojang.brigadier.context.CommandContext) EntitySummonArgument(net.minecraft.command.arguments.EntitySummonArgument) SuggestionProviders(net.minecraft.command.arguments.SuggestionProviders) TextFormatting(net.minecraft.util.text.TextFormatting) ResourceLocation(net.minecraft.util.ResourceLocation) StringTextComponent(net.minecraft.util.text.StringTextComponent) ConfigManager(de.budschie.bmorph.capabilities.blacklist.ConfigManager) Commands(net.minecraft.command.Commands) BlacklistData(de.budschie.bmorph.capabilities.blacklist.BlacklistData) StringTextComponent(net.minecraft.util.text.StringTextComponent)

Example 2 with BlacklistData

use of de.budschie.bmorph.capabilities.blacklist.BlacklistData in project BudschieMorphMod by Budschie.

the class BMorphMod method onCommonSetup.

@SubscribeEvent
public static void onCommonSetup(final FMLCommonSetupEvent event) {
    ShrinkAPIInteractor.init();
    MorphCapabilityAttacher.register();
    PufferfishCapabilityAttacher.register();
    GuardianBeamCapabilityAttacher.register();
    ConfigManager.INSTANCE.register(BlacklistData.class, BlacklistData::new);
    System.out.println("Registered capabilities.");
    KEEP_MORPH_INVENTORY = GameRules.register("keepMorphInventory", Category.PLAYER, BooleanValue.create(true));
    PREVENT_LOOKAT = GameRules.register("preventLookat", Category.PLAYER, BooleanValue.create(false));
    DO_MORPH_DROPS = GameRules.register("doMorphDrops", Category.DROPS, BooleanValue.create(true));
    MORPH_AGGRO_DURATION = GameRules.register("morphAggroDuration", Category.PLAYER, IntegerValue.create(200));
    MainNetworkChannel.registerMainNetworkChannels();
    MorphHandler.addMorphItem("player_morph_item", () -> new PlayerMorphItem());
    MorphHandler.addMorphItem("fallback_morph_item", () -> new FallbackMorphItem());
    MorphManagerHandlers.registerDefaultManagers();
    // VanillaFallbackMorphData.intialiseFallbackData();
    // APIInteractor.executeLoadClassIf(() -> ModList.get().isLoaded("betteranimalsplus"), "de.budschie.bmorph.morph.BetterAnimalsPlusFallbackMorphData");
    EntitySynchronizerRegistry.addEntitySynchronizer(new LivingEntitySynchronzier());
    EntitySynchronizerRegistry.addEntitySynchronizer(new ParrotSynchronizer());
    EntitySynchronizerRegistry.addEntitySynchronizer(new SquidSynchronizer());
    EntitySynchronizerRegistry.addEntitySynchronizer(new AbstractPlayerSynchronizer());
    EntitySynchronizerRegistry.addEntitySynchronizer(new PufferfishSynchronizer());
    DYNAMIC_ABILITY_REGISTRY = new DynamicAbilityRegistry();
}
Also used : ParrotSynchronizer(de.budschie.bmorph.render_handler.ParrotSynchronizer) SquidSynchronizer(de.budschie.bmorph.render_handler.SquidSynchronizer) PufferfishSynchronizer(de.budschie.bmorph.render_handler.PufferfishSynchronizer) DynamicAbilityRegistry(de.budschie.bmorph.morph.functionality.DynamicAbilityRegistry) FallbackMorphItem(de.budschie.bmorph.morph.fallback.FallbackMorphItem) BlacklistData(de.budschie.bmorph.capabilities.blacklist.BlacklistData) AbstractPlayerSynchronizer(de.budschie.bmorph.render_handler.AbstractPlayerSynchronizer) PlayerMorphItem(de.budschie.bmorph.morph.player.PlayerMorphItem) LivingEntitySynchronzier(de.budschie.bmorph.render_handler.LivingEntitySynchronzier) SubscribeEvent(net.minecraftforge.eventbus.api.SubscribeEvent)

Example 3 with BlacklistData

use of de.budschie.bmorph.capabilities.blacklist.BlacklistData in project BudschieMorphMod by Budschie.

the class BlacklistCommand method removeBlacklist.

private static int removeBlacklist(CommandContext<CommandSource> ctx) {
    ResourceLocation arg = ctx.getArgument("entity", ResourceLocation.class);
    BlacklistData blacklist = ConfigManager.INSTANCE.get(BlacklistData.class);
    if (blacklist.isInBlacklist(arg)) {
        blacklist.removeBlacklist(arg);
        ctx.getSource().sendFeedback(new StringTextComponent(TextFormatting.GREEN + "Successfully removed " + arg.toString() + " from the entity blacklist."), false);
        blacklist.writeToFile();
    } else {
        ctx.getSource().sendErrorMessage(new StringTextComponent("Failed to remove entry " + arg.toString() + " from the entity blacklist because that entry doesn't exist yet."));
    }
    return 0;
}
Also used : ResourceLocation(net.minecraft.util.ResourceLocation) BlacklistData(de.budschie.bmorph.capabilities.blacklist.BlacklistData) StringTextComponent(net.minecraft.util.text.StringTextComponent)

Example 4 with BlacklistData

use of de.budschie.bmorph.capabilities.blacklist.BlacklistData in project BudschieMorphMod by Budschie.

the class BlacklistCommand method addBlacklist.

private static int addBlacklist(CommandContext<CommandSource> ctx) {
    BlacklistData blacklist = ConfigManager.INSTANCE.get(BlacklistData.class);
    ResourceLocation arg = ctx.getArgument("entity", ResourceLocation.class);
    if (blacklist.isInBlacklist(arg)) {
        ctx.getSource().sendErrorMessage(new StringTextComponent("Failed to add entry " + arg.toString() + " to the entity blacklist because that entry already exists."));
    } else {
        blacklist.addBlacklist(arg);
        ctx.getSource().sendFeedback(new StringTextComponent(TextFormatting.GREEN + "Successfully added " + arg.toString() + " to the blacklist!"), true);
        blacklist.writeToFile();
    }
    return 0;
}
Also used : ResourceLocation(net.minecraft.util.ResourceLocation) BlacklistData(de.budschie.bmorph.capabilities.blacklist.BlacklistData) StringTextComponent(net.minecraft.util.text.StringTextComponent)

Aggregations

BlacklistData (de.budschie.bmorph.capabilities.blacklist.BlacklistData)4 ResourceLocation (net.minecraft.util.ResourceLocation)3 StringTextComponent (net.minecraft.util.text.StringTextComponent)3 CommandDispatcher (com.mojang.brigadier.CommandDispatcher)1 CommandContext (com.mojang.brigadier.context.CommandContext)1 ConfigManager (de.budschie.bmorph.capabilities.blacklist.ConfigManager)1 FallbackMorphItem (de.budschie.bmorph.morph.fallback.FallbackMorphItem)1 DynamicAbilityRegistry (de.budschie.bmorph.morph.functionality.DynamicAbilityRegistry)1 PlayerMorphItem (de.budschie.bmorph.morph.player.PlayerMorphItem)1 AbstractPlayerSynchronizer (de.budschie.bmorph.render_handler.AbstractPlayerSynchronizer)1 LivingEntitySynchronzier (de.budschie.bmorph.render_handler.LivingEntitySynchronzier)1 ParrotSynchronizer (de.budschie.bmorph.render_handler.ParrotSynchronizer)1 PufferfishSynchronizer (de.budschie.bmorph.render_handler.PufferfishSynchronizer)1 SquidSynchronizer (de.budschie.bmorph.render_handler.SquidSynchronizer)1 CommandSource (net.minecraft.command.CommandSource)1 Commands (net.minecraft.command.Commands)1 EntitySummonArgument (net.minecraft.command.arguments.EntitySummonArgument)1 ResourceLocationArgument (net.minecraft.command.arguments.ResourceLocationArgument)1 SuggestionProviders (net.minecraft.command.arguments.SuggestionProviders)1 TextFormatting (net.minecraft.util.text.TextFormatting)1