update naar UltimateKingdom 1.7.x
This commit is contained in:
parent
c5c718fe50
commit
c27aeb1c48
|
@ -14,4 +14,7 @@
|
||||||
</option>
|
</option>
|
||||||
</component>
|
</component>
|
||||||
<component name="ProjectRootManager" version="2" languageLevel="JDK_16" default="true" project-jdk-name="openjdk-16" project-jdk-type="JavaSDK" />
|
<component name="ProjectRootManager" version="2" languageLevel="JDK_16" default="true" project-jdk-name="openjdk-16" project-jdk-type="JavaSDK" />
|
||||||
|
<component name="ProjectType">
|
||||||
|
<option name="id" value="jpab" />
|
||||||
|
</component>
|
||||||
</project>
|
</project>
|
|
@ -21,7 +21,7 @@ repositories {
|
||||||
|
|
||||||
dependencies {
|
dependencies {
|
||||||
compileOnly "org.spigotmc:spigot:1.8-R0.1-SNAPSHOT"
|
compileOnly "org.spigotmc:spigot:1.8-R0.1-SNAPSHOT"
|
||||||
compileOnly 'me.map:ultimatekingdom:1.3.6-ALPHA'
|
compileOnly 'me.map:ultimatekingdom:ALPHA-1.7.37'
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
|
@ -3,21 +3,17 @@ package me.map.example.command;
|
||||||
|
|
||||||
import me.map.mojangbrigadier.Command;
|
import me.map.mojangbrigadier.Command;
|
||||||
import me.map.mojangbrigadier.context.CommandContext;
|
import me.map.mojangbrigadier.context.CommandContext;
|
||||||
import me.map.newbrigadier.API.CommandSource;
|
|
||||||
import me.map.newbrigadier.API.command.BrigadierCommand;
|
|
||||||
|
|
||||||
import me.map.ultimatekingdom.API.KingdomSettings;
|
|
||||||
import me.map.ultimatekingdom.API.UltimateKingdom;
|
import me.map.ultimatekingdom.API.UltimateKingdom;
|
||||||
import me.map.ultimatekingdom.API.commands.arguments.KingdomPlayerArgumentType;
|
import me.map.ultimatekingdom.API.cmd.AbstractCommand;
|
||||||
|
|
||||||
import me.map.ultimatekingdom.API.commands.arguments.exceptions.UnknownSetting;
|
import me.map.ultimatekingdom.API.cmd.CommandSource;
|
||||||
|
import me.map.ultimatekingdom.API.cmd.KingdomCommand;
|
||||||
|
import me.map.ultimatekingdom.API.cmd.args.plugin.KingdomPlayerArgumentType;
|
||||||
import me.map.ultimatekingdom.API.objects.KingdomPlayer;
|
import me.map.ultimatekingdom.API.objects.KingdomPlayer;
|
||||||
import me.map.ultimatekingdom.API.objects.PluginCommand;
|
|
||||||
import me.map.ultimatekingdom.API.settings.BooleanSetting;
|
|
||||||
import org.bukkit.entity.Player;
|
|
||||||
|
|
||||||
|
|
||||||
public class TestCommand extends PluginCommand {
|
|
||||||
|
public class TestCommand extends AbstractCommand {
|
||||||
|
|
||||||
|
|
||||||
public TestCommand() {
|
public TestCommand() {
|
||||||
|
@ -31,19 +27,14 @@ public class TestCommand extends PluginCommand {
|
||||||
|
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
protected void createCommand(BrigadierCommand command) {
|
protected void createCommand(KingdomCommand command) {
|
||||||
command
|
command
|
||||||
.then(argument("player", KingdomPlayerArgumentType.kingdomplayer())
|
.then(argument("player", KingdomPlayerArgumentType.kingdomplayer())
|
||||||
.executes(c -> {
|
.executes(c -> {
|
||||||
final KingdomPlayer kingdomPlayer = c.getArgument("player",KingdomPlayer.class);
|
final KingdomPlayer kingdomPlayer = c.getArgument("player",KingdomPlayer.class);
|
||||||
BooleanSetting setting = KingdomSettings.kingdomplayer_is_mod;
|
|
||||||
setting.setValue(Boolean.TRUE);
|
|
||||||
|
|
||||||
try {
|
|
||||||
kingdomPlayer.setSetting(setting);
|
|
||||||
} catch (UnknownSetting e) {
|
|
||||||
e.printStackTrace();
|
|
||||||
}
|
|
||||||
|
|
||||||
return Command.SINGLE_SUCCESS;
|
return Command.SINGLE_SUCCESS;
|
||||||
})
|
})
|
||||||
|
@ -53,6 +44,8 @@ public class TestCommand extends PluginCommand {
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void onCommandComplete(CommandContext<CommandSource> commandContext, boolean b, int i) {
|
public void onCommandComplete(CommandContext<CommandSource> commandContext, boolean b, int i) {
|
||||||
//hier kan je nog wat doen na het uitvoeren van createCommand
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,10 +1,8 @@
|
||||||
package me.map.example.listener;
|
package me.map.example.listener;
|
||||||
|
|
||||||
import me.map.ultimatekingdom.API.KingdomSettings;
|
|
||||||
|
|
||||||
import me.map.ultimatekingdom.API.events.KingdomPlayerLoadEvent;
|
import me.map.ultimatekingdom.gameplay.KingdomAction;
|
||||||
import me.map.ultimatekingdom.API.objects.KingdomPlayer;
|
import me.map.ultimatekingdom.gameplay.events.actions.KingdomBuildEvent;
|
||||||
import me.map.ultimatekingdom.API.settings.BooleanSetting;
|
|
||||||
import org.bukkit.event.EventHandler;
|
import org.bukkit.event.EventHandler;
|
||||||
import org.bukkit.event.EventPriority;
|
import org.bukkit.event.EventPriority;
|
||||||
import org.bukkit.event.Listener;
|
import org.bukkit.event.Listener;
|
||||||
|
@ -12,18 +10,9 @@ import org.bukkit.event.Listener;
|
||||||
public class Luisteraar implements Listener {
|
public class Luisteraar implements Listener {
|
||||||
|
|
||||||
@EventHandler(priority = EventPriority.LOWEST)
|
@EventHandler(priority = EventPriority.LOWEST)
|
||||||
public void onJoin(KingdomPlayerLoadEvent event) {
|
public void onJoin(KingdomBuildEvent event) {
|
||||||
|
|
||||||
BooleanSetting setting = KingdomSettings.kingdomplayer_is_mod;
|
|
||||||
KingdomPlayer user = event.getKingdomPlayer();
|
|
||||||
|
|
||||||
if (user.hasSetting(setting)) {
|
|
||||||
BooleanSetting userSetting = (BooleanSetting) user.getSetting(setting);
|
|
||||||
System.out.println(userSetting.getDisplayValue());
|
|
||||||
}
|
|
||||||
|
|
||||||
if (user.getKingdom() != null) {
|
|
||||||
System.out.println(user.getKingdom().getPrefixedName());
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,7 +1,7 @@
|
||||||
package me.map.example;
|
package me.map.example;
|
||||||
|
|
||||||
import me.map.ultimatekingdom.API.objects.Kingdom;
|
import me.map.ultimatekingdom.API.objects.Kingdom;
|
||||||
import me.map.ultimatekingdom.API.objects.data.*;
|
import me.map.ultimatekingdom.Shared.metadata.*;
|
||||||
|
|
||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
import java.util.HashMap;
|
import java.util.HashMap;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
@ -17,7 +17,7 @@ public class metadata {
|
||||||
//check for existing data
|
//check for existing data
|
||||||
if (kingdom.hasMeta("customMetaName")) {
|
if (kingdom.hasMeta("customMetaName")) {
|
||||||
|
|
||||||
MetaData<?> data = kingdom.getMetadata("customMetaName");
|
MetaData<?> data = kingdom.getMetaData("customMetaName");
|
||||||
|
|
||||||
//get value (List)
|
//get value (List)
|
||||||
metaArrayList = (List<String>) data.getValue();
|
metaArrayList = (List<String>) data.getValue();
|
||||||
|
@ -26,7 +26,7 @@ public class metadata {
|
||||||
String label = data.getLabel();
|
String label = data.getLabel();
|
||||||
|
|
||||||
//or just use this one
|
//or just use this one
|
||||||
metaArrayList = (List<String>) kingdom.getMetadata("customMetaName").getValue();
|
metaArrayList = (List<String>) kingdom.getMetaData("customMetaName").getValue();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@ -38,7 +38,14 @@ public class metadata {
|
||||||
//or save with a extra label,
|
//or save with a extra label,
|
||||||
MetaData<?> myMetaData2 = new ListField("customMetaName", metaArrayList,"ExtraLabel" );
|
MetaData<?> myMetaData2 = new ListField("customMetaName", metaArrayList,"ExtraLabel" );
|
||||||
//savedata
|
//savedata
|
||||||
kingdom.addMetaData(myMetaData);
|
|
||||||
|
kingdom.addMetaData(myMetaData,(result) -> {
|
||||||
|
if (result.isOk()) {
|
||||||
|
//do something
|
||||||
|
} else {
|
||||||
|
// get result.toString();
|
||||||
|
}
|
||||||
|
});
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -47,7 +54,7 @@ public class metadata {
|
||||||
List<String> metaArrayList = new ArrayList<>();
|
List<String> metaArrayList = new ArrayList<>();
|
||||||
|
|
||||||
if (kingdom.hasMeta("customMetaName")) {
|
if (kingdom.hasMeta("customMetaName")) {
|
||||||
metaArrayList = (List<String>) kingdom.getMetadata("customMetaName").getValue();
|
metaArrayList = (List<String>) kingdom.getMetaData("customMetaName").getValue();
|
||||||
}
|
}
|
||||||
|
|
||||||
//remove value
|
//remove value
|
||||||
|
@ -58,16 +65,29 @@ public class metadata {
|
||||||
// convert with a label.
|
// convert with a label.
|
||||||
|
|
||||||
MetaData<?> myMetaData2 = new ListField("customMetaName", metaArrayList,"ExtraLabel" );
|
MetaData<?> myMetaData2 = new ListField("customMetaName", metaArrayList,"ExtraLabel" );
|
||||||
kingdom.addMetaData(myMetaData);
|
|
||||||
|
|
||||||
|
|
||||||
|
kingdom.addMetaData(myMetaData, (result) ->{
|
||||||
|
if (result.isOk()) {
|
||||||
|
//do somehting
|
||||||
|
} else {
|
||||||
|
System.err.println(result.toString());//print error
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
});
|
||||||
|
|
||||||
|
|
||||||
//remove all values
|
//remove all values
|
||||||
kingdom.removeMetaData(myMetaData);
|
kingdom.removeMetaData(myMetaData,(result) ->{
|
||||||
|
if (result.isOk()) {
|
||||||
|
|
||||||
|
} else {
|
||||||
|
System.err.println(result.toString());
|
||||||
|
}
|
||||||
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
public void test () {
|
public void test () {
|
||||||
|
|
||||||
//boolean
|
//boolean
|
||||||
|
|
Loading…
Reference in New Issue
Block a user