Skip to content

Commit

Permalink
Some changes in sponge/spigot guis
Browse files Browse the repository at this point in the history
  • Loading branch information
NeumimTo committed Apr 18, 2020
1 parent dc98ac7 commit 6ff5eb5
Show file tree
Hide file tree
Showing 26 changed files with 308 additions and 644 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -70,6 +70,7 @@ public class LocalizationKeys {
public static final String CONFIRM_SKILL_SELECTION_BUTTON = "gui.button.label.confirm.skill-selection";
public static final String WEAPONS_MENU_HELP = "gui.label.weapons.tooltip";
public static final String WEAPONS = "gui.label.weapons";
public static final String ITEM_CLASS = "gui.label.item-class";
public static final String ARMOR = "gui.label.armor";
public static final String ARMOR_MENU_HELP = "gui.label.armor.tooltip";
public static final String PROPERTIES = "gui.label.generic.properties";
Expand Down
15 changes: 9 additions & 6 deletions Common/src/main/java/cz/neumimto/rpg/common/gui/GuiParser.java
Original file line number Diff line number Diff line change
Expand Up @@ -64,11 +64,13 @@ public Map<String, Object> initInventories(ClassLoader classLoader, String confN
String type = s.getClassType();
Object[] context2 = new Object[]{
type,
(Supplier<T[]>) () -> api.getClassService().getClassDefinitions()
.stream().filter(a -> a.getClassType().equals(type))
.map(this::toItemStack)
.collect(Collectors.toList())
.toArray(initArray(api.getClassService().getClassDefinitions().size()))
(Supplier<T[]>) () -> {
List<T> collect = api.getClassService().getClassDefinitions()
.stream().filter(a -> a.getClassType().equals(type))
.map(this::toItemStack)
.collect(Collectors.toList());
return collect.toArray(initArray(collect.size()));
}
};
ConfigInventory c2 = createCachedMenu(
sFactorz, guiName, gui, context2
Expand Down Expand Up @@ -227,7 +229,8 @@ private T parseItemsAndReturnBlank(Invocable i, Object context, Map<Character, T
try {
return (String) i.invokeFunction("command", context, command);
} catch (ScriptException | NoSuchMethodException e) {
return "";
e.printStackTrace();
return command;
}
});
if (split[0].equals(dynamicspace)) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,30 +10,8 @@ public StaticInventory(T[] items, InventorySlotProcessor<T, I> processor) {

@Override
public void fill(I inventory) {
for (int i = 0; i < items.length; ) {
//does java automatically unroll loops?

processor.setItem(items[i], inventory, i);
i++;
processor.setItem(items[i], inventory, i);
i++;
processor.setItem(items[i], inventory, i);
i++;
processor.setItem(items[i], inventory, i);
i++;
processor.setItem(items[i], inventory, i);
i++;
processor.setItem(items[i], inventory, i);
i++;
processor.setItem(items[i], inventory, i);
i++;
if (i == 54) {
return;
}
processor.setItem(items[i], inventory, i);
i++;
for (int i = 0; i < 54; i++) {
processor.setItem(items[i], inventory, i);
i++;
}
}
}
Original file line number Diff line number Diff line change
@@ -1,7 +1,5 @@
package cz.neumimto.rpg.common.gui;

import java.util.function.Function;

public class TemplateInventory<T, I> extends DynamicInventory<T, I> {

public TemplateInventory(T[] items, T replaceToken, InventorySlotProcessor<T, I> processor) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -114,7 +114,7 @@ private Map<String, Path> preloadClassDefs(Path path, Set<ClassDefinition> set)
}

if (classTypeDefinition == null) {
error(" - Unknown ClassType; Allowed Class Types: " + String.join(", ", types.keySet()));
error(" - Unknown ClassType " + classType + "; Allowed Class Types: " + String.join(", ", types.keySet()));
} else {
classDefinition = new ClassDefinition(name, classType);
map.put(name, p);
Expand Down
36 changes: 30 additions & 6 deletions Common/src/main/resources/guis.conf
Original file line number Diff line number Diff line change
Expand Up @@ -51,17 +51,20 @@ gui: [
conditions: ""
dynamic_space: "-"
command: """
if ("---".equals(command_)) {
return command_;
}
return "ninfo classes " + context_.getName()
"""
}
{
type: classes_by_type
inv: [
"<UUUUUUUU"
"U-------U"
"UUUUUUUUU"
"U-------U"
"U-------U"
"U-------U"
"U------<U"
"UUUUUUUUU"
]
items: [
Expand All @@ -87,9 +90,9 @@ gui: [
items: [
"-,,minecraft:gray_stained_glass_pane,12345,---"
"Q,,minecraft:red_stained_glass_pane,12345,---"
"W,gui.label.weapons,minecraft:diamond_sword,12345,char class-weapons "
"A,gui.label.armor,minecraft:diamond_chestplate,12345,char class-armor "
"T,gui.attributes.label,minecraft:book,12345,ninfo class-attributes %class%"
"W,gui.label.weapons,minecraft:diamond_sword,12345,char weapons "
"A,gui.label.armor,minecraft:diamond_chestplate,12345,char armor "
"T,gui.attributes.label,minecraft:book,12345,ninfo attributes "
]
conditions: ""
dynamic_space: "Q"
Expand All @@ -116,7 +119,28 @@ gui: [
conditions: ""
dynamic_space: "-"
command: """
command_.replaceAll("%class%", context_.getName());
return command_.replaceAll("%class%", context_[0].getName());
"""
}
{
type: char_allowed_items
inv: [
"<UUUUUUUU"
"---------"
"---------"
"---------"
"---------"
"---------"
]
items: [
"U,,minecraft:white_stained_glass_pane,12345,---"
"-,,minecraft:gray_stained_glass_pane,12345,---"
"<,gui.button.back,minecraft:paper,12345,char"
]
conditions: ""
dynamic_space: "-"
command: """
return command_;
"""
}
]
2 changes: 1 addition & 1 deletion Implementations/Spigot/14/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ repositories {
}

group = 'cz.neumimto.rpg'
version = '2.1.0-SNAPSHOT-8'
version = '2.1.0-SNAPSHOT-9'

compileJava {
options.compilerArgs += ["-parameters"]
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@
import java.util.concurrent.Executors;


@Plugin(name = "NT-RPG", version = "0.0.6-SNAPSHOT")
@Plugin(name = "NT-RPG", version = "2.1.0-SNAPSHOT-9")
@Description("Complete combat overhaul with classes and skills")
@Author("NeumimTo")
@Website("https://github.com/Sponge-RPG-dev/NT-RPG")
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
package cz.neumimto.rpg.spigot.commands;


import co.aikar.commands.BaseCommand;
import co.aikar.commands.annotation.Optional;
import co.aikar.commands.annotation.*;
import co.aikar.commands.bukkit.contexts.OnlinePlayer;
Expand Down Expand Up @@ -41,7 +42,7 @@
@Singleton
@CommandAlias("nadmin|na")
@CommandPermission("ntrpg.admin")
public class SpigotAdminCommands {
public class SpigotAdminCommands extends BaseCommand {

@Inject
private AdminCommandFacade adminCommandFacade;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -232,7 +232,6 @@ public void displayCharacterArmor(ISpigotCharacter character, int page) {
Player player = character.getPlayer();
Inventory i = SpigotGuiHelper.createInventoryTemplate(player, character.getName());

// SpigotGuiHelper.fillArmorView(i, character.getAllowedArmor(), "char");
player.openInventory(i);

}
Expand All @@ -242,31 +241,9 @@ public void displayCharacterWeapons(ISpigotCharacter character, int page) {
Player player = character.getPlayer();
Inventory i = SpigotGuiHelper.createInventoryTemplate(player, character.getName());

// SpigotGuiHelper.fillWeaponView(i, character.getAllowedWeapons(), "char");
player.openInventory(i);
}

public void displayRuneword(ISpigotCharacter character, RuneWord runeword, boolean b) {

}

public void displayRunewordAllowedItems(ISpigotCharacter character, RuneWord runeWord) {

}

public void displayRunewordAllowedGroups(ISpigotCharacter character, RuneWord runeWord) {

}

public void displayRunewordRequiredGroups(ISpigotCharacter character, RuneWord runeWord) {

}

public void displayRunewordBlockedGroups(ISpigotCharacter character, RuneWord runeWord) {

}


public void displayCharacterAttributes(Player player, ISpigotCharacter character) {
Inventory inventory = SpigotGuiHelper.createCharacterAttributeView(player, character);
player.openInventory(inventory);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -230,27 +230,6 @@ public static void sendcharacters(Player player, ISpigotCharacter player1, Chara
});
}

private static ItemStack toItemStack(SpigotRpgItemType type, double damage, String damageLabel) {
ItemStack itemStack = new ItemStack(type.getMaterial());
ItemMeta itemMeta = itemStack.getItemMeta();
if (type.getModelId() != null) {
itemMeta.setCustomModelData(Integer.parseInt(type.getModelId()));
}
if (damage > 0) {
List<String> lore = new ArrayList<>();
SpigotDamageService spigotDamageService = (SpigotDamageService) Rpg.get().getDamageService();
String colorByDamage = spigotDamageService.getColorByDamage(damage);
lore.add(damageLabel + ":" + colorByDamage + damage);
itemMeta.setLore(lore);
}
itemMeta.addItemFlags(ItemFlag.HIDE_ATTRIBUTES);
itemStack.setItemMeta(itemMeta);

return unclickableIcon(itemStack);
}



public static Inventory createClassAttributesView(Player player, ClassDefinition cc) {
String translate = Rpg.get().getLocalizationService().translate(LocalizationKeys.ATTRIBUTES);
Map<AttributeConfig, Integer> attrs = cc.getStartingAttributes();
Expand Down
8 changes: 7 additions & 1 deletion Implementations/Sponge/7/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,12 @@ plugins {
group = 'cz.neumimto.rpg'
version = '2.1.0-SNAPSHOT-2'

repositories {
maven {
url 'https://jitpack.io'
}
}

compileJava {
options.compilerArgs += ["-parameters"]
options.fork = true
Expand All @@ -26,7 +32,7 @@ dependencies {
compileOnly 'me.lucko.luckperms:luckperms-api:4.2'
compileOnly 'com.github.rojo8399:PlaceholderAPI:4.5.1'
compileOnly 'it.unimi.dsi:fastutil:8.2.1'

compileOnly 'com.github.randombyte-developer:holograms:v3.2.0'
compile "co.aikar:acf-sponge:0.5.0-SNAPSHOT"

testImplementation 'org.junit.jupiter:junit-jupiter-api:5.4.1'
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,6 @@
import co.aikar.commands.CommandIssuer;
import co.aikar.commands.InvalidCommandArgument;
import co.aikar.commands.SpongeCommandManager;
import co.aikar.commands.sponge.contexts.OnlinePlayer;
import com.google.inject.Inject;
import com.google.inject.Injector;
import cz.neumimto.rpg.api.Rpg;
Expand All @@ -32,6 +31,7 @@
import cz.neumimto.rpg.api.utils.FileUtils;
import cz.neumimto.rpg.common.commands.*;
import cz.neumimto.rpg.persistence.flatfiles.FlatFilesModule;
import cz.neumimto.rpg.sponge.bridges.HologramsListener;
import cz.neumimto.rpg.sponge.commands.*;
import cz.neumimto.rpg.sponge.gui.GuiHelper;
import cz.neumimto.rpg.sponge.gui.VanillaMessaging;
Expand Down Expand Up @@ -361,12 +361,21 @@ public void initializeApi(GamePreInitializationEvent event) {
if (Boolean.TRUE.equals(Rpg.get().getPluginConfig().ITEM_COOLDOWNS)) {
Rpg.get().registerListeners(new SpongeItemCooldownListener());
}


try {
Class.forName("de.randombyte.holograms.api.class.HologramsService");
injector.getInstance(HologramsListener.class).init();
Log.info("Holograms inetgartions enabled");
} catch (ClassNotFoundException e) {

}

}
);
Rpg.get().getSyncExecutor();



info("NtRpg plugin successfully loaded in " + elapsedTime + " seconds");
}

Expand Down
Loading

0 comments on commit 6ff5eb5

Please sign in to comment.