Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- package ua.whitebear60.beehive.cmd;
- import net.minecraft.command.CommandBase;
- import net.minecraft.command.CommandException;
- import net.minecraft.command.ICommandSender;
- import net.minecraft.server.MinecraftServer;
- import net.minecraft.util.text.ITextComponent;
- import net.minecraft.util.text.TextComponentString;
- import net.minecraft.util.text.TextComponentTranslation;
- import net.minecraft.util.text.TextFormatting;
- import net.minecraft.util.text.event.ClickEvent;
- import net.minecraft.world.GameType;
- import org.apache.logging.log4j.LogManager;
- import org.apache.logging.log4j.Logger;
- import ua.whitebear60.beehive.Reference;
- import java.util.*;
- /*
- * Originally coded by HellFirePvP, modified by WhiteBear60 for the Beehive modpack needs
- */
- public class CommandBeehive extends CommandBase {
- private ITextComponent newLine = new TextComponentString("\n");
- private static ITextComponent separator = new TextComponentString("===========\n");
- private static Logger logger = LogManager.getLogger(Reference.NAME);
- private static final String[] COMMANDS = new String[]{
- "help",
- "start",
- "test"
- };
- private List<String> cmdAliases = new ArrayList<>();
- public CommandBeehive() {
- this.cmdAliases.add("beehive");
- this.cmdAliases.add("bee");
- }
- @Override
- public String getName() {
- return "beehive";
- }
- @Override
- public String getUsage(ICommandSender sender) {
- return "/beehive <action>";
- }
- @Override
- public List<String> getAliases() {
- return cmdAliases;
- }
- @Override
- public boolean isUsernameIndex(String[] args, int index) {
- return index == 1;
- }
- @Override
- public void execute(MinecraftServer server, ICommandSender sender, String[] args) throws CommandException {
- ITextComponent only_once = new TextComponentTranslation("beehive.cmd.has_tag");
- HashSet<String> senderTags = new HashSet<String>(sender.getCommandSenderEntity().getTags());
- if (args.length == 0) {
- senderTags.clear();
- senderTags.addAll(sender.getCommandSenderEntity().getTags());
- logger.info("Displaying help...");
- logger.info("The player tags are: " + senderTags);
- displayHelp(sender);
- return;
- }
- if (args.length == 1) {
- String identifier = args[0];
- if ("help".equalsIgnoreCase(identifier)) {
- displayHelp(sender);
- } else if ("start".equalsIgnoreCase(identifier)) {
- // TODO: Move welcome text here and make it translatable.
- if (senderTags.contains("start1")) {
- sender.sendMessage(only_once);
- logger.warn(sender.getName() + " is trying to execute start command more than once.");
- logger.info("The player tags are: " + senderTags);
- }
- if (!senderTags.contains("start1")) {
- ITextComponent welcomeText1 = new TextComponentTranslation("beehive.welcome");
- welcomeText1.getStyle().setColor(TextFormatting.YELLOW);
- ITextComponent welcomeText2 = new TextComponentTranslation("beehive.welcome.page1.c1");
- welcomeText2.getStyle().setColor(TextFormatting.YELLOW);
- ITextComponent welcomeText3 = new TextComponentTranslation("beehive.welcome.page1.c2");
- welcomeText3.getStyle().setColor(TextFormatting.WHITE);
- ITextComponent welcomeText4 = new TextComponentTranslation("beehive.welcome.page1.c3");
- // /millSpawnVillage byzantines tradingvillage 508 497
- welcomeText4.getStyle().setColor(TextFormatting.GREEN).setClickEvent(new ClickEvent(ClickEvent.Action.RUN_COMMAND, "/say @a Byzantines village is preparing to spawn"));
- // sender.sendMessage(welcomeText2);
- ITextComponent welcomeText5 = new TextComponentTranslation("beehive.welcome.page1.c4");
- // /millSpawnVillage seljuk agriculture_village_seljuks 508 497
- welcomeText5.getStyle().setColor(TextFormatting.GREEN).setClickEvent(new ClickEvent(ClickEvent.Action.RUN_COMMAND, "/say @a Seljuk Turks village is preparing to spawn"));
- ITextComponent welcomeText6 = new TextComponentTranslation("beehive.welcome.page1.c5");
- // /millSpawnVillage japanese seiji 508 497
- welcomeText6.getStyle().setColor(TextFormatting.GREEN).setClickEvent(new ClickEvent(ClickEvent.Action.RUN_COMMAND, "/say @a Japanese village is preparing to spawn"));
- ITextComponent welcomeText7 = new TextComponentTranslation("beehive.welcome.page1.to_next_page");
- welcomeText7.getStyle().setColor(TextFormatting.AQUA);
- ITextComponent welcomeText8 = new TextComponentTranslation("beehive.welcome.click_here");
- welcomeText8.getStyle().setColor(TextFormatting.GREEN).setClickEvent(new ClickEvent(ClickEvent.Action.RUN_COMMAND, "/beehive start 1"));
- ITextComponent result = welcomeText1.appendSibling(new TextComponentString(" ")).appendSibling(welcomeText2).appendSibling(new TextComponentString(" ")).appendSibling(welcomeText3).appendSibling(newLine).appendSibling(welcomeText4).appendSibling(newLine).appendSibling(welcomeText5).appendSibling(newLine).appendSibling(welcomeText6).appendSibling(newLine).appendSibling(welcomeText7).appendSibling(new TextComponentString(" ")).appendSibling(welcomeText8);
- // sender.getCommandSenderEntity().addTag("start1");
- sender.sendMessage(result);
- }
- // BlockPos pos = sender.getPosition();
- // double px = pos.getX();
- // double py = 10;
- // double pz = pos.getZ();
- // server.getCommandManager().executeCommand( server, "/tp " + sender.getName() + " " + px + " " + py + " " + pz );
- } else if ("test".equalsIgnoreCase(identifier)) {
- // sender.sendMessage(new TextComponentTranslation("beehive.keyhole.success"));
- sender.sendMessage(new TextComponentString("Test is not implemented yet."));
- }
- } else if (args.length == 2) {
- String identifier = args[1];
- if ("1".equalsIgnoreCase(identifier)) {
- if (senderTags.contains("start2")) {
- sender.sendMessage(only_once);
- logger.warn(sender.getName() + " is trying to execute start command more than once.");
- logger.info("The player tags are: " + senderTags);
- } if (!senderTags.contains("start2")) {
- ITextComponent two_hive = new TextComponentTranslation("beehive.welcome.page2.c1");
- two_hive.getStyle().setColor(TextFormatting.YELLOW);
- ITextComponent sizes = new TextComponentTranslation("beehive.welcome.page2.c2");
- sizes.getStyle().setColor(TextFormatting.YELLOW);
- ITextComponent tp = new TextComponentTranslation("beehive.welcome.page2.c3");
- tp.getStyle().setColor(TextFormatting.YELLOW);
- ITextComponent proceed = new TextComponentTranslation("beehive.welcome.page2.c4");
- proceed.getStyle().setColor(TextFormatting.YELLOW);
- ITextComponent click_here = new TextComponentTranslation("beehive.welcome.click_here");
- click_here.getStyle().setColor(TextFormatting.GREEN).setClickEvent(new ClickEvent(ClickEvent.Action.RUN_COMMAND, "/beehive start 2"));
- // sender.getCommandSenderEntity().addTag("start2");
- sender.sendMessage(separator.appendSibling(two_hive).appendSibling(new TextComponentString(" ")).appendSibling(sizes).appendSibling(new TextComponentString(" ")).appendSibling(tp).appendSibling(new TextComponentString(" ")).appendSibling(proceed).appendSibling(new TextComponentString(" ")).appendSibling(click_here));
- }
- }
- if ("2".equalsIgnoreCase(identifier)) {
- if (senderTags.contains("start3")) {
- sender.sendMessage(only_once);
- logger.warn(sender.getName() + " is trying to execute start command more than once.");
- logger.info("The player tags are: " + senderTags);
- } if (!senderTags.contains("start3")) {
- ITextComponent has_tp = new TextComponentTranslation("beehive.welcome.page3.c1");
- has_tp.getStyle().setColor(TextFormatting.YELLOW);
- ITextComponent to_tp = new TextComponentTranslation("beehive.welcome.page3.c2");
- to_tp.getStyle().setColor(TextFormatting.YELLOW);
- ITextComponent big = new TextComponentTranslation("beehive.welcome.page3.c3");
- big.getStyle().setColor(TextFormatting.YELLOW);
- ITextComponent small = new TextComponentTranslation("beehive.welcome.page3.c4");
- small.getStyle().setColor(TextFormatting.YELLOW);
- ITextComponent village = new TextComponentTranslation("beehive.welcome.page3.c5");
- village.getStyle().setColor(TextFormatting.YELLOW);
- ITextComponent goodluck = new TextComponentTranslation("beehive.goodluck");
- goodluck.getStyle().setColor(TextFormatting.YELLOW);
- // sender.getCommandSenderEntity().addTag("start3");
- sender.sendMessage(separator.appendSibling(has_tp).appendSibling(newLine).appendSibling(to_tp).appendSibling(newLine).appendSibling(big).appendSibling(newLine).appendSibling(small).appendSibling(newLine).appendSibling(village).appendSibling(newLine).appendSibling(newLine).appendSibling(goodluck));
- server.commandManager.executeCommand(sender, "/tp " + sender.getName() + " -2 21 -503");
- getCommandSenderAsPlayer(sender).setGameType(GameType.SURVIVAL);
- }
- }
- }
- }
- private void displayHelp(ICommandSender sender) {
- sender.sendMessage(new TextComponentString("\nAvialable Subcommands:"));
- sender.sendMessage(new TextComponentString("§a/beehive start§7 - start the map"));
- sender.sendMessage(new TextComponentString("§a/beehive help§7 - display this help"));
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement