Skip to content

Commit

Permalink
Merge pull request #94 from BTEUK/Develop
Browse files Browse the repository at this point in the history
Fixes the menu icon texts
  • Loading branch information
george112n authored Mar 27, 2024
2 parents 23d701d + 34e7fd8 commit 36bf878
Show file tree
Hide file tree
Showing 9 changed files with 89 additions and 50 deletions.
3 changes: 3 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -14,3 +14,6 @@ It will provide a foundation for a tutorials system which can be used throughout

## Credits
#### WorldEdit

## Versions
Native to minecraft 1.18.2, tested on 1.20.1
2 changes: 1 addition & 1 deletion pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@

<groupId>me.bteuk</groupId>
<artifactId>TeachingTutorials</artifactId>
<version>1.1.0-Beta6</version>
<version>1.1.0-Beta6.1</version>
<packaging>jar</packaging>

<name>TeachingTutorials</name>
Expand Down
18 changes: 9 additions & 9 deletions src/main/java/teachingtutorials/guis/AdminMenu.java
Original file line number Diff line number Diff line change
Expand Up @@ -30,18 +30,18 @@ public AdminMenu(TeachingTutorials plugin, User user)
private void createGui()
{
ItemStack setCompulsory = Utils.createItem(Material.IRON_DOOR, 1,
Component.text("Set Compulsory Tutorial", NamedTextColor.GREEN),
Component.text("Admins only", NamedTextColor.DARK_GREEN));
TutorialGUIUtils.optionTitle("Set Compulsory Tutorial"),
TutorialGUIUtils.optionLore("Admins only"));

ItemStack myTutorials = Utils.createItem(Material.BOOKSHELF, 1,
Component.text("My Tutorials", NamedTextColor.GREEN),
Component.text("View the tutorials you have created", NamedTextColor.DARK_GREEN),
Component.text("Add locations", NamedTextColor.DARK_GREEN),
Component.text("Set a tutorial as in use or not in use", NamedTextColor.DARK_GREEN));
TutorialGUIUtils.optionTitle("My Tutorials"),
TutorialGUIUtils.optionLore("- View the tutorials you have created"),
TutorialGUIUtils.optionLore("- Add locations"),
TutorialGUIUtils.optionLore("- Set a tutorial as in use or not in use"));

ItemStack createTutorial = Utils.createItem(Material.WRITABLE_BOOK, 1,
Component.text("Create Tutorial", NamedTextColor.GREEN),
Component.text("Create a new tutorial in game (coming soon)", NamedTextColor.DARK_GREEN));
TutorialGUIUtils.optionTitle("Create a new Tutorial"),
TutorialGUIUtils.optionLore("Create a new tutorial in game (coming soon)"));

int iSlotMyTutorials;

Expand Down Expand Up @@ -96,7 +96,7 @@ public void leftClick(User u) {
});

