#help-development

1 messages · Page 2116 of 1

sacred mountain
#

i have a hashmap <UUID, Integer> how would i update and order a leaderboard?

#

like sort the hashmap based on the highest int in the hashmapa

#

idk if theres a simple way

tardy delta
#

i would use a LinkedHashMap

#

thats sorted right

sacred mountain
#

ok

sacred mountain
#

stores a player uuid and a score

grim ice
#

oh wait nvm

sacred mountain
#

i just want to create a method that returns their rank

grim ice
#

i mean why not use a short

#

cuz will u need over 32k for that

sacred mountain
#

well ok but

tardy delta
#

32k?

sacred mountain
#

idk what 32k means

grim ice
#

32700

sacred mountain
#

of what tho

grim ice
#

Short.MAX_VALUE

#

Im saying

#

u can use

sacred mountain
#

yeah the points go higher

grim ice
#

UUID, Short

#

o

#

ok

sacred mountain
#

than the short max value

#

because there are like boss fights that give a lot

#

so basically i want to have a map of some type that stores their scores, and i want to create a method that returns the player's rank/place in the map

#

so bascialyl their position on the leaderboard

#

so if i did getPlayerRank(player.getUniqueID()) it would return something like 5 (th place)

tardy delta
sacred mountain
#

thx

tardy delta
#

anyways how can i check for the equivalent of obj instanceof SomeClass but i only have a class object?

tardy delta
#

no i only got a Class<?>

sacred mountain
tardy delta
#

and an object

#

so i guess obj.getClass().isAssingableFrom(clazz)?

grim ice
#

isInstance

#

clazz.isAssignableFrom() or clazz.isInstance()

golden kelp
sacred mountain
tardy delta
#

enum cannot be generic sighs

golden kelp
sacred mountain
#

is just dk

golden kelp
#

Off topic, which theme is that, i love it

sacred mountain
#

dracula

#

but yeah i ened help

#

i just used the stack overflow method which seems to work when i tested it, so

golden kelp
#

Great

sacred mountain
#

well its sorted but i dont know how to find their rank

#

in a sortedset

#

ive never used a set lmao

grim ice
#

You have a set of what

golden kelp
sacred mountain
grim ice
#

what

tardy delta
#

what kind of exception should i throw when the user forgot to do something?

grim ice
#

a set cant have 2 generics

sacred mountain
#

mapentry

#

SortedSet<Map.Entry<UUID, Integer>> sortedSet = entriesSortedByValues(map);

golden kelp
#

Oh

sacred mountain
#

and the map is just a generic map

grim ice
#

oh

sacred mountain
#

the unsorted score points map

grim ice
#

cant you just

#

have a hashmap

#

UUID, Integer

#

I dont see why you need to sort the map

sacred mountain
#

to find the player's ranking

#

like a leaderboard

golden kelp
#

^

grim ice
sacred mountain
grim ice
#

u dont need to sort the hashmap for that

#

??

sacred mountain
#

oh

#

lmao

#

how would i do it

grim ice
#

leaderboard.get(uuid) will return their rank

sacred mountain
#

????

grim ice
#

with a simple HashMap<UUID, Integer>

sacred mountain
#

that will return their score

#

not their rank

grim ice
#

Bruh

#

So you have a hashmap of scores

sacred mountain
#

yes.

#

i need to find out who has the highest, second highest etc

#

and return an integer as their rank

grim ice
#

then I guess make a RankedPlayer class, that contains a player ranking and their score

#

and their uuid

#

and make a Set of it

#

it might be kinda costy to performance tho

#

cuz u gotta loop through it to get the player u want

#

u will have to do

#

rankedPlayers.stream().filter(rankedPlayer -> rankedPlayer.getRanking() == 1).findAny();

#

to get the first ranker

#

You wouldnt need that

tardy delta
#

use iterator

#

concurrent is slow

upper mica
#

Hello, does NMS from 1.17 not use versions in packages names?

quaint mantle
#

can someone help me use mineresetlite on aternos please its not working

tardy delta
prime kraken
#

Hello, a little question, how do I verify an Inventory name in an event ? I use this for my code Inventory inv = e.getInventory() and normally when I search for an inventory name i use inv.getName().equalsIgnoreCase("") but here in spigot 1.17.1 I have nothing

eternal oxide
#

e.getView().getName()

prime kraken
#

Thanks a lot

midnight shore
#

Hi! does the itemmeta displayname support ChatColor colors?

#

thank yoy

#

also the lore?

crimson scarab
#

how do i cancel a bukkit runnable whenever i try i get all kind of errors

#
    @EventHandler
    public void onSnowballThrow(ProjectileLaunchEvent event) {
        if (event.getEntity() instanceof Snowball) {
            Plugin plugin = getServer().getPluginManager().getPlugin("CoolGear");
            ArmorStand armorStand = event.getEntity().getWorld().spawn(event.getEntity().getLocation(), ArmorStand.class);
            armorStand.setGravity(false);
            BukkitScheduler scheduler = getServer().getScheduler();

            scheduler.scheduleSyncRepeatingTask(plugin, new Runnable() {
                @Override
                public void run() {
                    if (!event.getEntity().isDead()) {
                        armorStand.teleport(event.getEntity().getLocation());
                    }
                }
            }, 20L, 5L);
        }
    }
eternal night
#

as that returns you a BukkitTask

tardy delta
#

^^

eternal night
#

which you can use to bukkitTask.cancel()

tardy delta
#

and use a lambda expression

#

like

