Package de.Keyle.MyPet.api
Class WorldGroup
java.lang.Object
de.Keyle.MyPet.api.WorldGroup
A named set of worlds that share pets. A pet belongs to exactly one group, so a player can keep a different pet in each. The
---DISABLED--- group marks worlds where MyPet does not run at all.-
Field Summary
FieldsModifier and TypeFieldDescriptionstatic final WorldGroupThe group every world falls into unless the config says otherwise.static final WorldGroupThe group for worlds MyPet is switched off in. -
Constructor Summary
ConstructorsConstructorDescriptionWorldGroup(String groupName, boolean disabled) Creates a group and registers it. -
Method Summary
Modifier and TypeMethodDescriptionbooleanAdds a world to this group, unless another group already claims it.static voidRemoves all worlds from the groups and then deletes the groups, leaving only the default and disabled groups.booleancontainsWorld(String worldName) Checks whether a world group contains the worldstatic WorldGroupgetGroupByName(String name) Returns the group by name.static WorldGroupgetGroupByWorld(String name) Returns the group the world is instatic WorldGroupgetGroupByWorld(World world) Returns the group the world is instatic Collection<WorldGroup> Returns all available world groupsgetName()This group's name, lower-cased.The worlds in this group.booleanWhether MyPet is switched off in this group's worlds.static voidloadGroups(File f) Reads every group from the given YAML file, then puts any world not mentioned into the default group.
-
Field Details
-
DEFAULT_GROUP
The group every world falls into unless the config says otherwise. -
DISABLED_GROUP
The group for worlds MyPet is switched off in.
-
-
Constructor Details
-
WorldGroup
Creates a group and registers it. A group whose name is already taken is not registered again.- Parameters:
groupName- the group's name; lower-cased on the way indisabled-trueto switch MyPet off in this group's worlds
-
-
Method Details
-
getWorlds
The worlds in this group.- Returns:
- the world names in this group; a read-only view, empty if the group is no longer registered
-
getGroups
Returns all available world groups- Returns:
Collection<WorldGroup>
-
getGroupByWorld
Returns the group the world is in- Parameters:
name- the world's name- Returns:
- the world's group, or
DISABLED_GROUPif no group claims the world (nevernull)
-
getGroupByWorld
Returns the group the world is in- Parameters:
world- the world- Returns:
- the world's group, or
DISABLED_GROUPif no group claims the world (nevernull)
-
getGroupByName
Returns the group by name. Group names are stored lower-cased, so the lookup ignores case.- Parameters:
name- the group's name- Returns:
- the group, or
DISABLED_GROUPif there is no group with that name (nevernull)
-
clearGroups
public static void clearGroups()Removes all worlds from the groups and then deletes the groups, leaving only the default and disabled groups. -
loadGroups
Reads every group from the given YAML file, then puts any world not mentioned into the default group. The new groups are built on the side and replace the old ones in a single step, so lookups running on other threads during a reload never see a half-loaded state. If reading fails, the old groups stay.- Parameters:
f- the world-groups configuration file
-
addWorld
Adds a world to this group, unless another group already claims it.- Parameters:
world- the world name to add- Returns:
trueif the world was added
-
containsWorld
Checks whether a world group contains the world- Parameters:
worldName- The name of the checked world- Returns:
- boolean
-
getName
This group's name, lower-cased.- Returns:
- the group name
-
isDisabled
public boolean isDisabled()Whether MyPet is switched off in this group's worlds.- Returns:
trueif pets are disabled here
-