setItem(27 - 1, Utils.createItem(Material.SPRUCE_DOOR, 1,
Component.text("Back to main menu", NamedTextColor.GREEN, TextDecoration.BOLD)),
TutorialGUIUtils.backButton("Back to main menu")),
new guiAction() {
@Override
public void rightClick(User u) {
Expand Down
14 changes: 8 additions & 6 deletions src/main/java/teachingtutorials/guis/CompulsoryTutorialMenu.java
Original file line number Diff line number Diff line change
Expand Up @@ -68,12 +68,14 @@ private static Inventory getGUI (Tutorial[] tutorials)
//Indicates that the creator has no tutorials if they don't own any
if (iTutorials == 0)
{
ItemStack noTutorials = Utils.createItem(Material.BARRIER, 1, Component.text("There are no in-use tutorials on the system", NamedTextColor.GREEN));
ItemStack noTutorials = Utils.createItem(Material.BARRIER, 1,
TutorialGUIUtils.optionTitle("There are no in-use tutorials on the system"));
inventory.setItem(5-1, noTutorials);
}

//Adds back button
ItemStack back = Utils.createItem(Material.SPRUCE_DOOR, 1, Component.text("Back to creator menu", NamedTextColor.GREEN, TextDecoration.BOLD));
ItemStack back = Utils.createItem(Material.SPRUCE_DOOR, 1,
TutorialGUIUtils.backButton("Back to creator menu"));
inventory.setItem((iRows * 9)-1, back);

//Inv slot 0 = the first one
Expand All @@ -84,14 +86,14 @@ private static Inventory getGUI (Tutorial[] tutorials)
if (tutorials[i].bCompulsory)
{
tutorial = Utils.createItem(compulsoryBlock, 1,
Component.text(tutorials[i].szTutorialName, NamedTextColor.GREEN, TextDecoration.BOLD),
Component.text(Bukkit.getPlayer(tutorials[i].uuidAuthor).getName(), NamedTextColor.DARK_GREEN));
TutorialGUIUtils.optionTitle(tutorials[i].szTutorialName).decoration(TextDecoration.BOLD, true),
TutorialGUIUtils.optionLore(Bukkit.getPlayer(tutorials[i].uuidAuthor).getName()));
}
else
{
tutorial = Utils.createItem(nonCompulsoryBlock, 1,
Component.text(tutorials[i].szTutorialName, NamedTextColor.GREEN),
Component.text(Bukkit.getPlayer(tutorials[i].uuidAuthor).getName(), NamedTextColor.DARK_GREEN));
TutorialGUIUtils.optionTitle(tutorials[i].szTutorialName),
TutorialGUIUtils.optionLore(Bukkit.getPlayer(tutorials[i].uuidAuthor).getName()));
}
inventory.setItem(i, tutorial);
}
Expand Down
16 changes: 8 additions & 8 deletions src/main/java/teachingtutorials/guis/CreatorTutorialsMenu.java
Original file line number Diff line number Diff line change
Expand Up @@ -82,12 +82,12 @@ private static Inventory getGUI (Tutorial[] allTutorials)
//Indicates that the creator has no tutorials if they don't own any
if (allTutorials.length == 0)
{
ItemStack noTutorials = Utils.createItem(Material.BARRIER, 1, Component.text("You have no tutorials", NamedTextColor.GREEN));
ItemStack noTutorials = Utils.createItem(Material.BARRIER, 1, TutorialGUIUtils.optionTitle("You have no tutorials"));
inventory.setItem(5-1, noTutorials);
}

//Adds back button
ItemStack back = Utils.createItem(Material.SPRUCE_DOOR, 1, Component.text("Back to creator menu", NamedTextColor.GREEN, TextDecoration.BOLD));
ItemStack back = Utils.createItem(Material.SPRUCE_DOOR, 1, TutorialGUIUtils.backButton("Back to creator menu"));
inventory.setItem((iRows * 9)-1, back);

//Creates the menu options
Expand All @@ -97,14 +97,14 @@ private static Inventory getGUI (Tutorial[] allTutorials)
//Sets tutorial name bold for tutorials in use
if (allTutorials[i].bInUse)
tutorial = Utils.createItem(Material.WRITTEN_BOOK, 1,
Component.text(allTutorials[i].szTutorialName, NamedTextColor.GREEN, TextDecoration.BOLD),
Component.text("In Use - Left click to remove from use", NamedTextColor.DARK_GREEN),
Component.text("Right click to add a new location", NamedTextColor.DARK_GREEN));
TutorialGUIUtils.optionTitle(allTutorials[i].szTutorialName).decoration(TextDecoration.BOLD, true),
TutorialGUIUtils.optionLore("In Use - Left click to remove from use"),
TutorialGUIUtils.optionLore("Right click to add a new location"));
else
tutorial = Utils.createItem(Material.BOOK, 1,
Component.text(allTutorials[i].szTutorialName, NamedTextColor.GREEN),
Component.text("Not in Use - Left click to set in use", NamedTextColor.DARK_GREEN),
Component.text("Right click to add a new location", NamedTextColor.DARK_GREEN));
TutorialGUIUtils.optionTitle(allTutorials[i].szTutorialName),
TutorialGUIUtils.optionLore("Not in Use - Left click to set in use"),
TutorialGUIUtils.optionLore("Right click to add a new location"));
inventory.setItem(i, tutorial);
}

Expand Down
10 changes: 6 additions & 4 deletions src/main/java/teachingtutorials/guis/LibraryMenu.java
Original file line number Diff line number Diff line change
Expand Up @@ -71,7 +71,9 @@ private static Inventory getGUI (Tutorial[] tutorials)
//Indicates that there are no tutorials in the system
if (iTutorials == 0)
{
ItemStack noTutorials = Utils.createItem(Material.BARRIER, 1, Component.text("There are no tutorials available to play currently", NamedTextColor.GREEN));
ItemStack noTutorials = Utils.createItem(Material.BARRIER, 1,
TutorialGUIUtils.optionTitle("There are no tutorials available to play currently"),
TutorialGUIUtils.optionLore("Ask a server admin to get some created"));
inventory.setItem(5-1, noTutorials);
}

