Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Dev #1

Merged
merged 5 commits into from
Apr 14, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 6 additions & 3 deletions .github/workflows/maven.yml
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,10 @@ name: Java CI with Maven
on:
push:
branches:
- dev
- main
pull_request:
branches:
- main

jobs:
buildRelese:
Expand All @@ -37,8 +40,8 @@ jobs:
uses: "marvinpinto/action-automatic-releases@latest"
with:
repo_token: "${{ secrets.GITHUB_TOKEN }}"
automatic_release_tag: "pre-${{ github.sha }}"
automatic_release_tag: "b-${{ github.sha }}"
prerelease: false
title: "Development Build pre-${{ github.sha }}"
title: "Development Build ${{ github.sha }}"
files: |
./target/${{ vars.JAR_NAME }}.jar
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1,2 +1,3 @@
.idea/
target
commands.md
37 changes: 37 additions & 0 deletions commands.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@

## Categories
### 1. Gamemodes
```
/gmc /gms /gmsp /gmc
/gamemode|gm <gamemode> [player]
```
### 2. Teleportation
```
/setspawn
/spawn
```
### 3. Inventory
```
/invsee <player>
/workbench /craft /wb
/anvil
/enchanttable /et
/enderchest /ec
```
### 4. Chat
```
/cmdspy
/clearchat
/lockchat
```
### 5. Utils
```
/feed /heal /fly /speed
/whois /ping
/msg <player> <message>
/r <message>
```
### 6. Weather
```
/day /night /sun /rain /thunder
```
20 changes: 20 additions & 0 deletions dependency-reduced-pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -92,6 +92,14 @@
<id>sonatype</id>
<url>https://oss.sonatype.org/content/groups/public/</url>
</repository>
<repository>
<id>jitpack.io</id>
<url>https://jitpack.io</url>
</repository>
<repository>
<id>placeholderapi</id>
<url>https://repo.extendedclip.com/content/repositories/placeholderapi/</url>
</repository>
</repositories>
<dependencies>
<dependency>
Expand All @@ -106,6 +114,18 @@
<version>1.9.23</version>
<scope>test</scope>
</dependency>
<dependency>
<groupId>com.github.MilkBowl</groupId>
<artifactId>VaultAPI</artifactId>
<version>1.7</version>
<scope>provided</scope>
</dependency>
<dependency>
<groupId>me.clip</groupId>
<artifactId>placeholderapi</artifactId>
<version>2.11.5</version>
<scope>provided</scope>
</dependency>
</dependencies>
<properties>
<kotlin.version>1.9.23</kotlin.version>
Expand Down
20 changes: 20 additions & 0 deletions pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -107,6 +107,14 @@
<id>sonatype</id>
<url>https://oss.sonatype.org/content/groups/public/</url>
</repository>
<repository>
<id>jitpack.io</id>
<url>https://jitpack.io</url>
</repository>
<repository>
<id>placeholderapi</id>
<url>https://repo.extendedclip.com/content/repositories/placeholderapi/</url>
</repository>
</repositories>

<dependencies>
Expand Down Expand Up @@ -142,5 +150,17 @@
<version>${kotlin.version}</version>
<scope>test</scope>
</dependency>
<dependency>
<groupId>com.github.MilkBowl</groupId>
<artifactId>VaultAPI</artifactId>
<version>1.7</version>
<scope>provided</scope>
</dependency>
<dependency>
<groupId>me.clip</groupId>
<artifactId>placeholderapi</artifactId>
<version>2.11.5</version>
<scope>provided</scope>
</dependency>
</dependencies>
</project>
66 changes: 66 additions & 0 deletions readme.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,66 @@
# XaCore

## Description
Plugin that contains basic commands and features for a Minecraft server. <br>
Supports Vault and PlaceholderAPI. <br>

<details>
<summary><b>Commands categories</b></summary>

#### 1. Gamemodes
```
/gmc /gms /gmsp /gmc
/gamemode|gm <gamemode> [player]
```
#### 2. Teleportation
```
/setspawn
/spawn
```
#### 3. Inventory
```
/invsee <player>
/workbench /craft /wb
/anvil
/enchanttable /et
/enderchest /ec
```
#### 4. Chat
```
/cmdspy
/clearchat
/lockchat
```
#### 5. Utils
```
/feed /heal /fly /speed
/whois /ping
/msg <player> <message>
/r <message>
```
#### 6. Weather
```
/day /night /sun /rain /thunder
```
</details>
<br>
<details>
<summary><b>Features</b></summary>

- Supporting PAPI placeholders in all messages (in lang.yml)
- Customizable join/quit messages and chat format
- Command blacklist
- Spawn on join, gamemode on join
- Customizable world flags like: disable fall damage, block break etc..

</details>
<br>
<details>
<summary><b>TODO</b></summary>

- MOTD
- Customizable tablist
- Customizable scoreboard
- Tpa, tpahere, tpaccept, tpdeny
- Warps, homes
</details>
100 changes: 81 additions & 19 deletions src/main/java/me/xap3y/xacore/Main.kt
Original file line number Diff line number Diff line change
@@ -1,13 +1,17 @@
package me.xap3y.xacore

