mirror of
https://github.com/DieReicheErethons/Brewery.git
synced 2024-11-16 10:35:22 +01:00
Detect more changes to Cauldrons
This commit is contained in:
parent
49efceaaae
commit
e69deaba29
@ -102,6 +102,9 @@ public class P extends JavaPlugin {
|
|||||||
p.getServer().getPluginManager().registerEvents(entityListener, p);
|
p.getServer().getPluginManager().registerEvents(entityListener, p);
|
||||||
p.getServer().getPluginManager().registerEvents(inventoryListener, p);
|
p.getServer().getPluginManager().registerEvents(inventoryListener, p);
|
||||||
p.getServer().getPluginManager().registerEvents(worldListener, p);
|
p.getServer().getPluginManager().registerEvents(worldListener, p);
|
||||||
|
if (use1_9) {
|
||||||
|
p.getServer().getPluginManager().registerEvents(new CauldronListener(), p);
|
||||||
|
}
|
||||||
|
|
||||||
// Heartbeat
|
// Heartbeat
|
||||||
p.getServer().getScheduler().runTaskTimer(p, new BreweryRunnable(), 650, 1200);
|
p.getServer().getScheduler().runTaskTimer(p, new BreweryRunnable(), 650, 1200);
|
||||||
|
22
src/com/dre/brewery/listeners/CauldronListener.java
Normal file
22
src/com/dre/brewery/listeners/CauldronListener.java
Normal file
@ -0,0 +1,22 @@
|
|||||||
|
package com.dre.brewery.listeners;
|
||||||
|
|
||||||
|
import com.dre.brewery.BCauldron;
|
||||||
|
import org.bukkit.event.EventHandler;
|
||||||
|
import org.bukkit.event.EventPriority;
|
||||||
|
import org.bukkit.event.Listener;
|
||||||
|
import org.bukkit.event.block.CauldronLevelChangeEvent;
|
||||||
|
|
||||||
|
public class CauldronListener implements Listener {
|
||||||
|
|
||||||
|
@EventHandler(priority = EventPriority.HIGH, ignoreCancelled = true)
|
||||||
|
public void onCauldronChange(CauldronLevelChangeEvent event) {
|
||||||
|
if (event.getNewLevel() == 0 && event.getOldLevel() != 0) {
|
||||||
|
if (event.getReason() == CauldronLevelChangeEvent.ChangeReason.BOTTLE_FILL) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
BCauldron.remove(event.getBlock());
|
||||||
|
} else if (event.getNewLevel() == 3 && event.getOldLevel() != 3) {
|
||||||
|
BCauldron.remove(event.getBlock());
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
@ -39,7 +39,7 @@ public class PlayerListener implements Listener {
|
|||||||
Material materialInHand = event.getMaterial();
|
Material materialInHand = event.getMaterial();
|
||||||
ItemStack item = event.getItem();
|
ItemStack item = event.getItem();
|
||||||
|
|
||||||
if (materialInHand == null) {
|
if (materialInHand == null || materialInHand == Material.BUCKET) {
|
||||||
return;
|
return;
|
||||||
|
|
||||||
} else if (materialInHand == Material.WATCH) {
|
} else if (materialInHand == Material.WATCH) {
|
||||||
@ -64,22 +64,16 @@ public class PlayerListener implements Listener {
|
|||||||
}
|
}
|
||||||
return;
|
return;
|
||||||
|
|
||||||
// reset cauldron when refilling to prevent
|
// reset cauldron when refilling to prevent unlimited source of potions
|
||||||
// unlimited source of potions
|
|
||||||
} else if (materialInHand == Material.WATER_BUCKET) {
|
} else if (materialInHand == Material.WATER_BUCKET) {
|
||||||
if (BCauldron.getFillLevel(clickedBlock) != 0 && BCauldron.getFillLevel(clickedBlock) < 2) {
|
if (!P.use1_9) {
|
||||||
// will only remove when existing
|
if (BCauldron.getFillLevel(clickedBlock) != 0 && BCauldron.getFillLevel(clickedBlock) < 2) {
|
||||||
BCauldron.remove(clickedBlock);
|
// will only remove when existing
|
||||||
|
BCauldron.remove(clickedBlock);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
return;
|
return;
|
||||||
|
|
||||||
// Its possible to empty a Cauldron with a Bucket in 1.9
|
|
||||||
} else if (P.use1_9 && materialInHand == Material.BUCKET) {
|
|
||||||
if (BCauldron.getFillLevel(clickedBlock) == 2) {
|
|
||||||
// will only remove when existing
|
|
||||||
BCauldron.remove(clickedBlock);
|
|
||||||
}
|
|
||||||
return;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// Check if fire alive below cauldron when adding ingredients
|
// Check if fire alive below cauldron when adding ingredients
|
||||||
|
Loading…
Reference in New Issue
Block a user