#help-development
1 messages · Page 2022 of 1
;-;
whatever
I mean technically you can
He told you to use this, you changed it
so how do I go through all online players
No I know, I meant you told them to use it
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.
And they changed it to the for(int i...
it is basic java
i know how to do a for each loop
I want to know what the f Bukkit.getOnlinePlayers(); means
@lime jolt what are u trying to do
?spigot
spigot documentation
THATS WHAT I SAID
@tender shard this blog is nice btw, very useful information 
but i thought u said I could use it some how
so then mfnalex
how do I go from that method
^^^ true
I dont know what that method means
but HOW
it's straight forward
declaration: package: org.bukkit, interface: Server
I need an explenation
ok
so how would I narrate through all of the players
using that method
I know how to use a loop
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.
...
*explanation no offense
https://www.learnjavaonline.org/ is the easiest one btw imo
this is funny to read
drum rolll
.....
most intense typing I have ever seen
the answer
to all of my problems
if (hand == null) {
p.sendMessage("You need to be holding a item in your main hand");
}else{
ItemMeta meta = hand.getItemMeta();
...
ok
Caused by: java.lang.NullPointerException: Cannot invoke "org.bukkit.inventory.meta.ItemMeta.setLore(java.util.List)" because "meta" is null
this is the error
;-;
why
Probably need to see a bit more code, also what line it is on
!report mfnalex cyberbulling
lol
if i have a folder in my resources directory named configs and a file named config.yml inside of that
how do I do saveResource("configs/config.yml", false) and save it to the plugins directory under config.yml and not configs/config.yml
and return stops the code right?
getItemInOffHand
getItemInMainHand
return true?
anyone know how I can narrate through all of the players in a server
You have a Collection. Collections can be iterated over with a for each loop.
This is not rocket science.
for (Player player : Bukkit.getOnlinePlayers()) {
player.sendMessage("hi");
}```
You need to take the advice of people in this channel and learn some more of the basics
YEs
I thought you know how to use loops
Can you just time him out already?
;-;
he is pretending too bad
I know java basics
Doesn’t understand collections
https://mystb.in/OclcAdministratorDisputes.typescript keeps saying meta is null
Collections are not Minecraft-related
They are Java features
These are things you should have a basic understanding of
but implementing them with that method for me is not normal
Bukkit.getOnlinePlayers()
You gotta read the docs also
is new
java is object oriented programming
i know
That's fine, but from there, iterating over it should be something you should know
if u can read the java tutorial u said with 5k pages then reading docs for spigot aint that hard
Check if the item is null or air
wait there is tutorials on every spigot object?
I thought ItemMeta gets created when non exist?
i thougt hand it a material.air
fair
Material.Air feels bad
Is air even meant to be in an itemstack
should i just do this?
There’s also hasItemMeta
ok
Correct
Which is what you want if you are only reading meta
If you are modifying it, that’s different
Fair
I’m guilty of using getItemMeta when I only want to read
Which is bad
Arrow? wut?
joinks thanks
also if i do
/lore
i get a error
i wanna be able to do
/lore agag
and it still send the help page
only if i do /lore set/remove
then i want it to run that code
how do i do that
what's the error
oh no i'm using the wrong way
jikes
i were unfamiliar
first time hearing about it
but i guess i havn't done much patterns designs
it is messy
when i do /lore i get
Caused by: java.lang.ArrayIndexOutOfBoundsException: Index 0 out of bounds for length 0
show ur code
Only V O I D
if i do
/lore
/lore egasrgag
it shows the help page
but if they type remove/set
then it does the code
yes but what if
/lore ojkgaga
i want it to still show the hlep page
ok
thanks
Switch would work well
if (!(args[0].equalsIgnoreCase("remove") || args[0].equalsIgnoreCase("set"))){
p.sendMessage("help page");
return true;
}
Plus that’ll just keep getting uglier as you add more options
well i want
/lore
/lore agaega
to both show the help page
how do i do that
are u using a list for your lores
i think so
what
iv been coding this for 3 hours
will that do waht im trying to do
/lore agag help page
/lore help page
i thought u said i should not use a switch
im sorry
Last I recall, Arrays#asList() is immutable
How long until you start charging
Lists.newArrayList(args) would be the appropriate replacement there
Yep
I think that’s the name anyway
bit to late, im reading it now
package com.sun.istack.internal does not exist
import com.sun.istack.internal.NotNull;
kk
what does that do
That’s a weird import
Can’t say I’ve had eclipse tell me to just import things that don’t exist
Does anyone have any ideas on how to make this returnable?
@Override
public void onPluginMessageReceived(String channel, Player player, byte[] message) {
if (!channel.equals("BungeeCord")) {
return;
}
ByteArrayDataInput in = ByteStreams.newDataInput(message);
String subChannel = in.readUTF();
if (subChannel.equals("PlayerCount")) {
int playerCount = in.readInt();
//ra
}
}```
My idea was to put the return on the scoreboard, but you can't do that with a void :/
and I confess that I don't remember how to do it
In the BungeeCord API, is a PlayerDisconnectEvent fired for each connected player when the proxy shuts down?
Only for the player who was disconnected, so yes
i mean when someone runs /end, which makes BungeeCord shut down
But if you want to get all the players, you have to make a method to get all the players when one player leaves
for some reason, I dont gain hearts from killing ppl and sometimes the person who dies doesnt lose any, what went wrong
if(lastDamage instanceof EntityDamageByEntityEvent){
EntityDamageByEntityEvent entityDamage = (EntityDamageByEntityEvent) lastDamage;
Entity killer = entityDamage.getDamager();
if(killer instanceof Player){
Player player = ((Player) killer).getPlayer();
// Adds a heart to the killer
double killerHeartAmount = player.getAttribute(Attribute.GENERIC_MAX_HEALTH).getBaseValue();
killerHeartAmount = killerHeartAmount + 2.0;
player.getAttribute(Attribute.GENERIC_MAX_HEALTH).setBaseValue(killerHeartAmount);
// Removes a heart from the player
Player player1 = e.getEntity().getPlayer();
double playerHeartAmount = player1.getAttribute(Attribute.GENERIC_MAX_HEALTH).getBaseValue();
playerHeartAmount = playerHeartAmount - 2.0;
player.getAttribute(Attribute.GENERIC_MAX_HEALTH).setBaseValue(playerHeartAmount);
}
}```
ok, thanks
Could someone help me with this?
How can I convert a Chatcolor to the nbt value for color for leather armor
Nevermind
Not returnable, but you can assign that player count to some field and make use of it instead
Or just update the scoreboard directly if you really want. Get the scoreboard you're updating, set that value
https://mystb.in/MadnessTrashCreature.java
if someone says those words. if no one is online is there a way i can see who said those words
^^
yes
How can someone say those words
no
bro my brain hurts trying to understand
for get that
if 1 person is on the server
and they say that
how can i make it so i tells me who says the word when i get online
if you want to know if someone said something before they left the server, you would need to log chat. i dont think minecraft does that natively.
It does
bitte
oh ok, then get the chat logs
how
All chat is logged and then compressed when the server restarts
is it accessible without a restart though?
wait nvm
oh ok, so @simple anvil, just parse the plain text to find any instances of the message and see who wrote it.
i think
unless theres a better way
im gonna have discord SRV
and ill cansel the event, then brodcast a message
that way i can look in the discord chat and search for the keyword
Probably better to just save the player name to a file manually
And like, a time stamp or whatever you want
^^
Discord works too I suppose
yes
big easy
danek
in python i can do
name = "cyber"
print($"hi my name is {name}")
is there a way i can do that in java with out
("hi my name is " + name);
no but still in the " "
No
oh
how is that diffrent tehn
String("ok" + "name")
It’s not
But it’s nicer when you have a lot of things to add in
So you don’t need a million +‘s
%s what does this do
Placeholder for a string
kk
thanks
Any idea how id make a bomb like so?
Note: It takes where the player is facing and throws it in that directions
*direction
Man I wish i joined this discord server before starting my plugin dev things
I spent a lot of time on forums xD
are there any good libraries out there with good documentation for managing configuration files
https://pastebin.com/GtG07eYB
Why are all 3 spawned if MONK is the type, 2 spawned if merchant is the type, and 1 spawned if default is the type?
Pastebin.com is the number one paste tool since 2002. Pastebin is a website where you can store text online for a set period of time.
You don’t break at the end of the case
looks like a job for @ancient plank
bomb bomb bomb bomb bomb
u probably just set the item's velocity in the direction its thrown then after like 3 seconds generate a sphere around the bomb's location with some particles and sound
simple
if u don't wanna do the math to generate the sphere urself u can depend on WE iirc @quaint mantle
How can I get the number of totems spent?
I want a message to come out when using a totem
player has used his totem number: 6
ah alright
any way to make it drop the items?
from those blocks however?
I've been trying to change the colour of a Particle.SPELL, but anything that I try just spawns white coloured particles. Any help?
location.getWorld().spawnParticle(Particle.SPELL, location.clone().add(0, 1, 0), 0, color.getRed()/255D , color.getGreen()/255D, color.getBlue()/255D , 1);
get the blocks destroyed and handle their drops
alr
final question @ancient plank, ingame the item had text above it
any way to do that w/out an armor stand?
kk
alr
is it generally a bad idea to hide NBT Tags from the client?
by modifying the items sent to the players using packets
I'm experimenting :)
I already got it working good tho
and send an extra value being the hash of the actual nbt to solve the stacking problems that may happen
but I was wondering if it would be a good idea to use this in a real environment
I can’t think of any reason to
the only reason I can think of is
there can be plenty of reasons to, i.e: keep track of an item without players noticing
lol
were them at least hashed lmao?
no
kek
I mean adding pdc is generally unnoticeable
Unless they have a mod to show NBT data
But who cares if they can see your custom items name or whatever
for the most part it doesn't matter, but that's not what I'm asking
oh no they can see my CIDs 
Well if it doesn’t matter then don’t bother
At best it does nothing
At worst it causes a bunch of weird side effects
based on what I know, I think the side effects will be mostly avoided by sending an extra value of the original hashed NBT
so, no reason why not?
unless there's something I'm missing
I think 📄 has options to hide NBT
I don't happen to find them, can you tell me where they are?
Sorta. I've made my own once or twice
Yeah I used them to auto register events
You can auto register commands as well by having an argument. I might still have it let me check
You can get the annotations of a class easily enough
And go from there
And yes I should improve that catch block
how do I prevent a number from going below 1 and above 64?
is there like a math.huge
or math.boundarys
function
alr
You want to add methods at runtime 
@Override
public @NotNull Map<String, Object> serialize() {
Map<String, Object> map = new HashMap<>();
map.put("pitch", this.pitch);
// Not putting entity value in as it's generated upon creation.
//map.put("entity", this.entity);
map.put("loc", this.location);
map.put("nbt", this.nbt);
return map;
}
public static NPC deserialize(Map<String, Object> decrypt){
return new NPC((double) decrypt.get("pitch"), (Location) decrypt.get("loc"), (String) decrypt.get("nbt"));
}
Why does it throw this error?
Pastebin.com is the number one paste tool since 2002. Pastebin is a website where you can store text online for a set period of time.
Items BasicKey = Items.newItem("basicKey",null, true);
ItemStack itemA = new ItemStack(Material.TRIPWIRE_HOOK, 1);
ItemMeta metaA = itemA.getItemMeta();
metaA.setDisplayName(ChatColor.GREEN + "Basic Key");
metaA.addEnchant(Enchantment.DURABILITY, 1, true);
NamespacedKey keyA = NamespaceKeyList.getKey("crateKey");
metaA.getPersistentDataContainer().set(keyA, PersistentDataType.STRING, "basicCrate");
ArrayList<String> loreA = new ArrayList<>();
loreA.add(ChatColor.DARK_GRAY + "A key! can open a basic crate.");
metaA.addItemFlags(ItemFlag.HIDE_ENCHANTS);
metaA.setLore(loreA);
itemA.setItemMeta(metaA);
BasicKey.setItem(itemA);
I feel like im wasting A TON of variables doing this
any way I can lower that down?
i constantly type itemA, itemB, etc
it gets tiring
Yea I thought so
Ill try that
.
allows for
It could use a lot of cleaning up but it's an example of what you can do
Yeah, basically. I'm cleaning it up as it's a mix of two systems due to a server having issues with it.
If you want magic look at how Lombok does it
Fun fact
Naming the string in your annotation “value” means you don’t have to specify the name when using it
Which was strange to find out
It's the default isn't it? I remember something about that.
Yeah
is --rev 1.18.2 --generate-sources --generate-javadoc --remapped the correct build tools args to generate everything?
how to make world void how?
what?
I want to make a skywars server, how do I make the world void?
you can either use a prebuilt map or void world, or run a function that sets every block to air in the chunks making up the arena
okay wtf is the arg for javadoc
nvmind found it
where the fuck does it generate to though?
like
i just compiled but
the only javadoc i can find is the 1.18 javadoc from last month
Player#setSwimming doesn't work?
If I set it to true and you go in water then it works (The player starts swimming right away)
But when I try to set it to false it doesn't work. (The player continues to swim)
Wait wdym?
Is this still how you get itemstack of held item?
invToInteract.getInventory().getItemInMainHand()
(invToInteract is humanentity)
I'm trying to set it to false (I'm trying to block sprint-swimming)
it broke after 1.18.1 or something
Ohh
Try cancelling the event that triggers when player starts to swim ig
I'll try it again, but I've tried that many times (didn't work to)
did they change how to register events in 1.18.2?
I don't think so
no?
then why the fuck can't i do java @Override public void onEnable(){ getServer().getPluginManager().registerEvent(this, this); }
this anymore
it throws an error
wat
With a s
Add s
Always has been I believe
registerEvent is a method to, but it takes more arguments.
registerEvents will just register all the events in that listener class
@EventHandler
public void onSwim(EntityToggleSwimEvent e) {
e.setCancelled(true);
}
That didn't work
(Crossplay JavaBedrock) Is there someone in here I can trust with an IP?
I need to figure out if someone can join it on Bedrock Ed.
Dunno If U can Trust me
Is there any packet i can't send (with protocollib) for stopping the sprint-swim animation?
Or even just stop the entire sprint swimming
wth will ppl do with your ip?
nothing
exactly
Someone is definitely commiting a crime that will throw him in prison for 10 years 🤓
what's the usually used naming scheme for plugins? [major][minor][patch] or [major][minor][build][revision]
Former
thx
wait
people sell plugins
how can they do that if all bukkit/spigot code is under GPL3?
I’m not a pro at licenses, but I believe they have to give you source if you ask for it, and most code of plugins is actually written by the authors themselves per say
ik some plugins that require a subscription
like 25€/year for no source and 75€/year for source
on spigot
i don't remember the plugin tho
so how does that work
how would they enforce that?
maybe don't give updates?
im pretty sure a license system is not allowed on spigot
o
Which is kind of bs
But like it takes a lot of effort to enforce someone the license
yeah but like
just don't give out updates?
people will just not buy it if they don't want
i know thats why i still get ppl on 1.5.1.2 version of my plugin, which is like 5 months old (note: its free and open source, no reason to not update)
@ivory sleet btw, is this correct?
if so ill try to find it again and report it
I don’t really know, actually
what i mean is having a key to make the plugin actually work.
thats fine
thats allowed iirc
the thing is subscription thing
or is it not allowed
well wait, just make the key decode the plugin
Like people can license their code afaik
ah well having a license system on a spigot plugin does not make much sense
Not sure if same applies to spigot (the software that is)
and just when ppl buy give them a plugin with the key
that decodes stuff
lemme just
@vagrant stratus
optic won't kill me
right
right??
i hope
well alex pings him 94/7
so its fine
🥲
He's blocked iirc lol
lmao
actually wait no, I just ignore him
optic
look at what i replied to in this message
Premium or free?
premium
this was for a premium plugin
Read the premium guidelines then https://www.spigotmc.org/threads/premium-resource-guidelines.31667/
ah shit
right
google fucking sucks
DRM systems are (provisionally allowed), with the following key caveats:
All resources must run directly from downloaded file without any manual installation steps or access to a specific server. This means that licensing systems of any form are prohibited. This also means that all applicable code must fail-safe in the event of (web) server error.
They must not interfere with any aspect of the server outside of the plugin itself.
We will treat all complaints of DRM abuse with the highest severity, which may result in immediate and permanent suspension of your resource unless sufficient evidence is provided.
We may request it be removed or altered at any time.
no its not drm iirc
literally part of the requirements you should be reading @tall dragon
its just no updates if you don't buy
no no
i saw a plugin
that had a rental
thing
well im not making a premium plugin
and they pointed out its not allowed
we were just discussing it
^
Either way, when it comes to license systems and premium, you're limited due to the above rule.
what is DRM short for?
Digital Rights Management
e.g. a resource based around gambling wouldn't be allowed
ah
so no casino plugin
so a mechanic that involves random chance does not count
sadge
gambling is putting valuables up for random chance of reward iirc
well it aint that
Something like https://www.spigotmc.org/resources/⭐-vegas-⭐-casino-plugin-►-13-game-modes-1-12-1-18-1.92321/ for example wouldn't get accepted afaik. Currently uploaded resources however are grandfathered
ah wel
i meant more like that there's a chance somethign just wont work/activate even if done right
same error
if i wanted to make data for different types of blocks for a custom mining system, like each kind of block has different code that runs or different tool thats required, should i use an abstract class and then make a new class for each block which extends the abstract class?
or should i just hard code all the different block events into a single class
Hi! what lib should i use for inventories in 1.17?
what version are you running it in
1.18.1
is there a event for a beacon activating/deactivating?
what commands should i make?
Didnt find anything. You can check https://hub.spigotmc.org/javadocs/bukkit/org/bukkit/event/block/BlockPhysicsEvent.html
But if not then you might need to check the BlockPlaceEvent
declaration: package: org.bukkit.event.block, class: BlockPhysicsEvent
what?
This is not java nor kotlin. Looks like some sort of scripting language
Wait. Its Skript isnt it?
Yes, it's a script with the skript-reflect add-on that allows you to use java code
:D
How about you just write your plugin in java?
I plan to study this summer.
Then you get auto completion and javadocs and everything else that would explain you how to get those.
Vlad fyi this channel is by no means for Skript assistance, consider joining their discord if you need assistance concerning Skript, thanks!
Ok, thanks:)
is event.getBlock.getType() == Material.BEACON a 'lightweight' check?
Yes
You can do a thousand of those in a tick and dont see it in your timings
ok
and then further checks from there
imma presume that not too many of those blocks are beacons lol
Yeah from then on you can get more expensive with every safeguard statement
safeguard?
if (some_condition) {
return;
}
doesnt that result in the same runtime as
if(!condition){
code;
}
Sure. But it reduces nesting by a lot.
Doesnt make a difference. And even if it would we would talk about nanoseconds.
it should be identical once byte code
ok
@EventHandler
public void onMove(PlayerMoveEvent event) {
if (event.getPlayer().hasPermission("some.permission")) {
if (event.getFrom().getBlockX() == event.getTo().getBlockX()) {
if (event.getFrom().getBlockY() == event.getTo().getBlockY()) {
if (event.getFrom().getBlockZ() == event.getTo().getBlockZ()) {
event.getPlayer().sendMessage("You are looking around and not moving.");
}
}
}
}
}
@EventHandler
public void onMove(PlayerMoveEvent event) {
if (!event.getPlayer().hasPermission("some.permission")) {
return;
}
if (event.getFrom().getBlockX() != event.getTo().getBlockX()) {
return;
}
if (event.getFrom().getBlockY() != event.getTo().getBlockY()) {
return;
}
if (event.getFrom().getBlockZ() != event.getTo().getBlockZ()) {
return;
}
event.getPlayer().sendMessage("You are looking around and not moving.");
}
@lost matrix java onEnable(); final String[] sword = { "DIAMOND_SWORD", "IRON_SWORD", "GOLD_SWORD", "STONE_SWORD", "WOOD_SWORD", "DIAMOND_PICKAXE", "IRON_PICKAXE", "GOLD_PICKAXE", "STONE_PICKAXE", "WOOD_PICKAXE", "DIAMOND_AXE", "IRON_AXE", "GOLD_AXE", "STONE_AXE", "WOOD_AXE", "DIAMOND_SPADE", "IRON_SPADE", "GOLD_SPADE", "STONE_SPADE", "WOOD_SPADE", "DIAMOND_HOE", "IRON_HOE", "GOLD_HOE", "STONE_HOE", "WOOD_HOE", "BOW", "FISHING_ROD", "BLAZE_ROD", "STICK", "BONE", "GOLD_INGOT", "RECORD_3", "WATCH", "SHEARS", "GREEN_RECORD", "COAL" }; Arrays.asList(sword).stream().forEach(e -> LootManagement.items.add(e));
static List<Material> items = new ArrayList<>();
i was reading in your performance forum on some code, and i'm in doubt on the best way for me to check if a material is inside a list, i'm talking to avoid that every time the object is instantiated and create a new list, i I already created it inside onEnable(), I don't know if for me and using Strings and comparing with a material would be the best way
iirc you cant just do list.contains(Object) tho, and O(n) of that should be either 1 or list.length
it's O(n)
You are on the O(n) graph.
You can see on the right that adding more elements linearly increases the time for contains.
allr
rather use a set like the resource says
you're basically doing what java already has just in complex
The fastest contains you could achieve here comes from an EnumSet<Material>
GodCipher telled me to do this xd
yea do a set
Sure but this only defines the scalability of a collection. The raw contains time is still faster in an EnumSet (compared to a HashSet)
oh true
Also not all Set<T> contains calls are O(1).
Only the on of HashSet<T>.
Take a TreeSet<T> for example. It has O(log(n))
"Does not working" is a useless statement. Please describe what exactly is not working, what you expect it to do, and what actually happens. If you get any console errors, also ?paste the entire stacktrace.
how to add arraylist location to config file?
i have an code with save location by arraylist but when reload all arraylist reset
then i want to add arraylist to config to keep the file
in reality I was using a HashSet
public static Set<String> items = new HashSet<>();
Location implements ConfigurationSerializable. You can just throw it in a FileConfiguration
but comparing a material using string
why not use new EnumSet.of()
You need to cast it when retrieving
@minor garnet
ok
Dunno if you want to rely on enum sets for materials for too much longer
ok
There is an open PR to move those to proper registries
Also "just" moved is a vibe
Lool
Im suspecting that spigot will just deprecate Material for 3 years before dropping it.
now that i think about it
Nah
tf are legacy material enums about
1.12 plugins
And no, the material class is just rewritten afaik
With as little backwards breaking changed as possible

No
I didnt say anything about implementing that yourself
how to do bro
How to do what exactly bro
this a xy problem without even saying whats wanted
bruh
?xy
Asking about your attempted solution rather than your actual problem
?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.
sender as Player
or sender as? Player
but thats not really applicable in this context
its if youre not sure if its actually and want to get null instead of a cce
I mean theoretically you can do
(sender as? Player) ?: error("Not a player :<")
But
don't
you only do something if(stack.getAmount() <= 1) less than or equal to 1? what happens if its more than one?
ah yeah, i was lining up brackets one level off
?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.
i didnt text it for you
where is the code you have for placing currently?
well you need to count your items, and then decide how to split them with the chest being in the center
beyond that it is just alignment based on the number of items and the location of the chest
so if you have 4 itemstacks, you might choose to have two on left, one in the center and one on the right - for a single chest
or you could make your life a bit simpler and just use the chest location as your left margin
hmm most of the reasoning would, not sure you can use get and set together like that - ive not tried
you also need to interrate through the inventory as you print/place
actually, second i do usie it similar to that in a section of code
...
OWPPortalDestruction().owpPortalDestruction( lstBlockList.get(0).getBlock(), event );
...
centerBlock.setType(Material.GLOWSTONE);
Use ` not '
yeah i wlays forget which is which :0
anyway, roughly your code will do something like what you want. Specifically I am unsure what happens when you set the airblock to an item
you might need to use a custom block or head to represent the item if you don't want it to appear dropped
There's probably a much easier way to do this, nested for loops, or calculating the x/y coordinates yourself using modulo
google is useful tbf
EntityDamageEvent maybe?
mfw that post says to use EntityCombustEvent
you're*
and I'm glad you think that way, feel free to leave a review on yelp and I'll get to you as quick as possible
LMAO
No I know
I was defending you 😛
Yeah that is weird, I would've thought EntityDamageEvent would've been fired atleast.
I mean idk how you solved it, or even if you did solve it, but nested for loops/calculating are good options.
pain
It won't print the display name if that's what you're asking
public class KitEditor implements Listener{
private ItemStack kitEditor = new ItemStack(Material.BOOK);
public KitEditor() {
ItemMeta meta = kitEditor.getItemMeta();
meta.setDisplayName(ChatColor.GRAY + "Kit Editor");
ArrayList<String> lore = new ArrayList<>();
meta.setLore(lore);
kitEditor.setItemMeta(meta);
}
public ItemStack getKitEditor() {
return kitEditor;
}
public void setKitEditor(ItemStack kitEditor) {
this.kitEditor = kitEditor;
}
@EventHandler
public void onJoin(PlayerJoinEvent e) {
Player p = e.getPlayer();
p.getInventory().addItem(kitEditor);
}
}```iis there any wrong thing on this code
for(int i = 0; i < inventorySize; i++) {
int x = i % 9;
int y = i / 9;
//use dem bitches
}
Honestly I don't know, probably not? Never used getName on an Item Entity before.
What do you mean by "wrong thing"
i dont know somehow i can not get the item
U gotta check if the entity is an instance of item then cast to get the item type iirc
"You can't get the item"? Send the code where you're trying to get the item
in event
Then get pissy at me for responding
Okay send code then
How dare you try to be helpful. 
public class KitEditor implements Listener{
private ItemStack kitEditor = new ItemStack(Material.BOOK);
public KitEditor() {
ItemMeta meta = kitEditor.getItemMeta();
meta.setDisplayName(ChatColor.GRAY + "Kit Editor");
ArrayList<String> lore = new ArrayList<>();
meta.setLore(lore);
kitEditor.setItemMeta(meta);
}
public ItemStack getKitEditor() {
return kitEditor;
}
public void setKitEditor(ItemStack kitEditor) {
this.kitEditor = kitEditor;
}
@EventHandler
public void onJoin(PlayerJoinEvent e) {
Player p = e.getPlayer();
p.getInventory().addItem(kitEditor);
}
}```
You asked if get entity then the name would return item type and I responded with the method to get the item type
I am incredibly conflicted on Spigot versions atm
Oh... oh, you should really separate the listener from the editor.
Use 1.19 ez
Like, a lot of people still use 1.8, so if I want to get any clients I'd have to dev for it since I probably couldn't persuade them to use ProtocolSupport/ViaVersion.
At the same time, I want to develop for the latest version only
But anyways, @kindred valley did you register the listener?
Hi
im dumb sorry
How to make wait in x second in interact event ?
Yeah but not everyone updates their Minecraft so it's still kinda necessary if the server wants players
It's like
The best solution isn't the best solution since the best solution requires alienating a large portion of your playerbase/clientbase
It's starting from the top left
So place your blocks starting from the top left
Or figure out how to flip it
Hey guys.
what is the best way to replace blocks between two locations with less lag and fastest speed as possible.
How to use interact event in scheduler?
?scheduling
double chests are pain
You need to add the chest offsets also
which event i need to use for clicking an item
random question but is it better performance wise to not use the bukkit scheduler for async tasks?
InventoryClickEvent?
PlayerInteractEvent
Oh I see the problem now
I already have the list of those blocks but my problem is that i need a better speed without lagging the server?
I wasn't visualizing it right lol
Using for was the fastest speed but uh
server crashed
because of high amount of blocks
then i used BukkitRunnable but it was too slowly
.
//Num rows - current row - 1 (to keep 0-2 instead of 1-3)
int y = (inventorySize / 9) - (i / 9) - 1;
Maybe?
You should use Bukkit's scheduler if you're doing async tasks.
like it's an async task that finishes very quickly not lasts for a while
and I'm doing lots of them
Then why are you doing it async
either split it up accross different ticks or use an api
^ FAWE 
this is the third time im hearing people suggesting me this today
seems you gotta use EntityDamageByBlockEvent
Seems like it'd be a good idea then huh
it's using FAWE api and I'm just filling an area and doing it async so ut doesn't affect the main thread but since they happen often idk if the bukkit scheduler is good for it
it's good once you understand it ngl
aye
it was the fastest way
liquids are blocks
It should definitely be able to place 250 blocks/second.
it is
wdym
i mean
it does it all very quickly, I do about a million blocks in less than a sec with it
you serious?
i just tried it with 1000 blocks and
server crashed
are u using world edit
a lil testing never hurt anyone
none of them lol
alright, I got to go for abt 30m as I'm in class but if you still need help I'll be happy to help when I'm back
alright
I'll send one of my code snippets when I'm back
mmm try not to use fawe if you can help it, use the normal worldedit api
this is my old code which when i tested that the server crashed ...
Can we detect if an inventory is not a default inventory in spigot with packets or else ? (an inventory created on the client side)
that the wrong way to use the api lol
thats not world edit api btw
hotbar has been a longtime issue
but uh if you meaned my own api nah thats fine i think
Well no wonder, you were checkinh every single block in ur region
thats what you have to do when you want to replace them
What is the problem with the hotbar? I don't get it.
its fully clientside - it is also used to circumvent a lot of anti-cheats
using FAWE probably also needs world edit as a required plugin right?
no
It wasn't really the hotbar that I had a problem with, but maybe there is a way to determine where a packet is coming from, or maybe with the packets to determine that the inventory is not a basic inventory present in spigot?
cool thanks
the hotbar allows swapping in illegal and invalid inventory
you will get a server event when someone tries to use bad the inventory as far as i know
Youd have to find their current direction, and apply the x y with that
many times you will also get an event for moving inventory too fast
The problem on my side is that when we make a creative give with forge, for bukkit (even when I go through the packets to intercept before) the open inventory of the player is his creative inventory even if he has none open on the client side
me when I first discovered that inventory is client side like 10 months ago 
How can I prevent a player from taking an item after clicking on any item in a newly made inventory?
🙂
List<HumanEntity> getViewers()
Gets a list of players viewing the inventory. Note that a player is considered to be viewing their own inventory and internal crafting screen even when said inventory is not open. They will normally be considered to be viewing their inventory even when they have a different inventory screen open, but it's possible for customized inventory screens to exclude the viewer's inventory, so this should never be assumed to be non-empty.
okay
That's not the problem xd (I'm more interested in knowing if bukkit doesn't recognize this inventory or if there is a way to know the origin of a packet)
if the player is online, their personal inventory is always open per the above getViewers description
Except for that, well in theory
My guess is that you would need a clientmod to actually know - which is also the hotbar "solution"
the only exception would be personal inventories that are replaced with a custom inventory like a backpack etc - and in that case you would create an open/closed state
Couldn't you theoretically also take advantage of ForkJoinPool?
I think you didn't understand what I was looking for
that is pretty much how you would handle the condition you highlighted - have been to 2 or 3 servers where personal inventory was replaced
Maybe my translations are not quite perfect, excuse me
how can i change the example text on the new inventory
for your application you might be better off saving a schematic and pasting it to "reset" the arena
its set when you create ur inventory
y
the setlore text? - hmm you said title
Hey 7smile7, do you have any other guides of this nature? I don't mean on this particular topic but of this level of quality. Kinda realized that my infrastructure design is quite shit.
yeah i know
yeah did it
how can i prevent the custom item from falling to the ground
inventoryclickevent
couldnt find any method on dropevent
dropping?
how can i control if the item is custom item
conditions
i know
check the item meta
u can do ItemStack#isSimilar
no
wym no
isSimilar is basically
if(item1.equals(item2)) but
it does not consider the stack size
yes this is different
it checks item meta, durability, etc
I know
u dont need to consider stack size if ur checking if its a custom item
u can just compare the types and the item meta
or localized names
dont
or as u like tbf
using a pdc or a localized name much better though
idk what is pdc
PersistentDataContainer
I tried to read but I did not understand
public interface PersistentDataContainer - This interface represents a map like object, capable of storing custom tags in it.
Infastructure as in data synchronization between instances?
i dont fucking have this thing on spigot 1.7
Just the underlying structure of my code
1.7 makes for a great security breech
I know.
Ah i see. Probably not going to write something for this as opinions diverge quite a bit on that.
Generally just enforce the SOLID principles and some code style. (I use a stricter version of google java code style)
You really cant expect any support for that version. Its so incredibly old...
right.
if youre gonna support 1.8 do what you want but 1.7 is just unreasonable
Yes.
context?
the client doesn't know it's still there
im using 1.12 api but i don't see any better way than using getData() and setData() do you guys know any?
Does 1.12 already have BlockData? I thought so.
Ok i see BlockState but no BlockData...
Ah.
BlockState -> MaterialData
So the answer is: Use the BlockState of a Block and change its MaterialData. Cast for the right types.
if i kill a player using a bow, will the getKiller return me?
Yes i think so
I would assume that its already set at this point.
i have a luckyblocks plugin but i ran into an issue, i kinda need to have like 3 elements in my map, so like Having
ACustomMap<Key,AnotherKey,Value>
is there any implementation ready in java?
since i need to check both for the data and the material
Another opinion: Create a class that wraps the nested key-value relation.
yes i've tried, i think table from guava is the best option
tho when retrieving on the block break i'd have to create a new object each time
because like, it has a lot of maps for security and backups
No. Why?
how would i do it then?
Map::computeIfAbsent 😌
Single best method ever created
You are doing lucky blocks, right?
objectively true
this is what i've tried
You should not query WorldGuard like this. Just increase your listener prio and ignore cancelled events.
i've tried several times, didn't work
its about a year that i've been working on this plugin, i'm trying to fix a bug, its a commission for a server
well actually i've been maintaining it
when something popped up, i don't actually code on it daily like i think you understand
getter for a map. That just calls for chaos and fragility in your code...
where is the static getter?
- What is MaterialBlock
my object that wraps my material and data
Show it please
Where is your hashCode method?
never used hashcode in my life
Implementing hashCode is necessary for maps imo
If you want to use something as a key in a hashmap then you should write a hashcode method.
Just use @EqualsAndHashCode for now
yeah because else they will always differ right?
i would like to know when the player.getKiller can be null
fall damage
or other stuff
I dont see where you would use the Table. Mind giving a hint?
getKiller will be null if they weren't killed by a player
i mean, didn't realize i could retrieve data using my custom object
so i tought maybe a need a table so i can use <Material, Short, LuckyBlock>
Alright so then it should be resolved now
yes, i'll test now, this thing of hashcode is very cool, might read documentation later, i've seen it across while reading the java book but never used it and forgot about it
You mean a plugin?
ye
ah thanks
there is a problem now, it won't add blocks that have the same material wtf
what does 'no rating' mean
So same Material but different data values?
yes
The resource is unrated, it has no reviews therefore a rating can't be calculated.
Then you need to write a custom hash method
wait a sec i cant select that option
Oh
im hovering over 'no rating'
Yeah nvm I don't know what that is
Items treaty = Items.newItem("treaty",null, true);
item = new ItemStack(Material.PAPER, 1);
meta = item.getItemMeta();
meta.setDisplayName(ChatColor.BLUE + "Treaty");
meta.addEnchant(Enchantment.DURABILITY, 1, true);
key = NamespaceKeyList.getKey("treaty");
meta.getPersistentDataContainer().set(key, PersistentDataType.STRING, "true");
lore = new ArrayList<>();
lore.add(ChatColor.DARK_GRAY + "Requests to have a treaty with another person.");
lore.add(ChatColor.DARK_GRAY + "If accepted, you cannot harm eachother.");
meta.addItemFlags(ItemFlag.HIDE_ENCHANTS);
meta.setLore(lore);
item.setItemMeta(meta);
treaty.setItem(item);
How would I make this more efficient?
use List.of(String...) instead of actually using a new instance of the array list
not what i meant but ok
Nah it does the same thing
public int hashOf(Material material, short data) {
return material.ordinal() & 0xFFFF | (data & 0xFFFF) << 16;
}
This should be fast and reliable.
yeah but i mean could save 2 lines
It takes up a TON of line space, and I feel as if it isnt efficient at all.
and how would i use it?
That seems fine anyways
i know but i mean could compact it
I'm not replying to you lol
Using ItemMeta generally just uses a lot of lines
Yeah
And actually
You could probably use Arrays.asList
It, unlike List.of, does not create an java.util.ArrayList
It actually creates a java.util.Arrays.ArrayList, which is a private implementation of List that directly uses the array.
Does it cause any problems in your timings?
Because this looks not really worth optimizing much
No problems, but It just looks ugly lol
And I hate ugly code a LOT
ive redone thousands of lines of code just cause it doesnt look right to me
You could change the order in which you do things to make it prettier probably
i have OOD when it comes to coding lol
maybe
...do you mean OCD?
i remember someone recommending negative checks to me
I mean either way, OCD is the wrong terminology for perfectionism
use a code style guide then
if(not condition) return multiple times
But OOD is not a thing
different topic
actually wait one sec
How should i use a github link as external download URL, should i link the file or the releases page?
typed wrong lol
Still
everyone says i have code OCD
OCD is a very broad mental disorder, and I don't mean to be all SJW about its usage within conversation
buuuut I'm a bit of a perfectionist
when it comes to how people use words and stuff
deleting a space is a commit for me
im a perfectionist ig lol
KISS, an acronym for keep it simple, stupid, is a design principle noted by the U.S. Navy in 1960. The KISS principle states that most systems work best if they are kept simple rather than made complicated; therefore, simplicity should be a key goal in design, and unnecessary complexity should be avoided. The phrase has been associated with airc...
fair
then program using SEI rules/style
how do I upload code on a seperate site to show
whats the command that sends that link
or whatever
?paste
kinda need it
?paste