#help-development

1 messages · Page 1749 of 1

quaint mantle
#

Imagine.

lean gull
#

but it's 6

lyric oar
#

hey, it's me again, now i would like to make a permission plugin for my server but i don't know how to deny all permissions to a player. Is there a way to do that?

quaint mantle
lean gull
#

it's 8 but without the bold &l and &x it's 6

slim kernel
quaint mantle
#

Tho it is kinda hard to see those characters in app discord…

lean gull
#

don't make excuses, you were toxic for no reason whatsoever and it ended up you were wrong

#

now can i please get some help from someone who won't judge me?

lean gull
quaint mantle
#

Uhhh ok…

#

Lol

slim kernel
#

my start.bat looks like this tho. Do I just change the %JAVA_PARAMETERS% to %JAVA_8% then?

#
@echo off

call settings.bat

:start_server
echo Starting SevTech Ages of the Sky Server...
java -server -Xms%MIN_RAM% -Xmx%MAX_RAM% %JAVA_PARAMETERS% -jar %SERVER_JAR% nogui
pause
exit /B

goto start_server
quaint mantle
#

Change java-> %JAVA_8%

slim kernel
quaint mantle
slim kernel
#

@lost matrix thank you so much for always helping me aswell

lean gull
#

how do i get the amount of values in a config file?

#

like a FileConfiguration type thing

quaint mantle
#

getKeys(false)

#

.size

#

(true) would return all keys for the given section and all of their subsections as well

tardy delta
#

can i compare world instances or do i need to check for the name?

quaint mantle
#

So if you just want the base section you use (false)

quaint mantle
#

Why don’t you test it out 🤔

tardy delta
#

yea true but i was just wondering

quaint mantle
#

Yea not sure about that one

tardy delta
#

i'm not going to compile and run it every time 😂

quaint mantle
#

Lol

silver shuttle
#

gradle > maven == true ?

tardy delta
#

gradle brr

silver shuttle
#

good, glad Ive been using Maven all along then

lean gull
#

how do i know if i use maven or gradle

tardy delta
#

probably maven

lean gull
#

maven is the buildtools one right?

tardy delta
#

uhh

#

that doesnt matter i guess

ivory sleet
#

Pretty much

ivory sleet
lean gull
tardy delta
#

yesh

lean gull
#

wohh how u make it look liek dat

tardy delta
#

uhh a theme i guess

tight hedge
#

Can someone help me? How do i make a holographic display that displays the balance of the baltop, idk what placeholders

#

plz help out boys need this asap

jade perch
#

Paying someone to do it would probably be the fastest

tight hedge
#

sort of like this

bold plank
#

is setmarker a paper method or does spigot have it too?

tight hedge
# tight hedge

I got this far but i dont know how to make it auto update.

jade perch
tight hedge
# jade perch spigot has it

If i have a command that runs every 15 second to auto update the entire holograph would that lag the server?

bold plank
#

sweeeeet

unique meteor
#

and its the other way around, if spigot have it, paper would have it too.

unique meteor
tardy delta
#

you might be doing it async if you have alot of scoreboards

tight hedge
#

Whats that?

tight hedge
#

is there a difference if i run it every 15sec or 1 sec (performance wise)

jade perch
#

Yes

unique meteor
jade perch
#

it will run 15 times

tight hedge
#

updating placeholders

#

I've got to the placeholder part on display but i dont know how to make it updatre

unique meteor
#

since you will only notice a peak of performance if your operation comes over 20ms, i wouldn't think so

#

unless you are accessing some DB or files

tardy delta
#

does that else has a purpose?

tight hedge
#

I will use a plugin that runs commands and just redoes the entire command aka /hd setline baltop 1 %baltop_1_player%

tardy delta
#

as i do a return

silver shuttle
#
            Player shooter = killEvent.getKiller();
            UUID shooterUUID = shooter.getUniqueId();
            if(playerKills.containsKey(shooterUUID)) {
                int val = playerKills.get(shooterUUID);
                int time = val % 100;
                val = val - time;
                playerKills.put(shooterUUID, val + 110);
            }
            else {
                playerKills.put(shooterUUID, 110);
            }
            if(!(playerStreaks.containsKey(shooter.getUniqueId()))) {
                scheduler.runTaskTimer(myPlugin, task -> {
                    playerStreaks.put(shooterUUID, task.getTaskId());
                    playerKills.put(shooterUUID, (playerKills.get(shooterUUID) - 1));
                    if(playerKills.get(shooterUUID) % 100 == 0) {
                        task.cancel();
                        playerKills.remove(shooterUUID);
                        playerStreaks.remove(shooterUUID);
                    }
                }, 20L, 20L);
            }
            int kills = (playerKills.get(shooterUUID) - (playerKills.get(shooterUUID) % 100)) / 100;
            final char killMarker;
            if(kills > 10) {
                kills = 10;
            }
            killMarker = (char) ('\ue100' + kills - 1);
            String killSound = "killmarker" + kills;
            shooter.sendTitle("" + killMarker, "", 0, 10 + (kills * 4), 10);
            shooter.playSound(shooter.getLocation(), killSound, 1, 1);
#

Okay so this event gets called whenever a player kills another entity.
It adds the killer's uuid to a map and assigns a score (100 for each kill, 10 points as timer)
Then it starts a streak timer which then removes 1 point per second from each players score
This task gets cancelled once the score is divisable by 100 and rest is 0
However, the line
playerKills.put(shooterUUID, (playerKills.get(shooterUUID) - 1));
returns an exception sometimes, saying that the return value is null.
Any ideas why that might happen or how to fix that?

#

(It is not really if a player kills any entity, it is related to CrackShot, killing entities is just for reference as it is the same effect)

jade perch
#

Weird way to do that

silver shuttle
#

What's a better way

#

I tried to think of one yet I didnt have any ideas

silver shuttle
last ledge
#

I am trying to use Custom Enchanments for ItemStack items(Armors), but when i try to run it it says : Caused by: java.lang.IllegalArgumentException: Enchantment level is either too low or too high (given 3, bounds are 1 to 2)

jade perch
#

You don't need two different hashmaps

last ledge
#

how do i use custom enchanments

#

like unbreaking 10

#

in itemstack?

silver shuttle
jade perch
#

Yeah you can just make an object that tracks both

silver shuttle
#

and so I know which player already has a clock to reduce the tasks

silver shuttle
fiery inlet
#

Anyone know how to make piglins dance the victory dance they do when killing a hog??

jade perch
#

make a hashmap with the uuid key, and make an object that stores two integers

tardy delta
jade perch
#

then you can have HashMap<UUID, yourRandomTwoIntegerObject>

silver shuttle
last ledge
tardy delta
#

normally i had something like this

fiery inlet
#

does no one know how to make piglin dance

last ledge
silver shuttle
tardy delta
#

if set to false it would normally accept higher levels

jade perch
silver shuttle
jade perch
#

might have something to do with how you're removing the uuid from the hashmap

silver shuttle
#

the problem is: if it gets removed, the task also gets immediately cancelled

#

ooooh wait

#

it coul dbe

#

no wait

#

doesnt make sense

jade perch
#

Would be much easier to just make a hashmap with a tracker object

#

instead of using hashmap.remove

#

then you wouldn't have to worry about it

silver shuttle
#

mhm

#

any better overall solution for this?

jade perch
#

Yes, make the tracker object like I said before

silver shuttle
#

no like overall

tight hedge
#

is there a placeholder for economy top with vault?

jade perch
#

Not off the top of my head

tight hedge
#

could anyone help me out please because im having alot of issues with it.

silver shuttle
#

I figured out the problem

#

since the task has a starting delay before it adds it to the streaks map

#

it might be starting 2 tasks

#

which causes the problems

#

so i need to set it to 11 seconds and set the delay to 0

#

let me try this again

bold plank
#

Hey guys I'm trying to make a custom terrain generator, but biome generation appears fragmented, could someone help me out?

