Bugfixes - fix some contract violations as well as comparisons that would always fail.
This commit is contained in:
parent
4bf75c8868
commit
c5c8f08f42
@ -17,6 +17,7 @@ import org.bukkit.Bukkit;
|
||||
import org.bukkit.GameMode;
|
||||
import org.bukkit.Material;
|
||||
import org.bukkit.Sound;
|
||||
import org.bukkit.attribute.Attribute;
|
||||
import org.bukkit.block.Block;
|
||||
import org.bukkit.entity.Player;
|
||||
import org.bukkit.inventory.ItemStack;
|
||||
@ -89,7 +90,7 @@ public class ArenaHandler {
|
||||
return;
|
||||
}
|
||||
|
||||
LocationSerializable zero = new LocationSerializable(Bukkit.getWorld(player.getWorld().getName().toString()), 0, 0, 0, 0, 0);
|
||||
LocationSerializable zero = new LocationSerializable(Bukkit.getWorld(player.getWorld().getName()), 0, 0, 0, 0, 0);
|
||||
if (arena.lobbyWarp != null && arena.hidersWarp != null && arena.seekersWarp != null && arena.spawnWarp != null) {
|
||||
if (!arena.lobbyWarp.equals(zero) && !arena.hidersWarp.equals(zero) && !arena.seekersWarp.equals(zero) && !arena.spawnWarp.equals(zero)) {
|
||||
if (arena.gameState == ArenaState.WAITING || arena.gameState == ArenaState.STARTING) {
|
||||
@ -105,7 +106,7 @@ public class ArenaHandler {
|
||||
Bukkit.getPluginManager().callEvent(event);
|
||||
|
||||
PlayerArenaData pad = new PlayerArenaData(player.getLocation(), player.getGameMode(), player.getInventory().getContents(), player
|
||||
.getInventory().getArmorContents(), player.getExp(), player.getLevel(), player.getMaxHealth(), player.getHealth(), player.getFoodLevel(),
|
||||
.getInventory().getArmorContents(), player.getExp(), player.getLevel(), player.getAttribute(Attribute.GENERIC_MAX_HEALTH).getValue(), player.getHealth(), player.getFoodLevel(),
|
||||
player.getActivePotionEffects(), player.getAllowFlight());
|
||||
|
||||
W.pData.put(player, pad);
|
||||
@ -117,7 +118,7 @@ public class ArenaHandler {
|
||||
}
|
||||
player.setFoodLevel(20);
|
||||
player.setHealth(20);
|
||||
player.setMaxHealth(20);
|
||||
player.getAttribute(Attribute.GENERIC_MAX_HEALTH).setBaseValue(20);
|
||||
player.setLevel(arena.timer);
|
||||
player.setExp(0);
|
||||
player.getInventory().clear();
|
||||
@ -299,7 +300,7 @@ public class ArenaHandler {
|
||||
player.updateInventory();
|
||||
player.setExp(pad.pEXP);
|
||||
player.setLevel(pad.pEXPL);
|
||||
player.setMaxHealth(pad.pMaxHealth);
|
||||
player.getAttribute(Attribute.GENERIC_MAX_HEALTH).setBaseValue(pad.pMaxHealth);
|
||||
player.setHealth(pad.pHealth);
|
||||
player.setFoodLevel(pad.pFood);
|
||||
player.addPotionEffects(pad.pPotionEffects);
|
||||
|
@ -333,7 +333,7 @@ public class BlockHunt extends JavaPlugin implements Listener {
|
||||
|
||||
// blockAnnouncer code.
|
||||
if ((arena.blockAnnouncerTime > 0) && (arena.timer == arena.blockAnnouncerTime)) {
|
||||
ArrayList<String> remainingBlocks = new ArrayList<String>();
|
||||
ArrayList<String> remainingBlocks = new ArrayList<>();
|
||||
for (Player arenaPlayer : arena.playersInArena) {
|
||||
if (!arena.seekers.contains(arenaPlayer)) {
|
||||
String block = arenaPlayer.getInventory().getItem(8).getType().name();
|
||||
|
@ -13,7 +13,6 @@ import nl.Steffion.BlockHunt.Managers.MessageM;
|
||||
import org.bukkit.Bukkit;
|
||||
import org.bukkit.command.Command;
|
||||
import org.bukkit.entity.Player;
|
||||
import org.bukkit.inventory.ItemStack;
|
||||
|
||||
public class CMDcreate extends DefaultCMD {
|
||||
|
||||
|
@ -101,7 +101,7 @@ public class OnPlayerInteractEvent implements Listener {
|
||||
if (event.getClickedBlock().getType().equals(Material.ENCHANTMENT_TABLE) || event.getClickedBlock().getType().equals(Material.WORKBENCH)
|
||||
|| event.getClickedBlock().getType().equals(Material.FURNACE) || event.getClickedBlock().getType().equals(Material.CHEST)
|
||||
|| event.getClickedBlock().getType().equals(Material.ANVIL) || event.getClickedBlock().getType().equals(Material.ENDER_CHEST)
|
||||
|| event.getClickedBlock().getType().equals(Material.JUKEBOX) || block.getFace(block).equals(Material.FIRE)) {
|
||||
|| event.getClickedBlock().getType().equals(Material.JUKEBOX) || block.getRelative(event.getBlockFace()).getType().equals(Material.FIRE)) {
|
||||
for (Arena arena : W.arenaList) {
|
||||
if (arena.playersInArena.contains(player)) {
|
||||
event.setCancelled(true);
|
||||
|
@ -97,7 +97,7 @@ public class ConfigM {
|
||||
try {
|
||||
this.file.getParentFile().mkdirs();
|
||||
this.file.createNewFile();
|
||||
if (this.fileLocation == BlockHunt.pdfFile.getName()) {
|
||||
if (this.fileLocation.equals(BlockHunt.pdfFile.getName())) {
|
||||
W.newFiles.add(this.fileName);
|
||||
} else {
|
||||
W.newFiles.add(this.fileLocation + this.fileName);
|
||||
|
@ -4,6 +4,6 @@ import java.util.Map;
|
||||
|
||||
public class M {
|
||||
public static Object g(Map<String, Object> map, String key, Object def) {
|
||||
return (map.containsKey(key) ? map.get(key) : def);
|
||||
return map.getOrDefault(key, def);
|
||||
}
|
||||
}
|
@ -96,7 +96,8 @@ public class SignsHandler {
|
||||
Sign signblock = (Sign) loc.getBlock().getState();
|
||||
String[] lines = signblock.getLines();
|
||||
if (sign.contains("leave")) {
|
||||
ArrayList<String> signLines = (ArrayList<String>) W.config.getFile().getList(ConfigC.sign_LEAVE.location);
|
||||
|
||||
ArrayList<String> signLines = (ArrayList<String>) W.config.getFile().getStringList(ConfigC.sign_LEAVE.location);
|
||||
int linecount = 0;
|
||||
for (String line : signLines) {
|
||||
if (linecount <= 3) {
|
||||
@ -107,7 +108,7 @@ public class SignsHandler {
|
||||
}
|
||||
signblock.update();
|
||||
} else if (sign.contains("shop")) {
|
||||
ArrayList<String> signLines = (ArrayList<String>) W.config.getFile().getList(ConfigC.sign_SHOP.location);
|
||||
ArrayList<String> signLines = (ArrayList<String>) W.config.getFile().getStringList(ConfigC.sign_SHOP.location);
|
||||
int linecount = 0;
|
||||
for (String line : signLines) {
|
||||
if (linecount <= 3) {
|
||||
@ -121,7 +122,7 @@ public class SignsHandler {
|
||||
for (Arena arena : W.arenaList) {
|
||||
if (lines[1].endsWith(arena.arenaName)) {
|
||||
if (arena.gameState.equals(ArenaState.WAITING)) {
|
||||
ArrayList<String> signLines = (ArrayList<String>) W.config.getFile().getList(ConfigC.sign_WAITING.location);
|
||||
ArrayList<String> signLines = (ArrayList<String>) W.config.getFile().getStringList(ConfigC.sign_WAITING.location);
|
||||
int linecount = 0;
|
||||
if (signLines != null) {
|
||||
for (String line : signLines) {
|
||||
@ -137,7 +138,7 @@ public class SignsHandler {
|
||||
}
|
||||
signblock.update();
|
||||
} else if (arena.gameState.equals(ArenaState.STARTING)) {
|
||||
ArrayList<String> signLines = (ArrayList<String>) W.config.getFile().getList(ConfigC.sign_STARTING.location);
|
||||
ArrayList<String> signLines = (ArrayList<String>) W.config.getFile().getStringList(ConfigC.sign_STARTING.location);
|
||||
int linecount = 0;
|
||||
if (signLines != null) {
|
||||
for (String line : signLines) {
|
||||
@ -153,7 +154,7 @@ public class SignsHandler {
|
||||
}
|
||||
signblock.update();
|
||||
} else if (arena.gameState.equals(ArenaState.INGAME)) {
|
||||
ArrayList<String> signLines = (ArrayList<String>) W.config.getFile().getList(ConfigC.sign_INGAME.location);
|
||||
ArrayList<String> signLines = (ArrayList<String>) W.config.getFile().getStringList(ConfigC.sign_INGAME.location);
|
||||
int linecount = 0;
|
||||
if (signLines != null) {
|
||||
for (String line : signLines) {
|
||||
|
Loading…
x
Reference in New Issue
Block a user