RuneHive-Game
Loading...
Searching...
No Matches
com.runehive.content.clanchannel.ClanRepository Class Reference

The repository containing all the clans and their corresponding data. More...

Static Public Member Functions

static void addChannel (ClanChannel channel)
 Adds the channel.
static ClanChannel getChannel (String channel)
 Returns the channel.
static Optional< Set< ClanChannel > > getTopChanels (ClanType type)
static Optional< Set< ClanChannel > > getTopChanels (ClanViewer.Filter filter)
static void loadChannels ()
 Loads all clans and puts them into the map.
static boolean nameExist (String name)
static void removeChannel (ClanChannel channel)
 Handles removing a channel from the clan lists.
static void saveAllActiveClans ()
static void setActive (ClanChannel channel)
static void setInactive (ClanChannel channel)
static boolean tagExist (String tag)

Static Public Attributes

static Set< ClanChannelACTIVE_CHANNELS = new HashSet<>()
 Set of all active clan chat channels.
static Set< String > ACTIVE_NAMES = new HashSet<>()
 Set of all active clan chat names.
static Set< String > ACTIVE_TAGS = new HashSet<>()
 Set of all active clan chat tags.
static Set< ClanChannelALLTIME = new TreeSet<>()
 Set of all active clan chat names.

Static Private Member Functions

static void saveClan (ClanChannel channel)

Static Private Attributes

static Map< String, ClanChannelCHANNELS = new HashMap<>()
 Map of all clan chat channels.
static Set< ClanChannelTOP_IRON_MAN = new TreeSet<>()
 Set of all active clan chat names.
static Set< ClanChannelTOP_PVM = new TreeSet<>()
 Set of all active clan chat names.
static Set< ClanChannelTOP_PVP = new TreeSet<>()
 Set of all active clan chat names.
static Set< ClanChannelTOP_SKILLING = new TreeSet<>()
 Set of all active clan chat names.

Detailed Description

The repository containing all the clans and their corresponding data.

Author
Daniel

Definition at line 18 of file ClanRepository.java.

Member Function Documentation

◆ addChannel()

void com.runehive.content.clanchannel.ClanRepository.addChannel ( ClanChannel channel)
static

Adds the channel.

Definition at line 53 of file ClanRepository.java.

53 {
54 CHANNELS.put(channel.getOwner().toLowerCase().trim(), channel);
55 }

References CHANNELS.

Referenced by com.runehive.content.clanchannel.channel.ClanChannel.create(), and com.runehive.content.clanchannel.channel.ClanChannel.load().

Here is the caller graph for this function:

◆ getChannel()

ClanChannel com.runehive.content.clanchannel.ClanRepository.getChannel ( String channel)
static

Returns the channel.

Definition at line 48 of file ClanRepository.java.

48 {
49 return CHANNELS.get(channel.toLowerCase().trim());
50 }

References CHANNELS.

Referenced by com.runehive.content.clanchannel.channel.ClanChannel.activateTask(), com.runehive.content.clanchannel.channel.ClanChannelHandler.connect(), com.runehive.content.clanchannel.channel.ClanChannel.create(), and com.runehive.content.clanchannel.channel.ClanChannel.setRank().

Here is the caller graph for this function:

◆ getTopChanels() [1/2]

Optional< Set< ClanChannel > > com.runehive.content.clanchannel.ClanRepository.getTopChanels ( ClanType type)
static

Definition at line 138 of file ClanRepository.java.

138 {
139 if (type.equals(ClanType.PVP)) {
140 return Optional.of(TOP_PVP);
141 }
142 if (type.equals(ClanType.PVM)) {
143 return Optional.of(TOP_PVM);
144 }
145 if (type.equals(ClanType.SKILLING)) {
146 return Optional.of(TOP_SKILLING);
147 }
148 if (type.equals(ClanType.IRON_MAN)) {
149 return Optional.of(TOP_IRON_MAN);
150 }
151 return Optional.empty();
152 }

References com.runehive.content.clanchannel.ClanType.IRON_MAN, com.runehive.content.clanchannel.ClanType.PVM, com.runehive.content.clanchannel.ClanType.PVP, com.runehive.content.clanchannel.ClanType.SKILLING, TOP_IRON_MAN, TOP_PVM, TOP_PVP, and TOP_SKILLING.

Referenced by com.runehive.content.clanchannel.content.ClanViewer.drawClanList().

Here is the caller graph for this function:

◆ getTopChanels() [2/2]