#
    public void generateNoise(WorldInfo worldInfo, Random random, int chunkX, int chunkZ, ChunkData chunkData) {
        SimplexOctaveGenerator generator = new SimplexOctaveGenerator(new Random(worldInfo.getSeed()), 6);
        generator.setScale(0.01);

       
        Material material = Material.STONE;
       
        int worldX = chunkX * 16;
        int worldZ = chunkZ * 16;
        if(chunkData.getBiome(chunkX, chunkData.getMinHeight(), chunkZ) == Biome.MOUNTAINS) {
            for (int x = 0; x < 16; x++) {
                for (int z = 0; z < 16; z++) {
                    double noise = generator.noise(worldX + x, worldZ + z, 1, 1, true);
                    int height = (int) (noise * 40);
                    height += 84;
                    if (height > chunkData.getMaxHeight()) {
                        height = chunkData.getMaxHeight();
                    }
                    for (int y = 0; y < height; y++) {
                        
                        chunkData.setBlock(x, y, z, Material.GRASS_BLOCK);
                        chunkData.setBlock(z, y-1, z, Material.DIRT);
                        for (int i = y-2; i > 0; i--)
                            chunkData.setBlock(x, i, z, Material.STONE);
                    }
        
           
        }}}
        if(chunkData.getBiome(chunkX, chunkData.getMinHeight(), chunkZ) == Biome.PLAINS) {
            for (int x = 0; x < 16; x++) {
                for (int z = 0; z < 16; z++) {
                    double noise = generator.noise(worldX + x, worldZ + z, 1, 1, true);
                    int height = (int) (noise * 40);
                    height += 84;
                    if (height > chunkData.getMaxHeight()) {
                        height = chunkData.getMaxHeight();
                    }
                    for (int y = 0; y < height; y++) {
                        chunkData.setBlock(x, y, z, material);
                    }
                }
            }
        }
    }```
silver shuttle
#

Is there any way to check if a player already sees a title?

stone sinew
silver shuttle
#

there are no packets sent after the initial

winged hinge
#

how can i remove effectivePermissions which i didn't set by self? Unset don't work

i tried this, but in the gotten attachment in line 3 do not exist the effective Permissions

playerPermissions.put(event.getPlayer().getUniqueId(), event.getPlayer().addAttachment(getPlugin()));
event.getPlayer().sendMessage("added uuid to HashMap playerPermissions");

PermissionAttachment attachment = playerPermissions.get(event.getPlayer().getUniqueId());
event.getPlayer().sendMessage("Attachment permissions: " + getAllPermissions(event.getPlayer()));
playerPermissions.get(event.getPlayer().getUniqueId()).unsetPermission("multiverse.help");
event.getPlayer().sendMessage("Attachment permissions after unset: " + getAllPermissions(event.getPlayer()));
opaque panther
#

someone help me

fiery inlet
#

sendPacket(new PacketPlayOutEntityMetadata(19, true, DataWatcherRegistry.i);

private void sendPacket(Packet<?> packet) {
        for (Player all : Bukkit.getOnlinePlayers()) {
            CraftPlayer player = (CraftPlayer) all;
            player.getHandle().b.sendPacket(packet);
        }

how to make piglin dance, me sad inside dis annoy me

opaque panther
#

i tried to make gui in spigot but console says initializing legacy material

#

spigot version is 1.17.1

fiery inlet
#

send code

karmic mural
#

?paste

undone axleBOT
opaque panther
#

and api-version is 1.17

tardy delta
#

does HashMap#remove(Object key, Object value) tries to remove as much as possible or does it only removes it the map contains both?

lost matrix
opaque panther
#

no no i only have my plugin

visual tide
opaque panther
#

yea

visual tide
#

odd

opaque panther
#

name: MyFirstPlugin
version: '${project.version}'
main: me.ihsan.myfirstplugin.MyFirstPlugin
api-version: '1.17'
authors: [ ihsan ]
description: My first plugin
commands:
die:
description: Simple way to attempt suicide.
usage: /<command>
aliases:
- suicide
- killme
about:
description: About the server.
usage: /<command>
aliases:
- info
- server
tpa:
description: Send a teleport request to a player.
usage: /<command> <player>
fly:
description: Get ability to fly. Only for operators.
usage: /<command>
tpaccept:
description: Accept teleport request.
tpdeny:
description: Deny teleport request.
menu:
description: Opens menu.
usage: /<command>

#

api

#

verson is there

lost matrix
#

remove the ' chars

opaque panther
#

oh

undone axleBOT
opaque panther
#

i removed it and tried to but still didnt work @lost matrix

winged hinge
lost matrix
#

Look inside the compiled jar (inside your plugins folder) and make sure your plugin.yml is in there

tardy delta
#

i wasn't responding to that

opaque panther
winged hinge
lost matrix
opaque panther
#

wait i checked my jar file and there is plugin.xml

#

thats it?

hasty prawn
tardy delta
#

uhh what

#

ah got it

opaque panther
#

it is still saying initializing legacy even tho the api version is 1.17

#

anyone any idea?

#

?

#

this is the message in console

#

[21:21:15] [Server thread/WARN]: Initializing Legacy Material Support. Unless you have legacy plugins and/or data this is a bug!

#

?paste

undone axleBOT
opaque panther
#

is tehre something wrong in the class where i made the gui?

#

how do i put code here

karmic mural
#

Just click that link

#

and then ctrl + s

#

And copy the link in your browrser

#

browser*

opaque panther
#

can you see it

karmic mural
#

Yes

opaque panther
#

Initializing Legacy Material Support issue

fallow merlin
#

Kind of unrelated to development; is there a mod that allows me to see mob pathfinder goals?

#

similar to bedrock developer edition

tardy delta
#

if i only create one instance of a class, is static useful?

upper vale
#

As in a singleton pattern?

patent quarry
#

Hey, someone know if I can avoid the name of the armorstand to turn black ?

hasty prawn
#

Make it a Marker and put the armorstand above the block

patent quarry
#

I will try that ty

patent quarry
onyx shale
#

afaik its a rather common problem

#

try setting the armor stand on fire

lost matrix
patent quarry
worldly ingot
#

Otherwise, if you're capable of Forge (or Fabric) modding, you can definitely enable those renderers yourself. They're built into the client, they're just not activated

fallow merlin
tardy delta
#

can't i use someString.replace() instead of someString = someString.replace()?

lost matrix
tardy delta
#

ah

#

the char[] is final smh

waxen plinth
#

StringBuilder is mutable

quaint mantle
#

i have a question about substring

#

for example

#

skull-blablabla

#

if i want the blablabla

#

should the startindex be 6 ?

lost matrix
#

Program it position agnostic

#
  public String getStringAfter(String line, char delim) {
    return line.substring(line.indexOf(delim));
  }
#

This will return the String which comes after the first delimiter char

#

Doesnt matter where its located at

quaint mantle
#

if the char delim is -

#

will it get for example blablabla

ivory sleet
lost matrix
#

So then

  public String getStringAfter(String line, char delim) {
    return line.substring(line.indexOf(delim) + 1);
  }
toxic mesa
#

is there an easy way to figure out where lost connection: Internal Exception: java.lang.IllegalStateException: Asynchronous getNearbyEntities! is coming from?
I legit can't figure out where it's coming from as I use a util function to fetch nearby entities and it worked and now it doesn't?

lost matrix
#

Sure. Some bob calls spigot methods async.

#

Show the places where you call it

toxic mesa
#

there's a shit load of em

#

just go through them all and debug one by one or smth?

lost matrix
#

Why are there so many places where this method is called? That sounds like a big design problem.
Do you call this method in an event that starts with "Async"?

#

Or in a task that was started using ".runTaskAsynchronously()"?

ancient plank
#

some bob square pants

toxic mesa
#

am busy reworking old messed up plugin, only events used don't use getNearbyEntities, uses packets, no clue if that effects anything
Might be easier to just start from scratch lmfao

lost matrix
#

Yeah scrap that

rancid pine
#

How would I change mob textures in my plug-in, I want to make the creeper texture blue

#

Instead of green

lost matrix
#

You cant unless you distribute a resource pack to the clients

rancid pine
#

Oh ok

#

Would there be a way to make mobs huge

lost matrix
#

With a forge mod probably

fading lake
young knoll
#

I wish Mojang let us scale all mobs

#

Like we can with slimes and phantoms

fading lake
#

you can do it with phantoms?

lost matrix
#

And add new Blocks, Items and GUIs

young knoll
#

Yeah phantoms have a size tag

#

Mojang never used it

fading lake
#

which ones are phantoms again? Im a 1.8 user

young knoll
#

The annoying ones that spawn if you don’t sleep

fading lake
#

ah

tardy delta
#

😂

rugged topaz
#

placed a world folder in my server dir, renamed it, now trying to teleport to it with a location and a Bukkit.getWorld("world_name") and it returns a NullPointerException, what's the cause?

timid valley
#

hello there, i want to play a sound to a player from this event. I would normally use Player.playSound(...) but I'm not sure how to get the player from this event, or if theres a better way to do so.

@EventHandler
    public void onEntityDamageByEntity(EntityDamageByEntityEvent e) {
        if (e.getEntity().getType() == EntityType.PLAYER && e.getDamager().getType() == EntityType.PLAYER) {
            e.getEntity().sendMessage("");
            // Play sound to entity?
            e.setCancelled(true);
        }
    }
lost matrix
rugged topaz
#

and what would be the method for that?

lost matrix
eternal oxide
lost matrix
rugged topaz
#

got it thanks

timid valley
#

Im pretty new to Java but to cast I would do something like Player player = (Player) e.getEntity() correct?

Also is it better to use instanceof instead of checking the type with Entity.getType()?

eternal oxide
#

in some instances the object you get may be null. in which case you will throw an error, instanceof will not

timid valley
lost matrix
# timid valley Ohh okay, gotcha. thank you :)

One sollutuion:

  @EventHandler
  public void onDamage(final EntityDamageByEntityEvent event) {
    final Entity attacker = event.getDamager();
    final Entity defender = event.getEntity();

    if (!(attacker instanceof Player attackingPlayer)) {
      return;
    }

    if (!(defender instanceof Player defendingPlayer)) {
      return;
    }

    attackingPlayer.playSound(...);
    defendingPlayer.playSound(...);
  }

Or this:

  @EventHandler
  public void onDamage(final EntityDamageByEntityEvent event) {
    final Entity attacker = event.getDamager();
    final Entity defender = event.getEntity();

    if (!(attacker instanceof Player) || !(defender instanceof Player)) {
      return;
    }
    
    Player attackingPlayer = (Player) attacker;
    Player defendingPlayer = (Player) defender;
    attackingPlayer.playSound(...);
    defendingPlayer.playSound(...);
  }
eternal oxide
#

top one is cleaner and uses java 16 methods.

lost matrix
#

This gets me thinking if there is a functional way of calling instanceof and casting...

buoyant viper
#

ah it was already answered

#

nvm

#

but yeah u just gotta cast it

lost matrix
#

*Dont forget to check the instanceof

buoyant viper
#

he pretty much does by calling getType and making sure its Player

opal juniper
#

idk what you meant lol

buoyant viper
opal juniper
#

oh

buoyant viper
#

still waiting for graalvm to have a j16 on scoop.sh

#

top 10 reasons i shouldve switched to linux when i built my pc

#

less waiting most of the time 😔

lost matrix
#
  @EventHandler
  public void onDamage(final EntityDamageByEntityEvent event) {
    IsInstance.of(Player.class, event.getEntity()).ifPresent(player -> player.playSound(...))
  }

  public static class IsInstance {
    public static <T> Optional<T> of(final Class<T> clazz, final Object obj) {
      return Optional.ofNullable(obj != null && clazz.equals(obj.getClass()) ? clazz.cast(obj) : null);
    }
  }

😄

lost matrix
buoyant viper
#

could probably find it with winget but

#

or choco

lost matrix
#

Just build a docker with native linux code ^^
The windows kernel sim of linux is quite good

buoyant viper
#

wsl?

lost matrix
#

yeah WSL 2

buoyant viper
#

ill just use linux then 😼😎

buoyant viper
lost matrix
#

true

young knoll
#

Gosh we get the fancy new inline casting with instanceof all y'all still love your lambdas :p

buoyant viper
#

ofc

#

theyre fun

young knoll
#

How many chained lambdas is too many chained lambdas

buoyant viper
#

no such thing

lost matrix
#

-> go brrr

young knoll
#

Code an entire plugin with Lambdas

buoyant viper
#

rewrite command system to use brigadier

young knoll
#

buildergadier

lost matrix
#
  @EventHandler
  public void onDamage(final EntityDamageByEntityEvent event) {
    Optional.of(event.getEntity()).stream()
        .filter(e -> e instanceof Player)
        .map(Player.class::cast)
        .forEach(player -> player.playSound(...));
  }
buoyant viper
#

is that overhead for making a collection ?

final star
#

hello guys I'm trying to integrate minecraft with Discord, but when I use "JDABuilder" it keeps giving an error. Can someone help me? (I've already tested 6 versions of JDA)

buoyant viper
#

send the code ur using to create it? (and dont include the bots token in the paste)

final star
#

are you saying that my message is too long ;-;

#

Could you send it to your private?

lost matrix
#

Do you get a compile time error or a runtime error?
Send the stack trace

final star
#

I can't send any files, but it's at runtime

lost matrix
#

But you can send text. Just send us the stack trace

final star
#

ok

mystic tartan
#

when I teleport a player who was falling, it makes the "player fell" noise, is there a way to stop the sound from playing?

lost matrix
final star
# lost matrix But you can send text. Just send us the stack trace

Caused by: java.lang.ClassNotFoundException: net.dv8tion.jda.api.JDABuilder
at java.net.URLClassLoader.findClass(Unknown Source) ~[?:1.8.0_301]
at org.bukkit.plugin.java.PluginClassLoader.findClass(PluginClassLoader.java:101) ~[spigot-1.8.8.jar:git-Spigot-db6de12-18fbb24]
at org.bukkit.plugin.java.PluginClassLoader.findClass(PluginClassLoader.java:86) ~[spigot-1.8.8.jar:git-Spigot-db6de12-18fbb24]
at java.lang.ClassLoader.loadClass(Unknown Source) ~[?:1.8.0_301]
at java.lang.ClassLoader.loadClass(Unknown Source) ~[?:1.8.0_301]
... 12 more

lost matrix
mystic tartan
final star
lost matrix
lost matrix
final star
#

no

lost matrix
# final star no

Add the maven-shade plugin to your pom:

  <build>
    <plugins>
      ...
      <plugin>
        <groupId>org.apache.maven.plugins</groupId>
        <artifactId>maven-shade-plugin</artifactId>
        <version>3.2.4</version>
        <executions>
          <execution>
            <phase>package</phase>
            <goals>
              <goal>shade</goal>
            </goals>
            <configuration>
              <createDependencyReducedPom>false</createDependencyReducedPom>
            </configuration>
          </execution>
        </executions>
      </plugin>
    </plugins>
  </build>

And make sure that dependencies which are present at runtime get the scope "provided", like this:

  <dependencies>
    ...
    <dependency>
      <groupId>org.spigotmc</groupId>
      <artifactId>spigot-api</artifactId>
      <version>1.17.1-R0.1-SNAPSHOT</version>
      <scope>provided</scope>
    </dependency>
  </dependencies>
final star
#
<repositories>
        <repository>
            <id>spigotmc-repo</id>
            <url>https://hub.spigotmc.org/nexus/content/repositories/snapshots/</url>
        </repository>
        <repository>
            <id>sonatype</id>
            <url>https://oss.sonatype.org/content/groups/public/</url>
        </repository>

        <repository>
            <id>dv8tion</id>
            <name>m2-dv8tion</name>
            <url>https://m2.dv8tion.net/releases</url>
        </repository>
    </repositories>

    <dependencies>
        <dependency>
            <groupId>org.spigotmc</groupId>
            <artifactId>spigot-api</artifactId>
            <version>1.12.2-R0.1-SNAPSHOT</version>
            <scope>provided</scope>
        </dependency>

        <dependency>
            <groupId>net.dv8tion</groupId>
            <artifactId>JDA</artifactId>
            <version>4.2.1_253</version>
        </dependency>
    </dependencies>

and it's still giving an error

lost matrix
#
  1. Latest version is 4.3.0_339
  2. Make sure that you have the maven shade plugin in your pom
  3. Actually use maven and dont build artifacts because then you are ignoring maven completely and you could just throw your entire pom in the trash
glossy venture
#

If ur using gradle use shadowJar to make a jar with dependencies

lost matrix
glossy venture
#

For some reason gradle doesnt have that option by default

#

Nvm

#

Maven

lost matrix
#

Yeah the problem is that the dependency is not shaded.

glossy venture
#

U need to find a way to include it in rhe jar

#

So that it gets loaded by bukkit

lost matrix
#

Ive sent him a setup for the maven-shade-plugin
But i think he builds artifacts anyways so the pom gets ignored completely ^^

glossy venture
#

Bruh

#

@final star if ur building artifacts use the include dependencies in project and then add JDA jar file

#

But rhen using maven is conpletely pointless

little trail
#

how can i get the uh player from an AsyncPlayerChatEvent

echo basalt
#

What's the Bukkit.isPrimaryThread() equivalent for proxies?

glossy venture
#

Also u need to regenerate the artifact afterwards

little trail
#

oh its hidden under it

#

in inherited

lost matrix
little trail
#

yes, as i said i noticed its hidden

#

by hidden not in the main methods list

young knoll
#

CTRL F is your friend

lost matrix
#

A plugin that lets you define a multiplier for every type of damage. Name it DamageControl

wary harness
#

any one can suggest how could I get rid of decimals in double
I got option in config to disable decimals for my economy plugin
but qustion is there a way to remove all decimals which shows sometimes
of double without DecimalFormat
because I currently only found suggestions using DecimalFormat that will turn it to string and then I need to get it back to double and save it to data base

young knoll
#

String.format can display it without decimals

#

Or you can just cast to int

wary harness
lost matrix
#

*long

young knoll
#

Cast to long

lost matrix
#

^^

vast shale
#

Can someone help me figure out why this isn't working?

public static Map<Integer, Integer> trackExp = new HashMap<>();
public static Map<UUID, Map<Integer, Integer>> bdExps = new HashMap<>();

public void addPlayerExp(UUID playerUUID, int track, int exp) {
    if (bdExps.containsKey(playerUUID)) {
        int totalExp = exp;
        totalExp += bdExps.get(playerUUID).get(track);
        bdExps.get(playerUUID).put(track, totalExp);
        }
    else {
        Map<Integer, Integer> tempTrackExp = new HashMap<>();
        trackExp.put(track, exp);
        bdExps.put(playerUUID, trackExp);
    }
}

public int getPlayerExp(UUID playerUUID, int track) {
    if (bdExps.containsKey(playerUUID))
        return bdExps.get(playerUUID).get(track);
    return 0;
}

Invoking "getPlayerExp" results in

Cannot invoke "java.lang.Integer.intValue()" because the return value of "java.util.Map.get(Object)" is null
lost matrix
young knoll
#

MapMaps

lost matrix
young knoll
#

Or

#

Guava tables

vast shale
#

Is nesting hashmaps ineffiicient?

lost matrix
#

Eh. If its exactly one MapMap and you have exactly defined relations then sure... but as a general rule: Make new classes

lost matrix
vast shale
#

Im assuming thats why you suggest making new classes

jade perch
#

Is an antipattern to make maps in maps in maps

lost matrix
#

New classes just improve the modularity, maintainability and expandability of your code

jade perch
#

And it looks log dog sheet to

ivory sleet
young knoll
#

Yeah I recently used a table for cooldowns, works well

vast shale
#

Hmm okay. How would I convert my nested maps into a class to hold the values?

lost matrix
jade perch
#

It was statement

lost matrix
#
  private final Map<String, Map<Integer, Integer>> trackMap = new HashMap<>();

To:

  private final Map<String, TrackedMatch> trackedMatchMap = new HashMap<>();
  public class TrackedMatch {

    private final Map<Integer, Integer> tracks = new HashMap<>();

    public void addTrack(final int key, final int value) {
      this.tracks.put(key, value);
    }

    public void removeTrack(final int key) {
      this.tracks.remove(key);
    }

    // And so on

  }
#

And make sure you enforce strong encapsulation. Meaning that you never make your data structures public and you never write getters or setters for them.

jade perch
#

My favorite class is abstractmap.simpleimmutableentry when I'm super lazy

vast shale
#

Great, thank you, however, I'm still confused on how I'm supposed to get the value from a nested hashmap

lost matrix
#

Dont use nested maps

vast shale
#

But how can I save the values to a specific UUID now using your way?

lost matrix
#

Example for the class i wrote:

  private final Map<String, TrackedMatch> trackedMatchMap = new HashMap<>();

  public int getTrackedValue(String holder, int track) {
    TrackedMatch trackedMatch = trackedMatchMap.get(holder);
    if (trackedMatch == null) {
      return 0;
    }
    return trackedMatch.getTrackValue(track);
  }
vast shale
#

Ahh okay, thank you!

vague oracle
#

getOrDefault 😉

lost matrix
vague oracle
#

🙂 Just assumed you didnt want extra data stored as your werent adding it xD

lost matrix
#

idk

unique eagle
#

Hello ! i search for CraftFallingBlock the noClip in 1.17.1 😢

#

in 1.16.5 it's this : ((CraftFallingBlock) liftedBlock).getHandle().noClip = true;

#

and i search for the 1.17.1

lost matrix
young knoll
#

Probably not mapped anymore

#

Also what the heck is no clip

lost matrix
young knoll
#

Mappings are for dweebs

unique eagle
lost matrix
unique eagle
#

disappear

dusk flicker
#

?jd

lost matrix
unique eagle
#

how ?

#

because in 1.16.5 i use craftfallingblock and noClip

lost matrix
#
  @EventHandler
  public void onBlockLand(final EntityChangeBlockEvent event) {
    final Entity entity = event.getEntity();
    if (entity instanceof FallingBlock fallingBlock && this.shouldBeIgnored(fallingBlock)) {
      event.setCancelled(true);
    }
  }

  private boolean shouldBeIgnored(final FallingBlock fallingBlock) {
    return true; // Make a check here so not all falling blocks get ignored
  }
lost matrix
unique eagle
#

ho

young knoll
#

They probably get killed past y-64

#

I still wonder why a no clip option exists in the first place

unique eagle
#

thank you !

vast shale
#

Im having issues with opening a custom inventory. I printed out the player's current open inventory and it appears to be changing, but no GUI appears..

Before openInventory(): org.bukkit.craftbukkit.v1_17_R1.inventory.CraftInventoryView@3a2ab454
After : org.bukkit.craftbukkit.v1_17_R1.inventory.CraftContainer$1@686a2933
young knoll
#

What are you opening

carmine nacelle
#

hey so I have a list of player UUIDs, im trying to create a list of players FROM those uuids,

return new ArrayList<>().addAll()

Trying to convert all UUIDs to players and add them to the new list in one line with lambda. any ideas..?

lost matrix
#

one moment

carmine nacelle
#

dope

lost matrix
#

One example:

#
  public List<Player> toPlayerList(final Collection<UUID> uuidCollection) {
    return uuidCollection.stream().map(Bukkit::getPlayer).filter(Objects::nonNull).toList();
  }
lost matrix
# carmine nacelle dope

Its basically the same as:

  public List<Player> toPlayerList(final Collection<UUID> uuidCollection) {
    final List<Player> playerList = new ArrayList<>();
    for (final UUID uid : uuidCollection) {
      final Player player = Bukkit.getPlayer(uid);
      if (player != null) {
        playerList.add(player);
      }
    }
    return playerList;
  }
carmine nacelle
#

alright sweet thx for that, im trying to do something like

    // Gets all currently playing players
    public List<Player> getInGamePlayers() {
        return new ArrayList<>().addAll(uuid -> inGamePlayerUUIDs.forEach(Bukkit.getPlayer(uuid));
    }
#

with the little lambda arrow bois, they look high tech

#

am I close..?

#
    // Gets all currently playing players
    public List<Player> getInGamePlayers() {
        return inGamePlayerUUIDs.stream().map(Bukkit::getPlayer).filter(Objects::nonNull).collect(Collectors.toList());
    }

this should do

tame elbow
#

if statements not working

uneven dock
#

Hey guys,

I'm not sure if this is even possible but I plan to develop it if it hasn't already been done but...

Is there a way to redirect players who join a Java server on Bedrock or Pocket Edition to another server that is bedrock/pocket? If so, is there a plugin out there that already does it or am I gonna have to make one?

#

nevermind I found one

twilit wharf
#

does anyone know how to create a lobby system like hypixel? I dont want to know all the code, just how to approach it?

uneven dock
ivory sleet
twilit wharf
#

open a menu, select a block, and get moved to the server

ivory sleet
#

Or are you going to code it?

twilit wharf
#

I want to code it

ivory sleet
#

well first of all you want to establish some sort of message broker

twilit wharf
#

do I need bungeecord api for that?

ivory sleet
#

Which in this case redis or rabbitmq could be alternatives

uneven dock
#

I would just use a pre-built plugin like SSX personally

ivory sleet
#

^

#

It’s a lot of work to make a proper lobby system

uneven dock
#

You get all the customization you want in config

#

and no Java coding

twilit wharf
#

alright, thanks

vast shale
#

Im having issues with opening a custom inventory. I printed out the player's current open inventory and it appears to be changing, but no GUI appears..

Before openInventory(): org.bukkit.craftbukkit.v1_17_R1.inventory.CraftInventoryView@3a2ab454
After : org.bukkit.craftbukkit.v1_17_R1.inventory.CraftContainer$1@686a2933

Heres my methods. The message "Opening Win Inventory!" does appear.

    public void WinBattleGUI() {
        WinInv = Bukkit.createInventory(null, 54, ChatColor.GOLD + "" + "Exp");
        initWinInvItems();
    }
    
    public void initWinInvItems() {
        WinInv.setItem(0, createGuiItem(Material.PURPLE_CONCRETE, ChatColor.DARK_PURPLE + "" + "Test"));
    }
    
    public void openWinInventory(final HumanEntity e) {
        WinBattleGUI();
        e.sendMessage("Opening Win Inventory!");
        Bukkit.getServer().broadcastMessage("1: " + e.getOpenInventory().toString());
        e.openInventory(WinInv);
        Bukkit.getServer().broadcastMessage("2: " + e.getOpenInventory().toString());
    }
twilit wharf
#

and you can choose what lobby you want by opening the lobby selector

uneven dock
lusty bramble
#

If someone could help me out in #help-server I'd be very grateful

ivory sleet
#

Be patient

#

If someone wants to assist you they’ll surely look in the right channel (:

quaint mantle
#

I've never coded anything before but I'm trying to make custom ores in 1.17. I want to replace all deepslate ores with a new custom ore; this is because custom blocks aren't effective as ores in my opinion. I believe I'd be better off replacing deepslate ores with new blocks if possible.

  1. I need to rename all deepslate ore blocks, as well retexture all deepslate ore blocks.

  2. I need to make a custom ore item, which would then need to be replaced with what the normal deepslate ore block drops.

  3. I then need to remove the ore blocks from being able to be smelted, or if they're smelted, make it smelt into the custom item.

#

Is this something that is possible to do? ^

twilit wharf
quaint mantle
#

Yes, of course. haha

#

Is this simple or should I pay someone to do this for me? I've never coded anything a day in my life but I'm up for the challenge if it's not advanced.

twilit wharf
quaint mantle
#

ah okay, no worries

twilit wharf
#

I am getting this error in my command and I dont know what is wrong, couldnt find any info on what file or what part was wrong

#
org.bukkit.command.CommandException: Cannot execute command 'staff' in plugin StaffPlugin vA.01 - plugin is disabled.
        at org.bukkit.command.PluginCommand.execute(PluginCommand.java:37) ~[patched_1.17.1.jar:git-Paper-351]
        at org.bukkit.command.SimpleCommandMap.dispatch(SimpleCommandMap.java:159) ~[patched_1.17.1.jar:git-Paper-351]
        at org.bukkit.craftbukkit.v1_17_R1.CraftServer.dispatchCommand(CraftServer.java:869) ~[patched_1.17.1.jar:git-Paper-351]
        at net.minecraft.server.network.ServerGamePacketListenerImpl.handleCommand(ServerGamePacketListenerImpl.java:2262) ~[app:?]
        at net.minecraft.server.network.ServerGamePacketListenerImpl.handleChat(ServerGamePacketListenerImpl.java:2073) ~[app:?]
        at net.minecraft.server.network.ServerGamePacketListenerImpl.handleChat(ServerGamePacketListenerImpl.java:2054) ~[app:?]
        at net.minecraft.network.protocol.game.ServerboundChatPacket.handle(ServerboundChatPacket.java:46) ~[app:?]
        at net.minecraft.network.protocol.game.ServerboundChatPacket.handle(ServerboundChatPacket.java:6) ~[app:?]
        at net.minecraft.network.protocol.PacketUtils.lambda$ensureRunningOnSameThread$1(PacketUtils.java:56) ~[app:?]
        at net.minecraft.server.TickTask.run(TickTask.java:18) ~[patched_1.17.1.jar:git-Paper-351]
        at net.minecraft.util.thread.BlockableEventLoop.doRunTask(BlockableEventLoop.java:149) ~[app:?]
        at net.minecraft.util.thread.ReentrantBlockableEventLoop.doRunTask(ReentrantBlockableEventLoop.java:23) ~[app:?]        at net.minecraft.server.MinecraftServer.doRunTask(MinecraftServer.java:1423) ~[patched_1.17.1.jar:git-Paper-351]        at net.minecraft.server.MinecraftServer.shouldRun(MinecraftServer.java:192) ~[patched_1.17.1.jar:git-Paper-351]
        at net.minecraft.util.thread.BlockableEventLoop.pollTask(BlockableEventLoop.java:122) ~[app:?]```
