forked from Upstream/CommandPanels
3.16.2.4
This commit is contained in:
parent
6aa3593a3f
commit
9dc1f1bacb
@ -48,6 +48,7 @@ placeholders:
|
|||||||
updater:
|
updater:
|
||||||
auto-update: true
|
auto-update: true
|
||||||
minor-updates-only: true
|
minor-updates-only: true
|
||||||
|
update-checks: true
|
||||||
purchase:
|
purchase:
|
||||||
currency:
|
currency:
|
||||||
success: '&aSuccessfully Bought For $%cp-args%'
|
success: '&aSuccessfully Bought For $%cp-args%'
|
||||||
|
@ -1,4 +1,4 @@
|
|||||||
version: 3.16.2.3
|
version: 3.16.2.4
|
||||||
main: me.rockyhawk.commandpanels.CommandPanels
|
main: me.rockyhawk.commandpanels.CommandPanels
|
||||||
name: CommandPanels
|
name: CommandPanels
|
||||||
author: RockyHawk
|
author: RockyHawk
|
||||||
|
@ -35,7 +35,6 @@ public class Utils implements Listener {
|
|||||||
//when clicked on a panel
|
//when clicked on a panel
|
||||||
Player p = (Player)e.getWhoClicked();
|
Player p = (Player)e.getWhoClicked();
|
||||||
int clickedSlot = e.getSlot();
|
int clickedSlot = e.getSlot();
|
||||||
ItemStack clicked = e.getCurrentItem();
|
|
||||||
|
|
||||||
if(!plugin.openPanels.hasPanelOpen(p.getName(),PanelPosition.Top) || e.getClick() == ClickType.DOUBLE_CLICK){
|
if(!plugin.openPanels.hasPanelOpen(p.getName(),PanelPosition.Top) || e.getClick() == ClickType.DOUBLE_CLICK){
|
||||||
return;
|
return;
|
||||||
@ -52,7 +51,7 @@ public class Utils implements Listener {
|
|||||||
//if the panel is clicked on the outside area of the GUI
|
//if the panel is clicked on the outside area of the GUI
|
||||||
if (panel.getConfig().contains("outside-commands")) {
|
if (panel.getConfig().contains("outside-commands")) {
|
||||||
try {
|
try {
|
||||||
plugin.commandTags.runCommands(panel,PanelPosition.Top,p, panel.getConfig().getStringList("outside-commands"));
|
plugin.commandTags.runCommands(panel,PanelPosition.Top,p, panel.getConfig().getStringList("outside-commands"),e.getClick());
|
||||||
}catch(Exception s){
|
}catch(Exception s){
|
||||||
plugin.debug(s,p);
|
plugin.debug(s,p);
|
||||||
}
|
}
|
||||||
@ -133,51 +132,12 @@ public class Utils implements Listener {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
commands = commandsAfterSequence;
|
commands = commandsAfterSequence;
|
||||||
for (int i = 0; commands.size() - 1 >= i; i++) {
|
plugin.commandTags.runCommands(panel,position,p,commands,e.getClick());
|
||||||
try {
|
/*for (int i = 0; commands.size() - 1 >= i; i++) {
|
||||||
switch(commands.get(i).split("\\s")[0]){
|
commands.set(i,plugin.commandTags.hasCorrectClick(commands.get(i),e.getClick()));
|
||||||
case "right=":{
|
if(commands.get(i).equals("")){
|
||||||
//if commands is for right clicking, remove the 'right=' and continue
|
//click type is wrong
|
||||||
commands.set(i, commands.get(i).replace("right=", "").trim());
|
continue;
|
||||||
if (e.getClick() != ClickType.RIGHT) {
|
|
||||||
continue;
|
|
||||||
}
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
case "rightshift=":{
|
|
||||||
//if commands is for right clicking, remove the 'right=' and continue
|
|
||||||
commands.set(i, commands.get(i).replace("rightshift=", "").trim());
|
|
||||||
if (e.getClick() != ClickType.SHIFT_RIGHT) {
|
|
||||||
continue;
|
|
||||||
}
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
case "left=":{
|
|
||||||
//if commands is for right clicking, remove the 'right=' and continue
|
|
||||||
commands.set(i, commands.get(i).replace("left=", "").trim());
|
|
||||||
if (e.getClick() != ClickType.LEFT) {
|
|
||||||
continue;
|
|
||||||
}
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
case "leftshift=":{
|
|
||||||
//if commands is for right clicking, remove the 'right=' and continue
|
|
||||||
commands.set(i, commands.get(i).replace("leftshift=", "").trim());
|
|
||||||
if (e.getClick() != ClickType.SHIFT_LEFT) {
|
|
||||||
continue;
|
|
||||||
}
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
case "middle=":{
|
|
||||||
commands.set(i, commands.get(i).replace("middle=", "").trim());
|
|
||||||
if (e.getClick() != ClickType.MIDDLE) {
|
|
||||||
continue;
|
|
||||||
}
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
} catch (Exception click) {
|
|
||||||
//skip if you can't do this
|
|
||||||
}
|
}
|
||||||
//start custom command placeholders
|
//start custom command placeholders
|
||||||
try {
|
try {
|
||||||
@ -198,7 +158,7 @@ public class Utils implements Listener {
|
|||||||
if(val == PaywallOutput.NotApplicable){
|
if(val == PaywallOutput.NotApplicable){
|
||||||
plugin.commandTags.runCommand(panel,position, p, commands.get(i));
|
plugin.commandTags.runCommand(panel,position, p, commands.get(i));
|
||||||
}
|
}
|
||||||
}
|
}*/
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -17,6 +17,7 @@ import org.bukkit.Bukkit;
|
|||||||
import org.bukkit.ChatColor;
|
import org.bukkit.ChatColor;
|
||||||
import org.bukkit.Material;
|
import org.bukkit.Material;
|
||||||
import org.bukkit.entity.Player;
|
import org.bukkit.entity.Player;
|
||||||
|
import org.bukkit.event.inventory.ClickType;
|
||||||
import org.bukkit.inventory.ItemStack;
|
import org.bukkit.inventory.ItemStack;
|
||||||
|
|
||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
@ -30,6 +31,25 @@ public class CommandTags {
|
|||||||
this.plugin = pl;
|
this.plugin = pl;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
//with the click type included
|
||||||
|
public void runCommands(Panel panel, PanelPosition position,Player p, List<String> commands, ClickType click){
|
||||||
|
for (String command : commands) {
|
||||||
|
command = plugin.commandTags.hasCorrectClick(command,click);
|
||||||
|
if(command.equals("")){
|
||||||
|
//click type is wrong
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
|
||||||
|
PaywallOutput val = plugin.commandTags.commandPayWall(panel,p,command);
|
||||||
|
if(val == PaywallOutput.Blocked){
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
if(val == PaywallOutput.NotApplicable){
|
||||||
|
plugin.commandTags.runCommand(panel,position,p, command);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
public void runCommands(Panel panel, PanelPosition position,Player p, List<String> commands){
|
public void runCommands(Panel panel, PanelPosition position,Player p, List<String> commands){
|
||||||
for (String command : commands) {
|
for (String command : commands) {
|
||||||
PaywallOutput val = plugin.commandTags.commandPayWall(panel,p,command);
|
PaywallOutput val = plugin.commandTags.commandPayWall(panel,p,command);
|
||||||
@ -65,6 +85,56 @@ public class CommandTags {
|
|||||||
plugin.getServer().getPluginManager().registerEvents(new ItemTags(plugin), plugin);
|
plugin.getServer().getPluginManager().registerEvents(new ItemTags(plugin), plugin);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public String hasCorrectClick(String command, ClickType click){
|
||||||
|
try {
|
||||||
|
switch(command.split("\\s")[0]){
|
||||||
|
case "right=":{
|
||||||
|
//if commands is for right clicking, remove the 'right=' and continue
|
||||||
|
command = command.replace("right= ", "");
|
||||||
|
if (click != ClickType.RIGHT) {
|
||||||
|
return "";
|
||||||
|
}
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
case "rightshift=":{
|
||||||
|
//if commands is for right clicking, remove the 'right=' and continue
|
||||||
|
command = command.replace("rightshift= ", "");
|
||||||
|
if (click != ClickType.SHIFT_RIGHT) {
|
||||||
|
return "";
|
||||||
|
}
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
case "left=":{
|
||||||
|
//if commands is for right clicking, remove the 'right=' and continue
|
||||||
|
command = command.replace("left= ", "");
|
||||||
|
if (click != ClickType.LEFT) {
|
||||||
|
return "";
|
||||||
|
}
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
case "leftshift=":{
|
||||||
|
//if commands is for right clicking, remove the 'right=' and continue
|
||||||
|
command = command.replace("leftshift= ", "");
|
||||||
|
if (click != ClickType.SHIFT_LEFT) {
|
||||||
|
return "";
|
||||||
|
}
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
case "middle=":{
|
||||||
|
command = command.replace("middle= ", "");
|
||||||
|
if (click != ClickType.MIDDLE) {
|
||||||
|
return "";
|
||||||
|
}
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return command;
|
||||||
|
} catch (Exception ex) {
|
||||||
|
return "";
|
||||||
|
//skip if you can't do this
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
@SuppressWarnings("deprecation")
|
@SuppressWarnings("deprecation")
|
||||||
public PaywallOutput commandPayWall(Panel panel, Player p, String command) { //return 0 means no funds, 1 is they passed and 2 means paywall is not this command
|
public PaywallOutput commandPayWall(Panel panel, Player p, String command) { //return 0 means no funds, 1 is they passed and 2 means paywall is not this command
|
||||||
String tag = plugin.config.getString("config.format.tag") + " ";
|
String tag = plugin.config.getString("config.format.tag") + " ";
|
||||||
|
@ -24,7 +24,7 @@ public class SpecialTags implements Listener {
|
|||||||
e.commandTagUsed();
|
e.commandTagUsed();
|
||||||
//if player uses open= it will open the panel, with the option to add custom placeholders
|
//if player uses open= it will open the panel, with the option to add custom placeholders
|
||||||
String panelName = e.args[0];
|
String panelName = e.args[0];
|
||||||
String cmd = String.join(" ",e.args).replace(e.args[0],"").trim();
|
String cmd = String.join(" ",e.args).replace(e.args[0] + " ","").trim();
|
||||||
|
|
||||||
Panel openPanel = null;
|
Panel openPanel = null;
|
||||||
PanelPosition openPosition = e.pos;
|
PanelPosition openPosition = e.pos;
|
||||||
|
@ -6,6 +6,7 @@ import me.rockyhawk.commandpanels.openpanelsmanager.PanelPosition;
|
|||||||
import org.bukkit.Bukkit;
|
import org.bukkit.Bukkit;
|
||||||
import org.bukkit.Material;
|
import org.bukkit.Material;
|
||||||
import org.bukkit.entity.Player;
|
import org.bukkit.entity.Player;
|
||||||
|
import org.bukkit.event.inventory.ClickType;
|
||||||
import org.bukkit.inventory.ItemStack;
|
import org.bukkit.inventory.ItemStack;
|
||||||
|
|
||||||
import java.util.HashMap;
|
import java.util.HashMap;
|
||||||
@ -30,7 +31,7 @@ public class HotbarItemLoader {
|
|||||||
}
|
}
|
||||||
|
|
||||||
//return true if found
|
//return true if found
|
||||||
public boolean stationaryExecute(int slot, Player p, boolean openPanel){
|
public boolean stationaryExecute(int slot, Player p, ClickType click, boolean openPanel){
|
||||||
if(stationaryItems.get(p.getUniqueId()).list.containsKey(slot)){
|
if(stationaryItems.get(p.getUniqueId()).list.containsKey(slot)){
|
||||||
if(openPanel) {
|
if(openPanel) {
|
||||||
try {
|
try {
|
||||||
@ -49,9 +50,7 @@ public class HotbarItemLoader {
|
|||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
if(panel.getHotbarSection(p).contains("commands")){
|
if(panel.getHotbarSection(p).contains("commands")){
|
||||||
for(String command : panel.getHotbarSection(p).getStringList("commands")){
|
plugin.commandTags.runCommands(panel,PanelPosition.Top,p,panel.getHotbarSection(p).getStringList("commands"),click);
|
||||||
plugin.commandTags.runCommand(panel,PanelPosition.Top,p, command);
|
|
||||||
}
|
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
panel.open(p, PanelPosition.Top);
|
panel.open(p, PanelPosition.Top);
|
||||||
|
@ -14,6 +14,10 @@ public class UtilsChestSortEvent implements Listener {
|
|||||||
}
|
}
|
||||||
@EventHandler
|
@EventHandler
|
||||||
public void onChestSortEvent(ChestSortEvent e){
|
public void onChestSortEvent(ChestSortEvent e){
|
||||||
|
//if player is null it is not necessary
|
||||||
|
if(e.getPlayer() == null){
|
||||||
|
return;
|
||||||
|
}
|
||||||
//cancel if a panel is opened at all
|
//cancel if a panel is opened at all
|
||||||
if(plugin.openPanels.hasPanelOpen(e.getPlayer().getName(), PanelPosition.Top)){
|
if(plugin.openPanels.hasPanelOpen(e.getPlayer().getName(), PanelPosition.Top)){
|
||||||
e.setCancelled(true);
|
e.setCancelled(true);
|
||||||
|
@ -40,7 +40,7 @@ public class UtilsOpenWithItem implements Listener {
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
if(e.getClickedInventory().getType() == InventoryType.PLAYER && !e.isCancelled()) {
|
if(e.getClickedInventory().getType() == InventoryType.PLAYER && !e.isCancelled()) {
|
||||||
if (plugin.hotbar.stationaryExecute(e.getSlot(), p, true)) {
|
if (plugin.hotbar.stationaryExecute(e.getSlot(), p,e.getClick(), true)) {
|
||||||
e.setCancelled(true);
|
e.setCancelled(true);
|
||||||
p.updateInventory();
|
p.updateInventory();
|
||||||
}
|
}
|
||||||
|
@ -28,7 +28,7 @@ public class Updater implements Listener {
|
|||||||
//send update message when the player joins the game with the permission
|
//send update message when the player joins the game with the permission
|
||||||
@EventHandler
|
@EventHandler
|
||||||
public void joinGame(PlayerJoinEvent e){
|
public void joinGame(PlayerJoinEvent e){
|
||||||
if(e.getPlayer().hasPermission("commandpanel.update")){
|
if(e.getPlayer().hasPermission("commandpanel.update") && plugin.config.getBoolean("updater.update-checks")){
|
||||||
if(githubNewUpdate(false)){
|
if(githubNewUpdate(false)){
|
||||||
new BukkitRunnable() {
|
new BukkitRunnable() {
|
||||||
@Override
|
@Override
|
||||||
|
Loading…
Reference in New Issue
Block a user