forked from Upstream/CommandPanels
Merge pull request #312 from TinyTank800/master
Animated titles and give-item expansion.
This commit is contained in:
commit
d7d6444352
@ -70,6 +70,20 @@ public class SpecialTags implements Listener {
|
||||
}
|
||||
return;
|
||||
}
|
||||
if(e.name.equalsIgnoreCase("panel-title=")) {
|
||||
e.commandTagUsed();
|
||||
//added into the 1.20 API
|
||||
//will set the open panel title to the provided string panel-title= <VALUE>
|
||||
//AS OF TINYTANK800's pull this only works on static panels!
|
||||
if(e.args.length >= 1){
|
||||
StringBuilder title = new StringBuilder();
|
||||
for(String args : e.args){
|
||||
title.append(args).append(" ");
|
||||
}
|
||||
e.p.getOpenInventory().setTitle(title.toString());
|
||||
}
|
||||
return;
|
||||
}
|
||||
if(e.name.equalsIgnoreCase("title=")) {
|
||||
e.commandTagUsed();
|
||||
//added into the 1.11 API
|
||||
|
@ -3,6 +3,7 @@ package me.rockyhawk.commandpanels.commandtags.tags.standard;
|
||||
import me.rockyhawk.commandpanels.CommandPanels;
|
||||
import me.rockyhawk.commandpanels.commandtags.CommandTagEvent;
|
||||
import me.rockyhawk.commandpanels.openpanelsmanager.PanelPosition;
|
||||
import org.bukkit.Material;
|
||||
import org.bukkit.NamespacedKey;
|
||||
import org.bukkit.enchantments.Enchantment;
|
||||
import org.bukkit.event.EventHandler;
|
||||
@ -22,14 +23,27 @@ public class ItemTags implements Listener {
|
||||
public void commandTag(CommandTagEvent e){
|
||||
if(e.name.equalsIgnoreCase("give-item=")){
|
||||
e.commandTagUsed();
|
||||
ItemStack itm = plugin.itemCreate.makeCustomItemFromConfig(null,e.pos,e.panel.getConfig().getConfigurationSection("custom-item." + e.args[0]), e.p, true, true, false);
|
||||
if(e.args.length == 2){
|
||||
try{
|
||||
itm.setAmount(Integer.parseInt(e.args[1]));
|
||||
} catch (Exception err){
|
||||
plugin.debug(err,e.p);
|
||||
ItemStack itm;
|
||||
if (Material.matchMaterial(e.args[0]) == null) {
|
||||
itm = plugin.itemCreate.makeCustomItemFromConfig(null,e.pos,e.panel.getConfig().getConfigurationSection("custom-item." + e.args[0]), e.p, true, true, false);
|
||||
if(e.args.length == 2){
|
||||
try{
|
||||
itm.setAmount(Integer.parseInt(e.args[1]));
|
||||
} catch (Exception err){
|
||||
plugin.debug(err,e.p);
|
||||
}
|
||||
}
|
||||
} else {
|
||||
itm = new ItemStack(Objects.requireNonNull(Material.matchMaterial(e.args[0])));
|
||||
if(e.args.length == 2){
|
||||
try{
|
||||
itm.setAmount(Integer.parseInt(e.args[1]));
|
||||
} catch (Exception err){
|
||||
plugin.debug(err,e.p);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
plugin.inventorySaver.addItem(e.p,itm);
|
||||
return;
|
||||
}
|
||||
|
@ -31,6 +31,9 @@ public class GenUtils implements Listener {
|
||||
@EventHandler
|
||||
public void onInventoryClose(InventoryCloseEvent e) {
|
||||
Player p = (Player)e.getPlayer();
|
||||
if(!this.plugin.generateMode.contains(p)){
|
||||
return;
|
||||
}
|
||||
if(!ChatColor.stripColor(e.getView().getTitle()).equals("Generate New Panel")){
|
||||
return;
|
||||
}
|
||||
|
@ -26,11 +26,17 @@ public class OpenGUI {
|
||||
ConfigurationSection pconfig = panel.getConfig();
|
||||
|
||||
Inventory i;
|
||||
String title = "";
|
||||
if(position == PanelPosition.Top) {
|
||||
String title;
|
||||
if(pconfig.contains("custom-title")) {
|
||||
//used for titles in the custom-title section, for has sections
|
||||
String section = plugin.has.hasSection(panel,position,pconfig.getConfigurationSection("custom-title"), p);
|
||||
|
||||
//check for if there is animations inside the custom-title section
|
||||
if (pconfig.contains("custom-title" + section + ".animate" + animateValue)) {
|
||||
section = section + ".animate" + animateValue;
|
||||
}
|
||||
|
||||
title = plugin.tex.placeholders(panel, position, p, pconfig.getString("custom-title" + section + ".title"));
|
||||
}else {
|
||||
//regular inventory title
|
||||
@ -175,6 +181,9 @@ public class OpenGUI {
|
||||
} else if (openType == PanelOpenType.Refresh) {
|
||||
//openType 0 will just refresh the panel
|
||||
if(position == PanelPosition.Top) {
|
||||
if(!p.getOpenInventory().getTitle().equals(title) && !title.isEmpty()){
|
||||
p.getOpenInventory().setTitle(title);
|
||||
}
|
||||
p.getOpenInventory().getTopInventory().setContents(i.getContents());
|
||||
}
|
||||
} else if (openType == PanelOpenType.Return) {
|
||||
|
@ -143,7 +143,7 @@ public class InventorySaver implements Listener {
|
||||
p.getInventory().addItem(item);
|
||||
return;
|
||||
}
|
||||
}else {
|
||||
} else {
|
||||
List<ItemStack> cont = new ArrayList<>(Arrays.asList(getNormalInventory(p)));
|
||||
boolean found = false;
|
||||
for (int i = 0; 36 > i; i++){
|
||||
|
Loading…
Reference in New Issue
Block a user