6 Commits

Author SHA1 Message Date
17b1a0568e bugfix
If you didn't have the permission to see an item, you could still click on it and get the message that you don't have the permission. This has now been changed so that you only get the message if you can see the item.
2022-04-06 20:21:19 +02:00
1c6e6d6660 2.6.2_Snapshop-1
The GUI listener has been redesigned in terms of code and improved in terms of performance.
2022-03-28 21:56:57 +02:00
JaTiTV
ff2cb3ce96 Merge pull request '2.6.1' (#6) from perm-change into main
Reviewed-on: JaTiTV/CommandGUI#6
2022-03-21 22:23:25 +01:00
92d4c86aa0 2.6.1 2022-03-21 22:21:54 +01:00
e98c047ff0 Update pom.xml 2022-03-10 22:54:24 +01:00
4cbe8ed802 2.6.0
Add:
- 1.18.2 Support

Bugfix:
- Fixed a bug where bungee commands were executed multiple times when multiple players were on the server.

New features:
- Bungee commands can now also be executed from the server
2022-03-08 20:12:02 +01:00
11 changed files with 326 additions and 463 deletions

View File

@@ -6,7 +6,7 @@
<groupId>net.t2code</groupId> <groupId>net.t2code</groupId>
<artifactId>CommandGUI_V2</artifactId> <artifactId>CommandGUI_V2</artifactId>
<version>2.5.23</version> <version>2.6.2_Snapshot-2</version>
<packaging>jar</packaging> <packaging>jar</packaging>
<name>CommandGUI</name> <name>CommandGUI</name>
@@ -53,6 +53,10 @@
</build> </build>
<repositories> <repositories>
<repository>
<id>spigot-repo</id>
<url>https://hub.spigotmc.org/nexus/content/repositories/snapshots/</url>
</repository>
<repository> <repository>
<id>Builders-Paradise</id> <id>Builders-Paradise</id>
<url>https://repo.t2code.net/repository/Builders-Paradise/</url> <url>https://repo.t2code.net/repository/Builders-Paradise/</url>
@@ -61,10 +65,7 @@
<id>T2Code</id> <id>T2Code</id>
<url>https://repo.t2code.net/repository/T2Code/</url> <url>https://repo.t2code.net/repository/T2Code/</url>
</repository> </repository>
<repository>
<id>spigot-repo</id>
<url>https://hub.spigotmc.org/nexus/content/repositories/snapshots/</url>
</repository>
</repositories> </repositories>
<dependencies> <dependencies>
@@ -81,13 +82,18 @@
<dependency> <dependency>
<groupId>net.t2code</groupId> <groupId>net.t2code</groupId>
<artifactId>T2CodeLib</artifactId> <artifactId>T2CodeLib</artifactId>
<version>10.3</version> <version>11.2</version>
</dependency> </dependency>
<dependency> <dependency>
<groupId>net.t2code</groupId> <groupId>net.t2code</groupId>
<artifactId>LuckyBox-API</artifactId> <artifactId>LuckyBox-API</artifactId>
<version>4.2.2</version> <version>4.2.2</version>
</dependency> </dependency>
<dependency>
<groupId>net.t2code.minecraft.1_18.r2</groupId>
<artifactId>spigot</artifactId>
<version>1.18r2</version>
</dependency>
<dependency> <dependency>
<groupId>net.t2code.minecraft.1_18.r1</groupId> <groupId>net.t2code.minecraft.1_18.r1</groupId>
<artifactId>spigot</artifactId> <artifactId>spigot</artifactId>

View File

@@ -1,6 +1,7 @@
package de.jatitv.commandguiv2.Bungee; package de.jatitv.commandguiv2.Bungee;
import net.md_5.bungee.BungeeCord; import net.md_5.bungee.BungeeCord;
import net.md_5.bungee.api.ProxyServer;
import net.md_5.bungee.api.connection.ProxiedPlayer; import net.md_5.bungee.api.connection.ProxiedPlayer;
import net.md_5.bungee.api.event.PlayerDisconnectEvent; import net.md_5.bungee.api.event.PlayerDisconnectEvent;
import net.md_5.bungee.api.event.PluginMessageEvent; import net.md_5.bungee.api.event.PluginMessageEvent;
@@ -16,13 +17,20 @@ public class BListener implements Listener {
@EventHandler @EventHandler
public void onPluginmessage(PluginMessageEvent event) { public void onPluginmessage(PluginMessageEvent event) {
if (event.getTag().equalsIgnoreCase("cgui:bungee")) { if (event.getTag().equalsIgnoreCase("cgui:bungee")) {
DataInputStream stream = new DataInputStream(new ByteArrayInputStream(event.getData())); DataInputStream stream = new DataInputStream(new ByteArrayInputStream(event.getData()));
try { try {
String channel = stream.readUTF(); String channel = stream.readUTF();
String input = stream.readUTF(); String input = stream.readUTF();
ProxiedPlayer player = BungeeCord.getInstance().getPlayer(channel); if (channel.equals("cgui-Console")) {
ProxyServer.getInstance().getConsole().sendMessage("Command Console: "+ input);
ProxyServer.getInstance().getPluginManager().dispatchCommand(ProxyServer.getInstance().getConsole(), input);
} else {
ProxiedPlayer player = ProxyServer.getInstance().getPlayer(channel);
if (player != null) { if (player != null) {
BungeeCord.getInstance().getPluginManager().dispatchCommand(player, input); ProxyServer.getInstance().getConsole().sendMessage("Command " + player +": "+ input);
ProxyServer.getInstance().getPluginManager().dispatchCommand(player, input);
}
} }
} catch (IOException e) { } catch (IOException e) {
e.printStackTrace(); e.printStackTrace();

View File

@@ -22,6 +22,7 @@ import org.bukkit.event.Listener;
import org.bukkit.event.inventory.ClickType; import org.bukkit.event.inventory.ClickType;
import org.bukkit.event.inventory.InventoryClickEvent; import org.bukkit.event.inventory.InventoryClickEvent;
import org.bukkit.plugin.Plugin; import org.bukkit.plugin.Plugin;
import org.bukkit.plugin.java.JavaPlugin;
import org.bukkit.scheduler.BukkitRunnable; import org.bukkit.scheduler.BukkitRunnable;
import java.io.File; import java.io.File;
@@ -36,66 +37,93 @@ public class GUI_Listener implements Listener {
@EventHandler @EventHandler
public void onInventoryClick(InventoryClickEvent e) { public void onInventoryClick(InventoryClickEvent e) {
Player player = (Player) e.getWhoClicked(); Player player = (Player) e.getWhoClicked();
if (e.getInventory() != null && e.getCurrentItem() != null) { JavaPlugin plugin = Main.plugin;
if (e.getInventory() == null) return;
if (e.getCurrentItem() == null) return;
for (Object gui : Main.guiHashMap.values()) { for (Object gui : Main.guiHashMap.values()) {
if (player.getOpenInventory().getTitle().equals(Replace.replace(prefix, GUICode + gui.GUI_Name)) if (player.getOpenInventory().getTitle().equals(Replace.replace(prefix, GUICode + gui.GUI_Name))
|| (Main.PaPi && player.getOpenInventory().getTitle().equals(Replace.replace(prefix, player, GUICode + gui.GUI_Name)))) { || (Main.PaPi && player.getOpenInventory().getTitle().equals(Replace.replace(prefix, player, GUICode + gui.GUI_Name)))) {
e.setCancelled(true); e.setCancelled(true);
for (Slot slot : gui.GUI_Slots) { for (Slot slot : gui.GUI_Slots) {
/* if (!slot.ItemsRemovable) { if (e.getSlot() != slot.Slot) continue;
e.setCancelled(true);
}
*/
if (e.getSlot() == slot.Slot) {
if (!slot.Perm || player.hasPermission("commandgui.gui." + gui.Command_Command + ".slot." + (slot.Slot + 1))
|| player.hasPermission("commandgui.admin")) {
if (slot.Enable) {
if (e.getCurrentItem().getItemMeta().getDisplayName().equals(Replace.replace(prefix, slot.Name))) {
if (e.getCurrentItem().getType() == ItemVersion.getHead() || e.getCurrentItem().getType() == Material.valueOf(slot.Item.toUpperCase().replace(".", "_"))) { if (e.getCurrentItem().getType() == ItemVersion.getHead() || e.getCurrentItem().getType() == Material.valueOf(slot.Item.toUpperCase().replace(".", "_"))) {
if (!slot.Perm
|| player.hasPermission("commandgui.gui." + gui.Command_Command + ".slot." + (slot.Slot + 1))
|| player.hasPermission("commandgui.gui." + gui.Command_Command + ".slot." + (slot.Slot + 1) + ".use")
|| player.hasPermission("commandgui.admin")) {
if (!slot.Enable) continue;
if (!e.getCurrentItem().getItemMeta().getDisplayName().equals(Replace.replace(prefix, slot.Name))) continue;
if (slot.Cost_Enable) { if (slot.Cost_Enable) {
if (slot.Command_Enable || slot.Message_Enable || slot.OpenGUI_Enable || slot.ServerChange) { if (slot.Command_Enable || slot.Message_Enable || slot.OpenGUI_Enable || slot.ServerChange) {
if (Vault.buy(prefix, player, slot.Price)) { if (!Vault.buy(prefix, player, slot.Price)) {
player.sendMessage(SelectMessages.Buy_msg.replace("[itemname]", Replace.replace(prefix, slot.Name))
.replace("[price]", slot.Price + " " + SelectConfig.Currency));
if (slot.Command_Enable) {
new BukkitRunnable() { new BukkitRunnable() {
@Override @Override
public void run() { public void run() {
player.closeInventory(); player.closeInventory();
} }
}.runTaskLater(plugin, 1L); }.runTaskLater(plugin, 1L);
player.sendMessage(SelectMessages.No_money);
if (SelectConfig.Sound_NoMoney_Enable && SelectConfig.Sound_Enable)
player.playSound(player.getLocation(), SelectConfig.Sound_NoMoney, 3, 1);
} else {
player.sendMessage(SelectMessages.Buy_msg.replace("[itemname]", Replace.replace(prefix, slot.Name))
.replace("[price]", slot.Price + " " + SelectConfig.Currency));
execute(slot, player, e, gui);
}
}
} else execute(slot, player, e, gui);
} else player.sendMessage(SelectMessages.NoPermissionForItem.replace("[item]", Replace.replace(prefix, slot.Name))
.replace("[perm]", "commandgui.gui." + gui.Command_Command + ".slot." + (slot.Slot + 1)));
}
}
}
}
}
private static void execute(Slot slot, Player player, InventoryClickEvent e, Object gui) {
if (slot.Command_Enable) command(slot, player);
if (slot.OpenGUI_Enable) openGUI(slot, player);
if (slot.Message_Enable) message(slot, player);
if (slot.ServerChange) serverChange(slot, player);
if (slot.SetConfigEnable) setConfig(slot, player, e);
if (SelectConfig.Sound_Enable && SelectConfig.Sound_Click_Enable) sound(slot, player, gui);
}
private static void command(Slot slot, Player player) {
new BukkitRunnable() { new BukkitRunnable() {
@Override @Override
public void run() { public void run() {
if (slot.Command_BungeeCommand && SelectConfig.Bungee) { player.closeInventory();
}
}.runTaskLater(plugin, 1L);
new BukkitRunnable() {
@Override
public void run() {
if (slot.Command_BungeeCommand) {
if (SelectConfig.Bungee) {
for (String cmd : slot.Command) { for (String cmd : slot.Command) {
Bungee_Sender_Reciver.sendToBungee(player, player.getName(), cmd.replace("[player]", player.getName())); Bungee_Sender_Reciver.sendToBungee(player, cmd.replace("[player]", player.getName()), slot.CommandAsConsole);
} }
} else { } else {
send.console(prefix + " §4To use bungee commands, enable the Bungee option in the config.");
send.player(player, prefix + " §4To use bungee commands, enable the Bungee option in the config.");
}
} else {
for (String cmd : slot.Command) {
if (slot.CommandAsConsole) { if (slot.CommandAsConsole) {
for (String cmd : slot.Command) {
Bukkit.getServer().dispatchCommand(Bukkit.getServer().getConsoleSender(), cmd.replace("[player]", player.getName())); Bukkit.getServer().dispatchCommand(Bukkit.getServer().getConsoleSender(), cmd.replace("[player]", player.getName()));
} } else player.chat("/" + cmd.replace("[player]", player.getName()));
} else {
for (String cmd : slot.Command) {
player.chat("/" + cmd.replace("[player]", player.getName()));
}
} }
} }
} }
}.runTaskLater(plugin, 2L); }.runTaskLater(plugin, 2L);
} }
if (slot.OpenGUI_Enable) {
private static void openGUI(Slot slot, Player player) {
new BukkitRunnable() { new BukkitRunnable() {
@Override @Override
public void run() { public void run() {
player.closeInventory(); player.closeInventory();
} }
}.runTaskLater(plugin, 1L); }.runTaskLater(plugin, 1L);
new BukkitRunnable() { new BukkitRunnable() {
@@ -105,29 +133,34 @@ public class GUI_Listener implements Listener {
} }
}.runTaskLater(plugin, 2L); }.runTaskLater(plugin, 2L);
} }
if (slot.Message_Enable) {
private static void message(Slot slot, Player player) {
new BukkitRunnable() { new BukkitRunnable() {
@Override @Override
public void run() { public void run() {
player.closeInventory(); player.closeInventory();
} }
}.runTaskLater(plugin, 1L); }.runTaskLater(plugin, 1L);
for (String msg : slot.Message) { for (String msg : slot.Message) {
if (Main.PaPi) { if (Main.PaPi) {
if (slot.Cost_Enable) {
player.sendMessage(Replace.replacePrice(prefix, player, msg, slot.Price + " " + SelectConfig.Currency)); player.sendMessage(Replace.replacePrice(prefix, player, msg, slot.Price + " " + SelectConfig.Currency));
} else } else player.sendMessage(Replace.replace(prefix, player, msg.replace("[prefix]", prefix)));
} else {
if (slot.Cost_Enable) {
player.sendMessage(Replace.replacePrice(prefix, msg, slot.Price + " " + SelectConfig.Currency)); player.sendMessage(Replace.replacePrice(prefix, msg, slot.Price + " " + SelectConfig.Currency));
} else player.sendMessage(Replace.replace(prefix, msg.replace("[prefix]", prefix)));
} }
} }
if (slot.ServerChange) { }
private static void serverChange(Slot slot, Player player) {
new BukkitRunnable() { new BukkitRunnable() {
@Override @Override
public void run() { public void run() {
player.closeInventory(); player.closeInventory();
} }
}.runTaskLater(plugin, 1L); }.runTaskLater(plugin, 1L);
send.player(player, SelectMessages.onServerChange.replace("[server]", slot.ServerChangeServer)); send.player(player, SelectMessages.onServerChange.replace("[server]", slot.ServerChangeServer));
new BukkitRunnable() { new BukkitRunnable() {
@Override @Override
@@ -136,7 +169,8 @@ public class GUI_Listener implements Listener {
} }
}.runTaskLater(Main.plugin, 20L); }.runTaskLater(Main.plugin, 20L);
} }
if (slot.SetConfigEnable) {
private static void setConfig(Slot slot, Player player, InventoryClickEvent e) {
File config = new File(slot.ConfigFilePath); File config = new File(slot.ConfigFilePath);
YamlConfiguration yamlConfiguration = YamlConfiguration.loadConfiguration(config); YamlConfiguration yamlConfiguration = YamlConfiguration.loadConfiguration(config);
/*if (slot.ConfigChatInput){ /*if (slot.ConfigChatInput){
@@ -192,7 +226,7 @@ public class GUI_Listener implements Listener {
}.runTaskLater(plugin, 1L); }.runTaskLater(plugin, 1L);
} }
if (SelectConfig.Sound_Enable && SelectConfig.Sound_Click_Enable) { private static void sound(Slot slot, Player player, Object gui) {
if (slot.CustomSound_Enable) { if (slot.CustomSound_Enable) {
if (!slot.CustomSound_NoSound) { if (!slot.CustomSound_NoSound) {
try { try {
@@ -204,193 +238,7 @@ public class GUI_Listener implements Listener {
player.playSound(player.getLocation(), SelectConfig.Sound_Click, 3, 1); player.playSound(player.getLocation(), SelectConfig.Sound_Click, 3, 1);
} }
} }
} else } else player.playSound(player.getLocation(), SelectConfig.Sound_Click, 3, 1);
player.playSound(player.getLocation(), SelectConfig.Sound_Click, 3, 1);
}
} else {
new BukkitRunnable() {
@Override
public void run() {
player.closeInventory();
}
}.runTaskLater(plugin, 1L);
player.sendMessage(SelectMessages.No_money);
if (SelectConfig.Sound_NoMoney_Enable && SelectConfig.Sound_Enable) {
player.playSound(player.getLocation(), SelectConfig.Sound_NoMoney, 3, 1);
}
}
}
} else {
if (slot.Command_Enable) {
new BukkitRunnable() {
@Override
public void run() {
player.closeInventory();
}
}.runTaskLater(plugin, 1L);
new BukkitRunnable() {
@Override
public void run() {
if (slot.Command_BungeeCommand) {
if (SelectConfig.Bungee) {
for (String cmd : slot.Command) {
Bungee_Sender_Reciver.sendToBungee(player, player.getName(), cmd.replace("[player]", player.getName()));
}
} else {
send.console(prefix + " §4To use bungee commands, enable the Bungee option in the config.");
send.player(player, prefix + " §4To use bungee commands, enable the Bungee option in the config.");
}
} else {
if (slot.CommandAsConsole) {
for (String cmd : slot.Command) {
Bukkit.getServer().dispatchCommand(Bukkit.getServer().getConsoleSender(), cmd.replace("[player]", player.getName()));
}
} else {
for (String cmd : slot.Command) {
player.chat("/" + cmd);
}
}
}
}
}.runTaskLater(plugin, 2L);
}
if (slot.OpenGUI_Enable) {
new BukkitRunnable() {
@Override
public void run() {
player.closeInventory();
}
}.runTaskLater(plugin, 1L);
new BukkitRunnable() {
@Override
public void run() {
OpenGUI.openGUI(player, Main.guiHashMap.get(slot.OpenGUI), slot.OpenGUI);
}
}.runTaskLater(plugin, 2L);
}
if (slot.Message_Enable) {
new BukkitRunnable() {
@Override
public void run() {
player.closeInventory();
}
}.runTaskLater(plugin, 1L);
for (String msg : slot.Message) {
if (Main.PaPi) {
player.sendMessage(Replace.replace(prefix, player, msg.replace("[prefix]", prefix)));
} else
player.sendMessage(Replace.replace(prefix, msg.replace("[prefix]", prefix)));
}
}
if (slot.ServerChange) {
new BukkitRunnable() {
@Override
public void run() {
player.closeInventory();
}
}.runTaskLater(plugin, 1L);
send.player(player, SelectMessages.onServerChange.replace("[server]", slot.ServerChangeServer));
new BukkitRunnable() {
@Override
public void run() {
ServerChange.send(player, slot.ServerChangeServer);
}
}.runTaskLater(Main.plugin, 20L);
}
if (slot.SetConfigEnable) {
File config = new File(slot.ConfigFilePath);
YamlConfiguration yamlConfiguration = YamlConfiguration.loadConfiguration(config);
/*if (slot.ConfigChatInput){
ConfigChat.EditChat.put(player, slot.ConfigOptionPath);
player.sendMessage(DefaultValue.SettingsGUIchatSet.replace("[setting]", "Shop Name Chest small"));
player.sendMessage(DefaultValue.SettingsGUIchatCancel);
} else
{
*/
if (e.isLeftClick()) {
if (slot.ConfigOptionPremat.equals("String")) {
yamlConfiguration.set(slot.ConfigOptionPath.replace("/", "."), slot.ConfigStringValueLeft);
} else if (slot.ConfigOptionPremat.equals("Boolean")) {
yamlConfiguration.set(slot.ConfigOptionPath.replace("/", "."), slot.ConfigBooleanValueLeft);
} else if (slot.ConfigOptionPremat.equals("Integer")) {
yamlConfiguration.set(slot.ConfigOptionPath.replace("/", "."), slot.ConfigIntegerValueLeft);
} else if (slot.ConfigOptionPremat.equals("Double")) {
yamlConfiguration.set(slot.ConfigOptionPath.replace("/", "."), slot.ConfigDoubleValueLeft);
} else if (slot.ConfigOptionPremat.equals("List")) {
yamlConfiguration.set(slot.ConfigOptionPath.replace("/", "."), slot.ConfigListValueLeft);
} else {
player.sendMessage("§cCheck the Option §6SetConfig/Option/Premat"); //todo
}
}
if (e.isRightClick()) {
if (slot.ConfigOptionPremat.equals("String")) {
yamlConfiguration.set(slot.ConfigOptionPath.replace("/", "."), slot.ConfigStringValueRight);
} else if (slot.ConfigOptionPremat.equals("Boolean")) {
yamlConfiguration.set(slot.ConfigOptionPath.replace("/", "."), slot.ConfigBooleanValueRight);
} else if (slot.ConfigOptionPremat.equals("Integer")) {
yamlConfiguration.set(slot.ConfigOptionPath.replace("/", "."), slot.ConfigIntegerValueRight);
} else if (slot.ConfigOptionPremat.equals("Double")) {
yamlConfiguration.set(slot.ConfigOptionPath.replace("/", "."), slot.ConfigDoubleValueRight);
} else if (slot.ConfigOptionPremat.equals("List")) {
yamlConfiguration.set(slot.ConfigOptionPath.replace("/", "."), slot.ConfigListValueRight);
} else {
player.sendMessage("§cCheck the Option §6SetConfig/Option/Premat"); //todo
}
}
try {
yamlConfiguration.save(config);
} catch (IOException tac) {
tac.printStackTrace();
}
if (slot.PluginReloadEnable) {
Bukkit.getServer().dispatchCommand(Bukkit.getServer().getConsoleSender(), slot.PluginReloadCommand);
}
new BukkitRunnable() {
@Override
public void run() {
player.closeInventory();
}
}.runTaskLater(plugin, 1L);
}
if (SelectConfig.Sound_Enable && SelectConfig.Sound_Click_Enable) {
if (slot.CustomSound_Enable) {
if (!slot.CustomSound_NoSound) {
try {
player.playSound(player.getLocation(), Sound.valueOf(slot.CustomSound_Sound.toUpperCase().replace(".", "_")), 3, 1);
} catch (Exception e1) {
send.console("§4\n§4\n§4\n" + SelectMessages.SoundNotFound.replace("[prefix]", prefix)
.replace("[sound]", "§6GUI: §e" + Replace.replace(prefix, gui.GUI_Name) + "§r §6Slot: §e" + slot.Slot + " §6CustomSound: §9" + slot.CustomSound_Sound));
player.playSound(player.getLocation(), SelectConfig.Sound_Click, 3, 1);
}
}
} else
player.playSound(player.getLocation(), SelectConfig.Sound_Click, 3, 1);
}
}
}
}
}
} else {
player.sendMessage(SelectMessages.NoPermissionForItem.replace("[item]", Replace.replace(prefix, slot.Name))
.replace("[perm]", "commandgui.gui." + gui.Command_Command + ".slot." + (slot.Slot + 1)));
}
}
}
}
}
}
} }
} }

View File

@@ -23,7 +23,6 @@ public class ItemChange {
slot = Select_Database.selectSlot(player); slot = Select_Database.selectSlot(player);
} }
} }
if (!SelectConfig.UseItem_Enable) { if (!SelectConfig.UseItem_Enable) {
return; return;
} }
@@ -101,7 +100,6 @@ public class ItemChange {
} }
} }
}.runTaskLater(Main.plugin, 1L * 1); }.runTaskLater(Main.plugin, 1L * 1);
} }
private static void setCursor(Player player, int slot) { private static void setCursor(Player player, int slot) {
@@ -153,6 +151,5 @@ public class ItemChange {
} }
} }
} }
} }
} }

