7 Commits
2.2 ... main

Author SHA1 Message Date
26aad1c54b Upload file pom.xml via GUI 2026-03-04 11:41:23 +01:00
4d72b64866 Update from Git Manager GUI 2026-03-04 11:41:13 +01:00
673ed06998 README.md aktualisiert 2026-03-04 09:13:51 +00:00
4d805abebe LICENSE gelöscht 2026-03-01 11:15:29 +00:00
9f06c73591 README.md aktualisiert 2026-03-01 11:15:21 +00:00
aa418921db Upload pom.xml via GUI 2026-02-25 18:02:14 +00:00
62e5c3d7f1 Update from Git Manager GUI 2026-02-25 19:02:12 +01:00
9 changed files with 3901 additions and 983 deletions

117
LICENSE
View File

@@ -1,117 +0,0 @@
GNU GENERAL PUBLIC LICENSE
Version 2, June 1991
Copyright (C) 1989, 1991 Free Software Foundation, Inc.
51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA
Everyone is permitted to copy and distribute verbatim copies of this license document, but changing it is not allowed.
Preamble
The licenses for most software are designed to take away your freedom to share and change it. By contrast, the GNU General Public License is intended to guarantee your freedom to share and change free software--to make sure the software is free for all its users. This General Public License applies to most of the Free Software Foundation's software and to any other program whose authors commit to using it. (Some other Free Software Foundation software is covered by the GNU Lesser General Public License instead.) You can apply it to your programs, too.
When we speak of free software, we are referring to freedom, not price. Our General Public Licenses are designed to make sure that you have the freedom to distribute copies of free software (and charge for this service if you wish), that you receive source code or can get it if you want it, that you can change the software or use pieces of it in new free programs; and that you know you can do these things.
To protect your rights, we need to make restrictions that forbid anyone to deny you these rights or to ask you to surrender the rights. These restrictions translate to certain responsibilities for you if you distribute copies of the software, or if you modify it.
For example, if you distribute copies of such a program, whether gratis or for a fee, you must give the recipients all the rights that you have. You must make sure that they, too, receive or can get the source code. And you must show them these terms so they know their rights.
We protect your rights with two steps: (1) copyright the software, and (2) offer you this license which gives you legal permission to copy, distribute and/or modify the software.
Also, for each author's protection and ours, we want to make certain that everyone understands that there is no warranty for this free software. If the software is modified by someone else and passed on, we want its recipients to know that what they have is not the original, so that any problems introduced by others will not reflect on the original authors' reputations.
Finally, any free program is threatened constantly by software patents. We wish to avoid the danger that redistributors of a free program will individually obtain patent licenses, in effect making the program proprietary. To prevent this, we have made it clear that any patent must be licensed for everyone's free use or not licensed at all.
The precise terms and conditions for copying, distribution and modification follow.
TERMS AND CONDITIONS FOR COPYING, DISTRIBUTION AND MODIFICATION
0. This License applies to any program or other work which contains a notice placed by the copyright holder saying it may be distributed under the terms of this General Public License. The "Program", below, refers to any such program or work, and a "work based on the Program" means either the Program or any derivative work under copyright law: that is to say, a work containing the Program or a portion of it, either verbatim or with modifications and/or translated into another language. (Hereinafter, translation is included without limitation in the term "modification".) Each licensee is addressed as "you".
Activities other than copying, distribution and modification are not covered by this License; they are outside its scope. The act of running the Program is not restricted, and the output from the Program is covered only if its contents constitute a work based on the Program (independent of having been made by running the Program). Whether that is true depends on what the Program does.
1. You may copy and distribute verbatim copies of the Program's source code as you receive it, in any medium, provided that you conspicuously and appropriately publish on each copy an appropriate copyright notice and disclaimer of warranty; keep intact all the notices that refer to this License and to the absence of any warranty; and give any other recipients of the Program a copy of this License along with the Program.
You may charge a fee for the physical act of transferring a copy, and you may at your option offer warranty protection in exchange for a fee.
2. You may modify your copy or copies of the Program or any portion of it, thus forming a work based on the Program, and copy and distribute such modifications or work under the terms of Section 1 above, provided that you also meet all of these conditions:
a) You must cause the modified files to carry prominent notices stating that you changed the files and the date of any change.
b) You must cause any work that you distribute or publish, that in whole or in part contains or is derived from the Program or any part thereof, to be licensed as a whole at no charge to all third parties under the terms of this License.
c) If the modified program normally reads commands interactively when run, you must cause it, when started running for such interactive use in the most ordinary way, to print or display an announcement including an appropriate copyright notice and a notice that there is no warranty (or else, saying that you provide a warranty) and that users may redistribute the program under these conditions, and telling the user how to view a copy of this License. (Exception: if the Program itself is interactive but does not normally print such an announcement, your work based on the Program is not required to print an announcement.)
These requirements apply to the modified work as a whole. If identifiable sections of that work are not derived from the Program, and can be reasonably considered independent and separate works in themselves, then this License, and its terms, do not apply to those sections when you distribute them as separate works. But when you distribute the same sections as part of a whole which is a work based on the Program, the distribution of the whole must be on the terms of this License, whose permissions for other licensees extend to the entire whole, and thus to each and every part regardless of who wrote it.
Thus, it is not the intent of this section to claim rights or contest your rights to work written entirely by you; rather, the intent is to exercise the right to control the distribution of derivative or collective works based on the Program.
In addition, mere aggregation of another work not based on the Program with the Program (or with a work based on the Program) on a volume of a storage or distribution medium does not bring the other work under the scope of this License.
3. You may copy and distribute the Program (or a work based on it, under Section 2) in object code or executable form under the terms of Sections 1 and 2 above provided that you also do one of the following:
a) Accompany it with the complete corresponding machine-readable source code, which must be distributed under the terms of Sections 1 and 2 above on a medium customarily used for software interchange; or,
b) Accompany it with a written offer, valid for at least three years, to give any third party, for a charge no more than your cost of physically performing source distribution, a complete machine-readable copy of the corresponding source code, to be distributed under the terms of Sections 1 and 2 above on a medium customarily used for software interchange; or,
c) Accompany it with the information you received as to the offer to distribute corresponding source code. (This alternative is allowed only for noncommercial distribution and only if you received the program in object code or executable form with such an offer, in accord with Subsection b above.)
The source code for a work means the preferred form of the work for making modifications to it. For an executable work, complete source code means all the source code for all modules it contains, plus any associated interface definition files, plus the scripts used to control compilation and installation of the executable. However, as a special exception, the source code distributed need not include anything that is normally distributed (in either source or binary form) with the major components (compiler, kernel, and so on) of the operating system on which the executable runs, unless that component itself accompanies the executable.
If distribution of executable or object code is made by offering access to copy from a designated place, then offering equivalent access to copy the source code from the same place counts as distribution of the source code, even though third parties are not compelled to copy the source along with the object code.
4. You may not copy, modify, sublicense, or distribute the Program except as expressly provided under this License. Any attempt otherwise to copy, modify, sublicense or distribute the Program is void, and will automatically terminate your rights under this License. However, parties who have received copies, or rights, from you under this License will not have their licenses terminated so long as such parties remain in full compliance.
5. You are not required to accept this License, since you have not signed it. However, nothing else grants you permission to modify or distribute the Program or its derivative works. These actions are prohibited by law if you do not accept this License. Therefore, by modifying or distributing the Program (or any work based on the Program), you indicate your acceptance of this License to do so, and all its terms and conditions for copying, distributing or modifying the Program or works based on it.
6. Each time you redistribute the Program (or any work based on the Program), the recipient automatically receives a license from the original licensor to copy, distribute or modify the Program subject to these terms and conditions. You may not impose any further restrictions on the recipients' exercise of the rights granted herein. You are not responsible for enforcing compliance by third parties to this License.
7. If, as a consequence of a court judgment or allegation of patent infringement or for any other reason (not limited to patent issues), conditions are imposed on you (whether by court order, agreement or otherwise) that contradict the conditions of this License, they do not excuse you from the conditions of this License. If you cannot distribute so as to satisfy simultaneously your obligations under this License and any other pertinent obligations, then as a consequence you may not distribute the Program at all. For example, if a patent license would not permit royalty-free redistribution of the Program by all those who receive copies directly or indirectly through you, then the only way you could satisfy both it and this License would be to refrain entirely from distribution of the Program.
If any portion of this section is held invalid or unenforceable under any particular circumstance, the balance of the section is intended to apply and the section as a whole is intended to apply in other circumstances.
It is not the purpose of this section to induce you to infringe any patents or other property right claims or to contest validity of any such claims; this section has the sole purpose of protecting the integrity of the free software distribution system, which is implemented by public license practices. Many people have made generous contributions to the wide range of software distributed through that system in reliance on consistent application of that system; it is up to the author/donor to decide if he or she is willing to distribute software through any other system and a licensee cannot impose that choice.
This section is intended to make thoroughly clear what is believed to be a consequence of the rest of this License.
8. If the distribution and/or use of the Program is restricted in certain countries either by patents or by copyrighted interfaces, the original copyright holder who places the Program under this License may add an explicit geographical distribution limitation excluding those countries, so that distribution is permitted only in or among countries not thus excluded. In such case, this License incorporates the limitation as if written in the body of this License.
9. The Free Software Foundation may publish revised and/or new versions of the General Public License from time to time. Such new versions will be similar in spirit to the present version, but may differ in detail to address new problems or concerns.
Each version is given a distinguishing version number. If the Program specifies a version number of this License which applies to it and "any later version", you have the option of following the terms and conditions either of that version or of any later version published by the Free Software Foundation. If the Program does not specify a version number of this License, you may choose any version ever published by the Free Software Foundation.
10. If you wish to incorporate parts of the Program into other free programs whose distribution conditions are different, write to the author to ask for permission. For software which is copyrighted by the Free Software Foundation, write to the Free Software Foundation; we sometimes make exceptions for this. Our decision will be guided by the two goals of preserving the free status of all derivatives of our free software and of promoting the sharing and reuse of software generally.
NO WARRANTY
11. BECAUSE THE PROGRAM IS LICENSED FREE OF CHARGE, THERE IS NO WARRANTY FOR THE PROGRAM, TO THE EXTENT PERMITTED BY APPLICABLE LAW. EXCEPT WHEN OTHERWISE STATED IN WRITING THE COPYRIGHT HOLDERS AND/OR OTHER PARTIES PROVIDE THE PROGRAM "AS IS" WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. THE ENTIRE RISK AS TO THE QUALITY AND PERFORMANCE OF THE PROGRAM IS WITH YOU. SHOULD THE PROGRAM PROVE DEFECTIVE, YOU ASSUME THE COST OF ALL NECESSARY SERVICING, REPAIR OR CORRECTION.
12. IN NO EVENT UNLESS REQUIRED BY APPLICABLE LAW OR AGREED TO IN WRITING WILL ANY COPYRIGHT HOLDER, OR ANY OTHER PARTY WHO MAY MODIFY AND/OR REDISTRIBUTE THE PROGRAM AS PERMITTED ABOVE, BE LIABLE TO YOU FOR DAMAGES, INCLUDING ANY GENERAL, SPECIAL, INCIDENTAL OR CONSEQUENTIAL DAMAGES ARISING OUT OF THE USE OR INABILITY TO USE THE PROGRAM (INCLUDING BUT NOT LIMITED TO LOSS OF DATA OR DATA BEING RENDERED INACCURATE OR LOSSES SUSTAINED BY YOU OR THIRD PARTIES OR A FAILURE OF THE PROGRAM TO OPERATE WITH ANY OTHER PROGRAMS), EVEN IF SUCH HOLDER OR OTHER PARTY HAS BEEN ADVISED OF THE POSSIBILITY OF SUCH DAMAGES.
END OF TERMS AND CONDITIONS
How to Apply These Terms to Your New Programs
If you develop a new program, and you want it to be of the greatest possible use to the public, the best way to achieve this is to make it free software which everyone can redistribute and change under these terms.
To do so, attach the following notices to the program. It is safest to attach them to the start of each source file to most effectively convey the exclusion of warranty; and each file should have at least the "copyright" line and a pointer to where the full notice is found.
one line to give the program's name and an idea of what it does. Copyright (C) yyyy name of author
This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation; either version 2 of the License, or (at your option) any later version.
This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details.
You should have received a copy of the GNU General Public License along with this program; if not, write to the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. Also add information on how to contact you by electronic and paper mail.
If the program is interactive, make it output a short notice like this when it starts in an interactive mode:
Gnomovision version 69, Copyright (C) year name of author Gnomovision comes with ABSOLUTELY NO WARRANTY; for details type `show w'. This is free software, and you are welcome to redistribute it under certain conditions; type `show c' for details.
The hypothetical commands `show w' and `show c' should show the appropriate parts of the General Public License. Of course, the commands you use may be called something other than `show w' and `show c'; they could even be mouse-clicks or menu items--whatever suits your program.
You should also get your employer (if you work as a programmer) or your school, if any, to sign a "copyright disclaimer" for the program, if necessary. Here is a sample; alter the names:
Yoyodyne, Inc., hereby disclaims all copyright interest in the program `Gnomovision' (which makes passes at compilers) written by James Hacker.
signature of Ty Coon, 1 April 1989 Ty Coon, President of Vice