#

        at net.minecraft.server.MinecraftServer.pollTaskInternal(MinecraftServer.java:1401) ~[patched_1.17.1.jar:git-Paper-351]
        at net.minecraft.server.MinecraftServer.pollTask(MinecraftServer.java:1394) ~[patched_1.17.1.jar:git-Paper-351]
        at net.minecraft.util.thread.BlockableEventLoop.managedBlock(BlockableEventLoop.java:132) ~[app:?]
        at net.minecraft.server.MinecraftServer.waitUntilNextTick(MinecraftServer.java:1372) ~[patched_1.17.1.jar:git-Paper-351]
        at net.minecraft.server.MinecraftServer.runServer(MinecraftServer.java:1283) ~[patched_1.17.1.jar:git-Paper-351]        at net.minecraft.server.MinecraftServer.lambda$spin$0(MinecraftServer.java:319) ~[patched_1.17.1.jar:git-Paper-351]
        at java.lang.Thread.run(Thread.java:831) ~[?:?]
quaint mantle
twilit wharf
#

yeah ik

quaint mantle
#

First: We see the PluginCommand

twilit wharf
#

yeah

quaint mantle
#

Which is about your command.

twilit wharf
#

yeah

#

obviously

#

I just cant find anything wrong there

#

😦

quaint mantle
#