Expand All @@ -80,13 +82,13 @@ private static Inventory getGUI (Tutorial[] tutorials)
for (i = 0 ; i < iTutorials ; i++)
{
tutorial = Utils.createItem(Material.KNOWLEDGE_BOOK, 1,
Component.text(tutorials[i].szTutorialName, NamedTextColor.GREEN, TextDecoration.BOLD),
Component.text("Tutor: " +Bukkit.getOfflinePlayer(tutorials[i].uuidAuthor).getName(), NamedTextColor.DARK_GREEN));
TutorialGUIUtils.optionTitle(tutorials[i].szTutorialName).decoration(TextDecoration.BOLD, true),
TutorialGUIUtils.optionLore("Tutor - " +Bukkit.getOfflinePlayer(tutorials[i].uuidAuthor).getName()));
inventory.setItem(i, tutorial);
}

//Adds back button
ItemStack back = Utils.createItem(Material.SPRUCE_DOOR, 1, Component.text("Back to main menu", NamedTextColor.GREEN, TextDecoration.BOLD));
ItemStack back = Utils.createItem(Material.SPRUCE_DOOR, 1, TutorialGUIUtils.backButton("Back to main menu"));
inventory.setItem((iRows * 9) - 1, back);

//Inv slot 0 = the first one
Expand Down
30 changes: 16 additions & 14 deletions src/main/java/teachingtutorials/guis/MainMenu.java
Original file line number Diff line number Diff line change
Expand Up @@ -35,30 +35,32 @@ private void createGui()
FileConfiguration config = TeachingTutorials.getInstance().getConfig();
boolean bCompulsoryTutorialEnabled = config.getBoolean("Compulsory_Tutorial");

//Continue learning menu button
//'Continue' menu button
ItemStack continueLearning_CompulsoryComplete;
if (user.bInLesson)
continueLearning_CompulsoryComplete = Utils.createItem(Material.WRITABLE_BOOK, 1,
Component.text("Continue learning", NamedTextColor.GREEN),
Component.text("Continue your lesson", NamedTextColor.DARK_GREEN));
TutorialGUIUtils.optionTitle("Continue lesson"),
TutorialGUIUtils.optionLore("Continue your lesson"));
else
continueLearning_CompulsoryComplete = Utils.createItem(Material.WRITABLE_BOOK, 1,
Component.text("Continue learning", NamedTextColor.GREEN),
Component.text("Start another tutorial", NamedTextColor.DARK_GREEN));
TutorialGUIUtils.optionTitle("Start a new Tutorial"),
TutorialGUIUtils.optionLore("Finds a tutorial for you"));

//Tutorial library
ItemStack tutorialLibrary = Utils.createItem(Material.BOOKSHELF, 1,
Component.text("Tutorial Library", NamedTextColor.GREEN),
Component.text("Browse all of our available tutorials", NamedTextColor.DARK_GREEN));
TutorialGUIUtils.optionTitle("Tutorial Library"),
TutorialGUIUtils.optionLore("Browse all of our available tutorials"));

