#help-development
1 messages · Page 1372 of 1
but when i'm going to anvil
putting my book and my items
it doesn't give me a new tools
I have never programmed CEs via that method as I believe that it is a too large of a hack
Player auth = (Player) sender;
ItemStack newBook = new ItemStack(Material.ENCHANTED_BOOK);
newBook.addUnsafeEnchantment(CustomEnchants.SAVE, 1);
auth.getInventory().addItem(newBook);
So I cannot really help you with these unintended consequences
Though did you specify your enchantment targets?
By overriding the needed methods within your class that overrides Enchantment
but not "in" the book
Because you force-set it
like he said
Bukkit will not care at that point whether it makes any sense, it will care about it later, which is why it is needed
how can I "non force"
you need to add your own functionality with a PrepareAnvilEvent listener if you want it to be compatible with anvils
🙁
Yeah, good luck with that
like geol said its a pretty hacky subject, a lot of things you need to reimplement yourself
That has been the single most painfull thing when I added CEs in
mhmmm
okay
is there any other way
i just want like there is an item
and
i can gave this item to another item, and the second item got the enchant
Ok so i have a problem that is driving me literally insane. So My Problem is that i almost randomly get this error message at the client but nothing the outputlog or the server throws any kind of error message https://cdn.discordapp.com/attachments/486919187038470155/830827009889271838/unknown.png
oh my, do you have some issue with making a full sentence on one line?
Does anyone know how to fix this or what could cause this behavior?
With no code, no
Since i have no clue where this error is thrown i cannot send any code
As far as I know there has been no fix as noone knows what the cause is
This could have changed since the last time i have heard of that was a few months ago
Ok i testes something a while ago and I sometimes got this error when calling the hideNpcName function of my npc class https://pastebin.com/g1ricDpn
so maybe it is a problem with sending packets?
A rare sight indeed
mhmm okay
so if i'm making an item and giving it the enchant using command, if I want to put this item in a shop (another plugin), how can I? Because, I need to put the name (minecraft:diamond_pickaxe), and I can put enchantments, like: "THORNS:3", so I tried "SAVE:1" (save is my enchantment), but it didn't worked. I guess it's because save is a custom plugin, is there any other way to "create" an item with this custom enchant
make a command to apply the enchant to your held item
yes ofc
but i do not want everyone to use the command just to get the enchantment
Did you also register the enchantment?
what does it mean
Like, Enchamtents#register or whatever it is called
i just made a custom enchantment, and adding it to the items i want
(with additional reflection hacks)
i do not think i registered it
You may need to do it to unlock more through capabillities
public class CustomEnchants {
public static final Enchantment SAVE = new EnchantmentWrapper("save", "Save", 1);
public static void register()
{
boolean registered = Arrays.stream(Enchantment.values()).collect(Collectors.toList()).contains(SAVE);
if (!registered)
{
registerEnchantment(SAVE);
}
}
public static void registerEnchantment(Enchantment enchantment)
{
boolean registered = true;
try
{
Field f = Enchantment.class.getDeclaredField("acceptingNew");
f.setAccessible(true);
f.set(null, true);
Enchantment.registerEnchantment(enchantment);
}
catch(Exception e)
{
registered = false;
e.printStackTrace();
}
if (registered)
{
}
}
}
Does it mean it's registered?
yeah, that would work
What do you want to say with this?
I decided to not prepend my message with >
The issue is that 1.13.2 has a very low adoption when it was released and is no longer much in use, so it lacks in having a community that knows stuff
What would be the best version for a minigame or something like that then?
Ah yes, the minigame version dillema; there is no best version I am afraid, and your 1.13 compromise between modernity and speed is fairly good, though in most cases you go all out for 1.16
ok so then another question is there another way to remove the name of a npc since how i do it is something i randomly found out but I dont know if that is the right way
why doesnt this work? i get teleported to the right coords but fall to -5k without taking fall damage, gamemode doesnt change. WHats wrong?
https://paste.md-5.net/itotapever.coffeescript
Hello, i try to recode my plugins with gradle instead of maven but i have an issue with my install.
In my core i want split the different part but keep an mono repo (using multi-project).
I have done that but my dependencies is not shared (the module bukkit and bungeecord doesn't have api, and all module except bukkit doesn't have jetbrains annotation).
My repo : https://github.com/orblazer/gradle-bug
Note: im new in gradle
Thanks by advance
if im searching for a string in a specific color what's the right way to do that
would it work if i just used §
There is no real way especially after Minimessage/Adventure
I suggest stripping the message down; what're you trying to do Gee?
check for a display name on an item and the color of it determines what i do with it
hmm
If you're looking for reliable information I suggest using the displayname of a new itemstack based on that Material
since the displayname is changeable via an anvil
if you're not worried about that then yeah just get the display name and strip it
how do you mean use a new itemstack
new ItemStack(Material)#getItemMeta().getDisplayName()
shows how it would look to the client if it were a new item
check the meta for nulls though
Hi guys any one got a nice example how to do custom enchantments in 1.16. i tried a few online examples but dont seem to get any to work
oh you mean to do that when they obtain the item? And also if the name had a section sign in it and i searched with chatcolor would that work
what I have no idea, I usually use that method for my shop plugin for readability
how can I set color with .setLore with Meta thingy
ItemMeta meta = currentItem.getItemMeta();
List<String> alLore = new ArrayList<String>();
alLore.add(ChatColor.GOLD + ChatColor.BOLD + "Save I");
meta.setLore(alLore);
currentItem.setItemMeta(meta);
The operator + is undefined for the argument type(s) net.md_5.bungee.api.ChatColor, net.md_5.bungee.api.ChatColor
Object#toString
uh ?
So just ChatColor.GOLD.toString() + ChatColor.BOLD + "Save I"
Or ChatColor.GOLD + "" + ChatColor.BOLD + "Save I"
Now, because the Java compiler will do that automatically
At the bytecode level String concentration will use a String builder, so they are basically the same
This is how I load my config.yml. Is this the same way to load other yml files?
nyes
Hello, I'm making a Spigot plugin and following the wiki, when it says "In the window which now is coming up [project structure], you have to browse to your location where the SpigotAPI is stored." Do they want the Spigot-API folder or Spigot-1.16.5.jar?
is dual hands still a thing in minecraft 1.16 cause i still dont know how to do it and a lot of methods are deprecated cause of it
me?
yes
Using your IDE as your build system will haunt you later.
Of course you could also use gradle
What is the difference between Maven and Gradle?
Normally the .jar.
not that big of one, but gradle has more powers
People will laugh but i use Eclipse as my IDE
I use it too, but you should not use eclipse as your build system
The Material class is on the brink of getting deprecated either way
how can I convert string like "&c" to ChatColor
It already is internally, you aren't really allowed to work on it
using args in command
geez
ChatColor#translateAlternateColorCodes
because when i'm doing "&cAH" it just says "&cAH" as raw
or you can use § for color codes
Don't use it for configs though
can yall get to mine when youre done with his?
Encodings will haunt you otherwise
Hmmm is gradle very complicated to get started with?
assuming the spigot save configs in utf-8, its safe
ill give it a go some time
Then use maven, but having to do a costly setup for each and every update is simply not worth it
Plus you can basically copy+paste the build script for every plugin, which is extra pog
does anybody have a link to a method i can use to deserialize a potion effect from a config
thanks
Hey I'm storing two things in a dictionary:
blockData.put(block.getLocation(), player.getUniqueId().toString());
A blocks location object and a players UUID as a string. I want to be able to pull that UUID when I do:
blockData.get(aBlock.getlocation())
yet when I try to do it as a Player:
Player playerBlock = blockData.get(block.getLocation());
it doesn't work as it wants an object to be returned. How would I do this
PotionType#valueOf(String)
how could I convert a string like "&c Hey" to chat color
without using ChatColor.GOLD
§ instead of &
so I could just use .replace method ?
Use Bukkit#getPlayer(UUID) and make the map a Map<Location, UUID> instead and drop the #tostring()
No
ChatColor#translateAlternateColorCodes
As I already said
Hm, thanks.
Example ChatColor.translateAlternateColorCodes('&', "&4random & bits")
Which is also why you should NOT use String#replace
ty
Is there a quick way to support @ selectors in my commands
Hmmmm, PsudoCommands plugin
Weird that that's not in the Spigot interface itself. Entity[] getEntitySelection(String) or something
wdym
Using Tab Completion?
What?
That's not what I mean
Unless I'm misunderstanding you
Say I have a command in my plugin, and I want to be able to pass it a set of players, like in vanilla commands
so /test @a
Yes
And it would be a set of Players
And /test PlayerName would be a set of Players with one member
declaration: package: org.bukkit.command, interface: TabCompleter
There is something that would help you
Bukkit has a built in feature for that
Oh?
I cannot recall the name of it, but it is in the bukkit class
Bukkit.selectEntities
It also supports parsing player names and UUIDs
They are a pain to resolve, and I still don't know how to get them automatically
But eclipse (don't know about intelliJ) appears to generate the javadocs automatically if I tell it to download the sources jar (unfortunately that is not a maven/gradle operation)
Oh, I thought I just had to install the docs separate from the API
Doesn't sound very far fetched
Docs are big
I'll see what it is
https://hub.spigotmc.org/nexus/content/repositories/snapshots/org/spigotmc/spigot-api/1.16.5-R0.1-SNAPSHOT/ alternatively you can download the javadoc jars from here
You're insane if you think I'll touch a jar manually when a build tool is a possibility
I did that before knowing better. Sad life I was living lmao
I was just saying that you can add these jars to your IDE globally, under normal circumstances your IDE should pick them up without thinking twice about it, but sometimes IDE do not behave like we want them to
https://paste.md-5.net/pexepexazi.cs
Can someone tell me why this timer isn't notifying me or sending any messages at all?
Add some debug messages
hey guys, i'm beginner, how can I add "info"
like when i start my server it says "xxx is starting!"
yes
uh
when you start, your server, every plugins are writing into the console "<plugin> is starting!"
System.out.println?
You can use that
ok ty
But for bukkit, the recommended method is Bukkit.getConsoleSender().sendMessage(String yourMessage);
Again, you can still use System.out.println()
the other one is just recomended
anyone know what the best way to store data inside mysql for a server? since there's a table then there's values, and it would be easy to create an element of a player's uuid as the primary key each time, what would be the way to store server data such as the most amount of ppl on at a time, spawn location, etc.?
Absolutely not!
Bukkit.getLogger().info("") is just a bit more better, but still not the recommended way
The recommended way is using the plugin logger
What's wrong with consoleSender?
It litterally performs a command
no it doesnt
anyone know why every method in Velocity's Command class is deprecated
how would you get all online players in a Player[] i cant think of how to initialize the array after checking if everyone is online
without checking everyone twice
also not using getOnlinePlayers
that's like the best way to do it
why not
well its not all online players im trying to do just certain ones
but it applies the same way
ArrayList<Player> players = Bukkit.getOnlinePlayers() then for loop through them?
No, it's a collection afaik
getOnlinePlayers().stream().filter(i -> i.getName().equals("Username")).collect(Collectors.toList());
iirc the list implementation isn’t exposed
So don't assume that it is a list, since it can also be a hashset
Oh yeah very true
getOnlinePlayers().stream().filter(i -> i.getName().equals("Username")).collect(Collectors.toList());
? extends Player
Yeah, it contains something which extends Player
In most circumstances that is CraftPlayer
that gives a list i guess id just go to an array from then. I was trying to do it without arraylists or collections but i guess its not possible
Cause it’s not really a Player, but still a Player
You can’t declare it to a Player Set without casting
Your method does not care tho
If you stream it
You can #map(Player::getPlayer) probably
Wait. But there should only be one player with the given name, right? Then why stream it?
Im searching through mongodb looking for values in an descending order with the limit of ten, all of them return their Winstreak from mongo (which is correct) then i use a linked hash map to put it in, but after i put all the values in the map it doesn't have the correct values.
Here is the code:
https://gyazo.com/583d0b99fc49edb712d1160780e7bf2c
example
If the values printed by the topStats.foreach then you probably get the wrong map from your cachedStatistics map.
topStats gets put into cachedStatistics
well into another map with the kit name with the stats
And the values printed there are right?
Speaking of the values printed inside the foreach loop
the values printined in the map are incorrect, somehow the double is 0.0 when in mongo its 3.0
Then i would check if the kitDocument property is always null.
That means ur boolean value is false
Debug the statistic name and if kitDocument is null ^^
its not though, because when i print after it says the correct value.
statistic is a enum
kitDocument probably doesnt have the stat name as a key
If you're really sure it's returning true, then try changing the 0.0 to a different number. If you get that diff #, then the boolean value is for sure false.
Oh i see you dont use return values here but just shove it into a "toInsert" variable. Thats a method with side effects and makes this code quite a bit harder to debug...
But first make some null checks just to be sure
Otherwise if you still get 0.0, then you know there is something wrong with one of your queries elsewhere
Are the methods "getTopTenStatistics" (which actually isnt a getter btw) and "refreshFormattedStat" called consecutively on the same thread?
How can I make a player respawn at a specific block?
They should be called on the same thread (obviously not the main)
Im going to change the method name, was just trying to figure this problem out
But are they called after each other?
Because there could be tons of side effects since you are not using a chain of responsibility but just a field that everyone can access at any time.
only refresh calls getTopTen
But i dont see the refresh method doing anything with the result from your "getTopTenStatistics" method.
The values get just put into some ominous "toInsert" map which is not accessed by the refresh method.
https://hub.spigotmc.org/javadocs/spigot/org/bukkit/event/player/PlayerRespawnEvent.html setRespawnLocation
declaration: package: org.bukkit.event.player, class: PlayerRespawnEvent
Thanks!
the toInsert map is from the refresh method, the method creates "topStat" which is a linked hash map and passes it though the method params for getTopTenStatistics, which is then thrown into another map with the key of the kit and a value of the stats, which that map is thrown into cached stats after all kits have been looped
Oh i didnt see the method parameter there
So the values that are printed before insertion are all right but the values printed in your iteration afterwards are all 0.0?
yeah as ay.ngel told me todo is change the 0.0 and it did change all the values, but i don't see how it gets to that.
the checks are correct
Ok. Then we are back to our first recommendation.
Check if kitDocument is null or if the kitDocument does not contain the statistics key by just logging that beforehand.
i did a check on that already, most are not, some are, which is why i handle that, and i did the contain key and its also the same, true or false if it does.
Btw you should def sort like this:
collection.find().sort(Sorts.descending(kitTypeName + "." statistic.name()));
Instead of using raw documents.
But i think you got your answer.
Its only 0.0 if the document is null or doesnt have the property.
imagine boosting but not being verified
lol
I can now finally compile my Java 16 plugins again!
Lots of counterpoints to gradle is the best
I dont want to switch to gradle... i just got nice and comfy with my xml mess
Wait, they are all trash talking gradle in there
I just moved from Ant to Maven around 1 year ago. I refuse to move for another 10 years now.
i want to create an api enpoint in my spigot plugin but spring boot and spigot dont work together
I need this in order to retrive players balance from discord id (i already have that logic done)
I will call this from a Fabric mod, what do you recommend me to do now? I heave hard some chat channels but i dont understand at all how they do
Would be cool tho if its simple to have an api endpoint for a website or something i plan to do in future
spring boot and spigot could probably work together. But i have no idea why you would shove a CDI container in a plugin
You could do a subproccess for your spring boot and do some network IO stuff between the two
What is CDI? Common rail diesel injecton?
Would you mind describing your setup in more detail? Because running a whole spring application just for a simple rest endpoint is probably overkill.
At this point i might as well just make a tcp server socket and call it a day
context and dependency injection
Yeah I also dunno why spring boot wouldn't work, but jeez 900 pound gorilla
"Sry your plugin is 415.17MB above the sites limit"
i study in my native so i never get to hear actual terms in java programmiung, thanks to forums i can actually learn theme
like for god sake you have no clue how bad they translate stuff, so unatural
Ok so you have 2 different servers running? A fabric and a spigot one. Right?
Wait. You just want to retrieve the number of users from a fabric mod?
No no no, i have only one server a spigot server that has vault installed, i made a plugin that works as a discord bot and has all the uuids and discord ids linked together in a database, i will use this api endpoing for the discord rpc mod for farbic (since everyone uses fabric). I already have the logic of retriving the balance ready and tested as a discord command so that is not an issue, i need to chose how spigot server and fabric mod for client will communicate
So my main question is what would be the best way for a spigot server and a fabric client mod to communicate? Should i make a simple tcp server and do it all that way?
Oh. I think you can just send packets down the plugin messaging channel.
From fabric -> spigot
@ornate hollow you probably could use plugin message or create an custom packet
It needs to go fabric (sends user discord id) -> spigot (gets vault balance) -> fabric (gets balance and displays it as discord rpc status)
it would be super simple, single string lmao
Or (controversial) you just access the data from an external source like a database or simply use redis as shared memory (maybe even using pub/sub system). This way you dont need to worry about communication.
But if you want communication then the messaging channel is probably the way to go.
Yeah but how would i then get the persons vault balance? I would have to cache it, and risk opening mysql to the internet, although if i do cache it i can then make a seperate spring boot application that has all the endpoints
Yeah this is a very very nice idea mate
Wow thanks
If you have your own Economy implementation then you could actually just sit your vault data behind a spring application and let both the client and the server
just access this endpoint. And the endpoint can then also be accessed by websites etc.
I dont have my own economy impl but this sounds like a very nice rewritten version of what i am doing
thank you
Exception in thread "main" java.lang.NullPointerException
at me.imaginedev.imengine.GameWindow.addImage(GameWindow.java:26)
at Main.main(Main.java:16)
game.addImage(new ImageIcon("player.png").getImage(), 0, 0);
Thats not how you access resources from within your jar.
well how do i
didnt want the obvious
Exception in thread "main" java.lang.NullPointerException
at me.imaginedev.imengine.GameWindow.addImage(GameWindow.java:26)
at Main.main(Main.java:16)
What's the format for ConfigurationSection#getLocation
This path is resolved relative to your executed application. So you have 2 options:
- Extract all data you want to use into a folder when your application starts and load it into memory when you need it.
- Use the ClassLoader to gain access to resources. Those will be streamed and therefore provided as InputStreams.
probably a path
So im trying to learn what would be an easier method to this? I thought a loop would work but not sure
https://paste.md-5.net/titojugoxi.cpp
Should i use that:
event.setCancelled(true);
}```
or that:
```for (ItemStack equipmentPiece : armorstand.getEquipment().getArmorContents()) {
if (isCrashItem(equipmentPiece)) event.setCancelled(true);```
declaration: package: org.bukkit.configuration, interface: ConfigurationSection
Oh, wait, it is a path
No, I'm reading the docs
I don't know what a path is then, lmao
a:
b: 2 # a.b is the path
Location loc = section.getLocation("path.to.your.location");
Dude
I'm asking about the config's format to parse a Location from
Does it just need x y and z children? Yaw, pitch?
test it out
ideally it should
@Override
public void onEnable() {
saveDefaultConfig();
getConfig().set("a", new Location(2, 2, 2));
saveConfig();
}
no idea
Just look at the class
No because you should never do that
is #Enum.valueOf("enumname")'s time complexity O(1) or** O(n)**? Does it loop the enums internally? or it is an internal hashtable, which makes it O(1)?
you should probs just parse your own if i were you
Dont deserialize by hand.
Just let the serializer resolve the structure:
Location loc = section.getLocation("path.to.your.location");
anyone?
O(1)
Smile, I don't understand how I'm not making myself clear. I'm saying the docs should be a bit more specific, like "Path to a ConfigurationSection with x, y and z children, and optional yaw and pitch children"
thanks
?
But thats not how ConfigurationSections work...
Well, yeah, at least those children
Def the second one.
Is it faster?
We need another help channel ffs
No. Both are pretty much the same.
oops didnt mean static
so no difference?
Smile, my statement didn't say only those children. It should just have those children available
No difference.
Is there something I'm not understanding
Hi I’m trying to make this work but booleans can’t be with void and I’m not sure how to fix this:
public class list implements Listener {
@EventHandler
public static void onChat(AsyncPlayerChatEvent e) {
Player p = e.getPlayer();
if (p.setSneaking(true)) {
p.sendMessage("hey");
}
}
}
Here is the error:
java: incompatible types: void cannot be converted to boolean
How can I fix this or am I doing something wrong with the event?
You can shove a location into whatever section you want.
@Override
public void onEnable() {
final File testFile = new File(this.getDataFolder(), "test.yml");
final FileConfiguration configuration = new YamlConfiguration();
final Location spawnLoc = Bukkit.getWorlds().get(0).getSpawnLocation();
configuration.set("I.Am.A.Spawn.Location", spawnLoc);
try {
configuration.save(testFile);
} catch (final IOException e) {
e.printStackTrace();
}
final Location deserializedLocation = configuration.getLocation("I.Am.A.Spawn.Location");
}
The path doesnt matter.
Booked, the error doesn't seem to be there
The method shouldn’t be static.
Your class name should start with an uppercase letter.
I believe you meant to use p.isSneaking()
@quaint mantle
Why can't it be static, exactly
Woah, thanks man, that's cool
No need for static, you shoudl never ever call it yourself
No need, but is it erroneous
Okay thanks
No idea if it woudl even work. It has to match the pattern Bukkit expects for the Eventhandler
It's annotated. But then again, you give an instance of the listener, not its Class
The annotation just says "look here" to Bukkit.
Yeah, that's what I'm thinking
It doesn;t mena take thsi as a handler no matter what
So static doesn't feel like it would be a problem
The class is scanned for annotated methods so static ones should get picked up. The relfective invocation of static methods is
actually a little bit faster than the one from instanced ones. But you should not worry about that when writing a plugin. Making them
static is just dirty.
Awesome, we guessed it
Speaking of static
Please help me guys. I'm helping these kids with their plugin and...
Especially because the jit optimizes reflective invocations pretty well (to the point where you cant distinguish them from normal ones)
They're making...mutable...static...utility....classes
The whole event handling of spigot is not really state of the art. But it was written before the functional API of Java 8 became a thing and it would be unthinkable to change that now.
good, make it all static
Really
Why does it all have to be lambdas
Though there is an alternate api where you could pass lambdas in
To what?
But annotations have far less boilerplate imo
It does not need to be all lambdas. The interfaces can also have concrete implementations.
I can agree on that.
I cant quite make out what you mean by that. I can only think of squishing a lambda into the PluginManager methods (ew)
Theres the registerEvent interface that takes an event and a handler
I’m not sure what your idea of state of the art event handling would be
Can someone help me out? https://www.spigotmc.org/threads/walk-npc.500032/
The better pattern in my opinion is the having a top level interface for any event, and abstract classes implementing it for types of events sharing data. Then an "adapter" kind of class implementing an interface for listening to the top level event, say "EventHandler", and instanceofing it to see which abstract method to cast the instance into. Then extending the adapter, and overriding whatever methods are of interest. And the event firing object just takes EventHandler instances
At least this is what I'm most familiar with
I'm not sure if the pattern has a name
Something without reflective invocations 😄 and more type save implementations.
That pattern is silly and slow when you have as many events as bukkit
Ah, that is true
Bukkit used to do it hat way 10 years ago
Mind explaining what exactly it does now? I haven't looked into it
Slow in terms of development speed?
That and speed in general
Also makes custom events second class
Doesn’t jda have like a generic event thing like you described Operation21
No offence, but can you not? You just got surprised by how ConfigurationSections work...
That is exactly what I described hahaha
Hm? Is there a problem?
Not sure what type safe means, and reflection is kind of unavoidable unless you force events to be registered. People hate on reflection too much anyway, its rather optimised internally
I actually ran some jmh benchmarks which resulted in reflective invocations being optimized by the jit several minutes before the concrete implementation ones. (On Java 11 they are fast and on 11+ they are indistinguishable from normal method calls)
But the fact that i dont see this approach in enterprise code just made me wonder if there isnt a better way of registering events.
By type safe i mean that this will compile fine but throws runtime exceptions:
@EventHandler
public void onBreak(final BlockBreakEvent breakEvent, final BlockPlaceEvent placeEvent) {
}
Where are the spigot compile maven plugins when we need them
What would such a plugin do?
Idk XD run exactly those checks lol
Ah i see. You can surely write Sonar checkrules for that lul
Probably 😂 but where is the fun in that
No idea. Imagine code quality concerns in spigot plguins...
How does that double handler work
it doesn't
Oh, I see
I would never put my plugins on a resume at least the ones I’ve done so far
The code sucks
Anyone tried using sparc http://sparkjava.com/ with spigot, how well it works? I need to make a simple api endpoint
Spark Framework - Create web applications in Java rapidly. Spark is a micro web framework that lets you focus on writing your code, not boilerplate code.
i think this uses it?
not sure tho
you could check the jar, check if it has the library
oh wait nvm
spark framework is for web apps in java
yeah it doesnt sue it
no idea, never tried it
i just looked at gradle
I mean all i need is a very very basic single api endpoint
why doesnt this work? i get teleported to the right coords but fall to -5k without taking fall damage, gamemode doesnt change. WHats wrong?
https://paste.md-5.net/itotapever.coffeescript
i in spring boot but the plugin would be 1gb so not this time
youre setting gamemode to survival? @arctic summit
yeah
what is it otherwise?
im trying to teleport players after a game is over back to the lobby
but i think i fall thru the floor or smthn
bc i keep falling to like -5k and dont take void damage
and for some reason
players who are in spectator
stay in spectator
but wouldnt that make it wait 5 seconds for each player?
no
I mean... if you make it a 5 second delay...
its a 5 second delay bc its supposed to run after a title appears and dissapears
yeah
ok ill try it out
Try acquiring a chunk ticket for the target chunk. Then teleport after a short delay (20 ticks or so)
a chunk ticket?
load the chunk
Teleporting all users at once should not be a problem.
just saves having 20 different runnables
when you can just have 1
also assuming players1v1, redTeam1v1, blueTeam1v1 and specators1v1 doesnt rely on the player variable, you can move that out of your for loop
wait so i would do Bukkit.getWorld.getChunk.load()?
ok
Try this
public void teleportAllPlayersToPotentiallyUnloadedLocation(final Location location, final Collection<Player> playerCollection) {
final Chunk chunk = location.getChunk();
chunk.addPluginChunkTicket(plugin);
Bukkit.getScheduler().runTaskLater(plugin, () -> {
playerCollection.forEach(player -> player.teleport(location));
chunk.removePluginChunkTicket(plugin);
}, 20L);
}
thats a mouthfull lmao
thank you
hello, how can I block noteblock from updating? I put a noteblock with a given instrument, but after updating the block under the noteblock, the instrument updates.
lies. This is not verbose enough
i have code for that, one min
Interesting. Post plz. I couldnt figure out what events actually trigger in this case (besides the physics event)
?paste
Nope. This way you get the ticket and remove it right away.
And you try to remove it for every player afterwards too.
private CustomBlockType blockType;
private NoteBlock nb;
@EventHandler(priority = EventPriority.HIGHEST)
public void physics(BlockPhysicsEvent e) {
if(e.getBlock().getType() == Material.NOTE_BLOCK) {
if(!e.getSourceBlock().getRelative(BlockFace.UP).equals(e.getBlock())) return;
nb = (NoteBlock) e.getBlock().getBlockData();
if(CustomBlockType.getType(nb.getInstrument(), Byte.toUnsignedInt(nb.getNote().getId())) != null)
blockType = CustomBlockType.getType(nb.getInstrument(), Byte.toUnsignedInt(nb.getNote().getId()));
Bukkit.getScheduler().runTaskLater(ClusterCore.getInstance(), new Runnable() {
@Override
public void run() {
nb.setInstrument(blockType.instrument);
nb.setNote(new Note(blockType.note));
e.getBlock().setBlockData(nb);
}
}, 1);
}
}```
It's nto the best way to do it, but just cache the noteblock and replace it. Otherwise theres no immediate way to change it
theres other methods that i've seen that do the same thing pretty much
thats using some of my own code so you'll have to fiddle around with it
so what should i do?
thx, i try it
Can you use Block variable type in switch()?
This is my ocd version of that code:
@EventHandler(priority = EventPriority.HIGHEST)
public void physics(final BlockPhysicsEvent event) {
if (event.getBlock().getType() != Material.NOTE_BLOCK) {
return;
}
final Block eventBlock = event.getBlock();
if (!event.getSourceBlock().getRelative(BlockFace.UP).equals(eventBlock)) {
return;
}
final NoteBlock noteBlock = (NoteBlock) eventBlock.getBlockData();
final Instrument instrument = noteBlock.getInstrument();
final Note note = noteBlock.getNote();
Bukkit.getScheduler().runTask(plugin, () -> {
noteBlock.setInstrument(instrument);
noteBlock.setNote(note);
eventBlock.setBlockData(noteBlock);
});
}
Material is an enum so it can be used in switch case statements
Like this?
public void remove(int x, int y, int z, World world, Block block) {
switch (block){
case Material.BEDROCK:
//code
break;
case Material.COBBLESTONE:
//code
break;
}
}
No. Block is not an enum.
You could create a collection of Players by iterating over the collection of UUIDs.
Then at the end you just call the teleportAllPlayersToPotentiallyUnloadedLocation with that collection of Players ^^
Or you can do the following in your own code:
Acquire the ticked before the runnable.
Then release the ticket after every player was teleported.
Thats probably better
Bump
thanks for cleaning that up for me smile
The PacketPlayOutRelEntityMove packet is fired very often and only for fractions of the actual target location.
For players there is an extra packet for position/rotation. So you would need to implement the complete movement yourself
and send a ton of packets for lowly walking the player to the target location.
i just found a weird thing in the spigot api
Ok thanks
imagine i is a tool/armor piece
i.setDurability(i.getDurability() + 1);
guess what this does
It tells us that you are using an ancient spigot version 
If i is of type ItemStack then yes. If its Damageable then no.
Ok go ahead. It reduces the durability by one.
i was about to point that out
i think it makes no sense lol
should be called setDamage instead of setDurability
It increases the received damage... so it kind of makes sense.
Damage goes up -> Durability goes down
but its called setDurability
But ive been there and have done that like many others.
I also think it is quite ambiguous.
wait how can i check if an item is damageable?
declaration: package: org.bukkit.inventory.meta, interface: Damageable
or Damagable
ah
Damageable#setDamage(int)
I think this was deprecated half a decade ago
But alright now you know ^^
its still in spigot 1.16.5
Didnt know that it still exists ;P
ah, yeah it does
but marked as deprecated
i instanceof Damageable this should work for checking if its damageable no?
ye
youll get an npe
a stackoverflow post from 2010 says itll just return false
instanceof is null safe and always false
i just learned something
same
Was "org.spigotmc.spigot" removed from the repository?
There has never been a public spigot repo, only the API
Lies
i thought there was?
Hmm, I think I just used to remove "-api" from my dependencies and it would add all the NMS stuff
Its illegal to distribute spigot
ye that happens for me too
Lier
?bt
The home of Spigot a high performance, no lag customized CraftBukkit Minecraft server API, and BungeeCord, the cloud server proxy.
Liar
run buildtools
wack
it puts org.spigotmc.spigot in ur local repo
its a legal thing, they had to
all good, just takes a lot of time to download and install everything, a bit frustrating
can someone help me out im making a plugin that uses chatevent to send messages to people when they say one of the key words like buy or help | shop and stuff like that but i have another plugin that addes [player] or [there rank] of there message so the chat event picks up there [player] first
so like if someone types "hey im new" and i have that as a key word so when they say that it sends them info messages but with my other plugin its makes them send "[player] hey im new"
oh btw this is my alt lol
just sent message wrong acc
you've just magically changed identities have you
lmao
2 acc
jokes aside, can't you just check what the message contains?
ah ok thanks
hey, so i have this method that checks for the lowest item amount in a crafting grid so that it changes the result of a custom item's amount, but it doesnt run. i tried adding system logs in the PrepareItemCraftEvent aswell but none of them run for some reason, so i can't really tell whats wrong
https://paste.myst.rs/vqh3mtla
Any reason why you dont implement crafting recipes for items?
if you have a regular recipe it will do it for you
messing with ItemCraftEvent isn't really advised, it's super buggy if you try to mess with the result
i have them in a seperate file
Ah i see. Then you should use the namespaces of the recipes for detection.
Would you be interested in an approach that lets each recipe handle custom conditions and
actions for the event they are crafted in?
that would be cool yes
Ok ill write an example. Might take some minutes
but for now im just trying to have it so the result's amount changes depending on how much items are in the grid
like if u had 2 wooden planks on 4 squares u would get 2 crafting tables
Thats handled internally by the recipe...
int amount = 64;
for(Integer i : interactableSlots) {
if(invInstance.getItem(i) == null || invInstance.getItem(i).getType() == Material.AIR) continue;
if(invInstance.getItem(i).getAmount() < amount) amount = invInstance.getItem(i).getAmount();
}```
That's how i handle shift clicking in my custom inventory
assuming the recipe is correct, you just find the lowest amount in the matrix
i thought so but for some reason it doesnt
wait ill take a screenshot
Any able to help me figure out why this isn't working?
Im trying to get the next number divisible by 9 when i enter a value
https://paste.md-5.net/kabaqijago.cs
is there anywhere where i can put an image
you have to verify your acc
yeah i see it
so yeah it doesnt do it
look at the code block i sent, that will give the max amount of craftable items
you'll have to change it to work with your matrix
but assuming your recipe is complete, and the recipe only takes 1 item per slot, you just get the smallest amount from the matrix
which is what ive done
the checkMultiples method
it does nothing tho
no need for multiple for loops
wait does getMatrix return an arraylist object?
public Integer checkMultiples(PrepareItemCraftEvent event) {
int amount = 64;
for (ItemStack item : event.getInventory().getMatrix()) {
if (item != null) {
if(item.getAmount() < amount)
amount = item.getAmount();
}
}
return amount;
}```
reduce the complexity then you have less points of possible failure
Oh i see... you want to set the amount of the result to the smallest amount of the input.
But why? This will really mess up the recipe when someone shift clicks.
i didnt think of that rip
ohh i see
it just goes lower and lower as it goes
idk why i made an arraylist while getMatrix literally returns the list
lemme see if it works
and Integer temp = list.get(0); assumes the 1st element is the highest
but wouldnt that not matter if i check if the other elements are smaller?
could be higher though
but that wouldnt be important if im just looking for the smallest one
alr wait so lemme check if it works
yeah
wait lemme send u the image
Anyways. Here is the recipe implementation where each recipe can handle the event they are crafted in.
https://gist.github.com/Flo0/d7f12797944860854328d005b6367e07
It contains an example recipe for tnt that needs less resources but has a 50% chance to just explode.
@snow bane
man why did i never think of extending ShapedRecipe
im gonna rewrite my crafting system
ive never understood how extending work i should read up on that
cuz it seems powerful
Or a new sub-class that restricts certain recipes:
public abstract class RestrictedShapedRecipe extends CustomShapedRecipe {
public RestrictedShapedRecipe(@NotNull final NamespacedKey key, @NotNull final ItemStack result) {
super(key, result);
}
@Override
public void handlePreparation(final PrepareItemCraftEvent event) {
if (!this.isAllowedToCraft((Player) event.getView().getPlayer())) {
event.getInventory().setResult(null);
this.handleFail(event);
return;
}
this.handleSuccess(event);
}
public abstract void handleFail(PrepareItemCraftEvent event);
public abstract void handleSuccess(PrepareItemCraftEvent event);
public abstract boolean isAllowedToCraft(Player player);
}
This recipe can only be crafted in a MOUNTAIN biome and above height 200:
public class MountainRecipe extends RestrictedShapedRecipe {
public MountainRecipe() {
super(NamespacedKey.minecraft("mountain_recipe"), new ItemStack(Material.GOLD_BLOCK));
super.shape("gg", "gg");
super.setIngredient('g', Material.GOLD_INGOT);
}
@Override
public void handleFail(final PrepareItemCraftEvent event) {
event.getView().getPlayer().sendMessage("You can only attempt this recipe high in the mountains.");
}
@Override
public void handleSuccess(final PrepareItemCraftEvent event) {
}
@Override
public boolean isAllowedToCraft(final Player player) {
final World world = player.getWorld();
final Location playerLoc = player.getLocation();
final Biome biome = world.getBiome(playerLoc.getBlockX(), playerLoc.getBlockY(), playerLoc.getBlockZ());
if (biome != Biome.MOUNTAINS) {
return false;
}
return playerLoc.getY() > 200;
}
}
The chat spam...
I'm still weary on messing with PrepareItemCraftEvent result
last time i tried that i ended up getting over 64 stacks of items
If you set it null then you cant do anything wrong. But i would also not mess with the result.
question, can spigot load an extracted plugin from a folder?
- Yes
- What do you mean by "extracted"
Oh wait... do you mean that you extracted all contents of a jar file into a folder??
i dont wanna have to deal with having to shut down my server, halt the batch script, drag the folder into my jar file in 7zip, unhalt the script @lost matrix
lol
how
was messing around with PrepareItemCraftEvent, like i was saying it's super iffy lol
lmao
Then set up your project for hot swapping. I personally run my compiles with a script that stops the server if it runs, compiles the plugin, copies it and starts the server again XD
ayo wtf
now thats cool
i havent been able to get it to make a jar @lost matrix
Use gradle or maven. (Latter is preferred if you are new to dependency managers)
im using gradle
Gradle has an instane learning curve. Its basically a wall. If you have never used dependency managers before then i would def recommend you to use maven.
You will get a lot more help with it. Especially in the spigot community.
i didnt even know maven was scriptable
im gonna try this for the third time cause i have yet to receive help!
https://paste.md-5.net/cipirapubo.cpp
Trying to get the next number that is divisible by 9
check number % 9
i did
if number % 9 == 0 its divisible
but still nothing
um, why not just +9 to your current number?
whaty do you mean "next" number
Uhm. I think you should just use a base 9 calculation. So not base 10 or 2
@eternal oxide inventory requires your size to be divisble by 9
can't be between 0 and 54
But describe what exactly your method should do.
Yes, so +9 it will always be divisible by 9
so lets say im given the number 10,
your question is super vague
ah, so yoru first number is NOT divisible
Oh ok. So you want the next highest number to yours which is divisible by 9. Right?
you just need to for (Double num = i+1, num <= i+9; num++) { if (num % 9 == 0) return num; }
you probably want to ++num so it doesn;t return yrou current number
ok so
the Math.ceil didn't work
for ayone trying to make a jar task in gradle:
teh for loop will
task jarTest(type: Jar){
from 'build/classes/java/main/'
}```
gonna try ElgarlL
this works, defines a task called jarTest which takes build output an makes a jar in build/libs
the for loop that @eternal oxide suggested work
no need for a loop when you can do it in one function lol
The Math.ceil will return teh current number if its divisble by 9
This is my lookup table solution without having to do a bunch of loops:
private static final List<Integer> INV_SIZES = new ArrayList<>() {{
for (int i = 1; i <= 6; i++) {
this.add(i * 9);
}
}};
public static int getSizeFor(final int spaces) {
return INV_SIZES.get(spaces == 0 ? spaces : Math.floorDiv(spaces - 1, 9));
}
is that not what they want?
if 9, return 9, if 10 return 18
next
But this is actually better...
And also if someone sees this he thinks you know what you are doing ^^
public static int getSizeFor(final int spaces) {
return (int) Math.ceil(((double) spaces) / 9) * 9;
}
you need +1 on spaces
Use this TimeStamps. Its what the cool bois do apparently ^
gradle is really great once you get into it
it took me a month or so to really get to know it coming from maven tho
I was also tryna set up a multi-module project for the first time sooo
I've never tried gradle, what benefits does it have over maven?
im going to use the math.ceil
@lost matrix yo btw i figured it out i straight up just didnt register the event
I think this looks correct actually.
i am slightly not smart
no, it needs to return the next divisible
so if you pass 9 it returns 18
this was my original code
and it shoudl never return zero
but i knew there was a simpler way
so +1 on the value passed in
so @crisp iron if size is 9 do you want to return 18 or 9?
9
Then i didnt get the specifications right. I thought you are given the amount of items and should return the next biggest inventory size that fits those items.
So 9 -> 9
right so not +1
well it's the same thing
lies and deception
if x isnt divisible, next
lol
nope, that different
yeah basically i want the inventory to be compact
like a load a unneeded space
i explained it that way bc it made the most sense
so 7smile7's method is correct
Its from baboon
well @drowsy helm method works just fine
ah yep
yeah buoobuoo.XD
I swear i always think of that monkey race when my eyes strive your name
has much as you helped me i cannot help you, i wish i could though
No worries ^^
sort of want to get into machine learning, most I've done is facial recognition and emotion detection
I just finished my first course in it... and all i have done is maths. Tons and tons of maths. There are so many complex concepts in ml of which i only grasped like 20% so far.
Its really hard to get into. But at least i understand now how to properly prepare data for different activation functions. (which doesnt really help)
what a great explanation
And if we like number we give some nodes a cookie
yeah it sounds super hard though, I'm not sure if its my type of programming
Im still deciding. Because i can keep me interested only when i see progression and results. So game programming with LibGDX or Unity has worked great.
Or spigot plugins because i can see my results right away. But so far it feels like im walking against a wall in ml. A wall which is covered in math graphity.
Yeah I can imagine, but if you're looking at going into the field apparently the cash is great
seems like a scam
Simple task: k
Simple task done with machine learning: OMGWTFBBQ
ml seems so much harder tho lol
Well... i also got 30 min of processing time for an IBM quantum computer from my university each week. But i looked at the whole entanglement thing and stopped right away.
But im bored so one of those two needs to be brute forced 😦
I think the hype is more for the potential it has in the future
are you saying my kettle doesn't need machine learning to know when to boil itself
😠
I mean ml isnt something new. It has existed for several decades now. And the value lays in the scalability of it which is needed right now.
I keep getting the error java.io.FileNotFoundException: Jar does not contain plugin.yml and I'm not sure what is causing the issue. It says "Build Success" when running it so the pom.xml file might not be the issue, not really sure but here is a copy of my pom.xml file: https://pastebin.com/ykhuK24E
AAAAHAHAHA no
is your resources inside of your main?
open the jar with a zip program and check
I dont know how comfortable i would be with "one or more internal cameras" facing towards me
all fun and good till your bidet gets hacked
The jar file does indeed have the plugin.yml file
check you uploaded the right jar
very unlikely
That was generated automatically
also check the file is valid
try move resources out of main
ok theres the issue
ok so pressure sensors dont work?
the yml needs to be in the root of the jar
hey md_5 you have no experience with gradle do you?
@solemn shoal well its gotta find out what orifices you have
im failing at including my plugin.yml into my jar
Oh. My god. But thats not a thing, right? That cant be a thing.
lol. No. If you s**t in a bidet you will get kicked out for sure...
lol
what is a bidet lol
maybe ML can replace our hobbies one day
washes your arse
write plugins for us
i mean when i google a bidet it shows me toilets
american toilets are the most wtf thing ever tbh
yes, very
Didn't work. All of the folders were generated automatically
they're like a lake
Uhm.. have you ever seen japanese ones? Its basically standard to have your anus pressure washed by an extending piston thingy
it should be in the root, not the src
how can americans take a shit without splish splash lol
this channel has taken an interesting turn
The one on the left is only seen in cheap public toilets here...
Maybe thats my first ml project. I got a RPI 4 with a cam and a bidet...
Hm. I have only done high pressure hydraulic pistons with an arduino before (to lift a car)
That might be a bit much tho... I could maybe lower the pressure and pray that no bug slides into my code.
definitely dont look up jet ski injuries
moey with the suped up jetski
Imagine
*extends arm through toilet*
I don't understand people who code like rockets and stuff
do they just get one chance
or like a simulation environment
well if you're elon musk your rockets explode all the time
hey i like elon 😠
Lmao
banned
hater
Elon big meme
In those environments coding is quite different. The code has 100% test coverage and needs 3 layer independent fail safe systems.
except if youre elon and just use electron
And they also use simulations of course
Just a laptop that runs a nodejs server for communication.
I was about to say.. lol
i think they use KSP to simulate
I wonder if teslas use electron
Wait. But thats a meme right? They dont actually run electron applications there.
No?
they did for the gui
Yeah. No. There is way more sophisticated software for that. But KSP is noice. Cant wait for 2 to come out.
was joke lmao
I mean. For the GUI i could understand it because of portability reasons. But still. js bad hurr durr
ye they got early access to ksp 2
I could use electron for ml...
Id rathee write python then js
Id rather stay type safe and not interpreted at all.
Id rather write c# tho
I dont touch js unless i can work with TypeScript
You mean Microsoft Java?
imagine wanting to write anything other than java
java with pointers
Imagine wanting to write java
The only 2 cool features of C# are delegates and the fact that generic types are not erased on runtime
I like the string interpolation
I mean. C# only has "real" pointers in unsafe code blocks. And with Java 16 we also got a foreign memory access API that is not unsafe (or OS specific)...
java needs string interpolation
yeah that's true
The shorthand getters and setters are also nice, as is LINQ
i mean you get to play with pointers in C# outside of unsafe codeblocks too
if youre dealing with win32 apis
Ok calm. We just got multi line Strings (innovative). Give Oracle another 10 years and they might consider string interpolation for first incubation.
Yes but with C# you don't need weird compiler hacks :p
Annotation processing is not that wird. Just a bit black magicy.
Isn't Lombok a compiler hack tho
Its both.
Look at CDI frameworks like Springboot or Quarkus. They write entire proxy classes and re-write static method on compile time so everything can be lazy initialized.
accessors/tostring/equals are great, everything else is meh
if lombok just did those three things it would probably be fine
Yeah... And @SneakyThrows about your main method solves all the problems
i only use lombok for the construcotrs and getter/setters
who in their right mind thought "yeah lets put a huge fucking chili on the screen"
@Builder
public class PersonData {
private final String name;
private final String lastName;
private final int age;
}
final PersonData data = PersonData.builder()
.name("Bob")
.age(12)
.lastName("Martin")
.build();
😄
lombok is spicy, duh
And sometimes the @ToString for a class is quite nice if you want to just sysout the fields of that class for debugging.
Tostring all the things
anything that saves me lines of code, i like lol
unless im paid by the hour, then i hate lombok
Paid per line
how do i register event dont link me spigot website spigot is ip logger
lmao what
ip logger
getServer().getPluginManager().registerEvents(Listener, plugin)
MD consumes IPs for nutrients
that didint work
ok
where are you calling it from
from ur mom
great
how do i remove a class from the spigot 1.7 source code
without spigot telling me to kms
what class do you want to remove
and just fork the source and compile your own jar
but you shouldnt need to
i want to remove PotionEffects class and add custom effect called GLowing
why
there is literally no reason to do that
they dont like it probb
no i cant
Just make a plugin that extends the class.
will probs also cause so many issues
that would be a mod
no it isnt
spigot cant do that
Do you want item glowing or entity glowing?
You can probably do it with packets
But 1.7 builds are not available, and are definitely not supported
You can't make 1.7 clients see glow though
THATS THE POINT
gya
1.7 and 1.8 WONT SEE GLOW
he means even if somehow u made it happen they still cant see it
BUT I WANT 1.9+ SEE
Have you considered
For glowing in 1.7 it requires a mod since its client sided 1.9 was made serversided
Updating
a
i said viaversion
