#help-development
1 messages · Page 2116 of 1
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
ok
what
stores a player uuid and a score
oh wait nvm
i just want to create a method that returns their rank
well ok but
32k?
idk what 32k means
32700
of what tho
yeah the points go higher
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)
thx
anyways how can i check for the equivalent of obj instanceof SomeClass but i only have a class object?
.newInstance
no i only got a Class<?>
how do i find their rank from that? ive sorted it now
What is the rank
their place in the sortedset
enum cannot be generic sighs
Ohh
is just dk
Off topic, which theme is that, i love it
dracula
but yeah i ened help
i just used the stack overflow method which seems to work when i tested it, so
Great
well its sorted but i dont know how to find their rank
in a sortedset
ive never used a set lmao
You have a set of what
Sem
uuid, integer
what
what kind of exception should i throw when the user forgot to do something?
a set cant have 2 generics
mapentry
SortedSet<Map.Entry<UUID, Integer>> sortedSet = entriesSortedByValues(map);
Oh
and the map is just a generic map
oh
the unsorted score points map
^
so with an input of a player u get their ranking?
yes
leaderboard.get(uuid) will return their rank
????
with a simple HashMap<UUID, Integer>
yes.
i need to find out who has the highest, second highest etc
and return an integer as their rank
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
Hello, does NMS from 1.17 not use versions in packages names?
can someone help me use mineresetlite on aternos please its not working
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
e.getView().getName()
Thanks a lot
Hi! does the itemmeta displayname support ChatColor colors?
thank yoy
also the lore?
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);
}
}
I'd personally recommend https://hub.spigotmc.org/javadocs/spigot/org/bukkit/scheduler/BukkitScheduler.html#runTaskTimer(org.bukkit.plugin.Plugin,java.lang.Runnable,long,long) overscheduleSyncRepeatingTask
as that returns you a BukkitTask
^^
which you can use to bukkitTask.cancel()
and use a lambda expression
like
scheduler.runTAskTimer(plugin, task -> {
// do your repeating stuff here
if (condition) task.cancel()
}, 20L, 5L);```
tho that method does not return you a bukkit task 
you can cancel it from within the lambda 😌
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);
ye ah i dont see the cancel thing
Well, for you fourteen's version is probably a lot better
i guess many people dont know what lambda expressions are
because you want to cancel if the entity is dead I presume
yep
or the compiler isnt saying it 🥺
whenever i try to cancel it says task is not initalized
Well use the layout fourteen proposed (I hope I can call you fourteen?)
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
can a consolesender have permissions? i saw it implements Permissible
wdym faster
faster than a tick?
well i am making a armor stand follow a snowball but it is always a bit behind
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
such as?
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
I mean, setClickHandler is not spigot. ranks are also not spigot
what plugin are you using for ranks
setClickHandler is Canvas: https://github.com/IPVP-MC/canvas
I mean, then you just need to call the API of the plugin you use for ranks
👍 ah k thanks for the help
how does this looks like?
https://paste.md-5.net/tugipejime.java
hey how to get the tps? i tried this but its not working getServer().spigot().getTPS()
double[] tps = MinecraftServer.getServer().recentTps;
it's deprecated but that's how spigot retrieves them aswell
Why is it deprecated
ask mojang basically
🤷♂️
Also why is it an array
1m 5m 15m
What
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"
the opposite
Im pretty sure most people know it
But why the heck
are you using allman style
im crying
huh?
public static void main(String[] args) {
}
thats K&R
when you use the build tools this is what gets compiled into your spigot.jar
I also go with this option
K&R is Kernighan and Ritchie btw
o
how to send a packet to a player?
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 :)
Would Player.setInvisible prevent mobs from noticing the player?
Is it possible to create custom resources and commands that can be used in datapacks?
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 ?
You can set the a lore to the Item with the size of your ArrayList
then cant i get tps in 1.18?
Of course you still can. It's deprecated but still works
how is a furnace minecart named in the api?
its not working for me
tho
is it that you can't find MinecraftServer?
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
So you will have many tems the best is to create a custom object (Team for example) with team color, ArrayList of players, a boolean isFull().
So then just do an ArrayList<Team>
And do all your stuff from that ArrayList
If have better ideas tell him/her
how are you importing your normal spigot?
<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
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>```
remove the -api in artifactId
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
how can i make a snowball invisible
Im wondering how i can make a custom rank system for a server
can anybody tell me how to do it?
you can try scoreboard and team api
👍 thank you
declaration: package: org.bukkit.scoreboard
thanks
my pleasure 🙂
btw can you use it on 1.8.8 or no?
That you should check on the older version of this api
👍
does anybody know any youtube video that can help about making custom icon textures?
icon display on server list?
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
no as in like chat and tab
ok
oh sorry my fault
this is a bit of a maths problem but how would i make a spawned armorstand always face away from the player
if you're a mod it will show like a green cube with "Mod" on it
the ~ ~ ~ ig?
or ^ ^ ^
Location of armour stand (as vector) - location of player (as vector) = vector facing away from player
Location armourStandLocation = armourstand.getLocation();
Vector playerPosition = player.getLocation().toVector();
Vector armourStandPosition = armourStandLocation.toVector();
Vector result = armourStandPosition.subtract(playerPosition);
armourStandLocation.setDirection(result);
armourStand.teleport(armourStandLocation);
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
lemme guess, the remapped ones are the ones that dont work
did u use the Lifecycle package command?
yes
actually the -obf one can't work
remapped one can work well
but u said 2 didnt work
Hi, I made a command but it doesn't work, no console errors etc. it just won't do anything
the other one was original one which was not remapped, I think that was the reason why it didn't work
have you registered it?
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
that is weird
have you checked your configurations in the plugin.yml?
yes, both commands appear ingame but none of them works if I register both commands. wanna see my plugin.yml?
sure
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
try to remove it and run the test
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
have you tried only registering this command and testing it?
it can show on the server and when you run it, it has no responding?
have you check your code in AfkCommand.class?
Where do you register it?
yeah, I can't find anything that might break it
Also did you remember to register the command in the plugin.yml?
in my 'main' class in the onEnable method
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?
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
Does it also not work if you only set the afkManager?
Still doesn't work then, yes
the vanish thing only works if I comment both lines for the afk thing in my onenable
So both lines cause issues? In that case I'd like to see the constructor of both AfkManager and VanishManager
^
So lombok?
what
Okay, then you are not using that. What is the constructor?
Because you must have defined one
otherwise it would not compile
What do you mean, what is the constructor?
Somehwere in your code you will have
class AfkManager {
/* ... */
AfkManager(Plugin pl) {
/* ... */
}
I think he means the constructor of your object
like this one
Yeah
how do you import/use nms
For which version?
ive tried this
<dependency>
<groupId>org.spigotmc</groupId>
<artifactId>spigot</artifactId>
<version>1.18-R0.1-SNAPSHOT</version>
<scope>provided</scope>
</dependency>
add this one in your pom.xml
this one?
but it doesnt work
can armorstands be upside down?
can other mobs be upside down
check on this post
NMS been changed since 1.17
yeah
this is in my afkmanager class
then probably
more so how would i change the pitch as rn changing pitch does nothing
That shouldn't be an issue. Which is strange
so? i used the buildtools batch but now idk what im supposed to do with it
like i have buildtools
Yeah, it's weird for me too, because this is an almost exact copy of my vanishmanager
And what is the afk command class (in fully if possible)
so you can't import spigot into your maven project?
I think you might depend on the vanish manager in your afk command class constructor, which would explain the failure
i can do spigot-api just not the full thing with nms
it gives me this error
there we have it
Hm?
when you building maven project?
when loading it
private String PlayerName = player.getDisplayName() will always throw an NullPointerException
As player is initialised as null
It is a bit strange that IntelliJ isn't pedantric enough to spot the issue
this should be better
have you run the buildtool to get lib?
Eclipse sure as hell wouldn't allow it
yes but idk what to do with the jars and stuff it made
do i just add them the old way?
I am ... at a loss of words
like putting the jars directly into the project
It didn't work bruh
You need to remove your field too
Thank you a lot, i found
What field?
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
so what do i do once i have the lib
do i just add it to the project or smth
the craftbukkit
try reboot your IDEA?
ah nvm
there is no reason it should not work but cursed installation it is ¯_(ツ)_/¯
maven sometimes break
I've tried once, not recommended
so what do i do
this is my full pom https://paste.md-5.net/izomelutof.xml
i literally just set this project up 10 mins ago lol
actually, I've once met this problem, but after a few attempt it just worked
rebuild pom.xml
I'm cursed
maybe you should try to use buildtool to build libs again
@quiet ice turns out I still had this private Player player; private String PlayerName = ... in my afkamanger class at the almost very bottom
Ah
were you using this command to build libs?java -jar "BuildTools.jar" --rev $YOURVERSION --remapped
i did the batch, which does that, so yes
the batch is the same but i can type the version
may you try downloading buildtool.jar and using CMD to run it?
I don't know much about batch, I built it with jar
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
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>
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>
ik
but if you still can't solve the previous problem, adding this may won't change anything
only in java world however
In C/C++ world you should never update your IDE
unless it is broken beyond repair
you may check your .m2\repository\org\spigotmc\spigot folder to make sure the libs were properly installed
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
lol
is there a method for ProjectileHitEvent, so I can get the item that shot the projectile
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
yea that was my idea, just wanted to know if there is a easier way
thats easy
if its not an arrow then its the projectile itself
if an arrow then a bow
what if they want custom bows?
o
with special abilities?
yea I have a custom bow
idk
Guys Can You Help Me
Is there an event for when the player moves? (jumping, walking, sprinting, flying etc)
playermoveevent
like looking around?
yes
yeah should be fine to cancel afk status
if you only wanna listen to movement and not look
just check if the getTo is the same as getFrom
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.
u need to add usage & description in the commands
Okay, thanks
those are methods from the event itself which gice you the location they moved to and from
msg:
description: example
usage: /<command>
r:
description: example
usage: /<command>
@brittle lily
have you solved the problem with the command, I am curious what caused it.
no you don't
those are completely optional
oo i get it now
it's the getCommand method
Is there any way to monitor the player putting some items into the container?
containers have nbt
declaration: package: org.bukkit.event.inventory
you could store information about each player and what they put
or look at inventory click event
and store some information in the plugin
Yeah, Player player declaration was null
i try
if people think of cigarettes as fat 90 old men dicks no one will smoke anymore
Oh thanks i will try
that won't fix it
where are u calling the method
show us your full plugin.yml and where you are registering executors
it reminds me that I used have done the same thing, lol.
Yeah, I got kinda used to doing that because I used C++ for a time
how can i send a packet to the player?
nms?
NMS?
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
btw is this correct?
what kind of remapping you are using?
spigot i think
mojang remapping maybe better
it's doesn't work on your server or just in your IDEA
many beginners, lets say it liek that
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 ?
cancel the EntitySpawnEvent or smth
hey fourteen do you know how to do the ranking thing i was talking about tearlier
^
what was i'm on when i wrote my code a few hours ago lol
i would say use a TreeSet<PlayerRanking> and in the TreeSet constructor, give a Comparator which checks for the points in the ranking
no clue how to do that
How would I do that? if (event.getTo() == event.getFrom()) makes no sense (and doesn't work)
(event is the variable for the PlayerMovement)
check for HashCode?
event.getTo and from return a location
@Override
public int compare(Map.Entry<UUID, Integer> o1, Map.Entry<UUID, Integer> o2) {
return o2.getValue().compareTo(o1.getValue());
}
});```
a TreeSet provided with a Comparator will insert your element in the right position (so the set will always be sorted)
oh ok
Keep getting this exception on startup https://paste.md-5.net/tofixaxuso.coffeescript
Have no idea what its being caused by as my plugin is java 1.8 and so is maven compiler version
what mc version?
1.8
It’s compiling it for Java 9
JRE version was outdated?
You have to set the Pom to compile it as Java 8
It is
Let’s see
i have mine as 8 too
plugin was working just fine a bit ago
¯_(ツ)_/¯
how about project settings
I assume you’re compiling it with mvn install?
i believe so
Spooky
👻
just weird since i havent changed anything to the project structure
Could always try the old delete the project and re-configure it
idk if thats a good idea
its set up on a pretty complex git structure that i dont even fully understand
have you checked this setting?
how do i get the server version? i want to add something like this:
https://i-own-a.blacklisted.store/IYUjq4DF
i use spigot, i just used the bungee startup message as an example
I meant the IDE-level configuration
i could try i guess
i did too much rust but do java switches use commas?
i forgot lol
looks like they dont
anyone?
i'll give it a try, cheers
use it in enable method, I don't know if it can work
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
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
oh god what the fuck
list.size() == whatever
well uhh does it makes sense to check permissions for the console?
doesnt console have all persmissions
it does implement Permissible
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
just to be sure
thanks you !
lol i thought that was js
i still cant figure out how to sort and get a position in a treemap or whatever map
I mean
i would create the playerranking first
ty
nvm if it's op, it returns true
i still have no clue
write a sort algorithm manually, lol.
told him to use this
¯_(ツ)_/¯
fixed, somehow caused by adding gson to a project that already had guava 🙃
@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?
smh did too much rust
nice
probably because you're checking for 64 sandstone blocks
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
yea, it does not contain the player. The player shouldnt be able to build while the list does not contains him or he builds with sandstone
you should use && not ||
?
noo
if(!list.contains(playerId))
event.setCancelled(!isSandstone)
whut?
my brains hurting
I changed it...
@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
I dont think so but Ill test
yeahh
you were right
yea, I think that's the problem, you are using or selection, which means, even if you have permission, you still can't place sand stone
epic
no wait a sec
now I can interact with everything again
I only wanna be able to place sandstone
you means, when you have permission, you can only place sand stone?
what's the difference between
ItemStack#getEnchantments and ItemStack#getItemMeta#getEnchants
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
ItemStack blocks = new ItemStack(Material.SANDSTONE, 64);
if (!buildPlayers.contains(player.getUniqueId()) && e.getItem().getType() != (Material.SANDSTONE)) {
e.setCancelled(true);
}```
would make no sense, or am I just stupid?
it didn't work?
how do i send a chatmessage
Now I can interact with everything again
Player#sendMessage() look at the docs or google for that one pal
Player#sendMessage()
remove ! before the permission check?
nah i need to bc it
e.getItem might be null
which one?
first
tbh we can just rework the code a bit
then I also would need to change setCancelled(false)?
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();
yea
if(buildingPlayers.contains(playerId))
return;
ItemStack item = event.getItem();
if(item == null || item.getType() == SANDSTONE)
return;
event.setCancelled(true);
yes, this may case NullPointerException
I register on my Main Class
wait for a sec
oh, yea
my mind is not very clear right now, I need take a moment to think about it
It didnt fixed
@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 :)
show the actual code
full code
?pastw
?paste
this may case a little bug
anyone?
when your server are very lag, it may can't process type message before any other move
what if they are trying to open a door with sandstone in their hand?
oh
yea, thats a problem...
there's a method from player
it's like get block looking at
something like that
let me check
yea, that is also a problem
?jd
I cant do a if-loop for like 200 blocks
can you help me with your method ? i check if the list.size() == 10 (for exemple) but after i want to say something to the player... ?
Is there a way to do setdisplayname for an item but with colors?
if(list.size() == 10) ...
§ColorCode
if(list.size==10){player.sendMsg(String msg)}
don't use §
use ChatColor
I always use § 🤷
why not use the blockplace event
ChatColor#translateAlternateColorCodes
ChatColor.of(Color)
dont know why is called ChatColor smh
because it's a color that appears on chat messages
there are multiple types of color
Nice, i just made a class ArrayListManager with all of my arrayList, how may I import the player ?
ChatColor, DyeColor, FireworkColor or whatever
mmye on the meta of an itemstack :kekw:
@torn vale
yes
Player#getTargetBlock(range)
Changing the meta ye
this can return air/water
But I will have to process like at least 20 blocks :/
create a get method
what's your code trying to di
every door type, trapdoor type, etc.
getTargetBlockExact
or make a static object of your ArrayListManager object
the player only should be able to place sandstone, nothing else
nice, to cancel the player to getting in the hashmap i had just to had a return false ?
game does some rtx stuff and tosses a ray from the player's eye view that will do magic
you can also just check if the block is interactable I think that's an interface
@earnest forum here is my codes..
sorry, I am a little bit of confused
don't worry
what do you mean getting in the hashmap
nah
broadcastMessage
I'll explain
ok
help pls, i want to edit my name above my head
try run this and see what the error is
Honestly I didn't know it was a thing in intellij
if i remember your error before told you to update?
:o
NMS maybe needed
no problems
whats the method?
you can't change the name, but you can add prefix and suffix
1 sec
pretty sure you can change the name above the head with paper easily
that is what i am using
actually you can use NMS change your profile name
setDisplayName
that doesn't change anything
true
this only change the name display in chat and tab list
it only changes the chat name
that changes your name on the server too, so you can't do /tp to your actual name
yes
use autocomplete or google it...
i just need to add a prefix to my name
that why I said it was not recommended
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)
google just comes up with that
autocomplete cant find
i want my teammates to have their name with the color of our team
check for scoreboard and team API
use teams
Bukkit#getServer().broadcastMessage()
ok no i still cant do the leaderboard thing
.
took like 1sec
you don't need packets for this, however if you want multiple scoreboard such as a sidebar, you need packets
i am already using teams
teams are created using scoreboards
but it is not working
anyone know how to get a player's rank based on their point count in a map/ idk how to
@earnest forum here. thats my error
.
try update your jar
Material.isInteractable()
oh, I get it, pls wait a sec, let me think about it
google it
Take the time you want, i wait, thank you very much
that's what it says in javadoc
how do I get the block the player is look at?
i hvae bruh
my pleasure:)
Player#getTargetBlockExact
dafq
Its 18....
are you sure you are using Spigot?
what did you find?
idunno
no bukkits api
it is not working
try type in Bukkit.broadcast and see what comes up in auto complete
how to sort it, but not how to find the player's position in that map
you have to set the teams prefix and stuff
nthn
and in the 1.8.8 api? :/
also set the player's scoreboard to that scoreboard
so you want to get a value in a map based on a key?
you can use HashMap<$YOURTEAMIDOBJECT,ArrayList<Player>>to store data
the name tag visibility is working
just google java get value from hashmap
prefixes cannot be more than 16 chars btw
18 Isnt Last one?
it is not more than 16
download most recent build
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
and the 1.17 limit is 64
I will check with that thx
yes
Oh Okay
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
if there are to many armour stand would it cost too many recourse of the server?
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
this method does not exist in the 1.8.8 :(
oh, I get it, thx
actually is was because colors are not accepted in the prefix
but how could i make this possible
like
[red]I am prefix [blue]aisuoiyhsaudhasuhdui
team.setColor?
i want 2 colors
that changes the player's name
colours do work for prefixes
maybe try using the ChatColor constants instead of the special symbol
i want this
setColor is just for 1 color
try this?ChatColor.of(Color.RED)+"text"+ChatColor.of(Color.BLUE)+"text"
ChatColor.RED
how would i make a progress bar as a string
just use ChatColor.RED + "I am prefix" + ChatColor.BLUE + "hshsbehe"
Lmao
use some custom box character
any solutions?
there is no method such as of
bro
make a static utility method
thanks!
there's 0 way that worked
1.14 or above version required
🙂
yeah but like how would i make that method
nothing in 1.18.2 @sterile grotto
which ChatColor you are using
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
if you import wrong package, it would not work
use bungee.api
shouldn't be using that
yes
for a spigot plugin..
why is making a command api such a pain
ChatColor.of(Color.RED) is just unnecessary resource use
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?
what's ceil do
you can use it this way, if you like ChatColor.of(new Color(0x9F0909))
I'm on my phone that formatting is cancer
it can customise colour
can you send a paste
me?
nvm it's all good
that's good
i want the pasta
run it
now how can i style this with the underline, italic and etc?
ChatColor.ITALIC
did not worked
please do not use .of
you need to pointed that ChatColor is from package of bukkit
don't toString
not bungee.api
should be using bukkit anyways
it will be using the .toString anyways
make sure you import the bukkit chatcolor
if two ChatColor next to each other, "" is needed
yes
Why not just use ChatColor.translateAlternateColorCodes('&', message)
the underline is already from the bukkit
and then put colour codes in the string
I was gonna say
did not work
..?
public static String coloured(String text) {
return ChatColor.translateAlternateColorCodes('&', text);
}
use this
you can't just say did not work give some context
yeah but what didnt work?
omfg
what did you try
what didnt work?
what were you expecting
especially what did you try?
i give up on trying to help you omfg
ChatColor.ITALIC+""+ net.md_5.bungee.api.ChatColor.of(Color.RED)+"text"
what's that one command
how about this?
?didnothelp
?didnotwork
?didntwork
bro why are you using .of
unnecessary string comparison
I don't know
ChatColor.RED
just get used to do that
PacketPlayOutEntityDestroy packet=new PacketPlayOutEntityDestroy(event.getEntity().getEntityId());
for(Player pl: Bukkit.getOnlinePlayers()) {
((CraftPlayer)pl).getHandle().b.a(packet);
}
@golden turret make sure you put a +""+ in between ChatColors
why does this produce an error
that shouldnt change anything
yes
you have to do that
when you use like italic and red together
put a "" in between them
that dont change anything
ChatColor.ITALIC+""+ChatColor.RED+"text"
.toString already does it
^
reverse them
red and italic
that may work
ChatColor.RED.toString() + ChatColor.BLUE.toString()
cuz like even with colour codes, italic overrides the colour
again with the toSteinf
?notworking
"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.
THANK U
here we go
what the fu-?
don't use toString()
wizardly can you jsut send your whole code?
the same as ChatColor.RED + "" + ChatColor.BLUE
this is why translate alternate is so much better
no that's redundant
you use +""+ if you've got a modifier like italic bold or underline
use the color first
so red, then italic
ChatColor.RED+""+ChatColor.ITALIC+"text"+ChatColor.BLUE+""+ChatColor.ITALIC+"text"
yes
it's alright
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.
Give me an idea to code
yes I know this
or... just use translate colour
pls im bored af
but chat color modifiers act weirdly
make math without math
create a new api with NMS, lol.
ok..?
this NMS stuff really driving me mad