//The system has the compulsory tutorial feature enabled
//Checks the system has the compulsory tutorial feature enabled
if (bCompulsoryTutorialEnabled)
{
if (user.bHasCompletedCompulsory)
{
//Restart compulsory tutorial
ItemStack restartCompulsory = Utils.createItem(Material.ENCHANTED_BOOK, 1,
Component.text("Restart Compulsory Tutorial", NamedTextColor.GREEN));
TutorialGUIUtils.optionTitle("Restart the Starter Tutorial"),
TutorialGUIUtils.optionLore("If you are already in a tutorial,"),
TutorialGUIUtils.optionLore("it will resume that."));
super.setItem(11 - 1, restartCompulsory, new guiAction() {
@Override
public void rightClick(User u)
Expand Down Expand Up @@ -110,14 +112,14 @@ public void leftClick(User u)
if (user.bInLesson)
{
continue_CompulsoryNotComplete = Utils.createItem(Material.BOOK, 1,
Component.text("Continue Compulsory Tutorial", NamedTextColor.GREEN),
Component.text("Gain the applicant rank", NamedTextColor.DARK_GREEN));
TutorialGUIUtils.optionTitle("Continue the Starter Tutorial"),
TutorialGUIUtils.optionLore("Gain the applicant rank"));
}
else
{
continue_CompulsoryNotComplete = Utils.createItem(Material.BOOK, 1,
Component.text("Start Compulsory Tutorial", NamedTextColor.GREEN),
Component.text("Gain the applicant rank", NamedTextColor.DARK_GREEN));
TutorialGUIUtils.optionTitle("Begin the Starter Tutorial"),
TutorialGUIUtils.optionLore("Gain the applicant rank"));
}
super.setItem(14 - 1, continue_CompulsoryNotComplete, new guiAction() {
@Override
Expand Down Expand Up @@ -171,7 +173,7 @@ public void leftClick(User u) {
{
//Admin and creator menu
super.setItem(19 - 1, Utils.createItem(Material.LECTERN, 1,
Component.text("Creator Menu", NamedTextColor.GREEN)), new guiAction() {
TutorialGUIUtils.optionTitle("Creator Menu")), new guiAction() {
@Override
public void rightClick(User u) {
leftClick(u);
Expand Down
29 changes: 29 additions & 0 deletions src/main/java/teachingtutorials/guis/TutorialGUIUtils.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
package teachingtutorials.guis;

import net.kyori.adventure.text.Component;
import net.kyori.adventure.text.TextComponent;
import net.kyori.adventure.text.format.NamedTextColor;
import net.kyori.adventure.text.format.TextDecoration;

/**
* Utils for Tutorial Menus
*/
public class TutorialGUIUtils
{
public static TextComponent backButton(String szText)
{
return Component.text(szText, NamedTextColor.GREEN)
.decoration(TextDecoration.ITALIC, false)
.decoration(TextDecoration.BOLD, true);
}

public static TextComponent optionTitle(String szText)
{
return Component.text(szText, NamedTextColor.GREEN).decoration(TextDecoration.ITALIC, false);
}

public static TextComponent optionLore(String szText)
{
return Component.text(szText, NamedTextColor.DARK_GREEN).decoration(TextDecoration.ITALIC, false);
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@
import org.bukkit.inventory.ItemStack;
import teachingtutorials.TeachingTutorials;
import teachingtutorials.guis.Gui;
import teachingtutorials.guis.TutorialGUIUtils;
import teachingtutorials.listeners.TextEditorBookListener;
import teachingtutorials.tutorials.LocationStep;
import teachingtutorials.tutorials.Step;
Expand Down Expand Up @@ -49,15 +50,15 @@ public StepEditorMenu(TeachingTutorials plugin, User user, Step step, LocationSt
public void setItems()
{
ItemStack setStartLocation = Utils.createItem(Material.COMPASS, 1,
Component.text("Set the step's start location", NamedTextColor.GREEN),
Component.text("Set the start location to your current position and direction", NamedTextColor.DARK_GREEN));
TutorialGUIUtils.optionTitle("Set the step's start location"),
TutorialGUIUtils.optionLore("Set the start location to your current position and direction"));

ItemStack teleportToStart = Utils.createItem(Material.VILLAGER_SPAWN_EGG, 1,
Component.text("Teleport back to the start location", NamedTextColor.GREEN));
TutorialGUIUtils.optionTitle("Teleport back to the start location"));

ItemStack videoLink = Utils.createItem(Material.PAINTING, 1,
Component.text("Set the video tutorial link if one exists", NamedTextColor.GREEN),
Component.text("This is specific to each location of the tutorial", NamedTextColor.DARK_GREEN));
TutorialGUIUtils.optionTitle("Set the video tutorial link if one exists"),
TutorialGUIUtils.optionLore("This is specific to each location of the tutorial"));

boolean bIsHologramNeeded = step.getInstructionDisplayType().equals(Display.DisplayType.hologram);
if (bIsHologramNeeded)
Expand All @@ -77,7 +78,7 @@ public void leftClick(User u) {

//Set instructions
ItemStack instructions = Utils.createItem(Material.WRITABLE_BOOK, 1,
Component.text("Set the instructions", NamedTextColor.GREEN));
TutorialGUIUtils.optionTitle("Set the instructions"));

setItem(12, instructions, new guiAction() {
@Override
Expand All @@ -104,8 +105,8 @@ public void leftClick(User u) {

//Set hologram coordinates to player's current location
ItemStack hologramLocation = Utils.createItem(Material.FILLED_MAP, 1,
Component.text("Set the instructions hologram location", NamedTextColor.GREEN),
Component.text("Set the instructions hologram to your current position", NamedTextColor.DARK_GREEN));
TutorialGUIUtils.optionTitle("Set the instructions hologram location"),
TutorialGUIUtils.optionLore("Set the instructions hologram to your current position"));

setItem(14, hologramLocation, new guiAction() {
@Override
Expand Down

0 comments on commit 36bf878

Please sign in to comment.