RuneHive-Game
Loading...
Searching...
No Matches
com.runehive.util.Utility Class Reference

Handles miscellaneous methods. More...

Static Public Member Functions

static String bigDaddyTime (long period)
static String capitalizeSentence (final String string)
 Capitalize each letter after .
static boolean checkRequirements (Player player, int[] requirements, String action)
static String convertWord (int amount)
 Converts an integer into words.
static Position findAccessableTile (Interactable source)
static Position findBestInside (Interactable source, Interactable target)
static void fixInsidePosition (Mob source, Interactable target)
static String formatDigits (final double amount)
 Formats digits for doubles.
static String formatDigits (final int amount)
 Formats digits for integers.
static String formatDigits (final long amount)
 Formats digits for longs.
static String formatEnum (final String string)
 Formats name of enum.
static String formatName (final String input)
static String formatPrice (final long amount)
 Formats a price for longs.
static String formatText (String s)
static String getAOrAn (String nextWord)
 A or an.
static Position[] getBoundaries (Interactable interactable)
static List< Object > getClassesInDirectory (String directory)
 Gets all of the classes in a directory.
static int getCurrentDay ()
static String getDate ()
 Gets the date of server.
static Position getDelta (Interactable source, Interactable target)
static Position getDelta (Position source, int sourceWidth, int sourceLength, Position target, int targetWidth, int targetLength)
static Position getDelta (Position source, Position target)
static int getDistance (Interactable source, Interactable target)
static int getDistance (Interactable source, Position target)
static int getDistance (Position source, int sourceWidth, int sourceLength, Position target, int targetWidth, int targetLength)
static Position[] getInnerBoundaries (Interactable interactable)
static Position[] getInnerBoundaries (Position position, int width, int length)
static double getPercentageAmount (int progress, int total)
 Gets a percentage amount.
static String getSimpleDate ()
 Gets the date of server.
static int getStarters (String host)
static List< String > getSubDirectories (Class<?> clazz)
 Gets all of the sub directories of a folder.
static String getTime ()
 Gets the current server time and formats it.
static String getTime (int ticks)
 Gets a basic time based off seconds.
static String getTime (long period)
 Gets the time based off a long.
static String getUptime ()
 Gets the current uptime of server and formats it.
static final boolean goodDistance (int objectX, int objectY, int playerX, int playerY, int distance)
static long hash (String input)
static boolean hasOneOutOf (double chance)
static boolean inRange (int absX, int absY, int size, int targetX, int targetY, int targetSize, int distance)
static boolean inRange (Interactable source, Interactable target, int distance)
static boolean inside (Interactable source, Interactable target)
static boolean inside (Interactable source, Position target)
static boolean inside (Position source, int sourceWidth, int sourceLength, Position target, int targetWidth, int targetLength)
static boolean isLarger (Interactable source, Interactable other)
static boolean isRegionChange (Position position, Position region)
static String longToString (long l)
static int min (int... values)
static long nameToLong (String text)
 Converts the first 12 characters in a string of text to a hash.
static int random (int bound)
static int random (int lowerBound, int upperBound)
static int random (int lowerBound, int upperBound, boolean inclusive)
static< T > T randomElement (Collection< T > collection)
 Picks a random element out of any array type.
static int randomElement (int[] array)
 Picks a random element out of any array type.
static< T > T randomElement (List< T > list)
 Picks a random element out of any list type.
static< T > T randomElement (T[] array)
 Picks a random element out of any array type.
static String rank (final String string)
 Formats the player name.
static boolean setStarter (Player player)
static int[] shuffleArray (int[] array)
static long stringToLong (String string)
static boolean within (Interactable source, Interactable target, int distance)
static boolean within (Position source, int sourceWidth, int sourceLength, Position target, int targetWidth, int targetLength, int distance)
static boolean within (Position source, Position target, int distance)
static boolean withinDistance (Interactable source, Interactable target, int radius)
static boolean withinDistance (Interactable source, Position target, int radius)
static boolean withinOctal (Interactable source, Interactable target, int distance)
static boolean withinOctal (Position source, int sourceWidth, int sourceLength, Position target, int targetWidth, int targetLength, int distance)
static boolean withinViewingDistance (Interactable source, Interactable target, int radius)

Static Private Attributes

static final Random RANDOM = new Random(System.currentTimeMillis())
 Random instance, used to generate pseudo-random primitive types.
static final char[] VALID_CHARS = {'_', 'a', 'b', 'c', 'd', 'e', 'f', 'g', 'h', 'i', 'j', 'k', 'l', 'm', 'n', 'o', 'p', 'q', 'r', 's', 't', 'u', 'v', 'w', 'x', 'y', 'z', '0', '1', '2', '3', '4', '5', '6', '7', '8', '9', '/'}
 Array of all valid characters.

Detailed Description

Handles miscellaneous methods.

Author
Daniel

Definition at line 27 of file Utility.java.

Member Function Documentation

◆ bigDaddyTime()

String com.runehive.util.Utility.bigDaddyTime ( long period)
static

Definition at line 150 of file Utility.java.

150 {
151 return new SimpleDateFormat("HH:mm:ss").format(period);
152 }

◆ capitalizeSentence()

String com.runehive.util.Utility.capitalizeSentence ( final String string)
static

Capitalize each letter after .

Definition at line 99 of file Utility.java.

99 {
100 int pos = 0;
101 boolean capitalize = true;
102 StringBuilder sb = new StringBuilder(string);
103 while (pos < sb.length()) {
104 if (sb.charAt(pos) == '.') {
105 capitalize = true;
106 } else if (capitalize && !Character.isWhitespace(sb.charAt(pos))) {
107 sb.setCharAt(pos, Character.toUpperCase(sb.charAt(pos)));
108 capitalize = false;
109 }
110 pos++;
111 }
112 return sb.toString();
113 }

Referenced by com.runehive.util.tools.wiki.impl.ItemDefParser.format(), formatEnum(), com.runehive.content.skill.guides.SkillGuides.openInterface(), com.runehive.game.world.World.sendBroadcast(), com.runehive.content.gambling.GambleManager.sendRequest(), com.runehive.game.world.entity.skill.SkillData.toString(), and com.runehive.content.Yell.yell().

Here is the caller graph for this function:

◆ checkRequirements()

boolean com.runehive.util.Utility.checkRequirements ( Player player,
int[] requirements,
String action )
static

Definition at line 807 of file Utility.java.

807 {
808 boolean can = true;
809 for (int index = 0; index < requirements.length; index++) {
810 int level = player.skills.getMaxLevel(index);
811 int required = requirements[index];
812
813 if (level < required) {
814 player.send(new SendMessage("You need a level of " + required + " " + Skill.getName(index) + " to " + action));
815 can = false;
816 }
817 }
818 return can;
819 }
val index

References com.runehive.game.world.entity.skill.SkillManager.getMaxLevel(), com.runehive.game.world.entity.skill.Skill.getName(), com.runehive.game.world.entity.mob.player.Player.send(), and com.runehive.game.world.entity.mob.Mob.skills.

Referenced by com.runehive.game.world.items.containers.equipment.Equipment.equip().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ convertWord()

String com.runehive.util.Utility.convertWord ( int amount)
static

Converts an integer into words.

Definition at line 136 of file Utility.java.

136 {
137 return Words.getInstance(amount).getNumberInWords();
138 }

References com.runehive.util.Words.getInstance(), and com.runehive.util.Words.getNumberInWords().

Referenced by com.runehive.game.world.entity.mob.player.PlayerAssistant.useROW().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ findAccessableTile()

Position com.runehive.util.Utility.findAccessableTile ( Interactable source)
static

Definition at line 478 of file Utility.java.

478 {
479 Position found = null;
480 Position[] positions = getBoundaries(source);
481
482 for (Position next : positions) {
483 Direction direction = Direction.getDirection(source.getPosition(), next);
484
485 if (inside(next, 0, 0, source.getPosition(), source.width(), source.length())) {
486 continue;
487 }
488
489 if (TraversalMap.isTraversable(next, direction, false)) {
490 found = next;
491 break;
492 }
493 }
494
495 return found;
496 }

References getBoundaries(), com.runehive.game.world.entity.mob.Direction.getDirection(), com.runehive.game.world.Interactable.getPosition(), inside(), com.runehive.game.world.pathfinding.TraversalMap.isTraversable(), com.runehive.game.world.Interactable.length(), and com.runehive.game.world.Interactable.width().

Referenced by com.runehive.content.pet.Pets.onObtain(), and com.runehive.content.pet.Pets.onSpawn().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ findBestInside()

Position com.runehive.util.Utility.findBestInside ( Interactable source,
Interactable target )
static

Definition at line 498 of file Utility.java.

498 {
499 if (target.width() <= 1 || target.length() <= 1) {
500 return target.getPosition();
501 }
502
503 int dx, dy, dist = Integer.MAX_VALUE;
504 Position best = source.getPosition();
505
506 for (int x = 0; x < target.width(); x++) {
507 Position boundary = target.getPosition().transform(x, 0);
508 int distance = getDistance(source, boundary);
509
510 if (dist > distance) {
511 dist = distance;
512 best = boundary;
513 }
514
515 boundary = target.getPosition().transform(x, target.length() - 1);
516 distance = getDistance(source, boundary);
517
518 if (dist > distance) {
519 dist = distance;
520 best = boundary;
521 }
522 }
523
524 for (int y = 0; y < target.length(); y++) {
525 Position boundary = target.getPosition().transform(0, y);
526 int distance = getDistance(source, boundary);
527
528 if (dist > distance) {
529 dist = distance;
530 best = boundary;
531 }
532
533 boundary = target.getPosition().transform(target.width() - 1, y);
534 distance = getDistance(source, boundary);
535
536 if (dist > distance) {
537 dist = distance;
538 best = boundary;
539 }
540 }
541
542 if (best.equals(source.getPosition())) {
543 return source.getPosition();
544 }
545
546 Direction direction = Direction.getDirection(source.getPosition(), best);
547 Position sourceTopRight = source.getPosition().transform(source.width() - 1, source.length() - 1, 0);
548
549 if (source.getX() > best.getX()) {
550 dx = best.getX() - source.getX();
551 } else if (sourceTopRight.getX() < best.getX()) {
552 dx = best.getX() - sourceTopRight.getX();
553 } else {
554 dx = direction.getDirectionX();
555 }
556 if (source.getY() > best.getY()) {
557 dy = best.getY() - source.getY();
558 } else if (sourceTopRight.getY() < best.getY()) {
559 dy = best.getY() - sourceTopRight.getY();
560 } else {
561 dy = direction.getDirectionY();
562 }
563
564 return source.getPosition().transform(dx, dy);
565 }