Did it said Caused by in the stacktrace? Or that is all you got?

twilit wharf
#

thats all I got

quaint mantle
#

how many commands do u have

paper viper
#

you are doing something fucky then

#

show your code

twilit wharf
#

4

#

commands

paper viper
#

only show relavant code

quaint mantle
#

show wat code u think that cause the error

#

?pastes

#

?paste

undone axleBOT
quaint mantle
#

if u have too much

twilit wharf
paper viper
#

how do you register it

#

does your command class implement CommandExecutor

twilit wharf
#

yes

paper viper
#

How do you register it then

twilit wharf
#

getCommand("staff").setExecutor(new StaffCommand());

#

like my 3 other commands that work fine

paper viper
#

what is ItemManager

twilit wharf
#

this is what StaffCommand uses from it: ```java
public static ItemStack vanish;

public static ItemStack[] createStaffItems() {

    vanish = new ItemStack(Material.INK_SAC);
    ItemMeta vanishMeta = vanish.getItemMeta();
    vanishMeta.setDisplayName(ChatColor.GOLD + "Vanish");
    ArrayList<String> lore = new ArrayList<>();
    lore.add(ChatColor.GRAY + "Toggles your total vanish");
    vanishMeta.setLore(lore);
    vanish.setItemMeta(vanishMeta);

    ItemStack[] inv = new ItemStack[]{
            AdminPanelCommand.createItem(), vanish
    };
    System.out.println("Created Staff Items");
    return inv;
}
paper viper
#

Does the Created Staff Items print into console

#

when you execute the command

rough salmon
#

A

twilit wharf
#

nope

paper viper
#

This doesn't make sense

#

org.bukkit.command.CommandException: Cannot execute command 'staff' in plugin StaffPlugin vA.01 - plugin is disabled.

#

it says plugin is disabled

#

but your other 3 commands work?

twilit wharf
#

wait, now they dont

#

they were a minute ago

paper viper
#

... that is useful information

#

it means when you ran the command, it made an exception so bad it disabled the plugin or something

twilit wharf
#

wait

#

so

#

I didnt notice this the first time

#

but upon initialization of the plugin

#

it runs into a error

#

saying it is already initialized

paper viper
#

Lmao then thats why

#

You can't initialize multiple instances of your plugin

#

you can only keep one instance and pass it around

twilit wharf
#

yeah...

#

I know exactly where that is leading to

#

thanks

#

yep

#

thats what the issue was

quasi patrol
#

I'm trying to wait in a for loop, but it is waiting like the delay in the for loop and than it runs everything instead of waiting the time, do the thing, than waiting again and all that.

young knoll
#

Use a repeating task instead of a for loop

quaint mantle
#

?scheduling

undone axleBOT
opaque panther
#

guys if I have a lot of functions which needs to check for event handler, can I make multiple event handlers for same event. do multiple event listeners of same event execute at the same time or in the order they are registered?

young knoll
#

Order they are registered I imagine

#

Generally it’s better to have 1 handler that calls multiple other functions

opaque panther
#

ohh

#

i didnt think of that

#

thanks

opaque panther
#

hey whats the best way to change a small part of a gui menu. I want the item in the menu to change to a grass block when they click on it and change them to creative mode, and vice versa. Should I make a whole copy of that and display back? Or is some efficient way possible?

young knoll
#

Just change that slot?

elfin talon
#

Hey I have a 5 min countdown. How can I let the boss bar run down?

young knoll
#

Use a repeating task to update the boss bar every second or whatever

opaque panther
#

i have a gamemode change event . How do i check if a specific inventory is open for that player

eternal night
#

HumanEntity#getOpenInventory

opaque panther
eternal night
#

Read the javadocs

opaque panther
#

ok i read it, should have read it before asking

#

im dumb

quaint mantle
#

hey how can i check if a block that is not normally powered by redstone, is powered by redstone

#

specifically, a transparent block

wild reef
#

you could check the blocks arround the one you want to check. If one of them is redstone or something which can power your block, the condition is true

#

I think you are also able to check if the blocks arround have isBlockPowered on true (just read about that rn)

quaint mantle
#

should i use the BlockRedstoneUpdateEvent then

#

its osmething like that i can check for the actual event

wild reef
#

yea that should work too

quaint mantle
#

cool deal

opaque panther
#

hey how do I store player details for a tpa command which can be accessed by another class without using static hashmap? I made it using that way but I saw people saying static members are bad

ivory sleet
#

Not inherently but yeah

#

It’s probably better to just pass an instance which encapsulates a map instead

#

?di

undone axleBOT
ivory sleet
#

Believe that does go over it

opaque panther
#

ok thanks

acoustic widget
#

Hello , any tips for access to config file outside the main class ?

quaint mantle
#

?di

undone axleBOT
quaint mantle
#

?learnjava

undone axleBOT
acoustic widget
quaint mantle
ivory sleet
#

😩

acoustic widget
#

I read that is not a good way to use singleton patern, and dependency injection better right ??

ivory sleet
#

Most scenarios yes

quaint mantle
#

why it is not a good way

ivory sleet
#

Anyways you shouldn’t have to pass your plugin instance to any other class

#

If it isn’t something which for instance neeeds the scheduler or smtng

ivory sleet
#

Or wiki page

#

Dependency injection

quaint mantle
#

i always use constructor (di, but i like constructor word more)

quaint mantle
acoustic widget
#

@quaint mantle If I understand dependency injection inject just what you need in the method of your class.

ivory sleet
ivory sleet
quaint mantle
#

so what are the examples in that article

acoustic widget
ivory sleet
#

Idk that article isn’t entirely written by me and iirc it doesn’t go over the best practices

#

But generally

quaint mantle
#

makes this

#

and then this

ivory sleet
#

Using singletons will make your classes have to tightly rely on specific instances

#

It can get hard to unit test

#

And you will experience a loss of reusability in long terms

#

So static singletons actually complexifies your code architecture as opposed to just passing dependencies

quaint mantle
#

so will it do anything bad to optimization ??

ivory sleet
#

Performance is negligible

summer scroll
#

I need help with cancelling player to taking out their helmet, so I equip helmet using packets to player, and I want prevent player to taking out the helmet, how can I do that?

ivory sleet
#

In terms of runtime

#

Though I’d argue for that passing dependencies is more optimized for the developer themselves

quaint mantle
#

so what should i do now

#

make a private MyPlugin INSTANCE;

ivory sleet
#

Well

quaint mantle
#

and make a public getter for it ?

#

i dont get it

ivory sleet
#

I can write an example

quaint mantle
#

is this what you mean ?

#

doing something like this

#
private static MainClass instance;

@Override
public void onEnable() { instance=this; }

public static MainClass getInstance() { return instance; }
#
// In class "Hello"
private final MainClass main;
public Hello(MainClass main) { this.main=main; }

// On enable in main class
command.setExecutor(new Hello(this)); 
#

Or use record classes

#

public record Hello(MainClass main) {}

sullen marlin
#

uh

#

I don't think that's what records are for....

quaint mantle
#

💀

#

But idl records ya

ivory sleet
#
class JavaPluginImpl extends JavaPlugin {
  @Override public void onEnable() {
    PluginScheduler scheduler = new PluginScheduler(this);
    this.getServer().getPluginManager().registerEvents(new ConnectionListener(scheduler),this);
  }
}
class PluginScheduler {
  private final Plugin plugin;
 
  public PluginScheduler(Plugin plugin) {
    this.plugin = plugin;
  }

  public BukkitTask runTask(Consumer<BukkitRunnable> action) {
    new BukkitRunnable() {
      public void run() {
        this.action.accept(this);
       }
    }.runTask(this.plugin);
  }
}
class ConnectionListener implement Listener {
  private final PluginScheduler scheduler;
  public ConnectionListener(PluginScheduler scheduler) {
    this.scheduler = scheduler;
  }
  @EventHandler public void onLogin(AsyncPlayerPreLoginEvent event) {
    this.scheduler.runTask(task -> {
      //TODO
    });
  }
}```
Typed it on phone but yeah
quaint mantle
#

