mirror of
https://github.com/songoda/FabledSkyBlock.git
synced 2024-11-24 03:05:56 +01:00
Remove points when a dragon egg is destroyed.
This commit is contained in:
parent
08fdf5ac50
commit
ebc6ec3d06
@ -167,6 +167,7 @@ public class SkyBlock extends SongodaPlugin {
|
||||
pluginManager.registerEvents(new Spawner(this), this);
|
||||
pluginManager.registerEvents(new Food(this), this);
|
||||
pluginManager.registerEvents(new Grow(this), this);
|
||||
pluginManager.registerEvents(new Piston(this), this);
|
||||
|
||||
if (pluginManager.isPluginEnabled("EpicSpawners")) pluginManager.registerEvents(new EpicSpawners(this), this);
|
||||
if (pluginManager.isPluginEnabled("WildStacker")) pluginManager.registerEvents(new WildStacker(this), this);
|
||||
@ -218,9 +219,9 @@ public class SkyBlock extends SongodaPlugin {
|
||||
if (this.hologramManager != null) {
|
||||
this.hologramManager.onDisable();
|
||||
}
|
||||
|
||||
|
||||
if (this.fabledChallenge != null) {
|
||||
this.fabledChallenge.onDisable();
|
||||
this.fabledChallenge.onDisable();
|
||||
}
|
||||
|
||||
HandlerList.unregisterAll(this);
|
||||
@ -352,8 +353,8 @@ public class SkyBlock extends SongodaPlugin {
|
||||
public RewardManager getRewardManager() {
|
||||
return rewardManager;
|
||||
}
|
||||
|
||||
|
||||
public FabledChallenge getFabledChallenge() {
|
||||
return fabledChallenge;
|
||||
return fabledChallenge;
|
||||
}
|
||||
}
|
||||
|
65
src/main/java/com/songoda/skyblock/listeners/Piston.java
Normal file
65
src/main/java/com/songoda/skyblock/listeners/Piston.java
Normal file
@ -0,0 +1,65 @@
|
||||
package com.songoda.skyblock.listeners;
|
||||
|
||||
import com.songoda.core.compatibility.CompatibleMaterial;
|
||||
import com.songoda.skyblock.SkyBlock;
|
||||
import com.songoda.skyblock.config.FileManager;
|
||||
import com.songoda.skyblock.island.Island;
|
||||
import com.songoda.skyblock.island.IslandLevel;
|
||||
import com.songoda.skyblock.island.IslandManager;
|
||||
import com.songoda.skyblock.utils.version.Materials;
|
||||
import com.songoda.skyblock.world.WorldManager;
|
||||
import org.bukkit.block.Block;
|
||||
import org.bukkit.configuration.file.FileConfiguration;
|
||||
import org.bukkit.event.EventHandler;
|
||||
import org.bukkit.event.Listener;
|
||||
import org.bukkit.event.block.BlockPistonExtendEvent;
|
||||
|
||||
import java.io.File;
|
||||
|
||||
public class Piston implements Listener {
|
||||
|
||||
private final SkyBlock skyblock;
|
||||
|
||||
public Piston(SkyBlock skyblock) {
|
||||
this.skyblock = skyblock;
|
||||
}
|
||||
|
||||
// Prevent point farming with Dragon Egg
|
||||
@EventHandler
|
||||
public void onPistonMove(BlockPistonExtendEvent event) {
|
||||
|
||||
Block block = event.getBlock().getRelative(event.getDirection());
|
||||
|
||||
IslandManager islandManager = skyblock.getIslandManager();
|
||||
WorldManager worldManager = skyblock.getWorldManager();
|
||||
|
||||
if (!worldManager.isIslandWorld(block.getWorld())) return;
|
||||
|
||||
Island island = islandManager.getIslandAtLocation(block.getLocation());
|
||||
|
||||
if (island == null ||
|
||||
CompatibleMaterial.DRAGON_EGG != CompatibleMaterial.getMaterial(block)) return;
|
||||
|
||||
FileManager.Config config = skyblock.getFileManager().getConfig(new File(skyblock.getDataFolder(), "config.yml"));
|
||||
FileConfiguration configLoad = config.getFileConfiguration();
|
||||
|
||||
if (!configLoad.getBoolean("Island.Block.Level.Enable")) return;
|
||||
|
||||
final Materials materials;
|
||||
|
||||
materials = Materials.getMaterials(block.getType(), block.getData());
|
||||
|
||||
if (materials == null) return;
|
||||
|
||||
IslandLevel level = island.getLevel();
|
||||
|
||||
if (!level.hasMaterial(materials.name())) return;
|
||||
|
||||
long materialAmount = level.getMaterialAmount(materials.name());
|
||||
|
||||
if (materialAmount <= 1)
|
||||
level.removeMaterial(materials.name());
|
||||
else
|
||||
level.setMaterialAmount(materials.name(), materialAmount - 1);
|
||||
}
|
||||
}
|
Loading…
Reference in New Issue
Block a user