updated cotton client commands

This commit is contained in:
creeper123123321 2019-04-30 14:48:22 -03:00
parent 6676a9f3d9
commit 52f102d4ec
No known key found for this signature in database
GPG Key ID: 0AC57D54786721D1
4 changed files with 51 additions and 26 deletions

View File

@ -61,8 +61,8 @@ dependencies {
modCompile("net.fabricmc:fabric:0.2.7+build.127")
modCompile("io.github.cottonmc:client-commands:0.2.1+1.14-pre5-SNAPSHOT")
include("io.github.cottonmc:client-commands:0.2.1+1.14-pre5-SNAPSHOT")
modCompile("io.github.cottonmc:cotton-client-commands:0.3.0+1.14-SNAPSHOT")
include("io.github.cottonmc:cotton-client-commands:0.3.0+1.14-SNAPSHOT")
}
minecraft {

View File

@ -25,7 +25,10 @@
package com.github.creeper123123321.viafabric;
import com.github.creeper123123321.viafabric.commands.VRCommandHandler;
import com.github.creeper123123321.viafabric.platform.*;
import com.github.creeper123123321.viafabric.platform.VRInjector;
import com.github.creeper123123321.viafabric.platform.VRLoader;
import com.github.creeper123123321.viafabric.platform.VRPlatform;
import com.github.creeper123123321.viafabric.platform.VRRewindPlatform;
import com.github.creeper123123321.viafabric.protocol.protocol1_7_6_10to1_7_1_5.Protocol1_7_6_10To1_7_1_5;
import com.github.creeper123123321.viafabric.protocol.protocol1_8to1_7_6_10.Protocol1_8To1_7_6_10;
import com.github.creeper123123321.viafabric.util.JLoggerToLog4j;
@ -71,7 +74,7 @@ public class ViaFabric implements ModInitializer {
.get().getMetadata().getVersion().getFriendlyString();
}
private static <S extends CommandSource> LiteralArgumentBuilder<S> command(String commandName) {
public static <S extends CommandSource> LiteralArgumentBuilder<S> command(String commandName) {
return LiteralArgumentBuilder.<S>literal(commandName)
.then(
RequiredArgumentBuilder
@ -95,26 +98,8 @@ public class ViaFabric implements ModInitializer {
new VRRewindPlatform().init();
// new VRBackwardsPlatform().init(); todo reenable when viabackwards is updated
if (FabricLoader.getInstance().getEnvironmentType() == EnvType.CLIENT) {
try {
Class.forName("io.github.cottonmc.clientcommands.ClientCommands")
.getMethod("registerCommand", Consumer.class)
.invoke(null,
(Consumer<CommandDispatcher<CommandSource>>) c ->
c.register(command("viafabricclient"))
);
} catch (ClassNotFoundException | NoSuchMethodException | IllegalAccessException | InvocationTargetException e) {
Via.getPlatform().getLogger().warning("ClientCommands isn't installed");
}
}
try {
Class.forName("net.fabricmc.fabric.api.registry.CommandRegistry");
CommandRegistry.INSTANCE.register(false, c -> c.register(command("viaversion")));
CommandRegistry.INSTANCE.register(false, c -> c.register(command("viaver")));
CommandRegistry.INSTANCE.register(false, c -> c.register(command("vvfabric")));
} catch (ClassNotFoundException e) {
Via.getPlatform().getLogger().warning("Fabric API isn't installed");
}
CommandRegistry.INSTANCE.register(false, c -> c.register(command("viaversion")));
CommandRegistry.INSTANCE.register(false, c -> c.register(command("viaver")));
CommandRegistry.INSTANCE.register(false, c -> c.register(command("vvfabric")));
}
}

View File

@ -0,0 +1,37 @@
/*
* MIT License
*
* Copyright (c) 2018 creeper123123321 and 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 com.github.creeper123123321.viafabric.commands;
import com.github.creeper123123321.viafabric.ViaFabric;
import com.mojang.brigadier.CommandDispatcher;
import io.github.cottonmc.clientcommands.ClientCommandPlugin;
import net.minecraft.server.command.CommandSource;
public class VRClientCommands implements ClientCommandPlugin {
@Override
public void registerCommands(CommandDispatcher<CommandSource> commandDispatcher) {
commandDispatcher.register(ViaFabric.command("viafabricclient"));
}
}

View File

@ -18,6 +18,9 @@
"entrypoints": {
"main": [
"com.github.creeper123123321.viafabric.ViaFabric"
],
"cotton-client-commands": [
"com.github.creeper123123321.viafabric.commands.VRClientCommands"
]
},
"requires": {
@ -25,7 +28,7 @@
"fabric": "*"
},
"recommended": {
"clientcommands": "*"
"cotton-client-commands": "*"
},
"mixins": [
"mixins.viafabric.json"