References com.runehive.game.world.position.Position.equals(), com.runehive.game.world.entity.mob.Direction.getDirection(), com.runehive.game.world.entity.mob.Direction.getDirectionX(), com.runehive.game.world.entity.mob.Direction.getDirectionY(), getDistance(), com.runehive.game.world.Interactable.getPosition(), com.runehive.game.world.Interactable.getX(), com.runehive.game.world.position.Position.getX(), com.runehive.game.world.Interactable.getY(), com.runehive.game.world.position.Position.getY(), com.runehive.game.world.Interactable.length(), com.runehive.game.world.position.Position.transform(), and com.runehive.game.world.Interactable.width().

Referenced by com.runehive.game.world.pathfinding.path.impl.SimplePathFinder.addWalks(), com.runehive.game.world.pathfinding.path.SimplePathChecker.checkLine(), com.runehive.game.world.pathfinding.path.SimplePathChecker.checkProjectile(), com.runehive.game.world.pathfinding.path.impl.DijkstraPathFinder.find(), com.runehive.game.world.entity.mob.movement.waypoint.WalkToWaypoint.onDestination(), com.runehive.game.world.entity.combat.strategy.npc.boss.Callisto.Roar.start(), com.runehive.game.world.entity.combat.strategy.npc.boss.magearena.Derwen.LightingRain.start(), and com.runehive.game.world.entity.combat.strategy.npc.boss.magearena.Justiciar.LightingRain.start().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ fixInsidePosition()

void com.runehive.util.Utility.fixInsidePosition ( Mob source,
Interactable target )
static

Definition at line 567 of file Utility.java.

567 {
568 if (source.movement.needsPlacement()) return;
569
570 List<Position> boundaries = new LinkedList<>();
571 Map<Position, LinkedList<Position>> paths = new HashMap<>();
572 Position cur = source.getPosition();
573
574 for (Position position : getBoundaries(target)) {
575 Position delta = getDelta(target.getPosition(), position);
576 int dx = Integer.signum(delta.getX()), dy = Integer.signum(delta.getY());
577 Direction direction = Direction.getDirection(dx, dy);
578
579 if (direction == Direction.NONE)
580 continue;
581
582 while (inside(cur, source.width(), source.length(), target.getPosition(), target.width(), target.length())) {
583 if (!TraversalMap.isTraversable(cur, direction, source.width())) {
584 break;
585 }
586
587 cur = cur.transform(direction.getFaceLocation());
588 LinkedList<Position> list = paths.computeIfAbsent(position, pos -> {
589 boundaries.add(position);
590 return new LinkedList<>();
591 });
592
593 list.add(cur);
594 paths.put(position, list);
595 }
596 }
597
598 if (boundaries.isEmpty()) return;
599
600 source.setFixingInside(true);
601 Position random = boundaries.get(0);//RandomUtils.random(boundaries);
602 source.movement.addPath(new Path(paths.get(random)));
603 }

References com.runehive.game.world.entity.mob.movement.Movement.addPath(), getBoundaries(), getDelta(), com.runehive.game.world.entity.mob.Direction.getDirection(), com.runehive.game.world.entity.mob.Direction.getFaceLocation(), com.runehive.game.world.entity.Entity.getPosition(), com.runehive.game.world.Interactable.getPosition(), com.runehive.game.world.position.Position.getX(), com.runehive.game.world.position.Position.getY(), inside(), com.runehive.game.world.pathfinding.TraversalMap.isTraversable(), com.runehive.game.world.entity.Entity.length, com.runehive.game.world.Interactable.length(), com.runehive.game.world.entity.mob.Mob.movement, com.runehive.game.world.entity.mob.movement.Movement.needsPlacement(), com.runehive.game.world.entity.mob.Direction.NONE, random(), com.runehive.game.world.entity.mob.Mob.setFixingInside(), com.runehive.game.world.position.Position.transform(), com.runehive.game.world.entity.Entity.width, and com.runehive.game.world.Interactable.width().

Referenced by com.runehive.game.world.entity.mob.movement.waypoint.Waypoint.execute().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ formatDigits() [1/3]

String com.runehive.util.Utility.formatDigits ( final double amount)
static

Formats digits for doubles.

Definition at line 51 of file Utility.java.

51 {
52 return NumberFormat.getInstance().format(amount);
53 }

◆ formatDigits() [2/3]

String com.runehive.util.Utility.formatDigits ( final int amount)
static

Formats digits for integers.

Definition at line 41 of file Utility.java.

41 {
42 return NumberFormat.getInstance().format(amount);
43 }

Referenced by com.runehive.content.clanchannel.channel.ClanChannel.activateAchievement(), com.runehive.game.world.entity.mob.player.PlayerAssistant.activateSkilling(), com.runehive.content.clanchannel.channel.ClanChannel.activateTask(), com.runehive.game.world.items.containers.bank.BankVault.add(), com.runehive.content.clanchannel.channel.ClanChannel.addExperience(), com.runehive.content.combat.Killstreak.announce(), com.runehive.content.triviabot.TriviaBot.answered(), com.runehive.content.tradingpost.TradingPost.buyingDialogueOptions(), com.runehive.content.pet.Pets.buyInsurance(), com.runehive.content.itemaction.impl.MagmaHelm.charge(), com.runehive.content.itemaction.impl.SerpentineHelm.charge(), com.runehive.content.itemaction.impl.TanzaniteHelm.charge(), com.runehive.content.itemaction.impl.ToxicBlowpipe.charge(), com.runehive.content.itemaction.impl.CelestialRing.check(), com.runehive.content.itemaction.impl.CrawsBow.check(), com.runehive.content.itemaction.impl.ThammaronsSceptre.check(), com.runehive.content.itemaction.impl.TridentOfTheSeas.check(), com.runehive.content.itemaction.impl.TridentOfTheSwamp.check(), com.runehive.content.itemaction.impl.ViggorasChainmace.check(), com.runehive.content.pet.Pets.claimLostPets(), com.runehive.content.dialogue.impl.ClanmasterDialogue.clanLevel(), com.runehive.content.dialogue.impl.ClanmasterDialogue.clanTask(), com.runehive.content.WellOfGoodwill.contribute(), com.runehive.content.skill.impl.magic.RunePouch.deposit(), com.runehive.game.world.items.containers.bank.BankVault.deposit(), com.runehive.content.DropDisplay.display(), com.runehive.content.skill.impl.construction.BuildableInterface.display(), com.runehive.game.world.entity.mob.npc.drop.NpcDropManager.drop(), com.runehive.content.combat.Killstreak.end(), com.runehive.content.dialogue.impl.VoteDialogue.exchange(), com.runehive.content.skill.impl.thieving.Thieving.exchange(), com.runehive.content.activity.impl.barrows.BarrowsUtility.generateRewards(), com.runehive.content.clanchannel.content.ClanViewer.getDetails(), com.runehive.content.clanchannel.content.ClanViewer.getProfile(), com.runehive.content.store.currency.CurrencyType.getValue(), com.runehive.net.packet.in.ExaminePacketListener.handleInterfaceExamine(), com.runehive.game.world.entity.mob.npc.drop.NpcDropManager.handleMessages(), com.runehive.content.itemaction.impl.ToxicBlowpipe.load(), com.runehive.content.store.impl.PersonalStore.modify(), com.runehive.content.skill.impl.slayer.SlayerOfferings.offer(), com.runehive.game.world.items.containers.impl.LootingBag.onRefresh(), com.runehive.game.world.items.containers.pricechecker.PriceChecker.onRefresh(), com.runehive.content.ActivityLogger.open(), com.runehive.content.ItemsKeptOnDeath.open(), com.runehive.content.RoyaltyProgram.open(), com.runehive.content.WellOfGoodwill.open(), com.runehive.game.world.items.containers.bank.BankVault.open(), com.runehive.content.pet.Pets.openInsurance(), com.runehive.game.world.items.containers.equipment.Equipment.openInterface(), com.runehive.content.pet.Pets.openLostPets(), com.runehive.content.store.impl.PersonalStore.openMenu(), com.runehive.content.donators.Donation.redeem(), com.runehive.content.skill.impl.slayer.SlayerTab.refresh(), com.runehive.content.activity.impl.duelarena.DuelArenaActivity.reward(), com.runehive.content.combat.Killstreak.reward(), com.runehive.game.world.items.containers.pricechecker.PriceChecker.search(), com.runehive.game.world.items.containers.pricechecker.PriceChecker.searchItem(), com.runehive.content.dialogue.impl.WellOfGoodwillDialogue.sendDialogues(), com.runehive.content.tradingpost.TradingPost.sendItemHistoryData(), com.runehive.content.store.Store.sendPurchaseValue(), com.runehive.content.store.Store.sendSellValue(), com.runehive.content.clanchannel.channel.ClanChannel.splitLoot(), com.runehive.content.skill.impl.slayer.Slayer.store(), com.runehive.content.ProfileViewer.string(), com.runehive.content.itemaction.impl.MagmaHelm.uncharge(), com.runehive.content.itemaction.impl.SerpentineHelm.uncharge(), com.runehive.content.itemaction.impl.TanzaniteHelm.uncharge(), com.runehive.content.itemaction.impl.ToxicBlowpipe.uncharge(), com.runehive.content.activity.impl.fightcaves.FightCaves.update(), com.runehive.content.activity.inferno.Inferno.update(), com.runehive.content.tradingpost.TradingPost.updateBuyingPageWidgets(), com.runehive.game.world.entity.mob.player.exchange.trade.TradeSession.updateOfferComponents(), com.runehive.content.tradingpost.TradingPost.updatePriceStrings(), com.runehive.game.world.items.containers.bank.BankVault.value(), and com.runehive.game.world.items.containers.bank.BankVault.withdraw().