scheduler.runTAskTimer(plugin, task -> {
  // do your repeating stuff here
  if (condition) task.cancel()
}, 20L, 5L);```
eternal night
#

tho that method does not return you a bukkit task Sadge

tardy delta
#

you can cancel it from within the lambda 😌

eternal night
#

depends on whether or not you want to cancel from inside or outside

#

yee

tardy delta
#

hmmye

#

or just set a boolean whether to cancel or not

#

not really elegant smh

crimson scarab
#

should it look like this?

            BukkitTask task = scheduler.runTaskTimer(plugin, new Runnable() {
                @Override
                public void run() {
                    if (!event.getEntity().isDead()) {
                        armorStand.teleport(event.getEntity().getLocation());
                    }
                }
            }, 20L, 5L);
tardy delta
#

ye ah i dont see the cancel thing

eternal night
#

Well, for you fourteen's version is probably a lot better

tardy delta
#

i guess many people dont know what lambda expressions are

eternal night
#

because you want to cancel if the entity is dead I presume

crimson scarab
#

yep

tardy delta
#

or the compiler isnt saying it 🥺

crimson scarab
#

whenever i try to cancel it says task is not initalized

eternal night
#

Well use the layout fourteen proposed (I hope I can call you fourteen?)

tardy delta
#

ye lol

#

😂

crimson scarab
#

i think i got it working

#

yep! thanks

#

this is probably a stupid question but can a scheduler be faster than 0 delay 0 period

tardy delta
#

can a consolesender have permissions? i saw it implements Permissible

#

wdym faster

#

faster than a tick?

crimson scarab
#

well i am making a armor stand follow a snowball but it is always a bit behind

eternal night
#

the client interpolates the movement of a snowball

#

you'll never be able to keep up with it 100% using a packet based approach

#

only way to really get that going is to make the armor stand a passanger of the snowball

#

tho that has its own issues

crimson scarab
#

such as?

eternal night
#

well the armorstand is now riding the snowball

#

e.g. it is above the snowball

tardy delta
#

lets ride the snowball

#

am i flying

solid jungle
#
        slot10.setClickHandler((player, info) -> {
            player.sendMessage("You Received Server Rank 1 For JuvyMC");
        });
```how can i make it add a rank to the player once they click on the slot
eternal night
#

I mean, setClickHandler is not spigot. ranks are also not spigot

#

what plugin are you using for ranks

eternal night
#

I mean, then you just need to call the API of the plugin you use for ranks

solid jungle
#

👍 ah k thanks for the help

tardy delta
fallen sandal
#

hey how to get the tps? i tried this but its not working getServer().spigot().getTPS()

flint coyote
#

double[] tps = MinecraftServer.getServer().recentTps;

#

it's deprecated but that's how spigot retrieves them aswell

grand perch
#

Why is it deprecated

eternal night
#

ask mojang basically

flint coyote
#

🤷‍♂️

grand perch
#

I think mojang should join this discord server

#

And answer my question

grand perch
flint coyote
#

1m 5m 15m

grand perch
#

What

flint coyote
#

minutes

#

average tps in the last x minutes

#

or something along those lines. Not 100% sure

#
package org.spigotmc;

import net.minecraft.server.MinecraftServer;
import org.bukkit.ChatColor;
import org.bukkit.command.Command;
import org.bukkit.command.CommandSender;

public class TicksPerSecondCommand extends Command
{

    public TicksPerSecondCommand(String name)
    {
        super( name );
        this.description = "Gets the current ticks per second for the server";
        this.usageMessage = "/tps";
        this.setPermission( "bukkit.command.tps" );
    }

    @Override
    public boolean execute(CommandSender sender, String currentAlias, String[] args)
    {
        if ( !testPermission( sender ) )
        {
            return true;
        }

        StringBuilder sb = new StringBuilder( ChatColor.GOLD + "TPS from last 1m, 5m, 15m: " );
        for ( double tps : MinecraftServer.getServer().recentTps )
        {
            sb.append( format( tps ) );
            sb.append( ", " );
        }
        sender.sendMessage( sb.substring( 0, sb.length() - 2 ) );
        sender.sendMessage(ChatColor.GOLD + "Current Memory Usage: " + ChatColor.GREEN + ((Runtime.getRuntime().totalMemory() - Runtime.getRuntime().freeMemory()) / (1024 * 1024)) + "/" + (Runtime.getRuntime().totalMemory() / (1024 * 1024)) + " mb (Max: "
                + (Runtime.getRuntime().maxMemory() / (1024 * 1024)) + " mb)");

        return true;
    }

    private String format(double tps)
    {
        return ( ( tps > 18.0 ) ? ChatColor.GREEN : ( tps > 16.0 ) ? ChatColor.YELLOW : ChatColor.RED ).toString()
                + ( ( tps > 20.0 ) ? "*" : "" ) + Math.min( Math.round( tps * 100.0 ) / 100.0, 20.0 );
    }
}

This is spigots /tps command and they also state "TPS from last 1m, 5m, 15m"

grim ice
#

Im pretty sure most people know it

grim ice
#

are you using allman style

#

im crying

flint coyote
#

huh?

grim ice
#

public static void main(String[] args)
{
}

#

thats Allman Style

flint coyote
#

that's not my code

#

that's from spigot

grim ice
#

public static void main(String[] args) {
}
thats K&R

flint coyote
#

when you use the build tools this is what gets compiled into your spigot.jar

flint coyote
grim ice
#

K&R is Kernighan and Ritchie btw

crimson scarab
#

how to send a packet to a player?

flint coyote
# grim ice o

Spigot\Spigot-Server\src\main\java\org\spigotmc\TicksPerSecondCommand.java
You can find the class under this path if you wanna take a look yourself :)

carmine mica
#

Would Player.setInvisible prevent mobs from noticing the player?

grim ice
broken knot
#

Is it possible to create custom resources and commands that can be used in datapacks?

prime kraken
#