View File

@@ -23,10 +23,9 @@ public class PluginEvent implements Listener {
public void onJoinEvent(PlayerLoginEvent event) { public void onJoinEvent(PlayerLoginEvent event) {
Player player = event.getPlayer(); Player player = event.getPlayer();
Select_Database.nameCheck(player); Select_Database.nameCheck(player);
UpdateAPI.join(Main.plugin,prefix, "commandgui.updatemsg", event.getPlayer(), Util.getSpigot(), Util.getDiscord()); UpdateAPI.join(Main.plugin, prefix, "commandgui.updatemsg", event.getPlayer(), Util.getSpigot(), Util.getDiscord());
} }
@EventHandler @EventHandler
public void onClearServer(ServerCommandEvent event) { public void onClearServer(ServerCommandEvent event) {
if (SelectConfig.UseItem_KeepAtCommandClear) { if (SelectConfig.UseItem_KeepAtCommandClear) {
@@ -36,11 +35,11 @@ public class PluginEvent implements Listener {
public void run() { public void run() {
try { try {
Player player = Bukkit.getPlayer(event.getCommand().replace("/", "").replace("clear ", "")); Player player = Bukkit.getPlayer(event.getCommand().replace("/", "").replace("clear ", ""));
if (player == null){ if (player == null) {
return; return;
} }
clearGive(player); clearGive(player);
} catch (Exception ex){ } catch (Exception ex) {
ex.printStackTrace(); ex.printStackTrace();
return; return;
} }
@@ -50,7 +49,6 @@ public class PluginEvent implements Listener {
} }
} }
@EventHandler @EventHandler
public void onClearPlayer(PlayerCommandPreprocessEvent event) { public void onClearPlayer(PlayerCommandPreprocessEvent event) {
if (SelectConfig.UseItem_KeepAtCommandClear) { if (SelectConfig.UseItem_KeepAtCommandClear) {

View File

@@ -80,25 +80,6 @@ public class Events implements Listener {
Player player = e.getPlayer(); Player player = e.getPlayer();
if (SelectConfig.UseItem_Enable) { if (SelectConfig.UseItem_Enable) {
ItemChange.itemChange(player, false); ItemChange.itemChange(player, false);
//if (!SelectConfig.UseItem_AllowToggle || Select_Database.selectItemStatus(player)) {
// if (SelectConfig.UseItem_GiveOnlyOnFirstJoin) {
// if (!player.hasPlayedBefore()) {
// new BukkitRunnable() {
// @Override
// public void run() {
// Give_UseItem.onGive(player);
// }
// }.runTaskLater(Main.plugin, 20L * 1);
// }
// } else {
// new BukkitRunnable() {
// @Override
// public void run() {
// Give_UseItem.onGive(player);
// }
// }.runTaskLater(Main.plugin, 20L * 1);
// }
//}
} }
} }
@@ -130,7 +111,6 @@ public class Events implements Listener {
}.runTaskLater(Main.plugin, SelectConfig.UseItemWorldChangeDelayInTicks * 1L); }.runTaskLater(Main.plugin, SelectConfig.UseItemWorldChangeDelayInTicks * 1L);
} }
@EventHandler(priority = EventPriority.HIGHEST) @EventHandler(priority = EventPriority.HIGHEST)
public void onInteract(PlayerInteractEvent e) { public void onInteract(PlayerInteractEvent e) {
Player p = e.getPlayer(); Player p = e.getPlayer();
@@ -206,7 +186,6 @@ public class Events implements Listener {
} }
} }
@EventHandler(priority = EventPriority.HIGHEST) @EventHandler(priority = EventPriority.HIGHEST)
public void onItemMove(InventoryDragEvent e) { public void onItemMove(InventoryDragEvent e) {
if (!SelectConfig.UseItem_BlockMoveAndDrop || !SelectConfig.UseItem_Enable) return; if (!SelectConfig.UseItem_BlockMoveAndDrop || !SelectConfig.UseItem_Enable) return;

View File

@@ -69,7 +69,8 @@ public final class Main extends JavaPlugin {
if (PluginCheck.plotSquaredGUI()) { if (PluginCheck.plotSquaredGUI()) {
PlotSquaredGUI = true; PlotSquaredGUI = true;
addonEnable(Bukkit.getPluginManager().getPlugin("PlotSquaredGUI")); addonEnable(Bukkit.getPluginManager().getPlugin("PlotSquaredGUI"));
}if (PluginCheck.luckyBox()) { }
if (PluginCheck.luckyBox()) {
LuckyBox = true; LuckyBox = true;
addonEnable(Bukkit.getPluginManager().getPlugin("T2C-LuckyBox")); addonEnable(Bukkit.getPluginManager().getPlugin("T2C-LuckyBox"));
} }

View File

@@ -93,7 +93,6 @@ public class Obj_Select {
yamlConfiguration_gui.getBoolean("Slots." + key + ".SetConfig.PluginReload.Enable"), yamlConfiguration_gui.getBoolean("Slots." + key + ".SetConfig.PluginReload.Enable"),
yamlConfiguration_gui.getString("Slots." + key + ".SetConfig.PluginReload.Command")); yamlConfiguration_gui.getString("Slots." + key + ".SetConfig.PluginReload.Command"));
slots.add(slot); slots.add(slot);
} }
Object objekt = new Object(GUI_Enable, GUI_Lines, GUI_Name, GUI_FillItem_Enable, GUI_FillItem_Item, Object objekt = new Object(GUI_Enable, GUI_Lines, GUI_Name, GUI_FillItem_Enable, GUI_FillItem_Item,
config_gui.getName().replace(".yml", ""), Command_Alias_Enable, Command_Permission, slots); config_gui.getName().replace(".yml", ""), Command_Alias_Enable, Command_Permission, slots);
@@ -107,7 +106,6 @@ public class Obj_Select {
e.printStackTrace(); e.printStackTrace();
} }
} }
} }
} }
} }

