RuneHive-Tarnish
Neural OSRS Enhancement Framework
Loading...
Searching...
No Matches
ClanMember.java
1package com.osroyale.content.clanchannel;
2
3import com.osroyale.content.clanchannel.channel.ClanChannel;
4import com.osroyale.game.world.entity.mob.player.Player;
5import com.osroyale.game.world.entity.mob.player.relations.PrivacyChatMode;
6import com.osroyale.net.packet.out.SendClanDetails;
7
8import java.util.Objects;
9import java.util.Optional;
10
51
52public class ClanMember {
54 public final String name;
55
57 public ClanRank rank;
58
60 public int totalLevel;
61
63 public String joined;
64
66 public double expGained;
67
69 public int npcKills;
70
72 public int playerKills;
73
75 public Optional<Player> player;
76
78 public ClanMember(String name) {
79 this.name = name;
80 this.rank = ClanRank.MEMBER;
81 this.player = Optional.empty();
82 }
83
86 this.name = player.getName();
87 this.player = Optional.of(player);
88 this.rank = ClanRank.MEMBER;
89 }
90
92 public void message(Object... messages) {
93 player.ifPresent(p -> {
94 ClanChannel channel = p.clanChannel;
95 for (Object message : messages) {
96 p.send(new SendClanDetails(String.valueOf(message), channel.getName(), ClanRank.SYSTEM));
97 }
98 });
99 }
100
102 public void chat(ClanMember speaker, Object message) {
103 player.ifPresent(p -> {
104 final ClanChannel channel = p.clanChannel;
105
106 final Optional<Player> result = speaker.player;
107
108 if (!result.isPresent()) {
109 return;
110 }
111
112 final Player playerTalking = result.get();
113
114 if (p.relations.getClanChatMode() == PrivacyChatMode.OFF
115 || p.relations.getClanChatMode() == PrivacyChatMode.FRIENDS_ONLY && !p.relations.isFriendWith(playerTalking.getName())) {
116 return;
117 }
118
119 p.send(new SendClanDetails(speaker.name, String.valueOf(message), channel.getName(), speaker.rank));
120 });
121 }
122
124 public int getValue() {
125 return (int) expGained;
126 }
127
128 public boolean hasContributed() {
129 return !(npcKills == 0 && expGained == 0 && playerKills == 0);
130 }
131
132 @Override
133 public boolean equals(Object obj) {
134 if (obj == this) return true;
135 if (obj instanceof ClanMember) {
136 ClanMember other = (ClanMember) obj;
137 return Objects.equals(name, other.name)
138 && Objects.equals(rank, other.rank)
139 && Objects.equals(totalLevel, other.totalLevel)
140 && Objects.equals(joined, other.joined)
141 && Objects.equals(expGained, other.expGained)
142 && Objects.equals(npcKills, other.npcKills)
143 && Objects.equals(playerKills, other.playerKills);
144 }
145 return false;
146 }
147
148 @Override
149 public int hashCode() {
150 return name.hashCode();
151 }
152
153 @Override
154 public String toString() {
155 return name + " " + rank;
156 }
157
158}
void chat(ClanMember speaker, Object message)