#help-development
1 messages · Page 1981 of 1
Yes. You need packets for that.
packets probably and send it to select players
good idea
what would it need to tell 👀
hey I was wondering if there is a way to disable the typo checker in IntelliJ? it gets a bit annoying after some time
Yes. But you can also download language packs and add Strings to your dictionary.
If it triggers a lot then you probably should re-check naming conventions.
https://stackoverflow.com/questions/717849/disable-spell-checking-on-intellij-idea#:~:text=-> Uncheck the options that you want to disable.&text=2%3A File>>Settings>,"spelling" is better! %3A)&text=Just%20to%20be%20clear%2C%20the,Typo%22%20checkbox%20disables%20them%20all.
if thats what ur looking for then google before asking because stackoverflow contains everything
For some reason there are no GameProfiles anymore... Did they remove them?
No. Its on the nms classpath. Was never part of the API.
But if you are on 1.18 then you can use PlayerProfile now.
alr ty
I think you can also just add mojangs auth stuff as a dependency
Okay
Also... I'm feeling ashamed for that but I have no clue about packets. Does anyone know where I can learn how they are working and how I can send them?
Dont be ashamed of that. Spigot was build so all that packet tinkering gets abstracted away from you.
Usually you wouldnt want to deal with that. It depends a bit on what you are trying to do.
This contains all the information about the current protocol:
https://wiki.vg/Protocol
Then you just need to decide if you want to send raw NMS packets or use ProtocolLib.
<dependency>
<groupId>com.mojang</groupId>
<artifactId>authlib</artifactId>
<version>1.5.21</version>
<scope>provided</scope>
</dependency>
<repository>
<id>minecraft-repo</id>
<url>https://libraries.minecraft.net/</url>
</repository>
if you use maven darkmango u can access nms like htis
I'm using maven but what is htis?
this*
ah sorry
<repository>
<id>nms-repo</id>
<url>https://repo.codemc.io/repository/nms/</url>
</repository>
idk i think this
i use that repo for nsm
NMS?
dont u have to buildtools?
why
because its illegal...
what is the net.minecraft repository link?
why is it not legal
huh
well that didn't work sadly
did you read the EULA before accepting it ?
If you've started your server, you have accepted it
^
I used server.pro
you still did
automatically accepts it for me
Check their EULA
:o
It probably mentions the mojang one
they are distributing mojang assets when hosting those jars
will anyone sue them tho
They might receive a takedown request
is buildtools licensed or
and if not obeyed, it might be followed by a lawsuit
Buildtools downloads those assets separately from Mojang
So it legally doesn't count as distributing them
yo is there a way to use maven placeholders in my code? not literlaly in the code but inside the ide, for instance if i have ${project.version} and i wanna use it in something
how does this look like? its a command handling thing i made
https://paste.md-5.net/gerawivagi.java
Quick question about IDEA how to remove this yellow thing. its in all my files.
usually you'd want to read what intellij is suggesting
read the warning
i saw them but i want to remove them : /
fix the warning and it will go away
ok Fixed it : )
hate the fact that you cant do if (!sender instanceof Player)
always that extra pair of brackets
I wish you could do !instanceof
Class::isInstance isnt that something?
There’s also isAssignableFrom
whats the difference between them
The later works with subclasses and such
This one for classes only
clazz1.isAssignableFrom(clazz2)
I assume the other is for objects
isInstance is for objects
yep it takes an object as parameter
anyone know why this is happening
Guide to dependency injection: https://www.spigotmc.org/wiki/using-dependency-injection/
ohh
i see
which is then
if (sender.hasPermission("vlu.admin")) {
- 1.8 is ancient and support was dropped years ago
- Something in MainVLandsCommand.java line 22 is null
thats it for line 22
sender is null
I'm having a weird problem with my plugin:
banned.remove(uuidString);
plugin.banned.set("banned-players", banned);
I clearly remove the player from the Map and then set the Map to the updated Map.
This works and removes them, although when I try and add them back later it doesn't add them. Any reason this might happening?
try {
banned = Objects.requireNonNull(plugin.banned.getConfigurationSection("banned-players")).getValues(false);
if(!banned.containsKey(player.getUniqueId().toString())) {
banned.put(player.getUniqueId().toString(), System.currentTimeMillis() + (banDuration * 1000L));
plugin.banned.set("banned-players", banned);
}
} catch (NullPointerException exc) {
System.out.println("created map");
banned = new HashMap<String, Object>();
banned.put(player.getUniqueId().toString(), System.currentTimeMillis() + (banDuration * 1000L));
plugin.banned.set("banned-players", banned);
}
oh wow
Whenever it creates a new HashMap it doesn't seem to add them
And I have no clue why
How can I import net.minecraft?
catch (NullPointerException exc) thats not really good practice
rnn throws npe though
I tried checking if it was null
came with loads of problems
so I just became lazy
then you are doing something wrong more than likely
Why wouldn't it add them to the HashMap after I create it though?
1 note is
dont use contains()
use if(hashMap.putIfAbsent(k, v) == null)
putIfAbsent will put if there is no value and will return the value found, otherwise will return null
Doesn't solve my problem either way lmao
makes your code cleaner and probably better performance
I appreciate the tips but again, that doesn't fix the problem that it just doesn't add it to the map
and im right
its better performance
oh also
you probably want to just store the hashmap in ur code instead of plugin.banned every second
its not, i printed sender out before the if and it worked
idk whats wrong
i guess banned is a FileConfiguration
this wont do anything
plugin.banned.set("banned-players", banned);
so we basically just got rid of containsKey performance loss
youre not saving it
as containsKey searches for the key
put also does that
so you're doing double searching
where putIfAbsent does 1
@young knoll So what is the way to fix my issue : ) sorry for the mention
and its recommended to not catch Runtime Exceptions, like an NPE
instead, you should avoid it
so make sure your map is actually initialized
?Di
also avoid public variables and exposing collections
?di
Guide to dependency injection: https://www.spigotmc.org/wiki/using-dependency-injection/
alright thank you very much
I did fix it by just storing it in a hashmap and then only saving the hashmap on disable
I will try my best to implement/fix everything y'all told me though
thanks
di ?
dependency injection
Also do not use sysout in bukkit plugins, Loggers exist.
just for debugging
thx
its quicker
public static HashMap<String, Integer> loadHashMap(String hashName) {
HashMap<String, Integer> hm = new HashMap<String, Integer>();
file = new File(Main.instance.getDataFolder(), hashName + ".yml");
if (!file.exists()) {
try {
file.createNewFile();
System.out.println("3");
} catch (IOException e) {
e.printStackTrace();
System.out.println("4");
}
}
YamlConfiguration customFile = YamlConfiguration.loadConfiguration(file);
for (String key : customFile.getConfigurationSection(hashName).getKeys(true)) {
// Load the config from the file, and apply it to the hashmaps needed.
hm.put(key, (int) customFile.get(hashName + "." + key));
}
return hm;
}
}
Any idea why this wouldent be working? I have no errors.
Is there anything glaringly wrong
new HashMap<String, Integer>();
UUID.fromString is something
That didn't work for some reason. Did I forget something maybe?
wait
it provides a Map<String, Object>
lmao
dunno what you are doing
what isnt working here
idk is there another way
might want to not use it, ig just use String
but if ur on a newer version probably use it
Its just not saving or loading from my file
got improved a lot tho in jdk 14+
also instead of (int) fileconfig.get there is a getInt method
Is there an event called when a player is inside a powdered snow block? and if so what is it called.
I couldn't find anything in the javadocs
EntityChangeBlockEvent does not seem to work
I am essentially trying to disable the powdered snow block for players with a certain permission
Here is an idea of what I'm trying to do:
public void EntityChangeBlockEvent(EntityChangeBlockEvent e) {
if(e.getEntity() instanceof Player) {
if(e.getBlock().getType().equals(Material.POWDER_SNOW)){
Player p = (Player)e.getEntity();
if (p.hasPermission("n2.snow")) {
p.setFreezeTicks(0);
p.sendMessage(":" + p.getFreezeTicks());
}
}
}
}```
yo can i use jfrog to set up a maven repo?
EventPriority.NORMAL is redundant
oh wait yes you can
couldnt find it at first
Sure. Every good package manager should be able to support maven
JFrog specifically supports Maven, yes
i have no idea what im doing
i created a repo but now its asking me to configure
jfrog thing
but i can only configure release and snapshot, but the generated settings include themselves
idk its hard to explain
where do i deploy this
i dont have a local server
remote. linux machine.
im using a free profile on jfrog and it asked me to set up an aws server
but did it create the server
or do i have to create it and then link it somehow
or do i have to log into it
No idea i always go for nexus and install that on my dedicated server
it seems like it has a server set up (url https://orbyfied.jfrog.io/ui/native/m2-libs-release/) cuz it says Artifactory Online Server
btw is this server help
?
technically
am i in the wrong channel again
is there a java.util.function class that takes a parameter and returns nothing?
consumer
lmfao
making some command handling thing
what should i use as package in my repository, maven or gradle
i like maven but
would choosing gradle prevent maven users from using the artifacts
Runnable:
void -> void
Consumer:
T -> void
Function:
T -> R
BiConsumer:
T, V -> void
BiFunction:
T, V -> R
Supplier:
void -> T
Predicate:
T -> boolean
BiPredicate:
T, V -> boolean
UnaryOperator:
T -> T
BinarOperator:
T, T -> T
And then there is also a bunch of primitive stuff like IntConsumer or LongBinaryOperator and so on
wdym compressed?
oh idk thats just me lol
ah
but would choosing gradle prevent maven users from using the artifacts
on a repo
switch (result) {
case FAILED -> sender.sendMessage(ChatColor.RED + "Something went wrong!");
case NO_PERMISSION -> Lang.NO_PERMISSION.sendTo(sender);
case PLAYER_ONLY -> Lang.NO_CONSOLE.sendTo(sender);
case TARGET_NOT_FOUND -> Lang.PLAYER_NOT_FOUND.sendTo(sender);
case SHOW_USAGE -> usage.sendTo(sender);
}
Could be done in a Map<CommandResult, Consumer<Player>> for a tiny tiny bit better performance.
And i also hate switch case statements.
lemme copy 300 more lines from my old plugin lol 😂
👀
mye possible
what if i would do something that doesnt need a player 🤷
ill look at that tomorrow
goodnight
wait does a hashmap have better performance than a switch statement?
Hey guys
Let's say a player is in the middle of two blocks, but like slightly more closer to one
How do I get the block the player is closer to
so if i have a material, how do i work out if it is something like a flower that is technically a block but has no collider
isnt there an isSolid method or something
on the material
i think thats what youre looking for
does any of you have any idea why
player.getInventory().getItem(0);
returns null, and:
player.getOpenInventory().getItem(36);
returns AIR itemstack
both methods are nullable
i've tried decompiling CraftBukkit classes
but i cant find any difference
The slot that a player currently has selected is of type AIR
Thats the ItemStack in his hand when its empty
Players can move things around in their inventory, so there is no guarantee that item slot 0 will be what you want it to be.
but why inventory class
returns null
for the same slot
instead of AIR
at the same time
also it makes no sense to return AIR itemstack whenever the method is marked as @Nullable
welcome to the joys of bukkit inventory api
The API is more and more moving towards not returning null
that being said, null can be returned from time to time
^
How can I make a bossbar for the player?
im currently looking for a 1.7.10 spigot (the spigot itself, not plugins) developer, if you have any information and have any experience, please dm me with snippets and previous work.
I run Alpha, a HCF server. For info about the team, server, or paid development jobs my dms are open
?services
If you wish to request or offer development/art/building/administration services, please do so at https://www.spigotmc.org/forums/services-recruitment-v2.54/
Although good luck finding devs that work with 1.7.10 lol
Haha thanks. Is this not the right spot to advertise? I’ll move it if needed just let me know where I should take it too
The right spot is through the forums, https://www.spigotmc.org/forums/services-recruitment-v2.54/. We just offer development support here.
Please
You should separate the cooldown and the display of the cooldown
And also a while loop on the main thread blocks the whole server
minecraft has only a single thread. If you block it with a while loop then the server just stops.
minecraft has more than a single thread
but most of the game processes happen on the one, yes
scheduled repeating task
You basically check every tick
You are using a BukkitRunnable which means you can just call BukkitRunnable#runTaskTimer(JavaPlugin, long, long)
just use runTaskTimer like he said
it's part of the BukkitRunnable interface so you can use it there
A BukkitRunnable is fine. But you need to think of discrete timeframes instead of continuous ones.
Here is a guide for the scheduler in bukkit:
?scheduling
Running the BukkitRunnable every N ticks
Ill just copy something from a thread i wrote
From 2 different threads
And scheduling a repeated task basically runs your run() method at the start of every tick until you stop it.
what's the event that happens when a player's exhaustion level increases?
EntityExhaustionEvent, despite it being specific to players only
logic
How I can check if Player on ground in PlayerMoveEvent?
look how to check if the player is jumping and do a if not of that check
normal spigot jar is enough tbh
If you want to get a custom one for some reason, you need a really skilled developer
which will break your bank
mostly
so im trying to make a delhome command its work perfectly except for the home name
test: {} is become like that
plugin.homesYaml.set( "Homes." + getPlayerUUID( player ) + "." + homeName, null); I have test this method but same's its still dont wont remove it
homeName become args[0] because i made a method for that
if someone know how to remove the homeName please ping me
i think by setting something to null you make that value null. Maybe it would work if you call .remove() instead
on a different topic what is BlockDamageAbortEvent
https://hub.spigotmc.org/javadocs/bukkit/org/bukkit/event/block/BlockDamageAbortEvent.html
renamed to? I can't seem to find it in the actual api
declaration: package: org.bukkit.event.block, class: BlockDamageAbortEvent
wait wtf
im using the 1.18.1 api
should be cool if .remove() exists XD
How can I set a cooldown on an event?
make internal static variable either per player or per event and store the time of last activation in that
if the difference between that and the current event is smaller than your cooldown do setCancelled(), otherwise update that variable
also
why the fuck does the docs online specify a class that doesnt exist in the api?
literally only me and conclure said a compliment
why do people get urges to comment on everything, even the smallest mistakes on writing that the writer knew the correction for
How I can check if Player on ground in PlayerMoveEvent?
if(player.isOnGround())
Don't use that
o
Use that if you are aware of why it’s deprecated
declaration: package: org.bukkit.entity, interface: Player
I want to check the end position so it won't work
Subtract a tiny amount from the y
And then check if that position is a block
Not perfect, but it can’t be spoofed
and this is problem if block is water grass flowers etc
loop thru 3 blocks
Hence the solid block
actually 2
or actually 1
check if itsa solid block
if its not go to the one below it and check if it is
if it isnt, then he isnt on the ground
oke how many
by subtracting an inaccurate value you can give errors
you know, however, I'd rather not use this method
You could also look into checking the bounding boxes of the player against the block
maybe do you have other idea
if its not something you gain an adventage of by cheating
then just use isOnGround
as long as spoofing wont give adventages
but it's actually interesting
Block has a getCollisionShape
I highly recommend not using isOnGround unless this is a for-fun plugin
oh realy?
hmm why?
because its client dependent
someone can just telling your erver the resot that method is supposed to have
@main dew can read about it here ^
ergo it can be given wrong results if the player wishes for it
thats one way to do it
a hacked client can spend a packet
of being on the ground
when the user isnt
very easily
all in all, it's an interesting approach
but it doesn't answer that question
so?
how i see only the ".Something" can be removed
@main dew also why are you using player move event
it runs every single lil movement
even when turning ur head
nobody answer me lel
is there a method that only works when the player is moving?
Yes, PlayerMoveEvent with this check
if ((int) event.getFrom().getX() != (int) event.getTo().getX() || (int) event.getFrom().getY() != (int) event.getTo().getY() || (int) event.getFrom().getZ() != (int) event.getTo().getZ()) ```
getBlockX/Z/Y will floor
anyways
and this can create a new event
but there is no such existing one?
Why would you not use getBlockX/Y/Z
good question xD
I'm making a moderation plugin for bungeecord, how would I do durations and write it to a MySQL database?
System.currentTimeMillis() ```
and you add time do this for example
System.currentTimeMillis()+hours*60*60*1000+minutes*60*1000+seconds*1000 ```
or second option
System.currentTimeMillis()/1000+hours*60*60+minutes*60+seconds ```
anyone know an easy way to kill a player and set their hunger to half after they respawn? ive tried just killing then saving their uuid and checking if its saved on the respawn event to no avail
hmm this should working you can show source?
Just came here. What are you guys doing?
I have problem with this xD
Works. But they could log out when they are in the death screen. To make it safer and spare a listener you should
just tag the player using his scoreboard tags.
and he doesn't write back
please help
delay the action by a tick
Dont use configs on runtime.
Load a players home(s) when he joins the server.
From then on you only use properly named variables and classes.
When the player quits again then you simply save his data again.
the command do all of that
and i still dont get it because its wont delete the homeName
But the command should do nothing of that. Thats the whole point. Because this makes debugging really hard.
i mean the command create where the home is and reload the config
i dont need to load it because it all on a yaml file
Yeah i get that. But it should not.
wont the player still be on the respawn screen?
Load the config when the server starts.
Use the loaded data (HomeManager for example)
Save the data when the server stops
Just tag the player
public void saveHomesFile() {
try {
homesYaml.save( homesFile );
} catch (IOException e) {
e.printStackTrace();
}
}```
method for save my data and its onEnable method
But most modifications to the player need to be delayed a tick when using the respawn event
how would i tag the player? i havent done stuff with scoreboards yet
Example:
private static final String HALF_HUNGER_TAG = "__HALF_HUNGER__";
public void killAndTagForHalfHunger(Player player) {
player.getScoreboardTags().add(HALF_HUNGER_TAG);
player.setHealth(0);
}
@EventHandler
public void onRespawn(PlayerRespawnEvent event) {
Player player = event.getPlayer();
if (player.getScoreboardTags().remove(HALF_HUNGER_TAG)) {
player.setFoodLevel(10);
}
}
tysm
should remove reload from my homemanger?
Scoreboard tags are just janky pdc
and how tf i can remove my home name
anyone help me with this?
I actually used them like pdcs by storing a huge json string in them when i first started out XD
Use the spigot method. Be aware that i can be spoofed. Every other way is quite expensive.

