SteamWar/MissileWars
Archiviert
13
0

Commits vergleichen

..

62 Commits

Autor SHA1 Nachricht Datum
yoyosource
021d0a5d75 Fix Elo to only calculate for Events or Challenges
Alle Prüfungen waren erfolgreich
SteamWarCI Build successful
2024-08-04 13:04:07 +02:00
yoyosource
387fe9c694 Fix Commands
Alle Prüfungen waren erfolgreich
SteamWarCI Build successful
2024-08-03 19:26:17 +02:00
yoyosource
8ee0268b9c Hotfix MissileWars
Alle Prüfungen waren erfolgreich
SteamWarCI Build successful
2024-08-03 18:43:17 +02:00
yoyosource
09a1859979 Fix memory leak
Alle Prüfungen waren erfolgreich
SteamWarCI Build successful
2024-08-03 17:48:29 +02:00
yoyosource
38475d75ec Fix JoinListener.joinEvent
Alle Prüfungen waren erfolgreich
SteamWarCI Build successful
2024-08-03 14:42:49 +02:00
yoyosource
b5db2a4c70 Add FightEndsPacket to end call
Alle Prüfungen waren erfolgreich
SteamWarCI Build successful
2024-08-03 14:01:30 +02:00
yoyosource
76ebcc95a0 Fix TeamRedName to be German
Alle Prüfungen waren erfolgreich
SteamWarCI Build successful
2024-08-03 13:14:28 +02:00
yoyosource
b5eb7fb4af Add Event things to MissileWars
Alle Prüfungen waren erfolgreich
SteamWarCI Build successful
2024-08-03 13:12:12 +02:00
yoyosource
d1968e0c43 Update FightScoreboard
Einige Prüfungen sind fehlgeschlagen
SteamWarCI Build failed
2024-08-01 10:49:39 +02:00
yoyosource
f3f341d38e Fix MWTeam.givePlayerItem
Alle Prüfungen waren erfolgreich
SteamWarCI Build successful
2024-08-01 10:33:55 +02:00
yoyosource
8b945b0089 Fix FightScoreboard
Alle Prüfungen waren erfolgreich
SteamWarCI Build successful
2024-08-01 10:20:50 +02:00
yoyosource
95457509aa Fix many item things!
Alle Prüfungen waren erfolgreich
SteamWarCI Build successful
2024-08-01 10:17:48 +02:00
yoyosource
4c68900162 Fix commands
Alle Prüfungen waren erfolgreich
SteamWarCI Build successful
2024-07-22 16:15:45 +02:00
yoyosource
690f53716d Fix MWTeam
Alle Prüfungen waren erfolgreich
SteamWarCI Build successful
2024-07-22 14:23:28 +02:00
yoyosource
58e3120ce2 Fix SpecialItem
Alle Prüfungen waren erfolgreich
SteamWarCI Build successful
2024-07-22 12:14:57 +02:00
yoyosource
4200d62159 Fix SpecialItem
Alle Prüfungen waren erfolgreich
SteamWarCI Build successful
2024-07-22 11:52:44 +02:00
yoyosource
4602a3654b Fix InviteCommand
Alle Prüfungen waren erfolgreich
SteamWarCI Build successful
2024-07-22 11:35:36 +02:00
yoyosource
c857f33c97 Fix Item dropping
Alle Prüfungen waren erfolgreich
SteamWarCI Build successful
2024-07-22 11:31:56 +02:00
yoyosource
d280622778 Fix Item dropping
Alle Prüfungen waren erfolgreich
SteamWarCI Build successful
2024-07-22 11:29:35 +02:00
yoyosource
4b5daa208c Add Item dropping capability
Alle Prüfungen waren erfolgreich
SteamWarCI Build successful
2024-07-22 11:26:35 +02:00
yoyosource
2b3b885a7b Fix SpecialItem
Alle Prüfungen waren erfolgreich
SteamWarCI Build successful
2024-07-22 11:06:18 +02:00
yoyosource
ea37dc8287 Fix MissileWars
Alle Prüfungen waren erfolgreich
SteamWarCI Build successful
2024-07-22 11:01:03 +02:00
yoyosource
78dd77a31d Fix MWTeam.givePlayerItem
Alle Prüfungen waren erfolgreich
SteamWarCI Build successful
2024-07-22 10:53:25 +02:00
yoyosource
5c23d323d1 Fix Missile.lore
Alle Prüfungen waren erfolgreich
SteamWarCI Build successful
2024-07-22 10:49:12 +02:00
yoyosource
3f5784cecb Fix SpecialItem.getRandomItem
Alle Prüfungen waren erfolgreich
SteamWarCI Build successful
2024-07-22 10:46:59 +02:00
yoyosource
b137aaec24 Fix MWTeam.givePlayerItem
Alle Prüfungen waren erfolgreich
SteamWarCI Build successful
Update Missile.lore
2024-07-22 10:30:54 +02:00
yoyosource
4c9327face Fix errorlog
Alle Prüfungen waren erfolgreich
SteamWarCI Build successful
2024-07-22 10:19:38 +02:00
yoyosource
59a8ef91e0 Update MWTeam.givePlayerItem and ScriptedItem.createItemStack
Alle Prüfungen waren erfolgreich
SteamWarCI Build successful
2024-07-22 10:12:04 +02:00
yoyosource
b5b6fe26e2 Fix gamerule!
Alle Prüfungen waren erfolgreich
SteamWarCI Build successful
2024-06-13 22:42:50 +02:00
yoyosource
b3fcf199b7 Fix gamerule!
Alle Prüfungen waren erfolgreich
SteamWarCI Build successful
2024-06-13 22:13:54 +02:00
yoyosource
d107be9891 Fix gamerule!
Alle Prüfungen waren erfolgreich
SteamWarCI Build successful
2024-06-13 22:10:59 +02:00
yoyosource
c06fba9781 Fix build?
Alle Prüfungen waren erfolgreich
SteamWarCI Build successful
2024-06-13 21:37:46 +02:00
yoyosource
10b169d742 Update to 1.20
Alle Prüfungen waren erfolgreich
SteamWarCI Build successful
2024-06-13 20:16:23 +02:00
yoyosource
c22857457b Fix NPE of InviteCommand
Alle Prüfungen waren erfolgreich
SteamWarCI Build successful
2023-12-14 15:01:32 +01:00
yoyosource
1f7c09c352 Fix InviteCommand
Alle Prüfungen waren erfolgreich
SteamWarCI Build successful
2023-06-12 17:33:10 +02:00
ae70e0fc25 Merge pull request 'Umbau der MissileWars Commands auf das neue Command Framework' (#53) from MissileWarsCommandFramework into master
Alle Prüfungen waren erfolgreich
SteamWarCI Build successful
Reviewed-on: #53
Reviewed-by: Lixfel <lixfel@steamwar.de>
2023-06-12 16:43:07 +02:00
9618a02f0e Merge branch 'master' into MissileWarsCommandFramework
Alle Prüfungen waren erfolgreich
SteamWarCI Build successful
2023-06-12 16:41:41 +02:00
4e844f76c1 Merge pull request 'Add Gradle Plugin' (#54) from gradle into master
Alle Prüfungen waren erfolgreich
SteamWarCI Build successful
Reviewed-on: #54
Reviewed-by: YoyoNow <jwsteam@nidido.de>
2023-05-22 09:27:43 +02:00
Chaoscaot
23ad73f462 Add Gradle Plugin
Alle Prüfungen waren erfolgreich
SteamWarCI Build successful
2023-05-21 21:03:02 +02:00
Chaoscaot
595c686af8 Add Gradle Plugin
Alle Prüfungen waren erfolgreich
SteamWarCI Build successful
2023-05-21 21:02:39 +02:00
PsiRobot
b38baa5b7b Fix formatting issues
Alle Prüfungen waren erfolgreich
SteamWarCI Build successful
2023-04-21 20:49:19 +00:00
PsiRobot
b17845b85c Umbau der MissileWars Commands auf das neue Command Framework
Alle Prüfungen waren erfolgreich
SteamWarCI Build successful
2023-04-21 19:36:58 +00:00
85ba9d3233 Fix MW WorldReset
Alle Prüfungen waren erfolgreich
SteamWarCI Build successful
2023-04-18 19:49:08 +02:00
082637e924 Merge pull request 'Fix 1.19 WorldReset' (#52) from 1.19 into master
Alle Prüfungen waren erfolgreich
SteamWarCI Build successful
Reviewed-on: #52
2023-04-17 22:32:11 +02:00
Chaoscaot
c5e2eb08ab Update CopyRight
Alle Prüfungen waren erfolgreich
SteamWarCI Build successful
2023-04-17 22:25:54 +02:00
dd8ba769d6 Fix CI
Alle Prüfungen waren erfolgreich
SteamWarCI Build successful
2023-04-17 22:25:07 +02:00
Chaoscaot
75b45e7871 Fix 1.19 WorldReset
Einige Prüfungen sind fehlgeschlagen
SteamWarCI Build failed
2023-04-17 22:22:05 +02:00
yoyosource
2070c8b850 Fix SpaceListener
Alle Prüfungen waren erfolgreich
SteamWarCI Build successful
2022-12-28 21:45:21 +01:00
yoyosource
412d348b43 Fix SpaceListener
Alle Prüfungen waren erfolgreich
SteamWarCI Build successful
2022-12-28 21:44:40 +01:00
yoyosource
7a0c763923 Fix SpaceListener
Alle Prüfungen waren erfolgreich
SteamWarCI Build successful
2022-12-28 21:40:43 +01:00
yoyosource
15c204fe68 Fix SpaceListener
Alle Prüfungen waren erfolgreich
SteamWarCI Build successful
2022-12-28 21:35:54 +01:00
yoyosource
857e201ca8 Fix SpaceListener
Alle Prüfungen waren erfolgreich
SteamWarCI Build successful
2022-12-28 21:33:42 +01:00
yoyosource
00e1e929ee Fix SpaceListener
Alle Prüfungen waren erfolgreich
SteamWarCI Build successful
2022-12-28 21:22:49 +01:00
yoyosource
ca956564eb Fix SpaceListener
Alle Prüfungen waren erfolgreich
SteamWarCI Build successful
2022-12-28 21:19:22 +01:00
yoyosource
5776d56039 Fix SpaceListener
Alle Prüfungen waren erfolgreich
SteamWarCI Build successful
2022-12-28 21:16:22 +01:00
yoyosource
eed250ce95 Fix SpaceListener
Alle Prüfungen waren erfolgreich
SteamWarCI Build successful
2022-12-28 21:12:22 +01:00
yoyosource
b8da1a3d24 Add SpaceListener
Alle Prüfungen waren erfolgreich
SteamWarCI Build successful
2022-12-28 18:40:10 +01:00
yoyosource
04ef766fb4 Add BarrierListener
Alle Prüfungen waren erfolgreich
SteamWarCI Build successful
2022-12-28 18:21:02 +01:00
yoyosource
a2dafd7a1a Hotfix RandomPlayerScript
Alle Prüfungen waren erfolgreich
SteamWarCI Build successful
2022-11-15 18:09:52 +01:00
yoyosource
415ec61f7b Add RandomPlayerScript
Alle Prüfungen waren erfolgreich
SteamWarCI Build successful
2022-11-14 17:32:14 +01:00
yoyosource
67847c8ff9 Add RandomPlayerScript
Alle Prüfungen waren erfolgreich
SteamWarCI Build successful
2022-11-14 17:24:37 +01:00
yoyosource
e08982f594 Hotfix CooldownScript
Alle Prüfungen waren erfolgreich
SteamWarCI Build successful
2022-11-13 17:43:51 +01:00
32 geänderte Dateien mit 964 neuen und 649 gelöschten Zeilen

Datei anzeigen

@ -17,11 +17,6 @@
* along with this program. If not, see <https://www.gnu.org/licenses/>.
*/
import org.apache.tools.ant.taskdefs.condition.Os
import java.util.function.BiConsumer
plugins {
// Adding the base plugin fixes the following gradle warnings in IntelliJ:
//
@ -35,47 +30,16 @@ plugins {
id 'application'
id 'com.github.johnrengelman.shadow' version '5.0.0'
}
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"
}
}
id 'de.steamwar.gradle' version 'RELEASE'
}
group 'de.steamwar'
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'
sourceCompatibility = 1.8
targetCompatibility = 1.8
sourceCompatibility = 11
targetCompatibility = 11
mainClassName = ''
@ -95,11 +59,11 @@ repositories {
mavenCentral()
maven {
url = uri('https://steamwar.de/maven/')
credentials {
username = steamwarProperties.getProperty("maven.username")
password = steamwarProperties.getProperty("maven.password")
}
url = uri("https://repo.codemc.io/repository/maven-snapshots/")
}
maven {
url = uri('https://hub.spigotmc.org/nexus/content/repositories/snapshots/')
}
}
@ -109,155 +73,9 @@ dependencies {
annotationProcessor '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("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
}

Datei anzeigen

@ -17,4 +17,13 @@
* 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'

Datei anzeigen

@ -4,6 +4,9 @@ ShieldFlyTime: 100
PlatformTime: 30
EndTime: 200
# Special
Barrier: true
Arena:
MinX: 0
MaxX: 0

Datei anzeigen

@ -19,6 +19,9 @@
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.Location;
import org.bukkit.configuration.ConfigurationSection;
@ -30,86 +33,148 @@ import java.util.UUID;
import java.util.logging.Level;
public class Config {
private Config(){}
private Config() {
}
public static final int ArenaMinX;
public static final int ArenaMaxX;
public static final int ArenaMinY;
public static final int ArenaMinZ;
public static final int ArenaMaxZ;
public static final int ArenaMinX;
public static final int ArenaMaxX;
public static final int ArenaMinY;
public static final int ArenaMinZ;
public static final int ArenaMaxZ;
public static final Location RedSpawn;
public static final int RedPortalZ;
public static final Location BlueSpawn;
public static final int BluePortalZ;
public static final Location RedSpawn;
public static final int RedPortalZ;
public static final Location BlueSpawn;
public static final int BluePortalZ;
public static final int WaitingTime;
public static final int PlatformTime;
public static final int ItemTime;
public static final int ShieldFlyTime;
public static final int EndTime;
public static final int WaitingTime;
public static final int PlatformTime;
public static final int ItemTime;
public static final int ShieldFlyTime;
public static final int EndTime;
public static final double MissileChance;
public static final double MissileChance;
public static UUID BlueLeader;
public static UUID RedLeader;
public static final boolean Barrier;
public static final boolean Space;
private static final int EventKampfID;
// Challenge
public static UUID BlueLeader;
public static UUID RedLeader;
static {
File configfile = new File(Bukkit.getWorlds().get(0).getWorldFolder(), "config.yml");
if (!configfile.exists()) {
Bukkit.getLogger().log(Level.SEVERE, "Config fehlt!");
Bukkit.shutdown();
}
private static final int EventKampfID;
FileConfiguration config = YamlConfiguration.loadConfiguration(configfile);
WaitingTime = config.getInt("WaitingTime");
PlatformTime = config.getInt("PlatformTime");
ItemTime = config.getInt("ItemTime");
ShieldFlyTime = config.getInt("ShieldFlyTime");
EndTime = config.getInt("EndTime");
// 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;
MissileChance = config.getDouble("MissileChance");
static {
File configfile = new File(Bukkit.getWorlds().get(0).getWorldFolder(), "config.yml");
if (!configfile.exists()) {
Bukkit.getLogger().log(Level.SEVERE, "Config fehlt!");
Bukkit.shutdown();
}
ConfigurationSection arena = config.getConfigurationSection("Arena");
assert arena != null;
ArenaMinX = arena.getInt("MinX");
ArenaMaxX = arena.getInt("MaxX");
ArenaMinY = arena.getInt("MinY");
ArenaMinZ = arena.getInt("MinZ");
ArenaMaxZ = arena.getInt("MaxZ");
FileConfiguration config = YamlConfiguration.loadConfiguration(configfile);
WaitingTime = config.getInt("WaitingTime");
PlatformTime = config.getInt("PlatformTime");
ItemTime = config.getInt("ItemTime");
ShieldFlyTime = config.getInt("ShieldFlyTime");
EndTime = config.getInt("EndTime");
ConfigurationSection red = config.getConfigurationSection("Red");
assert red != null;
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"));
MissileChance = config.getDouble("MissileChance");
ConfigurationSection blue = config.getConfigurationSection("Blue");
assert blue != null;
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"));
ConfigurationSection arena = config.getConfigurationSection("Arena");
assert arena != null;
ArenaMinX = arena.getInt("MinX");
ArenaMaxX = arena.getInt("MaxX");
ArenaMinY = arena.getInt("MinY");
ArenaMinZ = arena.getInt("MinZ");
ArenaMaxZ = arena.getInt("MaxZ");
String blueLeader = System.getProperty("blueLeader", null);
String redLeader = System.getProperty("redLeader", null);
if(blueLeader != null)
BlueLeader = UUID.fromString(blueLeader);
else
BlueLeader = null;
if(redLeader != null)
RedLeader = UUID.fromString(redLeader);
else
RedLeader = null;
ConfigurationSection red = config.getConfigurationSection("Red");
assert red != null;
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"));
EventKampfID = Integer.parseInt(System.getProperty("fightID", "0"));
}
ConfigurationSection blue = config.getConfigurationSection("Blue");
assert blue != null;
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"));
public static boolean isChallenge() {
return BlueLeader != null && RedLeader != null;
}
String blueLeader = System.getProperty("blueLeader", null);
String redLeader = System.getProperty("redLeader", null);
if (blueLeader != null)
BlueLeader = UUID.fromString(blueLeader);
else
BlueLeader = null;
if (redLeader != null)
RedLeader = UUID.fromString(redLeader);
else
RedLeader = null;
public static boolean test(){
return EventKampfID == -1;
}
Barrier = config.getBoolean("Barrier", false);
Space = config.getBoolean("Space", false);
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() {
return BlueLeader != null && RedLeader != null;
}
public static boolean test() {
return EventKampfID == -1;
}
}

Datei anzeigen

@ -37,8 +37,8 @@ public class FightInfoPacketSender implements Runnable {
private final String serverName = Bukkit.getServer().getName();
private final String gameMode = "missilewars";
private final String worldName = world.getName();
private final String blueName = "§3blue";
private final String redName = "§cred";
private final String blueName = Config.TeamBlueColor + Config.TeamBlueName;
private final String redName = Config.TeamRedColor + Config.TeamRedName;
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;

Datei anzeigen

@ -19,24 +19,31 @@
package de.steamwar.misslewars;
import de.steamwar.scoreboard.SWScoreboard;
import de.steamwar.scoreboard.ScoreboardCallback;
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.Objective;
import org.bukkit.scoreboard.Scoreboard;
import java.text.SimpleDateFormat;
import java.util.HashMap;
import java.util.Objects;
/**
* Modified Version of the Fight-System Scoreboard
*/
class FightScoreboard {
class FightScoreboard implements Listener {
private FightScoreboard(){}
public FightScoreboard() {
Bukkit.getPluginManager().registerEvents(this, MissileWars.getPlugin());
}
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;
@ -44,34 +51,37 @@ class FightScoreboard {
return startTime;
}
static{
if(scoreboard.getObjective("AAA") == null)
objective = scoreboard.registerNewObjective("AAA", "BBB", "MissleWars");
else
objective = scoreboard.getObjective("AAA");
@EventHandler
public void onPlayerJoin(PlayerJoinEvent event) {
SWScoreboard.createScoreboard(event.getPlayer(), new ScoreboardCallback() {
@Override
public String getTitle() {
return "§eMissileWars";
}
@Override
public HashMap<String, Integer> getData() {
HashMap<String, Integer> data = new HashMap<>();
data.put("§eSpielzeit", 5);
if (startTime == 0) {
data.put("§7??:??:??", 4);
} else {
long current_time = System.currentTimeMillis() - startTime;
data.put(String.format("§7%02d:%02d", current_time / 60000, (current_time / 1000) % 60), 4);
}
data.put("", 3);
data.put("§eSpieler", 2);
MissileWars.getBlueTeam().teamScoreboard(data);
MissileWars.getRedTeam().teamScoreboard(data);
return data;
}
});
}
static void init(){
Bukkit.getScheduler().scheduleSyncRepeatingTask(MissileWars.getPlugin(), () -> {
objective.unregister();
scoreboard.registerNewObjective("AAA", "BBB", "MissleWars");
objective.setDisplaySlot(DisplaySlot.SIDEBAR);
objective.setDisplayName("§eMissileWars");
objective.getScore("§eSpielzeit").setScore(5);
if (startTime == 0) {
objective.getScore("§7??:??:??").setScore(4);
} else {
long current_time = System.currentTimeMillis() - startTime;
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);
Bukkit.getOnlinePlayers().forEach(player -> player.setScoreboard(scoreboard));
}, 0, 50);
@EventHandler
public void onPlayerQuit(PlayerQuitEvent event) {
SWScoreboard.removeScoreboard(event.getPlayer());
}
static Scoreboard getScoreboard() {
@ -81,5 +91,4 @@ class FightScoreboard {
static void startTime() {
startTime = System.currentTimeMillis();
}
}

Datei anzeigen

@ -22,11 +22,11 @@
package de.steamwar.misslewars;
import de.steamwar.core.CraftbukkitWrapper;
import net.minecraft.server.v1_15_R1.Chunk;
import net.minecraft.world.level.chunk.Chunk;
import org.bukkit.Bukkit;
import org.bukkit.World;
import org.bukkit.WorldCreator;
import org.bukkit.craftbukkit.v1_15_R1.CraftWorld;
import org.bukkit.craftbukkit.v1_20_R1.CraftWorld;
import org.bukkit.entity.Entity;
import org.bukkit.entity.EntityType;
import org.bukkit.entity.Player;
@ -36,11 +36,6 @@ import java.util.function.ObjIntConsumer;
public class FightWorld {
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){
return pos / 16.0;
@ -69,11 +64,7 @@ public class FightWorld {
}
public static void resetWorld(){
for(Entity entity : world.getEntities()){
if(entity.getType() != EntityType.PLAYER){
entity.remove();
}
}
world.getEntities().stream().filter(entity -> entity.getType() != EntityType.PLAYER).forEach(Entity::remove);
World backup = new WorldCreator(world.getName() + "/backup").createWorld();
assert backup != null;
@ -82,21 +73,12 @@ public class FightWorld {
}
private static void resetChunk(World world, World backup, int x, int z) {
net.minecraft.server.v1_15_R1.World w = ((CraftWorld) world).getHandle();
Chunk chunk = w.getChunkAt(x, z);
Chunk backupChunk = ((CraftWorld) backup).getHandle().getChunkAt(x, z);
Chunk chunk = ((CraftWorld) world).getHandle().d(x, z);
Chunk backupChunk = ((CraftWorld) backup).getHandle().d(x, z);
System.arraycopy(backupChunk.getSections(), 0, chunk.getSections(), 0, chunk.getSections().length);
w.tileEntityListTick.removeAll(chunk.tileEntities.values());
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()){
System.arraycopy(backupChunk.d(), 0, chunk.d(), 0, chunk.d().length);
for(Player p : Bukkit.getOnlinePlayers())
CraftbukkitWrapper.impl.sendChunk(p, x, z);
}
}
}

Datei anzeigen

@ -19,19 +19,23 @@
package de.steamwar.misslewars;
import org.bukkit.*;
import lombok.Getter;
import org.bukkit.ChatColor;
import org.bukkit.GameMode;
import org.bukkit.Location;
import org.bukkit.Material;
import org.bukkit.enchantments.Enchantment;
import org.bukkit.entity.Player;
import org.bukkit.inventory.Inventory;
import org.bukkit.inventory.ItemStack;
import org.bukkit.inventory.meta.Damageable;
import org.bukkit.inventory.meta.ItemMeta;
import org.bukkit.scoreboard.Objective;
import org.bukkit.scoreboard.Team;
import java.util.*;
public class MWTeam {
private static final ItemStack bow = new ItemStack(Material.BOW);
public static final ItemStack bow = new ItemStack(Material.BOW);
static {
ItemMeta bowMeta = Objects.requireNonNull(bow.getItemMeta());
@ -43,27 +47,30 @@ public class MWTeam {
bow.setItemMeta(bowMeta);
}
private final ChatColor color;
private final String color;
private final String teamName;
private final Team sbteam; //scoreboard-Team
@Getter
private final Location spawn;
@Getter
private final int portalZ;
private final LinkedList<Player> players = new LinkedList<>();
@Getter
private final LinkedList<Player> players = new LinkedList<>();
private final Set<Player> openInvitations = new HashSet<>();
MWTeam(ChatColor color, Location spawn, String teamName, int portalZ) {
MWTeam(String color, Location spawn, String teamName, int portalZ) {
this.teamName = teamName;
this.color = color;
this.spawn = spawn;
this.portalZ = portalZ;
if(FightScoreboard.getScoreboard().getTeam(teamName) == null)
if (FightScoreboard.getScoreboard().getTeam(teamName) == null)
sbteam = FightScoreboard.getScoreboard().registerNewTeam(teamName);
else
sbteam = FightScoreboard.getScoreboard().getTeam(teamName);
assert sbteam != null;
sbteam.setAllowFriendlyFire(false);
sbteam.setColor(color);
sbteam.setColor(ChatColor.getByChar(color.charAt(1)));
}
public void countdown(int timeDelay, int offset) {
@ -81,50 +88,89 @@ 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) {
if (players.isEmpty()) {
return;
}
if (players.isEmpty()) {
return;
}
Player p = players.removeFirst();
players.addLast(p);
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);
if (itemStack != null && itemStack.isSimilar(item) && itemStack.getAmount() + item.getAmount() <= itemStack.getMaxStackSize()) {
if (itemStack == null) continue;
if (itemStack.isSimilar(item) && itemStack.getAmount() + item.getAmount() <= item.getMaxStackSize()) {
itemStack.setAmount(itemStack.getAmount() + item.getAmount());
inventory.setItem(i, itemStack);
p.updateInventory();
return;
}
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;
}
}
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);
if (itemStack == null || itemStack.getType().equals(Material.AIR)) {
inventory.setItem(i, item);
p.updateInventory();
return;
}
}
}
public void teamScoreboard(Objective objective) {
players.forEach(p -> objective.getScore(getColorCode() + p.getName()).setScore(1));
public void teamScoreboard(HashMap<String, Integer> data) {
players.forEach(player -> {
data.put(getColorCode() + player.getName(), 1);
});
}
public int size() {
return players.size();
}
public int getPortalZ() {
return portalZ;
}
public Location getSpawn(){
return spawn;
}
public void join(Player p) {
players.add(p);
p.teleport(spawn);
@ -182,8 +228,8 @@ public class MWTeam {
return MissileWars.getRedTeam();
}
public String getColorCode(){
return "§" + color.getChar();
public String getColorCode() {
return color;
}
public boolean hasPlayer(Player p) {
@ -195,16 +241,11 @@ public class MWTeam {
}
public String getColoredName() {
return color.toString() + teamName;
}
public LinkedList<Player> getPlayers() {
return players;
return color + teamName;
}
public static void removeInvitations(Player p) {
MissileWars.getRedTeam().openInvitations.remove(p);
MissileWars.getBlueTeam().openInvitations.remove(p);
}
}

Datei anzeigen

@ -1,7 +1,7 @@
/*
This file is a part of the SteamWar software.
Copyright (C) 2020 SteamWar.de-Serverteam
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
@ -19,21 +19,23 @@
package de.steamwar.misslewars;
import de.steamwar.misslewars.commands.CommandAcceptDecline;
import de.steamwar.misslewars.commands.CommandInvite;
import de.steamwar.misslewars.commands.CommandItems;
import de.steamwar.misslewars.commands.CommandSpectate;
import de.steamwar.misslewars.commands.AcceptCommand;
import de.steamwar.misslewars.commands.DeclineCommand;
import de.steamwar.misslewars.commands.InviteCommand;
import de.steamwar.misslewars.commands.SpectateCommand;
import de.steamwar.misslewars.countdowns.EndCountdown;
import de.steamwar.misslewars.countdowns.ItemCountdown;
import de.steamwar.misslewars.countdowns.WaitingCountdown;
import de.steamwar.misslewars.items.CustomItem;
import de.steamwar.misslewars.items.Missile;
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 org.bukkit.Bukkit;
import org.bukkit.ChatColor;
import org.bukkit.GameMode;
import org.bukkit.Sound;
import de.steamwar.network.NetworkSender;
import de.steamwar.network.packets.common.FightEndsPacket;
import de.steamwar.sql.SteamwarUser;
import org.bukkit.*;
import org.bukkit.entity.Entity;
import org.bukkit.entity.Player;
import org.bukkit.plugin.java.JavaPlugin;
@ -59,8 +61,8 @@ public class MissileWars extends JavaPlugin {
@Override
public void onEnable() {
redTeam = new MWTeam(ChatColor.RED, Config.RedSpawn, "Rot", Config.RedPortalZ);
blueTeam = new MWTeam(ChatColor.DARK_AQUA, Config.BlueSpawn, "Blau", Config.BluePortalZ);
redTeam = new MWTeam(Config.TeamRedColor, Config.RedSpawn, Config.TeamRedName, Config.RedPortalZ);
blueTeam = new MWTeam(Config.TeamBlueColor, Config.BlueSpawn, Config.TeamBlueName, Config.BluePortalZ);
new BreakListener();
new DeathListener();
new ItemListener();
@ -72,31 +74,35 @@ public class MissileWars extends JavaPlugin {
new WaitingListener();
new FightListener();
new ChatListener();
getCommand("spectate").setExecutor(new CommandSpectate());
new SpectateCommand();
// Invitation Commands
CommandInvite commandInvite = new CommandInvite();
getCommand("invite").setExecutor(commandInvite);
getCommand("invite").setTabCompleter(commandInvite);
getCommand("accept").setExecutor(new CommandAcceptDecline());
getCommand("decline").setExecutor(new CommandAcceptDecline());
new InviteCommand();
new AcceptCommand();
new DeclineCommand();
new WaitingCountdown();
new ItemCountdown();
new EndCountdown();
FightScoreboard.init();
new FightScoreboard();
Missile.init();
CustomItem.init();
StateDependent.setupState(fightState);
new BarrierListener();
new SpaceListener();
Bukkit.getScheduler().runTaskTimer(this, new FightInfoPacketSender(), 20, 20);
if(Config.test()) {
new CommandItems();
}
Bukkit.getWorlds().forEach(world -> {
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() {
@ -143,6 +149,23 @@ public class MissileWars extends JavaPlugin {
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) {
case PORTAL_DESTROYED:
Bukkit.getServer().broadcastMessage(winner.getColoredName() + ChatColor.RESET + " §7hat das gegnerische Portal zerstört");
@ -186,14 +209,6 @@ public class MissileWars extends JavaPlugin {
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) {
MissileWars.getBlueTeam().leave(p);
MissileWars.getRedTeam().leave(p);

Datei anzeigen

@ -2,7 +2,7 @@
*
* This file is a part of the SteamWar software.
*
* Copyright (C) 2020 SteamWar.de-Serverteam
* 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
@ -16,49 +16,55 @@
*
* 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.Bukkit;
import org.bukkit.command.Command;
import org.bukkit.command.CommandExecutor;
import org.bukkit.command.CommandSender;
import org.bukkit.entity.Player;
public class CommandAcceptDecline implements CommandExecutor {
public class AcceptCommand extends SWCommand {
@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;
}
public AcceptCommand() {
super("accept");
}
@Register
public void onCommand(@Validator Player player, String... varargs) {
MWTeam teamInvitation = MissileWars.getInvitation(player);
if (teamInvitation == null) {
player.sendMessage("§cDu wurdest nicht eingeladen.");
return false;
}
if (command.getName().equalsIgnoreCase("accept")) {
} else {
teamInvitation.acceptInvite(player);
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;
}
@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));
}
}

Datei anzeigen

@ -1,95 +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.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<>();
}
}

Datei anzeigen

@ -1,24 +0,0 @@
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();
}
}

Datei anzeigen

@ -1,55 +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.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;
}
}

Datei anzeigen

@ -0,0 +1,70 @@
/*
*
* 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));
}
}

Datei anzeigen

@ -0,0 +1,99 @@
/*
*
* 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);
}
}

Datei anzeigen

@ -0,0 +1,69 @@
/*
*
* 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);
}
}

Datei anzeigen

@ -36,7 +36,11 @@ public class EndCountdown extends StateDependent {
@Override
public void enable() {
task = Bukkit.getScheduler().runTaskLater(MissileWars.getPlugin(), this::restart, Config.EndTime);
if (Config.isEvent()) {
task = Bukkit.getScheduler().runTaskLater(MissileWars.getPlugin(), this::stop, 1200);
} else {
task = Bukkit.getScheduler().runTaskLater(MissileWars.getPlugin(), this::restart, Config.EndTime);
}
}
private void restart() {
@ -44,6 +48,17 @@ public class EndCountdown extends StateDependent {
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
public void disable() {
if (task != null && !task.isCancelled())

Datei anzeigen

@ -41,11 +41,6 @@ public class ItemCountdown extends StateDependent {
}
private void run() {
if (currenTime == 0) {
ItemStack itemStack = SpecialItem.getRandomItem();
MissileWars.getBlueTeam().givePlayerItem(itemStack);
MissileWars.getRedTeam().givePlayerItem(itemStack);
}
currenTime++;
int teamCount = Math.max(MissileWars.getBlueTeam().size(), MissileWars.getRedTeam().size());

Datei anzeigen

@ -72,7 +72,7 @@ public class CustomItem extends SpecialItem {
new CustomItem(new ScriptedItem(jsonObject));
} catch (JsonSyntaxException | IOException e) {
e.printStackTrace();
throw new SecurityException("Item JSON error", e);
throw new SecurityException("Item JSON error " + itemFile, e);
}
}
}

Datei anzeigen

@ -49,7 +49,6 @@ import java.util.Objects;
public class Missile extends SpecialItem {
private static final World world = new BukkitWorld(Bukkit.getWorlds().get(0));
private static final int GRAPH_SIZE = 7;
private final Clipboard clipboard;
private final ItemStack item;
@ -70,8 +69,8 @@ public class Missile extends SpecialItem {
}
List<String> lore = new ArrayList<>();
lore(lore, strings, 2, " §7Speed");
lore(lore, strings, 3, " §7Size");
lore(lore, strings, 2, "§7Speed");
lore(lore, strings, 3, "§7Size");
EditSession e = WorldEdit.getInstance().getEditSessionFactory().getEditSession(world, -1);
BlockTypeMask blockTypeMask = new BlockTypeMask(clipboard, BlockTypes.TNT);
@ -82,32 +81,10 @@ public class Missile extends SpecialItem {
private void lore(List<String> lore, String[] args, int index, String tag) {
if (args.length > index) {
try {
lore.add(graph(Integer.parseInt(args[index]), GRAPH_SIZE) + tag);
return;
} catch (NumberFormatException e) {
// Ignored
}
lore.add(tag + " §8: §e" + Integer.parseInt(args[index]) + "§8/§77");
} else {
lore.add(tag + " §8: §e0§8/§77");
}
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

Datei anzeigen

@ -40,7 +40,8 @@ import java.util.Random;
public abstract class SpecialItem {
private static final Random random = new Random();
private static boolean lastItemWasSupportItem = false;
private static double count = 0;
private static int consecutiveSupportItems = 0;
private static List<SpecialItem> supportItems = new ArrayList<>();
private static List<SpecialItem> missileItems = new ArrayList<>();
@ -110,20 +111,22 @@ public abstract class SpecialItem {
}
public static ItemStack getRandomItem() {
if (!lastItemWasSupportItem && random.nextDouble() > Config.MissileChance) {
lastItemWasSupportItem = true;
if (Config.MissileChance == 0 || consecutiveSupportItems > 1) {
consecutiveSupportItems = 0;
return supportItems.get(random.nextInt(supportItems.size())).getItem();
}
lastItemWasSupportItem = false;
return missileItems.get(random.nextInt(missileItems.size())).getItem();
}
if (Config.MissileChance == 1) {
return missileItems.get(random.nextInt(missileItems.size())).getItem();
}
public static List<ItemStack> getAllItems() {
List<ItemStack> items = new ArrayList<>();
for (SpecialItem specialItem : supportItems)
items.add(specialItem.getItem());
for (SpecialItem specialItem : missileItems)
items.add(specialItem.getItem());
return items;
double missileChance = Config.MissileChance + count * 0.1;
if (random.nextDouble() > missileChance) {
count += Config.MissileChance;
consecutiveSupportItems++;
return supportItems.get(random.nextInt(supportItems.size())).getItem();
} else {
count -= 1 - Config.MissileChance;
return missileItems.get(random.nextInt(missileItems.size())).getItem();
}
}
}

Datei anzeigen

@ -21,12 +21,15 @@ package de.steamwar.misslewars.listener;
import de.steamwar.misslewars.Config;
import de.steamwar.misslewars.FightState;
import de.steamwar.misslewars.MWTeam;
import de.steamwar.misslewars.MissileWars;
import org.bukkit.GameMode;
import org.bukkit.Location;
import org.bukkit.entity.Player;
import org.bukkit.event.EventHandler;
import org.bukkit.event.entity.EntityPickupItemEvent;
import org.bukkit.event.entity.FoodLevelChangeEvent;
import org.bukkit.event.entity.ItemDespawnEvent;
import org.bukkit.event.inventory.InventoryOpenEvent;
import org.bukkit.event.inventory.InventoryType;
import org.bukkit.event.player.PlayerDropItemEvent;
@ -34,6 +37,7 @@ import org.bukkit.event.player.PlayerMoveEvent;
import org.bukkit.event.player.PlayerPickupArrowEvent;
import java.util.EnumSet;
import java.util.Map;
import java.util.Objects;
public class ArenaListener extends BasicListener {
@ -69,12 +73,7 @@ public class ArenaListener extends BasicListener {
e.setCancelled(true);
}
@EventHandler
public void onItemDrop(PlayerDropItemEvent e){
e.setCancelled(true);
}
@EventHandler
@EventHandler
public void onHunger(FoodLevelChangeEvent e){
e.setCancelled(true);
}

Datei anzeigen

@ -31,7 +31,7 @@ import java.util.Set;
public abstract class BasicListener extends StateDependent implements Listener {
BasicListener(final Set<FightState> active){
protected BasicListener(final Set<FightState> active){
super(active);
}

Datei anzeigen

@ -20,28 +20,47 @@
package de.steamwar.misslewars.listener;
import de.steamwar.misslewars.FightState;
import de.steamwar.misslewars.MWTeam;
import de.steamwar.misslewars.MissileWars;
import de.steamwar.misslewars.items.SpecialItem;
import org.bukkit.Material;
import org.bukkit.entity.Player;
import org.bukkit.event.EventHandler;
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.ProjectileLaunchEvent;
import org.bukkit.event.player.PlayerDropItemEvent;
import org.bukkit.event.player.PlayerInteractEvent;
import org.bukkit.inventory.ItemStack;
import java.util.EnumSet;
import java.util.HashSet;
import java.util.Set;
public class ItemListener extends BasicListener {
private Set<Integer> RED_ITEMS = new HashSet<>();
private Set<Integer> BLUE_ITEMS = new HashSet<>();
public ItemListener() {
super(EnumSet.of(FightState.FIGHTING));
}
@Override
public void enable() {
super.enable();
RED_ITEMS.clear();
BLUE_ITEMS.clear();
}
@EventHandler
public void onItemClick(PlayerInteractEvent e) {
ItemStack item = e.getItem();
if (item == null)
return;
if (e.getPlayer().hasCooldown(item.getType())) return;
if (e.getAction() != Action.RIGHT_CLICK_BLOCK && e.getAction() != Action.RIGHT_CLICK_AIR)
return;
@ -63,4 +82,42 @@ public class ItemListener extends BasicListener {
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());
}
}

Datei anzeigen

@ -22,6 +22,7 @@ package de.steamwar.misslewars.listener;
import de.steamwar.misslewars.Config;
import de.steamwar.misslewars.FightState;
import de.steamwar.misslewars.MissileWars;
import de.steamwar.sql.SteamwarUser;
import org.bukkit.entity.Player;
import org.bukkit.event.EventHandler;
import org.bukkit.event.EventPriority;
@ -42,16 +43,59 @@ public class JoinListener extends BasicListener {
}
public static void join(Player p) {
if (Config.isChallenge()) {
if (Config.RedLeader.equals(p.getUniqueId())) {
MissileWars.getRedTeam().join(p);
} else if (Config.BlueLeader.equals(p.getUniqueId())) {
MissileWars.getBlueTeam().join(p);
} else {
p.teleport(MissileWars.getRedTeam().getSpawn().toVector().midpoint(MissileWars.getBlueTeam().getSpawn().toVector()).toLocation(p.getWorld()));
}
if (Config.isEvent()) {
joinEvent(p);
return;
}
MissileWars.join(p);
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())) {
MissileWars.getRedTeam().join(p);
} else if (Config.BlueLeader.equals(p.getUniqueId())) {
MissileWars.getBlueTeam().join(p);
} else {
p.teleport(MissileWars.getRedTeam().getSpawn().toVector().midpoint(MissileWars.getBlueTeam().getSpawn().toVector()).toLocation(p.getWorld()));
}
}
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);
}
}
}

Datei anzeigen

@ -0,0 +1,58 @@
/*
*
* 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;
}
}
}
}

Datei anzeigen

@ -0,0 +1,82 @@
/*
*
* 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);
}
}

Datei anzeigen

@ -87,6 +87,8 @@ public class Script {
return new SlowMoScript(jsonObject);
case "cooldown":
return new CooldownScript(jsonObject);
case "randomplayer":
return new RandomPlayerScript(jsonObject);
default:
return null;
}

Datei anzeigen

@ -24,7 +24,9 @@ import de.steamwar.misslewars.scripts.utils.JsonUtils;
import org.bukkit.Location;
import org.bukkit.Material;
import org.bukkit.entity.Entity;
import org.bukkit.entity.LingeringPotion;
import org.bukkit.inventory.ItemStack;
import org.bukkit.inventory.meta.Damageable;
import org.bukkit.inventory.meta.ItemMeta;
import org.bukkit.inventory.meta.PotionMeta;
import org.bukkit.potion.PotionEffect;
@ -44,6 +46,7 @@ public class ScriptedItem {
// "lore": Lore array (OPTIONAL STRING.ARRAY)
// "amount": Item amount (OPTIONAL [default 1] INT)
// "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)
// - onClick
// - onHit
@ -98,6 +101,12 @@ 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);
return itemStack;
}
@ -115,5 +124,4 @@ public class ScriptedItem {
public String getEntityName() {
return entityName;
}
}

Datei anzeigen

@ -2,9 +2,12 @@ package de.steamwar.misslewars.scripts.implemented;
import com.google.gson.JsonObject;
import com.google.gson.JsonPrimitive;
import de.steamwar.misslewars.MissileWars;
import de.steamwar.misslewars.scripts.RunnableScript;
import de.steamwar.misslewars.scripts.RunnableScriptEvent;
import org.bukkit.Bukkit;
import org.bukkit.Material;
import org.bukkit.inventory.ItemStack;
public class CooldownScript implements RunnableScript {
@ -17,8 +20,12 @@ public class CooldownScript implements RunnableScript {
@Override
public boolean execute(RunnableScriptEvent runnableScriptEvent) {
if (runnableScriptEvent.getPlayer().getInventory().getItemInMainHand().getType() != Material.AIR) runnableScriptEvent.getPlayer().setCooldown(runnableScriptEvent.getPlayer().getInventory().getItemInMainHand().getType(), cooldown);
if (runnableScriptEvent.getPlayer().getInventory().getItemInOffHand().getType() != Material.AIR) runnableScriptEvent.getPlayer().setCooldown(runnableScriptEvent.getPlayer().getInventory().getItemInOffHand().getType(), cooldown);
Material mainHand = runnableScriptEvent.getPlayer().getInventory().getItemInMainHand().getType();
Material offHand = runnableScriptEvent.getPlayer().getInventory().getItemInOffHand().getType();
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;
}
}

Datei anzeigen

@ -0,0 +1,54 @@
/*
*
* 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;
}
}

Datei anzeigen

@ -1,7 +1,9 @@
build:
setup:
- "ln -s /home/gitea/lib"
- "cp ~/gradle.properties ."
build:
- "./gradlew buildProject"
- "./gradlew --stop"
artifacts:
"/binarys/missilewars.jar": "build/libs/missilewars.jar"