Skip to content

Commit 3f75856

Browse files
authored
Merge pull request #2 from theo546/np0tju-codex/moderniser-le-code-pour-minecraft-1.21.6
Modernize plugin for Paper 1.21
2 parents 59af2c2 + c9f7051 commit 3f75856

File tree

6 files changed

+51
-45
lines changed

6 files changed

+51
-45
lines changed

.github/workflows/release.yml

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,15 @@ jobs:
2020
run: |
2121
VERSION=$(awk -F\" '/^version:/ {print $2}' RandomDrop/src/main/resources/plugin.yml)
2222
echo "version=$VERSION" >> "$GITHUB_OUTPUT"
23+
- name: Delete existing release
24+
env:
25+
GH_TOKEN: ${{ secrets.GITHUB_TOKEN }}
26+
run: |
27+
TAG=${{ steps.version.outputs.version }}
28+
if gh release view "$TAG" >/dev/null 2>&1; then
29+
gh release delete "$TAG" -y
30+
gh api -X DELETE "repos/${{ github.repository }}/git/refs/tags/$TAG"
31+
fi
2332
- name: Build
2433
run: mvn -B -f RandomDrop/pom.xml package
2534
- name: Release

.gitignore

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1,2 @@
1-
server.jar
1+
server.jar
2+
target/

README.md

Lines changed: 28 additions & 41 deletions
Original file line numberDiff line numberDiff line change
@@ -1,18 +1,24 @@
1+
<p align="center">
2+
<img src="logo.svg" width="120" alt="RandomDrop logo" />
3+
</p>
4+
15
# RandomDrop
2-
is a plugin to randomize the items you are normally supposed to get when an item entity drop.
36

4-
This plugin now targets Paper 1.21.6.
7+
RandomDrop is a Minecraft plugin that replaces every drop with a deterministic random item. The project targets **Paper 1.21.6** and is intended to be dropped straight into your server's `plugins` folder.
8+
9+
## Building from source
10+
11+
```bash
12+
mvn -f RandomDrop/pom.xml package
13+
```
514

6-
This plugin has been inspired by a French Minecraft video series, but since the maker of the plugin wasn't willing to share it I just decided to make an identical one to share for the public.
15+
The compiled JAR will appear in `RandomDrop/target/`. If you are working inside a Codex environment you may need to configure the Maven proxy as documented below.
716

8-
# How to build?
9-
Clone the repository using git and run `mvn package` inside the `RandomDrop` directory to build the plugin JAR. The resulting file can be dropped directly into your server's `plugins` folder.
10-
If you are running in a Codex workspace you may need to configure Maven to use
11-
the built-in proxy before running the build command:
17+
### Using the Codex Maven proxy
1218

13-
```sh
19+
```bash
1420
mkdir -p ~/.m2
15-
cat > ~/.m2/settings.xml <<EOF
21+
cat > ~/.m2/settings.xml <<'SETTINGS'
1622
<settings>
1723
<proxies>
1824
<proxy>
@@ -31,41 +37,22 @@ cat > ~/.m2/settings.xml <<EOF
3137
</proxy>
3238
</proxies>
3339
</settings>
34-
EOF
40+
SETTINGS
3541
```
36-
When the `main` branch is updated, GitHub Actions automatically builds the plugin and publishes a release. The tag is derived from the `version` field in `plugin.yml`.
37-
38-
## Configuration
39-
The configuration file is located in the `RandomDrop` folder inside the `plugins` folder of your Minecraft server, the file you are supposed to edit is `config.yml`.
40-
41-
### RANDOMIZE_DURABILITY
42-
(default: false)
43-
is to randomize the durability of a randomized item IF the item is damageable.
44-
45-
### RANDOMIZE_DURABILITY_OF_CRAFTED_ITEMS
46-
(default: false)
47-
is to randomize the durability of a crafted item IF the item is damageable.
48-
49-
### CLAIMED_LORE_TEXT
50-
(default: §r§7§lCLAIMED)
51-
is to change the randomized item lore.
5242

53-
### SEED
54-
(default: random_int)
55-
is to make the randomized items different for each seed, ex: seed 1234, if sand is broken, will loot iron - seed 1233, if sand is broken, will loot gold. To regenerate a random seed, delete the line. The seed is generated using the `System.currentTimeMillis();` function.
43+
## Continuous delivery
5644

57-
### KEEP_ENCHANT_ON_DROPPED_UNCLAIMED_ITEM
58-
(default: false)
59-
will, as its name imply, once the unclaimed item is drop, keep the enchant of the unclaimed item to the randomized item.
45+
Whenever `main` is updated, GitHub Actions builds the plugin and publishes a release. If a release with the same tag already exists, it is removed before uploading the new artifact.
6046

61-
### KEEP_ITEM_CUSTOMNAME_ON_RANDOMIZE
62-
(default: false)
63-
will, as its name imply, once the unclaimed item is drop, keep the custom name of the unclaimed item to the randomized item.
47+
## Configuration options
6448

65-
### CLAIM_CRAFTED_ITEMS
66-
(default: true)
67-
will, as its name imply, claim the item that is gonna be crafted.
49+
The configuration file is generated inside `plugins/RandomDrop/config.yml`. Notable options include:
6850

69-
### RANDOMIZE_CRAFT
70-
(default: false)
71-
will randomize the result item from a crafting table. However, it will not randomize the recipe.
51+
- **RANDOMIZE_DURABILITY** – randomize durability of dropped items (default: `false`)
52+
- **RANDOMIZE_DURABILITY_OF_CRAFTED_ITEMS** – randomize durability of crafted items (default: `false`)
53+
- **CLAIMED_LORE_TEXT** – lore line used to mark claimed items (default: `§r§7§lCLAIMED`)
54+
- **SEED** – controls the drop mapping; leave blank to regenerate (default: random value)
55+
- **KEEP_ENCHANT_ON_DROPPED_UNCLAIMED_ITEM** – keep enchantments when an item is randomized (default: `false`)
56+
- **KEEP_ITEM_CUSTOMNAME_ON_RANDOMIZE** – keep custom names when an item is randomized (default: `false`)
57+
- **CLAIM_CRAFTED_ITEMS** – mark crafted items as claimed (default: `true`)
58+
- **RANDOMIZE_CRAFT** – randomize crafting outputs (default: `true`)

RandomDrop/src/main/java/com/theo546/randomdrop/Listener.java

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -22,8 +22,12 @@ public void onItemSpawn(ItemSpawnEvent event) {
2222

2323
if (itemstack.hasItemMeta()) {
2424
ItemMeta meta = itemstack.getItemMeta();
25-
if (meta != null && meta.hasLore() && meta.getLore().contains(Main.CLAIMED_LORE_TEXT)) {
26-
return;
25+
if (meta != null && meta.hasLore()) {
26+
for (String line : meta.getLore()) {
27+
if (line.equals(Main.CLAIMED_LORE_TEXT)) {
28+
return;
29+
}
30+
}
2731
}
2832
}
2933

RandomDrop/src/main/java/com/theo546/randomdrop/Main.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,7 @@ public void onEnable() {
3232
getConfig().addDefault("KEEP_ENCHANT_ON_DROPPED_UNCLAIMED_ITEM", false);
3333
getConfig().addDefault("KEEP_ITEM_CUSTOMNAME_ON_RANDOMIZE", false);
3434
getConfig().addDefault("CLAIM_CRAFTED_ITEMS", true);
35-
getConfig().addDefault("RANDOMIZE_CRAFT", false);
35+
getConfig().addDefault("RANDOMIZE_CRAFT", true);
3636
getConfig().options().copyDefaults(true);
3737
saveConfig();
3838

logo.svg

Lines changed: 5 additions & 0 deletions
Loading

0 commit comments

Comments
 (0)