1.4.0 initial

This commit is contained in:
Tyler Murphy 2022-04-11 12:36:11 -04:00
parent 31d60d7d23
commit e9daa95473
17 changed files with 579 additions and 73 deletions

58
pom.xml
View file

@ -1,8 +1,11 @@
<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.3.3</version>
<version>1.4.0</version>
<name>Hide and Seek Plugin</name>
<properties>
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
</properties>
<build>
<plugins>
<plugin>
@ -14,6 +17,50 @@
<target>8</target>
</configuration>
</plugin>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-shade-plugin</artifactId>
<version>3.2.4</version>
<configuration>
<createDependencyReducedPom>false</createDependencyReducedPom>
<relocations>
<relocation>
<pattern>com.cryptomorin.xseries</pattern>
<shadedPattern>net.tylermurphy.hideAndSeek.util.xseries</shadedPattern>
</relocation>
</relocations>
<artifactSet>
<includes>
<include>com.github.cryptomorin:XSeries</include>
<include>org.xerial:sqlite-jdbc</include>
</includes>
</artifactSet>
<filters>
<filter>
<artifact>*:*</artifact>
<excludes>
<exclude>META-INF/*.MF</exclude>
<exclude>com/cryptomorin/xseries/XBiome*</exclude>
<exclude>com/cryptomorin/xseries/NMSExtras*</exclude>
<exclude>com/cryptomorin/xseries/NoteBlockMusic*</exclude>
<exclude>com/cryptomorin/xseries/SkullCacheListener*</exclude>
<exclude>com/cryptomorin/xseries/XBlock*</exclude>
<exclude>com/cryptomorin/xseries/XEntity*</exclude>
<exclude>com/cryptomorin/xseries/particles/*</exclude>
<exclude>com/cryptomorin/xseries/messages/ActionBar*</exclude>
</excludes>
</filter>
</filters>
</configuration>
<executions>
<execution>
<phase>package</phase>
<goals>
<goal>shade</goal>
</goals>
</execution>
</executions>
</plugin>
</plugins>
</build>
<repositories>
@ -30,7 +77,7 @@
<dependency>
<groupId>org.spigotmc</groupId>
<artifactId>spigot-api</artifactId>
<version>1.18.1-R0.1-SNAPSHOT</version>
<version>1.9-R0.1-SNAPSHOT</version>
<type>jar</type>
<scope>provided</scope>
</dependency>
@ -43,11 +90,18 @@
<groupId>org.xerial</groupId>
<artifactId>sqlite-jdbc</artifactId>
<version>3.36.0.3</version>
<type>jar</type>
<scope>provided</scope>
</dependency>
<dependency>
<groupId>org.jetbrains</groupId>
<artifactId>annotations</artifactId>
<version>23.0.0</version>
</dependency>
<dependency>
<groupId>com.github.cryptomorin</groupId>
<artifactId>XSeries</artifactId>
<version>8.7.1</version>
</dependency>
</dependencies>
</project>

View file

@ -26,7 +26,7 @@ public class About implements ICommand {
public void execute(CommandSender sender, String[] args) {
sender.sendMessage(
String.format("%s%sHide and Seek %s(%s1.3.3%s)\n", ChatColor.AQUA, ChatColor.BOLD, ChatColor.GRAY,ChatColor.WHITE,ChatColor.GRAY) +
String.format("%s%sHide and Seek %s(%s1.4.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

@ -19,6 +19,7 @@
package net.tylermurphy.hideAndSeek.configuration;
import net.tylermurphy.hideAndSeek.util.Version;
import org.bukkit.util.Vector;
public class Config {
@ -36,7 +37,7 @@ public class Config {
spawnWorld,
exitWorld,
lobbyWorld,
local;
locale;
public static Vector
spawnPosition,
@ -57,7 +58,8 @@ public class Config {
pvpEnabled,
autoJoin,
teleportToExit,
lobbyCountdownEnabled;
lobbyCountdownEnabled,
seekerPing;
public static int
minPlayers,
@ -74,7 +76,10 @@ public class Config {
countdown,
changeCountdown,
lobbyMin,
lobbyMax;
lobbyMax,
seekerPingLevel1,
seekerPingLevel2,
seekerPingLevel3;
public static void loadConfig() {
@ -143,7 +148,7 @@ public class Config {
//Glow
glowLength = Math.max(1,manager.getInt("glow.time"));
glowStackable = manager.getBoolean("glow.stackable");
glowEnabled = manager.getBoolean("glow.enabled");
glowEnabled = manager.getBoolean("glow.enabled") && Version.atLeast("1.9");
//Lobby
minPlayers = Math.max(2, manager.getInt("minPlayers"));
@ -153,6 +158,12 @@ public class Config {
lobbyMax = manager.getInt("lobby.max");
lobbyCountdownEnabled = manager.getBoolean("lobby.enabled");
//SeekerPing
seekerPing = manager.getBoolean("seekerPing.enabled");
seekerPingLevel1 = manager.getInt("seekerPing.distances.level1");
seekerPingLevel2 = manager.getInt("seekerPing.distances.level2");
seekerPingLevel3 = manager.getInt("seekerPing.distances.level3");
//Other
nametagsVisible = manager.getBoolean("nametagsVisible");
permissionsRequired = manager.getBoolean("permissionsRequired");
@ -160,7 +171,7 @@ public class Config {
pvpEnabled = manager.getBoolean("pvp");
autoJoin = manager.getBoolean("autoJoin");
teleportToExit = manager.getBoolean("teleportToExit");
local = manager.getString("local");
locale = manager.getString("locale", "local");
}
public static void addToConfig(String path, Object value) {

View file

@ -130,6 +130,20 @@ public class ConfigManager {
}
}
public String getString(String path, String oldPath){
String value = config.getString(path);
if(value == null){
String oldValue = config.getString(oldPath);
if(oldValue == null){
return defaultConfig.getString(path);
} else {
return oldValue;
}
} else {
return value;
}
}
public void reset(String path){
config.set(path, defaultConfig.get(path));
}

View file

@ -19,9 +19,13 @@
package net.tylermurphy.hideAndSeek.configuration;
import com.cryptomorin.xseries.XEnchantment;
import com.cryptomorin.xseries.XMaterial;
import com.cryptomorin.xseries.XPotion;
import net.tylermurphy.hideAndSeek.util.Version;
import org.bukkit.Bukkit;
import org.bukkit.ChatColor;
import org.bukkit.Material;
import org.bukkit.NamespacedKey;
import org.bukkit.configuration.ConfigurationSection;
import org.bukkit.enchantments.Enchantment;
import org.bukkit.inventory.ItemStack;
@ -63,7 +67,6 @@ public class Items {
if(item != null) HIDER_ITEMS.add(item);
i++;
}
SEEKER_EFFECTS = new ArrayList<>();
ConfigurationSection SeekerEffects = manager.getConfigurationSection("effects.seeker");
i = 1;
@ -91,18 +94,22 @@ public class Items {
private static ItemStack createItem(ConfigurationSection item) {
String material_string = item.getString("material");
if(material_string == null) return null;
Material material = Material.valueOf(material_string.toUpperCase());
if(!XMaterial.matchXMaterial(material_string.toUpperCase()).isPresent()) return null;
Material material = XMaterial.matchXMaterial(material_string.toUpperCase()).get().parseMaterial();
int amount = item.getInt("amount");
if(material == null) return null;
ItemStack stack = new ItemStack(material, amount);
if(material == Material.POTION || material == Material.SPLASH_POTION || material == Material.LINGERING_POTION){
if(material == XMaterial.POTION.parseMaterial() || material == XMaterial.SPLASH_POTION.parseMaterial() || material == XMaterial.LINGERING_POTION.parseMaterial()){
PotionMeta meta = getPotionMeta(stack, item);
if(meta == null) return null;
stack.setItemMeta(meta);
} else {
ConfigurationSection enchantments = item.getConfigurationSection("enchantments");
if (enchantments != null)
for (String enchantment_string : enchantments.getKeys(false)) {
Enchantment enchantment = Enchantment.getByKey(NamespacedKey.minecraft(enchantment_string));
if(!XEnchantment.matchXEnchantment(enchantment_string).isPresent()) continue;
Enchantment enchantment = XEnchantment.matchXEnchantment(enchantment_string).get().getEnchant();
if (enchantment == null) continue;
stack.addUnsafeEnchantment(
enchantment,
@ -121,23 +128,38 @@ public class Items {
String name = item.getString("name");
if(name != null)
meta.setDisplayName(ChatColor.translateAlternateColorCodes('&', name));
if(Version.atLeast("1.11")){
meta.setUnbreakable(item.getBoolean("unbreakable"));
} else {
meta.spigot().setUnbreakable(true);
}
meta.setLore(item.getStringList("lore"));
return meta;
}
private static PotionMeta getPotionMeta(ItemStack stack, ConfigurationSection item){
private static PotionMeta getPotionMeta(ItemStack stack, ConfigurationSection item) {
String type = item.getString("type");
PotionMeta meta = (PotionMeta) stack.getItemMeta();
if(type==null) return meta;
assert meta != null;
meta.setBasePotionData(new PotionData((PotionType.valueOf(type.toUpperCase()))));
XPotion.Effect potionEffect = XPotion.parseEffect(type.toUpperCase());
if(potionEffect == null) return null;
XPotion xpotion = potionEffect.getXPotion();
if(xpotion == null) return null;
PotionEffectType potionType = xpotion.getPotionEffectType();
if(potionType == null) return null;
if(Version.atLeast("1.9")) {
meta.setBasePotionData(new PotionData(xpotion.getPotionType()));
} else {
meta.setMainEffect(potionType);
}
return meta;
}
private static PotionEffect getPotionEffect(ConfigurationSection item){
String type = item.getString("type");
if(type == null) return null;
if(PotionEffectType.getByName(type.toUpperCase()) == null) return null;
return new PotionEffect(
Objects.requireNonNull(PotionEffectType.getByName(type.toUpperCase())),
item.getInt("duration"),

View file

@ -33,7 +33,7 @@ public class Localization {
public static void loadLocalization() {
ConfigManager manager = new ConfigManager("localization.yml", "lang"+File.separator+"localization_"+Config.local+".yml");
ConfigManager manager = new ConfigManager("localization.yml", "lang"+File.separator+"localization_"+Config.locale +".yml");
int PLUGIN_VERSION = 2;
int VERSION = manager.getInt("version");
@ -50,8 +50,8 @@ public class Localization {
String SELECTED_LOCAL = manager.getString("type");
if(SELECTED_LOCAL == null){
manager.reset("type");
} else if(!SELECTED_LOCAL.equals(Config.local)){
manager.resetFile("lang"+File.separator+"localization_"+Config.local+".yml");
} else if(!SELECTED_LOCAL.equals(Config.locale)){
manager.resetFile("lang"+File.separator+"localization_"+Config.locale +".yml");
}
manager.saveConfig();

View file

@ -68,6 +68,13 @@ public class Database {
}
public static void init(){
try {
Class.forName("org.sqlite.JDBC");
} catch (ClassNotFoundException e) {
Main.plugin.getLogger().severe("Unable to load SQLite driver!");
System.exit(-1);
return;
}
playerInfo = new PlayerInfoTable();
}
}

View file

@ -28,6 +28,7 @@ import java.util.Map;
import java.util.stream.Collectors;
import net.tylermurphy.hideAndSeek.util.Status;
import net.tylermurphy.hideAndSeek.util.Version;
import org.bukkit.Bukkit;
import org.bukkit.ChatColor;
import org.bukkit.command.CommandSender;
@ -275,8 +276,13 @@ class CustomBoard {
this.board = manager.getNewScoreboard();
this.LINES = new HashMap<>();
this.player = player;
if(Version.atLeast("1.13")){
this.obj = board.registerNewObjective(
"Scoreboard", "dummy", ChatColor.translateAlternateColorCodes('&', title));
} else {
this.obj = board.registerNewObjective("Scoreboard", "dummy");
this.obj.setDisplayName(ChatColor.translateAlternateColorCodes('&', title));
}
this.blanks = 0;
this.displayed = false;
this.updateTeams();
@ -297,6 +303,7 @@ class CustomBoard {
seekerTeam.removeEntry(entry);
for(Player player : Board.getSeekers())
seekerTeam.addEntry(player.getName());
if(Version.atLeast("1.9")){
if(nametagsVisible) {
hiderTeam.setOption(Team.Option.NAME_TAG_VISIBILITY, Team.OptionStatus.FOR_OWN_TEAM);
seekerTeam.setOption(Team.Option.NAME_TAG_VISIBILITY, Team.OptionStatus.FOR_OTHER_TEAMS);
@ -304,8 +311,22 @@ class CustomBoard {
hiderTeam.setOption(Team.Option.NAME_TAG_VISIBILITY, Team.OptionStatus.NEVER);
seekerTeam.setOption(Team.Option.NAME_TAG_VISIBILITY, Team.OptionStatus.NEVER);
}
} else {
if(nametagsVisible) {
hiderTeam.setNameTagVisibility(NameTagVisibility.HIDE_FOR_OTHER_TEAMS);
seekerTeam.setNameTagVisibility(NameTagVisibility.HIDE_FOR_OWN_TEAM);
} else {
hiderTeam.setNameTagVisibility(NameTagVisibility.NEVER);
seekerTeam.setNameTagVisibility(NameTagVisibility.NEVER);
}
}
if(Version.atLeast("1.12")){
hiderTeam.setColor(ChatColor.GOLD);
seekerTeam.setColor(ChatColor.RED);
} else {
hiderTeam.setPrefix(ChatColor.translateAlternateColorCodes('&', "&6"));
seekerTeam.setPrefix(ChatColor.translateAlternateColorCodes('&', "&c"));
}
}
public void setLine(String key, String message){

View file

@ -21,8 +21,11 @@ package net.tylermurphy.hideAndSeek.game;
import static net.tylermurphy.hideAndSeek.configuration.Config.*;
import com.cryptomorin.xseries.XMaterial;
import com.cryptomorin.xseries.XSound;
import net.tylermurphy.hideAndSeek.Main;
import net.tylermurphy.hideAndSeek.util.Status;
import net.tylermurphy.hideAndSeek.util.Version;
import org.bukkit.*;
import org.bukkit.attribute.Attribute;
import org.bukkit.attribute.AttributeInstance;
@ -178,16 +181,23 @@ public class EventListener implements Listener {
}
}
}
if (player.getHealth() - event.getDamage() < 0 || !pvpEnabled) {
if (player.getHealth() - event.getFinalDamage() < 0 || !pvpEnabled) {
if (spawnPosition == null) return;
event.setCancelled(true);
if(Version.atLeast("1.9")) {
AttributeInstance attribute = player.getAttribute(Attribute.GENERIC_MAX_HEALTH);
if(attribute != null)
player.setHealth(attribute.getValue());
if (attribute != null) player.setHealth(attribute.getValue());
} else {
player.setHealth(player.getMaxHealth());
}
player.teleport(new Location(Bukkit.getWorld("hideandseek_" + spawnWorld), spawnPosition.getX(), spawnPosition.getY(), spawnPosition.getZ()));
Packet.playSound(player, Sound.ENTITY_PLAYER_DEATH, 1, 1);
if(Version.atLeast("1.9")){
XSound.ENTITY_PLAYER_DEATH.play(player, 1, 1);
} else {
XSound.ENTITY_PLAYER_HURT.play(player, 1, 1);
}
if (Board.isSeeker(player)) {
Bukkit.broadcastMessage(message("GAME_PLAYER_DEATH").addPlayer(player).toString());
Game.broadcastMessage(message("GAME_PLAYER_DEATH").addPlayer(player).toString());
}
if (Board.isHider(player)) {
if (attacker == null) {
@ -217,7 +227,8 @@ public class EventListener implements Listener {
if(Board.isHider(player)) {
Game.glow.onProjectile();
snowball.remove();
player.getInventory().remove(Material.SNOWBALL);
assert XMaterial.SNOWBALL.parseMaterial() != null;
player.getInventory().remove(XMaterial.SNOWBALL.parseMaterial());
}
}
}

View file

@ -21,14 +21,19 @@ package net.tylermurphy.hideAndSeek.game;
import static net.tylermurphy.hideAndSeek.configuration.Config.*;
import com.cryptomorin.xseries.XMaterial;
import com.cryptomorin.xseries.XSound;
import com.cryptomorin.xseries.messages.Titles;
import net.md_5.bungee.api.ChatColor;
import net.tylermurphy.hideAndSeek.configuration.Items;
import net.tylermurphy.hideAndSeek.database.Database;
import net.tylermurphy.hideAndSeek.util.Status;
import net.tylermurphy.hideAndSeek.util.Version;
import net.tylermurphy.hideAndSeek.util.WinType;
import net.tylermurphy.hideAndSeek.world.WorldLoader;
import org.bukkit.*;
import org.bukkit.attribute.Attribute;
import org.bukkit.attribute.AttributeInstance;
import org.bukkit.entity.Entity;
import org.bukkit.entity.EntityType;
import org.bukkit.entity.Firework;
@ -42,7 +47,6 @@ import org.bukkit.inventory.meta.ItemMeta;
import org.bukkit.potion.PotionEffect;
import org.bukkit.potion.PotionEffectType;
import java.beans.EventHandler;
import java.io.File;
import java.util.*;
import java.util.stream.Collectors;
@ -92,11 +96,11 @@ public class Game {
for(Player player : Board.getSeekers()) {
player.addPotionEffect(new PotionEffect(PotionEffectType.BLINDNESS,1000000,127,false,false));
player.addPotionEffect(new PotionEffect(PotionEffectType.SLOW,1000000,127,false,false));
player.sendTitle(ChatColor.RED + "" + ChatColor.BOLD + "SEEKER", ChatColor.WHITE + message("SEEKERS_SUBTITLE").toString(), 10, 70, 20);
Titles.sendTitle(player, 10, 70, 20, ChatColor.RED + "" + ChatColor.BOLD + "SEEKER", ChatColor.WHITE + message("SEEKERS_SUBTITLE").toString());
}
for(Player player : Board.getHiders()) {
player.addPotionEffect(new PotionEffect(PotionEffectType.SPEED,1000000,5,false,false));
player.sendTitle(ChatColor.GOLD + "" + ChatColor.BOLD + "HIDER", ChatColor.WHITE + message("HIDERS_SUBTITLE").toString(), 10, 70, 20);
Titles.sendTitle(player, 10, 70, 20, ChatColor.GOLD + "" + ChatColor.BOLD + "HIDER", ChatColor.WHITE + message("HIDERS_SUBTITLE").toString());
}
if(tauntEnabled)
taunt = new Taunt();
@ -153,10 +157,12 @@ public class Game {
player.removePotionEffect(effect.getType());
}
player.addPotionEffect(new PotionEffect(PotionEffectType.HEAL, 1, 100));
if(Version.atLeast("1.9")){
for(Player temp : Board.getPlayers()) {
Packet.setGlow(player, temp, false);
}
}
}
EventListener.temp_loc.clear();
worldLoader.unloadMap();
Board.reloadLobbyBoards();
@ -207,7 +213,8 @@ public class Game {
for(PotionEffect effect : Items.HIDER_EFFECTS)
player.addPotionEffect(effect);
if(glowEnabled) {
ItemStack snowball = new ItemStack(Material.SNOWBALL, 1);
assert XMaterial.SNOWBALL.parseMaterial() != null;
ItemStack snowball = new ItemStack(XMaterial.SNOWBALL.parseMaterial(), 1);
ItemMeta snowballMeta = snowball.getItemMeta();
assert snowballMeta != null;
snowballMeta.setDisplayName("Glow Powerup");
@ -238,11 +245,16 @@ public class Game {
player.setGameMode(GameMode.SPECTATOR);
Board.createGameBoard(player);
player.teleport(new Location(Bukkit.getWorld("hideandseek_"+spawnWorld), spawnPosition.getX(),spawnPosition.getY(),spawnPosition.getZ()));
player.sendTitle(ChatColor.GRAY + "" + ChatColor.BOLD + "SPECTATING", ChatColor.WHITE + message("SPECTATOR_SUBTITLE").toString(), 10, 70, 20);
Titles.sendTitle(player, 10, 70, 20, ChatColor.GRAY + "" + ChatColor.BOLD + "SPECTATING", ChatColor.WHITE + message("SPECTATOR_SUBTITLE").toString());
}
player.setFoodLevel(20);
player.setHealth(Objects.requireNonNull(player.getAttribute(Attribute.GENERIC_MAX_HEALTH)).getBaseValue());
if(Version.atLeast("1.9")) {
AttributeInstance attribute = player.getAttribute(Attribute.GENERIC_MAX_HEALTH);
if (attribute != null) player.setHealth(attribute.getValue());
} else {
player.setHealth(player.getMaxHealth());
}
}
public static void removeItems(Player player){
@ -296,20 +308,36 @@ public class Game {
distance = temp;
}
}
switch(tick%10) {
// if(seekerPing) switch(tick%10) {
// case 0:
// if(distance < seekerPingLevel1) Packet.playSound(hider, XSound.BLOCK_NOTE_BLOCK_BASEDRUM.parseSound(), .5f, 1f);
// if(distance < seekerPingLevel3) Packet.playSound(hider, XSound.BLOCK_NOTE_BLOCK_PLING.parseSound(), .3f, 1f);
// break;
// case 3:
// if(distance < seekerPingLevel1) Packet.playSound(hider, XSound.BLOCK_NOTE_BLOCK_BASEDRUM.parseSound(), .3f, 1f);
// if(distance < seekerPingLevel3) Packet.playSound(hider, XSound.BLOCK_NOTE_BLOCK_PLING.parseSound(), .3f, 1f);
// break;
// case 6:
// if(distance < seekerPingLevel3) Packet.playSound(hider, XSound.BLOCK_NOTE_BLOCK_PLING.parseSound(), .3f, 1f);
// break;
// case 9:
// if(distance < seekerPingLevel2) Packet.playSound(hider, XSound.BLOCK_NOTE_BLOCK_PLING.parseSound(), .3f, 1f);
// break;
// }
if(seekerPing) switch(tick%10) {
case 0:
if(distance < 30) Packet.playSound(hider, Sound.BLOCK_NOTE_BLOCK_BASEDRUM, .5f, 1f);
if(distance < 10) Packet.playSound(hider, Sound.BLOCK_NOTE_BLOCK_BIT, .3f, 1f);
if(distance < seekerPingLevel1) XSound.BLOCK_NOTE_BLOCK_BASEDRUM.play(hider, .5f, 1f);
if(distance < seekerPingLevel3) XSound.BLOCK_NOTE_BLOCK_PLING.play(hider, .3f, 1f);
break;
case 3:
if(distance < 30) Packet.playSound(hider, Sound.BLOCK_NOTE_BLOCK_BASEDRUM, .3f, 1f);
if(distance < 10) Packet.playSound(hider, Sound.BLOCK_NOTE_BLOCK_BIT, .3f, 1f);
if(distance < seekerPingLevel1) XSound.BLOCK_NOTE_BLOCK_BASEDRUM.play(hider, .3f, 1f);
if(distance < seekerPingLevel3) XSound.BLOCK_NOTE_BLOCK_PLING.play(hider, .3f, 1f);
break;
case 6:
if(distance < 10) Packet.playSound(hider, Sound.BLOCK_NOTE_BLOCK_BIT, .3f, 1f);
if(distance < seekerPingLevel3) XSound.BLOCK_NOTE_BLOCK_PLING.play(hider, .3f, 1f);
break;
case 9:
if(distance < 20) Packet.playSound(hider, Sound.BLOCK_NOTE_BLOCK_BIT, .3f, 1f);
if(distance < seekerPingLevel2) XSound.BLOCK_NOTE_BLOCK_PLING.play(hider, .3f, 1f);
break;
}
}

View file

@ -21,6 +21,8 @@ package net.tylermurphy.hideAndSeek.util;
import java.lang.reflect.InvocationTargetException;
import net.tylermurphy.hideAndSeek.Main;
import net.tylermurphy.hideAndSeek.util.protocollib.WrapperPlayServerNamedSoundEffect;
import org.bukkit.Sound;
import org.bukkit.entity.Player;
@ -38,19 +40,15 @@ public class Packet {
private static final ProtocolManager protocolManager = ProtocolLibrary.getProtocolManager();
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();
}
WrapperPlayServerNamedSoundEffect packet = new WrapperPlayServerNamedSoundEffect();
packet.setSoundCategory(SoundCategory.MASTER);
packet.setSoundEffect(sound);
packet.setEffectPositionX((int)(player.getLocation().getX() * 8.0));
packet.setEffectPositionY((int)(player.getLocation().getY() * 8.0));
packet.setEffectPositionZ((int)(player.getLocation().getZ() * 8.0));
packet.setPitch(pitch);
packet.setVolume(volume);
packet.sendPacket(player);
}
public static void setGlow(Player player, Player target, boolean glowing) {

View file

@ -0,0 +1,45 @@
package net.tylermurphy.hideAndSeek.util;
import org.bukkit.Bukkit;
import java.util.HashMap;
import java.util.Map;
public class Version {
private static final Map<String,Boolean> CACHE = new HashMap<>();
public static boolean atLeast(String testVersion){
if(CACHE.containsKey(testVersion)) return CACHE.get(testVersion);
String[] serverCheckTemp = Bukkit.getBukkitVersion().substring(2,Bukkit.getBukkitVersion().indexOf('-')).split("\\.");
int[] serverCheck = new int[serverCheckTemp.length];
for(int i=0; i<serverCheck.length; i++){
serverCheck[i] = Integer.parseInt(serverCheckTemp[i]);
}
String[] customCheckTemp = testVersion.substring(2).split("\\.");
int[] customCheck = new int[customCheckTemp.length];
for(int i=0; i<customCheck.length; i++){
customCheck[i] = Integer.parseInt(customCheckTemp[i]);
}
boolean result = getResult(customCheck, serverCheck);
CACHE.put(testVersion, result);
return result;
}
private static boolean getResult(int[] customCheck, int[] serverCheck){
if(customCheck[0] > serverCheck[0]) return false;
else if(customCheck[0] < serverCheck[0]) return true;
else {
if (customCheck.length == 1 && serverCheck.length == 1) return true;
else if(customCheck.length == 2 && serverCheck.length == 2){
return customCheck[1] <= serverCheck[1];
}
else return serverCheck.length == 2;
}
}
}

View file

@ -0,0 +1,115 @@
/**
* PacketWrapper - ProtocolLib wrappers for Minecraft packets
* Copyright (C) dmulloy2 <http://dmulloy2.net>
* Copyright (C) Kristian S. Strangeland
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
package net.tylermurphy.hideAndSeek.util.protocollib;
import java.lang.reflect.InvocationTargetException;
import org.bukkit.entity.Player;
import com.comphenix.protocol.PacketType;
import com.comphenix.protocol.ProtocolLibrary;
import com.comphenix.protocol.events.PacketContainer;
import com.google.common.base.Objects;
public abstract class AbstractPacket {
// The packet we will be modifying
protected PacketContainer handle;
/**
* Constructs a new strongly typed wrapper for the given packet.
*
* @param handle - handle to the raw packet data.
* @param type - the packet type.
*/
protected AbstractPacket(PacketContainer handle, PacketType type) {
// Make sure we're given a valid packet
if (handle == null)
throw new IllegalArgumentException("Packet handle cannot be NULL.");
if (!Objects.equal(handle.getType(), type))
throw new IllegalArgumentException(handle.getHandle()
+ " is not a packet of type " + type);
this.handle = handle;
}
/**
* Retrieve a handle to the raw packet data.
*
* @return Raw packet data.
*/
public PacketContainer getHandle() {
return handle;
}
/**
* Send the current packet to the given receiver.
*
* @param receiver - the receiver.
* @throws RuntimeException If the packet cannot be sent.
*/
public void sendPacket(Player receiver) {
try {
ProtocolLibrary.getProtocolManager().sendServerPacket(receiver,
getHandle());
} catch (InvocationTargetException e) {
throw new RuntimeException("Cannot send packet.", e);
}
}
/**
* Send the current packet to all online players.
*/
public void broadcastPacket() {
ProtocolLibrary.getProtocolManager().broadcastServerPacket(getHandle());
}
/**
* Simulate receiving the current packet from the given sender.
*
* @param sender - the sender.
* @throws RuntimeException If the packet cannot be received.
* @deprecated Misspelled. recieve to receive
* @see #receivePacket(Player)
*/
@Deprecated
public void recievePacket(Player sender) {
try {
ProtocolLibrary.getProtocolManager().recieveClientPacket(sender,
getHandle());
} catch (Exception e) {
throw new RuntimeException("Cannot recieve packet.", e);
}
}
/**
* Simulate receiving the current packet from the given sender.
*
* @param sender - the sender.
* @throws RuntimeException if the packet cannot be received.
*/
public void receivePacket(Player sender) {
try {
ProtocolLibrary.getProtocolManager().recieveClientPacket(sender,
getHandle());
} catch (Exception e) {
throw new RuntimeException("Cannot receive packet.", e);
}
}
}

