forked from Upstream/CommandPanels
v3.15.3.0
This commit is contained in:
parent
19d18d10d4
commit
6c0655e6e9
@ -1,4 +1,4 @@
|
|||||||
version: 3.15.2.4
|
version: 3.15.3.0
|
||||||
main: me.rockyhawk.commandpanels.CommandPanels
|
main: me.rockyhawk.commandpanels.CommandPanels
|
||||||
name: CommandPanels
|
name: CommandPanels
|
||||||
author: RockyHawk
|
author: RockyHawk
|
||||||
|
@ -10,6 +10,7 @@ import me.clip.placeholderapi.PlaceholderAPI;
|
|||||||
import me.rockyhawk.commandpanels.api.CommandPanelsAPI;
|
import me.rockyhawk.commandpanels.api.CommandPanelsAPI;
|
||||||
import me.rockyhawk.commandpanels.api.Panel;
|
import me.rockyhawk.commandpanels.api.Panel;
|
||||||
import me.rockyhawk.commandpanels.classresources.*;
|
import me.rockyhawk.commandpanels.classresources.*;
|
||||||
|
import me.rockyhawk.commandpanels.classresources.item_fall.ItemFallManager;
|
||||||
import me.rockyhawk.commandpanels.commands.*;
|
import me.rockyhawk.commandpanels.commands.*;
|
||||||
import me.rockyhawk.commandpanels.completetabs.CpTabComplete;
|
import me.rockyhawk.commandpanels.completetabs.CpTabComplete;
|
||||||
import me.rockyhawk.commandpanels.customcommands.CommandPlaceholderLoader;
|
import me.rockyhawk.commandpanels.customcommands.CommandPlaceholderLoader;
|
||||||
@ -140,6 +141,7 @@ public class CommandPanels extends JavaPlugin{
|
|||||||
this.getServer().getPluginManager().registerEvents(new UtilsPanelsLoader(this), this);
|
this.getServer().getPluginManager().registerEvents(new UtilsPanelsLoader(this), this);
|
||||||
this.getServer().getPluginManager().registerEvents(new GenUtils(this), this);
|
this.getServer().getPluginManager().registerEvents(new GenUtils(this), this);
|
||||||
this.getServer().getPluginManager().registerEvents(new CommandpanelUserInput(this), this);
|
this.getServer().getPluginManager().registerEvents(new CommandpanelUserInput(this), this);
|
||||||
|
this.getServer().getPluginManager().registerEvents(new ItemFallManager(this), this);
|
||||||
|
|
||||||
//if refresh-panels set to false, don't load this
|
//if refresh-panels set to false, don't load this
|
||||||
if(Objects.requireNonNull(config.getString("config.refresh-panels")).equalsIgnoreCase("true")){
|
if(Objects.requireNonNull(config.getString("config.refresh-panels")).equalsIgnoreCase("true")){
|
||||||
|
@ -273,6 +273,7 @@ public class ItemCreation {
|
|||||||
patterns.add(new Pattern(DyeColor.valueOf(dyePattern[0]), PatternType.valueOf(dyePattern[1]))); //load patterns in config: RED:STRIPE_TOP
|
patterns.add(new Pattern(DyeColor.valueOf(dyePattern[0]), PatternType.valueOf(dyePattern[1]))); //load patterns in config: RED:STRIPE_TOP
|
||||||
}
|
}
|
||||||
bannerMeta.setPatterns(patterns);
|
bannerMeta.setPatterns(patterns);
|
||||||
|
bannerMeta.addItemFlags(ItemFlag.HIDE_POTION_EFFECTS);
|
||||||
s.setItemMeta(bannerMeta);
|
s.setItemMeta(bannerMeta);
|
||||||
}
|
}
|
||||||
}catch(Exception ignore){
|
}catch(Exception ignore){
|
||||||
@ -327,20 +328,28 @@ public class ItemCreation {
|
|||||||
}
|
}
|
||||||
if (itemSection.contains("damage")) {
|
if (itemSection.contains("damage")) {
|
||||||
//change the damage amount (placeholders accepted)
|
//change the damage amount (placeholders accepted)
|
||||||
if(plugin.legacy.isLegacy()){
|
//if the damage is not unbreakable and should be a value
|
||||||
|
if (plugin.legacy.isLegacy()) {
|
||||||
try {
|
try {
|
||||||
s.setDurability(Short.parseShort(Objects.requireNonNull(plugin.papi(p, itemSection.getString("damage")))));
|
s.setDurability(Short.parseShort(Objects.requireNonNull(plugin.papi(p, itemSection.getString("damage")))));
|
||||||
}catch(Exception e){
|
} catch (Exception e) {
|
||||||
plugin.debug(e,p);
|
plugin.debug(e, p);
|
||||||
p.sendMessage(plugin.papi(plugin.tag + plugin.config.getString("config.format.error") + " damage: " + itemSection.getString("damage")));
|
p.sendMessage(plugin.papi(plugin.tag + plugin.config.getString("config.format.error") + " damage: " + itemSection.getString("damage")));
|
||||||
}
|
}
|
||||||
}else {
|
} else {
|
||||||
|
if(itemSection.getString("damage").equalsIgnoreCase("-1")){
|
||||||
|
//if the player wants the item to be unbreakable. Only works in non legacy versions
|
||||||
|
ItemMeta unbreak = s.getItemMeta();
|
||||||
|
unbreak.setUnbreakable(true);
|
||||||
|
s.setItemMeta(unbreak);
|
||||||
|
}
|
||||||
|
|
||||||
try {
|
try {
|
||||||
Damageable itemDamage = (Damageable) s.getItemMeta();
|
Damageable itemDamage = (Damageable) s.getItemMeta();
|
||||||
itemDamage.setDamage(Integer.parseInt(Objects.requireNonNull(plugin.papi(p, itemSection.getString("damage")))));
|
itemDamage.setDamage(Integer.parseInt(Objects.requireNonNull(plugin.papi(p, itemSection.getString("damage")))));
|
||||||
s.setItemMeta((ItemMeta) itemDamage);
|
s.setItemMeta((ItemMeta) itemDamage);
|
||||||
} catch (Exception e) {
|
} catch (Exception e) {
|
||||||
plugin.debug(e,p);
|
plugin.debug(e, p);
|
||||||
p.sendMessage(plugin.papi(plugin.tag + plugin.config.getString("config.format.error") + " damage: " + itemSection.getString("damage")));
|
p.sendMessage(plugin.papi(plugin.tag + plugin.config.getString("config.format.error") + " damage: " + itemSection.getString("damage")));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -369,7 +378,7 @@ public class ItemCreation {
|
|||||||
|
|
||||||
//hasperm hasvalue, etc sections will be done here
|
//hasperm hasvalue, etc sections will be done here
|
||||||
public String hasSection(ConfigurationSection cf, Player p){
|
public String hasSection(ConfigurationSection cf, Player p){
|
||||||
if (cf.contains("hasvalue")) {
|
if (cf.isSet("hasvalue")) {
|
||||||
//this will do the hasvalue without any numbers
|
//this will do the hasvalue without any numbers
|
||||||
boolean outputValue = true;
|
boolean outputValue = true;
|
||||||
//outputValue will default to true
|
//outputValue will default to true
|
||||||
|
@ -0,0 +1,45 @@
|
|||||||
|
package me.rockyhawk.commandpanels.classresources.item_fall;
|
||||||
|
|
||||||
|
import me.rockyhawk.commandpanels.CommandPanels;
|
||||||
|
import me.rockyhawk.commandpanels.api.PanelClosedEvent;
|
||||||
|
import org.bukkit.Bukkit;
|
||||||
|
import org.bukkit.Material;
|
||||||
|
import org.bukkit.event.EventHandler;
|
||||||
|
import org.bukkit.event.Listener;
|
||||||
|
import org.bukkit.inventory.ItemStack;
|
||||||
|
import org.bukkit.scheduler.BukkitRunnable;
|
||||||
|
|
||||||
|
public class ItemFallManager implements Listener {
|
||||||
|
CommandPanels plugin;
|
||||||
|
public ItemFallManager(CommandPanels pl) {
|
||||||
|
this.plugin = pl;
|
||||||
|
}
|
||||||
|
|
||||||
|
@EventHandler
|
||||||
|
public void panelCloseItemsDrop(PanelClosedEvent e){
|
||||||
|
new BukkitRunnable(){
|
||||||
|
@Override
|
||||||
|
public void run(){
|
||||||
|
for(String item : e.getPanel().getConfig().getConfigurationSection("item").getKeys(false)){
|
||||||
|
if(e.getPanel().getConfig().isSet("item." + item + ".itemType")){
|
||||||
|
if(e.getPanel().getConfig().getStringList("item." + item + ".itemType").contains("dropItem")){
|
||||||
|
ItemStack stack = e.getPlayer().getOpenInventory().getTopInventory().getItem(Integer.parseInt(item));
|
||||||
|
if(stack == null || stack.getType() == Material.AIR){
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
|
||||||
|
//trigger event and check for cancel
|
||||||
|
PanelItemDropEvent dropEvent = new PanelItemDropEvent(e.getPlayer(),e.getPanel(),stack);
|
||||||
|
Bukkit.getPluginManager().callEvent(dropEvent);
|
||||||
|
if(dropEvent.isCancelled()){
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
|
||||||
|
e.getPlayer().getWorld().dropItem(e.getPlayer().getLocation(),stack);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}.run();
|
||||||
|
}
|
||||||
|
}
|
@ -0,0 +1,51 @@
|
|||||||
|
package me.rockyhawk.commandpanels.classresources.item_fall;
|
||||||
|
|
||||||
|
import me.rockyhawk.commandpanels.api.Panel;
|
||||||
|
import org.bukkit.entity.Player;
|
||||||
|
import org.bukkit.event.Cancellable;
|
||||||
|
import org.bukkit.event.Event;
|
||||||
|
import org.bukkit.event.HandlerList;
|
||||||
|
import org.bukkit.inventory.ItemStack;
|
||||||
|
|
||||||
|
public class PanelItemDropEvent extends Event implements Cancellable {
|
||||||
|
|
||||||
|
private boolean isCancelled;
|
||||||
|
private final Player p;
|
||||||
|
private final Panel panel;
|
||||||
|
private final ItemStack item;
|
||||||
|
|
||||||
|
public boolean isCancelled() {
|
||||||
|
return this.isCancelled;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setCancelled(boolean isCancelled) {
|
||||||
|
this.isCancelled = isCancelled;
|
||||||
|
}
|
||||||
|
|
||||||
|
public PanelItemDropEvent(Player player, Panel panel, ItemStack drop) {
|
||||||
|
this.p = player;
|
||||||
|
this.panel = panel;
|
||||||
|
this.item = drop;
|
||||||
|
}
|
||||||
|
|
||||||
|
public Player getPlayer(){
|
||||||
|
return this.p;
|
||||||
|
}
|
||||||
|
|
||||||
|
public ItemStack getItem(){
|
||||||
|
return this.item;
|
||||||
|
}
|
||||||
|
|
||||||
|
public Panel getPanel(){
|
||||||
|
return this.panel;
|
||||||
|
}
|
||||||
|
|
||||||
|
private static final HandlerList HANDLERS = new HandlerList();
|
||||||
|
public HandlerList getHandlers() {
|
||||||
|
return HANDLERS;
|
||||||
|
}
|
||||||
|
|
||||||
|
public static HandlerList getHandlerList() {
|
||||||
|
return HANDLERS;
|
||||||
|
}
|
||||||
|
}
|
@ -44,6 +44,9 @@ public class HotbarItemLoader {
|
|||||||
if(!plugin.panelPerms.isPanelWorldEnabled(p,panel.getConfig())){
|
if(!plugin.panelPerms.isPanelWorldEnabled(p,panel.getConfig())){
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
if(!itemCheckExecute(p.getInventory().getItem(slot),p,false,false)){
|
||||||
|
return false;
|
||||||
|
}
|
||||||
if(panel.getConfig().contains("open-with-item.commands")){
|
if(panel.getConfig().contains("open-with-item.commands")){
|
||||||
for(String command : panel.getConfig().getStringList("open-with-item.commands")){
|
for(String command : panel.getConfig().getStringList("open-with-item.commands")){
|
||||||
plugin.commandTags.commandTags(p,plugin.papi(p,command),command);
|
plugin.commandTags.commandTags(p,plugin.papi(p,command),command);
|
||||||
|
@ -18,7 +18,6 @@ public class UtilsChestSortEvent implements Listener {
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
//If the ChestSort plugin triggers an event
|
//If the ChestSort plugin triggers an event
|
||||||
plugin.getServer().getConsoleSender().sendMessage(e.getInventory().getType().toString());
|
|
||||||
if(e.getInventory().getType() == InventoryType.PLAYER){
|
if(e.getInventory().getType() == InventoryType.PLAYER){
|
||||||
for(int slot : plugin.hotbar.getStationaryItemSlots()){
|
for(int slot : plugin.hotbar.getStationaryItemSlots()){
|
||||||
e.setUnmovable(slot);
|
e.setUnmovable(slot);
|
||||||
|
Loading…
Reference in New Issue
Block a user