Here is the caller graph for this function:

◆ formatDigits() [3/3]

String com.runehive.util.Utility.formatDigits ( final long amount)
static

Formats digits for longs.

Definition at line 46 of file Utility.java.

46 {
47 return NumberFormat.getInstance().format(amount);
48 }

◆ formatEnum()

String com.runehive.util.Utility.formatEnum ( final String string)
static

◆ formatName()

String com.runehive.util.Utility.formatName ( final String input)
static

Definition at line 645 of file Utility.java.

645 {
646 if(input == null) {
647 return null;
648 }
649 //Open chagpt
650 StringBuilder formattedName = new StringBuilder();
651
652 // Split the input string by spaces
653 String[] words = input.trim().split(" ");
654
655 // Capitalize the first letter of each word
656 for (String word : words) {
657 if (!word.isEmpty()) {
658 // Capitalize the first letter
659 char firstLetter = Character.toUpperCase(word.charAt(0));
660 formattedName.append(firstLetter);
661
662 // Append the remaining letters
663 if (word.length() > 1) {
664 formattedName.append(word.substring(1));
665 }
666
667 // Append a space
668 formattedName.append(" ");
669 }
670 }
671
672 // Remove the trailing space and return the formatted name
673 return formattedName.toString().trim();
674 }

Referenced by com.runehive.game.world.entity.mob.player.relations.PlayerRelation.addFriend(), com.runehive.game.world.entity.mob.player.relations.PlayerRelation.addIgnore(), com.runehive.content.dialogue.DialogueFactory.appendKeywords(), com.runehive.game.world.entity.combat.CombatUtil.canAttack(), com.runehive.content.store.impl.PersonalStore.changeName(), com.runehive.content.clanchannel.channel.ClanChannelHandler.connected(), com.runehive.game.world.entity.mob.player.relations.PlayerRelation.deleteFriend(), com.runehive.game.world.entity.mob.player.relations.PlayerRelation.deleteIgnore(), com.runehive.content.activity.record.PlayerRecord.display(), com.runehive.content.skill.impl.construction.House.enter(), com.runehive.content.clanchannel.content.ClanViewer.getDetails(), com.runehive.game.world.entity.mob.player.Player.getName(), com.runehive.content.itemaction.impl.DrillDemonBox.inventory(), com.runehive.content.itemaction.impl.MimeBox.inventory(), com.runehive.content.clanchannel.content.ClanViewer.open(), com.runehive.content.tittle.TitleManager.refresh(), com.runehive.game.world.entity.mob.player.Player.register(), com.runehive.game.world.entity.mob.player.requests.RequestManager.request(), com.runehive.content.famehall.FameHandler.search(), com.runehive.content.dialogue.DialogueFactory.sendPlayerChat(), com.runehive.content.clanchannel.channel.ClanChannel.setName(), com.runehive.content.clanchannel.channel.ClanChannel.setSlogan(), com.runehive.game.world.entity.combat.strategy.npc.boss.ChaosFanatic.RainAttack.start(), com.runehive.content.activity.impl.duelarena.DuelArenaActivity.DuelPanel.update(), com.runehive.game.world.entity.mob.player.exchange.trade.TradeSession.updateMainComponents(), com.runehive.content.clanchannel.channel.ClanChannelHandler.updateMemberList(), com.runehive.game.world.entity.mob.player.exchange.duel.StakeSession.updateOfferComponents(), and com.runehive.game.world.entity.mob.player.exchange.trade.TradeSession.updateOfferComponents().

Here is the caller graph for this function:

◆ formatPrice()

String com.runehive.util.Utility.formatPrice ( final long amount)
static

Formats a price for longs.

Definition at line 56 of file Utility.java.

56 {
57 if (amount >= 0 && amount < 1_000)
58 return "" + amount;
59 if (amount >= 1_000 && amount < 1_000_000) {
60 return (amount / 1_000) + "K";
61 }
62 if (amount >= 1_000_000 && amount < 1_000_000_000) {
63 return (amount / 1_000_000) + "M";
64 }
65 if (amount >= 1_000_000_000 && amount < Integer.MAX_VALUE) {
66 return (amount / 1_000_000_000) + "B";
67 }
68 return "<col=fc2a2a>Lots!";
69 }

Referenced by com.runehive.content.store.impl.PersonalStore.openMenu(), com.runehive.game.world.items.containers.bank.Bank.sendValue(), com.runehive.content.ProfileViewer.string(), and com.runehive.game.world.items.containers.bank.BankVault.withdraw().

Here is the caller graph for this function:

◆ formatText()

String com.runehive.util.Utility.formatText ( String s)
static

Definition at line 682 of file Utility.java.

682 {
683 for (int i = 0; i < s.length(); i++) {
684 if (i == 0) {
685 s = String.format("%s%s", Character.toUpperCase(s.charAt(0)),
686 s.substring(1));
687 }
688 if (!Character.isLetterOrDigit(s.charAt(i))) {
689 if (i + 1 < s.length()) {
690 s = String.format("%s%s%s", s.subSequence(0, i + 1),
691 Character.toUpperCase(s.charAt(i + 1)),
692 s.substring(i + 2));
693 }
694 }
695 }
696 return s.replace("_", " ");
697 }

Referenced by com.runehive.content.gambling.impl.FlowerPoker.plant().

Here is the caller graph for this function:

◆ getAOrAn()

String com.runehive.util.Utility.getAOrAn ( String nextWord)
static

A or an.

Definition at line 116 of file Utility.java.

116 {
117 String s = "a";
118 char c = nextWord.toUpperCase().charAt(0);
119 if (c == 'A' || c == 'E' || c == 'I' || c == 'O' || c == 'U') {
120 s = "an";
121 }
122 return s;
123 }

Referenced by com.runehive.content.skill.impl.crafting.impl.Glass.blow(), com.runehive.util.parser.old.defs.EquipmentRequirement.canEquip(), com.runehive.content.skill.impl.hunter.net.Netting.canSchedule(), com.runehive.content.skill.impl.crafting.impl.Jewellery.click(), com.runehive.content.skill.impl.herblore.Herblore.clickItem(), com.runehive.content.skill.impl.construction.House.construct(), com.runehive.content.skill.impl.crafting.impl.Glass.craft(), com.runehive.content.skill.impl.crafting.impl.Jewellery.craft(), com.runehive.game.world.entity.mob.npc.drop.NpcDropManager.drop(), com.runehive.game.world.entity.mob.npc.drop.NpcDropManager.handleMessages(), com.runehive.content.skill.impl.fishing.Fishing.hasFishingItems(), com.runehive.content.skill.impl.farming.patches.FarmingPatch.inspect(), com.runehive.content.skill.impl.mining.MiningAction.mine(), com.runehive.content.mysterybox.MysteryBoxEvent.reward(), com.runehive.content.skill.impl.woodcutting.BirdsNest.search(), com.runehive.game.world.entity.skill.SkillManager.showLevelUpInterface(), com.runehive.content.skill.impl.crafting.impl.Spinning.spin(), com.runehive.content.skill.impl.crafting.Crafting.start(), com.runehive.content.skill.impl.fletching.Fletching.start(), com.runehive.content.skill.impl.crafting.impl.Stringing.string(), com.runehive.content.donators.Donation.updateRank(), com.runehive.game.world.entity.skill.SkillManager.updateSkill(), com.runehive.content.skill.impl.crafting.Crafting.useItem(), and com.runehive.content.skill.impl.fletching.Fletching.useItem().

Here is the caller graph for this function:

◆ getBoundaries()

Position[] com.runehive.util.Utility.getBoundaries ( Interactable interactable)
static

Definition at line 605 of file Utility.java.

605 {
606 int nextSlot = 0;
607 int width = interactable.width();
608 int length = interactable.length();
609 Position[] boundaries = new Position[2 * (width + length)];
610 for (int y = 0; y < length + 2; y++) {
611 for (int x = 0; x < width + 2; x++) {
612 int xx = x % (width + 1);
613 int yy = y % (length + 1);
614 if (xx == 0 && yy == 0 || xx != 0 && yy != 0) continue;
615 boundaries[nextSlot++] = interactable.getPosition().transform(x - 1, y - 1, 0);
616 }
617 }
618 return boundaries;
619 }

References com.runehive.game.world.Interactable.getPosition(), com.runehive.game.world.Interactable.length(), com.runehive.game.world.position.Position.transform(), and com.runehive.game.world.Interactable.width().

Referenced by findAccessableTile(), and fixInsidePosition().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ getClassesInDirectory()

List< Object > com.runehive.util.Utility.getClassesInDirectory ( String directory)
static

Gets all of the classes in a directory.

Definition at line 284 of file Utility.java.

284 {
285 List<Object> classes = new LinkedList<>();
286 File dir = new File(directory);
287 if (!dir.exists() || !dir.isDirectory()) {
288 return classes;
289 }
290 try {
291 File[] files = dir.listFiles();
292 if (files == null) {
293 return classes;
294 }
295 for (File f : files) {
296 if (f.isDirectory() || f.getName().contains("$")) {
297 continue;
298 }
299 String domainPath = Utility.class.getProtectionDomain().getCodeSource().getLocation().getPath().replace("/", "\\");
300 String filePath = "\\" + f.getPath();
301 String clazzName = filePath.replace(domainPath, "");
302 clazzName = clazzName.replace("\\", ".");
303 clazzName = clazzName.replace(".class", "");
304 Class<?> clazz = Class.forName(clazzName);
305 Object o = clazz.getDeclaredConstructor().newInstance();
306 classes.add(o);
307 }
308 } catch (ClassNotFoundException | IllegalAccessException | InstantiationException
309 | InvocationTargetException | NoSuchMethodException e) {
310 // e.printStackTrace();
311 }
312 return classes;
313 }

◆ getCurrentDay()

int com.runehive.util.Utility.getCurrentDay ( )
static

Definition at line 891 of file Utility.java.