View file

@ -0,0 +1,158 @@
/**
* PacketWrapper - ProtocolLib wrappers for Minecraft packets
* Copyright (C) dmulloy2 <http://dmulloy2.net>
* Copyright (C) Kristian S. Strangeland
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
package net.tylermurphy.hideAndSeek.util.protocollib;
import org.bukkit.Sound;
import com.comphenix.protocol.PacketType;
import com.comphenix.protocol.events.PacketContainer;
import com.comphenix.protocol.wrappers.EnumWrappers.SoundCategory;
public class WrapperPlayServerNamedSoundEffect extends AbstractPacket {
public static final PacketType TYPE =
PacketType.Play.Server.NAMED_SOUND_EFFECT;
public WrapperPlayServerNamedSoundEffect() {
super(new PacketContainer(TYPE), TYPE);
handle.getModifier().writeDefaults();
}
public WrapperPlayServerNamedSoundEffect(PacketContainer packet) {
super(packet, TYPE);
}
public Sound getSoundEffect() {
return handle.getSoundEffects().read(0);
}
public void setSoundEffect(Sound value) {
handle.getSoundEffects().write(0, value);
}
public SoundCategory getSoundCategory() {
return handle.getSoundCategories().read(0);
}
public void setSoundCategory(SoundCategory value) {
handle.getSoundCategories().write(0, value);
}
/**
* Retrieve Effect position X.
* <p>
* Notes: effect X multiplied by 8
*
* @return The current Effect position X
*/
public int getEffectPositionX() {
return handle.getIntegers().read(0);
}
/**
* Set Effect position X.
*
* @param value - new value.
*/
public void setEffectPositionX(int value) {
handle.getIntegers().write(0, value);
}
/**
* Retrieve Effect position Y.
* <p>
* Notes: effect Y multiplied by 8
*
* @return The current Effect position Y
*/
public int getEffectPositionY() {
return handle.getIntegers().read(1);
}
/**
* Set Effect position Y.
*
* @param value - new value.
*/
public void setEffectPositionY(int value) {
handle.getIntegers().write(1, value);
}
/**
* Retrieve Effect position Z.
* <p>
* Notes: effect Z multiplied by 8
*
* @return The current Effect position Z
*/
public int getEffectPositionZ() {
return handle.getIntegers().read(2);
}
/**
* Set Effect position Z.
*
* @param value - new value.
*/
public void setEffectPositionZ(int value) {
handle.getIntegers().write(2, value);
}
/**
* Retrieve Volume.
* <p>
* Notes: 1 is 100%, can be more
*
* @return The current Volume
*/
public float getVolume() {
return handle.getFloat().read(0);
}
/**
* Set Volume.
*
* @param value - new value.
*/
public void setVolume(float value) {
handle.getFloat().write(0, value);
}
/**
* Retrieve Pitch.
* <p>
* Notes: 63 is 100%, can be more
*
* @return The current Pitch
*/
public float getPitch() {
return handle.getFloat().read(1);
}
/**
* Set Pitch.
*
* @param value - new value.
*/
public void setPitch(float value) {
handle.getFloat().write(1, value);
}
}

