add ctf game
This commit is contained in:
1 parent
6bf144690d
commit
af6d9d34bb
43 files changed
+5075
No files matched your search
@@ -0,0 +1,102 @@
|
||||
package me.pgactf.EventHandler;
|
||||
|
||||
import me.pgactf.*;
|
||||
import me.pgactf.InventoryPages.KitSelectorPage;
|
||||
import org.bukkit.Bukkit;
|
||||
import org.bukkit.GameMode;
|
||||
import org.bukkit.Location;
|
||||
import org.bukkit.World;
|
||||
import org.bukkit.entity.Player;
|
||||
import org.bukkit.event.EventHandler;
|
||||
import org.bukkit.event.Listener;
|
||||
import org.bukkit.event.player.PlayerRespawnEvent;
|
||||
import org.bukkit.plugin.java.JavaPlugin;
|
||||
import org.bukkit.scheduler.BukkitRunnable;
|
||||
|
||||
public class RespawnHandler implements Listener{
|
||||
|
||||
public int getTimer(Player p){
|
||||
String team = Teams.getTeam(p);
|
||||
int countdown = 8;
|
||||
return countdown;
|
||||
}
|
||||
@EventHandler
|
||||
public void onPlayerRespawn(PlayerRespawnEvent e) {
|
||||
Player p = e.getPlayer();
|
||||
|
||||
YamlHandler yamlHandler = new YamlHandler();
|
||||
values val = yamlHandler.readYaml();
|
||||
World gameWorld = Bukkit.getWorld(val.getGameWorld());
|
||||
World spawnWorld = Bukkit.getWorld(val.getSpawnWorld());
|
||||
|
||||
if (!GameProperties.mainGameRunning() && p.getWorld() == gameWorld) {
|
||||
p.teleport(new Location(spawnWorld, val.getSpawnLocX(), val.getSpawnLocY(), val.getSpawnLocZ()));
|
||||
}
|
||||
|
||||
if (Players.getPlayers().contains(p)) {
|
||||
|
||||
if ((GameProperties.mainGameRunning())) {
|
||||
|
||||
p.setGameMode(GameMode.SPECTATOR);
|
||||
|
||||
|
||||
|
||||
|
||||
if (Teams.getTeam(p).equals("Blue")) {
|
||||
|
||||
new BukkitRunnable() {
|
||||
int countDown = getTimer(p);
|
||||
int timer = countDown;
|
||||
|
||||
@Override
|
||||
public void run() {
|
||||
if (timer == countDown) {
|
||||
p.teleport(GameProperties.blueFlagLocationBase().clone().add(0, 1, 0.5));
|
||||
}
|
||||
if (timer > 0) {
|
||||
p.sendTitle(Integer.toString(timer), "", 0, 21, 0);
|
||||
timer -= 1;
|
||||
} else {
|
||||
p.setGameMode(GameMode.SURVIVAL);
|
||||
p.teleport(new Location(gameWorld, val.getBlueTeamSpawnX(), val.getBlueTeamSpawnY(), val.getBlueTeamSpawnZ()));
|
||||
p.getInventory().clear();
|
||||
KitSelectorPage k = new KitSelectorPage();
|
||||
k.SelectKit(p);
|
||||
cancel();
|
||||
}
|
||||
}
|
||||
}.runTaskTimer(JavaPlugin.getPlugin(PgaCTF.class), 0, 20);
|
||||
|
||||
} else if (Teams.getTeam(p).equals("Red")) {
|
||||
|
||||
new BukkitRunnable() {
|
||||
int countDown = getTimer(p);
|
||||
int timer = countDown;
|
||||
|
||||
@Override
|
||||
public void run() {
|
||||
if (timer == countDown) {
|
||||
p.teleport(GameProperties.redFlagLocationBase().clone().add(0, 1, 0.5));
|
||||
}
|
||||
if (timer > 0) {
|
||||
p.sendTitle(Integer.toString(timer), "", 0, 21, 0);
|
||||
timer -= 1;
|
||||
} else {
|
||||
p.setGameMode(GameMode.SURVIVAL);
|
||||
p.teleport(new Location(gameWorld, val.getRedTeamSpawnX(), val.getRedTeamSpawnY(), val.getRedTeamSpawnZ()));
|
||||
p.getInventory().clear();
|
||||
KitSelectorPage k = new KitSelectorPage();
|
||||
k.SelectKit(p);
|
||||
|
||||
cancel();
|
||||
}
|
||||
}
|
||||
}.runTaskTimer(JavaPlugin.getPlugin(PgaCTF.class), 0, 20);
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
Reference in new issue
Block a user