Merge branch 'master' into schematic-node
# Conflicts: # SpigotCore_Main/src/de/steamwar/sql/Schematic.java
Dieser Commit ist enthalten in:
Commit
297f72a16e
16
.gitignore
vendored
16
.gitignore
vendored
@ -1,5 +1,15 @@
|
|||||||
|
# Package Files
|
||||||
|
*.jar
|
||||||
|
|
||||||
|
# Gradle
|
||||||
|
.gradle
|
||||||
|
**/build/
|
||||||
|
!gradle/wrapper/gradle-wrapper.jar
|
||||||
|
steamwar.properties
|
||||||
|
|
||||||
|
# IntelliJ IDEA
|
||||||
.idea
|
.idea
|
||||||
target
|
|
||||||
lib
|
|
||||||
dependency-reduced-pom.xml
|
|
||||||
*.iml
|
*.iml
|
||||||
|
|
||||||
|
# Other
|
||||||
|
lib
|
49
SpigotCore_10/build.gradle
Normale Datei
49
SpigotCore_10/build.gradle
Normale Datei
@ -0,0 +1,49 @@
|
|||||||
|
/*
|
||||||
|
* 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 {
|
||||||
|
implementation project(":SpigotCore_Main")
|
||||||
|
|
||||||
|
compileOnly files("${project.rootDir}/lib/Spigot-1.10.jar")
|
||||||
|
}
|
@ -1,59 +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>SpigotCore</artifactId>
|
|
||||||
<version>2.0</version>
|
|
||||||
</parent>
|
|
||||||
|
|
||||||
<properties>
|
|
||||||
<main.basedir>${project.basedir}/..</main.basedir>
|
|
||||||
</properties>
|
|
||||||
|
|
||||||
<artifactId>SpigotCore_10</artifactId>
|
|
||||||
<version>2.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.10</version>
|
|
||||||
<scope>system</scope>
|
|
||||||
<systemPath>${main.basedir}/lib/Spigot-1.10.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>SpigotCore_API</artifactId>
|
|
||||||
<version>2.0</version>
|
|
||||||
</dependency>
|
|
||||||
<dependency>
|
|
||||||
<groupId>steamwar</groupId>
|
|
||||||
<artifactId>SpigotCore_9</artifactId>
|
|
||||||
<version>2.0</version>
|
|
||||||
</dependency>
|
|
||||||
</dependencies>
|
|
||||||
</project>
|
|
20
SpigotCore_10/settings.gradle
Normale Datei
20
SpigotCore_10/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 = 'SpigotCore_10'
|
@ -17,17 +17,24 @@
|
|||||||
along with this program. If not, see <https://www.gnu.org/licenses/>.
|
along with this program. If not, see <https://www.gnu.org/licenses/>.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
package de.steamwar.chunk;
|
package de.steamwar.core;
|
||||||
|
|
||||||
|
import net.minecraft.server.v1_10_R1.MinecraftServer;
|
||||||
import net.minecraft.server.v1_10_R1.PacketPlayOutMapChunk;
|
import net.minecraft.server.v1_10_R1.PacketPlayOutMapChunk;
|
||||||
import org.bukkit.craftbukkit.v1_10_R1.CraftChunk;
|
import org.bukkit.craftbukkit.v1_10_R1.CraftChunk;
|
||||||
import org.bukkit.craftbukkit.v1_10_R1.entity.CraftPlayer;
|
import org.bukkit.craftbukkit.v1_10_R1.entity.CraftPlayer;
|
||||||
import org.bukkit.entity.Player;
|
import org.bukkit.entity.Player;
|
||||||
|
|
||||||
public class Chunk_10 {
|
public class CraftbukkitWrapper10 implements CraftbukkitWrapper.ICraftbukkitWrapper {
|
||||||
private Chunk_10(){}
|
|
||||||
|
|
||||||
public static void sendChunk(Player p, int chunkX, int chunkZ){
|
@Override
|
||||||
|
public void sendChunk(Player p, int chunkX, int chunkZ) {
|
||||||
((CraftPlayer)p).getHandle().playerConnection.sendPacket(new PacketPlayOutMapChunk(((CraftChunk)p.getWorld().getChunkAt(chunkX, chunkZ)).getHandle(), 65535));
|
((CraftPlayer)p).getHandle().playerConnection.sendPacket(new PacketPlayOutMapChunk(((CraftChunk)p.getWorld().getChunkAt(chunkX, chunkZ)).getHandle(), 65535));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@SuppressWarnings("deprecation")
|
||||||
|
@Override
|
||||||
|
public double[] getSpigotTPS() {
|
||||||
|
return MinecraftServer.getServer().recentTps;
|
||||||
|
}
|
||||||
}
|
}
|
@ -1,32 +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.core;
|
|
||||||
|
|
||||||
import net.minecraft.server.v1_10_R1.MinecraftServer;
|
|
||||||
|
|
||||||
public class SpigotTPS_10 {
|
|
||||||
|
|
||||||
private SpigotTPS_10(){}
|
|
||||||
|
|
||||||
static double[] getTps(){
|
|
||||||
return MinecraftServer.getServer().recentTps;
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
|
49
SpigotCore_12/build.gradle
Normale Datei
49
SpigotCore_12/build.gradle
Normale Datei
@ -0,0 +1,49 @@
|
|||||||
|
/*
|
||||||
|
* 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 {
|
||||||
|
implementation project(":SpigotCore_Main")
|
||||||
|
|
||||||
|
compileOnly files("${project.rootDir}/lib/Spigot-1.12.jar")
|
||||||
|
}
|
@ -1,59 +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>SpigotCore</artifactId>
|
|
||||||
<version>2.0</version>
|
|
||||||
</parent>
|
|
||||||
|
|
||||||
<properties>
|
|
||||||
<main.basedir>${project.basedir}/..</main.basedir>
|
|
||||||
</properties>
|
|
||||||
|
|
||||||
<artifactId>SpigotCore_12</artifactId>
|
|
||||||
<version>2.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>
|
|
||||||
<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>SpigotCore_API</artifactId>
|
|
||||||
<version>2.0</version>
|
|
||||||
</dependency>
|
|
||||||
<dependency>
|
|
||||||
<groupId>steamwar</groupId>
|
|
||||||
<artifactId>SpigotCore_8</artifactId>
|
|
||||||
<version>2.0</version>
|
|
||||||
</dependency>
|
|
||||||
</dependencies>
|
|
||||||
</project>
|
|
20
SpigotCore_12/settings.gradle
Normale Datei
20
SpigotCore_12/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 = 'SpigotCore_12'
|
@ -17,17 +17,24 @@
|
|||||||
along with this program. If not, see <https://www.gnu.org/licenses/>.
|
along with this program. If not, see <https://www.gnu.org/licenses/>.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
package de.steamwar.chunk;
|
package de.steamwar.core;
|
||||||
|
|
||||||
|
import net.minecraft.server.v1_12_R1.MinecraftServer;
|
||||||
import net.minecraft.server.v1_12_R1.PacketPlayOutMapChunk;
|
import net.minecraft.server.v1_12_R1.PacketPlayOutMapChunk;
|
||||||
import org.bukkit.craftbukkit.v1_12_R1.CraftChunk;
|
import org.bukkit.craftbukkit.v1_12_R1.CraftChunk;
|
||||||
import org.bukkit.craftbukkit.v1_12_R1.entity.CraftPlayer;
|
import org.bukkit.craftbukkit.v1_12_R1.entity.CraftPlayer;
|
||||||
import org.bukkit.entity.Player;
|
import org.bukkit.entity.Player;
|
||||||
|
|
||||||
public class Chunk_12 {
|
public class CraftbukkitWrapper12 implements CraftbukkitWrapper.ICraftbukkitWrapper {
|
||||||
private Chunk_12(){}
|
|
||||||
|
|
||||||
public static void sendChunk(Player p, int chunkX, int chunkZ){
|
@Override
|
||||||
|
public void sendChunk(Player p, int chunkX, int chunkZ) {
|
||||||
((CraftPlayer)p).getHandle().playerConnection.sendPacket(new PacketPlayOutMapChunk(((CraftChunk)p.getWorld().getChunkAt(chunkX, chunkZ)).getHandle(), 65535));
|
((CraftPlayer)p).getHandle().playerConnection.sendPacket(new PacketPlayOutMapChunk(((CraftChunk)p.getWorld().getChunkAt(chunkX, chunkZ)).getHandle(), 65535));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@SuppressWarnings("deprecation")
|
||||||
|
@Override
|
||||||
|
public double[] getSpigotTPS() {
|
||||||
|
return MinecraftServer.getServer().recentTps;
|
||||||
|
}
|
||||||
}
|
}
|
@ -1,32 +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.core;
|
|
||||||
|
|
||||||
import net.minecraft.server.v1_12_R1.MinecraftServer;
|
|
||||||
|
|
||||||
public class SpigotTPS_12 {
|
|
||||||
|
|
||||||
private SpigotTPS_12(){}
|
|
||||||
|
|
||||||
static double[] getTps(){
|
|
||||||
return MinecraftServer.getServer().recentTps;
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
|
@ -17,16 +17,16 @@
|
|||||||
along with this program. If not, see <https://www.gnu.org/licenses/>.
|
along with this program. If not, see <https://www.gnu.org/licenses/>.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
package de.steamwar.message;
|
package de.steamwar.core;
|
||||||
|
|
||||||
import org.bukkit.entity.Player;
|
import org.bukkit.entity.Player;
|
||||||
|
|
||||||
import java.util.Locale;
|
import java.util.Locale;
|
||||||
|
|
||||||
class Message_12 {
|
public class WorldOfColorWrapper12 implements WorldOfColorWrapper.IWorldOfColorWrapper {
|
||||||
private Message_12(){}
|
|
||||||
|
|
||||||
static Locale getLocale(Player player){
|
@Override
|
||||||
|
public Locale getLocale(Player player){
|
||||||
return Locale.forLanguageTag(player.getLocale());
|
return Locale.forLanguageTag(player.getLocale());
|
||||||
}
|
}
|
||||||
}
|
}
|
50
SpigotCore_14/build.gradle
Normale Datei
50
SpigotCore_14/build.gradle
Normale Datei
@ -0,0 +1,50 @@
|
|||||||
|
/*
|
||||||
|
* 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 {
|
||||||
|
implementation project(":SpigotCore_Main")
|
||||||
|
|
||||||
|
compileOnly files("${project.rootDir}/lib/Spigot-1.14.jar")
|
||||||
|
compileOnly files("${project.rootDir}/lib/WorldEdit-1.15.jar")
|
||||||
|
}
|
@ -1,55 +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>SpigotCore</artifactId>
|
|
||||||
<version>2.0</version>
|
|
||||||
</parent>
|
|
||||||
|
|
||||||
<properties>
|
|
||||||
<main.basedir>${project.basedir}/..</main.basedir>
|
|
||||||
</properties>
|
|
||||||
|
|
||||||
<artifactId>SpigotCore_14</artifactId>
|
|
||||||
<version>2.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.14</version>
|
|
||||||
<scope>system</scope>
|
|
||||||
<systemPath>${main.basedir}/lib/Spigot-1.14.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>
|
|
||||||
<dependency>
|
|
||||||
<groupId>steamwar</groupId>
|
|
||||||
<artifactId>SpigotCore_API</artifactId>
|
|
||||||
<version>2.0</version>
|
|
||||||
<scope>compile</scope>
|
|
||||||
</dependency>
|
|
||||||
</dependencies>
|
|
||||||
</project>
|
|
20
SpigotCore_14/settings.gradle
Normale Datei
20
SpigotCore_14/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 = 'SpigotCore_14'
|
@ -17,17 +17,24 @@
|
|||||||
along with this program. If not, see <https://www.gnu.org/licenses/>.
|
along with this program. If not, see <https://www.gnu.org/licenses/>.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
package de.steamwar.chunk;
|
package de.steamwar.core;
|
||||||
|
|
||||||
|
import net.minecraft.server.v1_14_R1.MinecraftServer;
|
||||||
import net.minecraft.server.v1_14_R1.PacketPlayOutMapChunk;
|
import net.minecraft.server.v1_14_R1.PacketPlayOutMapChunk;
|
||||||
import org.bukkit.craftbukkit.v1_14_R1.CraftChunk;
|
import org.bukkit.craftbukkit.v1_14_R1.CraftChunk;
|
||||||
import org.bukkit.craftbukkit.v1_14_R1.entity.CraftPlayer;
|
import org.bukkit.craftbukkit.v1_14_R1.entity.CraftPlayer;
|
||||||
import org.bukkit.entity.Player;
|
import org.bukkit.entity.Player;
|
||||||
|
|
||||||
public class Chunk_14 {
|
public class CraftbukkitWrapper14 implements CraftbukkitWrapper.ICraftbukkitWrapper {
|
||||||
private Chunk_14(){}
|
|
||||||
|
|
||||||
public static void sendChunk(Player p, int chunkX, int chunkZ){
|
@Override
|
||||||
|
public void sendChunk(Player p, int chunkX, int chunkZ) {
|
||||||
((CraftPlayer)p).getHandle().playerConnection.sendPacket(new PacketPlayOutMapChunk(((CraftChunk)p.getWorld().getChunkAt(chunkX, chunkZ)).getHandle(), 65535));
|
((CraftPlayer)p).getHandle().playerConnection.sendPacket(new PacketPlayOutMapChunk(((CraftChunk)p.getWorld().getChunkAt(chunkX, chunkZ)).getHandle(), 65535));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@SuppressWarnings("deprecation")
|
||||||
|
@Override
|
||||||
|
public double[] getSpigotTPS() {
|
||||||
|
return MinecraftServer.getServer().recentTps;
|
||||||
|
}
|
||||||
}
|
}
|
@ -17,8 +17,10 @@
|
|||||||
along with this program. If not, see <https://www.gnu.org/licenses/>.
|
along with this program. If not, see <https://www.gnu.org/licenses/>.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
package de.steamwar.inventory;
|
package de.steamwar.core;
|
||||||
|
|
||||||
|
import com.comphenix.tinyprotocol.Reflection;
|
||||||
|
import de.steamwar.scoreboard.SWScoreboard;
|
||||||
import org.bukkit.Bukkit;
|
import org.bukkit.Bukkit;
|
||||||
import org.bukkit.Material;
|
import org.bukkit.Material;
|
||||||
import org.bukkit.inventory.ItemStack;
|
import org.bukkit.inventory.ItemStack;
|
||||||
@ -27,8 +29,7 @@ import org.bukkit.inventory.meta.SkullMeta;
|
|||||||
import java.util.HashMap;
|
import java.util.HashMap;
|
||||||
import java.util.Map;
|
import java.util.Map;
|
||||||
|
|
||||||
class SWItem_14 {
|
public class FlatteningWrapper14 implements FlatteningWrapper.IFlatteningWrapper {
|
||||||
private SWItem_14(){}
|
|
||||||
|
|
||||||
private static final Map<String, Material> renamedLegacy = new HashMap<>();
|
private static final Map<String, Material> renamedLegacy = new HashMap<>();
|
||||||
|
|
||||||
@ -221,7 +222,25 @@ class SWItem_14 {
|
|||||||
renamedLegacy.put("RECORD_12", Material.MUSIC_DISC_WAIT);
|
renamedLegacy.put("RECORD_12", Material.MUSIC_DISC_WAIT);
|
||||||
}
|
}
|
||||||
|
|
||||||
static Material getMaterial(String material) {
|
private static final Reflection.FieldAccessor<?> scoreboardName = Reflection.getField(SWScoreboard.scoreboardObjective, Reflection.getClass("{nms}.IChatBaseComponent"), 0);
|
||||||
|
private static final Reflection.ConstructorInvoker chatComponentConstructor = Reflection.getConstructor(Reflection.getClass("{nms}.ChatComponentText"), String.class);
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void setScoreboardTitle(Object packet, String title) {
|
||||||
|
scoreboardName.set(packet, chatComponentConstructor.invoke(title));
|
||||||
|
}
|
||||||
|
|
||||||
|
private static final Class<?> scoreActionEnum = Reflection.getClass("{nms}.ScoreboardServer$Action");
|
||||||
|
private static final Reflection.FieldAccessor<?> scoreAction = Reflection.getField(SWScoreboard.scoreboardScore, scoreActionEnum, 0);
|
||||||
|
private static final Object scoreActionChange = scoreActionEnum.getEnumConstants()[0];
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void setScoreAction(Object packet) {
|
||||||
|
scoreAction.set(packet, scoreActionChange);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public Material getMaterial(String material) {
|
||||||
try{
|
try{
|
||||||
return Material.valueOf(material);
|
return Material.valueOf(material);
|
||||||
}catch(IllegalArgumentException e){
|
}catch(IllegalArgumentException e){
|
||||||
@ -229,7 +248,8 @@ class SWItem_14 {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
static Material getDye(int colorCode){
|
@Override
|
||||||
|
public Material getDye(int colorCode) {
|
||||||
switch(colorCode){
|
switch(colorCode){
|
||||||
case 1:
|
case 1:
|
||||||
return Material.RED_DYE;
|
return Material.RED_DYE;
|
||||||
@ -266,7 +286,9 @@ class SWItem_14 {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
static ItemStack setSkullOwner(String player){
|
@SuppressWarnings("deprecation")
|
||||||
|
@Override
|
||||||
|
public ItemStack setSkullOwner(String player) {
|
||||||
ItemStack head = new ItemStack(Material.PLAYER_HEAD, 1);
|
ItemStack head = new ItemStack(Material.PLAYER_HEAD, 1);
|
||||||
SkullMeta headmeta = (SkullMeta) head.getItemMeta();
|
SkullMeta headmeta = (SkullMeta) head.getItemMeta();
|
||||||
assert headmeta != null;
|
assert headmeta != null;
|
@ -1,23 +1,4 @@
|
|||||||
/*
|
package de.steamwar.core;
|
||||||
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.sql;
|
|
||||||
|
|
||||||
import com.google.common.collect.ImmutableList;
|
import com.google.common.collect.ImmutableList;
|
||||||
import com.google.common.collect.Maps;
|
import com.google.common.collect.Maps;
|
||||||
@ -25,7 +6,6 @@ import com.sk89q.jnbt.*;
|
|||||||
import com.sk89q.worldedit.EmptyClipboardException;
|
import com.sk89q.worldedit.EmptyClipboardException;
|
||||||
import com.sk89q.worldedit.WorldEdit;
|
import com.sk89q.worldedit.WorldEdit;
|
||||||
import com.sk89q.worldedit.WorldEditException;
|
import com.sk89q.worldedit.WorldEditException;
|
||||||
import com.sk89q.worldedit.bukkit.WorldEditPlugin;
|
|
||||||
import com.sk89q.worldedit.extension.input.InputParseException;
|
import com.sk89q.worldedit.extension.input.InputParseException;
|
||||||
import com.sk89q.worldedit.extension.input.ParserContext;
|
import com.sk89q.worldedit.extension.input.ParserContext;
|
||||||
import com.sk89q.worldedit.extension.platform.Actor;
|
import com.sk89q.worldedit.extension.platform.Actor;
|
||||||
@ -46,7 +26,7 @@ import com.sk89q.worldedit.world.DataFixer;
|
|||||||
import com.sk89q.worldedit.world.block.BlockState;
|
import com.sk89q.worldedit.world.block.BlockState;
|
||||||
import com.sk89q.worldedit.world.block.BlockTypes;
|
import com.sk89q.worldedit.world.block.BlockTypes;
|
||||||
import com.sk89q.worldedit.world.registry.LegacyMapper;
|
import com.sk89q.worldedit.world.registry.LegacyMapper;
|
||||||
import org.bukkit.Bukkit;
|
import de.steamwar.sql.NoClipboardException;
|
||||||
import org.bukkit.entity.Player;
|
import org.bukkit.entity.Player;
|
||||||
|
|
||||||
import java.io.ByteArrayOutputStream;
|
import java.io.ByteArrayOutputStream;
|
||||||
@ -54,20 +34,19 @@ import java.io.IOException;
|
|||||||
import java.io.InputStream;
|
import java.io.InputStream;
|
||||||
import java.util.*;
|
import java.util.*;
|
||||||
import java.util.stream.Collectors;
|
import java.util.stream.Collectors;
|
||||||
import java.util.zip.GZIPInputStream;
|
|
||||||
|
|
||||||
import static com.google.common.base.Preconditions.checkNotNull;
|
import static com.google.common.base.Preconditions.checkNotNull;
|
||||||
|
|
||||||
class Schematic_14 {
|
public class WorldEditWrapper14 implements WorldEditWrapper.IWorldEditWrapper {
|
||||||
private Schematic_14(){}
|
|
||||||
|
|
||||||
private static final ClipboardFormat SCHEMATIC = BuiltInClipboardFormat.MCEDIT_SCHEMATIC;
|
private static final ClipboardFormat SCHEMATIC = BuiltInClipboardFormat.MCEDIT_SCHEMATIC;
|
||||||
private static final ClipboardFormat SCHEM = BuiltInClipboardFormat.SPONGE_SCHEMATIC;
|
private static final ClipboardFormat SCHEM = BuiltInClipboardFormat.SPONGE_SCHEMATIC;
|
||||||
|
|
||||||
static byte[] getPlayerClipboard(Player player, boolean schemFormat) {
|
@Override
|
||||||
|
public byte[] getPlayerClipboard(Player player, boolean schemFormat) {
|
||||||
ClipboardHolder clipboardHolder;
|
ClipboardHolder clipboardHolder;
|
||||||
try {
|
try {
|
||||||
clipboardHolder = getWorldEditPlugin().getSession(player).getClipboard();
|
clipboardHolder = WorldEditWrapper.getWorldEditPlugin().getSession(player).getClipboard();
|
||||||
} catch (EmptyClipboardException e) {
|
} catch (EmptyClipboardException e) {
|
||||||
throw new NoClipboardException();
|
throw new NoClipboardException();
|
||||||
}
|
}
|
||||||
@ -93,7 +72,8 @@ class Schematic_14 {
|
|||||||
return outputStream.toByteArray();
|
return outputStream.toByteArray();
|
||||||
}
|
}
|
||||||
|
|
||||||
static void setPlayerClipboard(Player player, InputStream is, boolean schemFormat) {
|
@Override
|
||||||
|
public void setPlayerClipboard(Player player, InputStream is, boolean schemFormat) {
|
||||||
Clipboard clipboard = null;
|
Clipboard clipboard = null;
|
||||||
try {
|
try {
|
||||||
clipboard = getClipboard(is, schemFormat);
|
clipboard = getClipboard(is, schemFormat);
|
||||||
@ -104,26 +84,23 @@ class Schematic_14 {
|
|||||||
if (clipboard == null)
|
if (clipboard == null)
|
||||||
throw new NoClipboardException();
|
throw new NoClipboardException();
|
||||||
|
|
||||||
Actor actor = getWorldEditPlugin().wrapCommandSender(player);
|
Actor actor = WorldEditWrapper.getWorldEditPlugin().wrapCommandSender(player);
|
||||||
getWorldEditPlugin().getWorldEdit().getSessionManager().get(actor).setClipboard(new ClipboardHolder(clipboard));
|
WorldEditWrapper.getWorldEditPlugin().getWorldEdit().getSessionManager().get(actor).setClipboard(new ClipboardHolder(clipboard));
|
||||||
}
|
}
|
||||||
|
|
||||||
static Clipboard getClipboard(InputStream is, boolean schemFormat) throws IOException {
|
@Override
|
||||||
|
public Clipboard getClipboard(InputStream is, boolean schemFormat) throws IOException {
|
||||||
try {
|
try {
|
||||||
if(schemFormat){
|
if(schemFormat){
|
||||||
return new SpongeSchematicReader(new NBTInputStream(new GZIPInputStream(is))).read();
|
return new SpongeSchematicReader(new NBTInputStream(is)).read();
|
||||||
}else{
|
}else{
|
||||||
return new MCEditSchematicReader(new NBTInputStream(new GZIPInputStream(is))).read();
|
return new MCEditSchematicReader(new NBTInputStream(is)).read();
|
||||||
}
|
}
|
||||||
} catch (NullPointerException e) {
|
} catch (NullPointerException e) {
|
||||||
throw new NoClipboardException();
|
throw new NoClipboardException();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private static WorldEditPlugin getWorldEditPlugin() {
|
|
||||||
return (WorldEditPlugin) Bukkit.getPluginManager().getPlugin("WorldEdit");
|
|
||||||
}
|
|
||||||
|
|
||||||
private static class MCEditSchematicReader extends NBTSchematicReader {
|
private static class MCEditSchematicReader extends NBTSchematicReader {
|
||||||
|
|
||||||
private final NBTInputStream inputStream;
|
private final NBTInputStream inputStream;
|
49
SpigotCore_15/build.gradle
Normale Datei
49
SpigotCore_15/build.gradle
Normale Datei
@ -0,0 +1,49 @@
|
|||||||
|
/*
|
||||||
|
* 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 {
|
||||||
|
implementation project(":SpigotCore_Main")
|
||||||
|
|
||||||
|
compileOnly files("${project.rootDir}/lib/Spigot-1.15.jar")
|
||||||
|
}
|
@ -1,59 +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>SpigotCore</artifactId>
|
|
||||||
<version>2.0</version>
|
|
||||||
</parent>
|
|
||||||
|
|
||||||
<properties>
|
|
||||||
<main.basedir>${project.basedir}/..</main.basedir>
|
|
||||||
</properties>
|
|
||||||
|
|
||||||
<artifactId>SpigotCore_15</artifactId>
|
|
||||||
<version>2.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.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>
|
|
||||||
<dependency>
|
|
||||||
<groupId>steamwar</groupId>
|
|
||||||
<artifactId>SpigotCore_API</artifactId>
|
|
||||||
<version>2.0</version>
|
|
||||||
</dependency>
|
|
||||||
<dependency>
|
|
||||||
<groupId>steamwar</groupId>
|
|
||||||
<artifactId>SpigotCore_14</artifactId>
|
|
||||||
<version>2.0</version>
|
|
||||||
</dependency>
|
|
||||||
</dependencies>
|
|
||||||
</project>
|
|
20
SpigotCore_15/settings.gradle
Normale Datei
20
SpigotCore_15/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 = 'SpigotCore_15'
|
@ -1,33 +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.authlib;
|
|
||||||
|
|
||||||
import net.minecraft.server.v1_15_R1.MinecraftServer;
|
|
||||||
|
|
||||||
public class AuthlibInjector_15 {
|
|
||||||
|
|
||||||
static Class getMinecraftClass() {
|
|
||||||
return MinecraftServer.class;
|
|
||||||
}
|
|
||||||
|
|
||||||
static Object getMinecraftServerInstance() {
|
|
||||||
return MinecraftServer.getServer();
|
|
||||||
}
|
|
||||||
}
|
|
@ -17,17 +17,24 @@
|
|||||||
along with this program. If not, see <https://www.gnu.org/licenses/>.
|
along with this program. If not, see <https://www.gnu.org/licenses/>.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
package de.steamwar.chunk;
|
package de.steamwar.core;
|
||||||
|
|
||||||
|
import net.minecraft.server.v1_15_R1.MinecraftServer;
|
||||||
import net.minecraft.server.v1_15_R1.PacketPlayOutMapChunk;
|
import net.minecraft.server.v1_15_R1.PacketPlayOutMapChunk;
|
||||||
import org.bukkit.craftbukkit.v1_15_R1.CraftChunk;
|
import org.bukkit.craftbukkit.v1_15_R1.CraftChunk;
|
||||||
import org.bukkit.craftbukkit.v1_15_R1.entity.CraftPlayer;
|
import org.bukkit.craftbukkit.v1_15_R1.entity.CraftPlayer;
|
||||||
import org.bukkit.entity.Player;
|
import org.bukkit.entity.Player;
|
||||||
|
|
||||||
public class Chunk_15 {
|
public class CraftbukkitWrapper15 implements CraftbukkitWrapper.ICraftbukkitWrapper {
|
||||||
private Chunk_15(){}
|
|
||||||
|
|
||||||
public static void sendChunk(Player p, int chunkX, int chunkZ){
|
@Override
|
||||||
|
public void sendChunk(Player p, int chunkX, int chunkZ) {
|
||||||
((CraftPlayer)p).getHandle().playerConnection.sendPacket(new PacketPlayOutMapChunk(((CraftChunk)p.getWorld().getChunkAt(chunkX, chunkZ)).getHandle(), 65535));
|
((CraftPlayer)p).getHandle().playerConnection.sendPacket(new PacketPlayOutMapChunk(((CraftChunk)p.getWorld().getChunkAt(chunkX, chunkZ)).getHandle(), 65535));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@SuppressWarnings("deprecation")
|
||||||
|
@Override
|
||||||
|
public double[] getSpigotTPS() {
|
||||||
|
return MinecraftServer.getServer().recentTps;
|
||||||
|
}
|
||||||
}
|
}
|
50
SpigotCore_8/build.gradle
Normale Datei
50
SpigotCore_8/build.gradle
Normale Datei
@ -0,0 +1,50 @@
|
|||||||
|
/*
|
||||||
|
* 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 {
|
||||||
|
implementation project(":SpigotCore_Main")
|
||||||
|
|
||||||
|
compileOnly files("${project.rootDir}/lib/Spigot-1.8.jar")
|
||||||
|
compileOnly files("${project.rootDir}/lib/WorldEdit-1.12.jar")
|
||||||
|
}
|
@ -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>
|
|
||||||
|
|
||||||
<parent>
|
|
||||||
<groupId>steamwar</groupId>
|
|
||||||
<artifactId>SpigotCore</artifactId>
|
|
||||||
<version>2.0</version>
|
|
||||||
</parent>
|
|
||||||
|
|
||||||
<properties>
|
|
||||||
<main.basedir>${project.basedir}/..</main.basedir>
|
|
||||||
</properties>
|
|
||||||
|
|
||||||
<artifactId>SpigotCore_8</artifactId>
|
|
||||||
<version>2.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.8</version>
|
|
||||||
<scope>system</scope>
|
|
||||||
<systemPath>${main.basedir}/lib/Spigot-1.8.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>SpigotCore_API</artifactId>
|
|
||||||
<version>2.0</version>
|
|
||||||
</dependency>
|
|
||||||
</dependencies>
|
|
||||||
</project>
|
|
20
SpigotCore_8/settings.gradle
Normale Datei
20
SpigotCore_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 = 'SpigotCore_8'
|
41
SpigotCore_8/src/de/steamwar/core/BountifulWrapper8.java
Normale Datei
41
SpigotCore_8/src/de/steamwar/core/BountifulWrapper8.java
Normale Datei
@ -0,0 +1,41 @@
|
|||||||
|
/*
|
||||||
|
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.core;
|
||||||
|
|
||||||
|
import net.md_5.bungee.api.ChatMessageType;
|
||||||
|
import net.md_5.bungee.api.chat.BaseComponent;
|
||||||
|
import net.minecraft.server.v1_8_R3.ChatComponentText;
|
||||||
|
import net.minecraft.server.v1_8_R3.PacketPlayOutChat;
|
||||||
|
import org.bukkit.Sound;
|
||||||
|
import org.bukkit.craftbukkit.v1_8_R3.entity.CraftPlayer;
|
||||||
|
import org.bukkit.entity.Player;
|
||||||
|
|
||||||
|
public class BountifulWrapper8 implements BountifulWrapper.IBountifulWrapper {
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void playPling(Player player) {
|
||||||
|
player.playSound(player.getLocation(), Sound.ORB_PICKUP, 1, 1);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void sendMessage(Player player, ChatMessageType type, BaseComponent... msg) {
|
||||||
|
((CraftPlayer) player).getHandle().playerConnection.sendPacket(new PacketPlayOutChat(new ChatComponentText(BaseComponent.toLegacyText(msg)), (byte)type.ordinal()));
|
||||||
|
}
|
||||||
|
}
|
@ -17,17 +17,23 @@
|
|||||||
along with this program. If not, see <https://www.gnu.org/licenses/>.
|
along with this program. If not, see <https://www.gnu.org/licenses/>.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
package de.steamwar.chunk;
|
package de.steamwar.core;
|
||||||
|
|
||||||
|
import net.minecraft.server.v1_8_R3.MinecraftServer;
|
||||||
import net.minecraft.server.v1_8_R3.PacketPlayOutMapChunk;
|
import net.minecraft.server.v1_8_R3.PacketPlayOutMapChunk;
|
||||||
import org.bukkit.craftbukkit.v1_8_R3.CraftChunk;
|
import org.bukkit.craftbukkit.v1_8_R3.CraftChunk;
|
||||||
import org.bukkit.craftbukkit.v1_8_R3.entity.CraftPlayer;
|
import org.bukkit.craftbukkit.v1_8_R3.entity.CraftPlayer;
|
||||||
import org.bukkit.entity.Player;
|
import org.bukkit.entity.Player;
|
||||||
|
|
||||||
public class Chunk_8 {
|
public class CraftbukkitWrapper8 implements CraftbukkitWrapper.ICraftbukkitWrapper {
|
||||||
private Chunk_8(){}
|
|
||||||
|
|
||||||
public static void sendChunk(Player p, int chunkX, int chunkZ){
|
@Override
|
||||||
|
public void sendChunk(Player p, int chunkX, int chunkZ) {
|
||||||
((CraftPlayer)p).getHandle().playerConnection.sendPacket(new PacketPlayOutMapChunk(((CraftChunk)p.getWorld().getChunkAt(chunkX, chunkZ)).getHandle(), true, 65535));
|
((CraftPlayer)p).getHandle().playerConnection.sendPacket(new PacketPlayOutMapChunk(((CraftChunk)p.getWorld().getChunkAt(chunkX, chunkZ)).getHandle(), true, 65535));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public double[] getSpigotTPS() {
|
||||||
|
return MinecraftServer.getServer().recentTps;
|
||||||
|
}
|
||||||
}
|
}
|
@ -17,16 +17,33 @@
|
|||||||
along with this program. If not, see <https://www.gnu.org/licenses/>.
|
along with this program. If not, see <https://www.gnu.org/licenses/>.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
package de.steamwar.inventory;
|
package de.steamwar.core;
|
||||||
|
|
||||||
|
import com.comphenix.tinyprotocol.Reflection;
|
||||||
|
import de.steamwar.scoreboard.SWScoreboard;
|
||||||
import org.bukkit.Material;
|
import org.bukkit.Material;
|
||||||
import org.bukkit.inventory.ItemStack;
|
import org.bukkit.inventory.ItemStack;
|
||||||
import org.bukkit.inventory.meta.SkullMeta;
|
import org.bukkit.inventory.meta.SkullMeta;
|
||||||
|
|
||||||
class SWItem_8 {
|
public class FlatteningWrapper8 implements FlatteningWrapper.IFlatteningWrapper {
|
||||||
private SWItem_8(){}
|
|
||||||
|
|
||||||
static Material getMaterial(String material){
|
private static final Reflection.FieldAccessor<String> scoreboardName = Reflection.getField(SWScoreboard.scoreboardObjective, String.class, 1);
|
||||||
|
private static final Class<?> scoreActionEnum = Reflection.getClass("{nms}.PacketPlayOutScoreboardScore$EnumScoreboardAction");
|
||||||
|
private static final Reflection.FieldAccessor<?> scoreAction = Reflection.getField(SWScoreboard.scoreboardScore, scoreActionEnum, 0);
|
||||||
|
private static final Object scoreActionChange = scoreActionEnum.getEnumConstants()[0];
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void setScoreboardTitle(Object packet, String title) {
|
||||||
|
scoreboardName.set(packet, title);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void setScoreAction(Object packet) {
|
||||||
|
scoreAction.set(packet, scoreActionChange);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public Material getMaterial(String material) {
|
||||||
try{
|
try{
|
||||||
return Material.valueOf(material);
|
return Material.valueOf(material);
|
||||||
}catch(IllegalArgumentException e){
|
}catch(IllegalArgumentException e){
|
||||||
@ -34,11 +51,13 @@ class SWItem_8 {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
static Material getDye(){
|
@Override
|
||||||
|
public Material getDye(int colorCode) {
|
||||||
return Material.INK_SACK;
|
return Material.INK_SACK;
|
||||||
}
|
}
|
||||||
|
|
||||||
static ItemStack setSkullOwner(String player){
|
@Override
|
||||||
|
public ItemStack setSkullOwner(String player) {
|
||||||
ItemStack head = new ItemStack(Material.SKULL_ITEM, 1, (short) 3);
|
ItemStack head = new ItemStack(Material.SKULL_ITEM, 1, (short) 3);
|
||||||
SkullMeta headmeta = (SkullMeta) head.getItemMeta();
|
SkullMeta headmeta = (SkullMeta) head.getItemMeta();
|
||||||
headmeta.setOwner(player);
|
headmeta.setOwner(player);
|
@ -17,7 +17,7 @@
|
|||||||
along with this program. If not, see <https://www.gnu.org/licenses/>.
|
along with this program. If not, see <https://www.gnu.org/licenses/>.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
package de.steamwar.sql;
|
package de.steamwar.core;
|
||||||
|
|
||||||
import org.bukkit.configuration.file.YamlConfiguration;
|
import org.bukkit.configuration.file.YamlConfiguration;
|
||||||
|
|
||||||
@ -26,12 +26,12 @@ import java.util.HashMap;
|
|||||||
import java.util.Map;
|
import java.util.Map;
|
||||||
import java.util.Objects;
|
import java.util.Objects;
|
||||||
|
|
||||||
class IDConverter {
|
class IDConverter8 {
|
||||||
private IDConverter(){}
|
private IDConverter8(){}
|
||||||
|
|
||||||
static Map<String, BlockTypeID> getMap(){
|
static Map<String, BlockTypeID> getMap(){
|
||||||
Map<String, BlockTypeID> ids = new HashMap<>();
|
Map<String, BlockTypeID> ids = new HashMap<>();
|
||||||
YamlConfiguration legacy = YamlConfiguration.loadConfiguration(new InputStreamReader(Objects.requireNonNull(IDConverter.class.getClassLoader().getResourceAsStream("legacy.yml"))));
|
YamlConfiguration legacy = YamlConfiguration.loadConfiguration(new InputStreamReader(Objects.requireNonNull(IDConverter8.class.getClassLoader().getResourceAsStream("legacy.yml"))));
|
||||||
for(String blockString : legacy.getKeys(false)){
|
for(String blockString : legacy.getKeys(false)){
|
||||||
String blockNum = legacy.getString(blockString);
|
String blockNum = legacy.getString(blockString);
|
||||||
String[] block = blockNum.split(":");
|
String[] block = blockNum.split(":");
|
@ -1,32 +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.core;
|
|
||||||
|
|
||||||
import net.minecraft.server.v1_8_R3.MinecraftServer;
|
|
||||||
|
|
||||||
public class SpigotTPS_8 {
|
|
||||||
|
|
||||||
private SpigotTPS_8(){}
|
|
||||||
|
|
||||||
static double[] getTps(){
|
|
||||||
return MinecraftServer.getServer().recentTps;
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
|
@ -1,23 +1,4 @@
|
|||||||
/*
|
package de.steamwar.core;
|
||||||
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.sql;
|
|
||||||
|
|
||||||
import com.google.common.base.Preconditions;
|
import com.google.common.base.Preconditions;
|
||||||
import com.google.common.collect.Maps;
|
import com.google.common.collect.Maps;
|
||||||
@ -25,20 +6,19 @@ import com.sk89q.jnbt.*;
|
|||||||
import com.sk89q.worldedit.*;
|
import com.sk89q.worldedit.*;
|
||||||
import com.sk89q.worldedit.blocks.BaseBlock;
|
import com.sk89q.worldedit.blocks.BaseBlock;
|
||||||
import com.sk89q.worldedit.bukkit.BukkitWorld;
|
import com.sk89q.worldedit.bukkit.BukkitWorld;
|
||||||
import com.sk89q.worldedit.bukkit.WorldEditPlugin;
|
|
||||||
import com.sk89q.worldedit.extension.input.ParserContext;
|
import com.sk89q.worldedit.extension.input.ParserContext;
|
||||||
import com.sk89q.worldedit.extension.platform.Actor;
|
import com.sk89q.worldedit.extension.platform.Actor;
|
||||||
import com.sk89q.worldedit.extent.clipboard.BlockArrayClipboard;
|
import com.sk89q.worldedit.extent.clipboard.BlockArrayClipboard;
|
||||||
import com.sk89q.worldedit.extent.clipboard.Clipboard;
|
import com.sk89q.worldedit.extent.clipboard.Clipboard;
|
||||||
import com.sk89q.worldedit.extent.clipboard.io.ClipboardFormat;
|
import com.sk89q.worldedit.extent.clipboard.io.ClipboardFormat;
|
||||||
import com.sk89q.worldedit.extent.clipboard.io.ClipboardReader;
|
import com.sk89q.worldedit.extent.clipboard.io.ClipboardReader;
|
||||||
|
import com.sk89q.worldedit.extent.clipboard.io.SchematicReader;
|
||||||
import com.sk89q.worldedit.regions.CuboidRegion;
|
import com.sk89q.worldedit.regions.CuboidRegion;
|
||||||
import com.sk89q.worldedit.session.ClipboardHolder;
|
import com.sk89q.worldedit.session.ClipboardHolder;
|
||||||
import com.sk89q.worldedit.world.registry.WorldData;
|
import com.sk89q.worldedit.world.registry.WorldData;
|
||||||
import org.bukkit.Bukkit;
|
import de.steamwar.sql.NoClipboardException;
|
||||||
import org.bukkit.entity.Player;
|
import org.bukkit.entity.Player;
|
||||||
|
|
||||||
import javax.annotation.Nullable;
|
|
||||||
import java.io.ByteArrayOutputStream;
|
import java.io.ByteArrayOutputStream;
|
||||||
import java.io.IOException;
|
import java.io.IOException;
|
||||||
import java.io.InputStream;
|
import java.io.InputStream;
|
||||||
@ -47,15 +27,14 @@ import java.util.Iterator;
|
|||||||
import java.util.List;
|
import java.util.List;
|
||||||
import java.util.Map;
|
import java.util.Map;
|
||||||
import java.util.stream.Collectors;
|
import java.util.stream.Collectors;
|
||||||
import java.util.zip.GZIPInputStream;
|
|
||||||
|
|
||||||
class Schematic_8 {
|
public class WorldEditWrapper8 implements WorldEditWrapper.IWorldEditWrapper {
|
||||||
private Schematic_8(){}
|
|
||||||
|
|
||||||
static byte[] getPlayerClipboard(Player player) {
|
@Override
|
||||||
|
public byte[] getPlayerClipboard(Player player, boolean schemFormat) {
|
||||||
ClipboardHolder clipboardHolder;
|
ClipboardHolder clipboardHolder;
|
||||||
try {
|
try {
|
||||||
clipboardHolder = getWorldEditPlugin().getSession(player).getClipboard();
|
clipboardHolder = WorldEditWrapper.getWorldEditPlugin().getSession(player).getClipboard();
|
||||||
} catch (EmptyClipboardException e) {
|
} catch (EmptyClipboardException e) {
|
||||||
throw new NoClipboardException();
|
throw new NoClipboardException();
|
||||||
}
|
}
|
||||||
@ -73,7 +52,8 @@ class Schematic_8 {
|
|||||||
return outputStream.toByteArray();
|
return outputStream.toByteArray();
|
||||||
}
|
}
|
||||||
|
|
||||||
static void setPlayerClipboard(Player player, InputStream is, boolean schemFormat) {
|
@Override
|
||||||
|
public void setPlayerClipboard(Player player, InputStream is, boolean schemFormat) {
|
||||||
WorldData world = new BukkitWorld(player.getWorld()).getWorldData();
|
WorldData world = new BukkitWorld(player.getWorld()).getWorldData();
|
||||||
Clipboard clipboard;
|
Clipboard clipboard;
|
||||||
try {
|
try {
|
||||||
@ -82,22 +62,19 @@ class Schematic_8 {
|
|||||||
throw new RuntimeException(e);
|
throw new RuntimeException(e);
|
||||||
}
|
}
|
||||||
|
|
||||||
Actor actor = getWorldEditPlugin().wrapCommandSender(player);
|
Actor actor = WorldEditWrapper.getWorldEditPlugin().wrapCommandSender(player);
|
||||||
getWorldEditPlugin().getWorldEdit().getSessionManager().get(actor).setClipboard(new ClipboardHolder(clipboard, world));
|
WorldEditWrapper.getWorldEditPlugin().getWorldEdit().getSessionManager().get(actor).setClipboard(new ClipboardHolder(clipboard, world));
|
||||||
}
|
}
|
||||||
|
|
||||||
static Clipboard getClipboard(InputStream is, boolean schemFormat) throws IOException {
|
@Override
|
||||||
|
public Clipboard getClipboard(InputStream is, boolean schemFormat) throws IOException {
|
||||||
if(schemFormat)
|
if(schemFormat)
|
||||||
return new SpongeSchematicReader(new NBTInputStream(new GZIPInputStream(is))).read(WorldEdit.getInstance().getServer().getWorlds().get(0).getWorldData());
|
return new SpongeSchematicReader(new NBTInputStream(is)).read(WorldEdit.getInstance().getServer().getWorlds().get(0).getWorldData());
|
||||||
else
|
else
|
||||||
return ClipboardFormat.SCHEMATIC.getReader(is).read(WorldEdit.getInstance().getServer().getWorlds().get(0).getWorldData());
|
return new SchematicReader(new NBTInputStream(is)).read(WorldEdit.getInstance().getServer().getWorlds().get(0).getWorldData());
|
||||||
}
|
}
|
||||||
|
|
||||||
private static WorldEditPlugin getWorldEditPlugin() {
|
private static class SpongeSchematicReader implements ClipboardReader {
|
||||||
return (WorldEditPlugin) Bukkit.getPluginManager().getPlugin("WorldEdit");
|
|
||||||
}
|
|
||||||
|
|
||||||
public static class SpongeSchematicReader implements ClipboardReader {
|
|
||||||
|
|
||||||
private final NBTInputStream inputStream;
|
private final NBTInputStream inputStream;
|
||||||
private int schematicVersion = -1;
|
private int schematicVersion = -1;
|
||||||
@ -132,7 +109,7 @@ class Schematic_8 {
|
|||||||
}
|
}
|
||||||
|
|
||||||
private BlockArrayClipboard readSchematic(CompoundTag schematicTag) throws IOException {
|
private BlockArrayClipboard readSchematic(CompoundTag schematicTag) throws IOException {
|
||||||
final Map<String, IDConverter.BlockTypeID> ids = IDConverter.getMap();
|
final Map<String, IDConverter8.BlockTypeID> ids = IDConverter8.getMap();
|
||||||
|
|
||||||
Map<String, Tag> schematic = schematicTag.getValue();
|
Map<String, Tag> schematic = schematicTag.getValue();
|
||||||
int width = (requireTag(schematic, "Width", ShortTag.class)).getValue();
|
int width = (requireTag(schematic, "Width", ShortTag.class)).getValue();
|
||||||
@ -181,7 +158,7 @@ class Schematic_8 {
|
|||||||
String palettePart = iterator.next();
|
String palettePart = iterator.next();
|
||||||
id = requireTag(paletteObject, palettePart, IntTag.class).getValue();
|
id = requireTag(paletteObject, palettePart, IntTag.class).getValue();
|
||||||
|
|
||||||
IDConverter.BlockTypeID blockID = ids.get(palettePart);
|
IDConverter8.BlockTypeID blockID = ids.get(palettePart);
|
||||||
if(blockID == null){
|
if(blockID == null){
|
||||||
blockID = ids.get(palettePart.split("\\[")[0]);
|
blockID = ids.get(palettePart.split("\\[")[0]);
|
||||||
}
|
}
|
||||||
@ -277,7 +254,6 @@ class Schematic_8 {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@Nullable
|
|
||||||
private static <T extends Tag> T getTag(Map<String, Tag> items, String key, Class<T> expected) {
|
private static <T extends Tag> T getTag(Map<String, Tag> items, String key, Class<T> expected) {
|
||||||
if (!items.containsKey(key)) {
|
if (!items.containsKey(key)) {
|
||||||
return null;
|
return null;
|
@ -17,16 +17,16 @@
|
|||||||
along with this program. If not, see <https://www.gnu.org/licenses/>.
|
along with this program. If not, see <https://www.gnu.org/licenses/>.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
package de.steamwar.message;
|
package de.steamwar.core;
|
||||||
|
|
||||||
import org.bukkit.entity.Player;
|
import org.bukkit.entity.Player;
|
||||||
|
|
||||||
import java.util.Locale;
|
import java.util.Locale;
|
||||||
|
|
||||||
class Message_8 {
|
public class WorldOfColorWrapper8 implements WorldOfColorWrapper.IWorldOfColorWrapper {
|
||||||
private Message_8(){}
|
|
||||||
|
|
||||||
static Locale getLocale(Player player){
|
@Override
|
||||||
|
public Locale getLocale(Player player){
|
||||||
return Locale.forLanguageTag(player.spigot().getLocale());
|
return Locale.forLanguageTag(player.spigot().getLocale());
|
||||||
}
|
}
|
||||||
}
|
}
|
49
SpigotCore_9/build.gradle
Normale Datei
49
SpigotCore_9/build.gradle
Normale Datei
@ -0,0 +1,49 @@
|
|||||||
|
/*
|
||||||
|
* 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 {
|
||||||
|
implementation project(":SpigotCore_Main")
|
||||||
|
|
||||||
|
compileOnly files("${project.rootDir}/lib/Spigot-1.9.jar")
|
||||||
|
}
|
@ -1,59 +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>SpigotCore</artifactId>
|
|
||||||
<version>2.0</version>
|
|
||||||
</parent>
|
|
||||||
|
|
||||||
<properties>
|
|
||||||
<main.basedir>${project.basedir}/..</main.basedir>
|
|
||||||
</properties>
|
|
||||||
|
|
||||||
<artifactId>SpigotCore_9</artifactId>
|
|
||||||
<version>2.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.9</version>
|
|
||||||
<scope>system</scope>
|
|
||||||
<systemPath>${main.basedir}/lib/Spigot-1.9.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>SpigotCore_API</artifactId>
|
|
||||||
<version>2.0</version>
|
|
||||||
</dependency>
|
|
||||||
<dependency>
|
|
||||||
<groupId>steamwar</groupId>
|
|
||||||
<artifactId>SpigotCore_8</artifactId>
|
|
||||||
<version>2.0</version>
|
|
||||||
</dependency>
|
|
||||||
</dependencies>
|
|
||||||
</project>
|
|
20
SpigotCore_9/settings.gradle
Normale Datei
20
SpigotCore_9/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 = 'SpigotCore_9'
|
@ -17,14 +17,22 @@
|
|||||||
along with this program. If not, see <https://www.gnu.org/licenses/>.
|
along with this program. If not, see <https://www.gnu.org/licenses/>.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
package de.steamwar.comms;
|
package de.steamwar.core;
|
||||||
|
|
||||||
|
import net.md_5.bungee.api.ChatMessageType;
|
||||||
|
import net.md_5.bungee.api.chat.BaseComponent;
|
||||||
import org.bukkit.Sound;
|
import org.bukkit.Sound;
|
||||||
import org.bukkit.entity.Player;
|
import org.bukkit.entity.Player;
|
||||||
|
|
||||||
public class BungeeReceiver_9 {
|
public class BountifulWrapper9 implements BountifulWrapper.IBountifulWrapper {
|
||||||
|
|
||||||
public static void playpling(Player player) {
|
@Override
|
||||||
|
public void playPling(Player player) {
|
||||||
player.playSound(player.getLocation(), Sound.ENTITY_EXPERIENCE_ORB_PICKUP, 1, 1);
|
player.playSound(player.getLocation(), Sound.ENTITY_EXPERIENCE_ORB_PICKUP, 1, 1);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void sendMessage(Player player, ChatMessageType type, BaseComponent... msg) {
|
||||||
|
player.spigot().sendMessage(type, msg);
|
||||||
|
}
|
||||||
}
|
}
|
@ -17,17 +17,24 @@
|
|||||||
along with this program. If not, see <https://www.gnu.org/licenses/>.
|
along with this program. If not, see <https://www.gnu.org/licenses/>.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
package de.steamwar.chunk;
|
package de.steamwar.core;
|
||||||
|
|
||||||
|
import net.minecraft.server.v1_9_R2.MinecraftServer;
|
||||||
import net.minecraft.server.v1_9_R2.PacketPlayOutMapChunk;
|
import net.minecraft.server.v1_9_R2.PacketPlayOutMapChunk;
|
||||||
import org.bukkit.craftbukkit.v1_9_R2.CraftChunk;
|
import org.bukkit.craftbukkit.v1_9_R2.CraftChunk;
|
||||||
import org.bukkit.craftbukkit.v1_9_R2.entity.CraftPlayer;
|
import org.bukkit.craftbukkit.v1_9_R2.entity.CraftPlayer;
|
||||||
import org.bukkit.entity.Player;
|
import org.bukkit.entity.Player;
|
||||||
|
|
||||||
public class Chunk_9 {
|
public class CraftbukkitWrapper9 implements CraftbukkitWrapper.ICraftbukkitWrapper {
|
||||||
private Chunk_9(){}
|
|
||||||
|
|
||||||
public static void sendChunk(Player p, int chunkX, int chunkZ){
|
@Override
|
||||||
|
public void sendChunk(Player p, int chunkX, int chunkZ) {
|
||||||
((CraftPlayer)p).getHandle().playerConnection.sendPacket(new PacketPlayOutMapChunk(((CraftChunk)p.getWorld().getChunkAt(chunkX, chunkZ)).getHandle(), 65535));
|
((CraftPlayer)p).getHandle().playerConnection.sendPacket(new PacketPlayOutMapChunk(((CraftChunk)p.getWorld().getChunkAt(chunkX, chunkZ)).getHandle(), 65535));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@SuppressWarnings("deprecation")
|
||||||
|
@Override
|
||||||
|
public double[] getSpigotTPS() {
|
||||||
|
return MinecraftServer.getServer().recentTps;
|
||||||
|
}
|
||||||
}
|
}
|
@ -1,32 +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.core;
|
|
||||||
|
|
||||||
import net.minecraft.server.v1_9_R2.MinecraftServer;
|
|
||||||
|
|
||||||
public class SpigotTPS_9 {
|
|
||||||
|
|
||||||
private SpigotTPS_9(){}
|
|
||||||
|
|
||||||
static double[] getTps(){
|
|
||||||
return MinecraftServer.getServer().recentTps;
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
|
@ -1,32 +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>SpigotCore</artifactId>
|
|
||||||
<version>2.0</version>
|
|
||||||
</parent>
|
|
||||||
|
|
||||||
<properties>
|
|
||||||
<main.basedir>${project.basedir}/..</main.basedir>
|
|
||||||
</properties>
|
|
||||||
|
|
||||||
<artifactId>SpigotCore_API</artifactId>
|
|
||||||
<version>2.0</version>
|
|
||||||
|
|
||||||
<build>
|
|
||||||
<sourceDirectory>src</sourceDirectory>
|
|
||||||
<resources>
|
|
||||||
<resource>
|
|
||||||
<directory>src</directory>
|
|
||||||
<excludes>
|
|
||||||
<exclude>**/*.java</exclude>
|
|
||||||
<exclude>**/*.kt</exclude>
|
|
||||||
</excludes>
|
|
||||||
</resource>
|
|
||||||
</resources>
|
|
||||||
</build>
|
|
||||||
</project>
|
|
55
SpigotCore_Main/build.gradle
Normale Datei
55
SpigotCore_Main/build.gradle
Normale Datei
@ -0,0 +1,55 @@
|
|||||||
|
/*
|
||||||
|
* 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 files("${project.rootDir}/lib/Spigot-1.15.jar")
|
||||||
|
compileOnly files("${project.rootDir}/lib/WorldEdit-1.12.jar")
|
||||||
|
implementation 'net.wesjd:anvilgui:1.4.0-SNAPSHOT'
|
||||||
|
}
|
||||||
|
|
||||||
|
processResources {
|
||||||
|
from("build/classes/java/main/META-INF/annotations/") {
|
||||||
|
into("de.steamwar.bausystem")
|
||||||
|
}
|
||||||
|
}
|
@ -1,128 +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>SpigotCore</artifactId>
|
|
||||||
<version>2.0</version>
|
|
||||||
</parent>
|
|
||||||
|
|
||||||
<properties>
|
|
||||||
<main.basedir>${project.basedir}/..</main.basedir>
|
|
||||||
</properties>
|
|
||||||
|
|
||||||
<repositories>
|
|
||||||
<repository>
|
|
||||||
<id>codemc-snapshots</id>
|
|
||||||
<url>https://repo.codemc.io/repository/maven-snapshots/</url>
|
|
||||||
</repository>
|
|
||||||
</repositories>
|
|
||||||
|
|
||||||
<artifactId>SpigotCore_Main</artifactId>
|
|
||||||
<version>2.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>spigotcore</finalName>
|
|
||||||
</build>
|
|
||||||
|
|
||||||
<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>WorldEdit</artifactId>
|
|
||||||
<version>1.12</version>
|
|
||||||
<scope>system</scope>
|
|
||||||
<systemPath>${main.basedir}/lib/WorldEdit-1.12.jar</systemPath>
|
|
||||||
</dependency>
|
|
||||||
<dependency>
|
|
||||||
<groupId>steamwar</groupId>
|
|
||||||
<artifactId>ProtocolLib</artifactId>
|
|
||||||
<version>1.0</version>
|
|
||||||
<scope>system</scope>
|
|
||||||
<systemPath>${main.basedir}/lib/ProtocolLib.jar</systemPath>
|
|
||||||
</dependency>
|
|
||||||
<dependency>
|
|
||||||
<groupId>net.wesjd</groupId>
|
|
||||||
<artifactId>anvilgui</artifactId>
|
|
||||||
<version>1.4.0-SNAPSHOT</version>
|
|
||||||
<scope>compile</scope>
|
|
||||||
</dependency>
|
|
||||||
<dependency>
|
|
||||||
<groupId>steamwar</groupId>
|
|
||||||
<artifactId>SpigotCore_API</artifactId>
|
|
||||||
<version>2.0</version>
|
|
||||||
<scope>compile</scope>
|
|
||||||
</dependency>
|
|
||||||
<dependency>
|
|
||||||
<groupId>steamwar</groupId>
|
|
||||||
<artifactId>SpigotCore_8</artifactId>
|
|
||||||
<version>2.0</version>
|
|
||||||
<scope>compile</scope>
|
|
||||||
</dependency>
|
|
||||||
<dependency>
|
|
||||||
<groupId>steamwar</groupId>
|
|
||||||
<artifactId>SpigotCore_9</artifactId>
|
|
||||||
<version>2.0</version>
|
|
||||||
<scope>compile</scope>
|
|
||||||
</dependency>
|
|
||||||
<dependency>
|
|
||||||
<groupId>steamwar</groupId>
|
|
||||||
<artifactId>SpigotCore_10</artifactId>
|
|
||||||
<version>2.0</version>
|
|
||||||
<scope>compile</scope>
|
|
||||||
</dependency>
|
|
||||||
<dependency>
|
|
||||||
<groupId>steamwar</groupId>
|
|
||||||
<artifactId>SpigotCore_12</artifactId>
|
|
||||||
<version>2.0</version>
|
|
||||||
<scope>compile</scope>
|
|
||||||
</dependency>
|
|
||||||
<dependency>
|
|
||||||
<groupId>steamwar</groupId>
|
|
||||||
<artifactId>SpigotCore_14</artifactId>
|
|
||||||
<version>2.0</version>
|
|
||||||
<scope>compile</scope>
|
|
||||||
</dependency>
|
|
||||||
<dependency>
|
|
||||||
<groupId>steamwar</groupId>
|
|
||||||
<artifactId>SpigotCore_15</artifactId>
|
|
||||||
<version>2.0</version>
|
|
||||||
<scope>compile</scope>
|
|
||||||
</dependency>
|
|
||||||
</dependencies>
|
|
||||||
</project>
|
|
20
SpigotCore_Main/settings.gradle
Normale Datei
20
SpigotCore_Main/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 = 'SpigotCore_Main'
|
411
SpigotCore_Main/src/com/comphenix/tinyprotocol/Reflection.java
Normale Datei
411
SpigotCore_Main/src/com/comphenix/tinyprotocol/Reflection.java
Normale Datei
@ -0,0 +1,411 @@
|
|||||||
|
package com.comphenix.tinyprotocol;
|
||||||
|
|
||||||
|
import org.bukkit.Bukkit;
|
||||||
|
|
||||||
|
import java.lang.reflect.Constructor;
|
||||||
|
import java.lang.reflect.Field;
|
||||||
|
import java.lang.reflect.Method;
|
||||||
|
import java.util.Arrays;
|
||||||
|
import java.util.regex.Matcher;
|
||||||
|
import java.util.regex.Pattern;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* An utility class that simplifies reflection in Bukkit plugins.
|
||||||
|
*
|
||||||
|
* @author Kristian
|
||||||
|
*/
|
||||||
|
public final class Reflection {
|
||||||
|
/**
|
||||||
|
* An interface for invoking a specific constructor.
|
||||||
|
*/
|
||||||
|
public interface ConstructorInvoker {
|
||||||
|
/**
|
||||||
|
* Invoke a constructor for a specific class.
|
||||||
|
*
|
||||||
|
* @param arguments - the arguments to pass to the constructor.
|
||||||
|
* @return The constructed object.
|
||||||
|
*/
|
||||||
|
public Object invoke(Object... arguments);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* An interface for invoking a specific method.
|
||||||
|
*/
|
||||||
|
public interface MethodInvoker {
|
||||||
|
/**
|
||||||
|
* Invoke a method on a specific target object.
|
||||||
|
*
|
||||||
|
* @param target - the target object, or NULL for a static method.
|
||||||
|
* @param arguments - the arguments to pass to the method.
|
||||||
|
* @return The return value, or NULL if is void.
|
||||||
|
*/
|
||||||
|
public Object invoke(Object target, Object... arguments);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* An interface for retrieving the field content.
|
||||||
|
*
|
||||||
|
* @param <T> - field type.
|
||||||
|
*/
|
||||||
|
public interface FieldAccessor<T> {
|
||||||
|
/**
|
||||||
|
* Retrieve the content of a field.
|
||||||
|
*
|
||||||
|
* @param target - the target object, or NULL for a static field.
|
||||||
|
* @return The value of the field.
|
||||||
|
*/
|
||||||
|
public T get(Object target);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Set the content of a field.
|
||||||
|
*
|
||||||
|
* @param target - the target object, or NULL for a static field.
|
||||||
|
* @param value - the new value of the field.
|
||||||
|
*/
|
||||||
|
public void set(Object target, Object value);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Determine if the given object has this field.
|
||||||
|
*
|
||||||
|
* @param target - the object to test.
|
||||||
|
* @return TRUE if it does, FALSE otherwise.
|
||||||
|
*/
|
||||||
|
public boolean hasField(Object target);
|
||||||
|
}
|
||||||
|
|
||||||
|
// Deduce the net.minecraft.server.v* package
|
||||||
|
private static String OBC_PREFIX = Bukkit.getServer().getClass().getPackage().getName();
|
||||||
|
private static String NMS_PREFIX = OBC_PREFIX.replace("org.bukkit.craftbukkit", "net.minecraft.server");
|
||||||
|
private static String VERSION = OBC_PREFIX.replace("org.bukkit.craftbukkit", "").replace(".", "");
|
||||||
|
|
||||||
|
// Variable replacement
|
||||||
|
private static Pattern MATCH_VARIABLE = Pattern.compile("\\{([^\\}]+)\\}");
|
||||||
|
|
||||||
|
private Reflection() {
|
||||||
|
// Seal class
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Retrieve a field accessor for a specific field type and name.
|
||||||
|
*
|
||||||
|
* @param target - the target type.
|
||||||
|
* @param name - the name of the field, or NULL to ignore.
|
||||||
|
* @param fieldType - a compatible field type.
|
||||||
|
* @return The field accessor.
|
||||||
|
*/
|
||||||
|
public static <T> FieldAccessor<T> getField(Class<?> target, String name, Class<T> fieldType) {
|
||||||
|
return getField(target, name, fieldType, 0);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Retrieve a field accessor for a specific field type and name.
|
||||||
|
*
|
||||||
|
* @param className - lookup name of the class, see {@link #getClass(String)}.
|
||||||
|
* @param name - the name of the field, or NULL to ignore.
|
||||||
|
* @param fieldType - a compatible field type.
|
||||||
|
* @return The field accessor.
|
||||||
|
*/
|
||||||
|
public static <T> FieldAccessor<T> getField(String className, String name, Class<T> fieldType) {
|
||||||
|
return getField(getClass(className), name, fieldType, 0);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Retrieve a field accessor for a specific field type and name.
|
||||||
|
*
|
||||||
|
* @param target - the target type.
|
||||||
|
* @param fieldType - a compatible field type.
|
||||||
|
* @param index - the number of compatible fields to skip.
|
||||||
|
* @return The field accessor.
|
||||||
|
*/
|
||||||
|
public static <T> FieldAccessor<T> getField(Class<?> target, Class<T> fieldType, int index) {
|
||||||
|
return getField(target, null, fieldType, index);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Retrieve a field accessor for a specific field type and name.
|
||||||
|
*
|
||||||
|
* @param className - lookup name of the class, see {@link #getClass(String)}.
|
||||||
|
* @param fieldType - a compatible field type.
|
||||||
|
* @param index - the number of compatible fields to skip.
|
||||||
|
* @return The field accessor.
|
||||||
|
*/
|
||||||
|
public static <T> FieldAccessor<T> getField(String className, Class<T> fieldType, int index) {
|
||||||
|
return getField(getClass(className), fieldType, index);
|
||||||
|
}
|
||||||
|
|
||||||
|
// Common method
|
||||||
|
private static <T> FieldAccessor<T> getField(Class<?> target, String name, Class<T> fieldType, int index) {
|
||||||
|
for (final Field field : target.getDeclaredFields()) {
|
||||||
|
if ((name == null || field.getName().equals(name)) && fieldType.isAssignableFrom(field.getType()) && index-- <= 0) {
|
||||||
|
field.setAccessible(true);
|
||||||
|
|
||||||
|
// A function for retrieving a specific field value
|
||||||
|
return new FieldAccessor<T>() {
|
||||||
|
|
||||||
|
@Override
|
||||||
|
@SuppressWarnings("unchecked")
|
||||||
|
public T get(Object target) {
|
||||||
|
try {
|
||||||
|
return (T) field.get(target);
|
||||||
|
} catch (IllegalAccessException e) {
|
||||||
|
throw new RuntimeException("Cannot access reflection.", e);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void set(Object target, Object value) {
|
||||||
|
try {
|
||||||
|
field.set(target, value);
|
||||||
|
} catch (IllegalAccessException e) {
|
||||||
|
throw new RuntimeException("Cannot access reflection.", e);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public boolean hasField(Object target) {
|
||||||
|
// target instanceof DeclaringClass
|
||||||
|
return field.getDeclaringClass().isAssignableFrom(target.getClass());
|
||||||
|
}
|
||||||
|
};
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// Search in parent classes
|
||||||
|
if (target.getSuperclass() != null)
|
||||||
|
return getField(target.getSuperclass(), name, fieldType, index);
|
||||||
|
|
||||||
|
throw new IllegalArgumentException("Cannot find field with type " + fieldType);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Search for the first publicly and privately defined method of the given name and parameter count.
|
||||||
|
*
|
||||||
|
* @param className - lookup name of the class, see {@link #getClass(String)}.
|
||||||
|
* @param methodName - the method name, or NULL to skip.
|
||||||
|
* @param params - the expected parameters.
|
||||||
|
* @return An object that invokes this specific method.
|
||||||
|
* @throws IllegalStateException If we cannot find this method.
|
||||||
|
*/
|
||||||
|
public static MethodInvoker getMethod(String className, String methodName, Class<?>... params) {
|
||||||
|
return getTypedMethod(getClass(className), methodName, null, params);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Search for the first publicly and privately defined method of the given name and parameter count.
|
||||||
|
*
|
||||||
|
* @param clazz - a class to start with.
|
||||||
|
* @param methodName - the method name, or NULL to skip.
|
||||||
|
* @param params - the expected parameters.
|
||||||
|
* @return An object that invokes this specific method.
|
||||||
|
* @throws IllegalStateException If we cannot find this method.
|
||||||
|
*/
|
||||||
|
public static MethodInvoker getMethod(Class<?> clazz, String methodName, Class<?>... params) {
|
||||||
|
return getTypedMethod(clazz, methodName, null, params);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Search for the first publicly and privately defined method of the given name and parameter count.
|
||||||
|
*
|
||||||
|
* @param clazz - a class to start with.
|
||||||
|
* @param methodName - the method name, or NULL to skip.
|
||||||
|
* @param returnType - the expected return type, or NULL to ignore.
|
||||||
|
* @param params - the expected parameters.
|
||||||
|
* @return An object that invokes this specific method.
|
||||||
|
* @throws IllegalStateException If we cannot find this method.
|
||||||
|
*/
|
||||||
|
public static MethodInvoker getTypedMethod(Class<?> clazz, String methodName, Class<?> returnType, Class<?>... params) {
|
||||||
|
for (final Method method : clazz.getDeclaredMethods()) {
|
||||||
|
if ((methodName == null || method.getName().equals(methodName))
|
||||||
|
&& (returnType == null || method.getReturnType().equals(returnType))
|
||||||
|
&& Arrays.equals(method.getParameterTypes(), params)) {
|
||||||
|
method.setAccessible(true);
|
||||||
|
|
||||||
|
return new MethodInvoker() {
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public Object invoke(Object target, Object... arguments) {
|
||||||
|
try {
|
||||||
|
return method.invoke(target, arguments);
|
||||||
|
} catch (Exception e) {
|
||||||
|
throw new RuntimeException("Cannot invoke method " + method, e);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
};
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// Search in every superclass
|
||||||
|
if (clazz.getSuperclass() != null)
|
||||||
|
return getMethod(clazz.getSuperclass(), methodName, params);
|
||||||
|
|
||||||
|
throw new IllegalStateException(String.format("Unable to find method %s (%s).", methodName, Arrays.asList(params)));
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Search for the first publically and privately defined constructor of the given name and parameter count.
|
||||||
|
*
|
||||||
|
* @param className - lookup name of the class, see {@link #getClass(String)}.
|
||||||
|
* @param params - the expected parameters.
|
||||||
|
* @return An object that invokes this constructor.
|
||||||
|
* @throws IllegalStateException If we cannot find this method.
|
||||||
|
*/
|
||||||
|
public static ConstructorInvoker getConstructor(String className, Class<?>... params) {
|
||||||
|
return getConstructor(getClass(className), params);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Search for the first publically and privately defined constructor of the given name and parameter count.
|
||||||
|
*
|
||||||
|
* @param clazz - a class to start with.
|
||||||
|
* @param params - the expected parameters.
|
||||||
|
* @return An object that invokes this constructor.
|
||||||
|
* @throws IllegalStateException If we cannot find this method.
|
||||||
|
*/
|
||||||
|
public static ConstructorInvoker getConstructor(Class<?> clazz, Class<?>... params) {
|
||||||
|
for (final Constructor<?> constructor : clazz.getDeclaredConstructors()) {
|
||||||
|
if (Arrays.equals(constructor.getParameterTypes(), params)) {
|
||||||
|
constructor.setAccessible(true);
|
||||||
|
|
||||||
|
return new ConstructorInvoker() {
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public Object invoke(Object... arguments) {
|
||||||
|
try {
|
||||||
|
return constructor.newInstance(arguments);
|
||||||
|
} catch (Exception e) {
|
||||||
|
throw new RuntimeException("Cannot invoke constructor " + constructor, e);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
};
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
throw new IllegalStateException(String.format("Unable to find constructor for %s (%s).", clazz, Arrays.asList(params)));
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Retrieve a class from its full name, without knowing its type on compile time.
|
||||||
|
* <p>
|
||||||
|
* This is useful when looking up fields by a NMS or OBC type.
|
||||||
|
* <p>
|
||||||
|
*
|
||||||
|
* @see {@link #getClass()} for more information.
|
||||||
|
* @param lookupName - the class name with variables.
|
||||||
|
* @return The class.
|
||||||
|
*/
|
||||||
|
public static Class<Object> getUntypedClass(String lookupName) {
|
||||||
|
@SuppressWarnings({ "rawtypes", "unchecked" })
|
||||||
|
Class<Object> clazz = (Class) getClass(lookupName);
|
||||||
|
return clazz;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Retrieve a class from its full name.
|
||||||
|
* <p>
|
||||||
|
* Strings enclosed with curly brackets - such as {TEXT} - will be replaced according to the following table:
|
||||||
|
* <p>
|
||||||
|
* <table border="1">
|
||||||
|
* <tr>
|
||||||
|
* <th>Variable</th>
|
||||||
|
* <th>Content</th>
|
||||||
|
* </tr>
|
||||||
|
* <tr>
|
||||||
|
* <td>{nms}</td>
|
||||||
|
* <td>Actual package name of net.minecraft.server.VERSION</td>
|
||||||
|
* </tr>
|
||||||
|
* <tr>
|
||||||
|
* <td>{obc}</td>
|
||||||
|
* <td>Actual pacakge name of org.bukkit.craftbukkit.VERSION</td>
|
||||||
|
* </tr>
|
||||||
|
* <tr>
|
||||||
|
* <td>{version}</td>
|
||||||
|
* <td>The current Minecraft package VERSION, if any.</td>
|
||||||
|
* </tr>
|
||||||
|
* </table>
|
||||||
|
*
|
||||||
|
* @param lookupName - the class name with variables.
|
||||||
|
* @return The looked up class.
|
||||||
|
* @throws IllegalArgumentException If a variable or class could not be found.
|
||||||
|
*/
|
||||||
|
public static Class<?> getClass(String lookupName) {
|
||||||
|
return getCanonicalClass(expandVariables(lookupName));
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Retrieve a class in the net.minecraft.server.VERSION.* package.
|
||||||
|
*
|
||||||
|
* @param name - the name of the class, excluding the package.
|
||||||
|
* @throws IllegalArgumentException If the class doesn't exist.
|
||||||
|
*/
|
||||||
|
public static Class<?> getMinecraftClass(String name) {
|
||||||
|
return getCanonicalClass(NMS_PREFIX + "." + name);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Retrieve a class in the org.bukkit.craftbukkit.VERSION.* package.
|
||||||
|
*
|
||||||
|
* @param name - the name of the class, excluding the package.
|
||||||
|
* @throws IllegalArgumentException If the class doesn't exist.
|
||||||
|
*/
|
||||||
|
public static Class<?> getCraftBukkitClass(String name) {
|
||||||
|
return getCanonicalClass(OBC_PREFIX + "." + name);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Retrieve a class by its canonical name.
|
||||||
|
*
|
||||||
|
* @param canonicalName - the canonical name.
|
||||||
|
* @return The class.
|
||||||
|
*/
|
||||||
|
private static Class<?> getCanonicalClass(String canonicalName) {
|
||||||
|
try {
|
||||||
|
return Class.forName(canonicalName);
|
||||||
|
} catch (ClassNotFoundException e) {
|
||||||
|
throw new IllegalArgumentException("Cannot find " + canonicalName, e);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Expand variables such as "{nms}" and "{obc}" to their corresponding packages.
|
||||||
|
*
|
||||||
|
* @param name - the full name of the class.
|
||||||
|
* @return The expanded string.
|
||||||
|
*/
|
||||||
|
private static String expandVariables(String name) {
|
||||||
|
StringBuffer output = new StringBuffer();
|
||||||
|
Matcher matcher = MATCH_VARIABLE.matcher(name);
|
||||||
|
|
||||||
|
while (matcher.find()) {
|
||||||
|
String variable = matcher.group(1);
|
||||||
|
String replacement = "";
|
||||||
|
|
||||||
|
// Expand all detected variables
|
||||||
|
if ("nms".equalsIgnoreCase(variable))
|
||||||
|
replacement = NMS_PREFIX;
|
||||||
|
else if ("obc".equalsIgnoreCase(variable))
|
||||||
|
replacement = OBC_PREFIX;
|
||||||
|
else if ("version".equalsIgnoreCase(variable))
|
||||||
|
replacement = VERSION;
|
||||||
|
else
|
||||||
|
throw new IllegalArgumentException("Unknown variable: " + variable);
|
||||||
|
|
||||||
|
// Assume the expanded variables are all packages, and append a dot
|
||||||
|
if (replacement.length() > 0 && matcher.end() < name.length() && name.charAt(matcher.end()) != '.')
|
||||||
|
replacement += ".";
|
||||||
|
matcher.appendReplacement(output, Matcher.quoteReplacement(replacement));
|
||||||
|
}
|
||||||
|
|
||||||
|
matcher.appendTail(output);
|
||||||
|
return output.toString();
|
||||||
|
}
|
||||||
|
|
||||||
|
public static Object newInstance(Class<?> clazz) {
|
||||||
|
try {
|
||||||
|
return clazz.newInstance();
|
||||||
|
} catch (InstantiationException | IllegalAccessException e) {
|
||||||
|
throw new SecurityException("Could not create object", e);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
518
SpigotCore_Main/src/com/comphenix/tinyprotocol/TinyProtocol.java
Normale Datei
518
SpigotCore_Main/src/com/comphenix/tinyprotocol/TinyProtocol.java
Normale Datei
@ -0,0 +1,518 @@
|
|||||||
|
package com.comphenix.tinyprotocol;
|
||||||
|
|
||||||
|
import com.comphenix.tinyprotocol.Reflection.FieldAccessor;
|
||||||
|
import com.comphenix.tinyprotocol.Reflection.MethodInvoker;
|
||||||
|
import com.google.common.collect.Lists;
|
||||||
|
import com.google.common.collect.MapMaker;
|
||||||
|
import com.mojang.authlib.GameProfile;
|
||||||
|
import io.netty.channel.*;
|
||||||
|
import org.bukkit.Bukkit;
|
||||||
|
import org.bukkit.entity.Player;
|
||||||
|
import org.bukkit.event.EventHandler;
|
||||||
|
import org.bukkit.event.EventPriority;
|
||||||
|
import org.bukkit.event.HandlerList;
|
||||||
|
import org.bukkit.event.Listener;
|
||||||
|
import org.bukkit.event.player.PlayerLoginEvent;
|
||||||
|
import org.bukkit.event.server.PluginDisableEvent;
|
||||||
|
import org.bukkit.plugin.Plugin;
|
||||||
|
import org.bukkit.scheduler.BukkitRunnable;
|
||||||
|
|
||||||
|
import java.util.*;
|
||||||
|
import java.util.concurrent.atomic.AtomicInteger;
|
||||||
|
import java.util.logging.Level;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Represents a very tiny alternative to ProtocolLib.
|
||||||
|
* <p>
|
||||||
|
* It now supports intercepting packets during login and status ping (such as OUT_SERVER_PING)!
|
||||||
|
*
|
||||||
|
* @author Kristian
|
||||||
|
*/
|
||||||
|
public abstract class TinyProtocol {
|
||||||
|
private static final AtomicInteger ID = new AtomicInteger(0);
|
||||||
|
|
||||||
|
// Used in order to lookup a channel
|
||||||
|
private static final MethodInvoker getPlayerHandle = Reflection.getMethod("{obc}.entity.CraftPlayer", "getHandle");
|
||||||
|
private static final FieldAccessor<Object> getConnection = Reflection.getField("{nms}.EntityPlayer", "playerConnection", Object.class);
|
||||||
|
private static final FieldAccessor<Object> getManager = Reflection.getField("{nms}.PlayerConnection", "networkManager", Object.class);
|
||||||
|
private static final FieldAccessor<Channel> getChannel = Reflection.getField("{nms}.NetworkManager", Channel.class, 0);
|
||||||
|
|
||||||
|
// Looking up ServerConnection
|
||||||
|
private static final Class<Object> minecraftServerClass = Reflection.getUntypedClass("{nms}.MinecraftServer");
|
||||||
|
private static final Class<Object> serverConnectionClass = Reflection.getUntypedClass("{nms}.ServerConnection");
|
||||||
|
private static final FieldAccessor<Object> getMinecraftServer = Reflection.getField("{obc}.CraftServer", minecraftServerClass, 0);
|
||||||
|
private static final FieldAccessor<Object> getServerConnection = Reflection.getField(minecraftServerClass, serverConnectionClass, 0);
|
||||||
|
private static final MethodInvoker getNetworkMarkers;
|
||||||
|
static {
|
||||||
|
MethodInvoker networkMarkers;
|
||||||
|
try {
|
||||||
|
networkMarkers = Reflection.getTypedMethod(serverConnectionClass, null, List.class, serverConnectionClass);
|
||||||
|
} catch (IllegalStateException e) { // Paper, wtf why.
|
||||||
|
networkMarkers = Reflection.getTypedMethod(serverConnectionClass, null, Queue.class, serverConnectionClass);
|
||||||
|
}
|
||||||
|
getNetworkMarkers = networkMarkers;
|
||||||
|
}
|
||||||
|
|
||||||
|
// Packets we have to intercept
|
||||||
|
private static final Class<?> PACKET_LOGIN_IN_START = Reflection.getMinecraftClass("PacketLoginInStart");
|
||||||
|
private static final FieldAccessor<GameProfile> getGameProfile = Reflection.getField(PACKET_LOGIN_IN_START, GameProfile.class, 0);
|
||||||
|
|
||||||
|
// Speedup channel lookup
|
||||||
|
private Map<String, Channel> channelLookup = new MapMaker().weakValues().makeMap();
|
||||||
|
private Listener listener;
|
||||||
|
|
||||||
|
// Channels that have already been removed
|
||||||
|
private Set<Channel> uninjectedChannels = Collections.newSetFromMap(new MapMaker().weakKeys().<Channel, Boolean>makeMap());
|
||||||
|
|
||||||
|
// List of network markers
|
||||||
|
private Collection<Object> networkManagers;
|
||||||
|
|
||||||
|
// Injected channel handlers
|
||||||
|
private List<Channel> serverChannels = Lists.newArrayList();
|
||||||
|
private ChannelInboundHandlerAdapter serverChannelHandler;
|
||||||
|
private ChannelInitializer<Channel> beginInitProtocol;
|
||||||
|
private ChannelInitializer<Channel> endInitProtocol;
|
||||||
|
|
||||||
|
// Current handler name
|
||||||
|
private String handlerName;
|
||||||
|
|
||||||
|
protected volatile boolean closed;
|
||||||
|
protected Plugin plugin;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Construct a new instance of TinyProtocol, and start intercepting packets for all connected clients and future clients.
|
||||||
|
* <p>
|
||||||
|
* You can construct multiple instances per plugin.
|
||||||
|
*
|
||||||
|
* @param plugin - the plugin.
|
||||||
|
*/
|
||||||
|
public TinyProtocol(final Plugin plugin) {
|
||||||
|
this.plugin = plugin;
|
||||||
|
|
||||||
|
// Compute handler name
|
||||||
|
this.handlerName = getHandlerName();
|
||||||
|
|
||||||
|
// Prepare existing players
|
||||||
|
registerBukkitEvents();
|
||||||
|
|
||||||
|
try {
|
||||||
|
registerChannelHandler();
|
||||||
|
registerPlayers(plugin);
|
||||||
|
} catch (IllegalArgumentException ex) {
|
||||||
|
// Damn you, late bind
|
||||||
|
plugin.getLogger().info("[TinyProtocol] Delaying server channel injection due to late bind.");
|
||||||
|
|
||||||
|
new BukkitRunnable() {
|
||||||
|
@Override
|
||||||
|
public void run() {
|
||||||
|
registerChannelHandler();
|
||||||
|
registerPlayers(plugin);
|
||||||
|
plugin.getLogger().info("[TinyProtocol] Late bind injection successful.");
|
||||||
|
}
|
||||||
|
}.runTask(plugin);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
private void createServerChannelHandler() {
|
||||||
|
// Handle connected channels
|
||||||
|
endInitProtocol = new ChannelInitializer<Channel>() {
|
||||||
|
|
||||||
|
@Override
|
||||||
|
protected void initChannel(Channel channel) throws Exception {
|
||||||
|
try {
|
||||||
|
// This can take a while, so we need to stop the main thread from interfering
|
||||||
|
synchronized (networkManagers) {
|
||||||
|
// Stop injecting channels
|
||||||
|
if (!closed) {
|
||||||
|
channel.eventLoop().submit(() -> injectChannelInternal(channel));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
} catch (Exception e) {
|
||||||
|
plugin.getLogger().log(Level.SEVERE, "Cannot inject incomming channel " + channel, e);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
};
|
||||||
|
|
||||||
|
// This is executed before Minecraft's channel handler
|
||||||
|
beginInitProtocol = new ChannelInitializer<Channel>() {
|
||||||
|
|
||||||
|
@Override
|
||||||
|
protected void initChannel(Channel channel) throws Exception {
|
||||||
|
channel.pipeline().addLast(endInitProtocol);
|
||||||
|
}
|
||||||
|
|
||||||
|
};
|
||||||
|
|
||||||
|
serverChannelHandler = new ChannelInboundHandlerAdapter() {
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void channelRead(ChannelHandlerContext ctx, Object msg) throws Exception {
|
||||||
|
Channel channel = (Channel) msg;
|
||||||
|
|
||||||
|
// Prepare to initialize ths channel
|
||||||
|
channel.pipeline().addFirst(beginInitProtocol);
|
||||||
|
ctx.fireChannelRead(msg);
|
||||||
|
}
|
||||||
|
|
||||||
|
};
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Register bukkit events.
|
||||||
|
*/
|
||||||
|
private void registerBukkitEvents() {
|
||||||
|
listener = new Listener() {
|
||||||
|
|
||||||
|
@EventHandler(priority = EventPriority.LOWEST)
|
||||||
|
public final void onPlayerLogin(PlayerLoginEvent e) {
|
||||||
|
if (closed)
|
||||||
|
return;
|
||||||
|
|
||||||
|
Channel channel = getChannel(e.getPlayer());
|
||||||
|
|
||||||
|
// Don't inject players that have been explicitly uninjected
|
||||||
|
if (!uninjectedChannels.contains(channel)) {
|
||||||
|
injectPlayer(e.getPlayer());
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
@EventHandler
|
||||||
|
public final void onPluginDisable(PluginDisableEvent e) {
|
||||||
|
if (e.getPlugin().equals(plugin)) {
|
||||||
|
close();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
};
|
||||||
|
|
||||||
|
plugin.getServer().getPluginManager().registerEvents(listener, plugin);
|
||||||
|
}
|
||||||
|
|
||||||
|
@SuppressWarnings("unchecked")
|
||||||
|
private void registerChannelHandler() {
|
||||||
|
Object mcServer = getMinecraftServer.get(Bukkit.getServer());
|
||||||
|
Object serverConnection = getServerConnection.get(mcServer);
|
||||||
|
boolean looking = true;
|
||||||
|
|
||||||
|
// We need to synchronize against this list
|
||||||
|
networkManagers = (Collection<Object>) getNetworkMarkers.invoke(null, serverConnection);
|
||||||
|
createServerChannelHandler();
|
||||||
|
|
||||||
|
// Find the correct list, or implicitly throw an exception
|
||||||
|
for (int i = 0; looking; i++) {
|
||||||
|
List<Object> list = Reflection.getField(serverConnection.getClass(), List.class, i).get(serverConnection);
|
||||||
|
|
||||||
|
for (Object item : list) {
|
||||||
|
if (!ChannelFuture.class.isInstance(item))
|
||||||
|
break;
|
||||||
|
|
||||||
|
// Channel future that contains the server connection
|
||||||
|
Channel serverChannel = ((ChannelFuture) item).channel();
|
||||||
|
|
||||||
|
serverChannels.add(serverChannel);
|
||||||
|
serverChannel.pipeline().addFirst(serverChannelHandler);
|
||||||
|
looking = false;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
private void unregisterChannelHandler() {
|
||||||
|
if (serverChannelHandler == null)
|
||||||
|
return;
|
||||||
|
|
||||||
|
for (Channel serverChannel : serverChannels) {
|
||||||
|
final ChannelPipeline pipeline = serverChannel.pipeline();
|
||||||
|
|
||||||
|
// Remove channel handler
|
||||||
|
serverChannel.eventLoop().execute(new Runnable() {
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void run() {
|
||||||
|
try {
|
||||||
|
pipeline.remove(serverChannelHandler);
|
||||||
|
} catch (NoSuchElementException e) {
|
||||||
|
// That's fine
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
});
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
private void registerPlayers(Plugin plugin) {
|
||||||
|
for (Player player : plugin.getServer().getOnlinePlayers()) {
|
||||||
|
injectPlayer(player);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Invoked when the server is starting to send a packet to a player.
|
||||||
|
* <p>
|
||||||
|
* Note that this is not executed on the main thread.
|
||||||
|
*
|
||||||
|
* @param receiver - the receiving player, NULL for early login/status packets.
|
||||||
|
* @param channel - the channel that received the packet. Never NULL.
|
||||||
|
* @param packet - the packet being sent.
|
||||||
|
* @return The packet to send instead, or NULL to cancel the transmission.
|
||||||
|
*/
|
||||||
|
public Object onPacketOutAsync(Player receiver, Channel channel, Object packet) {
|
||||||
|
return packet;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Invoked when the server has received a packet from a given player.
|
||||||
|
* <p>
|
||||||
|
* Use {@link Channel#remoteAddress()} to get the remote address of the client.
|
||||||
|
*
|
||||||
|
* @param sender - the player that sent the packet, NULL for early login/status packets.
|
||||||
|
* @param channel - channel that received the packet. Never NULL.
|
||||||
|
* @param packet - the packet being received.
|
||||||
|
* @return The packet to recieve instead, or NULL to cancel.
|
||||||
|
*/
|
||||||
|
public Object onPacketInAsync(Player sender, Channel channel, Object packet) {
|
||||||
|
return packet;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Send a packet to a particular player.
|
||||||
|
* <p>
|
||||||
|
* Note that {@link #onPacketOutAsync(Player, Channel, Object)} will be invoked with this packet.
|
||||||
|
*
|
||||||
|
* @param player - the destination player.
|
||||||
|
* @param packet - the packet to send.
|
||||||
|
*/
|
||||||
|
public void sendPacket(Player player, Object packet) {
|
||||||
|
sendPacket(getChannel(player), packet);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Send a packet to a particular client.
|
||||||
|
* <p>
|
||||||
|
* Note that {@link #onPacketOutAsync(Player, Channel, Object)} will be invoked with this packet.
|
||||||
|
*
|
||||||
|
* @param channel - client identified by a channel.
|
||||||
|
* @param packet - the packet to send.
|
||||||
|
*/
|
||||||
|
public void sendPacket(Channel channel, Object packet) {
|
||||||
|
channel.pipeline().writeAndFlush(packet);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Pretend that a given packet has been received from a player.
|
||||||
|
* <p>
|
||||||
|
* Note that {@link #onPacketInAsync(Player, Channel, Object)} will be invoked with this packet.
|
||||||
|
*
|
||||||
|
* @param player - the player that sent the packet.
|
||||||
|
* @param packet - the packet that will be received by the server.
|
||||||
|
*/
|
||||||
|
public void receivePacket(Player player, Object packet) {
|
||||||
|
receivePacket(getChannel(player), packet);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Pretend that a given packet has been received from a given client.
|
||||||
|
* <p>
|
||||||
|
* Note that {@link #onPacketInAsync(Player, Channel, Object)} will be invoked with this packet.
|
||||||
|
*
|
||||||
|
* @param channel - client identified by a channel.
|
||||||
|
* @param packet - the packet that will be received by the server.
|
||||||
|
*/
|
||||||
|
public void receivePacket(Channel channel, Object packet) {
|
||||||
|
channel.pipeline().context("encoder").fireChannelRead(packet);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Retrieve the name of the channel injector, default implementation is "tiny-" + plugin name + "-" + a unique ID.
|
||||||
|
* <p>
|
||||||
|
* Note that this method will only be invoked once. It is no longer necessary to override this to support multiple instances.
|
||||||
|
*
|
||||||
|
* @return A unique channel handler name.
|
||||||
|
*/
|
||||||
|
protected String getHandlerName() {
|
||||||
|
return "tiny-" + plugin.getName() + "-" + ID.incrementAndGet();
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Add a custom channel handler to the given player's channel pipeline, allowing us to intercept sent and received packets.
|
||||||
|
* <p>
|
||||||
|
* This will automatically be called when a player has logged in.
|
||||||
|
*
|
||||||
|
* @param player - the player to inject.
|
||||||
|
*/
|
||||||
|
public void injectPlayer(Player player) {
|
||||||
|
injectChannelInternal(getChannel(player)).player = player;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Add a custom channel handler to the given channel.
|
||||||
|
*
|
||||||
|
* @param channel - the channel to inject.
|
||||||
|
* @return The intercepted channel, or NULL if it has already been injected.
|
||||||
|
*/
|
||||||
|
public void injectChannel(Channel channel) {
|
||||||
|
injectChannelInternal(channel);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Add a custom channel handler to the given channel.
|
||||||
|
*
|
||||||
|
* @param channel - the channel to inject.
|
||||||
|
* @return The packet interceptor.
|
||||||
|
*/
|
||||||
|
private PacketInterceptor injectChannelInternal(Channel channel) {
|
||||||
|
try {
|
||||||
|
PacketInterceptor interceptor = (PacketInterceptor) channel.pipeline().get(handlerName);
|
||||||
|
|
||||||
|
// Inject our packet interceptor
|
||||||
|
if (interceptor == null) {
|
||||||
|
interceptor = new PacketInterceptor();
|
||||||
|
channel.pipeline().addBefore("packet_handler", handlerName, interceptor);
|
||||||
|
uninjectedChannels.remove(channel);
|
||||||
|
}
|
||||||
|
|
||||||
|
return interceptor;
|
||||||
|
} catch (IllegalArgumentException e) {
|
||||||
|
// Try again
|
||||||
|
return (PacketInterceptor) channel.pipeline().get(handlerName);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Retrieve the Netty channel associated with a player. This is cached.
|
||||||
|
*
|
||||||
|
* @param player - the player.
|
||||||
|
* @return The Netty channel.
|
||||||
|
*/
|
||||||
|
public Channel getChannel(Player player) {
|
||||||
|
Channel channel = channelLookup.get(player.getName());
|
||||||
|
|
||||||
|
// Lookup channel again
|
||||||
|
if (channel == null) {
|
||||||
|
Object connection = getConnection.get(getPlayerHandle.invoke(player));
|
||||||
|
Object manager = getManager.get(connection);
|
||||||
|
|
||||||
|
channelLookup.put(player.getName(), channel = getChannel.get(manager));
|
||||||
|
}
|
||||||
|
|
||||||
|
return channel;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Uninject a specific player.
|
||||||
|
*
|
||||||
|
* @param player - the injected player.
|
||||||
|
*/
|
||||||
|
public void uninjectPlayer(Player player) {
|
||||||
|
uninjectChannel(getChannel(player));
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Uninject a specific channel.
|
||||||
|
* <p>
|
||||||
|
* This will also disable the automatic channel injection that occurs when a player has properly logged in.
|
||||||
|
*
|
||||||
|
* @param channel - the injected channel.
|
||||||
|
*/
|
||||||
|
public void uninjectChannel(final Channel channel) {
|
||||||
|
// No need to guard against this if we're closing
|
||||||
|
if (!closed) {
|
||||||
|
uninjectedChannels.add(channel);
|
||||||
|
}
|
||||||
|
|
||||||
|
// See ChannelInjector in ProtocolLib, line 590
|
||||||
|
channel.eventLoop().execute(new Runnable() {
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void run() {
|
||||||
|
channel.pipeline().remove(handlerName);
|
||||||
|
}
|
||||||
|
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Determine if the given player has been injected by TinyProtocol.
|
||||||
|
*
|
||||||
|
* @param player - the player.
|
||||||
|
* @return TRUE if it is, FALSE otherwise.
|
||||||
|
*/
|
||||||
|
public boolean hasInjected(Player player) {
|
||||||
|
return hasInjected(getChannel(player));
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Determine if the given channel has been injected by TinyProtocol.
|
||||||
|
*
|
||||||
|
* @param channel - the channel.
|
||||||
|
* @return TRUE if it is, FALSE otherwise.
|
||||||
|
*/
|
||||||
|
public boolean hasInjected(Channel channel) {
|
||||||
|
return channel.pipeline().get(handlerName) != null;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Cease listening for packets. This is called automatically when your plugin is disabled.
|
||||||
|
*/
|
||||||
|
public final void close() {
|
||||||
|
if (!closed) {
|
||||||
|
closed = true;
|
||||||
|
|
||||||
|
// Remove our handlers
|
||||||
|
for (Player player : plugin.getServer().getOnlinePlayers()) {
|
||||||
|
uninjectPlayer(player);
|
||||||
|
}
|
||||||
|
|
||||||
|
// Clean up Bukkit
|
||||||
|
HandlerList.unregisterAll(listener);
|
||||||
|
unregisterChannelHandler();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Channel handler that is inserted into the player's channel pipeline, allowing us to intercept sent and received packets.
|
||||||
|
*
|
||||||
|
* @author Kristian
|
||||||
|
*/
|
||||||
|
private final class PacketInterceptor extends ChannelDuplexHandler {
|
||||||
|
// Updated by the login event
|
||||||
|
public volatile Player player;
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void channelRead(ChannelHandlerContext ctx, Object msg) throws Exception {
|
||||||
|
// Intercept channel
|
||||||
|
final Channel channel = ctx.channel();
|
||||||
|
handleLoginStart(channel, msg);
|
||||||
|
|
||||||
|
try {
|
||||||
|
msg = onPacketInAsync(player, channel, msg);
|
||||||
|
} catch (Exception e) {
|
||||||
|
plugin.getLogger().log(Level.SEVERE, "Error in onPacketInAsync().", e);
|
||||||
|
}
|
||||||
|
|
||||||
|
if (msg != null) {
|
||||||
|
super.channelRead(ctx, msg);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void write(ChannelHandlerContext ctx, Object msg, ChannelPromise promise) throws Exception {
|
||||||
|
try {
|
||||||
|
msg = onPacketOutAsync(player, ctx.channel(), msg);
|
||||||
|
} catch (Exception e) {
|
||||||
|
plugin.getLogger().log(Level.SEVERE, "Error in onPacketOutAsync().", e);
|
||||||
|
}
|
||||||
|
|
||||||
|
if (msg != null) {
|
||||||
|
super.write(ctx, msg, promise);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
private void handleLoginStart(Channel channel, Object packet) {
|
||||||
|
if (PACKET_LOGIN_IN_START.isInstance(packet)) {
|
||||||
|
GameProfile profile = getGameProfile.get(packet);
|
||||||
|
channelLookup.put(profile.getName(), channel);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
@ -29,7 +29,8 @@ public interface TypeMapper<T> {
|
|||||||
}
|
}
|
||||||
|
|
||||||
// For backwards compatibility, can be removed later on
|
// For backwards compatibility, can be removed later on
|
||||||
@Deprecated(since = "Use the other map Function without calling super!")
|
// SINCE="Use the other map Function without calling super!"
|
||||||
|
@Deprecated
|
||||||
default T map(String[] previousArguments, String s) {
|
default T map(String[] previousArguments, String s) {
|
||||||
throw new SecurityException();
|
throw new SecurityException();
|
||||||
}
|
}
|
||||||
|
@ -23,8 +23,9 @@ import com.google.common.io.ByteArrayDataInput;
|
|||||||
import com.google.common.io.ByteStreams;
|
import com.google.common.io.ByteStreams;
|
||||||
import de.steamwar.comms.handlers.BungeeHandler;
|
import de.steamwar.comms.handlers.BungeeHandler;
|
||||||
import de.steamwar.comms.handlers.InventoryHandler;
|
import de.steamwar.comms.handlers.InventoryHandler;
|
||||||
import de.steamwar.core.VersionedRunnable;
|
import de.steamwar.core.BountifulWrapper;
|
||||||
import de.steamwar.sql.*;
|
import de.steamwar.sql.BauweltMember;
|
||||||
|
import de.steamwar.sql.SteamwarUser;
|
||||||
import org.bukkit.Bukkit;
|
import org.bukkit.Bukkit;
|
||||||
import org.bukkit.entity.Player;
|
import org.bukkit.entity.Player;
|
||||||
import org.bukkit.plugin.messaging.PluginMessageListener;
|
import org.bukkit.plugin.messaging.PluginMessageListener;
|
||||||
@ -46,8 +47,7 @@ public class BungeeReceiver implements PluginMessageListener {
|
|||||||
UUID uuid = SteamwarUser.get(byteArrayDataInput.readInt()).getUUID();
|
UUID uuid = SteamwarUser.get(byteArrayDataInput.readInt()).getUUID();
|
||||||
if(Bukkit.getPlayer(uuid).isOnline()) {
|
if(Bukkit.getPlayer(uuid).isOnline()) {
|
||||||
Player player = Bukkit.getPlayer(uuid);
|
Player player = Bukkit.getPlayer(uuid);
|
||||||
VersionedRunnable.call(new VersionedRunnable(() -> BungeeReceiver_8.playPling(player), 8),
|
BountifulWrapper.impl.playPling(player);
|
||||||
new VersionedRunnable(() -> BungeeReceiver_9.playpling(player), 9));
|
|
||||||
}
|
}
|
||||||
|
|
||||||
});
|
});
|
||||||
|
@ -20,14 +20,18 @@
|
|||||||
package de.steamwar.comms;
|
package de.steamwar.comms;
|
||||||
|
|
||||||
public class PacketIdManager {
|
public class PacketIdManager {
|
||||||
|
private PacketIdManager(){}
|
||||||
|
|
||||||
//0x0(X) Standalone Packets
|
//0x0(X) Standalone Packets
|
||||||
public final static byte PING_PACKET = 0x01;
|
public static final byte PING_PACKET = 0x01;
|
||||||
public final static byte TABLIST_NAME = 0x02;
|
public static final byte TABLIST_NAME = 0x02;
|
||||||
public static final byte PREPARE_SCHEM = 0x03;
|
public static final byte PREPARE_SCHEM = 0x03;
|
||||||
public final static byte BAUMEMBER_UPDATE = 0x04;
|
public static final byte BAUMEMBER_UPDATE = 0x04;
|
||||||
//0x1(X) Bungee Inventory
|
//0x1(X) Bungee Inventory
|
||||||
public final static byte INVENTORY_PACKET = 0x10;
|
public static final byte INVENTORY_PACKET = 0x10;
|
||||||
public final static byte INVENTORY_CALLBACK_PACKET = 0x11;
|
public static final byte INVENTORY_CALLBACK_PACKET = 0x11;
|
||||||
public final static byte INVENTORY_CLOSE_PACKET = 0x12;
|
public static final byte INVENTORY_CLOSE_PACKET = 0x12;
|
||||||
|
//0x2(X) Server Information System
|
||||||
|
public static final byte I_AM_A_LOBBY = 0x20;
|
||||||
|
public static final byte FIGHT_INFO = 0x21;
|
||||||
}
|
}
|
||||||
|
174
SpigotCore_Main/src/de/steamwar/comms/packets/FightInfoPacket.java
Normale Datei
174
SpigotCore_Main/src/de/steamwar/comms/packets/FightInfoPacket.java
Normale Datei
@ -0,0 +1,174 @@
|
|||||||
|
/*
|
||||||
|
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.comms.packets;
|
||||||
|
|
||||||
|
import com.google.common.io.ByteArrayDataInput;
|
||||||
|
import com.google.common.io.ByteArrayDataOutput;
|
||||||
|
import de.steamwar.comms.PacketIdManager;
|
||||||
|
|
||||||
|
import java.util.ArrayList;
|
||||||
|
import java.util.List;
|
||||||
|
|
||||||
|
public class FightInfoPacket extends SpigotPacket {
|
||||||
|
|
||||||
|
private final String serverName; // Name of the Server, might be changed by Bungee
|
||||||
|
private final String gameMode; // GameMode aka Schematictype (if known, else "")
|
||||||
|
private final String arena; // Name of the arena
|
||||||
|
private final String blueName; // Name of the blue team, expected to begin with "§a" colorcode
|
||||||
|
private final String redName; // Name of the red team, expected to begin with "§a" colorcode
|
||||||
|
private final String fightState; // Fight state (technical term) (if known, else "")
|
||||||
|
private final int countdown; // Countdown state in seconds (if known, else 0)
|
||||||
|
private final int blueLeader; // SWUserID of the blue team leader (if known, else 0)
|
||||||
|
private final int redLeader; // SWUserID of the red team leader (if known, else 0)
|
||||||
|
private final int blueSchem; // Blue SchemID (if known, else 0)
|
||||||
|
private final int redSchem; // Red SchemID (if known, else 0)
|
||||||
|
private final List<Integer> bluePlayers; // List of Blue SWUserIDs
|
||||||
|
private final List<Integer> redPlayers; // List of Red SWUserIDs
|
||||||
|
private final List<Integer> spectators; // List of Spectator SWUserIDs
|
||||||
|
|
||||||
|
public FightInfoPacket(String serverName, String gameMode, String arena, String blueName, String redName, String fightState, int countdown, int blueLeader, int redLeader, int blueSchem, int redSchem, List<Integer> bluePlayers, List<Integer> redPlayers, List<Integer> spectators) {
|
||||||
|
this.serverName = serverName;
|
||||||
|
this.gameMode = gameMode;
|
||||||
|
this.arena = arena;
|
||||||
|
this.blueName = blueName;
|
||||||
|
this.redName = redName;
|
||||||
|
this.fightState = fightState;
|
||||||
|
this.countdown = countdown;
|
||||||
|
this.blueLeader = blueLeader;
|
||||||
|
this.redLeader = redLeader;
|
||||||
|
this.blueSchem = blueSchem;
|
||||||
|
this.redSchem = redSchem;
|
||||||
|
this.bluePlayers = bluePlayers;
|
||||||
|
this.redPlayers = redPlayers;
|
||||||
|
this.spectators = spectators;
|
||||||
|
}
|
||||||
|
|
||||||
|
public FightInfoPacket(ByteArrayDataInput in) {
|
||||||
|
this.serverName = in.readUTF();
|
||||||
|
this.gameMode = in.readUTF();
|
||||||
|
this.arena = in.readUTF();
|
||||||
|
this.blueName = in.readUTF();
|
||||||
|
this.redName = in.readUTF();
|
||||||
|
this.fightState = in.readUTF();
|
||||||
|
this.countdown = in.readInt();
|
||||||
|
this.blueLeader = in.readInt();
|
||||||
|
this.redLeader = in.readInt();
|
||||||
|
this.blueSchem = in.readInt();
|
||||||
|
this.redSchem = in.readInt();
|
||||||
|
this.bluePlayers = readPlayerList(in);
|
||||||
|
this.redPlayers = readPlayerList(in);
|
||||||
|
this.spectators = readPlayerList(in);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public int getName() {
|
||||||
|
return PacketIdManager.FIGHT_INFO;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void writeVars(ByteArrayDataOutput out) {
|
||||||
|
out.writeUTF(serverName);
|
||||||
|
out.writeUTF(gameMode);
|
||||||
|
out.writeUTF(arena);
|
||||||
|
out.writeUTF(blueName);
|
||||||
|
out.writeUTF(redName);
|
||||||
|
out.writeUTF(fightState);
|
||||||
|
out.writeInt(countdown);
|
||||||
|
out.writeInt(blueLeader);
|
||||||
|
out.writeInt(redLeader);
|
||||||
|
out.writeInt(blueSchem);
|
||||||
|
out.writeInt(redSchem);
|
||||||
|
writePlayerList(out, bluePlayers);
|
||||||
|
writePlayerList(out, redPlayers);
|
||||||
|
writePlayerList(out, spectators);
|
||||||
|
}
|
||||||
|
|
||||||
|
public String getServerName() {
|
||||||
|
return serverName;
|
||||||
|
}
|
||||||
|
|
||||||
|
public String getGameMode() {
|
||||||
|
return gameMode;
|
||||||
|
}
|
||||||
|
|
||||||
|
public String getArena() {
|
||||||
|
return arena;
|
||||||
|
}
|
||||||
|
|
||||||
|
public String getBlueName() {
|
||||||
|
return blueName;
|
||||||
|
}
|
||||||
|
|
||||||
|
public String getRedName() {
|
||||||
|
return redName;
|
||||||
|
}
|
||||||
|
|
||||||
|
public String getFightState() {
|
||||||
|
return fightState;
|
||||||
|
}
|
||||||
|
|
||||||
|
public int getCountdown() {
|
||||||
|
return countdown;
|
||||||
|
}
|
||||||
|
|
||||||
|
public int getBlueLeader() {
|
||||||
|
return blueLeader;
|
||||||
|
}
|
||||||
|
|
||||||
|
public int getRedLeader() {
|
||||||
|
return redLeader;
|
||||||
|
}
|
||||||
|
|
||||||
|
public int getBlueSchem() {
|
||||||
|
return blueSchem;
|
||||||
|
}
|
||||||
|
|
||||||
|
public int getRedSchem() {
|
||||||
|
return redSchem;
|
||||||
|
}
|
||||||
|
|
||||||
|
public List<Integer> getBluePlayers() {
|
||||||
|
return bluePlayers;
|
||||||
|
}
|
||||||
|
|
||||||
|
public List<Integer> getRedPlayers() {
|
||||||
|
return redPlayers;
|
||||||
|
}
|
||||||
|
|
||||||
|
public List<Integer> getSpectators() {
|
||||||
|
return spectators;
|
||||||
|
}
|
||||||
|
|
||||||
|
private static List<Integer> readPlayerList(ByteArrayDataInput in) {
|
||||||
|
int length = in.readInt();
|
||||||
|
List<Integer> players = new ArrayList<>(length);
|
||||||
|
for(int i = 0; i < length; i++) {
|
||||||
|
players.add(in.readInt());
|
||||||
|
}
|
||||||
|
return players;
|
||||||
|
}
|
||||||
|
|
||||||
|
private void writePlayerList(ByteArrayDataOutput out, List<Integer> players) {
|
||||||
|
out.writeInt(players.size());
|
||||||
|
for(Integer player : players) {
|
||||||
|
out.writeInt(player);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
@ -17,16 +17,20 @@
|
|||||||
along with this program. If not, see <https://www.gnu.org/licenses/>.
|
along with this program. If not, see <https://www.gnu.org/licenses/>.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
package de.steamwar.core;
|
package de.steamwar.comms.packets;
|
||||||
|
|
||||||
import net.minecraft.server.v1_15_R1.MinecraftServer;
|
import com.google.common.io.ByteArrayDataOutput;
|
||||||
|
import de.steamwar.comms.PacketIdManager;
|
||||||
|
|
||||||
public class SpigotTPS_15 {
|
public class ImALobbyPacket extends SpigotPacket {
|
||||||
|
|
||||||
private SpigotTPS_15(){}
|
@Override
|
||||||
|
public int getName() {
|
||||||
static double[] getTps(){
|
return PacketIdManager.I_AM_A_LOBBY;
|
||||||
return MinecraftServer.getServer().recentTps;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void writeVars(ByteArrayDataOutput byteArrayDataOutput) {
|
||||||
|
//no content
|
||||||
|
}
|
||||||
}
|
}
|
36
SpigotCore_Main/src/de/steamwar/core/BountifulWrapper.java
Normale Datei
36
SpigotCore_Main/src/de/steamwar/core/BountifulWrapper.java
Normale Datei
@ -0,0 +1,36 @@
|
|||||||
|
/*
|
||||||
|
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.core;
|
||||||
|
|
||||||
|
import net.md_5.bungee.api.ChatMessageType;
|
||||||
|
import net.md_5.bungee.api.chat.BaseComponent;
|
||||||
|
import org.bukkit.entity.Player;
|
||||||
|
|
||||||
|
public class BountifulWrapper {
|
||||||
|
private BountifulWrapper() {}
|
||||||
|
|
||||||
|
public static final IBountifulWrapper impl = VersionDependent.getVersionImpl(Core.getInstance());
|
||||||
|
|
||||||
|
public interface IBountifulWrapper {
|
||||||
|
void playPling(Player player);
|
||||||
|
|
||||||
|
void sendMessage(Player player, ChatMessageType type, BaseComponent... msg);
|
||||||
|
}
|
||||||
|
}
|
@ -19,8 +19,8 @@
|
|||||||
|
|
||||||
package de.steamwar.core;
|
package de.steamwar.core;
|
||||||
|
|
||||||
import de.steamwar.authlib.AuthlibInjector;
|
|
||||||
import de.steamwar.comms.BungeeReceiver;
|
import de.steamwar.comms.BungeeReceiver;
|
||||||
|
import de.steamwar.core.authlib.AuthlibInjector;
|
||||||
import de.steamwar.core.events.ChattingEvent;
|
import de.steamwar.core.events.ChattingEvent;
|
||||||
import de.steamwar.core.events.ChunkListener;
|
import de.steamwar.core.events.ChunkListener;
|
||||||
import de.steamwar.core.events.PlayerJoinedEvent;
|
import de.steamwar.core.events.PlayerJoinedEvent;
|
||||||
@ -29,8 +29,14 @@ import de.steamwar.sql.SQL;
|
|||||||
import org.bukkit.Bukkit;
|
import org.bukkit.Bukkit;
|
||||||
import org.bukkit.plugin.java.JavaPlugin;
|
import org.bukkit.plugin.java.JavaPlugin;
|
||||||
|
|
||||||
|
import java.io.BufferedReader;
|
||||||
|
import java.io.IOException;
|
||||||
|
import java.io.InputStreamReader;
|
||||||
|
import java.util.logging.Level;
|
||||||
|
|
||||||
|
|
||||||
public class Core extends JavaPlugin{
|
public class Core extends JavaPlugin{
|
||||||
|
|
||||||
private static Core instance;
|
private static Core instance;
|
||||||
private static final int version;
|
private static final int version;
|
||||||
|
|
||||||
@ -57,20 +63,25 @@ public class Core extends JavaPlugin{
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void onEnable() {
|
public void onEnable() {
|
||||||
|
new ErrorHandler();
|
||||||
|
|
||||||
Bukkit.getPluginManager().registerEvents(new PlayerJoinedEvent(), this);
|
Bukkit.getPluginManager().registerEvents(new PlayerJoinedEvent(), this);
|
||||||
Bukkit.getPluginManager().registerEvents(new ChattingEvent(), this);
|
Bukkit.getPluginManager().registerEvents(new ChattingEvent(), this);
|
||||||
Bukkit.getPluginManager().registerEvents(new WorldLoadEvent(), this);
|
Bukkit.getPluginManager().registerEvents(new WorldLoadEvent(), this);
|
||||||
ChunkListener.init();
|
|
||||||
if(version >= 12)
|
|
||||||
ErrorLogger.init();
|
|
||||||
getServer().getMessenger().registerIncomingPluginChannel(this, "sw:bridge", new BungeeReceiver());
|
getServer().getMessenger().registerIncomingPluginChannel(this, "sw:bridge", new BungeeReceiver());
|
||||||
getServer().getMessenger().registerOutgoingPluginChannel(this, "sw:bridge");
|
getServer().getMessenger().registerOutgoingPluginChannel(this, "sw:bridge");
|
||||||
|
ChunkListener.init();
|
||||||
AuthlibInjector.inject();
|
AuthlibInjector.inject();
|
||||||
|
try {
|
||||||
|
Bukkit.getLogger().log(Level.INFO, "Running on: " + new BufferedReader(new InputStreamReader(Runtime.getRuntime().exec("hostname").getInputStream())).readLine());
|
||||||
|
} catch (IOException e) {
|
||||||
|
throw new SecurityException("Could not load Hostname", e);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void onDisable(){
|
public void onDisable(){
|
||||||
SQL.closeConnection();
|
SQL.close();
|
||||||
}
|
}
|
||||||
|
|
||||||
public static Core getInstance() {
|
public static Core getInstance() {
|
||||||
|
33
SpigotCore_Main/src/de/steamwar/core/CraftbukkitWrapper.java
Normale Datei
33
SpigotCore_Main/src/de/steamwar/core/CraftbukkitWrapper.java
Normale Datei
@ -0,0 +1,33 @@
|
|||||||
|
/*
|
||||||
|
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.core;
|
||||||
|
|
||||||
|
import org.bukkit.entity.Player;
|
||||||
|
|
||||||
|
public class CraftbukkitWrapper {
|
||||||
|
private CraftbukkitWrapper() {}
|
||||||
|
|
||||||
|
public static final ICraftbukkitWrapper impl = VersionDependent.getVersionImpl(Core.getInstance());
|
||||||
|
|
||||||
|
public interface ICraftbukkitWrapper {
|
||||||
|
void sendChunk(Player p, int chunkX, int chunkZ);
|
||||||
|
double[] getSpigotTPS();
|
||||||
|
}
|
||||||
|
}
|
141
SpigotCore_Main/src/de/steamwar/core/ErrorHandler.java
Normale Datei
141
SpigotCore_Main/src/de/steamwar/core/ErrorHandler.java
Normale Datei
@ -0,0 +1,141 @@
|
|||||||
|
/*
|
||||||
|
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.core;
|
||||||
|
|
||||||
|
import de.steamwar.sql.SWException;
|
||||||
|
|
||||||
|
import java.io.ByteArrayOutputStream;
|
||||||
|
import java.io.PrintStream;
|
||||||
|
import java.util.ArrayList;
|
||||||
|
import java.util.Collections;
|
||||||
|
import java.util.List;
|
||||||
|
import java.util.logging.Handler;
|
||||||
|
import java.util.logging.Level;
|
||||||
|
import java.util.logging.LogRecord;
|
||||||
|
import java.util.logging.Logger;
|
||||||
|
|
||||||
|
public class ErrorHandler extends Handler {
|
||||||
|
|
||||||
|
private boolean logDisabled = false;
|
||||||
|
|
||||||
|
public ErrorHandler(){
|
||||||
|
Logger.getLogger("").addHandler(this);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void publish(LogRecord logRecord) {
|
||||||
|
if(logRecord.getLevel().intValue() < Level.WARNING.intValue())
|
||||||
|
return;
|
||||||
|
|
||||||
|
if(logDisabled)
|
||||||
|
return;
|
||||||
|
|
||||||
|
String message = logRecord.getMessage();
|
||||||
|
for(String reason : ignoreStartsWith)
|
||||||
|
if(message.startsWith(reason))
|
||||||
|
return;
|
||||||
|
for(String reason : ignoreContains)
|
||||||
|
if(message.contains(reason))
|
||||||
|
return;
|
||||||
|
|
||||||
|
switch (message) {
|
||||||
|
case "The server has stopped responding!":
|
||||||
|
logDisabled = true;
|
||||||
|
return;
|
||||||
|
case "------------------------------":
|
||||||
|
message = "Server stopped responding";
|
||||||
|
logDisabled = true;
|
||||||
|
break;
|
||||||
|
case "Exception stopping the server":
|
||||||
|
logDisabled = true;
|
||||||
|
break;
|
||||||
|
default:
|
||||||
|
}
|
||||||
|
|
||||||
|
ByteArrayOutputStream stacktraceOutput = new ByteArrayOutputStream();
|
||||||
|
if(logRecord.getThrown() != null)
|
||||||
|
logRecord.getThrown().printStackTrace(new PrintStream(stacktraceOutput));
|
||||||
|
String stacktrace = stacktraceOutput.toString();
|
||||||
|
if(stacktrace.contains("POI data mismatch"))
|
||||||
|
return;
|
||||||
|
|
||||||
|
SWException.log(message, stacktrace);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void flush() {
|
||||||
|
//This is task of the database
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void close() throws SecurityException {
|
||||||
|
//Done in the database
|
||||||
|
}
|
||||||
|
|
||||||
|
private static final List<String> ignoreStartsWith;
|
||||||
|
private static final List<String> ignoreContains;
|
||||||
|
|
||||||
|
static {
|
||||||
|
List<String> startsWith = new ArrayList<>();
|
||||||
|
startsWith.add("Could not save the list after adding a user.");
|
||||||
|
startsWith.add("Could not save spigot.yml");
|
||||||
|
startsWith.add("Failed to save operators list:");
|
||||||
|
startsWith.add("Block at");
|
||||||
|
startsWith.add("POI data mismatch");
|
||||||
|
startsWith.add("handleDisconnection() called twice");
|
||||||
|
startsWith.add("**** SERVER IS RUNNING IN OFFLINE/INSECURE MODE!");
|
||||||
|
startsWith.add("The server will make no attempt to authenticate usernames. Beware.");
|
||||||
|
startsWith.add("Whilst this makes it possible to use BungeeCord,");
|
||||||
|
startsWith.add("Please see http://www.spigotmc.org/wiki/firewall-guide/ for further information.");
|
||||||
|
startsWith.add("To change this, set \"online-mode\" to \"true\" in the server.properties file.");
|
||||||
|
startsWith.add("This crash report has been saved to:");
|
||||||
|
startsWith.add("Could not pass event PlayerQuitEvent to WorldEditSUI");
|
||||||
|
startsWith.add("[ViaVersion] ");
|
||||||
|
startsWith.add("[ViaBackwards] ");
|
||||||
|
startsWith.add("Something went wrong upgrading!");
|
||||||
|
startsWith.add("Tried to load unrecognized recipe");
|
||||||
|
startsWith.add("Invalid BlockState in palette:");
|
||||||
|
startsWith.add("Could not register alias");
|
||||||
|
startsWith.add("Can't keep up! Is the server overloaded?");
|
||||||
|
startsWith.add("\tat ");
|
||||||
|
startsWith.add("java.lang.Exception");
|
||||||
|
startsWith.add("An exceptionCaught()");
|
||||||
|
startsWith.add("Exception verifying");
|
||||||
|
startsWith.add("[WorldEditSUI]");
|
||||||
|
startsWith.add("Unsupported key:");
|
||||||
|
startsWith.add("ThrownPotion entity");
|
||||||
|
startsWith.add("Couldn't load custom particle");
|
||||||
|
startsWith.add("Chunk file at [");
|
||||||
|
startsWith.add("Ignoring unknown attribute");
|
||||||
|
startsWith.add("Skipping player strafe phase because no player was found");
|
||||||
|
startsWith.add("Couldn't save chunk; already in use by another instance of Minecraft?");
|
||||||
|
startsWith.add("Failed to save player data for ");
|
||||||
|
startsWith.add("Failed to check session lock for world located at");
|
||||||
|
startsWith.add("Saving oversized chunk ");
|
||||||
|
ignoreStartsWith = Collections.unmodifiableList(startsWith);
|
||||||
|
|
||||||
|
List<String> contains = new ArrayList<>();
|
||||||
|
contains.add("moved too quickly!");
|
||||||
|
contains.add("moved wrongly!");
|
||||||
|
contains.add("was kicked for floating too long!");
|
||||||
|
contains.add("just tried to change non-editable sign");
|
||||||
|
ignoreContains = Collections.unmodifiableList(contains);
|
||||||
|
}
|
||||||
|
}
|
@ -1,63 +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.core;
|
|
||||||
|
|
||||||
import de.steamwar.sql.SWException;
|
|
||||||
import org.apache.logging.log4j.LogManager;
|
|
||||||
import org.apache.logging.log4j.core.Appender;
|
|
||||||
import org.apache.logging.log4j.core.Core;
|
|
||||||
import org.apache.logging.log4j.core.LogEvent;
|
|
||||||
import org.apache.logging.log4j.core.LoggerContext;
|
|
||||||
import org.apache.logging.log4j.core.appender.AbstractAppender;
|
|
||||||
import org.apache.logging.log4j.core.config.plugins.Plugin;
|
|
||||||
import org.apache.logging.log4j.core.config.plugins.PluginAttribute;
|
|
||||||
import org.apache.logging.log4j.core.config.plugins.PluginFactory;
|
|
||||||
import org.apache.logging.log4j.spi.StandardLevel;
|
|
||||||
|
|
||||||
@Plugin(name = "ErrorLogger", category = Core.CATEGORY_NAME, elementType = Appender.ELEMENT_TYPE)
|
|
||||||
public class ErrorLogger extends AbstractAppender {
|
|
||||||
|
|
||||||
public static void init(){
|
|
||||||
final LoggerContext lc = (LoggerContext) LogManager.getContext(false);
|
|
||||||
ErrorLogger el = ErrorLogger.createAppender("SWErrorLogger");
|
|
||||||
el.start();
|
|
||||||
lc.getConfiguration().addAppender(el);
|
|
||||||
lc.getRootLogger().addAppender(lc.getConfiguration().getAppender(el.getName()));
|
|
||||||
lc.updateLoggers();
|
|
||||||
}
|
|
||||||
|
|
||||||
private ErrorLogger(String name) {
|
|
||||||
super(name, null, null);
|
|
||||||
}
|
|
||||||
|
|
||||||
@PluginFactory
|
|
||||||
public static ErrorLogger createAppender(
|
|
||||||
@PluginAttribute("name") String name) {
|
|
||||||
return new ErrorLogger(name);
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public void append(LogEvent logEvent) {
|
|
||||||
if(logEvent.getLevel().intLevel() > StandardLevel.WARN.intLevel())
|
|
||||||
return;
|
|
||||||
|
|
||||||
SWException.log(logEvent);
|
|
||||||
}
|
|
||||||
}
|
|
@ -19,14 +19,20 @@
|
|||||||
|
|
||||||
package de.steamwar.core;
|
package de.steamwar.core;
|
||||||
|
|
||||||
import net.minecraft.server.v1_14_R1.MinecraftServer;
|
import org.bukkit.Material;
|
||||||
|
import org.bukkit.inventory.ItemStack;
|
||||||
|
|
||||||
public class SpigotTPS_14 {
|
public class FlatteningWrapper {
|
||||||
|
private FlatteningWrapper() {}
|
||||||
|
|
||||||
private SpigotTPS_14(){}
|
public static final IFlatteningWrapper impl = VersionDependent.getVersionImpl(Core.getInstance());
|
||||||
|
|
||||||
static double[] getTps(){
|
public interface IFlatteningWrapper {
|
||||||
return MinecraftServer.getServer().recentTps;
|
void setScoreboardTitle(Object packet, String title);
|
||||||
|
void setScoreAction(Object packet);
|
||||||
|
|
||||||
|
Material getMaterial(String material);
|
||||||
|
Material getDye(int colorCode);
|
||||||
|
ItemStack setSkullOwner(String player);
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
@ -79,12 +79,7 @@ public class TPSWatcher {
|
|||||||
}
|
}
|
||||||
|
|
||||||
private static double[] getSpigotTPS() {
|
private static double[] getSpigotTPS() {
|
||||||
return VersionedCallable.call(new VersionedCallable<>(SpigotTPS_8::getTps, 8),
|
return CraftbukkitWrapper.impl.getSpigotTPS();
|
||||||
new VersionedCallable<>(SpigotTPS_9::getTps, 9),
|
|
||||||
new VersionedCallable<>(SpigotTPS_10::getTps, 10),
|
|
||||||
new VersionedCallable<>(SpigotTPS_12::getTps, 12),
|
|
||||||
new VersionedCallable<>(SpigotTPS_14::getTps, 14),
|
|
||||||
new VersionedCallable<>(SpigotTPS_15::getTps, 15));
|
|
||||||
}
|
}
|
||||||
|
|
||||||
private static double round(double d) {
|
private static double round(double d) {
|
||||||
|
46
SpigotCore_Main/src/de/steamwar/core/VersionDependent.java
Normale Datei
46
SpigotCore_Main/src/de/steamwar/core/VersionDependent.java
Normale Datei
@ -0,0 +1,46 @@
|
|||||||
|
/*
|
||||||
|
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.core;
|
||||||
|
|
||||||
|
import org.bukkit.plugin.Plugin;
|
||||||
|
|
||||||
|
import java.lang.reflect.InvocationTargetException;
|
||||||
|
|
||||||
|
public class VersionDependent {
|
||||||
|
private VersionDependent() {}
|
||||||
|
|
||||||
|
public static <T> T getVersionImpl(Plugin plugin) {
|
||||||
|
return getVersionImpl(plugin, (new Exception()).getStackTrace()[1].getClassName());
|
||||||
|
}
|
||||||
|
|
||||||
|
public static <T> T getVersionImpl(Plugin plugin, String className){
|
||||||
|
ClassLoader loader = plugin.getClass().getClassLoader();
|
||||||
|
for(int version = Core.getVersion(); version >= 8; version--) {
|
||||||
|
try {
|
||||||
|
return ((Class<? extends T>) Class.forName(className + version, true, loader)).getDeclaredConstructor().newInstance();
|
||||||
|
} catch (InstantiationException | IllegalAccessException | InvocationTargetException | NoSuchMethodException e) {
|
||||||
|
throw new SecurityException("Could not load version dependent class", e);
|
||||||
|
} catch (ClassNotFoundException e) {
|
||||||
|
// try next version
|
||||||
|
}
|
||||||
|
}
|
||||||
|
throw new SecurityException("Unable to find version dependent implementation for " + className);
|
||||||
|
}
|
||||||
|
}
|
@ -33,6 +33,7 @@ public class VersionedCallable<T> {
|
|||||||
this.minVersion = minVersion;
|
this.minVersion = minVersion;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Deprecated
|
||||||
public static <T> T call(VersionedCallable<T>... versionedCallables) {
|
public static <T> T call(VersionedCallable<T>... versionedCallables) {
|
||||||
for (int i = versionedCallables.length - 1; i >= 0; i--) {
|
for (int i = versionedCallables.length - 1; i >= 0; i--) {
|
||||||
VersionedCallable<T> versionedCallable = versionedCallables[i];
|
VersionedCallable<T> versionedCallable = versionedCallables[i];
|
||||||
|
@ -31,6 +31,7 @@ public class VersionedRunnable {
|
|||||||
this.minVersion = minVersion;
|
this.minVersion = minVersion;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Deprecated
|
||||||
public static void call(VersionedRunnable... versionedRunnables) {
|
public static void call(VersionedRunnable... versionedRunnables) {
|
||||||
for (int i = versionedRunnables.length - 1; i >= 0; i--) {
|
for (int i = versionedRunnables.length - 1; i >= 0; i--) {
|
||||||
VersionedRunnable versionedRunnable = versionedRunnables[i];
|
VersionedRunnable versionedRunnable = versionedRunnables[i];
|
||||||
|
26
SpigotCore_Main/src/de/steamwar/core/WorldEditWrapper.java
Normale Datei
26
SpigotCore_Main/src/de/steamwar/core/WorldEditWrapper.java
Normale Datei
@ -0,0 +1,26 @@
|
|||||||
|
package de.steamwar.core;
|
||||||
|
|
||||||
|
import com.sk89q.worldedit.bukkit.WorldEditPlugin;
|
||||||
|
import com.sk89q.worldedit.extent.clipboard.Clipboard;
|
||||||
|
import org.bukkit.Bukkit;
|
||||||
|
import org.bukkit.entity.Player;
|
||||||
|
|
||||||
|
import java.io.IOException;
|
||||||
|
import java.io.InputStream;
|
||||||
|
|
||||||
|
public class WorldEditWrapper {
|
||||||
|
private WorldEditWrapper() {}
|
||||||
|
|
||||||
|
public static final IWorldEditWrapper impl = VersionDependent.getVersionImpl(Core.getInstance());
|
||||||
|
|
||||||
|
public interface IWorldEditWrapper {
|
||||||
|
byte[] getPlayerClipboard(Player player, boolean schemFormat);
|
||||||
|
void setPlayerClipboard(Player player, InputStream is, boolean schemFormat);
|
||||||
|
Clipboard getClipboard(InputStream is, boolean schemFormat) throws IOException;
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
static WorldEditPlugin getWorldEditPlugin() {
|
||||||
|
return (WorldEditPlugin) Bukkit.getPluginManager().getPlugin("WorldEdit");
|
||||||
|
}
|
||||||
|
}
|
@ -15,16 +15,20 @@
|
|||||||
|
|
||||||
You should have received a copy of the GNU Affero General Public License
|
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/>.
|
along with this program. If not, see <https://www.gnu.org/licenses/>.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
package de.steamwar.comms;
|
package de.steamwar.core;
|
||||||
|
|
||||||
import org.bukkit.Sound;
|
|
||||||
import org.bukkit.entity.Player;
|
import org.bukkit.entity.Player;
|
||||||
|
|
||||||
public class BungeeReceiver_8 {
|
import java.util.Locale;
|
||||||
|
|
||||||
public static void playPling(Player player) {
|
public class WorldOfColorWrapper {
|
||||||
player.playSound(player.getLocation(), Sound.ORB_PICKUP, 1, 1);
|
private WorldOfColorWrapper() {}
|
||||||
|
|
||||||
|
public static final IWorldOfColorWrapper impl = VersionDependent.getVersionImpl(Core.getInstance());
|
||||||
|
|
||||||
|
public interface IWorldOfColorWrapper {
|
||||||
|
Locale getLocale(Player player);
|
||||||
}
|
}
|
||||||
}
|
}
|
@ -17,31 +17,19 @@
|
|||||||
* along with this program. If not, see <https://www.gnu.org/licenses/>.
|
* along with this program. If not, see <https://www.gnu.org/licenses/>.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
package de.steamwar.authlib;
|
package de.steamwar.core.authlib;
|
||||||
|
|
||||||
|
import com.comphenix.tinyprotocol.Reflection;
|
||||||
|
import com.mojang.authlib.GameProfileRepository;
|
||||||
import com.mojang.authlib.yggdrasil.YggdrasilGameProfileRepository;
|
import com.mojang.authlib.yggdrasil.YggdrasilGameProfileRepository;
|
||||||
import de.steamwar.core.Core;
|
|
||||||
import de.steamwar.core.VersionedCallable;
|
|
||||||
|
|
||||||
import java.lang.reflect.Field;
|
|
||||||
|
|
||||||
public class AuthlibInjector {
|
public class AuthlibInjector {
|
||||||
|
private AuthlibInjector() {}
|
||||||
|
|
||||||
public static void inject() {
|
public static void inject() {
|
||||||
if (Core.getVersion() != 15) {
|
Class<?> minecraftServerClass = Reflection.getClass("{nms}.MinecraftServer");
|
||||||
return;
|
Reflection.FieldAccessor<GameProfileRepository> gameProfile = Reflection.getField(minecraftServerClass, GameProfileRepository.class, 0);
|
||||||
}
|
Object minecraftServer = Reflection.getTypedMethod(minecraftServerClass, "getServer", minecraftServerClass).invoke(null);
|
||||||
|
gameProfile.set(minecraftServer, new SteamwarGameProfileRepository((YggdrasilGameProfileRepository) gameProfile.get(minecraftServer)));
|
||||||
try {
|
|
||||||
Class<?> minecraftServerClass = VersionedCallable.call(new VersionedCallable<>(() -> AuthlibInjector_15.getMinecraftClass(), 15));
|
|
||||||
Field repo = minecraftServerClass.getDeclaredField("gameProfileRepository");
|
|
||||||
repo.setAccessible(true);
|
|
||||||
Object instance = VersionedCallable.call(new VersionedCallable<>(() -> AuthlibInjector_15.getMinecraftServerInstance(), 15));
|
|
||||||
repo.set(instance, new SteamwarGameProfileRepository((YggdrasilGameProfileRepository) repo.get(instance)));
|
|
||||||
} catch (NoSuchFieldException e) {
|
|
||||||
e.printStackTrace();
|
|
||||||
} catch (IllegalAccessException e) {
|
|
||||||
e.printStackTrace();
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
@ -17,7 +17,7 @@
|
|||||||
* along with this program. If not, see <https://www.gnu.org/licenses/>.
|
* along with this program. If not, see <https://www.gnu.org/licenses/>.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
package de.steamwar.authlib;
|
package de.steamwar.core.authlib;
|
||||||
|
|
||||||
import com.mojang.authlib.Agent;
|
import com.mojang.authlib.Agent;
|
||||||
import com.mojang.authlib.GameProfile;
|
import com.mojang.authlib.GameProfile;
|
@ -19,64 +19,42 @@
|
|||||||
|
|
||||||
package de.steamwar.core.events;
|
package de.steamwar.core.events;
|
||||||
|
|
||||||
import com.comphenix.protocol.PacketType;
|
import com.comphenix.tinyprotocol.Reflection;
|
||||||
import com.comphenix.protocol.ProtocolLibrary;
|
import com.comphenix.tinyprotocol.TinyProtocol;
|
||||||
import com.comphenix.protocol.events.PacketAdapter;
|
|
||||||
import com.comphenix.protocol.events.PacketContainer;
|
|
||||||
import com.comphenix.protocol.events.PacketEvent;
|
|
||||||
import com.comphenix.protocol.injector.server.TemporaryPlayer;
|
|
||||||
import com.comphenix.protocol.reflect.StructureModifier;
|
|
||||||
import de.steamwar.chunk.*;
|
|
||||||
import de.steamwar.core.Core;
|
import de.steamwar.core.Core;
|
||||||
import de.steamwar.core.VersionedRunnable;
|
import de.steamwar.core.CraftbukkitWrapper;
|
||||||
import de.steamwar.sql.SteamwarUser;
|
import de.steamwar.sql.SteamwarUser;
|
||||||
import org.bukkit.Bukkit;
|
import io.netty.channel.Channel;
|
||||||
import org.bukkit.entity.Player;
|
import org.bukkit.entity.Player;
|
||||||
|
|
||||||
import java.util.logging.Level;
|
|
||||||
|
|
||||||
public class ChunkListener {
|
public class ChunkListener {
|
||||||
private ChunkListener(){}
|
private ChunkListener(){}
|
||||||
|
|
||||||
public static void init(){
|
private static final Class<?> mapChunkPacket = Reflection.getClass("{nms}.PacketPlayOutMapChunk");
|
||||||
ProtocolLibrary.getProtocolManager().addPacketListener(new PacketAdapter(Core.getInstance(), PacketType.Play.Server.MAP_CHUNK) {
|
private static final Reflection.FieldAccessor<Boolean> fullChunk = Reflection.getField(mapChunkPacket, boolean.class, 0);
|
||||||
|
private static final Reflection.FieldAccessor<Integer> chunkX = Reflection.getField(mapChunkPacket, int.class, 0);
|
||||||
|
private static final Reflection.FieldAccessor<Integer> chunkZ = Reflection.getField(mapChunkPacket, int.class, 1);
|
||||||
|
|
||||||
|
public static final TinyProtocol protocol = new TinyProtocol(Core.getInstance()){
|
||||||
@Override
|
@Override
|
||||||
public void onPacketSending(PacketEvent e) {
|
public Object onPacketOutAsync(Player receiver, Channel channel, Object packet) {
|
||||||
Player p = e.getPlayer();
|
if (
|
||||||
if(p instanceof TemporaryPlayer)
|
!mapChunkPacket.isInstance(packet) ||
|
||||||
return;
|
!SteamwarUser.get(receiver.getUniqueId()).isBedrock() ||
|
||||||
|
fullChunk.get(packet)
|
||||||
|
)
|
||||||
|
return packet;
|
||||||
|
|
||||||
try{
|
CraftbukkitWrapper.impl.sendChunk(receiver, chunkX.get(packet), chunkZ.get(packet));
|
||||||
SteamwarUser user = SteamwarUser.get(p.getUniqueId());
|
return null;
|
||||||
if(!user.isBedrock())
|
}
|
||||||
return;
|
};
|
||||||
}catch(UnsupportedOperationException ex){
|
|
||||||
Bukkit.getLogger().log(Level.SEVERE, "Could not get uuid", ex);
|
public static void init(){
|
||||||
return;
|
//triggering <cinit>
|
||||||
}
|
}
|
||||||
|
|
||||||
PacketContainer packet = e.getPacket();
|
public static void sendChunk(Player p, int chunkX, int chunkZ) {
|
||||||
StructureModifier<Boolean> fullChunk = packet.getBooleans();
|
CraftbukkitWrapper.impl.sendChunk(p, chunkX, chunkZ);
|
||||||
if(fullChunk.read(0))
|
|
||||||
return;
|
|
||||||
|
|
||||||
e.setCancelled(true);
|
|
||||||
|
|
||||||
StructureModifier<Integer> ints = packet.getIntegers();
|
|
||||||
int chunkX = ints.read(0);
|
|
||||||
int chunkZ = ints.read(1);
|
|
||||||
|
|
||||||
sendChunk(p, chunkX, chunkZ);
|
|
||||||
}
|
|
||||||
});
|
|
||||||
}
|
|
||||||
|
|
||||||
public static void sendChunk(Player p, int chunkX, int chunkZ){
|
|
||||||
VersionedRunnable.call(new VersionedRunnable(() -> Chunk_8.sendChunk(p, chunkX, chunkZ), 8),
|
|
||||||
new VersionedRunnable(() -> Chunk_9.sendChunk(p, chunkX, chunkZ), 9),
|
|
||||||
new VersionedRunnable(() -> Chunk_10.sendChunk(p, chunkX, chunkZ), 10),
|
|
||||||
new VersionedRunnable(() -> Chunk_12.sendChunk(p, chunkX, chunkZ), 12),
|
|
||||||
new VersionedRunnable(() -> Chunk_14.sendChunk(p, chunkX, chunkZ), 14),
|
|
||||||
new VersionedRunnable(() -> Chunk_15.sendChunk(p, chunkX, chunkZ), 15));
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -30,35 +30,58 @@ import org.bukkit.event.inventory.InventoryCloseEvent;
|
|||||||
import org.bukkit.inventory.Inventory;
|
import org.bukkit.inventory.Inventory;
|
||||||
import org.bukkit.inventory.ItemStack;
|
import org.bukkit.inventory.ItemStack;
|
||||||
|
|
||||||
import java.util.*;
|
import java.util.ArrayList;
|
||||||
|
import java.util.HashMap;
|
||||||
|
import java.util.List;
|
||||||
|
import java.util.Map;
|
||||||
|
import java.util.function.Consumer;
|
||||||
|
import java.util.function.Supplier;
|
||||||
|
|
||||||
public class SWInventory implements Listener {
|
public class SWInventory implements Listener {
|
||||||
|
|
||||||
final Player player;
|
final Player player;
|
||||||
final Map<Integer, InvCallback> callbacks = new HashMap<>();
|
final Map<Integer, Consumer<InventoryClickEvent>> callbacks = new HashMap<>();
|
||||||
final Inventory inventory;
|
final Inventory inventory;
|
||||||
|
boolean open = false;
|
||||||
|
|
||||||
public SWInventory(Player p, int size, String t){
|
public SWInventory(Player p, int size, String t) {
|
||||||
player = p;
|
player = p;
|
||||||
inventory = Bukkit.createInventory(p, size, t);
|
inventory = Bukkit.createInventory(p, size, t);
|
||||||
}
|
}
|
||||||
|
|
||||||
public SWInventory(Player p, int size, String t, Map<Integer, SWItem> items){
|
public SWInventory(Player p, int size, String t, Map<Integer, SWItem> items) {
|
||||||
this(p, size, t);
|
this(p, size, t);
|
||||||
items.forEach(this::setItem);
|
items.forEach(this::setItem);
|
||||||
open();
|
open();
|
||||||
}
|
}
|
||||||
|
|
||||||
public void addCloseCallback(InvCallback c){
|
public SWInventory(Player p, Supplier<Inventory> inventoryConstructor) {
|
||||||
callbacks.put(-1, c);
|
player = p;
|
||||||
|
try {
|
||||||
|
inventory = inventoryConstructor.get();
|
||||||
|
} catch (Exception e) {
|
||||||
|
throw new SecurityException("Could not construct inventory", e);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public void setItem(int pos, ItemStack itemStack, InvCallback c){
|
public void addCloseCallback(InvCallback c) {
|
||||||
|
callbacks.put(-1, inventoryClickEvent -> c.clicked(null));
|
||||||
|
}
|
||||||
|
|
||||||
|
public void addCloseRunnable(Runnable c) {
|
||||||
|
callbacks.put(-1, inventoryClickEvent -> c.run());
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setItem(int pos, ItemStack itemStack, InvCallback c) {
|
||||||
inventory.setItem(pos, itemStack);
|
inventory.setItem(pos, itemStack);
|
||||||
callbacks.put(pos, c);
|
if(c != null) {
|
||||||
|
callbacks.put(pos, inventoryClickEvent -> c.clicked(inventoryClickEvent.getClick()));
|
||||||
|
} else {
|
||||||
|
callbacks.remove(pos);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public void setItem(int pos, SWItem item){
|
public void setItem(int pos, SWItem item) {
|
||||||
setItem(pos, item.getItemStack(), item.getCallback());
|
setItem(pos, item.getItemStack(), item.getCallback());
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -70,32 +93,63 @@ public class SWInventory implements Listener {
|
|||||||
setItem(pos, m, meta, name, new ArrayList<>(), false, c);
|
setItem(pos, m, meta, name, new ArrayList<>(), false, c);
|
||||||
}
|
}
|
||||||
|
|
||||||
public void setItem(int pos, Material m, String name, List<String> lore, boolean e, InvCallback c){
|
public void setItem(int pos, Material m, String name, List<String> lore, boolean e, InvCallback c) {
|
||||||
setItem(pos, m, (byte)0, name, lore, e, c);
|
setItem(pos, m, (byte) 0, name, lore, e, c);
|
||||||
}
|
}
|
||||||
|
|
||||||
public void setItem(int pos, Material m, byte meta, String name, List<String> lore, boolean e, InvCallback c){
|
public void setItem(int pos, Material m, byte meta, String name, List<String> lore, boolean e, InvCallback c) {
|
||||||
SWItem item = new SWItem(m, meta, name, lore, e, c);
|
SWItem item = new SWItem(m, meta, name, lore, e, c);
|
||||||
setItem(pos, item);
|
setItem(pos, item);
|
||||||
}
|
}
|
||||||
|
|
||||||
public void setCallback(int pos, InvCallback c){
|
public void setCallback(int pos, InvCallback c) {
|
||||||
|
callbacks.put(pos, inventoryClickEvent -> c.clicked(inventoryClickEvent.getClick()));
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setItemEvent(int pos, ItemStack itemStack, Consumer<InventoryClickEvent> c) {
|
||||||
|
inventory.setItem(pos, itemStack);
|
||||||
callbacks.put(pos, c);
|
callbacks.put(pos, c);
|
||||||
}
|
}
|
||||||
|
|
||||||
public void open(){
|
public void setItemEvent(int pos, Material m, String name, Consumer<InventoryClickEvent> c) {
|
||||||
|
setItemEvent(pos, m, name, new ArrayList<>(), false, c);
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setItemEvent(int pos, Material m, byte meta, String name, Consumer<InventoryClickEvent> c) {
|
||||||
|
setItemEvent(pos, m, meta, name, new ArrayList<>(), false, c);
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setItemEvent(int pos, Material m, String name, List<String> lore, boolean e, Consumer<InventoryClickEvent> c) {
|
||||||
|
setItemEvent(pos, m, (byte) 0, name, lore, e, c);
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setItemEvent(int pos, Material m, byte meta, String name, List<String> lore, boolean e, Consumer<InventoryClickEvent> c) {
|
||||||
|
SWItem item = new SWItem(m, meta, name, lore, e, click -> {
|
||||||
|
});
|
||||||
|
setItem(pos, item);
|
||||||
|
setEventCallback(pos, c);
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setEventCallback(int pos, Consumer<InventoryClickEvent> c) {
|
||||||
|
callbacks.put(pos, c);
|
||||||
|
}
|
||||||
|
|
||||||
|
public void open() {
|
||||||
player.openInventory(inventory);
|
player.openInventory(inventory);
|
||||||
|
if(!open) {
|
||||||
Bukkit.getPluginManager().registerEvents(this, Core.getInstance());
|
Bukkit.getPluginManager().registerEvents(this, Core.getInstance());
|
||||||
|
open = true;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@EventHandler
|
@EventHandler
|
||||||
public void onInventoryClick(InventoryClickEvent e){
|
public void onInventoryClick(InventoryClickEvent e) {
|
||||||
if(!player.equals(e.getWhoClicked()))
|
if (!player.equals(e.getWhoClicked()))
|
||||||
return;
|
return;
|
||||||
|
|
||||||
if(callbacks.containsKey(e.getRawSlot()) && callbacks.get(e.getRawSlot()) != null) {
|
if (callbacks.containsKey(e.getRawSlot()) && callbacks.get(e.getRawSlot()) != null) {
|
||||||
e.setCancelled(true);
|
e.setCancelled(true);
|
||||||
callbacks.get(e.getRawSlot()).clicked(e.getClick());
|
callbacks.get(e.getRawSlot()).accept(e);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -107,6 +161,7 @@ public class SWInventory implements Listener {
|
|||||||
InventoryClickEvent.getHandlerList().unregister(this);
|
InventoryClickEvent.getHandlerList().unregister(this);
|
||||||
InventoryCloseEvent.getHandlerList().unregister(this);
|
InventoryCloseEvent.getHandlerList().unregister(this);
|
||||||
if(callbacks.containsKey(-1))
|
if(callbacks.containsKey(-1))
|
||||||
callbacks.get(-1).clicked(null);
|
callbacks.get(-1).accept(null);
|
||||||
|
open = false;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -21,7 +21,7 @@ package de.steamwar.inventory;
|
|||||||
|
|
||||||
import com.google.gson.JsonArray;
|
import com.google.gson.JsonArray;
|
||||||
import com.google.gson.JsonObject;
|
import com.google.gson.JsonObject;
|
||||||
import de.steamwar.core.VersionedCallable;
|
import de.steamwar.core.FlatteningWrapper;
|
||||||
import org.bukkit.Material;
|
import org.bukkit.Material;
|
||||||
import org.bukkit.OfflinePlayer;
|
import org.bukkit.OfflinePlayer;
|
||||||
import org.bukkit.enchantments.Enchantment;
|
import org.bukkit.enchantments.Enchantment;
|
||||||
@ -44,24 +44,21 @@ public class SWItem {
|
|||||||
|
|
||||||
public static SWItem getPlayerSkull(String playerName){
|
public static SWItem getPlayerSkull(String playerName){
|
||||||
SWItem p = new SWItem();
|
SWItem p = new SWItem();
|
||||||
ItemStack head = VersionedCallable.call(new VersionedCallable<>(() -> SWItem_8.setSkullOwner(playerName), 8),
|
ItemStack head = FlatteningWrapper.impl.setSkullOwner(playerName);
|
||||||
new VersionedCallable<>(() -> SWItem_14.setSkullOwner(playerName), 14));
|
|
||||||
p.setItemStack(head);
|
p.setItemStack(head);
|
||||||
return p;
|
return p;
|
||||||
}
|
}
|
||||||
|
|
||||||
public static Material getMaterial(String material){
|
public static Material getMaterial(String material){
|
||||||
try{
|
try{
|
||||||
return VersionedCallable.call(new VersionedCallable<>(() -> SWItem_8.getMaterial(material), 8),
|
return FlatteningWrapper.impl.getMaterial(material);
|
||||||
new VersionedCallable<>(() -> SWItem_14.getMaterial(material), 14));
|
|
||||||
}catch(IllegalArgumentException e){
|
}catch(IllegalArgumentException e){
|
||||||
return Material.STONE;
|
return Material.STONE;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public static Material getDye(int colorCode){
|
public static Material getDye(int colorCode){
|
||||||
return VersionedCallable.call(new VersionedCallable<>(SWItem_8::getDye, 8),
|
return FlatteningWrapper.impl.getDye(colorCode);
|
||||||
new VersionedCallable<>(() -> SWItem_14.getDye(colorCode), 14));
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public SWItem() {
|
public SWItem() {
|
||||||
@ -90,6 +87,7 @@ public class SWItem {
|
|||||||
this(material, (byte)0, name, lore, enchanted, c);
|
this(material, (byte)0, name, lore, enchanted, c);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@SuppressWarnings("deprecation")
|
||||||
public SWItem(Material material, byte meta, String name, List<String> lore, boolean enchanted, InvCallback c) {
|
public SWItem(Material material, byte meta, String name, List<String> lore, boolean enchanted, InvCallback c) {
|
||||||
try {
|
try {
|
||||||
itemStack = new ItemStack(material, 1, (short)0, meta);
|
itemStack = new ItemStack(material, 1, (short)0, meta);
|
||||||
|
@ -19,7 +19,8 @@
|
|||||||
|
|
||||||
package de.steamwar.message;
|
package de.steamwar.message;
|
||||||
|
|
||||||
import de.steamwar.core.VersionedCallable;
|
import de.steamwar.core.BountifulWrapper;
|
||||||
|
import de.steamwar.core.WorldOfColorWrapper;
|
||||||
import net.md_5.bungee.api.ChatMessageType;
|
import net.md_5.bungee.api.ChatMessageType;
|
||||||
import net.md_5.bungee.api.chat.ClickEvent;
|
import net.md_5.bungee.api.chat.ClickEvent;
|
||||||
import net.md_5.bungee.api.chat.HoverEvent;
|
import net.md_5.bungee.api.chat.HoverEvent;
|
||||||
@ -73,8 +74,7 @@ public class Message {
|
|||||||
}
|
}
|
||||||
|
|
||||||
private Locale getLocale(Player player){
|
private Locale getLocale(Player player){
|
||||||
return VersionedCallable.call(new VersionedCallable<>(() -> Message_8.getLocale(player), 8),
|
return WorldOfColorWrapper.impl.getLocale(player);
|
||||||
new VersionedCallable<>(() -> Message_12.getLocale(player), 12));
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Send a message to one player */
|
/* Send a message to one player */
|
||||||
@ -109,10 +109,11 @@ public class Message {
|
|||||||
msg.setHoverEvent(new HoverEvent(HoverEvent.Action.SHOW_TEXT, TextComponent.fromLegacyText(onHover)));
|
msg.setHoverEvent(new HoverEvent(HoverEvent.Action.SHOW_TEXT, TextComponent.fromLegacyText(onHover)));
|
||||||
if(onClick != null)
|
if(onClick != null)
|
||||||
msg.setClickEvent(onClick);
|
msg.setClickEvent(onClick);
|
||||||
|
|
||||||
if(sender instanceof Player)
|
if(sender instanceof Player)
|
||||||
((Player)sender).spigot().sendMessage(type, msg);
|
BountifulWrapper.impl.sendMessage((Player)sender, type, msg);
|
||||||
else
|
else
|
||||||
sender.spigot().sendMessage(msg);
|
sender.sendMessage(msg.toPlainText());
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Send message to all players */
|
/* Send message to all players */
|
||||||
|
@ -19,57 +19,69 @@
|
|||||||
|
|
||||||
package de.steamwar.scoreboard;
|
package de.steamwar.scoreboard;
|
||||||
|
|
||||||
import com.comphenix.protocol.PacketType;
|
import com.comphenix.tinyprotocol.Reflection;
|
||||||
import com.comphenix.protocol.ProtocolLibrary;
|
|
||||||
import com.comphenix.protocol.ProtocolManager;
|
|
||||||
import com.comphenix.protocol.events.PacketContainer;
|
|
||||||
import com.comphenix.protocol.wrappers.WrappedChatComponent;
|
|
||||||
import de.steamwar.core.Core;
|
import de.steamwar.core.Core;
|
||||||
import de.steamwar.core.VersionedRunnable;
|
import de.steamwar.core.FlatteningWrapper;
|
||||||
|
import de.steamwar.core.events.ChunkListener;
|
||||||
import org.bukkit.Bukkit;
|
import org.bukkit.Bukkit;
|
||||||
import org.bukkit.entity.Player;
|
import org.bukkit.entity.Player;
|
||||||
|
|
||||||
import java.lang.reflect.InvocationTargetException;
|
|
||||||
import java.util.HashMap;
|
import java.util.HashMap;
|
||||||
import java.util.Map;
|
import java.util.Map;
|
||||||
|
|
||||||
public class SWScoreboard {
|
public class SWScoreboard {
|
||||||
private SWScoreboard() {}
|
private SWScoreboard() {}
|
||||||
|
|
||||||
private static final ProtocolManager manager = ProtocolLibrary.getProtocolManager();
|
public static final Class<?> scoreboardObjective = Reflection.getClass("{nms}.PacketPlayOutScoreboardObjective");
|
||||||
|
private static final Reflection.FieldAccessor<String> scoreboardName = Reflection.getField(scoreboardObjective, String.class, 0);
|
||||||
|
private static final Reflection.FieldAccessor<Integer> scoreboardAction = Reflection.getField(scoreboardObjective, int.class, 0);
|
||||||
|
private static final Class<?> scoreboardDisplayEnum = Reflection.getClass("{nms}.IScoreboardCriteria$EnumScoreboardHealthDisplay");
|
||||||
|
private static final Reflection.FieldAccessor<?> scoreboardDisplayType = Reflection.getField(scoreboardObjective, scoreboardDisplayEnum, 0);
|
||||||
|
private static final Object displayTypeIntegers = scoreboardDisplayEnum.getEnumConstants()[0];
|
||||||
|
|
||||||
|
public static final Class<?> scoreboardScore = Reflection.getClass("{nms}.PacketPlayOutScoreboardScore");
|
||||||
|
private static final Reflection.FieldAccessor<String> scoreName = Reflection.getField(scoreboardScore, String.class, 0);
|
||||||
|
private static final Reflection.FieldAccessor<String> scoreScoreboardName = Reflection.getField(scoreboardScore, String.class, 1);
|
||||||
|
private static final Reflection.FieldAccessor<Integer> scoreValue = Reflection.getField(scoreboardScore, int.class, 0);
|
||||||
|
|
||||||
private static final HashMap<Player, ScoreboardCallback> playerBoards = new HashMap<>(); //Object -> Scoreboard | Alle Versionen in der Map!
|
private static final HashMap<Player, ScoreboardCallback> playerBoards = new HashMap<>(); //Object -> Scoreboard | Alle Versionen in der Map!
|
||||||
private static int toggle = 0; // Scoreboard 0 updates while scoreboard 1 is presenting. toggle marks the current active scoreboard
|
private static int toggle = 0; // Scoreboard 0 updates while scoreboard 1 is presenting. toggle marks the current active scoreboard
|
||||||
|
|
||||||
private static final String SIDEBAR = "Sidebar";
|
private static final String SIDEBAR = "Sidebar";
|
||||||
private static final PacketContainer[] DELETE_SCOREBOARD = new PacketContainer[2];
|
private static final Object[] DELETE_SCOREBOARD = new Object[2];
|
||||||
private static final PacketContainer[] DISPLAY_SIDEBAR = new PacketContainer[2];
|
private static final Object[] DISPLAY_SIDEBAR = new Object[2];
|
||||||
|
|
||||||
static {
|
static {
|
||||||
setScoreboardConstants(0);
|
Class<?> scoreboardDisplayObjective = Reflection.getClass("{nms}.PacketPlayOutScoreboardDisplayObjective");
|
||||||
setScoreboardConstants(1);
|
Reflection.FieldAccessor<String> scoreboardDisplayName = Reflection.getField(scoreboardDisplayObjective, String.class, 0);
|
||||||
|
Reflection.FieldAccessor<Integer> scoreboardDisplaySlot = Reflection.getField(scoreboardDisplayObjective, int.class, 0);
|
||||||
|
for(int id = 0; id < 2; id++) {
|
||||||
|
DELETE_SCOREBOARD[id] = Reflection.newInstance(scoreboardObjective);
|
||||||
|
scoreboardName.set(DELETE_SCOREBOARD[id], SIDEBAR + id);
|
||||||
|
scoreboardAction.set(DELETE_SCOREBOARD[id], 1); //1 to remove
|
||||||
|
|
||||||
|
DISPLAY_SIDEBAR[id] = Reflection.newInstance(scoreboardDisplayObjective);
|
||||||
|
scoreboardDisplayName.set(DISPLAY_SIDEBAR[id], SIDEBAR + id);
|
||||||
|
scoreboardDisplaySlot.set(DISPLAY_SIDEBAR[id], 1); // 1 = Sidebar
|
||||||
|
}
|
||||||
|
|
||||||
Bukkit.getScheduler().runTaskTimer(Core.getInstance(), () -> {
|
Bukkit.getScheduler().runTaskTimer(Core.getInstance(), () -> {
|
||||||
toggle ^= 1; // Toggle between 0 and 1
|
toggle ^= 1; // Toggle between 0 and 1
|
||||||
|
|
||||||
for(Map.Entry<Player, ScoreboardCallback> scoreboard : playerBoards.entrySet()) {
|
for(Map.Entry<Player, ScoreboardCallback> scoreboard : playerBoards.entrySet()) {
|
||||||
Player player = scoreboard.getKey();
|
Player player = scoreboard.getKey();
|
||||||
ScoreboardCallback callback = scoreboard.getValue();
|
ScoreboardCallback callback = scoreboard.getValue();
|
||||||
try {
|
|
||||||
manager.sendServerPacket(player, DELETE_SCOREBOARD[toggle]);
|
ChunkListener.protocol.sendPacket(player, DELETE_SCOREBOARD[toggle]);
|
||||||
manager.sendServerPacket(player, createSidebarPacket(callback.getTitle()));
|
ChunkListener.protocol.sendPacket(player, createSidebarPacket(callback.getTitle()));
|
||||||
for(Map.Entry<String, Integer> score : callback.getData().entrySet()){
|
for(Map.Entry<String, Integer> score : callback.getData().entrySet()){
|
||||||
manager.sendServerPacket(player, createScorePacket(score.getKey(), score.getValue()));
|
ChunkListener.protocol.sendPacket(player, createScorePacket(score.getKey(), score.getValue()));
|
||||||
}
|
|
||||||
} catch (InvocationTargetException e) {
|
|
||||||
throw new SecurityException("Could not send scoreboard packets", e);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
Bukkit.getScheduler().runTaskLater(Core.getInstance(), () -> {
|
Bukkit.getScheduler().runTaskLater(Core.getInstance(), () -> {
|
||||||
if(!player.isOnline())
|
if(!player.isOnline())
|
||||||
return;
|
return;
|
||||||
try {
|
ChunkListener.protocol.sendPacket(player, DISPLAY_SIDEBAR[toggle]);
|
||||||
ProtocolLibrary.getProtocolManager().sendServerPacket(player, DISPLAY_SIDEBAR[toggle]);
|
|
||||||
} catch (InvocationTargetException e) {
|
|
||||||
throw new SecurityException("Could not send DISPLAY_SIDEBAR", e);
|
|
||||||
}
|
|
||||||
}, 2);
|
}, 2);
|
||||||
}
|
}
|
||||||
}, 10, 5);
|
}, 10, 5);
|
||||||
@ -81,52 +93,27 @@ public class SWScoreboard {
|
|||||||
}
|
}
|
||||||
|
|
||||||
public static void removeScoreboard(Player player) {
|
public static void removeScoreboard(Player player) {
|
||||||
if(playerBoards.remove(player) == null)
|
if(playerBoards.remove(player) == null || !player.isOnline())
|
||||||
return;
|
return;
|
||||||
|
|
||||||
try {
|
ChunkListener.protocol.sendPacket(player, DELETE_SCOREBOARD[toggle]);
|
||||||
ProtocolLibrary.getProtocolManager().sendServerPacket(player, DELETE_SCOREBOARD[toggle]);
|
|
||||||
} catch (InvocationTargetException e) {
|
|
||||||
throw new SecurityException("Could not send DELETE_PACKET", e);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
private static PacketContainer createSidebarPacket(String name){
|
private static Object createSidebarPacket(String name){
|
||||||
PacketContainer packet = manager.createPacket(PacketType.Play.Server.SCOREBOARD_OBJECTIVE);
|
Object packet = Reflection.newInstance(scoreboardObjective);
|
||||||
packet.getStrings().write(0, SIDEBAR + toggle);
|
scoreboardName.set(packet, SIDEBAR + toggle);
|
||||||
packet.getIntegers().write(0, 0); //0 to create
|
scoreboardAction.set(packet, 0); //0 to create
|
||||||
VersionedRunnable.call(new VersionedRunnable(() -> packet.getStrings().write(1, name), 8),
|
FlatteningWrapper.impl.setScoreboardTitle(packet, name);
|
||||||
new VersionedRunnable(() -> packet.getChatComponents().write(0, WrappedChatComponent.fromText(name)), 14));
|
scoreboardDisplayType.set(packet, displayTypeIntegers);
|
||||||
packet.getEnumModifier(RenderType.class, 2).write(0, RenderType.INTEGER);
|
|
||||||
return packet;
|
return packet;
|
||||||
}
|
}
|
||||||
|
|
||||||
private static PacketContainer createScorePacket(String name, int value){
|
private static Object createScorePacket(String name, int value){
|
||||||
PacketContainer packet = manager.createPacket(PacketType.Play.Server.SCOREBOARD_SCORE);
|
Object packet = Reflection.newInstance(scoreboardScore);
|
||||||
packet.getStrings().write(0, name);
|
scoreName.set(packet, name);
|
||||||
packet.getIntegers().write(0, value);
|
scoreScoreboardName.set(packet, SIDEBAR + toggle);
|
||||||
packet.getStrings().write(1, SIDEBAR + toggle);
|
scoreValue.set(packet, value);
|
||||||
packet.getEnumModifier(Action.class, 3).write(0, Action.CHANGE);
|
FlatteningWrapper.impl.setScoreAction(packet);
|
||||||
return packet;
|
return packet;
|
||||||
}
|
}
|
||||||
|
|
||||||
private enum Action{
|
|
||||||
CHANGE,
|
|
||||||
REMOVE
|
|
||||||
}
|
|
||||||
|
|
||||||
private enum RenderType{
|
|
||||||
INTEGER,
|
|
||||||
HEART
|
|
||||||
}
|
|
||||||
|
|
||||||
private static void setScoreboardConstants(int id){
|
|
||||||
DELETE_SCOREBOARD[id] = manager.createPacket(PacketType.Play.Server.SCOREBOARD_OBJECTIVE);
|
|
||||||
DELETE_SCOREBOARD[id].getStrings().write(0, SIDEBAR + id);
|
|
||||||
DELETE_SCOREBOARD[id].getIntegers().write(0, 1); //1 to remove
|
|
||||||
|
|
||||||
DISPLAY_SIDEBAR[id] = manager.createPacket(PacketType.Play.Server.SCOREBOARD_DISPLAY_OBJECTIVE);
|
|
||||||
DISPLAY_SIDEBAR[id].getStrings().write(0, SIDEBAR + id);
|
|
||||||
DISPLAY_SIDEBAR[id].getIntegers().write(0, 1); // 1 = Sidebar
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
@ -57,6 +57,11 @@ public class EventFight {
|
|||||||
SQL.update("UPDATE EventFight SET Ergebnis = ? WHERE FightID = ?", winner, fightID);
|
SQL.update("UPDATE EventFight SET Ergebnis = ? WHERE FightID = ?", winner, fightID);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public void setFight(int fight){
|
||||||
|
//Fight.FightID, not EventFight.FightID
|
||||||
|
SQL.update("UPDATE EventFight SET Fight = ? WHERE FightID = ?", fight, fightID);
|
||||||
|
}
|
||||||
|
|
||||||
public int getTeamBlue() {
|
public int getTeamBlue() {
|
||||||
return teamBlue;
|
return teamBlue;
|
||||||
}
|
}
|
||||||
|
@ -19,6 +19,8 @@
|
|||||||
|
|
||||||
package de.steamwar.sql;
|
package de.steamwar.sql;
|
||||||
|
|
||||||
|
import java.io.InputStream;
|
||||||
|
import java.sql.Blob;
|
||||||
import java.sql.ResultSet;
|
import java.sql.ResultSet;
|
||||||
import java.sql.SQLException;
|
import java.sql.SQLException;
|
||||||
import java.sql.Timestamp;
|
import java.sql.Timestamp;
|
||||||
@ -27,8 +29,12 @@ public class Fight {
|
|||||||
private Fight(){}
|
private Fight(){}
|
||||||
|
|
||||||
public static int create(String gamemode, String arena, Timestamp starttime, int duration, int blueleader, int redleader, Integer blueschem, Integer redschem, int win, String wincondition){
|
public static int create(String gamemode, String arena, Timestamp starttime, int duration, int blueleader, int redleader, Integer blueschem, Integer redschem, int win, String wincondition){
|
||||||
SQL.update("INSERT INTO Fight (GameMode, Arena, StartTime, Duration, BlueLeader, RedLeader, BlueSchem, RedSchem, Win, WinCondition) VALUES (?, ?, ?, ?, ?, ?, ?, ?, ?, ?)",
|
return create(gamemode, arena, null, starttime, duration, blueleader, redleader, blueschem, redschem, win, wincondition);
|
||||||
gamemode, arena, starttime, duration, blueleader, redleader,blueschem, redschem, win, wincondition);
|
}
|
||||||
|
|
||||||
|
public static int create(String gamemode, String server, String arena, Timestamp starttime, int duration, int blueleader, int redleader, Integer blueschem, Integer redschem, int win, String wincondition){
|
||||||
|
SQL.update("INSERT INTO Fight (GameMode, Server, Arena, StartTime, Duration, BlueLeader, RedLeader, BlueSchem, RedSchem, Win, WinCondition) VALUES (?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?)",
|
||||||
|
gamemode, server, arena, starttime, duration, blueleader, redleader, blueschem, redschem, win, wincondition);
|
||||||
ResultSet rs = SQL.select("SELECT LAST_INSERT_ID() AS FightID");
|
ResultSet rs = SQL.select("SELECT LAST_INSERT_ID() AS FightID");
|
||||||
try{
|
try{
|
||||||
if(!rs.next())
|
if(!rs.next())
|
||||||
@ -39,4 +45,27 @@ public class Fight {
|
|||||||
throw new SecurityException(e);
|
throw new SecurityException(e);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public static InputStream getReplay(int fightID) {
|
||||||
|
ResultSet rs = SQL.select("SELECT Replay FROM Fight WHERE FightID = ?", fightID);
|
||||||
|
try {
|
||||||
|
rs.next();
|
||||||
|
Blob replay = rs.getBlob("Replay");
|
||||||
|
if(replay == null)
|
||||||
|
throw new SecurityException("Replay null");
|
||||||
|
return replay.getBinaryStream();
|
||||||
|
} catch (SQLException e) {
|
||||||
|
throw new SecurityException(e);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public static void setReplay(int fightID, byte[] data) {
|
||||||
|
Blob blob = SQL.blob();
|
||||||
|
try {
|
||||||
|
blob.setBytes(1, data);
|
||||||
|
} catch (SQLException e) {
|
||||||
|
throw new SecurityException(e);
|
||||||
|
}
|
||||||
|
SQL.update("UPDATE Fight SET Replay = ? WHERE FightID = ?", blob, fightID);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
@ -24,18 +24,18 @@ import org.bukkit.configuration.file.YamlConfiguration;
|
|||||||
|
|
||||||
import java.io.File;
|
import java.io.File;
|
||||||
import java.sql.*;
|
import java.sql.*;
|
||||||
|
import java.util.ArrayList;
|
||||||
|
import java.util.List;
|
||||||
|
import java.util.logging.Level;
|
||||||
|
|
||||||
|
|
||||||
public class SQL {
|
public class SQL {
|
||||||
|
|
||||||
private SQL(){}
|
private SQL(){}
|
||||||
|
|
||||||
private static final String host;
|
|
||||||
private static final String port;
|
|
||||||
private static final String database;
|
|
||||||
private static final String user;
|
|
||||||
private static final String password;
|
|
||||||
private static Connection con;
|
private static Connection con;
|
||||||
|
private static String url;
|
||||||
|
private static String user;
|
||||||
|
private static String password;
|
||||||
|
|
||||||
static{
|
static{
|
||||||
File file = new File(Core.getInstance().getDataFolder(), "MySQL.yml");
|
File file = new File(Core.getInstance().getDataFolder(), "MySQL.yml");
|
||||||
@ -44,20 +44,47 @@ public class SQL {
|
|||||||
if(!file.exists())
|
if(!file.exists())
|
||||||
throw new SecurityException("SQL-ConfigFile not found!");
|
throw new SecurityException("SQL-ConfigFile not found!");
|
||||||
|
|
||||||
host = config.getString("HOST");
|
url = "jdbc:mysql://" + config.getString("HOST") + ":" + config.getString("PORT") + "/" + config.getString("DATABASE");
|
||||||
port = config.getString("PORT");
|
|
||||||
database = config.getString("DATABASE");
|
|
||||||
user = config.getString("USER");
|
user = config.getString("USER");
|
||||||
password = config.getString("PASSWORD");
|
password = config.getString("PASSWORD");
|
||||||
|
|
||||||
connect();
|
connect();
|
||||||
}
|
}
|
||||||
|
|
||||||
public static void closeConnection() {
|
private static void connect() {
|
||||||
|
try {
|
||||||
|
con = DriverManager.getConnection(url + "?autoreconnect=true", user, password);
|
||||||
|
} catch (SQLException e) {
|
||||||
|
throw new SecurityException("Could not start SQL connection", e);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public static void close() {
|
||||||
|
for (Statement statement : Statement.statements) {
|
||||||
|
try {
|
||||||
|
statement.st.close();
|
||||||
|
} catch (SQLException e) {
|
||||||
|
Core.getInstance().getLogger().log(Level.INFO, "Could not close statement", e);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
try {
|
try {
|
||||||
con.close();
|
con.close();
|
||||||
}catch (SQLException e) {
|
} catch (SQLException e) {
|
||||||
throw new SecurityException("Could not close connection", e);
|
Core.getInstance().getLogger().log(Level.WARNING, "Could not close SQL-Connection", e);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
private static void reset(SQLException e) {
|
||||||
|
Core.getInstance().getLogger().log(Level.WARNING, "SQL Exception thrown", e);
|
||||||
|
close();
|
||||||
|
connect();
|
||||||
|
try {
|
||||||
|
for (Statement statement : Statement.statements) {
|
||||||
|
statement.init();
|
||||||
|
}
|
||||||
|
} catch (SQLException ex) {
|
||||||
|
throw new SecurityException("Could not reprepare SQL Statements", ex);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -65,7 +92,7 @@ public class SQL {
|
|||||||
try {
|
try {
|
||||||
prepare(qry, objects).executeUpdate();
|
prepare(qry, objects).executeUpdate();
|
||||||
} catch (SQLException e) {
|
} catch (SQLException e) {
|
||||||
reconnect();
|
reset(e);
|
||||||
try {
|
try {
|
||||||
prepare(qry, objects).executeUpdate();
|
prepare(qry, objects).executeUpdate();
|
||||||
} catch (SQLException ex) {
|
} catch (SQLException ex) {
|
||||||
@ -78,7 +105,7 @@ public class SQL {
|
|||||||
try {
|
try {
|
||||||
return prepare(qry, objects).executeQuery();
|
return prepare(qry, objects).executeQuery();
|
||||||
} catch (SQLException e) {
|
} catch (SQLException e) {
|
||||||
reconnect();
|
reset(e);
|
||||||
try {
|
try {
|
||||||
return prepare(qry, objects).executeQuery();
|
return prepare(qry, objects).executeQuery();
|
||||||
} catch (SQLException ex) {
|
} catch (SQLException ex) {
|
||||||
@ -91,7 +118,7 @@ public class SQL {
|
|||||||
try {
|
try {
|
||||||
return con.createBlob();
|
return con.createBlob();
|
||||||
} catch (SQLException e) {
|
} catch (SQLException e) {
|
||||||
reconnect();
|
reset(e);
|
||||||
try {
|
try {
|
||||||
return con.createBlob();
|
return con.createBlob();
|
||||||
} catch (SQLException ex) {
|
} catch (SQLException ex) {
|
||||||
@ -108,18 +135,66 @@ public class SQL {
|
|||||||
return st;
|
return st;
|
||||||
}
|
}
|
||||||
|
|
||||||
private static void connect() {
|
public static class Statement {
|
||||||
|
private static final List<Statement> statements = new ArrayList<>();
|
||||||
|
|
||||||
|
private final String sql;
|
||||||
|
private PreparedStatement st;
|
||||||
|
|
||||||
|
Statement(String sql) {
|
||||||
|
this.sql = sql;
|
||||||
|
statements.add(this);
|
||||||
try {
|
try {
|
||||||
con = DriverManager.getConnection("jdbc:mysql://" + host + ":" + port + "/" + database + "?autoreconnect=true", user, password);
|
init();
|
||||||
if(con.isClosed())
|
} catch (SQLException e) {
|
||||||
throw new SQLException("Could not connect to database!");
|
reset(e);
|
||||||
}catch (SQLException e) {
|
|
||||||
throw new SecurityException("No connection to database.", e);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private static void reconnect(){
|
private synchronized void init() throws SQLException {
|
||||||
closeConnection();
|
st = con.prepareStatement(sql);
|
||||||
connect();
|
}
|
||||||
|
|
||||||
|
<T> T select(ResultSetUser<T> user, Object... objects) {
|
||||||
|
return prepare(() -> {
|
||||||
|
ResultSet rs = st.executeQuery();
|
||||||
|
T result = user.use(rs);
|
||||||
|
rs.close();
|
||||||
|
return result;
|
||||||
|
}, objects);
|
||||||
|
}
|
||||||
|
|
||||||
|
void update(Object... objects) {
|
||||||
|
prepare(st::executeUpdate, objects);
|
||||||
|
}
|
||||||
|
|
||||||
|
private synchronized <T> T prepare(SQLRunnable<T> runnable, Object... objects) {
|
||||||
|
try {
|
||||||
|
setObjects(objects);
|
||||||
|
return runnable.run();
|
||||||
|
} catch (SQLException e) {
|
||||||
|
reset(e);
|
||||||
|
try {
|
||||||
|
setObjects(objects);
|
||||||
|
return runnable.run();
|
||||||
|
} catch (SQLException ex) {
|
||||||
|
throw new SecurityException("Could not execute SQL statement", ex);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
private void setObjects(Object... objects) throws SQLException {
|
||||||
|
for (int i = 0; i < objects.length; i++) {
|
||||||
|
st.setObject(i + 1, objects[i]);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
interface ResultSetUser<T> {
|
||||||
|
T use(ResultSet rs) throws SQLException;
|
||||||
|
}
|
||||||
|
|
||||||
|
private interface SQLRunnable<T> {
|
||||||
|
T run() throws SQLException;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -19,101 +19,13 @@
|
|||||||
|
|
||||||
package de.steamwar.sql;
|
package de.steamwar.sql;
|
||||||
|
|
||||||
import org.apache.logging.log4j.core.LogEvent;
|
|
||||||
import org.bukkit.Bukkit;
|
import org.bukkit.Bukkit;
|
||||||
import org.bukkit.entity.Player;
|
import org.bukkit.entity.Player;
|
||||||
|
|
||||||
import java.util.ArrayList;
|
|
||||||
import java.util.Collections;
|
|
||||||
import java.util.List;
|
|
||||||
|
|
||||||
public class SWException {
|
public class SWException {
|
||||||
private SWException(){}
|
private SWException(){}
|
||||||
|
|
||||||
private static boolean logDisabled = false;
|
public static void log(String message, String stacktrace){
|
||||||
private static final List<String> ignorereasons;
|
|
||||||
|
|
||||||
static {
|
|
||||||
List<String> reasons = new ArrayList<>();
|
|
||||||
reasons.add("Could not save the list after adding a user.");
|
|
||||||
reasons.add("Could not save spigot.yml");
|
|
||||||
reasons.add("Failed to save operators list:");
|
|
||||||
reasons.add("Block at");
|
|
||||||
reasons.add("POI data mismatch");
|
|
||||||
reasons.add("handleDisconnection() called twice");
|
|
||||||
reasons.add("**** SERVER IS RUNNING IN OFFLINE/INSECURE MODE!");
|
|
||||||
reasons.add("The server will make no attempt to authenticate usernames. Beware.");
|
|
||||||
reasons.add("Whilst this makes it possible to use BungeeCord,");
|
|
||||||
reasons.add("Please see http://www.spigotmc.org/wiki/firewall-guide/ for further information.");
|
|
||||||
reasons.add("To change this, set \"online-mode\" to \"true\" in the server.properties file.");
|
|
||||||
reasons.add("This crash report has been saved to:");
|
|
||||||
reasons.add("Could not pass event PlayerQuitEvent to WorldEditSUI");
|
|
||||||
reasons.add("[ViaVersion] ");
|
|
||||||
reasons.add("[ViaBackwards] ");
|
|
||||||
reasons.add("Something went wrong upgrading!");
|
|
||||||
reasons.add("Tried to load unrecognized recipe");
|
|
||||||
reasons.add("Invalid BlockState in palette:");
|
|
||||||
reasons.add("Could not register alias");
|
|
||||||
reasons.add("Can't keep up! Is the server overloaded?");
|
|
||||||
reasons.add("\tat ");
|
|
||||||
reasons.add("java.lang.Exception");
|
|
||||||
reasons.add("An exceptionCaught()");
|
|
||||||
reasons.add("Exception verifying");
|
|
||||||
reasons.add("[WorldEditSUI]");
|
|
||||||
reasons.add("Unsupported key:");
|
|
||||||
reasons.add("ThrownPotion entity");
|
|
||||||
reasons.add("Couldn't load custom particle");
|
|
||||||
reasons.add("Chunk file at [");
|
|
||||||
reasons.add("Ignoring unknown attribute");
|
|
||||||
reasons.add("Skipping player strafe phase because no player was found");
|
|
||||||
reasons.add("Couldn't save chunk; already in use by another instance of Minecraft?");
|
|
||||||
reasons.add("Failed to save player data for ");
|
|
||||||
reasons.add("Failed to check session lock for world located at");
|
|
||||||
reasons.add("Saving oversized chunk ");
|
|
||||||
ignorereasons = Collections.unmodifiableList(reasons);
|
|
||||||
}
|
|
||||||
|
|
||||||
public static void log(LogEvent logEvent){
|
|
||||||
if(logDisabled)
|
|
||||||
return;
|
|
||||||
|
|
||||||
String message = logEvent.getMessage().getFormattedMessage();
|
|
||||||
for(String reason : ignorereasons)
|
|
||||||
if(message.startsWith(reason))
|
|
||||||
return;
|
|
||||||
|
|
||||||
if(message.contains("moved too quickly!") || message.contains("moved wrongly!") || message.contains("was kicked for floating too long!") || message.contains("just tried to change non-editable sign"))
|
|
||||||
return;
|
|
||||||
|
|
||||||
switch (message) {
|
|
||||||
case "The server has stopped responding!":
|
|
||||||
logDisabled = true;
|
|
||||||
return;
|
|
||||||
case "------------------------------":
|
|
||||||
message = "Server stopped responding";
|
|
||||||
logDisabled = true;
|
|
||||||
break;
|
|
||||||
case "Exception stopping the server":
|
|
||||||
logDisabled = true;
|
|
||||||
break;
|
|
||||||
default:
|
|
||||||
}
|
|
||||||
|
|
||||||
StringBuilder stacktrace = new StringBuilder(logEvent.getSource().toString());
|
|
||||||
Throwable throwable = logEvent.getThrown();
|
|
||||||
while(throwable != null){
|
|
||||||
stacktrace.append("\nCaused by ").append(throwable.getClass().getName()).append(": ").append(throwable.getMessage());
|
|
||||||
|
|
||||||
for(StackTraceElement ste : throwable.getStackTrace())
|
|
||||||
stacktrace.append("\n").append(ste.toString());
|
|
||||||
|
|
||||||
throwable = throwable.getCause();
|
|
||||||
}
|
|
||||||
|
|
||||||
String st = stacktrace.toString();
|
|
||||||
if(st.contains("POI data mismatch"))
|
|
||||||
return;
|
|
||||||
|
|
||||||
message += "\n";
|
message += "\n";
|
||||||
for(Player player : Bukkit.getOnlinePlayers())
|
for(Player player : Bukkit.getOnlinePlayers())
|
||||||
message += player.getName() + " ";
|
message += player.getName() + " ";
|
||||||
@ -124,7 +36,6 @@ public class SWException {
|
|||||||
else
|
else
|
||||||
server = Bukkit.getWorlds().get(0).getName();
|
server = Bukkit.getWorlds().get(0).getName();
|
||||||
|
|
||||||
SQL.update("INSERT INTO Exception (server, message, stacktrace) VALUES (?, ?, ?)",
|
SQL.update("INSERT INTO Exception (server, message, stacktrace) VALUES (?, ?, ?)", server, message, stacktrace);
|
||||||
server, message, st);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -64,5 +64,4 @@ public class UserConfig {
|
|||||||
public static void removePlayerConfig(int id, String config) {
|
public static void removePlayerConfig(int id, String config) {
|
||||||
SQL.update("DELETE FROM UserConfig WHERE User = ? AND Config = ?", id, config);
|
SQL.update("DELETE FROM UserConfig WHERE User = ? AND Config = ?", id, config);
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
@ -5,8 +5,6 @@ api-version: "1.13"
|
|||||||
load: STARTUP
|
load: STARTUP
|
||||||
softdepend:
|
softdepend:
|
||||||
- WorldEdit
|
- WorldEdit
|
||||||
depend:
|
|
||||||
- ProtocolLib
|
|
||||||
|
|
||||||
main: de.steamwar.core.Core
|
main: de.steamwar.core.Core
|
||||||
commands:
|
commands:
|
236
build.gradle
Normale Datei
236
build.gradle
Normale Datei
@ -0,0 +1,236 @@
|
|||||||
|
/*
|
||||||
|
* 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/>.
|
||||||
|
*/
|
||||||
|
|
||||||
|
|
||||||
|
import org.apache.tools.ant.taskdefs.condition.Os
|
||||||
|
|
||||||
|
import java.util.function.BiConsumer
|
||||||
|
|
||||||
|
plugins {
|
||||||
|
// Adding the base plugin fixes the following gradle warnings in IntelliJ:
|
||||||
|
//
|
||||||
|
// Warning: root project 'module-work-multi': Unable to resolve all content root directories
|
||||||
|
// Details: java.lang.IllegalStateException: No value has been specified for this provider.
|
||||||
|
//
|
||||||
|
// Warning: root project 'module-work-multi': Unable to resolve additional project configuration.
|
||||||
|
// Details: java.lang.IllegalStateException: No value has been specified for this provider.
|
||||||
|
id 'base'
|
||||||
|
id 'application'
|
||||||
|
|
||||||
|
id 'com.github.johnrengelman.shadow' version '5.0.0'
|
||||||
|
}
|
||||||
|
|
||||||
|
group 'de.steamwar'
|
||||||
|
version ''
|
||||||
|
|
||||||
|
Properties steamwarProperties = new Properties()
|
||||||
|
if (file("steamwar.properties").exists()) {
|
||||||
|
steamwarProperties.load(file("steamwar.properties").newDataInputStream())
|
||||||
|
}
|
||||||
|
|
||||||
|
ext {
|
||||||
|
buildName = 'SpigotCore'
|
||||||
|
artifactName = 'spigotcore'
|
||||||
|
|
||||||
|
uberJarName = "${buildName}-all.jar"
|
||||||
|
jarName = "${artifactName}.jar"
|
||||||
|
libs = "${buildDir}/libs"
|
||||||
|
|
||||||
|
if (Os.isFamily(Os.FAMILY_WINDOWS)) {
|
||||||
|
operatingSystem = "windows"
|
||||||
|
} else {
|
||||||
|
operatingSystem = "unix"
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
compileJava.options.encoding = 'UTF-8'
|
||||||
|
|
||||||
|
sourceCompatibility = 1.8
|
||||||
|
targetCompatibility = 1.8
|
||||||
|
|
||||||
|
mainClassName = ''
|
||||||
|
|
||||||
|
allprojects {
|
||||||
|
repositories {
|
||||||
|
mavenCentral()
|
||||||
|
jcenter()
|
||||||
|
|
||||||
|
maven {
|
||||||
|
url = uri("https://repo.codemc.io/repository/maven-snapshots/")
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
dependencies {
|
||||||
|
implementation project(":SpigotCore_Main")
|
||||||
|
implementation project(":SpigotCore_8")
|
||||||
|
implementation project(":SpigotCore_9")
|
||||||
|
implementation project(":SpigotCore_10")
|
||||||
|
implementation project(":SpigotCore_12")
|
||||||
|
implementation project(":SpigotCore_14")
|
||||||
|
implementation project(":SpigotCore_15")
|
||||||
|
}
|
||||||
|
|
||||||
|
task buildProject {
|
||||||
|
description 'Build this project'
|
||||||
|
group "Steamwar"
|
||||||
|
|
||||||
|
dependsOn build
|
||||||
|
}
|
||||||
|
|
||||||
|
task finalizeProject {
|
||||||
|
description 'Finalize this project'
|
||||||
|
group "Steamwar"
|
||||||
|
|
||||||
|
doLast {
|
||||||
|
if ("${buildDir}" == null) {
|
||||||
|
return
|
||||||
|
}
|
||||||
|
delete fileTree("${libs}").matching {
|
||||||
|
exclude("${uberJarName}")
|
||||||
|
}
|
||||||
|
file(libs + "/" + uberJarName).renameTo(file(libs + "/" + jarName))
|
||||||
|
}
|
||||||
|
}
|
||||||
|
build.finalizedBy(finalizeProject)
|
||||||
|
|
||||||
|
if (steamwarProperties.containsKey("hostname")) {
|
||||||
|
String hostname = steamwarProperties.get("hostname")
|
||||||
|
String uploadPath = steamwarProperties.getOrDefault("uploadPath", "~")
|
||||||
|
|
||||||
|
String server = steamwarProperties.getOrDefault("server", "Dev1.15")
|
||||||
|
String serverStartFlags = steamwarProperties.getOrDefault("serverStartFlags", "")
|
||||||
|
|
||||||
|
task uploadProject {
|
||||||
|
description 'Upload this project'
|
||||||
|
group "Steamwar"
|
||||||
|
|
||||||
|
doLast {
|
||||||
|
await(shell("scp ${libs}/${jarName} ${hostname}:${uploadPath}/${server}/plugins"))
|
||||||
|
if (!answer("Start ${server} server?")) {
|
||||||
|
return
|
||||||
|
}
|
||||||
|
serverStart(server, serverStartFlags, hostname)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
uploadProject.dependsOn(buildProject)
|
||||||
|
|
||||||
|
task startDevServer {
|
||||||
|
description 'Start the DevServer'
|
||||||
|
group "Steamwar"
|
||||||
|
|
||||||
|
doLast {
|
||||||
|
serverStart(server, serverStartFlags, hostname)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
private def await(Process proc) {
|
||||||
|
def out = new StringBuilder()
|
||||||
|
def err = new StringBuilder()
|
||||||
|
proc.waitForProcessOutput(out, err)
|
||||||
|
return [out, err, proc.exitValue()]
|
||||||
|
}
|
||||||
|
|
||||||
|
private def shell(String command) {
|
||||||
|
if (operatingSystem == "unix") {
|
||||||
|
return ['bash', '-c', command].execute()
|
||||||
|
} else {
|
||||||
|
return ["cmd", "/c", command].execute()
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
private def serverStart(String serverName, String serverFlags, String hostname) {
|
||||||
|
def proc = shell("ssh -t ${hostname} \"./mc ${serverFlags} ${serverName}\"")
|
||||||
|
|
||||||
|
Set<String> strings = new HashSet<>()
|
||||||
|
File file = new File("${projectDir}/ignoredlog");
|
||||||
|
if (file.exists()) {
|
||||||
|
new BufferedReader(new InputStreamReader(new FileInputStream(file))).readLines().forEach({ s ->
|
||||||
|
strings.add(s)
|
||||||
|
})
|
||||||
|
}
|
||||||
|
|
||||||
|
Thread outputThread = new Thread({
|
||||||
|
Reader reader = proc.getInputStream().newReader();
|
||||||
|
Writer writer = System.out.newWriter();
|
||||||
|
try {
|
||||||
|
while (proc.alive) {
|
||||||
|
String s = reader.readLine()
|
||||||
|
if (s == null) {
|
||||||
|
return
|
||||||
|
}
|
||||||
|
if (strings.stream().anyMatch({check -> s.contains(check)})) {
|
||||||
|
continue
|
||||||
|
}
|
||||||
|
writer.write(s + "\n")
|
||||||
|
writer.flush()
|
||||||
|
}
|
||||||
|
} catch (IOException e) {
|
||||||
|
// Ignored
|
||||||
|
}
|
||||||
|
})
|
||||||
|
outputThread.setName("${serverName} - OutputThread")
|
||||||
|
outputThread.start()
|
||||||
|
|
||||||
|
Writer writer
|
||||||
|
Thread inputThread = new Thread({
|
||||||
|
Reader reader = System.in.newReader()
|
||||||
|
writer = proc.getOutputStream().newWriter()
|
||||||
|
try {
|
||||||
|
while (proc.alive) {
|
||||||
|
String s = reader.readLine()
|
||||||
|
writer.write(s + "\n")
|
||||||
|
writer.flush()
|
||||||
|
}
|
||||||
|
} catch (IOException e) {
|
||||||
|
// Ignored
|
||||||
|
}
|
||||||
|
})
|
||||||
|
inputThread.setName("${serverName} - InputThread")
|
||||||
|
inputThread.start()
|
||||||
|
|
||||||
|
gradle.buildFinished { buildResult ->
|
||||||
|
if (!proc.alive) {
|
||||||
|
return
|
||||||
|
}
|
||||||
|
writer = proc.getOutputStream().newWriter()
|
||||||
|
writer.write("stop\n")
|
||||||
|
writer.flush()
|
||||||
|
awaitClose(proc, outputThread, inputThread)
|
||||||
|
}
|
||||||
|
awaitClose(proc, outputThread, inputThread)
|
||||||
|
};
|
||||||
|
|
||||||
|
private static def awaitClose(Process proc, Thread outputThread, Thread inputThread) {
|
||||||
|
while (proc.alive) {
|
||||||
|
Thread.sleep(10)
|
||||||
|
}
|
||||||
|
proc.closeStreams()
|
||||||
|
outputThread.interrupt()
|
||||||
|
inputThread.interrupt()
|
||||||
|
}
|
||||||
|
|
||||||
|
private def answer(String question) {
|
||||||
|
while (System.in.available() > 0) System.in.read()
|
||||||
|
println(question)
|
||||||
|
boolean valid = "Yy".contains(((char) System.in.read()).toString())
|
||||||
|
while (System.in.available() > 0) System.in.read()
|
||||||
|
return valid
|
||||||
|
}
|
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 @@
|
|||||||
|
#Wed May 05 10:45:33 CEST 2021
|
||||||
|
distributionUrl=https\://services.gradle.org/distributions/gradle-6.1.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
|
2
ignoredlog
Normale Datei
2
ignoredlog
Normale Datei
@ -0,0 +1,2 @@
|
|||||||
|
SteamWar? Unbekannter Befehl.
|
||||||
|
moved too quickly!
|
43
pom.xml
43
pom.xml
@ -1,43 +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>SpigotCore</artifactId>
|
|
||||||
<version>2.0</version>
|
|
||||||
<packaging>pom</packaging>
|
|
||||||
<url>https://maven.apache.org</url>
|
|
||||||
|
|
||||||
<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>
|
|
||||||
<finalName>${project.name}</finalName>
|
|
||||||
</build>
|
|
||||||
|
|
||||||
<modules>
|
|
||||||
<module>SpigotCore_API</module>
|
|
||||||
<module>SpigotCore_8</module>
|
|
||||||
<module>SpigotCore_9</module>
|
|
||||||
<module>SpigotCore_10</module>
|
|
||||||
<module>SpigotCore_12</module>
|
|
||||||
<module>SpigotCore_14</module>
|
|
||||||
<module>SpigotCore_15</module>
|
|
||||||
<module>SpigotCore_Main</module>
|
|
||||||
</modules>
|
|
||||||
</project>
|
|
28
settings.gradle
Normale Datei
28
settings.gradle
Normale Datei
@ -0,0 +1,28 @@
|
|||||||
|
/*
|
||||||
|
* 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 = 'SpigotCore'
|
||||||
|
|
||||||
|
include 'SpigotCore_Main'
|
||||||
|
include 'SpigotCore_15'
|
||||||
|
include 'SpigotCore_14'
|
||||||
|
include 'SpigotCore_12'
|
||||||
|
include 'SpigotCore_10'
|
||||||
|
include 'SpigotCore_9'
|
||||||
|
include 'SpigotCore_8'
|
8
steamwarci.yml
Normale Datei
8
steamwarci.yml
Normale Datei
@ -0,0 +1,8 @@
|
|||||||
|
build:
|
||||||
|
- "ln -s /home/gitea/lib"
|
||||||
|
- "cp ~/gradle.properties ."
|
||||||
|
- "chmod u+x build.gradle"
|
||||||
|
- "./gradlew buildProject"
|
||||||
|
|
||||||
|
artifacts:
|
||||||
|
"/binarys/spigotcore.jar": "build/libs/spigotcore.jar"
|
In neuem Issue referenzieren
Einen Benutzer sperren