#help-development
1 messages ยท Page 1348 of 1
then there's d .-. do we talk about d
I mean C# has some very very nice features. Like delegates. Or the fact that there is not type erasure of generics.
LOL
But i also dont like the conventions of C#...
But you cant tell me that anyone writing Java understands this:
how would i call multiple events in a method
But thats more C than C++
What do you mean by that? You normally dont call events yourself.
well
For example, a combat log plugin
onPlayerPunch {
onPlayercommand.cancel
onPlayerlogout.kill
}
??
bruh wot
its not real java code its just an example
@quaint mantle hold up i show u how its done
Ok
You don;t call events, you listen to them
Store the tagged player.
I think he wants it to be when a player is punched if they combat log they die and they can't run commands
Yeah
Is that with UUIDs
Oh ok. Then go with what aglerr told you.
Tag the player. You can use the scoreboard tags for that.
So, when the player is punched, put the player in like an array list, and listen for other events, and if the player from that event is in the array list cancel the event
ah
Yes, you can do that using UUID.
public void onPlayerPussyPvp(PlayerCombatLogEvent event)
{
Player player = event.getPlayer();
if (player.getWorld().getUID().equals(Plugin.ArenaMan.ArenaWorld))
{
UUID uid = player.getUniqueId();
tellEverybody(player.getName() + " is a b**ch");
}
}```
^ u need pvpmanager plugin api for this to work doe
ty
ohh ty
This would be an example for tagging:
private static final String COMBAT_TAG = "_IN_COMBAT_";
public void tagPlayer(final Player player) {
player.getScoreboardTags().add(COMBAT_TAG);
}
public void unTagPlayer(final Player player) {
player.getScoreboardTags().remove(COMBAT_TAG);
}
public boolean isTagged(final Player player) {
return player.getScoreboardTags().contains(COMBAT_TAG);
}
You don't need to use scoreboards!! Overcomplicated
๐ฎ oh shit wut are those
ah yeah
Scoreboards are too complicated you don't have to use those
looks simple enough
What would be simpler than just adding a String to a Set?
Ig if you think so
i thought scoreboard was that display on the right side of screen that some servers have
Store uuids in an arraylist
Yeah. Have fun with O(n) time complexity for contains...
and remove
And no persitence
The ScoreboardTags are persistent
Why would it need to persist after a restart if it's a combat log prevention plugin?
They are not in combat after a restart lol
You have a combat log of 5min -> Server restarts but you dont want to kill everyone that is in combat but maintain the combat log tag after restart
๐ฎ ok i didnt think of that 1, smart
Apologies. Resending this message as I forgot to add other bits of code..
Does anyone know how to fix a player skull being off center on the block it was placed?
The issue:
The code:
public static void setBlockToCoconut(Location location, String texture) {
Block block = location.getBlock();
block.getChunk().load();
block.setType(Material.SKULL);
changeSkin(block, texture);
}
public static void changeSkin(Block b, String texture) {
if (b.getType() == Material.SKULL) {
Skull skull = (Skull) b.getState();
skull.setRotation(BlockFace.SOUTH);
skull.setOwner("Demonly");
skull.setSkullType(SkullType.PLAYER);
GameProfile profile = new GameProfile(UUID.randomUUID(), null);
byte[] encodedData = Base64.encodeBase64(String.format("{textures:{SKIN:{url:\"%s\"}}}", texture).getBytes());
profile.getProperties().put("textures", new Property("textures", new String(encodedData)));
try {
Field profileField = skull.getClass().getDeclaredField("profile");
profileField.setAccessible(true);
profileField.set(skull, profile);
} catch (NoSuchFieldException | IllegalAccessException e) {
e.printStackTrace();
}
skull.update(true);
}
}
chat = :nuke:
public void onBreak(BlockBreakEvent e) {
Player p = e.getPlayer();
if(!p.hasPermission("break.break"));
e.setCancelled(true);
}
@EventHandler
public void onPlace(BlockPlaceEvent e) {
Player p = e.getPlayer();
if(!p.hasPermission("place.place"));
e.setCancelled(true);
}
}``` Hey, can anyone help.. Even If I had the permission I can't break / place
^^
Did you give yourself the perm
add/remove 0.5 to x/z coordinates until it looks right
Yes
Learn how to use If statements.
I'm not using it correctly?
No
You put a semicolon
Will attempt thanks
I believe
@rapid vigil remove semicolon at end of if and for the love of god start reading ur ide's warnings
good luck :3
Sorry...
ide warnings cover shit like this lol
if(!p.hasPermission("place.place"));
e.setCancelled(true);
to
if(!p.hasPermission("place.place")) {
e.setCancelled(true);
}
Or this one (but the other one is preferred)
if(!p.hasPermission("place.place")) e.setCancelled(true);
Rly? IntelliJ doesnโt tell me when I put a semicolon after an if
ive been warned bout bad semicolons but tbh idk if it was on a if or somethin else
What's the difference between ); and ) { ?
mighta been somethin else LOL if so nvm poreyy
); no work
oh, So It won't read the "set.Cancelled(true):" ?
Nope
and { will read the under line?
eyy guys i'm having a little problem
then i loop storage enchants it loops every past enchant for example
i combined enchants on enchant book 2 times x 4 sharpness and... i want sharpness 5 enchant
Yes
it will but even if the If is false
Thanks for help a lot, I appreciate that
i want the combind enchant number any easy way to do this?
Hey guys I have a plugin that runs off a Map of objects that gets saved to a file when the server shuts down. One problem I have ran into is when the server is forced close I lose all the data on the map because it wasnt shut down and didnt call the on disable. Is this something that a server can go through or is this only something I can do locally. Also if it is something that I need to watch for would the solution be a timed backup of everything that gets recorded every hour or so?
If the server crashes, nothing you can do, but you can do timed backups
thread auto save?
what arguments does tagPlayer take in?
player.getScoreboardTags().add(COMBAT_TAG);
}
public void unTagPlayer(final Player player) {
player.getScoreboardTags().remove(COMBAT_TAG);
}
public boolean isTagged(final Player player) {
return player.getScoreboardTags().contains(COMBAT_TAG);
}
@EventHandler
public void onLogOut(PlayerQuitEvent event) {
Player player = event.getPlayer();
if (tagPlayer() = true) {
}
}```
A player
?paste
Please
And yes please use paste
ok
I put Player player = event.getPlayer
and tagPlayer(player) doesn't work
u kinda have to know java..
And also that's not the correct way to check If player is tagged or not.
did not work
attempted 0.5+- in every combo on all 3 coords
Make an Arraylist?
check if Arraylist contains player?
yeah thats my current plan of action
Dont. You will have the same player in there multiple times. If you check contains before adding your will have O(2n) time complexity which is really bad
how can I use a PlaceholderAPI placeholder in the a field/b field of the tablist?
I've tried several different methods, but can't figure it out.
you will have O(2n) time complexity ? wut you mean
You need to parse the String and let PlaceholderAPI replace the placeholder. Then use the resulting String. PlaceholderAPI doesnt automatically scan every String in the JVM heap (obvsly)
It means that an ArrayList scales really bad when using contains or remove operations.
Is a Set fine for that?
Set<UUID> would probably be the choice
really never knew hmm ๐ค
then what would better then an Arraylist?
It kinda have a same concept with ArrayList.
For contains and remove? Pretty much everything else thats not array backed.
// Placeholders class
private static Player player;
public static void setPlayer(Player player) {
GetPlayerCount.player = player;
}
public static String bungeeCount() {
String bungeecount = "%bungee_total%";
return PlaceholderAPI.setPlaceholders(player, bungeecount);
}
// Tablist class
b.set(packet, ".....Network: " + Placeholders.bungeeCount)
}
I have something like that, doesn't hook, the player thing i've added was a test which didn't work (it's called on PlayerJoinEvent and it adds the latest player as the player as a test, which did not work
the b set is in a ChatComponentText
its just simplified
Did you download the required Placeholder from the ecloud?
Do you regularly re-send the header/footer?
And do you replace the String each time you send the tablist header/Footer?
okay yeah wait its not replacing
How do I make 2 permissions for a command
if(player.hasPermission(x) && player.hasPermission(y))
Then do ||
||
Yeah thanks.
if(!sender.hasPermission("tp.tp" || !sender.hasPermission("tp.tps")))
That gives me error
Your missing a ) after the first permission
if(!sender.hasPermission("tp.tp") || !sender.hasPermission("tp.tps"))
Try that
Also:
! (NOT || NOT) -> ! IS && ! IS
So
if(!sender.hasPermission("tp.tp") && !sender.hasPermission("tp.tps"))) { //prevent command }
its replacing now but that doesnt solve the placeholder issue
Thanks 7smile7!
The two screenshots are not related.
dont use legacy components
it is
mfw not even using Components
me?
you should be using bungee api components
what you are using has been depricated by mojang since 2012
i would recommend kyori/adventure but you should at least use BaseComponents
a bit of the bungee api is in spigot
sorry i dont understand what you mean, im not making a bungee plugin
What does CC.translate return?
Remove the ) after the &e" then add it at the end of the line
thanks
Hey guys Ive been trying to look online how to solve this issue and I cant seem to find anything on it. I would assume I need to download the latest jar and throw it somewhere in the plugin but I dont know where exactly it is stored in the plugin files. Will anyone be able to help me out?
[11:10:24 WARN]: [NBTAPI] [NBTAPI] The NBT-API at 'package de.tr7zw.nbtapi' seems to be outdated!
[11:10:24 WARN]: [NBTAPI] [NBTAPI] Current Version: '2.6.0' Newest Version: 2.7.1'
[11:10:24 WARN]: [NBTAPI] [NBTAPI] Please update the nbt-api or the plugin that contains the api!
Do you have NBTAPI as a dependency?
Your own plugin?
Do you have any dependencies of which one depends on NBTAPI? You can look that up by showing the dependency tree
ok I see its a different plugin its not on loadup its only when I place a block thats why ive never seen it before
Always have a clean test environment with only your plugin and your dependencies
a doubt, defining a variable a position of the player's camera with a defined pitch and yaw and defining another variable with a different position, can I define a vector between these two points and get the maximum of the vector reached?
Should I keep a mysql connection open if I will constantly be writing and reading when a player joins/leaves and for an interval too?
use a connection pool, like hikaricp
yeah
Hey! I have a question.
I'm trying to find the Velocity required to launch the player to an exact location that I know. to do this I needed to do calculations for projectile motion. I did so and it didn't work, so I researched a bit and found out that there's a 2% drag added to the player's velocity (I think) so I calculated the equations using the last way and then added 2% of the velocity back to the velocity (that might have been a wrong thing to do so that's why I need help) but I still can't get it to work.
If anyone knows how to do this, I'd be happy to hear it.
you might find it tricky applying a velocity directly to a player, as they will be subject to stuff like anti-cheats and the client themselves moving, you might want to consider having them riding another entity (like an arrow or something) to simplify your calculations and prevent movement
I'll check it out, thanks!
Quick question: is there any way to disable mobs like skeletons from climbing up ladders in 1.16, just curious
@unreal quartz Would you suggest I use this? https://www.spigotmc.org/threads/tutorial-implement-mysql-in-your-plugin-with-pooling.61678/
looks fine to me
awesome
I was asking it but i will do it againd because i dont uderstand D:
Defining the constructor in your listener
public MyListener(JavaPlugin plugin)
and then when you instantiate a new listener in the main class extending JavaPlugin
new MyListener(this)
which bit don't you understand
What am i suuposed to write in main and wchich in Listener
I tried bot combination and none woreked
do you know what a constructor is?
Not really
He probably copied it from a tutorial
it is called when instantiating a new class, which is what you do when you use the new keyword
Do you think this would be a correct implementation of hikari?
https://paste.md-5.net/mirubofote.java
it looks like this (what you wrote)
public MyListener(JavaPlugin plugin) {}, basically a method with no return type
so in this case the constructor would go in the listener class (again, what you wrote), and it accepts an instance of your main class as an argument
Co i wrote my Listener
public class ZbozeListener(JavaPlugin plugin) implements Listener {
@EventHandler
public void onBreak(final BlockBreakEvent event) {
final Block block = event.getBlock();
if (block.getType() != Material.WHEAT) {
return;
}
final Ageable ageable = (Ageable) block.getBlockData();
if (ageable.getAge() != ageable.getMaximumAge()) {
return;
}
Bukkit.getScheduler().runTask(this.pluginInstance , () -> block.setType(Material.WHEAT));
}
}
i want death
yes that wont even compile
public class ClassName implements Listener {
public ClassName(JavaPlugin plugin) {
// do something with plugin
}
// ...
}```
this is an example of a constructor, to instantiate a class of this type you would need to do `new ClassName(/* instance of JavaPlugin */)`, I would suggest you learn a bit of basic java before jumping into spigot
so eventhandler shoul be in wchic bracket
@distant fern You did something that I would never expect anyone to do, but you put the.... I don't know what to call it... when you defined the class... remove "(JavaPlugin plugin)" and inside of your actual class I want you to put this:
private YourMainClass plugin;
public ZbozeListener(YourMainClass plugin) {
this.plugin = plugin;
}```
Class scope. Annotation target is method.
but please learn java
^
@unreal quartz
what does synchronized (plugin) do
Its basically an implicit lock on that field.
So if another thread currently uses that variable (by calling a synchronized block) then the current thread waits until the lock is released.
what event would i use to detect only when the players block changes, then get the block theyre walking over?
PlayerMoveEvent
What do you mean by "when the players block changes". A player doesnt have a Block.
Implicit?
Hey guys, anyone got a link to a tutorial/forum post on making custom sounds w/ a resource pack?
Oh. Yeah. Then PlayerMoveEvent
this is what i have rn, but all it does is tp the player down whenever they look or move:
@EventHandler
public void playerMoveEvent(PlayerMoveEvent event) {
Player p = event.getPlayer();
Location loc = event.getTo();
Location loc2 = loc;
loc2.subtract(0,1,0);
Block block = loc2.getBlock();
BlockData data = block.getBlockData();
Material newBlock = data.getMaterial();
p.getInventory().addItem(new ItemStack(newBlock));
}
}```
Yes. You dont have an actual Lock object that can be acquired. (unless you synchronize on a lock)
Ah
PlayerMoveEvent is called when the player looks around
You synchronize on a specific Object but the Object is not the lock.
I get what you mean
so is it good to use synchronized for database management? ๐ค
there might be an option in the event, lemme just have a look
yes, to avoid race conditions
Though choosing the right data types is more important for that
Ok I think what you have to do is just compare the player's position
ok
the event has .getTo() and .getFrom()
thats what i thought i would do
and then how would i get the block theyre working on?
from is the position they were in, to is the position they're going to
Something like this should work.
@EventHandler
public void onMove(final PlayerMoveEvent event) {
final Location from = event.getFrom();
final Location to = event.getTo();
if (to == null) {
return;
}
final int fromX = from.getBlockX();
final int fromY = from.getBlockY();
final int fromZ = from.getBlockZ();
final int toX = from.getBlockX();
final int toY = from.getBlockY();
final int toZ = from.getBlockZ();
if (fromX == toX && fromY == toY && fromZ == toZ) {
return;
}
System.out.println("Player walked from [" + fromX + "|" + fromY + "|" + fromZ + "] to [" + toX + "|" + toY + "|" + toZ + "]");
}
getTo could be null? 
Yes
lemme try that
How can I make an ItemSteck that gets a certain players head?
Location has getBlock()
so just get the location below the player by subtracting one from the y axis
then call getBlock()
the one their feet is in I'd assume
Player#teleport
you can use Location.setWorld()
pass in the world u want to teleport them to
Hello, how would I read from a text file in my src folder?
then teleport them to that location
no it isn't
yup
this is dead
???
we're all dead here
^
You could just save it in the data folder of your plugin. Otherwise you can get it as an InputStream
we're all dead helpers
oh yeah I forgot
We are all recordings repeating the same messages over and over.
what's your git pulse
^?
How can I make an ItemSteck that gets a certain players head?
I almost thought about making macros for classics like "Pleas take your time and learn Java" and Just sending the how to create a Spigot plugin in <some IDE>
uhm
i found it
I wrote an IRC bot once to recognise frequently asked questions and give canned responses
SkullMeta meta = stack.getItemMeta();
meta.setOwner(player.getName());
stack.setItemMeta(meta);```
totally isn't a virus or anything
Nah never
I mean like sending profile json files, kelogging account information input. Nah
totally not sus
Thats in interesting idea. I could just pipe this chat into my dl4j learning project and see what the net comes up with XD
PFF
lol
yeah i see that
When the programme is sus ahahha hahha hahh a
I mean this isn't sus at all
I had the same, instead of 1, (byte) 3); behind SKULL_ITEM, why does it have to be like this?
so true
natural selection at this point
Jesus Christ
that isn't a cracked plugin
Yeah lol
seriously fuck automod
No, but some do contain a backdoor
most contain one
the jumpscares play randomly every 2 hours
Hopefully the responses to the bot dont get logged. Because i have insulted him countless times with the most absurd profanities.
LMAO
MY EARS
XD
does it work
The jumpscare works, yes
7smile7 sadly, it did not work
casually reports repo as malicious
How do I build a plugin directly into a folder?
idk im not a developer
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-shade-plugin</artifactId>
<version>3.2.1</version>
<configuration>
<outputFile>./server/plugins/${project.artifactId}.jar</outputFile>
</configuration>
</plugin>```
something like that
yeah who's a developer lmao
M O N K E O N A K E Y B O A R D
๐ฅฒ
Oh no
@lost matrix sadly, your way did not work
didnt work
Do you think this would be a correct implementation of hikari?
https://paste.md-5.net/mirubofote.java
Let me check
why it no work
i dont mind if the intended effect also happens when the player looks around, i would just prefer if it didnt
Hey there, im trying to make a cage of iron fence around a player, but idk what would be the cleanest way to do it ...
this is how i get playerpos (sorry im a beginner) :
Location playerpos = new Location(player.getWorld(), player.getLocation().getX(), player.getLocation().getY(), player.getLocation().getZ());
It works for me...
Oh i see. The code from above had an error in there.
so its
final int toX = to.getBlockX();
final int toY = to.getBlockY();
final int toZ = to.getBlockZ();
im gonna play some WD legion for a bit
@dusty herald thanks
np
ok i just messed up idea lmao
If its a fixed size then probably just some simple nested for loops.
How do i set blocks around the player now ๐ค
its deleting characters in front of it when i type now
i will use this code on a blockbreak event
Get player Location, get Block of that location, iterate over x, y, z and use Block#getRelative(x, y, z) for getting the surrounding blocks. Then just set their type.
Alright ty sir, i will look for that
press insert (over delete) once on your keyboard
wdym over delete?
xd
The key over your "del" key. Its probably different in every language. Mine says "entf"
anyone
Nested snychronized blocks... and synchronizing on a non encapsulated field together with the fact that Hikari is thread safe...
This does not look good
ok im definitely making progress, but it gets the block in the players feet
btw can somebody help me with custom plugin messages from bungeecord to spigot like idk how it works and some wikis or smth are just bungeecord things like connect or something
Why are you synchronizing on anything here? Do you plan on calling the setup method very frequent over several threats?
Is there simpe way to replace reesed seeds when wheat is broken?
Yes. Its def not needed here
Yes. And i think i gave you the exact code for doing so yesterday.
I guess so i but i dont udferstand it and i doesnt work D:
Other than that its good?
The rest looks fine
Alright
But you should prefer this approach:
HikariConfig config = new HikariConfig();
config.setJdbcUrl( "jdbc_url" );
config.setUsername( "database_username" );
config.setPassword( "database_password" );
config.addDataSourceProperty( "cachePrepStmts" , "true" );
config.addDataSourceProperty( "prepStmtCacheSize" , "250" );
config.addDataSourceProperty( "prepStmtCacheSqlLimit" , "2048" );
dataSource = new HikariDataSource( config );
Maybe. But without code i cant help you.
btw can somebody help me with custom plugin messages from bungeecord to spigot like idk how it works and some wikis or smth are just bungeecord things like connect or something
It works. I event sent you a gif of it working.
You simply listen for the BlockBreakEvent then check if the broken type is WHEAT
After that check its age and if its max aged you set the Block to type WHEAT again.
is there a way to add a build plugin configuration entry to a maven subproject from the command line?
Makes no sense to me. When does Placeholders.bungeeCount get updated?
in a runnable, its being called every 10 ticks
but it doesnt even register the placeholder correctly
which is the issue
config.setJdbcUrl( "jdbc:mysql://" + host + ":" + port + "/" + database );
config.setUsername( username );
config.setPassword( password );
config.addDataSourceProperty( "cachePrepStmts" , "true" );
config.addDataSourceProperty( "prepStmtCacheSize" , "250" );
config.addDataSourceProperty( "prepStmtCacheSqlLimit" , "2048" );
hikari = new HikariDataSource( config );```
so that @lost matrix ?
do you call the method bungeeCount()?
And does hikari automatically pool the connections?
Yes
So the variable gets updated every 10 ticks? Then how often do you send the header/footer?
10 ticks
And does that happen in independent loops?
With this amount of code you narrowed it down to like half a million possibilities.
how big will you have cage?
i were thinking you could loop tough cords and do some 3D Math (X,Y,Z)
ill send the full code
okay
@round finch well its juste a 3 block high and 1 air block on the player loc
Sure. looks alright. Not sure if you need a statement cache that big.
Location playerpos = player.getLocation();
Block test = test.getRelative(playerpos.getBlockX() + 1, playerpos.getBlockY(), playerpos.getBlockZ());
test.setType(Material.IRON_FENCE);
idk if thats good
that is not the issue btw
as i said, the issue is the placeholders not registering
What does that statement cache even do?
ok final question: how would i add the nbt data of the block to the inventory?
do you have the bungeecord installed in papi plugin like /papi ecloud download bungee
Yes
okay
is that featherboard?
caching statements
so like if the player walks over a chest it would keep the contents
If so try: {placeholderapi_bungee_count}
It's not featherboard
custom code?
right
okay show the full code of the scorebaord showing up
ok
@lost matrix since you seem experienced with hikari
But you said earlier that it worked on another plugin. So it has to be registered already
someone @ me if you know
@latent talon sell the full code if possible pls
yeah hold on
that would be easier
As others told you ๐ Yes. The connection pool (one wouldnt believe it) does pool connections.
woahhhhh
@carmine ivy wrong chan, go in #help-server
lmfao
1.16.5 is a pretty good alternative
Read your post on workload distribution and loved it! Excellent resource, good sir ๐ฉ
anyone know this one? i tried getBlockData() but that does not seem to have worked
There isn't a version of per world plugin for that
Although if there was I would be using it rn
@lost matrix is this what you told me to do ?
Shoot okay I'll move
PerworldPlugin has a 1.16 version
Its even native to 1.16
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.
wtf send it to me lmao
I wish I found out earlier
@latent talon try debugging the bungeeCount method like (Bukkit.broadcastMessage(bungeeCount());
okay
what about top cover and bottom floor?
no top and bottom sir
ok
First of all. No:
} catch (Exception ex) {
ex.printStackTrace();
}
Then: Absolutely no! :
private static Player player;
Last: You improperly used the placeholders:
Its "%bungee_SMP%" not "%bungee_<SMP>%"
And be aware that your header/footer will only work for one single player and nobody else
whats wrong with the ex.printstacktrace()?
The thing wrong with that is the "Exception" but I'm going to assume
You should never catch all possible exceptions. Narrow it down to the ones you need. So ReflectiveOperationException would be enough in your case.
yep
oh?
also what does that mean, first time using packets generally
you should even change the String practicecount = "%bungee_<Practice>%"; to String practicecount = "%bungee_Practice%";
yeah alright i got that
And you didnt cache your reflections. So on a server with a lot of people, running something like this every 10 ticks without distribution will lead to micro lags.
but %bungee_total% doesn't work either
placeholders should be lowercase
Practice is name of server
/papi ecloud download Bungee
/papi reload
okay well i just followed a tutorial on the tab list thing
already have that
:C
did the debug showed something?
didn't run it yet hold on
okay
Its not supposed to work?
@EventHandler
public void onBreak ( final BlockBreakEvent event){
final Block block = event.getBlock();
if (block.getType() != Material.WHEAT) {
return;
}
final Ageable ageable = (Ageable) block.getBlockData();
if (ageable.getAge() == ageable.getMaximumAge()) {
block.setType(Material.WHEAT_SEEDS);
}
}
}
u register ur listener?
Does anyone know how to change a string into a location?
Listener:
public class ZbozeListener implements Listener {
@EventHandler
public void onBreak ( final BlockBreakEvent event){
final Block block = event.getBlock();
if (block.getType() != Material.WHEAT) {
return;
}
final Ageable ageable = (Ageable) block.getBlockData();
if (ageable.getAge() == ageable.getMaximumAge()) {
block.setType(Material.WHEAT_SEEDS);
}
}
}
Main:
getServer().getPluginManager().registerEvents(new ZbozeListener(), this);
well my code takes the player location and prints it to a book
so yes
i want to use that location from the book and teleport the player there
you can use something like player.getLocation().getWorld().toString();
oh if is there
you use Bukkit.getWorld(get playerworld)
any error messages?
no it stores it to the book as a string beacause I think that's the only way to put it in a book
yeah it does
not
no but it is just telling me that i can't use a string as a location
what are u trying to take from the book
a world, x, y ,z or
ok the player types a command and it takes their current location and puts it in the book using player.getlocation then I want them to be able to type a different command,the plugin reads taht book and teleports them to their previous location that is already listed in the book
but I think I can only put a string in a book
okay show me the saving method in the book
ok one sec
okay
Srry for wait
its okay
My computer crashed I have to restart
okay take your time
can someone pls vc with me i rly need help, and what i need would be hard to explain in txt
?ask
If you have a question, please just ask it. Don't look for staff or topic experts. Don't ask to ask or ask if people are awake or available. Just ask the question to the channel straight out, and wait patiently for a reply.
i could help but ill firstly help the @deft sedge
ok sure thats fine
You could start phrasing your problem then...
Im rebooted im screenshotting code
okay
for some reason my smithing table event is acting very weird
like i add enchants and i test it and it works
but like when i add another if statement after that
the old if statement stops working
?paste your code
Someone else will help, I don;t do screenshots.
cool
sure
I really don't know whats going on:
Using per world plugin and when I try to reload the plugin using /pwp reload it resets the config file
If there is a way to fix please help!
const promptMessage = player => events.once('PlayerChatEvent', event => event.getPlayer() === player).then(i => i.getMessage());
commands.create('prompt', async sender => {
sender.sendMessage('Tell me hello.');
const msg = await promptMessage(sender);
switch (msg) {
case 'hello':
sender.sendMessage('Wow, that is so kind of you :D');
break;
default:
sender.sendMessage(':(');
}
});
Any thoughts on promptMessage?
Should I improve it?
what if they type Hello 
for some reason when i put the axe and blaze powder, the axe in the second slot becomes enchanted
Oh true
i only want the result to be enchanted
switch (msg.toLowerCase())
Ye
I'm glad I'm working with JS since it wouldn't be possible in Java
For promptMessage
Who is glad to work with JS?
[] == ![]; // -> true
or
!!"false" == !!"true"; // -> true
!!"false" === !!"true"; // -> true
false is true
Like...
Java has legacy problems too
And as long as you don't try to step in dirty waters, you won't
Any normal person won't be doing !!"true" and !!"false" often
And won't use == and will use ===
๐
Java has its own bad legacy features too
And it's incredibly verbose
So I'm very glad to work with JS
Verbosity isnโt necessarily bad
Yeah itโs a subjective topic indeed
More ppl seem to dislike verbosity
Iโm fine with that, we do after all have Langs like js and kotlin and what not
The plugin I'm using that I made for JS and TS actually has experimental TS support that I've been working on
Doesn't static type check but your IDE should be able to
Interesting
I refuse to work on js without the TS layer.
Also one of the weirdest things in js is parsing numbers:
parseInt("Infinity", 10); // -> NaN
parseInt("Infinity", 18); // -> NaN ?
parseInt("Infinity", 19); // -> 18
parseInt("Infinity", 23); // -> 18 ?
Or dependency on ecma version:
parseInt("06"); // always 6
parseInt("08"); // 8 if support ECMAScript 5
parseInt("08"); // 0 if not support ECMAScript 5
^
alr
?paste
I need some help. I need to change the block drops for a block every minute. The .equals statement doesn't seem to work when I use an instance variable but it works if I explicitly say Material.STONE, etc.
Code for reference ^
don't compare enums with .equals()
It doesn't work with == either
debug and see if blockDrop is null
also, instead of just running it on repeat, you could just use a local variable and use it inside of the event
Do you get teh message from yoru broadcast saying what type?
yes
the runnable works fine
im checking with debug rn
Hi. Im just curioous is there a way to make no drop from destroyin item
Could you elaborate?
int choice = new Random().nextInt(6);
Material blockDrop;
String blockName;
switch(choice)
{
case 1:
blockDrop = Material.STONE;
blockName = "Stone";
break;
case 2:
blockDrop = Material.GRASS_BLOCK;
blockName = "Grass block";
break;
case 3:
blockDrop = Material.DIRT;
blockName = "Dirt block";
break;
case 4:
blockDrop = Material.SAND;
blockName = "Sand";
break;
case 5:
blockDrop = Material.GRAVEL;
blockName = "Gravel";
break;
default:
blockDrop = Material.GOLD_ORE;
blockName = "Gold Ore";
break;
}
if(event.getBlock().getType() == blockDrop)
{
Block block = event.getBlock();
block.setType(Material.AIR);
block.getWorld().dropItemNaturally(block.getLocation(), OPItem.getOPItem());
event.setCancelled(true);
}```
something like that inside of the event, no pretty tho
nm,m that won;t work
Ill implement any improvements you guys suggest after I get this thing to work
Well the only thing I see wrong in that code is using .equals instead of ==
what I'm thinking is the Event doesn't know that blockDrop or blockName is set
Hello everyone, does someone here have experience with BouncyCastle lib? More specifically with performing ECDH
who knows
or the OPItem is not what you are expcting
I believe OPItem works
sysout on it to be certain
yeah it is a static method ๐
Because the plugin works as intended if I change blockDrops to something explicit like Material.STONE
k
Would using a Set<Material> then picking a random element make any signficant difference?
Sorry, I'm not familiar with Sets atm
If that works then yoru switch is failign to set/access the blockDrop variable
Its fine, just curious
True, but blockName is getting initialized just fine
Send a paste link of your current code
what do you need help with?
Like everything?
I already pasted the relevant parts
I mean nothing special in how BouncyCastle does it vs say another crypto lib except efficiency
an easy test, add a setter for teh blockDrop in the class
@wet breach I'm getting error about point encoding when trying to get Public key from byte array
Exception in thread "main" java.lang.IllegalArgumentException: Invalid point encoding 0x30
at org.bouncycastle.math.ec.ECCurve.decodePoint(Unknown Source)
at me.inao.ecdhexample.KeyExchange.getPubKeyFromBytes(KeyExchange.java:33)
at me.inao.ecdhexample.Main.starter(Main.java:18)
at me.inao.ecdhexample.Main.main(Main.java:10)
!paste
Trying this rn
?paste
Public key is being encoded into Base64 and then sent using Socket to client from server. Client should decode Base64 and use decoded bytes to get PublicKey object
btw, it's also possible to use `
3 times
test
As I can see, bytes are correct, so I don't really know what's wrong
Server
[48, 89, 48, 19, 6, 7, 42, -122, 72, -50, 61, 2, 1, 6, 8, 42, -122, 72, -50, 61, 3, 1, 7, 3, 66, 0, 4, -80, -17, 78, -37, 27, 44, -46, -31, 6, -20, -88, 83, -116, 26, 70, -50, 57, 68, -50, 67, 89, 27, 66, -71, 102, 28, 35, -5, 9, -16, 2, -109, -53, 74, 114, -44, -5, -101, 42, -35, -81, -23, 124, 78, -88, 27, 47, -46, -6, 5, 61, 55, 58, -4, 36, -51, 6, -58, 47, -101, -44, -111, 127, 99]
Client
[48, 89, 48, 19, 6, 7, 42, -122, 72, -50, 61, 2, 1, 6, 8, 42, -122, 72, -50, 61, 3, 1, 7, 3, 66, 0, 4, -80, -17, 78, -37, 27, 44, -46, -31, 6, -20, -88, 83, -116, 26, 70, -50, 57, 68, -50, 67, 89, 27, 66, -71, 102, 28, 35, -5, 9, -16, 2, -109, -53, 74, 114, -44, -5, -101, 42, -35, -81, -23, 124, 78, -88, 27, 47, -46, -6, 5, 61, 55, 58, -4, 36, -51, 6, -58, 47, -101, -44, -111, 127, 99]
Tried with a setter method, still doesn't work
@quaint mantle
I'm gonna try this next
Did you add the check for a null block?
Well from the code you have shown I see no reason for it to not work.
no
@heavy mason If you mean for the code, I will push server code to GitHub and will send link. For client, code is the same
should I?
No, I'm saying use a paste link instead of pasting large amounts of text that flood chat
@quaint mantle Is client and server both something you made?
You should
@wet breach Yes and no, some parts are from github xdd
https://github.com/inao-cz/bufferBot/blob/bouncycastle/src/main/java/me/inao/discordbot/server/KeyExchange.java
The only thing I could see that could possibly be throwing it off, is that sometimes you have to specify which spec you are using, which there is two names for it.
prime256v1 and secp256r1. The second one is the more accepted name for it, while some are just fine with the former.
Exception is being generated on line 31, decodePoint(raw)
maybe you should cook it
its raw
yes yes, bake it for 3 hours
public org.bouncycastle.jce.interfaces.ECPublicKey loadECPublicKeyBC(String encodedPublicKey) throws NoSuchProviderException, NoSuchAlgorithmException, InvalidKeySpecException, IOException {
Base64.Decoder base64Decoder = Base64.getUrlDecoder();
byte[] decodedPublicKey = base64Decoder.decode(encodedPublicKey);
KeyFactory keyFactory = KeyFactory.getInstance("ECDH", "BC");
ECParameterSpec ecParameterSpec = ECUtil.getECParameterSpec(openSSLProvider, "prime256v1");
ECPoint ecPoint = ECUtil.decodePoint(decodedPublicKey, ecParameterSpec.getCurve());
ECPublicKeySpec pubSpec = new ECPublicKeySpec(ecPoint, ecParameterSpec);
org.bouncycastle.jce.interfaces.ECPublicKey ecPublicKey = (org.bouncycastle.jce.interfaces.ECPublicKey)keyFactory.generatePublic(pubSpec);
return ecPublicKey;
}
this is using BouncyCastle
im trying to make a while loop for the player y being 256, i havent done a while true before but this is what ive got and its not working while (player.getLocation().getY() >= "264" (true) {
Do I have to close preparedstatements/statements after using them?
well not "have to"
but should I
@quaint mantle Did you check that the public key value you have obtained is actually correct?
that would be the only other thing I could see going wrong, is that you are generating a key, and then from said key extracting the wrong public key using incorrect values from the private key
@wet breach what pastebin do you use
?paste
thanks
the last 6 values of the generated key is what is used to derive the public key if that better helps you @quaint mantle not entirely sure how well versed you are in crypto lol
Any one has an example of plugin that uses a websocket?
Well, for getting the key, I'm using https://github.com/inao-cz/bufferBot/blob/bouncycastle/src/main/java/me/inao/discordbot/server/Connection.java#L34
And since key should be generated correctly (hopefully, it's in init function of KeyExchange.java)
@EventHandler
public void onSmith(PrepareSmithingEvent e) {
if (e.getInventory().getItem(0) != null && e.getInventory().getItem(1) != null) {
if (e.getInventory().getItem(1).getType().toString().endsWith("_AXE")) {
ItemStack result = e.getInventory().getItem(1);
ItemMeta resultMeta = e.getInventory().getItem(1).getItemMeta();
//List<String> lore;
if (e.getInventory().getItem(0).getType() == Material.BLAZE_POWDER) {
result.addUnsafeEnchantment(Enchantment.FIRE_ASPECT, 10);
}
if (e.getInventory().getItem(0).getType() == Material.BONE) {
result.addUnsafeEnchantment(Main.boneEnchant, 1);
resultMeta.setLore(Arrays.asList("Bones"));
}
result.setItemMeta(resultMeta);
e.setResult(result);
}
}
}
that is my event
but
here is what happens:
it sets the lore
but its not enchanted
@quaint mantle so the line you linked is for getting the public key from a key. So now the question is, the key being provided, is it a valid ECDH key? And is said key actually being used to encrypt the session or is it just the public key?
How do I set a npc selected hotbar slot?
Okay so I've figured out that blockDrops is null. The thing is, I don't know why
Mind sharing some code?
hello again,
Do you onyl want to edit the drops? Because this can be done using the BlockDropItemEvent
So im creating a world manage plugin and this is the method that im trying to use to load a premade world, however it does not work.
https://paste.md-5.net/aziwusuluc.cs
The File has to be created relative to the world container
Is there an event prior to PluginEnableEvent?
no
Bruh
i dont think so lol
I have a question. Why i doesnt work D; Pls help
Main:
import org.bukkit.command.Command;
import org.bukkit.command.CommandSender;
import org.bukkit.entity.Player;
import org.bukkit.event.Listener;
import org.bukkit.plugin.java.JavaPlugin;
public class Main extends JavaPlugin implements Listener {
@Override
public void onEnable() {
this.getServer().getPluginManager().registerEvents(new Join(), this);
}
@Override
public void onDisable() {
}
@Override
public boolean onCommand(CommandSender sender, Command command, String label, String[] args) {
if(label.equalsIgnoreCase("createnpc")) {
if(!(sender instanceof Player)){
return true;
}
Player player =(Player) sender;
NPc.createNPC(player);
player.sendMessage("NPC CREATED");
}
return false;
}
}
onEnable void
public File getWorldFolder(final String worldName) {
return new File(Bukkit.getWorldContainer() + File.separator + worldName);
}
I want to cancel a plugin from loading entirely
NPc:
public class NPc {
public static List<EntityPlayer> NPC = new ArrayList<EntityPlayer>();
public static void createNPC(Player player) {
MinecraftServer server = ((CraftServer) Bukkit.getServer()).getServer();
WorldServer world = ((CraftWorld) Bukkit.getWorld(player.getWorld().getName())).getHandle();
GameProfile gameProfile = new GameProfile(UUID.randomUUID(), "Farmer");
EntityPlayer npc = new EntityPlayer(server, world, gameProfile, new PlayerInteractManager(world));
npc.setLocation(player.getLocation().getX(), player.getLocation().getY(), player.getLocation().getZ(),
player.getLocation().getYaw(), player.getLocation().getPitch());
}
public static void addNPCPackets(EntityPlayer npc){
for (Player player: Bukkit.getOnlinePlayers()){
PlayerConnection connection = ((CraftPlayer)player).getHandle().playerConnection;
connection.sendPacket(new PacketPlayOutPlayerInfo(PacketPlayOutPlayerInfo.EnumPlayerInfoAction.ADD_PLAYER, npc));
connection.sendPacket(new PacketPlayOutNamedEntitySpawn(npc));
connection.sendPacket(new PacketPlayOutEntityHeadRotation(npc, (byte) (npc.yaw *256 / 360)));
}
}
public static void addJoinPackets(Player player){
for (EntityPlayer npc : NPC){
PlayerConnection connection = ((CraftPlayer)player).getHandle().playerConnection;
connection.sendPacket(new PacketPlayOutPlayerInfo(PacketPlayOutPlayerInfo.EnumPlayerInfoAction.ADD_PLAYER, npc));
connection.sendPacket(new PacketPlayOutNamedEntitySpawn(npc));
connection.sendPacket(new PacketPlayOutEntityHeadRotation(npc, (byte) (npc.yaw *256 / 360)));
}
}
public static List<EntityPlayer> getNPCs() {
return NPC;
}
}
Never mind, I finally found the solution
What are you trying to do?
Join:
import org.bukkit.entity.NPC;
import org.bukkit.event.EventHandler;
import org.bukkit.event.Listener;
import org.bukkit.event.player.PlayerJoinEvent;
public class Join implements Listener {
@EventHandler
public void onJoin(PlayerJoinEvent event){
if(NPc.getNPCs() == null)
return;
if(NPc.getNPCs().isEmpty())
return;
NPc.addJoinPackets(event.getPlayer());
}
}
which plugin like yours or other?
Other
aaa why is your class name NPc?
it's messing with my head
I accidentally made two objects 
its gonna explode
That's why it was null
xD
plase dont use Main :0
try this
if (getServer().getPluginManager().getPlugin("PluginName") != null) { getServer().getPluginManager().disablePlugin(getServer().getPluginManager().getPlugin("PluginName")); }
@molten hearth
Btw. Never throw a NullPointer yourself
is there an event for when a chunk is being generated for the first time
never really put much mind to it
I know there's ChunkLoadEvent
Anything else that might be wrong?
would that be called whenever a player loads a chunk?
thanks bb
Yes. ChunkLoadEvent#isNewChunk()
// Using an API
if (obj == null) return null;
// This IS an API
if (obj == null) throw new NPE
wow, such wisdom
What exactly does not work in your code? Do you always get your random NullPointer?
no, it just never loads the world
i wasn't receiving the null pointer at all
when i run /worldmng load test it says it loaded, but it never actually does
Throw some sysouts in there and see what lines get actually called.
Hi, I wish my plugin could search for players by coordinates, e.g. / examplecommand @a [x = 10, y = 20, z = 20], does anyone have any idea how to do this?
Well I don't want to disable it i want to cancel it ever calling onEnable
use @urban grotto instead lol
wait what the fuck
change your name
lmao
of course
but still, newbie programmers
Ironic
Guys I need help with my code:
Location spawn = new Location(Bukkit.getWorld("ffa"), -1074, 80, 96, 175.5, -2.9); Why does it give me error on paw and pitch?
g
or you can use @Contract
no
@Contract also works
Yes. But most approaches are pretty slow. Why do you want to do that?
you can also define purity with that as well
an error message would be nice
Would be hilarious if that pinged someone
I can't send here
ikr lol
I guess
?paste
send the error
!paste
I might be able to use loadBefore and have the same plugin name so that it errors due to a duplicate name entry but I'd rather do it programmatically
How do I upload a picture
Wait how am I gonna loadbefore the same plugin name pain
I'm creating a plugin that will work based on a Yes or No game and I need to detect a player from the given coordinates and would like to use @a, @r, @p etc.
Change the plugin name
Ez
This is the error: https://paste.md-5.net/equdoxakeb.bash
bro
@rapid vigil you have to change x y z to double and yaw and pitch to float
^
But then it won't error due to a duplicate plugin name
Or can i dynamically change the plugin name
Arent you trying to avoid the error?
I dont think thats possible
No I'm trying to cause the error so that the 2nd plugin doesn't enable
then do what i told u to do
You told me to disable it
or just remove the plugin
xd
I can't that's the problem lul
then do what i told u to
Location spawn = new Location(Bukkit.getWorld("ffa"), (double) -1074, (double) 80, (double) 96, (float) 175.5, (float) -2.9);
Like that?
But it messes stuff up within it's onEnable
public Optional<Player> getPlayerNear(final Location location, final double range) {
return location.getWorld().getNearbyEntities(location, range, range, range, entity -> entity instanceof Player)
.stream()
.sorted((ent1, ent2) -> (int) (ent1.getLocation().distanceSquared(location) - ent2.getLocation().distanceSquared(location)))
.map(Player.class::cast)
.findAny();
}
Get all players near a location
Sort them by distance from that location
Get nearest player if present
That actually works, No errors but there's 3 warnings
what warnings
Casting '-1074' to 'double' is redundant
Casting '-80' to 'double' is redundant
Casting '-96' to 'double' is redundant
Thank you โค๏ธ
Changed, but still same warnings
now it says:
Casting '-1074' to 'int' is redundant
Casting '-80' to 'int' is redundant
Casting '-96' to 'int' is redundant
show the code like the method
i got it to work @7smile7 thanks
IF you want them as doubles just append a d
oh maybe try ((int) the number)
For floats, f
public boolean onCommand(CommandSender sender, Command command, String label, String[] args) {
if (sender instanceof Player) {
Player p = (Player) sender;
Location spawn = new Location(Bukkit.getWorld("world"), (int) -1074, (int) 80, (int) 96, (float) 175.5, (float) -2.9);
if(label.equalsIgnoreCase("spawn"))
p.teleport(spawn);
p.setHealth(20);
p.setFoodLevel(20);
p.getInventory().clear();
p.removePotionEffect(PotionEffectType.STRENGTH);
}
return false;}
}```
Does an or ```
|| work in a catch statement? like catch(IOExeception e || MalformedUrlException mue)
Would that be possible to attempt something like that?
@Override
public boolean onCommand(CommandSender sender, Command command, String label, String[] args) {
if (sender instanceof Player) {
Player p = (Player) sender;
Location spawn = new Location(Bukkit.getWorld("world"), -1074d, 80d, 96d, 175.5f, -2.9f);
if(label.equalsIgnoreCase("spawn"))
p.teleport(spawn);
p.setHealth(20);
p.setFoodLevel(20);
p.getInventory().clear();
p.removePotionEffect(PotionEffectType.STRENGTH);
}
return false;}
}```
catch (ExceptionA || ExceptionB || ExceptionC ex)
remove the mue
its okay
weird
Exception covers ALL exceptions
oh than thats why
Be specific when adding them
okay
isn't it just 1 pipe
instead of two
no an or statement is 2
u think?
?
operator*
yeah i think it is too only 2 exceptions
Ah ye, it is 1
It wasn't like that before smh
how are you launching your server?
run.bat
start script?
Ye
no i mean
yeah
java -jar <options> spigot.jar
but like running a jar doesnt give u an console
it does?
never did to me
it gives you the console if you run it in command prompt. However, --nogui will not let the gui thing pop up
yeah
well yea
@wet breach I've solved it ๐ Problem was at sending whole key when I actually don't need it ๐
just runned the an 1.8.8 spigot jar didnt open anything
yea
i thought 1.8 was extremely buggy
they added console later
Ah
Only if you start it from withing a terminal. stdout does not have to be piped into your terminal.
On linux you can just do java -jar <options> spigot.jar >> some.txt and pipe the console directly into a File.
i mean
thats what I meant the whole time
like manually launching the jar
is through terminal imo
ive always done it like that I guess but new spigot is cooler I guess
you are smoking crack
Couple things. The <String,Integer> part at the end isn't necessary and you should be using Map<String, Integer> mana = new HashMap<>(); instead because it allows your code to be more flexible
yes it does
storing players as strings very good
@quaint mantle see I knew it had to be something with the key lol
glad you resolved it though
@wet breach I had to do this: ((ECPublicKey)session.getKeyExchange().getPair().getPublic()).getQ().getEncoded(true));
Instead of: (session.getKeyExchange().getPair().getPublic().getEncoded());
๐
Ah that makes sense
just do Map#get()?
it's better practice to define a map like this: ```java
public Map<String, Integer> mana = new HashMap<>();
and check the value
Ideally you wouldnt even make it public
i said that above ๐ฅฒ
nah all g
no
mana.get(player.getUniqueId()); to get the value right
then compare than to 100
You only really need to do it that way if you expect others to be using your code. IE making an API. In which case you let the user decide what they want instead of forcing them to use a certain collection. Otherwise just stating it as a hashmap instead of a map is perfectly fine and acceptable.
?paste
you're trying to use a uuid object as key in a map that requires a string
then do Bukkit.shutdown()