891 {
892 return Calendar.getInstance().get(Calendar.DAY_OF_YEAR);
893 }

Referenced by com.runehive.content.dailyeffect.DailyEffect.canUse(), and com.runehive.content.dailyeffect.DailyEffect.use().

Here is the caller graph for this function:

◆ getDate()

String com.runehive.util.Utility.getDate ( )
static

Gets the date of server.

Definition at line 126 of file Utility.java.

126 {
127 return new SimpleDateFormat("EE MMM dd yyyy").format(new Date());
128 }

Referenced by com.runehive.content.famehall.FameHandler.activate().

Here is the caller graph for this function:

◆ getDelta() [1/3]

Position com.runehive.util.Utility.getDelta ( Interactable source,
Interactable target )
static

Definition at line 459 of file Utility.java.

459 {
460 return getDelta(source.getPosition(), source.width(), source.length(), target.getPosition(), target.width(), target.length());
461 }

References getDelta(), com.runehive.game.world.Interactable.getPosition(), com.runehive.game.world.Interactable.length(), and com.runehive.game.world.Interactable.width().

Here is the call graph for this function:

◆ getDelta() [2/3]

Position com.runehive.util.Utility.getDelta ( Position source,
int sourceWidth,
int sourceLength,
Position target,
int targetWidth,
int targetLength )
static

Definition at line 421 of file Utility.java.

421 {
422 if (source.getHeight() != target.getHeight()) {
423 return Position.create(Integer.MAX_VALUE, Integer.MAX_VALUE);
424 }
425
426 if (sourceWidth <= 0) sourceWidth = 1;
427 if (sourceLength <= 0) sourceLength = 1;
428 if (targetWidth <= 0) targetWidth = 1;
429 if (targetLength <= 0) targetLength = 1;
430
431 Position sourceTopRight = source.transform(sourceWidth - 1, sourceLength - 1, 0);
432 Position targetTopRight = target.transform(targetWidth - 1, targetLength - 1, 0);
433
434 int dx, dy;
435
436 if (sourceTopRight.getX() < target.getX()) {
437 dx = target.getX() - sourceTopRight.getX();
438 } else if (source.getX() > targetTopRight.getX()) {
439 dx = source.getX() - targetTopRight.getX();
440 } else {
441 dx = 0;
442 }
443
444 if (sourceTopRight.getY() < target.getY()) {
445 dy = target.getY() - sourceTopRight.getY();
446 } else if (source.getY() > targetTopRight.getY()) {
447 dy = source.getY() - targetTopRight.getY();
448 } else {
449 dy = 0;
450 }
451
452 return Position.create(dx, dy);
453 }

References com.runehive.game.world.position.Position.create(), com.runehive.game.world.position.Position.getHeight(), com.runehive.game.world.position.Position.getX(), com.runehive.game.world.position.Position.getY(), and com.runehive.game.world.position.Position.transform().

Referenced by fixInsidePosition(), and getDelta().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ getDelta() [3/3]

Position com.runehive.util.Utility.getDelta ( Position source,
Position target )
static

Definition at line 463 of file Utility.java.

463 {
464 int dx = target.getX() - source.getX();
465 int dy = target.getY() - source.getY();
466 return Position.create(dx, dy);
467 }

References com.runehive.game.world.position.Position.create(), com.runehive.game.world.position.Position.getX(), and com.runehive.game.world.position.Position.getY().

Here is the call graph for this function:

◆ getDistance() [1/3]

int com.runehive.util.Utility.getDistance ( Interactable source,
Interactable target )
static

Definition at line 455 of file Utility.java.

455 {
456 return getDistance(source.getPosition(), source.width(), source.length(), target.getPosition(), target.width(), target.length());
457 }

References getDistance(), com.runehive.game.world.Interactable.getPosition(), com.runehive.game.world.Interactable.length(), and com.runehive.game.world.Interactable.width().

Here is the call graph for this function:

◆ getDistance() [2/3]

int com.runehive.util.Utility.getDistance ( Interactable source,
Position target )
static

Definition at line 363 of file Utility.java.

363 {
364 Position sourceTopRight = source.getPosition().transform(source.width() - 1, source.length() - 1);
365
366 int dx, dy;
367
368 if (sourceTopRight.getX() < target.getX()) {
369 dx = target.getX() - sourceTopRight.getX();
370 } else if (source.getX() > target.getX()) {
371 dx = source.getX() - target.getX();
372 } else {
373 dx = 0;
374 }
375
376 if (sourceTopRight.getY() < target.getY()) {
377 dy = target.getY() - sourceTopRight.getY();
378 } else if (source.getY() > target.getY()) {
379 dy = source.getY() - target.getY();
380 } else {
381 dy = 0;
382 }
383
384 return dx + dy;
385 }

References com.runehive.game.world.Interactable.getPosition(), com.runehive.game.world.Interactable.getX(), com.runehive.game.world.position.Position.getX(), com.runehive.game.world.Interactable.getY(), com.runehive.game.world.position.Position.getY(), com.runehive.game.world.Interactable.length(), com.runehive.game.world.position.Position.transform(), and com.runehive.game.world.Interactable.width().

Referenced by com.runehive.game.world.entity.combat.CombatUtil.areaAction(), com.runehive.game.world.entity.combat.CombatTarget.checkAggression(), com.runehive.game.world.entity.combat.CombatTarget.checkAggression(), com.runehive.game.world.entity.combat.CombatTarget.compare(), findBestInside(), com.runehive.game.world.entity.mob.movement.waypoint.Waypoint.findRoute(), com.runehive.game.world.region.RegionManager.forNearbyPlayer(), com.runehive.game.world.region.RegionManager.forNearbyPlayer(), getDistance(), com.runehive.game.world.position.Position.getManhattanDistance(), com.runehive.game.world.entity.combat.CombatUtil.getOldHitDelay(), com.runehive.game.world.entity.combat.CombatTarget.setTarget(), com.runehive.content.activity.impl.kraken.KrakenActivityListener.withinDistance(), com.runehive.game.world.entity.mob.movement.waypoint.CombatWaypoint.withinDistance(), and com.runehive.game.world.entity.mob.movement.waypoint.Waypoint.withinDistance().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ getDistance() [3/3]

int com.runehive.util.Utility.getDistance ( Position source,
int sourceWidth,
int sourceLength,
Position target,
int targetWidth,
int targetLength )
static

Definition at line 387 of file Utility.java.

387 {
388 if (source.getHeight() != target.getHeight()) {
389 return Integer.MAX_VALUE;
390 }
391
392 if (sourceWidth <= 0) sourceWidth = 1;
393 if (sourceLength <= 0) sourceLength = 1;
394 if (targetWidth <= 0) targetWidth = 1;
395 if (targetLength <= 0) targetLength = 1;
396
397 Position sourceTopRight = source.transform(sourceWidth - 1, sourceLength - 1, 0);
398 Position targetTopRight = target.transform(targetWidth - 1, targetLength - 1, 0);
399
400 int dx, dy;
401
402 if (sourceTopRight.getX() < target.getX()) {
403 dx = target.getX() - sourceTopRight.getX();
404 } else if (source.getX() > targetTopRight.getX()) {
405 dx = source.getX() - targetTopRight.getX();
406 } else {
407 dx = 0;
408 }
409
410 if (sourceTopRight.getY() < target.getY()) {
411 dy = target.getY() - sourceTopRight.getY();
412 } else if (source.getY() > targetTopRight.getY()) {
413 dy = source.getY() - targetTopRight.getY();
414 } else {
415 dy = 0;
416 }
417
418 return dx + dy;
419 }

References com.runehive.game.world.position.Position.getHeight(), com.runehive.game.world.position.Position.getX(), com.runehive.game.world.position.Position.getY(), and com.runehive.game.world.position.Position.transform().

Here is the call graph for this function:

◆ getInnerBoundaries() [1/2]

Position[] com.runehive.util.Utility.getInnerBoundaries ( Interactable interactable)
static

Definition at line 632 of file Utility.java.

632 {
633 int nextSlot = 0;
634 int width = interactable.width();
635 int length = interactable.length();
636 Position[] boundaries = new Position[width * length];
637 for (int y = 0; y < length; y++) {
638 for (int x = 0; x < width; x++) {
639 boundaries[nextSlot++] = interactable.getPosition().transform(x, y, 0);
640 }
641 }
642 return boundaries;
643 }

References com.runehive.game.world.Interactable.getPosition(), com.runehive.game.world.Interactable.length(), com.runehive.game.world.position.Position.transform(), and com.runehive.game.world.Interactable.width().

Here is the call graph for this function:

◆ getInnerBoundaries() [2/2]

Position[] com.runehive.util.Utility.getInnerBoundaries ( Position position,
int width,
int length )
static

Definition at line 621 of file Utility.java.

621 {
622 int nextSlot = 0;
623 Position[] boundaries = new Position[width * length];
624 for (int y = 0; y < length; y++) {
625 for (int x = 0; x < width; x++) {
626 boundaries[nextSlot++] = position.transform(x, y, 0);
627 }
628 }
629 return boundaries;
630 }

References com.runehive.game.world.position.Position.transform().

Referenced by com.runehive.content.pet.Pets.abandon(), com.runehive.game.world.entity.combat.strategy.npc.boss.Vetion.finishIncoming(), com.runehive.content.activity.infernomobs.JalTokJad.hit(), com.runehive.game.world.entity.combat.strategy.npc.boss.scorpia.Scorpia.hit(), com.runehive.content.activity.impl.magearena.MageArena.meteors(), com.runehive.game.world.entity.combat.strategy.npc.boss.Hydra.poisonAttack(), com.runehive.game.world.entity.mob.npc.Npc.register(), com.runehive.content.bloodmoney.BloodMoneyChest.spawn(), com.runehive.content.activity.impl.fightcaves.FightCaves.start(), com.runehive.content.activity.impl.recipefordisaster.RecipeForDisaster.start(), com.runehive.content.activity.inferno.Inferno.start(), com.runehive.game.world.entity.combat.strategy.npc.boss.Cerberus.LavaAttack.start(), and com.runehive.game.world.entity.combat.strategy.npc.boss.Vetion.Magic.start().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ getPercentageAmount()

