Skip to content

Commit

Permalink
manually merge #598
Browse files Browse the repository at this point in the history
  • Loading branch information
Jsinco committed Jul 18, 2024
1 parent 2aef581 commit 7e63590
Show file tree
Hide file tree
Showing 11 changed files with 86 additions and 44 deletions.
Binary file modified .gradle/8.2/executionHistory/executionHistory.bin
Binary file not shown.
Binary file modified .gradle/8.2/executionHistory/executionHistory.lock
Binary file not shown.
Binary file modified .gradle/8.2/fileHashes/fileHashes.bin
Binary file not shown.
Binary file modified .gradle/8.2/fileHashes/fileHashes.lock
Binary file not shown.
Binary file modified .gradle/buildOutputCleanup/buildOutputCleanup.lock
Binary file not shown.
Binary file modified .gradle/buildOutputCleanup/outputFiles.bin
Binary file not shown.
Binary file modified .gradle/file-system.probe
Binary file not shown.
37 changes: 27 additions & 10 deletions build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -60,10 +60,6 @@ dependencies {


tasks {

java {
toolchain.languageVersion = JavaLanguageVersion.of(langVersion)
}
jar {
enabled = false
}
Expand All @@ -72,6 +68,7 @@ tasks {
}
build {
dependsOn(shadowJar)
finalizedBy("kotlinReducedJar")
}

processResources {
Expand All @@ -84,11 +81,7 @@ tasks {
}

shadowJar {
//dependencies {
//include(dependency("org.bstats:bstats-bukkit"))
//include(dependency("com.github.Anon8281:UniversalScheduler"))
// }
relocate("org.bstats", "com.dre.brewery.integration.bstats")
//relocate("org.bstats", "com.dre.brewery.integration.bstats")
relocate("com.github.Anon8281.universalScheduler", "com.dre.brewery.integration.universalScheduler")

archiveClassifier.set("")
Expand All @@ -97,9 +90,30 @@ tasks {
test {
useJUnitPlatform()
}
}


// Kotlin Reduced Jars
register<Copy>("kotlinReducedResources") {
from("src/main/resources")
into("$buildDir/kt-reduced")
doLast {
val pluginFile = file("$buildDir/kt-reduced/plugin.yml")
var content = pluginFile.readText()
content = content.replace("libraries: ['org.jetbrains.kotlin:kotlin-stdlib-jdk8:1.9.10']", "")
pluginFile.writeText(content)
}
}

register<Jar>("kotlinReducedJar") {
dependsOn("kotlinReducedResources")
from("$buildDir/kt-reduced")
archiveClassifier.set("KtReduced")
}
}

java {
toolchain.languageVersion = JavaLanguageVersion.of(langVersion)
}

publishing {
publications {
Expand All @@ -108,3 +122,6 @@ publishing {
}
}
}



5 changes: 2 additions & 3 deletions src/main/java/com/dre/brewery/BDistiller.java
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,6 @@
import org.bukkit.block.Block;
import org.bukkit.block.BlockState;
import org.bukkit.block.BrewingStand;
import org.bukkit.event.inventory.InventoryClickEvent;
import org.bukkit.inventory.BrewerInventory;
import org.bukkit.inventory.ItemStack;
import org.bukkit.inventory.meta.PotionMeta;
Expand Down Expand Up @@ -51,8 +50,8 @@ public void start() {
task = new DistillRunnable().runTaskTimer(BreweryPlugin.getInstance(), 2L, 1L);
}

public static void distillerClick(InventoryClickEvent event) {
BrewerInventory standInv = (BrewerInventory) event.getInventory();
public static void distillerClick(BrewerInventory standInv) {

final Block standBlock = standInv.getHolder().getBlock();

// If we were already tracking the brewer, cancel any ongoing event due to the click.
Expand Down
83 changes: 55 additions & 28 deletions src/main/java/com/dre/brewery/listeners/InventoryListener.java
Original file line number Diff line number Diff line change
@@ -1,6 +1,11 @@
package com.dre.brewery.listeners;

import com.dre.brewery.*;
import com.dre.brewery.BDistiller;
import com.dre.brewery.BSealer;
import com.dre.brewery.Barrel;
import com.dre.brewery.Brew;
import com.dre.brewery.BreweryPlugin;
import com.dre.brewery.MCBarrel;
import com.dre.brewery.filedata.BConfig;
import com.dre.brewery.lore.BrewLore;
import com.dre.brewery.utility.MinecraftVersion;
Expand All @@ -10,7 +15,16 @@
import org.bukkit.event.EventHandler;
import org.bukkit.event.EventPriority;
import org.bukkit.event.Listener;
import org.bukkit.event.inventory.*;
import org.bukkit.event.inventory.BrewEvent;
import org.bukkit.event.inventory.ClickType;
import org.bukkit.event.inventory.InventoryAction;
import org.bukkit.event.inventory.InventoryClickEvent;
import org.bukkit.event.inventory.InventoryCloseEvent;
import org.bukkit.event.inventory.InventoryDragEvent;
import org.bukkit.event.inventory.InventoryMoveItemEvent;
import org.bukkit.event.inventory.InventoryOpenEvent;
import org.bukkit.event.inventory.InventoryPickupItemEvent;
import org.bukkit.event.inventory.InventoryType;
import org.bukkit.inventory.BrewerInventory;
import org.bukkit.inventory.Inventory;
import org.bukkit.inventory.InventoryHolder;
Expand All @@ -27,7 +41,7 @@ public class InventoryListener implements Listener {
private static final MinecraftVersion VERSION = BreweryPlugin.getMCVersion();

/* === Recreating manually the prior BrewEvent behavior. === */
private HashSet<UUID> trackedBrewmen = new HashSet<>();
private final HashSet<UUID> trackedBrewmen = new HashSet<>();

/**
* Start tracking distillation for a person when they open the brewer window.
Expand Down Expand Up @@ -77,15 +91,15 @@ public void onBrewerClick(InventoryClickEvent event) {

HumanEntity player = event.getWhoClicked();
Inventory inv = event.getInventory();
if (player == null || !(inv instanceof BrewerInventory)) return;
if (!(inv instanceof BrewerInventory)) return;

UUID puid = player.getUniqueId();
if (!trackedBrewmen.contains(puid)) return;

if (InventoryType.BREWING != inv.getType()) return;
if (event.getAction() == InventoryAction.NOTHING) return; // Ignore clicks that do nothing

BDistiller.distillerClick(event);
BDistiller.distillerClick((BrewerInventory) event.getInventory());
}

@EventHandler(priority = EventPriority.LOW, ignoreCancelled = true)
Expand Down Expand Up @@ -259,34 +273,47 @@ public void onHopperPickupPuke(InventoryPickupItemEvent event){
// Block taking out items from running distillers,
// Convert Color Lore from MC Barrels back into normal color on taking out
@EventHandler(ignoreCancelled = true, priority = EventPriority.HIGH)
public void onHopperMove(InventoryMoveItemEvent event){
if (event.getSource() instanceof BrewerInventory) {
if (BDistiller.isTrackingDistiller(((BrewerInventory) event.getSource()).getHolder().getBlock())) {
event.setCancelled(true);
}
return;
public void onHopperMove(InventoryMoveItemEvent event) {
if (event.getDestination().getType() == InventoryType.BREWING) {
dealWithBrewery(event.getItem(), (BrewerInventory) event.getDestination());
}

if (VERSION.isOrEarlier(MinecraftVersion.V1_14)) return;
if (event.getSource().getType() == InventoryType.BREWING) {
dealWithBrewery(event.getItem(), (BrewerInventory) event.getSource());
}

if (event.getSource().getType() == InventoryType.BARREL) {
ItemStack item = event.getItem();
if (item.getType() == Material.POTION && Brew.isBrew(item)) {
PotionMeta meta = (PotionMeta) item.getItemMeta();
assert meta != null;
if (BrewLore.hasColorLore(meta)) {
// has color lore, convert lore back to normal
Brew brew = Brew.get(meta);
if (brew != null) {
BrewLore lore = new BrewLore(brew, meta);
lore.convertLore(false);
lore.write();
item.setItemMeta(meta);
event.setItem(item);
}
}
}
dealWithBarrel(event);
}
}

private void dealWithBarrel(InventoryMoveItemEvent event){
if (VERSION.isOrEarlier(MinecraftVersion.V1_14)) return;
ItemStack item = event.getItem();
if (item.getType() != Material.POTION || !Brew.isBrew(item)) {
return;
}
PotionMeta meta = (PotionMeta) item.getItemMeta();
assert meta != null;
if (!BrewLore.hasColorLore(meta)) {
return;
}
// has color lore, convert lore back to normal
Brew brew = Brew.get(meta);
if (brew != null) {
BrewLore lore = new BrewLore(brew, meta);
lore.convertLore(false);
lore.write();
item.setItemMeta(meta);
event.setItem(item);
}
}

private void dealWithBrewery(ItemStack item, BrewerInventory inventory){
if (item.getType() != Material.POTION || !Brew.isBrew(item)) {
return;
}
BDistiller.distillerClick(inventory);
}

@EventHandler
Expand Down
5 changes: 2 additions & 3 deletions src/main/resources/plugin.yml
Original file line number Diff line number Diff line change
@@ -1,13 +1,12 @@
name: BreweryX
version: '${project.version}'
version: '${version}'
website: 'https://www.spigotmc.org/resources/breweryx.114777/'
main: com.dre.brewery.BreweryPlugin
softdepend: [LWC, LogBlock, WorldGuard, GriefPrevention, Vault, ChestShop, Shopkeepers, Towny, BlockLocker, Slimefun, PlaceholderAPI]
authors: [Jonah (Jsinco), Milan Albrecht, Frank Baumann, ProgrammerDan, Daniel Saukel]
folia-supported: true
api-version: 1.13
libraries:
- 'org.jetbrains.kotlin:kotlin-stdlib-jdk8:1.9.10'
libraries: ['org.jetbrains.kotlin:kotlin-stdlib-jdk8:1.9.10']
commands:
breweryx:
description: Mostly admin commands to create/modify Brews and drunkenness
Expand Down

0 comments on commit 7e63590

Please sign in to comment.