yea I need check localization getTo (the current inGround method will refer to the player's previous position)
His requirement was to know if a player is grounded in the PlayerMoveEvent. Or does he want to know if the target location will be grounded?
The later
You’d probably do something with a BoundingBox and block#getCollisionShape
I see. Then ray tracing downwards for like .1 would be my approach. Not sure how it compares to the boundingbox method.
!docs block#getCollisionShape
!docs block#getCollisionShape
Nice try
what command to do this? xD
Also not a bad idea
Maybe on a certain forks discord
and it was here for sure
and you could show an example because I don't know what you mean I don't use ray tracing
I need help someone please help me. basically my simplescore plugin isnt working
?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.
?help
selfrole Add or remove a selfrole from yourself.
cleanup Base command for deleting messages.
embedset Commands for toggling embeds on or off.
info Shows info about CafeBabe.
licenseinfo Get info about Red's licenses.
mydata Commands which interact with the data CafeBabe has about...
set Commands for changing CafeBabe's settings.
uptime Shows CafeBabe's uptime.
findcog Find which cog a command comes from.
names Show previous names and nicknames of a member.
userinfo Show information about a member.
listcases List cases for the specified member.
reason Specify a reason for a modlog case.
permissions Command permission management tools.
how do i disable inbuilt commands like /w? PlayerCommandPreprocessEvent then just cancelling the event or using commands.yml?
what would be "better"?
For what reason? It's just an alias to /msg, no?
is there a good way to broadcast to everyone online?
If you don't want people to use /msg you should just revoke access to that command, happi
Bukkit#broadcastMessage
how i can make a tab completer to get player home?
implement TabCompleter and register it for that command+
getCommand("command").setTabCompleter(new YourCompleter());
wouldn't it uh, show a no permission error if i did that?
yea that i know, the thing its how do i get home from config
Hi :D
I've had a little problem for quite some time with hexadecimal colors. Basically, when a color in the form §#af1233 test is entered by the player, we see test in color but when it is done by the code or by the server we see under this form §#af1233 test the color is not translated. So I wanted to know if anyone knew what it was, if there have been recent changes (I'm in 1.17.1) because I didn't have this problem before :(
Thanks in advance for any help you can give me :p
Yes. Do you just want the command removed entirely?
In which case yes the only way to do that would be to cancel a preprocess event
Simplescore plugin is not working I reinstalled it and everything it does not pop up when I do the command ./rg flag global scoreboard example. Yes I created the reguion global using world edit and even deleted it and re-added it multiple times. It still is not popping up
It was working before but then it just stopped after I edited it to what I wanted in the scoreboards file
Once again: Dont dabble with configs on runtime. Load them once. Use properly named variables and classes from then on.
Eh, well, in some cases it's fine to do on the fly. For simple configurable values, everything is cached anyways
i dont get it whats i should use?
i have methods for make thing and remove things from config
and you could show an example because I don't know what you mean I don't use ray tracing pls 😅
Everything that uses String keys is error prone to typos. I would really try to enforce this doctrine to not use FileConfigurations as actual data structures.