◆ getSimpleDate()

String com.runehive.util.Utility.getSimpleDate ( )
static

Gets the date of server.

Definition at line 131 of file Utility.java.

131 {
132 return new SimpleDateFormat("yyyy/MM/dd").format(new Date());
133 }

Referenced by com.runehive.content.clanchannel.channel.ClanChannel.create(), com.runehive.content.clanchannel.channel.ClanChannel.establish(), and com.runehive.content.activity.record.GameRecord.GameRecord().

Here is the caller graph for this function:

◆ getStarters()

int com.runehive.util.Utility.getStarters ( String host)
static

Definition at line 825 of file Utility.java.

825 {
826 int amount = 0;
827 try {
828 File file = new File("./data/starters/" + host + ".txt");
829 if (!file.exists()) {
830 return 0;
831 }
832 BufferedReader in = new BufferedReader(new FileReader(file));
833
834 String whatever = in.readLine();
835
836 long max = Long.parseLong(whatever);
837
838 if (max > Integer.MAX_VALUE) {
839 amount = 2;
840 } else {
841 amount = (int) max;
842 }
843
844 in.close();
845 } catch (Exception e) {
846 e.printStackTrace();
847 }
848 return amount;
849 }

Referenced by setStarter().

Here is the caller graph for this function:

◆ getSubDirectories()

List< String > com.runehive.util.Utility.getSubDirectories ( Class<?> clazz)
static

Gets all of the sub directories of a folder.

Definition at line 316 of file Utility.java.

316 {
317 String filePath = clazz.getResource("/" + clazz.getName().replace(".", "/") + ".class").getFile();
318 File file = new File(filePath);
319 File directory = file.getParentFile();
320 List<String> list = new ArrayList<>();
321
322 File[] files = directory.listFiles();
323
324 if (files == null) {
325 return Collections.emptyList();
326 }
327
328 for (File f : files) {
329 if (f.isDirectory()) {
330 list.add(f.getPath());
331 }
332 }
333
334 String[] directories = list.toArray(new String[0]);
335 return Arrays.asList(directories);
336 }

◆ getTime() [1/3]

◆ getTime() [2/3]

String com.runehive.util.Utility.getTime ( int ticks)
static

Gets a basic time based off seconds.

Definition at line 160 of file Utility.java.

160 {
161 long secs = ticks * 3 / 5;
162
163 if (secs < 60) {
164 return "0:" + (secs < 10 ? "0" : "") + secs;
165 }
166
167 long mins = secs / 60;
168 long remainderSecs = secs - (mins * 60);
169 if (mins < 60) {
170 return mins + ":" + (remainderSecs < 10 ? "0" : "") + remainderSecs + "";
171 }
172
173 long hours = mins / 60;
174 long remainderMins = mins - (hours * 60);
175 if (hours < 24) {
176 return hours + "h " + (remainderMins < 10 ? "0" : "") + remainderMins + "m " + (remainderSecs < 10 ? "0" : "") + remainderSecs + "s";
177 }
178
179 long days = hours / 24;
180 long remainderHrs = hours - (days * 24);
181 return days + "d " + (remainderHrs < 10 ? "0" : "") + remainderHrs + "h " + (remainderMins < 10 ? "0" : "") + remainderMins + "m";
182 }

◆ getTime() [3/3]

String com.runehive.util.Utility.getTime ( long period)
static

Gets the time based off a long.

Definition at line 146 of file Utility.java.

146 {
147 return new SimpleDateFormat("m:ss").format(period);
148 }

◆ getUptime()

String com.runehive.util.Utility.getUptime ( )
static

Gets the current uptime of server and formats it.

Definition at line 155 of file Utility.java.

155 {
156 return getTime((int) (RuneHive.UPTIME.elapsedTime() / 600));
157 }

References com.runehive.util.Stopwatch.elapsedTime(), getTime(), and com.runehive.RuneHive.UPTIME.

Here is the call graph for this function:

◆ goodDistance()

final boolean com.runehive.util.Utility.goodDistance ( int objectX,
int objectY,
int playerX,
int playerY,
int distance )
static

Definition at line 903 of file Utility.java.

903 {
904 int deltaX = objectX - playerX;
905 int deltaY = objectY - playerY;
906 int trueDistance = ((int) Math.sqrt(Math.pow(deltaX, 2) + Math.pow(deltaY, 2)));
907 return trueDistance <= distance;
908 }

Referenced by com.runehive.content.wintertodt.Wintertodt.breakBrazier(), com.runehive.content.wintertodt.Wintertodt.doMagicAttack(), and com.runehive.game.world.entity.mob.player.Player.loadRegion().

Here is the caller graph for this function:

◆ hash()

long com.runehive.util.Utility.hash ( String input)
static

Definition at line 217 of file Utility.java.

217 {
218 long hash = 0L;
219 if (input == null) {
220 input = "null";
221 }
222 for (int index = 0; index < input.length() && index < 12; index++) {
223 char key = input.charAt(index);
224 hash *= 37L;
225 if (key >= 'A' && key <= 'Z') {
226 hash += (1 + key) - 65;
227 } else if (key >= 'a' && key <= 'z') {
228 hash += (1 + key) - 97;
229 } else if (key >= '0' && key <= '9') {
230 hash += (27 + key) - 48;
231 }
232 }
233 while (hash % 37L == 0L && hash != 0L) {
234 hash /= 37L;
235 }
236 return hash;
237 }

References hash().

Referenced by com.runehive.net.packet.out.SendPlayerUpdate.appendAppearanceMask(), hash(), and nameToLong().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ hasOneOutOf()

boolean com.runehive.util.Utility.hasOneOutOf ( double chance)
static

Definition at line 257 of file Utility.java.

257 {
258 if (chance < 1) {
259 chance = 0;
260 }
261 chance *= 100.0;
262 return random(1, (int) chance) <= 100;
263 }

References random().

Referenced by com.runehive.game.world.entity.mob.player.PlayerAssistant.activateSkilling(), com.runehive.content.skill.impl.mining.MiningAction.handleCelestialRing(), and com.runehive.game.world.entity.combat.strategy.npc.boss.Hydra.hit().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ inRange() [1/2]

boolean com.runehive.util.Utility.inRange ( int absX,
int absY,
int size,
int targetX,
int targetY,
int targetSize,
int distance )
static

Definition at line 910 of file Utility.java.

910 {
911 if (absX < targetX) {
912 /*
913 * West of target
914 */
915 int closestX = absX + (size - 1);
916 int diffX = targetX - closestX;
917 if (diffX > distance)
918 return false;
919 } else if (absX > targetX) {
920 /*
921 * East of target
922 */
923 int closestTargetX = targetX + (targetSize - 1);
924 int diffX = absX - closestTargetX;
925 if (diffX > distance)
926 return false;
927 }
928 if (absY < targetY) {
929 /*
930 * South of target
931 */
932 int closestY = absY + (size - 1);
933 int diffY = targetY - closestY;
934 return diffY <= distance;
935 } else if (absY > targetY) {
936 /*
937 * North of target
938 */
939 int closestTargetY = targetY + (targetSize - 1);
940 int diffY = absY - closestTargetY;
941 return diffY <= distance;
942 }
943 return true;
944 }

Referenced by inRange(), com.runehive.game.world.entity.combat.strategy.basic.MagicStrategy< T extends Mob >.withinDistance(), com.runehive.game.world.entity.combat.strategy.basic.MeleeStrategy< T extends Mob >.withinDistance(), and com.runehive.game.world.entity.combat.strategy.basic.RangedStrategy< T extends Mob >.withinDistance().

Here is the caller graph for this function:

◆ inRange() [2/2]

boolean com.runehive.util.Utility.inRange ( Interactable source,
Interactable target,
int distance )
static

Definition at line 946 of file Utility.java.

946 {
947 return inRange(source.getX(), source.getY(), source.width(), target.getX(), target.getY(), target.width(), distance);
948 }

References com.runehive.game.world.Interactable.getX(), com.runehive.game.world.Interactable.getY(), inRange(), and com.runehive.game.world.Interactable.width().

Here is the call graph for this function:

◆ inside() [1/3]

boolean com.runehive.util.Utility.inside ( Interactable source,
Interactable target )
static

Definition at line 783 of file Utility.java.

783 {
784 return inside(source.getPosition(), source.width(), source.length(), target.getPosition(), target.width(), target.length());
785 }

References com.runehive.game.world.Interactable.getPosition(), inside(), com.runehive.game.world.Interactable.length(), and com.runehive.game.world.Interactable.width().

Referenced by com.runehive.game.world.entity.combat.Combat< T extends Mob >.checkWithin(), com.runehive.content.activity.impl.zulrah.ZulrahActivity.cloudEffect(), com.runehive.game.world.entity.mob.movement.waypoint.Waypoint.execute(), findAccessableTile(), fixInsidePosition(), inside(), inside(), com.runehive.content.skill.impl.farming.zones.FarmingZone.isViewable(), com.runehive.game.world.region.Region.reachable(), com.runehive.game.world.pathfinding.path.impl.SimplePathFinder.traversable(), and com.runehive.content.skill.impl.farming.patches.FarmingPatch.within().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ inside() [2/3]

boolean com.runehive.util.Utility.inside ( Interactable source,
Position target )
static

Definition at line 787 of file Utility.java.

787 {
788 return inside(source.getPosition(), source.width(), source.length(), target, 1, 1);
789 }

References com.runehive.game.world.Interactable.getPosition(), inside(), com.runehive.game.world.Interactable.length(), and com.runehive.game.world.Interactable.width().

Here is the call graph for this function:

◆ inside() [3/3]

boolean com.runehive.util.Utility.inside ( Position source,
int sourceWidth,
int sourceLength,
Position target,
int targetWidth,
int targetLength )
static

Definition at line 791 of file Utility.java.