ah got it

#

thanks

ivory sleet
#

In this way you avoid passing your highest order component (class extending javaplugin) to one of the lowest ordered components in the system

acoustic widget
#

Assuming what we are talking about dependency injection, Am I fine for accessing config in a command ?

public final class TestMaven extends JavaPlugin {
    @Override
    public void onEnable() {
        getCommand("test").setExecutor(new Test(getConfig()));
    }
}
public class Test implements CommandExecutor {
    private final FileConfiguration config;

    public Test(FileConfiguration config) {
        this.config = config;
    }
}

ivory sleet
#

Yeah

#

That’d be fine

acoustic widget
#

Thank you guys for help

opaque panther
#

someone help me

#

?paste

undone axleBOT
opaque panther
#

someone help me

#

my tpa command is not working when I removed the static from hashmap

#

I dont understand it

#

help someon pleaasa af ap

#

\

#

/

#

how do I paste it

drowsy helm
#

oops didnt see the pastbin

opaque panther
#

in that code when I used static before hashmap it worked

#

But when I removed, it didnt

#

why is that so

#

what I dont understand is

drowsy helm
#

are you creating a new instance of TPACommands for each player? I don't see a reason why it wouldn't work

opaque panther
#

wait ill send main

#

?paste

undone axleBOT
drowsy helm
#

