Skip to content

Commit 8498557

Browse files
committed
working->
0 parents  commit 8498557

File tree

7 files changed

+452
-0
lines changed

7 files changed

+452
-0
lines changed

.gitignore

Lines changed: 113 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,113 @@
1+
# User-specific stuff
2+
.idea/
3+
4+
*.iml
5+
*.ipr
6+
*.iws
7+
8+
# IntelliJ
9+
out/
10+
11+
# Compiled class file
12+
*.class
13+
14+
# Log file
15+
*.log
16+
17+
# BlueJ files
18+
*.ctxt
19+
20+
# Package Files #
21+
*.jar
22+
*.war
23+
*.nar
24+
*.ear
25+
*.zip
26+
*.tar.gz
27+
*.rar
28+
29+
# virtual machine crash logs, see http://www.java.com/en/download/help/error_hotspot.xml
30+
hs_err_pid*
31+
32+
*~
33+
34+
# temporary files which can be created if a process still has a handle open of a deleted file
35+
.fuse_hidden*
36+
37+
# KDE directory preferences
38+
.directory
39+
40+
# Linux trash folder which might appear on any partition or disk
41+
.Trash-*
42+
43+
# .nfs files are created when an open file is removed but is still being accessed
44+
.nfs*
45+
46+
# General
47+
.DS_Store
48+
.AppleDouble
49+
.LSOverride
50+
51+
# Icon must end with two \r
52+
Icon
53+
54+
# Thumbnails
55+
._*
56+
57+
# Files that might appear in the root of a volume
58+
.DocumentRevisions-V100
59+
.fseventsd
60+
.Spotlight-V100
61+
.TemporaryItems
62+
.Trashes
63+
.VolumeIcon.icns
64+
.com.apple.timemachine.donotpresent
65+
66+
# Directories potentially created on remote AFP share
67+
.AppleDB
68+
.AppleDesktop
69+
Network Trash Folder
70+
Temporary Items
71+
.apdisk
72+
73+
# Windows thumbnail cache files
74+
Thumbs.db
75+
Thumbs.db:encryptable
76+
ehthumbs.db
77+
ehthumbs_vista.db
78+
79+
# Dump file
80+
*.stackdump
81+
82+
# Folder config file
83+
[Dd]esktop.ini
84+
85+
# Recycle Bin used on file shares
86+
$RECYCLE.BIN/
87+
88+
# Windows Installer files
89+
*.cab
90+
*.msi
91+
*.msix
92+
*.msm
93+
*.msp
94+
95+
# Windows shortcuts
96+
*.lnk
97+
98+
target/
99+
100+
pom.xml.tag
101+
pom.xml.releaseBackup
102+
pom.xml.versionsBackup
103+
pom.xml.next
104+
105+
release.properties
106+
dependency-reduced-pom.xml
107+
buildNumber.properties
108+
.mvn/timing.properties
109+
.mvn/wrapper/maven-wrapper.jar
110+
.flattened-pom.xml
111+
112+
# Common working directory
113+
run/

pom.xml