View File

@@ -7,6 +7,7 @@ import net.t2code.lib.Spigot.Lib.messages.send;
import net.t2code.lib.Spigot.Lib.minecraftVersion.NMSVersion; import net.t2code.lib.Spigot.Lib.minecraftVersion.NMSVersion;
import org.bukkit.Bukkit; import org.bukkit.Bukkit;
import org.bukkit.plugin.Plugin; import org.bukkit.plugin.Plugin;
import org.eclipse.sisu.space.ClassFinder;
import java.io.File; import java.io.File;
@@ -110,6 +111,11 @@ public class AliasRegister {
org.bukkit.craftbukkit.v1_18_R1.CraftServer craftServer = (org.bukkit.craftbukkit.v1_18_R1.CraftServer) plugin.getServer(); org.bukkit.craftbukkit.v1_18_R1.CraftServer craftServer = (org.bukkit.craftbukkit.v1_18_R1.CraftServer) plugin.getServer();
craftServer.getCommandMap().register(alias, new RegisterCommand(alias)); craftServer.getCommandMap().register(alias, new RegisterCommand(alias));
} }
if (NMSVersion.v1_18_R2) {
send.debug(plugin, "Alias register 1.18_R2");
org.bukkit.craftbukkit.v1_18_R2.CraftServer craftServer = (org.bukkit.craftbukkit.v1_18_R2.CraftServer) plugin.getServer();
craftServer.getCommandMap().register(alias, new RegisterCommand(alias));
}
} }
} }
} }

