SteamWar/MissileWars
Archiviert
13
0

First fightable version

Dieser Commit ist enthalten in:
Lixfel 2020-06-24 18:24:00 +02:00
Ursprung 3e75eeacfb
Commit e99470fec5
17 geänderte Dateien mit 93 neuen und 54 gelöschten Zeilen

Datei anzeigen

@ -1,7 +1,7 @@
WaitingTime: 600
ItemTime: 300
ShieldFlyTime: 100
EndTime: 100
EndTime: 600
Arena:
MinX: 0

Datei anzeigen

@ -51,11 +51,11 @@ public class Config {
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"));
RedSpawn = new Location(Bukkit.getWorlds().get(0), red.getDouble("SpawnX"), red.getDouble("SpawnY"), red.getDouble("SpawnZ"), (float)red.getDouble("SpawnYaw"), (float)red.getDouble("SpawnPitch"));
ConfigurationSection blue = config.getConfigurationSection("Blue");
assert blue != null;
BluePortalZ = blue.getInt("PortalZ");
BlueSpawn = new Location(Bukkit.getWorlds().get(0), blue.getDouble("SpawnX"), blue.getDouble("SpawnY"), blue.getDouble("SpawnZ"));
BlueSpawn = new Location(Bukkit.getWorlds().get(0), blue.getDouble("SpawnX"), blue.getDouble("SpawnY"), blue.getDouble("SpawnZ"), (float)blue.getDouble("SpawnYaw"), (float)blue.getDouble("SpawnPitch"));
}
}

Datei anzeigen

@ -32,16 +32,14 @@ public class FightScoreboard {
objective.setDisplaySlot(DisplaySlot.SIDEBAR);
MWTeam fightTeam = getIndexDisplay();
if(fightTeam != null)
teamScoreboard(fightTeam);
else
generalScoreboard();
Bukkit.getOnlinePlayers().forEach(player -> player.setScoreboard(scoreboard));
}, 0, 200);
}
public static Scoreboard getScoreboard() {
static Scoreboard getScoreboard() {
return scoreboard;
}
@ -52,23 +50,14 @@ public class FightScoreboard {
});
}
private static void generalScoreboard(){
objective.setDisplayName("§6Kampf");
int fightTime = MissileWars.getFightTime();
if (fightTime >= 60)
objective.getScore("§7Zeit: §a" + fightTime / 60 + "m " + fightTime % 60 + "s").setScore(3);
else
objective.getScore("§7Zeit: §a" + fightTime + "s").setScore(3);
}
private static MWTeam getIndexDisplay() {
index++;
if(index == 1)
if(index == 0) {
index = 1;
return MissileWars.getRedTeam();
if(index == 2)
return MissileWars.getBlueTeam();
}else{
index = 0;
return null;
return MissileWars.getBlueTeam();
}
}
}

Datei anzeigen

