#help-development
1 messages · Page 825 of 1
kotlin moment
oh wait I think my IDE assumed im using UUID from java.util
walk with you out the door 🥰 ?
Sure
Yeah, better use UUID from org.bukkit 
wtf does assume you are using java.util
I always invite ppl who talk about kotlin to walk out the door
ngl that was the face I made when I nearly ran over a homeless lady during today's driving lesson
LMAO
Man tf
was the first one pls chill
lady at the end asked me to drive back to the school and I was like "wtf I'm not baby driver" and did it anyways
I love receiving some alcohol after school and in school noon break
Mulled wine is great
So is staying sober
Interesting topic for this channel lol
I thought because @echo basalt said that he just drove over a woman, almost
wait I just realised
About alcohol, an ukrainian friend of mine told me that some ukrainians, 12-13 years of age, could buy alcohol by showing some poorly photoshopped ukrainian document lol
Fuck I need a red bull and the corner store is closed
it does not
because why would it
bru
java.util.UUID is perfectly fine
this explains a lot
It doesn't, why would it
Well in Germany we can legally buy alcohol at 16, drink at 14 and get even earlier
I am 16 and I can just buy drinks with some type of liquor lol
Well, from 16 you can only buy some weaker alc iirc
It just depends on how it is made, if it is mixed and so on
For example, wine is fine even when it has like 16%
I can also buy aperol mixed which has liquor in it
Or some types of mulled wine with liquor in it
kotlin is fun, yk cause functions are fun
:D
Actually so true
DaFeist
Lol
Not legally. Only alcohols which have been created by pure fermentation.
Anything distilled is 18+
Hmmm
wine isn't distilled
I don't buy alcohol because I'm pretty fucked even without it
And somehow they are fine with stuff like aperol
And often they do not even care if you buy harder stuff
No idea where you live but down here in bavaria it is very strict because you can literally go to prison for
selling hard alc to a minor...
Germany with its Bundesländer is kinda like a little USA lol
UUID is just short for "universally unique identifier"
Its nothing more than a 128bit number and is used in a ton of applications outside of minecraft or gaming.
Always a power of two
I am in bavaria
You two should meet for fun
Yeah, no
I mean, that is not spigot 😅
?fork
SpigotMC maintains the Spigot server. If you are using a fork of Spigot (such as Paper, Airplane, Purpur, or other derivative works), you should seek support in the appropriate Discord servers.
are hashmaps values automatically gcd or should I manually do that? eg if a player disconnects in a <Player, blabla> hashmap will the value eventually get removed from the hashmap or do i need to handle it myself
you have to remove
sick
Don't weakrefs do that are something? Or what were weakrefs even for
Yeah you could use a WeakHashMap for that
I live in a mental state of void
IdentityHashMap
fuck I lost 33 cents on the stock market
❓
p sure IdentityHashMap works with player keys
the point of IdentityHashMap doesnt really seem to be garbage collection removal
I remember that being an option
I mean it works with any object... But how does this help with references.
also do WeakHashMap-s require a WeakReference to function correctly or do they make a WeakReference themselves
Guava has weak identity map
They internally have weak associations
o might be a misunderstanding then
yeah IdentityHashMap is faster if you're manually removing refs
yeah id rather not do that but thanks
Isn't IdentityHashMap just HashMap with == instead of .equals
The main diff is how the hash code is calculated
Hello! If I'm going to use NMS my don't want to use obfuscated in my code that I write, can I use this then?
Therefore, there seem to be slightly different names for the classes, for example "DismountUtil" is called "DismountHelper" etc
Yeah
hmm would a Heap Summary be what i need to find thats referencing the weakhashmap value 😭
Huh? Why would you need that...
cause if so I dont see references to player here but the value is still in the weakhashmap
well once the player disconnects the value seems to remain in the weakhashmap and im trying to figure out where its being referenced still
Well did the GC run yet?
i mean, I did a System.gc() upon disconnect but im not sure
get a full heap dump and run it via eclipse mat/visualvm to see where it's referenced
You should never have any references to Players in the first place to be honest...
I must for the greater good
(I am not bothering editing 50 hashmaps to handle disconnecting)
There is no greater good. Only drawbacks.
the greater good is not having my time wasted 😭
you're wasting it right now
i mean once i figure whats referencing player its going to be easier than editing all of my hashmaps to make them accessible
should have done it right from the start
How did you manage to have that many player maps.
I have never written a project with more than 10 maps with player id keys. maybe 15 if you count general entity maps.
Sounds like a design problem.
Maybe more Map<UUID, PlayerData> and less Map<UUID, Stats> Map<UUID, PlayTime> Map<UUID, Homes>...
too late lul
weakrefs are almost always not the way to do things
Hello! Did some quick experimenting with NMS trying to get findSafeDismountLocation to work for a player managed to get Player as entityType and blockPos but it requires "net.minecraft.world.level.CollisionGetter" how do I get it?
That would probably be the world
CraftWorld?
(Server)Level
im looking a plugin like
when my SQL queries in my code are incorrect, a warning will be thrown or the error message above will be given.
someoneknow ?
CraftServer?
No
When I run the program it says I'm looking for a plugin that checks before running.
CraftWorld craftWorld = entityPlayer.getLevel().getWorld();
Or how do you mean
You can just test your queries outside of the plugin first
oh, so what should it be then?
.
ServerLevel Level = entityPlayer.getLevel();
?tas
Okey!
But how do you change a player from org.bukkit.entity.player to NMS player ie ServerPlayer?
Tried with this but didn't get it to work:
ServerPlayer entityPlayer = ((CraftPlayer) player).getHandle();
Or do you need to retrieve the player's profile etc. to convert a player to NMS player?
?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.
Looks like you might have forgotten to remap
How did you build your plugin
Do you want to se my pom.xml or what do you mean?
I stop my test server --> Build my plugin --> Start my testserver
You're writing 1.19.4 nms
For a 1.20 server
That or multiple maven modules
Is it like when you have a single part of the plugin called like "Spigot_1_16_R3" and so for each version
damn i was not expecting createBlockData to be this expensive
here i was calling it like 30 times per tick per player
like this
Why so often?
i was checking if the block below the player was a wooden sound type, and if it was i created block data of another material to use it
what kind of info could i give to arrow that would then be transfered even when shot and turned into an entity
so i can identify it on impact
just try to reach a random ip ig
.
You can add PDC values and then use the ProjectileLaunchEvent to get the ItemStack and transfer it manually
Ah nice. I was eyeing that one.
It's never too late to refactor the entire project
Hey i wanna run a task allways at 12pm how to do that?
You can use the ScheduledExecutorService
So um... issue
I'm putting the <T extends Event> in the method signature so that the class can handle more than one Event consumer at once
But for completeness I'm keeping a list of Event.class -> Consumer, which has to be <? extends Event>
(There's only ever one consumer per event, I believe that constraint is reasonable)
a method arg Consumer<T> passes fine into that, but i cannot pass the values of that back to a T without casting is. My question therefore is: Is the following code fine?
@SuppressWarnings("unchecked")
public <T extends Event> void registerConsumers(){
for(Map.Entry<Class<? extends Event>, Consumer<? extends Event>> e : consumerList.entrySet())
handler.registerListener((Class<T>) e.getKey(), (Consumer<T>) e.getValue());
}```
side question: would this cast it to Class<Event> or to Class<actual class extending Event>
i may be stupid and intermediary java experience, but why not just use Event instead of something that extends it
Which event is called when the player is in the process of breaking a block?
because it needs to register with the actual event class or it wont get called correctly
oh so you didnt make this Event class?
thats the bukkit event
blockBreak event and adjacent. probably one of the events extending playerEvent or blockEvent
break is called when it actually breaks tho, not when you start breaking it
anyway on the off chance he sees this, @lost matrix i need some help again
Consumer<? extends> doesnt make sense
i mean
the whole idea was to not have a <T extends Event> attached to the class so that it could register consumers for more than 1 event
Not sure what im seeing here... You have a Map<Class<? extends Event>, Consumer<? extends Event>> and
you are trying to put all of those into another Map<Class<? extends Event>, Consumer<? extends Event>>?
public <T extends Event> void cacheConsumer(Class<T> clazz, Consumer<T> consumer){
consumerList.put(clazz, consumer);
}
@SuppressWarnings("unchecked")
public <T extends Event> void registerConsumers(){
for(Map.Entry<Class<? extends Event>, Consumer<? extends Event>> e : consumerList.entrySet())
handler.registerListener((Class<T>) e.getKey(), (Consumer<T>) e.getValue());
}
public <T extends Event> void registerListener(final Class<T> eventClass, final Consumer<T> listener) {
Class<?> clazz = eventClass;
do{
consumerMap.computeIfAbsent(eventClass, k -> new ArrayList<>()).add(listener);
clazz = clazz.getSuperclass();
} while(!Modifier.isAbstract(clazz.getModifiers()));
}
problem being i cant put T in the map
Ugh... pls show your "consumerList" and "consumerMap" and then explain the purpose of them
ah well this is spread over two classes
the map is what u gave me originally
Map<Class<? extends Event>, List<Consumer<? extends Event>>> consumerMap = new HashMap<>();
the list is the list of consumers cached in the Effect class to be able to remove them again
Map<Class<? extends Event>, Consumer<? extends Event>> consumerList;
One moment
Yes but your design makes little to no sense
shrug
havent gotten a better idea yet
hello ! little question, how do i get my plugin from an other class than main class? like i want to get my plugin here
?di
Guide to dependency injection: https://www.spigotmc.org/wiki/using-dependency-injection/
?paste
Are you trying to do something like this?
https://paste.md-5.net/egizurukit.cs
Kind of? Part of the whole nonsense with the scheduling im doing here is to allow effects to have consumers for multiple events
so this should work?
I wouldnt ripp out the consumers from within your effect and put it into another handler.
Just propagate the events to the effects directly.
thats a fair point
follow up question
tried to figure out the reverse to the inject method u did but couldnt
how do i remove an effect from this then a la computeIfPresent/Absent ?
Kind of depends on what you are trying to do. If you go with the EffectManager then you can just
private final Map<Class<? extends Event>, List<Effect>> eventMap;
public EffectManager() {
eventMap = new HashMap<>();
}
public void addEffect(Effect effect) {
for (Class<? extends Event> eventClass : effect.getEventClasses()) {
eventMap.computeIfAbsent(eventClass, k -> new ArrayList<>()).add(effect);
}
}
public void removeEffect(Effect effect) {
for (Class<? extends Event> eventClass : effect.getEventClasses()) {
List<Effect> effects = eventMap.get(eventClass);
if (effects != null) {
effects.remove(effect);
}
}
}
Is it possible to make random ticks tick in certain chunks? Would I need NMS?
No this doesnt work for several reasons.
Wdym by this
I assume they want to force more random ticks to happen
oh god you're one of those init-hashmap-in-constructor
Well, I have heard somewhere that force loading chunks doesn't do random ticks preventing crops from growing. Idk how right that is
Which no, there is no api for that
You can probably get away with manually calling a chunks tick method though use nms
you can just call block.tick
I am too power to the hashmap in constructor peoples
And I need some chunk loader that can load one specific chunk with random ticks so crops grow
That's not a method that exists in spigot
pretty sure i saw it done somewhere once
Yeah so blocks don't tick in nms either AFAIK
Chunks do afaik
Game picks (random tick speed) blocks per tick in a chunk and sends a random tick to them
Would I need to implement that myself or what
Well
Expose Chunk#tick() method when?
Maybe™️
Expose? Is it something that exists but private/protected?
it is hidden in nms
I like to run it in a while true loop
Hmmmm
Do it in another thread for performance reasons
of course
I like to run it in a async bukkit task
I still dk what it is lmao
Uh... chunks are getting ticked in an ugly way.
that is just the decompiler setting that was choosen
Though better than FF's default indent of 3
Fuck decompilers then
Ah i kinda understand what they are doing. They have a backlog of ticks for chunks so that they can catch up with missed chunk ticks
when the server get busy...
So, how tf do I make a chunk loader that can random tick
You could use nms 🤷
Hmmm
Or simply select N random blocks based on the gameRule and tick them
Heya, I got a Git issue and hope someone could help:
In the image, there is one blue repo. From all that I could gather, it's a "sub-module". However, that is causing quite some issues. For some reason I cannot commit to it or rather, my changes aren't considered.
So, either, how do I remove its sub-module status or how do I turn all of them into sub-modules, but with the ability to commit to them?
That submodule belongs to a different repo
That's why you can't commit to it
Even if that repo is mine?
You'd need to commit to it seperately, probably
In any case, would it be possible to retain both repos; But have it not be a sub-module. Or should I just always commit that code to the other repo.
Make sure you cd in to the submodule
ok, thanks
but how do i know what arrow shot into the air? couldve been any arrow couldnt it
what is the event when a player pickup a item in 1.19.4?
Deprecated
i found EntityPickupItemEvent but it does not fire. ```
@EventHandler
public void pickUpMoney(EntityPickupItemEvent event) throws SQLException {
System.out.println(event.getEntity());
}
can you show whats abouth maybe there is a } to much
Did you register the listener
That's not an import issue
oh my bad 😄
oh... okay thank you wait im trying to find how to do the ''' thing correctly
if you understand
lol im dumb wait
gonna take me a min then i can show
like that how do you imbed it?
i forgot 💀
Somethign like attemptpickupevent
I dotn know the exqct name
They're using the right event
The essence of the problem:
I have an island system. When a player logs in, we check his UUID by yml - if there is no UUID, then we create an island for the player. At the same time, the player can be in the list of members of a certain owner. In this case, the player is teleported to the owner's island.
/member <player> - add a player to the island.
Problem:
The player enters and is teleported to the owner's island. But the problem is that the players do not see each other (although they are in the same map). And yet they don't have gamemode 3 or invisible, etc.```
spigot 1.12.2
help pls
Are you canceling paxkets?
packets?
yes
No. I just add information to yml and the system determines what to do based on it...
Sec, I will send code
ConfigurationSection playerSection = islandSystem.getPlayerConfig().getConfigurationSection(player.getUniqueId().toString());
List<String> membersList = playerSection.getStringList("members");
List<String> membersUUIDList = playerSection.getStringList("membersUUID");
membersList.add(targetPlayerName);
membersUUIDList.add(targetPlayerUUID.toString());
playerSection.set("members", membersList);
playerSection.set("membersUUID", membersUUIDList);
try {
islandSystem.getPlayerConfig().save(islandSystem.getPlayerIslandFile());
player.sendMessage(ChatColor.GREEN + "Player " + targetPlayerName + " has been added to your island.");
} catch (IOException e) {
e.printStackTrace();
player.sendMessage(ChatColor.RED + "An error occurred while saving the configuration.");
}
here is add player to yml (members)
public void teleportPlayer(Player player, String copiedWorldName) {
UUID playerUUID = player.getUniqueId();
ConfigurationSection playerSection = getPlayerConfig().getConfigurationSection(playerUUID.toString());
if (playerSection == null) {
for (String key : playerConfig.getKeys(false)) {
ConfigurationSection subSection = playerConfig.getConfigurationSection(key);
List<String> membersUUIDList = subSection.getStringList("membersUUID");
if (membersUUIDList != null && membersUUIDList.contains(playerUUID.toString())) {
playerSection = subSection;
break;
}
}
}
if (playerSection != null) {
ConfigurationSection locationSection = playerSection.getConfigurationSection("location");
World copiedWorld = Bukkit.getWorld(copiedWorldName);
if (copiedWorld != null) {
Location defaultLocation = new Location(copiedWorld, 7, 100, 7);
player.teleport(defaultLocation);
}
}
}
}
and here is teleportation
Are you maybe creating a replica of the owners map that the player is being teleported to?
That way it seems the aame but you xant See each other bexause of different maps
No, no, no. They are on the same map, for example, one of them breaks blocks - and the other sees it... I've already tried all the methods... I don't understand what the mistake is..
If the players dont see each other and everything else works you probably cancel the ADD_PLAYER packet or the entitytrackentityevent?
I sow something about "ADD_PLAYER" In console. But now this is 0 error .... Idk why... But problem
if you restart the plugin, then the players see each other.
Or, for example, one of them has crossed over, it is also visible..
import org.bukkit.Material;
import org.bukkit.block.Sign;
import org.bukkit.entity.Player;
import org.bukkit.event.EventHandler;
import org.bukkit.event.Listener;
import org.bukkit.event.block.Action;
import org.bukkit.event.player.PlayerInteractEntityEvent;;
import org.bukkit.event.player.PlayerInteractEvent;
import org.bukkit.event.Event.*;
public class EventClass implements Listener {
@EventHandler
public void onPlayerClickSign(PlayerInteractEntityEvent e) {
Player player = e.getPlayer();
if(event.getClickedBlock().getType() == Material.OAK_SIGN ||event.getClickedBlock().getType() == Material.OAK_HANGING_SIGN ||event.getClickedBlock().getType() == Material.OAK_WALL_SIGN){
if(event.getAction() == Action.RIGHT_CLICK_BLOCK) {
player.sendMessage(ChatColor.LIGHT_PURPLE + "[PVPMANAGER] " + ChatColor.GREEN)``` this is my code why is my event red? Do i need to import something? What is the issue?
that's no variable called event
It's called e
Try not to copy paste code without knowing what it does
lol
?learnjava
Here are some links to get you started on learning Java:
- https://www.codecademy.com/learn/learn-java
- https://www.sololearn.com/learning/1068
- https://www.learnjavaonline.org/
- https://programmingbydoing.com/
- https://docs.oracle.com/javase/tutorial/java/index.html
The last one is the only official one, however some of those concepts assume that you already know a bit about programming.
oh okay thanks
guys please help someone...
where is a problem
What system are you talking about?
how to despawn a item?
just call .remove() on it
oh i need Item not Item Stack for that
skyblock plugin system
This means you have actually no idea what the problem could be and no way to fix it...
When a player logs in, the system checks him to see if the player is somewhere. If so, we will teleport the owner to the island. The problem is that it all works, but the players do not see each other, although they are on the same island
I have specifically described exactly how my code works above
Then some code calls Player#hidePlayer(Player) or blocks player packets.
Why in tutorial first import is orange but if I copy code it’s gray
No
I don't use this
no hide, no packets
There are only those possibilities:
- The players are not on the same island
- Someone blocks player packages
idk at his code its orange and in mine not
what do you need that you can say why its so
at the same time, if the player re-enters, then it is visible...
The color of your code is irrelevant...
okay
please learn how your IDE works or use one that confuses you less
but isnt it if import is orange that is used in code
color is irrelevant
okay
maybe the problem is that the system (yml) does not have time to determine the player's place? or?
FileConfigurations are completely in memory.
And you are abusing them to the max. You should never constantly read/write from/to FileConfigurations.
Load your data from a File into a FileConfiguration and from your FC to proper classes when the player joins.
are you using any disguise/skin plugin?
ohhhh
Pretty
ttyy
anyone here good with non euclidean geometry, namely path equivalence?
please dont ask why
Meh. Depends. In a discrete or continuous space?
was looking at different approaches tbh
could you describe a grid of squares as discrete?
like, what i want is a function, or an approach for writing one, which takes two paths from a start point to spit out if they end up in the same location, if the step size stays constant
a la forward, 90° left & right, back (that one only as first step i guess)
and a given vertex count (is that the word? number of square tiles around a corner point)
i know i could just map it to poincare coordinates but that is something that's likely to break given numbers for computers arent infinitely precise
you want to A* on a surface of vertices?
well no
i want 'do those two paths lead to the same tile'
because in non euclidean geometry, depending on the path you take, rotation becomes an issue
fixed path or search?
u cant just add up everything
two fixed paths
finding a path there would be helpful but i fail to understand how to check path equivalence
it sounds like you are confusing things with model space and world space.
if you work in worldspace you will always be using ecludian math
there was a thread about pathing in this channel, not sure if it's still there
well, i guess describing why I'm concerned about this might help
side note this is something thats been at the back of my mind for a while, im curious about it, but its not something important
so the thing i was thinking was that non-euclidean geometry has this thing where surface area increases exponentionell if you increase the radius, which meant if i was generating paths i could only know by either generating everything up until the furthest distance from 'zero' and just checking if the paths end up on the same tile, which is NOT feasible for longer paths, or some way to check if two paths are equivalent
I've read on and off some articles about coordinates but they tend to confuse me, and the thing i take away from it is that it is math that tends to have rounding errors so i cant do an equality check
I guess it depends on the application
if we are talking Minecraft here then rounding errors will not be significant enough to worry about
well i thought about doing it in minecraft but that opens a whole other can of worms and nms nonsense
but if we are talking MC here, you are over thinking the complexity
the problem is if i want to do anything in minecraft thats remotely hyperbolic i need some coordinate system for a square-tesselated hyperbolic space
hover over it and it will tell you
what means warning
'it will probably work'
okay
== || is not valid java
A Warning is not serious enough to be an error but it's something to take note of
okay ty
This one is telling you of a deprecation
concrete example here: staring at the same coordinates and orientation with a 4,5 hyperbolic space, the paths 'forward, right, forward' and 'right, left' are equivalent
I don;t think I've seen a green underline
hover your mouse over and see what it tells you
Bukkit.getEventHandler().registerEvent(new Listener(), this); or smth
What means or smth
like im not 100% sure
Okay
thats what i can remember
It don’t work
then you have other issues
did you build, copy the plugin, and restart your server?
There isn’t an double jump
Yea
this is full code :
package com.tomlegendxd.untitled.listeners;
import org.bukkit.GameMode;
import org.bukkit.entity.Player;
import org.bukkit.event.EventHandler;
import org.bukkit.event.Listener;
import org.bukkit.event.player.PlayerGameModeChangeEvent;
import org.bukkit.event.player.PlayerJoinEvent;
import org.bukkit.event.player.PlayerMoveEvent;
import org.bukkit.event.player.PlayerToggleFlightEvent;
import java.util.HashMap;
public class DoubleJumpListerners implements Listener {
private HashMap<Player, Boolean> cooldown = new HashMap<>();
@EventHandler
public void onJoin(PlayerJoinEvent event) {
event.getPlayer().setAllowFlight(true);
cooldown.put(event.getPlayer(), false);
}
@EventHandler
public void onFly(PlayerToggleFlightEvent event) {
if (event.getPlayer().getGameMode() == GameMode.SURVIVAL || event.getPlayer().getGameMode() == GameMode.ADVENTURE) {
event.setCancelled(true);
if (cooldown.get(event.getPlayer())) return;
event.getPlayer().setVelocity(event.getPlayer().getLocation().getDirection().setY(1));
cooldown.put(event.getPlayer() , true);
}
}
@EventHandler
public void onMove(PlayerMoveEvent event){
if (event.getPlayer().isOnGround()){
cooldown.put(event.getPlayer() , false);
}
}
@EventHandler
public void onGamemodeChange(PlayerGameModeChangeEvent event){
if (event.getNewGameMode() == GameMode.SURVIVAL || event.getNewGameMode() == GameMode.ADVENTURE){
event.getPlayer().setAllowFlight(true);
}
}
}
package com.tomlegendxd.untitled.listeners;
import com.tomlegendxd.untitled.listeners.DoubleJumpListerners;
import org.bukkit.Bukkit;
import org.bukkit.plugin.java.JavaPlugin;
public final class DoubleJump extends JavaPlugin {
@Override
public void onEnable() {
Bukkit.getPluginManager().registerEvents(new DoubleJumpListerners(), this);
}
}
its plugin.getServer().getPluginManager().registerEvents(Listener, Plugin))
what
is this worng ? Bukkit.getPluginManager().registerEvents(new DoubleJumpListerners(), this);
what was the character one can use to make progress bars in nametags
|
oh
hmm but the import is not used
also known as 'pipe symbol'
its gray
yh i know its the same char used to make or statements
and if its gray its not used
just thought there was another
well
theres some
i believe theres a char that doesnt have any space before or after
to make a continuous bar
dunno the name tho
its arl ill just use this one
someone knows why when i spawn some particles with offset they are being shoot like 20 block aways and some are spawning correcly
please format your code using ```java <code> ```. also, we have ?paste for larger blocks of code
how can i kill a player without appearing the Respawn screen (1.8.8)?
- set immediate respawn true, kill, set it false
- simulate death and teleport them to their respawn location
import org.bukkit.GameMode;
import org.bukkit.entity.Player;
import org.bukkit.event.EventHandler;
import org.bukkit.event.Listener;
import org.bukkit.event.player.PlayerGameModeChangeEvent;
import org.bukkit.event.player.PlayerJoinEvent;
import org.bukkit.event.player.PlayerMoveEvent;
import org.bukkit.event.player.PlayerToggleFlightEvent;
import java.util.HashMap;
public class DoubleJumpListerners implements Listener {
private HashMap<Player, Boolean> cooldown = new HashMap<>();
@EventHandler
public void onJoin(PlayerJoinEvent event) {
event.getPlayer().setAllowFlight(true);
cooldown.put(event.getPlayer(), false);
}
@EventHandler
public void onFly(PlayerToggleFlightEvent event) {
if (event.getPlayer().getGameMode() == GameMode.SURVIVAL || event.getPlayer().getGameMode() == GameMode.ADVENTURE) {
event.setCancelled(true);
if (cooldown.get(event.getPlayer())) return;
event.getPlayer().setVelocity(event.getPlayer().getLocation().getDirection().setY(1));
cooldown.put(event.getPlayer() , true);
}
}
@EventHandler
public void onMove(PlayerMoveEvent event){
if (event.getPlayer().isOnGround()){
cooldown.put(event.getPlayer() , false);
}
}
@EventHandler
public void onGamemodeChange(PlayerGameModeChangeEvent event){
if (event.getNewGameMode() == GameMode.SURVIVAL || event.getNewGameMode() == GameMode.ADVENTURE){
event.getPlayer().setAllowFlight(true);
}
}
}```
so ?
import com.tomlegendxd.untitled.listeners.DoubleJumpListerners;
import org.bukkit.Bukkit;
import org.bukkit.plugin.java.JavaPlugin;
public final class DoubleJump extends JavaPlugin {
@Override
public void onEnable() {
Bukkit.getPluginManager().registerEvents(new DoubleJumpListerners(), this);
}
}```
?paste
Some particles use the offset as a velocity if you set the amount to 0
cuz its in the same folder, no idea why ur jump aint working tho
amount is 1 tho
so idk
if its same foulder what does it change?
its considered in the same package, its already visible to each other
but why jump dont wotk than :((
so
Player#inmediateRespawn(true)
Player#setHealth(0)
Player#kill(false)
Player#teleport(spawn)
?
uh that were two distinct options lol
a OR b
like, set the gamerule, kill the player, set the gamerule back
OR
simulate their death manually
okay
that were the two ideas i had
Thanks thanks
Havent used WorldGuard in a while. Any better way of getting all Players inside a ProtectedRegion, other than a full iteration?
public boolean hasParticipants() {
ProtectedRegion region = this.getRegion();
if(region == null) {
return false;
}
return Bukkit.getOnlinePlayers().stream()
.map(Player::getLocation)
.map(BukkitAdapter::asBlockVector)
.anyMatch(region::contains);
}
ah nvm i skip the double jump i dont need this just wanna leran java
Access the default domain iirc
with getMembers or sth
membership is something else
oh nvm then
I don't think WG keeps track of that itself, but that's one approach, the other approach would be to use a session handler and keep constant track of the regions players enter/exit, in the same fashion as the enter/exit message flags for example
I thought about converting it to a BoundingBox but then realized that WG regions might not have an AABB shape.
I guess there is no other way. But should be fine, right?
I mean unless you have like millions of players online, iteration will be fine lol
Its for ~20 ppl online and checked once every few seconds. I shouldnt worry about it 🙂
Im just marked from the time where WG scaled horribly and i wrote my own region system.
But they did a similar optimization a few months afterwards.
What were the benchmarks, out of curiosity?
Creating a bunch of regions and checking with a profiler how well it scaled with a runnable checking a location every tick 🙂
I was a semi-noob when it comes to benchmarking. But it was apparent as it scaled linearly with the amount of regions until
they started mapping them to chunk coordinates.
fair enough
I don't think they map to chunk coords?
they just use an r-tree
kinda, with priorities
an r-tree still
I just remember it being way better. r-tree would mean O(log(n)) still. Better than O(n) but worse than
what you would have with chunk mapping (Which is O(1) if there is only one region in a chunk)
also i have a feeling this got buried a bit, anyone know how to do this?
the event bus thingy?
or are you working on something else now? :,)
He's babbling about non-euclidian geom
well, ur consumers and maps etc
oy its not easy to understand
what is the tldr moterius?
for the non euclidean thing you mean?
yea
im trying to figure out how to check equivalence for paths in {4,n} (n > 4) tesselations
like in the example, the paths do not have the same number of moves but still end up in the same tile
well, i have scarcely touched tesselations, but did you have a current approach as of right now?
well a really bad one yes
generate map out to max radius, see if they end up at the same tile
which considering how fast hyperbolic space grows is... not ideal
https://roguetemple.com/z/hyper/dev.php
one of the sites ive tried to look at is this one, but like i said, the math looks like it would have rounding problems
how can i learn java making plugins without paying money?
?learnjava
Here are some links to get you started on learning Java:
- https://www.codecademy.com/learn/learn-java
- https://www.sololearn.com/learning/1068
- https://www.learnjavaonline.org/
- https://programmingbydoing.com/
- https://docs.oracle.com/javase/tutorial/java/index.html
The last one is the only official one, however some of those concepts assume that you already know a bit about programming.
you need to pay to learn java? xd
nah idk there some tutos for money
what rounding issues would u get, do u mean with float and double precision?
is minecrat plugins making and java different things?
ye thats the worry i have
not entirely
minecraft stuff is usually made in java, java is broader
but what i have to learn if i wanna make plugins
java basics
uh, basic java syntax, basic spigot api
hmm, I mean one tactic is to use BigDecimal
or maybe if you can limit urself to the space Z^3 rather than R^3
what are java basiscs xD?
altho it comes with heavy compromises
syntax, and oop concepts
wtf is this
i doubt Z^3 works in non-flat space
the grammar rules of java
if i watch tutos how to make a plugin will it help?
first go watch some java tutorial
like actual practice
i watched tutos how to create plugin basiscs
Im getting a ClassCastException, why do i need to cast it to a runnable in the first place and why does it throw an exception, what did i do wrong?
like gamemode switch warps
yea
yeah well ur other option is to use BigDecimal
can you recommend me an good youtuber?
tho it can become mem intensive
who makes good tutorials
i liked laur spilca
?learnjava
Here are some links to get you started on learning Java:
- https://www.codecademy.com/learn/learn-java
- https://www.sololearn.com/learning/1068
- https://www.learnjavaonline.org/
- https://programmingbydoing.com/
- https://docs.oracle.com/javase/tutorial/java/index.html
The last one is the only official one, however some of those concepts assume that you already know a bit about programming.
no i will not learn java
there ought to be a better way for tesselations
i dont doubt I'd need bigDecimal for continuous space but tesselated should have some better options
what i need to know before making plugins?
yeah, have u looked around in other open source projects, maybe someone wrote something useful for u alr :>
Basics of Java, like types, classes, OOP, maybe generics and then you can learn on the go while making plugins. Also looking into other people's resources
i did but i found that usually theres so much stuff around it its hard to even find let alone understand
2 weeks to 6 years
depends on how much you work on it
?whereami
thats paper
Very basic OOP (classes have methods, classes can inherit classes or interfaces, interfaces define methods that can be called, constructors initiate classes, etc.) as well as very basic syntax (Instructions are seperated by semicolons, static method calls are Class.method(), non-static ones are instance.method(), method parameters are put in the brackets (e.g. System.out.println(arg)), Strings (basically any text) are defined by "<content>", chars (single character/unicode codepoint [with limitations]) by '<char>', constructors are called via new Class([...]), Classes are defined by class Name { [...] }, methods by public <returnType> Name(args) { [...] } etc.)
paper is an 'optimized' fork that isnt 100% compatible with spigot, so people here will tell you to go to the paper discord
hmm ty guys i prob start learn java instat of tutos how to create dumb plugins xD
it's probably the better idea
yea
I personally recommend making small CLI applications first
I too started programming because of minecraft primarily 10 years ago (which aint that an eternity), so you can too
okay ty guys i going to scool and i have only 1-2 hours per day to learn java hope it its enogh 😉
Like very simple text-based games. Note, if I talk about making very simple games, I mean very simple. Don't try to make anything like DF or even any sort of rougelike for the first few weeks to months (depending on how good you are at learning it)
Pft, for as long as you go to school your free time is basically unlimited
classic minecraft to cs/se pipeline
like if i click on a button an hi comes?
lol
That isn't text based.
what is text based
command line interface
I'm talking about something like if you enter "click" in the terminal it would increase your score by one. That sort of thing
okay i try ty i gotta go now i have school tmrw bye
You enter click in the terminal and it deletes system32
And I'm not talking about making games that look like this (even though that is sorta possible in a terminal, depending on your terminal)
Is that terraria 2
Nah, that is the steam release of dwarf fortress. Not a CLI game though, just CLI-inspired
isnt dwarf fortress on steam GUI?
Yes, but there is an ASCII graphics mode
player.getWorld().spawnParticle(particle, player.getLocation(), 1);
i do this and by spawning (i think its like that because its directional?) for example "soul fire flame", it gets shoot like 20 blocks away, obsidian tear particle works normal tho
the longer spawn method should have a speed arg
try setting that to 0
Take a shot for ever spawnParticle overload
i hate it
Is it good or bad practice to wrap a Player? Not like an actual Player object but in a sense like GamemodePlayer that is stored in some cache
cant I just remove on player leave
you can, yes
but I'd recommend using a UUID anyways so you can access the player even if they're offline (or if on pre-connect)
but that depends on your use-case
Also works with playSound
any way to spawn particle behind where the player is looking?
how can i add permissions to LuckPerms web editor by the API?
They should just appear if they are in your plugin.yml
okay
so i got a problem
is not a command
and i need a permission per every material on the api
sooo
Hmm
how can i do that without hard writing it
I assume they have an api for it
why do you need a permission for every material?
idk, a client just told me to do so
find out why as it may be pointless
it may be better to default allow all and then use permissions to blacklist materials
i mean you can register a permission in the pluginmanager, that'll have the same effect, but like, eh
THANKS
how
get the plugin manager
register a permission
fwiw, it isn't specific to the web editor, there's getKnownPermissions or something somewhere, but I don't think the collection it returns is mutable
probably an unmodifiable view
For plugin devs and others, what are normally things that you struggle with during minecraft plugin development? I'm working on an api rn and am trying to include some things people normally struggle with to ease mc plugin developing
?nocode
It’s hard to answer a programming question without code
Oh no! You ran into a problem. But no worries, people are willing to help, but first they need to see your code. This is because otherwise, they would be providing help based on guesses instead of concrete knowledge. Whether it be a compile error, runtime error, or an unexpected output, I'm sure that if you were to provide code, you'd receive a quick solution.
Theres no code needed for this question. I just asked why isnt there no getAtributes in the entity class
LivingEntity
ah thxy
I'm trying to call setCancelDrop() on a FallingBlock, but it doesn't seem to think the method exists despite it being in the documentation
any ideas?
Are you on the right api version
it takes a boolean
currently using 1.20.4
is getting a player's armor and pdc like a bunch of times a tick going to hurt my server's performance
how are you achiving getting pdc multiple times per tick
not really answer to my question
you most likely don't need to constantly check for pdc
im making a plugin with a bunch of custom items
and so
each one can have a custom ability in like a damage event or something
and I thought about another ability, having the ability to interfere with other abilities
so check for it in entitydamagebyentity event, not constantly
and now idek how to start
yes it can be costly as getting the PDC of an item requires fetching the Meta, which is cloned every time
how do i even approach this lol
if multiple items have different on damage events
my current system is custom events, so like
CustomItemEntityDamageEvent
and then I send it to all those custom item ability handlers
which caches some info
maybe I should just cache the pdc
is it costly the get a tag off a pdc?
why not store type of custom item inside of event ?
that way, you dont need to check pdc again
but lets say
an item can interfere with another item's ability
then in each impl of each ability, i need to add this new item
Too generalized to comment on. It all depends on your implementation
but remember fetching the PDC is a costly action if done repeatedly
shouldn't be
fetching a tag itself, no
depends
if you do it 100 times per tick, i would say something is wrong with your impl
100 times per item? 1 times each item for 100 players?
so 1 time per player
so like
lets say
i have a custom event (CachedEntityDamageEvent) that stores the entities armor as a pdc, so helmet, boots, chestplate, all as a pdc
now I have each armor item, with their abilities that is subscribed to the custom event
calling pdc#something
how do i change the damage in a projectile hit event
would the best way to implement custom durability be just using PlayerItemDamageEvent with pdc
thankz™️
sometimes I wish the event bus would let you attach a listener to specific values and receive and get the chance to cancel an event anytime it changes
one or two events always seem to slip through the cracks
wtf is a "Suspicious call to 'HashMap.getOrDefault()' "
It means you being sus
Or more likely you are calling it with something that doesn’t match the key type
ah oikay
the value type might just be Object
no the key is Object
I have no clue why
but it means you can pass anything as the key and only your ide will pick up on the fact that it's probably not what you meant
1 question if you are still here, im currently creating custom items as well and my approach is to just check if the item has a uuid in its pdc marking that it is custom. After the check the events will take the information and handle the item like it should be, is this fine or expensive as well?
that is probably how would i do it idk
okay, thank you :)
you've got helper methods right
what ?
hello?
let's see your event handler code that checks the uuid
well I'm just asking if you abstracted out the logic for checking the UUID
I'm confused why you're asking for advice on your code but won't show the code
i think it's fine, i was only scared about the pdc is perfomance heavy part
except this im pretty confident it's effiecient
he bacc
im having weird beheavior with ItemStack#setDurability
this is cursed
whats going on?
1 sec lol
if I do java event.getItem().setDurability((short) 1560); on a Diamond Axe (they have a max durability of 1561) the durability drops to 1
💀
yeah you need to set to 0
Durability is deprecated
that happened to me too the first time i used it
please use the Damageable Interface
yeah well idk how you're gonna deprecate a minecraft feature I still need to set durability 😭 🙏
oh okay
its less confusing because damageable implies its inverted
where durrability does not
?jd-s
specifically statesSets the damage in the java doc, so you'd actually wanna do Damageable#setDamage(1)
its so wack that its inverted but 🤷♂️
does anyone know how a server like hypixel manages all the custom enchants in a gamemode like hypixel pit
what is the default walk speed for a player
0.2 i think
arl thx
they likely use NBT since they're on some old highly modified fork of spigot. As of for todays standard you really should be using PDC. You can also go about it in another way though. However, you have to be ready for breakages with this method. First you have to unfreeze the NMS Enchantment registry and create a new NMS Enchantment. Then you can use the API to operate MOST of your enchantment logic. I say most because you also have to think about the actual function. Its also important to note that even with this method there is no proper implementation in the EnchantmentTable and Anvil. If you do go the NMS route pay mind you'll be pretty much on your own
what is it called when cats "lay in bed"
thought it would just be cat.setSleeping
like with fox
but it isnt
uhh so am i supposed to do somethin along the lines of java Damageable damageable = (Damageable) event.getItem().getItemMeta(); damageable.setDamage(1560);
oh god
cause i aint gonna lie that didnt do shit
damageables gave me trauma
set the meta of the item to the modified meta
my bad forgot autosave wasnt on
np
ItemMeta isn't mutable
it is a copy
interesting system
you need to do
Damageable damagelabe = event.getItem().getMeta();
damageable.set(5);
event.getItem().setItemMeta(damageable)
yeah i got it thanks
was it too next gen thinking to simply have setDurability
sigh
wtf
what
how do you think the ndb is structured
don't worry about NBT if your >1.14
the NBT is probably pretty simple hell they probably just have their own enchantment logic embedded into the server
its probably just a single entry
idk im asking because they have enchants
which can effect other enchants
vice versa
and I wonder how they implemented that optimally
that's likely all in the event logic
i can understand it to a certain extent
but they added an enchant that disables others
same logic
i decompiled a spigot fork and removed a certian line that was causing me trouble, how can i recompile these files into a server.jar ?
do you think that would be in the individual item's logic?
🤷♂️ I can't tell you the logic for your entire plugin sometimes you just gotta take an idea and run even if you have to keep going back and improving it
that's how you get better
ok well im guessing they hardcoded it
Is their any way to define a specific line to hard wrap comments at in Intellij. Right now by code wraps at 120 lines, but I want my javadocs to wrap at 80. However, autoformat always reformats my docs to wrap at 120. I couldn't find anything in the settings regarding this either
they abandoned it
i think its using mvn to build it
then you gotta figure it out yourself
how to send itemstack using netty
is there an alternative to GENERIC_ATTACK_DAMAGE that scales with enchantments?
bc i currently have java itemMeta.addAttributeModifier(Attribute.GENERIC_ATTACK_DAMAGE, new AttributeModifier(UUID.randomUUID(), "generic.attackDamage", 10, AttributeModifier.Operation.ADD_NUMBER, EquipmentSlot.HAND)); and when enchanting the item with sharpness its unaffected
Did you check the actual damage or just the tooltip
just the tooltip
i mean idk if the actual damage is correct or not but the broken tooltip is the issue lol
If you want it to show the full damage, yeah
im guessing this is no longer 10 base damage then
but the actual item's damage + 10
unless im trippin
for some reason, users (that is a map <String, Long>) is null when file already exists. https://paste.md-5.net/ofewuqemum.js
this is what copilot came with
but idk, i dont trust copilot so much
so someone can give me a code check?
It’s the games base damage plus 10
The games base damage is 1
thanks
Is there a way to spawn a dragon, then make it constantly target a player?
javac
check on how to compile plugins with javacompiler
How to send banners using netty?
by banners u mean titles?
like the ones that appear in the middle of the screen?
Banner item
oh
lmao I saw minecraft internally had BASE_ATTACK_DAMAGE_UUID = UUID.fromString("CB3F55D3-645C-4F38-A497-9C13A33DB5CF"); and got excited and thought i could just use that UUID
k, yea idk
Looks good
why are these 2 specific checks here? https://hub.spigotmc.org/stash/projects/SPIGOT/repos/craftbukkit/browse/src/main/java/org/bukkit/craftbukkit/inventory/CraftMetaBlockState.java#266-270
so we know if it is a shulkerbox or a bee nest
jk bc beenest and beehive have the same tag
...
why does it bother u so specifically
well that's not it
there are a zillion blocks which have the same block entities
then go check them all :D
I'm curious why those 2 are called out specifically there, and what the reason only those 2 are
ask paper fr
?
They are a troll just ignore them
They haven't a clue wtf is going on
Also tbh I'd just ping md5 and ask I'm sure he'd probably respond when he wakes up or is avaliable
yeah for sure
?kick @grand flint trolling
Done. That felt good.
how would i generate vanilla world that is only plains
if i create a biome provider that is only one biome
it still generates everrything normally just with it displaying as that biome in f3
oceans are my main concern
Done. That felt good.
ty
See mulitverse core's src
do they even have one biome
Hmm they probably also have an outdated API usage
You could ask the gpt mfo
Altough he'll most likely be useless
And also outdated api usage, probably
Yeah, his info about the world is really inconsistent
Yes
Anyway, when are maps (the item) rendered?
After like, at least one chunk has been sent?
Hello,
I have a small issue with BuildTools -
I've installed BuildTools for version 1.20.1 in my IdeaProjects > tools folder and tried to use the dependency for this version in my build.gradle (without -api) but it doesn't work at all, I can't build the project nor I can access NMS code. I've tried to restart the IDE but it didn't fix the problem. Any ideas? Maybe someone else had had this problem
did you run buildtools and have it complete
Yes
It said the build was successful
do you have mavenLocal() in the depdencies block of your build.gradle
❤️❤️
Thank you
two questions:
- is it fine to put initialization for attributes into the {} thing that's called before the constructor? I want to avoid having to call super in extending classes
- does this check guarantee the cast works?
Class<? extends Event> currentClazz = clazz;
//loop
if (!superClazz.isAssignableFrom(Event.class)) break;
currentClazz = (Class<? extends Event>) superClazz;
'avoid' as in, not having to add a constructor to every class extending this
If there is no primary constructor you have to add it anyway
do certain server softwares have somekind of yml correction system in place because sometimes it's doing this even though that's not present in the default config at all
this being the default
its also replacing those double quotes with single quotes for some reason
yaml is formated when it's saved.
the {} is removed as it does nothing. it's completely empty
it shoudl not be there in the first place
2 any1?
The cast works regardless due to type erasure
It really depends on what you use it for
is doing this still a good idea? this is before then end of a do...while(! ...isAbstract(CurrentClazz) )
But I think you have the isAssignableFrom switched up
yeah he does
do {
//add / remove from list
Class<?> superClazz = currentClazz.getSuperclass();
if (!Event.class.isAssignableFrom(superClazz)) break;
currentClazz = (Class<? extends Event>) superClazz;
} while (!Modifier.isAbstract(currentClazz.getModifiers()));
I'm iterating through the classes upwards, and was worried about the 'unchecked cast' thing
side note wouldnt this break if there's a key -> null in the map? It's not supposed to happen, but im curious what would if it were
HashMap<Class, List<Event>> eventMap;
...
eventMap.computeIfAbsent(currentClazz, k -> new ArrayList<>()).add(effect);
no, {} is added to the config
its not there in the default config
but because its added it throws errors on the servers where this happens
the bottom pic is the default config i got in my project and the top pic is what some servers get after the plugin is loaded, and its causing errors because obviously {} is gonna break that config section
{}is not valid as teh next key is indented as a subsection
be sure teh original yaml is saved as UTF8 when it's in teh jar
then I can't see how it is being changed as that is not valid yaml, unless they have something else editing it
some servers just try to correct it or whatever even though there's nothing to correct
so its attempt breaks the file
I guess they are running some buggy web console
these files were also completely unedited so this happens when the plugin is first being started
If they can have them exclude it from their web console configs
Spigot will not save like that, so it's nothing to do with Spigot
they do be using purpur and i know purpur does a bunch of wacky shit sometimes
unlikely
does purpur have somekind of plugin caching system that anyone is aware of because sometimes uploading a new plugin jar doesnt even update the plugin
My guess would be a hosts web console messing with it
oh you're one of those LOL
me smart, fix servers good
so first of all
@ancient plank porn + troll
yeah but doing it in an annoying child way
the gates of heaven will be welded shut for you
?fork
SpigotMC maintains the Spigot server. If you are using a fork of Spigot (such as Paper, Airplane, Purpur, or other derivative works), you should seek support in the appropriate Discord servers.
is folia a spigot fork?
technically
so plugins might work
folia is a fork off of paper which is a fork off of spigot i think
they sometimes work, as far as i know they have a different scheduler system
so any plugin that schedules tasks need to be reworked to suit folia, probably among other changes
folia is still in development so maybe there's no guide to plugin compatibility yet
also sent a porn gif, can send ss and links if you want
wouldnt it be visible in server logs?
uh why are my annotations collapsing like this?
yo is there a way to save the slots of individual items when serializing and encoding to base64?
im trying to save an inventory but whenever it's decoded, all the items end up in a stack at the top of the inventory rather than individual items in their respective slots
anything can be base64 encoded, including the array representing the inventory. if that's a good idea though...
lemme dig up something
huh im not doing it b64
ByteArrayOutputStream bos = new ByteArrayOutputStream();
BukkitObjectOutputStream oos = new BukkitObjectOutputStream(bos);
oos.writeInt(stack.length);
for (ItemStack itemStack : stack) {oos.writeObject(itemStack);}
oos.close();
return bos.toByteArray();
might break between versions then
hm
alright
ty :D