Commits vergleichen
1 Commits
master
...
item_giver
Autor | SHA1 | Datum | |
---|---|---|---|
|
fcde18f0c8 |
204
build.gradle
204
build.gradle
@ -17,6 +17,11 @@
|
|||||||
* along with this program. If not, see <https://www.gnu.org/licenses/>.
|
* 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 {
|
plugins {
|
||||||
// Adding the base plugin fixes the following gradle warnings in IntelliJ:
|
// Adding the base plugin fixes the following gradle warnings in IntelliJ:
|
||||||
//
|
//
|
||||||
@ -30,16 +35,47 @@ plugins {
|
|||||||
id 'application'
|
id 'application'
|
||||||
|
|
||||||
id 'com.github.johnrengelman.shadow' version '5.0.0'
|
id 'com.github.johnrengelman.shadow' version '5.0.0'
|
||||||
id 'de.steamwar.gradle' version 'RELEASE'
|
}
|
||||||
|
|
||||||
|
ext.swdep = { s ->
|
||||||
|
if (file("${rootDir}/lib/${s}.jar").exists()) {
|
||||||
|
return files("${rootDir}/lib/${s}.jar")
|
||||||
|
} else {
|
||||||
|
if (s.contains("-")) {
|
||||||
|
return "de.steamwar:${s.toLowerCase().replace('-', ':')}"
|
||||||
|
} else {
|
||||||
|
return "de.steamwar:${s.toLowerCase()}:RELEASE"
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
group 'de.steamwar'
|
group 'de.steamwar'
|
||||||
version ''
|
version ''
|
||||||
|
|
||||||
|
Properties steamwarProperties = new Properties()
|
||||||
|
if (file("steamwar.properties").exists()) {
|
||||||
|
steamwarProperties.load(file("steamwar.properties").newDataInputStream())
|
||||||
|
}
|
||||||
|
|
||||||
|
ext {
|
||||||
|
buildName = 'MissileWars'
|
||||||
|
artifactName = 'missilewars'
|
||||||
|
|
||||||
|
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'
|
compileJava.options.encoding = 'UTF-8'
|
||||||
|
|
||||||
sourceCompatibility = 11
|
sourceCompatibility = 1.8
|
||||||
targetCompatibility = 11
|
targetCompatibility = 1.8
|
||||||
|
|
||||||
mainClassName = ''
|
mainClassName = ''
|
||||||
|
|
||||||
@ -59,11 +95,11 @@ repositories {
|
|||||||
mavenCentral()
|
mavenCentral()
|
||||||
|
|
||||||
maven {
|
maven {
|
||||||
url = uri("https://repo.codemc.io/repository/maven-snapshots/")
|
url = uri('https://steamwar.de/maven/')
|
||||||
|
credentials {
|
||||||
|
username = steamwarProperties.getProperty("maven.username")
|
||||||
|
password = steamwarProperties.getProperty("maven.password")
|
||||||
}
|
}
|
||||||
|
|
||||||
maven {
|
|
||||||
url = uri('https://hub.spigotmc.org/nexus/content/repositories/snapshots/')
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -73,9 +109,155 @@ dependencies {
|
|||||||
annotationProcessor 'org.projectlombok:lombok:1.18.22'
|
annotationProcessor 'org.projectlombok:lombok:1.18.22'
|
||||||
testAnnotationProcessor 'org.projectlombok:lombok:1.18.22'
|
testAnnotationProcessor 'org.projectlombok:lombok:1.18.22'
|
||||||
|
|
||||||
compileOnly 'org.spigotmc:spigot-api:1.20-R0.1-SNAPSHOT'
|
|
||||||
|
|
||||||
compileOnly swdep("Spigot-1.20")
|
|
||||||
compileOnly swdep('FastAsyncWorldEdit-1.18')
|
|
||||||
compileOnly swdep("SpigotCore")
|
compileOnly swdep("SpigotCore")
|
||||||
|
compileOnly swdep("Spigot-1.15")
|
||||||
|
compileOnly swdep("WorldEdit-1.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", "DevBungee")
|
||||||
|
String serverStartFlags = steamwarProperties.getOrDefault("serverStartFlags", "")
|
||||||
|
|
||||||
|
task uploadProject {
|
||||||
|
description 'Upload this project'
|
||||||
|
group "Steamwar"
|
||||||
|
|
||||||
|
doLast {
|
||||||
|
await(shell("scp ${libs}/${jarName} ${hostname}:${uploadPath}/${server}/plugins"))
|
||||||
|
if (steamwarProperties.getOrDefault("directStart", "false") == "false" && !answer("Start ${server} server?")) {
|
||||||
|
return
|
||||||
|
}
|
||||||
|
serverStart(server, serverStartFlags, hostname)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
uploadProject.dependsOn(buildProject)
|
||||||
|
|
||||||
|
task startDevServer {
|
||||||
|
description 'Start the DevBungee'
|
||||||
|
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
|
||||||
}
|
}
|
@ -17,13 +17,4 @@
|
|||||||
* along with this program. If not, see <https://www.gnu.org/licenses/>.
|
* along with this program. If not, see <https://www.gnu.org/licenses/>.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
pluginManagement {
|
|
||||||
repositories {
|
|
||||||
gradlePluginPortal()
|
|
||||||
maven {
|
|
||||||
url = uri("https://steamwar.de/maven/")
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
rootProject.name = 'MissileWars'
|
rootProject.name = 'MissileWars'
|
@ -4,9 +4,6 @@ ShieldFlyTime: 100
|
|||||||
PlatformTime: 30
|
PlatformTime: 30
|
||||||
EndTime: 200
|
EndTime: 200
|
||||||
|
|
||||||
# Special
|
|
||||||
Barrier: true
|
|
||||||
|
|
||||||
Arena:
|
Arena:
|
||||||
MinX: 0
|
MinX: 0
|
||||||
MaxX: 0
|
MaxX: 0
|
||||||
|
@ -19,9 +19,6 @@
|
|||||||
|
|
||||||
package de.steamwar.misslewars;
|
package de.steamwar.misslewars;
|
||||||
|
|
||||||
import de.steamwar.sql.Event;
|
|
||||||
import de.steamwar.sql.EventFight;
|
|
||||||
import de.steamwar.sql.Team;
|
|
||||||
import org.bukkit.Bukkit;
|
import org.bukkit.Bukkit;
|
||||||
import org.bukkit.Location;
|
import org.bukkit.Location;
|
||||||
import org.bukkit.configuration.ConfigurationSection;
|
import org.bukkit.configuration.ConfigurationSection;
|
||||||
@ -33,8 +30,7 @@ import java.util.UUID;
|
|||||||
import java.util.logging.Level;
|
import java.util.logging.Level;
|
||||||
|
|
||||||
public class Config {
|
public class Config {
|
||||||
private Config() {
|
private Config(){}
|
||||||
}
|
|
||||||
|
|
||||||
public static final int ArenaMinX;
|
public static final int ArenaMinX;
|
||||||
public static final int ArenaMaxX;
|
public static final int ArenaMaxX;
|
||||||
@ -55,25 +51,11 @@ public class Config {
|
|||||||
|
|
||||||
public static final double MissileChance;
|
public static final double MissileChance;
|
||||||
|
|
||||||
public static final boolean Barrier;
|
|
||||||
public static final boolean Space;
|
|
||||||
|
|
||||||
// Challenge
|
|
||||||
public static UUID BlueLeader;
|
public static UUID BlueLeader;
|
||||||
public static UUID RedLeader;
|
public static UUID RedLeader;
|
||||||
|
|
||||||
private static final int EventKampfID;
|
private static final int EventKampfID;
|
||||||
|
|
||||||
// Event
|
|
||||||
public static final EventFight EventKampf;
|
|
||||||
public static final String TeamBlueName;
|
|
||||||
public static final String TeamRedName;
|
|
||||||
public static final String TeamBlueColor;
|
|
||||||
public static final String TeamRedColor;
|
|
||||||
public static final int EventTeamBlueID;
|
|
||||||
public static final int EventTeamRedID;
|
|
||||||
public static final int MaximumTeamMembers;
|
|
||||||
|
|
||||||
static {
|
static {
|
||||||
File configfile = new File(Bukkit.getWorlds().get(0).getWorldFolder(), "config.yml");
|
File configfile = new File(Bukkit.getWorlds().get(0).getWorldFolder(), "config.yml");
|
||||||
if (!configfile.exists()) {
|
if (!configfile.exists()) {
|
||||||
@ -101,80 +83,33 @@ public class Config {
|
|||||||
ConfigurationSection red = config.getConfigurationSection("Red");
|
ConfigurationSection red = config.getConfigurationSection("Red");
|
||||||
assert red != null;
|
assert red != null;
|
||||||
RedPortalZ = red.getInt("PortalZ");
|
RedPortalZ = red.getInt("PortalZ");
|
||||||
RedSpawn = new Location(Bukkit.getWorlds().get(0), red.getDouble("SpawnX"), red.getDouble("SpawnY"), red.getDouble("SpawnZ"), (float) red.getDouble("SpawnYaw"), (float) red.getDouble("SpawnPitch"));
|
RedSpawn = new Location(Bukkit.getWorlds().get(0), red.getDouble("SpawnX"), red.getDouble("SpawnY"), red.getDouble("SpawnZ"), (float)red.getDouble("SpawnYaw"), (float)red.getDouble("SpawnPitch"));
|
||||||
|
|
||||||
ConfigurationSection blue = config.getConfigurationSection("Blue");
|
ConfigurationSection blue = config.getConfigurationSection("Blue");
|
||||||
assert blue != null;
|
assert blue != null;
|
||||||
BluePortalZ = blue.getInt("PortalZ");
|
BluePortalZ = blue.getInt("PortalZ");
|
||||||
BlueSpawn = new Location(Bukkit.getWorlds().get(0), blue.getDouble("SpawnX"), blue.getDouble("SpawnY"), blue.getDouble("SpawnZ"), (float) blue.getDouble("SpawnYaw"), (float) blue.getDouble("SpawnPitch"));
|
BlueSpawn = new Location(Bukkit.getWorlds().get(0), blue.getDouble("SpawnX"), blue.getDouble("SpawnY"), blue.getDouble("SpawnZ"), (float)blue.getDouble("SpawnYaw"), (float)blue.getDouble("SpawnPitch"));
|
||||||
|
|
||||||
String blueLeader = System.getProperty("blueLeader", null);
|
String blueLeader = System.getProperty("blueLeader", null);
|
||||||
String redLeader = System.getProperty("redLeader", null);
|
String redLeader = System.getProperty("redLeader", null);
|
||||||
if (blueLeader != null)
|
if(blueLeader != null)
|
||||||
BlueLeader = UUID.fromString(blueLeader);
|
BlueLeader = UUID.fromString(blueLeader);
|
||||||
else
|
else
|
||||||
BlueLeader = null;
|
BlueLeader = null;
|
||||||
if (redLeader != null)
|
if(redLeader != null)
|
||||||
RedLeader = UUID.fromString(redLeader);
|
RedLeader = UUID.fromString(redLeader);
|
||||||
else
|
else
|
||||||
RedLeader = null;
|
RedLeader = null;
|
||||||
|
|
||||||
Barrier = config.getBoolean("Barrier", false);
|
|
||||||
Space = config.getBoolean("Space", false);
|
|
||||||
|
|
||||||
EventKampfID = Integer.parseInt(System.getProperty("fightID", "0"));
|
EventKampfID = Integer.parseInt(System.getProperty("fightID", "0"));
|
||||||
if (EventKampfID >= 1) {
|
|
||||||
EventKampf = EventFight.get(EventKampfID);
|
|
||||||
if (EventKampf == null) {
|
|
||||||
Bukkit.getLogger().log(Level.SEVERE, "Failed to load EventFight");
|
|
||||||
Bukkit.shutdown();
|
|
||||||
}
|
|
||||||
assert EventKampf != null;
|
|
||||||
|
|
||||||
Team team1 = Team.get(EventKampf.getTeamBlue());
|
|
||||||
Team team2 = Team.get(EventKampf.getTeamRed());
|
|
||||||
|
|
||||||
if (team1 == null || team2 == null) {
|
|
||||||
Bukkit.getLogger().log(Level.SEVERE, "Failed to load Team");
|
|
||||||
Bukkit.shutdown();
|
|
||||||
}
|
|
||||||
assert team1 != null;
|
|
||||||
assert team2 != null;
|
|
||||||
|
|
||||||
TeamBlueName = team1.getTeamKuerzel();
|
|
||||||
TeamRedName = team2.getTeamKuerzel();
|
|
||||||
TeamBlueColor = "§" + team1.getTeamColor();
|
|
||||||
TeamRedColor = "§" + team2.getTeamColor();
|
|
||||||
EventTeamBlueID = team1.getTeamId();
|
|
||||||
EventTeamRedID = team2.getTeamId();
|
|
||||||
|
|
||||||
Event event = Event.get(EventKampf.getEventID());
|
|
||||||
if (EventTeamBlueID == 0 && EventTeamRedID == 0) {
|
|
||||||
MaximumTeamMembers = Integer.MAX_VALUE;
|
|
||||||
} else {
|
|
||||||
MaximumTeamMembers = event.getMaximumTeamMembers();
|
|
||||||
}
|
|
||||||
} else {
|
|
||||||
EventKampf = null;
|
|
||||||
TeamBlueName = "Blau";
|
|
||||||
TeamRedName = "Rot";
|
|
||||||
TeamBlueColor = "§3";
|
|
||||||
TeamRedColor = "§c";
|
|
||||||
EventTeamBlueID = 0;
|
|
||||||
EventTeamRedID = 0;
|
|
||||||
MaximumTeamMembers = Integer.MAX_VALUE;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
public static boolean isEvent() {
|
|
||||||
return EventKampfID >= 1;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public static boolean isChallenge() {
|
public static boolean isChallenge() {
|
||||||
return BlueLeader != null && RedLeader != null;
|
return BlueLeader != null && RedLeader != null;
|
||||||
}
|
}
|
||||||
|
|
||||||
public static boolean test() {
|
public static boolean test(){
|
||||||
return EventKampfID == -1;
|
return EventKampfID == -1;
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
@ -37,8 +37,8 @@ public class FightInfoPacketSender implements Runnable {
|
|||||||
private final String serverName = Bukkit.getServer().getName();
|
private final String serverName = Bukkit.getServer().getName();
|
||||||
private final String gameMode = "missilewars";
|
private final String gameMode = "missilewars";
|
||||||
private final String worldName = world.getName();
|
private final String worldName = world.getName();
|
||||||
private final String blueName = Config.TeamBlueColor + Config.TeamBlueName;
|
private final String blueName = "§3blue";
|
||||||
private final String redName = Config.TeamRedColor + Config.TeamRedName;
|
private final String redName = "§cred";
|
||||||
private final int blueLeader = Config.BlueLeader != null ? SteamwarUser.get(Config.BlueLeader).getId() : 0;
|
private final int blueLeader = Config.BlueLeader != null ? SteamwarUser.get(Config.BlueLeader).getId() : 0;
|
||||||
private final int redLeader = Config.RedLeader != null ? SteamwarUser.get(Config.RedLeader).getId() : 0;
|
private final int redLeader = Config.RedLeader != null ? SteamwarUser.get(Config.RedLeader).getId() : 0;
|
||||||
|
|
||||||
|
@ -19,31 +19,24 @@
|
|||||||
|
|
||||||
package de.steamwar.misslewars;
|
package de.steamwar.misslewars;
|
||||||
|
|
||||||
import de.steamwar.scoreboard.SWScoreboard;
|
|
||||||
import de.steamwar.scoreboard.ScoreboardCallback;
|
|
||||||
import org.bukkit.Bukkit;
|
import org.bukkit.Bukkit;
|
||||||
import org.bukkit.event.EventHandler;
|
|
||||||
import org.bukkit.event.Listener;
|
|
||||||
import org.bukkit.event.player.PlayerJoinEvent;
|
|
||||||
import org.bukkit.event.player.PlayerQuitEvent;
|
|
||||||
import org.bukkit.scoreboard.DisplaySlot;
|
import org.bukkit.scoreboard.DisplaySlot;
|
||||||
import org.bukkit.scoreboard.Objective;
|
import org.bukkit.scoreboard.Objective;
|
||||||
import org.bukkit.scoreboard.Scoreboard;
|
import org.bukkit.scoreboard.Scoreboard;
|
||||||
|
|
||||||
import java.text.SimpleDateFormat;
|
import java.text.SimpleDateFormat;
|
||||||
import java.util.HashMap;
|
|
||||||
import java.util.Objects;
|
import java.util.Objects;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Modified Version of the Fight-System Scoreboard
|
* Modified Version of the Fight-System Scoreboard
|
||||||
*/
|
*/
|
||||||
class FightScoreboard implements Listener {
|
class FightScoreboard {
|
||||||
|
|
||||||
public FightScoreboard() {
|
private FightScoreboard(){}
|
||||||
Bukkit.getPluginManager().registerEvents(this, MissileWars.getPlugin());
|
|
||||||
}
|
|
||||||
|
|
||||||
private static final Scoreboard scoreboard = Objects.requireNonNull(Bukkit.getScoreboardManager()).getMainScoreboard();
|
private static final Scoreboard scoreboard = Objects.requireNonNull(Bukkit.getScoreboardManager()).getMainScoreboard();
|
||||||
|
private static final Objective objective;
|
||||||
|
private static final SimpleDateFormat format = new SimpleDateFormat("HH:mm:ss");
|
||||||
|
|
||||||
private static long startTime = 0;
|
private static long startTime = 0;
|
||||||
|
|
||||||
@ -51,37 +44,34 @@ class FightScoreboard implements Listener {
|
|||||||
return startTime;
|
return startTime;
|
||||||
}
|
}
|
||||||
|
|
||||||
@EventHandler
|
static{
|
||||||
public void onPlayerJoin(PlayerJoinEvent event) {
|
if(scoreboard.getObjective("AAA") == null)
|
||||||
SWScoreboard.createScoreboard(event.getPlayer(), new ScoreboardCallback() {
|
objective = scoreboard.registerNewObjective("AAA", "BBB", "MissleWars");
|
||||||
@Override
|
else
|
||||||
public String getTitle() {
|
objective = scoreboard.getObjective("AAA");
|
||||||
return "§eMissileWars";
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
static void init(){
|
||||||
public HashMap<String, Integer> getData() {
|
Bukkit.getScheduler().scheduleSyncRepeatingTask(MissileWars.getPlugin(), () -> {
|
||||||
HashMap<String, Integer> data = new HashMap<>();
|
objective.unregister();
|
||||||
data.put("§eSpielzeit", 5);
|
scoreboard.registerNewObjective("AAA", "BBB", "MissleWars");
|
||||||
|
objective.setDisplaySlot(DisplaySlot.SIDEBAR);
|
||||||
|
objective.setDisplayName("§eMissileWars");
|
||||||
|
|
||||||
|
objective.getScore("§eSpielzeit").setScore(5);
|
||||||
if (startTime == 0) {
|
if (startTime == 0) {
|
||||||
data.put("§7??:??:??", 4);
|
objective.getScore("§7??:??:??").setScore(4);
|
||||||
} else {
|
} else {
|
||||||
long current_time = System.currentTimeMillis() - startTime;
|
long current_time = System.currentTimeMillis() - startTime;
|
||||||
data.put(String.format("§7%02d:%02d", current_time / 60000, (current_time / 1000) % 60), 4);
|
objective.getScore(String.format("§7%02d:%02d", current_time / 60000, (current_time / 1000) % 60)).setScore(4);
|
||||||
}
|
}
|
||||||
|
objective.getScore("").setScore(3);
|
||||||
|
objective.getScore("§eSpieler").setScore(2);
|
||||||
|
MissileWars.getBlueTeam().teamScoreboard(objective);
|
||||||
|
MissileWars.getRedTeam().teamScoreboard(objective);
|
||||||
|
|
||||||
data.put("", 3);
|
Bukkit.getOnlinePlayers().forEach(player -> player.setScoreboard(scoreboard));
|
||||||
data.put("§eSpieler", 2);
|
}, 0, 50);
|
||||||
MissileWars.getBlueTeam().teamScoreboard(data);
|
|
||||||
MissileWars.getRedTeam().teamScoreboard(data);
|
|
||||||
return data;
|
|
||||||
}
|
|
||||||
});
|
|
||||||
}
|
|
||||||
|
|
||||||
@EventHandler
|
|
||||||
public void onPlayerQuit(PlayerQuitEvent event) {
|
|
||||||
SWScoreboard.removeScoreboard(event.getPlayer());
|
|
||||||
}
|
}
|
||||||
|
|
||||||
static Scoreboard getScoreboard() {
|
static Scoreboard getScoreboard() {
|
||||||
@ -91,4 +81,5 @@ class FightScoreboard implements Listener {
|
|||||||
static void startTime() {
|
static void startTime() {
|
||||||
startTime = System.currentTimeMillis();
|
startTime = System.currentTimeMillis();
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
@ -22,11 +22,11 @@
|
|||||||
package de.steamwar.misslewars;
|
package de.steamwar.misslewars;
|
||||||
|
|
||||||
import de.steamwar.core.CraftbukkitWrapper;
|
import de.steamwar.core.CraftbukkitWrapper;
|
||||||
import net.minecraft.world.level.chunk.Chunk;
|
import net.minecraft.server.v1_15_R1.Chunk;
|
||||||
import org.bukkit.Bukkit;
|
import org.bukkit.Bukkit;
|
||||||
import org.bukkit.World;
|
import org.bukkit.World;
|
||||||
import org.bukkit.WorldCreator;
|
import org.bukkit.WorldCreator;
|
||||||
import org.bukkit.craftbukkit.v1_20_R1.CraftWorld;
|
import org.bukkit.craftbukkit.v1_15_R1.CraftWorld;
|
||||||
import org.bukkit.entity.Entity;
|
import org.bukkit.entity.Entity;
|
||||||
import org.bukkit.entity.EntityType;
|
import org.bukkit.entity.EntityType;
|
||||||
import org.bukkit.entity.Player;
|
import org.bukkit.entity.Player;
|
||||||
@ -36,6 +36,11 @@ import java.util.function.ObjIntConsumer;
|
|||||||
public class FightWorld {
|
public class FightWorld {
|
||||||
|
|
||||||
private static final World world = Bukkit.getWorlds().get(0);
|
private static final World world = Bukkit.getWorlds().get(0);
|
||||||
|
private static final boolean paper = Bukkit.getVersion().contains("git-Paper");
|
||||||
|
|
||||||
|
private static boolean isPaper(){
|
||||||
|
return paper;
|
||||||
|
}
|
||||||
|
|
||||||
private static double posToChunk(int pos){
|
private static double posToChunk(int pos){
|
||||||
return pos / 16.0;
|
return pos / 16.0;
|
||||||
@ -64,7 +69,11 @@ public class FightWorld {
|
|||||||
}
|
}
|
||||||
|
|
||||||
public static void resetWorld(){
|
public static void resetWorld(){
|
||||||
world.getEntities().stream().filter(entity -> entity.getType() != EntityType.PLAYER).forEach(Entity::remove);
|
for(Entity entity : world.getEntities()){
|
||||||
|
if(entity.getType() != EntityType.PLAYER){
|
||||||
|
entity.remove();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
World backup = new WorldCreator(world.getName() + "/backup").createWorld();
|
World backup = new WorldCreator(world.getName() + "/backup").createWorld();
|
||||||
assert backup != null;
|
assert backup != null;
|
||||||
@ -73,12 +82,21 @@ public class FightWorld {
|
|||||||
}
|
}
|
||||||
|
|
||||||
private static void resetChunk(World world, World backup, int x, int z) {
|
private static void resetChunk(World world, World backup, int x, int z) {
|
||||||
Chunk chunk = ((CraftWorld) world).getHandle().d(x, z);
|
net.minecraft.server.v1_15_R1.World w = ((CraftWorld) world).getHandle();
|
||||||
Chunk backupChunk = ((CraftWorld) backup).getHandle().d(x, z);
|
Chunk chunk = w.getChunkAt(x, z);
|
||||||
|
Chunk backupChunk = ((CraftWorld) backup).getHandle().getChunkAt(x, z);
|
||||||
|
|
||||||
System.arraycopy(backupChunk.d(), 0, chunk.d(), 0, chunk.d().length);
|
System.arraycopy(backupChunk.getSections(), 0, chunk.getSections(), 0, chunk.getSections().length);
|
||||||
|
w.tileEntityListTick.removeAll(chunk.tileEntities.values());
|
||||||
for(Player p : Bukkit.getOnlinePlayers())
|
if (!FightWorld.isPaper()) {
|
||||||
|
w.tileEntityList.removeAll(chunk.tileEntities.values());
|
||||||
|
}
|
||||||
|
chunk.tileEntities.clear();
|
||||||
|
chunk.tileEntities.putAll(backupChunk.tileEntities);
|
||||||
|
chunk.heightMap.clear();
|
||||||
|
chunk.heightMap.putAll(backupChunk.heightMap);
|
||||||
|
for(Player p : Bukkit.getOnlinePlayers()){
|
||||||
CraftbukkitWrapper.impl.sendChunk(p, x, z);
|
CraftbukkitWrapper.impl.sendChunk(p, x, z);
|
||||||
}
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
@ -19,23 +19,19 @@
|
|||||||
|
|
||||||
package de.steamwar.misslewars;
|
package de.steamwar.misslewars;
|
||||||
|
|
||||||
import lombok.Getter;
|
import org.bukkit.*;
|
||||||
import org.bukkit.ChatColor;
|
|
||||||
import org.bukkit.GameMode;
|
|
||||||
import org.bukkit.Location;
|
|
||||||
import org.bukkit.Material;
|
|
||||||
import org.bukkit.enchantments.Enchantment;
|
import org.bukkit.enchantments.Enchantment;
|
||||||
import org.bukkit.entity.Player;
|
import org.bukkit.entity.Player;
|
||||||
import org.bukkit.inventory.Inventory;
|
import org.bukkit.inventory.Inventory;
|
||||||
import org.bukkit.inventory.ItemStack;
|
import org.bukkit.inventory.ItemStack;
|
||||||
import org.bukkit.inventory.meta.Damageable;
|
|
||||||
import org.bukkit.inventory.meta.ItemMeta;
|
import org.bukkit.inventory.meta.ItemMeta;
|
||||||
|
import org.bukkit.scoreboard.Objective;
|
||||||
import org.bukkit.scoreboard.Team;
|
import org.bukkit.scoreboard.Team;
|
||||||
|
|
||||||
import java.util.*;
|
import java.util.*;
|
||||||
|
|
||||||
public class MWTeam {
|
public class MWTeam {
|
||||||
public static final ItemStack bow = new ItemStack(Material.BOW);
|
private static final ItemStack bow = new ItemStack(Material.BOW);
|
||||||
|
|
||||||
static {
|
static {
|
||||||
ItemMeta bowMeta = Objects.requireNonNull(bow.getItemMeta());
|
ItemMeta bowMeta = Objects.requireNonNull(bow.getItemMeta());
|
||||||
@ -47,30 +43,27 @@ public class MWTeam {
|
|||||||
bow.setItemMeta(bowMeta);
|
bow.setItemMeta(bowMeta);
|
||||||
}
|
}
|
||||||
|
|
||||||
private final String color;
|
private final ChatColor color;
|
||||||
private final String teamName;
|
private final String teamName;
|
||||||
private final Team sbteam; //scoreboard-Team
|
private final Team sbteam; //scoreboard-Team
|
||||||
@Getter
|
|
||||||
private final Location spawn;
|
private final Location spawn;
|
||||||
@Getter
|
|
||||||
private final int portalZ;
|
private final int portalZ;
|
||||||
|
|
||||||
@Getter
|
|
||||||
private final LinkedList<Player> players = new LinkedList<>();
|
private final LinkedList<Player> players = new LinkedList<>();
|
||||||
private final Set<Player> openInvitations = new HashSet<>();
|
private final Set<Player> openInvitations = new HashSet<>();
|
||||||
|
|
||||||
MWTeam(String color, Location spawn, String teamName, int portalZ) {
|
MWTeam(ChatColor color, Location spawn, String teamName, int portalZ) {
|
||||||
this.teamName = teamName;
|
this.teamName = teamName;
|
||||||
this.color = color;
|
this.color = color;
|
||||||
this.spawn = spawn;
|
this.spawn = spawn;
|
||||||
this.portalZ = portalZ;
|
this.portalZ = portalZ;
|
||||||
if (FightScoreboard.getScoreboard().getTeam(teamName) == null)
|
if(FightScoreboard.getScoreboard().getTeam(teamName) == null)
|
||||||
sbteam = FightScoreboard.getScoreboard().registerNewTeam(teamName);
|
sbteam = FightScoreboard.getScoreboard().registerNewTeam(teamName);
|
||||||
else
|
else
|
||||||
sbteam = FightScoreboard.getScoreboard().getTeam(teamName);
|
sbteam = FightScoreboard.getScoreboard().getTeam(teamName);
|
||||||
assert sbteam != null;
|
assert sbteam != null;
|
||||||
sbteam.setAllowFriendlyFire(false);
|
sbteam.setAllowFriendlyFire(false);
|
||||||
sbteam.setColor(ChatColor.getByChar(color.charAt(1)));
|
sbteam.setColor(color);
|
||||||
}
|
}
|
||||||
|
|
||||||
public void countdown(int timeDelay, int offset) {
|
public void countdown(int timeDelay, int offset) {
|
||||||
@ -88,43 +81,6 @@ public class MWTeam {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private int getUsesOfItem(ItemStack itemStack) {
|
|
||||||
ItemMeta itemMeta = itemStack.getItemMeta();
|
|
||||||
if (itemMeta instanceof Damageable) {
|
|
||||||
Damageable damageable = (Damageable) itemMeta;
|
|
||||||
return itemStack.getType().getMaxDurability() - damageable.getDamage();
|
|
||||||
}
|
|
||||||
return 1_000_000;
|
|
||||||
}
|
|
||||||
|
|
||||||
private boolean hasUses(ItemStack itemStack) {
|
|
||||||
switch (itemStack.getType()) {
|
|
||||||
case WOODEN_AXE:
|
|
||||||
case STONE_AXE:
|
|
||||||
case IRON_AXE:
|
|
||||||
case GOLDEN_AXE:
|
|
||||||
case DIAMOND_AXE:
|
|
||||||
case NETHERITE_AXE:
|
|
||||||
// return true;
|
|
||||||
case WOODEN_SHOVEL:
|
|
||||||
case STONE_SHOVEL:
|
|
||||||
case IRON_SHOVEL:
|
|
||||||
case GOLDEN_SHOVEL:
|
|
||||||
case DIAMOND_SHOVEL:
|
|
||||||
case NETHERITE_SHOVEL:
|
|
||||||
// return true;
|
|
||||||
case WOODEN_PICKAXE:
|
|
||||||
case STONE_PICKAXE:
|
|
||||||
case IRON_PICKAXE:
|
|
||||||
case GOLDEN_PICKAXE:
|
|
||||||
case DIAMOND_PICKAXE:
|
|
||||||
case NETHERITE_PICKAXE:
|
|
||||||
return true;
|
|
||||||
default:
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
public void givePlayerItem(ItemStack item) {
|
public void givePlayerItem(ItemStack item) {
|
||||||
if (players.isEmpty()) {
|
if (players.isEmpty()) {
|
||||||
return;
|
return;
|
||||||
@ -133,44 +89,42 @@ public class MWTeam {
|
|||||||
players.addLast(p);
|
players.addLast(p);
|
||||||
|
|
||||||
Inventory inventory = p.getInventory();
|
Inventory inventory = p.getInventory();
|
||||||
for (int i = 0; i <= 35; i++) { // 35 is the last normal inventory slot
|
for (int i = 0; i <= 35; i++) { //35 is the last normal inventory slot
|
||||||
ItemStack itemStack = inventory.getItem(i);
|
ItemStack itemStack = inventory.getItem(i);
|
||||||
if (itemStack == null) continue;
|
if (itemStack != null && itemStack.isSimilar(item) && itemStack.getAmount() + item.getAmount() <= itemStack.getMaxStackSize()) {
|
||||||
if (itemStack.isSimilar(item) && itemStack.getAmount() + item.getAmount() <= item.getMaxStackSize()) {
|
|
||||||
itemStack.setAmount(itemStack.getAmount() + item.getAmount());
|
itemStack.setAmount(itemStack.getAmount() + item.getAmount());
|
||||||
inventory.setItem(i, itemStack);
|
inventory.setItem(i, itemStack);
|
||||||
return;
|
p.updateInventory();
|
||||||
}
|
|
||||||
if (hasUses(itemStack) && hasUses(item) && getUsesOfItem(itemStack) + getUsesOfItem(item) <= itemStack.getType().getMaxDurability()) {
|
|
||||||
int uses = getUsesOfItem(itemStack) + getUsesOfItem(item);
|
|
||||||
ItemMeta itemMeta = itemStack.getItemMeta();
|
|
||||||
Damageable damageable = (Damageable) itemMeta;
|
|
||||||
damageable.setDamage(itemStack.getType().getMaxDurability() - uses);
|
|
||||||
itemStack.setItemMeta(damageable);
|
|
||||||
inventory.setItem(i, itemStack);
|
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
for (int i = 0; i <= 35; i++) { // 35 is the last normal inventory slot
|
for (int i = 0; i <= 35; i++) { //35 is the last normal inventory slot
|
||||||
ItemStack itemStack = inventory.getItem(i);
|
ItemStack itemStack = inventory.getItem(i);
|
||||||
if (itemStack == null || itemStack.getType().equals(Material.AIR)) {
|
if (itemStack == null || itemStack.getType().equals(Material.AIR)) {
|
||||||
inventory.setItem(i, item);
|
inventory.setItem(i, item);
|
||||||
|
p.updateInventory();
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public void teamScoreboard(HashMap<String, Integer> data) {
|
public void teamScoreboard(Objective objective) {
|
||||||
players.forEach(player -> {
|
players.forEach(p -> objective.getScore(getColorCode() + p.getName()).setScore(1));
|
||||||
data.put(getColorCode() + player.getName(), 1);
|
|
||||||
});
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public int size() {
|
public int size() {
|
||||||
return players.size();
|
return players.size();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public int getPortalZ() {
|
||||||
|
return portalZ;
|
||||||
|
}
|
||||||
|
|
||||||
|
public Location getSpawn(){
|
||||||
|
return spawn;
|
||||||
|
}
|
||||||
|
|
||||||
public void join(Player p) {
|
public void join(Player p) {
|
||||||
players.add(p);
|
players.add(p);
|
||||||
p.teleport(spawn);
|
p.teleport(spawn);
|
||||||
@ -228,8 +182,8 @@ public class MWTeam {
|
|||||||
return MissileWars.getRedTeam();
|
return MissileWars.getRedTeam();
|
||||||
}
|
}
|
||||||
|
|
||||||
public String getColorCode() {
|
public String getColorCode(){
|
||||||
return color;
|
return "§" + color.getChar();
|
||||||
}
|
}
|
||||||
|
|
||||||
public boolean hasPlayer(Player p) {
|
public boolean hasPlayer(Player p) {
|
||||||
@ -241,11 +195,16 @@ public class MWTeam {
|
|||||||
}
|
}
|
||||||
|
|
||||||
public String getColoredName() {
|
public String getColoredName() {
|
||||||
return color + teamName;
|
return color.toString() + teamName;
|
||||||
|
}
|
||||||
|
|
||||||
|
public LinkedList<Player> getPlayers() {
|
||||||
|
return players;
|
||||||
}
|
}
|
||||||
|
|
||||||
public static void removeInvitations(Player p) {
|
public static void removeInvitations(Player p) {
|
||||||
MissileWars.getRedTeam().openInvitations.remove(p);
|
MissileWars.getRedTeam().openInvitations.remove(p);
|
||||||
MissileWars.getBlueTeam().openInvitations.remove(p);
|
MissileWars.getBlueTeam().openInvitations.remove(p);
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
@ -1,7 +1,7 @@
|
|||||||
/*
|
/*
|
||||||
This file is a part of the SteamWar software.
|
This file is a part of the SteamWar software.
|
||||||
|
|
||||||
Copyright (C) 2023 SteamWar.de-Serverteam
|
Copyright (C) 2020 SteamWar.de-Serverteam
|
||||||
|
|
||||||
This program is free software: you can redistribute it and/or modify
|
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
|
it under the terms of the GNU Affero General Public License as published by
|
||||||
@ -19,23 +19,21 @@
|
|||||||
|
|
||||||
package de.steamwar.misslewars;
|
package de.steamwar.misslewars;
|
||||||
|
|
||||||
import de.steamwar.misslewars.commands.AcceptCommand;
|
import de.steamwar.misslewars.commands.CommandAcceptDecline;
|
||||||
import de.steamwar.misslewars.commands.DeclineCommand;
|
import de.steamwar.misslewars.commands.CommandInvite;
|
||||||
import de.steamwar.misslewars.commands.InviteCommand;
|
import de.steamwar.misslewars.commands.CommandItems;
|
||||||
import de.steamwar.misslewars.commands.SpectateCommand;
|
import de.steamwar.misslewars.commands.CommandSpectate;
|
||||||
import de.steamwar.misslewars.countdowns.EndCountdown;
|
import de.steamwar.misslewars.countdowns.EndCountdown;
|
||||||
import de.steamwar.misslewars.countdowns.ItemCountdown;
|
import de.steamwar.misslewars.countdowns.ItemCountdown;
|
||||||
import de.steamwar.misslewars.countdowns.WaitingCountdown;
|
import de.steamwar.misslewars.countdowns.WaitingCountdown;
|
||||||
import de.steamwar.misslewars.items.CustomItem;
|
import de.steamwar.misslewars.items.CustomItem;
|
||||||
import de.steamwar.misslewars.items.Missile;
|
import de.steamwar.misslewars.items.Missile;
|
||||||
import de.steamwar.misslewars.listener.*;
|
import de.steamwar.misslewars.listener.*;
|
||||||
import de.steamwar.misslewars.listener.special.BarrierListener;
|
|
||||||
import de.steamwar.misslewars.listener.special.SpaceListener;
|
|
||||||
import de.steamwar.misslewars.slowmo.SlowMoRunner;
|
import de.steamwar.misslewars.slowmo.SlowMoRunner;
|
||||||
import de.steamwar.network.NetworkSender;
|
import org.bukkit.Bukkit;
|
||||||
import de.steamwar.network.packets.common.FightEndsPacket;
|
import org.bukkit.ChatColor;
|
||||||
import de.steamwar.sql.SteamwarUser;
|
import org.bukkit.GameMode;
|
||||||
import org.bukkit.*;
|
import org.bukkit.Sound;
|
||||||
import org.bukkit.entity.Entity;
|
import org.bukkit.entity.Entity;
|
||||||
import org.bukkit.entity.Player;
|
import org.bukkit.entity.Player;
|
||||||
import org.bukkit.plugin.java.JavaPlugin;
|
import org.bukkit.plugin.java.JavaPlugin;
|
||||||
@ -61,8 +59,8 @@ public class MissileWars extends JavaPlugin {
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void onEnable() {
|
public void onEnable() {
|
||||||
redTeam = new MWTeam(Config.TeamRedColor, Config.RedSpawn, Config.TeamRedName, Config.RedPortalZ);
|
redTeam = new MWTeam(ChatColor.RED, Config.RedSpawn, "Rot", Config.RedPortalZ);
|
||||||
blueTeam = new MWTeam(Config.TeamBlueColor, Config.BlueSpawn, Config.TeamBlueName, Config.BluePortalZ);
|
blueTeam = new MWTeam(ChatColor.DARK_AQUA, Config.BlueSpawn, "Blau", Config.BluePortalZ);
|
||||||
new BreakListener();
|
new BreakListener();
|
||||||
new DeathListener();
|
new DeathListener();
|
||||||
new ItemListener();
|
new ItemListener();
|
||||||
@ -74,35 +72,31 @@ public class MissileWars extends JavaPlugin {
|
|||||||
new WaitingListener();
|
new WaitingListener();
|
||||||
new FightListener();
|
new FightListener();
|
||||||
new ChatListener();
|
new ChatListener();
|
||||||
new SpectateCommand();
|
getCommand("spectate").setExecutor(new CommandSpectate());
|
||||||
|
|
||||||
// Invitation Commands
|
// Invitation Commands
|
||||||
new InviteCommand();
|
CommandInvite commandInvite = new CommandInvite();
|
||||||
new AcceptCommand();
|
getCommand("invite").setExecutor(commandInvite);
|
||||||
new DeclineCommand();
|
getCommand("invite").setTabCompleter(commandInvite);
|
||||||
|
|
||||||
|
getCommand("accept").setExecutor(new CommandAcceptDecline());
|
||||||
|
getCommand("decline").setExecutor(new CommandAcceptDecline());
|
||||||
|
|
||||||
new WaitingCountdown();
|
new WaitingCountdown();
|
||||||
new ItemCountdown();
|
new ItemCountdown();
|
||||||
new EndCountdown();
|
new EndCountdown();
|
||||||
|
|
||||||
new FightScoreboard();
|
FightScoreboard.init();
|
||||||
|
|
||||||
Missile.init();
|
Missile.init();
|
||||||
CustomItem.init();
|
CustomItem.init();
|
||||||
|
|
||||||
StateDependent.setupState(fightState);
|
StateDependent.setupState(fightState);
|
||||||
|
|
||||||
new BarrierListener();
|
|
||||||
new SpaceListener();
|
|
||||||
|
|
||||||
Bukkit.getScheduler().runTaskTimer(this, new FightInfoPacketSender(), 20, 20);
|
Bukkit.getScheduler().runTaskTimer(this, new FightInfoPacketSender(), 20, 20);
|
||||||
|
if(Config.test()) {
|
||||||
Bukkit.getWorlds().forEach(world -> {
|
new CommandItems();
|
||||||
world.setGameRule(GameRule.KEEP_INVENTORY, true);
|
}
|
||||||
world.setGameRule(GameRule.MOB_GRIEFING, true);
|
|
||||||
world.setGameRule(GameRule.DO_TILE_DROPS, false);
|
|
||||||
});
|
|
||||||
|
|
||||||
// TODO: Enable Item Dropping, and the own team can pick them up! Add config value for that?
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public static void waiting() {
|
public static void waiting() {
|
||||||
@ -149,23 +143,6 @@ public class MissileWars extends JavaPlugin {
|
|||||||
player.setGameMode(GameMode.SPECTATOR);
|
player.setGameMode(GameMode.SPECTATOR);
|
||||||
}
|
}
|
||||||
|
|
||||||
byte ergebnis = winner == blueTeam ? (byte) 1 : (byte) 2;
|
|
||||||
if (Config.isEvent()) {
|
|
||||||
Config.EventKampf.setErgebnis(ergebnis);
|
|
||||||
}
|
|
||||||
if (Config.isEvent() || Config.isChallenge()) {
|
|
||||||
FightEndsPacket packet = FightEndsPacket.builder()
|
|
||||||
.gameMode("MissileWars")
|
|
||||||
.duration((int)((System.currentTimeMillis() - FightScoreboard.getStartTime()) / 1000))
|
|
||||||
.win(ergebnis)
|
|
||||||
.bluePlayers(blueTeam.getPlayers().stream().map(Player::getUniqueId).map(SteamwarUser::get).map(SteamwarUser::getId).collect(Collectors.toList()))
|
|
||||||
.redPlayers(redTeam.getPlayers().stream().map(Player::getUniqueId).map(SteamwarUser::get).map(SteamwarUser::getId).collect(Collectors.toList()))
|
|
||||||
.blueSchem(-1)
|
|
||||||
.redSchem(-1)
|
|
||||||
.build();
|
|
||||||
NetworkSender.send(packet);
|
|
||||||
}
|
|
||||||
|
|
||||||
switch (reason) {
|
switch (reason) {
|
||||||
case PORTAL_DESTROYED:
|
case PORTAL_DESTROYED:
|
||||||
Bukkit.getServer().broadcastMessage(winner.getColoredName() + ChatColor.RESET + " §7hat das gegnerische Portal zerstört");
|
Bukkit.getServer().broadcastMessage(winner.getColoredName() + ChatColor.RESET + " §7hat das gegnerische Portal zerstört");
|
||||||
@ -209,6 +186,14 @@ public class MissileWars extends JavaPlugin {
|
|||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public static void join(Player p) {
|
||||||
|
if (MissileWars.getRedTeam().size() < MissileWars.getBlueTeam().size()) {
|
||||||
|
MissileWars.getRedTeam().join(p);
|
||||||
|
} else {
|
||||||
|
MissileWars.getBlueTeam().join(p);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
public static void leave(Player p) {
|
public static void leave(Player p) {
|
||||||
MissileWars.getBlueTeam().leave(p);
|
MissileWars.getBlueTeam().leave(p);
|
||||||
MissileWars.getRedTeam().leave(p);
|
MissileWars.getRedTeam().leave(p);
|
||||||
|
@ -2,7 +2,7 @@
|
|||||||
*
|
*
|
||||||
* This file is a part of the SteamWar software.
|
* This file is a part of the SteamWar software.
|
||||||
*
|
*
|
||||||
* Copyright (C) 2023 SteamWar.de-Serverteam
|
* Copyright (C) 2020 SteamWar.de-Serverteam
|
||||||
*
|
*
|
||||||
* This program is free software: you can redistribute it and/or modify
|
* 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
|
* it under the terms of the GNU Affero General Public License as published by
|
||||||
@ -16,55 +16,49 @@
|
|||||||
*
|
*
|
||||||
* 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.misslewars.commands;
|
package de.steamwar.misslewars.commands;
|
||||||
|
|
||||||
import de.steamwar.command.SWCommand;
|
|
||||||
import de.steamwar.command.TypeValidator;
|
|
||||||
import de.steamwar.misslewars.Config;
|
import de.steamwar.misslewars.Config;
|
||||||
import de.steamwar.misslewars.MWTeam;
|
import de.steamwar.misslewars.MWTeam;
|
||||||
import de.steamwar.misslewars.MissileWars;
|
import de.steamwar.misslewars.MissileWars;
|
||||||
|
import org.bukkit.Bukkit;
|
||||||
|
import org.bukkit.command.Command;
|
||||||
|
import org.bukkit.command.CommandExecutor;
|
||||||
import org.bukkit.command.CommandSender;
|
import org.bukkit.command.CommandSender;
|
||||||
import org.bukkit.entity.Player;
|
import org.bukkit.entity.Player;
|
||||||
|
|
||||||
public class AcceptCommand extends SWCommand {
|
public class CommandAcceptDecline implements CommandExecutor {
|
||||||
|
|
||||||
public AcceptCommand() {
|
@Override
|
||||||
super("accept");
|
public boolean onCommand(CommandSender sender, Command command, String label, String[] args) {
|
||||||
|
if (!(sender instanceof Player)) return false;
|
||||||
|
Player player = (Player) sender;
|
||||||
|
if (!Config.isChallenge()) {
|
||||||
|
player.sendMessage("§cDieser Command ist deaktiviert.");
|
||||||
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Register
|
|
||||||
public void onCommand(@Validator Player player, String... varargs) {
|
|
||||||
MWTeam teamInvitation = MissileWars.getInvitation(player);
|
MWTeam teamInvitation = MissileWars.getInvitation(player);
|
||||||
if (teamInvitation == null) {
|
if (teamInvitation == null) {
|
||||||
player.sendMessage("§cDu wurdest nicht eingeladen.");
|
player.sendMessage("§cDu wurdest nicht eingeladen.");
|
||||||
} else {
|
|
||||||
teamInvitation.acceptInvite(player);
|
|
||||||
message(teamInvitation, "§7Der Spieler §e" + player.getName() + "§7 ist dem Team §abeigetreten§7.");
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
@ClassValidator(value = Player.class, local = true)
|
|
||||||
public TypeValidator<Player> validator() {
|
|
||||||
return new TypeValidator<Player>() {
|
|
||||||
@Override
|
|
||||||
public boolean validate(CommandSender commandSender, Player player, MessageSender messageSender) {
|
|
||||||
if (!Config.isChallenge()) {
|
|
||||||
messageSender.send("§cDieser Command ist deaktiviert.");
|
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
return true;
|
|
||||||
}
|
|
||||||
};
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
if (command.getName().equalsIgnoreCase("accept")) {
|
||||||
protected void sendMessage(CommandSender sender, String message, Object[] args) {
|
teamInvitation.acceptInvite(player);
|
||||||
sender.sendMessage(message);
|
message(teamInvitation, "§7Der Spieler §e" + player.getName() + "§7 ist dem Team §abeigetreten§7.");
|
||||||
|
} else {
|
||||||
|
MWTeam.removeInvitations(player);
|
||||||
|
message(teamInvitation, "§7Der Spieler §e" + player.getName() + "§7 hat die Einladung §cabgelehnt§7.");
|
||||||
|
}
|
||||||
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
private void message(MWTeam mwTeam, String s) {
|
private void message(MWTeam mwTeam, String s) {
|
||||||
mwTeam.getPlayers().forEach(player -> player.sendMessage(s));
|
mwTeam.getPlayers().forEach(player -> player.sendMessage(s));
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
95
src/de/steamwar/misslewars/commands/CommandInvite.java
Normale Datei
95
src/de/steamwar/misslewars/commands/CommandInvite.java
Normale Datei
@ -0,0 +1,95 @@
|
|||||||
|
/*
|
||||||
|
*
|
||||||
|
* 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.misslewars.commands;
|
||||||
|
|
||||||
|
import de.steamwar.misslewars.Config;
|
||||||
|
import de.steamwar.misslewars.MWTeam;
|
||||||
|
import de.steamwar.misslewars.MissileWars;
|
||||||
|
import org.bukkit.Bukkit;
|
||||||
|
import org.bukkit.command.Command;
|
||||||
|
import org.bukkit.command.CommandExecutor;
|
||||||
|
import org.bukkit.command.CommandSender;
|
||||||
|
import org.bukkit.command.TabCompleter;
|
||||||
|
import org.bukkit.entity.Player;
|
||||||
|
|
||||||
|
import java.util.ArrayList;
|
||||||
|
import java.util.List;
|
||||||
|
import java.util.stream.Collectors;
|
||||||
|
|
||||||
|
public class CommandInvite implements CommandExecutor, TabCompleter {
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public boolean onCommand(CommandSender sender, Command command, String label, String[] args) {
|
||||||
|
if (!(sender instanceof Player)) return false;
|
||||||
|
Player player = (Player) sender;
|
||||||
|
if (!Config.isChallenge()) {
|
||||||
|
player.sendMessage("§cDieser Command ist deaktiviert.");
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
MWTeam team = MissileWars.getTeam(player);
|
||||||
|
if (!Config.RedLeader.equals(player.getUniqueId()) && !Config.BlueLeader.equals(player.getUniqueId()) || team == null) {
|
||||||
|
player.sendMessage("§cDu kannst keine Spieler einladen.");
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (args.length != 1) {
|
||||||
|
player.sendMessage("§c/invite <PLAYER>");
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
Player invitedPlayer = Bukkit.getPlayer(args[0]);
|
||||||
|
if (invitedPlayer == null) {
|
||||||
|
player.sendMessage("§cDieser Spieler ist nicht online.");
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
if (MissileWars.getTeam(invitedPlayer) != null) {
|
||||||
|
player.sendMessage("§cDieser Spieler ist bereits in einem Team.");
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
if (MissileWars.getInvitation(invitedPlayer) != null) {
|
||||||
|
player.sendMessage("§cDieser Spieler wurde bereits eingeladen.");
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
team.invitePlayer(invitedPlayer);
|
||||||
|
player.sendMessage("§7Du hast §e" + invitedPlayer.getName() + " §7eingeladen.");
|
||||||
|
invitedPlayer.sendMessage("§7Du wurdest von §e" + player.getName() + "§7 in das Team §e" + MissileWars.getTeam(player).getColoredName() + "§7 eingeladen.");
|
||||||
|
invitedPlayer.sendMessage("§8/§eaccept §8- §7Zum akzeptieren.");
|
||||||
|
invitedPlayer.sendMessage("§8/§edecline §8- §7Zum ablehnen.");
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public List<String> onTabComplete(CommandSender sender, Command command, String label, String[] args) {
|
||||||
|
if (args.length == 1) {
|
||||||
|
return Bukkit.getOnlinePlayers()
|
||||||
|
.stream()
|
||||||
|
.filter(p -> MissileWars.getTeam(p) != null)
|
||||||
|
.filter(p -> MissileWars.getInvitation(p) != null)
|
||||||
|
.map(Player::getName)
|
||||||
|
.collect(Collectors.toList());
|
||||||
|
}
|
||||||
|
return new ArrayList<>();
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
24
src/de/steamwar/misslewars/commands/CommandItems.java
Normale Datei
24
src/de/steamwar/misslewars/commands/CommandItems.java
Normale Datei
@ -0,0 +1,24 @@
|
|||||||
|
package de.steamwar.misslewars.commands;
|
||||||
|
|
||||||
|
import de.steamwar.command.SWCommand;
|
||||||
|
import de.steamwar.inventory.SWItem;
|
||||||
|
import de.steamwar.inventory.SWListInv;
|
||||||
|
import de.steamwar.misslewars.items.SpecialItem;
|
||||||
|
import org.bukkit.entity.Player;
|
||||||
|
import org.bukkit.inventory.ItemStack;
|
||||||
|
|
||||||
|
import java.util.stream.Collectors;
|
||||||
|
|
||||||
|
public class CommandItems extends SWCommand {
|
||||||
|
public CommandItems() {
|
||||||
|
super("give");
|
||||||
|
}
|
||||||
|
|
||||||
|
public void genericCommand(Player player, String[] args) {
|
||||||
|
SWListInv<ItemStack> inv = new SWListInv<>(player, "Misslewars Items", SpecialItem.getAllItems().stream().map(item -> new SWListInv.SWListEntry<>(new SWItem(item.getType(), item.getItemMeta().getDisplayName()), item)).collect(Collectors.toList()), (clickType, itemStack) -> {
|
||||||
|
player.closeInventory();
|
||||||
|
player.getInventory().addItem(itemStack);
|
||||||
|
});
|
||||||
|
inv.open();
|
||||||
|
}
|
||||||
|
}
|
55
src/de/steamwar/misslewars/commands/CommandSpectate.java
Normale Datei
55
src/de/steamwar/misslewars/commands/CommandSpectate.java
Normale Datei
@ -0,0 +1,55 @@
|
|||||||
|
/*
|
||||||
|
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.misslewars.commands;
|
||||||
|
|
||||||
|
import de.steamwar.misslewars.Config;
|
||||||
|
import de.steamwar.misslewars.MWTeam;
|
||||||
|
import de.steamwar.misslewars.MissileWars;
|
||||||
|
import org.bukkit.GameMode;
|
||||||
|
import org.bukkit.command.Command;
|
||||||
|
import org.bukkit.command.CommandExecutor;
|
||||||
|
import org.bukkit.command.CommandSender;
|
||||||
|
import org.bukkit.entity.Player;
|
||||||
|
|
||||||
|
public class CommandSpectate implements CommandExecutor {
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public boolean onCommand(CommandSender sender, Command command, String label, String[] args) {
|
||||||
|
if (!(sender instanceof Player)) return false;
|
||||||
|
Player player = (Player) sender;
|
||||||
|
if (Config.isChallenge()) {
|
||||||
|
player.sendMessage("§cDieser Command ist deaktiviert.");
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
MWTeam mwTeam = MissileWars.getTeam(player);
|
||||||
|
if (mwTeam == null) return false;
|
||||||
|
if (mwTeam.size() == 1) {
|
||||||
|
player.sendMessage("§cDu bist alleine im Team, zuschauen ist daher nicht möglich.");
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
MissileWars.leave(player);
|
||||||
|
player.setGameMode(GameMode.SPECTATOR);
|
||||||
|
player.getInventory().clear();
|
||||||
|
player.updateInventory();
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
@ -1,70 +0,0 @@
|
|||||||
/*
|
|
||||||
*
|
|
||||||
* This file is a part of the SteamWar software.
|
|
||||||
*
|
|
||||||
* Copyright (C) 2023 SteamWar.de-Serverteam
|
|
||||||
*
|
|
||||||
* This program is free software: you can redistribute it and/or modify
|
|
||||||
* it under the terms of the GNU Affero General Public License as published by
|
|
||||||
* the Free Software Foundation, either version 3 of the License, or
|
|
||||||
* (at your option) any later version.
|
|
||||||
*
|
|
||||||
* This program is distributed in the hope that it will be useful,
|
|
||||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
||||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
||||||
* GNU Affero General Public License for more details.
|
|
||||||
*
|
|
||||||
* You should have received a copy of the GNU Affero General Public License
|
|
||||||
* along with this program. If not, see <https://www.gnu.org/licenses/>.
|
|
||||||
*/
|
|
||||||
|
|
||||||
package de.steamwar.misslewars.commands;
|
|
||||||
|
|
||||||
import de.steamwar.command.SWCommand;
|
|
||||||
import de.steamwar.command.TypeValidator;
|
|
||||||
import de.steamwar.misslewars.Config;
|
|
||||||
import de.steamwar.misslewars.MWTeam;
|
|
||||||
import de.steamwar.misslewars.MissileWars;
|
|
||||||
import org.bukkit.command.CommandSender;
|
|
||||||
import org.bukkit.entity.Player;
|
|
||||||
|
|
||||||
public class DeclineCommand extends SWCommand {
|
|
||||||
|
|
||||||
public DeclineCommand() {
|
|
||||||
super("decline");
|
|
||||||
}
|
|
||||||
|
|
||||||
@Register
|
|
||||||
public void onCommand(@Validator Player player, String... varargs) {
|
|
||||||
MWTeam teamInvitation = MissileWars.getInvitation(player);
|
|
||||||
if (teamInvitation == null) {
|
|
||||||
player.sendMessage("§cDu wurdest nicht eingeladen.");
|
|
||||||
} else {
|
|
||||||
MWTeam.removeInvitations(player);
|
|
||||||
message(teamInvitation, "§7Der Spieler §e" + player.getName() + "§7 hat die Einladung §cabgelehnt§7.");
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
@ClassValidator(value = Player.class, local = true)
|
|
||||||
public TypeValidator<Player> validator() {
|
|
||||||
return new TypeValidator<Player>() {
|
|
||||||
@Override
|
|
||||||
public boolean validate(CommandSender commandSender, Player player, MessageSender messageSender) {
|
|
||||||
if (!Config.isChallenge()) {
|
|
||||||
messageSender.send("§cDieser Command ist deaktiviert.");
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
};
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
protected void sendMessage(CommandSender sender, String message, Object[] args) {
|
|
||||||
sender.sendMessage(message);
|
|
||||||
}
|
|
||||||
|
|
||||||
private void message(MWTeam mwTeam, String s) {
|
|
||||||
mwTeam.getPlayers().forEach(player -> player.sendMessage(s));
|
|
||||||
}
|
|
||||||
}
|
|
@ -1,99 +0,0 @@
|
|||||||
/*
|
|
||||||
*
|
|
||||||
* This file is a part of the SteamWar software.
|
|
||||||
*
|
|
||||||
* Copyright (C) 2023 SteamWar.de-Serverteam
|
|
||||||
*
|
|
||||||
* This program is free software: you can redistribute it and/or modify
|
|
||||||
* it under the terms of the GNU Affero General Public License as published by
|
|
||||||
* the Free Software Foundation, either version 3 of the License, or
|
|
||||||
* (at your option) any later version.
|
|
||||||
*
|
|
||||||
* This program is distributed in the hope that it will be useful,
|
|
||||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
||||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
||||||
* GNU Affero General Public License for more details.
|
|
||||||
*
|
|
||||||
* You should have received a copy of the GNU Affero General Public License
|
|
||||||
* along with this program. If not, see <https://www.gnu.org/licenses/>.
|
|
||||||
*/
|
|
||||||
|
|
||||||
package de.steamwar.misslewars.commands;
|
|
||||||
|
|
||||||
import de.steamwar.command.PreviousArguments;
|
|
||||||
import de.steamwar.command.SWCommand;
|
|
||||||
import de.steamwar.command.TypeMapper;
|
|
||||||
import de.steamwar.command.TypeValidator;
|
|
||||||
import de.steamwar.misslewars.Config;
|
|
||||||
import de.steamwar.misslewars.MWTeam;
|
|
||||||
import de.steamwar.misslewars.MissileWars;
|
|
||||||
import org.bukkit.Bukkit;
|
|
||||||
import org.bukkit.command.CommandSender;
|
|
||||||
import org.bukkit.entity.Player;
|
|
||||||
|
|
||||||
import java.util.Collection;
|
|
||||||
import java.util.stream.Collectors;
|
|
||||||
|
|
||||||
public class InviteCommand extends SWCommand {
|
|
||||||
|
|
||||||
public InviteCommand() {
|
|
||||||
super("invite", "inv");
|
|
||||||
}
|
|
||||||
|
|
||||||
@Register
|
|
||||||
public void onCommand(@Validator Player player, @AllowNull @OptionalValue("") Player invitedPlayer) {
|
|
||||||
MWTeam team = MissileWars.getTeam(player);
|
|
||||||
|
|
||||||
if (!player.getUniqueId().equals(Config.RedLeader) && !player.getUniqueId().equals(Config.BlueLeader) || team == null) {
|
|
||||||
player.sendMessage("§cDu kannst keine Spieler einladen.");
|
|
||||||
} else if (invitedPlayer == null) {
|
|
||||||
player.sendMessage("§cDieser Spieler ist nicht online.");
|
|
||||||
} else if (MissileWars.getTeam(invitedPlayer) != null) {
|
|
||||||
player.sendMessage("§cDieser Spieler ist bereits in einem Team.");
|
|
||||||
} else if (MissileWars.getInvitation(invitedPlayer) != null) {
|
|
||||||
player.sendMessage("§cDieser Spieler wurde bereits eingeladen.");
|
|
||||||
} else {
|
|
||||||
team.invitePlayer(invitedPlayer);
|
|
||||||
player.sendMessage("§7Du hast §e" + invitedPlayer.getName() + " §7eingeladen.");
|
|
||||||
invitedPlayer.sendMessage("§7Du wurdest von §e" + player.getName() + "§7 in das Team §e" + MissileWars.getTeam(player).getColoredName() + "§7 eingeladen.");
|
|
||||||
invitedPlayer.sendMessage("§8/§eaccept §8- §7Zum akzeptieren.");
|
|
||||||
invitedPlayer.sendMessage("§8/§edecline §8- §7Zum ablehnen.");
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
@ClassMapper(value = Player.class, local = true)
|
|
||||||
public TypeMapper<Player> typeMapper() {
|
|
||||||
return new TypeMapper<>() {
|
|
||||||
@Override
|
|
||||||
public Player map(CommandSender commandSender, String[] previousArguments, String s) {
|
|
||||||
return Bukkit.getPlayer(s);
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public Collection<String> tabCompletes(CommandSender sender, PreviousArguments previousArguments, String s) {
|
|
||||||
return Bukkit.getOnlinePlayers()
|
|
||||||
.stream()
|
|
||||||
.filter(p -> MissileWars.getTeam(p) != null)
|
|
||||||
.filter(p -> MissileWars.getInvitation(p) != null)
|
|
||||||
.map(Player::getName)
|
|
||||||
.collect(Collectors.toList());
|
|
||||||
}
|
|
||||||
};
|
|
||||||
}
|
|
||||||
|
|
||||||
@ClassValidator(value = Player.class, local = true)
|
|
||||||
public TypeValidator<Player> validator() {
|
|
||||||
return (commandSender, player, messageSender) -> {
|
|
||||||
if (!Config.isChallenge()) {
|
|
||||||
messageSender.send("§cDieser Command ist deaktiviert.");
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
return true;
|
|
||||||
};
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
protected void sendMessage(CommandSender sender, String message, Object[] args) {
|
|
||||||
sender.sendMessage(message);
|
|
||||||
}
|
|
||||||
}
|
|
@ -1,69 +0,0 @@
|
|||||||
/*
|
|
||||||
*
|
|
||||||
* This file is a part of the SteamWar software.
|
|
||||||
*
|
|
||||||
* Copyright (C) 2023 SteamWar.de-Serverteam
|
|
||||||
*
|
|
||||||
* This program is free software: you can redistribute it and/or modify
|
|
||||||
* it under the terms of the GNU Affero General Public License as published by
|
|
||||||
* the Free Software Foundation, either version 3 of the License, or
|
|
||||||
* (at your option) any later version.
|
|
||||||
*
|
|
||||||
* This program is distributed in the hope that it will be useful,
|
|
||||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
||||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
||||||
* GNU Affero General Public License for more details.
|
|
||||||
*
|
|
||||||
* You should have received a copy of the GNU Affero General Public License
|
|
||||||
* along with this program. If not, see <https://www.gnu.org/licenses/>.
|
|
||||||
*/
|
|
||||||
|
|
||||||
package de.steamwar.misslewars.commands;
|
|
||||||
|
|
||||||
import de.steamwar.command.SWCommand;
|
|
||||||
import de.steamwar.command.TypeValidator;
|
|
||||||
import de.steamwar.misslewars.Config;
|
|
||||||
import de.steamwar.misslewars.MWTeam;
|
|
||||||
import de.steamwar.misslewars.MissileWars;
|
|
||||||
import org.bukkit.GameMode;
|
|
||||||
import org.bukkit.command.CommandSender;
|
|
||||||
import org.bukkit.entity.Player;
|
|
||||||
|
|
||||||
public class SpectateCommand extends SWCommand {
|
|
||||||
|
|
||||||
public SpectateCommand() {
|
|
||||||
super("spectate", "spec");
|
|
||||||
}
|
|
||||||
|
|
||||||
@Register
|
|
||||||
public void onCommand(@Validator Player player) {
|
|
||||||
MWTeam mwTeam = MissileWars.getTeam(player);
|
|
||||||
if (mwTeam == null) return;
|
|
||||||
if (mwTeam.size() == 1) {
|
|
||||||
player.sendMessage("§cDu bist alleine im Team, zuschauen ist daher nicht möglich.");
|
|
||||||
}
|
|
||||||
MissileWars.leave(player);
|
|
||||||
player.setGameMode(GameMode.SPECTATOR);
|
|
||||||
player.getInventory().clear();
|
|
||||||
player.updateInventory();
|
|
||||||
}
|
|
||||||
|
|
||||||
@ClassValidator(value = Player.class, local = true)
|
|
||||||
public TypeValidator<Player> validator() {
|
|
||||||
return new TypeValidator<Player>() {
|
|
||||||
@Override
|
|
||||||
public boolean validate(CommandSender commandSender, Player player, MessageSender messageSender) {
|
|
||||||
if (Config.isChallenge()) {
|
|
||||||
messageSender.send("§cDieser Command ist deaktiviert.");
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
};
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
protected void sendMessage(CommandSender sender, String message, Object[] args) {
|
|
||||||
sender.sendMessage(message);
|
|
||||||
}
|
|
||||||
}
|
|
@ -36,29 +36,14 @@ public class EndCountdown extends StateDependent {
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void enable() {
|
public void enable() {
|
||||||
if (Config.isEvent()) {
|
|
||||||
task = Bukkit.getScheduler().runTaskLater(MissileWars.getPlugin(), this::stop, 1200);
|
|
||||||
} else {
|
|
||||||
task = Bukkit.getScheduler().runTaskLater(MissileWars.getPlugin(), this::restart, Config.EndTime);
|
task = Bukkit.getScheduler().runTaskLater(MissileWars.getPlugin(), this::restart, Config.EndTime);
|
||||||
}
|
}
|
||||||
}
|
|
||||||
|
|
||||||
private void restart() {
|
private void restart() {
|
||||||
FightWorld.resetWorld();
|
FightWorld.resetWorld();
|
||||||
MissileWars.waiting();
|
MissileWars.waiting();
|
||||||
}
|
}
|
||||||
|
|
||||||
private void stop() {
|
|
||||||
//Staggered kick to prevent lobby overloading
|
|
||||||
if(Bukkit.getOnlinePlayers().isEmpty()){
|
|
||||||
Bukkit.shutdown();
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
Bukkit.getOnlinePlayers().iterator().next().kickPlayer(null);
|
|
||||||
Bukkit.getScheduler().runTaskLater(MissileWars.getPlugin(), this::stop, 10);
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void disable() {
|
public void disable() {
|
||||||
if (task != null && !task.isCancelled())
|
if (task != null && !task.isCancelled())
|
||||||
|
@ -41,6 +41,11 @@ public class ItemCountdown extends StateDependent {
|
|||||||
}
|
}
|
||||||
|
|
||||||
private void run() {
|
private void run() {
|
||||||
|
if (currenTime == 0) {
|
||||||
|
ItemStack itemStack = SpecialItem.getRandomItem();
|
||||||
|
MissileWars.getBlueTeam().givePlayerItem(itemStack);
|
||||||
|
MissileWars.getRedTeam().givePlayerItem(itemStack);
|
||||||
|
}
|
||||||
currenTime++;
|
currenTime++;
|
||||||
|
|
||||||
int teamCount = Math.max(MissileWars.getBlueTeam().size(), MissileWars.getRedTeam().size());
|
int teamCount = Math.max(MissileWars.getBlueTeam().size(), MissileWars.getRedTeam().size());
|
||||||
|
@ -72,7 +72,7 @@ public class CustomItem extends SpecialItem {
|
|||||||
new CustomItem(new ScriptedItem(jsonObject));
|
new CustomItem(new ScriptedItem(jsonObject));
|
||||||
} catch (JsonSyntaxException | IOException e) {
|
} catch (JsonSyntaxException | IOException e) {
|
||||||
e.printStackTrace();
|
e.printStackTrace();
|
||||||
throw new SecurityException("Item JSON error " + itemFile, e);
|
throw new SecurityException("Item JSON error", e);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -49,6 +49,7 @@ import java.util.Objects;
|
|||||||
public class Missile extends SpecialItem {
|
public class Missile extends SpecialItem {
|
||||||
|
|
||||||
private static final World world = new BukkitWorld(Bukkit.getWorlds().get(0));
|
private static final World world = new BukkitWorld(Bukkit.getWorlds().get(0));
|
||||||
|
private static final int GRAPH_SIZE = 7;
|
||||||
|
|
||||||
private final Clipboard clipboard;
|
private final Clipboard clipboard;
|
||||||
private final ItemStack item;
|
private final ItemStack item;
|
||||||
@ -69,8 +70,8 @@ public class Missile extends SpecialItem {
|
|||||||
}
|
}
|
||||||
|
|
||||||
List<String> lore = new ArrayList<>();
|
List<String> lore = new ArrayList<>();
|
||||||
lore(lore, strings, 2, "§7Speed");
|
lore(lore, strings, 2, " §7Speed");
|
||||||
lore(lore, strings, 3, "§7Size");
|
lore(lore, strings, 3, " §7Size");
|
||||||
|
|
||||||
EditSession e = WorldEdit.getInstance().getEditSessionFactory().getEditSession(world, -1);
|
EditSession e = WorldEdit.getInstance().getEditSessionFactory().getEditSession(world, -1);
|
||||||
BlockTypeMask blockTypeMask = new BlockTypeMask(clipboard, BlockTypes.TNT);
|
BlockTypeMask blockTypeMask = new BlockTypeMask(clipboard, BlockTypes.TNT);
|
||||||
@ -81,11 +82,33 @@ public class Missile extends SpecialItem {
|
|||||||
|
|
||||||
private void lore(List<String> lore, String[] args, int index, String tag) {
|
private void lore(List<String> lore, String[] args, int index, String tag) {
|
||||||
if (args.length > index) {
|
if (args.length > index) {
|
||||||
lore.add(tag + " §8: §e" + Integer.parseInt(args[index]) + "§8/§77");
|
try {
|
||||||
} else {
|
lore.add(graph(Integer.parseInt(args[index]), GRAPH_SIZE) + tag);
|
||||||
lore.add(tag + " §8: §e0§8/§77");
|
return;
|
||||||
|
} catch (NumberFormatException e) {
|
||||||
|
// Ignored
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
lore.add(graph(0, GRAPH_SIZE) + tag);
|
||||||
|
}
|
||||||
|
|
||||||
|
private String graph(int index, int size) {
|
||||||
|
if (index > size) index = size;
|
||||||
|
StringBuilder st = new StringBuilder();
|
||||||
|
st.append("§8[§e");
|
||||||
|
if (index > 0) st.append(repeat(index));
|
||||||
|
st.append("§7");
|
||||||
|
st.append(repeat(size - index));
|
||||||
|
st.append("§8]");
|
||||||
|
return st.toString();
|
||||||
|
}
|
||||||
|
|
||||||
|
private String repeat(int count) {
|
||||||
|
if (count == 0) return "";
|
||||||
|
StringBuilder st = new StringBuilder();
|
||||||
|
for (int i = 0; i < count; i++) st.append("=");
|
||||||
|
return st.toString();
|
||||||
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public ItemStack getItem() {
|
public ItemStack getItem() {
|
||||||
|
@ -40,8 +40,7 @@ import java.util.Random;
|
|||||||
public abstract class SpecialItem {
|
public abstract class SpecialItem {
|
||||||
|
|
||||||
private static final Random random = new Random();
|
private static final Random random = new Random();
|
||||||
private static double count = 0;
|
private static boolean lastItemWasSupportItem = false;
|
||||||
private static int consecutiveSupportItems = 0;
|
|
||||||
|
|
||||||
private static List<SpecialItem> supportItems = new ArrayList<>();
|
private static List<SpecialItem> supportItems = new ArrayList<>();
|
||||||
private static List<SpecialItem> missileItems = new ArrayList<>();
|
private static List<SpecialItem> missileItems = new ArrayList<>();
|
||||||
@ -111,22 +110,20 @@ public abstract class SpecialItem {
|
|||||||
}
|
}
|
||||||
|
|
||||||
public static ItemStack getRandomItem() {
|
public static ItemStack getRandomItem() {
|
||||||
if (Config.MissileChance == 0 || consecutiveSupportItems > 1) {
|
if (!lastItemWasSupportItem && random.nextDouble() > Config.MissileChance) {
|
||||||
consecutiveSupportItems = 0;
|
lastItemWasSupportItem = true;
|
||||||
return supportItems.get(random.nextInt(supportItems.size())).getItem();
|
return supportItems.get(random.nextInt(supportItems.size())).getItem();
|
||||||
}
|
}
|
||||||
if (Config.MissileChance == 1) {
|
lastItemWasSupportItem = false;
|
||||||
return missileItems.get(random.nextInt(missileItems.size())).getItem();
|
return missileItems.get(random.nextInt(missileItems.size())).getItem();
|
||||||
}
|
}
|
||||||
|
|
||||||
double missileChance = Config.MissileChance + count * 0.1;
|
public static List<ItemStack> getAllItems() {
|
||||||
if (random.nextDouble() > missileChance) {
|
List<ItemStack> items = new ArrayList<>();
|
||||||
count += Config.MissileChance;
|
for (SpecialItem specialItem : supportItems)
|
||||||
consecutiveSupportItems++;
|
items.add(specialItem.getItem());
|
||||||
return supportItems.get(random.nextInt(supportItems.size())).getItem();
|
for (SpecialItem specialItem : missileItems)
|
||||||
} else {
|
items.add(specialItem.getItem());
|
||||||
count -= 1 - Config.MissileChance;
|
return items;
|
||||||
return missileItems.get(random.nextInt(missileItems.size())).getItem();
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -21,15 +21,12 @@ package de.steamwar.misslewars.listener;
|
|||||||
|
|
||||||
import de.steamwar.misslewars.Config;
|
import de.steamwar.misslewars.Config;
|
||||||
import de.steamwar.misslewars.FightState;
|
import de.steamwar.misslewars.FightState;
|
||||||
import de.steamwar.misslewars.MWTeam;
|
|
||||||
import de.steamwar.misslewars.MissileWars;
|
import de.steamwar.misslewars.MissileWars;
|
||||||
import org.bukkit.GameMode;
|
import org.bukkit.GameMode;
|
||||||
import org.bukkit.Location;
|
import org.bukkit.Location;
|
||||||
import org.bukkit.entity.Player;
|
import org.bukkit.entity.Player;
|
||||||
import org.bukkit.event.EventHandler;
|
import org.bukkit.event.EventHandler;
|
||||||
import org.bukkit.event.entity.EntityPickupItemEvent;
|
|
||||||
import org.bukkit.event.entity.FoodLevelChangeEvent;
|
import org.bukkit.event.entity.FoodLevelChangeEvent;
|
||||||
import org.bukkit.event.entity.ItemDespawnEvent;
|
|
||||||
import org.bukkit.event.inventory.InventoryOpenEvent;
|
import org.bukkit.event.inventory.InventoryOpenEvent;
|
||||||
import org.bukkit.event.inventory.InventoryType;
|
import org.bukkit.event.inventory.InventoryType;
|
||||||
import org.bukkit.event.player.PlayerDropItemEvent;
|
import org.bukkit.event.player.PlayerDropItemEvent;
|
||||||
@ -37,7 +34,6 @@ import org.bukkit.event.player.PlayerMoveEvent;
|
|||||||
import org.bukkit.event.player.PlayerPickupArrowEvent;
|
import org.bukkit.event.player.PlayerPickupArrowEvent;
|
||||||
|
|
||||||
import java.util.EnumSet;
|
import java.util.EnumSet;
|
||||||
import java.util.Map;
|
|
||||||
import java.util.Objects;
|
import java.util.Objects;
|
||||||
|
|
||||||
public class ArenaListener extends BasicListener {
|
public class ArenaListener extends BasicListener {
|
||||||
@ -73,6 +69,11 @@ public class ArenaListener extends BasicListener {
|
|||||||
e.setCancelled(true);
|
e.setCancelled(true);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@EventHandler
|
||||||
|
public void onItemDrop(PlayerDropItemEvent e){
|
||||||
|
e.setCancelled(true);
|
||||||
|
}
|
||||||
|
|
||||||
@EventHandler
|
@EventHandler
|
||||||
public void onHunger(FoodLevelChangeEvent e){
|
public void onHunger(FoodLevelChangeEvent e){
|
||||||
e.setCancelled(true);
|
e.setCancelled(true);
|
||||||
|
@ -31,7 +31,7 @@ import java.util.Set;
|
|||||||
public abstract class BasicListener extends StateDependent implements Listener {
|
public abstract class BasicListener extends StateDependent implements Listener {
|
||||||
|
|
||||||
|
|
||||||
protected BasicListener(final Set<FightState> active){
|
BasicListener(final Set<FightState> active){
|
||||||
super(active);
|
super(active);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -20,47 +20,28 @@
|
|||||||
package de.steamwar.misslewars.listener;
|
package de.steamwar.misslewars.listener;
|
||||||
|
|
||||||
import de.steamwar.misslewars.FightState;
|
import de.steamwar.misslewars.FightState;
|
||||||
import de.steamwar.misslewars.MWTeam;
|
|
||||||
import de.steamwar.misslewars.MissileWars;
|
|
||||||
import de.steamwar.misslewars.items.SpecialItem;
|
import de.steamwar.misslewars.items.SpecialItem;
|
||||||
import org.bukkit.Material;
|
import org.bukkit.Material;
|
||||||
import org.bukkit.entity.Player;
|
|
||||||
import org.bukkit.event.EventHandler;
|
import org.bukkit.event.EventHandler;
|
||||||
import org.bukkit.event.block.Action;
|
import org.bukkit.event.block.Action;
|
||||||
import org.bukkit.event.entity.EntityPickupItemEvent;
|
|
||||||
import org.bukkit.event.entity.ItemDespawnEvent;
|
|
||||||
import org.bukkit.event.entity.ProjectileHitEvent;
|
import org.bukkit.event.entity.ProjectileHitEvent;
|
||||||
import org.bukkit.event.entity.ProjectileLaunchEvent;
|
import org.bukkit.event.entity.ProjectileLaunchEvent;
|
||||||
import org.bukkit.event.player.PlayerDropItemEvent;
|
|
||||||
import org.bukkit.event.player.PlayerInteractEvent;
|
import org.bukkit.event.player.PlayerInteractEvent;
|
||||||
import org.bukkit.inventory.ItemStack;
|
import org.bukkit.inventory.ItemStack;
|
||||||
|
|
||||||
import java.util.EnumSet;
|
import java.util.EnumSet;
|
||||||
import java.util.HashSet;
|
|
||||||
import java.util.Set;
|
|
||||||
|
|
||||||
public class ItemListener extends BasicListener {
|
public class ItemListener extends BasicListener {
|
||||||
|
|
||||||
private Set<Integer> RED_ITEMS = new HashSet<>();
|
|
||||||
private Set<Integer> BLUE_ITEMS = new HashSet<>();
|
|
||||||
|
|
||||||
public ItemListener() {
|
public ItemListener() {
|
||||||
super(EnumSet.of(FightState.FIGHTING));
|
super(EnumSet.of(FightState.FIGHTING));
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
|
||||||
public void enable() {
|
|
||||||
super.enable();
|
|
||||||
RED_ITEMS.clear();
|
|
||||||
BLUE_ITEMS.clear();
|
|
||||||
}
|
|
||||||
|
|
||||||
@EventHandler
|
@EventHandler
|
||||||
public void onItemClick(PlayerInteractEvent e) {
|
public void onItemClick(PlayerInteractEvent e) {
|
||||||
ItemStack item = e.getItem();
|
ItemStack item = e.getItem();
|
||||||
if (item == null)
|
if (item == null)
|
||||||
return;
|
return;
|
||||||
if (e.getPlayer().hasCooldown(item.getType())) return;
|
|
||||||
|
|
||||||
if (e.getAction() != Action.RIGHT_CLICK_BLOCK && e.getAction() != Action.RIGHT_CLICK_AIR)
|
if (e.getAction() != Action.RIGHT_CLICK_BLOCK && e.getAction() != Action.RIGHT_CLICK_AIR)
|
||||||
return;
|
return;
|
||||||
@ -82,42 +63,4 @@ public class ItemListener extends BasicListener {
|
|||||||
SpecialItem.handleHit(e);
|
SpecialItem.handleHit(e);
|
||||||
}
|
}
|
||||||
|
|
||||||
@EventHandler
|
|
||||||
public void onItemDrop(PlayerDropItemEvent e){
|
|
||||||
MWTeam mwTeam = MissileWars.getTeam(e.getPlayer());
|
|
||||||
if (mwTeam == null) {
|
|
||||||
e.setCancelled(true);
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
if (e.getItemDrop().getItemStack().isSimilar(MWTeam.bow)) {
|
|
||||||
e.setCancelled(true);
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
if (mwTeam == MissileWars.getRedTeam()) {
|
|
||||||
RED_ITEMS.add(e.getItemDrop().getEntityId());
|
|
||||||
} else {
|
|
||||||
BLUE_ITEMS.add(e.getItemDrop().getEntityId());
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
@EventHandler
|
|
||||||
public void onEntityPickupItem(EntityPickupItemEvent e) {
|
|
||||||
Player player = (Player) e.getEntity();
|
|
||||||
MWTeam mwTeam = MissileWars.getTeam(player);
|
|
||||||
if (mwTeam == null) {
|
|
||||||
e.setCancelled(true);
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
if (mwTeam == MissileWars.getRedTeam() && !RED_ITEMS.contains(e.getItem().getEntityId())) {
|
|
||||||
e.setCancelled(true);
|
|
||||||
} else if (mwTeam == MissileWars.getBlueTeam() && !BLUE_ITEMS.contains(e.getItem().getEntityId())) {
|
|
||||||
e.setCancelled(true);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
@EventHandler
|
|
||||||
public void onItemDespawn(ItemDespawnEvent event) {
|
|
||||||
RED_ITEMS.remove(event.getEntity().getEntityId());
|
|
||||||
BLUE_ITEMS.remove(event.getEntity().getEntityId());
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
@ -22,7 +22,6 @@ package de.steamwar.misslewars.listener;
|
|||||||
import de.steamwar.misslewars.Config;
|
import de.steamwar.misslewars.Config;
|
||||||
import de.steamwar.misslewars.FightState;
|
import de.steamwar.misslewars.FightState;
|
||||||
import de.steamwar.misslewars.MissileWars;
|
import de.steamwar.misslewars.MissileWars;
|
||||||
import de.steamwar.sql.SteamwarUser;
|
|
||||||
import org.bukkit.entity.Player;
|
import org.bukkit.entity.Player;
|
||||||
import org.bukkit.event.EventHandler;
|
import org.bukkit.event.EventHandler;
|
||||||
import org.bukkit.event.EventPriority;
|
import org.bukkit.event.EventPriority;
|
||||||
@ -43,39 +42,7 @@ public class JoinListener extends BasicListener {
|
|||||||
}
|
}
|
||||||
|
|
||||||
public static void join(Player p) {
|
public static void join(Player p) {
|
||||||
if (Config.isEvent()) {
|
|
||||||
joinEvent(p);
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (Config.isChallenge()) {
|
if (Config.isChallenge()) {
|
||||||
joinChallenge(p);
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
joinNormal(p);
|
|
||||||
}
|
|
||||||
|
|
||||||
private static void joinEvent(Player p) {
|
|
||||||
if (Config.EventTeamRedID == 0 && Config.EventTeamBlueID == 0) {
|
|
||||||
joinNormal(p);
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
int teamId = SteamwarUser.get(p.getUniqueId()).getTeam();
|
|
||||||
if (teamId != Config.EventTeamRedID && teamId != Config.EventTeamBlueID) {
|
|
||||||
teamId = 0;
|
|
||||||
}
|
|
||||||
if (teamId == Config.EventTeamRedID && MissileWars.getRedTeam().size() < Config.MaximumTeamMembers) {
|
|
||||||
MissileWars.getRedTeam().join(p);
|
|
||||||
} else if (teamId == Config.EventTeamBlueID && MissileWars.getBlueTeam().size() < Config.MaximumTeamMembers) {
|
|
||||||
MissileWars.getBlueTeam().join(p);
|
|
||||||
} else {
|
|
||||||
p.teleport(MissileWars.getRedTeam().getSpawn().toVector().midpoint(MissileWars.getBlueTeam().getSpawn().toVector()).toLocation(p.getWorld()));
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
private static void joinChallenge(Player p) {
|
|
||||||
if (Config.RedLeader.equals(p.getUniqueId())) {
|
if (Config.RedLeader.equals(p.getUniqueId())) {
|
||||||
MissileWars.getRedTeam().join(p);
|
MissileWars.getRedTeam().join(p);
|
||||||
} else if (Config.BlueLeader.equals(p.getUniqueId())) {
|
} else if (Config.BlueLeader.equals(p.getUniqueId())) {
|
||||||
@ -83,19 +50,8 @@ public class JoinListener extends BasicListener {
|
|||||||
} else {
|
} else {
|
||||||
p.teleport(MissileWars.getRedTeam().getSpawn().toVector().midpoint(MissileWars.getBlueTeam().getSpawn().toVector()).toLocation(p.getWorld()));
|
p.teleport(MissileWars.getRedTeam().getSpawn().toVector().midpoint(MissileWars.getBlueTeam().getSpawn().toVector()).toLocation(p.getWorld()));
|
||||||
}
|
}
|
||||||
|
return;
|
||||||
}
|
}
|
||||||
|
MissileWars.join(p);
|
||||||
private static void joinNormal(Player p) {
|
|
||||||
if (MissileWars.getRedTeam().size() == MissileWars.getBlueTeam().size()) {
|
|
||||||
if (Math.random() > 0.5) {
|
|
||||||
MissileWars.getRedTeam().join(p);
|
|
||||||
} else {
|
|
||||||
MissileWars.getBlueTeam().join(p);
|
|
||||||
}
|
|
||||||
} else if (MissileWars.getRedTeam().size() < MissileWars.getBlueTeam().size()) {
|
|
||||||
MissileWars.getRedTeam().join(p);
|
|
||||||
} else {
|
|
||||||
MissileWars.getBlueTeam().join(p);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -1,58 +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.misslewars.listener.special;
|
|
||||||
|
|
||||||
import de.steamwar.misslewars.Config;
|
|
||||||
import de.steamwar.misslewars.FightState;
|
|
||||||
import de.steamwar.misslewars.listener.BasicListener;
|
|
||||||
import org.bukkit.Material;
|
|
||||||
import org.bukkit.block.Block;
|
|
||||||
import org.bukkit.event.EventHandler;
|
|
||||||
import org.bukkit.event.block.BlockPhysicsEvent;
|
|
||||||
|
|
||||||
import java.util.EnumSet;
|
|
||||||
|
|
||||||
public class BarrierListener extends BasicListener {
|
|
||||||
|
|
||||||
public BarrierListener() {
|
|
||||||
super(EnumSet.allOf(FightState.class));
|
|
||||||
}
|
|
||||||
|
|
||||||
private int middle = Config.ArenaMinZ + (Config.ArenaMaxZ - Config.ArenaMinZ) / 2;
|
|
||||||
|
|
||||||
@EventHandler
|
|
||||||
public void onBlockPhysics(BlockPhysicsEvent event) {
|
|
||||||
if (!Config.Barrier) return;
|
|
||||||
Block block = event.getBlock();
|
|
||||||
if (block.getZ() > middle - 10 && block.getZ() < middle + 10) {
|
|
||||||
switch (block.getType()) {
|
|
||||||
case SLIME_BLOCK:
|
|
||||||
case HONEY_BLOCK:
|
|
||||||
case TNT:
|
|
||||||
block.setType(Material.AIR);
|
|
||||||
break;
|
|
||||||
default:
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
@ -1,82 +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.misslewars.listener.special;
|
|
||||||
|
|
||||||
import de.steamwar.misslewars.Config;
|
|
||||||
import de.steamwar.misslewars.FightState;
|
|
||||||
import de.steamwar.misslewars.MissileWars;
|
|
||||||
import de.steamwar.misslewars.listener.BasicListener;
|
|
||||||
import org.bukkit.Bukkit;
|
|
||||||
import org.bukkit.entity.Player;
|
|
||||||
import org.bukkit.entity.TNTPrimed;
|
|
||||||
import org.bukkit.event.EventHandler;
|
|
||||||
import org.bukkit.event.entity.EntitySpawnEvent;
|
|
||||||
import org.bukkit.event.player.PlayerJoinEvent;
|
|
||||||
import org.bukkit.event.player.PlayerRespawnEvent;
|
|
||||||
import org.bukkit.potion.PotionEffect;
|
|
||||||
import org.bukkit.potion.PotionEffectType;
|
|
||||||
import org.bukkit.util.Vector;
|
|
||||||
|
|
||||||
import java.util.EnumSet;
|
|
||||||
|
|
||||||
public class SpaceListener extends BasicListener {
|
|
||||||
|
|
||||||
public SpaceListener() {
|
|
||||||
super(EnumSet.allOf(FightState.class));
|
|
||||||
}
|
|
||||||
|
|
||||||
@EventHandler
|
|
||||||
public void onPlayerJoin(PlayerJoinEvent event) {
|
|
||||||
if (!Config.Space) return;
|
|
||||||
Bukkit.getScheduler().runTaskLater(MissileWars.getPlugin(), () -> {
|
|
||||||
Player player = event.getPlayer();
|
|
||||||
player.addPotionEffect(new PotionEffect(PotionEffectType.JUMP, Integer.MAX_VALUE, 3));
|
|
||||||
player.addPotionEffect(new PotionEffect(PotionEffectType.SLOW_FALLING, Integer.MAX_VALUE, 3));
|
|
||||||
player.setHealth(0.5);
|
|
||||||
player.setHealthScale(0.5);
|
|
||||||
}, 5);
|
|
||||||
}
|
|
||||||
|
|
||||||
@EventHandler
|
|
||||||
public void onPlayerRespawn(PlayerRespawnEvent event) {
|
|
||||||
if (!Config.Space) return;
|
|
||||||
Bukkit.getScheduler().runTaskLater(MissileWars.getPlugin(), () -> {
|
|
||||||
Player player = event.getPlayer();
|
|
||||||
player.addPotionEffect(new PotionEffect(PotionEffectType.JUMP, Integer.MAX_VALUE, 3));
|
|
||||||
player.addPotionEffect(new PotionEffect(PotionEffectType.SLOW_FALLING, Integer.MAX_VALUE, 3));
|
|
||||||
player.setHealth(0.5);
|
|
||||||
player.setHealthScale(0.5);
|
|
||||||
}, 5);
|
|
||||||
}
|
|
||||||
|
|
||||||
@EventHandler
|
|
||||||
public void onEntitySpawn(EntitySpawnEvent event) {
|
|
||||||
if (!Config.Space) return;
|
|
||||||
if (event.getEntity() instanceof Player) return;
|
|
||||||
event.getEntity().setGravity(false);
|
|
||||||
Vector vector = event.getEntity().getVelocity();
|
|
||||||
if (event.getEntity() instanceof TNTPrimed) {
|
|
||||||
vector.setY(0);
|
|
||||||
}
|
|
||||||
event.getEntity().setVelocity(vector);
|
|
||||||
}
|
|
||||||
}
|
|
@ -87,8 +87,6 @@ public class Script {
|
|||||||
return new SlowMoScript(jsonObject);
|
return new SlowMoScript(jsonObject);
|
||||||
case "cooldown":
|
case "cooldown":
|
||||||
return new CooldownScript(jsonObject);
|
return new CooldownScript(jsonObject);
|
||||||
case "randomplayer":
|
|
||||||
return new RandomPlayerScript(jsonObject);
|
|
||||||
default:
|
default:
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
@ -24,9 +24,7 @@ import de.steamwar.misslewars.scripts.utils.JsonUtils;
|
|||||||
import org.bukkit.Location;
|
import org.bukkit.Location;
|
||||||
import org.bukkit.Material;
|
import org.bukkit.Material;
|
||||||
import org.bukkit.entity.Entity;
|
import org.bukkit.entity.Entity;
|
||||||
import org.bukkit.entity.LingeringPotion;
|
|
||||||
import org.bukkit.inventory.ItemStack;
|
import org.bukkit.inventory.ItemStack;
|
||||||
import org.bukkit.inventory.meta.Damageable;
|
|
||||||
import org.bukkit.inventory.meta.ItemMeta;
|
import org.bukkit.inventory.meta.ItemMeta;
|
||||||
import org.bukkit.inventory.meta.PotionMeta;
|
import org.bukkit.inventory.meta.PotionMeta;
|
||||||
import org.bukkit.potion.PotionEffect;
|
import org.bukkit.potion.PotionEffect;
|
||||||
@ -46,7 +44,6 @@ public class ScriptedItem {
|
|||||||
// "lore": Lore array (OPTIONAL STRING.ARRAY)
|
// "lore": Lore array (OPTIONAL STRING.ARRAY)
|
||||||
// "amount": Item amount (OPTIONAL [default 1] INT)
|
// "amount": Item amount (OPTIONAL [default 1] INT)
|
||||||
// "potion": Object with key value pairs for PotionType and Object containing duration and amplifier (OPTIONAL OBJECT)
|
// "potion": Object with key value pairs for PotionType and Object containing duration and amplifier (OPTIONAL OBJECT)
|
||||||
// "uses": Uses of Item (OPTIONAL INT)
|
|
||||||
// "EVENT.<eventName>": Event (OPTIONAL JSONobject.ARRAY)
|
// "EVENT.<eventName>": Event (OPTIONAL JSONobject.ARRAY)
|
||||||
// - onClick
|
// - onClick
|
||||||
// - onHit
|
// - onHit
|
||||||
@ -101,12 +98,6 @@ public class ScriptedItem {
|
|||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
if (jsonObject.has("uses") && itemMeta instanceof Damageable) {
|
|
||||||
int uses = jsonObject.getAsJsonPrimitive("uses").getAsInt();
|
|
||||||
Damageable damageable = (Damageable) itemMeta;
|
|
||||||
damageable.setDamage(itemStack.getType().getMaxDurability() - uses);
|
|
||||||
}
|
|
||||||
|
|
||||||
itemStack.setItemMeta(itemMeta);
|
itemStack.setItemMeta(itemMeta);
|
||||||
return itemStack;
|
return itemStack;
|
||||||
}
|
}
|
||||||
@ -124,4 +115,5 @@ public class ScriptedItem {
|
|||||||
public String getEntityName() {
|
public String getEntityName() {
|
||||||
return entityName;
|
return entityName;
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
@ -2,12 +2,9 @@ package de.steamwar.misslewars.scripts.implemented;
|
|||||||
|
|
||||||
import com.google.gson.JsonObject;
|
import com.google.gson.JsonObject;
|
||||||
import com.google.gson.JsonPrimitive;
|
import com.google.gson.JsonPrimitive;
|
||||||
import de.steamwar.misslewars.MissileWars;
|
|
||||||
import de.steamwar.misslewars.scripts.RunnableScript;
|
import de.steamwar.misslewars.scripts.RunnableScript;
|
||||||
import de.steamwar.misslewars.scripts.RunnableScriptEvent;
|
import de.steamwar.misslewars.scripts.RunnableScriptEvent;
|
||||||
import org.bukkit.Bukkit;
|
|
||||||
import org.bukkit.Material;
|
import org.bukkit.Material;
|
||||||
import org.bukkit.inventory.ItemStack;
|
|
||||||
|
|
||||||
public class CooldownScript implements RunnableScript {
|
public class CooldownScript implements RunnableScript {
|
||||||
|
|
||||||
@ -20,12 +17,8 @@ public class CooldownScript implements RunnableScript {
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
public boolean execute(RunnableScriptEvent runnableScriptEvent) {
|
public boolean execute(RunnableScriptEvent runnableScriptEvent) {
|
||||||
Material mainHand = runnableScriptEvent.getPlayer().getInventory().getItemInMainHand().getType();
|
if (runnableScriptEvent.getPlayer().getInventory().getItemInMainHand().getType() != Material.AIR) runnableScriptEvent.getPlayer().setCooldown(runnableScriptEvent.getPlayer().getInventory().getItemInMainHand().getType(), cooldown);
|
||||||
Material offHand = runnableScriptEvent.getPlayer().getInventory().getItemInOffHand().getType();
|
if (runnableScriptEvent.getPlayer().getInventory().getItemInOffHand().getType() != Material.AIR) runnableScriptEvent.getPlayer().setCooldown(runnableScriptEvent.getPlayer().getInventory().getItemInOffHand().getType(), cooldown);
|
||||||
Bukkit.getScheduler().runTaskLater(MissileWars.getPlugin(), () -> {
|
|
||||||
if (mainHand != Material.AIR) runnableScriptEvent.getPlayer().setCooldown(mainHand, cooldown);
|
|
||||||
if (offHand != Material.AIR) runnableScriptEvent.getPlayer().setCooldown(offHand, cooldown);
|
|
||||||
}, 1);
|
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -1,54 +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.misslewars.scripts.implemented;
|
|
||||||
|
|
||||||
import com.google.gson.JsonObject;
|
|
||||||
import de.steamwar.misslewars.MissileWars;
|
|
||||||
import de.steamwar.misslewars.scripts.RunnableScript;
|
|
||||||
import de.steamwar.misslewars.scripts.RunnableScriptEvent;
|
|
||||||
import org.bukkit.entity.Player;
|
|
||||||
|
|
||||||
import java.util.Random;
|
|
||||||
|
|
||||||
public class RandomPlayerScript implements RunnableScript {
|
|
||||||
|
|
||||||
private Random random = new Random();
|
|
||||||
|
|
||||||
public RandomPlayerScript(JsonObject __) {
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public boolean execute(RunnableScriptEvent runnableScriptEvent) {
|
|
||||||
int size = MissileWars.getBlueTeam().getPlayers().size() + MissileWars.getRedTeam().getPlayers().size();
|
|
||||||
if (size == 0) return true;
|
|
||||||
int index = random.nextInt(size);
|
|
||||||
Player player;
|
|
||||||
if (index >= MissileWars.getBlueTeam().getPlayers().size()) {
|
|
||||||
player = MissileWars.getRedTeam().getPlayers().get(index - MissileWars.getBlueTeam().getPlayers().size());
|
|
||||||
} else {
|
|
||||||
player = MissileWars.getBlueTeam().getPlayers().get(index);
|
|
||||||
}
|
|
||||||
runnableScriptEvent.setLocationType(RunnableScriptEvent.LocationType.CUSTOM);
|
|
||||||
runnableScriptEvent.setCustomLocation(player.getLocation().getX(), player.getLocation().getY(), player.getLocation().getZ(), player.getLocation().getPitch(), player.getLocation().getYaw());
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
}
|
|
@ -1,9 +1,7 @@
|
|||||||
setup:
|
|
||||||
- "ln -s /home/gitea/lib"
|
|
||||||
|
|
||||||
build:
|
build:
|
||||||
|
- "ln -s /home/gitea/lib"
|
||||||
|
- "cp ~/gradle.properties ."
|
||||||
- "./gradlew buildProject"
|
- "./gradlew buildProject"
|
||||||
- "./gradlew --stop"
|
|
||||||
|
|
||||||
artifacts:
|
artifacts:
|
||||||
"/binarys/missilewars.jar": "build/libs/missilewars.jar"
|
"/binarys/missilewars.jar": "build/libs/missilewars.jar"
|
||||||
|
In neuem Issue referenzieren
Einen Benutzer sperren