Fixed some warnings

This commit is contained in:
Sn0wStorm
2018-10-30 15:59:56 +01:00
parent 72d13b30dd
commit 9bb5936d0d
10 changed files with 33 additions and 32 deletions
@@ -9,6 +9,7 @@ import java.util.List;
import org.bukkit.Location;
import org.bukkit.entity.HumanEntity;
import org.bukkit.entity.Player;
import org.bukkit.inventory.Inventory;
import org.bukkit.inventory.ItemStack;
@@ -22,6 +23,7 @@ import static de.diddiz.util.BukkitUtils.compressInventory;
import java.lang.reflect.InvocationTargetException;
import java.lang.reflect.Method;
@SuppressWarnings("JavaReflectionMemberAccess")
public class LogBlockBarrel {
private static final List<LogBlockBarrel> opened = new ArrayList<>();
public static Consumer consumer = LogBlock.getInstance().getConsumer();
@@ -61,7 +63,8 @@ public class LogBlockBarrel {
for (final ItemStack item : diff) {
if (!P.use1_13) {
try {
queueChestAccess.invoke(consumer, player.getName(), loc, LegacyUtil.getBlockTypeIdAt(loc), (short) item.getType().getId(), (short) item.getAmount(), (short) rawData.invoke(null, item));
//noinspection deprecation
queueChestAccess.invoke(consumer, player.getName(), loc, LegacyUtil.getBlockTypeIdAt(loc), (short) item.getType().getId(), (short) item.getAmount(), rawData.invoke(null, item));
} catch(IllegalAccessException | IllegalArgumentException | InvocationTargetException e) {
e.printStackTrace();
}
@@ -94,7 +97,7 @@ public class LogBlockBarrel {
}
}
public static void breakBarrel(String playerName, ItemStack[] contents, Location spigotLoc) {
public static void breakBarrel(Player player, ItemStack[] contents, Location spigotLoc) {
if (consumer == null) {
return;
}
@@ -103,12 +106,13 @@ public class LogBlockBarrel {
for (final ItemStack item : items) {
if (!P.use1_13) {
try {
queueChestAccess.invoke(consumer, playerName, spigotLoc, LegacyUtil.getBlockTypeIdAt(spigotLoc), (short) item.getType().getId(), (short) (item.getAmount() * -1), rawData.invoke(null, item));
//noinspection deprecation
queueChestAccess.invoke(consumer, player.getName(), spigotLoc, LegacyUtil.getBlockTypeIdAt(spigotLoc), (short) item.getType().getId(), (short) (item.getAmount() * -1), rawData.invoke(null, item));
} catch(IllegalAccessException | IllegalArgumentException | InvocationTargetException e) {
e.printStackTrace();
}
} else {
consumer.queueChestAccess(Actor.actorFromString(playerName), spigotLoc, spigotLoc.getBlock().getBlockData(), item, false);
consumer.queueChestAccess(Actor.actorFromEntity(player), spigotLoc, spigotLoc.getBlock().getBlockData(), item, false);
}
}
}
@@ -8,7 +8,6 @@ import org.bukkit.plugin.java.JavaPlugin;
import com.dre.brewery.P;
import com.sk89q.worldedit.bukkit.WorldEditPlugin;
import com.sk89q.worldedit.extension.platform.Actor;
import com.sk89q.worldedit.util.Location;
import com.sk89q.worldedit.world.World;
import com.sk89q.worldguard.WorldGuard;
@@ -27,7 +26,7 @@ public class WGBarrel7 implements WGBarrel {
World world = platform.getWorldByName(spigot.getWorld().getName());
if (!platform.getGlobalStateManager().get(world).useRegions) return true; // Region support disabled
WorldEditPlugin we = JavaPlugin.getPlugin(WorldEditPlugin.class);
if (new RegionPermissionModel((Actor) we.wrapPlayer(player)).mayIgnoreRegionProtection(world)) return true; // Whitelisted cause
if (new RegionPermissionModel(we.wrapPlayer(player)).mayIgnoreRegionProtection(world)) return true; // Whitelisted cause
RegionQuery query = platform.getRegionContainer().createQuery();
@@ -32,6 +32,7 @@ public class WGBarrelOld implements WGBarrel {
}
}
@SuppressWarnings("deprecation")
public boolean checkAccess(Player player, Block spigot, Plugin plugin) {
WorldGuardPlugin wg = (WorldGuardPlugin) plugin;
if (!wg.getGlobalRegionManager().hasBypass(player, player.getWorld())) {
@@ -49,10 +50,7 @@ public class WGBarrelOld implements WGBarrel {
}
}
} catch (IllegalAccessException e) {
e.printStackTrace();
return false;
} catch (InvocationTargetException e) {
} catch (IllegalAccessException | InvocationTargetException e) {
e.printStackTrace();
return false;
}