Skip to content

Commit

Permalink
Include chest GUI configuration examples
Browse files Browse the repository at this point in the history
  • Loading branch information
ustc-zzzz committed Mar 8, 2017
1 parent 95068a4 commit bb5d243
Show file tree
Hide file tree
Showing 4 changed files with 247 additions and 5 deletions.
186 changes: 186 additions & 0 deletions resources/assets/virtualchest/examples/example.conf
Original file line number Diff line number Diff line change
@@ -0,0 +1,186 @@
virtualchest {
TextTitle = "&1&lExample 1"
Rows = 2
Position-1-1 {
Item {
Count = 1
ItemType = "minecraft:dye"
UnsafeDamage = 1
DisplayName = "&c&lI'm red"
ItemLore = [
"&bItem type and damage: &eminecraft:dye 1"
]
}
KeepOpen = true
}
Position-2-1 {
Item {
Count = 1
ItemType = "minecraft:dye"
UnsafeDamage = 2
DisplayName = "&a&lI'm green"
ItemLore = [
"&bItem type and damage: &eminecraft:dye 2"
]
}
KeepOpen = true
}
Position-3-1 {
Item {
Count = 1
ItemType = "minecraft:dye"
UnsafeDamage = 4
DisplayName = "&9&lI'm blue"
ItemLore = [
"&bItem type and damage: &eminecraft:dye 4"
]
}
KeepOpen = true
}
Position-7-1 {
Item {
Count = 1
ItemType = "minecraft:dye"
UnsafeDamage = 5
DisplayName = "&lTell you some life experience"
ItemLore = [
"&e&lToo young!"
]
}
PrimaryAction = "tell: &lToo simple!; delay: 20; tell: +1s; title: &l-1s; delay: 20; tell: +2s; title: &l-2s; delay: 20; tell: +3s; title: &l-3s; delay: 20; tell: &lSometimes naive!; title: "
MiddleAction = "tell: &lToo simple!; delay: 20; tell: +1s; title: &l-1s; delay: 20; tell: +2s; title: &l-2s; delay: 20; tell: +3s; title: &l-3s; delay: 20; tell: &lSometimes naive!; title: "
SecondaryAction = "tell: &lToo simple!; delay: 20; tell: +1s; title: &l-1s; delay: 20; tell: +2s; title: &l-2s; delay: 20; tell: +3s; title: &l-3s; delay: 20; tell: &lSometimes naive!; title: "
}
Position-8-1 {
Item {
Count = 1
ItemType = "minecraft:dye"
UnsafeDamage = 0
DisplayName = "&lTry left/middle/right click"
ItemLore = [
"&e&lDifferent title will be generated"
]
}
PrimaryAction = "broadcast: A player has used the primary mouse button.; bigtitle: Primary"
MiddleAction = "broadcast: A player has used the middle mouse button.; bigtitle: Middle"
SecondaryAction = "broadcast: A player has used the secondary mouse button.; bigtitle: Secondary"
}
Position-9-1 {
Item {
Count = 1
ItemType = "minecraft:compass"
UnsafeDamage = 0
DisplayName = "&lYou can right click the compass in the game to open the GUI"
ItemLore = [
"&e&lWhat happened when you left click it?"
]
}
PrimaryAction = "console: say Hello World!"
MiddleAction = "console: say Hello World!"
SecondaryAction = "console: say Hello World!"
}
Position-1-2 {
Item {
Count = 63
ItemType = "minecraft:gold_block"
UnsafeDamage = 0
DisplayName = "&7&lI almost fill the block"
ItemLore = [
"&bItem type and damage: &eminecraft:gold_block 0"
"&dCount: &e63"
"&eAll of the item type, the damage, and the count"
"&eshould be specified"
]
}
KeepOpen = true
}
Position-2-2 {
Item {
Count = 1
ItemType = "minecraft:iron_block"
UnsafeDamage = 0
DisplayName = "&f&lI'm a white enchanter"
ItemEnchantments = [
"minecraft:protection:4"
"minecraft:fire_protection:4"
"minecraft:feather_falling:4"
"minecraft:blast_protection:4"
"minecraft:projectile_protection:4"
"minecraft:respiration"
"minecraft:aqua_affinity"
]
}
KeepOpen = true
}
Position-3-2 {
Item {
Count = 1
ItemType = "minecraft:coal_block"
UnsafeDamage = 0
DisplayName = "&8&lI'm a black enchanter"
ItemLore = [
"&ewith hidden enchantments"
]
ItemEnchantments = [
"minecraft:infinity"
]
HideEnchantments = true
}
KeepOpen = true
}
Position-7-2 {
Item {
Count = 1
ItemType = "minecraft:redstone_block"
UnsafeDamage = 0
DisplayName = "&4&lAttention!"
ItemLore = [
"&eI'll show you the help menu"
]
ItemEnchantments = [
"minecraft:infinity"
]
HideEnchantments = true
}
PrimaryAction = "help"
MiddleAction = "help"
SecondaryAction = "help"
}
Position-8-2 {
Item {
Count = 1
ItemType = "minecraft:quartz_block"
UnsafeDamage = 0
DisplayName = "&lHello! {player}"
ItemLore = [
"&eYou are now at &l{world}"
"&eThe server now has &l{online}&r &eplayer(s), and the capacity is &l{max_players}"
]
ItemEnchantments = [
"minecraft:infinity"
]
HideEnchantments = true
}
KeepOpen = true
}
Position-9-2 {
Item {
Count = 1
ItemType = "minecraft:diamond_block"
UnsafeDamage = 0
DisplayName = "&lGoodbye! {player}"
ItemLore = [
"&eYou will open another chest GUI"
]
}
KeepOpen = true
PrimaryAction = "virtualchest open example2"
MiddleAction = "virtualchest open example2"
SecondaryAction = "virtualchest open example2"
}
TriggerItem {
ItemType = "minecraft:compass"
EnablePrimaryAction = false
EnableSecondaryAction = true
}
}
38 changes: 38 additions & 0 deletions resources/assets/virtualchest/examples/example2.conf
Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@
virtualchest {
TextTitle = "&2&lExample 2"
Rows = 2
Position-9-1 {
Item {
Count = 1
ItemType = "minecraft:compass"
UnsafeDamage = 0
DisplayName = "&lYou can left click the compass in the game to open the GUI"
ItemLore = [
"&e&lWhat happened when you right click it?"
]
}
PrimaryAction = "console: say Hello World!"
MiddleAction = "console: say Hello World!"
SecondaryAction = "console: say Hello World!"
}
Position-9-2 {
Item {
Count = 1
ItemType = "minecraft:emerald_block"
UnsafeDamage = 0
DisplayName = "&lGoodbye! {player}"
ItemLore = [
"&eYou will open another chest GUI"
]
}
KeepOpen = true
PrimaryAction = "virtualchest open example"
MiddleAction = "virtualchest open example"
SecondaryAction = "virtualchest open example"
}
TriggerItem {
ItemType = "minecraft:compass"
EnablePrimaryAction = true
EnableSecondaryAction = false
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -54,8 +54,8 @@ public void runCommand(Player player, String commandString)
String prefix = colonPos > 0 ? command.substring(0, colonPos) : "";
if (this.executors.containsKey(prefix))
{
int suffixPosition = colonPos + 1;
while (Character.isWhitespace(command.charAt(suffixPosition)))
int length = command.length(), suffixPosition = colonPos + 1;
while (suffixPosition < length && Character.isWhitespace(command.charAt(suffixPosition)))
{
++suffixPosition;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,12 +2,15 @@

import com.github.ustc_zzzz.virtualchest.VirtualChestPlugin;
import com.github.ustc_zzzz.virtualchest.translation.VirtualChestTranslation;
import com.google.common.base.Throwables;
import com.google.common.collect.ImmutableList;
import com.google.common.reflect.TypeToken;
import ninja.leaping.configurate.commented.CommentedConfigurationNode;
import ninja.leaping.configurate.hocon.HoconConfigurationLoader;
import ninja.leaping.configurate.objectmapping.ObjectMappingException;
import org.spongepowered.api.Sponge;
import org.spongepowered.api.asset.Asset;
import org.spongepowered.api.asset.AssetManager;
import org.spongepowered.api.data.DataContainer;
import org.spongepowered.api.data.persistence.DataTranslator;
import org.spongepowered.api.data.persistence.DataTranslators;
Expand All @@ -17,7 +20,6 @@

import java.io.File;
import java.io.IOException;
import java.nio.file.Path;
import java.util.*;

/**
Expand Down Expand Up @@ -85,8 +87,24 @@ public void saveConfig(CommentedConfigurationNode node) throws IOException

private List<String> releaseExample()
{
// TODO: release example command GUIs
return Collections.singletonList("menu/");
String defaultMenuDir = "menu/";
File menuDir = this.plugin.getConfigDir().resolve(defaultMenuDir).toFile();
if (menuDir.isDirectory() || menuDir.mkdirs())
{
try
{
AssetManager assetManager = Sponge.getAssetManager();
Optional<Asset> example = assetManager.getAsset(this.plugin, "examples/example.conf");
Optional<Asset> example2 = assetManager.getAsset(this.plugin, "examples/example2.conf");
example.orElseThrow(IOException::new).copyToDirectory(menuDir.toPath());
example2.orElseThrow(IOException::new).copyToDirectory(menuDir.toPath());
}
catch (IOException e)
{
Throwables.propagate(e);
}
}
return Collections.singletonList(defaultMenuDir);
}

private Map<String, VirtualChestInventory> scanDir(File file)
Expand Down

0 comments on commit bb5d243

Please sign in to comment.