Did you know is its possible to show the number of player in an arrayList on a item ? Like I have a GUI, with a red wool item in, when i click, this item put me in the red team and close the GUI, but if the arraylist is full, it says you cann't join blablabla and i just want for the player to see how many people are in the red team ?

sterile token
fallen sandal
flint coyote
#

Of course you still can. It's deprecated but still works

solid cargo
#

how is a furnace minecart named in the api?

fallen sandal
#

tho

flint coyote
#

I have it in one of my 1.18.2 plugins

#

what's not working?

fallen sandal
#

wait a min

#

ah i cant send images here

flint coyote
#

is it that you can't find MinecraftServer?

fallen sandal
#

i had added this in maven

#
            <groupId>org.spigotmc</groupId>
            <artifactId>minecraft-server</artifactId>
            <version>1.18.1-R0.1-SNAPSHOT</version>
        </dependency>```
#

now the MinecraftServer fixed but

#

Cannot resolve method 'getServer' in 'MinecraftServer'

#

this error coming

sterile token
#

If have better ideas tell him/her

flint coyote
#
            <groupId>org.spigotmc</groupId>
            <artifactId>spigot</artifactId>
            <version>1.18.1-R0.1-SNAPSHOT</version>
            <scope>provided</scope>
        </dependency>```
I import it like this and I got the class.
(artifactId is spigot and not spigot-api)
#

with spigot-api it won't work

fallen sandal
#

okay

#

so

#

im importing like this

