Merge pull request 'bug fixes' (#11) from dev into main

Reviewed-on: https://g.tylerm.dev/tylerm/KenshinsHideAndSeek/pulls/11
This commit is contained in:
Murphy 2023-08-03 04:20:24 +00:00
commit 2953057ef1
7 changed files with 15 additions and 12 deletions

View file

@ -1,7 +1,7 @@
<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>dev.tylerm</groupId>
<artifactId>KenshinsHideAndSeek</artifactId>
<version>1.7.5</version>
<version>1.7.6</version>
<name>Hide and Seek Plugin</name>
<properties>

View file

@ -49,7 +49,7 @@ public class CommandGroup {
if (data == null) {
player.sendMessage(
String.format("%s%sKenshin's Hide and Seek %s(%s1.7.5%s)\n", ChatColor.AQUA, ChatColor.BOLD, ChatColor.GRAY, ChatColor.WHITE, ChatColor.GRAY) +
String.format("%s%sKenshin's Hide and Seek %s(%s1.7.6%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

@ -60,8 +60,6 @@ public class Game {
private int gameTimer;
private boolean hiderLeft;
private Random random;
public Game(Map map, Board board) {
this.currentMap = map;
@ -78,8 +76,6 @@ public class Game {
this.startingTimer = -1;
this.gameTimer = 0;
this.hiderLeft = false;
this.random = new Random();
}
public Status getStatus(){
@ -107,7 +103,7 @@ public class Game {
List<Player> pool = board.getPlayers();
for (int i = 0; i < startingSeekerCount; i++) {
try {
int rand = random.nextInt(0, pool.size());
int rand = (int)(Math.random() * pool.size());
seekers.add(pool.remove(rand));
} catch (Exception e){
Main.getInstance().getLogger().warning("Failed to select random seeker.");

View file

@ -8,7 +8,6 @@ import com.comphenix.protocol.events.PacketAdapter;
import com.comphenix.protocol.events.PacketContainer;
import com.comphenix.protocol.events.PacketEvent;
import com.comphenix.protocol.wrappers.EnumWrappers;
import com.comphenix.protocol.wrappers.EnumWrappers.EntityUseAction;
import dev.tylerm.khs.Main;
import dev.tylerm.khs.game.util.Disguise;
import org.bukkit.Bukkit;
@ -51,15 +50,19 @@ public class DisguiseHandler implements Listener {
PacketContainer packet = event.getPacket();
// only left click attacks
EntityUseAction action = packet.getEntityUseActions().getValues().stream().findFirst().orElse(null);
EnumWrappers.EntityUseAction action = packet.getEntityUseActions().getValues().stream().findFirst().orElse(null);
if (action == null) return;
if (action != EnumWrappers.EntityUseAction.ATTACK) return;
//noinspection ComparatorResultComparison
if (action.compareTo(EnumWrappers.EntityUseAction.INTERACT) == 2) {
return;
}
Player player = event.getPlayer();
int id = packet.getIntegers().read(0);
Disguise disguise = Main.getInstance().getDisguiser().getByEntityID(id);
if(disguise == null) disguise = Main.getInstance().getDisguiser().getByHitBoxID(id);
if(disguise == null) return;
if(disguise.getPlayer().getGameMode() == GameMode.CREATIVE) return;
event.setCancelled(true);
handleAttack(disguise, player);
@ -82,7 +85,9 @@ public class DisguiseHandler implements Listener {
disguise.setSolidify(false);
if(debounce.contains(disguise.getPlayer())) return;
debounce.add(disguise.getPlayer());
Bukkit.getScheduler().scheduleSyncDelayedTask(Main.getInstance(), () -> {
EntityDamageByEntityEvent event =
new EntityDamageByEntityEvent(seeker, disguise.getPlayer(), EntityDamageEvent.DamageCause.ENTITY_ATTACK, amount);

View file

@ -39,6 +39,7 @@ public class InventoryHandler implements Listener {
@EventHandler(priority = EventPriority.HIGHEST)
public void onInventoryClick(InventoryClickEvent event) {
if (event.getCurrentItem() == null) return;
if (!(event.getWhoClicked() instanceof Player)) return;
checkForInventoryMove(event);
checkForSpectatorTeleportMenu(event);
@ -56,6 +57,7 @@ public class InventoryHandler implements Listener {
Player player = (Player) event.getWhoClicked();
ItemStack item = event.getCurrentItem();
ItemMeta meta = item.getItemMeta();
String name = meta.getDisplayName();

View file

@ -31,7 +31,7 @@ public class PAPIExpansion extends PlaceholderExpansion {
@Override
public @NotNull String getVersion() {
return "1.7.5";
return "1.7.6";
}
@Override

View file

@ -1,6 +1,6 @@
name: KenshinsHideAndSeek
main: dev.tylerm.khs.Main
version: 1.7.5
version: 1.7.6
author: KenshinEto
load: STARTUP
api-version: 1.13