Adding Citadel support and finally fixing brew colors for 1.12

This commit is contained in:
ProgrammerDan 2017-07-26 14:36:50 -04:00
parent 851160fbac
commit 5089b24dac
10 changed files with 115 additions and 16 deletions

18
pom.xml
View File

@ -4,7 +4,7 @@
<groupId>com.dre</groupId>
<artifactId>brewery</artifactId>
<version>1.6.0</version>
<version>1.6.1</version>
<name>Brewery</name>
<properties>
@ -68,6 +68,10 @@
<id>dre2n-rpo</id>
<url>http://feuerstern.bplaced.net/repo/</url>
</repository>
<repository>
<id>devoted-repo</id>
<url>https://build.devotedmc.com/plugin/repository/everything/</url>
</repository>
</repositories>
<dependencies>
@ -83,6 +87,18 @@
<version>1.6</version>
<scope>provided</scope>
</dependency>
<dependency>
<groupId>vg.civcraft.mc.citadel</groupId>
<artifactId>Citadel</artifactId>
<version>3.9.1</version>
<scope>compile</scope>
</dependency>
<dependency>
<groupId>vg.civcraft.mc.civmodcore</groupId>
<artifactId>CivModCore</artifactId>
<version>1.6.0</version>
<scope>compile</scope>
</dependency>
<dependency>
<groupId>com.sk89q</groupId>
<artifactId>worldguard</artifactId>

View File

@ -265,6 +265,7 @@ cooked:
useWorldGuard: true
useLWC: true
useGriefPrevention: true
useCitadel: true
# Änderungen an Fassinventaren mit LogBlock aufzeichen [true]
useLogBlock: true

View File

@ -263,6 +263,7 @@ cooked:
useWorldGuard: true
useLWC: true
useGriefPrevention: true
useCitadel: true
# Enable the Logging of Barrel Inventories to LogBlock [true]
useLogBlock: true

View File

@ -268,6 +268,7 @@ cooked:
useWorldGuard: true
useLWC: true
useGriefPrevention: true
useCitadel: true
# Activer l'historique du contenu des tonneaux avec LogBlock [true]
useLogBlock: true

View File

@ -263,6 +263,7 @@ cooked:
useWorldGuard: true
useLWC: true
useGriefPrevention: true
useCitadel: true
# Abilita il logging degli inventari dei barili [true]
useLogBlock: true

View File

@ -2,7 +2,7 @@ name: ${project.name}
version: ${project.version}
main: com.dre.brewery.P
authors: [Milan Albrecht, Frank Baumann, ProgrammerDan]
softdepend: [LWC, LogBlock, WorldGuard, GriefPrevention, Vault]
softdepend: [LWC, LogBlock, WorldGuard, GriefPrevention, Vault, Citadel]
commands:
brewery:
description: Command for Administration

View File

@ -22,6 +22,7 @@ import org.bukkit.material.Wood;
import org.bukkit.plugin.Plugin;
import org.bukkit.scheduler.BukkitRunnable;
import com.dre.brewery.integration.CitadelBarrel;
import com.dre.brewery.integration.GriefPreventionBarrel;
import com.dre.brewery.integration.LWCBarrel;
import com.dre.brewery.integration.LogBlockBarrel;
@ -179,6 +180,26 @@ public class Barrel implements InventoryHolder {
}
}
}
if (event != null && P.p.useCitadel) {
Plugin plugin = P.p.getServer().getPluginManager().getPlugin("Citadel");
if (plugin != null) {
try {
if (isSign(event.getClickedBlock())) {
return CitadelBarrel.checkAccess(player, getSignOfSpigot());
} else {
return CitadelBarrel.checkAccess(player, spigot);
}
} catch (Throwable e) {
P.p.errorLog("Failed to Check Citadel for Container Access Permissions!");
P.p.errorLog("Brewery was tested with version 3.9.1 of Citadel!");
P.p.errorLog("Disable Citadel support in the config and do /brew reload");
e.printStackTrace();
P.p.msg(player, "&cError opening Barrel, please report to an admin!");
return false;
}
}
}
return true;
}

View File