791 {
792 if (sourceWidth <= 0) sourceWidth = 1;
793 if (sourceLength <= 0) sourceLength = 1;
794 if (targetWidth <= 0) targetWidth = 1;
795 if (targetLength <= 0) targetLength = 1;
796 Position sourceTopRight = source.transform(sourceWidth - 1, sourceLength - 1, 0);
797 Position targetTopRight = target.transform(targetWidth - 1, targetLength - 1, 0);
798 if (source.equals(target) || sourceTopRight.equals(targetTopRight)) {
799 return true;
800 }
801 if (source.getX() > targetTopRight.getX() || sourceTopRight.getX() < target.getX()) {
802 return false;
803 }
804 return source.getY() <= targetTopRight.getY() && sourceTopRight.getY() >= target.getY();
805 }

References com.runehive.game.world.position.Position.equals(), com.runehive.game.world.position.Position.getX(), com.runehive.game.world.position.Position.getY(), and com.runehive.game.world.position.Position.transform().

Here is the call graph for this function:

◆ isLarger()

boolean com.runehive.util.Utility.isLarger ( Interactable source,
Interactable other )
static

Definition at line 821 of file Utility.java.

821 {
822 return source.width() * source.length() > other.width() * other.length();
823 }

References com.runehive.game.world.Interactable.length(), and com.runehive.game.world.Interactable.width().

Here is the call graph for this function:

◆ isRegionChange()

boolean com.runehive.util.Utility.isRegionChange ( Position position,
Position region )
static

Definition at line 343 of file Utility.java.

343 {
344 int diffX = position.getX() - region.getChunkX() * 8;
345 int diffY = position.getY() - region.getChunkY() * 8;
346 boolean changed = false;
347
348 if (diffX < 16) {
349 changed = true;
350 } else if (diffX >= 88) {
351 changed = true;
352 }
353
354 if (diffY < 16) {
355 changed = true;
356 } else if (diffY >= 88) {
357 changed = true;
358 }
359
360 return changed;
361 }

References com.runehive.game.world.position.Position.getChunkX(), com.runehive.game.world.position.Position.getChunkY(), com.runehive.game.world.position.Position.getX(), and com.runehive.game.world.position.Position.getY().

Referenced by com.runehive.game.world.entity.mob.Mob.move().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ longToString()

String com.runehive.util.Utility.longToString ( long l)
static

Definition at line 202 of file Utility.java.

202 {
203 if (l <= 0L || l >= 0x5b5b57f8a98a5dd1L)
204 return null;
205 if (l % 37L == 0L)
206 return null;
207 int i = 0;
208 char ac[] = new char[12];
209 while (l != 0L) {
210 long l1 = l;
211 l /= 37L;
212 ac[11 - i++] = VALID_CHARS[(int) (l1 - l * 37L)];
213 }
214 return new String(ac, 12 - i, i);
215 }

References VALID_CHARS.

Referenced by com.runehive.game.world.entity.mob.player.relations.PlayerRelation.addFriend(), com.runehive.game.world.entity.mob.player.relations.PlayerRelation.addIgnore(), com.runehive.game.world.entity.mob.player.relations.PlayerRelation.deleteFriend(), and com.runehive.game.world.entity.mob.player.relations.PlayerRelation.deleteIgnore().

Here is the caller graph for this function:

◆ min()

int com.runehive.util.Utility.min ( int... values)
static

Definition at line 895 of file Utility.java.

895 {
896 int i = Integer.MAX_VALUE;
897 for(int i2 : values)
898 if(i2 < i)
899 i = i2;
900 return i;
901 }

Referenced by com.runehive.content.wintertodt.Wintertodt.mixHerb().

Here is the caller graph for this function:

◆ nameToLong()

long com.runehive.util.Utility.nameToLong ( String text)
static

Converts the first 12 characters in a string of text to a hash.

Definition at line 185 of file Utility.java.

185 {
186 long hash = 0L;
187 for (int index = 0; index < text.length() && index < 12; index++) {
188 char key = text.charAt(index);
189 hash *= 37L;
190 if (key >= 'A' && key <= 'Z')
191 hash += (1 + key) - 65;
192 else if (key >= 'a' && key <= 'z')
193 hash += (1 + key) - 97;
194 else if (key >= '0' && key <= '9')
195 hash += (27 + key) - 48;
196 }
197 while (hash % 37L == 0L && hash != 0L)
198 hash /= 37L;
199 return hash;
200 }

References hash().

Referenced by com.runehive.net.session.LoginSession.evaluate(), com.runehive.game.world.entity.mob.player.Player.Player(), and com.runehive.game.world.entity.mob.player.Player.setUsername().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ random() [1/3]

int com.runehive.util.Utility.random ( int bound)
static

Definition at line 239 of file Utility.java.

239 {
240 return random(0, bound, false);
241 }

References random().

Referenced by com.runehive.game.world.entity.combat.strategy.npc.boss.Vorkath.VenomSpecial.AcidTask(), com.runehive.content.Obelisks.activate(), com.runehive.content.triviabot.TriviaBot.answer(), com.runehive.content.triviabot.TriviaBot.answered(), com.runehive.content.wintertodt.Wintertodt.applyColdDamage(), com.runehive.content.skill.impl.slayer.Slayer.assign(), com.runehive.content.wintertodt.Wintertodt.attackPyromancers(), com.runehive.game.world.entity.combat.strategy.npc.boss.magearena.Porazdir.block(), com.runehive.content.skill.impl.firemaking.Firemaking.bonfireAction(), com.runehive.content.wintertodt.Wintertodt.breakBrazier(), com.runehive.game.world.entity.combat.attack.listener.npc.dragon.BrutalDragon.canAttack(), com.runehive.game.world.entity.combat.strategy.npc.boss.Cerberus.canAttack(), com.runehive.content.skill.impl.thieving.WallSafe.chance(), com.runehive.content.skill.impl.woodcutting.WoodcuttingAction.chop(), com.runehive.content.skill.impl.hunter.Hunter.clickItem(), com.runehive.content.skill.impl.thieving.Thieving.clickNpc(), com.runehive.content.skill.impl.thieving.Thieving.clickObject(), com.runehive.content.skill.impl.thieving.WallSafe.crack(), com.runehive.content.skill.impl.crafting.Crafting.craft(), com.runehive.content.wintertodt.Wintertodt.doMagicAttack(), com.runehive.game.world.entity.combat.strategy.npc.boss.Vorkath.VenomSpecial.dragonFireTickableTask(), com.runehive.content.skill.impl.woodcutting.BirdsNest.drop(), com.runehive.game.world.entity.mob.npc.drop.NpcDropManager.drop(), com.runehive.content.skill.impl.agility.obstacle.ObstacleInteraction.execute(), com.runehive.content.skill.impl.hunter.net.Netting.execute(), com.runehive.content.skill.impl.thieving.PickpocketAction.execute(), com.runehive.content.wintertodt.Wintertodt.extinguishBraziers(), com.runehive.content.activity.inferno.Inferno.finish(), com.runehive.game.world.entity.combat.attack.listener.npc.dragon.BrutalDragon.finishOutgoing(), com.runehive.content.skill.impl.fishing.FishingAction.fish(), fixInsidePosition(), com.runehive.content.skill.impl.fletching.Fletching.fletch(), com.runehive.content.gambling.impl.FiftyFive.gamble(), com.runehive.content.gambling.impl.FlowerPoker.gamble(), com.runehive.content.lms.LMSGame.gearUpPlayers(), com.runehive.content.activity.impl.barrows.BarrowsUtility.generateRewards(), com.runehive.content.clanchannel.content.ClanTask.getAmount(), com.runehive.game.world.entity.combat.strategy.npc.boss.LizardShaman.AcidAttack.getHits(), com.runehive.content.Obelisks.ObeliskData.getRandom(), com.runehive.game.world.entity.mob.Direction.getRandomDirection(), com.runehive.game.world.position.impl.SquareArea.getRandomLocation(), com.runehive.content.activity.impl.fightcaves.FightCaves.handleDeath(), com.runehive.content.activity.inferno.Inferno.handleDeath(), com.runehive.game.world.entity.mob.npc.drop.NpcDropManager.handleMiscDrops(), hasOneOutOf(), com.runehive.game.world.entity.combat.attack.listener.item.AhrimListener.hit(), com.runehive.game.world.entity.combat.attack.listener.item.ToragListener.hit(), com.runehive.game.world.entity.combat.attack.listener.npc.SergeantStrongstack.hit(), com.runehive.game.world.entity.combat.strategy.npc.boss.MutantTarn.FrozenSpecial.hit(), com.runehive.content.itemaction.impl.DrillDemonBox.inventory(), com.runehive.content.itemaction.impl.MimeBox.inventory(), com.runehive.content.skill.SkillRepository.isSuccess(), com.runehive.content.skill.SkillRepository.isSuccess(), com.runehive.content.skill.SkillRepository.isSuccess(), com.runehive.game.world.items.Item.Item(), com.runehive.content.lms.lobby.LMSLobby.leaveLobby(), com.runehive.content.lms.loadouts.LMSLoadoutManager.load(), com.runehive.content.skill.impl.hunter.trap.TrapManager.lootTrap(), com.runehive.content.activity.impl.magearena.MageArena.meteors(), com.runehive.content.skill.impl.mining.MiningAction.mine(), com.runehive.content.skill.impl.herblore.Herblore.mix(), com.runehive.content.lms.LMSGame.moveToGame(), com.runehive.content.mysterybox.MysteryBoxEvent.MysteryBoxEvent(), com.runehive.util.parser.impl.NpcForceChatParser.ForcedMessage.nextMessage(), com.runehive.content.activity.impl.magearena.MageArena.onDeath(), com.runehive.content.activity.impl.pestcontrol.PestControlGame.onDeath(), com.runehive.content.skill.impl.firemaking.FiremakingAction.onDestruct(), com.runehive.content.pet.Pets.onReward(), com.runehive.content.pet.Pets.onReward(), com.runehive.game.world.entity.combat.strategy.npc.boss.Hydra.poisonTask(), com.runehive.game.world.entity.mob.npc.NpcDeath.postDeath(), com.runehive.content.wintertodt.Wintertodt.pyromancerText(), random(), random(), com.runehive.content.skill.impl.thieving.WallSafe.rate(), com.runehive.content.skill.impl.hunter.birdhouse.Birdhouses.receiveLoot(), com.runehive.content.lms.LMSGame.reset(), com.runehive.content.lms.LMSGame.rollChest(), com.runehive.content.skill.impl.prayer.BoneSacrifice.sacrifice(), com.runehive.content.skill.impl.hunter.trap.TrapExecution.setTrapProcess(), com.runehive.content.lms.LMSGame.setupSafezone(), com.runehive.content.lms.crate.LMSCrate.spawn(), com.runehive.content.activity.impl.magearena.MageArena.start(), com.runehive.content.activity.impl.pestcontrol.PestControlGame.PestControlNode.start(), com.runehive.content.activity.inferno.Inferno.start(), com.runehive.game.world.entity.combat.attack.listener.npc.CommanderZilyana.start(), com.runehive.game.world.entity.combat.attack.listener.npc.KrilTsutsaroth.start(), com.runehive.game.world.entity.combat.strategy.npc.boss.Callisto.Roar.start(), com.runehive.game.world.entity.combat.strategy.npc.boss.LizardShaman.JumpAttack.start(), com.runehive.game.world.entity.combat.strategy.npc.boss.LizardShaman.MinionsAttack.start(), com.runehive.game.world.entity.combat.strategy.npc.boss.magearena.Derwen.LightingRain.start(), com.runehive.game.world.entity.combat.strategy.npc.boss.magearena.Derwen.Magic.start(), com.runehive.game.world.entity.combat.strategy.npc.boss.magearena.Justiciar.LightingRain.start(), com.runehive.game.world.entity.combat.strategy.npc.boss.magearena.Justiciar.Magic.start(), com.runehive.game.world.entity.combat.strategy.npc.boss.magearena.Justiciar.TeleGrab.start(), com.runehive.game.world.entity.combat.strategy.npc.boss.magearena.Porazdir.Magic.start(), com.runehive.game.world.entity.combat.strategy.npc.boss.skotizo.Skotizo.LightingRain.start(), com.runehive.game.world.entity.combat.strategy.npc.boss.skotizo.Skotizo.Magic.start(), com.runehive.game.world.entity.combat.strategy.npc.boss.StoneGuardian.BoomAttack.start(), com.runehive.game.world.entity.combat.strategy.npc.boss.StoneGuardian.PrayerAttack.start(), com.runehive.content.skill.impl.cooking.Cooking.success(), com.runehive.content.skill.impl.mining.Mining.success(), com.runehive.game.task.impl.CeillingCollapseTask.tick(), and com.runehive.content.activity.randomevent.RandomEventHandler.trigger().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ random() [2/3]

