From 802a7691beb6f290b9ca4f3edc5109cbcf98b645 Mon Sep 17 00:00:00 2001 From: NeumimTo Date: Wed, 25 Apr 2018 20:48:11 +0200 Subject: [PATCH] Add command to list player's characters (cherry picked from commit 684712f) --- .../java/cz/neumimto/rpg/NtRpgPlugin.java | 10 +++++ .../configuration/CommandLocalization.java | 11 +++-- .../cz/neumimto/rpg/gui/VanillaMessaging.java | 44 ++++--------------- 3 files changed, 27 insertions(+), 38 deletions(-) diff --git a/Plugin/src/main/java/cz/neumimto/rpg/NtRpgPlugin.java b/Plugin/src/main/java/cz/neumimto/rpg/NtRpgPlugin.java index 1cb58c251..794039a92 100644 --- a/Plugin/src/main/java/cz/neumimto/rpg/NtRpgPlugin.java +++ b/Plugin/src/main/java/cz/neumimto/rpg/NtRpgPlugin.java @@ -1000,6 +1000,15 @@ public void registerCharacterCommands() { }) .build(); + CommandSpec cslist = CommandSpec.builder() + .description(TextSerializers.FORMATTING_CODE.deserialize(CommandLocalization.COMMAND_CHARACTE_LIST)) + .executor((src, args) -> { + IActiveCharacter character = GlobalScope.characterService.getCharacter(((Player) src).getUniqueId()); + Gui.sendListOfCharacters(character, character.getCharacterBase()); + return CommandResult.success(); + }) + .build(); + CommandSpec characterRoot = CommandSpec.builder() .description(TextSerializers.FORMATTING_CODE .deserialize(CommandLocalization.COMMAND_CHOOSE_DESC)) @@ -1008,6 +1017,7 @@ public void registerCharacterCommands() { .child(cskill, "skill", "s","sk") .child(cattribute, "attribute", "attr", "a") .child(cswitch, "switch") + .child(cslist, "list") .build(); Sponge.getCommandManager().register(this, characterRoot, "character", "char", "nc"); diff --git a/Plugin/src/main/java/cz/neumimto/rpg/configuration/CommandLocalization.java b/Plugin/src/main/java/cz/neumimto/rpg/configuration/CommandLocalization.java index dee2ea6b7..af4f373a9 100644 --- a/Plugin/src/main/java/cz/neumimto/rpg/configuration/CommandLocalization.java +++ b/Plugin/src/main/java/cz/neumimto/rpg/configuration/CommandLocalization.java @@ -27,8 +27,7 @@ @ConfigurationContainer(path = "{WorkingDir}", filename = "CommandLocalization.conf") public class CommandLocalization { - - @ConfigValue + @ConfigValue public static String COMMAND_ADMIN_ENCHANT = "&2Enchants held item with custom enchantment"; @ConfigValue public static String COMMAND_ADMIN_DESC = "&2Access to administration commands"; @@ -43,7 +42,7 @@ public class CommandLocalization { public static String COMMAND_ADMIN_SOCKET = "&2Inserts sockets into held item"; @ConfigValue - public static String COMMAND_ADMIN_RUNE = "&2Creates a rune";; + public static String COMMAND_ADMIN_RUNE = "&2Creates a rune"; @ConfigValue public static String COMMAND_ADMIN_RUNEWORD = "&2Tries to insert runeword into held item"; @@ -128,4 +127,10 @@ public class CommandLocalization { @ConfigValue public static String COMMAND_ADMIN_RARITY = "Sets rarity of current item type"; + + @ConfigValue + public static String COMMAND_ADMIN_ITEM_TYPE = "&2Sets item type"; + + @ConfigValue + public static String COMMAND_CHARACTE_LIST = "&2Lists all your characters"; } diff --git a/Plugin/src/main/java/cz/neumimto/rpg/gui/VanillaMessaging.java b/Plugin/src/main/java/cz/neumimto/rpg/gui/VanillaMessaging.java index c18b8be18..668e1ed14 100644 --- a/Plugin/src/main/java/cz/neumimto/rpg/gui/VanillaMessaging.java +++ b/Plugin/src/main/java/cz/neumimto/rpg/gui/VanillaMessaging.java @@ -18,31 +18,17 @@ package cz.neumimto.rpg.gui; -import static cz.neumimto.rpg.gui.GuiHelper.back; -import static cz.neumimto.rpg.gui.GuiHelper.createPlayerGroupView; -import static cz.neumimto.rpg.gui.GuiHelper.getItemLore; - import cz.neumimto.core.ioc.Inject; import cz.neumimto.core.ioc.IoC; import cz.neumimto.core.ioc.PostProcess; import cz.neumimto.core.ioc.Singleton; -import cz.neumimto.rpg.Arg; -import cz.neumimto.rpg.GroupService; -import cz.neumimto.rpg.NtRpgPlugin; -import cz.neumimto.rpg.Pair; -import cz.neumimto.rpg.ResourceLoader; -import cz.neumimto.rpg.TextHelper; +import cz.neumimto.rpg.*; import cz.neumimto.rpg.commands.InfoCommand; import cz.neumimto.rpg.configuration.CommandPermissions; import cz.neumimto.rpg.configuration.Localization; import cz.neumimto.rpg.configuration.PluginConfig; import cz.neumimto.rpg.damage.DamageService; -import cz.neumimto.rpg.effects.EffectService; -import cz.neumimto.rpg.effects.EffectSourceType; -import cz.neumimto.rpg.effects.EffectStatusType; -import cz.neumimto.rpg.effects.IEffect; -import cz.neumimto.rpg.effects.IEffectContainer; -import cz.neumimto.rpg.effects.InternalEffectSourceProvider; +import cz.neumimto.rpg.effects.*; import cz.neumimto.rpg.effects.common.def.BossBarExpNotifier; import cz.neumimto.rpg.effects.common.def.ManaBarNotifier; import cz.neumimto.rpg.inventory.CannotUseItemReson; @@ -59,11 +45,7 @@ import cz.neumimto.rpg.inventory.runewords.RuneWord; import cz.neumimto.rpg.persistance.DirectAccessDao; import cz.neumimto.rpg.persistance.model.CharacterClass; -import cz.neumimto.rpg.players.CharacterBase; -import cz.neumimto.rpg.players.CharacterService; -import cz.neumimto.rpg.players.ExtendedNClass; -import cz.neumimto.rpg.players.IActiveCharacter; -import cz.neumimto.rpg.players.SkillTreeViewModel; +import cz.neumimto.rpg.players.*; import cz.neumimto.rpg.players.groups.ConfigClass; import cz.neumimto.rpg.players.groups.PlayerGroup; import cz.neumimto.rpg.players.groups.Race; @@ -107,20 +89,12 @@ import org.spongepowered.api.text.format.TextColors; import org.spongepowered.api.text.format.TextStyles; import org.spongepowered.api.util.Color; -import org.spongepowered.api.util.Direction; - -import java.util.ArrayList; -import java.util.Collection; -import java.util.Collections; -import java.util.HashMap; -import java.util.Iterator; -import java.util.List; -import java.util.Map; -import java.util.Optional; -import java.util.Set; -import java.util.TreeSet; + +import java.util.*; import java.util.concurrent.TimeUnit; +import static cz.neumimto.rpg.gui.GuiHelper.*; + /** * Created by NeumimTo on 6.8.2015. */ @@ -329,7 +303,7 @@ public void showClassInfo(IActiveCharacter character, ConfigClass cc) { public void sendListOfCharacters(final IActiveCharacter player, CharacterBase currentlyCreated) { PaginationService paginationService = Sponge.getServiceManager().provide(PaginationService.class).get(); PaginationList.Builder builder = paginationService.builder(); - Sponge.getScheduler().createTaskBuilder().async().execute(() -> { + NtRpgPlugin.asyncExecutor.execute(() -> { DirectAccessDao build = IoC.get().build(DirectAccessDao.class); //language=HQL String query = "select new cz.neumimto.rpg.utils.model.CharacterListModel(" + @@ -375,7 +349,7 @@ public void sendListOfCharacters(final IActiveCharacter player, CharacterBase cu .contents(content); builder.sendTo(player.getEntity()); - }).submit(plugin); + }); } @Override