#
            <groupId>org.spigotmc</groupId>
            <artifactId>spigot-api</artifactId>
            <version>1.18.1-R0.1-SNAPSHOT</version>
            <scope>provided</scope>
        </dependency>```
flint coyote
#

remove the -api in artifactId

fallen sandal
#

lol same

#

oo

#

mm

#

i tried this some times ago.. but it was saying

#

Could not find artifact org.spigotmc:spigot:jar:remapped-mojang:1.18.2-R0.1-SNAPSHOT in spigotmc-repo (https://hub.spigotmc.org/nexus/content/repositories/snapshots/)

#

wth

#

now its worked

crimson scarab
#

how can i make a snowball invisible

solid jungle
#

Im wondering how i can make a custom rank system for a server

#

can anybody tell me how to do it?

sterile grotto
solid jungle
sterile grotto
#

my pleasure 🙂

solid jungle
sterile grotto
#

That you should check on the older version of this api

solid jungle
#

👍

solar sable
#

does anybody know any youtube video that can help about making custom icon textures?

fallen sandal
#

when i start the plugin

sterile grotto
fallen sandal
#

its saying java.lang.NoSuchFieldException: recentTps

#

?

solar sable
#

i want to make special rank icons but I'm not familiar with texture packs and i cant seem to find any video explaining it

solar sable
sterile grotto
#

ok

fallen sandal
#

oh sorry my fault

crimson scarab
#

this is a bit of a maths problem but how would i make a spawned armorstand always face away from the player

solar sable
#

if you're a mod it will show like a green cube with "Mod" on it

worldly ingot
#
Location armourStandLocation = armourstand.getLocation();

Vector playerPosition = player.getLocation().toVector();
Vector armourStandPosition = armourStandLocation.toVector();
Vector result = armourStandPosition.subtract(playerPosition);

armourStandLocation.setDirection(result);
armourStand.teleport(armourStandLocation);
arctic moth
#

how do i make fake player npcs

#

should i use the nms way or is there a better way

sterile grotto
#

I am trying to use NMS to develop a new API, but as I follow the tutorial doing this remapping thing, after using Maven package command to build my JAR, I get four different JAR and only two of them can work on my test server, so can somebody tell me why

arctic moth
#

did u use the Lifecycle package command?

sterile grotto
sterile grotto
#

remapped one can work well

arctic moth
#

but u said 2 didnt work

carmine mica
#

Hi, I made a command but it doesn't work, no console errors etc. it just won't do anything

sterile grotto
carmine mica
#

Yes

#

the weird part about it is (I have 2 commands), when I comment out the line for the 'broken' command the other one works, when I try to register both, none of them work

sterile grotto
#

have you checked your configurations in the plugin.yml?

carmine mica
#

yes, both commands appear ingame but none of them works if I register both commands. wanna see my plugin.yml?

carmine mica
#

This is how I do my commands in my plugin.yml (the other stuff above such as name, description version etc works fine)

#

Theres gotta be something wrong with the afk command

#

But I cant see anything wrong

sterile grotto
#

try to remove it and run the test

carmine mica
#

I almost copied my vanish command 1:1 because they almost work the same

#

If I comment both of those lines, the other stuff works fine, If I leave them like this, nothing works

#

Doubt it will change anything, ingame it still says /afk

sterile grotto
carmine mica
#

Yes

#

It didn't work

sterile grotto
#

it can show on the server and when you run it, it has no responding?

carmine mica
#

Yes

#

No errors, nothing logged in the console or anything

#

just no response

sterile grotto
#

have you check your code in AfkCommand.class?

carmine mica
#

I think i might found something

#

nvm

quiet ice
#

Where do you register it?

carmine mica
quiet ice
#

Also did you remember to register the command in the plugin.yml?

carmine mica
quiet ice
#

What is the constructor of AfkManager and AfkCommand? Also, in what way does nothing work? Is there a deadlock or do the commands simply not show up?

carmine mica
#

If I try to use the commands, it just gives no response, it should send something into the chat but doesn't

#

Kinda missed up that order in the screenshot

#

Oh and I have this in my onEnable method

quiet ice
#

Does it also not work if you only set the afkManager?

carmine mica
#

Still doesn't work then, yes

#

the vanish thing only works if I comment both lines for the afk thing in my onenable

quiet ice
#

So both lines cause issues? In that case I'd like to see the constructor of both AfkManager and VanishManager

quiet ice
#

So lombok?

carmine mica
#

what

quiet ice
#

Okay, then you are not using that. What is the constructor?

#

Because you must have defined one

#

otherwise it would not compile

carmine mica
#

What do you mean, what is the constructor?

quiet ice
#

Somehwere in your code you will have

class AfkManager {
 /* ... */
 AfkManager(Plugin pl) {
  /* ... */
  }
sterile grotto
#

like this one

quiet ice
#

Yeah

arctic moth
#

how do you import/use nms

quiet ice
#

For which version?

sterile grotto
carmine mica
arctic moth
#

ive tried this

<dependency>
            <groupId>org.spigotmc</groupId>
            <artifactId>spigot</artifactId>
            <version>1.18-R0.1-SNAPSHOT</version>
            <scope>provided</scope>
        </dependency>
sterile grotto
#

add this one in your pom.xml

carmine mica
arctic moth
#

but it doesnt work

crimson scarab
#

can armorstands be upside down?

arctic moth
sterile grotto
#

check on this post

#

NMS been changed since 1.17

quaint mantle
carmine mica
arctic moth
crimson scarab
#

more so how would i change the pitch as rn changing pitch does nothing

quiet ice
arctic moth
#

like i have buildtools

carmine mica
#

Yeah, it's weird for me too, because this is an almost exact copy of my vanishmanager

quiet ice
#

And what is the afk command class (in fully if possible)

sterile grotto
quiet ice
#

I think you might depend on the vanish manager in your afk command class constructor, which would explain the failure

arctic moth
#

it gives me this error

quiet ice
#

there we have it

carmine mica
#

Hm?

sterile grotto
arctic moth
quiet ice
#

private String PlayerName = player.getDisplayName() will always throw an NullPointerException

#

As player is initialised as null

carmine mica
#

ah

#

okay

#

lemme try somethign else

quiet ice
#

It is a bit strange that IntelliJ isn't pedantric enough to spot the issue

carmine mica
#

this should be better

sterile grotto
quiet ice
#

Eclipse sure as hell wouldn't allow it

arctic moth
#

do i just add them the old way?

quiet ice
arctic moth
carmine mica
quiet ice
#

You need to remove your field too

carmine mica
quiet ice
#

both fields are pretty much useless from what I see

#

So both can get removed

#

Oh you already removed it

#

Yeah this makes it strange

arctic moth
#

do i just add it to the project or smth

#

the craftbukkit

carmine mica
#

I get errors now

#

atleast that

sterile grotto
carmine mica
#

ah nvm

quiet ice
#

there is no reason it should not work but cursed installation it is ¯_(ツ)_/¯

arctic moth
#

lol

#

it worked

#

nvm

sterile grotto
#

maven sometimes break

arctic moth
#

what if i just

#

put the craftbukkit folder in my project

sterile grotto
arctic moth
#

i literally just set this project up 10 mins ago lol

sterile grotto
#

actually, I've once met this problem, but after a few attempt it just worked

arctic moth
#

few attempts at what

#

whatd you do

sterile grotto
#

rebuild pom.xml

sterile grotto
carmine mica
#

@quiet ice turns out I still had this private Player player; private String PlayerName = ... in my afkamanger class at the almost very bottom

quiet ice
#

Ah

sterile grotto
arctic moth
#

the batch is the same but i can type the version

sterile grotto
#

I don't know much about batch, I built it with jar

arctic moth
#

the batch just downloads the jar and runs it

#

i noticed my intellij is super outdated, so ima update it and see if it fixes

#

why is it taking so long

#

it worked lol

sterile grotto
#

that was pretty magical

arctic moth
#

yep

#

thats a lesson kids; update your ide

sterile grotto
#

then you need to add <classifier>remapped-mojang</classifier> below the <groupId>org.spigotmc</groupId> <artifactId>spigot</artifactId> <version>1.18.1-R0.1-SNAPSHOT</version>

arctic moth
#

why

#

now it says unresolved dependency

#

whenever i add the classifier

sterile grotto
#

in the <dependency> part

#

<dependency> <groupId>org.spigotmc</groupId> <artifactId>spigot</artifactId> <version>1.18.1-R0.1-SNAPSHOT</version> <classifier>remapped-mojang</classifier> </dependency>

arctic moth
#

ik

sterile grotto
#

but if you still can't solve the previous problem, adding this may won't change anything

quiet ice
#

In C/C++ world you should never update your IDE

#

unless it is broken beyond repair

sterile grotto
# arctic moth ik

you may check your .m2\repository\org\spigotmc\spigot folder to make sure the libs were properly installed

short raptor
#

Why would this code produce this output?

#

UsersScore.getScore() should be an int, no?

#

NEVERMIND

#

I DIDNT PUT THE NEW VERSION ON THE SERVER

#

I spent 30 fucking minutes searching on google for a solution omg

sterile grotto
#

lol

glass mauve
#

is there a method for ProjectileHitEvent, so I can get the item that shot the projectile

earnest forum
#

well

#

you could listen to the projectile shoot event

#

and then store the projectile somewhere with all the info u need

#

and then on projectile hit you could check if it's that same projectile

glass mauve
#

yea that was my idea, just wanted to know if there is a easier way

grim ice
#

if its not an arrow then its the projectile itself

#

if an arrow then a bow

earnest forum
#

what if they want custom bows?

grim ice
#

o

earnest forum
#

with special abilities?

glass mauve
#

yea I have a custom bow

golden kelp
#

idk

brittle lily
#

Guys Can You Help Me

carmine mica
#

Is there an event for when the player moves? (jumping, walking, sprinting, flying etc)

earnest forum
#

playermoveevent

carmine mica
#

ahh

#

thanks

earnest forum
#

this also fires for looking

#

with mouse

carmine mica
#

like looking around?

earnest forum
#

yes

carmine mica
#

yeah should be fine to cancel afk status

earnest forum
#

if you only wanna listen to movement and not look

#

just check if the getTo is the same as getFrom

crimson scarab
#

what does it mean [ProtocolLib] Loaded class me.tapwatero.coolgear.CoolGear from CoolGear v1.0-SNAPSHOT which is not a depend or softdepend of this plugin.

golden kelp
carmine mica
earnest forum
golden kelp
#
msg:
  description: example
  usage: /<command>
r:
  description: example
  usage: /<command>

@brittle lily

sterile grotto
earnest forum
#

those are completely optional

golden kelp
#

oh

#

then?

#

Show complete plugin.yml

earnest forum
#

is this in the JavaPlugin?

#

that's not the issue

golden kelp
#

oo i get it now

earnest forum
#

it's the getCommand method

shell linden
#

Is there any way to monitor the player putting some items into the container?

earnest forum
#

you could store information about each player and what they put

#

or look at inventory click event

#

and store some information in the plugin

carmine mica
shell linden
#

i try

grim ice
#

if people think of cigarettes as fat 90 old men dicks no one will smoke anymore

earnest forum
golden kelp
earnest forum
#

show us your full plugin.yml and where you are registering executors

sterile grotto
carmine mica
#

Yeah, I got kinda used to doing that because I used C++ for a time

crimson scarab
#

how can i send a packet to the player?

golden kelp
#

nms?

sterile grotto
crimson scarab
#

i've tried but i keep getting erors

#
            PacketPlayOutEntityDestroy packet = new PacketPlayOutEntityDestroy(event.getEntity().getEntityId());
            CraftPlayer craftPlayer = (CraftPlayer) player;
            PlayerConnection playerConnection = ((CraftPlayer) player).getHandle().b;
            playerConnection.a(packet);
#

its really a pain because of the obfuscation

glass mauve
#

btw is this correct?

sterile grotto
crimson scarab
#

spigot i think

sterile grotto
#

mojang remapping maybe better

sterile grotto
tardy delta
prime kraken
#

Hey, weird question but i use an egg as a projectile for a weapon and I want to cancel the spawn of baby KFC chicken, do you know how to do that ?

tardy delta
#

cancel the EntitySpawnEvent or smth

sacred mountain
#

hey fourteen do you know how to do the ranking thing i was talking about tearlier

echo basalt
#

^

tardy delta
#

what was i'm on when i wrote my code a few hours ago lol

tardy delta
sacred mountain
#

no clue how to do that

carmine mica
#

(event is the variable for the PlayerMovement)

tardy delta
#

search for java comparator in google

#

and look how a treeset works

tardy delta
sacred mountain
#
            @Override
            public int compare(Map.Entry<UUID, Integer> o1, Map.Entry<UUID, Integer> o2) {
                return o2.getValue().compareTo(o1.getValue());
            }
        });```
