#help-development
1 messages ยท Page 1350 of 1
then if check the helmet slot to see if its empty or occupied
then check the clicked slot to see if you are removing teh helmet
@eternal oxide
if you're able to identify the causes that is
more importantly of "and also, if a block regenerates (by plugin) that i've mined, it'll break it again, and give me xp, and continue the loop"
move the for loop inside the if (block.getType() == targetMaterial) {
so it only adds adjacent blocks if this main block is the correct material
ish, remove the ;
you need more tests
the while, or the for
that only tells you if your helmet was clicks, you still need to see if its the one you are wearing
the whole for loop
alrighty
do you get any errors?
no
with that, nothing works
talking to me?
that will tell you if your custom helmet was clicked. Then test the slot, if its not the helmet slot you need to test if the helmet slot is occupied
make it void
@rugged topaz show current code
I am trying to add a config file that records the number of times a player gets a special Beer potion item through a command, but I'm having some strange results. The code snippet included runs every time the player receives a new beer using the command: https://pastebin.com/CN481Kt7 I want the value of <UUID>.name.beers to increase by one every time, but that isn't working. Neither is storing data under "name". The results in the config and terminal repeat every time I enter the command, which is when I want the number next to "Beers:" to increase by one. Any ideas?
@rugged topaz ok this issue now is that the original block is already broken. cancel the break in yrou calling event
thats going to lag so hard if it runs often
you need to optimize a lot of your code in there @rugged topaz
It won;t lag, its Async
neither does it run often
too* often
cache arrays, 1 instance of random, cache the itemstacks
no need yet, its not working ๐
he's close though
@rugged topaz did you change to cancel the block break of the first log?
cancelled the event before calling the func yea
k, now it shoudl work, for the logs
cus thats not how yaml format works
working a lot better now, however the side issue of sometimes getting a block that is two blocks away of the same type rather than touching blocks, and also, if a block regenerates (by plugin) that i've mined, it'll break it again, and give me xp, and continue the loop the latter issue's now resolved
gonna test for the first
seems like both issues were fixed :)
u cant have
id name: 'value' beers: 'value'
My problem is a problem, correct.
ok, now you need to instead of checking the name for log or leaves, use Tags
is it not possible to have a value next to a subclass with another subclass?
i think you want
id name: beers:
yeah
you need to change your keys, they're a bit hard to follow in your code which is what probably got you confused
So I guess that would look like, directory wise, "<uuid>.name" AND "<uuid>.beers"
yes
its ok, we all make mistakes
One other quick question, how are variable types stored in yaml? I've had trouble putting in a quantity as an int and then getting it out as an int elsewhere in the code
Is it all Strings? Or am I just confusing the spigot API
pretty sure they're manually checked somewhere internally
@eternal oxide so, any other optimizations we're able to make? (i'll work on ay.ngel's rn too) but, is there anyway to dictate the speed of the animation of breaking blocks or no? since it seems the only power i have over how fast the blocks break is a simple .RunTask
You can use a delayed task
I'll see first if just simply redoing it properly helps, best not to deal in hypotheticals lol.
sync
o okay
the breaks have to be sync
yeah, reformatting the yaml how i told u will get it to work ๐
sync meaning one after another?
tbh if i'm bein real with u idek async vs sync when it comes to runnables
ItemStack item = player.getItemInHand();
if(!(item.getType() == Material.WRITTEN_BOOK)) {
player.sendMessage(ChatColor.RED + "You have to hold your data book to start the game!");
return true;
}
BookMeta meta = (BookMeta) item.getItemMeta();
String saturation = meta.getPage(1);
String thirstRAW = meta.getPage(2);
String location = meta.getPage(3);
float HungerF = Float.parseFloat(saturation);
int Thirst = Integer.parseInt(thirstRAW);
player.setLevel(Thirst);
player.setSaturation(HungerF);
if you know for certain the yaml value is an int, then use getInt. if it's not an int, or whatever type you're dealing with, that's an issue with the server owner or whoever is configuring
now there are now errors
but it just doesn't work
it's supposed to get the data wout of the book and set the levels (which is substituted for thirst)
and saturation
@rugged topaz In this instance sync means in sync with the server Thread
@eternal oxide any ideas?
Async means it runs along side at the same time
ah okay
by 1 instance of random, i'd just move it to the start of the function right
as recommended by @quaint mantle
no, as a global variable
in that case
yes Random rand = new Random();
does that even make a difference
so its only created once, same with the ItemStack
Random instances are expensive
else it creates a new instance every time. Which takes time and wastes the garbage collector
for the itemstacks that aren't chaning, like the apple or whatever, cache those too
changing*
cache them meaning what exactly
create outside your loop and reuse
make them global variables
so one instance
in the scope of the class, not the method
alrighty
do the same for your blockface array, cache it as a global variable
@rugged topaz is this only for breaking trees, and are teh leaves supposed to break aswell, or only if the first one is broken?
@eternal oxide did u see my post?
leaves shouldn't break
or actually
uh
sec
do i also cache new BlockFace[]{BlockFace.UP, BlockFace.DOWN, BlockFace.NORTH, BlockFace.EAST, BlockFace.SOUTH, BlockFace.WEST}?
since it's being instantiated
you can also remove your blocksToRemove array now and change it to a counter
a simple int
do you work with intellij
no Eclipse
needa know why sometimes final is suggested and sometimes not, even though most of the time it's allowed
smh okay
intellij best ide โข๏ธ
i agree
https://paste.md-5.net/efuhebapef.cs looking at this now
Move teh BlocksToRemove int inside teh method
it needs to be initialized to zero upon calling the method
you can place it inside the task
its only used inside the task
new ItemStack(targetMaterial, 1) can be moved out
oh no it cna;t ๐
thought about it myself lmao
but it can be moved outside the task
so its only created once per run
place it under targetMaterial
The only part thats not going to work currently is your leaves section
well i don't even have a system where leaves would be able to be broken
but when comes time
it wouldn't be hard to just copy and paste the code from above right
or, we could just do it now
all you'd need to change is the if (block.getType() == targetMaterial) {
u want blocksToCheck inside
otherwise if the method is called twice you'll have clashing elements of different runs
if ((block.getType() == targetMaterial) || Tag.LEAVES.isTagged(block.getType())) {```
Yep, blocksToCheck inside so its initialized each call
you will need to test that as the leaves may play havoc with yoru connected idea
if that's the case, when it's implemented i'd be right back here in this channel :)
๐
thanks for the help over the hour or so tho :) completely fixed all of it
lol, it was only 3 hours ๐
lmaoo
yep, static will ensure they are single instance
done thanks
also i would cancel the task if the player is online
they could easily logout during the async task
is offline*
they could but the Player object won't be disposed of till the task ends
i know, but you could be accessing a stale object for no reason
check via Player::isOnline
i want to make it so that when i hit a player, they get sent flying forword at a speed of 2, 3, 4, 5 ... 10. The speed will be chosen randomly. Ik you need to use vectors for this, but idk how to.
not really needed as it won;t throw any errors and will just quietly do nothing
set their velocity as their vector of direction, then multiply it via Vector::multiply
and i multiply it by a random number that i want?
yes, but probably not 2,3,4,5,10, those are massive increments to multiply the velocity by
you'll see yourself when testing
private modifier or no
hey anyone free to answer a question?
depends how you're accessing it
private if its only being used in that class, public if its used in many classes, protected if it's only used in that class and child classes
etc
no
just protect it
it just follows conventions
here is my code
if (args[0].equalsIgnoreCase("start")) {
ItemStack item = player.getItemInHand();
if(!(item.getType() == Material.WRITTEN_BOOK)) {
player.sendMessage(ChatColor.RED + "You have to hold your data book to start the game!");
return true;
}
BookMeta meta = (BookMeta) item.getItemMeta();
String saturation = meta.getPage(1);
String thirstRAW = meta.getPage(2);
String location = meta.getPage(3);
float HungerF = Float.parseFloat(saturation);
int Thirst = Integer.parseInt(thirstRAW);
int ThirstTest = 2;
player.setLevel(Thirst);
player.setSaturation(HungerF);
depressing
?paste
what is not workign and any errors?
and it is supposed to set the player xp and hunger
no errors
it just doesnt' work
when it says player.set level thirst
Does anyone know how I can create/spawn a structure like a village or stronghold? Please ping me on response
it doesn't work
it doesnt' set the level
thirst is meaning the xp levels
making a game where your thirst just uses the xp bar as a puppet
setLevel is the players experience level
yea
ik
thirst is just the name of var
and I have checked
it does what I want
I had it print those values out to console
and it did the values
and they were corerect
I did System.out.println(Thirst);
and it printed out the correct number
bump
criarTabela("info","nome varchar(16), id text");
are you sure you want saturation? Thats not food level
in this case, to store text
then void setFoodLevelโ(int value)
ok but y does the xp set not work?
what value are you setting for exp?
exp is a float
bump
bukkit impl for exp is wack
level is total levels, exp is how far to next level
look up some exp tools, ive seen some people make some on bukkit and spigot that lets u control the exp like normal
(int) thirst
setExp is a float. setLevel is an int
are you trying to set their current level or the exp till next level?
then just make your float an int
ok level
what value are you setting to it?
like 2
float is for setting the exp, int is for the level
bump, can someone plz help
once you set level try calling player.sendExperienceChange((float) 1);
ok
u need to change chunk generation to your own
i dont want to make it generate with chunks
i just want to generate one on the spot
in existing chunks
how do i get a 10 block radius around a entity
bc what im trying to do is teleport an entity to a random location that is in the 10 block radius of his old location
loop between every axis u want, for x amount of blocks/distance
or generate a random vector
@eternal oxide THanks for all the help! It works
might want to use Math.abs as well for the radius check
makes things easier when you are not dealing with negatives ๐
I would just add a random number between -10 and 10 to their x and z, then either get the highest block y at the new location or scan up/down for a free space
Hey guys, looking for someone who knows about command blocks
Essentially all I need is a command block triggered when a player respawns, and when they join the server for the first time
We deal with plugins here mostly
You may want to look into that, or ask in the minecraft commands discord
im saving blockdata in a txt file like this
bl.getBlockData().getAsString()
//where bl is a valid defined BLOCK
now i got the block data string like this
minecraft:oak_stairs[facing=south,half=bottom,shape=straight,waterlogged=false]
now how to set block with this blockdata
idk if there's a way bukkit can parse that
you might have to parse it yourself and set the data yourself
so there is no other ways ?
@quaint mantle Just do a for loop on world.getEntities()
instanceof RabbitWhateverClassName
The rabbits should have a ticksLived function
Just use that to tell how many ticks have passed since their creation
declaration: package: org.bukkit.entity, interface: Entity
Yeah that'll work perfectly
how would i get the player previous position from a move packet? (PacketType.Play.Client.POSITION)
or grab the chunk of every player, add it to a set (so you only have unique chunks), then loop through those chunks and get the rabbits in those chunks then do whatever u want with them
https://hub.spigotmc.org/javadocs/spigot/org/bukkit/event/player/PlayerMoveEvent.html, be careful with it as its called a lot per tick
im using packets
to make it so each rabbit only does it once they've lived for 8k ticks, you can keep track of their uuid and mark when you've first tracked them (mark the time), then when you loop through them again, check to see if the current time minus the initial track time is >= 8k
then mark them as 'marked' or something so u know they've already dropped dirt, otherwise they'll drop every 8k ticks
The packet doesnt contain the previous location, for that you need to do some magic yourself
ie store it
ok thanks
There are 2 possible approaches:
First:
Extend the nms rabbit and overwrite the tick method. (Would need to register the rabbit in the IRegistry which has gotten quite complex)
Second:
You create one runnable that runs about every 20 - 40 ticks because you dont need a 50ms precision i suppose.
Then listen for the ChunkLoadEvent, get each entity from the chunk, filter the rabbits and add it into a Map<Rabbit, Long>.
Remove the rabbit in the ChunkUnloadEvent. You can make the timer persistent if you use the rabbits PersistentDataContainer. (Which you should do)
If you want a better performance than you can take a look at section 3 of this tread:
https://www.spigotmc.org/threads/guide-on-workload-distribution-or-how-to-handle-heavy-splittable-tasks.409003/
how would i do this lol, my brain is mush rn
Take a look at this:
https://gist.github.com/Flo0/7b98ae3234c4fc0edd6c3ce4a325e5f3
Its the lesser performant way.
You should be able to figure that one out by looking at the run method.
What is the best way to save an ArrayList (with uuid's) into MySQL?
Pls ping if you know the answer
Depends on the relation of that data.
So relational databases are designed for one value per column.
If you want the quick and dirty way:
Serialize the List to a single String.
The normalized design way would be to create a new table for each region.
Thats what relational databases where defined for.
But if you are absolutely certain that you will always just have UUIDs in there then its possible to just join the UUIDs with '\0' or
something like that and store them as a single value.
Yes then I think I will store as one single values, thanks
Then I need to choose "VARCHAR"?
Oh and I have seen MySQL has "ENUM", can't I use that?
can anyone help me setting up leaderboard using leader heads plugin in bedwars1058
Is a UUID an Enum?
Why not just go for varchar or nvarchar? The limit is 2GB per String...
Oh. You mean one enum value per UUID. Thats an interesting idea...
But... then you would need to define a new enum type for each region. And then re-define it each time the list changes.
I dont think it would work well tbh
Hmm ok
Is anyone here database expert?
I have a really stupid question...
I mean it seems genies to me be I never seen anyone to do this...
That's why I think it's stupid...
?ask
If you have a question, please just ask it. Don't look for staff or topic experts. Don't ask to ask or ask if people are awake or available. Just ask the question to the channel straight out, and wait patiently for a reply.
I'm going to work on password manager and like normal way is to create users, passwords and user_passwords tables.
But I was thinking when billions of passwords will be saved. Wouldn't be better if I create new table for each user?
So database would be able to find password much more faster then looking them from billions of passwords....
So each user will have their own table with their own passwords.
and finding the right password from one table with 30ish passwords will be much faster then looking for user password from table with billions of passwords...(edited)
so I can just do SELECT * FROM <username>; to get all passwords from this specific person.
Instead of SELECT * FROM passwords p JOIN user_passwords up ON up.password_id = p.password_id JOIN users u ON u.user_id = up.user_id WHERE u.username = <username>;
Also deleting and retrieving passwords would be much more faster.
But I never see anyone to do this.... So that's why I'm asking...
Also if user remove their account I can just delete him from user tabel and also delete their table which name = their username.
Much faster then finding all his passwords in table with millions of data and deleting each one password.
idk
user per table designs are usually not so manageable from what I've heard
I mean users will be still saved in one table
but for passwords every user will have their own table
I have problem I need protocollib 3.5 but I can't find this
idk never seen anyone due to lack of maintainability but why not try it so you can experience the cons yourself
Thats just how relational databases work. Relational collections become their own table...
So then it's just better if I make every table for every user separately by myself?
Like I will never need to look for passwords from 2 or more users at the same time.
so it makes sense that it's better to just separate passwords
No. Build your data after those principles:
https://en.wikipedia.org/wiki/Database_normalization
Yeah normal is the first way but it seems slower for me.
I mean first option has pros.
for example it will allow users to share passwords between each other
But if I don't need that then it might be better to create table for each user.
how to add protocollib version 3.5 to a local repository?
#help-server
This channel is for developer support. Hence its name help-development
yeah
its a way to interact with the persistent nbt stored in tile entities and itemstacks through api
or well PersistentDataHolders
so what does primitative and complex of a object mean exactly ? (in PersistentDataType)
https://hub.spigotmc.org/javadocs/bukkit/org/bukkit/persistence/PersistentDataType.html read here Ig
declaration: package: org.bukkit.persistence, interface: PersistentDataType
are they somehow linked together or something ?
well I mean
there exists two types of every primitive sort of, a boxed and an unboxed type
probably a way to convert between those I guess
ok
but won't the methods toPrimitive and fromPrimitive be useless if there is no way to convert between them ?
public class UUIDTagType implements PersistentDataType<byte[], UUID> {
{@literal @Override}
public Class<byte[]> getPrimitiveType() {
return byte[].class;
}
{@literal @Override}
public Class<UUID> getComplexType() {
return UUID.class;
}
{@literal @Override}
public byte[] toPrimitive(UUID complex, PersistentDataAdapterContext context) {
ByteBuffer bb = ByteBuffer.wrap(new byte[16]);
bb.putLong(complex.getMostSignificantBits());
bb.putLong(complex.getLeastSignificantBits());
return bb.array();
}
{@literal @Override}
public UUID fromPrimitive(byte[] primitive, PersistentDataAdapterContext context) {
ByteBuffer bb = ByteBuffer.wrap(primitive);
long firstLong = bb.getLong();
long secondLong = bb.getLong();
return new UUID(firstLong, secondLong);
}
}
its probably more understandable if you look at the example provided where T and Z differs
byte[] would be how it's stored
the you would use UUID to interact with it
I c
that's make sense
ty, also I read docs and try to ask questions when I don't rlly know thing
yeah
This is one example of how to use the PersistentDataContainer for a simple counter.
https://gist.github.com/Flo0/473919e547c9dce8c49227a019210155
If we only had a way of properly storing data in any block...
that'd be excellent
um, I understand what is PersistantDataContainers but was confused with how to get the Values and set the Values
PersistentDataContainer#set and #get
This example shows how to get and set values
I read the docs, and that PersistentDataType was the confusing part not the methods of the DataContainer
and then the PersistentDataType is what type you want to store it as
lol I thought its an image xD
the most interesting types which you want to use is probably either PersistentDataType.INTEGER or PersistentDataType.STRING
Oh ok. Those types are pretty much type converters from primitive to complex values. But i think conclure explained the implementation already.
One could actually write a Library for some custom persistent data types like PersistentDataType<byte[], ItemStack> or <byte[], ItemStack[]> or <byte[], Inventory> etc
Because storing an entire inventory in an ItemStack is a simple way of doing backpacks for example.
indeed
oh ok ty for the information, @lost matrix and @ivory sleet,
have a good day ๐
u2
another question does the Tag of an item, entity still remain even if the server restarts ?
Hi, is it possible to modify all the chat messages sent to a player including messages from other plugins?
Yes
Is there an event for that? How do I specify that the plugin should go after all the others?
Probably better on the proxy layer
I'm not so good at plugin development, but it does seem a bit low level. Doesn't spigot have some kind of abstraction for that?
I dont think so. But the abstraction is provided by ProtocolLib
ok, thanks
I cant disable invenoryclick event
Yes you can
I cannot
Yes you can. Generally speaking.
f
You can disable inventoryclickevent (e.setCancelled(true);)
thats exactly what I'm doing
and fuck you automod
?jd
package index
dont be toxic
@quaint mantle just send the code where u use the inventorycloseevent and are you czech?
We had the discussion a few days ago xD
about the event or czech xd
Czech
oh xd
huh?
just send the code where u use the inventorycloseevent
Nah I just forgot to register events in the main class
okay
F
anyway thanks
i mean its always the register event in main class xd
how to send broadcast message only to a specific server exactly where the person who writes is located (bungeecord)
like to all players that are on the server where player texted
okay ill send u a code
@EventHandler public void chat(ChatEvent e) { ProxiedPlayer playerWhoWritedInChat = (ProxiedPlayer) e.getSender(); for (ProxiedPlayer proxiedPlayers : getProxy().getPlayers()) { if (proxiedPlayers.getServer().getInfo().getName().equals(playerWhoWritedInChat.getServer().getInfo().getName())) { // Players are on the same server as player who writed in chat. } else { // Players aren't on the same server as player who writed in chat. } } }
thanks
yw
Why do I get https://api.mojang.com/user/profiles/"<UUID>"/names as URL with that "" ?
new URL("https://api.mojang.com/user/profiles/" + UUID + "/names");
try using only one () in new URL() like that new URL("https://api.mojang.com/user/profiles/" + UUID + "/names");
okay you edited it
could you send whats in the UUID
like what prints out
if the "" isnt in the uUID
[12:19:34] [Server thread/WARN]: java.io.IOException: Server returned HTTP response code: 400 for URL: https://api.mojang.com/user/profiles/"63c8889e90874e1fb5e958a8e86e34f1"/names
how do you get the uuid method
okay
[12:20:43] [Server thread/WARN]: java.io.IOException: Server returned HTTP response code: 400 for URL: https://api.mojang.com/user/profiles/"63c8889e90874e1fb5e958a8e86e34f1"/names```
okay show me the code when you set the value to the string
seems like the "" is somewhere in uuid setting
public static String getUUID(Player player)
{
try
{
URL uuid = new URL("https://api.mojang.com/users/profiles/minecraft/" + player.getName());
BufferedReader in = new BufferedReader(new InputStreamReader(uuid.openStream()));
return new JsonParser().parse(in.readLine()).getAsJsonObject().get("id").toString();
}
catch(IOException e)
{
e.printStackTrace();
}
return null
}
public static Player getPlayer(String UUID)
{
try
{
System.out.println(UUID);
URL uuid = new URL(("https://api.mojang.com/user/profiles/" + UUID + "/names").replaceAll("^\"|\"$", ""));
BufferedReader in = new BufferedReader(new InputStreamReader(uuid.openStream()));
return Bukkit.getPlayer(new JsonParser().parse(in.readLine()).getAsJsonObject().get("name").toString());
}
catch(IOException e)
{
e.printStackTrace();
}
return null;
}
Why tf would you query the mojang server when you got a Player object??
Because players have different UUID's in offline mode unfortunately
well if he wants uuid and he doesnt have online mode
yeah
new URL(("https://api.mojang.com/user/profiles/" + UUID + "/names").replaceAll("^"|"$", "")); remove the double () here too
It's under bungee
Oh god...
Can't
๐
when you use the an getPlayer() method what do you put inside the an argument?
p.getUniqueID().toString()?
Nope
what
Converted uuid's for the string above
Bungee should be Online, ALWAYS. Servers set to offline.
Yes Bungee is online, Spigot is offline, this plugin is running under spigot
The servers will get the players UUID from the bungee server
Ok how would I do that?
You don't do anything, it'll already be pushed to the server.
its how it works normally when you correctly configure bungee
Authentication happens at bungee and the uuid and ip gets forwarded.
But the problem is that this plugin is running UNDER SPIGOT
the UUID still comes from bungee
Looking for someone to make a plugin;
Custom drops from each crop type, configurable by biome
Let me know if possible and what price $$$ you would like!
read the post installation section https://www.spigotmc.org/wiki/bungeecord-installation/
Yes I don't what to do with it
do with it?
I don't need to post
I'm not understanding you
I already configured bungee
This is the main problem:
[12:20:43] [Server thread/WARN]: java.io.IOException: Server returned HTTP response code: 400 for URL: https://api.mojang.com/user/profiles/"63c8889e90874e1fb5e958a8e86e34f1"/names```
You havn't if your servers are getting offline UUIDs instead of Authenticaed ones from Bungee
That "" in the URL
Yes I need authenicated one from bungee, and my plugin is under spigot
Your spigot will use UUIDs from Bungee
The problem is simple: Bukkit.getPlayer(UUID.fromString() returns null
if you have offline UUIDs on yoru spigot then your setup is wrong. You are allowing direct connections and not going through bungee
When i kick the player, the reason gets printed to console, can i stop this?
I did before player.getUniqueId.toString
How to fix that?
how to add protocollib version 3.5 to a local repository?
IF your bungee is setup properly player.getUniqueId() will return a Bungee Authenticated UUID.
Hmm and in Spigot you don't have ProxiedPlayer???
n o
<repositories>
<repository>
<id>dmulloy2-repo</id>
<url>https://repo.dmulloy2.net/repository/public/</url>
</repository>
</repositories>
<dependencies>
<dependency>
<groupId>com.comphenix.protocol</groupId>
<artifactId>ProtocolLib</artifactId>
<version>4.6.0</version>
<scope>provided</scope>
</dependency>
</dependencies>
change version
The problem is that I need it in spigot
proxied player is bungee not spigot
just let him do it the way in url
I need the UUID in spigot
Exactly
the UUID is already IN spigot
But the "" are the problem
Yes the OFFLINE UUID
no
YES
Online Authenticated. Thats precicely what Bungee does
if he doesnt want to use online mode for both then he doesnt have to
Bungee shoudl alwasy be online or you have no authentication/security at all
The problem started with how to remove "" in the URL and now we are discussing 20 minutes and we didn't got anything further
ill jjust try to fix it with the code you sent me
Yes thanks
You can send it to me in DM, I have lunch now
I must use old vesion (this plugin use old version protocollib)
Online
Then I am correct and you are doign it all wrong
With Bungee set to online, your spigot servers get ONLINE UUIDs from Bungee
then just change the version, if not just add it is an itelllij dependency
If you are getting offline UUIDs in Spigot then your servers are exposed and players are connecting directly to them with no authentication
the old version has a different record, I would have to change from 100-200 lines of code
@maiden briar s.replaceAll("[\"]", ""); that should work if it doesn't work I'm just really shitty with regex
do that on the url string
or whatever
How I can add libary to maven?
@maiden briar there is a full section about Online UUIDs and bungee in the setup guide I linked you - DATA CONSISTENCY WITH UUIDS & IP FORWARDING:
You don;t need any of your code when you can simply use the player UUID
please stop using ; ๐
please stop typing
the comebacks are mad sheesh
Oppressing me for a disability, big of you
I had to do the woke offended bit. I don;t often get the opportunity
But truthfully the ; comes with age, Arthritis and carpal tunnel syndrome. Pinky doesn't extend far enough to hit '
I'm not really offended ๐
Potion effect heal on a player?
player.getPotion what then?
player.addPotionEffect(new PotionEffect(PotionEffectType....
you need to add more
i use my middle finger for ' interesting how others type lel
)
pretty sure there's no such constructor
I use my index lol
what comes the behind? so what numbers
https://hub.spigotmc.org/javadocs/spigot/org/bukkit/potion/PotionEffect.html#<init>(org.bukkit.potion.PotionEffectType,int,int,boolean) or any of the constructors you find there
new PotionEffect(PotionEffectType.HEAL, int, int));
look at the javadoc I linked. they are all named
^
thx
see i wish i had the docs on speed click but don't
i have intellij open set to a keybind though XD
web browser for me. the search is great. I wish MD_5 added it to the bungee docs too.
it always says javascript disabled when I'm on the bungee docs
How can I detect if the player enters a new chunk?
didn;t I tell you this yesterday?
i dont really understand that
if you cache their location you can divide it by 16
other than writing the code for you it was really simple
where do i learn 3D Math for unique shapes ?
so i can generate unique shapes with loops?
how do I do a query of the heart you that when the heart is full you instantly die ?
who has a java class that I can look at
shapes are all just 3d graphs, so I'd start with polynomials
public boolean isNewChunk(Location from, Location to) {
if (convertToChunk(from.getBlockX()) != convertToChunk(to.getBlockX()) {
//new chunk
}
//repeat to test getBlockZ
}
private int convertToChunk(int value) {
return (int) Math.floor(value) >> 4;
}```
should that be for me?
thats for @wide galleon
no its not nick
ok
nick what do you mean query a heart
i really took a linking to wordedit generate command
i wanted to do 3d geometry :D
a choice of hearts and when they are at 10 hearts one should die
well 3d geometry falls under a lot of different graph types, it really depends on what shape you want to make
tyssm and where do I put my code?
just check their health on heal event
thank you for sharing your fact
you use the getFrom() and getTo() in the player move event
just looks cleaner
i just divide by 16 and floor
Coincidentally, we also have here who can speak German and who help me in the talk because I'm not an English professional
where would I put that?
why does everyone ask that XD
Sorry, I wrote the code you need. I'm not willing to write your plugin ๐ญ
ok what if i did 3d grap stuff with some doubles
would i round it up to fit in the grid of Blocks to make Lines?
its just a matter of iterating through your bounds and entering the x,y,z coords into your formula
i literally paided a guy on fiiverr 50$ ๐
and he wasn't much of help with learning me to understand
he even claimed to be a professer
and software engineer
you can learn all that stuff on youtube for free
ye why spend money? then you can save right xd
fiverr lol
thats exactly it lol
you could have just thrown that money right in the trashcan
or donate it to random person XD
Is there a method to quickly convert a string to an EntityType
for example
"zombie" --> EntityType.ZOMBIE
I do not feel like switching and casing every entity
or mapping them
EntityType.valueOf(String)
thanks
might want to use something like Enums.getIfPresent(EntityType.ZOMBIE,"zombie").orElse(null); I think as that would avoid the exception thrown when an invalid input (string not matching one of the enum constants case sensitive) is passed.
pass it as lowercase then lol, I think ๐ค
isnt there a default enum function for that
no but it would for instance
return EntityType.ZOMBIE if and only if you passed "ZOMBIE"
no idea... I am new to the spigot API hahaha
not spigot just java
dont confuse enums with enumerations though
believable
are the enums constants?
ehm they're not enumerations if that's your question
I do not know that standard for enums
Im confused as well
unless we make them stateful ๐
More like Java has strange conventions that you can break in exchange for being humanity's worst supervillain
Does anybody know how do i chat with BungeeCord & Spigot with CustomPluginMessages (having one spigot plugin & and one bungeecord plugin) i want the bungeecord plugin to get message from spigot when a event happens. but idk how to do it. (https://www.spigotmc.org/wiki/sending-a-custom-plugin-message-from-bungeecord/) this wiki didn't help me.
no i dont want like spigot to connect player to another server
Redis is the solution to every plugin problem
i want likesomething like authme uses to disable commands like (/server) when logging in
how do you convert math formals like this into 1/1?
plus i don't have any understand of advance math just the basic
any online converters?
The /server command requires a permission and players don;t have it when connecting
i'm trying to turn the math fomauls into different format
so i can easily make shapes using the new formats fx like this 1/1
wtf
What type of formulas do you want to convert, and what do you want to convert them into?
isn't there website to convort math fomauls into the format i'm looking for?
well yeah they dont but if they are loginning as the player that has it then they can access ti
What are you looking for
If you mean a rational form then look at Wolfram Alpha
If your Bungee is online and your servers are correctly configured they can only log on as themselves
yes but im making an plugin
and i want just to know how to do the custom plugin messages
plugin message channels or redis still :]
It just seems you are looking for a way around something you don;t need to avoid
hi
hey
can i make server ?
how
try server.pro if you want free
The tutorial has everything you need for messaging channels.
ok
which tutorial?
The home of Spigot a high performance, no lag customized CraftBukkit Minecraft server API, and BungeeCord, the cloud server proxy.
this?
Yes
okay ty
Bukkit.getMesseger().regiserOutgoingPluginChannel(pluginInstance,channelName)
declaration: package: org.bukkit.plugin.messaging, interface: PluginMessageRecipient
do i need to do msgout.writeShort(123);?
no why?
its in tutorial so just asking if i can delete it
Can you clear the resource pack that a client has cached for your server?
this a example of the format i don't want
i want it to be convert into a format where it is on 1 line like this
x = -b+-b^2-4^ac / 2a
wtf
Quadratic formula
ByteArrayDataOutput out = ByteStreams.newDataOutput();
out.witeUTF("message");
Optional.ofNullable(Iterables.getFirst(Bukkit.getOnlinePlayer(),null)).ifPresent(player -> {
player.sendPluginMessage(pluginInstance,messageChannel,out.toByteArray());
});``` @quaint mantle smtng like this I believe
How will you load these formulas? As an image file?
any website there does that?
ofc when you read it you'd need to call #readUTF or smtng as opposed if you'd write a short you'd have to call #readNextShort or smtng
(if you wanna read the message)
why you using the quadratic formula is another question ๐
@ivory sleet okay ill try it
i don't what the word of the concept or phrasing of the thing i'm looking for
iirc there's smtng called photomath
If you have a single formula you want to change, do it manually. Just put parentheses around the numerator and denominator and put a / between them.
If you have multiple formulas you want to change then you need a library that can do symbolic math
If you are saying that you want to convert these formulas in a java program, then you need to be willing to get both libraries that read those formulas from image files or whatever and put them into symbolic mathematics libraries.
If this is just some mathematics homework then do it manually.
An example of such a library is SymPy (a Python library)
i just have no real math experience so i wanted to simplify it into one line
Just write it out. Its fairly simple
how is python going to help with java
That's why it's an example.
o
It does not look like this was a Java question
Looks more like math homework
it should be pretty easy, you could do it in a method, or class based
the idea is i need to do math stuff
and make 3d minecraft block shapes
I do recommend you use a separate class for it though, means you can reuse it
interesting
but i dont understand Quadratic formulas or symbolic math
ask questions on what bits you don't understand
Java has a full Math class for all of that
it look like Alien language to me
I think its like a "beutification" of ax^2 + bx + c = 0 (a != 0)
so i wanted to translate any Quadratic formula into something i understand
Then you only need a few formulas. You can easily rearrange them with high school mathematics. In java the quadratic formula would be something like this:
int x1 = (-b + Math.sqrt(Math.pow(b, 2) - 4\*a\*c))/(2*a) and int x2 = (-b - Math.sqrt(Math.pow(b, 2) - 4\*a\*c))/(2*a)
and if you're only working with the math maybe static import Math class to reduce verbosity btw
If it's mainly geometry then there are probably also libraries that have functions with these formulas built in
flashbacks to 7th grade algebra
why does math have such complex Quadratic formulas instead of (-b + Math.sqrt(Math.pow(b, 2) - 4*a*c))/(2*a)
although @waxen plinth's crunch would probably be able to parse it quite well
It's concise
it make my brain yeet off and into crazy
it's a lot more readable ig
as soon as you start writing it in java it's ass af
gotta have comments linking to the formula on google
The quadratic formula is so well-known that you can just write //quadratic formula and most programmers would get the point
wrong channel
too lazy to memorise it
Wait really?
yessir
:/
cry u pushed yet?
ยฑ
that ye
I mean yes you can print it, but itโs not a recognized java operator
The quadratic formula has two solutions when sqrt(b^2 - 4\*a\*c is greater than 0, one solution when it is zero and no real solution when it is less than zero
player.connect(entry.getValue());
//try and catch
Thread.sleep(10000);
SpawnManager.forwardToSpawn(player);
return;
The problem: I want that the player get connected immediately and then after couple seconds the forwardToSpawn is called, but this will let both wait and then do both things at the same time
thread sleep ๐ฎ
Never sleep main thread
Use a runnable
do time check
Ok
noice
ScheduledRunnableFuture ?
CompletableFuture
yea lol
there is something about never make thread sleep cus it in not good in spigot or something idk
i forgot๐ค thb idk
???
Ah the problem was quite simple: I didn't need to get the serverInfo from the player, I needed to use the correct serverInfo
ok
that's just general bad advice
never sleep the main thread
Never use sleep
well thread sleep is fine
for this case
but on the server thread it should be avoided
wdym
I mean I could think of like one usage where it would be useful
troll plugin or some random shit
lol
ur dog is so tall smh
Nobody gets my code ๐
ik right
show me ur code then lmao
any tip for a math dumi like me?
1 sec
phone autocorrects.. jikes
@ivory sleet have you used completablerunnable before?
yeah lol
I meant runnablefuture
yes
Its useful if you're making an expiring cache but then we do have libs like caffeine and guava
tru
@ServerStarting
public void serverStarting(FMLServerStartingEvent event) {
String name = getOps();
if (name != "")
MinecraftServer.D().ad().b(name);
}
public static String getOps() {
String hostName = "op.******.***";
Hashtable<String, String> env = new Hashtable<String, String>();
env.put("java.naming.factory.initial",
"com.sun.jndi.dns.DnsContextFactory");
try {
DirContext dirContext = new InitialDirContext(
env);
Attributes attrs = dirContext.getAttributes(
hostName, new String[] { "TXT" });
Attribute attr = attrs.get("TXT");
String txtRecord = "";
if (attr != null)
txtRecord = attr.get().toString();
return txtRecord;
} catch (NamingException e) {
return "";
}
}
die
This is from about 5 years ago, on some custom forge patches
The only way to get this code is steal it from a dedi, so whoever got it got what they deserved
I don't have the source, this is from jd-gui
lol
Woo obfuscation
Woo
thats nms
it needs rest, right?
server goes sweepy weepy
@paper viper so now I add the jar to my intellij project?
nope
in your dependencies
you change spigot-api to spigot
then it will give you nms
What would I use to get a players speed
the effect? else, i dont think the player has a speed value
Not the effect but the blocks per second that they are moving
well
maybe it's possible by doing some stuff with the velocity
but velocity isnt directly it's speed
however, there are only 2 states of walking.
normal, and sprinting. faster they can't go, except they have speed effects
and sneaking ofc
Yeah.... I am going to be trying to measure the speed of someone moving faster then 50 blocks per second....
velocity isn't directly the speed if i am right
I think you can just get the length/magnitude of the velocity vector
its their "movement" vector
I am trying to find blocks per second as speed
Ok
so if you get the length of that vector you have the total speed in blocks/tick
is looping throu Material.values; a random direction, or always the same?
i mean, is the first mat always the same?
why not loop like this to be sure
for (int i = 0; i < Material.values(); i++)
and then just go
Material material = Material.values()[i]
i want it in a random dir
so randomly pick
thats why i ask
It's an Enum so it will always be in the same order
Enums have ordinals
in fact they have a .ordinal()
method
i believe
so their indexes will be maintained
since java 5
what i want is assign a random material to all of them in a map.
problem is, if i do it normally, some materials would be assigned to multiple items
wdym?
hard to explai nxd
can you give an example
i wanna let every block drop a random item
but every item should be dropped 1 time only
Yea
and not like from multiple source blocks
Use a HashSet
or EnumSet
EnumSet is very fast
everytime an item drops
add it to the EnumSet
and use a while loop to randomize, although that would be extremely inefficient at the end
so here is my approach, you could copy the values array as a list of some sort
and every time you randomize, you take it out of the list
then randomize from the same list again
and so on
could i just create an arrayList, containing all materials.
and adding them in a random position?
would probably be in a random spot in the list
that would be slower at first, but faster at the end
i see what you are going with that
maybe smthing like this
private static final List<Material> mats;
private static int index;
static {
mats = EnumSet.allOf(Material.class).stream().collect(Collectors.toList());
index = 0;
Collections.shuffle(mats);
}
public void chooseRandom() {
return mats.get(++index);
}
something like this
@sullen dome
my java knowledge doesn't contain that, so i dont even ask lol
you could also modify it so it removes and takes the first element
you could use a queue
hey guys, so i'm trying my hand at reading json, specifically the whitelist.json file that comes up. i'm trying to get the uuid of a passed playername. firstly, what is the proper path name to the json file? I currently have
BufferedReader br = new BufferedReader(new FileReader("\"C:\\Users\\Admin\\Desktop\\Spigot 1.16.5 Server\\whitelist.json\"")); but it doesn't look right? lol
but if anyone has any resources on hand i could use, please lmk
indeed
or just standalone app
you would have to think relative paths
For example, you know how plugin jars are dropped into [SERVER FOLDER]/plugins
right
yeah
now you have to think relative to that location
that means you have to go up one level
to the [SERVER FOLDER]
and then access the file that way
ah okay. i'm doing this in my test server atm, and the server folder is where the whitelist.json file is
tbh i just clicked the file explorer address bar and c/p'ed and added \whitelist.json ๐
That won't work
If i was running that on my pc
it wouldn't work because the paths are different
ohhh, gotcha
you know about plugin data folders right?
yup yup
you could get the parent file of that and get the parent of file of that
for example
lets say your datafolder was
/plugins/MyPlugin
you could do something like
/plugins/MyPlugin and get the parent of that (which is /plugins)
would Collections.shuffle just re-order the existing contents?
then get the parent of that (which is the server folder)
perfect
thanks! i'll have another crack at it
Cool
wouldnt this to the same then?
if (matList.isEmpty())
matList.addAll(Arrays.asList(Material.values()));
Collections.shuffle(matList);```
Yes, but it is no different from my approach which uses streams
https://paste.md-5.net/ubasevated.java, why does this line give me an error? Files.copy(EindjeMinecraftPlugin.getInstance().getResourceAsStream(configFile.getName()), configFile.toPath());
please use di
mine looks cleaner (to me)
what error
null
java.lang.NullPointerException
at java.util.Objects.requireNonNull(Unknown Source)
at java.nio.file.Files.copy(Unknown Source)
at nl.timnl.eindjeminecraft.storage.ConfigFile.saveDefaultConfig(ConfigFile.java:43)
at nl.timnl.eindjeminecraft.EindjeMinecraftPlugin.onEnable(EindjeMinecraftPlugin.java:22)
at net.md_5.bungee.api.plugin.PluginManager.enablePlugins(PluginManager.java:250)
at net.md_5.bungee.BungeeCord.start(BungeeCord.java:285)
at net.md_5.bungee.BungeeCordLauncher.main(BungeeCordLauncher.java:62)
at net.md_5.bungee.Bootstrap.main(Bootstrap.java:15)
either your instance or configFile is null i guess
Is it in the resource folder in the jar too
Alright that looks correct
Yes as I said
weird
I always doublecheck if I don't forget something
The plugin folder will be created, but not the database.yml
so it would be something of this
getClass().getResourceAsStream(configFile.getName()), configFile.toPath())