also instead of using names i woudl recommend using UUIDs

opaque panther
#

why?

drowsy helm
#

well UUIDs are unique to each player

opaque panther
#

oh

#

but names are too?

drowsy helm
#

yeah they can be, but its just better practice. Not that it will happen but names cna overlap

opaque panther
#

ok

#

anyway can you check the main class

#

if there are not errors

drowsy helm
#

hmm your code looks perfectly fine to me

opaque panther
#

I dont get it why isnt it working

#

this is discouraging

drowsy helm
#

if its working static but not non static that implies that you are accessing different instances of it

opaque panther
#

in this video

#

he makes flying plugin

#

in 7:01

#

he makes non static arraylist to store players and it works

#

but why doesnt the map work when I do

drowsy helm
#

so static is the only thing youve changed right

#

no logic in code or anything?

opaque panther
#

nothing

drowsy helm
#

have you tried to debug the contents of the map?

opaque panther
#

let me check it

drowsy helm
#

itll help show which bit of the code is failing

opaque panther
#

ok ok

random isle
#

did someone know how i get a ItemStack from a id likr this 1:3 in the version 1.17.1

drowsy helm
#

as in a number id?

random isle
#

easyly i will get a itemstack from a number id. In the past it was Material.getMateriel(int) but doesnt works

drowsy helm
#

unless you make your own lib to map number ids to a material, no

#

all traces of number ids were removed a while ago

vagrant stratus
random isle
#

but why it was a realy god and easy system

drowsy helm
#

not really

#

you had to remember a bunch of arbitrary numbers

#

imagine if everyone on earth had a number instead of a name, its just harder lol

random isle
#

yeah ok but why not number and the new system

drowsy helm
#

minecraft stopped supporting numbers not spigot

vagrant stratus
#

number's completely useless with the new system lol

drowsy helm
#

if spigot were to continue supporting numbered ids, they would have to make their own id for new items

#

adding even more complication to the process

random isle
#

yeah but i like the numbers more then the new system

vagrant stratus
#

oh well 🤷‍♂️

#

your only option is re-create the old method

drowsy helm
#

so did I for a bit, then i realised how useless it was

#

far easier to reference an item as its name than a random number

#

after all, you can implement your own method for it, will just take a bit

vagrant stratus
#

^ Material.GOLD_ORE is much easier to remember than whatever its id is

random isle
#

yeah it will but i have a shild with a id and like to get the item. Not everyone who create a shild like to write the word the most writing the number id

drowsy helm
#

I think the fact that we don't need cheatsheets to remember material ids speaks volumes about it's effectiveness

random isle
#

so i will my own class for that

drowsy helm
#

yeah you're going to have to

#

then create ids for the new items aswell

#

and sub-ids

random isle
#

yay it "makes" me smile

vagrant stratus
#

and maybe even sub-sub-ids

vagrant stratus
random isle
vagrant stratus
#

still, good luck 🤷‍♂️
You've got quite a few new items to map to ids.... that's not even including 1.18+

fallow merlin
#

How do I make terrain generation with noise more variant?

#

most of it is pretty flat

#

with small hills scattered about

vagrant stratus
#

I can't wait to see the mess that is Pierre's implementation of the old system 👀

random isle
#

yeah i too vut when it works i am happy

drowsy helm
#

just use an enum

vagrant stratus
#

all because they like dealing with IDs more than the current Material.RED_BED situation

#

best part is they'll have to update it every time an update comes out

drowsy helm
#

pog

random isle
#

no for first its still for the 1.17 XD

vagrant stratus
#

You've still got a bunch of new things to make IDs for

#

then once 1.18 hits, you've got even more ids to create

#

1.19? Probably more IDs

random isle
#

yeah its ok i am a developer with many freetimeXD

#

for all minecraft 1.17 item you will need 1200 double chests

vagrant stratus
#

and I don't know anyone else who'd be willing to learn all the IDs needed just to use your resource tbh

random isle
#

yeah but i doo it what ever you will talk to me XD

drowsy helm
vagrant stratus
#

yes

random isle
#

in the 1.17 its round about 64.800 Items it makes me smile XD

vagrant stratus
#

god help the performance

#

and i don't see why it would be that high honestly

drowsy helm
#

64k?

#

that doesn't sound right

vagrant stratus
#

^

random isle
#

all obtainable and non-obtainable

vagrant stratus
#

that's....still way off

drowsy helm
#

i mean you could always just write a tool that generates ids automatically but it wouldn't retain the legacy ids

vagrant stratus
#

some items you can't even get in any way, shape or form anymore lol

#

so not only are you going to be writing a bunch of IDs, you need to test them all as well to make sure they're all correct lol

#

Gonna pray for the resource performance too

opal juniper
#

its just gonna be one big hashmap lol

random isle
#

easyly i take the creative inventory and a few other items like commandblock XD

random isle
#

you will see

opaque panther
vagrant stratus
#

Not that easy lol, you'd still need to get all the old ids

#

and make a bunch of new ones that make sense

random isle
#

yeah but yet i beginn, when i write here anymore then i end this never

vagrant stratus
#

can't wait to see that mess though 👌

drowsy helm
#

have fun

opal juniper
#

there is no way to do that nicely imo

drowsy helm
#

enum with mat, id and sub id is best way i can think of

opal juniper
#

oh wait we are in help-dev??? i assumed this was general cause optic was here

vagrant stratus
drowsy helm
#

theres no other good way of doing it without a performance hit lol

#

immutable hashmap?

#

sql database???

vagrant stratus
#

....using the new material system

drowsy helm
#

i think thats out of the picture rn lmao

opal juniper
#

new???

#

thats not new

vagrant stratus
#

so I'm considering the current one new lol

fallow merlin
vagrant stratus
hushed garnet
#