int com.runehive.util.Utility.random ( int lowerBound,
int upperBound )
static

Definition at line 243 of file Utility.java.

243 {
244 return random(lowerBound, upperBound, false);
245 }

References random().

Here is the call graph for this function:

◆ random() [3/3]

int com.runehive.util.Utility.random ( int lowerBound,
int upperBound,
boolean inclusive )
static

Definition at line 275 of file Utility.java.

275 {
276 if (lowerBound >= upperBound) {
277 throw new IllegalArgumentException("The lower bound cannot be larger than or equal to the upper bound!");
278 }
279
280 return lowerBound + RANDOM.nextInt(upperBound - lowerBound) + (inclusive ? 1 : 0);
281 }

References RANDOM.

◆ randomElement() [1/4]

static< T > T com.runehive.util.Utility.randomElement ( Collection< T > collection)
static

Picks a random element out of any array type.

Definition at line 248 of file Utility.java.

248 {
249 return new ArrayList<T>(collection).get((int) (RANDOM.nextDouble() * collection.size()));
250 }

References RANDOM.

Referenced by com.runehive.content.pet.Pets.abandon(), com.runehive.content.skill.impl.slayer.SlayerTask.assign(), com.runehive.game.world.entity.combat.strategy.npc.boss.magearena.Justiciar.block(), com.runehive.game.world.entity.combat.strategy.npc.boss.magearena.Porazdir.block(), com.runehive.game.world.entity.combat.CombatTarget.checkAggression(), com.runehive.content.skill.impl.hunter.Hunter.clickItem(), com.runehive.content.skill.impl.thieving.Thieving.clickNpc(), com.runehive.content.skill.impl.runecrafting.Runecraft.clickObject(), com.runehive.content.skill.impl.thieving.WallSafe.crack(), com.runehive.game.world.entity.mob.player.PlayerDeath.death(), com.runehive.content.skill.impl.woodcutting.BirdsNest.drop(), com.runehive.game.world.entity.mob.npc.drop.NpcDropManager.drop(), com.runehive.content.skill.impl.thieving.PickpocketAction.execute(), com.runehive.game.task.impl.MessageEvent.execute(), com.runehive.content.bot.objective.impl.RestockObjective.finish(), com.runehive.game.world.entity.combat.strategy.npc.boss.ChaosFanatic.finishOutgoing(), com.runehive.game.world.entity.combat.strategy.npc.boss.CrazyArchaeologist.finishOutgoing(), com.runehive.game.world.entity.combat.strategy.npc.boss.magearena.DerwenUtility.SpawnData.generate(), com.runehive.game.world.entity.combat.strategy.npc.boss.magearena.JusticarUtility.SpawnData2.generate(), com.runehive.game.world.entity.combat.strategy.npc.boss.magearena.PorazdirUtility.SpawnData.generate(), com.runehive.game.world.entity.combat.strategy.npc.boss.skotizo.SkotizoUtility.SpawnData.generate(), com.runehive.content.activity.impl.barrows.BarrowsUtility.generateRewards(), com.runehive.content.clanchannel.content.ClanTask.getAssignment(), com.runehive.content.activity.impl.magearena.MageArena.getAvailablePosition(), com.runehive.content.activity.impl.zulrah.ZulrahActivity.getCloudPosition(), com.runehive.content.activity.impl.barrows.BarrowsUtility.getHiddenBrother(), com.runehive.content.preloads.RandomItem.getItem(), com.runehive.content.activity.impl.zulrah.ZulrahActivity.getSnakelingPosition(), com.runehive.game.world.entity.mob.npc.drop.NpcDropManager.handleMiscDrops(), com.runehive.game.world.entity.combat.attack.listener.npc.SergeantStrongstack.hit(), com.runehive.content.bot.objective.impl.CombatObjective.init(), com.runehive.content.itemaction.impl.ClanShowcaseBox.inventory(), com.runehive.content.itemaction.impl.DrillDemonBox.inventory(), com.runehive.content.itemaction.impl.MimeBox.inventory(), com.runehive.content.bot.PlayerBot.loopCombat(), com.runehive.content.bot.BotUtility.nameGenerator(), com.runehive.content.activity.impl.zulrah.ZulrahActivity.nextPhase(), com.runehive.content.DropDisplay.open(), com.runehive.content.simulator.DropSimulator.open(), com.runehive.content.skill.impl.woodcutting.BirdsNest.search(), com.runehive.content.emote.EmoteHandler.selectRandom(), com.runehive.content.activity.impl.pestcontrol.PestControlGame.sequence(), com.runehive.game.world.entity.mob.npc.Npc.sequence(), com.runehive.content.activity.record.PlayerRecord.showActivities(), com.runehive.content.bloodmoney.BloodMoneyChest.spawn(), com.runehive.content.skill.SkillRepository.spawn(), com.runehive.content.activity.impl.pestcontrol.PestControlGame.spawnMonsters(), com.runehive.content.teleport.TeleportHandler.special(), com.runehive.game.world.entity.combat.attack.listener.npc.CommanderZilyana.start(), com.runehive.game.world.entity.combat.attack.listener.npc.GeneralGraardor.start(), com.runehive.game.world.entity.combat.attack.listener.npc.KrilTsutsaroth.start(), com.runehive.game.world.entity.combat.strategy.npc.boss.ChaosFanatic.RainAttack.start(), com.runehive.game.world.entity.combat.strategy.npc.boss.LizardShaman.MinionsAttack.start(), com.runehive.game.world.entity.combat.strategy.npc.boss.skotizo.Skotizo.Magic.start(), and com.runehive.content.activity.impl.magearena.MageArena.update().

Here is the caller graph for this function:

◆ randomElement() [2/4]

int com.runehive.util.Utility.randomElement ( int[] array)
static

Picks a random element out of any array type.

Definition at line 271 of file Utility.java.

271 {
272 return array[(int) (RANDOM.nextDouble() * array.length)];
273 }

References RANDOM.

◆ randomElement() [3/4]

static< T > T com.runehive.util.Utility.randomElement ( List< T > list)
static

Picks a random element out of any list type.

Definition at line 253 of file Utility.java.

253 {
254 return list.get((int) (RANDOM.nextDouble() * list.size()));
255 }

References RANDOM.

◆ randomElement() [4/4]

static< T > T com.runehive.util.Utility.randomElement ( T[] array)
static

Picks a random element out of any array type.

Definition at line 266 of file Utility.java.

266 {
267 return array[(int) (RANDOM.nextDouble() * array.length)];
268 }

References RANDOM.

◆ rank()

String com.runehive.util.Utility.rank ( final String string)
static

Formats the player name.

Definition at line 94 of file Utility.java.

94 {
95 return Stream.of(string.trim().split("\\s")).filter(word -> word.length() > 0).map(word -> word.substring(0, 1).toUpperCase() + word.substring(1)).collect(Collectors.joining(" "));
96 }

◆ setStarter()

boolean com.runehive.util.Utility.setStarter ( Player player)
static

Definition at line 851 of file Utility.java.

851 {
852 String host = player.lastHost;
853
854 int amount = getStarters(host);
855
856 if (amount >= 2) {
857 return false;
858 }
859
860 if (amount == 0) {
861 amount = 1;
862 } else if (amount == 1) {
863 amount = 2;
864 }
865
866 try {
867 File file = new File("./data/starters/" + host + ".txt");
868 BufferedWriter out = new BufferedWriter(new FileWriter(file, false));
869 out.write(String.valueOf(amount));
870 out.close();
871 } catch (Exception e) {
872 e.printStackTrace();
873 return false;
874 }
875 return true;
876 }

