mirror of
https://github.com/DieReicheErethons/Brewery.git
synced 2024-06-28 10:44:48 +02:00
Fixed cauldron duplication bug
This commit is contained in:
parent
1f16c6af04
commit
02b909a26a
2
pom.xml
2
pom.xml
|
@ -4,7 +4,7 @@
|
|||
|
||||
<groupId>com.dre</groupId>
|
||||
<artifactId>brewery</artifactId>
|
||||
<version>1.3.1</version>
|
||||
<version>1.3.2</version>
|
||||
<name>Brewery</name>
|
||||
|
||||
<properties>
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
name: Brewery
|
||||
version: 1.3.1
|
||||
version: 1.3.2
|
||||
main: com.dre.brewery.P
|
||||
authors: [Milan Albrecht, Frank Baumann]
|
||||
softdepend: [LWC, LogBlock, WorldGuard, GriefPrevention]
|
||||
|
|
|
@ -97,22 +97,28 @@ public class BCauldron {
|
|||
}
|
||||
ItemStack potion = bcauldron.ingredients.cook(bcauldron.state);
|
||||
if (potion != null) {
|
||||
byte data = block.getData();
|
||||
if (data > 3) {
|
||||
data = 3;
|
||||
block.setData(data);
|
||||
} else if (data <= 0) {
|
||||
bcauldrons.remove(bcauldron);
|
||||
return false;
|
||||
}
|
||||
data -= 1;
|
||||
block.setData(data);
|
||||
|
||||
if (data == 0) {
|
||||
bcauldrons.remove(bcauldron);
|
||||
} else {
|
||||
bcauldron.someRemoved = true;
|
||||
}
|
||||
// Bukkit Bug, inventory not updating while in event so this
|
||||
// will delay the give
|
||||
// but could also just use deprecated updateInventory()
|
||||
giveItem(player, potion);
|
||||
// player.getInventory().addItem(potion);
|
||||
// player.getInventory().updateInventory();
|
||||
if (block.getData() > 3) {
|
||||
block.setData((byte) 3);
|
||||
}
|
||||
block.setData((byte) (block.getData() - 1));
|
||||
|
||||
if (block.getData() == 0) {
|
||||
bcauldrons.remove(bcauldron);
|
||||
} else {
|
||||
bcauldron.someRemoved = true;
|
||||
}
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -34,15 +34,15 @@ public class PlayerListener implements Listener {
|
|||
Player player = event.getPlayer();
|
||||
if (!player.isSneaking()) {
|
||||
Material type = clickedBlock.getType();
|
||||
|
||||
// Interacting with a Cauldron
|
||||
if (type == Material.CAULDRON) {
|
||||
Block down = clickedBlock.getRelative(BlockFace.DOWN);
|
||||
if (down.getType() == Material.FIRE || down.getType() == Material.STATIONARY_LAVA || down.getType() == Material.LAVA) {
|
||||
Material materialInHand = event.getMaterial();
|
||||
ItemStack item = event.getItem();
|
||||
|
||||
|
||||
if (materialInHand == Material.WATCH) {
|
||||
BCauldron.printTime(player, clickedBlock);
|
||||
return;
|
||||
|
||||
// fill a glass bottle with potion
|
||||
} else if (materialInHand == Material.GLASS_BOTTLE) {
|
||||
|
@ -60,20 +60,25 @@ public class PlayerListener implements Listener {
|
|||
} else {
|
||||
event.setCancelled(true);
|
||||
}
|
||||
return;
|
||||
|
||||
// reset cauldron when refilling to prevent
|
||||
// unlimited source of potions
|
||||
} else if (materialInHand == Material.WATER_BUCKET) {
|
||||
if (BCauldron.getFillLevel(clickedBlock) != 0) {
|
||||
if (BCauldron.getFillLevel(clickedBlock) < 2) {
|
||||
if (BCauldron.getFillLevel(clickedBlock) != 0 && BCauldron.getFillLevel(clickedBlock) < 2) {
|
||||
// will only remove when existing
|
||||
BCauldron.remove(clickedBlock);
|
||||
}
|
||||
return;
|
||||
}
|
||||
|
||||
// add ingredient to cauldron that meet the previous
|
||||
// contitions
|
||||
} else if (BIngredients.possibleIngredients.contains(materialInHand)) {
|
||||
// Check if fire alive below cauldron when adding ingredients
|
||||
Block down = clickedBlock.getRelative(BlockFace.DOWN);
|
||||
if (down.getType() == Material.FIRE || down.getType() == Material.STATIONARY_LAVA || down.getType() == Material.LAVA) {
|
||||
|
||||
// add ingredient to cauldron that meet the previous conditions
|
||||
if (BIngredients.possibleIngredients.contains(materialInHand)) {
|
||||
|
||||
if (player.hasPermission("brewery.cauldron.insert")) {
|
||||
if (BCauldron.ingredientAdd(clickedBlock, item)) {
|
||||
boolean isBucket = item.getType().equals(Material.WATER_BUCKET)
|
||||
|
@ -100,8 +105,8 @@ public class PlayerListener implements Listener {
|
|||
} else {
|
||||
event.setCancelled(true);
|
||||
}
|
||||
return;
|
||||
}
|
||||
return;
|
||||
}
|
||||
|
||||
// Access a Barrel
|
||||
|
|
Loading…
Reference in New Issue
Block a user