Merge branch 'master' into development

This commit is contained in:
Christian Koop 2023-08-25 14:57:19 +02:00
commit 936c63fa45
No known key found for this signature in database
GPG Key ID: 89A8181384E010A3
3 changed files with 39 additions and 36 deletions

View File

@ -3,7 +3,7 @@
<img src="https://craftaro.com/images/products/493/icons/2hG0tPkGtUknkEKG7X13mwesVyeie8k3g3xpoU9v.png" width="128px"> <img src="https://craftaro.com/images/products/493/icons/2hG0tPkGtUknkEKG7X13mwesVyeie8k3g3xpoU9v.png" width="128px">
# UltimateKits # UltimateKits
**Creating and displaying your servers kits has never been easier.** **Creating and displaying your server&#39;s kits has never been easier.**
**Use a GUI to drag kit items in then players can browse through them and even use crate keys on them.** **Use a GUI to drag kit items in then players can browse through them and even use crate keys on them.**

View File

@ -10,6 +10,7 @@ import com.craftaro.ultimatekits.gui.BlockEditorGui;
import com.craftaro.ultimatekits.kit.Kit; import com.craftaro.ultimatekits.kit.Kit;
import com.craftaro.ultimatekits.kit.KitBlockData; import com.craftaro.ultimatekits.kit.KitBlockData;
import com.craftaro.ultimatekits.kit.KitType; import com.craftaro.ultimatekits.kit.KitType;
import com.craftaro.ultimatekits.settings.Settings;
import org.bukkit.ChatColor; import org.bukkit.ChatColor;
import org.bukkit.Material; import org.bukkit.Material;
import org.bukkit.block.Block; import org.bukkit.block.Block;
@ -19,11 +20,9 @@ import org.bukkit.event.Listener;
import org.bukkit.event.block.Action; import org.bukkit.event.block.Action;
import org.bukkit.event.player.PlayerInteractEvent; import org.bukkit.event.player.PlayerInteractEvent;
import org.bukkit.inventory.EquipmentSlot; import org.bukkit.inventory.EquipmentSlot;
import org.bukkit.inventory.InventoryHolder;
import org.bukkit.inventory.ItemStack; import org.bukkit.inventory.ItemStack;
public class InteractListeners implements Listener { public class InteractListeners implements Listener {
private final UltimateKits plugin; private final UltimateKits plugin;
private final GuiManager guiManager; private final GuiManager guiManager;
@ -53,55 +52,58 @@ public class InteractListeners implements Listener {
Kit kit = kitBlockData.getKit(); Kit kit = kitBlockData.getKit();
Player player = event.getPlayer(); Player player = event.getPlayer();
if (event.getAction() == Action.LEFT_CLICK_BLOCK) {
Material itemInHand = player.getItemInHand().getType();
Material keyMaterial = Settings.KEY_MATERIAL.getMaterial().parseMaterial();
if (event.getAction() == Action.LEFT_CLICK_BLOCK) {
if (player.isSneaking()) { if (player.isSneaking()) {
return; return;
} }
event.setCancelled(true); event.setCancelled(true);
if (player.getItemInHand().getType() == Material.TRIPWIRE_HOOK) { if (kitBlockData.getType() == KitType.PREVIEW) {
event.setCancelled(true); kit.display(player, this.guiManager, null);
kit.processKeyUse(player);
return;
}
if (kitBlockData.getType() != KitType.PREVIEW) { } else if (kitBlockData.getType() == KitType.CRATE) {
if (itemInHand == keyMaterial) {
kit.processKeyUse(player);
} else {
this.plugin.getLocale().getMessage("event.crate.needkey").sendPrefixedMessage(player);
return;
}
} else if (kitBlockData.getType() == KitType.CLAIM) {
if (!kit.hasPermissionToClaim(player)) { if (!kit.hasPermissionToClaim(player)) {
this.plugin.getLocale().getMessage("command.general.noperms").sendPrefixedMessage(player); this.plugin.getLocale().getMessage("command.general.noperms").sendPrefixedMessage(player);
return; return;
} }
if (kit.getNextUse(player) <= 0) {
kit.processGenericUse(player, false); if (kit.getNextUse(player) > 0) {
kit.updateDelay(player);
} else {
long time = kit.getNextUse(player); long time = kit.getNextUse(player);
this.plugin this.plugin.getLocale().getMessage("event.crate.notyet").processPlaceholder("time", TimeUtils.makeReadable(time)).sendPrefixedMessage(player);
.getLocale() return;
.getMessage("event.crate.notyet")
.processPlaceholder("time", TimeUtils.makeReadable(time))
.sendPrefixedMessage(player);
} }
} else if (kit.getLink() != null || kit.getPrice() != 0) {
kit.buy(player, this.guiManager); if (kit.getLink() != null || kit.getPrice() != 0) {
} else { kit.buy(player, this.guiManager);
kit.display(player, this.guiManager, null); } else {
} kit.processGenericUse(player, false);
} else if (event.getAction() == Action.RIGHT_CLICK_BLOCK) { }
if (block.getState() instanceof InventoryHolder || block.getType() == Material.ENDER_CHEST) {
event.setCancelled(true); kit.updateDelay(player);
} }
}
if (event.getAction() == Action.RIGHT_CLICK_BLOCK) {
event.setCancelled(true);
if (player.isSneaking() && player.hasPermission("ultimatekits.admin")) { if (player.isSneaking() && player.hasPermission("ultimatekits.admin")) {
this.guiManager.showGUI(player, new BlockEditorGui(this.plugin, kitBlockData)); this.guiManager.showGUI(player, new BlockEditorGui(this.plugin, kitBlockData));
return; return;
} }
if (player.getItemInHand().getType() == Material.TRIPWIRE_HOOK) {
event.setCancelled(true);
kit.processKeyUse(player);
return;
}
kit.display(player, this.guiManager, null);
kit.display(player, this.guiManager, null);
} }
} }
@ -113,8 +115,8 @@ public class InteractListeners implements Listener {
// Filter physical actions (pressure plates, buttons) // Filter physical actions (pressure plates, buttons)
if (event.getAction() == Action.PHYSICAL if (event.getAction() == Action.PHYSICAL
|| event.getItem() == null || event.getItem() == null
|| event.getItem().getType() == XMaterial.AIR.parseMaterial() || XMaterial.AIR.isSimilar(event.getItem())
|| XMaterial.matchXMaterial(event.getItem()) != XMaterial.CHEST) { || !XMaterial.CHEST.isSimilar(event.getItem())) {
return; return;
} }
@ -125,7 +127,7 @@ public class InteractListeners implements Listener {
return; return;
} }
Kit kit = UltimateKits.getInstance().getKitManager().getKit(ChatColor.stripColor(item.getItemMeta().getLore().get(0).split(" ")[0])); Kit kit = this.plugin.getKitManager().getKit(ChatColor.stripColor(item.getItemMeta().getLore().get(0).split(" ")[0]));
if (kit == null) { if (kit == null) {
return; return;

View File

@ -189,6 +189,7 @@ event:
wrongkey: '&cThis key doesn''t belong to this kit..' wrongkey: '&cThis key doesn''t belong to this kit..'
success: '&9Successfully opened a crate.' success: '&9Successfully opened a crate.'
given: '&9You have received a %crate% %kit% crate.' given: '&9You have received a %crate% %kit% crate.'
needkey: '&cYou need the right key to get this kit'
claim: claim:
cannotafford: '&9You cannot afford to buy kit &7%kit%&9.' cannotafford: '&9You cannot afford to buy kit &7%kit%&9.'
nottwice: '&9You can only receive this kit once.' nottwice: '&9You can only receive this kit once.'