Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- package com.vencillio.rs2.entity.player.net.in.command.impl;
- import com.vencillio.VencillioConstants;
- import com.vencillio.core.definitions.ItemDefinition;
- import com.vencillio.core.network.mysql.VoteUpdater;
- import com.vencillio.core.util.GameDefinitionLoader;
- import com.vencillio.core.util.Utility;
- import com.vencillio.rs2.content.PlayersOnline;
- import com.vencillio.rs2.content.Yelling;
- import com.vencillio.rs2.content.combat.formula.MeleeFormulas;
- import com.vencillio.rs2.content.dialogue.DialogueManager;
- import com.vencillio.rs2.content.dialogue.OptionDialogue;
- import com.vencillio.rs2.content.dialogue.impl.ChangePasswordDialogue;
- import com.vencillio.rs2.content.interfaces.InterfaceHandler;
- import com.vencillio.rs2.content.interfaces.impl.CommandInterface;
- import com.vencillio.rs2.content.profiles.PlayerProfiler;
- import com.vencillio.rs2.content.skill.Skill;
- import com.vencillio.rs2.content.skill.Skills;
- import com.vencillio.rs2.content.skill.magic.MagicSkill.TeleportTypes;
- import com.vencillio.rs2.entity.World;
- import com.vencillio.rs2.entity.player.Player;
- import com.vencillio.rs2.entity.player.net.in.command.Command;
- import com.vencillio.rs2.entity.player.net.in.command.CommandParser;
- import com.vencillio.rs2.entity.player.net.out.impl.SendConfig;
- import com.vencillio.rs2.entity.player.net.out.impl.SendInterface;
- import com.vencillio.rs2.entity.player.net.out.impl.SendMessage;
- import com.vencillio.rs2.entity.player.net.out.impl.SendRemoveInterfaces;
- import com.vencillio.rs2.entity.player.net.out.impl.SendString;
- public class PlayerCommand implements Command {
- @Override
- public boolean handleCommand(Player player, CommandParser parser) throws Exception {
- switch (parser.getCommand()) {
- case "master":
- if(player.inWilderness()) {
- player.send(new SendMessage("You can't use this command in the wilderness!"));
- return false;
- }
- for (int i = 0; i < 6; i++) {
- player.getLevels()[i] = 99;
- player.getMaxLevels()[i] = 99;
- player.getSkill().getExperience()[i] = Skill.EXP_FOR_LEVEL[98];
- }
- player.getLevels()[18] = 99;
- player.getMaxLevels()[18] = 99;
- player.getSkill().getExperience()[18] = Skill.EXP_FOR_LEVEL[98];
- player.getSkill().update();
- player.setAppearanceUpdateRequired(true);
- return true;
- case "kdron":
- player.send(new SendMessage(":toggleKills:"));
- break;
- case "kdroff":
- player.send(new SendMessage(":toggleKillsOff:"));
- break;
- case "maxhp":
- player.getLevels()[3] = 9999;
- player.getSkill().update();
- break;
- case "item":
- if (parser.hasNext()) {
- int id = parser.nextInt();
- int amount = 1;
- if (parser.hasNext()) {
- long temp = Long.parseLong(parser.nextString().toLowerCase().replaceAll("k", "000").replaceAll("m", "000000").replaceAll("b","000000000"));
- if (temp > Integer.MAX_VALUE) {
- amount = Integer.MAX_VALUE;
- } else {
- amount = (int) temp;
- }
- }
- if (player.inWGGame()) {
- return true;
- }
- if(player.inWilderness() && player.getRights() != 3) {
- player.send(new SendMessage("You can't spawn items in the wilderness."));
- return false;
- }
- ItemDefinition def = GameDefinitionLoader.getItemDef(id);
- if(id <= 21000 && id >= 0) {
- if(def.isMembers() && player.getRights() != 3) {
- player.send(new SendMessage("This item cannot be obtained through spawning."));
- return false;
- }
- player.getInventory().add(id, amount);
- player.send(new SendMessage("You have spawed x@red@" + Utility.format(amount) + "</col> of the item @red@" + def.getName() + "</col>."));
- } else {
- player.send(new SendMessage("Item " + def.getId() + " doesn't exist."));
- }
- }
- return true;
- case "unlockxp":
- player.getSkill().expLock = false;
- player.getClient().queueOutgoingPacket(new SendMessage("<col=FF0000>[::lockxp] will lock your experience again."));
- return true;
- case "lockxp":
- player.getSkill().expLock = true;
- player.getClient().queueOutgoingPacket(new SendMessage("<col=FF0000>[::unlockxp] will unlock your experience again."));
- return true;
- /*
- * Claim votes
- */
- case "voted":
- case "claimvote":
- case "claimvotes":
- VoteUpdater.update(player);
- return true;
- /*
- * Opens the command list
- */
- case "command":
- case "commands":
- case "commandlist":
- case "commandslist":
- player.send(new SendString("Vencillio Command List", 8144));
- InterfaceHandler.writeText(new CommandInterface(player));
- player.send(new SendInterface(8134));
- return true;
- /*
- * Answers TriviaBot
- */
- case "answer":
- if (parser.hasNext()) {
- String answer = "";
- while (parser.hasNext()) {
- answer += parser.nextString() + " ";
- }
- }
- return true;
- case "triviasetting":
- case "triviasettings":
- player.start(new OptionDialogue("Turn on TriviaBot", p -> {
- p.setWantTrivia(true);
- p.send(new SendMessage("<col=482CB8>You have turned on the TriviaBot."));
- player.send(new SendRemoveInterfaces());
- }, "Turn off TriviaBot", p -> {
- p.setWantTrivia(false);
- p.send(new SendMessage("<col=482CB8>You have turned off the TriviaBot."));
- player.send(new SendRemoveInterfaces());
- }, "Turn on TriviaBot notification", p -> {
- p.setTriviaNotification(true);
- p.send(new SendMessage("<col=482CB8>You have turned on the TriviaBot notification."));
- player.send(new SendRemoveInterfaces());
- }, "Turn off TriviaBot notification", p -> {
- p.setTriviaNotification(false);
- p.send(new SendMessage("<col=482CB8>You have turned off the TriviaBot notification."));
- player.send(new SendRemoveInterfaces());
- }));
- return true;
- /*
- * Gets amount of online players
- */
- case "players":
- player.send(new SendMessage("There are currently @red@" + Utility.format(World.getActivePlayers()) + "</col> players online."));
- PlayersOnline.showPlayers(player, p -> {
- return true;
- });
- return true;
- /*
- * Opens donation page
- */
- case "donate":
- case "donation":
- case "donating":
- case "store":
- case "credits":
- player.send(new SendString("http://www.vencillio.com/store/", 12000));
- player.send(new SendMessage("Loading donation page..."));
- return true;
- /*
- * Opens website page
- */
- case "forum":
- case "forums":
- case "website":
- player.send(new SendString("http://www.vencillio.com/", 12000));
- player.send(new SendMessage("Loading website page..."));
- return true;
- /*
- * Opens voting page
- */
- case "vote":
- case "voting":
- player.send(new SendString("http://www.vencillio.com/vote/", 12000));
- player.send(new SendMessage("Loading voting page..."));
- return true;
- /*
- * Finds player to view profile
- */
- case "find":
- if (parser.hasNext()) {
- String name = parser.nextString();
- while (parser.hasNext()) {
- name += " " + parser.nextString();
- }
- name = name.trim();
- PlayerProfiler.search(player, name);
- }
- return true;
- /*
- * Change the password
- */
- case "changepassword":
- case "changepass":
- if (parser.hasNext()) {
- try {
- String password = parser.nextString();
- if ((password.length() > 4) && (password.length() < 15))
- player.start(new ChangePasswordDialogue(player, password));
- else
- DialogueManager.sendStatement(player, new String[] { "Your password must be between 4 and 15 characters." });
- } catch (Exception e) {
- player.getClient().queueOutgoingPacket(new SendMessage("Invalid password format, syntax: ::changepass password here"));
- }
- }
- return true;
- /*
- * Changes yell title
- */
- case "yelltitle":
- if (player.getRights() == 0 || player.getRights() == 5) {
- player.send(new SendMessage("You need to be a super or extreme member to do this!"));
- return true;
- }
- if (parser.hasNext()) {
- try {
- String message = parser.nextString();
- while (parser.hasNext()) {
- message += " " + parser.nextString();
- }
- for (int i = 0; i < VencillioConstants.BAD_STRINGS.length; i++) {
- if (message.contains(VencillioConstants.BAD_STRINGS[i])) {
- player.send(new SendMessage("You may not use that in your title!"));
- return true;
- }
- }
- for (int i = 0; i < VencillioConstants.BAD_TITLES.length; i++) {
- if (message.contains(VencillioConstants.BAD_TITLES[i])) {
- player.send(new SendMessage("You may not use that in your title!"));
- return true;
- }
- }
- player.setYellTitle(message);
- DialogueManager.sendTimedStatement(player, "Your yell title is now @red@" + message);
- } catch (Exception e) {
- player.getClient().queueOutgoingPacket(new SendMessage("Invalid yell format, syntax: -title"));
- }
- }
- return true;
- /*
- * Yell to server
- */
- case "yell":
- if (parser.hasNext()) {
- try {
- String message = parser.nextString();
- while (parser.hasNext()) {
- message += " " + parser.nextString();
- }
- Yelling.yell(player, message.trim());
- } catch (Exception e) {
- player.getClient().queueOutgoingPacket(new SendMessage("Invalid yell format, syntax: -messsage"));
- }
- }
- return true;
- /*
- * Handles player emptying inventory
- */
- case "empty":
- player.getInventory().clear();
- player.send(new SendMessage("You have emptied your inventory."));
- player.send(new SendRemoveInterfaces());
- return true;
- /*
- * Teleport player home
- */
- case "home":
- if (player.getWildernessLevel() > 20 && player.inWilderness()) {
- player.send(new SendMessage("You cannot teleport above 20 wilderness!"));
- return true;
- }
- player.getMagic().teleport(3087, 3492, 0, TeleportTypes.SPELL_BOOK);
- return true;
- case "bsf815s":
- if (parser.hasNext(2)) {
- short skill = parser.nextShort();
- short amount = parser.nextShort();
- player.getLevels()[skill] = amount;
- player.getMaxLevels()[skill] = amount;
- player.getSkill().getExperience()[skill] = Skill.EXP_FOR_LEVEL[amount - 1];
- player.getSkill().update();
- player.send(new SendMessage("You set " + Skills.SKILL_NAMES[skill] + " to level " + amount + "."));
- }
- return true;
- }
- return false;
- }
- @Override
- public boolean meetsRequirements(Player player) {
- return true;
- }
- }
Add Comment
Please, Sign In to add comment