mirror of
https://github.com/DieReicheErethons/Brewery.git
synced 2025-01-31 22:41:20 +01:00
commit
82964cfd8c
14
.editorconfig
Normal file
14
.editorconfig
Normal file
@ -0,0 +1,14 @@
|
|||||||
|
root = true
|
||||||
|
|
||||||
|
[*]
|
||||||
|
end_of_line = lf
|
||||||
|
insert_final_newline = true
|
||||||
|
indent_style = tab
|
||||||
|
indent_size = 4
|
||||||
|
trim_trailing_whitespace = true
|
||||||
|
|
||||||
|
[*.yml]
|
||||||
|
indent_style = spaces
|
||||||
|
indent_size = 2
|
||||||
|
trim_trailing_whitespace = true
|
||||||
|
|
110
pom.xml
110
pom.xml
@ -1,15 +1,15 @@
|
|||||||
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
|
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
|
||||||
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
|
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
|
||||||
<modelVersion>4.0.0</modelVersion>
|
<modelVersion>4.0.0</modelVersion>
|
||||||
|
|
||||||
<groupId>com.dre</groupId>
|
<groupId>com.dre</groupId>
|
||||||
<artifactId>brewery</artifactId>
|
<artifactId>brewery</artifactId>
|
||||||
<version>1.3.2</version>
|
<version>1.4.1</version>
|
||||||
<name>Brewery</name>
|
<name>Brewery</name>
|
||||||
|
|
||||||
<properties>
|
<properties>
|
||||||
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
|
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
|
||||||
<project.reporting.outputEncoding>UTF-8</project.reporting.outputEncoding>
|
<project.reporting.outputEncoding>UTF-8</project.reporting.outputEncoding>
|
||||||
</properties>
|
</properties>
|
||||||
|
|
||||||
<build>
|
<build>
|
||||||
@ -18,7 +18,7 @@
|
|||||||
<resources>
|
<resources>
|
||||||
<!-- Static resources -->
|
<!-- Static resources -->
|
||||||
<resource>
|
<resource>
|
||||||
<filtering>false</filtering>
|
<filtering>true</filtering>
|
||||||
<directory>${project.basedir}/resources</directory>
|
<directory>${project.basedir}/resources</directory>
|
||||||
<includes>
|
<includes>
|
||||||
<include>**/*.yml</include>
|
<include>**/*.yml</include>
|
||||||
@ -33,10 +33,10 @@
|
|||||||
<plugins>
|
<plugins>
|
||||||
<plugin>
|
<plugin>
|
||||||
<artifactId>maven-compiler-plugin</artifactId>
|
<artifactId>maven-compiler-plugin</artifactId>
|
||||||
<version>3.1</version>
|
<version>2.5.1</version>
|
||||||
<configuration>
|
<configuration>
|
||||||
<source>1.6</source>
|
<source>1.7</source>
|
||||||
<target>1.6</target>
|
<target>1.7</target>
|
||||||
<encoding>UTF-8</encoding>
|
<encoding>UTF-8</encoding>
|
||||||
</configuration>
|
</configuration>
|
||||||
</plugin>
|
</plugin>
|
||||||
@ -47,35 +47,19 @@
|
|||||||
<repository>
|
<repository>
|
||||||
<id>spigot-repo</id>
|
<id>spigot-repo</id>
|
||||||
<url>https://hub.spigotmc.org/nexus/content/groups/public/</url>
|
<url>https://hub.spigotmc.org/nexus/content/groups/public/</url>
|
||||||
<snapshots>
|
|
||||||
<enabled>true</enabled>
|
|
||||||
<updatePolicy>always</updatePolicy>
|
|
||||||
</snapshots>
|
|
||||||
</repository>
|
</repository>
|
||||||
|
<repository>
|
||||||
<repository>
|
<id>vault-repo</id>
|
||||||
<id>vault-repo</id>
|
<url>http://nexus.theyeticave.net/content/repositories/pub_releases</url>
|
||||||
<url>http://nexus.theyeticave.net/content/repositories/pub_releases</url>
|
</repository>
|
||||||
</repository>
|
<!--<repository>
|
||||||
|
<id>dre2n-repo</id>
|
||||||
|
<url>http://feuerstern.bplaced.net/repo/</url>
|
||||||
|
</repository>-->
|
||||||
<repository>
|
<repository>
|
||||||
<id>sk89q-repo</id>
|
<id>sk89q-repo</id>
|
||||||
<url>http://maven.sk89q.com/artifactory/repo/</url>
|
<url>http://maven.sk89q.com/repo/</url>
|
||||||
<snapshots>
|
|
||||||
<enabled>true</enabled>
|
|
||||||
<updatePolicy>always</updatePolicy>
|
|
||||||
</snapshots>
|
|
||||||
</repository>
|
</repository>
|
||||||
|
|
||||||
<repository>
|
|
||||||
<id>dre-repo</id>
|
|
||||||
<url>http://server.die-reiche-erethons.com/maven2</url>
|
|
||||||
<snapshots>
|
|
||||||
<enabled>true</enabled>
|
|
||||||
<updatePolicy>always</updatePolicy>
|
|
||||||
</snapshots>
|
|
||||||
</repository>
|
|
||||||
|
|
||||||
<repository>
|
<repository>
|
||||||
<id>addstar-repo</id>
|
<id>addstar-repo</id>
|
||||||
<url>http://maven.addstar.com.au/artifactory/ext-release-local/</url>
|
<url>http://maven.addstar.com.au/artifactory/ext-release-local/</url>
|
||||||
@ -84,60 +68,44 @@
|
|||||||
<updatePolicy>always</updatePolicy>
|
<updatePolicy>always</updatePolicy>
|
||||||
</snapshots>
|
</snapshots>
|
||||||
</repository>
|
</repository>
|
||||||
|
<repository>
|
||||||
|
<id>md_5-releases</id>
|
||||||
|
<url>http://repo.md-5.net/content/repositories/releases/</url>
|
||||||
|
</repository>
|
||||||
</repositories>
|
</repositories>
|
||||||
|
|
||||||
<dependencies>
|
<dependencies>
|
||||||
<!-- Provided by third-party -->
|
|
||||||
<dependency>
|
<dependency>
|
||||||
<groupId>org.spigotmc</groupId>
|
<groupId>org.bukkit</groupId>
|
||||||
<artifactId>spigot-api</artifactId>
|
<artifactId>bukkit</artifactId>
|
||||||
<version>1.8-R0.1-SNAPSHOT</version>
|
<version>1.9-R0.1-SNAPSHOT</version>
|
||||||
|
</dependency>
|
||||||
|
<dependency>
|
||||||
|
<groupId>net.milkbowl.vault</groupId>
|
||||||
|
<artifactId>VaultAPI</artifactId>
|
||||||
|
<version>1.5</version>
|
||||||
|
<scope>provided</scope>
|
||||||
</dependency>
|
</dependency>
|
||||||
|
|
||||||
<dependency>
|
|
||||||
<groupId>net.milkbowl.vault</groupId>
|
|
||||||
<artifactId>VaultAPI</artifactId>
|
|
||||||
<version>1.5</version>
|
|
||||||
<scope>provided</scope>
|
|
||||||
</dependency>
|
|
||||||
|
|
||||||
<dependency>
|
<dependency>
|
||||||
<groupId>com.sk89q</groupId>
|
<groupId>com.sk89q</groupId>
|
||||||
<artifactId>worldguard</artifactId>
|
<artifactId>worldguard</artifactId>
|
||||||
<version>6.0.0-SNAPSHOT</version>
|
<version>6.1</version>
|
||||||
</dependency>
|
</dependency>
|
||||||
|
|
||||||
<dependency>
|
<dependency>
|
||||||
<groupId>com.dre</groupId>
|
<groupId>com.griefcraft.lwc</groupId>
|
||||||
<artifactId>managerxl</artifactId>
|
<artifactId>LWCPlugin</artifactId>
|
||||||
<version>0.0.1-SNAPSHOT</version>
|
<version>1.7.2</version>
|
||||||
<scope>compile</scope>
|
|
||||||
<type>jar</type>
|
|
||||||
</dependency>
|
</dependency>
|
||||||
|
|
||||||
<dependency>
|
|
||||||
<groupId>com.griefcraft</groupId>
|
|
||||||
<artifactId>lwc</artifactId>
|
|
||||||
<version>4.4.0</version>
|
|
||||||
<scope>compile</scope>
|
|
||||||
<type>jar</type>
|
|
||||||
</dependency>
|
|
||||||
|
|
||||||
<dependency>
|
<dependency>
|
||||||
<groupId>me.ryanhamshire</groupId>
|
<groupId>me.ryanhamshire</groupId>
|
||||||
<artifactId>griefprevention</artifactId>
|
<artifactId>GriefPrevention</artifactId>
|
||||||
<version>7.8</version>
|
<version>14.5.1</version>
|
||||||
<scope>compile</scope>
|
<scope>compile</scope>
|
||||||
<type>jar</type>
|
|
||||||
</dependency>
|
</dependency>
|
||||||
|
|
||||||
<dependency>
|
<dependency>
|
||||||
<groupId>de.diddiz.LogBlock</groupId>
|
<groupId>de.diddiz</groupId>
|
||||||
<artifactId>LogBlock</artifactId>
|
<artifactId>logblock</artifactId>
|
||||||
<version>1.80</version>
|
<version>1.94</version>
|
||||||
<scope>compile</scope>
|
|
||||||
<type>jar</type>
|
|
||||||
</dependency>
|
</dependency>
|
||||||
</dependencies>
|
</dependencies>
|
||||||
</project>
|
</project>
|
||||||
|
@ -1,7 +1,7 @@
|
|||||||
name: Brewery
|
name: ${project.name}
|
||||||
version: 1.3.2
|
version: ${project.version}
|
||||||
main: com.dre.brewery.P
|
main: com.dre.brewery.P
|
||||||
authors: [Milan Albrecht, Frank Baumann]
|
authors: [Milan Albrecht, Frank Baumann, ProgrammerDan]
|
||||||
softdepend: [LWC, LogBlock, WorldGuard, GriefPrevention, Vault]
|
softdepend: [LWC, LogBlock, WorldGuard, GriefPrevention, Vault]
|
||||||
commands:
|
commands:
|
||||||
brewery:
|
brewery:
|
||||||
@ -110,4 +110,4 @@ permissions:
|
|||||||
brewery.bypass.overdrink:
|
brewery.bypass.overdrink:
|
||||||
description: Will despite config-setting not be kicked on overdrink
|
description: Will despite config-setting not be kicked on overdrink
|
||||||
brewery.bypass.teleport:
|
brewery.bypass.teleport:
|
||||||
description: Will despite config-setting not be teleported on login
|
description: Will despite config-setting not be teleported on login
|
||||||
|
@ -1,16 +1,15 @@
|
|||||||
package com.dre.brewery;
|
package com.dre.brewery;
|
||||||
|
|
||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
|
import java.util.HashMap;
|
||||||
import java.util.HashSet;
|
import java.util.HashSet;
|
||||||
import java.util.Map;
|
import java.util.Map;
|
||||||
import java.util.HashMap;
|
|
||||||
import java.util.Set;
|
import java.util.Set;
|
||||||
|
import org.bukkit.Material;
|
||||||
import org.bukkit.configuration.ConfigurationSection;
|
import org.bukkit.configuration.ConfigurationSection;
|
||||||
import org.bukkit.inventory.ItemStack;
|
import org.bukkit.inventory.ItemStack;
|
||||||
import org.bukkit.Material;
|
|
||||||
import org.bukkit.potion.PotionEffectType;
|
|
||||||
import org.bukkit.inventory.meta.PotionMeta;
|
import org.bukkit.inventory.meta.PotionMeta;
|
||||||
|
import org.bukkit.potion.PotionEffectType;
|
||||||
|
|
||||||
public class BIngredients {
|
public class BIngredients {
|
||||||
public static Set<Material> possibleIngredients = new HashSet<Material>();
|
public static Set<Material> possibleIngredients = new HashSet<Material>();
|
||||||
@ -84,7 +83,11 @@ public class BIngredients {
|
|||||||
Brew.addOrReplaceEffects(potionMeta, brew.getEffects(), brew.getQuality());
|
Brew.addOrReplaceEffects(potionMeta, brew.getEffects(), brew.getQuality());
|
||||||
|
|
||||||
cookedName = cookRecipe.getName(quality);
|
cookedName = cookRecipe.getName(quality);
|
||||||
potion.setDurability(Brew.PotionColor.valueOf(cookRecipe.getColor()).getColorId(false));
|
if (P.use1_9) {
|
||||||
|
potionMeta.setMainEffect(Brew.PotionColor.valueOf(cookRecipe.getColor()).getEffect());
|
||||||
|
} else {
|
||||||
|
potion.setDurability(Brew.PotionColor.valueOf(cookRecipe.getColor()).getColorId(false));
|
||||||
|
}
|
||||||
|
|
||||||
} else {
|
} else {
|
||||||
// new base potion
|
// new base potion
|
||||||
@ -92,14 +95,22 @@ public class BIngredients {
|
|||||||
|
|
||||||
if (state <= 1) {
|
if (state <= 1) {
|
||||||
cookedName = P.p.languageReader.get("Brew_ThickBrew");
|
cookedName = P.p.languageReader.get("Brew_ThickBrew");
|
||||||
potion.setDurability(Brew.PotionColor.BLUE.getColorId(false));
|
if (P.use1_9) {
|
||||||
|
potionMeta.setMainEffect(Brew.PotionColor.BLUE.getEffect());
|
||||||
|
} else {
|
||||||
|
potion.setDurability(Brew.PotionColor.BLUE.getColorId(false));
|
||||||
|
}
|
||||||
} else {
|
} else {
|
||||||
for (Material ingredient : materials.keySet()) {
|
for (Material ingredient : materials.keySet()) {
|
||||||
if (cookedNames.containsKey(ingredient)) {
|
if (cookedNames.containsKey(ingredient)) {
|
||||||
// if more than half of the ingredients is of one kind
|
// if more than half of the ingredients is of one kind
|
||||||
if (materials.get(ingredient) > (getIngredientsCount() / 2)) {
|
if (materials.get(ingredient) > (getIngredientsCount() / 2)) {
|
||||||
cookedName = cookedNames.get(ingredient);
|
cookedName = cookedNames.get(ingredient);
|
||||||
potion.setDurability(Brew.PotionColor.CYAN.getColorId(true));
|
if (P.use1_9) {
|
||||||
|
potionMeta.setMainEffect(Brew.PotionColor.CYAN.getEffect());
|
||||||
|
} else {
|
||||||
|
potion.setDurability(Brew.PotionColor.CYAN.getColorId(true));
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -108,7 +119,11 @@ public class BIngredients {
|
|||||||
if (cookedName == null) {
|
if (cookedName == null) {
|
||||||
// if no name could be found
|
// if no name could be found
|
||||||
cookedName = P.p.languageReader.get("Brew_Undefined");
|
cookedName = P.p.languageReader.get("Brew_Undefined");
|
||||||
potion.setDurability(Brew.PotionColor.CYAN.getColorId(true));
|
if (P.use1_9) {
|
||||||
|
potionMeta.setMainEffect(Brew.PotionColor.CYAN.getEffect());
|
||||||
|
} else {
|
||||||
|
potion.setDurability(Brew.PotionColor.CYAN.getColorId(true));
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
potionMeta.setDisplayName(P.p.color("&f" + cookedName));
|
potionMeta.setDisplayName(P.p.color("&f" + cookedName));
|
||||||
|
@ -1,22 +1,21 @@
|
|||||||
package com.dre.brewery;
|
package com.dre.brewery;
|
||||||
|
|
||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
import java.util.Map;
|
|
||||||
import java.util.HashMap;
|
import java.util.HashMap;
|
||||||
import java.util.Iterator;
|
import java.util.Iterator;
|
||||||
|
import java.util.Map;
|
||||||
import java.util.UUID;
|
import java.util.UUID;
|
||||||
|
import org.bukkit.Location;
|
||||||
|
import org.bukkit.Material;
|
||||||
import org.bukkit.OfflinePlayer;
|
import org.bukkit.OfflinePlayer;
|
||||||
import org.bukkit.event.player.PlayerMoveEvent;
|
import org.bukkit.configuration.ConfigurationSection;
|
||||||
import org.bukkit.entity.Player;
|
|
||||||
import org.bukkit.entity.Entity;
|
import org.bukkit.entity.Entity;
|
||||||
import org.bukkit.entity.Item;
|
import org.bukkit.entity.Item;
|
||||||
|
import org.bukkit.entity.Player;
|
||||||
|
import org.bukkit.event.player.PlayerMoveEvent;
|
||||||
import org.bukkit.inventory.ItemStack;
|
import org.bukkit.inventory.ItemStack;
|
||||||
import org.bukkit.Material;
|
|
||||||
import org.bukkit.util.Vector;
|
|
||||||
import org.bukkit.Location;
|
|
||||||
import org.bukkit.potion.PotionEffectType;
|
import org.bukkit.potion.PotionEffectType;
|
||||||
import org.bukkit.configuration.ConfigurationSection;
|
import org.bukkit.util.Vector;
|
||||||
|
|
||||||
public class BPlayer {
|
public class BPlayer {
|
||||||
private static Map<String, BPlayer> players = new HashMap<String, BPlayer>();// Players name/uuid and BPlayer
|
private static Map<String, BPlayer> players = new HashMap<String, BPlayer>();// Players name/uuid and BPlayer
|
||||||
@ -339,10 +338,6 @@ public class BPlayer {
|
|||||||
Location home = null;
|
Location home = null;
|
||||||
if (homeType.equalsIgnoreCase("bed")) {
|
if (homeType.equalsIgnoreCase("bed")) {
|
||||||
home = player.getBedSpawnLocation();
|
home = player.getBedSpawnLocation();
|
||||||
} else if (homeType.equalsIgnoreCase("ManagerXL")) {
|
|
||||||
if (com.dre.managerxl.MPlayer.get(player.getName()) != null) {
|
|
||||||
home = com.dre.managerxl.MPlayer.get(player.getName()).getHome();
|
|
||||||
}
|
|
||||||
} else if (homeType.startsWith("cmd: ")) {
|
} else if (homeType.startsWith("cmd: ")) {
|
||||||
player.performCommand(homeType.substring(5));
|
player.performCommand(homeType.substring(5));
|
||||||
} else if (homeType.startsWith("cmd:")) {
|
} else if (homeType.startsWith("cmd:")) {
|
||||||
|
@ -2,9 +2,8 @@ package com.dre.brewery;
|
|||||||
|
|
||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
|
||||||
import org.bukkit.configuration.ConfigurationSection;
|
|
||||||
import org.bukkit.Material;
|
import org.bukkit.Material;
|
||||||
|
import org.bukkit.configuration.ConfigurationSection;
|
||||||
import org.bukkit.inventory.ItemStack;
|
import org.bukkit.inventory.ItemStack;
|
||||||
import org.bukkit.inventory.meta.PotionMeta;
|
import org.bukkit.inventory.meta.PotionMeta;
|
||||||
import org.bukkit.potion.PotionEffectType;
|
import org.bukkit.potion.PotionEffectType;
|
||||||
@ -205,7 +204,11 @@ public class BRecipe {
|
|||||||
|
|
||||||
Brew brew = new Brew(uid, bIngredients, quality, distillruns, getAge(), wood, getName(5), false, false, true);
|
Brew brew = new Brew(uid, bIngredients, quality, distillruns, getAge(), wood, getName(5), false, false, true);
|
||||||
|
|
||||||
potion.setDurability(Brew.PotionColor.valueOf(getColor()).getColorId(false));
|
if (P.use1_9) {
|
||||||
|
potionMeta.setMainEffect(Brew.PotionColor.valueOf(getColor()).getEffect());
|
||||||
|
} else {
|
||||||
|
potion.setDurability(Brew.PotionColor.valueOf(getColor()).getColorId(false));
|
||||||
|
}
|
||||||
potionMeta.setDisplayName(P.p.color("&f" + getName(quality)));
|
potionMeta.setDisplayName(P.p.color("&f" + getName(quality)));
|
||||||
// This effect stores the UID in its Duration
|
// This effect stores the UID in its Duration
|
||||||
potionMeta.addCustomEffect((PotionEffectType.REGENERATION).createEffect((uid * 4), 0), true);
|
potionMeta.addCustomEffect((PotionEffectType.REGENERATION).createEffect((uid * 4), 0), true);
|
||||||
|
@ -1,22 +1,20 @@
|
|||||||
package com.dre.brewery;
|
package com.dre.brewery;
|
||||||
|
|
||||||
import java.util.Map;
|
|
||||||
import java.util.HashMap;
|
|
||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
|
import java.util.HashMap;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
import java.util.Map;
|
||||||
import org.bukkit.Material;
|
import org.bukkit.Material;
|
||||||
import org.bukkit.configuration.ConfigurationSection;
|
import org.bukkit.configuration.ConfigurationSection;
|
||||||
|
import org.bukkit.inventory.BrewerInventory;
|
||||||
import org.bukkit.inventory.ItemStack;
|
import org.bukkit.inventory.ItemStack;
|
||||||
import org.bukkit.inventory.meta.PotionMeta;
|
import org.bukkit.inventory.meta.PotionMeta;
|
||||||
import org.bukkit.potion.PotionEffect;
|
import org.bukkit.potion.PotionEffect;
|
||||||
import org.bukkit.potion.PotionEffectType;
|
import org.bukkit.potion.PotionEffectType;
|
||||||
import org.bukkit.inventory.BrewerInventory;
|
|
||||||
|
|
||||||
public class Brew {
|
public class Brew {
|
||||||
|
|
||||||
// represents the liquid in the brewed Potions
|
// represents the liquid in the brewed Potions
|
||||||
|
|
||||||
public static Map<Integer, Brew> potions = new HashMap<Integer, Brew>();
|
public static Map<Integer, Brew> potions = new HashMap<Integer, Brew>();
|
||||||
public static Boolean colorInBarrels; // color the Lore while in Barrels
|
public static Boolean colorInBarrels; // color the Lore while in Barrels
|
||||||
public static Boolean colorInBrewer; // color the Lore while in Brewer
|
public static Boolean colorInBrewer; // color the Lore while in Brewer
|
||||||
@ -87,7 +85,6 @@ public class Brew {
|
|||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
// returns UID of custom Potion item
|
// returns UID of custom Potion item
|
||||||
public static int getUID(ItemStack item) {
|
public static int getUID(ItemStack item) {
|
||||||
return getUID((PotionMeta) item.getItemMeta());
|
return getUID((PotionMeta) item.getItemMeta());
|
||||||
@ -210,7 +207,7 @@ public class Brew {
|
|||||||
alc *= 1 - ((float) (10 - quality) * 0.04);
|
alc *= 1 - ((float) (10 - quality) * 0.04);
|
||||||
// distillable Potions should have half alc after one and full alc after all needed distills
|
// distillable Potions should have half alc after one and full alc after all needed distills
|
||||||
alc /= 2;
|
alc /= 2;
|
||||||
alc *= 1.0F + ((float) distillRuns / currentRecipe.getDistillRuns()) ;
|
alc *= 1.0F + ((float) distillRuns / currentRecipe.getDistillRuns());
|
||||||
} else {
|
} else {
|
||||||
// quality decides 10% - 100%
|
// quality decides 10% - 100%
|
||||||
alc *= ((float) quality / 10.0);
|
alc *= ((float) quality / 10.0);
|
||||||
@ -294,7 +291,15 @@ public class Brew {
|
|||||||
this.stat = stat;
|
this.stat = stat;
|
||||||
if (currentRecipe != null && canDistill()) {
|
if (currentRecipe != null && canDistill()) {
|
||||||
if (stat) {
|
if (stat) {
|
||||||
potion.setDurability(PotionColor.valueOf(currentRecipe.getColor()).getColorId(false));
|
if (P.use1_9) {
|
||||||
|
PotionMeta potionMeta = (PotionMeta) potion.getItemMeta();
|
||||||
|
potionMeta.setMainEffect(PotionColor.valueOf(currentRecipe.getColor()).getEffect());
|
||||||
|
} else {
|
||||||
|
potion.setDurability(PotionColor.valueOf(currentRecipe.getColor()).getColorId(false));
|
||||||
|
}
|
||||||
|
} else if (P.use1_9) {
|
||||||
|
PotionMeta potionMeta = (PotionMeta) potion.getItemMeta();
|
||||||
|
potionMeta.setMainEffect(PotionColor.valueOf(currentRecipe.getColor()).getEffect());
|
||||||
} else {
|
} else {
|
||||||
potion.setDurability(PotionColor.valueOf(currentRecipe.getColor()).getColorId(true));
|
potion.setDurability(PotionColor.valueOf(currentRecipe.getColor()).getColorId(true));
|
||||||
}
|
}
|
||||||
@ -302,7 +307,6 @@ public class Brew {
|
|||||||
}
|
}
|
||||||
|
|
||||||
// Distilling section ---------------
|
// Distilling section ---------------
|
||||||
|
|
||||||
// distill all custom potions in the brewer
|
// distill all custom potions in the brewer
|
||||||
public static void distillAll(BrewerInventory inv, Boolean[] contents) {
|
public static void distillAll(BrewerInventory inv, Boolean[] contents) {
|
||||||
int slot = 0;
|
int slot = 0;
|
||||||
@ -332,12 +336,21 @@ public class Brew {
|
|||||||
|
|
||||||
addOrReplaceEffects(potionMeta, getEffects(), quality);
|
addOrReplaceEffects(potionMeta, getEffects(), quality);
|
||||||
potionMeta.setDisplayName(P.p.color("&f" + recipe.getName(quality)));
|
potionMeta.setDisplayName(P.p.color("&f" + recipe.getName(quality)));
|
||||||
slotItem.setDurability(PotionColor.valueOf(recipe.getColor()).getColorId(canDistill()));
|
if (P.use1_9) {
|
||||||
|
potionMeta.setMainEffect(PotionColor.valueOf(recipe.getColor()).getEffect());
|
||||||
|
} else {
|
||||||
|
slotItem.setDurability(PotionColor.valueOf(recipe.getColor()).getColorId(canDistill()));
|
||||||
|
}
|
||||||
|
|
||||||
} else {
|
} else {
|
||||||
quality = 0;
|
quality = 0;
|
||||||
removeEffects(potionMeta);
|
removeEffects(potionMeta);
|
||||||
potionMeta.setDisplayName(P.p.color("&f" + P.p.languageReader.get("Brew_DistillUndefined")));
|
potionMeta.setDisplayName(P.p.color("&f" + P.p.languageReader.get("Brew_DistillUndefined")));
|
||||||
slotItem.setDurability(PotionColor.GREY.getColorId(canDistill()));
|
if (P.use1_9) {
|
||||||
|
potionMeta.setMainEffect(PotionColor.GREY.getEffect());
|
||||||
|
} else {
|
||||||
|
slotItem.setDurability(PotionColor.GREY.getColorId(canDistill()));
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// Distill Lore
|
// Distill Lore
|
||||||
@ -356,7 +369,6 @@ public class Brew {
|
|||||||
}
|
}
|
||||||
|
|
||||||
// Ageing Section ------------------
|
// Ageing Section ------------------
|
||||||
|
|
||||||
public void age(ItemStack item, float time, byte woodType) {
|
public void age(ItemStack item, float time, byte woodType) {
|
||||||
if (stat) {
|
if (stat) {
|
||||||
return;
|
return;
|
||||||
@ -364,15 +376,13 @@ public class Brew {
|
|||||||
|
|
||||||
PotionMeta potionMeta = (PotionMeta) item.getItemMeta();
|
PotionMeta potionMeta = (PotionMeta) item.getItemMeta();
|
||||||
ageTime += time;
|
ageTime += time;
|
||||||
|
|
||||||
// if younger than half a day, it shouldnt get aged form
|
// if younger than half a day, it shouldnt get aged form
|
||||||
if (ageTime > 0.5) {
|
if (ageTime > 0.5) {
|
||||||
if (wood == 0) {
|
if (wood == 0) {
|
||||||
wood = woodType;
|
wood = woodType;
|
||||||
} else {
|
} else if (wood != woodType) {
|
||||||
if (wood != woodType) {
|
woodShift(time, woodType);
|
||||||
woodShift(time, woodType);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
BRecipe recipe = ingredients.getAgeRecipe(wood, ageTime, distillRuns > 0);
|
BRecipe recipe = ingredients.getAgeRecipe(wood, ageTime, distillRuns > 0);
|
||||||
if (recipe != null) {
|
if (recipe != null) {
|
||||||
@ -381,12 +391,20 @@ public class Brew {
|
|||||||
|
|
||||||
addOrReplaceEffects(potionMeta, getEffects(), quality);
|
addOrReplaceEffects(potionMeta, getEffects(), quality);
|
||||||
potionMeta.setDisplayName(P.p.color("&f" + recipe.getName(quality)));
|
potionMeta.setDisplayName(P.p.color("&f" + recipe.getName(quality)));
|
||||||
item.setDurability(PotionColor.valueOf(recipe.getColor()).getColorId(canDistill()));
|
if (P.use1_9) {
|
||||||
|
potionMeta.setMainEffect(PotionColor.valueOf(recipe.getColor()).getEffect());
|
||||||
|
} else {
|
||||||
|
item.setDurability(PotionColor.valueOf(recipe.getColor()).getColorId(canDistill()));
|
||||||
|
}
|
||||||
} else {
|
} else {
|
||||||
quality = 0;
|
quality = 0;
|
||||||
removeEffects(potionMeta);
|
removeEffects(potionMeta);
|
||||||
potionMeta.setDisplayName(P.p.color("&f" + P.p.languageReader.get("Brew_BadPotion")));
|
potionMeta.setDisplayName(P.p.color("&f" + P.p.languageReader.get("Brew_BadPotion")));
|
||||||
item.setDurability(PotionColor.GREY.getColorId(canDistill()));
|
if (P.use1_9) {
|
||||||
|
potionMeta.setMainEffect(PotionColor.GREY.getEffect());
|
||||||
|
} else {
|
||||||
|
item.setDurability(PotionColor.GREY.getColorId(canDistill()));
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -434,7 +452,6 @@ public class Brew {
|
|||||||
}
|
}
|
||||||
|
|
||||||
// Lore -----------
|
// Lore -----------
|
||||||
|
|
||||||
// Converts to/from qualitycolored Lore
|
// Converts to/from qualitycolored Lore
|
||||||
public void convertLore(PotionMeta meta, Boolean toQuality) {
|
public void convertLore(PotionMeta meta, Boolean toQuality) {
|
||||||
if (currentRecipe == null) {
|
if (currentRecipe == null) {
|
||||||
@ -521,14 +538,12 @@ public class Brew {
|
|||||||
if (currentRecipe.getWood() > 0) {
|
if (currentRecipe.getWood() > 0) {
|
||||||
int quality = ingredients.getWoodQuality(currentRecipe, wood);
|
int quality = ingredients.getWoodQuality(currentRecipe, wood);
|
||||||
addOrReplaceLore(meta, getQualityColor(quality), P.p.languageReader.get("Brew_Woodtype"));
|
addOrReplaceLore(meta, getQualityColor(quality), P.p.languageReader.get("Brew_Woodtype"));
|
||||||
} else {
|
} else if (meta.hasLore()) {
|
||||||
if (meta.hasLore()) {
|
List<String> existingLore = meta.getLore();
|
||||||
List<String> existingLore = meta.getLore();
|
int index = indexOfSubstring(existingLore, P.p.languageReader.get("Brew_Woodtype"));
|
||||||
int index = indexOfSubstring(existingLore, P.p.languageReader.get("Brew_Woodtype"));
|
if (index > -1) {
|
||||||
if (index > -1) {
|
existingLore.remove(index);
|
||||||
existingLore.remove(index);
|
meta.setLore(existingLore);
|
||||||
meta.setLore(existingLore);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -587,7 +602,7 @@ public class Brew {
|
|||||||
}
|
}
|
||||||
|
|
||||||
// True if the PotionMeta has colored Lore
|
// True if the PotionMeta has colored Lore
|
||||||
public static Boolean hasColorLore(PotionMeta meta) {
|
public static Boolean hasColorLore(PotionMeta meta) {
|
||||||
return meta.hasLore() && !meta.getLore().get(1).startsWith(P.p.color("&7"));
|
return meta.hasLore() && !meta.getLore().get(1).startsWith(P.p.color("&7"));
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -645,23 +660,25 @@ public class Brew {
|
|||||||
}
|
}
|
||||||
|
|
||||||
public static enum PotionColor {
|
public static enum PotionColor {
|
||||||
PINK(1),
|
PINK(1, PotionEffectType.REGENERATION),
|
||||||
CYAN(2),
|
CYAN(2, PotionEffectType.SPEED),
|
||||||
ORANGE(3),
|
ORANGE(3, PotionEffectType.FIRE_RESISTANCE),
|
||||||
GREEN(4),
|
GREEN(4, PotionEffectType.POISON),
|
||||||
BRIGHT_RED(5),
|
BRIGHT_RED(5, PotionEffectType.HEAL),
|
||||||
BLUE(6),
|
BLUE(6, PotionEffectType.NIGHT_VISION),
|
||||||
BLACK(8),
|
BLACK(8, PotionEffectType.WEAKNESS),
|
||||||
RED(9),
|
RED(9, PotionEffectType.INCREASE_DAMAGE),
|
||||||
GREY(10),
|
GREY(10, PotionEffectType.SLOW),
|
||||||
WATER(11),
|
WATER(11, PotionEffectType.WATER_BREATHING),
|
||||||
DARK_RED(12),
|
DARK_RED(12, PotionEffectType.HARM),
|
||||||
BRIGHT_GREY(14);
|
BRIGHT_GREY(14, PotionEffectType.INVISIBILITY);
|
||||||
|
|
||||||
private final int colorId;
|
private final int colorId;
|
||||||
|
private final PotionEffectType effect;
|
||||||
|
|
||||||
private PotionColor(int colorId) {
|
private PotionColor(int colorId, PotionEffectType effect) {
|
||||||
this.colorId = colorId;
|
this.colorId = colorId;
|
||||||
|
this.effect = effect;
|
||||||
}
|
}
|
||||||
|
|
||||||
// gets the Damage Value, that sets a color on the potion
|
// gets the Damage Value, that sets a color on the potion
|
||||||
@ -672,6 +689,11 @@ public class Brew {
|
|||||||
}
|
}
|
||||||
return (short) (colorId + 32);
|
return (short) (colorId + 32);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public PotionEffectType getEffect() {
|
||||||
|
return effect;
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
@ -1,46 +1,44 @@
|
|||||||
package com.dre.brewery;
|
package com.dre.brewery;
|
||||||
|
|
||||||
import java.io.FileOutputStream;
|
import com.dre.brewery.filedata.*;
|
||||||
import java.io.InputStream;
|
import com.dre.brewery.integration.LogBlockBarrel;
|
||||||
import java.io.OutputStream;
|
|
||||||
import java.util.Map;
|
|
||||||
import java.util.List;
|
|
||||||
import java.util.ArrayList;
|
|
||||||
import java.util.ListIterator;
|
|
||||||
import java.util.HashMap;
|
|
||||||
import java.io.IOException;
|
|
||||||
import java.io.File;
|
|
||||||
import java.util.UUID;
|
|
||||||
|
|
||||||
import org.bukkit.entity.Player;
|
|
||||||
import org.bukkit.inventory.ItemStack;
|
|
||||||
import org.bukkit.plugin.java.JavaPlugin;
|
|
||||||
import org.bukkit.configuration.file.FileConfiguration;
|
|
||||||
import org.bukkit.configuration.file.YamlConfiguration;
|
|
||||||
import org.bukkit.configuration.ConfigurationSection;
|
|
||||||
|
|
||||||
import com.dre.brewery.integration.WGBarrel;
|
import com.dre.brewery.integration.WGBarrel;
|
||||||
import com.dre.brewery.integration.WGBarrelNew;
|
import com.dre.brewery.integration.WGBarrelNew;
|
||||||
import com.dre.brewery.integration.WGBarrelOld;
|
import com.dre.brewery.integration.WGBarrelOld;
|
||||||
import org.apache.commons.lang.math.NumberUtils;
|
|
||||||
import org.bukkit.event.HandlerList;
|
|
||||||
import org.bukkit.Bukkit;
|
|
||||||
import org.bukkit.World;
|
|
||||||
import org.bukkit.Location;
|
|
||||||
import org.bukkit.command.CommandSender;
|
|
||||||
import org.bukkit.ChatColor;
|
|
||||||
import org.bukkit.Material;
|
|
||||||
import org.bukkit.block.Block;
|
|
||||||
|
|
||||||
import com.dre.brewery.listeners.*;
|
import com.dre.brewery.listeners.*;
|
||||||
import com.dre.brewery.filedata.*;
|
import java.io.File;
|
||||||
import com.dre.brewery.integration.LogBlockBarrel;
|
import java.io.FileOutputStream;
|
||||||
|
import java.io.IOException;
|
||||||
|
import java.io.InputStream;
|
||||||
|
import java.io.OutputStream;
|
||||||
|
import java.util.ArrayList;
|
||||||
|
import java.util.HashMap;
|
||||||
|
import java.util.List;
|
||||||
|
import java.util.ListIterator;
|
||||||
|
import java.util.Map;
|
||||||
|
import java.util.UUID;
|
||||||
|
import org.apache.commons.lang.math.NumberUtils;
|
||||||
|
import org.bukkit.Bukkit;
|
||||||
|
import org.bukkit.ChatColor;
|
||||||
|
import org.bukkit.Location;
|
||||||
|
import org.bukkit.Material;
|
||||||
|
import org.bukkit.World;
|
||||||
|
import org.bukkit.block.Block;
|
||||||
|
import org.bukkit.command.CommandSender;
|
||||||
|
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.event.HandlerList;
|
||||||
|
import org.bukkit.inventory.ItemStack;
|
||||||
|
import org.bukkit.plugin.java.JavaPlugin;
|
||||||
|
|
||||||
public class P extends JavaPlugin {
|
public class P extends JavaPlugin {
|
||||||
public static P p;
|
public static P p;
|
||||||
public static String configVersion = "1.3.1";
|
public static String configVersion = "1.3.1";
|
||||||
public static boolean debug;
|
public static boolean debug;
|
||||||
public static boolean useUUID;
|
public static boolean useUUID;
|
||||||
|
public static boolean use1_9;
|
||||||
public static boolean updateCheck;
|
public static boolean updateCheck;
|
||||||
|
|
||||||
// Third Party Enabled
|
// Third Party Enabled
|
||||||
@ -57,6 +55,7 @@ public class P extends JavaPlugin {
|
|||||||
public EntityListener entityListener;
|
public EntityListener entityListener;
|
||||||
public InventoryListener inventoryListener;
|
public InventoryListener inventoryListener;
|
||||||
public WorldListener worldListener;
|
public WorldListener worldListener;
|
||||||
|
public Compat1_9 compat1_9;
|
||||||
|
|
||||||
// Language
|
// Language
|
||||||
public String language;
|
public String language;
|
||||||
@ -68,7 +67,11 @@ public class P extends JavaPlugin {
|
|||||||
|
|
||||||
// Version check
|
// Version check
|
||||||
String v = Bukkit.getBukkitVersion();
|
String v = Bukkit.getBukkitVersion();
|
||||||
useUUID = !v.matches(".*1\\.[1-6].*") && !v.matches(".*1\\.7\\.[0-5].*");
|
useUUID = !v.matches(".*1\\.[0-6].*") && !v.matches(".*1\\.7\\.[0-5].*");
|
||||||
|
use1_9 = !v.matches(".*1\\.[0-8].*");
|
||||||
|
if (use1_9) {
|
||||||
|
log("&cExperimental support for Bukkit 1.9 enabled.");
|
||||||
|
}
|
||||||
|
|
||||||
// load the Config
|
// load the Config
|
||||||
try {
|
try {
|
||||||
@ -94,6 +97,7 @@ public class P extends JavaPlugin {
|
|||||||
entityListener = new EntityListener();
|
entityListener = new EntityListener();
|
||||||
inventoryListener = new InventoryListener();
|
inventoryListener = new InventoryListener();
|
||||||
worldListener = new WorldListener();
|
worldListener = new WorldListener();
|
||||||
|
compat1_9 = new Compat1_9();
|
||||||
getCommand("Brewery").setExecutor(new CommandListener());
|
getCommand("Brewery").setExecutor(new CommandListener());
|
||||||
|
|
||||||
p.getServer().getPluginManager().registerEvents(blockListener, p);
|
p.getServer().getPluginManager().registerEvents(blockListener, p);
|
||||||
@ -101,6 +105,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(compat1_9, p);
|
||||||
|
}
|
||||||
|
|
||||||
// Heartbeat
|
// Heartbeat
|
||||||
p.getServer().getScheduler().runTaskTimer(p, new BreweryRunnable(), 650, 1200);
|
p.getServer().getScheduler().runTaskTimer(p, new BreweryRunnable(), 650, 1200);
|
||||||
|
@ -1,42 +1,47 @@
|
|||||||
package com.dre.brewery.integration;
|
package com.dre.brewery.integration;
|
||||||
|
|
||||||
|
import com.dre.brewery.P;
|
||||||
|
import me.ryanhamshire.GriefPrevention.Claim;
|
||||||
|
import me.ryanhamshire.GriefPrevention.GriefPrevention;
|
||||||
|
import me.ryanhamshire.GriefPrevention.PlayerData;
|
||||||
import org.bukkit.block.Block;
|
import org.bukkit.block.Block;
|
||||||
import org.bukkit.entity.Player;
|
import org.bukkit.entity.Player;
|
||||||
|
|
||||||
import com.dre.brewery.P;
|
|
||||||
import me.ryanhamshire.GriefPrevention.Configuration.WorldConfig;
|
|
||||||
import me.ryanhamshire.GriefPrevention.GriefPrevention;
|
|
||||||
import me.ryanhamshire.GriefPrevention.Messages;
|
|
||||||
import me.ryanhamshire.GriefPrevention.PlayerData;
|
|
||||||
import me.ryanhamshire.GriefPrevention.TextMode;
|
|
||||||
|
|
||||||
public class GriefPreventionBarrel {
|
public class GriefPreventionBarrel {
|
||||||
|
|
||||||
|
static P brewery = P.p;
|
||||||
|
static GriefPrevention griefPrevention = GriefPrevention.instance;
|
||||||
|
|
||||||
public static boolean checkAccess(Player player, Block sign) {
|
public static boolean checkAccess(Player player, Block sign) {
|
||||||
|
PlayerData playerData = griefPrevention.dataStore.getPlayerData(player.getUniqueId());
|
||||||
|
|
||||||
WorldConfig wc = GriefPrevention.instance.getWorldCfg(player.getWorld());
|
if (!griefPrevention.claimsEnabledForWorld(player.getWorld()) || playerData.ignoreClaims || !griefPrevention.config_claims_preventTheft) {
|
||||||
/*if (!wc.Enabled()) {
|
|
||||||
return true;
|
return true;
|
||||||
}*/
|
}
|
||||||
|
|
||||||
PlayerData playerData = GriefPrevention.instance.dataStore.getPlayerData(player.getName());
|
|
||||||
|
|
||||||
// block container use during pvp combat
|
// block container use during pvp combat
|
||||||
if (playerData.inPvpCombat() && wc.getPvPBlockContainers()) {
|
if (playerData.inPvpCombat()) {
|
||||||
GriefPrevention.sendMessage(player, TextMode.Err, Messages.PvPNoContainers);
|
brewery.msg(player, brewery.languageReader.get("Error_NoBarrelAccess"));
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
// check permissions for the claim the Barrel is in
|
// check permissions for the claim the Barrel is in
|
||||||
if (wc.getContainersRules().Allowed(sign.getLocation(), player, true).Denied()) {
|
Claim claim = griefPrevention.dataStore.getClaimAt(sign.getLocation(), false, playerData.lastClaim);
|
||||||
P.p.msg(player, P.p.languageReader.get("Error_NoBarrelAccess"));
|
if (claim != null) {
|
||||||
return false;
|
playerData.lastClaim = claim;
|
||||||
|
String noContainersReason = claim.allowContainers(player);
|
||||||
|
if (noContainersReason != null) {
|
||||||
|
brewery.msg(player, brewery.languageReader.get("Error_NoBarrelAccess"));
|
||||||
|
return false;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// drop any pvp protection, as the player opens a barrel
|
// drop any pvp protection, as the player opens a barrel
|
||||||
if (playerData.pvpImmune) {
|
if (playerData.pvpImmune) {
|
||||||
playerData.pvpImmune = false;
|
playerData.pvpImmune = false;
|
||||||
GriefPrevention.sendMessage(player, TextMode.Warn, Messages.PvPImmunityEnd);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
32
src/com/dre/brewery/listeners/Compat1_9.java
Normal file
32
src/com/dre/brewery/listeners/Compat1_9.java
Normal file
@ -0,0 +1,32 @@
|
|||||||
|
package com.dre.brewery.listeners;
|
||||||
|
|
||||||
|
import com.dre.brewery.Brew;
|
||||||
|
import org.bukkit.Material;
|
||||||
|
import org.bukkit.event.EventHandler;
|
||||||
|
import org.bukkit.event.Listener;
|
||||||
|
import org.bukkit.event.player.PlayerItemConsumeEvent;
|
||||||
|
import org.bukkit.inventory.ItemStack;
|
||||||
|
import org.bukkit.inventory.meta.PotionMeta;
|
||||||
|
import org.bukkit.potion.PotionData;
|
||||||
|
import org.bukkit.potion.PotionType;
|
||||||
|
|
||||||
|
// Workaround to remove unwanted potion effects
|
||||||
|
public class Compat1_9 implements Listener {
|
||||||
|
|
||||||
|
@EventHandler
|
||||||
|
public void onPlayerDrink(PlayerItemConsumeEvent event) {
|
||||||
|
ItemStack item = event.getItem();
|
||||||
|
Brew brew = Brew.get(item);
|
||||||
|
if (brew == null) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (item.getType() == Material.POTION) {
|
||||||
|
PotionMeta meta = (PotionMeta) item.getItemMeta();
|
||||||
|
// Throw away former "base" effect and replace with MUNDANE.
|
||||||
|
meta.setBasePotionData(new PotionData(PotionType.MUNDANE, false, false));
|
||||||
|
item.setItemMeta(meta);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
@ -1,16 +1,28 @@
|
|||||||
package com.dre.brewery.listeners;
|
package com.dre.brewery.listeners;
|
||||||
|
|
||||||
|
import java.util.HashMap;
|
||||||
|
import java.util.HashSet;
|
||||||
|
import java.util.UUID;
|
||||||
|
|
||||||
|
import org.bukkit.block.Block;
|
||||||
|
import org.bukkit.block.BlockState;
|
||||||
|
import org.bukkit.block.BrewingStand;
|
||||||
|
import org.bukkit.entity.HumanEntity;
|
||||||
import org.bukkit.event.EventHandler;
|
import org.bukkit.event.EventHandler;
|
||||||
import org.bukkit.event.EventPriority;
|
import org.bukkit.event.EventPriority;
|
||||||
import org.bukkit.event.Listener;
|
import org.bukkit.event.Listener;
|
||||||
import org.bukkit.event.inventory.BrewEvent;
|
import org.bukkit.event.inventory.BrewEvent;
|
||||||
import org.bukkit.event.inventory.InventoryClickEvent;
|
import org.bukkit.event.inventory.InventoryClickEvent;
|
||||||
import org.bukkit.event.inventory.InventoryCloseEvent;
|
import org.bukkit.event.inventory.InventoryCloseEvent;
|
||||||
|
import org.bukkit.event.inventory.InventoryOpenEvent;
|
||||||
import org.bukkit.event.inventory.InventoryPickupItemEvent;
|
import org.bukkit.event.inventory.InventoryPickupItemEvent;
|
||||||
import org.bukkit.event.inventory.InventoryType;
|
import org.bukkit.event.inventory.InventoryType;
|
||||||
import org.bukkit.inventory.BrewerInventory;
|
import org.bukkit.inventory.BrewerInventory;
|
||||||
|
import org.bukkit.inventory.Inventory;
|
||||||
import org.bukkit.inventory.meta.PotionMeta;
|
import org.bukkit.inventory.meta.PotionMeta;
|
||||||
import org.bukkit.inventory.ItemStack;
|
import org.bukkit.inventory.ItemStack;
|
||||||
|
import org.bukkit.scheduler.BukkitRunnable;
|
||||||
|
import org.bukkit.Bukkit;
|
||||||
import org.bukkit.Material;
|
import org.bukkit.Material;
|
||||||
|
|
||||||
import com.dre.brewery.Barrel;
|
import com.dre.brewery.Barrel;
|
||||||
@ -18,8 +30,148 @@ import com.dre.brewery.Brew;
|
|||||||
import com.dre.brewery.P;
|
import com.dre.brewery.P;
|
||||||
import com.dre.brewery.integration.LogBlockBarrel;
|
import com.dre.brewery.integration.LogBlockBarrel;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Updated for 1.9 to replicate the "Brewing" process for distilling.
|
||||||
|
* Because of how metadata has changed, the brewer no longer triggers as previously described.
|
||||||
|
* So, I've added some event tracking and manual forcing of the brewing "animation" if the
|
||||||
|
* set of ingredients in the brewer can be distilled.
|
||||||
|
* Nothing here should interfere with vanilla brewing.
|
||||||
|
*
|
||||||
|
* Note in testing I did discover a few ways to "hack" brewing to distill your brews alongside
|
||||||
|
* potions; put fuel and at least one "valid" water bottle w/ a brewing component. You can distill
|
||||||
|
* two brews this way, just remove them before the "final" distillation or you will actually
|
||||||
|
* brew the potion as well.
|
||||||
|
*
|
||||||
|
* @author ProgrammerDan (1.9 distillation update only)
|
||||||
|
*/
|
||||||
public class InventoryListener implements Listener {
|
public class InventoryListener implements Listener {
|
||||||
|
|
||||||
|
/* === Recreating manually the prior BrewEvent behavior. === */
|
||||||
|
private HashSet<UUID> trackedBrewmen = new HashSet<UUID>();
|
||||||
|
private HashMap<Block, Integer> trackedBrewers = new HashMap<Block, Integer>();
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Start tracking distillation for a person when they open the brewer window.
|
||||||
|
* @param event
|
||||||
|
*/
|
||||||
|
@EventHandler(priority = EventPriority.HIGH, ignoreCancelled = true)
|
||||||
|
public void onBrewerOpen(InventoryOpenEvent event) {
|
||||||
|
if (!P.use1_9) return;
|
||||||
|
HumanEntity player = event.getPlayer();
|
||||||
|
Inventory inv = event.getInventory();
|
||||||
|
if (player == null || inv == null || !(inv instanceof BrewerInventory)) return;
|
||||||
|
|
||||||
|
P.p.debugLog("Starting brew inventory tracking");
|
||||||
|
trackedBrewmen.add(player.getUniqueId());
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Stop tracking distillation for a person when they close the brewer window.
|
||||||
|
* @param event
|
||||||
|
*/
|
||||||
|
@EventHandler(priority = EventPriority.HIGH, ignoreCancelled = true)
|
||||||
|
public void onBrewerClose(InventoryCloseEvent event) {
|
||||||
|
if (!P.use1_9) return;
|
||||||
|
HumanEntity player = event.getPlayer();
|
||||||
|
Inventory inv = event.getInventory();
|
||||||
|
if (player == null || inv == null || !(inv instanceof BrewerInventory)) return;
|
||||||
|
|
||||||
|
P.p.debugLog("Stopping brew inventory tracking");
|
||||||
|
trackedBrewmen.remove(player.getUniqueId());
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Clicking can either start or stop the new brew distillation tracking.
|
||||||
|
* Note that server restart will halt any ongoing brewing processes and
|
||||||
|
* they will _not_ restart until a new click event.
|
||||||
|
*
|
||||||
|
* @param event the Click event.
|
||||||
|
*/
|
||||||
|
@EventHandler(priority = EventPriority.HIGH, ignoreCancelled = true)
|
||||||
|
public void onBrewerClick(InventoryClickEvent event) {
|
||||||
|
if (!P.use1_9) return;
|
||||||
|
HumanEntity player = event.getWhoClicked();
|
||||||
|
Inventory inv = event.getInventory();
|
||||||
|
if (player == null || inv == null || !(inv instanceof BrewerInventory)) return;
|
||||||
|
|
||||||
|
UUID puid = player.getUniqueId();
|
||||||
|
if (!trackedBrewmen.contains(puid)) return;
|
||||||
|
|
||||||
|
if (InventoryType.BREWING != inv.getType()) return;
|
||||||
|
|
||||||
|
BrewerInventory brewer = (BrewerInventory) inv;
|
||||||
|
final Block brewery = brewer.getHolder().getBlock();
|
||||||
|
|
||||||
|
// If we were already tracking the brewer, cancel any ongoing event due to the click.
|
||||||
|
Integer curTask = trackedBrewers.get(brewery);
|
||||||
|
if (curTask != null) {
|
||||||
|
Bukkit.getScheduler().cancelTask(curTask); // cancel prior
|
||||||
|
}
|
||||||
|
|
||||||
|
// Now check if we should bother to track it.
|
||||||
|
trackedBrewers.put(brewery, new BukkitRunnable() {
|
||||||
|
private int brewTime = 401;
|
||||||
|
@Override
|
||||||
|
public void run() {
|
||||||
|
BlockState now = brewery.getState();
|
||||||
|
if (now instanceof BrewingStand) {
|
||||||
|
BrewingStand stand = (BrewingStand) now;
|
||||||
|
// check if still custom
|
||||||
|
BrewerInventory brewer = stand.getInventory();
|
||||||
|
if (isCustomAndDistill(brewer) ) {
|
||||||
|
|
||||||
|
// Still a valid brew distillation
|
||||||
|
brewTime = brewTime - 1; // count down.
|
||||||
|
stand.setBrewingTime(brewTime); // arbitrary for now
|
||||||
|
|
||||||
|
if (brewTime <= 1) { // Done!
|
||||||
|
BrewEvent doBrew = new BrewEvent(brewery, brewer);
|
||||||
|
Bukkit.getServer().getPluginManager().callEvent(doBrew);
|
||||||
|
if (!doBrew.isCancelled()) { // BrewEvent _wasn't_ cancelled.
|
||||||
|
this.cancel();
|
||||||
|
trackedBrewers.remove(brewery);
|
||||||
|
stand.setBrewingTime(0);
|
||||||
|
P.p.debugLog("All done distilling");
|
||||||
|
} else {
|
||||||
|
brewTime = 401; // go again.
|
||||||
|
P.p.debugLog("Can distill more! Continuing.");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
this.cancel();
|
||||||
|
trackedBrewers.remove(brewery);
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
this.cancel();
|
||||||
|
trackedBrewers.remove(brewery);
|
||||||
|
P.p.debugLog("The block was replaced; not a brewing stand.");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}.runTaskTimer(P.p, 2l, 1l).getTaskId());
|
||||||
|
}
|
||||||
|
|
||||||
|
private boolean isCustomAndDistill(BrewerInventory brewer) {
|
||||||
|
ItemStack item = brewer.getItem(3); // ingredient
|
||||||
|
if (item == null || Material.GLOWSTONE_DUST != item.getType()) return false; // need dust in the top slot.
|
||||||
|
Boolean[] contents = new Boolean[3];
|
||||||
|
for (int slot = 0; slot < 3; slot++) {
|
||||||
|
item = brewer.getItem(slot);
|
||||||
|
contents[slot] = false;
|
||||||
|
if (item != null) {
|
||||||
|
if (item.getType() == Material.POTION) {
|
||||||
|
if (item.hasItemMeta()) {
|
||||||
|
int uid = Brew.getUID(item);
|
||||||
|
Brew pot = Brew.potions.get(uid);
|
||||||
|
if (pot != null && pot.canDistill()) { // need at least one distillable potion.
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
@EventHandler(priority = EventPriority.HIGH, ignoreCancelled = true)
|
@EventHandler(priority = EventPriority.HIGH, ignoreCancelled = true)
|
||||||
public void onBrew(BrewEvent event) {
|
public void onBrew(BrewEvent event) {
|
||||||
int slot = 0;
|
int slot = 0;
|
||||||
|
Loading…
Reference in New Issue
Block a user