From fdf82833ca7b4525809e6f3548ffc93d99189997 Mon Sep 17 00:00:00 2001 From: HorridoJoho <HorridoJoho@l2jserver.com> Date: Sat, 11 Jun 2022 00:07:23 +0200 Subject: [PATCH] Added BufferService commands 3 commands were added to the BufferService. One to show any html and commands to select and deselect a buff category, like with the unique bufflists. See documentation.txt --- .../custom/service/buffer/BufferService.java | 43 ++++++++++- .../buffer/BufferServiceRepository.java | 16 +++- .../service/buffer/model/GlobalConfig.java | 8 +- .../data/service/buffer/documentation.txt | 77 +++++++++++++++++++ 4 files changed, 139 insertions(+), 5 deletions(-) create mode 100644 src/main/resources/data/service/buffer/documentation.txt diff --git a/src/main/java/com/l2jserver/datapack/custom/service/buffer/BufferService.java b/src/main/java/com/l2jserver/datapack/custom/service/buffer/BufferService.java index 63fe36831d..32d3849572 100644 --- a/src/main/java/com/l2jserver/datapack/custom/service/buffer/BufferService.java +++ b/src/main/java/com/l2jserver/datapack/custom/service/buffer/BufferService.java @@ -1,5 +1,5 @@ /* - * Copyright © 2004-2021 L2J DataPack + * Copyright © 2004-2022 L2J DataPack * * This file is part of L2J DataPack. * @@ -76,6 +76,7 @@ public final class BufferService extends CustomServiceScript { private static final Map<Integer, Long> LAST_PLAYABLES_HEAL_TIME = new ConcurrentHashMap<>(); private static final Map<Integer, String> ACTIVE_PLAYER_BUFFLISTS = new ConcurrentHashMap<>(); + private static final Map<Integer, String> ACTIVE_PLAYER_CATEGORIES = new ConcurrentHashMap<>(); BufferService() { super(SCRIPT_NAME); @@ -115,6 +116,14 @@ public final class BufferService extends CustomServiceScript { placeholders.put("active_unique", ulistPlaceholder); } } + + String activeCategoryId = ACTIVE_PLAYER_CATEGORIES.get(player.getObjectId()); + if (activeCategoryId != null) { + HTMLTemplatePlaceholder catPlaceholder = BufferServiceRepository.getInstance().getBuffCategoryPlaceholder(activeCategoryId); + if (catPlaceholder != null) { + placeholders.put("active_category", catPlaceholder); + } + } HTMLTemplatePlaceholder playerPlaceholder = new HTMLTemplatePlaceholder("player", null); playerPlaceholder.addChild("name", player.getName()); @@ -126,6 +135,11 @@ public final class BufferService extends CustomServiceScript { super.showAdvancedHtml(player, buffer, npc, htmlPath, placeholders); } + private boolean htmlShowAny(L2PcInstance player, AbstractBuffer buffer, L2Npc npc, String html) { + showAdvancedHtml(player, buffer, npc, html, new HashMap<>()); + return true; + } + private boolean htmlShowMain(L2PcInstance player, AbstractBuffer buffer, L2Npc npc) { showAdvancedHtml(player, buffer, npc, "main.html", new HashMap<>()); return true; @@ -376,6 +390,27 @@ public final class BufferService extends CustomServiceScript { } } + private void categorySelect(L2PcInstance player, AbstractBuffer buffer, String categoryIdent) { + BuffCategory cat = buffer.getBuffCats().get(categoryIdent); + if (cat == null) { + return; + } + + ACTIVE_PLAYER_CATEGORIES.put(player.getObjectId(), categoryIdent); + } + + private void categoryDeselect(L2PcInstance player) { + ACTIVE_PLAYER_CATEGORIES.remove(player.getObjectId()); + } + + private void executeCategoryCommand(L2PcInstance player, AbstractBuffer buffer, CommandProcessor command) { + if (command.matchAndRemove("select ", "s ")) { + categorySelect(player, buffer, command.getRemaining()); + } else if (command.matchAndRemove("deselect ", "des ")) { + categoryDeselect(player); + } + } + private boolean uniqueCreate(L2PcInstance player, String uniqueName) { if (!BufferServiceRepository.getInstance().canHaveMoreBufflists(player)) { player.sendMessage("Maximum number of unique bufflists reached!"); @@ -491,7 +526,9 @@ public final class BufferService extends CustomServiceScript { return false; } - if (command.matchAndRemove("main", "m")) { + if (command.matchAndRemove("any ", "a ")) { + return htmlShowAny(player, buffer, npc, command.getRemaining()); + } else if (command.matchAndRemove("main", "m")) { return htmlShowMain(player, buffer, npc); } else if (command.matchAndRemove("category ", "c ")) { return htmlShowCategory(player, buffer, npc, command.getRemaining()); @@ -552,6 +589,8 @@ public final class BufferService extends CustomServiceScript { if (command.matchAndRemove("target ", "t ")) { executeTargetCommand(player, buffer, command); + } else if (command.matchAndRemove("category ", "c ")) { + executeCategoryCommand(player, buffer, command); } else if (command.matchAndRemove("unique ", "u ")) { executeUniqueCommand(player, buffer, command); } diff --git a/src/main/java/com/l2jserver/datapack/custom/service/buffer/BufferServiceRepository.java b/src/main/java/com/l2jserver/datapack/custom/service/buffer/BufferServiceRepository.java index b709600b36..a274192e04 100644 --- a/src/main/java/com/l2jserver/datapack/custom/service/buffer/BufferServiceRepository.java +++ b/src/main/java/com/l2jserver/datapack/custom/service/buffer/BufferServiceRepository.java @@ -1,5 +1,5 @@ /* - * Copyright © 2004-2021 L2J DataPack + * Copyright © 2004-2022 L2J DataPack * * This file is part of L2J DataPack. * @@ -34,6 +34,7 @@ import com.l2jserver.commons.database.ConnectionFactory; import com.l2jserver.datapack.custom.service.base.util.htmltmpls.HTMLTemplatePlaceholder; import com.l2jserver.datapack.custom.service.buffer.model.BufferConfig; import com.l2jserver.datapack.custom.service.buffer.model.UniqueBufflist; +import com.l2jserver.datapack.custom.service.buffer.model.entity.BuffCategory; import com.l2jserver.datapack.custom.service.buffer.model.entity.BuffSkill; import com.l2jserver.gameserver.config.Configuration; import com.l2jserver.gameserver.model.actor.instance.L2PcInstance; @@ -229,6 +230,19 @@ public final class BufferServiceRepository { return Collections.unmodifiableList(ulist); } + public BuffCategory getBuffCategory(String categoryIdent) { + return getConfig().getGlobal().getCategory(categoryIdent); + } + + public HTMLTemplatePlaceholder getBuffCategoryPlaceholder(String categoryIdent) { + BuffCategory cat = getBuffCategory(categoryIdent); + if (cat == null) { + return null; + } + + return cat.getPlaceholder(); + } + public HTMLTemplatePlaceholder getPlayersUListPlaceholder(int playerObjectId, String ulistName) { UniqueBufflist ulist = getPlayersUList(playerObjectId, ulistName); if (ulist == null) { diff --git a/src/main/java/com/l2jserver/datapack/custom/service/buffer/model/GlobalConfig.java b/src/main/java/com/l2jserver/datapack/custom/service/buffer/model/GlobalConfig.java index 6d66613cf7..1b176797f5 100644 --- a/src/main/java/com/l2jserver/datapack/custom/service/buffer/model/GlobalConfig.java +++ b/src/main/java/com/l2jserver/datapack/custom/service/buffer/model/GlobalConfig.java @@ -1,5 +1,5 @@ /* - * Copyright © 2004-2021 L2J DataPack + * Copyright © 2004-2022 L2J DataPack * * This file is part of L2J DataPack. * @@ -43,13 +43,17 @@ public final class GlobalConfig { } public BuffSkill getBuff(String id) { - return buffs.get(id); + return getBuffs().get(id); } public final Map<String, BuffSkill> getBuffs() { return buffs; } + public final BuffCategory getCategory(String id) { + return getCategories().get(id); + } + public final Map<String, BuffCategory> getCategories() { return buffCategories; } diff --git a/src/main/resources/data/service/buffer/documentation.txt b/src/main/resources/data/service/buffer/documentation.txt new file mode 100644 index 0000000000..6dd6c60c73 --- /dev/null +++ b/src/main/resources/data/service/buffer/documentation.txt @@ -0,0 +1,77 @@ +############ +# COMMANDS # +############ +On a html, the command starts with a bypass prefix. Here, as an example i use +the bypass prefix for a voiced buffer with the default command .bufferservice. + +Usage: bypass voice .bufferservice [COMMAND] +Commands: + html, h + any, a [html] Opens [html] + main, m Opens main.html + category, c [categoryId] Opens category.html + preset, p [presetId] Opens preset.html + buff, b [categoryId] [buffId] Opens buff.html + unique, u [uniqueName] Opens unique.html + target, t [target] [target] can either be player or + summon + buff, b [categoryId] [buffId] Apply a buff to the target + unique, u [uniqueName] Apply a unique bufflist to the + target + preset, p [presetId] Apply a preset bufflist to the + target + heal, h Heal the target + cancel, c Cancel bufs of the target + category, c + select, s [categoryId] Select a buff category as active. + The selected buff category can be + referenced to on any html by + %active_category% + deselect, des [categoryId] Deselect the active buff category + unique, u + create, c [name] Creates a unique bufflist + create_from_effects, cfe [name] Creates a unique bufflist based on + buffs + delete, del [name] Delete a unique bufflist + add, a [name] [categoryId] [buffId] Add a buff to the unique bufflist + remove, r [name] [categoryId] [buffId] Remove a buff from unique bufflist + select, s [name] Select a unique bufflist as active. + The selected unique bufflist can be + referenced to on any html by + %active_unique% + deselect, des Deselects the active unique bufflist +Examples: + Create a unique bufflist + bypass voice .bufferservice u c MyList + Add a buff to a bufflist: + bypass voice .bufferservice u a MyList BC_DWARFEN DWARFEN_0 + Show category.html: + bypass voice .bufferservice h c BC_DWARFEN + Select unique bufflist as active: + bypass voice .bufferservice u s MyList + + +######## +# HTML # +######## +On all HTML files, the following placeholders are available: +buffer + name +player + name + unique_max_buffs + unique_max_song_dances +active_unique (if one is selected) +active_category (if one is selected) + +Following is a list of html files and their additional available placeholders. + +category.html + category +buff.html + category + buff +preset.html + preset +unique.html + unique -- GitLab