tardy delta
#

a TreeSet provided with a Comparator will insert your element in the right position (so the set will always be sorted)

sacred mountain
#

oh ok

crisp steeple
#

Have no idea what its being caused by as my plugin is java 1.8 and so is maven compiler version

tardy delta
#

what mc version?

crisp steeple
#

1.8

brave sparrow
#

It’s compiling it for Java 9

brave sparrow
#

You have to set the Pom to compile it as Java 8

crisp steeple
brave sparrow
#

Let’s see

crisp steeple
brave sparrow
#

1.8

#

Not 8

tardy delta
#

wont both work?

#

i thought so

crisp steeple
#

im pretty sure they do

#

i havent done anything to the pom

tardy delta
#

i have mine as 8 too

crisp steeple
#

plugin was working just fine a bit ago

brave sparrow
#

¯_(ツ)_/¯

sterile grotto
brave sparrow
#

What IDE

#

yeah

crisp steeple
brave sparrow
#

I assume you’re compiling it with mvn install?

crisp steeple
#

i believe so

brave sparrow
#

Spooky

tardy delta
#

👻

crisp steeple
#

just weird since i havent changed anything to the project structure

brave sparrow
#

Could always try the old delete the project and re-configure it

crisp steeple
#

idk if thats a good idea

#

its set up on a pretty complex git structure that i dont even fully understand

sterile grotto
crisp steeple
#

yea its 1.8

urban kernel
brave sparrow
crisp steeple
tardy delta
#

i did too much rust but do java switches use commas?

#

i forgot lol

#

looks like they dont

tardy delta
#

on java16

#

Bukkit.getServer().getVersion() i guess

urban kernel
#

i'll give it a try, cheers

sterile grotto
kindred valley
#
if (p.hasPermission("Polis")) {
            for (String i : PersonConfig.get().getKeys(false)) {
                for (String o : PersonConfig.get().getConfigurationSection(i + ".playerdata").getKeys(false)) {
                    if(PersonConfig.get().getInt(i + ".playerdata." + o) == Integer.parseInt(strings[0])){
                        ChatColor darkBlue = ChatColor.DARK_BLUE;
                        p.sendMessage(ChatColor.AQUA + String.valueOf(darkBlue) + "[" + ChatColor.AQUA + "POLIS OFISI -->>" + darkBlue + "]: " + ChatColor.AQUA + " BOYLE BIR KIMLIK BULUNMAKTADIR..." + ChatColor.GREEN + " (+)");
                    }else {
                        ChatColor darkBlue = ChatColor.DARK_BLUE;
                        p.sendMessage(ChatColor.AQUA + String.valueOf(darkBlue) + "[" + ChatColor.AQUA + "POLIS OFISI -->>" + darkBlue + "]: " + ChatColor.AQUA + " BOYLE BIR KIMLIK BULUNMAMAKTADIR..." + ChatColor.RED + " (-)");
                    }
                }
            }
        }
