Compare commits
3 Commits
Author | SHA1 | Date | |
---|---|---|---|
137ba95a24 | |||
a1e415d6f0 | |||
b6b44d25c5 |
85
dependency-reduced-pom.xml
Normal file
85
dependency-reduced-pom.xml
Normal file
@@ -0,0 +1,85 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<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/maven-v4_0_0.xsd">
|
||||
<modelVersion>4.0.0</modelVersion>
|
||||
<groupId>viper</groupId>
|
||||
<artifactId>ButtonControl</artifactId>
|
||||
<version>1.3</version>
|
||||
<packaging>jar</packaging>
|
||||
|
||||
<properties>
|
||||
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
|
||||
<maven.compiler.source>17</maven.compiler.source>
|
||||
<maven.compiler.target>17</maven.compiler.target>
|
||||
<java.version>17</java.version>
|
||||
</properties>
|
||||
|
||||
<repositories>
|
||||
<repository>
|
||||
<id>spigot-repo</id>
|
||||
<url>https://hub.spigotmc.org/nexus/content/groups/public/</url>
|
||||
</repository>
|
||||
</repositories>
|
||||
|
||||
<dependencies>
|
||||
<dependency>
|
||||
<groupId>org.spigotmc</groupId>
|
||||
<artifactId>spigot-api</artifactId>
|
||||
<version>1.21-R0.1-SNAPSHOT</version>
|
||||
<scope>provided</scope>
|
||||
</dependency>
|
||||
<!-- bStats Monitoring -->
|
||||
<dependency>
|
||||
<groupId>org.bstats</groupId>
|
||||
<artifactId>bstats-bukkit</artifactId>
|
||||
<version>3.0.2</version>
|
||||
<scope>compile</scope>
|
||||
</dependency>
|
||||
</dependencies>
|
||||
|
||||
<build>
|
||||
<plugins>
|
||||
<plugin>
|
||||
<groupId>org.apache.maven.plugins</groupId>
|
||||
<artifactId>maven-compiler-plugin</artifactId>
|
||||
<version>3.10.1</version>
|
||||
<configuration>
|
||||
<source>${java.version}</source>
|
||||
<target>${java.version}</target>
|
||||
</configuration>
|
||||
</plugin>
|
||||
|
||||
<plugin>
|
||||
<groupId>org.apache.maven.plugins</groupId>
|
||||
<artifactId>maven-shade-plugin</artifactId>
|
||||
<version>3.4.1</version>
|
||||
<executions>
|
||||
<execution>
|
||||
<phase>package</phase>
|
||||
<goals>
|
||||
<goal>shade</goal>
|
||||
</goals>
|
||||
<configuration>
|
||||
<relocations>
|
||||
<relocation>
|
||||
<pattern>org.bstats</pattern>
|
||||
<shadedPattern>de.viper.bstats</shadedPattern>
|
||||
</relocation>
|
||||
</relocations>
|
||||
<filters>
|
||||
<filter>
|
||||
<artifact>*:*</artifact>
|
||||
<excludes>
|
||||
<exclude>META-INF/*.SF</exclude>
|
||||
<exclude>META-INF/*.DSA</exclude>
|
||||
<exclude>META-INF/*.RSA</exclude>
|
||||
</excludes>
|
||||
</filter>
|
||||
</filters>
|
||||
</configuration>
|
||||
</execution>
|
||||
</executions>
|
||||
</plugin>
|
||||
|
||||
</plugins>
|
||||
</build>
|
||||
</project>
|
@@ -8,6 +8,7 @@ import org.bukkit.event.EventHandler;
|
||||
import org.bukkit.event.Listener;
|
||||
import org.bukkit.event.inventory.InventoryClickEvent;
|
||||
import org.bukkit.event.inventory.InventoryCloseEvent;
|
||||
import org.bukkit.event.inventory.InventoryDragEvent;
|
||||
import org.bukkit.inventory.Inventory;
|
||||
import org.bukkit.inventory.ItemStack;
|
||||
import org.bukkit.inventory.meta.ItemMeta;
|
||||
@@ -21,6 +22,7 @@ public class MotionSensorGUI implements Listener {
|
||||
private final String blockLocation;
|
||||
private final String buttonId;
|
||||
private final Player player;
|
||||
private final Inventory inv;
|
||||
|
||||
public MotionSensorGUI(ButtonControl plugin, Player player, String blockLocation, String buttonId) {
|
||||
this.plugin = plugin;
|
||||
@@ -29,18 +31,26 @@ public class MotionSensorGUI implements Listener {
|
||||
this.blockLocation = blockLocation;
|
||||
this.buttonId = buttonId;
|
||||
this.player = player;
|
||||
this.inv = Bukkit.createInventory(player, 27, "Bewegungsmelder Einstellungen");
|
||||
plugin.getServer().getPluginManager().registerEvents(this, plugin);
|
||||
}
|
||||
|
||||
public void open() {
|
||||
Inventory inv = Bukkit.createInventory(player, 27, "Bewegungsmelder Einstellungen");
|
||||
|
||||
// Aktuelle Werte aus DataManager holen oder Standardwerte aus Config
|
||||
double radius = dataManager.getMotionSensorRadius(blockLocation);
|
||||
if (radius == -1) radius = configManager.getConfig().getDouble("motion-detection-radius", 5.0);
|
||||
long delay = dataManager.getMotionSensorDelay(blockLocation);
|
||||
if (delay == -1) delay = configManager.getConfig().getLong("motion-close-delay-ms", 5000L);
|
||||
|
||||
// Füllitems für leere Slots (graue Glasscheiben)
|
||||
ItemStack filler = new ItemStack(Material.GRAY_STAINED_GLASS_PANE);
|
||||
ItemMeta fillerMeta = filler.getItemMeta();
|
||||
fillerMeta.setDisplayName(ChatColor.RESET + "");
|
||||
filler.setItemMeta(fillerMeta);
|
||||
for (int i = 0; i < 27; i++) {
|
||||
inv.setItem(i, filler);
|
||||
}
|
||||
|
||||
// Items für die GUI
|
||||
ItemStack radiusItem = new ItemStack(Material.COMPASS);
|
||||
ItemMeta radiusMeta = radiusItem.getItemMeta();
|
||||
@@ -75,17 +85,23 @@ public class MotionSensorGUI implements Listener {
|
||||
|
||||
@EventHandler
|
||||
public void onInventoryClick(InventoryClickEvent event) {
|
||||
if (!event.getInventory().getHolder().equals(player)) return;
|
||||
if (!event.getInventory().equals(inv) || !event.getWhoClicked().equals(player)) return;
|
||||
if (event.getCurrentItem() == null) return;
|
||||
event.setCancelled(true);
|
||||
|
||||
event.setCancelled(true); // Alle Klicks standardmäßig abbrechen
|
||||
|
||||
int slot = event.getRawSlot();
|
||||
ItemStack clicked = event.getCurrentItem();
|
||||
|
||||
// Nur Klicks auf Slots 11, 15 und 22 verarbeiten
|
||||
if (slot != 11 && slot != 15 && slot != 22) return;
|
||||
|
||||
double radius = dataManager.getMotionSensorRadius(blockLocation);
|
||||
if (radius == -1) radius = configManager.getConfig().getDouble("motion-detection-radius", 5.0);
|
||||
long delay = dataManager.getMotionSensorDelay(blockLocation);
|
||||
if (delay == -1) delay = configManager.getConfig().getLong("motion-close-delay-ms", 5000L);
|
||||
|
||||
if (clicked.getType() == Material.COMPASS) {
|
||||
if (clicked.getType() == Material.COMPASS && slot == 11) {
|
||||
if (event.isLeftClick()) {
|
||||
radius = Math.min(radius + 0.5, 20.0); // Max. Radius: 20 Blöcke
|
||||
} else if (event.isRightClick()) {
|
||||
@@ -99,7 +115,8 @@ public class MotionSensorGUI implements Listener {
|
||||
ChatColor.GRAY + "Rechtsklick: -0.5 Blöcke"
|
||||
));
|
||||
clicked.setItemMeta(meta);
|
||||
} else if (clicked.getType() == Material.CLOCK) {
|
||||
inv.setItem(11, clicked);
|
||||
} else if (clicked.getType() == Material.CLOCK && slot == 15) {
|
||||
if (event.isLeftClick()) {
|
||||
delay = Math.min(delay + 1000, 30000); // Max. Verzögerung: 30 Sekunden
|
||||
} else if (event.isRightClick()) {
|
||||
@@ -113,15 +130,23 @@ public class MotionSensorGUI implements Listener {
|
||||
ChatColor.GRAY + "Rechtsklick: -1 Sekunde"
|
||||
));
|
||||
clicked.setItemMeta(meta);
|
||||
} else if (clicked.getType() == Material.EMERALD) {
|
||||
inv.setItem(15, clicked);
|
||||
} else if (clicked.getType() == Material.EMERALD && slot == 22) {
|
||||
player.closeInventory();
|
||||
}
|
||||
}
|
||||
|
||||
@EventHandler
|
||||
public void onInventoryDrag(InventoryDragEvent event) {
|
||||
if (!event.getInventory().equals(inv) || !event.getWhoClicked().equals(player)) return;
|
||||
event.setCancelled(true); // Verhindert Drag-and-Drop
|
||||
}
|
||||
|
||||
@EventHandler
|
||||
public void onInventoryClose(InventoryCloseEvent event) {
|
||||
if (event.getPlayer().equals(player)) {
|
||||
if (event.getPlayer().equals(player) && event.getInventory().equals(inv)) {
|
||||
InventoryClickEvent.getHandlerList().unregister(this);
|
||||
InventoryDragEvent.getHandlerList().unregister(this);
|
||||
InventoryCloseEvent.getHandlerList().unregister(this);
|
||||
}
|
||||
}
|
||||
|
@@ -1,7 +1,7 @@
|
||||
name: ButtonControl
|
||||
version: 1.3
|
||||
version: 1.4
|
||||
main: viper.ButtonControl
|
||||
api-version: 1.21
|
||||
api-version: 1.18
|
||||
author: viper
|
||||
description: Ein Plugin, um Türen, Redstone-Lampen und Notenblöcke mit einem Button oder Tageslichtsensor zu steuern.
|
||||
|
||||
|
Reference in New Issue
Block a user