forked from Upstream/CommandPanels
3.11.2 Fixes
This commit is contained in:
parent
b789328985
commit
5e5b4a723c
@ -1,7 +1,7 @@
|
|||||||
<component name="libraryTable">
|
<component name="libraryTable">
|
||||||
<library name="PlaceholderAPI-2.10.8">
|
<library name="PlaceholderAPI-2.10.8">
|
||||||
<CLASSES>
|
<CLASSES>
|
||||||
<root url="jar://$PROJECT_DIR$/../../Tools/Build Tools/Jar Libraries/PlaceholderAPI-2.10.8.jar!/" />
|
<root url="jar://$APPLICATION_HOME_DIR$/Tools/Build Tools/Jar Libraries/PlaceholderAPI-2.10.8.jar!/" />
|
||||||
</CLASSES>
|
</CLASSES>
|
||||||
<JAVADOC />
|
<JAVADOC />
|
||||||
<SOURCES />
|
<SOURCES />
|
||||||
|
@ -1,4 +1,4 @@
|
|||||||
version: 3.11.1
|
version: 3.11.2
|
||||||
main: me.rockyhawk.commandpanels.CommandPanels
|
main: me.rockyhawk.commandpanels.CommandPanels
|
||||||
name: CommandPanels
|
name: CommandPanels
|
||||||
author: RockyHawk
|
author: RockyHawk
|
||||||
|
@ -1,11 +1,8 @@
|
|||||||
package me.rockyhawk.commandpanels;
|
package me.rockyhawk.commandpanels;
|
||||||
|
|
||||||
import com.Ben12345rocks.VotingPlugin.UserManager.UserManager;
|
import com.Ben12345rocks.VotingPlugin.UserManager.UserManager;
|
||||||
import com.mojang.authlib.GameProfile;
|
|
||||||
import com.mojang.authlib.properties.Property;
|
|
||||||
|
|
||||||
import java.io.*;
|
import java.io.*;
|
||||||
import java.lang.reflect.Field;
|
|
||||||
import java.net.InetSocketAddress;
|
import java.net.InetSocketAddress;
|
||||||
import java.net.Socket;
|
import java.net.Socket;
|
||||||
import java.util.*;
|
import java.util.*;
|
||||||
@ -18,7 +15,7 @@ import me.rockyhawk.commandpanels.classresources.*;
|
|||||||
import me.rockyhawk.commandpanels.commands.*;
|
import me.rockyhawk.commandpanels.commands.*;
|
||||||
import me.rockyhawk.commandpanels.completetabs.CpTabComplete;
|
import me.rockyhawk.commandpanels.completetabs.CpTabComplete;
|
||||||
import me.rockyhawk.commandpanels.generatepanels.Commandpanelsgenerate;
|
import me.rockyhawk.commandpanels.generatepanels.Commandpanelsgenerate;
|
||||||
import me.rockyhawk.commandpanels.generatepanels.NewGenUtils;
|
import me.rockyhawk.commandpanels.generatepanels.GenUtils;
|
||||||
import me.rockyhawk.commandpanels.generatepanels.TabCompleteGenerate;
|
import me.rockyhawk.commandpanels.generatepanels.TabCompleteGenerate;
|
||||||
import me.rockyhawk.commandpanels.ingameeditor.CpIngameEditCommand;
|
import me.rockyhawk.commandpanels.ingameeditor.CpIngameEditCommand;
|
||||||
import me.rockyhawk.commandpanels.ingameeditor.CpTabCompleteIngame;
|
import me.rockyhawk.commandpanels.ingameeditor.CpTabCompleteIngame;
|
||||||
@ -106,7 +103,7 @@ public class CommandPanels extends JavaPlugin {
|
|||||||
this.getServer().getPluginManager().registerEvents(new Utils(this), this);
|
this.getServer().getPluginManager().registerEvents(new Utils(this), this);
|
||||||
this.getServer().getPluginManager().registerEvents(new UtilsOpenWithItem(this), this);
|
this.getServer().getPluginManager().registerEvents(new UtilsOpenWithItem(this), this);
|
||||||
this.getServer().getPluginManager().registerEvents(new EditorUtils(this), this);
|
this.getServer().getPluginManager().registerEvents(new EditorUtils(this), this);
|
||||||
this.getServer().getPluginManager().registerEvents(new NewGenUtils(this), this);
|
this.getServer().getPluginManager().registerEvents(new GenUtils(this), this);
|
||||||
this.getServer().getPluginManager().registerEvents(new Commandpanelcustom(this), this);
|
this.getServer().getPluginManager().registerEvents(new Commandpanelcustom(this), this);
|
||||||
this.getServer().getPluginManager().registerEvents(new CommandpanelUserInput(this), this);
|
this.getServer().getPluginManager().registerEvents(new CommandpanelUserInput(this), this);
|
||||||
this.getServer().getPluginManager().registerEvents(new EditorUserInput(this), this);
|
this.getServer().getPluginManager().registerEvents(new EditorUserInput(this), this);
|
||||||
@ -281,7 +278,7 @@ public class CommandPanels extends JavaPlugin {
|
|||||||
p.openInventory(i);
|
p.openInventory(i);
|
||||||
} else if (onOpen == 0) {
|
} else if (onOpen == 0) {
|
||||||
//onOpen 0 will just refresh the panel
|
//onOpen 0 will just refresh the panel
|
||||||
p.getOpenInventory().getTopInventory().setStorageContents(i.getStorageContents());
|
legacy.setStorageContents(p,legacy.getStorageContents(i));
|
||||||
} else if (onOpen == 2) {
|
} else if (onOpen == 2) {
|
||||||
//will return the inventory, not opening it at all
|
//will return the inventory, not opening it at all
|
||||||
return i;
|
return i;
|
||||||
@ -446,7 +443,7 @@ public class CommandPanels extends JavaPlugin {
|
|||||||
str = str.replaceAll("%cp-player-y%", String.valueOf(Math.round(p.getLocation().getY())));
|
str = str.replaceAll("%cp-player-y%", String.valueOf(Math.round(p.getLocation().getY())));
|
||||||
str = str.replaceAll("%cp-player-z%", String.valueOf(Math.round(p.getLocation().getZ())));
|
str = str.replaceAll("%cp-player-z%", String.valueOf(Math.round(p.getLocation().getZ())));
|
||||||
str = str.replaceAll("%cp-online-players%", Integer.toString(Bukkit.getServer().getOnlinePlayers().size()));
|
str = str.replaceAll("%cp-online-players%", Integer.toString(Bukkit.getServer().getOnlinePlayers().size()));
|
||||||
//placeholder to check for server availability
|
//placeholder to check for server availability %cp-server-IP:PORT%
|
||||||
while (str.contains("%cp-server-")) {
|
while (str.contains("%cp-server-")) {
|
||||||
int start = str.indexOf("%cp-server-");
|
int start = str.indexOf("%cp-server-");
|
||||||
int end = str.indexOf("%", str.indexOf("%cp-server-")+1);
|
int end = str.indexOf("%", str.indexOf("%cp-server-")+1);
|
||||||
@ -460,6 +457,15 @@ public class CommandPanels extends JavaPlugin {
|
|||||||
str = str.replace(str.substring(start, end) + "%", papi(p, "false"));
|
str = str.replace(str.substring(start, end) + "%", papi(p, "false"));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
//does %cp-random-MIN,MAX%
|
||||||
|
while (str.contains("%cp-random-")) {
|
||||||
|
int start = str.indexOf("%cp-random-");
|
||||||
|
int end = str.indexOf("%", str.indexOf("%cp-random-")+1);
|
||||||
|
String min_max = str.substring(start, end).replace("%cp-random-", "").replace("%","");
|
||||||
|
int min = Integer.parseInt(min_max.split(",")[0]);
|
||||||
|
int max = Integer.parseInt(min_max.split(",")[1]);
|
||||||
|
str = str.replace(str.substring(start, end) + "%", String.valueOf(getRandomNumberInRange(min,max)));
|
||||||
|
}
|
||||||
while (str.contains("%cp-player-online-")) {
|
while (str.contains("%cp-player-online-")) {
|
||||||
int start = str.indexOf("%cp-player-online-");
|
int start = str.indexOf("%cp-player-online-");
|
||||||
int end = str.indexOf("-find%",str.indexOf("%cp-player-online-")+1);
|
int end = str.indexOf("-find%",str.indexOf("%cp-player-online-")+1);
|
||||||
@ -606,12 +612,22 @@ public class CommandPanels extends JavaPlugin {
|
|||||||
public Reader getReaderFromStream(InputStream initialStream) throws IOException {
|
public Reader getReaderFromStream(InputStream initialStream) throws IOException {
|
||||||
//this reads the encrypted resource files in the jar file
|
//this reads the encrypted resource files in the jar file
|
||||||
if(Bukkit.getVersion().contains("1.13") || legacy.isLegacy()){
|
if(Bukkit.getVersion().contains("1.13") || legacy.isLegacy()){
|
||||||
return new Sequence_1_13().getReaderFromStream(initialStream);
|
return new Sequence_1_13(this).getReaderFromStream(initialStream);
|
||||||
}else{
|
}else{
|
||||||
return new Sequence_1_14().getReaderFromStream(initialStream);
|
return new Sequence_1_14(this).getReaderFromStream(initialStream);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public int getRandomNumberInRange(int min, int max) {
|
||||||
|
|
||||||
|
if (min >= max) {
|
||||||
|
throw new IllegalArgumentException("max must be greater than min");
|
||||||
|
}
|
||||||
|
|
||||||
|
Random r = new Random();
|
||||||
|
return r.nextInt((max - min) + 1) + min;
|
||||||
|
}
|
||||||
|
|
||||||
//used to translate hex colours into ChatColors
|
//used to translate hex colours into ChatColors
|
||||||
public String translateHexColorCodes(String message) {
|
public String translateHexColorCodes(String message) {
|
||||||
final Pattern hexPattern = Pattern.compile("#" + "([A-Fa-f0-9]{6})");
|
final Pattern hexPattern = Pattern.compile("#" + "([A-Fa-f0-9]{6})");
|
||||||
|
@ -20,6 +20,7 @@ public class CommandTags {
|
|||||||
this.plugin = pl;
|
this.plugin = pl;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@SuppressWarnings("deprecation")
|
||||||
public void commandTags(Player p, String command) {
|
public void commandTags(Player p, String command) {
|
||||||
String tag = plugin.config.getString("config.format.tag") + " ";
|
String tag = plugin.config.getString("config.format.tag") + " ";
|
||||||
//set cp placeholders
|
//set cp placeholders
|
||||||
@ -78,10 +79,20 @@ public class CommandTags {
|
|||||||
if(!Objects.requireNonNull(plugin.config.getString("config.format.bought")).isEmpty()){
|
if(!Objects.requireNonNull(plugin.config.getString("config.format.bought")).isEmpty()){
|
||||||
p.sendMessage(plugin.papi( tag + Objects.requireNonNull(plugin.config.getString("config.format.bought")).replaceAll("%cp-args%", command.split("\\s")[1])));
|
p.sendMessage(plugin.papi( tag + Objects.requireNonNull(plugin.config.getString("config.format.bought")).replaceAll("%cp-args%", command.split("\\s")[1])));
|
||||||
}
|
}
|
||||||
|
//legacy ID
|
||||||
|
byte id = 0;
|
||||||
|
if(plugin.legacy.isLegacy()) {
|
||||||
|
for (String argsTemp : command.split("\\s")) {
|
||||||
|
if (argsTemp.startsWith("id:")) {
|
||||||
|
id = Byte.parseByte(argsTemp.replace("id:", ""));
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
if (p.getInventory().firstEmpty() >= 0) {
|
if (p.getInventory().firstEmpty() >= 0) {
|
||||||
p.getInventory().addItem(new ItemStack(Objects.requireNonNull(Material.matchMaterial(command.split("\\s")[2])), Integer.parseInt(command.split("\\s")[3])));
|
p.getInventory().addItem(new ItemStack(Objects.requireNonNull(Material.matchMaterial(command.split("\\s")[2])), Integer.parseInt(command.split("\\s")[3]),id));
|
||||||
} else {
|
} else {
|
||||||
Objects.requireNonNull(p.getLocation().getWorld()).dropItemNaturally(p.getLocation(), new ItemStack(Objects.requireNonNull(Material.matchMaterial(command.split("\\s")[2])), Integer.parseInt(command.split("\\s")[3])));
|
Objects.requireNonNull(p.getLocation().getWorld()).dropItemNaturally(p.getLocation(), new ItemStack(Objects.requireNonNull(Material.matchMaterial(command.split("\\s")[2])), Integer.parseInt(command.split("\\s")[3]),id));
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
p.sendMessage(plugin.papi( tag + plugin.config.getString("config.format.needmoney")));
|
p.sendMessage(plugin.papi( tag + plugin.config.getString("config.format.needmoney")));
|
||||||
@ -106,10 +117,20 @@ public class CommandTags {
|
|||||||
if(!Objects.requireNonNull(plugin.config.getString("config.format.bought")).isEmpty()) {
|
if(!Objects.requireNonNull(plugin.config.getString("config.format.bought")).isEmpty()) {
|
||||||
p.sendMessage(plugin.papi( tag + Objects.requireNonNull(plugin.config.getString("config.format.bought")).replaceAll("%cp-args%", command.split("\\s")[1])));
|
p.sendMessage(plugin.papi( tag + Objects.requireNonNull(plugin.config.getString("config.format.bought")).replaceAll("%cp-args%", command.split("\\s")[1])));
|
||||||
}
|
}
|
||||||
|
//legacy ID
|
||||||
|
byte id = 0;
|
||||||
|
if(plugin.legacy.isLegacy()) {
|
||||||
|
for (String argsTemp : command.split("\\s")) {
|
||||||
|
if (argsTemp.startsWith("id:")) {
|
||||||
|
id = Byte.parseByte(argsTemp.replace("id:", ""));
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
if (p.getInventory().firstEmpty() >= 0) {
|
if (p.getInventory().firstEmpty() >= 0) {
|
||||||
p.getInventory().addItem(new ItemStack(Objects.requireNonNull(Material.matchMaterial(command.split("\\s")[2])), Integer.parseInt(command.split("\\s")[3])));
|
p.getInventory().addItem(new ItemStack(Objects.requireNonNull(Material.matchMaterial(command.split("\\s")[2])), Integer.parseInt(command.split("\\s")[3]),id));
|
||||||
} else {
|
} else {
|
||||||
Objects.requireNonNull(p.getLocation().getWorld()).dropItemNaturally(p.getLocation(), new ItemStack(Objects.requireNonNull(Material.matchMaterial(command.split("\\s")[2])), Integer.parseInt(command.split("\\s")[3])));
|
Objects.requireNonNull(p.getLocation().getWorld()).dropItemNaturally(p.getLocation(), new ItemStack(Objects.requireNonNull(Material.matchMaterial(command.split("\\s")[2])), Integer.parseInt(command.split("\\s")[3]),id));
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
p.sendMessage(plugin.papi( tag + plugin.config.getString("config.format.needmoney")));
|
p.sendMessage(plugin.papi( tag + plugin.config.getString("config.format.needmoney")));
|
||||||
@ -134,6 +155,17 @@ public class CommandTags {
|
|||||||
for(String argsTemp : command.split("\\s")){
|
for(String argsTemp : command.split("\\s")){
|
||||||
if(argsTemp.startsWith("potion:")){
|
if(argsTemp.startsWith("potion:")){
|
||||||
potion = argsTemp.replace("potion:","");
|
potion = argsTemp.replace("potion:","");
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
//legacy ID
|
||||||
|
byte id = -1;
|
||||||
|
if(plugin.legacy.isLegacy()) {
|
||||||
|
for (String argsTemp : command.split("\\s")) {
|
||||||
|
if (argsTemp.startsWith("id:")) {
|
||||||
|
id = Byte.parseByte(argsTemp.replace("id:", ""));
|
||||||
|
break;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
//check to ensure any extensions are checked
|
//check to ensure any extensions are checked
|
||||||
@ -142,8 +174,12 @@ public class CommandTags {
|
|||||||
PotionMeta potionMeta = (PotionMeta) itm.getItemMeta();
|
PotionMeta potionMeta = (PotionMeta) itm.getItemMeta();
|
||||||
assert potionMeta != null;
|
assert potionMeta != null;
|
||||||
if (!potionMeta.getBasePotionData().getType().name().equalsIgnoreCase(potion)) {
|
if (!potionMeta.getBasePotionData().getType().name().equalsIgnoreCase(potion)) {
|
||||||
p.sendMessage(plugin.papi( tag + ChatColor.RED + "Your item has the wrong potion effect"));
|
continue;
|
||||||
return;
|
}
|
||||||
|
}
|
||||||
|
if (id != -1) {
|
||||||
|
if (itm.getDurability() != id) {
|
||||||
|
continue;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}catch(Exception exc){
|
}catch(Exception exc){
|
||||||
@ -192,6 +228,16 @@ public class CommandTags {
|
|||||||
potion = argsTemp.replace("potion:","");
|
potion = argsTemp.replace("potion:","");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
//legacy ID
|
||||||
|
byte id = -1;
|
||||||
|
if(plugin.legacy.isLegacy()) {
|
||||||
|
for (String argsTemp : command.split("\\s")) {
|
||||||
|
if (argsTemp.startsWith("id:")) {
|
||||||
|
id = Byte.parseByte(argsTemp.replace("id:", ""));
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
//check to ensure any extensions are checked
|
//check to ensure any extensions are checked
|
||||||
try {
|
try {
|
||||||
if (!potion.equals("false")) {
|
if (!potion.equals("false")) {
|
||||||
@ -202,6 +248,11 @@ public class CommandTags {
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
if (id != -1) {
|
||||||
|
if (itm.getDurability() != id) {
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
}
|
||||||
}catch(Exception exc){
|
}catch(Exception exc){
|
||||||
//skip if it cannot do unless plugin.debug is enabled
|
//skip if it cannot do unless plugin.debug is enabled
|
||||||
plugin.debug(exc);
|
plugin.debug(exc);
|
||||||
|
@ -24,10 +24,10 @@ import java.util.ArrayList;
|
|||||||
import java.util.Arrays;
|
import java.util.Arrays;
|
||||||
import java.util.Objects;
|
import java.util.Objects;
|
||||||
|
|
||||||
public class NewGenUtils implements Listener {
|
public class GenUtils implements Listener {
|
||||||
public YamlConfiguration tempEdit;
|
public YamlConfiguration tempEdit;
|
||||||
CommandPanels plugin;
|
CommandPanels plugin;
|
||||||
public NewGenUtils(CommandPanels pl) {
|
public GenUtils(CommandPanels pl) {
|
||||||
this.plugin = pl;
|
this.plugin = pl;
|
||||||
this.tempEdit = YamlConfiguration.loadConfiguration(new File(plugin.getDataFolder() + File.separator + "temp.yml"));
|
this.tempEdit = YamlConfiguration.loadConfiguration(new File(plugin.getDataFolder() + File.separator + "temp.yml"));
|
||||||
}
|
}
|
||||||
@ -123,6 +123,11 @@ public class NewGenUtils implements Listener {
|
|||||||
}else {
|
}else {
|
||||||
file.addDefault("panels." + date + ".item." + i + ".material", cont[i].getType().toString());
|
file.addDefault("panels." + date + ".item." + i + ".material", cont[i].getType().toString());
|
||||||
}
|
}
|
||||||
|
if(plugin.legacy.isLegacy()){
|
||||||
|
if (cont[i].getDurability() != 0 && !cont[i].getType().toString().equals("SKULL_ITEM") && !cont[i].getType().toString().equals("SKULL_ITEM")) {
|
||||||
|
file.addDefault("panels." + date + ".item." + i + ".ID", cont[i].getDurability());
|
||||||
|
}
|
||||||
|
}
|
||||||
if(cont[i].getAmount() != 1){
|
if(cont[i].getAmount() != 1){
|
||||||
file.addDefault("panels." + date + ".item." + i + ".stack", cont[i].getAmount());
|
file.addDefault("panels." + date + ".item." + i + ".stack", cont[i].getAmount());
|
||||||
}
|
}
|
@ -630,6 +630,11 @@ public class EditorUtils implements Listener {
|
|||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
if(plugin.legacy.isLegacy()){
|
||||||
|
if (cont.getDurability() != 0 && !cont.getType().toString().equals("SKULL_ITEM") && !cont.getType().toString().equals("SKULL_ITEM")) {
|
||||||
|
file.addDefault("panels." + panelName + ".item." + i + ".ID", cont.getDurability());
|
||||||
|
}
|
||||||
|
}
|
||||||
if(file.contains("panels." + panelName + ".item." + i + ".material")){
|
if(file.contains("panels." + panelName + ".item." + i + ".material")){
|
||||||
if(Objects.requireNonNull(file.getString("panels." + panelName + ".item." + i + ".material")).contains("%") || Objects.requireNonNull(file.getString("panels." + panelName + ".item." + i + ".material")).contains("=")){
|
if(Objects.requireNonNull(file.getString("panels." + panelName + ".item." + i + ".material")).contains("%") || Objects.requireNonNull(file.getString("panels." + panelName + ".item." + i + ".material")).contains("=")){
|
||||||
if(!plugin.getHeads.ifSkullOrHead(cont.getType().toString())){
|
if(!plugin.getHeads.ifSkullOrHead(cont.getType().toString())){
|
||||||
|
@ -88,7 +88,7 @@ public class Commandpanelrefresher implements Listener {
|
|||||||
final String fpanel = panel;
|
final String fpanel = panel;
|
||||||
final String fpanelTitle = panelTitle;
|
final String fpanelTitle = panelTitle;
|
||||||
ItemStack[] panelItemList = plugin.openGui(fpanel, p, cf,2, -1).getContents();
|
ItemStack[] panelItemList = plugin.openGui(fpanel, p, cf,2, -1).getContents();
|
||||||
ItemStack[] playerItemList = p.getInventory().getStorageContents();
|
ItemStack[] playerItemList = plugin.legacy.getStorageContents(p.getInventory());
|
||||||
new BukkitRunnable(){
|
new BukkitRunnable(){
|
||||||
int c = 0;
|
int c = 0;
|
||||||
int animatecount = 0;
|
int animatecount = 0;
|
||||||
@ -133,7 +133,7 @@ public class Commandpanelrefresher implements Listener {
|
|||||||
//check to ensure players haven't duplicated items
|
//check to ensure players haven't duplicated items
|
||||||
try {
|
try {
|
||||||
p.updateInventory();
|
p.updateInventory();
|
||||||
for (ItemStack playerContent : p.getInventory().getStorageContents()) {
|
for (ItemStack playerContent : plugin.legacy.getStorageContents(p.getInventory())) {
|
||||||
for (ItemStack panelContent : panelItemList) {
|
for (ItemStack panelContent : panelItemList) {
|
||||||
if (playerContent != null && panelContent != null) {
|
if (playerContent != null && panelContent != null) {
|
||||||
if (!playerContent.getType().equals(Material.matchMaterial("AIR")) && !panelContent.getType().equals(Material.matchMaterial("AIR"))) {
|
if (!playerContent.getType().equals(Material.matchMaterial("AIR")) && !panelContent.getType().equals(Material.matchMaterial("AIR"))) {
|
||||||
|
@ -0,0 +1,22 @@
|
|||||||
|
package me.rockyhawk.commandpanels.ioclasses;
|
||||||
|
|
||||||
|
import me.rockyhawk.commandpanels.CommandPanels;
|
||||||
|
import org.bukkit.entity.Player;
|
||||||
|
import org.bukkit.inventory.Inventory;
|
||||||
|
import org.bukkit.inventory.ItemStack;
|
||||||
|
|
||||||
|
//get contents
|
||||||
|
public class GetStorageContents {
|
||||||
|
CommandPanels plugin;
|
||||||
|
public GetStorageContents(CommandPanels pl) {
|
||||||
|
this.plugin = pl;
|
||||||
|
}
|
||||||
|
|
||||||
|
public ItemStack[] getStorageContents(Inventory i){
|
||||||
|
return i.getContents();
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setStorageContents(Player p, ItemStack[] i){
|
||||||
|
p.getOpenInventory().getTopInventory().setContents(i);
|
||||||
|
}
|
||||||
|
}
|
@ -0,0 +1,22 @@
|
|||||||
|
package me.rockyhawk.commandpanels.ioclasses;
|
||||||
|
|
||||||
|
import me.rockyhawk.commandpanels.CommandPanels;
|
||||||
|
import org.bukkit.entity.Player;
|
||||||
|
import org.bukkit.inventory.Inventory;
|
||||||
|
import org.bukkit.inventory.ItemStack;
|
||||||
|
|
||||||
|
//get contents legacy
|
||||||
|
public class GetStorageContents_Legacy {
|
||||||
|
CommandPanels plugin;
|
||||||
|
public GetStorageContents_Legacy(CommandPanels pl) {
|
||||||
|
this.plugin = pl;
|
||||||
|
}
|
||||||
|
|
||||||
|
public ItemStack[] getStorageContents(Inventory i){
|
||||||
|
return i.getContents();
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setStorageContents(Player p, ItemStack[] i){
|
||||||
|
p.getOpenInventory().getTopInventory().setContents(i);
|
||||||
|
}
|
||||||
|
}
|
@ -1,14 +1,23 @@
|
|||||||
package me.rockyhawk.commandpanels.ioclasses;
|
package me.rockyhawk.commandpanels.ioclasses;
|
||||||
|
|
||||||
//1.13 Imports
|
//1.13- Imports
|
||||||
|
import me.rockyhawk.commandpanels.CommandPanels;
|
||||||
import org.apache.commons.io.IOUtils;
|
import org.apache.commons.io.IOUtils;
|
||||||
import org.apache.commons.io.input.CharSequenceReader;
|
import org.apache.commons.io.input.CharSequenceReader;
|
||||||
|
import org.bukkit.entity.Player;
|
||||||
|
import org.bukkit.inventory.Inventory;
|
||||||
|
import org.bukkit.inventory.ItemStack;
|
||||||
|
|
||||||
import java.io.IOException;
|
import java.io.IOException;
|
||||||
import java.io.InputStream;
|
import java.io.InputStream;
|
||||||
import java.io.Reader;
|
import java.io.Reader;
|
||||||
|
|
||||||
public class Sequence_1_13 {
|
public class Sequence_1_13 {
|
||||||
|
CommandPanels plugin;
|
||||||
|
public Sequence_1_13(CommandPanels pl) {
|
||||||
|
this.plugin = pl;
|
||||||
|
}
|
||||||
|
|
||||||
public Reader getReaderFromStream(InputStream initialStream) throws IOException {
|
public Reader getReaderFromStream(InputStream initialStream) throws IOException {
|
||||||
//this reads the encrypted resource files in the jar file
|
//this reads the encrypted resource files in the jar file
|
||||||
byte[] buffer = IOUtils.toByteArray(initialStream);
|
byte[] buffer = IOUtils.toByteArray(initialStream);
|
||||||
|
@ -1,14 +1,23 @@
|
|||||||
package me.rockyhawk.commandpanels.ioclasses;
|
package me.rockyhawk.commandpanels.ioclasses;
|
||||||
|
|
||||||
//1.14+ Imports
|
//1.14+ Imports
|
||||||
|
import me.rockyhawk.commandpanels.CommandPanels;
|
||||||
import org.bukkit.craftbukkit.libs.org.apache.commons.io.IOUtils;
|
import org.bukkit.craftbukkit.libs.org.apache.commons.io.IOUtils;
|
||||||
import org.bukkit.craftbukkit.libs.org.apache.commons.io.input.CharSequenceReader;
|
import org.bukkit.craftbukkit.libs.org.apache.commons.io.input.CharSequenceReader;
|
||||||
|
import org.bukkit.entity.Player;
|
||||||
|
import org.bukkit.inventory.Inventory;
|
||||||
|
import org.bukkit.inventory.ItemStack;
|
||||||
|
|
||||||
import java.io.IOException;
|
import java.io.IOException;
|
||||||
import java.io.InputStream;
|
import java.io.InputStream;
|
||||||
import java.io.Reader;
|
import java.io.Reader;
|
||||||
|
|
||||||
public class Sequence_1_14 {
|
public class Sequence_1_14 {
|
||||||
|
CommandPanels plugin;
|
||||||
|
public Sequence_1_14(CommandPanels pl) {
|
||||||
|
this.plugin = pl;
|
||||||
|
}
|
||||||
|
|
||||||
public Reader getReaderFromStream(InputStream initialStream) throws IOException {
|
public Reader getReaderFromStream(InputStream initialStream) throws IOException {
|
||||||
//this reads the encrypted resource files in the jar file
|
//this reads the encrypted resource files in the jar file
|
||||||
byte[] buffer = IOUtils.toByteArray(initialStream);
|
byte[] buffer = IOUtils.toByteArray(initialStream);
|
||||||
|
@ -1,7 +1,12 @@
|
|||||||
package me.rockyhawk.commandpanels.legacy;
|
package me.rockyhawk.commandpanels.legacy;
|
||||||
|
|
||||||
import me.rockyhawk.commandpanels.CommandPanels;
|
import me.rockyhawk.commandpanels.CommandPanels;
|
||||||
|
import me.rockyhawk.commandpanels.ioclasses.GetStorageContents_Legacy;
|
||||||
|
import me.rockyhawk.commandpanels.ioclasses.GetStorageContents;
|
||||||
import org.bukkit.Bukkit;
|
import org.bukkit.Bukkit;
|
||||||
|
import org.bukkit.entity.Player;
|
||||||
|
import org.bukkit.inventory.Inventory;
|
||||||
|
import org.bukkit.inventory.ItemStack;
|
||||||
|
|
||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
|
|
||||||
@ -11,10 +16,31 @@ public class LegacyVersion {
|
|||||||
this.plugin = pl;
|
this.plugin = pl;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
//true if 1.15 or below
|
||||||
|
public boolean isLegacyStorageContents() {
|
||||||
|
boolean output = false;
|
||||||
|
ArrayList<String> legacyVersions = new ArrayList<>();
|
||||||
|
legacyVersions.add("1.8");
|
||||||
|
legacyVersions.add("1.9");
|
||||||
|
legacyVersions.add("1.10");
|
||||||
|
legacyVersions.add("1.11");
|
||||||
|
legacyVersions.add("1.12");
|
||||||
|
legacyVersions.add("1.13");
|
||||||
|
legacyVersions.add("1.14");
|
||||||
|
legacyVersions.add("1.15");
|
||||||
|
for(String key : legacyVersions){
|
||||||
|
if (Bukkit.getVersion().contains(key)) {
|
||||||
|
output = true;
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return output;
|
||||||
|
}
|
||||||
|
|
||||||
//true if 1.12 or below
|
//true if 1.12 or below
|
||||||
public boolean isLegacy() {
|
public boolean isLegacy() {
|
||||||
boolean output = false;
|
boolean output = false;
|
||||||
ArrayList<String> legacyVersions = new ArrayList();
|
ArrayList<String> legacyVersions = new ArrayList<>();
|
||||||
legacyVersions.add("1.8");
|
legacyVersions.add("1.8");
|
||||||
legacyVersions.add("1.9");
|
legacyVersions.add("1.9");
|
||||||
legacyVersions.add("1.10");
|
legacyVersions.add("1.10");
|
||||||
@ -28,4 +54,20 @@ public class LegacyVersion {
|
|||||||
}
|
}
|
||||||
return output;
|
return output;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public ItemStack[] getStorageContents(Inventory i){
|
||||||
|
if(plugin.legacy.isLegacy()){
|
||||||
|
return new GetStorageContents_Legacy(plugin).getStorageContents(i);
|
||||||
|
}else{
|
||||||
|
return new GetStorageContents(plugin).getStorageContents(i);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setStorageContents(Player p, ItemStack[] i){
|
||||||
|
if(plugin.legacy.isLegacyStorageContents()){
|
||||||
|
new GetStorageContents_Legacy(plugin).setStorageContents(p,i);
|
||||||
|
}else{
|
||||||
|
new GetStorageContents(plugin).setStorageContents(p,i);
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user