summaryrefslogtreewikicommitdiff
path: root/src/main/java/net/tylermurphy
diff options
context:
space:
mode:
Diffstat (limited to 'src/main/java/net/tylermurphy')
-rw-r--r--src/main/java/net/tylermurphy/hideAndSeek/configuration/Config.java34
-rw-r--r--src/main/java/net/tylermurphy/hideAndSeek/configuration/ConfigManager.java9
-rw-r--r--src/main/java/net/tylermurphy/hideAndSeek/game/EventListener.java49
-rw-r--r--src/main/java/net/tylermurphy/hideAndSeek/game/Game.java25
4 files changed, 68 insertions, 49 deletions
diff --git a/src/main/java/net/tylermurphy/hideAndSeek/configuration/Config.java b/src/main/java/net/tylermurphy/hideAndSeek/configuration/Config.java
index 589d3a2..39bc55f 100644
--- a/src/main/java/net/tylermurphy/hideAndSeek/configuration/Config.java
+++ b/src/main/java/net/tylermurphy/hideAndSeek/configuration/Config.java
@@ -21,6 +21,7 @@ package net.tylermurphy.hideAndSeek.configuration;
import com.cryptomorin.xseries.XItemStack;
import com.cryptomorin.xseries.XMaterial;
+import com.cryptomorin.xseries.XSound;
import net.tylermurphy.hideAndSeek.util.Version;
import org.bukkit.ChatColor;
import org.bukkit.Material;
@@ -100,6 +101,11 @@ public class Config {
lobbyItemLeavePosition,
lobbyItemStartPosition;
+ public static float
+ seekerPingLeadingVolume,
+ seekerPingVolume,
+ seekerPingPitch;
+
public static List<String>
blockedCommands,
blockedInteracts;
@@ -124,7 +130,12 @@ public class Config {
public static ItemStack
lobbyLeaveItem,
- lobbyStartItem;
+ lobbyStartItem,
+ glowPowerupItem;
+
+ public static XSound
+ ringingSound,
+ heartbeatSound;
public static void loadConfig() {
@@ -196,6 +207,16 @@ public class Config {
glowLength = Math.max(1, config.getInt("glow.time"));
glowStackable = config.getBoolean("glow.stackable");
glowEnabled = config.getBoolean("glow.enabled") && Version.atLeast("1.9");
+ if(glowEnabled) {
+ ConfigurationSection item = new YamlConfiguration().createSection("temp");
+ item.set("name", ChatColor.translateAlternateColorCodes('&',config.getString("glow.name")));
+ item.set("material", config.getString("glow.material"));
+ List<String> lore = config.getStringList("glow.lore");
+ if (lore != null && !lore.isEmpty()) item.set("lore", lore);
+ ItemStack temp = null;
+ try{ temp = XItemStack.deserialize(item); } catch(Exception ignored){}
+ glowPowerupItem = temp;
+ }
//Lobby
minPlayers = Math.max(2, config.getInt("minPlayers"));
@@ -210,6 +231,13 @@ public class Config {
seekerPingLevel1 = config.getInt("seekerPing.distances.level1");
seekerPingLevel2 = config.getInt("seekerPing.distances.level2");
seekerPingLevel3 = config.getInt("seekerPing.distances.level3");
+ seekerPingLeadingVolume = config.getFloat("seekerPing.sounds.leadingVolume");
+ seekerPingVolume = config.getFloat("seekerPing.sounds.volume");
+ seekerPingPitch = config.getFloat("seekerPing.sounds.pitch");
+ Optional<XSound> heartbeatOptional = XSound.matchXSound(config.getString("seekerPing.sounds.heartbeatNoise"));
+ heartbeatSound = heartbeatOptional.orElse(XSound.BLOCK_NOTE_BLOCK_BASEDRUM);
+ Optional<XSound> ringingOptional = XSound.matchXSound(config.getString("seekerPing.sounds.ringingNoise"));
+ ringingSound = heartbeatOptional.orElse(XSound.BLOCK_NOTE_BLOCK_PLING);
//Other
nametagsVisible = config.getBoolean("nametagsVisible");
@@ -259,7 +287,7 @@ public class Config {
item.set("name", ChatColor.translateAlternateColorCodes('&',config.getString("lobbyItems.leave.name")));
item.set("material", config.getString("lobbyItems.leave.material"));
if(Version.atLeast("1.14")){
- if(config.contains("lobbyItems.leave.model-data")){
+ if(config.contains("lobbyItems.leave.model-data") && config.getInt("lobbyItems.leave.model-data") != 0){
config.set("model-data", config.getInt("lobbyItems.leave.model-data"));
}
}
@@ -282,7 +310,7 @@ public class Config {
lobbyItemStartAdmin = config.getBoolean("lobbyItems.start.adminOnly");
lobbyItemStartPosition = config.getInt("lobbyItems.start.position");
if(Version.atLeast("1.14")){
- if(config.contains("lobbyItems.start.model-data")){
+ if(config.contains("lobbyItems.start.model-data") && config.getInt("lobbyItems.start.model-data") != 0){
config.set("model-data", config.getInt("lobbyItems.start.model-data"));
}
}
diff --git a/src/main/java/net/tylermurphy/hideAndSeek/configuration/ConfigManager.java b/src/main/java/net/tylermurphy/hideAndSeek/configuration/ConfigManager.java
index 53a30c2..3546fa8 100644
--- a/src/main/java/net/tylermurphy/hideAndSeek/configuration/ConfigManager.java
+++ b/src/main/java/net/tylermurphy/hideAndSeek/configuration/ConfigManager.java
@@ -130,6 +130,15 @@ public class ConfigManager {
return defaultConfig.getInt(path);
}
+ public float getFloat(String path){
+ float value = (float) config.getDouble(path);
+ if(value == 0){
+ return (float) defaultConfig.getDouble(path);
+ } else {
+ return value;
+ }
+ }
+
public String getString(String path){
String value = config.getString(path);
if(value == null){
diff --git a/src/main/java/net/tylermurphy/hideAndSeek/game/EventListener.java b/src/main/java/net/tylermurphy/hideAndSeek/game/EventListener.java
index 5995dbc..e464fba 100644
--- a/src/main/java/net/tylermurphy/hideAndSeek/game/EventListener.java
+++ b/src/main/java/net/tylermurphy/hideAndSeek/game/EventListener.java
@@ -32,7 +32,6 @@ import org.bukkit.attribute.AttributeInstance;
import org.bukkit.entity.Arrow;
import org.bukkit.entity.Entity;
import org.bukkit.entity.Player;
-import org.bukkit.entity.Snowball;
import org.bukkit.event.EventHandler;
import org.bukkit.event.EventPriority;
import org.bukkit.event.Listener;
@@ -42,7 +41,6 @@ import org.bukkit.event.entity.EntityRegainHealthEvent.RegainReason;
import org.bukkit.event.inventory.InventoryClickEvent;
import org.bukkit.event.player.*;
-import org.bukkit.inventory.EquipmentSlot;
import org.bukkit.inventory.ItemStack;
import org.bukkit.potion.PotionEffect;
import org.bukkit.projectiles.ProjectileSource;
@@ -240,24 +238,6 @@ public class EventListener implements Listener {
}
@EventHandler(priority = EventPriority.HIGHEST)
- public void onProjectile(ProjectileLaunchEvent event) {
- if(Game.status != Status.PLAYING) return;
- if(event.getEntity() instanceof Snowball) {
- if(!glowEnabled) return;
- Snowball snowball = (Snowball) event.getEntity();
- if(snowball.getShooter() instanceof Player) {
- Player player = (Player) snowball.getShooter();
- if(Board.isHider(player)) {
- Game.glow.onProjectile();
- snowball.remove();
- assert XMaterial.SNOWBALL.parseMaterial() != null;
- player.getInventory().remove(XMaterial.SNOWBALL.parseMaterial());
- }
- }
- }
- }
-
- @EventHandler(priority = EventPriority.HIGHEST)
public void onFoodLevelChange(FoodLevelChangeEvent event) {
if(event.getEntity() instanceof Player) {
if(!Board.isPlayer((Player) event.getEntity())) return;
@@ -297,18 +277,19 @@ public class EventListener implements Listener {
@EventHandler(priority = EventPriority.HIGHEST)
public void onPlayerInteract(PlayerInteractEvent event) {
if(!Board.isPlayer(event.getPlayer())) return;
-
if(event.getAction() == Action.RIGHT_CLICK_BLOCK && event.getClickedBlock() != null && blockedInteracts.contains(event.getClickedBlock().getType().name())){
event.setCancelled(true);
return;
}
-
- if(Game.status != Status.STANDBY) return;
-
-
ItemStack temp = event.getItem();
if(temp == null) return;
+ if(Game.status == Status.STANDBY)
+ onPlayerInteractLobby(temp, event);
+ if(Game.status == Status.PLAYING)
+ onPlayerInteractGame(temp, event);
+ }
+ private void onPlayerInteractLobby(ItemStack temp, PlayerInteractEvent event){
if (temp.getItemMeta().getDisplayName().equalsIgnoreCase(lobbyLeaveItem.getItemMeta().getDisplayName()) && temp.getType() == lobbyLeaveItem.getType()) {
event.setCancelled(true);
Game.leave(event.getPlayer());
@@ -330,7 +311,20 @@ public class EventListener implements Listener {
}
Game.start();
}
+ }
+ private void onPlayerInteractGame(ItemStack temp, PlayerInteractEvent event){
+ if (temp.getItemMeta().getDisplayName().equalsIgnoreCase(glowPowerupItem.getItemMeta().getDisplayName()) && temp.getType() == glowPowerupItem.getType()) {
+ if(!glowEnabled) return;
+ Player player = event.getPlayer();
+ if(Board.isHider(player)) {
+ Game.glow.onProjectile();
+ player.getInventory().remove(glowPowerupItem);
+ assert XMaterial.SNOWBALL.parseMaterial() != null;
+ player.getInventory().remove(XMaterial.SNOWBALL.parseMaterial());
+ event.setCancelled(true);
+ }
+ }
}
@EventHandler(priority = EventPriority.HIGHEST)
@@ -344,9 +338,8 @@ public class EventListener implements Listener {
}
@EventHandler(priority = EventPriority.HIGHEST)
- public void onItemDrop(PlayerDropItemEvent event)
- {
- if(Board.isPlayer(event.getPlayer()) && Game.status == Status.STANDBY){
+ public void onItemDrop(PlayerDropItemEvent event) {
+ if(Board.isPlayer(event.getPlayer())){
event.setCancelled(true);
}
}
diff --git a/src/main/java/net/tylermurphy/hideAndSeek/game/Game.java b/src/main/java/net/tylermurphy/hideAndSeek/game/Game.java
index c01682b..7488163 100644
--- a/src/main/java/net/tylermurphy/hideAndSeek/game/Game.java
+++ b/src/main/java/net/tylermurphy/hideAndSeek/game/Game.java
@@ -273,18 +273,7 @@ public class Game {
for(PotionEffect effect : Items.HIDER_EFFECTS)
player.addPotionEffect(effect);
if(glowEnabled) {
- assert XMaterial.SNOWBALL.parseMaterial() != null;
- ItemStack snowball = new ItemStack(XMaterial.SNOWBALL.parseMaterial(), 1);
- ItemMeta snowballMeta = snowball.getItemMeta();
- assert snowballMeta != null;
- snowballMeta.setDisplayName("Glow Powerup");
- List<String> snowballLore = new ArrayList<>();
- snowballLore.add("Throw to make all seekers glow");
- snowballLore.add("Last 30s, all hiders can see it");
- snowballLore.add("Time stacks on multi use");
- snowballMeta.setLore(snowballLore);
- snowball.setItemMeta(snowballMeta);
- player.getInventory().addItem(snowball);
+ player.getInventory().addItem(glowPowerupItem);
}
}
}
@@ -391,18 +380,18 @@ public class Game {
}
if(seekerPing) switch(tick%10) {
case 0:
- if(distance < seekerPingLevel1) XSound.BLOCK_NOTE_BLOCK_BASEDRUM.play(hider, .5f, 1f);
- if(distance < seekerPingLevel3) XSound.BLOCK_NOTE_BLOCK_PLING.play(hider, .3f, 1f);
+ if(distance < seekerPingLevel1) heartbeatSound.play(hider, seekerPingLeadingVolume, seekerPingPitch);
+ if(distance < seekerPingLevel3) ringingSound.play(hider, seekerPingVolume, seekerPingPitch);
break;
case 3:
- if(distance < seekerPingLevel1) XSound.BLOCK_NOTE_BLOCK_BASEDRUM.play(hider, .3f, 1f);
- if(distance < seekerPingLevel3) XSound.BLOCK_NOTE_BLOCK_PLING.play(hider, .3f, 1f);
+ if(distance < seekerPingLevel1) heartbeatSound.play(hider, seekerPingVolume, seekerPingPitch);
+ if(distance < seekerPingLevel3) ringingSound.play(hider, seekerPingVolume, seekerPingPitch);
break;
case 6:
- if(distance < seekerPingLevel3) XSound.BLOCK_NOTE_BLOCK_PLING.play(hider, .3f, 1f);
+ if(distance < seekerPingLevel3) ringingSound.play(hider, seekerPingVolume, seekerPingPitch);
break;
case 9:
- if(distance < seekerPingLevel2) XSound.BLOCK_NOTE_BLOCK_PLING.play(hider, .3f, 1f);
+ if(distance < seekerPingLevel2) ringingSound.play(hider, seekerPingVolume, seekerPingPitch);
break;
}
}