forked from Upstream/CommandPanels
3.15.7.1
This commit is contained in:
parent
a88ffc13b4
commit
87a5765fd6
@ -1,4 +1,4 @@
|
|||||||
version: 3.15.7.0
|
version: 3.15.7.1
|
||||||
main: me.rockyhawk.commandpanels.CommandPanels
|
main: me.rockyhawk.commandpanels.CommandPanels
|
||||||
name: CommandPanels
|
name: CommandPanels
|
||||||
author: RockyHawk
|
author: RockyHawk
|
||||||
|
@ -6,7 +6,7 @@ import me.rockyhawk.commandpanels.api.Panel;
|
|||||||
import me.rockyhawk.commandpanels.classresources.ExecuteOpenVoids;
|
import me.rockyhawk.commandpanels.classresources.ExecuteOpenVoids;
|
||||||
import me.rockyhawk.commandpanels.classresources.GetCustomHeads;
|
import me.rockyhawk.commandpanels.classresources.GetCustomHeads;
|
||||||
import me.rockyhawk.commandpanels.classresources.ItemCreation;
|
import me.rockyhawk.commandpanels.classresources.ItemCreation;
|
||||||
import me.rockyhawk.commandpanels.classresources.OpenEditorGuis;
|
import me.rockyhawk.commandpanels.ingameeditor.OpenEditorGuis;
|
||||||
import me.rockyhawk.commandpanels.classresources.item_fall.ItemFallManager;
|
import me.rockyhawk.commandpanels.classresources.item_fall.ItemFallManager;
|
||||||
import me.rockyhawk.commandpanels.classresources.placeholders.CreateText;
|
import me.rockyhawk.commandpanels.classresources.placeholders.CreateText;
|
||||||
import me.rockyhawk.commandpanels.classresources.placeholders.HexColours;
|
import me.rockyhawk.commandpanels.classresources.placeholders.HexColours;
|
||||||
|
@ -2,6 +2,7 @@ package me.rockyhawk.commandpanels.ingameeditor;
|
|||||||
|
|
||||||
import me.rockyhawk.commandpanels.CommandPanels;
|
import me.rockyhawk.commandpanels.CommandPanels;
|
||||||
import me.rockyhawk.commandpanels.api.Panel;
|
import me.rockyhawk.commandpanels.api.Panel;
|
||||||
|
import org.bukkit.Bukkit;
|
||||||
import org.bukkit.ChatColor;
|
import org.bukkit.ChatColor;
|
||||||
import org.bukkit.Material;
|
import org.bukkit.Material;
|
||||||
import org.bukkit.Sound;
|
import org.bukkit.Sound;
|
||||||
@ -372,19 +373,18 @@ public class EditorUserInput implements Listener {
|
|||||||
}
|
}
|
||||||
try {
|
try {
|
||||||
int loc = Integer.parseInt(e.getMessage());
|
int loc = Integer.parseInt(e.getMessage());
|
||||||
if (loc >= 34 || loc <= -1) {
|
if (loc >= 36 || loc <= -1) {
|
||||||
//if the number isn't between 1-9
|
//if the number isn't between the numbers
|
||||||
p.sendMessage(plugin.tex.colour( plugin.tag + ChatColor.GREEN + "Choose an integer between 0 to 33!"));
|
p.sendMessage(plugin.tex.colour( plugin.tag + ChatColor.GREEN + "Choose an integer between 0 to 35!"));
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
p.sendMessage(plugin.tex.colour( plugin.tag + ChatColor.GREEN + "Set Hotbar Location to " + loc + "!"));
|
p.sendMessage(plugin.tex.colour( plugin.tag + ChatColor.GREEN + "Set Hotbar Location to " + loc + "!"));
|
||||||
//because it needs to convert 1-9 to 0-8 for in the panel
|
|
||||||
loc -= 1;
|
|
||||||
cf.set("open-with-item.stationary", loc);
|
cf.set("open-with-item.stationary", loc);
|
||||||
savePanelFile(cf, cfile, panelName, panelFile);
|
savePanelFile(cf, cfile, panelName, panelFile);
|
||||||
} catch (Exception io) {
|
} catch (Exception io) {
|
||||||
plugin.debug(io,p);
|
plugin.debug(io,p);
|
||||||
}
|
}
|
||||||
|
plugin.hotbar.reloadHotbarSlots();
|
||||||
break;
|
break;
|
||||||
case "panel.hotbar.name":
|
case "panel.hotbar.name":
|
||||||
cf.set("open-with-item.name",e.getMessage());
|
cf.set("open-with-item.name",e.getMessage());
|
||||||
|
@ -316,7 +316,7 @@ public class EditorUtils implements Listener {
|
|||||||
boolean found = false;
|
boolean found = false;
|
||||||
boolean hotbarItems = false;
|
boolean hotbarItems = false;
|
||||||
try {
|
try {
|
||||||
//neew to loop through files to get file names
|
//need to loop through files to get file names
|
||||||
for(Panel panel : plugin.panelList) { //will loop through all the files in folder
|
for(Panel panel : plugin.panelList) { //will loop through all the files in folder
|
||||||
if(e.getView().getTitle().equals("Panel Settings: " + panel.getName())){
|
if(e.getView().getTitle().equals("Panel Settings: " + panel.getName())){
|
||||||
panelName = panel.getName();
|
panelName = panel.getName();
|
||||||
@ -440,7 +440,7 @@ public class EditorUtils implements Listener {
|
|||||||
}
|
}
|
||||||
if(e.getSlot() == 42 && hotbarItems){
|
if(e.getSlot() == 42 && hotbarItems){
|
||||||
plugin.editorInputStrings.add(new String[]{p.getName(),panelName,"panel.hotbar.stationary"});
|
plugin.editorInputStrings.add(new String[]{p.getName(),panelName,"panel.hotbar.stationary"});
|
||||||
p.sendMessage(plugin.tex.colour(plugin.tag + ChatColor.WHITE + "Enter Location (1 to 9)"));
|
p.sendMessage(plugin.tex.colour(plugin.tag + ChatColor.WHITE + "Enter Location (0 to 35)"));
|
||||||
p.closeInventory();
|
p.closeInventory();
|
||||||
}
|
}
|
||||||
if(e.getSlot() == 44 && hotbarItems){
|
if(e.getSlot() == 44 && hotbarItems){
|
||||||
|
@ -1,4 +1,4 @@
|
|||||||
package me.rockyhawk.commandpanels.classresources;
|
package me.rockyhawk.commandpanels.ingameeditor;
|
||||||
|
|
||||||
import me.rockyhawk.commandpanels.CommandPanels;
|
import me.rockyhawk.commandpanels.CommandPanels;
|
||||||
import me.rockyhawk.commandpanels.api.Panel;
|
import me.rockyhawk.commandpanels.api.Panel;
|
||||||
@ -306,7 +306,7 @@ public class OpenEditorGuis {
|
|||||||
temp = new ItemStack(Material.BEDROCK, 1);
|
temp = new ItemStack(Material.BEDROCK, 1);
|
||||||
lore.clear();
|
lore.clear();
|
||||||
lore.add(ChatColor.GRAY + "Hotbar location for the item");
|
lore.add(ChatColor.GRAY + "Hotbar location for the item");
|
||||||
lore.add(ChatColor.GRAY + "choose a number from 0 to 33");
|
lore.add(ChatColor.GRAY + "choose a number from 0 to 35");
|
||||||
if (cf.contains("open-with-item.stationary")) {
|
if (cf.contains("open-with-item.stationary")) {
|
||||||
lore.add(ChatColor.WHITE + "-------------------------");
|
lore.add(ChatColor.WHITE + "-------------------------");
|
||||||
int location = cf.getInt("open-with-item.stationary");
|
int location = cf.getInt("open-with-item.stationary");
|
@ -2,7 +2,8 @@ package me.rockyhawk.commandpanels.openwithitem;
|
|||||||
|
|
||||||
import me.rockyhawk.commandpanels.CommandPanels;
|
import me.rockyhawk.commandpanels.CommandPanels;
|
||||||
import me.rockyhawk.commandpanels.api.Panel;
|
import me.rockyhawk.commandpanels.api.Panel;
|
||||||
import org.apache.commons.lang.ObjectUtils;
|
import org.bukkit.Bukkit;
|
||||||
|
import org.bukkit.Material;
|
||||||
import org.bukkit.entity.Player;
|
import org.bukkit.entity.Player;
|
||||||
import org.bukkit.inventory.ItemStack;
|
import org.bukkit.inventory.ItemStack;
|
||||||
|
|
||||||
@ -15,7 +16,7 @@ public class HotbarItemLoader {
|
|||||||
this.plugin = pl;
|
this.plugin = pl;
|
||||||
}
|
}
|
||||||
|
|
||||||
//stationary slots 0-8 are the hotbar, using 9-33 for inside the inventory
|
//stationary slots 0-8 are the hotbar, using 9-35 for inside the inventory
|
||||||
HashMap<Integer,Panel> stationaryItems = new HashMap<>();
|
HashMap<Integer,Panel> stationaryItems = new HashMap<>();
|
||||||
|
|
||||||
//will compile the ArrayList {slot 0-4, index of panelNames}
|
//will compile the ArrayList {slot 0-4, index of panelNames}
|
||||||
@ -26,6 +27,10 @@ public class HotbarItemLoader {
|
|||||||
stationaryItems.put(panel.getConfig().getInt("open-with-item.stationary"), panel.copy());
|
stationaryItems.put(panel.getConfig().getInt("open-with-item.stationary"), panel.copy());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
//update hotbar items for all players when reloaded
|
||||||
|
for(Player p : Bukkit.getServer().getOnlinePlayers()){
|
||||||
|
plugin.hotbar.updateHotbarItems(p);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public Set<Integer> getStationaryItemSlots(){
|
public Set<Integer> getStationaryItemSlots(){
|
||||||
@ -68,7 +73,7 @@ public class HotbarItemLoader {
|
|||||||
if (plugin.nbt.getNBT(invItem, "CommandPanelsHotbar") == null) {
|
if (plugin.nbt.getNBT(invItem, "CommandPanelsHotbar") == null) {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
}catch(NullPointerException nu){
|
}catch(IllegalArgumentException | NullPointerException nu){
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
for(Panel panel : plugin.panelList) {
|
for(Panel panel : plugin.panelList) {
|
||||||
@ -98,4 +103,43 @@ public class HotbarItemLoader {
|
|||||||
}
|
}
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public void updateHotbarItems(Player p){
|
||||||
|
/*
|
||||||
|
If the player is using disabled-worlds/enabled-worlds
|
||||||
|
and they change worlds, it will check if the player can have the item
|
||||||
|
and if they can, it gives the item. This is because onRespawn doesn't
|
||||||
|
give the item to the player in all the worlds that it could automatically.
|
||||||
|
|
||||||
|
The player will of course need a plugin to split inventories between worlds
|
||||||
|
for this to take effect. I don't want to delete the item on the wrong world
|
||||||
|
because then it might overwrite one of their actual slots upon rejoining the enabled world.
|
||||||
|
*/
|
||||||
|
if(!plugin.openWithItem){
|
||||||
|
//if none of the panels have open-with-item
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
//remove any old hotbar items
|
||||||
|
for(int i = 0; i <= 35; i++){
|
||||||
|
try {
|
||||||
|
if (plugin.nbt.getNBT(p.getInventory().getItem(i), "CommandPanelsHotbar") != null) {
|
||||||
|
p.getInventory().setItem(i,new ItemStack(Material.AIR));
|
||||||
|
}
|
||||||
|
}catch(NullPointerException | IllegalArgumentException ignore){}
|
||||||
|
}
|
||||||
|
|
||||||
|
//add current hotbar items
|
||||||
|
for(Panel panel : plugin.panelList) { //will loop through all the files in folder
|
||||||
|
if(!plugin.panelPerms.isPanelWorldEnabled(p,panel.getConfig())){
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
if (p.hasPermission("commandpanel.panel." + panel.getConfig().getString("perm")) && panel.hasHotbarItem()) {
|
||||||
|
ItemStack s = panel.getHotbarItem(p);
|
||||||
|
if(panel.getConfig().contains("open-with-item.stationary")) {
|
||||||
|
p.getInventory().setItem(panel.getConfig().getInt("open-with-item.stationary"),s);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
@ -68,52 +68,11 @@ public class UtilsOpenWithItem implements Listener {
|
|||||||
}
|
}
|
||||||
@EventHandler
|
@EventHandler
|
||||||
public void onWorldChange(PlayerChangedWorldEvent e){
|
public void onWorldChange(PlayerChangedWorldEvent e){
|
||||||
/*
|
plugin.hotbar.updateHotbarItems(e.getPlayer());
|
||||||
This world change event is added so if the player is using disabled-worlds
|
|
||||||
and they change worlds, it will check if the player can have the item
|
|
||||||
and if they can, it gives the item. This is because onRespawn doesn't
|
|
||||||
give the item to the player in all the worlds that it could automatically.
|
|
||||||
|
|
||||||
The player will of course need a plugin to split inventories between worlds
|
|
||||||
for this to take effect. I don't want to delete the item on the wrong world
|
|
||||||
because then it might overwrite one of their actual slots upon rejoining the enabled world.
|
|
||||||
*/
|
|
||||||
if(!plugin.openWithItem){
|
|
||||||
//if none of the panels have open-with-item
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
Player p = e.getPlayer();
|
|
||||||
|
|
||||||
for(Panel panel : plugin.panelList) { //will loop through all the files in folder
|
|
||||||
if(!plugin.panelPerms.isPanelWorldEnabled(p,panel.getConfig())){
|
|
||||||
continue;
|
|
||||||
}
|
|
||||||
if (p.hasPermission("commandpanel.panel." + panel.getConfig().getString("perm")) && panel.hasHotbarItem()) {
|
|
||||||
ItemStack s = panel.getHotbarItem(p);
|
|
||||||
if(panel.getConfig().contains("open-with-item.stationary")) {
|
|
||||||
p.getInventory().setItem(panel.getConfig().getInt("open-with-item.stationary"),s);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
@EventHandler
|
@EventHandler
|
||||||
public void onPlayerRespawn(PlayerRespawnEvent e){
|
public void onPlayerRespawn(PlayerRespawnEvent e){
|
||||||
if(!plugin.openWithItem){
|
plugin.hotbar.updateHotbarItems(e.getPlayer());
|
||||||
//if none of the panels have open-with-item
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
Player p = e.getPlayer();
|
|
||||||
for(Panel panel : plugin.panelList) { //will loop through all the files in folder
|
|
||||||
if(!plugin.panelPerms.isPanelWorldEnabled(p,panel.getConfig())){
|
|
||||||
continue;
|
|
||||||
}
|
|
||||||
if (p.hasPermission("commandpanel.panel." + panel.getConfig().getString("perm")) && panel.hasHotbarItem()) {
|
|
||||||
ItemStack s = panel.getHotbarItem(p);
|
|
||||||
if(panel.getConfig().contains("open-with-item.stationary")){
|
|
||||||
p.getInventory().setItem(panel.getConfig().getInt("open-with-item.stationary"), s);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
@EventHandler
|
@EventHandler
|
||||||
public void onPlayerDeath(PlayerDeathEvent e){
|
public void onPlayerDeath(PlayerDeathEvent e){
|
||||||
@ -133,30 +92,7 @@ public class UtilsOpenWithItem implements Listener {
|
|||||||
}
|
}
|
||||||
@EventHandler
|
@EventHandler
|
||||||
public void onPlayerJoin(PlayerJoinEvent e){
|
public void onPlayerJoin(PlayerJoinEvent e){
|
||||||
if(!plugin.openWithItem){
|
plugin.hotbar.updateHotbarItems(e.getPlayer());
|
||||||
//if none of the panels have open-with-item
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
Player p = e.getPlayer();
|
|
||||||
for(Panel panel : plugin.panelList) { //will loop through all the files in folder
|
|
||||||
if(!panel.getConfig().contains("open-with-item.stationary")){
|
|
||||||
continue;
|
|
||||||
}
|
|
||||||
if (p.hasPermission("commandpanel.panel." + panel.getConfig().getString("perm"))){
|
|
||||||
if(!plugin.panelPerms.isPanelWorldEnabled(p,panel.getConfig())){
|
|
||||||
continue;
|
|
||||||
}
|
|
||||||
ItemStack s = panel.getHotbarItem(p);
|
|
||||||
p.getInventory().setItem(panel.getConfig().getInt("open-with-item.stationary"), s);
|
|
||||||
}else{
|
|
||||||
//if the player has an item that they have no permission for, remove it
|
|
||||||
ItemStack s;
|
|
||||||
s = panel.getHotbarItem(p);
|
|
||||||
if (p.getInventory().getItem(panel.getConfig().getInt("open-with-item.stationary")).isSimilar(s)) {
|
|
||||||
p.getInventory().setItem(panel.getConfig().getInt("open-with-item.stationary"), null);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
@EventHandler
|
@EventHandler
|
||||||
public void onPlayerDropItem(PlayerDropItemEvent e){
|
public void onPlayerDropItem(PlayerDropItemEvent e){
|
||||||
|
Loading…
Reference in New Issue
Block a user