Optional< Set< ClanChannel > > com.runehive.content.clanchannel.ClanRepository.getTopChanels ( ClanViewer.Filter filter)
static

Definition at line 154 of file ClanRepository.java.

154 {
155 if (filter.equals(ClanViewer.Filter.ALL_TIME)) {
156 return Optional.of(ALLTIME);
157 }
158 if (filter.equals(ClanViewer.Filter.TOP_PVM)) {
159 return Optional.of(TOP_PVM);
160 }
161 if (filter.equals(ClanViewer.Filter.TOP_PVP)) {
162 return Optional.of(TOP_PVP);
163 }
164 if (filter.equals(ClanViewer.Filter.TOP_SKILLING)) {
165 return Optional.of(TOP_SKILLING);
166 }
167 if (filter.equals(ClanViewer.Filter.TOP_IRON_MAN)) {
168 return Optional.of(TOP_IRON_MAN);
169 }
170 return Optional.empty();
171 }

References com.runehive.content.clanchannel.content.ClanViewer.Filter.ALL_TIME, ALLTIME, TOP_IRON_MAN, com.runehive.content.clanchannel.content.ClanViewer.Filter.TOP_IRON_MAN, TOP_PVM, com.runehive.content.clanchannel.content.ClanViewer.Filter.TOP_PVM, TOP_PVP, com.runehive.content.clanchannel.content.ClanViewer.Filter.TOP_PVP, TOP_SKILLING, and com.runehive.content.clanchannel.content.ClanViewer.Filter.TOP_SKILLING.

◆ loadChannels()

void com.runehive.content.clanchannel.ClanRepository.loadChannels ( )
static

Loads all clans and puts them into the map.

Definition at line 112 of file ClanRepository.java.

112 {
113 Path path = Paths.get("./data/content/clan/");
114 File[] files = path.toFile().listFiles();
115
116 if (files == null) {
117 System.out.println("No clan files were found.");
118 return;
119 }
120
121 for (File file : files) {
122 String fileName = file.getName();
123 if (!fileName.toLowerCase().endsWith(".json")) continue;
124 /*ClanChannel channel = ClanChannel.fromJson(file.getName().replace(".json", ""));
125 if (channel != null) {
126 if (!channel.getTag().isEmpty())
127 ACTIVE_TAGS.add(channel.getTag());
128 if (!channel.getName().isEmpty())
129 ACTIVE_NAMES.add(channel.getName());
130 ALLTIME.add(channel);
131 CHANNELS.put(channel.getOwner().toLowerCase().trim(), channel);
132 }*/
133
134 ClanChannel.load(file.getName().replace(".json", ""));
135 }
136 }

References com.runehive.content.clanchannel.channel.ClanChannel.load().

Referenced by com.runehive.RuneHive.processParallelStartupTasks().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ nameExist()

boolean com.runehive.content.clanchannel.ClanRepository.nameExist ( String name)
static

Definition at line 74 of file ClanRepository.java.

74 {
75 return ACTIVE_TAGS.contains(name.toLowerCase().trim());
76 }

References ACTIVE_TAGS.

Referenced by com.runehive.content.clanchannel.channel.ClanChannel.setName().

Here is the caller graph for this function:

◆ removeChannel()

void com.runehive.content.clanchannel.ClanRepository.removeChannel ( ClanChannel channel)
static

Handles removing a channel from the clan lists.

Definition at line 58 of file ClanRepository.java.

58 {
59 CHANNELS.remove(channel.getOwner().toLowerCase().trim());
60 ACTIVE_CHANNELS.remove(channel);
61 saveClan(channel);
62 }

References ACTIVE_CHANNELS, CHANNELS, and saveClan().

Here is the call graph for this function:

◆ saveAllActiveClans()

void com.runehive.content.clanchannel.ClanRepository.saveAllActiveClans ( )
static

Definition at line 86 of file ClanRepository.java.

86 {
87 for (ClanChannel channel : ClanRepository.ACTIVE_CHANNELS) {
88 if (channel.activeSize() <= 0) {
89 continue;
90 }
91 saveClan(channel);
92 }
93 }

References ACTIVE_CHANNELS, and saveClan().

Referenced by com.runehive.game.task.impl.PlayerSaveEvent.execute(), and com.runehive.game.world.World.save().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ saveClan()

void com.runehive.content.clanchannel.ClanRepository.saveClan ( ClanChannel channel)
staticprivate

Definition at line 95 of file ClanRepository.java.