one moment
whats type of "data structures"
oh damn
i know what you mean
Not sure if this covers everything:
private static final Vector DOWN = new Vector(0, -1, 0);
public static boolean isGroundedLocation(Location location) {
World world = location.getWorld();
Preconditions.checkArgument(world != null);
RayTraceResult result = world.rayTraceBlocks(location, DOWN, 0.1, FluidCollisionMode.NEVER);
return result != null && result.getHitBlock() != null;
}
but im so stupid for make it LEL
you know i wouldn't think of that xD thanks
yo guys i got a pretty dumb question, im very new to owning a server.
im in the process of updating the plugins on my server and im using filezilla. Obviously theres the .jar file for the plugin but some of them also have folders. can I just drag the updated version of the plugin from my downloads folder into the plugin folder?
and then delete the old.jar and the folder? or keep the folder
shit this is in the wrong chat
my fault guys
but if someone could reply that would still be dope 👍
i tried this and some other things and the if statement doesnt seem to be working is there something else i should use like .contains?
oh nevermind the problem was that it didnt remove the food
Hi :D
I've had a little problem for quite some time with hexadecimal colors. Basically, when a color in the form §#af1233 test is entered by the player, we see test in color but when it is done by the code or by the server we see under this form §#af1233 test the color is not translated. So I wanted to know if anyone knew what it was, if there have been recent changes (I'm in 1.17.1) because I didn't have this problem before :(
Thanks in advance for any help you can give me :p
Use the Bungee Chat API
someone had this error ?
java.lang.RuntimeException: Cannot retrieve entity from ID.```
public class CommandServer extends Command implements TabExecutor { public CommandServer() { super("server", "bungeecord.command.server", new String[0]); }
Can someone explain me how to add aliases to bungeecord commands?
Where?
How can I get the location of a player and move only the location in his line of sight?
check move event, get their line of sight, if it's not going there, cancel it
are there any way in optimizing a repeating runnable code that does teleportation every 2 ticks
is IllegalStack your plugin?
if yes, send the full error message/stacktrace. if no, report it to them
wdym with "optimizing"? just don't do unnecessary stuff
What’s the purpose behind doing that
its a mob that stays beside the player that will fight any mob that damaged the player after killing the target it will stay back to the player's side again like floating and follows when moving
every two tick seems unnecessary
You could probably make a custom entity with actual pathfinding goals for that
yeah but unfortunately I'm not gonna use nms for it
Then reducing the frequency at which it runs is gonna be the best you can do
the transition is not that smooth with higher delays which makes it have very delayed movement
but its the best option I have ig
Is there a scoreboard objectives update event?
I don't think there is
if not, would doing a check every tick be resource heavy?
. this will also help you if you're gonna do a runnable for it
wanna see something stupid
Stream.concat(Stream.generate(() -> new Random().nextInt(66, 92)).limit(10000), Stream.generate(() -> new Random().nextInt(34, 60)).limit(10000)) .sorted((x, y) -> new Random().nextInt(-10, 10))
I mean...
Yeah by definition it's going to sort perfectly
but by any typical human definition, that's far from sorted
real talk though, aren't the unicode numbers for uppercase letters 34-60 and 66-92 for lowercase?
dont you just love it when this happens
Yes
pisses me off to the max
at least that's what wikipedia said
I've a feeling they're wider than that, though maybe I'm wrong.
Yeah, you've got some punctuation in there too
I mean 60-34 is 26 and 92-66 are both 26 so like it cant be any wider than that
I fudn this website but no clue on how to... you know, get it in there but I'll look it up https://unicode-table.com/en/alphabets/latin/
65 - 90 = A - Z
I forget where lowercase letters are just off hand though
97 - 122
64-90 or 65-91? 65-90 would be missing either A or Z
I'm being inclusive here
yeah I just realized lol my bad
;p
mmm I'm gonna have to ramp up those random sorting ints by a few 0's
100000* works
the sweet feeling when you fix something
oh god conventions
can't you just print it out yourself
codePointAt
I did not know that method existed but I will look into using it in the future, thank you
It's ok, I got that from a technical interview where I forgot the code and couldn't check it online lol
then I realize you could just print it to check
what kind of task were you given where you needed to know the unicode of characters? I was just generating a random string of letters and now adding random line breaks
I was asked to implement a bold function to bold requested word in a paragraph using the markdown * symbols
oh, why did you choose to do that with unicode?
I choose to use the .split to split the paragraph with the requested words, then join them back with the words in between with * wrapped around as separator
then I realise I have to check if a word is preceded or ending with anything but an alphabet
It was a pretty bad solution but I was in a rush
there was also a question of capitalizing the word where I needed to know the difference in the unicode
oh, what would you do differently from then?
I could instead check character by character using a trie or sorts, reset whenever I am met with a whitespace or punctuation (which I will probably still required the use of unicode).
As in it looks for the * or it looks for the word
looks for the word, then add * before and after
You wouldn’t need a trie then
I'll have to practice that
the trie is just an optimization for the case where the requested words are similar to each other
Iterate through the characters of the string
TRIE?
Why not just use regex
When you find the first letter, set an index point
That's like my favorite data structure
HashMaps
HashMaps are a close second
This is for a technical interview question, they don’t want regex because it’s more about understanding the data and the algorithm than the string itself
Ah
I need an example of this "prefix tree" you speak of
same as trie
Yeah but prefix tree is a better name
Just call it Jeff
HashMaps > Jeffs
@hardy swan:
Iterate through the characters, keep a pointer to the current index of the first character in the word you’re looking for too
When you find a match, set a start index at the current point in the main string and increment the cur pointers. Continue matching each subsequent character until you fail to match or you find the entire word. If you fail to match, unset the start and set the word pointer back to 0, if you complete the match insert the * and keep going
No need to reorganize the data at all
that will work for matching one word
i mean it will work for multiple words, just k times the whatever complexity it is, where k is the number of words
where n is longest word's length
Longest word is going to be shorter than the entire string presumably
The limiting factor is the length of the main string
oops yea, the entire string
Yep
public static String bold(String input, String... words) {
CharTree<Integer> tree = new CharTree<>();
for (String word : words) {
tree.set(word, 1);
}
StringBuilder builder = new StringBuilder();
for (int i = 0; i < input.length(); i++) {
Pair<Integer, Integer> result = tree.getFrom(input, i);
if (result.getFirst() != null) {
builder.append('*').append(input.substring(i, i + result.getSecond())).append('*');
i += result.getSecond() - 1;
continue;
}
builder.append(input.charAt(i));
}
return builder.toString();
}```
This is using the CharTree implementation I posted above
Pretty sure it's the optimal solution
I meant to do it in one pass using trie
Using a trie for this is like killing a fly with a sledgehammer
It’s overkill
You end up not wasting processor time
How is it overkill if it's saving time?
If you have a lot of different words you want to bold it could make a massive difference
i think the difference is even more apparent when the words are kind of similar
I have a .schematic file in my resources folder, how do I get the actual File object, and not the InputSteam object with JavaPlugin#getResource()?
["trie", "tried", "tries"]
You can't
Because it's not a File
It's an internal resource in the jar
save it as a resource in the data folder perhaps?
not sure how to get around that then
Could just get it as a string presumably?
That is probably the easiest route
yeah just saveResource(params)
okay so I have a really terrible issue
List<Character> temp = Stream.concat(Stream.generate(() -> new Random().nextInt(65, 91)).limit(limit), Stream.generate(() -> new Random().nextInt(97, 123)).limit(limit))
.sorted((x, y) -> new Random().nextInt(-1000, 1000)).map(n -> (Character) (char) (int) n)
.toList();
System.out.println(temp);```
this works as intended, generating the limit*2 of random letters
but after that it's putting a single random char into arrayOfChars
System.out.println(temp);
char[] arrayOfChars = new char[limit*2];
for (int j = 0; j < temp.size(); j++) {
System.out.println(temp.get(i));
arrayOfChars[i] = temp.get(i);
System.out.println(arrayOfChars[i]);
}```
What is the point of the sort there
to sort
That's not a good shuffle
(Character) (char) (int) n
And I don't see the point of shuffling a string that is already made of random characters
Get rid of it
And it's filling the array with the same character because you're using i for all the indices and not j
But j is your loop variable
If you want to shuffle it (though I'm not sure why you need to) then you should just use Collections.shuffle on the list
Never shuffle using sort
I assume it’s because the list starts with all upper and ends with all lower
It's slower and it's heavily biased
Or the other way around, idk
I am getting this odd error when trying to access my plugins data folder, [22:05:07 WARN]: java.nio.file.AccessDeniedException: plugins\LobbySystem
Does the folder somehow belong to another user
/ is the server being run from a different user
different user?
shouldnt be
I had a notepad editor open that was editing a file in that folder
would that effect it?
Potentially but it shouldn't affect the folder itself
yeah it doesnt
hmm
wait so
I am using Paths.get(LobbySystem.getInstance().getDataFolder().getPath())
Would the .getPath() be causing any issues?
probably
I am using File.copy(InputSteam, Path) to save the resource
which is why I need the path
for my wordle plugin, I added the word list to my data folder using saveResource("words.txt", true);
oh I forgot that existed
the resource path is where the file is stored beginning from your resources folder
and it saves "words.txt" to the plugin's data folder
yeah
then you can get the File with new File(plugin.getDataFolder() + File.separator + "theFile.exe")
or something really close to that
yeah
I am now getting this error with worldedit, not sure what I means [22:17:38 WARN]: com.sk89q.worldedit.extension.platform.NoCapablePlatformException: No platforms have been registered yet! Please wait until WorldEdit is initialized.
oh, well I'm not sure about that because I've never depended on worldedit before, sorry
yeah, google wasnt very helpful
just conclure help for ping or use gnoogle
"conclure help for ping", perfect enlgish
lol you must be new here
sorry I don't know what it's about
I just did my usual running gag
if you get this message, it means you're accessing worldedit(worldguard too early or that your WorldEdit/WG version is too old
compared to you being in for almost 2 years
that doesnt make sense tho
why?
since world edit says it has loaded
loaded, okay. but also enabled?
and I am calling on world edit from a command
doesnt it come enabled?
onLoad() != onEnable()
//wand works
hm
okay let's do this:
in your command, just add a very stupid System.out.prinlnt("Test yolo");
then run your command and ?paste your log
I know, sounds stupid, but I bet it'll help
what is it?
I am using the com.sk89q.worldedit:worldedit-CORE:7.2.0-SNAPSHOT, and not com.sk89q.worldedit:worldedit-BUKKIT:7.2.0-SNAPSHOT
accessing for what?
that is the gradle dependancy
in 90% of cases you WANT to access the core thingy
idk if it makes a difference
of course you'll need both anyway
so add both to my dependancies?
your gradle file seems to be fine
as I said, please do this:
and this
I gotta know where exactly it thows an error, and what that exact line of code is
sometimes I question my choice of being a programmer
it was my gradle
and it was the stupidest thing ever
what was it?
I used implementation and not compileOnly
meaning it was making a new instance of worldedit
tbh I don*'t even knot the difference
aaah
okay so "implementation" in gradle is probably "compile" in maven
gradle is so much more complicated than maven lol
implementation compiles the dependancy into your .jar
but I dont like maven cause it looks like html and I dont like html
yeah well
sort of
that's a pretty stupid reason not to like maven
haha
that's like
worldedit is now complaining that my schematic is bad
"I have a wive, she looks so simple" and next year she stole your children, house and bank accounts
but "she looked so simple"
because she didn't <look>like this</look>
lol
still aint gonna change my mind
I get it lol
gradle isn't easier just because the syntax is different
in fact, and I bet EVERYONE here confirms: gradle is 20% more powerful while beging 230% more complicated
also with WorldEdit, how do I get a SessionOwner object?
ah
7
I have to get the World object
Bukkit world or WE world?
WE World
EditSession editSession = WorldEdit.getInstance().getEditSessionFactory().getEditSession(WorldEdit.getInstance().getSessionManager().get((SessionOwner) p).getWorldOverride(), -1)
that is what I am currently doing
the cast from SessionOwner to Player is invalid
yeah of course
wait
you need the WE world
from an editsession object
right?
doesn't EditSession has some kind of getWorld method?!
I need to get a EditSession
I just need to paste a schematic
I have a player object
create a new editsession
using a WE world
for that you need the BukkitAdapter IIRC
it's actually totally easy once you have the correct set of "depedencies" (WE world, player (in this case, probably null), etc)
what's the thing you're having tourble with exactly?
trouble*
tp
tp?
oh
ugh
yeah if it works, that's good lol
it says that there is a invalid block
this schematic was made from a .nbt file from like 2012
ye
send full message
[22:47:45 WARN]: Unknown block when loading schematic: 64:15. This is most likely a bad schematic.
aren't there any more lines in the stacktrace?
oh
yeah
your schematic is 10 years old
it's almost old enough to have sex
there's no chance that WE 7 will be able to load it
it worked tho
that's like installing some win98 program on windows vista
hm yeah might be but you'll have to ask on EngineHub's discord for that
WE 7 can convert legacy schematics
this is definitely something related do schematics/worldedit itself
idk what block it was
the build seems completely intact
now that I think about it
64 is an oak door
this .nbt was once used for a modpack
hmm
No it’s a door
Likely used for rotation
I only started coding Mc plugins once all those retarded numeric ID's were gone
And openness
I always thought X:N, that N was the color
It’s metadata
or in general, the type
It was used for a bunch of stuff
ok so
Rotation, color, stone type, slab orientation
I just did a full scan of the build
Etc
and what I found, was that half of the trap doors were not flipped right, and one door was not there
Yeah that would be it
how can I fix the trapdoor thing?
Don’t use legacy schematics
tbh
easy solution
paste your schematic in 1.8
convert world to 1.18
create new schematic
there were like 10 trapdoors
I can just move them manually, then save it again
yeah
Don’t forget the door
``` *Using password: no* even though I am weirdo
tbh
using no password most of the time is the securest option
this is dumb
?
not really
it means you can only authenticate using other methods
like sockets
nah
yah
It's authentication is trash
Iwe should use schematics to authenticate
if someone sends a dirt hut = auth denied
if someones sends an awesome cathedral = denied
but if someone sends the correctly built blackstone cathedral, block by block, = access allowed
basically just keyauth with extra steps
Does anyone know what is going on here?
I am getting this error when I compile, it almost seems like a library is missing. Cannot resolve method 'getClickedInventory' in 'InventoryClickEvent'
Is there a way to change the sky color from the world?
Like an API, NMS or something to do it
I found a plugin that seems to work only up 1.17, but the author stated that you can't change it anymore via NMS
on 1.17+
Are you compiling against Bukkit? or Spigot?
Last I recall, getClickedInventory() is a Spigot method
Nope, I'm wrong
It is spigot yes
I'm wondering why I cna't pass x and y to Comparator's reverseOrder method java Character[] sortedChars = l.stream() .sorted((x, y) -> Comparator.reverseOrder(x, y)) .toArray(new Character[0]);
I looked at it and it shows that it uses the object's compareTo method, which the Character class does have
what is l
'reverseOrder()' in 'java.util.Comparator' cannot be applied to '(java.lang.Character, java.lang.Character)
l is just a list of type Character
reverseOrder() takes no args. It's the reverse order of natural ordering. Not quite what you want
You'll want (x, y) -> -Character.compare(x, y)
ah shoot you're right, I missed that
thank you
I saw another tab completion that was at least 60% of the same text
Also, I've a feeling toArray() can accept an IntFunction as well, so Character[]::new should work instead of new Character[0]
Yes. It can
oh it does, that's neat
I'm trying to use Comparator's reverse method though, but I found .reversed
which also doesn't work
I'm ngl, dealing with characters in a stream is pain to me
'comparingInt(java.util.function.ToIntFunction<? super T>)' in 'java.util.Comparator' cannot be applied to '(int, int)'
wait
I know I see it
I mean if you're hard-set on using Comparator.reverseOrder(), you can just pass that to sorted() afaik
It returns a Comparator
yeah I'm still trying to get used to streams with characters, i just did .sorted(Comparator.reverseOrder()) like you said
just me making it harder than it is
stupid question
instead of for(int i = 0; i < n; i++) {
what if for(int i : new int[n]) {
🤔
in the event index i doesn't matter of course
but thatd loop through the contents of an array
but it's empty
you just define its size
yes but you would iterate n times
no?
you tried it?
yes
for(int i : new int[30]) {
String randomizedFileString = insertRandomLineBreaks(randomString(500000), 10000);
System.out.println(randomizedFileString);
Writer fr = new FileWriter(f, false);
fr.write(randomizedFileString);
}```
Why like that tho?
I have no clue but I was dreaming about python's range(int, int)
You probably shouldn't define an array for no reason
you are absolutely right
Still works, but why 
Can't argue with that
it's like
why write for(;;)
instead of while(true)
except worse because of memory and stuff but that's besides the point
or like why write 0x1.0p-53 instead of 1.0
is there a better explanation for the EntityDamageByEntity event than 'this field exists' which is about the extent of the javadoc on spigotmc.org ?
(i need to know how to modify both the damage before and after applying damage reduction/changes due to armor, potions etc.)
setDamage is before, setFinalDamage is after calculations iirc
thanks
wait a sec there's no setfinaldamage (getFinalDamage works fine tho)
Oh, then setDamage then. getFinalDamage will return the calculated one
What are you trying to do
doubling damage in a specific circumstance
Yeah, so just set the damage to getFinalDamage * 2
wait, wouldnt that possibly result in a wrong number?
Why would it
if they have any armor the FinalDamage is less than the original damage
shouldnt it be damage *=2
What would use to make event-deriven system in java (have an event and listen to it)? Would you use Observators? Or is something better?
Register an EventListener -> EventRegistry
Event occurs -> EventRegistry.Registered -> Send the event through each one however you want to
Because the design pattern I find didnt convince me
I was expecting somethimg like spigot ones
But didnt find anyone like that
Spigot uses reflections to get methods into their registry.
You need a manager class that contains something like a Map<Class<? extends Event>, List<EventMethod>>
This manager can then be used to dispatch events and register instances of which every annotated method is being registered.
Example:
Original dmg: 10
Reduction: 30%
Original final: 7
getFinalDamage -> 7
multiply by 2 -> 14
setDamage -> damage is now 14 so final damage is now 14 - 30% so 9.8
You effectively reduced it by 2% instead of increasing it by 100%
thats why i changed the original damage instead
also is there yet a way to detect a player jumping outside of PlayerMoveEvent?
wait a second
is it possible to manipulate a player object asynchrously?
urrrgh im not finding anything online
is it possible to call runTaskAsynchrously and parse it an event instance