import me.xap3y.xacore.api.config.ConfigManager
import me.xap3y.xacore.api.config.StorageManager
import me.xap3y.xacore.api.enums.CommandCategory
import me.xap3y.xacore.api.text.Texter
import me.xap3y.xacore.commands.*
import me.xap3y.xacore.listeners.PlayerChatListener
import me.xap3y.xacore.listeners.PlayerCommandPreprocessListener
import me.xap3y.xacore.listeners.PlayerJoinListener
import me.xap3y.xacore.listeners.PlayerQuitListener
import me.xap3y.xacore.listeners.*
import me.xap3y.xacore.utils.Helper
import me.xap3y.xacore.utils.HookManager
import net.milkbowl.vault.chat.Chat
import net.milkbowl.vault.permission.Permission
import org.apache.logging.log4j.CloseableThreadContext.Instance
import org.bukkit.command.CommandSender
import org.bukkit.entity.Player
import org.bukkit.event.Listener
import org.bukkit.plugin.PluginManager
import org.bukkit.plugin.java.JavaPlugin
Expand All @@ -19,12 +23,21 @@ import java.io.File

class Main : JavaPlugin() {

lateinit var configManager: ConfigManager
lateinit var storageManager: StorageManager
lateinit var configFile: File
lateinit var messageFile: File
lateinit var logFile: File
lateinit var vaultPair: Pair<Chat, Permission>

var chatLocked = false
var useVault = false
var usePapi = false

val textApi: Texter by lazy { Texter(this) }
val helper: Helper by lazy { Helper(this) }
val textApi: Texter by lazy { Texter(this) }
val whisperPlayers: HashMap<CommandSender, CommandSender> = hashMapOf()
val cmdSpyToggles: MutableSet<Player> = mutableSetOf()


override fun onEnable() {

Expand All @@ -33,35 +46,82 @@ class Main : JavaPlugin() {

configFile = File(dataFolder, "config.yml")
messageFile = File(dataFolder, "lang.yml")
logFile = File(dataFolder, "logs.txt")

configManager = ConfigManager(this)
configManager.loadConfig()
configManager.loadLang()
storageManager = StorageManager(this)
storageManager.loadConfig()
storageManager.loadLang()

useVault = config.getBoolean("hookVault")

val commandManager = createCommandManager()
val annotationParser = createAnnotationParser(commandManager)

annotationParser.parse(RootCommand(this))
annotationParser.parse(Gamemodes(this))
annotationParser.parse(WeatherCommands(this))
annotationParser.parse(AdminCommands(this))
annotationParser.parse(UtilityCommands(this))

regiserListeners()
val commandCategories: HashMap<CommandCategory, Any> =
hashMapOf(
CommandCategory.GAMEMODE to GamemodeCommands(this),
CommandCategory.WEATHER to WeatherCommands(this),
CommandCategory.CHAT to ChatCommands(this),
CommandCategory.INVENTORY to InventoryCommands(this),
CommandCategory.UTILS to UtilityCommands(this),
CommandCategory.TELEPORT to TeleportationCommands(this)
)

val list = config.getList("commandCategoriesDisabled") ?: listOf()

commandCategories.forEach { (k, v) ->
if (list.contains(k.name.lowercase())) return@forEach
annotationParser.parse(v)
}

registerListeners()

// Hooks
val hookManager = HookManager(this)

if (useVault) {
val pair = hookManager.hookVault()

if (pair !== null)
vaultPair = pair
else
if (useVault) useVault = false
}

if (config.getBoolean("hookPlaceholderAPI")) {
if (hookManager.hookPAPI())
usePapi = true
else
if (usePapi) usePapi = false
}

val time = System.currentTimeMillis()
val date = java.util.Date(time)
val humanDate = date.toString()

storageManager.logInfo("Plugin enabled at $humanDate")

}

override fun onDisable() {
// Plugin shutdown logic
val time = System.currentTimeMillis()
val date = java.util.Date(time)
val humanDate = date.toString()

storageManager.logInfo("Plugin disabled at $humanDate")
}

private fun regiserListeners() {
private fun registerListeners() {
val list: Set<Listener> = setOf(
PlayerJoinListener(this),
PlayerQuitListener(this),
PlayerChatListener(this),
PlayerCommandPreprocessListener(this)
PlayerCommandPreprocessListener(this),
EntityDamageListener(this),
BlockListener(this),
ServerCommandListener(this.storageManager),
FoodLevelChangeListener(this)
)

val pm: PluginManager = server.pluginManager
Expand Down Expand Up @@ -99,4 +159,6 @@ class Main : JavaPlugin() {

fun isConfigFileInit() = ::configFile.isInitialized
fun isLangFileInit() = ::messageFile.isInitialized
fun isVaultPairInit() = ::vaultPair.isInitialized
fun isLogFileInit() = ::logFile.isInitialized
}
42 changes: 0 additions & 42 deletions src/main/java/me/xap3y/xacore/api/config/ConfigManager.kt

This file was deleted.

Loading
Loading