RuneHive-Game
Loading...
Searching...
No Matches
Donation.java
Go to the documentation of this file.
1package com.runehive.content.donators;
2
3import com.runehive.content.writer.InterfaceWriter;
4import com.runehive.content.writer.impl.InformationWriter;
5import com.runehive.game.world.World;
6import com.runehive.game.world.entity.mob.UpdateFlag;
7import com.runehive.game.world.entity.mob.player.Player;
8import com.runehive.game.world.entity.mob.player.PlayerRight;
9import com.runehive.net.packet.out.SendAnnouncement;
10import com.runehive.util.Utility;
11import org.apache.logging.log4j.LogManager;
12import org.apache.logging.log4j.Logger;
13
14/**
15 * This class handles everything related to donators.
16 *
17 * @author Daniel
18 */
19public class Donation {
20
21 private static final Logger logger = LogManager.getLogger(Donation.class);
22
23 private final Player player;
24 private int credits;
25 private int spent;
26
28 this.player = player;
29 }
30
31 public void redeem(DonatorBond bond) {
34 player.message("<col=FF0000>You have claimed your donator bond. You now have " + Utility.formatDigits(getCredits()) + " donator credits!");
35 World.sendMessage("<col=CF2192>osroyale: <col=" + player.right.getColor() + ">" + player.getName() + " </col>has opened <col=CF2192>" + Utility.formatEnum(bond.name()) + "");
36 updateRank(false);
37 }
38
39 public void updateRank(boolean login) {
41
42 if (rank == null) {
43 return;
44 }
45
46 if (player.right.equals(rank)) {
47 return;
48 }
49
50 if (login) {
52 player.right = rank;
53 player.updateFlags.add(UpdateFlag.APPEARANCE);
54 }
55 return;
56 }
57
59 player.message("Since you are an iron man, your rank icon will not change.");
60 } else if (!PlayerRight.isModerator(player)) {
61 player.right = rank;
62 player.updateFlags.add(UpdateFlag.APPEARANCE);
63 }
64
65 String name = rank.getName();
66 player.send(new SendAnnouncement("Rank Level Up!", "You are now " + Utility.getAOrAn(name) + " " + PlayerRight.getCrown(player) + " " + name + "!", 0x1C889E));
67 player.dialogueFactory.sendStatement("You are now " + Utility.getAOrAn(name) + " " + PlayerRight.getCrown(player) + " " + name + "!").execute();
69 }
70
71 public int getCredits() {
72 return credits;
73 }
74
75 public int getSpent() {
76 return spent;
77 }
78
79 public void setCredits(int credits) {
80 this.credits = credits;
81 }
82
83 public void setSpent(int spent) {
84 this.spent = spent;
85 }
86}
Handles writing on an itemcontainer.
static void write(InterfaceWriter writer)
Class handles writing on the quest tab itemcontainer.
Represents the game world.
Definition World.java:46
static void sendMessage(String... messages)
Sends a global message.
Definition World.java:396
This class represents a character controlled by a player.
Definition Player.java:125
Handles miscellaneous methods.
Definition Utility.java:27
static String formatDigits(final int amount)
Formats digits for integers.
Definition Utility.java:41
static String getAOrAn(String nextWord)
A or an.
Definition Utility.java:116
static String formatEnum(final String string)
Formats name of enum.
Definition Utility.java:89
Holds all the donator bond data.
final int moneySpent
The amount of money spent that was required for this bond.
final int credits
The amount of credits this bond will give.
static boolean isHelper(Player player)
Checks if the player is a HELPER member.
static String getCrown(Player player)
Gets the crown display.
static boolean isIronman(Player player)
Checks if the player is an ironman.
static boolean isModerator(Player player)
Checks if the player is a management member.