Added satellite list command

This commit is contained in:
9Valjews 2024-09-08 21:50:34 +03:00
parent 59d54942a3
commit fffad80638
2 changed files with 23 additions and 3 deletions

View File

@ -8,6 +8,7 @@ import net.minecraft.command.CommandBase;
import net.minecraft.command.ICommandSender;
import net.minecraft.entity.player.EntityPlayer;
import net.minecraft.util.ChatComponentTranslation;
import net.minecraft.util.ChatComponentText;
import net.minecraft.util.ChatStyle;
import net.minecraft.util.EnumChatFormatting;
@ -25,8 +26,10 @@ public class CommandSatellites extends CommandBase {
@Override
public String getCommandUsage(ICommandSender iCommandSender) {
return String.format(Locale.US,
"%s/%s orbit %s- Launch the held satellite\n" +
"%s/%s descend <frequency> %s- Deletes satellite by frequency.",
"%s/%s orbit %s- Launch the held satellite.\n" +
"%s/%s descend <frequency> %s- Deletes satellite by frequency.\n"+
"%s/%s list %s- Lists all active satellites.",
EnumChatFormatting.GREEN, getCommandName(), EnumChatFormatting.LIGHT_PURPLE,
EnumChatFormatting.GREEN, getCommandName(), EnumChatFormatting.LIGHT_PURPLE,
EnumChatFormatting.GREEN, getCommandName(), EnumChatFormatting.LIGHT_PURPLE
);
@ -65,6 +68,22 @@ public class CommandSatellites extends CommandBase {
sender.addChatMessage(new ChatComponentTranslation( "commands.satellite.no_satellite").setChatStyle(new ChatStyle().setColor(EnumChatFormatting.RED)));
}
break;
case "list":
data = SatelliteSavedData.getData(sender.getEntityWorld());
if (data.sats.isEmpty()) {
ChatComponentTranslation message = new ChatComponentTranslation("commands.satellite.no_active_satellites");
message.getChatStyle().setColor(EnumChatFormatting.RED);
sender.addChatMessage(message);
} else {
data.sats.forEach((listFreq, sat) -> {
String messageText = String.valueOf(listFreq) + " - " + sat.getClass().getSimpleName();
ChatComponentText message = new ChatComponentText(messageText);
message.getChatStyle().setColor(EnumChatFormatting.GREEN);
sender.addChatMessage(message);
});
}
break;
}
}
@ -78,7 +97,7 @@ public class CommandSatellites extends CommandBase {
return Collections.emptyList();
}
if(args.length == 1) {
return getListOfStringsMatchingLastWord(args, "orbit", "descend");
return getListOfStringsMatchingLastWord(args, "orbit", "descend","list");
}
if (args[0].equals("descend")) {
return getListOfStringsFromIterableMatchingLastWord(args, SatelliteSavedData.getData(sender.getEntityWorld()).sats.keySet().stream().map(String::valueOf).collect(Collectors.toList()));

View File

@ -675,6 +675,7 @@ chem.XENON=Linde Xenon Cycle
chem.XENON_OXY=Boosted Linde Xenon Cycle
chem.YELLOWCAKE=Yellowcake Production
commands.satellite.no_active_satellites=No active satellites found!
commands.satellite.no_satellite=No satellite using this frequency found!
commands.satellite.not_a_satellite=The held item is not a satellite!
commands.satellite.satellite_descended=Satellite successfully descended.