#help-development
1 messages · Page 1903 of 1
Sadly bukkit does not directly expose it
(though you can just copy&paste the method that obtains the logger, it should work the same regardless)
how do u change gamemode
the sout catcher is good
player.setGamemode?
stops stupid plugins printing error messages without you knowing where from
thnx
in setgamemode() what comes in ()
?jd
Read the documentation
GameMode.X
ok thank
a gamemode
ex. creative?
yes
Gamemode.CREATIVE i guess
declaration: package: org.bukkit, enum: GameMode
thanks
public static long getChunkKey(final Chunk chunk) {
return ((long)chunk.getX() < 32) | (chunk.getZ() & 0xFFFFFFFFL);
}
This returns a chunkkey for an x&z coord but is there a way to include the world?
Not without using BigDecimal or something like that
<<?
or cast it to a string and concatenate the name of the world 😈
Exception Connecting:NativeIoException : readAddress(..) failed: Connection reset by peer
How to repair it?
Bungee latest version
Spigot latest 1.8.8 + ViaVersion
latest 1.4.6
newest 1.8.8 mc version on spigot
add the hashed world name?
last patch
update to 1.18
its for lobby
Then use cuberite, supports 1.8 - 1.12 --- no plugins needed!
but 1.18 doesnt support 1.17 in ViaVersion
viabackwards exists
no i dont like this idea
mr adrian
Which is equally cursed but eh
1 + 2 = 3
2 + 1 = 3
cancel player hunger (they should not be able to regen just not run out of sprint)
are you a cat object?
@opal juniper You could reduce the amount of bits used to store the x/z coords and use it to store a hashed version of the UUID, but you will only have access to like 6 or so bits for that (if you do not make use of compromises), so eh
cancel FoodLevelChangeEvent
thanks
The european axis is strong with spigot
i downloading 1.18.1 and check if works
yeah hahah
where do you download 1.18 from, just curious
?bt
@white frost did the bot delete your message?
yeah
If you downloaded your 1.8 version from the source I think you downloaded it from, you might have been running a server with a critical security exploit
"Cant you just send the Spigot jar?"
No, we can't. It's illegal to distribute Mojang code, meaning that you have to use BuildTools to build the Spigot jar.
running buildtools is as easy as running the server
Or well, not malicious malicious, just that noone can truely verify whether it is safe to use
just takes a bit of time
hashes are different
I ran a bytecode differential on the jars and there were no notable differences outside of a few lambda names being different
Just once though
¯_(ツ)_/¯
So I cannot say that all are not malicious, just that a single jar from a single provider was clean (except if it used exploits in the zip protocol to hide some classes)
com.mysql.jdbc.exceptions.jdbc4.MySQLSyntaxErrorException: You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near '?' at line 1 java public static void createRole(String id,String role , Integer position,String prefix , String sufix) throws SQLException { Bukkit.getLogger().info(position.toString()); PreparedStatement date = connection.prepareStatement("INSERT INTO rolemanager(id,name,position,prefix,sufix)" + " VALUES (? , ?, ?, ?, ?)"); date.setString(1,id); date.setString(2,role); date.setInt(3,position); date.setString(4,prefix); date.setString(5,sufix); date.executeUpdate(); } whats wrong?
Did you define the command in the plugin.yml?
how do i change gamemode of player in a playerevent (death event to be specific)
I'd use player respawn event
hmm good idea
though idk if it makes a difference
event.getPlayer() or event.getEntity().getPlayer(), depending on what event and just use setGamemode
hmm ill try
declaration: package: org.bukkit.event.entity, class: PlayerDeathEvent
event.getEntity().getPlayer() is redundant. If you can call getPlayer(), you probably have a Player
isnt there a way to change player gamemode on death/respawn
Hey everyone 👋
I need some help regarding BuildTools.
The console showed me, when powering up the server, my current build is outdated. Thought, fine, time to update.
After building the new Jar, BuildTools ran into issues while compiling the code I guess.
So I deleted the BuildTools.jar and re-downloaded it, gave it the appropiate permissions which needs it and re-ran it again. Same issue.
Error with compiling.
The Log is here: https://pastebin.com/kAZSw6pK
TIA Newt
Re-wrote some of the conversation api stuff to my liking. Is this considered "clean" or is it overengineered?
looks good to me
@EventHandler
public void onPlayerRespawn(PlayerRespawnEvent event){
kills = kills + 1;
for (Player onlinePlayer : Bukkit.getOnlinePlayers()) {
onlinePlayer.sendMessage(ChatColor.RED + "The Hunter Now Has " + kills + " Kills!");
onlinePlayer.playSound(onlinePlayer.getLocation(), Sound.ENTITY_ENDERMAN_DEATH,100000 ,1);
}
}
is something wrong
becuase no work lmao
You can't compare strings like that
Also don't use name to identify your inventory
I have a Long which stores a time in milliseconds:
Long test = 360000L;
And I'm trying to print it in HOURS:MINUTES:SECONDS format.
I've tried this:
String hours = String.valueOf(TimeUnit.MILLISECONDS.toHours(test));
String minutes = String.valueOf(TimeUnit.MILLISECONDS.toMinutes(test));
String seconds = String.valueOf(TimeUnit.MILLISECONDS.toSeconds(test));
player.sendMessage(hours + "H " + minutes + "M " + seconds + "S");
but it doesn't subtract hours from minutes and minutes from seconds, so it'll say "1 hour 60 minutes 3600 seconds" (example) instead of "1 hour 0 minutes 0 seconds". Any ideas?
Perhaps doing it over the SimpleDateFormat and a custom Datestamp? 🤔
I've tried that, like with https://stackoverflow.com/a/9311087, but everything online assumes it's milliseconds since 1970 and not just milliseconds.
like
SimpleDateFormat sdf = new SimpleDateFormat("HH:mm:ss");
String dateTime = sdf.format(new Date(test));```
if i want an event player's name in a death message how would i do it
yeah, right ^^ I know, but assuming that string is 0 with 01.01.1970 00:00:00 and 360000 is 01.01.1970 01:00
u can, its just bound for failure
"your message" + player.getName();
thnx
more like event.getView().getTitle().equalsIgnoreCase("your String to compare")) {
event.setDeathMessage(Player.getName(); + " was shot by hunter!");
hmm how do i do this in a death event
be me, fuck it up completely trying to use variables to replace
this works for minutes and seconds but not for hours, hmm
(it should be 0 hours 4 minutes 57 seconds)
Well, I need your code completely, so I can actually see, what you want t do 🤷♂️
mine?
sativa's issue
@viral hazel
what if u didnt send the same thing 3 times within 5 minutes of each other and waited for someone to get to helping u
^this
If on blockbreakevent I get the block how do i check if its a spawner and put it in the players inv
cuz if i get the Material it wont keep the spawner type
and im trying to keep the type of spawner
again, check this out.
hello how do i put someone in spectator on death pls hel[
@real palm for reference, I'm trying to make exactly this https://www.daftlogic.com/projects-convert-milliseconds-to-hours-minutes-seconds.htm
Convert from milliseconds to hours, minutes and seconds
@EventHandler
public void onDeath(PlayerDeathEvent e) {
e.getEntity().setGameMode(GameMode.SPECTATOR);
}```
sigh
thanls
Yeah, I got you. did you try it also with just seconds and not millisecs?
I am already helping you, but you cant work with it - I'm not gonna write your code, you have to figure out, what I am refering to.
check, what I wrote and think, to what I could refer to in your code.
Use the PluginMessaging Channels then
just google lol
Google your question before asking it:
https://www.google.com/
how do I make something like this ? : Block block = (Spawner) e.getBlock();
.
Hi, I've been trying to port a 1.8 plugin with custom items to 1.18 but when I try to use the NMS item's getOrCreateTag function, it gives me this error:
java.lang.NoSuchMethodError: 'net.minecraft.nbt.NBTTagCompound net.minecraft.world.item.ItemStack.getOrCreateTag()'
check how many people online
Could you help?
public static void createRole(String id,String role , Integer position,String prefix , String sufix) throws SQLException {
Bukkit.getLogger().info(position.toString());
PreparedStatement date = connection.prepareStatement("INSERT INTO rolemanager(id,name,position,prefix,sufix) VALUES (?, ?, ?, ?, ?)");
date.setString(1,id);
date.setString(2,role);
date.setInt(3,position);
date.setString(4,prefix);
date.setString(5,sufix);
date.executeUpdate();
}```
That should be it.
is there any way to store the amount of players online into a int
Bukkit.getOnlinePlayers().size() <- Returns the current players as int
^
thanks
yw!
I will check
👍
When working with maven multi modules, is there a way to put the version of the parent pom into the sub modules automatically?
Because right now I have to change the version in each module to update the version number. I would like to just set the version number once.
I think if you use the placeholder in the sub modules it works
this looks stupid two times the same generic types
That doesn't seem to exist.
what maven version you using
Is there a quick way to check?
I'm just using what the IDE provides.
Don't think I have an actual version of it installed on the system.
open the terminal on intellij and try mvn -v maybe?
Apache Maven 3.6.3
i got same error
how are you using that method?
try {
Player p = (Player) sender;
if (args.length >= 4) {
String role = args[0];
String roleId = UUID.randomUUID().toString();
Integer position = parseInt(args[1]);
Bukkit.getLogger().info(position.toString());
String prefix = args[2];
String sufix = args[3];
p.sendMessage(RanksAPi.createRole(roleId,role,position,prefix,sufix));
} else {
p.sendMessage("za mało argumentów");
}
} catch (Exception e) {
e.printStackTrace();
}
return true;
}```
is it suffix or sufix?
is there a way to detect if a player has a certain item in their inventory, and then not let them do anything? im trying to create a sort of spawn protection that requires an item(s) to be protected. Protection meaning that they cannot be damaged and they cannot placeblocks/damage other players etc
suffix XD
,sufix) in your statement
what is the exact sql error?
i know there is a PlayerInventory#containsAtLeast
add this to your parent pom
<properties>
<revision>version</revision>
</properties>
forgot lol
idk if it works with materials or itemstacks
it just the name of the of method
then reload project
how would i do this with a specific meta item? like if they have a chest named §aKit Selector
com.mysql.jdbc.exceptions.jdbc4.MySQLSyntaxErrorException: You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near '?' at line
are you sure those are the exact names of the columns?
yes
"CREATE TABLE IF NOT EXISTS roleranager(id VARCHAR(100) not null,name VARCHAR(100)," +
"position " +
"INT," +
"prefix " +
"VARCHAR(100)," +
"sufix VARCHAR(100))");```
i think you want id as a primary key with auto_increment too
Thank you! That's exactly what I needed.
so what i should put there
why rolemanager in the message of MauriceLPs and you use roleranagar?
Care to be more specific? Help with what?
You have us to tell that so we can help you
Again, need to be more specific. We don't know what to look for if you don't tell us what your problem is.
how do i check for an item in the players inventory with a specific name? with color
CREATE TABLE IF NOT EXISTS rolemanager (
id INT AUTO_INCREMENT,
name VARCHAR(100),
position INT,
prefix VARCHAR(100),
sufix VARCHAR(100),
PRIMARY_KEY (id)
);```
not sure if you want 100 as length too
Thx
ItemMeta#getDisplayName(), check if it matches a converted color string using ChatColor#translateAlternateColorCodes();
However, if you are doing item comparisons, it's recommended that you use the PersistentDataContainer.
wha-
Talking to Tobys
oh 😳
My end goal is to check if a player has a 'spawn item' and give them complete protection, so they cannot pickup/drop items they cant interact and they cant be damaged etc
System.out.println 🤔
Build.getPlugin() requires an argument
Well if you use the PDC, you could set a small piece of data onto the item and just check to see if it's there when the player wants 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.
ill explain a bit more (sort of pseudocode)
if player has chest named "&aKit Selector" in inventory slot 1
then prevent player from doing anything
but it requires a parameter, what parameter
im not sure how i would prevent the player from doing stuff, i dont wanna use like 15 eventhandlers
worldguard 
or listeners otherwise ._.
no, because worldguard cant detect if a player has an item and then applies protections
worldguard uses regions or maybe they have like some other features im unaware of
Oh you can register custom flags with worldguard 😄
i see many people calling their main class Main 🥺
listeners then thats not even much work
I'm a little confused by that. Why would you want to prevent the player from doing anything if they have a certain item in the first slot?
Are you intending for the player to right click it and then it do something? Or are you trying to check if the item just exists in that slot?
Wdym aren't effects
Manually searching for them
its sort of like a kit protection, if they have a menu item, then they cant hit other players
?
wha-
Well for filtering out the ones that require data, just check if getDataType returns Void.class. All the non-effect ones you'll probably have to filter out manually.
if they have a menu item in their inventory?
yeah
cant you make the players invulnerable?
Sorry, I'm not familiar with that concept. Is it to prevent players from pvping if they accidentally pull an item out of a GUI that they aren't supposed to?
if a player logs out while I have an item of theirs in a gui, how can I return it to them while they are offline?
prevent players from pvping and damaging/placing if they still have not selected a kit, which would mean they still have a menu item in their inventory
i guess if they join the game, a menu opens?
no they have items in their hotbar
that they dont continue with the previous one
and im trying to check if they have those items they cant pvp
yeah sorry im bad at explaining
its a bit of a weird plugin concept
wdym? items to choose like a server, a kit, etc?
yep
com.mysql.jdbc.exceptions.jdbc4.MySQLSyntaxErrorException: You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near '(id))' at line 1
so when they have that menu, they arent yet in the actual "fight arena"?
@sacred mountain What version are you making this for? I need to know before I suggest something that you might not be able to use.
did you drop the previous table? might be that
dont do if there important stuff in it
It's 1.8, and yes before anyone hates me for it i hate coding in 1.8 too im doing it for some reasons i cant exactly explain
for particles that don't require data, you can do: ```java
Arrays.stream(Particle.values()).filter(p -> p.getDataType() == Void.class);
so when they have that menu, they arent yet in the actual "fight arena"?
yeah
and the plugin im using doesnt seem to have the feature so im making a llightweight plugin as sort of an addon
since the plugin isnt opensource
then just store the players that are waiting in the lobby somewhere and make them invulnerable
if a player logs out while I have an item of theirs in a gui, how can I return it to them while they are offline?
yeah its just the players are meant to drop down from the lobby into the arena so there isnt really a barrier
or a teleportation system
not?
that's not helpful, I have to return it to them
Well, that eliminates the usage of the PDC. 😦 However, the concept I have works the same.
I'd recommend putting some form of NBT on your items. That way you can modify the item and change how it looks if you need to.
Then, you will need a runnable that runs every tick or so. In that runnable, you will just check to see if the player's inventory contains an item that has that NBT in slot 1 and if they do, set them to invulnerable. Then you will need another listener to prevent them from pvping.
i would say use worldguard and make the arena a region with pvp on and disable pvp for the rest
players would be able to drop down from the spawn without a kit then
and hit other players
without a kit
OfflinePlayer doesnt have an get inventory method
my plugin doesnt manage the items, which is why im trying to check for the name of the item
working on players that arent online wont work
Hello, is there any way to detect a tree with spigot? I want to do something so that if a player breaks a tree, i want to know the tree location, the number of wood blocks and then break all of the tree
then set a flag to prevent them from entering the arena if they havent a permission, i would set a permission so they can enter when you choose a kit
thats how i see it
Store the items mapped to their UUID. When they log back in, give them back.
is there a way to teleport them back if they enter the region?
like run a command
That would require the plugin to handle permissions in the first place. Which it likely doesn't
set a flag with worldguard that only a specific group can enter
"permission group"
i'm also thinking about luckperms
wouldnt that just make the player lag back constnatly
I would just use ScoreboardTags to be honest.
When they join:
Tag them "NO_KIT"
If they choose a Kit:
Remove the tag.
When they die:
Add the tag
since theyre falling into the arena
uhm i guess
and not walking into it
that depends on your build
Please think this through. If you do manage to make a plugin like this, you also need to remove the permission node when they die. Otherwise, you have the same issue he is describing.
if they have to jump down probably
i know
i would do it in that way but its probably not ideal for someone else
But he doesn't. That's something that he should probably be aware of.
im tryna make them invulnerable and they cant do things/drop/pickup whilst they have an item, no matter where they are
Dont fiddle around with permissions
he will definitely need worldguard to prevent a user from entering a region
Just use the scoreboard tags
explain
How do I change the spawner's type
ah instead of permission nodes?
like how do i change a spawner's type in the player's inventory
declaration: package: org.bukkit.block, interface: CreatureSpawner
i have to go now, but ill see the mentions when i get back :) thanks for the help so far though
You dont
noice
You can try the following:
- get the ItemMeta of the spawner ItemStack
- Cast it to BlockStateMeta
- get the BlockState of the BlockStateMeta
- Cast it to CreatureSpawner
- set the CreatureSpawners type
- set the BlockState back on the BlockStateMeta
- set the BlockStateMeta back on the ItemStack
If that doesnt work then i got another workaround.
CreatureSpawner#setSpawnedType? what about that
CreatureSpawner is a block
or is that when placed down?
yes
ah what i thought
im trying to change the itemstack
ItemStacks which represent blocks that contain TileEntities posses a BlockStateMeta.
Use this
You can try the following:
- get the ItemMeta of the spawner ItemStack
- Cast it to BlockStateMeta
- get the BlockState of the BlockStateMeta
- Cast it to CreatureSpawner
- set the CreatureSpawners type
- set the BlockState back on the BlockStateMeta
- set the BlockStateMeta back on the ItemStack
You can set the type on an ItemStack, it's just that it won't work in survival. However if you place it down in creative, it will have the proper data.
cast it to CreatureSpawner?
What does it refer to?
The spawner.
blockstate of the blockstatemeta
basicly
when i'm trying to make a spawner pickaxe
that when you breaka spawner
it gives you the right spawner
one moment...
I'm trying to find a way other than storing the type in the nbt and then having a HUGE if statement and then changing the spawner when placing it down
Huge if statement? Use a switch
You wouldn't need a huge if statement. If you store the name of the SpawnerType or whatever it's called, you can just use Enum#value(String name) and if the name is correct, which it should be, you only have one method instead of a bunch of checks.
but still would be ugly
nah
wasn't for that one
thank you !
never thought that entitytype#valueof existed
#valueOf is a default method built into all enums. You can use it on any enum.
yes it has a tilestate
tilestate has #getPersistentDataContainer
save the entity type it spawn in string form in there?
what I'm gunna do is save the spawner.getSpawnedType.toString() to the nbt of the item
nbt? why?
and then on block place change the spawner spawned type to EntityType.valueof
public static ItemStack createSpawnerItemFromBlock(Block block) {
Material blockType = block.getType();
if (blockType != Material.SPAWNER) {
return null;
}
BlockState currentState = block.getState();
ItemStack spawnerItem = new ItemStack(Material.SPAWNER);
BlockStateMeta meta = (BlockStateMeta) spawnerItem.getItemMeta();
meta.setBlockState(currentState);
spawnerItem.setItemMeta(meta);
return spawnerItem;
}
public static void setSpawnerBlockFromItemStack(ItemStack spawnerItem, Block target) {
target.setType(Material.SPAWNER);
if (spawnerItem.getType() != Material.SPAWNER) {
return;
}
BlockStateMeta meta = (BlockStateMeta) spawnerItem.getItemMeta();
CreatureSpawner spawnerState = (CreatureSpawner) meta.getBlockState();
CreatureSpawner currentState = (CreatureSpawner) target.getState();
currentState.setSpawnedType(spawnerState.getSpawnedType());
currentState.setDelay(spawnerState.getDelay());
currentState.update(true);
}
doesnt my method works?
a block that hosts a tile entity
at a location
declaration: package: org.bukkit.block, interface: TileState
?
yes his way makes a lot more sense
it was confusing when he explained it but i understand it perfectly now
it doesnt, i was misinterpreting it
his way doesnt work now?
idk if my approach works. Just threw it together in a min
doesnt seem to be working
Let me check
do something with this
return meta.getPersistentDataContainer().has(IS_INVISIBLE_KEY, PersistentDataType.BYTE);
sec
IS_INVISIBLE_KEY = new NamespacedKey(this, "invisible");
i guess idk
you need an itemstack with material itemframe
get the itemmeta and the persistent data container from it and apply the namespaced key
ItemStack itemFrame = new ItemStack(Material.ITEM_FRAME);
itemFrame.getItemMeta().getpersistentDataContainer().set(new NameSpacedKey(plugin, PersistentDataType.STRING, "invisible"));
idk if it can be chained but i hope it helps
oh you need to set the meta again
its just about knowing that it uses a namespacedkey
if(e.getBlock().getType() == Material.SPAWNER) {
CreatureSpawner creatureSpawner = (CreatureSpawner) e.getBlock();
it gives me an exception
java.lang.ClassCastException: class
there should not be any exceptions for that cuz i verify that it is a creture spawner
does creaturespawner extends/ implements block?
yes
CreatureSpawner is a ? blockstate ? ..
but CreatureSpawner does not extends BlockState
ayo
it extends TileState which extends BlockState
Hey, I have the following problem. I'm trying to connect to an external MySQL database in my plugin, but I cant seem to execute the Command through the command Class (implementing CommandExecutor). If i try to send a request to the database via a public static void main() outside of the class it works fine, but otherwise im getting a "Communication link failure" when I try to execute the command in MC /command.
Could be anything. Did you run the java application on a different machine?
Trying it rn
hello! did anyone find a solution to what im trying to do
to this question
With "them" I assume you mean players
All you need to do is listen to the event of each thing you want to prevent and cancel it
only if they have an item with a specific name in their inventory
can i put event handlers in an IF statement
or should i loop it to constantly check for the item idk
oh yea true
ok
how do i check for an item with a specific name?
like if i wanted to check for e.g.
Chest with name '&aTest Item'
Loop items in inventory:
If item has ItemMeta:
getItemMeta.hasDisplayName:
getDisplayName
Does anyone know what the player.setTime() will do? Will it actually change the day-night cylcle for the player to the chosen time? I'm looking for the best way to kick players from a bed
is there a right way for a cmd to say something to the executer
a teleport seems a good solution
If I teleport the player to his current location, that would also kick him/her from the bed?
I think so
idk the events for that
like what eventhandler
?jd-s I recommend learning to use this
what jvm version do i have to use for 1.18 plugins
17
No
you can use any version you like
I always compile against 1.8 so that 1.16 people can use my plugins too
still works fine on 1.18 servers with java 17
java is backwards compatible (in 99.9% of cases)
The compiler needs to be j17+
mostly because bukkit API is still on java 8
how do you remove an item from player's inventory
like inv.remove() removes every item
i wanna remove 1
get the index of the item and remove it that way
you can remove stuff via index instead of removing all itemstacks of that material
get the index, set the quantity of the item - 1
or you just create the item stack with amount 1 and call https://hub.spigotmc.org/javadocs/spigot/org/bukkit/inventory/Inventory.html#removeItem(org.bukkit.inventory.ItemStack...)
declaration: package: org.bukkit.inventory, interface: Inventory
Hello guys, how can I define block as Concrete, and then get color of this concrete?
if (block.getType() != Material.AIR) {
if (block.getType().toString().endsWith("CONCRETE")) {
Location newL = new Location(world, block.getX() - 1, block.getY(), block.getZ());
newL.getBlock().setType(block.getType());
block.setType(Material.AIR);
// and here, how can I define block as Concrete? Cause something like "Concrete = (Concrete) block.getType();" don't work, cause there's no "Concrete"
Idk_whats_here my_concrete = block.getType();
Bukkit.getLogger().info(my_concrete.getColor());
tak++;
}
Location newL = new Location(world, block.getX() - 1, block.getY(), block.getZ());
newL.getBlock().setType(block.getType());
block.setType(Material.AIR);
tak++;
}
(i'm using spigot 1.18.1)
does Bukkit.getOfflinePlayer work if the player has never joined the server before?
no
@rancid beacon it's not a blockstate, each material has its own color
so how can i get color of block?
seems like an xy problem
it actually might be a block state one sec
it does work
wrong
that does work?
well guess i learned something today then
does it use mojang api to get then?
nope
an OfflinePlayer is just a wrapper for the UUID, basically
BUT
OfflinePlayer#getName() will return null if the player never joined before
🙂
np 🙂
oh wait
the first method I sent, getOfflinePlayer(String name) does indeed to a web request
but the UUID one doesn't
exactly
This method may involve a blocking web request to get the UUID for the given name.
do you have any idea how i can get the color of this block then?
for what?
why do you want the color of the block
Check its block type
to place a new concrete block of the same color as the detected concrete block
public static String getColor(Material mat) {
if(mat.name().endsWith("_CONCRETE")) {
return mat.name().split("_")[0];
}
return null;
}
returns null for everything that's not concrete, or for uncolored concrete
or "RED" or "PURPLE" etc
oh, thanks
LIGHT_BLUE_CONCRETE :D
okay
Will it work for skull owners? I'm assuming yes?
If you’re just replacing the block then just save the block type
No need to manually check or assign
public static String getColor(Material mat) {
if(mat.name().contains("_CONCRETE")) {
return mat.name()
.replace("_CONCRETE_POWDER","")
.replace("_CONCRETE","");
}
return null;
}
this works
I didnt know where to ask this so I'll ask it here.
If anyone has messed around with textures? i'm trying to make my bossbar invisible (the white one) so I can display text without the bar but
whenever I remove the whitebar from the image it goes onto the black bar for some reason?
I've removed all of the bossbars and that works but its not exactly viable for what I want to do.
no, to get textures it'd have to do a web request to mjang api
hehehehe paper has player profile api
the client does the web request
iirc
but if for example it detects concrete block with lime color then if I define new concrete block as detected_block.getType() then it will be white, not lime color
okay, i will try
uhm i doubt
you kinda, put base64 in skull's nbt
I'm pretty sure about that though because all my servers are behind a firewall and skull textures work fine for me
I only allowed 25000...25999
outgoing
the reason why I ask is because on a SP world, you can set the skull owner with just Name & UUID
SP?
ah
and yea you're right
since it doesnt get the name of the player
the server cant fill in the texture
not sure why it needs both
the server doesn't need it
the client needs it
because as I said, the client is the one querying the texture IIRC
and ONLY the name is required IIRC
you can use a random UUID, if you set the correct name, the client will get the texture by name
(I might be wrong though, that's just how I remember how it used to work)
sure it's possible to set custom textures
here's my class for custom heads etc
WHY
THE FUCK
does recipe not implement Keyed
I know why. because ALL recipe subclasses implement Keyed EXCEPT for MerchantRecipe
but
why doesn't MerchantRecipe implement it too
@sullen marlin why doesn't MerchantRecipe implement Keyed D:
removing ones plugin's recipes is more complicated then it should be imho lol
private void removeOldRecipes() {
Iterator<Recipe> it = Bukkit.recipeIterator();
NamespacedKey dummy = new NamespacedKey(this,"dummy");
while(it.hasNext()) {
Recipe next = it.next();
if(!(next instanceof Keyed)) continue;
Keyed keyed = (Keyed) next;
if(!keyed.getKey().getNamespace().equals(dummy.getNamespace())) continue;
it.remove();
}
}
does any one know how to cancel "InventoryCloseEvent"?
So uh? Gradle just stopped wanting to work, and has this error, it was working before yesterday.
I made an npc but he wont spawn with the specified pitch, i can only change if he looks up or down
private static byte getConvertedRotation(float a) {
return (byte) (a * 256f / 360f);
}
PlayerConnection connection = ((CraftPlayer) player).getHandle().b; // weird mojang name for PlayerConnection
DataWatcher watcher = npc.ai();
watcher.registrationLocked = false;
watcher.b(new DataWatcherObject<>(17, DataWatcherRegistry.a), (byte) 127);
connection.a(new PacketPlayOutPlayerInfo(PacketPlayOutPlayerInfo.EnumPlayerInfoAction.a, npc));
connection.a(new PacketPlayOutNamedEntitySpawn(npc));
connection.a(new PacketPlayOutEntityHeadRotation(npc, getConvertedRotation(npc.getBukkitYaw())));
connection.a(new PacketPlayOutEntityMetadata(npc.getBukkitEntity().getEntityId(), watcher, true));
Bukkit.getServer().broadcastMessage(npc.dm() + " - " + npc.dn());
connection.a(new PacketPlayOutEntity.PacketPlayOutEntityLook(npc.getBukkitEntity().getEntityId(), getConvertedRotation(npc.dm()), getConvertedRotation(npc.dn()), true));
```
any one?
me too
i mean just resend the Inventory
if it was a chest
but if its the inventory, then i think there is no way to force open it
as the inventory is, if i call correctly, handled completely client sided
and you cant force open it or listen for it to open
Delay it by a tick
You cannot cancel inventorycloseevent
how
?scheduling
public class OnPlayerCloseInventory implements Listener {
@EventHandler
public void Event(InventoryCloseEvent e){
if(e.getView().getTitle().equals("Pick Nation")){
if(PlayerData.HasPlayerData(e.getPlayer().getUniqueId())){
if(PlayerData.GetPlayerData(e.getPlayer().getUniqueId()).IsInNation == false){
e.getPlayer().openInventory(e.getView());
}
} else {
Objects.requireNonNull(Bukkit.getPlayer(e.getPlayer().getUniqueId())).kickPlayer("Did Not Found Player Data");
}
}
}
}```
Yeah delay the openInventory call using schedulers
any one?
i dont know about npc's stuff
rip
I do, just a sec.
I remember having the same issue. Need to look back at how I fixed it.
do it 1 tick later
mfw smh
in PlayerBucketFillEvent does e.getItemStack() not give you the actual item stack
because the item stack has nbt data
but when i check for it
it doesnt work
Bukkit.getScheduler().runTaskLater(yourPlugin, () -> {
e.getPlayer().openInventory(e.getView());
}, 1);
and
PLEASE
USE PROPER VARIABLE NAMES
"e" is NOT a proper variable name
------------------> https://blog.jeff-media.com/give-your-variables-descriptive-names-ffs/
Okay yep, you need to delay the connection.a(new PacketPlayOutEntityHeadRotation(npc, getConvertedRotation(npc.getBukkitYaw()))); by a tick.
Are Still People using e for Event?
You can just use runTask for 1 tick delays btw
80% of people do that
Just why
no
Yes 😄
runTask runs it on the same tick
runTask runs on the same tick
but after everything else was done
but yeah, runTask would work too
I mean it's not like it really matters 
it doesn't, but at least I learnt sth new today :3
True!
it sadly still only looks up and not to the side https://i.imgur.com/xpniSav.png
?paste your code again
PlayerConnection connection = ((CraftPlayer) player).getHandle().b; // weird mojang name for PlayerConnection
DataWatcher watcher = npc.ai();
watcher.registrationLocked = false;
watcher.b(new DataWatcherObject<>(17, DataWatcherRegistry.a), (byte) 127);
connection.a(new PacketPlayOutPlayerInfo(PacketPlayOutPlayerInfo.EnumPlayerInfoAction.a, npc));
connection.a(new PacketPlayOutNamedEntitySpawn(npc));
Bukkit.getServer().getScheduler().scheduleSyncDelayedTask(LobbySystem.instance.getInstance(), new Runnable(){
@Override
public void run(){
connection.a(new PacketPlayOutEntityHeadRotation(npc, getConvertedRotation(npc.getBukkitYaw())));
}
}, 1);
connection.a(new PacketPlayOutEntityMetadata(npc.getBukkitEntity().getEntityId(), watcher, true));
Bukkit.getServer().broadcastMessage(npc.dm() + " - " + npc.dn());
connection.a(new PacketPlayOutEntity.PacketPlayOutEntityLook(npc.getBukkitEntity().getEntityId(), getConvertedRotation(npc.dm()), getConvertedRotation(npc.dn()), true));
```
What happens if you remove the EntityLook packet at the end
Also use runTask instead of scheduleSyncDelayedTask
Get rid of the , 1
Are you sure you're reloading it properly
yes

i reload + rejoin
bruh nobody wanna help
Have you tried turning it off and on again
Are you respawning the NPC?
Most of the time /reload is a bad idea :p
getItemStack should work fine
no idea what you mean but i dont think so
it doesn't work
ima try that gimme a sec
You need to re-send the packets.
Yeah, restart and try
yea i do that
because when i check for nbt data it doesnt say yes
Well try restarting lol
it resends the packets when i rejoin
?paste your code
public void onWaterPlace(PlayerBucketEmptyEvent e) {
e.getPlayer().sendMessage("1");
if (PickupBucketWaterEvent.prevents.contains(e.getPlayer().getUniqueId())){
e.setCancelled(true);
return;
}
e.getPlayer().sendMessage("2");
ItemStack bucket = e.getPlayer().getItemOnCursor();
NBTItem nbti = new NBTItem(bucket);
if(nbti.hasNBTData() && nbti.hasKey("CustomItemKey")) {
e.getPlayer().sendMessage("3");
if(nbti.getString("CustomItemKey").equals("DolphinBucket")) {
e.getPlayer().sendMessage("4");
e.setCancelled(true);
bucket.setAmount(bucket.getAmount()-1);
Player player = e.getPlayer();
player.getInventory().addItem(new ItemStack(Material.BUCKET));
e.getBlock().setType(Material.WATER);
player.getLocation().getWorld().spawnEntity(e.getBlock().getLocation(), EntityType.DOLPHIN);
}
}```
oh my bad but yes i did try with get item stack
Try it again 😄
still didnt work
I will
so i should just restart until it works?
oh ok
Talking to Fenzy to try getItemStack again lol
oh lol
Yes that is exactly what you should do :) /s
yup still not working
Mjanko try just sending the PacketPlayOutPlayerInfo and the delayed HeadRotation
And comment out all the other ones
So it prints 2 and not 3
Ctrl + /
Print your itemstack before checking and see what it says. My guess is that your ItemStack just doesn't have that key.
that's what a thout
now its gone
getItemStack returns a bucket everytime
a normal bucket
Lmao yes
Lol send what you're doing now Mjanko
i'm not even using a bucket and it returns a BUCKET
normal bucket
i'm using a salmon bucket
You know you're checking PlayerBucketEmptyEvent right?
Of course it's always empty lol

Ahhh
okay then what should i use @hasty prawn
You should switched to remapped Mjanko it's going to make working with NMS a million times easier
thank you very much
ur welcome
i tried that 3 times now
and i was always defeated by it
PlayerBucketFillEvent, if you're using trying to listen for when you fill it.
no im trying to listen for when i place it down

im making a dolphin bucket
how can you remove a value from a hashmap?
i thought it was hashmap.remove(key), but i dont see the option show up
. . .
wait is the thing on the right for return values?
yes
remove (with no value argument) returns the value that was removed from the map
why would it return ConfigManager if i was just removing a value
oh
so i can just ignore the return value
yes
remove with a value argument returns whether or not the value was actually removed
is there a way to add CanBreak to an itemstack?
create own itemstack class
that extends itemstack
Or idk if you can add flags to an itemstack, i think its possible
Not through the API. I wrote a PR for it a while ago but it never went through because I was too busy
It's one of those things nobody ever finalized API for
what is CM?
a hashmap
queue the naming convention comments
that's what i was thinking
CM is NOT a map
well is CM a static final variable? :)
please show your definition of CM?
public Map<Player, ConfigManager> CM = new HashMap<>();
cm*
where's the problem? 😛
there isnt one
There was no problem he misunderstood what remove meant because of the return type being on the far right of IDEA's code completion.
oh ok
no i misunderstood that the remove event returned a vlue and mistaked it for a different method
That's what I said
In plugin.yml, for the command usage section, what's the convention for optional command arguments? eg how to communicate that the player in "/kill <player>" is optional?
gotcha maybe like uh "/kill <optional: player>"?
that could work too
Usually its communicated like this:
/command <argument> <argument> [optional] [optional]
Pls dont expose data structures
i just use [] as optional and <> as required, and have an info message above my usage telling them this
for example
oh that's pretty
isnt it?
I'mma steal that style in the future thanks
haha, feel free
monke
Hi, I'm using Vault in my server, and now I've added it as a Dependency in my plugin. But it won't work as it can't find Vault in my plugins folder orso. I've exactly this code in my plugin, https://github.com/MilkBowl/VaultAPI. And yes, I've added Vault in my plugin.yml. And Vault is in my server
Does vault come up if you type /pl ?
How does this "won't work as it can't find Vault" manifest?
?paste
"Disabled due to no Vault dependency found!"
well sounds like vault is either not in your deps or you misconfigured your plugin.yml
depend:
- Vault```
<repositories>
<repository>
<id>spigotmc-repo</id>
<url>https://hub.spigotmc.org/nexus/content/repositories/snapshots/</url>
</repository>
<repository>
<id>sonatype</id>
<url>https://oss.sonatype.org/content/groups/public/</url>
</repository>
<repository>
<id>jitpack.io</id>
<url>https://jitpack.io</url>
</repository>
</repositories>
<dependencies>
<dependency>
<groupId>org.spigotmc</groupId>
<artifactId>spigot-api</artifactId>
<version>1.17.1-R0.1-SNAPSHOT</version>
<scope>provided</scope>
</dependency>
<dependency>
<groupId>org.projectlombok</groupId>
<artifactId>lombok</artifactId>
<version>RELEASE</version>
<scope>compile</scope>
</dependency>
<dependency>
<groupId>com.github.MilkBowl</groupId>
<artifactId>VaultAPI</artifactId>
<version>1.7</version>
<scope>provided</scope>
</dependency>
</dependencies>```
Paste your class that checks for vault pls
What do you mean?
like, the plugin is running at runtime in your server
and that is its name
also what smile sad
private boolean setupEconomy() {
if (getServer().getPluginManager().getPlugin("Vault") == null) {
return false;
}
RegisteredServiceProvider<Economy> rsp = getServer().getServicesManager().getRegistration(Economy.class);
if (rsp == null) {
return false;
}
econ = rsp.getProvider();
return econ != null;
}```
And in my onEnable:
```java
if (!setupEconomy() ) {
System.out.println("Disabled due to no Vault dependency found!");
getServer().getPluginManager().disablePlugin(Main.getInstance());
return;
}```
Do you have a plugin installed that provides a Economy.class?
Something like Essentials you mean?
Sure
RegisteredServiceProvider<Economy> rsp = getServer().getServicesManager().getRegistration(Economy.class);
This ovsly returns null if there is no plugin that actually provides the Economy service
hello, i am making a toggle command that changes a boolean to true or false to use in my listeners class, is there a more optimized or better way to do this?
main class:```java
public final class Main extends JavaPlugin {
public static boolean toggle = false;
@Override
public void onEnable() {
System.out.println("Hello world!");
getServer().getPluginManager().registerEvents(new BreakBlock(), this);
getServer().getPluginManager().registerEvents(new MobSpawns(), this);
}
@Override
public void onDisable() {
// Plugin shutdown logic
}
}```
command class: ```java
@Override
public boolean onCommand(CommandSender sender, Command command, String label, String[] args) {
if (args[0].equalsIgnoreCase("on")) {
if (sender instanceof Player)
Main.toggle = true;
} else if (args[0].equalsIgnoreCase("off")) {
if (sender instanceof Player)
Main.toggle = false;
}
}```
Dont use public for this and dont use static
alrighty
private is better in most situations for fields
public is mainly reserved for constants like public static final CONSTANT_VALUE = 6;
okay, beginner to java and spigot stuff so thanks for the help!
Write a class like:
public class PluginOptions {
private boolean toggled = false;
public boolean isToggled() {
return toggled;
}
public void toggle() {
this.toggled = !this.toggled;
}
}
Then have one single instance of it and pass it to other classes that need it.
like this?
command class:```java
package me.mrhonbon.opmobs;
import org.bukkit.ChatColor;
import org.bukkit.command.Command;
import org.bukkit.command.CommandExecutor;
import org.bukkit.command.CommandSender;
import org.bukkit.entity.Player;
public class MobSpawnCommand implements CommandExecutor {
private boolean isToggled;
@Override
public boolean onCommand(CommandSender sender, Command command, String label, String[] args) {
if (args[0].equalsIgnoreCase("on")) {
if (sender instanceof Player)
sender.sendMessage("Overpowered Mobs has been enabled.");
this.isToggled = true;
} else if (args[0].equalsIgnoreCase("off")) {
if (sender instanceof Player)
sender.sendMessage("Overpowered Mobs has been disabled.");
this.isToggled = false;
}
}
}```
Nope. This makes it really hard to share the "isToggled" property
You need a shared instance.
I think he need an Object

I dont... what? Thats basically the same
Take a look at the PluginOptions class ive posted above.
You would create a single instance of that class in your onEnable,
then pass the same instance to your Listener and to your CommandExecutor.
Now both have the same instance. So if one changes the state of this instance
then everyone also possessing this instance will be able to see those changes.
ohhhhh okay i think i get what you're sayin
public class PlayerOption {
private static Map<UUID, Option> options = new HashMap<>();
public static Option getOptions(UUID uuid) {
return options.computeIfAbsent(uuid, option -> new Option(true));
}
public static class Option {
private boolean property;
public Option(boolean property) {
this.property = property;
}
public boolean getProperty() { return property; }
}
}
There you have a simple example
What the
wha
Verano you sober or not? (Just good to know)
LOL
Idk I think he was drunk once here before
So asking out of curiosity just to make sure
Im depressed only
Yes. I would advise you just to ignore that for now. I think you got the idea right.
Implement it and then update us.
i will try my hardest, bare with me 😁
What the problem with that?? Its a simple Object and Object Manager
Let say the one which contains the Map, allow you to add/remove the object
So a repository?
Not a problem but the Option class is just a glorified Boolean?
He?
Explain again
My brains has exploded
I mean you could literally use sth like the type Boolean instead
This is static abuse. Your Option class is also just a weak wrapper for a primitive which makes it virtually useless
Yeah the Option type doesn't say anything about the actual option
Just whether or not it's true
I dont use like that. I have separate the Repository and the Object
And that also means there's only one option for a player, which is not extensible.
But for example i doit together
Don't write useless code just for the sake of it existing :p
Why one option?? You can add more things to the Object 🤔
So let forget he already solve his problem. Any scoreboard api recommendation without Reclections i hate them
Every scoreboard api on github works with them i dk why
Should be more of a Map<UUID, List<Option>>
Which is bad because nested collections.
So you would write a new class "OptionDomain"
and then use a Map<UUID, OptionDomain>
Yeah
How i use man
BTWW
Look
Omg
Because it's a map
of UUID -> Option
a single option
only one option
you'd need a list of Options
but then you'd not be able to differentiate the options since it's just a wrapper around a boolean
I’d say nested collections might be fine if they stay strictly within the concretion smile, thoughts?
Multimap is still nicer than nested collections
Ya
I would recommend using Guava in your plugins since Minecraft depends on it anyway
Hm. Sure if they are not exposed and you need a more generic approach (if you wanted to use ArrayLists and LinkedLists for example)
then nesting collections might be fine.
Yeah, probably depends very much on scenario, just need to hear someone else agree upon it :>
Its exactly the same, the only things as an example i do it all together
This i what i use for my Global Core
Well... here it actually makes sense.
With the previous example the addition of an Option was legitimately pointless and just served to add noisiness.
I am not apologizing, I'm saying that this is a better use case for a custom DTO.
Why do you have protected final fields + public getters...
Can i take your SocreboardAPI from gth? I cannot understand how to create one
I don't have a scoreboard API
Oh :(
You just depressed more than i am 😮💨
Field access for subclasses = speed 🤡
He always does it though
Yes. Clown face indeed.
I agree
neva’ 😔
Yeah, I agree too that that is in fact what you do
But I don't agree that it's a good idea
Someone here told me that its not wrong
Cuz it intended to use to protect field access
It's not wrong for classes that are designed to be inherited
It is terribly wrong for classes that should never be inherited or are designed not to be (like data classes)
I mean usually we want to code defensively by restricting ourselves and surrounding ourselves with + by abstractions Verano 
You should change the way you code :p
Module as?
Cuz it will have 2 plugins Bungee side and Spigot side
You'd want 3 modules probably
So i would have to create a core and them implement it on the sides right?
Multiple gradle modules? Multiple java modules? Or just multiple layers?
common, spigot, and bungee
Allright thanks
MaVeN
Gradle ZZZ
I'm not gonna get into this debate again we've argued about Maven and Gradle like 25 thousand times
Lol conclusion gradle wins 8)
This is bait
Stop sending out provocations and it gets easier to ignore :p
I know it but im tempted
Smile stop resisting the inevitable 
Proovcations? Lol i never send nude photos
...
Im a gradle user now anyways...
that is not what "provocation" means

That what google yet translator said
But not what you meant
action or speech that makes someone annoyed or angry, especially deliberately.
That’s one definition
There’s also things like a provocative image
Etc
A provocative gesture
well I don't think "provocative" applies just to sex
He’s running everything through a translator
So sometimes he gets the wrong definition
to elicit a response from someone

be it HORNY, angry, sad, etc.

His translator translated it into a word without those multiple meanings
No horny here
No horny ⛔
It’s very indulging when people know the rules
I don't know the rules

I didn't actually read Spigot's rules
I just assumed they were the same copy-paste shit like
"no committing murder"
and
"no jaywalking"
In short it’s just common sense
Yes
Man I hate jaywalkers
You know how annoying it is as a driver to have to constantly look for idiots crossing at random parts of the road?
i apologize if this is taking too long, im still learning java and how OOP works and such
bare with me 😁
Yeah no worries, the concept isn’t trivial at first
Especially when you also learn the semantics of the language
Right? They always cross when im far away so i have to accelerate in order to reach them in time...
People what difference betweeen:
getCollection("test").updateOne(Filters.eq("uuid", uuid), document, new UpdateOptions().upsert(true));
getCollection("test").updateOne(Filters.eq("uuid", uuid), new BasicDBObject("$set", document));
I cannot understand then
thanks for understanding conclure 😄
10 points
Well truth be told, I was once in your position myself, so I know how it feels
We all were at some point
idk how the law is in your state, but in my state in a round about, there are no lights to tell drivers when to stop and when walkers can walk, drivers simply have to yield to people crossing
Humans are just moving speedbumps
which i think is kinda stupid
Does mongo have support for java driver or at least a channel for asking about their driver?
Upsert updates every part that has changed. It can be optimized by the db.
Set just ingores old values and writes everything into the collection.
Supposedly not all learn oop by java but yeah mostly speaking
So uptsert it better?
Mine is actually sane, right of way doesnt just default to pedestrians
Java is probably the best way to learn OOP
^
So if they do something stupid and I hit them, they can be found at fault for the accident
LUCKY
I think C# its easier
Anyone who learned otherwise just had it worse 
Eh. Sure. Probably not much of a difference in most cases.
Yeah tho it seems most people who learn it starts by going insanely procedural 
C# is a better language but it has a lot more syntax and features
My university teaches it in Java for 1 class and then the rest is C++
okay here is my confusion
plugin options class:```java
package me.mrhonbon.opmobs;
public class PluginOptions {
private boolean toggled = false;
public boolean isToggled() {
return toggled;
}
public void toggle() {
this.toggled = !this.toggled;
}
} main class:java
package me.mrhonbon.opmobs;
import org.bukkit.plugin.java.JavaPlugin;
public final class Main extends JavaPlugin {
private PluginOptions pluginOptions = new pluginOptions();
@Override
public void onEnable() {
System.out.println("Hello world!");
getServer().getPluginManager().registerEvents(new BreakBlock(), this);
getServer().getPluginManager().registerEvents(new MobSpawns(), this);
}
@Override
public void onDisable() {
// Plugin shutdown logic
}
}
Allright thanks!
am i close?
Time to Rust/C it up
For long code its recommend using ?paste
My intro to programming class at this uni was C 

wtf
