forked from Upstream/CommandPanels
Merge pull request #263 from jman13378/jman13378-patch-1
Added some new features
This commit is contained in:
commit
228ccec717
12
.github/ISSUE_TEMPLATE/bug_report.yml
vendored
12
.github/ISSUE_TEMPLATE/bug_report.yml
vendored
@ -40,6 +40,18 @@ body:
|
|||||||
attributes:
|
attributes:
|
||||||
label: What CommandPanels version are you using?
|
label: What CommandPanels version are you using?
|
||||||
options:
|
options:
|
||||||
|
- latest
|
||||||
|
- 3.19.0.3
|
||||||
|
- 3.19.0.2
|
||||||
|
- 3.19.0.1
|
||||||
|
- 3.19.0.0
|
||||||
|
- 3.18.6.2
|
||||||
|
- 3.18.6.1
|
||||||
|
- 3.18.6.0
|
||||||
|
- 3.18.5.1
|
||||||
|
- 3.18.5.0
|
||||||
|
- 3.18.4.1
|
||||||
|
- 3.18.4.0
|
||||||
- 3.18.3.0
|
- 3.18.3.0
|
||||||
- 3.18.2.0
|
- 3.18.2.0
|
||||||
- 3.18.1.4
|
- 3.18.1.4
|
||||||
|
20
.github/ISSUE_TEMPLATE/need-help.yml
vendored
20
.github/ISSUE_TEMPLATE/need-help.yml
vendored
@ -1,6 +1,6 @@
|
|||||||
name: Need help
|
name: Need help
|
||||||
description: Create an issue for a problem you are having.
|
description: Create an issue for a problem you are having.
|
||||||
labels: ["help wanted"]
|
labels: [ "help wanted" ]
|
||||||
body:
|
body:
|
||||||
- type: checkboxes
|
- type: checkboxes
|
||||||
id: searched
|
id: searched
|
||||||
@ -32,12 +32,24 @@ body:
|
|||||||
- 1.18
|
- 1.18
|
||||||
- 1.19
|
- 1.19
|
||||||
validations:
|
validations:
|
||||||
required: true
|
required: true
|
||||||
- type: dropdown
|
- type: dropdown
|
||||||
id: commandpanels_version
|
id: commandpanels_version
|
||||||
attributes:
|
attributes:
|
||||||
label: What CommandPanels version are you using?
|
label: What CommandPanels version are you using?
|
||||||
options:
|
options:
|
||||||
|
- latest
|
||||||
|
- 3.19.0.3
|
||||||
|
- 3.19.0.2
|
||||||
|
- 3.19.0.1
|
||||||
|
- 3.19.0.0
|
||||||
|
- 3.18.6.2
|
||||||
|
- 3.18.6.1
|
||||||
|
- 3.18.6.0
|
||||||
|
- 3.18.5.1
|
||||||
|
- 3.18.5.0
|
||||||
|
- 3.18.4.1
|
||||||
|
- 3.18.4.0
|
||||||
- 3.18.3.0
|
- 3.18.3.0
|
||||||
- 3.18.2.0
|
- 3.18.2.0
|
||||||
- 3.18.1.4
|
- 3.18.1.4
|
||||||
@ -64,7 +76,7 @@ body:
|
|||||||
- 3.17.1.0
|
- 3.17.1.0
|
||||||
- Any other version
|
- Any other version
|
||||||
validations:
|
validations:
|
||||||
required: true
|
required: true
|
||||||
- type: dropdown
|
- type: dropdown
|
||||||
id: server_software
|
id: server_software
|
||||||
attributes:
|
attributes:
|
||||||
@ -82,7 +94,7 @@ body:
|
|||||||
- Velocity
|
- Velocity
|
||||||
- Travertine
|
- Travertine
|
||||||
validations:
|
validations:
|
||||||
required: true
|
required: true
|
||||||
- type: textarea
|
- type: textarea
|
||||||
id: what-happened
|
id: what-happened
|
||||||
attributes:
|
attributes:
|
||||||
|
3
.gitignore
vendored
3
.gitignore
vendored
@ -1,2 +1,3 @@
|
|||||||
# Project exclude paths
|
# Project exclude paths
|
||||||
/out/
|
/out/
|
||||||
|
/target/
|
@ -1,5 +1,10 @@
|
|||||||
<?xml version="1.0" encoding="UTF-8"?>
|
<?xml version="1.0" encoding="UTF-8"?>
|
||||||
<project version="4">
|
<project version="4">
|
||||||
|
<component name="EntryPointsManager">
|
||||||
|
<list size="1">
|
||||||
|
<item index="0" class="java.lang.String" itemvalue="org.bukkit.event.EventHandler" />
|
||||||
|
</list>
|
||||||
|
</component>
|
||||||
<component name="MavenProjectsManager">
|
<component name="MavenProjectsManager">
|
||||||
<option name="originalFiles">
|
<option name="originalFiles">
|
||||||
<list>
|
<list>
|
||||||
|
@ -1,5 +1,16 @@
|
|||||||
<?xml version="1.0" encoding="UTF-8"?>
|
<?xml version="1.0" encoding="UTF-8"?>
|
||||||
<module org.jetbrains.idea.maven.project.MavenProjectsManager.isMavenModule="true" type="JAVA_MODULE" version="4">
|
<module org.jetbrains.idea.maven.project.MavenProjectsManager.isMavenModule="true" type="JAVA_MODULE" version="4">
|
||||||
|
<component name="FacetManager">
|
||||||
|
<facet type="minecraft" name="Minecraft">
|
||||||
|
<configuration>
|
||||||
|
<autoDetectTypes>
|
||||||
|
<platformType>ADVENTURE</platformType>
|
||||||
|
<platformType>SPIGOT</platformType>
|
||||||
|
<platformType>BUKKIT</platformType>
|
||||||
|
</autoDetectTypes>
|
||||||
|
</configuration>
|
||||||
|
</facet>
|
||||||
|
</component>
|
||||||
<component name="NewModuleRootManager" LANGUAGE_LEVEL="JDK_1_8">
|
<component name="NewModuleRootManager" LANGUAGE_LEVEL="JDK_1_8">
|
||||||
<output url="file://$MODULE_DIR$/target/classes" />
|
<output url="file://$MODULE_DIR$/target/classes" />
|
||||||
<output-test url="file://$MODULE_DIR$/target/test-classes" />
|
<output-test url="file://$MODULE_DIR$/target/test-classes" />
|
||||||
|
@ -75,3 +75,7 @@ purchase:
|
|||||||
enable: true
|
enable: true
|
||||||
success: '&aSuccessfully Bought For %cp-args% Experience.'
|
success: '&aSuccessfully Bought For %cp-args% Experience.'
|
||||||
failure: '&cInsufficient Experience!'
|
failure: '&cInsufficient Experience!'
|
||||||
|
permission:
|
||||||
|
enable: true
|
||||||
|
success: '&aYou have successfully passed the permission check for "%cp-args%".'
|
||||||
|
failure: '&cInefficient Permissions'
|
@ -1,4 +1,4 @@
|
|||||||
version: 3.19.0.3
|
version: 3.19.0.3-DEV
|
||||||
main: me.rockyhawk.commandpanels.CommandPanels
|
main: me.rockyhawk.commandpanels.CommandPanels
|
||||||
name: CommandPanels
|
name: CommandPanels
|
||||||
author: RockyHawk
|
author: RockyHawk
|
||||||
|
@ -1,5 +1,6 @@
|
|||||||
package me.rockyhawk.commandpanels;
|
package me.rockyhawk.commandpanels;
|
||||||
|
|
||||||
|
import com.bencodez.votingplugin.VotingPluginHooks;
|
||||||
import io.lumine.mythic.lib.api.item.NBTItem;
|
import io.lumine.mythic.lib.api.item.NBTItem;
|
||||||
import me.rockyhawk.commandpanels.api.CommandPanelsAPI;
|
import me.rockyhawk.commandpanels.api.CommandPanelsAPI;
|
||||||
import me.rockyhawk.commandpanels.api.Panel;
|
import me.rockyhawk.commandpanels.api.Panel;
|
||||||
@ -66,6 +67,7 @@ import java.util.*;
|
|||||||
import java.util.concurrent.Callable;
|
import java.util.concurrent.Callable;
|
||||||
|
|
||||||
public class CommandPanels extends JavaPlugin{
|
public class CommandPanels extends JavaPlugin{
|
||||||
|
public VotingPluginHooks votingPlugin;
|
||||||
public YamlConfiguration config;
|
public YamlConfiguration config;
|
||||||
public Economy econ = null;
|
public Economy econ = null;
|
||||||
public boolean openWithItem = false; //this will be true if there is a panel with open-with-item
|
public boolean openWithItem = false; //this will be true if there is a panel with open-with-item
|
||||||
@ -213,7 +215,10 @@ public class CommandPanels extends JavaPlugin{
|
|||||||
if (!Bukkit.getVersion().contains("1.8")) {
|
if (!Bukkit.getVersion().contains("1.8")) {
|
||||||
this.getServer().getPluginManager().registerEvents(new SwapItemEvent(this), this);
|
this.getServer().getPluginManager().registerEvents(new SwapItemEvent(this), this);
|
||||||
}
|
}
|
||||||
|
//if VotingPlugin is enabled
|
||||||
|
if (getServer().getPluginManager().isPluginEnabled("VotingPlugin")) {
|
||||||
|
votingPlugin= VotingPluginHooks.getInstance();
|
||||||
|
}
|
||||||
//if plugin ChestSort is enabled
|
//if plugin ChestSort is enabled
|
||||||
if(getServer().getPluginManager().isPluginEnabled("ChestSort")){
|
if(getServer().getPluginManager().isPluginEnabled("ChestSort")){
|
||||||
this.getServer().getPluginManager().registerEvents(new UtilsChestSortEvent(this), this);
|
this.getServer().getPluginManager().registerEvents(new UtilsChestSortEvent(this), this);
|
||||||
|
@ -142,8 +142,12 @@ public class Utils implements Listener {
|
|||||||
commands.set(i, commands.get(i).replaceAll("%cp-clicked%", "AIR"));
|
commands.set(i, commands.get(i).replaceAll("%cp-clicked%", "AIR"));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
if (panel.getConfig().contains("item." + clickedSlot + section + ".multi-paywall")) {
|
||||||
plugin.commandTags.runCommands(panel,position,p,commands,e.getClick());
|
plugin.commandTags.runMultiPaywall(panel,position,p,
|
||||||
|
panel.getConfig().getStringList("item." + clickedSlot + section + ".multi-paywall"),
|
||||||
|
commands,e.getClick());
|
||||||
|
} else
|
||||||
|
plugin.commandTags.runCommands(panel,position,p,commands,e.getClick());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -16,7 +16,6 @@ import java.io.IOException;
|
|||||||
import java.net.InetSocketAddress;
|
import java.net.InetSocketAddress;
|
||||||
import java.net.Socket;
|
import java.net.Socket;
|
||||||
import java.util.*;
|
import java.util.*;
|
||||||
import java.util.stream.Collectors;
|
|
||||||
|
|
||||||
public class Placeholders {
|
public class Placeholders {
|
||||||
CommandPanels plugin;
|
CommandPanels plugin;
|
||||||
|
@ -10,9 +10,12 @@ import org.bukkit.scheduler.BukkitRunnable;
|
|||||||
|
|
||||||
public class CommandPanelImport implements CommandExecutor {
|
public class CommandPanelImport implements CommandExecutor {
|
||||||
CommandPanels plugin;
|
CommandPanels plugin;
|
||||||
public CommandPanelImport(CommandPanels pl) { this.plugin = pl; }
|
|
||||||
|
|
||||||
@EventHandler
|
public CommandPanelImport(CommandPanels pl) {
|
||||||
|
this.plugin = pl;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
public boolean onCommand(CommandSender sender, Command cmd, String label, String[] args) {
|
public boolean onCommand(CommandSender sender, Command cmd, String label, String[] args) {
|
||||||
if (sender.hasPermission("commandpanel.import")) {
|
if (sender.hasPermission("commandpanel.import")) {
|
||||||
if (args.length == 2) {
|
if (args.length == 2) {
|
||||||
@ -20,14 +23,14 @@ public class CommandPanelImport implements CommandExecutor {
|
|||||||
new BukkitRunnable() {
|
new BukkitRunnable() {
|
||||||
@Override
|
@Override
|
||||||
public void run() {
|
public void run() {
|
||||||
plugin.downloader.downloadPanel(sender,args[1],args[0]);
|
plugin.downloader.downloadPanel(sender, args[1], args[0]);
|
||||||
plugin.reloadPanelFiles();
|
plugin.reloadPanelFiles();
|
||||||
plugin.hotbar.reloadHotbarSlots();
|
plugin.hotbar.reloadHotbarSlots();
|
||||||
}
|
}
|
||||||
}.run();
|
}.run();
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
}else{
|
} else {
|
||||||
sender.sendMessage(plugin.tex.colour(plugin.tag + plugin.config.getString("config.format.perms")));
|
sender.sendMessage(plugin.tex.colour(plugin.tag + plugin.config.getString("config.format.perms")));
|
||||||
}
|
}
|
||||||
sender.sendMessage(plugin.tex.colour(plugin.tag + ChatColor.RED + "Usage: /cpi <file name> <url>"));
|
sender.sendMessage(plugin.tex.colour(plugin.tag + ChatColor.RED + "Usage: /cpi <file name> <url>"));
|
||||||
|
@ -3,6 +3,7 @@ package me.rockyhawk.commandpanels.commands;
|
|||||||
import me.rockyhawk.commandpanels.CommandPanels;
|
import me.rockyhawk.commandpanels.CommandPanels;
|
||||||
import me.rockyhawk.commandpanels.api.Panel;
|
import me.rockyhawk.commandpanels.api.Panel;
|
||||||
import me.rockyhawk.commandpanels.openpanelsmanager.PanelPosition;
|
import me.rockyhawk.commandpanels.openpanelsmanager.PanelPosition;
|
||||||
|
import org.bukkit.Bukkit;
|
||||||
import org.bukkit.ChatColor;
|
import org.bukkit.ChatColor;
|
||||||
import org.bukkit.command.Command;
|
import org.bukkit.command.Command;
|
||||||
import org.bukkit.command.CommandExecutor;
|
import org.bukkit.command.CommandExecutor;
|
||||||
@ -17,77 +18,97 @@ public class Commandpanel implements CommandExecutor {
|
|||||||
this.plugin = pl;
|
this.plugin = pl;
|
||||||
}
|
}
|
||||||
|
|
||||||
@EventHandler
|
@Override
|
||||||
public boolean onCommand(CommandSender sender, Command cmd, String label, String[] args) {
|
public boolean onCommand(CommandSender sender, Command cmd, String label, String[] args) {
|
||||||
//below is going to go through the files and find the right one
|
//below is going to go through the files and find the right one
|
||||||
Panel panel = null;
|
Panel panel = null;
|
||||||
if (args.length != 0) { //check to make sure the person hasn't just left it empty
|
if (args.length != 0) { //check to make sure the person hasn't just left it empty
|
||||||
for(Panel tempPanel : plugin.panelList){
|
for (Panel tempPanel : plugin.panelList) {
|
||||||
if(tempPanel.getName().equals(args[0])) {
|
if (tempPanel.getName().equals(args[0])) {
|
||||||
panel = tempPanel;
|
panel = tempPanel;
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}else{
|
} else {
|
||||||
plugin.helpMessage(sender);
|
plugin.helpMessage(sender);
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
if(panel == null){
|
if (panel == null) {
|
||||||
sender.sendMessage(plugin.tex.colour(plugin.tag + plugin.config.getString("config.format.nopanel")));
|
sender.sendMessage(plugin.tex.colour(plugin.tag + plugin.config.getString("config.format.nopanel")));
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
boolean disableCommand = false;
|
boolean disableCommand = false;
|
||||||
if(panel.getConfig().contains("panelType")) {
|
if (panel.getConfig().contains("panelType")) {
|
||||||
if (panel.getConfig().getStringList("panelType").contains("nocommand")) {
|
if (panel.getConfig().getStringList("panelType").contains("nocommand")) {
|
||||||
//do not allow command with noCommand, console is an exception
|
//do not allow command with noCommand, console is an exception
|
||||||
disableCommand = true;
|
disableCommand = true;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
//below will start the command, once it got the right file and panel
|
//below will start the command, once it got the right file and panel
|
||||||
if(!(sender instanceof Player)) {
|
if (!(sender instanceof Player)) {
|
||||||
//do console command
|
//do console command
|
||||||
if(args.length == 2){
|
if (args.length == 2) {
|
||||||
if(!args[1].equals("item")){
|
if (!args[1].equals("item")) {
|
||||||
plugin.openVoids.openCommandPanel(sender, plugin.getServer().getPlayer(args[1]), panel.copy(), PanelPosition.Top, true);
|
if (args[1].equalsIgnoreCase("all")) {
|
||||||
}else{
|
for (Player player : Bukkit.getOnlinePlayers())
|
||||||
sender.sendMessage(plugin.tex.colour(plugin.tag + ChatColor.RED + "Usage: /cp <panel> [item] [player]"));
|
plugin.openVoids.openCommandPanel(sender, player, panel.copy(), PanelPosition.Top, true);
|
||||||
|
} else
|
||||||
|
plugin.openVoids.openCommandPanel(sender, plugin.getServer().getPlayer(args[1]), panel.copy(), PanelPosition.Top, true);
|
||||||
|
} else {
|
||||||
|
sender.sendMessage(plugin.tex.colour(plugin.tag + ChatColor.RED + "Usage: /cp <panel> [item] [player|all]"));
|
||||||
}
|
}
|
||||||
return true;
|
return true;
|
||||||
}else if(args.length == 3){
|
} else if (args.length == 3) {
|
||||||
if (args[1].equals("item")) {
|
if (args[1].equals("item")) {
|
||||||
plugin.openVoids.giveHotbarItem(sender,plugin.getServer().getPlayer(args[2]),panel.copy(),true);
|
if (args[2].equalsIgnoreCase("all")) {
|
||||||
}else{
|
// if the argument is all open the panel for all of the players
|
||||||
sender.sendMessage(plugin.tex.colour(plugin.tag + ChatColor.RED + "Usage: /cp <panel> item [player]"));
|
for (Player player : Bukkit.getOnlinePlayers())
|
||||||
|
plugin.openVoids.openCommandPanel(sender, player, panel.copy(), PanelPosition.Top, true);
|
||||||
|
} else
|
||||||
|
plugin.openVoids.giveHotbarItem(sender, plugin.getServer().getPlayer(args[2]), panel.copy(), true);
|
||||||
|
} else {
|
||||||
|
sender.sendMessage(plugin.tex.colour(plugin.tag + ChatColor.RED + "Usage: /cp <panel> item [player|all]"));
|
||||||
}
|
}
|
||||||
return true;
|
return true;
|
||||||
} else {
|
} else {
|
||||||
sender.sendMessage(plugin.tex.colour( plugin.tag + ChatColor.RED + "Please execute command directed to a Player!"));
|
sender.sendMessage(plugin.tex.colour(plugin.tag + ChatColor.RED + "Please execute command directed to a Player!"));
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
}else{
|
} else {
|
||||||
//get player
|
//get player
|
||||||
Player p = (Player) sender;
|
Player p = (Player) sender;
|
||||||
//do player command
|
//do player command
|
||||||
if (args.length == 1) {
|
if (args.length == 1) {
|
||||||
if(!disableCommand) {
|
if (!disableCommand) {
|
||||||
plugin.openVoids.openCommandPanel(sender, p, panel.copy(),PanelPosition.Top, false);
|
plugin.openVoids.openCommandPanel(sender, p, panel.copy(), PanelPosition.Top, false);
|
||||||
}
|
}
|
||||||
return true;
|
return true;
|
||||||
}else if(args.length == 2){
|
} else if (args.length == 2) {
|
||||||
if (args[1].equals("item")) {
|
if (args[1].equals("item")) {
|
||||||
|
|
||||||
plugin.openVoids.giveHotbarItem(sender, p, panel.copy(), false);
|
plugin.openVoids.giveHotbarItem(sender, p, panel.copy(), false);
|
||||||
}else{
|
} else {
|
||||||
if(!disableCommand) {
|
if (!disableCommand) {
|
||||||
plugin.openVoids.openCommandPanel(sender, plugin.getServer().getPlayer(args[1]), panel.copy(),PanelPosition.Top, true);
|
if (args[1].equalsIgnoreCase("all")) {
|
||||||
|
// if the argument is all open the panel for all of the players
|
||||||
|
for (Player player : Bukkit.getOnlinePlayers())
|
||||||
|
plugin.openVoids.openCommandPanel(sender, player, panel.copy(), PanelPosition.Top, true);
|
||||||
|
} else
|
||||||
|
plugin.openVoids.openCommandPanel(sender, plugin.getServer().getPlayer(args[1]), panel.copy(), PanelPosition.Top, true);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return true;
|
return true;
|
||||||
}else if(args.length == 3){
|
} else if (args.length == 3) {
|
||||||
plugin.openVoids.giveHotbarItem(sender, plugin.getServer().getPlayer(args[2]), panel.copy(),true);
|
if (args[2].equalsIgnoreCase("all")) {
|
||||||
|
// if the argument is all open the panel for all of the players
|
||||||
|
for (Player player : Bukkit.getOnlinePlayers())
|
||||||
|
plugin.openVoids.giveHotbarItem(sender, player, panel.copy(), true);
|
||||||
|
} else
|
||||||
|
plugin.openVoids.giveHotbarItem(sender, plugin.getServer().getPlayer(args[2]), panel.copy(), true);
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
sender.sendMessage(plugin.tex.colour(plugin.tag + ChatColor.RED + "Usage: /cp <panel> [player:item] [player]"));
|
sender.sendMessage(plugin.tex.colour(plugin.tag + ChatColor.RED + "Usage: /cp <panel> [player|all:item] [player|all]"));
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -1,84 +1,123 @@
|
|||||||
package me.rockyhawk.commandpanels.commands;
|
package me.rockyhawk.commandpanels.commands;
|
||||||
|
|
||||||
import me.rockyhawk.commandpanels.CommandPanels;
|
import me.rockyhawk.commandpanels.CommandPanels;
|
||||||
|
import org.bukkit.Bukkit;
|
||||||
import org.bukkit.ChatColor;
|
import org.bukkit.ChatColor;
|
||||||
|
import org.bukkit.OfflinePlayer;
|
||||||
import org.bukkit.command.Command;
|
import org.bukkit.command.Command;
|
||||||
import org.bukkit.command.CommandExecutor;
|
import org.bukkit.command.CommandExecutor;
|
||||||
import org.bukkit.command.CommandSender;
|
import org.bukkit.command.CommandSender;
|
||||||
import org.bukkit.event.EventHandler;
|
|
||||||
|
|
||||||
import java.util.Arrays;
|
import java.util.Arrays;
|
||||||
|
|
||||||
public class Commandpanelsdata implements CommandExecutor {
|
public class Commandpanelsdata implements CommandExecutor {
|
||||||
CommandPanels plugin;
|
CommandPanels plugin;
|
||||||
public Commandpanelsdata(CommandPanels pl) { this.plugin = pl; }
|
|
||||||
|
|
||||||
@EventHandler
|
public Commandpanelsdata(CommandPanels pl) {
|
||||||
|
this.plugin = pl;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
public boolean onCommand(CommandSender sender, Command cmd, String label, String[] args) {
|
public boolean onCommand(CommandSender sender, Command cmd, String label, String[] args) {
|
||||||
if (sender.hasPermission("commandpanel.data")) {
|
if (sender.hasPermission("commandpanel.data")) {
|
||||||
boolean sendPlayerMessage = true;
|
boolean sendPlayerMessage = true;
|
||||||
//if the first argument is -s it will not send a message to the sender
|
//if the first argument is -s it will not send a message to the sender
|
||||||
if(args[0].equalsIgnoreCase("-s")){
|
if (args[0].equalsIgnoreCase("-s")) {
|
||||||
args = Arrays.copyOfRange(args, 1, args.length);
|
args = Arrays.copyOfRange(args, 1, args.length);
|
||||||
sendPlayerMessage = false;
|
sendPlayerMessage = false;
|
||||||
}
|
}
|
||||||
if(args.length == 2){
|
int count = 0;
|
||||||
|
if (args.length == 2) {
|
||||||
//for the clear command
|
//for the clear command
|
||||||
if(args[0].equals("clear")){
|
if (args[0].equals("clear")) {
|
||||||
plugin.panelData.clearData(plugin.panelData.getOffline(args[1]));
|
if (args[1].equalsIgnoreCase("all") || args[1].equalsIgnoreCase("online")) {
|
||||||
if(sendPlayerMessage) {
|
for (OfflinePlayer player : Bukkit.getOfflinePlayers()) {
|
||||||
|
if (args[1].equalsIgnoreCase("online") && !player.isOnline()) continue;
|
||||||
|
plugin.panelData.clearData(plugin.panelData.getOffline(player.getName()));
|
||||||
|
count++;
|
||||||
|
}
|
||||||
|
} else
|
||||||
|
plugin.panelData.clearData(plugin.panelData.getOffline(args[1]));
|
||||||
|
if (sendPlayerMessage) {
|
||||||
sender.sendMessage(plugin.tex.colour(plugin.tag
|
sender.sendMessage(plugin.tex.colour(plugin.tag
|
||||||
+ ChatColor.GREEN + "Cleared all data for "
|
+ ChatColor.GREEN + "Cleared all data for "
|
||||||
+ ChatColor.WHITE + args[1]));
|
+ ChatColor.WHITE + (count == 0 ? args[1] : count + "" + ChatColor.GREEN + " players")));
|
||||||
}
|
}
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
}else if (args.length == 3){
|
} else if (args.length == 3) {
|
||||||
//for the remove command
|
//for the remove command
|
||||||
if(args[0].equals("remove")) {
|
if (args[0].equals("remove")) {
|
||||||
plugin.panelData.delUserData(plugin.panelData.getOffline(args[1]), args[2]);
|
if (args[1].equalsIgnoreCase("all") || args[1].equalsIgnoreCase("online")) {
|
||||||
if(sendPlayerMessage) {
|
for (OfflinePlayer player : Bukkit.getOfflinePlayers()) {
|
||||||
|
if (args[1].equalsIgnoreCase("online") && !player.isOnline()) continue;
|
||||||
|
plugin.panelData.delUserData(plugin.panelData.getOffline(player.getName()), args[2]);
|
||||||
|
count++;
|
||||||
|
}
|
||||||
|
} else
|
||||||
|
plugin.panelData.delUserData(plugin.panelData.getOffline(args[1]), args[2]);
|
||||||
|
if (sendPlayerMessage) {
|
||||||
sender.sendMessage(plugin.tex.colour(plugin.tag
|
sender.sendMessage(plugin.tex.colour(plugin.tag
|
||||||
+ ChatColor.GREEN + "Removed "
|
+ ChatColor.GREEN + "Removed "
|
||||||
+ ChatColor.WHITE + args[2]
|
+ ChatColor.WHITE + args[2]
|
||||||
+ ChatColor.GREEN + " from "
|
+ ChatColor.GREEN + " from "
|
||||||
+ ChatColor.WHITE + args[1]));
|
+ ChatColor.WHITE + (count == 0 ? args[1] : count + "" + ChatColor.GREEN + " players")));
|
||||||
}
|
}
|
||||||
return true;
|
return true;
|
||||||
}else if(args[0].equals("get")){
|
} else if (args[0].equals("get")) {
|
||||||
//for the get command
|
//for the get command
|
||||||
sender.sendMessage(plugin.tex.colour(plugin.tag
|
sender.sendMessage(plugin.tex.colour(plugin.tag
|
||||||
+ ChatColor.GREEN + "Value of data is "
|
+ ChatColor.GREEN + "Value of data is "
|
||||||
+ ChatColor.WHITE + plugin.panelData.getUserData(plugin.panelData.getOffline(args[1]), args[2])));
|
+ ChatColor.WHITE + plugin.panelData.getUserData(plugin.panelData.getOffline(args[1]), args[2])));
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
}else if (args.length == 4){
|
} else if (args.length == 4) {
|
||||||
if(args[0].equals("set")){
|
if (args[0].equals("set")) {
|
||||||
//for set command
|
//for set command
|
||||||
plugin.panelData.setUserData(plugin.panelData.getOffline(args[1]), args[2],args[3],true);
|
if (args[1].equalsIgnoreCase("all") || args[1].equalsIgnoreCase("online")) {
|
||||||
if(sendPlayerMessage) {
|
for (OfflinePlayer player : Bukkit.getOfflinePlayers()) {
|
||||||
|
if (args[1].equalsIgnoreCase("online") && !player.isOnline()) continue;
|
||||||
|
plugin.panelData.setUserData(plugin.panelData.getOffline(player.getName()), args[2], args[3], true);
|
||||||
|
count++;
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
plugin.panelData.setUserData(plugin.panelData.getOffline(args[1]), args[2], args[3], true);
|
||||||
|
}
|
||||||
|
if (sendPlayerMessage) {
|
||||||
sender.sendMessage(plugin.tex.colour(plugin.tag
|
sender.sendMessage(plugin.tex.colour(plugin.tag
|
||||||
+ ChatColor.GREEN + "Set "
|
+ ChatColor.GREEN + "Set "
|
||||||
+ ChatColor.WHITE + args[2]
|
+ ChatColor.WHITE + args[2]
|
||||||
+ ChatColor.GREEN + " to "
|
+ ChatColor.GREEN + " to "
|
||||||
+ ChatColor.WHITE + args[3]));
|
+ ChatColor.WHITE + args[3]
|
||||||
|
+ ChatColor.GREEN + " for "
|
||||||
|
+ ChatColor.WHITE + (count == 0 ? args[1] : count + "" + ChatColor.GREEN + " players")));
|
||||||
}
|
}
|
||||||
}else{
|
} else {
|
||||||
//for add command
|
//for add command
|
||||||
plugin.panelData.setUserData(plugin.panelData.getOffline(args[1]), args[2],args[3],false);
|
if (args[1].equalsIgnoreCase("all") || args[1].equalsIgnoreCase("online")) {
|
||||||
if(sendPlayerMessage) {
|
|
||||||
|
for (OfflinePlayer player : Bukkit.getOfflinePlayers()) {
|
||||||
|
if (args[1].equalsIgnoreCase("online") && !player.isOnline()) continue;
|
||||||
|
plugin.panelData.setUserData(plugin.panelData.getOffline(player.getName()), args[2], args[3], false);
|
||||||
|
count++;
|
||||||
|
}
|
||||||
|
} else
|
||||||
|
plugin.panelData.setUserData(plugin.panelData.getOffline(args[1]), args[2], args[3], false);
|
||||||
|
if (sendPlayerMessage) {
|
||||||
sender.sendMessage(plugin.tex.colour(plugin.tag
|
sender.sendMessage(plugin.tex.colour(plugin.tag
|
||||||
+ ChatColor.GREEN + "Set "
|
+ ChatColor.GREEN + "Set "
|
||||||
+ ChatColor.WHITE + args[2]
|
+ ChatColor.WHITE + args[2]
|
||||||
+ ChatColor.GREEN + " to "
|
+ ChatColor.GREEN + " to "
|
||||||
+ ChatColor.WHITE + args[3])
|
+ ChatColor.WHITE + args[3])
|
||||||
+ ChatColor.GREEN + " if it did not exist already");
|
+ ChatColor.GREEN + " for "
|
||||||
|
+ ChatColor.WHITE + (count == 0 ? args[1] : count + "" + ChatColor.GREEN + " players")
|
||||||
|
+ " if it did not exist already");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
sender.sendMessage(plugin.tex.colour(plugin.tag + ChatColor.RED + "Usage: /cpdata <set:add:get:remove:clear> <player> <data> [value]"));
|
sender.sendMessage(plugin.tex.colour(plugin.tag + ChatColor.RED + "Usage: /cpdata <set:add:get:remove:clear> <player|all|online> <data> [value]"));
|
||||||
}else{
|
} else {
|
||||||
sender.sendMessage(plugin.tex.colour(plugin.tag + plugin.config.getString("config.format.perms")));
|
sender.sendMessage(plugin.tex.colour(plugin.tag + plugin.config.getString("config.format.perms")));
|
||||||
}
|
}
|
||||||
return true;
|
return true;
|
||||||
|
@ -6,13 +6,12 @@ import org.bukkit.command.Command;
|
|||||||
import org.bukkit.command.CommandExecutor;
|
import org.bukkit.command.CommandExecutor;
|
||||||
import org.bukkit.command.CommandSender;
|
import org.bukkit.command.CommandSender;
|
||||||
import org.bukkit.entity.Player;
|
import org.bukkit.entity.Player;
|
||||||
import org.bukkit.event.EventHandler;
|
|
||||||
|
|
||||||
public class Commandpanelsdebug implements CommandExecutor {
|
public class Commandpanelsdebug implements CommandExecutor {
|
||||||
CommandPanels plugin;
|
CommandPanels plugin;
|
||||||
public Commandpanelsdebug(CommandPanels pl) { this.plugin = pl; }
|
public Commandpanelsdebug(CommandPanels pl) { this.plugin = pl; }
|
||||||
|
|
||||||
@EventHandler
|
@Override
|
||||||
public boolean onCommand(CommandSender sender, Command cmd, String label, String[] args) {
|
public boolean onCommand(CommandSender sender, Command cmd, String label, String[] args) {
|
||||||
if (sender.hasPermission("commandpanel.debug")) {
|
if (sender.hasPermission("commandpanel.debug")) {
|
||||||
if (args.length == 0) {
|
if (args.length == 0) {
|
||||||
|
@ -11,7 +11,7 @@ public class Commandpanelversion implements CommandExecutor {
|
|||||||
CommandPanels plugin;
|
CommandPanels plugin;
|
||||||
public Commandpanelversion(CommandPanels pl) { this.plugin = pl; }
|
public Commandpanelversion(CommandPanels pl) { this.plugin = pl; }
|
||||||
|
|
||||||
@EventHandler
|
@Override
|
||||||
public boolean onCommand(CommandSender sender, Command cmd, String label, String[] args) {
|
public boolean onCommand(CommandSender sender, Command cmd, String label, String[] args) {
|
||||||
|
|
||||||
if (label.equalsIgnoreCase("cpv") || label.equalsIgnoreCase("commandpanelversion") || label.equalsIgnoreCase("cpanelv")) {
|
if (label.equalsIgnoreCase("cpv") || label.equalsIgnoreCase("commandpanelversion") || label.equalsIgnoreCase("cpanelv")) {
|
||||||
|
@ -41,7 +41,7 @@ public class CommandTags {
|
|||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
|
||||||
PaywallOutput val = plugin.commandTags.commandPayWall(panel, p, command);
|
PaywallOutput val = plugin.commandTags.commandPayWall(panel, p, command, true);
|
||||||
if (val == PaywallOutput.Blocked) {
|
if (val == PaywallOutput.Blocked) {
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
@ -53,7 +53,7 @@ public class CommandTags {
|
|||||||
|
|
||||||
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, true);
|
||||||
if (val == PaywallOutput.Blocked) {
|
if (val == PaywallOutput.Blocked) {
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
@ -63,6 +63,23 @@ public class CommandTags {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public void runMultiPaywall(Panel panel, PanelPosition position, Player p, List<String> paywalls, List<String> commands, ClickType click) {
|
||||||
|
List<String> cmds = new ArrayList<String>();
|
||||||
|
for (String command : paywalls) {
|
||||||
|
PaywallOutput val = plugin.commandTags.commandPayWall(panel, p, command, false);
|
||||||
|
// Stop the for loop if 1 of the outputs is blocked
|
||||||
|
if (val == PaywallOutput.Blocked) {
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
// add the paywall so it will be executed in runCommands
|
||||||
|
cmds.add(command);
|
||||||
|
}
|
||||||
|
// Add the commands last so paywalls run first
|
||||||
|
cmds.addAll(commands);
|
||||||
|
plugin.commandTags.runCommands(panel, position, p, cmds, click);
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
public void runCommand(Panel panel, PanelPosition position, Player p, String commandRAW) {
|
public void runCommand(Panel panel, PanelPosition position, Player p, String commandRAW) {
|
||||||
CommandTagEvent tags = new CommandTagEvent(plugin, panel, position, p, commandRAW);
|
CommandTagEvent tags = new CommandTagEvent(plugin, panel, position, p, commandRAW);
|
||||||
Bukkit.getPluginManager().callEvent(tags);
|
Bukkit.getPluginManager().callEvent(tags);
|
||||||
@ -137,7 +154,7 @@ public class CommandTags {
|
|||||||
}
|
}
|
||||||
|
|
||||||
@SuppressWarnings("deprecation")
|
@SuppressWarnings("deprecation")
|
||||||
public PaywallOutput commandPayWall(Panel panel, Player p, String rawCommand) { //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 rawCommand, boolean removal) { //return 0 means no funds, 1 is they passed and 2 means paywall is not this command
|
||||||
|
|
||||||
//create new instance of command but with placeholders parsed
|
//create new instance of command but with placeholders parsed
|
||||||
String command = plugin.tex.placeholders(panel, PanelPosition.Top, p, rawCommand);
|
String command = plugin.tex.placeholders(panel, PanelPosition.Top, p, rawCommand);
|
||||||
@ -147,8 +164,8 @@ public class CommandTags {
|
|||||||
try {
|
try {
|
||||||
if (plugin.econ != null) {
|
if (plugin.econ != null) {
|
||||||
if (plugin.econ.getBalance(p) >= Double.parseDouble(command.split("\\s")[1])) {
|
if (plugin.econ.getBalance(p) >= Double.parseDouble(command.split("\\s")[1])) {
|
||||||
plugin.econ.withdrawPlayer(p, Double.parseDouble(command.split("\\s")[1]));
|
if (removal) plugin.econ.withdrawPlayer(p, Double.parseDouble(command.split("\\s")[1]));
|
||||||
if (plugin.config.getBoolean("purchase.currency.enable")) {
|
if (plugin.config.getBoolean("purchase.currency.enable") && removal) {
|
||||||
plugin.tex.sendString(panel, PanelPosition.Top, p, Objects.requireNonNull(plugin.config.getString("purchase.currency.success")).replaceAll("%cp-args%", command.split("\\s")[1]));
|
plugin.tex.sendString(panel, PanelPosition.Top, p, Objects.requireNonNull(plugin.config.getString("purchase.currency.success")).replaceAll("%cp-args%", command.split("\\s")[1]));
|
||||||
}
|
}
|
||||||
return PaywallOutput.Passed;
|
return PaywallOutput.Passed;
|
||||||
@ -167,6 +184,22 @@ public class CommandTags {
|
|||||||
plugin.tex.sendString(p, plugin.tag + plugin.config.getString("config.format.error") + " " + "commands: " + command);
|
plugin.tex.sendString(p, plugin.tag + plugin.config.getString("config.format.error") + " " + "commands: " + command);
|
||||||
return PaywallOutput.Blocked;
|
return PaywallOutput.Blocked;
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
case "hasperm=": {
|
||||||
|
//if player uses hasperm= [perm]
|
||||||
|
if (p.hasPermission(String.valueOf(command.split("\\s")[1]))) {
|
||||||
|
if (plugin.config.getBoolean("purchase.permission.enable") && removal) {
|
||||||
|
plugin.tex.sendString(panel, PanelPosition.Top, p, Objects.requireNonNull(plugin.config.getString("purchase.permission.success")).replaceAll("%cp-args%", command.split("\\s")[1]));
|
||||||
|
}
|
||||||
|
return PaywallOutput.Passed;
|
||||||
|
} else {
|
||||||
|
if (plugin.config.getBoolean("purchase.currency.enable")) {
|
||||||
|
plugin.tex.sendString(panel, PanelPosition.Top, p, Objects.requireNonNull(plugin.config.getString("purchase.permission.failure")));
|
||||||
|
}
|
||||||
|
return PaywallOutput.Blocked;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
case "tokenpaywall=": {
|
case "tokenpaywall=": {
|
||||||
//if player uses tokenpaywall= [price]
|
//if player uses tokenpaywall= [price]
|
||||||
@ -176,9 +209,9 @@ public class CommandTags {
|
|||||||
assert api != null;
|
assert api != null;
|
||||||
int balance = Integer.parseInt(Long.toString(api.getTokens(p).orElse(0)));
|
int balance = Integer.parseInt(Long.toString(api.getTokens(p).orElse(0)));
|
||||||
if (balance >= Double.parseDouble(command.split("\\s")[1])) {
|
if (balance >= Double.parseDouble(command.split("\\s")[1])) {
|
||||||
api.removeTokens(p, Long.parseLong(command.split("\\s")[1]));
|
if (removal) api.removeTokens(p, Long.parseLong(command.split("\\s")[1]));
|
||||||
//if the message is empty don't send
|
//if the message is empty don't send
|
||||||
if (plugin.config.getBoolean("purchase.tokens.enable")) {
|
if (plugin.config.getBoolean("purchase.tokens.enable") && removal) {
|
||||||
plugin.tex.sendString(panel, PanelPosition.Top, p, Objects.requireNonNull(plugin.config.getString("purchase.tokens.success")).replaceAll("%cp-args%", command.split("\\s")[1]));
|
plugin.tex.sendString(panel, PanelPosition.Top, p, Objects.requireNonNull(plugin.config.getString("purchase.tokens.success")).replaceAll("%cp-args%", command.split("\\s")[1]));
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -209,15 +242,15 @@ public class CommandTags {
|
|||||||
byte id = -1;
|
byte id = -1;
|
||||||
int customData = 0;
|
int customData = 0;
|
||||||
boolean noCustom = false;
|
boolean noCustom = false;
|
||||||
for(String val : args) {
|
for (String val : args) {
|
||||||
if(val.startsWith("id:")) {
|
if (val.startsWith("id:")) {
|
||||||
id = Byte.parseByte(val.substring(3));
|
id = Byte.parseByte(val.substring(3));
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
if(val.startsWith("custom-data:")) {
|
if (val.startsWith("custom-data:")) {
|
||||||
customData = Integer.parseInt(val.substring(12));
|
customData = Integer.parseInt(val.substring(12));
|
||||||
}
|
}
|
||||||
if(val.contains("NOCUSTOMDATA")) {
|
if (val.contains("NOCUSTOMDATA")) {
|
||||||
noCustom = true;
|
noCustom = true;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -249,7 +282,7 @@ public class CommandTags {
|
|||||||
if (plugin.itemCreate.isIdentical(sellItem, itm)) {
|
if (plugin.itemCreate.isIdentical(sellItem, itm)) {
|
||||||
ItemStack add = new ItemStack(p.getInventory().getItem(f).getType(), p.getInventory().getItem(f).getAmount(), (short) f);
|
ItemStack add = new ItemStack(p.getInventory().getItem(f).getType(), p.getInventory().getItem(f).getAmount(), (short) f);
|
||||||
remainingAmount -= add.getAmount();
|
remainingAmount -= add.getAmount();
|
||||||
remCont.add(add);
|
if (removal) remCont.add(add);
|
||||||
if (remainingAmount <= 0) {
|
if (remainingAmount <= 0) {
|
||||||
removedItem = PaywallOutput.Passed;
|
removedItem = PaywallOutput.Passed;
|
||||||
break;
|
break;
|
||||||
@ -265,10 +298,11 @@ public class CommandTags {
|
|||||||
|
|
||||||
if (plugin.isMMOItem(itm, mmoType, mmoID) && sellItem.getAmount() <= itm.getAmount()) {
|
if (plugin.isMMOItem(itm, mmoType, mmoID) && sellItem.getAmount() <= itm.getAmount()) {
|
||||||
if (plugin.inventorySaver.hasNormalInventory(p)) {
|
if (plugin.inventorySaver.hasNormalInventory(p)) {
|
||||||
p.getInventory().getItem(f).setAmount(itm.getAmount() - sellItem.getAmount());
|
if (removal)
|
||||||
|
p.getInventory().getItem(f).setAmount(itm.getAmount() - sellItem.getAmount());
|
||||||
p.updateInventory();
|
p.updateInventory();
|
||||||
} else {
|
} else {
|
||||||
itm.setAmount(itm.getAmount() - sellItem.getAmount());
|
if (removal) itm.setAmount(itm.getAmount() - sellItem.getAmount());
|
||||||
plugin.inventorySaver.inventoryConfig.set(p.getUniqueId().toString(), plugin.itemSerializer.itemStackArrayToBase64(cont.toArray(new ItemStack[0])));
|
plugin.inventorySaver.inventoryConfig.set(p.getUniqueId().toString(), plugin.itemSerializer.itemStackArrayToBase64(cont.toArray(new ItemStack[0])));
|
||||||
}
|
}
|
||||||
removedItem = PaywallOutput.Passed;
|
removedItem = PaywallOutput.Passed;
|
||||||
@ -277,7 +311,7 @@ public class CommandTags {
|
|||||||
if (plugin.isMMOItem(itm, mmoType, mmoID)) {
|
if (plugin.isMMOItem(itm, mmoType, mmoID)) {
|
||||||
ItemStack add = new ItemStack(p.getInventory().getItem(f).getType(), p.getInventory().getItem(f).getAmount(), (short) f);
|
ItemStack add = new ItemStack(p.getInventory().getItem(f).getType(), p.getInventory().getItem(f).getAmount(), (short) f);
|
||||||
remainingAmount -= add.getAmount();
|
remainingAmount -= add.getAmount();
|
||||||
remCont.add(add);
|
if (removal) remCont.add(add);
|
||||||
if (remainingAmount <= 0) {
|
if (remainingAmount <= 0) {
|
||||||
removedItem = PaywallOutput.Passed;
|
removedItem = PaywallOutput.Passed;
|
||||||
break;
|
break;
|
||||||
@ -292,23 +326,23 @@ public class CommandTags {
|
|||||||
//if the item is a standard material
|
//if the item is a standard material
|
||||||
if (itm.getType() == sellItem.getType()) {
|
if (itm.getType() == sellItem.getType()) {
|
||||||
//Checking for custom model data. If it does not have or not the correct number go to next in loop.
|
//Checking for custom model data. If it does not have or not the correct number go to next in loop.
|
||||||
if(customData != 0){
|
if (customData != 0) {
|
||||||
if(!itm.hasItemMeta()){
|
if (!itm.hasItemMeta()) {
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
if(Objects.requireNonNull(itm.getItemMeta()).getCustomModelData() != customData){
|
if (Objects.requireNonNull(itm.getItemMeta()).getCustomModelData() != customData) {
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
//Check if the item matches the id set. If not continue to next in loop.
|
//Check if the item matches the id set. If not continue to next in loop.
|
||||||
if(id != -1 && itm.getDurability() != id){
|
if (id != -1 && itm.getDurability() != id) {
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
|
||||||
//Check if noCustom is set and if the item has custom data. If so continue to next in loop.
|
//Check if noCustom is set and if the item has custom data. If so continue to next in loop.
|
||||||
if(noCustom && itm.hasItemMeta()){
|
if (noCustom && itm.hasItemMeta()) {
|
||||||
if(Objects.requireNonNull(itm.getItemMeta()).hasCustomModelData()){
|
if (Objects.requireNonNull(itm.getItemMeta()).hasCustomModelData()) {
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -316,7 +350,7 @@ public class CommandTags {
|
|||||||
//Adding item to the remove list then checking if we have reached the required amount.
|
//Adding item to the remove list then checking if we have reached the required amount.
|
||||||
ItemStack add = new ItemStack(itm.getType(), itm.getAmount(), (short) f);
|
ItemStack add = new ItemStack(itm.getType(), itm.getAmount(), (short) f);
|
||||||
remainingAmount -= add.getAmount();
|
remainingAmount -= add.getAmount();
|
||||||
remCont.add(add);
|
if (removal) remCont.add(add);
|
||||||
if (remainingAmount <= 0) {
|
if (remainingAmount <= 0) {
|
||||||
removedItem = PaywallOutput.Passed;
|
removedItem = PaywallOutput.Passed;
|
||||||
break;
|
break;
|
||||||
@ -330,25 +364,27 @@ public class CommandTags {
|
|||||||
ItemStack remItem = remCont.get(f);
|
ItemStack remItem = remCont.get(f);
|
||||||
|
|
||||||
//Check if its the last item in the loop and only subtract the remaining amount.
|
//Check if its the last item in the loop and only subtract the remaining amount.
|
||||||
if(f == remCont.size() - 1){
|
if (f == remCont.size() - 1) {
|
||||||
if (plugin.inventorySaver.hasNormalInventory(p)) {
|
if (plugin.inventorySaver.hasNormalInventory(p)) {
|
||||||
p.getInventory().getItem((int)remItem.getDurability()).setAmount(remItem.getAmount() - sellItem.getAmount());
|
if (removal)
|
||||||
|
p.getInventory().getItem((int) remItem.getDurability()).setAmount(remItem.getAmount() - sellItem.getAmount());
|
||||||
p.updateInventory();
|
p.updateInventory();
|
||||||
} else {
|
} else {
|
||||||
cont.get((int)remItem.getDurability()).setAmount(remItem.getAmount() - sellItem.getAmount());
|
if (removal)
|
||||||
|
cont.get((int) remItem.getDurability()).setAmount(remItem.getAmount() - sellItem.getAmount());
|
||||||
plugin.inventorySaver.inventoryConfig.set(p.getUniqueId().toString(), plugin.itemSerializer.itemStackArrayToBase64(cont.toArray(new ItemStack[0])));
|
plugin.inventorySaver.inventoryConfig.set(p.getUniqueId().toString(), plugin.itemSerializer.itemStackArrayToBase64(cont.toArray(new ItemStack[0])));
|
||||||
}
|
}
|
||||||
} else { //If its anywhere but the last in loop just get rid of the items.
|
} else { //If its anywhere but the last in loop just get rid of the items.
|
||||||
if (plugin.inventorySaver.hasNormalInventory(p)) {
|
if (plugin.inventorySaver.hasNormalInventory(p)) {
|
||||||
p.getInventory().getItem(remItem.getDurability()).setAmount(0);
|
if (removal) p.getInventory().getItem(remItem.getDurability()).setAmount(0);
|
||||||
p.updateInventory();
|
p.updateInventory();
|
||||||
} else {
|
} else {
|
||||||
cont.get((int)remItem.getDurability()).setAmount(0);
|
if (removal) cont.get((int) remItem.getDurability()).setAmount(0);
|
||||||
plugin.inventorySaver.inventoryConfig.set(p.getUniqueId().toString(), plugin.itemSerializer.itemStackArrayToBase64(cont.toArray(new ItemStack[0])));
|
plugin.inventorySaver.inventoryConfig.set(p.getUniqueId().toString(), plugin.itemSerializer.itemStackArrayToBase64(cont.toArray(new ItemStack[0])));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
sellItem.setAmount(sellItem.getAmount() - remItem.getAmount());
|
if (removal) sellItem.setAmount(sellItem.getAmount() - remItem.getAmount());
|
||||||
}
|
}
|
||||||
|
|
||||||
removedItem = PaywallOutput.Passed;
|
removedItem = PaywallOutput.Passed;
|
||||||
@ -361,7 +397,7 @@ public class CommandTags {
|
|||||||
plugin.tex.sendString(panel, PanelPosition.Top, p, Objects.requireNonNull(plugin.config.getString("purchase.item.failure")));
|
plugin.tex.sendString(panel, PanelPosition.Top, p, Objects.requireNonNull(plugin.config.getString("purchase.item.failure")));
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
if (plugin.config.getBoolean("purchase.item.enable")) {
|
if (plugin.config.getBoolean("purchase.item.enable") && removal) {
|
||||||
//item was removed
|
//item was removed
|
||||||
plugin.tex.sendString(panel, PanelPosition.Top, p, Objects.requireNonNull(plugin.config.getString("purchase.item.success")).replaceAll("%cp-args%", command.split("\\s")[1]));
|
plugin.tex.sendString(panel, PanelPosition.Top, p, Objects.requireNonNull(plugin.config.getString("purchase.item.success")).replaceAll("%cp-args%", command.split("\\s")[1]));
|
||||||
}
|
}
|
||||||
@ -384,12 +420,12 @@ public class CommandTags {
|
|||||||
}
|
}
|
||||||
if (balance >= Integer.parseInt(command.split("\\s")[1])) {
|
if (balance >= Integer.parseInt(command.split("\\s")[1])) {
|
||||||
if (command.split("\\s")[2].startsWith("level")) {
|
if (command.split("\\s")[2].startsWith("level")) {
|
||||||
p.setLevel(p.getLevel() - Integer.parseInt(command.split("\\s")[1]));
|
if (removal) p.setLevel(p.getLevel() - Integer.parseInt(command.split("\\s")[1]));
|
||||||
} else {
|
} else {
|
||||||
removePlayerExp(p, Integer.parseInt(command.split("\\s")[1]));
|
if (removal) removePlayerExp(p, Integer.parseInt(command.split("\\s")[1]));
|
||||||
}
|
}
|
||||||
//if the message is empty don't send
|
//if the message is empty don't send
|
||||||
if (plugin.config.getBoolean("purchase.xp.enable")) {
|
if (plugin.config.getBoolean("purchase.xp.enable") && removal) {
|
||||||
plugin.tex.sendString(panel, PanelPosition.Top, p, Objects.requireNonNull(plugin.config.getString("purchase.xp.success")).replaceAll("%cp-args%", command.split("\\s")[1]));
|
plugin.tex.sendString(panel, PanelPosition.Top, p, Objects.requireNonNull(plugin.config.getString("purchase.xp.success")).replaceAll("%cp-args%", command.split("\\s")[1]));
|
||||||
}
|
}
|
||||||
return PaywallOutput.Passed;
|
return PaywallOutput.Passed;
|
||||||
@ -409,7 +445,8 @@ public class CommandTags {
|
|||||||
//if player uses data-paywall= <data> <amount>
|
//if player uses data-paywall= <data> <amount>
|
||||||
try {
|
try {
|
||||||
if (Double.parseDouble(plugin.panelData.getUserData(p.getUniqueId(), command.split("\\s")[1])) >= Double.parseDouble(command.split("\\s")[2])) {
|
if (Double.parseDouble(plugin.panelData.getUserData(p.getUniqueId(), command.split("\\s")[1])) >= Double.parseDouble(command.split("\\s")[2])) {
|
||||||
plugin.panelData.doDataMath(p.getUniqueId(), command.split("\\s")[1], "-" + plugin.tex.placeholdersNoColour(panel, PanelPosition.Top, p, command.split("\\s")[2]));
|
if (removal)
|
||||||
|
plugin.panelData.doDataMath(p.getUniqueId(), command.split("\\s")[1], "-" + plugin.tex.placeholdersNoColour(panel, PanelPosition.Top, p, command.split("\\s")[2]));
|
||||||
//if the message is empty don't send
|
//if the message is empty don't send
|
||||||
if (plugin.config.getBoolean("purchase.data.enable")) {
|
if (plugin.config.getBoolean("purchase.data.enable")) {
|
||||||
plugin.tex.sendString(panel, PanelPosition.Top, p, Objects.requireNonNull(plugin.config.getString("purchase.data.success")).replaceAll("%cp-args%", command.split("\\s")[1]));
|
plugin.tex.sendString(panel, PanelPosition.Top, p, Objects.requireNonNull(plugin.config.getString("purchase.data.success")).replaceAll("%cp-args%", command.split("\\s")[1]));
|
||||||
|
@ -2,6 +2,7 @@ package me.rockyhawk.commandpanels.completetabs;
|
|||||||
|
|
||||||
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.command.Command;
|
import org.bukkit.command.Command;
|
||||||
import org.bukkit.command.CommandSender;
|
import org.bukkit.command.CommandSender;
|
||||||
import org.bukkit.command.TabCompleter;
|
import org.bukkit.command.TabCompleter;
|
||||||
@ -13,37 +14,63 @@ import java.util.List;
|
|||||||
|
|
||||||
public class CpTabComplete implements TabCompleter {
|
public class CpTabComplete implements TabCompleter {
|
||||||
CommandPanels plugin;
|
CommandPanels plugin;
|
||||||
public CpTabComplete(CommandPanels pl) { this.plugin = pl; }
|
|
||||||
|
public CpTabComplete(CommandPanels pl) {
|
||||||
|
this.plugin = pl;
|
||||||
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public List<String> onTabComplete(CommandSender sender, Command cmd, String label, String[] args) {
|
public List<String> onTabComplete(CommandSender sender, Command cmd, String label, String[] args) {
|
||||||
if(sender instanceof Player && args.length == 1){
|
if (sender instanceof Player && args.length >= 1)
|
||||||
Player p = ((Player) sender).getPlayer();
|
if (label.equalsIgnoreCase("cp") || label.equalsIgnoreCase("cpanel") || label.equalsIgnoreCase("commandpanel")) {
|
||||||
if(label.equalsIgnoreCase("cp") || label.equalsIgnoreCase("cpanel") || label.equalsIgnoreCase("commandpanel")){
|
Player p = ((Player) sender).getPlayer();
|
||||||
ArrayList<String> apanels = new ArrayList<String>(); //all panels
|
if (args.length == 1) {
|
||||||
for(Panel panel : plugin.panelList) { //will loop through all the files in folder
|
ArrayList<String> apanels = new ArrayList<String>(); //all panels
|
||||||
try {
|
for (Panel panel : plugin.panelList) { //will loop through all the files in folder
|
||||||
if (!panel.getName().startsWith(args[0])) {
|
try {
|
||||||
//this will narrow down the panels to what the user types
|
if (!panel.getName().startsWith(args[0])) {
|
||||||
continue;
|
//this will narrow down the panels to what the user types
|
||||||
}
|
continue;
|
||||||
if (sender.hasPermission("commandpanel.panel." + panel.getConfig().getString("perm"))) {
|
}
|
||||||
if(panel.getConfig().contains("panelType")) {
|
if (sender.hasPermission("commandpanel.panel." + panel.getConfig().getString("perm"))) {
|
||||||
if (panel.getConfig().getStringList("panelType").contains("nocommand")) {
|
if (panel.getConfig().contains("panelType")) {
|
||||||
//do not allow command with nocommand
|
if (panel.getConfig().getStringList("panelType").contains("nocommand")) {
|
||||||
continue;
|
//do not allow command with nocommand
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if (plugin.panelPerms.isPanelWorldEnabled(p, panel.getConfig())) {
|
||||||
|
apanels.add(panel.getName());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if(plugin.panelPerms.isPanelWorldEnabled(p,panel.getConfig())){
|
} catch (Exception skip) {
|
||||||
apanels.add(panel.getName());
|
//ignore panel
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}catch(Exception skip){
|
|
||||||
//ignore panel
|
|
||||||
}
|
}
|
||||||
|
return apanels;
|
||||||
}
|
}
|
||||||
return apanels;
|
|
||||||
|
if (args.length == 2 || args.length == 3) {
|
||||||
|
|
||||||
|
List<String> aplayers = new ArrayList<>();
|
||||||
|
|
||||||
|
if ("all".startsWith(args[(args.length == 2 ? 1 : 2)].toLowerCase())) aplayers.add("all");
|
||||||
|
|
||||||
|
if (args.length == 2 && "item".startsWith(args[1].toLowerCase())) aplayers.add("item");
|
||||||
|
for (Player player : Bukkit.getOnlinePlayers()) {
|
||||||
|
String name = player.getName();
|
||||||
|
if (name.toLowerCase().startsWith(args[(args.length == 2 ? 1 : 2)])) {
|
||||||
|
//this will narrow down the panels to what the user types
|
||||||
|
aplayers.add(name);
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
return aplayers;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
}
|
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
}
|
}
|
@ -2,13 +2,13 @@ package me.rockyhawk.commandpanels.completetabs;
|
|||||||
|
|
||||||
import me.rockyhawk.commandpanels.CommandPanels;
|
import me.rockyhawk.commandpanels.CommandPanels;
|
||||||
import org.bukkit.Bukkit;
|
import org.bukkit.Bukkit;
|
||||||
|
import org.bukkit.OfflinePlayer;
|
||||||
import org.bukkit.command.Command;
|
import org.bukkit.command.Command;
|
||||||
import org.bukkit.command.CommandSender;
|
import org.bukkit.command.CommandSender;
|
||||||
import org.bukkit.command.TabCompleter;
|
import org.bukkit.command.TabCompleter;
|
||||||
import org.bukkit.entity.Player;
|
import org.bukkit.entity.Player;
|
||||||
|
|
||||||
import java.util.ArrayList;
|
import java.util.*;
|
||||||
import java.util.List;
|
|
||||||
|
|
||||||
|
|
||||||
public class DataTabComplete implements TabCompleter {
|
public class DataTabComplete implements TabCompleter {
|
||||||
@ -18,25 +18,50 @@ public class DataTabComplete implements TabCompleter {
|
|||||||
public List<String> onTabComplete(CommandSender sender, Command cmd, String label, String[] args) {
|
public List<String> onTabComplete(CommandSender sender, Command cmd, String label, String[] args) {
|
||||||
if(sender.hasPermission("commandpanel.data")) {
|
if(sender.hasPermission("commandpanel.data")) {
|
||||||
ArrayList<String> output = new ArrayList<>();
|
ArrayList<String> output = new ArrayList<>();
|
||||||
|
if (args.length>=1 && args[0].equalsIgnoreCase("-s")) {
|
||||||
|
|
||||||
|
args = Arrays.copyOfRange(args, 1, args.length);
|
||||||
|
}
|
||||||
if(args.length == 1){
|
if(args.length == 1){
|
||||||
output.add("set");
|
String arg1 = args[0].toLowerCase();
|
||||||
output.add("add");
|
if ("set".startsWith(arg1))output.add("set");
|
||||||
output.add("get");
|
if ("add".startsWith(arg1))output.add("add");
|
||||||
output.add("remove");
|
if ("get".startsWith(arg1))output.add("get");
|
||||||
output.add("clear");
|
if ("remove".startsWith(arg1))output.add("remove");
|
||||||
|
if ("clear".startsWith(arg1))output.add("clear");
|
||||||
}else if(args.length == 2){
|
}else if(args.length == 2){
|
||||||
for (Player p : Bukkit.getOnlinePlayers()) {
|
if ("all".startsWith(args[1].toLowerCase()) && !args[0].equalsIgnoreCase("get")) output.add("all");
|
||||||
if (!p.getName().startsWith(args[1])) {
|
if ("online".startsWith(args[1].toLowerCase()) && !args[0].equalsIgnoreCase("get")) output.add("online");
|
||||||
continue;
|
for (OfflinePlayer player : Bukkit.getOfflinePlayers()) {
|
||||||
|
String name = player.getName();
|
||||||
|
// don't worry about it saying it may throw a NPE
|
||||||
|
if (name.toLowerCase().startsWith(args[1].toLowerCase())) {
|
||||||
|
//this will narrow down the panels to what the user types
|
||||||
|
output.add(name);
|
||||||
}
|
}
|
||||||
output.add(p.getName());
|
|
||||||
}
|
}
|
||||||
}else if(args.length == 3){
|
}else if(args.length == 3){
|
||||||
|
if (!args[0].equalsIgnoreCase("remove")) return new ArrayList<>();
|
||||||
//the clear function is here as it is the only subcommand with 3 args
|
//the clear function is here as it is the only subcommand with 3 args
|
||||||
try {
|
try {
|
||||||
return new ArrayList<>(plugin.panelData.dataConfig.getConfigurationSection("playerData." + plugin.panelData.getOffline(args[1])).getKeys(false));
|
|
||||||
|
if (!args[1].equalsIgnoreCase("all") && !args[1].equalsIgnoreCase("online"))
|
||||||
|
return new ArrayList<>(plugin.panelData.dataConfig.getConfigurationSection("playerData." + plugin.panelData.getOffline(args[1])).getKeys(false));
|
||||||
|
|
||||||
|
else {
|
||||||
|
Set<String> set = new HashSet<>();
|
||||||
|
for (OfflinePlayer player : Bukkit.getOfflinePlayers()) {
|
||||||
|
if (!player.isOnline()&&args[1].equalsIgnoreCase("online")) continue;
|
||||||
|
set.addAll(plugin.panelData.dataConfig.getConfigurationSection("playerData." + plugin.panelData.getOffline(player.getName())).getKeys(false));
|
||||||
|
|
||||||
|
}
|
||||||
|
String[] finalArgs = args;
|
||||||
|
set.removeIf(s -> !s.toLowerCase().startsWith(finalArgs[2]));
|
||||||
|
return new ArrayList<>(set);
|
||||||
|
}
|
||||||
} catch (Exception ex) {
|
} catch (Exception ex) {
|
||||||
return null;
|
return new ArrayList<>();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return output;
|
return output;
|
||||||
|
@ -24,7 +24,7 @@ public class CommandPanelsEditor implements CommandExecutor {
|
|||||||
this.plugin = pl;
|
this.plugin = pl;
|
||||||
}
|
}
|
||||||
|
|
||||||
@EventHandler
|
@Override
|
||||||
public boolean onCommand(CommandSender sender, Command cmd, String label, String[] args) {
|
public boolean onCommand(CommandSender sender, Command cmd, String label, String[] args) {
|
||||||
if (sender.hasPermission("commandpanel.edit")) {
|
if (sender.hasPermission("commandpanel.edit")) {
|
||||||
if (!(sender instanceof Player)) {
|
if (!(sender instanceof Player)) {
|
||||||
|
@ -1,8 +1,13 @@
|
|||||||
package me.rockyhawk.commandpanels.editor;
|
package me.rockyhawk.commandpanels.editor;
|
||||||
|
|
||||||
import me.rockyhawk.commandpanels.CommandPanels;
|
import me.rockyhawk.commandpanels.CommandPanels;
|
||||||
|
import net.md_5.bungee.api.chat.BaseComponent;
|
||||||
|
import net.md_5.bungee.api.chat.ClickEvent;
|
||||||
|
import net.md_5.bungee.api.chat.ComponentBuilder;
|
||||||
import org.bukkit.ChatColor;
|
import org.bukkit.ChatColor;
|
||||||
import org.bukkit.command.CommandSender;
|
import org.bukkit.command.CommandSender;
|
||||||
|
import org.bukkit.configuration.file.YamlConfiguration;
|
||||||
|
import org.bukkit.entity.Player;
|
||||||
|
|
||||||
import java.io.*;
|
import java.io.*;
|
||||||
import java.net.URL;
|
import java.net.URL;
|
||||||
@ -13,19 +18,23 @@ import java.util.logging.Level;
|
|||||||
public class PanelDownloader {
|
public class PanelDownloader {
|
||||||
|
|
||||||
CommandPanels plugin;
|
CommandPanels plugin;
|
||||||
public PanelDownloader(CommandPanels pl) { this.plugin = pl; }
|
|
||||||
|
public PanelDownloader(CommandPanels pl) {
|
||||||
|
this.plugin = pl;
|
||||||
|
}
|
||||||
|
|
||||||
public void downloadPanel(CommandSender sender, String url, String fileName) {
|
public void downloadPanel(CommandSender sender, String url, String fileName) {
|
||||||
BufferedInputStream in = null;
|
BufferedInputStream in = null;
|
||||||
FileOutputStream fout = null;
|
FileOutputStream fout = null;
|
||||||
|
|
||||||
//add extension if not already added
|
//add extension if not already added
|
||||||
if(!fileName.endsWith(".yml") && !fileName.endsWith(".yaml")) {
|
if (!fileName.endsWith(".yml") && !fileName.endsWith(".yaml")) {
|
||||||
fileName = fileName + ".yml";
|
fileName = fileName + ".yml";
|
||||||
}
|
}
|
||||||
|
|
||||||
//Check if fileName contains file://
|
//Check if fileName contains file://
|
||||||
try {
|
try {
|
||||||
if(URLDecoder.decode(url, StandardCharsets.UTF_8.toString()).contains("file://")) {
|
if (URLDecoder.decode(url, StandardCharsets.UTF_8.toString()).contains("file://")) {
|
||||||
sender.sendMessage(plugin.tag + ChatColor.RED + "Invalid URL. Using file:// is not supported.");
|
sender.sendMessage(plugin.tag + ChatColor.RED + "Invalid URL. Using file:// is not supported.");
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
@ -55,10 +64,32 @@ public class PanelDownloader {
|
|||||||
byte[] data = new byte[1024];
|
byte[] data = new byte[1024];
|
||||||
|
|
||||||
int count;
|
int count;
|
||||||
while((count = in.read(data, 0, 1024)) != -1) {
|
while ((count = in.read(data, 0, 1024)) != -1) {
|
||||||
fout.write(data, 0, count);
|
fout.write(data, 0, count);
|
||||||
}
|
}
|
||||||
sender.sendMessage(plugin.tag + ChatColor.GREEN + "Finished downloading.");
|
if (sender instanceof Player) {
|
||||||
|
YamlConfiguration panels = YamlConfiguration.loadConfiguration(file);
|
||||||
|
if (panels.getConfigurationSection("panels").getKeys(false).size()>1) {
|
||||||
|
sender.sendMessage(plugin.tag + ChatColor.GREEN + "Finished downloading," +
|
||||||
|
ChatColor.UNDERLINE +ChatColor.YELLOW+ " Panel '" + fileName + "'");
|
||||||
|
} else {
|
||||||
|
|
||||||
|
BaseComponent[] components = new ComponentBuilder(plugin.tag +
|
||||||
|
net.md_5.bungee.api.ChatColor.GREEN + "Finished downloading, " +
|
||||||
|
ChatColor.UNDERLINE + "Panel '" + fileName + "'.\n" +
|
||||||
|
ChatColor.YELLOW + ChatColor.UNDERLINE + " Click Here to open the panel.")
|
||||||
|
.event(new ClickEvent(ClickEvent.Action.SUGGEST_COMMAND, "/cp " +
|
||||||
|
panels.getConfigurationSection("panels").getKeys(false).toArray()[0]))
|
||||||
|
.create();
|
||||||
|
Player player =(Player) sender;
|
||||||
|
player.spigot().sendMessage(components);
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
} else {
|
||||||
|
sender.sendMessage(plugin.tag + ChatColor.GREEN + "Finished downloading, " +
|
||||||
|
ChatColor.UNDERLINE +ChatColor.YELLOW+ "Panel '" + fileName + "'");
|
||||||
|
}
|
||||||
} catch (Exception var22) {
|
} catch (Exception var22) {
|
||||||
sender.sendMessage(plugin.tag + ChatColor.RED + "Could not download panel.");
|
sender.sendMessage(plugin.tag + ChatColor.RED + "Could not download panel.");
|
||||||
} finally {
|
} finally {
|
||||||
|
@ -15,19 +15,29 @@ public class OpenOnJoin implements Listener {
|
|||||||
}
|
}
|
||||||
@EventHandler
|
@EventHandler
|
||||||
public void onWorldLogin(PlayerJoinEvent e){
|
public void onWorldLogin(PlayerJoinEvent e){
|
||||||
//only opens when the player first logins
|
if (!e.getPlayer().hasPlayedBefore()) {
|
||||||
openOnJoin(e.getPlayer(),"open-on-login.");
|
openOnJoin(e.getPlayer(),"open-on-first-login");
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
//only opens when the player logs into the server
|
||||||
|
openOnJoin(e.getPlayer(),"open-on-login");
|
||||||
}
|
}
|
||||||
|
|
||||||
@EventHandler
|
@EventHandler
|
||||||
public void onWorldJoin(PlayerChangedWorldEvent e){
|
public void onWorldJoin(PlayerChangedWorldEvent e){
|
||||||
//only opens when the player changes the world internally
|
//only opens when the player changes the world internally
|
||||||
openOnJoin(e.getPlayer(),"open-on-join.");
|
openOnJoin(e.getPlayer(),"open-on-join");
|
||||||
}
|
}
|
||||||
|
|
||||||
private void openOnJoin(Player p, String joinType){
|
private void openOnJoin(Player p, String joinType){
|
||||||
if(plugin.config.contains(joinType + p.getWorld().getName())){
|
String world = p.getWorld().getName();
|
||||||
String command = "open= " + plugin.config.getString(joinType + p.getWorld().getName());
|
// Limited to '1' panel as you can only have '1' inventory open
|
||||||
|
// pass the world as "" to tell the code to not use world
|
||||||
|
if (joinType.equalsIgnoreCase("open-on-first-login")) world="";
|
||||||
|
|
||||||
|
String joinString = joinType + (world.equals("") ? "" : "."+ world);
|
||||||
|
if(plugin.config.contains(joinString)){
|
||||||
|
String command = "open= " + plugin.config.getString(joinString);
|
||||||
plugin.commandTags.runCommand(null, PanelPosition.Top,p, command);
|
plugin.commandTags.runCommand(null, PanelPosition.Top,p, command);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user