cleanup unused code and mixins

This commit is contained in:
gnembon committed 2020-08-18 01:54:24 -03:00
1 parent 598219608b
commit 3167fe06f3
62 files changed
+56 -916

No files matched your search

@@ -1,73 +0,0 @@
package carpet.commands;
import carpet.CarpetSettings;
import carpet.settings.SettingsManager;
import com.mojang.brigadier.CommandDispatcher;
import com.mojang.brigadier.builder.LiteralArgumentBuilder;
import com.mojang.brigadier.exceptions.CommandSyntaxException;
import net.minecraft.network.packet.s2c.play.EntityVelocityUpdateS2CPacket;
import net.minecraft.network.packet.s2c.play.RemoveEntityStatusEffectS2CPacket;
import net.minecraft.server.command.ServerCommandSource;
import net.minecraft.command.argument.EntityArgumentType;
import net.minecraft.entity.effect.StatusEffects;
import net.minecraft.entity.effect.StatusEffectInstance;
import net.minecraft.server.network.ServerPlayerEntity;
import net.minecraft.world.GameMode;
import static net.minecraft.server.command.CommandManager.argument;
import static net.minecraft.server.command.CommandManager.literal;
public class CameraModeCommand
{/*
public static void register(CommandDispatcher<ServerCommandSource> dispatcher)
{
LiteralArgumentBuilder<ServerCommandSource> camera = literal("c").
requires((player) -> SettingsManager.canUseCommand(player, CarpetSettings.commandCameramode)).
executes((c) -> cameraMode(c.getSource(), c.getSource().getPlayer())).
then(argument("player", EntityArgumentType.player()).
executes( (c) -> cameraMode(c.getSource(), EntityArgumentType.getPlayer(c, "player"))));
LiteralArgumentBuilder<ServerCommandSource> survival = literal("s").
requires((player) -> SettingsManager.canUseCommand(player, CarpetSettings.commandCameramode)).
executes((c) -> survivalMode(
c.getSource(),
c.getSource().getPlayer())).
then(argument("player", EntityArgumentType.player()).
executes( (c) -> survivalMode(c.getSource(), EntityArgumentType.getPlayer(c, "player"))));
dispatcher.register(camera);
dispatcher.register(survival);
}
private static boolean iCanHasPermissions(ServerCommandSource source, ServerPlayerEntity player)
{
try
{
return source.hasPermissionLevel(2) || source.getPlayer() == player;
}
catch (CommandSyntaxException e)
{
return true; // shoudn't happen because server has all permissions anyways
}
}
private static int cameraMode(ServerCommandSource source, ServerPlayerEntity player)
{
if (!(iCanHasPermissions(source, player))) return 0;
player.setGameMode(GameMode.SPECTATOR);
player.addVelocity(0,0.1,0);
player.networkHandler.sendPacket(new EntityVelocityUpdateS2CPacket(player));
player.addStatusEffect(new StatusEffectInstance(StatusEffects.NIGHT_VISION, 999999, 0, false, false));
player.addStatusEffect(new StatusEffectInstance(StatusEffects.CONDUIT_POWER, 999999, 0, false, false));
return 1;
}
private static int survivalMode(ServerCommandSource source, ServerPlayerEntity player)
{
if (!(iCanHasPermissions(source, player))) return 0;
player.setGameMode(GameMode.SURVIVAL);
player.networkHandler.sendPacket(new RemoveEntityStatusEffectS2CPacket(player.getEntityId(), StatusEffects.NIGHT_VISION));
player.removeStatusEffect(StatusEffects.NIGHT_VISION);
player.networkHandler.sendPacket(new RemoveEntityStatusEffectS2CPacket(player.getEntityId(), StatusEffects.CONDUIT_POWER));
player.removeStatusEffect(StatusEffects.CONDUIT_POWER);
return 1;
}
*/
}
@@ -15,7 +15,6 @@ import net.minecraft.command.argument.BlockPosArgumentType;
import net.minecraft.command.argument.EntitySummonArgumentType;
import net.minecraft.nbt.CompoundTag;
import net.minecraft.util.math.BlockPos;
import net.minecraft.util.math.Direction;
import static net.minecraft.server.command.CommandManager.argument;
import static net.minecraft.server.command.CommandManager.literal;
@@ -29,7 +29,6 @@ import net.minecraft.util.math.Vec3d;
import net.minecraft.util.registry.RegistryKey;
import net.minecraft.world.GameMode;
import net.minecraft.world.World;
import net.minecraft.world.dimension.DimensionType;
import java.util.Arrays;
import java.util.Collection;
@@ -1,8 +1,14 @@
package carpet.commands;
import carpet.CarpetServer;
import carpet.script.*;
import carpet.CarpetSettings;
import carpet.script.CarpetEventServer;
import carpet.script.CarpetExpression;
import carpet.script.CarpetScriptHost;
import carpet.script.Expression;
import carpet.script.LazyValue;
import carpet.script.ScriptHost;
import carpet.script.Tokenizer;
import carpet.script.exception.CarpetExpressionException;
import carpet.script.value.FunctionValue;
import carpet.settings.SettingsManager;
@@ -27,7 +33,13 @@ import net.minecraft.server.world.ServerWorld;
import net.minecraft.util.math.BlockBox;
import org.apache.commons.lang3.StringUtils;
import java.util.*;
import java.util.ArrayList;
import java.util.Collection;
import java.util.Collections;
import java.util.List;
import java.util.Locale;
import java.util.Set;
import java.util.TreeSet;
import java.util.concurrent.CompletableFuture;
import java.util.function.Predicate;
import java.util.function.Supplier;
@@ -55,13 +67,14 @@ public class ScriptCommand
if (quoteCount % 2 == 1)
return Collections.emptyList();
int maxLen = prefix.length()<3 ? (prefix.length()*2+1) : 1234;
String eventPrefix = prefix.startsWith("__on_")?prefix.substring(5):null;
List<String> scarpetMatches = scarpetFunctions.stream().
filter(s -> s.startsWith(prefix) && s.length() <= maxLen).map(s -> s+"(").collect(Collectors.toList());
scarpetMatches.addAll(APIFunctions.stream().
filter(s -> s.startsWith(prefix) && s.length() <= maxLen).map(s -> s+"(").collect(Collectors.toList()));
// not that useful in commandline, more so in external scripts, so skipping here
//scarpetMatches.addAll(CarpetServer.scriptServer.events.eventHandlers.keySet().stream().
// filter(s -> s.startsWith(prefix) && s.length() <= maxLen).map(s -> "__"+s+"(").collect(Collectors.toList()));
if (eventPrefix != null) scarpetMatches.addAll(CarpetEventServer.Event.byName.keySet().stream().
filter(s -> s.startsWith(eventPrefix)).map(s -> "__on_"+s+"(").collect(Collectors.toList()));
scarpetMatches.addAll(host.globaFunctionNames(host.main, s -> s.startsWith(prefix)).map(s -> s+"(").collect(Collectors.toList()));
scarpetMatches.addAll(host.globaVariableNames(host.main, s -> s.startsWith(prefix)).collect(Collectors.toList()));
return scarpetMatches;
@@ -14,15 +14,11 @@ import com.mojang.brigadier.exceptions.SimpleCommandExceptionType;
import net.minecraft.command.argument.BlockPosArgumentType;
import net.minecraft.command.argument.DimensionArgumentType;
import net.minecraft.entity.SpawnGroup;
import net.minecraft.entity.player.PlayerEntity;
import net.minecraft.server.command.ServerCommandSource;
import net.minecraft.server.network.ServerPlayerEntity;
import net.minecraft.server.world.ServerWorld;
import net.minecraft.util.DyeColor;
import net.minecraft.util.math.BlockPos;
import net.minecraft.util.registry.RegistryKey;
import net.minecraft.world.World;
import net.minecraft.world.dimension.DimensionType;
import java.util.Arrays;
import java.util.stream.Collectors;
@@ -8,7 +8,6 @@ import carpet.utils.Messenger;
import com.mojang.brigadier.CommandDispatcher;
import com.mojang.brigadier.builder.LiteralArgumentBuilder;
import com.mojang.brigadier.exceptions.CommandSyntaxException;
import net.minecraft.entity.player.PlayerEntity;
import net.minecraft.server.network.ServerPlayerEntity;
import net.minecraft.text.BaseText;
import net.minecraft.server.command.ServerCommandSource;
@@ -90,10 +89,7 @@ public class TickCommand
{
}
BaseText message = TickSpeed.tickrate_advance(player, advance, tail_command, source);
if (message != null)
{
source.sendFeedback(message, false);
}
source.sendFeedback(message, false);
return 1;
}