#help-development
1 messages ยท Page 175 of 1
what is the problem then
lol
....
its not giving me an error to help me debug this shit
somebody can tell me how i can request a players UUID, when he never played before? wanna do a sort of own whitelist not based on the minecraft one
randomUUID
Bukkit.getOfflinePlayer (name).getUniqueId
returns null every time
Use a string in the name
huh weird
notnull too
my server is in online mode, normally it should work wtf
are you running spigot? Maybe you disabled stack traces
i had to remove if (!(sender instanceof Player)) {
!(sender instanceof player p)
in yml file or with flag
!(sender instancefof Player) will go through if they arent a player
oh wait i just realised what its doing
dont mind me
even tho you don't get debug messages, why do you use weird old constructions
which are replaced in newer java versions
wdym
switch (usage) {
case "spectator":
case "sp":
case "4":
target.setGameMode(GameMode.SPECTATOR);
gamemode = "SPECTATOR";
break;
are you saying I should use if?
case "spectator", "sp", "4" -> {
target.setGameMode(GameMode.SPECTATOR);
gamemode = "SPECTATOR";
}```
ya know
no break needed
if (!(sender instanceof Player)) { why not using pattern matching?
wdym
and why do you guys use that still
it's basically can only be null if you manually edited plugin.yml in jar file
if (!(sender instanceof Player player)) {
sender.sendMessage("omg you are console");
return false;
}
// now you are free to use player variable anywhere in the method
tho half of this can be wrapped with Enum
what if you want to set your own gamemode with these commands
wdym
not for another player but to yourself
/gmc
>>> asking for help not for a lesson ๐
is it normal that the bukkit dont make any web request with that offlinePlayer method?
hardcoded UUID generator i guess
couldve sworn i looked at the server code for getting an OfflinePlayer and found out it was a Lookup
might have to look again ig
your code is kinda hard to refactor
a lot of spaghetti
oh and im in the 1.16.5, with server in online mode
public Gamemode(Main plugin) {
this.plugin = plugin;
plugin.getCommand("gamemode").setExecutor(this);
plugin.getCommand("gmc").setExecutor(this);
plugin.getCommand("gma").setExecutor(this);
plugin.getCommand("gms").setExecutor(this);
plugin.getCommand("gmsp").setExecutor(this);
}```
at least i refactored constructor
yk you can just use aliases right
still around?
there are no aliases for args > 0 commands ya know
uhh..... you good?
no you cant have an arg as a command name LMAO
no ofc not
so what the heck are you talking about then
he has 5 different commands
gmc gma gms gmsp
which can't basically have any other aliases
i mean they can but not defined here
but this is effectively doing the same thing as:
gmc:
aliases: [gamemode, gmc, gma, gms, gmsp]```
and gamemode which has gm alias only
ya know that they all point to different result right?
they all point to this
so you would need to do like label check
so no
which is extremely cringe
if you use /gma you get adventure
and /gmc gives creative
also why would you need /gamemode creative as an alias
cuz gmc is shortcut to gamemode creative
that's already a default mc command
true btw
not to me
not my code
blame author for redefining gamemode command
i guess i know why
he wants colored messages on /gamemode
also, I was simply creating an analogous version in yml form, this implementation would still require label checks
this one i sent doesn't tho
these are all different commands
you basically do cmd.getName()
Hello
bro you can't tell me that you use the this keyword 6 different times and it means 6 different things
they all have the same executor object
legitimately i don't see the difference between this and label checks, which you just called cringe
that's why i never execute all commands in one CommandExecutor
doesn't cmd.getName() for gm return parent command tho
if gm is an alias to gamemode in plugin.yml
never checked this
and never watched the sources of Command class
here's my solution:
class AdvCmd {
.. GamemodeCommand.adv()
}
class CreCmd{
.. GamemodeCommand.cre()
}
class SrvCmd{
.. GamemodeCommand.srv()
}
class SpecCmd{
.. GamemodeCommand.spec()
}
class GamemodeCommand {
.. switch(args[0]){
case "spec":
spec
etc ...
public static boolean adv(){
// set to adv mode
}
etc...
}```
you can always condense it and put them into the same class, but imo it's unnecessary
so each command would have own executor class in your solution?
another optimization you can do is just to have a single static function that takes in a string that represents a gamemode
and then calling that instead of doing the independent logic on each one
the alternative is to just use label checks that check the name of the command called, but you called that "extremely cringe"
forgotthename
i mean i have one executor for each command
cuz they easily eat command aliases
other solutions for me are garbage from the beginning
hard to refactor
hard to read
lazy asses think it's a good idea to have all of them in one class
and leave with 200 lines of unnecessary code after that
its ok im gonna go spend 10 hours reinventing the wheel
good luck
โค๏ธ
the only thing i do with a shame is writing multiple EventHandlers in one class
yes
hehe some good shit coming
a lot of code tho
not an easy task to get where your problem starts
been looking through your code
so first recommendation
don't use star imports
you should import only the things that are actually needed, not too big of a deal. Second, I think it might be with the runnables if you are experiencing any lag in regards to your plugin. And if not that, possibly the dynmap stuff since dynmap isn't exactly resource friendly
also, for comparing the doors
instead of using a string you can actually use this
declaration: package: org.bukkit.block.data.type, interface: Door
there is a door type category that applies to all the doors so you don't need to use a contains
The dynmap stuff is directly taken from factions
which didn't lag
also my runnables don't run very often
my save runnable runs only every 20 mins
and wdym comparing doors?
I didn't compare doors anywhere
believe block data has a getType
I can't compare a material to a door
part of BlockData ๐
there is no type
declaration: package: org.bukkit.block.data.type
doesn't work
or you can use Openable
then that gets doors and fence doors ๐
which you should be able to do an instance check with that
instead of a ==
yeah doesn't work either
you need to get BlockData
declaration: package: org.bukkit.block.data, interface: Openable
check if the blockdata is an istance of openable
ok that worked
unfortunately can't do that with seeds I don't think lol
I tried removing org.bukkit.* from the imports
it just readded it
automatically
need to change your IDE settings
anyways as far as the lag goes, I don't really see anything specific that stands out, other then just possibly being dynmap stuff. Even if it comes from factions doesn't necessarily mean it is optimal because it does come from that
Java VisualVM is a profiler you could use to profile
also, if you go the heapdump route to look at that
then just be warned that heapdumps are the same size as the amount of ram you allocated to the server
so if you allocated 10GB and then took a heapdump, it will be a 10GB file
I did make a heap dump and put it into visualVM
still trying to understand how to use it though
I found what was causing most of the lag
I think it's my getClaimedChunks method in the Nation object
I am using another method to turn a chunk into a string and back because when a Chunk is unloaded it then returns null
why are you turning a chunk into a string?
because when the chunk is unloaded it turns to null
ok but that doesn't answer why turning it to a string
I am saving it into a string so I can save it into memory
just use chunk coords
and then use world.getChunk() to get it back
chunk coords?
declaration: package: org.bukkit, interface: World
As long as you have the x and z, you can always load a chunk
I also need the world
that's why I turn it into a string like "world,x,z"
and then I use getChunkAt
wait
I have an idea
not sure if it'll work better
factions uses it's own object for chunks
that stores the world x and z positions
would that be faster than using strings?
Well you could just use serialization
so just use a custom object that implements serializable
and then you can just straight save the object
So basically what I suggested right?
no need to convert it to a string and then you can load the object again by deserializing it
yes, except just added to serialize it instead of converting anything
how do I exactly implement serializable. I mean just implements serializable shouldn't work right?
do I have to make a certain method
for a class to be serializable it needs to implement serializable
yes I did that
it needs to have a long UUID constant in the class
for the world field in my object
should I use World
UUID
or string for the name
I suppose world can be removed from memory
making it return null
generally it is better to use UUID's because world names can be changed, but not their UUID's however the name should be fine because most people don't generally make it a habit of changing their world names
is any faster than the other
no, both are the same as both are loaded at server startup
server, loads all the worlds the server has at startup and loads all the information into memory so doesn't really matter
no I mean like is getting the world from a name or UUID faster
I just told you world information is loaded at server startup, therefore when using those methods it just fetching the data that is already loaded in memory
not sure but maybe comparing a string is slower than a UUID
so no neither one is faster or slower then the other
ok
now, if you are doing comparison checks though
it is generally faster to check object equality then it is string comparisons
Is it ok to make listener classes with parameters?
sure
what type or parameters
Like in my on enable I need to register economy for vault api
and pass that instance to my listener
yeah thats fine
the only thing is, when you go to register your listener
you need to be able to feed those types your listener requires
Wym?
best to pass ``this` in and have methods to get that
well you have to create the listener class object when registering your listeners
therefore if your listener requires parameters
you need to be able to pass in the parameters you specified
Ranking ranking = new Ranking(economy);
getServer().getPluginManager().registerEvents(ranking, this);
getCommand("rank").setExecutor(ranking);
this is how i registered it
Makes sense
isnt it a lot easier to just follow vaults docts and have getEconomy in main class and just pass this in then this.plugin.getEconomy
in most cases vault isn't required
people think if they are providing an economy, that they need to implement vault but don't realize that for people to use vault with their economy, vault actually needs to implement their economy not the other way around
unless vault changed since I last looked at it, but I think it is still at version 1.7
if you are trying to provide api for your own economy, you could just directly do so
no need for vault
It's not for my economy it's just for a simple thing to remove money from players when they click an item
ah ok, that is a valid use case then ๐
Ig but i mean-
Same result in the end right? and i don't have any other get methods from the main class
also are u saying the constructor should be
Ranking(Plugin plugin)
not sure if it is, because this would refer to your plugin
ok nvm
not the plugin that holds the economy
yes but the method to return economy
eg
return econ;
}```
ok nvm
how do i even find this.plugin
there is more than likely a better way but this is the best i know
public class MyClassName implements Listener {
private final MainClassName plugin;
public MyClassName(MainClassName plugin) this.plugin = plugin;
}
public class EconListener implements Listener {
Plugin plugin; //<---- this.plugin refers here
public EconListener(Plugin plugin) {
this.plugin = plugin;
}
}
AH ok make sense thanks
this.plugin.getEconomy or plugin.getEconomy work
I have a question regarding the site-maven-plugin.
So I want to "host" my small maven project on github so that I can use it in another project and found an article to achieve that: https://stackoverflow.com/questions/14013644/hosting-a-maven-repository-on-github (2. awnser).
But when I execute nvm clean deploy, the following error is thrown: Error creating blob: Not Found (404)
?paste ur pom
For whatever reason this returns a ClassCastException. Does anyone know why?
All I do
new TerraChunk(chunk)
and it says I am casting the chunk
Doesn't look like you're casting in that code
ik
Make sure the plugin jar is up to date so it matches the code
well can we see the exception?
wait actually I didn't
I put the plugin in the root of my server
not in the plugins folder
lmfao
I am stupid
lol
I try to sent a fake Chat msg with the ClientboundPlayerChatPacket but im stuck. One of the needed Parameters is the SignedMessageBody, takes a ChatMessageCotant, an Instant, salt and LastSeenMessages. What is salt and how can I get it? And how can I get the LastMessagesSeen?
I just want to see if it is possible with packets
Don't
Why
Oh shit ok
That makes sense
What รญs the simplest thing you can do with nms? I just want to test my ReflectionUtils
You can spawn a mob
Ok thanks
Help, how to change the color of the chat? I tried like this: Bukkit.getServer().broadcastMessage("&l[&d&lDS&f&l]"); However, this comes out:
How can I set the location to spawn the mob, a pig in my case, into
ChatColor.translateAlternateColorCodes('&', yourString);
thanks
Is there any pugin that changes player's skin depending on his tag?
I have a problem when i add vault api to my plugin all later versions of minecraft items break using Material.
eg honey block and deepslate
I am using version 1.7
1.7 isnt supported
AH right but 1.7.1 fixed it :')
average 1.7 logic
1.8 doesn't even exist ๐
many here would celebrate if that was true
What 1.9 u even talking about
๐
idk why minecraft is the only game where people use 8 year old versions and consider this okay
also PLAY_ONE_MINUTE is counted in ticks correct?
yes
yup just double checking
so to get from ticks to milliseconds you / 50 or *
because one tick happens every 0.05 seconds
Ok cool cool then from milliseconds to seconds u / 1000
Hello, I'm working on a plugin and am trying to diagnose the cause of lag. I think a profiler is the best way to go. I've managed to run a profiler on the whole server, but I'd like to run one on just my plugin. Is that possible?
timings/spark let you isolate the plugin after running for the whole server
go to plugins -> yourplugin and you'll see the causes of lag there
Oh yes I just forgot that existed haha
while spark lets you see some things in regards specifically to your plugin, it does not replace a profiler
fair I do not know any spigot profiler
profiler they should be able to isolate methods specific to their plugin
or even class objects
oh yeah
Thanks a bunch
Can someone help me figure out if the result of an InventoryClickEvent is successful or not?
A friend of mine needs a plugin that can stop people from putting putting items on their head (through the use of modified clients this is possible) => https://uploadi.ng/๐๐ฆฉ๐๐
The issue that im having is that I cant figure out how to tell if the player is actually putting the item on their head or not, since event.result seems to always be ALLOW and event.isCancelled is always false, even if when a player on a non-modified client clicks on an armor slot with an item in their cursor, and the item does not get placed. Any suggestions?
Can't you get the slot the player is trying to move the item to?
Do a 1 tick delay and see if the item was set
I am
Does anyone know what I am doing wrong? He tries to teleport the NPC to the player's locations, but he teleports to the spawn of the world
public static void run(Player player){
ServerPlayer cPlayer = ((CraftPlayer) player).getHandle();
GameProfile gProfile = new GameProfile(UUID.randomUUID(), player.getName());
ServerPlayer npc = new ServerPlayer(((CraftServer) Bukkit.getServer()).getServer(), ((CraftWorld)player.getWorld()).getHandle(),
gProfile, null);
Location loc = player.getLocation();
npc.teleportTo(((CraftWorld) loc.getWorld()).getHandle(), loc.getX(), loc.getY(), loc.getZ(), loc.getYaw(), loc.getPitch());
cPlayer.connection.send(new ClientboundPlayerInfoPacket(ClientboundPlayerInfoPacket.Action.ADD_PLAYER, npc));
cPlayer.connection.send(new ClientboundAddPlayerPacket(npc));
}
Hey guys question
I have a plugin that adds a possibility to place water in the nether
but when i try to waterlog a block it still evaporates the water.
Even tho i set it to waterlogged
placing normal water does work
public void onWaterPlace(@Nonnull PlayerInteractEvent event) {
final Player player = event.getPlayer();
final Block clickedBlock = event.getClickedBlock();
if (event.getClickedBlock() != null
&& event.getItem() != null
&& clickedBlock != null
&& WorldUtils.inNether(player.getWorld())
&& player.getInventory().getItemInMainHand().getType() == Material.WATER_BUCKET
&& Purification.getValue(clickedBlock.getChunk()) >= Purification.PLACE_WATER
) {
event.setCancelled(true);
if (clickedBlock.getBlockData() instanceof Waterlogged block
&& !block.isWaterlogged()
&& !player.isSneaking()
) {
block.setWaterlogged(true);
} else if (clickedBlock.getRelative(event.getBlockFace()).isEmpty()) {
clickedBlock.getRelative(event.getBlockFace()).setType(Material.WATER);
}
if (player.getGameMode() != GameMode.CREATIVE) {
event.getItem().setType(Material.BUCKET);
}
}```
You need to send a position packet
Think you can only do Class<?> in that context
mhh stackoverflow stated that its not possible and that i have to use wildcards and internal casting
do you know which package will help me with this?
ClientboundTeleportEntityPacket
Hi so im using spigot to make a minecraft server on my raspberry pi 3 b and ive run into an erros reading Error: unable to access jarfile /home/emdeboss/minecraft/spigot-1.15.2.jar nogui i have no clue how to fix can anyone else know?
And ClientboundRotateHeadPacket
Show your start script
Nogui shouldnt be part of that error
hmm i like the syntax
In NMS, do the craftbukkit or net.minecraft.server imports change cause of the version?
Yes, but you can use mappings
java -Xms512M -Xmx1008M -jar /home/emdeboss/minecraft/spigot-1.15.2.jar nogui @buoobuoo
Do both change?
im pretty sure you need to use --nogui
When I print out the name of the package entityplayer is in, it say net.minecraft.server.level without an version
Yeah needs the hyphens
ill try thanks
If itโs on a cli os you dont need the nogui bit anyway
Thats moj mapping names
buoobuoo since you seem to be relatively smart any answer to this?
why this not working smh
still get the error
Afraid not sorry
I dont use any mappings
are you on linux egg?
sadge
no im using a raspbery pi
yea okay so you are on linux mind doing ls /home/emdeboss/minecraft/
raspian i think
i assume raspbian
no ubuntu server :(
What does it say on highlight?
alr i did the command
send the output
Dont thi k the intial <T> is necessary
apache-maven-3.6.0 BuildData BuildTools.jat BuildTools.log.txt Bukkit CraftBukkit spigot.jar work
unexpected token ye
Thats your issue
okay change java -Xms512M -Xmx1008M -jar /home/emdeboss/minecraft/spigot-1.15.2.jar nogui to java -Xms512M -Xmx1008M -jar /home/emdeboss/minecraft/spigot.jar --nogui
ok
now i get an error saying
invalid or corrupt jar file
then the /home and all of that
became even worser
it seems like your spigot jar is corrupt then
how can i fix it?
Should just use reflection to apply;)
mye i was thinking about that too but ive never used reflections and im trying to make my stuff as fast as possible
with java how would I load a jar API from a spefic folder?
UrlClassLoader?
inside my program
ah static block not allowed in an interface lol
so I'm spawning an Armor Stand to show the amount of damage dealt by the player every time a player whacks an entity, is there any way to prevent the player from hitting the armor stand when they attack the entity thats behind the armor stand
I think best you can do is set it to a marker
I do the same thing and have never had issues with hitboxes
If you want to go above and beyond, have a class for each armorstand which contains a parent (the mob) and when the armorstand is hit transfer the damage to the mob
hmm I guess that works lol sounds so hacky ty
File? Stream?
bruh
didn't find much
i did google search before asking
clearly i'm too autistic to give a good question for google or there isn't much to find?
@tardy delta
bing
Yahoo

are you referring to something like URLClassLoader
Getting a jar file from a folder in my program
uhm
inside the program
sorry brain confusion
I mean I want to get a jar from some spefic folder load class from the chosen jar into my own program
did you have a look at https://stackoverflow.com/questions/60764/how-to-load-jar-files-dynamically-at-runtime
URLClassLoader child = new URLClassLoader(
new URL[] {myJar.toURI().toURL()},
this.getClass().getClassLoader()
);``` you can set `myJar` to be whatever jar you're trying to load
if this is what you're trying to do
isn't URL for websites?
I have no idea why they called it URLClassLoader
actually its because you give it an URL
but a file path can be an URL
true

pain
i wanted this for a plugin
to load random apis
:)
you can do like java URL myJarURL = new File("path/to/my.jar").toURI().toURL(); URLClassLoader child = new URLClassLoader( myJarUrl, this.getClass().getClassLoader() );
an url is a universal resource locator so not only for sites and whatever
i was confused too
URI is even more confusing right
whats an uri even
an URLI
kinda stupid that the ide cannot infer that sneakyThrow will neverr return normally even with a contract
i learn something "new" yesterday with path "./myFolder/"
lol
dis might help too
i broke ij
foudn old code
that time when i decided to write a linkedlist impl :/
alright boys I am once again back with my maths skill
how does one implement a % of something happening? I guess my best bet is if I have 50% then I convert it to 0.5 then uh maybe I generate a random number between 0 and 1 and if its <= 0.5 then I return true else I return false?
Random::nextInt == percentage / 100?
like that will be 0.1, 0.3
ima make tea and reflect on that one
No point in most cases
unless im doing cryptography or smth why should I care about that? (genuine question)
If I'm generating a random to generate some loot there is zero point in using SecureRandom
personally im using this as a crit chance %
Elaborate
so I guess players could carefully commit mafs to calculate when they'll definitely crit? kind of overkill imo if they want sure
Only if they have access to the server and can track EVERY random you generate
impossible, unless they have server access and can trace every single generated random
and at that point tbh the server has bigger problems
Yep
I dont think ANY player would care to go to that level of pain-in-the-assery to do that
Either way tjats not the wnd of the world
Arenโt randoms seeded by the system time when created with no set seed
of course you do, you have to be able to know every random which was generated to be able to predict teh next random
Encryption and cryptography are probably the only proper usecase for them
So youโd need the exact system time the random was created
can some 1 help me with this?
why doesnt this work?? (the item doesnt show up)
its not to implement, its just to use as Throwing.Function<PreparedStatement, ResultSet, SQLException> f = PreparedStatement::executeQuery
amazing job copilot
ikr
that's why I don't pay for it
got it for free lol
ThreadlocalRandom.current
Fuck you
thats what I use
no fuck you
only if you're 18
fuck all of us?
i am 18
pog
No you can't as not all randoms are generated for you
And how did you catch the exception?
copilot copying my old code
To predict you have to see every random which is generated to monitor teh patern
by surrounding it with a try catch
happens all the time!!!
basically
can u plz help me and not argue??
its another ij window lol
thankz
Randoms do follow a sequence, BUT if you only see one random every now and then, predicting becomes impossible
even then these are random generated in a plugin to determin crits. You will never actually see the random result, only a true/false so impossible to predict
LOL
๐
bro really wanted those free 5 iron ingots
hahaha
๐
guessing you had to make sure no-one used the casino whilst you were trying to obtain the sequence?
bro really wanted those minecraft vbucks to irl trade
Oh amazing I was trying to make one for executor
oh
I'd say skill issue
help :/
โI can crack random number generation in a casino pluginโฆ with the source codeโ
L
my guy in a bad mood
L
nah fam I'm chillin
y'all acting like kids
ye
F
no, the item just doesnt show up... the gui does
Isnโt slot 2 the output
Game probably overrides it immediately since there is nothing in the input
Fourteen I was trying to do something like:
void test() throws Exception;
Executor executor = Executors.newScheduledExecutor();
executor.submit(test()).catch(ex -> sout(ex.getMessage())) ;
i tried all slots from 0-2 but when i tried 3 it gave me an exepton, so the slots exist but the item isnt registered
looks bloat
Bloat?
all my exception handling is basically rethrowing the exception so the delegate can handle it
Im really fucked to have to do try-catch un executor
i had a Result<T, E extends Exception> before
i tried casting but it gave classcastexeption
I dont know why the fuck you cannot pass a method throwing a checked exceptions
๐ก
*checked exception ๐ค
jk lol
Checked exceptions are the one throwing right?
Ok, can someone tell me im not crazy?
This almost feels like a spigot bug, but im probably just doing something wrong
This code here kotlin @EventHandler fun onInventoryClickEvent(event: InventoryClickEvent) { val slot = event.slot val cursor = event.cursor val current = event.currentItem println("slot: $slot, cursor: $cursor, current: $current") } outputs this for some reason????```verilog
[08:37:10 INFO]: slot: 17, cursor: ItemStack{GOLDEN_HELMET x 1}, current: ItemStack{DIRT x 1}
[08:37:10 INFO]: slot: 17, cursor: ItemStack{GOLDEN_HELMET x 1}, current: ItemStack{AIR x 0}
[08:37:10 INFO]: slot: 17, cursor: ItemStack{AIR x 0}, current: ItemStack{GOLDEN_HELMET x 1}
It seems that when in creative mode, it correctly identifies the event.slot as 39, but when in survival mode it always says slot 17, and even goes as far as saying that event.currentItem is the item that is actually in slot 17, instead of what is in the helmet slot (39)
this java??
Not most people use Kotlin
Kotlin ๐คข
ikr
checked ones are the one that the ide knows of and that you need to surround with a try catch
fuuck
checked
cuz it doesnt extends RuntimeException
Ok
btw isnt there a oneliner to create a file if it does not yet exist?
why this is happening? someone know?
mwoa 3 lines
new File(databasePath.normalize().toString()).createNewFile();
Fourteen what do you recommend to be able to pass method with checked exceptions thru an executor
it should make the file if it doesnt exist and ignore it if it exists
Caused by: java.lang.ClassCastException: class org.bukkit.craftbukkit.v1_19_R1.inventory.CraftInventoryCustom cannot be cast to class org.bukkit.inventory.SmithingInventory (org.bukkit.craftbukkit.v1_19_R1.inventory.CraftInventoryCustom and org.bukkit.inventory.SmithingInventory are in unnamed module of loader java.net.URLClassLoader @3b764bce)
you shoudl not be casting at all
ye but the item doesnt appear
remove the cast and then tell us what happens
basically the gui opens but without the sword...
surely a smithign inventory has slots 0 and 1 with a result in 2
it has
what is the packet to make a chest appear opened
i tried changing from 0-3 but 3 gave me an exception, so it registers the slots
but not the item
exactly
what are you trying to do? It looks like you are tryign to open a smithing inventory with ONLY a result
You are crasy
basically i have a server with custom crafting recipies, one of them is if u put an iron sword + diamond in a smithingtable it will give u a diamond sword. And im trying to make a "tutorial" where a gui opens and shows everyone how to craft it
Im a bit confused about reflections, because the imports in my case from 1.19.2 are net.minecraft.server instead of net.minecraft.server.v1_19_2
We used kotlin at a previous job I had, Ive never seriously learned java
You can;t set the result slot without anything else (I don;t believe)
wdym?
you need something in slot 0 and 1 to be able to put something in slot 2
ie you can;t have a result without an input
nope
doesnt work
lets see if it works
So I scraped together enough stackOverflow to translate my code to java, ill repost this here
Ok, can someone tell me im not crazy?
This almost feels like a spigot bug, but im probably just doing something wrong
This code here java @EventHandler public final void onInventoryClickEvent(@NotNull InventoryClickEvent event) { int slot = event.getSlot(); ItemStack cursor = event.getCursor(); ItemStack current = event.getCurrentItem(); System.out.println("slot: " + slot + ", cursor: " + cursor + ", current: " + current); } outputs this for some reason????```verilog
[08:37:10 INFO]: slot: 17, cursor: ItemStack{GOLDEN_HELMET x 1}, current: ItemStack{DIRT x 1}
[08:37:10 INFO]: slot: 17, cursor: ItemStack{GOLDEN_HELMET x 1}, current: ItemStack{AIR x 0}
[08:37:10 INFO]: slot: 17, cursor: ItemStack{AIR x 0}, current: ItemStack{GOLDEN_HELMET x 1}
It seems that when in creative mode, it correctly identifies the event.slot as 39, but when in survival mode it always says slot 17, and even goes as far as saying that event.currentItem is the item that is actually in slot 17, instead of what is in the helmet slot (39)
show your project structure
Can someone please help me?
why is your main class class in a main folder tho
edit: i tried anvil and it worked!!!
bruh md_5 plz fix smithing table
Hi, does anybody here work with MongoDB? I followed all the instructions from https://www.spigotmc.org/wiki/using-mongodb/ but I'm getting an error when I try to connect to Mongo -> java.lang.NoClassDefFoundError: com/mongodb/client/MongoClients
I tried different methods to solve this problem but none of them worked
yeah smithign throws error on click
might abstract away sql strings tho
is it possible to detect the click of a lying NPC? I use the ProtocolLib plugin and when I click on a standing (or floating) NPC, he sends me a message, but completely ignores the sleeping NPC...
ProtocolManager manager = ProtocolLibrary.getProtocolManager();
manager.addPacketListener(new PacketAdapter(this, PacketType.Play.Client.USE_ENTITY) {
@Override
public void onPacketReceiving(PacketEvent event) {
PacketContainer pack = event.getPacket();
int enId = pack.getIntegers().read(0);
event.getPlayer().sendMessage(enId+"");
}
});
just google
which ide?
dont say eclipse
For Eclipse - https://bukkit.fandom.com/wiki/Plugin_Tutorial_(Eclipse)
I use Eclipse.
how can i initialize a Team without applying it to a scoreboard?
๐
You happy now? :)
im very angry now
why is the main class called "Main"
I love Eclipse. they even improved module handling so I'm a happy camper
You gotta shade mongo
i name it Loader
say sike right now
I name it <project name>Plugin
UniversityPlugin, ZombiesPlugin etc
Ok now my head goes completely nuts
Why use all version below 1.17 import net.minecraft.server.v<VERSION>.EntityPig for example
and all above import net.minecraft.world.entity.animal.EntityPig
because the structure changed
So you have to check in your Reflection Class if the version is below this?
Yeh
hmm might use reflections to map pojos to db tables but i saw what happened with gson
Im beginning to understand why almost everybody hates nms for multiple version compatibility
modules makes it simple
do i need to have a scoreboard to make a team
or just skip that and make a load(Map<String, Object>) type thing
ah lol
having this currently
netbeans
ms-paint-ide
real men use Eclipse
legends use nano because vim is for nerds
The home of Spigot a high performance, no lag customized CraftBukkit Minecraft server API, and BungeeCord, the cloud server proxy.
Is it possible to rename a inv?
Nope you need to create a new named inventory
is it bad practice to have a hashmap in a hashmap
Yes. If you have any nested collections then you need to create more classes which contain the nested data structures.
unless it has to be performant
Never create any getter or setter for any data structure
s
then whats to point of making another class
to wrap it
I have an enum called SkillType which has stuff like SkillType.WOODCUTTING, SkillType.FISHING and I need it to map to a value for a level, so eg <SkillType.FISHING, 5> and I need to map this collection of values to the player UUID
so I have HashMap<UUID, HashMap<SkillType, Integer>> not sure if I could do it a different way
i think i know what youre going to say
"you can expand it, and its a principle for manageable code" but if you only need the hash map and no other shit theres no point in making another class, it will basically just be a wrapper
oh wait
yeah in this case this is better
what i have is
maybe even a player data class
was he talking about keeping track of progress or computing the xp needed to level up a skill?
lol
Yes and you want that. You dont want to ever have ambiguous dangling data structures nested inside other data structures.
This breaks strong encapsulation. There is only one acceptable scenarios in which nested data structures are viable:
The nested structures are only used inside the class. Otherwise the class breaks strong encapsulation and in most cases
the single responsibility principle.
i dont care about principles as long as it saves me coding time and execution time
unless you need more data
just use the structure
So for this you would 100% use a Map<UUID, SkillHolder> where the SkillHolder wraps a Map<SkillType, Integer>
instead of a wrapper doing the same thing
yeah
uh and why would I do that instead of directly just having it in one line?
what is the range of ports I can use for my mc servers, or is there none?
The only reason for the SOLID principles to exist is to "save you coding time"
Saying i dont care about them if it saves time is contradicting in itself
well if youre certain you just need that data writing a wrapper class definitely takes longer
Any you want. But there are obvsly some standard ports which are used by other applications like 8080, 83, 1 - 128 etc
so imo it wouldnt be worth it
mk
Not in the long run. Imagine if he later wants entities to also have skills. Then instead of just adding another Map<UUID, SkillHolder> you
need to basically copy paste the entire class and make sure the functionality doesnt contain anything player specific.
Its all about modularity. Making something "work quickly" will create huge problems if you want to modify or expand
the code at any point. There is no excuse to ever ignore those principles. Otherwise you are not writing an application
but a simple script in which case you are better off using Python or something similar.
I learned to never nest maps because I ended up having to change the data structure and it took me like 2 hours to replace all of it
Its always worth it. "The only way to go fast is to go well." - Bob Martin
This is crucial in software development
7smile7 what's your stance on extending collections for the sake of utility ๐
oof im not sure if i have ever taken that route. The only scenarios in which i extend collections
is to prevent type erasure. But if you do it for the sake of utility then you should make it generic at least.
Otherwise (like for filtering content) you are adding too much responsibility into the data structure.
The responsibility to manage the data lays with the enclosing class
Yeah i personally would not do that. Its a nifty idea but it also overloads a single class.
This looks like you abused a LinkedList to achieve a Composite pattern now that i look at it closer
you make it seem like I'm going to jail for class abuse
but sure I was thinking on using an internal list or something
I do need a node chain structure regardless, would make more sense than an arraylist
a tree not so much as I have no "go forward" button
Nah prob fine
https://paste.md-5.net/elejusoqek.java
Cannot resolve symbol 'target'
Nested switch
target is defined in a totally different scope here. This is the problem if you write monster methods like this.
Keep your methods small. Max 20 lines of code.
I dont see what you mean.
Also:
if (sender instanceof Player player) {
Player target = Bukkit.getPlayer(player);
} else {
This makes no sense whatsoever. Here sender and target will always be the same person
it checks if the args are 0 first though.
target is created in a different scope. Down there its not a variable anymore.
So what can I do?
Learn the basics of java i guess?
You need to define "target" in a higher scope
Your target variable is defined and then deleted right away without seeing any usage currently
Alr I fixed it
Guys
I am having a problem with my collision here
basically clone the repository and run it yourself
open the index.html
This is bannable
Delete that post pls
and click anywhere in the screen to add circles
that is just a collision code
There are too many "can you try out my application" scams
Already on it
basically
when I add some circles
everythign works fine
they collide and do the physics
but when I add a lot of circles
hi how can i make my vault economy math expression to look like this 2k instead of 2000 and also how can i capitalize letters on placeholders?
the heaviest of them starts to teleport
What maven command do I use to build my plugin?
let me record to show it
"Object" is a pretty questionable name. Use Body or RigidBody for physics based objects
install will do
if (target = Player) {
target.sendMessage("ยงeยงlYour gamemode has been set to ยงaยงl" + gamemode);
return true;
}
Expression expected
== instead of =
Dang forgot thanks
No, i set target to player earlier so its fine
๐ค
@lost matrix https://www.youtube.com/watch?v=IPWQMw2k6Yw
here
what happens
it should not happen
the bigger ball starting to teleport
when I add multiple balls
the bigger ball has a mass of 50000000000
and the others balls has a mass of 1
Is there a reason why you only calculate the gravitational force for the heaviest object?
when I remove this the physics simply stops to work
and also, I dont know how to use it for all objects
Every object with mass in a space has gravitational force. So even your desk is currently pulling your toilet to itself and vice versa.
For a correct n-body simulation you need to calculate the force of each object towards each other object.
that is what happens when I apply the gravitational force for all objects
basically, the physics works only for the first added ball
and stops working on all balls if I add more
no errors on console
Why is gravitationalForce not a vector?
Caused by: java.lang.ClassCastException: class org.bukkit.craftbukkit.v1_16_R3.inventory.CraftMetaLeatherArmor cannot be cast to class org.bukkit.entity.Damageable (org.bukkit.craftbukkit.v1_16_R3.inventory.CraftMetaLeatherArmor and org.bukkit.entity.Damageable are in unnamed module of loader 'app')
Wrong Damageable import
there are two
dsaodkadosdjids
Ah i see the problem. You need to create a resulting force out of all forces.
So the acceleration currently only uses the very last force
acceleration += force.divide.. should do the trick actually
it is the force from here
Ah this is the simplified forumla used in schools
and then here I transform it to a vector
Anyways you only apply the last acceleration instead of the resulting overlayed acceleration
with this
so it should look like this, right?
Or you create a force vector, overlay all forces and only set the acceleration at the end
I would rather go with the technically correct way of creating a final force vector which
is the result of adding all force vectors and then setting the acceleration once
like I just sent?
Math#cos
Math#sin
yes
This would get out of hand very quickly. So no.
Create one vector before the loop and add all force vectors on it.
Afterwards you set the acceleration to finalForce / mass
just for a base, I stole the code from here https://github.com/JVictorDias/CanhaoDeNewton/blob/main/src/main.cpp, which is described here https://www.youtube.com/watch?v=evcnQajrR6E
it is in portuguese btw
โ - Aprenda programaรงรฃo na Alura, estudando com 10% de desconto em: www.alura.com.br/promocao/universoprogramado
Olรก!! Seja muito bem vindo(a) ao Universo Programado!
Neste vรญdeo vocรช verรก como simular a gravidade em um computador e com ela reproduzir o experimento do Canhรฃo de Newton! Neste vรญdeo abordaremos conceitos fรญsicos como posiรงรฃo, ...
I have a custom inv. and I want to get that inv in InventoryCloseEvent so if I check it like this,
if e.getInventory().equals(MyCustomInv){
...
}
will it check if the event inventory is exactly my custom inv or it will check the inv type/ inv name or something else?
event.getInventory() will return the inventory you are currently clicking
Use a Set<Inventory>. When you open the custom inv -> add it to the Set. When its being closed -> remove it from the Set.
Then on click and close you can simply check if the Set contains the inv.
Not quite. It will always get the primary inventory (upper one)
Map<UUID, Inventory> menus = new HashMap<>();
Inventory inventory = menus.get(event.getPlayer().getUniqueId());
if (!event.getView().getTopInventory().equals(inventory)) return;
That could help you
Looks like collision handling gone wrong to me
hahaha i mean i dont copied that from yours
I used to use that before i ask you for help
Where is the thread
I cannot find it
This is pretty redundant... A Set<UUID> or a Set<Inventory> would do the same.
No
Yes
?
But the event does
7smile is rarely wrong, the guys a magician
it fixed the physics, but still the bigger ball still teleports
looks better
Which forces do you calculate?
wdym
This makes more sense
There are a ton of forces in physics... which ones do you account for?
I am trying to do a gravity
I need the thread where you sent the code
I mean i never left the thread
weird
fucked discord
what is the onCollision code?
Hm. Try disabling the elastic collisions. onCollide -> set the velocity to 0
Im predicting a problem in there
I deem that you have something like https://www.youtube.com/watch?v=SqpIcsN0FTI
Github https://github.com/johnBuffer/NoCol
Music used https://freepd.com/music/Screen Saver.mp3
This is a reupload to fix typo.
why null?
I mean why holder is set to null?
What should be holder so
I never understand why its there if no oe use it
It's just there for the sake of being there
Im being serious
InventoryHolder is a hack
I have a variable on the physics.js called ZERO_ON_COLLISION. If that is true, then the Circle.zeroCollision is called, which sets the velocity and acceleration to 0. Should I set it to true then?
Im still thinking how to track custom inventories during event when i have a map<String, Menu>
name
No no
Unique name
Let find a example from Ilussion impl
but that string is no the menu name
๐ง
just for a base, my gravity works. If I set the velocity high enough the ball starts to orbit the bigger one
why discord doesnt display the nfucked picture
Fucked discord
๐ก
what
are u trolling
Im being serious bruh
I dont have coding problems
I have LOGIC problems that is not the same as CODING
Indeed
you talk really closed enlighs
Problem here. I was testing with only 2 types of circles: 1 with 50000000 of mass and another with 1 of mass. I added one more type with 10 of mass and its speed is very slow now
Also take care that is not my code
I know he has a Map<String, Menu> that is simple
Lmao intellij is weird
displaying errors when everything is correct
๐
Its a library
your import does not have ;
If i create a new instance every time the menus will always be null
oh that why hahaha . i never realize
NewInstanceMenuHandler == HavingMenusEmpty
How would i relationate the menus with player
static is cringe
it also makes you more unprofesional
Arent nested map really bad?
I dont think so
I dont know wy you are trolling me
If im being serious
I will make a chain obj for that
Doesnt this coding skills look great
Yeah
hehe i know
I dont wanna blame u
Because i will get banned
Conclure just have given 1 oportunity more next one im banned
He is really kind
mans flexing my own code
imlllusion unblock me
made it a bit cleaner
hi how can i make my vault economy math expression to look like this 2k instead of 2000 and also how can i capitalize letters on placeholders?
If your economy plugin supports the format methods I'd use those
Alternatively you'd have to make the SI unit conversion yourself
hello
he probably uses PAPI vault placeholders i guess
don't know where to post this but why are my images not showing up?
so he would need to manually work with string
did they work before
yes.
then just a website bug
I tested the images and they work on other websites.
I use vault placeholders
I don't think they were deleted cuz I use Imgur.
nono
it's just a spigotmc thing
You shouldn't use any text within images anyways