Trying to create a hologram after a player types in some text in chat, but getting this error:

        at com.gmail.filoghost.holographicdisplays.util.Validator.isTrue(Validator.java:27) ~[HolographicDisplays-2.4.9.jar:?]
        at com.gmail.filoghost.holographicdisplays.object.DefaultBackendAPI.createHologram(DefaultBackendAPI.java:40) ~[HolographicDisplays-2.4.9.jar:?]
        at com.gmail.filoghost.holographicdisplays.api.HologramsAPI.createHologram(HologramsAPI.java:46) ~[HolographicDisplays-2.4.9.jar:?]```

When hooking into `AsyncPlayerChatEvent` ... is there another approach I could take?
#

Why can't you make a hologram async?!

opal juniper
#

Bukkit.getScheduler#runTask

#

its an entity

#

you cant async entity add

hushed garnet
#

so fire off a scheduled task inside the async event?

opal juniper
hushed garnet
#

interesting, ok will go try this. Thanks @opal juniper

drowsy helm
#

yeah you need to run a synchronous event in the async

hushed garnet
#

thought I had tried that already... sure enough just worked!

valid solstice
#
Block block = e.getBlock();
        Material block_mat = block.getType();

switch(block_mat){
                    case DIAMOND_ORE:
                        player.sendMessage("DIAMOND!!!");
                        break;
                }
``` why is this not sending me the diamond message?
#

e is from a block break event

tardy delta
#

did you register the event?

valid solstice
#

yup

tardy delta
#

isnt it Material.DIAMOND_ORE?

valid solstice
#

it sends me a message when the event gets fired

tardy delta
#

u

valid solstice
#

atleast thats what i know...

opal juniper
#

You dont

#

Show more code

#

the entire event listener

valid solstice
#

alright 1 sec

quaint mantle
drowsy helm
valid solstice
#
@EventHandler
    public static void onBreak(BlockBreakEvent e){


        Block block = e.getBlock();
        Material block_mat = block.getType();

        Player player = e.getPlayer();

        player.sendMessage("runned");

        Random rand_int = new Random();

        if(Prosperity.getPlayersAffected().contains(player)) {
            player.sendMessage("its");
            if (true) { //true will be changed to rand_int
                switch(block_mat){
                    case DIAMOND_ORE:
                        player.sendMessage("DIAMOND!!!");
                        break;
                }
            }
        }
    }```
drowsy helm
#

its static

#

don't make it static

valid solstice
#

the method?

drowsy helm
#

yes

valid solstice
#

why is that? its getting runned even its static...

quaint mantle
drowsy helm
#

its static abuse

#

is "its" being printed?

valid solstice
#

true ill remove it

valid solstice
quaint mantle
eternal oxide
#

Do unsafeEnchanments break villager trades?

drowsy helm
#

try and print out block_mat

#

see what it prints

drowsy helm
eternal oxide
#

having, yes

quaint mantle
drowsy helm
#

I don't think it does

tacit drift
#

Can i force the player to refresh chunks (F3+A) when it joins the server?

chrome beacon
#

Why?

tacit drift
#

because

#

¯_(ツ)_/¯

tepid thicket
#

Hi, which event is called, when a falling sand block collides with a torch, and dies?

tepid thicket
#

I would like to cancel the action and let the sand block sit on top instead.

quaint mantle
#

why dont u check it too?

tepid thicket
#

Which event to use?

lost matrix
quaint mantle
#

oh right

#

yeah that is right

lost matrix
tepid thicket
#

The EntityDeathEvent doesn't seem to fire for a falling sand.

#

Any other ideas?

lost matrix
#

Some things i would test:
EntityCombustByBlockEvent
EntityDropItemEvent
EntityInteractEvent

sullen marlin
#

EntityChangeBlockEvent

#

Pretty sure its that with target block as air

#

If not then probably no event, open a feature request

tepid thicket
#

I read, that the EntityChangeBlockEvent would only fire, when the sand block is placed, but not when it dies by a torch.

#

But I can check it out of course.

lost matrix
#

I see. But the EntityDropItemEvent looks viable too as it actually drops itself.

tepid thicket
#

Though the EntityDropItemEvent doesn't provide a spawn cause, so it might be hard to track right?

lost matrix
#

But you would have the Entity that dropped it.

tepid thicket
#

Ohh right. I thought of the ItemSpawnEvent. Let me check whether yours fires for sand.

karmic mural
#

I was given some good help yesterday but I can't seem to implement it... I created a thread, (Generating items from config) could I request some assistance there, please?

eternal oxide
#

I looked, I don;t see what you are stuck on. You have been given pretty much all you need

karmic mural
#

Indeed... I am aware of that, I've just been trying to implement the code and it seems I am not capable of that... I've been spending some time watching some java tutorials and a lot of googling trying to implement it properly.

tardy delta
tepid thicket
#

Okay, so indeed the EntityChangeBlockEvent fires for the first air block. Then you could scan down in a hacky way.

#

But the EntityDropItemEvent also fires and has the falling block as dropper/entity, which makes it the clear winner.

#

The other events don't fire and can be ignored for the most past.

#

Thank you guys. 🙂

stone sinew
#

Why are NBTTagCompound.entrySet() values LinkedTreeMaps instead of normal objects like String, List, Double etc...?
Especially since you can't set a linkedtreemap in the compound.

tags.entrySet().forEach(entry -> {
    String key = entry.getKey();
    Object value = entry.getValue();
    
    String found = "None";
    if(value instanceof String) {
        compound.setString(key, (String) value); 
        found = "String";}
    if(value instanceof int[]) {
        compound.setIntArray(key, (int[]) value); 
        found = "IntArray";}
    if(value instanceof Integer) {
        compound.setInt(key, (Integer) value); 
        found = "Integer";}
    /*7 other if statements for other instances*/
    
    ConsoleOutput.debug("Tag: "+key+" Value: "+value+" Value Class: "+value.getClass().getCanonicalName()+" Instance: "+found);
});
[DEBUG] [**String of values list**]
[DEBUG] Tag: Unbreakable Value: {x=1.0} Value Class: com.google.gson.internal.LinkedTreeMap Instance: None
[DEBUG] Tag: HideFlags Value: {c=6.0} Value Class: com.google.gson.internal.LinkedTreeMap Instance: None
[DEBUG] Tag: display Value: **display json** Value Class: com.google.gson.internal.LinkedTreeMap Instance: None
[DEBUG] Tag: Enchantments Value: [**enchants**] Value Class: java.util.ArrayList Instance: None
[DEBUG] Tag: Damage Value: {c=1560.0} Value Class: com.google.gson.internal.LinkedTreeMap Instance: None
karmic mural
#

I was given some code to help me with creating items automatically from my config, but I am little bit confused for the final part, what do I put there?

public class CustomItems {

    private static final Map<String, ItemStack> namedItems = new HashMap<>();

    public static ItemStack getNamedItem(final String name) {
        return namedItems.get(name);
    }

    public static void loadFromConfig(final FileConfiguration configuration) {
        final ConfigurationSection itemSuperSection = configuration.getConfigurationSection("Path.To.Super.Section");
        for (final String key : itemSuperSection.getKeys(false)) {
            final ConfigurationSection itemSingleSection = itemSuperSection.getConfigurationSection(key);
            loadSingleItemFromSection(key, itemSingleSection);
        }
    }

    private static void loadSingleItemFromSection(final String key, final ConfigurationSection section) {
        // Load the ItemStack from a section and put it in the Map
    }

}```
Talking about the last bit "loadSingleItemFromSection", wording confuses me a bit
#

I understand the "pathtosupersection" being just the path to the part of my config I want to get stuff from, but that "load the ItemStack from a section and put it in the Map" has me confused

eternal oxide
#

section.getItemStack

karmic mural
#

Right, but for the path it requires there, do I just put the string-value of section or something static to point it to the part of the config I want it to take from?

eternal oxide
#

the section is already extracted from the path

maiden mountain
#

Is it possible to have custom GUI on the player screen with spigot? like Hypixel has

karmic mural
lyric oar
#

Hello, i would like to edit the name of a player above the head. Is it possible to do that with spigot?

eternal oxide
#

you are getting items not adding them

karmic mural
#

section.getItemStack insists on having a String path

#

"Load the ItemStack from a section and put it in the Map" has me confused a bit then

eternal oxide
#

yes, you use teh name of the item

maiden mountain
#

How do you create 2D GUIs like this?

karmic mural
maiden mountain
#

Is it possible with Spigot?

eternal night
#

that is a scoreboard

karmic mural
#

Yes, it's a scoreboard

fallow merlin
#

but spigot makes it easier

#

imo

maiden mountain
#

aaah oke

#

so am i able to change the position aswell?

#

Like on top of the screen

eternal night
#

no

maiden mountain
#

So how would you create something like this?

stone sinew
maiden mountain
#

Alright, thanks for the help

karmic mural
#

Man I must be thicc as bread... I want to generate items automatically from a config, what's the most efficient way to do that?

#

If there's some article I can read, video I can watch or whatever that'd be great

#

I've been trying to find resources myself, figuring out from code I already have etc etc but I just can't seem to crack it.

acoustic widget
#

