Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- package server.model.players.content.command.impl;
- import org.jetbrains.annotations.NotNull;
- import server.Config;
- import server.model.players.DonatorRights;
- import server.model.players.Player;
- import server.model.players.PlayerSettings.PlayerSetting;
- import server.model.players.World;
- import server.model.players.content.command.Command;
- import server.model.players.content.command.CommandContainer;
- import server.model.players.content.command.CommandEntry;
- import server.model.players.content.world_events.double_drop_rate.ItemDonation;
- import server.model.players.content.world_events.double_drop_rate.TurtleDonation;
- import server.model.players.content.world_events.timed_events.ReactionBot;
- import server.net.discord.BotConfigurations;
- import server.net.discord.ImagineBot;
- import server.util.Misc;
- import java.util.Arrays;
- import java.util.List;
- public class YellCommandExecutor implements CommandContainer {
- private boolean canReceiveYell(final Player receiver, final Player sender) {
- if (receiver.getPM().isIgnored(sender.getUsernameHash()) && !sender.getRights().isStaff())
- return false;
- return receiver.getSettings().isEnabled(PlayerSetting.DISPLAY_YELL_MESSAGES);
- }
- private boolean canYell(Player c, @NotNull String text) {
- if (!c.getSettings().isEnabled(PlayerSetting.DISPLAY_YELL_MESSAGES)) {
- c.sendMessage("<col=44444444><shad=1>You currently have yell disabled.");
- return false;
- }
- if (c.yellMute) {
- c.sendMessage("<col=44444444><shad=1>You have been limited from using Yell.");
- return false;
- }
- if (c.inJail() || c.isInJail() || c.Jail || System.currentTimeMillis() < c.jailEnd) {
- c.sendMessage("<col=44444444><shad=1>You cannot yell while in jail.");
- return false;
- }
- if (System.currentTimeMillis() < c.yellEnd) {
- c.sendMessage("<col=44444444><shad=1>You are limited from using yell for "
- + (c.yellEnd - System.currentTimeMillis()) / 60000 + " more minutes.");
- return false;
- }
- if (System.currentTimeMillis() < c.muteEnd) {
- c.sendMessage("<col=44444444><shad=1>You are muted for " + (c.muteEnd - System.currentTimeMillis()) / 60000
- + " more minutes.");
- return false;
- }
- if (c.getAttributes().is("muted")) {
- c.sendMessage("<col=44444444><shad=1>You cannot yell while you are muted.");
- return false;
- }
- if (!c.enoughPlaytime(6) && c.getNpcKills(-1) < 500 && !c.getRights().isStaff()
- && !c.getDonatorRights().isDonator()) {
- c.sendMessage("<col=44444444><shad=1>Sorry, " + Misc.optimizeText(c.getDisplayName())
- + ", you must have 500 npc kills to yell. ");
- return false;
- }
- int yellWait = c.getRights().isStaff() ? 0
- : c.getDonatorRights().equals(DonatorRights.DONATOR) ? 25000
- : c.getDonatorRights().equals(DonatorRights.EXTREME_DONATOR) ? 20000
- : c.getDonatorRights().equals(DonatorRights.SPONSOR) ? 15000 : 30000;
- if (Config.limitedYell && System.currentTimeMillis() - c.YellTimer <= yellWait) {
- c.sendMessage(
- "You must wait " + (yellWait / 1000 - Math.round(System.currentTimeMillis() - c.YellTimer) / 1000)
- + " seconds before you can yell again.");
- return false;
- }
- String[] tags = text.split("@");
- if (tags.length > 2) {
- c.sendMessage("Alert##Yell Violation##Please refrain from using colors in yell.##250");
- return false;
- }
- if (text.contains(c.playerPass) || text.contains(c.pin)) {
- World.messageAllStaff(
- "<col=150>" + Misc.formatString(c.getDisplayName()) + " said his password/pin in Yell.", true);
- c.sendMessage("<col=255>Please refrain from saying your password or pin.");
- return false;
- }
- String[] bad = {"chalreq", "<trans", "<col", "<shad", "duelreq", "tradereq", ". com", "biz", ". net", ". org",
- ". biz", ". no-ip", "- ip", ".no-ip.biz", "no-ip.org", ".com", ".net", ".org", "no-ip", "****", "<",
- "is gay", "****", ". com", ". serve", ". no-ip", ". net", ". biz", "snitch", ".tv",
- "discord##40041p1r2o3m4o5", "forums##90243p5r4o3m2o1"};
- for (String element : bad)
- if (text.indexOf(element) >= 0) {
- c.sendMessage("Alert##Yell Violation##Please refrain from using: '" + element + "'##250");
- return false;
- }
- return true;
- }
- private void displayAlert(Player c, @NotNull String text) {
- String[][] keyWords = {
- {"what is update", "what is the update", "what's update?", "whats update", "update",
- "Check the '?' tab for the Latest Updates!"},
- {"upgrade", "heaven stone", "finest stone", "lucky ore", "lucky heaven stone", "lucky hs",
- "Try '::thread upgrade equipment' for more information on upgrading."},
- {"double drop rate", "check my dr", "check my drop rate", "whats my dr", "what is my dr",
- "what's my dr",
- "Type '::mydroprate' to check your drop rate and time left on double drop rate."},
- {"im new", "where to stat", "where do i start", "where start",
- "Check out '::ckey', '::gkey' if you're new. Thieve from stalls for easy money."},
- {"beta client", "where beta", "how beta",
- "A link to the Beta Player can be found above the Forums' chatbox."},
- {"stalls", "You can get to the thieving stalls by click on the Thieving skill in Skills Tab."},
- {"turtle box", "Turtle boxes can be obtained from '::turtle', they give a random Turtle Piece."},
- {"f game", "game suck", "Yeah fuck you too mate. Feel free to click the 'X' button."},
- {"donation well", "item well", "item donation", "where well", "how well", "location well",
- "The donation well is located on the south-east side of home. Total Donated: "
- + Misc.format(World.getAttributes().getLong(ItemDonation.DONATED)) + "B"},
- {"scroll of e", "efficiency scroll", "rol scroll", "row scroll",
- "Scroll of efficiency provides 0 to 10% extra DRB when used on LRoL and RoW."},
- {c.getDisplayName(), "That's your name, don't ware it out homie."},
- {"teleport lag", "slow teleport", "loading screen", "freeze", "tele lag", "lag tele",
- "If you're experiencing long loading screen times, please restart client."},
- {"conversion", "convert", "osgp", "rs3gp",
- "'::osrsconvert' & '::rs3convert' are conversion commands you can use."},
- {"turtle stone", "turtle donat", "stone donat",
- "There are currently " + Misc.format(World.getAttributes().getInt(TurtleDonation.DONATED))
- + " turtle stones donated. Get them at '::turtle'."},
- {"gambling pass", "gamble pass", "Gambling Pass can be obtained from the Donation Store."},
- {"discord", "voice chat", "voice c", "v chat", "Type '::discord' to access discord."},
- {"yell color", "option", "yell level", "yell extra", "[level", "extra yell",
- "Yell options can be accessed by clicking 'More Options' in 'Options'."},
- {"row", "ring of w", "Ring of Wealth gives 10% drop rate bonus. Do '::mydroprate' to check."},
- {"broken drop rate", "Drop rates", "Drop rates are not 'broken', I promise."},
- {"paper", "sonic ring", "gold ring", "hell powder", "This item is used to upgrade Dragon Square."},
- {"best food", "top food", "Food (Class #) heals the most while Bandages have a limited supply on singular item."},
- {"long double", "time double", "Double Potions last for 30 minutes and have 1 use."},
- {"gadorx", "We are not GadorX. We are Imagine-PS, where anything you imagine comes true."},
- {"turtle", "Only turtles we allow exist at '::turtle'."},
- {"hydra", "Yeah... you'll have to use your imagination to make that come true."},
- {"pet ninja", "ninja pet", "Ninja pet makes thieving 100% more successful. (Not 100% successful)"},
- {"pet vorago", "vorago pet", "Vorago Pet has a 10% chance of doubling your max hit, next hit."},
- {"pet corp", "corp pet", "corporeal pet", "corporeal beast pet",
- "Corporeal Pet has a 10% chance to reduce next damage taken by 50%."},
- {"pet prestige", "prestige pet", "p pet",
- "Prestige Pet has a 10% chance to do maximum damage (::maxhit) next hit."},
- {"pet td", "pet tormented", "tormented pet", "tormented demon pet", "td pet", "tds pet",
- "Tormented Demon Pet gives 15% DRB towards Tormented Demons."},
- {"pet pika", "pikachu pet", "pika pet",
- "Pikachu pet gives 10% DRB, if you're under 5,000 NPC Kills, 5% otherwise."},
- {"pet raic", "raichu pet", "raic pet",
- "Raichu pet gives 10% DRB if NPC Kills < 5k, 7% DRB if NPC Kills < 10k, 5% otherwise."},
- {"vet'ion pet", "pet vet", "vetion pet",
- "Vet'ion pet makes special recover 2 times as fast as usual."},
- {"celestial pet", "pet cel", "celes pet", "celest pet", "celestial dragon pet",
- "celestial dragon (pet)", "Celestial Pet increases experience gained by Bone Crusher by 2x."},
- {"warped terrorbird pet", "warped pet", "terrorbird pet",
- "Warped Terrorbird pet cuts all prayer drainage in half."},
- {"veteran", "To obtain the veteran rank, you need an account 9+ months old & 30+ days playtime."},
- {"hell key", "hell chest",
- "Hell keys are used to open Hell Chests which are also dropped by monsters."},
- {"rare drop", "Type '::raredrops NPC NAME' to check rare drops of an NPC."},
- {"drop potential", "Type '::thread Drop Potential' to learn more about Drop Potential."},
- {"imagination", "You're gonna need that... lmfao. Sad."},
- {"price c", "check price", "price of", "how much are", "how much is",
- "Type '::pc NAME' or right click an item to check its price."},
- {"tired", "bored", "You're not tired/bored man the FUCK up."},
- {"server is nice", "server is cool", "server is awesome", "server is great",
- "The server loves you very much."},
- {"max skill", "The max skill level is 125."},
- {"ice diamond", "Ice diamond is used to fix a Lucky Ring of Life [Damaged]"},
- {"guardian", "Talk to Aggressive Mage at home to start the Guardian Assault/Resistance"},
- {"immortal", "Type ::thread topic 3017 to learn about Immortal Band/Charm"},
- {"req", "Type ::req to show you the list of Requirements."},
- {"drop Catcher", "Type ::thread topic 2557 to learn about Drop Catchers."},
- {"buffs", "Buffs come from Admin+, click the icon to view benefits."},
- {"gear", "Type ::thread topic 2930 for the Gear Guide."},
- {"start", "Type ::thread topic 3012 for the Starter Guide."},
- {"minigame", "Type ::thread topic 2902 for the Korasi Minigame."},
- {"trophy", "Talk to Mr.Trophy in varrock to claim trophies."},
- {"milestone", "King Milestone is located in varrock, trade him required pieces."},
- {"pet", "Type ::thread topic 1977 for the Pet Effect Guide."},
- {"ss", "Type ::thread topic 1444 for the Spirit Shield Effects guide."},
- {"attendance", "Talk to king milestone to learn about Attendance."},
- {"drop potential", "Type ::thread topic 1449 to learn about Drop Potential."},
- {"auction", "The auctioneer is loacted north east at home."},
- {"vote", "Type ::vote to vote, and ::redeem to claim your votes."},
- {"thread", "Type ::thread topic #### to open a thread "},
- {"benefits", "Type ::thread donor benefits to view Donator benefits."},
- {"staff", "feedback", "leave your staff feedback by typing ::thread topic 3109"}
- };
- keyWords:
- for (int i = 0; i < keyWords.length; i++)
- for (int j = 0; j < keyWords[i].length - 1; j++)
- if (text.indexOf(keyWords[i][j]) > -1) {
- c.sendMessage("Alert##Yell Assistance##" + keyWords[i][keyWords[i].length - 1] + "##250");
- break keyWords;
- }
- for (String inapporpriate : Config.inappropriate)
- if (text.toLowerCase().contains(inapporpriate))
- c.sendMessage(
- "Alert##Yell Violation##Please refrain from using: '" + inapporpriate + "' in yell.##250");
- }
- @NotNull
- @Override
- public List<Command> execute() {
- return Arrays.asList(new Command("yell", "Yell command") {
- @Override
- public void execute(@NotNull Player player, @NotNull CommandEntry command) {
- try {
- if (command.getArguments().length() < 1)
- return;
- final String text = command.getArguments();
- if (!canYell(player, text))
- return;
- player.YellTimer = System.currentTimeMillis();
- displayAlert(player, text);
- String yellColor = getYellColor(player);
- String yellRank = player.getRights().toString();
- if (player.getDisplayName().equalsIgnoreCase("moon")) {
- yellRank = "Administrator";
- }
- if (!player.getRights().isStaff() || player.getRights().isSuper())
- if (player.getDonatorRights().isDonator())
- if (player.getDonatorRights().isSuperiorOrEqual(DonatorRights.SPONSOR)) {
- if (!player.customYellTag.equalsIgnoreCase("Default Tag")
- && !player.customYellTag.isEmpty())
- yellRank = player.customYellTag;
- else
- yellRank = player.getDonatorRights().toString();
- } else
- yellRank = player.getDonatorRights().toString();
- yellRank = yellRank.replaceAll("ADMINISTRATOR", "Admin").replaceAll("MODERATOR", "Mod")
- .replaceAll("EXTREME", "E").replaceAll("LEGENDARY", "L")
- .replaceAll("SUPER", "S").replaceAll("DIVINE", "D");
- boolean displayExtras = player.getSettings().isEnabled(PlayerSetting.DISPLAY_YELL_EXTRAS);
- boolean displayLevel = player.getSettings().isEnabled(PlayerSetting.DISPLAY_YELL_LEVEL);
- String yellExtras = !displayExtras ? ""
- : (player.getNpcKills(-1) > 1000
- ? !displayLevel ? "[" + Misc.format(player.getNpcKills(-1)) + " KC]"
- : "[Level " + player.getNpcKills(-1) / 1000 + "]"
- : "") + (player.prestige > 0 ? "[P" + player.prestige + "]" : "");
- String yellTitle = player.getCrownsAsString() + yellExtras
- + (!yellRank.isEmpty() ? "[" + Misc.formatString(yellRank) + "]" : "");
- String yellMessage = modifiedYell(player, text, false);
- if (ReactionBot.isRunning()
- && ReactionBot.getString().startsWith("bot")
- && command.getArguments().startsWith("bot")) {
- ReactionBot.rewardPlayer(player, command.getArguments());
- }
- World.getPlayerStream().filter(p -> canReceiveYell(p, player))
- .forEach(i -> {
- String title = yellTitle;
- if (!i.getAttribute("toggleyelltitle", false)) {
- title = "[" + player.getCrownsAsString() + "]";
- }
- i.getPacketSender().sendYell(
- (i.getAttribute("toggleyellcolor", true) ? yellColor : "") + title,
- Misc.formatString(player.getDisplayName()),
- yellMessage);
- });
- if (!Config.limitedDiscord) {
- String discordMessage = modifiedYell(player, text, true);
- ImagineBot.sendMessage(player.getDisplayName(), discordMessage, ImagineBot.Type.YELL);
- }
- player.getAttributes().set("discord_yell", false);
- } catch (Exception e) {
- e.printStackTrace();
- }
- }
- });
- }
- private String getYellColor(Player player) {
- switch (player.getRights()) {
- // case OWNER:
- // return "<shad=FF90DB>";
- case ADMINISTRATOR:
- return "<shad=FF7373>";
- case MODERATOR:
- return "<shad=00C5FF>";
- case SUPPORT:
- return "<shad=48AEFF>";
- default:
- return player.yellColor;
- }
- }
- private String modifiedYell(@NotNull Player c, String text, boolean discord) {
- text = text.toLowerCase();
- if (discord) {
- for (String bad : BotConfigurations.PROHIBITED_WORDS) {
- text = text.replaceAll(bad, "");
- }
- for (Player player : World.getPlayers()) {
- if (player != null) {
- if (text.indexOf(player.getDisplayName().toLowerCase()) > -1
- && player.getAttributes().get("discord_user") != null
- && !((String) player.getAttributes().get("discord_user")).isEmpty()) {
- if (player.getAttributes().get("discord_user") == null)
- break;
- if (ImagineBot.getApi()
- .getUsersByName(((String) player.getAttributes().get("discord_user")).substring(
- 0, ((String) player.getAttributes().get("discord_user")).indexOf("#")),
- true).size() > 0)
- text = text.replaceAll("@" + player.getDisplayName().toLowerCase(),
- ImagineBot.getApi()
- .getUsersByName(((String) player.getAttributes().get("discord_user")).substring(
- 0, ((String) player.getAttributes().get("discord_user")).indexOf("#")),
- true)
- .get(0).getAsMention());
- }
- }
- }
- return text;
- }
- String[] names = new String[5];
- int name = 0;
- boolean start = false;
- try {
- players:
- for (int j = 0; j < World.getPlayers().capacity(); j++)
- if (World.getPlayer(j) != null)
- if (text.toLowerCase().indexOf(World.getPlayer(j).getDisplayName().toLowerCase()) > -1) {
- int index = text.toLowerCase().indexOf(World.getPlayer(j).getDisplayName().toLowerCase());
- if (index == 0 || !text.substring(index - 1, index).equalsIgnoreCase("@"))
- break;
- else {
- text = text.split("@")[0] + text.split("@")[1];
- index--;
- }
- if (index == 0)
- start = true;
- int length = World.getPlayer(j).getDisplayName().toLowerCase().length();
- if (index > 0 && text.charAt(index - 1) != ' ' || index + length != text.toLowerCase().length()
- && text.toLowerCase().charAt(index + length) != ' '
- && text.toLowerCase().substring(index + length, index + length + 1)
- .matches("[a-zA-Z]+(?:'[a-zA-Z]+)*"))
- continue;
- names[name] = World.getPlayer(j).getDisplayName().toLowerCase();
- name++;
- if (World.getPlayer(j) != c)
- World.getPlayer(j).sendMessage(
- "<col=255>" + Misc.formatString(c.getDisplayName()) + " said your name in Yell.");
- break players;
- }
- } catch (Exception e) {
- e.printStackTrace();
- }
- text = Misc.optimizeText(text);
- if (start)
- text = text.substring(0, 1).toLowerCase() + text.substring(1);
- for (String name2 : names) {
- if (name2 == null)
- continue;
- if (name2.length() < 1)
- continue;
- text = text.replace(name2, "'" + Misc.formatString(name2) + "'");
- }
- if (text.indexOf(":") > 0) {
- String[] parts = text.split(":");
- text = "";
- for (int p = 0; p < parts.length; p++) {
- if (p != 0)
- parts[p] = Misc.optimizeText(parts[p]);
- text += parts[p] + (p != parts.length - 1 ? ":" : "");
- }
- }
- if (text.indexOf("`") > -1) {
- text += " ";
- for (int z = 0; z < text.length(); z++)
- if (text.charAt(z) == '`') {
- String s1 = text.substring(z + 1, z + 2).toUpperCase();
- text = text.substring(0, z) + s1 + text.substring(z + 2);
- }
- }
- if (text.toLowerCase().indexOf("ree") > -1) {
- String[] words = text.split(" ");
- for (String word : words) {
- if (word.toLowerCase().startsWith("ree") || word.toLowerCase().contains("reee"))
- text = text.replaceAll(word, "");
- }
- }
- return text;
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement