mirror of
https://github.com/DieReicheErethons/Brewery.git
synced 2024-06-28 10:44:48 +02:00
Fixed some warnings
This commit is contained in:
parent
72d13b30dd
commit
9bb5936d0d
|
@ -249,7 +249,7 @@ public class BIngredients {
|
||||||
badStuff++;
|
badStuff++;
|
||||||
if (badStuff < ingredients.size()) {
|
if (badStuff < ingredients.size()) {
|
||||||
// when there are other ingredients
|
// when there are other ingredients
|
||||||
quality -= count * (recipe.getDifficulty() / 2);
|
quality -= count * (recipe.getDifficulty() / 2.0);
|
||||||
continue;
|
continue;
|
||||||
} else {
|
} else {
|
||||||
// ingredients dont fit at all
|
// ingredients dont fit at all
|
||||||
|
@ -342,4 +342,4 @@ public class BIngredients {
|
||||||
return mats;
|
return mats;
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -207,9 +207,7 @@ public class BPlayer {
|
||||||
}
|
}
|
||||||
quality = getQuality();
|
quality = getQuality();
|
||||||
if (drunkeness <= -offlineDrunk) {
|
if (drunkeness <= -offlineDrunk) {
|
||||||
if (drunkeness <= -hangoverTime) {
|
return drunkeness <= -hangoverTime;
|
||||||
return true;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return false;
|
return false;
|
||||||
|
@ -226,6 +224,8 @@ public class BPlayer {
|
||||||
// Is he moving
|
// Is he moving
|
||||||
if (event.getFrom().getX() != event.getTo().getX() || event.getFrom().getZ() != event.getTo().getZ()) {
|
if (event.getFrom().getX() != event.getTo().getX() || event.getFrom().getZ() != event.getTo().getZ()) {
|
||||||
Player player = event.getPlayer();
|
Player player = event.getPlayer();
|
||||||
|
// We have to cast here because it had issues otherwise on previous versions of Minecraft
|
||||||
|
// Dont know if thats still the case, but we better leave it
|
||||||
Entity entity = (Entity) player;
|
Entity entity = (Entity) player;
|
||||||
// not in midair
|
// not in midair
|
||||||
if (entity.isOnGround()) {
|
if (entity.isOnGround()) {
|
||||||
|
@ -605,7 +605,7 @@ public class BPlayer {
|
||||||
if (drunkeness < 0) {
|
if (drunkeness < 0) {
|
||||||
return quality;
|
return quality;
|
||||||
}
|
}
|
||||||
return Math.round(quality / drunkeness);
|
return Math.round((float) quality / (float) drunkeness);
|
||||||
}
|
}
|
||||||
|
|
||||||
// opposite of quality
|
// opposite of quality
|
||||||
|
|
|
@ -448,7 +448,7 @@ public class Barrel implements InventoryHolder {
|
||||||
ItemStack[] items = inventory.getContents();
|
ItemStack[] items = inventory.getContents();
|
||||||
if (P.p.useLB && breaker != null) {
|
if (P.p.useLB && breaker != null) {
|
||||||
try {
|
try {
|
||||||
LogBlockBarrel.breakBarrel(breaker.getName(), items, spigot.getLocation());
|
LogBlockBarrel.breakBarrel(breaker, items, spigot.getLocation());
|
||||||
} catch (Throwable e) {
|
} catch (Throwable e) {
|
||||||
P.p.errorLog("Failed to Log Barrel-break to LogBlock!");
|
P.p.errorLog("Failed to Log Barrel-break to LogBlock!");
|
||||||
P.p.errorLog("Brewery was tested with version 1.94 of LogBlock!");
|
P.p.errorLog("Brewery was tested with version 1.94 of LogBlock!");
|
||||||
|
|
|
@ -247,10 +247,9 @@ public class Brew {
|
||||||
if (stat) return false;
|
if (stat) return false;
|
||||||
if (currentRecipe != null) {
|
if (currentRecipe != null) {
|
||||||
return currentRecipe.getDistillRuns() > distillRuns;
|
return currentRecipe.getDistillRuns() > distillRuns;
|
||||||
} else if (distillRuns >= 6) {
|
} else {
|
||||||
return false;
|
return distillRuns < 6;
|
||||||
}
|
}
|
||||||
return true;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// return special effect
|
// return special effect
|
||||||
|
|
|
@ -74,10 +74,10 @@ public class P extends JavaPlugin {
|
||||||
|
|
||||||
// Version check
|
// Version check
|
||||||
String v = Bukkit.getBukkitVersion();
|
String v = Bukkit.getBukkitVersion();
|
||||||
useUUID = !v.matches("(^|.*[^\\.\\d])1\\.[0-6]([^\\d].*|$)") && !v.matches("(^|.*[^\\.\\d])1\\.7\\.[0-5]([^\\d].*|$)");
|
useUUID = !v.matches("(^|.*[^.\\d])1\\.[0-6]([^\\d].*|$)") && !v.matches("(^|.*[^.\\d])1\\.7\\.[0-5]([^\\d].*|$)");
|
||||||
use1_9 = !v.matches("(^|.*[^\\.\\d])1\\.[0-8]([^\\d].*|$)");
|
use1_9 = !v.matches("(^|.*[^.\\d])1\\.[0-8]([^\\d].*|$)");
|
||||||
use1_12 = !v.matches("(^|.*[^\\.\\d])1\\.1[0-1]([^\\d].*|$)") && !v.matches("(^|.*[^\\.\\d])1\\.[0-9]([^\\d].*|$)");
|
use1_12 = !v.matches("(^|.*[^.\\d])1\\.1[0-1]([^\\d].*|$)") && !v.matches("(^|.*[^.\\d])1\\.[0-9]([^\\d].*|$)");
|
||||||
use1_13 = !v.matches("(^|.*[^\\.\\d])1\\.1[0-2]([^\\d].*|$)") && !v.matches("(^|.*[^\\.\\d])1\\.[0-9]([^\\d].*|$)");
|
use1_13 = !v.matches("(^|.*[^.\\d])1\\.1[0-2]([^\\d].*|$)") && !v.matches("(^|.*[^.\\d])1\\.[0-9]([^\\d].*|$)");
|
||||||
|
|
||||||
// load the Config
|
// load the Config
|
||||||
try {
|
try {
|
||||||
|
|
|
@ -210,7 +210,7 @@ public class Words {
|
||||||
// All occurences of "from" need to be replaced
|
// All occurences of "from" need to be replaced
|
||||||
return words.replaceAll(from, to);
|
return words.replaceAll(from, to);
|
||||||
}
|
}
|
||||||
String newWords = "";
|
StringBuilder newWords = new StringBuilder();
|
||||||
if (words.endsWith(from)) {
|
if (words.endsWith(from)) {
|
||||||
// add space to end to recognize last occurence of "from"
|
// add space to end to recognize last occurence of "from"
|
||||||
words = words + " ";
|
words = words + " ";
|
||||||
|
@ -226,15 +226,15 @@ public class Words {
|
||||||
while (index < splitted.length - 1) {
|
while (index < splitted.length - 1) {
|
||||||
part = splitted[index];
|
part = splitted[index];
|
||||||
// add current part of "words" to the output
|
// add current part of "words" to the output
|
||||||
newWords = newWords + part;
|
newWords.append(part);
|
||||||
// check if the part ends with correct string
|
// check if the part ends with correct string
|
||||||
|
|
||||||
if (doesPreMatch(part) && Math.random() * 100.0 <= percentage) {
|
if (doesPreMatch(part) && Math.random() * 100.0 <= percentage) {
|
||||||
// add replacement
|
// add replacement
|
||||||
newWords = newWords + to;
|
newWords.append(to);
|
||||||
} else {
|
} else {
|
||||||
// add original
|
// add original
|
||||||
newWords = newWords + from;
|
newWords.append(from);
|
||||||
}
|
}
|
||||||
index++;
|
index++;
|
||||||
}
|
}
|
||||||
|
@ -242,9 +242,9 @@ public class Words {
|
||||||
part = splitted[index];
|
part = splitted[index];
|
||||||
if (part.equals(" ")) {
|
if (part.equals(" ")) {
|
||||||
// dont add the space to the end
|
// dont add the space to the end
|
||||||
return newWords;
|
return newWords.toString();
|
||||||
} else {
|
} else {
|
||||||
return newWords + part;
|
return newWords.append(part).toString();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
} catch (java.util.regex.PatternSyntaxException e) {
|
} catch (java.util.regex.PatternSyntaxException e) {
|
||||||
|
@ -271,4 +271,4 @@ public class Words {
|
||||||
return isBefore;
|
return isBefore;
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -9,6 +9,7 @@ import java.util.List;
|
||||||
|
|
||||||
import org.bukkit.Location;
|
import org.bukkit.Location;
|
||||||
import org.bukkit.entity.HumanEntity;
|
import org.bukkit.entity.HumanEntity;
|
||||||
|
import org.bukkit.entity.Player;
|
||||||
import org.bukkit.inventory.Inventory;
|
import org.bukkit.inventory.Inventory;
|
||||||
import org.bukkit.inventory.ItemStack;
|
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.InvocationTargetException;
|
||||||
import java.lang.reflect.Method;
|
import java.lang.reflect.Method;
|
||||||
|
|
||||||
|
@SuppressWarnings("JavaReflectionMemberAccess")
|
||||||
public class LogBlockBarrel {
|
public class LogBlockBarrel {
|
||||||
private static final List<LogBlockBarrel> opened = new ArrayList<>();
|
private static final List<LogBlockBarrel> opened = new ArrayList<>();
|
||||||
public static Consumer consumer = LogBlock.getInstance().getConsumer();
|
public static Consumer consumer = LogBlock.getInstance().getConsumer();
|
||||||
|
@ -61,7 +63,8 @@ public class LogBlockBarrel {
|
||||||
for (final ItemStack item : diff) {
|
for (final ItemStack item : diff) {
|
||||||
if (!P.use1_13) {
|
if (!P.use1_13) {
|
||||||
try {
|
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) {
|
} catch(IllegalAccessException | IllegalArgumentException | InvocationTargetException e) {
|
||||||
e.printStackTrace();
|
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) {
|
if (consumer == null) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
@ -103,12 +106,13 @@ public class LogBlockBarrel {
|
||||||
for (final ItemStack item : items) {
|
for (final ItemStack item : items) {
|
||||||
if (!P.use1_13) {
|
if (!P.use1_13) {
|
||||||
try {
|
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) {
|
} catch(IllegalAccessException | IllegalArgumentException | InvocationTargetException e) {
|
||||||
e.printStackTrace();
|
e.printStackTrace();
|
||||||
}
|
}
|
||||||
} else {
|
} 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.dre.brewery.P;
|
||||||
import com.sk89q.worldedit.bukkit.WorldEditPlugin;
|
import com.sk89q.worldedit.bukkit.WorldEditPlugin;
|
||||||
import com.sk89q.worldedit.extension.platform.Actor;
|
|
||||||
import com.sk89q.worldedit.util.Location;
|
import com.sk89q.worldedit.util.Location;
|
||||||
import com.sk89q.worldedit.world.World;
|
import com.sk89q.worldedit.world.World;
|
||||||
import com.sk89q.worldguard.WorldGuard;
|
import com.sk89q.worldguard.WorldGuard;
|
||||||
|
@ -27,7 +26,7 @@ public class WGBarrel7 implements WGBarrel {
|
||||||
World world = platform.getWorldByName(spigot.getWorld().getName());
|
World world = platform.getWorldByName(spigot.getWorld().getName());
|
||||||
if (!platform.getGlobalStateManager().get(world).useRegions) return true; // Region support disabled
|
if (!platform.getGlobalStateManager().get(world).useRegions) return true; // Region support disabled
|
||||||
WorldEditPlugin we = JavaPlugin.getPlugin(WorldEditPlugin.class);
|
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();
|
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) {
|
public boolean checkAccess(Player player, Block spigot, Plugin plugin) {
|
||||||
WorldGuardPlugin wg = (WorldGuardPlugin) plugin;
|
WorldGuardPlugin wg = (WorldGuardPlugin) plugin;
|
||||||
if (!wg.getGlobalRegionManager().hasBypass(player, player.getWorld())) {
|
if (!wg.getGlobalRegionManager().hasBypass(player, player.getWorld())) {
|
||||||
|
@ -49,10 +50,7 @@ public class WGBarrelOld implements WGBarrel {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
} catch (IllegalAccessException e) {
|
} catch (IllegalAccessException | InvocationTargetException e) {
|
||||||
e.printStackTrace();
|
|
||||||
return false;
|
|
||||||
} catch (InvocationTargetException e) {
|
|
||||||
e.printStackTrace();
|
e.printStackTrace();
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
|
@ -20,6 +20,7 @@ public class CommandListener implements CommandExecutor {
|
||||||
|
|
||||||
public P p = P.p;
|
public P p = P.p;
|
||||||
|
|
||||||
|
// TODO add command complete
|
||||||
@Override
|
@Override
|
||||||
public boolean onCommand(CommandSender sender, Command command, String label, String[] args) {
|
public boolean onCommand(CommandSender sender, Command command, String label, String[] args) {
|
||||||
|
|
||||||
|
@ -575,4 +576,4 @@ public class CommandListener implements CommandExecutor {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue
Block a user