mirror of
https://github.com/DieReicheErethons/Brewery.git
synced 2025-01-09 19:17:35 +01:00
Notify ShopKeepers users of unsealed brews
This commit is contained in:
parent
7319bca59d
commit
2ee7dd825d
12
pom.xml
12
pom.xml
@ -111,6 +111,10 @@
|
||||
<id>MMOPlugins</id>
|
||||
<url>https://mvn.lumine.io/repository/maven-releases/</url>
|
||||
</repository>
|
||||
<repository>
|
||||
<id>Lichtspiele</id>
|
||||
<url>https://nexus.lichtspiele.org/repository/releases/</url>
|
||||
</repository>
|
||||
</repositories>
|
||||
|
||||
<dependencies>
|
||||
@ -199,7 +203,7 @@
|
||||
<dependency>
|
||||
<groupId>de.diddiz</groupId>
|
||||
<artifactId>logblock</artifactId>
|
||||
<version>1.15.2</version>
|
||||
<version>1.16.1.1</version>
|
||||
<scope>provided</scope>
|
||||
<exclusions>
|
||||
<exclusion>
|
||||
@ -239,6 +243,12 @@
|
||||
<version>0.96.3.0</version>
|
||||
<scope>provided</scope>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>com.nisovin.shopkeepers</groupId>
|
||||
<artifactId>ShopkeepersAPI</artifactId>
|
||||
<version>2.12.0</version>
|
||||
<scope>provided</scope>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>org.bstats</groupId>
|
||||
<artifactId>bstats-bukkit</artifactId>
|
||||
|
@ -108,6 +108,6 @@ 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'
|
||||
Player_ShopSealBrew: '&eIt''s recommended to trade/sell &6sealed &eBrews'
|
||||
Player_Drunkeness: 'Drunkeness'
|
||||
Player_Hangover: 'Your Hangover'
|
||||
|
@ -108,6 +108,6 @@ Player_WakeNoCheck: '&cNessun punto di risveglio attivo al momento.'
|
||||
Player_WakeNoPoints: '&cNon ci sono punti di risveglio!'
|
||||
Player_WakeNotExist: '&cIl punto di risveglio con id &6&v1 &cnon esiste!'
|
||||
Player_WakeTeleport: 'Teletrasportato al punto di risveglio di id &6&v1&f alla posizione &6&v2 &v3, &v4, &v5'
|
||||
Player_ShopSealBrew: '&eBrews should be sealed before selling them'
|
||||
Player_ShopSealBrew: '&eIt''s recommended to trade/sell &6sealed &eBrews'
|
||||
Player_Drunkeness: 'Ubriacatura'
|
||||
Player_Hangover: 'Hangover'
|
||||
|
@ -108,6 +108,6 @@ Player_WakeNoCheck: '&c目前沒有喚醒點是處於活動狀態'
|
||||
Player_WakeNoPoints: '&c沒有喚醒點!'
|
||||
Player_WakeNotExist: '&c這個喚醒點 id: &6&v1 &c不存在!'
|
||||
Player_WakeTeleport: '傳送到這個喚醒點 id: &6&v1&f 在位置: &6&v2 &v3, &v4, &v5'
|
||||
Player_ShopSealBrew: '&eBrews should be sealed before selling them'
|
||||
Player_ShopSealBrew: '&eIt''s recommended to trade/sell &6sealed &eBrews'
|
||||
Player_Drunkeness: '醉酒'
|
||||
Player_Hangover: '你的宿醉'
|
||||
|
@ -108,6 +108,6 @@ Player_WakeNoCheck: '&c目前没有执行苏醒处检查.'
|
||||
Player_WakeNoPoints: '&c目前没有设定任何一个苏醒处!'
|
||||
Player_WakeNotExist: '&cid为: &6&v1 &c的苏醒处并不存在!'
|
||||
Player_WakeTeleport: '前往id为: &6&v1 &f坐标为: &6&v2 &v3, &v4, &v5 &r的苏醒处.'
|
||||
Player_ShopSealBrew: '&eBrews should be sealed before selling them'
|
||||
Player_ShopSealBrew: '&eIt''s recommended to trade/sell &6sealed &eBrews'
|
||||
Player_Drunkeness: '醉酒'
|
||||
Player_Hangover: '你的宿醉'
|
||||
|
@ -1,7 +1,7 @@
|
||||
name: Brewery
|
||||
version: 2.1.2
|
||||
main: com.dre.brewery.P
|
||||
softdepend: [LWC, LogBlock, WorldGuard, GriefPrevention, Vault, ChestShop, Towny]
|
||||
softdepend: [LWC, LogBlock, WorldGuard, GriefPrevention, Vault, ChestShop, Shopkeepers, Towny]
|
||||
authors: [Milan Albrecht, Frank Baumann, ProgrammerDan, Daniel Saukel]
|
||||
api-version: 1.13
|
||||
commands:
|
||||
|
@ -7,6 +7,7 @@ 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.ShopKeepersListener;
|
||||
import com.dre.brewery.integration.barrel.LogBlockBarrel;
|
||||
import com.dre.brewery.listeners.*;
|
||||
import com.dre.brewery.recipe.*;
|
||||
@ -135,6 +136,9 @@ public class P extends JavaPlugin {
|
||||
if (BConfig.hasChestShop && use1_13) {
|
||||
p.getServer().getPluginManager().registerEvents(new ChestShopListener(), p);
|
||||
}
|
||||
if (BConfig.hasShopKeepers) {
|
||||
p.getServer().getPluginManager().registerEvents(new ShopKeepersListener(), p);
|
||||
}
|
||||
|
||||
// Heartbeat
|
||||
p.getServer().getScheduler().runTaskTimer(p, new BreweryRunnable(), 650, 1200);
|
||||
|
@ -56,6 +56,7 @@ public class BConfig {
|
||||
public static Boolean hasSlimefun = null; // Slimefun ; Null if not checked
|
||||
public static Boolean hasMMOItems = null; // MMOItems ; Null if not checked
|
||||
public static boolean hasChestShop;
|
||||
public static boolean hasShopKeepers;
|
||||
|
||||
// Barrel
|
||||
public static boolean openEverywhere;
|
||||
@ -228,6 +229,7 @@ public class BConfig {
|
||||
hasVault = plMan.isPluginEnabled("Vault")
|
||||
&& Integer.parseInt(plMan.getPlugin("Vault").getDescription().getVersion().split("\\.")[1]) <= 6;
|
||||
hasChestShop = plMan.isPluginEnabled("ChestShop");
|
||||
hasShopKeepers = plMan.isPluginEnabled("Shopkeepers");
|
||||
|
||||
// various Settings
|
||||
DataSave.autosave = config.getInt("autosave", 3);
|
||||
|
67
src/com/dre/brewery/integration/ShopKeepersListener.java
Normal file
67
src/com/dre/brewery/integration/ShopKeepersListener.java
Normal file
@ -0,0 +1,67 @@
|
||||
package com.dre.brewery.integration;
|
||||
|
||||
import com.dre.brewery.Brew;
|
||||
import com.dre.brewery.P;
|
||||
import com.dre.brewery.filedata.BConfig;
|
||||
import com.nisovin.shopkeepers.api.events.PlayerOpenUIEvent;
|
||||
import com.nisovin.shopkeepers.api.ui.DefaultUITypes;
|
||||
import org.bukkit.Material;
|
||||
import org.bukkit.entity.HumanEntity;
|
||||
import org.bukkit.entity.Player;
|
||||
import org.bukkit.event.EventHandler;
|
||||
import org.bukkit.event.EventPriority;
|
||||
import org.bukkit.event.HandlerList;
|
||||
import org.bukkit.event.Listener;
|
||||
import org.bukkit.event.inventory.InventoryClickEvent;
|
||||
import org.bukkit.event.inventory.InventoryCloseEvent;
|
||||
import org.bukkit.inventory.ItemStack;
|
||||
|
||||
import java.util.HashSet;
|
||||
import java.util.Set;
|
||||
|
||||
public class ShopKeepersListener implements Listener {
|
||||
Set<HumanEntity> openedEditors = new HashSet<>();
|
||||
|
||||
@EventHandler(priority = EventPriority.MONITOR, ignoreCancelled = true)
|
||||
public void onShopCreated(PlayerOpenUIEvent event) {
|
||||
try {
|
||||
if (event.getUIType() == DefaultUITypes.EDITOR() || event.getUIType() == DefaultUITypes.TRADING()) {
|
||||
openedEditors.add(event.getPlayer());
|
||||
}
|
||||
} catch (Throwable e) {
|
||||
failed(e);
|
||||
}
|
||||
}
|
||||
|
||||
@EventHandler(ignoreCancelled = true)
|
||||
public void onInventoryClickShopKeeper(InventoryClickEvent event) {
|
||||
if (openedEditors.isEmpty() || !openedEditors.contains(event.getWhoClicked())) {
|
||||
return;
|
||||
}
|
||||
if (!(event.getWhoClicked() instanceof Player)) {
|
||||
return;
|
||||
}
|
||||
ItemStack item = event.getCursor();
|
||||
if (item != null && item.getType() == Material.POTION && event.getClickedInventory() == event.getView().getTopInventory()) {
|
||||
Brew brew = Brew.get(item);
|
||||
if (brew != null && !brew.isSealed()) {
|
||||
P.p.msg(event.getWhoClicked(), P.p.languageReader.get("Player_ShopSealBrew"));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@EventHandler
|
||||
public void onCloseInventoryShopKeeper(InventoryCloseEvent event) {
|
||||
openedEditors.remove(event.getPlayer());
|
||||
}
|
||||
|
||||
private void failed(Throwable e) {
|
||||
HandlerList.unregisterAll(this);
|
||||
BConfig.hasShopKeepers = false;
|
||||
e.printStackTrace();
|
||||
P.p.errorLog("Failed to notify Player using 'ShopKeepers'. Disabling 'ShopKeepers' support");
|
||||
openedEditors.clear();
|
||||
}
|
||||
|
||||
}
|
Loading…
Reference in New Issue
Block a user