```the else statements repeats for 2 times what can be the reason
prime kraken
#

Ok so I'm back again with my problems x), I have mad succesfully the lore on made item to show the number of "Player" in my arrayList but now, I'm stuck at the point where i hade to set a limit of people who join my arrayList and when the limit is reach, a message is send to the player

tardy delta
#

well uhh does it makes sense to check permissions for the console?

echo basalt
#

no

#

it will always return true

sacred mountain
tardy delta
#

it does implement Permissible

crisp steeple
#

looking at it in a decompiler, the only module in module-info is gson
would make sense if this was causing it since i just now added it, but im think gson is 1.8

tardy delta
#

just to be sure

prime kraken
tardy delta
#

lol i thought that was js

sacred mountain
#

i still cant figure out how to sort and get a position in a treemap or whatever map

echo basalt
#

I mean

tardy delta
#

i would create the playerranking first

echo basalt
#

checking for permissions might return false

#

but it is hardcoded to be op'ed

tardy delta
#

ty

echo basalt
#

nvm if it's op, it returns true

sacred mountain
sterile grotto
sacred mountain
#

make a player ranking class

#

what should it do

echo basalt
#

it's kinda weird

#

if you set it to false, even op'ed, it will return false

echo basalt
#

otherwise it defaults to true

tardy delta
#

¯_(ツ)_/¯

crisp steeple
torn vale
#
   @EventHandler
    public void onPlayerInteract(PlayerInteractEvent e) {
        Player player = e.getPlayer();
        ItemStack blocks = new ItemStack(Material.SANDSTONE, 64);
        if (!buildPlayers.contains(player.getUniqueId()) || !e.getPlayer().getInventory().getItemInHand().equals(blocks)) {
            e.setCancelled(true);
        }
    }```
Why cant I place sandstone blocks?
tardy delta
#

smh did too much rust

sacred mountain
#

nice

echo basalt
echo basalt
#

or because the buildPlayers map doesn't contain it

#

you gotta debug

#

also you call e.getPlayer twice

#

🤦

#

you already have a variable for it ffs

torn vale
sterile grotto
#

?

torn vale
#

noo

sterile grotto
#

nope

#

sorry

#

I misunderstand

echo basalt
#
if(!list.contains(playerId))
   event.setCancelled(!isSandstone)
echo basalt
#

that's the uh

#

rough idea

tardy delta
#

my brains hurting

sacred mountain
#

smae

#

i still canot

torn vale
#
    @EventHandler
    public void onPlayerInteract(PlayerInteractEvent e) {
        Player player = e.getPlayer();
        ItemStack blocks = new ItemStack(Material.SANDSTONE, 64);
        if (!buildPlayers.contains(player.getUniqueId()) || player.getInventory().getItemInHand().getType().equals(Material.SANDSTONE)) {
            e.setCancelled(true);
        }
    }```
like this it also does not work
echo basalt
#

changing that || to a && will likely work

#

also you can just event#getItem

tardy delta
#

and dont compare enums with ::equals

#

use ==

torn vale
echo basalt
#

yeahh

torn vale
sterile grotto
echo basalt
#

epic

torn vale
#

no wait a sec

#

now I can interact with everything again

#

I only wanna be able to place sandstone

sterile grotto
#

you means, when you have permission, you can only place sand stone?

river oracle
#

what's the difference between
ItemStack#getEnchantments and ItemStack#getItemMeta#getEnchants

sterile grotto
#

then you can use the opposite of the sandstone check

#

like if you have permission and you are not using sandstone, then cancel the event

torn vale
urban kernel
#

how do i send a chatmessage

torn vale
river oracle
torn vale
sterile grotto
urban kernel
#

nah i need to bc it

river oracle
#

broadcast?

#

Bukkit#broadcast iirc

#

or something like that

urban kernel
#

yeh

#

ok

echo basalt
torn vale
sterile grotto
echo basalt
#

tbh we can just rework the code a bit

torn vale
green prism
#

Guys, Is it possible to refresh a Placeholder? Because when I change the text in the config and save, it doesn't changes automatically and I need a /reload
Already tried by JavaPlugin#reloadConfig();

torn vale
echo basalt
#
if(buildingPlayers.contains(playerId))
  return;

ItemStack item = event.getItem();

if(item == null || item.getType() == SANDSTONE)
  return;

event.setCancelled(true);
sterile grotto
brittle lily
sterile grotto
torn vale
sterile grotto
#

my mind is not very clear right now, I need take a moment to think about it

brittle lily
torn vale
#
    @EventHandler
    public void onPlayerInteract(PlayerInteractEvent e) {
        Player player = e.getPlayer();
        ItemStack blocks = new ItemStack(Material.SANDSTONE, 64);
        if (!buildPlayers.contains(player.getUniqueId()) && player.getItemInHand().getType() != (Material.SANDSTONE)) {
            e.setCancelled(true);
        }
    }```
like this it works just fine :)
earnest forum
#

full code

#

?pastw

#

?paste

undone axleBOT
sterile grotto
sterile grotto
earnest forum
torn vale
#

yea, thats a problem...

earnest forum
#

there's a method from player

#

it's like get block looking at

#

something like that

#

let me check

sterile grotto
#

yea, that is also a problem

earnest forum
#

?jd

torn vale
#

I cant do a if-loop for like 200 blocks

prime kraken
sinful tundra
#

Is there a way to do setdisplayname for an item but with colors?

sterile grotto
echo basalt
#

don't use §

tardy delta
#

use ChatColor

torn vale
#

I always use § 🤷

sacred mountain
#

why not use the blockplace event

echo basalt
#

ChatColor#translateAlternateColorCodes

sterile grotto
tardy delta
#

dont know why is called ChatColor smh

echo basalt
#

because it's a color that appears on chat messages

#

