From d9d8f38dc6da8c74886bf1edb7d8f83061cc8b20 Mon Sep 17 00:00:00 2001
From: the-codeboy <71213855+the-codeboy@users.noreply.github.com>
Date: Tue, 12 Oct 2021 18:51:50 +0200
Subject: [PATCH 01/16] fixed removeFile

---
 pom.xml                                       |  2 +-
 .../codeboy/mcide/ide/gui/ProjectMenu.java    | 26 ++++++++-----------
 2 files changed, 12 insertions(+), 16 deletions(-)

diff --git a/pom.xml b/pom.xml
index 8881021..a2f6a93 100644
--- a/pom.xml
+++ b/pom.xml
@@ -93,7 +93,7 @@
         <dependency>
             <groupId>com.github.the-codeboy</groupId>
             <artifactId>BukkitBootstrap</artifactId>
-            <version>d663859a9d</version>
+            <version>24875ef2c6</version>
         </dependency>
     </dependencies>
 </project>
diff --git a/src/main/java/com/github/codeboy/mcide/ide/gui/ProjectMenu.java b/src/main/java/com/github/codeboy/mcide/ide/gui/ProjectMenu.java
index 4f70204..f8c0ad1 100644
--- a/src/main/java/com/github/codeboy/mcide/ide/gui/ProjectMenu.java
+++ b/src/main/java/com/github/codeboy/mcide/ide/gui/ProjectMenu.java
@@ -14,6 +14,7 @@
 
 public class ProjectMenu extends MultiPageGui {
     private final CodeProject project;
+    private final int filesPerPage=9*4;
 
     public ProjectMenu(CodeProject project) {
         super(Mcide.getPlugin(Mcide.class), 54, project.getTitle(), (Gui page) -> {
@@ -45,24 +46,19 @@ protected int getPrevButtonIndex() {
 
     public void addFile(MCCodeFile file, boolean mainFile) {
         ItemStack fileItem = createItem(Material.BOOK_AND_QUILL, file.getName(), mainFile);
-        addItem(fileItem, p -> project.editFile(file, p));
+        int files=project.getMCCodeFiles().size()-1;
+        int pageNumber=files/filesPerPage;
+        int slotNumber=files%filesPerPage;
+        Gui page= getPages().get(pageNumber);
+        page.addItem(fileItem, slotNumber, p -> project.editFile(file, p));
     }
 
     public void removeFile() {
-        ArrayList<Gui>pages=getPages();
-        for (int i = pages.size() - 1; i >= 0; i--) {
-            Gui page=pages.get(i);
-            Inventory inventory= page.getInventory();
-
-            int index = inventory.getSize() - 1;
-            while (index>=0) {
-                if(isProjectFile(inventory.getItem(index))){
-                    inventory.setItem(index,null);
-                    return;
-                }
-                index--;
-            }
-        }
+        int files=project.getMCCodeFiles().size()-1;
+        int pageNumber=files/filesPerPage;
+        int slotNumber=files%filesPerPage;
+        Gui page= getPages().get(pageNumber);
+        page.removeItem(slotNumber);
     }
 
     private boolean isProjectFile(ItemStack itemStack){

From 09e8075f49691828a6b48edc8f33ec903d05e04d Mon Sep 17 00:00:00 2001
From: the-codeboy <71213855+the-codeboy@users.noreply.github.com>
Date: Tue, 12 Oct 2021 18:52:16 +0200
Subject: [PATCH 02/16] used new configurable annotation where possible

---
 .../java/com/github/codeboy/mcide/config/Config.java     | 5 ++++-
 .../java/com/github/codeboy/mcide/config/Message.java    | 9 ++++-----
 2 files changed, 8 insertions(+), 6 deletions(-)

diff --git a/src/main/java/com/github/codeboy/mcide/config/Config.java b/src/main/java/com/github/codeboy/mcide/config/Config.java
index 9cfa1fd..b837bb6 100644
--- a/src/main/java/com/github/codeboy/mcide/config/Config.java
+++ b/src/main/java/com/github/codeboy/mcide/config/Config.java
@@ -1,9 +1,12 @@
 package com.github.codeboy.mcide.config;
 
+import ml.codeboy.bukkitbootstrap.config.ConfigScope;
 import ml.codeboy.bukkitbootstrap.config.ConfigValue;
+import ml.codeboy.bukkitbootstrap.config.Configurable;
 
+@Configurable(name = "config.yml",comments = "Edit these values however you like\n" +
+        "They should be self explanatory",scope = ConfigScope.PUBLIC)
 public class Config {
-    @ConfigValue
     public static String language = "english";
 
     @ConfigValue(key = "piston.endpoint")
diff --git a/src/main/java/com/github/codeboy/mcide/config/Message.java b/src/main/java/com/github/codeboy/mcide/config/Message.java
index a48f6bd..6cda028 100644
--- a/src/main/java/com/github/codeboy/mcide/config/Message.java
+++ b/src/main/java/com/github/codeboy/mcide/config/Message.java
@@ -1,12 +1,14 @@
 package com.github.codeboy.mcide.config;
 
-import ml.codeboy.bukkitbootstrap.config.ConfigValue;
+import ml.codeboy.bukkitbootstrap.config.ConfigScope;
+import ml.codeboy.bukkitbootstrap.config.Configurable;
 import org.bukkit.ChatColor;
 
+@Configurable(name = "message.yml",comments = "Edit these messages however you like\n" +
+        "It should be self explanatory where they are used",scope = ConfigScope.PUBLIC)
 public class Message {
 
     // region GUI
-    @ConfigValue
     public static String
             RUN_OPTION_TITLE = "Run options",
             RUN_CHAT_OPTION = "Chat output",
@@ -15,7 +17,6 @@ public class Message {
             RUN_BOOK_OPTION_LORE = "Will redirect the output to written book";
     // endregion
     // region info
-    @ConfigValue
     public static String PROJECTS = "projects",
             EXECUTION_START = ChatColor.BLUE + "Running project {0}",
             RIGHT_CLICK_TO_EDIT = ChatColor.BLUE + "Right click to edit. Move to cancel",
@@ -26,7 +27,6 @@ public class Message {
             DELETE_FILE = ChatColor.RED + "delete file",
             EDIT_CANCELLED = ChatColor.DARK_RED + "Cancelled editing file {0}";
     //region error
-    @ConfigValue
     public static String CMD_PLAYER_ONLY = ChatColor.RED + "Only players can use this command",
             LANGUAGE_AND_NAME_REQUIRED = ChatColor.RED + "You need to specify a language and a name for the project",
             NAME_REQUIRED = ChatColor.RED + "You need to specify a name!",
@@ -34,7 +34,6 @@ public class Message {
             NOT_PROJECT_OWNER = ChatColor.RED + "You are not the owner of this project";
     // endregion
     //region success
-    @ConfigValue
     public static String PROJECT_CREATE_SUCCESS = ChatColor.GREEN + "Project created successfully",
             RUN_PROJECT_SUCCESS = ChatColor.GREEN + "Ran project \"{0}\" successfully. Here is your output:",
             EDIT_SUCCESS = ChatColor.GREEN + "Edited file {0} successfully";

From aeff1e566aac0b90335206deb58af56d21375ee6 Mon Sep 17 00:00:00 2001
From: the-codeboy <71213855+the-codeboy@users.noreply.github.com>
Date: Tue, 12 Oct 2021 18:58:11 +0200
Subject: [PATCH 03/16] =?UTF-8?q?create=20new=20pages=20when=20item=20does?=
 =?UTF-8?q?n=C2=B4t=20fit?=
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit

---
 src/main/java/com/github/codeboy/mcide/ide/gui/ProjectMenu.java | 2 ++
 1 file changed, 2 insertions(+)

diff --git a/src/main/java/com/github/codeboy/mcide/ide/gui/ProjectMenu.java b/src/main/java/com/github/codeboy/mcide/ide/gui/ProjectMenu.java
index f8c0ad1..657e80c 100644
--- a/src/main/java/com/github/codeboy/mcide/ide/gui/ProjectMenu.java
+++ b/src/main/java/com/github/codeboy/mcide/ide/gui/ProjectMenu.java
@@ -49,6 +49,8 @@ public void addFile(MCCodeFile file, boolean mainFile) {
         int files=project.getMCCodeFiles().size()-1;
         int pageNumber=files/filesPerPage;
         int slotNumber=files%filesPerPage;
+        if(pageNumber>=getPages().size())
+            createPage();
         Gui page= getPages().get(pageNumber);
         page.addItem(fileItem, slotNumber, p -> project.editFile(file, p));
     }

From 535b7a66fb6886c9e9656bdfef11522b2407b4ee Mon Sep 17 00:00:00 2001
From: the-codeboy <71213855+the-codeboy@users.noreply.github.com>
Date: Tue, 12 Oct 2021 19:09:57 +0200
Subject: [PATCH 04/16] fix add file

---
 .../com/github/codeboy/mcide/ide/gui/ProjectMenu.java     | 8 +++++---
 1 file changed, 5 insertions(+), 3 deletions(-)

diff --git a/src/main/java/com/github/codeboy/mcide/ide/gui/ProjectMenu.java b/src/main/java/com/github/codeboy/mcide/ide/gui/ProjectMenu.java
index 657e80c..e198f07 100644
--- a/src/main/java/com/github/codeboy/mcide/ide/gui/ProjectMenu.java
+++ b/src/main/java/com/github/codeboy/mcide/ide/gui/ProjectMenu.java
@@ -49,9 +49,11 @@ public void addFile(MCCodeFile file, boolean mainFile) {
         int files=project.getMCCodeFiles().size()-1;
         int pageNumber=files/filesPerPage;
         int slotNumber=files%filesPerPage;
-        if(pageNumber>=getPages().size())
-            createPage();
-        Gui page= getPages().get(pageNumber);
+        ArrayList<Gui>pages=getPages();
+        while (pageNumber>=pages.size()) {
+            pages.add(createPage());
+        }
+        Gui page= pages.get(pageNumber);
         page.addItem(fileItem, slotNumber, p -> project.editFile(file, p));
     }
 

From e89399904eac41e20204258b2ec5a428d9ea03cf Mon Sep 17 00:00:00 2001
From: ThreshMain <martinkos007@gmail.com>
Date: Wed, 13 Oct 2021 10:51:13 +0200
Subject: [PATCH 05/16] Fixed NPE by using latest BukkitBootstrap

---
 pom.xml | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/pom.xml b/pom.xml
index a2f6a93..ba081fb 100644
--- a/pom.xml
+++ b/pom.xml
@@ -93,7 +93,7 @@
         <dependency>
             <groupId>com.github.the-codeboy</groupId>
             <artifactId>BukkitBootstrap</artifactId>
-            <version>24875ef2c6</version>
+            <version>f6879926bc</version>
         </dependency>
     </dependencies>
 </project>

From 0e651c4617883fecf81a1ccfa813fee4d424bf93 Mon Sep 17 00:00:00 2001
From: ThreshMain <martinkos007@gmail.com>
Date: Wed, 13 Oct 2021 10:51:48 +0200
Subject: [PATCH 06/16] Added next and previous button to the ProjectMenu +
 formatting

---
 .../codeboy/mcide/ide/gui/ProjectMenu.java    | 29 ++++++++++---------
 1 file changed, 15 insertions(+), 14 deletions(-)

diff --git a/src/main/java/com/github/codeboy/mcide/ide/gui/ProjectMenu.java b/src/main/java/com/github/codeboy/mcide/ide/gui/ProjectMenu.java
index e198f07..5f593f0 100644
--- a/src/main/java/com/github/codeboy/mcide/ide/gui/ProjectMenu.java
+++ b/src/main/java/com/github/codeboy/mcide/ide/gui/ProjectMenu.java
@@ -7,14 +7,13 @@
 import ml.codeboy.bukkitbootstrap.gui.Gui;
 import ml.codeboy.bukkitbootstrap.gui.MultiPageGui;
 import org.bukkit.Material;
-import org.bukkit.inventory.Inventory;
 import org.bukkit.inventory.ItemStack;
 
 import java.util.ArrayList;
 
 public class ProjectMenu extends MultiPageGui {
     private final CodeProject project;
-    private final int filesPerPage=9*4;
+    private final int filesPerPage = 9 * 4;
 
     public ProjectMenu(CodeProject project) {
         super(Mcide.getPlugin(Mcide.class), 54, project.getTitle(), (Gui page) -> {
@@ -46,26 +45,28 @@ protected int getPrevButtonIndex() {
 
     public void addFile(MCCodeFile file, boolean mainFile) {
         ItemStack fileItem = createItem(Material.BOOK_AND_QUILL, file.getName(), mainFile);
-        int files=project.getMCCodeFiles().size()-1;
-        int pageNumber=files/filesPerPage;
-        int slotNumber=files%filesPerPage;
-        ArrayList<Gui>pages=getPages();
-        while (pageNumber>=pages.size()) {
+        int files = project.getMCCodeFiles().size() - 1;
+        int pageNumber = files / filesPerPage;
+        int slotNumber = files % filesPerPage;
+        ArrayList<Gui> pages = getPages();
+        while (pageNumber >= pages.size()) {
+            addNextButton(pages.get(pages.size() - 1));
             pages.add(createPage());
+            addPrevButton(pages.get(pages.size() - 1));
         }
-        Gui page= pages.get(pageNumber);
+        Gui page = pages.get(pageNumber);
         page.addItem(fileItem, slotNumber, p -> project.editFile(file, p));
     }
 
     public void removeFile() {
-        int files=project.getMCCodeFiles().size()-1;
-        int pageNumber=files/filesPerPage;
-        int slotNumber=files%filesPerPage;
-        Gui page= getPages().get(pageNumber);
+        int files = project.getMCCodeFiles().size() - 1;
+        int pageNumber = files / filesPerPage;
+        int slotNumber = files % filesPerPage;
+        Gui page = getPages().get(pageNumber);
         page.removeItem(slotNumber);
     }
 
-    private boolean isProjectFile(ItemStack itemStack){
-        return itemStack!=null&&itemStack.getType()==Material.BOOK_AND_QUILL;
+    private boolean isProjectFile(ItemStack itemStack) {
+        return itemStack != null && itemStack.getType() == Material.BOOK_AND_QUILL;
     }
 }

From 29fecff795515ec0ae0d528e68d54eac47cfde21 Mon Sep 17 00:00:00 2001
From: the-codeboy <71213855+the-codeboy@users.noreply.github.com>
Date: Wed, 13 Oct 2021 11:21:02 +0200
Subject: [PATCH 07/16] remove unnecessary variable

---
 src/main/java/com/github/codeboy/mcide/config/Message.java | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/src/main/java/com/github/codeboy/mcide/config/Message.java b/src/main/java/com/github/codeboy/mcide/config/Message.java
index 6cda028..52e3694 100644
--- a/src/main/java/com/github/codeboy/mcide/config/Message.java
+++ b/src/main/java/com/github/codeboy/mcide/config/Message.java
@@ -4,7 +4,7 @@
 import ml.codeboy.bukkitbootstrap.config.Configurable;
 import org.bukkit.ChatColor;
 
-@Configurable(name = "message.yml",comments = "Edit these messages however you like\n" +
+@Configurable(comments = "Edit these messages however you like\n" +
         "It should be self explanatory where they are used",scope = ConfigScope.PUBLIC)
 public class Message {
 

From 132751b30e9d181b97c31468d4f7355ac1550731 Mon Sep 17 00:00:00 2001
From: ThreshMain <martinkos007@gmail.com>
Date: Wed, 13 Oct 2021 12:42:02 +0200
Subject: [PATCH 08/16] Update issue templates

---
 .github/ISSUE_TEMPLATE/bug_report.md      | 33 +++++++++++++++++++++++
 .github/ISSUE_TEMPLATE/feature_request.md | 20 ++++++++++++++
 2 files changed, 53 insertions(+)
 create mode 100644 .github/ISSUE_TEMPLATE/bug_report.md
 create mode 100644 .github/ISSUE_TEMPLATE/feature_request.md

diff --git a/.github/ISSUE_TEMPLATE/bug_report.md b/.github/ISSUE_TEMPLATE/bug_report.md
new file mode 100644
index 0000000..3264ffe
--- /dev/null
+++ b/.github/ISSUE_TEMPLATE/bug_report.md
@@ -0,0 +1,33 @@
+---
+name: Bug report
+about: Create a report to help us improve
+title: "[BUG] "
+labels: bug
+assignees: ''
+
+---
+
+**Describe the bug**
+A clear and concise description of what the bug is.
+
+**To Reproduce**
+Steps to reproduce the behavior:
+1. Go to '...'
+2. Click on '....'
+3. Scroll down to '....'
+4. See error
+
+**Expected behavior**
+A clear and concise description of what you expected to happen.
+
+**Screenshots**
+If applicable, add screenshots to help explain your problem.
+
+**Desktop (please complete the following information):**
+ - OS: [e.g. Windows 11, Linux]
+ - Java version: [e.g. OpenJDK 1.8, 17]
+ - Minecraft version: [e.g. 1.8.8, 1.16.1]
+ - Plugin version: [e.g. 1.1, 1.2]
+
+**Additional context**
+Add any other context about the problem here.
diff --git a/.github/ISSUE_TEMPLATE/feature_request.md b/.github/ISSUE_TEMPLATE/feature_request.md
new file mode 100644
index 0000000..11fc491
--- /dev/null
+++ b/.github/ISSUE_TEMPLATE/feature_request.md
@@ -0,0 +1,20 @@
+---
+name: Feature request
+about: Suggest an idea for this project
+title: ''
+labels: enhancement
+assignees: ''
+
+---
+
+**Is your feature request related to a problem? Please describe.**
+A clear and concise description of what the problem is. Ex. I'm always frustrated when [...]
+
+**Describe the solution you'd like**
+A clear and concise description of what you want to happen.
+
+**Describe alternatives you've considered**
+A clear and concise description of any alternative solutions or features you've considered.
+
+**Additional context**
+Add any other context or screenshots about the feature request here.

From 01d8ede7a5710f3a4254dc39fda63bd5a8907a97 Mon Sep 17 00:00:00 2001
From: the-codeboy <71213855+the-codeboy@users.noreply.github.com>
Date: Wed, 13 Oct 2021 13:06:25 +0200
Subject: [PATCH 09/16] Add Test cases for MCCodeFileTest

---
 pom.xml                                       |  18 ++--
 .../codeboy/mcide/ide/MCCodeFileTest.java     | 102 ++++++++++++++++++
 2 files changed, 114 insertions(+), 6 deletions(-)
 create mode 100644 src/test/java/com/github/codeboy/mcide/ide/MCCodeFileTest.java

diff --git a/pom.xml b/pom.xml
index ba081fb..729d68f 100644
--- a/pom.xml
+++ b/pom.xml
@@ -44,6 +44,18 @@
                     </execution>
                 </executions>
             </plugin>
+            <plugin>
+                <groupId>org.apache.maven.plugins</groupId>
+                <artifactId>maven-surefire-plugin</artifactId>
+                <version>2.22.1</version>
+                <dependencies>
+                    <dependency>
+                        <groupId>org.junit.jupiter</groupId>
+                        <artifactId>junit-jupiter-engine</artifactId>
+                        <version>5.2.0</version>
+                    </dependency>
+                </dependencies>
+            </plugin>
         </plugins>
         <resources>
             <resource>
@@ -84,12 +96,6 @@
             <artifactId>Piston4J</artifactId>
             <version>v0.0.6</version>
         </dependency>
-        <dependency>
-            <groupId>org.junit.jupiter</groupId>
-            <artifactId>junit-jupiter</artifactId>
-            <version>RELEASE</version>
-            <scope>test</scope>
-        </dependency>
         <dependency>
             <groupId>com.github.the-codeboy</groupId>
             <artifactId>BukkitBootstrap</artifactId>
diff --git a/src/test/java/com/github/codeboy/mcide/ide/MCCodeFileTest.java b/src/test/java/com/github/codeboy/mcide/ide/MCCodeFileTest.java
new file mode 100644
index 0000000..a8ad13a
--- /dev/null
+++ b/src/test/java/com/github/codeboy/mcide/ide/MCCodeFileTest.java
@@ -0,0 +1,102 @@
+package com.github.codeboy.mcide.ide;
+
+import com.github.codeboy.piston4j.api.CodeFile;
+import org.junit.Before;
+import org.junit.Test;
+
+import java.util.Random;
+
+import static org.junit.Assert.*;
+
+public class MCCodeFileTest {
+
+    private Random random;
+
+    @Before
+    public void setUp() {
+        random = new Random();
+    }
+
+    private String randomString(int length) {
+        byte[] bytes = new byte[length];
+        random.nextBytes(bytes);
+        return new String(bytes);
+    }
+
+    @Test
+    public void getName() {
+        MCCodeFile codeFile = new MCCodeFile();
+        assertEquals("Name of codefile without name should be \"unnamed\"", "unnamed", codeFile.getName());
+    }
+
+    @Test
+    public void setName() {
+        MCCodeFile codeFile = new MCCodeFile();
+        String name = randomString(10);
+
+        codeFile.setName(name);
+
+        assertEquals("Name of codefile didnĀ“t return correct name after setting it", name, codeFile.getName());
+    }
+
+    @Test
+    public void getContent() {
+        MCCodeFile codeFile = new MCCodeFile();
+        String[] content = codeFile.getContent();
+
+        assertArrayEquals("Content should be empty by default", new String[0], content);
+    }
+
+    @Test
+    public void setContent() {
+        MCCodeFile codeFile = new MCCodeFile();
+        String[] expectedContent = {randomString(5), randomString(5)};
+        codeFile.setContent(expectedContent);
+
+        String[] content = codeFile.getContent();
+
+        assertArrayEquals("Content not the same after changing it", expectedContent,content);
+    }
+
+    @Test
+    public void isMainFile() {
+        MCCodeFile codeFile = new MCCodeFile();
+        assertFalse("Codefile should not be main file by default", codeFile.isMainFile());
+    }
+
+    @Test
+    public void setMainFile() {
+        MCCodeFile codeFile = new MCCodeFile();
+        codeFile.setMainFile(true);
+        assertTrue("Codefile is not main file after setting it as main file", codeFile.isMainFile());
+    }
+
+    @Test
+    public void getProject() {
+        MCCodeFile codeFile = new MCCodeFile();
+        assertNull("Project should be null by default", codeFile.getProject());
+    }
+
+    @Test
+    public void setProject() {
+
+    }
+
+    @Test
+    public void toCodeFile() {
+        MCCodeFile mcCodeFile = new MCCodeFile();
+
+        assertCodeFileEquals(mcCodeFile, mcCodeFile.toCodeFile());
+
+        mcCodeFile.setContent(randomString(15), randomString(20));
+
+        assertCodeFileEquals(mcCodeFile, mcCodeFile.toCodeFile());
+    }
+
+    private void assertCodeFileEquals(MCCodeFile mcCodeFile, CodeFile codeFile) {
+        assertNotNull("McCodeFile should not be null", mcCodeFile);
+        assertNotNull("CodeFile should not be null", codeFile);
+
+        // no further tests because there currently CodeFile does not offer a way of accessing the content or name
+    }
+}
\ No newline at end of file

From fd398153432df23fa40927a56601e2bf06877998 Mon Sep 17 00:00:00 2001
From: the-codeboy <71213855+the-codeboy@users.noreply.github.com>
Date: Wed, 13 Oct 2021 12:04:49 +0200
Subject: [PATCH 10/16] add glass panes as decoration to ProjectMenu

---
 .../com/github/codeboy/mcide/ide/gui/ProjectMenu.java | 11 +++++++++++
 1 file changed, 11 insertions(+)

diff --git a/src/main/java/com/github/codeboy/mcide/ide/gui/ProjectMenu.java b/src/main/java/com/github/codeboy/mcide/ide/gui/ProjectMenu.java
index 5f593f0..d62e02d 100644
--- a/src/main/java/com/github/codeboy/mcide/ide/gui/ProjectMenu.java
+++ b/src/main/java/com/github/codeboy/mcide/ide/gui/ProjectMenu.java
@@ -4,6 +4,7 @@
 import com.github.codeboy.mcide.config.Message;
 import com.github.codeboy.mcide.ide.CodeProject;
 import com.github.codeboy.mcide.ide.MCCodeFile;
+import ml.codeboy.bukkitbootstrap.gui.Action;
 import ml.codeboy.bukkitbootstrap.gui.Gui;
 import ml.codeboy.bukkitbootstrap.gui.MultiPageGui;
 import org.bukkit.Material;
@@ -43,6 +44,16 @@ protected int getPrevButtonIndex() {
         return 50;
     }
 
+    @Override
+    protected Gui createPage() {
+        Gui gui= super.createPage();
+        ItemStack item = createItem(Material.STAINED_GLASS_PANE,"-");
+        for (int i = 0; i < 9; i++) {
+            gui.addItemLast(item, Action.none);
+        }
+        return gui;
+    }
+
     public void addFile(MCCodeFile file, boolean mainFile) {
         ItemStack fileItem = createItem(Material.BOOK_AND_QUILL, file.getName(), mainFile);
         int files = project.getMCCodeFiles().size() - 1;

From e5a577b42101d7e1a3a0d1c68bac2abbd37a3a00 Mon Sep 17 00:00:00 2001
From: the-codeboy <martinkos007@gmail.com>
Date: Wed, 13 Oct 2021 23:34:01 +0200
Subject: [PATCH 11/16] Fixed glass panes and removeFiles removing main file

---
 .../codeboy/mcide/ide/gui/ProjectMenu.java    | 39 +++++++++++--------
 1 file changed, 22 insertions(+), 17 deletions(-)

diff --git a/src/main/java/com/github/codeboy/mcide/ide/gui/ProjectMenu.java b/src/main/java/com/github/codeboy/mcide/ide/gui/ProjectMenu.java
index d62e02d..3c87323 100644
--- a/src/main/java/com/github/codeboy/mcide/ide/gui/ProjectMenu.java
+++ b/src/main/java/com/github/codeboy/mcide/ide/gui/ProjectMenu.java
@@ -46,35 +46,40 @@ protected int getPrevButtonIndex() {
 
     @Override
     protected Gui createPage() {
-        Gui gui= super.createPage();
-        ItemStack item = createItem(Material.STAINED_GLASS_PANE,"-");
+        Gui gui = super.createPage();
+        ItemStack item = createItem(Material.STAINED_GLASS_PANE, "-");
         for (int i = 0; i < 9; i++) {
-            gui.addItemLast(item, Action.none);
+            gui.addItem(item, 54 - 18 + i, Action.none);
         }
         return gui;
     }
 
     public void addFile(MCCodeFile file, boolean mainFile) {
         ItemStack fileItem = createItem(Material.BOOK_AND_QUILL, file.getName(), mainFile);
-        int files = project.getMCCodeFiles().size() - 1;
-        int pageNumber = files / filesPerPage;
-        int slotNumber = files % filesPerPage;
         ArrayList<Gui> pages = getPages();
-        while (pageNumber >= pages.size()) {
-            addNextButton(pages.get(pages.size() - 1));
-            pages.add(createPage());
-            addPrevButton(pages.get(pages.size() - 1));
+        int index = 0;
+        Gui lastPage;
+        do {
+            lastPage = pages.get(index++);
+        } while (lastPage.getFreeSlot() > filesPerPage && index < pages.size());
+        int freeSlot = lastPage.getFreeSlot();
+        if (freeSlot > filesPerPage) {
+            addNextButton(lastPage);
+            lastPage = createPage();
+            pages.add(lastPage);
+            addPrevButton(lastPage);
         }
-        Gui page = pages.get(pageNumber);
-        page.addItem(fileItem, slotNumber, p -> project.editFile(file, p));
+        lastPage.addItem(fileItem, p -> project.editFile(file, p));
     }
 
     public void removeFile() {
-        int files = project.getMCCodeFiles().size() - 1;
-        int pageNumber = files / filesPerPage;
-        int slotNumber = files % filesPerPage;
-        Gui page = getPages().get(pageNumber);
-        page.removeItem(slotNumber);
+        int files = project.getMCCodeFiles().size();
+        if (!project.getMCCodeFiles().get(files - 1).isMainFile()) {
+            int pageNumber = files / filesPerPage;
+            int slotNumber = files % filesPerPage;
+            Gui page = getPages().get(pageNumber);
+            page.removeItem(slotNumber);
+        }
     }
 
     private boolean isProjectFile(ItemStack itemStack) {

From 70e1ee983bde851924cfe3df274faa1d7eb966f0 Mon Sep 17 00:00:00 2001
From: the-codeboy <martinkos007@gmail.com>
Date: Wed, 13 Oct 2021 23:38:54 +0200
Subject: [PATCH 12/16] Updated versioning system

---
 pom.xml | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/pom.xml b/pom.xml
index 729d68f..962cee4 100644
--- a/pom.xml
+++ b/pom.xml
@@ -6,7 +6,7 @@
 
     <groupId>com.github.codeboy</groupId>
     <artifactId>mcide</artifactId>
-    <version>1.2-SNAPSHOT</version>
+    <version>1.2.1</version>
     <packaging>jar</packaging>
 
     <name>Mcide</name>

From 3fb6a32371a4e35d460606b8c6489552741b62b3 Mon Sep 17 00:00:00 2001
From: ThreshMain <martinkos007@gmail.com>
Date: Tue, 12 Oct 2021 17:01:35 +0200
Subject: [PATCH 13/16] item-bound command to get item which opens project menu

---
 .../java/com/github/codeboy/mcide/Mcide.java  | 11 +++++
 .../mcide/commands/BoundItemCommand.java      | 40 +++++++++++++++++++
 src/main/resources/plugin.yml                 |  3 +-
 3 files changed, 53 insertions(+), 1 deletion(-)
 create mode 100644 src/main/java/com/github/codeboy/mcide/commands/BoundItemCommand.java

diff --git a/src/main/java/com/github/codeboy/mcide/Mcide.java b/src/main/java/com/github/codeboy/mcide/Mcide.java
index cedbf64..83b5f39 100644
--- a/src/main/java/com/github/codeboy/mcide/Mcide.java
+++ b/src/main/java/com/github/codeboy/mcide/Mcide.java
@@ -1,5 +1,6 @@
 package com.github.codeboy.mcide;
 
+import com.github.codeboy.mcide.commands.BoundItemCommand;
 import com.github.codeboy.mcide.commands.CreateProject;
 import com.github.codeboy.mcide.commands.IdeCommand;
 import com.github.codeboy.mcide.commands.RunCommand;
@@ -9,8 +10,10 @@
 import com.github.codeboy.piston4j.api.ExecutionResult;
 import com.github.codeboy.piston4j.api.Piston;
 import com.google.gson.Gson;
+import ml.codeboy.bukkitbootstrap.CustomItem;
 import ml.codeboy.bukkitbootstrap.config.ConfigReader;
 import org.bukkit.ChatColor;
+import org.bukkit.Material;
 import org.bukkit.command.Command;
 import org.bukkit.command.CommandSender;
 import org.bukkit.event.EventHandler;
@@ -18,6 +21,7 @@
 import org.bukkit.event.player.PlayerJoinEvent;
 import org.bukkit.plugin.java.JavaPlugin;
 
+import javax.management.InstanceAlreadyExistsException;
 import java.io.File;
 import java.util.Arrays;
 import java.util.List;
@@ -38,6 +42,11 @@ public static Piston getPiston() {
     @Override
     public void onEnable() {
         // Plugin startup logic
+        try {
+            CustomItem item = CustomItem.createItem("Open menu", Material.GOLD_HOE, (short) 0);
+        } catch (InstanceAlreadyExistsException e) {
+            e.printStackTrace();
+        }
 
         readConfigs();
 
@@ -47,6 +56,8 @@ public void onEnable() {
         getCommand("run").setExecutor(new RunCommand());
         getCommand("ide").setExecutor(new IdeCommand());
         getCommand("create-project").setExecutor(new CreateProject());
+        getCommand("bound-item").setExecutor(new BoundItemCommand());
+        getServer().getPluginManager().registerEvents(new BoundItemCommand(), this);
         getServer().getPluginManager().registerEvents(new Listener() {
             @EventHandler
             public void onPlayerJoin(PlayerJoinEvent event) {
diff --git a/src/main/java/com/github/codeboy/mcide/commands/BoundItemCommand.java b/src/main/java/com/github/codeboy/mcide/commands/BoundItemCommand.java
new file mode 100644
index 0000000..e5070a8
--- /dev/null
+++ b/src/main/java/com/github/codeboy/mcide/commands/BoundItemCommand.java
@@ -0,0 +1,40 @@
+package com.github.codeboy.mcide.commands;
+
+import com.github.codeboy.mcide.ide.gui.ProjectSelector;
+import ml.codeboy.bukkitbootstrap.CustomItem;
+import org.bukkit.command.Command;
+import org.bukkit.command.CommandExecutor;
+import org.bukkit.command.CommandSender;
+import org.bukkit.entity.Player;
+import org.bukkit.event.EventHandler;
+import org.bukkit.event.Listener;
+import org.bukkit.event.player.PlayerInteractEvent;
+import org.bukkit.inventory.ItemStack;
+
+public class BoundItemCommand implements CommandExecutor, Listener {
+    @Override
+    public boolean onCommand(CommandSender sender, Command command, String label, String[] args) {
+        if (!(sender instanceof Player)) {
+            return false;
+        }
+        Player player = (Player) sender;
+        CustomItem item = CustomItem.getItem("Open menu");
+        if (item != null) {
+            player.getInventory().addItem(item.getItem());
+            return true;
+        }
+        return false;
+    }
+
+    @EventHandler
+    public void onPlayerUse(PlayerInteractEvent event) {
+        Player player = event.getPlayer();
+        ItemStack item = player.getItemInHand();
+        CustomItem customItem = CustomItem.getItem("Open menu");
+        if (customItem != null && customItem.itemIsInstance(item) && player.getOpenInventory() != null) {
+            ProjectSelector menu = new ProjectSelector(player);
+            menu.open(player);
+            event.setCancelled(true);
+        }
+    }
+}
diff --git a/src/main/resources/plugin.yml b/src/main/resources/plugin.yml
index 50de563..03a3e95 100644
--- a/src/main/resources/plugin.yml
+++ b/src/main/resources/plugin.yml
@@ -7,4 +7,5 @@ website: https://github.com/the-codeboy
 commands:
   run:
   ide:
-  create-project:
\ No newline at end of file
+  create-project:
+  bound-item:
\ No newline at end of file

From ca32ea42c2bdfe69e3f0d5ce6ec66d8cf4ffeeae Mon Sep 17 00:00:00 2001
From: the-codeboy <martinkos007@gmail.com>
Date: Wed, 13 Oct 2021 23:44:36 +0200
Subject: [PATCH 14/16] Upgraded bukkit-boot-strap version

---
 pom.xml | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/pom.xml b/pom.xml
index 962cee4..f510849 100644
--- a/pom.xml
+++ b/pom.xml
@@ -99,7 +99,7 @@
         <dependency>
             <groupId>com.github.the-codeboy</groupId>
             <artifactId>BukkitBootstrap</artifactId>
-            <version>f6879926bc</version>
+            <version>6b7cd63491</version>
         </dependency>
     </dependencies>
 </project>

From c22b1a107b5eaf16f4d268338fd7e7200a47b44c Mon Sep 17 00:00:00 2001
From: the-codeboy <martinkos007@gmail.com>
Date: Thu, 14 Oct 2021 00:58:00 +0200
Subject: [PATCH 15/16] Upgraded custom item even management and fixed all
 issues with bound-item

---
 pom.xml                                       |  2 +-
 .../java/com/github/codeboy/mcide/Mcide.java  | 10 ++---
 .../mcide/commands/BoundItemCommand.java      | 38 ++++++++-----------
 .../services/CustomItemEventManager.java      | 35 +++++++++++++++++
 4 files changed, 55 insertions(+), 30 deletions(-)
 create mode 100644 src/main/java/com/github/codeboy/mcide/services/CustomItemEventManager.java

diff --git a/pom.xml b/pom.xml
index f510849..8645d27 100644
--- a/pom.xml
+++ b/pom.xml
@@ -99,7 +99,7 @@
         <dependency>
             <groupId>com.github.the-codeboy</groupId>
             <artifactId>BukkitBootstrap</artifactId>
-            <version>6b7cd63491</version>
+            <version>f821d5e8d4</version>
         </dependency>
     </dependencies>
 </project>
diff --git a/src/main/java/com/github/codeboy/mcide/Mcide.java b/src/main/java/com/github/codeboy/mcide/Mcide.java
index 83b5f39..9cfb8db 100644
--- a/src/main/java/com/github/codeboy/mcide/Mcide.java
+++ b/src/main/java/com/github/codeboy/mcide/Mcide.java
@@ -6,6 +6,7 @@
 import com.github.codeboy.mcide.commands.RunCommand;
 import com.github.codeboy.mcide.config.Config;
 import com.github.codeboy.mcide.config.Message;
+import com.github.codeboy.mcide.services.CustomItemEventManager;
 import com.github.codeboy.piston4j.api.ExecutionOutput;
 import com.github.codeboy.piston4j.api.ExecutionResult;
 import com.github.codeboy.piston4j.api.Piston;
@@ -42,12 +43,6 @@ public static Piston getPiston() {
     @Override
     public void onEnable() {
         // Plugin startup logic
-        try {
-            CustomItem item = CustomItem.createItem("Open menu", Material.GOLD_HOE, (short) 0);
-        } catch (InstanceAlreadyExistsException e) {
-            e.printStackTrace();
-        }
-
         readConfigs();
 
         piston = Piston.getInstance(Config.pistonEndPoint);
@@ -57,7 +52,6 @@ public void onEnable() {
         getCommand("ide").setExecutor(new IdeCommand());
         getCommand("create-project").setExecutor(new CreateProject());
         getCommand("bound-item").setExecutor(new BoundItemCommand());
-        getServer().getPluginManager().registerEvents(new BoundItemCommand(), this);
         getServer().getPluginManager().registerEvents(new Listener() {
             @EventHandler
             public void onPlayerJoin(PlayerJoinEvent event) {
@@ -65,6 +59,8 @@ public void onPlayerJoin(PlayerJoinEvent event) {
             }
         }, this);
 
+        getServer().getPluginManager().registerEvents(new CustomItemEventManager(), Mcide.getPlugin(Mcide.class));
+
     }
 
     private void readConfigs() {
diff --git a/src/main/java/com/github/codeboy/mcide/commands/BoundItemCommand.java b/src/main/java/com/github/codeboy/mcide/commands/BoundItemCommand.java
index e5070a8..bab14a5 100644
--- a/src/main/java/com/github/codeboy/mcide/commands/BoundItemCommand.java
+++ b/src/main/java/com/github/codeboy/mcide/commands/BoundItemCommand.java
@@ -1,40 +1,34 @@
 package com.github.codeboy.mcide.commands;
 
 import com.github.codeboy.mcide.ide.gui.ProjectSelector;
+import com.github.codeboy.mcide.services.CustomItemEventManager;
 import ml.codeboy.bukkitbootstrap.CustomItem;
+import org.bukkit.Material;
 import org.bukkit.command.Command;
 import org.bukkit.command.CommandExecutor;
 import org.bukkit.command.CommandSender;
 import org.bukkit.entity.Player;
-import org.bukkit.event.EventHandler;
-import org.bukkit.event.Listener;
-import org.bukkit.event.player.PlayerInteractEvent;
-import org.bukkit.inventory.ItemStack;
+import org.bukkit.event.block.Action;
 
-public class BoundItemCommand implements CommandExecutor, Listener {
+public class BoundItemCommand implements CommandExecutor {
     @Override
     public boolean onCommand(CommandSender sender, Command command, String label, String[] args) {
         if (!(sender instanceof Player)) {
             return false;
         }
         Player player = (Player) sender;
-        CustomItem item = CustomItem.getItem("Open menu");
-        if (item != null) {
-            player.getInventory().addItem(item.getItem());
-            return true;
-        }
-        return false;
-    }
+        CustomItem customItem =  CustomItem.createItemOrGet("Open menu", Material.GOLD_HOE, (short) 0);
+        player.getInventory().addItem(customItem.getItem());
 
-    @EventHandler
-    public void onPlayerUse(PlayerInteractEvent event) {
-        Player player = event.getPlayer();
-        ItemStack item = player.getItemInHand();
-        CustomItem customItem = CustomItem.getItem("Open menu");
-        if (customItem != null && customItem.itemIsInstance(item) && player.getOpenInventory() != null) {
-            ProjectSelector menu = new ProjectSelector(player);
-            menu.open(player);
-            event.setCancelled(true);
-        }
+        CustomItemEventManager.addInteraction(customItem, event -> {
+            if (event.getAction() == Action.RIGHT_CLICK_AIR || event.getAction() == Action.RIGHT_CLICK_BLOCK) {
+                Player p = event.getPlayer();
+                event.setCancelled(true);
+                ProjectSelector menu = new ProjectSelector(p);
+                menu.open(p);
+                event.setCancelled(true);
+            }
+        });
+        return true;
     }
 }
diff --git a/src/main/java/com/github/codeboy/mcide/services/CustomItemEventManager.java b/src/main/java/com/github/codeboy/mcide/services/CustomItemEventManager.java
new file mode 100644
index 0000000..1057a9d
--- /dev/null
+++ b/src/main/java/com/github/codeboy/mcide/services/CustomItemEventManager.java
@@ -0,0 +1,35 @@
+package com.github.codeboy.mcide.services;
+
+import ml.codeboy.bukkitbootstrap.CustomItem;
+import org.bukkit.entity.Player;
+import org.bukkit.event.EventHandler;
+import org.bukkit.event.Listener;
+import org.bukkit.event.player.PlayerInteractEvent;
+import org.bukkit.inventory.ItemStack;
+
+import java.util.HashMap;
+import java.util.function.Consumer;
+
+public class CustomItemEventManager implements Listener {
+
+    private static final HashMap<CustomItem, Consumer<PlayerInteractEvent>> interactions = new HashMap<>();
+
+    @EventHandler
+    public void onPlayerUse(PlayerInteractEvent event) {
+        Player player = event.getPlayer();
+        ItemStack item = player.getItemInHand();
+        for(CustomItem customItem:interactions.keySet()){
+            if (customItem.itemIsInstance(item)) {
+                interactions.get(customItem).accept(event);
+            }
+        }
+    }
+
+    public static boolean addInteraction(CustomItem customItem,Consumer<PlayerInteractEvent> interaction){
+        if(interactions.containsKey(customItem)){
+            return false;
+        }
+        interactions.put(customItem,interaction);
+        return true;
+    }
+}

From cef63e77bdec97cf4e0ffa1837b26461db4d0a23 Mon Sep 17 00:00:00 2001
From: the-codeboy <martinkos007@gmail.com>
Date: Thu, 14 Oct 2021 12:13:00 +0200
Subject: [PATCH 16/16] Removed hard coded item name

---
 .../com/github/codeboy/mcide/commands/BoundItemCommand.java   | 3 ++-
 src/main/java/com/github/codeboy/mcide/config/Message.java    | 4 ++++
 2 files changed, 6 insertions(+), 1 deletion(-)

diff --git a/src/main/java/com/github/codeboy/mcide/commands/BoundItemCommand.java b/src/main/java/com/github/codeboy/mcide/commands/BoundItemCommand.java
index bab14a5..99660b7 100644
--- a/src/main/java/com/github/codeboy/mcide/commands/BoundItemCommand.java
+++ b/src/main/java/com/github/codeboy/mcide/commands/BoundItemCommand.java
@@ -1,5 +1,6 @@
 package com.github.codeboy.mcide.commands;
 
+import com.github.codeboy.mcide.config.Message;
 import com.github.codeboy.mcide.ide.gui.ProjectSelector;
 import com.github.codeboy.mcide.services.CustomItemEventManager;
 import ml.codeboy.bukkitbootstrap.CustomItem;
@@ -17,7 +18,7 @@ public boolean onCommand(CommandSender sender, Command command, String label, St
             return false;
         }
         Player player = (Player) sender;
-        CustomItem customItem =  CustomItem.createItemOrGet("Open menu", Material.GOLD_HOE, (short) 0);
+        CustomItem customItem =  CustomItem.createItemOrGet(player.getPlayerListName(), Material.GOLD_HOE, (short) 0);
         player.getInventory().addItem(customItem.getItem());
 
         CustomItemEventManager.addInteraction(customItem, event -> {
diff --git a/src/main/java/com/github/codeboy/mcide/config/Message.java b/src/main/java/com/github/codeboy/mcide/config/Message.java
index 52e3694..0f3d962 100644
--- a/src/main/java/com/github/codeboy/mcide/config/Message.java
+++ b/src/main/java/com/github/codeboy/mcide/config/Message.java
@@ -8,6 +8,10 @@
         "It should be self explanatory where they are used",scope = ConfigScope.PUBLIC)
 public class Message {
 
+    // region CUSTOM_ITEM
+    public static String
+            ITEM_PROJECT_SELECTOR = "Open Menu";
+    // endregion
     // region GUI
     public static String
             RUN_OPTION_TITLE = "Run options",