summaryrefslogtreewikicommitdiff
path: root/src/main/java/net/tylermurphy/hideAndSeek/events/EventTick.java
diff options
context:
space:
mode:
authorTyler Murphy <tylermurphy534@gmail.com>2021-08-27 17:20:07 -0400
committerTyler Murphy <tylermurphy534@gmail.com>2021-08-27 17:20:07 -0400
commit0154a34f1dc240652908810314167a44638c847e (patch)
tree4f4e4a7dac2581ee8b32644cb30c3f852a1b8e8d /src/main/java/net/tylermurphy/hideAndSeek/events/EventTick.java
parent1.3.0 beta 2, bug fixes, added more block settings, added more config options (diff)
downloadkenshinshideandseek-0154a34f1dc240652908810314167a44638c847e.tar.gz
kenshinshideandseek-0154a34f1dc240652908810314167a44638c847e.tar.bz2
kenshinshideandseek-0154a34f1dc240652908810314167a44638c847e.zip
add world rollback and other stuff
Diffstat (limited to 'src/main/java/net/tylermurphy/hideAndSeek/events/EventTick.java')
-rw-r--r--src/main/java/net/tylermurphy/hideAndSeek/events/EventTick.java92
1 files changed, 60 insertions, 32 deletions
diff --git a/src/main/java/net/tylermurphy/hideAndSeek/events/EventTick.java b/src/main/java/net/tylermurphy/hideAndSeek/events/EventTick.java
index 2198c05..042b0a3 100644
--- a/src/main/java/net/tylermurphy/hideAndSeek/events/EventTick.java
+++ b/src/main/java/net/tylermurphy/hideAndSeek/events/EventTick.java
@@ -3,6 +3,7 @@ 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;
@@ -13,11 +14,13 @@ import org.bukkit.entity.EntityType;
import org.bukkit.entity.Firework;
import org.bukkit.entity.Player;
import org.bukkit.inventory.meta.FireworkMeta;
-import org.bukkit.potion.PotionEffect;
-import org.bukkit.potion.PotionEffectType;
+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.Functions;
+import net.tylermurphy.hideAndSeek.util.Packet;
public class EventTick {
@@ -26,10 +29,53 @@ public class EventTick {
public static void onTick() {
if(board == null) {
- Functions.loadScoreboard();
+ 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;
}
- Functions.emptyOfflinePlayers();
+ 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();
@@ -53,7 +99,7 @@ public class EventTick {
for(String playerName : Seeker.getEntries()) {
Player player = playerList.get(playerName);
if(player != null) {
- player.teleport(new Location(Bukkit.getWorld(spawnWorld), spawnPosition.getX(),spawnPosition.getY(),spawnPosition.getZ()));
+ player.teleport(new Location(Bukkit.getWorld("hideandseek_"+spawnWorld), spawnPosition.getX(),spawnPosition.getY(),spawnPosition.getZ()));
}
}
}
@@ -86,26 +132,8 @@ public class EventTick {
}
tauntPlayer = "";
}
- for(Player player : playerList.values()) {
- player.addPotionEffect(new PotionEffect(PotionEffectType.DOLPHINS_GRACE, 1000000, 1, false, false));
- }
- for(String playerName : Seeker.getEntries()) {
- Player player = playerList.get(playerName);
- if(player != null) {
- player.addPotionEffect(new PotionEffect(PotionEffectType.SPEED, 1000000, 2, false, false));
- player.addPotionEffect(new PotionEffect(PotionEffectType.JUMP, 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));
- }
- for(Player temp : playerList.values()) {
- Functions.setGlow(player, temp, false);
- }
- }
for(String playerName : Hider.getEntries()) {
Player player = playerList.get(playerName);
- if(player != null) {
- player.addPotionEffect(new PotionEffect(PotionEffectType.WATER_BREATHING, 1000000, 1, false, false));
- }
int distance = 100;
for(String seekerName : Seeker.getEntries()) {
Player seeker = playerList.get(seekerName);
@@ -114,25 +142,25 @@ public class EventTick {
distance = temp;
}
if(glowTime > 0) {
- Functions.setGlow(player, seeker, true);
+ Packet.setGlow(player, seeker, true);
} else {
- Functions.setGlow(player, seeker, false);
+ Packet.setGlow(player, seeker, false);
}
}
switch(tick%10) {
case 0:
- if(distance < 30) Functions.playSound(player, Sound.BLOCK_NOTE_BLOCK_BASEDRUM, .5f, 1f);
- if(distance < 10) Functions.playSound(player, Sound.BLOCK_NOTE_BLOCK_BIT, .3f, 1f);
+ 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) Functions.playSound(player, Sound.BLOCK_NOTE_BLOCK_BASEDRUM, .3f, 1f);
- if(distance < 10) Functions.playSound(player, Sound.BLOCK_NOTE_BLOCK_BIT, .3f, 1f);
+ 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) Functions.playSound(player, Sound.BLOCK_NOTE_BLOCK_BIT, .3f, 1f);
+ if(distance < 10) Packet.playSound(player, Sound.BLOCK_NOTE_BLOCK_BIT, .3f, 1f);
break;
case 9:
- if(distance < 20) Functions.playSound(player, Sound.BLOCK_NOTE_BLOCK_BIT, .3f, 1f);
+ if(distance < 20) Packet.playSound(player, Sound.BLOCK_NOTE_BLOCK_BIT, .3f, 1f);
break;
}
}