there are multiple types of color

prime kraken
echo basalt
#

ChatColor, DyeColor, FireworkColor or whatever

tardy delta
#

mmye on the meta of an itemstack :kekw:

earnest forum
#

@torn vale

torn vale
#

yes

earnest forum
#

Player#getTargetBlock(range)

sinful tundra
earnest forum
#

this can return air/water

torn vale
earnest forum
#

what's your code trying to di

torn vale
#

every door type, trapdoor type, etc.

echo basalt
#

getTargetBlockExact

earnest forum
#

that^

#

is better

sterile grotto
#

or make a static object of your ArrayListManager object

torn vale
prime kraken
echo basalt
#

game does some rtx stuff and tosses a ray from the player's eye view that will do magic

earnest forum
#

you can also just check if the block is interactable I think that's an interface

brittle lily
sterile grotto
prime kraken
sterile grotto
#

what do you mean getting in the hashmap

urban kernel
earnest forum
#

broadcastMessage

prime kraken
sterile grotto
#

ok

golden turret
#

help pls, i want to edit my name above my head

earnest forum
sinful tundra
#

Honestly I didn't know it was a thing in intellij

earnest forum
#

if i remember your error before told you to update?

tardy delta
#

:o

sterile grotto
golden turret
earnest forum
earnest forum
echo basalt
#

pretty sure you can change the name above the head with paper easily

golden turret
sterile grotto
echo basalt
#

setDisplayName

sterile grotto
#

but this may break your game

#

so it's not recommended

earnest forum
echo basalt
#

true

sterile grotto
golden turret
#

it only changes the chat name

earnest forum
torn vale
golden turret
#

i just need to add a prefix to my name

sterile grotto
#

that why I said it was not recommended

prime kraken
# sterile grotto what do you mean getting in the hashmap

I try to made team plugin for my own, I need one Hashmap per Team so imagine I have 2 team, Red and Blue, I want one player in each team, and i just want to know how to set a "maximum" value for my hashmap and when this value is reach, no one can join the team (hashmap), It's clear ? I'm french, english is a little bit diffcult for me x)

urban kernel
#

autocomplete cant find

golden turret
#

i want my teammates to have their name with the color of our team

sterile grotto
earnest forum
torn vale
sacred mountain
#

ok no i still cant do the leaderboard thing

golden turret
#

.

torn vale
#

took like 1sec

earnest forum
#

you don't need packets for this, however if you want multiple scoreboard such as a sidebar, you need packets

golden turret
#

i am already using teams

earnest forum
#

teams are created using scoreboards

golden turret
#

but it is not working

sacred mountain
#

anyone know how to get a player's rank based on their point count in a map/ idk how to

brittle lily
torn vale
earnest forum
earnest forum
sterile grotto
earnest forum
#

this also fires for stairs and pistons which is a bug I tgink

#

@torn vale

prime kraken
earnest forum
#

that's what it says in javadoc

torn vale
sacred mountain
sterile grotto
earnest forum
brittle lily
torn vale
#

are you sure you are using Spigot?

tardy delta
urban kernel
urban kernel
golden turret
#

it is not working

earnest forum
sacred mountain
earnest forum
torn vale
earnest forum
#

also set the player's scoreboard to that scoreboard

tardy delta
sterile grotto
golden turret
#

the name tag visibility is working

tardy delta
#

just google java get value from hashmap

earnest forum
brittle lily
golden turret
#

it is not more than 16

earnest forum
sacred mountain
# tardy delta so you want to get a value in a map based on a key?

no thats just a normal hashmap, i want to get the player's rank based on how many points they have, for instance if i had one player with 5 points and another with 10, if i used getRank(player1.getUniqueID) it would return 2 since that is the second highest in the map

golden turret
#

and the 1.17 limit is 64

prime kraken
earnest forum
#

that's great

golden turret
#

yes

brittle lily
earnest forum
#

what's your prefix

#

and what is showing up on your screen

golden turret
#

a color

#

§c§l

earnest forum
#

if you just wanna change color

#

set team colour

#

prefixes don't carry onto the name

#

I don't thinl

#

you could maybe try disabling the player nickname

#

and then sending other players a packet for an armour stand

#

that constantly follows the player

#

with a custom name

#

much more customizability

sterile grotto
earnest forum
#

it's a packet

#

client sided

#

no server presence at all

#

ofc this means that you can't modify the armour stand with spigot api

torn vale
sterile grotto
#

oh, I get it, thx

golden turret
#

actually is was because colors are not accepted in the prefix

#

but how could i make this possible

#

like

earnest forum
#

colours are accepted

#

I use them

golden turret
#

[red]I am prefix [blue]aisuoiyhsaudhasuhdui

earnest forum
#

team.setColor?

golden turret
#

i want 2 colors

earnest forum
#

that changes the player's name

#

colours do work for prefixes

#

maybe try using the ChatColor constants instead of the special symbol

golden turret
#

setColor is just for 1 color

sterile grotto
earnest forum
#

ChatColor.RED

red sedge
#

how would i make a progress bar as a string

earnest forum
earnest forum
torn vale
grim ice
#

there is no method such as of

golden turret
#

bro

earnest forum
#

make a static utility method

earnest forum
#

there's 0 way that worked

sterile grotto
grim ice
#

Oh

#

right

sterile grotto
red sedge
earnest forum
#

if you've got 10 boxes

#

you have a percentage

grim ice
#

nothing in 1.18.2 @sterile grotto

earnest forum
#

use the modulo % operator

#

with the percentage and 10

sterile grotto
earnest forum
#

to check if it's a multiple of 10

#

if the modulo returns 0

#

divide the percentage by 10 and then that number is how much boxes to colour in

#

bukkit

#

use bukkit

sterile grotto
#

if you import wrong package, it would not work

