Begin rework
Dieser Commit ist enthalten in:
Ursprung
4947ede7dd
Commit
1e731c11f0
3
.gitignore
vendored
Normale Datei
3
.gitignore
vendored
Normale Datei
@ -0,0 +1,3 @@
|
|||||||
|
.idea
|
||||||
|
*.iml
|
||||||
|
target
|
59
pom.xml
Normale Datei
59
pom.xml
Normale Datei
@ -0,0 +1,59 @@
|
|||||||
|
<?xml version="1.0" encoding="UTF-8"?>
|
||||||
|
<project xmlns="http://maven.apache.org/POM/4.0.0"
|
||||||
|
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
|
||||||
|
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
|
||||||
|
<modelVersion>4.0.0</modelVersion>
|
||||||
|
|
||||||
|
<groupId>steamwar</groupId>
|
||||||
|
<artifactId>MissileWars</artifactId>
|
||||||
|
<version>1.0</version>
|
||||||
|
|
||||||
|
<properties>
|
||||||
|
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
|
||||||
|
</properties>
|
||||||
|
|
||||||
|
<repositories>
|
||||||
|
<repository>
|
||||||
|
<id>steamwar</id>
|
||||||
|
<url>https://steamwar.de:81/maven</url>
|
||||||
|
</repository>
|
||||||
|
</repositories>
|
||||||
|
|
||||||
|
<build>
|
||||||
|
<sourceDirectory>src</sourceDirectory>
|
||||||
|
<resources>
|
||||||
|
<resource>
|
||||||
|
<directory>src</directory>
|
||||||
|
<excludes>
|
||||||
|
<exclude>**/*.java</exclude>
|
||||||
|
<exclude>**/*.kt</exclude>
|
||||||
|
</excludes>
|
||||||
|
</resource>
|
||||||
|
</resources>
|
||||||
|
<plugins>
|
||||||
|
<plugin>
|
||||||
|
<groupId>org.apache.maven.plugins</groupId>
|
||||||
|
<artifactId>maven-compiler-plugin</artifactId>
|
||||||
|
<version>3.6.1</version>
|
||||||
|
<configuration>
|
||||||
|
<source>1.8</source>
|
||||||
|
<target>1.8</target>
|
||||||
|
</configuration>
|
||||||
|
</plugin>
|
||||||
|
</plugins>
|
||||||
|
<finalName>missilewars</finalName>
|
||||||
|
</build>
|
||||||
|
|
||||||
|
<dependencies>
|
||||||
|
<dependency>
|
||||||
|
<groupId>steamwar</groupId>
|
||||||
|
<artifactId>Spigot</artifactId>
|
||||||
|
<version>1.15</version>
|
||||||
|
</dependency>
|
||||||
|
<dependency>
|
||||||
|
<groupId>steamwar</groupId>
|
||||||
|
<artifactId>SpigotCore</artifactId>
|
||||||
|
<version>2.0</version>
|
||||||
|
</dependency>
|
||||||
|
</dependencies>
|
||||||
|
</project>
|
@ -1,4 +1,4 @@
|
|||||||
Rot ist im süden
|
Rot ist im süden
|
||||||
SpawnEgg name == MissleName (Config)
|
SpawnEgg name == MissleName (Config)
|
||||||
incl Color-Tags, ect
|
incl Color-Tags, ect
|
||||||
Missle-Configs sind für Team Rot
|
Missle-Configs sind für Team Rot
|
@ -1,7 +1,3 @@
|
|||||||
Commands:
|
|
||||||
join
|
|
||||||
leave
|
|
||||||
forcestop
|
|
||||||
Config:
|
Config:
|
||||||
Timeout-Time
|
Timeout-Time
|
||||||
Runden max length
|
Runden max length
|
||||||
@ -16,4 +12,3 @@ Features
|
|||||||
bridge
|
bridge
|
||||||
Item-giver
|
Item-giver
|
||||||
am anfang bogen geben
|
am anfang bogen geben
|
||||||
listener + commadns registrieren
|
|
@ -1,28 +0,0 @@
|
|||||||
package de.steamwar.misslewars;
|
|
||||||
|
|
||||||
import java.util.TimerTask;
|
|
||||||
|
|
||||||
import org.bukkit.Bukkit;
|
|
||||||
|
|
||||||
public class EndTimer extends TimerTask{
|
|
||||||
|
|
||||||
private boolean endPrep; //if true it counts to end of preparing (after end server if not ingame); if false it counts to end of game -> win
|
|
||||||
|
|
||||||
public EndTimer(boolean endPrep) {
|
|
||||||
this.endPrep = endPrep;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public void run() {
|
|
||||||
if (endPrep) {
|
|
||||||
if (MissleWars.getFightState() != FightState.WAITING) return;
|
|
||||||
Bukkit.getServer().broadcastMessage("Da kein Gegner gefunden wurde schaltet der Server sich jetzt ab.");
|
|
||||||
Bukkit.getServer().shutdown();
|
|
||||||
}else {
|
|
||||||
if (MissleWars.getFightState() == FightState.END) return;
|
|
||||||
//TODO end match - unentschieden
|
|
||||||
}
|
|
||||||
this.cancel();
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
|
@ -1,7 +1,5 @@
|
|||||||
package de.steamwar.misslewars;
|
package de.steamwar.misslewars;
|
||||||
|
|
||||||
import de.steamwar.misslewars.MWTeam;
|
|
||||||
|
|
||||||
import org.bukkit.Bukkit;
|
import org.bukkit.Bukkit;
|
||||||
import org.bukkit.scoreboard.DisplaySlot;
|
import org.bukkit.scoreboard.DisplaySlot;
|
||||||
import org.bukkit.scoreboard.Objective;
|
import org.bukkit.scoreboard.Objective;
|
||||||
@ -29,7 +27,7 @@ public class FightScoreboard {
|
|||||||
}
|
}
|
||||||
|
|
||||||
public static void init(){
|
public static void init(){
|
||||||
Bukkit.getScheduler().scheduleSyncRepeatingTask(MissleWars.getPlugin(), () -> {
|
Bukkit.getScheduler().scheduleSyncRepeatingTask(MissileWars.getPlugin(), () -> {
|
||||||
objective.unregister();
|
objective.unregister();
|
||||||
//noinspection deprecation
|
//noinspection deprecation
|
||||||
scoreboard.registerNewObjective("AAA", "BBB", "MissleWars");
|
scoreboard.registerNewObjective("AAA", "BBB", "MissleWars");
|
||||||
@ -51,14 +49,14 @@ public class FightScoreboard {
|
|||||||
|
|
||||||
private static void teamScoreboard(MWTeam fightTeam){
|
private static void teamScoreboard(MWTeam fightTeam){
|
||||||
objective.setDisplayName(fightTeam.getColoredName());
|
objective.setDisplayName(fightTeam.getColoredName());
|
||||||
fightTeam.getPlayers().forEach(fp -> {
|
fightTeam.getPlayers().forEach(p -> {
|
||||||
objective.getScore(fightTeam.getPrefix() + fp.getPlayer().getName()).setScore((int) fp.getKills());
|
objective.getScore(fightTeam.getPrefix() + p.getName()).setScore(1);
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
private static void generalScoreboard(){
|
private static void generalScoreboard(){
|
||||||
objective.setDisplayName("§6Kampf");
|
objective.setDisplayName("§6Kampf");
|
||||||
int fightTime = MissleWars.getFightTime();
|
int fightTime = MissileWars.getFightTime();
|
||||||
if (fightTime >= 60)
|
if (fightTime >= 60)
|
||||||
objective.getScore("§7Zeit: §a" + fightTime / 60 + "m " + fightTime % 60 + "s").setScore(3);
|
objective.getScore("§7Zeit: §a" + fightTime / 60 + "m " + fightTime % 60 + "s").setScore(3);
|
||||||
else
|
else
|
||||||
@ -68,9 +66,9 @@ public class FightScoreboard {
|
|||||||
private static MWTeam getIndexDisplay() {
|
private static MWTeam getIndexDisplay() {
|
||||||
index++;
|
index++;
|
||||||
if(index == 1)
|
if(index == 1)
|
||||||
return MissleWars.redTeam;
|
return MissileWars.getRedTeam();
|
||||||
if(index == 2)
|
if(index == 2)
|
||||||
return MissleWars.blueTeam;
|
return MissileWars.getBlueTeam();
|
||||||
index = 0;
|
index = 0;
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
@ -1,7 +1,7 @@
|
|||||||
package de.steamwar.misslewars;
|
package de.steamwar.misslewars;
|
||||||
|
|
||||||
public enum FightState {
|
public enum FightState {
|
||||||
WAITING, //waiting for at least 2Players
|
WAITING, // waiting for at least 2 players
|
||||||
FIGHTING, //no one has Won
|
FIGHTING, // no one has won
|
||||||
END // fight ended for some reason
|
END // fight ended for some reason
|
||||||
}
|
}
|
||||||
|
@ -1,24 +0,0 @@
|
|||||||
package de.steamwar.misslewars;
|
|
||||||
|
|
||||||
import org.bukkit.entity.Player;
|
|
||||||
|
|
||||||
public class MWPlayer {
|
|
||||||
private Player p;
|
|
||||||
private int kills = 0;
|
|
||||||
|
|
||||||
public int getKills() {
|
|
||||||
return kills;
|
|
||||||
}
|
|
||||||
|
|
||||||
public void addKill() {
|
|
||||||
kills++;
|
|
||||||
}
|
|
||||||
|
|
||||||
public MWPlayer (Player p) {
|
|
||||||
this.p = p;
|
|
||||||
}
|
|
||||||
|
|
||||||
public Player getPlayer() {
|
|
||||||
return p;
|
|
||||||
}
|
|
||||||
}
|
|
@ -1,86 +1,91 @@
|
|||||||
package de.steamwar.misslewars;
|
package de.steamwar.misslewars;
|
||||||
|
|
||||||
import java.util.ArrayList;
|
|
||||||
import java.util.List;
|
|
||||||
|
|
||||||
import org.bukkit.ChatColor;
|
import org.bukkit.ChatColor;
|
||||||
import org.bukkit.Location;
|
import org.bukkit.Location;
|
||||||
|
import org.bukkit.Material;
|
||||||
|
import org.bukkit.enchantments.Enchantment;
|
||||||
import org.bukkit.entity.Player;
|
import org.bukkit.entity.Player;
|
||||||
|
import org.bukkit.inventory.ItemStack;
|
||||||
import org.bukkit.scoreboard.Team;
|
import org.bukkit.scoreboard.Team;
|
||||||
import org.bukkit.scoreboard.Team.Option;
|
|
||||||
import org.bukkit.scoreboard.Team.OptionStatus;
|
import java.util.HashSet;
|
||||||
|
import java.util.Objects;
|
||||||
|
import java.util.Set;
|
||||||
|
|
||||||
public class MWTeam {
|
public class MWTeam {
|
||||||
private ChatColor color;
|
private static final ItemStack bow = new ItemStack(Material.BOW);
|
||||||
private String teamName;
|
|
||||||
private String prefix;
|
|
||||||
private Team sbteam; //scoreboard-Team
|
|
||||||
private ArrayList<MWPlayer> spieler = new ArrayList<MWPlayer>();
|
|
||||||
private Location spawn;
|
|
||||||
|
|
||||||
public List<MWPlayer> getPlayers(){
|
static {
|
||||||
return spieler;
|
Objects.requireNonNull(bow.getItemMeta()).addEnchant(Enchantment.ARROW_FIRE, 1, false);
|
||||||
}
|
}
|
||||||
|
|
||||||
public MWTeam(ChatColor color, String teamName, String prefix) {
|
private final ChatColor color;
|
||||||
|
private final String teamName;
|
||||||
|
private final Team sbteam; //scoreboard-Team
|
||||||
|
private final Location spawn;
|
||||||
|
private final int portalZ;
|
||||||
|
|
||||||
|
private Set<Player> players = new HashSet<>();
|
||||||
|
|
||||||
|
public Set<Player> getPlayers(){
|
||||||
|
return players;
|
||||||
|
}
|
||||||
|
|
||||||
|
public MWTeam(ChatColor color, Location spawn, String teamName, int portalZ) {
|
||||||
this.teamName = teamName;
|
this.teamName = teamName;
|
||||||
this.prefix = prefix;
|
|
||||||
this.color = color;
|
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);
|
sbteam = FightScoreboard.getScoreboard().registerNewTeam(teamName);
|
||||||
else
|
else
|
||||||
sbteam = FightScoreboard.getScoreboard().getTeam(teamName);
|
sbteam = FightScoreboard.getScoreboard().getTeam(teamName);
|
||||||
assert sbteam != null;
|
assert sbteam != null;
|
||||||
sbteam.setOption(Option.NAME_TAG_VISIBILITY, OptionStatus.FOR_OWN_TEAM);
|
|
||||||
sbteam.setAllowFriendlyFire(false);
|
sbteam.setAllowFriendlyFire(false);
|
||||||
|
sbteam.setColor(color);
|
||||||
}
|
}
|
||||||
|
|
||||||
public void tpToSpawn(Player p) {
|
public int getPortalZ() {
|
||||||
p.teleport(spawn);
|
return portalZ;
|
||||||
|
}
|
||||||
|
|
||||||
|
public Location getSpawn(){
|
||||||
|
return spawn;
|
||||||
}
|
}
|
||||||
|
|
||||||
public void join (Player p) {
|
public void join (Player p) {
|
||||||
spieler.add(new MWPlayer(p));
|
players.add(p);
|
||||||
p.setDisplayName(color + "[" + teamName + "]" + p.getName());
|
p.teleport(spawn);
|
||||||
if (MissleWars.getFightState() == FightState.WAITING) {
|
p.setItemOnCursor(bow);
|
||||||
if (!enemy().getPlayers().isEmpty())
|
sbteam.addPlayer(p);
|
||||||
MissleWars.startRound();
|
p.setDisplayName(color + teamName + " " + p.getName());
|
||||||
}
|
if (MissileWars.getFightState() == FightState.WAITING && !enemy().getPlayers().isEmpty())
|
||||||
|
MissileWars.startRound();
|
||||||
}
|
}
|
||||||
|
|
||||||
public void leave (Player p) {
|
public void leave (Player p) {
|
||||||
for (MWPlayer pl : spieler) {
|
if(!players.contains(p))
|
||||||
if (p == pl.getPlayer()) {
|
return;
|
||||||
spieler.remove(pl);
|
|
||||||
break;
|
players.remove(p);
|
||||||
}
|
sbteam.removePlayer(p);
|
||||||
p.setDisplayName(p.getName());
|
if (players.isEmpty())
|
||||||
}
|
MissileWars.end(WinReasons.NO_ENEMY, enemy());
|
||||||
if (spieler.isEmpty())
|
|
||||||
MissleWars.end(WinReasons.NOENEMY, enemy());
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public MWTeam enemy() {
|
public MWTeam enemy() {
|
||||||
if (this == MissleWars.redTeam) return MissleWars.blueTeam;
|
if (this == MissileWars.getRedTeam())
|
||||||
return MissleWars.redTeam;
|
return MissileWars.getBlueTeam();
|
||||||
|
|
||||||
|
return MissileWars.getRedTeam();
|
||||||
}
|
}
|
||||||
|
|
||||||
public String getPrefix(){
|
public String getPrefix(){
|
||||||
return prefix;
|
return "§" + color.getChar();
|
||||||
}
|
}
|
||||||
|
|
||||||
public boolean hasPlayer (Player p) {
|
public boolean hasPlayer (Player p) {
|
||||||
for (MWPlayer pl : spieler)
|
return players.contains(p);
|
||||||
if (p == pl.getPlayer())
|
|
||||||
return true;
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
|
|
||||||
public MWPlayer getPlayer (Player p) {
|
|
||||||
for (MWPlayer pl : spieler)
|
|
||||||
if (p == pl.getPlayer())
|
|
||||||
return pl;
|
|
||||||
return null;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public String getColoredName() {
|
public String getColoredName() {
|
||||||
|
119
src/de/steamwar/misslewars/MissileWars.java
Normale Datei
119
src/de/steamwar/misslewars/MissileWars.java
Normale Datei
@ -0,0 +1,119 @@
|
|||||||
|
package de.steamwar.misslewars;
|
||||||
|
|
||||||
|
import de.steamwar.misslewars.listener.*;
|
||||||
|
import org.bukkit.Bukkit;
|
||||||
|
import org.bukkit.ChatColor;
|
||||||
|
import org.bukkit.Location;
|
||||||
|
import org.bukkit.entity.Player;
|
||||||
|
import org.bukkit.plugin.java.JavaPlugin;
|
||||||
|
import org.bukkit.scheduler.BukkitRunnable;
|
||||||
|
|
||||||
|
public class MissileWars extends JavaPlugin {
|
||||||
|
private static final int END_PHASE_TIME = 600; //gameticks (30s)
|
||||||
|
|
||||||
|
private static MissileWars plugin;
|
||||||
|
private static MWTeam redTeam; //red has South side -> spawns missles towards north
|
||||||
|
private static MWTeam blueTeam;
|
||||||
|
private static FightState fightState;
|
||||||
|
private static long startTime; //timestamp when the fight starts
|
||||||
|
|
||||||
|
/**
|
||||||
|
* create teams, ect
|
||||||
|
*/
|
||||||
|
@Override
|
||||||
|
public void onLoad() {
|
||||||
|
plugin = this;
|
||||||
|
fightState = FightState.WAITING;
|
||||||
|
startTime = System.currentTimeMillis();
|
||||||
|
|
||||||
|
//TODO: Config
|
||||||
|
redTeam = new MWTeam(ChatColor.RED, new Location(Bukkit.getWorlds().get(0), 0, 0, 0), "Rot", -63);
|
||||||
|
blueTeam = new MWTeam(ChatColor.BLUE, new Location(Bukkit.getWorlds().get(0), 0, 0, 0), "Blau", 63);
|
||||||
|
MissleSpawnSystem.load();
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void onEnable() {
|
||||||
|
new DeathListener();
|
||||||
|
new EggClickListener();
|
||||||
|
new ArenaListener(arenaMinX, arenaMaxX, arenaMinZ, arenaMaxZ, arenaMinY);
|
||||||
|
new ConnectionListener();
|
||||||
|
new JoinListener();
|
||||||
|
new EndListener();
|
||||||
|
new PortalDestructListener();
|
||||||
|
|
||||||
|
//TODO: Wait for players/Auto termination
|
||||||
|
BasicListener.setupListeners(fightState);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* call to change fightstate from WAITING to INGAME
|
||||||
|
*/
|
||||||
|
public static void startRound() {
|
||||||
|
if (fightState != FightState.WAITING) // anti dual-call
|
||||||
|
return;
|
||||||
|
fightState = FightState.FIGHTING;
|
||||||
|
BasicListener.setupListeners(fightState);
|
||||||
|
|
||||||
|
startTime = System.currentTimeMillis();
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Fight beenden
|
||||||
|
* @param reason Grund fürs ende
|
||||||
|
* @param winner Gewinner (oder null)
|
||||||
|
*/
|
||||||
|
public static void end(WinReasons reason, MWTeam winner) {
|
||||||
|
if (fightState == FightState.END) //verhindern dass es mehrfach gecallt wird
|
||||||
|
return;
|
||||||
|
fightState = FightState.END;
|
||||||
|
BasicListener.setupListeners(fightState);
|
||||||
|
|
||||||
|
switch (reason) {
|
||||||
|
case NO_ENEMY:
|
||||||
|
Bukkit.getServer().broadcastMessage("Ohne Gegner kein Kampf - Team " + winner.getColoredName() + ChatColor.RESET + " hat gewonnen.");
|
||||||
|
break;
|
||||||
|
case PORTAL_DESTROYED:
|
||||||
|
Bukkit.getServer().broadcastMessage(winner.getColoredName() + ChatColor.RESET + " hat das gegnerische Portal zerst<73>rt.");
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
new BukkitRunnable() {
|
||||||
|
public void run() {
|
||||||
|
Bukkit.getServer().shutdown();
|
||||||
|
}
|
||||||
|
}.runTaskLater(plugin, END_PHASE_TIME);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
public static MissileWars getPlugin() {
|
||||||
|
return plugin;
|
||||||
|
}
|
||||||
|
|
||||||
|
public static FightState getFightState() {
|
||||||
|
return fightState;
|
||||||
|
}
|
||||||
|
|
||||||
|
public static MWTeam getRedTeam(){
|
||||||
|
return redTeam;
|
||||||
|
}
|
||||||
|
|
||||||
|
public static MWTeam getBlueTeam(){
|
||||||
|
return blueTeam;
|
||||||
|
}
|
||||||
|
|
||||||
|
public static MWTeam getTeam(Player p){
|
||||||
|
if(blueTeam.getPlayers().contains(p))
|
||||||
|
return blueTeam;
|
||||||
|
if(redTeam.getPlayers().contains(p))
|
||||||
|
return redTeam;
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @return seconds since start
|
||||||
|
*/
|
||||||
|
public static int getFightTime() {
|
||||||
|
return Math.floorDiv((int) (System.currentTimeMillis() - startTime), 60);
|
||||||
|
}
|
||||||
|
}
|
@ -1,32 +1,33 @@
|
|||||||
package de.steamwar.misslewars;
|
package de.steamwar.misslewars;
|
||||||
|
|
||||||
import java.io.File;
|
import org.bukkit.Bukkit;
|
||||||
import java.util.List;
|
|
||||||
|
|
||||||
import org.bukkit.Location;
|
import org.bukkit.Location;
|
||||||
import org.bukkit.Material;
|
import org.bukkit.Material;
|
||||||
import org.bukkit.block.Block;
|
import org.bukkit.block.Block;
|
||||||
import org.bukkit.block.BlockFace;
|
import org.bukkit.block.BlockFace;
|
||||||
|
import org.bukkit.block.data.type.Observer;
|
||||||
import org.bukkit.block.data.type.Piston;
|
import org.bukkit.block.data.type.Piston;
|
||||||
import org.bukkit.configuration.file.FileConfiguration;
|
import org.bukkit.configuration.file.FileConfiguration;
|
||||||
import org.bukkit.configuration.file.YamlConfiguration;
|
import org.bukkit.configuration.file.YamlConfiguration;
|
||||||
import org.bukkit.block.data.type.Observer;
|
|
||||||
|
import java.io.File;
|
||||||
|
import java.util.ArrayList;
|
||||||
|
|
||||||
public class MissleSpawnSystem {
|
public class MissleSpawnSystem {
|
||||||
|
|
||||||
public static Missle[] missles;
|
public static Missile[] missiles;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* load Config, ect
|
* load Config, ect
|
||||||
*/
|
*/
|
||||||
@SuppressWarnings("unchecked")
|
@SuppressWarnings("unchecked")
|
||||||
public static void load() {
|
public static void load() {
|
||||||
FileConfiguration c = YamlConfiguration.loadConfiguration(new File(MissleWars.path + "/missles.yml"));
|
FileConfiguration c = YamlConfiguration.loadConfiguration(new File(MissileWars.getPlugin().getDataFolder(), "missles.yml"));
|
||||||
missles = ((List<Missle>) c.get("missles")).toArray(new Missle[0]);
|
missiles = (c.getList("missles", new ArrayList<Missile>())).toArray();
|
||||||
}
|
}
|
||||||
|
|
||||||
public static void paste(String missle, boolean red, Location l) {
|
public static void paste(String missle, boolean red, Location l) {
|
||||||
for (Missle m : missles) {
|
for (Missile m : missiles) {
|
||||||
if (m.name == missle)
|
if (m.name == missle)
|
||||||
m.paste(l, red, red);
|
m.paste(l, red, red);
|
||||||
}
|
}
|
||||||
@ -36,7 +37,7 @@ public class MissleSpawnSystem {
|
|||||||
* Missle-Schematic
|
* Missle-Schematic
|
||||||
*/
|
*/
|
||||||
@SuppressWarnings("unused")
|
@SuppressWarnings("unused")
|
||||||
private class Missle{
|
private class Missile {
|
||||||
public String name;
|
public String name;
|
||||||
private byte height;
|
private byte height;
|
||||||
private byte depth;
|
private byte depth;
|
||||||
@ -57,7 +58,7 @@ public class MissleSpawnSystem {
|
|||||||
for (int z=0; z < width; z++) {
|
for (int z=0; z < width; z++) {
|
||||||
int i = x+y*width+z*height*width;
|
int i = x+y*width+z*height*width;
|
||||||
if (i > blocks.length || i < 0) continue;
|
if (i > blocks.length || i < 0) continue;
|
||||||
setBlock(blocks[i], MissleWars.world.getBlockAt(l.getBlockX() + x, l.getBlockY() + y, l.getBlockZ() + z * a), north, redTeam);
|
setBlock(blocks[i], Bukkit.getWorlds().get(0).getBlockAt(l.getBlockX() + x, l.getBlockY() + y, l.getBlockZ() + z * a), north, redTeam);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -1,135 +0,0 @@
|
|||||||
package de.steamwar.misslewars;
|
|
||||||
|
|
||||||
import java.io.File;
|
|
||||||
import java.util.Timer;
|
|
||||||
|
|
||||||
import org.bukkit.Bukkit;
|
|
||||||
import org.bukkit.ChatColor;
|
|
||||||
import org.bukkit.World;
|
|
||||||
import org.bukkit.entity.Player;
|
|
||||||
import org.bukkit.plugin.java.JavaPlugin;
|
|
||||||
import org.bukkit.scheduler.BukkitRunnable;
|
|
||||||
|
|
||||||
public class MissleWars extends JavaPlugin {
|
|
||||||
public static World world;
|
|
||||||
private static MissleWars plugin;
|
|
||||||
public static MWTeam redTeam; //red has South side -> spawns missles towards north
|
|
||||||
public static MWTeam blueTeam;
|
|
||||||
public static int redPortalZ;
|
|
||||||
public static int bluePortalZ;
|
|
||||||
private static FightState fightstate;
|
|
||||||
private static long fightend; //timestamp when the fight ends
|
|
||||||
private static int rundenLaenge = 108000; //millis (108000 = 30mins)
|
|
||||||
private static int timeOut = 36000; //millis (36000 = 10min)
|
|
||||||
private static EndTimer timerClass;
|
|
||||||
private static int inspectionTime = 3600; //gameticks (3600 = 3min)
|
|
||||||
public static File path;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* create teams, ect
|
|
||||||
*/
|
|
||||||
public void onLoad() {
|
|
||||||
path = getDataFolder();
|
|
||||||
plugin = this;
|
|
||||||
redTeam = new MWTeam(ChatColor.RED, "Rot", "Rot");
|
|
||||||
redTeam = new MWTeam(ChatColor.BLUE, "Blau", "Blau");
|
|
||||||
fightstate = FightState.WAITING;
|
|
||||||
fightend = System.currentTimeMillis() + timeOut;
|
|
||||||
MissleSpawnSystem.load();
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* start waiting for players timeout-timer
|
|
||||||
*/
|
|
||||||
public void onEnable() {
|
|
||||||
world = Bukkit.getServer().getWorlds().get(0);
|
|
||||||
timerClass = new EndTimer(true);
|
|
||||||
(new Timer()).schedule(timerClass, timeOut);
|
|
||||||
fightend = System.currentTimeMillis() + timeOut;
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* call to change fightstate from WAITING to INGAME
|
|
||||||
*/
|
|
||||||
public static void startRound() {
|
|
||||||
if (fightstate != FightState.WAITING) // anti dual-call
|
|
||||||
return;
|
|
||||||
if (timerClass != null) timerClass.cancel();
|
|
||||||
timerClass = new EndTimer(false);
|
|
||||||
(new Timer()).schedule(timerClass, rundenLaenge);
|
|
||||||
fightend = System.currentTimeMillis() + rundenLaenge;
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @return how long did this round last so far
|
|
||||||
*/
|
|
||||||
public static long getRoundLength() {
|
|
||||||
return rundenLaenge - (fightend - System.currentTimeMillis());
|
|
||||||
//pflicht-ende-zeit - zeit bis zum pflicht-ende (pflicht-ende-timestamp - current-timestamp)
|
|
||||||
}
|
|
||||||
|
|
||||||
public static MissleWars getPlugin() {
|
|
||||||
return plugin;
|
|
||||||
}
|
|
||||||
|
|
||||||
public static FightState getFightState() {
|
|
||||||
return fightstate;
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @return seconds left
|
|
||||||
*/
|
|
||||||
public static int getFightTime() {
|
|
||||||
return Math.floorDiv((int) (fightend - System.currentTimeMillis()), 60);
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* get the corresponding MWPlayer Object for a Player (if Player is ingame, otherwise returns null)
|
|
||||||
*/
|
|
||||||
public static MWPlayer getPlayer(Player p) {
|
|
||||||
MWPlayer pe = redTeam.getPlayer(p);
|
|
||||||
if (pe != null) return pe;
|
|
||||||
return blueTeam.getPlayer(p);
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* checks if a Bukkit-Player Object is in a team
|
|
||||||
*/
|
|
||||||
public static boolean playerInGame(Player p) {
|
|
||||||
return redTeam.hasPlayer(p) || blueTeam.hasPlayer(p);
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Fight beenden
|
|
||||||
* @param reason Grund fürs ende
|
|
||||||
* @param winner Gewinner (oder null)
|
|
||||||
*/
|
|
||||||
public static void end(WinReasons reason, MWTeam winner) {
|
|
||||||
if (fightstate == FightState.END) //verhindern dass es mehrfach gecallt wird
|
|
||||||
return;
|
|
||||||
fightstate = FightState.END;
|
|
||||||
timerClass.cancel();
|
|
||||||
String winnerName = "Null";
|
|
||||||
if (winner == redTeam) winnerName = redTeam.getColoredName();
|
|
||||||
if (winner == blueTeam) winnerName = blueTeam.getColoredName();
|
|
||||||
switch (reason) {
|
|
||||||
case NOENEMY:
|
|
||||||
Bukkit.getServer().broadcastMessage("Ohne Gegner kein Kampf - Team " + winnerName + ChatColor.RESET + " hat gewonnen.");
|
|
||||||
break;
|
|
||||||
case PORTALDESTROYED:
|
|
||||||
Bukkit.getServer().broadcastMessage(winnerName + ChatColor.RESET + " hat das gegnerische Portal zerstört.");
|
|
||||||
break;
|
|
||||||
case TIMEOUT:
|
|
||||||
Bukkit.getServer().broadcastMessage("Kampf beendet: Unentschieden (Zeit abgelaufen).");
|
|
||||||
break;
|
|
||||||
default:
|
|
||||||
Bukkit.getServer().broadcastMessage("Kampf beendet.");
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
new BukkitRunnable() {
|
|
||||||
public void run() {
|
|
||||||
Bukkit.getServer().shutdown();
|
|
||||||
}
|
|
||||||
}.runTaskLater(plugin, inspectionTime);
|
|
||||||
}
|
|
||||||
}
|
|
@ -1,7 +1,6 @@
|
|||||||
package de.steamwar.misslewars;
|
package de.steamwar.misslewars;
|
||||||
|
|
||||||
public enum WinReasons {
|
public enum WinReasons {
|
||||||
NOENEMY,
|
NO_ENEMY,
|
||||||
PORTALDESTROYED,
|
PORTAL_DESTROYED
|
||||||
TIMEOUT
|
|
||||||
}
|
}
|
||||||
|
@ -1,5 +0,0 @@
|
|||||||
package de.steamwar.misslewars.commands;
|
|
||||||
|
|
||||||
public class JoinCommand {
|
|
||||||
|
|
||||||
}
|
|
48
src/de/steamwar/misslewars/listener/ArenaListener.java
Normale Datei
48
src/de/steamwar/misslewars/listener/ArenaListener.java
Normale Datei
@ -0,0 +1,48 @@
|
|||||||
|
package de.steamwar.misslewars.listener;
|
||||||
|
|
||||||
|
import de.steamwar.misslewars.FightState;
|
||||||
|
import org.bukkit.GameMode;
|
||||||
|
import org.bukkit.Location;
|
||||||
|
import org.bukkit.entity.Player;
|
||||||
|
import org.bukkit.event.EventHandler;
|
||||||
|
import org.bukkit.event.player.PlayerMoveEvent;
|
||||||
|
|
||||||
|
import java.util.EnumSet;
|
||||||
|
|
||||||
|
public class ArenaListener extends BasicListener {
|
||||||
|
|
||||||
|
private final int arenaMinX;
|
||||||
|
private final int arenaMaxX;
|
||||||
|
private final int arenaMinZ;
|
||||||
|
private final int arenaMaxZ;
|
||||||
|
private final int arenaMinY;
|
||||||
|
|
||||||
|
public ArenaListener(int arenaMinX, int arenaMaxX, int arenaMinZ, int arenaMaxZ, int arenaMinY) {
|
||||||
|
super(EnumSet.allOf(FightState.class));
|
||||||
|
this.arenaMinX = arenaMinX;
|
||||||
|
this.arenaMaxX = arenaMaxX;
|
||||||
|
this.arenaMinZ = arenaMinZ;
|
||||||
|
this.arenaMaxZ = arenaMaxZ;
|
||||||
|
this.arenaMinY = arenaMinY;
|
||||||
|
}
|
||||||
|
|
||||||
|
@EventHandler
|
||||||
|
public void onMove(PlayerMoveEvent e) {
|
||||||
|
Location location = e.getTo();
|
||||||
|
Player p = e.getPlayer();
|
||||||
|
|
||||||
|
assert location != null;
|
||||||
|
if(location.getY() < arenaMinY){
|
||||||
|
if(p.getGameMode() == GameMode.SPECTATOR)
|
||||||
|
p.teleport(e.getFrom());
|
||||||
|
else
|
||||||
|
p.damage(Double.MAX_VALUE);
|
||||||
|
}else if(
|
||||||
|
location.getX() < arenaMinX ||
|
||||||
|
location.getX() > arenaMaxX ||
|
||||||
|
location.getZ() < arenaMinZ ||
|
||||||
|
location.getZ() > arenaMaxZ){
|
||||||
|
p.teleport(e.getFrom());
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
35
src/de/steamwar/misslewars/listener/BasicListener.java
Normale Datei
35
src/de/steamwar/misslewars/listener/BasicListener.java
Normale Datei
@ -0,0 +1,35 @@
|
|||||||
|
package de.steamwar.misslewars.listener;
|
||||||
|
|
||||||
|
import de.steamwar.misslewars.FightState;
|
||||||
|
import de.steamwar.misslewars.MissileWars;
|
||||||
|
import org.bukkit.Bukkit;
|
||||||
|
import org.bukkit.event.HandlerList;
|
||||||
|
import org.bukkit.event.Listener;
|
||||||
|
|
||||||
|
import java.util.HashSet;
|
||||||
|
import java.util.Set;
|
||||||
|
|
||||||
|
public abstract class BasicListener implements Listener {
|
||||||
|
private static Set<BasicListener> listeners = new HashSet<>();
|
||||||
|
|
||||||
|
private final Set<FightState> active;
|
||||||
|
private boolean running;
|
||||||
|
|
||||||
|
BasicListener(final Set<FightState> active){
|
||||||
|
this.active = active;
|
||||||
|
running = false;
|
||||||
|
listeners.add(this);
|
||||||
|
}
|
||||||
|
|
||||||
|
public static void setupListeners(FightState state){
|
||||||
|
for(BasicListener listener : listeners){
|
||||||
|
if(listener.running && !listener.active.contains(state)){
|
||||||
|
HandlerList.unregisterAll(listener);
|
||||||
|
listener.running = false;
|
||||||
|
}else if(!listener.running && listener.active.contains(state)){
|
||||||
|
Bukkit.getPluginManager().registerEvents(listener, MissileWars.getPlugin());
|
||||||
|
listener.running = true;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
32
src/de/steamwar/misslewars/listener/ConnectionListener.java
Normale Datei
32
src/de/steamwar/misslewars/listener/ConnectionListener.java
Normale Datei
@ -0,0 +1,32 @@
|
|||||||
|
package de.steamwar.misslewars.listener;
|
||||||
|
|
||||||
|
import de.steamwar.misslewars.FightState;
|
||||||
|
import de.steamwar.misslewars.MissileWars;
|
||||||
|
import org.bukkit.GameMode;
|
||||||
|
import org.bukkit.entity.Player;
|
||||||
|
import org.bukkit.event.EventHandler;
|
||||||
|
import org.bukkit.event.player.PlayerJoinEvent;
|
||||||
|
import org.bukkit.event.player.PlayerQuitEvent;
|
||||||
|
|
||||||
|
import java.util.EnumSet;
|
||||||
|
|
||||||
|
public class ConnectionListener extends BasicListener{
|
||||||
|
|
||||||
|
public ConnectionListener(){
|
||||||
|
super(EnumSet.allOf(FightState.class));
|
||||||
|
}
|
||||||
|
|
||||||
|
@EventHandler
|
||||||
|
public void onJoin(PlayerJoinEvent e) {
|
||||||
|
e.getPlayer().setGameMode(GameMode.SPECTATOR);
|
||||||
|
}
|
||||||
|
|
||||||
|
@EventHandler
|
||||||
|
public void onLeave(PlayerQuitEvent e) {
|
||||||
|
e.setQuitMessage(null);
|
||||||
|
Player p = e.getPlayer();
|
||||||
|
|
||||||
|
MissileWars.getBlueTeam().leave(p);
|
||||||
|
MissileWars.getRedTeam().leave(p);
|
||||||
|
}
|
||||||
|
}
|
@ -1,25 +1,33 @@
|
|||||||
package de.steamwar.misslewars.listener;
|
package de.steamwar.misslewars.listener;
|
||||||
|
|
||||||
|
import de.steamwar.misslewars.FightState;
|
||||||
|
import de.steamwar.misslewars.MWTeam;
|
||||||
|
import de.steamwar.misslewars.MissileWars;
|
||||||
import org.bukkit.entity.Player;
|
import org.bukkit.entity.Player;
|
||||||
import org.bukkit.event.EventHandler;
|
import org.bukkit.event.EventHandler;
|
||||||
import org.bukkit.event.Listener;
|
|
||||||
|
|
||||||
import de.steamwar.misslewars.MWPlayer;
|
|
||||||
import de.steamwar.misslewars.MissleWars;
|
|
||||||
|
|
||||||
import org.bukkit.event.entity.PlayerDeathEvent;
|
import org.bukkit.event.entity.PlayerDeathEvent;
|
||||||
|
import org.bukkit.event.player.PlayerRespawnEvent;
|
||||||
|
|
||||||
|
import java.util.EnumSet;
|
||||||
|
|
||||||
|
public class DeathListener extends BasicListener {
|
||||||
|
|
||||||
|
public DeathListener() {
|
||||||
|
super(EnumSet.allOf(FightState.class));
|
||||||
|
}
|
||||||
|
|
||||||
public class DeathListener implements Listener {
|
|
||||||
@EventHandler
|
@EventHandler
|
||||||
public void onDeath(PlayerDeathEvent e) {
|
public void onDeath(PlayerDeathEvent e) {
|
||||||
Player p = e.getEntity();
|
e.setDeathMessage(null);
|
||||||
if (!MissleWars.playerInGame(p)) {
|
}
|
||||||
e.setDeathMessage("");
|
|
||||||
|
@EventHandler
|
||||||
|
public void onRespawn(PlayerRespawnEvent e){
|
||||||
|
Player p = e.getPlayer();
|
||||||
|
MWTeam team = MissileWars.getTeam(p);
|
||||||
|
if(team == null)
|
||||||
return;
|
return;
|
||||||
}
|
|
||||||
Player killer = p.getKiller();
|
e.setRespawnLocation(team.getSpawn());
|
||||||
if (killer == null) return;
|
|
||||||
MWPlayer mwKiller = MissleWars.getPlayer(killer);
|
|
||||||
if (mwKiller != null) mwKiller.addKill();
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -1,20 +1,23 @@
|
|||||||
package de.steamwar.misslewars.listener;
|
package de.steamwar.misslewars.listener;
|
||||||
|
|
||||||
|
import de.steamwar.misslewars.FightState;
|
||||||
|
import de.steamwar.misslewars.MissileWars;
|
||||||
|
import de.steamwar.misslewars.MissleSpawnSystem;
|
||||||
import org.bukkit.event.EventHandler;
|
import org.bukkit.event.EventHandler;
|
||||||
import org.bukkit.event.Listener;
|
|
||||||
import org.bukkit.event.player.PlayerInteractEvent;
|
import org.bukkit.event.player.PlayerInteractEvent;
|
||||||
|
|
||||||
import de.steamwar.misslewars.FightState;
|
import java.util.EnumSet;
|
||||||
import de.steamwar.misslewars.MissleSpawnSystem;
|
|
||||||
import de.steamwar.misslewars.MissleWars;
|
public class EggClickListener extends BasicListener {
|
||||||
|
public EggClickListener() {
|
||||||
|
super(EnumSet.of(FightState.FIGHTING));
|
||||||
|
}
|
||||||
|
|
||||||
public class EggClickListener implements Listener {
|
|
||||||
@EventHandler
|
@EventHandler
|
||||||
public void onItemClick(PlayerInteractEvent e) {
|
public void onItemClick(PlayerInteractEvent e) {
|
||||||
if (MissleWars.getFightState() != FightState.FIGHTING) return;
|
if (e.getItem() == null || !e.getItem().getType().toString().contains("SPAWN_EGG"))
|
||||||
if (!MissleWars.playerInGame(e.getPlayer())) return;
|
return;
|
||||||
if (!e.getItem().getType().toString().contains("SPAWN_EGG")) return;
|
MissleSpawnSystem.paste(e.getItem().getItemMeta().getDisplayName() , MissileWars.getRedTeam().hasPlayer(e.getPlayer()), e.getPlayer().getLocation());
|
||||||
MissleSpawnSystem.paste(e.getItem().getItemMeta().getDisplayName() , MissleWars.redTeam.hasPlayer(e.getPlayer()), e.getPlayer().getLocation());
|
|
||||||
e.getItem().setAmount(e.getItem().getAmount()-1);
|
e.getItem().setAmount(e.getItem().getAmount()-1);
|
||||||
e.setCancelled(true);
|
e.setCancelled(true);
|
||||||
}
|
}
|
||||||
|
21
src/de/steamwar/misslewars/listener/EndListener.java
Normale Datei
21
src/de/steamwar/misslewars/listener/EndListener.java
Normale Datei
@ -0,0 +1,21 @@
|
|||||||
|
package de.steamwar.misslewars.listener;
|
||||||
|
|
||||||
|
import de.steamwar.misslewars.FightState;
|
||||||
|
import org.bukkit.GameMode;
|
||||||
|
import org.bukkit.event.EventHandler;
|
||||||
|
import org.bukkit.event.player.PlayerJoinEvent;
|
||||||
|
|
||||||
|
import java.util.EnumSet;
|
||||||
|
|
||||||
|
public class EndListener extends BasicListener {
|
||||||
|
|
||||||
|
public EndListener(){
|
||||||
|
super(EnumSet.of(FightState.END));
|
||||||
|
}
|
||||||
|
|
||||||
|
@EventHandler
|
||||||
|
public void onJoin(PlayerJoinEvent e) {
|
||||||
|
e.setJoinMessage(null);
|
||||||
|
e.getPlayer().setGameMode(GameMode.SPECTATOR);
|
||||||
|
}
|
||||||
|
}
|
@ -1,15 +0,0 @@
|
|||||||
package de.steamwar.misslewars.listener;
|
|
||||||
|
|
||||||
import org.bukkit.event.EventHandler;
|
|
||||||
import org.bukkit.event.Listener;
|
|
||||||
import org.bukkit.event.player.PlayerMoveEvent;
|
|
||||||
|
|
||||||
import de.steamwar.misslewars.MissleWars;
|
|
||||||
|
|
||||||
public class FallOutOfWorldListener implements Listener {
|
|
||||||
@EventHandler
|
|
||||||
public void onMove(PlayerMoveEvent e) {
|
|
||||||
if (!MissleWars.playerInGame(e.getPlayer())) return;
|
|
||||||
if (e.getPlayer().getEyeHeight() < 0) e.getPlayer().damage(Double.MAX_VALUE);
|
|
||||||
}
|
|
||||||
}
|
|
@ -1,13 +1,23 @@
|
|||||||
package de.steamwar.misslewars.listener;
|
package de.steamwar.misslewars.listener;
|
||||||
|
|
||||||
import org.bukkit.GameMode;
|
import de.steamwar.misslewars.FightState;
|
||||||
|
import de.steamwar.misslewars.MissileWars;
|
||||||
import org.bukkit.event.EventHandler;
|
import org.bukkit.event.EventHandler;
|
||||||
import org.bukkit.event.Listener;
|
|
||||||
import org.bukkit.event.player.PlayerJoinEvent;
|
import org.bukkit.event.player.PlayerJoinEvent;
|
||||||
|
|
||||||
public class JoinListener implements Listener{
|
import java.util.EnumSet;
|
||||||
|
|
||||||
|
public class JoinListener extends BasicListener {
|
||||||
|
|
||||||
|
public JoinListener(){
|
||||||
|
super(EnumSet.of(FightState.WAITING, FightState.FIGHTING));
|
||||||
|
}
|
||||||
|
|
||||||
@EventHandler
|
@EventHandler
|
||||||
public void onJoin(PlayerJoinEvent e){
|
public void onJoin(PlayerJoinEvent e){
|
||||||
e.getPlayer().setGameMode(GameMode.SPECTATOR);
|
if(MissileWars.getRedTeam().getPlayers().size() < MissileWars.getBlueTeam().getPlayers().size())
|
||||||
|
MissileWars.getRedTeam().join(e.getPlayer());
|
||||||
|
else
|
||||||
|
MissileWars.getBlueTeam().join(e.getPlayer());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -1,22 +1,28 @@
|
|||||||
package de.steamwar.misslewars.listener;
|
package de.steamwar.misslewars.listener;
|
||||||
|
|
||||||
|
import de.steamwar.misslewars.FightState;
|
||||||
|
import de.steamwar.misslewars.MissileWars;
|
||||||
|
import de.steamwar.misslewars.WinReasons;
|
||||||
import org.bukkit.Material;
|
import org.bukkit.Material;
|
||||||
import org.bukkit.event.EventHandler;
|
import org.bukkit.event.EventHandler;
|
||||||
import org.bukkit.event.Listener;
|
|
||||||
import org.bukkit.event.block.BlockPhysicsEvent;
|
import org.bukkit.event.block.BlockPhysicsEvent;
|
||||||
|
|
||||||
import de.steamwar.misslewars.MissleWars;
|
import java.util.EnumSet;
|
||||||
import de.steamwar.misslewars.WinReasons;
|
|
||||||
|
public class PortalDestructListener extends BasicListener {
|
||||||
|
|
||||||
|
public PortalDestructListener(){
|
||||||
|
super(EnumSet.of(FightState.FIGHTING));
|
||||||
|
}
|
||||||
|
|
||||||
public class PortalDestructListener implements Listener {
|
|
||||||
@EventHandler
|
@EventHandler
|
||||||
public void onBlockupdate(BlockPhysicsEvent e) {
|
public void onBlockupdate(BlockPhysicsEvent e) {
|
||||||
if (e.getBlock().getType() != Material.NETHER_PORTAL)
|
if (e.getBlock().getType() != Material.NETHER_PORTAL)
|
||||||
return;
|
return;
|
||||||
int z = e.getBlock().getZ();
|
int z = e.getBlock().getZ();
|
||||||
if (z == MissleWars.redPortalZ)
|
if (z == MissileWars.getRedTeam().getPortalZ())
|
||||||
MissleWars.end(WinReasons.PORTALDESTROYED, MissleWars.blueTeam);
|
MissileWars.end(WinReasons.PORTAL_DESTROYED, MissileWars.getBlueTeam());
|
||||||
if (z == MissleWars.bluePortalZ)
|
if (z == MissileWars.getBlueTeam().getPortalZ())
|
||||||
MissleWars.end(WinReasons.PORTALDESTROYED, MissleWars.blueTeam);
|
MissileWars.end(WinReasons.PORTAL_DESTROYED, MissileWars.getRedTeam());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -1,8 +1,8 @@
|
|||||||
name: MissleWars
|
name: MissleWars
|
||||||
prefix: MW
|
prefix: MW
|
||||||
main: de.steamwar.misslewars
|
main: de.steamwar.misslewars.MissileWars
|
||||||
authors: [Jan9103]
|
authors:
|
||||||
version: 1.0
|
- Jan9103
|
||||||
commands:
|
- Lixfel
|
||||||
join:
|
version: "1.0"
|
||||||
leave:
|
api-version: "1.13"
|
In neuem Issue referenzieren
Einen Benutzer sperren