update naar UltimateKingdom 1.1.x

This commit is contained in:
webadmin 2022-09-03 18:15:45 +02:00
parent 31ce546e53
commit a027b19399
3 changed files with 40 additions and 54 deletions

View File

@ -20,9 +20,8 @@ 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.0.15-ALPHA' compileOnly 'me.map:ultimatekingdom:1.1.1-ALPHA'
} }

View File

@ -1,5 +1,6 @@
package me.map.example; package me.map.example;
import jdk.incubator.vector.VectorOperators;
import me.map.example.command.TestCommand; import me.map.example.command.TestCommand;
import me.map.example.listener.Luisteraar; import me.map.example.listener.Luisteraar;
import me.map.example.placeholder.OwnPlaceHolder; import me.map.example.placeholder.OwnPlaceHolder;
@ -42,7 +43,7 @@ public class Example extends JavaPlugin {
Kingdom kingdom = kingdomPlayer.getKingdom(); Kingdom kingdom = kingdomPlayer.getKingdom();
//toevoegen nieuwe commando //toevoegen nieuwe commando
UltimateKingdom.getKingdomServer().Commands().register(new TestCommand(this)); new TestCommand(); // of als er geen register() in commando is -> new TestCommand().register();
//vertaling toevoegen //vertaling toevoegen
UltimateKingdom.getKingdomServer().Message().addTranslations("test_command" ,"^&adit is kingdom: &f{0} &aen player ^&f{1}"); UltimateKingdom.getKingdomServer().Message().addTranslations("test_command" ,"^&adit is kingdom: &f{0} &aen player ^&f{1}");

View File

@ -1,71 +1,57 @@
package me.map.example.command; package me.map.example.command;
import me.map.example.Example;
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.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.exceptions.UnknownSetting;
import me.map.ultimatekingdom.API.objects.KingdomPlayer; import me.map.ultimatekingdom.API.objects.KingdomPlayer;
import me.map.ultimatekingdom.API.objects.PluginCommands; import me.map.ultimatekingdom.API.objects.PluginCommand;
import me.map.ultimatekingdom.API.settings.BooleanSetting; import me.map.ultimatekingdom.API.settings.BooleanSetting;
import me.map.ultimatekingdom.API.settings.Setting;
import me.map.ultimatekingdom.UltimateKingdomPlugin;
import org.bukkit.Bukkit;
import org.bukkit.command.CommandExecutor;
import org.bukkit.command.CommandSender;
import org.bukkit.entity.HumanEntity;
import org.bukkit.entity.Player; import org.bukkit.entity.Player;
import java.util.ArrayList;
import java.util.List;
import java.util.UUID;
import java.util.stream.Collectors;
public class TestCommand extends PluginCommands { public class TestCommand extends PluginCommand {
private final Example main; public TestCommand() {
public TestCommand(Example main) { super("testcommand");
setDescription(UltimateKingdom.translate(false, "test_command"));
super("testcommand", "kingdom.admin", false, "<player>"); setPermission("kingdom.admin"); //optional
this.main = main; setShowUsageOnFail(true); //optional
this.setDescription(UltimateKingdom.translate(false, "test_command")); setPlayerOnly(true); //optional
//this.setDescription("test commando"); register(); //very
}
@Override
public boolean execute(CommandSender sender, String[] args) {
if (args.length != 1) {
return false;
}
final String username = args[0];
UUID uuid = UltimateKingdom.findUUID(username);
// result uuid with username or null
if (uuid == null) {
UltimateKingdom.send(sender, UltimateKingdom.translate("noPlayer"));
return true;
}
final KingdomPlayer user = UltimateKingdom.Players().getPlayer(uuid);
BooleanSetting setting = KingdomSettings.kingdomplayer_is_mod;
setting.setValue(Boolean.TRUE);
user.setSetting(setting);
return true;
} }
@Override @Override
public List<String> tabcomplete(CommandSender sender, String[] args) { protected void createCommand(BrigadierCommand command) {
if (!sender.hasPermission(this.getPermission())) return new ArrayList<>(); command
.then(argument("player", KingdomPlayerArgumentType.kingdomplayer())
.executes(c -> {
final KingdomPlayer kingdomPlayer = c.getArgument("player",KingdomPlayer.class);
BooleanSetting setting = KingdomSettings.kingdomplayer_is_mod;
setting.setValue(Boolean.TRUE);
if (args.length == 2) { try {
return Bukkit.getOnlinePlayers().stream().filter(p -> p != sender).filter(p -> p.getName().regionMatches(true, 0, args[1], 0, args[1].length())).map(HumanEntity::getName).collect(Collectors.toList()); kingdomPlayer.setSetting(setting);
} } catch (UnknownSetting e) {
e.printStackTrace();
}
return new ArrayList<>(); return Command.SINGLE_SUCCESS;
})
);
} }
@Override
public void onCommandComplete(CommandContext<CommandSource> commandContext, boolean b, int i) {
//hier kan je nog wat doen na het uitvoeren van createCommand
}
} }