forked from Upstream/CommandPanels
3.17.3.1
This commit is contained in:
parent
ef819bc34f
commit
d01d54fe43
@ -1,7 +1,7 @@
|
||||
<component name="libraryTable">
|
||||
<library name="spigot-api-1.18-rc3-R0.1-SNAPSHOT">
|
||||
<library name="spigot-api-1.18.1-R0.1-SNAPSHOT">
|
||||
<CLASSES>
|
||||
<root url="jar://$PROJECT_DIR$/../../../Intellij Plugin Testers/Plugin Tester 1.18.1/bundler/libraries/spigot-api-1.18-rc3-R0.1-SNAPSHOT.jar!/" />
|
||||
<root url="jar://$PROJECT_DIR$/../../../Intellij Plugin Testers/Plugin Tester 1.18.1/bundler/libraries/spigot-api-1.18.1-R0.1-SNAPSHOT.jar!/" />
|
||||
</CLASSES>
|
||||
<JAVADOC />
|
||||
<SOURCES />
|
@ -19,8 +19,9 @@
|
||||
<orderEntry type="library" name="PlaceholderAPI-2.10.9" level="project" />
|
||||
<orderEntry type="library" name="MMOItems-6.6.1" level="project" />
|
||||
<orderEntry type="library" name="MythicLib-1.1.3" level="project" />
|
||||
<orderEntry type="library" name="spigot-api-1.18-rc3-R0.1-SNAPSHOT" level="project" />
|
||||
<orderEntry type="library" name="spigot-api-1.18.1-R0.1-SNAPSHOT" level="project" />
|
||||
<orderEntry type="library" name="spigot" level="project" />
|
||||
<orderEntry type="library" name="spigot-1.13.2" level="project" />
|
||||
<orderEntry type="library" name="spigot" level="project" />
|
||||
</component>
|
||||
</module>
|
@ -1,6 +1,6 @@
|
||||
# |------------------------------------------------------------------------
|
||||
# | CommandPanels Legacy Example File
|
||||
# | By RockyHawk v2.2
|
||||
# | By RockyHawk v2.3
|
||||
# | https://www.spigotmc.org/resources/command-panels-custom-guis.67788/
|
||||
# |------------------------------------------------------------------------
|
||||
panels:
|
||||
@ -34,10 +34,9 @@ panels:
|
||||
'10':
|
||||
material: REDSTONE_BLOCK
|
||||
name: '&fTake the diamond'
|
||||
hasvalue:
|
||||
value: DIAMOND
|
||||
output: false
|
||||
compare: '%cp-material-1%'
|
||||
has0:
|
||||
value0: NOT DIAMOND
|
||||
compare0: '%cp-material-1%'
|
||||
name: '&fNice One!'
|
||||
material: EMERALD_BLOCK
|
||||
'9':
|
||||
@ -92,10 +91,9 @@ panels:
|
||||
name: '&cYour nickname is not ''RockyHawk'''
|
||||
commands:
|
||||
- 'msg= &cNot RockyHawk'
|
||||
hasvalue:
|
||||
output: true
|
||||
value: RockyHawk
|
||||
compare: '%cp-player-name%'
|
||||
has0:
|
||||
value0: RockyHawk
|
||||
compare0: '%cp-player-name%'
|
||||
material: WOOL
|
||||
ID: 5
|
||||
name: '&aYour username is ''RockyHawk'''
|
||||
@ -132,9 +130,9 @@ panels:
|
||||
lore:
|
||||
- '&4You cannot change to'
|
||||
- '&4creative looking like that!'
|
||||
hasperm:
|
||||
perm: essentials.gamemode
|
||||
output: true
|
||||
has0:
|
||||
value0: '%cp-player-name% HASPERM'
|
||||
compare0: essentials.gamemode
|
||||
material: EMERALD_BLOCK
|
||||
name: '&aClick Me'
|
||||
lore:
|
||||
|
@ -1,4 +1,4 @@
|
||||
version: 3.17.3.0
|
||||
version: 3.17.3.1
|
||||
main: me.rockyhawk.commandpanels.CommandPanels
|
||||
name: CommandPanels
|
||||
author: RockyHawk
|
||||
|
@ -11,6 +11,7 @@ import org.bukkit.inventory.meta.ItemMeta;
|
||||
import org.bukkit.inventory.meta.SkullMeta;
|
||||
|
||||
import java.lang.reflect.Field;
|
||||
import java.lang.reflect.Method;
|
||||
import java.util.Iterator;
|
||||
import java.util.UUID;
|
||||
|
||||
@ -70,34 +71,33 @@ public class GetCustomHeads {
|
||||
ItemStack head = new ItemStack(Material.matchMaterial(plugin.getHeads.playerHeadString()), 1,id);
|
||||
ItemMeta headMeta = head.getItemMeta();
|
||||
assert headMeta != null;
|
||||
Class headMetaClass = headMeta.getClass();
|
||||
|
||||
Field profileField;
|
||||
Method setProfileMethod = null;
|
||||
try {
|
||||
getField(headMetaClass, "profile", GameProfile.class, 0).set(headMeta, profile);
|
||||
} catch (IllegalArgumentException | IllegalAccessException var10) {
|
||||
plugin.debug(var10,null);
|
||||
profileField = headMeta.getClass().getDeclaredField("profile");
|
||||
profileField.setAccessible(true);
|
||||
profileField.set(headMeta, profile);
|
||||
} catch (NoSuchFieldException | IllegalArgumentException | IllegalAccessException e1) {
|
||||
try {
|
||||
setProfileMethod = headMeta.getClass().getDeclaredMethod("setProfile", GameProfile.class);
|
||||
} catch (NoSuchMethodException ignore) {}
|
||||
} catch (SecurityException ignored) {}
|
||||
try {
|
||||
if (setProfileMethod == null) {
|
||||
profileField = headMeta.getClass().getDeclaredField("profile");
|
||||
profileField.setAccessible(true);
|
||||
profileField.set(headMeta, profile);
|
||||
} else {
|
||||
setProfileMethod.setAccessible(true);
|
||||
setProfileMethod.invoke(headMeta, profile);
|
||||
}
|
||||
} catch (Exception e1) {
|
||||
plugin.debug(e1,null);
|
||||
}
|
||||
|
||||
head.setItemMeta(headMeta);
|
||||
return head;
|
||||
}
|
||||
}
|
||||
|
||||
//used with getItem for heads
|
||||
private <T> Field getField(Class<?> target, String name, Class<T> fieldType, int index) {
|
||||
Field[] var4 = target.getDeclaredFields();
|
||||
|
||||
for (Field field : var4) {
|
||||
if ((name == null || field.getName().equals(name)) && fieldType.isAssignableFrom(field.getType()) && index-- <= 0) {
|
||||
field.setAccessible(true);
|
||||
return field;
|
||||
}
|
||||
}
|
||||
|
||||
if (target.getSuperclass() != null) {
|
||||
return getField(target.getSuperclass(), name, fieldType, index);
|
||||
} else {
|
||||
throw new IllegalArgumentException("Cannot find field with type " + fieldType);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -17,6 +17,8 @@ import org.bukkit.event.inventory.InventoryType;
|
||||
import org.bukkit.event.player.*;
|
||||
import org.bukkit.inventory.ItemStack;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
import java.util.Objects;
|
||||
|
||||
public class UtilsOpenWithItem implements Listener {
|
||||
@ -80,14 +82,16 @@ public class UtilsOpenWithItem implements Listener {
|
||||
//if none of the panels have open-with-item
|
||||
return;
|
||||
}
|
||||
Player p = e.getEntity();
|
||||
for(Panel panel : plugin.panelList) { //will loop through all the files in folder
|
||||
if (p.hasPermission("commandpanel.panel." + panel.getConfig().getString("perm")) && panel.hasHotbarItem()) {
|
||||
if(panel.getConfig().contains("open-with-item.stationary")){
|
||||
ItemStack s = panel.getHotbarItem(p);
|
||||
//a new list instance has to be created with the dropped items to avoid ConcurrentModificationException
|
||||
for(ItemStack s : new ArrayList<>(e.getDrops())){
|
||||
try {
|
||||
if (plugin.nbt.getNBT(s, "CommandPanelsHotbar") != null) {
|
||||
//do not remove items that are not stationary
|
||||
if(!plugin.nbt.getNBT(s, "CommandPanelsHotbar").endsWith("-1")) {
|
||||
e.getDrops().remove(s);
|
||||
}
|
||||
}
|
||||
}catch(NullPointerException | IllegalArgumentException ignore){}
|
||||
}
|
||||
}
|
||||
@EventHandler
|
||||
|
Loading…
Reference in New Issue
Block a user