This commit is contained in:
Tyler Murphy 2021-08-21 20:08:11 -04:00
parent 8f0a3ef68c
commit dc731b425f
12 changed files with 214 additions and 174 deletions

69
pom.xml
View file

@ -1,34 +1,43 @@
<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"> <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>
<modelVersion>4.0.0</modelVersion> <groupId>net.tylermurphy</groupId>
<groupId>net.tylermurphy</groupId> <artifactId>HideAndSeek</artifactId>
<artifactId>HideAndSeek</artifactId> <version>1.1.0</version>
<version>1.0.0</version> <name>Hide and Seek Plugin</name>
<name>Hide and Seek Plugin</name> <build>
<build> <plugins>
<plugins> <plugin>
<plugin> <groupId>org.apache.maven.plugins</groupId>
<groupId>org.apache.maven.plugins</groupId> <artifactId>maven-compiler-plugin</artifactId>
<artifactId>maven-compiler-plugin</artifactId> <version>2.3.2</version>
<configuration> <configuration>
<source>1.8</source> <source>1.8</source>
<target>1.8</target> <target>1.8</target>
</configuration> </configuration>
</plugin> </plugin>
</plugins> </plugins>
</build> </build>
<repositories> <repositories>
<repository> <repository>
<id>spigot-repo</id> <id>spigot-repo</id>
<url>https://hub.spigotmc.org/nexus/content/repositories/public/</url> <url>https://hub.spigotmc.org/nexus/content/repositories/public/</url>
</repository> </repository>
</repositories> <repository>
<dependencies> <id>dmulloy2-repo</id>
<dependency> <url>https://repo.dmulloy2.net/repository/public/</url>
<groupId>org.spigotmc</groupId> </repository>
<artifactId>spigot-api</artifactId> </repositories>
<version>1.17.1-R0.1-SNAPSHOT</version> <dependencies>
<type>jar</type> <dependency>
<scope>provided</scope> <groupId>org.spigotmc</groupId>
</dependency> <artifactId>spigot-api</artifactId>
<version>1.17.1-R0.1-SNAPSHOT</version>
<type>jar</type>
<scope>provided</scope>
</dependency>
<dependency>
<groupId>com.comphenix.protocol</groupId>
<artifactId>ProtocolLib</artifactId>
<version>4.7.0</version>
</dependency>
</dependencies> </dependencies>
</project> </project>

View file

