Workaround for buggy items

This commit is contained in:
mathiascode 2020-08-02 14:38:15 +03:00
parent 2738bc3647
commit 99c92fae5c
2 changed files with 7 additions and 6 deletions

View File

@ -5,8 +5,8 @@
<version>master</version>
<properties>
<maven.compiler.source>1.5</maven.compiler.source>
<maven.compiler.target>1.5</maven.compiler.target>
<maven.compiler.source>1.6</maven.compiler.source>
<maven.compiler.target>1.6</maven.compiler.target>
<maven.test.skip>true</maven.test.skip>
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
</properties>

View File

@ -20,17 +20,18 @@ import pw.kaboom.weapons.modules.weapons.WeaponSniper;
public final class PlayerUseWeapon implements Listener {
@EventHandler
void onPlayerInteract(final PlayerInteractEvent event) {
if (event.hasItem()
&& event.getItem().getItemMeta().hasDisplayName()) {
final Action action = event.getAction();
final Material item = event.getMaterial();
if (event.hasItem()) {
String name = "";
try {
name = event.getItem().getItemMeta().getDisplayName();
} catch (Exception ignored) {
return;
}
final Action action = event.getAction();
final Material item = event.getMaterial();
if (action == Action.LEFT_CLICK_AIR
|| action == Action.LEFT_CLICK_BLOCK) {
WeaponAnvilDropper.leftClick(item, name, event);