#help-development

1 messages · Page 615 of 1

undone axleBOT
#

Bootstrap Jar
The main spigot-1.18.jar is now a bootstrap jar which contains all libraries. You cannot directly depend on this jar. You should depend on Spigot/Spigot-API/target/spigot-api-1.18-R0.1-SNAPSHOT-shaded.jar, or the entire contents of the bundler directory from your server, or use a dependency manager such as Maven or Gradle to handle this automatically.

Please read the release notes for further information: https://www.spigotmc.org/threads/9-years-of-spigotmc-spigot-bungeecord-1-18-1-18-1-release.534760/#post-4305163

wet breach
#

another link as well

silver robin
#

wait what

shadow owl
#

Is there any way to have an AttributeModifuer on an item apply to a player without them wearing/holding it?

EDIT: nevermind, figured this out, you can apply attributemodifier directly to player.getAttribute() since that returns an AttributeInstance

silver robin
#

buildtools --remapped which basically gives a jar, with unobfuscated names, but comments and docs are lost, right?
so it's not possbile in any other way?

wet breach
#

only api has documentation

silver robin
#

alright, and how do I get craftbukkit? (i assume it's the bridge between spigot and nms)

wet breach
#

but you wanted to use NMS, so you need spigot-server jar

eternal oxide
#

?nms just follow the tutorial

eternal oxide
#

Do exactly as it says

silver robin
#

should I remove the other spigot-api dependency from pom or not then?

wet breach
#

spigot api isn't needed as a dependency if you are going to depend on spigot-server since the api is shaded into the server jar

silver robin
#

BuildTools will install all dependencies to your local maven repository.
I'm getting this error, unsure where I'm supposed to put the jar after buildtools finishes it's job?

tender shard
eternal oxide
#

nowhere, follow the tutorial word for word

#

1.16 ah

silver robin
#

I'm okay with using obfuscated names, i'd just like to be able to use org.bukkit.craftbukkit, net.minecraft.server, and com.mojang.authlib classes

wet breach
#

oh, 1.16 then you just need to have spigot-server as a dependency and either let intellij install it or put it in your local maven repo

tender shard
#

1.16.5 is like 2.5 years old already D:

#

why does anyone still use it

silver robin
#

performance 😦 I'm running a cheap server

icy beacon
#

com.mysql.jdbc.exceptions.jdbc4.MySQLNonTransientConnectionException: Client does not support authentication protocol requested by server; consider upgrading MySQL client (full error and other info: https://paste.md-5.net/vipumabaxa.makefile)
any idea why this is happening? mysql select version(); outputs 10.4.27-MariaDB, dependency is com.mysql:mysql-connector-j:8.0.33

tender shard
#

1.16.5 uses spigot mappings, which is a mixture of obfsucated and random names

#

just remove the <classifier>

silver robin
tender shard
#

run buildtools

silver robin
#

yeah, I got the jar

tender shard
#

run buildtools

wet breach
silver robin
#

run buildtools in which directory?

tender shard
#

doesnt matter

icy beacon
#

wherever

tender shard
#

just urn buildtools for 1.16.5

#

and then add spigot 1.16.5 as dependency

#

that's it

native bramble
#

How can i check that item was renamed by plugin, not by player?

silver robin
icy beacon
#

wherever you run it

tender shard
icy beacon
#

and it'll be available in maven

#

just run buildtools

#

please

#

mysql problem

tender shard
#

there is literally no need to mess with any files that buildtools generated

#

just run it, and then use maven to add org.spigotmc:spigot:1.16.5-R0.1-SNAPSHOT

#
<dependency>
  <groupId>org.spigotmc</groupId>
  <artifactId>spigot</artifactId>
  <version>1.16.5-R0.1-SNAPSHOT</version>
  <scope>provided</scope>
</dependency>
silver robin
tender shard
#

how often do you want me to tell you to run buildtools for 1.16.5

silver robin
#

wait nevermind

#

it was okay

#

I had the mojang remapped thing in <dependency> left, my bad

tender shard
#

remapped-mojang is only available in 1.17+

silver robin
#

eh, I thought it's not going to do anything and that it would matter where buildtools is ran, but intellij indexed it now, thanks

tender shard
#

no, you can run it anywhere, buildtools automatically mvn installs the dependencies it has built

silver robin
#

does that "local maven repo" point back to the buildtools folder or is it copied? (is it safe to delete buildtools folder now?)

icy beacon
#

it doesn't point back to anything

tender shard
#

your maven repository is at $HOME/.m2/repository. maven copies the files there

icy beacon
#

it stores your local dependencies

tender shard
#

tl;dr you can remove buildtools after it's finished

icy beacon
#

whenever you add some dependency in your project and then refresh the pom, if the dependency was not yet in your local repo, it gets downloaded

#

almost same with buildtools, you run it and it's now in your local repo

#

which means that you can use it in any of your projects

#

maven will look for the dependencies in your local repo

silver robin
#

so it looks locally first?

tender shard
#

yes

icy beacon
#

i'd say it only looks locally

tender shard
#

and if something's not there, it looks in maven central and all your declared repositories

icy beacon
#

if it's not there it downloads

#

yep

silver robin
#

makes sense

icy beacon
#

🙂

silver robin
#

I thought "local maven repository" refers to where my intellij project is for some reason, mb

icy beacon
#

lol

wet breach
# silver robin so it looks locally first?

technically, if you have no repos listed in the pom, it looks at maven central first. If you do have a repo listed, it will look at that repo first, then maven central then locally

#

unless you specify to only look locally

#

in either case, maven will eventually find it

tender shard
#

it always uses the local repository first

wet breach
#

no

icy beacon
#

if it doesn't exist at all

#

nitpicking

wet breach
#

well if it doesn't exist at all, yeah won't find it

#

but I was just detailing the order in which maven looks for dependencies lol

#

local is always last unless you configured maven for offline in which case it will only look locally lol

native bramble
#

How can i check that item was renamed by plugin, not by player?

tender shard
#

ofc it uses the local repo first

smoky anchor
native bramble
smoky anchor
#

Then just give it some flag with

#

?pdc

native bramble
#

i saw that getlocalizedname give another output than getdisplayname

native bramble
smoky anchor
#

don't tell me

native bramble
#

i need to rename itemframe when it placed

tender shard
#

which is by default once per day

smoky anchor
wet breach
native bramble
#

I need to realize invisible item frames. When player cst a splash potion frames, which in radius of potion, should be always invisible, so i need not only setVisible, but also smth data in frame, that i will check and make it invivisble on hangingplaceevent

#

here is code

#

i also have this event:

@EventHandler
    public void onPlayerPlaceFrame(HangingPlaceEvent e){
        ItemStack item = e.getItemStack();
        if(item == null) return;
        if(item.getType() == Material.ITEM_FRAME){
            ItemFrame frame = (ItemFrame) e.getEntity();
            if(!item.hasItemMeta()) return;
            if(!item.getItemMeta().hasDisplayName()) return;
            System.out.println(Arrays.toString(item.getItemMeta().getLocalizedName().getBytes()));
            if(item.getItemMeta().getDisplayName().equals(ChatColor.RESET + "Невидимая рамка")){
                frame.setVisible(false);
            }

        } else if (item.getType() == Material.GLOW_ITEM_FRAME) {
            GlowItemFrame frame = (GlowItemFrame) e.getEntity();
            frame.setVisible(false);
        }
    }
tender shard
#

Dont use display names to identify items

native bramble
#

now im experimenting with localizedname

tender shard
#

Use pdc tags

native bramble
#

read pls

native bramble
#

i know that i should use NOT name, like custommodeldata and another

tender shard
native bramble
#

read what i want to do

tender shard
#

I did

native bramble
#

i cant get itemmeta of itemframe

tender shard
#

You still keep using the itemmeta‘s name

native bramble
tender shard
#

Ofc not, its not an itemstack

young knoll
#

It’s an entity

native bramble
#

so

young knoll
#

Entities can also have pdc

young knoll
#

Yes

smoky anchor
native bramble
smoky anchor
#

I assume you will try to implement something like:
When player breaks item frame, check if it is the custom "invisible" item frame, if so give player the custom "invisible" item frame item.
For that you can use PDC as mentioned before.

native bramble
#

i was tried pdc and trying now but i get null when checks the item pdc

#
private static final NamespacedKey invisibleKey = new NamespacedKey(WhitePlus.getInstance(), "invisible");
    public static void changeFrameVisibility(Entity entity) {
        if(entity == null) return;
        if(entity.getType() == EntityType.ITEM_FRAME){
            ItemFrame frame = (ItemFrame) entity;
            frame.setVisible(false);
            frame.setCustomName(itemFrameName);
            frame.getPersistentDataContainer().set(invisibleKey, PersistentDataType.BYTE, (byte) 1);
        } else if (entity.getType() == EntityType.GLOW_ITEM_FRAME) {
            GlowItemFrame frame = (GlowItemFrame) entity;
            frame.setVisible(false);
            frame.setCustomName(glowItemFrameName);
            frame.getPersistentDataContainer().set(invisibleKey, PersistentDataType.BYTE, (byte) 1);
        }
    }```
#
@EventHandler
    public void onPlayerPlaceFrame(HangingPlaceEvent e){
        ItemStack item = e.getItemStack();
        if(item == null) return;
        if(item.getType() == Material.ITEM_FRAME){
            ItemFrame frame = (ItemFrame) e.getEntity();
            System.out.println(frame.getPersistentDataContainer()
                    .get(InvisibleItemFramesMain.getInvisibleKey(), PersistentDataType.BYTE));
            //if()){
            //    frame.setVisible(false);
            //}

        } else if (item.getType() == Material.GLOW_ITEM_FRAME) {
            GlowItemFrame frame = (GlowItemFrame) e.getEntity();
            frame.setVisible(false);
        }
    }
smoky anchor
#

where are you getting it and is it an error or a warning?

native bramble
#

or pdc not saves after block breaks?

smoky anchor
#

that.. doesn't explain anything

native bramble
#

and it output null

#

always

smoky anchor
#

ah ok gotcha

#

Uuhh you need to get the PDC from the item, not the entity

native bramble
#

can i get item of entity?

#

no, i think

#

or u about ItemFrame, not ItemStack?

#

ohh, no

smoky anchor
#

get pdc from ```java
ItemStack item = e.getItemStack();

#

wait am I doing a dumb
guys help XD

remote swallow
#

item meta

native bramble
smoky anchor
#

you can
you have the item

native bramble
#

but it always null

#

i was trying this

smoky anchor
#

it can't be null unless it's air

native bramble
#

u want to get itemmeta from ItemFrame?

smoky anchor
#

no, from your item

native bramble
#

in which event?

smoky anchor
#

so you can check if it is your custom item

native bramble
#

hangingplace?

native bramble
#

man

#

i cant create custom item

#

custom item is creating in onPlayerCastSplashPotion

#

in PotionSplashEvent

#

sry

#

problem is

#

i cant do nothing with placed itemframe except of setCustomName

smoky anchor
#

I might be misunderstanding

native bramble
#

i wanted to check item name, check if this item was renamed by plugin, not by player and frame.setVisible(true) if true

smoky anchor
#

Ok, how do players get this item

native bramble
#

oh sry

#

i didnt send one more event

#

my sry

#
@EventHandler
    public void onPlayerCastSplashPotion(PotionSplashEvent e){
        if(((PotionMeta)e.getPotion().getItem().getItemMeta())
                .getBasePotionData().getType() != PotionType.INVISIBILITY) return;
        for(Entity entity: e.getPotion().getNearbyEntities(4,4,4)){
            InvisibleItemFramesMain.changeFrameVisibility(entity);
        }

    }
native bramble
#

player cast splash potion on default item frames -> default item frames become invisible item frames

smoky anchor
#

yes, that looks correct
so does changeFrameVisibility

native bramble
#

so that because my question was "How check if item was renamed by plugin?"

smoky anchor
#

Is it by breaking the invisible item frame ?
If so, then you're missing an event

native bramble
#

if player want to get invisible items, he need to cast splash potion (invisible) to item frames, which will be setVisible(false) and than player can break itemframe to get

smoky anchor
#

ok so.. create that event now

native bramble
#

i was trying to check HangingBreakEvent

#

and check if itemframe was invisible

#

like setVisible(false)

#

but i cant

smoky anchor
#

send what you tried

umbral ridge
#

In Material class in values(), is it possible to extract Blocks only?

#

and not eg. spawn eggs books, eggs, etc

remote swallow
#

stream it, filter to isBlock

#

do that in a static final field too thanks

umbral ridge
#

Oh that's a great idea lol

native bramble
#

@smoky anchor ty, its working with hangingbreakevent

#

at first i didnt see that its inherits getEntity from hangingevent

smoky anchor
#

ok.. so now uhm... you send it here and..
who here knows how to change the item the entity drops

#

My idea is to cancel the event, destroy the entity and spawn a new item.

native bramble
#

i will send what i write

silver robin
icy beacon
#

i'm dying to find out why this is not fucking working

  fun update(query: String, vararg arguments: Any) {
    println("A")
    connect()
    println("B")

    val statement = connection.prepareStatement(query)
    println("C")
    arguments.forEachIndexed { index, argument ->
      println("D ${index+1} $argument")
      statement.setObject(index + 1, argument)
    }
    println("E")

    statement.executeUpdate()
  }

it never outputs "E", and moreover it halts the code (e.g.):

    CompletableFuture.supplyAsync {
      println(1)
      plugin.database.update(Commands.ADD_PLAYER_IF_NOT_EXISTS, uuid)

      println(2) // never happens
      // *snip*
    }

command in question:

    const val ADD_PLAYER_IF_NOT_EXISTS = """
      INSERT IGNORE INTO kitpvp (uuid, locale, kills, deaths, playtime, totalxp)
      VALUES ('?', 'en_US', 0, 0, 0, 0);
    """
#

please help me i'm going insane

smoky anchor
silver robin
icy beacon
#

it could be

remote swallow
#

the question mark would be replaced with hikari most likely

silver robin
smoky anchor
#

GlowItemFrame, ItemFrame, LeashHitch, Painting

icy beacon
#

another problem that i've been encountering is that i can't seem to get resultsets to actually return what i need, it gets stuck again:

val localeResultSet = plugin.database.fetch(Commands.GET_LOCALE, uuid)
println(2.05)
println(localeResultSet.getObject(1)) // this is never printed

command is in the attachment and here:

const val GET_LOCALE = """
  SELECT locale
  FROM kitpvp
  WHERE uuid = ?;
"""

(the fetch function should be working i think, i debugged it and it goes through successfully, but here it is just in case)

  fun fetch(query: String, vararg arguments: Any): ResultSet {
    connect()

    val statement = connection.prepareStatement(query)
    arguments.forEachIndexed { index, argument ->
      statement.setObject(index + 1, argument)
    }

    return statement.executeQuery()
  }
echo basalt
#

localeResultSet.next()

icy beacon
#

oh let me try that

hazy parrot
#

Sqlexception should be thrown, that is why your code "stopped" working

icy beacon
#

oh, i assumed that when it's not caught, it's just thrown and the stack trace is outputted

#

will keep that in mind, ty

hazy parrot
#

Iirc that is case for runtime exceptions, might be wrong

icy beacon
#

it very well could be

icy beacon
#

thanks!

tender shard
echo basalt
#

Gotta love having random people following me on git

#

You look at their profile and it's just some kid from egypt with a tiktok bot made in python

silver robin
silver robin
icy beacon
#

i think the project will undergo a lot of optimisation before prod

#

i'm just getting it to work now

silver robin
# echo basalt Makes it harder to debug

how so? mysql client will show them as large hexadecimal numbers, and you can always use SELECT HEX(a), ... to convert it back to (non-dashed) uuid after querying

echo basalt
#

Just debugging tables in general

tender shard
echo basalt
#

^ sql injection is the term for this

tender shard
#

hence you do SELECT * FROM users WHERE user = ? and then it'll auto escape my "username"

silver robin
#

I understand that lmao

#

wait what was my message about

#

ah, the parametrized queries
seems like there's a whole object for those prepated statements in java

worthy moat
#

Hey I saved a HashMap in my YML with <ENUM, Object> .... It has a Problem with the Enum

#
org.bukkit.configuration.InvalidConfigurationException: Global tag is not allowed: tag:yaml.org,2002:de.marvn.alphablock.alphawars.util.objects.TeamType
 in 'reader', line 5, column 5:
        &id001 !!de.marvn.alphablock.alp ...```
#

How can I serialize Enums?

tender shard
#

save their names instead of the actual instance

#

turn your map into a String,Object

worthy moat
#

ok

tender shard
#

example

    {
        // Original map: Map<Material,Integer>
        Map<Material,Integer> map = new HashMap<>();
        map.put(Material.DIRT, 1);
        map.put(Material.STONE, 2);

        // Turn to Map<String,Integer>
        Map<String,Integer> stringMap = map.entrySet().stream().collect(Collectors.toMap(e -> e.getKey().name(), Map.Entry::getValue));
        
        // Turn it back into the original map:
        Map<Material,Integer> map2 = stringMap.entrySet().stream().collect(Collectors.toMap(e -> Material.valueOf(e.getKey()), Map.Entry::getValue));
    }
silver robin
tender shard
#

there is no sources jar for spigot

silver robin
#

huh? I swear they were loaded (the same docs comments as in the javadoc)

tender shard
#

the javadocs yes, but not the sources

fluid river
#

is a = b + c actually compiling to temp = b, temp = temp + c, a = temp?

silver robin
# tender shard the javadocs yes, but not the sources

wait i'll give an example
this is the bukkit Vector class, now that I put spigot-api as dependency in pom.xml (instead of just 'spigot'), it has comments
and the arguments of every function are nice and not var1, var2...
where's that coming from then?

native bramble
smoky anchor
native bramble
#

ohh, thank u

smoky anchor
#

Otherwise, does it work as you expect ?

native bramble
#

yeah

smoky anchor
#

Great!

native bramble
#

also its works nice with items in frame

quaint mantle
#

Hello, Is there any simple way of checking if an entity is "inside" a location?
I've tried checking entity bounding box, but didn't work as expected

tender shard
#

wdym with "didnt work as expected"?

quaint mantle
#

Well, it doesn't work, I check if the boundingbox contains the location, but doesn't work

AtomicBoolean work = new AtomicBoolean(true);
            for (int i = 0; i < distance; i++) {
                if (!work.get()) break;

                int currentI = i;
                scheduler.runTaskLater((task) -> {
                    double offsetX = currentI * projectileDirection.getX();
                    double offsetY = currentI * projectileDirection.getY();
                    double offsetZ = currentI * projectileDirection.getZ();

                    Location particleLocation = startLocation.clone().add(offsetX, offsetY, offsetZ);
                    Block block = particleLocation.getBlock();
                    if (!block.getType().name().contains("AIR")) {
                        work.set(false);
                        ProjectileHitEvent event = new ProjectileHitEvent(magicTrace, block);
                        server.getPluginManager().callEvent(event);

                        return;
                    }

                    Entity hitEntity = null;
                    for (Entity ent : world.getEntities()) {
                        if (ent.getBoundingBox().contains(particleLocation.getX(), particleLocation.getY(), particleLocation.getZ())) {
                            hitEntity = ent;
                            break;
                        }
                    }
                    if (hitEntity != null) {
                        work.set(false);
                        ProjectileHitEvent event = new ProjectileHitEvent(magicTrace, hitEntity);
                        server.getPluginManager().callEvent(event);

                        return;
                    }

                    world.spawnParticle(Particle.CRIT, particleLocation, 10, 0.15, 0.15, 0.15, 0);
                    world.spawnParticle(Particle.EGG_CRACK, particleLocation, 2, 0, 0, 0, 0);
                }, magicTrace.tracePeriod() * i);
            }
tender shard
#

why are you checking if the material contains "AIR"?

#

OAK_STAIRS

#

check if the material .isAir()

#

what are actually trying to do btw?

quaint mantle
#

I don't know where my mind is

quaint mantle
#

Let me show you

#

It should stop when it hits an entity, and call the "ProjectileHitEvent"

#

But it doesn't

#

That's the ProjectileHitEvent

@EventHandler(priority = EventPriority.LOWEST)
    public void onEntityHit(ProjectileHitEvent e) {
        Projectile projectile = e.getEntity();
        if (projectile instanceof MagicTrace trace) {
            CraftMagicTrace cmt = (CraftMagicTrace) trace;

            Entity hitEntity = e.getHitEntity();
            if (hitEntity instanceof LivingEntity living) {
                e.setCancelled(true);

                double tracePeriod = trace.tracePeriod();
                double baseDamage = cmt.getHandle().getBaseDamage();

                AttributeInstance attribute = living.getAttribute(Attribute.GENERIC_MAX_HEALTH);
                if (attribute != null) {
                    double scaledTrace = attribute.getBaseValue() / tracePeriod;
                    double scaledDamage = baseDamage * scaledTrace;

                    living.damage(scaledDamage, projectile);
                }
            }

            cmt.getHandle().remove(net.minecraft.world.entity.Entity.RemovalReason.KILLED);
        }
    }
#

Just to clarify, CraftMagicTrace and MagicTrace are just "dummy" classes I created modifying spigot source code

#

CraftMagicTrace

public class CraftMagicTrace extends CraftArrow implements MagicTrace {

    private long speed = 0L;

    public CraftMagicTrace(CraftServer server, EntityTippedArrow entity) {
        super(server, entity);
    }

    @Override
    public EntityTippedArrow getHandle() {
        return (EntityTippedArrow) entity;
    }

    @Override
    public String toString() {
        return "CraftMagicTrace";
    }

    @Override
    public EntityType getType() {
        return EntityType.ARROW;
    }

    /**
     * Set the magic trace speed
     *
     * @param speed the speed
     */
    @Override
    public void setTracePeriod(final long speed) {
        this.speed = speed;
    }

    /**
     * Get the magic trace speed
     *
     * @return the magic trace speed
     */
    @Override
    public long tracePeriod() {
        return speed;
    }
}
#

MagicTrace

/**
 * Represents a magic trace
 */
public interface MagicTrace extends DummyProjectile {

    /**
     * Set the magic trace speed
     *
     * @param speed the speed
     */
    void setTracePeriod(final long speed);

    /**
     * Get the magic trace speed
     *
     * @return the magic trace speed
     */
    long tracePeriod();
}
young knoll
#

🙃

worthy moat
#

wHow could I make a Vote System? Players should Vote for something and then I pick the thing with the most votes
how could I achieve this?

tender shard
#

create a Map<Whatever,Integer> where Whatever is what they voted vor, and integer is the amounts of votes it got

#

and another set with the UUID of people who already voted

#

or a Map<Whatever,Set<UUID>>

keen charm
#

But that data would last temporarily

#

If you need something for a bigger network, like it should get saved on even restarts, you need to use databases

tender shard
#

i'd just save the map to a yaml

quaint mantle
tender shard
#

yaml is for serializing whatever you want to serialize

quaint mantle
#

I would use json to store data instead

tender shard
#

well json is valid yaml, doesn't really make any difference

quaint mantle
#

I know, but idk, I feel like json is "better" even though both are valid

#

||I'm a JSON lover||

tender shard
#

idk imho json is just yaml in "hard to edit" lol

quaint mantle
#

json is not hard to edit 😔

echo basalt
#

World#rayTrace

#

Make a fancy predicate and all

tender shard
worthy moat
tender shard
#

by looping over the map's entryset and check whether any of the value sets contains the UUID

worthy moat
#

ok thx

young knoll
#

map.containsKey

#

Silly alex

#

Ah wait it's a value

#

Could use a bimap ig

tender shard
#
    private final Map<String, Set<UUID>> votes = new HashMap<>();
    
    public void addVote(String name, UUID uuid) {
        removeVote(uuid);
        Set<UUID> uuids = votes.computeIfAbsent(name, __ -> new HashSet<>());
        uuids.add(uuid);
    }
    
    public boolean hasVoted(UUID uuid) {
        return votes.values().stream().anyMatch(uuids -> uuids.contains(uuid));
    }
    
    public void removeVote(UUID uuid) {
        votes.values().forEach(uuids -> uuids.remove(uuid));
    }

idk sth like that

quaint mantle
tender shard
#

the predicate could just always return false to catch all entities but that's a hacky solution

echo basalt
#

You want to get all the entities in a bounding box or something?

young knoll
#

There's a method for that

quaint mantle
quaint mantle
#

Doesn't RayTraceResult #getEntity return always the latest/first hit entity only?

echo basalt
#

It does but that's what the predicate is for

#

You can just make a basic for loop, range checks and have an entity collection

tender shard
#
    private final class BadPredicate implements Predicate<Entity> {

        private final List<Entity> hitEntities = new ArrayList<>();
        private final Predicate<Entity> predicate;

        private BadPredicate(Predicate<Entity> predicate) {
            this.predicate = predicate;
        }

        @Override
        public boolean test(Entity entity) {
            if(predicate == null || predicate.test(entity)) {
                hitEntities.add(entity);
            }
            return false;
        }

        public List<Entity> getHitEntities() {
            return hitEntities;
        }
    };

    {
        Player player = null;
        BadPredicate predicate = new BadPredicate(null);
        RayTraceResult ignored = player.getWorld().rayTrace(..., predicate);
        List<Entity> hitEntities = predicate.getHitEntities();
    }
#

very hacky solution

young knoll
#

lol

echo basalt
#

That seems like an icky solution

quaint mantle
#

Or like this?

List<Entity> tracedEntities = new ArrayList<>();
            world.rayTrace(startLocation, direction, distance, FluidCollisionMode.NEVER, true, 1, (ent) -> {
                tracedEntities.add(ent);
                return true;
            });
tender shard
quaint mantle
#

Aight

#

And the raytrace itself will stop when it hits a solid block right?

echo basalt
#

Yea

river oracle
#

com.google.gson.JsonSyntaxException: java.lang.IllegalStateException: Duplicate key 1 (attempted merging values Enchantment[minecraft:unbreaking, DURABILITY] and Enchantment[minecraft:mending, MENDING]) wtf is this supposed to mean

#

oh nvm I get it now

#

I'm dumb

tender shard
#

Remember this one dude who always replied Objects.requireNonNull when someone posted a stacktrace

worthy moat
river oracle
#

IntellIJ really loves Objects.requireNonNull

tender shard
river oracle
#

even though its kinda shit in most cases imho

worthy moat
tender shard
#

Yes

worthy moat
#

whats that?

zenith gate
#
{
  "parent": "minecraft:item/handheld",
  "textures": {
    "layer0": "minecraft:item/stick"
  },
  "overrides": [
    {
      "predicate": {
        "custom_model_data": 2
      },
      "model": "minecraft:item/woh",
      "textures": {
        "layer0": "minecraft:item/woh"
      }
    },
    {
      "predicate": {
        "custom_model_data": 1
      },
      "model": "minecraft:item/BrokenWand",
      "textures": {
        "layer0": "minecraft:item/BrokenWand"
      }
    }
  ]
}

Why isn't this working? I am using a stick with a custom model data number, its applying the BrokenWand texture to both of the items. woh has its own texture called woh.png.

river oracle
tender shard
#

You got 2 before 1

tender shard
worthy moat
#

How can I sort them if I stgream the entry set

river oracle
#

Stream#sorted

tender shard
#
    private String getHighestVote() {
        return votes.entrySet().stream().max(Comparator.comparingInt(entry -> entry.getValue().size())).map(Map.Entry::getKey).orElse(null);
    }
worthy moat
#

but this one doesnt sort with the highest int in the map

river oracle
#

you have to reverse it

tender shard
river oracle
#

oh :| I totally knew that

#

time to go fix my code

river oracle
onyx fjord
#

arent enchants a multimap

tender shard
#

no? every enchantment can only have one level

zenith gate
# tender shard It must be in correct order

So i reordered it, now it just only shows the black and purple texture. It wont give the model number 2 the texture. I did try my new texture on data model number 1 and it worked, its just for the 2nd id of stick, no texture is displayed.

tender shard
#

BrokenWand probably won't work, it must be all lowercase iirc

zenith gate
#

that one does work

#

its just WoH

#

for the Custom Data Model 2 nothing ever gets set.

#

both my PNGs do work, its just the 2nd data model wont show.

tender shard
#

idk, hard to tell without having your full resource pack

gleaming grove
#

Does minecraft provides now some featue I can use do draw mesh(3d box) outline, or still paricles are the only option?

rare rover
#

Particles

tender shard
#

or blockdisplays if you wanna make it fancy

gleaming grove
#

I've never use that stuff has spigot some API for structure blocks?

tender shard
#

yes

#

I'd try to experiment with glowing blockdisplays though

#

you only set the placeholders once, in the for loop in line 17

#

you would have to call that in your scheduled runnable everytime instead

#

but you always reuse the same strings

#

imagine you do this:

  1. my string is "name is %player_name%"
  2. apply placeholders to that string -> "name is mfnalex"
  3. now you tell FastBoard once per second "set scoreboard to "name is mfnalex""
#

ofc it will never change afterwards

#

you gotta do step 2 inside the scheduler task, too

worldly ingot
gleaming grove
sour folio
#

how can i use a custom hexcode for a chatcolor?

worthy moat
#

Got a problem

#
    private Map<Arena, Integer> votes = new ConcurrentHashMap<>();
    private Map<Arena, List<UUID>> whoVotedFor = new ConcurrentHashMap<>();

    public void vote(Arena arena, Player p) {

        whoVotedFor.forEach((votedArena, uuids) -> {

            if (arena == votedArena) {
                MessageManager.sendMessage(p, "<red>You already voted for this map");
                return;
            }

            if (uuids.contains(p.getUniqueId())) {
                votes.put(votedArena, votes.get(votedArena) - 1);
            }
        });

        if (votes.get(arena) == null) {
            votes.put(arena, 1);
            whoVotedFor.put(arena, List.of(p.getUniqueId()));
            return;
        }

        votes.put(arena, votes.get(arena) + 1);
        var list = whoVotedFor.get(arena);
        list.add(p.getUniqueId());
        whoVotedFor.put(arena, list);
        MessageManager.sendMessage(p, "<green>Sucessfully voted for <aqua><bold>" + arena.getName());

        setChosenArena(votes.entrySet().stream().max(Comparator.comparingInt(Map.Entry::getValue)).map(Map.Entry::getKey).orElse(null));
    }```
sour folio
#

ty

worthy moat
#

java.lang.UnsupportedOperationException: null

tender shard
#

the third last line is empty

worthy moat
#

yeah

#

Thats the thing

#

at de.marvn.alphablock.alphawars.cache.MiniGame.vote(MiniGame.java:54) ~[AlphaWars-1.0-all.jar:?]

ivory sleet
#

I mean sure you use CHM

#

But like, no atomicity

worthy moat
#

what?

ivory sleet
#

And taking advantage of the higher order functions that are specially implemented

worthy moat
#

how could I fix this?

worthy moat
tender shard
#

then your .jar doesn't match the source code

#

recompile, restart server, try again

worthy moat
#

As soon as I change my vote this error pops up

#

AH now the line is correct

#

list.add(p.getUniqueId()); this is null

twilit roost
#

how could I limit Vector angle?

so player couldn't launch themself straight up? but only to 70 degrees?

ivory sleet
#

The vector has some rotation methods, you can use those in combination with some checks

worthy moat
ivory sleet
#

Sounds like you could use a tree map in that case

tender shard
#

well Set, List, doesn't matter

worthy moat
#

no I had two maps

#

one with an integer

tender shard
#

why did you have two?

worthy moat
#

and one with the players

worthy moat
tender shard
#

I told you you can do either/or, and then I sent you code that uses a Map<Arena,Set<UUID>>

#

well I used a string instead of arena

worthy moat
#

oh haha

#
    private Arena chosenArena;

    public Map<Arena, List<UUID>> getVotes() {
        return votes;
    }

    private Map<Arena, List<UUID>> votes = new ConcurrentHashMap<>();

    public void vote(Arena arena, Player p) {
        setChosenArena(arena);
        p.sendMessage(arena.getName());

        votes.values().forEach(list-> {
            if (list.contains(p.getUniqueId())) {
                list.remove(p.getUniqueId());
            }
        });

        if (votes.get(arena).isEmpty()) {
            votes.put(arena, List.of(p.getUniqueId()));
            MessageManager.sendMessage(p, "<green>Sucessfully voted for <aqua><bold>" + arena.getName());
            return;
        }

        var list = votes.get(arena);
        list.add(p.getUniqueId());
        votes.put(arena, list);
        MessageManager.sendMessage(p, "<green>Sucessfully voted for <aqua><bold>" + arena.getName());

        setChosenArena(votes.entrySet().stream().max(Comparator.comparingInt(entry -> entry.getValue().size())).map(Map.Entry::getKey).orElse(null));```
vital sandal
#

what is the event which is called even cactus naturally break or cane break if break from the lowest layer?

worthy moat
#

Do you see any logic errors in thsi new vote thing?

vital sandal
#
votes.values().forEach(list-> {
            if (list.contains(p.getUniqueId())) {
                list.remove(p.getUniqueId());
            }
        });
worthy moat
#

whats with that?

vital sandal
#

1> I don't think that is a great way to remove items without iterators
2> you can just do remove without checking if it exist

worthy moat
#

what iterators whould I use?

trim creek
#

If so, then do not check if it exists or not 😹

vital sandal
worthy moat
#

I am getting a UnsupportedOperationException with a normal List<>

#

Hows That

vital sandal
icy bone
#

Question, im using TabExecutor to make my commands more cleaner, for example now it will auto complete all options. So this way the user knows what kind of options there are. But if noticed that when my options are done (for example: /seek [player/mob] <- for example my options follow up by [close/far]) i noticed it always try to put a username on the end. So with the example given, i use /seek player far, then it will give the auto complete option to add players form the server. Is there a way to block this?

#

Oh i fixed it by returning an empty list when checking for the last args, but is there a nicer way?

tender shard
worthy moat
#

I just used ArrayList and now it works

#

If I save a Location in a world in my config and then restart my server it tells me this

quaint mantle
worthy moat
#

How could I fix this?

quaint mantle
worthy moat
#

I already stored one

quaint mantle
#

Then are you trying to load it?

#

How are you storing it btw?

#

Ah, yes, you are trying to load a location

#

Why don't you store the values you need separately, then create a location instance out of those values?

#

Like storing the world UUID/name, X, Y, Z, yaw and pitch

#

Then create a location with those values

#

Bukkit#getServer#getWorld(UUID)

#

Bukkit#getServer#getWorld(String)

#

Check if the world is null, and if so, it means the world no longer exists

#

So the location is not longer "valid"

eternal oxide
#

You probably accessed your config too early, before worlds are loaded

sage patio
#

any idea how i can hide this icons in IntelliJ?

#

adds a kilometer of space after each line number

worthy moat
torn shuttle
#

I swear...

worthy moat
#

How can I load every world?

eternal oxide
worthy moat
#

The worlds I stored the locations from

eternal oxide
#

What worlds? Multiverse or default?

sterile token
worthy moat
#

Slime World Managee

#

Ok thx

umbral ridge
#

XD

sterile token
#

But i recommend it for big projects where you need to load many worlds and work with them around. Specially for mini games where its a mess

gleaming grove
#

Why m'I getting out of memory exception? Sever is only using 2GB of ram

sterile token
gleaming grove
#

That would be StackOverflowException

tender shard
#

once you replaced the lines in replacedLines, they are done

#

use a separate array or list

#
String[] original = new String[] { "name: %player_name%" };

// in scheduler:
String[] replaced = new String[original.length];
for(int i = 0; i < original.length; i++) {
  replaced[i] = PlaceholderAPI.setPlaceholders(player, original[i]);
}
FastBoard.updateBoard(board, replaced);

sth like this

#

tl;dr: keep the "original" lines that contain the placeholders

gleaming grove
torn shuttle
#

hey uh

#

when I do $ java -jar BuildTools.jar --rev 1.20 --remapped I'm getting 1.20.1, is anyone else experiencing this?

torn shuttle
#

erm

#

how do I do the mappings then

#

if one field and one method were added then the reobfuscation won't match somewhere, right?

vital sandal
#

I want to change blockdrop of some specific blocks (like special canes)

#

what are the events should I listen to :l

#

I got the idea but just wanna hear from you guys

tender shard
tender shard
#

yikes why do people never update

#

yeah anyway md said "No names changed"

torn shuttle
#

I mean is this a surprise to literally any dev that has been doing this for more than a month

ivory sleet
torn shuttle
#

well then if md said it... whatever changed is probably not what I want to mess with anyway

#

I swear I did not have this much white hair when I first started looking at NMS code

worthy moat
worthy moat
eternal oxide
#

your plugin shoudl load it's own worlds, the same way it created them

quaint mantle
#

Shout out to rick0wens

chilly hearth
#

Howe to make custom item by using itemstack

eternal oxide
#

create a new ItemStack, add a pdc tag, done. Custom item

tender shard
#

wdym? custom texture? custom behaviour? or just a stick with "my fancy item" name?

chilly hearth
#

Consider it a stick ig

chilly hearth
eternal oxide
#

as alex said, it really depends on what you want to do with your item

tender shard
#

thethen listen to the specific events, e.g. PlayerInteractEvent, and check if the item in use has your PDC tag

#

if yes, do your stuff

chilly hearth
#

Oh what will be the event of using the item?

tender shard
#

depends what you consider "using"

chilly hearth
#

Ok what if I Wana spawn thunder upon right clicking it

tender shard
#

PlayerInteractEvent

#

then check if the action is RIGHT_CLICK_AIR or RIGHT_CLICK_BLOCK

worthy moat
chilly hearth
#

@tender shard one more thing how do I make mobs attract players

tender shard
#

tell your players that the mobs are cute anime girls

worthy moat
#

hahahahahaha

eternal oxide
#

that will load whatever world you specify

worthy moat
#

so I need to add those worlds manually

eternal oxide
#

are you writing a plugin?

sage patio
#

if i have a FileConfiguration variable, its not getting updated when the file is changed right?

tender shard
#

correct

sage patio
#

thanks

worthy moat
eternal oxide
#

This will load (or create if it doesn't exist)java WorldCreator("yourWorldName").createWorld()

worthy moat
#

hmm ok

#

thx

eternal oxide
worthy moat
eternal oxide
#

no idea what SWM is. This is Spigot

worthy moat
#

Slime World Manager

eternal oxide
#

Spigot

tender shard
eternal oxide
#

no point in using a manager to load your own worlds

worthy moat
#

ok

sage patio
#

any idea why placeholder is not getting the updated value?

#

but the same method in a command gets the updated one

tender shard
worthy moat
#

hmm ok

eternal oxide
#

Yeah, never used it

sage patio
# sage patio

case test is the command and balance_comma is the placeholder

tender shard
#

how does your PAPI code look like

sage patio
# tender shard how does your PAPI code look like
public class PAPIExpansion extends PlaceholderExpansion {
    public PAPIExpansion(Plugin plugin) {
        Plugin p = NLBank.getInstance();
    }

    @Override
    public @NotNull String getIdentifier() {
        return "nlbank";
    }

    @Override
    public @NotNull String getAuthor() {
        return "xii69";
    }

    @Override
    public @NotNull String getVersion() {
        return "1.0.0";
    }

    @Override
    public boolean canRegister() {
        return true;
    }

    @Override
    public boolean persist() {
        return true;
    }

    @Override
    public @Nullable String onPlaceholderRequest(Player player, @NotNull String params) {
        switch (params) {
            case "balance" -> {
                return String.valueOf(AccountUtils.getBalance(player.getName()));
            }
            case "balance_comma" -> {
                return Utils.formatNumber(AccountUtils.getBalance(player.getName()));
            }
        }
        return null;
    }
}
eternal oxide
modern badge
#

Hello! Why, after canceling the InventoryClickEvent, the player can still put the item in the inventory by clicking frequently?

worthy moat
tender shard
tender shard
#

you know, like when you drag an item over 10 slots and it divides the stack into all those slots? the same can happen if they move the mouse over just one slot

modern badge
#

and how to find out from it that the player dragged the item in the inventory created using the script?

sage patio
tender shard
#

then your AccountUtils method must be messed up

sage patio
tender shard
#

is it the same plugin? the command and the placeholder?

sage patio
#

yes

#

and i use papi parse for testing it

tender shard
#

what does getFileManager() do?

#

or getConfig() in that

sage patio
#

well returns a FileManager class, getConfig returns a FileConfiguration

#

is it because of i'm reloading my plugin using a plugin?

tender shard
#

yes probably. your PAPI extension keeps loaded because you return true for persistent(), and then it uses the old FileManager from your previous plugin instance

sage patio
#

any idea how i can fix it?

tender shard
#

restart your server

sage patio
#

maybe i just have to reboot the server

#

alright, thanks

tender shard
#

or at least unregister your extension in onDisable

worthy moat
# eternal oxide WorldCreator.name("customWorld").createWorld()
        arenas.getArenas().forEach((file, fileConfiguration) -> {
            var arena = (Arena) fileConfiguration.get("Arena");
            if (arena.getTeams() != null) {
                arena.getTeams().entrySet().stream().findFirst().ifPresent(teamTypeTeamEntry -> {
                    WorldCreator.name(teamTypeTeamEntry.getValue().getSpawnBlock().getWorld().getName()).createWorld();
                    Bukkit.getLogger().log(Level.INFO, "Sucessfully loaded " + teamTypeTeamEntry.getValue().getSpawnBlock().getWorld().getName());
                });
            }
        });``` So this should load my worlds?
eternal oxide
#

um? getSpawnBlock().getWorld().getName()

worthy moat
#

Yeah thats something from my Object

eternal oxide
#

is that a Bukkit world object?

worthy moat
#

Nope

#

My own

eternal oxide
#

ok

worthy moat
#

But this should work?

modern badge
#

@tender shard thanks

eternal oxide
#

seems a little overboard but shoudl work

worthy moat
eternal oxide
#

why only the first?

worthy moat
#

Because every team has the same world...I only need one

eternal oxide
#

ok

tender shard
#

if every team has the same world, then the world belongs to the arena and not the team, I guess

worthy moat
tender shard
#

lol ok

worthy moat
#

Yeah xD

#

Dont want to store that extra if I already can get them somehow

#

ah got a new question

#
        ProtocolManager manager = AlphaWars.protocolManager;
        BlockPosition position = new BlockPosition(player.getLocation().getBlockX(), 255,
                player.getLocation().getBlockZ());

        PacketContainer blockChange = manager.createPacket(PacketType.Play.Server.BLOCK_CHANGE);
        blockChange.getBlockPositionModifier().write(0, position);
        blockChange.getBlockData().write(0, WrappedBlockData.createData(Material.OAK_WALL_SIGN));
        PacketContainer updateSign = manager.createPacket(PacketType.Play.Server.UPDATE_SIGN);
        updateSign.getBlockPositionModifier().write(0, position);
        updateSign.getChatComponentArrays().write(0, new WrappedChatComponent[]{WrappedChatComponent.fromText(lines[0]), WrappedChatComponent.fromText(lines[1]), WrappedChatComponent.fromText(lines[2]), WrappedChatComponent.fromText(lines[3])});
        PacketContainer open = manager.createPacket(PacketType.Play.Server.OPEN_SIGN_ENTITY);
        open.getBlockPositionModifier().write(0, position);

        manager.sendServerPacket(player, blockChange);
        manager.sendServerPacket(player, updateSign);
        manager.sendServerPacket(player, open);``` this is how I open a Sign Inv
#

But this SignInv is now despawning instantly

#

No errors nothing

#

It comes and goes

buoyant viper
#

?stash for self

undone axleBOT
chilly hearth
#

No is there a way?

tender shard
#

?learnjava

undone axleBOT
chilly hearth
#

Oh

tender shard
chilly hearth
#

Like mobs follow players

tender shard
#

Add a custom pathfindergoal

#

That requires NMS though

chilly hearth
#

If they reach a certain radius

#

Nms?

tender shard
#

Internal minecraft code

#

?nms

tender shard
#

Here‘s how to setup maven to use NMS

chilly hearth
#

Oh

#

Alr thx

tender shard
worthy moat
#

anyone else know how I can open an SignGUI?

flint coyote
worthy moat
#

openSign needs a real sign

flint coyote
#

You will have to create a sign either way (could use packets aswell). You can despawn it. Whether you have to keep it "alive" while the GUI is open in order to get the SignChangeEvent is something you'd have to test.

fluid river
#

best way to check player entered a BoundingBox/Zone(not region)?

worthy moat
novel pendant
#

Does anyone know of an effective way to make item displays and block displays in spigot?

worthy moat
#

After I migrated to 1.20 it instantly despawns

#

maby this is the issue

flint coyote
worthy moat
#

How can I create a Sign with Spigot?

flint coyote
#

A real one or packet based?

worthy moat
#

a real one

flint coyote
#

Just use World#getBlockAt()#setType()

worthy moat
flint coyote
#

You can store the block in a variable and then cast it to a Sign once you changed its type

tender shard
#

maybe sending a blockchange to the client is enough

worthy moat
# tender shard maybe sending a blockchange to the client is enough
        ProtocolManager manager = AlphaWars.protocolManager;
        BlockPosition position = new BlockPosition(player.getLocation().getBlockX(), 255,
                player.getLocation().getBlockZ());

        PacketContainer blockChange = manager.createPacket(PacketType.Play.Server.BLOCK_CHANGE);
        blockChange.getBlockPositionModifier().write(0, position);
        blockChange.getBlockData().write(0, WrappedBlockData.createData(Material.OAK_WALL_SIGN));
        PacketContainer updateSign = manager.createPacket(PacketType.Play.Server.TILE_ENTITY_DATA);
        updateSign.getBlockPositionModifier().write(0, position);
        updateSign.getChatComponentArrays().write(0, new WrappedChatComponent[]{WrappedChatComponent.fromText(lines[0]), WrappedChatComponent.fromText(lines[1]), WrappedChatComponent.fromText(lines[2]), WrappedChatComponent.fromText(lines[3])});
        PacketContainer open = manager.createPacket(PacketType.Play.Server.OPEN_SIGN_EDITOR);
        open.getBlockPositionModifier().write(0, position);

        manager.sendServerPacket(player, blockChange);
        manager.sendServerPacket(player, updateSign);
        manager.sendServerPacket(player, open);``` This is how I sent that
#

But the Sign despawns instantly

flint coyote
eternal oxide
#

if you are creating a sign using packets then it will disapear th einstant anyone interacts with it

flint coyote
#

From what I read a packet sign should be enough. I did not test that though

flint coyote
fluid river
#

yeah and in which condition

#

playermove

#

runnable

worthy moat
flint coyote
#

On a scheduler as I don't need a 1 tick precision

fluid river
#

i would have to loop through all players and all boxes then

flint coyote
flint coyote
#

You can optimize it by tracking which chunks contain a region and whether they get loaded/unloaded

fluid river
#

worldguard is using some code under the hood

#

anyways

#

which can also be runnable

#

or moveevent

flint coyote
worthy moat
flint coyote
worthy moat
flint coyote
#

If you complete the parameters, yes

worthy moat
#

How can I create a block instanze

#

because I need a BlockData

flint coyote
#

Bukkit.createBlockData(material)

worthy moat
#

thx

chilly hearth
#

?learnjava

undone axleBOT
chilly hearth
#

Where is that gif they removed it bruh

chrome beacon
#

?learnjava!

undone axleBOT
chrome beacon
#

It's a different command 🙂

worthy moat
worthy moat
flint coyote
#

?tas

undone axleBOT
worthy moat
#

hahaha

tender shard
chrome beacon
worthy moat
tender shard
#

it does

odd cobalt
#

CraftWorld craftWorld = (CraftWorld) player.getLocation().getWorld();
EntityArmorStand armorStand = new EntityArmorStand(craftWorld.getHandle(), loc.getX(), loc.getY(), loc.getZ());

'EntityArmorStand(net.minecraft.world.level.World, double, double, double)' in 'net.minecraft.world.entity.decoration.EntityArmorStand' cannot be applied to '(net.minecraft.server.level.ServerLevel, double, double, double)'

please help me

worthy moat
# tender shard it does
        player.openSign((Sign) block.createBlockState());``` So like that? Do I need to cast that??
tender shard
#

yep

chrome beacon
#

Open the class and take a look

#

Also why are you using unmapped

#

That's going to be a pain

#

?nms

worthy moat
#

There is no event.setCancelled with BlockBreakEvent

worthy moat
young knoll
#

There is

worthy moat
#

oh yeah

#

your right

flint coyote
worthy moat
flint coyote
#

or check what's used to determine it's placed and check that via reflection. I'd just find a spot between bedrock in spawn chunks and actually place it

worthy moat
#

via reflection?

flint coyote
#

It's probably a variable

#

and that will be private

worthy moat
#

I think the best case is to place a sign in the air above the player and then remove it after I needed it

flint coyote
#

You might be able to place it, open the GUI and instantly remove it

worthy moat
flint coyote
#

Not sure, something you'd have to test

worthy moat
#

ok how do I spawn a block?

#

World.setBlock?

flint coyote
#

getblockat.settype

worthy moat
flint coyote
#

yes

#

Or you use setBlockData

worthy moat
#
        BlockData block = Bukkit.createBlockData(Material.OAK_SIGN);
        
        player.getWorld().setBlockData(
                player.getLocation().getBlockX(),
                200, player.getLocation().getBlockZ(),
                block
        );
        
        Sign sign = (Sign) block.createBlockState();
        sign.getSide(Side.FRONT).setLine(1, "^^^^");
        sign.getSide(Side.FRONT).setLine(2, "Enter how many");
        sign.getSide(Side.FRONT).setLine(3, "players per team");
        player.sendBlockChange(player.getLocation(), block);
        player.openSign(sign, Side.FRONT);``` Like that? Lets try
#

It does spawn the sign but still an error that it must be placed

tender shard
#

just set the sign to the world, call openSign, and one line later, remove the sign again

worthy moat
#

But the error persists

flint coyote
#

No the code only sends packets

#

it never actually places it

worthy moat
#

It spawns and flies in the world

flint coyote
#

don't see that anywhere up there

eternal night
#

createBlockState creates a virtual block state

flint coyote
#

oh nvm I'm blind lol

eternal night
#

you need to actively retrieve the block state of the sign placed in the world

worthy moat
#

how?

tender shard
#

by placing the sign, and then call getBlockState

worthy moat
#

thx

tender shard
#

maybe sth like this

    public static void openSign(Player player) {
        Block block = player.getWorld().getBlockAt(player.getLocation());
        block.setType(Material.OAK_SIGN);
        Sign sign = (Sign) block.getState();
        player.openSign(sign, Side.FRONT);
        block.setType(Material.AIR); // Actually, save the original BlockData and set it back here
    }
rose trail
#

Is it possible to find out if the player is online on some server connected by a proxy server?

worthy moat
#
java.lang.IllegalStateException: Tile is null, asynchronous access? CraftBlock{pos=BlockPosition{x=-144, y=200, z=-291},type=OAK_SIGN,data=Block{minecraft:oak_sign}[rotation=0,waterlogged=false],fluid=net.minecraft.world.level.material.FluidTypeEmpty@5d0d9a4d}```
worthy moat
# tender shard maybe sth like this ```java public static void openSign(Player player) { ...
        Block block = player.getWorld().getBlockAt(new Location(player.getWorld(), player.getLocation().getX(),
                200, player.getLocation().getZ()));
        block.setType(Material.OAK_SIGN);
        signBlock = block;

        Sign sign = (Sign) player.getWorld().getBlockState(signBlock.getLocation());
        sign.getSide(Side.FRONT).setLine(1, "^^^^");
        sign.getSide(Side.FRONT).setLine(2, "Enter how many");
        sign.getSide(Side.FRONT).setLine(3, "players per team");
        player.sendBlockChange(player.getLocation(), block.getBlockData());
        player.openSign(sign, Side.FRONT);```
#

This is my code

worthy moat
#

The SignGUI closes instantly

eternal oxide
#

are you doing anything after player.openSign ?

worthy moat
#

.nope

#

If the sign closes I retrieve a packet…And this packet gets retrieved after opening so I get kicked out

#

I think I spawn the wrong sign

#

There is an TitleEntitySign

#

Nvm

#

Hmm

#

I don’t know any further

worthy moat
#

How could I make a timer? I want that if enough Players are on the Lobb it should count down from 20 and then execute some stuff

#

Its for a Minigame

river oracle
worthy moat
#

How can I achieve this then?

river oracle
#

just listen to PlayerJoinEvent, PlayerLeaveEvent, though I suppose you'll need a timer for the countdown

worthy moat
#

yeah

river oracle
#

?scheduler

#

?schedule

#

fuck

#

I'l just pull it up

#

?jd-s

undone axleBOT
eternal oxide
#

ing

worthy moat
#

runTaskDelayed

chrome beacon
#

?scheduling

undone axleBOT
river oracle
#

why is it ing

worthy moat
#

But I want a countdown

river oracle
#

ye schedulers do that

river oracle
worthy moat
river oracle
#

I don't see the issue

#

run it every tick after 20 seconds worth of ticks cancel it

#

usually I wrap this into a nice easy to use class

worthy moat
#

You mean the repeating task as long as 20s and one delayed task running the code?

eternal oxide
#

You want a countdown so run it per second (20 ticks)

pseudo hazel
#

if you want to run something once you just use a delayed task

worthy moat
river oracle
remote swallow
#

so have a repeating runnable that sends them the message while counting to whatever

pseudo hazel
#

okay

remote swallow
#

then when it reaches it run ur code and cancel the task

pseudo hazel
#

then do that

river oracle
#

i find it easiest to just wrap this logic into a class tbh

pseudo hazel
#

same I have a CountdownTimer class

eternal oxide
#

if you are going to use it in a few places, create a task which accepts countdown(int) and a runnable

#

your task does the countdown adn then executes the runnable

worthy moat
remote swallow
#

yeah

worthy moat
#

How do I cancel such a task?

remote swallow
#

task.cancel

pseudo hazel
#

task.cancel

remote swallow
#

use the consumer method

eternal oxide
#

read the link

pseudo hazel
#

ur a consumer

river oracle
#

aren't we all consumers

worthy moat
#

ah yeah

#

just found it

#

Can I somehow store it somewherre else? Because if another player joins it would create another instance

#

xD

eternal oxide
#

you only start it when you hit the correct number of players

#

set a flag to show it's started

#

so you don;t start it again

worthy moat
#

ah ok so if the flag is for example RUNNING Countdown it wont start another instance

worthy moat
#

if I set the initial delay to 0 it instantly starts?

worthy moat
trim creek
#

Make a loop, and a few variables.
You need a variable for the countdown, and for the players.

In the loop, if the player's is minimum, then the loop should remove 1 from countdown each second, otherwise, just make the loop itself. If countdown is X, then do event you want.

worthy moat
trim creek
#

Good, then do the countdown loop.

#

Where if player's minimum is met, remove one from countdown each second

#

and if countdown is X, do what you need

worthy moat
#

I cant place an var in there because its a lambda

#
            if (!MiniGame.getInstance().isInitializing()) {
                if (p.getServer().getOnlinePlayers().size() >= MiniGame.getInstance().getChosenArena().getTeams().size()) {
                    MiniGame.getInstance().setInitializing(true);
                    MessageManager.sendMessage(Bukkit.getServer(), "<green>The game is starting in 20 seconds");
                    Bukkit.getScheduler().runTaskTimer(AlphaWars.getAPI(), bukkitTask -> {

                        if (p.getServer().getOnlinePlayers().size() < MiniGame.getInstance().getChosenArena().getTeams().size()) {
                            bukkitTask.cancel();
                            MiniGame.getInstance().setInitializing(false);
                            MessageManager.sendMessage(Bukkit.getServer(), "<red>Countdown stopped! <bold>Not enough players!");
                            return;
                        }

                        MessageManager.sendMessage(Bukkit.getServer(), "<green>The game is starting in 20 seconds");

                    }, 1, 20);
                }
            }```
mortal hare
#

so im trying to setup spock on my java gradle project

#

and for some reason gradle doesnt detect testLogging as a valid property

#

even though it reloads successfully

#

what's the problem here?

tender shard
#

it also claims it can't find it but that's normal lol

odd cobalt
#

please help:
craftPlayer.getHandle().connection.send(packet)

java.lang.NoSuchFieldError: connection

tender shard
#

you didn't remap your .jar

#

?nms

river oracle
#

you're not remapping

odd cobalt
#

im use gradle how to remap my jar

remote swallow
#

painfully

river oracle
#

unless you made a remap plugin yourself

#

or use paperweight

#

and if youre using paperweight you should probably ask paper

tender shard
#

spigot uses maven

#

you can ofc just manually run the specialsource-plugin .jar

#

https://www.spigotmc.org/threads/spigot-bungeecord-1-17-1-17-1.510208/#post-4184317

java -cp $HOME/.m2/repository/net/md-5/SpecialSource/1.10.0/SpecialSource-1.10.0-shaded.jar:$HOME/.m2/repository/org/spigotmc/spigot/1.17-R0.1-SNAPSHOT/spigot-1.17-R0.1-SNAPSHOT-remapped-mojang.jar \
net.md_5.specialsource.SpecialSource --live -i $PLUGIN.jar -o $PLUGIN-obf.jar -m $HOME/.m2/repository/org/spigotmc/minecraft-server/1.17-R0.1-SNAPSHOT/minecraft-server-1.17-R0.1-SNAPSHOT-maps-mojang.txt --reverse

java -cp $HOME/.m2/repository/net/md-5/SpecialSource/1.10.0/SpecialSource-1.10.0-shaded.jar:$HOME/.m2/repository/org/spigotmc/spigot/1.17-R0.1-SNAPSHOT/spigot-1.17-R0.1-SNAPSHOT-remapped-obf.jar net.md_5.specialsource.SpecialSource \
--live -i $PLUGIN-obf.jar -o $PLUGIN.jar -m $HOME/.m2/repository/org/spigotmc/minecraft-server/1.17-R0.1-SNAPSHOT/minecraft-server-1.17-R0.1-SNAPSHOT-maps-spigot.csrg
#

ofc you gotta adjust the version and change $PLUGIN to your .jar file's path

#

could just write a gradle task that runs those 2 commands

mortal hare
#

just add Test as a class name

#

it shows errors because it uses generics

#

to determine the type

tender shard
#

weird, it worked without that for me

mortal hare
#

it works without it

#

but this way is better since its more correct

#

basically it uses generics to provide methods

#

when you dont specify this, it would refer IDE to the generic type with a wildcard ? and it doesnt recognize all of those methods

#

im not an expert in groovy but i think that's what happens

tender shard
#

isn't 'test' the only task of type Test? i usually use withType

#

if I am forced to use gradle

mortal hare
mortal hare
#

so idk

tacit drift
#

🤡🤡👹👹👹👹

mortal hare
#

👏 port 👏 this 👏 to 👏 java 👏 please 👏

#

imagine authme

#

without all of those shenanigans of reducing walkspeed and cancelling move events

worldly ingot
#

I prefer to imagine AuthMe not existing at all

buoyant viper
#

true

tender shard
#

i never understood the purpose of authme

buoyant viper
#

offline mode expandssia

mortal hare
#

to play on cracked

worldly ingot
#

buit yes, camera command and it being registerable on the server would be cool

tender shard
#

imagine playing on a cracked server lol

#

/register asd asd

#

so useful

worldly ingot
#

Could open up the possibility of top-down game modes

sterile token
mortal hare
#

you're saying that because you can afford it

#

some people cant unfortunately

#

I have premium account also

#

but i think authme has a reasonable place in the plugin marketplace

worldly ingot
#

Just weird to me that cracked players spend more money on cracked servers than it would cost for a Minecraft account

#

but I digress. Not the point here

worldly ingot
mortal hare
#

same

#

cutscenes

#

custom gui scenes

worldly ingot
#

Potentially, yeah. Like I said, top-down games as well

sterile token
hazy parrot
#

what

sterile token
#

I remember also a dev explained me you can dictionary attack it too

tender shard
sterile token
#

Wait wait im really confused i thought you were talking about auhtme reload plugin

tender shard
#

we are talking about this weird /register asd asd and /login asd plugin

sterile token
#

oh right i wasnt wrong

#

I was told that authme reload has many vulnerability issues related to password, you can brute force them and also attack them by dictionary

hazy parrot
#

isn't bruteforce and dictionary attack same thing

tender shard
#

dictionary tries normal words, bruteforce can either mean "trying out a lot of stuff" or really just "starting at a and ending at zzzzzzzzzzzzz"

hazy parrot
#

never saw anyone do bruteforce without predefined list of "possible passwords"

#

starting at a and ending at zzzzzzzzzzzzz seems really long and inefficient lol

tender shard
#

It does work offline for short passwords eg /etc/shadow

worthy moat
# tender shard works fine for me

Ive got a JoinListener running and everytime someone joins he gets teleported to the Location I want....BUT! If someone new joins, the person spawns exactly where the worldSpawn is set...How can I override that without doing that manually with a command?

tender shard
#

how do you teleport them?

#

just by calling teleport in the event?

worthy moat
#

Yes

umbral ridge
#

Why does right click on PlayerInteractEvent fire twice again?

undone axleBOT
#

The PlayerInteractEvent may be called once per hand. If you only want code to be executed once, you can check the result of https://hub.spigotmc.org/javadocs/spigot/org/bukkit/event/player/PlayerInteractEvent.html#getHand(), then decide functionality.

For example, only executing code if the main hand was used:

@EventHandler
public void onPlayerInteract(PlayerInteractEvent event) {
    if (event.getHand() != EquipmentSlot.HAND) { // * if the hand used is NOT the main hand:
        return; // do not progress past this point  |
    }
    // provide functionality
}
umbral ridge
#

Clicking with an axe

white root
#

How expensive is checking permissions via vault?
Do I need to worry about caching permissions and not checking them too often?

tender shard
#

don't worry about it

rare rover
#

Anyone got any good tutorials on Function, and Predicate? I'm wanting to expand my knowledge with it. I've seen them in many API's on github and noticed they could be quite useful for me

hazy parrot
#

What exactly are you struggling with

#

Function is just generic function where you can decide both argument and return type

#

And predicate is basically same, but it's defined that it must return boolean

#

As its used for filters

#

Just part of java functional interfaces, which are usually used to pass some kind of functions to method arguments

#

That is called higher order functions ^

rare rover
rare rover
hazy parrot
#

There are much more functional interfaces you can explore, probably most commonly used others are Runnable and Consumer

#

And it's common for all func interfaces that they only have one non-default method

rare rover
#

Ah, yeah ik how to use Runnable, Consumers, and Suppliers

buoyant viper
#

just wait until u hear about BiConsumers and BiFunctions expandssia

hazy parrot
#

Bibibibifunction

buoyant viper
#

but no BiSupplier 😔

hazy parrot
#

Well that would make no sense, as supplier have no args 😛

buoyant viper
#

dont need em

#

just raw Power and Will

hazy parrot
#

🫡

buoyant viper
#

like a month or 2 ago i was actually talking abt BiSupplier

#

not realizing just why they didnt exist

rare rover
#

Seems wonderful

buoyant viper
#

the BiSupplier would have to have just been a Supplier<Object[]> lol

hazy parrot
young knoll
buoyant viper
#

true

rare rover
#

So what's the upside to them? Like why should I use them?

#

If you've already answered that srry lol

hazy parrot
#

If you need to pass function somehow or somewhere

#

And depends on what that function have to do, you will chose corresponding functional interface

rare rover
#

Where the TriFunction at 🙄😭

#

Love to see it lol

young knoll
#

You can always make one

#

:p

rare rover
#

True thay

#

That*

rare rover
#

ohhh i see

#
public class Main {

    public static void main(String[] args) {
        int testing = testing(1, integer -> integer * 2);
        Predicate<Integer> check = check(testing);
        if (check.test(2)) {
            System.out.println("Test passed");
        } else {
            System.out.println("Test failed");
        }
    }

    public static int testing(int apply, Function<Integer, Integer> function) {
        return function.apply(apply);
    }

    public static Predicate<Integer> check(int test) {
        return integer -> integer == test;
    }
}``` kinda like this?
worldly ingot
#

Sure but you can forego the check() method and in-line your predicate

#

Predicate<Integer> check = (integer) -> integer == test; will work fine

#

Or, well, I suppose the better way to go about that would be to turn your method into a predicate target

#

Oh, nevermind. I see why you put it in a method lol

rare rover
#

i still don't fully get the reason why people use this?

#

Predicate atleast

#

i get why Function

worldly ingot
#

Take Collection#removeIf() for example which takes in a Predicate<T> (where T is the element in the collection)

#

That allows you to pass in some arbitrary condition which will remove any values that match the predicate

young knoll
#

Yeah lambda stuff is pretty cool

#

I find myself using consumer the most

rare rover
#

oh i see

#

so i could do

#
        int testing = testing(1, integer -> {
            if (integer == 1) {
                return 2;
            } else {
                return 3;
            }
        });``` bad example but
worldly ingot
#

It's when you want to pass on decision making to the caller rather than having to implement very specific methods and limiting your API

rare rover
#

so literally lambda lol

#

i see why people use this now

#

😆

worldly ingot
#

A lambda is just syntax sugar for implementing an interface with a single method

rare rover
#

ah

#
default boolean removeIf(Predicate<? super E> filter) {```
#

ahhh

#

i can see why this is useful

young knoll
#

Now you get to learn default methods :p

rare rover
#

this explains it somewhat

rare rover
#

its like public in a class

#

but in an interface

worldly ingot
#

Not necessarily

rare rover
#

basically

#

instead of using static boolean removeIf

rare rover
worldly ingot
#

default is just a default implementation. They introduced it in Java 8 so they could add methods like removeIf() and forEach() without breaking API that implemented the Collection interfaces

rare rover
#

ahh

worldly ingot
#

Before then interfaces didn't provide any implementation whatsoever. It was all up to implementing classes. Now they can provide default behaviour and implementations can override it if they'd like

young knoll
#

And now interfaces are just glorified abstract classes

#

||/s||

worldly ingot
rare rover
#

hmm

#

so

#

somewhat like this?

public class Main {

    public static void main(String[] args) {
        List<Integer> ints = List.of(1, 2, 3, 4, 5);
        check(ints, integer -> integer > 0);
    }

    public static void check(Iterable<Integer> iterable, Predicate<? super Integer> predicate) {
        iterable.forEach(integer -> {
            if (predicate.test(integer)) {
                System.out.println("Test passed");
            } else {
                System.out.println("Test failed");
            }
        });

    }
}```
#

i could do Integer

#

in the Predicate

#

but

#

instead of ? super integer

#

makes me feel special doing that

#

🤣

#

just for testing purposes i wont do this in my actual API

#

obviously

worldly ingot
#

Yeah that looks right. Though as a note, there is an IntPredicate which accepts a primitive int instead of a wrapped Integer which will avoid boxing

#
public class Main {

    public static void main(String[] args) {
        List<Integer> ints = List.of(1, 2, 3, 4, 5);
        check(ints, value -> value > 0);
    }

    public static void check(Iterable<Integer> iterable, IntPredicate predicate) {
        iterable.forEach(integer -> {
            if (predicate.test(integer)) {
                System.out.println("Test passed");
            } else {
                System.out.println("Test failed");
            }
        });

    }
}```
#

Same thing just a different type

#

A lot of the stdlib functional interfaces have primitive sister types

blazing flare
#

How would I serialize an ItemStack, but to json? I got that itemStack.serialize() returns a Map<String, Object> but I'm then trying to use GSON to serialize that. Initially, it appears to work, until I go to serialize what was deserialized and then it chokes due to java.util.Optional#value, wherever that came from I have no clue but it likely didn't deserialize correctly.

worldly ingot
#

Serializing to JSON isn't really something we expose in Bukkit because it's subject to changing and isn't very version-independent. Bukkit tries to retain version compatibility

#

The best way to serialize an ItemStack is probably via the BukkitObjectInput/OutputStreams, which isn't JSON, but it's a byte stream representation of the Map

rare rover
#

okay so i changed it to:

public class Main {

    public static void main(String[] args) {
        Testing<Integer> testing = new Testing<>();
        testing.check(List.of(1, 2, 3, 4, 5), integer -> integer > 0);
    }

    public static class Testing<K extends Integer> {

        public void check(Iterable<K> iterable, Predicate<K> predicate) {
            iterable.forEach(integer -> {
                if (predicate.test(integer)) {
                    System.out.println("Test passed");
                } else {
                    System.out.println("Test failed");
                }
            });

        }
    }
}``` at least im somewhat getting the hang of this
worldly ingot
#

Here you actually don't need the class. You can generify the method itself