Skip to content

Commit

Permalink
feat: Network Restructure
Browse files Browse the repository at this point in the history
  • Loading branch information
CoasterFreakDE committed Jun 11, 2024
1 parent 07dbe37 commit 2ef1cc9
Show file tree
Hide file tree
Showing 32 changed files with 325 additions and 179 deletions.
2 changes: 1 addition & 1 deletion .github/FUNDING.yml
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
# These are supported funding model platforms

github: [coasterfreakde]
github: [ coasterfreakde ]
8 changes: 5 additions & 3 deletions .github/ISSUE_TEMPLATE/bug_report.md
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@ 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 '....'
Expand All @@ -24,9 +25,10 @@ A clear and concise description of what you expected to happen.
If applicable, add screenshots to help explain your problem.

**Desktop (please complete the following information):**
- OS: [e.g. Win11]
- IDE [e.g. intellij, vsc]
- Gradle Verson [e.g. 1.3.3]

- OS: [e.g. Win11]
- IDE [e.g. intellij, vsc]
- Gradle Verson [e.g. 1.3.3]

**Additional context**
Add any other context about the problem here.
27 changes: 21 additions & 6 deletions CONTRIBUTING.md
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
# Contributing to DevSky Boilerplates

We love your input! We want to make contributing to this project as easy and transparent as possible, whether it's:

- Reporting a bug
Expand All @@ -8,10 +9,13 @@ We love your input! We want to make contributing to this project as easy and tra
- Becoming a maintainer

## We Develop with Github

We use github to host code, to track issues and feature requests, as well as accept pull requests.