@ -14,6 +14,7 @@ import org.bukkit.util.Vector;
import net.tylermurphy.hideAndSeek.manager.CommandManager; import net.tylermurphy.hideAndSeek.manager.CommandManager;
import net.tylermurphy.hideAndSeek.manager.EventManager; import net.tylermurphy.hideAndSeek.manager.EventManager;
import net.tylermurphy.hideAndSeek.manager.TickManager; import net.tylermurphy.hideAndSeek.manager.TickManager;
import net.tylermurphy.hideAndSeek.util.Functions;
public class Main extends JavaPlugin implements Listener { public class Main extends JavaPlugin implements Listener {
@ -43,14 +44,6 @@ public class Main extends JavaPlugin implements Listener {
} }
worldborderEnabled = getConfig().getBoolean("borderEnabled"); worldborderEnabled = getConfig().getBoolean("borderEnabled");
// Init Gamerules
Bukkit.getServer().dispatchCommand(Bukkit.getConsoleSender(), "gamerule sendCommandFeedback false");
Bukkit.getServer().dispatchCommand(Bukkit.getConsoleSender(), "gamerule doImmediateRespawn true");
Bukkit.getServer().dispatchCommand(Bukkit.getConsoleSender(), "gamerule logAdminCommands false");
Bukkit.getServer().dispatchCommand(Bukkit.getConsoleSender(), "gamerule naturalRegeneration false");
Bukkit.getServer().dispatchCommand(Bukkit.getConsoleSender(), "gamerule keepInventory true");
Bukkit.getServer().dispatchCommand(Bukkit.getConsoleSender(), "gamerule showDeathMessages false");
// Register Commands // Register Commands
CommandManager.registerCommands(); CommandManager.registerCommands();

View file

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

View file

@ -1,6 +1,5 @@
package net.tylermurphy.hideAndSeek.commands; package net.tylermurphy.hideAndSeek.commands;
import org.bukkit.Bukkit;
import org.bukkit.command.CommandSender; import org.bukkit.command.CommandSender;
import org.bukkit.entity.Player; import org.bukkit.entity.Player;
import org.bukkit.util.Vector; import org.bukkit.util.Vector;
@ -26,8 +25,8 @@ public class SetSpawnLocation implements ICommand {
sender.sendMessage(messagePrefix + "Set spawn position to current location"); sender.sendMessage(messagePrefix + "Set spawn position to current location");
getConfig().set("spawnPosition", newSpawnPosition); getConfig().set("spawnPosition", newSpawnPosition);
saveConfig(); saveConfig();
Bukkit.getServer().dispatchCommand(Bukkit.getConsoleSender(), String.format("setworldspawn %s %s %s", player.getLocation().getBlockX(), player.getLocation().getBlockY(), player.getLocation().getBlockZ())); // Bukkit.getServer().dispatchCommand(Bukkit.getConsoleSender(), String.format("setworldspawn %s %s %s", player.getLocation().getBlockX(), player.getLocation().getBlockY(), player.getLocation().getBlockZ()));
Bukkit.getServer().dispatchCommand(Bukkit.getConsoleSender(), String.format("spawnpoint @a %s %s %s", player.getLocation().getBlockX(), player.getLocation().getBlockY(), player.getLocation().getBlockZ())); // Bukkit.getServer().dispatchCommand(Bukkit.getConsoleSender(), String.format("spawnpoint @a %s %s %s", player.getLocation().getBlockX(), player.getLocation().getBlockY(), player.getLocation().getBlockZ()));
} }
public String getLabel() { public String getLabel() {

View file

@ -17,8 +17,6 @@ import net.tylermurphy.hideAndSeek.util.Functions;
import static net.tylermurphy.hideAndSeek.Store.*; import static net.tylermurphy.hideAndSeek.Store.*;
import java.util.HashMap;
public class Start implements ICommand { public class Start implements ICommand {
public void execute(CommandSender sender, String[] args) { public void execute(CommandSender sender, String[] args) {
@ -39,8 +37,6 @@ public class Start implements ICommand {
return; return;
} }
Functions.setGamerules();
for(Player player : playerList.values()) { for(Player player : playerList.values()) {
player.getInventory().clear(); player.getInventory().clear();
player.setGameMode(GameMode.ADVENTURE); player.setGameMode(GameMode.ADVENTURE);
@ -49,7 +45,7 @@ public class Start implements ICommand {
player.removePotionEffect(effect.getType()); player.removePotionEffect(effect.getType());
} }
} }
Bukkit.getServer().dispatchCommand(Bukkit.getConsoleSender(), String.format("spawnpoint @a %s %s %s", spawnPosition.getBlockX(), spawnPosition.getBlockY(), spawnPosition.getBlockZ())); //Bukkit.getServer().dispatchCommand(Bukkit.getConsoleSender(), String.format("spawnpoint @a %s %s %s", spawnPosition.getBlockX(), spawnPosition.getBlockY(), spawnPosition.getBlockZ()));
for(String playerName : Seeker.getEntries()) { for(String playerName : Seeker.getEntries()) {
Player player = playerList.get(playerName); Player player = playerList.get(playerName);
if(player != null) { if(player != null) {
@ -65,34 +61,62 @@ public class Start implements ICommand {
} }
WorldborderManager.reset(); WorldborderManager.reset();
status = "Starting"; status = "Starting";
Bukkit.getServer().getScheduler().runTaskAsynchronously(Main.plugin, new Runnable(){ int temp = gameId;
Bukkit.getServer().broadcastMessage(messagePrefix + "Hiders have 30 seconds to hide!");
Bukkit.getServer().getScheduler().runTaskLater(Main.plugin, new Runnable() {
public void run() { public void run() {
int temp = gameId;
Bukkit.getServer().broadcastMessage(messagePrefix + "Hiders have 30 seconds to hide!");
try { Thread.sleep(10*1000); } catch (InterruptedException e) {}
if(temp != gameId) return; if(temp != gameId) return;
Bukkit.getServer().broadcastMessage(messagePrefix + "Hiders have 20 seconds to hide!"); Bukkit.getServer().broadcastMessage(messagePrefix + "Hiders have 20 seconds to hide!");
try { Thread.sleep(10*1000); } catch (InterruptedException e) {} }
}, 20 * 10);
Bukkit.getServer().getScheduler().runTaskLater(Main.plugin, new Runnable() {
public void run() {
if(temp != gameId) return; if(temp != gameId) return;
Bukkit.getServer().broadcastMessage(messagePrefix + "Hiders have 10 seconds to hide!"); Bukkit.getServer().broadcastMessage(messagePrefix + "Hiders have 10 seconds to hide!");
try { Thread.sleep(5*1000); } catch (InterruptedException e) {} }
}, 20 * 20);
Bukkit.getServer().getScheduler().runTaskLater(Main.plugin, new Runnable() {
public void run() {
if(temp != gameId) return; if(temp != gameId) return;
Bukkit.getServer().broadcastMessage(messagePrefix + "Hiders have 5 seconds to hide!"); Bukkit.getServer().broadcastMessage(messagePrefix + "Hiders have 5 seconds to hide!");
try { Thread.sleep(2*1000); } catch (InterruptedException e) {} }
}, 20 * 25);
Bukkit.getServer().getScheduler().runTaskLater(Main.plugin, new Runnable() {
public void run() {
if(temp != gameId) return; if(temp != gameId) return;
Bukkit.getServer().broadcastMessage(messagePrefix + "Hiders have 3 seconds to hide!"); Bukkit.getServer().broadcastMessage(messagePrefix + "Hiders have 3 seconds to hide!");
try { Thread.sleep(1*1000); } catch (InterruptedException e) {} }
}, 20 * 27);
Bukkit.getServer().getScheduler().runTaskLater(Main.plugin, new Runnable() {
public void run() {
if(temp != gameId) return; if(temp != gameId) return;
Bukkit.getServer().broadcastMessage(messagePrefix + "Hiders have 2 seconds to hide!"); Bukkit.getServer().broadcastMessage(messagePrefix + "Hiders have 2 seconds to hide!");
try { Thread.sleep(1*1000); } catch (InterruptedException e) {} }
}, 20 * 28);
Bukkit.getServer().getScheduler().runTaskLater(Main.plugin, new Runnable() {
public void run() {
if(temp != gameId) return; if(temp != gameId) return;
Bukkit.getServer().broadcastMessage(messagePrefix + "Hiders have 1 seconds to hide!"); Bukkit.getServer().broadcastMessage(messagePrefix + "Hiders have 1 seconds to hide!");
try { Thread.sleep(1*1000); } catch (InterruptedException e) {} }
}, 20 * 29);
Bukkit.getServer().getScheduler().runTaskLater(Main.plugin, new Runnable() {
public void run() {
if(temp != gameId) return; if(temp != gameId) return;
Bukkit.getServer().broadcastMessage(messagePrefix + "Attetion SEEKERS, its time to find the hiders!"); Bukkit.getServer().broadcastMessage(messagePrefix + "Attetion SEEKERS, its time to find the hiders!");
status = "Playing"; status = "Playing";
for(Player player : playerList.values()) {
Functions.resetPlayer(player);
}
} }
}); }, 20 * 30);
if(worldborderEnabled) { if(worldborderEnabled) {
WorldborderManager.schedule(); WorldborderManager.schedule();
} }

View file

@ -33,6 +33,7 @@ public class Stop implements ICommand {
public static void onStop() { public static void onStop() {
if(status.equals("Standby") || status.equals("Setup")) return; if(status.equals("Standby") || status.equals("Setup")) return;
status = "Standby"; status = "Standby";
gameId++;
for(Player player : playerList.values()) { for(Player player : playerList.values()) {
player.setGameMode(GameMode.ADVENTURE); player.setGameMode(GameMode.ADVENTURE);
Hider.addEntry(player.getName()); Hider.addEntry(player.getName());
@ -44,7 +45,6 @@ public class Stop implements ICommand {
player.addPotionEffect(new PotionEffect(PotionEffectType.HEAL, 1, 100)); player.addPotionEffect(new PotionEffect(PotionEffectType.HEAL, 1, 100));
} }
WorldborderManager.reset(); WorldborderManager.reset();
gameId++;
} }
public String getUsage() { public String getUsage() {

View file

@ -1,40 +0,0 @@
package net.tylermurphy.hideAndSeek.manager;
import static net.tylermurphy.hideAndSeek.Store.*;
import org.bukkit.Bukkit;
import org.bukkit.ChatColor;
import org.bukkit.scoreboard.Scoreboard;
import org.bukkit.scoreboard.ScoreboardManager;
import org.bukkit.scoreboard.Team.Option;
import org.bukkit.scoreboard.Team.OptionStatus;
public class BoardManager {
public static void loadScoreboard() {
ScoreboardManager manager = Bukkit.getScoreboardManager();
Scoreboard mainBoard = manager.getMainScoreboard();
try { mainBoard.registerNewTeam("Seeker");} catch(Exception e) {}
Seeker = mainBoard.getTeam("Seeker");
Seeker.setColor(ChatColor.RED);
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);
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;
}
}

View file

@ -5,26 +5,29 @@ import static net.tylermurphy.hideAndSeek.Store.*;
import org.bukkit.Bukkit; import org.bukkit.Bukkit;
import org.bukkit.GameMode; import org.bukkit.GameMode;
import org.bukkit.Location; import org.bukkit.Location;
import org.bukkit.Material;
import org.bukkit.Sound;
import org.bukkit.attribute.Attribute;
import org.bukkit.entity.Player; import org.bukkit.entity.Player;
import org.bukkit.entity.Snowball; import org.bukkit.entity.Snowball;
import org.bukkit.event.EventHandler; import org.bukkit.event.EventHandler;
import org.bukkit.event.Listener; import org.bukkit.event.Listener;
import org.bukkit.event.entity.PlayerDeathEvent; import org.bukkit.event.entity.EntityDamageEvent;
import org.bukkit.event.entity.EntityRegainHealthEvent;
import org.bukkit.event.entity.EntityRegainHealthEvent.RegainReason;
import org.bukkit.event.entity.ProjectileLaunchEvent; import org.bukkit.event.entity.ProjectileLaunchEvent;
import org.bukkit.event.player.PlayerJoinEvent; import org.bukkit.event.player.PlayerJoinEvent;
import org.bukkit.event.player.PlayerQuitEvent; import org.bukkit.event.player.PlayerQuitEvent;
import org.bukkit.potion.PotionEffect; import org.bukkit.potion.PotionEffect;
import net.md_5.bungee.api.ChatColor; import net.md_5.bungee.api.ChatColor;
import net.tylermurphy.hideAndSeek.Main;
import net.tylermurphy.hideAndSeek.util.Functions; import net.tylermurphy.hideAndSeek.util.Functions;
public class EventManager implements Listener { public class EventManager implements Listener {
@EventHandler @EventHandler
public void onPlayerJoin(PlayerJoinEvent event) { public void onPlayerJoin(PlayerJoinEvent event) {
if(Bukkit.getScoreboardManager() != null && board == null) {
BoardManager.loadScoreboard();
}
if(status.equals("Playing") || status.equals("Starting")) { if(status.equals("Playing") || status.equals("Starting")) {
Spectator.addEntry(event.getPlayer().getName()); Spectator.addEntry(event.getPlayer().getName());
event.getPlayer().sendMessage(messagePrefix + "You have joined mid game, and thus have been placed on the spectator team."); event.getPlayer().sendMessage(messagePrefix + "You have joined mid game, and thus have been placed on the spectator team.");
@ -49,18 +52,28 @@ public class EventManager implements Listener {
} }
@EventHandler @EventHandler
public void onDeath(PlayerDeathEvent event) { public void onPlayerDamage(EntityDamageEvent event) {
if(status.equals("Playing")) { if(event.getEntity() instanceof Player) {
if(Hider.hasEntry(event.getEntity().getName())) { Player player = (Player) event.getEntity();
Bukkit.getServer().broadcastMessage(String.format(messagePrefix + "%s%s%s has died and become a seeker", ChatColor.GOLD, event.getEntity().getName(), ChatColor.WHITE)); if(player.getHealth()-event.getDamage() < 0) {
if(spawnPosition == null) return;
event.setCancelled(true);
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());
}
} }
if(Seeker.hasEntry(event.getEntity().getName())) {
Bukkit.getServer().broadcastMessage(String.format(messagePrefix + "%s%s%s has been beat by a hider", ChatColor.RED, event.getEntity().getName(), ChatColor.WHITE));
}
Functions.giveItems(event.getEntity());
Seeker.addEntry(event.getEntity().getName());
} }
} }
@EventHandler @EventHandler
@ -73,9 +86,22 @@ public class EventManager implements Listener {
if(Hider.hasEntry(player.getName())) { if(Hider.hasEntry(player.getName())) {
glowTime++; glowTime++;
snowball.remove(); snowball.remove();
player.getInventory().remove(Material.SNOWBALL);
int temp = gameId;
Bukkit.getServer().getScheduler().runTaskLater(Main.plugin, new Runnable() {
public void run() {
if(temp != gameId) return;
glowTime--;
}
}, 20 * 30);
} }
} }
} }
} }
@EventHandler
public void onPlayerRegainHealth(EntityRegainHealthEvent event) {
if(event.getRegainReason() == RegainReason.SATIATED || event.getRegainReason() == RegainReason.REGEN)
event.setCancelled(true);
}
} }

View file

@ -7,6 +7,9 @@ import org.bukkit.ChatColor;
import org.bukkit.Color; import org.bukkit.Color;
import org.bukkit.FireworkEffect; import org.bukkit.FireworkEffect;
import org.bukkit.Location; import org.bukkit.Location;
import org.bukkit.Sound;
import org.bukkit.World;
import org.bukkit.WorldBorder;
import org.bukkit.entity.EntityType; import org.bukkit.entity.EntityType;
import org.bukkit.entity.Firework; import org.bukkit.entity.Firework;
import org.bukkit.entity.Player; import org.bukkit.entity.Player;
@ -23,9 +26,11 @@ public class TickManager {
public static void onTick() { public static void onTick() {
if(board == null) return; if(board == null) {
Functions.loadScoreboard();
}
Functions.checkTeams(); Functions.emptyOfflinePlayers();
for(Player player : playerList.values()) { for(Player player : playerList.values()) {
player.addPotionEffect(new PotionEffect(PotionEffectType.SATURATION, 1000000, 127, false, false)); player.addPotionEffect(new PotionEffect(PotionEffectType.SATURATION, 1000000, 127, false, false));
@ -41,11 +46,11 @@ public class TickManager {
tick ++; tick ++;
if(Hider.getSize() < 1) { if(( status.equals("Starting") || status.equals("Playing") ) && Hider.getSize() < 1) {
Bukkit.broadcastMessage(messagePrefix + "Game over! All hiders have been found."); Bukkit.broadcastMessage(messagePrefix + "Game over! All hiders have been found.");
Stop.onStop(); Stop.onStop();
} }
if(Seeker.getSize() < 1) { if(( status.equals("Starting") || status.equals("Playing") ) && Seeker.getSize() < 1) {
Bukkit.broadcastMessage(messagePrefix + "Game has ended as all seekers have quit."); Bukkit.broadcastMessage(messagePrefix + "Game has ended as all seekers have quit.");
Stop.onStop(); Stop.onStop();
} }
@ -55,6 +60,7 @@ public class TickManager {
for(Player player : playerList.values()) { for(Player player : playerList.values()) {
player.addPotionEffect(new PotionEffect(PotionEffectType.REGENERATION, 1000000, 127, false, false)); player.addPotionEffect(new PotionEffect(PotionEffectType.REGENERATION, 1000000, 127, false, false));
} }
} }
private static void onStarting() { private static void onStarting() {
@ -68,7 +74,9 @@ public class TickManager {
private static void onPlaying() { private static void onPlaying() {
if(decreaseBorder) { if(decreaseBorder) {
Bukkit.getServer().dispatchCommand(Bukkit.getConsoleSender(), "worldborder add -100 30"); World world = Bukkit.getWorld("world");
WorldBorder border = world.getWorldBorder();
border.setSize(border.getSize()-100,30);
decreaseBorder = false; decreaseBorder = false;
} }
if(!tauntPlayer.equals("")) { if(!tauntPlayer.equals("")) {
@ -122,29 +130,23 @@ public class TickManager {
distance = temp; distance = temp;
} }
} }
int x = player.getLocation().getBlockX();
int y = player.getLocation().getBlockY();
int z = player.getLocation().getBlockZ();
switch(tick%10) { switch(tick%10) {
case 0: case 0:
if(distance < 30) Bukkit.getServer().dispatchCommand(Bukkit.getConsoleSender(), String.format("playsound minecraft:block.note_block.basedrum master %s %s %s %s .5 1",player.getName(),x,y,z)); if(distance < 30) Functions.playSound(player, Sound.BLOCK_NOTE_BLOCK_BASEDRUM, .5f, 1f);
if(distance < 10) Bukkit.getServer().dispatchCommand(Bukkit.getConsoleSender(), String.format("playsound minecraft:block.note_block.bit master %s %s %s %s .3 1",player.getName(),x,y,z)); if(distance < 10) Functions.playSound(player, Sound.BLOCK_NOTE_BLOCK_BIT, .3f, 1f);
break; break;
case 3: case 3:
if(distance < 30) Bukkit.getServer().dispatchCommand(Bukkit.getConsoleSender(), String.format("playsound minecraft:block.note_block.basedrum master %s %s %s %s 3.31",player.getName(),x,y,z)); if(distance < 30) Functions.playSound(player, Sound.BLOCK_NOTE_BLOCK_BASEDRUM, .3f, 1f);
if(distance < 10) Bukkit.getServer().dispatchCommand(Bukkit.getConsoleSender(), String.format("playsound minecraft:block.note_block.bit master %s %s %s %s .3 1",player.getName(),x,y,z)); if(distance < 10) Functions.playSound(player, Sound.BLOCK_NOTE_BLOCK_BIT, .3f, 1f);
break; break;
case 6: case 6:
if(distance < 10) Bukkit.getServer().dispatchCommand(Bukkit.getConsoleSender(), String.format("playsound minecraft:block.note_block.bit master %s %s %s %s .3 1",player.getName(),x,y,z)); if(distance < 10) Functions.playSound(player, Sound.BLOCK_NOTE_BLOCK_BIT, .3f, 1f);
break; break;
case 9: case 9:
if(distance < 20) Bukkit.getServer().dispatchCommand(Bukkit.getConsoleSender(), String.format("playsound minecraft:block.note_block.bit master %s %s %s %s .3 1",player.getName(),x,y,z)); if(distance < 20) Functions.playSound(player, Sound.BLOCK_NOTE_BLOCK_BIT, .3f, 1f);
break; break;
} }
} }
if(tick%(20*30) == 0) {
glowTime = Math.max(0, glowTime--);
}
} }
} }

View file

@ -3,6 +3,8 @@ package net.tylermurphy.hideAndSeek.manager;
import static net.tylermurphy.hideAndSeek.Store.*; import static net.tylermurphy.hideAndSeek.Store.*;
import org.bukkit.Bukkit; import org.bukkit.Bukkit;
import org.bukkit.World;
import org.bukkit.WorldBorder;
import net.md_5.bungee.api.ChatColor; import net.md_5.bungee.api.ChatColor;
import net.tylermurphy.hideAndSeek.Main; import net.tylermurphy.hideAndSeek.Main;
@ -32,12 +34,16 @@ public class WorldborderManager {
public static void reset() { public static void reset() {
if(worldborderEnabled) { if(worldborderEnabled) {
Bukkit.getServer().dispatchCommand(Bukkit.getConsoleSender(), "worldborder set "+worldborderSize); World world = Bukkit.getWorld("world");
Bukkit.getServer().dispatchCommand(Bukkit.getConsoleSender(), String.format("worldborder center %s %s",worldborderPosition.getBlockX(),worldborderPosition.getBlockZ())); WorldBorder border = world.getWorldBorder();
border.setSize(worldborderSize);
border.setCenter(worldborderPosition.getX(), worldborderPosition.getZ());
currentWorldborderSize = worldborderSize; currentWorldborderSize = worldborderSize;
} else { } else {
Bukkit.getServer().dispatchCommand(Bukkit.getConsoleSender(), "worldborder set 30000000"); World world = Bukkit.getWorld("world");
Bukkit.getServer().dispatchCommand(Bukkit.getConsoleSender(), "worldborder center 0 0"); WorldBorder border = world.getWorldBorder();
border.setSize(30000000);
border.setCenter(0, 0);
} }
} }

View file

@ -6,12 +6,14 @@ import static net.tylermurphy.hideAndSeek.Store.Spectator;
import static net.tylermurphy.hideAndSeek.Store.board; import static net.tylermurphy.hideAndSeek.Store.board;
import static net.tylermurphy.hideAndSeek.Store.playerList; import static net.tylermurphy.hideAndSeek.Store.playerList;
import java.lang.reflect.InvocationTargetException;
import java.util.ArrayList; import java.util.ArrayList;
import java.util.List; import java.util.List;
import org.bukkit.Bukkit; import org.bukkit.Bukkit;
import org.bukkit.ChatColor; import org.bukkit.ChatColor;
import org.bukkit.Material; import org.bukkit.Material;
import org.bukkit.Sound;
import org.bukkit.enchantments.Enchantment; import org.bukkit.enchantments.Enchantment;
import org.bukkit.entity.Player; import org.bukkit.entity.Player;
import org.bukkit.inventory.ItemStack; import org.bukkit.inventory.ItemStack;
@ -20,21 +22,22 @@ import org.bukkit.inventory.meta.PotionMeta;
import org.bukkit.potion.PotionData; import org.bukkit.potion.PotionData;
import org.bukkit.potion.PotionEffect; import org.bukkit.potion.PotionEffect;
import org.bukkit.potion.PotionType; import org.bukkit.potion.PotionType;
import org.bukkit.scoreboard.Scoreboard;
import org.bukkit.scoreboard.ScoreboardManager;
import org.bukkit.scoreboard.Team.Option; import org.bukkit.scoreboard.Team.Option;
import org.bukkit.scoreboard.Team.OptionStatus; import org.bukkit.scoreboard.Team.OptionStatus;
public class Functions { import com.comphenix.protocol.PacketType;
import com.comphenix.protocol.ProtocolLibrary;
import com.comphenix.protocol.ProtocolManager;
import com.comphenix.protocol.events.PacketContainer;
import com.comphenix.protocol.wrappers.EnumWrappers.SoundCategory;
public static void setGamerules() { public class Functions {
Bukkit.getServer().dispatchCommand(Bukkit.getConsoleSender(), "gamerule sendCommandFeedback false");
Bukkit.getServer().dispatchCommand(Bukkit.getConsoleSender(), "gamerule doImmediateRespawn true");
Bukkit.getServer().dispatchCommand(Bukkit.getConsoleSender(), "gamerule logAdminCommands false");
Bukkit.getServer().dispatchCommand(Bukkit.getConsoleSender(), "gamerule naturalRegeneration false");
Bukkit.getServer().dispatchCommand(Bukkit.getConsoleSender(), "gamerule keepInventory true");
Bukkit.getServer().dispatchCommand(Bukkit.getConsoleSender(), "gamerule showDeathMessages false");
}
public static void giveItems(Player player) { private static ProtocolManager protocolManager = ProtocolLibrary.getProtocolManager();
public static void resetPlayer(Player player) {
player.getInventory().clear(); player.getInventory().clear();
for(PotionEffect effect : player.getActivePotionEffects()){ for(PotionEffect effect : player.getActivePotionEffects()){
player.removePotionEffect(effect.getType()); player.removePotionEffect(effect.getType());
@ -84,37 +87,11 @@ public class Functions {
snowballLore.add("Last 30s, all hiders can see it"); snowballLore.add("Last 30s, all hiders can see it");
snowballLore.add("Time stacks on multi use"); snowballLore.add("Time stacks on multi use");
snowballMeta.setLore(snowballLore); snowballMeta.setLore(snowballLore);
player.getInventory().addItem(snowball);
} }
} }
public static void checkTeams() { public static void emptyOfflinePlayers() {
try { Hider.getSize(); }
catch (Exception e) {
board.registerNewTeam("Hider");
Hider = board.getTeam("Hider");
Hider.setColor(ChatColor.GOLD);
Hider.setOption(Option.NAME_TAG_VISIBILITY, OptionStatus.NEVER);
Hider.setAllowFriendlyFire(false);
}
try { Seeker.getSize(); }
catch (Exception e) {
board.registerNewTeam("Seeker");
Seeker = board.getTeam("Seeker");
Seeker.setColor(ChatColor.RED);
Seeker.setOption(Option.NAME_TAG_VISIBILITY, OptionStatus.NEVER);
Seeker.setAllowFriendlyFire(false);
}
try { Spectator.getSize(); }
catch (Exception e) {
board.registerNewTeam("Spectator");
Spectator = board.getTeam("Spectator");
Spectator.setColor(ChatColor.GRAY);
Spectator.setOption(Option.NAME_TAG_VISIBILITY, OptionStatus.NEVER);
Spectator.setAllowFriendlyFire(false);
}
for(String entry : Hider.getEntries()) { for(String entry : Hider.getEntries()) {
if(!playerList.containsKey(entry)) { if(!playerList.containsKey(entry)) {
@ -135,4 +112,46 @@ public class Functions {
} }
} }
public static void loadScoreboard() {
ScoreboardManager manager = Bukkit.getScoreboardManager();
Scoreboard mainBoard = manager.getMainScoreboard();
try { mainBoard.registerNewTeam("Seeker");} catch(Exception e) {}
Seeker = mainBoard.getTeam("Seeker");
Seeker.setColor(ChatColor.RED);
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);
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;
}
public static void playSound(Player player, Sound sound, float volume, float pitch) {
PacketContainer packet = protocolManager.createPacket(PacketType.Play.Server.NAMED_SOUND_EFFECT);
packet.getSoundCategories().write(0, SoundCategory.MASTER);
packet.getSoundEffects().write(0, sound);
packet.getIntegers().write(0, (int)(player.getLocation().getX() * 8.0));
packet.getIntegers().write(1, (int)(player.getLocation().getY() * 8.0));
packet.getIntegers().write(2, (int)(player.getLocation().getZ() * 8.0));
packet.getFloat().write(0, volume);
packet.getFloat().write(1, pitch);
try {
protocolManager.sendServerPacket(player, packet);
} catch (InvocationTargetException e) {
e.printStackTrace();
}
}
} }

View file

@ -1,8 +1,10 @@
name: HideAndSeek name: HideAndSeek
main: net.tylermurphy.hideAndSeek.Main main: net.tylermurphy.hideAndSeek.Main
version: 1.0 version: 1.1.0
author: KenshinEto author: KenshinEto
load: STARTUP load: STARTUP
api-version: 1.17
depend: [ProtocolLib]
commands: commands:
hideandseek: hideandseek:
description: Hide and Seek command description: Hide and Seek command