Inital commit

This commit is contained in:
Leon Grünewald 2025-01-28 23:54:14 +01:00
commit 43ab86cf5d
8 changed files with 243 additions and 0 deletions

121
.gitignore vendored Normal file
View file

@ -0,0 +1,121 @@
# User-specific stuff
.idea/
*.iml
*.ipr
*.iws
# IntelliJ
out/
# mpeltonen/sbt-idea plugin
.idea_modules/
# JIRA plugin
atlassian-ide-plugin.xml
# Compiled class file
*.class
# Log file
*.log
# BlueJ files
*.ctxt
# Package Files #
*.jar
*.war
*.nar
*.ear
*.zip
*.tar.gz
*.rar
# virtual machine crash logs, see http://www.java.com/en/download/help/error_hotspot.xml
hs_err_pid*
*~
# temporary files which can be created if a process still has a handle open of a deleted file
.fuse_hidden*
# KDE directory preferences
.directory
# Linux trash folder which might appear on any partition or disk
.Trash-*
# .nfs files are created when an open file is removed but is still being accessed
.nfs*
# General
.DS_Store
.AppleDouble
.LSOverride
# Icon must end with two \r
Icon
# Thumbnails
._*
# Files that might appear in the root of a volume
.DocumentRevisions-V100
.fseventsd
.Spotlight-V100
.TemporaryItems
.Trashes
.VolumeIcon.icns
.com.apple.timemachine.donotpresent
# Directories potentially created on remote AFP share
.AppleDB
.AppleDesktop
Network Trash Folder
Temporary Items
.apdisk
# Windows thumbnail cache files
Thumbs.db
Thumbs.db:encryptable
ehthumbs.db
ehthumbs_vista.db
# Dump file
*.stackdump
# Folder config file
[Dd]esktop.ini
# Recycle Bin used on file shares
$RECYCLE.BIN/
# Windows Installer files
*.cab
*.msi
*.msix
*.msm
*.msp
# Windows shortcuts
*.lnk
.gradle
build/
# Ignore Gradle GUI config
gradle-app.setting
# Cache of project
.gradletasknamecache
**/build/
# Common working directory
run/
runs/
# Avoid ignoring Gradle wrapper jar file (.jar files are usually ignored)
!gradle-wrapper.jar
/run

63
build.gradle Normal file
View file

@ -0,0 +1,63 @@
plugins {
id 'java'
id("xyz.jpenilla.run-paper") version "2.3.1"
}
group = 'de.doggoat'
version = '1.0-SNAPSHOT'
repositories {
mavenCentral()
maven {
name = "spigotmc-repo"
url = "https://hub.spigotmc.org/nexus/content/repositories/snapshots/"
}
maven {
name = "sonatype"
url = "https://oss.sonatype.org/content/groups/public/"
}
}
configurations {
toCopy
}
dependencies {
compileOnly("org.spigotmc:spigot-api:1.21.1-R0.1-SNAPSHOT")
}
def targetJavaVersion = 21
java {
def javaVersion = JavaVersion.toVersion(targetJavaVersion)
sourceCompatibility = javaVersion
targetCompatibility = javaVersion
if (JavaVersion.current() < javaVersion) {
toolchain.languageVersion = JavaLanguageVersion.of(targetJavaVersion)
}
}
tasks.withType(JavaCompile).configureEach {
options.encoding = 'UTF-8'
if (targetJavaVersion >= 10 || JavaVersion.current().isJava10Compatible()) {
options.release.set(targetJavaVersion)
}
}
tasks {
runServer {
// Configure the Minecraft version for our task.
// This is the only required configuration besides applying the plugin.
// Your plugin's jar (or shadowJar if present) will be used automatically.
minecraftVersion("1.21.1")
}
}
processResources {
def props = [version: version]
inputs.properties props
filteringCharset 'UTF-8'
filesMatching('plugin.yml') {
expand props
}
}

0
gradle.properties Normal file
View file

View file

@ -0,0 +1 @@
distributionUrl=https\://services.gradle.org/distributions/gradle-8.8-bin.zip

1
settings.gradle Normal file
View file

@ -0,0 +1 @@
rootProject.name = 'growable-rebalance'

View file

@ -0,0 +1,19 @@
package de.doggoat.growableRebalance;
import de.doggoat.growableRebalance.listeners.GrowthEventListener;
import org.bukkit.plugin.java.JavaPlugin;
public final class GrowableRebalance extends JavaPlugin {
@Override
public void onEnable() {
// Plugin startup logic
getServer().getPluginManager().registerEvents(new GrowthEventListener(), this);
}
@Override
public void onDisable() {
// Plugin shutdown logic
getServer().getPluginManager().disablePlugin(this);
}
}

View file

@ -0,0 +1,34 @@
package de.doggoat.growableRebalance.listeners;
import org.bukkit.Material;
import org.bukkit.block.BlockState;
import org.bukkit.entity.Player;
import org.bukkit.event.EventHandler;
import org.bukkit.event.Listener;
import org.bukkit.event.world.StructureGrowEvent;
import java.util.Arrays;
import java.util.List;
public class GrowthEventListener implements Listener {
List<Material> dirtBlocks = Arrays.asList(Material.ROOTED_DIRT, Material.PODZOL);
List<Material> unreplaceableBlocks = Arrays.asList(Material.MOSS_BLOCK, Material.MUD, Material.MUDDY_MANGROVE_ROOTS);
@EventHandler
public void onStructureGrow(StructureGrowEvent e) {
Player p = e.getPlayer();
List<BlockState> forbiddenBlocks = e.getBlocks().stream()
.filter(blockState-> unreplaceableBlocks.contains(blockState.getBlock().getType()))
.filter(blockState -> dirtBlocks.contains(blockState.getType()))
.toList();
if (!forbiddenBlocks.isEmpty()) {
if (p != null) {
BlockState forbiddenBlockState = forbiddenBlocks.getFirst();
p.sendMessage("You cannot convert " + forbiddenBlockState.getBlock().getType().name() + " to " + forbiddenBlockState.getType().name());
}
e.setCancelled(true);
}
}
}

View file

@ -0,0 +1,4 @@
name: 'GrowableRebalance'
version: '1.0-SNAPSHOT'
main: de.doggoat.growableRebalance.GrowableRebalance
api-version: '1.21'