mirror of
https://github.com/songoda/FabledSkyBlock.git
synced 2025-01-07 16:27:49 +01:00
1.8.8 compatibility (almost)
This commit is contained in:
parent
7bd6d5aa08
commit
0c1b75d222
@ -160,7 +160,7 @@ public class Challenge {
|
||||
ItemStack is = (ItemStack) obj;
|
||||
//p.getInventory().removeItem(new ItemStack(is.getType(), is.getAmount()));
|
||||
int toRemove = is.getAmount();
|
||||
for(ItemStack jis : p.getInventory().getStorageContents()) {
|
||||
for(ItemStack jis : p.getInventory().getContents()) {
|
||||
if(jis != null && jis.isSimilar(is)) {
|
||||
if(jis.getAmount() <= toRemove) {
|
||||
toRemove -= jis.getAmount();
|
||||
|
@ -61,8 +61,8 @@ public class ChallengeCategory {
|
||||
Challenge c = new Challenge(this, id, name, maxTimes, showInChat, require, reward, ic);
|
||||
challenges.put(id, c);
|
||||
} catch (IllegalArgumentException ex) {
|
||||
throw new IllegalArgumentException("Exception at category " + this.name + "(" + this.id
|
||||
+ ") at challenge " + name + "(" + id + "): " + ex.getMessage());
|
||||
throw new IllegalArgumentException("Exception at category " + this.name.replace("&", "") + "(" + this.id
|
||||
+ ") at challenge " + name.replace("&", "") + "(" + id + "): " + ex.getMessage());
|
||||
}
|
||||
}
|
||||
Bukkit.getConsoleSender().sendMessage("[FabledSkyBlock] " + ChatColor.GREEN + "Category " + name + ChatColor.GREEN
|
||||
|
@ -47,7 +47,6 @@ import org.bukkit.configuration.ConfigurationSection;
|
||||
import org.bukkit.configuration.file.FileConfiguration;
|
||||
import org.bukkit.configuration.file.YamlConfiguration;
|
||||
import org.bukkit.entity.Player;
|
||||
import org.bukkit.plugin.IllegalPluginAccessException;
|
||||
|
||||
import java.io.File;
|
||||
import java.io.IOException;
|
||||
|
@ -25,9 +25,8 @@ import org.bukkit.block.BlockFace;
|
||||
import org.bukkit.block.BlockState;
|
||||
import org.bukkit.block.CreatureSpawner;
|
||||
import org.bukkit.configuration.file.FileConfiguration;
|
||||
import org.bukkit.entity.ArmorStand;
|
||||
import org.bukkit.entity.*;
|
||||
import org.bukkit.entity.Entity;
|
||||
import org.bukkit.entity.Player;
|
||||
import org.bukkit.event.EventHandler;
|
||||
import org.bukkit.event.EventPriority;
|
||||
import org.bukkit.event.Listener;
|
||||
@ -323,22 +322,29 @@ public class Block implements Listener {
|
||||
if(configLoad.getBoolean("Island.Nether.WaterDoNotFlowNearNetherMobs", false) && worldManager.getIslandWorld(block.getWorld()).equals(IslandWorld.Nether)){
|
||||
Collection<Entity> entities = block.getWorld().getNearbyEntities(block.getLocation(), 1d, 1d, 1d);
|
||||
if(entities.size() > 0){
|
||||
EntityCycle: for(Entity ent : entities){
|
||||
switch(ent.getType()){
|
||||
case PIG_ZOMBIE:
|
||||
case BLAZE:
|
||||
case MAGMA_CUBE:
|
||||
case WITHER_SKELETON:
|
||||
case WITHER:
|
||||
case GHAST:
|
||||
if(block.getRelative(event.getFace().getOppositeFace()).getType().equals(Material.WATER)){
|
||||
event.setCancelled(true);
|
||||
for(Entity ent : entities){
|
||||
boolean witherSkeleton;
|
||||
if (NMSUtil.getVersionNumber() > 10) {
|
||||
witherSkeleton = ent.getType().equals(EntityType.WITHER_SKELETON);
|
||||
} else {
|
||||
witherSkeleton = ent instanceof Skeleton && ((Skeleton) ent).getSkeletonType().equals(Skeleton.SkeletonType.WITHER);
|
||||
}
|
||||
if (ent.getType().equals(EntityType.PIG_ZOMBIE) ||
|
||||
ent.getType().equals(EntityType.BLAZE) ||
|
||||
ent.getType().equals(EntityType.MAGMA_CUBE) ||
|
||||
ent.getType().equals(EntityType.WITHER) ||
|
||||
ent.getType().equals(EntityType.GHAST) ||
|
||||
witherSkeleton) {
|
||||
if(block.getRelative(event.getFace().getOppositeFace()).getType().equals(Material.WATER)){
|
||||
event.setCancelled(true);
|
||||
if(NMSUtil.getVersionNumber() > 8){
|
||||
event.getToBlock().getWorld().playSound(block.getLocation(), Sound.BLOCK_FIRE_EXTINGUISH, 1f, 1f);
|
||||
event.getToBlock().getWorld().playEffect(block.getLocation(), Effect.SMOKE, 1);
|
||||
} else {
|
||||
// TODO Find a sound for 1.8
|
||||
}
|
||||
break EntityCycle; // TODO No spaghetti code
|
||||
default:
|
||||
break;
|
||||
event.getToBlock().getWorld().playEffect(block.getLocation(), Effect.SMOKE, 1);
|
||||
}
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -638,7 +644,7 @@ public class Block implements Listener {
|
||||
// PortalCreateEvent.getBlocks() changed from ArrayList<Block> to
|
||||
// ArrayList<BlockState> in 1.14.1
|
||||
if (NMSUtil.getVersionNumber() > 13) {
|
||||
List<BlockState> blocks = event.getBlocks();
|
||||
List<BlockState> blocks = event.getBlocks(); // TODO 1.8
|
||||
if (event.getBlocks().isEmpty()) return;
|
||||
|
||||
Island island = islandManager.getIslandAtLocation(event.getBlocks().get(0).getLocation());
|
||||
|
@ -18,6 +18,7 @@ import com.songoda.skyblock.stackable.Stackable;
|
||||
import com.songoda.skyblock.stackable.StackableManager;
|
||||
import com.songoda.skyblock.utils.NumberUtil;
|
||||
import com.songoda.skyblock.utils.structure.StructureUtil;
|
||||
import com.songoda.skyblock.utils.version.NMSUtil;
|
||||
import com.songoda.skyblock.utils.world.LocationUtil;
|
||||
import com.songoda.skyblock.world.WorldManager;
|
||||
import org.apache.commons.lang.WordUtils;
|
||||
@ -121,7 +122,12 @@ public class Interact implements Listener {
|
||||
if(configLoad.getBoolean("Island.Nether.AllowNetherWater", false)){
|
||||
event.setCancelled(true);
|
||||
block.setType(Material.WATER, true);
|
||||
block.getWorld().playSound(block.getLocation(), Sound.ITEM_BUCKET_EMPTY, 1f, 1f);
|
||||
if(NMSUtil.getVersionNumber() > 8){
|
||||
block.getWorld().playSound(block.getLocation(), Sound.ITEM_BUCKET_EMPTY, 1f, 1f);
|
||||
} else {
|
||||
//block.getWorld().playSound(block.getLocation(), Sound.SPLASH, 1f, 1f);
|
||||
// TODO Find a sound for 1.8
|
||||
}
|
||||
if(!event.getPlayer().getGameMode().equals(GameMode.CREATIVE)){
|
||||
event.getItem().setType(Material.BUCKET);
|
||||
}
|
||||
|
@ -123,7 +123,7 @@ public class Leaderboard {
|
||||
2);
|
||||
} else {
|
||||
nInv.addItem(
|
||||
nInv.createItem(new ItemStack(Material.GRAY_STAINED_GLASS_PANE), "", null, null, null, null), 2);
|
||||
nInv.createItem(CompatibleMaterial.BLACK_STAINED_GLASS_PANE.getItem(), "", null, null, null, null), 2);
|
||||
}
|
||||
nInv.addItem(
|
||||
nInv.createItem(new ItemStack(Material.EMERALD), configLoad
|
||||
|
@ -11,6 +11,7 @@ import com.songoda.skyblock.leaderboard.Leaderboard;
|
||||
import com.songoda.skyblock.leaderboard.LeaderboardManager;
|
||||
import com.songoda.skyblock.utils.NumberUtil;
|
||||
import com.songoda.skyblock.utils.player.OfflinePlayer;
|
||||
import com.songoda.skyblock.utils.version.NMSUtil;
|
||||
import com.songoda.skyblock.utils.world.LocationUtil;
|
||||
import com.songoda.skyblock.visit.Visit;
|
||||
import org.bukkit.*;
|
||||
@ -18,7 +19,9 @@ import org.bukkit.block.Block;
|
||||
import org.bukkit.block.BlockFace;
|
||||
import org.bukkit.configuration.file.FileConfiguration;
|
||||
import org.bukkit.entity.Entity;
|
||||
import org.bukkit.entity.EntityType;
|
||||
import org.bukkit.entity.Player;
|
||||
import org.bukkit.entity.Skeleton;
|
||||
import org.bukkit.scheduler.BukkitRunnable;
|
||||
|
||||
import java.io.File;
|
||||
@ -51,28 +54,22 @@ public class MobNetherWaterTask extends BukkitRunnable {
|
||||
.getFileConfiguration().getBoolean("Island.Nether.WaterDisappearWithNetherMobs", false)){
|
||||
for(World world : Bukkit.getServer().getWorlds()){
|
||||
if(plugin.getWorldManager().isIslandWorld(world) && plugin.getWorldManager().getIslandWorld(world).equals(IslandWorld.Nether)){
|
||||
for(Entity ent : world.getEntities()){
|
||||
switch(ent.getType()){
|
||||
case PIG_ZOMBIE:
|
||||
case BLAZE:
|
||||
case MAGMA_CUBE:
|
||||
case WITHER_SKELETON:
|
||||
case WITHER:
|
||||
case GHAST:
|
||||
Block block = ent.getLocation().getBlock();
|
||||
if(block.getType().equals(Material.WATER)){
|
||||
block.setType(Material.AIR, true);
|
||||
world.playSound(block.getLocation(), Sound.BLOCK_FIRE_EXTINGUISH, 1f, 1f);
|
||||
world.playEffect(block.getLocation(), Effect.SMOKE, 1);
|
||||
}
|
||||
block = block.getRelative(BlockFace.UP);
|
||||
if(block.getType().equals(Material.WATER)){
|
||||
block.setType(Material.AIR, true);
|
||||
world.playSound(block.getLocation(), Sound.BLOCK_FIRE_EXTINGUISH, 1f, 1f);
|
||||
world.playEffect(block.getLocation(), Effect.SMOKE, 1);
|
||||
}
|
||||
default:
|
||||
break;
|
||||
for(Entity ent : world.getEntities()) {
|
||||
boolean witherSkeleton;
|
||||
if (NMSUtil.getVersionNumber() > 10) {
|
||||
witherSkeleton = ent.getType().equals(EntityType.WITHER_SKELETON);
|
||||
} else {
|
||||
witherSkeleton = ent instanceof Skeleton && ((Skeleton) ent).getSkeletonType().equals(Skeleton.SkeletonType.WITHER);
|
||||
}
|
||||
if (ent.getType().equals(EntityType.PIG_ZOMBIE) ||
|
||||
ent.getType().equals(EntityType.BLAZE) ||
|
||||
ent.getType().equals(EntityType.MAGMA_CUBE) ||
|
||||
ent.getType().equals(EntityType.WITHER) ||
|
||||
ent.getType().equals(EntityType.GHAST) ||
|
||||
witherSkeleton) {
|
||||
Block block = ent.getLocation().getBlock();
|
||||
removeWater(world, block);
|
||||
removeWater(world, block.getRelative(BlockFace.UP));
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -80,6 +77,18 @@ public class MobNetherWaterTask extends BukkitRunnable {
|
||||
}
|
||||
}
|
||||
|
||||
private void removeWater(World world, Block block) {
|
||||
if (block.getType().equals(Material.WATER)) {
|
||||
block.setType(Material.AIR, true);
|
||||
if(NMSUtil.getVersionNumber() > 8){
|
||||
world.playSound(block.getLocation(), Sound.BLOCK_FIRE_EXTINGUISH, 1f, 1f);
|
||||
} else {
|
||||
// TODO Find a sound for 1.8
|
||||
}
|
||||
world.playEffect(block.getLocation(), Effect.SMOKE, 1);
|
||||
}
|
||||
}
|
||||
|
||||
public void onDisable() {
|
||||
}
|
||||
|
||||
|
@ -9,13 +9,13 @@ import com.songoda.skyblock.island.IslandEnvironment;
|
||||
import com.songoda.skyblock.island.IslandManager;
|
||||
import com.songoda.skyblock.island.IslandWorld;
|
||||
import com.songoda.skyblock.utils.math.VectorUtil;
|
||||
import com.songoda.skyblock.utils.version.NMSUtil;
|
||||
import com.songoda.skyblock.utils.world.block.BlockDegreesType;
|
||||
import com.songoda.skyblock.world.WorldManager;
|
||||
import org.bukkit.*;
|
||||
import org.bukkit.World.Environment;
|
||||
import org.bukkit.block.Block;
|
||||
import org.bukkit.block.BlockFace;
|
||||
import org.bukkit.block.data.Waterlogged;
|
||||
import org.bukkit.entity.Player;
|
||||
|
||||
import java.io.File;
|
||||
@ -32,10 +32,8 @@ public final class LocationUtil {
|
||||
Location tempLoc = LocationUtil.getDefinitiveLocation(loc);
|
||||
if(tempLoc.getBlock().getType().equals(Material.WATER)){
|
||||
tempLoc.getBlock().setType(Material.AIR);
|
||||
} else if(tempLoc.getBlock().getBlockData() instanceof Waterlogged){
|
||||
Waterlogged blockData = (Waterlogged) tempLoc.getBlock().getBlockData();
|
||||
blockData.setWaterlogged(false);
|
||||
tempLoc.getBlock().setBlockData(blockData);
|
||||
} else if(NMSUtil.getVersionNumber() > 13){
|
||||
LocationUtil113.removeWaterLoggedFromLocation(tempLoc);
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -66,7 +64,8 @@ public final class LocationUtil {
|
||||
Location locWorking = loc.clone();
|
||||
for(int i=locWorking.getBlockY(); i>=0; i--){
|
||||
if(!locWorking.getBlock().isEmpty()){
|
||||
if(locWorking.getBlock().getType().equals(Material.WATER) || locWorking.getBlock().getBlockData() instanceof Waterlogged){
|
||||
if(locWorking.getBlock().getType().equals(Material.WATER) ||
|
||||
(NMSUtil.getVersionNumber() > 13 && locWorking.getBlock().getBlockData() instanceof org.bukkit.block.data.Waterlogged)){
|
||||
loc = locWorking;
|
||||
}
|
||||
break;
|
||||
@ -79,39 +78,38 @@ public final class LocationUtil {
|
||||
boolean safe = false;
|
||||
if(!locChecked.getBlock().isEmpty() &&
|
||||
!locChecked.getBlock().isLiquid() &&
|
||||
!locChecked.getBlock().isPassable() &&
|
||||
locChecked.getBlock().getType().isSolid() &&
|
||||
locChecked.getBlock().getType().isBlock() &&
|
||||
locChecked.add(0d,1d,0d).getBlock().getType().isAir() &&
|
||||
locChecked.add(0d,2d,0d).getBlock().getType().isAir() &&
|
||||
!(locChecked.getBlock().getBlockData() instanceof Waterlogged)){
|
||||
locChecked.add(0d,1d,0d).getBlock().getType().equals(Material.AIR) &&
|
||||
locChecked.add(0d,2d,0d).getBlock().getType().equals(Material.AIR) &&
|
||||
!(NMSUtil.getVersionNumber() <= 13 || locChecked.getBlock().getBlockData() instanceof org.bukkit.block.data.Waterlogged)){
|
||||
safe = true;
|
||||
switch(locChecked.getBlock().getType()){
|
||||
case ACACIA_BUTTON:
|
||||
case ACACIA_DOOR:
|
||||
case ACACIA_DOOR: // <= 1.8.8
|
||||
case ACACIA_FENCE_GATE:
|
||||
case ACACIA_TRAPDOOR:
|
||||
case BIRCH_DOOR:
|
||||
case BIRCH_FENCE_GATE:
|
||||
case BIRCH_TRAPDOOR:
|
||||
case CACTUS:
|
||||
case CAKE:
|
||||
case CAMPFIRE:
|
||||
case COBWEB:
|
||||
case DARK_OAK_DOOR:
|
||||
case DARK_OAK_FENCE_GATE:
|
||||
case DARK_OAK_TRAPDOOR:
|
||||
case IRON_TRAPDOOR:
|
||||
case JUNGLE_DOOR:
|
||||
case JUNGLE_FENCE_GATE:
|
||||
case JUNGLE_TRAPDOOR:
|
||||
case LADDER:
|
||||
case MAGMA_BLOCK:
|
||||
case NETHER_PORTAL:
|
||||
case OAK_DOOR:
|
||||
case OAK_FENCE_GATE:
|
||||
case SPRUCE_DOOR:
|
||||
case SPRUCE_FENCE_GATE:
|
||||
case ACACIA_BUTTON: // TODO check server version
|
||||
case ACACIA_TRAPDOOR: // TODO check server version
|
||||
case BIRCH_TRAPDOOR: // TODO check server version
|
||||
case CAMPFIRE: // TODO check server version
|
||||
case COBWEB: // TODO check server version
|
||||
case DARK_OAK_TRAPDOOR: // TODO check server version
|
||||
case JUNGLE_TRAPDOOR: // TODO check server version
|
||||
case MAGMA_BLOCK: // TODO check server version
|
||||
case NETHER_PORTAL: // TODO check server version
|
||||
case OAK_DOOR: // TODO check server version
|
||||
case OAK_FENCE_GATE: // TODO check server version
|
||||
safe = false;
|
||||
break;
|
||||
}
|
||||
|
@ -0,0 +1,13 @@
|
||||
package com.songoda.skyblock.utils.world;
|
||||
|
||||
import org.bukkit.Location;
|
||||
|
||||
public class LocationUtil113 {
|
||||
public static void removeWaterLoggedFromLocation(Location loc){
|
||||
if(loc.getBlock().getBlockData() instanceof org.bukkit.block.data.Waterlogged){
|
||||
org.bukkit.block.data.Waterlogged blockData = (org.bukkit.block.data.Waterlogged) loc.getBlock().getBlockData();
|
||||
blockData.setWaterlogged(false);
|
||||
loc.getBlock().setBlockData(blockData);
|
||||
}
|
||||
}
|
||||
}
|
@ -498,7 +498,10 @@ public final class EntityUtil {
|
||||
}
|
||||
|
||||
public static boolean isMonster(EntityType type) {
|
||||
switch (type) {
|
||||
if (NMSUtil.getVersionNumber() > 10) {
|
||||
if(type.equals(EntityType.WITHER_SKELETON)) return true; // TODO In < 11 we have SkeletonType.Wither
|
||||
}
|
||||
switch (type) { // TODO Check server versions
|
||||
case BAT:
|
||||
case BLAZE:
|
||||
case CAVE_SPIDER:
|
||||
@ -525,7 +528,6 @@ public final class EntityUtil {
|
||||
case VINDICATOR:
|
||||
case WITCH:
|
||||
case WITHER:
|
||||
case WITHER_SKELETON:
|
||||
case ZOMBIE:
|
||||
case ZOMBIE_VILLAGER:
|
||||
return true;
|
||||
|
Loading…
Reference in New Issue
Block a user