hunder and standby health rewrite

This commit is contained in:
Tyler Murphy 2021-08-21 22:02:11 -04:00
parent dc731b425f
commit 20037e986f
5 changed files with 22 additions and 27 deletions

View file

@ -1,7 +1,7 @@
<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.1.0</version>
<version>1.1.1</version>
<name>Hide and Seek Plugin</name>
<build>
<plugins>

View file

@ -9,7 +9,7 @@ public class About implements ICommand {
public void execute(CommandSender sender, String[] args) {
sender.sendMessage(
String.format("%s%sHide and Seek %s(1.1.0%s)\n", ChatColor.AQUA, ChatColor.BOLD, ChatColor.GRAY,ChatColor.WHITE,ChatColor.GRAY) +
String.format("%s%sHide and Seek %s(1.1.1%s)\n", ChatColor.AQUA, ChatColor.BOLD, ChatColor.GRAY,ChatColor.WHITE,ChatColor.GRAY) +
String.format("%sAuthor: %s[KenshinEto]\n", ChatColor.GRAY, ChatColor.WHITE) +
String.format("%sHelp Command: %s/hs %shelp", ChatColor.GRAY, ChatColor.AQUA, ChatColor.WHITE)
);

View file

@ -15,6 +15,7 @@ import org.bukkit.event.Listener;
import org.bukkit.event.entity.EntityDamageEvent;
import org.bukkit.event.entity.EntityRegainHealthEvent;
import org.bukkit.event.entity.EntityRegainHealthEvent.RegainReason;
import org.bukkit.event.entity.FoodLevelChangeEvent;
import org.bukkit.event.entity.ProjectileLaunchEvent;
import org.bukkit.event.player.PlayerJoinEvent;
import org.bukkit.event.player.PlayerQuitEvent;
@ -54,6 +55,10 @@ public class EventManager implements Listener {
@EventHandler
public void onPlayerDamage(EntityDamageEvent event) {
if(event.getEntity() instanceof Player) {
if(!status.equals("Playing")) {
event.setCancelled(true);
return;
}
Player player = (Player) event.getEntity();
if(player.getHealth()-event.getDamage() < 0) {
if(spawnPosition == null) return;
@ -61,16 +66,14 @@ public class EventManager implements Listener {
player.setHealth(player.getAttribute(Attribute.GENERIC_MAX_HEALTH).getValue());
player.teleport(new Location(player.getWorld(), spawnPosition.getX(), spawnPosition.getY(), spawnPosition.getZ()));
Functions.playSound(player, Sound.ENTITY_PLAYER_DEATH, 1, 1);
if(status.equals("Playing")) {
Functions.resetPlayer(player);
if(Hider.hasEntry(event.getEntity().getName())) {
Bukkit.broadcastMessage(String.format(messagePrefix + "%s%s%s has died and become a seeker", ChatColor.GOLD, event.getEntity().getName(), ChatColor.WHITE));
}
if(Seeker.hasEntry(event.getEntity().getName())) {
Bukkit.broadcastMessage(String.format(messagePrefix + "%s%s%s has been beat by a hider", ChatColor.RED, event.getEntity().getName(), ChatColor.WHITE));
}
Seeker.addEntry(player.getName());
Functions.resetPlayer(player);
if(Hider.hasEntry(event.getEntity().getName())) {
Bukkit.broadcastMessage(String.format(messagePrefix + "%s%s%s has died and become a seeker", ChatColor.GOLD, event.getEntity().getName(), ChatColor.WHITE));
}
if(Seeker.hasEntry(event.getEntity().getName())) {
Bukkit.broadcastMessage(String.format(messagePrefix + "%s%s%s has been beat by a hider", ChatColor.RED, event.getEntity().getName(), ChatColor.WHITE));
}
Seeker.addEntry(player.getName());
}
}
@ -99,6 +102,11 @@ public class EventManager implements Listener {
}
}
@EventHandler
public void onFoodLevelChange(FoodLevelChangeEvent event) {
event.setCancelled(false);
}
@EventHandler
public void onPlayerRegainHealth(EntityRegainHealthEvent event) {
if(event.getRegainReason() == RegainReason.SATIATED || event.getRegainReason() == RegainReason.REGEN)

View file

@ -31,14 +31,8 @@ public class TickManager {
}
Functions.emptyOfflinePlayers();
for(Player player : playerList.values()) {
player.addPotionEffect(new PotionEffect(PotionEffectType.SATURATION, 1000000, 127, false, false));
}
if(status.equals("Standby") || status.equals("Setup")) {
onStandby();
} else if(status.equals("Starting")) {
if(status.equals("Starting")) {
onStarting();
} else if(status.equals("Playing")) {
onPlaying();
@ -56,13 +50,6 @@ public class TickManager {
}
}
private static void onStandby() {
for(Player player : playerList.values()) {
player.addPotionEffect(new PotionEffect(PotionEffectType.REGENERATION, 1000000, 127, false, false));
}
}
private static void onStarting() {
for(String playerName : Seeker.getEntries()) {
Player player = playerList.get(playerName);

View file

@ -1,6 +1,6 @@
name: HideAndSeek
main: net.tylermurphy.hideAndSeek.Main
version: 1.1.0
version: 1.1.1
author: KenshinEto
load: STARTUP
api-version: 1.17