View File

@@ -90,6 +90,10 @@ public class OpenGUI {
} }
} }
for (Slot slot : gui.GUI_Slots) { for (Slot slot : gui.GUI_Slots) {
if (!slot.Perm
|| player.hasPermission("commandgui.gui." + gui.Command_Command + ".slot." + (slot.Slot + 1))
|| player.hasPermission("commandgui.gui." + gui.Command_Command + ".slot." + (slot.Slot + 1)+".see")
|| player.hasPermission("commandgui.admin")) {
if (slot.Enable) { if (slot.Enable) {
if (slot.Empty) { if (slot.Empty) {
ItemStack air = new ItemStack(Material.AIR); ItemStack air = new ItemStack(Material.AIR);
@@ -186,7 +190,7 @@ public class OpenGUI {
} }
} }
} }
}
player.openInventory(inventory); player.openInventory(inventory);
send.debug(plugin, "§6" + player.getName() + " §5Open §6" + Replace.replace(prefix, gui.GUI_Name) + " §5" + " §7- §e" + (System.currentTimeMillis() - long_.longValue()) + "ms"); send.debug(plugin, "§6" + player.getName() + " §5Open §6" + Replace.replace(prefix, gui.GUI_Name) + " §5" + " §7- §e" + (System.currentTimeMillis() - long_.longValue()) + "ms");
} else player.sendMessage(SelectMessages.GUIIsDisabled.replace("[gui]", Replace.replace(prefix, gui.GUI_Name))); } else player.sendMessage(SelectMessages.GUIIsDisabled.replace("[gui]", Replace.replace(prefix, gui.GUI_Name)));

