public boolean dispatchServerCommand(CommandSender sender, ServerCommand serverCommand) { if (sender instanceof Conversable) { Conversable conversable = (Conversable)sender; if (conversable.isConversing()) { conversable.acceptConversationInput(serverCommand.command); return true; } } try { this.playerCommandState = true; return dispatchCommand(sender, serverCommand.command); } catch (Exception ex) { getLogger().log(Level.WARNING, "Unexpected exception while parsing console command \"" + serverCommand.command + '"', ex); return false; } finally { this.playerCommandState = false; } }
public boolean dispatchServerCommand(CommandSender sender, ServerCommand serverCommand) { if (sender instanceof Conversable) { Conversable conversable = (Conversable)sender; if (conversable.isConversing()) { conversable.acceptConversationInput(serverCommand.command); return true; } } try { return dispatchCommand(sender, serverCommand.command); } catch (Exception ex) { getLogger().log(Level.WARNING, "Unexpected exception while parsing console command \"" + serverCommand.command + '"', ex); return false; } }
/** * Executes the given command, returning its success * * @param sender Source of the command * @param command Command which was executed * @param label Alias of the command which was used * @param args Passed command arguments * @return true if a valid command, otherwise false */ @Override public boolean onCommand(CommandSender cs, Command command, String label, String[] args) { if (cs instanceof Player) { if (!cs.hasPermission("ssba.admin.setmode")) { cs.sendMessage(Col.Dark_Red() + "You do not have permission to run setmode"); return true; } } if (cs instanceof Conversable) { String[] strings1 = new String[19]; for (int i = 0; i < 19; i++) { strings1[i] = ""; } cs.sendMessage(strings1); Map<Object, Object> data = new HashMap<>(); data.put("pre", 2); factory.withInitialSessionData(data); factory.withFirstPrompt(new SetModeStart()); factory.buildConversation((Conversable) cs).begin(); return true; } else return false; }
@Override public String getPromptText(ConversationContext context) { Conversable c = context.getForWhom(); String mess; c.sendRawMessage(""); c.sendRawMessage(Col.Grey() + "---------------------------"); c.sendRawMessage(Col.Gold() + "Dedicated Mode: " + Col.Reset()); c.sendRawMessage(Col.Green() + "Set to dedicated if will only be used for SuperSkyBros"); c.sendRawMessage(Col.Grey() + "---------------------------"); c.sendRawMessage(Col.Gold() + "Mixed Mode: " + Col.Reset()); c.sendRawMessage(Col.Green() + "Set to mixed mode if the server runs other plugins like"); c.sendRawMessage(Col.Green() + "factions or has a survival world" + Col.Reset()); mess = "\n" + Col.Blue() + "If unsure set to mixed mode you can always change it later" + Col.Reset(); return mess; }
public static void sendLine(Conversable c) { StringBuilder sb = new StringBuilder(61); int len = sb.append(ChatColor.GRAY + "--------------------------------------------").length(); int padding = 61 - len; if (padding <= 0) { c.sendRawMessage(sb.toString()); return; } else { int mod = padding % 2; if (padding % 2 == 1) { padding--; } int off, out; off = padding / 2; out = padding / 2; char[] ch = new char[out]; for (int i = out; i <= 0; i--) { ch[i] = '\u0020'; } sb.insert(0, ch); c.sendRawMessage(sb.toString()); } }
public boolean dispatchServerCommand(CommandSender sender, net.minecraft.command.ServerCommand serverCommand) { if (sender instanceof Conversable) { Conversable conversable = (Conversable)sender; if (conversable.isConversing()) { conversable.acceptConversationInput(serverCommand.field_73702_a); return true; } } try { return dispatchCommand(sender, serverCommand.field_73702_a); } catch (Exception ex) { getLogger().log(Level.WARNING, "Unexpected exception while parsing console command \"" + serverCommand.field_73702_a + '"', ex); return false; } }
public boolean dispatchServerCommand(CommandSender sender, net.minecraft.command.ServerCommand serverCommand) { if (sender instanceof Conversable) { Conversable conversable = (Conversable)sender; if (conversable.isConversing()) { conversable.acceptConversationInput(serverCommand.command); return true; } } try { this.playerCommandState = true; // Cauldron start - handle bukkit/vanilla console commands int space = serverCommand.command.indexOf(" "); // if bukkit command exists then execute it over vanilla if (this.getCommandMap().getCommand(serverCommand.command.substring(0, space != -1 ? space : serverCommand.command.length())) != null) { return this.dispatchCommand(sender, serverCommand.command); } else { // process vanilla console command craftCommandMap.setVanillaConsoleSender(serverCommand.sender); return this.dispatchVanillaCommand(sender, serverCommand.command); } // Cauldron end } catch (Exception ex) { getLogger().log(Level.WARNING, "Unexpected exception while parsing console command \"" + serverCommand.command + '"', ex); return false; } finally { this.playerCommandState = false; } }
public static void askForName(Conversable whom, IPet pet, boolean admin) { new ConversationFactory(EchoPet.getPlugin()) .withModality(true) .withLocalEcho(false) .withPrefix(new NameConversationPrefix()) .withTimeout(90) .withFirstPrompt(new NamePrompt(pet, admin)) .withEscapeSequence("exit") .withEscapeSequence("quit") .buildConversation(whom).begin(); }
public void sendPrintMessage(CharSequence message, String source){ if (source == null) source = ""; String prefix = String.format(VarScript.printPrefix, source); if (sender instanceof Conversable && ((Conversable) sender).isConversing()) { ((Conversable) sender).sendRawMessage(prefix + message); } else { sender.sendMessage(prefix + message); } }
public void sendMessage(CharSequence message, String source){ if (source == null) source = ""; String prefix = String.format(VarScript.prefix, source); if (sender instanceof Conversable && ((Conversable) sender).isConversing()) { ((Conversable) sender).sendRawMessage(prefix + message); } else { sender.sendMessage(prefix + message); } }
public void sendErrorMessage(CharSequence message, String source){ if (source == null) source = ""; String prefix = String.format(VarScript.errorPrefix, source); if (sender instanceof Conversable && ((Conversable) sender).isConversing()) { ((Conversable) sender).sendRawMessage(prefix + message); } else { sender.sendMessage(prefix + message); } }
public static void send(Conversable conversable, String message) { if (conversable instanceof CommandSender) { send((CommandSender) conversable, message); return; } if (message != null) { conversable.sendRawMessage(HoloAPI.getPrefix() + ChatColor.translateAlternateColorCodes('&', message)); } }
@Command( command = "create", description = "Create a hologram from text", permission = "holoapi.holo.create", help = {"Lines can be entered one after another", "Once the command is entered, you will be prompted to enter the line content"} ) public boolean create(CommandEvent event) { if (!(event.sender() instanceof Conversable)) { event.respond(Lang.NOT_CONVERSABLE.getValue()); return true; } InputFactory.buildBasicConversation().withFirstPrompt(new InputPrompt()).buildConversation((Conversable) event.sender()).begin(); return true; }
@Command( command = "create animation", description = "Create a hologram using animations", permission = "holoapi.holo.create", help = "Animation can be defined in the HoloAPI config file" ) public boolean createAnimation(CommandEvent event) { if (!(event.sender() instanceof Conversable)) { event.respond(Lang.NOT_CONVERSABLE.getValue()); return true; } InputFactory.buildBasicConversation().withFirstPrompt(new AnimationBuilderInputPrompt()).buildConversation((Conversable) event.sender()).begin(); return true; }
@Command( command = "build", description = "Dynamically build a combined hologram of both text and images", permission = "holoapi.holo.build" ) public boolean command(CommandEvent event) { if (!(event.sender() instanceof Conversable)) { event.respond(Lang.NOT_CONVERSABLE.getValue()); return true; } InputFactory.buildBasicConversation().withFirstPrompt(new BuilderInputPrompt()).buildConversation((Conversable) event.sender()).begin(); return true; }
private void sendRaw(Object message, Conversable conversable) { if (message instanceof String) { String string = (String) message; conversable.sendRawMessage(string); } else { String[] list = (String[]) message; for (String s : list) { conversable.sendRawMessage(s); } } }
/** * @param player Player * @param args String[] * @return boolean */ @Override public boolean onCommand(Player player, String[] args) throws IOException, ClassNotFoundException { if (!SkyApi.getSm().isDedicated()) { player.sendMessage(Col.Dark_Red() + "You can only run this in Dedicated mode"); return true; } factory = DefaultConversationFactory.getDefaultConversation(); String[] strings1 = new String[6]; for (int i = 0; i < 6; i++) { strings1[i] = ""; } player.sendMessage(strings1); Map<Object, Object> data = new HashMap<>(); data.put("pre", 2); factory.withInitialSessionData(data); factory.withFirstPrompt(new SetAutoStart()); factory.buildConversation((Conversable) player).begin(); /*player.sendMessage(strings1); player.sendMessage(this.cHeader); getPlugin().getConfig().set("generateDefaultWorld", true); getPlugin().saveConfig(); player.sendMessage(ChatColor.GREEN + "The server will now shutdown you will need to stop and start the server"); player.sendMessage("3 times to complete the setup the console will display details of progress."); player.sendMessage(ChatColor.GRAY + "----------------------------------------------"); DelayedShutDown.shutDown(); player.sendMessage(ChatColor.RED + "The server will now shutdown in 5 seconds");*/ return true; }
@Override public String getPromptText(ConversationContext context) { Conversable c = context.getForWhom(); c.sendRawMessage(cHeader); c.sendRawMessage(ChatColor.GREEN + "To begin you need to decide the server mode"); c.sendRawMessage(ChatColor.GREEN + "There are 2 modes that you can choose"); c.sendRawMessage(""); c.sendRawMessage(ChatColor.GOLD + "MIXED MODE" + ChatColor.GREEN + " or " + ChatColor.GOLD + "DEDICATED MODE"); context.getForWhom().sendRawMessage(Col.Grey() + "---------------------------"); return ChatColor.BLUE + "Type /quit at anytime to exit"; }
@Override public String getPromptText(ConversationContext context) { Conversable c = context.getForWhom(); c.sendRawMessage(""); c.sendRawMessage(Col.Grey() + "---------------------------"); return ChatColor.BLUE + "Final Confirmation would you like to proceed ? " + Col.Reset() + "\n" + formatFixedSet(); }
@Override public String getPromptText(ConversationContext context) { Conversable c = context.getForWhom(); c.sendRawMessage(cHeader); c.sendRawMessage(ChatColor.GREEN + "Autosetup is a very powerful feature."); c.sendRawMessage(ChatColor.GREEN + "It is to be used for DEDICATED server only"); c.sendRawMessage(""); c.sendRawMessage(ChatColor.BLUE + "Type /quit at anytime to exit"); context.getForWhom().sendRawMessage(Col.Grey() + "---------------------------"); return ChatColor.GREEN + "Enter any key to continue"; }
@Override public String getPromptText(ConversationContext context) { Conversable c = context.getForWhom(); SkyApi.getSm().getPluginConfig().set("generateDefaultWorld", true); SkyApi.getSm().getPluginConfig().set("worldGenerateStage", 1); SkyApi.getSCB().saveConfig(); c.sendRawMessage(""); c.sendRawMessage(Col.Grey() + "---------------------------"); c.sendRawMessage(ChatColor.RED + "AutoSetup will now shutdown the server"); DelayedShutDown.shutDown(); return ChatColor.RED + "Please restart the server 3 times"; }
@Override public String getPromptText(ConversationContext context) { Conversable c = context.getForWhom(); c.sendRawMessage(Col.Grey() + "---------------------------"); c.sendRawMessage(ChatColor.BLUE + "AutoSetup does the following:"); c.sendRawMessage(ChatColor.GOLD + "1) " + ChatColor.GREEN + "The main world will be deleted"); c.sendRawMessage(ChatColor.GOLD + "2) " + ChatColor.GREEN + "The 'end' and 'nether' will be deleted"); c.sendRawMessage(ChatColor.GOLD + "3) " + ChatColor.GREEN + "Server settings will be auto applied"); c.sendRawMessage(ChatColor.GOLD + "4) " + ChatColor.GREEN + "A new empty void world is created"); c.sendRawMessage(ChatColor.GOLD + "5) " + ChatColor.GREEN + "This world is set as the main world"); c.sendRawMessage(Col.Grey() + "---------------------------"); return ChatColor.BLUE + "Enter any key to continue"; }
@Override public String getPromptText(ConversationContext context) { Conversable c = context.getForWhom(); c.sendRawMessage(ChatColor.GRAY + "---------------------------"); c.sendRawMessage(""); c.sendRawMessage(ChatColor.GREEN + "If you proceed the server will shut down"); c.sendRawMessage(ChatColor.DARK_GREEN + "You will then need to restart the server 3 times"); c.sendRawMessage(ChatColor.GREEN + "The console will tell you when to login"); c.sendRawMessage(ChatColor.DARK_GREEN + "Simple as that, I advise you to proceed"); c.sendRawMessage(ChatColor.GRAY + "---------------------------"); return ChatColor.BLUE + "Would you like to proceed ? " + Col.Reset() + "\n" + formatFixedSet(); }
@Override public void onExecute(CommandSender sender, String[] args) { // Store Regex Filter to differentiate between user and IP String ip_filter = "\\d{1,3}\\.\\d{1,3}\\.\\d{1,3}\\.\\d{1,3}"; argument = args[1]; // If the argument is an IP address, validate it and fetch IPO. if (argument.matches(ip_filter)) { if (db.isValidIP(argument)) { // Fetch IPO from Database IPObject ipo = db.getIPObject(argument); // If the IPO is exempt, unexempt it, else throw an error. if (ipo.getExemptStatus()) { db.unexemptIP(argument); } else { sendPlayerMessage(sender, getLocalString("NO_MODIFY")); return; } sendPlayerMessage(sender, getLocalString("EXEMPT_DEL_SUC")); } else { sendPlayerMessage(sender, getLocalString("NO_FIND")); } /* If the argument is a player name, fetch the UPO and verify whether * it is exempt or not. If it is, unexempt it, otherwise throw a * NO_MODIFY error.*/ } else { if (db.isValidPlayer(argument)) { // Prompt for the Exemption Type getConversationFactory().withFirstPrompt(this); getConversationFactory() .buildConversation((Conversable) sender).begin(); } else { sendPlayerMessage(sender, getLocalString("NO_FIND")); } } }
@Override public void onExecute(CommandSender sender, String[] args) { // Store Argument for use with different Exempt Types argument = args[1]; // If the argument is an IP address, validate it and ask for the type. if (argument.matches(ip_filter)) { if (db.isValidIP(argument)) { // Prompt for the Exemption Type getConversationFactory().withFirstPrompt(this); getConversationFactory() .buildConversation((Conversable) sender).begin(); } else { sendPlayerMessage(sender, getLocalString("NO_FIND")); } // If the argument is a user name, validate it and ask for the type. } else { if (db.isValidPlayer(argument)) { // Prompt for the Exemption Type getConversationFactory().withFirstPrompt(this); getConversationFactory() .buildConversation((Conversable) sender).begin(); } else { sendPlayerMessage(sender, getLocalString("NO_FIND")); } } }