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
|
||||
SpawnEgg name == MissleName (Config)
|
||||
incl Color-Tags, ect
|
||||
Missle-Configs sind für Team Rot
|
||||
Rot ist im süden
|
||||
SpawnEgg name == MissleName (Config)
|
||||
incl Color-Tags, ect
|
||||
Missle-Configs sind für Team Rot
|
33
src/ToDo.txt
33
src/ToDo.txt
@ -1,19 +1,14 @@
|
||||
Commands:
|
||||
join
|
||||
leave
|
||||
forcestop
|
||||
Config:
|
||||
Timeout-Time
|
||||
Runden max length
|
||||
shield / platform / ect item on/off
|
||||
give-speed (default: 11)
|
||||
Features
|
||||
Items:
|
||||
shield
|
||||
platform
|
||||
fireball
|
||||
pfeile
|
||||
bridge
|
||||
Item-giver
|
||||
am anfang bogen geben
|
||||
listener + commadns registrieren
|
||||
Config:
|
||||
Timeout-Time
|
||||
Runden max length
|
||||
shield / platform / ect item on/off
|
||||
give-speed (default: 11)
|
||||
Features
|
||||
Items:
|
||||
shield
|
||||
platform
|
||||
fireball
|
||||
pfeile
|
||||
bridge
|
||||
Item-giver
|
||||
am anfang bogen geben
|
@ -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;
|
||||
|
||||
import de.steamwar.misslewars.MWTeam;
|
||||
|
||||
import org.bukkit.Bukkit;
|
||||
import org.bukkit.scoreboard.DisplaySlot;
|
||||
import org.bukkit.scoreboard.Objective;
|
||||
@ -29,7 +27,7 @@ public class FightScoreboard {
|
||||
}
|
||||
|
||||
public static void init(){
|
||||
Bukkit.getScheduler().scheduleSyncRepeatingTask(MissleWars.getPlugin(), () -> {
|
||||
Bukkit.getScheduler().scheduleSyncRepeatingTask(MissileWars.getPlugin(), () -> {
|
||||
objective.unregister();
|
||||
//noinspection deprecation
|
||||
scoreboard.registerNewObjective("AAA", "BBB", "MissleWars");
|
||||
@ -51,14 +49,14 @@ public class FightScoreboard {
|
||||
|
||||
private static void teamScoreboard(MWTeam fightTeam){
|
||||
objective.setDisplayName(fightTeam.getColoredName());
|
||||
fightTeam.getPlayers().forEach(fp -> {
|
||||
objective.getScore(fightTeam.getPrefix() + fp.getPlayer().getName()).setScore((int) fp.getKills());
|
||||
fightTeam.getPlayers().forEach(p -> {
|
||||
objective.getScore(fightTeam.getPrefix() + p.getName()).setScore(1);
|
||||
});
|
||||
}
|
||||
|
||||
private static void generalScoreboard(){
|
||||
objective.setDisplayName("§6Kampf");
|
||||
int fightTime = MissleWars.getFightTime();
|
||||
int fightTime = MissileWars.getFightTime();
|
||||
if (fightTime >= 60)
|
||||
objective.getScore("§7Zeit: §a" + fightTime / 60 + "m " + fightTime % 60 + "s").setScore(3);
|
||||
else
|
||||
@ -68,9 +66,9 @@ public class FightScoreboard {
|
||||
private static MWTeam getIndexDisplay() {
|
||||
index++;
|
||||
if(index == 1)
|
||||
return MissleWars.redTeam;
|
||||
return MissileWars.getRedTeam();
|
||||
if(index == 2)
|
||||
return MissleWars.blueTeam;
|
||||
return MissileWars.getBlueTeam();
|
||||
index = 0;
|
||||
return null;
|
||||
}
|
||||
|
@ -1,7 +1,7 @@
|
||||
package de.steamwar.misslewars;
|
||||
|
||||
public enum FightState {
|
||||
WAITING, //waiting for at least 2Players
|
||||
FIGHTING, //no one has Won
|
||||
END // fight ended for some reason
|
||||
}
|
||||
package de.steamwar.misslewars;
|
||||
|
||||
public enum FightState {
|
||||
WAITING, // waiting for at least 2 players
|
||||
FIGHTING, // no one has won
|
||||
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,89 +1,94 @@
|
||||
package de.steamwar.misslewars;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
import org.bukkit.ChatColor;
|
||||
import org.bukkit.Location;
|
||||
import org.bukkit.entity.Player;
|
||||
import org.bukkit.scoreboard.Team;
|
||||
import org.bukkit.scoreboard.Team.Option;
|
||||
import org.bukkit.scoreboard.Team.OptionStatus;
|
||||
|
||||
public class MWTeam {
|
||||
private ChatColor color;
|
||||
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(){
|
||||
return spieler;
|
||||
}
|
||||
|
||||
public MWTeam(ChatColor color, String teamName, String prefix) {
|
||||
this.teamName = teamName;
|
||||
this.prefix = prefix;
|
||||
this.color = color;
|
||||
if(FightScoreboard.getScoreboard().getTeam(teamName) == null)
|
||||
sbteam = FightScoreboard.getScoreboard().registerNewTeam(teamName);
|
||||
else
|
||||
sbteam = FightScoreboard.getScoreboard().getTeam(teamName);
|
||||
assert sbteam != null;
|
||||
sbteam.setOption(Option.NAME_TAG_VISIBILITY, OptionStatus.FOR_OWN_TEAM);
|
||||
sbteam.setAllowFriendlyFire(false);
|
||||
}
|
||||
|
||||
public void tpToSpawn(Player p) {
|
||||
p.teleport(spawn);
|
||||
}
|
||||
|
||||
public void join (Player p) {
|
||||
spieler.add(new MWPlayer(p));
|
||||
p.setDisplayName(color + "[" + teamName + "]" + p.getName());
|
||||
if (MissleWars.getFightState() == FightState.WAITING) {
|
||||
if (!enemy().getPlayers().isEmpty())
|
||||
MissleWars.startRound();
|
||||
}
|
||||
}
|
||||
|
||||
public void leave (Player p) {
|
||||
for (MWPlayer pl : spieler) {
|
||||
if (p == pl.getPlayer()) {
|
||||
spieler.remove(pl);
|
||||
break;
|
||||
}
|
||||
p.setDisplayName(p.getName());
|
||||
}
|
||||
if (spieler.isEmpty())
|
||||
MissleWars.end(WinReasons.NOENEMY, enemy());
|
||||
}
|
||||
|
||||
public MWTeam enemy() {
|
||||
if (this == MissleWars.redTeam) return MissleWars.blueTeam;
|
||||
return MissleWars.redTeam;
|
||||
}
|
||||
|
||||
public String getPrefix(){
|
||||
return prefix;
|
||||
}
|
||||
|
||||
public boolean hasPlayer (Player p) {
|
||||
for (MWPlayer pl : spieler)
|
||||
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() {
|
||||
return color.toString() + teamName;
|
||||
}
|
||||
}
|
||||
package de.steamwar.misslewars;
|
||||
|
||||
import org.bukkit.ChatColor;
|
||||
import org.bukkit.Location;
|
||||
import org.bukkit.Material;
|
||||
import org.bukkit.enchantments.Enchantment;
|
||||
import org.bukkit.entity.Player;
|
||||
import org.bukkit.inventory.ItemStack;
|
||||
import org.bukkit.scoreboard.Team;
|
||||
|
||||
import java.util.HashSet;
|
||||
import java.util.Objects;
|
||||
import java.util.Set;
|
||||
|
||||
public class MWTeam {
|
||||
private static final ItemStack bow = new ItemStack(Material.BOW);
|
||||
|
||||
static {
|
||||
Objects.requireNonNull(bow.getItemMeta()).addEnchant(Enchantment.ARROW_FIRE, 1, false);
|
||||
}
|
||||
|
||||
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.color = color;
|
||||
this.spawn = spawn;
|
||||
this.portalZ = portalZ;
|
||||
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);
|
||||
}
|
||||
|
||||
public int getPortalZ() {
|
||||
return portalZ;
|
||||
}
|
||||
|
||||
public Location getSpawn(){
|
||||
return spawn;
|
||||
}
|
||||
|
||||
public void join (Player p) {
|
||||
players.add(p);
|
||||
p.teleport(spawn);
|
||||
p.setItemOnCursor(bow);
|
||||
sbteam.addPlayer(p);
|
||||
p.setDisplayName(color + teamName + " " + p.getName());
|
||||
if (MissileWars.getFightState() == FightState.WAITING && !enemy().getPlayers().isEmpty())
|
||||
MissileWars.startRound();
|
||||
}
|
||||
|
||||
public void leave (Player p) {
|
||||
if(!players.contains(p))
|
||||
return;
|
||||
|
||||
players.remove(p);
|
||||
sbteam.removePlayer(p);
|
||||
if (players.isEmpty())
|
||||
MissileWars.end(WinReasons.NO_ENEMY, enemy());
|
||||
}
|
||||
|
||||
public MWTeam enemy() {
|
||||
if (this == MissileWars.getRedTeam())
|
||||
return MissileWars.getBlueTeam();
|
||||
|
||||
return MissileWars.getRedTeam();
|
||||
}
|
||||
|
||||
public String getPrefix(){
|
||||
return "§" + color.getChar();
|
||||
}
|
||||
|
||||
public boolean hasPlayer (Player p) {
|
||||
return players.contains(p);
|
||||
}
|
||||
|
||||
public String getColoredName() {
|
||||
return color.toString() + teamName;
|
||||
}
|
||||
}
|
||||
|
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,142 +1,143 @@
|
||||
package de.steamwar.misslewars;
|
||||
|
||||
import java.io.File;
|
||||
import java.util.List;
|
||||
|
||||
import org.bukkit.Location;
|
||||
import org.bukkit.Material;
|
||||
import org.bukkit.block.Block;
|
||||
import org.bukkit.block.BlockFace;
|
||||
import org.bukkit.block.data.type.Piston;
|
||||
import org.bukkit.configuration.file.FileConfiguration;
|
||||
import org.bukkit.configuration.file.YamlConfiguration;
|
||||
import org.bukkit.block.data.type.Observer;
|
||||
|
||||
public class MissleSpawnSystem {
|
||||
|
||||
public static Missle[] missles;
|
||||
|
||||
/**
|
||||
* load Config, ect
|
||||
*/
|
||||
@SuppressWarnings("unchecked")
|
||||
public static void load() {
|
||||
FileConfiguration c = YamlConfiguration.loadConfiguration(new File(MissleWars.path + "/missles.yml"));
|
||||
missles = ((List<Missle>) c.get("missles")).toArray(new Missle[0]);
|
||||
}
|
||||
|
||||
public static void paste(String missle, boolean red, Location l) {
|
||||
for (Missle m : missles) {
|
||||
if (m.name == missle)
|
||||
m.paste(l, red, red);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Missle-Schematic
|
||||
*/
|
||||
@SuppressWarnings("unused")
|
||||
private class Missle{
|
||||
public String name;
|
||||
private byte height;
|
||||
private byte depth;
|
||||
private byte width;
|
||||
private MissleBlockTypes[] blocks;
|
||||
|
||||
/**
|
||||
*
|
||||
* @param l Location of the spawning player
|
||||
* @param redTeam for Block-color blue / red
|
||||
* @param north facing north or south?
|
||||
*/
|
||||
public void paste(Location l, boolean redTeam, boolean north) {
|
||||
byte a = 1;
|
||||
if (!north) a = -1;
|
||||
for (int x=0; x < width; x++) {
|
||||
for (int y=height; y > 0; y--) {
|
||||
for (int z=0; z < width; z++) {
|
||||
int i = x+y*width+z*height*width;
|
||||
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);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
//bewusst mit blockupdate, damit observer, ect beim pasten triggern
|
||||
private void setBlock(MissleBlockTypes t, Block b, boolean n, boolean red) {
|
||||
if (t == MissleBlockTypes.GLASS) {
|
||||
if (red)
|
||||
b.setType(Material.RED_STAINED_GLASS);
|
||||
else
|
||||
b.setType(Material.BLUE_STAINED_GLASS);
|
||||
}else if (t == MissleBlockTypes.BLOCK) {
|
||||
if (red)
|
||||
b.setType(Material.RED_CONCRETE);
|
||||
else
|
||||
b.setType(Material.BLUE_CONCRETE);
|
||||
}else if (t == MissleBlockTypes.HONEY_BLOCK) {
|
||||
b.setType(Material.HONEY_BLOCK);
|
||||
}else if (t == MissleBlockTypes.PANE) {
|
||||
if (red)
|
||||
b.setType(Material.RED_STAINED_GLASS_PANE);
|
||||
else
|
||||
b.setType(Material.BLUE_STAINED_GLASS_PANE);
|
||||
}else if (t == MissleBlockTypes.TNT) {
|
||||
b.setType(Material.TNT);
|
||||
}else if (t == MissleBlockTypes.SLIME_BLOCK) {
|
||||
b.setType(Material.SLIME_BLOCK);
|
||||
}else if (t.toString().contains("STICKY_PISTON")) {
|
||||
b.setType(Material.STICKY_PISTON);
|
||||
((Piston) b).setFacing(getFacing(t, n));
|
||||
}else if (t.toString().contains("PISTON")) {
|
||||
b.setType(Material.PISTON);
|
||||
((Piston) b).setFacing(getFacing(t, n));
|
||||
}else if (t.toString().contains("OBSERVER")) {
|
||||
b.setType(Material.OBSERVER);
|
||||
((Observer) b).setFacing(getFacing(t, n));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public BlockFace getFacing(MissleBlockTypes t, boolean north) {
|
||||
String s = t.toString();
|
||||
if (s.contains("UP")) return BlockFace.UP;
|
||||
if (s.contains("DOWN")) return BlockFace.DOWN;
|
||||
if ((s.contains("NORTH") && north) || (s.contains("SOUTH") && !north)) return BlockFace.NORTH;
|
||||
if ((s.contains("NORTH") && !north) || (s.contains("SOUTH") && north)) return BlockFace.SOUTH;
|
||||
if ((s.contains("WEST") && north) || (s.contains("EAST") && !north)) return BlockFace.WEST;
|
||||
return BlockFace.EAST;
|
||||
}
|
||||
|
||||
/**
|
||||
* For Config & lowRAM save of missles
|
||||
*/
|
||||
private enum MissleBlockTypes {
|
||||
PISTON_UP,
|
||||
PISTON_DOWN,
|
||||
PISTON_NORTH,
|
||||
PISTON_SOUTH,
|
||||
PISTON_EAST,
|
||||
PISTON_WEST,
|
||||
STICKY_PISTON_UP,
|
||||
STICKY_PISTON_DOWN,
|
||||
STICKY_PISTON_NORTH,
|
||||
STICKY_PISTON_SOUTH,
|
||||
STICKY_PISTON_WEST,
|
||||
STICKY_PISTON_EAST,
|
||||
GLASS, //teamcolored
|
||||
BLOCK, //normal block, teamcolored
|
||||
PANE, //teamcolored (glass-pane)
|
||||
REDSTONE_BLOCK,
|
||||
OBSERVER_UP,
|
||||
OBSERVER_DOWN,
|
||||
OBSERVER_NORTH,
|
||||
OBSERVER_SOUTH,
|
||||
OBSERVER_EAST,
|
||||
OBSERVER_WEST,
|
||||
SLIME_BLOCK,
|
||||
HONEY_BLOCK,
|
||||
TNT
|
||||
}
|
||||
}
|
||||
package de.steamwar.misslewars;
|
||||
|
||||
import org.bukkit.Bukkit;
|
||||
import org.bukkit.Location;
|
||||
import org.bukkit.Material;
|
||||
import org.bukkit.block.Block;
|
||||
import org.bukkit.block.BlockFace;
|
||||
import org.bukkit.block.data.type.Observer;
|
||||
import org.bukkit.block.data.type.Piston;
|
||||
import org.bukkit.configuration.file.FileConfiguration;
|
||||
import org.bukkit.configuration.file.YamlConfiguration;
|
||||
|
||||
import java.io.File;
|
||||
import java.util.ArrayList;
|
||||
|
||||
public class MissleSpawnSystem {
|
||||
|
||||
public static Missile[] missiles;
|
||||
|
||||
/**
|
||||
* load Config, ect
|
||||
*/
|
||||
@SuppressWarnings("unchecked")
|
||||
public static void load() {
|
||||
FileConfiguration c = YamlConfiguration.loadConfiguration(new File(MissileWars.getPlugin().getDataFolder(), "missles.yml"));
|
||||
missiles = (c.getList("missles", new ArrayList<Missile>())).toArray();
|
||||
}
|
||||
|
||||
public static void paste(String missle, boolean red, Location l) {
|
||||
for (Missile m : missiles) {
|
||||
if (m.name == missle)
|
||||
m.paste(l, red, red);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Missle-Schematic
|
||||
*/
|
||||
@SuppressWarnings("unused")
|
||||
private class Missile {
|
||||
public String name;
|
||||
private byte height;
|
||||
private byte depth;
|
||||
private byte width;
|
||||
private MissleBlockTypes[] blocks;
|
||||
|
||||
/**
|
||||
*
|
||||
* @param l Location of the spawning player
|
||||
* @param redTeam for Block-color blue / red
|
||||
* @param north facing north or south?
|
||||
*/
|
||||
public void paste(Location l, boolean redTeam, boolean north) {
|
||||
byte a = 1;
|
||||
if (!north) a = -1;
|
||||
for (int x=0; x < width; x++) {
|
||||
for (int y=height; y > 0; y--) {
|
||||
for (int z=0; z < width; z++) {
|
||||
int i = x+y*width+z*height*width;
|
||||
if (i > blocks.length || i < 0) continue;
|
||||
setBlock(blocks[i], Bukkit.getWorlds().get(0).getBlockAt(l.getBlockX() + x, l.getBlockY() + y, l.getBlockZ() + z * a), north, redTeam);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
//bewusst mit blockupdate, damit observer, ect beim pasten triggern
|
||||
private void setBlock(MissleBlockTypes t, Block b, boolean n, boolean red) {
|
||||
if (t == MissleBlockTypes.GLASS) {
|
||||
if (red)
|
||||
b.setType(Material.RED_STAINED_GLASS);
|
||||
else
|
||||
b.setType(Material.BLUE_STAINED_GLASS);
|
||||
}else if (t == MissleBlockTypes.BLOCK) {
|
||||
if (red)
|
||||
b.setType(Material.RED_CONCRETE);
|
||||
else
|
||||
b.setType(Material.BLUE_CONCRETE);
|
||||
}else if (t == MissleBlockTypes.HONEY_BLOCK) {
|
||||
b.setType(Material.HONEY_BLOCK);
|
||||
}else if (t == MissleBlockTypes.PANE) {
|
||||
if (red)
|
||||
b.setType(Material.RED_STAINED_GLASS_PANE);
|
||||
else
|
||||
b.setType(Material.BLUE_STAINED_GLASS_PANE);
|
||||
}else if (t == MissleBlockTypes.TNT) {
|
||||
b.setType(Material.TNT);
|
||||
}else if (t == MissleBlockTypes.SLIME_BLOCK) {
|
||||
b.setType(Material.SLIME_BLOCK);
|
||||
}else if (t.toString().contains("STICKY_PISTON")) {
|
||||
b.setType(Material.STICKY_PISTON);
|
||||
((Piston) b).setFacing(getFacing(t, n));
|
||||
}else if (t.toString().contains("PISTON")) {
|
||||
b.setType(Material.PISTON);
|
||||
((Piston) b).setFacing(getFacing(t, n));
|
||||
}else if (t.toString().contains("OBSERVER")) {
|
||||
b.setType(Material.OBSERVER);
|
||||
((Observer) b).setFacing(getFacing(t, n));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public BlockFace getFacing(MissleBlockTypes t, boolean north) {
|
||||
String s = t.toString();
|
||||
if (s.contains("UP")) return BlockFace.UP;
|
||||
if (s.contains("DOWN")) return BlockFace.DOWN;
|
||||
if ((s.contains("NORTH") && north) || (s.contains("SOUTH") && !north)) return BlockFace.NORTH;
|
||||
if ((s.contains("NORTH") && !north) || (s.contains("SOUTH") && north)) return BlockFace.SOUTH;
|
||||
if ((s.contains("WEST") && north) || (s.contains("EAST") && !north)) return BlockFace.WEST;
|
||||
return BlockFace.EAST;
|
||||
}
|
||||
|
||||
/**
|
||||
* For Config & lowRAM save of missles
|
||||
*/
|
||||
private enum MissleBlockTypes {
|
||||
PISTON_UP,
|
||||
PISTON_DOWN,
|
||||
PISTON_NORTH,
|
||||
PISTON_SOUTH,
|
||||
PISTON_EAST,
|
||||
PISTON_WEST,
|
||||
STICKY_PISTON_UP,
|
||||
STICKY_PISTON_DOWN,
|
||||
STICKY_PISTON_NORTH,
|
||||
STICKY_PISTON_SOUTH,
|
||||
STICKY_PISTON_WEST,
|
||||
STICKY_PISTON_EAST,
|
||||
GLASS, //teamcolored
|
||||
BLOCK, //normal block, teamcolored
|
||||
PANE, //teamcolored (glass-pane)
|
||||
REDSTONE_BLOCK,
|
||||
OBSERVER_UP,
|
||||
OBSERVER_DOWN,
|
||||
OBSERVER_NORTH,
|
||||
OBSERVER_SOUTH,
|
||||
OBSERVER_EAST,
|
||||
OBSERVER_WEST,
|
||||
SLIME_BLOCK,
|
||||
HONEY_BLOCK,
|
||||
TNT
|
||||
}
|
||||
}
|
||||
|
@ -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;
|
||||
|
||||
public enum WinReasons {
|
||||
NOENEMY,
|
||||
PORTALDESTROYED,
|
||||
TIMEOUT
|
||||
}
|
||||
package de.steamwar.misslewars;
|
||||
|
||||
public enum WinReasons {
|
||||
NO_ENEMY,
|
||||
PORTAL_DESTROYED
|
||||
}
|
||||
|
@ -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;
|
||||
|
||||
import org.bukkit.entity.Player;
|
||||
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;
|
||||
|
||||
public class DeathListener implements Listener {
|
||||
@EventHandler
|
||||
public void onDeath(PlayerDeathEvent e) {
|
||||
Player p = e.getEntity();
|
||||
if (!MissleWars.playerInGame(p)) {
|
||||
e.setDeathMessage("");
|
||||
return;
|
||||
}
|
||||
Player killer = p.getKiller();
|
||||
if (killer == null) return;
|
||||
MWPlayer mwKiller = MissleWars.getPlayer(killer);
|
||||
if (mwKiller != null) mwKiller.addKill();
|
||||
}
|
||||
}
|
||||
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.event.EventHandler;
|
||||
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));
|
||||
}
|
||||
|
||||
@EventHandler
|
||||
public void onDeath(PlayerDeathEvent e) {
|
||||
e.setDeathMessage(null);
|
||||
}
|
||||
|
||||
@EventHandler
|
||||
public void onRespawn(PlayerRespawnEvent e){
|
||||
Player p = e.getPlayer();
|
||||
MWTeam team = MissileWars.getTeam(p);
|
||||
if(team == null)
|
||||
return;
|
||||
|
||||
e.setRespawnLocation(team.getSpawn());
|
||||
}
|
||||
}
|
||||
|
@ -1,21 +1,24 @@
|
||||
package de.steamwar.misslewars.listener;
|
||||
|
||||
import org.bukkit.event.EventHandler;
|
||||
import org.bukkit.event.Listener;
|
||||
import org.bukkit.event.player.PlayerInteractEvent;
|
||||
|
||||
import de.steamwar.misslewars.FightState;
|
||||
import de.steamwar.misslewars.MissleSpawnSystem;
|
||||
import de.steamwar.misslewars.MissleWars;
|
||||
|
||||
public class EggClickListener implements Listener {
|
||||
@EventHandler
|
||||
public void onItemClick(PlayerInteractEvent e) {
|
||||
if (MissleWars.getFightState() != FightState.FIGHTING) return;
|
||||
if (!MissleWars.playerInGame(e.getPlayer())) return;
|
||||
if (!e.getItem().getType().toString().contains("SPAWN_EGG")) return;
|
||||
MissleSpawnSystem.paste(e.getItem().getItemMeta().getDisplayName() , MissleWars.redTeam.hasPlayer(e.getPlayer()), e.getPlayer().getLocation());
|
||||
e.getItem().setAmount(e.getItem().getAmount()-1);
|
||||
e.setCancelled(true);
|
||||
}
|
||||
}
|
||||
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.player.PlayerInteractEvent;
|
||||
|
||||
import java.util.EnumSet;
|
||||
|
||||
public class EggClickListener extends BasicListener {
|
||||
public EggClickListener() {
|
||||
super(EnumSet.of(FightState.FIGHTING));
|
||||
}
|
||||
|
||||
@EventHandler
|
||||
public void onItemClick(PlayerInteractEvent e) {
|
||||
if (e.getItem() == null || !e.getItem().getType().toString().contains("SPAWN_EGG"))
|
||||
return;
|
||||
MissleSpawnSystem.paste(e.getItem().getItemMeta().getDisplayName() , MissileWars.getRedTeam().hasPlayer(e.getPlayer()), e.getPlayer().getLocation());
|
||||
e.getItem().setAmount(e.getItem().getAmount()-1);
|
||||
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;
|
||||
|
||||
import org.bukkit.GameMode;
|
||||
import org.bukkit.event.EventHandler;
|
||||
import org.bukkit.event.Listener;
|
||||
import org.bukkit.event.player.PlayerJoinEvent;
|
||||
|
||||
public class JoinListener implements Listener{
|
||||
@EventHandler
|
||||
public void onJoin(PlayerJoinEvent e) {
|
||||
e.getPlayer().setGameMode(GameMode.SPECTATOR);
|
||||
}
|
||||
}
|
||||
package de.steamwar.misslewars.listener;
|
||||
|
||||
import de.steamwar.misslewars.FightState;
|
||||
import de.steamwar.misslewars.MissileWars;
|
||||
import org.bukkit.event.EventHandler;
|
||||
import org.bukkit.event.player.PlayerJoinEvent;
|
||||
|
||||
import java.util.EnumSet;
|
||||
|
||||
public class JoinListener extends BasicListener {
|
||||
|
||||
public JoinListener(){
|
||||
super(EnumSet.of(FightState.WAITING, FightState.FIGHTING));
|
||||
}
|
||||
|
||||
@EventHandler
|
||||
public void onJoin(PlayerJoinEvent e){
|
||||
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;
|
||||
|
||||
import org.bukkit.Material;
|
||||
import org.bukkit.event.EventHandler;
|
||||
import org.bukkit.event.Listener;
|
||||
import org.bukkit.event.block.BlockPhysicsEvent;
|
||||
|
||||
import de.steamwar.misslewars.MissleWars;
|
||||
import de.steamwar.misslewars.WinReasons;
|
||||
|
||||
public class PortalDestructListener implements Listener {
|
||||
@EventHandler
|
||||
public void onBlockupdate(BlockPhysicsEvent e) {
|
||||
if (e.getBlock().getType() != Material.NETHER_PORTAL)
|
||||
return;
|
||||
int z = e.getBlock().getZ();
|
||||
if (z == MissleWars.redPortalZ)
|
||||
MissleWars.end(WinReasons.PORTALDESTROYED, MissleWars.blueTeam);
|
||||
if (z == MissleWars.bluePortalZ)
|
||||
MissleWars.end(WinReasons.PORTALDESTROYED, MissleWars.blueTeam);
|
||||
}
|
||||
}
|
||||
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.event.EventHandler;
|
||||
import org.bukkit.event.block.BlockPhysicsEvent;
|
||||
|
||||
import java.util.EnumSet;
|
||||
|
||||
public class PortalDestructListener extends BasicListener {
|
||||
|
||||
public PortalDestructListener(){
|
||||
super(EnumSet.of(FightState.FIGHTING));
|
||||
}
|
||||
|
||||
@EventHandler
|
||||
public void onBlockupdate(BlockPhysicsEvent e) {
|
||||
if (e.getBlock().getType() != Material.NETHER_PORTAL)
|
||||
return;
|
||||
int z = e.getBlock().getZ();
|
||||
if (z == MissileWars.getRedTeam().getPortalZ())
|
||||
MissileWars.end(WinReasons.PORTAL_DESTROYED, MissileWars.getBlueTeam());
|
||||
if (z == MissileWars.getBlueTeam().getPortalZ())
|
||||
MissileWars.end(WinReasons.PORTAL_DESTROYED, MissileWars.getRedTeam());
|
||||
}
|
||||
}
|
||||
|
@ -1,8 +1,8 @@
|
||||
name: MissleWars
|
||||
prefix: MW
|
||||
main: de.steamwar.misslewars
|
||||
authors: [Jan9103]
|
||||
version: 1.0
|
||||
commands:
|
||||
join:
|
||||
leave:
|
||||
name: MissleWars
|
||||
prefix: MW
|
||||
main: de.steamwar.misslewars.MissileWars
|
||||
authors:
|
||||
- Jan9103
|
||||
- Lixfel
|
||||
version: "1.0"
|
||||
api-version: "1.13"
|
In neuem Issue referenzieren
Einen Benutzer sperren