Commits vergleichen
267 Commits
Autor | SHA1 | Datum | |
---|---|---|---|
726fb12354 | |||
089113f0c0 | |||
41c0117d06 | |||
ec17a6b2d0 | |||
1eeb45a293 | |||
80ddb37108 | |||
35a94a7907 | |||
16013fa7b1 | |||
e3b5a5ab4d | |||
584ea77419 | |||
|
6ff7170310 | ||
|
857c33978d | ||
|
4e76cd654b | ||
c47d57fbb6 | |||
|
5d4be80c61 | ||
|
50f5c940bb | ||
86f7ca728a | |||
|
b514594cfd | ||
|
3703a82190 | ||
|
31eeac1217 | ||
|
46b5bb29cc | ||
|
56a602ccee | ||
|
8a474997c6 | ||
|
7d3fffa9da | ||
|
eef545d282 | ||
|
33d6a9ad53 | ||
|
985f11e968 | ||
|
e81f4a314f | ||
|
169e4fd75f | ||
|
c664e08fa6 | ||
|
ccdfb40d71 | ||
|
429d4eba84 | ||
|
a8d68ddd7e | ||
88ffcac32f | |||
|
2fd915b3f3 | ||
|
eaaafef825 | ||
|
3abbac1547 | ||
|
12ab5b4652 | ||
|
66bdb46a56 | ||
|
f6bba7eaea | ||
|
ca5b271f65 | ||
|
5652832486 | ||
|
6eccdbf3ec | ||
|
d34c5b2583 | ||
|
13e1646477 | ||
|
2fce9f927f | ||
|
bd37391e88 | ||
|
573188a5ec | ||
|
271b38c775 | ||
|
88f9063d23 | ||
|
a2174106ac | ||
|
5e903f115d | ||
|
412505ee0c | ||
|
b8f6eacca4 | ||
|
2809593238 | ||
|
cdf12be656 | ||
|
43a712c62a | ||
|
8de16e966c | ||
|
f5bb922df9 | ||
|
f36a226120 | ||
|
b00ce4a2e1 | ||
|
63dd784118 | ||
|
4fca055164 | ||
|
2ee72bdb9b | ||
|
ee259e28b6 | ||
|
a2ccc6ce43 | ||
|
174808befc | ||
2199ba2ae2 | |||
|
6dde2cf3fc | ||
|
d95ecb088b | ||
|
051c3a0d97 | ||
|
8287ea3137 | ||
|
0e13b0d010 | ||
|
a721f61a38 | ||
|
f1a1f4edd1 | ||
|
822f1c2faa | ||
|
06f1df7fc9 | ||
|
315a59bc91 | ||
fd575dffe2 | |||
|
fd66be9b37 | ||
465d2a32b1 | |||
|
149a2e9a27 | ||
|
7afe6d73c8 | ||
aeb0d36696 | |||
|
959a17b89f | ||
|
683e9d57fa | ||
|
5e752943fd | ||
|
eba2a3e80b | ||
|
9281c5e56e | ||
|
0700ae4247 | ||
|
a36658faa5 | ||
|
1a8c5a0677 | ||
|
b0703c393b | ||
|
00245f5bf5 | ||
7851be80fd | |||
|
19020e6e6a | ||
|
fef92e7f8e | ||
|
ace8419e31 | ||
|
407eb7a468 | ||
|
afc3440486 | ||
|
6eef99db65 | ||
|
3766265fc7 | ||
|
9ddb30a3cf | ||
|
123a16fd42 | ||
|
6e195a6c93 | ||
|
9914c029e5 | ||
|
f78927c50a | ||
|
8642eb4564 | ||
|
5530987e6e | ||
|
b8f606b1ef | ||
|
0e0c315045 | ||
d3772a0c0d | |||
|
fcbfcf1c9c | ||
|
5553b8d733 | ||
|
996303b97a | ||
|
5fda841f27 | ||
|
1f9d04c8ae | ||
|
1423f864c6 | ||
|
e77d43d8d7 | ||
|
23d7698076 | ||
|
5f4cd5b9ea | ||
|
6a2ca1c39a | ||
|
62dafab6d7 | ||
|
c4f8056b5e | ||
|
51083cbe3a | ||
|
74fbf965ac | ||
|
86b157aac4 | ||
a28fd77566 | |||
|
3ae6387cae | ||
|
94f9184094 | ||
|
88a7b66422 | ||
|
93ec17f929 | ||
|
2cad972c5c | ||
|
52a154a6c4 | ||
|
d63431127d | ||
|
7a2588cd60 | ||
|
a704ffe7c1 | ||
|
b15cca62cb | ||
|
92cb06191a | ||
|
39f25462ff | ||
|
b3d281e189 | ||
|
917d674f21 | ||
|
834bcb5428 | ||
|
170b1da9a7 | ||
|
eb336fd89e | ||
|
744dccb326 | ||
74a10cba9a | |||
b45055da94 | |||
|
eb2027e5cb | ||
|
73cca7675c | ||
|
3a885bbe5e | ||
|
ef87eae96e | ||
cf3e083f8d | |||
1c16f6703e | |||
a1500d4368 | |||
d96cf47eff | |||
|
938ace0e31 | ||
2893325be3 | |||
a690baf348 | |||
fc155f653d | |||
|
307036ac82 | ||
|
d9bad80a54 | ||
e1418aed99 | |||
|
b6a8ab4b4f | ||
|
0e12df8b05 | ||
|
5ebe8c2ce3 | ||
|
40ac248553 | ||
|
7f3725842f | ||
|
86888e708f | ||
|
310c28d54b | ||
|
bc5542204a | ||
|
61bcb9f16d | ||
|
d288edf2c9 | ||
|
ccdf61b6c9 | ||
|
a2e5a7b320 | ||
|
f16f260c96 | ||
|
7e17d5ab34 | ||
|
09c6d3fe79 | ||
|
1e8f6ab99f | ||
|
c4132ebda1 | ||
|
4bd2e6e779 | ||
|
ace5778fba | ||
|
7d8ba6675b | ||
|
1b8e572025 | ||
|
4140225b91 | ||
|
1247f596d2 | ||
|
d800b90ac2 | ||
|
897fdba6bb | ||
|
d42c116f60 | ||
|
0591a1c5cc | ||
|
9224d6f9a6 | ||
|
92bcc4b205 | ||
|
1b18fe5a28 | ||
|
737a6b5a0d | ||
|
0a2760efbd | ||
|
d8d5d150d2 | ||
|
a7a7a0b5e3 | ||
|
769538bef3 | ||
03d8c7a078 | |||
|
e428a1285f | ||
|
6f93130fe6 | ||
|
604e683362 | ||
|
7aafe88ead | ||
|
9453e41a05 | ||
|
e58ad971f6 | ||
|
9e0f9c42df | ||
7a6b22d832 | |||
|
3fc2c3d505 | ||
|
1e04cca2f8 | ||
|
884125a62e | ||
|
8c905ceacf | ||
|
26a02f5098 | ||
|
8322f64182 | ||
|
171c0ddd02 | ||
|
b2c0003570 | ||
|
03254ed85d | ||
|
94711318f9 | ||
|
57de31af2f | ||
|
37e59401d7 | ||
|
1a6c532f45 | ||
|
2ad03392ac | ||
18f1b9c088 | |||
13be5f1725 | |||
|
48a10b0b9b | ||
|
d6f4de67f5 | ||
|
fed00014bc | ||
|
4f0bbecc36 | ||
|
cd3915bb89 | ||
|
7c12b38174 | ||
|
9a59c903fe | ||
|
e4194b46b0 | ||
|
322c0530a1 | ||
|
70ca0c5574 | ||
|
cfacfce82e | ||
|
e55b0481c4 | ||
|
f87bf8d902 | ||
09017ede77 | |||
0fd8fcbb38 | |||
bc8bb20e23 | |||
07e10c86d9 | |||
|
82fb26592c | ||
|
c22109daa9 | ||
|
441bc4ee6c | ||
|
e28d01ca05 | ||
|
41ea0beaa4 | ||
|
8fe2a4f648 | ||
|
1918c96816 | ||
|
0d10aedd81 | ||
|
4f8e527201 | ||
863ef9cc2a | |||
f71d732a47 | |||
|
1ff74f7ab8 | ||
|
b59ff373b1 | ||
|
7c300f366f | ||
|
1758b4b9aa | ||
|
d59dc62284 | ||
|
2f9cdff26d | ||
|
ad5e7f977b | ||
|
df2db0d63d | ||
5dcb083954 | |||
eca811f3a4 | |||
3fadc8156b | |||
bb5f56b7f8 | |||
e1fadadb58 | |||
|
5662062b2c | ||
923fc5c062 | |||
fb8389bece |
18
.gitignore
vendored
18
.gitignore
vendored
@ -1,5 +1,15 @@
|
||||
# Package Files
|
||||
*.jar
|
||||
|
||||
# Gradle
|
||||
.gradle
|
||||
**/build/
|
||||
!gradle/wrapper/gradle-wrapper.jar
|
||||
steamwar.properties
|
||||
|
||||
# IntelliJ IDEA
|
||||
.idea
|
||||
target
|
||||
lib
|
||||
dependency-reduced-pom.xml
|
||||
*.iml
|
||||
*.iml
|
||||
|
||||
# Other
|
||||
lib
|
@ -1,54 +0,0 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<project xmlns="http://maven.apache.org/POM/4.0.0"
|
||||
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
|
||||
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
|
||||
<modelVersion>4.0.0</modelVersion>
|
||||
|
||||
<artifactId>SchematicSystem_12</artifactId>
|
||||
<version>1.0</version>
|
||||
|
||||
<parent>
|
||||
<groupId>steamwar</groupId>
|
||||
<artifactId>SchematicSystem</artifactId>
|
||||
<version>1.0</version>
|
||||
</parent>
|
||||
|
||||
<properties>
|
||||
<main.basedir>${project.basedir}/..</main.basedir>
|
||||
</properties>
|
||||
|
||||
<build>
|
||||
<sourceDirectory>src</sourceDirectory>
|
||||
<resources>
|
||||
<resource>
|
||||
<directory>src</directory>
|
||||
<excludes>
|
||||
<exclude>**/*.java</exclude>
|
||||
<exclude>**/*.kt</exclude>
|
||||
</excludes>
|
||||
</resource>
|
||||
</resources>
|
||||
</build>
|
||||
|
||||
<dependencies>
|
||||
<dependency>
|
||||
<groupId>steamwar</groupId>
|
||||
<artifactId>Spigot</artifactId>
|
||||
<version>1.12</version>
|
||||
<scope>system</scope>
|
||||
<systemPath>${main.basedir}/lib/Spigot-1.12.jar</systemPath>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>steamwar</groupId>
|
||||
<artifactId>WorldEdit</artifactId>
|
||||
<version>1.12</version>
|
||||
<scope>system</scope>
|
||||
<systemPath>${main.basedir}/lib/WorldEdit-1.12.jar</systemPath>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>steamwar</groupId>
|
||||
<artifactId>SchematicSystem_API</artifactId>
|
||||
<version>1.0</version>
|
||||
</dependency>
|
||||
</dependencies>
|
||||
</project>
|
@ -1,193 +0,0 @@
|
||||
/*
|
||||
This file is a part of the SteamWar software.
|
||||
|
||||
Copyright (C) 2020 SteamWar.de-Serverteam
|
||||
|
||||
This program is free software: you can redistribute it and/or modify
|
||||
it under the terms of the GNU Affero General Public License as published by
|
||||
the Free Software Foundation, either version 3 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 Affero General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU Affero General Public License
|
||||
along with this program. If not, see <https://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
package de.steamwar.schematicsystem;
|
||||
|
||||
import com.sk89q.jnbt.CompoundTag;
|
||||
import com.sk89q.worldedit.Vector;
|
||||
import com.sk89q.worldedit.blocks.BaseBlock;
|
||||
import com.sk89q.worldedit.extent.clipboard.Clipboard;
|
||||
import com.sk89q.worldedit.regions.Region;
|
||||
import de.steamwar.sql.NoClipboardException;
|
||||
import de.steamwar.sql.Schematic;
|
||||
import org.bukkit.Bukkit;
|
||||
import org.bukkit.Material;
|
||||
|
||||
import java.io.IOException;
|
||||
import java.util.HashSet;
|
||||
import java.util.List;
|
||||
import java.util.Set;
|
||||
import java.util.logging.Level;
|
||||
|
||||
@SuppressWarnings("deprecation")
|
||||
class CheckSchemType_12 {
|
||||
private static final int TNT = Material.TNT.getId();
|
||||
private static final int SLIME = Material.SLIME_BLOCK.getId();
|
||||
private static final int OBSIDIAN = Material.OBSIDIAN.getId();
|
||||
private static final int BEDROCK = Material.BEDROCK.getId();
|
||||
private static final int DISPENSER = Material.DISPENSER.getId();
|
||||
private static final int AIR = Material.AIR.getId();
|
||||
private static final int JUKEBOX = Material.JUKEBOX.getId();
|
||||
private static final int CHEST = Material.CHEST.getId();
|
||||
private static final Set<Integer> INVENTORY;
|
||||
private static final Set<Material> FLOWERS;
|
||||
|
||||
static{
|
||||
Set<Integer> inventory = new HashSet<>();
|
||||
inventory.add(CHEST);
|
||||
inventory.add(Material.TRAPPED_CHEST.getId());
|
||||
inventory.add(Material.HOPPER.getId());
|
||||
inventory.add(Material.FURNACE.getId());
|
||||
inventory.add(Material.BURNING_FURNACE.getId());
|
||||
inventory.add(JUKEBOX); //RecordItem
|
||||
inventory.add(DISPENSER);
|
||||
inventory.add(Material.DROPPER.getId());
|
||||
inventory.add(Material.ANVIL.getId());
|
||||
inventory.add(Material.BREWING_STAND.getId());
|
||||
inventory.add(Material.BLACK_SHULKER_BOX.getId());
|
||||
inventory.add(Material.RED_SHULKER_BOX.getId());
|
||||
inventory.add(Material.WHITE_SHULKER_BOX.getId());
|
||||
inventory.add(Material.ORANGE_SHULKER_BOX.getId());
|
||||
inventory.add(Material.BLUE_SHULKER_BOX.getId());
|
||||
inventory.add(Material.LIGHT_BLUE_SHULKER_BOX.getId());
|
||||
inventory.add(Material.YELLOW_SHULKER_BOX.getId());
|
||||
inventory.add(Material.GREEN_SHULKER_BOX.getId());
|
||||
inventory.add(Material.BROWN_SHULKER_BOX.getId());
|
||||
inventory.add(Material.CYAN_SHULKER_BOX.getId());
|
||||
inventory.add(Material.GRAY_SHULKER_BOX.getId());
|
||||
inventory.add(Material.SILVER_SHULKER_BOX.getId());
|
||||
inventory.add(Material.LIME_SHULKER_BOX.getId());
|
||||
inventory.add(Material.MAGENTA_SHULKER_BOX.getId());
|
||||
inventory.add(Material.PINK_SHULKER_BOX.getId());
|
||||
inventory.add(Material.PURPLE_SHULKER_BOX.getId());
|
||||
INVENTORY = inventory;
|
||||
|
||||
Set<Material> flowers = new HashSet<>();
|
||||
flowers.add(Material.YELLOW_FLOWER);
|
||||
flowers.add(Material.RED_ROSE);
|
||||
flowers.add(Material.DOUBLE_PLANT);
|
||||
FLOWERS = flowers;
|
||||
}
|
||||
|
||||
private CheckSchemType_12(){}
|
||||
|
||||
static AutoCheckResult autoCheck(Schematic schematic, ICheckSchemType type) {
|
||||
AutoCheckResult result = new AutoCheckResult(type);
|
||||
Clipboard clipboard;
|
||||
try {
|
||||
clipboard = schematic.load();
|
||||
} catch (IOException | NoClipboardException e) {
|
||||
Bukkit.getLogger().log(Level.SEVERE, "Schematic could not be loaded", e);
|
||||
result.setErrorLoadingSchematic();
|
||||
return result;
|
||||
}
|
||||
|
||||
Vector dimensions = clipboard.getDimensions();
|
||||
result.setLength(dimensions.getBlockX());
|
||||
result.setHeight(dimensions.getBlockY());
|
||||
result.setWidth(dimensions.getBlockZ());
|
||||
|
||||
Region region = clipboard.getRegion();
|
||||
Vector min = region.getMinimumPoint();
|
||||
Vector max = region.getMaximumPoint();
|
||||
|
||||
int tnt = 0;
|
||||
int slime = 0;
|
||||
int blocks = 0;
|
||||
int dispenser = 0;
|
||||
|
||||
for(int x = min.getBlockX(); x <= max.getBlockX(); x++){
|
||||
for(int y = min.getBlockY(); y <= max.getBlockY(); y++){
|
||||
for(int z = min.getBlockZ(); z <= max.getBlockZ(); z++){
|
||||
final BaseBlock block = clipboard.getBlock(new Vector(x, y, z));
|
||||
final int blockId = block.getId();
|
||||
|
||||
if(blockId == TNT || blockId == OBSIDIAN)
|
||||
tnt++;
|
||||
|
||||
if(blockId == SLIME || blockId == BEDROCK)
|
||||
slime++;
|
||||
|
||||
if(blockId == DISPENSER)
|
||||
dispenser++;
|
||||
|
||||
if (blockId != AIR)
|
||||
blocks++;
|
||||
|
||||
if(INVENTORY.contains(blockId)){
|
||||
checkInventory(result, block, blockId, type);
|
||||
}
|
||||
|
||||
result.checkMaterial(Material.getMaterial(blockId).name());
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
result.setTNT(tnt);
|
||||
result.setSlime(slime);
|
||||
result.setDispenser(dispenser);
|
||||
result.setBlocks(blocks);
|
||||
|
||||
return result;
|
||||
}
|
||||
|
||||
private static void checkInventory(AutoCheckResult result, BaseBlock block, int blockId, ICheckSchemType type){
|
||||
CompoundTag nbt = block.getNbtData();
|
||||
if(nbt == null){
|
||||
result.defunctNbt(Material.getMaterial(blockId).name());
|
||||
return;
|
||||
}
|
||||
|
||||
if(blockId == JUKEBOX && nbt.getValue().containsKey("RecordItem")){
|
||||
result.foundRecord();
|
||||
return;
|
||||
}
|
||||
|
||||
List<CompoundTag> items = nbt.getList("Items", CompoundTag.class);
|
||||
if(items.isEmpty())
|
||||
return; //Leeres Inventar
|
||||
|
||||
int counter = 0;
|
||||
for(CompoundTag item : items){
|
||||
if(!item.containsKey("id")){
|
||||
result.defunctNbt(Material.getMaterial(blockId).name());
|
||||
continue;
|
||||
}
|
||||
|
||||
String materialName = item.getString("id");
|
||||
if(materialName.contains(":"))
|
||||
materialName = materialName.split(":")[1];
|
||||
materialName = materialName.toUpperCase().replace("SHOVEL", "SPADE");
|
||||
Material itemType = Material.getMaterial(materialName);
|
||||
if(itemType == null && item.getString("id").equals("minecraft:fire_charge"))
|
||||
itemType = Material.FIREBALL;
|
||||
if(itemType == null) //Leere Slots
|
||||
continue;
|
||||
|
||||
if(blockId == DISPENSER && (itemType.equals(Material.FIREBALL) || itemType.equals(Material.ARROW)))
|
||||
counter += item.getByte("Count");
|
||||
else if(!FLOWERS.contains(itemType) && !(blockId == CHEST && itemType.equals(Material.TNT)))
|
||||
result.foundForbiddenItem(Material.getMaterial(blockId).name(), itemType.name(), item.getByte("Count"));
|
||||
else if(item.containsKey("tag"))
|
||||
result.foundItemWithTag(Material.getMaterial(blockId).name(), itemType.name(), item.getByte("Count"));
|
||||
}
|
||||
|
||||
result.dispenserItems(counter);
|
||||
}
|
||||
}
|
56
SchematicSystem_15/build.gradle
Normale Datei
56
SchematicSystem_15/build.gradle
Normale Datei
@ -0,0 +1,56 @@
|
||||
/*
|
||||
* This file is a part of the SteamWar software.
|
||||
*
|
||||
* Copyright (C) 2021 SteamWar.de-Serverteam
|
||||
*
|
||||
* This program is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU Affero General Public License as published by
|
||||
* the Free Software Foundation, either version 3 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 Affero General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU Affero General Public License
|
||||
* along with this program. If not, see <https://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
plugins {
|
||||
id 'base'
|
||||
id 'java'
|
||||
}
|
||||
|
||||
group 'steamwar'
|
||||
version '1.0'
|
||||
|
||||
compileJava.options.encoding = 'UTF-8'
|
||||
|
||||
sourceCompatibility = 1.8
|
||||
targetCompatibility = 1.8
|
||||
|
||||
sourceSets {
|
||||
main {
|
||||
java {
|
||||
srcDirs = ['src/']
|
||||
}
|
||||
resources {
|
||||
srcDirs = ['src/']
|
||||
exclude '**/*.java', '**/*.kt'
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
dependencies {
|
||||
compileOnly 'org.projectlombok:lombok:1.18.22'
|
||||
testCompileOnly 'org.projectlombok:lombok:1.18.22'
|
||||
annotationProcessor 'org.projectlombok:lombok:1.18.22'
|
||||
testAnnotationProcessor 'org.projectlombok:lombok:1.18.22'
|
||||
|
||||
implementation project(":SchematicSystem_Core")
|
||||
|
||||
compileOnly swdep("Spigot-1.15")
|
||||
compileOnly swdep("WorldEdit-1.15")
|
||||
compileOnly swdep("SpigotCore")
|
||||
}
|
@ -1,54 +0,0 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<project xmlns="http://maven.apache.org/POM/4.0.0"
|
||||
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
|
||||
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
|
||||
<modelVersion>4.0.0</modelVersion>
|
||||
|
||||
<artifactId>SchematicSystem_15</artifactId>
|
||||
<version>1.0</version>
|
||||
|
||||
<parent>
|
||||
<groupId>steamwar</groupId>
|
||||
<artifactId>SchematicSystem</artifactId>
|
||||
<version>1.0</version>
|
||||
</parent>
|
||||
|
||||
<properties>
|
||||
<main.basedir>${project.basedir}/..</main.basedir>
|
||||
</properties>
|
||||
|
||||
<build>
|
||||
<sourceDirectory>src</sourceDirectory>
|
||||
<resources>
|
||||
<resource>
|
||||
<directory>src</directory>
|
||||
<excludes>
|
||||
<exclude>**/*.java</exclude>
|
||||
<exclude>**/*.kt</exclude>
|
||||
</excludes>
|
||||
</resource>
|
||||
</resources>
|
||||
</build>
|
||||
|
||||
<dependencies>
|
||||
<dependency>
|
||||
<groupId>steamwar</groupId>
|
||||
<artifactId>SchematicSystem_API</artifactId>
|
||||
<version>1.0</version>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>steamwar</groupId>
|
||||
<artifactId>Spigot</artifactId>
|
||||
<version>1.15</version>
|
||||
<scope>system</scope>
|
||||
<systemPath>${main.basedir}/lib/Spigot-1.15.jar</systemPath>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>steamwar</groupId>
|
||||
<artifactId>WorldEdit</artifactId>
|
||||
<version>1.15</version>
|
||||
<scope>system</scope>
|
||||
<systemPath>${main.basedir}/lib/WorldEdit-1.15.jar</systemPath>
|
||||
</dependency>
|
||||
</dependencies>
|
||||
</project>
|
@ -1,188 +0,0 @@
|
||||
/*
|
||||
This file is a part of the SteamWar software.
|
||||
|
||||
Copyright (C) 2020 SteamWar.de-Serverteam
|
||||
|
||||
This program is free software: you can redistribute it and/or modify
|
||||
it under the terms of the GNU Affero General Public License as published by
|
||||
the Free Software Foundation, either version 3 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 Affero General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU Affero General Public License
|
||||
along with this program. If not, see <https://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
package de.steamwar.schematicsystem;
|
||||
|
||||
import com.sk89q.jnbt.CompoundTag;
|
||||
import com.sk89q.worldedit.extent.clipboard.Clipboard;
|
||||
import com.sk89q.worldedit.math.BlockVector3;
|
||||
import com.sk89q.worldedit.regions.Region;
|
||||
import com.sk89q.worldedit.world.block.BaseBlock;
|
||||
import de.steamwar.sql.NoClipboardException;
|
||||
import de.steamwar.sql.Schematic;
|
||||
import org.bukkit.Bukkit;
|
||||
import org.bukkit.Material;
|
||||
|
||||
import java.io.IOException;
|
||||
import java.util.EnumSet;
|
||||
import java.util.List;
|
||||
import java.util.Set;
|
||||
import java.util.logging.Level;
|
||||
|
||||
class CheckSchemType_15 {
|
||||
private static final Set<Material> INVENTORY = EnumSet.of(
|
||||
Material.BARREL,
|
||||
Material.BLAST_FURNACE,
|
||||
Material.BREWING_STAND,
|
||||
Material.CAMPFIRE,
|
||||
Material.CHEST,
|
||||
Material.DISPENSER,
|
||||
Material.DROPPER,
|
||||
Material.FURNACE,
|
||||
Material.HOPPER,
|
||||
Material.JUKEBOX,
|
||||
Material.SHULKER_BOX,
|
||||
Material.WHITE_SHULKER_BOX,
|
||||
Material.ORANGE_SHULKER_BOX,
|
||||
Material.MAGENTA_SHULKER_BOX,
|
||||
Material.LIGHT_BLUE_SHULKER_BOX,
|
||||
Material.YELLOW_SHULKER_BOX,
|
||||
Material.LIME_SHULKER_BOX,
|
||||
Material.PINK_SHULKER_BOX,
|
||||
Material.GRAY_SHULKER_BOX,
|
||||
Material.LIGHT_GRAY_SHULKER_BOX,
|
||||
Material.CYAN_SHULKER_BOX,
|
||||
Material.PURPLE_SHULKER_BOX,
|
||||
Material.BLUE_SHULKER_BOX,
|
||||
Material.BROWN_SHULKER_BOX,
|
||||
Material.GREEN_SHULKER_BOX,
|
||||
Material.RED_SHULKER_BOX,
|
||||
Material.BLACK_SHULKER_BOX,
|
||||
Material.SMOKER,
|
||||
Material.TRAPPED_CHEST);
|
||||
|
||||
private static final Set<Material> FLOWERS = EnumSet.of(
|
||||
Material.CORNFLOWER,
|
||||
Material.POPPY,
|
||||
Material.FERN,
|
||||
Material.DANDELION,
|
||||
Material.BLUE_ORCHID,
|
||||
Material.ALLIUM,
|
||||
Material.AZURE_BLUET,
|
||||
Material.RED_TULIP,
|
||||
Material.ORANGE_TULIP,
|
||||
Material.WHITE_TULIP,
|
||||
Material.PINK_TULIP,
|
||||
Material.OXEYE_DAISY,
|
||||
Material.CORNFLOWER,
|
||||
Material.LILY_OF_THE_VALLEY,
|
||||
Material.WITHER_ROSE,
|
||||
Material.SUNFLOWER);
|
||||
|
||||
private CheckSchemType_15(){}
|
||||
|
||||
static AutoCheckResult autoCheck(Schematic schematic, ICheckSchemType type) {
|
||||
AutoCheckResult result = new AutoCheckResult(type);
|
||||
Clipboard clipboard;
|
||||
try {
|
||||
clipboard = schematic.load();
|
||||
} catch (IOException | NoClipboardException e) {
|
||||
result.setErrorLoadingSchematic();
|
||||
Bukkit.getLogger().log(Level.SEVERE, "Schematic could not be loaded", e);
|
||||
return result;
|
||||
}
|
||||
|
||||
BlockVector3 dimensions = clipboard.getDimensions();
|
||||
result.setLength(dimensions.getBlockX());
|
||||
result.setHeight(dimensions.getBlockY());
|
||||
result.setWidth(dimensions.getBlockZ());
|
||||
|
||||
Region region = clipboard.getRegion();
|
||||
BlockVector3 min = region.getMinimumPoint();
|
||||
BlockVector3 max = region.getMaximumPoint();
|
||||
|
||||
int tnt = 0;
|
||||
int slime = 0;
|
||||
int dispenser = 0;
|
||||
int blocks = 0;
|
||||
|
||||
for(int x = min.getBlockX(); x <= max.getBlockX(); x++){
|
||||
for(int y = min.getBlockY(); y <= max.getBlockY(); y++){
|
||||
for(int z = min.getBlockZ(); z <= max.getBlockZ(); z++){
|
||||
final BaseBlock block = clipboard.getFullBlock(BlockVector3.at(x, y, z));
|
||||
final Material blockMaterial = Material.matchMaterial(block.getBlockType().getId());
|
||||
if(blockMaterial == null)
|
||||
continue;
|
||||
|
||||
result.checkMaterial(blockMaterial.name());
|
||||
|
||||
if(blockMaterial == Material.TNT || blockMaterial == Material.OBSIDIAN)
|
||||
tnt++;
|
||||
|
||||
if(blockMaterial == Material.SLIME_BLOCK || blockMaterial == Material.HONEY_BLOCK || blockMaterial == Material.BEDROCK)
|
||||
slime++;
|
||||
|
||||
if(blockMaterial == Material.DISPENSER)
|
||||
dispenser++;
|
||||
|
||||
if(blockMaterial != Material.AIR)
|
||||
blocks++;
|
||||
|
||||
if(INVENTORY.contains(blockMaterial))
|
||||
checkInventory(result, block, blockMaterial);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
result.setTNT(tnt);
|
||||
result.setSlime(slime);
|
||||
result.setDispenser(dispenser);
|
||||
result.setBlocks(blocks);
|
||||
|
||||
return result;
|
||||
}
|
||||
|
||||
private static void checkInventory(AutoCheckResult result, BaseBlock block, Material blockMaterial){
|
||||
CompoundTag nbt = block.getNbtData();
|
||||
if(nbt == null){
|
||||
result.defunctNbt(blockMaterial.name());
|
||||
return;
|
||||
}
|
||||
|
||||
if(blockMaterial == Material.JUKEBOX && nbt.getValue().containsKey("RecordItem")){
|
||||
result.foundRecord();
|
||||
return;
|
||||
}
|
||||
|
||||
List<CompoundTag> items = nbt.getList("Items", CompoundTag.class);
|
||||
if(items.isEmpty())
|
||||
return; //Leeres Inventar
|
||||
|
||||
int counter = 0;
|
||||
for(CompoundTag item : items){
|
||||
if(!item.containsKey("id")){
|
||||
result.defunctNbt(blockMaterial.name());
|
||||
continue;
|
||||
}
|
||||
|
||||
Material itemType = Material.matchMaterial(item.getString("id"));
|
||||
if(itemType == null) //Leere Slots
|
||||
continue;
|
||||
|
||||
if(blockMaterial == Material.DISPENSER && (itemType.equals(Material.FIRE_CHARGE) || itemType.equals(Material.ARROW)))
|
||||
counter += item.getByte("Count");
|
||||
else if(!FLOWERS.contains(itemType) && !(blockMaterial == Material.CHEST && itemType.equals(Material.TNT)))
|
||||
result.foundForbiddenItem(blockMaterial.name(), itemType.name(), item.getByte("Count"));
|
||||
else if(item.containsKey("tag"))
|
||||
result.foundItemWithTag(blockMaterial.name(), itemType.name(), item.getByte("Count"));
|
||||
}
|
||||
|
||||
result.dispenserItems(counter);
|
||||
}
|
||||
}
|
@ -0,0 +1,185 @@
|
||||
/*
|
||||
This file is a part of the SteamWar software.
|
||||
|
||||
Copyright (C) 2023 SteamWar.de-Serverteam
|
||||
|
||||
This program is free software: you can redistribute it and/or modify
|
||||
it under the terms of the GNU Affero General Public License as published by
|
||||
the Free Software Foundation, either version 3 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 Affero General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU Affero General Public License
|
||||
along with this program. If not, see <https://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
package de.steamwar.schematicsystem.autocheck;
|
||||
|
||||
import com.sk89q.jnbt.CompoundTag;
|
||||
import com.sk89q.worldedit.entity.Entity;
|
||||
import com.sk89q.worldedit.extent.clipboard.Clipboard;
|
||||
import com.sk89q.worldedit.math.BlockVector3;
|
||||
import com.sk89q.worldedit.world.block.BaseBlock;
|
||||
import de.steamwar.schematicsystem.CheckSchemType;
|
||||
import org.bukkit.Material;
|
||||
|
||||
import java.util.*;
|
||||
import java.util.stream.Collectors;
|
||||
|
||||
public class AutoChecker15 implements AutoChecker.IAutoChecker {
|
||||
private static final Set<Material> INVENTORY = EnumSet.of(
|
||||
Material.BARREL,
|
||||
Material.BLAST_FURNACE,
|
||||
Material.BREWING_STAND,
|
||||
Material.CAMPFIRE,
|
||||
Material.CHEST,
|
||||
Material.DISPENSER,
|
||||
Material.DROPPER,
|
||||
Material.FURNACE,
|
||||
Material.HOPPER,
|
||||
Material.JUKEBOX,
|
||||
Material.SHULKER_BOX,
|
||||
Material.WHITE_SHULKER_BOX,
|
||||
Material.ORANGE_SHULKER_BOX,
|
||||
Material.MAGENTA_SHULKER_BOX,
|
||||
Material.LIGHT_BLUE_SHULKER_BOX,
|
||||
Material.YELLOW_SHULKER_BOX,
|
||||
Material.LIME_SHULKER_BOX,
|
||||
Material.PINK_SHULKER_BOX,
|
||||
Material.GRAY_SHULKER_BOX,
|
||||
Material.LIGHT_GRAY_SHULKER_BOX,
|
||||
Material.CYAN_SHULKER_BOX,
|
||||
Material.PURPLE_SHULKER_BOX,
|
||||
Material.BLUE_SHULKER_BOX,
|
||||
Material.BROWN_SHULKER_BOX,
|
||||
Material.GREEN_SHULKER_BOX,
|
||||
Material.RED_SHULKER_BOX,
|
||||
Material.BLACK_SHULKER_BOX,
|
||||
Material.SMOKER,
|
||||
Material.TRAPPED_CHEST);
|
||||
|
||||
private static final Set<Material> FLOWERS = EnumSet.of(
|
||||
Material.CORNFLOWER,
|
||||
Material.POPPY,
|
||||
Material.FERN,
|
||||
Material.DANDELION,
|
||||
Material.BLUE_ORCHID,
|
||||
Material.ALLIUM,
|
||||
Material.AZURE_BLUET,
|
||||
Material.RED_TULIP,
|
||||
Material.ORANGE_TULIP,
|
||||
Material.WHITE_TULIP,
|
||||
Material.PINK_TULIP,
|
||||
Material.OXEYE_DAISY,
|
||||
Material.LILY_OF_THE_VALLEY,
|
||||
Material.WITHER_ROSE,
|
||||
Material.SUNFLOWER,
|
||||
Material.DIAMOND_HORSE_ARMOR,
|
||||
Material.IRON_HORSE_ARMOR,
|
||||
Material.GOLDEN_HORSE_ARMOR,
|
||||
Material.HONEY_BOTTLE);
|
||||
|
||||
public AutoChecker.BlockScanResult scan(Clipboard clipboard) {
|
||||
AutoChecker.BlockScanResult result = new AutoChecker.BlockScanResult();
|
||||
BlockVector3 min = clipboard.getMinimumPoint();
|
||||
BlockVector3 max = clipboard.getMaximumPoint();
|
||||
for(int x = min.getBlockX(); x <= max.getBlockX(); x++){
|
||||
for(int y = min.getBlockY(); y <= max.getBlockY(); y++) {
|
||||
for (int z = min.getBlockZ(); z <= max.getBlockZ(); z++) {
|
||||
final BaseBlock block = clipboard.getFullBlock(BlockVector3.at(x, y, z));
|
||||
final Material material = Material.matchMaterial(block.getBlockType().getId());
|
||||
if(material == null) {
|
||||
continue;
|
||||
}
|
||||
|
||||
result.getBlockCounts().merge(material, 1, Integer::sum);
|
||||
|
||||
if(INVENTORY.contains(material)) {
|
||||
checkInventory(result, block, material, new BlockPos(x, y, z));
|
||||
}
|
||||
|
||||
if(x == 0 || x == max.getBlockX() - 1 || y == max.getBlockY() - 1 || z == 0 || z == max.getBlockZ() - 1) {
|
||||
result.getDesignBlocks().computeIfAbsent(material, m -> new ArrayList<>()).add(new BlockPos(x, y, z));
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
return result;
|
||||
}
|
||||
|
||||
private static final Map<Material, Set<Material>> itemsInInv = new EnumMap<>(Material.class);
|
||||
|
||||
static {
|
||||
itemsInInv.put(Material.BUCKET, EnumSet.of(Material.DISPENSER));
|
||||
itemsInInv.put(Material.TNT, EnumSet.of(Material.CHEST, Material.BARREL));
|
||||
itemsInInv.put(Material.FIRE_CHARGE, EnumSet.of(Material.DISPENSER));
|
||||
itemsInInv.put(Material.ARROW, EnumSet.of(Material.DISPENSER));
|
||||
FLOWERS.forEach(material -> itemsInInv.put(material, INVENTORY));
|
||||
}
|
||||
|
||||
private void checkInventory(AutoChecker.BlockScanResult result, BaseBlock block, Material material, BlockPos pos) {
|
||||
CompoundTag nbt = block.getNbtData();
|
||||
if(nbt == null) {
|
||||
result.getDefunctNbt().add(pos);
|
||||
return;
|
||||
}
|
||||
|
||||
|
||||
if(material == Material.JUKEBOX && nbt.getValue().containsKey("RecordItem")){
|
||||
result.getRecords().add(pos);
|
||||
return;
|
||||
}
|
||||
|
||||
List<CompoundTag> items = nbt.getList("Items", CompoundTag.class);
|
||||
if(items.isEmpty())
|
||||
return; //Leeres Inventar
|
||||
|
||||
int counter = 0;
|
||||
for(CompoundTag item : items){
|
||||
if(!item.containsKey("id")){
|
||||
result.getDefunctNbt().add(pos);
|
||||
continue;
|
||||
}
|
||||
|
||||
Material itemType = Material.matchMaterial(item.getString("id"));
|
||||
if(itemType == null) //Leere Slots
|
||||
continue;
|
||||
|
||||
if (!itemsInInv.getOrDefault(itemType, EnumSet.noneOf(Material.class)).contains(material)) {
|
||||
result.getForbiddenItems().computeIfAbsent(pos, blockVector3 -> new HashSet<>()).add(itemType);
|
||||
} else if(material == Material.DISPENSER && (itemType == Material.ARROW || itemType == Material.FIRE_CHARGE)) {
|
||||
counter += item.getByte("Count");
|
||||
}
|
||||
if (item.containsKey("tag")) {
|
||||
result.getForbiddenNbt().computeIfAbsent(pos, blockVector3 -> new HashSet<>()).add(itemType);
|
||||
}
|
||||
}
|
||||
result.getDispenserItems().put(pos, counter);
|
||||
}
|
||||
|
||||
@Override
|
||||
public AutoCheckerResult check(Clipboard clipboard, CheckSchemType type) {
|
||||
return AutoCheckerResult.builder()
|
||||
.type(type)
|
||||
.height(clipboard.getDimensions().getBlockY())
|
||||
.width(clipboard.getDimensions().getBlockX())
|
||||
.depth(clipboard.getDimensions().getBlockZ())
|
||||
.blockScanResult(scan(clipboard))
|
||||
.entities(clipboard.getEntities().stream().map(Entity::getLocation).map(blockVector3 -> new BlockPos(blockVector3.getBlockX(), blockVector3.getBlockY(), blockVector3.getBlockZ())).collect(Collectors.toList()))
|
||||
.build();
|
||||
}
|
||||
|
||||
@Override
|
||||
public AutoCheckerResult sizeCheck(Clipboard clipboard, CheckSchemType type) {
|
||||
return AutoCheckerResult.builder()
|
||||
.type(type)
|
||||
.height(clipboard.getDimensions().getBlockY())
|
||||
.width(clipboard.getDimensions().getBlockX())
|
||||
.depth(clipboard.getDimensions().getBlockZ())
|
||||
.build();
|
||||
}
|
||||
}
|
@ -0,0 +1,148 @@
|
||||
/*
|
||||
This file is a part of the SteamWar software.
|
||||
|
||||
Copyright (C) 2023 SteamWar.de-Serverteam
|
||||
|
||||
This program is free software: you can redistribute it and/or modify
|
||||
it under the terms of the GNU Affero General Public License as published by
|
||||
the Free Software Foundation, either version 3 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 Affero General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU Affero General Public License
|
||||
along with this program. If not, see <https://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
package de.steamwar.schematicsystem.commands.schematiccommand;
|
||||
|
||||
import com.sk89q.jnbt.CompoundTag;
|
||||
import com.sk89q.jnbt.CompoundTagBuilder;
|
||||
import com.sk89q.jnbt.ListTag;
|
||||
import com.sk89q.worldedit.EditSession;
|
||||
import com.sk89q.worldedit.WorldEditException;
|
||||
import com.sk89q.worldedit.extent.clipboard.Clipboard;
|
||||
import com.sk89q.worldedit.function.operation.ForwardExtentCopy;
|
||||
import com.sk89q.worldedit.function.operation.Operations;
|
||||
import com.sk89q.worldedit.math.BlockVector3;
|
||||
import com.sk89q.worldedit.world.block.BaseBlock;
|
||||
import com.sk89q.worldedit.world.block.BlockState;
|
||||
import com.sk89q.worldedit.world.block.BlockTypes;
|
||||
import de.steamwar.schematicsystem.CheckSchemType;
|
||||
import de.steamwar.schematicsystem.autocheck.AutoCheckerResult;
|
||||
import de.steamwar.schematicsystem.autocheck.BlockPos;
|
||||
import de.steamwar.schematicsystem.commands.schematiccommand.SchematicCommand;
|
||||
import org.bukkit.Material;
|
||||
|
||||
import java.util.*;
|
||||
import java.util.stream.Collectors;
|
||||
|
||||
public class SchematicCommand15 implements SchematicCommand.ISchematicCommand {
|
||||
@Override
|
||||
public Clipboard fixClipboard(Clipboard clipboard, AutoCheckerResult result, CheckSchemType type) throws Exception {
|
||||
for (BlockPos blockPos : result.getBlockScanResult().getRecords()) {
|
||||
BlockVector3 vector = BlockVector3.at(blockPos.getX(), blockPos.getY(), blockPos.getZ());
|
||||
clipboard.setBlock(vector, clipboard.getFullBlock(vector).toBaseBlock(new CompoundTag(Collections.emptyMap())));
|
||||
}
|
||||
|
||||
Map<BlockPos, Set<Material>> toBeCheckedInvs = new HashMap<>();
|
||||
|
||||
toBeCheckedInvs.putAll(result.getBlockScanResult().getForbiddenItems());
|
||||
toBeCheckedInvs.putAll(result.getBlockScanResult().getForbiddenNbt());
|
||||
|
||||
for (Map.Entry<BlockPos, Set<Material>> entry: toBeCheckedInvs.entrySet()) {
|
||||
BlockPos pos = entry.getKey();
|
||||
Set<Material> materials = entry.getValue();
|
||||
BlockVector3 vector = BlockVector3.at(pos.getX(), pos.getY(), pos.getZ());
|
||||
BaseBlock block = clipboard.getFullBlock(vector);
|
||||
CompoundTag tag = block.getNbtData();
|
||||
CompoundTagBuilder builder = CompoundTagBuilder.create();
|
||||
List<CompoundTag> list = new ArrayList<>();
|
||||
for (CompoundTag items : tag.getList("Items", CompoundTag.class)) {
|
||||
if(materials.contains(Material.matchMaterial(items.getString("id")))) {
|
||||
continue;
|
||||
}
|
||||
|
||||
if(items.containsKey("tag")) {
|
||||
continue;
|
||||
}
|
||||
|
||||
list.add(items);
|
||||
}
|
||||
builder.put("Items", new ListTag(CompoundTag.class, list));
|
||||
clipboard.setBlock(vector, block.toBaseBlock(builder.build()));
|
||||
}
|
||||
|
||||
if(type.getMaxDispenserItems() > 0 ) {
|
||||
for (Map.Entry<BlockPos, Integer> entry : result.getBlockScanResult().getDispenserItems().entrySet()) {
|
||||
if(entry.getValue() <= type.getMaxDispenserItems()) {
|
||||
continue;
|
||||
}
|
||||
|
||||
BlockPos pos = entry.getKey();
|
||||
BlockVector3 vector = BlockVector3.at(pos.getX(), pos.getY(), pos.getZ());
|
||||
BaseBlock block = clipboard.getFullBlock(vector);
|
||||
CompoundTag tag = block.getNbtData();
|
||||
CompoundTagBuilder builder = tag.createBuilder();
|
||||
List<CompoundTag> items = tag.getList("Items", CompoundTag.class);
|
||||
Collections.reverse(items); // To let the first item be in the Dispenser
|
||||
List<CompoundTag> list = new ArrayList<>();
|
||||
int diff = entry.getValue() - type.getMaxDispenserItems();
|
||||
for (CompoundTag item : items) {
|
||||
if(item == null) {
|
||||
continue;
|
||||
}
|
||||
|
||||
if(diff == 0) {
|
||||
list.add(item);
|
||||
continue;
|
||||
}
|
||||
|
||||
if(diff > item.getByte("Count")) {
|
||||
diff -= item.getByte("Count");
|
||||
continue;
|
||||
}
|
||||
|
||||
item = item.createBuilder().putByte("Count", (byte) (item.getByte("Count") - diff)).build();
|
||||
diff = 0;
|
||||
list.add(item);
|
||||
}
|
||||
|
||||
builder.put("Items", new ListTag(CompoundTag.class, list));
|
||||
clipboard.setBlock(vector, block.toBaseBlock(builder.build()));
|
||||
}
|
||||
}
|
||||
|
||||
if(!result.isLimitedBlocksOK()) {
|
||||
Set<Material> toReplace = type.getLimits().entrySet().stream()
|
||||
.filter(setIntegerEntry -> setIntegerEntry.getValue() == 0)
|
||||
.flatMap(setIntegerEntry -> setIntegerEntry.getKey().stream())
|
||||
.map(Material::matchMaterial)
|
||||
.collect(Collectors.toSet());
|
||||
BlockState replaceType = Objects.requireNonNull(toReplace.contains(Material.END_STONE) ? BlockTypes.IRON_BLOCK : BlockTypes.END_STONE).getDefaultState();
|
||||
BlockVector3 min = clipboard.getMinimumPoint();
|
||||
BlockVector3 max = clipboard.getMaximumPoint();
|
||||
for (int i = min.getBlockX(); i <= max.getBlockX(); i++) {
|
||||
for (int j = min.getBlockY(); j <= max.getBlockY(); j++) {
|
||||
for (int k = min.getBlockZ(); k <= max.getBlockZ(); k++) {
|
||||
BlockVector3 vector = BlockVector3.at(i, j, k);
|
||||
BaseBlock block = clipboard.getFullBlock(vector);
|
||||
if(toReplace.contains(Material.matchMaterial(block.getBlockType().getId()))) {
|
||||
clipboard.setBlock(vector, replaceType.toBaseBlock());
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return clipboard;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void createCopy(EditSession editSession, Clipboard clipboard) throws WorldEditException {
|
||||
Operations.complete(new ForwardExtentCopy(editSession, clipboard.getRegion(), clipboard, clipboard.getMinimumPoint()));
|
||||
}
|
||||
}
|
56
SchematicSystem_8/build.gradle
Normale Datei
56
SchematicSystem_8/build.gradle
Normale Datei
@ -0,0 +1,56 @@
|
||||
/*
|
||||
* This file is a part of the SteamWar software.
|
||||
*
|
||||
* Copyright (C) 2021 SteamWar.de-Serverteam
|
||||
*
|
||||
* This program is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU Affero General Public License as published by
|
||||
* the Free Software Foundation, either version 3 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 Affero General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU Affero General Public License
|
||||
* along with this program. If not, see <https://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
plugins {
|
||||
id 'base'
|
||||
id 'java'
|
||||
}
|
||||
|
||||
group 'steamwar'
|
||||
version '1.0'
|
||||
|
||||
compileJava.options.encoding = 'UTF-8'
|
||||
|
||||
sourceCompatibility = 1.8
|
||||
targetCompatibility = 1.8
|
||||
|
||||
sourceSets {
|
||||
main {
|
||||
java {
|
||||
srcDirs = ['src/']
|
||||
}
|
||||
resources {
|
||||
srcDirs = ['src/']
|
||||
exclude '**/*.java', '**/*.kt'
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
dependencies {
|
||||
compileOnly 'org.projectlombok:lombok:1.18.22'
|
||||
testCompileOnly 'org.projectlombok:lombok:1.18.22'
|
||||
annotationProcessor 'org.projectlombok:lombok:1.18.22'
|
||||
testAnnotationProcessor 'org.projectlombok:lombok:1.18.22'
|
||||
|
||||
implementation project(":SchematicSystem_Core")
|
||||
|
||||
compileOnly swdep("Spigot-1.8")
|
||||
compileOnly swdep("WorldEdit-1.12")
|
||||
compileOnly swdep("SpigotCore")
|
||||
}
|
20
SchematicSystem_8/settings.gradle
Normale Datei
20
SchematicSystem_8/settings.gradle
Normale Datei
@ -0,0 +1,20 @@
|
||||
/*
|
||||
* This file is a part of the SteamWar software.
|
||||
*
|
||||
* Copyright (C) 2020 SteamWar.de-Serverteam
|
||||
*
|
||||
* This program is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU Affero General Public License as published by
|
||||
* the Free Software Foundation, either version 3 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 Affero General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU Affero General Public License
|
||||
* along with this program. If not, see <https://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
rootProject.name = 'SchematicSystem_8'
|
@ -0,0 +1,174 @@
|
||||
/*
|
||||
This file is a part of the SteamWar software.
|
||||
|
||||
Copyright (C) 2023 SteamWar.de-Serverteam
|
||||
|
||||
This program is free software: you can redistribute it and/or modify
|
||||
it under the terms of the GNU Affero General Public License as published by
|
||||
the Free Software Foundation, either version 3 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 Affero General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU Affero General Public License
|
||||
along with this program. If not, see <https://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
package de.steamwar.schematicsystem.autocheck;
|
||||
|
||||
import com.sk89q.jnbt.CompoundTag;
|
||||
import com.sk89q.worldedit.Vector;
|
||||
import com.sk89q.worldedit.blocks.BaseBlock;
|
||||
import com.sk89q.worldedit.entity.Entity;
|
||||
import com.sk89q.worldedit.extent.clipboard.Clipboard;
|
||||
import com.sk89q.worldedit.regions.Region;
|
||||
import de.steamwar.schematicsystem.CheckSchemType;
|
||||
import org.bukkit.Material;
|
||||
|
||||
import java.util.*;
|
||||
import java.util.stream.Collectors;
|
||||
|
||||
@SuppressWarnings("deprecation")
|
||||
public class AutoChecker8 implements AutoChecker.IAutoChecker {
|
||||
private static final int DISPENSER = Material.DISPENSER.getId();
|
||||
private static final int JUKEBOX = Material.JUKEBOX.getId();
|
||||
private static final int CHEST = Material.CHEST.getId();
|
||||
private static final Set<Integer> INVENTORY = new HashSet<>();
|
||||
private static final Set<Material> FLOWERS;
|
||||
|
||||
static{
|
||||
INVENTORY.add(CHEST);
|
||||
INVENTORY.add(Material.TRAPPED_CHEST.getId());
|
||||
INVENTORY.add(Material.HOPPER.getId());
|
||||
INVENTORY.add(Material.FURNACE.getId());
|
||||
INVENTORY.add(Material.BURNING_FURNACE.getId());
|
||||
INVENTORY.add(JUKEBOX); //RecordItem
|
||||
INVENTORY.add(DISPENSER);
|
||||
INVENTORY.add(Material.DROPPER.getId());
|
||||
INVENTORY.add(Material.ANVIL.getId());
|
||||
INVENTORY.add(Material.BREWING_STAND.getId());
|
||||
for(int i = 219; i <= 234; i++) {
|
||||
INVENTORY.add(i); // ShulkerBoxes
|
||||
}
|
||||
|
||||
Set<Material> flowers = new HashSet<>();
|
||||
flowers.add(Material.YELLOW_FLOWER);
|
||||
flowers.add(Material.RED_ROSE);
|
||||
flowers.add(Material.DOUBLE_PLANT);
|
||||
flowers.add(Material.DIAMOND_BARDING);
|
||||
flowers.add(Material.IRON_BARDING);
|
||||
flowers.add(Material.GOLD_BARDING);
|
||||
FLOWERS = flowers;
|
||||
}
|
||||
|
||||
public void scan(AutoChecker.BlockScanResult result, Clipboard clipboard) {
|
||||
Region region = clipboard.getRegion();
|
||||
Vector min = region.getMinimumPoint();
|
||||
Vector max = region.getMaximumPoint();
|
||||
|
||||
for(int x = min.getBlockX(); x <= max.getBlockX(); x++){
|
||||
for(int y = min.getBlockY(); y <= max.getBlockY(); y++){
|
||||
for(int z = min.getBlockZ(); z <= max.getBlockZ(); z++){
|
||||
final BaseBlock block = clipboard.getBlock(new Vector(x, y, z));
|
||||
final int blockId = block.getId();
|
||||
final Material material = Material.getMaterial(blockId);
|
||||
|
||||
result.getBlockCounts().merge(material, 1, Integer::sum);
|
||||
|
||||
if(INVENTORY.contains(blockId)){
|
||||
checkInventory(result, block, blockId, new BlockPos(x, y, z));
|
||||
}
|
||||
|
||||
if(x == 0 || x == max.getBlockX() - 1 || y == max.getBlockY() - 1 || z == 0 || z == max.getBlockZ() - 1) {
|
||||
result.getDesignBlocks().computeIfAbsent(material, m -> new ArrayList<>()).add(new BlockPos(x, y, z));
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private static final Map<Material, EnumSet<Material>> itemsInInv = new EnumMap<>(Material.class);
|
||||
|
||||
static {
|
||||
itemsInInv.put(Material.BUCKET, EnumSet.of(Material.DISPENSER));
|
||||
itemsInInv.put(Material.TNT, EnumSet.of(Material.CHEST));
|
||||
itemsInInv.put(Material.FIREBALL, EnumSet.of(Material.DISPENSER));
|
||||
itemsInInv.put(Material.ARROW, EnumSet.of(Material.DISPENSER));
|
||||
FLOWERS.forEach(material -> itemsInInv.put(material, INVENTORY.stream().map(Material::getMaterial).collect(Collectors.toCollection(() -> EnumSet.noneOf(Material.class)))));
|
||||
}
|
||||
|
||||
private static void checkInventory(AutoChecker.BlockScanResult result, BaseBlock block, int blockId, BlockPos pos) {
|
||||
CompoundTag nbt = block.getNbtData();
|
||||
if(nbt == null){
|
||||
result.getDefunctNbt().add(pos);
|
||||
return;
|
||||
}
|
||||
|
||||
if(blockId == JUKEBOX && nbt.getValue().containsKey("RecordItem")){
|
||||
result.getRecords().add(pos);
|
||||
return;
|
||||
}
|
||||
|
||||
List<CompoundTag> items = nbt.getList("Items", CompoundTag.class);
|
||||
if(items.isEmpty())
|
||||
return; //Leeres Inventar
|
||||
|
||||
int counter = 0;
|
||||
for(CompoundTag item : items){
|
||||
if(!item.containsKey("id")){
|
||||
result.getDefunctNbt().add(pos);
|
||||
continue;
|
||||
}
|
||||
|
||||
String materialName = item.getString("id");
|
||||
if(materialName.contains(":"))
|
||||
materialName = materialName.split(":")[1];
|
||||
materialName = materialName.toUpperCase().replace("SHOVEL", "SPADE");
|
||||
Material itemType = Material.getMaterial(materialName);
|
||||
if(itemType == null && item.getString("id").equals("minecraft:fire_charge"))
|
||||
itemType = Material.FIREBALL;
|
||||
if(itemType == null) //Leere Slots
|
||||
continue;
|
||||
|
||||
|
||||
if(!itemsInInv.getOrDefault(itemType, EnumSet.noneOf(Material.class)).contains(Material.getMaterial(blockId))) {
|
||||
result.getForbiddenItems().computeIfAbsent(pos, blockPos -> new HashSet<>()).add(Material.getMaterial(blockId));
|
||||
} else if(blockId == DISPENSER && (itemType.equals(Material.FIREBALL) || itemType.equals(Material.ARROW))) {
|
||||
counter += item.getByte("Count");
|
||||
}
|
||||
if(item.containsKey("tag")) {
|
||||
result.getForbiddenNbt().computeIfAbsent(pos, blockPos -> new HashSet<>()).add(Material.getMaterial(blockId));
|
||||
}
|
||||
}
|
||||
|
||||
result.getDispenserItems().put(pos, counter);
|
||||
}
|
||||
|
||||
@Override
|
||||
public AutoCheckerResult check(Clipboard clipboard, CheckSchemType type) {
|
||||
AutoChecker.BlockScanResult blockScanResult = new AutoChecker.BlockScanResult();
|
||||
scan(blockScanResult, clipboard);
|
||||
|
||||
return AutoCheckerResult.builder()
|
||||
.type(type)
|
||||
.height(clipboard.getDimensions().getBlockY())
|
||||
.width(clipboard.getDimensions().getBlockX())
|
||||
.depth(clipboard.getDimensions().getBlockZ())
|
||||
.blockScanResult(blockScanResult)
|
||||
.entities(clipboard.getEntities().stream().map(Entity::getLocation).map(blockVector3 -> new BlockPos(blockVector3.getBlockX(), blockVector3.getBlockY(), blockVector3.getBlockZ())).collect(Collectors.toList()))
|
||||
.build();
|
||||
}
|
||||
|
||||
@Override
|
||||
public AutoCheckerResult sizeCheck(Clipboard clipboard, CheckSchemType type) {
|
||||
return AutoCheckerResult.builder()
|
||||
.type(type)
|
||||
.height(clipboard.getDimensions().getBlockY())
|
||||
.width(clipboard.getDimensions().getBlockX())
|
||||
.depth(clipboard.getDimensions().getBlockZ())
|
||||
.build();
|
||||
}
|
||||
}
|
@ -0,0 +1,42 @@
|
||||
/*
|
||||
This file is a part of the SteamWar software.
|
||||
|
||||
Copyright (C) 2023 SteamWar.de-Serverteam
|
||||
|
||||
This program is free software: you can redistribute it and/or modify
|
||||
it under the terms of the GNU Affero General Public License as published by
|
||||
the Free Software Foundation, either version 3 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 Affero General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU Affero General Public License
|
||||
along with this program. If not, see <https://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
package de.steamwar.schematicsystem.commands.schematiccommand;
|
||||
|
||||
import com.sk89q.worldedit.EditSession;
|
||||
import com.sk89q.worldedit.WorldEditException;
|
||||
import com.sk89q.worldedit.extent.clipboard.Clipboard;
|
||||
import com.sk89q.worldedit.function.operation.ForwardExtentCopy;
|
||||
import com.sk89q.worldedit.function.operation.Operations;
|
||||
import de.steamwar.schematicsystem.CheckSchemType;
|
||||
import de.steamwar.schematicsystem.autocheck.AutoCheckerResult;
|
||||
import de.steamwar.schematicsystem.commands.schematiccommand.SchematicCommand;
|
||||
|
||||
public class SchematicCommand8 implements SchematicCommand.ISchematicCommand {
|
||||
|
||||
@Override
|
||||
public Clipboard fixClipboard(Clipboard clipboard, AutoCheckerResult result, CheckSchemType type) throws Exception {
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void createCopy(EditSession editSession, Clipboard clipboard) throws WorldEditException {
|
||||
Operations.complete(new ForwardExtentCopy(editSession, clipboard.getRegion(), clipboard, clipboard.getMinimumPoint()));
|
||||
}
|
||||
}
|
@ -1,42 +0,0 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<project xmlns="http://maven.apache.org/POM/4.0.0"
|
||||
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
|
||||
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
|
||||
<modelVersion>4.0.0</modelVersion>
|
||||
|
||||
<parent>
|
||||
<groupId>steamwar</groupId>
|
||||
<artifactId>SchematicSystem</artifactId>
|
||||
<version>1.0</version>
|
||||
</parent>
|
||||
|
||||
<properties>
|
||||
<main.basedir>${project.basedir}/..</main.basedir>
|
||||
</properties>
|
||||
|
||||
<artifactId>SchematicSystem_API</artifactId>
|
||||
<version>1.0</version>
|
||||
|
||||
<build>
|
||||
<sourceDirectory>src</sourceDirectory>
|
||||
<resources>
|
||||
<resource>
|
||||
<directory>src</directory>
|
||||
<excludes>
|
||||
<exclude>**/*.java</exclude>
|
||||
<exclude>**/*.kt</exclude>
|
||||
</excludes>
|
||||
</resource>
|
||||
</resources>
|
||||
</build>
|
||||
|
||||
<dependencies>
|
||||
<dependency>
|
||||
<groupId>steamwar</groupId>
|
||||
<artifactId>Spigot</artifactId>
|
||||
<version>1.12</version>
|
||||
<scope>system</scope>
|
||||
<systemPath>${main.basedir}/lib/Spigot-1.12.jar</systemPath>
|
||||
</dependency>
|
||||
</dependencies>
|
||||
</project>
|
@ -1,186 +0,0 @@
|
||||
/*
|
||||
This file is a part of the SteamWar software.
|
||||
|
||||
Copyright (C) 2020 SteamWar.de-Serverteam
|
||||
|
||||
This program is free software: you can redistribute it and/or modify
|
||||
it under the terms of the GNU Affero General Public License as published by
|
||||
the Free Software Foundation, either version 3 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 Affero General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU Affero General Public License
|
||||
along with this program. If not, see <https://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
package de.steamwar.schematicsystem;
|
||||
|
||||
import de.steamwar.core.Core;
|
||||
|
||||
import java.util.*;
|
||||
|
||||
public class AutoCheckResult {
|
||||
|
||||
private final ICheckSchemType type;
|
||||
|
||||
private final boolean noChecksInThisVersion;
|
||||
private boolean wrongVersionException = false; // Schematic nicht in der Version ladbar
|
||||
private boolean errorLoadingSchematic = false; // Schematic irgendwie invalide
|
||||
|
||||
private int width = 0;
|
||||
private int height = 0;
|
||||
private int length = 0;
|
||||
|
||||
private int tnt = 0;
|
||||
private int slime = 0;
|
||||
private int dispenser = 0;
|
||||
private int blocks = 0;
|
||||
|
||||
private Map<String, Integer> forbiddenMaterials = new HashMap<>(); // Anzahl verbotener Blöcke nach Material
|
||||
|
||||
private Map<String, Integer> defunctNbt = new HashMap<>(); // Anzahl an defekten NBT-Blöcken nach Materialname
|
||||
private int records = 0; // Gefundene Schallplatten
|
||||
private Map<String, Map<String, Integer>> forbiddenItems = new HashMap<>(); // Anzahl verbotener Items nach Inventartyp
|
||||
private Map<String, Map<String, Integer>> itemsWithTag = new HashMap<>(); // Anzahl an Items mit Tag nach Inventartyp
|
||||
private int tooManyDispenserItems = 0; // Gefundene Überschreitungen von DispenserItems
|
||||
|
||||
AutoCheckResult(ICheckSchemType type){
|
||||
this.type = type;
|
||||
noChecksInThisVersion = false;
|
||||
}
|
||||
|
||||
AutoCheckResult(){
|
||||
type = null;
|
||||
noChecksInThisVersion = true;
|
||||
}
|
||||
|
||||
public Collection<String> errors(){
|
||||
List<String> errors = new LinkedList<>();
|
||||
|
||||
if(noChecksInThisVersion){
|
||||
errors.add("In der 1." + Core.getVersion() + " können keine Schematics eingesendet werden");
|
||||
return errors;
|
||||
}
|
||||
if(wrongVersionException)
|
||||
errors.add("Diese Schematic kann nicht in dieser Version geändert werden");
|
||||
if(errorLoadingSchematic)
|
||||
errors.add("Die Schematic konnte nicht geladen werden");
|
||||
|
||||
assert type != null;
|
||||
if(width > type.getDepth())
|
||||
errors.add("Die Schematic ist zu breit (" + width + " > " + type.getDepth() + ")");
|
||||
if(length > type.getWidth())
|
||||
errors.add("Die Schematic ist zu lang (" + length + " > " + type.getWidth() + ")");
|
||||
if(height > type.getHeight())
|
||||
errors.add("Die Schematic ist zu hoch (" + height + " > " + type.getHeight() + ")");
|
||||
|
||||
int errorTNTSlime = slime + tnt;
|
||||
if(type.getMaxTNT() != 0 && tnt > type.getMaxTNT())
|
||||
errors.add("Zu viele TNT-Blöcke (" + tnt + " > " + type.getMaxTNT() + ")");
|
||||
if(type.getMaxSlime() != 0 && slime > type.getMaxSlime())
|
||||
errors.add("Zu viele Schleim/Honig-Blöcke (" + slime + " > " + type.getMaxSlime() + ")");
|
||||
if(type.getMaxDispenser() != 0 && dispenser > type.getMaxDispenser())
|
||||
errors.add("Zu viele Werfer (" + dispenser + " > " + type.getMaxDispenser() + ")");
|
||||
if(type.getMaxTNTSlime() != 0 && errorTNTSlime > type.getMaxTNTSlime())
|
||||
errors.add("Zu viel Schleim+TNT" + errorTNTSlime + " > " + type.getMaxTNTSlime() + ")");
|
||||
if(type.getMaxBlocks() != 0 && blocks > type.getMaxBlocks()) {
|
||||
errors.add("Zu viele Blöcke (" + blocks + " > " + type.getMaxBlocks() + ")");
|
||||
}
|
||||
|
||||
for(Map.Entry<String, Integer> block : forbiddenMaterials.entrySet())
|
||||
errors.add("Der Block " + block.getKey() + " ist verboten (" + block.getValue() + " verbaut)");
|
||||
|
||||
if(records > 0)
|
||||
errors.add("Keine Schallplatten erlaubt (" + records + " gefunden)");
|
||||
for(Map.Entry<String, Map<String, Integer>> block : forbiddenItems.entrySet())
|
||||
for(Map.Entry<String, Integer> item : block.getValue().entrySet())
|
||||
errors.add("In " + block.getKey() + "s wurde das verbotene Item " + item.getKey() + " " + item.getValue() + " mal gefunden");
|
||||
for(Map.Entry<String, Map<String, Integer>> block : itemsWithTag.entrySet())
|
||||
for(Map.Entry<String, Integer> item : block.getValue().entrySet())
|
||||
errors.add("In " + block.getKey() + "s wurde das Item " + item.getKey() + " " + item.getValue() + " mal mit Custom-Tag gefunden");
|
||||
if(tooManyDispenserItems == 1)
|
||||
errors.add("Ein Werfer enthält mehr als " + type.getMaxDispenserItems() + " Pfeile und Feuerbälle");
|
||||
else if(tooManyDispenserItems > 1)
|
||||
errors.add(tooManyDispenserItems + " Werfer enthalten mehr als " + type.getMaxDispenserItems() + " Pfeile und Feuerbälle");
|
||||
|
||||
return errors;
|
||||
}
|
||||
|
||||
public Collection<String> warnings(){
|
||||
List<String> warnings = new LinkedList<>();
|
||||
|
||||
for(Map.Entry<String, Integer> nbtBlock : defunctNbt.entrySet()){
|
||||
if(nbtBlock.getValue() > 1)
|
||||
warnings.add(nbtBlock.getValue() + " " + nbtBlock.getKey() + "s enthalten keine oder inkorrekte NBT-Daten");
|
||||
else
|
||||
warnings.add("Ein(e) " + nbtBlock.getKey() + " enthält keine oder inkorrekte NBT-Daten");
|
||||
}
|
||||
|
||||
return warnings;
|
||||
}
|
||||
|
||||
void setErrorLoadingSchematic(){
|
||||
errorLoadingSchematic = true;
|
||||
}
|
||||
|
||||
void setWidth(int width){
|
||||
this.width = width;
|
||||
}
|
||||
void setLength(int length){
|
||||
this.length = length;
|
||||
}
|
||||
void setHeight(int height){
|
||||
this.height = height;
|
||||
}
|
||||
|
||||
void setTNT(int tnt){
|
||||
this.tnt = tnt;
|
||||
}
|
||||
void setSlime(int slime){
|
||||
this.slime = slime;
|
||||
}
|
||||
void setDispenser(int dispenser){
|
||||
this.dispenser = dispenser;
|
||||
}
|
||||
void setBlocks(int blocks) {
|
||||
this.blocks = blocks;
|
||||
}
|
||||
|
||||
void checkMaterial(String name){
|
||||
assert type != null;
|
||||
if(type.getForbidden().contains(name))
|
||||
forbiddenMaterials.compute(name, (k, v) -> v == null ? 1 : v+1);
|
||||
}
|
||||
|
||||
void defunctNbt(String name){
|
||||
defunctNbt.compute(name, (k, v) -> v == null ? 1 : v+1);
|
||||
}
|
||||
void foundRecord(){
|
||||
records++;
|
||||
}
|
||||
void foundForbiddenItem(String material, String item, int count){
|
||||
forbiddenItems.compute(material, (k1, v) -> {
|
||||
if(v == null)
|
||||
v = new HashMap<>();
|
||||
v.compute(item, (k2, v2) -> v2 == null ? count : v2 + count);
|
||||
return v;
|
||||
});
|
||||
}
|
||||
void foundItemWithTag(String material, String item, int count){
|
||||
itemsWithTag.compute(material, (k1, v) -> {
|
||||
if(v == null)
|
||||
v = new HashMap<>();
|
||||
v.compute(item, (k2, v2) -> v2 == null ? count : v2 + count);
|
||||
return v;
|
||||
});
|
||||
}
|
||||
void dispenserItems(int counter){
|
||||
assert type != null;
|
||||
if(counter > type.getMaxDispenserItems())
|
||||
tooManyDispenserItems++;
|
||||
}
|
||||
}
|
54
SchematicSystem_Core/build.gradle
Normale Datei
54
SchematicSystem_Core/build.gradle
Normale Datei
@ -0,0 +1,54 @@
|
||||
/*
|
||||
* This file is a part of the SteamWar software.
|
||||
*
|
||||
* Copyright (C) 2021 SteamWar.de-Serverteam
|
||||
*
|
||||
* This program is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU Affero General Public License as published by
|
||||
* the Free Software Foundation, either version 3 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 Affero General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU Affero General Public License
|
||||
* along with this program. If not, see <https://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
plugins {
|
||||
id 'base'
|
||||
id 'java'
|
||||
}
|
||||
|
||||
group 'steamwar'
|
||||
version '1.0'
|
||||
|
||||
compileJava.options.encoding = 'UTF-8'
|
||||
|
||||
sourceCompatibility = 1.8
|
||||
targetCompatibility = 1.8
|
||||
|
||||
sourceSets {
|
||||
main {
|
||||
java {
|
||||
srcDirs = ['src/']
|
||||
}
|
||||
resources {
|
||||
srcDirs = ['src/']
|
||||
exclude '**/*.java', '**/*.kt'
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
dependencies {
|
||||
compileOnly 'org.projectlombok:lombok:1.18.22'
|
||||
testCompileOnly 'org.projectlombok:lombok:1.18.22'
|
||||
annotationProcessor 'org.projectlombok:lombok:1.18.22'
|
||||
testAnnotationProcessor 'org.projectlombok:lombok:1.18.22'
|
||||
|
||||
compileOnly swdep("Spigot-1.15")
|
||||
compileOnly swdep("WorldEdit-1.15")
|
||||
compileOnly swdep("SpigotCore")
|
||||
}
|
264
SchematicSystem_Core/src/SchematicSystem.properties
Normale Datei
264
SchematicSystem_Core/src/SchematicSystem.properties
Normale Datei
@ -0,0 +1,264 @@
|
||||
#
|
||||
# This file is a part of the SteamWar software.
|
||||
#
|
||||
# Copyright (C) 2023 SteamWar.de-Serverteam
|
||||
#
|
||||
# This program is free software: you can redistribute it and/or modify
|
||||
# it under the terms of the GNU Affero General Public License as published by
|
||||
# the Free Software Foundation, either version 3 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 Affero General Public License for more details.
|
||||
#
|
||||
# You should have received a copy of the GNU Affero General Public License
|
||||
# along with this program. If not, see <https://www.gnu.org/licenses/>.
|
||||
#
|
||||
|
||||
PREFIX=§eSchematic§8» §7
|
||||
ON=§aon
|
||||
OFF=§coff
|
||||
CHANGE=§7To change
|
||||
CLICK=§7Click
|
||||
CLICK_DRAG_ITEM=§7Click or drag item here
|
||||
CURRENT=§7Current: {0}
|
||||
CONFIRM=§aConfirm
|
||||
CANCEL=§cCancel
|
||||
|
||||
UTIL_NAME_REQUIRED=§cFolder name required
|
||||
UTIL_NAME_TOO_LONG=§cSchematic name too long
|
||||
UTIL_NAME_INVALID_CHAR=§cThe specified schema name contains forbidden characters
|
||||
UTIL_NAME_FORBIDDEN=§cThe path must not contain \"§l{0}§c\"
|
||||
UTIL_LIST_HEAD=§eSchematics §8(§e{0}§8)
|
||||
UTIL_LIST_PATH=§7Current path: §e{0}
|
||||
UTIL_LIST_BACK=§e../
|
||||
UTIL_LIST_BACK_HOVER=§eBack {0}
|
||||
UTIL_LIST_DIR=§7§lDIR
|
||||
UTIL_LIST_TYPE=§8§l{0}
|
||||
UTIL_LIST_BASE=§e
|
||||
UTIL_LIST_FROM=§8from §7{0}
|
||||
UTIL_LIST_OPEN_DIR=§eShow directory
|
||||
UTIL_LIST_OPEN_SCHEM=§eManage schematics
|
||||
UTIL_LIST_REMOVE=[Remove]
|
||||
UTIL_LIST_REMOVE_HOVER=§7Remove yourself from the directory
|
||||
UTIL_LIST_BACK_ARROW=««
|
||||
UTIL_LIST_BACK_ARROW_HOVER=§ePrevious page
|
||||
UTIL_LIST_NEXT=Page ({0}/{1}) »»
|
||||
UTIL_LIST_NEXT_HOVER=§eNext page
|
||||
UTIL_INFO_SCHEM=§7Schematic: §e{0}
|
||||
UTIL_INFO_NAME=§7Name: §e{0}
|
||||
UTIL_INFO_OWNER=§7Owner: §e{0}
|
||||
UTIL_INFO_PARENT=§7Directory: §e{0}
|
||||
UTIL_INFO_UPDATED=§7Last update: §e{0}
|
||||
UTIL_INFO_TYPE=§7Type: §e{0}
|
||||
UTIL_INFO_TYPE_DIR=§eDIR
|
||||
UTIL_INFO_RANK=§7Rank: §e{0}
|
||||
UTIL_INFO_COLOR=§7Color translation: {0}
|
||||
UTIL_INFO_REPLAY=§7Replay playback: {0}
|
||||
UTIL_INFO_ELO=§7Elo: §e{0}
|
||||
UTIL_INFO_FORMAT=§7Format: §e{0}
|
||||
UTIL_INFO_STATUS=§cState: §c{0}: {1}
|
||||
UTIL_INFO_MEMBER=§7Members: §e{0}
|
||||
UTIL_INFO_MEMBER_STRING=Members:
|
||||
UTIL_INFO_ACTION_LOAD=(Load)
|
||||
UTIL_INFO_ACTION_LOAD_HOVER=§eLoad schematic
|
||||
UTIL_INFO_ACTION_DOWNLOAD=(Download)
|
||||
UTIL_INFO_ACTION_DOWNLOAD_HOVER=§eDownload schematic
|
||||
UTIL_INFO_ACTION_TYPE_HOVER=§eChange schematic type
|
||||
UTIL_INFO_ACTION_ADD_HOVER=§eAdd member
|
||||
UTIL_INFO_ACTION_REMOVE_HOVER=§eRemove {0}
|
||||
UTIL_INFO_ACTION_MOVE_HOVER=§eMove schematic
|
||||
UTIL_INFO_ACTION_RENAME_HOVER=§eRename schematic
|
||||
UTIL_INFO_ACTION_DELETE=(Delete)
|
||||
UTIL_INFO_ACTION_DELETE_HOVER=§eDelete schematic
|
||||
UTIL_LOAD_NOT_HERE=§cYou cannot load schematics here
|
||||
UTIL_LOAD_NOT_HERE_ALL=§cSchematics cannot be loaded on this build
|
||||
UTIL_LOAD_DIR=§cYou cannot load folders
|
||||
UTIL_LOAD_DONE=§7Schematic §e{0} loaded
|
||||
UTIL_LOAD_NO_DATA=§cNo data could be found in the Schematic
|
||||
UTIL_LOAD_ERROR=§cThe schematic could not be loaded
|
||||
UTIL_DOWNLOAD_PUNISHED=§cYou are not allowed to download schematics: §f§l{0}
|
||||
UTIL_DOWNLOAD_NOT_OWN=§cYou may download only your own schematics
|
||||
UTIL_DOWNLOAD_LINK=Your download link:
|
||||
UTIL_TYPE_PUNISHED=§cYou are not allowed to submit schematics: §f§l{0}
|
||||
UTIL_TYPE_NOT_OWN=§cYou can only submit your own schematics
|
||||
UTIL_TYPE_DIR=§cYou cannot submit folders
|
||||
UTIL_TYPE_NOT_ASSIGNABLE=§cSchematics cannot be changed for this type
|
||||
UTIL_TYPE_ALREADY=§cThe Schematic already has this type
|
||||
UTIL_TYPE_DONE=§aChange schematic type
|
||||
UTIL_TYPE_FIGHT_ALREADY=§cYou have already submitted this schematic
|
||||
UTIL_TYPE_AFTER_DEADLINE=§cSchematics of this type can no longer be submitted. Deadline was: {0}
|
||||
UTIL_TYPE_ERROR=§cThe Schematic is not compliant with the rules
|
||||
UTIL_TYPE_EXTEND=§aThe preparation server is starting
|
||||
UTIL_SUBMIT_TITLE=Extend Schematic
|
||||
UTIL_SUBMIT_REPLAY_ON=§aReplay allowed
|
||||
UTIL_SUBMIT_REPLAY_OFF=§cReplay locked
|
||||
UTIL_SUBMIT_COLOR_ON=§aReplace pink to team color
|
||||
UTIL_SUBMIT_COLOR_OFF=§cDo not replace pink
|
||||
UTIL_SUBMIT_DIRECT=§eSubmit directly
|
||||
UTIL_SUBMIT_DIRECT_DONE=§aThe Schematic will be reviewed in a timely manner
|
||||
UTIL_SUBMIT_EXTEND=§eExtend Schematic
|
||||
UTIL_SUBMIT_EXTEND_DONE=§aThe preparation server is starting
|
||||
UTIL_CHECK_TYPE_NOT_FOUND=§cThe type {0} was not found
|
||||
UTIL_CHECK_SUCCESS=§aThe schematic was checked successfully
|
||||
|
||||
COMMAND_INVALID_NODE=§cInvalid Schematic
|
||||
COMMAND_NOT_OWN=§cYou can only use this command on your own Schematic
|
||||
COMMAND_MUST_DIR=§cYou can only use this command on a directory
|
||||
COMMAND_MUST_SCHEM=§cYou can only use this command on a Schematic
|
||||
COMMAND_ENTER_NAME=Insert name
|
||||
COMMAND_PUNISHMENT_NO_SAVE_EXTERNAL=§cYou can not make schematics on other build server
|
||||
COMMAND_PUNISHMENT_NO_SAVE=§cSchematics cannot be made on this build
|
||||
COMMAND_SAVE_NO_NAME=§cYou must also specify a name for the schematic after the folder
|
||||
COMMAND_SAVE_FOLDER=§cSchematic is a folder
|
||||
COMMAND_SAVE_NO_OVERWRITE=§cYou must not overwrite this Schematic
|
||||
COMMAND_SAVE_CLIPBOARD_EMPTY=§cYour clipboard is empty
|
||||
COMMAND_SAVE_ERROR=§cError while saving the Schematic
|
||||
COMMAND_SAVE_DONE=Schematic §e{0} §7stored
|
||||
COMMAND_SAVE_OVERWRITE=Schematic §e{0} §7overwritten
|
||||
COMMAND_SAVE_OVERWRITE_CONFIRM=§cThe Schematic §e{0} §calready exists. Do you want to overwrite it? §e*click*
|
||||
COMMAND_SAVE_OVERWRITE_CONFIRM_HOVER=§eOverwrite Schematic
|
||||
COMMAND_ADD_PUNISH=§cYou may not add anyone to your schematics: §f§l{0}
|
||||
COMMAND_ADD_USER_PUNISHED=§c{0} must not be added to schematics
|
||||
COMMAND_ADD_OWN=§cSo please: This is your own Schematic!
|
||||
COMMAND_ADD_PUBLIC=§cFor public requests please contact the moderator
|
||||
COMMAND_ADD_ALREADY=§c{0} is already added to this schematic
|
||||
COMMAND_ADD_ADDED=You now have access to the Schematic §e{0} §7of §e{1}
|
||||
COMMAND_ADD_NONE=§cNo player has been added
|
||||
COMMAND_ADD_ONE=§7The player §e{0} was added to the schematic
|
||||
COMMAND_ADD_MANY=§7The players §e{0} were added to the schematic
|
||||
COMMAND_DELMEM_DONE=The player §e{0} §7no longer has access to the Schematic §e{1}
|
||||
COMMAND_DELMEM_DELETED=§cYou now no longer have access to the Schematic §e{0} §7of §e{1}
|
||||
COMMAND_SEARCH_NOT_A_PLAYER=§cThe player §e{0} §cdoes not exists
|
||||
COMMAND_LOCKREPLAY=Replays of fights with {0} can no longer be viewed from now on
|
||||
COMMAND_REPLACE_COLOR_OFF=In fights {0} pink blocks are not replaced
|
||||
COMMAND_REPLACE_COLOR_ON=In fights {0} pink blocks are replaced
|
||||
COMMAND_DIR_DONE=§7Directory §e{0} §7created
|
||||
COMMAND_CHANGE_TYPE_SELECT=§eSelect type
|
||||
COMMAND_MOVE_RECURSIVE=§cThis only gives mistakes, trust me
|
||||
COMMAND_MOVE_DONE=§7The schematic can now be found under §e{0}
|
||||
COMMAND_RENAME_DONE=§7The schematic is now called §e{0}
|
||||
COMMAND_ADD_TEAM_NOT_IN_TEAM=§cYou are not in any team
|
||||
COMMAND_DEL_TEAM_NOT_IN_TEAM=§cYou are not in any team
|
||||
COMMAND_DEL_TEAM_NONE=§7No player was removed
|
||||
COMMAND_DEL_TEAM_DONE=§7The player §e{0} §7were removed from the Schematic
|
||||
COMMAND_CLEAR_MEMBER_DONE=§7All players were removed from the Schematic
|
||||
COMMAND_DEL_ALL_MEMBER=§e{0} §7has been removed from §e{1} §7Schematics
|
||||
COMMAND_PUBLIC_ON=§aYou are now the public user
|
||||
COMMAND_PUBLIC_OFF=§cYou are no longer the public user
|
||||
COMMAND_DELETE_NOT_OWN=§cThe schematic is not yours
|
||||
COMMAND_DELETE_MEMBER=§aYou have removed yourself from the Schematic
|
||||
COMMAND_DELETE_DIR=§aThe folder §e{0}§a is deleted...
|
||||
COMMAND_DELETE_DIR_FULL=§cThe folder must be empty to delete it
|
||||
COMMAND_DELETE_SCHEM=§aThe Schematic §e{0}§a is deleted...
|
||||
COMMAND_CHECK_SELECTION_INCOMPLETE=§cThe selection is incomplete
|
||||
COMMAND_CHECK_CLIPBOARD_EMPTY=§cThe clipboard is empty
|
||||
COMMAND_FIX_OK=§aThe schematic is already fixed
|
||||
COMMAND_FIX_DONE=§aThe schematic has been fixed
|
||||
COMMAND_FIX_COULD_NOT_FIX=§cCould not fix this in the schematic
|
||||
COMMAND_FIX_MANUAL=manually fix
|
||||
COMMAND_FIX_ERROR=§cError while fixing the schematic, please contact a developer
|
||||
COMMAND_FIX_WRONG_VERSION=§cThis feature is only available for version 1.15 and greater
|
||||
|
||||
HELP_HEADER=§e§lSchematicSystem §8§lHelp
|
||||
HELP_VIEW=Find & Load
|
||||
HELP_VIEW_HOVER=Search or download schematics
|
||||
HELP_VIEW_1=§8/§7schem §einfo §8[§7schematic§8] - §7Shows information about the schematic
|
||||
HELP_VIEW_2=§8/§7schem §elist §8- §7Shows you your schematics
|
||||
HELP_VIEW_3=§8/§7schem §elist public §8- §7Shows all public schematics
|
||||
HELP_VIEW_4=§8/§7schem §esearch §8[§7keyword§8] - §7Searches for matching schematics
|
||||
HELP_VIEW_5=§8/§7schem §eload §8[§7schematic§8] - §7Loads a schematic
|
||||
HELP_VIEW_6=§8/§7schem §edownload §8[§7schematic§8] - §7Gives you a download link (valid for 1 min)
|
||||
HELP_VIEW_7=§8/§7download §8- §7Gives you a download link for your current clipboard (valid for 1 min)
|
||||
HELP_VIEW_8=§8/§7schem §echeck §8[§7schematic§8|§7selection§8|§7clipboard§8] [§7schematictype§8] - §7Checks the schematic for errors
|
||||
HELP_EDIT=Save & Edit
|
||||
HELP_EDIT_HOVER=Modification of schematics and folders
|
||||
HELP_EDIT_1=§8/§7schem §esave §8[§7schematic§8] - §7Saves your clipboard as a schematic
|
||||
HELP_EDIT_2=§8/§7schem §eordner §8[§7directory§8] - §7Create an empty folder
|
||||
HELP_EDIT_3=§8/§7schem §emove §8[§7schematic§8] [§7new path§8] - §7Move a schematic
|
||||
HELP_EDIT_4=§8/§7schem §erename §8[§7schematic§8] [§7new path§8] - §7Give the schematic a new name
|
||||
HELP_EDIT_5=§8/§7schem §echangetype §8[§7schematic§8] - §7Changes the type of your schematic
|
||||
HELP_EDIT_6=§8/§7schem §elockreplay §8[§7schematic§8] - §7Locks replays of the schematic
|
||||
HELP_EDIT_7=§8/§7schem §ereplacecolor §8[§7schematic§8] - §7Changes color substitution in the arena
|
||||
HELP_EDIT_8=§8/§7schem §edelete §8[§7schematic§8] - §7Deletes a schematic
|
||||
HELP_EDIT_9=§8/§7schem §efix §8[§7schematictype§8] - §7Tries to fix the schematic in your clipboard
|
||||
HELP_SHARE=Ownership
|
||||
HELP_SHARE_HOVER=Share Schematics with others
|
||||
HELP_SHARE_1=§8/§7schem §eaddmember §8[§7schematic§8] §8[§7Spieler§8] - §7Adds a player to a schematic
|
||||
HELP_SHARE_2=§8/§7schem §edelmember §8[§7schematic§8] §8[§7Spieler§8] - §7Removes a player from a schematic
|
||||
HELP_SHARE_3=§8/§7schem §eclearmember §8[§7schematic§8] - §7Removes all players from the schematic
|
||||
HELP_SHARE_4=§8/§7schem §edelallmember §8[§7player§8] - §7Removes a player from all your schematics
|
||||
HELP_SHARE_5=§8/§7schem §eaddteam §8[§7schematic§8] - §7Add everyone from your team to the schematic
|
||||
HELP_SHARE_6=§8/§7schem §edelteam §8[§7schematic§8] - §7Remove everyone from your team from the Schematic
|
||||
|
||||
GUI_TITLE=Schematics \{1\}
|
||||
GUI_FOLDER_PROPERTIES=§7Directory properties
|
||||
GUI_INFO_LOAD=§eLoading
|
||||
GUI_INFO_BACK=§eBack
|
||||
GUI_INFO_STATUS=§eState {0}
|
||||
GUI_INFO_STATUS_LORE=§7{0}
|
||||
GUI_INFO_MAT=§e{0}
|
||||
GUI_INFO_TYPE=§e{0}
|
||||
GUI_INFO_DOWNLOAD=§eDownload
|
||||
GUI_INFO_COLOR=Color translation
|
||||
GUI_INFO_REPLAY=Replay playback
|
||||
GUI_INFO_REPLAY_OFF=§7§lTurn off
|
||||
GUI_INFO_REPLAY_TITLE=Lock playback permanently
|
||||
GUI_INFO_MEMBER=§eMembers
|
||||
GUI_INFO_MOVE=§eMove
|
||||
GUI_INFO_RENAME=§eRename
|
||||
GUI_INFO_RENAME_TITLE={0} rename
|
||||
GUI_INFO_DELETE=§cDelete
|
||||
GUI_INFO_MEMBER_FROM=§7Owner §e{0}
|
||||
GUI_INFO_MEMBER_REMOVE=§cRemove access
|
||||
GUI_CHANGE_TYPE=Change type
|
||||
GUI_CHANGE_TYPE_NOT_POSSIBLE=§cThe Schematic is too big
|
||||
GUI_CHANGE_TYPE_NOT_POSSIBLE_COLOR=§7{0}
|
||||
GUI_DELETE_OWN_DELETED=Schematic §e{0} §7deleted
|
||||
GUI_DELETE_OWN_TITLE=Delete {0}
|
||||
GUI_DELETE_MEMBER_TITLE=Remove {0}
|
||||
GUI_DELETE_MEMBER_DONE=Access to Schematic §e{0} §7removed
|
||||
GUI_DELETE_MEMBERS_TITLE=Remove members
|
||||
GUI_CHANGE_ITEM=Change item
|
||||
|
||||
AUTO_CHECK_RESULT_NOT_LOAD=The schematic could not be loaded
|
||||
AUTO_CHECK_RESULT_TOO_WIDE=The schematic is too wide ({0} > {1})
|
||||
AUTO_CHECK_RESULT_TOO_LONG=The schematic is too long ({0} > {1})
|
||||
AUTO_CHECK_RESULT_TOO_HIGH=The schematic is too high ({0} > {1})
|
||||
AUTO_CHECK_RESULT_TOO_MANY_BLOCK=The block {0} was used {1} times too often
|
||||
AUTO_CHECK_RESULT_TOO_MANY_BLOCKS=The block combination {0} was used {1} times too often
|
||||
AUTO_CHECK_RESULT_TOO_MANY_ALL_BLOCKS=Too many blocks ({0} > {1})
|
||||
AUTO_CHECK_RESULT_TOO_MANY_RECORDS=No records allowed ({0} found)
|
||||
AUTO_CHECK_RESULT_FORBIDDEN_ITEM=In {0}s the forbidden item {1} {2} times was found
|
||||
AUTO_CHECK_RESULT_FORBIDDEN_ITEM_NBT=In {0}s the forbidden item {1} {2} times was found with custom tag
|
||||
AUTO_CHECK_RESULT_TOO_MANY_DISPENSER_ITEMS=One launcher contains more than {0} arrows and fireballs
|
||||
AUTO_CHECK_RESULT_TOO_MANY_DISPENSERS_ITEMS={0} launchers contains more than {1} arrows and fireballs
|
||||
AUTO_CHECK_RESULT_NBTS_WARNING={0} {1}s contain no or incorrect NBT data
|
||||
AUTO_CHECK_RESULT_NBT_WARNING=One {0} contains no or incorrect NBT data.
|
||||
|
||||
SAFE_NODE_NOT_A_DIR=§cThe selected Schematic is not a folder
|
||||
SAFE_NODE_ALREADY_IN_DIRECTORY=§cThe schematic is already available in this folder
|
||||
SAFE_NODE_INVALID_NAME=§cThis name is illegal
|
||||
SAFE_NODE_NOT_OWNER=§cYou are not the owner of this schematic
|
||||
|
||||
DOWNLOAD_ERROR=§cAn error occurred while uploading the schematic
|
||||
|
||||
AUTO_CHECKER_RESULT_HEADER=§7---=== (§eAuto-Check: {0}§7) ===---
|
||||
AUTO_CHECKER_RESULT_WIDTH =§7Width: §c{0}§7, Max: §e{1}
|
||||
AUTO_CHECKER_RESULT_LENGTH=§7Length: §c{0}§7, Max: §e{1}
|
||||
AUTO_CHECKER_RESULT_HEIGHT=§7Height: §c{0}§7, Max: §e{1}
|
||||
AUTO_CHECKER_RESULT_BLOCKS=§7Blocks: §c{0}§7, Max: §e{1}
|
||||
AUTO_CHECKER_RESULT_UNKNOWN_MATERIAL=§7Unknown block: §c{0}
|
||||
AUTO_CHECKER_RESULT_TOO_MANY_BLOCK=§7{0}: §c{1}§7, Max: §e{2}
|
||||
AUTO_CHECKER_RESULT_FORBIDDEN_BLOCK=§7Forbidden block: §c{0}
|
||||
AUTO_CHECKER_RESULT_FORBIDDEN_ITEM=§7Forbidden Item: [{0}, {1}, {2}] -> §c{3}
|
||||
AUTO_CHECKER_RESULT_DEFUNCT_NBT=§7Defunct NBT: §7[{0}, {1}, {2}]
|
||||
AUTO_CHECKER_RESULT_DESIGN_BLOCK=§7{0} in Design: [{1}, {2}, {3}]
|
||||
AUTO_CHECKER_RESULT_ENTITY=§7Entity: §7[{0}, {1}, {2}]
|
||||
AUTO_CHECKER_RESULT_RECORD=§7Record: §c[{0}, {1}, {2}]
|
||||
AUTO_CHECKER_RESULT_TOO_MANY_DISPENSER_ITEMS=§7Dispenser: §c[{0}, {1}, {2}]§7, §c{3} §7items, Max: §e{4}
|
||||
AUTO_CHECKER_RESULT_FORBIDDEN_ITEM_NBT=§7Forbidden Item NBT: [{0}, {1}, {2}] -> §c{3}
|
||||
AUTO_CHECKER_RESULT_TELEPORT_HERE=§7Teleport to block
|
||||
AUTO_CHECKER_RESULT_AFTER_DEADLINE=§cThe deadline has expired: {0}
|
243
SchematicSystem_Core/src/SchematicSystem_de.properties
Normale Datei
243
SchematicSystem_Core/src/SchematicSystem_de.properties
Normale Datei
@ -0,0 +1,243 @@
|
||||
#
|
||||
# This file is a part of the SteamWar software.
|
||||
#
|
||||
# Copyright (C) 2023 SteamWar.de-Serverteam
|
||||
#
|
||||
# This program is free software: you can redistribute it and/or modify
|
||||
# it under the terms of the GNU Affero General Public License as published by
|
||||
# the Free Software Foundation, either version 3 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 Affero General Public License for more details.
|
||||
#
|
||||
# You should have received a copy of the GNU Affero General Public License
|
||||
# along with this program. If not, see <https://www.gnu.org/licenses/>.
|
||||
#
|
||||
|
||||
ON=§aAn
|
||||
OFF=§cAus
|
||||
CHANGE=§7Zum Ändern
|
||||
CLICK=§7anklicken
|
||||
CLICK_DRAG_ITEM=§7anklicken oder hier Item hineinlegen
|
||||
CURRENT=§7Aktuell: {0}
|
||||
CONFIRM=§aBestätigen
|
||||
CANCEL=§cAbbrechen
|
||||
|
||||
UTIL_NAME_REQUIRED=§cDeine Ordner brauchen schon einen Namen
|
||||
UTIL_NAME_TOO_LONG=§cDer Name der Schematic ist zu lang
|
||||
UTIL_NAME_INVALID_CHAR=§cDer angegebene Schematicname enthält verbotene Zeichen
|
||||
UTIL_NAME_FORBIDDEN=§cDer Pfad darf nicht \"§l{0}§c\" enthalten
|
||||
UTIL_LIST_PATH=§7Aktueller Pfad: §e{0}
|
||||
UTIL_LIST_BACK_HOVER=§eZurück gehen {0}
|
||||
UTIL_LIST_FROM=§8von §7{0}
|
||||
UTIL_LIST_OPEN_DIR=§eOrdner anzeigen
|
||||
UTIL_LIST_OPEN_SCHEM=§eSchematic verwalten
|
||||
UTIL_LIST_REMOVE=[Entfernen]
|
||||
UTIL_LIST_REMOVE_HOVER=§7Entferne dich von dem Ordner
|
||||
UTIL_LIST_BACK_ARROW_HOVER=§eVorherige Seite
|
||||
UTIL_LIST_NEXT=Seite ({0}/{1}) »»
|
||||
UTIL_LIST_NEXT_HOVER=§eNächste Seite
|
||||
UTIL_INFO_OWNER=§7Besitzer: §e{0}
|
||||
UTIL_INFO_PARENT=§7Ordner: §e{0}
|
||||
UTIL_INFO_UPDATED=§7Letzes Update: §e{0}
|
||||
UTIL_INFO_TYPE=§7Typ: §e{0}
|
||||
UTIL_INFO_RANK=§7Rang: §e{0}
|
||||
UTIL_INFO_COLOR=§7Farbersetzung: {0}
|
||||
UTIL_INFO_REPLAY=§7Replaywiedergabe: {0}
|
||||
UTIL_INFO_STATUS=§cStatus: §c{0}: {1}
|
||||
UTIL_INFO_MEMBER=§7Mitglieder: §e{0}
|
||||
UTIL_INFO_MEMBER_STRING=Mitglieder:
|
||||
UTIL_INFO_ACTION_LOAD=(Laden)
|
||||
UTIL_INFO_ACTION_LOAD_HOVER=§eSchematic laden
|
||||
UTIL_INFO_ACTION_DOWNLOAD_HOVER=§eSchematic downloaden
|
||||
UTIL_INFO_ACTION_TYPE_HOVER=§eSchematic Typ ändern
|
||||
UTIL_INFO_ACTION_ADD_HOVER=§eMember hinzufügen
|
||||
UTIL_INFO_ACTION_REMOVE_HOVER=§e{0} entfernen
|
||||
UTIL_INFO_ACTION_MOVE_HOVER=§eSchematic verschieben
|
||||
UTIL_INFO_ACTION_RENAME_HOVER=§eSchematic umbenennen
|
||||
UTIL_INFO_ACTION_DELETE=(Löschen)
|
||||
UTIL_INFO_ACTION_DELETE_HOVER=§eSchematic löschen
|
||||
UTIL_LOAD_NOT_HERE=§cDu kannst hier keine Schematics laden
|
||||
UTIL_LOAD_NOT_HERE_ALL=§cAuf diesem Bau können keine Schematics geladen werden
|
||||
UTIL_LOAD_DIR=§cDu kannst keine Ordner Laden
|
||||
UTIL_LOAD_DONE=§7Schematic §e{0} geladen
|
||||
UTIL_LOAD_NO_DATA=§cEs konnte keine Daten in der Schematic gefunden werden
|
||||
UTIL_LOAD_ERROR=§cDie Schematic konnte nicht geladen werden
|
||||
UTIL_DOWNLOAD_PUNISHED=§cDu darf keine Schematics Downloaden: §f§l{0}
|
||||
UTIL_DOWNLOAD_NOT_OWN=§cDu darfst nur deine eigenen Schematics herunterladen
|
||||
UTIL_DOWNLOAD_LINK=Dein Download Link:
|
||||
UTIL_TYPE_PUNISHED=§cDu darf keine Schematics einsenden: §f§l{0}
|
||||
UTIL_TYPE_NOT_OWN=§cDu kannst nur deine eigenen Schematics einsenden
|
||||
UTIL_TYPE_DIR=§cDu kannst keine Ordner einsenden
|
||||
UTIL_TYPE_NOT_ASSIGNABLE=§cZu diesem Typen können keine Schematics geändert werden
|
||||
UTIL_TYPE_ALREADY=§cDie Schematic hat schon diesen Typen
|
||||
UTIL_TYPE_DONE=§aSchematictyp geändert
|
||||
UTIL_TYPE_FIGHT_ALREADY=§cDu hast diese Schematic bereits eingesendet
|
||||
UTIL_TYPE_AFTER_DEADLINE=§cVon diesem Typen können keine Schematics mehr eingesendet werden. Einsendeschluss war: {0}
|
||||
UTIL_TYPE_ERROR=§cDie Schematic ist nicht regelkonform
|
||||
UTIL_TYPE_EXTEND=§aDer Vorbereitungsserver wird gestartet
|
||||
UTIL_SUBMIT_TITLE=Schematic ausfahren
|
||||
UTIL_SUBMIT_REPLAY_ON=§aReplay erlaubt
|
||||
UTIL_SUBMIT_REPLAY_OFF=§cReplay gesperrt
|
||||
UTIL_SUBMIT_COLOR_ON=§aPink zu Teamfarbe ersetzen
|
||||
UTIL_SUBMIT_COLOR_OFF=§cPink nicht ersetzen
|
||||
UTIL_SUBMIT_DIRECT=§eDirekt einsenden
|
||||
UTIL_SUBMIT_DIRECT_DONE=§aDie Schematic wird zeitnah überprüft
|
||||
UTIL_SUBMIT_EXTEND=§eSchematic ausfahren
|
||||
UTIL_SUBMIT_EXTEND_DONE=§aDer Vorbereitungsserver wird gestartet
|
||||
|
||||
COMMAND_INVALID_NODE=§cDie Schematic konnte nicht gefunden werden
|
||||
COMMAND_NOT_OWN=§cDas darfst du nur bei deinen eigenen Schematics machen
|
||||
COMMAND_MUST_DIR=§cDu musst einen Ordner angeben
|
||||
COMMAND_MUST_SCHEM=§cDu musst eine Schematic angeben
|
||||
COMMAND_ENTER_NAME=Namen eingeben
|
||||
COMMAND_PUNISHMENT_NO_SAVE_EXTERNAL=§cDu kannst nicht auf anderen Baus Schematics machen
|
||||
COMMAND_PUNISHMENT_NO_SAVE=§cAuf diesem Bau können keine Schematics gemacht werden
|
||||
COMMAND_SAVE_NO_NAME=§cDu must auch einen Namen für die Schematic nach dem Ordner angeben
|
||||
COMMAND_SAVE_FOLDER=§cDie Schematic ist ein Ordner
|
||||
COMMAND_SAVE_NO_OVERWRITE=§cDu darfst diese Schematic nicht überschreiben
|
||||
COMMAND_SAVE_CLIPBOARD_EMPTY=§cDein Clipboard ist leer
|
||||
COMMAND_SAVE_ERROR=§cFehler beim Speichern der Schematic
|
||||
COMMAND_SAVE_DONE=Schematic §e{0} §7gespeichert
|
||||
COMMAND_SAVE_OVERWRITE=Schematic §e{0} §7überschrieben
|
||||
COMMAND_SAVE_OVERWRITE_CONFIRM=§cDie Schematic §e{0} §7existiert bereits. Möchtest du sie überschreiben? §e*klick*
|
||||
COMMAND_SAVE_OVERWRITE_CONFIRM_HOVER=§eSchematic überschreiben
|
||||
COMMAND_ADD_PUNISH=§cDu darfst niemanden auf deine Schematics hinzufügen: §f§l{0}
|
||||
COMMAND_ADD_USER_PUNISHED=§c{0} darf nicht auf Schematics hinzugefügt werden
|
||||
COMMAND_ADD_OWN=§cAlso bitte: Das ist deine eigene Schematic!
|
||||
COMMAND_ADD_PUBLIC=§cFür Public-Anträge bitte bei der Moderation melden
|
||||
COMMAND_ADD_ALREADY=§c{0} ist bereits auf diese Schematic geaddet
|
||||
COMMAND_ADD_ADDED=Du hast nun Zugriff auf die Schematic §e{0} §7von §e{1}
|
||||
COMMAND_ADD_NONE=§cEs wurde kein Spieler hinzugefügt
|
||||
COMMAND_ADD_ONE=§7Der Spieler §e{0} wurde auf die Schematic hinzugefügt
|
||||
COMMAND_ADD_MANY=§7Die Spieler §e{0} wurden auf die Schematic hinzugefügt
|
||||
COMMAND_DELMEM_DONE=Der Spieler §e{0} §7hat nun keinen Zugriff mehr auf die Schematic §e{1}
|
||||
COMMAND_DELMEM_DELETED=§cDu hast nun keinen Zugriff mehr auf die Schematic §e{0} §7von §e{1}
|
||||
COMMAND_SEARCH_NOT_A_PLAYER=§cDer Spieler §e{0} §cexistiert nicht
|
||||
COMMAND_LOCKREPLAY=Replays von Kämpfen mit {0} können ab sofort nicht mehr betrachtet werden
|
||||
COMMAND_REPLACE_COLOR_OFF=In Kämpfen {0} werden pinke Blöcke nicht ersetzt
|
||||
COMMAND_REPLACE_COLOR_ON=In Kämpfen {0} werden pinke Blöcke ersetzt
|
||||
COMMAND_DIR_DONE=§7Ordner §e{0} §7erstellt
|
||||
COMMAND_CHANGE_TYPE_SELECT=§eTyp auswählen
|
||||
COMMAND_MOVE_RECURSIVE=§cDas gibt nur Fehler, vertrau mir
|
||||
COMMAND_MOVE_DONE=§7Die Schematic ist nun unter §e{0} §7zu finden
|
||||
COMMAND_RENAME_DONE=§7Die Schematic heißt nun §e{0}
|
||||
COMMAND_ADD_TEAM_NOT_IN_TEAM=§cDu bist in keinem Team
|
||||
COMMAND_DEL_TEAM_NOT_IN_TEAM=§cDu bist in keinem Team
|
||||
COMMAND_DEL_TEAM_NONE=§7Es wurde kein Spieler entfernt
|
||||
COMMAND_DEL_TEAM_DONE=§7Der Spieler §e{0} §7wurden von der Schematic entfernt
|
||||
COMMAND_CLEAR_MEMBER_DONE=§7Alle Spieler wurden von der Schematic entfernt
|
||||
COMMAND_DEL_ALL_MEMBER=§e{0} §7wurde von §e{1} §7Schematics entfernt
|
||||
COMMAND_PUBLIC_ON=§aDu bist nun der Public User
|
||||
COMMAND_PUBLIC_OFF=§cDu bist nun nicht mehr der Public User
|
||||
COMMAND_DELETE_NOT_OWN=§cDie Schematic gehört dir nicht
|
||||
COMMAND_DELETE_MEMBER=§aDu hast dich von der Schematic entfernt
|
||||
COMMAND_DELETE_DIR=§aDer Ordner §e{0}§a wird gelöscht...
|
||||
COMMAND_DELETE_DIR_FULL=§cDer Ordner muss leer sein, um ihn zu löschen
|
||||
COMMAND_DELETE_SCHEM=§aDie Schematic §e{0}§a wird gelöscht...
|
||||
COMMAND_CHECK_SELECTION_INCOMPLETE=§cDeine Auswahl ist unvollständig
|
||||
COMMAND_CHECK_CLIPBOARD_EMPTY=§cDein Clipboard ist leer
|
||||
COMMAND_FIX_OK=§aDie Schematic ist bereits gefixt
|
||||
COMMAND_FIX_DONE=§aDie Schematic wurde repariert
|
||||
COMMAND_FIX_COULD_NOT_FIX=§cKonnte diese nicht sachen in der Schematic reparieren
|
||||
COMMAND_FIX_MANUAL=Manuel Fixen
|
||||
COMMAND_FIX_ERROR=§cFehler beim Fixen der Schematic, bitte kontaktiere einen Developer
|
||||
COMMAND_FIX_WRONG_VERSION=§cDiese Funktion ist nur für Version 1.15 und höher verfügbar
|
||||
|
||||
HELP_HEADER=§e§lSchematicSystem §8§lHilfe
|
||||
HELP_VIEW=Finden & Laden
|
||||
HELP_VIEW_HOVER=Suche oder lade Schematics
|
||||
HELP_VIEW_1=§8/§7schem §einfo §8[§7Schematic§8] - §7Zeigt dir Informationen zur Schematic
|
||||
HELP_VIEW_2=§8/§7schem §elist §8- §7Zeigt dir deine Schematics an
|
||||
HELP_VIEW_3=§8/§7schem §elist public §8- §7Zeigt alle Public-Schematics
|
||||
HELP_VIEW_4=§8/§7schem §esearch §8[§7Stichwort§8] - §7Sucht nach passenden Schematics
|
||||
HELP_VIEW_5=§8/§7schem §eload §8[§7Schematic§8] - §7Lädt eine Schematic
|
||||
HELP_VIEW_6=§8/§7schem §edownload §8[§7Schematic§8] - §7Gibt dir einen Downloadlink (1 min gültig)
|
||||
HELP_VIEW_7=§8/§7download §8- §7Gibt dir einen Downloadlink von deinem Clipboard (1 min gültig)
|
||||
HELP_VIEW_8=§8/§7schem §echeck §8[§7Schematic§8|§7selection§8|§7clipboard§8] [§7SchematicTyp§8] - §7Überprüft deine Schematic
|
||||
HELP_EDIT=Speichern & Bearbeiten
|
||||
HELP_EDIT_HOVER=Modifizierung von Schematics und Ordnern
|
||||
HELP_EDIT_1=§8/§7schem §esave §8[§7Schematic§8] - §7Speichert dein Clipboard als Schematic
|
||||
HELP_EDIT_2=§8/§7schem §eordner §8[§7Ordner§8] - §7Erstelle einen leeren Ordner
|
||||
HELP_EDIT_3=§8/§7schem §emove §8[§7Schematic§8] [§7Neuer Pfad§8] - §7Verschiebe eine Schematic
|
||||
HELP_EDIT_4=§8/§7schem §erename §8[§7Schematic§8] [§7Neuer Name§8] - §7Gib der Schematic einen neuen Namen
|
||||
HELP_EDIT_5=§8/§7schem §echangetype §8[§7Schematic§8] - §7Ändert die Art deiner Schematic
|
||||
HELP_EDIT_6=§8/§7schem §elockreplay §8[§7Schematic§8] - §7Sperrt Replays mit der Schematic
|
||||
HELP_EDIT_7=§8/§7schem §ereplacecolor §8[§7Schematic§8] - §7Ändert Farbersetzung in der Arena
|
||||
HELP_EDIT_8=§8/§7schem §edelete §8[§7Schematic§8] - §7Löscht eine Schematic
|
||||
HELP_EDIT_9=§8/§7schem §efix §8[§7SchematicTyp§8] - §7Versucht die Schematic in deinem Clipboard konform zu machen
|
||||
HELP_SHARE=Besitzrechte
|
||||
HELP_SHARE_HOVER=Schematics mit anderen teilen
|
||||
HELP_SHARE_1=§8/§7schem §eaddmember §8[§7Schematic§8] §8[§7Spieler§8] - §7Fügt einen Spieler zu einer Schematic hinzu
|
||||
HELP_SHARE_2=§8/§7schem §edelmember §8[§7Schematic§8] §8[§7Spieler§8] - §7Entfernt einen Spieler von einer Schematic
|
||||
HELP_SHARE_3=§8/§7schem §eclearmember §8[§7Schematic§8] - §7Entfernt alle Spieler von der Schematic
|
||||
HELP_SHARE_4=§8/§7schem §edelallmember §8[§7Spieler§8] - §7Entfernt einen Spieler von allen deinen Schematics
|
||||
HELP_SHARE_5=§8/§7schem §eaddteam §8[§7Schematic§8] - §7Füge jeden aus deinem Team auf die Schematic hinzu
|
||||
HELP_SHARE_6=§8/§7schem §edelteam §8[§7Schematic§8] - §7Entferne jeden aus deinem Team von der Schematic
|
||||
|
||||
GUI_TITLE=Schematics \{1\}
|
||||
GUI_FOLDER_PROPERTIES=§7Ordnereigenschaften
|
||||
GUI_INFO_LOAD=§eLaden
|
||||
GUI_INFO_BACK=§eZurück
|
||||
GUI_INFO_STATUS=§eStatus {0}
|
||||
GUI_INFO_COLOR=Farbersetzung
|
||||
GUI_INFO_REPLAY=Replay Wiedergabe
|
||||
GUI_INFO_REPLAY_OFF=§7Zum §lAusschalten
|
||||
GUI_INFO_REPLAY_TITLE=Wiedergabe dauerhaft sperren
|
||||
GUI_INFO_MEMBER=§eMitglieder
|
||||
GUI_INFO_MOVE=§eVerschieben
|
||||
GUI_INFO_RENAME=§eUmbenennen
|
||||
GUI_INFO_RENAME_TITLE={0} umbenennen
|
||||
GUI_INFO_DELETE=§cLöschen
|
||||
GUI_INFO_MEMBER_FROM=§7von §e{0}
|
||||
GUI_INFO_MEMBER_REMOVE=§cZugriff entfernen
|
||||
GUI_CHANGE_TYPE=Typ ändern
|
||||
GUI_CHANGE_TYPE_NOT_POSSIBLE=§cDie Schematic ist zu groß
|
||||
GUI_DELETE_OWN_DELETED=Schematic §e{0} §7gelöscht
|
||||
GUI_DELETE_OWN_TITLE={0} löschen
|
||||
GUI_DELETE_MEMBER_TITLE={0} entfernen
|
||||
GUI_DELETE_MEMBER_DONE=Zugriff zu Schematic §e{0} §7entfernt
|
||||
GUI_DELETE_MEMBERS_TITLE=Mitglieder entfernen
|
||||
GUI_CHANGE_ITEM=Item ändern
|
||||
|
||||
AUTO_CHECK_RESULT_NOT_LOAD=Die Schematic konnte nicht geladen werden
|
||||
AUTO_CHECK_RESULT_TOO_WIDE=Die Schematic ist zu breit ({0} > {1})
|
||||
AUTO_CHECK_RESULT_TOO_LONG=Die Schematic ist zu lang ({0} > {1})
|
||||
AUTO_CHECK_RESULT_TOO_HIGH=Die Schematic ist zu hoch ({0} > {1})
|
||||
AUTO_CHECK_RESULT_TOO_MANY_BLOCK=Der Block {0} wurde {1} mal zu häufig verbaut
|
||||
AUTO_CHECK_RESULT_TOO_MANY_BLOCKS=Die Blockkombination {0} wurde {1} mal zu häufig verbaut
|
||||
AUTO_CHECK_RESULT_TOO_MANY_ALL_BLOCKS=Zu viele Blöcke ({0} > {1})
|
||||
AUTO_CHECK_RESULT_TOO_MANY_RECORDS=Keine Schallplatten erlaubt ({0} gefunden)
|
||||
AUTO_CHECK_RESULT_FORBIDDEN_ITEM=In {0}s wurde das verbotene Item {1} {2} mal gefunden
|
||||
AUTO_CHECK_RESULT_FORBIDDEN_ITEM_NBT=In {0}s wurde das verbotene Item {1} {2} mal mit Custom-Tag gefunden
|
||||
AUTO_CHECK_RESULT_TOO_MANY_DISPENSER_ITEMS=Ein Werfer enthält mehr als {0} Pfeile und Feuerbälle
|
||||
AUTO_CHECK_RESULT_TOO_MANY_DISPENSERS_ITEMS={0} Werfer enthält mehr als {1} Pfeile und Feuerbälle
|
||||
AUTO_CHECK_RESULT_NBTS_WARNING={0} {1}s enthalten keine oder inkorrekte NBT-Daten
|
||||
AUTO_CHECK_RESULT_NBT_WARNING=Ein(e) {0} enthält keine oder inkorrekte NBT-Daten
|
||||
|
||||
SAFE_NODE_NOT_A_DIR=§cDie ausgewählte Schematic ist kein Ordner
|
||||
SAFE_NODE_ALREADY_IN_DIRECTORY=§cDie Schematic gibt es bereits in diesem Ordner
|
||||
SAFE_NODE_INVALID_NAME=§cDieser Name ist unzulässig
|
||||
SAFE_NODE_NOT_OWNER=§cDu bist nicht der Besitzer dieser Schematic
|
||||
|
||||
DOWNLOAD_ERROR=§cFehler beim Hochladen deines Clipboards
|
||||
|
||||
AUTO_CHECKER_RESULT_HEADER=§7---=== (§eAutoPrüfer: {0}§7) ===---
|
||||
AUTO_CHECKER_RESULT_WIDTH=§7Breite: §c{0}§7, Max: §e{1}
|
||||
AUTO_CHECKER_RESULT_LENGTH=§7Länge: §c{0}§7, Max: §e{1}
|
||||
AUTO_CHECKER_RESULT_HEIGHT=§7Höhe: §c{0}§7, Max: §e{1}
|
||||
AUTO_CHECKER_RESULT_BLOCKS=§7Blöcke: §c{0}§7, Max: §e{1}
|
||||
AUTO_CHECKER_RESULT_UNKNOWN_MATERIAL=§7Unbekannter Block: §c{0}
|
||||
AUTO_CHECKER_RESULT_TOO_MANY_BLOCK=§7{0}: §c{1}§7, Max: §e{2}
|
||||
AUTO_CHECKER_RESULT_FORBIDDEN_BLOCK=§7Verbotener Block: §c{0}
|
||||
AUTO_CHECKER_RESULT_FORBIDDEN_ITEM=§7Verbotener gegenstand: [{0}, {1}, {2}] -> §c{3}
|
||||
AUTO_CHECKER_RESULT_DEFUNCT_NBT=§7Keine NBT-Daten: §c[{0}, {1}, {2}]
|
||||
AUTO_CHECKER_RESULT_DESIGN_BLOCK=§7{0} im Design: [{1}, {2}, {3}]
|
||||
AUTO_CHECKER_RESULT_RECORD=§7Schallplatte: §c[{0}, {1}, {2}]
|
||||
AUTO_CHECKER_RESULT_TOO_MANY_DISPENSER_ITEMS=§7Dispenser: §c[{0}, {1}, {2}]§7, §c{3} §7gegenstände, Max: §e{4}
|
||||
AUTO_CHECKER_RESULT_FORBIDDEN_ITEM_NBT=§7Verbotene NBT-Daten: [{0}, {1}, {2}] -> §c{3}
|
||||
AUTO_CHECKER_RESULT_TELEPORT_HERE=§7Zum block teleportieren
|
||||
AUTO_CHECKER_RESULT_AFTER_DEADLINE=§cDer einsendeschluss ist bereits vorbei: {0}
|
113
SchematicSystem_Core/src/de/steamwar/schematicsystem/CheckSchemType.java
Normale Datei
113
SchematicSystem_Core/src/de/steamwar/schematicsystem/CheckSchemType.java
Normale Datei
@ -0,0 +1,113 @@
|
||||
/*
|
||||
This file is a part of the SteamWar software.
|
||||
|
||||
Copyright (C) 2020 SteamWar.de-Serverteam
|
||||
|
||||
This program is free software: you can redistribute it and/or modify
|
||||
it under the terms of the GNU Affero General Public License as published by
|
||||
the Free Software Foundation, either version 3 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 Affero General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU Affero General Public License
|
||||
along with this program. If not, see <https://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
package de.steamwar.schematicsystem;
|
||||
|
||||
import de.steamwar.sql.SchematicType;
|
||||
import lombok.Getter;
|
||||
import org.bukkit.configuration.ConfigurationSection;
|
||||
import org.bukkit.configuration.file.YamlConfiguration;
|
||||
|
||||
import java.io.File;
|
||||
import java.text.DateFormat;
|
||||
import java.text.ParseException;
|
||||
import java.text.SimpleDateFormat;
|
||||
import java.time.Instant;
|
||||
import java.util.*;
|
||||
|
||||
@Getter
|
||||
public class CheckSchemType {
|
||||
|
||||
private static final Map<SchematicType, CheckSchemType> types = new HashMap<>();
|
||||
|
||||
private final int width;
|
||||
private final int height;
|
||||
private final int depth;
|
||||
private final int maxDispenserItems;
|
||||
|
||||
private final Map<Set<String>, Integer> limits;
|
||||
private final int maxBlocks;
|
||||
|
||||
private final Date deadline;
|
||||
private final float maxBlastResistance;
|
||||
|
||||
private CheckSchemType(ConfigurationSection section) {
|
||||
String name = section.getString("Schematic.Type");
|
||||
width = section.getInt("Schematic.Size.x");
|
||||
height = section.getInt("Schematic.Size.y");
|
||||
depth = section.getInt("Schematic.Size.z");
|
||||
|
||||
maxDispenserItems = section.getInt("Schematic.MaxDispenserItems", 128);
|
||||
maxBlocks = section.getInt("Schematic.MaxBlocks", 0);
|
||||
|
||||
maxBlastResistance = (float) section.getDouble("Schematic.MaxDesignBlastResistance", Double.MAX_VALUE);
|
||||
|
||||
limits = new HashMap<>();
|
||||
for(Map<?, ?> entry : section.getMapList("Schematic.Limited")) {
|
||||
int amount = (Integer) entry.get("Amount");
|
||||
Set<String> materials = new HashSet<>((List<String>) entry.get("Materials"));
|
||||
if(amount == 0) {
|
||||
materials.forEach(material -> limits.put(Collections.singleton(material), 0));
|
||||
} else {
|
||||
limits.put(materials, amount);
|
||||
}
|
||||
}
|
||||
|
||||
String deadlineString = section.getString("deadline", null);
|
||||
if (deadlineString != null) {
|
||||
try {
|
||||
SimpleDateFormat dateFormat = new SimpleDateFormat("dd.MM.yyyy HH:mm");
|
||||
deadline = dateFormat.parse(deadlineString);
|
||||
} catch (ParseException e) {
|
||||
throw new SecurityException(e.getMessage(), e);
|
||||
}
|
||||
} else {
|
||||
deadline = null;
|
||||
}
|
||||
|
||||
types.put(SchematicType.fromDB(name.toLowerCase()), this);
|
||||
types.put(SchematicType.fromDB("c" + name.toLowerCase()), this);
|
||||
}
|
||||
|
||||
static {
|
||||
File folder = new File(SchematicSystem.getInstance().getDataFolder().getParentFile(), "FightSystem");
|
||||
|
||||
if(folder.exists()) {
|
||||
for(File configFile : folder.listFiles((file, name) -> name.endsWith(".yml") && !name.endsWith(".kits.yml"))) {
|
||||
YamlConfiguration config = YamlConfiguration.loadConfiguration(configFile);
|
||||
if (!config.isList("CheckQuestions") && config.getBoolean("Schematic.ManualCheck", true))
|
||||
continue;
|
||||
|
||||
new CheckSchemType(config);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public static CheckSchemType get(SchematicType type){
|
||||
return types.get(type);
|
||||
}
|
||||
|
||||
public Map<Set<String>, Integer> getLimits() {
|
||||
return new HashMap<>(limits);
|
||||
}
|
||||
|
||||
public boolean isAfterDeadline() {
|
||||
return deadline != null && deadline.before(Date.from(Instant.now()));
|
||||
}
|
||||
}
|
@ -0,0 +1,89 @@
|
||||
/*
|
||||
This file is a part of the SteamWar software.
|
||||
|
||||
Copyright (C) 2023 SteamWar.de-Serverteam
|
||||
|
||||
This program is free software: you can redistribute it and/or modify
|
||||
it under the terms of the GNU Affero General Public License as published by
|
||||
the Free Software Foundation, either version 3 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 Affero General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU Affero General Public License
|
||||
along with this program. If not, see <https://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
package de.steamwar.schematicsystem;
|
||||
|
||||
import de.steamwar.sql.SchematicNode;
|
||||
import de.steamwar.sql.SteamwarUser;
|
||||
import lombok.AllArgsConstructor;
|
||||
import lombok.NonNull;
|
||||
import org.bukkit.entity.Player;
|
||||
|
||||
public class SafeSchematicNode {
|
||||
|
||||
public static Result setParent(@NonNull SteamwarUser user, @NonNull SchematicNode node, SchematicNode newParent) {
|
||||
if(user.getId() != node.getOwner()) {
|
||||
return Result.NOT_OWNER;
|
||||
}
|
||||
if(newParent == null) {
|
||||
if(SchematicNode.list(user, null)
|
||||
.stream().map(SchematicNode::getName).anyMatch(s -> s.equalsIgnoreCase(node.getName()))) {
|
||||
return Result.ALREADY_IN_DIRECTORY;
|
||||
}
|
||||
|
||||
node.setParent(null);
|
||||
} else {
|
||||
if(!newParent.isDir()) {
|
||||
return Result.NOT_A_DIR;
|
||||
}
|
||||
|
||||
if(SchematicNode.list(user, newParent.getId())
|
||||
.stream().map(SchematicNode::getName).anyMatch(s -> s.equalsIgnoreCase(node.getName()))) {
|
||||
return Result.ALREADY_IN_DIRECTORY;
|
||||
}
|
||||
|
||||
node.setParent(newParent.getId());
|
||||
}
|
||||
return Result.DONE;
|
||||
}
|
||||
|
||||
public static Result setName(@NonNull SteamwarUser user, @NonNull SchematicNode node, @NonNull String name) {
|
||||
if(user.getId() != node.getOwner()) {
|
||||
return Result.NOT_OWNER;
|
||||
}
|
||||
|
||||
if(SchematicNode.invalidSchemName(new String[]{name})) {
|
||||
return Result.INVALID_NAME;
|
||||
}
|
||||
|
||||
if(SchematicNode.list(user, node.getParent()).stream().map(SchematicNode::getName).anyMatch(s -> s.equalsIgnoreCase(name))) {
|
||||
return Result.ALREADY_IN_DIRECTORY;
|
||||
}
|
||||
|
||||
node.setName(name);
|
||||
return Result.DONE;
|
||||
}
|
||||
|
||||
@AllArgsConstructor
|
||||
public enum Result {
|
||||
DONE,
|
||||
NOT_A_DIR,
|
||||
ALREADY_IN_DIRECTORY,
|
||||
INVALID_NAME,
|
||||
NOT_OWNER;
|
||||
|
||||
public void sendError(Player player) {
|
||||
SchematicSystem.MESSAGE.send("SAFE_NODE_" + this.name(), player);
|
||||
}
|
||||
|
||||
public boolean isSuccessful() {
|
||||
return this == DONE;
|
||||
}
|
||||
}
|
||||
}
|
@ -0,0 +1,48 @@
|
||||
/*
|
||||
This file is a part of the SteamWar software.
|
||||
|
||||
Copyright (C) 2023 SteamWar.de-Serverteam
|
||||
|
||||
This program is free software: you can redistribute it and/or modify
|
||||
it under the terms of the GNU Affero General Public License as published by
|
||||
the Free Software Foundation, either version 3 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 Affero General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU Affero General Public License
|
||||
along with this program. If not, see <https://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
package de.steamwar.schematicsystem;
|
||||
|
||||
import de.steamwar.message.Message;
|
||||
import de.steamwar.schematicsystem.commands.DownloadCommand;
|
||||
import de.steamwar.schematicsystem.commands.schematiccommand.SchematicCommand;
|
||||
import de.steamwar.schematicsystem.commands.schematiccommand.SchematicCommandInitializer;
|
||||
import de.steamwar.schematicsystem.listener.PlayerEventListener;
|
||||
import org.bukkit.Bukkit;
|
||||
import org.bukkit.plugin.java.JavaPlugin;
|
||||
|
||||
public class SchematicSystem extends JavaPlugin {
|
||||
public static final Message MESSAGE = new Message("SchematicSystem", SchematicSystem.class.getClassLoader());
|
||||
|
||||
private static SchematicSystem instance;
|
||||
|
||||
@Override
|
||||
public void onEnable() {
|
||||
instance = this;
|
||||
|
||||
SchematicCommandInitializer.init();
|
||||
new DownloadCommand();
|
||||
|
||||
Bukkit.getPluginManager().registerEvents(new PlayerEventListener(), this);
|
||||
}
|
||||
|
||||
public static SchematicSystem getInstance() {
|
||||
return instance;
|
||||
}
|
||||
}
|
@ -0,0 +1,60 @@
|
||||
/*
|
||||
This file is a part of the SteamWar software.
|
||||
|
||||
Copyright (C) 2023 SteamWar.de-Serverteam
|
||||
|
||||
This program is free software: you can redistribute it and/or modify
|
||||
it under the terms of the GNU Affero General Public License as published by
|
||||
the Free Software Foundation, either version 3 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 Affero General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU Affero General Public License
|
||||
along with this program. If not, see <https://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
package de.steamwar.schematicsystem.autocheck;
|
||||
|
||||
import com.sk89q.worldedit.extent.clipboard.Clipboard;
|
||||
import de.steamwar.core.VersionDependent;
|
||||
import de.steamwar.schematicsystem.CheckSchemType;
|
||||
import de.steamwar.schematicsystem.SchematicSystem;
|
||||
import lombok.Getter;
|
||||
import lombok.ToString;
|
||||
import org.bukkit.Material;
|
||||
|
||||
import java.util.*;
|
||||
|
||||
public class AutoChecker {
|
||||
|
||||
public static AutoCheckerResult check(Clipboard clipboard, CheckSchemType type) {
|
||||
return impl.check(clipboard, type);
|
||||
}
|
||||
|
||||
public static AutoCheckerResult sizeCheck(Clipboard clipboard, CheckSchemType type) {
|
||||
return impl.sizeCheck(clipboard, type);
|
||||
}
|
||||
|
||||
private static final IAutoChecker impl = VersionDependent.getVersionImpl(SchematicSystem.getInstance());
|
||||
|
||||
public interface IAutoChecker {
|
||||
AutoCheckerResult check(Clipboard clipboard, CheckSchemType type);
|
||||
AutoCheckerResult sizeCheck(Clipboard clipboard, CheckSchemType type);
|
||||
}
|
||||
|
||||
@Getter
|
||||
@ToString
|
||||
public static class BlockScanResult {
|
||||
private final Map<Material, Integer> blockCounts = new EnumMap<>(Material.class);
|
||||
private final List<BlockPos> defunctNbt = new ArrayList<>();
|
||||
private final List<BlockPos> records = new ArrayList<>();
|
||||
private final Map<Material, List<BlockPos>> designBlocks = new EnumMap<>(Material.class);
|
||||
private final Map<BlockPos, Integer> dispenserItems = new HashMap<>();
|
||||
private final Map<BlockPos, Set<Material>> forbiddenItems = new HashMap<>();
|
||||
private final Map<BlockPos, Set<Material>> forbiddenNbt = new HashMap<>();
|
||||
}
|
||||
}
|
@ -0,0 +1,168 @@
|
||||
/*
|
||||
This file is a part of the SteamWar software.
|
||||
|
||||
Copyright (C) 2023 SteamWar.de-Serverteam
|
||||
|
||||
This program is free software: you can redistribute it and/or modify
|
||||
it under the terms of the GNU Affero General Public License as published by
|
||||
the Free Software Foundation, either version 3 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 Affero General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU Affero General Public License
|
||||
along with this program. If not, see <https://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
package de.steamwar.schematicsystem.autocheck;
|
||||
|
||||
import de.steamwar.schematicsystem.CheckSchemType;
|
||||
import de.steamwar.schematicsystem.SchematicSystem;
|
||||
import lombok.Builder;
|
||||
import lombok.Getter;
|
||||
import lombok.ToString;
|
||||
import net.md_5.bungee.api.chat.ClickEvent;
|
||||
import org.bukkit.Material;
|
||||
import org.bukkit.entity.Player;
|
||||
|
||||
import java.util.*;
|
||||
|
||||
@Builder
|
||||
@Getter
|
||||
@ToString
|
||||
public class AutoCheckerResult {
|
||||
private final CheckSchemType type;
|
||||
private final int width;
|
||||
private final int height;
|
||||
private final int depth;
|
||||
private final AutoChecker.BlockScanResult blockScanResult;
|
||||
private final List<BlockPos> entities;
|
||||
|
||||
public boolean isOk() {
|
||||
return blockScanResult.getRecords().isEmpty() &&
|
||||
blockScanResult.getForbiddenItems().isEmpty() &&
|
||||
blockScanResult.getForbiddenNbt().isEmpty() &&
|
||||
isSizeOk() &&
|
||||
isBlockCountOk() &&
|
||||
isLimitedBlocksOK() &&
|
||||
isDispenserItemsOK() &&
|
||||
!type.isAfterDeadline() &&
|
||||
entities.isEmpty() &&
|
||||
isDesignBlastResistanceOK();
|
||||
}
|
||||
|
||||
public boolean fastOk() {
|
||||
return isSizeOk() &&
|
||||
!type.isAfterDeadline();
|
||||
}
|
||||
|
||||
public boolean isDispenserItemsOK() {
|
||||
return blockScanResult.getDispenserItems().values().stream().allMatch(i -> i <= type.getMaxDispenserItems());
|
||||
}
|
||||
|
||||
public boolean hasWarnings() {
|
||||
return blockScanResult.getDefunctNbt().isEmpty();
|
||||
}
|
||||
|
||||
public boolean isSizeOk() {
|
||||
return !isTooWide() && !isTooHigh() && !isTooDeep();
|
||||
}
|
||||
|
||||
public boolean isTooWide() {
|
||||
return width > type.getWidth();
|
||||
}
|
||||
|
||||
public boolean isTooHigh() {
|
||||
return height > type.getHeight();
|
||||
}
|
||||
|
||||
public boolean isTooDeep() {
|
||||
return depth > type.getDepth();
|
||||
}
|
||||
|
||||
public boolean isBlockCountOk() {
|
||||
return type.getMaxBlocks() == 0 || blockScanResult.getBlockCounts().entrySet().stream().filter(entry -> entry.getKey() != Material.AIR).map(Map.Entry::getValue).reduce(Integer::sum).map(i -> i <= type.getMaxBlocks()).orElse(false);
|
||||
}
|
||||
|
||||
public boolean isLimitedBlocksOK() {
|
||||
try {
|
||||
return type.getLimits().entrySet().stream()
|
||||
.map(setIntegerEntry -> setIntegerEntry.getKey().stream().map(Material::getMaterial).map(blockScanResult.getBlockCounts()::get).map(i -> i == null || i <= setIntegerEntry.getValue()).reduce(Boolean::logicalAnd).orElse(false))
|
||||
.reduce(Boolean::logicalAnd).orElse(true);
|
||||
} catch (NullPointerException e) {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
public boolean isDesignBlastResistanceOK() {
|
||||
return blockScanResult.getDesignBlocks().keySet().stream().map(Material::getBlastResistance).noneMatch(i -> i > type.getMaxBlastResistance());
|
||||
}
|
||||
|
||||
public void sendErrorMessage(Player p, String schemName) {
|
||||
SchematicSystem.MESSAGE.sendPrefixless("AUTO_CHECKER_RESULT_HEADER", p, schemName);
|
||||
if(isTooWide()) SchematicSystem.MESSAGE.sendPrefixless("AUTO_CHECKER_RESULT_WIDTH", p, width, type.getWidth());
|
||||
if(isTooHigh()) SchematicSystem.MESSAGE.sendPrefixless("AUTO_CHECKER_RESULT_HEIGHT", p, height, type.getHeight());
|
||||
if(isTooDeep()) SchematicSystem.MESSAGE.sendPrefixless("AUTO_CHECKER_RESULT_LENGTH", p, depth, type.getDepth());
|
||||
if(type.getMaxBlocks() != 0 && !isBlockCountOk()) {
|
||||
SchematicSystem.MESSAGE.sendPrefixless("AUTO_CHECKER_RESULT_BLOCKS", p, blockScanResult.getBlockCounts().values().stream().reduce(Integer::sum).orElse(0), type.getMaxBlocks());
|
||||
}
|
||||
if(!isLimitedBlocksOK()) {
|
||||
type.getLimits().forEach((strings, integer) -> {
|
||||
for (String string : strings) {
|
||||
Material mat = Material.matchMaterial(string);
|
||||
if(mat != null && blockScanResult.getBlockCounts().getOrDefault(mat, 0) > integer) {
|
||||
if(integer == 0) {
|
||||
SchematicSystem.MESSAGE.sendPrefixless("AUTO_CHECKER_RESULT_FORBIDDEN_BLOCK", p, mat.name());
|
||||
} else {
|
||||
SchematicSystem.MESSAGE.sendPrefixless("AUTO_CHECKER_RESULT_TOO_MANY_BLOCK", p, mat.name(), blockScanResult.getBlockCounts().getOrDefault(mat, 0), integer);
|
||||
}
|
||||
}
|
||||
}
|
||||
});
|
||||
}
|
||||
blockScanResult.getDispenserItems().entrySet().stream().filter(blockVector3IntegerEntry -> blockVector3IntegerEntry.getValue() > type.getMaxDispenserItems()).forEach(blockVector3IntegerEntry -> {
|
||||
SchematicSystem.MESSAGE.sendPrefixless("AUTO_CHECKER_RESULT_TOO_MANY_DISPENSER_ITEMS", p, SchematicSystem.MESSAGE.parse("AUTO_CHECKER_RESULT_TELEPORT_HERE", p), tpCommandTo(blockVector3IntegerEntry.getKey()),
|
||||
blockVector3IntegerEntry.getKey().getBlockX(),
|
||||
blockVector3IntegerEntry.getKey().getBlockY(),
|
||||
blockVector3IntegerEntry.getKey().getBlockZ(),
|
||||
blockVector3IntegerEntry.getValue(),
|
||||
type.getMaxDispenserItems());
|
||||
});
|
||||
blockScanResult.getRecords().forEach(blockVector3 -> {
|
||||
SchematicSystem.MESSAGE.sendPrefixless("AUTO_CHECKER_RESULT_RECORD", p, SchematicSystem.MESSAGE.parse("AUTO_CHECKER_RESULT_TELEPORT_HERE", p), tpCommandTo(blockVector3), blockVector3.getBlockX(), blockVector3.getBlockY(), blockVector3.getBlockZ());
|
||||
});
|
||||
blockScanResult.getForbiddenItems().forEach((blockVector3, materials) -> {
|
||||
SchematicSystem.MESSAGE.sendPrefixless("AUTO_CHECKER_RESULT_FORBIDDEN_ITEM", p, SchematicSystem.MESSAGE.parse("AUTO_CHECKER_RESULT_TELEPORT_HERE", p), tpCommandTo(blockVector3), blockVector3.getX(), blockVector3.getY(), blockVector3.getZ(), setToString(materials));
|
||||
});
|
||||
blockScanResult.getForbiddenNbt().forEach((blockVector3, materials) -> {
|
||||
SchematicSystem.MESSAGE.sendPrefixless("AUTO_CHECKER_RESULT_FORBIDDEN_ITEM_NBT", p, SchematicSystem.MESSAGE.parse("AUTO_CHECKER_RESULT_TELEPORT_HERE", p), tpCommandTo(blockVector3), blockVector3.getX(), blockVector3.getY(), blockVector3.getZ(), setToString(materials));
|
||||
});
|
||||
blockScanResult.getDefunctNbt().forEach(blockVector3 -> {
|
||||
SchematicSystem.MESSAGE.sendPrefixless("AUTO_CHECKER_RESULT_DEFUNCT_NBT", p, SchematicSystem.MESSAGE.parse("AUTO_CHECKER_RESULT_TELEPORT_HERE", p), tpCommandTo(blockVector3), blockVector3.getX(), blockVector3.getY(), blockVector3.getZ());
|
||||
});
|
||||
blockScanResult.getDesignBlocks().forEach((material, poss) -> {
|
||||
if(material.getBlastResistance() > type.getMaxBlastResistance()) {
|
||||
poss.forEach(pos -> {
|
||||
SchematicSystem.MESSAGE.sendPrefixless("AUTO_CHECKER_RESULT_DESIGN_BLOCK", p, SchematicSystem.MESSAGE.parse("AUTO_CHECKER_RESULT_TELEPORT_HERE", p), tpCommandTo(pos), material.name(), pos.getBlockX(), pos.getBlockY(), pos.getBlockZ());
|
||||
});
|
||||
}
|
||||
});
|
||||
entities.forEach(blockPos -> {
|
||||
SchematicSystem.MESSAGE.sendPrefixless("AUTO_CHECKER_RESULT_ENTITY", p, SchematicSystem.MESSAGE.parse("AUTO_CHECKER_RESULT_TELEPORT_HERE", p), tpCommandTo(blockPos), blockPos.getX(), blockPos.getY(), blockPos.getZ());
|
||||
});
|
||||
if(type.isAfterDeadline()) {
|
||||
SchematicSystem.MESSAGE.sendPrefixless("AUTO_CHECKER_RESULT_AFTER_DEADLINE", p, type.getDeadline());
|
||||
}
|
||||
}
|
||||
|
||||
private static ClickEvent tpCommandTo(BlockPos pos) {
|
||||
return new ClickEvent(ClickEvent.Action.RUN_COMMAND, "/tp " + pos.getBlockX() + " " + pos.getBlockY() + " " + pos.getBlockZ());
|
||||
}
|
||||
|
||||
private static String setToString(Collection<Material> set) {
|
||||
return set.stream().map(material -> material.getKey().getKey()).reduce((s, s2) -> s + "§7, §c" + s2).orElse("");
|
||||
}
|
||||
}
|
@ -1,7 +1,7 @@
|
||||
/*
|
||||
/*
|
||||
This file is a part of the SteamWar software.
|
||||
|
||||
Copyright (C) 2020 SteamWar.de-Serverteam
|
||||
|
||||
Copyright (C) 2022 SteamWar.de-Serverteam
|
||||
|
||||
This program is free software: you can redistribute it and/or modify
|
||||
it under the terms of the GNU Affero General Public License as published by
|
||||
@ -17,22 +17,34 @@
|
||||
along with this program. If not, see <https://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
package de.steamwar.schematicsystem;
|
||||
package de.steamwar.schematicsystem.autocheck;
|
||||
|
||||
import java.util.List;
|
||||
import lombok.AllArgsConstructor;
|
||||
import lombok.EqualsAndHashCode;
|
||||
import lombok.Getter;
|
||||
import lombok.ToString;
|
||||
|
||||
interface ICheckSchemType {
|
||||
String getName();
|
||||
/*
|
||||
* Can be removed with 1.12 support removal
|
||||
*/
|
||||
@Getter
|
||||
@AllArgsConstructor
|
||||
@ToString
|
||||
@EqualsAndHashCode
|
||||
public class BlockPos {
|
||||
private int x;
|
||||
private int y;
|
||||
private int z;
|
||||
|
||||
int getWidth();
|
||||
int getHeight();
|
||||
int getDepth();
|
||||
int getMaxDispenserItems();
|
||||
int getMaxDispenser();
|
||||
int getMaxTNT();
|
||||
int getMaxTNTSlime();
|
||||
int getMaxSlime();
|
||||
int getMaxBlocks();
|
||||
public int getBlockX() {
|
||||
return x;
|
||||
}
|
||||
|
||||
List<String> getForbidden();
|
||||
public int getBlockY() {
|
||||
return y;
|
||||
}
|
||||
|
||||
public int getBlockZ() {
|
||||
return z;
|
||||
}
|
||||
}
|
@ -0,0 +1,63 @@
|
||||
/*
|
||||
This file is a part of the SteamWar software.
|
||||
|
||||
Copyright (C) 2023 SteamWar.de-Serverteam
|
||||
|
||||
This program is free software: you can redistribute it and/or modify
|
||||
it under the terms of the GNU Affero General Public License as published by
|
||||
the Free Software Foundation, either version 3 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 Affero General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU Affero General Public License
|
||||
along with this program. If not, see <https://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
package de.steamwar.schematicsystem.commands;
|
||||
|
||||
import de.steamwar.command.SWCommand;
|
||||
import de.steamwar.schematicsystem.SchematicSystem;
|
||||
import de.steamwar.schematicsystem.commands.schematiccommand.SchematicCommandUtils;
|
||||
import de.steamwar.sql.*;
|
||||
import org.bukkit.entity.Player;
|
||||
|
||||
import java.io.IOException;
|
||||
|
||||
public class DownloadCommand extends SWCommand {
|
||||
public DownloadCommand() {
|
||||
super("download", "/download");
|
||||
}
|
||||
|
||||
@Register(help = true)
|
||||
public void genericCommand(Player player, String... args) {
|
||||
SteamwarUser user = SteamwarUser.get(player.getUniqueId());
|
||||
SchematicNode copyNode = SchematicNode.getSchematicNode(user.getId(), "//copy", 0);
|
||||
boolean newSchem = false;
|
||||
if(copyNode == null) {
|
||||
copyNode = SchematicNode.createSchematicNode(user.getId(), "//copy", 0, SchematicType.Normal.toDB(), "");
|
||||
newSchem = true;
|
||||
}
|
||||
|
||||
try {
|
||||
new SchematicData(copyNode).saveFromPlayer(player);
|
||||
} catch (IOException e) {
|
||||
SchematicSystem.MESSAGE.send("DOWNLOAD_ERROR", player);
|
||||
if(newSchem) {
|
||||
copyNode.delete();
|
||||
}
|
||||
throw new SecurityException(e);
|
||||
} catch (NoClipboardException e) {
|
||||
SchematicSystem.MESSAGE.send("COMMAND_SAVE_CLIPBOARD_EMPTY", player);
|
||||
if(newSchem) {
|
||||
copyNode.delete();
|
||||
}
|
||||
return;
|
||||
}
|
||||
|
||||
SchematicCommandUtils.download(player, copyNode);
|
||||
}
|
||||
}
|
@ -0,0 +1,321 @@
|
||||
/*
|
||||
This file is a part of the SteamWar software.
|
||||
|
||||
Copyright (C) 2023 SteamWar.de-Serverteam
|
||||
|
||||
This program is free software: you can redistribute it and/or modify
|
||||
it under the terms of the GNU Affero General Public License as published by
|
||||
the Free Software Foundation, either version 3 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 Affero General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU Affero General Public License
|
||||
along with this program. If not, see <https://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
package de.steamwar.schematicsystem.commands.schematiccommand;
|
||||
|
||||
import com.sk89q.worldedit.extent.clipboard.Clipboard;
|
||||
import de.steamwar.core.Core;
|
||||
import de.steamwar.inventory.*;
|
||||
import de.steamwar.schematicsystem.CheckSchemType;
|
||||
import de.steamwar.schematicsystem.SafeSchematicNode;
|
||||
import de.steamwar.schematicsystem.SchematicSystem;
|
||||
import de.steamwar.schematicsystem.autocheck.AutoChecker;
|
||||
import de.steamwar.schematicsystem.commands.schematiccommand.SchematicCommandUtils;
|
||||
import de.steamwar.sql.*;
|
||||
import org.bukkit.Bukkit;
|
||||
import org.bukkit.Material;
|
||||
import org.bukkit.entity.Player;
|
||||
import org.bukkit.event.inventory.ClickType;
|
||||
|
||||
import java.io.IOException;
|
||||
import java.util.*;
|
||||
import java.util.concurrent.atomic.AtomicBoolean;
|
||||
import java.util.stream.Collectors;
|
||||
|
||||
import static de.steamwar.schematicsystem.commands.schematiccommand.SchematicCommandUtils.*;
|
||||
|
||||
public class GUI {
|
||||
private GUI() {}
|
||||
|
||||
public static void list(Player player) {
|
||||
SchematicSelector selector = new SchematicSelector(player, SchematicSelector.selectSchematic(), new SchematicSelectorInjectable() {
|
||||
@Override
|
||||
public String createTitle(Player player) {
|
||||
return SchematicSystem.MESSAGE.parse("GUI_TITLE", player);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onListRender(SchematicSelector selector, SWListInv<SchematicNode> inv, SchematicNode parent) {
|
||||
inv.setCallback(-999, (ClickType click) -> {
|
||||
if(parent == null) {
|
||||
player.closeInventory();
|
||||
} else {
|
||||
selector.reOpenDirUp();
|
||||
}
|
||||
});
|
||||
if(parent == null) {
|
||||
inv.setItem(49, Material.AIR, "", clickType -> {});
|
||||
} else {
|
||||
inv.setItem(49, Material.ANVIL, SchematicSystem.MESSAGE.parse("GUI_FOLDER_PROPERTIES", player), clickType -> {
|
||||
info(selector.getPlayer(), parent, selector);
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public AnvilInvCloseAction onAnvilInvCloseAction(SchematicSelector selector) {
|
||||
return AnvilInvCloseAction.REOPEN;
|
||||
}
|
||||
}, node -> {});
|
||||
selector.setCallback(node -> info(player, node, selector));
|
||||
selector.setSingleDirOpen(false);
|
||||
selector.open();
|
||||
}
|
||||
|
||||
private static void setCloseLeftCallback(SWAnvilInv inv, Runnable action) {
|
||||
AtomicBoolean left = new AtomicBoolean(false);
|
||||
inv.addCloseCallback(() -> {
|
||||
if(!left.get()) {
|
||||
Bukkit.getScheduler().runTaskLater(SchematicSystem.getInstance(), action, 1);
|
||||
}
|
||||
});
|
||||
inv.addLeftCallback(() -> {
|
||||
left.set(true);
|
||||
action.run();
|
||||
});
|
||||
}
|
||||
|
||||
private static void info(Player player, SchematicNode node, SchematicSelector back) {
|
||||
SteamwarUser user = getUser(player);
|
||||
SWInventory inv = new SWInventory(player, 9 * 2, node.generateBreadcrumbs());
|
||||
if(!node.isDir()) {
|
||||
inv.setItem(0, SWItem.getMaterial("WOOD_AXE"), SchematicSystem.MESSAGE.parse("GUI_INFO_LOAD", player), click -> {
|
||||
player.closeInventory();
|
||||
SchematicCommandUtils.loadSchem(player, node);
|
||||
});
|
||||
}
|
||||
|
||||
inv.setItem(9, SWItem.getMaterial("LEASH"), SchematicSystem.MESSAGE.parse("GUI_INFO_BACK", player), clickType -> {
|
||||
back.reOpen();
|
||||
});
|
||||
|
||||
if(node.getOwner() == user.getId()){
|
||||
if(!node.isDir() && node.getSchemtype().writeable()){
|
||||
CheckedSchematic.getLastDeclinedOfNode(node.getId()).stream().findFirst().ifPresent(checkedSchematic ->
|
||||
inv.setItem(1, SWItem.getDye(10), (byte) 10, SchematicSystem.MESSAGE.parse("GUI_INFO_STATUS", player, node.getSchemtype().name()), Collections.singletonList(SchematicSystem.MESSAGE.parse("GUI_INFO_STATUS_LORE", player, checkedSchematic.getDeclineReason().replaceAll("&", "§"))), false, click -> {}));
|
||||
}
|
||||
Material mat = SWItem.getMaterial(node.getItem());
|
||||
|
||||
inv.setItemEvent(node.isDir()?7:5, mat, SchematicSystem.MESSAGE.parse("GUI_INFO_MAT", player, mat.name()), Arrays.asList(SchematicSystem.MESSAGE.parse("CHANGE", player), SchematicSystem.MESSAGE.parse("CLICK_DRAG_ITEM", player)), false, event -> {
|
||||
if(event.getCursor() != null && event.getCursor().getType() != Material.AIR) {
|
||||
node.setItem(event.getCursor().getType().name());
|
||||
info(player, node, back);
|
||||
} else {
|
||||
changeItem(player, node, back);
|
||||
}
|
||||
});
|
||||
if(!node.isDir()) {
|
||||
inv.setItem(6, SWItem.getMaterial(node.getSchemtype().getMaterial()), SchematicSystem.MESSAGE.parse("GUI_INFO_TYPE", player, node.getSchemtype().name()), Arrays.asList(SchematicSystem.MESSAGE.parse("CHANGE", player), SchematicSystem.MESSAGE.parse("CLICK", player)), node.getSchemtype().fightType(), click -> {
|
||||
changeType(player, node);
|
||||
});
|
||||
inv.setItem(7, SWItem.getMaterial("MAGENTA_GLAZED_TERRACOTTA"), SchematicSystem.MESSAGE.parse("GUI_INFO_DOWNLOAD", player), click -> {
|
||||
player.closeInventory();
|
||||
SchematicCommandUtils.download(player, node);
|
||||
});
|
||||
if(node.getSchemtype().fightType()) {
|
||||
inv.setItem(14, SWItem.getMaterial(node.replaceColor() ? "PINK_WOOL" : "LIGHT_GRAY_WOOL"), SchematicSystem.MESSAGE.parse("GUI_INFO_COLOR", player), Arrays.asList(SchematicSystem.MESSAGE.parse("CURRENT", player, SchematicSystem.MESSAGE.parse(node.replaceColor()?"ON":"OFF", player)), SchematicSystem.MESSAGE.parse("CHANGE", player), SchematicSystem.MESSAGE.parse("CLICK", player)), false, clickType -> {
|
||||
node.setReplaceColor(!node.replaceColor());
|
||||
info(player, node, back);
|
||||
});
|
||||
inv.setItem(13, SWItem.getMaterial(node.allowReplay() ? "EYE_OF_ENDER" : "ENDER_PEARL"), SchematicSystem.MESSAGE.parse("GUI_INFO_REPLAY", player), Arrays.asList(SchematicSystem.MESSAGE.parse("CURRENT", player, SchematicSystem.MESSAGE.parse(node.allowReplay()?"ON":"OFF", player)), SchematicSystem.MESSAGE.parse("GUI_INFO_REPLAY_OFF", player), SchematicSystem.MESSAGE.parse("CLICK", player)), false, clickType -> {
|
||||
if(node.allowReplay()) {
|
||||
SWInventory confInv = new SWInventory(player, 9, SchematicSystem.MESSAGE.parse("GUI_INFO_REPLAY_TITLE", player));
|
||||
confInv.setItem(0, SWItem.getDye(10), (byte) 10, SchematicSystem.MESSAGE.parse("CONFIRM", player), type -> {
|
||||
node.setAllowReplay(false);
|
||||
info(player, node, back);
|
||||
});
|
||||
confInv.setItem(8, SWItem.getDye(1), (byte) 1, SchematicSystem.MESSAGE.parse("CANCEL", player), type -> {
|
||||
info(player, node, back);
|
||||
});
|
||||
confInv.open();
|
||||
}
|
||||
});
|
||||
}
|
||||
}
|
||||
SWItem skull = SWItem.getPlayerSkull("MHF_STEVE");
|
||||
skull.setCallback(click -> {
|
||||
player.closeInventory();
|
||||
delmembers(player, node);
|
||||
});
|
||||
skull.setName(SchematicSystem.MESSAGE.parse("GUI_INFO_MEMBER", player));
|
||||
inv.setItem(8, skull);
|
||||
inv.setItem(16, Material.NAME_TAG, SchematicSystem.MESSAGE.parse("GUI_INFO_RENAME", player), clickType -> {
|
||||
SWAnvilInv anvilInv = new SWAnvilInv(player, SchematicSystem.MESSAGE.parse("GUI_INFO_RENAME_TITLE", player, node.getName()), node.getName());
|
||||
anvilInv.setItem(mat, Collections.singletonList(Core.MESSAGE.parse("SCHEM_SELECTOR_CLICK_BACK", player)), false);
|
||||
anvilInv.setCallback(s -> {
|
||||
SafeSchematicNode.Result result = SafeSchematicNode.setName(user, node, s);
|
||||
if(result.isSuccessful()) {
|
||||
info(player, SchematicNode.byIdAndUser(user, node.getId()), back);
|
||||
} else {
|
||||
result.sendError(player);
|
||||
}
|
||||
});
|
||||
setCloseLeftCallback(anvilInv, () -> info(player, node, back));
|
||||
anvilInv.open();
|
||||
});
|
||||
if(node.getOwner() != 0) {
|
||||
inv.setItem(17, SWItem.getDye(1), (byte) 1, SchematicSystem.MESSAGE.parse("GUI_INFO_DELETE", player), click -> {
|
||||
delete(player, node, back);
|
||||
});
|
||||
}
|
||||
}else{
|
||||
if(!node.isDir()) {
|
||||
inv.setItem(4, SWItem.getMaterial("CAULDRON_ITEM"), SchematicSystem.MESSAGE.parse("GUI_INFO_TYPE", player, node.getSchemtype().name()), Collections.emptyList(), node.getSchemtype().fightType(), click -> {});
|
||||
}
|
||||
|
||||
SteamwarUser owneruser = SteamwarUser.get(node.getOwner());
|
||||
SWItem skull = SWItem.getPlayerSkull(owneruser.getUserName());
|
||||
skull.setName(SchematicSystem.MESSAGE.parse("GUI_INFO_MEMBER_FROM", player, owneruser.getUserName()));
|
||||
inv.setItem(8, skull.getItemStack(), clickType -> {});
|
||||
|
||||
if(NodeMember.getNodeMember(node.getId(), user.getId()) != null) {
|
||||
inv.setItem(17, SWItem.getDye(1), (byte) 1, SchematicSystem.MESSAGE.parse("GUI_INFO_MEMBER_REMOVE", player), click -> {
|
||||
delete(player, node, back);
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
if(node.getOwner() == user.getId() || NodeMember.getNodeMember(node.getId(), user.getId()) != null) {
|
||||
inv.setItem(15, Material.ARROW, SchematicSystem.MESSAGE.parse("GUI_INFO_MOVE", player), clickType -> {
|
||||
SchematicSelector selector = new SchematicSelector(player, SchematicSelector.selectDirectory(), npar -> {
|
||||
if(npar != null && SchematicNode.parentsOfNode(user, npar.getId()).stream().anyMatch(n -> n.getId() == node.getId())) {
|
||||
SchematicSystem.MESSAGE.send("COMMAND_MOVE_RECURSIVE", player);
|
||||
return;
|
||||
}
|
||||
if(node.getOwner() == user.getId()) {
|
||||
SafeSchematicNode.Result result = SafeSchematicNode.setParent(user, node, npar);
|
||||
if(result.isSuccessful()) {
|
||||
info(player, SchematicNode.getSchematicNode(node.getId()), back);
|
||||
} else {
|
||||
result.sendError(player);
|
||||
}
|
||||
} else {
|
||||
NodeMember.getNodeMember(node.getId(), user.getId()).setParentId(Optional.ofNullable(npar).map(SchematicNode::getId).orElse(null));
|
||||
}
|
||||
});
|
||||
selector.open();
|
||||
});
|
||||
}
|
||||
|
||||
inv.setCallback(-999, click -> back.reOpen());
|
||||
inv.open();
|
||||
}
|
||||
|
||||
static void changeType(Player p, SchematicNode schem){
|
||||
Clipboard clipboard = null;
|
||||
try {
|
||||
clipboard = new SchematicData(schem).load();
|
||||
} catch (IOException ignored) { }
|
||||
|
||||
Clipboard finalClipboard = clipboard;
|
||||
List<SchematicType> types = SchematicType.values().parallelStream()
|
||||
.filter(SchematicType::isAssignable)
|
||||
.filter(type -> finalClipboard == null || CheckSchemType.get(type) == null || AutoChecker.sizeCheck(finalClipboard, CheckSchemType.get(type)).fastOk())
|
||||
.collect(Collectors.toList());
|
||||
|
||||
List<SWListInv.SWListEntry<SchematicType>> items = types.stream()
|
||||
.map(type -> new SWListInv.SWListEntry<>(new SWItem(SWItem.getMaterial(type.getMaterial()), type.name(), Collections.emptyList(), type.fightType(), null), type))
|
||||
.collect(Collectors.toList());
|
||||
|
||||
items.addAll(SchematicType.values().stream()
|
||||
.filter(SchematicType::isAssignable)
|
||||
.filter(type -> !types.contains(type))
|
||||
.map(type -> new SWListInv.SWListEntry<>(new SWItem(SWItem.getMaterial(type.getMaterial()), SchematicSystem.MESSAGE.parse("GUI_CHANGE_TYPE_NOT_POSSIBLE_COLOR", p, type.name()), Collections.singletonList(SchematicSystem.MESSAGE.parse("GUI_CHANGE_TYPE_NOT_POSSIBLE", p)), false, null), (SchematicType) null))
|
||||
.collect(Collectors.toList()));
|
||||
|
||||
SWListInv<SchematicType> inv = new SWListInv<>(p, SchematicSystem.MESSAGE.parse("GUI_CHANGE_TYPE", p), items, (clickType, schematicType) -> {
|
||||
if(schematicType == null) return;
|
||||
p.closeInventory();
|
||||
SchematicCommandUtils.changeType(p, schem, schematicType, null);
|
||||
});
|
||||
inv.setCallback(-999, (ClickType click) -> p.closeInventory());
|
||||
inv.open();
|
||||
}
|
||||
|
||||
private static void deleteOwn(Player p, SchematicNode schem, SchematicSelector back){
|
||||
SteamwarUser user = getUser(p);
|
||||
SWInventory inv = new SWInventory(p, 9, SchematicSystem.MESSAGE.parse("GUI_DELETE_OWN_TITLE", p, schem.generateBreadcrumbs()));
|
||||
inv.setItem(0, SWItem.getDye(1), (byte) 1, SchematicSystem.MESSAGE.parse("CONFIRM", p), click -> {
|
||||
p.performCommand("schematic delete " + schem.generateBreadcrumbs());
|
||||
|
||||
if(back != null) {
|
||||
if(schem.isDir()) {
|
||||
back.reOpenDirUp();
|
||||
} else {
|
||||
back.reOpen();
|
||||
}
|
||||
}
|
||||
});
|
||||
inv.setItem(8, SWItem.getDye(14), (byte) 14, SchematicSystem.MESSAGE.parse("CANCEL", p), click -> p.closeInventory());
|
||||
inv.setCallback(-999, click -> p.closeInventory());
|
||||
inv.open();
|
||||
}
|
||||
|
||||
private static void deleteMembership(Player p, SchematicNode schem, SchematicSelector back){
|
||||
SteamwarUser user = getUser(p);
|
||||
SWInventory inv = new SWInventory(p, 9, SchematicSystem.MESSAGE.parse("GUI_DELETE_MEMBER_TITLE", p, schem.generateBreadcrumbs()));
|
||||
inv.setItem(0, SWItem.getDye(1), (byte) 1, SchematicSystem.MESSAGE.parse("CONFIRM", p), click -> {
|
||||
NodeMember member = NodeMember.getNodeMember(schem.getId(), user.getId());
|
||||
if(member != null)
|
||||
member.delete();
|
||||
SchematicSystem.MESSAGE.send("GUI_DELETE_MEMBER_DONE", p, schem.generateBreadcrumbs());
|
||||
if(back != null) {
|
||||
if(schem.isDir()) {
|
||||
back.reOpenDirUp();
|
||||
} else {
|
||||
back.reOpen();
|
||||
}
|
||||
}
|
||||
});
|
||||
inv.setItem(8, SWItem.getDye(14), (byte) 14, SchematicSystem.MESSAGE.parse("CANCEL", p), click -> p.closeInventory());
|
||||
inv.setCallback(-999, click -> p.closeInventory());
|
||||
inv.open();
|
||||
}
|
||||
|
||||
static void delete(Player p, SchematicNode schem, SchematicSelector back){
|
||||
if(SteamwarUser.get(p.getUniqueId()).getId() == schem.getOwner())
|
||||
deleteOwn(p, schem, back);
|
||||
else
|
||||
deleteMembership(p, schem, back);
|
||||
}
|
||||
|
||||
static void delmembers(Player p, SchematicNode schem){
|
||||
List<SWListInv.SWListEntry<NodeMember>> members = new LinkedList<>();
|
||||
for(NodeMember member : schem.getMembers()){
|
||||
SteamwarUser user = SteamwarUser.get(member.getMember());
|
||||
members.add(new SWListInv.SWListEntry<>(SWItem.getPlayerSkull(user.getUserName()), member));
|
||||
}
|
||||
|
||||
SWListInv<NodeMember> inv = new SWListInv<>(p, SchematicSystem.MESSAGE.parse("GUI_DELETE_MEMBERS_TITLE", p), members, (clickType, member) -> {
|
||||
member.delete();
|
||||
p.closeInventory();
|
||||
delmembers(p, schem);
|
||||
});
|
||||
inv.setCallback(-999, (ClickType click) -> p.closeInventory());
|
||||
inv.open();
|
||||
}
|
||||
|
||||
private static void changeItem(Player p, SchematicNode schem, SchematicSelector back){
|
||||
UtilGui.openMaterialSelector(p, SchematicSystem.MESSAGE.parse("GUI_CHANGE_ITEM", p), material -> {
|
||||
schem.setItem(material.name());
|
||||
p.closeInventory();
|
||||
info(p, schem, back);
|
||||
});
|
||||
}
|
||||
}
|
@ -0,0 +1,149 @@
|
||||
/*
|
||||
This file is a part of the SteamWar software.
|
||||
|
||||
Copyright (C) 2023 SteamWar.de-Serverteam
|
||||
|
||||
This program is free software: you can redistribute it and/or modify
|
||||
it under the terms of the GNU Affero General Public License as published by
|
||||
the Free Software Foundation, either version 3 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 Affero General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU Affero General Public License
|
||||
along with this program. If not, see <https://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
package de.steamwar.schematicsystem.commands.schematiccommand;
|
||||
|
||||
import com.sk89q.worldedit.*;
|
||||
import com.sk89q.worldedit.extent.clipboard.Clipboard;
|
||||
import de.steamwar.command.*;
|
||||
import de.steamwar.core.VersionDependent;
|
||||
import de.steamwar.schematicsystem.CheckSchemType;
|
||||
import de.steamwar.schematicsystem.SchematicSystem;
|
||||
import de.steamwar.schematicsystem.autocheck.AutoCheckerResult;
|
||||
import de.steamwar.sql.*;
|
||||
import org.bukkit.command.CommandSender;
|
||||
import org.bukkit.entity.Player;
|
||||
|
||||
import static de.steamwar.schematicsystem.commands.schematiccommand.SchematicCommandHelp.*;
|
||||
import static de.steamwar.schematicsystem.commands.schematiccommand.SchematicCommandUtils.*;
|
||||
|
||||
@SuppressWarnings("unused")
|
||||
public class SchematicCommand extends SWCommand {
|
||||
|
||||
public SchematicCommand() {
|
||||
super("schematic", new String[] {"schem", "/schem", "/schematic"});
|
||||
}
|
||||
|
||||
@Register("help")
|
||||
public void pagedHelp(Player player, HelpPage page) {
|
||||
printHelpPage(player, page);
|
||||
}
|
||||
|
||||
@Register
|
||||
public void genericHelp(Player player, String... args) {
|
||||
printHelpMainPage(player);
|
||||
}
|
||||
|
||||
@Register(value = "togglepublic", noTabComplete = true)
|
||||
public void togglePublicMode(Player player) {
|
||||
SteamwarUser user = SteamwarUser.get(player.getUniqueId());
|
||||
if (!user.hasPerm(UserPerm.MODERATION)) {
|
||||
genericHelp(player);
|
||||
return;
|
||||
}
|
||||
|
||||
if (togglePublic(player)) {
|
||||
SchematicSystem.MESSAGE.send("COMMAND_PUBLIC_ON", player);
|
||||
} else {
|
||||
SchematicSystem.MESSAGE.send("COMMAND_PUBLIC_OFF", player);
|
||||
}
|
||||
}
|
||||
|
||||
@Mapper("publicMapper")
|
||||
public TypeMapper<SchematicNode> publicNodeTypeMapper() {
|
||||
return SchematicMapper.publicNodeTypeMapper();
|
||||
}
|
||||
|
||||
@Mapper("memberMapper")
|
||||
public static TypeMapper<NodeMember> nodeMemberTypeMapper() {
|
||||
return SchematicMapper.nodeMemberTypeMapper();
|
||||
}
|
||||
|
||||
@Mapper("dirMapper")
|
||||
public static TypeMapper<SchematicNode> dirNodeTypeMapper() {
|
||||
return SchematicMapper.dirNodeTypeMapper();
|
||||
}
|
||||
|
||||
@Mapper("publicDirMapper")
|
||||
public static TypeMapper<SchematicNode> publicDirNodeTypeMapper() {
|
||||
return SchematicMapper.publicDirNodeTypeMapper();
|
||||
}
|
||||
|
||||
@Mapper("dirStringMapper")
|
||||
public static TypeMapper<String> stringTabMapper() {
|
||||
return SchematicMapper.stringTabMapper();
|
||||
}
|
||||
|
||||
@Mapper("stringMapper")
|
||||
public static TypeMapper<String> stringMapper() {
|
||||
return SchematicMapper.stringMapper();
|
||||
}
|
||||
|
||||
@ClassMapper(SchematicType.class)
|
||||
public static TypeMapper<SchematicType> typeTypeMapper() {
|
||||
return SchematicMapper.typeTypeMapper();
|
||||
}
|
||||
|
||||
@AbstractSWCommand.ClassMapper(value = SchematicNode.class, local = true)
|
||||
public static TypeMapper<SchematicNode> nodeTypeMapper() {
|
||||
return SchematicMapper.nodeTypeMapper();
|
||||
}
|
||||
|
||||
@ClassMapper(value = CheckSchemType.class, local = true)
|
||||
public static TypeMapper<CheckSchemType> checkSchemTypeTypeMapper() {
|
||||
return SchematicMapper.checkSchemTypeTypeMapper();
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void sendMessage(CommandSender sender, String message, Object[] args) {
|
||||
SchematicSystem.MESSAGE.send(message, sender, args);
|
||||
}
|
||||
|
||||
@Validator(value = "isSchemValidator", local = true)
|
||||
public static TypeValidator<SchematicNode> isSchemValidator() {
|
||||
return SchematicValidator.isSchemValidator();
|
||||
}
|
||||
|
||||
@Validator(value = "isDirValidator", local = true)
|
||||
public static TypeValidator<SchematicNode> isDirValidator() {
|
||||
return SchematicValidator.isDirValidator();
|
||||
}
|
||||
|
||||
@Validator(value = "isOwnerValidator", local = true)
|
||||
public static TypeValidator<SchematicNode> isOwnerValidator() {
|
||||
return SchematicValidator.isOwnerValidator();
|
||||
}
|
||||
|
||||
@Validator(value = "isOwnerSchematicValidator", local = true)
|
||||
public static TypeValidator<SchematicNode> isOwnerSchematicValidator() {
|
||||
return SchematicValidator.isOwnerSchematicValidator();
|
||||
}
|
||||
|
||||
public enum Extend {
|
||||
AUSFAHREN,
|
||||
NORMAL
|
||||
}
|
||||
|
||||
public static final ISchematicCommand impl = VersionDependent.getVersionImpl(SchematicSystem.getInstance());
|
||||
|
||||
public interface ISchematicCommand {
|
||||
Clipboard fixClipboard(Clipboard clipboard, AutoCheckerResult result, CheckSchemType type) throws Exception;
|
||||
void createCopy(EditSession editSession, Clipboard clipboard) throws WorldEditException;
|
||||
}
|
||||
}
|
@ -0,0 +1,92 @@
|
||||
/*
|
||||
This file is a part of the SteamWar software.
|
||||
|
||||
Copyright (C) 2023 SteamWar.de-Serverteam
|
||||
|
||||
This program is free software: you can redistribute it and/or modify
|
||||
it under the terms of the GNU Affero General Public License as published by
|
||||
the Free Software Foundation, either version 3 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 Affero General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU Affero General Public License
|
||||
along with this program. If not, see <https://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
package de.steamwar.schematicsystem.commands.schematiccommand;
|
||||
|
||||
import de.steamwar.schematicsystem.SchematicSystem;
|
||||
import net.md_5.bungee.api.ChatColor;
|
||||
import net.md_5.bungee.api.chat.ClickEvent;
|
||||
import net.md_5.bungee.api.chat.HoverEvent;
|
||||
import net.md_5.bungee.api.chat.TextComponent;
|
||||
import org.bukkit.entity.Player;
|
||||
|
||||
public class SchematicCommandHelp {
|
||||
private SchematicCommandHelp() {
|
||||
}
|
||||
|
||||
public static void printHelpMainPage(Player player) {
|
||||
SchematicSystem.MESSAGE.sendPrefixless("HELP_HEADER", player);
|
||||
for (HelpPage page : HelpPage.values()) {
|
||||
TextComponent pageComp = new TextComponent(SchematicSystem.MESSAGE.parse(page.mainText, player));
|
||||
pageComp.setColor(ChatColor.GRAY);
|
||||
pageComp.setHoverEvent(new HoverEvent(HoverEvent.Action.SHOW_TEXT, TextComponent.fromLegacyText("§e" + SchematicSystem.MESSAGE.parse(page.hover, player))));
|
||||
pageComp.setClickEvent(new ClickEvent(ClickEvent.Action.RUN_COMMAND, "/schem help " + page.name()));
|
||||
player.spigot().sendMessage(pageComp);
|
||||
}
|
||||
}
|
||||
|
||||
public static void printHelpPage(Player player, HelpPage page) {
|
||||
SchematicSystem.MESSAGE.sendPrefixless("HELP_HEADER", player);
|
||||
for (String s : page.content) {
|
||||
SchematicSystem.MESSAGE.sendPrefixless(s, player);
|
||||
}
|
||||
}
|
||||
|
||||
public enum HelpPage {
|
||||
ANSICHT("HELP_VIEW", "HELP_VIEW_HOVER", new String[]{
|
||||
"HELP_VIEW_1",
|
||||
"HELP_VIEW_2",
|
||||
"HELP_VIEW_3",
|
||||
"HELP_VIEW_4",
|
||||
"HELP_VIEW_5",
|
||||
"HELP_VIEW_6",
|
||||
"HELP_VIEW_7",
|
||||
"HELP_VIEW_8"
|
||||
}),
|
||||
BEARBEITUNG("HELP_EDIT", "HELP_EDIT_HOVER", new String[]{
|
||||
"HELP_EDIT_1",
|
||||
"HELP_EDIT_2",
|
||||
"HELP_EDIT_3",
|
||||
"HELP_EDIT_4",
|
||||
"HELP_EDIT_5",
|
||||
"HELP_EDIT_6",
|
||||
"HELP_EDIT_7",
|
||||
"HELP_EDIT_8",
|
||||
"HELP_EDIT_9"
|
||||
}),
|
||||
MEMBER("HELP_SHARE", "HELP_SHARE_HOVER", new String[]{
|
||||
"HELP_SHARE_1",
|
||||
"HELP_SHARE_2",
|
||||
"HELP_SHARE_3",
|
||||
"HELP_SHARE_4",
|
||||
"HELP_SHARE_5",
|
||||
"HELP_SHARE_6"
|
||||
});
|
||||
|
||||
private final String mainText;
|
||||
private final String[] content;
|
||||
private final String hover;
|
||||
|
||||
HelpPage(String mainText, String hover, String[] content) {
|
||||
this.mainText = mainText;
|
||||
this.hover = hover;
|
||||
this.content = content;
|
||||
}
|
||||
}
|
||||
}
|
@ -0,0 +1,36 @@
|
||||
/*
|
||||
This file is a part of the SteamWar software.
|
||||
|
||||
Copyright (C) 2023 SteamWar.de-Serverteam
|
||||
|
||||
This program is free software: you can redistribute it and/or modify
|
||||
it under the terms of the GNU Affero General Public License as published by
|
||||
the Free Software Foundation, either version 3 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 Affero General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU Affero General Public License
|
||||
along with this program. If not, see <https://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
package de.steamwar.schematicsystem.commands.schematiccommand;
|
||||
|
||||
import de.steamwar.schematicsystem.SchematicSystem;
|
||||
import de.steamwar.schematicsystem.commands.schematiccommand.parts.*;
|
||||
|
||||
public class SchematicCommandInitializer {
|
||||
|
||||
public static void init() {
|
||||
new SchematicCommand().setMessage(SchematicSystem.MESSAGE);
|
||||
new CheckPart().setMessage(SchematicSystem.MESSAGE);
|
||||
new MemberPart().setMessage(SchematicSystem.MESSAGE);
|
||||
new ModifyPart().setMessage(SchematicSystem.MESSAGE);
|
||||
new SavePart().setMessage(SchematicSystem.MESSAGE);
|
||||
new SearchPart().setMessage(SchematicSystem.MESSAGE);
|
||||
new ViewPart().setMessage(SchematicSystem.MESSAGE);
|
||||
}
|
||||
}
|
@ -0,0 +1,505 @@
|
||||
/*
|
||||
This file is a part of the SteamWar software.
|
||||
|
||||
Copyright (C) 2023 SteamWar.de-Serverteam
|
||||
|
||||
This program is free software: you can redistribute it and/or modify
|
||||
it under the terms of the GNU Affero General Public License as published by
|
||||
the Free Software Foundation, either version 3 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 Affero General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU Affero General Public License
|
||||
along with this program. If not, see <https://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
package de.steamwar.schematicsystem.commands.schematiccommand;
|
||||
|
||||
import com.sk89q.worldedit.extent.clipboard.Clipboard;
|
||||
import de.steamwar.inventory.SWInventory;
|
||||
import de.steamwar.inventory.SWItem;
|
||||
import de.steamwar.network.NetworkSender;
|
||||
import de.steamwar.network.packets.client.PrepareSchemPacket;
|
||||
import de.steamwar.providers.BauServerInfo;
|
||||
import de.steamwar.schematicsystem.CheckSchemType;
|
||||
import de.steamwar.schematicsystem.SchematicSystem;
|
||||
import de.steamwar.schematicsystem.autocheck.AutoChecker;
|
||||
import de.steamwar.schematicsystem.autocheck.AutoCheckerResult;
|
||||
import de.steamwar.sql.*;
|
||||
import lombok.AllArgsConstructor;
|
||||
import lombok.Builder;
|
||||
import lombok.Getter;
|
||||
import lombok.With;
|
||||
import net.md_5.bungee.api.ChatColor;
|
||||
import net.md_5.bungee.api.chat.ClickEvent;
|
||||
import net.md_5.bungee.api.chat.ComponentBuilder;
|
||||
import net.md_5.bungee.api.chat.HoverEvent;
|
||||
import net.md_5.bungee.api.chat.TextComponent;
|
||||
import org.bukkit.Bukkit;
|
||||
import org.bukkit.entity.Player;
|
||||
|
||||
import java.io.IOException;
|
||||
import java.util.*;
|
||||
import java.util.function.IntFunction;
|
||||
import java.util.function.UnaryOperator;
|
||||
import java.util.logging.Level;
|
||||
import java.util.stream.Collectors;
|
||||
|
||||
public class SchematicCommandUtils {
|
||||
|
||||
public static final int CHUNK_SIZE = 15;
|
||||
private static final List<Player> PUBLIC_TOGGLED = new ArrayList<>();
|
||||
private static final List<String> FORBIDDEN_NAMES = Collections.unmodifiableList(Arrays.asList("public"));
|
||||
private static final Map<Player, CachedSchematicList> CACHED_LISTS = new HashMap<>();
|
||||
|
||||
|
||||
private SchematicCommandUtils() {
|
||||
}
|
||||
|
||||
public static boolean invalidSchemName(Player player, String[] layers) {
|
||||
for (String layer : layers) {
|
||||
if (layer.isEmpty()) {
|
||||
SchematicSystem.MESSAGE.send("UTIL_NAME_REQUIRED", player);
|
||||
return true;
|
||||
}
|
||||
if(layer.length() > 64) {
|
||||
SchematicSystem.MESSAGE.send("UTIL_NAME_TOO_LONG", player);
|
||||
return true;
|
||||
}
|
||||
if (layer.contains("/") ||
|
||||
layer.contains("\\") ||
|
||||
layer.contains("<") ||
|
||||
layer.contains(">") ||
|
||||
layer.contains("^") ||
|
||||
layer.contains("°") ||
|
||||
layer.contains("'") ||
|
||||
layer.contains("\"") ||
|
||||
layer.contains(" ")) {
|
||||
SchematicSystem.MESSAGE.send("UTIL_NAME_INVALID_CHAR", player);
|
||||
return true;
|
||||
}
|
||||
if (FORBIDDEN_NAMES.contains(layer.toLowerCase())) {
|
||||
SchematicSystem.MESSAGE.send("UTIL_NAME_FORBIDDEN", player, layer);
|
||||
return true;
|
||||
}
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
public static void createCachedSchemList(Player player, List<SchematicNode> nodes, int chunk, SchematicNode parent, SchematicListBehavior behavior) {
|
||||
CachedSchematicList cachedSchematicList = new CachedSchematicList(nodes, chunk, (int) Math.ceil(nodes.size() / (double) CHUNK_SIZE), parent, behavior.withPageCommandGen((page) -> "/schematic page " + (page - 1)));
|
||||
CACHED_LISTS.put(player, cachedSchematicList);
|
||||
renderSchemlist(player, cachedSchematicList.nodes, chunk, parent, cachedSchematicList.behavior);
|
||||
}
|
||||
|
||||
public static void cachedSchemList(Player player, int chunk) {
|
||||
CACHED_LISTS.computeIfPresent(player, (p, cachedSchematicList) -> {
|
||||
renderSchemlist(player, cachedSchematicList.nodes, chunk, null, cachedSchematicList.behavior);
|
||||
return cachedSchematicList.withPage(chunk);
|
||||
});
|
||||
}
|
||||
|
||||
public static void renderSchemlist(Player player,
|
||||
List<SchematicNode> nodes,
|
||||
int chunk,
|
||||
SchematicNode parent,
|
||||
SchematicListBehavior behavior) {
|
||||
SteamwarUser user = getUser(player);
|
||||
int pageCount = (int) Math.ceil(nodes.size() / (double) CHUNK_SIZE);
|
||||
|
||||
SchematicSystem.MESSAGE.sendPrefixless("UTIL_LIST_HEAD", player, nodes.size());
|
||||
String breadcrumbs = parent == null ? "" : parent.generateBreadcrumbs();
|
||||
SchematicSystem.MESSAGE.sendPrefixless("UTIL_LIST_PATH", player, (breadcrumbs.isEmpty() ? "/" : breadcrumbs));
|
||||
if (!breadcrumbs.isEmpty()) {
|
||||
String str = breadcrumbs.substring(0, Math.max(0, breadcrumbs.substring(0, breadcrumbs.length() - 1).lastIndexOf("/")));
|
||||
SchematicSystem.MESSAGE.sendPrefixless("UTIL_LIST_BACK", player, SchematicSystem.MESSAGE.parse("UTIL_LIST_BACK_HOVER", player, str), new ClickEvent(ClickEvent.Action.RUN_COMMAND, "/schem list " + (behavior.isPublics() ? "public" : "") + " " + str));
|
||||
}
|
||||
for (int i = chunk * CHUNK_SIZE; i < nodes.size() && i < (chunk + 1) * CHUNK_SIZE; i++) {
|
||||
SchematicNode node = nodes.get(i);
|
||||
|
||||
StringBuilder nodeString = new StringBuilder();
|
||||
|
||||
if (node.isDir()) {
|
||||
nodeString.append(SchematicSystem.MESSAGE.parse("UTIL_LIST_DIR", player)).append(" ");
|
||||
} else {
|
||||
SchematicType type = node.getSchemtype();
|
||||
if (type != SchematicType.Normal) {
|
||||
nodeString.append(SchematicSystem.MESSAGE.parse("UTIL_LIST_TYPE", player, type.getKuerzel())).append(" ");
|
||||
}
|
||||
}
|
||||
nodeString.append(SchematicSystem.MESSAGE.parse("UTIL_LIST_BASE", player));
|
||||
|
||||
nodeString.append(behavior.getRenderHook().apply(node.getName()));
|
||||
|
||||
if (node.isDir()) {
|
||||
nodeString.append("/");
|
||||
}
|
||||
|
||||
if (node.getOwner() != user.getId()) {
|
||||
nodeString.append(" ").append(SchematicSystem.MESSAGE.parse("UTIL_LIST_FROM", player, SteamwarUser.get(node.getOwner()).getUserName()));
|
||||
}
|
||||
TextComponent schematics = new TextComponent(nodeString.toString());
|
||||
|
||||
if (node.isDir()) {
|
||||
schematics.setHoverEvent(new HoverEvent(HoverEvent.Action.SHOW_TEXT, new ComponentBuilder(SchematicSystem.MESSAGE.parse("UTIL_LIST_OPEN_DIR", player)).create()));
|
||||
schematics.setClickEvent(new ClickEvent(ClickEvent.Action.RUN_COMMAND, "/schem list " + (behavior.isPublics() ? "public " : "") + (behavior.nonCachedBreadcrumbs ? node.generateBreadcrumbs() : breadcrumbs + node.getName() + "/")));
|
||||
} else {
|
||||
schematics.setHoverEvent(new HoverEvent(HoverEvent.Action.SHOW_TEXT, new ComponentBuilder(SchematicSystem.MESSAGE.parse("UTIL_LIST_OPEN_SCHEM", player)).create()));
|
||||
schematics.setClickEvent(new ClickEvent(ClickEvent.Action.RUN_COMMAND, "/schem info " + (behavior.isPublics() ? "public " : "") + (behavior.nonCachedBreadcrumbs ? node.generateBreadcrumbs() : breadcrumbs + node.getName())));
|
||||
}
|
||||
|
||||
player.spigot().sendMessage(schematics);
|
||||
}
|
||||
|
||||
if (parent != null && parent.getOwner() != user.getId() && NodeMember.getNodeMember(parent.getId(), user.getId()) != null) {
|
||||
TextComponent deadd = SchematicSystem.MESSAGE.parseToComponent("UTIL_LIST_REMOVE", false, player);
|
||||
deadd.setColor(ChatColor.RED);
|
||||
deadd.setHoverEvent(new HoverEvent(HoverEvent.Action.SHOW_TEXT, new TextComponent[] {SchematicSystem.MESSAGE.parseToComponent("UTIL_LIST_REMOVE_HOVER", false, player)}));
|
||||
deadd.setClickEvent(new ClickEvent(ClickEvent.Action.RUN_COMMAND, "/schem delete " + parent.generateBreadcrumbs()));
|
||||
player.spigot().sendMessage(deadd);
|
||||
}
|
||||
|
||||
TextComponent beforePage = SchematicSystem.MESSAGE.parseToComponent("UTIL_LIST_BACK_ARROW", false, player);
|
||||
beforePage.addExtra(" ");
|
||||
if (chunk > 0) {
|
||||
beforePage.setColor(ChatColor.YELLOW);
|
||||
beforePage.setHoverEvent(new HoverEvent(HoverEvent.Action.SHOW_TEXT, new TextComponent[] {SchematicSystem.MESSAGE.parseToComponent("UTIL_LIST_BACK_ARROW_HOVER", false, player)}));
|
||||
beforePage.setClickEvent(new ClickEvent(ClickEvent.Action.RUN_COMMAND, behavior.getPageCommandGen().apply(chunk)));
|
||||
} else {
|
||||
beforePage.setColor(ChatColor.RED);
|
||||
}
|
||||
|
||||
TextComponent nextPage = SchematicSystem.MESSAGE.parseToComponent("UTIL_LIST_NEXT", false, player, chunk + 1, Math.max(pageCount, 1));
|
||||
if (chunk < pageCount - 1) {
|
||||
nextPage.setColor(ChatColor.YELLOW);
|
||||
nextPage.setHoverEvent(new HoverEvent(HoverEvent.Action.SHOW_TEXT, new TextComponent[] {SchematicSystem.MESSAGE.parseToComponent("UTIL_LIST_NEXT_HOVER", false, player)}));
|
||||
nextPage.setClickEvent(new ClickEvent(ClickEvent.Action.RUN_COMMAND, behavior.getPageCommandGen().apply(chunk + 2)));
|
||||
} else {
|
||||
nextPage.setColor(ChatColor.RED);
|
||||
}
|
||||
|
||||
beforePage.addExtra(nextPage);
|
||||
player.spigot().sendMessage(beforePage);
|
||||
}
|
||||
|
||||
@Getter
|
||||
@Builder(setterPrefix = "set")
|
||||
@With
|
||||
public static class SchematicListBehavior {
|
||||
public static final SchematicListBehavior DEFAULT = SchematicListBehavior.builder().build();
|
||||
|
||||
@Builder.Default private boolean showPath = true;
|
||||
@Builder.Default private boolean publics = false;
|
||||
@Builder.Default private boolean nonCachedBreadcrumbs = false;
|
||||
@Builder.Default private UnaryOperator<String> renderHook = s -> s;
|
||||
@Builder.Default private IntFunction<String> pageCommandGen = value -> "/schem list " + value;
|
||||
}
|
||||
|
||||
public static void printSchemInfo(Player player, SchematicNode node) {
|
||||
SteamwarUser user = getUser(player);
|
||||
SchematicSystem.MESSAGE.sendPrefixless("UTIL_INFO_SCHEM", player, node.generateBreadcrumbs());
|
||||
if(node.getOwner() == user.getId()) {
|
||||
player.spigot().sendMessage(
|
||||
new ComponentBuilder(SchematicSystem.MESSAGE.parseToComponent("UTIL_INFO_NAME", false, player, node.getName()))
|
||||
.event(new HoverEvent(HoverEvent.Action.SHOW_TEXT, new TextComponent[] {SchematicSystem.MESSAGE.parseToComponent("UTIL_INFO_ACTION_RENAME_HOVER", false, player)}))
|
||||
.event(new ClickEvent(ClickEvent.Action.SUGGEST_COMMAND, "/schem rename " + node.generateBreadcrumbs() + " "))
|
||||
.create()
|
||||
);
|
||||
} else {
|
||||
SchematicSystem.MESSAGE.sendPrefixless("UTIL_INFO_NAME", player, node.getName());
|
||||
}
|
||||
SchematicSystem.MESSAGE.sendPrefixless("UTIL_INFO_OWNER", player, node.getOwner() == user.getId() ? user.getUserName() : SteamwarUser.get(node.getOwner()).getUserName());
|
||||
if(node.getOwner() == user.getId()) {
|
||||
player.spigot().sendMessage(
|
||||
new ComponentBuilder(SchematicSystem.MESSAGE.parseToComponent("UTIL_INFO_PARENT", false, player, node.getParent() == null ? "/" : node.getParentNode().generateBreadcrumbs()))
|
||||
.event(new HoverEvent(HoverEvent.Action.SHOW_TEXT, new TextComponent[] {SchematicSystem.MESSAGE.parseToComponent("UTIL_INFO_ACTION_MOVE_HOVER", false, player)}))
|
||||
.event(new ClickEvent(ClickEvent.Action.SUGGEST_COMMAND, "/schem move " + node.generateBreadcrumbs() + " " + node.generateBreadcrumbs().replace("/" + node.getName(), "")))
|
||||
.create()
|
||||
);
|
||||
} else {
|
||||
SchematicSystem.MESSAGE.sendPrefixless("UTIL_INFO_PARENT", player, node.getParent() == null ? "/" : node.getParentNode().generateBreadcrumbs());
|
||||
}
|
||||
SchematicSystem.MESSAGE.sendPrefixless("UTIL_INFO_UPDATED", player, node.getLastUpdate());
|
||||
if (!node.isDir()) {
|
||||
if(node.getOwner() == user.getId()) {
|
||||
player.spigot().sendMessage(
|
||||
new ComponentBuilder(SchematicSystem.MESSAGE.parseToComponent("UTIL_INFO_TYPE", false, player, node.getSchemtype().name()))
|
||||
.event(new HoverEvent(HoverEvent.Action.SHOW_TEXT, new TextComponent[] {SchematicSystem.MESSAGE.parseToComponent("UTIL_INFO_ACTION_TYPE_HOVER", false, player)}))
|
||||
.event(new ClickEvent(ClickEvent.Action.RUN_COMMAND, "/schem changetype " + node.generateBreadcrumbs()))
|
||||
.create()
|
||||
);
|
||||
} else {
|
||||
SchematicSystem.MESSAGE.sendPrefixless("UTIL_INFO_TYPE", player, node.getSchemtype().name());
|
||||
}
|
||||
if (node.getRank() > 0) {
|
||||
SchematicSystem.MESSAGE.sendPrefixless("UTIL_INFO_RANK", player, node.getRank());
|
||||
}
|
||||
|
||||
if (node.getSchemtype().fightType()) {
|
||||
SchematicSystem.MESSAGE.sendPrefixless("UTIL_INFO_COLOR", player, SchematicSystem.MESSAGE.parse(node.replaceColor() ? "ON" : "OFF", player));
|
||||
SchematicSystem.MESSAGE.sendPrefixless("UTIL_INFO_REPLAY", player, SchematicSystem.MESSAGE.parse(node.allowReplay() ? "ON" : "OFF", player));
|
||||
SchematicSystem.MESSAGE.sendPrefixless("UTIL_INFO_ELO", player, node.getElo(Season.getSeason()));
|
||||
}
|
||||
|
||||
SchematicSystem.MESSAGE.sendPrefixless("UTIL_INFO_FORMAT", player, node.getSchemFormat() ? ".schem" : ".schematic");
|
||||
CheckedSchematic.getLastDeclinedOfNode(node.getId()).stream().findFirst().ifPresent(checkedSchematic -> SchematicSystem.MESSAGE.sendPrefixless("UTIL_INFO_STATUS", player, checkedSchematic.getEndTime(), checkedSchematic.getDeclineReason()));
|
||||
} else {
|
||||
SchematicSystem.MESSAGE.sendPrefixless("UTIL_INFO_TYPE", player, SchematicSystem.MESSAGE.parse("UTIL_INFO_TYPE_DIR", player));
|
||||
}
|
||||
|
||||
|
||||
if(node.getOwner() == user.getId()) {
|
||||
ComponentBuilder memberBuilder = new ComponentBuilder(SchematicSystem.MESSAGE.parse("UTIL_INFO_MEMBER_STRING", player) + " ").color(ChatColor.GRAY);
|
||||
NodeMember.getNodeMembers(node.getId()).forEach(nodeMember -> {
|
||||
SteamwarUser member = SteamwarUser.get(nodeMember.getMember());
|
||||
memberBuilder.append(member.getUserName())
|
||||
.color(ChatColor.YELLOW)
|
||||
.event(new ClickEvent(ClickEvent.Action.SUGGEST_COMMAND, "/schem delmember " + node.generateBreadcrumbs() + " " + member.getUserName()))
|
||||
.event(new HoverEvent(HoverEvent.Action.SHOW_TEXT, new TextComponent[]{SchematicSystem.MESSAGE.parseToComponent("UTIL_INFO_ACTION_REMOVE_HOVER", false, player, member.getUserName())}))
|
||||
.append(" ", ComponentBuilder.FormatRetention.NONE);
|
||||
});
|
||||
memberBuilder.append("(+)", ComponentBuilder.FormatRetention.NONE)
|
||||
.color(ChatColor.GREEN)
|
||||
.event(new HoverEvent(HoverEvent.Action.SHOW_TEXT, new TextComponent[]{SchematicSystem.MESSAGE.parseToComponent("UTIL_INFO_ACTION_ADD_HOVER", false, player)}))
|
||||
.event(new ClickEvent(ClickEvent.Action.SUGGEST_COMMAND, "/schem addmember " + node.generateBreadcrumbs() + " "));
|
||||
player.spigot().sendMessage(memberBuilder.create());
|
||||
} else {
|
||||
List<String> schematicMembers = new ArrayList<>();
|
||||
NodeMember.getNodeMembers(node.getId()).forEach(nodeMember -> schematicMembers.add(SteamwarUser.get(nodeMember.getMember()).getUserName()));
|
||||
if(!schematicMembers.isEmpty()) {
|
||||
SchematicSystem.MESSAGE.sendPrefixless("UTIL_INFO_MEMBER", player, schematicMembers.stream().reduce((s, s2) -> s + ", " + s2).orElse(""));
|
||||
}
|
||||
}
|
||||
|
||||
TextComponent base = new TextComponent();
|
||||
|
||||
if (!node.isDir()) {
|
||||
TextComponent load = SchematicSystem.MESSAGE.parseToComponent("UTIL_INFO_ACTION_LOAD", false, player);
|
||||
load.setColor(ChatColor.GREEN);
|
||||
load.setHoverEvent(new HoverEvent(HoverEvent.Action.SHOW_TEXT, new TextComponent[]{SchematicSystem.MESSAGE.parseToComponent("UTIL_INFO_ACTION_LOAD_HOVER", false, player)}));
|
||||
load.setClickEvent(new ClickEvent(ClickEvent.Action.RUN_COMMAND, "/schem load " + (node.getOwner() == 0 ? "public " : "") + node.generateBreadcrumbs()));
|
||||
base.addExtra(load);
|
||||
|
||||
if (node.getOwner() == user.getId()) {
|
||||
TextComponent download = SchematicSystem.MESSAGE.parseToComponent("UTIL_INFO_ACTION_DOWNLOAD", false, player);
|
||||
download.setColor(ChatColor.GOLD);
|
||||
download.setHoverEvent(new HoverEvent(HoverEvent.Action.SHOW_TEXT, new TextComponent[]{SchematicSystem.MESSAGE.parseToComponent("UTIL_INFO_ACTION_DOWNLOAD_HOVER", false, player)}));
|
||||
download.setClickEvent(new ClickEvent(ClickEvent.Action.RUN_COMMAND, "/schem download " + node.generateBreadcrumbs()));
|
||||
base.addExtra(download);
|
||||
}
|
||||
}
|
||||
|
||||
if (node.getOwner() != 0) {
|
||||
TextComponent delete = SchematicSystem.MESSAGE.parseToComponent("UTIL_INFO_ACTION_DELETE", false, player);
|
||||
delete.setColor(ChatColor.DARK_RED);
|
||||
delete.setHoverEvent(new HoverEvent(HoverEvent.Action.SHOW_TEXT, new TextComponent[]{SchematicSystem.MESSAGE.parseToComponent("UTIL_INFO_ACTION_DELETE_HOVER", false, player)}));
|
||||
delete.setClickEvent(new ClickEvent(ClickEvent.Action.SUGGEST_COMMAND, "/schem delete " + node.generateBreadcrumbs()));
|
||||
base.addExtra(delete);
|
||||
}
|
||||
|
||||
if (!base.getExtra().isEmpty()) {
|
||||
player.spigot().sendMessage(base);
|
||||
}
|
||||
}
|
||||
|
||||
public static void check(Player player, Clipboard clipboard, CheckSchemType type, String schemName, boolean gui) {
|
||||
AutoCheckerResult result = AutoChecker.check(clipboard, type);
|
||||
if(!result.isOk()) {
|
||||
result.sendErrorMessage(player, schemName);
|
||||
} else {
|
||||
SchematicSystem.MESSAGE.send("UTIL_CHECK_SUCCESS", player, schemName);
|
||||
}
|
||||
}
|
||||
|
||||
public static SchematicNode mkdirs(String[] layers, SteamwarUser user, int minus) {
|
||||
Optional<SchematicNode> currentNode = Optional.empty();
|
||||
for (int i = 0; i < layers.length - minus; i++) {
|
||||
int finalI = i;
|
||||
List<SchematicNode> nodes = SchematicNode.list(user, currentNode.map(SchematicNode::getId).orElse(null)).stream()
|
||||
.filter(node -> node.getName().equalsIgnoreCase(layers[finalI]))
|
||||
.collect(Collectors.toList());
|
||||
if (nodes.isEmpty()) {
|
||||
currentNode = Optional.ofNullable(SchematicNode.byIdAndUser(user, SchematicNode.createSchematicDirectory(user.getId(), layers[i], currentNode.map(SchematicNode::getId).orElse(null)).getId()));
|
||||
} else {
|
||||
if(nodes.stream().anyMatch(SchematicNode::isDir)) {
|
||||
currentNode = nodes.stream().filter(SchematicNode::isDir).findFirst();
|
||||
} else {
|
||||
currentNode = Optional.ofNullable(SchematicNode.byIdAndUser(user, SchematicNode.createSchematicDirectory(user.getId(), layers[i] + "-dir-" + System.currentTimeMillis() % 100, currentNode.map(SchematicNode::getId).orElse(null)).getId()));
|
||||
}
|
||||
}
|
||||
}
|
||||
return currentNode.orElse(null);
|
||||
}
|
||||
|
||||
public static SteamwarUser getUser(Player player) {
|
||||
if (PUBLIC_TOGGLED.contains(player)) {
|
||||
return SteamwarUser.get(0);
|
||||
} else {
|
||||
return SteamwarUser.get(player.getUniqueId());
|
||||
}
|
||||
}
|
||||
|
||||
public static boolean togglePublic(Player player) {
|
||||
if (PUBLIC_TOGGLED.contains(player)) {
|
||||
PUBLIC_TOGGLED.remove(player);
|
||||
return false;
|
||||
} else {
|
||||
PUBLIC_TOGGLED.add(player);
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
||||
public static void turnOffPublic(Player player) {
|
||||
PUBLIC_TOGGLED.remove(player);
|
||||
}
|
||||
|
||||
public static void loadSchem(Player player, SchematicNode node) {
|
||||
SteamwarUser user = getUser(player);
|
||||
if(BauServerInfo.isBauServer() && BauServerInfo.getOwnerId() != user.getId() &&
|
||||
(Punishment.isPunished(user, Punishment.PunishmentType.NoSchemSharing, punishment ->
|
||||
SchematicSystem.MESSAGE.send("UTIL_LOAD_NOT_HERE", player)) ||
|
||||
Punishment.isPunished(SteamwarUser.get(BauServerInfo.getOwnerId()), Punishment.PunishmentType.NoSchemReceiving, punishment ->
|
||||
SchematicSystem.MESSAGE.send("UTIL_LOAD_NOT_HERE_ALL", player)))) {
|
||||
return;
|
||||
}
|
||||
if (node.isDir()) {
|
||||
SchematicSystem.MESSAGE.send("UTIL_LOAD_DIR", player);
|
||||
return;
|
||||
}
|
||||
|
||||
try {
|
||||
new SchematicData(node).loadToPlayer(player);
|
||||
SchematicSystem.MESSAGE.send("UTIL_LOAD_DONE", player, node.getName());
|
||||
Bukkit.getLogger().log(Level.INFO, "{0} has loaded Schematic {1} {2}", new Object[]{player.getName(), node.getId(), node.getName()});
|
||||
} catch (NoClipboardException e) {
|
||||
SchematicSystem.MESSAGE.send("UTIL_LOAD_NO_DATA", player);
|
||||
} catch (Exception e) {
|
||||
SchematicSystem.MESSAGE.send("UTIL_LOAD_ERROR", player);
|
||||
Bukkit.getLogger().log(Level.INFO, e.getMessage(), e);
|
||||
}
|
||||
}
|
||||
|
||||
public static void download(Player player, SchematicNode node) {
|
||||
SteamwarUser user = getUser(player);
|
||||
if (Punishment.isPunished(user, Punishment.PunishmentType.NoSchemSharing, punishment -> {
|
||||
SchematicSystem.MESSAGE.send("UTIL_DOWNLOAD_PUNISHED", player, punishment.getReason());
|
||||
})) {
|
||||
return;
|
||||
}
|
||||
if (node.getOwner() != user.getId()) {
|
||||
SchematicSystem.MESSAGE.send("UTIL_DOWNLOAD_NOT_OWN", player);
|
||||
return;
|
||||
}
|
||||
|
||||
SchematicSystem.MESSAGE.send("UTIL_DOWNLOAD_LINK", player);
|
||||
player.sendMessage(NodeDownload.getLink(node));
|
||||
}
|
||||
|
||||
public static void changeType(Player player, SchematicNode node, SchematicType type, SchematicCommand.Extend extend) {
|
||||
SteamwarUser user = getUser(player);
|
||||
if (Punishment.isPunished(user,
|
||||
Punishment.PunishmentType.NoSchemSubmitting,
|
||||
punishment -> SchematicSystem.MESSAGE.send("UTIL_TYPE_PUNISHED", player, punishment.getReason()))) {
|
||||
return;
|
||||
}
|
||||
if (node.getOwner() != user.getId()) {
|
||||
SchematicSystem.MESSAGE.send("UTIL_TYPE_NOT_OWN", player);
|
||||
return;
|
||||
}
|
||||
|
||||
if (node.isDir()) {
|
||||
SchematicSystem.MESSAGE.send("UTIL_TYPE_DIR", player);
|
||||
return;
|
||||
}
|
||||
|
||||
if (!type.isAssignable()) {
|
||||
SchematicSystem.MESSAGE.send("UTIL_TYPE_NOT_ASSIGNABLE", player);
|
||||
return;
|
||||
}
|
||||
|
||||
if (node.getSchemtype().equals(type)) {
|
||||
SchematicSystem.MESSAGE.send("UTIL_TYPE_ALREADY", player);
|
||||
return;
|
||||
}
|
||||
|
||||
if (type.writeable()) {
|
||||
node.setSchemtype(type);
|
||||
SchematicSystem.MESSAGE.send("UTIL_TYPE_DONE", player);
|
||||
} else if (type.fightType()) {
|
||||
if (node.getSchemtype().check()) {
|
||||
SchematicSystem.MESSAGE.send("UTIL_TYPE_FIGHT_ALREADY", player);
|
||||
return;
|
||||
}
|
||||
|
||||
CheckSchemType checkSchemType = CheckSchemType.get(type);
|
||||
if (checkSchemType.isAfterDeadline()) {
|
||||
SchematicSystem.MESSAGE.send("UTIL_TYPE_AFTER_DEADLINE", player, checkSchemType.getDeadline());
|
||||
return;
|
||||
}
|
||||
|
||||
AutoCheckerResult result = null;
|
||||
try {
|
||||
result = AutoChecker.check(new SchematicData(node).load(), checkSchemType);
|
||||
} catch (IOException e) {
|
||||
SchematicSystem.MESSAGE.send("UTIL_LOAD_ERROR", player);
|
||||
SchematicSystem.getInstance().getLogger().throwing(SchematicCommandUtils.class.getName(), "changeType", e);
|
||||
return;
|
||||
}
|
||||
if (!result.isOk()) {
|
||||
SchematicSystem.MESSAGE.send("UTIL_TYPE_ERROR", player);
|
||||
result.sendErrorMessage(player, node.getName());
|
||||
return;
|
||||
}
|
||||
|
||||
if (extend == null) {
|
||||
submitSchemGUI(player, node, type);
|
||||
} else if (extend == SchematicCommand.Extend.AUSFAHREN) {
|
||||
NetworkSender.send(new PrepareSchemPacket(SteamwarUser.get(player.getUniqueId()).getId(), node.getId(), type.toDB()));
|
||||
SchematicSystem.MESSAGE.send("UTIL_TYPE_EXTEND", player);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private static void submitSchemGUI(Player player, SchematicNode node, SchematicType type) {
|
||||
SWInventory inv = new SWInventory(player, 9, SchematicSystem.MESSAGE.parse("UTIL_SUBMIT_TITLE", player));
|
||||
inv.setItem(0, SWItem.getMaterial("SIGN"), SchematicSystem.MESSAGE.parse(node.allowReplay()?"UTIL_SUBMIT_REPLAY_ON":"UTIL_SUBMIT_REPLAY_OFF", player), click -> {
|
||||
node.setAllowReplay(!node.allowReplay());
|
||||
submitSchemGUI(player, node, type);
|
||||
});
|
||||
inv.setItem(1, SWItem.getMaterial(node.replaceColor() ? "PINK_WOOL" : "LIGHT_GRAY_WOOL"), SchematicSystem.MESSAGE.parse(node.allowReplay()?"UTIL_SUBMIT_COLOR_ON":"UTIL_SUBMIT_COLOR_OFF", player), click -> {
|
||||
node.setReplaceColor(!node.replaceColor());
|
||||
submitSchemGUI(player, node, type);
|
||||
});
|
||||
inv.setItem(7, SWItem.getDye(7), (byte) 7, SchematicSystem.MESSAGE.parse("UTIL_SUBMIT_DIRECT", player), click -> {
|
||||
node.setSchemtype(type.checkType());
|
||||
SchematicSystem.MESSAGE.send("UTIL_SUBMIT_DIRECT_DONE", player);
|
||||
player.closeInventory();
|
||||
});
|
||||
inv.setItem(8, SWItem.getDye(10), (byte) 10, SchematicSystem.MESSAGE.parse("UTIL_SUBMIT_EXTEND", player), click -> {
|
||||
NetworkSender.send(new PrepareSchemPacket(SteamwarUser.get(player.getUniqueId()).getId(), node.getId(), type.toDB()));
|
||||
SchematicSystem.MESSAGE.send("UTIL_SUBMIT_EXTEND_DONE", player);
|
||||
player.closeInventory();
|
||||
});
|
||||
inv.setCallback(-999, click -> player.closeInventory());
|
||||
inv.open();
|
||||
}
|
||||
|
||||
public static void quitPlayer(Player player) {
|
||||
CACHED_LISTS.remove(player);
|
||||
PUBLIC_TOGGLED.remove(player);
|
||||
}
|
||||
|
||||
@AllArgsConstructor
|
||||
@With
|
||||
static class CachedSchematicList {
|
||||
private List<SchematicNode> nodes;
|
||||
private int page;
|
||||
private int maxPage;
|
||||
private SchematicNode parent;
|
||||
private SchematicListBehavior behavior;
|
||||
}
|
||||
}
|
@ -0,0 +1,191 @@
|
||||
/*
|
||||
This file is a part of the SteamWar software.
|
||||
|
||||
Copyright (C) 2023 SteamWar.de-Serverteam
|
||||
|
||||
This program is free software: you can redistribute it and/or modify
|
||||
it under the terms of the GNU Affero General Public License as published by
|
||||
the Free Software Foundation, either version 3 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 Affero General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU Affero General Public License
|
||||
along with this program. If not, see <https://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
package de.steamwar.schematicsystem.commands.schematiccommand;
|
||||
|
||||
import de.steamwar.command.TypeMapper;
|
||||
import de.steamwar.schematicsystem.CheckSchemType;
|
||||
import de.steamwar.sql.NodeMember;
|
||||
import de.steamwar.sql.SchematicNode;
|
||||
import de.steamwar.sql.SchematicType;
|
||||
import de.steamwar.sql.SteamwarUser;
|
||||
import org.bukkit.command.CommandSender;
|
||||
import org.bukkit.entity.Player;
|
||||
|
||||
import java.util.Collection;
|
||||
import java.util.Collections;
|
||||
import java.util.List;
|
||||
import java.util.Optional;
|
||||
import java.util.stream.Collectors;
|
||||
|
||||
import static de.steamwar.schematicsystem.commands.schematiccommand.SchematicCommandUtils.getUser;
|
||||
|
||||
public class SchematicMapper {
|
||||
|
||||
private static final TypeMapper<SchematicNode> publicCommandTypeMapper = publicNodeTypeMapper();
|
||||
|
||||
public static TypeMapper<SchematicNode> publicNodeTypeMapper() {
|
||||
return new TypeMapper<SchematicNode>() {
|
||||
@Override
|
||||
public List<String> tabCompletes(CommandSender commandSender, String[] strings, String s) {
|
||||
return SchematicNode.getNodeTabcomplete(SteamwarUser.get(0), s);
|
||||
}
|
||||
|
||||
@Override
|
||||
public SchematicNode map(CommandSender commandSender, String[] previousArguments, String s) {
|
||||
return SchematicNode.getNodeFromPath(SteamwarUser.get(0), s);
|
||||
}
|
||||
};
|
||||
}
|
||||
|
||||
public static TypeMapper<NodeMember> nodeMemberTypeMapper() {
|
||||
return new TypeMapper<NodeMember>() {
|
||||
@Override
|
||||
public NodeMember map(CommandSender commandSender, String[] previousArguments, String s) {
|
||||
SchematicNode node = SchematicNode.getNodeFromPath(getUser((Player) commandSender), previousArguments[previousArguments.length - 1]);
|
||||
SteamwarUser user = SteamwarUser.get(s);
|
||||
return NodeMember.getNodeMember(node.getId(), user.getId());
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<String> tabCompletes(CommandSender commandSender, String[] strings, String s) {
|
||||
return Optional.ofNullable(SchematicNode.getNodeFromPath(getUser((Player) commandSender), strings[strings.length - 1]))
|
||||
.map(SchematicNode::getMembers)
|
||||
.map(nodeMembers -> nodeMembers.stream().map(NodeMember::getMember).map(SteamwarUser::get).map(SteamwarUser::getUserName).collect(Collectors.toList()))
|
||||
.orElse(Collections.emptyList());
|
||||
}
|
||||
};
|
||||
}
|
||||
|
||||
public static TypeMapper<SchematicNode> dirNodeTypeMapper() {
|
||||
return new TypeMapper<SchematicNode>() {
|
||||
@Override
|
||||
public List<String> tabCompletes(CommandSender commandSender, String[] strings, String s) {
|
||||
List<String> list = SchematicNode.getNodeTabcomplete(getUser((Player) commandSender), s);
|
||||
list.removeIf(s1 -> !s1.endsWith("/"));
|
||||
return list;
|
||||
}
|
||||
|
||||
@Override
|
||||
public SchematicNode map(CommandSender commandSender, String[] previousArguments, String s) {
|
||||
SchematicNode node = SchematicNode.getNodeFromPath(getUser((Player) commandSender), s);
|
||||
if(node.isDir()) {
|
||||
return node;
|
||||
} else {
|
||||
return null;
|
||||
}
|
||||
}
|
||||
};
|
||||
}
|
||||
|
||||
public static TypeMapper<SchematicNode> publicDirNodeTypeMapper() {
|
||||
return new TypeMapper<SchematicNode>() {
|
||||
@Override
|
||||
public Collection<String> tabCompletes(CommandSender commandSender, String[] strings, String s) {
|
||||
Collection<String> list = publicCommandTypeMapper.tabCompletes(commandSender, strings, s);
|
||||
list.removeIf(s1 -> !s1.endsWith("/"));
|
||||
return list;
|
||||
}
|
||||
|
||||
@Override
|
||||
public SchematicNode map(CommandSender commandSender, String[] previousArguments, String s) {
|
||||
SchematicNode node = publicCommandTypeMapper.map(commandSender, previousArguments, s);
|
||||
if(node.isDir()) {
|
||||
return node;
|
||||
} else {
|
||||
return null;
|
||||
}
|
||||
}
|
||||
};
|
||||
}
|
||||
|
||||
public static TypeMapper<String> stringTabMapper() {
|
||||
return new TypeMapper<String>() {
|
||||
@Override
|
||||
public List<String> tabCompletes(CommandSender commandSender, String[] strings, String s) {
|
||||
List<String> list = SchematicNode.getNodeTabcomplete(getUser((Player) commandSender), s);
|
||||
list.removeIf(s1 -> !s1.endsWith("/"));
|
||||
return list;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String map(CommandSender commandSender, String[] previousArguments, String s) {
|
||||
return s;
|
||||
}
|
||||
};
|
||||
}
|
||||
|
||||
public static TypeMapper<String> stringMapper() {
|
||||
return new TypeMapper<String>() {
|
||||
@Override
|
||||
public List<String> tabCompletes(CommandSender commandSender, String[] strings, String s) {
|
||||
List<String> list = SchematicNode.getNodeTabcomplete(getUser((Player) commandSender), s);
|
||||
list.add(s);
|
||||
return list;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String map(CommandSender commandSender, String[] previousArguments, String s) {
|
||||
return s;
|
||||
}
|
||||
};
|
||||
}
|
||||
|
||||
public static TypeMapper<SchematicType> typeTypeMapper() {
|
||||
return new TypeMapper<SchematicType>() {
|
||||
@Override
|
||||
public List<String> tabCompletes(CommandSender commandSender, String[] strings, String s) {
|
||||
return SchematicType.values().stream().filter(SchematicType::isAssignable).map(SchematicType::name).collect(Collectors.toList());
|
||||
}
|
||||
|
||||
@Override
|
||||
public SchematicType map(CommandSender commandSender, String[] previousArguments, String s) {
|
||||
return SchematicType.values().stream().filter(type -> type.name().equals(s)).collect(Collectors.toList()).get(0);
|
||||
}
|
||||
};
|
||||
}
|
||||
|
||||
public static TypeMapper<SchematicNode> nodeTypeMapper() {
|
||||
return new TypeMapper<SchematicNode>() {
|
||||
@Override
|
||||
public List<String> tabCompletes(CommandSender commandSender, String[] strings, String s) {
|
||||
return SchematicNode.getNodeTabcomplete(getUser((Player) commandSender), s);
|
||||
}
|
||||
|
||||
@Override
|
||||
public SchematicNode map(CommandSender commandSender, String[] previousArguments, String s) {
|
||||
return SchematicNode.getNodeFromPath(getUser((Player) commandSender), s);
|
||||
}
|
||||
};
|
||||
}
|
||||
|
||||
public static TypeMapper<CheckSchemType> checkSchemTypeTypeMapper() {
|
||||
return new TypeMapper<CheckSchemType>() {
|
||||
@Override
|
||||
public Collection<String> tabCompletes(CommandSender commandSender, String[] strings, String s) {
|
||||
return SchematicType.values().stream().filter(type -> CheckSchemType.get(type) != null).map(SchematicType::name).collect(Collectors.toList());
|
||||
}
|
||||
|
||||
@Override
|
||||
public CheckSchemType map(CommandSender commandSender, String[] previousArguments, String s) {
|
||||
return SchematicType.values().stream().filter(type -> type.name().equalsIgnoreCase(s)).map(CheckSchemType::get).findAny().orElse(null);
|
||||
}
|
||||
};
|
||||
}
|
||||
}
|
@ -0,0 +1,94 @@
|
||||
/*
|
||||
This file is a part of the SteamWar software.
|
||||
|
||||
Copyright (C) 2023 SteamWar.de-Serverteam
|
||||
|
||||
This program is free software: you can redistribute it and/or modify
|
||||
it under the terms of the GNU Affero General Public License as published by
|
||||
the Free Software Foundation, either version 3 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 Affero General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU Affero General Public License
|
||||
along with this program. If not, see <https://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
package de.steamwar.schematicsystem.commands.schematiccommand;
|
||||
|
||||
import de.steamwar.command.AbstractSWCommand;
|
||||
import de.steamwar.command.AbstractValidator;
|
||||
import de.steamwar.command.TypeValidator;
|
||||
import de.steamwar.sql.SchematicNode;
|
||||
import de.steamwar.sql.SteamwarUser;
|
||||
import org.bukkit.entity.Player;
|
||||
|
||||
public class SchematicValidator {
|
||||
|
||||
private static boolean nodeNullCheck(AbstractValidator.MessageSender messageSender, SchematicNode node) {
|
||||
if (node == null) {
|
||||
messageSender.send("COMMAND_INVALID_NODE");
|
||||
return false;
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
public static TypeValidator<SchematicNode> isSchemValidator() {
|
||||
return (commandSender, schematicNode, messageSender) -> {
|
||||
if(!nodeNullCheck(messageSender, schematicNode)) {
|
||||
return false;
|
||||
}
|
||||
if(schematicNode.isDir()) {
|
||||
messageSender.send("COMMAND_MUST_SCHEM");
|
||||
return false;
|
||||
}
|
||||
return true;
|
||||
};
|
||||
}
|
||||
|
||||
public static TypeValidator<SchematicNode> isDirValidator() {
|
||||
return (commandSender, schematicNode, messageSender) -> {
|
||||
if(!nodeNullCheck(messageSender, schematicNode)) {
|
||||
return false;
|
||||
}
|
||||
if(!schematicNode.isDir()) {
|
||||
messageSender.send("COMMAND_MUST_DIR");
|
||||
return false;
|
||||
}
|
||||
return true;
|
||||
};
|
||||
}
|
||||
|
||||
public static TypeValidator<SchematicNode> isOwnerValidator() {
|
||||
return (commandSender, schematicNode, messageSender) -> {
|
||||
if(!nodeNullCheck(messageSender, schematicNode)) {
|
||||
return false;
|
||||
}
|
||||
if(schematicNode.getOwner() != SteamwarUser.get(((Player) commandSender).getUniqueId()).getId()) {
|
||||
messageSender.send("COMMAND_NOT_OWN");
|
||||
return false;
|
||||
}
|
||||
return true;
|
||||
};
|
||||
}
|
||||
|
||||
public static TypeValidator<SchematicNode> isOwnerSchematicValidator() {
|
||||
return (commandSender, schematicNode, messageSender) -> {
|
||||
if(!nodeNullCheck(messageSender, schematicNode)) {
|
||||
return false;
|
||||
}
|
||||
if(schematicNode.getOwner() != SchematicCommandUtils.getUser((Player) commandSender).getId()) {
|
||||
messageSender.send("COMMAND_NOT_OWN");
|
||||
return false;
|
||||
}
|
||||
if(schematicNode.isDir()) {
|
||||
messageSender.send("COMMAND_MUST_SCHEM");
|
||||
return false;
|
||||
}
|
||||
return true;
|
||||
};
|
||||
}
|
||||
}
|
@ -0,0 +1,119 @@
|
||||
/*
|
||||
This file is a part of the SteamWar software.
|
||||
|
||||
Copyright (C) 2023 SteamWar.de-Serverteam
|
||||
|
||||
This program is free software: you can redistribute it and/or modify
|
||||
it under the terms of the GNU Affero General Public License as published by
|
||||
the Free Software Foundation, either version 3 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 Affero General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU Affero General Public License
|
||||
along with this program. If not, see <https://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
package de.steamwar.schematicsystem.commands.schematiccommand.parts;
|
||||
|
||||
import com.sk89q.worldedit.*;
|
||||
import com.sk89q.worldedit.bukkit.BukkitPlayer;
|
||||
import com.sk89q.worldedit.bukkit.BukkitWorld;
|
||||
import com.sk89q.worldedit.extent.clipboard.BlockArrayClipboard;
|
||||
import com.sk89q.worldedit.extent.clipboard.Clipboard;
|
||||
import com.sk89q.worldedit.session.ClipboardHolder;
|
||||
import de.steamwar.command.AbstractSWCommand;
|
||||
import de.steamwar.command.SWCommand;
|
||||
import de.steamwar.core.Core;
|
||||
import de.steamwar.schematicsystem.CheckSchemType;
|
||||
import de.steamwar.schematicsystem.SchematicSystem;
|
||||
import de.steamwar.schematicsystem.autocheck.AutoChecker;
|
||||
import de.steamwar.schematicsystem.autocheck.AutoCheckerResult;
|
||||
import de.steamwar.schematicsystem.commands.schematiccommand.SchematicCommand;
|
||||
import de.steamwar.sql.SchematicData;
|
||||
import de.steamwar.sql.SchematicNode;
|
||||
import org.bukkit.entity.Player;
|
||||
|
||||
import java.io.IOException;
|
||||
import java.util.logging.Level;
|
||||
|
||||
import static de.steamwar.schematicsystem.commands.schematiccommand.SchematicCommandUtils.check;
|
||||
import static de.steamwar.schematicsystem.commands.schematiccommand.SchematicCommand.impl;
|
||||
|
||||
@AbstractSWCommand.PartOf(SchematicCommand.class)
|
||||
public class CheckPart extends SWCommand {
|
||||
public CheckPart() {
|
||||
super(null);
|
||||
}
|
||||
|
||||
@Register("check")
|
||||
public void checkCommand(Player player, @Validator("isOwnerSchematicValidator") SchematicNode node, CheckSchemType type) {
|
||||
try {
|
||||
check(player, new SchematicData(node).load(), type, node.getName(), false);
|
||||
} catch (IOException e) {
|
||||
SchematicSystem.MESSAGE.send("UTIL_LOAD_ERROR", player);
|
||||
}
|
||||
}
|
||||
|
||||
@Register(value = {"check", "clipboard"})
|
||||
public void checkClipboardCommand(Player player, @ErrorMessage("UTIL_CHECK_TYPE_NOT_FOUND") CheckSchemType type) {
|
||||
try {
|
||||
check(player, WorldEdit.getInstance().getSessionManager().findByName(player.getName()).getClipboard().getClipboard(), type, "clipboard", false);
|
||||
} catch (EmptyClipboardException e) {
|
||||
SchematicSystem.MESSAGE.send("COMMAND_CHECK_CLIPBOARD_EMPTY", player);
|
||||
}
|
||||
}
|
||||
|
||||
@Register(value = {"check", "selection"})
|
||||
public void checkSelectionCommand(Player player, @ErrorMessage("UTIL_CHECK_TYPE_NOT_FOUND") CheckSchemType type) {
|
||||
try {
|
||||
Clipboard clipboard = new BlockArrayClipboard(WorldEdit.getInstance().getSessionManager().findByName(player.getName()).getSelection(new BukkitWorld(player.getWorld())));
|
||||
EditSession editSession = WorldEdit.getInstance().getEditSessionFactory().getEditSession(new BukkitWorld(player.getWorld()), -1);
|
||||
|
||||
impl.createCopy(editSession, clipboard);
|
||||
|
||||
check(player, clipboard, type, "selection", false);
|
||||
} catch (IncompleteRegionException e) {
|
||||
SchematicSystem.MESSAGE.send("COMMAND_CHECK_SELECTION_INCOMPLETE", player);
|
||||
} catch (WorldEditException e) {
|
||||
SchematicSystem.MESSAGE.send("COMMAND_SAVE_ERROR", player);
|
||||
}
|
||||
}
|
||||
|
||||
@Register("fix")
|
||||
public void fixSchematicCommand(Player player, @ErrorMessage("UTIL_CHECK_TYPE_NOT_FOUND") CheckSchemType type) {
|
||||
if(Core.getVersion() < 15) {
|
||||
SchematicSystem.MESSAGE.send("COMMAND_FIX_WRONG_VERSION", player);
|
||||
return;
|
||||
}
|
||||
Clipboard clipboard;
|
||||
try {
|
||||
clipboard = WorldEdit.getInstance().getSessionManager().findByName(player.getName()).getClipboard().getClipboard();
|
||||
} catch (EmptyClipboardException e) {
|
||||
SchematicSystem.MESSAGE.send("COMMAND_CHECK_CLIPBOARD_EMPTY", player);
|
||||
return;
|
||||
}
|
||||
AutoCheckerResult result = AutoChecker.check(clipboard, type);
|
||||
if(result.isOk()) {
|
||||
SchematicSystem.MESSAGE.send("COMMAND_FIX_OK", player);
|
||||
return;
|
||||
}
|
||||
try {
|
||||
clipboard = impl.fixClipboard(clipboard, result, type);
|
||||
WorldEdit.getInstance().getSessionManager().get(new BukkitPlayer(player)).setClipboard(new ClipboardHolder(clipboard));
|
||||
AutoCheckerResult after = AutoChecker.check(clipboard, type);
|
||||
if(after.isOk()) {
|
||||
SchematicSystem.MESSAGE.send("COMMAND_FIX_DONE", player);
|
||||
} else {
|
||||
after.sendErrorMessage(player, SchematicSystem.MESSAGE.parse("COMMAND_FIX_MANUAL", player));
|
||||
SchematicSystem.MESSAGE.send("COMMAND_FIX_COULD_NOT_FIX", player);
|
||||
}
|
||||
} catch (Exception e) {
|
||||
SchematicSystem.MESSAGE.send("COMMAND_FIX_ERROR", player);
|
||||
SchematicSystem.getInstance().getLogger().log(Level.SEVERE, e.getMessage(), e);
|
||||
}
|
||||
}
|
||||
}
|
@ -0,0 +1,173 @@
|
||||
/*
|
||||
This file is a part of the SteamWar software.
|
||||
|
||||
Copyright (C) 2023 SteamWar.de-Serverteam
|
||||
|
||||
This program is free software: you can redistribute it and/or modify
|
||||
it under the terms of the GNU Affero General Public License as published by
|
||||
the Free Software Foundation, either version 3 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 Affero General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU Affero General Public License
|
||||
along with this program. If not, see <https://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
package de.steamwar.schematicsystem.commands.schematiccommand.parts;
|
||||
|
||||
import de.steamwar.command.AbstractSWCommand;
|
||||
import de.steamwar.command.SWCommand;
|
||||
import de.steamwar.schematicsystem.SchematicSystem;
|
||||
import de.steamwar.schematicsystem.commands.schematiccommand.SchematicCommand;
|
||||
import de.steamwar.sql.*;
|
||||
import org.bukkit.Bukkit;
|
||||
import org.bukkit.entity.Player;
|
||||
|
||||
import java.time.Instant;
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
import java.util.Optional;
|
||||
|
||||
import static de.steamwar.schematicsystem.commands.schematiccommand.SchematicCommandUtils.getUser;
|
||||
import static de.steamwar.schematicsystem.commands.schematiccommand.SchematicCommandUtils.mkdirs;
|
||||
|
||||
@AbstractSWCommand.PartOf(SchematicCommand.class)
|
||||
public class MemberPart extends SWCommand {
|
||||
public MemberPart() {
|
||||
super(null);
|
||||
}
|
||||
|
||||
@Register("addmember")
|
||||
public void addMember(Player player, @Validator("isOwnerValidator") SchematicNode node, SteamwarUser... targets) {
|
||||
SteamwarUser user = getUser(player);
|
||||
if(Punishment.isPunished(user, Punishment.PunishmentType.NoSchemSharing, punishment -> SchematicSystem.MESSAGE.send("COMMAND_ADD_PUNISH", player, punishment.getReason()))) {
|
||||
return;
|
||||
}
|
||||
List<SteamwarUser> added = new ArrayList<>();
|
||||
for (SteamwarUser target: targets) {
|
||||
if(Punishment.isPunished(target,
|
||||
Punishment.PunishmentType.NoSchemReceiving,
|
||||
punishment -> SchematicSystem.MESSAGE.send("COMMAND_ADD_USER_PUNISHED", player, target.getUserName()))) {
|
||||
continue;
|
||||
}
|
||||
|
||||
if (user.getId() == target.getId()) {
|
||||
SchematicSystem.MESSAGE.send("COMMAND_ADD_OWN", player);
|
||||
continue;
|
||||
}
|
||||
|
||||
if (target.getId() == 0) {
|
||||
SchematicSystem.MESSAGE.send("COMMAND_ADD_PUBLIC", player);
|
||||
continue;
|
||||
}
|
||||
|
||||
if (NodeMember.getNodeMember(node.getId(), target.getId()) != null) {
|
||||
SchematicSystem.MESSAGE.send("COMMAND_ADD_ALREADY", player, target.getUserName());
|
||||
continue;
|
||||
}
|
||||
|
||||
NodeMember.createNodeMember(node.getId(), target.getId());
|
||||
added.add(target);
|
||||
|
||||
Player t = Bukkit.getPlayer(target.getUUID());
|
||||
if (t != null) {
|
||||
SchematicSystem.MESSAGE.send("COMMAND_ADD_ADDED", t, node.generateBreadcrumbs(), player.getName());
|
||||
}
|
||||
}
|
||||
|
||||
Optional<String> reduced = added.stream().map(SteamwarUser::getUserName).reduce((s, s2) -> s + ", " + s2);
|
||||
if (reduced.isPresent()) {
|
||||
SchematicSystem.MESSAGE.send(added.size()>1?"COMMAND_ADD_MANY":"COMMAND_ADD_ONE", player, reduced.get());
|
||||
} else {
|
||||
SchematicSystem.MESSAGE.send("COMMAND_ADD_NONE", player);
|
||||
}
|
||||
}
|
||||
|
||||
@Register("delmember")
|
||||
public void delMember(Player player, @Validator("isOwnerValidator") SchematicNode node, @Mapper("memberMapper") NodeMember member) {
|
||||
SteamwarUser user = getUser(player);
|
||||
SteamwarUser target = SteamwarUser.get(member.getMember());
|
||||
|
||||
List<SchematicNode> nodes = SchematicNode.deepGet(node.getId(), node1 -> node1.getOwner() != user.getId());
|
||||
if (!nodes.isEmpty()) {
|
||||
for (SchematicNode schematicNode : nodes) {
|
||||
SchematicNode newNode = mkdirs(schematicNode.generateBreadcrumbs().split("/"), target, 1);
|
||||
if(SchematicNode.getSchematicNode(schematicNode.getName(), newNode == null ? 0 : newNode.getId()) != null) {
|
||||
schematicNode.setName(schematicNode.getName() + "-" + Instant.now().getEpochSecond() % 1000);
|
||||
}
|
||||
schematicNode.setParent(newNode == null ? null : newNode.getId());
|
||||
}
|
||||
}
|
||||
|
||||
member.delete();
|
||||
SchematicSystem.MESSAGE.send("COMMAND_DELMEM_DONE", player, target.getUserName(), node.generateBreadcrumbs());
|
||||
|
||||
Player t = Bukkit.getPlayer(target.getUUID());
|
||||
if (t != null) {
|
||||
SchematicSystem.MESSAGE.send("COMMAND_DELMEM_DELETED", t, node.getName(), player.getName());
|
||||
}
|
||||
}
|
||||
|
||||
@Register("addteam")
|
||||
public void addTeam(Player player, @Validator("isOwnerValidator") SchematicNode node) {
|
||||
SteamwarUser user = getUser(player);
|
||||
Team team = Team.get(user.getTeam());
|
||||
if (team == null || team.getTeamId() == 0) {
|
||||
SchematicSystem.MESSAGE.send("COMMAND_ADD_TEAM_NOT_IN_TEAM", player);
|
||||
return;
|
||||
}
|
||||
|
||||
addMember(player, node, team.getMembers().stream().map(SteamwarUser::get).filter(steamwarUser -> steamwarUser.getId() != user.getId()).toArray(SteamwarUser[]::new));
|
||||
}
|
||||
|
||||
@Register("delteam")
|
||||
public void remTeam(Player player, @Validator("isOwnerValidator") SchematicNode node) {
|
||||
SteamwarUser user = getUser(player);
|
||||
Team team = Team.get(user.getTeam());
|
||||
if (team == null || team.getTeamId() == 0) {
|
||||
SchematicSystem.MESSAGE.send("COMMAND_DEL_TEAM_NOT_IN_TEAM", player);
|
||||
return;
|
||||
}
|
||||
|
||||
List<String> removed = new ArrayList<>();
|
||||
for (Integer member : team.getMembers()) {
|
||||
if (user.getId() == member) continue;
|
||||
NodeMember nodeMember = NodeMember.getNodeMember(node.getId(), member);
|
||||
if (nodeMember != null) {
|
||||
nodeMember.delete();
|
||||
removed.add(SteamwarUser.get(member).getUserName());
|
||||
}
|
||||
}
|
||||
|
||||
Optional<String> reduced = removed.stream().reduce((s, s2) -> s + ", " + s2);
|
||||
if (reduced.isPresent()) {
|
||||
SchematicSystem.MESSAGE.send("COMMAND_DEL_TEAM_DONE", player, reduced.get());
|
||||
} else {
|
||||
SchematicSystem.MESSAGE.send("COMMAND_DEL_TEAM_NONE", player);
|
||||
}
|
||||
}
|
||||
|
||||
@Register("clearmember")
|
||||
public void clearMember(Player player, @Validator("isOwnerValidator") SchematicNode node) {
|
||||
node.getMembers().forEach(NodeMember::delete);
|
||||
SchematicSystem.MESSAGE.send("COMMAND_CLEAR_MEMBER_DONE", player);
|
||||
}
|
||||
|
||||
@Register("delallmember")
|
||||
public void delAllMember(Player player, SteamwarUser target) {
|
||||
SteamwarUser user = getUser(player);
|
||||
int i = 0;
|
||||
for (NodeMember nodeMember : NodeMember.getSchematics(target.getId())) {
|
||||
SchematicNode node = SchematicNode.getSchematicNode(nodeMember.getNode());
|
||||
if (node.getOwner() == user.getId()) {
|
||||
nodeMember.delete();
|
||||
i++;
|
||||
}
|
||||
}
|
||||
SchematicSystem.MESSAGE.send("COMMAND_DEL_ALL_MEMBER", player, target.getUserName(), i);
|
||||
}
|
||||
}
|
@ -0,0 +1,186 @@
|
||||
/*
|
||||
This file is a part of the SteamWar software.
|
||||
|
||||
Copyright (C) 2023 SteamWar.de-Serverteam
|
||||
|
||||
This program is free software: you can redistribute it and/or modify
|
||||
it under the terms of the GNU Affero General Public License as published by
|
||||
the Free Software Foundation, either version 3 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 Affero General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU Affero General Public License
|
||||
along with this program. If not, see <https://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
package de.steamwar.schematicsystem.commands.schematiccommand.parts;
|
||||
|
||||
import com.sk89q.worldedit.extent.clipboard.Clipboard;
|
||||
import de.steamwar.command.AbstractSWCommand;
|
||||
import de.steamwar.command.SWCommand;
|
||||
import de.steamwar.schematicsystem.CheckSchemType;
|
||||
import de.steamwar.schematicsystem.SafeSchematicNode;
|
||||
import de.steamwar.schematicsystem.SchematicSystem;
|
||||
import de.steamwar.schematicsystem.autocheck.AutoChecker;
|
||||
import de.steamwar.schematicsystem.commands.schematiccommand.SchematicCommandUtils;
|
||||
import de.steamwar.schematicsystem.commands.schematiccommand.SchematicCommand;
|
||||
import de.steamwar.sql.*;
|
||||
import net.md_5.bungee.api.ChatColor;
|
||||
import net.md_5.bungee.api.chat.ClickEvent;
|
||||
import net.md_5.bungee.api.chat.HoverEvent;
|
||||
import net.md_5.bungee.api.chat.TextComponent;
|
||||
import org.bukkit.entity.Player;
|
||||
|
||||
import java.io.IOException;
|
||||
|
||||
import static de.steamwar.schematicsystem.commands.schematiccommand.SchematicCommandUtils.*;
|
||||
|
||||
@AbstractSWCommand.PartOf(SchematicCommand.class)
|
||||
public class ModifyPart extends SWCommand {
|
||||
public ModifyPart() {
|
||||
super(null);
|
||||
}
|
||||
|
||||
@Register("changetype")
|
||||
public void changeType(Player player, @Validator("isOwnerSchematicValidator") SchematicNode node) {
|
||||
TextComponent base = new TextComponent();
|
||||
|
||||
Clipboard clipboard = null;
|
||||
try {
|
||||
clipboard = new SchematicData(node).load();
|
||||
} catch (IOException ignored) { }
|
||||
|
||||
Clipboard finalClipboard = clipboard;
|
||||
|
||||
String breadcrumb = node.generateBreadcrumbs();
|
||||
|
||||
SchematicType.values().parallelStream()
|
||||
.filter(SchematicType::isAssignable)
|
||||
.filter(type -> finalClipboard == null || CheckSchemType.get(type) == null || AutoChecker.sizeCheck(finalClipboard, CheckSchemType.get(type)).fastOk())
|
||||
.forEach(type -> {
|
||||
TextComponent component = new TextComponent(type.name() + " ");
|
||||
component.setColor(ChatColor.GRAY);
|
||||
component.setBold(true);
|
||||
component.setHoverEvent(new HoverEvent(HoverEvent.Action.SHOW_TEXT, TextComponent.fromLegacyText(SchematicSystem.MESSAGE.parse("COMMAND_CHANGE_TYPE_SELECT", player))));
|
||||
component.setClickEvent(new ClickEvent(ClickEvent.Action.RUN_COMMAND, "/schem changetype " + breadcrumb + " " + type.name()));
|
||||
base.addExtra(component);
|
||||
});
|
||||
|
||||
player.spigot().sendMessage(base);
|
||||
}
|
||||
|
||||
@Register("changetype")
|
||||
public void changeType(Player player, @Validator("isOwnerSchematicValidator") SchematicNode node, SchematicType type) {
|
||||
changeType(player, node, type, null);
|
||||
}
|
||||
|
||||
@Register("changetype")
|
||||
public void changeType(Player player, @Validator("isOwnerSchematicValidator") SchematicNode node, SchematicType type, SchematicCommand.Extend extend) {
|
||||
SchematicCommandUtils.changeType(player, node, type, extend);
|
||||
}
|
||||
|
||||
@Register("move")
|
||||
public void moveToNull(Player player, @ErrorMessage("COMMAND_INVALID_NODE") SchematicNode node) {
|
||||
move(player, node, "/");
|
||||
}
|
||||
|
||||
@Register("move")
|
||||
public void move(Player player, @ErrorMessage("COMMAND_INVALID_NODE") SchematicNode node, @Mapper("dirStringMapper") String name) {
|
||||
SteamwarUser user = getUser(player);
|
||||
|
||||
if (name.equals("/")) {
|
||||
if(node.getOwner() == user.getId()) {
|
||||
node.setParent(null);
|
||||
} else if(NodeMember.getNodeMember(node.getId(), user.getId()) != null) {
|
||||
NodeMember member = NodeMember.getNodeMember(node.getId(), user.getId());
|
||||
member.setParentId(null);
|
||||
} else {
|
||||
SchematicSystem.MESSAGE.send("COMMAND_NOT_OWN", player);
|
||||
return;
|
||||
}
|
||||
} else {
|
||||
if (name.startsWith("/")) name = name.substring(1);
|
||||
if (name.endsWith("/")) name = name.substring(0, name.length() - 1);
|
||||
String[] layers = name.split("/");
|
||||
if (invalidSchemName(player, layers)) return;
|
||||
SchematicNode newNode = mkdirs(layers, user, 0);
|
||||
if(SchematicNode.parentsOfNode(user, newNode.getId()).stream().anyMatch(n -> n.getId() == node.getId())) {
|
||||
SchematicSystem.MESSAGE.send("COMMAND_MOVE_RECURSIVE", player);
|
||||
return;
|
||||
}
|
||||
|
||||
if(node.getOwner() == user.getId()) {
|
||||
SafeSchematicNode.Result result = SafeSchematicNode.setParent(user, node, newNode);
|
||||
if(!result.isSuccessful()) {
|
||||
result.sendError(player);
|
||||
return;
|
||||
}
|
||||
} else if(NodeMember.getNodeMember(node.getId(), user.getId()) != null) {
|
||||
NodeMember member = NodeMember.getNodeMember(node.getId(), user.getId());
|
||||
member.setParentId(newNode.getId());
|
||||
} else {
|
||||
SchematicSystem.MESSAGE.send("COMMAND_NOT_OWN", player);
|
||||
return;
|
||||
}
|
||||
}
|
||||
SchematicSystem.MESSAGE.send("COMMAND_MOVE_DONE", player, SchematicNode.byIdAndUser(user, node.getId()).generateBreadcrumbs());
|
||||
}
|
||||
|
||||
@Register("rename")
|
||||
public void rename(Player player, @Validator("isOwnerValidator") SchematicNode node, String name) {
|
||||
SteamwarUser user = getUser(player);
|
||||
if (invalidSchemName(player, new String[]{name})) {
|
||||
return;
|
||||
}
|
||||
SafeSchematicNode.Result result = SafeSchematicNode.setName(user, node, name);
|
||||
if (!result.isSuccessful()) {
|
||||
result.sendError(player);
|
||||
return;
|
||||
}
|
||||
SchematicSystem.MESSAGE.send("COMMAND_RENAME_DONE", player, node.generateBreadcrumbs());
|
||||
}
|
||||
|
||||
@Register("delete")
|
||||
public void deleteSchem(Player player, SchematicNode node) {
|
||||
SteamwarUser user = SteamwarUser.get(player.getUniqueId());
|
||||
if (node.getOwner() != user.getId()) {
|
||||
NodeMember member = NodeMember.getNodeMember(node.getId(), user.getId());
|
||||
if (member == null) {
|
||||
SchematicSystem.MESSAGE.send("COMMAND_DELETE_NOT_OWN", player);
|
||||
return;
|
||||
}
|
||||
member.delete();
|
||||
SchematicSystem.MESSAGE.send("COMMAND_DELETE_MEMBER", player);
|
||||
return;
|
||||
}
|
||||
|
||||
if (node.isDir()) {
|
||||
if (SchematicNode.getSchematicNodeInNode(node).isEmpty()) {
|
||||
SchematicSystem.MESSAGE.send("COMMAND_DELETE_DIR", player, node.generateBreadcrumbs());
|
||||
node.delete();
|
||||
} else {
|
||||
SchematicSystem.MESSAGE.send("COMMAND_DELETE_DIR_FULL", player);
|
||||
}
|
||||
} else {
|
||||
SchematicSystem.MESSAGE.send("COMMAND_DELETE_SCHEM", player, node.generateBreadcrumbs());
|
||||
node.delete();
|
||||
}
|
||||
}
|
||||
|
||||
@Register("lockreplay")
|
||||
public void lockreplay(Player player, @Validator("isOwnerSchematicValidator") SchematicNode node) {
|
||||
node.setAllowReplay(false);
|
||||
SchematicSystem.MESSAGE.send("COMMAND_LOCKREPLAY", player, node.getName());
|
||||
}
|
||||
|
||||
@Register("replacecolor")
|
||||
public void replacecolor(Player player, @Validator("isOwnerSchematicValidator") SchematicNode node) {
|
||||
boolean state = !node.replaceColor();
|
||||
node.setReplaceColor(state);
|
||||
SchematicSystem.MESSAGE.send(state?"COMMAND_REPLACE_COLOR_ON":"COMMAND_REPLACE_COLOR_OFF", player, node.getName());
|
||||
}
|
||||
}
|
@ -0,0 +1,133 @@
|
||||
/*
|
||||
This file is a part of the SteamWar software.
|
||||
|
||||
Copyright (C) 2023 SteamWar.de-Serverteam
|
||||
|
||||
This program is free software: you can redistribute it and/or modify
|
||||
it under the terms of the GNU Affero General Public License as published by
|
||||
the Free Software Foundation, either version 3 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 Affero General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU Affero General Public License
|
||||
along with this program. If not, see <https://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
package de.steamwar.schematicsystem.commands.schematiccommand.parts;
|
||||
|
||||
import de.steamwar.command.AbstractSWCommand;
|
||||
import de.steamwar.command.SWCommand;
|
||||
import de.steamwar.inventory.SWAnvilInv;
|
||||
import de.steamwar.inventory.SchematicSelector;
|
||||
import de.steamwar.providers.BauServerInfo;
|
||||
import de.steamwar.schematicsystem.SchematicSystem;
|
||||
import de.steamwar.schematicsystem.commands.schematiccommand.SchematicCommand;
|
||||
import de.steamwar.sql.*;
|
||||
import net.md_5.bungee.api.chat.ClickEvent;
|
||||
import org.bukkit.Bukkit;
|
||||
import org.bukkit.Material;
|
||||
import org.bukkit.entity.Player;
|
||||
|
||||
import java.util.logging.Level;
|
||||
|
||||
import static de.steamwar.schematicsystem.commands.schematiccommand.SchematicCommandUtils.*;
|
||||
|
||||
@AbstractSWCommand.PartOf(SchematicCommand.class)
|
||||
public class SavePart extends SWCommand {
|
||||
|
||||
public SavePart() {
|
||||
super(null);
|
||||
}
|
||||
|
||||
@Register("save")
|
||||
@Register("s")
|
||||
public void saveSchem(Player player) {
|
||||
SchematicSelector selector = new SchematicSelector(player, SchematicSelector.selectSchematicNode(), schematicNode -> {
|
||||
if(schematicNode == null || schematicNode.isDir()) {
|
||||
SWAnvilInv anvilInv = new SWAnvilInv(player, SchematicSystem.MESSAGE.parse("COMMAND_ENTER_NAME", player));
|
||||
anvilInv.setCallback(s -> saveSchem(player, schematicNode==null?s:(schematicNode.generateBreadcrumbs() + s), true));
|
||||
anvilInv.setItem(Material.CAULDRON);
|
||||
anvilInv.open();
|
||||
} else {
|
||||
saveSchem(player, schematicNode.generateBreadcrumbs(), true);
|
||||
}
|
||||
});
|
||||
selector.setSingleDirOpen(false);
|
||||
selector.open();
|
||||
}
|
||||
|
||||
@Register("save")
|
||||
@Register("s")
|
||||
public void saveSchem(Player player, @AbstractSWCommand.Mapper("stringMapper") String name, @AbstractSWCommand.StaticValue(value = {"", "-f"}, allowISE=true) @AbstractSWCommand.OptionalValue("") boolean overwrite) {
|
||||
SteamwarUser user = getUser(player);
|
||||
if(BauServerInfo.isBauServer() && BauServerInfo.getOwnerId() != user.getId() &&
|
||||
(Punishment.isPunished(user, Punishment.PunishmentType.NoSchemReceiving, punishment ->
|
||||
SchematicSystem.MESSAGE.send("COMMAND_PUNISHMENT_NO_SAVE_EXTERNAL", player)) ||
|
||||
Punishment.isPunished(SteamwarUser.get(BauServerInfo.getOwnerId()), Punishment.PunishmentType.NoSchemSharing, punishment ->
|
||||
SchematicSystem.MESSAGE.send("COMMAND_PUNISHMENT_NO_SAVE", player)))) {
|
||||
return;
|
||||
}
|
||||
if (name.endsWith("/")) {
|
||||
SchematicSystem.MESSAGE.send("COMMAND_SAVE_NO_NAME", player);
|
||||
return;
|
||||
}
|
||||
if (name.startsWith("/")) name = name.substring(1);
|
||||
String[] layers = name.split("/");
|
||||
if (invalidSchemName(player, layers)) return;
|
||||
SchematicNode currentNode = mkdirs(layers, user, 1);
|
||||
|
||||
SchematicNode node = SchematicNode.getNodeFromPath(user, String.join("/", layers));
|
||||
if (node != null) {
|
||||
if(node.isDir()) {
|
||||
SchematicSystem.MESSAGE.send("COMMAND_SAVE_FOLDER", player);
|
||||
return;
|
||||
} else if (!node.getSchemtype().writeable() || node.getOwner() != user.getId()) {
|
||||
SchematicSystem.MESSAGE.send("COMMAND_SAVE_NO_OVERWRITE", player);
|
||||
return;
|
||||
} else if(!overwrite) {
|
||||
SchematicSystem.MESSAGE.send("COMMAND_SAVE_OVERWRITE_CONFIRM", player, SchematicSystem.MESSAGE.parse("COMMAND_SAVE_OVERWRITE_CONFIRM_HOVER", player), new ClickEvent(ClickEvent.Action.RUN_COMMAND, "/schem s " + name + " -f"), node.generateBreadcrumbs());
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
boolean newSchem = false;
|
||||
if (node == null) {
|
||||
newSchem = true;
|
||||
node = SchematicNode.createSchematic(user.getId(), layers[layers.length - 1], currentNode == null ? 0 : currentNode.getId());
|
||||
}
|
||||
|
||||
try {
|
||||
new SchematicData(node).saveFromPlayer(player);
|
||||
} catch (NoClipboardException e) {
|
||||
SchematicSystem.MESSAGE.send("COMMAND_SAVE_CLIPBOARD_EMPTY", player);
|
||||
if (newSchem)
|
||||
node.delete();
|
||||
return;
|
||||
} catch (Exception ex) {
|
||||
Bukkit.getLogger().log(Level.SEVERE, "Could not save schematic", ex);
|
||||
SchematicSystem.MESSAGE.send("COMMAND_SAVE_ERROR", player);
|
||||
if (newSchem)
|
||||
node.delete();
|
||||
return;
|
||||
}
|
||||
|
||||
SchematicSystem.MESSAGE.send(newSchem?"COMMAND_SAVE_DONE":"COMMAND_SAVE_OVERWRITE", player, node.generateBreadcrumbs());
|
||||
}
|
||||
|
||||
@Register("dir")
|
||||
@Register("ordner")
|
||||
@Register("mkdir")
|
||||
public void mkdir(Player player, @Mapper("dirStringMapper") String name) {
|
||||
SteamwarUser user = getUser(player);
|
||||
if (name.startsWith("/")) name = name.substring(1);
|
||||
if (name.endsWith("/")) name = name.substring(0, name.length() - 1);
|
||||
String[] layers = name.split("/");
|
||||
if (invalidSchemName(player, layers)) return;
|
||||
SchematicNode node = mkdirs(layers, user, 0);
|
||||
SchematicSystem.MESSAGE.send("COMMAND_DIR_DONE", player, node.generateBreadcrumbs());
|
||||
}
|
||||
}
|
@ -0,0 +1,184 @@
|
||||
/*
|
||||
This file is a part of the SteamWar software.
|
||||
|
||||
Copyright (C) 2023 SteamWar.de-Serverteam
|
||||
|
||||
This program is free software: you can redistribute it and/or modify
|
||||
it under the terms of the GNU Affero General Public License as published by
|
||||
the Free Software Foundation, either version 3 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 Affero General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU Affero General Public License
|
||||
along with this program. If not, see <https://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
package de.steamwar.schematicsystem.commands.schematiccommand.parts;
|
||||
|
||||
import de.steamwar.command.*;
|
||||
import de.steamwar.schematicsystem.SchematicSystem;
|
||||
import de.steamwar.schematicsystem.commands.schematiccommand.SchematicCommandUtils;
|
||||
import de.steamwar.schematicsystem.commands.schematiccommand.SchematicCommand;
|
||||
import de.steamwar.sql.SchematicNode;
|
||||
import de.steamwar.sql.SchematicType;
|
||||
import de.steamwar.sql.SteamwarUser;
|
||||
import org.bukkit.Material;
|
||||
import org.bukkit.command.CommandSender;
|
||||
import org.bukkit.entity.Player;
|
||||
|
||||
import java.util.*;
|
||||
import java.util.concurrent.atomic.AtomicBoolean;
|
||||
import java.util.function.Function;
|
||||
import java.util.function.Predicate;
|
||||
import java.util.stream.Collectors;
|
||||
|
||||
import static de.steamwar.schematicsystem.commands.schematiccommand.SchematicCommandUtils.createCachedSchemList;
|
||||
import static de.steamwar.schematicsystem.commands.schematiccommand.SchematicCommandUtils.getUser;
|
||||
|
||||
@AbstractSWCommand.PartOf(SchematicCommand.class)
|
||||
public class SearchPart extends SWCommand {
|
||||
|
||||
private static final Map<String, AbstractTypeMapper<CommandSender, ?>> searchMapper = new HashMap<>();
|
||||
|
||||
|
||||
static {
|
||||
searchMapper.put("-type", SWCommandUtils.createMapper(SchematicType.values().stream().map(SchematicType::name).toArray(String[]::new)));
|
||||
searchMapper.put("-owner", SWCommandUtils.createMapper(Function.identity(), (commandSender, s) -> Collections.singletonList(s)));
|
||||
Class<?> clazz = Material.class;
|
||||
searchMapper.put("-item", SWCommandUtils.createEnumMapper((Class<Enum<?>>) clazz));
|
||||
searchMapper.put("-public", null);
|
||||
searchMapper.put("-ignoreCase", null);
|
||||
searchMapper.put("-exclude", SWCommandUtils.createMapper(Function.identity(), (commandSender, s) -> Collections.singletonList(s)));
|
||||
searchMapper.put("-excludeType", SWCommandUtils.createMapper(SchematicType.values().stream().map(SchematicType::name).toArray(String[]::new)));
|
||||
searchMapper.put("-excludeOwner", SWCommandUtils.createMapper(Function.identity(), (commandSender, s) -> Collections.singletonList(s)));
|
||||
}
|
||||
|
||||
public SearchPart() {
|
||||
super(null);
|
||||
}
|
||||
|
||||
public boolean containsCheckCase(String s, String s2, AtomicBoolean isIgnoreCase) {
|
||||
if (isIgnoreCase.get()) {
|
||||
return s.toLowerCase().contains(s2.toLowerCase());
|
||||
}
|
||||
return s.contains(s2);
|
||||
}
|
||||
|
||||
@Register("search")
|
||||
public void schemSearch(Player player, @OptionalValue("1") int page, @Mapper("searchMapper") String... query) {
|
||||
SteamwarUser user = getUser(player);
|
||||
int userId = user.getId();
|
||||
List<Predicate<SchematicNode>> predicates = new ArrayList<>();
|
||||
List<String> nameList = new ArrayList<>();
|
||||
int i = 0;
|
||||
AtomicBoolean isIgnoreCase = new AtomicBoolean(false);
|
||||
while (i < query.length) {
|
||||
String current = query[i];
|
||||
if (searchMapper.containsKey(current)) {
|
||||
if (searchMapper.get(current) == null) {
|
||||
switch (current) {
|
||||
case "-public":
|
||||
userId = 0;
|
||||
break;
|
||||
case "-ignoreCase":
|
||||
isIgnoreCase.set(true);
|
||||
break;
|
||||
default:
|
||||
throw new IllegalStateException("Unexpected value: " + current);
|
||||
}
|
||||
} else if (i + 1 < query.length) {
|
||||
int finalI = i;
|
||||
switch (current) {
|
||||
case "-type":
|
||||
predicates.add(node -> !node.isDir() && node.getSchemtype().name().equalsIgnoreCase(query[finalI + 1]));
|
||||
break;
|
||||
case "-item":
|
||||
predicates.add(node -> node.getItem().equalsIgnoreCase(query[finalI + 1]));
|
||||
break;
|
||||
case "-owner":
|
||||
SteamwarUser steamwarUser = SteamwarUser.get(query[finalI + 1]);
|
||||
if (steamwarUser == null) {
|
||||
SchematicSystem.MESSAGE.send("COMMAND_SEARCH_NOT_A_PLAYER", player, query[finalI + 1]);
|
||||
return;
|
||||
}
|
||||
predicates.add(node -> node.getOwner() == steamwarUser.getId());
|
||||
break;
|
||||
case "-exclude":
|
||||
predicates.add(node -> !node.getName().contains(query[finalI + 1]));
|
||||
break;
|
||||
case "-excludeType":
|
||||
predicates.add(node -> !node.isDir() && !node.getSchemtype().name().equalsIgnoreCase(query[finalI + 1]));
|
||||
break;
|
||||
case "-excludeOwner":
|
||||
SteamwarUser steamwarUser1 = SteamwarUser.get(query[finalI + 1]);
|
||||
if (steamwarUser1 == null) {
|
||||
SchematicSystem.MESSAGE.send("COMMAND_SEARCH_NOT_A_PLAYER", player, query[finalI + 1]);
|
||||
return;
|
||||
}
|
||||
predicates.add(node -> node.getOwner() != steamwarUser1.getId());
|
||||
break;
|
||||
default:
|
||||
throw new IllegalStateException("Unexpected value: " + current);
|
||||
}
|
||||
i++;
|
||||
}
|
||||
} else {
|
||||
predicates.add(node -> containsCheckCase(node.getName(), current, isIgnoreCase));
|
||||
nameList.add(current);
|
||||
}
|
||||
i++;
|
||||
}
|
||||
|
||||
List<SchematicNode> nodes = SchematicNode.getAll(SteamwarUser.get(userId)).stream().filter(node -> {
|
||||
for (Predicate<SchematicNode> predicate : predicates) {
|
||||
if (!predicate.test(node)) {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
return true;
|
||||
}).collect(Collectors.toList());
|
||||
createCachedSchemList(player, nodes, Math.max(page - 1, 0), null, SchematicCommandUtils.SchematicListBehavior.builder().setPublics(userId == 0).setShowPath(false).setRenderHook(s -> {
|
||||
for (String ss : nameList) {
|
||||
s = s.replace(ss, "§e§l" + ss + "§7");
|
||||
}
|
||||
return "§7" + s;
|
||||
}).setNonCachedBreadcrumbs(true).build());
|
||||
}
|
||||
|
||||
@Mapper(value = "searchMapper", local = true)
|
||||
public TypeMapper<String> searchTypeMapper() {
|
||||
return new TypeMapper<String>() {
|
||||
@Override
|
||||
public String map(CommandSender commandSender, String[] previousArguments, String s) {
|
||||
return s;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Collection<String> tabCompletes(CommandSender commandSender, String[] strings, String s) {
|
||||
if (strings.length == 0) {
|
||||
List<String> list = new ArrayList<>();
|
||||
list.add(s);
|
||||
list.addAll(searchMapper.keySet());
|
||||
return list;
|
||||
}
|
||||
String last = strings[strings.length - 1];
|
||||
if (searchMapper.containsKey(last)) {
|
||||
AbstractTypeMapper<CommandSender, ?> mapper = searchMapper.get(last);
|
||||
if (mapper == null) {
|
||||
List<String> list = new ArrayList<>(searchMapper.keySet());
|
||||
list.add(s);
|
||||
return list;
|
||||
}
|
||||
return mapper.tabCompletes(commandSender, strings, s);
|
||||
}
|
||||
List<String> list = new ArrayList<>(searchMapper.keySet());
|
||||
list.add(s);
|
||||
return list;
|
||||
}
|
||||
};
|
||||
}
|
||||
}
|
@ -0,0 +1,98 @@
|
||||
/*
|
||||
This file is a part of the SteamWar software.
|
||||
|
||||
Copyright (C) 2023 SteamWar.de-Serverteam
|
||||
|
||||
This program is free software: you can redistribute it and/or modify
|
||||
it under the terms of the GNU Affero General Public License as published by
|
||||
the Free Software Foundation, either version 3 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 Affero General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU Affero General Public License
|
||||
along with this program. If not, see <https://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
package de.steamwar.schematicsystem.commands.schematiccommand.parts;
|
||||
|
||||
import de.steamwar.command.AbstractSWCommand;
|
||||
import de.steamwar.command.SWCommand;
|
||||
import de.steamwar.schematicsystem.commands.schematiccommand.GUI;
|
||||
import de.steamwar.schematicsystem.commands.schematiccommand.SchematicCommandUtils;
|
||||
import de.steamwar.schematicsystem.commands.schematiccommand.SchematicCommand;
|
||||
import de.steamwar.sql.SchematicNode;
|
||||
import de.steamwar.sql.SteamwarUser;
|
||||
import org.bukkit.entity.Player;
|
||||
|
||||
import static de.steamwar.schematicsystem.commands.schematiccommand.SchematicCommandUtils.*;
|
||||
|
||||
@AbstractSWCommand.PartOf(SchematicCommand.class)
|
||||
public class ViewPart extends SWCommand {
|
||||
public ViewPart() {
|
||||
super(null);
|
||||
}
|
||||
|
||||
@Register("list")
|
||||
@Register({"list", "/"})
|
||||
public void schemList(Player player, @OptionalValue(value = "1", onlyUINIG = true) int page) {
|
||||
createCachedSchemList(player, SchematicNode.list(getUser(player), null), Math.max(page - 1, 0), null, SchematicCommandUtils.SchematicListBehavior.DEFAULT);
|
||||
}
|
||||
|
||||
@Register({"list", "public"})
|
||||
public void schemListPublic(Player player, @Validator("isDirValidator") @Mapper("publicDirMapper") SchematicNode node, @OptionalValue("1") int page) {
|
||||
schemList(player, node, page);
|
||||
}
|
||||
|
||||
@Register({"list", "public"})
|
||||
@Register({"list", "public", "/"})
|
||||
public void schemListPublic(Player player, @OptionalValue(value = "1", onlyUINIG = true) int page) {
|
||||
createCachedSchemList(player, SchematicNode.list(SteamwarUser.get(0), null), Math.max(page - 1, 0), null, SchematicCommandUtils.SchematicListBehavior.builder().setPublics(true).setPageCommandGen(integer -> "/schem list public " + integer).build());
|
||||
}
|
||||
|
||||
@Register("list")
|
||||
public void schemList(Player player, @Validator("isDirValidator") @Mapper("dirMapper") SchematicNode node, @OptionalValue("1") int page) {
|
||||
SteamwarUser user = getUser(player);
|
||||
createCachedSchemList(player, SchematicNode.list(user, node.getId()), Math.max(page - 1, 0), node, SchematicCommandUtils.SchematicListBehavior.builder().setPublics(node.getOwner() == 0).setPageCommandGen(value -> "/schem list " + (node.getOwner()==0?"public ":"") + node.generateBreadcrumbs() + " " + value).build());
|
||||
}
|
||||
|
||||
@Register({"info", "public"})
|
||||
public void schemInfoPublic(Player player, @Mapper("publicMapper") SchematicNode node) {
|
||||
schemInfo(player, SchematicNode.getSchematicNode(node.getId()));
|
||||
}
|
||||
|
||||
@Register("info")
|
||||
public void schemInfo(Player player, @ErrorMessage("COMMAND_INVALID_NODE") SchematicNode node) {
|
||||
printSchemInfo(player, node);
|
||||
}
|
||||
|
||||
@Register(value = "page", noTabComplete = true)
|
||||
public void pageCommand(Player player, int page) {
|
||||
cachedSchemList(player, page);
|
||||
}
|
||||
|
||||
@Register({"l", "public"})
|
||||
@Register({"load", "public"})
|
||||
public void loadSchemPublic(Player player, @Validator("isSchemValidator") @Mapper("publicMapper") SchematicNode node) {
|
||||
loadSchem(player, node);
|
||||
}
|
||||
|
||||
@Register("l")
|
||||
@Register("load")
|
||||
public void loadSchem(Player player, @Validator("isSchemValidator") SchematicNode node) {
|
||||
SchematicCommandUtils.loadSchem(player, node);
|
||||
}
|
||||
|
||||
@Register("gui")
|
||||
public void gui(Player player) {
|
||||
GUI.list(player);
|
||||
}
|
||||
|
||||
@Register("download")
|
||||
public void download(Player player, @Validator("isOwnerSchematicValidator") SchematicNode node) {
|
||||
SchematicCommandUtils.download(player, node);
|
||||
}
|
||||
}
|
@ -0,0 +1,28 @@
|
||||
CheckPart:
|
||||
- fix
|
||||
- check
|
||||
MemberPart:
|
||||
- addmember
|
||||
- delmember
|
||||
- addteam
|
||||
- delteam
|
||||
- clearmember
|
||||
- delallmember
|
||||
ModifyPart:
|
||||
- changetype
|
||||
- move
|
||||
- rename
|
||||
- delete
|
||||
- lockreplay
|
||||
- replacecolor
|
||||
SavePart:
|
||||
- save
|
||||
- ordner
|
||||
SearchPart:
|
||||
- search
|
||||
ViewPart:
|
||||
- list
|
||||
- info
|
||||
- load
|
||||
- gui
|
||||
- download
|
@ -0,0 +1,33 @@
|
||||
/*
|
||||
This file is a part of the SteamWar software.
|
||||
|
||||
Copyright (C) 2023 SteamWar.de-Serverteam
|
||||
|
||||
This program is free software: you can redistribute it and/or modify
|
||||
it under the terms of the GNU Affero General Public License as published by
|
||||
the Free Software Foundation, either version 3 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 Affero General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU Affero General Public License
|
||||
along with this program. If not, see <https://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
package de.steamwar.schematicsystem.listener;
|
||||
|
||||
import de.steamwar.schematicsystem.commands.schematiccommand.SchematicCommandUtils;
|
||||
import org.bukkit.event.EventHandler;
|
||||
import org.bukkit.event.Listener;
|
||||
import org.bukkit.event.player.PlayerQuitEvent;
|
||||
|
||||
public class PlayerEventListener implements Listener {
|
||||
|
||||
@EventHandler
|
||||
public void onPlayerQuit(PlayerQuitEvent event) {
|
||||
SchematicCommandUtils.quitPlayer(event.getPlayer());
|
||||
}
|
||||
}
|
8
SchematicSystem_Core/src/plugin.yml
Normale Datei
8
SchematicSystem_Core/src/plugin.yml
Normale Datei
@ -0,0 +1,8 @@
|
||||
name: SchematicSystem
|
||||
version: "2.1.0"
|
||||
authors: [Yaruma3341, Lixfel, Chaoscaot]
|
||||
depend: [SpigotCore, WorldEdit]
|
||||
main: de.steamwar.schematicsystem.SchematicSystem
|
||||
website: steamwar.de
|
||||
api-version: "1.13"
|
||||
description: Schematic-Frontend
|
@ -1,96 +0,0 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<project xmlns="http://maven.apache.org/POM/4.0.0"
|
||||
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
|
||||
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
|
||||
<modelVersion>4.0.0</modelVersion>
|
||||
|
||||
<parent>
|
||||
<groupId>steamwar</groupId>
|
||||
<artifactId>SchematicSystem</artifactId>
|
||||
<version>1.0</version>
|
||||
</parent>
|
||||
|
||||
<properties>
|
||||
<main.basedir>${project.basedir}/..</main.basedir>
|
||||
</properties>
|
||||
|
||||
<artifactId>SchematicSystem_Main</artifactId>
|
||||
<version>1.0</version>
|
||||
<packaging>jar</packaging>
|
||||
|
||||
<build>
|
||||
<sourceDirectory>src</sourceDirectory>
|
||||
<resources>
|
||||
<resource>
|
||||
<directory>src</directory>
|
||||
<excludes>
|
||||
<exclude>**/*.java</exclude>
|
||||
<exclude>**/*.kt</exclude>
|
||||
</excludes>
|
||||
</resource>
|
||||
</resources>
|
||||
<plugins>
|
||||
<plugin>
|
||||
<groupId>org.apache.maven.plugins</groupId>
|
||||
<artifactId>maven-shade-plugin</artifactId>
|
||||
<version>3.2.1</version>
|
||||
<executions>
|
||||
<execution>
|
||||
<phase>package</phase>
|
||||
<goals>
|
||||
<goal>shade</goal>
|
||||
</goals>
|
||||
</execution>
|
||||
</executions>
|
||||
</plugin>
|
||||
</plugins>
|
||||
<finalName>schematicsystem</finalName>
|
||||
</build>
|
||||
|
||||
|
||||
<repositories>
|
||||
<repository>
|
||||
<id>maven-restlet</id>
|
||||
<name>Public online Restlet repository</name>
|
||||
<url>http://maven.restlet.org</url>
|
||||
</repository>
|
||||
</repositories>
|
||||
|
||||
<dependencies>
|
||||
<dependency>
|
||||
<groupId>steamwar</groupId>
|
||||
<artifactId>Spigot</artifactId>
|
||||
<version>1.15</version>
|
||||
<scope>system</scope>
|
||||
<systemPath>${main.basedir}/lib/Spigot-1.15.jar</systemPath>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>steamwar</groupId>
|
||||
<artifactId>SchematicSystem_15</artifactId>
|
||||
<version>1.0</version>
|
||||
<scope>compile</scope>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>steamwar</groupId>
|
||||
<artifactId>SchematicSystem_12</artifactId>
|
||||
<version>1.0</version>
|
||||
<scope>compile</scope>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>steamwar</groupId>
|
||||
<artifactId>SchematicSystem_API</artifactId>
|
||||
<version>1.0</version>
|
||||
<scope>compile</scope>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>org.apache.httpcomponents</groupId>
|
||||
<artifactId>httpclient</artifactId>
|
||||
<version>4.5.13</version>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>org.apache.httpcomponents</groupId>
|
||||
<artifactId>httpmime</artifactId>
|
||||
<version>4.5.13</version>
|
||||
</dependency>
|
||||
</dependencies>
|
||||
</project>
|
@ -1,138 +0,0 @@
|
||||
/*
|
||||
This file is a part of the SteamWar software.
|
||||
|
||||
Copyright (C) 2020 SteamWar.de-Serverteam
|
||||
|
||||
This program is free software: you can redistribute it and/or modify
|
||||
it under the terms of the GNU Affero General Public License as published by
|
||||
the Free Software Foundation, either version 3 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 Affero General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU Affero General Public License
|
||||
along with this program. If not, see <https://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
package de.steamwar.schematicsystem;
|
||||
|
||||
import de.steamwar.core.VersionedCallable;
|
||||
import de.steamwar.sql.Schematic;
|
||||
import de.steamwar.sql.SchematicType;
|
||||
import org.bukkit.configuration.ConfigurationSection;
|
||||
|
||||
import java.util.HashMap;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
|
||||
public class CheckSchemType implements ICheckSchemType {
|
||||
|
||||
private static final Map<SchematicType, CheckSchemType> types = new HashMap<>();
|
||||
|
||||
private final String name;
|
||||
|
||||
private final int width;
|
||||
private final int height;
|
||||
private final int depth;
|
||||
private final int maxDispenserItems;
|
||||
private final List<String> forbiddenMaterials;
|
||||
|
||||
private final int maxTNT;
|
||||
private final int maxSlime;
|
||||
private final int maxTNTSlime;
|
||||
private final int maxDispenser;
|
||||
private final int maxBlocks;
|
||||
|
||||
private CheckSchemType(ConfigurationSection section) {
|
||||
name = section.getName();
|
||||
width = section.getInt("width");
|
||||
height = section.getInt("height");
|
||||
depth = section.getInt("depth");
|
||||
|
||||
maxTNT = section.getInt("maxTNT");
|
||||
maxSlime = section.getInt("maxSlime");
|
||||
maxTNTSlime = section.getInt("maxTNTSlime");
|
||||
maxDispenser = section.getInt("maxDispenser");
|
||||
maxDispenserItems = section.getInt("maxDispenserItems");
|
||||
maxBlocks = section.getInt("maxBlocks");
|
||||
|
||||
forbiddenMaterials = section.getStringList("forbiddenMaterials");
|
||||
types.put(SchematicType.fromDB(name), this);
|
||||
types.put(SchematicType.fromDB("c" + name), this);
|
||||
}
|
||||
|
||||
static void init(ConfigurationSection config){
|
||||
ConfigurationSection types = config.getConfigurationSection("Schematics");
|
||||
for(String sectionName : types.getKeys(false))
|
||||
new CheckSchemType(types.getConfigurationSection(sectionName));
|
||||
}
|
||||
|
||||
public static CheckSchemType get(SchematicType type){
|
||||
return types.get(type);
|
||||
}
|
||||
|
||||
public AutoCheckResult autoCheck(Schematic schematic) {
|
||||
return VersionedCallable.call(new VersionedCallable<>(AutoCheckResult::new, 8),
|
||||
new VersionedCallable<>(() -> CheckSchemType_12.autoCheck(schematic, this), 12),
|
||||
new VersionedCallable<>(AutoCheckResult::new, 13),
|
||||
new VersionedCallable<>(() -> CheckSchemType_15.autoCheck(schematic, this), 15));
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getName() {
|
||||
return name;
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getWidth() {
|
||||
return width;
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getHeight() {
|
||||
return height;
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getDepth() {
|
||||
return depth;
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getMaxDispenserItems() {
|
||||
return maxDispenserItems;
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getMaxDispenser() {
|
||||
return maxDispenser;
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getMaxTNT() {
|
||||
return maxTNT;
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getMaxTNTSlime() {
|
||||
return maxTNTSlime;
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getMaxSlime() {
|
||||
return maxSlime;
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getMaxBlocks(){
|
||||
return maxBlocks;
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<String> getForbidden() {
|
||||
return forbiddenMaterials;
|
||||
}
|
||||
}
|
@ -1,42 +0,0 @@
|
||||
/*
|
||||
This file is a part of the SteamWar software.
|
||||
|
||||
Copyright (C) 2020 SteamWar.de-Serverteam
|
||||
|
||||
This program is free software: you can redistribute it and/or modify
|
||||
it under the terms of the GNU Affero General Public License as published by
|
||||
the Free Software Foundation, either version 3 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 Affero General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU Affero General Public License
|
||||
along with this program. If not, see <https://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
package de.steamwar.schematicsystem;
|
||||
|
||||
import de.steamwar.schematicsystem.commands.SchematicCommand;
|
||||
import org.bukkit.Bukkit;
|
||||
import org.bukkit.plugin.java.JavaPlugin;
|
||||
|
||||
import java.io.File;
|
||||
import java.util.logging.Level;
|
||||
|
||||
public class SchematicSystem extends JavaPlugin {
|
||||
public static final String PREFIX = "§eSchematic§8» §7";
|
||||
|
||||
@Override
|
||||
public void onEnable() {
|
||||
if (!new File(getDataFolder(), "config.yml").exists()) {
|
||||
saveDefaultConfig();
|
||||
Bukkit.getLogger().log(Level.SEVERE, "config.yml erstellt und geladen!");
|
||||
}
|
||||
|
||||
CheckSchemType.init(getConfig());
|
||||
getCommand("schem").setExecutor(new SchematicCommand());
|
||||
}
|
||||
}
|
@ -1,237 +0,0 @@
|
||||
/*
|
||||
This file is a part of the SteamWar software.
|
||||
|
||||
Copyright (C) 2020 SteamWar.de-Serverteam
|
||||
|
||||
This program is free software: you can redistribute it and/or modify
|
||||
it under the terms of the GNU Affero General Public License as published by
|
||||
the Free Software Foundation, either version 3 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 Affero General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU Affero General Public License
|
||||
along with this program. If not, see <https://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
package de.steamwar.schematicsystem.commands;
|
||||
|
||||
import com.google.common.collect.Lists;
|
||||
import de.steamwar.inventory.SWAnvilInv;
|
||||
import de.steamwar.inventory.SWInventory;
|
||||
import de.steamwar.inventory.SWItem;
|
||||
import de.steamwar.inventory.SWListInv;
|
||||
import de.steamwar.schematicsystem.SchematicSystem;
|
||||
import de.steamwar.sql.*;
|
||||
import org.bukkit.Material;
|
||||
import org.bukkit.entity.Player;
|
||||
import org.bukkit.event.inventory.ClickType;
|
||||
|
||||
import java.util.*;
|
||||
|
||||
class GUI {
|
||||
private GUI(){}
|
||||
|
||||
static void changeType(Player p, Schematic schem){
|
||||
List<SWListInv.SWListEntry<SchematicType>> types = new LinkedList<>();
|
||||
for(SchematicType type : SchematicType.values()){
|
||||
if(!type.isAssignable())
|
||||
continue;
|
||||
|
||||
SWItem item = new SWItem(SWItem.getMaterial("STONE_BUTTON"), type.name());
|
||||
if(type.fightType())
|
||||
item.setEnchanted(true);
|
||||
|
||||
types.add(new SWListInv.SWListEntry<>(item, type));
|
||||
}
|
||||
|
||||
SWListInv<SchematicType> inv = new SWListInv<>(p, "Typ ändern", types, (clickType, schematicType) -> {
|
||||
SchematicCommand.changetype(p, schem, schematicType);
|
||||
p.closeInventory();
|
||||
});
|
||||
inv.setCallback(-999, (ClickType click) -> p.closeInventory());
|
||||
inv.open();
|
||||
}
|
||||
|
||||
private static void deleteOwn(Player p, Schematic schem){
|
||||
SWInventory inv = new SWInventory(p, 9, schem.getSchemName() + " löschen");
|
||||
inv.setItem(0, SWItem.getDye(1), (byte) 1, "§eLöschen", click -> {
|
||||
schem.remove();
|
||||
|
||||
List<CheckedSchematic> checkedSchematics = CheckedSchematic.getLastDeclined(p.getUniqueId());
|
||||
for(CheckedSchematic checkedSchematic : checkedSchematics) {
|
||||
if(checkedSchematic.getSchemOwner() == schem.getSchemOwner() &&
|
||||
checkedSchematic.getSchemName().equals(schem.getSchemName()))
|
||||
checkedSchematic.remove();
|
||||
}
|
||||
p.sendMessage(SchematicSystem.PREFIX + "Schematic §e" + schem.getSchemName() + " §7gelöscht");
|
||||
p.closeInventory();
|
||||
});
|
||||
inv.setItem(8, SWItem.getDye(14), (byte) 14, "§cAbbruch", click -> p.closeInventory());
|
||||
inv.setCallback(-999, click -> p.closeInventory());
|
||||
inv.open();
|
||||
}
|
||||
|
||||
private static void deleteMembership(Player p, Schematic schem){
|
||||
SWInventory inv = new SWInventory(p, 9, schem.getSchemName() + " entfernen");
|
||||
inv.setItem(0, SWItem.getDye(1), (byte) 1, "§eZugriff entfernen", click -> {
|
||||
SchematicMember member = SchematicMember.getSchemMemberFromDB(schem.getSchemName(), schem.getSchemOwner(), SteamwarUser.get(p.getUniqueId()).getId());
|
||||
if(member != null)
|
||||
member.remove();
|
||||
p.sendMessage(SchematicSystem.PREFIX + "Zugriff zu Schematic §e" + schem.getSchemName() + " §7entfernt");
|
||||
p.closeInventory();
|
||||
});
|
||||
inv.setItem(8, SWItem.getDye(14), (byte) 14, "§cAbbruch", click -> p.closeInventory());
|
||||
inv.setCallback(-999, click -> p.closeInventory());
|
||||
inv.open();
|
||||
}
|
||||
|
||||
static void delete(Player p, Schematic schem){
|
||||
if(SteamwarUser.get(p.getUniqueId()).getId() == schem.getSchemOwner())
|
||||
deleteOwn(p, schem);
|
||||
else
|
||||
deleteMembership(p, schem);
|
||||
}
|
||||
|
||||
static void delmembers(Player p, Schematic schem){
|
||||
List<SWListInv.SWListEntry<SchematicMember>> members = new LinkedList<>();
|
||||
for(SchematicMember member : SchematicMember.getSchemMembers(schem.getSchemName(), schem.getSchemOwner())){
|
||||
SteamwarUser user = SteamwarUser.get(member.getMember());
|
||||
members.add(new SWListInv.SWListEntry<>(SWItem.getPlayerSkull(user.getUserName()), member));
|
||||
}
|
||||
|
||||
SWListInv<SchematicMember> inv = new SWListInv<>(p, "Mitglieder entfernen", members, (clickType, member) -> {
|
||||
member.remove();
|
||||
p.closeInventory();
|
||||
delmembers(p, schem);
|
||||
});
|
||||
inv.setCallback(-999, (ClickType click) -> p.closeInventory());
|
||||
inv.open();
|
||||
}
|
||||
|
||||
private static void changeItem(Player p, Schematic schem){
|
||||
List<SWListInv.SWListEntry<Material>> materials = new LinkedList<>();
|
||||
for(Material material : Material.values()){
|
||||
SWItem item = new SWItem(material, "§7" + material.name());
|
||||
if(item.getItemMeta() != null && material.isItem())
|
||||
materials.add(new SWListInv.SWListEntry<>(item, material));
|
||||
}
|
||||
|
||||
SWListInv<Material> inv = new SWListInv<>(p, "Item ändern", materials, (clickType, material) -> {
|
||||
schem.setItem(material.name());
|
||||
p.closeInventory();
|
||||
info(p, schem);
|
||||
});
|
||||
inv.setCallback(-999, (ClickType click) -> p.closeInventory());
|
||||
inv.open();
|
||||
}
|
||||
|
||||
private static void info(Player p, Schematic schem){
|
||||
SWInventory inv = new SWInventory(p, 9, schem.getSchemName());
|
||||
if(schem.availible())
|
||||
inv.setItem(0, SWItem.getMaterial("WOOD_AXE"), "§eLaden", click -> {
|
||||
SchematicCommand.load(p, schem);
|
||||
p.closeInventory();
|
||||
});
|
||||
|
||||
if(schem.getSchemOwner() == SteamwarUser.get(p.getUniqueId()).getId()){
|
||||
if(schem.getSchemType().writeable()){
|
||||
List<CheckedSchematic> checkedSchematics = CheckedSchematic.getLastDeclined(p.getUniqueId());
|
||||
ListIterator<CheckedSchematic> i = checkedSchematics.listIterator(checkedSchematics.size());
|
||||
while(i.hasPrevious()) {
|
||||
CheckedSchematic checkedSchematic = i.previous();
|
||||
if(checkedSchematic.getSchemName().equals(schem.getSchemName()) &&
|
||||
checkedSchematic.getSchemOwner() == schem.getSchemOwner()) {
|
||||
inv.setItem(1, SWItem.getDye(10), (byte) 10, "§eStatus " + schem.getSchemType().name(), Collections.singletonList("§7" + checkedSchematic.getDeclineReason()), false, click -> {});
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
Material mat = SWItem.getMaterial("CAULDRON_ITEM");
|
||||
if(schem.getItem() != null && !schem.getItem().equals(""))
|
||||
mat = SWItem.getMaterial(schem.getItem());
|
||||
|
||||
inv.setItem(2, mat, "§e" + mat.name(), Arrays.asList("§7Zum Ändern", "§7anklicken"), false, click -> {
|
||||
p.closeInventory();
|
||||
changeItem(p, schem);
|
||||
});
|
||||
if(schem.availible())
|
||||
inv.setItem(4, SWItem.getMaterial("CAULDRON_ITEM"), "§e" + schem.getSchemType().name(), Arrays.asList("§7Zum Ändern", "§7anklicken"), false, click -> {
|
||||
p.closeInventory();
|
||||
changeType(p, schem);
|
||||
});
|
||||
inv.setItem(5, SWItem.getMaterial("MAGENTA_GLAZED_TERRACOTTA"), "§eDownload", click -> {
|
||||
p.closeInventory();
|
||||
SchematicCommand.download(p, schem);
|
||||
});
|
||||
SWItem skull = SWItem.getPlayerSkull("MHF_STEVE");
|
||||
skull.setCallback(click -> {
|
||||
p.closeInventory();
|
||||
delmembers(p, schem);
|
||||
});
|
||||
skull.setName("§eMitglieder");
|
||||
inv.setItem(6, skull);
|
||||
inv.setItem(8, SWItem.getDye(1), (byte) 1, "§cLöschen", click -> {
|
||||
p.closeInventory();
|
||||
delete(p, schem);
|
||||
});
|
||||
}else{
|
||||
inv.setItem(4, SWItem.getMaterial("CAULDRON_ITEM"), "§e" + schem.getSchemType().name(), click -> {});
|
||||
|
||||
SteamwarUser owneruser = SteamwarUser.get(schem.getSchemOwner());
|
||||
SWItem skull = SWItem.getPlayerSkull(owneruser.getUserName());
|
||||
skull.setName("§7von §e" + owneruser.getUserName());
|
||||
inv.setItem(6, skull);
|
||||
|
||||
inv.setItem(8, SWItem.getDye(1), (byte) 1, "§cZugriff entfernen", click -> {
|
||||
p.closeInventory();
|
||||
delete(p, schem);
|
||||
});
|
||||
}
|
||||
|
||||
inv.setCallback(-999, click -> p.closeInventory());
|
||||
inv.open();
|
||||
}
|
||||
|
||||
static void list(Player p){
|
||||
list(p, Schematic.getSchemsAccessibleByUser(SteamwarUser.get(p.getUniqueId()).getId()), false);
|
||||
}
|
||||
|
||||
private static void list(Player p, List<Schematic> schems, boolean publics){
|
||||
List<SWListInv.SWListEntry<Schematic>> schemList = new ArrayList<>();
|
||||
|
||||
for(Schematic schem : schems) {
|
||||
Material m;
|
||||
if (schem.getItem().isEmpty())
|
||||
m = SWItem.getMaterial("CAULDRON_ITEM");
|
||||
else
|
||||
m = SWItem.getMaterial(schem.getItem());
|
||||
|
||||
SWItem item = new SWItem(m, "§e" + schem.getSchemName(), Collections.singletonList("§7" + schem.getSchemType().name()), !schem.getSchemType().writeable(), click -> {});
|
||||
if(schem.getRank() > 0)
|
||||
item.setLore(Lists.newArrayList("§7" + schem.getSchemType().name(), "§8Rang " + schem.getRank()));
|
||||
schemList.add(new SWListInv.SWListEntry<>(item, schem));
|
||||
}
|
||||
|
||||
SWListInv<Schematic> inv = new SWListInv<>(p, "§eSchematicliste", false, schemList, (clickType, schem) -> info(p, schem));
|
||||
if(publics)
|
||||
inv.setItem(48, Material.BUCKET, "§7Eigene Schematics", clickType -> list(p));
|
||||
else
|
||||
inv.setItem(48, Material.GLASS, "§7Public Schematics", clickType -> list(p, Schematic.getSchemsAccessibleByUser(0), true));
|
||||
inv.setItem(50, Material.NAME_TAG, "§7Suche", clickType -> search(p, schems));
|
||||
inv.open();
|
||||
}
|
||||
|
||||
static void search(Player p, List<Schematic> schems){
|
||||
SWAnvilInv inv = new SWAnvilInv(p, "§7Schematicsuche");
|
||||
inv.setCallback(term -> {
|
||||
ArrayList<Schematic> schemCopy = new ArrayList<>(schems);
|
||||
schemCopy.removeIf(schem -> !schem.getSchemName().toLowerCase().contains(term.toLowerCase()));
|
||||
list(p, schemCopy, false);
|
||||
});
|
||||
inv.open();
|
||||
}
|
||||
}
|
@ -1,556 +0,0 @@
|
||||
/*
|
||||
This file is a part of the SteamWar software.
|
||||
|
||||
Copyright (C) 2020 SteamWar.de-Serverteam
|
||||
|
||||
This program is free software: you can redistribute it and/or modify
|
||||
it under the terms of the GNU Affero General Public License as published by
|
||||
the Free Software Foundation, either version 3 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 Affero General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU Affero General Public License
|
||||
along with this program. If not, see <https://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
package de.steamwar.schematicsystem.commands;
|
||||
|
||||
import de.steamwar.schematicsystem.AutoCheckResult;
|
||||
import de.steamwar.schematicsystem.CheckSchemType;
|
||||
import de.steamwar.schematicsystem.SchematicSystem;
|
||||
import de.steamwar.sql.*;
|
||||
import net.md_5.bungee.api.ChatColor;
|
||||
import net.md_5.bungee.api.chat.ClickEvent;
|
||||
import net.md_5.bungee.api.chat.ComponentBuilder;
|
||||
import net.md_5.bungee.api.chat.HoverEvent;
|
||||
import net.md_5.bungee.api.chat.TextComponent;
|
||||
import org.bukkit.Bukkit;
|
||||
import org.bukkit.command.Command;
|
||||
import org.bukkit.command.CommandExecutor;
|
||||
import org.bukkit.command.CommandSender;
|
||||
import org.bukkit.entity.Player;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.Collection;
|
||||
import java.util.List;
|
||||
import java.util.logging.Level;
|
||||
|
||||
public class SchematicCommand implements CommandExecutor {
|
||||
|
||||
private static final int FILES_PER_PAGE = 15;
|
||||
|
||||
@Override
|
||||
public boolean onCommand(CommandSender sender, Command command, String label, String[] args) {
|
||||
if(!(sender instanceof Player))
|
||||
return false;
|
||||
Player player = (Player) sender;
|
||||
|
||||
if(args.length == 0){
|
||||
help(player);
|
||||
return false;
|
||||
}
|
||||
|
||||
switch(args[0].toLowerCase()){
|
||||
case "gui":
|
||||
GUI.list(player);
|
||||
break;
|
||||
case "list":
|
||||
list(player, args);
|
||||
break;
|
||||
case "load":
|
||||
load(player, args);
|
||||
break;
|
||||
case "delete":
|
||||
delete(player, args);
|
||||
break;
|
||||
case "save":
|
||||
save(player, args);
|
||||
break;
|
||||
case "info":
|
||||
info(player, args);
|
||||
break;
|
||||
case "changetype":
|
||||
changetype(player, args);
|
||||
break;
|
||||
case "addmember":
|
||||
addmember(player, args);
|
||||
break;
|
||||
case "delmember":
|
||||
delmember(player, args);
|
||||
break;
|
||||
case "download":
|
||||
download(player, args);
|
||||
break;
|
||||
case "search":
|
||||
search(player, args);
|
||||
break;
|
||||
default:
|
||||
help(player);
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
private void list(Player player, String[] args){
|
||||
if(args.length <= 1){
|
||||
sendPlayerSchematicList(0, player, "/schem list ", Schematic.getSchemsAccessibleByUser(SteamwarUser.get(player.getUniqueId()).getId()));
|
||||
return;
|
||||
}
|
||||
|
||||
if("public".equalsIgnoreCase(args[1])){
|
||||
if(args.length == 2){
|
||||
sendPlayerSchematicList(0, player, "/schem list public ", Schematic.getSchemsAccessibleByUser(0));
|
||||
return;
|
||||
}
|
||||
|
||||
try {
|
||||
sendPlayerSchematicList(Integer.parseInt(args[2]), player, "/schem list public ", Schematic.getSchemsAccessibleByUser(0));
|
||||
} catch (NumberFormatException ex) {
|
||||
player.sendMessage(SchematicSystem.PREFIX + "§cUngültige Seitenzahl");
|
||||
}
|
||||
return;
|
||||
}
|
||||
|
||||
try {
|
||||
sendPlayerSchematicList(Integer.parseInt(args[1]), player, "/schem list ", Schematic.getSchemsAccessibleByUser(SteamwarUser.get(player.getUniqueId()).getId()));
|
||||
} catch (NumberFormatException ex) {
|
||||
player.sendMessage(SchematicSystem.PREFIX + "§cUngültige Seitenzahl");
|
||||
}
|
||||
}
|
||||
|
||||
private boolean invalidSchemName(Player player, String name){
|
||||
if(name.contains("/") ||
|
||||
name.contains("\\") ||
|
||||
name.contains("<") ||
|
||||
name.contains(">") ||
|
||||
name.contains("^") ||
|
||||
name.contains("°") ||
|
||||
name.contains("'") ||
|
||||
name.contains("\"")){
|
||||
player.sendMessage(SchematicSystem.PREFIX + "§cDer angegebene Schematicname enthält verbotene Zeichen");
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
private Schematic getSchem(Player player, String name){
|
||||
if(invalidSchemName(player, name))
|
||||
return null;
|
||||
|
||||
Schematic schematic = Schematic.getSchemFromDB(name, player.getUniqueId());
|
||||
if(schematic == null)
|
||||
schematic = Schematic.getSchemFromDB(name, 0); //public schematic
|
||||
|
||||
if (schematic == null) {
|
||||
player.sendMessage(SchematicSystem.PREFIX + "§cDie angegebene Schematic existiert nicht");
|
||||
return null;
|
||||
}
|
||||
|
||||
return schematic;
|
||||
}
|
||||
|
||||
private void load(Player player, String[] args){
|
||||
if(args.length < 2){
|
||||
help(player);
|
||||
return;
|
||||
}
|
||||
|
||||
Schematic schematic = getSchem(player, args[1]);
|
||||
if(schematic == null)
|
||||
return;
|
||||
|
||||
load(player, schematic);
|
||||
}
|
||||
|
||||
static void load(Player player, Schematic schematic){
|
||||
try {
|
||||
schematic.loadToPlayer(player);
|
||||
player.sendMessage(SchematicSystem.PREFIX + "Schematic §e" + schematic.getSchemName() + " §7geladen");
|
||||
}catch (Exception e){
|
||||
Bukkit.getLogger().log(Level.SEVERE, "Schematic konnte nicht geladen werden", e);
|
||||
player.sendMessage(SchematicSystem.PREFIX + "§cFehler beim Laden der Schematic. Dies liegt wahrscheinlich an einer defekten Schematic.");
|
||||
}
|
||||
}
|
||||
|
||||
private void delete(Player player, String[] args){
|
||||
if(args.length < 2){
|
||||
help(player);
|
||||
return;
|
||||
}
|
||||
|
||||
Schematic schematic = getSchem(player, args[1]);
|
||||
if(schematic == null)
|
||||
return;
|
||||
|
||||
GUI.delete(player, schematic);
|
||||
}
|
||||
|
||||
private void save(Player player, String[] args){
|
||||
if(args.length < 2){
|
||||
help(player);
|
||||
return;
|
||||
}
|
||||
|
||||
if(invalidSchemName(player, args[1]))
|
||||
return;
|
||||
|
||||
if(args[1].length() > 64){
|
||||
player.sendMessage(SchematicSystem.PREFIX + "§cDer Name der Schematic ist zu lang");
|
||||
return;
|
||||
}
|
||||
|
||||
Schematic schematic = Schematic.getSchemFromDB(args[1], player.getUniqueId());
|
||||
if(schematic != null && !schematic.getSchemType().writeable()) {
|
||||
player.sendMessage(SchematicSystem.PREFIX + "§cDu darfst diese Schematic nicht überschreiben");
|
||||
return;
|
||||
}
|
||||
|
||||
boolean newSchem = false;
|
||||
if(schematic == null || schematic.getSchemOwner() != SteamwarUser.get(player.getUniqueId()).getId()){
|
||||
newSchem = true;
|
||||
Schematic.createSchem(args[1], player.getUniqueId(), "", SchematicType.Normal);
|
||||
schematic = Schematic.getSchemFromDB(args[1], player.getUniqueId());
|
||||
}
|
||||
|
||||
try {
|
||||
schematic.saveFromPlayer(player);
|
||||
}catch (NoClipboardException e) {
|
||||
player.sendMessage(SchematicSystem.PREFIX + "§cDein Clipboard ist leer");
|
||||
if(newSchem)
|
||||
schematic.remove();
|
||||
return;
|
||||
}catch(Exception ex){
|
||||
Bukkit.getLogger().log(Level.SEVERE, "Could not save schematic", ex);
|
||||
player.sendMessage(SchematicSystem.PREFIX + "§cFehler beim Speichern der Schematic.");
|
||||
if(newSchem)
|
||||
schematic.remove();
|
||||
return;
|
||||
}
|
||||
|
||||
if (newSchem)
|
||||
player.sendMessage(SchematicSystem.PREFIX + "Schematic §e" + args[1] + " §7gespeichert");
|
||||
else
|
||||
player.sendMessage(SchematicSystem.PREFIX + "Schematic §e" + args[1] + " §7überschrieben");
|
||||
}
|
||||
|
||||
private void changetype(Player player, String[] args){
|
||||
if(args.length < 2){
|
||||
help(player);
|
||||
return;
|
||||
}
|
||||
|
||||
Schematic schematic = getSchem(player, args[1]);
|
||||
if(schematic == null)
|
||||
return;
|
||||
|
||||
if(args.length < 3) {
|
||||
GUI.changeType(player, schematic);
|
||||
return;
|
||||
}
|
||||
|
||||
SchematicType type = SchematicType.fromDB(args[2]);
|
||||
if(type == null || !type.isAssignable()){
|
||||
player.sendMessage(SchematicSystem.PREFIX + "§cDiesen Schematictypen gibt es nicht");
|
||||
return;
|
||||
}
|
||||
|
||||
changetype(player, schematic, type);
|
||||
}
|
||||
|
||||
static void changetype(Player player, Schematic schematic, SchematicType type){
|
||||
if(schematic.getSchemType() == type){
|
||||
player.sendMessage(SchematicSystem.PREFIX + "§cDie Schematic hat bereits diesen Typen");
|
||||
return;
|
||||
}
|
||||
|
||||
if(type.writeable()){
|
||||
schematic.setSchemType(type);
|
||||
player.sendMessage(SchematicSystem.PREFIX + "§aSchematictyp geändert");
|
||||
}else if(type.fightType()){
|
||||
if(schematic.getSchemType().check()){
|
||||
player.sendMessage(SchematicSystem.PREFIX + "§cDu hast diese Schematic bereits eingesendet");
|
||||
return;
|
||||
}
|
||||
|
||||
AutoCheckResult result = CheckSchemType.get(type).autoCheck(schematic);
|
||||
Collection<String> errors = result.errors();
|
||||
for(String warning : result.warnings()){
|
||||
player.sendMessage(" §e" + warning);
|
||||
}
|
||||
for(String error : errors){
|
||||
player.sendMessage(" §c" + error);
|
||||
}
|
||||
if(!errors.isEmpty()){
|
||||
player.sendMessage(SchematicSystem.PREFIX + "§cDie Schematic ist nicht regelkonform");
|
||||
return;
|
||||
}
|
||||
|
||||
schematic.setSchemType(type.checkType());
|
||||
player.sendMessage(SchematicSystem.PREFIX + "§aDie Schematic wird zeitnah überprüft");
|
||||
}
|
||||
}
|
||||
|
||||
private void info(Player player, String[] args){
|
||||
if(args.length < 2){
|
||||
help(player);
|
||||
return;
|
||||
}
|
||||
|
||||
Schematic schematic = getSchem(player, args[1]);
|
||||
if(schematic == null)
|
||||
return;
|
||||
|
||||
player.sendMessage("§eName: §7" + schematic.getSchemName());
|
||||
|
||||
TextComponent type = new TextComponent("§eTyp: §7" + schematic.getSchemType().name());
|
||||
if(SteamwarUser.get(schematic.getSchemOwner()).getUUID().equals(player.getUniqueId()) && schematic.availible()){
|
||||
type.setHoverEvent(new HoverEvent(HoverEvent.Action.SHOW_TEXT, TextComponent.fromLegacyText("§eTyp ändern")));
|
||||
type.setClickEvent(new ClickEvent(ClickEvent.Action.RUN_COMMAND, "/schem changetype " + schematic.getSchemName()));
|
||||
}
|
||||
if(schematic.getRank() > 0){
|
||||
type.addExtra("§8Rang " + schematic.getRank());
|
||||
}
|
||||
player.spigot().sendMessage(type);
|
||||
|
||||
if(SteamwarUser.get(schematic.getSchemOwner()).getUUID().equals(player.getUniqueId())){
|
||||
TextComponent download = new TextComponent("§eDownload Schematic");
|
||||
download.setHoverEvent(new HoverEvent(HoverEvent.Action.SHOW_TEXT, TextComponent.fromLegacyText("§eGeneriere Downloadlink")));
|
||||
download.setClickEvent(new ClickEvent(ClickEvent.Action.RUN_COMMAND, "/schem download " + schematic.getSchemName()));
|
||||
player.spigot().sendMessage(download);
|
||||
}
|
||||
|
||||
List<CheckedSchematic> checkedSchematics = CheckedSchematic.getLastDeclined(player.getUniqueId());
|
||||
for(int i = checkedSchematics.size() -1; i >= 0; i--) {
|
||||
if(checkedSchematics.get(i).getSchemName().equals(schematic.getSchemName()) &&
|
||||
checkedSchematics.get(i).getSchemOwner() == schematic.getSchemOwner()) {
|
||||
player.sendMessage("§cStatus: §c" + checkedSchematics.get(i).getStartTime() + " : " + checkedSchematics.get(i).getDeclineReason());
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
if(!SteamwarUser.get(schematic.getSchemOwner()).getUUID().equals(player.getUniqueId())) {
|
||||
player.sendMessage("§eBesitzer: §7" + SteamwarUser.get(schematic.getSchemOwner()).getUserName());
|
||||
} else {
|
||||
List<String> schematicMembers = new ArrayList<>();
|
||||
for(SchematicMember schematicMember : SchematicMember.getSchemMembers(schematic.getSchemName(), schematic.getSchemOwner())) {
|
||||
schematicMembers.add(SteamwarUser.get(schematicMember.getMember()).getUserName());
|
||||
}
|
||||
player.sendMessage("§eMitglieder: §7" + schematicMembers.toString());
|
||||
}
|
||||
|
||||
if(schematic.availible()){
|
||||
TextComponent loadSchematic = new TextComponent("LADEN");
|
||||
loadSchematic.setColor(ChatColor.DARK_GREEN);
|
||||
loadSchematic.setClickEvent(new ClickEvent(ClickEvent.Action.RUN_COMMAND, "/schem load " + schematic.getSchemName()));
|
||||
player.spigot().sendMessage(loadSchematic);
|
||||
}
|
||||
}
|
||||
|
||||
private void download(Player player, String[] args){
|
||||
if(args.length < 2){
|
||||
help(player);
|
||||
return;
|
||||
}
|
||||
|
||||
Schematic schematic = getSchem(player, args[1]);
|
||||
if(schematic == null)
|
||||
return;
|
||||
|
||||
download(player, schematic);
|
||||
}
|
||||
|
||||
private void search(Player player, String[] args) {
|
||||
if(args.length < 2) {
|
||||
help(player);
|
||||
return;
|
||||
}
|
||||
|
||||
List<Schematic> schems = Schematic.getSchemsAccessibleByUser(SteamwarUser.get(player.getUniqueId()).getId());
|
||||
schems.removeIf(schem -> !schem.getSchemName().toLowerCase().contains(args[1].toLowerCase()));
|
||||
|
||||
if(args.length == 2){
|
||||
sendPlayerSchematicList(0, player, "/schem search " + args[1] + " ", schems);
|
||||
return;
|
||||
}
|
||||
|
||||
try {
|
||||
sendPlayerSchematicList(Integer.parseInt(args[2]), player, "/schem search " + args[1] + " ", schems);
|
||||
} catch (NumberFormatException ex) {
|
||||
player.sendMessage(SchematicSystem.PREFIX + "§cUngültige Seitenzahl");
|
||||
}
|
||||
}
|
||||
|
||||
static void download(Player player, Schematic schematic){
|
||||
if(schematic.getSchemOwner() != SteamwarUser.get(player.getUniqueId()).getId()){
|
||||
player.sendMessage("§cDu darfst nur deine eigenen Schematics herunterladen!");
|
||||
return;
|
||||
}
|
||||
|
||||
player.sendMessage(DownloadSchematic.getLink(schematic));
|
||||
}
|
||||
|
||||
private void addmember(Player player, String[] args){
|
||||
if(args.length < 3){
|
||||
help(player);
|
||||
return;
|
||||
}
|
||||
|
||||
Schematic schematic = getSchem(player, args[1]);
|
||||
if(schematic == null)
|
||||
return;
|
||||
|
||||
if(schematic.getSchemOwner() != SteamwarUser.get(player.getUniqueId()).getId()) {
|
||||
player.sendMessage(SchematicSystem.PREFIX + "§cDu darfst nur auf deine eigene Schematic Mitglieder hinzufügen");
|
||||
return;
|
||||
}
|
||||
|
||||
SteamwarUser warkingUser = SteamwarUser.get(args[2]);
|
||||
if(warkingUser == null){
|
||||
player.sendMessage(SchematicSystem.PREFIX + "§cDieser Spieler existiert nicht");
|
||||
return;
|
||||
}
|
||||
if(schematic.getSchemOwner() == warkingUser.getId()){
|
||||
player.sendMessage(SchematicSystem.PREFIX + "§cAlso bitte: Das ist deine eigene Schematic!");
|
||||
return;
|
||||
}
|
||||
|
||||
if(SchematicMember.getSchemMemberFromDB(schematic.getSchemName(), SteamwarUser.get(schematic.getSchemOwner()).getUUID(), warkingUser.getUUID()) != null){
|
||||
player.sendMessage(SchematicSystem.PREFIX + "§cDieser Spieler ist bereits auf diese Schematic geaddet");
|
||||
return;
|
||||
}
|
||||
|
||||
new SchematicMember(schematic.getSchemName(), SteamwarUser.get(schematic.getSchemOwner()).getUUID(), warkingUser.getUUID());
|
||||
player.sendMessage(SchematicSystem.PREFIX + "Der Spieler §e" + warkingUser.getUserName() + " §7hat nun Zugriff auf die Schematic §e" + schematic.getSchemName());
|
||||
|
||||
Player target = Bukkit.getPlayer(warkingUser.getUUID());
|
||||
if(target != null)
|
||||
target.sendMessage(SchematicSystem.PREFIX + "Du hast nun Zugriff auf die Schematic §e" + schematic.getSchemName() + " §7von §e" + SteamwarUser.get(schematic.getSchemOwner()).getUserName());
|
||||
}
|
||||
|
||||
private void delmember(Player player, String[] args){
|
||||
if(args.length < 2){
|
||||
help(player);
|
||||
return;
|
||||
}
|
||||
|
||||
Schematic schematic = getSchem(player, args[1]);
|
||||
if(schematic == null)
|
||||
return;
|
||||
|
||||
if(schematic.getSchemOwner() != SteamwarUser.get(player.getUniqueId()).getId()) {
|
||||
player.sendMessage(SchematicSystem.PREFIX + "§cDu darfst nur von deinen eigenen Schematics Mitglieder entfernen");
|
||||
return;
|
||||
}
|
||||
|
||||
if(args.length < 3){
|
||||
GUI.delmembers(player, schematic);
|
||||
return;
|
||||
}
|
||||
|
||||
SteamwarUser user = SteamwarUser.get(args[2]);
|
||||
if(user == null){
|
||||
player.sendMessage(SchematicSystem.PREFIX + "§cDieser Spieler existiert nicht");
|
||||
return;
|
||||
}
|
||||
if(schematic.getSchemOwner() == user.getId()){
|
||||
player.sendMessage(SchematicSystem.PREFIX + "§cAlso bitte: Das ist deine eigene Schematic!");
|
||||
return;
|
||||
}
|
||||
|
||||
SchematicMember schematicMember = SchematicMember.getSchemMemberFromDB(schematic.getSchemName(), SteamwarUser.get(schematic.getSchemOwner()).getUUID(), user.getUUID());
|
||||
if(schematicMember == null) {
|
||||
player.sendMessage(SchematicSystem.PREFIX + "§cDieser Spieler ist nicht auf die Schematic hinzugefügt");
|
||||
return;
|
||||
}
|
||||
|
||||
schematicMember.remove();
|
||||
player.sendMessage(SchematicSystem.PREFIX + "Der Spieler §e" + user.getUserName() + " §7hat keinen Zugriff mehr auf die Schematic §e" + schematic.getSchemName());
|
||||
|
||||
Player target = Bukkit.getPlayer(user.getUUID());
|
||||
if(target != null)
|
||||
target.sendMessage(SchematicSystem.PREFIX + "Du hast keinen Zugriff mehr auf die Schematic §e" + schematic.getSchemName() + "§7von §e" + SteamwarUser.get(schematic.getSchemOwner()).getUserName());
|
||||
}
|
||||
|
||||
private void help(Player player) {
|
||||
player.sendMessage(SchematicSystem.PREFIX + "Befehle§8:");
|
||||
player.sendMessage("§8/§eschem gui §8- §7Öffnet die Schematic-GUI");
|
||||
player.sendMessage("§8/§eschem list §8- §7Zeigt dir deine Schematics an");
|
||||
player.sendMessage("§8/§eschem list public §8- §7Zeigt alle Public-Schematics");
|
||||
player.sendMessage("§8/§eschem search §8[§7Stichwort§8] - §7Sucht nach passenden Schematics");
|
||||
player.sendMessage("§8/§eschem load §8[§7Schematic§8] - §7Lädt eine Schematic");
|
||||
player.sendMessage("§8/§eschem save §8[§7Schematic§8] - §7Speichert dein Clipboard als Schematic");
|
||||
player.sendMessage("§8/§eschem changetype §8[§7Schematic§8] - §7Ändert die Art deiner Schematic");
|
||||
player.sendMessage("§8/§eschem delete §8[§7Schematic§8] - §7Löscht eine Schematic");
|
||||
player.sendMessage("§8/§eschem info §8[§7Schematic§8] - §7Zeigt dir Informationen zur Schematic");
|
||||
player.sendMessage("§8/§eschem download §8[§7Schematic§8] - §7Gibt dir einen Downloadlink (1 min gültig)");
|
||||
player.sendMessage("§8/§eschem addmember §8[§7Schematic§8] §8[§7Spieler§8] - §7Fügt einen Spieler zu einer Schematic hinzu");
|
||||
player.sendMessage("§8/§eschem delmember §8[§7Schematic§8] §8[§7Spieler§8] - §7Entfernt einen Spieler von einer Schematic");
|
||||
}
|
||||
|
||||
private void sendPlayerSchematicList(int currentPage, Player player, String precommand, List<Schematic> schematicList) {
|
||||
SteamwarUser user = SteamwarUser.get(player.getUniqueId());
|
||||
|
||||
if(schematicList.isEmpty()) {
|
||||
player.sendMessage(SchematicSystem.PREFIX + "§cKeine Schematics gefunden");
|
||||
return;
|
||||
}
|
||||
|
||||
int pages;
|
||||
|
||||
double doublePages = schematicList.size() / (double) FILES_PER_PAGE;
|
||||
int intPages = schematicList.size() / FILES_PER_PAGE;
|
||||
|
||||
if(schematicList.size() <= FILES_PER_PAGE) {
|
||||
pages = 1;
|
||||
}else if(doublePages > intPages){
|
||||
pages = (intPages + 1);
|
||||
}else
|
||||
pages = intPages;
|
||||
|
||||
if(currentPage >= pages || currentPage < 0) return;
|
||||
|
||||
player.sendMessage("§eSeite " + (currentPage + 1) + " §8/ " + pages + " §8| §e" + schematicList.size() + " Schematics");
|
||||
|
||||
for(int i = currentPage * FILES_PER_PAGE; i < (currentPage * FILES_PER_PAGE) + FILES_PER_PAGE; i++) {
|
||||
if(schematicList.size() <= i) break;
|
||||
|
||||
Schematic schematic = schematicList.get(i);
|
||||
|
||||
String schematicPlayer = "";
|
||||
if(schematic.getSchemOwner() != user.getId())
|
||||
schematicPlayer = " §8von §7" + SteamwarUser.get(schematic.getSchemOwner()).getUserName();
|
||||
|
||||
TextComponent schematics = new TextComponent("§e" + schematic.getSchemType().getKuerzel() + " §7" + schematic.getSchemName() + schematicPlayer);
|
||||
schematics.setBold(true);
|
||||
|
||||
schematics.setHoverEvent(new HoverEvent(HoverEvent.Action.SHOW_TEXT, new ComponentBuilder("§eSchematic verwalten").create()));
|
||||
schematics.setClickEvent(new ClickEvent(ClickEvent.Action.RUN_COMMAND, "/schem info " + schematic.getSchemName()));
|
||||
|
||||
player.spigot().sendMessage(schematics);
|
||||
}
|
||||
|
||||
if(pages <= 1) return;
|
||||
|
||||
TextComponent beforePage = new TextComponent("««");
|
||||
if(currentPage > 0){
|
||||
beforePage.setColor(ChatColor.YELLOW);
|
||||
beforePage.setHoverEvent(new HoverEvent(HoverEvent.Action.SHOW_TEXT, new ComponentBuilder("§eVorherige Seite").create()));
|
||||
beforePage.setClickEvent(new ClickEvent(ClickEvent.Action.RUN_COMMAND, precommand + (currentPage - 1)));
|
||||
}else
|
||||
beforePage.setColor(ChatColor.RED);
|
||||
|
||||
TextComponent nextPage = new TextComponent(" Seite »»");
|
||||
if(currentPage < pages-1){
|
||||
nextPage.setColor(ChatColor.YELLOW);
|
||||
nextPage.setHoverEvent(new HoverEvent(HoverEvent.Action.SHOW_TEXT, new ComponentBuilder("§eNächste Seite").create()));
|
||||
nextPage.setClickEvent(new ClickEvent(ClickEvent.Action.RUN_COMMAND, precommand + (currentPage + 1)));
|
||||
}else
|
||||
nextPage.setColor(ChatColor.RED);
|
||||
|
||||
beforePage.addExtra(nextPage);
|
||||
player.spigot().sendMessage(beforePage);
|
||||
}
|
||||
}
|
@ -1,14 +0,0 @@
|
||||
name: SchematicSystem
|
||||
version: "1.0"
|
||||
authors: [Yaruma3341, Lixfel]
|
||||
depend: [SpigotCore, WorldEdit]
|
||||
main: de.steamwar.schematicsystem.SchematicSystem
|
||||
api-version: "1.13"
|
||||
|
||||
commands:
|
||||
schem:
|
||||
aliases:
|
||||
- schematic
|
||||
- /schematic
|
||||
- /schem
|
||||
check:
|
60
build.gradle
Normale Datei
60
build.gradle
Normale Datei
@ -0,0 +1,60 @@
|
||||
/*
|
||||
* This file is a part of the SteamWar software.
|
||||
*
|
||||
* Copyright (C) 2020 SteamWar.de-Serverteam
|
||||
*
|
||||
* This program is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU Affero General Public License as published by
|
||||
* the Free Software Foundation, either version 3 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 Affero General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU Affero General Public License
|
||||
* along with this program. If not, see <https://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
plugins {
|
||||
id 'base'
|
||||
id 'application'
|
||||
|
||||
id 'com.github.johnrengelman.shadow' version '5.0.0'
|
||||
id 'de.steamwar.gradle' version 'RELEASE'
|
||||
}
|
||||
|
||||
group 'de.steamwar'
|
||||
version ''
|
||||
|
||||
compileJava.options.encoding = 'UTF-8'
|
||||
compileJava.options.compilerArgs << '-parameter'
|
||||
|
||||
sourceCompatibility = 11
|
||||
targetCompatibility = 11
|
||||
|
||||
mainClassName = ''
|
||||
|
||||
allprojects {
|
||||
repositories {
|
||||
mavenCentral()
|
||||
maven {
|
||||
url = uri("https://repo.codemc.io/repository/maven-snapshots/")
|
||||
}
|
||||
|
||||
maven {
|
||||
url = uri('https://hub.spigotmc.org/nexus/content/repositories/snapshots/')
|
||||
}
|
||||
|
||||
maven {
|
||||
url = uri('https://libraries.minecraft.net')
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
dependencies {
|
||||
implementation project(":SchematicSystem_Core")
|
||||
implementation project(":SchematicSystem_15")
|
||||
implementation project(":SchematicSystem_8")
|
||||
}
|
22
gradle.properties
Normale Datei
22
gradle.properties
Normale Datei
@ -0,0 +1,22 @@
|
||||
#
|
||||
# This file is a part of the SteamWar software.
|
||||
#
|
||||
# Copyright (C) 2020 SteamWar.de-Serverteam
|
||||
#
|
||||
# This program is free software: you can redistribute it and/or modify
|
||||
# it under the terms of the GNU Affero General Public License as published by
|
||||
# the Free Software Foundation, either version 3 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 Affero General Public License for more details.
|
||||
#
|
||||
# You should have received a copy of the GNU Affero General Public License
|
||||
# along with this program. If not, see <https://www.gnu.org/licenses/>.
|
||||
#
|
||||
|
||||
org.gradle.daemon = true
|
||||
org.gradle.parallel = true
|
||||
org.gradle.workers.max = 4
|
BIN
gradle/wrapper/gradle-wrapper.jar
vendored
Normale Datei
BIN
gradle/wrapper/gradle-wrapper.jar
vendored
Normale Datei
Binäre Datei nicht angezeigt.
6
gradle/wrapper/gradle-wrapper.properties
vendored
Normale Datei
6
gradle/wrapper/gradle-wrapper.properties
vendored
Normale Datei
@ -0,0 +1,6 @@
|
||||
#Sat Apr 10 23:34:12 CEST 2021
|
||||
distributionUrl=https\://services.gradle.org/distributions/gradle-7.3.1-all.zip
|
||||
distributionBase=GRADLE_USER_HOME
|
||||
distributionPath=wrapper/dists
|
||||
zipStorePath=wrapper/dists
|
||||
zipStoreBase=GRADLE_USER_HOME
|
183
gradlew
vendored
Ausführbare Datei
183
gradlew
vendored
Ausführbare Datei
@ -0,0 +1,183 @@
|
||||
#!/usr/bin/env sh
|
||||
|
||||
#
|
||||
# Copyright 2015 the original author or authors.
|
||||
#
|
||||
# Licensed under the Apache License, Version 2.0 (the "License");
|
||||
# you may not use this file except in compliance with the License.
|
||||
# You may obtain a copy of the License at
|
||||
#
|
||||
# https://www.apache.org/licenses/LICENSE-2.0
|
||||
#
|
||||
# Unless required by applicable law or agreed to in writing, software
|
||||
# distributed under the License is distributed on an "AS IS" BASIS,
|
||||
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
# See the License for the specific language governing permissions and
|
||||
# limitations under the License.
|
||||
#
|
||||
|
||||
##############################################################################
|
||||
##
|
||||
## Gradle start up script for UN*X
|
||||
##
|
||||
##############################################################################
|
||||
|
||||
# Attempt to set APP_HOME
|
||||
# Resolve links: $0 may be a link
|
||||
PRG="$0"
|
||||
# Need this for relative symlinks.
|
||||
while [ -h "$PRG" ] ; do
|
||||
ls=`ls -ld "$PRG"`
|
||||
link=`expr "$ls" : '.*-> \(.*\)$'`
|
||||
if expr "$link" : '/.*' > /dev/null; then
|
||||
PRG="$link"
|
||||
else
|
||||
PRG=`dirname "$PRG"`"/$link"
|
||||
fi
|
||||
done
|
||||
SAVED="`pwd`"
|
||||
cd "`dirname \"$PRG\"`/" >/dev/null
|
||||
APP_HOME="`pwd -P`"
|
||||
cd "$SAVED" >/dev/null
|
||||
|
||||
APP_NAME="Gradle"
|
||||
APP_BASE_NAME=`basename "$0"`
|
||||
|
||||
# Add default JVM options here. You can also use JAVA_OPTS and GRADLE_OPTS to pass JVM options to this script.
|
||||
DEFAULT_JVM_OPTS='"-Xmx64m" "-Xms64m"'
|
||||
|
||||
# Use the maximum available, or set MAX_FD != -1 to use that value.
|
||||
MAX_FD="maximum"
|
||||
|
||||
warn () {
|
||||
echo "$*"
|
||||
}
|
||||
|
||||
die () {
|
||||
echo
|
||||
echo "$*"
|
||||
echo
|
||||
exit 1
|
||||
}
|
||||
|
||||
# OS specific support (must be 'true' or 'false').
|
||||
cygwin=false
|
||||
msys=false
|
||||
darwin=false
|
||||
nonstop=false
|
||||
case "`uname`" in
|
||||
CYGWIN* )
|
||||
cygwin=true
|
||||
;;
|
||||
Darwin* )
|
||||
darwin=true
|
||||
;;
|
||||
MINGW* )
|
||||
msys=true
|
||||
;;
|
||||
NONSTOP* )
|
||||
nonstop=true
|
||||
;;
|
||||
esac
|
||||
|
||||
CLASSPATH=$APP_HOME/gradle/wrapper/gradle-wrapper.jar
|
||||
|
||||
# Determine the Java command to use to start the JVM.
|
||||
if [ -n "$JAVA_HOME" ] ; then
|
||||
if [ -x "$JAVA_HOME/jre/sh/java" ] ; then
|
||||
# IBM's JDK on AIX uses strange locations for the executables
|
||||
JAVACMD="$JAVA_HOME/jre/sh/java"
|
||||
else
|
||||
JAVACMD="$JAVA_HOME/bin/java"
|
||||
fi
|
||||
if [ ! -x "$JAVACMD" ] ; then
|
||||
die "ERROR: JAVA_HOME is set to an invalid directory: $JAVA_HOME
|
||||
|
||||
Please set the JAVA_HOME variable in your environment to match the
|
||||
location of your Java installation."
|
||||
fi
|
||||
else
|
||||
JAVACMD="java"
|
||||
which java >/dev/null 2>&1 || die "ERROR: JAVA_HOME is not set and no 'java' command could be found in your PATH.
|
||||
|
||||
Please set the JAVA_HOME variable in your environment to match the
|
||||
location of your Java installation."
|
||||
fi
|
||||
|
||||
# Increase the maximum file descriptors if we can.
|
||||
if [ "$cygwin" = "false" -a "$darwin" = "false" -a "$nonstop" = "false" ] ; then
|
||||
MAX_FD_LIMIT=`ulimit -H -n`
|
||||
if [ $? -eq 0 ] ; then
|
||||
if [ "$MAX_FD" = "maximum" -o "$MAX_FD" = "max" ] ; then
|
||||
MAX_FD="$MAX_FD_LIMIT"
|
||||
fi
|
||||
ulimit -n $MAX_FD
|
||||
if [ $? -ne 0 ] ; then
|
||||
warn "Could not set maximum file descriptor limit: $MAX_FD"
|
||||
fi
|
||||
else
|
||||
warn "Could not query maximum file descriptor limit: $MAX_FD_LIMIT"
|
||||
fi
|
||||
fi
|
||||
|
||||
# For Darwin, add options to specify how the application appears in the dock
|
||||
if $darwin; then
|
||||
GRADLE_OPTS="$GRADLE_OPTS \"-Xdock:name=$APP_NAME\" \"-Xdock:icon=$APP_HOME/media/gradle.icns\""
|
||||
fi
|
||||
|
||||
# For Cygwin or MSYS, switch paths to Windows format before running java
|
||||
if [ "$cygwin" = "true" -o "$msys" = "true" ] ; then
|
||||
APP_HOME=`cygpath --path --mixed "$APP_HOME"`
|
||||
CLASSPATH=`cygpath --path --mixed "$CLASSPATH"`
|
||||
JAVACMD=`cygpath --unix "$JAVACMD"`
|
||||
|
||||
# We build the pattern for arguments to be converted via cygpath
|
||||
ROOTDIRSRAW=`find -L / -maxdepth 1 -mindepth 1 -type d 2>/dev/null`
|
||||
SEP=""
|
||||
for dir in $ROOTDIRSRAW ; do
|
||||
ROOTDIRS="$ROOTDIRS$SEP$dir"
|
||||
SEP="|"
|
||||
done
|
||||
OURCYGPATTERN="(^($ROOTDIRS))"
|
||||
# Add a user-defined pattern to the cygpath arguments
|
||||
if [ "$GRADLE_CYGPATTERN" != "" ] ; then
|
||||
OURCYGPATTERN="$OURCYGPATTERN|($GRADLE_CYGPATTERN)"
|
||||
fi
|
||||
# Now convert the arguments - kludge to limit ourselves to /bin/sh
|
||||
i=0
|
||||
for arg in "$@" ; do
|
||||
CHECK=`echo "$arg"|egrep -c "$OURCYGPATTERN" -`
|
||||
CHECK2=`echo "$arg"|egrep -c "^-"` ### Determine if an option
|
||||
|
||||
if [ $CHECK -ne 0 ] && [ $CHECK2 -eq 0 ] ; then ### Added a condition
|
||||
eval `echo args$i`=`cygpath --path --ignore --mixed "$arg"`
|
||||
else
|
||||
eval `echo args$i`="\"$arg\""
|
||||
fi
|
||||
i=`expr $i + 1`
|
||||
done
|
||||
case $i in
|
||||
0) set -- ;;
|
||||
1) set -- "$args0" ;;
|
||||
2) set -- "$args0" "$args1" ;;
|
||||
3) set -- "$args0" "$args1" "$args2" ;;
|
||||
4) set -- "$args0" "$args1" "$args2" "$args3" ;;
|
||||
5) set -- "$args0" "$args1" "$args2" "$args3" "$args4" ;;
|
||||
6) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" ;;
|
||||
7) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" "$args6" ;;
|
||||
8) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" "$args6" "$args7" ;;
|
||||
9) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" "$args6" "$args7" "$args8" ;;
|
||||
esac
|
||||
fi
|
||||
|
||||
# Escape application args
|
||||
save () {
|
||||
for i do printf %s\\n "$i" | sed "s/'/'\\\\''/g;1s/^/'/;\$s/\$/' \\\\/" ; done
|
||||
echo " "
|
||||
}
|
||||
APP_ARGS=`save "$@"`
|
||||
|
||||
# Collect all arguments for the java command, following the shell quoting and substitution rules
|
||||
eval set -- $DEFAULT_JVM_OPTS $JAVA_OPTS $GRADLE_OPTS "\"-Dorg.gradle.appname=$APP_BASE_NAME\"" -classpath "\"$CLASSPATH\"" org.gradle.wrapper.GradleWrapperMain "$APP_ARGS"
|
||||
|
||||
exec "$JAVACMD" "$@"
|
100
gradlew.bat
vendored
Normale Datei
100
gradlew.bat
vendored
Normale Datei
@ -0,0 +1,100 @@
|
||||
@rem
|
||||
@rem Copyright 2015 the original author or authors.
|
||||
@rem
|
||||
@rem Licensed under the Apache License, Version 2.0 (the "License");
|
||||
@rem you may not use this file except in compliance with the License.
|
||||
@rem You may obtain a copy of the License at
|
||||
@rem
|
||||
@rem https://www.apache.org/licenses/LICENSE-2.0
|
||||
@rem
|
||||
@rem Unless required by applicable law or agreed to in writing, software
|
||||
@rem distributed under the License is distributed on an "AS IS" BASIS,
|
||||
@rem WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
@rem See the License for the specific language governing permissions and
|
||||
@rem limitations under the License.
|
||||
@rem
|
||||
|
||||
@if "%DEBUG%" == "" @echo off
|
||||
@rem ##########################################################################
|
||||
@rem
|
||||
@rem Gradle startup script for Windows
|
||||
@rem
|
||||
@rem ##########################################################################
|
||||
|
||||
@rem Set local scope for the variables with windows NT shell
|
||||
if "%OS%"=="Windows_NT" setlocal
|
||||
|
||||
set DIRNAME=%~dp0
|
||||
if "%DIRNAME%" == "" set DIRNAME=.
|
||||
set APP_BASE_NAME=%~n0
|
||||
set APP_HOME=%DIRNAME%
|
||||
|
||||
@rem Add default JVM options here. You can also use JAVA_OPTS and GRADLE_OPTS to pass JVM options to this script.
|
||||
set DEFAULT_JVM_OPTS="-Xmx64m" "-Xms64m"
|
||||
|
||||
@rem Find java.exe
|
||||
if defined JAVA_HOME goto findJavaFromJavaHome
|
||||
|
||||
set JAVA_EXE=java.exe
|
||||
%JAVA_EXE% -version >NUL 2>&1
|
||||
if "%ERRORLEVEL%" == "0" goto init
|
||||
|
||||
echo.
|
||||
echo ERROR: JAVA_HOME is not set and no 'java' command could be found in your PATH.
|
||||
echo.
|
||||
echo Please set the JAVA_HOME variable in your environment to match the
|
||||
echo location of your Java installation.
|
||||
|
||||
goto fail
|
||||
|
||||
:findJavaFromJavaHome
|
||||
set JAVA_HOME=%JAVA_HOME:"=%
|
||||
set JAVA_EXE=%JAVA_HOME%/bin/java.exe
|
||||
|
||||
if exist "%JAVA_EXE%" goto init
|
||||
|
||||
echo.
|
||||
echo ERROR: JAVA_HOME is set to an invalid directory: %JAVA_HOME%
|
||||
echo.
|
||||
echo Please set the JAVA_HOME variable in your environment to match the
|
||||
echo location of your Java installation.
|
||||
|
||||
goto fail
|
||||
|
||||
:init
|
||||
@rem Get command-line arguments, handling Windows variants
|
||||
|
||||
if not "%OS%" == "Windows_NT" goto win9xME_args
|
||||
|
||||
:win9xME_args
|
||||
@rem Slurp the command line arguments.
|
||||
set CMD_LINE_ARGS=
|
||||
set _SKIP=2
|
||||
|
||||
:win9xME_args_slurp
|
||||
if "x%~1" == "x" goto execute
|
||||
|
||||
set CMD_LINE_ARGS=%*
|
||||
|
||||
:execute
|
||||
@rem Setup the command line
|
||||
|
||||
set CLASSPATH=%APP_HOME%\gradle\wrapper\gradle-wrapper.jar
|
||||
|
||||
@rem Execute Gradle
|
||||
"%JAVA_EXE%" %DEFAULT_JVM_OPTS% %JAVA_OPTS% %GRADLE_OPTS% "-Dorg.gradle.appname=%APP_BASE_NAME%" -classpath "%CLASSPATH%" org.gradle.wrapper.GradleWrapperMain %CMD_LINE_ARGS%
|
||||
|
||||
:end
|
||||
@rem End local scope for the variables with windows NT shell
|
||||
if "%ERRORLEVEL%"=="0" goto mainEnd
|
||||
|
||||
:fail
|
||||
rem Set variable GRADLE_EXIT_CONSOLE if you need the _script_ return code instead of
|
||||
rem the _cmd.exe /c_ return code!
|
||||
if not "" == "%GRADLE_EXIT_CONSOLE%" exit 1
|
||||
exit /b 1
|
||||
|
||||
:mainEnd
|
||||
if "%OS%"=="Windows_NT" endlocal
|
||||
|
||||
:omega
|
48
pom.xml
48
pom.xml
@ -1,48 +0,0 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<project xmlns="http://maven.apache.org/POM/4.0.0"
|
||||
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
|
||||
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
|
||||
<modelVersion>4.0.0</modelVersion>
|
||||
|
||||
<groupId>steamwar</groupId>
|
||||
<artifactId>SchematicSystem</artifactId>
|
||||
<version>1.0</version>
|
||||
<url>https://maven.apache.org</url>
|
||||
<packaging>pom</packaging>
|
||||
|
||||
<properties>
|
||||
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
|
||||
<main.basedir>${project.basedir}</main.basedir>
|
||||
</properties>
|
||||
|
||||
<build>
|
||||
<plugins>
|
||||
<plugin>
|
||||
<groupId>org.apache.maven.plugins</groupId>
|
||||
<artifactId>maven-compiler-plugin</artifactId>
|
||||
<version>3.6.1</version>
|
||||
<configuration>
|
||||
<source>1.8</source>
|
||||
<target>1.8</target>
|
||||
</configuration>
|
||||
</plugin>
|
||||
</plugins>
|
||||
</build>
|
||||
|
||||
<modules>
|
||||
<module>SchematicSystem_12</module>
|
||||
<module>SchematicSystem_15</module>
|
||||
<module>SchematicSystem_API</module>
|
||||
<module>SchematicSystem_Main</module>
|
||||
</modules>
|
||||
|
||||
<dependencies>
|
||||
<dependency>
|
||||
<groupId>steamwar</groupId>
|
||||
<artifactId>SpigotCore</artifactId>
|
||||
<version>1.0</version>
|
||||
<scope>system</scope>
|
||||
<systemPath>${main.basedir}/lib/SpigotCore.jar</systemPath>
|
||||
</dependency>
|
||||
</dependencies>
|
||||
</project>
|
38
settings.gradle
Normale Datei
38
settings.gradle
Normale Datei
@ -0,0 +1,38 @@
|
||||
/*
|
||||
* This file is a part of the SteamWar software.
|
||||
*
|
||||
* Copyright (C) 2020 SteamWar.de-Serverteam
|
||||
*
|
||||
* This program is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU Affero General Public License as published by
|
||||
* the Free Software Foundation, either version 3 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 Affero General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU Affero General Public License
|
||||
* along with this program. If not, see <https://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
pluginManagement {
|
||||
repositories {
|
||||
gradlePluginPortal()
|
||||
maven {
|
||||
url = uri("https://steamwar.de/maven/")
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
rootProject.name = 'SchematicSystem'
|
||||
|
||||
file('.').listFiles().each {
|
||||
if (!it.isDirectory()) {
|
||||
return
|
||||
}
|
||||
if (new File(it, "build.gradle").exists()) {
|
||||
include(it.name)
|
||||
}
|
||||
}
|
9
steamwarci.yml
Normale Datei
9
steamwarci.yml
Normale Datei
@ -0,0 +1,9 @@
|
||||
setup:
|
||||
- "ln -s /home/gitea/lib"
|
||||
|
||||
build:
|
||||
- "./gradlew buildProject"
|
||||
- "./gradlew --stop"
|
||||
|
||||
artifacts:
|
||||
"/binarys/schematicsystem.jar": "build/libs/schematicsystem.jar"
|
In neuem Issue referenzieren
Einen Benutzer sperren