#help-development
1 messages ยท Page 57 of 1
Every programmer ever
Most of the time it's all shit
I've been using Stackoverflow less often these days
But we still got to respect the legends on stack overflow
Same
But thats mainly due to me learning how to code from stack overflow and other mediums lol
You probably need to either do that manually or use a lib
I haven't heard of anything within java's stdlib to convert between these representations
Actually I have been wrong
Can anyone help me with installing buildtools as for some reason its just not working for me
Something like
TemporalAccessor accessor = DateTimeFormatter.RFC_1123_DATE_TIME.parse("Mon Sep 12 12:23:07 CEST 2022");
Date.from(Instant.from(accessor));
(you probably need to use another standard there though)
Please elaborate by not working
if im using this https://blog.jeff-media.com/nms-use-mojang-mappings-for-your-spigot-plugins/ what version of the maven dependency would i use in my compile module? in this example they use 1.18.2 but my plugin supports 1.18-1.19
Is it possible to remove all elements of a Stream except the First and last element?
You'd need both
๐ฉ
I.e. multi-module project
wdym
(hence why I generally recommend to prefe grossr hacks over NMS)
id need a 1.18.2 and a 1.19 one in my compile pom?
No, you need three poms
No four actually
you need one module, e.g. one pom, per NMS version. And you must never have more than one spigot version per module
I'm using the bat method rn and everytime I run the bat I enter the minecraft version(1.17.1) and then enter the java version (16) and it just doesn't do anything after that it makes a folder and inside that folder is just the jar file of buildtools and thats it
Or five depending on how you do it
If you are using windows I might be able to help you
I also tried the other methods as well using git but same thing
i have a plugin pom, 1.18 pom, 1.19 pom, and api pom
here's an example for something that supports 1.16.1 up to 1.19.2 with one module per NMS version https://github.com/JEFF-Media-GbR/JeffLib
yeah I am
cd BuildTools
curl -z BuildTools.jar -o BuildTools.jar https://hub.spigotmc.org/jenkins/job/BuildTools/lastSuccessfulBuild/artifact/target/BuildTools.jar
set /p Input=Enter the version: || set Input=latest
java -jar BuildTools.jar --rev %Input% --remapped
pause```are you using this?
oh okay that's good then
So a parent POM, a common nms api POM, a 1.18 pom, a 1.19 pom and a base impl pom
No I was using the one that was on spigot I could try using this though
I used that when I was using windows and it never failed me
Alright I'll try it
Suppose i have an array
{1, 2, 3, 4, 5}
How can i remove 2, 3, 4 ???
Hmm it now just creates a buildtools log saying "Please do not run BuildTools in a Dropbox, OneDrive, or similar. You can always copy the completed jars there later."
?
let me try something actually
Just run it directly on your disk/drive
Arrays cannot be shrunk
You'd need to create a new array that has those objects removed
Do you know how to use stream?
ok ty got it finally working
lit
public List<Integer> higherLowest(String string) {
List<String> listString = Arrays.asList(string.split(" "));
List<Integer> listInteger = listString
.stream().map(Integer::parseInt)
.sorted()
.collect(Collectors.toList());
return listInteger;
}```
Basically i need to enter a String of integers like `"1 3 4 5 2"` and then it needs to return a list of the highest and lowest. `[1,5]`
The easiest option would be to do
int[] array = {1, 2, 3, 4, 5};
int count = 0;
for (int x : array) {
if (x == 2 || x == 3 || x == 4) {
count++;
}
}
int[] copy = new int[count];
count = 0;
for (int x : array) {
if (x == 2 || x == 3 || x == 4) {
copy[count++] = x;
}
}
Oh bruh
Then after sort return Arrays.asList(listInteger.get(0), listInteger(listInteger.size() - 1))
im so dumb
okay
i was doing List.of and things tryna cry ๐
Thank you ๐
no problem...
public List<Integer> higherLowest(String string) {
int max = Integer.MIN_VALUE;
int min = Integer.MAX_VALUE;
for (String s : string.split("\\s+") {
int x = Integer.parseInt(s);
max = Math.max(max, x);
min = Math.min(max, x);
}
return Arrays.toList(min, max);
}
public List<Integer> higherLowest(String string) {
List<Integer> listInteger = Arrays.asList(string.split(" "))
.stream().map(Integer::parseInt)
.sorted()
.collect(Collectors.toList());
return Arrays.asList(listInteger.get(0), listInteger.get(listInteger.size() -1));
}
}```
Does configFile.getName() include the yaml file extension?
But performance ๐ข
just chuck an async at it, who cares anymore?
Let them do what they like... It's hard to explain about performance now ๐คท
(that was a joke)
You can only make it async if it is like an insanely big string
They will learn about performance later ๐
At which point you probably want to do something like radix sort
guys how do i spawn a custom entity at a specific location
customentity.setlocation doesnt work
method doesnt exist
spawn method takes a Location, unless its an NMS entity then its placed when you add to the world and have called setPos
oh im dumb
its an nms entity
does addFreshEntity do the same thing as addEntity
on what class?
Thanks for help ๐คท I had to use a packet to close the inventory too ๐
Did not expect that...
https://ibb.co/d4THcKM
Cannot resolve com.comphenix.protocol:ProtocolLib:5.0.0-SNAPSHOT
Cannot resolve net.bytebuddy:byte-buddy:1.12.12
im getting this`errors when trying to add prorocollib to my maven project
If I update an ItemStack's ItemMeta through a different instance, will it update?
?paste me your pom.xml
Hey guys, is there a way to make a Specific Block object unbreakable?
private void makeSafeLanding(Location location) {
Block block = location.getBlock();
Block blockBelow = block.getRelative(BlockFace.DOWN);
Material initialType = blockBelow.getType();
blockBelow.setType(Material.HAY_BLOCK);
Bukkit.getScheduler().runTaskLater(Tyrants.getInstance(), () -> {
blockBelow.setType(initialType);
}, 2000);
}```
I'm making a safe landing block and I don't want users to break it (either they can't break it or it won't drop an item)
Listen for players trying to break it in the BlockBreakEvent
is keeping a collection of chunks mem safe?
I doubt it, maybe a reference to chunks?
How would I know that it's that specific block they're trying to break?
Locations probably
BlockBreakEvent#getBlock()
Oh, well that means I'd have to store this specific block into an array somewhere and then match it?
Yeah, it's just one block
Static variable
But I mean players can be spawning these blocks many times, it comes from a random TP command
what did you change?
Okay, does this approach also work if i don't want the block to drop anything?
the version to what is stated on the github repo
So there's multiple of these spawn blocks that you want to store the location of?
Yup
Is it working?
nope still the same error
- Get block which is being added to the 'spawn block' list.
- If you want these blocks to be kept after reloading/restarting the server it will need to be stored to a file and retrieved on startup.
- Listen for players trying to break blocks at the location of any of these spawn blocks.
- Cancel the event.
Alright, thank you very much wizz
how to convert projectile to item?
just tried it on mine and it works
did you remove your .m2 folder?
I deleted it now
whats your error again?
any idea?
but not on this one
exactly the same one
Can you send me the pom of one of your other projects that works?
they are very different
you might want to make your vice one look like the other one
should I try if the protocollib dependency works if I remove some other dependencies?
no no no, let me change your existing pom to match the layout of your other one and you try that
ok
why are you using java 1.8?
bump
I dont know. you think if I change it to a higher version it could work?
but projectile has item's nbt
No, because your other one uses 1.8 as well, I just think using a later version is best practice. But I understand if you want to support lower versions of mc.
stick with latest LTS
is this a bug java.lang.IllegalArgumentException: y out of range (expected 0-256, got -50) on 1.18.1 server?
Is from method getBlockType();.
why 1 not 2
I only added the xml header and packaging tag
If the world supports depth, yeah
nothing changed
time, is it a bug only in 1.18.1 ?
I did test on a test server so it is a bug in 1.18.1 (at least that build it run on).
The server you were previuosly on went down, you have been connected to a fallback server" cloud a plugin cause it?
or what cause in in first place?
since it drops players by parts like 20% each time out of all online players
How can I detect when a player touches a block with their hand or with whatever, right or left, to change it into a different block type?
use PlayerInteractEvent
check if event clicked block is not null and change it type
Is it possible to clone PersistentDataContainer?
Sweet thanks
ah time to edit all my stuff again then
i made some utility methods which assume that the connection needs to be closed afterwards smh
should be super hard to fix
i mean you can open it each time you wanna send a query
just a bit inefficient
lmao
Hey guys! Working on generating loot from entities. Using Lootable and LootContext like this:
Lootable lootable = (Lootable) entity;
LootTable lootTable = lootable.getLootTable();
if (lootTable == null) { return new ArrayList<>(); }
LootContext.Builder contextBuilder = new LootContext.Builder(location).lootedEntity(entity).killer(player);
contextBuilder = contextBuilder.lootingModifier(0);
LootContext context = contextBuilder.build();
loot.addAll(lootTable.populateLoot(ThreadLocalRandom.current(), context));
Problem is that if a player is holding an item with the Looting enchantment, this generates more loot. Tried using #lootingMoodifier(0), but it doesn't seem to work. Anyone who can help me disable this enchantment behaviour? Thanks
๐
I'm currently trying to get the console output of spigot, but I can't think of a way. How to get console output?
add a custom logging filter
smth like this ig
I'm not sure if that catches ALL logging messages though. E.g. vanilla ones are probably not going through the Bukkit logger
in that case you might need LogManager.getRootLogger()
that should catch stuff both from craftbukkit/plugins, and from vanilla logger
(but I am not sure)
thanks... but it not capture all of log.. ex) chat, command, etc
Does anyone here know how to recenter an armorstand to its original position after constant head rotations ? (it would basically rotate while staying in the same original position)
why is intellij being a bitch?
its stuck on Downloading from codemc-snapshots
it does this sometimes
and it takes 10 minutes to compile
when it normally takes 10 seconds
maybe they finally got slapped for illegally distributing mojang owned software
I'm not aware about the legalities of spigot
Well, there is a reason why spigot does not offer you a downloadable jar but rather asks you to build spigot locally
slightly sus
int count = 0;
for(Block nearby : brokenCrop.detectNearbyCrops(broken.getLocation())){
count++;
Material toBreak = nearby.getType();
nearby.breakNaturally();
System.out.println(toBreak.name());
player.getWorld().dropItemNaturally(nearby.getLocation(), new ItemStack(toBreak, HoeAPI.getDropForLevel(brokenCrop, cropLevel)-1));
}
I've tried many approaches and I couldn't be more confused with why this isn't working. I don't see how this approach still throws Caused by: java.lang.IllegalArgumentException: Cannot drop air, the toBreak material literally outputs SUGAR_CANE.
My method for detecting nearby crops removes blocks of Material.AIR in the process.
just check if the material is air first
im trying to use recursion to make a vein miner method, but it crashes the server with this:
thats the code
Took too long. You are searching too far
if (block.getType().equals(Material.AIR)){
toRemove.add(block);
continue;
}
Under the detectNearbyCrops() it filters the AIR blocks.
I made a vein miner a while ago, want to see my code?
sure
?paste
Well yea, you are not allowed to just distribute code you don't own
hence why build tools downloads vanilla from mojang themselves
and builds spigot locally on top of that
all the NMS repos out there just basically shit on that in the hopes mojang does not come after them
but also anyone know why my code causes the crash?
One of your lambda functions
I guess its because you are iterating over the same blocks
My method keeps track of blocks that have been processed and skips them
That way we don't get errors or loops
yay it compiled after 6 minutes, that 4 minutes less than last time
The code still returns the IllegalStateException:
if (toBreak.equals(Material.AIR)) continue;
player.getWorld().dropItemNaturally(nearby.getLocation(), new ItemStack(toBreak,
HoeAPI.getDropForLevel(brokenCrop, cropLevel)-1));
I'm so confused
toBreak.name() returns SUGAR_CANE
where does it return illegal state?
``` use that as a check
!item.getType().isAir()
What, the ItemStack?
the item you are breaking
Does this not do the same as !toBreak.equals(Material.AIR)
Theres different types of air
Could you elaborate?
Material#isAir exists
cave air
Sorry, I haven't really programming Spigot since 1.8, I wasn't aware of this ๐คฃ
it got me too the first time ๐
happened to me when I was making a anti mob farm thingo
AIR
CAVE_AIR
VOID_AIR
I know, I'm trying with that
elgarl beat me
Same error .-.
The same happens when I use my Crop interface's #getType which returns the Material of the crop
I've not looked at your code or the error. Is it the server timing out?
IllegalStateException
I can't open a browser while in this game
what is nearby?
nearby is of type Block, I have a function from my Crop interface (variable brokenCrop) which detects surrounding blocks, within this detecting function it skips air which is what confuses me.
So each nearby block shouldn't be of type AIR because they simply wouldn't be added to the list
It's sugar cane
< - This block breaks naturally but wouldn't be in the nearby blocks
< - I'm breaking this block
I'll debug to see if it's breaking twize
The "Breaking" log only printed once
I'm bewildered
Can you put your current code in ?paste
Everything that is apart of the process of gettings blocks/items to breaking it
Is the quantity of the item 0?
Perhaps you should debug that as well ^
Because ItemStacks with a quantity of zero will be converted to air
Just log everything to get a sense of whats happening in the code
Hey guys, I have this stupid method to check if the world passed in as an argument is one of the defined worlds in the method, but I can't seem to call it anywhere in my class....? (Might be a really dumb beginner mistake)
public static boolean inWorld(World world){
//CHECK IF IN RUNNER VS HUNTER TYPE WORLD
if(world == Bukkit.getWorld("RunnerVsHunterMap1")){
return true;
}
else if (world == Bukkit.getWorld("RunnerVsHunterMap2")){
return true;
}
else if (world == Bukkit.getWorld("RunnerVsHunterMap3")){
return true;
}
else if (world == Bukkit.getWorld("RunnerVsHunterhub")){
return true;
}
else {
return false;
}
}
I mean at that point just compare the name
just make it a spliterator and multithread that bitch
better than the for loop 100%
/s
Sorting is not really multithreaded
There is a better way of doing this, all the else ifs are very ugly
Also, for those warning about perf, that really isn't an issue
a modern cpu can handle that easy
Sure it could be if you are using something like radix sort, but the quicksort used by java isn't really that multi-threadable
create a config with the world names, or at the very least a list with the worlds/names (doesnt matter) and check if it contains it
Thank you! You're a lifesaver
Thanks to everyone else who helped as well
Ignoring performance makes the difference between spigot's 5 minute shutdown time and paper's 3 second one
true, but why cant i call it in the same class with if(getWorld(player.getWorld()))
I am not saying ignoring perf
I am saying ignoring perf if it's really small, or the alternative is unreadable/unmaintainable
Why not just get the player's world?
i am...
Is there an event that is called when a block breaks for any reason
That's only called for players breaking blocks
You'd have to listen for individual events. There's no all-encompassing event
explosions, physics and a whole bunch of stuff could help
in this case streams are less redable than a simple for-loop imo
yeah, depends on the context sometimes
though streams are lazily evaluated anyways
Ohh, inWorld
Use .equals for the world objects or compare world names
ok thanks
So is any other code
I also noticed they have similar names, you could simplify that code by checking if the string contains the generic identifier
no I meant
me going wild
stream()
.map(Test::new)
.map(Object::toString)
```It won't run two iirc
You definitely don't have to wrap that in a WeakReference, right? You would want to weak wrap the result of your lazy value
May I ask what's a weak reference and a lazy value?
The weak reference won't handle types inside of their wrapped instances
ye right
I use this
public static boolean inWorld(World world){
//CHECK IF IN RUNNER VS HUNTER TYPE WORLD
if(world.equals(Bukkit.getWorld("RunnerVsHunterMap1"))){
return true;
}
else if (world.equals(Bukkit.getWorld("RunnerVsHunterMap2"))){
return true;
}
else if (world.equals(Bukkit.getWorld("RunnerVsHunterMap3"))){
return true;
}
else if (world.equals(Bukkit.getWorld("RunnerVsHunterhub"))){
return true;
}
else {
return false;
}
}
But i cant call this method in my class
new WeakRef(new X) is asking for trouble
WeakReference will not hold a reference from being garbage collected. So if it gets collected by the GC, .get() will return null. The LazyValue (which is either something FourteenBrush wrote or from Apache Commons or something) will only initialize the value when it's first called upon
How are you calling it?
Iโm updating a scoreboard every second, but for some reason the scoreboard stops updating after about a minute or two for some random reason. Iโve tried 3-4 different wrappers and APIโs and the issue is the exact same. Is this a common issue? If so, is there a way to fix this?
Ah so lazy value is literally like lazy val hey: String = "Hello, World" in scala
i was thinking smth was wrong with wrapping that into a weakref yes
it does
Not from what I remember
streams don't magically cache stuff
Yeah basically. Though Java doesn't have a lazy keyword
unless it gets compiled down to a constantDynamic
i would put that in front of my name
which uhm I highly doubt
Simple if statement
Says it shoud return void or smh
world.getName().startsWith("RunnerVsHunter")
actually i needed a LazyValue<WeakReference<Player>> lmfao
Please just create a config with the names of as a list, it will save you so much bother in the future
Isn't this better
It is, but a config would be better
especially if there are new worlds or name changes
Fair point
or an internal list in the code, that might be best for him
However it depends, if there is always a prefix just check for the prefix
Thats good if he keeps with the naming convention, and any other people involved in the development of hypothetical server
codemc-snapshots is having another stroke?
Can't go to https://repo.codemc.io/
Nexus Repository Manager
okay its back
sqlite not having a proper upsert command :(
I'd like to play a custom mp3 ambient music for my spawn and different worlds, what should I use for this?
you can simplify it by ||
I think you are not doing a proper usage. But as im not a sql expet I wont giv eopinion
Yea ill rather use a config, but i still cant understand why I canโt call it in the sane class
use a switch function
tf is that
weird things which i already changed
ah shit scala
the definition of a mess
lazy String hey
When I try to call this, it gives me this
Invalid decleration, or declare abstract
val hey: String by lazy { "Hello World" }
๐
val lazy fourteen: Fourteen = Fourteen::new()
kotlin delegates OP, sorry to you kotlin haters
ive got a list of locations, whats the best way to make an entity just walk between them
ah so like
u have a few boxes
u want the player to be able to only walk in them
not anywhere outside those
right
Oh I understood that totally different. I thought he wanted an npc (or mob) to travel from one location to the next one and repeat once at the end
well i mean its just like:
the distance between locations can be assumed to be no more than 1 block
I made a system 2 days ago that plots points x distance between two points
If you beed that
Or are you saying you need the pathfinder goal for it
ServerLevel s = ((ServerLevel)loc.getWorld()); java.lang.ClassCastException: class org.bukkit.craftbukkit.v1_18_R2.CraftWorld cannot be cast to class net.minecraft.server.level.WorldServer (org.bukkit.craftbukkit.v1_18_R2.CraftWorld and net.minecraft.server.level.WorldServer are in unnamed module of loader java.net.URLClassLoader @7aec35a) how would i do this? someone earlier told me to cast to serverlevel (Im trying to get a world using nms 1.18.2
if i wanted paper i would have bloody asked 
lol
((CraftWorld)world).getHandle()
ye ye sorry xD I mean pathfinder still seems the easiest ?
a bit of NMS here and there just makes the plugin more spicy
i dont really need it to do any pathfinding though, i just need it to walk right there
i could, but dont entities like move at different speeds? i forget
or is that a speed you can access
Just use a speed equation
Keep in mind that doesnt account for jumping
Parhfinding is your best option as you dont have to handle jumping
How can I make the pathfinder of a zombie only attack certain zombies? (i want to make two teams and have them fight each other)
uhhhh
im fucking up my entire shit
might even leave the datasource away but then i need a unaryoperator as parameter in a constructor :/
kinda weird
fuck
how can i create a packet entity that everyone can see
Hello, does anyone know which packet works on %server_online%
Send it t9 every online player
Are you using papi? Just fix your place holder
if someone joins after the entity is created they wont see it though is there a way around this
Send it to the joined player after they join
The placeholder is fine, but I need to reduce the number by 1
I make vanish plugin
? Idk how to send scoreboard packets
๐
It's essentially a way of throwing an exception without explicitly declaring that you throw an exception in the method declaration
Sneaky throws are very ugly and hacky
Lol gross
Though it's a way to allow callers to not be forced to create a try/catch
i'm catching every exception and then rethrowing it ah yes
The only thing I don't like about try catch is how ugly it looks
It's horrendous
I mean checked exceptions are kind of gross to begin with
the rusts way of exception handling is cleaner in my opinion
by returning a Result<T, E> where T is the value you want and E the optional exception
I mean that's basically a CompletableFuture lol
Is there then also a function like "ifPassed(Function)"?
Fourteen, you good? You've been typing for the past 2 minutes
theres a ton of fun stuff
let a :Result<char, smth::Error> = some_method();
println!(a.unwrap()); // prints the char or throws some ugly error which we cannot catch
println!(a.expect("we did not get the char :(")); //prints the char or throw an error with the message :/
smh
too long ago since i did rust
im getting a circular dependency warning but i kind of dont have a choice i have a multi module project with each version 1.18.2, 1.19 etc and ofc the plugin itself needs these versions as a dependency and the version modules need the plugin dependency to get instance of the main plugin so what should i do
theres a map function which is like CompletableFuture::thenAccept
some_database_result().map(|loaded_player| loaded_player.login());```
theres some or_else thing too
but lemme shut up now
@EventHandler
public void onSnowballThrow(ProjectileLaunchEvent event) {
if (event.getEntity() instanceof Snowball) {
ProtocolManager pm = ProtocolLibrary.getProtocolManager();
final PacketContainer destroyEntity = pm.createPacket(PacketType.Play.Server.ENTITY_DESTROY);
final int[] ids = {event.getEntity().getEntityId()};
destroyEntity.getIntegerArrays().write(0, ids);
Bukkit.getOnlinePlayers().forEach(online->{
try {
pm.sendServerPacket(online, destroyEntity);
} catch (InvocationTargetException e) {
throw new RuntimeException(e);
}
});
}
}
what is incorrect here
i get the FieldAcessException error
why are you trying to fake destroy all snowballs when launched?
You are also doing it too early. The launch event fires before any clients have been notified of the entity
so i can mount entites to it
Hi, im trying to convert array of materials - Material[] to array of ItemStack[]. I have no idea how to do it. Can anyone help me?
and they can move in various ways
what event should be used?
Arrays.stream(materialList).map(ItemStack::new).toArray(ItemStack[]::new)
Thats the correct event, if thats what you want to do, but you have to delay it all by a tick or so
or for loop
the snowball will not exist on teh clients until that event finishes
so sending a destroy packet for an entity they know nothing about will do nothing
Oh. Thank you. That was fast ๐
I can;t comment onm your use of Protocolwhatsit
is that the likely cause of my error
or is that one of many
one of many
So I have a simple InventoryClickEvent that is cancelled when a player clicks on a specific item while having another on the cursor. Everything works fine, but when I cancel it, it just duplicates the clicked item. (Deleting the item on the cursor)Am I using the wrong event for this or it's just not possible to cancel in this event?
do you know if protocol lib has a discord server
i feel like i may not be able to get support here and i would be wasting time
how would i get info about a player that's not online?
for example, get uuid from name
Block clicked = e.getClickedBlock();
if (clicked.getType().equals(Material.CHEST)) {
TileState chestState = (TileState) clicked;``` why does this error happen when i already check if it s a chest?
check if getClickedBlock is null
can i remove a zombies AI
nvm
just make it stand there
oh wait yes
Bukkit.getOfflinePlayer()
oh thx
that requires uuid
you could wrap the entity in yrou own class, then remove all goals when you spawn it
same error
?jd-s
Bukkit.getOfflinePlayer(UUID.fromString("name"));
Should be possible, right?
i just need it for a cheap and cheerful test
Block clicked = e.getClickedBlock();
if (clicked.getType().equals(Material.CHEST) && clicked != null) {
TileState chestState = (TileState) clicked;```
how can i access a protected field here lol, this class just has a persistencehandler field
doesnt Block have a getState method?
oh wait i can cast it to living entity right?
like (TileState) clicked.getState();
try it, but looks like you should work to me
Incorrect, there's a method to do it with name, though it's deprecated (obviously, since you can change your name)
is there any way of getting it from name without mapping every name and uuid of players when they join?
that returns block state not tikle state?
@lost knoll method may work scroll up
cast block state to tile state or smth
aah what
il;l try
didnt know it just exposes protected fields to the package
no, a UUID is never a name
lol
well, its quite unlikely
UUIDfromString is expecting the UUID in a very specific string format
yep
You either Bukkit.getOfflinePlayer(name) and risk a Mojang lookup, or you loop over Bukkit.getOfflinePlayers()
EgarlL should I switch to NMS instead of protocol lib?
that depends on how much you are willing to put into maintaining yoru plugin
both kinda suck lol
Not with remap
even with remap
I enjoy making plugins and never touching them ever again except for bug fixes
same here
Its just a fun lil thing that is not for anyone else but me
but I also like messing with nms
then I'd recommend using nms packets over protocol lib
using Mojang mappings makes packets so simple now
but version specific
Ngl the only instances where I've needed nms was for pathfinding (then I discovered paper has an API for it)
yeah, spigot needs some logic API
time to pr
I've no time, but I'd never get a PR accepted. Too many typos ๐ฆ
๐ I don't have the knowhow to do a pr
I want to PR @since onto everything but I'll need to ask hashman first
Big job
hmm i love it, something is closing my db connection while it shouldnt
a "try with" I'd expect
is there a way to get the entity a player is looking at ?
you can use World#rayTrace()#getHitEntity()
in fact I currently have code open that lets you spawn an explosion at an entity you're looking at when interacting at it from far away
i should try to avoid all try catch blocks in my impl classes ๐ค
depends
I'd do an interface, then an implementation depending on the type
you could SQLite as a base (with no try with) then extend that and override or wrap methods for SQL
chestState.getPersistentDataContainer().set(new NamespacedKey(plugin, "ATTACHED_MINION"), PersistentDataType.STRING, stand.getUniqueId().toString());
System.out.println(persistentChestData.get(new NamespacedKey(plugin, "ATTACHED_MINION"), PersistentDataType.STRING));```
any idea why this give null
you are using a BlockState and I bet you are not pushing teh changes back to the Block
chestState().update()
oh didnt know i had to do that
all BlockStates are snapshots
i think i fixed it but im not really happy bout this class
I also don't like that class. It's the reason most people just use HikariCP
Ah, SQLite. Gotcha
Well even still, a lazy connection really isn't all that worth it ๐
if(chest.getType().equals(Material.CHEST)) {
((Chest) chest).getInventory();``` cannot cast to Chest even though i already checked if block is chest
Just get a connection and try-with-resources it
its to leave my connection opened :/
No, close it when you're done with it
thank you mfnalex now i can sleep in peace
Block can't be cast to Chest, but its state can
block.getState()
ah hmm some people say that i should leave it opened and you dont :/
There's no reason to leave a connection to a database open
Again, connection pools do keep them open but they close them after (by default) 60 seconds of no use
i'm not using hikari so creating a new connection could be quiet heavy no?
It depends entirely on how frequently you intend on sending/receiving data from your database I suppose
For what it's worth, HikariCP does support SQLite iirc
ye
but yeah it's really not all that terrible. Just perform your SQL asynchronously and you'll be fine
sure lmao
@EventHandler
public void onSnowballThrow(ProjectileLaunchEvent event) {
if (event.getEntity() instanceof Snowball && event.getEntity() instanceof Player) {
Player player = (Player) event.getEntity();
((CraftPlayer) player).getHandle().b.a(new PacketPlayOutEntityDestroy(event.getEntity().getEntityId()));
}
}
there is no error
but nothing happens
entity is both a snowabll AND a player?
channel=KodySimpso
anyone know if giving an Allay an item is the PlayerInteractEntityEvent
Is it possible to do nbt without nms
Is there a method provided by Bukkit which lets me see how much food an item restores?
Or do I need to compile a list myself?
it's present in the nms class but not in bukkit
Okay, thanks
PersistentDataContainer is your best choice for that
in NMS, you can use getFoodProperties()
should get getNutrition()
btw wtf is isFastFood() for lmao
DRIED_KELP is fastfood, but nothing else, as it seems
Okay, thanks.
But I'm trying to go a non-nms route here
villages having their own mcdonalds?
there is no non-nms way I think
no there is not :)
you can just compile your own nms list from sources with a basic plugin
interesting. a whole tropical fish has only half the nutrition of a single berry
yeah
Can you eat DRIED_KELP faster than other food items?
That would explain it
always eat is:
- chorus fruit
- enc gapple
- gapple
- sus stew
seems so, have never tried it
i'd imagine in normal life you need longer to chew some DRIED kelp than you'd need for the same amount of juicy beef lol
Can you eat DRIED_KELP faster than other food items?
stew very sus
I already answered that I don't know
one funny thing that I hate about minecraft's food system
is that the food sound is sent every 3-4 ticks
because it's just a single bite
Discord lagged
Sent it twice.
It might send it another time ๐คท
vanished
A creeper blew up a block, is there a way to know who placed the creeper and blew up the block?
yes
itโs twice as fast compared to any other food
Oh, okay
Sorry for pinging but wans you the one who helped with mongo pojos?
maybe
is there a good api for discord integration with bots/webhooks?
d4j, jda
๐ if you're chewing your seaweed you're eating it wrong
I've never had seaweed on its own
How are you supposed to eat it
I've only had it as part of sushi
If it's the dried salted seaweed u bite a bit, then it undries in ur mouth and u swallow gg
If u chew it too much it becomes a wet squishy rug
It's a decent snack
Bruh what
thanks
Seaweed โcrispedโ above gas stove is SUPREME. dont burn ur fingers tho
Nah
Have you tried it?
No
Try it then
I don't eat plants I'm not a beta loser
I only eat red meat
My diet is 100% red meat
Because im a based alpha male
i want to do /gm 0 and my gamemode turns to survival and /gm 1, 2, 3
@Override
public boolean onCommand(CommandSender sender, Command cmd, String label, String[] args) {
if (sender instanceof Player p) {
if (args.length != 1) {
p.sendMessage(ChatColor.RED + "Tu precisas de especificar um argumento.");
return true;
}
if (args[0] == "0") {
p.setGameMode(GameMode.SURVIVAL);
p.sendMessage(ChatColor.GREEN + "Modo de jogo mudado para Subrevivรชncia.");
return true;
}
if (args[0] == "1") {
p.setGameMode(GameMode.CREATIVE);
p.sendMessage(ChatColor.GREEN + "Modo de jogo mudado para Criativo.");
return true;
}
if (args[0] == "2") {
p.setGameMode(GameMode.SPECTATOR);
p.sendMessage(ChatColor.GREEN + "Modo de jogo mudado para Espectador.");
return true;
}
if (args[0] == "3") {
p.setGameMode(GameMode.ADVENTURE);
p.sendMessage(ChatColor.GREEN + "Modo de jogo mudado para Aventura.");
return true;
}
} else {
System.out.println("Tu precisas de ser um jogador para executar este comando.");
}
return true;
}```
is this good?
You can negate the first statement
and also reuse args[0]
and use better naming like player instead of p
ok
how do i reuse
btw you should compare strings with equals, not with ==
like this?
if (args[0].equals("3"))```
Yeah
DateTimeFormatter
.ofPattern("HH:mm:ss.SSSS", Locale.ROOT)
.withResolverStyle(ResolverStyle.LENIENT)
.parse("48:00:00.0000", TemporalQueries.localTime());
Why doesn't this parse correctly? It just returns 0 for MILLI_OF_DAY (which is the correct value to get)
Assign it to a var
Anyone know how to fix the visual bug of giving an Allay an Item?
If I cancel the Event which is PlayerInteractEntityEvent the player will keep the item
But the item will still appear in the allays and, and if the player takes the item they dont actually get the item back
Its a visual bug but an annoying one and I don't know how to go about fixing it
Optional<Entity> optionalEntity = nearbyEntities.stream()
.filter(entity -> entity instanceof LivingEntity && ((Projectile) arrow).getShooter() != entity)
.min(Comparator.comparing(entity -> entity.getLocation().distanceSquared(entity.getLocation())));
how can i add another factor to .min
i would like to also compare against how much health the entity has
well
which one comes first
health or distance
you'd need to make a comparator that checks for both
equally as important
or basically you gotta make a graph that maps health-distance to a point factor
You should probably create a JIRA issue about this
?jira
Attach a plugin we can use to replicate the issue, but it's definitely a fixable bug in CraftBukkit
what would be the best storage method for data?
Some room for improvements there
Could simply use a switch statement
And save args[0] and this "preString" of your messages into variables
Loot context
As long as it's a single-dev project I honestly think just take whatever you feel comfortable with
String howAreYallDoingToday = "Modo de jogo mudado para ";```
that's cool but I remember a guy naming his variables "yipee" and "asdasd"
Well, I don't even know why someone would do that
this dud
xd
How can I spawn in prebuilt-structures into the world?
depends on what you mean by prebuilt-structures
Just builds I've made
just use worldedit's api
will check that out thanks
Hi is there a way to give all entity's and effect when left click on item
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.PlayerInteractEvent;
public class m1ttenEvents implements Listener {
@EventHandler
public static void onLEFTCLICK(PlayerInteractEvent event){
if(event.getAction() == Action.LEFT_CLICK_AIR){
if (event.getItem() != null){
if (event.getItem().getItemMeta().equals(ItemManager.wand.getItemMeta())){
Player player = event.getPlayer();
}
}
}
}
}
oh god
@echo basalt ??
this dosent work for some reason
LivingEntity livingEntity = (LivingEntity) entity;
This reminds me of that one hypixel interview that just said "spot all the wrong things in this class"
but they didn't stoop this low
sure they did web requests on a PlayerMoveEvent listener but they were actually listening to events lmao
m1tten did you learn java before trying to code minecraft plugins?
since like i would like to help you but it seems like the real problem here not gonna solve spoon feeding
i have learn java and opps and threading
Look into design patterns and beginner mistakes
ok i will try my bes
where is your constractor to main class?
if(event.getAction() == Action.LEFT_CLICK_AIR){?
why player cannot do magic trick on other block?
i dont think you learned java please dont tell us wrong information
ImIllusion you know i own a big network and there an fan player that always sent me those kind of codes
bruh i did the hellsinki course online
i am sorry
funny stuff
dont be sorry its ok
I might reapply at hypixel next summer
public void interactPlayer(PlayerInteractEvent event) {
}
if(event.getAction == Action.RIGHT_CLICK_AIR) {
player.setHealth(0.5)
ArrayList<String> list = new ArrayList<String>
add.Mob(Zombie);
add.Mob(Skeleton;
public enum class
playerinteractevent;
playerheldevent;
blockplaceevent;
}
like
this is the samething for me
i tell him that this is illegal and he will go to prison
- his computer will explode if he try to run it
how do you convert a regular world into this format
it comes that way what do you mean?
where is your constractor to main class?
regular world looks like this
well
oh sorry
thats what i was thinking
what that?
god no
alright will try
only the region and entities folder
are relevant honestly
region contains all the tiles and chunk data
entities stores the entities
playerdata is needed as well
playerdata is fun if you want stuff like inventory
but in my case I just have my datasync plugin handle it
it meant to be a joke
like someone posted here his code
and like we didnt want to be rude but he didnt try to even learn java
also playerdata is usually only stored in the first world folder
so that inventories persist across deleted worlds
btw guys i have something really wierd to tell you
is it possible to exclude DataPacks from worlds? while on this topic ๐ค
Oh
so @chrome pewter dont lose motivation
i thought u were gonna say me for a second
that's how my programming teachers learned to code, according to them
i have a friend who uses his cellphone to code and play minecraft
I know a chinese guy who codes in binary
im very serious about it like its not a joke i know he doesnt have money to afford a laptop
so he turned his android into linux or something not sure
No i was just joking hahaha
but like for everything you can do, there's a 4 yrs old chinese who can do it too
notepad >>>>
seen a meme recently
where the US Math team beat china for the first time in 40 yrs
exactly
and they were chinese
and they were all chinese in the US team xd
i wonder tho
what about plugins
I mean it's possible
i imagine how many times he tried to run it
how would project structure work?
till it worked
my classmates found it weird when I was opening up a hex viewer to debug my code ๐
I bet they can do that too
RaiderRoss1 i really dont know but i have seen he uploaded a pluin
plugin i decompile it
and asked him how
he told me he made it in his mobile
Wow
3kb's tho
I mean there are java ides
education edition block coding doesnt count
Give this man an IDE and he codes minecraft 2
also btw u can call me Raider/Ross or jusy ping me idm
for android?
ye
for every plattform
i didnt know it too
but i can imagine how bad is coding on small screen
with mobile keyboard
๐ข
Yeeee
can someone help me? I'm trying to make a plugin that shows FirstJoinMessage only to players that have a staff rank (or simpler, to players that have permission)
imagine debugging your code
ive had to do it while my pc was broken
and you made a simple mistake or your keyboard fucked up somehow
welll
how do they have the staff rank if it's their first time joining?
i wonder do plugins on bedrock exist
nvm console exists
They have to
I mean that staffs can see who joins for the first time
Have a look at the hive server
never worked with permissions sorry
evan talking about that guy makes me feel sad for all the expensive shit I bought for coding
bedrock exclusive
How the hive doing it then
Ooooh
i can't read my bad
bedrock has something called addons
ye i got no idea sorry
aswell as im pretty sure bedrock supports datapacks
and command blocks are a thing
you can code a bedrock server with java
yea
just takes a lot of networking
its ok, maybe there's someone that can help me
i should try to make a server jar that can handle atleast 1 bedrock player and 1 java player from the ground up
that would be hell though
what i never put it anywhere i dont even touch plugin.yml only when i add commands and shit
dragonproxy was a proxy that was meant for that
I think it got discontinued in order for geyser to work
i mean like
from the ground up completely
geyser has a standalone option
like handle every preexisting minecraft packet
and detect whether a player is on bedrock or java
yeah that's geyser standalone
I did not
?
?
yo lads. hope you're all having a good day. if i wanted to format a message from config using hex colour codes and also add a clickevent, how would i do that? using the component api i havent been able to get hex to behave well. thanks in advance!
i tried using TextComponent.fromLegacyText but the message formats weirdly and &r doesn't work
String string = txt;
if (Bukkit.getPluginManager().getPlugin("PlaceholderAPI") != null) {
string = PlaceholderAPI.setPlaceholders(target, string);
}
Pattern pattern = Pattern.compile("&#[a-fA-F0-9]{6}");
for (Matcher matcher = pattern.matcher(string); matcher.find(); matcher = pattern.matcher(string)) {
String color = string.substring(matcher.start(), matcher.end());
string = string.replace(color, net.md_5.bungee.api.ChatColor.of(color.substring(1)) + ""); // You're missing this replacing
}
string = ChatColor.translateAlternateColorCodes('&', string); // Translates any & codes too
return string;
}```
this is my format method
this is the source text: "&#D39FF0&l>&r &#A39E7CJoin our discord! &r&#F0E6AA&o(click here)"
the output is correct but the entire message is bold - &r doesn't work.
```ComponentBuilder test = new ComponentBuilder().append(TextComponent.fromLegacyText(ColorUtils.format(string, p)));
for(BaseComponent c : test.getParts()) {
c.setClickEvent(new ClickEvent(ClickEvent.Action.OPEN_URL, link));
}
p.spigot().sendMessage(test.create());```
any ideas?
you should run the translateAlternateColorCodes before
as TextComponent uses the translated &
so it uses ยง
if you translate after then it won't work
i mean my format method has worked everywhere else so im not sure?
string = ChatColor.translateAlternateColorCodes('&', string); // Translates any & codes too and it does translate it
try from the start
Is Json is good file storage ?
no
I mean good for storing data ?
It uses a lot of space
@rough drift i changed it but its the same message
Data loss , config file ๐ญ
String string = txt;
if (Bukkit.getPluginManager().getPlugin("PlaceholderAPI") != null) {
string = PlaceholderAPI.setPlaceholders(target, string);
}
string = ChatColor.translateAlternateColorCodes('&', string); // Translates any & codes too
Pattern pattern = Pattern.compile("&#[a-fA-F0-9]{6}");
for (Matcher matcher = pattern.matcher(string); matcher.find(); matcher = pattern.matcher(string)) {
String color = string.substring(matcher.start(), matcher.end());
string = string.replace(color, net.md_5.bungee.api.ChatColor.of(color.substring(1)) + ""); // You're missing this replacing
}
return string;
}```
you'd rather want a byte array output stream, or a data output stream (less recommended, I suggest just using a dop to baos then write the content's of baos at once for extra speed if you really need dop)
its still bold and doesnt &r
https://stackoverflow.com/a/2984550/13050697
This is an example
ahhhh I see
the pattern is still old there
you're doing &# in the pattern
rather than ยง#
the issue isn't the format method fam, its the other part
the format method has worked fine for ages
idk
for(BaseComponent c : test.getParts()) {
c.setClickEvent(new ClickEvent(ClickEvent.Action.OPEN_URL, link));
}
p.spigot().sendMessage(test.create());```
&r works in all other places
but just not with components
oh I see
yeah idk ๐ฆ
Basically
just try doing
BaseComponent[] components = TextComponent.fromLegacyText(ColorUtils.format(string, p));
for(BaseComponent component : components)
component.setClickEvent(new ClickEvent(ClickEvent.Action.OPEN_URL, link));
p.spigot().sendMessage(components);
If that does not work
na it doesnt
TextComponent comp = new TextComponent();
BaseComponent[] components = TextComponent.fromLegacyText(ColorUtils.format(string, p));
for(BaseComponent component : components) {
component.setClickEvent(new ClickEvent(ClickEvent.Action.OPEN_URL, link));
comp.addExtra(component);
}
p.spigot().sendMessage(comp);
nope
ike ill try both
brb
changing it to an array of components works. it actually makes sense because componentbuilder probably treats each component separately meaning the &r wouldnt affect other components. whereas an array would treat them collectively
thanks
๐
np
the builder does make each separate, the array is just bunched together and sent as one, rather than being split
I just think it adds an &r at the end
to make the components not affect eachother
(removing the possibility for mistakes when using a builder)
that would make sense but i tried a different string where the &r didnt have a space before the next elements and it still outputted bold text
either way: note to self: use basecomponent arrays rather than builders
๐คฃ
to make the components not affect eachother
discord
are you ok
I sent that message 5 minutes ago
nah, sometimes it dies
it sent up here
but then discord resent it
haha fair
Either brigadier or strings
could someone make plugin for me that Server gives 1 mystery player a bounty to kill someone else and if they kill their bounty they get 1 heart, but if they don't kill them for 24h if they are on the server and die to their bounty the mystery player loses a heart
ill use brigadier
?request
aaaaaaaaaaaa
?services
If you wish to request or offer development/art/building/administration services, please do so at https://www.spigotmc.org/forums/services-recruitment-v2.54/
does brigadier have target selector support?
ok
@lunar zealot
yes
brigadier is what vanilla commands use
so yes
what is brigadier
Minecraft's own command library
(Made by Mojang themselves)
It's extremely verbose and kind of a pain to work with
but it allows you to do so many things
it's insane
Hell it allows for auto completions ON THE CLIENT
Is there a form of fog mod in spigot? I'm trying to build a sandy map with light sandy/dusty weather
Aww, so there's no way?
RIP okay
You can however make a sort of blood moon if you want that
oo what's that?
The sky turns red
The rain turns red
Water turns red etc
requires a lot of tinkering
but it is possible
Normally a huge wave of enemies appear when this happens
Ah, is this part of minecraft?
not really, it's some old obscure forgotten things
but it does exist in the protocol
is there a way to make sure there are no blocks between two entites
How does one achieve that?
I'm getting Asynchronous chunk getEntities error. Why is that?
Entity#hasLineOfSight(Entity)
sorta like that
you need to run it on the main thread
as mc is signle threaded
Sending a couple of packets
namely one to change the biome color, and one to change the weather state
