Added ChestShop notification

This commit is contained in:
Sn0wStorm 2020-04-08 10:13:04 +02:00
parent 241150a468
commit ce4e665fda
8 changed files with 75 additions and 8 deletions

22
pom.xml
View File

@ -97,6 +97,10 @@
<id>brewery-repo</id>
<url>https://zebradrive.de/maven/</url>
</repository>
<repository>
<id>chestshop-repo</id>
<url>https://repo.minebench.de/</url>
</repository>
<repository>
<!-- bStats -->
<id>CodeMC</id>
@ -142,7 +146,7 @@
<dependency>
<groupId>com.sk89q.worldedit</groupId>
<artifactId>worldedit-bukkit</artifactId>
<version>7.0.0-SNAPSHOT</version>
<version>7.1.0</version>
<scope>provided</scope>
<exclusions>
<exclusion>
@ -154,7 +158,7 @@
<dependency>
<groupId>com.sk89q.worldedit</groupId>
<artifactId>worldedit-core</artifactId>
<version>7.0.0-SNAPSHOT</version>
<version>7.1.0</version>
<scope>provided</scope>
<exclusions>
<exclusion>
@ -166,7 +170,7 @@
<dependency>
<groupId>com.sk89q.worldguard</groupId>
<artifactId>worldguard-core</artifactId>
<version>7.0.0-SNAPSHOT</version>
<version>7.0.2</version>
<scope>provided</scope>
<exclusions>
<exclusion>
@ -184,13 +188,13 @@
<dependency>
<groupId>com.github.TechFortress</groupId>
<artifactId>GriefPrevention</artifactId>
<version>16.11.5</version>
<version>16.13.0</version>
<scope>provided</scope>
</dependency>
<dependency>
<groupId>de.diddiz</groupId>
<artifactId>logblock</artifactId>
<version>1.13.2-SNAPSHOT-391</version>
<version>1.15.2</version>
<scope>provided</scope>
<exclusions>
<exclusion>
@ -202,7 +206,7 @@
<dependency>
<groupId>com.github.TheBusyBiscuit</groupId>
<artifactId>Slimefun4</artifactId>
<version>4bb9abd247</version>
<version>156683f318</version>
<scope>provided</scope>
</dependency>
<!--<dependency>
@ -218,6 +222,12 @@
<version>1.0.9</version>
<scope>provided</scope>
</dependency>
<dependency>
<groupId>com.acrobot.chestshop</groupId>
<artifactId>chestshop</artifactId>
<version>3.10.1</version>
<scope>provided</scope>
</dependency>
<dependency>
<groupId>org.bstats</groupId>
<artifactId>bstats-bukkit</artifactId>

View File

@ -101,3 +101,4 @@ Player_WakeNoCheck: '&cEs läuft kein Aufwachpunkte-Check'
Player_WakeNoPoints: '&cEs wurden noch keine Aufwachpunkte erstellt!'
Player_WakeNotExist: '&cDer Aufwachpunkt mit der id: &6&v1 &cexistiert nicht!'
Player_WakeTeleport: 'Teleport zu Aufwachpunkt mit der id: &6&v1&f An Position: &6&v2 &v3, &v4, &v5'
Player_ShopSealBrew: '&eBrewery Tränke sollten vor dem verkaufen versiegelt werden'

View File

@ -101,3 +101,4 @@ Player_WakeNoCheck: '&cNo Wakeup Point Check is currently active'
Player_WakeNoPoints: '&cThere are no Wakeup Points!'
Player_WakeNotExist: '&cThe Wakeup Point with the id: &6&v1 &cdoesn''t exist!'
Player_WakeTeleport: 'Teleport to Wakeup Point with the id: &6&v1&f At position: &6&v2 &v3, &v4, &v5'
Player_ShopSealBrew: '&eBrews should be sealed before selling them'

View File

@ -1,7 +1,7 @@
name: Brewery
version: 2.0.1
main: com.dre.brewery.P
softdepend: [LWC, LogBlock, WorldGuard, GriefPrevention, Vault, Citadel]
softdepend: [LWC, LogBlock, WorldGuard, GriefPrevention, Vault, ChestShop]
authors: [Milan Albrecht, Frank Baumann, ProgrammerDan, Daniel Saukel]
api-version: 1.13
commands:

View File

@ -22,6 +22,7 @@ import org.jetbrains.annotations.NotNull;
public class BSealer implements InventoryHolder {
public static final NamespacedKey TAG_KEY = new NamespacedKey(P.p, "SealingTable");
public static boolean recipeRegistered = false;
public static boolean inventoryHolderWorking = true;
private final Inventory inventory;
private final Player player;
@ -31,7 +32,17 @@ public class BSealer implements InventoryHolder {
public BSealer(Player player) {
this.player = player;
inventory = P.p.getServer().createInventory(this, InventoryType.DISPENSER, P.p.languageReader.get("Etc_SealingTable"));
if (inventoryHolderWorking) {
Inventory inv = P.p.getServer().createInventory(this, InventoryType.DISPENSER, P.p.languageReader.get("Etc_SealingTable"));
// Inventory Holder (for DISPENSER, ...) is only passed in Paper, not in Spigot. Doing inventory.getHolder() will return null in spigot :/
if (inv.getHolder() == this) {
inventory = inv;
return;
} else {
inventoryHolderWorking = false;
}
}
inventory = P.p.getServer().createInventory(this, 9, P.p.languageReader.get("Etc_SealingTable"));
}
@Override

View File

@ -5,6 +5,7 @@ import com.dre.brewery.filedata.BData;
import com.dre.brewery.filedata.DataSave;
import com.dre.brewery.filedata.LanguageReader;
import com.dre.brewery.filedata.UpdateChecker;
import com.dre.brewery.integration.ChestShopListener;
import com.dre.brewery.integration.IntegrationListener;
import com.dre.brewery.integration.barrel.LogBlockBarrel;
import com.dre.brewery.listeners.*;
@ -120,6 +121,9 @@ public class P extends JavaPlugin {
if (use1_9) {
p.getServer().getPluginManager().registerEvents(new CauldronListener(), p);
}
if (BConfig.hasChestShop) {
p.getServer().getPluginManager().registerEvents(new ChestShopListener(), p);
}
// Heartbeat
p.getServer().getScheduler().runTaskTimer(p, new BreweryRunnable(), 650, 1200);

View File

@ -54,6 +54,7 @@ public class BConfig {
public static boolean useGMInventories; // GamemodeInventories
public static Boolean hasSlimefun = null; // Slimefun ; Null if not checked
public static Boolean hasMMOItems = null; // MMOItems ; Null if not checked
public static boolean hasChestShop;
// Barrel
public static boolean openEverywhere;
@ -214,6 +215,7 @@ public class BConfig {
// The item util has been removed in Vault 1.7+
hasVault = plMan.isPluginEnabled("Vault")
&& Integer.parseInt(plMan.getPlugin("Vault").getDescription().getVersion().split("\\.")[1]) <= 6;
hasChestShop = plMan.isPluginEnabled("ChestShop");
// various Settings
DataSave.autosave = config.getInt("autosave", 3);

View File

@ -0,0 +1,38 @@
package com.dre.brewery.integration;
import com.Acrobot.ChestShop.Events.ShopCreatedEvent;
import com.dre.brewery.Brew;
import com.dre.brewery.P;
import com.dre.brewery.filedata.BConfig;
import org.bukkit.Material;
import org.bukkit.block.Container;
import org.bukkit.event.EventHandler;
import org.bukkit.event.HandlerList;
import org.bukkit.event.Listener;
import org.bukkit.inventory.ItemStack;
public class ChestShopListener implements Listener {
@EventHandler
public void onShopCreated(ShopCreatedEvent event) {
try {
Container container = event.getContainer();
if (container != null) {
for (ItemStack item : container.getInventory().getContents()) {
if (item != null && item.getType() == Material.POTION) {
Brew brew = Brew.get(item);
if (brew != null && !brew.isSealed()) {
event.getPlayer().sendTitle("", P.p.color(P.p.languageReader.get("Player_ShopSealBrew")), 10, 70, 20);
return;
}
}
}
}
} catch (Throwable e) {
HandlerList.unregisterAll(this);
BConfig.hasChestShop = false;
e.printStackTrace();
P.p.errorLog("Failed to notify Player using ChestShop. Disabling ChestShop support");
}
}
}