update naar UltimateKingdom 1.1.x
This commit is contained in:
parent
a027b19399
commit
c5c718fe50
|
@ -21,7 +21,7 @@ repositories {
|
|||
|
||||
dependencies {
|
||||
compileOnly "org.spigotmc:spigot:1.8-R0.1-SNAPSHOT"
|
||||
compileOnly 'me.map:ultimatekingdom:1.1.1-ALPHA'
|
||||
compileOnly 'me.map:ultimatekingdom:1.3.6-ALPHA'
|
||||
}
|
||||
|
||||
|
||||
|
|
|
@ -5,11 +5,12 @@ import me.map.mojangbrigadier.Command;
|
|||
import me.map.mojangbrigadier.context.CommandContext;
|
||||
import me.map.newbrigadier.API.CommandSource;
|
||||
import me.map.newbrigadier.API.command.BrigadierCommand;
|
||||
import me.map.newbrigadier.API.types.PlayerArgumentType;
|
||||
|
||||
import me.map.ultimatekingdom.API.KingdomSettings;
|
||||
import me.map.ultimatekingdom.API.UltimateKingdom;
|
||||
import me.map.ultimatekingdom.API.commands.arguments.KingdomPlayerArgumentType;
|
||||
import me.map.ultimatekingdom.API.exceptions.UnknownSetting;
|
||||
|
||||
import me.map.ultimatekingdom.API.commands.arguments.exceptions.UnknownSetting;
|
||||
import me.map.ultimatekingdom.API.objects.KingdomPlayer;
|
||||
import me.map.ultimatekingdom.API.objects.PluginCommand;
|
||||
import me.map.ultimatekingdom.API.settings.BooleanSetting;
|
||||
|
@ -25,7 +26,7 @@ public class TestCommand extends PluginCommand {
|
|||
setPermission("kingdom.admin"); //optional
|
||||
setShowUsageOnFail(true); //optional
|
||||
setPlayerOnly(true); //optional
|
||||
register(); //very
|
||||
register(); //optional
|
||||
}
|
||||
|
||||
|
||||
|
|
114
src/main/java/me/map/example/metadata.java
Normal file
114
src/main/java/me/map/example/metadata.java
Normal file
|
@ -0,0 +1,114 @@
|
|||
package me.map.example;
|
||||
|
||||
import me.map.ultimatekingdom.API.objects.Kingdom;
|
||||
import me.map.ultimatekingdom.API.objects.data.*;
|
||||
import java.util.ArrayList;
|
||||
import java.util.HashMap;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
|
||||
public class metadata {
|
||||
|
||||
public void addMetaData(Kingdom kingdom) {
|
||||
|
||||
//create list
|
||||
List<String> metaArrayList = new ArrayList<>();
|
||||
|
||||
//check for existing data
|
||||
if (kingdom.hasMeta("customMetaName")) {
|
||||
|
||||
MetaData<?> data = kingdom.getMetadata("customMetaName");
|
||||
|
||||
//get value (List)
|
||||
metaArrayList = (List<String>) data.getValue();
|
||||
|
||||
//get label if you need it.
|
||||
String label = data.getLabel();
|
||||
|
||||
//or just use this one
|
||||
metaArrayList = (List<String>) kingdom.getMetadata("customMetaName").getValue();
|
||||
}
|
||||
|
||||
|
||||
//add value.
|
||||
metaArrayList.add("bla");
|
||||
|
||||
//convert list to metadata and save
|
||||
MetaData<?> myMetaData = new ListField("customMetaName", metaArrayList);
|
||||
//or save with a extra label,
|
||||
MetaData<?> myMetaData2 = new ListField("customMetaName", metaArrayList,"ExtraLabel" );
|
||||
//savedata
|
||||
kingdom.addMetaData(myMetaData);
|
||||
|
||||
}
|
||||
|
||||
public void removeMetaData(Kingdom kingdom) {
|
||||
|
||||
List<String> metaArrayList = new ArrayList<>();
|
||||
|
||||
if (kingdom.hasMeta("customMetaName")) {
|
||||
metaArrayList = (List<String>) kingdom.getMetadata("customMetaName").getValue();
|
||||
}
|
||||
|
||||
//remove value
|
||||
metaArrayList.remove("bla");
|
||||
|
||||
//convert and save to kingdom
|
||||
MetaData<?> myMetaData = new ListField("customMetaName", metaArrayList);
|
||||
// convert with a label.
|
||||
|
||||
MetaData<?> myMetaData2 = new ListField("customMetaName", metaArrayList,"ExtraLabel" );
|
||||
kingdom.addMetaData(myMetaData);
|
||||
|
||||
|
||||
|
||||
//remove all values
|
||||
kingdom.removeMetaData(myMetaData);
|
||||
}
|
||||
|
||||
|
||||
|
||||
public void test () {
|
||||
|
||||
//boolean
|
||||
boolean booleanMeta = true;
|
||||
MetaData<?> booleanMetaData = new BooleanDataField("customMetaName", booleanMeta);
|
||||
MetaData<?> booleanMetaData2 = new BooleanDataField("customMetaName", booleanMeta,"ExtraLabel" );
|
||||
|
||||
//Integer
|
||||
Integer integermeta = 1;
|
||||
MetaData<?> integerDataField = new IntegerDataField("customMetaName", integermeta);
|
||||
MetaData<?> integerDataField1 = new IntegerDataField("customMetaName", integermeta,"ExtraLabel" );
|
||||
|
||||
//Double
|
||||
Double doubevalue = 0.1;
|
||||
MetaData<?> decimalDataField = new DecimalDataField("customMetaName", doubevalue);
|
||||
MetaData<?> decimalDataField1 = new DecimalDataField("customMetaName", doubevalue,"doubevalue" );
|
||||
|
||||
//Long
|
||||
Long longvalue = 10L;
|
||||
MetaData<?> longDataField = new LongDataField("customMetaName", longvalue);
|
||||
MetaData<?> longDataField1 = new LongDataField("customMetaName", longvalue,"longvalue" );
|
||||
|
||||
//String
|
||||
String stringvalue = "string";
|
||||
MetaData<?> stringDataField = new StringDataField("customMetaName", stringvalue);
|
||||
MetaData<?> stringDataField1 = new StringDataField("customMetaName", stringvalue,"longvalue" );
|
||||
|
||||
// arraylist <String>
|
||||
List<String> metaArrayList = new ArrayList<>(); //
|
||||
MetaData<?> listField = new ListField("customMetaName", metaArrayList);
|
||||
MetaData<?> listField1 = new ListField("customMetaName", metaArrayList,"ExtraLabel" );
|
||||
|
||||
//Hashmap <String,boolean>
|
||||
Map<String,Integer> metaHashmap = new HashMap();
|
||||
MetaData<?> hashMapStringIntegerField = new HashMapStringIntegerField("customMetaName", metaHashmap);
|
||||
MetaData<?> hashMapStringIntegerField1 = new HashMapStringIntegerField("customMetaName", metaHashmap,"ExtraLabel");
|
||||
|
||||
//Hashmap <String,Integer>
|
||||
Map<String,Boolean> metaHashmap2 = new HashMap();
|
||||
MetaData<?> hashMapStringBooleanField = new HashMapStringBooleanField("customMetaName", metaHashmap2);
|
||||
MetaData<?> hashMapStringBooleanField1 = new HashMapStringBooleanField("customMetaName", metaHashmap2,"ExtraLabel");
|
||||
}
|
||||
|
||||
}
|
Loading…
Reference in New Issue
Block a user