1.3.1 build 6
This commit is contained in:
parent
2a52629152
commit
72f093b243
10 changed files with 137 additions and 114 deletions
12
HideAndSeekPlugin.iml
Normal file
12
HideAndSeekPlugin.iml
Normal 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
16
pom.xml
|
@ -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>
|
|
@ -77,15 +77,13 @@ 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);
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -82,43 +82,47 @@ 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 {
|
||||||
Player p = (Player) event.getEntity();
|
if (event.getEntity() instanceof Player) {
|
||||||
if(!Main.plugin.board.isPlayer(p)) return;
|
Player p = (Player) event.getEntity();
|
||||||
if(!Main.plugin.status.equals("Playing")) {
|
if (!Main.plugin.board.isPlayer(p)) return;
|
||||||
event.setCancelled(true);
|
if (!Main.plugin.status.equals("Playing")) {
|
||||||
return;
|
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());
|
|
||||||
}
|
}
|
||||||
if(Main.plugin.board.isHider(player)) {
|
Player attacker = null;
|
||||||
if(attacker == null) {
|
if (event instanceof EntityDamageByEntityEvent) {
|
||||||
Util.broadcastMessage(message("GAME_PLAYER_FOUND").addPlayer(event.getEntity()).toString());
|
Entity damager = ((EntityDamageByEntityEvent) event).getDamager();
|
||||||
} else {
|
if (damager instanceof Player) {
|
||||||
Util.broadcastMessage(message("GAME_PLAYER_FOUND_BY").addPlayer(event.getEntity()).addPlayer(attacker).toString());
|
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);
|
Player player = (Player) event.getEntity();
|
||||||
Main.plugin.board.reloadBoardTeams();
|
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
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -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;
|
||||||
}
|
}
|
||||||
|
|
|
@ -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 + "\"";
|
||||||
|
|
|
@ -37,16 +37,14 @@ 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);
|
if(glowTime == 0) {
|
||||||
if(glowTime == 0) {
|
stopGlow();
|
||||||
stopGlow();
|
} else {
|
||||||
} else {
|
waitGlow();
|
||||||
waitGlow();
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}, 20);
|
}, 20);
|
||||||
}
|
}
|
||||||
|
|
|
@ -32,20 +32,19 @@ 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();
|
} else {
|
||||||
} else {
|
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,31 +61,29 @@ 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 taunted1 = Main.plugin.board.getPlayer(tauntPlayer);
|
||||||
Player taunted = Main.plugin.board.getPlayer(tauntPlayer);
|
if(taunted1 != null) {
|
||||||
if(taunted != null) {
|
Firework fw = (Firework) taunted1.getLocation().getWorld().spawnEntity(taunted1.getLocation(), EntityType.FIREWORK);
|
||||||
Firework fw = (Firework) taunted.getLocation().getWorld().spawnEntity(taunted.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()
|
.withColor(Color.BLUE)
|
||||||
.withColor(Color.BLUE)
|
.withColor(Color.RED)
|
||||||
.withColor(Color.RED)
|
.withColor(Color.YELLOW)
|
||||||
.withColor(Color.YELLOW)
|
.with(FireworkEffect.Type.STAR)
|
||||||
.with(FireworkEffect.Type.STAR)
|
.with(FireworkEffect.Type.BALL)
|
||||||
.with(FireworkEffect.Type.BALL)
|
.with(FireworkEffect.Type.BALL_LARGE)
|
||||||
.with(FireworkEffect.Type.BALL_LARGE)
|
.flicker(true)
|
||||||
.flicker(true)
|
.withTrail()
|
||||||
.withTrail()
|
.build());
|
||||||
.build());
|
fw.setFireworkMeta(fwm);
|
||||||
fw.setFireworkMeta(fwm);
|
Util.broadcastMessage(tauntPrefix + message("TAUNT_ACTIVATE"));
|
||||||
Util.broadcastMessage(tauntPrefix + message("TAUNT_ACTIVATE"));
|
|
||||||
}
|
|
||||||
tauntPlayer = "";
|
|
||||||
running = false;
|
|
||||||
schedule();
|
|
||||||
}
|
}
|
||||||
|
tauntPlayer = "";
|
||||||
|
running = false;
|
||||||
|
schedule();
|
||||||
},20*30);
|
},20*30);
|
||||||
} else {
|
} else {
|
||||||
schedule();
|
schedule();
|
||||||
|
|
|
@ -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();
|
||||||
|
}
|
||||||
|
|
||||||
|
private void waitBorder(){
|
||||||
|
Bukkit.getServer().getScheduler().scheduleSyncDelayedTask(Main.plugin, () -> {
|
||||||
|
if(delay == 0) decreaceWorldborder();
|
||||||
|
else {
|
||||||
|
delay--; waitBorder();
|
||||||
}
|
}
|
||||||
},20*60*worldborderDelay);
|
}, 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);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -56,5 +62,13 @@ public class Worldborder {
|
||||||
border.setCenter(0, 0);
|
border.setCenter(0, 0);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public int getDelay(){
|
||||||
|
return delay;
|
||||||
|
}
|
||||||
|
|
||||||
|
public boolean isRunning() {
|
||||||
|
return running;
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -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();
|
||||||
|
|
Loading…
Reference in a new issue