View File

@@ -2,6 +2,8 @@ package de.jatitv.commandguiv2.Spigot.system;
import de.jatitv.commandguiv2.Spigot.Main; import de.jatitv.commandguiv2.Spigot.Main;
import net.t2code.lib.Spigot.Lib.messages.send; import net.t2code.lib.Spigot.Lib.messages.send;
import org.bukkit.Bukkit;
import org.bukkit.command.CommandSender;
import org.bukkit.entity.Player; import org.bukkit.entity.Player;
import org.bukkit.plugin.messaging.PluginMessageListener; import org.bukkit.plugin.messaging.PluginMessageListener;
@@ -9,16 +11,32 @@ import java.io.*;
public class Bungee_Sender_Reciver implements PluginMessageListener { public class Bungee_Sender_Reciver implements PluginMessageListener {
public static void sendToBungee(Player player,String channel, String information) { public static void sendToBungee(CommandSender sender, String information, Boolean console) {
ByteArrayOutputStream stream = new ByteArrayOutputStream(); ByteArrayOutputStream stream = new ByteArrayOutputStream();
DataOutputStream output = new DataOutputStream(stream); DataOutputStream output = new DataOutputStream(stream);
try { try {
output.writeUTF(channel); if (console) {
output.writeUTF("cgui-Console");
} else {
if (sender instanceof Player) {
output.writeUTF(sender.getName());
} else {
output.writeUTF("cgui-Console");
}
}
output.writeUTF(information); output.writeUTF(information);
} catch (IOException e) { } catch (IOException e) {
e.printStackTrace(); e.printStackTrace();
} }
if (sender instanceof Player) {
Player player = (Player) sender;
player.sendPluginMessage(Main.plugin, "cgui:bungee", stream.toByteArray()); player.sendPluginMessage(Main.plugin, "cgui:bungee", stream.toByteArray());
}else {
for(Player player : Bukkit.getOnlinePlayers()){
player.sendPluginMessage(Main.plugin, "cgui:bungee", stream.toByteArray());
return;
}
}
} }
@Override @Override