1.3.1 build 6

This commit is contained in:
Tyler Murphy 2021-11-08 15:53:13 -05:00
parent 2a52629152
commit 72f093b243
10 changed files with 137 additions and 114 deletions

12
HideAndSeekPlugin.iml Normal file
View file

@ -0,0 +1,12 @@
<?xml version="1.0" encoding="UTF-8"?>
<module version="4">
<component name="FacetManager">
<facet type="minecraft" name="Minecraft">
<configuration>
<autoDetectTypes>
<platformType>SPIGOT</platformType>
</autoDetectTypes>
</configuration>
</facet>
</component>
</module>

16
pom.xml
View file

@ -1,14 +1,8 @@
<?xml version="1.0" encoding="UTF-8"?> <project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 https://maven.apache.org/xsd/maven-4.0.0.xsd"><modelVersion>4.0.0</modelVersion>
<project xmlns="http://maven.apache.org/POM/4.0.0"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
<modelVersion>4.0.0</modelVersion>
<groupId>net.tylermurphy</groupId> <groupId>net.tylermurphy</groupId>
<artifactId>HideAndSeek</artifactId> <artifactId>HideAndSeek</artifactId>
<version>1.3.1</version> <version>1.3.1</version>
<name>Hide and Seek Plugin</name> <name>Hide and Seek Plugin</name>
<build> <build>
<plugins> <plugins>
<plugin> <plugin>
@ -22,7 +16,6 @@
</plugin> </plugin>
</plugins> </plugins>
</build> </build>
<repositories> <repositories>
<repository> <repository>
<id>spigot-repo</id> <id>spigot-repo</id>
@ -33,7 +26,6 @@
<url>https://repo.dmulloy2.net/repository/public/</url> <url>https://repo.dmulloy2.net/repository/public/</url>
</repository> </repository>
</repositories> </repositories>
<dependencies> <dependencies>
<dependency> <dependency>
<groupId>org.spigotmc</groupId> <groupId>org.spigotmc</groupId>
@ -48,10 +40,4 @@
<version>4.7.0</version> <version>4.7.0</version>
</dependency> </dependency>
</dependencies> </dependencies>
<properties>
<maven.compiler.source>11</maven.compiler.source>
<maven.compiler.target>11</maven.compiler.target>
</properties>
</project> </project>

View file

@ -77,14 +77,12 @@ public class Main extends JavaPlugin implements Listener {
board.reload(); board.reload();
// Start Tick Timer // Start Tick Timer
onTickTask = Bukkit.getServer().getScheduler().runTaskTimer(this, new Runnable(){ onTickTask = Bukkit.getServer().getScheduler().runTaskTimer(this, () -> {
public void run(){
try{ try{
Tick.onTick(); Tick.onTick();
} catch (Exception e) { } catch (Exception e) {
e.printStackTrace(); e.printStackTrace();
} }
}
},0,1); },0,1);
} }

View file

