fixed pokeballs plugin

This commit is contained in:
Janik Heß
2025-03-05 13:37:07 +01:00
parent 3ab390414c
commit b7334e484f
9 changed files with 100 additions and 110 deletions

BIN
CUSTOM.zip Executable file

Binary file not shown.

View File

@@ -31,7 +31,7 @@ public class CustomItems implements Listener {
}
private String url = "https://mc.hessj.de/texturepack/CUSTOM.zip";
private String sha1 = "f6187af75579b5ce34850fe4cbc9bed4e57a04e6";
private String sha1 = "a7f7bde9e54279b502d65435877d251aa522cabc";
@EventHandler
public void onPlayerJoin(PlayerJoinEvent e) {

View File

@@ -87,25 +87,6 @@ public class EnvironmentExListeners implements Listener {
return false;
}
private void randomWeather(Block bed) {
App.main.log(bed.getWorld().getWeatherDuration() + "dura");
App.main.log(bed.getWorld().isThundering() + "thunder");
App.main.log(bed.getWorld().hasStorm() + "storm");
if (bed.getWorld().isThundering()) {
bed.getWorld().setThundering(false);
Random randomno = new Random();
Integer random = randomno.nextInt((1 - 0) + 1) + 0;
if (random == 0) {
bed.getWorld().setStorm(true);
} else {
bed.getWorld().setStorm(false);
}
}
}
@EventHandler
public void onBedEnter(PlayerBedEnterEvent e) {
@@ -124,7 +105,6 @@ public class EnvironmentExListeners implements Listener {
if (e.getPlayer().isSleeping()) {
e.getPlayer().wakeup(true);
}
randomWeather(e.getBed());
} else {
e.getPlayer()
@@ -184,7 +164,6 @@ public class EnvironmentExListeners implements Listener {
}
}
Bukkit.getWorlds().get(0).setTime(24000);
randomWeather(e.getBed());
} else if (voteForNo >= voteForYes) {

View File

@@ -29,7 +29,7 @@
<artifactId>mc-api</artifactId>
<version>1.0</version>
<scope>system</scope>
<systemPath>/Users/janik/Documents/MCPlugins/craftbukkit-1.21.1.jar</systemPath>
<systemPath>/Users/janik/Desktop/MCPlugins/craftbukkit.jar</systemPath>
</dependency>
</dependencies>
<build>

46
pokeballs/build.gradle.kts Executable file
View File

@@ -0,0 +1,46 @@
plugins {
`java-library`
id("io.papermc.paperweight.userdev") version "2.0.0-beta.14"
id("xyz.jpenilla.run-paper") version "2.3.1" // Adds runServer and runMojangMappedServer tasks for testing
}
group = "de.hessj.pokeballs"
version = "1.0-SNAPSHOT"
description = "pokeballs"
dependencies {
implementation(files("/Users/janik/Desktop/MCPlugins/craftbukkit.jar"))
implementation(files("/Users/janik/Desktop/helper-1.0-SNAPSHOT.jar"))
paperweight.paperDevBundle("1.21.4-R0.1-SNAPSHOT")
}
tasks {
// Configure reobfJar to run when invoking the build task
assemble {
dependsOn(reobfJar)
}
compileJava {
options.encoding = Charsets.UTF_8.name() // We want UTF-8 for everything
// Set the release flag. This configures what version bytecode the compiler will emit, as well as what JDK APIs are usable.
// See https://openjdk.java.net/jeps/247 for more information.
options.release.set(21)
}
javadoc {
options.encoding = Charsets.UTF_8.name() // We want UTF-8 for everything
}
processResources {
filteringCharset = Charsets.UTF_8.name() // We want UTF-8 for everything
val props = mapOf(
"name" to project.name,
"version" to project.version,
"description" to project.description,
"apiVersion" to "1.21"
)
inputs.properties(props)
filesMatching("plugin.yml") {
expand(props)
}
}
}

View File

@@ -1,68 +0,0 @@
<?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/xsd/maven-4.0.0.xsd">
<modelVersion>4.0.0</modelVersion>
<groupId>de.hessj.pokeballs</groupId>
<artifactId>pokeballs</artifactId>
<version>1.0-SNAPSHOT</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>
</properties>
<repositories>
<repository>
<id>papermc</id>
<url>https://repo.papermc.io/repository/maven-public/</url>
</repository>
</repositories>
<dependencies>
<dependency>
<groupId>io.papermc.paper</groupId>
<artifactId>paper-api</artifactId>
<version>1.21.4-R0.1-SNAPSHOT</version>
<scope>provided</scope>
</dependency>
<dependency>
<groupId>org.bukkit</groupId>
<artifactId>mc-api</artifactId>
<version>1.0</version>
<scope>system</scope>
<systemPath>/Users/janik/Documents/MCPlugins/craftbukkit-1.21.1.jar</systemPath>
</dependency>
<dependency>
<groupId>de.hessj.helper</groupId>
<artifactId>helper</artifactId>
<version>1.0</version>
<scope>system</scope>
<systemPath>/Users/janik/Desktop/helper-1.0-SNAPSHOT.jar</systemPath>
</dependency>
<dependency>
<groupId>org.apache.commons</groupId>
<artifactId>commons-lang3</artifactId>
<version>3.12.0</version>
</dependency>
</dependencies>
<build>
<sourceDirectory>${project.basedir}/src/main/java</sourceDirectory>
<resources>
<resource>
<directory>${project.basedir}/src/main/resources</directory>
<includes>
<include>plugin.yml</include>
</includes>
</resource>
</resources>
<plugins>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-jar-plugin</artifactId>
<version>2.3.1</version>
<configuration>
<outputDirectory>/Users/janik/Desktop</outputDirectory>
</configuration>
</plugin>
</plugins>
</build>
</project>

5
pokeballs/settings.gradle.kts Executable file
View File

@@ -0,0 +1,5 @@
plugins {
id("org.gradle.toolchains.foojay-resolver-convention") version "0.9.0"
}
rootProject.name = "pokeballs"

View File

@@ -1,6 +1,8 @@
package de.hessj.pokeballs;
import java.util.Arrays;
import java.util.HashMap;
import java.util.List;
import org.apache.commons.lang3.StringUtils;
import org.bukkit.Bukkit;
@@ -12,6 +14,7 @@ import org.bukkit.entity.Player;
import org.bukkit.inventory.ItemStack;
import org.bukkit.inventory.ShapedRecipe;
import org.bukkit.inventory.meta.ItemMeta;
import org.bukkit.inventory.meta.components.CustomModelDataComponent;
import org.bukkit.persistence.PersistentDataType;
import org.bukkit.plugin.PluginManager;
import org.bukkit.plugin.java.JavaPlugin;
@@ -52,6 +55,12 @@ public class App extends JavaPlugin {
ItemMeta newPokeballMeta = newPokeball.getItemMeta();
newPokeballMeta.displayName(Component.translatable(ChatColor.WHITE + "Pokéball"));
newPokeballMeta.setCustomModelData(1000011);
CustomModelDataComponent cmdc4 = newPokeballMeta.getCustomModelDataComponent();
List<String> list4 = Arrays.asList("pokeball");
cmdc4.setStrings(list4);
newPokeballMeta.setCustomModelDataComponent(cmdc4);
newPokeballMeta.getPersistentDataContainer().set(nskPokeball, PersistentDataType.STRING, "R3S_Pokeball");
newPokeball.setItemMeta(newPokeballMeta);
ShapedRecipe pokeballRecipe = new ShapedRecipe(nskPokeball, newPokeball);
@@ -74,6 +83,9 @@ public class App extends JavaPlugin {
if(!((Player) sender).isOp()){
return true;
}
if(args != null && args.length > 0){
if (label.equalsIgnoreCase("get") && args[0].toString() != "" && args[0].toString().equals("pokeball") && args.length == 2 && StringUtils.isNumeric(args[1])) {
ItemStack is = newPokeball.clone();
is.setAmount(Integer.parseInt(args[1]));
@@ -83,6 +95,7 @@ public class App extends JavaPlugin {
((Player) sender).getInventory().addItem(newPokeball);
}
}
}
return true;
}

View File

@@ -10,6 +10,7 @@ import org.bukkit.Sound;
import org.bukkit.block.data.type.Fence;
import org.bukkit.block.data.type.Stairs;
import org.bukkit.entity.Allay;
import org.bukkit.entity.Armadillo;
import org.bukkit.entity.Axolotl;
import org.bukkit.entity.Bee;
import org.bukkit.entity.Cat;
@@ -295,8 +296,8 @@ public class PokeballsListeners implements Listener {
whichHitEntity(e, EntityType.MULE, "Maultier", null, null, ((Mule) e.getHitEntity()).getAge());
}
break;
case MUSHROOM_COW:
whichHitEntity(e, EntityType.MUSHROOM_COW, "Pilzkuh", null, null,
case MOOSHROOM:
whichHitEntity(e, EntityType.MOOSHROOM, "Pilzkuh", null, null,
((MushroomCow) e.getHitEntity()).getAge());
break;
case OCELOT:
@@ -333,7 +334,7 @@ public class PokeballsListeners implements Listener {
((Frog) e.getHitEntity()).getAge());
break;
case ALLAY:
whichHitEntity(e, EntityType.FROG, "Hilfsgeist", null, null, null);
whichHitEntity(e, EntityType.ALLAY, "Hilfsgeist", null, null, null);
break;
case WOLF:
if (!((Wolf) e.getHitEntity()).isTamed()) {
@@ -353,6 +354,9 @@ public class PokeballsListeners implements Listener {
"Wer versucht, die Katze eines anderen zu stehlen, ist ein gemeiner Dieb!"));
}
break;
case ARMADILLO:
whichHitEntity(e, EntityType.ARMADILLO, "Gürteltier", null, null, ((Armadillo) e.getHitEntity()).getAge());
break;
default:
break;
}
@@ -720,7 +724,14 @@ public class PokeballsListeners implements Listener {
c.setCatType(Cat.Type.WHITE);
break;
}
}
if (((Snowball) e.getEntity()).getItem().getItemMeta().getPersistentDataContainer()
.get(App.main.nskEntityPokeball, PersistentDataType.STRING).equals("Gürteltier")) {
Armadillo armadillo = e.getEntity().getWorld().spawn(loc, Armadillo.class);
armadillo.setAge(((Snowball) e.getEntity()).getItem().getItemMeta().getPersistentDataContainer()
.get(App.main.nskAgePokeball, PersistentDataType.INTEGER));
}
e.getEntity().getWorld().spawnParticle(Particle.FLASH, loc, 1);
App.main.isThrownHM.put((Player) e.getEntity().getShooter(), false);
@@ -910,13 +921,13 @@ public class PokeballsListeners implements Listener {
}
} else if (variant instanceof org.bukkit.entity.Frog.Variant) {
switch ((org.bukkit.entity.Frog.Variant) variant) {
case COLD:
switch (((org.bukkit.entity.Frog.Variant) variant).toString()) {
case "COLD":
usedPBm.getPersistentDataContainer().set(App.main.nskEntVariantPokeball,
PersistentDataType.INTEGER, 0);
lore.add(Component.text(ChatColor.WHITE + "Farbe: " + ChatColor.GREEN + "Grün"));
break;
case TEMPERATE:
case "TEMPERATE":
usedPBm.getPersistentDataContainer().set(App.main.nskEntVariantPokeball,
PersistentDataType.INTEGER, 1);
tLore = Component.text(ChatColor.WHITE + "Farbe: ")
@@ -924,11 +935,13 @@ public class PokeballsListeners implements Listener {
.decoration(TextDecoration.ITALIC, false));
lore.add(tLore);
break;
case WARM:
case "WARM":
usedPBm.getPersistentDataContainer().set(App.main.nskEntVariantPokeball,
PersistentDataType.INTEGER, 2);
lore.add(Component.text(ChatColor.WHITE + "Farbe: " + ChatColor.GRAY + "Grau"));
break;
default:
break;
}
} else if (variant instanceof org.bukkit.entity.Parrot.Variant) {
switch ((org.bukkit.entity.Parrot.Variant) variant) {
@@ -1004,24 +1017,24 @@ public class PokeballsListeners implements Listener {
break;
}
} else if (variant instanceof Cat.Type) {
switch ((Cat.Type) variant) {
case ALL_BLACK:
switch (((Cat.Type) variant).toString()) {
case "ALL_BLACK":
usedPBm.getPersistentDataContainer().set(App.main.nskEntVariantPokeball,
PersistentDataType.INTEGER, 0);
lore.add(Component.text(ChatColor.WHITE + "Farbe: " + ChatColor.BLACK + "Schwarz"));
break;
case BLACK:
case "BLACK":
usedPBm.getPersistentDataContainer().set(App.main.nskEntVariantPokeball,
PersistentDataType.INTEGER, 1);
lore.add(Component.text(
ChatColor.WHITE + "Farbe: " + ChatColor.BLACK + "Schwarz" + ChatColor.WHITE + "weiß"));
break;
case BRITISH_SHORTHAIR:
case "BRITISH_SHORTHAIR":
usedPBm.getPersistentDataContainer().set(App.main.nskEntVariantPokeball,
PersistentDataType.INTEGER, 2);
lore.add(Component.text(ChatColor.WHITE + "Farbe: " + ChatColor.GRAY + "Grau"));
break;
case CALICO:
case "CALICO":
usedPBm.getPersistentDataContainer().set(App.main.nskEntVariantPokeball,
PersistentDataType.INTEGER, 3);
@@ -1035,13 +1048,13 @@ public class PokeballsListeners implements Listener {
lore.add(tLore);
break;
case JELLIE:
case "JELLIE":
usedPBm.getPersistentDataContainer().set(App.main.nskEntVariantPokeball,
PersistentDataType.INTEGER, 4);
lore.add(Component.text(
ChatColor.WHITE + "Farbe: " + ChatColor.GRAY + "Grau" + ChatColor.WHITE + "weiß"));
break;
case PERSIAN:
case "PERSIAN":
usedPBm.getPersistentDataContainer().set(App.main.nskEntVariantPokeball,
PersistentDataType.INTEGER, 5);
tLore = Component.text(ChatColor.WHITE + "Farbe: ")
@@ -1049,7 +1062,7 @@ public class PokeballsListeners implements Listener {
.decoration(TextDecoration.ITALIC, false));
lore.add(tLore);
break;
case RAGDOLL:
case "RAGDOLL":
usedPBm.getPersistentDataContainer().set(App.main.nskEntVariantPokeball,
PersistentDataType.INTEGER, 6);
tLore = Component.text(ChatColor.WHITE + "Farbe: ")
@@ -1059,7 +1072,7 @@ public class PokeballsListeners implements Listener {
false));
lore.add(tLore);
break;
case RED:
case "RED":
usedPBm.getPersistentDataContainer().set(App.main.nskEntVariantPokeball,
PersistentDataType.INTEGER, 7);
tLore = Component.text(ChatColor.WHITE + "Farbe: ")
@@ -1067,7 +1080,7 @@ public class PokeballsListeners implements Listener {
.decoration(TextDecoration.ITALIC, false));
lore.add(tLore);
break;
case SIAMESE:
case "SIAMESE":
usedPBm.getPersistentDataContainer().set(App.main.nskEntVariantPokeball,
PersistentDataType.INTEGER, 8);
tLore = Component.text(ChatColor.WHITE + "Farbe: ")
@@ -1077,7 +1090,7 @@ public class PokeballsListeners implements Listener {
.decoration(TextDecoration.ITALIC, false));
lore.add(tLore);
break;
case TABBY:
case "TABBY":
usedPBm.getPersistentDataContainer().set(App.main.nskEntVariantPokeball,
PersistentDataType.INTEGER, 9);
tLore = Component.text(ChatColor.WHITE + "Farbe: ")
@@ -1085,11 +1098,13 @@ public class PokeballsListeners implements Listener {
.decoration(TextDecoration.ITALIC, false));
lore.add(tLore);
break;
case WHITE:
case "WHITE":
usedPBm.getPersistentDataContainer().set(App.main.nskEntVariantPokeball,
PersistentDataType.INTEGER, 10);
lore.add(Component.text(ChatColor.WHITE + "Farbe: " + ChatColor.WHITE + "Weiß"));
break;
default:
break;
}
} else if (variant instanceof Horse.Color) {
switch ((Horse.Color) variant) {