I'm looking tutorial with onBowShoot event, but I can't find this event in the documentation. (he's teleporting where the arrow hit) Maybe it doesn't exist anymore and replaced by ProjectileHitEvent ? Or am I looking at the wrong place ?

lavish hemlock
#

Man I must be thicc as bread...
I have never heard this saying once in my entire life.

karmic mural
#

Yeah well there you have me. I've been stuck at this for days, even with someone having written code for me I just can't understand how to use it? Like am I just that thick?

opal sluice
#

Hello, does someone knows how to create a new MobEffect (NMS)

#

Would like to give invisibility to an EntityPlayer

eternal night
#

just get its bukkit entity

#

and use the spigot methods

#

EntityPlayer#getBukkitEntity()

opal sluice
#

I can't do that since it's not a logged player

#

it will try to send the packet to the player to add the potion effect

eternal night
#

but you have an instance

opal sluice
#

sure

eternal night
#

oh

#

technically that should still work

opal sluice
#

?paste

undone axleBOT
opal sluice
#

Saying that the connection is null

#
@SuppressWarnings("deprecation")
MobEffect invisibilityEffect = new MobEffect(MobEffectList.fromId(PotionEffectType.INVISIBILITY.getId()), Integer.MAX_VALUE, 2);
pc.sendPacket(new PacketPlayOutEntityEffect(ridable.getId(), invisibilityEffect));
#

Tried that but doesn't work 😢

hasty prawn
acoustic widget
#

Yes ok, but where I can find event like this one : onBowShoot

#

I tried to search on spigot doc but i don't know how to find it

hasty prawn
#

ProjectileLaunchEvent

#

That's fired when someone shoots a bow

#

You just need to make sure it's a bow @acoustic widget

elfin talon
#

How can I set the skulltype?

hasty prawn
elfin talon
#

1.12.2

hasty prawn
#

Are you trying to get a Player head or what

elfin talon
#

yeah

hasty prawn
#

If Material.PLAYER_HEAD doesn't exist, make a skull item with a data byte of 3

plain helm
#

guys how can i force a player to walk somewhere?

hasty prawn
acoustic widget
hasty prawn
acoustic widget
#

I was watching a video on 1.13 (2018)

plain helm
hasty prawn
#

I think you're looking at the name of the method and not the actual event name @acoustic widget. If you go watch the video again I'm guessing they use ProjectileLaunchEvent

acoustic widget
#

hahaha

#

you are right...

#

Sorry, I'm learning java dev, my mistake

#

Thanks !

hasty prawn
plain helm
#

ohh

#

that's what i'm doing wrong then lol

#

i've been using this method

 target.setVelocity(vel.normalize());
 target.teleport(loc);
hasty prawn
#

Yeah you should just set the velocity

plain helm
#

i'll try that ty

elfin talon
#
LOC.get(i).getBlock().setType(Material.SKULL);
            Skull skull = (Skull) LOC.get(i).getBlock().getState();```

But how can I set the skulltype to a playertype?
hasty prawn
#

Hmm, I'm not sure. This was all changed in 1.13 so I don't remember how it was done, you might just have to do some Googling.

elfin talon
#

okay ty

quaint mantle
#

Hey, I'm trying to get player inventory information like so, I know I can use item.getType() and item.getAmount() to get the type and amount, is there something to get the slot it was in in the inventory as a number?

#
ItemStack[] items = player.getInventory().getContents();
        ArrayList<String> itemList = new ArrayList<String>();
        for(ItemStack item : items) {
            if(item != null) {
                // item.getType(), item.getAmount(),
            }```
tardy delta
#

what

quaint mantle
#

sorry let me rephrase

tardy delta
#

you mean get the index of the itemstack when its in the arraylist?

quaint mantle
#

I'm trying to build a list of items in a players inventory, I know how to get the item type and amount, but I'd also like to get the position (slot i guess?) of it in the players inventory

rough jay
#

hi, what about built in bukkit ORM? Is it good?

opal juniper
#

can’t you do like Inventory#getSlot

tardy delta
#

i think he means to get the original slot index or something

#

dont

manager.setupCommands(this);
        manager.setupListeners(this);
        manager.setupBungeeCord(this);

try ```java
Manager manager = new Manager(this);

instead
#

you understand what i mean?

#

i did it like this but that looks the same

private boolean setupChat() {
        if (getServer().getPluginManager().getPlugin("Vault") == null) {
            return false;
        }
        RegisteredServiceProvider<Chat> chatProvider = getServer().getServicesManager().getRegistration(net.milkbowl.vault.chat.Chat.class);
        if (chatProvider != null) {
            chat = chatProvider.getProvider();
        }
        return chat != null;
    }
#

also i don't know if the extra space before Vault in your plugin.yml causes it

#

i think it does

#

probably the rsp is null in that way

tame elbow
#

quick question, how would I go about constantly making zombie piglins angry at everyone all the time? I found the PigZombieAngerEvent in docs but dont know how to use it.

tardy delta
#

Cant you make them angry when they Spawn?

tame elbow
#

or this zombifiedpiglin.setAngry(true);

tame elbow
verbal nymph
#

Hey friends, I wanna make days a little bit longer my SMP using a plugin. Can I just set DO_DAYLIGHT_CYCLE to false while the sun is up and then set it back to true a few thousand ticks later or is that gonna cause some problems I'm currently not thinking of?

opal juniper
#

the best ways are the ones already in minecraft

#

don’t work harder than you have to

verbal nymph
#

Haha true, thank you! 🙂

noble knot
#

Hi. I'm pretty new to Java. How would I fix this error?

quaint mantle
#

You need to pass an instance of your Announcement class into JoinListener()

noble knot
#

And how would I do that?

quaint mantle
#

Show more code

noble knot
#

In what class?

quaint mantle
#

That one

quaint mantle
#

Okay so

#

Instead of doing new Announcement() inside of the setExecutor

#

Make a variable for it

#

Announcement announcement = new Announcement();

noble knot
#

ok

quaint mantle
#

Then you can put setExecutor(announcement); and also new JoinListener(announcement);

noble knot
#

It's giving me an error

quaint mantle
#

What is it

#

Oh yea I see the red line under setExecutor

noble knot
noble knot
quaint mantle
#

Oh ok I’m blind

#

Oh

#

Swap the parameters I think

noble knot
#

What parameters?

quaint mantle
#

new JoinListener and “this”

noble knot
#

Nope

#

Still red

quaint mantle
#

Wait

#

Confused. What is your announcement class and JoinListener class

#

Also I’m pretty sure you have to use registerEvents instead of registerEvent

#

That’s prob why it’s not working

noble knot
#

Ok thanks

#

I'm dumb

quaint mantle
#

No error now?

noble knot
#

Wait it doesn't work

#

No errors in console

quaint mantle
#

What exactly about it doesn’t work

#

I'm trying to debug my plugin because it lags the server

#

How am I supposed to pinpoint the exact location in the code that causes it?

#

0.39% 666.33% 0.33 s 333.17 ms 0.0 0.0k Task: Database$$Lambda$4362/0x0000000801797878(Single) I got this from /timings pase

#

You could run a timings report

#

Oh

#

Okay are you calling to the database on the main thread?

#

Probably

#

Database calls need to be executed asynchronously

#

it looks like it but

#

I am wrapping the calls in an asyncv scheduler

#

Hmm

#

Show?

tardy delta
#

Bukkit.getscheduler.runasync()

toxic mesa
#

How would u guys go about solving this issue:

  • kicked with message asynchronous getNearbyEntities
  • getNearbyEntities is never called
    Something is messing up hard here
quaint mantle
#

this seems to happen here:

    @EventHandler
    public void onPlayerJoin(PlayerJoinEvent e) {
        Map.add(e.getPlayer(), System.currentTimeMillis());
        Database.getInfo(e.getPlayer().getUniqueId().toString(), (result) -> {
            Map2.add(e.getPlayer(), result);
        });
    }
#

Ok show your get info method

proud shuttle
#

I'm look for a plugin which I can make teleport command so like I can do /plots and it teleport me

quaint mantle
#

Also I hope you aren’t mutating the Map2 asynchronously or you’ll have problems

#

inside getInfo:

        Bukkit.getScheduler().runTaskAsynchronously(plugin, () -> {
            try {
                int result;
                PreparedStatement statement = connection.prepareStatement(Queries.get_info);
                statement.setString(1, uuid);
                ResultSet set = statement.executeQuery();
                if (set.next()) {
                    result = set.getInt("info");
                } else {
                    result = 0;
                }
                set.close();
                Bukkit.getScheduler().runTask(plugin, () -> callback.accept(result));
            } catch (SQLException e) {
                Logger.logError(e);
            }
        });
#

That looks fine, only thing I see is you not closing the connection

#

Are you using a connection pool?

#

no

#

I would suggest looking into doing that. HikariCP is a good one.
Also you never close the statement either. Closing the resultset doesn’t close the statement, however closing the statement should close the resultset

#

oh

#

so am I supposed to replace set.close with statement.close?

#

Yep

#

You could leave the set.close if you want, for clarity

#

And put the statement.close after it

#

Basically you want to close things in the reverse order that you made them

#

yeah