RuneHive-Game
Loading...
Searching...
No Matches
com.runehive.game.service.DonationService Class Reference

Static Public Member Functions

static void claimDonation (Player player)

Private Member Functions

 DonationService ()

Static Private Attributes

static final String CONNECTION_STRING = "jdbc:mysql://173.82.152.23:3306/osroyjs_store_2"
static final Logger logger = LogManager.getLogger(DonationService.class)
static final String PASS = "3AXbU=W7IfzX"
static final String USER = "osroyjs_exo1"

Detailed Description

Definition at line 13 of file DonationService.java.

Constructor & Destructor Documentation

◆ DonationService()

com.runehive.game.service.DonationService.DonationService ( )
private

Definition at line 19 of file DonationService.java.

19 {
20
21 }

Member Function Documentation

◆ claimDonation()

void com.runehive.game.service.DonationService.claimDonation ( Player player)
static

Definition at line 23 of file DonationService.java.

23 {
24 if (!player.databaseRequest.elapsed(1, TimeUnit.MINUTES)) {
25 player.dialogueFactory.sendNpcChat(5523,"You can only check our database once every 1 minute!").execute();
26 return;
27 }
28
29 if (!player.inventory.isEmpty()) {
30 player.dialogueFactory.sendNpcChat(5523, Expression.SAD, "You must have an empty inventory to do this!").execute();
31 return;
32 }
33
34 player.dialogueFactory.sendStatement("Checking request...").execute();
35 boolean claimed = false;
36 player.databaseRequest.reset();
37
38 try(Connection connection = DriverManager.getConnection(CONNECTION_STRING, USER, PASS);
39 PreparedStatement sta = connection.prepareStatement("SELECT * FROM payments WHERE player_name = ? AND status='Completed' AND claimed=0", ResultSet.TYPE_SCROLL_INSENSITIVE, ResultSet.CONCUR_UPDATABLE)) {
40 sta.setString(1, player.getName().replace("_", " "));
41
42 ResultSet rs = sta.executeQuery();
43
44
45 while(rs.next()) {
46 final int itemNumber = rs.getInt("item_number");
47 final int quantity = rs.getInt("quantity");
48
49 switch(itemNumber) {
50 //$10 DONATOR BOND
51 case 10:
52 if (player.inventory.add(new Item(DonatorBond.BOND_10.item, quantity))) {
53 claimed = true;
54 }
55 break;
56
57 //$50 DONATOR BOND
58 case 20:
59 if (player.inventory.add(new Item(DonatorBond.BOND_50.item, quantity))) {
60 claimed = true;
61 }
62 break;
63
64 //$100 DONATOR BOND
65 case 21:
66 if (player.inventory.add(new Item(DonatorBond.BOND_100.item, quantity))) {
67 claimed = true;
68 }
69 break;
70
71 //$200 DONATOR BOND
72 case 22:
73 if (player.inventory.add(new Item(DonatorBond.BOND_200.item, quantity))) {
74 claimed = true;
75 }
76 break;
77
78 //$500 DONATOR BOND
79 case 23:
80 if (player.inventory.add(new Item(DonatorBond.BOND_500.item, quantity))) {
81 claimed = true;
82 }
83 break;
84 }
85
86 if (claimed) {
87 rs.updateInt("claimed", 1);
88 rs.updateRow();
89 }
90
91 }
92
93 if (!claimed) {
94 player.dialogueFactory.sendNpcChat(5523,"There is no donation reward for you to claim!").execute();
95 } else {
96 player.dialogueFactory.sendNpcChat(5523,"Thank-you for your donation!").execute();
97 }
98
99 } catch (SQLException ex) {
100 logger.error(String.format("Failed to claim donation for player=%s", player.getName()), ex);
101 }
102 }

References com.runehive.game.world.items.containers.ItemContainer.add(), com.runehive.content.donators.DonatorBond.BOND_10, com.runehive.content.donators.DonatorBond.BOND_100, com.runehive.content.donators.DonatorBond.BOND_200, com.runehive.content.donators.DonatorBond.BOND_50, com.runehive.content.donators.DonatorBond.BOND_500, CONNECTION_STRING, com.runehive.game.world.entity.mob.player.Player.databaseRequest, com.runehive.game.world.entity.mob.player.Player.dialogueFactory, com.runehive.util.Stopwatch.elapsed(), com.runehive.content.dialogue.DialogueFactory.execute(), com.runehive.game.world.entity.mob.player.Player.getName(), com.runehive.game.world.entity.mob.player.Player.inventory, com.runehive.game.world.items.containers.ItemContainer.isEmpty(), logger, PASS, com.runehive.util.Stopwatch.reset(), com.runehive.content.dialogue.Expression.SAD, com.runehive.content.dialogue.DialogueFactory.sendNpcChat(), com.runehive.content.dialogue.DialogueFactory.sendStatement(), and USER.

Here is the call graph for this function:

Member Data Documentation

◆ CONNECTION_STRING

final String com.runehive.game.service.DonationService.CONNECTION_STRING = "jdbc:mysql://173.82.152.23:3306/osroyjs_store_2"
staticprivate

Definition at line 17 of file DonationService.java.

Referenced by claimDonation().

◆ logger

final Logger com.runehive.game.service.DonationService.logger = LogManager.getLogger(DonationService.class)
staticprivate

Definition at line 14 of file DonationService.java.

Referenced by claimDonation().

◆ PASS

final String com.runehive.game.service.DonationService.PASS = "3AXbU=W7IfzX"
staticprivate

Definition at line 16 of file DonationService.java.

Referenced by claimDonation().

◆ USER

final String com.runehive.game.service.DonationService.USER = "osroyjs_exo1"
staticprivate

Definition at line 15 of file DonationService.java.

Referenced by claimDonation().


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