Improves button and material customization
Allows specifying a comma-separated list of materials and tags for a portal's button, open-material, closed-material and border blocks. A random value is used if more than one material is available.0 Uses the supplied button if any, instead of enforcing the specified button material. Always protects the button against block breaking. Fixes an incorrect permission result in the previous commit, which caused players stargate access to be inverted.
This commit is contained in:
@@ -0,0 +1,36 @@
|
||||
package net.knarcraft.stargate.config.material;
|
||||
|
||||
import org.bukkit.Material;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
|
||||
import java.util.Set;
|
||||
|
||||
/**
|
||||
* A specifier for a Bukkit material
|
||||
*/
|
||||
public class BukkitMaterialSpecifier implements MaterialSpecifier {
|
||||
|
||||
private final Material material;
|
||||
|
||||
/**
|
||||
* Instantiates a new material specifier
|
||||
*
|
||||
* @param material <p>The material to specify</p>
|
||||
*/
|
||||
public BukkitMaterialSpecifier(@NotNull Material material) {
|
||||
this.material = material;
|
||||
}
|
||||
|
||||
@Override
|
||||
@NotNull
|
||||
public String asString() {
|
||||
return this.material.name();
|
||||
}
|
||||
|
||||
@Override
|
||||
@NotNull
|
||||
public Set<Material> asMaterials() {
|
||||
return Set.of(this.material);
|
||||
}
|
||||
|
||||
}
|
@@ -0,0 +1,35 @@
|
||||
package net.knarcraft.stargate.config.material;
|
||||
|
||||
import org.bukkit.Material;
|
||||
import org.bukkit.Tag;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
|
||||
import java.util.Set;
|
||||
|
||||
/**
|
||||
* A specifier for a Bukkit material tag
|
||||
*/
|
||||
public class BukkitTagSpecifier implements MaterialSpecifier {
|
||||
|
||||
private final Tag<Material> tag;
|
||||
|
||||
/**
|
||||
* Instantiates a new tag specifier
|
||||
*
|
||||
* @param tag <p>The tag to specify</p>
|
||||
*/
|
||||
public BukkitTagSpecifier(@NotNull Tag<Material> tag) {
|
||||
this.tag = tag;
|
||||
}
|
||||
|
||||
@Override
|
||||
public @NotNull String asString() {
|
||||
return "#" + this.tag.getKey().toString().replaceFirst("minecraft:", "");
|
||||
}
|
||||
|
||||
@Override
|
||||
public @NotNull Set<Material> asMaterials() {
|
||||
return this.tag.getValues();
|
||||
}
|
||||
|
||||
}
|
@@ -0,0 +1,29 @@
|
||||
package net.knarcraft.stargate.config.material;
|
||||
|
||||
import org.bukkit.Material;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
|
||||
import java.util.Set;
|
||||
|
||||
/**
|
||||
* An interface describing a specifier for one or more Bukkit materials
|
||||
*/
|
||||
public interface MaterialSpecifier {
|
||||
|
||||
/**
|
||||
* Gets the string representation of the material specifier
|
||||
*
|
||||
* <p>This is used when saving the value to a gate file</p>
|
||||
*/
|
||||
@NotNull
|
||||
String asString();
|
||||
|
||||
/**
|
||||
* Gets all the materials the specifier specifies
|
||||
*
|
||||
* <p>This is used when registering gate materials</p>
|
||||
*/
|
||||
@NotNull
|
||||
Set<Material> asMaterials();
|
||||
|
||||
}
|
Reference in New Issue
Block a user