From ce6f250235b4b026a933f6218d7a09bf3079caf6 Mon Sep 17 00:00:00 2001 From: Brian Neumann-Fopiano Date: Sat, 29 Jul 2023 05:54:45 -0400 Subject: [PATCH] Fixed things! --- build.gradle | 2 +- .../adapt/api/adaptation/Adaptation.java | 2 +- .../com/volmit/adapt/api/skill/Skill.java | 2 +- .../volmit/adapt/api/skill/SkillRegistry.java | 10 +++-- .../adapt/content/gui/CorruptionGui.java | 40 ------------------- 5 files changed, 9 insertions(+), 47 deletions(-) delete mode 100644 src/main/java/com/volmit/adapt/content/gui/CorruptionGui.java diff --git a/build.gradle b/build.gradle index ba593271..5a6865fa 100644 --- a/build.gradle +++ b/build.gradle @@ -23,7 +23,7 @@ plugins { id "de.undercouch.download" version "5.0.1" } -version '1.12.0-1.20.1' +version '1.12.1-1.20.1' def nmsVersion = "1.20.1" //[NMS] def apiVersion = '1.20' def specialSourceVersion = '1.11.0' //[NMS] diff --git a/src/main/java/com/volmit/adapt/api/adaptation/Adaptation.java b/src/main/java/com/volmit/adapt/api/adaptation/Adaptation.java index e839c762..c84ae0d5 100644 --- a/src/main/java/com/volmit/adapt/api/adaptation/Adaptation.java +++ b/src/main/java/com/volmit/adapt/api/adaptation/Adaptation.java @@ -389,7 +389,7 @@ default void openGui(Player player) { player.getWorld().playSound(player.getLocation(), Sound.ITEM_BOOK_PAGE_TURN, 0.3f, 0.855f); Window w = new UIWindow(player); w.setTag("skill/" + getSkill().getName() + "/" + getName()); - w.setDecorator((window, position, row) -> new UIElement("bg").setMaterial(new MaterialBlock(Material.BLACK_STAINED_GLASS_PANE))); + w.setDecorator((window, position, row) -> new UIElement("bg").setName(" ").setMaterial(new MaterialBlock(Material.BLACK_STAINED_GLASS_PANE))); w.setResolution(WindowResolution.W9_H6); int o = 0; diff --git a/src/main/java/com/volmit/adapt/api/skill/Skill.java b/src/main/java/com/volmit/adapt/api/skill/Skill.java index 4456e4dc..76e764ce 100644 --- a/src/main/java/com/volmit/adapt/api/skill/Skill.java +++ b/src/main/java/com/volmit/adapt/api/skill/Skill.java @@ -207,7 +207,7 @@ default void openGui(Player player) { player.getWorld().playSound(player.getLocation(), Sound.ITEM_BOOK_PAGE_TURN, 0.3f, 1.855f); Window w = new UIWindow(player); w.setTag("skill/" + getName()); - w.setDecorator((window, position, row) -> new UIElement("bg").setMaterial(new MaterialBlock(Material.BLACK_STAINED_GLASS_PANE))); + w.setDecorator((window, position, row) -> new UIElement("bg").setName(" ").setMaterial(new MaterialBlock(Material.BLACK_STAINED_GLASS_PANE))); int ind = 0; diff --git a/src/main/java/com/volmit/adapt/api/skill/SkillRegistry.java b/src/main/java/com/volmit/adapt/api/skill/SkillRegistry.java index 4c6c1e21..514a5c3f 100644 --- a/src/main/java/com/volmit/adapt/api/skill/SkillRegistry.java +++ b/src/main/java/com/volmit/adapt/api/skill/SkillRegistry.java @@ -31,10 +31,7 @@ import com.volmit.adapt.util.C; import com.volmit.adapt.util.Form; import com.volmit.adapt.util.M; -import org.bukkit.Bukkit; -import org.bukkit.Material; -import org.bukkit.Particle; -import org.bukkit.Sound; +import org.bukkit.*; import org.bukkit.block.BlockFace; import org.bukkit.entity.Player; import org.bukkit.event.EventHandler; @@ -88,6 +85,10 @@ public void on(PlayerExpChangeEvent e) { } } + private boolean canInteract(Player player, Location targetLocation) { + return Adapt.instance.getProtectorRegistry().getAllProtectors().stream().allMatch(protector -> protector.canInteract(player, targetLocation, null)); + } + @EventHandler(priority = EventPriority.MONITOR) public void on(PlayerInteractEvent e) { Player p = e.getPlayer(); @@ -97,6 +98,7 @@ public void on(PlayerInteractEvent e) { boolean isObserver = commonConditions && e.getClickedBlock().getType().equals(Material.OBSERVER); boolean isAdaptActivator = !e.getBlockFace().equals(BlockFace.UP) && !e.getBlockFace().equals(BlockFace.DOWN) && !p.isSneaking() && e.getAction().equals(Action.RIGHT_CLICK_BLOCK) && e.getClickedBlock() != null + && canInteract(p, e.getClickedBlock().getLocation()) && e.getClickedBlock().getType().equals(Material.valueOf(AdaptConfig.get().adaptActivatorBlock)) && (p.getInventory().getItemInMainHand().getType().equals(Material.AIR) || !p.getInventory().getItemInMainHand().getType().isBlock()) && (p.getInventory().getItemInOffHand().getType().equals(Material.AIR) || !p.getInventory().getItemInOffHand().getType().isBlock()); diff --git a/src/main/java/com/volmit/adapt/content/gui/CorruptionGui.java b/src/main/java/com/volmit/adapt/content/gui/CorruptionGui.java deleted file mode 100644 index 4072a1a8..00000000 --- a/src/main/java/com/volmit/adapt/content/gui/CorruptionGui.java +++ /dev/null @@ -1,40 +0,0 @@ -/*------------------------------------------------------------------------------ - - Adapt is a Skill/Integration plugin for Minecraft Bukkit Servers - - Copyright (c) 2022 Arcane Arts (Volmit Software) - - - - 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 . - -----------------------------------------------------------------------------*/ - -package com.volmit.adapt.content.gui; - -import com.volmit.adapt.Adapt; -import com.volmit.adapt.api.world.AdaptPlayer; -import com.volmit.adapt.api.xp.XP; -import com.volmit.adapt.util.*; -import org.bukkit.Material; -import org.bukkit.entity.Player; - -public class CorruptionGui { - public static void open(Player player) { - Window w = new UIWindow(player); - w.setResolution(WindowResolution.W9_H6); - w.setDecorator((window, position, row) -> new UIElement("bg").setMaterial(new MaterialBlock(Material.BLACK_STAINED_GLASS_PANE))); - - AdaptPlayer a = Adapt.instance.getAdaptServer().getPlayer(player); - int ind = 0; - - w.setTitle(Localizer.dLocalize("snippets", "gui", "level") + " " + (int) XP.getLevelForXp(a.getData().getMasterXp()) + " (" + a.getData().getUsedPower() + "/" + a.getData().getMaxPower() + " " + Localizer.dLocalize("snippets", "gui", "powerused") + ")"); - w.open(); - } -}