Merge pull request #1669 from 9Valjew/master

Satellite List Command
This commit is contained in:
HbmMods 2024-09-12 16:22:41 +02:00 committed by GitHub
commit 89139ec30e
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
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.command.ICommandSender;
import net.minecraft.entity.player.EntityPlayer; import net.minecraft.entity.player.EntityPlayer;
import net.minecraft.util.ChatComponentTranslation; import net.minecraft.util.ChatComponentTranslation;
import net.minecraft.util.ChatComponentText;
import net.minecraft.util.ChatStyle; import net.minecraft.util.ChatStyle;
import net.minecraft.util.EnumChatFormatting; import net.minecraft.util.EnumChatFormatting;
@ -25,8 +26,10 @@ public class CommandSatellites extends CommandBase {
@Override @Override
public String getCommandUsage(ICommandSender iCommandSender) { public String getCommandUsage(ICommandSender iCommandSender) {
return String.format(Locale.US, return String.format(Locale.US,
"%s/%s orbit %s- Launch the held satellite\n" + "%s/%s orbit %s- Launch the held satellite.\n" +
"%s/%s descend <frequency> %s- Deletes satellite by frequency.", "%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,
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))); sender.addChatMessage(new ChatComponentTranslation( "commands.satellite.no_satellite").setChatStyle(new ChatStyle().setColor(EnumChatFormatting.RED)));
} }
break; 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(); return Collections.emptyList();
} }
if(args.length == 1) { if(args.length == 1) {
return getListOfStringsMatchingLastWord(args, "orbit", "descend"); return getListOfStringsMatchingLastWord(args, "orbit", "descend","list");
} }
if (args[0].equals("descend")) { if (args[0].equals("descend")) {
return getListOfStringsFromIterableMatchingLastWord(args, SatelliteSavedData.getData(sender.getEntityWorld()).sats.keySet().stream().map(String::valueOf).collect(Collectors.toList())); 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.XENON_OXY=Boosted Linde Xenon Cycle
chem.YELLOWCAKE=Yellowcake Production 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.no_satellite=No satellite using this frequency found!
commands.satellite.not_a_satellite=The held item is not a satellite! commands.satellite.not_a_satellite=The held item is not a satellite!
commands.satellite.satellite_descended=Satellite successfully descended. commands.satellite.satellite_descended=Satellite successfully descended.