Lines changed: 72 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,72 @@
1+
<?xml version="1.0" encoding="UTF-8"?>
2+
<project xmlns="http://maven.apache.org/POM/4.0.0"
3+
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
4+
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
5+
<modelVersion>4.0.0</modelVersion>
6+
7+
<groupId>me.setloth</groupId>
8+
<artifactId>ModificationMaster</artifactId>
9+
<version>1.0-SNAPSHOT</version>
10+
<packaging>jar</packaging>
11+
12+
<name>ModificationMaster</name>
13+
14+
<properties>
15+
<java.version>21</java.version>
16+
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
17+
</properties>
18+
19+
<build>
20+
<defaultGoal>clean package</defaultGoal>
21+
<plugins>
22+
<plugin>
23+
<groupId>org.apache.maven.plugins</groupId>
24+
<artifactId>maven-compiler-plugin</artifactId>
25+
<version>3.13.0</version>
26+
<configuration>
27+
<source>${java.version}</source>
28+
<target>${java.version}</target>
29+
</configuration>
30+
</plugin>
31+
<plugin>
32+
<groupId>org.apache.maven.plugins</groupId>
33+
<artifactId>maven-shade-plugin</artifactId>
34+
<version>3.5.3</version>
35+
<executions>
36+
<execution>
37+
<phase>package</phase>
38+
<goals>
39+
<goal>shade</goal>
40+
</goals>
41+
</execution>
42+
</executions>
43+
</plugin>
44+
</plugins>
45+
<resources>
46+
<resource>
47+
<directory>src/main/resources</directory>
48+
<filtering>true</filtering>
49+
</resource>
50+
</resources>
51+
</build>
52+
53+
<repositories>
54+
<repository>
55+
<id>papermc-repo</id>
56+
<url>https://repo.papermc.io/repository/maven-public/</url>
57+
</repository>
58+
<repository>
59+
<id>sonatype</id>
60+
<url>https://oss.sonatype.org/content/groups/public/</url>
61+
</repository>
62+
</repositories>
63+
64+
<dependencies>
65+
<dependency>
66+
<groupId>io.papermc.paper</groupId>
67+
<artifactId>paper-api</artifactId>
68+
<version>1.21.1-R0.1-SNAPSHOT</version>
69+
<scope>provided</scope>
70+
</dependency>
71+
</dependencies>
72+
</project>
Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,28 @@
1+
package me.setloth.modificationMaster;
2+
3+
import me.setloth.modificationMaster.commands.Sort;
4+
import me.setloth.modificationMaster.listeners.TreeChop;
5+
import org.bukkit.plugin.java.JavaPlugin;
6+
7+
import java.util.Objects;
8+
import java.util.logging.Logger;
9+
10+
public final class ModificationMaster extends JavaPlugin {
11+
12+
@Override
13+
public void onEnable() {
14+
// Plugin startup logic
15+
Logger.getLogger("MM").info("Registering Events");
16+
getServer().getPluginManager().registerEvents(new TreeChop(), this);
17+
Logger.getLogger("MM").info("Registering Commands");
18+
Objects.requireNonNull(getServer().getPluginCommand("sort")).setExecutor(new Sort());
19+
20+
}
21+
22+
@Override
23+
public void onDisable() {
24+
// Plugin shutdown logic
25+
Logger.getLogger("MM").info("Goodbye :(");
26+
27+
}
28+
}
Lines changed: 43 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,43 @@
1+
package me.setloth.modificationMaster.commands;
2+
3+
import me.setloth.modificationMaster.util.Utility;
4+
import org.bukkit.block.Block;
5+
import org.bukkit.block.BlockState;
6+
import org.bukkit.block.Container;
7+
import org.bukkit.command.Command;
8+
import org.bukkit.command.CommandExecutor;
9+
import org.bukkit.command.CommandSender;
10+
import org.bukkit.command.TabCompleter;
11+
import org.bukkit.entity.Player;
12+
import org.bukkit.inventory.Inventory;
13+
import org.jetbrains.annotations.NotNull;
14+
import org.jetbrains.annotations.Nullable;
15+
16+
import java.util.List;
17+
18+
public class Sort implements CommandExecutor, TabCompleter {
19+
20+
public boolean onCommand(@NotNull CommandSender commandSender, @NotNull Command command, @NotNull String s, @NotNull String[] strings) {
21+
if (!(commandSender instanceof Player p)) return true;
22+
23+
Inventory inv = p.getInventory();
24+
25+
if (strings.length > 0 && strings[0].equalsIgnoreCase("block")) {
26+
Block b = p.getTargetBlock(null, 100);
27+
BlockState bs = b.getState();
28+
29+
if (!(bs instanceof Container c)) return false;
30+
inv = c.getInventory();
31+
}
32+
33+
Utility.sort(inv);
34+
35+
return true;
36+
}
37+
38+
public @Nullable List<String> onTabComplete(@NotNull CommandSender commandSender, @NotNull Command command, @NotNull String s, @NotNull String[] strings) {
39+
if (!(commandSender instanceof Player)) return null;
40+
if (strings.length < 2) return List.of("block");
41+
return null;
42+
}
43+
}
Lines changed: 40 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,40 @@
1+
package me.setloth.modificationMaster.listeners;
2+
3+
import me.setloth.modificationMaster.util.Utility;
4+
import org.bukkit.block.Block;
5+
import org.bukkit.entity.Player;
6+
import org.bukkit.event.EventHandler;
7+
import org.bukkit.event.Listener;
8+
import org.bukkit.event.block.BlockBreakEvent;
9+
import org.bukkit.inventory.ItemStack;
10+
11+
public class TreeChop implements Listener {
12+
13+
14+
@EventHandler
15+
public void onBlockBreak(BlockBreakEvent event) {
16+
Block b = event.getBlock();
17+
Player p = event.getPlayer();
18+
if (Utility.isWood(b.getType())) {
19+
ItemStack stack = p.getInventory().getItemInMainHand();
20+
21+
if (Utility.isAxe(stack.getType())) {
22+
Utility.destroyBranch(b, stack, false);
23+
}
24+
}
25+
if (Utility.isVeinBlock(b.getType())) {
26+
ItemStack stack = p.getInventory().getItemInMainHand();
27+
28+
29+
if (Utility.isPickaxe(stack.getType())) {
30+
Utility.destroyBranch(b, stack, true);
31+
}
32+
}
33+
}
34+
35+
36+
37+
38+
39+
40+
}

0 commit comments

Comments
 (0)