From 1e35e555c267405ab3b5026d3a69cae03523a415 Mon Sep 17 00:00:00 2001 From: Trixkz Date: Mon, 29 Nov 2021 06:20:30 -0500 Subject: [PATCH] t --- .../java/rip/tilly/bedwars/game/Game.java | 51 +++++++++---------- .../bedwars/listeners/InteractListener.java | 26 ++++++---- 2 files changed, 40 insertions(+), 37 deletions(-) diff --git a/src/main/java/rip/tilly/bedwars/game/Game.java b/src/main/java/rip/tilly/bedwars/game/Game.java index 3cbad9d..30dcce2 100644 --- a/src/main/java/rip/tilly/bedwars/game/Game.java +++ b/src/main/java/rip/tilly/bedwars/game/Game.java @@ -6,7 +6,6 @@ import lombok.Setter; import org.bukkit.Location; import org.bukkit.Material; import org.bukkit.Sound; -import org.bukkit.World; import org.bukkit.block.Block; import org.bukkit.entity.Entity; import org.bukkit.entity.Player; @@ -22,8 +21,6 @@ import rip.tilly.bedwars.generators.GeneratorType; import rip.tilly.bedwars.utils.CC; import rip.tilly.bedwars.utils.CustomLocation; import rip.tilly.bedwars.utils.TimeUtils; -import rip.tilly.bedwars.villager.CustomVillager; - import java.util.*; import java.util.stream.Collectors; import java.util.stream.Stream; @@ -314,30 +311,30 @@ public class Game { } public void spawnVillagers() { - CustomVillager villager = new CustomVillager(this.copiedArena.getA().toBukkitWorld()); - villager.register(); - villager.spawn(this.copiedArena.getTeamAshop().toBukkitLocation(), "&aItem Shop"); - this.addEntityToRemove(villager.getBukkitEntity()); +// CustomVillager villager = new CustomVillager(this.copiedArena.getA().toBukkitWorld()); +// villager.register(); +// villager.spawn(this.copiedArena.getTeamAshop().toBukkitLocation(), "&aItem Shop"); +// this.addEntityToRemove(villager.getBukkitEntity()); -// Villager teamAShopVillager = this.copiedArena.getTeamAshop().toBukkitLocation().getWorld().spawn(this.copiedArena.getTeamAshop().toBukkitLocation(), Villager.class); -// teamAShopVillager.setCustomName(CC.translate("&aItem Shop")); -// teamAShopVillager.setCustomNameVisible(true); -// -// Villager teamBShopVillager = this.copiedArena.getTeamBshop().toBukkitLocation().getWorld().spawn(this.copiedArena.getTeamBshop().toBukkitLocation(), Villager.class); -// teamBShopVillager.setCustomName(CC.translate("&aItem Shop")); -// teamBShopVillager.setCustomNameVisible(true); -// -// Villager teamAUpgradesVillager = this.copiedArena.getTeamAupgrades().toBukkitLocation().getWorld().spawn(this.copiedArena.getTeamAupgrades().toBukkitLocation(), Villager.class); -// teamAUpgradesVillager.setCustomName(CC.translate("&aUpgrades Shop")); -// teamAUpgradesVillager.setCustomNameVisible(true); -// -// Villager teamBUpgradesVillager = this.copiedArena.getTeamBupgrades().toBukkitLocation().getWorld().spawn(this.copiedArena.getTeamBupgrades().toBukkitLocation(), Villager.class); -// teamBUpgradesVillager.setCustomName(CC.translate("&aUpgrades Shop")); -// teamBUpgradesVillager.setCustomNameVisible(true); -// -// this.addEntityToRemove(teamAShopVillager); -// this.addEntityToRemove(teamBShopVillager); -// this.addEntityToRemove(teamAUpgradesVillager); -// this.addEntityToRemove(teamBUpgradesVillager); + Villager teamAShopVillager = this.copiedArena.getTeamAshop().toBukkitLocation().getWorld().spawn(this.copiedArena.getTeamAshop().toBukkitLocation(), Villager.class); + teamAShopVillager.setCustomName(CC.translate("&aItem Shop")); + teamAShopVillager.setCustomNameVisible(true); + + Villager teamBShopVillager = this.copiedArena.getTeamBshop().toBukkitLocation().getWorld().spawn(this.copiedArena.getTeamBshop().toBukkitLocation(), Villager.class); + teamBShopVillager.setCustomName(CC.translate("&aItem Shop")); + teamBShopVillager.setCustomNameVisible(true); + + Villager teamAUpgradesVillager = this.copiedArena.getTeamAupgrades().toBukkitLocation().getWorld().spawn(this.copiedArena.getTeamAupgrades().toBukkitLocation(), Villager.class); + teamAUpgradesVillager.setCustomName(CC.translate("&aUpgrades Shop")); + teamAUpgradesVillager.setCustomNameVisible(true); + + Villager teamBUpgradesVillager = this.copiedArena.getTeamBupgrades().toBukkitLocation().getWorld().spawn(this.copiedArena.getTeamBupgrades().toBukkitLocation(), Villager.class); + teamBUpgradesVillager.setCustomName(CC.translate("&aUpgrades Shop")); + teamBUpgradesVillager.setCustomNameVisible(true); + + this.addEntityToRemove(teamAShopVillager); + this.addEntityToRemove(teamBShopVillager); + this.addEntityToRemove(teamAUpgradesVillager); + this.addEntityToRemove(teamBUpgradesVillager); } } diff --git a/src/main/java/rip/tilly/bedwars/listeners/InteractListener.java b/src/main/java/rip/tilly/bedwars/listeners/InteractListener.java index be6d0fd..5c932d9 100644 --- a/src/main/java/rip/tilly/bedwars/listeners/InteractListener.java +++ b/src/main/java/rip/tilly/bedwars/listeners/InteractListener.java @@ -1,11 +1,10 @@ package rip.tilly.bedwars.listeners; -import org.bukkit.ChatColor; import org.bukkit.GameMode; import org.bukkit.Material; import org.bukkit.entity.ArmorStand; +import org.bukkit.entity.EntityType; import org.bukkit.entity.Player; -import org.bukkit.entity.Villager; import org.bukkit.event.EventHandler; import org.bukkit.event.Listener; import org.bukkit.event.block.Action; @@ -15,14 +14,12 @@ import org.bukkit.event.player.PlayerInteractEvent; import org.bukkit.inventory.ItemStack; import org.bukkit.material.TrapDoor; import rip.tilly.bedwars.BedWars; -import rip.tilly.bedwars.game.GameState; import rip.tilly.bedwars.managers.hotbar.impl.HotbarItem; import rip.tilly.bedwars.menus.queue.PlayAGameMenu; import rip.tilly.bedwars.menus.settings.SettingsMenu; import rip.tilly.bedwars.menus.shop.blocks.BlocksMenu; import rip.tilly.bedwars.playerdata.PlayerData; import rip.tilly.bedwars.playerdata.PlayerState; -import rip.tilly.bedwars.utils.CC; import rip.tilly.bedwars.utils.menusystem.menu.UpgradesMenu; public class InteractListener implements Listener { @@ -108,7 +105,7 @@ public class InteractListener implements Listener { // open party games menu break; case PARTY_INFO: - player.performCommand("party info"); + player.chat("/party info"); break; case PARTY_LEAVE: @@ -147,22 +144,20 @@ public class InteractListener implements Listener { return; } - String name = event.getRightClicked().getCustomName(); + String name = event.getRightClicked().getName(); if (name == null) { return; } - name = ChatColor.stripColor(name); - switch (name) { - case "Item Shop": + case "&aItem Shop": event.setCancelled(true); new BlocksMenu().openMenu(player); break; - case "Upgrades Shop": + case "&aUpgrades Shop": event.setCancelled(true); new UpgradesMenu(this.plugin.getPlayerMenuUtil(player)).open(player); @@ -170,4 +165,15 @@ public class InteractListener implements Listener { break; } } + + @EventHandler + public void onEntityDamage(EntityDamageEvent event) { + Player player = (Player) event.getEntity(); + + if (event.getEntityType() == EntityType.VILLAGER) { + event.setCancelled(true); + + return; + } + } }