implement lobby check
This commit is contained in:
parent
2577a71ca7
commit
1a9a9aea42
4 changed files with 83 additions and 4 deletions
|
@ -0,0 +1,72 @@
|
|||
package net.saltymc.eaa.commands;
|
||||
|
||||
import com.mojang.brigadier.arguments.StringArgumentType;
|
||||
import com.mojang.brigadier.builder.LiteralArgumentBuilder;
|
||||
import com.mojang.brigadier.context.CommandContext;
|
||||
import net.fabricmc.fabric.api.client.command.v1.FabricClientCommandSource;
|
||||
import net.minecraft.client.MinecraftClient;
|
||||
import net.minecraft.client.toast.SystemToast;
|
||||
import net.minecraft.command.argument.EntityArgumentType;
|
||||
import net.minecraft.text.Text;
|
||||
import net.saltymc.eaa.util.database.DB_Player;
|
||||
import net.saltymc.eaa.util.database.DB_Tag;
|
||||
import net.saltymc.eaa.util.mojangApi.PlayerInfo;
|
||||
|
||||
import java.text.SimpleDateFormat;
|
||||
import java.util.*;
|
||||
import java.util.stream.Collectors;
|
||||
|
||||
import static net.fabricmc.fabric.api.client.command.v1.ClientCommandManager.argument;
|
||||
import static net.fabricmc.fabric.api.client.command.v1.ClientCommandManager.literal;
|
||||
|
||||
public class CheckLobbyCommand extends EaaModCommand{
|
||||
|
||||
private static final Map<String, DB_Tag> player_tags = new HashMap<>();
|
||||
public static final SimpleDateFormat dateformat = new SimpleDateFormat("dd.MM.yyyy");
|
||||
|
||||
@Override
|
||||
public int run(CommandContext<FabricClientCommandSource> context) {
|
||||
FabricClientCommandSource source = context.getSource();
|
||||
|
||||
try {
|
||||
List<String> uuids = new ArrayList<>();
|
||||
MinecraftClient.getInstance().getNetworkHandler().getPlayerList().forEach(x -> uuids.add(x.getProfile().getId().toString()));
|
||||
|
||||
int dangerLvl = 0; // 0 = nothing; 1 = idiot; 2 = hacker
|
||||
|
||||
for (String uuid: uuids){
|
||||
TagCommand.loadPlayer(uuid, false);
|
||||
if (TagCommand.getHashMap().containsKey(uuid)){
|
||||
DB_Tag.Type type = TagCommand.getHashMap().get(uuid).getType();
|
||||
if (type == DB_Tag.Type.HACKER){
|
||||
dangerLvl = 2;
|
||||
break;
|
||||
} else if (type == DB_Tag.Type.IDIOT){
|
||||
dangerLvl = 1;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
switch (dangerLvl){
|
||||
case 0:
|
||||
SystemToast.add(source.getClient().getToastManager(), SystemToast.Type.WORLD_BACKUP, Text.of("OKAY!"), Text.of("No Hackers found"));
|
||||
break;
|
||||
case 1:
|
||||
SystemToast.add(source.getClient().getToastManager(), SystemToast.Type.TUTORIAL_HINT, Text.of("MEH!"), Text.of("There is an Idiot!"));
|
||||
break;
|
||||
case 2:
|
||||
SystemToast.add(source.getClient().getToastManager(), SystemToast.Type.WORLD_ACCESS_FAILURE, Text.of("ALARM!"), Text.of("There is a Hacker!"));
|
||||
}
|
||||
|
||||
} catch (Exception e) {
|
||||
source.sendFeedback(Text.of(e.toString()));
|
||||
}
|
||||
|
||||
return 1;
|
||||
}
|
||||
|
||||
@Override
|
||||
public LiteralArgumentBuilder<FabricClientCommandSource> getCommandSpecification() {
|
||||
return literal("/lobby").executes(this);
|
||||
}
|
||||
}
|
Loading…
Add table
Add a link
Reference in a new issue