206
README.md
View File

@@ -16,22 +16,28 @@ Schluss mit unordentlichen Truhen und stundenlangem Sortieren! **AutoSortChest**
## ✨ Features
- **Einfache Schild-Steuerung:** Erstelle Input-, Ziel- und Rest-Truhen durch das Platzieren eines Schildes.
- **Einfache Schild-Steuerung:** Erstelle Input-, Ziel-, Rest- und Mülltruhen durch das Platzieren eines Schildes.
- **Visuelles Status-System:** Schilder ändern ihre Farbe, wenn eine Truhe voll ist, und senden Warnungen im Chat.
- **Smart Rest-Truhe (Fallback):** Konfiguriere eine Auffangtruhe für alle Items ohne spezielles Ziel.
- **Smart Rest-Truhe (Fallback):** Konfiguriere mehrere Auffangtruhen für alle Items ohne spezielles Ziel.
- **Mülltruhe:** Definiere eine Truhe, die bestimmte oder alle Items automatisch vernichtet mit konfigurierbarer Filter-Liste und optionalem Auto-Clear-Intervall.
- **Dynamic Item Update:** Ändere das sortierte Item einer Truhe jederzeit per Rechtsklick kein Abbauen nötig!
- **Mehrere Zieltruhen pro Item:** Definiere mehrere Zieltruhen für denselben Item-Typ volle Truhen werden automatisch übersprungen.
- **Privatsphäre-Modus:** Schalte Truhen per Shift-Rechtsklick zwischen Öffentlich und Privat um.
- **Hopper-Schutz:** Input- und Rest-Truhen blockieren Hopper automatisch Sortierung läuft ausschließlich über das ASC-System.
- **Clean-Modus:** Optionaler sauberer Schild-Stil ohne sichtbaren Item-Namen übersichtlicheres Aussehen im Lager.
- **Visuelle Effekte:** Optionale Partikel- und Sound-Effekte beim Sortiervorgang.
- **Server-übergreifend (CrossLink):** Mit MySQL können Zieltruhen auf anderen Servern des Netzwerks liegen. Items werden automatisch via Transfer-Tabelle weitergeleitet.
- **Import & Export:** Daten lassen sich bequem zwischen `players.yml` und MySQL hin- und herwechseln per Admin-Befehl.
- **Update-Checker:** Admins werden beim Login automatisch über neue Versionen informiert.
- **Multiplayer-Optimiert:** Jeder Spieler verwaltet sein eigenes System kein gegenseitiges Stören.
- **Vollständig Anpassbar:** Alle Nachrichten, Farben und Limits lassen sich in der `config.yml` editieren.
- **Vollständig Anpassbar:** Alle Nachrichten, Farben, Titel und Limits lassen sich in der `config.yml` editieren.
---
## 📖 Einrichtung
### 1. Eingangstruhe (Input)
Hier wirfst du alle unsortierten Items hinein.
Hier wirfst du alle unsortierten Items hinein. Hopper können keine Items direkt einlegen die Sortierung läuft ausschließlich über den eigenen Mechanismus.
Schild an die Truhe platzieren und folgendes schreiben:
```
@@ -52,14 +58,33 @@ ziel
```
Danach mit dem gewünschten Item (z. B. Diamant) auf das Schild **Rechtsklicken** der Item-Typ wird automatisch eingetragen.
> Sind mehrere Zieltruhen für denselben Item-Typ vorhanden, wird die nächste automatisch befüllt, wenn die erste voll ist.
---
### 3. Rest-Truhe (Fallback)
Das Auffangbecken für alle Items ohne Zieltruhe.
Das Auffangbecken für alle Items ohne Zieltruhe. Hopper können keine Items einlegen.
```
[asc]
rest
```
> Es können mehrere Rest-Truhen registriert werden. Sind alle voll, bleibt das Item in der Eingangstruhe.
---
### 4. Mülltruhe (Trash)
Items, die in diese Truhe gelangen, werden automatisch vernichtet.
```
[asc]
trash
```
Nach dem Platzieren des Schildes erscheint ein **Rechtsklick-Hinweis**. Durch Rechtsklick auf das Schild öffnet sich ein Konfiguration-GUI:
- **Ohne Filter-Liste:** Alle Items in der Truhe werden gelöscht.
- **Mit Filter-Liste:** Nur die eingetragenen Item-Typen werden gelöscht, der Rest bleibt erhalten.
- Items können per Rechtsklick zur Liste hinzugefügt oder entfernt werden.
- Der **Auto-Clear-Intervall** lässt sich in der `config.yml` einstellen (z. B. alle 5 Minuten).
- Auch Items, die per **Hopper** eingeworfen werden, werden sofort verarbeitet.
---
@@ -68,6 +93,8 @@ rest
| Aktion | Beschreibung |
|--------|-------------|
| **Shift + Rechtsklick** (leere Hand) auf Schild/Truhe | Wechselt zwischen Privat und Öffentlich |
| **Rechtsklick** auf Ziel-Schild (Item in Hand) | Ändert den zugeordneten Item-Typ |
| **Rechtsklick** auf Mülltruhen-Schild | Öffnet das Filter-Konfiguration-GUI |
| **Privat** | Nur der Besitzer kann die Truhe nutzen. Sortierung nur bei Online-Status. |
| **Öffentlich** | Alle Spieler dürfen Items einwerfen. Sortierung auch offline. Schild zeigt `[Public]`. |
@@ -76,6 +103,21 @@ rest
---
## 🎨 Clean-Modus
Wenn `sign-style.clean-target: true` in der `config.yml` gesetzt ist, werden Schilder in einem aufgeräumten Format ohne sichtbare `[asc]`-Kennung angezeigt:
| Schild-Typ | Zeile 1 | Zeile 2 | Zeile 3 |
|-----------|---------|---------|---------|
| **Input** | Spielername | „Eingang" / „Input" | Öffentlich / Privat |
| **Target** | Item-Name | Spielername | Öffentlich / Privat |
| **Rest** | Spielername | „Rest" | Öffentlich / Privat |
| **Trash** | Spielername | „Müll" / „Trash" | — |
Die Farben für den Clean-Modus werden separat unter `sign-colors-clean` konfiguriert.
---
## 🌐 Serverübergreifende Sortierung (CrossLink)
Wenn MySQL aktiviert und `server_crosslink: true` gesetzt ist, können Zieltruhen auf **anderen Servern desselben Netzwerks** liegen.
@@ -85,6 +127,14 @@ Wenn MySQL aktiviert und `server_crosslink: true` gesetzt ist, können Zieltruhe
2. Server A schreibt den Transfer in die gemeinsame Datenbank (`asc_transfers`).
3. Server B liest die Transfer-Tabelle und befüllt seine lokale Zieltruhe automatisch.
**BungeeCord-Setup:**
1. Dieselbe MySQL-Datenbank auf allen Servern eintragen.
2. Auf jedem Server einen **eindeutigen** `server_name` setzen (z. B. `survival`, `creative`).
3. `mysql.enabled: true` und `server_crosslink: true` setzen.
4. Alle Server neu starten das Schema wird automatisch migriert.
> Wird `server_name` leer gelassen, läuft das Plugin im Legacy-Modus (welt-basierte Erkennung, kein BungeeCord).
**Voraussetzung:** Alle Server müssen dieselbe MySQL-Datenbank nutzen.
---
@@ -99,6 +149,21 @@ Wenn MySQL aktiviert und `server_crosslink: true` gesetzt ist, können Zieltruhe
| `/asc import` | Importiert Daten aus `players.yml` → MySQL | `autosortchest.import` (OP) |
| `/asc export` | Exportiert Daten aus MySQL → `players.yml` | `autosortchest.export` (OP) |
### Berechtigungen Vollständige Übersicht
| Permission | Beschreibung | Standard |
|-----------|-------------|---------|
| `autosortchest.use` | Erlaubt das Erstellen von ASC-Schildern | `true` |
| `autosortchest.reload` | Erlaubt `/asc reload` | OP |
| `autosortchest.import` | Erlaubt `/asc import` | OP |
| `autosortchest.export` | Erlaubt `/asc export` | OP |
| `autosortchest.bypass` | Schilder ohne Shift abbauen, unabhängig vom Besitzer | OP |
| `autosortchest.limit.bypass` | Umgeht alle Truhen-Limits | OP |
| `autosortchest.admin` | Zugriff auf fremde ASC-Truhen | OP |
| `autosortchest.limit.<gruppe>` | Weist dem Spieler die Limits einer Gruppe zu (z. B. `autosortchest.limit.vip`) | `false` |
> Spieler **ohne** jede `autosortchest.limit.*`-Permission können bei aktivierten Limits **keine** Truhen erstellen. Vergib `autosortchest.limit.default` an alle normalen Spieler (z. B. in LuckPerms).
### Import & Export Details
**`/asc import`**
@@ -110,13 +175,17 @@ Exportiert alle Daten aus MySQL zurück in die `players.yml`. Enthält die `play
---
## ⚙️ Konfiguration (config.yml)
```yaml
# Version der Konfigurationsdatei
version: "2.0"
version: "2.3"
# Debug-Modus (nur für Entwicklung)
debug: false
# Sprache: 'de' oder 'en'
language: "de"
# MySQL/MariaDB für CrossLink und zentralen Datenspeicher
mysql:
enabled: false
@@ -129,8 +198,10 @@ mysql:
# Serverübergreifende Sortierung (benötigt MySQL)
server_crosslink: true
# Sprache: 'de' oder 'en'
language: "de"
# Eindeutiger Servername im BungeeCord-Netzwerk
# Leer lassen = Legacy-Modus (welt-basiert, kein BungeeCord)
# Beispiele: lobby | survival | creative
server_name: ""
# Welten, in denen das Plugin deaktiviert ist
world_blacklist:
@@ -138,24 +209,69 @@ world_blacklist:
- "world_the_end"
# Sortier-Intervall in Ticks (1 Tick = 0,05s)
sort_interval_ticks: 5
# Empfohlen: 10 (= 0,5s)
sort_interval_ticks: 10
# Maximale Anzahl Zieltruhen pro Spielergruppe
# Rest-Truhen Nachsortierung (0 = deaktiviert)
rest_resort_interval_ticks: 400 # 400 Ticks = 20 Sekunden
# Mülltruhe
trash:
# 0 = Nur beim Schließen leeren | 300 = alle 5 Min | 3600 = stündlich
auto_clear_interval_seconds: 0
# Visuelle Effekte
effects:
enabled: false # Partikel-Effekte anzeigen?
sound: false # Ton beim Ankommen von Items?
type: "DUST" # Partikel-Typ ('DUST' = bunter Regenbogen-Effekt)
# Schild-Stil
sign-style:
clean-target: false # true = sauberer Modus (kein Item-Name auf dem Schild)
# Maximale Anzahl Truhen pro Spielergruppe
chest_limits:
default: 5
vip: 100
enabled: true
default:
input: 1
rest: 1
target: 50
target_per_item: 1 # Wie viele Zieltruhen pro Item-Typ erlaubt sind
vip:
input: 2
rest: 2
target: 100
target_per_item: 3
# Truhen-Fenstertitel (Platzhalter: %item%)
chest-titles:
input:
de: "&6Eingangstruhe"
en: "&6Input Chest"
target:
de: "&6%item%"
en: "&6%item%"
rest:
de: "&6Rest-Truhe"
en: "&6Rest Chest"
trash:
de: "&4Mülltruhe"
en: "&4Trash Chest"
# Schildfarben (Minecraft-Farbcodes)
sign-colors:
input:
line1: "&6" # [asc]
line2: "&0" # input
line4: "&1" # Spielername
line1: "&6"
line2: "&0"
line4: "&1"
target:
line1: "&6" # [asc]
line2: "&0" # ziel
line3: "&f" # Item-Typ
line4: "&1" # Spielername
line1: "&6"
line2: "&0"
line3: "&f"
line4: "&1"
full:
line1: "&c"
line2: "&4"
@@ -166,8 +282,34 @@ sign-colors:
line2: "&0"
line3: "&f"
line4: "&1"
trash:
line1: "&6"
line2: "&0"
line4: "&1"
# Nachrichten
# Schildfarben im Clean-Modus
sign-colors-clean:
input:
line1: "&1"
line2: "&0"
line3: "&a"
target:
line1: "&f"
line2: "&1"
line3: "&a"
full:
line1: "&e"
line2: "&1"
line3: "&a"
rest:
line1: "&1"
line2: "&0"
line3: "&a"
trash:
line1: "&1"
line2: "&0"
# Nachrichten (Platzhalter: %player%, %item%, %x%, %y%, %z%, %mode%, %max%)
messages:
no-chest-near-sign: "&cKeine Truhe in der Nähe des Schildes!"
no-item-in-hand: "&cDu musst ein Item in der Hand halten!"
@@ -175,14 +317,28 @@ messages:
input-chest-set: "&aEingangstruhe erfolgreich gesetzt!"
target-chest-set: "&aZieltruhe erfolgreich für %item% eingerichtet!"
rest-chest-set: "&aRest-Truhe (Fallback) erfolgreich gesetzt!"
trash-chest-set: "&aMülltruhe erfolgreich eingerichtet!"
trash-chest-hint: "&7Rechtsklicke das Schild um Items zu konfigurieren."
target-chest-missing: "&cZieltruhe für %item% fehlt!"
target-chest-full: "&cZieltruhe für %item% ist voll! Koordinaten: (%x%, %y%, %z%)"
sign-break-denied: "&cDu musst Shift gedrückt halten, um dieses Schild oder die Truhe abzubauen!"
no-permission: "&cDu hast keine Berechtigung für diesen Befehl!"
world-blacklisted: "&cIn dieser Welt kannst du keine AutoSortChest erstellen!"
reload-success: "&aKonfiguration erfolgreich neu geladen!"
mode-changed: "&aModus gewechselt: &e%mode%"
mode-public: "&aÖffentlich"
mode-private: "&cPrivat"
limit-input-reached: "&cDu hast das Limit deiner Eingangstruhen erreicht! &7(%max%)"
limit-rest-reached: "&cDu hast das Limit deiner Rest-Truhen erreicht! &7(%max%)"
limit-target-reached: "&cDu hast das Limit deiner Zieltruhen erreicht! &7(%max%)"
limit-target-per-item: "&cDu hast das Limit für %item%-Truhen erreicht! &7(%max%)"
limit-no-permission: "&cDu hast keine Berechtigung um Truhen zu erstellen!"
trash-cleared: "&a✔ Mülltruhe wurde geleert!"
trash-item-added: "&a✔ &e%item% &azur Müll-Liste hinzugefügt."
trash-item-already: "&eDiseses Item ist bereits in der Müll-Liste."
trash-item-removed: "&c✖ &e%item% &caus der Müll-Liste entfernt."
trash-info-empty: "&4Mülltruhe &8(Deaktiviert) &7 Rechtsklick Schild zum Konfigurieren"
trash-info-filter: "&4Müll: &f%items% &8| Schild-Rechtsklick: Konfigurieren"
```
---
@@ -195,8 +351,10 @@ Bei aktiviertem MySQL erstellt das Plugin folgende Tabellen automatisch:
|---------|--------|
| `asc_players` | Spieler-UUIDs und Namen |
| `asc_input_chests` | Registrierte Eingangstruhen |
| `asc_target_chests` | Zieltruhen mit Item-Zuordnung |
| `asc_target_chests` | Zieltruhen mit Item-Zuordnung und Slot-Index |
| `asc_rest_chests` | Rest-/Fallback-Truhen |
| `asc_trash_chests` | Mülltruhen mit Serverzuordnung |
| `asc_trash_items` | Filter-Listen der Mülltruhen |
| `asc_transfers` | Ausstehende CrossLink-Transfers zwischen Servern |
---
@@ -206,7 +364,7 @@ Bei aktiviertem MySQL erstellt das Plugin folgende Tabellen automatisch:
- **Kompatibilität:** Paper, Spigot, Purpur (1.18.x 1.21.x)
- **Java:** 17+
- **Datenbank:** YAML (Standard) oder MySQL/MariaDB (optional)
- **Performance:** Ressourcenschonende Sortier-Algorithmen mit konfigurierbarem Intervall
- **Performance:** Asynchrones Speichern der `players.yml`, konfigurierbarer Sortier-Intervall, TTL-Caching für öffentliche Truhen
---
@@ -216,4 +374,6 @@ Bei aktiviertem MySQL erstellt das Plugin folgende Tabellen automatisch:
---
*Viper Plugins © 2026 Effizienz für deinen Server*
**Copyright © 2026 - M_Viper - Alle Rechte vorbehalten**
Die unbefugte Vervielfältigung, Verbreitung oder Weitergabe dieses Plugins ist strafbar und wird rechtlich verfolgt.

View File

@@ -3,7 +3,7 @@
<modelVersion>4.0.0</modelVersion>
<groupId>com.viper</groupId>
<artifactId>AutoSortChest</artifactId>
<version>2.2</version>
<version>2.5</version>
<name>AutoSortChest</name>
<repositories>

File diff suppressed because it is too large Load Diff

View File

@@ -36,6 +36,39 @@ public class MySQLManager {
}
}
/**
* Migriert den PRIMARY KEY der asc_rest_chests von (uuid) auf (uuid, slot) falls nötig.
* Ermöglicht mehrere Rest-Truhen pro Spieler.
*/
private void migrateRestChestPrimaryKey(Statement st) {
try {
// Slot-Spalte zuerst sicherstellen
if (!columnExists("asc_rest_chests", "slot")) {
st.execute("ALTER TABLE asc_rest_chests ADD COLUMN slot INT NOT NULL DEFAULT 0;");
}
// Prüfen ob slot bereits im PRIMARY KEY ist
try (PreparedStatement ps = connection.prepareStatement(
"SELECT COUNT(*) FROM information_schema.KEY_COLUMN_USAGE " +
"WHERE TABLE_SCHEMA = DATABASE() AND TABLE_NAME = 'asc_rest_chests' " +
"AND CONSTRAINT_NAME = 'PRIMARY' AND COLUMN_NAME = 'slot';")) {
ResultSet rs = ps.executeQuery();
if (rs.next() && rs.getInt(1) > 0) {
rs.close();
return; // Bereits migriert
}
rs.close();
}
// Alten PK droppen und neuen mit slot anlegen
st.execute("ALTER TABLE asc_rest_chests DROP PRIMARY KEY, ADD PRIMARY KEY(uuid, slot);");
} catch (SQLException e) {
if (!e.getMessage().toLowerCase().contains("primary")) {
e.printStackTrace();
}
}
}
/**
* Migriert den PRIMARY KEY von (uuid, item) auf (uuid, item, slot) falls nötig.
* Nutzt DATABASE() um nur die aktuelle DB zu prüfen (kein Cross-DB-Problem).
@@ -78,6 +111,26 @@ public class MySQLManager {
}
}
/**
* Stellt sicher, dass die Verbindung offen ist.
* Reconnect-Logik für den Fall, dass die MySQL-Verbindung abgelaufen ist
* (z.B. nach wait_timeout, Netzwerk-Unterbrechung).
* Wird vor jeder DB-Operation aufgerufen.
*/
private void ensureConnected() {
try {
if (connection == null || connection.isClosed() || !connection.isValid(2)) {
connection = DriverManager.getConnection(
"jdbc:mysql://" + host + ":" + port + "/" + database
+ "?useSSL=false&autoReconnect=true&characterEncoding=UTF-8&serverTimezone=UTC",
user, password
);
}
} catch (SQLException e) {
e.printStackTrace();
}
}
// ═══════════════════════════════════════════════════════════════════
// BungeeCord-Erweiterung: Sanfte Schema-Migration
// Fügt eine Spalte hinzu, falls sie noch nicht existiert.
@@ -88,7 +141,7 @@ public class MySQLManager {
*/
private void tryAlterColumn(Statement st, String table, String column, String definition) {
try {
ResultSet rs = st.getConnection().getMetaData().getColumns(null, null, table, column);
ResultSet rs = st.getConnection().getMetaData().getColumns(connection.getCatalog(), null, table, column);
if (!rs.next()) {
st.execute("ALTER TABLE " + table + " ADD COLUMN " + column + " " + definition + ";");
}
@@ -105,7 +158,7 @@ public class MySQLManager {
*/
private boolean columnExists(String table, String column) {
try {
ResultSet rs = connection.getMetaData().getColumns(null, null, table, column);
ResultSet rs = connection.getMetaData().getColumns(connection.getCatalog(), null, table, column);
boolean exists = rs.next();
rs.close();
return exists;
@@ -146,6 +199,7 @@ public class MySQLManager {
* asc_transfers (CrossLink Transfers)
*/
public void setupTables() {
ensureConnected();
try (Statement st = connection.createStatement()) {
// ── Basis-Tabellen anlegen (falls nicht vorhanden) ────────────────────
@@ -168,9 +222,10 @@ public class MySQLManager {
");");
st.execute("CREATE TABLE IF NOT EXISTS asc_rest_chests (" +
"uuid VARCHAR(36), world VARCHAR(32)," +
"uuid VARCHAR(36), slot INT NOT NULL DEFAULT 0," +
"world VARCHAR(32)," +
"x INT, y INT, z INT, `public` BOOLEAN DEFAULT FALSE," +
"PRIMARY KEY(uuid)" +
"PRIMARY KEY(uuid, slot)" +
");");
// ── asc_transfers: immer beim Start sicherstellen ─────────────────────
@@ -195,6 +250,17 @@ public class MySQLManager {
// Jede Migration ist idempotent mehrfaches Ausführen schadet nicht.
// ══════════════════════════════════════════════════════════════════════
// ── Mülltruchen-Tabellen ──────────────────────────────────────────────
st.execute("CREATE TABLE IF NOT EXISTS asc_trash_chests (" +
"uuid VARCHAR(36) PRIMARY KEY, world VARCHAR(32)," +
"x INT, y INT, z INT, server VARCHAR(64) DEFAULT ''" +
");");
st.execute("CREATE TABLE IF NOT EXISTS asc_trash_items (" +
"uuid VARCHAR(36), item VARCHAR(64)," +
"PRIMARY KEY(uuid, item)" +
");");
// v1 → v2 (BungeeCord): server-Spalten
tryAlterColumn(st, "asc_input_chests", "server", "VARCHAR(64) DEFAULT ''");
tryAlterColumn(st, "asc_target_chests", "server", "VARCHAR(64) DEFAULT ''");
@@ -207,6 +273,9 @@ public class MySQLManager {
// v2 → v3 (Multi-Target): slot-Spalte + PRIMARY KEY Migration
migrateTargetChestPrimaryKey(st);
// v2 → v3 (Multi-Rest): slot-Spalte + PRIMARY KEY Migration fuer Rest-Truhen
migrateRestChestPrimaryKey(st);
} catch (SQLException e) {
e.printStackTrace();
}
@@ -228,6 +297,7 @@ public class MySQLManager {
*/
public void heartbeat(String serverName) {
if (serverName == null || serverName.isEmpty()) return;
ensureConnected();
try (PreparedStatement ps = connection.prepareStatement(
"REPLACE INTO asc_servers (server_name, last_seen) VALUES (?, NOW());")) {
ps.setString(1, serverName);
@@ -243,6 +313,7 @@ public class MySQLManager {
*/
public void addTransfer(String uuid, String item, int amount,
String targetWorld, String targetServer, String sourceServer) {
ensureConnected();
try (PreparedStatement ps = connection.prepareStatement(
"INSERT INTO asc_transfers (uuid, item, amount, target_world, target_server, source_server) " +
"VALUES (?, ?, ?, ?, ?, ?);")) {
@@ -311,6 +382,7 @@ public class MySQLManager {
}
public void deleteTransfer(long id) {
ensureConnected();
try (PreparedStatement ps = connection.prepareStatement(
"DELETE FROM asc_transfers WHERE id=?;")) {
ps.setLong(1, id);
@@ -321,6 +393,7 @@ public class MySQLManager {
}
public void updateTransferAmount(long id, int newAmount) {
ensureConnected();
try (PreparedStatement ps = connection.prepareStatement(
"UPDATE asc_transfers SET amount=? WHERE id=?;")) {
ps.setInt(1, newAmount);
@@ -334,6 +407,7 @@ public class MySQLManager {
// --- Spieler ---
public void savePlayer(String uuid, String name) {
ensureConnected();
try (PreparedStatement ps = connection.prepareStatement(
"REPLACE INTO asc_players (uuid, name) VALUES (?, ?);")) {
ps.setString(1, uuid);
@@ -345,6 +419,7 @@ public class MySQLManager {
}
public List<Map<String, Object>> getAllPlayers() {
ensureConnected();
List<Map<String, Object>> list = new ArrayList<>();
try (Statement st = connection.createStatement();
ResultSet rs = st.executeQuery("SELECT uuid, name FROM asc_players;")) {
@@ -373,6 +448,7 @@ public class MySQLManager {
/** BungeeCord-Überladung mit serverName. */
public void addInputChest(String uuid, String chestId, String world,
int x, int y, int z, boolean isPublic, String serverName) {
ensureConnected();
try (PreparedStatement ps = connection.prepareStatement(
"REPLACE INTO asc_input_chests (uuid, chest_id, world, x, y, z, `public`, server) " +
"VALUES (?, ?, ?, ?, ?, ?, ?, ?);")) {
@@ -391,6 +467,7 @@ public class MySQLManager {
}
public void removeInputChest(String uuid, String chestId) {
ensureConnected();
try (PreparedStatement ps = connection.prepareStatement(
"DELETE FROM asc_input_chests WHERE uuid=? AND chest_id=?;")) {
ps.setString(1, uuid);
@@ -402,6 +479,7 @@ public class MySQLManager {
}
public List<Map<String, Object>> getInputChests(String uuid) {
ensureConnected();
List<Map<String, Object>> list = new ArrayList<>();
try (PreparedStatement ps = connection.prepareStatement(
"SELECT * FROM asc_input_chests WHERE uuid=?;")) {
@@ -444,6 +522,7 @@ public class MySQLManager {
/** Vollständige Überladung mit slot für Multi-Target-Support. */
public void setTargetChest(String uuid, String item, int slot, String world,
int x, int y, int z, boolean isPublic, String serverName) {
ensureConnected();
try (PreparedStatement ps = connection.prepareStatement(
"REPLACE INTO asc_target_chests (uuid, item, slot, world, x, y, z, `public`, server) " +
"VALUES (?, ?, ?, ?, ?, ?, ?, ?, ?);")) {
@@ -521,6 +600,7 @@ public class MySQLManager {
/** Gibt ALLE Zieltruhen für ein bestimmtes Item zurück, sortiert nach slot. */
public List<Map<String, Object>> getTargetChestsForItem(String uuid, String item) {
ensureConnected();
List<Map<String, Object>> list = new ArrayList<>();
try (PreparedStatement ps = connection.prepareStatement(
"SELECT * FROM asc_target_chests WHERE uuid=? AND item=? ORDER BY slot ASC;")) {
@@ -547,6 +627,7 @@ public class MySQLManager {
}
public void removeTargetChest(String uuid, String item) {
ensureConnected();
try (PreparedStatement ps = connection.prepareStatement(
"DELETE FROM asc_target_chests WHERE uuid=? AND item=?;")) {
ps.setString(1, uuid);
@@ -559,6 +640,7 @@ public class MySQLManager {
/** Gibt alle Zieltruhen eines Spielers zurück, sortiert nach item + slot. */
public List<Map<String, Object>> getTargetChests(String uuid) {
ensureConnected();
List<Map<String, Object>> list = new ArrayList<>();
try (PreparedStatement ps = connection.prepareStatement(
"SELECT * FROM asc_target_chests WHERE uuid=? ORDER BY item ASC, slot ASC;")) {
@@ -593,32 +675,96 @@ public class MySQLManager {
setRestChest(uuid, world, x, y, z, isPublic, "");
}
/** BungeeCord-Überladung mit serverName. */
/** BungeeCord-Überladung mit serverName ermittelt automatisch den nächsten freien Slot. */
public void setRestChest(String uuid, String world, int x, int y, int z,
boolean isPublic, String serverName) {
// Prüfen ob diese exakte Location bereits als Rest-Truhe registriert ist (Update)
int slot = getRestSlotForLocation(uuid, world, x, y, z);
if (slot < 0) {
// Neue Truhe: nächsten freien Slot ermitteln
slot = getNextRestSlot(uuid);
}
setRestChest(uuid, slot, world, x, y, z, isPublic, serverName);
}
/** Vollständige Überladung mit explizitem slot. */
public void setRestChest(String uuid, int slot, String world, int x, int y, int z,
boolean isPublic, String serverName) {
ensureConnected();
try (PreparedStatement ps = connection.prepareStatement(
"REPLACE INTO asc_rest_chests (uuid, world, x, y, z, `public`, server) " +
"VALUES (?, ?, ?, ?, ?, ?, ?);")) {
"REPLACE INTO asc_rest_chests (uuid, slot, world, x, y, z, `public`, server) " +
"VALUES (?, ?, ?, ?, ?, ?, ?, ?);")) {
ps.setString(1, uuid);
ps.setString(2, world);
ps.setInt(3, x);
ps.setInt(4, y);
ps.setInt(5, z);
ps.setBoolean(6, isPublic);
ps.setString(7, serverName != null ? serverName : "");
ps.setInt(2, slot);
ps.setString(3, world);
ps.setInt(4, x);
ps.setInt(5, y);
ps.setInt(6, z);
ps.setBoolean(7, isPublic);
ps.setString(8, serverName != null ? serverName : "");
ps.executeUpdate();
} catch (SQLException e) {
e.printStackTrace();
}
}
public Map<String, Object> getRestChest(String uuid) {
/** Gibt den nächsten freien Slot für Rest-Truhen zurück. */
public int getNextRestSlot(String uuid) {
try (PreparedStatement ps = connection.prepareStatement(
"SELECT * FROM asc_rest_chests WHERE uuid=?;")) {
"SELECT COALESCE(MAX(slot)+1, 0) AS next_slot FROM asc_rest_chests WHERE uuid=?;")) {
ps.setString(1, uuid);
ResultSet rs = ps.executeQuery();
if (rs.next()) {
if (rs.next()) return rs.getInt("next_slot");
} catch (SQLException e) {
e.printStackTrace();
}
return 0;
}
/**
* Gibt den Slot zurück, den diese Location bereits belegt, oder -1 wenn nicht gefunden.
*/
public int getRestSlotForLocation(String uuid, String world, int x, int y, int z) {
try (PreparedStatement ps = connection.prepareStatement(
"SELECT slot FROM asc_rest_chests WHERE uuid=? AND world=? AND x=? AND y=? AND z=?;")) {
ps.setString(1, uuid);
ps.setString(2, world);
ps.setInt(3, x);
ps.setInt(4, y);
ps.setInt(5, z);
ResultSet rs = ps.executeQuery();
if (rs.next()) return rs.getInt("slot");
} catch (SQLException e) {
e.printStackTrace();
}
return -1;
}
/** Zählt wie viele Rest-Truhen ein Spieler hat. */
public int countRestChests(String uuid) {
ensureConnected();
try (PreparedStatement ps = connection.prepareStatement(
"SELECT COUNT(*) FROM asc_rest_chests WHERE uuid=?;")) {
ps.setString(1, uuid);
ResultSet rs = ps.executeQuery();
if (rs.next()) return rs.getInt(1);
} catch (SQLException e) {
e.printStackTrace();
}
return 0;
}
/** Gibt ALLE Rest-Truhen eines Spielers zurück, sortiert nach slot. */
public List<Map<String, Object>> getRestChests(String uuid) {
ensureConnected();
List<Map<String, Object>> list = new ArrayList<>();
try (PreparedStatement ps = connection.prepareStatement(
"SELECT * FROM asc_rest_chests WHERE uuid=? ORDER BY slot ASC;")) {
ps.setString(1, uuid);
ResultSet rs = ps.executeQuery();
while (rs.next()) {
Map<String, Object> map = new HashMap<>();
map.put("slot", rs.getInt("slot"));
map.put("world", rs.getString("world"));
map.put("x", rs.getInt("x"));
map.put("y", rs.getInt("y"));
@@ -626,14 +772,73 @@ public class MySQLManager {
map.put("public", rs.getBoolean("public"));
try { map.put("server", rs.getString("server")); }
catch (SQLException ignored) { map.put("server", ""); }
return map;
list.add(map);
}
} catch (SQLException e) {
e.printStackTrace();
}
return null;
return list;
}
/** Gibt die erste Rest-Truhe (slot=0) zurück Legacy-Kompatibilität. */
public Map<String, Object> getRestChest(String uuid) {
List<Map<String, Object>> all = getRestChests(uuid);
return all.isEmpty() ? null : all.get(0);
}
/** Löscht eine spezifische Rest-Truhe anhand ihrer Location. */
public void removeRestChestByLocation(String uuid, String world, int x, int y, int z) {
ensureConnected();
try (PreparedStatement ps = connection.prepareStatement(
"DELETE FROM asc_rest_chests WHERE uuid=? AND world=? AND x=? AND y=? AND z=?;")) {
ps.setString(1, uuid);
ps.setString(2, world);
ps.setInt(3, x);
ps.setInt(4, y);
ps.setInt(5, z);
ps.executeUpdate();
} catch (SQLException e) {
e.printStackTrace();
}
// Slots nach dem gelöschten nach unten schieben um Lücken zu vermeiden
compactRestSlots(uuid);
}
/** Löscht eine spezifische Rest-Truhe anhand des Slots. */
public void removeRestChestSlot(String uuid, int slot) {
try (PreparedStatement ps = connection.prepareStatement(
"DELETE FROM asc_rest_chests WHERE uuid=? AND slot=?;")) {
ps.setString(1, uuid);
ps.setInt(2, slot);
ps.executeUpdate();
} catch (SQLException e) {
e.printStackTrace();
}
compactRestSlots(uuid);
}
/** Schiebt Rest-Slots nach dem gelöschten nach unten (keine Lücken). */
private void compactRestSlots(String uuid) {
try {
List<Map<String, Object>> remaining = getRestChests(uuid);
for (int i = 0; i < remaining.size(); i++) {
int currentSlot = (int) remaining.get(i).get("slot");
if (currentSlot != i) {
try (PreparedStatement ps = connection.prepareStatement(
"UPDATE asc_rest_chests SET slot=? WHERE uuid=? AND slot=?;")) {
ps.setInt(1, i);
ps.setString(2, uuid);
ps.setInt(3, currentSlot);
ps.executeUpdate();
}
}
}
} catch (SQLException e) {
e.printStackTrace();
}
}
/** Löscht ALLE Rest-Truhen eines Spielers. */
public void removeRestChest(String uuid) {
try (PreparedStatement ps = connection.prepareStatement(
"DELETE FROM asc_rest_chests WHERE uuid=?;")) {
@@ -694,11 +899,12 @@ public class MySQLManager {
public Map<String, Object> getAnyRestChest() {
try (PreparedStatement ps = connection.prepareStatement(
"SELECT * FROM asc_rest_chests WHERE public=1 LIMIT 1;")) {
"SELECT * FROM asc_rest_chests WHERE `public`=1 ORDER BY uuid, slot LIMIT 1;")) {
ResultSet rs = ps.executeQuery();
if (rs.next()) {
Map<String, Object> map = new HashMap<>();
map.put("uuid", rs.getString("uuid"));
map.put("slot", rs.getInt("slot"));
map.put("world", rs.getString("world"));
map.put("x", rs.getInt("x"));
map.put("y", rs.getInt("y"));
@@ -713,4 +919,198 @@ public class MySQLManager {
}
return null;
}
// ══════════════════════════════════════════════════════════════════════════
// MÜLLTRUCHEN (asc_trash_chests + asc_trash_items)
// ══════════════════════════════════════════════════════════════════════════
/** Legt eine Mülltruche an oder aktualisiert sie. */
public void setTrashChest(String uuid, String world, int x, int y, int z, String server) {
try (PreparedStatement ps = connection.prepareStatement(
"INSERT INTO asc_trash_chests (uuid, world, x, y, z, server) VALUES (?,?,?,?,?,?) " +
"ON DUPLICATE KEY UPDATE world=VALUES(world), x=VALUES(x), y=VALUES(y), z=VALUES(z), server=VALUES(server)")) {
ps.setString(1, uuid);
ps.setString(2, world);
ps.setInt(3, x);
ps.setInt(4, y);
ps.setInt(5, z);
ps.setString(6, server == null ? "" : server);
ps.executeUpdate();
} catch (SQLException e) { e.printStackTrace(); }
}
/** Gibt die Mülltruche eines Spielers zurück (nur die des eigenen Servers). */
public Map<String, Object> getTrashChest(String uuid, String serverName) {
try (PreparedStatement ps = connection.prepareStatement(
"SELECT * FROM asc_trash_chests WHERE uuid=? AND (server=? OR server='') LIMIT 1")) {
ps.setString(1, uuid);
ps.setString(2, serverName == null ? "" : serverName);
ResultSet rs = ps.executeQuery();
if (rs.next()) {
Map<String, Object> map = new HashMap<>();
map.put("world", rs.getString("world"));
map.put("x", rs.getInt("x"));
map.put("y", rs.getInt("y"));
map.put("z", rs.getInt("z"));
map.put("server", rs.getString("server"));
return map;
}
} catch (SQLException e) { e.printStackTrace(); }
return null;
}
/** Gibt ALLE Mülltruchen zurück (für sign-update oder cross-server). */
public List<Map<String, Object>> getAllTrashChests() {
List<Map<String, Object>> list = new ArrayList<>();
try (PreparedStatement ps = connection.prepareStatement("SELECT * FROM asc_trash_chests")) {
ResultSet rs = ps.executeQuery();
while (rs.next()) {
Map<String, Object> map = new HashMap<>();
map.put("uuid", rs.getString("uuid"));
map.put("world", rs.getString("world"));
map.put("x", rs.getInt("x"));
map.put("y", rs.getInt("y"));
map.put("z", rs.getInt("z"));
map.put("server", rs.getString("server"));
list.add(map);
}
} catch (SQLException e) { e.printStackTrace(); }
return list;
}
/** Entfernt die Mülltruche eines Spielers. */
public void removeTrashChest(String uuid) {
try (PreparedStatement ps = connection.prepareStatement(
"DELETE FROM asc_trash_chests WHERE uuid=?")) {
ps.setString(1, uuid);
ps.executeUpdate();
} catch (SQLException e) { e.printStackTrace(); }
}
/** Speichert die komplette Filter-Liste (ersetzt alte Einträge). */
public void setTrashItems(String uuid, List<String> items) {
try (PreparedStatement del = connection.prepareStatement(
"DELETE FROM asc_trash_items WHERE uuid=?")) {
del.setString(1, uuid);
del.executeUpdate();
} catch (SQLException e) { e.printStackTrace(); }
if (items == null || items.isEmpty()) return;
try (PreparedStatement ps = connection.prepareStatement(
"INSERT IGNORE INTO asc_trash_items (uuid, item) VALUES (?,?)")) {
for (String item : items) {
ps.setString(1, uuid);
ps.setString(2, item);
ps.addBatch();
}
ps.executeBatch();
} catch (SQLException e) { e.printStackTrace(); }
}
/** Lädt die Filter-Liste eines Spielers. */
public List<String> getTrashItems(String uuid) {
List<String> list = new ArrayList<>();
try (PreparedStatement ps = connection.prepareStatement(
"SELECT item FROM asc_trash_items WHERE uuid=?")) {
ps.setString(1, uuid);
ResultSet rs = ps.executeQuery();
while (rs.next()) list.add(rs.getString("item"));
} catch (SQLException e) { e.printStackTrace(); }
return list;
}
/** Fügt ein einzelnes Item zur Filter-Liste hinzu. */
public void addTrashItem(String uuid, String item) {
try (PreparedStatement ps = connection.prepareStatement(
"INSERT IGNORE INTO asc_trash_items (uuid, item) VALUES (?,?)")) {
ps.setString(1, uuid);
ps.setString(2, item);
ps.executeUpdate();
} catch (SQLException e) { e.printStackTrace(); }
}
/** Entfernt ein einzelnes Item aus der Filter-Liste. */
public void removeTrashItem(String uuid, String item) {
try (PreparedStatement ps = connection.prepareStatement(
"DELETE FROM asc_trash_items WHERE uuid=? AND item=?")) {
ps.setString(1, uuid);
ps.setString(2, item);
ps.executeUpdate();
} catch (SQLException e) { e.printStackTrace(); }
}
/** Entfernt alle Filter-Items eines Spielers. */
public void removeAllTrashItems(String uuid) {
try (PreparedStatement ps = connection.prepareStatement(
"DELETE FROM asc_trash_items WHERE uuid=?")) {
ps.setString(1, uuid);
ps.executeUpdate();
} catch (SQLException e) { e.printStackTrace(); }
}
// ═══════════════════════════════════════════════════════════════════
// FIX: Einzelne UNION-Abfrage statt 3 separater Queries für isChestPublic()
// Reduziert Main-Thread-Blockierung bei MySQL um ~66%.
// ═══════════════════════════════════════════════════════════════════
/**
* Prüft ob eine Truhen-Location in IRGENDEINER Tabelle als public markiert ist.
* Kombiniert Input-, Target- und Rest-Tabelle in einer einzigen UNION-Abfrage.
* @return true wenn mindestens eine Zeile `public=TRUE` enthält.
*/
public boolean isLocationPublic(String world, int x, int y, int z) {
ensureConnected();
// MySQL erfordert Klammern um einzelne SELECT-Statements wenn LIMIT verwendet wird
String sql =
"(SELECT 1 FROM asc_input_chests WHERE world=? AND x=? AND y=? AND z=? AND `public`=TRUE LIMIT 1) " +
"UNION ALL " +
"(SELECT 1 FROM asc_target_chests WHERE world=? AND x=? AND y=? AND z=? AND `public`=TRUE LIMIT 1) " +
"UNION ALL " +
"(SELECT 1 FROM asc_rest_chests WHERE world=? AND x=? AND y=? AND z=? AND `public`=TRUE LIMIT 1)";
try (PreparedStatement ps = connection.prepareStatement(sql)) {
for (int i = 0; i < 3; i++) {
int base = i * 4;
ps.setString(base + 1, world);
ps.setInt (base + 2, x);
ps.setInt (base + 3, y);
ps.setInt (base + 4, z);
}
ResultSet rs = ps.executeQuery();
boolean result = rs.next();
rs.close();
return result;
} catch (SQLException e) {
e.printStackTrace();
return false;
}
}
// ═══════════════════════════════════════════════════════════════════
// FIX: MySQL-Implementierung für findItemForChestLocation()
// Wurde bisher übersprungen Clean-Sign-Modus + MySQL war dadurch broken.
// ═══════════════════════════════════════════════════════════════════
/**
* Findet den Item-Typ (z.B. "IRON_ORE") der einer Truhen-Location als Zieltruhe
* zugewiesen ist. Wird von findItemForChestLocation() im Clean-Sign-Modus benötigt.
* @return Material-Name oder null wenn nicht gefunden.
*/
public String getItemForLocation(String uuid, String world, int x, int y, int z) {
ensureConnected();
try (PreparedStatement ps = connection.prepareStatement(
"SELECT item FROM asc_target_chests WHERE uuid=? AND world=? AND x=? AND y=? AND z=? LIMIT 1;")) {
ps.setString(1, uuid);
ps.setString(2, world);
ps.setInt(3, x);
ps.setInt(4, y);
ps.setInt(5, z);
ResultSet rs = ps.executeQuery();
if (rs.next()) {
String item = rs.getString("item");
rs.close();
return item;
}
rs.close();
} catch (SQLException e) {
e.printStackTrace();
}
return null;
}
}

View File

@@ -0,0 +1,512 @@
package com.viper.autosortchest;
import org.bukkit.Bukkit;
import org.bukkit.ChatColor;
import org.bukkit.Location;
import org.bukkit.Material;
import org.bukkit.World;
import org.bukkit.block.Chest;
import org.bukkit.configuration.file.FileConfiguration;
import org.bukkit.entity.Player;
import org.bukkit.event.EventHandler;
import org.bukkit.event.Listener;
import org.bukkit.event.inventory.InventoryClickEvent;
import org.bukkit.event.inventory.InventoryCloseEvent;
import org.bukkit.inventory.Inventory;
import org.bukkit.inventory.ItemStack;
import org.bukkit.inventory.meta.ItemMeta;
import org.bukkit.inventory.meta.SkullMeta;
import org.bukkit.profile.PlayerProfile;
import org.bukkit.profile.PlayerTextures;
import org.bukkit.scheduler.BukkitRunnable;
import org.bukkit.scheduler.BukkitTask;
import java.net.URL;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import java.util.UUID;
/**
* Verwaltet Mülltruhen für das AutoSortChest-Plugin.
*
* Speicherung:
* MySQL (wenn aktiv):
* asc_trash_chests : uuid, world, x, y, z, server
* asc_trash_items : uuid, item
* YAML (Fallback):
* players.<uuid>.trash-chest.world / x / y / z
* players.<uuid>.trash-items (StringList)
*/
public class TrashChestManager {
private static final String SKULL_TEXTURE =
"http://textures.minecraft.net/texture/942e7fb9b8eae22d55e32b8222f38eca7b2c41948b15d769b716d80f9d113611";
/** Gibt den sprachabhängigen GUI-Titel zurück (Farbe aus chest-titles.trash). */
private String getGuiTitle() {
boolean isEn = "en".equalsIgnoreCase(plugin.getConfig().getString("language", "de"));
String colorPrefix = getChestTitleColor();
String label = isEn ? "Configure Trash Chest" : "Mülltruhe konfigurieren";
return colorPrefix + ChatColor.BOLD + label;
}
private final Main plugin;
/** UUID → Truhen-Location (In-Memory-Cache für diesen Server) */
private final Map<UUID, Location> trashChestLocations = new HashMap<>();
/** UUID → Filter-Liste */
private final Map<UUID, List<String>> trashFilterLists = new HashMap<>();
/** Location-Key → Besitzer-UUID */
private final Map<String, UUID> locationToOwner = new HashMap<>();
/** Spieler-UUID → Truhen-Besitzer-UUID (offene GUIs) */
private final Map<UUID, UUID> openGuiOwners = new HashMap<>();
private BukkitTask autoTrashTask = null;
public TrashChestManager(Main plugin) {
this.plugin = plugin;
loadAllTrashChests();
plugin.getServer().getPluginManager().registerEvents(new GuiListener(), plugin);
}
// ══════════════════════════════════════════════════════════════════════════
// LADEN
// ══════════════════════════════════════════════════════════════════════════
private void loadAllTrashChests() {
if (plugin.isMysqlEnabled() && plugin.getMysqlManager() != null) {
loadMySQL();
} else {
loadYaml();
}
}
private void loadMySQL() {
MySQLManager db = plugin.getMysqlManager();
String myServer = plugin.getServerName();
for (Map<String, Object> row : db.getAllTrashChests()) {
String srv = (String) row.getOrDefault("server", "");
if (!srv.isEmpty() && !srv.equals(myServer)) continue;
try {
UUID uuid = UUID.fromString((String) row.get("uuid"));
World world = Bukkit.getWorld((String) row.get("world"));
if (world == null) continue;
Location loc = new Location(world, (int) row.get("x"), (int) row.get("y"), (int) row.get("z"));
trashChestLocations.put(uuid, loc);
locationToOwner.put(locKey(loc), uuid);
trashFilterLists.put(uuid, new ArrayList<>(db.getTrashItems(uuid.toString())));
} catch (IllegalArgumentException ignored) {}
}
}
private void loadYaml() {
FileConfiguration data = plugin.getPlayerData();
if (data == null || data.getConfigurationSection("players") == null) return;
for (String uuidStr : data.getConfigurationSection("players").getKeys(false)) {
try {
UUID uuid = UUID.fromString(uuidStr);
String base = "players." + uuidStr + ".trash-chest";
if (!data.contains(base + ".world")) continue;
World world = Bukkit.getWorld(data.getString(base + ".world"));
if (world == null) continue;
Location loc = new Location(world,
data.getInt(base + ".x"), data.getInt(base + ".y"), data.getInt(base + ".z"));
trashChestLocations.put(uuid, loc);
locationToOwner.put(locKey(loc), uuid);
trashFilterLists.put(uuid, new ArrayList<>(data.getStringList("players." + uuidStr + ".trash-items")));
} catch (IllegalArgumentException ignored) {}
}
}
// ══════════════════════════════════════════════════════════════════════════
// SPEICHERN
// ══════════════════════════════════════════════════════════════════════════
private void saveTrashChest(UUID uuid) {
if (plugin.isMysqlEnabled() && plugin.getMysqlManager() != null) {
saveMySQL(uuid);
} else {
saveYaml(uuid);
}
}
private void saveMySQL(UUID uuid) {
MySQLManager db = plugin.getMysqlManager();
String uuidStr = uuid.toString();
Location loc = trashChestLocations.get(uuid);
if (loc != null && loc.getWorld() != null) {
db.setTrashChest(uuidStr, loc.getWorld().getName(),
loc.getBlockX(), loc.getBlockY(), loc.getBlockZ(),
plugin.getServerName());
db.savePlayer(uuidStr, Bukkit.getOfflinePlayer(uuid).getName());
} else {
db.removeTrashChest(uuidStr);
}
db.setTrashItems(uuidStr, trashFilterLists.getOrDefault(uuid, new ArrayList<>()));
}
private void saveYaml(UUID uuid) {
FileConfiguration data = plugin.getPlayerData();
String uuidStr = uuid.toString();
Location loc = trashChestLocations.get(uuid);
if (loc != null && loc.getWorld() != null) {
String path = "players." + uuidStr + ".trash-chest";
data.set(path + ".world", loc.getWorld().getName());
data.set(path + ".x", loc.getBlockX());
data.set(path + ".y", loc.getBlockY());
data.set(path + ".z", loc.getBlockZ());
} else {
data.set("players." + uuidStr + ".trash-chest", null);
}
data.set("players." + uuidStr + ".trash-items",
trashFilterLists.getOrDefault(uuid, new ArrayList<>()));
plugin.savePlayerDataPublic();
}
// ══════════════════════════════════════════════════════════════════════════
// TRUHE VERWALTEN
// ══════════════════════════════════════════════════════════════════════════
public void setTrashChestLocation(UUID uuid, Location loc) {
Location old = trashChestLocations.get(uuid);
if (old != null) locationToOwner.remove(locKey(old));
trashChestLocations.put(uuid, loc);
locationToOwner.put(locKey(loc), uuid);
trashFilterLists.putIfAbsent(uuid, new ArrayList<>());
saveTrashChest(uuid);
}
public void removeTrashChest(UUID uuid) {
Location loc = trashChestLocations.remove(uuid);
if (loc != null) locationToOwner.remove(locKey(loc));
trashFilterLists.remove(uuid);
if (plugin.isMysqlEnabled() && plugin.getMysqlManager() != null) {
plugin.getMysqlManager().removeTrashChest(uuid.toString());
plugin.getMysqlManager().removeAllTrashItems(uuid.toString());
} else {
FileConfiguration data = plugin.getPlayerData();
data.set("players." + uuid + ".trash-chest", null);
data.set("players." + uuid + ".trash-items", null);
plugin.savePlayerDataPublic();
}
}
public UUID getTrashChestOwner(Location loc) {
return locationToOwner.get(locKey(loc));
}
public Location getTrashChestLocation(UUID uuid) {
return trashChestLocations.get(uuid);
}
public Map<UUID, Location> getAllTrashChests() {
return new HashMap<>(trashChestLocations);
}
public boolean isTrashItem(UUID uuid, Material mat) {
if (!trashChestLocations.containsKey(uuid)) return false;
List<String> filter = trashFilterLists.getOrDefault(uuid, new ArrayList<>());
// Leerer Filter = keine Items werden weitergeleitet (Mülltruhe deaktiviert)
return !filter.isEmpty() && filter.contains(mat.name());
}
// ══════════════════════════════════════════════════════════════════════════
// ITEM-VERARBEITUNG
// ══════════════════════════════════════════════════════════════════════════
public void processTrashChestInventory(UUID ownerUUID, Inventory inv) {
List<String> filter = trashFilterLists.getOrDefault(ownerUUID, new ArrayList<>());
// Leerer Filter = keine Items löschen (Mülltruhe deaktiviert bis Items konfiguriert sind)
if (filter.isEmpty()) return;
for (int i = 0; i < inv.getSize(); i++) {
ItemStack item = inv.getItem(i);
if (item == null || item.getType() == Material.AIR) continue;
if (filter.contains(item.getType().name())) inv.setItem(i, null);
}
}
public void clearTrashChest(UUID ownerUUID) {
Location loc = trashChestLocations.get(ownerUUID);
if (loc == null || loc.getWorld() == null) return;
if (loc.getBlock().getState() instanceof Chest chest) chest.getInventory().clear();
}
// ══════════════════════════════════════════════════════════════════════════
// FILTER-LISTE
// ══════════════════════════════════════════════════════════════════════════
public boolean addToFilter(UUID uuid, Material mat) {
List<String> filter = trashFilterLists.computeIfAbsent(uuid, k -> new ArrayList<>());
if (filter.contains(mat.name())) return false;
filter.add(mat.name());
if (plugin.isMysqlEnabled() && plugin.getMysqlManager() != null) {
plugin.getMysqlManager().addTrashItem(uuid.toString(), mat.name());
} else {
saveTrashChest(uuid);
}
return true;
}
public boolean removeFromFilter(UUID uuid, Material mat) {
List<String> filter = trashFilterLists.get(uuid);
if (filter == null) return false;
boolean removed = filter.remove(mat.name());
if (removed) {
if (plugin.isMysqlEnabled() && plugin.getMysqlManager() != null) {
plugin.getMysqlManager().removeTrashItem(uuid.toString(), mat.name());
} else {
saveTrashChest(uuid);
}
}
return removed;
}
public List<String> getFilter(UUID uuid) {
return trashFilterLists.getOrDefault(uuid, new ArrayList<>());
}
// ══════════════════════════════════════════════════════════════════════════
// AUTO-CLEAR-TASK
// ══════════════════════════════════════════════════════════════════════════
public void startAutoTrashTask() {
stopAutoTrashTask();
int intervalSeconds = plugin.getConfig().getInt("trash.auto_clear_interval_seconds", 0);
if (intervalSeconds <= 0) return;
long ticks = intervalSeconds * 20L;
autoTrashTask = new BukkitRunnable() {
@Override
public void run() {
for (Map.Entry<UUID, Location> entry : new HashMap<>(trashChestLocations).entrySet()) {
Location loc = entry.getValue();
if (loc == null || loc.getWorld() == null) continue;
if (loc.getBlock().getState() instanceof Chest chest) {
processTrashChestInventory(entry.getKey(), chest.getInventory());
}
}
}
}.runTaskTimer(plugin, ticks, ticks);
}
public void stopAutoTrashTask() {
if (autoTrashTask != null) { autoTrashTask.cancel(); autoTrashTask = null; }
}
// ══════════════════════════════════════════════════════════════════════════
// KONFIGURATIONS-GUI
// ══════════════════════════════════════════════════════════════════════════
public void openConfigGui(Player player, UUID ownerUUID) {
openGuiOwners.put(player.getUniqueId(), ownerUUID);
Inventory gui = Bukkit.createInventory(null, 54, getGuiTitle());
List<String> filter = trashFilterLists.getOrDefault(ownerUUID, new ArrayList<>());
int displaySlot = 0;
for (String matName : filter) {
if (displaySlot >= 45) break;
Material mat = Material.matchMaterial(matName);
if (mat == null || mat == Material.AIR) continue;
ItemStack display = new ItemStack(mat, 1);
ItemMeta meta = display.getItemMeta();
if (meta != null) {
meta.setDisplayName(getSignColor("trash", "line1") + formatMaterialName(matName));
meta.setLore(Arrays.asList(getSignColor("trash", "line4") + "Rechtsklick: Entfernen"));
display.setItemMeta(meta);
}
gui.setItem(displaySlot++, display);
}
ItemStack filler = new ItemStack(Material.BLACK_STAINED_GLASS_PANE);
ItemMeta fillerMeta = filler.getItemMeta();
if (fillerMeta != null) { fillerMeta.setDisplayName(" "); filler.setItemMeta(fillerMeta); }
for (int i = 45; i <= 53; i++) gui.setItem(i, filler.clone());
ItemStack modeInfo = new ItemStack(filter.isEmpty() ? Material.BARRIER : Material.WATER_BUCKET);
ItemMeta modeMeta = modeInfo.getItemMeta();
if (modeMeta != null) {
if (filter.isEmpty()) {
modeMeta.setDisplayName(getSignColor("trash", "line2") + "" + ChatColor.BOLD + "Modus: Deaktiviert");
modeMeta.setLore(Arrays.asList(
ChatColor.GRAY + "Kein Filter gesetzt ",
ChatColor.GRAY + "Items werden NICHT gelöscht.",
getSignColor("trash", "line1") + "Füge Items hinzu um die Mülltruhe",
getSignColor("trash", "line1") + "zu aktivieren."));
} else {
modeMeta.setDisplayName(getSignColor("trash", "line4") + "" + ChatColor.BOLD + "Modus: Filter aktiv");
modeMeta.setLore(Arrays.asList(
ChatColor.GRAY + "Nur gefilterte Items",
ChatColor.GRAY + "werden gelöscht."));
}
modeInfo.setItemMeta(modeMeta);
}
gui.setItem(48, modeInfo);
ItemStack addBtn = new ItemStack(Material.LIME_STAINED_GLASS_PANE);
ItemMeta addMeta = addBtn.getItemMeta();
if (addMeta != null) {
addMeta.setDisplayName(getSignColor("trash", "line1") + "" + ChatColor.BOLD + "Item hinzufügen");
addMeta.setLore(Arrays.asList(
ChatColor.GRAY + "Item in die Hand nehmen",
ChatColor.GRAY + "und diesen Button klicken."));
addBtn.setItemMeta(addMeta);
}
gui.setItem(49, addBtn);
gui.setItem(53, buildSkullButton());
player.openInventory(gui);
}
public UUID getGuiOwner(UUID playerUUID) {
return openGuiOwners.get(playerUUID);
}
private ItemStack buildSkullButton() {
ItemStack skull;
try {
skull = new ItemStack(Material.PLAYER_HEAD);
SkullMeta meta = (SkullMeta) skull.getItemMeta();
if (meta != null) {
PlayerProfile profile = Bukkit.createPlayerProfile(UUID.randomUUID(), "TrashBtn");
PlayerTextures textures = profile.getTextures();
textures.setSkin(new URL(SKULL_TEXTURE));
profile.setTextures(textures);
meta.setOwnerProfile(profile);
meta.setDisplayName(getChestTitleColor() + "" + ChatColor.BOLD + "Mülltruhe leeren");
meta.setLore(Arrays.asList(
ChatColor.GRAY + "Klicken um alle Items",
ChatColor.GRAY + "sofort zu löschen."));
skull.setItemMeta(meta);
}
} catch (Exception e) {
skull = new ItemStack(Material.RED_DYE);
ItemMeta meta = skull.getItemMeta();
if (meta != null) {
meta.setDisplayName(getChestTitleColor() + "" + ChatColor.BOLD + "Mülltruhe leeren");
meta.setLore(Arrays.asList(
ChatColor.GRAY + "Klicken um alle Items",
ChatColor.GRAY + "sofort zu löschen."));
skull.setItemMeta(meta);
}
}
return skull;
}
// ══════════════════════════════════════════════════════════════════════════
// GUI-LISTENER
// ══════════════════════════════════════════════════════════════════════════
private class GuiListener implements Listener {
@EventHandler
public void onInventoryClick(InventoryClickEvent event) {
if (!(event.getWhoClicked() instanceof Player player)) return;
if (!getGuiTitle().equals(event.getView().getTitle())) return;
event.setCancelled(true);
int clickedSlot = event.getRawSlot();
UUID ownerUUID = openGuiOwners.get(player.getUniqueId());
if (ownerUUID == null) return;
if (clickedSlot == 53) {
clearTrashChest(ownerUUID);
player.sendMessage(getMessage("trash-cleared"));
return;
}
if (clickedSlot == 49) {
ItemStack inHand = player.getInventory().getItemInMainHand();
if (inHand.getType() == Material.AIR) {
player.sendMessage(getMessage("no-item-in-hand"));
return;
}
Material mat = inHand.getType();
if (addToFilter(ownerUUID, mat)) {
player.sendMessage(getMessage("trash-item-added").replace("%item%", formatMaterialName(mat.name())));
} else {
player.sendMessage(getMessage("trash-item-already"));
}
openConfigGui(player, ownerUUID);
return;
}
if (clickedSlot >= 45) return;
if (event.isRightClick()) {
ItemStack clicked = event.getCurrentItem();
if (clicked == null || clicked.getType() == Material.AIR) return;
Material mat = clicked.getType();
if (removeFromFilter(ownerUUID, mat)) {
player.sendMessage(getMessage("trash-item-removed").replace("%item%", formatMaterialName(mat.name())));
openConfigGui(player, ownerUUID);
}
}
}
@EventHandler
public void onInventoryClose(InventoryCloseEvent event) {
if (event.getPlayer() instanceof Player player) {
openGuiOwners.remove(player.getUniqueId());
}
}
}
// ══════════════════════════════════════════════════════════════════════════
// HILFSMETHODEN
// ══════════════════════════════════════════════════════════════════════════
private String getMessage(String key) {
String msg = plugin.getConfig().getString("messages." + key, "messages." + key + " fehlt");
return org.bukkit.ChatColor.translateAlternateColorCodes('&', msg);
}
/**
* Liest eine Schildfarbe aus sign-colors.&lt;type&gt;.&lt;line&gt; in der Config.
* Gibt übersetzten §-Code zurück (z.B. §6 für &6).
*/
private String getSignColor(String type, String line) {
String raw = plugin.getConfig().getString("sign-colors." + type + "." + line, "&f");
return ChatColor.translateAlternateColorCodes('&', raw);
}
/**
* Liest nur den Farb-Präfix aus chest-titles.trash (ohne Titeltext).
* Gibt übersetzten §-Code zurück.
*/
private String getChestTitleColor() {
boolean isEn = "en".equalsIgnoreCase(plugin.getConfig().getString("language", "de"));
String lang = isEn ? "en" : "de";
String full = plugin.getConfig().getString("chest-titles.trash." + lang,
isEn ? "&4Trash Chest" : "&4Mülltruhe");
// Nur die führenden &X / &l Codes extrahieren
StringBuilder codes = new StringBuilder();
for (int i = 0; i + 1 < full.length(); i++) {
if (full.charAt(i) == '&' && "0123456789abcdefklmnor".indexOf(full.charAt(i + 1)) >= 0) {
codes.append(full, i, i + 2);
i++; // Zeichen überspringen
} else {
break; // erster Nicht-Code-Zeichenblock → abbrechen
}
}
return ChatColor.translateAlternateColorCodes('&', codes.length() > 0 ? codes.toString() : "&4");
}
private String locKey(Location loc) {
return loc.getWorld().getName() + ":" + loc.getBlockX() + ":" + loc.getBlockY() + ":" + loc.getBlockZ();
}
public static String formatMaterialName(String name) {
if (name == null || name.isEmpty()) return "";
String[] parts = name.split("_");
StringBuilder sb = new StringBuilder();
for (String part : parts) {
if (sb.length() > 0) sb.append(' ');
if (!part.isEmpty()) {
sb.append(Character.toUpperCase(part.charAt(0)));
if (part.length() > 1) sb.append(part.substring(1).toLowerCase());
}
}
return sb.toString();
}
}

View File

@@ -21,7 +21,7 @@ public class UpdateChecker {
public void getVersion(final Consumer<String> consumer) {
Bukkit.getScheduler().runTaskAsynchronously(this.plugin, () -> {
try (InputStream is = new URL("https://api.spigotmc.org/legacy/update.php?resource=" + this.resourceId + "/~").openStream();
try (InputStream is = new URL("https://api.spigotmc.org/legacy/update.php?resource=" + this.resourceId).openStream();
Scanner scann = new Scanner(is)) {
if (scann.hasNext()) {
consumer.accept(scann.next());

View File

@@ -7,19 +7,24 @@
#
# ============================================================
# --- GRUNDLEGUNG ---
# Version der Konfigurationsdatei. Nicht ändern, um Fehler zu vermeiden!
# ============================================================
# ALLGEMEIN
# ============================================================
version: "2.0"
# Debug-Modus (true = Ausführliche Logs in der Server-Konsole, nur zum Entwickeln nutzen)
# Version der Konfigurationsdatei bitte nicht ändern!
version: "2.3"
# Debug-Modus: true = Ausführliche Logs in der Konsole (nur zum Entwickeln)
debug: false
# ---------------------------------------------------
# DATENBANK (MySQL/MariaDB) - Optional
# ---------------------------------------------------
# Aktiviere MySQL/MariaDB Speicherung (true/false)
# Sprache der Benutzeroberfläche
# Mögliche Werte: 'de' (Deutsch) oder 'en' (Englisch)
# Betrifft: /asc help, /asc info und die Truhen-Fenstertitel
language: "de"
# ============================================================
# DATENBANK (MySQL / MariaDB) Optional
# ============================================================
mysql:
enabled: false
@@ -29,103 +34,72 @@ mysql:
user: "autosortchest"
password: "autosortchest"
# Soll serverübergreifendes Sortieren (mit MySQL) erlaubt sein?
server_crosslink: true
# ---------------------------------------------------
# ============================================================
# BUNGEE CORD / MULTI-SERVER SETUP
# ---------------------------------------------------
# ============================================================
# Soll serverübergreifendes Sortieren (über MySQL) erlaubt sein?
server_crosslink: false
# Eindeutiger Name dieses Servers im BungeeCord-Netzwerk.
# WICHTIG: Jeder Server braucht einen anderen Namen!
#
# Beispiele:
# server_name: "lobby"
# server_name: "survival"
# server_name: "creative"
# Beispiele: lobby | survival | creative
#
# Leer lassen = Legacy-Modus (welt-basierte Erkennung, kein BungeeCord).
# Fuer BungeeCord MUSS mysql.enabled: true gesetzt sein!
# Für BungeeCord MUSS mysql.enabled: true gesetzt sein!
#
# Setup-Schritte:
# Setup:
# 1. Gleiche MySQL-Datenbank auf allen Servern eintragen.
# 2. Auf jedem Server einen einzigartigen server_name setzen.
# 3. mysql.enabled: true und server_crosslink: true setzen.
# 4. Alle Server neu starten - Schema wird automatisch migriert.
# 4. Alle Server neu starten Schema wird automatisch migriert.
server_name: ""
# ---------------------------------------------------
# SPRACHE (Language)
# ---------------------------------------------------
# Mögliche Werte: 'de' für Deutsch oder 'en' für Englisch
# Ändert den Text von /asc help und /asc info
language: "de"
# ---------------------------------------------------
# BLACKLIST FÜR WELTEN (Optional)
# ---------------------------------------------------
# ============================================================
# WELTEN-BLACKLIST
# ============================================================
# Welten, in denen AutoSortChest NICHT funktioniert
world_blacklist:
- "world_nether"
- "world_the_end"
# ---------------------------------------------------
# VISUELLE EFFEKTE (PARTIKEL & TÖNE)
# ---------------------------------------------------
# Einstellungen für den Regenbogen-Effekt beim Sortieren
effects:
# Sollen Effekte angezeigt werden?
enabled: false
# Soll ein Ton gespielt werden, wenn Items ankommen?
sound: false
# Der Partikel-Typ.
# 'DUST' ist zwingend für den bunten Regenbogen-Effekt im aktuellen Code.
type: "DUST"
# ---------------------------------------------------
# ============================================================
# SORTIER-INTERVALL (Ticks)
# ---------------------------------------------------
# Wie oft soll sortiert werden? (1 Tick = 0,05s)
#
# Wähle hier je nach Server-Leistung:
#
# 1 = SEHR SCHNELL (Items verschwinden sofort)
# WARNUNG: Kann bei vielen Truhen Lagg verursachen!
#
# 5 = SCHNELL (Sehr flüssig, gute Balance)
# Empfohlen für schnelle Server.
#
# 10 = FLÜSSIG (0,5s Verzögerung)
# Spart Ressourcen, fühlt sich noch schnell an.
#
# 20 = STANDARD (1 Sekunde)
# Standard-Wert, minimale Last.
#
# 30+ = SPARSAM (>1,5 Sekunden)
# Für sehr große Server mit schwacher Hardware.
# ============================================================
# Wie oft soll sortiert werden? (1 Tick = 0,05 Sekunden)
#
# 1 = Sehr schnell Items verschwinden sofort
# WARNUNG: Kann bei vielen Truhen Lag verursachen!
# 5 = Schnell Sehr flüssig, gute Balance
# 10 = Flüssig 0,5s Verzögerung, spart Ressourcen <- Empfohlen
# 20 = Standard 1 Sekunde, minimale Last
# 30+ = Sparsam Für große Server mit schwacher Hardware
sort_interval_ticks: 5
sort_interval_ticks: 10
# ---------------------------------------------------
# LIMITS FÜR SORTIERKISTEN (Optional)
# ---------------------------------------------------
# Maximale Anzahl an Sortierkisten pro Spielergruppe
# Wie oft werden Rest-Truhen neu einsortiert? (in Ticks)
rest_resort_interval_ticks: 400 # 400 Ticks = 20 Sekunden
# ============================================================
# TRUHEN-LIMITS
# ============================================================
# Maximale Anzahl an Sortiertruhen pro Spielergruppe.
# Sollen Limits aktiv sein? (true = ja, false = keine Beschränkung)
chest_limits:
# Sollen Truhen-Limits aktiv sein? (true = ja, false = keine Beschraenkung)
enabled: true
# Jede Gruppe hat eigene Limits fuer input, rest und target.
# Spieler benoetigen die Permission: autosortchest.limit.<gruppe>
enabled: false
# Spieler benötigen die Permission: autosortchest.limit.<gruppe>
# WICHTIG: Spieler OHNE jegliche autosortchest.limit.*-Permission können bei
# aktivierten Limits KEINE Truhen erstellen (Limit = 0).
# Vergib autosortchest.limit.default an alle normalen Spieler (z.B. in LuckPerms).
default:
input: 1 # Eingangstruhen (Input)
input: 1 # Eingangstruhen
rest: 1 # Rest-Truhen (Fallback)
target: 50 # Zieltruhen gesamt
target_per_item: 1 # Wie viele Zieltruhen pro Item-Typ erlaubt sind
target_per_item: 1 # Zieltruhen pro Item-Typ
vip:
input: 2
@@ -133,7 +107,7 @@ chest_limits:
target: 100
target_per_item: 3
# Weitere Gruppen:
# Weitere Gruppen (auskommentiert):
# supporter:
# input: 3
# rest: 2
@@ -145,60 +119,196 @@ chest_limits:
# target: 200
# target_per_item: 10
# ---------------------------------------------------
# SCHILDFARBEN (Farbcodes wie im Chat)
# &c = Rot, &a = Grün, &e = Gelb, &6 = Gold, &f = Weiß, &0 = Schwarz
# ---------------------------------------------------
# ============================================================
# MÜLLTRUHE
# ============================================================
# auto_clear_interval_seconds:
# 0 = Deaktiviert (Truhe wird nur beim Schließen geleert)
# 300 = Alle 5 Minuten
# 3600 = Stündlich
trash:
auto_clear_interval_seconds: 0
# ============================================================
# VISUELLE EFFEKTE (Partikel & Töne)
# ============================================================
effects:
# Sollen Partikel-Effekte angezeigt werden?
enabled: false
# Soll ein Ton gespielt werden, wenn Items ankommen?
sound: false
# Partikel-Typ ('DUST' = bunter Regenbogen-Effekt)
type: "DUST"
# ============================================================
# SCHILD-STIL
# ============================================================
sign-style:
# Saubere Zieltruhen-Schilder (ohne Item-Namen auf dem Schild)
# true = Clean-Modus aktiviert
clean-target: false
# ============================================================
# SCHILDFARBEN
# ============================================================
# Farbcodes: &0-&9, &a-&f | &l = Fett, &o = Kursiv, &r = Reset
#
# &0 Schwarz &1 Dunkelblau &2 Dunkelgrün &3 Cyan
# &4 Dunkelrot &5 Lila &6 Gold &7 Grau
# &8 Dunkelgrau &9 Blau &a Grün &b Aqua
# &c Rot &d Pink &e Gelb &f Weiß
sign-colors:
# Farben für die Eingangstruhe ([asc] / input)
# Eingangstruhe ([asc] / input)
input:
line1: "&6" # Zeile 1: [asc]
line2: "&0" # Zeile 2: input
line4: "&1" # Zeile 4: Spielername
# Farben für die Zieltruhe ([asc] / ziel)
# Zieltruhe ([asc] / ziel)
target:
line1: "&6" # Zeile 1: [asc]
line2: "&0" # Zeile 2: ziel
line3: "&f" # Zeile 3: Item-Name
line4: "&1" # Zeile 4: Spielername
# Farben für volle Truhen (Automatische Erkennung)
# Volle Zieltruhe (automatische Erkennung)
full:
line1: "&c" # Zeile 1: [asc]
line2: "&4" # Zeile 2: ziel / rest (Rot)
line3: "&e" # Zeile 3: Item-Name (Gelb)
line2: "&4" # Zeile 2: ziel / rest
line3: "&e" # Zeile 3: Item-Name
line4: "&1" # Zeile 4: Spielername
# Farben für die Rest-Truhe ([asc] / rest)
# Rest-Truhe ([asc] / rest)
rest:
line1: "&6" # Zeile 1: [asc]
line2: "&0" # Zeile 2: rest
line3: "&f" # Zeile 3: (Leer)
line3: "&f" # Zeile 3: (leer)
line4: "&1" # Zeile 4: Spielername
# ---------------------------------------------------
# SYSTEM NACHRICHTEN (Spieler-Feedback)
# Mülltruhe ([asc] / trash)
trash:
line1: "&6" # Zeile 1: [asc]
line2: "&0" # Zeile 2: trash
line4: "&1" # Zeile 4: Spielername
# ============================================================
# CLEAN-MODUS SCHILDFARBEN (sign-style.clean-target: true)
# ============================================================
# Eigene Farben für den sauberen Schild-Stil.
# Farbcodes: &0-&9, &a-&f | &l = Fett, &o = Kursiv, &r = Reset
#
# Layout im Clean-Modus (Zeile 4 = versteckter Typ-Marker, nicht konfigurierbar):
#
# input → Z1: Spielername | Z2: "Eingang/Input" | Z3: Öffentlich/Privat
# target → Z1: Item-Name | Z2: Spielername | Z3: Öffentlich/Privat
# full → Z1: Item-Name | Z2: Spielername | Z3: Öffentlich/Privat (volle Truhe)
# rest → Z1: Spielername | Z2: "Rest" | Z3: Öffentlich/Privat
# trash → Z1: Spielername | Z2: "Müll/Trash" | Z3: (leer)
sign-colors-clean:
# Eingangstruhe (Clean)
input:
line1: "&1" # Zeile 1: Spielername
line2: "&0" # Zeile 2: "Eingang" / "Input"
line3: "&a" # Zeile 3: Öffentlich / Privat
# Zieltruhe (Clean)
target:
line1: "&f" # Zeile 1: Item-Name
line2: "&1" # Zeile 2: Spielername
line3: "&a" # Zeile 3: Öffentlich / Privat
# Volle Zieltruhe (Clean)
full:
line1: "&c" # Zeile 1: Item-Name (volle Truhe) → Rot
line2: "&1" # Zeile 2: Spielername
line3: "&a" # Zeile 3: Öffentlich / Privat
# Rest-Truhe (Clean)
rest:
line1: "&1" # Zeile 1: Spielername
line2: "&0" # Zeile 2: "Rest"
line3: "&a" # Zeile 3: Öffentlich / Privat
# Mülltruhe (Clean)
trash:
line1: "&1" # Zeile 1: Spielername
line2: "&0" # Zeile 2: "Müll" / "Trash"
# ============================================================
# TRUHEN-FENSTERTITEL
# ============================================================
# Farbe & Text des Titels, wenn ein Spieler eine ASC-Truhe öffnet.
# Farbcodes wie oben.
#
# Platzhalter für Zieltruhen:
# %item% -> wird durch den Item-Namen ersetzt (z.B. "Iron Ore")
# Beispiel: "&6%item%" zeigt "Iron Ore" in Gold
chest-titles:
input:
de: "&6Eingangstruhe"
en: "&6Input Chest"
target:
de: "&6%item%"
en: "&6%item%"
rest:
de: "&6Rest-Truhe"
en: "&6Rest Chest"
trash:
de: "&4Mülltruhe"
en: "&4Trash Chest"
# ============================================================
# SYSTEM-NACHRICHTEN (Spieler-Feedback)
# ============================================================
# Platzhalter: %player%, %item%, %x%, %y%, %z%, %mode%
# ---------------------------------------------------
messages:
# --- FEHLERMELDUNGEN ---
# --- Fehlermeldungen ---
no-chest-near-sign: "&cKeine Truhe in der Nähe des Schildes!"
no-item-in-hand: "&cDu musst ein Item in der Hand halten!"
not-your-chest: "&cDiese Truhe gehört dir nicht!"
target-chest-missing: "&cZieltruhe für %item% fehlt!"
sign-break-denied: "&cDu musst Shift gedrückt halten, um dieses Schild oder die Truhe abzubauen!"
no-permission: "&cDu hast keine Berechtigung für diesen Befehl!"
world-blacklisted: "&cIn dieser Welt kannst du keine AutoSortChest erstellen!"
# --- ERFOLGSMELDUNGEN ---
# --- Limit-Fehlermeldungen ---
# Platzhalter: %max% = erlaubtes Limit, %item% = Item-Name
limit-input-reached: "&cDu hast das Limit deiner Eingangstruhen erreicht! &7(%max%)"
limit-rest-reached: "&cDu hast das Limit deiner Rest-Truhen erreicht! &7(%max%)"
limit-target-reached: "&cDu hast das Limit deiner Zieltruhen erreicht! &7(%max%)"
limit-target-per-item: "&cDu hast das Limit für %item%-Truhen erreicht! &7(%max%)"
limit-no-permission: "&cDu hast keine Berechtigung um Truhen zu erstellen!"
# --- Erfolgsmeldungen ---
input-chest-set: "&aEingangstruhe erfolgreich gesetzt!"
target-chest-set: "&aZieltruhe erfolgreich für %item% eingerichtet!"
rest-chest-set: "&aRest-Truhe (Fallback) erfolgreich gesetzt!"
trash-chest-set: "&aMülltruhe erfolgreich eingerichtet!"
trash-chest-hint: "&7Rechtsklicke das Schild um Items zu konfigurieren."
reload-success: "&aKonfiguration erfolgreich neu geladen!"
# --- HINWEIS MELDUNGEN ---
# --- Mülltruhe GUI ---
trash-cleared: "&a✔ Mülltruhe wurde geleert!"
trash-item-added: "&a✔ &e%item% &azur Müll-Liste hinzugefügt."
trash-item-already: "&eDiseses Item ist bereits in der Müll-Liste."
trash-item-removed: "&c✖ &e%item% &caus der Müll-Liste entfernt."
# --- Mülltruhe Info (erscheint im Chat beim Öffnen der Truhe) ---
# Platzhalter: %items% = kommagetrennte Item-Liste
trash-info-empty: "&4Mülltruhe &8(Deaktiviert) &7 Rechtsklick Schild zum Konfigurieren"
trash-info-filter: "&4Müll: &f%items% &8| Schild-Rechtsklick: Konfigurieren"
# --- Hinweise ---
target-chest-full: "&cZieltruhe für %item% ist voll! Koordinaten: (%x%, %y%, %z%)"
mode-changed: "&aModus gewechselt: &e%mode%"
mode-public: "&aÖffentlich"

View File

@@ -1,5 +1,5 @@
name: AutoSortChest
version: 2.2
version: 2.5
main: com.viper.autosortchest.Main
api-version: 1.21
authors: [M_Viper]
@@ -10,6 +10,9 @@ commands:
usage: /<command> [help|info|reload|import|export]
aliases: [autosortchest]
permissions:
autosortchest.use:
description: Erlaubt das Erstellen von AutoSortChest-Schildern (Eingang, Ziel, Rest, Muelltruhe)
default: true
autosortchest.reload:
description: Erlaubt das Neuladen der Konfiguration mit /asc reload
default: op
@@ -20,8 +23,20 @@ permissions:
description: Erlaubt den Export von MySQL nach players.yml mit /asc export
default: op
autosortchest.bypass:
description: Erlaubt das Abbauen von ASC-Schildern ohne Shift-Taste und unabhängig vom Besitzer
description: Erlaubt das Abbauen von ASC-Schildern ohne Shift-Taste und unabhaengig vom Besitzer
default: op
autosortchest.limit.bypass:
description: Umgeht alle Truhen-Limits (input, rest, target) OPs haben dies automatisch
default: op
autosortchest.admin:
description: Erlaubt OPs/Admins Zugriff auf fremde AutoSortChest-Truhen (Öffnen, Entnehmen, Abbauen)
description: Erlaubt OPs/Admins Zugriff auf fremde AutoSortChest-Truhen
default: op
autosortchest.limit.<gruppe>:
description: >
Limits fuer eine benutzerdefinierte Gruppe aus der config.yml.
Ersetze <gruppe> durch den Gruppennamen (z.B. autosortchest.limit.vip).
Die Gruppen und ihre Limits werden ausschliesslich in der config.yml definiert.
WICHTIG: Spieler ohne jegliche autosortchest.limit.*-Permission koennen bei
aktivierten Limits (chest_limits.enabled: true) KEINE Truhen erstellen.
Vergib autosortchest.limit.default fuer den Standard-Rang.
default: false