Skip to content

Commit

Permalink
Add command to list player's characters
Browse files Browse the repository at this point in the history
(cherry picked from commit 684712f)
  • Loading branch information
NeumimTo committed May 1, 2018
1 parent 3c90ebf commit 802a769
Show file tree
Hide file tree
Showing 3 changed files with 27 additions and 38 deletions.
10 changes: 10 additions & 0 deletions Plugin/src/main/java/cz/neumimto/rpg/NtRpgPlugin.java
Original file line number Diff line number Diff line change
Expand Up @@ -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))
Expand All @@ -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");
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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";
Expand All @@ -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";
Expand Down Expand Up @@ -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";
}
44 changes: 9 additions & 35 deletions Plugin/src/main/java/cz/neumimto/rpg/gui/VanillaMessaging.java
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand All @@ -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;
Expand Down Expand Up @@ -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.
*/
Expand Down Expand Up @@ -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(" +
Expand Down Expand Up @@ -375,7 +349,7 @@ public void sendListOfCharacters(final IActiveCharacter player, CharacterBase cu
.contents(content);
builder.sendTo(player.getEntity());

}).submit(plugin);
});
}

@Override
Expand Down

0 comments on commit 802a769

Please sign in to comment.