#help-development
1 messages · Page 90 of 1
onEnable() != OnEnable()
public void methodThatTakesAnIntAndReturnsTheSameIntJustToTrollYou(int i ) { return i; }
hi im currently tying to make a plugin lets one user sleep through the night on a server. i have the PlayerBedEnterEvent and it calls a runTaskLater to wait a few seconds before setting the time to day. How can i set the time of the server within the runTaskLater?
How do i run a custom event async non related Spigot question? Its more a java question
what about Player#setSleepingIngored
huh ?
you wanna reduce the amount of players for the server to skip to day?
idk you might be able to use that method
if so there's a gamerule and you don't need a plugin at all
i just want one person to be able to sleep in a bed to then skip the night
i wanna do it through a plugin
theres a gamerule for the amount of players that have to sleep before passing to day afaik
why make a plugin for something that already exist in vanilla 🤔
because its a challenge
there's better challenges^^
how can i access the time to change it from within a Bukkit.getScheduler().runTaskLater()?
Bukkit.dispatchCommand(console, "/gamerule playersSleepingPercentage 1);
Wdym by that? The time of the scheduler?
stop trolling him pls
no the time of the server
that make a counter, increment it when PlayerBedEnterEvent happens and decrement it when PlayerBadLeaveEvent happens
i mean its basically reinventing a wheel but alright ¯_(ツ)_/¯
World#setTime()
or
World#setFullTime()
World world = ...;
world.setGameRule(GameRule.PLAYERS_SLEEPING_PERCENTAGE, 1);
thank you 👍
couldve skipped the judging me for what im trying to do part tho
how do i calculate the amount of armor points a player has (armor points = the armor icons above hearts)
I wasn't judging you. Atleast that wasn't my intention. I thought you might not know about the gamerule. And when you said you wanted a challenge I just thought it would be better to do something "more meaningful" as in "not already there by default"
Just get them from the player.
How.
Its an attribute
double armor = player.getAttribute(Attribute.GENERIC_ARMOR).getValue();
.getAttribute isnt a thing in 1.8 💀 (ik i shouldnt use 1.8 but its work stuff, i dont decide what hppns)
ouch
?1.8
Too old! (Click the link to get the exact time)
Well then update to a version that is still supported. 1.8 is ancient.
+1 i used to be an 1.8 developer and im with you
You are not alone mate
- understand my pain, i debug NPEs that are so shit, i miss 1.14 NPE update.
What are you doing if i can know?
Maybe if you want you can explain me via dm
like where i work?
Do you get an extra compensation for pain an suffering when working with 1.8? 💀
nope but gotta get the bag
NPEs are the easiest errors to fix after 0 divided by 0 exceptions. Unless you do something special that doesn't come into my mind rn
also idk what 1.14 changed about them
No no, i mean what are u coding
@EventHandler
public void onEntitySpawn(EntitySpawnEvent event) {
if (!(event.getEntity() instanceof LivingEntity) || (!(event.getEntity() instanceof Ageable))) return;
Ageable ageable = (Ageable) event.getEntity();
ageable.setAdult();
}
@EventHandler
public void onEggHitEvent(PlayerEggThrowEvent event) {
if (event.getEgg().getPersistentDataContainer().has(EntityKey, PersistentDataType.STRING)) {
String entityString = event.getEgg().getPersistentDataContainer().get(EntityKey, PersistentDataType.STRING);
entityString = (Objects.equals(entityString, "MOOSHROOM") ? entityString = "MUSHROOM_COW" : entityString);
event.setHatchingType(EntityType.valueOf(entityString));
event.setHatching(true);
event.setNumHatches((byte) 1);
}
}
@EventHandler
public void onThrowEgg(PlayerInteractEvent event) {
PlayerInventory inventory = event.getPlayer().getInventory();
if ((!event.getPlayer().getInventory().getItemInMainHand().getType().toString().endsWith("SPAWN_EGG"))) return;
if (event.getAction() == Action.LEFT_CLICK_BLOCK || event.getAction() == Action.LEFT_CLICK_AIR) return;
if (inventory.getItemInMainHand().getType() == null) return;
Entity entity = event.getPlayer().launchProjectile(Egg.class);
Egg egg = (Egg) entity;
egg.setItem(inventory.getItemInMainHand());
entity.getPersistentDataContainer().set(EntityKey, PersistentDataType.STRING, inventory.getItemInMainHand().getType().toString().substring(0, inventory.getItemInMainHand().getType().toString().length()-10));
}
can you fellows judge my code
Please use
?paste
eh so I am working a kit that would increase the damage u deal increases if u have better armor
!a || !b isnt that the same as !(a && b)
Oh ok, i ask because i was wondering to make an NPC api for 1.8 up to 1.19
Old NPEs dont show what caused it
ohh
1.8 iig?
uhh you want have access to most things
Hello, exists any guide for the firsts steps creating plugins?
I mean you got a line number. So you just check all variables in that line for null, no? Most of the time there shouldn't be too many anyway
depends. Do you know java?
Yes, exists more possible languages to make plugins?
u can make plugins using kotlin and java
Oh, I didn't know
The home of Spigot a high performance, no lag customized CraftBukkit Minecraft server API, and BungeeCord, the cloud server proxy.
Thank you!
how do I use my config from another class?
By passing class instance
dep injection or singleton pattern, doesn't matter
take a note there is #getPlugin(class) method
Simple java question. Please take a look at the java basics again.
An event which is fired when the player opens his own inventory.
I had an idea that used achievements for this. Never actually tried it.
alright
PlayerArmorEquipEvent
yeah I really should do that, I have neither coded plugins for a year, neither any other java stuff
alright events now
EventEvent
5
not because of coll's
its armor unequip
ok 7 now
8 now
these are what i have rn
just added another one
For the post process why not wait a tick,
Why is there a need to check player inventory update ?
PlayerLocationChange = PlayerMoveEvent
PlayerFaceDirectionChange = PlayerMoveEvent
im trying to do nms
Could not find artifact org.spigotmc:spigot:jar:1.19-R0.1-SNAPSHOT in spigot-repo
Did you run buildtools ?
yes
- yeah but for ease of access, and i got recommended that so
- its really useful trust me, especially anti cheats
-
- ease of access, less checks
Good evening, I would like to have my plugin send the player a chat message that uses hexadecimal codes (like # B399CC), what can I do? Because at the moment I can only use ChatColor. (COLOR) + "message".
cant u just stuff a hex into color
Did you check the methods in the ChatColor class ?
ChatColor.of
What I mean is all of this is needed in specific case, and you can easily do it by yourself.
Except the ArmorEquipEvent which I recognize is useful
player.canSee(entity)``` i spawned the mob behind me but why does it still return true?
Raytrace the player to the mob
Like this?
that wont work for multiple reasons
?jd-s look at ChatColor class, or read the discussion 👀
Did you run buildtools
tf-
again, yes, i did
its a method that draws a line between two locations
i think its used to tell if somethings in the way
^
anyways
my m2 folder does have the 1.19.2 remapped files
so why cant i use them in maven
Did you try not being a cringe vampire for once?
Show pom
This isnt even valid java...
vampire moment
?paste
wasnt aware that was there
All of them
lol what he heck
didnt fix anything tho
org.spigotmc:spigot:jar:remapped-mojang:1.19-R0.1-SNAPSHOT was not found in https://hub.spigotmc.org/nexus/content/repositories/snapshots/ during a previous attempt. This failure was cached in the local repository and resolution is not reattempted until the update interval of spigot-repo has elapsed or updates are forced
Well if you ran BuildTools for 1.19.2 then your repo will only contain 1.19.2
so youre saying replacing it with 1.19.2 would work
well new issue
wheres the biome fog gone
The what
Biome.L() ?
at least that what it was in non remapped half a year ago
the issue is
its not showing me an import option
so im asking where it is to type in manually
Decompile biome and look
Those are the biome statics
does player.getWorld() return the world in main (like no matter in which dimension, just the world) or the specific world like nether end or overworld
Hi i have a pb with cancelling droped item when a player die. Is it good ?:
p.getInventory().clear();
for (ItemStack stack : e.getDrops()) {
stack.setType(Material.AIR);
e.getDrops().remove(stack);
}
Its the World the Player is currently located in
The specific world
Dimensions are just worlds
hmm makes sense
Location centerUpperLeftQuarter = new Location(w,0.25*center.getX(),center.getY(),0.75*center.getZ());
Location centerUpperRightQuarter = new Location(w,0.75*center.getX(),center.getY(),0.75*center.getZ());
Location centerLowerRightQuarter = new Location(w,0.75*center.getX(),center.getY(),0.25*center.getZ());
Location centerLowerLeftQuarter = new Location(w,0.25*center.getX(),center.getY(),0.25*center.getZ());
This should return Corner positions of WorldBorder
But it doesn't return them correctly
idk someone said you shouldnt use onPlayerDeath or onEntityDeath
try it out
This makes no sense
Try 0.25 * 2 on your computing machine
No the multiplication makes no sense in the first place
0 < a * b < b if 0< a < 1
Any reason why you dont just get the WorldBorder object?
wait sheet I send wrong snippet
Location center = border.getCenter();
double distanceFromSideToCenter = border.getSize()/2;
Location upperLeftCorner = center.clone().subtract(distanceFromSideToCenter*2,0,0).add(0,0,distanceFromSideToCenter*2);
Location upperRightCorner = center.clone().add(distanceFromSideToCenter*2,0,distanceFromSideToCenter*2);
Location lowerLeftCorner = center.clone().subtract(distanceFromSideToCenter*2,0,distanceFromSideToCenter*2);
Location lowerRightCorner = center.clone().add(distanceFromSideToCenter*2,0,0).subtract(0,0,distanceFromSideToCenter*2);
With your logic the border gets bigger the further the center is away from the origin coords
how do I check what dimension a world is?
getEnvironment()
Why making * 2 ??
"distanceFromSideToCenter", why would the side be "twiceTheDistanceFromSideToCenter" ?
I was first testing it without * 2
but it also didn't work
Then I tried * 2 but also didn't work
Campfires mark those positions
this is without *2
can anybody tell me what I can write instead of that and if this is bad
Why would it be bad
Anyway plugin var could be private
ig ¯_(ツ)_/¯
xp 💀
filter*
but doesn't work in theory 🤷
I was thinking why my plugin wasn't working when I forgot to add saveConfig lol
wait, is WorldLoadEvent static?
What would that even mean
idk I remember forge split static and non-static events or something like that
Hello, I am trying to format the chat messages on my server so that they do not include the chevrons "<" and ">" around the player names. I was able to do this by calling AsyncPlayerChatEvent.setFormat("%s %s") but now my chat messages are showing a "?" after the message and when I hover the message it shows a popup that says "This message has been modified by the server"
Does anyone know how to get rid of this popup?
It seems that other 1.19 servers are able to remove the chevrons without showing that popup
Via preview
whats that
i see.
still no idea how to use it but ill search
so I have this code but I checked the console and there's nothing
@EventHandler
public void onWorldLoad(WorldLoadEvent event) {
plugin.logger.info("WorldLoadEvent executed");
}```
its getLogger().info(msg)
but the .logger is just a variable with .getLogger()
and make sure it's registered
you mean this?
Ye
by code you mean all the code or just the file with the events?
the code with the event and the code where you register it
I tried adding these event listeners but it is still showing that the server modified the message 😕
@EventHandler
public void onAsyncPlayerChatEvent(AsyncPlayerChatEvent event) {
event.setFormat("%s %s");
}
@EventHandler
public void onAsyncPlayerChatPreviewEvent(AsyncPlayerChatPreviewEvent event) {
event.setFormat("%s %s");
}
Main file: https://paste.md-5.net/evuqenuzik.java
Events file: https://paste.md-5.net/onufenofan.cs
does your onEnable log properly
yes, the other events seem to be working
if you want it to load BEFORE world load add this to your yml
I forgot to change the order
load: STARTUP
I completely forgot about that
Pretty sure you don't need the first event anymore
Just do the Preview one
Nevermind I lied
the problem is I still respawn here while my config says mainZ: 440
What's your respawn event ?
have you checked if you get a value properly read out from the config
just print it to console
considering you spawned nearly exactly on z=0 it mighve just spat out the default zero
okay so i know im asking this every 2 months but which file is the reobfuscated one again
remapped or remapped-obf
Thank you for the response! I thought that too at first, but it seems like both are needed. I just don't understand why it says "This message has been modified by the server"
cuz u cant chat report modified messages cuz they might be from the server
as i said
blame microsoft
It's definitely a weird system, I'm sure there's something out there you can read up on more about how it works. I'm sure once you know what it's doing, you can figure out how to get around it.
Spigot might have a thread on it somewhere. I just dont know where.
I blame Microsoft, but I still think there is a way around it because other servers don't have this issue
stupid question but what color is this? i tried every color code/ ChatColor and cant find it
for the "Mana Cost" string
&7 is this
but that is darker gray-
what-
oh
thats light gray
yeah
ig
what world u living in where 8 is light gray
Is there any way to change the format of chat messages without marking messages as "modified by the server"?
broo it is &8. the stupid website https://minecraftitemids.com/color-codes looks way different
An up-to-date list of all Minecraft color codes along with an easy-to-use text generator for previewing and testing messages. Color codes work on all Minecraft messages including from Bukkit, nicknames, Essentials, and server MOTDs.
yes
if (action.equals(Action.RIGHT_CLICK_AIR) || action.equals(Action.RIGHT_CLICK_BLOCK)) {``` its only working when i right click a block and not when i right click air
No event fires for empty hand right clicking air
its not empty hand tho
check if clicked block is null?
no cause im making a custom item
when they right click it
yeah thats what im doing
public void playerInteractEvent(org.bukkit.event.player.PlayerInteractEvent event) {
if(event.isCancelled()) return;
Block block = event.getClickedBlock();
Action action = event.getAction();
ItemStack item = event.getItem();
Player player = event.getPlayer();
World world = player.getWorld();
if (action.equals(Action.RIGHT_CLICK_AIR) || action.equals(Action.RIGHT_CLICK_BLOCK) || block == null) {
if (InferiorDragonSlayer.isItem(item)) {```
"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.
kewl
if(event.isCancelled()) return;This is exiting the event
right click air with anything the event fires in a cancelled state
Is it acceptable for a one-event plugin to have it's event in the main class?
(so just a miniscule under 500 bytes plugin sort of deal)
No I meant
Everything together is like 3,79KB
don't wanna make it 4-5kb just for a util I'll use
I know...?
I just like small sizes lmao
I normally make a PlayerConnectionListener, a BlockBreakListener etc
hi, so basically this says Success when i do /im name something but doesnt rename the item, any idea why?
never made one file plugins
You need to set the item's meta back to it
ItemMeta meta = item.getItemMeta();
// stuff
item.setItemMeta(meta);
oh yea thanks
does anyone know how to get a list of materials that have colliders
isBlock/isSolid I think
or the opposite, to get blocks that you cannot collide with
does this return things like stairs too
Looks like a mod or a custom resource pack
can you give a pdc to a entity spawned from an egg
Listen to the entityspawnevent, add pdc, boom
cancel the egg hit event and spawn the entity yourself, then you can apply the PDC easily
alright i will do that
hello, is the better way to use method of class "A" in class a class "B" is to create an instance of class "A" in class "B" or just do in the class B : A.methodIWantToUse ?
Hi, I just have the problem that the test message is never output. I want to add in my plugin the possibility to load addOns. The jars are detected in the upper for loop. I suspect that the problem is in line 13. Does anyone know what the problem is? In the addOn is a folder Meta-Info with the Plugin.properties.
https://pastebin.com/Sn13NJXC
Pastebin.com is the number one paste tool since 2002. Pastebin is a website where you can store text online for a set period of time.
You'll have to choose the way you want. It all depends on how you want to use it and how the class is supposed to act.
Java is very very object oriented, so the main usage would be:
GRAB the instance of the object (do not create it each time, use the one you need), and call the method from the instance.
But if you want to have like a Utility class that only bring a static simple method which don't use memory make your methods static so you can Class.coolMethod()
Do you have any error?
No
Can you please surround your call to the method with a try catch and print the exception ?
The call to loadPlugins()
This is my LoadCode:
try {
loadPlugins();
} catch (IOException e) {
throw new RuntimeException(e);
} catch (ClassNotFoundException e) {
throw new RuntimeException(e);
}
For debugging purpose, temporarily do:
Try {
LoadPlugins();
} Catch(Exception e) {
e.printStackTrace();
}
(sorry written on android)
okok thx for the response, in my case, it is only a Timer (Instant) class, i just want to grab timer in other class
Still no error comes
how can i change the sky's color? im pretty sure its packets
biome fog
what is the packet's name?
thats not a packet
oh
well its a packed if you want to pretent only to one player
method im thinking of does it for all players
can you show me an exmaple?
not one that works
get the world and the biome. that biome has a field, dunno the name, that has the colors of stuff like grass, leaves and sky. change the color of that
you probably need nms for that
shhh
uuuuh
java.lang.NoSuchMethodError: 'hc net.minecraft.server.level.WorldServer.w(net.minecraft.core.BlockPosition)'
did i just copy the wrong file?
can you explain a bit more?
im using remapped
Seem it has something to do with PacketPlayOutGameStateChange
my bad it's not the new way, it's only the "old school rain packet"
#1012313792488681492 for any one whos willing
Indeed you'll have to manipulate a chunk and send a chunk update packet
same way 🙂
Change the biome color!
#1.16 or 17 joy
In fact you can change:
- sky color
- foliage color
- water color
- water fog color
- grass color
- fog color
You can with NMS edit the biome colors
There are some fields for it
the real issue is
once you edited the field how do you get them back into biome
the fields are all private
i found that much but how can i actually set a biome
Any opinions about my sneaky coding
i hate generics so you really shouldnt ask me
Can you turn Class<?> into Class<T>? Not sure what your use case is.
You can pass Class<T> and make the type cast handleable at runtime
Also Jedis is the worst redis library
And you should use a codec instead of having everything doubly en/decoded to/from a string
Does someone have an implementation of an ItemStack list compression method? It would be bothersome to write it, if something of the sorts already exists.
Where do you want to persist this list?
Rephrase that, please?
I am assuming that you want to serialize a List<ItemStack> to a String and store it somewhere.
My question aimed on finding out where you want to store this list.
Oh, no. I meant compressing the ItemStacks inside the list. I.A, if the list has two ItemStack(Material.STONE, 32), it would compress them down to an ItemStack(Material.STONE, 64)
I hate it but it works and it's simple enough
Ah i see. I might have a utility method for that.
I would highly appreciate if you could share it then, it would avoid having me go through the trouble ^^
Ah, that's alright. Thank you anyways!
Im thinking of an algorithm that isnt horrible. But the fact that hashCode cant be used because isSimilar has
to be called, makes this a pretty cpu intensive one.
if a super type which was immutable of ItemStack just existed 😐
This is O(n^2)
public List<ItemStack> compress(List<ItemStack> list) {
List<ItemStack> compressed = new ArrayList<>();
list.forEach(item -> insert(compressed, item));
return compressed;
}
private void insert(List<ItemStack> list, ItemStack itemStack) {
for (ItemStack current : list) {
if (!current.isSimilar(itemStack)) {
continue;
}
if (merge(current, itemStack)) {
return;
}
}
list.add(itemStack);
}
private boolean merge(ItemStack target, ItemStack donator) {
int max = target.getMaxStackSize();
int space = max - target.getAmount();
int donated = donator.getAmount();
if(space >= donated) {
target.setAmount(target.getAmount() + donated);
donator.setAmount(0);
return true;
}
int delta = donated - space;
target.setAmount(max);
donator.setAmount(delta);
return false;
}
You can also be a bit sneaky and try this 
public List<ItemStack> sneakyCompress(List<ItemStack> list) {
Inventory inventory = Bukkit.createInventory(null, 6 * 9);
list.forEach(inventory::addItem);
List<ItemStack> compressed = new ArrayList<>();
for(ItemStack itemStack : inventory) {
if(itemStack == null) {
break;
}
compressed.add(itemStack);
}
return compressed;
}
And if you dont care about performance on top of that
public List<ItemStack> sneakyCompress(List<ItemStack> list) {
Inventory inventory = Bukkit.createInventory(null, 6 * 9);
list.forEach(inventory::addItem);
return Arrays.stream(inventory.getContents()).filter(Objects::nonNull).toList();
}
@gray merlin Mind trying those 3 approaches for me?
Will do, one second.
wtf 7smile
just iterate over every itemstac once
keep track of the item total
then generate the proper amount of item stacks
im trying to use this idk how to get the world from the cfg
Location loc = new Location(World, Double, Double, Double)
O(n)
The first one works flawlessly: The increasing time is a very small issue, but it's almost instant on compressing a player's inventory.
However, this does make a lot of sense, and I hadn't thought about it. I'll write that one, since, I mean, It's O(n). That was a very good idea, moterius
something along the lines of
HashMap<Material, Integer> itemmap;
public List<ItemStack> compress(List<ItemStack> list){
//init map
for(ItemStack i : list)
itemmap.put(i.getMaterial, itemmap.get(i.getMaterial,0)+i.getcount);
for(Material m : itemmap.getKeys())
//etc
}
keep in mind to not accidentally compress unique items though
might need a check for that
maybe use a hashset or smth to prevent that
We can get the max stack size for an item so that probably won't be an issue
This is useless. An ItemStack is not just a Material.
most itemstacks are only a material and a number
thats why i said to check for uniqueness
usually you can ignore those and just compress the rest
because those unique items are either unstackable - enchanted gear - or really rare, which usually would be something renamed
alternatively for approx O(n log n), keep two lists, one of non-full stacks and one of full. iterate over the non full list with the new item, add it, and if it exceeds max stack number add it to the full list, and the remainder to the non full one
Sounds like a lot of unnecessary logic to me.
Thats basically what im doing in the first approach.
Hello, i have some issue by updating Config file,
On a specific Config key it will not updated. whats wrong?
https://paste.gg/p/anonymous/690ffc7e4e3244e68f2f51138685c328
hm i see
im unsure if keeping a separate list would be faster
i dont actually know the heap sizes and performance impact of collections very well
like
theoretically or for massive amounts probably yes
but not for like 54 itemstacks
Use Spark
than you dont need make heapDumps
'''Can someone look at this'''
https://discordapp.com/channels/690411863766466590/741875863271899136/1012875651105165352
void damage(double amount,
@Nullable
Entity source)```
Will the killer be the source?
is it possible to use a weapon to damage a entity
hit it
theres probably a damage method for that but im not 100% certain
I couldn't find any methods for it
void damage(double amount, Entity source)
Deals the given amount of damage to this entity, from a specified entity.
Than you can damage a entity over a OnDamageEntityEvent
Yeah
not sure whats Event is
but u can't calculate the damage from a item right?
yeah
but it's very tedious
plus there is Block#breakNatrually(ItemStack item) so I thought there would be one for this too
well if there isn't, is there a way to force a player to hit a entity using a Item?
Is it really tedious tho
I’m sure NMS can handle it
It's simple math
player strength+ other attributes
yeah that's why
I didn't want to do that
thats a simple method, cancel damgeEvent if not having a specific item in hand
idk much about nms, I've just been using protocol lib
A other question, can a Config.yml key be in used by a progress. so it will block edit them? with getConfig.set()
It seems like its only on a specific key, not all of them can't be edited just one so far.
Be what
@lost matrix @smoky oak
https://pastecode.io/s/nt5n3yib
I have finished the implementation. This handles uniqueness, and is O(n), using @smoky oak's idea, and some of @lost matrix's reasoning.
settings:
global:
spawner:
spawnrate-percentage: 80
spawnrate-delay: 5
spawn-max-entities: 4
stack-size: 64
spawn-distance: 64
distance: 64
skyblock:
save-interval: 300
Only settings.global.spawner.distance can't be writen
oh thats a good idea
Here's it inside minecraft
using a pivot as item stack takes care of a lot of the messy stuff i wouldve done
also cant you do the last part as a while loop? while get > amount : clone; set size amount; decrease get by amount
then do the last part where it generates a stack with the leftover?
removes the if else thing
To be fair, I was so happy that I found an use for a "do while" that that kinda went as an oversight
I still don't quite understand what you mean
//for item in list
int amount = item.getMaxStackSize();
while(generationMap.get(item) > amount){
ItemStack itemClone = item.clone();
itemClone.setAmount(amount);
compressedList.add(itemClone);
generationMap.put(item, generationMap.get(item) - amount);
}
amount = generationMap.get(item);
ItemStack itemClone = item.clone();
itemClone.setAmount(amount);
compressedList.add(itemClone);
that
Ahhh, true.
welp imma go and die now
ive been awake for far too long
maybe ill be existent in another 12 hours
oh before i go tho
we do have a dedicated paste
?paste
oh hastebin
I stopped using that one because it broke for me many times
but i'll keep that in mind for spigot
thanks!
NGL this kind of goes against DRY
what now
So i'll just keep the do while
The "Don't repeat yourself" principle, I use it quite a lot
ah well you could stuff it in a method
i think my method is faster so I would use my version
Yeah, that's fair
but i cant know without benchmarking and it doesnt really matter for like 60 items max so
?paste
🤷♂️
Here's it using yours
I'll use my method though, since it complies with DRY & it's literally the first do while that I use in like... Three years? xD
Thank you guys for the pointers!
sure
one lesson i learned while programming is not to optimize prematurely or in the wrong spot
some youtuber made a video to the effect 'if your code is horrible but still only takes 20ms, you should optimize your graphics engine to fix lag, not your o(n^2) method that you call once every three minutes
Depends on how far you’re going to scale things
But generally speaking thats the principle
why does everybody have a new profile pic except choco -.-
That's fair enough.
Well
Got access to DALL-E 2 <o/
Dont think so?
good news is they are not dead
Sorry for pinging but can you explain me async?
Because i know what its and how it works but i dont know how to apply or implement it into java
async is the process of spreading out the work load. This can be done over a period of time or with the use of threading
if you don't use threads, you would have some form of timer that dictates when it needs to stop processing on that work because it is taking too long and to move onto something else
Just use build in classes for it ie Executors (or BukkitRunnable if working with spigot)
You can Google about executors
they are not wanting to know how to use executors
they are wanting to know implementation
?
two very different things
I mean i dont know what to use for async in java
Executors
Since there are lot of things, Future, ComplatbleFuture, Executors
CompletableFuture
Async is the art of code that does not run linearly to its natural flow of declaration
I abuse CompletableFuture
Nvm, I thought they were attempting to make something of their own, which is implementation lol
Has nothing to do with multiple threads inherently
There i so much shit for aync that im lost
It really depends on your use case/but executors are always a way to go
Ok
Because im doing an event-driven system based on redis
So i want to implement async into my events
CompletableFuture just plays with executors internally
Its alr partly async
this is terrible
Everything is async usually, async is just a relation at the end
but ok
I mean im doing a Packet based for redis and i have already implemented an event driven to listen the pckets
I mean they probably write an abstraction on top of the redis impl
Dk how terrible that is
Dont know
I mean you said that what ima doing is horrible?
No
Multithreading is one of those concepts that I understand but can't explain
But anyway what redis lib do u use
basically what i do
yeah i think using redis alone its really pissing because it rather support String or Byte
I basically just made a 'Packet' of sorts that just contains like an id, serialize/deserialize methods from whatever object im passing over redis
🥰
Nice
Mye ig
Sure

VANO13
I mean i have my own event-listening which works similar/exactly the same as spigot ones
Oh ok
🥵
And now i want to make the async part
LMFAO
Youuuuu alrwady sent it in general :-{
not a futuruma fan I guess, eh
Myeah
Just invoke the method on whatever thread needed
I wish having two instances of Minecraft open with intellij was doable on my computer
Translation to english-english please
For me eclipse works like a beest🤣
Executor executor = Executors.newCachedThreadPool();
executor.execute(()->{
try{
eventManager.callEvent(event);
}catch(Throwable e){
//handle
}
});
Verano
Minecraft eats all my memory
Also eclipse is fine
Nom nom
I mean i have ilnesses with eclipse
I sufered a lot when i used it
Now that im able to auto maintain jetbrains ultimate version 🤑
You need to know how to use true
Jetbrains ultimate >> Eclipse
Althought Jetbrains Ultimate neither Jetbrains community are optimized i can confirm that
I think i have a lot of pain when i go over Jetbains scared to break all my stuf
be a real chad like me and use VSCode
not really have you ever actually used it or do you just hear things and spout them back out
lmao too much air for day
I dont have anymore i cannot figure how i smoke a cage of 12
I know its non topic related question but im feel my self really dumb
Conclure also thanks for providing me that example
VSCode uses JDT afaik, so Not tooo much of an issue ig
And I beliebte IJ is able to convert JDT Projects to IJ projects. I really Wonder why people don't use eclipse more often If it is compatible with any other mainstream IDE outside netbeans
And do Not Tell me that you are using vi - because that is false
There are No Java devs that use vi. Only C/C++ use vi because their tooling sucks ass
the only issue with eclipse i see is it looks old
otherwise it works perfectly fine
Sorry WHAT
Nah, IntelliJ Just Looks futuristic
VSC looks better than eclipse lol
I'm addicted to my enhanced text editor that provides the same functionality as an IDE
don't forget the fact it uses its own maven implementation
vsc looks nice because it's minimalistic
oh yeah forgot about that lol
when I used eclipse I couldn't get maven to work out of the box so that was why I swapped to ij
When I wanted to use maven I swaped to vsc lol
I have brain damage though so
I make bad decisions
yeah and then instead of just hooking into maven they just made their own version
big brain
for the most part it works almost the same, just some things not so much lol
I like eclipse for how light it is, if I had managed to repair my old laptop I was planning on putting eclipse onto it so I could've coded plugins while in school kek
eclipse doesn't give me the impression for being light
when it takes ages for it to load
it loaded so fast for me when I used it
I'm on the ultimate text editor right now
hasn't been wood for a long time
idk, whichever version they added different buttons for different wood types
"minecraft when did they add spruce buttons"
1.13
literally the first result of google if you google button in minecraft
quite literally the easiest thing to do
you mean lack of vocabulary skills
only two words have to be used, button minecraft
learn and adapt or get left behind 🙂
Hi, is there any way to make a fishing rod bobber invisible? The FishHook cast to an entity has no .setVisible
public class B extends A {}
A.class.isAssignableFrom(B.class); // true
owo
Use maven or gradle or get rekd. Im tired of people who still havent read the 1.17/1.18 announcement, duh
how do I make a plugin that changes the server-side collision for blocks?
no
affecting mobs
idrc about the client movement
that's why I said server-side collision
rubberbanding because of different collision from client/server is the behavior I'm looking for
you need NMS
but it won't properly work because the client will not understand your custom logic
that's exactly what I want
rubberbanding and glitchy behavior
yeah that won't work unless you hook into the netty handler and do all the calculations yourself
what are you trying to achieve exactly?
removing collision from blocks that have collision and adding collision to blocks that don't have collision
the client already does the collision calculations before it sends any movement packets
yeah exactly
you cannot just get rid of them
I'm only looking to modify serverside collision
nothing client-sided
it's desirable to have the desync between client and server
but the client won'T allow you to do any "physics" that woulnd't work in vanilla
yeah exacctly what I want
only server-side entities would be affected
clients would just be glitchy at most
you cannot do that
yeah so I don't need anything on client
I don't want it to be modified on client
only server
so it desyncs
then you gotta listen to the PlayerMoveEvent, do all the calculations yourself (which are complicated as fuck) and notify the clients about their acrual new location
huh
I don't have to though
I don't want the clients do have the new collision
only entities
so mobs can go through walls but players can't
that's even more complicated. you gotta mess with every Mob's pathfinder goals then, I guess
Probably not with a plugin
I saw few that does it
You’re better off modifying the server itself
yes, if you do some extremely sophiscated math yourself
https://github.com/Camotoy/GeyserHacks
this for example
disables bamboo collision for alternate clients
Map<Integer, String> prefixes = new HashMap<>();
String highest = prefixes.entrySet().stream().sorted(Map.Entry.comparingByKey()).findFirst().get().getValue();
I need te equipvalent but for Set
?
I need to sort a Set<Listener> via priority
use a List if you wanna sort it
Oh ok perfect, but List doesnt require more than a Set
while a list is a sortable list of objects
Because Set is ordered right?
no
I have mess with the collections
a Set, or at least most set implmenentations, do not have any order
So why i cannot sort a Set?
Sorry for being painful..
Set = random amount of things
List = random amount of things with a particular order
(not 100% true but that's the general idea of set vs list)
set = "list without order"
but List desnt have an order
bullshit
Its weird
ArrayList is insertion ordered for example
wanna sort? use list. don't wanna sort? use set
I dont need order althought i just need to sort them before invoking each event
yeah
can I teleport player without sending packet
Perfect im using a List
Quick question, for the projectile launch event, does the get entity method get the specific unique identity of the projectile?
Player a;
Player b;
a.teleport(b);
of course. but without sending the packet, the player doesnt know that htey were teleported
yeah so how? do I teleport them and cancel the packet?
or is there a method to teleport them without sending the packet
Unique identity?
?!
mfalex i mean i dont understand how to sort a List correctly
why don't you just use Player#teleport ?
Inded
Like perhaps the uuid of the arrow that was shot?
that tells the player that they were teleported
Sure
List#sort(...)
I know that
getEntity().getUniqueId
Ah alright thanks
I want to teleport them without sending teleport packet
so the client doesn't know that they were teleported
but instead it just thinks it's in the same place
while it's at a different place on the server
I’m sure you can, but you’d have to go fairly deep into NMS
so teleport then cancel packet is easier
mfalex
The main issue is that i have ListenerInfo object which i need to sort via the Priority
And priority is not inside ListenerInfo, is inside the object EventHandler
is it possible to detect when a player moves there head or smthn like that im trying to make it so the player moves in the direction they look (up down left and right and the armorstand they are on is what moves)
PlayerMoveEvent
that gets the location though
Location object from bukkit allows you to use methods getPitch() and getYaw()
What are u trying to do so?
It’s also called when their head moves
Something that could sound rude but why do you discuss with someone already experienced?
😂
huh?
player.getLocation().setX/Y/Z seems to work for teleporting players without clients knowing
I think
or maybe not
Because there's a teleport() ;p
NMS doesn’t even have that I imagine
why not
I could make it call main thread
then teleport player
then cancel packet
but that's sooooo dumb :(((
I wish you could touch the nbt directly
Everything saved in NBT can be directly accessed with methods on Entity and its derivative classes
you can
like item nbt?
ItemMeta
but in regards to teleporting players however and not have the client know is actually impossible. You could kind of simulate I suppose but I think you are unaware of the relationship of the client and server
like how you do it in vanilla commands?
the client is the one that controls the location for the most part
yes
so I'm trying too force a position
just on the server
to get the desired effect
not sure what effect you are wanting
server using different location from client, so it does different calculations
like you want the player to be floating with nothing around?
you could do that in just the code
new Location()
no
I want the player to think that they're not teleported
but they are at a different place actually
ok, not sure for what purpose and still don't know what effect
aaaaaaa
my alt+tab keeps switching to wrong window
anyway
the effect is
doing movement calculations myself
so when I'm done
I can teleport them without sending a packet
this doesn't really make sense
elaborate more
soo the server can't mess with the player's location
it can but go on
idk how to explain really
then it sounds like you might be going about this the wrong way then and might need to think about it more if you are unable to explain it in such a way to get help
You want to disconnect the client and the server so the client sees one location and the server another?
yes
Why
so I can make the server behave as if the player is somewhere else
this is what I was trying to have them explain, which they seem to be unable to do so effectively
What would this accomplish?
maybe I can try with a bukkitscheduler (to teleport them in main) and canceling packet
You can't just disconnect the two. They're intrinsically linked
not only that, for the most part the client dictates the location
To do so would potentially make the game client authoritative
yes the server can change it, but you won't be able to really do so without the client knowing
hmmm?
for example player is at position x on their own client but other players sees them at position y
If you don't tell the client where it is ever the client would be desynced and unable to do anything
alright this is sometihng that is already doable without any fancy trickery per-say or some advanced stuff.
You can create a fake version of the player I suppose and hide the real one
not really
Or just mess with the packets being sent to other clients
then the server thinks the player is at the correct location
which is not what I want
the server doesn't need to duplicate the player
in fact the server doesn't need to know that the other entity is a fake player only that it is just an entity
what the entity looks like the server doesn't care
so you can dress it up as a clone of your player
can't I just make the server think that the player is at position x but the player is actually at y
and it mimic movements
COLL!!!! ❤️
what you've explained is just visual
the way you are proposing or thinking would require two player objects which you can't have duplicate player objects
Lmao trying to jump thru a window because i cannot do a simple list sort by priority
so the better way is to use another entity that looks like your player and mimics its movements. Your players won't know the difference depending how well you do it
lmao
then it's not the real player
it doesn't need to be
Can't you do this?
it does for what I'm trying to accomplish
ok so far we have covered the appearing in two locations
what is the next thing it needs to accomplish
Or this @sterile token
In my case its really diff, i have a List<ListenerInfo>, then i have a EventHandler reference, and then from EventHandle ri can finally get the priority
right now you have some of the most experienced individuals on right now in regards to knowing MC inside and out including the client. You won't be able to separate the client and server from being synchronized. However there might be other ways to go about what you are wanting to accomplish. Let us know what else needs to be done, we discussed how you can make it appear for a player to be in two places
not sure what else you need to have it do that would absolutely require a duplicate player object
no duplicate needed
just client thinks location x server thinks location y
server rejects client's location
and it just believes its own imaginations
server doesn't think anything is the thing
the server only knows where the player is at, because that is what the client said
then it doesn't have a way of knowing where the player is at in the world
exactly
I mean
what I want to do
Start by casting out any movement packets from the client
Try cancelling the PacketPlayInFlying packet
See what happens
yeah the player just gets stuck server side but client can move
but I need to move that player without telling the client
yeah by cancelling that packet I mentioned above, that should be possible
Use reflection to update the players position field
Cancel the teleport packet being sent to the client
Or cancel the clientbound movement packet
this one
that sounds more stable, can you explain
You can't do this because if the server doesn't know where the client is then the client can't load any chunks
that's what I want
Not much to explain
I believe there is a better way to do this, instead of all this complex stuff if they would just explain the reasoning behind needing something like this
how can i have 2 of the same variable in an arraylist
This sounds so awful you're just desyncing the client for no reason
The players position is probably private, so you need reflect to change it
In EntityPlayer or Entity or wherever it is
client will disconnect on desyncs too 😛
but I will let them figure that out I suppose
Never seen that happen
where can I see private methods?
Decompiler
Afaik the client only disconnects if the keep alive system fails
Or yknow, they press the button
This whole thing seems like a long winded XY problem but what do I know lol
well both of us
You might be able to use the method "setPositionRaw" if it doesn't send any packets to the client about their position @valid sorrel
o
I don't see it anywhere
What version is this on?
1.19.2
alr thanks
So the client rubber bands and then the server moves the players actual body around? Who would use such a system lol
the client doesn't know that it's being moved around
So the server is moving the clients body around and the client isn't moving?
And you want to desync them instead of just making the player invisible and moving a fake version of the player around?
wonder where it overrides getlocation
yep!
Basically the client and server stop communicating the players position with each other
So single player but worse
?
This seems like it's going to be a disaster waiting to happen
I love disaster
probs
owo
oh definitely, I had 0.25/80 internet once
bro what
Who provides 80 down and 0.25 up
great
Now I’m even more confused
do you know where the location is coming from in Player
Who provides 0.25 down and 80 up
so I can modify it
https://www.geeksforgeeks.org/can-an-arraylist-contain-multiple-references-to-the-same-object-in-java/ says // e1 will be inserted again as ArrayList can store multiple // reference to the same object but when i try the 2nd time i add the same object it just doesnt add why would this be happening ArrayList<String> testing = new ArrayList<>(); testing.add("hi"); testing.add("hi");
idk some provider which has way too much download but too free upload
This works

