#help-development
1 messages · Page 1966 of 1
Imagine having to learn js
can they move
react to this if you are extremely homosexual (
yeah
Annotations are uglier
i havent coded it yet
could be me 😔
Im uhum forced to learn html
Tho @Delegate annotation is hot
im still figuring out how to do that
Any modern ide allows you to refactor out a delegate
i might give them zombie ai
Oh fr
I wish delegation would be a jvm feature
But can it do this?
there is a nice js api
Or @UnmodifiableView
i create custom inventory class and
its working in newer version but its not work on 1.12.2 bukkit
idk why.. its same code..
Caused by: java.lang.ClassCastException: class org.bukkit.craftbukkit.v1_12_R1.inventory.CraftInventory cannot be cast to class com.darksoldier1404.dppc.api.inventory.DInventory (org.bukkit.craftbukkit.v1_12_R1.inventory.CraftInventory is in unnamed module of loader 'app'; com.darksoldier1404.dppc.api.inventory.DInventory is in unnamed module of loader org.bukkit.plugin.java.PluginClassLoader @621d9443)```
https://github.com/darksoldier1404/DPP-Core/blob/master/V1_12_2/src/main/java/com/darksoldier1404/dppc/api/inventory/DInventory.java
Still dunno what the difference with Unmodifiable is tho
Contract, Range, Pattern..
The bible
Thing is, whatever Lombok can do, is also possible to do with the normal java language features or ide features so that’s why I classify Lombok as useless but that’s just me
Or this class. Would be 400 lines delomboked instead of 80. I would have to scroll half my life to add a method.
Why not just making a programming language that's based on annotations then
I mean if you detest verbosity as said there are alternatives you could stick with instead
Well, view is a view. It means that collection by itself is mutable, but method returns a view of a collection which you cant use for modification
I believe verbosity is good, at least from what I have experienced so far
Thats just JavaEE lol
annotations are procedural
Idk lol
ok irs nor
Java is to some extent procedural

I used to hate lombok, now i dont hate it as much
though i dislike @Nonnull and how everything else is assumed to be null if not annotated
@Nullable & @NotNull are better imo
the jetbrains ones that is
Anyways. Gotta show something off bc i sat all day on this implementation and visualisation
of an async flood filling algorithm with 3 iterations [scan, safety, action]
I mean javas way of intersecting null with other types is, well… interesting

xD
Are those blocks of armor stands with glowing effects?
*With slime packets
ye
200 lines of pure protocollib horror and magic numbers left and right...
we love to see it
Didn't someone else show this earlier today?
Wait Lombook refactor bytecode right if not i dont find how its work
or it has its own "interpreter"
Annotation processor. Basically generates code at compile time.
Ah allrgiht
Its like a plugin-dependency
Its a dependency that inside contains a plugin
Now i understand why it wasnt working btw
lol, was looking thru your messages to try and find it, and found the same class as an example from a minute ago, but with remarkably less code in it 
someone was busy today xD
?
Yep...
Hello ! is here for bungeecord developpement ? 🙂
yep
i have a problem, i use ping method on proxy connect, and if the targeted server is offline, the player will send on a another server
Bungeecord and Spigot
and in bungeecord console, my event took xx ms
if (event.getServer() != null) return;
ProxiedPlayer#connect(ServerInfo target = event.getServer())
Send code please
guys does anyone know about using authme api?
They have tutrials with examples
String finalPlanet = planet;
Main.getInstance().getProxy().getServers().get(planet).ping((result, error) -> {
if (error != null) {
event.setTarget(ProxyServer.getInstance().getServerInfo("Limbo"));
} else {
event.setTarget(ProxyServer.getInstance().getServerInfo(finalPlanet));
}
});
}```
youtube or where
i made a discord bot (jda) and i need it
https://ci.codemc.io/job/AuthMe/job/AuthMeReloaded/javadoc/
they have a jd
simple type: "SpigotMC authme api examples"
is anyone know about this error???
yea i just see it but im trying to do but i can't
sure
it will give use examples
tysm
About using the api
yw
have a good day
You too
Full code on
?paste
if yes, creata paste with the issue
what do I do when I submit my premium resource and it requires an authentication key to work.
No recommended
java can be decompiled and simply removed the key verification
no
Licensing systems aren't even allowed in the first place
And if you obfuscate it, most times can be re-engeniering
err, i'm in trouble with set data watcher object in 1.16, can s.o help
fine i wont have an auth key
So we didnt understand why try to do
its for an external api i host
Take in care, that any resource on spigot cannot depend on internet connection for working (Its supid btw, but its a rule)
Ask to @ivory sleet he is staff and can tell you
When i read that rule, i was like are you shocking me? how plugins cannot depend on internet connection? If the spigot iselft depend from internet connection. BTW
@naive bolt , so your plugin interect with a backend via Rest API i suppouse
Well I saw one a plugin on spigot which was interacting with google translate...
yes
hello, i have a problem, i use ping method in a ServerConnectEvent and if the targeted server is offline, the player will send on a another server
https://paste.md-5.net/osunejukuj.cs
Dont spam, im trying to help you
sorry x)
how does the authentication key work
is it so that only your plugins can access an api
What was the error having
it just is a param in the api request.
i don't really need it but it was like a attempt to stop piracy
use base64 and prefered over HTTP__S__
like this
[10:51:14] [Netty Worker IO Thread #0/WARN]: Plugin listener be.shark_zekrom.listener.OnJoin took 188ms to process event ServerConnectEvent(player=DeathStarBricks, target=BungeeServerInfo(name=Station, socketAddress=/92.222.199.97:25567, restricted=false), reason=JOIN_PROXY, request=net.md_5.bungee.api.ServerConnectRequest@16bceced, cancelled=false)!
that makes no difference
Https transfer all encrypted, so why wouldnt?
yeah but you can just decompile the plugin lol
we werent talking about man in the middle attacks
getting total members of a discord guild. Its for a placeholder that works with the plugin
use 401 for unautheenticated
i could use JDA but prefer not
or 403 i dont remember
401
anyone know how to check if a player opens an anvil and what items did he put in?
and set what will come out
401 is unauthorized
!jd
can i create 2 commandexecutors with the same name?
i want to create /vlu reload in one class
and /vlu give in another
is that possible
the code doesnt do anything anyway
?jd
or do they have to be in the same class
right ok - so as long as if it cannot make the connection it returns for example 0, it will not be against the rules as far as i know
yea it returns Unknown
1 should be the executor ("vlu") and the others arguments
which i can set to 0
yeah ik that
that isnt my proble tho
Cool that should be fine then
Oh which is?
im just asking if i can create a different argument in a seperate class file
What http api using?
I have a lib for that
gib
well yes and no
the plugin should work without internet connection thats bout it
my own one
mostly to avoid stupid plugins to depend om some sort of cloud service
i really do need a lib for better command args
just so when the cloud service goes down the plugin doesnt become utterly useless
Oh exlactly what ARRann doing
He has a cloud i think
verano what lib btw
Hi, umm
private static ForcePowersManager force;
public static ForcePowersManager getForce() {
return force;
}
How can I let this only return force if force != null? (ForcePowersManager is a seperate class)
I tried:
public static ForcePowersManager getForce() {
if(force != null) {
return force;
}
}
But it said that there is a missing return statement
(Sorry I am new in developement)
does bstats error when no internet
if discord decides to reload when im typing again imma shred my cpu
Is this any good?
yes i use it but idk what it does
Seems oudated
Return null?
nope, its maintained by the paper team iirc
its so you get this
Or throw exception if it should t be null
Noob plugin
but my problem was that the NullPOinterException said no
Well then make it's initialized
how can I do that?
Oh, it adds a template pretty much
= new ForceThing()
yea its useful for making quick plugins
half of the plugins are dead because i started them but couldnt be bothered to finish them
Lol antijoinmessage i can Imagine that s only five lines of code
Maven vs Gradle?
the plugin does more actually
I was Willing to create a npc plugin
still not much but it isnt just block
BlockNoises creepy
yea i wanted to make a plugin so when you break a block its a random noise
but gave up
i got this far before i gave up
ty its $15.99
xD
Well thankfully the delete key is free
Where I buy?
Press it a few
The stupid song is in my head now
dm me 😉 ♥️ 🍸
The proper way would probably be listening to outgoing packets and just switching the sound namespace for a random one if the original was a block sound.
This sounds like it can be done in 10 lines with ProtocolLib
Protocollib 🥶
I give him 1/5 stars, he no help me when I give him this error
No such dir: java
😢
||The spigot community market is||
Maybe if you make optimize plugin that replaces every int with a string saying the actual number, it'd optimize pc
smart
||I'm so dead 🤣||
LOL xD
🥲
Now, turn that into a framework, called ||The numbers that never existed|| TNTNE
100m downloads
🥲
blockMeta.getPersistentDataContainer().set(new NamespacedKey(plugin, "convert-spawner"), PersistentDataType.STRING, cBlock.getSpawnedType().toString());
blockMeta.getBlockState().update();
System.out.println(blockMeta.getPersistentDataContainer().get(new NamespacedKey(plugin, "convert-spawner"), PersistentDataType.STRING));
prints out "PIG", or "COW", etc.
Whenever I try to access the pdc I can't, as it says it's not there
String spawnerType = cBlock.getPersistentDataContainer().get(new NamespacedKey(plugin, "convert-spawner"), PersistentDataType.STRING);
System.out.println(cBlock.getPersistentDataContainer().has(new NamespacedKey(plugin, "convert-spawner"), PersistentDataType.STRING));
System.out.println(spawnerType);
if(cBlock.getPersistentDataContainer().has(new NamespacedKey(plugin, "convert-spawner"), PersistentDataType.STRING)) {
cBlock.setSpawnedType(EntityType.valueOf(spawnerType.toUpperCase()));
}```
prints out false and null
Are you running Minecraft 1.19.2?
if i do smth like
for(ItemStack stack : p.getInventory().getArmorContents()){
double newDamage = ((damage / 100) * (100 - Durable.getInstance().getDamageRate(DamageRate.valueOf(
stack.getType().name().split("_")[0]))));```
**stack.setDurability((short) (stack.getDurability() - newDamage));**
```java
}```
yes its amazing
the thing in bold
its fully up to date
will it update the itemstack
wait what do I have to put in front of the =?
or do i have to set the armor slot
When you called getBlockState().update() you wiped out yoru old meta
to the itemstack
Just create a new object lol
okay
private static final Set<Sound> BLOCK_SOUNDS = Arrays.stream(Sound.values())
.filter(sound -> sound.getKey().getKey().toLowerCase(Locale.ROOT).contains("block"))
.collect(Collectors.toSet());
@Override
public void onEnable() {
ProtocolLibrary.getProtocolManager().addPacketListener(new PacketAdapter(this, PacketType.Play.Server.NAMED_SOUND_EFFECT) {
@Override
public void onPacketReceiving(PacketEvent event) {
PacketContainer container = event.getPacket();
StructureModifier<Sound> soundStructureModifier = container.getSoundEffects();
Sound original = soundStructureModifier.read(0);
if (SmileCore.BLOCK_SOUNDS.contains(original)) {
Sound[] allSounds = Sound.values();
Sound randomSound = allSounds[ThreadLocalRandom.current().nextInt(allSounds.length)];
soundStructureModifier.write(0, randomSound);
}
}
});
}
Probably needs some fine tuning. But thats the general idea.
So do I not even need to update it?
you put the meta back
can premium plugins have free dependency's
Sure
Yeah
k good
Just not paid ones
why not
Can free plugins have paid dependencies is the real question lmao
?premium
i was just checking as the rules are strict and confusing
Paid dependencies is a joke lmfao
a prem plugin with a prem dependency plugin with a prem dependency
if(version >= 1.16) System.out.println(Material.BLACKSTONE);
else System.out.println(Material.COBBLESTONE);
```Can you do something like that?
XMaterial
Yeah but... how does xmaterial do it? (Not interested in materials, it was an example)
i suppose nms?
https://github.com/CryptoMorin/XSeries
Its open source
ohhhhhhhhhhhhhhhhhhhhhhhhhhhhhhh
i see
they just have materials and legacy ones
and i suppose if you do like
get(int data, String legacyName) you get the correct one?
yeah
This should create instance if it doesnt right?
why do you need the ()
you can do
return this.mongo == null ? this.mongo = new Mongo(credentials) : this.mongo;
Im confused if first go the true result, or first the false
true
then false
If this method is in the "Mongo" class then it does not make much sense.
its
if(condition) thing else statement
if you don't like my error messages imma have to ask you to leave
singletons
No no, its my custom implemenetion
Singletones are kinda cringe
No
It other way around
cuz intellij say it will be null allways the var if ichange to what you said
show me the error
you put it the wrong way around...
That you explain in your code
i just said remove ()
I follow your example
you don't need those
How would i approach to create a bigger leaf decay distance?
It really confused
this is correct
My brains exploded
No
What do you mean by that? Leaf decay has no distance limit.
do you think my config is documented enough https://paste.gg/p/anonymous/0e6b403bc9ad47a09ea821ac655adfc3
This is marked as returning the var null (this.nongo)
lmao no
really?
imma show you my config
Or do you want to prevent decay of leaves when wood is nearby
For documenting, the method should contain:
Small description of what does
arguments it need and small description
if throw exceptions or not
i was gonna say
There
this is also not the most documented
System.out.println(true ? "true" : "false") -> this its not always
return this.mongo == null ? this.mongo = new Mongo(credentials) : this.mongo; -> this return always null
well then i amm sorry... what?
how'd you manage that
its a shorter if statement
so you messed something up
The first line of the message will be applicable only if the return equals this one, if not i will be always null
return (!this.mongo == null) ? this.mongo = new Mongo(credentials) : this.mongo;
We have a custom map with (big) custom trees.
If we enable the decay of leaves, all the leaves outside of the range will decay automatically.
https://minecraft.fandom.com/wiki/Leaves#Usage
Leave decay max distance = 6
Do i have explained now?
@lost matrix I think hes asking how he'd make a limit to define how close you need to be for leafs to decay
Dont tag for help, its not allowed. You are not paying for having isntant support
no, i am still confused as how you managed to make true ? "true" : "false" always false, its the equivalent of if (true) { return "true"; } else { return "false"; }
Lol im even more confuse than you😕
I tried to use saveResource() but the file I'm trying to save "isn't found in the plugin jar"
I put it in resources next to config.yml
is it in your resources folder?
yes
is the name correct? ("/resourcename")
"src/main/resources/words.txt"
you need to type it as "/words.txt" iirc
saveResource("src/main/resources/words.txt", false);
no
remove everything behind /words.txt
What you said
System.out.println(true ? "true" : "false"); // Its not always applicable
This is wrong
public Mysql mysql(Credentials credentials) {
return this.mysql == null ? this.mysql : this.mysql = new Mysql(credentials); // It always return null
}
Correct way
public Mysql mysql(Credentials credentials) {
return this.mysql == null ? this.mysql = new Mysql(credentials) : this.mysql;
}
just "/words.txt"
Do you understand now?
i said the last one
but ok
Oh so them i get really confused. My bad
also the first one IS always applicable
it will always output true
No, in my case no
eh
this better you think? https://paste.gg/p/anonymous/d71e6530f70949b9bcf81f97741c23ef
add the # right before the line
https://paste.md-5.net/yapatewovu.nginx what does this mean 😖
adding spaces between the lines
ok
like
enabled: true # Enable/Disable command should become
# Is the command be enabled?
# Default: true
enabled: true
nextThing
imo that is much more helpful
because it replies to the question
so like
Is the command enabled? true
add a Default section
yea
so people know how to reset
and add spaces between options
so after the option and before the next comment, add a space
e
almost perfect
add a space between join message and the comment
for every category
yep
thanks for your help
np
i have seen a great reduction of people asking me basic questions after i did this
so it should be good xD
@naive bolt you missed
good point
Hi, i want to make a plugin that records the player movement and rotation and then play it, like a replay mod, but its not very smooth cuz minecraft its running on 20 ticks so like 20 fps for the video i think.. any idea?
listen to the packets
The embedded resource '/words.txt' cannot be found
you can do so by either using protocollib or nms
try without the /
movement and rotation packets or ? idk much with packets, i need to learn
i have lots of private void setupSQL() { sorta things in my main.java should i split them into other files
theres a movement packet which is both rotation and movement
yes
//block break event
ItemStack spawnerToDrop = new ItemStack(Material.SPAWNER);
BlockStateMeta blockMeta = (BlockStateMeta) spawnerToDrop.getItemMeta();
blockMeta.getBlockState().setBlockData(block.getBlockData());
blockMeta.setDisplayName("§d" + StringUtils.capitalize((cBlock.getSpawnedType().toString().toLowerCase()) + " Spawner"));
blockMeta.getPersistentDataContainer().set(key, PersistentDataType.STRING, cBlock.getSpawnedType().toString());
spawnerToDrop.setItemMeta(blockMeta);
This works properly and prints that it exists and with the proper value, although when I try and access this later on:
//block place event
if(cBlock.getPersistentDataContainer().has(key, PersistentDataType.STRING)) {
String spawnerType = cBlock.getPersistentDataContainer().get(key, PersistentDataType.STRING);
cBlock.setSpawnedType(EntityType.valueOf(spawnerType.toUpperCase()));
cBlock.update();
}
If I were the print the values it prints that the pdc doesn't contain the key. Any thoughts on why this might be so?
what class do i make them
maybe SQLUtils?
sweet, that worked, thanks
yeah the / is only needed when using Class#getResource
oh, that's a thing too?? time to replace some things...
yeah
ok, thnx, i hope that when i play the video it wont play in 20 fps cuz there idk what to use besides scheduler.runTaskTimer
you can get a resource from the .jar to load and use without extracting
np
do you guys shutdown thread pools?
world.playEffect(location, Effect.FIREWORK_SHOOT);
Plays an effect to all players within a given radius around a location.
Params:
location – the Location around which players must be to hear the effect
effect – the Effect
data – a data bit needed for some effects
radius – the radius around the location```
Trying to use playEffect but when I do Effect.FIREWORK_SHOOT in particular it plays the bow shoot sound instead
lets say i dont need to shutdown my tasks gracefully
what's your api-version inside plugin.yml
do you use viaversion/protocolsupport
1.15, yes
it could be that viaversion converts sound packets badly
try removing it
and see if that's an issue
OK
ViaVersion is disabled and I'm still running into this issue
1.17.1
set your api-version
to the server's version
but i doubt that'll change anything
more features!!!!
Lol xD
anyone know a good command api (like subcommands, commands, etc)
im trying to clean up some of my code with nice libs
aikar's commands
Lamp
Lamp is inspired by ACF
https://github.com/Redempt/RedLib has a good command manager
@mortal hareyeah that did nothing unfortunately
0-0
nice
the 2018 memes marathon
Cloud!
why do i get
java.lang.ClassCastException: class xyz.arr4nn.DiscordMembers.functions.AutoAnnouncer cannot be cast to class org.bukkit.plugin.Plugin (xyz.arr4nn.DiscordMembers.functions.AutoAnnouncer is in unnamed module of loader 'DiscordMembers-1.0.jar' @7835e032; org.bukkit.plugin.Plugin is in unnamed module of loader java.net.URLClassLoader @5c29bfd)
in
https://paste.gg/p/anonymous/c8c5644d0d914759b97e638516cd518d
my plugin records every position loc paket, makes a file with a bunch of locations and then when i play them i teleport the players to those locations, any other idea on how should i do this? i mean the packet idea worked, i have a lot more locations in the file now but when i try to play it, it is still kinda lagging
add interpolation
?
Any good guides for reflection
ones that can get me to a master level I guess? I'm gonna grind it out
from (1, 0, 0) to (2, 0, 0) you can get 10x more movements by doing
(1.1, 0, 0)
(1.2, 0, 0)
(1.3, 0, 0)
...
(2, 0, 0)
that would work ig
lemme get you a guide @ebon stratus
Avoid reflection
How would I make a fake login process without having the player leave and rejoin?
its good some times
No sorry
483.2403412223496 67.926813027357 515.2491955154314
483.2411428250447 67.91333065959527 515.1385243891954
483.2419644951182 67.90524123893825 515.0278474758071
I have locations like this close in the file
Well I didn't say I will use it, I will learn it though
I'm planning on getting into nms
later on after mastering reflection
ehhhh
Not doing any nms until I get an intermediate knowledge of reflection and some other advanced topics
which is probably a wise choice, isnt it
How does spigot handle plugin loading for the @Override onEnable(){} and other events cause im kinda wanting to do something like that and was wondering if anyone could provide me with some insight on how it works.
But please, do not do relfeciton based code on nms and use modules instead
yeah its examples
im waiting :)
Working with nms doesnt require knoweledge of too many advanced topics though
It's the observer design and strategy design pattern
Well doesn't rly matter for me
What's that
fine im gonna learn modules after reflection
What
That's classical inheritance
That's what ive been told about how events in spigot work
<dependency>
<groupId>org.jetbrains</groupId>
<artifactId>annotations</artifactId>
<version>20.1.0</version>
</dependency>```
onEnable and onLoad etc arent like that though
they're probably called when server loads up
as they are not events, I assume
@mortal hare do you think that maybe I need to be providing some different kind of data along with Event.FIREWORK_SHOOT?
Please
Caused by: java.lang.NoSuchFieldException: modifiers
a field you are trying to access via reflection does not exist
Modifiers is the name of the field I’m trying to access?
at me.will0mane.epl.nametagchanger.NameTagChanger.enable(NameTagChanger.java:363)
That doesn’t access any reflection field tho
thats where the error is thrown
That line is a not null check
its getting null because the field doesn;t exis
It doesn’t even mention reflection
But I’m not getting reflection in that line
You can see your stack trace. you are calling your ReflectUtils class looking for a modifiers field
So there is a compiler error
Process process = Runtime.getRuntime().exec("jshell");
process.getOutputStream().write("System.out.println(\"Hello World!\");".getBytes(StandardCharsets.UTF_8));
process.getOutputStream().write('\n');```
I’m not calling that
public Vector lerp(Vector pos, Vector otherPos, double speed, double errorMargin) {
if(pos == null) throw new IllegalArgumentException("pos can't be null!");
if(otherPos == null) throw new IllegalArgumentException("otherPos can't be null!");
if(pos.equals(otherPos) || pos.distanceSquared(otherPos) <= errorMargin * errorMargin) return otherPos;
Vector delta = otherPos.subtract(pos).normalize();
return new Vector(pos.getX() + (speed * delta.getX()), pos.getY() + (speed * delta.getY()), pos.getZ() + (speed * delta.getZ()));
}
```Should be it (To increase the position, run lerp on the already lerped vector)
of executing code from a string
ok
done
thnx, ill try
no need
so like, i lerp the position first then player.teleport() ?
The Java Shell tool (JShell) is an interactive tool for learning the Java programming language and prototyping Java code. JShell is a Read-Evaluate-Print Loop (REPL), which evaluates declarations, statements, and expressions as they are entered and immediately shows the results. The tool is run from the command line.
its JShell.create() btw
when storing
you lerp
You can use java9+ on older MC versions as well
between old position that you know of the player
and the new one
(if you don't know an old one, skip lerping)
the replay start pos?
when you get a packet for movement
yeah
just store it as the old pos, then on any new packet, lerp for X amount of times from the oldPos to the currentPos
@rough drift I wanna run a few lines of code though
you can iirc
do I just make a string and keep \ning
also that link
shows how to do it in console
not with code
event.getPlayer().getLocation() right? or? idk with packets
yeah
you are using events, that also works
ig
packets
why cant i use jetbrains annotations?
i cant seem to find out how to use it
cant import
using maven?
cant find t
I gave you the dependency entry for maven to use org.jetbrains annotations
https://mvnrepository.com/ is your friend
Ummm
does JShell work for libraries
so like
if i use jshell to execute
for example Bukkit.getPlayer("Notch").sendMessage("ur mom");
will that work? or does it only recognize java stuff
I know that with beanshell it will work with libraries. But I do not know how jshell works there, but probably too
what is beanshell
just one more question, should i use scheduler.RunTaskTimer to play the replay?
imo you should find a way to async run a while loop that loops over every movement
so lik
make an interface, implement it for each version
dif.setY(0);
armor.teleport(armor.getLocation().clone().setDirection(dif));``` just when i move close that rotate is stranger
Rn i run it on when i receive a movement packet
store tem all
them*
and replay them at once
with a while loop or smt
iirc there's a lookAt method
I mean i store and play with the move packet
kk
Yeah
Hi! how can i make a team with a suffix and add a player to that team so that he will have a suffix saying for example "DUMB"
no?
how do i set my character encoding to UTF-8 in gradle?
#help-server (you can use /team command)
no, i don't want commands i want to do it with code
Believe me reflection is more painful
you have no choice
sigh ok
Vector dir = playerLoc.subtract(armorLoc).toVector();
dir.setY(0);
dir = dir.normalized();
armor.teleport(armor.getLocation().setDirection(dir));
there
:(
@minor garnet
player.setDisplayName(PREFIX + player.getName());
what should i do next?
that doesn't change the display name above the player head
it doesn't?
also i have a custom chat system
i swear it did
just put their name in chat as player.getDisplayName()
but i already have a chat system
i need the prefix above the head
sorry
suffix
suffix is the same code, just add it after
setDisplayName() really doesn't change much outside of chat plugins and the tab list
its not as easy as saying p.setcustomname and you have changed the player name (above the head). you need teams to do that and i'm wondering how to do teams 😐
ScoreboardTeams
exactly
You can do this with Bukkit's Scoreboard API. Bukkit#getScoreboardManager()
https://hub.spigotmc.org/javadocs/spigot/org/bukkit/scoreboard/ScoreboardManager.html
From there, getMainScoreboard(), operate on it
guys
You can register teams there and manipulate its prefixes/suffixes/colours, add players to it and you're good to go
t f
In that snippet there, you have no reason whatsoever to be using server internals
why is this nms
okay, so
Scoreboard board = Bukkit.getScoreboardManager().getMainScoreboard();
Team team = board.getTeam(player);
if(team == null) tam = board.registerNewTeam(player);
team.setSuffix(prefix);
team.addPlayer(player);
player.setScoreboard(scoreboard);
```iirc its like that
Looks about right
wha
Though you'll want to addEntry(), not addPlayer(). The latter is deprecated
team.addEntry(player.getName())
ohk
Also don't have to Player#setScoreboard() if I recall correctly, though it's been a while since I last used the scoreboard API.
Yes you probably do
that's what I did at least
Worth trying both with and without 🙂
yeah
If it works without setting, bonus. If not, set it
what is MethodHandle
what are you doing?!
Learning
whoa my code is so much shorter
vector3 what is that
the suffix requires a space iirc
my version is 1.12.2
at the start
yeah and
what do you mean with the method lookAt
oh ok
nothing i got the wrong api xD
just use the code i sent you, that makes the armor stand look at the position you want iirc
is just a method to make a entity look a direction ok
(it will look at the player)
wouldn't this code interfer with other plugins?
my problem is because i dont normalizale the vector?
no
what is pos
i renamed pos to dir and forgot to chang ethat
change that*
is stream normally faster than forEach? It seems to be 4x faster for me
this ill return a location too not a vector
is there a build in method to check what hand broke a block?
Depends on what you're doing. If you're just using a stream to for each, don't 😛
no it wont
Always the main hand, Pray. You can't break blocks with the off hand
it seems to be because it uses a spliterator
xd
I mean I did a check and forEach took 12ms on a small build and 6ms using stream
.
lemme fix it
done
i already know it
yeah
i just telling him ur mistakes
continue dontr working
is not the problem with the vector
no errors
and some problem that i don't know what it is basically armor stands rotates only when i new abruptly
wdym
From then on it starts to spin, soon I'll make a video that explains it better, this is annoying
how do i check if an item is consumable?
When i spawn the method makeLook os calling but the armor stand dont rotate
is there a preset list or smtn
i don't remember
wait
can't find it myself
Is there a way to fake a player relog? I want to make the server think that the player has left and rejoined the server.
I need to update the player after changing their uuid
I needed to change uuids to allow players to have different save files
essentially creating an entirely new player
persistentDataContainers aren’t affected by permissions, right?
that’s what I figured 😂
DataContainer
Does Java have any class implementation that allow me to do a consumer 2 values and then executing a function (if string, be able to catch that return).
So be able to do:
public void test() {
Consumer<T> consumer = new Consumer(Void);
consumer.accept((value-1, value-2), () -> System.out.println("My String"));
}
My most importante method should this one
public String replace(String text) {
return consumer.accept((value-1, value-2), () -> text.replace(value-1, value-2)).get();
}```
Im trying to recreate exactly
Yeah, not sure what you're trying to do in that first argument, but that looks like a BiFunction to me
BiFunction<T, U, String>
Whatever T and U are
2 inputs, 1 output
But BiFunction doesn allow you to do get()?
Wrap it in a Supplier then I guess 😛
The BiFunction returns the String so the get() is unnecessary
Ohhh
You can actually even do string::replace and that would be a BiFunction<String, String, String>
(or CharSequences, I can't remember)
There’s also BinaryOperator but ye
Depends on your inputs
Indeed
Oh im the same
I will prob endup doing a custom implement of Hasmap with custom forEach
😮💨
Basically a lambda-ified variable replacement
Ehm, off the top of my head I can't think of a great way to do that
There's probably something like a StringBuilder or StringBuffer you can wrap your string around to manipulate the chars mutably
(the former two only accepting indices, not CharSequences)
So it isnt possible doing a BiFunction with a supplier?
Probably not, no. The immutability of strings makes it pretty difficult to do unless you write some sort of wrapper around a String that would make it "mutable"
Not too hard, I guess.
public class MutableString {
private String string;
public MutableString(String string) {
this.string = string;
}
public void replace(CharSequence find, CharSequence replace) {
this.string = string.replace(find, replace);
}
public String get() {
return string;
}
}```
Oh
MutableString mutableString = new MutableString(string);
map.forEach(mutableString::replace);
return mutableString.get();```
That's probably a way to do it, though it's not super pretty lol
Oh GREAT
I don't actually know if that will work. That was just written here
OHH
THANKS
Im wondering doing this since "Enero"
I dont remeber how its called in English
January? The month?
o/ Take that class with a grain of salt. While that might be a clean way to write it there's probably a more efficient way to go about doing that.
What is “String…” in methods? I’ve seen it in the past and was never able to learn about it
It will probably still be better to use a StringBuilder in there
varargs.
String... means String[] it is another way to specify that it is an array
String... args String[] args String args[] all mean the same thing
except you can pass them in a lil different
Hey all, in case someone would like to use Hibernate along with Spigot I have created a simple demo plugin for that :]
https://www.spigotmc.org/threads/hibernate-orm-in-your-spigot-plugin.547594
Its called varargs, pretty much same as array :]
But its not commonly used. Its an old java feature.
well, i use that
I mean, its a user preference more less 😄
The main difference between String... and String[] is this
//String...
public void myMethod( String... foo ) {
// do something
// foo is an array (String[]) internally
System.out.println( foo[0] );
}
myMethod( "a", "b", "c" );
// OR
myMethod( new String[]{ "a", "b", "c" } );
// OR without passing any args
myMethod();
//String[]
public void myMethod( String[] foo ) {
// do something
System.out.println( foo[0] );
}
// compilation error!!!
myMethod( "a", "b", "c" );
// compilation error too!!!
myMethod();
// now, just this works
myMethod( new String[]{ "a", "b", "c" } );
what version of java is needed to run spigot 1.8.8
Hope that helps answer your question @tranquil viper
1.8 is generally recommended for that version
Can i use java 11 for spigot 1.8?
you could probably use Java 11 to run it, but to build/compile need java 8.
Why its not posible to use this way in constructor:
public ClassName {
public ClassName(String[] string) {
}
}
public ClassTwo extends ClassName {
public ClassName() {
super({"0", "1"});
}
}```
Ah thank you for help
because you need a new instance for the string array.
the first example might work though with super, never tested it
not usually something I need super for lol
I used it as an example
Anyone know how to lay a player on the ground using protocol lib 1.15.2
Probably have to send a packet to other players that says the player is sleeping in a bed
Thats a fact
Huh, I have no idea how to rerun a future task until the result meets a certain condition
Could you elaborate?
I have this
int x = random.nextInt(Config.randomTeleportMinRange, Config.randomTeleportMaxRange);
int z = random.nextInt(Config.randomTeleportMinRange, Config.randomTeleportMaxRange);
Location location = new Location(player.getWorld(), x, 0, z);
PaperLib.getChunkAtAsync(location, true).thenAccept(chunk -> {
location.setY(location.getWorld().getHighestBlockYAt(location, HeightMap.MOTION_BLOCKING_NO_LEAVES));
player.teleport(location.add(0.5, 1, 0.5));
});
``` But I want to keep retrying if the found location is a liquid
Don't look at the paperlib~
Isnt possible to do it all in-line?
And what are you trying to do?
Keep re-running it if the target location is a water block
The x and z don't change, do they?
Well, I would re-randomize them
just reschedule the task from within the task?
public CompletableFuture<Location> thing() {
Location loc = randomLocation();
return loc.getWorld().getChunkAtAsync(location, true).thenApply(c -> {
loc = loc.getWorld().getHighestBlockAt(loc).getLocation();
if (!loc.getBlock().getType().isSolid()) {
return loc;
}
return null;
}).thenApply(l -> l == null ? thing() : l);
}```
Something like this
It's not the prettiest but it should keep going until it finds a spawnable location
Hmm
thing(player.getWorld(), random).thenAccept(obj -> {
Location location = (Location) obj;
player.teleport(location.add(0.5, 1, 0.5));
});
``` only works when it succeeds the first time
Also it makes me return CompletableFuture<Object>
My happy ending 🙂
Why do you need this
What does build do
string.replace()
Other solution?
I gave you one the other day and you apparently ignored it
StringBuilder is probably the answer here
It's part of it
But it need more than 1 line
Or not?
I did say StringBuilder earlier and it appears Redempt gave you something better 😛
lul
Go with your terribly-optimized solution that's going to lag out a server if it has to handle a lot of placeholders
Because at least it's one line, right?
It will not support placeholder from multiple plugins
It just for the plugin config
🤔
Then why is it even a map
And what are you replacing anyways
I don't get why you're replacing fixed strings with other fixed strings, how would that even work as placeholders?
Are you reconstructing the entire map every time?
You're not using it as a map at all, it's just a series of string pairs
Maps shine when you need to do lookups but you're only doing iteration
Oh
MapUtil<String, String> vars = new MapUtil<>();
vars.put("{name}", "alex");
vars.put("{age}", "16");
String text = "{name} is {age}";
System.out.println(vars.forEach(text));
Hmn
...
Why
Are the placeholder values dynamic?
You're building a map every single time?
No
So they're static
What
its class annotated with @Singleton and there its the map
But where do the placeholder values come from
Is this just going to always replace {name} with alex no matter the context?
So you do rebuild the map every time
Well fuck, man, you can't have it both ways
The map never get recreated
Not what I mean
Hmn
I mean you have to go back through and change all the placeholder values every single time
Really not sure why you would make something like this a singleton to begin with
Especially not sure why you would make it parameterized when you're always going to be treating the keys and values as strings
Hmn
I would love to use something like Set<T> but instead being Set<K, V>
So i can use the lambda expressions
What
What do you mean "so I can use the lambda expressions"
What would a Set<K, V> even be
A set of pairs of values?
Because you can do that, you know
I need key-pair that allow me looping and returning
But man it is very frustrating trying to help you
If that its possible i can use it
Because you're focused solely on trying to use lambdas and write short code
And it's coming at the cost of performance and sanity
And I gave you a clean, performant solution, but you rejected it because it wasn't a one-liner
Hate to break it to you but sometimes you will need to write more than one line of code, and sometimes you won't be able to use lambdas
That hurts to look at
b-but short code = better code
nms is top-model code
Oh thanks for yours words redempt
I ill try to change
I really apreciate your time and sorry i lost your time
average python user
in python thats usually true
Redempt would you recommend me doing forEach or iterator (I have deleted the class) ?
the virgin snake divelopar vs the chad coffee devloper
Can someone please tell me why 10*(2^(1)) returns 30?
Yeah
What do you mean
^ is bitwise xor not exponentiation
You want Math.pow
2^1 = 3
I will do it with java stuff
But im between iterator or forEach
The simplest way to do it is with regex
what is your goal
All your placeholders are {somethingHere}, right?
They do basically the same thing
You can have a Map<String, Supplier<String>>
yeah
I rember that you sent some weeks before
Map<String, Function<Player, String>>
This would be to?
So you could use regex to match the placeholders, then get them by name from the map, then replace the values
😮
Function<Player, String> would be to send directly the message?
Oh allright
For example, you would map {name} to p -> p.getName()
Can I calculate math equalations with that?
Or Player::getName
Of course
10*Math.pow(2, 1)
equalations has been added to my vocabulary