mirror of
https://github.com/songoda/UltimateKits.git
synced 2024-11-08 03:29:46 +01:00
Merge branch 'master' into development
This commit is contained in:
commit
936c63fa45
@ -3,7 +3,7 @@
|
||||
<img src="https://craftaro.com/images/products/493/icons/2hG0tPkGtUknkEKG7X13mwesVyeie8k3g3xpoU9v.png" width="128px">
|
||||
|
||||
# UltimateKits
|
||||
**Creating and displaying your servers kits has never been easier.**
|
||||
**Creating and displaying your server'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.**
|
||||
|
||||
|
||||
|
@ -10,6 +10,7 @@ import com.craftaro.ultimatekits.gui.BlockEditorGui;
|
||||
import com.craftaro.ultimatekits.kit.Kit;
|
||||
import com.craftaro.ultimatekits.kit.KitBlockData;
|
||||
import com.craftaro.ultimatekits.kit.KitType;
|
||||
import com.craftaro.ultimatekits.settings.Settings;
|
||||
import org.bukkit.ChatColor;
|
||||
import org.bukkit.Material;
|
||||
import org.bukkit.block.Block;
|
||||
@ -19,11 +20,9 @@ import org.bukkit.event.Listener;
|
||||
import org.bukkit.event.block.Action;
|
||||
import org.bukkit.event.player.PlayerInteractEvent;
|
||||
import org.bukkit.inventory.EquipmentSlot;
|
||||
import org.bukkit.inventory.InventoryHolder;
|
||||
import org.bukkit.inventory.ItemStack;
|
||||
|
||||
public class InteractListeners implements Listener {
|
||||
|
||||
private final UltimateKits plugin;
|
||||
private final GuiManager guiManager;
|
||||
|
||||
@ -53,55 +52,58 @@ public class InteractListeners implements Listener {
|
||||
Kit kit = kitBlockData.getKit();
|
||||
|
||||
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()) {
|
||||
return;
|
||||
}
|
||||
|
||||
event.setCancelled(true);
|
||||
|
||||
if (player.getItemInHand().getType() == Material.TRIPWIRE_HOOK) {
|
||||
event.setCancelled(true);
|
||||
kit.processKeyUse(player);
|
||||
return;
|
||||
}
|
||||
if (kitBlockData.getType() == KitType.PREVIEW) {
|
||||
kit.display(player, this.guiManager, null);
|
||||
|
||||
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)) {
|
||||
this.plugin.getLocale().getMessage("command.general.noperms").sendPrefixedMessage(player);
|
||||
return;
|
||||
}
|
||||
if (kit.getNextUse(player) <= 0) {
|
||||
kit.processGenericUse(player, false);
|
||||
kit.updateDelay(player);
|
||||
} else {
|
||||
|
||||
if (kit.getNextUse(player) > 0) {
|
||||
long time = kit.getNextUse(player);
|
||||
this.plugin
|
||||
.getLocale()
|
||||
.getMessage("event.crate.notyet")
|
||||
.processPlaceholder("time", TimeUtils.makeReadable(time))
|
||||
.sendPrefixedMessage(player);
|
||||
this.plugin.getLocale().getMessage("event.crate.notyet").processPlaceholder("time", TimeUtils.makeReadable(time)).sendPrefixedMessage(player);
|
||||
return;
|
||||
}
|
||||
} else if (kit.getLink() != null || kit.getPrice() != 0) {
|
||||
kit.buy(player, this.guiManager);
|
||||
} else {
|
||||
kit.display(player, this.guiManager, null);
|
||||
}
|
||||
} else if (event.getAction() == Action.RIGHT_CLICK_BLOCK) {
|
||||
if (block.getState() instanceof InventoryHolder || block.getType() == Material.ENDER_CHEST) {
|
||||
event.setCancelled(true);
|
||||
|
||||
if (kit.getLink() != null || kit.getPrice() != 0) {
|
||||
kit.buy(player, this.guiManager);
|
||||
} else {
|
||||
kit.processGenericUse(player, false);
|
||||
}
|
||||
|
||||
kit.updateDelay(player);
|
||||
}
|
||||
}
|
||||
|
||||
if (event.getAction() == Action.RIGHT_CLICK_BLOCK) {
|
||||
event.setCancelled(true);
|
||||
|
||||
if (player.isSneaking() && player.hasPermission("ultimatekits.admin")) {
|
||||
this.guiManager.showGUI(player, new BlockEditorGui(this.plugin, kitBlockData));
|
||||
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)
|
||||
if (event.getAction() == Action.PHYSICAL
|
||||
|| event.getItem() == null
|
||||
|| event.getItem().getType() == XMaterial.AIR.parseMaterial()
|
||||
|| XMaterial.matchXMaterial(event.getItem()) != XMaterial.CHEST) {
|
||||
|| XMaterial.AIR.isSimilar(event.getItem())
|
||||
|| !XMaterial.CHEST.isSimilar(event.getItem())) {
|
||||
return;
|
||||
}
|
||||
|
||||
@ -125,7 +127,7 @@ public class InteractListeners implements Listener {
|
||||
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) {
|
||||
return;
|
||||
|
@ -189,6 +189,7 @@ event:
|
||||
wrongkey: '&cThis key doesn''t belong to this kit..'
|
||||
success: '&9Successfully opened a crate.'
|
||||
given: '&9You have received a %crate% %kit% crate.'
|
||||
needkey: '&cYou need the right key to get this kit'
|
||||
claim:
|
||||
cannotafford: '&9You cannot afford to buy kit &7%kit%&9.'
|
||||
nottwice: '&9You can only receive this kit once.'
|
||||
|
Loading…
Reference in New Issue
Block a user