View file

@ -29,6 +29,7 @@ import java.io.IOException;
import java.io.InputStream;
import java.io.OutputStream;
import net.tylermurphy.hideAndSeek.util.Version;
import org.bukkit.Bukkit;
import org.bukkit.World;
import org.bukkit.WorldCreator;
@ -111,7 +112,10 @@ public class WorldLoader {
private void copyFileFolder(String name, Boolean isMca) throws IOException {
File region = new File(Main.root+File.separator+mapname+File.separator+name);
File temp = new File(Main.root+File.separator+"temp_"+savename+File.separator+name);
System.out.println(region.getAbsolutePath());
System.out.println(temp.getAbsolutePath());
if(region.exists() && region.isDirectory()) {
System.out.println("passed");
if(!temp.exists())
if(!temp.mkdirs())
throw new IOException("Couldn't create region directory!");
@ -121,17 +125,17 @@ public class WorldLoader {
return;
}
for (String file : files) {
System.out.println("Testing file "+ file);
if(isMca) {
int minX = (int)Math.floor(saveMinX / 32.0);
int minZ = (int)Math.floor(saveMinZ / 32.0);
int maxX = (int)Math.floor(saveMaxX / 32.0);
int maxZ = (int)Math.floor(saveMaxZ / 32.0);
int minX = (int)Math.floor(saveMinX / 512.0);
int minZ = (int)Math.floor(saveMinZ / 512.0);
int maxX = (int)Math.floor(saveMaxX / 512.0);
int maxZ = (int)Math.floor(saveMaxZ / 512.0);
String[] parts = file.split("\\.");
if(parts.length > 1) {
Main.plugin.getLogger().info(file);
if( Integer.parseInt(parts[1]) < minX || Integer.parseInt(parts[1]) > maxX ||Integer.parseInt(parts[2]) < minZ || Integer.parseInt(parts[2]) > maxZ )
if( Integer.parseInt(parts[1]) < minX || Integer.parseInt(parts[1]) > maxX || Integer.parseInt(parts[2]) < minZ || Integer.parseInt(parts[2]) > maxZ )
continue;
}
}

View file

@ -90,10 +90,20 @@ lobby:
max: 10
enabled: true
# As a hider, the closer a seeker gets to you, the louder and faster a pining noise will play.
# There are 3 separate distances (in blocks) you can set to the 3 different levels for the noise.
# The higher the level, the closer the seeker.
seekerPing:
distances:
level1: 30
level2: 20
level3: 10
enabled: true
# Changes the default plugin language. Currently, Supported localizations are:
# en-US (English - United States)
# de-DE (German - Germany)
local: "en-US"
locale: "en-US"
# ---------------------------------------------------------- #
# ONLY EDIT BEYOND THIS POINT IF YOU KNOW WHAT YOU ARE DOING #

View file

@ -1,9 +1,9 @@
name: HideAndSeek
main: net.tylermurphy.hideAndSeek.Main
version: 1.3.3
version: 1.4.0
author: KenshinEto
load: STARTUP
api-version: 1.14
api-version: 1.13
depend: [ProtocolLib]
commands:
hideandseek:
@ -29,6 +29,8 @@ permissions:
hideandseek.join: true
hideandseek.leave: true
hideandseek.leavebounds: true
hideandseek.wins: true
hideand.top: true
hideandseek.about:
description: Allows you to run the about command
default: true
@ -74,3 +76,9 @@ permissions:
hideandseek.leavebounds:
description: Allows players to leave specified game bounderies
default: op
hideandseek.wins:
description: Allows players to see a players amount of wins
default: true
hideandseek.top:
description: Allows players to see the global wins leaderboard
default: true