/*
 * This file is part of Sponge, licensed under the MIT License (MIT).
 *
 * Copyright (c) SpongePowered <https://www.spongepowered.org>
 * Copyright (c) contributors
 *
 * Permission is hereby granted, free of charge, to any person obtaining a copy
 * of this software and associated documentation files (the "Software"), to deal
 * in the Software without restriction, including without limitation the rights
 * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
 * copies of the Software, and to permit persons to whom the Software is
 * furnished to do so, subject to the following conditions:
 *
 * The above copyright notice and this permission notice shall be included in
 * all copies or substantial portions of the Software.
 *
 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
 * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
 * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
 * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
 * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
 * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
 * THE SOFTWARE.
 */
package org.spongepowered.mod.command;

import net.minecraft.command.ICommand;
import net.minecraft.command.ICommandSender;
import net.minecraftforge.common.MinecraftForge;
import net.minecraftforge.event.CommandEvent;
import org.spongepowered.api.plugin.PluginContainer;
import org.spongepowered.api.command.InvocationCommandException;
import org.spongepowered.api.text.Text;
import org.spongepowered.common.command.MinecraftCommandWrapper;

/**
 * Command wrapper throwing forge events.
 */
public class ForgeMinecraftCommandWrapper extends MinecraftCommandWrapper {

    public ForgeMinecraftCommandWrapper(PluginContainer owner, ICommand command) {
        super(owner, command);
    }

    @Override
    protected boolean throwEvent(ICommandSender sender, String[] args) throws InvocationCommandException {
        CommandEvent event = new CommandEvent(this.command, sender, args);
        if (MinecraftForge.EVENT_BUS.post(event)) {
            if (event.getException() != null) {
                throw new InvocationCommandException(Text.of("Error while firing Forge event"), event.getException());
            }
            return false;
        }
        return super.throwEvent(sender, args);
    }
}

@@ -1618,16 +1618,60 @@
 t.Text;%0A
+import org.spongepowered.common.SpongeImpl;%0A
 import o
@@ -2493,11 +2493,285 @@
 );%0A    %7D
+%0A%0A    @Override%0A    public boolean suppressDuplicateAlias(String alias) %7B%0A        SpongeImpl.getLogger().warn(%22The mod %7B%7D has registered multiple commands for the alias '%7B%7D'. This is probably indicative of a bug.%22, this.getOwner().getId(), alias);%0A        return true;%0A    %7D
 %0A%7D%0A

Allow mods to register duplicate command aliases