mirror of
https://github.com/DRE2N/DungeonsXL.git
synced 2024-09-30 00:27:30 +02:00
Allow for getting groups by their untagged names
This commit is contained in:
parent
42bde96c86
commit
bd14fa2202
@ -136,7 +136,7 @@ public class DungeonsXL extends DREPlugin implements DungeonsAPI {
|
||||
private Registry<Integer, InstanceWorld> instanceCache = new Registry<>();
|
||||
private Registry<String, GameRule> gameRuleRegistry = new GameRuleRegistry();
|
||||
private Registry<String, ExternalMobProvider> externalMobProviderRegistry = new Registry<>();
|
||||
private Registry<String, PlayerGroup> playerGroupCache = new Registry<>();
|
||||
private Registry<String, PlayerGroup> playerGroupCache = new PlayerGroupCache();
|
||||
private Collection<GroupAdapter> groupAdapters = new ArrayList<>();
|
||||
|
||||
@Deprecated
|
||||
@ -177,6 +177,24 @@ public class DungeonsXL extends DREPlugin implements DungeonsAPI {
|
||||
|
||||
}
|
||||
|
||||
private class PlayerGroupCache extends Registry<String, PlayerGroup> {
|
||||
|
||||
@Override
|
||||
public PlayerGroup get(String key) {
|
||||
PlayerGroup group = elements.get(key);
|
||||
if (group != null) {
|
||||
return group;
|
||||
}
|
||||
for (PlayerGroup value : elements.values()) {
|
||||
if (((DGroup) value).getUntaggedName().equalsIgnoreCase(key)) {
|
||||
return value;
|
||||
}
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
private boolean loaded, loadingWorld;
|
||||
|
||||
private GlobalData globalData;
|
||||
|
@ -68,6 +68,7 @@ public class DGroup implements PlayerGroup {
|
||||
|
||||
private int id;
|
||||
private String name;
|
||||
private String untaggedName;
|
||||
private GroupSign groupSign;
|
||||
private Player captain;
|
||||
private PlayerCollection players = new PlayerCollection();
|
||||
@ -94,9 +95,10 @@ public class DGroup implements PlayerGroup {
|
||||
this.plugin = plugin;
|
||||
dPlayers = plugin.getPlayerCache();
|
||||
|
||||
plugin.getGroupCache().add(name, this);
|
||||
id = counter++;
|
||||
untaggedName = name;
|
||||
this.name = name + "#" + id;
|
||||
plugin.getGroupCache().add(this.name, this);
|
||||
|
||||
GroupPlayerJoinEvent event = new GroupPlayerJoinEvent(this, dPlayers.get(player), true);
|
||||
Bukkit.getPluginManager().callEvent(event);
|
||||
@ -123,9 +125,10 @@ public class DGroup implements PlayerGroup {
|
||||
this.plugin = plugin;
|
||||
dPlayers = plugin.getPlayerCache();
|
||||
|
||||
plugin.getGroupCache().add(name, this);
|
||||
id = counter++;
|
||||
untaggedName = name;
|
||||
this.name = name + "#" + id;
|
||||
plugin.getGroupCache().add(this.name, this);
|
||||
|
||||
GroupPlayerJoinEvent event = new GroupPlayerJoinEvent(this, dPlayers.get(captain), true);
|
||||
Bukkit.getPluginManager().callEvent(event);
|
||||
@ -169,6 +172,10 @@ public class DGroup implements PlayerGroup {
|
||||
this.name = name;
|
||||
}
|
||||
|
||||
public String getUntaggedName() {
|
||||
return untaggedName;
|
||||
}
|
||||
|
||||
public GroupSign getGroupSign() {
|
||||
return groupSign;
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user