grim ice
#

bukkit

#

oh u need the bungee one

sterile grotto
earnest forum
#

shouldn't be using that

sterile grotto
earnest forum
#

for a spigot plugin..

grim ice
#

its included with spigot api

tardy delta
#

why is making a command api such a pain

earnest forum
#

ChatColor.of(Color.RED) is just unnecessary resource use

red sedge
# earnest forum divide the percentage by 10 and then that number is how much boxes to colour in
    public static String progressBar(int progress, int maxProgress, String bar, String filledColour, String emptyColour) {
        StringBuilder message = new StringBuilder();
        int filled = (int) Math.ceil((double) progress / (double) maxProgress * bar.length());
        for (int i = 0; i < bar.length(); i++) {
            if (i < filled) {
                message.append(filledColour).append(bar.charAt(i));
            } else {
                message.append(emptyColour).append(bar.charAt(i));
            }
        }
        return message.toString();
    }``` smth like this?
earnest forum
#

what's ceil do

sterile grotto
echo basalt
#

0.9 -> 1

#

0.1 -> 1

earnest forum
#

I'm on my phone that formatting is cancer

sterile grotto
#

it can customise colour

earnest forum
#

can you send a paste

red sedge
#

me?

earnest forum
#

nvm it's all good

tardy delta
earnest forum
#

run it

golden turret
tardy delta
#

i cant

#

👉👈

earnest forum
golden turret
#

did not worked

earnest forum
#

please do not use .of

golden turret
sterile grotto
earnest forum
#

don't toString

sterile grotto
#

not bungee.api

earnest forum
#

should be using bukkit anyways

sterile grotto
#

don't use toString()

#

you can add "" cast it to String

earnest forum
#

it's unnecessary

#

the + "text" casts it already

golden turret
#

it will be using the .toString anyways

earnest forum
#

make sure you import the bukkit chatcolor

sterile grotto
earnest forum
#

yes

red sedge
# golden turret

Why not just use ChatColor.translateAlternateColorCodes('&', message)

golden turret
#

the underline is already from the bukkit

red sedge
#

and then put colour codes in the string

earnest forum
#

I was gonna say

earnest forum
#

I usually just make a static utility class

#

with that

red sedge
#

public static String coloured(String text) {
return ChatColor.translateAlternateColorCodes('&', text);
}

#

use this

earnest forum
#

you can't just say did not work give some context

red sedge
golden turret
#

i tried and it not work

#

this is the context

red sedge
#

yeah but what didnt work?

golden turret
red sedge
#

omfg

#

what did you try

#

what didnt work?

#

what were you expecting

#

especially what did you try?

golden turret
#

this is a conversation about team prefix

#

what do you expect me to try?

red sedge
#

i give up on trying to help you omfg

sterile grotto
earnest forum
#

what's that one command

sterile grotto
#

how about this?

earnest forum
#

?didnothelp

#

?didnotwork

#

?didntwork

#

bro why are you using .of

#

unnecessary string comparison

sterile grotto
#

I don't know

earnest forum
#

ChatColor.RED

sterile grotto
#

just get used to do that

crimson scarab
#
            PacketPlayOutEntityDestroy packet=new PacketPlayOutEntityDestroy(event.getEntity().getEntityId());
            for(Player pl: Bukkit.getOnlinePlayers()) {
                ((CraftPlayer)pl).getHandle().b.a(packet);
            }
earnest forum
#

@golden turret make sure you put a +""+ in between ChatColors

crimson scarab
#

why does this produce an error

red sedge
earnest forum
#

yes

#

you have to do that

#

when you use like italic and red together

#

put a "" in between them

golden turret
sterile grotto
#

ChatColor.ITALIC+""+ChatColor.RED+"text"

golden turret
#

.toString already does it

earnest forum
#

^

red sedge
#

red and italic

earnest forum
#

you have to do that

sterile grotto
earnest forum
#

there has to be a blank space in between

#

it's just how it is

golden turret
#

ChatColor.RED.toString() + ChatColor.BLUE.toString()

red sedge
earnest forum
#

again with the toSteinf

tardy delta
#

?notworking

undone axleBOT
#

"Does not working" is a useless statement. Please describe what exactly is not working, what you expect it to do, and what actually happens. If you get any console errors, also ?paste the entire stacktrace.

earnest forum
#

THANK U

tardy delta
#

here we go

sterile grotto
red sedge
#

wizardly can you jsut send your whole code?

golden turret
earnest forum
#

this is why translate alternate is so much better

earnest forum
#

you use +""+ if you've got a modifier like italic bold or underline

#

use the color first

#

so red, then italic

sterile grotto
#

ChatColor.RED+""+ChatColor.ITALIC+"text"+ChatColor.BLUE+""+ChatColor.ITALIC+"text"

earnest forum
#

yes

native gale
#

Is plugin.getServer() thread safe?

#

Sorry for interrupting

earnest forum
#

it's alright

lost matrix
# earnest forum put a "" in between them

String concatenation literally only calls to toString (implicitly) either way...
So

String msg = "Pre " + ChatColor.RED.toString() + ChatColor.BLUE.toString() + " post.";

and

String msg = "Pre " + ChatColor.RED + "" + ChatColor.BLUE + " post.";

and

String msg = "Pre " + ChatColor.RED + ChatColor.BLUE + " post.";

All compile to the same result. There is absolutely no difference.

grim ice
#

Give me an idea to code

grim ice
#

pls im bored af

earnest forum
#

but chat color modifiers act weirdly

red sedge
sterile grotto
golden turret
#

bro

#

my issue was

#

wrong order of colors

red sedge
#

ok..?

golden turret
#

AND IM USING TOSTRING AND IT IS WORKING OK

#

ty

sterile grotto
#

this NMS stuff really driving me mad