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

View file

@ -14,6 +14,7 @@ import org.bukkit.util.Vector;
import net.tylermurphy.hideAndSeek.manager.CommandManager;
import net.tylermurphy.hideAndSeek.manager.EventManager;
import net.tylermurphy.hideAndSeek.manager.TickManager;
import net.tylermurphy.hideAndSeek.util.Functions;
public class Main extends JavaPlugin implements Listener {
@ -43,14 +44,6 @@ public class Main extends JavaPlugin implements Listener {
}
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
CommandManager.registerCommands();

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.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("%sHelp Command: %s/hs %shelp", ChatColor.GRAY, ChatColor.AQUA, ChatColor.WHITE)
);

View file

@ -1,6 +1,5 @@
package net.tylermurphy.hideAndSeek.commands;
import org.bukkit.Bukkit;
import org.bukkit.command.CommandSender;
import org.bukkit.entity.Player;
import org.bukkit.util.Vector;
@ -26,8 +25,8 @@ public class SetSpawnLocation implements ICommand {
sender.sendMessage(messagePrefix + "Set spawn position to current location");
getConfig().set("spawnPosition", newSpawnPosition);
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("spawnpoint @a %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()));
}
public String getLabel() {

View file

@ -17,8 +17,6 @@ import net.tylermurphy.hideAndSeek.util.Functions;
import static net.tylermurphy.hideAndSeek.Store.*;
import java.util.HashMap;
public class Start implements ICommand {
public void execute(CommandSender sender, String[] args) {
@ -39,8 +37,6 @@ public class Start implements ICommand {
return;
}
Functions.setGamerules();
for(Player player : playerList.values()) {
player.getInventory().clear();
player.setGameMode(GameMode.ADVENTURE);
@ -49,7 +45,7 @@ public class Start implements ICommand {
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()) {
Player player = playerList.get(playerName);
if(player != null) {
@ -65,34 +61,62 @@ public class Start implements ICommand {
}
WorldborderManager.reset();
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() {
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;
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;
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;
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;
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;
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;
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;
Bukkit.getServer().broadcastMessage(messagePrefix + "Attetion SEEKERS, its time to find the hiders!");
status = "Playing";
for(Player player : playerList.values()) {
Functions.resetPlayer(player);
}
}
});
}, 20 * 30);
if(worldborderEnabled) {
WorldborderManager.schedule();
}

View file

@ -33,6 +33,7 @@ public class Stop implements ICommand {
public static void onStop() {
if(status.equals("Standby") || status.equals("Setup")) return;
status = "Standby";
gameId++;
for(Player player : playerList.values()) {
player.setGameMode(GameMode.ADVENTURE);
Hider.addEntry(player.getName());
@ -44,7 +45,6 @@ public class Stop implements ICommand {
player.addPotionEffect(new PotionEffect(PotionEffectType.HEAL, 1, 100));
}
WorldborderManager.reset();
gameId++;
}
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.GameMode;
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.Snowball;
import org.bukkit.event.EventHandler;
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.player.PlayerJoinEvent;
import org.bukkit.event.player.PlayerQuitEvent;
import org.bukkit.potion.PotionEffect;
import net.md_5.bungee.api.ChatColor;
import net.tylermurphy.hideAndSeek.Main;
import net.tylermurphy.hideAndSeek.util.Functions;
public class EventManager implements Listener {
@EventHandler
public void onPlayerJoin(PlayerJoinEvent event) {
if(Bukkit.getScoreboardManager() != null && board == null) {
BoardManager.loadScoreboard();
}
if(status.equals("Playing") || status.equals("Starting")) {
Spectator.addEntry(event.getPlayer().getName());
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
public void onDeath(PlayerDeathEvent event) {
if(status.equals("Playing")) {
if(Hider.hasEntry(event.getEntity().getName())) {
Bukkit.getServer().broadcastMessage(String.format(messagePrefix + "%s%s%s has died and become a seeker", ChatColor.GOLD, event.getEntity().getName(), ChatColor.WHITE));
public void onPlayerDamage(EntityDamageEvent event) {
if(event.getEntity() instanceof Player) {
Player player = (Player) event.getEntity();
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
@ -73,9 +86,22 @@ public class EventManager implements Listener {
if(Hider.hasEntry(player.getName())) {
glowTime++;
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.FireworkEffect;
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.Firework;
import org.bukkit.entity.Player;
@ -23,9 +26,11 @@ public class TickManager {
public static void onTick() {
if(board == null) return;
if(board == null) {
Functions.loadScoreboard();
}
Functions.checkTeams();
Functions.emptyOfflinePlayers();
for(Player player : playerList.values()) {
player.addPotionEffect(new PotionEffect(PotionEffectType.SATURATION, 1000000, 127, false, false));
@ -41,11 +46,11 @@ public class TickManager {
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.");
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.");
Stop.onStop();
}
@ -55,6 +60,7 @@ public class TickManager {
for(Player player : playerList.values()) {
player.addPotionEffect(new PotionEffect(PotionEffectType.REGENERATION, 1000000, 127, false, false));
}
}
private static void onStarting() {
@ -68,7 +74,9 @@ public class TickManager {
private static void onPlaying() {
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;
}
if(!tauntPlayer.equals("")) {
@ -122,29 +130,23 @@ public class TickManager {
distance = temp;
}
}
int x = player.getLocation().getBlockX();
int y = player.getLocation().getBlockY();
int z = player.getLocation().getBlockZ();
switch(tick%10) {
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 < 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 < 30) Functions.playSound(player, Sound.BLOCK_NOTE_BLOCK_BASEDRUM, .5f, 1f);
if(distance < 10) Functions.playSound(player, Sound.BLOCK_NOTE_BLOCK_BIT, .3f, 1f);
break;
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 < 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 < 30) Functions.playSound(player, Sound.BLOCK_NOTE_BLOCK_BASEDRUM, .3f, 1f);
if(distance < 10) Functions.playSound(player, Sound.BLOCK_NOTE_BLOCK_BIT, .3f, 1f);
break;
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;
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;
}
}
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 org.bukkit.Bukkit;
import org.bukkit.World;
import org.bukkit.WorldBorder;
import net.md_5.bungee.api.ChatColor;
import net.tylermurphy.hideAndSeek.Main;
@ -32,12 +34,16 @@ public class WorldborderManager {
public static void reset() {
if(worldborderEnabled) {
Bukkit.getServer().dispatchCommand(Bukkit.getConsoleSender(), "worldborder set "+worldborderSize);
Bukkit.getServer().dispatchCommand(Bukkit.getConsoleSender(), String.format("worldborder center %s %s",worldborderPosition.getBlockX(),worldborderPosition.getBlockZ()));
World world = Bukkit.getWorld("world");
WorldBorder border = world.getWorldBorder();
border.setSize(worldborderSize);
border.setCenter(worldborderPosition.getX(), worldborderPosition.getZ());
currentWorldborderSize = worldborderSize;
} else {
Bukkit.getServer().dispatchCommand(Bukkit.getConsoleSender(), "worldborder set 30000000");
Bukkit.getServer().dispatchCommand(Bukkit.getConsoleSender(), "worldborder center 0 0");
World world = Bukkit.getWorld("world");
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.playerList;
import java.lang.reflect.InvocationTargetException;
import java.util.ArrayList;
import java.util.List;
import org.bukkit.Bukkit;
import org.bukkit.ChatColor;
import org.bukkit.Material;
import org.bukkit.Sound;
import org.bukkit.enchantments.Enchantment;
import org.bukkit.entity.Player;
import org.bukkit.inventory.ItemStack;
@ -20,21 +22,22 @@ import org.bukkit.inventory.meta.PotionMeta;
import org.bukkit.potion.PotionData;
import org.bukkit.potion.PotionEffect;
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.OptionStatus;
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 class Functions {
public static void setGamerules() {
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");
}
private static ProtocolManager protocolManager = ProtocolLibrary.getProtocolManager();
public static void giveItems(Player player) {
public static void resetPlayer(Player player) {
player.getInventory().clear();
for(PotionEffect effect : player.getActivePotionEffects()){
player.removePotionEffect(effect.getType());
@ -84,37 +87,11 @@ public class Functions {
snowballLore.add("Last 30s, all hiders can see it");
snowballLore.add("Time stacks on multi use");
snowballMeta.setLore(snowballLore);
player.getInventory().addItem(snowball);
}
}
public static void checkTeams() {
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);
}
public static void emptyOfflinePlayers() {
for(String entry : Hider.getEntries()) {
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
main: net.tylermurphy.hideAndSeek.Main
version: 1.0
version: 1.1.0
author: KenshinEto
load: STARTUP
api-version: 1.17
depend: [ProtocolLib]
commands:
hideandseek:
description: Hide and Seek command