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 http://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 https://maven.apache.org/xsd/maven-4.0.0.xsd"><modelVersion>4.0.0</modelVersion>
<groupId>net.tylermurphy</groupId>
<artifactId>HideAndSeek</artifactId>
<version>1.3.1</version>
<name>Hide and Seek Plugin</name>
<build>
<plugins>
<plugin>
@ -22,7 +16,6 @@
</plugin>
</plugins>
</build>
<repositories>
<repository>
<id>spigot-repo</id>
@ -33,7 +26,6 @@
<url>https://repo.dmulloy2.net/repository/public/</url>
</repository>
</repositories>
<dependencies>
<dependency>
<groupId>org.spigotmc</groupId>
@ -48,10 +40,4 @@
<version>4.7.0</version>
</dependency>
</dependencies>
<properties>
<maven.compiler.source>11</maven.compiler.source>
<maven.compiler.target>11</maven.compiler.target>
</properties>
</project>

View file

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

View file

@ -82,43 +82,47 @@ public class EventListener implements Listener {
@EventHandler(priority = EventPriority.HIGHEST)
public void onEntityDamage(EntityDamageEvent event) {
if(event.getEntity() instanceof Player) {
Player p = (Player) event.getEntity();
if(!Main.plugin.board.isPlayer(p)) return;
if(!Main.plugin.status.equals("Playing")) {
event.setCancelled(true);
return;
}
Player attacker = null;
if(event instanceof EntityDamageByEntityEvent) {
Entity damager = ((EntityDamageByEntityEvent)event).getDamager();
if(damager instanceof Player) {
attacker = (Player) damager;
if(Main.plugin.board.onSameTeam(p, attacker)) event.setCancelled(true);
if(Main.plugin.board.isSpectator(p)) event.setCancelled(true);
}
}
Player player = (Player) event.getEntity();
if(player.getHealth()-event.getDamage() < 0 || !pvpEnabled) {
if(spawnPosition == null) return;
event.setCancelled(true);
player.setHealth(player.getAttribute(Attribute.GENERIC_MAX_HEALTH).getValue());
player.teleport(new Location(Bukkit.getWorld("hideandseek_"+spawnWorld), spawnPosition.getX(), spawnPosition.getY(), spawnPosition.getZ()));
Packet.playSound(player, Sound.ENTITY_PLAYER_DEATH, 1, 1);
if(Main.plugin.board.isSeeker(player)) {
Bukkit.broadcastMessage(message("GAME_PLAYER_DEATH").addPlayer(event.getEntity()).toString());
try {
if (event.getEntity() instanceof Player) {
Player p = (Player) event.getEntity();
if (!Main.plugin.board.isPlayer(p)) return;
if (!Main.plugin.status.equals("Playing")) {
event.setCancelled(true);
return;
}
if(Main.plugin.board.isHider(player)) {
if(attacker == null) {
Util.broadcastMessage(message("GAME_PLAYER_FOUND").addPlayer(event.getEntity()).toString());
} else {
Util.broadcastMessage(message("GAME_PLAYER_FOUND_BY").addPlayer(event.getEntity()).addPlayer(attacker).toString());
Player attacker = null;
if (event instanceof EntityDamageByEntityEvent) {
Entity damager = ((EntityDamageByEntityEvent) event).getDamager();
if (damager instanceof Player) {
attacker = (Player) damager;
if (Main.plugin.board.onSameTeam(p, attacker)) event.setCancelled(true);
if (Main.plugin.board.isSpectator(p)) event.setCancelled(true);
}
Main.plugin.board.addSeeker(player);
}
Util.resetPlayer(player);
Main.plugin.board.reloadBoardTeams();
Player player = (Player) event.getEntity();
if (player.getHealth() - event.getDamage() < 0 || !pvpEnabled) {
if (spawnPosition == null) return;
event.setCancelled(true);
player.setHealth(player.getAttribute(Attribute.GENERIC_MAX_HEALTH).getValue());
player.teleport(new Location(Bukkit.getWorld("hideandseek_" + spawnWorld), spawnPosition.getX(), spawnPosition.getY(), spawnPosition.getZ()));
Packet.playSound(player, Sound.ENTITY_PLAYER_DEATH, 1, 1);
if (Main.plugin.board.isSeeker(player)) {
Bukkit.broadcastMessage(message("GAME_PLAYER_DEATH").addPlayer(event.getEntity()).toString());
}
if (Main.plugin.board.isHider(player)) {
if (attacker == null) {
Util.broadcastMessage(message("GAME_PLAYER_FOUND").addPlayer(event.getEntity()).toString());
} else {
Util.broadcastMessage(message("GAME_PLAYER_FOUND_BY").addPlayer(event.getEntity()).addPlayer(attacker).toString());
}
Main.plugin.board.addSeeker(player);
}
Util.resetPlayer(player);
Main.plugin.board.reloadBoardTeams();
}
}
} catch (Exception e){
//Has shown to cause problems, so ignore if exception
}
}

View file

@ -40,9 +40,13 @@ public class Tick {
else tick = 1;
for(Player hider : Main.plugin.board.getHiders()) {
int distance = 100;
int distance = 100, temp = 100;
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) {
distance = temp;
}

View file

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

View file

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

View file

@ -32,20 +32,19 @@ public class Taunt {
}
private void waitTaunt() {
Bukkit.getServer().getScheduler().scheduleSyncDelayedTask(Main.plugin, new Runnable() {
public void run() {
if(delay == 0) {
if(!tauntLast && Main.plugin.board.size() < 2) return;
else executeTaunt();
} else {
delay--;
waitTaunt();
}
Bukkit.getServer().getScheduler().scheduleSyncDelayedTask(Main.plugin, () -> {
if(delay == 0) {
if(!tauntLast && Main.plugin.board.size() < 2) return;
else executeTaunt();
} else {
delay--;
waitTaunt();
}
},20);
}
private void executeTaunt() {
if(temp != Main.plugin.gameId) return;
Player taunted = null;
int rand = (int) (Math.random()*Main.plugin.board.sizeHider());
for(Player player : Main.plugin.board.getPlayers()) {
@ -62,31 +61,29 @@ public class Taunt {
taunted.sendMessage(message("TAUNTED").toString());
Util.broadcastMessage(tauntPrefix + message("TAUNT"));
tauntPlayer = taunted.getName();
Bukkit.getServer().getScheduler().scheduleSyncDelayedTask(Main.plugin, new Runnable() {
public void run() {
if(temp != Main.plugin.gameId) return;
Player taunted = Main.plugin.board.getPlayer(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);
Util.broadcastMessage(tauntPrefix + message("TAUNT_ACTIVATE"));
}
tauntPlayer = "";
running = false;
schedule();
Bukkit.getServer().getScheduler().scheduleSyncDelayedTask(Main.plugin, () -> {
if(temp != Main.plugin.gameId) return;
Player taunted1 = Main.plugin.board.getPlayer(tauntPlayer);
if(taunted1 != null) {
Firework fw = (Firework) taunted1.getLocation().getWorld().spawnEntity(taunted1.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);
Util.broadcastMessage(tauntPrefix + message("TAUNT_ACTIVATE"));
}
tauntPlayer = "";
running = false;
schedule();
},20*30);
} else {
schedule();

View file

@ -13,32 +13,38 @@ import net.tylermurphy.hideAndSeek.util.Util;
public class Worldborder {
private final int temp;
private int delay;
private boolean running;
public Worldborder(int temp) {
this.temp = temp;
}
public void schedule() {
Bukkit.getServer().getScheduler().scheduleSyncDelayedTask(Main.plugin, new Runnable() {
public void run() {
decreaceWorldborder();
delay = 60*worldborderDelay;
running = false;
waitBorder();
}
private void waitBorder(){
Bukkit.getServer().getScheduler().scheduleSyncDelayedTask(Main.plugin, () -> {
if(delay == 0) decreaceWorldborder();
else {
delay--; waitBorder();
}
},20*60*worldborderDelay);
}, 20);
}
private void decreaceWorldborder() {
if(temp != Main.plugin.gameId) return;
if(currentWorldborderSize-100 > 100) {
running = true;
Util.broadcastMessage(worldborderPrefix + message("WORLDBORDER_DECREASING"));
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);
schedule();
}
}
@ -56,5 +62,13 @@ public class Worldborder {
border.setCenter(0, 0);
}
}
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.addBlank();
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");
else
board.setLine("glow", "Glow: " + ChatColor.GREEN + "Active");
}
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");
else if(!tauntLast && Hider.size() == 1){
board.setLine("taunt", "Taunt: " + ChatColor.YELLOW + "Expired");
@ -195,7 +195,16 @@ public class Board {
else
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.setLine("time", "Time Left: " + ChatColor.GREEN + Main.plugin.timeLeft/60 + "m" + Main.plugin.timeLeft%60 + "s");
board.addBlank();