## We Use [Github Flow](https://guides.github.com/introduction/flow/index.html), So All Code Changes Happen Through Pull Requests
Pull requests are the best way to propose changes to the codebase (we use [Github Flow](https://guides.github.com/introduction/flow/index.html)). We actively welcome your pull requests:

Pull requests are the best way to propose changes to the codebase (we
use [Github Flow](https://guides.github.com/introduction/flow/index.html)). We actively welcome your pull requests:

1. Fork the repo and create your branch from `master`.
2. If you've added code that should be tested, add tests.
Expand All @@ -21,20 +25,28 @@ Pull requests are the best way to propose changes to the codebase (we use [Githu
6. Issue that pull request!

## Any contributions you make will be under the MIT Software License
In short, when you submit code changes, your submissions are understood to be under the same [MIT License](http://choosealicense.com/licenses/mit/) that covers the project. Feel free to contact the maintainers if that's a concern.

In short, when you submit code changes, your submissions are understood to be under the
same [MIT License](http://choosealicense.com/licenses/mit/) that covers the project. Feel free to contact the
maintainers if that's a concern.

## Report bugs using Github's [issues](https://github.com/briandk/transcriptase-atom/issues)

We use GitHub issues to track public bugs. Report a bug by [opening a new issue](); it's that easy!

## Write bug reports with detail, background, and sample code
[This is an example](http://stackoverflow.com/q/12488905/180626) of a bug report I wrote, and I think it's not a bad model. Here's [another example from Craig Hockenberry](http://www.openradar.me/11905408), an app developer whom I greatly respect.

[This is an example](http://stackoverflow.com/q/12488905/180626) of a bug report I wrote, and I think it's not a bad
model. Here's [another example from Craig Hockenberry](http://www.openradar.me/11905408), an app developer whom I
greatly respect.

**Great Bug Reports** tend to have:

- A quick summary and/or background
- Steps to reproduce
- Be specific!
- Give sample code if you can. [My stackoverflow question](http://stackoverflow.com/q/12488905/180626) includes sample code that *anyone* with a base R setup can run to reproduce what I was seeing
- Be specific!
- Give sample code if you can. [My stackoverflow question](http://stackoverflow.com/q/12488905/180626) includes
sample code that *anyone* with a base R setup can run to reproduce what I was seeing
- What you expected would happen
- What actually happens
- Notes (possibly including why you think this might be happening, or stuff you tried that didn't work)
Expand All @@ -46,7 +58,10 @@ People *love* thorough bug reports. I'm not even kidding.
* Stay close to the languages code style

## License

By contributing, you agree that your contributions will be licensed under its MIT License.

## References
This document was adapted from the open-source contribution guidelines for [Facebook's Draft](https://github.com/facebook/draft-js/blob/main/CONTRIBUTING.md)

This document was adapted from the open-source contribution guidelines
for [Facebook's Draft](https://github.com/facebook/draft-js/blob/main/CONTRIBUTING.md)
50 changes: 30 additions & 20 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -5,15 +5,16 @@
</a>
</div>

<h3 align="center">Energetic Storage Reborn</h3>
<h3 align="center">Energetic Storage Reborn</h3>

Energetic Storage Reborn is a plugin that is heavily inspired by the forge mods
named [Applied Energistics 2](https://www.curseforge.com/minecraft/mc-mods/applied-energistics-2)
and [Refined Storage](https://www.curseforge.com/minecraft/mc-mods/refined-storage).
If you don't know what Applied Energistics 2 is, it's a mod that allows the player to store large numbers of items,
sometimes hundreds of thousands, in just a few blocks.

Energetic Storage Reborn is a complete recode for Minecraft 1.20.6 of the original [Energetic Storage](https://github.com/SeanOMik/EnergeticStorage).
Energetic Storage Reborn is a complete recode for Minecraft 1.20.6 of the
original [Energetic Storage](https://github.com/SeanOMik/EnergeticStorage).
It is significantly more modern,
designed exclusively for PaperMC, Java 21, Kotlin, and Minecraft 1.20.6+,
utilizing the latest features the game has to offer.
Expand All @@ -26,29 +27,31 @@ If you run into any issues,
---

## Features:

* [ ] Networking
* [x] Cables (Data Transmissions)
* [ ] Network Cores
* [x] DiskDrives
* [x] Disks
* [ ] Terminals
* [ ] Terminal Sorting
* [ ] Importer
* [ ] Hopper Input
* [ ] Exporter
* [x] Configurable Network Length
* [x] Cables (Data Transmissions)
* [ ] Network Cores
* [x] DiskDrives
* [x] Disks
* [ ] Terminals
* [ ] Terminal Sorting
* [ ] Importer
* [ ] Hopper Input
* [ ] Exporter
* [x] Configurable Network Length
* [ ] Player/Region Whitelist
* [ ] Lands Integration
* [ ] Lands Integration
* [x] Support for 1.20.6
* [x] MySQL, MariaDB, SQLite, PostgreSQL, and H2 support



## Items And Blocks:

* 1k, 4k, 16k, and 64k, drives
* The drives are needed to store items. 1k can store 1024 items, 4k can store 4096 and so on (1024 * how many thousand).
* All drives have a type limit set at 64, 128, 256 or 512. This means that only this amount of different item types can be added to a single drive.
* Can be changed in config.
* The drives are needed to store items. 1k can store 1024 items, 4k can store 4096 and so on (1024 * how many
thousand).
* All drives have a type limit set at 64, 128, 256 or 512. This means that only this amount of different item types
can be added to a single drive.
* Can be changed in config.
* ES System
* The ES System is what keeps the drives inside it and is used to access the items stored on the drives.
* You can trust players into the system; they will have just as much access as you do.
Expand All @@ -59,20 +62,26 @@ If you run into any issues,
* Only trusted players and the owner of the system can destroy it.

## Permissions

* `energeticstorage.*`: Gives all Energetic Storage permissions. Default: `op`
* `energeticstorage.reload`: Gives permission to reload the Energetic Storage configuration files. Default: `op`
* `energeticstorage.esgive`: Gives permission to give an Energetic Storage item to themselves. Default: `op`
* `energeticstorage.esgive.others`: Gives permission to give an Energetic Storage item to others. Default: `op`
* `energeticstorage.system.open.untrusted`: Gives permission to open an ES System that the player is not trusted on. Default: `op`
* `energeticstorage.system.open.untrusted`: Gives permission to open an ES System that the player is not trusted on.
Default: `op`
* `energeticstorage.system.create`: Gives permission to create an ES System. Default: `Everyone`
* `energeticstorage.system.destroy.untrusted`: Gives permission to destroy a system the player isn't trusted on. Default: `op`
* `energeticstorage.system.destroy.untrusted`: Gives permission to destroy a system the player isn't trusted on.
Default: `op`

## Commands

* /esreload
* /esgive [1k, 4k, 16k, 64k, system] (player)

## Config:

Config.yml:

```yaml
drives:
# Sets the drives max type limit.
Expand Down Expand Up @@ -108,6 +117,7 @@ storage:
username: "root"
password: "password"
```
---
<p align="center">
Expand Down
8 changes: 0 additions & 8 deletions gradle.properties
Original file line number Diff line number Diff line change
@@ -1,24 +1,16 @@
kotlin.code.style=official

minecraftVersion=1.20.6

kotlinxSerializationJsonVersion=1.7.0

exposedVersion=0.51.1
hikariCPVersion=5.1.0

mysqlVersion=8.4.0
postgresqlVersion=42.7.3
mariaDBVersion=3.4.0
sqliteVersion=3.46.0.0
h2Version=2.2.224

fruxzAscendVersion=2024.2.1
fruxzStackedVersion=2024.1.1

kotlinxCoroutinesCoreVersion=1.9.0-RC
kotlinxCollectionsImmutableVersion=0.3.7

gsonVersion=2.11.0

slf4jVersion=2.0.13
1 change: 0 additions & 1 deletion settings.gradle.kts
Original file line number Diff line number Diff line change
@@ -1,3 +1,2 @@

rootProject.name = "EnergeticStorage-Reborn"

Original file line number Diff line number Diff line change
Expand Up @@ -12,8 +12,8 @@ const val TEXT_GRADIENT_DEFAULT = "<gradient:#f6e58d:#ffbe76>"
const val PACKAGE_NAME = "com.liamxsage.energeticstorage"

val DISK_ID_NAMESPACE = NamespacedKey(EnergeticStorage.instance, "disk_id")
val DISK_DRIVE_ID_NAMESPACE = NamespacedKey(EnergeticStorage.instance, "disk_drive_id")
val NETWORK_INTERFACE_NAMESPACE = NamespacedKey(EnergeticStorage.instance, "network_interface")
val NETWORK_INTERFACE_ID_NAMESPACE = NamespacedKey(EnergeticStorage.instance, "network_interface_id")

val PLAYER_DEBUG_MODE_NAMESPACE = NamespacedKey(EnergeticStorage.instance, "debug_mode")

Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
package com.liamxsage.energeticstorage.cache

import com.liamxsage.energeticstorage.model.Disk
import java.util.UUID
import java.util.*
import java.util.concurrent.locks.ReadWriteLock
import java.util.concurrent.locks.ReentrantReadWriteLock

Expand Down

This file was deleted.

Original file line number Diff line number Diff line change
@@ -0,0 +1,39 @@
package com.liamxsage.energeticstorage.cache

import com.liamxsage.energeticstorage.network.NetworkInterface
import java.util.*
import java.util.concurrent.locks.ReadWriteLock
import java.util.concurrent.locks.ReentrantReadWriteLock

object NetworkInterfaceCache {

private val cacheLock: ReadWriteLock = ReentrantReadWriteLock()
private var cache = mapOf<UUID, NetworkInterface>()

fun getNetworkInterfaceByUUID(interfaceUUID: UUID): NetworkInterface? {
cacheLock.readLock().lock()
val networkInterface = cache[interfaceUUID]
cacheLock.readLock().unlock()
return networkInterface
}

fun addNetworkInterface(networkInterface: NetworkInterface) {
cacheLock.writeLock().lock()
cache = cache + (networkInterface.uuid to networkInterface)
cacheLock.writeLock().unlock()
}

fun removeNetworkInterfaceByUUID(interfaceUUID: UUID) {
cacheLock.writeLock().lock()
cache = cache - interfaceUUID
cacheLock.writeLock().unlock()
}

fun getCachedNetworkInterfaces(): List<NetworkInterface> {
cacheLock.readLock().lock()
val networkInterfaces = cache.values.toList()
cacheLock.readLock().unlock()
return networkInterfaces
}

}
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,12 @@ class ESDebugCommand : CommandExecutor, TabExecutor {
return true
}

override fun onTabComplete(sender: CommandSender, command: Command, label: String, args: Array<out String>): List<String> {
override fun onTabComplete(
sender: CommandSender,
command: Command,
label: String,
args: Array<out String>
): List<String> {
return when (args.size) {
1 -> listOf("on", "off")
else -> emptyList()
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -40,17 +40,22 @@ class ESGiveCommand : CommandExecutor, TabExecutor {
"system" -> {
DiskDrive().createDiskDriveItem()
}

"core" -> {
Core().createCoreItem()
}

"cable" -> {
Cable().createCableItem()
}

"terminal" -> {
Terminal().createTerminalItem()
}

else -> {
val diskSize = DiskSize.entries.find { it.diskName.lowercase(Locale.getDefault()) == item.replace("_", " ") }
val diskSize =
DiskSize.entries.find { it.diskName.lowercase(Locale.getDefault()) == item.replace("_", " ") }
if (diskSize == null) {
sender.sendMessagePrefixed("<red>Invalid drive size")
return true
Expand All @@ -67,15 +72,28 @@ class ESGiveCommand : CommandExecutor, TabExecutor {
return true
}

override fun onTabComplete(sender: CommandSender, command: Command, label: String, args: Array<out String>): List<String> {
override fun onTabComplete(
sender: CommandSender,
command: Command,
label: String,
args: Array<out String>
): List<String> {
return when (args.size) {
1 -> {
listOf("system", "core", "cable", "terminal", *DiskSize.entries.map { it.diskName.replace(" ", "_") }.toTypedArray())
.filter { it.startsWith(args[0], ignoreCase = true)}
listOf(
"system",
"core",
"cable",
"terminal",
*DiskSize.entries.map { it.diskName.replace(" ", "_") }.toTypedArray()
)
.filter { it.startsWith(args[0], ignoreCase = true) }
}

2 -> {
Bukkit.getOnlinePlayers().map { it.name }.filter { it.startsWith(args[1], ignoreCase = true)}
Bukkit.getOnlinePlayers().map { it.name }.filter { it.startsWith(args[1], ignoreCase = true) }
}

else -> {
emptyList()
}
Expand Down
Loading

0 comments on commit 2ef1cc9

Please sign in to comment.