@ -82,34 +82,35 @@ public class EventListener implements Listener {
@EventHandler(priority = EventPriority.HIGHEST) @EventHandler(priority = EventPriority.HIGHEST)
public void onEntityDamage(EntityDamageEvent event) { public void onEntityDamage(EntityDamageEvent event) {
if(event.getEntity() instanceof Player) { try {
if (event.getEntity() instanceof Player) {
Player p = (Player) event.getEntity(); Player p = (Player) event.getEntity();
if(!Main.plugin.board.isPlayer(p)) return; if (!Main.plugin.board.isPlayer(p)) return;
if(!Main.plugin.status.equals("Playing")) { if (!Main.plugin.status.equals("Playing")) {
event.setCancelled(true); event.setCancelled(true);
return; return;
} }
Player attacker = null; Player attacker = null;
if(event instanceof EntityDamageByEntityEvent) { if (event instanceof EntityDamageByEntityEvent) {
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(Main.plugin.board.onSameTeam(p, attacker)) event.setCancelled(true); if (Main.plugin.board.onSameTeam(p, attacker)) event.setCancelled(true);
if(Main.plugin.board.isSpectator(p)) event.setCancelled(true); if (Main.plugin.board.isSpectator(p)) event.setCancelled(true);
} }
} }
Player player = (Player) event.getEntity(); Player player = (Player) event.getEntity();
if(player.getHealth()-event.getDamage() < 0 || !pvpEnabled) { if (player.getHealth() - event.getDamage() < 0 || !pvpEnabled) {
if(spawnPosition == null) return; if (spawnPosition == null) return;
event.setCancelled(true); event.setCancelled(true);
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(Main.plugin.board.isSeeker(player)) { if (Main.plugin.board.isSeeker(player)) {
Bukkit.broadcastMessage(message("GAME_PLAYER_DEATH").addPlayer(event.getEntity()).toString()); Bukkit.broadcastMessage(message("GAME_PLAYER_DEATH").addPlayer(event.getEntity()).toString());
} }
if(Main.plugin.board.isHider(player)) { if (Main.plugin.board.isHider(player)) {
if(attacker == null) { if (attacker == null) {
Util.broadcastMessage(message("GAME_PLAYER_FOUND").addPlayer(event.getEntity()).toString()); Util.broadcastMessage(message("GAME_PLAYER_FOUND").addPlayer(event.getEntity()).toString());
} else { } else {
Util.broadcastMessage(message("GAME_PLAYER_FOUND_BY").addPlayer(event.getEntity()).addPlayer(attacker).toString()); Util.broadcastMessage(message("GAME_PLAYER_FOUND_BY").addPlayer(event.getEntity()).addPlayer(attacker).toString());
@ -120,6 +121,9 @@ public class EventListener implements Listener {
Main.plugin.board.reloadBoardTeams(); Main.plugin.board.reloadBoardTeams();
} }
} }
} catch (Exception e){
//Has shown to cause problems, so ignore if exception
}
} }
@EventHandler(priority = EventPriority.HIGHEST) @EventHandler(priority = EventPriority.HIGHEST)

View file

@ -40,9 +40,13 @@ public class Tick {
else tick = 1; else tick = 1;
for(Player hider : Main.plugin.board.getHiders()) { for(Player hider : Main.plugin.board.getHiders()) {
int distance = 100; int distance = 100, temp = 100;
for(Player seeker : Main.plugin.board.getSeekers()) { for(Player seeker : Main.plugin.board.getSeekers()) {
int temp = (int) hider.getLocation().distance(seeker.getLocation()); try {
temp = (int) hider.getLocation().distance(seeker.getLocation());
} catch (Exception e){
//Players in different worlds, NOT OK!!!
}
if(distance > temp) { if(distance > temp) {
distance = temp; distance = temp;
} }

View file

@ -125,6 +125,7 @@ public class ConfigManager {
if(index == -1) continue;; if(index == -1) continue;;
int start = yamlString.indexOf(' ', index); int start = yamlString.indexOf(' ', index);
int end = yamlString.indexOf('\n', index); int end = yamlString.indexOf('\n', index);
if(end == -1) end = yamlString.length();
String replace = entry.getValue().toString(); String replace = entry.getValue().toString();
if(entry.getValue() instanceof String){ if(entry.getValue() instanceof String){
replace = "\"" + replace + "\""; replace = "\"" + replace + "\"";

View file

@ -37,8 +37,7 @@ public class Glow {
} }
private void waitGlow() { private void waitGlow() {
Bukkit.getServer().getScheduler().scheduleSyncDelayedTask(Main.plugin, new Runnable() { Bukkit.getServer().getScheduler().scheduleSyncDelayedTask(Main.plugin, () -> {
public void run() {
if(temp != Main.plugin.gameId) return; if(temp != Main.plugin.gameId) return;
glowTime--; glowTime--;
glowTime = Math.max(glowTime, 0); glowTime = Math.max(glowTime, 0);
@ -47,7 +46,6 @@ public class Glow {
} else { } else {
waitGlow(); waitGlow();
} }
}
}, 20); }, 20);
} }

View file

@ -32,8 +32,7 @@ public class Taunt {
} }
private void waitTaunt() { private void waitTaunt() {
Bukkit.getServer().getScheduler().scheduleSyncDelayedTask(Main.plugin, new Runnable() { Bukkit.getServer().getScheduler().scheduleSyncDelayedTask(Main.plugin, () -> {
public void run() {
if(delay == 0) { if(delay == 0) {
if(!tauntLast && Main.plugin.board.size() < 2) return; if(!tauntLast && Main.plugin.board.size() < 2) return;
else executeTaunt(); else executeTaunt();
@ -41,11 +40,11 @@ public class Taunt {
delay--; delay--;
waitTaunt(); waitTaunt();
} }
}
},20); },20);
} }
private void executeTaunt() { private void executeTaunt() {
if(temp != Main.plugin.gameId) return;
Player taunted = null; Player taunted = null;
int rand = (int) (Math.random()*Main.plugin.board.sizeHider()); int rand = (int) (Math.random()*Main.plugin.board.sizeHider());
for(Player player : Main.plugin.board.getPlayers()) { for(Player player : Main.plugin.board.getPlayers()) {
@ -62,12 +61,11 @@ public class Taunt {
taunted.sendMessage(message("TAUNTED").toString()); taunted.sendMessage(message("TAUNTED").toString());
Util.broadcastMessage(tauntPrefix + message("TAUNT")); Util.broadcastMessage(tauntPrefix + message("TAUNT"));
tauntPlayer = taunted.getName(); tauntPlayer = taunted.getName();
Bukkit.getServer().getScheduler().scheduleSyncDelayedTask(Main.plugin, new Runnable() { Bukkit.getServer().getScheduler().scheduleSyncDelayedTask(Main.plugin, () -> {
public void run() {
if(temp != Main.plugin.gameId) return; if(temp != Main.plugin.gameId) return;
Player taunted = Main.plugin.board.getPlayer(tauntPlayer); Player taunted1 = Main.plugin.board.getPlayer(tauntPlayer);
if(taunted != null) { if(taunted1 != null) {
Firework fw = (Firework) taunted.getLocation().getWorld().spawnEntity(taunted.getLocation(), EntityType.FIREWORK); Firework fw = (Firework) taunted1.getLocation().getWorld().spawnEntity(taunted1.getLocation(), EntityType.FIREWORK);
FireworkMeta fwm = fw.getFireworkMeta(); FireworkMeta fwm = fw.getFireworkMeta();
fwm.setPower(4); fwm.setPower(4);
fwm.addEffect(FireworkEffect.builder() fwm.addEffect(FireworkEffect.builder()
@ -86,7 +84,6 @@ public class Taunt {
tauntPlayer = ""; tauntPlayer = "";
running = false; running = false;
schedule(); schedule();
}
},20*30); },20*30);
} else { } else {
schedule(); schedule();

View file

@ -13,32 +13,38 @@ import net.tylermurphy.hideAndSeek.util.Util;
public class Worldborder { public class Worldborder {
private final int temp; private final int temp;
private int delay;
private boolean running;
public Worldborder(int temp) { public Worldborder(int temp) {
this.temp = temp; this.temp = temp;
} }
public void schedule() { public void schedule() {
Bukkit.getServer().getScheduler().scheduleSyncDelayedTask(Main.plugin, new Runnable() { delay = 60*worldborderDelay;
public void run() { running = false;
decreaceWorldborder(); waitBorder();
} }
},20*60*worldborderDelay);
private void waitBorder(){
Bukkit.getServer().getScheduler().scheduleSyncDelayedTask(Main.plugin, () -> {
if(delay == 0) decreaceWorldborder();
else {
delay--; waitBorder();
}
}, 20);
} }
private void decreaceWorldborder() { private void decreaceWorldborder() {
if(temp != Main.plugin.gameId) return; if(temp != Main.plugin.gameId) return;
if(currentWorldborderSize-100 > 100) { if(currentWorldborderSize-100 > 100) {
running = true;
Util.broadcastMessage(worldborderPrefix + message("WORLDBORDER_DECREASING")); Util.broadcastMessage(worldborderPrefix + message("WORLDBORDER_DECREASING"));
currentWorldborderSize -= 100; currentWorldborderSize -= 100;
World world = Bukkit.getWorld("hideandseek_"+spawnWorld); World world = Bukkit.getWorld("hideandseek_"+spawnWorld);
WorldBorder border = world.getWorldBorder(); WorldBorder border = world.getWorldBorder();
border.setSize(border.getSize()-100,30); border.setSize(border.getSize()-100,30);
Bukkit.getServer().getScheduler().scheduleSyncDelayedTask(Main.plugin, new Runnable() { schedule();
public void run() {
decreaceWorldborder();
}
},20*60*worldborderDelay);
} }
} }
@ -57,4 +63,12 @@ public class Worldborder {
} }
} }
public int getDelay(){
return delay;
}
public boolean isRunning() {
return running;
}
} }

View file

@ -180,13 +180,13 @@ public class Board {
board.setLine("seekers", ChatColor.BOLD + "" + ChatColor.RED + "SEEKERS:" + ChatColor.WHITE + " " + Seeker.size()); board.setLine("seekers", ChatColor.BOLD + "" + ChatColor.RED + "SEEKERS:" + ChatColor.WHITE + " " + Seeker.size());
board.addBlank(); board.addBlank();
if(glowEnabled){ if(glowEnabled){
if(Main.plugin.glow == null || !Main.plugin.glow.isRunning()) if(Main.plugin.glow == null || Main.plugin.status.equals("Starting") || !Main.plugin.glow.isRunning())
board.setLine("glow", "Glow: " + ChatColor.RED + "Inactive"); board.setLine("glow", "Glow: " + ChatColor.RED + "Inactive");
else else
board.setLine("glow", "Glow: " + ChatColor.GREEN + "Active"); board.setLine("glow", "Glow: " + ChatColor.GREEN + "Active");
} }
if(tauntEnabled && tauntCountdown){ if(tauntEnabled && tauntCountdown){
if(Main.plugin.taunt == null) if(Main.plugin.taunt == null || Main.plugin.status.equals("Starting"))
board.setLine("taunt", "Taunt: " + ChatColor.YELLOW + "0m0s"); board.setLine("taunt", "Taunt: " + ChatColor.YELLOW + "0m0s");
else if(!tauntLast && Hider.size() == 1){ else if(!tauntLast && Hider.size() == 1){
board.setLine("taunt", "Taunt: " + ChatColor.YELLOW + "Expired"); board.setLine("taunt", "Taunt: " + ChatColor.YELLOW + "Expired");
@ -195,7 +195,16 @@ public class Board {
else else
board.setLine("taunt", "Taunt: " + ChatColor.YELLOW + "Active"); board.setLine("taunt", "Taunt: " + ChatColor.YELLOW + "Active");
} }
if(glowEnabled || (tauntEnabled && tauntCountdown)) if(worldborderEnabled){
if(Main.plugin.worldborder == null || Main.plugin.status.equals("Starting")){
board.setLine("board", "WorldBorder: " + ChatColor.YELLOW + "0m0s");
} else if(!Main.plugin.worldborder.isRunning()) {
board.setLine("board", "WorldBorder: " + ChatColor.YELLOW + Main.plugin.worldborder.getDelay()/60 + "m" + Main.plugin.worldborder.getDelay()%60 + "s");
} else {
board.setLine("board", "WorldBorder: " + ChatColor.YELLOW + "Decreasing");
}
}
if(glowEnabled || (tauntEnabled && tauntCountdown) || worldborderEnabled)
board.addBlank(); board.addBlank();
board.setLine("time", "Time Left: " + ChatColor.GREEN + Main.plugin.timeLeft/60 + "m" + Main.plugin.timeLeft%60 + "s"); board.setLine("time", "Time Left: " + ChatColor.GREEN + Main.plugin.timeLeft/60 + "m" + Main.plugin.timeLeft%60 + "s");
board.addBlank(); board.addBlank();