teams reference rewrite
This commit is contained in:
parent
0503909014
commit
fc87556d8c
25 changed files with 531 additions and 502 deletions
|
@ -1,36 +1,13 @@
|
||||||
package net.tylermurphy.hideAndSeek;
|
package net.tylermurphy.hideAndSeek;
|
||||||
|
|
||||||
import java.util.ArrayList;
|
|
||||||
import java.util.HashMap;
|
|
||||||
import java.util.List;
|
|
||||||
import java.util.Map;
|
import java.util.Map;
|
||||||
import java.util.Map.Entry;
|
import java.util.Map.Entry;
|
||||||
|
|
||||||
import org.bukkit.configuration.ConfigurationSection;
|
import org.bukkit.configuration.ConfigurationSection;
|
||||||
import org.bukkit.configuration.file.FileConfiguration;
|
import org.bukkit.configuration.file.FileConfiguration;
|
||||||
import org.bukkit.entity.Player;
|
|
||||||
import org.bukkit.scoreboard.Scoreboard;
|
|
||||||
import org.bukkit.scoreboard.Team;
|
|
||||||
import org.bukkit.util.Vector;
|
import org.bukkit.util.Vector;
|
||||||
|
|
||||||
public class Store {
|
public class Config {
|
||||||
|
|
||||||
public static Map<String,Player>
|
|
||||||
playerList = new HashMap<String,Player>();
|
|
||||||
|
|
||||||
public static List<String>
|
|
||||||
Hider = new ArrayList<String>(),
|
|
||||||
Seeker = new ArrayList<String>(),
|
|
||||||
Spectator = new ArrayList<String>(),
|
|
||||||
Deaths = new ArrayList<String>();
|
|
||||||
|
|
||||||
public static Scoreboard
|
|
||||||
board;
|
|
||||||
|
|
||||||
public static Team
|
|
||||||
HiderTeam,
|
|
||||||
SeekerTeam,
|
|
||||||
SpectatorTeam;
|
|
||||||
|
|
||||||
public static String
|
public static String
|
||||||
messagePrefix,
|
messagePrefix,
|
||||||
|
@ -42,8 +19,7 @@ public class Store {
|
||||||
warningPrefix,
|
warningPrefix,
|
||||||
spawnWorld,
|
spawnWorld,
|
||||||
exitWorld,
|
exitWorld,
|
||||||
lobbyWorld,
|
lobbyWorld;
|
||||||
status = "Standby";
|
|
||||||
|
|
||||||
public static Vector
|
public static Vector
|
||||||
spawnPosition,
|
spawnPosition,
|
||||||
|
@ -55,18 +31,14 @@ public class Store {
|
||||||
nametagsVisible,
|
nametagsVisible,
|
||||||
permissionsRequired,
|
permissionsRequired,
|
||||||
announceMessagesToNonPlayers,
|
announceMessagesToNonPlayers,
|
||||||
lobbyStarted = false,
|
worldborderEnabled;
|
||||||
worldborderEnabled = false,
|
|
||||||
runningBackup = false;
|
|
||||||
|
|
||||||
public static int
|
public static int
|
||||||
minPlayers,
|
minPlayers,
|
||||||
gameId = 0,
|
|
||||||
worldborderSize,
|
worldborderSize,
|
||||||
worldborderDelay,
|
worldborderDelay,
|
||||||
currentWorldborderSize,
|
currentWorldborderSize,
|
||||||
gameLength,
|
gameLength;
|
||||||
timeLeft = 0;
|
|
||||||
|
|
||||||
public static FileConfiguration getConfig() {
|
public static FileConfiguration getConfig() {
|
||||||
return Main.plugin.getConfig();
|
return Main.plugin.getConfig();
|
|
@ -1,12 +1,15 @@
|
||||||
package net.tylermurphy.hideAndSeek;
|
package net.tylermurphy.hideAndSeek;
|
||||||
|
|
||||||
import java.io.File;
|
import java.io.File;
|
||||||
|
import java.util.HashMap;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
import java.util.Map;
|
||||||
|
|
||||||
import org.bukkit.Bukkit;
|
import org.bukkit.Bukkit;
|
||||||
|
|
||||||
import org.bukkit.command.Command;
|
import org.bukkit.command.Command;
|
||||||
import org.bukkit.command.CommandSender;
|
import org.bukkit.command.CommandSender;
|
||||||
|
import org.bukkit.entity.Player;
|
||||||
import org.bukkit.event.Listener;
|
import org.bukkit.event.Listener;
|
||||||
import org.bukkit.plugin.java.JavaPlugin;
|
import org.bukkit.plugin.java.JavaPlugin;
|
||||||
import org.bukkit.scheduler.BukkitTask;
|
import org.bukkit.scheduler.BukkitTask;
|
||||||
|
@ -18,15 +21,24 @@ import net.tylermurphy.hideAndSeek.bukkit.Tick;
|
||||||
import net.tylermurphy.hideAndSeek.events.Glow;
|
import net.tylermurphy.hideAndSeek.events.Glow;
|
||||||
import net.tylermurphy.hideAndSeek.events.Taunt;
|
import net.tylermurphy.hideAndSeek.events.Taunt;
|
||||||
import net.tylermurphy.hideAndSeek.events.Worldborder;
|
import net.tylermurphy.hideAndSeek.events.Worldborder;
|
||||||
|
import net.tylermurphy.hideAndSeek.util.Board;
|
||||||
|
|
||||||
public class Main extends JavaPlugin implements Listener {
|
public class Main extends JavaPlugin implements Listener {
|
||||||
|
|
||||||
public static Main plugin;
|
public static Main plugin;
|
||||||
public static File root;
|
public static File root;
|
||||||
|
|
||||||
public static Taunt taunt;
|
public Taunt taunt;
|
||||||
public static Glow glow;
|
public Glow glow;
|
||||||
public static Worldborder worldborder;
|
public Worldborder worldborder;
|
||||||
|
|
||||||
|
public Board board;
|
||||||
|
|
||||||
|
public Map<String,Player> playerList = new HashMap<String,Player>();
|
||||||
|
|
||||||
|
public String status = "Standby";
|
||||||
|
|
||||||
|
public int timeLeft = 0, gameId = 0;;
|
||||||
|
|
||||||
private BukkitTask onTickTask;
|
private BukkitTask onTickTask;
|
||||||
|
|
||||||
|
@ -38,7 +50,7 @@ public class Main extends JavaPlugin implements Listener {
|
||||||
getServer().getPluginManager().registerEvents(new EventListener(), this);
|
getServer().getPluginManager().registerEvents(new EventListener(), this);
|
||||||
|
|
||||||
// Init Configuration
|
// Init Configuration
|
||||||
Store.loadConfig();
|
Config.loadConfig();
|
||||||
|
|
||||||
// Register Commands
|
// Register Commands
|
||||||
CommandHandler.registerCommands();
|
CommandHandler.registerCommands();
|
||||||
|
@ -46,6 +58,10 @@ public class Main extends JavaPlugin implements Listener {
|
||||||
// Get Data Folder
|
// Get Data Folder
|
||||||
root = this.getServer().getWorldContainer();
|
root = this.getServer().getWorldContainer();
|
||||||
|
|
||||||
|
//Board
|
||||||
|
board = new Board();
|
||||||
|
board.init();
|
||||||
|
|
||||||
// Start Tick Timer
|
// Start Tick Timer
|
||||||
onTickTask = Bukkit.getServer().getScheduler().runTaskTimer(this, new Runnable(){
|
onTickTask = Bukkit.getServer().getScheduler().runTaskTimer(this, new Runnable(){
|
||||||
public void run(){
|
public void run(){
|
||||||
|
|
|
@ -1,6 +1,6 @@
|
||||||
package net.tylermurphy.hideAndSeek.bukkit;
|
package net.tylermurphy.hideAndSeek.bukkit;
|
||||||
|
|
||||||
import static net.tylermurphy.hideAndSeek.Store.*;
|
import static net.tylermurphy.hideAndSeek.Config.*;
|
||||||
|
|
||||||
import java.util.Arrays;
|
import java.util.Arrays;
|
||||||
import java.util.LinkedHashMap;
|
import java.util.LinkedHashMap;
|
||||||
|
@ -10,8 +10,8 @@ import org.bukkit.command.Command;
|
||||||
import org.bukkit.command.CommandSender;
|
import org.bukkit.command.CommandSender;
|
||||||
import org.bukkit.entity.Player;
|
import org.bukkit.entity.Player;
|
||||||
|
|
||||||
|
import net.tylermurphy.hideAndSeek.Main;
|
||||||
import net.tylermurphy.hideAndSeek.command.*;
|
import net.tylermurphy.hideAndSeek.command.*;
|
||||||
import net.tylermurphy.hideAndSeek.util.ICommand;
|
|
||||||
|
|
||||||
public class CommandHandler {
|
public class CommandHandler {
|
||||||
|
|
||||||
|
@ -40,6 +40,9 @@ public class CommandHandler {
|
||||||
}
|
}
|
||||||
|
|
||||||
public static boolean handleCommand(CommandSender sender, Command cmd, String label, String[] args) {
|
public static boolean handleCommand(CommandSender sender, Command cmd, String label, String[] args) {
|
||||||
|
if(!Main.plugin.board.isReady()) {
|
||||||
|
Main.plugin.board.reload();
|
||||||
|
}
|
||||||
if(sender instanceof Player == false) {
|
if(sender instanceof Player == false) {
|
||||||
sender.sendMessage(errorPrefix + "This command can only be run as a player.");
|
sender.sendMessage(errorPrefix + "This command can only be run as a player.");
|
||||||
} else if(args.length < 1 || !COMMAND_REGISTER.containsKey(args[0].toLowerCase()) ) {
|
} else if(args.length < 1 || !COMMAND_REGISTER.containsKey(args[0].toLowerCase()) ) {
|
||||||
|
@ -49,7 +52,7 @@ public class CommandHandler {
|
||||||
COMMAND_REGISTER.get("about").execute(sender, null);
|
COMMAND_REGISTER.get("about").execute(sender, null);
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
if(!args[0].toLowerCase().equals("about") && !args[0].toLowerCase().equals("help") && runningBackup) {
|
if(!args[0].toLowerCase().equals("about") && !args[0].toLowerCase().equals("help") && SaveMap.runningBackup) {
|
||||||
sender.sendMessage(errorPrefix + "Map save is currently in progress. Try again later.");
|
sender.sendMessage(errorPrefix + "Map save is currently in progress. Try again later.");
|
||||||
} else if(permissionsRequired && !sender.hasPermission("hideandseek."+args[0].toLowerCase())) {
|
} else if(permissionsRequired && !sender.hasPermission("hideandseek."+args[0].toLowerCase())) {
|
||||||
sender.sendMessage(errorPrefix + "You are not allowed to run this command.");
|
sender.sendMessage(errorPrefix + "You are not allowed to run this command.");
|
||||||
|
|
|
@ -1,6 +1,6 @@
|
||||||
package net.tylermurphy.hideAndSeek.bukkit;
|
package net.tylermurphy.hideAndSeek.bukkit;
|
||||||
|
|
||||||
import static net.tylermurphy.hideAndSeek.Store.*;
|
import static net.tylermurphy.hideAndSeek.Config.*;
|
||||||
|
|
||||||
import org.bukkit.Bukkit;
|
import org.bukkit.Bukkit;
|
||||||
import org.bukkit.GameMode;
|
import org.bukkit.GameMode;
|
||||||
|
@ -24,19 +24,22 @@ import org.bukkit.event.player.PlayerKickEvent;
|
||||||
import org.bukkit.event.player.PlayerQuitEvent;
|
import org.bukkit.event.player.PlayerQuitEvent;
|
||||||
|
|
||||||
import net.md_5.bungee.api.ChatColor;
|
import net.md_5.bungee.api.ChatColor;
|
||||||
import net.tylermurphy.hideAndSeek.Main;
|
|
||||||
import net.tylermurphy.hideAndSeek.util.Functions;
|
|
||||||
import net.tylermurphy.hideAndSeek.util.Packet;
|
import net.tylermurphy.hideAndSeek.util.Packet;
|
||||||
|
import net.tylermurphy.hideAndSeek.util.Util;
|
||||||
|
import net.tylermurphy.hideAndSeek.Main;
|
||||||
|
import net.tylermurphy.hideAndSeek.command.Start;
|
||||||
|
|
||||||
public class EventListener implements Listener {
|
public class EventListener implements Listener {
|
||||||
|
|
||||||
@EventHandler
|
@EventHandler
|
||||||
public void onPlayerJoin(PlayerJoinEvent event) {
|
public void onPlayerJoin(PlayerJoinEvent event) {
|
||||||
event.getPlayer().setLevel(0);
|
event.getPlayer().setLevel(0);
|
||||||
HiderTeam.removeEntry(event.getPlayer().getName());
|
if(Main.plugin.board.isReady()) {
|
||||||
SeekerTeam.removeEntry(event.getPlayer().getName());
|
Main.plugin.board.remove(event.getPlayer());
|
||||||
SpectatorTeam.removeEntry(event.getPlayer().getName());
|
} else {
|
||||||
if(!Functions.setup()) return;
|
Main.plugin.board.init();
|
||||||
|
}
|
||||||
|
if(!Util.isSetup()) return;
|
||||||
if(event.getPlayer().getWorld().getName().equals("hideandseek_"+spawnWorld) || event.getPlayer().getWorld().getName().equals(lobbyWorld)){
|
if(event.getPlayer().getWorld().getName().equals("hideandseek_"+spawnWorld) || event.getPlayer().getWorld().getName().equals(lobbyWorld)){
|
||||||
event.getPlayer().teleport(new Location(Bukkit.getWorld(exitWorld), exitPosition.getX(), exitPosition.getY(), exitPosition.getZ()));
|
event.getPlayer().teleport(new Location(Bukkit.getWorld(exitWorld), exitPosition.getX(), exitPosition.getY(), exitPosition.getZ()));
|
||||||
event.getPlayer().setGameMode(GameMode.ADVENTURE);
|
event.getPlayer().setGameMode(GameMode.ADVENTURE);
|
||||||
|
@ -45,34 +48,20 @@ public class EventListener implements Listener {
|
||||||
|
|
||||||
@EventHandler
|
@EventHandler
|
||||||
public void onQuit(PlayerQuitEvent event) {
|
public void onQuit(PlayerQuitEvent event) {
|
||||||
if(!playerList.containsKey(event.getPlayer().getName())) return;
|
Main.plugin.board.remove(event.getPlayer());
|
||||||
playerList.remove(event.getPlayer().getName());
|
|
||||||
Hider.remove(event.getPlayer().getName());
|
|
||||||
HiderTeam.removeEntry(event.getPlayer().getName());
|
|
||||||
Seeker.remove(event.getPlayer().getName());
|
|
||||||
SeekerTeam.removeEntry(event.getPlayer().getName());
|
|
||||||
Spectator.remove(event.getPlayer().getName());
|
|
||||||
SpectatorTeam.removeEntry(event.getPlayer().getName());
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@EventHandler
|
@EventHandler
|
||||||
public void onKick(PlayerKickEvent event) {
|
public void onKick(PlayerKickEvent event) {
|
||||||
if(!playerList.containsKey(event.getPlayer().getName())) return;
|
Main.plugin.board.remove(event.getPlayer());
|
||||||
playerList.remove(event.getPlayer().getName());
|
|
||||||
Hider.remove(event.getPlayer().getName());
|
|
||||||
HiderTeam.removeEntry(event.getPlayer().getName());
|
|
||||||
Seeker.remove(event.getPlayer().getName());
|
|
||||||
SeekerTeam.removeEntry(event.getPlayer().getName());
|
|
||||||
Spectator.remove(event.getPlayer().getName());
|
|
||||||
SpectatorTeam.removeEntry(event.getPlayer().getName());
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@EventHandler
|
@EventHandler
|
||||||
public void onEntityDamage(EntityDamageEvent event) {
|
public void onEntityDamage(EntityDamageEvent event) {
|
||||||
if(event.getEntity() instanceof Player) {
|
if(event.getEntity() instanceof Player) {
|
||||||
Player p = (Player) event.getEntity();
|
Player p = (Player) event.getEntity();
|
||||||
if(!playerList.containsKey(p.getName())) return;
|
if(!Main.plugin.board.isPlayer(p)) return;
|
||||||
if(!status.equals("Playing")) {
|
if(!Main.plugin.status.equals("Playing")) {
|
||||||
event.setCancelled(true);
|
event.setCancelled(true);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
@ -81,9 +70,8 @@ public class EventListener implements Listener {
|
||||||
Entity damager = ((EntityDamageByEntityEvent)event).getDamager();
|
Entity damager = ((EntityDamageByEntityEvent)event).getDamager();
|
||||||
if(damager instanceof Player) {
|
if(damager instanceof Player) {
|
||||||
attacker = (Player) damager;
|
attacker = (Player) damager;
|
||||||
if(Hider.contains(attacker.getName()) && Hider.contains(p.getName())) event.setCancelled(true);
|
if(Main.plugin.board.onSameTeam(p, p)) event.setCancelled(true);
|
||||||
if(Seeker.contains(attacker.getName()) && Seeker.contains(p.getName())) event.setCancelled(true);
|
if(Main.plugin.board.isSpectator(p)) event.setCancelled(true);
|
||||||
if(Spectator.contains(attacker.getName())) event.setCancelled(true);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
Player player = (Player) event.getEntity();
|
Player player = (Player) event.getEntity();
|
||||||
|
@ -93,33 +81,31 @@ public class EventListener implements Listener {
|
||||||
player.setHealth(player.getAttribute(Attribute.GENERIC_MAX_HEALTH).getValue());
|
player.setHealth(player.getAttribute(Attribute.GENERIC_MAX_HEALTH).getValue());
|
||||||
player.teleport(new Location(Bukkit.getWorld("hideandseek_"+spawnWorld), spawnPosition.getX(), spawnPosition.getY(), spawnPosition.getZ()));
|
player.teleport(new Location(Bukkit.getWorld("hideandseek_"+spawnWorld), spawnPosition.getX(), spawnPosition.getY(), spawnPosition.getZ()));
|
||||||
Packet.playSound(player, Sound.ENTITY_PLAYER_DEATH, 1, 1);
|
Packet.playSound(player, Sound.ENTITY_PLAYER_DEATH, 1, 1);
|
||||||
if(Seeker.contains(event.getEntity().getName())) {
|
if(Main.plugin.board.isSeeker(player)) {
|
||||||
Bukkit.broadcastMessage(String.format(messagePrefix + "%s%s%s was killed", ChatColor.RED, event.getEntity().getName(), ChatColor.WHITE));
|
Bukkit.broadcastMessage(String.format(messagePrefix + "%s%s%s was killed", ChatColor.RED, event.getEntity().getName(), ChatColor.WHITE));
|
||||||
}
|
}
|
||||||
if(Hider.contains(event.getEntity().getName())) {
|
if(Main.plugin.board.isHider(player)) {
|
||||||
if(attacker == null) {
|
if(attacker == null) {
|
||||||
Functions.broadcastMessage(String.format(messagePrefix + "%s%s%s was found and became a seeker", ChatColor.GOLD, event.getEntity().getName(), ChatColor.WHITE));
|
Util.broadcastMessage(String.format(messagePrefix + "%s%s%s was found and became a seeker", ChatColor.GOLD, event.getEntity().getName(), ChatColor.WHITE));
|
||||||
} else {
|
} else {
|
||||||
Functions.broadcastMessage(String.format(messagePrefix + "%s%s%s was found by %s%s%s and became a seeker", ChatColor.GOLD, event.getEntity().getName(), ChatColor.WHITE, ChatColor.RED, attacker.getName(), ChatColor.WHITE));
|
Util.broadcastMessage(String.format(messagePrefix + "%s%s%s was found by %s%s%s and became a seeker", ChatColor.GOLD, event.getEntity().getName(), ChatColor.WHITE, ChatColor.RED, attacker.getName(), ChatColor.WHITE));
|
||||||
}
|
}
|
||||||
Hider.remove(player.getName());
|
Main.plugin.board.addSeeker(player);
|
||||||
Seeker.add(player.getName());
|
|
||||||
SeekerTeam.addEntry(player.getName());
|
|
||||||
}
|
}
|
||||||
Functions.resetPlayer(player);
|
Start.resetPlayer(player);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@EventHandler
|
@EventHandler
|
||||||
public void onProjectile(ProjectileLaunchEvent event) {
|
public void onProjectile(ProjectileLaunchEvent event) {
|
||||||
if(!status.equals("Playing")) return;
|
if(Main.plugin.status.equals("Playing")) return;
|
||||||
if(event.getEntity() instanceof Snowball) {
|
if(event.getEntity() instanceof Snowball) {
|
||||||
Snowball snowball = (Snowball) event.getEntity();
|
Snowball snowball = (Snowball) event.getEntity();
|
||||||
if(snowball.getShooter() instanceof Player) {
|
if(snowball.getShooter() instanceof Player) {
|
||||||
Player player = (Player) snowball.getShooter();
|
Player player = (Player) snowball.getShooter();
|
||||||
if(Hider.contains(player.getName())) {
|
if(Main.plugin.board.isHider(player)) {
|
||||||
Main.glow.onProjectilve();
|
Main.plugin.glow.onProjectilve();
|
||||||
snowball.remove();
|
snowball.remove();
|
||||||
player.getInventory().remove(Material.SNOWBALL);
|
player.getInventory().remove(Material.SNOWBALL);
|
||||||
}
|
}
|
||||||
|
@ -130,7 +116,7 @@ public class EventListener implements Listener {
|
||||||
@EventHandler
|
@EventHandler
|
||||||
public void onFoodLevelChange(FoodLevelChangeEvent event) {
|
public void onFoodLevelChange(FoodLevelChangeEvent event) {
|
||||||
if(event.getEntity() instanceof Player) {
|
if(event.getEntity() instanceof Player) {
|
||||||
if(!playerList.containsKey(event.getEntity().getName())) return;
|
if(!Main.plugin.board.isPlayer((Player) event.getEntity())) return;
|
||||||
event.setCancelled(true);
|
event.setCancelled(true);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -139,7 +125,7 @@ public class EventListener implements Listener {
|
||||||
public void onPlayerRegainHealth(EntityRegainHealthEvent event) {
|
public void onPlayerRegainHealth(EntityRegainHealthEvent event) {
|
||||||
if(event.getRegainReason() == RegainReason.SATIATED || event.getRegainReason() == RegainReason.REGEN) {
|
if(event.getRegainReason() == RegainReason.SATIATED || event.getRegainReason() == RegainReason.REGEN) {
|
||||||
if(event.getEntity() instanceof Player) {
|
if(event.getEntity() instanceof Player) {
|
||||||
if(!playerList.containsKey(event.getEntity().getName())) return;
|
if(!Main.plugin.board.isPlayer((Player) event.getEntity())) return;
|
||||||
event.setCancelled(true);
|
event.setCancelled(true);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,14 +1,15 @@
|
||||||
package net.tylermurphy.hideAndSeek.bukkit;
|
package net.tylermurphy.hideAndSeek.bukkit;
|
||||||
|
|
||||||
import static net.tylermurphy.hideAndSeek.Store.*;
|
import static net.tylermurphy.hideAndSeek.Config.*;
|
||||||
|
|
||||||
import org.bukkit.Bukkit;
|
import org.bukkit.Bukkit;
|
||||||
import org.bukkit.Sound;
|
import org.bukkit.Sound;
|
||||||
import org.bukkit.entity.Player;
|
import org.bukkit.entity.Player;
|
||||||
|
|
||||||
|
import net.tylermurphy.hideAndSeek.Main;
|
||||||
import net.tylermurphy.hideAndSeek.command.Stop;
|
import net.tylermurphy.hideAndSeek.command.Stop;
|
||||||
import net.tylermurphy.hideAndSeek.util.Functions;
|
|
||||||
import net.tylermurphy.hideAndSeek.util.Packet;
|
import net.tylermurphy.hideAndSeek.util.Packet;
|
||||||
|
import net.tylermurphy.hideAndSeek.util.Util;
|
||||||
|
|
||||||
public class Tick {
|
public class Tick {
|
||||||
|
|
||||||
|
@ -16,26 +17,17 @@ public class Tick {
|
||||||
|
|
||||||
public static void onTick() {
|
public static void onTick() {
|
||||||
|
|
||||||
if(board == null) {
|
if(Main.plugin.status.equals("Standby")) tick = 0;
|
||||||
Functions.loadScoreboard();
|
else if(Main.plugin.status.equals("Playing")) onPlaying();
|
||||||
}
|
|
||||||
|
|
||||||
if(status.equals("Standby")) {
|
if(( Main.plugin.status.equals("Starting") || Main.plugin.status.equals("Playing") ) && Main.plugin.board.sizeHider() < 1) {
|
||||||
tick = 0;
|
|
||||||
}
|
|
||||||
|
|
||||||
if(status.equals("Playing")) {
|
|
||||||
onPlaying();
|
|
||||||
}
|
|
||||||
|
|
||||||
if(( status.equals("Starting") || status.equals("Playing") ) && Hider.size() < 1) {
|
|
||||||
if(announceMessagesToNonPlayers) Bukkit.broadcastMessage(gameoverPrefix + "All hiders have been found.");
|
if(announceMessagesToNonPlayers) Bukkit.broadcastMessage(gameoverPrefix + "All hiders have been found.");
|
||||||
else Functions.broadcastMessage(gameoverPrefix + "All hiders have been found.");
|
else Util.broadcastMessage(gameoverPrefix + "All hiders have been found.");
|
||||||
Stop.onStop();
|
Stop.onStop();
|
||||||
}
|
}
|
||||||
if(( status.equals("Starting") || status.equals("Playing") ) && Seeker.size() < 1) {
|
if(( Main.plugin.status.equals("Starting") || Main.plugin.status.equals("Playing") ) && Main.plugin.board.sizeSeeker() < 1) {
|
||||||
if(announceMessagesToNonPlayers) Bukkit.broadcastMessage(abortPrefix + "All seekers have quit.");
|
if(announceMessagesToNonPlayers) Bukkit.broadcastMessage(abortPrefix + "All seekers have quit.");
|
||||||
else Functions.broadcastMessage(abortPrefix + "All seekers have quit.");
|
else Util.broadcastMessage(abortPrefix + "All seekers have quit.");
|
||||||
Stop.onStop();
|
Stop.onStop();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -43,32 +35,31 @@ public class Tick {
|
||||||
|
|
||||||
private static void onPlaying() {
|
private static void onPlaying() {
|
||||||
|
|
||||||
tick ++;
|
if(tick<1000000) tick++;
|
||||||
|
else tick = 1;
|
||||||
|
|
||||||
for(String playerName : Hider) {
|
for(Player hider : Main.plugin.board.getHiders()) {
|
||||||
Player player = playerList.get(playerName);
|
|
||||||
int distance = 100;
|
int distance = 100;
|
||||||
for(String seekerName : Seeker) {
|
for(Player seeker : Main.plugin.board.getSeekers()) {
|
||||||
Player seeker = playerList.get(seekerName);
|
int temp = (int) hider.getLocation().distance(seeker.getLocation());
|
||||||
int temp = (int) player.getLocation().distance(seeker.getLocation());
|
|
||||||
if(distance > temp) {
|
if(distance > temp) {
|
||||||
distance = temp;
|
distance = temp;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
switch(tick%10) {
|
switch(tick%10) {
|
||||||
case 0:
|
case 0:
|
||||||
if(distance < 30) Packet.playSound(player, Sound.BLOCK_NOTE_BLOCK_BASEDRUM, .5f, 1f);
|
if(distance < 30) Packet.playSound(hider, Sound.BLOCK_NOTE_BLOCK_BASEDRUM, .5f, 1f);
|
||||||
if(distance < 10) Packet.playSound(player, Sound.BLOCK_NOTE_BLOCK_BIT, .3f, 1f);
|
if(distance < 10) Packet.playSound(hider, Sound.BLOCK_NOTE_BLOCK_BIT, .3f, 1f);
|
||||||
break;
|
break;
|
||||||
case 3:
|
case 3:
|
||||||
if(distance < 30) Packet.playSound(player, Sound.BLOCK_NOTE_BLOCK_BASEDRUM, .3f, 1f);
|
if(distance < 30) Packet.playSound(hider, Sound.BLOCK_NOTE_BLOCK_BASEDRUM, .3f, 1f);
|
||||||
if(distance < 10) Packet.playSound(player, Sound.BLOCK_NOTE_BLOCK_BIT, .3f, 1f);
|
if(distance < 10) Packet.playSound(hider, Sound.BLOCK_NOTE_BLOCK_BIT, .3f, 1f);
|
||||||
break;
|
break;
|
||||||
case 6:
|
case 6:
|
||||||
if(distance < 10) Packet.playSound(player, Sound.BLOCK_NOTE_BLOCK_BIT, .3f, 1f);
|
if(distance < 10) Packet.playSound(hider, Sound.BLOCK_NOTE_BLOCK_BIT, .3f, 1f);
|
||||||
break;
|
break;
|
||||||
case 9:
|
case 9:
|
||||||
if(distance < 20) Packet.playSound(player, Sound.BLOCK_NOTE_BLOCK_BIT, .3f, 1f);
|
if(distance < 20) Packet.playSound(hider, Sound.BLOCK_NOTE_BLOCK_BIT, .3f, 1f);
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -76,13 +67,13 @@ public class Tick {
|
||||||
|
|
||||||
if(tick%20 == 0) {
|
if(tick%20 == 0) {
|
||||||
if(gameLength > 0) {
|
if(gameLength > 0) {
|
||||||
timeLeft--;
|
Main.plugin.timeLeft--;
|
||||||
for(Player player : playerList.values()) {
|
for(Player player : Main.plugin.board.getPlayers()) {
|
||||||
player.setLevel(timeLeft);
|
player.setLevel(Main.plugin.timeLeft);
|
||||||
}
|
}
|
||||||
if(timeLeft < 1) {
|
if(Main.plugin.timeLeft < 1) {
|
||||||
if(announceMessagesToNonPlayers) Bukkit.broadcastMessage(gameoverPrefix + "Seekers ran out of time. Hiders win!");
|
if(announceMessagesToNonPlayers) Bukkit.broadcastMessage(gameoverPrefix + "Seekers ran out of time. Hiders win!");
|
||||||
else Functions.broadcastMessage(gameoverPrefix + "Seekers ran out of time. Hiders win!");
|
else Util.broadcastMessage(gameoverPrefix + "Seekers ran out of time. Hiders win!");
|
||||||
Stop.onStop();
|
Stop.onStop();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -3,8 +3,6 @@ package net.tylermurphy.hideAndSeek.command;
|
||||||
import org.bukkit.ChatColor;
|
import org.bukkit.ChatColor;
|
||||||
import org.bukkit.command.CommandSender;
|
import org.bukkit.command.CommandSender;
|
||||||
|
|
||||||
import net.tylermurphy.hideAndSeek.util.ICommand;
|
|
||||||
|
|
||||||
public class About implements ICommand {
|
public class About implements ICommand {
|
||||||
|
|
||||||
public void execute(CommandSender sender, String[] args) {
|
public void execute(CommandSender sender, String[] args) {
|
||||||
|
|
|
@ -4,7 +4,6 @@ import org.bukkit.command.CommandSender;
|
||||||
|
|
||||||
import net.md_5.bungee.api.ChatColor;
|
import net.md_5.bungee.api.ChatColor;
|
||||||
import net.tylermurphy.hideAndSeek.bukkit.CommandHandler;
|
import net.tylermurphy.hideAndSeek.bukkit.CommandHandler;
|
||||||
import net.tylermurphy.hideAndSeek.util.ICommand;
|
|
||||||
|
|
||||||
public class Help implements ICommand {
|
public class Help implements ICommand {
|
||||||
|
|
||||||
|
|
|
@ -1,4 +1,4 @@
|
||||||
package net.tylermurphy.hideAndSeek.util;
|
package net.tylermurphy.hideAndSeek.command;
|
||||||
|
|
||||||
import org.bukkit.command.CommandSender;
|
import org.bukkit.command.CommandSender;
|
||||||
|
|
|
@ -7,15 +7,15 @@ import org.bukkit.attribute.Attribute;
|
||||||
import org.bukkit.command.CommandSender;
|
import org.bukkit.command.CommandSender;
|
||||||
import org.bukkit.entity.Player;
|
import org.bukkit.entity.Player;
|
||||||
|
|
||||||
import net.tylermurphy.hideAndSeek.util.Functions;
|
import net.tylermurphy.hideAndSeek.Main;
|
||||||
import net.tylermurphy.hideAndSeek.util.ICommand;
|
import net.tylermurphy.hideAndSeek.util.Util;
|
||||||
|
|
||||||
import static net.tylermurphy.hideAndSeek.Store.*;
|
import static net.tylermurphy.hideAndSeek.Config.*;
|
||||||
|
|
||||||
public class Join implements ICommand {
|
public class Join implements ICommand {
|
||||||
|
|
||||||
public void execute(CommandSender sender, String[] args) {
|
public void execute(CommandSender sender, String[] args) {
|
||||||
if(!Functions.setup()) {
|
if(!Util.isSetup()) {
|
||||||
sender.sendMessage(errorPrefix + "Game is not setup. Run /hs setup to see what you needed to do");
|
sender.sendMessage(errorPrefix + "Game is not setup. Run /hs setup to see what you needed to do");
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
@ -24,21 +24,19 @@ public class Join implements ICommand {
|
||||||
sender.sendMessage(errorPrefix + "An internal error has occured");
|
sender.sendMessage(errorPrefix + "An internal error has occured");
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
if(playerList.containsKey(player.getName())){
|
if(Main.plugin.board.isPlayer(player)){
|
||||||
sender.sendMessage(errorPrefix + "You are already in the lobby/game");
|
sender.sendMessage(errorPrefix + "You are already in the lobby/game");
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
playerList.put(player.getName(), player);
|
|
||||||
if(status.equals("Standby")) {
|
if(Main.plugin.status.equals("Standby")) {
|
||||||
Hider.add(player.getName());
|
Main.plugin.board.addHider(player);
|
||||||
HiderTeam.addEntry(player.getName());
|
|
||||||
if(announceMessagesToNonPlayers) Bukkit.broadcastMessage(messagePrefix + sender.getName() + " has joined the HideAndSeek lobby");
|
if(announceMessagesToNonPlayers) Bukkit.broadcastMessage(messagePrefix + sender.getName() + " has joined the HideAndSeek lobby");
|
||||||
else Functions.broadcastMessage(messagePrefix + sender.getName() + " has joined the HideAndSeek lobby");
|
else Util.broadcastMessage(messagePrefix + sender.getName() + " has joined the HideAndSeek lobby");
|
||||||
player.teleport(new Location(Bukkit.getWorld(lobbyWorld), lobbyPosition.getX(),lobbyPosition.getY(),lobbyPosition.getZ()));
|
player.teleport(new Location(Bukkit.getWorld(lobbyWorld), lobbyPosition.getX(),lobbyPosition.getY(),lobbyPosition.getZ()));
|
||||||
player.setGameMode(GameMode.ADVENTURE);
|
player.setGameMode(GameMode.ADVENTURE);
|
||||||
} else {
|
} else {
|
||||||
Spectator.add(player.getName());
|
Main.plugin.board.addSeeker(player);
|
||||||
SpectatorTeam.addEntry(player.getName());
|
|
||||||
player.sendMessage(messagePrefix + "You have joined mid game and became a spectator");
|
player.sendMessage(messagePrefix + "You have joined mid game and became a spectator");
|
||||||
player.setGameMode(GameMode.SPECTATOR);
|
player.setGameMode(GameMode.SPECTATOR);
|
||||||
player.teleport(new Location(Bukkit.getWorld("hideandseek_"+spawnWorld), spawnPosition.getX(),spawnPosition.getY(),spawnPosition.getZ()));
|
player.teleport(new Location(Bukkit.getWorld("hideandseek_"+spawnWorld), spawnPosition.getX(),spawnPosition.getY(),spawnPosition.getZ()));
|
||||||
|
|
|
@ -5,15 +5,15 @@ import org.bukkit.Location;
|
||||||
import org.bukkit.command.CommandSender;
|
import org.bukkit.command.CommandSender;
|
||||||
import org.bukkit.entity.Player;
|
import org.bukkit.entity.Player;
|
||||||
|
|
||||||
import net.tylermurphy.hideAndSeek.util.Functions;
|
import net.tylermurphy.hideAndSeek.Main;
|
||||||
import net.tylermurphy.hideAndSeek.util.ICommand;
|
import net.tylermurphy.hideAndSeek.util.Util;
|
||||||
|
|
||||||
import static net.tylermurphy.hideAndSeek.Store.*;
|
import static net.tylermurphy.hideAndSeek.Config.*;
|
||||||
|
|
||||||
public class Leave implements ICommand {
|
public class Leave implements ICommand {
|
||||||
|
|
||||||
public void execute(CommandSender sender, String[] args) {
|
public void execute(CommandSender sender, String[] args) {
|
||||||
if(!Functions.setup()) {
|
if(!Util.isSetup()) {
|
||||||
sender.sendMessage(errorPrefix + "Game is not setup. Run /hs setup to see what you needed to do");
|
sender.sendMessage(errorPrefix + "Game is not setup. Run /hs setup to see what you needed to do");
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
@ -22,19 +22,13 @@ public class Leave implements ICommand {
|
||||||
sender.sendMessage(errorPrefix + "An internal error has occured");
|
sender.sendMessage(errorPrefix + "An internal error has occured");
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
if(!playerList.containsKey(player.getName())) {
|
if(!Main.plugin.board.isPlayer(player)) {
|
||||||
sender.sendMessage(errorPrefix + "You are currently not in the lobby");
|
sender.sendMessage(errorPrefix + "You are currently not in the lobby");
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
if(!Seeker.contains(player.getName())) {
|
if(announceMessagesToNonPlayers) Bukkit.broadcastMessage(messagePrefix + sender.getName() + " has left the HideAndSeek lobby");
|
||||||
if(announceMessagesToNonPlayers) Bukkit.broadcastMessage(messagePrefix + sender.getName() + " has left the HideAndSeek lobby");
|
else Util.broadcastMessage(messagePrefix + sender.getName() + " has left the HideAndSeek lobby");
|
||||||
else Functions.broadcastMessage(messagePrefix + sender.getName() + " has left the HideAndSeek lobby");
|
Main.plugin.board.remove(player);
|
||||||
}
|
|
||||||
playerList.remove(player.getName());
|
|
||||||
Hider.remove(player.getName());
|
|
||||||
Seeker.remove(player.getName());
|
|
||||||
HiderTeam.removeEntry(player.getName());
|
|
||||||
SeekerTeam.removeEntry(player.getName());
|
|
||||||
player.teleport(new Location(Bukkit.getWorld(exitWorld), exitPosition.getX(), exitPosition.getY(), exitPosition.getZ()));
|
player.teleport(new Location(Bukkit.getWorld(exitWorld), exitPosition.getX(), exitPosition.getY(), exitPosition.getZ()));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -1,29 +1,23 @@
|
||||||
package net.tylermurphy.hideAndSeek.command;
|
package net.tylermurphy.hideAndSeek.command;
|
||||||
|
|
||||||
import org.bukkit.command.CommandSender;
|
import org.bukkit.command.CommandSender;
|
||||||
import org.bukkit.entity.Player;
|
|
||||||
|
|
||||||
import net.tylermurphy.hideAndSeek.Store;
|
import net.tylermurphy.hideAndSeek.Main;
|
||||||
import net.tylermurphy.hideAndSeek.util.Functions;
|
import net.tylermurphy.hideAndSeek.Config;
|
||||||
import net.tylermurphy.hideAndSeek.util.ICommand;
|
|
||||||
|
|
||||||
import static net.tylermurphy.hideAndSeek.Store.*;
|
import static net.tylermurphy.hideAndSeek.Config.*;
|
||||||
|
|
||||||
import java.util.HashMap;
|
|
||||||
|
|
||||||
public class Reload implements ICommand {
|
public class Reload implements ICommand {
|
||||||
|
|
||||||
public void execute(CommandSender sender, String[] args) {
|
public void execute(CommandSender sender, String[] args) {
|
||||||
if(!status.equals("Standby")) {
|
|
||||||
|
if(!Main.plugin.status.equals("Standby")) {
|
||||||
sender.sendMessage(errorPrefix + "Game is currently in session");
|
sender.sendMessage(errorPrefix + "Game is currently in session");
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
Store.loadConfig();
|
Config.loadConfig();
|
||||||
try {
|
Main.plugin.board.reload();
|
||||||
Functions.loadScoreboard();
|
|
||||||
} catch(Exception e) {}
|
|
||||||
sender.sendMessage(messagePrefix + "Reloaded the config");
|
sender.sendMessage(messagePrefix + "Reloaded the config");
|
||||||
playerList = new HashMap<String,Player>();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public String getLabel() {
|
public String getLabel() {
|
||||||
|
|
|
@ -1,6 +1,6 @@
|
||||||
package net.tylermurphy.hideAndSeek.command;
|
package net.tylermurphy.hideAndSeek.command;
|
||||||
|
|
||||||
import static net.tylermurphy.hideAndSeek.Store.*;
|
import static net.tylermurphy.hideAndSeek.Config.*;
|
||||||
|
|
||||||
import java.io.File;
|
import java.io.File;
|
||||||
import java.io.FileInputStream;
|
import java.io.FileInputStream;
|
||||||
|
@ -16,12 +16,13 @@ import org.bukkit.command.CommandSender;
|
||||||
import org.bukkit.scheduler.BukkitRunnable;
|
import org.bukkit.scheduler.BukkitRunnable;
|
||||||
|
|
||||||
import net.tylermurphy.hideAndSeek.Main;
|
import net.tylermurphy.hideAndSeek.Main;
|
||||||
import net.tylermurphy.hideAndSeek.util.ICommand;
|
|
||||||
|
|
||||||
public class SaveMap implements ICommand {
|
public class SaveMap implements ICommand {
|
||||||
|
|
||||||
|
public static boolean runningBackup = false;
|
||||||
|
|
||||||
public void execute(CommandSender sender, String[] args) {
|
public void execute(CommandSender sender, String[] args) {
|
||||||
if(!status.equals("Standby")) {
|
if(!Main.plugin.status.equals("Standby")) {
|
||||||
sender.sendMessage(errorPrefix + "Game is currently in session");
|
sender.sendMessage(errorPrefix + "Game is currently in session");
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,6 +1,6 @@
|
||||||
package net.tylermurphy.hideAndSeek.command;
|
package net.tylermurphy.hideAndSeek.command;
|
||||||
|
|
||||||
import static net.tylermurphy.hideAndSeek.Store.*;
|
import static net.tylermurphy.hideAndSeek.Config.*;
|
||||||
|
|
||||||
import java.util.HashMap;
|
import java.util.HashMap;
|
||||||
import java.util.Map;
|
import java.util.Map;
|
||||||
|
@ -9,13 +9,13 @@ import org.bukkit.command.CommandSender;
|
||||||
import org.bukkit.entity.Player;
|
import org.bukkit.entity.Player;
|
||||||
import org.bukkit.util.Vector;
|
import org.bukkit.util.Vector;
|
||||||
|
|
||||||
import net.tylermurphy.hideAndSeek.util.Functions;
|
import net.tylermurphy.hideAndSeek.Main;
|
||||||
import net.tylermurphy.hideAndSeek.util.ICommand;
|
import net.tylermurphy.hideAndSeek.events.Worldborder;
|
||||||
|
|
||||||
public class SetBorder implements ICommand {
|
public class SetBorder implements ICommand {
|
||||||
|
|
||||||
public void execute(CommandSender sender, String[] args) {
|
public void execute(CommandSender sender, String[] args) {
|
||||||
if(!status.equals("Standby")) {
|
if(!Main.plugin.status.equals("Standby")) {
|
||||||
sender.sendMessage(errorPrefix + "Game is currently in session");
|
sender.sendMessage(errorPrefix + "Game is currently in session");
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
@ -30,7 +30,7 @@ public class SetBorder implements ICommand {
|
||||||
addToSection("worldBorder",temp);
|
addToSection("worldBorder",temp);
|
||||||
saveConfig();
|
saveConfig();
|
||||||
sender.sendMessage(messagePrefix + "Disabled worldborder.");
|
sender.sendMessage(messagePrefix + "Disabled worldborder.");
|
||||||
Functions.resetWorldborder(spawnWorld);
|
Worldborder.resetWorldborder(spawnWorld);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
int num,delay;
|
int num,delay;
|
||||||
|
@ -68,7 +68,7 @@ public class SetBorder implements ICommand {
|
||||||
addToSection("worldBorder",temp);
|
addToSection("worldBorder",temp);
|
||||||
sender.sendMessage(messagePrefix + "Set border center to current location, size to "+num+", and delay to "+delay);
|
sender.sendMessage(messagePrefix + "Set border center to current location, size to "+num+", and delay to "+delay);
|
||||||
saveConfig();
|
saveConfig();
|
||||||
Functions.resetWorldborder(spawnWorld);
|
Worldborder.resetWorldborder(spawnWorld);
|
||||||
}
|
}
|
||||||
|
|
||||||
public String getLabel() {
|
public String getLabel() {
|
||||||
|
|
|
@ -1,6 +1,6 @@
|
||||||
package net.tylermurphy.hideAndSeek.command;
|
package net.tylermurphy.hideAndSeek.command;
|
||||||
|
|
||||||
import static net.tylermurphy.hideAndSeek.Store.*;
|
import static net.tylermurphy.hideAndSeek.Config.*;
|
||||||
|
|
||||||
import java.util.HashMap;
|
import java.util.HashMap;
|
||||||
import java.util.Map;
|
import java.util.Map;
|
||||||
|
@ -9,7 +9,7 @@ import org.bukkit.command.CommandSender;
|
||||||
import org.bukkit.entity.Player;
|
import org.bukkit.entity.Player;
|
||||||
import org.bukkit.util.Vector;
|
import org.bukkit.util.Vector;
|
||||||
|
|
||||||
import net.tylermurphy.hideAndSeek.util.ICommand;
|
import net.tylermurphy.hideAndSeek.Main;
|
||||||
|
|
||||||
public class SetExitLocation implements ICommand {
|
public class SetExitLocation implements ICommand {
|
||||||
|
|
||||||
|
@ -19,7 +19,7 @@ public class SetExitLocation implements ICommand {
|
||||||
newExitPosition.setX(player.getLocation().getBlockX());
|
newExitPosition.setX(player.getLocation().getBlockX());
|
||||||
newExitPosition.setY(player.getLocation().getBlockY());
|
newExitPosition.setY(player.getLocation().getBlockY());
|
||||||
newExitPosition.setZ(player.getLocation().getBlockZ());
|
newExitPosition.setZ(player.getLocation().getBlockZ());
|
||||||
if(!status.equals("Standby")) {
|
if(!Main.plugin.status.equals("Standby")) {
|
||||||
sender.sendMessage(errorPrefix + "Game is currently in session");
|
sender.sendMessage(errorPrefix + "Game is currently in session");
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,6 +1,6 @@
|
||||||
package net.tylermurphy.hideAndSeek.command;
|
package net.tylermurphy.hideAndSeek.command;
|
||||||
|
|
||||||
import static net.tylermurphy.hideAndSeek.Store.*;
|
import static net.tylermurphy.hideAndSeek.Config.*;
|
||||||
|
|
||||||
import java.util.HashMap;
|
import java.util.HashMap;
|
||||||
import java.util.Map;
|
import java.util.Map;
|
||||||
|
@ -9,7 +9,7 @@ import org.bukkit.command.CommandSender;
|
||||||
import org.bukkit.entity.Player;
|
import org.bukkit.entity.Player;
|
||||||
import org.bukkit.util.Vector;
|
import org.bukkit.util.Vector;
|
||||||
|
|
||||||
import net.tylermurphy.hideAndSeek.util.ICommand;
|
import net.tylermurphy.hideAndSeek.Main;
|
||||||
|
|
||||||
public class SetLobbyLocation implements ICommand {
|
public class SetLobbyLocation implements ICommand {
|
||||||
|
|
||||||
|
@ -19,7 +19,7 @@ public class SetLobbyLocation implements ICommand {
|
||||||
newLobbyPosition.setX(player.getLocation().getBlockX());
|
newLobbyPosition.setX(player.getLocation().getBlockX());
|
||||||
newLobbyPosition.setY(player.getLocation().getBlockY());
|
newLobbyPosition.setY(player.getLocation().getBlockY());
|
||||||
newLobbyPosition.setZ(player.getLocation().getBlockZ());
|
newLobbyPosition.setZ(player.getLocation().getBlockZ());
|
||||||
if(!status.equals("Standby")) {
|
if(!Main.plugin.status.equals("Standby")) {
|
||||||
sender.sendMessage(errorPrefix + "Game is currently in session");
|
sender.sendMessage(errorPrefix + "Game is currently in session");
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,6 +1,6 @@
|
||||||
package net.tylermurphy.hideAndSeek.command;
|
package net.tylermurphy.hideAndSeek.command;
|
||||||
|
|
||||||
import static net.tylermurphy.hideAndSeek.Store.*;
|
import static net.tylermurphy.hideAndSeek.Config.*;
|
||||||
|
|
||||||
import java.util.HashMap;
|
import java.util.HashMap;
|
||||||
import java.util.Map;
|
import java.util.Map;
|
||||||
|
@ -9,7 +9,7 @@ import org.bukkit.command.CommandSender;
|
||||||
import org.bukkit.entity.Player;
|
import org.bukkit.entity.Player;
|
||||||
import org.bukkit.util.Vector;
|
import org.bukkit.util.Vector;
|
||||||
|
|
||||||
import net.tylermurphy.hideAndSeek.util.ICommand;
|
import net.tylermurphy.hideAndSeek.Main;
|
||||||
|
|
||||||
public class SetSpawnLocation implements ICommand {
|
public class SetSpawnLocation implements ICommand {
|
||||||
|
|
||||||
|
@ -19,7 +19,7 @@ public class SetSpawnLocation implements ICommand {
|
||||||
newSpawnPosition.setX(player.getLocation().getBlockX());
|
newSpawnPosition.setX(player.getLocation().getBlockX());
|
||||||
newSpawnPosition.setY(player.getLocation().getBlockY());
|
newSpawnPosition.setY(player.getLocation().getBlockY());
|
||||||
newSpawnPosition.setZ(player.getLocation().getBlockZ());
|
newSpawnPosition.setZ(player.getLocation().getBlockZ());
|
||||||
if(!status.equals("Standby")) {
|
if(!Main.plugin.status.equals("Standby")) {
|
||||||
sender.sendMessage(errorPrefix + "Game is currently in session");
|
sender.sendMessage(errorPrefix + "Game is currently in session");
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
|
@ -4,9 +4,8 @@ import org.bukkit.command.CommandSender;
|
||||||
|
|
||||||
import net.md_5.bungee.api.ChatColor;
|
import net.md_5.bungee.api.ChatColor;
|
||||||
import net.tylermurphy.hideAndSeek.Main;
|
import net.tylermurphy.hideAndSeek.Main;
|
||||||
import net.tylermurphy.hideAndSeek.util.ICommand;
|
|
||||||
|
|
||||||
import static net.tylermurphy.hideAndSeek.Store.*;
|
import static net.tylermurphy.hideAndSeek.Config.*;
|
||||||
|
|
||||||
import java.io.File;
|
import java.io.File;
|
||||||
|
|
||||||
|
|
|
@ -3,73 +3,75 @@ package net.tylermurphy.hideAndSeek.command;
|
||||||
import org.bukkit.Bukkit;
|
import org.bukkit.Bukkit;
|
||||||
import org.bukkit.GameMode;
|
import org.bukkit.GameMode;
|
||||||
import org.bukkit.Location;
|
import org.bukkit.Location;
|
||||||
|
import org.bukkit.Material;
|
||||||
import org.bukkit.command.CommandSender;
|
import org.bukkit.command.CommandSender;
|
||||||
|
import org.bukkit.enchantments.Enchantment;
|
||||||
import org.bukkit.entity.Player;
|
import org.bukkit.entity.Player;
|
||||||
|
import org.bukkit.inventory.ItemStack;
|
||||||
|
import org.bukkit.inventory.meta.ItemMeta;
|
||||||
|
import org.bukkit.inventory.meta.PotionMeta;
|
||||||
|
import org.bukkit.potion.PotionData;
|
||||||
import org.bukkit.potion.PotionEffect;
|
import org.bukkit.potion.PotionEffect;
|
||||||
import org.bukkit.potion.PotionEffectType;
|
import org.bukkit.potion.PotionEffectType;
|
||||||
|
import org.bukkit.potion.PotionType;
|
||||||
|
|
||||||
import net.md_5.bungee.api.ChatColor;
|
import net.md_5.bungee.api.ChatColor;
|
||||||
import net.tylermurphy.hideAndSeek.Main;
|
import net.tylermurphy.hideAndSeek.Main;
|
||||||
import net.tylermurphy.hideAndSeek.events.Glow;
|
import net.tylermurphy.hideAndSeek.events.Glow;
|
||||||
import net.tylermurphy.hideAndSeek.events.Taunt;
|
import net.tylermurphy.hideAndSeek.events.Taunt;
|
||||||
import net.tylermurphy.hideAndSeek.events.Worldborder;
|
import net.tylermurphy.hideAndSeek.events.Worldborder;
|
||||||
import net.tylermurphy.hideAndSeek.util.Functions;
|
import net.tylermurphy.hideAndSeek.util.Util;
|
||||||
import net.tylermurphy.hideAndSeek.util.ICommand;
|
|
||||||
|
|
||||||
import static net.tylermurphy.hideAndSeek.Store.*;
|
import static net.tylermurphy.hideAndSeek.Config.*;
|
||||||
|
|
||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
|
import java.util.List;
|
||||||
import java.util.Random;
|
import java.util.Random;
|
||||||
|
|
||||||
public class Start implements ICommand {
|
public class Start implements ICommand {
|
||||||
|
|
||||||
public void execute(CommandSender sender, String[] args) {
|
public void execute(CommandSender sender, String[] args) {
|
||||||
if(!Functions.setup()) {
|
if(!Util.isSetup()) {
|
||||||
sender.sendMessage(errorPrefix + "Game is not setup. Run /hs setup to see what you needed to do");
|
sender.sendMessage(errorPrefix + "Game is not setup. Run /hs setup to see what you needed to do");
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
if(!status.equals("Standby")) {
|
if(!Main.plugin.status.equals("Standby")) {
|
||||||
sender.sendMessage(errorPrefix + "Game is already in session");
|
sender.sendMessage(errorPrefix + "Game is already in session");
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
if(!playerList.containsKey(sender.getName())) {
|
if(!Main.plugin.board.isPlayer(sender)) {
|
||||||
sender.sendMessage(errorPrefix + "You are not in the lobby");
|
sender.sendMessage(errorPrefix + "You are not in the lobby");
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
if(playerList.size() < minPlayers) {
|
if(Main.plugin.board.size() < minPlayers) {
|
||||||
sender.sendMessage(errorPrefix + "You must have at least "+minPlayers+" players to start");
|
sender.sendMessage(errorPrefix + "You must have at least "+minPlayers+" players to start");
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
if(Bukkit.getServer().getWorld("hideandseek_"+spawnWorld) != null) {
|
if(Bukkit.getServer().getWorld("hideandseek_"+spawnWorld) != null) {
|
||||||
Functions.rollback("hideandseek_"+spawnWorld);
|
Util.rollback("hideandseek_"+spawnWorld);
|
||||||
} else {
|
} else {
|
||||||
Functions.loadMap("hideandseek_"+spawnWorld);
|
Util.loadMap("hideandseek_"+spawnWorld);
|
||||||
}
|
}
|
||||||
String seekerName;
|
String seekerName;
|
||||||
if(args.length < 1) {
|
if(args.length < 1) {
|
||||||
seekerName = playerList.values().stream().skip(new Random().nextInt(playerList.values().size())).findFirst().get().getName();
|
seekerName = Main.plugin.board.getPlayers().stream().skip(new Random().nextInt(Main.plugin.board.size())).findFirst().get().getName();
|
||||||
} else {
|
} else {
|
||||||
seekerName = args[0];
|
seekerName = args[0];
|
||||||
}
|
}
|
||||||
Player seeker = playerList.get(seekerName);
|
Player seeker = Main.plugin.board.getPlayer(seekerName);
|
||||||
if(seeker == null) {
|
if(seeker == null) {
|
||||||
sender.sendMessage(errorPrefix + "Invalid player: " + seekerName);
|
sender.sendMessage(errorPrefix + "Invalid player: " + seekerName);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
Hider = new ArrayList<String>();
|
Main.plugin.board.init();
|
||||||
Seeker = new ArrayList<String>();
|
for(Player temp : Main.plugin.board.getPlayers()) {
|
||||||
Spectator = new ArrayList<String>();
|
|
||||||
Deaths = new ArrayList<String>();
|
|
||||||
for(Player temp : playerList.values()) {
|
|
||||||
if(temp.getName().equals(seeker.getName()))
|
if(temp.getName().equals(seeker.getName()))
|
||||||
continue;
|
continue;
|
||||||
Hider.add(temp.getName());
|
Main.plugin.board.addHider(temp);
|
||||||
HiderTeam.addEntry(temp.getName());
|
|
||||||
}
|
}
|
||||||
Seeker.add(seeker.getName());
|
Main.plugin.board.addSeeker(seeker);
|
||||||
SeekerTeam.addEntry(seeker.getName());
|
|
||||||
currentWorldborderSize = worldborderSize;
|
currentWorldborderSize = worldborderSize;
|
||||||
for(Player player : playerList.values()) {
|
for(Player player : Main.plugin.board.getPlayers()) {
|
||||||
player.getInventory().clear();
|
player.getInventory().clear();
|
||||||
player.setGameMode(GameMode.ADVENTURE);
|
player.setGameMode(GameMode.ADVENTURE);
|
||||||
player.teleport(new Location(Bukkit.getWorld("hideandseek_"+spawnWorld), spawnPosition.getX(),spawnPosition.getY(),spawnPosition.getZ()));
|
player.teleport(new Location(Bukkit.getWorld("hideandseek_"+spawnWorld), spawnPosition.getX(),spawnPosition.getY(),spawnPosition.getZ()));
|
||||||
|
@ -77,94 +79,51 @@ public class Start implements ICommand {
|
||||||
player.removePotionEffect(effect.getType());
|
player.removePotionEffect(effect.getType());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
for(String playerName : Seeker) {
|
for(Player player : Main.plugin.board.getSeekers()) {
|
||||||
Player player = playerList.get(playerName);
|
player.addPotionEffect(new PotionEffect(PotionEffectType.BLINDNESS,1000000,127,false,false));
|
||||||
if(player != null) {
|
player.addPotionEffect(new PotionEffect(PotionEffectType.SLOW,1000000,127,false,false));
|
||||||
player.addPotionEffect(new PotionEffect(PotionEffectType.BLINDNESS,1000000,127,false,false));
|
player.sendTitle(ChatColor.RED + "" + ChatColor.BOLD + "SEEKER", ChatColor.WHITE + "Eliminate all hiders", 10, 70, 20);
|
||||||
player.addPotionEffect(new PotionEffect(PotionEffectType.SLOW,1000000,127,false,false));
|
|
||||||
player.sendTitle(ChatColor.RED + "" + ChatColor.BOLD + "SEEKER", ChatColor.WHITE + "Eliminate all hiders", 10, 70, 20);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
for(String playerName : Hider) {
|
for(Player player : Main.plugin.board.getHiders()) {
|
||||||
Player player = playerList.get(playerName);
|
player.addPotionEffect(new PotionEffect(PotionEffectType.SPEED,1000000,5,false,false));
|
||||||
if(player != null) {
|
player.sendTitle(ChatColor.GOLD + "" + ChatColor.BOLD + "HIDER", ChatColor.WHITE + "Hide away from the seekers", 10, 70, 20);
|
||||||
player.addPotionEffect(new PotionEffect(PotionEffectType.SPEED,1000000,5,false,false));
|
|
||||||
player.sendTitle(ChatColor.GOLD + "" + ChatColor.BOLD + "HIDER", ChatColor.WHITE + "Hide away from the seekers", 10, 70, 20);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
Functions.resetWorldborder("hideandseek_"+spawnWorld);
|
Worldborder.resetWorldborder("hideandseek_"+spawnWorld);
|
||||||
status = "Starting";
|
Main.plugin.status = "Starting";
|
||||||
int temp = gameId;
|
int temp = Main.plugin.gameId;
|
||||||
Functions.broadcastMessage(messagePrefix + "Hiders have 30 seconds to hide!");
|
Util.broadcastMessage(messagePrefix + "Hiders have 30 seconds to hide!");
|
||||||
|
Util.sendDelayedMessage(messagePrefix + "Hiders have 20 seconds to hide!", Main.plugin.gameId, 20 * 10);
|
||||||
|
Util.sendDelayedMessage(messagePrefix + "Hiders have 10 seconds to hide!", Main.plugin.gameId, 20 * 20);
|
||||||
|
Util.sendDelayedMessage(messagePrefix + "Hiders have 5 seconds to hide!", Main.plugin.gameId, 20 * 25);
|
||||||
|
Util.sendDelayedMessage(messagePrefix + "Hiders have 3 seconds to hide!", Main.plugin.gameId, 20 * 27);
|
||||||
|
Util.sendDelayedMessage(messagePrefix + "Hiders have 2 seconds to hide!", Main.plugin.gameId, 20 * 28);
|
||||||
|
Util.sendDelayedMessage(messagePrefix + "Hiders have 1 seconds to hide!", Main.plugin.gameId, 20 * 29);
|
||||||
Bukkit.getServer().getScheduler().runTaskLater(Main.plugin, new Runnable() {
|
Bukkit.getServer().getScheduler().runTaskLater(Main.plugin, new Runnable() {
|
||||||
public void run() {
|
public void run() {
|
||||||
if(temp != gameId) return;
|
if(temp != Main.plugin.gameId) return;
|
||||||
Functions.broadcastMessage(messagePrefix + "Hiders have 20 seconds to hide!");
|
Util.broadcastMessage(messagePrefix + "Attetion SEEKERS, its time to find the hiders!");
|
||||||
}
|
Main.plugin.status = "Playing";
|
||||||
}, 20 * 10);
|
for(Player player : Main.plugin.board.getPlayers()) {
|
||||||
|
resetPlayer(player);
|
||||||
Bukkit.getServer().getScheduler().runTaskLater(Main.plugin, new Runnable() {
|
|
||||||
public void run() {
|
|
||||||
if(temp != gameId) return;
|
|
||||||
Functions.broadcastMessage(messagePrefix + "Hiders have 10 seconds to hide!");
|
|
||||||
}
|
|
||||||
}, 20 * 20);
|
|
||||||
|
|
||||||
Bukkit.getServer().getScheduler().runTaskLater(Main.plugin, new Runnable() {
|
|
||||||
public void run() {
|
|
||||||
if(temp != gameId) return;
|
|
||||||
Functions.broadcastMessage(messagePrefix + "Hiders have 5 seconds to hide!");
|
|
||||||
}
|
|
||||||
}, 20 * 25);
|
|
||||||
|
|
||||||
Bukkit.getServer().getScheduler().runTaskLater(Main.plugin, new Runnable() {
|
|
||||||
public void run() {
|
|
||||||
if(temp != gameId) return;
|
|
||||||
Functions.broadcastMessage(messagePrefix + "Hiders have 3 seconds to hide!");
|
|
||||||
}
|
|
||||||
}, 20 * 27);
|
|
||||||
|
|
||||||
Bukkit.getServer().getScheduler().runTaskLater(Main.plugin, new Runnable() {
|
|
||||||
public void run() {
|
|
||||||
if(temp != gameId) return;
|
|
||||||
Functions.broadcastMessage(messagePrefix + "Hiders have 2 seconds to hide!");
|
|
||||||
}
|
|
||||||
}, 20 * 28);
|
|
||||||
|
|
||||||
Bukkit.getServer().getScheduler().runTaskLater(Main.plugin, new Runnable() {
|
|
||||||
public void run() {
|
|
||||||
if(temp != gameId) return;
|
|
||||||
Functions.broadcastMessage(messagePrefix + "Hiders have 1 seconds to hide!");
|
|
||||||
}
|
|
||||||
}, 20 * 29);
|
|
||||||
|
|
||||||
Bukkit.getServer().getScheduler().runTaskLater(Main.plugin, new Runnable() {
|
|
||||||
public void run() {
|
|
||||||
if(temp != gameId) return;
|
|
||||||
Functions.broadcastMessage(messagePrefix + "Attetion SEEKERS, its time to find the hiders!");
|
|
||||||
status = "Playing";
|
|
||||||
for(Player player : playerList.values()) {
|
|
||||||
Functions.resetPlayer(player);
|
|
||||||
}
|
}
|
||||||
Main.worldborder = null;
|
Main.plugin.worldborder = null;
|
||||||
Main.taunt = null;
|
Main.plugin.taunt = null;
|
||||||
Main.glow = null;
|
Main.plugin.glow = null;
|
||||||
|
|
||||||
if(worldborderEnabled) {
|
if(worldborderEnabled) {
|
||||||
Main.worldborder = new Worldborder(gameId);
|
Main.plugin.worldborder = new Worldborder(Main.plugin.gameId);
|
||||||
Main.worldborder.schedule();
|
Main.plugin.worldborder.schedule();
|
||||||
}
|
}
|
||||||
|
|
||||||
Main.taunt = new Taunt(gameId);
|
Main.plugin.taunt = new Taunt(Main.plugin.gameId);
|
||||||
Main.taunt.schedule();
|
Main.plugin.taunt.schedule();
|
||||||
|
|
||||||
Main.glow = new Glow(gameId);
|
Main.plugin.glow = new Glow(Main.plugin.gameId);
|
||||||
|
|
||||||
if(gameLength > 0) {
|
if(gameLength > 0) {
|
||||||
timeLeft = gameLength;
|
Main.plugin.timeLeft = gameLength;
|
||||||
for(Player player : playerList.values()) {
|
for(Player player : Main.plugin.board.getPlayers()) {
|
||||||
player.setLevel(timeLeft);
|
player.setLevel(gameLength);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -172,6 +131,69 @@ public class Start implements ICommand {
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public static void resetPlayer(Player player) {
|
||||||
|
player.getInventory().clear();
|
||||||
|
for(PotionEffect effect : player.getActivePotionEffects()){
|
||||||
|
player.removePotionEffect(effect.getType());
|
||||||
|
}
|
||||||
|
player.addPotionEffect(new PotionEffect(PotionEffectType.DOLPHINS_GRACE, 1000000, 1, false, false));
|
||||||
|
if(Main.plugin.board.isSeeker(player)){
|
||||||
|
ItemStack diamondSword = new ItemStack(Material.DIAMOND_SWORD,1);
|
||||||
|
diamondSword.addEnchantment(Enchantment.DAMAGE_ALL, 1);
|
||||||
|
ItemMeta diamondSwordMeta = diamondSword.getItemMeta();
|
||||||
|
diamondSwordMeta.setDisplayName("Seeker Sword");
|
||||||
|
diamondSwordMeta.setUnbreakable(true);
|
||||||
|
diamondSword.setItemMeta(diamondSwordMeta);
|
||||||
|
player.getInventory().addItem(diamondSword);
|
||||||
|
|
||||||
|
ItemStack wackyStick = new ItemStack(Material.STICK,1);
|
||||||
|
wackyStick.addUnsafeEnchantment(Enchantment.KNOCKBACK, 3);
|
||||||
|
ItemMeta wackyStickMeta = wackyStick.getItemMeta();
|
||||||
|
wackyStickMeta.setDisplayName("Wacky Stick");
|
||||||
|
wackyStick.setItemMeta(wackyStickMeta);
|
||||||
|
player.getInventory().addItem(wackyStick);
|
||||||
|
|
||||||
|
player.addPotionEffect(new PotionEffect(PotionEffectType.SPEED, 1000000, 2, false, false));
|
||||||
|
player.addPotionEffect(new PotionEffect(PotionEffectType.JUMP, 1000000, 1, false, false));
|
||||||
|
player.addPotionEffect(new PotionEffect(PotionEffectType.SLOW_FALLING, 1000000, 1, false, false));
|
||||||
|
player.addPotionEffect(new PotionEffect(PotionEffectType.WATER_BREATHING, 1000000, 10, false, false));
|
||||||
|
}
|
||||||
|
else if(Main.plugin.board.isHider(player)){
|
||||||
|
ItemStack stoneSword = new ItemStack(Material.STONE_SWORD,1);
|
||||||
|
stoneSword.addEnchantment(Enchantment.DAMAGE_ALL, 2);
|
||||||
|
ItemMeta stoneSwordMeta = stoneSword.getItemMeta();
|
||||||
|
stoneSwordMeta.setDisplayName("Hider Sword");
|
||||||
|
stoneSwordMeta.setUnbreakable(true);
|
||||||
|
stoneSword.setItemMeta(stoneSwordMeta);
|
||||||
|
player.getInventory().addItem(stoneSword);
|
||||||
|
|
||||||
|
ItemStack splashPotion = new ItemStack(Material.SPLASH_POTION,1);
|
||||||
|
PotionMeta splashPotionMeta = (PotionMeta) splashPotion.getItemMeta();
|
||||||
|
splashPotionMeta.setBasePotionData(new PotionData(PotionType.REGEN));
|
||||||
|
splashPotion.setItemMeta(splashPotionMeta);
|
||||||
|
player.getInventory().addItem(splashPotion);
|
||||||
|
|
||||||
|
ItemStack potion = new ItemStack(Material.POTION,2);
|
||||||
|
PotionMeta potionMeta = (PotionMeta) potion.getItemMeta();
|
||||||
|
potionMeta.setBasePotionData(new PotionData(PotionType.INSTANT_HEAL));
|
||||||
|
potion.setItemMeta(potionMeta);
|
||||||
|
player.getInventory().addItem(potion);
|
||||||
|
|
||||||
|
ItemStack snowball = new ItemStack(Material.SNOWBALL,1);
|
||||||
|
ItemMeta snowballMeta = snowball.getItemMeta();
|
||||||
|
snowballMeta.setDisplayName("Glow Powerup");
|
||||||
|
List<String> snowballLore = new ArrayList<String>();
|
||||||
|
snowballLore.add("Throw to make all seekers glow");
|
||||||
|
snowballLore.add("Last 30s, all hiders can see it");
|
||||||
|
snowballLore.add("Time stacks on multi use");
|
||||||
|
snowballMeta.setLore(snowballLore);
|
||||||
|
snowball.setItemMeta(snowballMeta);
|
||||||
|
player.getInventory().addItem(snowball);
|
||||||
|
|
||||||
|
player.addPotionEffect(new PotionEffect(PotionEffectType.WATER_BREATHING, 1000000, 1, false, false));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
public String getLabel() {
|
public String getLabel() {
|
||||||
return "start";
|
return "start";
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,6 +1,6 @@
|
||||||
package net.tylermurphy.hideAndSeek.command;
|
package net.tylermurphy.hideAndSeek.command;
|
||||||
|
|
||||||
import static net.tylermurphy.hideAndSeek.Store.*;
|
import static net.tylermurphy.hideAndSeek.Config.*;
|
||||||
|
|
||||||
import org.bukkit.Bukkit;
|
import org.bukkit.Bukkit;
|
||||||
import org.bukkit.GameMode;
|
import org.bukkit.GameMode;
|
||||||
|
@ -10,20 +10,21 @@ import org.bukkit.entity.Player;
|
||||||
import org.bukkit.potion.PotionEffect;
|
import org.bukkit.potion.PotionEffect;
|
||||||
import org.bukkit.potion.PotionEffectType;
|
import org.bukkit.potion.PotionEffectType;
|
||||||
|
|
||||||
import net.tylermurphy.hideAndSeek.util.Functions;
|
import net.tylermurphy.hideAndSeek.Main;
|
||||||
import net.tylermurphy.hideAndSeek.util.ICommand;
|
import net.tylermurphy.hideAndSeek.events.Worldborder;
|
||||||
import net.tylermurphy.hideAndSeek.util.Packet;
|
import net.tylermurphy.hideAndSeek.util.Packet;
|
||||||
|
import net.tylermurphy.hideAndSeek.util.Util;
|
||||||
|
|
||||||
public class Stop implements ICommand {
|
public class Stop implements ICommand {
|
||||||
|
|
||||||
public void execute(CommandSender sender, String[] args) {
|
public void execute(CommandSender sender, String[] args) {
|
||||||
if(!Functions.setup()) {
|
if(!Util.isSetup()) {
|
||||||
sender.sendMessage(errorPrefix + "Game is not setup. Run /hs setup to see what you needed to do");
|
sender.sendMessage(errorPrefix + "Game is not setup. Run /hs setup to see what you needed to do");
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
if(status.equals("Starting") || status.equals("Playing")) {
|
if(Main.plugin.status.equals("Starting") || Main.plugin.status.equals("Playing")) {
|
||||||
if(announceMessagesToNonPlayers) Bukkit.broadcastMessage(abortPrefix + "Game has been force stopped.");
|
if(announceMessagesToNonPlayers) Bukkit.broadcastMessage(abortPrefix + "Game has been force stopped.");
|
||||||
else Functions.broadcastMessage(abortPrefix + "Game has been force stopped.");
|
else Util.broadcastMessage(abortPrefix + "Game has been force stopped.");
|
||||||
onStop();
|
onStop();
|
||||||
|
|
||||||
} else {
|
} else {
|
||||||
|
@ -37,26 +38,25 @@ public class Stop implements ICommand {
|
||||||
}
|
}
|
||||||
|
|
||||||
public static void onStop() {
|
public static void onStop() {
|
||||||
if(status.equals("Standby")) return;
|
if(Main.plugin.status.equals("Standby")) return;
|
||||||
status = "Standby";
|
Main.plugin.status = "Standby";
|
||||||
gameId++;
|
Main.plugin.gameId++;
|
||||||
Functions.resetWorldborder("hideandseek_"+spawnWorld);
|
Worldborder.resetWorldborder("hideandseek_"+spawnWorld);
|
||||||
for(Player player : playerList.values()) {
|
for(Player player : Main.plugin.board.getPlayers()) {
|
||||||
player.setGameMode(GameMode.ADVENTURE);
|
player.setGameMode(GameMode.ADVENTURE);
|
||||||
player.setLevel(0);
|
player.setLevel(0);
|
||||||
Hider.add(player.getName());
|
Main.plugin.board.addHider(player);
|
||||||
HiderTeam.addEntry(player.getName());
|
|
||||||
player.getInventory().clear();
|
player.getInventory().clear();
|
||||||
player.teleport(new Location(Bukkit.getWorld(lobbyWorld), lobbyPosition.getX(),lobbyPosition.getY(),lobbyPosition.getZ()));
|
player.teleport(new Location(Bukkit.getWorld(lobbyWorld), lobbyPosition.getX(),lobbyPosition.getY(),lobbyPosition.getZ()));
|
||||||
for(PotionEffect effect : player.getActivePotionEffects()){
|
for(PotionEffect effect : player.getActivePotionEffects()){
|
||||||
player.removePotionEffect(effect.getType());
|
player.removePotionEffect(effect.getType());
|
||||||
}
|
}
|
||||||
player.addPotionEffect(new PotionEffect(PotionEffectType.HEAL, 1, 100));
|
player.addPotionEffect(new PotionEffect(PotionEffectType.HEAL, 1, 100));
|
||||||
for(Player temp : playerList.values()) {
|
for(Player temp : Main.plugin.board.getPlayers()) {
|
||||||
Packet.setGlow(player, temp, false);
|
Packet.setGlow(player, temp, false);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
Functions.unloadMap("hideandseek_"+spawnWorld);
|
Util.unloadMap("hideandseek_"+spawnWorld);
|
||||||
}
|
}
|
||||||
|
|
||||||
public String getUsage() {
|
public String getUsage() {
|
||||||
|
|
|
@ -1,7 +1,5 @@
|
||||||
package net.tylermurphy.hideAndSeek.events;
|
package net.tylermurphy.hideAndSeek.events;
|
||||||
|
|
||||||
import static net.tylermurphy.hideAndSeek.Store.*;
|
|
||||||
|
|
||||||
import org.bukkit.Bukkit;
|
import org.bukkit.Bukkit;
|
||||||
import org.bukkit.entity.Player;
|
import org.bukkit.entity.Player;
|
||||||
|
|
||||||
|
@ -27,12 +25,8 @@ public class Glow {
|
||||||
|
|
||||||
private void startGlow() {
|
private void startGlow() {
|
||||||
running = true;
|
running = true;
|
||||||
for(String hiderName : Hider) {
|
for(Player hider : Main.plugin.board.getHiders()) {
|
||||||
Player hider = playerList.get(hiderName);
|
for(Player seeker : Main.plugin.board.getSeekers()) {
|
||||||
if(hider == null) continue;
|
|
||||||
for(String seekerName : Seeker) {
|
|
||||||
Player seeker = playerList.get(seekerName);
|
|
||||||
if(seeker == null) continue;
|
|
||||||
Packet.setGlow(hider, seeker, true);
|
Packet.setGlow(hider, seeker, true);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -42,7 +36,7 @@ public class Glow {
|
||||||
private void waitGlow() {
|
private void waitGlow() {
|
||||||
Bukkit.getServer().getScheduler().scheduleSyncDelayedTask(Main.plugin, new Runnable() {
|
Bukkit.getServer().getScheduler().scheduleSyncDelayedTask(Main.plugin, new Runnable() {
|
||||||
public void run() {
|
public void run() {
|
||||||
if(temp != gameId) return;
|
if(temp != Main.plugin.gameId) return;
|
||||||
glowTime--;
|
glowTime--;
|
||||||
glowTime = Math.max(glowTime, 0);
|
glowTime = Math.max(glowTime, 0);
|
||||||
if(glowTime == 0) {
|
if(glowTime == 0) {
|
||||||
|
@ -55,12 +49,8 @@ public class Glow {
|
||||||
}
|
}
|
||||||
|
|
||||||
private void stopGlow() {
|
private void stopGlow() {
|
||||||
for(String hiderName : Hider) {
|
for(Player hider : Main.plugin.board.getHiders()) {
|
||||||
Player hider = playerList.get(hiderName);
|
for(Player seeker : Main.plugin.board.getSeekers()) {
|
||||||
if(hider == null) continue;
|
|
||||||
for(String seekerName : Seeker) {
|
|
||||||
Player seeker = playerList.get(seekerName);
|
|
||||||
if(seeker == null) continue;
|
|
||||||
Packet.setGlow(hider, seeker, false);
|
Packet.setGlow(hider, seeker, false);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,6 +1,6 @@
|
||||||
package net.tylermurphy.hideAndSeek.events;
|
package net.tylermurphy.hideAndSeek.events;
|
||||||
|
|
||||||
import static net.tylermurphy.hideAndSeek.Store.*;
|
import static net.tylermurphy.hideAndSeek.Config.*;
|
||||||
|
|
||||||
import org.bukkit.Bukkit;
|
import org.bukkit.Bukkit;
|
||||||
import org.bukkit.ChatColor;
|
import org.bukkit.ChatColor;
|
||||||
|
@ -12,7 +12,7 @@ import org.bukkit.entity.Player;
|
||||||
import org.bukkit.inventory.meta.FireworkMeta;
|
import org.bukkit.inventory.meta.FireworkMeta;
|
||||||
|
|
||||||
import net.tylermurphy.hideAndSeek.Main;
|
import net.tylermurphy.hideAndSeek.Main;
|
||||||
import net.tylermurphy.hideAndSeek.util.Functions;
|
import net.tylermurphy.hideAndSeek.util.Util;
|
||||||
|
|
||||||
public class Taunt {
|
public class Taunt {
|
||||||
|
|
||||||
|
@ -40,7 +40,7 @@ public class Taunt {
|
||||||
}
|
}
|
||||||
|
|
||||||
private void tryTaunt() {
|
private void tryTaunt() {
|
||||||
if(temp != gameId) return;
|
if(temp != Main.plugin.gameId) return;
|
||||||
if(Math.random() > .8) {
|
if(Math.random() > .8) {
|
||||||
executeTaunt();
|
executeTaunt();
|
||||||
} else {
|
} else {
|
||||||
|
@ -54,9 +54,9 @@ public class Taunt {
|
||||||
|
|
||||||
private void executeTaunt() {
|
private void executeTaunt() {
|
||||||
Player taunted = null;
|
Player taunted = null;
|
||||||
int rand = (int) (Math.random()*Hider.size());
|
int rand = (int) (Math.random()*Main.plugin.board.sizeHider());
|
||||||
for(Player player : playerList.values()) {
|
for(Player player : Main.plugin.board.getPlayers()) {
|
||||||
if(Hider.contains(player.getName())) {
|
if(Main.plugin.board.isHider(player)) {
|
||||||
rand--;
|
rand--;
|
||||||
if(rand==0) {
|
if(rand==0) {
|
||||||
taunted = player;
|
taunted = player;
|
||||||
|
@ -66,12 +66,12 @@ public class Taunt {
|
||||||
}
|
}
|
||||||
if(taunted != null) {
|
if(taunted != null) {
|
||||||
taunted.sendMessage(ChatColor.RED + "" + ChatColor.ITALIC + "Oh no! You have been chosed to be taunted.");
|
taunted.sendMessage(ChatColor.RED + "" + ChatColor.ITALIC + "Oh no! You have been chosed to be taunted.");
|
||||||
Functions.broadcastMessage(tauntPrefix + " A random hider will be taunted in the next 30s");
|
Util.broadcastMessage(tauntPrefix + " A random hider will be taunted in the next 30s");
|
||||||
tauntPlayer = taunted.getName();
|
tauntPlayer = taunted.getName();
|
||||||
Bukkit.getServer().getScheduler().scheduleSyncDelayedTask(Main.plugin, new Runnable() {
|
Bukkit.getServer().getScheduler().scheduleSyncDelayedTask(Main.plugin, new Runnable() {
|
||||||
public void run() {
|
public void run() {
|
||||||
if(temp != gameId) return;
|
if(temp != Main.plugin.gameId) return;
|
||||||
Player taunted = playerList.get(tauntPlayer);
|
Player taunted = Main.plugin.board.getPlayer(tauntPlayer);
|
||||||
if(taunted != null) {
|
if(taunted != null) {
|
||||||
Firework fw = (Firework) taunted.getLocation().getWorld().spawnEntity(taunted.getLocation(), EntityType.FIREWORK);
|
Firework fw = (Firework) taunted.getLocation().getWorld().spawnEntity(taunted.getLocation(), EntityType.FIREWORK);
|
||||||
FireworkMeta fwm = fw.getFireworkMeta();
|
FireworkMeta fwm = fw.getFireworkMeta();
|
||||||
|
@ -87,7 +87,7 @@ public class Taunt {
|
||||||
.withTrail()
|
.withTrail()
|
||||||
.build());
|
.build());
|
||||||
fw.setFireworkMeta(fwm);
|
fw.setFireworkMeta(fwm);
|
||||||
Functions.broadcastMessage(tauntPrefix + " Taunt has been activated");
|
Util.broadcastMessage(tauntPrefix + " Taunt has been activated");
|
||||||
}
|
}
|
||||||
tauntPlayer = "";
|
tauntPlayer = "";
|
||||||
waitTaunt();
|
waitTaunt();
|
||||||
|
|
|
@ -5,9 +5,9 @@ import org.bukkit.World;
|
||||||
import org.bukkit.WorldBorder;
|
import org.bukkit.WorldBorder;
|
||||||
|
|
||||||
import net.tylermurphy.hideAndSeek.Main;
|
import net.tylermurphy.hideAndSeek.Main;
|
||||||
import net.tylermurphy.hideAndSeek.util.Functions;
|
import net.tylermurphy.hideAndSeek.util.Util;
|
||||||
|
|
||||||
import static net.tylermurphy.hideAndSeek.Store.*;
|
import static net.tylermurphy.hideAndSeek.Config.*;
|
||||||
|
|
||||||
public class Worldborder {
|
public class Worldborder {
|
||||||
|
|
||||||
|
@ -26,9 +26,9 @@ public class Worldborder {
|
||||||
}
|
}
|
||||||
|
|
||||||
private void decreaceWorldborder() {
|
private void decreaceWorldborder() {
|
||||||
if(temp != gameId) return;
|
if(temp != Main.plugin.gameId) return;
|
||||||
if(currentWorldborderSize-100 > 100) {
|
if(currentWorldborderSize-100 > 100) {
|
||||||
Functions.broadcastMessage(worldborderPrefix + "Worldborder decreacing by 100 blocks over the next 30s");
|
Util.broadcastMessage(worldborderPrefix + "Worldborder decreacing by 100 blocks over the next 30s");
|
||||||
currentWorldborderSize -= 100;
|
currentWorldborderSize -= 100;
|
||||||
World world = Bukkit.getWorld("hideandseek_"+spawnWorld);
|
World world = Bukkit.getWorld("hideandseek_"+spawnWorld);
|
||||||
WorldBorder border = world.getWorldBorder();
|
WorldBorder border = world.getWorldBorder();
|
||||||
|
@ -41,4 +41,19 @@ public class Worldborder {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public static void resetWorldborder(String worldName) {
|
||||||
|
if(worldborderEnabled) {
|
||||||
|
World world = Bukkit.getWorld(worldName);
|
||||||
|
WorldBorder border = world.getWorldBorder();
|
||||||
|
border.setSize(worldborderSize);
|
||||||
|
border.setCenter(worldborderPosition.getX(), worldborderPosition.getZ());
|
||||||
|
currentWorldborderSize = worldborderSize;
|
||||||
|
} else {
|
||||||
|
World world = Bukkit.getWorld(worldName);
|
||||||
|
WorldBorder border = world.getWorldBorder();
|
||||||
|
border.setSize(30000000);
|
||||||
|
border.setCenter(0, 0);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
178
src/main/java/net/tylermurphy/hideAndSeek/util/Board.java
Normal file
178
src/main/java/net/tylermurphy/hideAndSeek/util/Board.java
Normal file
|
@ -0,0 +1,178 @@
|
||||||
|
package net.tylermurphy.hideAndSeek.util;
|
||||||
|
|
||||||
|
import java.util.ArrayList;
|
||||||
|
import java.util.HashMap;
|
||||||
|
import java.util.List;
|
||||||
|
import java.util.Map;
|
||||||
|
import java.util.stream.Collectors;
|
||||||
|
|
||||||
|
import org.bukkit.Bukkit;
|
||||||
|
import org.bukkit.ChatColor;
|
||||||
|
import org.bukkit.command.CommandSender;
|
||||||
|
import org.bukkit.entity.Player;
|
||||||
|
import org.bukkit.scoreboard.Scoreboard;
|
||||||
|
import org.bukkit.scoreboard.ScoreboardManager;
|
||||||
|
import org.bukkit.scoreboard.Team;
|
||||||
|
import org.bukkit.scoreboard.Team.Option;
|
||||||
|
import org.bukkit.scoreboard.Team.OptionStatus;
|
||||||
|
|
||||||
|
import static net.tylermurphy.hideAndSeek.Config.*;
|
||||||
|
|
||||||
|
public class Board {
|
||||||
|
|
||||||
|
private Team HiderTeam, SeekerTeam, SpectatorTeam;
|
||||||
|
private List<String> Hider, Seeker, Spectator;
|
||||||
|
private Map<String, Player> playerList = new HashMap<String,Player>();
|
||||||
|
|
||||||
|
private boolean setup = false;
|
||||||
|
|
||||||
|
public boolean isReady() {
|
||||||
|
return setup;
|
||||||
|
}
|
||||||
|
|
||||||
|
public boolean isPlayer(Player player) {
|
||||||
|
return playerList.containsKey(player.getName());
|
||||||
|
}
|
||||||
|
|
||||||
|
public boolean isPlayer(CommandSender sender) {
|
||||||
|
return playerList.containsKey(sender.getName());
|
||||||
|
}
|
||||||
|
|
||||||
|
public boolean isHider(Player player) {
|
||||||
|
return Hider.contains(player.getName());
|
||||||
|
}
|
||||||
|
|
||||||
|
public boolean isSeeker(Player player) {
|
||||||
|
return Seeker.contains(player.getName());
|
||||||
|
}
|
||||||
|
|
||||||
|
public boolean isSpectator(Player player) {
|
||||||
|
return Spectator.contains(player.getName());
|
||||||
|
}
|
||||||
|
|
||||||
|
public int sizeHider() {
|
||||||
|
return Hider.size();
|
||||||
|
}
|
||||||
|
|
||||||
|
public int sizeSeeker() {
|
||||||
|
return Seeker.size();
|
||||||
|
}
|
||||||
|
|
||||||
|
public int sizeSpectator() {
|
||||||
|
return Spectator.size();
|
||||||
|
}
|
||||||
|
|
||||||
|
public int size() {
|
||||||
|
return playerList.size();
|
||||||
|
}
|
||||||
|
|
||||||
|
public List<Player> getHiders(){
|
||||||
|
return Hider.stream().map(playerName -> playerList.get(playerName)).collect(Collectors.toList());
|
||||||
|
}
|
||||||
|
|
||||||
|
public List<Player> getSeekers(){
|
||||||
|
return Seeker.stream().map(playerName -> playerList.get(playerName)).collect(Collectors.toList());
|
||||||
|
}
|
||||||
|
|
||||||
|
public List<Player> getSpectators(){
|
||||||
|
return Spectator.stream().map(playerName -> playerList.get(playerName)).collect(Collectors.toList());
|
||||||
|
}
|
||||||
|
|
||||||
|
public List<Player> getPlayers(){
|
||||||
|
return new ArrayList<Player>(playerList.values());
|
||||||
|
}
|
||||||
|
|
||||||
|
public Player getPlayer(String name) {
|
||||||
|
return playerList.get(name);
|
||||||
|
}
|
||||||
|
|
||||||
|
public void addHider(Player player) {
|
||||||
|
Hider.add(player.getName());
|
||||||
|
Seeker.remove(player.getName());
|
||||||
|
Spectator.remove(player.getName());
|
||||||
|
HiderTeam.addEntry(player.getName());
|
||||||
|
if(!playerList.containsKey(player.getName()))
|
||||||
|
playerList.put(player.getName(), player);
|
||||||
|
}
|
||||||
|
|
||||||
|
public void addSeeker(Player player) {
|
||||||
|
Hider.remove(player.getName());
|
||||||
|
Seeker.add(player.getName());
|
||||||
|
Spectator.remove(player.getName());
|
||||||
|
SeekerTeam.addEntry(player.getName());
|
||||||
|
if(!playerList.containsKey(player.getName()))
|
||||||
|
playerList.put(player.getName(), player);
|
||||||
|
}
|
||||||
|
|
||||||
|
public void addSpectator(Player player) {
|
||||||
|
Hider.remove(player.getName());
|
||||||
|
Seeker.remove(player.getName());
|
||||||
|
Spectator.add(player.getName());
|
||||||
|
SpectatorTeam.addEntry(player.getName());
|
||||||
|
if(!playerList.containsKey(player.getName()))
|
||||||
|
playerList.put(player.getName(), player);
|
||||||
|
}
|
||||||
|
|
||||||
|
public void remove(Player player) {
|
||||||
|
Hider.remove(player.getName());
|
||||||
|
Seeker.remove(player.getName());
|
||||||
|
Spectator.remove(player.getName());
|
||||||
|
HiderTeam.removeEntry(player.getName());
|
||||||
|
SeekerTeam.removeEntry(player.getName());
|
||||||
|
SpectatorTeam.removeEntry(player.getName());
|
||||||
|
playerList.remove(player.getName());
|
||||||
|
}
|
||||||
|
|
||||||
|
public boolean onSameTeam(Player player1, Player player2) {
|
||||||
|
if(Hider.contains(player1.getName()) && Hider.contains(player2.getName())) return true;
|
||||||
|
else if(Seeker.contains(player1.getName()) && Seeker.contains(player2.getName())) return true;
|
||||||
|
else if(Spectator.contains(player1.getName()) && Spectator.contains(player2.getName())) return true;
|
||||||
|
else return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void init() {
|
||||||
|
Hider = new ArrayList<String>();
|
||||||
|
Seeker = new ArrayList<String>();
|
||||||
|
Spectator = new ArrayList<String>();
|
||||||
|
reload();
|
||||||
|
}
|
||||||
|
|
||||||
|
public void reload() {
|
||||||
|
|
||||||
|
ScoreboardManager manager = Bukkit.getScoreboardManager();
|
||||||
|
if(manager == null) return;
|
||||||
|
Scoreboard board = manager.getMainScoreboard();
|
||||||
|
|
||||||
|
try { board.registerNewTeam("Seeker"); } catch(Exception e) {}
|
||||||
|
SeekerTeam = board.getTeam("Seeker");
|
||||||
|
SeekerTeam.setColor(ChatColor.RED);
|
||||||
|
if(nametagsVisible) SeekerTeam.setOption(Option.NAME_TAG_VISIBILITY, OptionStatus.FOR_OTHER_TEAMS);
|
||||||
|
else SeekerTeam.setOption(Option.NAME_TAG_VISIBILITY, OptionStatus.NEVER);
|
||||||
|
|
||||||
|
try { board.registerNewTeam("Hider"); } catch(Exception e) {}
|
||||||
|
HiderTeam = board.getTeam("Hider");
|
||||||
|
HiderTeam.setColor(ChatColor.GOLD);
|
||||||
|
if(nametagsVisible) HiderTeam.setOption(Option.NAME_TAG_VISIBILITY, OptionStatus.FOR_OWN_TEAM);
|
||||||
|
else HiderTeam.setOption(Option.NAME_TAG_VISIBILITY, OptionStatus.NEVER);
|
||||||
|
|
||||||
|
try { board.registerNewTeam("Spectator"); } catch(Exception e) {}
|
||||||
|
SpectatorTeam = board.getTeam("Spectator");
|
||||||
|
SpectatorTeam.setColor(ChatColor.GRAY);
|
||||||
|
SpectatorTeam.setOption(Option.NAME_TAG_VISIBILITY, OptionStatus.NEVER);
|
||||||
|
|
||||||
|
setup = true;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void reset() {
|
||||||
|
Hider.clear();
|
||||||
|
Seeker.clear();
|
||||||
|
Spectator.clear();
|
||||||
|
for(String entry : HiderTeam.getEntries())
|
||||||
|
HiderTeam.removeEntry(entry);
|
||||||
|
for(String entry : SeekerTeam.getEntries())
|
||||||
|
SeekerTeam.removeEntry(entry);
|
||||||
|
for(String entry : SpectatorTeam.getEntries())
|
||||||
|
SpectatorTeam.removeEntry(entry);
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
|
@ -1,184 +0,0 @@
|
||||||
package net.tylermurphy.hideAndSeek.util;
|
|
||||||
|
|
||||||
import static net.tylermurphy.hideAndSeek.Store.*;
|
|
||||||
|
|
||||||
import java.io.File;
|
|
||||||
import java.util.ArrayList;
|
|
||||||
import java.util.List;
|
|
||||||
|
|
||||||
import org.bukkit.Bukkit;
|
|
||||||
import org.bukkit.ChatColor;
|
|
||||||
import org.bukkit.Material;
|
|
||||||
import org.bukkit.World;
|
|
||||||
import org.bukkit.WorldBorder;
|
|
||||||
import org.bukkit.WorldCreator;
|
|
||||||
import org.bukkit.enchantments.Enchantment;
|
|
||||||
import org.bukkit.entity.Player;
|
|
||||||
import org.bukkit.inventory.ItemStack;
|
|
||||||
import org.bukkit.inventory.meta.ItemMeta;
|
|
||||||
import org.bukkit.inventory.meta.PotionMeta;
|
|
||||||
import org.bukkit.potion.PotionData;
|
|
||||||
import org.bukkit.potion.PotionEffect;
|
|
||||||
import org.bukkit.potion.PotionEffectType;
|
|
||||||
import org.bukkit.potion.PotionType;
|
|
||||||
import org.bukkit.scoreboard.Scoreboard;
|
|
||||||
import org.bukkit.scoreboard.ScoreboardManager;
|
|
||||||
import org.bukkit.scoreboard.Team.Option;
|
|
||||||
import org.bukkit.scoreboard.Team.OptionStatus;
|
|
||||||
|
|
||||||
import net.tylermurphy.hideAndSeek.Main;
|
|
||||||
|
|
||||||
public class Functions {
|
|
||||||
|
|
||||||
public static void resetPlayer(Player player) {
|
|
||||||
player.getInventory().clear();
|
|
||||||
for(PotionEffect effect : player.getActivePotionEffects()){
|
|
||||||
player.removePotionEffect(effect.getType());
|
|
||||||
}
|
|
||||||
player.addPotionEffect(new PotionEffect(PotionEffectType.DOLPHINS_GRACE, 1000000, 1, false, false));
|
|
||||||
if(Seeker.contains(player.getName())){
|
|
||||||
ItemStack diamondSword = new ItemStack(Material.DIAMOND_SWORD,1);
|
|
||||||
diamondSword.addEnchantment(Enchantment.DAMAGE_ALL, 1);
|
|
||||||
ItemMeta diamondSwordMeta = diamondSword.getItemMeta();
|
|
||||||
diamondSwordMeta.setDisplayName("Seeker Sword");
|
|
||||||
diamondSwordMeta.setUnbreakable(true);
|
|
||||||
diamondSword.setItemMeta(diamondSwordMeta);
|
|
||||||
player.getInventory().addItem(diamondSword);
|
|
||||||
|
|
||||||
ItemStack wackyStick = new ItemStack(Material.STICK,1);
|
|
||||||
wackyStick.addUnsafeEnchantment(Enchantment.KNOCKBACK, 3);
|
|
||||||
ItemMeta wackyStickMeta = wackyStick.getItemMeta();
|
|
||||||
wackyStickMeta.setDisplayName("Wacky Stick");
|
|
||||||
wackyStick.setItemMeta(wackyStickMeta);
|
|
||||||
player.getInventory().addItem(wackyStick);
|
|
||||||
|
|
||||||
player.addPotionEffect(new PotionEffect(PotionEffectType.SPEED, 1000000, 2, false, false));
|
|
||||||
player.addPotionEffect(new PotionEffect(PotionEffectType.JUMP, 1000000, 1, false, false));
|
|
||||||
player.addPotionEffect(new PotionEffect(PotionEffectType.SLOW_FALLING, 1000000, 1, false, false));
|
|
||||||
player.addPotionEffect(new PotionEffect(PotionEffectType.WATER_BREATHING, 1000000, 10, false, false));
|
|
||||||
}
|
|
||||||
else if(Hider.contains(player.getName())){
|
|
||||||
ItemStack stoneSword = new ItemStack(Material.STONE_SWORD,1);
|
|
||||||
stoneSword.addEnchantment(Enchantment.DAMAGE_ALL, 2);
|
|
||||||
ItemMeta stoneSwordMeta = stoneSword.getItemMeta();
|
|
||||||
stoneSwordMeta.setDisplayName("Hider Sword");
|
|
||||||
stoneSwordMeta.setUnbreakable(true);
|
|
||||||
stoneSword.setItemMeta(stoneSwordMeta);
|
|
||||||
player.getInventory().addItem(stoneSword);
|
|
||||||
|
|
||||||
ItemStack splashPotion = new ItemStack(Material.SPLASH_POTION,1);
|
|
||||||
PotionMeta splashPotionMeta = (PotionMeta) splashPotion.getItemMeta();
|
|
||||||
splashPotionMeta.setBasePotionData(new PotionData(PotionType.REGEN));
|
|
||||||
splashPotion.setItemMeta(splashPotionMeta);
|
|
||||||
player.getInventory().addItem(splashPotion);
|
|
||||||
|
|
||||||
ItemStack potion = new ItemStack(Material.POTION,2);
|
|
||||||
PotionMeta potionMeta = (PotionMeta) potion.getItemMeta();
|
|
||||||
potionMeta.setBasePotionData(new PotionData(PotionType.INSTANT_HEAL));
|
|
||||||
potion.setItemMeta(potionMeta);
|
|
||||||
player.getInventory().addItem(potion);
|
|
||||||
|
|
||||||
ItemStack snowball = new ItemStack(Material.SNOWBALL,1);
|
|
||||||
ItemMeta snowballMeta = snowball.getItemMeta();
|
|
||||||
snowballMeta.setDisplayName("Glow Powerup");
|
|
||||||
List<String> snowballLore = new ArrayList<String>();
|
|
||||||
snowballLore.add("Throw to make all seekers glow");
|
|
||||||
snowballLore.add("Last 30s, all hiders can see it");
|
|
||||||
snowballLore.add("Time stacks on multi use");
|
|
||||||
snowballMeta.setLore(snowballLore);
|
|
||||||
snowball.setItemMeta(snowballMeta);
|
|
||||||
player.getInventory().addItem(snowball);
|
|
||||||
|
|
||||||
player.addPotionEffect(new PotionEffect(PotionEffectType.WATER_BREATHING, 1000000, 1, false, false));
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
public static void resetWorldborder(String worldName) {
|
|
||||||
if(worldborderEnabled) {
|
|
||||||
World world = Bukkit.getWorld(worldName);
|
|
||||||
WorldBorder border = world.getWorldBorder();
|
|
||||||
border.setSize(worldborderSize);
|
|
||||||
border.setCenter(worldborderPosition.getX(), worldborderPosition.getZ());
|
|
||||||
currentWorldborderSize = worldborderSize;
|
|
||||||
} else {
|
|
||||||
World world = Bukkit.getWorld(worldName);
|
|
||||||
WorldBorder border = world.getWorldBorder();
|
|
||||||
border.setSize(30000000);
|
|
||||||
border.setCenter(0, 0);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
public static void unloadMap(String mapname){
|
|
||||||
if(Bukkit.getServer().unloadWorld(Bukkit.getServer().getWorld(mapname), false)){
|
|
||||||
Main.plugin.getLogger().info("Successfully unloaded " + mapname);
|
|
||||||
}else{
|
|
||||||
Main.plugin.getLogger().severe("COULD NOT UNLOAD " + mapname);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
public static void loadMap(String mapname){
|
|
||||||
Bukkit.getServer().createWorld(new WorldCreator(mapname));
|
|
||||||
Bukkit.getServer().getWorld("hideandseek_"+spawnWorld).setAutoSave(false);
|
|
||||||
}
|
|
||||||
|
|
||||||
public static void rollback(String mapname){
|
|
||||||
unloadMap(mapname);
|
|
||||||
loadMap(mapname);
|
|
||||||
}
|
|
||||||
|
|
||||||
public static void loadScoreboard() {
|
|
||||||
|
|
||||||
ScoreboardManager manager = Bukkit.getScoreboardManager();
|
|
||||||
Scoreboard mainBoard = manager.getMainScoreboard();
|
|
||||||
|
|
||||||
try { mainBoard.registerNewTeam("Seeker");} catch(Exception e) {}
|
|
||||||
SeekerTeam = mainBoard.getTeam("Seeker");
|
|
||||||
SeekerTeam.setColor(ChatColor.RED);
|
|
||||||
if(nametagsVisible)
|
|
||||||
SeekerTeam.setOption(Option.NAME_TAG_VISIBILITY, OptionStatus.FOR_OTHER_TEAMS);
|
|
||||||
else
|
|
||||||
SeekerTeam.setOption(Option.NAME_TAG_VISIBILITY, OptionStatus.NEVER);
|
|
||||||
|
|
||||||
try { mainBoard.registerNewTeam("Hider");} catch(Exception e) {}
|
|
||||||
HiderTeam = mainBoard.getTeam("Hider");
|
|
||||||
HiderTeam.setColor(ChatColor.GOLD);
|
|
||||||
if(nametagsVisible)
|
|
||||||
HiderTeam.setOption(Option.NAME_TAG_VISIBILITY, OptionStatus.FOR_OWN_TEAM);
|
|
||||||
else
|
|
||||||
HiderTeam.setOption(Option.NAME_TAG_VISIBILITY, OptionStatus.NEVER);
|
|
||||||
|
|
||||||
try { mainBoard.registerNewTeam("Spectator");} catch(Exception e) {}
|
|
||||||
SpectatorTeam = mainBoard.getTeam("Spectator");
|
|
||||||
SpectatorTeam.setColor(ChatColor.GRAY);
|
|
||||||
SpectatorTeam.setOption(Option.NAME_TAG_VISIBILITY, OptionStatus.NEVER);
|
|
||||||
|
|
||||||
board = mainBoard;
|
|
||||||
}
|
|
||||||
|
|
||||||
public static void broadcastMessage(String message) {
|
|
||||||
for(Player player : playerList.values()) {
|
|
||||||
player.sendMessage(message);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
public static boolean setup() {
|
|
||||||
|
|
||||||
if(spawnPosition.getBlockX() == 0 && spawnPosition.getBlockY() == 0 && spawnPosition.getBlockZ() == 0) {
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
if(lobbyPosition.getBlockX() == 0 && lobbyPosition.getBlockY() == 0 && lobbyPosition.getBlockZ() == 0) {
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
if(exitPosition.getBlockX() == 0 && exitPosition.getBlockY() == 0 && exitPosition.getBlockZ() == 0) {
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
File destenation = new File(Main.root+File.separator+"hideandseek_"+spawnWorld);
|
|
||||||
if(!destenation.exists()) {
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
|
|
||||||
return true;
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
|
57
src/main/java/net/tylermurphy/hideAndSeek/util/Util.java
Normal file
57
src/main/java/net/tylermurphy/hideAndSeek/util/Util.java
Normal file
|
@ -0,0 +1,57 @@
|
||||||
|
package net.tylermurphy.hideAndSeek.util;
|
||||||
|
|
||||||
|
import static net.tylermurphy.hideAndSeek.Config.*;
|
||||||
|
|
||||||
|
import java.io.File;
|
||||||
|
|
||||||
|
import org.bukkit.Bukkit;
|
||||||
|
import org.bukkit.WorldCreator;
|
||||||
|
import org.bukkit.entity.Player;
|
||||||
|
|
||||||
|
import net.tylermurphy.hideAndSeek.Main;
|
||||||
|
|
||||||
|
public class Util {
|
||||||
|
|
||||||
|
public static void broadcastMessage(String message) {
|
||||||
|
for(Player player : Main.plugin.board.getPlayers()) {
|
||||||
|
player.sendMessage(message);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public static boolean isSetup() {
|
||||||
|
if(spawnPosition.getBlockX() == 0 && spawnPosition.getBlockY() == 0 && spawnPosition.getBlockZ() == 0) return false;
|
||||||
|
if(lobbyPosition.getBlockX() == 0 && lobbyPosition.getBlockY() == 0 && lobbyPosition.getBlockZ() == 0) return false;
|
||||||
|
if(exitPosition.getBlockX() == 0 && exitPosition.getBlockY() == 0 && exitPosition.getBlockZ() == 0) return false;
|
||||||
|
File destenation = new File(Main.root+File.separator+"hideandseek_"+spawnWorld);
|
||||||
|
if(!destenation.exists()) return false;
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
public static void unloadMap(String mapname){
|
||||||
|
if(Bukkit.getServer().unloadWorld(Bukkit.getServer().getWorld(mapname), false)){
|
||||||
|
Main.plugin.getLogger().info("Successfully unloaded " + mapname);
|
||||||
|
}else{
|
||||||
|
Main.plugin.getLogger().severe("COULD NOT UNLOAD " + mapname);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public static void loadMap(String mapname){
|
||||||
|
Bukkit.getServer().createWorld(new WorldCreator(mapname));
|
||||||
|
Bukkit.getServer().getWorld("hideandseek_"+spawnWorld).setAutoSave(false);
|
||||||
|
}
|
||||||
|
|
||||||
|
public static void rollback(String mapname){
|
||||||
|
unloadMap(mapname);
|
||||||
|
loadMap(mapname);
|
||||||
|
}
|
||||||
|
|
||||||
|
public static void sendDelayedMessage(String message, int gameId, int delay) {
|
||||||
|
Bukkit.getScheduler().runTaskLaterAsynchronously(Main.plugin, new Runnable() {
|
||||||
|
public void run() {
|
||||||
|
if(gameId == Main.plugin.gameId)
|
||||||
|
Util.broadcastMessage(messagePrefix + "Hiders have 1 seconds to hide!");
|
||||||
|
}
|
||||||
|
}, delay);
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
Loading…
Reference in a new issue