@ -1,5 +1,6 @@
package com.dre.brewery;
import org.bukkit.Color;
import org.bukkit.Material;
import org.bukkit.configuration.ConfigurationSection;
import org.bukkit.inventory.BrewerInventory;
@ -685,25 +686,27 @@ public class Brew {
}
public enum PotionColor {
PINK(1, PotionType.REGEN),
CYAN(2, PotionType.SPEED),
ORANGE(3, PotionType.FIRE_RESISTANCE),
GREEN(4, PotionType.POISON),
BRIGHT_RED(5, PotionType.INSTANT_HEAL),
BLUE(6, PotionType.NIGHT_VISION),
BLACK(8, PotionType.WEAKNESS),
RED(9, PotionType.STRENGTH),
GREY(10, PotionType.SLOWNESS),
WATER(11, P.use1_9 ? PotionType.WATER_BREATHING : null),
DARK_RED(12, PotionType.INSTANT_DAMAGE),
BRIGHT_GREY(14, PotionType.INVISIBILITY);
PINK(1, PotionType.REGEN, Color.FUCHSIA),
CYAN(2, PotionType.SPEED, Color.AQUA),
ORANGE(3, PotionType.FIRE_RESISTANCE, Color.ORANGE),
GREEN(4, PotionType.POISON, Color.GREEN),
BRIGHT_RED(5, PotionType.INSTANT_HEAL, Color.fromRGB(255,0,0)),
BLUE(6, PotionType.NIGHT_VISION, Color.NAVY),
BLACK(8, PotionType.WEAKNESS, Color.BLACK),
RED(9, PotionType.STRENGTH, Color.fromRGB(196,0,0)),
GREY(10, PotionType.SLOWNESS, Color.GRAY),
WATER(11, P.use1_9 ? PotionType.WATER_BREATHING : null, Color.BLUE),
DARK_RED(12, PotionType.INSTANT_DAMAGE, Color.fromRGB(128,0,0)),
BRIGHT_GREY(14, PotionType.INVISIBILITY, Color.SILVER);
private final int colorId;
private final PotionType type;
private final Color color;
PotionColor(int colorId, PotionType type) {
PotionColor(int colorId, PotionType type, Color color) {
this.colorId = colorId;
this.type = type;
this.color = color;
}
// gets the Damage Value, that sets a color on the potion
@ -718,11 +721,18 @@ public class Brew {
public PotionType getType() {
return type;
}
public Color getColor() {
return color;
}
public void colorBrew(PotionMeta meta, ItemStack potion, boolean destillable) {
if (P.use1_9) {
meta.setBasePotionData(new PotionData(getType()));
meta.addItemFlags(ItemFlag.HIDE_POTION_EFFECTS);
if (P.use1_12) {
meta.setColor(getColor());
}
} else {
potion.setDurability(getColorId(destillable));
}

View File

@ -39,6 +39,7 @@ public class P extends JavaPlugin {
public static boolean debug;
public static boolean useUUID;
public static boolean use1_9;
public static boolean use1_12;
public static boolean updateCheck;
// Third Party Enabled
@ -47,7 +48,8 @@ public class P extends JavaPlugin {
public boolean useLWC; //LWC
public boolean useLB; //LogBlock
public boolean useGP; //GriefPrevention
public boolean hasVault;
public boolean hasVault; // Vault
public boolean useCitadel; // CivCraft/DevotedMC Citadel
// Listeners
public BlockListener blockListener;
@ -70,6 +72,7 @@ public class P extends JavaPlugin {
String v = Bukkit.getBukkitVersion();
useUUID = !v.matches("(^|.*[^\\.\\d])1\\.[0-6]([^\\d].*|$)") && !v.matches("(^|.*[^\\.\\d])1\\.7\\.[0-5]([^\\d].*|$)");
use1_9 = !v.matches("(^|.*[^\\.\\d])1\\.[0-8]([^\\d].*|$)");
use1_12 = !v.matches("(^|.*[^\\.\\d])1\\.[0-11]([^\\d].*|$)");
// load the Config
try {
@ -280,6 +283,8 @@ public class P extends JavaPlugin {
useGP = config.getBoolean("useGriefPrevention", true) && getServer().getPluginManager().isPluginEnabled("GriefPrevention");
useLB = config.getBoolean("useLogBlock", false) && getServer().getPluginManager().isPluginEnabled("LogBlock");
hasVault = getServer().getPluginManager().isPluginEnabled("Vault");
useCitadel = config.getBoolean("useCitadel", false) && getServer().getPluginManager().isPluginEnabled("Citadel");
// various Settings
DataSave.autosave = config.getInt("autosave", 3);

View File

@ -0,0 +1,43 @@
package com.dre.brewery.integration;
import org.bukkit.block.Block;
import org.bukkit.entity.Player;
import com.dre.brewery.P;
import vg.civcraft.mc.citadel.Citadel;
import vg.civcraft.mc.citadel.ReinforcementManager;
import vg.civcraft.mc.citadel.reinforcement.NullReinforcement;
import vg.civcraft.mc.citadel.reinforcement.PlayerReinforcement;
import vg.civcraft.mc.citadel.reinforcement.Reinforcement;
/**
* Basic Citadel support to prevent randos from stealing your barrel aging brews
*
* @author ProgrammerDan
*/
public class CitadelBarrel {
static P brewery = P.p;
public static boolean checkAccess(Player player, Block sign) {
ReinforcementManager manager = Citadel.getReinforcementManager();
Reinforcement rein = manager.getReinforcement(sign);
if (rein == null) return true; // no protections in place.
if (rein instanceof PlayerReinforcement) {
PlayerReinforcement prein = (PlayerReinforcement) rein;
if (prein.canAccessChests(player)) {
return true;
}
} else if (rein instanceof NullReinforcement) {
return true;
}
// no support for multiblock atm, would require namelayer support.
// special locked, or no access.
brewery.msg(player, brewery.languageReader.get("Error_NoBarrelAccess"));
return false;
}
}