#help-development
1 messages · Page 1484 of 1
Yep, no getLocation in 1.12
is there a way to tell gradle where to put the output file?
you're going to have to read the world, x, y, z, yaw, and pitch
like what you do with artifacts
should I use artifacts in gradle projects?
i am. The arenaConfig thing is my issue
Its not showign up in random 1.12 javadocs I googled
Yeah
Wow it didn't. Late 2019. I'll be damned https://hub.spigotmc.org/stash/projects/SPIGOT/repos/bukkit/commits/a439ce02dc649961ce23012301141a139e9d373d
this is why you dont use outdated versions
It's serializable at least so you can set(Location) and get() and cast to Location
Can I just mention that the location part can't be the issue? I have the same issue with not being able to use arenaConfig in like every class
uhh where do i put it
project.buildDir = '/gen/main/java'
build.gradle?
i think
I use libsDirName
ok use Location loc = Location.deserialize(arenaConfig.getConfig().get("lobbyLocation).getValues(true));
where is /gen/main/java tho
change it
gradle is confusing
it has a steep curve for beginners
it really isnt
so change it to
what you want it to be?
C:/blah/blah
once you understand, its not that bad
maven is arguably as confusing
@eternal oxide
nah its actaully satistically harder due to its features
and idk how to explain it but if you are using something like kotlin dsl
onBlockBreak where i use this.arenaManager.setChestLocation(event.getPlayer(), event.getBlock().getLocation());
um, do you mean you are not sure its even loaded. I thought you said earlier you could access it
there is very little support
in my downlaods
well if you understand kotlin then its as trivial as the groovy dsl
it all worked before when I used static on it all but yeah
do you know what static does?
I know but Im not trynna static abuse like I did
ok lets test, in your PlayerJoinListener add some debug lines before your int x = arenaConfig java if (arenaConfig == null) System.out.println("arena is null"); if (arenaConfig.getConfig() == null) System.out.println("config is null");
I do notice you are using getInt on your config when its stored as a Double
Its probably going to be unhappy about that
is this where I say that it doesnt print any of those
use the Location.deserialize and it will deal with all that
good
now try adding the deserialize line I gave you and see if that errors
I'm going to guess after fixing all that code its the getInt
just replace all that code with the deserialize then
Why wouldnt this one work for my other event class?? this.arenaManager.setChestLocation(event.getPlayer(), event.getBlock().getLocation());
same situation there
what is setChestLocation ?
https://paste.md-5.net/kujerigoki.cpp Everything is basically the same and worked other than I switched it up to use the constructor and not static
other than not using static, the thing is the same and worked then
does it throw an error somewhere?
and line 26 is this.arenaManager.setChestLocation(event.getPlayer(), event.getBlock().getLocation());
does it still error in the same place after all teh changes I told you to make?
umm does anyone have any idea on how to stop entity collision when an entity is constantly being teleported to another
Copied the error from console right now with the changes you told me to make yes
show me your ArenaManager class
sec
actually show me your listener class with the BlockBreak event in it
Where do you register that listener? its not in yrou main class
its in the same place
pm.registerEvents(new BlockBreak(this, this.arenaManager), this);
same place as this one pm.registerEvents(new PlayerJoinListener(this, this.arenaConfig), this);?
yes
omg using gradle is really annoying
i'd appreciate that
Sure what's the issue
no its a warning u can ignore probably
ok that error seems to make no sense.
oh some methods might be deprecated
?paste send ur entire build.gradle
I know. That's why I haven't been able to figure out why it doesnt work for days now
The only thing in there that could be null is the arenaManager
@digital plinth
oh sorry, I see the error
first and foremost you're missing a } at the end, second of all if you wanna set the destination use libsDirName probably
@Override
public void onEnable() {
this.saveDefaultConfig();
this.arenaConfig = new ArenaConfig();
StateManager.setState(StateManager.IN_LOBBY);
this.arenaManager = new ArenaManager(this.arenaConfig);
registerListeners();
}```
okie
oh that worked...
i don't think i missed a brackets XD
oh yeah but remove the one at line 45
It was just the ordering
thats the second time I've messaged up the ordering
it happens I guess
Thank you so much for helping me out here, I appreciate it
np
okie
updated it
but i don't see the jar in my downloads
use \\
okie i don't think it worked
I mean I can’t tell what folders exist and don’t for you
did u reload ur gradle project btw
when i build the project no more logs are created at the bottom section
i closed and reopened
can someone link me to a turotial on blocking the packets without protocallib
i just need to block an entity for a specific player
Why do you resend after I deleted it, this channel is for development help related stuff.
yes i need help for choosing the best song
Regardless, this isn't the channel for that
hello, i may look stupid but
for (Entity entity : player.getWorld().getNearbyEntities(player.getLocation().add(player.getLocation().getDirection().multiply(1.0)), 10.0, 10.0, 10.0))
i want to count the entites in this range
help pls
It's much easier with ProtocolLib
Why not use it?
u sure i posted random utube links before no one deleted it
a 10 block cube around the 1 block in front of the player?
player.getWorld().getNearbyEntities(player.getLocation().add(player.getLocation().getDirection().multiply(1.0)), 10.0, 10.0, 10.0).size()
Did you read the channel topic of this channel?
We got bosses now, so no more malarkey 🙂
10x10x10 cube
I just gave you the code to know how many
it will be size or length, I forget what Collection is returned
its said error
only array
error?
yep
I did say it would be either size or length
hmm
does spigot support making an entity invisible for one specific player?
yeah
I think it has something like that in the api
for real?
hmm or might just be player entities
see the pic
yes
link?
its not a for loop, its an int
woah i was trying to use packets
link pls i don't see it anywhere
i think idk
actually u still need to use packets i think
i believe the api only does hiding and showing players for one player
and i dont think it does entitys
The easiest way to do it with an entity is to just send a PacketPlayOutDestroyEntity
I think that’s the name anyway
i saw this lol https://www.spigotmc.org/threads/hiding-an-entity.81669/
oh
so how do i send a packet?
i think u have to use nms
Google it
rip
for( Player on : Bukkit.getServer().getOnlinePlayers()) {
PacketPlayOutEntityDestroy packet = new PacketPlayOutEntityDestroy(skeleton.getEntityId());
((CraftPlayer) on).getHandle().playerConnection.sendPacket(packet);
}```?
public void hideEntityForPlayer(Player player, LivingEntity entity) {
PacketPlayOutEntityDestroy packet = new PacketPlayOutEntityDestroy(entity.getEntityId());
((CraftPlayer) player).getHandle().playerConnection.sendPacket(packet);
}
public void showEntityForPlayer(Player player, LivingEntity entity) {
PacketPlayOutSpawnEntityLiving packet = new PacketPlayOutSpawnEntityLiving(entity.getEntityId());
((CraftPlayer) player).getHandle().playerConnection.sendPacket(packet);
}``` lmao idk if this would work
never messed with packets
thanks
what if I want to hide a player from other players
what do i change the enrirt.getentityID to
u would have a player.hidePlayer(anotherPlayer);
player.something i suppose
ohh
player.showPlayer(anotherPlayer);
it has to be player objects
thats the instanceof Player
it cant be LivingEntity or whatever
or commandsender
it has to be a Player
okie
player.getWorld().createExplosion(player.getLocation(),7)
Guyssss fjafjsjtghskehtg what is the resolution for minecraft server icons???
256x256
i think
are you kidding me
i exploded the entire world
i want the particles
lol
ty
oh your talking about firework explosions?
its a still picture
its a PNG
eclipse says i need a newer java version to run, but when i use new java, the server says i need old java
https://hypixel.net/attachments/hyp-gif.2540850/
oh a particle effect
ugh packets again
i just lost ALL of brain cells from messing with packets
any solutions
i think you can scale it when you spawn the particle
now my turn
so you launch a wither skull when you right clcik
on air OR on a block
but when i teste it
it spawns TWO skulls when i click on a block
and don't spawn any when i right clcik air
Y
I'm trying to explain to my friend why he should compare player's via UUID instead of doing direct player .equals() comparison but i'm explaining it poorly. What is the reason behind doing UUID comparisons instead of player comparisons
UUId never change
player name changes
oh no i think my post is gonna get flooded
That doesn’t matter
The player objects name will never change
But comparing uuid is likely faster
Interact event fires for both hands
And iirc doesn’t fire at all for right clicking air with an empty hand
wait what
then what is the Action RIGHT_CLICK_AIR for
like when you raise a shield you right click air correct?
bruh why is there not a right click entity event
anyways, is there anyway to increase EXPLOSION_LARGE particles size?
PlayerInteractEntityEvent
ohh okie
Right clicking with air while holding an item
......
sdbvcjnsafa
what if i just need to do something when i right click with nothing
on air
Don’t think the client sends a packet for that anymore
i have like no idea
RIPPP
well you can hold a shield up with nothin in your main hand
lol
any1 have any idea to modify EXPLOSION_LARGE size
OMG
when a player is hidden
even the plugin can't reach it?
also how am i supposed to cancel a runnable like that
how 2 find the task ID
you close it with task id right?
Or the task reference
so lets say you have 3 players
player 1
player 2
player 3
now you have a plugin that when you run a command it will save your current location(location1), and when you run the same command it will storage the second location(location2) in a hashmap, so you can have as many locations as you want, so now it looks like this
hashmaplocation1:location2
and if you run the same command again it will storage your current location (location3) so you can run the command again and save the second location (location4)
hashmap<[location1:location2],[location3:location4]>
perfect now you have a hashmap with 2 sets of locations, this was all made by Player 1, but lets say you have another player, Player 2 in the same server, same world, same everything, and if Player 2 runs the exact same set of commands, does this create another hashmap for Player 2 or storages this new locations set by Player 2 in the same hashmap as player1?
My main question is: Does each player has his own version of each plugin in the server or do they all share the same plugins and data?
hmm is there a way to make plugins access hidden players
you mean vanished?
They all share the same plugin
yes .hideplayer
when i try to get a reference of a hiddenplayer
it says its null
which do not make sense
Use a custom class to store everything and add that to a map with the players uuid
BukkitTask.cancel
cancel from within?
You can do that too
wait how does it know which task im canceling
Because it’s an instance method
Look at the return type for the various run task methods
i dont understand how the server works, and how each player work with the active plugins, is there something i can read or google? i cant find anything
uhh like this?
i created a seperate task for like each player
wait hold on
does that mean
Plugins have no relation to the player, it’s all on the server
i have no way of canceling the tasks bc i can't give the task a new name everytime
and i won't be able to differentiate them
For example, a BlockPlacedEvent will fire for any online player, it’s bound to the server, not any specific player
Store them in a list
Or a map or whatever
yea but how can a server provide the same information to all players? how can you storage information for each player
Use a map with their uuid as a key
so taking the same example of the commands and locations i did before
it would be
hashmap<[KEY= PlayerUUID: [location1, location2]]>
so its a list with the player uuid as key
?
so i have a hashmap for each player with the active information
instead of rquesting it from the config file
no yea
sorry
like
a hashmap for each player means a peace of the hashmap with the player uuid for each player in my head
lmao
as the key*
OMG why can the plugin get a reference of a hidden player
the plugin is server sided
You sure you’re doing it right
I’ve never tried, but it doesn’t sound like it should be an issue
yea the server should know the existence of hidden players
take 5 minutes to drink water and once you come back you will most likely see the error right away
i just saw it
nice
indeed
that is how half of my erros are found
haha
Rubber duck debugging
int Count = player.getWorld().getNearbyEntities(player.getLocation().add(player.getLocation().getDirection().multiply(1.0)), 10.0, 10.0, 10.0).size();
i want to select entities but except items, player and armor stands
any help?
im ded inside
I believe you can use a predicate with that method
Or you could use a good old for loop with an if statement
example please
Loop over the collection, if it matches what you want add 1 to a number
how could i have a hashmap like this:
HashMap<UUID, List<Integer>> list = new HashMap<UUID,List<Integer>>();
that everytime you run a command adds a number to the list in the player uuid key, where the value is the next digit in the list for example if the list is [1,2] add 3 to that list so the hashmap is
<playerUUID, [1,2,3]>
or just add a string
the args 0 of the command
so like
<playerUUID, ["string0", "string 1"] etc
So you mean
You'd run a command like /thing add String
And it would add it to the list?
yes to the list inside the hashmap
Ok cool
That's very easy
First, initialize the map
Map<UUID, List<String>> map = new HashMap<>();```
You probably want to keep this as a member field
Then to add to it in a command:
Player player; //Assume this is populated with the command sender
String toAdd; //Assume this is populated with the string to add
map.computeIfAbsent(player.getUniqueId(), k -> new ArrayList<>()).add(toAdd);```
oh wow, whats the ->
It's a lambda
You know, that might be a bit complex if you don't understand what lambdas are
Here's an equivalent
lumbda
yea i saw it a few times with scheduelers, its on my todo list
List<String> list = map.get(player.getUniqueId());
if (list == null) {
list = new ArrayList<>();
map.put(player.getUniqueId(), list);
}
list.add(toAdd);```
This does the same thing
But the one-liner is much more elegant
computeIfAbsent takes a key and a lambda to generate a value if there isn't one present, and returns the existing or computed value
Which you can then call add on to add the string
Very handy
A lambda is essentially just a function that can be passed around
That's the easiest way to think of it
but this will add the value if key is absent right?
k -> new ArrayList<>() is a lambda which takes one parameter, k, and returns a new ArrayList
Yes
It will create a new list if one doesn't already exist
Under the hood, a lambda is shorthand for the anonymous class definition of a functional interface
In this case the functional interface is Function<K, V>
A functional interface is just an interface which only has one (abstract) method
In the case of Function it's public V apply(K)
So k -> new ArrayList<>() is equivalent to:
new Function<String, List<String>>() {
public List<String> apply(String key) {
return new ArrayList<>();
}
}```
It's just much much shorter to express the same thing with a lambda
Which of course is why lambdas exist
Does that make sense?
okay thats a lot of information 1 second
ok so i got that computeIfAbsent will add the Value if Key is null, where key is the player uuid, and value is
k where k = Key and Key is a new list generated with lamba wich is represented using ->, where -> is a shortcut to the functino that returns the arralist, so you define the arraylist cuz V is null, and then you add the value wich is a String arg0
now what im gonna try to do is computeIfAbsent, if its null, else get the arraylist and add the value, where K is player uuid
???
fk hell this is starting to hurt somewhere in my brain
computeIfAbsent returns the existing value if there is one
Otherwise it uses the function you pass to create a value, inserts that value at the given key, and returns it
yea wich means the K is null
its the if else you made
in a single line
right?
this one
This is what I don't get
You don't need any if/else with computeIfAbsent
If it makes it easier you can do it like this
yes but what im trying to do is have a hashmap where K is the uuid, and theres a list of all the args0, not adding it if its null
So you don't want to add a value if it's null
cuz once you run this command it will create the key, and once the key is no longer null it wont add the new args0 when you run the command again
i want to always add it
if its null or not
like this
Then what do you mean "not adding if its null"
Ok so if there is no mapping at all for the player already
Do you want it to create a new list and add the arg as the first element?
yea my problem was getting the list, adding the value and changing the V of the player K
but i think that with the help you gave me i got it
So there's no if required and you don't need to handle null
computeIfAbsent will put the list in if it was null previously, then return it
So you just call add on that list and you're good to go
I'm having some trouble with research, how do I add a Click Event or Hover Event in a custom book?
rather new so if u know how u might need to dumb it down a little
thank you @waxen plinth it worked like a charm
👍
How can I find what kind of portal an entity went through? The PlayerPortalEvent has a TeleportCause that serves this purpose, but the EntityPortalEvent seems to lack a way to figure this out. I tried testing the block the entity was in, but it appears the entity can teleport without being in the portal block depending on the speed of its movement.
I'd like to find the actual block of portal the entity entered anyway.
I'm trying to modify what happens with portals, to allow players to make portals to specific locations. The portals are going to be specified by in world differences, so I need to be able to find the portal they entered in order to check for that.
It looks like the player has to be within 0.3 blocks of the block that is actually the portal in order to contact the portal, so I can check the block locations at ±0.3 in x and z to find the portal.
yes, the issue is the block the player is standing in isn't the portal block, but sometimes the one next to it
I think that gives the players start location.
should probably check to be sure though
If he isn't standing on the portal block exactly you can always do extra functions to locate the portal
The from block does appear to be the same place as the player (and thus not the portal) so I guess I'll just check the blocks slightly offset, that seems to be working
interesting, I didn't see that event
But yeah
this only triggers when entity walks in it
not teleporting yet
I guess you could cache the block from here
yes
The player should only be able to teleport using a portal they have already touched, so I'm guessing that would always fire first with the correct portal block for the player. (thus ensuring the cache is always correct)
Also if you're planning on linking portals
you could also look into the portal creation event
In my case I'm just going to cancel the event, I don't want there to be a reverse portal.
I'm trying to implement something like the dislocators from the mod draconic evolution with a plugin
yeah
Ohhh wither
What its better? ExploitFixer or SpigotGuard?
You need to create a custom wither extending from the EntityWither NMS class and the setup a scheduler to constantly set the head's target entityId to 0
?
I didn't realize you were talking about withers ;p
Here's the way to do it
Is there a way to give an entity a specific texture based on it's name?
I wanna combine it with my plugin
Nope, Textures are controlled on the client's side. Servers cant do that
Can resource packs?
(Also I asked this here because I know plugins can request clients to load resource packs)
I think yes
is there a way to detect right clicks of entities when extending EntityPlayer?
overriding a(EntityHuman) only is fired when a player left clicks the entity,
protected boolean damageEntity0(final DamageSource damagesource, float f) {} doesn't provide a way to see which entityhuman damaged my entity
would i need to use protocol lib to detect the ENTITY_USE packet or is there another way i can do it without having to depend on protocollib?
There is model data that you can use
And then force a resource pack on the client so that they see the custom models
I am placing a lot of blocks and I did it like this:
startBlock.getLocation().add(5, 1, 1).getBlock().setType(Material.GRASS_BLOCK);
startBlock.getLocation().add(6, 1, 1).getBlock().setType(Material.GRASS_BLOCK);
startBlock.getLocation().add(4, 1, 2).getBlock().setType(Material.GRASS_BLOCK);
startBlock.getLocation().add(5, 1, 2).getBlock().setType(Material.GRASS_BLOCK);
startBlock.getLocation().add(6, 1, 2).getBlock().setType(Material.GRASS_BLOCK);
startBlock.getLocation().add(3, 1, 3).getBlock().setType(Material.GRASS_BLOCK);
startBlock.getLocation().add(4, 1, 3).getBlock().setType(Material.GRASS_BLOCK);
startBlock.getLocation().add(5, 1, 3).getBlock().setType(Material.GRASS_BLOCK);
startBlock.getLocation().add(2, 1, 4).getBlock().setType(Material.GRASS_BLOCK);
startBlock.getLocation().add(3, 1, 4).getBlock().setType(Material.GRASS_BLOCK);
startBlock.getLocation().add(4, 1, 4).getBlock().setType(Material.GRASS_BLOCK);
startBlock.getLocation().add(1, 1, 5).getBlock().setType(Material.GRASS_BLOCK);
But need to check if the block I am gonna replace is Air so I wont destroy anything. But is there an easier way than doing an if Statement around every block I am placing? I am placing a lot more than only them above....
google "java for loops"
how can i add 1.8 support to a 1.12.2 plugin?
i want the 1.12.2 plugin has 1.11, 1.10, 1.9 and 1.8
i've see a plugin that starts from 1.12 and has 1.8 support
You code against the 1.8 spigot API
The plugin should then work against the mentioned versions
Obviously will break if nms is involved
Never use java.awt
ok
i need to recode in 1.8 or use NMS?
Use the ChatColor api
is it just §0
Yes
frick
I even wrote my own color enum ;-;
also can I make Intellij show colored squares for custom classes
yeah I know what a for loop is but I dont know how to apply it here
create a list of locations and then iterate over them
oh okay I will try it thank you
@eternal night i need to use NMS or recode on 1.8 the plugin?
Hey, is it possible to set hex scoreboard team colors?
read what he said
U have been asking this a lot lol
i never know because all of you give an answer, 1 says maven, other nms
what is the right
we've given you the answer
maven and nms aren't mutually exclusive
and if you read what was said you'll understand, or you would if you had past-kindergarten levels of english comprehension, what you need to do
it was spelled out very simply and verbosely for you
ok
Spigot is backwards compatible for the most part
So if you use spigot only there is a high likelihood that it will work on older versions anyways.
However, if you use nms, it will not work on any other versions unless you use reflection or something
If I have two locations how can I calculate the circumference of the rectangle
assuming it is an axis-aligned rectangle, calculate its shape and then calculate the circumference
if it's not axis-aligned, two points isn't enough to identify it
So I would like to have all locations as scope
https://prnt.sc/14ceea3 The two red dots are given and the green one I want to have allos minecraft locations. But it can also be three-dimensional.
should I have an enum for NamespacedKey's?
Uh
if that's even possible
Yeah it is
but should I do it
I mean speaking of how NamespacedKey is instantiated you do need a plugin instance right?
that's what I was talking about
how do I get main to the enum
hence me saying if that's even possible
Of course you could use something like
PluginMain.getInstance() or JavaPlugin.getPlugin(PluginMain.class)
Now we know that I CAN do it, SHOULD I though?
ok, it works the same if i use spigot and paper support?
it's that like a good thing to do?
i start by paper and i add spigot support
lau_sam it’s probably fine here since we’re not writing enterprise java code here
But enums can be very limited and needless to say static can also
so when codes get big, it would ideally have enums for it
but for the scale we're doing at it doesn't matter?
Yeah it really doesn’t matter for a spigot plugin I think
But this isn’t always the case
but that makes your code look fancy amiright
Yeah
Uh if you want your code to be fancy use a lot of generics and enterprise your project lol
generics as in
ok i'm knowing, i'm getting info also from spigotmc.org
but for the sake of not needing to add a NamespacedKey in the constructor of everything Imm just make an enum for it
Yeah I mean some people overuse that. While I could see a point in doing so for the purpose of learning you probably want to avoid any over engineering or overuse of a single tool.
nice
Yeah lau it might be beneficial to do it here so that you can decouple your namespaces from whatever class you had them in before
Lol
So I should just pass the namespacekey all around?
the choice is either have a NamespacedKey in every constructor(that needs it ofc) or have an enum right
interface Namespaces {
NamespacedKey SOME_KEY = create("test");
NamespacedKey create(String key) {
return new NamespacedKey(JavaPlugin.getPlugin(PluginMain.class,key);
}
}```
That might be enough (using an interface to cut down verbosity)
Because with an enum you’d need to expose a getter or a field to obtain the namespacedkey
https://www.spigotmc.org/wiki/creating-a-gui-inventory/ have you red this?
The home of Spigot a high performance, no lag customized CraftBukkit Minecraft server API, and BungeeCord, the cloud server proxy.
Yes if it is a message
Have anyone any methods to how to get custom textured heads in menus ?
Hot swapping
How can I get a player by nickname? To then replace it with the setWhitelisted() method
Easiest way would be to get it with Bukkit.getPlayer("name");
hmmm it's telling me I need to make create default?
I never learned to use Interface so I have 0 idea how it works
hiyo my timer + scoreboard are kinda messed up https://paste.md-5.net/osipihazep.cs
im testing with my alt account and the timer is moving down 2 seconds every second and then it randomly spams the end screen code bit
Oh declare it static
How fast the time is decrementing seems to depend on the player count in that world
that's because you're iterating over all players in the same runnable
and subtracting timeleft with each iteration
@keen kelp now let’s say you wanna use the namespace SOME_KEY, then for instance you might have this:
class ListenerBlah implements Listener {
@EventHandler public void onBlah(InventoryClickEvent e) {
e.getInventory().getItem(0).getItemMeta().getPersistentDataContainer().get(Namespaces.SOME_KEY,PersistentDataType.STRING);
}
}``` or smtng
o
doesn't work :/
lemme look into it
bruh
rip
@ivory sleet outta curiosity, why does it have to be an interface
I dont know how it works but wouldn't a class work just fine
how do you consistently get the player's crafting inventory (those 4 slots)?
p.getinventory.getitem()?
Skip it but basically it’s roughly equivalent to
class Namespaces {
public static final NamespacedKey SOME_KEY = create("test");
static NamespacedKey create(String key) {
return new NamespacedKey(JavaPlugin.getPlugin(PluginMain.class),key);
}
}```
I see
no
ok thanks
or I mean its not like a transitive dependency if thats what you mean
yeyey
also isn't it an annotation processor?
i get ya
or smtng
yeah well I believe bungeecord has it
what slots are the crafting slots?
is there a way to change the player event speed and mobspeed
@ivory sleet so emm I can't use it for some reason, any ideas?
It's just nor prompted at all
Did u declare the class to be public
public interface Namespaces?
Oh yeah how’s the code for Namespaces looking
what modifier is it by default
public
I really don’t know as of now, mind sharing some code?
I made it public and it's fine now :/
so apparently it's not public by default
public interface Namespaces {
NamespacedKey Accessory = create("Accessory");
static NamespacedKey create(String Key)
{
return new NamespacedKey(JavaPlugin.getPlugin(Main.class), Key);
}
}
Oh yeah
and I can just use it with Namespaces.Accessory
my code is getting super verbose so I def needed this
Yeah but have it all caps since it’s a constant
Ye (:
Does BlockBreakEvent#setDropItems(false) prevent experience from being dropped, and if so how would you recommend getting around this if I want experience to still be dropped.
is there a like thong for naming conventions
yeah
https://google.github.io/styleguide/javaguide.html here is google's style guide for java
they're not going to waste time making a pretty style guide xd
well
I mean
google already have a style going right
you know, some people know it as google.com
It can't be that hard to use anything more than purple text XD
I follow google style loosely
how loose
Some of their style conventions are pretty counter intuitive
Yeah but try have some sort of style or at least consistency needless to say you should still adhere the standard java naming conventions
also if you use Intellij(which I suppose you do), do you know anything about colored squares
Colored squares?
dis
picture from minikloon's tweet
in which we know it's an enum, 99% sure it's intellij and 100% java
Pretty sure intellij shows them next to java colour objects
Oh no clue actually I know those show up sometimes when the line involves color as lynx said
are you sure there isn't a colour object in the enum constructor call ?
they show up when Color is used
but is it possible to have it show up for my own class is the question
pretty sure
we dont get much info about this
it seems to be new Buildblabla
so I suppose prolly not?
there might just be a new Color(23,422,145) in that line
There might be a configuration or plugin which may add that feature
Like on top of IntelliJ then that is
yeah Im thinking of that but google isn't budging
Is there an event for when a player damages a mob, i saw a event for right clicking a mob but not leftclicking
EntityDamageEntityEvent?
Yeah EntityDamageByEntityEvent
Oh -_- ok me being stupid
then if(!event.getdamager instanceof Player) return bla bla bla
Yeah cheers
:)
Wait was it in the entity event tab
pretty sure yes
Ah i was looking in player events
btw just to give you a heads up on how that screenshot might have been created
oh :/
ComplexWrapper 
so I can't make my enums have color
is this the thing you were talking about to make your code look fancy
the point of these colour codes is that you can easily modify the colours through the interface
not some weird colour coding for enum constants
I mean it would be cool to just be able to change a message's color from a GUI amiright
there is ChatColor support using the minecraft development plugin
like if the text was black and I dont like it, instead of typing, just click click click
how
plz send
what
how does one do this
I
yes
I just found it like 10sec ago
👀
I thought it's only for creating new projects
iirc this team also have an addon for VSC
don't care much for VSC ¯_(ツ)_/¯
i used to use it
still do for datapack
just dont make datapacks anymore
but regardless this is very poggers
I mean, if you code any somewhat used plugin you will have to externalise your language configuration anyway
this is a lifesaver
at which point this feature becomes useless
lol
like im so glad i found it before i started deep development
unlike me :/
ouch
sucks to suck man
java.lang.NoSuchMethodException: Constructor ('[class java.lang.Integer, class java.lang.Integer]') not found! ???
public static Reflection newInstance(Class<?> clazz, Object... parameters)
{
Class<?> superClass = clazz;
Class<?>[] parameterTypes = new Class[parameters.length];
for(int i = 0; i < parameters.length; i++)
parameterTypes[i] = parameters[i].getClass();
while(superClass != null)
{
try
{
Constructor<?> constructor = superClass.getDeclaredConstructor(parameterTypes);
constructor.setAccessible(true);
return new Reflection(constructor.newInstance(parameters));
}
catch(NoSuchMethodException e)
{
superClass = superClass.getSuperclass();
}
catch(InvocationTargetException | IllegalAccessException | InstantiationException e)
{
e.printStackTrace();
}
}
try
{
throw new NoSuchMethodException("Constructor ('" + Arrays.toString(parameterTypes) + "') not found!");
}
catch(NoSuchMethodException e)
{
e.printStackTrace();
return null;
}
}```
Integer and int are different classes
Hello! Is there easy way to change string for example "COD" to "Cod" or "DIAMOND" to "Diamond"?
and the object array you are using to pass the parameters can only store Integer
as ints are native/primitive
Oh...
And in reverse, if the constructor is (Integer, Integer) and I try to parse an int, does it work?
no
Use string to make them all lower cased then just capitalize the first letter?
completely different classes
Ok but how can I see then if I need Integer or int?
Same with Byte or byte and Short or short also?
yes
Just cast it?
they are completely different
you will need to specify what type you want to use I am afraid
Can't I add a boolean for "primitive" ?
or try every possible combination of object and primitive type
huh ?
You are only passing in a parameter object array tho
Imma head out this convo is getting confuuusing
either you interpret every Integer as an int
which would mess up constructors that take Integer
Can't I just try and catch?
it would always fail
yes but then you'd have to try every combination of Integer or int
to make sure you actually find the right constructor
Yes that is too much
Hm ok, no other things to try?
none that I know of
Ok
If I want a variable to not exist beyond a point, is there a better way better than if(true)
use scopes @keen kelp
{
int x = 5;
obj.anotherFunc(x); // works fine
}
obj.anotherFunc(x); //error, x does not exist.
Newbie at bukkit/spigot API (and java in general TBH)
This looks like it's horrible code, What's a better way of dealing with items with durability?
Inventory inv = ply.getInventory();
for (int size = 0; size<inv.getSize(); size++) {
ItemStack item = inv.getItem(size);
if(item != null){
ItemMeta meta = item.getItemMeta();
if(meta instanceof Damageable){
Material type = item.getType();
int min = config.getInt("min_damage");
int max = config.getInt("max_damage");
int durabilityChop = type.getMaxDurability() / (int)Math.floor(Math.random()*(max-min+1)+min);;
((Damageable) meta).setDamage(((Damageable) meta).getDamage() + durabilityChop);
item.setItemMeta(meta);
if(type.getMaxDurability() - ((Damageable) meta).getDamage() < 0){
inv.setItem(size, new ItemStack(Material.AIR));
ply.getWorld().playSound(ply.getLocation(), Sound.ENTITY_ITEM_BREAK, 1, 0.8f);
}
}
}
}
I mean for one, for better readability you would be better of doing
ItemStack item = inv.getItem(size);
if (item == null) continue; // Skips the current iteration of the loop to the next one.
ah yeah, fair.
Juggling the ItemMeta and Damageable seems odd to me
other than that, maybe
if (meta instanceof Damageable) {
Damageable damageableMeta = (Damageable) meta;
// no need to cast damageableMeta anymore.
}
or if you're using Java 16 or newer:
if (meta instanceof Damageable damageableMeta) {
// no need to cast damageableMeta anymore.
}
are locations immutable? i.e. if I use add, does it modify the location or return a new location?
it mutates them
thanks
Yeah, just read the javadoc
https://hub.spigotmc.org/javadocs/bukkit/org/bukkit/Location.html#add(org.bukkit.Location)
yeah I somehow missed that xD
Ah i see, Thanks a lot!
Aight next thing, is there a way to test if bStats is working other than just waiting?
I mean I personally just create the Metrics instance and don't care about it afterwards. If there's any problems it'll throw an error. If it stays quiet it's in 99.99% of the cases running fine.
Hello, can anyone help me? I am trying to make pickaxe with my custom enchantment and i want to prevent players to add mending or unbreaking to that pickaxe (for not OP purposes)... How can I set that custom enchant, to conflicts with these enchantments?
You can just loop with Class.getDeclaredConstructors
Can anyone tell me why this code isnt spawning specific player's head
public PhysicalBox(Chicken chicken) {
Location skullLoc = chicken.getLocation();
World w = chicken.getWorld();
skull = new ItemStack(Material.PLAYER_HEAD);
meta = (SkullMeta) skull.getItemMeta();
meta.setOwningPlayer(Bukkit.getPlayer("Nuxoria"));
skull.setItemMeta(meta);
skullLoc.getBlock().setType(skull.getType());
}
this just spawns steve's head
is it because skull.getType?
and it just spawns the default head?
Are you trying to change a player head block using the ItemMeta?
yea
Tha wont work
Get the BlockState, cast it to a skull and change everything you want from here
yea but
i need to set the block type first
before getting the state
otherwise it returns air
Do it then
can i change how block looks when its arleady placed?
Looks?
Yes ^^
e.getView().getTopInventory()
getView*
declaration: package: org.bukkit.block, interface: Skull
Ok I was right the first time
skull block has setOwningPlayerMethod()
idk why but this code still spawns default steve's skull
public PhysicalBox(Chicken chicken) {
Location skullLoc = chicken.getLocation();
World w = chicken.getWorld();
skullLoc.getBlock().setType(Material.PLAYER_HEAD);
skull = (Skull) skullLoc.getBlock().getState();
skull.setOwningPlayer(Bukkit.getPlayer("Nuxoria"));
}
Update
So ill set the type again?
No, no from player.getInventory the player's inventory will never be the top one
whatsu meant by updating tho
i set the type again
at the top of the code
but it still spawns steve
i just added that:
No, BlockState#update method
help please
are you doing this inside a method?
Full code
Debug
Also drag is when you have an item on the cursor already
not click
Nope need to check click for that
or inventory swap
if(event.getAction() == InventoryAction.HOTBAR_MOVE_AND_READD || event.getAction() == InventoryAction.HOTBAR_SWAP || event.getAction() == InventoryAction.MOVE_TO_OTHER_INVENTORY) {
event.setCancelled(true); p.updateInventory();
}
``` in `InventoryClickEvent`
Is ChallengesMenu an inventory?
Why do you create a new inventory every time?
Just create a single one
Show me the updated code
Delay updating the inventory by a tick
And debug to make sure its running
is there a way for animals such as pigs, sheep, and cows run away from someone as if they hit them
You didn't cancel the event on that new code... just broadcasted a message
if (newInventory == ChallengesMenu) {
Bukkit.broadcastMessage("Challenge Menu");
}
My code only cancels for specific actions
Not clicking
Is it easier to listen for an event on all the priorities so you don't need to create 6 methods?
try using .equals instead of == in this case. on newInventory.equals(ChallengesMenu) Also... every time you type that command its creates a new inventory so if you're still viewing the old inventory instance this will always be false.
Correct its not initialized until you type the command.
That can work to.
Debug. something isn't equal to your object
Then people can just create inventories with that name
you should really get into the habit of using ChatColor instead of §c
ChatColor allows better compatability between versions
lol if anything that's more verbose
public String colorize(String s) {
return ChatColor.translateAlternateColorCodes('&', s);
}
// player.sendMessage(colorize("&6Hello!"))
Someone know how to summon potion particle at a location ?
Isn't there Player#spawnParticle or World#spawnParticle
yes it is but don't find the Particle.POTION_PARTICLE
i dont see how the particle matters; both of those methods have a parameter for location
what ? i need the particle name to summon it
I think the particle is SPELL?
and i can't find any kind of potion particle inside Potion ENUM
Oh wait hm
wanna have this
should be spell or spell_mob
okay thx
dustoptions works with spell?
yeah idk if it could be used for anything else besides that
if it can thats kinda neat
Ok so according to the client changes, the World#playEffect(location, effect, int)
you just pass in the color you want for the int actually
you dont use DustOptions
The integer should be an rgb color
si i need to use DustOption ?
No
Let me check something to make sure, maybe even spawnParticle isnt the right method
cause there is playEffect
public <T> void spawnParticle(@NotNull Particle particle, @NotNull Location location, int count, @Nullable T data);```
And then you can try passing in an Effect and integer rgb color
Not sure tho, I need to verify this
i think you can use the offset x y and z parameters for colors
hooo okay
the count parameter also controls the alpha iirc so you can only spawn 1 at a time
Hey, I'm kind of confused, I'm probably doing something really simple wrong but I honestly have no clue,
Its printing test into the console however the armor stand isn't moving
Location armorLoc = armor.getLocation();
int task = Bukkit.getScheduler().scheduleSyncRepeatingTask(Main.getPlugin(Main.class), new Runnable() {
public void run() {
armorLoc.setY(armorLoc.getY() + 0.05);
armor.teleport(armorLoc);
System.out.println("test");
}
}, 1L, 1L);
You should be using BukkitRunnable btw instead (docs outdated it)
scheduler is fine here
lambda 
Finn, 0.05 is extremely small and armour stands have gravity
Ive disabled gravity, sorry forgot to mention that
armor.setCollidable(false); armor.setBasePlate(false); armor.setGravity(false);
Ive already done that, I set it to 1 earlier, still no movement whatsoever
what you are trying to do
Just move it upwards
?kick @gritty flame trolling
👢 Kicked Dragonze (Shank)#9952
lmao
tf
weird kid
don't work
Can we see the code?
you could just teleport the armor to its own location + your offset
Where do you set armor?
i'm testing your method with rgb data plz wait
Oh ok
just wondering should you use the schedule methods if you want to check if the scheduling failed or not. Because I usually use BukkitRunnable
I mean both works
Its printing test so its fine
don't work too
Can you show code
It's just a little nicer to write
Bukkit.getScheduler().runTaskTimer(plugin, () -> {
// whatever
}, 0L, 20);```
loc.getWorld().spawnParticle(Particle.SPELL, x + 0.5, loc.getY(), z + 0.5, 2, 255l, 0l, 0l);```
Pulse the only reason I would not use the BukkitScheduler would be where you want to take advantage of the impurity BukkitRunnable may offer
No like the playEffect
haa ok i'm tryng
ic
are docs down?
?jd
same
is there a way to detect entity movement in an event, i know PlayerMoveEvent is a thing
but i need it for entities
declaration: package: org.bukkit, interface: World
luckily enough EntityMoveEvent isnt a thing
that must've just happened lol, i was on the docs like 2 minutes ago
yep but there is not Potion effect
is there any way to detect it then?
How many Particles are compatible to DustOptions?
Uh I guess you could use a repeating task to check movement
or maybe potion break ?
how to set item position in gui?
dang
Yeah try that
then for the rgb, use the code i sent above
Yeah it's kinda dodo
which coverts the r, g, b into one integer
Inventory#setItem
I think its only redstone
Options which can be applied to redstone dust particles - a particle color and size.
yeah
Then, I guess the color of the SPELL must be determined by the speed
wdym
it work but there is like a potion break with the sound and it don't wanna this
the speed of the particle may change some misc stuff of the particles
ItemStack one = new ItemStack(Material.FEATHER);
ItemStack[] menu_items = {one};
gui.setContents(menu_items);
I did this
Hm let me see
loc.getWorld().playEffect(new Location(loc.getWorld(),x + 0.5, loc.getY(), z + 0.5), Effect.POTION_BREAK, 0);```
that wont compile
Yes it seems to be
;-;
spigot down again yeah