QUOTE: Life is a journey, not a destination.

Added info book - poppy - A feature-rich Minecraft plugin which enhances gaming experience

poppy

A feature-rich Minecraft plugin which enhances gaming experience
git clone git://192.168.2.2/poppy
Log | Files | Refs | README

commit 9f1a757deb20b1c127c717b2eddcb737af90cd20
parent 317d6a086e537d286a1d221fb19065915904ab1d
Author: typable <contact@typable.dev>
Date:   Tue,  3 Jan 2023 22:08:33 +0100

Added info book

Diffstat:
Mres/plugin.yml | 1+
Msrc/de/typable/minecrafthub/Main.java | 13+++++++++++++
Msrc/de/typable/minecrafthub/config/Config.java | 17+++++++++++++++++
3 files changed, 31 insertions(+), 0 deletions(-)

diff --git a/res/plugin.yml b/res/plugin.yml @@ -17,3 +17,4 @@ commands: usage: /setwarp <name> warp: usage: /warp <name> + info: diff --git a/src/de/typable/minecrafthub/Main.java b/src/de/typable/minecrafthub/Main.java @@ -20,6 +20,7 @@ import org.bukkit.entity.Player; import org.bukkit.entity.Entity; import org.bukkit.inventory.ItemStack; import org.bukkit.inventory.meta.SkullMeta; +import org.bukkit.inventory.meta.BookMeta; import org.bukkit.material.Tree; import org.bukkit.plugin.Plugin; import org.bukkit.plugin.PluginManager; @@ -242,6 +243,18 @@ public class Main extends JavaPlugin player.sendMessage(ChatColor.GRAY + "You've been teleported to warp point " + name + "."); } } + + if(label.equals("info")) + { + final ItemStack book = new ItemStack(Material.WRITTEN_BOOK); + final BookMeta meta = (BookMeta) book.getItemMeta(); + meta.setTitle("Info"); + meta.setAuthor("Server"); + meta.setPages(config.getInfoPages()); + book.setItemMeta(meta); + + player.openBook(book); + } } return true; diff --git a/src/de/typable/minecrafthub/config/Config.java b/src/de/typable/minecrafthub/config/Config.java @@ -2,6 +2,8 @@ package de.typable.minecrafthub.config; import java.io.File; import java.io.IOException; +import java.util.List; +import java.util.ArrayList; import org.bukkit.configuration.file.FileConfiguration; import org.bukkit.configuration.file.YamlConfiguration; @@ -58,4 +60,19 @@ public class Config return this.configuration.getLocation(path); } + + public List<String> getInfoPages() + { + final String path = "info"; + + try + { + this.configuration.load(this.file); + return (List<String>) this.configuration.getList(path); + } + catch(Exception ex) + { + return new ArrayList<>(); + } + } }