1.3.0 beta 5

This commit is contained in:
Tyler Murphy 2021-08-31 21:55:27 -04:00
parent d04d86f60f
commit f1379a9475
19 changed files with 452 additions and 295 deletions

View file

@ -12,15 +12,27 @@ import org.bukkit.command.CommandSender;
import org.bukkit.entity.Player; 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 net.tylermurphy.hideAndSeek.events.EventListener; import net.tylermurphy.hideAndSeek.bukkit.CommandHandler;
import net.tylermurphy.hideAndSeek.events.EventTick; import net.tylermurphy.hideAndSeek.bukkit.EventListener;
import net.tylermurphy.hideAndSeek.bukkit.TabCompleter;
import net.tylermurphy.hideAndSeek.bukkit.Tick;
import net.tylermurphy.hideAndSeek.events.Glow;
import net.tylermurphy.hideAndSeek.events.Taunt;
import net.tylermurphy.hideAndSeek.events.Worldborder;
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 static Glow glow;
public static Worldborder worldborder;
private BukkitTask onTickTask;
public void onEnable() { public void onEnable() {
plugin = this; plugin = this;
@ -41,10 +53,10 @@ public class Main extends JavaPlugin implements Listener {
root = this.getServer().getWorldContainer(); root = this.getServer().getWorldContainer();
// Start Tick Timer // Start Tick Timer
Bukkit.getServer().getScheduler().runTaskTimer(this, new Runnable(){ onTickTask = Bukkit.getServer().getScheduler().runTaskTimer(this, new Runnable(){
public void run(){ public void run(){
try{ try{
EventTick.onTick(); Tick.onTick();
} catch (Exception e) { } catch (Exception e) {
e.printStackTrace(); e.printStackTrace();
} }
@ -53,12 +65,16 @@ public class Main extends JavaPlugin implements Listener {
} }
public void onDisable() {
onTickTask.cancel();
}
public boolean onCommand(CommandSender sender, Command cmd, String label, String[] args) { public boolean onCommand(CommandSender sender, Command cmd, String label, String[] args) {
return CommandHandler.handleCommand(sender, cmd, label, args); return CommandHandler.handleCommand(sender, cmd, label, args);
} }
public List<String> onTabComplete(CommandSender sender, Command command, String label, String[] args) { public List<String> onTabComplete(CommandSender sender, Command command, String label, String[] args) {
return CommandTabCompleter.handleTabComplete(sender, command, label, args); return TabCompleter.handleTabComplete(sender, command, label, args);
} }
} }

View file

@ -18,13 +18,18 @@ public class Store {
public static Map<String,Player> public static Map<String,Player>
playerList = new HashMap<String,Player>(); playerList = new HashMap<String,Player>();
public static List<String>
Hider,
Seeker,
Spectator;
public static Scoreboard public static Scoreboard
board; board;
public static Team public static Team
Hider, HiderTeam,
Seeker, SeekerTeam,
Spectator; SpectatorTeam;
public static String public static String
messagePrefix, messagePrefix,
@ -35,8 +40,7 @@ public class Store {
gameoverPrefix, gameoverPrefix,
warningPrefix, warningPrefix,
spawnWorld, spawnWorld,
status = "Standby", status = "Standby";
tauntPlayer = "";
public static Vector public static Vector
spawnPosition, spawnPosition,
@ -57,12 +61,10 @@ public class Store {
interactableTrapdoors, interactableTrapdoors,
interactableFencegate, interactableFencegate,
worldborderEnabled = false, worldborderEnabled = false,
decreaseBorder = false,
runningBackup = false; runningBackup = false;
public static int public static int
minPlayers, minPlayers,
glowTime = 0,
gameId = 0, gameId = 0,
worldborderSize, worldborderSize,
worldborderDelay, worldborderDelay,
@ -128,6 +130,7 @@ public class Store {
worldborderDelay = Math.max(1,getConfig().getInt("worldBorder.delay")); worldborderDelay = Math.max(1,getConfig().getInt("worldBorder.delay"));
worldborderEnabled = getConfig().getBoolean("worldBorder.enabled"); worldborderEnabled = getConfig().getBoolean("worldBorder.enabled");
blockedCommands = getConfig().getStringList("blockedCommands"); blockedCommands = getConfig().getStringList("blockedCommands");
blockedCommands.add("team");
//Prefix //Prefix
char SYMBOLE = '\u00A7'; char SYMBOLE = '\u00A7';

View file

@ -1,4 +1,4 @@
package net.tylermurphy.hideAndSeek; package net.tylermurphy.hideAndSeek.bukkit;
import static net.tylermurphy.hideAndSeek.Store.*; import static net.tylermurphy.hideAndSeek.Store.*;
@ -10,7 +10,7 @@ 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.commands.*; import net.tylermurphy.hideAndSeek.command.*;
import net.tylermurphy.hideAndSeek.util.ICommand; import net.tylermurphy.hideAndSeek.util.ICommand;
public class CommandHandler { public class CommandHandler {

View file

@ -1,4 +1,4 @@
package net.tylermurphy.hideAndSeek.events; package net.tylermurphy.hideAndSeek.bukkit;
import static net.tylermurphy.hideAndSeek.Store.*; import static net.tylermurphy.hideAndSeek.Store.*;
@ -26,6 +26,7 @@ import org.bukkit.event.player.PlayerCommandPreprocessEvent;
import org.bukkit.event.player.PlayerInteractEntityEvent; import org.bukkit.event.player.PlayerInteractEntityEvent;
import org.bukkit.event.player.PlayerInteractEvent; import org.bukkit.event.player.PlayerInteractEvent;
import org.bukkit.event.player.PlayerJoinEvent; import org.bukkit.event.player.PlayerJoinEvent;
import org.bukkit.event.player.PlayerKickEvent;
import org.bukkit.event.player.PlayerQuitEvent; import org.bukkit.event.player.PlayerQuitEvent;
import org.bukkit.potion.PotionEffect; import org.bukkit.potion.PotionEffect;
@ -39,7 +40,8 @@ public class EventListener implements Listener {
@EventHandler @EventHandler
public void onPlayerJoin(PlayerJoinEvent event) { public void onPlayerJoin(PlayerJoinEvent event) {
if(status.equals("Playing") || status.equals("Starting")) { if(status.equals("Playing") || status.equals("Starting")) {
Spectator.addEntry(event.getPlayer().getName()); Spectator.add(event.getPlayer().getName());
SpectatorTeam.addEntry(event.getPlayer().getName());
event.getPlayer().sendMessage(messagePrefix + "You have joined mid game, and thus have been placed on the spectator team."); event.getPlayer().sendMessage(messagePrefix + "You have joined mid game, and thus have been placed on the spectator team.");
event.getPlayer().setGameMode(GameMode.SPECTATOR); event.getPlayer().setGameMode(GameMode.SPECTATOR);
event.getPlayer().getInventory().clear(); event.getPlayer().getInventory().clear();
@ -48,7 +50,8 @@ public class EventListener implements Listener {
} }
event.getPlayer().teleport(new Location(Bukkit.getWorld("hideandseek_"+spawnWorld), spawnPosition.getX(),spawnPosition.getY(),spawnPosition.getZ())); event.getPlayer().teleport(new Location(Bukkit.getWorld("hideandseek_"+spawnWorld), spawnPosition.getX(),spawnPosition.getY(),spawnPosition.getZ()));
} else if(status.equals("Setup") || status.equals("Standby")) { } else if(status.equals("Setup") || status.equals("Standby")) {
Hider.addEntry(event.getPlayer().getName()); Hider.add(event.getPlayer().getName());
HiderTeam.addEntry(event.getPlayer().getName());
event.getPlayer().setGameMode(GameMode.ADVENTURE); event.getPlayer().setGameMode(GameMode.ADVENTURE);
event.getPlayer().teleport(new Location(Bukkit.getWorld(spawnWorld), spawnPosition.getX(),spawnPosition.getY(),spawnPosition.getZ())); event.getPlayer().teleport(new Location(Bukkit.getWorld(spawnWorld), spawnPosition.getX(),spawnPosition.getY(),spawnPosition.getZ()));
} }
@ -57,10 +60,26 @@ public class EventListener implements Listener {
@EventHandler @EventHandler
public void onQuit(PlayerQuitEvent event) { public void onQuit(PlayerQuitEvent event) {
if(!playerList.containsKey(event.getPlayer().getName())) return;
playerList.remove(event.getPlayer().getName()); playerList.remove(event.getPlayer().getName());
Hider.removeEntry(event.getPlayer().getName()); Hider.remove(event.getPlayer().getName());
Seeker.removeEntry(event.getPlayer().getName()); HiderTeam.removeEntry(event.getPlayer().getName());
Spectator.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
public void onKick(PlayerKickEvent event) {
if(!playerList.containsKey(event.getPlayer().getName())) return;
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
@ -77,13 +96,15 @@ 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(Hider.hasEntry(event.getEntity().getName())) { if(Hider.contains(event.getEntity().getName())) {
Bukkit.broadcastMessage(String.format(messagePrefix + "%s%s%s has died and became a seeker", ChatColor.GOLD, event.getEntity().getName(), ChatColor.WHITE)); Bukkit.broadcastMessage(String.format(messagePrefix + "%s%s%s was found and became a seeker", ChatColor.GOLD, event.getEntity().getName(), ChatColor.WHITE));
} }
if(Seeker.hasEntry(event.getEntity().getName())) { if(Seeker.contains(event.getEntity().getName())) {
Bukkit.broadcastMessage(String.format(messagePrefix + "%s%s%s has been beat by a hider", ChatColor.RED, event.getEntity().getName(), ChatColor.WHITE)); Bukkit.broadcastMessage(String.format(messagePrefix + "%s%s%s was killed", ChatColor.RED, event.getEntity().getName(), ChatColor.WHITE));
} }
Seeker.addEntry(player.getName()); Seeker.add(player.getName());
Hider.remove(player.getName());
SeekerTeam.addEntry(player.getName());
Functions.resetPlayer(player); Functions.resetPlayer(player);
for(Player temp : playerList.values()) { for(Player temp : playerList.values()) {
Packet.setGlow(player, temp, false); Packet.setGlow(player, temp, false);
@ -218,17 +239,10 @@ public class EventListener implements Listener {
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.hasEntry(player.getName())) { if(Hider.contains(player.getName())) {
glowTime++; Main.glow.onProjectilve();
snowball.remove(); snowball.remove();
player.getInventory().remove(Material.SNOWBALL); player.getInventory().remove(Material.SNOWBALL);
int temp = gameId;
Bukkit.getServer().getScheduler().runTaskLater(Main.plugin, new Runnable() {
public void run() {
if(temp != gameId) return;
glowTime--;
}
}, 20 * 30);
} }
} }
} }

View file

@ -1,4 +1,4 @@
package net.tylermurphy.hideAndSeek; package net.tylermurphy.hideAndSeek.bukkit;
import java.util.ArrayList; import java.util.ArrayList;
import java.util.List; import java.util.List;
@ -7,7 +7,7 @@ import java.util.stream.Collectors;
import org.bukkit.command.Command; import org.bukkit.command.Command;
import org.bukkit.command.CommandSender; import org.bukkit.command.CommandSender;
public class CommandTabCompleter{ public class TabCompleter{
public static List<String> handleTabComplete(CommandSender sender, Command command, String label, String[] args) { public static List<String> handleTabComplete(CommandSender sender, Command command, String label, String[] args) {
if(args.length == 1) { if(args.length == 1) {

View file

@ -0,0 +1,81 @@
package net.tylermurphy.hideAndSeek.bukkit;
import static net.tylermurphy.hideAndSeek.Store.*;
import org.bukkit.Bukkit;
import org.bukkit.Location;
import org.bukkit.Sound;
import org.bukkit.entity.Player;
import net.tylermurphy.hideAndSeek.command.Stop;
import net.tylermurphy.hideAndSeek.util.Functions;
import net.tylermurphy.hideAndSeek.util.Packet;
public class Tick {
static int tick = 0;
public static void onTick() {
if(board == null) {
Functions.loadScoreboard();
}
if(status.equals("Starting")) {
onStarting();
} else if(status.equals("Playing")) {
onPlaying();
}
tick ++;
if(( status.equals("Starting") || status.equals("Playing") ) && Hider.size() < 1) {
Bukkit.broadcastMessage(gameoverPrefix + "All hiders have been found.");
Stop.onStop();
}
if(( status.equals("Starting") || status.equals("Playing") ) && Seeker.size() < 1) {
Bukkit.broadcastMessage(abortPrefix + "All seekers have quit.");
Stop.onStop();
}
}
private static void onStarting() {
for(String playerName : Seeker) {
Player player = playerList.get(playerName);
if(player != null) {
player.teleport(new Location(Bukkit.getWorld("hideandseek_"+spawnWorld), spawnPosition.getX(),spawnPosition.getY(),spawnPosition.getZ()));
}
}
}
private static void onPlaying() {
for(String playerName : Hider) {
Player player = playerList.get(playerName);
int distance = 100;
for(String seekerName : Seeker) {
Player seeker = playerList.get(seekerName);
int temp = (int) player.getLocation().distance(seeker.getLocation());
if(distance > temp) {
distance = temp;
}
}
switch(tick%10) {
case 0:
if(distance < 30) Packet.playSound(player, Sound.BLOCK_NOTE_BLOCK_BASEDRUM, .5f, 1f);
if(distance < 10) Packet.playSound(player, Sound.BLOCK_NOTE_BLOCK_BIT, .3f, 1f);
break;
case 3:
if(distance < 30) Packet.playSound(player, Sound.BLOCK_NOTE_BLOCK_BASEDRUM, .3f, 1f);
if(distance < 10) Packet.playSound(player, Sound.BLOCK_NOTE_BLOCK_BIT, .3f, 1f);
break;
case 6:
if(distance < 10) Packet.playSound(player, Sound.BLOCK_NOTE_BLOCK_BIT, .3f, 1f);
break;
case 9:
if(distance < 20) Packet.playSound(player, Sound.BLOCK_NOTE_BLOCK_BIT, .3f, 1f);
break;
}
}
}
}

View file

@ -1,4 +1,4 @@
package net.tylermurphy.hideAndSeek.commands; package net.tylermurphy.hideAndSeek.command;
import org.bukkit.ChatColor; import org.bukkit.ChatColor;
import org.bukkit.command.CommandSender; import org.bukkit.command.CommandSender;

View file

@ -1,9 +1,9 @@
package net.tylermurphy.hideAndSeek.commands; package net.tylermurphy.hideAndSeek.command;
import org.bukkit.command.CommandSender; import org.bukkit.command.CommandSender;
import net.md_5.bungee.api.ChatColor; import net.md_5.bungee.api.ChatColor;
import net.tylermurphy.hideAndSeek.CommandHandler; import net.tylermurphy.hideAndSeek.bukkit.CommandHandler;
import net.tylermurphy.hideAndSeek.util.ICommand; import net.tylermurphy.hideAndSeek.util.ICommand;
public class Help implements ICommand { public class Help implements ICommand {

View file

@ -1,8 +1,9 @@
package net.tylermurphy.hideAndSeek.commands; package net.tylermurphy.hideAndSeek.command;
import org.bukkit.command.CommandSender; import org.bukkit.command.CommandSender;
import net.tylermurphy.hideAndSeek.Store; import net.tylermurphy.hideAndSeek.Store;
import net.tylermurphy.hideAndSeek.util.Functions;
import net.tylermurphy.hideAndSeek.util.ICommand; import net.tylermurphy.hideAndSeek.util.ICommand;
import static net.tylermurphy.hideAndSeek.Store.*; import static net.tylermurphy.hideAndSeek.Store.*;
@ -11,6 +12,9 @@ public class Reload implements ICommand {
public void execute(CommandSender sender, String[] args) { public void execute(CommandSender sender, String[] args) {
Store.loadConfig(); Store.loadConfig();
try {
Functions.loadScoreboard();
} catch(Exception e) {}
sender.sendMessage(messagePrefix + "Reloaded the config"); sender.sendMessage(messagePrefix + "Reloaded the config");
} }

View file

@ -1,4 +1,4 @@
package net.tylermurphy.hideAndSeek.commands; package net.tylermurphy.hideAndSeek.command;
import static net.tylermurphy.hideAndSeek.Store.*; import static net.tylermurphy.hideAndSeek.Store.*;

View file

@ -1,4 +1,4 @@
package net.tylermurphy.hideAndSeek.commands; package net.tylermurphy.hideAndSeek.command;
import static net.tylermurphy.hideAndSeek.Store.*; import static net.tylermurphy.hideAndSeek.Store.*;
@ -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(); Functions.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(); Functions.resetWorldborder(spawnWorld);
} }
public String getLabel() { public String getLabel() {

View file

@ -1,4 +1,4 @@
package net.tylermurphy.hideAndSeek.commands; package net.tylermurphy.hideAndSeek.command;
import static net.tylermurphy.hideAndSeek.Store.*; import static net.tylermurphy.hideAndSeek.Store.*;

View file

@ -1,7 +1,6 @@
package net.tylermurphy.hideAndSeek.commands; package net.tylermurphy.hideAndSeek.command;
import org.bukkit.Bukkit; import org.bukkit.Bukkit;
import org.bukkit.ChatColor;
import org.bukkit.GameMode; import org.bukkit.GameMode;
import org.bukkit.Location; import org.bukkit.Location;
import org.bukkit.command.CommandSender; import org.bukkit.command.CommandSender;
@ -10,12 +9,16 @@ import org.bukkit.potion.PotionEffect;
import org.bukkit.potion.PotionEffectType; import org.bukkit.potion.PotionEffectType;
import net.tylermurphy.hideAndSeek.Main; import net.tylermurphy.hideAndSeek.Main;
import net.tylermurphy.hideAndSeek.events.Glow;
import net.tylermurphy.hideAndSeek.events.Taunt;
import net.tylermurphy.hideAndSeek.events.Worldborder;
import net.tylermurphy.hideAndSeek.util.Functions; import net.tylermurphy.hideAndSeek.util.Functions;
import net.tylermurphy.hideAndSeek.util.ICommand; import net.tylermurphy.hideAndSeek.util.ICommand;
import static net.tylermurphy.hideAndSeek.Store.*; import static net.tylermurphy.hideAndSeek.Store.*;
import java.io.File; import java.io.File;
import java.util.ArrayList;
import java.util.Random; import java.util.Random;
public class Start implements ICommand { public class Start implements ICommand {
@ -55,10 +58,17 @@ public class Start implements ICommand {
sender.sendMessage(errorPrefix + "Invalid player: " + seekerName); sender.sendMessage(errorPrefix + "Invalid player: " + seekerName);
return; return;
} }
Hider = new ArrayList<String>();
Seeker = new ArrayList<String>();
Spectator = new ArrayList<String>();
for(Player temp : playerList.values()) { for(Player temp : playerList.values()) {
Hider.addEntry(temp.getName()); if(temp.getName().equals(seeker.getName()))
continue;
Hider.add(temp.getName());
HiderTeam.addEntry(temp.getName());
} }
Seeker.addEntry(seeker.getName()); Seeker.add(seeker.getName());
SeekerTeam.addEntry(seeker.getName());
for(Player player : playerList.values()) { for(Player player : playerList.values()) {
player.getInventory().clear(); player.getInventory().clear();
@ -68,21 +78,20 @@ public class Start implements ICommand {
player.removePotionEffect(effect.getType()); player.removePotionEffect(effect.getType());
} }
} }
//Bukkit.getServer().dispatchCommand(Bukkit.getConsoleSender(), String.format("spawnpoint @a %s %s %s", spawnPosition.getBlockX(), spawnPosition.getBlockY(), spawnPosition.getBlockZ())); for(String playerName : Seeker) {
for(String playerName : Seeker.getEntries()) {
Player player = playerList.get(playerName); Player player = playerList.get(playerName);
if(player != null) { if(player != null) {
player.addPotionEffect(new PotionEffect(PotionEffectType.BLINDNESS,1000000,127,false,false)); player.addPotionEffect(new PotionEffect(PotionEffectType.BLINDNESS,1000000,127,false,false));
player.addPotionEffect(new PotionEffect(PotionEffectType.SLOW,1000000,127,false,false)); player.addPotionEffect(new PotionEffect(PotionEffectType.SLOW,1000000,127,false,false));
} }
} }
for(String playerName : Hider.getEntries()) { for(String playerName : Hider) {
Player player = playerList.get(playerName); Player player = playerList.get(playerName);
if(player != null) { if(player != null) {
player.addPotionEffect(new PotionEffect(PotionEffectType.SPEED,1000000,5,false,false)); player.addPotionEffect(new PotionEffect(PotionEffectType.SPEED,1000000,5,false,false));
} }
} }
Functions.resetWorldborder(); Functions.resetWorldborder("hideandseek_"+spawnWorld);
status = "Starting"; status = "Starting";
int temp = gameId; int temp = gameId;
Bukkit.getServer().broadcastMessage(messagePrefix + "Hiders have 30 seconds to hide!"); Bukkit.getServer().broadcastMessage(messagePrefix + "Hiders have 30 seconds to hide!");
@ -137,75 +146,24 @@ public class Start implements ICommand {
for(Player player : playerList.values()) { for(Player player : playerList.values()) {
Functions.resetPlayer(player); Functions.resetPlayer(player);
} }
Main.worldborder = null;
Main.taunt = null;
Main.glow = null;
if(worldborderEnabled) {
Main.worldborder = new Worldborder(gameId);
Main.worldborder.schedule();
}
Main.taunt = new Taunt(gameId);
Main.taunt.schedule();
Main.glow = new Glow(gameId);
} }
}, 20 * 30); }, 20 * 30);
if(worldborderEnabled) {
scheduleWorldborder();
}
scheduleTaunt();
} }
private static void scheduleTaunt() {
Bukkit.getServer().getScheduler().runTaskAsynchronously(Main.plugin, new Runnable(){
public void run() {
int temp = gameId;
while(true) {
if(tauntPlayer != null && !tauntPlayer.equals("")) {
try { Thread.sleep(1000); } catch (InterruptedException e) {}
if(gameId != temp) break;
continue;
}
try { Thread.sleep(1000*60); } catch (InterruptedException e) {}
if(gameId != temp) break;
if(Math.random() > .8) {
Player taunted = null;
int rand = (int) (Math.random()*Hider.getEntries().size());
for(Player player : playerList.values()) {
if(Hider.hasEntry(player.getName())) {
rand--;
if(rand==0) {
taunted = player;
break;
}
}
}
if(taunted != null) {
taunted.sendMessage(ChatColor.RED + "" + ChatColor.ITALIC + "Oh no! You have been chosed to be taunted.");
Bukkit.getServer().broadcastMessage(tauntPrefix + " A random hider will be taunted in the next 30s");
try { Thread.sleep(1000*30); } catch (InterruptedException e) {}
if(gameId != temp) break;
tauntPlayer = taunted.getName();
}
}
}
}
});
}
private static void scheduleWorldborder() {
Bukkit.getServer().getScheduler().runTaskAsynchronously(Main.plugin, new Runnable(){
public void run() {
int temp = gameId;
while(true) {
try { Thread.sleep(1000*60*worldborderDelay); } catch (InterruptedException e) {}
if(gameId != temp) break;
if(currentWorldborderSize-100 > 100) {
Bukkit.getServer().broadcastMessage(worldborderPrefix + "Worldborder decreacing by 100 blocks over the next 30s");
currentWorldborderSize -= 100;
decreaseBorder = true;
} else {
break;
}
}
}
});
}
public String getLabel() { public String getLabel() {
return "start"; return "start";
} }

View file

@ -1,4 +1,4 @@
package net.tylermurphy.hideAndSeek.commands; package net.tylermurphy.hideAndSeek.command;
import static net.tylermurphy.hideAndSeek.Store.*; import static net.tylermurphy.hideAndSeek.Store.*;
@ -35,9 +35,11 @@ public class Stop implements ICommand {
if(status.equals("Standby")) return; if(status.equals("Standby")) return;
status = "Standby"; status = "Standby";
gameId++; gameId++;
Functions.resetWorldborder("hideandseek_"+spawnWorld);
for(Player player : playerList.values()) { for(Player player : playerList.values()) {
player.setGameMode(GameMode.ADVENTURE); player.setGameMode(GameMode.ADVENTURE);
Hider.addEntry(player.getName()); Hider.add(player.getName());
HiderTeam.addEntry(player.getName());
player.getInventory().clear(); player.getInventory().clear();
player.teleport(new Location(Bukkit.getWorld(spawnWorld), spawnPosition.getX(),spawnPosition.getY(),spawnPosition.getZ())); player.teleport(new Location(Bukkit.getWorld(spawnWorld), spawnPosition.getX(),spawnPosition.getY(),spawnPosition.getZ()));
for(PotionEffect effect : player.getActivePotionEffects()){ for(PotionEffect effect : player.getActivePotionEffects()){
@ -48,7 +50,6 @@ public class Stop implements ICommand {
Packet.setGlow(player, temp, false); Packet.setGlow(player, temp, false);
} }
} }
Functions.resetWorldborder();
} }
public String getUsage() { public String getUsage() {

View file

@ -1,169 +0,0 @@
package net.tylermurphy.hideAndSeek.events;
import static net.tylermurphy.hideAndSeek.Store.*;
import org.bukkit.Bukkit;
import org.bukkit.ChatColor;
import org.bukkit.Color;
import org.bukkit.FireworkEffect;
import org.bukkit.Location;
import org.bukkit.Sound;
import org.bukkit.World;
import org.bukkit.WorldBorder;
import org.bukkit.entity.EntityType;
import org.bukkit.entity.Firework;
import org.bukkit.entity.Player;
import org.bukkit.inventory.meta.FireworkMeta;
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.commands.Stop;
import net.tylermurphy.hideAndSeek.util.Packet;
public class EventTick {
static int tick = 0;
public static void onTick() {
if(board == null) {
ScoreboardManager manager = Bukkit.getScoreboardManager();
Scoreboard mainBoard = manager.getMainScoreboard();
try { mainBoard.registerNewTeam("Seeker");} catch(Exception e) {}
Seeker = mainBoard.getTeam("Seeker");
Seeker.setColor(ChatColor.RED);
if(nametagsVisible)
Seeker.setOption(Option.NAME_TAG_VISIBILITY, OptionStatus.FOR_OTHER_TEAMS);
else
Seeker.setOption(Option.NAME_TAG_VISIBILITY, OptionStatus.NEVER);
Seeker.setAllowFriendlyFire(false);
try { mainBoard.registerNewTeam("Hider");} catch(Exception e) {}
Hider = mainBoard.getTeam("Hider");
Hider.setColor(ChatColor.GOLD);
if(nametagsVisible)
Hider.setOption(Option.NAME_TAG_VISIBILITY, OptionStatus.FOR_OWN_TEAM);
else
Hider.setOption(Option.NAME_TAG_VISIBILITY, OptionStatus.NEVER);
Hider.setAllowFriendlyFire(false);
try { mainBoard.registerNewTeam("Spectator");} catch(Exception e) {}
Spectator = mainBoard.getTeam("Spectator");
Spectator.setColor(ChatColor.GRAY);
Spectator.setOption(Option.NAME_TAG_VISIBILITY, OptionStatus.NEVER);
Spectator.setAllowFriendlyFire(false);
board = mainBoard;
}
for(String entry : Hider.getEntries()) {
if(!playerList.containsKey(entry)) {
Hider.removeEntry(entry);
}
}
for(String entry : Seeker.getEntries()) {
if(!playerList.containsKey(entry)) {
Seeker.removeEntry(entry);
}
}
for(String entry : Spectator.getEntries()) {
if(!playerList.containsKey(entry)) {
Spectator.removeEntry(entry);
}
}
if(status.equals("Starting")) {
onStarting();
} else if(status.equals("Playing")) {
onPlaying();
}
tick ++;
if(( status.equals("Starting") || status.equals("Playing") ) && Hider.getSize() < 1) {
Bukkit.broadcastMessage(gameoverPrefix + "All hiders have been found.");
Stop.onStop();
}
if(( status.equals("Starting") || status.equals("Playing") ) && Seeker.getSize() < 1) {
Bukkit.broadcastMessage(abortPrefix + "All seekers have quit.");
Stop.onStop();
}
}
private static void onStarting() {
for(String playerName : Seeker.getEntries()) {
Player player = playerList.get(playerName);
if(player != null) {
player.teleport(new Location(Bukkit.getWorld("hideandseek_"+spawnWorld), spawnPosition.getX(),spawnPosition.getY(),spawnPosition.getZ()));
}
}
}
private static void onPlaying() {
if(decreaseBorder) {
World world = Bukkit.getWorld("world");
WorldBorder border = world.getWorldBorder();
border.setSize(border.getSize()-100,30);
decreaseBorder = false;
}
if(!tauntPlayer.equals("")) {
Player taunted = playerList.get(tauntPlayer);
if(taunted != null) {
Firework fw = (Firework) taunted.getLocation().getWorld().spawnEntity(taunted.getLocation(), EntityType.FIREWORK);
FireworkMeta fwm = fw.getFireworkMeta();
fwm.setPower(4);
fwm.addEffect(FireworkEffect.builder()
.withColor(Color.BLUE)
.withColor(Color.RED)
.withColor(Color.YELLOW)
.with(FireworkEffect.Type.STAR)
.with(FireworkEffect.Type.BALL)
.with(FireworkEffect.Type.BALL_LARGE)
.flicker(true)
.withTrail()
.build());
fw.setFireworkMeta(fwm);
Bukkit.getServer().broadcastMessage(tauntPrefix + " Taunt has been activated");
}
tauntPlayer = "";
}
for(String playerName : Hider.getEntries()) {
Player player = playerList.get(playerName);
int distance = 100;
for(String seekerName : Seeker.getEntries()) {
Player seeker = playerList.get(seekerName);
int temp = (int) player.getLocation().distance(seeker.getLocation());
if(distance > temp) {
distance = temp;
}
if(glowTime > 0) {
Packet.setGlow(player, seeker, true);
} else {
Packet.setGlow(player, seeker, false);
}
}
switch(tick%10) {
case 0:
if(distance < 30) Packet.playSound(player, Sound.BLOCK_NOTE_BLOCK_BASEDRUM, .5f, 1f);
if(distance < 10) Packet.playSound(player, Sound.BLOCK_NOTE_BLOCK_BIT, .3f, 1f);
break;
case 3:
if(distance < 30) Packet.playSound(player, Sound.BLOCK_NOTE_BLOCK_BASEDRUM, .3f, 1f);
if(distance < 10) Packet.playSound(player, Sound.BLOCK_NOTE_BLOCK_BIT, .3f, 1f);
break;
case 6:
if(distance < 10) Packet.playSound(player, Sound.BLOCK_NOTE_BLOCK_BIT, .3f, 1f);
break;
case 9:
if(distance < 20) Packet.playSound(player, Sound.BLOCK_NOTE_BLOCK_BIT, .3f, 1f);
break;
}
}
}
}

View file

@ -0,0 +1,69 @@
package net.tylermurphy.hideAndSeek.events;
import static net.tylermurphy.hideAndSeek.Store.*;
import org.bukkit.Bukkit;
import org.bukkit.entity.Player;
import net.tylermurphy.hideAndSeek.Main;
import net.tylermurphy.hideAndSeek.util.Packet;
public class Glow {
private final int temp;
private int glowTime;
private boolean running;
public Glow(int temp) {
this.temp = temp;
this.glowTime = 0;
}
public void onProjectilve() {
glowTime++;
if(!running)
startGlow();
}
private void startGlow() {
running = true;
for(String hiderName : Hider) {
Player hider = playerList.get(hiderName);
if(hider == null) continue;
for(String seekerName : Seeker) {
Player seeker = playerList.get(seekerName);
if(seeker == null) continue;
Packet.setGlow(hider, seeker, true);
}
}
waitGlow();
}
private void waitGlow() {
Bukkit.getServer().getScheduler().scheduleSyncDelayedTask(Main.plugin, new Runnable() {
public void run() {
if(temp != gameId) return;
glowTime--;
glowTime = Math.max(glowTime, 0);
if(glowTime == 0) {
stopGlow();
} else {
waitGlow();
}
}
}, 20*30);
}
private void stopGlow() {
for(String hiderName : Hider) {
Player hider = playerList.get(hiderName);
if(hider == null) continue;
for(String seekerName : Seeker) {
Player seeker = playerList.get(seekerName);
if(seeker == null) continue;
Packet.setGlow(hider, seeker, false);
}
}
}
}

View file

@ -0,0 +1,100 @@
package net.tylermurphy.hideAndSeek.events;
import static net.tylermurphy.hideAndSeek.Store.*;
import org.bukkit.Bukkit;
import org.bukkit.ChatColor;
import org.bukkit.Color;
import org.bukkit.FireworkEffect;
import org.bukkit.entity.EntityType;
import org.bukkit.entity.Firework;
import org.bukkit.entity.Player;
import org.bukkit.inventory.meta.FireworkMeta;
import net.tylermurphy.hideAndSeek.Main;
public class Taunt {
private final int temp;
private String tauntPlayer;
public Taunt(int temp) {
this.temp = temp;
}
public void schedule() {
Bukkit.getServer().getScheduler().scheduleSyncDelayedTask(Main.plugin, new Runnable() {
public void run() {
tryTaunt();
}
},20*60*5);
}
private void waitTaunt() {
Bukkit.getServer().getScheduler().scheduleSyncDelayedTask(Main.plugin, new Runnable() {
public void run() {
tryTaunt();
}
},20*60);
}
private void tryTaunt() {
if(temp != gameId) return;
if(Math.random() > .8) {
executeTaunt();
} else {
Bukkit.getServer().getScheduler().scheduleSyncDelayedTask(Main.plugin, new Runnable() {
public void run() {
tryTaunt();
}
},20*60);
}
}
private void executeTaunt() {
Player taunted = null;
int rand = (int) (Math.random()*Hider.size());
for(Player player : playerList.values()) {
if(Hider.contains(player.getName())) {
rand--;
if(rand==0) {
taunted = player;
break;
}
}
}
if(taunted != null) {
taunted.sendMessage(ChatColor.RED + "" + ChatColor.ITALIC + "Oh no! You have been chosed to be taunted.");
Bukkit.getServer().broadcastMessage(tauntPrefix + " A random hider will be taunted in the next 30s");
tauntPlayer = taunted.getName();
Bukkit.getServer().getScheduler().scheduleSyncDelayedTask(Main.plugin, new Runnable() {
public void run() {
if(temp != gameId) return;
Player taunted = playerList.get(tauntPlayer);
if(taunted != null) {
Firework fw = (Firework) taunted.getLocation().getWorld().spawnEntity(taunted.getLocation(), EntityType.FIREWORK);
FireworkMeta fwm = fw.getFireworkMeta();
fwm.setPower(4);
fwm.addEffect(FireworkEffect.builder()
.withColor(Color.BLUE)
.withColor(Color.RED)
.withColor(Color.YELLOW)
.with(FireworkEffect.Type.STAR)
.with(FireworkEffect.Type.BALL)
.with(FireworkEffect.Type.BALL_LARGE)
.flicker(true)
.withTrail()
.build());
fw.setFireworkMeta(fwm);
Bukkit.getServer().broadcastMessage(tauntPrefix + " Taunt has been activated");
}
tauntPlayer = "";
waitTaunt();
}
},20*30);
} else {
waitTaunt();
}
}
}

View file

@ -0,0 +1,43 @@
package net.tylermurphy.hideAndSeek.events;
import org.bukkit.Bukkit;
import org.bukkit.World;
import org.bukkit.WorldBorder;
import net.tylermurphy.hideAndSeek.Main;
import static net.tylermurphy.hideAndSeek.Store.*;
public class Worldborder {
private final int temp;
public Worldborder(int temp) {
this.temp = temp;
}
public void schedule() {
Bukkit.getServer().getScheduler().scheduleSyncDelayedTask(Main.plugin, new Runnable() {
public void run() {
decreaceWorldborder();
}
},20*60*worldborderDelay);
}
private void decreaceWorldborder() {
if(temp != gameId) return;
if(currentWorldborderSize-100 > 100) {
Bukkit.getServer().broadcastMessage(worldborderPrefix + "Worldborder decreacing by 100 blocks over the next 30s");
currentWorldborderSize -= 100;
World world = Bukkit.getWorld("hideandseek_"+spawnWorld);
WorldBorder border = world.getWorldBorder();
border.setSize(border.getSize()-100,30);
Bukkit.getServer().getScheduler().scheduleSyncDelayedTask(Main.plugin, new Runnable() {
public void run() {
decreaceWorldborder();
}
},20*60*worldborderDelay);
}
}
}

View file

@ -6,6 +6,7 @@ import java.util.ArrayList;
import java.util.List; import java.util.List;
import org.bukkit.Bukkit; import org.bukkit.Bukkit;
import org.bukkit.ChatColor;
import org.bukkit.Material; import org.bukkit.Material;
import org.bukkit.World; import org.bukkit.World;
import org.bukkit.WorldBorder; import org.bukkit.WorldBorder;
@ -19,6 +20,10 @@ 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 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; import net.tylermurphy.hideAndSeek.Main;
@ -30,7 +35,7 @@ public class Functions {
player.removePotionEffect(effect.getType()); player.removePotionEffect(effect.getType());
} }
player.addPotionEffect(new PotionEffect(PotionEffectType.DOLPHINS_GRACE, 1000000, 1, false, false)); player.addPotionEffect(new PotionEffect(PotionEffectType.DOLPHINS_GRACE, 1000000, 1, false, false));
if(Seeker.getEntries().contains(player.getName())){ if(Seeker.contains(player.getName())){
ItemStack diamondSword = new ItemStack(Material.DIAMOND_SWORD,1); ItemStack diamondSword = new ItemStack(Material.DIAMOND_SWORD,1);
diamondSword.addEnchantment(Enchantment.DAMAGE_ALL, 1); diamondSword.addEnchantment(Enchantment.DAMAGE_ALL, 1);
ItemMeta diamondSwordMeta = diamondSword.getItemMeta(); ItemMeta diamondSwordMeta = diamondSword.getItemMeta();
@ -51,7 +56,7 @@ public class Functions {
player.addPotionEffect(new PotionEffect(PotionEffectType.SLOW_FALLING, 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)); player.addPotionEffect(new PotionEffect(PotionEffectType.WATER_BREATHING, 1000000, 10, false, false));
} }
else if(Hider.getEntries().contains(player.getName())){ else if(Hider.contains(player.getName())){
ItemStack stoneSword = new ItemStack(Material.STONE_SWORD,1); ItemStack stoneSword = new ItemStack(Material.STONE_SWORD,1);
stoneSword.addEnchantment(Enchantment.DAMAGE_ALL, 2); stoneSword.addEnchantment(Enchantment.DAMAGE_ALL, 2);
ItemMeta stoneSwordMeta = stoneSword.getItemMeta(); ItemMeta stoneSwordMeta = stoneSword.getItemMeta();
@ -87,15 +92,15 @@ public class Functions {
} }
} }
public static void resetWorldborder() { public static void resetWorldborder(String worldName) {
if(worldborderEnabled) { if(worldborderEnabled) {
World world = Bukkit.getWorld("world"); World world = Bukkit.getWorld(worldName);
WorldBorder border = world.getWorldBorder(); WorldBorder border = world.getWorldBorder();
border.setSize(worldborderSize); border.setSize(worldborderSize);
border.setCenter(worldborderPosition.getX(), worldborderPosition.getZ()); border.setCenter(worldborderPosition.getX(), worldborderPosition.getZ());
currentWorldborderSize = worldborderSize; currentWorldborderSize = worldborderSize;
} else { } else {
World world = Bukkit.getWorld("world"); World world = Bukkit.getWorld(worldName);
WorldBorder border = world.getWorldBorder(); WorldBorder border = world.getWorldBorder();
border.setSize(30000000); border.setSize(30000000);
border.setCenter(0, 0); border.setCenter(0, 0);
@ -119,5 +124,37 @@ public class Functions {
unloadMap(mapname); unloadMap(mapname);
loadMap(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);
SeekerTeam.setAllowFriendlyFire(false);
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);
HiderTeam.setAllowFriendlyFire(false);
try { mainBoard.registerNewTeam("Spectator");} catch(Exception e) {}
SpectatorTeam = mainBoard.getTeam("Spectator");
SpectatorTeam.setColor(ChatColor.GRAY);
SpectatorTeam.setOption(Option.NAME_TAG_VISIBILITY, OptionStatus.NEVER);
SpectatorTeam.setAllowFriendlyFire(false);
board = mainBoard;
}
} }