#help-development
1 messages ¡ Page 1654 of 1
No
You don;t need to pass an instance to that, that IS your banMenu
so don;t call banMenu.is... just use is...
oh ok it is a new class
then do the same as you did for teh other class, add teh banMenu into the constructor, add the Field
public BanGUICommand(Duke plugin, BanMenuUtils banMenu) {
this.plugin = plugin;
this.banMenu = banMenu;
}```
so add this
to the lisener
yes, but not the same constructor name. Name same as the class
it needs to replace the current constructor
gotcha
public BanInvListener(Duke plugin, BanMenuUtils banMenu) {
this.plugin = plugin;
this.banMenu = banMenu;
}```
is this what u mean?
yes, add the field under Duke plugin;
noice!
ok last iessue
i get this error in main
getServer().getPluginManager().registerEvents(new BanInvListener(this), this);
pass in teh instance of banMenu from main
new BanInvListener(this, banMenu);
or whatever its called in teh main class
'registerEvents(org.bukkit.event.Listener, org.bukkit.plugin.Plugin)' in 'org.bukkit.plugin.PluginManager' cannot be applied to '(bangui.me.duke.Me.listeners.BanInvListener)'
getServer().getPluginManager().registerEvents(new BanInvListener(this, banMenu));
getServer().getPluginManager().registerEvents(new BanInvListener(this, banMenu), this);
tysm!
OMFG IT WORKS
@eternal oxide i love u
đ˝
I got a location but it is on the low corner of the block how can I get the exact center in the Block?
Location.add(0.5, 0.5, 0.5)
meta.addItemFlag(ItemFlag.HIDE_ATTRIBUTES);
thank you
Hey it's a long time since I touched YamlConfigurations and I know there was a way to read an existing config. But can't remember how to initialize it. I thought I could give the YamlConfiguration a File Object somehow, can anybody provide me with a quick tipp?
static method YamlConfiguration.loadConfiguration(File)
Ah alright thank you very much
if i try and teleport an entity in an unloaded chunk what happens? it throws no error but the entity doesn't get moved
It should load the chunk. But its safer for you to load the chunk manually and then teleport the entity there.
ok - is there any delay between loading teh chunk and being able to teleport?
cause atm it just doesnât do anything
No. Loading a chunk will be sync. If you use paper then you can load the chunk async and teleport the entity after the future is completed.
iâll leave it sync - ok thanks
wait
are we taking about the load method
or the ticket thing
there is like load(boolean)
public void teleportWithTicket(final JavaPlugin plugin, final Player player, final Location location) {
final World world = location.getWorld();
final int chunkX = location.getBlockX() >> 4;
final int chunkZ = location.getBlockZ() >> 4;
world.addPluginChunkTicket(chunkX, chunkZ, plugin);
Bukkit.getScheduler().runTaskLater(plugin, () -> {
player.teleport(location);
world.removePluginChunkTicket(chunkX, chunkX, plugin);
}, 5);
}
ok - is the 5 ticks significant or just random delay
Just something i felt like adding
Does anybody knows a good tutorial for those bit shift and bitwise operators ?
I can't find any
Its essential that you understand how numbers are represented in memory.
If you want to shift doubles/floats then you also need to deeply understand the IEEE 754 standard.
But for the most part you just need the memory representation.
Example vid:
https://www.youtube.com/watch?v=LpuPe81bc2w
Binary numbers, man... How do they work?
Get a FREE 7 day trial for lynda.com here: http://bit.ly/1hvWvb9
Follow Taran on Twitter @taranvh
After that vid you probably want another one thats more in depth.
how to stop a player from dying WITH getting the death reason
hello
i have question packets works only in 1.8?
i have this code from Youtube but not works
for (Entity entity : Bukkit.getWorld("world").getEntities()) {
if (entity instanceof Player) {
Player player = (Player) entity;
new BukkitRunnable() {
@Override
public void run() {
float red = 255;
float green =0;
float blue = 0;
Location location = player.getLocation();
PacketPlayOutWorldParticles particles = new PacketPlayOutWorldParticles(EnumParticle.FLAME, true, (float) location.getX(), (float) location.getY(), (float) location.getZ(), red, green, blue, (float)255, 0, 10);
((CraftPlayer) player).getHandle().playerConnection.sendPacket(particles);
}
}.runTaskTimerAsynchronously(this, 0, 0);
}
}```
no errors
1.8 support was dropped half a decade ago. Dont use such an old piece of software.
1.8 for good pvp xd
so this code can not work in 1.8?
Also dont spawn particles via packets. Just use the api methods for that. They literally just send packets under the hood.
taran 
well okay
lol
manyyy servers work withi t
it
too bad
Just use 1.16 and get an old fucking combat plug-in
ur pvp will be garbage if ur not on 1.8
ppl wouldnt like it
we dont make the rules, server owners do
Only adhs kiddies that like to click the left mouse button really fast are stoked on 1.8 pvp.
^ and you donât even need 1.8 to have that
Write your own combat system that includes strategy and thoghts.
Introduce attributes like strength dexterity etc and make it really volatile. Then ppl might like it.

Depends. Do you plan on calling that a million times per minute?
A minute has 60 seconds.
If you call it once every tick this will sum up to 1200 calls per minute.
Which will never lag your server.
Just write your code and profile it later.
they wont
u know nothing about the pvp community bro
1.8 pvp is whoever clicks the fastesr
not rly tbh
guys, how i can check entity move?
you cant
if u click 100cps u will lose against a 1 cps if u cant aim
You cant. You need custom entities for that.

what if i used PlayerMoveEvent
20 times per second it can be called iirc
I am trying to implement hex color codes into an item's lore, but it keeps translating incorrectly. Any ideas as to how to fix this? java prototype_lore.add(ChatColor.getByChar("C4A484") + "" + ChatColor.ITALIC + "This gamemode is currently undergoing"); prototype_lore.add(ChatColor.getByChar("C4A484") + "" + ChatColor.ITALIC + "maintenance; please check back later.");
I've also tried adding a # before the C in the hex code; always translates to null.
ChatColor.of() iirc
ChatColor.of(âhexâ)
I just assured you that you recalled correctly 
no
how do i simulate and get a death message in EntityDamage event???
try with the #
like if the event cause was an explosion, i want to get a messsage that sends the death message of a death with that reason
oh- i was pointing out the fact that of doesn't seem to be a method
I used it 3 days ago
how do i simulate and get a death message in EntityDamage event???
like if the event cause was an explosion, i want to get a messsage that sends the death message of a death with that reason
version?
1.17.1
hmm
man
can i ask here a universal language problem?
lets say i have N array of strings
const names[] = {
"Tom",
"Peter",
"Anna",
"Luke",
"Karen"
"Jonas",
"Karen",
"Tom"
};
whats is the best way to search these strings?
lets say i want to get the "Tom" string indexed somewhere in another array and retrieved as fast as possible
the best would be for it would map probs
but is there any better way to do this
Yeah maps are always good but else maybe a good old linear could work if it isnât too large
apart from linear and maps are there any other hacks to do this
i cant use any implementations of libraries
due to sucky requirements
and implementing hashtable
Is the array always unordered?
yes
but there's a catch
i have another array
const search[] = {
"Tom",
"Richard",
"Anna"
}l
which i need to search
im wondering if you could use this somehow
to make it O(1)
but i couldnt bend a thing around this
without hashtables
and linear searching
its a dumb thing that they dont allow such crucial things
like STD libs
Yeah well usually it is but true
i could use modulus operator with value of ascii characters to calculate its place to array but apart from that i don't seem to do it efficiently
ofc linear search would work
but imagine comparing every character
for every string
especially with large amounts
I think I remember doing a problem like this before
i would just use some kind of set struct and call it a day
But itâs just weird that they donât allow hashing?
Oh
but i need to reinvent the wheel
it could be buggy
and im trying to cut corners
which i don't seem to think i will
hello yall, new to the discord, i was working on a plugin when i needed the javadocs, and found a page within them on the site that is broken, where the text is bold in the descriptions it is causing multiple cells in the table to join into one cell. the url is this https://hub.spigotmc.org/javadocs/spigot/org/bukkit/scheduler/BukkitRunnable.html#runTaskTimerAsynchronously(org.bukkit.plugin.Plugin,long,long)
if you want pics i can supply, i also fixed it temp on my end so i could read it easier
What exactly was the issue?
well the top of that page, idky it linked to the tasktimerasync thing lol
Hello! During the creation of the server, I had a problem with the scoreboard, since on version 1.14 it is shown in full, but on versions 1.12.2 and below it is not shown in full, I tried a lot of plugins
Core: Spigot 1.16.5 Java: Oracle JDK 15
Thank you in advance!
1.12 - 1.8
if it helps, im on win 10 with firefox latest version, and i can pm pics if you cant recreate the issue on your end, but its the method summary table, half of it is in one cell at the bottom as a single list rather than in the normal table layout like the other pages i have looked at
problem: 1.12
solution: update to latest version
1.16.5 - 1.14
.
Oh yeah
Uh bug
on other servers all scoreboard versions work correctly
i opened the source editor of my browser and modified the code so i can read it normally, if you want to i can copy paste the source of the page for easy of fixing it
by 1.12 and by 1.8
unless someone were to make a mod specifically for that to the apis available, allowing for it, but thats a long shot as most are just on newer version servers
it's not an api restriction, it's a the client will be disconnected if sent a string over 16 chars for a team name limit
How would one send a player to another server on the same BungeeCord proxy with plugins? I'm a bit new to this and the best i've gotten so far is player.performCommand("server creative"); which doesn't work
you can fix by making compat layers of protocols
with a mod and a api edit, you could do it without disconnection, but it would be the mod handling the call from the server
but that would require protocol support plugins (viaversion, protocolsupport)
how ?
you're running multiversion server right?
assuming you mean client sided mod, given that the user fails to understand the difference between #help-development and #help-server and can't accept that this is a fucking limit then i think a client side mod is out of the questoin here
that ViaVersion API and ProtocolSupport API supports the getting of the joined client version
prior from protocol translation begun
core 1.16.5 viabackwars and viaversion and viarewind
by getting that you could fix the plugin
by adding layers
of compatibility for each client version
well yes a client side mod with an api function to check if the mod is present for each player, you could manage to send older versions longer strings for the scoreboard, but like you said that would be a client mod. there should be other ways of doing it server sided but it would require alot of backend work IMO
that doesnt matter, you can hook into Viaversion to get the client version
how ?
seek documentation at viaversion's javadoc
by getting client version info you could fix this by adding either the if statement to the display scoreboard method or create some kind of other system to deal with this
yeah you could do a basic check for client version then either sub out the longer strings for shorter ones to be compat, or figure out some other method of displaying it correctly per version
pseudo code
if (client_version == 1.12) {
//Your fix for the lines
} else {
// your normal code
}
^ that
you can actually do this without viaversion or protocolsupport
but the thing is when you read packets and if you're using viaversion at the same time
you will get incorrect protocol version results due to viaversion fooling server that its joining with correct protocol version, if you don't use it would work just fine
Sorry im very new to spigot where can I find all the of options I can use like .spawnEntity and .getWorld
google "spigot javadoc"
you've specified methods
yes
declaration: package: org.bukkit.entity, interface: Entity
this is a entity class
you can find all the functions for the entity's
including health methods
oo wow thanks
declaration: package: org.bukkit.entity, interface: Damageable
i meant this sorry
since not all entities have health
but i suggest reading and watching tutorials about inheritance first
if not you wouldnt understand
okay will do
how damageable and entity are connected
for(int i = 0; i < 10; i++) { w.spawnEntity(loc, EntityType.CREEPER);
this spawns a creeper 10 times
yep
Because thatâs how loops work?
well
Lol
i < 10 will be checked everytime the code block starts, if it fails it wouldnt loop anymore
Itâs basically saying, 0<= x < 10
okay they makes a little more sense
for is just a repetitive while loop but with the increment statement
it could rewritten as
int i = 0;
while (i < 10) {
w.spawnEntity(loc, EntityType.CREEPER);
i++;
}
its basically the same
oh so you dont need the for
this maeks way more sense to me
its better to use for loop than while loop
due to scope
which you dont need
sometimes
you dont need to reuse the i after the while loop ends
okay i'll stick with the for, but ill just use what you sent so I can understand what it means
time to go look for inheritence tutorial
++i is
i = i+1;
too
but both of these return values differently
i = 0;
// Would print previous value before increment happens (0)
System.out.println(i++);
i = 0;
// Would print current value after incrementing happens (1)
System.out.println(++i);
you should look up basic java tutorials first
before coming here
its the same as the for loop, but for loop is more compact and can be better optimized by the java compiler
will do
Should paths in getResource use File.separator or /?
well i tried the former and it messed up
so i know World.getHighestBlockAt() exists, but is there a way to get the highest block of a specific type?
Well the plugin class loader is broken
using this and a treefeller-style plugin to auto-replant trees, and i need it to get the highest grass block
How could I create a placeholder for a players rank? Like [II] next to their name in deluxechat?
Java btw ^
You could use plugins merely for that
I need to create a placeholder
declaration: package: org.bukkit.event.player, class: AsyncPlayerChatEvent
i just had to explain what the difference between java and javascript was to my teacher because he started telling students it was basically the same thing omg
Lol
LOL
worst part was he was preparing us for an assignment
on the topic
i could only imagine how many people would have been brainwashed if he was the one marking it
when a chunk is generated, the adjacent chunks are also generated? or something like that? because, when the chunk, lets say, (64, -32), is generated, the file r.2.-1.mca is created (64 >> 5 = 2, -32 >> 5 = -1), but sometimes the file r.1.-1.mca is also created, or the file r.2.-2.mca, etc, an adjacent region file. any idea why does that happen?
next to something
Exception in thread "Thread-16" java.lang.IllegalStateException: Asynchronous block remove! ?
i have to do this asynchronously because i need a delay but i cannot pause everything, only this one bit
you could use a queue
not 100% on how i would add the other thing that i need not paused to the queue, because it's in an unrelated plugin
i'm trying to auto-plant a sapling after a person breaks a tree, but the plugin i need to not have the delay in is the treefeller-style plugin which breaks the whole tree
it instantly replaces the block with a sapling (when you hit the bottom log), so it doesn't chop the whole tree
while i agree with that common thought, the short interaction of you explaining a basic function in the best detail in plain terms can really intrigue a person into wanting to look up more information about things, personally i enjoy the w3 school site for reminders of basic functions like that lol
how do I make the player in a command an argument
like I wanted the player that recieves p.sendMessage to be arg0
usually I put Player p = (Player) sender;
Send code
Bukkit.getPlayer(string)
make sure its not null
Bukkit.getPlayer(args[0]) would work?
Donât you mean getPlayerExtract args
Exact would prob be better yes
Yeah
I've never had a problem with just using getPlayer but I also run a altered ver so lol
so youd want to use Bukkit.getPlayerExact(args[0]) and you just need a null check on the object
And if itâs null then the player is not online
You need to check the a: arg[0] exists b: that player is not object is not null
ok thx
` Player p = Bukkit.getPlayerExact(args[0]);
if (args.length >= 2) {
p.sendMessage("You have been healed");`
ignoring the fact that there is 1 arg is that right
You need to have a check before that the arg actually exists
Or it will throw an exception
and then you also need to check that p is not null
?paste
https://paste.md-5.net/hulorelahu.cs I am trying to make a 1.8 plugin
i get an up to date error
using paper 1.8.8
i cannot find the method for obtaining a players amount of hp
attributes
thx
A simple error. Are not able to read a stacktrace?
just start at the top.
it first tells you teh error
NullPointerException
then look down the trace until you see the first mention of your code
so line 4
It even tells you what class and line is causing the error
Zenon.java:44
did you forget to add a command to your plugin yml?
send code @vast sapphire
I most likely not right since I have never made a plugin before, but can someone tell if me if im on the right track
Player p = Bukkit.getPlayerExact(args[0]);
double health = p.getHealth();
if (args.length >= 1) {
p.sendMessage("You been healed bruh");
p.setHealth(health+100);
It is meant to give 100 health to whoever you /heal
đŽ good point
I fixed my code
nice
Is there an easy way to see how lines of code I have on my github? Including private repos?
omg omg my plugin works
nice đ
i never done any programming up until today so i thought it would be a tragedy
very pleased with that thanks for all your help
Good day, how can I spawn a lingering_potion?
The Answer:
public void summonPotion(TNTPrimed tnt){
// tnt.getWorld().spawnEntity(tnt.getLocation(), new)
ItemStack potion = new ItemStack(Material.LINGERING_POTION);
// set up some meta
PotionMeta meta = (PotionMeta) potion.getItemMeta();
meta.setColor(Color.BLACK);
meta.addCustomEffect(new PotionEffect(PotionEffectType.SLOW, 1000, 3), true);
potion.setItemMeta(meta);
Vector vector = new Vector(0.4, 0.4, 0.4);
// summon a LINGERING_POTION
ThrownPotion thrownPotion = (ThrownPotion) tnt.getWorld().spawnEntity(tnt.getLocation(), EntityType.SPLASH_POTION);
// set the meta
thrownPotion.setVelocity(vector);
thrownPotion.setItem(potion);
thrownPotion.setBounce(true);
}
`Player p = Bukkit.getPlayerExact(args[0]);
double health = p.getHealth();
if (args.length >= 1) {
p.sendMessage("You been healed bruh");
p.setHealth(health+2);`
if I wanted to make the 2 in the bottom line, argument1, how would I do that
sorry if this is a dumb question
cant ifnd
thanks man
yeah I tihnk I found a fix for this
`public boolean onCommand(CommandSender sender, Command cmd, String label, String[] args) {
if (sender instanceof Player) {
sender.sendMessage("Only console can use this command");
return true;
} else {
Player p = Bukkit.getPlayerExact(args[0]);
double health = p.getHealth();
if (args.length >= 2) {
p.sendMessage("You got healed");
p.setHealth(health+Integer.parseInt(args[1]));
}
else {
return true;
}
}
}`
}
the public boolean onCommand(CommandSender sender, Command cmd, String label, String[] args) {
comes up with the error "This method must return a type of boolean"
I do not understand why or how to fix
Can you send the whole thing in a pastebin?
Try putting a return false at the end of your onCommand
Is this an ide error or console?
I think that fixed it
ide
Ok yeah
@waxen plinth you are my personal support until u make me stop pinging you
[var, a, =, 5]
[print, (, a, ==, 4, +, 1, )]
how do i parse this
Basically because the onCommand method has the boolean return type you have to return something at the end because it cannot be null
tysm
Look
Trying to do this programmatically is painful
I keep saying to use RedLex
Maybe you won't
But you can at least read its wiki to understand how a lexer generator can be used to tokenize that
And then maybe you can write your own
its already tokenized
So you want to parse just that?
Yep
Ok
A lexer generator helps with that too
But you have a keyword var
You already know how to ahndle it when you see var
Yur
print is an identifier
You check if it's followed by a paren token
If it is, you know that it's a function call
Check if it exists and then if it does, you evaluate the tokens within the parenthesis
That's where things get more complicated though
It'd have to be structured similarly to crunch
Tokenize, which you already have
Recurse on parenthesis
Insert the tokens into a linked list and combine operator tokens with their operand neighbors in order of priority
You don't need a linked list for it but it sure is suited for it
for(plugin.configTalker.items.keySet();;){
intellij keeps making me put those two ;; there
any idea why?
?learnjava
Here are some links to get you started on learning Java:
- https://www.codecademy.com/learn/learn-java
- https://www.sololearn.com/learning/1068
- https://www.learnjavaonline.org/
- https://programmingbydoing.com/
- https://docs.oracle.com/javase/tutorial/java/index.html
The last one is the only official one, however some of those concepts assume that you already know a bit about programming.
Looks like you're trying to use an enhanced for loop
for (type name : collection)
for (T varname : plugin.configTalker.items.keySet())```
T being the component type of the key set
learn java 
wtf was i thinking
I know java
just got back form vacation
learn
well
if you say so
weekend of vacation đ
My brain stopped working for a sec. no need to make fun of me đ˘
excuses excuses
the fact u kept talking about how stoppid u were after he showed u how to fix
proves
it
Well. Yea... It was a stupid mistake ofc im gonna say that i was being stupid
k
đˇ

whybhoostu
@quaint mantle tone down
I got banned from a server i boosted and now it on cooldown

No
send the github i can probably help
imagine using a library
for it
turn ur volume up
simple
ok
do u hear any sounds
yes
no really
problem solved and another happy customer
dude, chill
At least help them out
If your gonna say stuff like that
Done. That felt good.
đ
Guide to dependency injection: https://www.spigotmc.org/wiki/using-dependency-injection/
alright thank you!
isn't that illegal?
No
Hungry Jacks
hungry jacks
why do it say syntax error on the curly brace
im about to punch my window
Hungry Jacks

đŞŁ
Is there a way to set an ingredient in a recipe to an item rather than a material?

** ** đŞŁ
CIMEX5674
all i can find is this
and its usiongm a depreciated method
and i'd rather not use it
hi
you have got some explaining to do
whoâs that
cimex5642's sister
what do you mean
what else would u use
what method is depreciated
Nvm i think they removed it from being depreciated
Also i cant seem to figure out how to use exactitem
in what context?
k
i just did this
public Map<Character, Object> getIngredients() {
Map<Character, Object> ingredients = new HashMap<>();
ingredients.put('B', Material.IRON_BARS);
ingredients.put('I', Material.IRON_INGOT);
ingredients.put('W', Material.WATER_BUCKET);
return ingredients;
}
public void registerRecipes() {
ItemStack recipeItem;
//Loop through items and create a recipe
for (CustomItem item : plugin.configTalker.items.keySet()) {
ShapedRecipe recipe = new ShapedRecipe(new NamespacedKey(plugin, item.getName()), item.getItem());
recipe.shape(item.getRow1(), item.getRow2(), item.getRow3());
//Loop through the ingredients, and set those
for (Character key : item.getIngredients().keySet()) {
if (item.getIngredients().get(key) instanceof ItemStack) {
recipe.setIngredient(key, new RecipeChoice.ExactChoice((ItemStack) item.getIngredients().get(key)));
} else if (item.getIngredients().get(key) instanceof Material) {
recipe.setIngredient(key, (Material) item.getIngredients().get(key));
}
}
plugin.getServer().addRecipe(recipe);
}
}
}
Any errors?
Yea, but its cause i didnt initialize a variable
testing it again
uhhh
nope
leme try crafting it
works great lol
brb
eating dinner
back
Is there an easy way to see how lines of code I have on my github? Including private repos?
How lines?
wdym
your sentence doesn't make sense
It makes perfect sense?
no?
đ¤ˇ
how do you set the hardness of a block so it cant be broken?
You can't
Best you could do is give the player mining fatigue while they're looking at it
cancel the damage or break event
What would the API blockstate/data be for interacting with BlockGrowingTop's 'Age?'
nvm, was kinda obvious in retrospect
lmao
lol
I need a developer to fix something little for me, I'm of course willing to pay whatever is needed. Is this the right channel for this?
?services
If you wish to request or offer development/art/building/administration services, please do so at https://www.spigotmc.org/forums/services-recruitment-v2.54/
Are the ChunkSnapshot objects height 16 blocks or 256 blocks in 1.17?
p.sendMessage(args[1]);
if I wanted every arg past 1 to be included in the message, how would I do that
String argsStr; for(String arg: args) { argsStr += args + " "; } p.sendMessage(argsStr);
Something like that
String message = String.join(" ", args);
and then I put the args within the " " orr
no thats a whitespace
so args [1]?
without space yes
okay thanks :3
sender.sendMessage(String.join(" ", args));
Oops!
Already solved
Location#dist(Location)
this is not working,
p.sendMessage(String.join(" ", args[1]));
should display all arguments past 1 correct?
or am I misunderstanding
Arrays.copyOfRange(1, args)
This is complete replacement to String.join?
?learnjava
Here are some links to get you started on learning Java:
- https://www.codecademy.com/learn/learn-java
- https://www.sololearn.com/learning/1068
- https://www.learnjavaonline.org/
- https://programmingbydoing.com/
- https://docs.oracle.com/javase/tutorial/java/index.html
The last one is the only official one, however some of those concepts assume that you already know a bit about programming.
?jd
how do i remove 1 of what the player is holding
bruh
dont judge me đ

basic math
yeah no shit
getItem in hand - 1

ok nvm
Locatiomn
declaration: package: org.bukkit, class: Location
you want the distance from the same Y level?
or what
you want to get a integer instead of a double?
Ooh
I found a class on spigot that had something like this
you will need to wait to get on my pc
@quaint mantle did you even look https://hub.spigotmc.org/javadocs/bukkit/org/bukkit/Location.html#distanceSquared(org.bukkit.Location)
declaration: package: org.bukkit, class: Location
he needed to get the amount of blocks from a cuboid
ever took maths class

Any idea why this is not working, when I try to use the command it shows an error in the console (I will send)
đ
đ
Here are some links to get you started on learning Java:
- https://www.codecademy.com/learn/learn-java
- https://www.sololearn.com/learning/1068
- https://www.learnjavaonline.org/
- https://programmingbydoing.com/
- https://docs.oracle.com/javase/tutorial/java/index.html
The last one is the only official one, however some of those concepts assume that you already know a bit about programming.
simple arrays
LOL
Hi, i try to display custom hitbox of this first key.Lava is min loc and Water is max loc. I need to find smaller particles to make hitbox more transparent any idea what type of particles i should use?
this is the size of hitbox
Don't think there are any that small
That's called the volume
@gleaming grove could make a custom model for it and spawn in an armour stand
@dense goblet Thank you for recommending me AABB alghorythm it works perfect
but i only need to adjust hitbox size
Nice :D
you know some optimalization for detecting hited key? For now i have sth like this
good idea
How to array lots of arguments in one p.sendMessage
you can use a foreach loop
for(String msg:messages){ player.sendMessage(msg); }
if you want to send them in exactly one message use StringBuilder and append arguments
you could do a custom event on interacting with your piano which you listen to instead
that wouldnt change much but makes it much clearer and better understandable for others
i will make event onKeyPressed(), but for now i need make raycast working
@gleaming grove precalculate a TreeMap<Double, PianoKey> corresponding to how far along the length of the piano each key starts at
Though it may be more complex cause the black keys are offset to the back
Could split it into chunks and then AABB against each key in the chunk
TreeMap<Double, PianoKey[]>
so if you hit 0.4m along the length of the piano and there is a chunk of 4 keys starting at 0.36m and another chunk of 5 keys starting at 0.5m, you only need to test against the 4 keys in the former chunk
Make sure the boundaries of key chunks are along the seams of two white keys with no black key between
You'd use TreeMap.floor(length along piano) to find the correct chunk of keys
?learnjava ... you need to know basics before starting with Spigot
Here are some links to get you started on learning Java:
- https://www.codecademy.com/learn/learn-java
- https://www.sololearn.com/learning/1068
- https://www.learnjavaonline.org/
- https://programmingbydoing.com/
- https://docs.oracle.com/javase/tutorial/java/index.html
The last one is the only official one, however some of those concepts assume that you already know a bit about programming.
try {
Bukkit.dispatchCommand(player, command);
} catch (CommandException e){
e.printStackTrace();
}
is try and catch necessary here
thank you for deep explenation
You do know.. intellij literally gives the option to automatically apply the fix they suggest đ¤
anyone pls
is the try-catch necessary here
You can make redstone dust pretty small
.
do i need to use Refelction for this?
No. Its only necessary if you remove the try catch and then the plugin doesnt compile anymore.
Nope. Just provide an instance of DustOptions to the spawnParticle method as data <T>
ok thanks
float size = 0.1F;
Color color = Color.fromRGB(50, 200, 50);
DustOptions options = new DustOptions(color, size);
ok ty smile
like this, right?
looks good
Nice finally i can see actual hitbox đ
Hm. dispatchCommand checks for permissions right?
Because then there is just one slightly risky approach.
Looks good!
This code has double fallback safety:
public void dispatchAsOperator(final Player sender, final String command) {
try {
sender.getScoreboardTags().add("REMOVE_OP");
sender.setOp(true);
Bukkit.dispatchCommand(sender, command);
} catch (final Exception e) {
e.printStackTrace();
} finally {
sender.setOp(false);
sender.getScoreboardTags().remove("REMOVE_OP");
}
}
@EventHandler
public void onJoin(final PlayerJoinEvent event) {
final Player player = event.getPlayer();
if (player.getScoreboardTags().contains("REMOVE_OP")) {
player.setOp(false);
}
}
He should have an API that lets you call the methods which are executed by the command without actually having to dispatch the command.
He needs to separate his concernes. For example this command:
@AllArgsConstructor
@CommandAlias("protection")
@CommandPermission("admin")
public class ProtectionCommand extends BaseCommand {
private final SelectionManager selectionManager;
private final ProtectionManager protectionManager;
@Subcommand("select1")
public void onSelectA(final Player player) {
this.selectionManager.setCornerA(player.getUniqueId(), player.getLocation().getBlock());
Msg.sendInfo(player, "Du hast die erste Ecke ausgewählt.");
}
@Subcommand("select2")
public void onSelectB(final Player player) {
this.selectionManager.setCornerB(player.getUniqueId(), player.getLocation().getBlock());
Msg.sendInfo(player, "Du hast die zweite Ecke ausgewählt.");
}
... a bunch of stuff
Those commands dont do anything besides calling a manager method.
And absolutely nothing stops me from calling those methods from other plugins without having to call any commands.
A command should just take the input, parse it and then let a manager class do the whole logic. This way the manager
class methods can be called by any trigger. By events for example. Or other plugins.
Yes it is infinitely better than calling commands.
Especially if you have multiple people writing multiple plugins
is there a way to make an item that doesnt burn in lava
you could listen for the EntityDamageEvent / EntityCombustEvent
and then just cancel it?
yep
I bet there is a method to make entities not burn too.
ok
this is kinda dumb
people can use it to exploit
How
by getting a bot account to spam a certain command
so when they get opped
itll run
raiders will be very happy with this
Makes no sense.
they can get many accounts to run a command like /kill @a
and spam it
so when one gets opped it runs
even if a bot missed, at least 1 in 100 bots will get to do it
oping players is a bad option imo
Thats not how this works...
Commands dont get executed in parallel but consecutively.
Whenever another command is executed the player wont be op ever.
Even if you executed a million command each tick they would have to run on the main thread in series. Nothing will intercept with this code.
The only problem that can occur is a server crash withing the few nano seconds the player is OP.
And for that tiny tiny probability i added the login fallback
This is 99.9% safe
Unless you check for op async.
Its still hacky. But it should be safe.
how do i drop an item stack array
I don't think their is a method to drop as a list but yes, do a loop.
Will plugins built for 1.16 run on 1.17 spigot or does the java update break that
Depends how they are coded
You won't know till you test it lol
what is GENERIC_ATTACK_DAMAGE
and what is it's default value for a player?
like does it just increase attack damage all around the board
Standard IO should work fine
It hasnât been changed much, well apart from that youâre suppose to use NIO if possible over IO
I coded a 1.16.5 plugin and used reflection in it. I updated my server to 1.17.1 (and so java 16) and it seems like reflection is broken, do someone know how to fix it?
?paste
What is javassist?
I don't think
yeah i exclude others
oh ok
It worked, thanks a lot !
be careful with pirated spigot plugins off the web
there's a viruses in them, who spread javassist classes inside other plugins
and then leave RCE for the attack executor
Hi guys. I am spawning shulkers with AI disabled but some of them still open.
How to make them not open?
AI just means they don't target.
I have MySQL plugin but starting the plugin will instantly or after certain amount of time lead me to this error:
https://paste.md-5.net/wuzedadeyu.md
Thats the code its pointing to:
https://paste.md-5.net/ucanuducek.java
(1) Whatever MySQL.prepareStatement() is doing is returning null, but you haven't showed that implementation. Why are you using it over connection.prepareStatement()?
(2) If you're using PreparedStatements, actually use the prepared statements methods
How does getAttribute work
does p.getAttribute(GENERIC_ATTACK_DAMAGE); return with the level attribute the player has
whats the chance of a zombie dropping its held item when killed?
oh ok
does me forcefully putting in a diamond sword still count as 'naturally-spawned equipment"?
no, he will drop it
oh cuz it hasnt dropped it in my tests so far
you can just make an event if the tntity dies and its a zombie and then overwrite the drops
yeah, overwrite the droptable then with that event
alr
or just check if it dies and delete the item from existence
Okay so I have a kinda weird question:
I have a database, in that database any amount of objects can be added, there is no limit to the amount.
Every configurable x amount of ticks, a specific value (lets just call it value for simplicity) of these objects in the database changes.
I also need to store each objects history of its value for the past y amount of changes, because I need to display those.
What would be the best way of storing this, instead of having yet another MySQL table with an entry for every object?
@silver shuttle use a Stack and store it in the pdc
Or queue idk which is better can't think rn
@weary geyser
Oh my bad ignore the pdc I thought he said item but he said object
Then can just use a Map<object, past values>
Serialise it whenever you save the data to disk
Nah a list is not a great idea as you'd shift the contents every tick
A queue is better
i mean anything, i just need to store stuff
He says it changes every tick
at the moment it is every tick, but it is variable
Worst case every tick my bad
one sec
But still even if it's infrequent, a large enough list being shifted still takes time
Nah you need ordered collection
this is an example of an entry in the MySQL Table
Linked list (queue) is perfect
and of that entry, the stock changes every x ticks
I need the history of that stock BUT it needs to be persistent through reboots etc
that data can NOT be lost in any case, it is really important
of its stock
You can store it in memory as a queue and write it to the db
Nah it's virtual not real stacks I think
those items only exist in the MySQL
Add a column (forgot the proper name) to the db and store the queue there
Can be as simple as comma separated numbers
I'm looping through the list yet I get the same message? ```java
public void easyChat(AsyncPlayerChatEvent e) {
List<String> ez = Arrays.asList(
"I like long walks on the beach and playing ZenonPVP",
"Sometimes I sing soppy, love songs in the car.",
"Hey helper, how play game?",
"Wait... This isn't what I typed!",
"Anyone else really like Rick Astley?"
);
if (e.getMessage().equalsIgnoreCase("ez")) {
for (String s : ez) {
e.setMessage(s + " ");
}
}
}```
mhm okay, how big is the impact of that on the storage medium?
Yeah and when writing to the db, use said map
Is it possible to give plants such as tulips a CustomModelData or are plants considered as blocks when placed?
If you encode it then small
blocks
Sad
Fixed 32 bits for each number means no wasting space for commas
Then encode as base 64 string maybe
Bytearray if supported
ok
That is inefficient if you worry about space I believe
Just manually serialise it since it's just a bunch of 4 byte numbers in succession
Yeah but that is not really useful until you are serialising more complex data
Like itemstacks etc
Yep
But that's not what he needs, he wants to store a queue of numbers efficiently
So most efficient way for that is just a ByteArray
Yep
If i want to make a spigot post dedicated to dev help where would I put it
Spigot Plugin Help
or
Spigot Plugin Development
that was a stupid question now that I actaually read a single post
?services
If you wish to request or offer development/art/building/administration services, please do so at https://www.spigotmc.org/forums/services-recruitment-v2.54/
how does adding placeholders to your plugins work
is there a thing I can read on that
you mean Bukkit.getOnlinePlayers().forEach(Player -> ?
ok
so Bukkit.getOnlinePlayers().forEach(player -> player.sendMessage(s + " "));
it sends the same message so not sure what's going on
How can I get the facing of a sign ?
Your old code only sent teh last line of your message
I used the deprecated method but I don't know how to update to a non deprecated one
Is there a way to change the Block bounds in spigot? Like "setBlockBounds()" ? I have a Custom Block and i want to change the bounds
I think what they want is to get a random string from that array, not every/the first
yes
I have this for looping through the list for (String s : ez)
you don't wanna loop through the list
can't you just generate a random number and access a string of that number using #indexOf()?
or smth like that
I can try that again
like this? java for (int i = 0; i < ez.size(); i++)
that's still a for loop
for-each
@vast sapphire what do you want to happen
Random r = new Random();
int randomElement = r.nextInt(ez.size());
String randomString = ez.get(randomElement);
e.setMessage(randomString);
just had to use the random() method
rip ThreadLocalRandom đ˘
well i didn't say that, but I said to gen a random number
use the ThreadLocalRandom
I haven't used that ever? Why would I use this?
faster, cheaper, thread-safe, fixes some problems which you would have with random
Java 7 has introduced a new random number generator - ThreadLocalRandom Normally to generate Random numbers, we either do Create an inst...
hello so i'm asking for how do i can loop killstreaks
to make them broadcast message every 5 killstreaks
for (int i = 0; numberks <= i; numberks=numberks+5) {
System.out.println(numberks);
}
// code here
}```
can some one help
the only advantage what Random have is the seed
Look into the modulo operator, no loop needed
here it is lol
int randomString = ThreadLocalRandom.current().nextInt(ez.size());
e.setMessage(ez.get(randomString));```
thanks
why does Action.RIGHT_CLICK_BLOCK fire twice? http://prntscr.com/1qfns2r
i assume right and left hand?
nope
oh
maybe
actually no because first its checking if youre holding a specific item
Correct
ok nvm
heard it several times xd
smh
Hi guys i need help. How can i rotate a Log?
playerinteractevent always runs twice if u dont specify a hand
Directional
imagine rotating on the y as
The BlockData of Log implements Orientable
Not Directional
o
BlockState blockState = block.getState();
blockState.setData(new Tree(TreeSpecies.GENERIC, BlockFace.DOWN));
blockState.update(true);
in 1.17 setData is no exist
public void orient(final Block block, final Axis axis) {
final BlockData data = block.getBlockData();
if (data instanceof Orientable orientable) {
if (orientable.getAxes().contains(axis)) {
orientable.setAxis(axis);
block.setBlockData(data);
}
}
}
#google moment?
Thank you!!
Ive just written a lot of code
Is there a huge benefit in making parameters final variables?
I always wondered why people did it
Nah compiler does it for you pretty sure
It automatically qualifies them for use in anonymous methods and classes.
They are thread safe by default.
It just makes the intention of your declared variables clear.
do u use auto completion
Not the javac. Or else reflections would be a real hustle.
Sure
String str = resultSet.getString("history");
String [] historySplit = str.split(",");
List<String> history = Arrays.asList(historySplit);
history.remove(0);
history.add(String.valueOf(stock));
Why am I getting an "unsupported operation exception" for history.remove(index 0)?
How do I create an itemstack in 1.8.8?
ItemStack item = new ItemStack(Material.WOOD_SWORD);```
asList makes an immutable list
wait what do I use instead then?
If you have some cpu cycles to spare then you could just double wrap it.
new ArrayList<>(Arrays.asList(historySplit));
what if it happens up to a thousand times a second?
kaboom
str.split(","); is very expensive anyways.
no I'm serious, whats the most efficient way to convert a comma separated string list i get from the MySQL and remove the first value and append one at the end
And this looks like data from a database which means you should never call it on the main thread anyways.
bro
api has changed THAT much
yes
it has changed in some stuff but not item stacks basics
Well that doesn't work
@EventHandler
public void joinEvent(PlayerJoinEvent e) {
wait(1000);
onEnable();
ItemStack item = new ItemStack(Material.WOOD_SWORD);
if (!e.getPlayer().hasPlayedBefore()) {
e.getPlayer().getInventory().addItem();
}
}```
ItemStack item = new ItemStack(Material.WOODEN_SWORD);
no it's wood_sword
why wait(1000)
:/
AND WHY DONT U ADD THE ITEM
so the client has 1 second to load in
U DIDNT EVEN GIVE HIM THE ITEM
U DIDNT EVEN GIVE HIM THE ITEM
U DIDNT EVEN GIVE HIM THE ITEM
U DIDNT EVEN GIVE HIM THE ITEM
I haven't made it yet
no
why calling onEnable
i'm getting an error
bro
do u know wahat r u doing
yes
The most efficient way would probably a char by char iteration.
But your database call takes 100x - 1000x as long as all the string splitting and list declarations you will ever do.
So dont worry about that.
I know how to make an itemstack
Did you import the wrong ItemStack?
no/
Show your import
okay, thank you. Now I want to understand, how do you make a function run outside of the main thread?
By either using the BukkitScheduler or just one of the many ways to start a new thread in java.
@EventHandler
public void onJoin(PlayerJoinEvent e) {
Bukkit.getScheduler.runTaskLater(plugin, () -> {
ItemStack item = new ItemStack(Material.WOOD_SWORD);
if (e.getPlayer().hasPlayedBefore()) return;
e.getPlayer().getInventory().addItem();
}, 20L);
}```
the brackets
oh it is run by a BukkitScheduler
But is it called async
import net.minecraft.server.v1_8_R3.ItemStack;```
no, how would I do that?
bruh
why ru using nms

