mirror of
https://github.com/alexcrea/CustomAnvil.git
synced 2026-06-24 00:26:16 +02:00
Add material group
parent
7aadf29baf
commit
f48a492b17
1 changed files with 65 additions and 0 deletions
65
Material-Group.md
Normal file
65
Material-Group.md
Normal file
|
|
@ -0,0 +1,65 @@
|
|||
## What is a material group
|
||||
|
||||
A material group is a named collection of bukkit material that can accept other material group to be "added" to the group policy. \
|
||||
It is used in enchantment conflict (config wip)
|
||||
|
||||
|
||||
***
|
||||
|
||||
## Actual implementation of material group
|
||||
|
||||
The 2 implementation of material groups are IncludeGroup and ExcludeGroup. \
|
||||
It is recommended to use only IncludeGroup as it can be edited by admin at runtime via the gui.
|
||||
|
||||
* IncludeGroup policy is to include given materials and groups. It starts with an empty group. \
|
||||
* ExcludeGroup policy is to remove given materials and groups. It starts containing every material.
|
||||
|
||||
Include group is useful for most use case, while exclude group can be used as a "use every item excluding theses" and a "everything" group. \
|
||||
Adding a group to another group is not impacted by the type of group. For example, adding an empty exclude group ("everything group") to an include group will create an include group containing everything.
|
||||
|
||||
|
||||
***
|
||||
|
||||
## Create and register material group
|
||||
Here is an example of you could create a material group
|
||||
```java
|
||||
@EventHandler
|
||||
public void onConfigReady(){
|
||||
// Create group of zombie drops
|
||||
IncludeGroup zombieGroup = new IncludeGroup("zombieDrop");
|
||||
zombieGroup.addToPolicy(Material.ROTTEN_FLESH) // Please note "addToPolicy would be "exclude from group" for ExcludeGroup
|
||||
.addToPolicy(Material.ZOMBIE_HEAD)
|
||||
.addToPolicy(Material.IRON_INGOT)
|
||||
.addToPolicy(Material.POTATO)
|
||||
.addToPolicy(Material.CARROT);
|
||||
|
||||
// Create group of skeleton drops
|
||||
IncludeGroup skeletonGroup = new IncludeGroup("skeletonDrop");
|
||||
skeletonGroup.addToPolicy(Material.BONE)
|
||||
.addToPolicy(Material.ARROW)
|
||||
.addToPolicy(Material.SKELETON_SKULL);
|
||||
|
||||
// Create group of overworld undead drops
|
||||
IncludeGroup undeadGroup = new IncludeGroup("overworldUndeadDrop");
|
||||
undeadGroup.addToPolicy(zombieGroup).addToPolicy(skeletonGroup);
|
||||
|
||||
// Register groups
|
||||
MaterialGroupApi.addMaterialGroup(zombieGroup);
|
||||
MaterialGroupApi.addMaterialGroup(skeletonGroup);
|
||||
MaterialGroupApi.addMaterialGroup(undeadGroup);
|
||||
|
||||
// Create conflict (see appropriate doc) (wiki wip)
|
||||
// ...
|
||||
|
||||
}
|
||||
```
|
||||
|
||||
Material group can also be registered after the event is triggered. But not before.
|
||||
It will be triggered almost instantly after every plugin have initialized.
|
||||
|
||||
|
||||
***
|
||||
## Removing a material group.
|
||||
You may want to remove a material group via MaterialGroupApi. But it is not recommended and current implementation: If the group is not in use everything should be fine, but if not the case then it is unspecified behavior. (but probably will still be used until restart by the required conflict and group) \
|
||||
A better version of these function will be implemented in the incoming update.
|
||||
|
||||
Loading…
Add table
Add a link
Reference in a new issue