References getStarters(), and com.runehive.game.world.entity.mob.player.Player.lastHost.

Here is the call graph for this function:

◆ shuffleArray()

int[] com.runehive.util.Utility.shuffleArray ( int[] array)
static

Definition at line 878 of file Utility.java.

878 {
879 int[] shuffledArray = new int[array.length];
880 System.arraycopy(array, 0, shuffledArray, 0, array.length);
881
882 for (int i = shuffledArray.length - 1; i > 0; i--) {
883 int index = RANDOM.nextInt(i + 1);
884 int a = shuffledArray[index];
885 shuffledArray[index] = shuffledArray[i];
886 shuffledArray[i] = a;
887 }
888 return shuffledArray;
889 }

References RANDOM.

Referenced by com.runehive.content.puzzle.PuzzleDisplay.randomize().

Here is the caller graph for this function:

◆ stringToLong()

long com.runehive.util.Utility.stringToLong ( String string)
static

Definition at line 71 of file Utility.java.

71 {
72 long l = 0L;
73 for (int i = 0; i < string.length() && i < 12; i++) {
74 char c = string.charAt(i);
75 l *= 37L;
76 if (c >= 'A' && c <= 'Z')
77 l += (1 + c) - 65;
78 else if (c >= 'a' && c <= 'z')
79 l += (1 + c) - 97;
80 else if (c >= '0' && c <= '9')
81 l += (27 + c) - 48;
82 }
83 while (l % 37L == 0L && l != 0L)
84 l /= 37L;
85 return l;
86 }

Referenced by com.runehive.game.world.entity.mob.player.relations.PlayerRelation.isFriendWith().

Here is the caller graph for this function:

◆ within() [1/3]

boolean com.runehive.util.Utility.within ( Interactable source,
Interactable target,
int distance )
static

Definition at line 699 of file Utility.java.

699 {
700 return within(source.getPosition(), source.width(), source.length(), target.getPosition(), target.width(), target.length(), distance);
701 }

References com.runehive.game.world.Interactable.getPosition(), com.runehive.game.world.Interactable.length(), com.runehive.game.world.Interactable.width(), and within().

Here is the call graph for this function:

◆ within() [2/3]

boolean com.runehive.util.Utility.within ( Position source,
int sourceWidth,
int sourceLength,
Position target,
int targetWidth,
int targetLength,
int distance )
static

Definition at line 731 of file Utility.java.

731 {
732 if (target.getHeight() != source.getHeight()) {
733 return false;
734 }
735 Position sourceTopRight = source.transform(sourceWidth - 1, sourceLength - 1);
736 Position targetTopRight = target.transform(targetWidth - 1, targetLength - 1);
737 int dx, dy;
738 if (sourceTopRight.getX() < target.getX()) {
739 dx = Math.abs(target.getX() - sourceTopRight.getX());
740 } else if (source.getX() > targetTopRight.getX()) {
741 dx = Math.abs(targetTopRight.getX() - source.getX());
742 } else {
743 dx = 0;
744 }
745 if (sourceTopRight.getY() < target.getY()) {
746 dy = Math.abs(target.getY() - sourceTopRight.getY());
747 } else if (source.getY() > targetTopRight.getY()) {
748 dy = Math.abs(targetTopRight.getY() - source.getY());
749 } else {
750 dy = 0;
751 }
752 return dx + dy <= distance;
753 }

References com.runehive.game.world.position.Position.getHeight(), com.runehive.game.world.position.Position.getX(), com.runehive.game.world.position.Position.getY(), and com.runehive.game.world.position.Position.transform().

Here is the call graph for this function:

◆ within() [3/3]

boolean com.runehive.util.Utility.within ( Position source,
Position target,
int distance )
static

Definition at line 676 of file Utility.java.

676 {
677 Interactable interactableSource = Interactable.create(source);
678 Interactable interactableTarget = Interactable.create(target);
679 return within(interactableSource, interactableTarget, distance);
680 }

References com.runehive.game.world.Interactable.create(), and within().

Referenced by com.runehive.game.world.entity.combat.attack.listener.npc.Alkahrid.block(), com.runehive.game.action.impl.DoorAction.execute(), com.runehive.game.world.entity.combat.attack.listener.npc.SergeantStrongstack.hit(), within(), within(), com.runehive.game.world.entity.combat.strategy.npc.boss.Zulrah.MeleeAttack.withinDistance(), withinDistance(), and withinDistance().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ withinDistance() [1/2]

◆ withinDistance() [2/2]

boolean com.runehive.util.Utility.withinDistance ( Interactable source,
Position target,
int radius )
static

Definition at line 474 of file Utility.java.

474 {
475 return within(source.getPosition(), source.width(), source.length(), target, 1, 1, radius);
476 }

References com.runehive.game.world.Interactable.getPosition(), com.runehive.game.world.Interactable.length(), com.runehive.game.world.Interactable.width(), and within().

Here is the call graph for this function:

◆ withinOctal() [1/2]

boolean com.runehive.util.Utility.withinOctal ( Interactable source,
Interactable target,
int distance )
static

Definition at line 703 of file Utility.java.

703 {
704 return withinOctal(source.getPosition(), source.width(), source.length(), target.getPosition(), target.width(), target.length(), distance);
705 }

References com.runehive.game.world.Interactable.getPosition(), com.runehive.game.world.Interactable.length(), com.runehive.game.world.Interactable.width(), and withinOctal().

Referenced by com.runehive.game.world.entity.combat.strategy.npc.boss.Vorkath.FireballAttack.hit(), and withinOctal().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ withinOctal() [2/2]

boolean com.runehive.util.Utility.withinOctal ( Position source,
int sourceWidth,
int sourceLength,
Position target,
int targetWidth,
int targetLength,
int distance )
static

Definition at line 707 of file Utility.java.

707 {
708 if (target.getHeight() != source.getHeight()) {
709 return false;
710 }
711 Position sourceTopRight = source.transform(sourceWidth - 1, sourceLength - 1);
712 Position targetTopRight = target.transform(targetWidth - 1, targetLength - 1);
713 int dx, dy;
714 if (sourceTopRight.getX() < target.getX()) {
715 dx = Math.abs(target.getX() - sourceTopRight.getX());
716 } else if (source.getX() > targetTopRight.getX()) {
717 dx = Math.abs(targetTopRight.getX() - source.getX());
718 } else {
719 dx = 0;
720 }
721 if (sourceTopRight.getY() < target.getY()) {
722 dy = Math.abs(target.getY() - sourceTopRight.getY());
723 } else if (source.getY() > targetTopRight.getY()) {
724 dy = Math.abs(targetTopRight.getY() - source.getY());
725 } else {
726 dy = 0;
727 }
728 return dx <= distance && dy <= distance;
729 }

References com.runehive.game.world.position.Position.getHeight(), com.runehive.game.world.position.Position.getX(), com.runehive.game.world.position.Position.getY(), and com.runehive.game.world.position.Position.transform().

Here is the call graph for this function:

◆ withinViewingDistance()

boolean com.runehive.util.Utility.withinViewingDistance ( Interactable source,
Interactable target,
int radius )
static

Definition at line 755 of file Utility.java.

755 {
756 if (source == null || target == null) {
757 return false;
758 }
759
760 if (target.getHeight() != source.getHeight()) {
761 return false;
762 }
763 Position sourceTopRight = source.getPosition().transform(source.width() - 1, source.length() - 1);
764 Position targetTopRight = target.getPosition().transform(target.width() - 1, target.length() - 1);
765 int dx, dy;
766 if (sourceTopRight.getX() < target.getX()) {
767 dx = Math.abs(target.getX() - sourceTopRight.getX());
768 } else if (source.getX() > targetTopRight.getX()) {
769 dx = Math.abs(targetTopRight.getX() - source.getX());
770 } else {
771 dx = 0;
772 }
773 if (sourceTopRight.getY() < target.getY()) {
774 dy = Math.abs(target.getY() - sourceTopRight.getY());
775 } else if (source.getY() > targetTopRight.getY()) {
776 dy = Math.abs(targetTopRight.getY() - source.getY());
777 } else {
778 dy = 0;
779 }
780 return dx <= radius && dy <= radius;
781 }

References com.runehive.game.world.Interactable.getHeight(), com.runehive.game.world.Interactable.getPosition(), com.runehive.game.world.Interactable.getX(), com.runehive.game.world.position.Position.getX(), com.runehive.game.world.Interactable.getY(), com.runehive.game.world.position.Position.getY(), com.runehive.game.world.Interactable.length(), com.runehive.game.world.position.Position.transform(), and com.runehive.game.world.Interactable.width().

Referenced by com.runehive.game.world.entity.combat.CombatUtil.areaAction(), com.runehive.game.world.object.StaticGameObject.register(), and com.runehive.game.world.object.StaticGameObject.unregister().

Here is the call graph for this function:
Here is the caller graph for this function:

Member Data Documentation

◆ RANDOM

final Random com.runehive.util.Utility.RANDOM = new Random(System.currentTimeMillis())
staticprivate

Random instance, used to generate pseudo-random primitive types.

Definition at line 30 of file Utility.java.

Referenced by random(), randomElement(), randomElement(), randomElement(), randomElement(), and shuffleArray().

◆ VALID_CHARS

final char [] com.runehive.util.Utility.VALID_CHARS = {'_', 'a', 'b', 'c', 'd', 'e', 'f', 'g', 'h', 'i', 'j', 'k', 'l', 'm', 'n', 'o', 'p', 'q', 'r', 's', 't', 'u', 'v', 'w', 'x', 'y', 'z', '0', '1', '2', '3', '4', '5', '6', '7', '8', '9', '/'}
staticprivate

Array of all valid characters.

Definition at line 33 of file Utility.java.

33{'_', 'a', 'b', 'c', 'd', 'e', 'f', 'g', 'h', 'i', 'j', 'k', 'l', 'm', 'n', 'o', 'p', 'q', 'r', 's', 't', 'u', 'v', 'w', 'x', 'y', 'z', '0', '1', '2', '3', '4', '5', '6', '7', '8', '9', '/'};

Referenced by longToString().


The documentation for this class was generated from the following file: