Skip to content

Commit

Permalink
Merge pull request #6 from PineappleDevelopmentGroup/dev
Browse files Browse the repository at this point in the history
Publish Up To Date Documentation
  • Loading branch information
Y2Kwastaken authored Mar 2, 2024
2 parents f3450d4 + 7ac8cba commit 8fae867
Show file tree
Hide file tree
Showing 22 changed files with 449 additions and 67 deletions.
48 changes: 46 additions & 2 deletions docusaurus.config.js
Original file line number Diff line number Diff line change
Expand Up @@ -99,6 +99,28 @@ const config = {
...remarkPluginsConfig
},
],
[
'@docusaurus/plugin-content-docs',
{
id: 'pineapple-plugins',
path: 'pineapple-plugins',
routeBasePath: 'pineapple-plugins',
sidebarPath: require.resolve('./sidebars/pineapplesidebar.js'),
editUrl: "https://github.com/PineappleDevelopmentGroup/PineappleDocs/tree/master",
...remarkPluginsConfig
},
],
[
'@docusaurus/plugin-content-docs',
{
id: 'pineapple-guides',
path: 'pineapple-guides',
routeBasePath: 'pineapple-guides',
sidebarPath: require.resolve('./sidebars/pineapplesidebar.js'),
editUrl: "https://github.com/PineappleDevelopmentGroup/PineappleDocs/tree/master",
...remarkPluginsConfig
},
],
],

themeConfig:
Expand All @@ -120,15 +142,37 @@ const config = {
items: [
{
type: 'doc',
docId: 'libraries/index',
position: 'left',
label: 'Libraries',
docId: 'index',
docsPluginId: 'pineapple-lib',
label: 'Pineapple Lib',
},
{
type: 'doc',
position: 'left',
docId: 'index',
docsPluginId: 'pineapple-chat',
label: 'Pineapple Chat',
},
{
type: "docsVersionDropdown",
position: "right",
docsPluginId: 'pineapple-lib',
},
{
type: 'doc',
position: 'left',
docId: 'index',
docsPluginId: 'pineapple-plugins',
label: 'Plugins',
},
{
type: 'doc',
position: 'left',
docId: 'index',
docsPluginId: 'pineapple-guides',
label: 'Dev Guides',
},
{to: '/blog', label: 'Blog', position: 'left'},
{
href: 'https://github.com/PineappleDevelopmentGroup',
Expand Down
Binary file added pineapple-guides/debugging/img/step1/i1.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added pineapple-guides/debugging/img/step1/i2.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added pineapple-guides/debugging/img/step2/i1.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added pineapple-guides/debugging/img/step2/i2.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added pineapple-guides/debugging/img/step2/i3.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added pineapple-guides/debugging/img/step3/i1.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added pineapple-guides/debugging/img/step3/i2.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added pineapple-guides/debugging/img/step3/i3.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added pineapple-guides/debugging/img/step3/i4.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added pineapple-guides/debugging/img/step4/i1.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added pineapple-guides/debugging/img/step4/i2.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added pineapple-guides/debugging/img/step4/i3.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added pineapple-guides/debugging/img/step5/i1.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added pineapple-guides/debugging/img/step5/i2.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
66 changes: 66 additions & 0 deletions pineapple-guides/debugging/index.mdx
Original file line number Diff line number Diff line change
@@ -0,0 +1,66 @@
---
title: Debugging
---

# Debugging

This demo will show how to setup Debugging inside of IntelliJ IDEA (Community and Ultimate). Debugging can be used on most if not all Java projects but for this we will be using spigot

## Setup

### Step 1 - Run Configuration Creation

Open the run configuration screen. This can be found in the top right of your project screen, it may have a current run configuration open that you use for your project or just say Edit Configurations.


<details>
<summary>Images</summary>
##### Images
![Run Configuration None Selected](./img/step1/i1.png)
![Run Configuration Already Selected](./img/step1/i2.png)
</details>

### Step 2 - Run Configuration Modification

Create a new debug run configuration and modify any info. Inside the popup window "Run/Debug Configurations" press the plus icon near the top left and find "Remove JVM Debug", click on that then you have your run configuration. You can now modify the name or port, for this example we will use "Server Debug" and keep the port as the default 5005. \
For Step 3 you should keep this screen open.
<details>
<summary>Images</summary>
##### Images
![Opening the run configuration screen](./img/step2/i1.png)
![Creating the debug configuration](./img/step2/i2.png)
![Configuring the name](./img/step2/i3.png)
</details>

### Step 3 - Server Modification

Now we need to tell our server how to connect to this Debug Configuration. Inside of the run configuration window for your Debug Configuration you should have a box called "Command line argument for remote JVM", copy everything inside this box and now apply and close the window. Once thats completed we need to now give the argument to our server. This will change depending on how you start your server, we will be using a shell script inside this example. Stop your server and open the startup script, now locate the line that starts your server. It might look something like this `java -jar spigot-1.20.4.jar`. Before the jar name paste that argument you got from IntelliJ and save the file, the line should now look like `java -agentlib:jdwp=transport=dt_socket,server=y,suspend=n,address=*:5005 -jar spigot-1.20.4.jar`.
<details>
<summary>Images</summary>
##### Images
![Copying the argument](./img/step3/i1.png)
![Saving the run configuration](./img/step3/i2.png)
![Adding to startup args](./img/step3/i3.png)
![Finished args](./img/step3/i4.png)
</details>

### Step 4 - Creating Breakpoints

Start your server, the server now knows how to connect to intellij and start tracking your code. Now run the debug task by selecting the run configuration in the top right and press the red Bug icon, and now its running. To debug something you will need to add breakpoints into your code. This is done by clicking in the gutter of a line of code and a red dot should appear and the line turns red, now trigger the code from your server, for example running a command or triggering an event. Once the code runs intellij will pause the server and give you a view of what is currently happening, this includes values and method calls. Now you can inspect whats happening, once you are happy with what you see press the play button in the debug panel at the bottom, near the left side of it and that will continue the server or run untill your next break point triggers.
<details>
<summary>Images</summary>
##### Images
![Selecting the run configuration](./img/step4/i1.png)
![Starting the run configuration](./img/step4/i2.png)
![Adding a breakpoint](./img/step4/i3.png)
</details>

### Step 5 - Stopping the debugger

That is all you need to do to debug your server, to stop it just stop the run configuration in by pressing the red stop icon in the top right if you still have the run configuration selected, if not press the red stop icon in the debug panel.
<details>
<summary>Images</summary>
##### Images
![Stopping from run configuration selection](./img/step5/i1.png)
![Stopping from the debug panel](./img/step5/i2.png)
</details>
12 changes: 12 additions & 0 deletions pineapple-guides/index.mdx
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
---
title: Guides
sidebar_position: 1
---

# Our Guides

Here are some of our useful guides to help you start Java/Kotlin Development or setup a dev environment

## Debugging

Debugging your projects can be incredibly useful for you as it allows to you pause code at runtime and inspect the flow and value of a variable. It also can save type as you wouldnt need to recompile and add debug statements to your project, find more info [here](/debugging/)
78 changes: 17 additions & 61 deletions pineapple-lib/config.md
Original file line number Diff line number Diff line change
Expand Up @@ -12,16 +12,16 @@ You need to initialize PineappleLib with `PineappleLib.initialize(Plugin)` befor

All the annotations PineappleLib provides for your configs

### @ConfigEntry
### @ConfigPath

This annoation is the only annotation required for your configs to work, it registeres a variable as a config entry and allows you to set the path of it inside of your YAML file.
Example:

#### Parent Section

```java
@ConfigEntry("foo")
public String bar = "foobar";
@ConfigPath("foo")
public static String bar = "foobar";
```

Will end up as the following in config
Expand All @@ -33,7 +33,7 @@ foo: "foobar"
#### Sub Section
```java
@ConfigEntry("foo.bar")
@ConfigPath("foo.bar")
public static String bar = "foobar";
```

Expand All @@ -53,8 +53,8 @@ Example:
```java title: "One comment"
@Comment("foobar, foobar")
@ConfigEntry("foo")
public String bar = "foobar";
@ConfigPath("foo")
public static String bar = "foobar";
```

Will end up as the following in config
Expand All @@ -69,8 +69,8 @@ foo: "foobar"
```java title: "One comment"
@Comment("foobar, foobar")
@Comment("barfoo, barfoo")
@ConfigEntry("foo")
public String bar = "foobar";
@ConfigPath("foo")
public static String bar = "foobar";
```

Will end up as the following in config
Expand All @@ -81,68 +81,24 @@ Will end up as the following in config
foo: "foobar"
```
### @PostLoad
The PostLoad annotation allows for you to run a method once a config has been loaded, you could use this for modifying the value once available or having an item stack with a configurable material
## Instanced Config
Pineapple allows for multiple types of config setups. To create an instance based config you will need to use [#createReloadable(File, T)](https://maven.miles.sh/javadoc/libraries/sh/miles/Pineapple/1.0.0-SNAPSHOT/raw/sh/miles/pineapple/config/ConfigurationManager.html#createReloadable(java.io.File,T))
```java title="PluginSettings.java"
public class PluginSettings {

@ConfigEntry("foo")
public String bar = "foobar";

}
```

```java title="PluginMain.java"
private PluginSettings settings = new PluginSettings();
private ConfigReloadable<PluginSettings> pluginConfig;

private void setupConfig() {
pluginConfig = PineappleLib.getConfigurationManager().createReloadable(new File(this.getDataFolder(), "config.yml"), this.settings);
pluginConfig.saveDefaults().load();
}

public void reload() {
pluginConfig.load();
}

public PluginSettings getSettings() {
return this.settings;
}
```

Accessing the values:

```java
public void sendValue(Player player) {
player.sendMessage(PluginMain#getSettings().bar);
}
```
## Creating a Reloadable Config
## Static Config

To create a static based config you will need to use [#createStaticReloadable(File, Class\<T\>)](https://maven.miles.sh/javadoc/libraries/sh/miles/Pineapple/1.0.0-SNAPSHOT/raw/sh/miles/pineapple/config/ConfigurationManager.html#createStaticReloadable(java.io.File,java.lang.Class))
All configs inside of Pineapple are reloadable you just have to retain an instance of the ConfigWrapper
```java title="PluginSettings.java"
public class PluginSettings {

@ConfigEntry("foo")
@ConfigPath("foo")
public static String BAR = "foobar"

}
```

```java title="PluginMain.java"
private ConfigReloadable<PluginSettings> pluginConfig;
private ConfigWrapper pluginConfig;

private void setupConfig() {
pluginConfig = PineappleLib.getConfigurationManager().createStaticReloadable(new File(this.getDataFolder(), "config.yml"), PluginSettings.class);
pluginConfig.saveDefaults().load();
pluginConfig = PineappleLib.getConfigurationManager().createDefault(new File(this.getDataFolder(), "config.yml"), PluginSettings.class);
}

public void reload() {
Expand Down Expand Up @@ -187,7 +143,7 @@ public class PlayerData {
The StringAdapter

```java title="PlayerDataAdapter.java"
public class PlayerDataAdapter implements GenericStringAdapter<PlayerData> {
public class PlayerDataAdapter implements TypeAdapterString<PlayerData> {

@Override
public Class<PlayerData> getRuntimeType() {
Expand All @@ -212,7 +168,7 @@ How it would look like used in a config:
```java title="PluginSettings.java"
public class PluginSettings {

@ConfigEntry("owner-data")
@ConfigPath("owner-data")
public static PlayerData OWNER_DATA = new PlayerData(UUID.randomUUID(), 20);

}
Expand All @@ -222,7 +178,7 @@ How to register the adapter:

```java
private void registerAdapter() {
PineappleLib.getConfigurationManager().registerTypeAdapter(PlayerData.class, new PlayerDataAdapter());
PineappleLib.getConfigurationManager().registerTypeAdapter(new PlayerDataAdapter());
}
```

Expand Down Expand Up @@ -295,7 +251,7 @@ How it would look like used in a config:
```java title="PluginSettings.java"
public class PluginSettings {

@ConfigEntry("owner-data")
@ConfigPath("owner-data")
public static PlayerData OWNER_DATA = new PlayerData(UUID.randomUUID(), 20);

}
Expand Down
5 changes: 1 addition & 4 deletions pineapple-lib/index.md
Original file line number Diff line number Diff line change
Expand Up @@ -28,10 +28,7 @@ repositories {

```kotlin tab={"label":"Gradle (Kotlin)"}
repositories {
maven {
name = "Miles Repository"
url = uri("https://maven.miles.sh/libraries")
}
maven("https://maven.miles.sh/libraries")
}
```

Expand Down
Loading

0 comments on commit 8fae867

Please sign in to comment.