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