Update gradle version to 7.3.1-all
Dieser Commit ist enthalten in:
Ursprung
6a9d6220a7
Commit
5495bdbc26
2
gradle/wrapper/gradle-wrapper.properties
vendored
2
gradle/wrapper/gradle-wrapper.properties
vendored
@ -1,5 +1,5 @@
|
||||
distributionBase=GRADLE_USER_HOME
|
||||
distributionPath=wrapper/dists
|
||||
distributionUrl=https\://services.gradle.org/distributions/gradle-5.6.1-bin.zip
|
||||
distributionUrl=https\://services.gradle.org/distributions/gradle-7.3.1-all.zip
|
||||
zipStoreBase=GRADLE_USER_HOME
|
||||
zipStorePath=wrapper/dists
|
||||
|
@ -1,271 +0,0 @@
|
||||
/*
|
||||
* 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/>.
|
||||
*/
|
||||
|
||||
package de.steamwar.teamserver.command;
|
||||
|
||||
import com.sk89q.worldedit.extent.clipboard.Clipboard;
|
||||
import com.sk89q.worldedit.math.BlockVector3;
|
||||
import com.sk89q.worldedit.world.block.BaseBlock;
|
||||
import com.sk89q.worldedit.world.block.BlockType;
|
||||
import com.sk89q.worldedit.world.block.BlockTypes;
|
||||
import de.steamwar.command.SWCommand;
|
||||
import de.steamwar.teamserver.Teamserver;
|
||||
import de.steamwar.sql.Schematic;
|
||||
import de.steamwar.sql.SteamwarUser;
|
||||
import lombok.AllArgsConstructor;
|
||||
import org.bukkit.Bukkit;
|
||||
import org.bukkit.entity.Player;
|
||||
|
||||
import java.io.IOException;
|
||||
import java.util.*;
|
||||
import java.util.concurrent.atomic.AtomicInteger;
|
||||
|
||||
public class SchemEqualityCommand extends SWCommand {
|
||||
|
||||
public SchemEqualityCommand() {
|
||||
super("schemcheck", "sc");
|
||||
}
|
||||
|
||||
@Register(help = true)
|
||||
public void genericHelp(Player p, String... args) {
|
||||
p.sendMessage("/schemcheck <Player1> <Schem1> <Player2> <Schem2>");
|
||||
p.sendMessage("/schemcheck <Player1> <Schem1> <Player2>");
|
||||
}
|
||||
|
||||
@Register
|
||||
public void genericCommand(Player p, String user1, String schem1, String user2) {
|
||||
SteamwarUser steamwarUser = SteamwarUser.get(p.getUniqueId());
|
||||
if (!steamwarUser.getUserGroup().isAdminGroup()) {
|
||||
p.sendMessage("Keine Berechtigung");
|
||||
return;
|
||||
}
|
||||
|
||||
SteamwarUser steamwarUser1 = SteamwarUser.get(user1);
|
||||
if (steamwarUser1 == null) {
|
||||
try {
|
||||
steamwarUser1 = SteamwarUser.get(UUID.fromString(user1));
|
||||
} catch (Exception e) {
|
||||
|
||||
}
|
||||
}
|
||||
if (steamwarUser1 == null) {
|
||||
try {
|
||||
steamwarUser1 = SteamwarUser.get(Integer.parseInt(user1));
|
||||
} catch (Exception e) {
|
||||
|
||||
}
|
||||
}
|
||||
if (steamwarUser1 == null) {
|
||||
p.sendMessage("Unbekannter Spieler");
|
||||
return;
|
||||
}
|
||||
Schematic schematic1 = Schematic.getSchemFromDB(schem1, steamwarUser1.getId());
|
||||
|
||||
SteamwarUser steamwarUser2 = SteamwarUser.get(user2);
|
||||
if (steamwarUser2 == null) {
|
||||
try {
|
||||
steamwarUser2 = SteamwarUser.get(UUID.fromString(user1));
|
||||
} catch (Exception e) {
|
||||
|
||||
}
|
||||
}
|
||||
if (steamwarUser2 == null) {
|
||||
try {
|
||||
steamwarUser2 = SteamwarUser.get(Integer.parseInt(user1));
|
||||
} catch (Exception e) {
|
||||
|
||||
}
|
||||
}
|
||||
if (steamwarUser2 == null) {
|
||||
p.sendMessage("Unbekannter Spieler");
|
||||
return;
|
||||
}
|
||||
List<Schematic> schematicList = Schematic.getSchemsAccessibleByUser(steamwarUser2.getId());
|
||||
|
||||
if (schematic1 == null) {
|
||||
p.sendMessage("Fehler beim finden einer der Schematics");
|
||||
return;
|
||||
}
|
||||
if (schematicList.isEmpty()) {
|
||||
p.sendMessage("Der User hat keine Schematics");
|
||||
return;
|
||||
}
|
||||
|
||||
Clipboard clipboard;
|
||||
try {
|
||||
clipboard = schematic1.load();
|
||||
} catch (IOException e) {
|
||||
p.sendMessage("Fehler beim laden");
|
||||
return;
|
||||
}
|
||||
|
||||
Bukkit.getScheduler().runTaskAsynchronously(Teamserver.getInstance(), () -> {
|
||||
List<CheckResult> checkResults = new ArrayList<>();
|
||||
int index = 0;
|
||||
for (Schematic schematic : schematicList) {
|
||||
if (index % 10 == 0) {
|
||||
p.sendMessage(index + "/" + schematicList.size());
|
||||
}
|
||||
index++;
|
||||
try {
|
||||
CheckResult checkResult = check(clipboard, schematic.getSchemName(), schematic.load());
|
||||
if (checkResult == null) {
|
||||
continue;
|
||||
}
|
||||
checkResults.add(checkResult);
|
||||
checkResults.sort(Comparator.comparingInt(value -> value.equalBlock));
|
||||
while (checkResults.size() > 3) {
|
||||
checkResults.remove(0);
|
||||
}
|
||||
} catch (Exception e) {
|
||||
// Ignored
|
||||
}
|
||||
}
|
||||
|
||||
for (int i = 0; i < checkResults.size(); i++) {
|
||||
p.sendMessage((checkResults.size() - i) + ". " + checkResults.get(i).name + " - " + checkResults.get(i).equalBlock + "/" + checkResults.get(i).volume);
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
@Register
|
||||
public void genericCommand(Player p, String user1, String schem1, String user2, String schem2) {
|
||||
SteamwarUser steamwarUser = SteamwarUser.get(p.getUniqueId());
|
||||
if (!steamwarUser.getUserGroup().isAdminGroup()) {
|
||||
p.sendMessage("Keine Berechtigung");
|
||||
return;
|
||||
}
|
||||
|
||||
SteamwarUser steamwarUser1 = SteamwarUser.get(user1);
|
||||
if (steamwarUser1 == null) {
|
||||
try {
|
||||
steamwarUser1 = SteamwarUser.get(UUID.fromString(user1));
|
||||
} catch (Exception e) {
|
||||
|
||||
}
|
||||
}
|
||||
if (steamwarUser1 == null) {
|
||||
try {
|
||||
steamwarUser1 = SteamwarUser.get(Integer.parseInt(user1));
|
||||
} catch (Exception e) {
|
||||
|
||||
}
|
||||
}
|
||||
if (steamwarUser1 == null) {
|
||||
p.sendMessage("Unbekannter Spieler");
|
||||
return;
|
||||
}
|
||||
Schematic schematic1 = Schematic.getSchemFromDB(schem1, steamwarUser1.getId());
|
||||
|
||||
SteamwarUser steamwarUser2 = SteamwarUser.get(user2);
|
||||
if (steamwarUser2 == null) {
|
||||
try {
|
||||
steamwarUser2 = SteamwarUser.get(UUID.fromString(user1));
|
||||
} catch (Exception e) {
|
||||
|
||||
}
|
||||
}
|
||||
if (steamwarUser2 == null) {
|
||||
try {
|
||||
steamwarUser2 = SteamwarUser.get(Integer.parseInt(user1));
|
||||
} catch (Exception e) {
|
||||
|
||||
}
|
||||
}
|
||||
if (steamwarUser2 == null) {
|
||||
p.sendMessage("Unbekannter Spieler");
|
||||
return;
|
||||
}
|
||||
Schematic schematic2 = Schematic.getSchemFromDB(schem2, steamwarUser2.getId());
|
||||
|
||||
if (schematic1 == null || schematic2 == null) {
|
||||
p.sendMessage("Fehler beim finden einer der Schematics");
|
||||
return;
|
||||
}
|
||||
|
||||
try {
|
||||
Clipboard clipboard1 = schematic1.load();
|
||||
Clipboard clipboard2 = schematic2.load();
|
||||
|
||||
CheckResult checkResult = check(clipboard1, schematic2.getSchemName(), clipboard2);
|
||||
if (checkResult == null) {
|
||||
p.sendMessage("Ungleich");
|
||||
return;
|
||||
}
|
||||
|
||||
p.sendMessage(checkResult.equalBlock + "/" + checkResult.volume);
|
||||
checkResult.blockEqualities.forEach((blockType, atomicInteger) -> {
|
||||
p.sendMessage(blockType.toString() + ": " + atomicInteger.get());
|
||||
});
|
||||
} catch (Exception e) {
|
||||
p.sendMessage("Fehler beim Laden der Schematics");
|
||||
}
|
||||
}
|
||||
|
||||
@AllArgsConstructor
|
||||
private class CheckResult {
|
||||
private String name;
|
||||
private int volume;
|
||||
private int equalBlock;
|
||||
private Map<BlockType, AtomicInteger> blockEqualities;
|
||||
}
|
||||
|
||||
private CheckResult check(Clipboard clipboard1, String name, Clipboard clipboard2) {
|
||||
if (!clipboard1.getDimensions().equals(clipboard2.getDimensions())) {
|
||||
return null;
|
||||
}
|
||||
|
||||
BlockVector3 minimum1 = clipboard1.getRegion().getMinimumPoint();
|
||||
BlockVector3 minimum2 = clipboard2.getRegion().getMinimumPoint();
|
||||
|
||||
Map<BlockType, AtomicInteger> blockEqualities = new HashMap<>();
|
||||
int equalBlocks = 0;
|
||||
for (int x = 0; x < clipboard1.getDimensions().getX(); x++) {
|
||||
for (int y = 0; y < clipboard1.getDimensions().getY(); y++) {
|
||||
for (int z = 0; z < clipboard1.getDimensions().getZ(); z++) {
|
||||
BlockVector3 pos1 = minimum1.add(x, y, z);
|
||||
BlockVector3 pos2 = minimum2.add(x, y, z);
|
||||
|
||||
BaseBlock block = clipboard1.getFullBlock(pos1);
|
||||
if (block.equalsFuzzy(clipboard2.getFullBlock(pos2))) {
|
||||
if (block.getBlockType().equals(BlockTypes.END_STONE)) {
|
||||
continue;
|
||||
}
|
||||
if (block.getBlockType().equals(BlockTypes.END_STONE_BRICKS)) {
|
||||
continue;
|
||||
}
|
||||
if (block.getBlockType().equals(BlockTypes.END_STONE_BRICK_SLAB)) {
|
||||
continue;
|
||||
}
|
||||
if (block.getBlockType().equals(BlockTypes.END_STONE_BRICK_STAIRS)) {
|
||||
continue;
|
||||
}
|
||||
if (block.getBlockType().equals(BlockTypes.END_STONE_BRICK_WALL)) {
|
||||
continue;
|
||||
}
|
||||
equalBlocks++;
|
||||
blockEqualities.computeIfAbsent(clipboard1.getFullBlock(pos1).getBlockType(), blockType -> new AtomicInteger()).incrementAndGet();
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
return new CheckResult(name, clipboard1.getDimensions().getX() * clipboard1.getDimensions().getY() * clipboard1.getDimensions().getZ(), equalBlocks, blockEqualities);
|
||||
}
|
||||
|
||||
}
|
In neuem Issue referenzieren
Einen Benutzer sperren