Commit 907ca587 authored by Ashijin's avatar Ashijin
Browse files

Added Namespace, Permission options to all cosmetics

parent 3016885e
......@@ -34,6 +34,10 @@ public abstract class Cosmetic implements PropertyHolder,MenuData<CosmeticProfil
return maybeCosmetic.isPresent() && maybeCosmetic.get().equals(this);
}
public abstract String getId();
public abstract String getNamespace();
public abstract String getPermission();
public abstract boolean hasVariants();
......
package io.lumine.cosmetics.constants;
import io.lumine.cosmetics.api.cosmetics.Cosmetic;
public class Permissions {
public static final String cosmeticPermission(Cosmetic cosmetic) {
return "mccosmetics.cosmetic." + cosmetic.getKey().toLowerCase();
}
public static final String COSMETIC_PERMISSION_PREFIX = "mccosmetics.cosmetic.";
public static final String COMMAND_BASE = "mccosmetics.command.base";
......
......@@ -28,6 +28,8 @@ import java.util.Optional;
public abstract class AbstractCosmetic extends Cosmetic {
protected static final StringProp NAMESPACE = Property.String(Scope.NONE, "Namespace", null);
protected static final StringProp PERMISSION = Property.String(Scope.NONE, "Permission", null);
protected static final EnumProp<Material> MATERIAL = Property.Enum(Scope.NONE, Material.class, "Material", Material.EMERALD);
protected static final IntProp MODEL = Property.Int(Scope.NONE, "Model");
protected static final LangProp DISPLAY = Property.Lang(Scope.NONE, "Display");
......@@ -40,7 +42,10 @@ public abstract class AbstractCosmetic extends Cosmetic {
protected static final NodeListProp VARIANTS = Property.NodeList(Scope.NONE, "Variants");
protected final File file;
protected final String key;
@Getter protected final String id;
@Getter protected final String key;
@Getter protected final String namespace;
@Getter protected final String permission;
@Getter protected final List<String> sources = Lists.newArrayList();
// Menu Item
......@@ -60,6 +65,26 @@ public abstract class AbstractCosmetic extends Cosmetic {
this.file = file;
this.key = key;
this.namespace = NAMESPACE.fget(file,this);
if(namespace == null) {
this.id = key;
} else {
this.id = namespace + "." + key;
}
String perm = PERMISSION.fget(file,this);
if(perm == null) {
if(namespace == null) {
this.permission = Permissions.COSMETIC_PERMISSION_PREFIX + key.toLowerCase();
} else {
this.permission = Permissions.COSMETIC_PERMISSION_PREFIX + namespace.toLowerCase() + "." + key.toLowerCase();
}
} else {
this.permission = perm;
}
this.material = MATERIAL.fget(file,this);
this.model = MODEL.fget(file,this);
this.display = DISPLAY.fget(file,this);
......@@ -115,11 +140,7 @@ public abstract class AbstractCosmetic extends Cosmetic {
}
}).build();
}
public String getPermission() {
return Permissions.cosmeticPermission(this);
}
public boolean hasVariants() {
return variants.isEmpty() == false;
}
......
......@@ -54,7 +54,8 @@ public abstract class MCCosmeticsManager<T extends Cosmetic> extends ReloadableM
for(var file : files) {
for(var node : KEYS.fget(file)) {
cosmetics.put(node, build(file, node));
var cosmetic = build(file, node);
cosmetics.put(cosmetic.getId(), cosmetic);
}
}
......
......@@ -17,13 +17,13 @@ public class ProfileCosmeticData {
public ProfileCosmeticData(Cosmetic cosmetic) {
this.type = cosmetic.getType();
this.id = cosmetic.getKey();
this.id = cosmetic.getId();
this.variant = "default";
}
public ProfileCosmeticData(CosmeticVariant variant) {
this.type = variant.getCosmetic().getType();
this.id = variant.getCosmetic().getKey();
this.id = variant.getCosmetic().getId();
this.variant = variant.getKey();
}
......
......@@ -12,7 +12,7 @@
<url>https://www.lumine.io</url>
</organization>
<properties>
<properties>
<mccosmetics.version>0.4.0-SNAPSHOT</mccosmetics.version>
<paperapi.version>1.18.2-R0.1-SNAPSHOT</paperapi.version>
<lumineutils.version>1.18-SNAPSHOT</lumineutils.version>
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment