Skip to content

Commit 8cf329c

Browse files
dG9hc3Qnopjmp
authored andcommitted
PlayerItemHeldEvent Add Slot
1 parent 0588e19 commit 8cf329c

File tree

2 files changed

+91
-19
lines changed

2 files changed

+91
-19
lines changed

README.md

+26-19
Original file line numberDiff line numberDiff line change
@@ -31,36 +31,43 @@ You can download the latest release of Dionysus [here](https://github.com/nopjmp
3131
You can also [build it yourself](https://github.com/nopjmp/Dionysus#building)
3232

3333
## Plugin Developers
34+
###### *With each Dionysus update you must update your dependency.*
3435

35-
In order to use Dionysus as a dependency you must [build it yourself](https://github.com/nopjmp/Dionysus#building).
36-
Each time you want to update your dependency you must re-build dionysus.
37-
38-
Dionysus-API maven dependency:
36+
In order to use Dionysus as a dependency you must [build it yourself](https://github.com/nopjmp/Dionysus#building)
37+
This will add it to your local maven repository folder. Then add the following to your `pom.xml`:
3938

39+
#### Dionysus-API Maven Dependency:
4040
```xml
41-
4241
<dependency>
43-
<groupId>dev.pomf.dionysusdev.pomf.dionysus</groupId>
44-
<artifactId>dionysus-api</artifactId>
45-
<version>1.12.2-R0.1-SNAPSHOT</version>
46-
<scope>provided</scope>
42+
<groupId>dev.pomf.dionysus</groupId>
43+
<artifactId>dionysus-api</artifactId>
44+
<version>1.12.2-R0.1-SNAPSHOT</version>
45+
<scope>provided</scope>
4746
</dependency>
4847
```
49-
50-
Dionysus-Server maven dependency:
51-
48+
#### Dionysus-Server Maven Dependency:
5249
```xml
53-
5450
<dependency>
55-
<groupId>dev.pomf.dionysusdev.pomf.dionysus</groupId>
56-
<artifactId>dionysus</artifactId>
57-
<version>1.12.2-R0.1-SNAPSHOT</version>
58-
<scope>provided</scope>
51+
<groupId>dev.pomf.dionysus</groupId>
52+
<artifactId>dionysus</artifactId>
53+
<version>1.12.2-R0.1-SNAPSHOT</version>
54+
<scope>provided</scope>
5955
</dependency>
6056
```
6157

62-
There is no repository required since the artifacts should be locally installed
63-
via building dionysus.
58+
#### Local Maven Repository:
59+
60+
Windows: `C:\Users\<UserName>\.m2`
61+
Linux: `/home/<UserName>/.m2`
62+
Mac: `/Users/<UserName>/.m2`
63+
64+
```xml
65+
<repository>
66+
<id>project.local</id>
67+
<name>project</name>
68+
<url>file:/Users/User/.m2/repository/</url>
69+
</repository>
70+
```
6471

6572
## Building
6673

Original file line numberDiff line numberDiff line change
@@ -0,0 +1,65 @@
1+
From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
2+
From: RemainingToast <[email protected]>
3+
Date: Tue, 6 Sep 2022 00:43:38 +1000
4+
Subject: [PATCH] PlayerItemHeldEvent Add Slot
5+
6+
7+
diff --git a/src/main/java/org/bukkit/event/player/PlayerItemHeldEvent.java b/src/main/java/org/bukkit/event/player/PlayerItemHeldEvent.java
8+
index f0d055a0e4466e9487c87b4d771fd2c892aa373c..68777b55fa0756777a563351a870cc90e198ceab 100644
9+
--- a/src/main/java/org/bukkit/event/player/PlayerItemHeldEvent.java
10+
+++ b/src/main/java/org/bukkit/event/player/PlayerItemHeldEvent.java
11+
@@ -3,6 +3,7 @@ package org.bukkit.event.player;
12+
import org.bukkit.entity.Player;
13+
import org.bukkit.event.Cancellable;
14+
import org.bukkit.event.HandlerList;
15+
+import org.bukkit.inventory.ItemStack;
16+
17+
/**
18+
* Fired when a player changes their currently held item
19+
@@ -10,13 +11,15 @@ import org.bukkit.event.HandlerList;
20+
public class PlayerItemHeldEvent extends PlayerEvent implements Cancellable {
21+
private static final HandlerList handlers = new HandlerList();
22+
private boolean cancel = false;
23+
- private final int previous;
24+
- private final int current;
25+
+ private final Slot previous; // Dionysus - Integer -> Slot
26+
+ private final Slot current; // Dionysus - Integer -> Slot
27+
28+
public PlayerItemHeldEvent(final Player player, final int previous, final int current) {
29+
super(player);
30+
- this.previous = previous;
31+
- this.current = current;
32+
+ // Dionysus start - Integer -> Slot
33+
+ this.previous = new Slot(this.player.getInventory().getItem(previous) , previous);
34+
+ this.current = new Slot(this.player.getInventory().getItem(current), current);
35+
+ // Dionysus end
36+
}
37+
38+
/**
39+
@@ -24,7 +27,7 @@ public class PlayerItemHeldEvent extends PlayerEvent implements Cancellable {
40+
*
41+
* @return Previous slot index
42+
*/
43+
- public int getPreviousSlot() {
44+
+ public Slot getPreviousSlot() { // Dionysus - Integer -> Slot
45+
return previous;
46+
}
47+
48+
@@ -33,7 +36,7 @@ public class PlayerItemHeldEvent extends PlayerEvent implements Cancellable {
49+
*
50+
* @return New slot index
51+
*/
52+
- public int getNewSlot() {
53+
+ public Slot getNewSlot() { // Dionysus - Integer -> Slot
54+
return current;
55+
}
56+
57+
@@ -53,4 +56,8 @@ public class PlayerItemHeldEvent extends PlayerEvent implements Cancellable {
58+
public static HandlerList getHandlerList() {
59+
return handlers;
60+
}
61+
+
62+
+ public record Slot(ItemStack item, int index) { // Dionysus - Integer -> Slot
63+
+
64+
+ }
65+
}

0 commit comments

Comments
 (0)