95 {
96 Thread.startVirtualThread(() -> {
97 final File dir = Paths.get("data", "content", "clan").toFile();
98
99 if (!dir.exists()) {
100 dir.mkdirs();
101 }
102
103 try (FileWriter fw = new FileWriter(dir.toPath().resolve(channel.getOwner() + ".json").toFile())) {
104 fw.write(GsonUtils.JSON_PRETTY_NO_NULLS.get().toJson(channel.toJson()));
105 } catch (final Exception e) {
106 e.printStackTrace();
107 }
108 });
109 }

References com.runehive.util.GsonUtils.JSON_PRETTY_NO_NULLS.

Referenced by removeChannel(), saveAllActiveClans(), and setInactive().

Here is the caller graph for this function:

◆ setActive()

void com.runehive.content.clanchannel.ClanRepository.setActive ( ClanChannel channel)
static

Definition at line 64 of file ClanRepository.java.

64 {
65 ACTIVE_CHANNELS.add(channel);
66 }

References ACTIVE_CHANNELS.

Referenced by com.runehive.content.clanchannel.channel.ClanChannel.establish().

Here is the caller graph for this function:

◆ setInactive()

void com.runehive.content.clanchannel.ClanRepository.setInactive ( ClanChannel channel)
static

Definition at line 68 of file ClanRepository.java.

68 {
69 if (ACTIVE_CHANNELS.remove(channel)) {
70 saveClan(channel);
71 }
72 }

References ACTIVE_CHANNELS, and saveClan().

Referenced by com.runehive.content.clanchannel.channel.ClanChannel.ban(), and com.runehive.content.clanchannel.channel.ClanChannel.disconnect().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ tagExist()

boolean com.runehive.content.clanchannel.ClanRepository.tagExist ( String tag)
static

Definition at line 78 of file ClanRepository.java.

78 {
79 for (ClanChannel channel : CHANNELS.values()) {
80 if (channel.getTag().equalsIgnoreCase(tag))
81 return true;
82 }
83 return false;
84 }

References CHANNELS.

Referenced by com.runehive.content.clanchannel.channel.ClanChannel.setTag().

Here is the caller graph for this function:

Member Data Documentation

◆ ACTIVE_CHANNELS

Set<ClanChannel> com.runehive.content.clanchannel.ClanRepository.ACTIVE_CHANNELS = new HashSet<>()
static

Set of all active clan chat channels.

Definition at line 24 of file ClanRepository.java.

Referenced by removeChannel(), saveAllActiveClans(), setActive(), setInactive(), and com.runehive.game.task.impl.ClanUpdateEvent.tick().

◆ ACTIVE_NAMES

Set<String> com.runehive.content.clanchannel.ClanRepository.ACTIVE_NAMES = new HashSet<>()
static

◆ ACTIVE_TAGS

Set<String> com.runehive.content.clanchannel.ClanRepository.ACTIVE_TAGS = new HashSet<>()
static

◆ ALLTIME

Set<ClanChannel> com.runehive.content.clanchannel.ClanRepository.ALLTIME = new TreeSet<>()
static

◆ CHANNELS

Map<String, ClanChannel> com.runehive.content.clanchannel.ClanRepository.CHANNELS = new HashMap<>()
staticprivate

Map of all clan chat channels.

Definition at line 21 of file ClanRepository.java.

Referenced by addChannel(), getChannel(), removeChannel(), and tagExist().

◆ TOP_IRON_MAN

Set<ClanChannel> com.runehive.content.clanchannel.ClanRepository.TOP_IRON_MAN = new TreeSet<>()
staticprivate

Set of all active clan chat names.

Definition at line 45 of file ClanRepository.java.

Referenced by getTopChanels(), and getTopChanels().

◆ TOP_PVM

Set<ClanChannel> com.runehive.content.clanchannel.ClanRepository.TOP_PVM = new TreeSet<>()
staticprivate

Set of all active clan chat names.

Definition at line 39 of file ClanRepository.java.

Referenced by getTopChanels(), and getTopChanels().

◆ TOP_PVP

Set<ClanChannel> com.runehive.content.clanchannel.ClanRepository.TOP_PVP = new TreeSet<>()
staticprivate

Set of all active clan chat names.

Definition at line 36 of file ClanRepository.java.

Referenced by getTopChanels(), and getTopChanels().

◆ TOP_SKILLING

Set<ClanChannel> com.runehive.content.clanchannel.ClanRepository.TOP_SKILLING = new TreeSet<>()
staticprivate

Set of all active clan chat names.

Definition at line 42 of file ClanRepository.java.

Referenced by getTopChanels(), and getTopChanels().


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