@ -1,8 +1,6 @@
package de.steamwar.misslewars;
import org.bukkit.ChatColor;
import org.bukkit.Location;
import org.bukkit.Material;
import org.bukkit.*;
import org.bukkit.enchantments.Enchantment;
import org.bukkit.entity.Player;
import org.bukkit.inventory.ItemStack;
@ -60,9 +58,10 @@ public class MWTeam {
public void join (Player p) {
players.add(p);
p.teleport(spawn);
Bukkit.getScheduler().runTaskLater(MissileWars.getPlugin(), () -> p.setGameMode(GameMode.SURVIVAL), 1);
p.getInventory().setItem(0, bow);
sbteam.addPlayer(p);
p.setDisplayName(color + teamName + " " + p.getName());
p.setDisplayName(color + " " + p.getName());
if (MissileWars.getFightState() == FightState.WAITING && !enemy().getPlayers().isEmpty())
MissileWars.startRound();
}

Datei anzeigen

@ -10,6 +10,8 @@ import de.steamwar.misslewars.items.Snowball;
import de.steamwar.misslewars.listener.*;
import org.bukkit.Bukkit;
import org.bukkit.ChatColor;
import org.bukkit.GameMode;
import org.bukkit.Sound;
import org.bukkit.entity.Player;
import org.bukkit.plugin.java.JavaPlugin;
@ -28,13 +30,12 @@ public class MissileWars extends JavaPlugin {
plugin = this;
fightState = FightState.WAITING;
startTime = System.currentTimeMillis();
redTeam = new MWTeam(ChatColor.RED, Config.RedSpawn, "Rot", Config.RedPortalZ);
blueTeam = new MWTeam(ChatColor.BLUE, Config.BlueSpawn, "Blau", Config.BluePortalZ);
}
@Override
public void onEnable() {
redTeam = new MWTeam(ChatColor.RED, Config.RedSpawn, "Rot", Config.RedPortalZ);
blueTeam = new MWTeam(ChatColor.BLUE, Config.BlueSpawn, "Blau", Config.BluePortalZ);
new DeathListener();
new ItemListener();
new ArenaListener();
@ -44,6 +45,7 @@ public class MissileWars extends JavaPlugin {
new PortalDestructListener();
new WaitingListener();
new FightListener();
new ChatListener();
new WaitingCountdown();
new ItemCountdown();
@ -82,13 +84,18 @@ public class MissileWars extends JavaPlugin {
fightState = FightState.END;
StateDependent.setupState(fightState);
for(Player player : Bukkit.getOnlinePlayers()){
player.playSound(player.getLocation(), Sound.ENTITY_ENDER_DRAGON_DEATH, 100f, 1f);
player.setGameMode(GameMode.SPECTATOR);
}
switch (reason) {
case PORTAL_DESTROYED:
Bukkit.getServer().broadcastMessage(winner.getColoredName() + ChatColor.RESET + " hat das gegnerische Portal zerstört.");
Bukkit.getServer().broadcastMessage(winner.getColoredName() + ChatColor.RESET + " §7hat das gegnerische Portal zerstört");
break;
case NO_ENEMY:
default:
Bukkit.getServer().broadcastMessage("Ohne Gegner kein Kampf - Team " + winner.getColoredName() + ChatColor.RESET + " hat gewonnen.");
Bukkit.getServer().broadcastMessage("§7Team " + winner.getColoredName() + ChatColor.RESET + " §7hat aufgrund fehlenden Gegners gewonnen");
break;
}
}

Datei anzeigen

@ -21,10 +21,10 @@ public abstract class StateDependent {
static void setupState(FightState state){
for(StateDependent listener : listeners){
if(listener.running && !listener.active.contains(state)){
listener.enable();
listener.disable();
listener.running = false;
}else if(!listener.running && listener.active.contains(state)){
listener.disable();
listener.enable();
listener.running = true;
}
}

Datei anzeigen

@ -29,7 +29,7 @@ public class EndCountdown extends StateDependent {
@Override
public void disable() {
if(!task.isCancelled())
if(task != null && !task.isCancelled())
task.cancel();
}
}

Datei anzeigen

@ -55,12 +55,12 @@ public class ItemCountdown extends StateDependent {
@Override
public void enable() {
task = Bukkit.getScheduler().runTaskTimer(MissileWars.getPlugin(), this::run, Config.ItemTime, 0);
task = Bukkit.getScheduler().runTaskTimer(MissileWars.getPlugin(), this::run, 0, Config.ItemTime);
}
@Override
public void disable() {
if(!task.isCancelled())
if(task != null && !task.isCancelled())
task.cancel();
}
}

Datei anzeigen

@ -27,7 +27,7 @@ public class WaitingCountdown extends StateDependent {
@Override
public void disable() {
if(!task.isCancelled())
if(task != null && !task.isCancelled())
task.cancel();
}
}

Datei anzeigen

@ -1,6 +1,7 @@
package de.steamwar.misslewars.items;
import org.bukkit.Material;
import org.bukkit.Sound;
import org.bukkit.entity.Player;
import org.bukkit.inventory.ItemStack;
@ -16,6 +17,8 @@ public class Fireball extends SpecialItem {
@Override
public boolean handleUse(Player p) {
org.bukkit.entity.Fireball fb = p.launchProjectile(org.bukkit.entity.Fireball.class);
fb.setVelocity(fb.getVelocity().multiply(2));
p.playSound(p.getLocation(), Sound.ITEM_FIRECHARGE_USE, 100, 1);
fb.setIsIncendiary(true);
return true;
}

Datei anzeigen

@ -32,8 +32,8 @@ public class Missile extends SpecialItem {
private final ItemStack item;
private Missile(File missileFile){
String name = missileFile.getName().split(".")[0];
Material itemType = Material.valueOf(missileFile.getName().split(".")[1]);
String name = missileFile.getName().split("\\.")[0];
Material itemType = Material.valueOf(missileFile.getName().split("\\.")[1]);
ClipboardFormat format = ClipboardFormats.findByFile(missileFile);
@ -60,24 +60,27 @@ public class Missile extends SpecialItem {
public boolean handleUse(Player p){
BlockVector3 dimensions = clipboard.getDimensions();
Location location = p.getLocation();
BlockVector3 v = BlockVector3.at(location.getBlockX(), location.getBlockY(), location.getBlockZ());
BlockVector3 v = BlockVector3.ZERO;
BlockVector3 offset = clipboard.getRegion().getMinimumPoint().subtract(clipboard.getOrigin());
AffineTransform aT = new AffineTransform();
double yaw = p.getLocation().getYaw();
if(yaw > 45 && yaw <= 135)
double yaw = (p.getLocation().getYaw() + 360f) % 360;
if(yaw > 45 && yaw <= 135) {
aT = aT.rotateY(90);
else if(yaw > 135 && yaw <= 225)
}else if(yaw > 135 && yaw <= 225) {
aT = aT.rotateY(180);
else if(yaw > 225 && yaw <= 315)
}else if(yaw > 225 && yaw <= 315) {
aT = aT.rotateY(270);
}
v = v.subtract(dimensions.getX()/2, dimensions.getY(), dimensions.getZ()/2 - dimensions.getZ()%2).subtract(offset);
v = v.subtract(dimensions.getX()/2, dimensions.getY() + 2, -2).subtract(offset);
v = aT.apply(v.toVector3()).toBlockPoint();
v = v.add(location.getBlockX(), location.getBlockY(), location.getBlockZ());
EditSession e = WorldEdit.getInstance().getEditSessionFactory().getEditSession(world, -1);
ClipboardHolder ch = new ClipboardHolder(clipboard);
ch.setTransform(aT);
Operations.completeBlindly(ch.createPaste(e).to(v).build());
Operations.completeBlindly(ch.createPaste(e).to(v).ignoreAirBlocks(true).build());
e.flushSession();
return true;
}

Datei anzeigen

@ -6,7 +6,9 @@ import org.bukkit.GameMode;
import org.bukkit.Location;
import org.bukkit.entity.Player;
import org.bukkit.event.EventHandler;
import org.bukkit.event.player.PlayerDropItemEvent;
import org.bukkit.event.player.PlayerMoveEvent;
import org.bukkit.event.player.PlayerPickupArrowEvent;
import java.util.EnumSet;
@ -26,7 +28,7 @@ public class ArenaListener extends BasicListener {
if(p.getGameMode() == GameMode.SPECTATOR)
p.teleport(e.getFrom());
else
p.damage(Double.MAX_VALUE);
p.damage(20.0f);
}else if(
location.getX() < Config.ArenaMinX ||
location.getX() > Config.ArenaMaxX ||
@ -35,4 +37,14 @@ public class ArenaListener extends BasicListener {
p.teleport(e.getFrom());
}
}
@EventHandler
public void onArrowPickup(PlayerPickupArrowEvent e){
e.setCancelled(true);
}
@EventHandler
public void onItemDrop(PlayerDropItemEvent e){
e.setCancelled(true);
}
}

Datei anzeigen

@ -0,0 +1,21 @@
package de.steamwar.misslewars.listener;
import de.steamwar.misslewars.FightState;
import org.bukkit.Bukkit;
import org.bukkit.event.EventHandler;
import org.bukkit.event.player.AsyncPlayerChatEvent;
import java.util.EnumSet;
public class ChatListener extends BasicListener {
public ChatListener() {
super(EnumSet.allOf(FightState.class));
}
@EventHandler
public void onChat(AsyncPlayerChatEvent e){
Bukkit.broadcastMessage(e.getPlayer().getDisplayName() + "§8» §7" + e.getMessage());
e.setCancelled(true);
}
}

Datei anzeigen

@ -5,6 +5,7 @@ import de.steamwar.misslewars.MissileWars;
import org.bukkit.GameMode;
import org.bukkit.entity.Player;
import org.bukkit.event.EventHandler;
import org.bukkit.event.EventPriority;
import org.bukkit.event.player.PlayerJoinEvent;
import org.bukkit.event.player.PlayerQuitEvent;
@ -16,14 +17,13 @@ public class ConnectionListener extends BasicListener{
super(EnumSet.allOf(FightState.class));
}
@EventHandler
@EventHandler(priority = EventPriority.HIGH)
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);

Datei anzeigen

@ -29,7 +29,7 @@ import java.util.Objects;
public class ItemListener extends BasicListener {
private static final File shield = new File(de.steamwar.misslewars.MissileWars.getPlugin().getDataFolder(), "shield.schematic");
private static final File shield = new File(MissileWars.getPlugin().getDataFolder(), "shield.schematic");
private static final World world = new BukkitWorld(Bukkit.getWorlds().get(0));
private static final Clipboard clipboard;
private static final BlockVector3 offset;
@ -69,7 +69,7 @@ public class ItemListener extends BasicListener {
BlockVector3 paste = BlockVector3.at(l.getX(), l.getY(), l.getZ()).subtract(offset);
EditSession editSession = WorldEdit.getInstance().getEditSessionFactory().getEditSession(world, -1);
Operations.completeBlindly(new ClipboardHolder(clipboard).createPaste(editSession).to(paste).build());
Operations.completeBlindly(new ClipboardHolder(clipboard).createPaste(editSession).ignoreAirBlocks(true).to(paste).build());
editSession.flushSession();
}, Config.ShieldFlyTime);
}

Datei anzeigen

@ -3,6 +3,7 @@ package de.steamwar.misslewars.listener;
import de.steamwar.misslewars.FightState;
import de.steamwar.misslewars.MissileWars;
import org.bukkit.event.EventHandler;
import org.bukkit.event.EventPriority;
import org.bukkit.event.player.PlayerJoinEvent;
import java.util.EnumSet;
@ -13,11 +14,12 @@ public class JoinListener extends BasicListener {
super(EnumSet.of(FightState.WAITING, FightState.FIGHTING));
}
@EventHandler
@EventHandler(priority = EventPriority.HIGHEST)
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());
e.setJoinMessage("§a» " + e.getPlayer().getDisplayName());
}
}

Datei anzeigen

@ -1,4 +1,4 @@
name: MissleWars
name: MissileWars
prefix: MW
main: de.steamwar.misslewars.MissileWars
authors:
@ -6,3 +6,6 @@ authors:
- Lixfel
version: "1.0"
api-version: "1.13"
depend:
- WorldEdit
- SpigotCore