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;
|
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=")) {
|
if(e.name.equalsIgnoreCase("title=")) {
|
||||||
e.commandTagUsed();
|
e.commandTagUsed();
|
||||||
//added into the 1.11 API
|
//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.CommandPanels;
|
||||||
import me.rockyhawk.commandpanels.commandtags.CommandTagEvent;
|
import me.rockyhawk.commandpanels.commandtags.CommandTagEvent;
|
||||||
import me.rockyhawk.commandpanels.openpanelsmanager.PanelPosition;
|
import me.rockyhawk.commandpanels.openpanelsmanager.PanelPosition;
|
||||||
|
import org.bukkit.Material;
|
||||||
import org.bukkit.NamespacedKey;
|
import org.bukkit.NamespacedKey;
|
||||||
import org.bukkit.enchantments.Enchantment;
|
import org.bukkit.enchantments.Enchantment;
|
||||||
import org.bukkit.event.EventHandler;
|
import org.bukkit.event.EventHandler;
|
||||||
@ -22,14 +23,27 @@ public class ItemTags implements Listener {
|
|||||||
public void commandTag(CommandTagEvent e){
|
public void commandTag(CommandTagEvent e){
|
||||||
if(e.name.equalsIgnoreCase("give-item=")){
|
if(e.name.equalsIgnoreCase("give-item=")){
|
||||||
e.commandTagUsed();
|
e.commandTagUsed();
|
||||||
ItemStack itm = plugin.itemCreate.makeCustomItemFromConfig(null,e.pos,e.panel.getConfig().getConfigurationSection("custom-item." + e.args[0]), e.p, true, true, false);
|
ItemStack itm;
|
||||||
if(e.args.length == 2){
|
if (Material.matchMaterial(e.args[0]) == null) {
|
||||||
try{
|
itm = plugin.itemCreate.makeCustomItemFromConfig(null,e.pos,e.panel.getConfig().getConfigurationSection("custom-item." + e.args[0]), e.p, true, true, false);
|
||||||
itm.setAmount(Integer.parseInt(e.args[1]));
|
if(e.args.length == 2){
|
||||||
} catch (Exception err){
|
try{
|
||||||
plugin.debug(err,e.p);
|
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);
|
plugin.inventorySaver.addItem(e.p,itm);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
@ -31,6 +31,9 @@ public class GenUtils implements Listener {
|
|||||||
@EventHandler
|
@EventHandler
|
||||||
public void onInventoryClose(InventoryCloseEvent e) {
|
public void onInventoryClose(InventoryCloseEvent e) {
|
||||||
Player p = (Player)e.getPlayer();
|
Player p = (Player)e.getPlayer();
|
||||||
|
if(!this.plugin.generateMode.contains(p)){
|
||||||
|
return;
|
||||||
|
}
|
||||||
if(!ChatColor.stripColor(e.getView().getTitle()).equals("Generate New Panel")){
|
if(!ChatColor.stripColor(e.getView().getTitle()).equals("Generate New Panel")){
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
@ -26,11 +26,17 @@ public class OpenGUI {
|
|||||||
ConfigurationSection pconfig = panel.getConfig();
|
ConfigurationSection pconfig = panel.getConfig();
|
||||||
|
|
||||||
Inventory i;
|
Inventory i;
|
||||||
|
String title = "";
|
||||||
if(position == PanelPosition.Top) {
|
if(position == PanelPosition.Top) {
|
||||||
String title;
|
|
||||||
if(pconfig.contains("custom-title")) {
|
if(pconfig.contains("custom-title")) {
|
||||||
//used for titles in the custom-title section, for has sections
|
//used for titles in the custom-title section, for has sections
|
||||||
String section = plugin.has.hasSection(panel,position,pconfig.getConfigurationSection("custom-title"), p);
|
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"));
|
title = plugin.tex.placeholders(panel, position, p, pconfig.getString("custom-title" + section + ".title"));
|
||||||
}else {
|
}else {
|
||||||
//regular inventory title
|
//regular inventory title
|
||||||
@ -175,6 +181,9 @@ public class OpenGUI {
|
|||||||
} else if (openType == PanelOpenType.Refresh) {
|
} else if (openType == PanelOpenType.Refresh) {
|
||||||
//openType 0 will just refresh the panel
|
//openType 0 will just refresh the panel
|
||||||
if(position == PanelPosition.Top) {
|
if(position == PanelPosition.Top) {
|
||||||
|
if(!p.getOpenInventory().getTitle().equals(title) && !title.isEmpty()){
|
||||||
|
p.getOpenInventory().setTitle(title);
|
||||||
|
}
|
||||||
p.getOpenInventory().getTopInventory().setContents(i.getContents());
|
p.getOpenInventory().getTopInventory().setContents(i.getContents());
|
||||||
}
|
}
|
||||||
} else if (openType == PanelOpenType.Return) {
|
} else if (openType == PanelOpenType.Return) {
|
||||||
|
@ -143,7 +143,7 @@ public class InventorySaver implements Listener {
|
|||||||
p.getInventory().addItem(item);
|
p.getInventory().addItem(item);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
}else {
|
} else {
|
||||||
List<ItemStack> cont = new ArrayList<>(Arrays.asList(getNormalInventory(p)));
|
List<ItemStack> cont = new ArrayList<>(Arrays.asList(getNormalInventory(p)));
|
||||||
boolean found = false;
|
boolean found = false;
|
||||||
for (int i = 0; 36 > i; i++){
|
for (int i = 0; 36 > i; i++){
|
||||||
|
Loading…
Reference in New Issue
Block a user