RuneHive-Tarnish
Neural OSRS Enhancement Framework
Loading...
Searching...
No Matches
Donation.java
1package com.osroyale.content.donators;
2
3import com.osroyale.content.writer.InterfaceWriter;
4import com.osroyale.content.writer.impl.InformationWriter;
5import com.osroyale.game.world.World;
6import com.osroyale.game.world.entity.mob.UpdateFlag;
7import com.osroyale.game.world.entity.mob.player.Player;
8import com.osroyale.game.world.entity.mob.player.PlayerRight;
9import com.osroyale.net.packet.out.SendAnnouncement;
10import com.osroyale.util.Utility;
11import org.apache.logging.log4j.LogManager;
12import org.apache.logging.log4j.Logger;
13
43
44* This class handles everything related to donators.
45 *
46 * @author Daniel
47 */
48public class Donation {
49
50 private static final Logger logger = LogManager.getLogger(Donation.class);
51
52 private final Player player;
53 private int credits;
54 private int spent;
55
56 public Donation(Player player) {
57 this.player = player;
58 }
59
60 public void redeem(DonatorBond bond) {
61 setSpent(getSpent() + bond.moneySpent);
62 setCredits(getCredits() + bond.credits);
63 player.message("<col=FF0000>You have claimed your donator bond. You now have " + Utility.formatDigits(getCredits()) + " donator credits!");
64 World.sendMessage("<col=CF2192>Tarnish: <col=" + player.right.getColor() + ">" + player.getName() + " </col>has opened <col=CF2192>" + Utility.formatEnum(bond.name()) + "");
65 updateRank(false);
66 }
67
68 public void updateRank(boolean login) {
69 PlayerRight rank = PlayerRight.forSpent(spent);
70
71 if (rank == null) {
72 return;
73 }
74
75 if (player.right.equals(rank)) {
76 return;
77 }
78
79 if (login) {
80 if (!PlayerRight.isIronman(player) && !PlayerRight.isHelper(player)) {
81 player.right = rank;
82 player.updateFlags.add(UpdateFlag.APPEARANCE);
83 }
84 return;
85 }
86
87 if (PlayerRight.isIronman(player)) {
88 player.message("Since you are an iron man, your rank icon will not change.");
89 } else if (!PlayerRight.isModerator(player)) {
90 player.right = rank;
91 player.updateFlags.add(UpdateFlag.APPEARANCE);
92 }
93
94 String name = rank.getName();
95 player.send(new SendAnnouncement("Rank Level Up!", "You are now " + Utility.getAOrAn(name) + " " + PlayerRight.getCrown(player) + " " + name + "!", 0x1C889E));
96 player.dialogueFactory.sendStatement("You are now " + Utility.getAOrAn(name) + " " + PlayerRight.getCrown(player) + " " + name + "!").execute();
97 InterfaceWriter.write(new InformationWriter(player));
98 }
99
100 public int getCredits() {
101 return credits;
102 }
103
104 public int getSpent() {
105 return spent;
106 }
107
108 public void setCredits(int credits) {
109 this.credits = credits;
110 }
111
112 public void setSpent(int spent) {
113 this.spent = spent;
114 }
115}
static void sendMessage(String... messages)
Definition World.java:433
static String formatDigits(final int amount)
Definition Utility.java:78
static String getAOrAn(String nextWord)
Definition Utility.java:153
static String formatEnum(final String string)
Definition Utility.java:126