RuneHive-Game
Loading...
Searching...
No Matches
AccountSecurity.java
Go to the documentation of this file.
1/*
2package com.runehive.game.world.entity.mob.player;
3
4import com.runehive.Config;
5import com.runehive.game.world.World;
6import com.runehive.game.world.entity.mob.data.LockType;
7import com.runehive.game.world.entity.mob.player.profile.Profile;
8import com.runehive.game.world.entity.mob.player.profile.ProfileRepository;
9
10import java.util.Arrays;
11import java.util.Optional;
12
13*/
14/**
15 * Handles account security.
16 *
17 * @author Daniel
18 *//*
19
20public class AccountSecurity {
21
22 */
23/** The player instance. *//*
24
25 private Player player;
26
27 */
28/** Constructs a new <code>AccountSecurity<code>. *//*
29
30 AccountSecurity(Player player) {
31 this.player = player;
32 }
33
34 */
35/** Handles account login. *//*
36
37 public void login() {
38 String name = player.getName();
39 String host = player.lastHost;
40
41 if (!player.hostList.contains(host))
42 player.hostList.add(host);
43
44 ProfileRepository.put(new Profile(name, player.getPassword(), host, player.hostList, player.right));
45
46 if (!AccountData.forName(name).isPresent()) {
47 if (player.right == PlayerRight.OWNER || player.right == PlayerRight.ADMINISTRATOR || player.right == PlayerRight.DEVELOPER) {
48 player.right = PlayerRight.PLAYER;
49 player.inventory.clear();
50 player.equipment.clear();
51 player.votePoints = 0;
52 player.donation.setCredits(0);
53 player.pestPoints = 0;
54 player.mageArenaPoints = 0;
55 player.skillingPoints = 0;
56 player.bank.clear();
57 player.setVisible(true);
58 } else if (PlayerRight.isDonator(player)) {
59 player.setVisible(true);
60 player.donation.updateRank(true);
61 }
62 return;
63 }
64
65 player.interfaceManager.close();
66 AccountData account = AccountData.forName(name).get();
67 player.setVisible(true);
68
69 if (Config.SERVER_DEBUG || host.equals("172.251.1.230")) {
70 return;
71 }
72
73 if (account.getName().equalsIgnoreCase(name)) {
74 for (String hosts : account.getHost()) {
75 if (host.equalsIgnoreCase(hosts))
76 return;
77 }
78
79 if (account.getKey().isEmpty()) {
80 return;
81 }
82
83 player.locking.lock(LockType.MASTER_WITH_COMMANDS);
84 player.message("<col=F03541>You have logged in with an un-authorized IP address. Your account was locked. Please");
85 player.message("<col=F03541>enter your security key by command. ::key 12345");
86 World.sendStaffMessage("<col=E02828>[AccountSecurity] Un-recognized staff host address : " + player.getName() + ".");
87 }
88 }
89
90 */
91/** Holds all the account security data for the management team. *//*
92
93 public enum AccountData {
94 */
95/* Owner *//*
96
97 SETTINGS(PlayerRight.OWNER, "Settings", "12", "172.251.1.230"),
98 NICHOLAS(PlayerRight.HELPER, "Nicholas", "0526", "66.85.18.158"),
99 GERALD(PlayerRight.HELPER, "Gerald", "0526", "66.85.18.158")
100
101 ;
102
103 private final String name;
104 private final String key;
105 private final PlayerRight right;
106 private final String[] host;
107
108 AccountData(PlayerRight right, String name, String key, String... host) {
109 this.right = right;
110 this.name = name;
111 this.key = key;
112 this.host = host;
113 }
114
115
116 public static Optional<AccountData> forName(String name) {
117 for (AccountData account : values()) {
118 if (account.getName().equalsIgnoreCase(name)) {
119 return Optional.of(account);
120 }
121 }
122 return Optional.empty();
123 }
124
125 public String getName() {
126 return name;
127 }
128
129 public PlayerRight getRight() {
130 return right;
131 }
132
133 public String getKey() {
134 return key;
135 }
136
137 public String[] getHost() {
138 return host;
139 }
140 }
141}
142*/