mirror of
https://github.com/songoda/FabledSkyBlock.git
synced 2024-11-26 20:26:34 +01:00
Hotfix for repeaters not being recognized in 1.8.8
This commit is contained in:
parent
d0b3f5f937
commit
41fd23122b
@ -1,6 +1,8 @@
|
||||
package com.songoda.skyblock.island;
|
||||
|
||||
import com.google.common.base.Strings;
|
||||
import com.songoda.core.compatibility.CompatibleMaterial;
|
||||
import com.songoda.core.compatibility.ServerVersion;
|
||||
import com.songoda.skyblock.SkyBlock;
|
||||
import com.songoda.skyblock.config.FileManager.Config;
|
||||
import com.songoda.skyblock.island.reward.LevelReward;
|
||||
@ -94,6 +96,15 @@ public class IslandLevel {
|
||||
}
|
||||
|
||||
public long getMaterialPoints(String material) {
|
||||
if(ServerVersion.isServerVersion(ServerVersion.V1_8)) {
|
||||
switch (material.toUpperCase()) {
|
||||
case "DIODE_BLOCK_OFF":
|
||||
case "DIODE_BLOCK_ON":
|
||||
material = CompatibleMaterial.REPEATER.name();
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
Config config = plugin.getFileManager().getConfig(new File(plugin.getDataFolder(), "levelling.yml"));
|
||||
FileConfiguration configLoad = config.getFileConfiguration();
|
||||
|
||||
@ -186,6 +197,15 @@ public class IslandLevel {
|
||||
}
|
||||
|
||||
public void setMaterialAmount(String material, long amount) {
|
||||
if(ServerVersion.isServerVersion(ServerVersion.V1_8)) {
|
||||
switch (material.toUpperCase()) {
|
||||
case "DIODE_BLOCK_OFF":
|
||||
case "DIODE_BLOCK_ON":
|
||||
material = CompatibleMaterial.REPEATER.name();
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
plugin.getFileManager().getConfig(new File(new File(plugin.getDataFolder().toString() + "/level-data"), ownerUUID.toString() + ".yml")).getFileConfiguration()
|
||||
.set("Levelling.Materials." + material + ".Amount", amount);
|
||||
|
||||
@ -193,10 +213,27 @@ public class IslandLevel {
|
||||
}
|
||||
|
||||
public long getMaterialAmount(String material) {
|
||||
if(ServerVersion.isServerVersion(ServerVersion.V1_8)) {
|
||||
switch (material.toUpperCase()) {
|
||||
case "DIODE_BLOCK_OFF":
|
||||
case "DIODE_BLOCK_ON":
|
||||
material = CompatibleMaterial.REPEATER.name();
|
||||
break;
|
||||
}
|
||||
}
|
||||
return this.materials.getOrDefault(material, 0l);
|
||||
}
|
||||
|
||||
public void removeMaterial(String material) {
|
||||
if(ServerVersion.isServerVersion(ServerVersion.V1_8)) {
|
||||
switch (material.toUpperCase()) {
|
||||
case "DIODE_BLOCK_OFF":
|
||||
case "DIODE_BLOCK_ON":
|
||||
material = CompatibleMaterial.REPEATER.name();
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
plugin.getFileManager().getConfig(new File(new File(plugin.getDataFolder().toString() + "/level-data"), ownerUUID.toString() + ".yml")).getFileConfiguration()
|
||||
.set("Levelling.Materials." + material, null);
|
||||
|
||||
|
@ -231,7 +231,18 @@ public final class IslandLevelManager {
|
||||
|
||||
private void updateLevelLocation(Island island, Location location) {
|
||||
Block block = location.getBlock();
|
||||
CompatibleMaterial material = CompatibleMaterial.getMaterial(block);
|
||||
CompatibleMaterial material = null;
|
||||
if(ServerVersion.isServerVersion(ServerVersion.V1_8)) {
|
||||
switch (block.getType().toString().toUpperCase()) {
|
||||
case "DIODE_BLOCK_OFF":
|
||||
case "DIODE_BLOCK_ON":
|
||||
material = CompatibleMaterial.REPEATER;
|
||||
break;
|
||||
}
|
||||
}
|
||||
if(material == null) {
|
||||
material = CompatibleMaterial.getMaterial(block);
|
||||
}
|
||||
|
||||
if (material == null || material == CompatibleMaterial.AIR) return;
|
||||
|
||||
|
@ -1,6 +1,7 @@
|
||||
package com.songoda.skyblock.limit.impl;
|
||||
|
||||
import com.songoda.core.compatibility.CompatibleMaterial;
|
||||
import com.songoda.core.compatibility.ServerVersion;
|
||||
import com.songoda.skyblock.SkyBlock;
|
||||
import com.songoda.skyblock.island.Island;
|
||||
import com.songoda.skyblock.island.IslandManager;
|
||||
@ -45,7 +46,7 @@ public final class BlockLimitation extends EnumLimitation<CompatibleMaterial> {
|
||||
|
||||
for (String key : keys) {
|
||||
final String enumName = key.toUpperCase(Locale.ENGLISH);
|
||||
final CompatibleMaterial type = CompatibleMaterial.getMaterial(enumName);
|
||||
CompatibleMaterial type = CompatibleMaterial.getMaterial(enumName);
|
||||
|
||||
if (type == null)
|
||||
throw new IllegalArgumentException("Unable to parse Materials from '" + enumName + "' in the Section '" + loadFrom.getCurrentPath() + "'");
|
||||
@ -64,7 +65,18 @@ public final class BlockLimitation extends EnumLimitation<CompatibleMaterial> {
|
||||
|
||||
if (player.hasPermission("fabledskyblock.limit.block.*")) return -1;
|
||||
|
||||
final CompatibleMaterial material = CompatibleMaterial.getMaterial(type);
|
||||
CompatibleMaterial material = null;
|
||||
if(ServerVersion.isServerVersion(ServerVersion.V1_8)) {
|
||||
switch (type.toString().toUpperCase()) {
|
||||
case "DIODE_BLOCK_OFF":
|
||||
case "DIODE_BLOCK_ON":
|
||||
material = CompatibleMaterial.REPEATER;
|
||||
break;
|
||||
}
|
||||
}
|
||||
if(material == null) {
|
||||
material = CompatibleMaterial.getMaterial(type);
|
||||
}
|
||||
|
||||
if (material == null) return -1;
|
||||
|
||||
@ -78,7 +90,6 @@ public final class BlockLimitation extends EnumLimitation<CompatibleMaterial> {
|
||||
}
|
||||
|
||||
public boolean isBlockLimitExceeded(Material type, Location loc, long limit) {
|
||||
|
||||
if (limit == -1) return false;
|
||||
|
||||
final IslandManager islandManager = SkyBlock.getInstance().getIslandManager();
|
||||
@ -88,7 +99,19 @@ public final class BlockLimitation extends EnumLimitation<CompatibleMaterial> {
|
||||
if (type == CompatibleMaterial.SPAWNER.getBlockMaterial()) {
|
||||
totalPlaced = island.getLevel().getMaterials().entrySet().stream().filter(x -> x.getKey().contains("SPAWNER")).mapToLong(Map.Entry::getValue).sum();
|
||||
} else {
|
||||
totalPlaced = island.getLevel().getMaterialAmount(CompatibleMaterial.getMaterial(type).name());
|
||||
CompatibleMaterial material = null;
|
||||
if(ServerVersion.isServerVersion(ServerVersion.V1_8)) {
|
||||
switch (type.toString().toUpperCase()) {
|
||||
case "DIODE_BLOCK_OFF":
|
||||
case "DIODE_BLOCK_ON":
|
||||
material = CompatibleMaterial.REPEATER;
|
||||
break;
|
||||
}
|
||||
}
|
||||
if(material == null) {
|
||||
material = CompatibleMaterial.getMaterial(type);
|
||||
}
|
||||
totalPlaced = island.getLevel().getMaterialAmount(material.name());
|
||||
}
|
||||
|
||||
return limit <= totalPlaced;
|
||||
|
@ -45,7 +45,6 @@ public class Block implements Listener {
|
||||
this.plugin = plugin;
|
||||
}
|
||||
|
||||
@SuppressWarnings("deprecation")
|
||||
@EventHandler(priority = EventPriority.LOW)
|
||||
public void onBlockBreak(BlockBreakEvent event) {
|
||||
Player player = event.getPlayer();
|
||||
@ -74,7 +73,18 @@ public class Block implements Listener {
|
||||
if (stackableManager != null && stackableManager.isStacked(blockLocation)) {
|
||||
Stackable stackable = stackableManager.getStack(block.getLocation(), CompatibleMaterial.getMaterial(block));
|
||||
if (stackable != null) {
|
||||
CompatibleMaterial material = CompatibleMaterial.getMaterial(block);
|
||||
CompatibleMaterial material = null;
|
||||
if(ServerVersion.isServerVersion(ServerVersion.V1_8)) {
|
||||
switch (block.getType().toString().toUpperCase()) {
|
||||
case "DIODE_BLOCK_OFF":
|
||||
case "DIODE_BLOCK_ON":
|
||||
material = CompatibleMaterial.REPEATER;
|
||||
break;
|
||||
}
|
||||
}
|
||||
if(material == null) {
|
||||
material = CompatibleMaterial.getMaterial(block);
|
||||
}
|
||||
byte data = block.getData();
|
||||
|
||||
int droppedAmount;
|
||||
@ -142,7 +152,18 @@ public class Block implements Listener {
|
||||
|
||||
if (event.isCancelled() || !configLoad.getBoolean("Island.Block.Level.Enable")) return;
|
||||
|
||||
CompatibleMaterial material = CompatibleMaterial.getMaterial(block);
|
||||
CompatibleMaterial material = null;
|
||||
if(ServerVersion.isServerVersion(ServerVersion.V1_8)) {
|
||||
switch (block.getType().toString().toUpperCase()) {
|
||||
case "DIODE_BLOCK_OFF":
|
||||
case "DIODE_BLOCK_ON":
|
||||
material = CompatibleMaterial.REPEATER;
|
||||
break;
|
||||
}
|
||||
}
|
||||
if(material == null) {
|
||||
material = CompatibleMaterial.getMaterial(block);
|
||||
}
|
||||
|
||||
if (material == null) return;
|
||||
|
||||
@ -273,7 +294,18 @@ public class Block implements Listener {
|
||||
long limit = limits.getBlockLimit(player, block);
|
||||
|
||||
if (limits.isBlockLimitExceeded(block, limit)) {
|
||||
CompatibleMaterial material = CompatibleMaterial.getMaterial(block.getType());
|
||||
CompatibleMaterial material = null;
|
||||
if(ServerVersion.isServerVersion(ServerVersion.V1_8)) {
|
||||
switch (block.getType().toString().toUpperCase()) {
|
||||
case "DIODE_BLOCK_OFF":
|
||||
case "DIODE_BLOCK_ON":
|
||||
material = CompatibleMaterial.REPEATER;
|
||||
break;
|
||||
}
|
||||
}
|
||||
if(material == null) {
|
||||
material = CompatibleMaterial.getMaterial(block);
|
||||
}
|
||||
|
||||
plugin.getMessageManager().sendMessage(player, plugin.getFileManager().getConfig(new File(plugin.getDataFolder(), "language.yml")).getFileConfiguration().getString("Island.Limit.Block.Exceeded.Message")
|
||||
.replace("%type", WordUtils.capitalizeFully(material.name().replace("_", " "))).replace("%limit", NumberUtil.formatNumber(limit)));
|
||||
|
Loading…
Reference in New Issue
Block a user