#help-development
1 messages · Page 2172 of 1
?ask please be more descriptive
If you have a question, please just ask it. Don't look for staff or topic experts. Don't ask to ask or ask if people are awake or available. Just ask the question to the channel straight out, and wait patiently for a reply. Make sure you use the right channel regarding the topic of your question. Create a thread in case the channel is already in use!
what would i do:
i'm having a playerdata class which is supposed to be loaded from a database and has alot of fields so i'd have to make a constructor with all those fields included
so should i just use that constructor or use a builder pattern or some static method fromSql(ResultSet) or something?


fromSql(ResultSet)
im sorry i had to
oh lol spigot is uwu
is what I'd do
It's snorkel time! ٩(- ̮̮̃-̃)۶ uwu :3
lmfaooo
im loading all the player stuff from different tables so i would end up with different resultsets
better instances
which doesnt make it easier
hmm
@tender shard
remove????
then do a method like PlayerData#getFromSql(Player playerName) or sth
and then it takes care of laoding stuff from all the different tables
nothing
and what about the playerdata constructor?
just throwing all parameters in or a builder or smth
declaration: package: org.bukkit.inventory, interface: Inventory
no it weirdly subtracts 60 and 3 from the amount
if (all.getItemMeta().equals(archaicweal.getItemMeta())) { all.setAmount(all.getAmount()-60); }
whats that gonna do>
it "removes the item out of every itemstack" what?
new ItemStack(material, amount)?
okay I'll try to explain
imagine you have 20 dirt and 10 diamonds in your inv
now you want to remove 5 dirt, and not more
AHHHHH
so you do it ike this:
ItemStack toRemove = new ItemStack(Material.DIRT, 5);
playerInv.removeItem(toRemove);
removeItem
now you're left with 15 dirt and 10 diamond
thanks mfnalex for explain
then clone that existing itemstack and set the amount to the amount you wanna remove
then pass it to the removeItem method
Why are you giving an item stacks and not having any memory or identifier to remove it with If that's your intention
:/
whats wrong
Java arrays are not written like that
lmao
Is it possible to change the time before server times out? Trying to increaes it so i can debug easier without getting kicked
what is the way to save Entity to Config?
i tried to save the Entity i clicked on but it only gives me CraftCow
i wanna save entity data
does anybody have an idea to cycle trough every player individually? and no i dont mean for(Player all: Bukkit.getOnlinePlayers()).
so i do something for every player, but not for everyone at the same time
for every player, after one player got cycled trough the other one. i know how to get players, but i wat to do it like that
im really wondering how to create an object based from data from different db tables, should i just use multiple prepared statements under the same connection or is there a more efficient way to do smth like that?
Hi @round finch 👋
HI @tardy delta 👋
How do I package Remapped NMS that is shaded?
What is better way for nametags via armorstands? I mean should I do it with packets or real entity?
define better
im getting an error: ERROR Could not pass event ProjectileLaunchEvent to DinnerChad v1.0-SNAPSHOT but i dont have a projectilelaunchevent
its throwing whenever an arrow is spawned
can you provide the entire arrow
the entire arrow?
error
autocorrect is out there
DinnerChad.java:66
that's where your error is
and it looks like you're casting an arrow as a living entity
ohhhhhh
thank you so much
You can use a resource pack and add it to the language file(s)
uh... what? you want to do something for every player... but don't want do do it for every player? i must be high rn
Probably yes
probably by editing the font bitmaps
Legacy color codes might work
afaik theyre not just wroten out as V and etc
i'm even pretty sure that the colors of tags and stuff are hardcored into the client
at least the creative ones for the category-tags are
any example on how to make a class that caches things?
i mean i could just throw everything in a map but then i'd end up with a class full of maps
Good morning guys! Do you know how to create a sort of "pin selector" inside an anvil? I would use it to do like a real ATM in a nutshell.
Then the operation would be, write in the pin bar (item rename bar), then click on the final item that confirms, if the pin is right opens the atm to withdraw.
i would use a sign for that
You say? I thought about doing it with a gui a dispenser where he asked for the pin, what do you think?
It'll be more difficult for sure
Wouldn't you just end up having maps somewhere?
idk i think so
i forgor how to get list inside of list within config
U can have a cahceholder class
And each cacheholder class has 1 map
U can add cache and removefromcache methods
As well as get
And create a cacheholder object for everything u wanna cache?
i saved a list of lists
lmao
To List<List<Whatever>>
Store all the cacheholders is a map<DataType, CacheHolder>
and then save it back
I thought you saved the list and wanna ge tit
i guess ill write classes like usermanager, kingdomsmanager etc
That's what i do
i do
Do Config.getList
brb gonna check for errors one sec
I also make my manager classes listeners so they load data on join, save on exit
If u have multiple types of data tho
U can have one listener that handles loading of all
can someone explaing me the logic of custom model data
Custom model data works with integers only. You set the custom model data field in your resource pack for a specific item and then when you want to create/show that item with spigot code, you set the custom model data to the same number that you set in your resource pack.
so is it possible i can just change an itemstacks's texture?
Yes if the user has the texture pack to support it
we need to add another model to the pack or just changing the model that we have created as Material on ItemStack?
You could just add another model to the pack and just give it another number.
as name?
You have the integer limit to work with for every single material in the game.
do you have any tutorials or can you explain me the process so simply?
a wise man once said that everything is a map
Not really. My knowledge of resource packs is a little limited since I only worked with them about a year ago. Things have probably changed a little, but it is a process. I’d recommend looking at the Minecraft wiki for the resource pack. It covers a lot about packs and how to get one setup. It’d then be up to you to add the models and make sure they all point to the right place.
If you are familiar with how pointers work, then you should be fine. Resource packs do a lot of that.
ok so weird question but how would you get the block of a target?
because Material.TARGET doesnt work
wot
like
Player#getTargetBlock()?
I want to check if a projectile hits a target block
Oh the actual target block?
yes
Is it not Material.TARGET_BLOCK?
if(event.getHitBlock().getType() == Material.TARGET) {
``` this is not a thing
target block doesnt work either
That's certainly how you would go about doing it. So either the code you're checking isn't being called or getHitBlock() isn't what you think it is. Printing things out is the best way to check
I have used this method with other blocks
so i know it is the right one
but the target block isnt an available block for some reason
?stash
Then just sort the map (by removing all enchantments and adding them back in in the order you wish)
That being said depending on the circumstances that may not always do what you want to
And the client might choose to display the enchantments differently
But considering that the server stores enchantments as a LinkedHashMap (https://hub.spigotmc.org/stash/projects/SPIGOT/repos/craftbukkit/browse/src/main/java/org/bukkit/craftbukkit/inventory/CraftMetaItem.java#304) it can be likely assumed that insertion order matters
Anyone have any custom item ideas for pvp and dungeon crawler gamemodes?
hey so i cant seem to understand how to do it so i m just gonna ask here:
If i am using a random host like idk minehut or a paid server so that i have access to the files, HOW can i creating multiple servers inside of my main? like each server has its own like plugin folder etc.
Also, in my code, do i need to implement, in my spigot prject, bungeecord like i would implement a library?
I m VERY lost here so any help would be cool
Multiworlds plugins
so i dont unse bungeecord right?
Pretty sure bungee just connects multiple server
So if you buy like 10 servers you use bungee
and
just a question
would u recommand to add the plugin to the server and make my code send commands to send the player to a world and create wome, or is there an existing api that i can use
does it matter if I build a plugin with spigot and will it work on a paper server
Spigot plugins generally work on Paper
oh ok
^
?paste
here is my pom :
https://paste.md-5.net/zefuqileri.xml
but when i run it, (i mean reload the maven) i have this error :
Blocked mirror for repositories: [onarandombox (http://repo.onarandombox.com/content/groups/public, default, releases+snapshots), vault-repo (http://nexus.theyeticave.net/content/repositories/pub_releases, default, releases+snapshots), elmakers-repo (http://maven.elmakers.com/repository/, default, releases+snapshots), Official Bukkit (http://repo.bukkit.org/content/repositories/public, default, releases+snapshots)]
Since Maven 3.8.1 http repositories are blocked.
Possible solutions:
- Check that Maven pom files not contain http repository http://repo.onarandombox.com/content/groups/public
- Check that Maven pom files not contain http repository http://nexus.theyeticave.net/content/repositories/pub_releases
- Check that Maven pom files not contain http repository http://maven.elmakers.com/repository/
- Check that Maven pom files not contain http repository http://repo.bukkit.org/content/repositories/public
- Add a mirror(s) for http://repo.onarandombox.com/content/groups/public, http://nexus.theyeticave.net/content/repositories/pub_releases, http://maven.elmakers.com/repository/, http://repo.bukkit.org/content/repositories/public that allows http url in the Maven settings.xml
- Downgrade Maven to version before 3.8.1 in settings
here is the wiki for the api i wanna use
How can I get the player's motion vector?
There is nothing about the motion vector. I tried to use getDirection but it gives a view of where the player is looking
declaration: package: org.bukkit.entity, interface: Entity
Always go for api usage when possible. Sending commands is a dirty hack to invoke functionality.
any reason this wouldn't work?
@EventHandler
public void EntityPickupItem(EntityPickupItemEvent e) {
if(ArrowPickup == true) {
if(e.getEntity() instanceof Player) {
if (e.getItem().getItemStack().getType() == Material.SPECTRAL_ARROW) {
Bukkit.broadcastMessage(ChatColor.WHITE + "<" + ChatColor.AQUA + "BlockyRef" + ChatColor.WHITE + "> " + ChatColor.RED + e.getEntity().getName() + " picked up the arrow");
e.getEntity().addPotionEffect(new PotionEffect(PotionEffectType.GLOWING, 300, 0));
}
}
}else {
return;
}
}
First of all: Format this pls. What IDE are you using?
Eclipse, Intellij, Visual Studio, Atom, Netbeans etc
Then click into the class and press ctrl + shift + F
For some reason my velocity in X and Y is 0
Means you are standing still
a noise pops up and nothing happens
oh there
it works
Now post the formatted code again pls
@EventHandler
public void EntityPickupItem(EntityPickupItemEvent e) {
if (ArrowPickup == true) {
if (e.getEntity() instanceof Player) {
if (e.getItem().getItemStack().getType() == Material.SPECTRAL_ARROW) {
Bukkit.broadcastMessage(ChatColor.WHITE + "<" + ChatColor.AQUA + "BlockyRef" + ChatColor.WHITE
+ "> " + ChatColor.RED + e.getEntity().getName() + " picked up the Arrow");
e.getEntity().addPotionEffect(new PotionEffect(PotionEffectType.GLOWING, 300, 0));
}
}
} else {
return;
}
}
} else {
return;
}
Is obsolete
what should I use instead
ArrowPickup should be arrowPickup
Only classes have first capital letters
nothing
oh
if (e.getItem().getItemStack().getType() == Material.SPECTRAL_ARROW)
i reccomend you use .equals instead of ==
I mean they’re comparing singletons
i am pretty sure that is incorrect. Right?
No wouldn’t do a difference at most
Wouldn't be incorrect, just depends on the person really
You should compare enums by identity. So == > .equals()
Its also null safer
i always use .equals
I use capital letters in all my other projects, the shit still works
but I wont do it anymore
fair enough
No, I'm walking, but still my velocity is: 0.0,0.071231441,0.0
Make sure the listener is registered.
Also add some debug messages after each conditional statement to see how far your code runs.
ok, it is registered
I know for a fact the command I am using to turn the thing on works
Is there another way to find out the motion vector?
Show some code pls
getVelocity returns literally the motion vector.
Add debug messages.
My prediction: You are setting the "ArrowPickup" variable in different instances.
thats what i tried to do but u see, when i try aplying this api look what happens :
.
should that matter if the variable is public?
I am and the only thing hat isnt working is the listener
@EventHandler
public void OnPlayerMove(PlayerMoveEvent e){
e.getPlayer().sendMessage(String.valueOf(e.getPlayer().getVelocity()));
if(number_of_squats==2){
e.getPlayer().sendMessage("Dodge");
number_of_squats=0;
Player player = e.getPlayer();
Vector vector = player.getVelocity().multiply(10);
player.setVelocity(vector);
}
}
now that is a dangerous event to play with 
hi! i’m doing something to select a text via a gui sign so the idea was to do:
Text:
Example
How can I make the first line uneditable? Can I?
(answer = xmas cookie :))
Worked for me. You are using an ancient spigot version of which the support was dropped ages ago. Who even plays this anymore?
Im def seeing some versioning issues here.
PS: change the repo from http to https
This event is fired before the velocity of the player is changed
vim
viiiiiiiiiiiiiiiiiiiiiiiiiiiiim
vvvvvvvvvvvvvvvvvvvvim
vimmmmmmmmmmmmmmmm
iiiiiiiiiii
vimmmmmmmmmmmmmmmmmmmmmmmmmmmmmm
ivm
milf
mivoen
yall on crack?
miov
me 👲
vim is nothing but a soft-lock tool. If i want to protect my pc from unauthorised access i just open vim.
LMFAO
text me babe 🙂
:q or :q!
🧐
that's how you exit vim
Can I use this: public void PlayerToggleSneakEvent(PlayerToggleSneakEvent e)?
whats all this then 🧐
if you type :q exit, :q! exit without saving
What are you trying to do?
Dodge when player crouch
?conventions
Java Coding Conventions: https://www.oracle.com/java/technologies/javase/codeconventions-namingconventions.html
What does "dodge" mean exactly? Because there is an "isCrouching()" method in Player
Okay so I wanna make it so there is a chance that an enchant procs, and the chance is 0.3% per level that you've got.
How would I approach that ?
I though of using random number generator, but I don't know how to exactly do it.
// If the player's enchant is level 1
if (randomnumber < enchantLevel / 0.3) {
// do stuff here
}
// Would this work ?```
what is proc?
if(ThreadLocalRandom.current().nextDouble() <= enchantLevel * 0.003) {
trigger();
}
Math.random() < .3
o wait
To execute the code or the enchant to active.
noice
ohh like the chance of effect?
Yes
7smile's answer is correct
1.0 == 100%
0.5 == 50%
0.01 == 1%
0.003 == 0.3%
But I think I'll use this.
Guys a question, I wanted to open the player a sign with the following text in their respective lines:
Text:
Example
Can you tell me if there is a possibility to block the modification of the 1, 3 and 4 line by the player?
Yes
Modification on what stage?
You cant block the player from changing the text while editing because thats client side.
But you can stop the player from applying changes to certain lines.
aoahohhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhh is fine so it’s clientside, I’m trying to block that from about 5 hours... Thanks
You basically have no option besides overwriting any changes they do
cool
just another question, if I set the first line text, is it possible to make that the player when you open them the sign, is already editing on the second line?
I mean, with the second line selected
98 you're my hope
and how could i use it in that version? cuz it should work : the api exists.
PS : the sever i m doing this for is NOT mine and there version cannot be changed (their choice)
I mean did you read what the error says?
Also you shouldn't need the bukkit api if you have spigot since it's included
Is there a way to create custom enchantments without creating a lore of an enchantment and then make an event for the item?
I mean like make an actual enchantment
No
nah
is there a special way i can correlate a value in a yamlconfig with a value stored in an enum?
or do i just have to run a switcher on it to get the value as in the enum
hello
When is PlayerVelocityEvent called?
when the player experiences velocity...
can i create a mysql database but not with localhost with jdbc?
@EventHandler
public void OnPlayerMove(PlayerVelocityEvent e, Vector vector1){
e.getPlayer().sendMessage("1");
}
What is the error, why is the code not working?
good quetion
what is Vector
remove it
^
get the vector inside the curly brackets
the params for that method only pass the event
All the time, when I change the vector of my movement, a message should be displayed. Did I understand correctly?
not the point
you cant put Vector vector1 in your method arguments
instead, get the vector afterwards
there's probably a method like e.getVector
Okay, i removed that part, but still nothing.
did you register the event?
Yes, because other events from the file work
are you getting an error in console?
No
Get his velocity
that event is triggered when a velocity of a player is changed
ezpz
@EventHandler
public void playerMove(PlayerMoveEvent e) {
e.getPlayer().sendMessage(e.getPlayer().getLocation().getDirection().toString());
}```
that is playerMoveEvent
he wants PlayerVelocityEvent
Thanks, but why didn't my code work?
i place a hashmap inside of hashmap within my config?
how do i get it from my config? 🤨 🤔
what you trying to make?
still got it to work
@EventHandler
public void playerMove(PlayerVelocityEvent e) {
e.getPlayer().sendMessage(e.getVelocity().toString());
}```
maybe you forgot the .toString()
well\
you can't send a velocity in chat
he wanted to send "1"
.
it was for a test i think
i k
then just..
@EventHandler
public void playerMove(PlayerVelocityEvent e) {
e.getPlayer().sendMessage("1");
}```
hell
iad
yes but well its seem more friendly
iad is more
Doesn't work
then you didnt register the event correctly
Then why do other events work?
That is, you received a unit in the chat when changing velocity?
yes
Entities:
01e53610-58bc-4aa4-b049-77ded56a8c74:
INVULNERABLE: 'false'
TYPE: COW
GRAVITY: 'true'
NAME: Cow
what are you doing to try and trigger the event?
you can create a class with a constructor
for all entities
public class EventListener implements Listener {
@EventHandler
public void playerMove(PlayerVelocityEvent e) {
e.getPlayer().sendMessage("1");
e.getPlayer().setVelocity(e.getVelocity().multiply(2));
}
}
This, no?
?codeblock
You can use the discord code block format to display code or just text in a more pleasing way:
```java
public class MyPlugin extends JavaPlugin {
@Override
public void onEnable() {
}
}```
Becomes:
public class MyPlugin extends JavaPlugin {
@Override
public void onEnable() {
}
}```
i have save it
i just need to return my hashmap with hashmaps
getServer().getPluginManager().registerEvents(new EventListener(), this);
}```
why a hashmap?
@crude cobalt ^
That is?
you can use class named Entities, save it in your config.yml, then when you enable the plugin, create again all Objects
I think that the equivalent of hashmaps in cofig are ConfiguractioNSection
what are you doing to try and make the message appear in chat
nah
But almost
And if you are saving custom data models, use ConfigurationSerializable
Fuck mongo db
Lol
This code
😡
I mean it’s easy to provide a strategy for serialization of enums tho
Wait mongo has a thing called codec
Yes
walk
Doesnt it allow to add support for custom object?
Idk
that's what I've been trying to tell him for a while.
walking doesnt set off the velocity event
i feel something isn't right..
Troll = BAN
PlayerMoveEvent
But it shouldn’t be too hard to circumvent the Enum issue
velocity event will only go off when you take VELOCITY
like push of tnt
who u talking to
cus i also have a similar issue
Verano
I dont know why it shit me when im saving just a list reference of an enum
here.
yeah?
I can't get velocity in this event
just subtract from/to
WallyTube mind elaborating further a bit?
Dont ask it everytime, if you dont want to get your mesage lost - open a thread on this channel
do you mean like directly getting the Enum constant from a string or am I mistaking myself now?
yeh i have this enum:
public enum FishRarity {
COMMON,
RARE,
LEGENDARY,
GOLDEN,
TRASH
}``` and i want to get the `whatever.rarity` value from a config, which i believe is gotten as a String, instead of a FishRarity
@EventHandler
public void onPlayerMove(PlayerMoveEvent e){
e.getPlayer.sendMessage(e.getPlayer().getLocation().getDirection().toString());
}```
thats a vector
not velocity
he wants to get the velocity of someone while theyre walking
Now im thinking if what im doing its wrong. But my idea is to keep a list of value from an enum
FishRarity.valueOf(string)
Keep in mind
nulls?
It throws an exception if given a mismatched input
This is not the direction the player is moving, this is the direction the player is facing.
IllegalArgumentException iirc
yeh i'll just tell my staffers not to be stupid ig
Lol
Doesnt apply doing "location.getTo() - location.getFrom()" ?
e.getFrom() and e.getTo()
are enum values supposed to be variables or just generic "values"?
Talking to?
conclure
They’re singletons
Conclure sorry for asking this noob question, but im not secure how track a list of enum values
whats the method for getting a material from string?
You could turn it into a list of strings and save it to Mongo? Then fetch it and use EnumClass.valueOf(str) for each string retrieved in the list and turn it into a list of Enum constants?
Material::getMaterial
or matchMaterial
or valueOf Ig
Can you write some code that will give me an analogue of velocity?
What are you trying to do? As far i can i see looks like a premium plugin
Material.valueOf("DIRT");
Because mongo has:
List<String> list = getBlaBlaBla().getList("field-name", String.class)
bambus
better?
Just a dodge plugin
Plz write code
Write the code yourself, it’ll be of good practice for you
Yeah
But he doesnt still explain what need
Its impossible to explain something in 1 world
you can use e.getPlayer.getVelocity
I can’t
getvelocity doesnt return ground velocity
Why?
@crude cobalt just subtract the from/to locations
I have already said that
...
How?
No
I‘m really not understand
why?
Start by using google translate then
or deepl
to.getX() - from.getX()
Doesnt give ground velocity
there is something to get you started
There will be 0
Maybe using vector? (What you other people think?)
Vector vector = new Vector(event.getTo()).substract(event.getFrom()).normalize();
vector.getVelocity()
I do not believe that this does what you mean
@crude cobalt literally what do you have as of now?
lore 🙂
Alongside the HIDE_ENCHANTMENTS flag
How would you calculate if player pressing WASD, which will be the form?
(that being said, syncing lore and enchantments is pain)
You can't. The client doesn't send the server raw WASD inputs. It doesn't ever send raw inputs. Rightfully so ;p
Client/server communications in a game should contain intent and be keybind agnostic
And how does it the plugin BentonQuests. hmns
Probably player move event
What exactly does it do?
So that why im asking ps. I just want to know the form
It has an interactive quest menu in chat that changes options when u press w or s
Anybody got a plugin idea?
For conversation options in a quest
yeah
I’ve never tried but just do some debugging getting the players direction etc and try something with it
But that would require the player to actually move (or have really strange behaviour when the ping is high)
Cancel event ?
Yeah high ping is a problem
Wait I realise
Bento quests put the player on an armor stand
So they can’t rly move
Cancel the event and create a fake train wagon?
I personally prefer my ClickEvent
What does it?
I like the way bento did it but it’s quite a lot of work tbh
?jd
He means in a gui lol
Is he trolling?
Frick not that
Like the hower event
Why the hell does this site not update the URL
Why using an ancient bungee version?
It is in bungee
Because that is the latest bungee chat version
Api*
But you can use adventure if you wish, it's the same thing
yeah
but bungeecord.jar last versions is 1.18 something
That is bungee chat
But in fact dont worry
Not bungeecord itself (i.e. the proxy)
but ungeecord contains bungee api 🤔
Yes, and spigot contains the bungeecord chat
He isn’t lmao
I dont know why he mentioned his click event
And the urls he sent
Looks really weird
As far as I know worldguard uses it to configure permissions in a more user-friendly way these days
ur api?
It probably does not use bungee directly, but at the core - yes
No he means a totally different approach like leave keys but clicks
Instead of wasd using mouse 1 and mouse 2
I dont know if he is either more drunk or me
Yeah, you basically click a piece of text and then the client runs a command
That what do default bungee chat lmao
he said he would prefer using bungee chat api to make clickable text instead of doing inventory move event
I dont think its realted to what i said
For navigating GUIs it is a more optimal approach imo
No, not individual key presses
Instead of using bungee I'd rather use https://jd.adventure.kyori.net/api/4.10.1/net/kyori/adventure/text/event/ClickEvent.html but alas adventure is not included in spigot by default
Also iirc adventure has some methods for keybinds maybe look into them not sure what they do tho
Nah, that is clientside
ahh I see
As adventure was originally written for sponge iirc
Im either drunked or java its weird today. I dont know why the event its not being cancelled if the condition its okay
You need to cancel the event via evt.setCancelled(true) if you did not already
But return doesnt stop code execution?
What is your issue? That it cancels or that it does not cancels?
how do i generate a random number from 1 to 100 (inclusive)
Return only jumps to the end of the method so to say
It allow me to break the protection block
Do +1 in thread local random
ThreadLocalRandom.current().nextInt(0, 101)
random.nextInt(100)+1
100*
tyty
inclusive
Nono use 101
So yeah, then you forgot to cancel the event
🤔
return only "stops" the method from running, but does not actually cancel the event
It does stop the code execution for the current iteration verano
Like within the method
NextInt
Ohh ok
awesome
and them return goes return?
wha?
Yeah, cancel and return
Allright
You need to do both depending on the case
return exits the method early, not to be mistaken for it cancelling anything. That means everything before the return will still run. Also the event is a different method that your method has been given access to. So returning exits your method early not the event itself if that makes sense.
They are probably not sober enough to realise this anyways
Ohhh ok
Thanks i didnt know that events works in diff way
Like does normal java methods
Yeah
or is there some fancier way to approach this
Though the && rand <= 100 is a bit pointless
tru
(Same as the rand <= 0 &&)
mhm
If you want the performance of a switch statement, just use an array with the size of 100 (though I'd trim it to 20 looking at the numbers)
Why he is nnot either using ">=" or "<="
That symbol he sent doesnt exists on java sintaxis
its an extension in the marketplace its not enabled by default
Many coding fonts use a special technique that combine two or more chars together
I forgot how that is called, but it has a name
for a ProjectileHitEvent
how do I check if a block or entity has been hit without spamming nulls
no
uh what ab the extension for the equal icons
really?
ligatures, that is what they are called
kk
No need lmao intellij its consuming your pc even more than normal
I know but when adding plugin its consumes more
Imagine i add github copilot and it consume a 5% more than without the plugin
what your pcs?
uh lemme find
That why exists the C++ version, but you have to pay it extra
Its like lmao i dont wanna play anymore
Destroy the competition with the Cyber PowerPC Gamer Xtreme VR series of gaming desktops. The Gamer Xtreme VR series features the latest generation of high performance Intel Core CPUs and DDR RAM to easily handle system intensive tasks, such as high definition video playback. Coupled with powerfu...
this one i believe
it surprisingly only has 8gb ram
I wouldn't play mc even on a C++ version these days
yikes
The joy of playing minecraft is simply ... gone
sometimes i use intellij to debug mc code if i can
unless i need to be in my test server
yeh i feel u
i tried playing some hypixel games yesterday
i felt... nothing :)
it's all just overly competitive
I really need to start understanding IJ's debugging toolset, hopefully they are better than eclipse's one
I am primarily a hardcore eclipse user
eclipse chad
Is it possible to setup global runs configuration for every proyect?
im not sure
Eclipse and recaf are the only two IDEs that I main
Its so annoying to link the spigot.jar and configure the params on all plugins projects
i just add the configs manually in each project
That what i dont like it
well i only have my server start jar app in the run config
and add a plugin in pom to compile my plugin directly to the plugins directory
and edit some shit for java to convert to kotlin
why a plugin?
What else are you going to compile?
Configure the output file like me (i add the name of jar, because its using shaded plugin to built)
<outputFile>C:\Users\Usuario\Desktop\Server\plugins\Claims.jar</outputFile>
how can i create a circle shaped region?
A cuboid region?
A circle right?
yeah a circle isn't cuboid ig
Oh i have taken a long time to figure cuboid regions
When working with cuboids regions, you take in care 2 corners "Esquina superior izquierda" and "Esquina inferior derecha" (i dont know how call it in English) which forms a square
Yeah
even if they are cuboids
Bounding box is for doing cuboids
also everything is cuboids in minecraft
Yeah
Will
What are you trying do?
i thought of making spheres in a cube game 😪
Generate a sphere of blocks?
no i'm making a shockwave
like a nuclear bomb shockwave
i dont know the meaning sorry im spanish speaker
But yeah i understand
onda de choque if google is right
You want to break a circle of blocks around a centered block
kind of
yeah i catch it
ty anyways
Im doing that, but instead of breaking im protecting and its a square based a centered block (the protection block)
kind of like WorldGuard
Yes
But without world edit and world guard
I wish be able to use world guard without world edit :(
😦
@ivory sleet how would i do a circle based on a cuboid class?
Sorry for ping, dont ban me!
You would need to have multiple cuboids depending on the resolution
To be honest, I'd rather not use a cuboid class at all
instead?
Using distSq or the manhattan distance
For doing what?
would this code get the corners?
I.e. having something like
int centerX;
int centerY;
int radius;
public boolean isWithin(int x, int y) {
int deltaX = centerX - x;
int deltaY = centerY - y;
return (deltaX * deltaX + deltaY * deltaY) <= radius * radius;
}
geol what do you think?
And for doing a cuboid based a radius?
Fancy maths, I cannot recall the name of the algorithm however
See the difference? If you think choosing between either one of the two is fine, then go with it - otherwise no
aren't spheres just circles rotated on the z axis?
what does this do exactly?
a lot of them
Apply pythagoras theorem
Come on, this is 9th grade maths
Perhaps even 8th grade
And if pythagoras is too complicated, use manhattan
(pythagoras also applies on a 3d space at which point it is a^3 + b^3 + c^3 = d^3)
I dont know why all here when something is diff they indirectly telling dont do it
actually no - it's a^2 + b^2 + c^2 = d^2 I think
Whatever, you get the gist
pitagoras is:
high^2 = side^2 + side^2
Marching squares was the name (or marching cubes for 3D)
geol
Yeah, but spheres becomes only a little bit more complicated, though I think really it is the same thing
geol how old are you?
You know a lot
I ask because im just doing on math "teoria de conjuntos" on math
And its really tired, becaue it takes more time to copy the act than doing it
Can I check if a player is going in the nether in a specific world even if the nether hasn't generated yet?
How would check it if the world is null?
If a string is “” is it null?
Hmn?
there might be an event fired for portal enter
yeah i think ?jd-s
bot is weird today
?jd-s Events
PlayerPortalEvent is a thing
Google says “” is null
I don't know if I can differentiate nether and end
because "" is threated as nothing
Only 17 heh
any text within "" will be threated as a literal from the google search engine
is there away i can tell if a string is an integer in string form?
Ah that why
int number = Integer.parseInt("20");
try {
int num = Integeer.parseInt(string);
// yes
} catch(Exception e) {
// No
// i forgot the exact exception lol
}
ok
Doesnt need to try catch
It will throw exception without catching it too
you want to catch it
to determine if its a number or not
you don't want a random crash
In my case when i dont want to catch it i just return if not nubmer
NumberFormatException
thought so
public boolean isNumber(String string){
Try( pass)
Catch (Exception)
Return false
}
Sorry for bad format
ye
I’m on cellphone
just return;
return true or false, is when its a boolean
we know that
Yes I know I meant public Boolean
that's why he made it return a boolean
Dont use the upper one, its better to use the camel case
The fact that I know of these algorithms is because I wanted to create stellaris-style map rendering for a game I Mod - so really it is Just a coincidence here
I meant that, I’m on telephone so I get random caps sometimes
iPhone text bad
Don’t worry
i have fixed the break block event on my claim plugin, but i cannot fix my block place
It really hurt my heart
Can you please tell me if I can get velocity using from, to in PlayerMoveEvent? Just getting the velocity is not an option, because when we get it here, it's always 0;
I dont know what are you doing
Why also you need to know the velocity?
And also which is the code you test it
Look. I want to create a plugin for dodge. When a player squats twice, I need to use velocity to throw him in the direction in which he goes
?codeblock
You can use the discord code block format to display code or just text in a more pleasing way:
```java
public class MyPlugin extends JavaPlugin {
@Override
public void onEnable() {
}
}```
Becomes:
public class MyPlugin extends JavaPlugin {
@Override
public void onEnable() {
}
}```
private int number_of_squats = 0;
@EventHandler
public void PlayerToggleSneakEvent(PlayerToggleSneakEvent e){
if(e.isSneaking()){
number_of_squats += 1;
Bukkit.getScheduler().scheduleSyncDelayedTask(ParkourV1.instance, () -> {
number_of_squats = 0;
},10);
}
}
@EventHandler
public void OnPlayerMove(PlayerMoveEvent e){
if(number_of_squats==2){
number_of_squats=0;
Player player = e.getPlayer();
Vector vector = player.getVelocity().multiply(2);
player.setVelocity(vector);
}
}
The problem is that the PlayerMoveEvent fires before the player gets the velocity.
A delay wouldnt actually work?
why is number_of_squats global to all players
Delay works fine
Also those naming conventions
Thanks, I know that. This code is a test case. I will change this variable. But first I want to understand how to throw the player in the direction of movement.
Agree
oh and you could just move:
if(number_of_squats==2){
number_of_squats=0;
Player player = e.getPlayer();
Vector vector = player.getVelocity().multiply(2);
player.setVelocity(vector);
}
to the sneak event
Agree
I was about to say that too
Because why doing it in PlayerMoveEvent if you dont use it
And also doing it in that event will cause memory leaking on the server
Not really
I try, but it's not work
Also another dude
Let say i have this code:
public void onPlace(BlockPlaceEvent event) {
Block block = event.getBlockPlaced();
Claim claim = this.plugin.getClaims().getClaimAt(block.getLocation());
if (claim == null) {
bla bla
}
if (event.getItemInHand().isSimilar(this.plugin.getItem())) {
return;
}
event.setCancelled(true);
}
In the case the item is similar, will endup calling the event right?
Thanks and sorry for noob questions
Calling what event
You mean cancel?
cancelling
Sometimes i right too fast that i dont right what i think
Hmn
Okay?=
Im like a 🤡 know
I dont know if java its weird or intellij
Its telling me that something can be null when im checking up if (object == null) return;
guys u know that cooldown animation which plays when u have used an item like the white overlay which slowly moves down the item? is it possible to trigger that for any item with spigot?
You probably did something wrong
Show your code
ok
You can trigger it for any material, yes.
https://hub.spigotmc.org/javadocs/spigot/org/bukkit/entity/HumanEntity.html#setCooldown(org.bukkit.Material,int)
declaration: package: org.bukkit.entity, interface: HumanEntity
And thanks olivo
WOW thank you
Keep in mind that it only takes Materials so if you have multiple itemstacks of the same material, they will all get the cooldown.
As long as you store the instance of it somewhere, you can reopen it at anytime. All items should still be in the inventory if no changes have been made elsewhere.
I personally keep a method like:
Menu menu = new MenuHandler().newMenu(name, rows).build();
Where builds set the items into the inv, and them i just have an update method
Where i can call it on a runnable or when i need it
getOwner could be null. You can use Objects.equals for a null safe alternative
yeah, if you reuse the same one multiple times it can cause issues
how expensive is it to create an inventory?
why?
I dont find the cause
i mean computing wise
Fuck, 3 days of agony and I created a damn plugin
Why couldnt be null?
Hover over and it will tell you
Thanks to everyone who helped guys
Use
Objects.equals(current.getOwner(), player.getUniqueId())
But why
If its impossible to be null
Then mark your method as always not null or ignore the warning
Im already checking
if (code == null) {
running code here if null
}
So here its suppoused not to be null nothing
So java its clown today
It's because you have code == null && <-- and something
Hmn?
If second condition is false it will skip the return and continue
No return
Add return in your null check
I missed a bit of that too at first so no worries
?
The return keyword has two major uses.
- Exit the method immediately. Any code beneath it will not run.
- It "returns" the value of the method so long as the method is not void.
Guard clauses are a great example of how they work.
int value = -1;
// This is a void method so no value will be returned.
// However, this method could do something like set a value.
// In this case, it will set a value if all of the checks pass.
public void myMethod(boolean isValid) {
if (!isValid) { // This is the guard clause.
return; // We return here because the condition isn't met. The return keyword breaks the method right here.
}
this.value = 1;
}
Because im checking if player is owner and return, but the code still running for some reason
Im on an event
public void onPlace(BlockPlaceEvent event) {
Player player = event.getPlayer();
Block block = event.getBlock();
Claim claim = this.plugin.getClaims().getClaimAt(block.getLocation());
if (claim == null) {
// creation code
return;
}
if (claim.getOwner().equals(player.getUniqueId())) return;
if (!claim.getFlags().contains(Flag.Build)) {
event.setCancelled(true);
return;
}
}
I dont know why the heck is no stopping the execution
Im really annoyed
Well if code is continuing to be executed, it means that your checks aren't passing.
Hmn
I have debug and the owner uuid of claim equals player uuid
And i did sout(claim.getOwner().equals(player.getUniqueId())) and shown true
That my reason of being annoyed
Lmfao this is definitly trolling
Don't set cancelled to false
That can mess with other plugins
Yeah a lot of trolls all the time 
here
guys i have an inventoryclickevent listener and i'm doing setcancelled(true) on it but players can still spam click and put an item in the inventory
how to fix
Listen to the InventoryDragEvent as well.
:v
If you spam click, it can be considered an InventoryDrag
thank you shadow master g 23
Sorry for ping, but what do u think about my code?
Well are you doing anything after those checks? Cause it looks fine and the result seems to be expected. At least to me.
He?
Its wrong the result
It should allow me to breaks blocks being owner
Could try to put the event handler method at monitor in terms of prioritization
But for some reason the code cotninues executing
in case some other event handler method is overriding whatever you’re doing
Okay, i dont know what does monitor
It makes sure your event handler method runs lastly
It fires last in the execution order.
It shouldnt be the reaon, because there is no other plugin
But i will try it
Mye
Oh also
Im really dumb
I have find the solution
The Flag should be apply to claim members
Perhaps you were the troll /s
So check if its a member and apply the flag
No
I just realized
🥰
I love you my boy
