mirror of
https://github.com/DieReicheErethons/Brewery.git
synced 2025-02-18 01:31:28 +01:00
Fixed some warnings
This commit is contained in:
parent
72d13b30dd
commit
9bb5936d0d
@ -249,7 +249,7 @@ public class BIngredients {
|
||||
badStuff++;
|
||||
if (badStuff < ingredients.size()) {
|
||||
// when there are other ingredients
|
||||
quality -= count * (recipe.getDifficulty() / 2);
|
||||
quality -= count * (recipe.getDifficulty() / 2.0);
|
||||
continue;
|
||||
} else {
|
||||
// ingredients dont fit at all
|
||||
@ -342,4 +342,4 @@ public class BIngredients {
|
||||
return mats;
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
|
@ -207,9 +207,7 @@ public class BPlayer {
|
||||
}
|
||||
quality = getQuality();
|
||||
if (drunkeness <= -offlineDrunk) {
|
||||
if (drunkeness <= -hangoverTime) {
|
||||
return true;
|
||||
}
|
||||
return drunkeness <= -hangoverTime;
|
||||
}
|
||||
}
|
||||
return false;
|
||||
@ -226,6 +224,8 @@ public class BPlayer {
|
||||
// Is he moving
|
||||
if (event.getFrom().getX() != event.getTo().getX() || event.getFrom().getZ() != event.getTo().getZ()) {
|
||||
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;
|
||||
// not in midair
|
||||
if (entity.isOnGround()) {
|
||||
@ -605,7 +605,7 @@ public class BPlayer {
|
||||
if (drunkeness < 0) {
|
||||
return quality;
|
||||
}
|
||||
return Math.round(quality / drunkeness);
|
||||
return Math.round((float) quality / (float) drunkeness);
|
||||
}
|
||||
|
||||
// opposite of quality
|
||||
|
@ -448,7 +448,7 @@ public class Barrel implements InventoryHolder {
|
||||
ItemStack[] items = inventory.getContents();
|
||||
if (P.p.useLB && breaker != null) {
|
||||
try {
|
||||
LogBlockBarrel.breakBarrel(breaker.getName(), items, spigot.getLocation());
|
||||
LogBlockBarrel.breakBarrel(breaker, items, spigot.getLocation());
|
||||
} catch (Throwable e) {
|
||||
P.p.errorLog("Failed to Log Barrel-break to 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 (currentRecipe != null) {
|
||||
return currentRecipe.getDistillRuns() > distillRuns;
|
||||
} else if (distillRuns >= 6) {
|
||||
return false;
|
||||
} else {
|
||||
return distillRuns < 6;
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
// return special effect
|
||||
|
@ -74,10 +74,10 @@ public class P extends JavaPlugin {
|
||||
|
||||
// Version check
|
||||
String v = Bukkit.getBukkitVersion();
|
||||
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_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].*|$)");
|
||||
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_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].*|$)");
|
||||
|
||||
// load the Config
|
||||
try {
|
||||
|
@ -210,7 +210,7 @@ public class Words {
|
||||
// All occurences of "from" need to be replaced
|
||||
return words.replaceAll(from, to);
|
||||
}
|
||||
String newWords = "";
|
||||
StringBuilder newWords = new StringBuilder();
|
||||
if (words.endsWith(from)) {
|
||||
// add space to end to recognize last occurence of "from"
|
||||
words = words + " ";
|
||||
@ -226,15 +226,15 @@ public class Words {
|
||||
while (index < splitted.length - 1) {
|
||||
part = splitted[index];
|
||||
// add current part of "words" to the output
|
||||
newWords = newWords + part;
|
||||
newWords.append(part);
|
||||
// check if the part ends with correct string
|
||||
|
||||
if (doesPreMatch(part) && Math.random() * 100.0 <= percentage) {
|
||||
// add replacement
|
||||
newWords = newWords + to;
|
||||
newWords.append(to);
|
||||
} else {
|
||||
// add original
|
||||
newWords = newWords + from;
|
||||
newWords.append(from);
|
||||
}
|
||||
index++;
|
||||
}
|
||||
@ -242,9 +242,9 @@ public class Words {
|
||||
part = splitted[index];
|
||||
if (part.equals(" ")) {
|
||||
// dont add the space to the end
|
||||
return newWords;
|
||||
return newWords.toString();
|
||||
} else {
|
||||
return newWords + part;
|
||||
return newWords.append(part).toString();
|
||||
}
|
||||
}
|
||||
} catch (java.util.regex.PatternSyntaxException e) {
|
||||
@ -271,4 +271,4 @@ public class Words {
|
||||
return isBefore;
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
|
@ -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;
|
||||
}
|
||||
|
@ -20,6 +20,7 @@ public class CommandListener implements CommandExecutor {
|
||||
|
||||
public P p = P.p;
|
||||
|
||||
// TODO add command complete
|
||||
@Override
|
||||
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