#help-development
1 messages · Page 70 of 1
call component#setExtra(new ArrayList<>());
On which component though?
the one you're trying to send
I'm only passing the list of components to sendMessage
i am currently getting Cannot read field "SQL" because "this.plugin" is null i can imagine im beign dumb but doesnt anyone know why. Code : https://paste.gg/p/anonymous/8269480771844cc1bb97c829addef0fb
Now show where this.plugin is
i dont have a this.plugin
oh yeah i do ```java
TownyMySQL plugin;
public SQLGetter(TownyMySQL plugin) {
this.plugin = plugin;
}
and where does that error happen
oh
Anyways the reason why you're getting that error is that you're trying to use plugin before it's set
Intellij already appears to warn you
how can i get around that? use the Connection connection in each call?
Set the connection in the constructor
because I got refound request
so like ```java
TownyMySQL plugin;
Connection connection;
public SQLGetter(TownyMySQL plugin) {
this.plugin = plugin;
connection = plugin.SQL.getConnection();
}
Yes
ty
Isn't this the wrong channel 🤔
sorryyyy
someone can help me about "goto" velocity?
?
do you have any idea how can I create offers?
You need to create an EnchantmentOffer
In what cases is ItemMeta null when getting from an item? Is it just when the item's material is AIR?
Yes I know and created: EnchantmentOffer(Enchantment.ARROW_DAMAGE, 1, 30) but I don't know how can I send it. I've tried
event.offers[0] = EnchantmentOffer(Enchantment.ARROW_DAMAGE, 1, 30), it works on enchantable items but not on unenchantables
is it possible to check for a scroll event
Is there a way to send a plugin message without there having to be a player online?
declaration: package: org.bukkit.event.player, class: PlayerItemHeldEvent
Nevermind I can just use Server
Hi!
In the map format the InhabitedTime tag
What time unit does it use?
Seconds? Milliseconds? Ticks?
For play.sendMessage
Is there a way to use multiple colors for the message like other plugins got
for example :
yes just use multiple colors
lol
Yes. Either use this https://www.spigotmc.org/wiki/the-chat-component-api/
The home of Spigot a high performance, no lag customized CraftBukkit Minecraft server API, and BungeeCord, the cloud server proxy.
Or just insert ChatColor.Whatewer whenever you need a new color
Nevermind, Server#sendPluginMessage still requires a player to be online
that sucks
Thanks
Bukkit#broadcastMessage() maybe?
he's asking for plugin messages
But did you really
How did you do it?
player.sendMessage(DARK_PURPLE + "" + BOLD +"Mine" + LIGHT_PURPLE + "" + BOLD +"Swift"+ RESET + LIGHT_PURPLE +"You have been teleported to the spawn.");
xd
Honestly I never used chat color enums but just §0-9, a-f, etc
also what's BOLD without ChatColor
same
Imagine having a 3 liner because of using ChatColor.<Color> every time
text component superiority
§l
omg ur static importing
or using kotlin and using with keyword
ChatColor.translateAlternateColorCodes('&', "&fThis&4&bAlso &3works");
something like that
idk
hey just confirming again, there is no player teleport event right?
wait
no there is
declaration: package: org.bukkit.event.player, class: PlayerTeleportEvent
Long time ago
how long is a long time ago
Pretty sure it was in 1.8
Probably was in before that as well
I swear I remember it not existing
just like my will to live
boomer moment
aren't you that guy that made a song about choco?
I am as old as the bones in minecraft's body
which actually would make me way younger than I actually am come to think of it
as if the minecraft body had bones
look all I'm saying is that when I was looking to stop playing the browser version of mc for free I'm pretty sure mc was still on infdev
you're as old as herobrine :)
Browser mc was great
I still remember getting staff on a server for the first time for one of those servers
Running around looking at all the people's public builds
in a limited size world that was pretty tiny lol
Yuh
Crazy have a group of random people could innocently build without worries of an a****** coming and breaking everything
if you thought that back then then you were truly naive, like I said I got staff for the first time
Idk I never experienced any assholes on browser mc
I'd say the griefing scene was at its peak back then
And I played it a lot
basically no protections and all public all the time baby
Guess I was lucky with the 5 hours a day I was playing
I do not want to know how long I've had minecraft-related things open for since I first started
what is this, 2016?
well last time I was paid $5 so with inflation that'll be $5000
should we go with a smoother hopsin style or bring out our inner joyner lucas 🤔
p.hideentity is depricated anyone know if it stil works
pass the plugin as the second param
Yes
It’s draft api
What is going on here. I was trying to save stuff in my config but this came up. The second is my config.yml
you tried to serialize a TextComponent
where
at de.itembingo.commands.Command_start.onCommand(Command_start.java:28) ~[ItemBingo-1.0-SNAPSHOT.jar:?]
show the entire start command
You are trying to save an Item
do you have any idea how can I create offers?
I've tried event.offers[0] = EnchantmentOffer(Enchantment.ARROW_DAMAGE, 1, 30), it works on enchantable items but not on unenchantables
Also why have you called your item variable “itemName” when it is not the items name but the entire item
how do you call a library that allows multiple database types without making different code for each one
Using if statements
an ORM framework
This is why proper variable names are important
Sending Enchantment Offers To Unenchantable Items
hikaricp counts as one?
ehhh
ayo bro
doesnt hikaricp just do connection pooling
u gotaa work on ur naming conventions
I don't think that it transforms your sql statements for each db engine
Well just because it works doesn't mean you're doing it right. You should always strive to follow good practices
ah
what do people usually use then?
i see often sqlite and mysql as option
that's because sqlite and mysql syntax differ very little
I code in Kotlin so I use Exposed, which uses a lot of syntax sugar to look good, so I have no clue what is popular in Java
it's also possible that people just put an abstraction on top of storage (which is recommended) and implement the different engines they support themselves
technically you could java interoperate with kotlin :>
you could, but that's why I noted this part: "which uses a lot of syntax sugar to look good"
Exposed would look like shit written in Java
yeah figures lol
How do I make particles spawn on a chunk border
how can i determine the amount of time left on something. Im wanting to make a chat cooldown and if the cooldown isn't past 3 seconds it'll display the time left
Save the timestamp of the last message in a map
And then check if it's there and how long ago it was
im getting this issue while building the plugin
Show pom
?paste
You added jitpack repo twice
you mean https://jitpack.com ?
Yea
uh what would I put there?
I just realized that the repo is all wrong too ;/
any articles on the topic?
Contribute to koca2000/NoteBlockAPI development by creating an account on GitHub.
um
if i wanna make
a rock paper scissors neural network
ill have to turn each choice into a number right
you don't need a neural network for rock paper scissors
why tho
Changed it, now I got these little men
I mean you could adapt it to a specific player, but its pretty much random unless there is some known mental bias I'm unaware of
Did you fix the jitpack repo?
?paste Send new pom
but yea using a number would be easier than a string but in the end its your choice
I have no clue what type of software you are using to construct it
I usually use scikitlearn
tinynn4j
it looked simple
and i understand what it doese somewhat
so i wanna use it
yep
ohhh a java thing I can't help you most of my api knowledge would be in scikitlearn in python
it doesnt matter tbh
well to make it i would have to assign
each thing a number
e.g
rock 1
paper 2
scissors 3
if you assign it to a number all you'd need to do is just make a string map if you want the ui to be good
but yeah that should work
well depends what the api offers
You can train the network by putting it up against a Random number generator X times
than save the dataset
//(number of inputs, number of nodes in hidden layer, number of outputs)
NeuralNetwork nn = new NeuralNetwork(3,5,1);
nn.setActivationFunction("RELU"); //default is SIGMOID
nn.setLearningRate(0.01f); //default is 0.1f
//3 inputs and 1 output
float[] trainingInputs = {1.0,2.0,3.0};
float[] trainingOutputs = {0.5};
nn.train(trainingInputs,trainingOutputs);
float[] testData = {1.1,2.1,3.1};
//output will be a float[] with size equal to the number of output nodes
float outputs[] = n.predict(testData);
and feed it in
Use the paste site
ah my bad
I'd just have 1 input node, and have multiple output nodes
still little new to this discord
Why is jitpack defined twice
the output node of the option thrown and whether they won or not true for win false for lose
Remove one of them
what why
nah the win is calculated somewhere else
oh okay than you'd only need 1 input and output node
alright
I'd track the winning as a sort of points system though for the AI as a reward for winning
the test set would be sets of rock paper scissor games
no like
what next
Hey hello, i have a second issue, I try to do something with InventoryMoveItemEvent But its not called.
And yes i register my event listener in my Main class.
#HopperEvents.class
public class HopperEvents implements Listener {
//This one not called
@EventHandler(priority = EventPriority.HIGHEST)
public void onInventoryMoveItem(InventoryMoveItemEvent event) {
Bukkit.getLogger().log(Level.INFO, "getDestination:"+event.getDestination().getType().name());
Bukkit.getLogger().log(Level.INFO, "getDestinationHolder:"+event.getDestination().getHolder().toString());
event.setCancelled(true);
}
//This one called fine
@EventHandler(priority = EventPriority.HIGHEST)
public void onInventoryPickupItem(InventoryPickupItemEvent event) {****}
}
#Main.class
@Override
public void onEnable()
{
this.getServer().getPluginManager().registerEvents(new me.plugin.HopperEvents(),this);
}
Whats going wrong i'm on API 1.19
That's it. Reload your pom and done
You know that event is for hoppers right?
well input I'm unsure how'd you want to structure it, but for output you'd want different results of losses and winns
Ah wait nvm
Missed class name
Common issue is for people to use it with inventory guis
what
Yes, When i put a chest above hopper and below its not called when i put something in the upper chest or direct into the hopper
based off your example though your ai would be basically learning the rules of rock paper scissors versus playing
Im still getting issues while building the plugin, heres the log https://paste.md-5.net/fiboxogucu.sql
so given a game it predicts the outcome if enough tests are given 10 or so it should beable to predict whether the game is won by one player or the other
atleast the api example seems to be predictive so you'd need to restructure for it to play
I've only done an ai that could play a game like once usually I just use AI to project data and future values
HopperEvents.class is listen for sure sinds InventoryPickupItemEvent is working?
Delete this file C:\Users\Toweles\.m2\repository\com\github\koca2000\NoteBlockAPI\1.6.1\NoteBlockAPI-1.6.1.jar
I try to detect hopper transfer from a chest to be clear
the input should be the player's last game input and the output should be the ai's answer @river oracle
this sounds good
yea that sounds good
but you also need to tell the AI the outcome of the game
the neat thing is if you actually legit play the AI enough it can unravel some mental biases you have in playing rock paper scissors and probably beat you close to every time
Delete it don't open it
how would I delete it?
Try to build again when you run as Administrator on your build program
I'm not sure with that api you'd have to look through the docs but its important the AI knows the output so it can learn otherwise its no better than a rng
thats what happens when I try to go to the file location
it gives me the error
uhhhhhhhhhhh
normally how would u do it
ohh lord okay its been a year let me think
AI was one of the first programming things I did lol
okay so, anyone can help me out https://discordapp.com/channels/690411863766466590/741875863271899136/1009579945409925222 😎
This is what i try to detect if i put some items in the upper chest.
InventoryMoveItemEvent is right true? to detect on hopper side?
Is there any way to use warden's sonic boom attack?
Correct
No API for this yet. I want to say there's a PR in the works though?
Its not called idk why
Thanks
What server are you using, shared? Paper?
Paper
They have a setting to disable that event from being called that's enabled by default
paper.yml should have something about inventory-move-event. Can't remember the name
@worldly ingot do u have an idea btw
omg this is so dump, why they do something like that ⚠️
Performance
The event is notoriously imperformant, but it's a weird choice in setting to enable by default
i wanna make an ai that u give the player's last choice and itll predict the next choice and reply to it
but
idk how to tell it
good job / bad job
to train it
Choice of what?
rock paper scissor
ngl, RPS is one of those games where a good AI is as simple as a random number generator
There's nothing you can really train an AI on and it will probably perform as well as RNG
someone once asked me if he can train an ai to make an anticheat processing the bytes of packets
This is client source, tried replicating something similar but a change of +1 each tick is a lot slower than the speed with which a boat normally turns
like what 💀
yeah but just tell me
try harder
he wanted to feed it byte arrays
Only the last choice seems pretty limiting for a neural network for rock paper scissors
At which point you'd need a TDNN
If you're insistent on doing an RPS NN, I'd agree with that
train ai to update spigot
/paste
thats smarter
!paste
?paste
The best training data you can give an RPS NN is just... random games of RPS
thanks
But at the end of the day it operates based on patterns
Ther is noting in there like inventory-move*-event (paper-global.yml, and paper-world-defaults.yml)
I can't remember what the name is called. One sec. I have a config on hand
world-settings.default.hopper.disable-move-event: true
Set that to false
on global?
Wherever you're using the event
I am testing my plugin on my server and Im getting this error https://paste.md-5.net/uwugaquxif.sql
Is there an event for saving a new chunk to the disk?
disable-move-event should be somewhere in the paper.yml. I don't know how Paper handles their configs. I seldom edit their config files and I only ever really work with Paper servers while I'm writing software for some company. Configuration is often left to the system admins lol
If it's not there you might have to add it. Though where to add it, I'm unsure. Asking the Papercord is probably a better option
yeah its a per world setting
thanks
its a good community, so if it is paper or spigot, if people can help why not, its helps me 😋
im not getting any issues in my ide though
only in the server log
invalid formatting in your plugin.yml
are there any examples of a correct plugin.yml I could use?
?paste yours and we'll tell you whats wrong
remove the } at the end
alright
Command isnt working
did you register an executor?
?
I dont believe so, the command was working a day ago though
check yoru startup for any errors
I am not getting any errors
Look down the stacktrace until you spot one of your plugin classesat me.toweles.songplugin.SongPlugin.onCommand(SongPlugin.java:35) ~[?:?]
it tells you where the error came from and what line number
the error being Caused by: java.lang.IllegalArgumentException: Cannot add null to playlist
I cant seem to find the line number
he legit provided the number
but if you want to see for yourself, paste link line 30
anyone know why i cant use any methods from spigot
i got the spigot jar in my build path
String kick_message = main.getConfig().getString("kick-message");
Player target = Bukkit.getPlayer(args[0]);
target.kick(MiniMessage.miniMessage().deserialize(kick_message));``` ```yml
resource-pack-message: "<red>To download the resource pack, click the server, then click \"edit\". Then \"enable\" the server resource packs!</red>>"```
Am I doing something wrong here? I'm not being kicked.
google java naming conventions please
?conventions
Java Coding Conventions: https://www.oracle.com/java/technologies/javase/codeconventions-namingconventions.html
also, you are not checking if target is null
@Override
public boolean onCommand(CommandSender sender, Command cmd, String label, String[] args) {
String prefix_message = main.getConfig().getString("prefix-message");
String no_permission_message = main.getConfig().getString("no-permission-message");
String kick_message = main.getConfig().getString("kick-message");
if (sender instanceof Player) {
Player player = (Player) sender;
boolean packstatus = resourcepackManager.getStatus(player.getUniqueId());
try {
Player target = Bukkit.getPlayer(args[0]);
if (sender.hasPermission("xo.texturepack.other")) {
if (target != null) {
target.kick(MiniMessage.miniMessage().deserialize(kick_message));``` the full code is this :P
ikr
So, what exactly is line 35?
Why are you still using sender for the permission check after using instaoceof Player and creating the player variable?
can someone read my message thanks :)
?bootstrap
Bootstrap Jar
The main spigot-1.18.jar is now a bootstrap jar which contains all libraries. You cannot directly depend on this jar. You should depend on Spigot/Spigot-API/target/spigot-api-1.18-R0.1-SNAPSHOT-shaded.jar, or the entire contents of the bundler directory from your server, or use a dependency manager such as Maven or Gradle to handle this automatically.
Please read the release notes for further information: https://www.spigotmc.org/threads/9-years-of-spigotmc-spigot-bungeecord-1-18-1-18-1-release.534760/#post-4305163
How can I reload my entire plugin and not just my config file?
Just reload what you want to?
plugman its a plugin
How can I reload a class file? I tried to reinitiate it but it didnt seem to change anything
plugman can break plugins
Uh what exactly do you want to reload?
I have a file that basically just holds a couple variables that I have to use multiple times through my plugin. I want to reload that since it doesn't reload when the config reloads
how exactly?
Gonna have to send it.
so the same as /reload lmfao
any form of reload has a chance to break plugins
aka why you NEVER use reload on production servers
I don't understand how it's difficult to reset variables
I would consider it fine to use on development servers, but if you have any errors restart to see if its persistant
on your config reload command or however you reload the config, just update the variables??
public class Variables {
private static final Plugin plugin = Plugin.getPlugin(Plugin.class); // Get this from main
// Get Placeholders
public String prefix = plugin.getConfig().getString("Placeholders.Prefix");
public String error = plugin.getConfig().getString("Placeholders.Error");
public String success = plugin.getConfig().getString("Placeholders.Success");
public String pluginName = plugin.getConfig().getString("Placeholders.Plugin Name");
}
This is the base of my variable file, the different strings don't change
.
^
but yeah do what Lewi is saying
Not super scalable, if theres a bunch of variables, or special circumstances for the variable, like converting a string to a material
You want this the easy way? Make an object that generates from a passed in config. Reload command resets the object with the updated config.
Don't even need an object but w/e
thats the smart way to do it tbh
Can just get the instance from your main class or smth so you really arent abusing static
or a config handler where u just call a method whenever you want to get it from config
but a fix for this exact problem is what ive already said
has anyone here worked with noteblock api? I sorta need your help
?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. Make sure you use the right channel regarding the topic of your question. Create a thread in case the channel is already in use!
oh alright
I need help with with noteblock api, Im getting a "Cannot add null to playlist" when I try to use my command to play a sound
Gonna need code to help you we can't read your mind lol
Then paste the error
Can someone send a link from the spigot forum how to solve my problem because I can't find a solution or I'm doing something wrong. I want the head of the armor stand to collide with the ground so the head stays on the ground like a block
Something is null with the file possibly? Check if the file name is correct and the location
Debug and log all the data
Its the code on line 34 trying to take an nbs
Im not sure how to make the nbs work
have you saved Song.nbs to yoru plugins data folder on the server?
Is that bstats?
no
Inside YOUR plugins folder
nope
?
how do you custom hex color codes
getDataFolder().mkdirs();
like in String form and not ChatColor.of
where would I put this, cmd prompt, my plugin?
in your onEnable()
that will just create the folder, you still have to put your Song file in there
plugin's*
Spaces supported in yaml sections?
"Plugin Name"
Yeah, It works for me atleast
I'm not sure I'd generally advise against it
same
yaml conventions in that picture are not followed at all
for me at least, I avoided using spaces so far
?paste
Spaces are allowed per the YAML spec, it's just that they aren't used a whole lot.
Anyone here knows which items will be displayed invisible in inventories?
Light gray stained glass pane
So far I have Material.FIRE and Material.WATER
haha yeah
Bruh, anyone knows why spigot-api is turning my discord into github:
https://api.spigotmc.org/simple/0.1/index.php?action=getAuthor&id=193922
whats a github
why isnt the debug message being displayed or the "menu" command when I right click the air with the matching displayName?
@EventHandler
public void playerInteractionEvent (PlayerInteractEvent event) {
Player p = event.getPlayer();
if(event.getAction() == Action.RIGHT_CLICK_AIR) {
if (p.getInventory().getItemInMainHand().getItemMeta().getDisplayName().equalsIgnoreCase("§a§lMain Menu §r§7(Right-click)")) {
System.out.println("(debug msg) player right-clicked the air with a main menu item");
p.performCommand("menu");
}
}
}
and here is how the item is given:
public void giveMenuItems (Player p) {
ItemStack Compass = new ItemStack(Material.COMPASS);
ItemMeta compassMeta = Compass.getItemMeta();
compassMeta.setDisplayName("§a§lMain Menu §r§7(Right-click)");
compassMeta.setLore(Collections.singletonList("§7Open the main game menu to switch servers games,etc."));
Compass.setItemMeta(compassMeta);
p.getInventory().setItem(0, Compass);
}
@EventHandler
public void onPlayerJoin(PlayerJoinEvent event) {
Player p = event.getPlayer();
giveMenuItems(p);
}
how would I call an api's onenable and ondisable methods?
you wouldent
if it has onEnable and onDisable, it means you need that as another plugin
Alright, how would I call another plugins onenable and ondisable methods
you dont
thats just a rabbithole you dont want to dive into
probably onlky gonna cause errors
the noteblockapi man said this will fix my error
that image aint loading
o i c
had to open it
So you have two options really
you can actually do call the onEnable and onDisable methods, id bet this will cause some errors but id bet someone else could confirm that. Or you just run it as another plugin and avoid any headache
Why do you need an alternative?
the only headache here is the one you are causing yourself
Might not have to call the methods
just add it as another plugin
?
then you dont need to screw with any onEnable or onDisable shit
I still wanna give it a shot
Alright
have NoteblockAPI as a secondary plugin in your server, have the plugin you're making depend on NoteblockAPI, then just call the methods from the api as its already initialized
how would I call the methods from the api
Contribute to koca2000/NoteBlockAPI development by creating an account on GitHub.
read. the. wiki.
how can i check if a player jumps this @EventHandler public void onJump(PlayerMoveEvent e) { Player player = e.getPlayer(); if ( player.getVelocity().getY() >= 0) { calls the event like 20 times so my code gets executed like 20 times
easier to listen to the jump statistic event
what event is that
thats fine. You can do either in that event
ight ty it works
anyone know why this doesnt work @EventHandler public void onShiftClick(PlayerInteractEvent e) { if (e.getAction() == Action.RIGHT_CLICK_AIR || e.getAction() == Action.RIGHT_CLICK_BLOCK) { if (e.getPlayer().isSneaking()) { im trying to do stuff when a player shift right clicks but nothing happens when i shift right click i have it broadcast a message yes its registered
Is your hand empty?
yes
No event is fired for an empty hand air click
RIGHT_CLICK_AIR
Action.RIGHT_CLICK_AIR ?
i have the exact same event but without the sneaking and it works fine
Not with an empty hand
nothing in my hand
Oh interesting
That makes sense, I'm not sure why I bothered printing RIGHT_CLICK_AIR if I knew that it wouldn't fire with an empty hand.. 😳
Anyways... copied and pasted:
Is there a good library to use for MySQL stuff? I'm really not a fan of running everything async, as it's quite repetitive, and a pain if something goes wrong (with statement itself, etc.)
Is there any library that will run it all async for me? Or am I better off to create a statement handler that runs it async and returns values accordingly.
- Is it even a good idea to make a "StatementHandler" class?
Of course, and I know that - I love to run it async, I just don't want everything related to the DB to just be async tasks though
I'd rather make 1 class for database getters/setters with the tasks there.. than in DBReports and DBUsers
use CompletableFutures with a consumer
Ok, I'll look for some tutorials on that - I've seen that a few times now, so yeah
I'll have to ask, would that allow me to make 1 central class for DB statements?
yes, you shoudl have one point of access to yoru db
I do, don't worry.. thank you
I'll make another thread here in a few when I test out some CompletableFuture stuff, to ensure it is correct and will work properly.
How do you mean
how can i set a mob dropped XP 😐 yes im dumb
MySQL CompletableFuture help
I believe so, yes
throw (your Error);
@quaint mantle
can you help me please
Check javadocs
EntityDeathEvent
Entity
LivingEntity
ok
I'm still not sure about how to correctly use CompletableFuture, the examples I've seen don't return anything... but rather do something, like message a player, etc.
I'm trying to get values
You can;t get data real time
you have to plan ahead, cache ti or run code to use it once it is retrieved
I'm aware of that, it's just that everything I need to obtain would need to be stored somehow, locally- by class (in my case, NPlayer)
I'm really not even sure where to start
You load the data in the async pre login event. Then while the player is online you keep that data in memory, if you make changes you push that (async) back to the db, then drop the data when they quit.
does anyone know about the spigot api (api.spigotmc.org)
https://github.com/SpigotMC/XenforoResourceManagerAPI
I don't know if this is the right channel to ask, however, I have a question regarding it. On the site for one of the examples I see it returns json however when I test it I get plain text along with a 1020 error (im using this for a discord bot) anyone know what the issue could be. The link im testing from is https://api.spigotmc.org/simple/0.2/index.php?action=listResources&category=4&page=2
code I followed for this is from the discord.js website. I just changed the url to be the one above
https:// discordjs.guide/additional-info/rest-api.html#retrieving-the-json-response-from-a-request
Exposes resource/author information via a simple JSON REST API - GitHub - SpigotMC/XenforoResourceManagerAPI: Exposes resource/author information via a simple JSON REST API
what plain text are you seeing? Its valid json to me
and did you enable redirection in your web request?
Code I use java HttpURLConnection conn = (HttpURLConnection) url.openConnection(); conn.setReadTimeout(5000); conn.setInstanceFollowRedirects(true); conn.addRequestProperty("User-Agent", "Mozilla/4.0"); conn.setDoOutput(false);
Any suggestions why this isn't working.
` public static void addReport(Player player, String reported, String reason) {
Connection con = null;
try {
con = Main.hikari.getConnection();
if (con == null) {
player.sendMessage("§cAn error occured accessing Hikari.");
return;
}
PreparedStatement ps = Main.hikari.getConnection().prepareStatement(
"insert into playerReports(reportUUID, reporterUUID, reportedUUID, reportedReason, reportOpened) values (?, ?, ?, ?, ?)");
ps.setString(1, UUID.randomUUID().toString());
ps.setString(2, User.getUUID(player.getName().toString()));
ps.setString(3, User.getUUID(reported));
ps.setString(4, reason);
ps.setLong(5, System.currentTimeMillis());
ps.execute();
} catch (SQLException e) {
// TODO Auto-generated catch block
e.printStackTrace();
Bukkit.broadcastMessage("§cAn error occured: " + e.getMessage());
}
}
`
When I run the command that runs this method, server just crashes.
nvm i'm an idiot.
Yeah, so but whenever I try to load the data.. async, it doesn't load to the variables
I.e; private int SHARDS remains 0.. despite me having > 1000 shards and the statement executing
sysout is yoru friend when debugging
Unfortunately, I already did that a while ago... and the prepared statements ran, and everything - data was collected
It just never updated locally
Thats an issue with yoru code then
do any db stuff async
the server is essentially pausing the main thread to connect and execute your statement
so it's hanging for a few ms
I'm not sure, because I did everything right (before learning of CompletableFuture)
The prepared statements ran, everything ran --- the private int/boolean/String were never updated though
what is your SHARDS field?
Is it because it's private.. but then why wouldn't it be highlighted and/or throwing an error?
why is it all caps lmao
That's not the question I asked, @drowsy helm
There's no harm in trying set it to public lol
DB-wise it's SHARDS, but before running async the method worked properly.. so I'm not sure
Worked properly.. being thrown around very lightly
SHARDS
then you shoudl be doing SHARDS = RESULTS.getInt("SHARDS");
I'll try that out, that's just odd it isn't throwing any error in that case
getInt(3) will simply try to set null, but as SHARDS is an int it will do nothing
Maybe not throwing an error per-sé, but it is odd it won't work with the specified column number
getInt(3) should get you a result, but using column indexes is not a good idea
always use column names
you could also sysout the value your result has, so you can see what data is returning
These are good ideas, I'm fixing a lot of stuff with my database right now (code-wise), so I'll post an update on using column labels =)
Yeah no it still didn't set the values, I'll output data now
I did get this error though? @eternal oxide
soo i have a config ```yaml
api:
player:
var: UUID
Logins:
First: blah blah
Last: blah blah
and i dont know how to iterate over the lists coz players can add mor lists in the lists
how many async tasks are you executing?
There should only be 2, 1 for particles (that aren't even loaded in-game on this server), and the other for MySQL
not enough memory set for your server?
I feel like 8GB should be good?
yep
I'm not sure what's causing this then, I'm quite upset about this
I'm about to start crying and rethinking life choices
But seriously, I'm really not too sure anymore --- I'm not sure why stuff like this never seems to work like on the tutorials 😳
like the user might want
api:
player:
var: UUID
Logins:
First: blah blah
Last: Blah Blah
BotData:
Weapon: weapon
Aromur: health
Shop:
itemone: blah
itemtwo: blah
itemthree: blah
does anybody have any ideas on this ^^ ? ping me if you do
please dont compare item names
use pdc ids its more robust
Or .isSimilar()?
ok I will look into that
I've began printing out information.. yeah the data is there, it prints into .log, but why aren't the variables being set?
yeah or isSimilar but you have to keep a copy of the item
wrong instance of the class?
Wdym
I'm just spit-balling things which could cause it, I don;t know your code so it's pure guesswork.
I've shared the code that would be causing issues, I haven't changed it drastically since adding the printing out of information.
This is my new code, nothing huge has changed..?
No, I'll look into how to make a new thread with spigot then?
i cant find much information on this - can you elaborate?
?pdc it's a bit overkill. Probably good to go with waht Jrouznikek said and use .isSimilar
keep a copy of the itemstack
wdym with spigot?
Well I'm not sure what to do with that exactly, as I've only seen the .runTaskAsynchronously()
I see no reason for this code to not set yoru values, not unless you have teh wrong instance they are updating.
I'll look at both how to make a java thread, and spigot thread
Me too
That makes two
It's a shot in the dark not too sure why you're getting the issue
dont worry about using it alongside spigot
I'm also not too sure, I'm fairly okay with development.. but this database stuff is really kicking me down flights of stairs here
yeah db can be a pain sometimes
Should I place this in onEnable()? Is it safer if I make a new Thread class instead?
yeah that works fine
ok thanks
So... would this be or do anything? Or rather should I make multiple threads (which seems risky) for each statement?
I'm not sure if run or start are the same thing
Yes, no Bukkit API
start actually executes it on another thread
So do I need any logic in the start() method?
nah
Okay
just run
Okay, so in run() would I place my getters for the database?
yeah
I'm a tad lost, and I'm not sure where
you should be able to copy paste everything over
In that case, I should make a private UUID variable?
for what?
Getting a user's information
depends how you want to structure it
you could just pass the entire class in and set them
Expand on that
or just make a thread in update_or_load method
Perhaps, I just fear of making up to 45 threads (nearly) at once
(45 Max players on my server)
Unless that doesn't matter
Obviously I'm not an expert on Threads and databases
It shouldn't be all at once, not after I complete my updates to userinfo
well think about it this way
Which I should do right now
would you rather queue 45 db requests on the same thread and have to wait for them to finish one after another
or do them all at the same time
Do them all at the same time
threads are relatively safe anyway
the worst that can happen is you crash the server
cant crash the machine like c++
XD? In that case, I have a class for local player data (last chat message, last chat time, etc.) NPlayer, should I store the updated values there, and then when they quit - store that to the database?
That sounds like the thing that everyone has been telling me, I just haven't found a way to put it to text
yeah thats how most people do it
What's ORM
object relational mapping
basically i can pass in any object, and it saves all it's variables dynamically
without having to manually define each variable
Question,
I store NPlayer's in a hashmap by UUID --- so the new NPlayer(uuid) is only called ONCE.
If that's the case, should I request user info when it's called?
I didn't want to reply to that message but regardless
And yes, that sounds like very nice
Load from the DB whenever a new NPlayer(uuid) is created
The constructor is only called once per player when they login
Okay cool deal
then save it every so often, and when player leaves
Okay, so make a runnable for..... 60 seconds? To save data if data doesn't match?
just save data
dont have to check if it doesnt match
it's computationally cheaper to just save blindly
Ahh
In the AsyncPlayerLoginEvent, should I check if the result is allowed before loading?
how can i remove the death message thingy? basically they dont get the option to "respawn" or "main menu".
ive tried player.spigot().respawn but it doesnt work cause it gets called before the player dies
like instant respawn?
Well, there is a gamerule for it in newer versions of the game
oh whats the gamerule
just cancel the EntityDeathEvent
set their health to max
and tp to spawn
oh might be a gamerule idk
thats smart-
I'm not sure, google is your friend
I think its something like ALLOW_INSTANT_RESPAWN
DO_IMMEDIATE_RESPAWN
Would anyone happen to know why this is being caused?
https://paste.gg/p/anonymous/096f60a0318947808c76ced2653e6735
Contribute to FroostySnoowman/XOSurvivalCore development by creating an account on GitHub.
because "rsp" is null
are you depending on the plugins
because that will effect initialization order
I am depending on Vault. depend: [Vault] in my plugin.yml
I just don't understand why it's happening. It's quite bizarre.
you need a economy plugin
I see, but I have no economy hook into it?
I'll get those two, one moment
if you're gonna be accessing these services you need something which implements all the api
What's the difference between vault's permission hook and something like if (player.hasPermission("xo.texturepack.other")) {?
no idea
Okay, so that fixed it, however, I'm back to a weird question...
vault will query the permission plugin via its API. Player.has() checks teh current players permission
always use Player.has over Vault permission unless you want perms for a different world
Here's all of my code: https://github.com/FroostySnoowman/XOSurvivalCore
The issue occurs in line 41 of this https://github.com/FroostySnoowman/XOSurvivalCore/blob/master/src/main/java/fwoostybots/com/xosurvivalcore/Events/JoinEvent.java
The exact same method on line 43 https://github.com/FroostySnoowman/XOSurvivalCore/blob/master/src/main/java/fwoostybots/com/xosurvivalcore/Commands/ResourcePackCommand.java gives me the prefix.
Why doesn't it give me the prefix in the JoinEvent?
I've tried a few things, such as making the priority the Highest.
It's just quite weird. https://fwoostyhub.com/🍞🔋🌰🚀
... alternatively, how would I just get the prefix from Luckperms as I've been trying this for hours and I really have nothing else to try.
listen on Monitor
Could you explain that a bit further, please?
or delay your sendMessage
Monitor level for teh event Listener. It runs last of all
you want to process the event as the last plugin
Hm, is there any documentations on how to Monitor level it?
I've never done that before.
https://www.spigotmc.org/wiki/using-the-event-api/ Advanced Functions section
@EventHandler(priority = EventPriority.MONITOR) just like so?
That didn't work either
How would I just delay the message?
@EventHandler(priority = EventPriority.HIGHEST) I also tried this.
and lowest... and everything in between.
What exactly does "MONITOR" mean,, what does monitoring an event mean, how it different from just normal
the priority is when the listener is called
lowest -> low -> normal -> high -> highest -> monitor
so while lowest is called as such, it’s technically the first one to have control over the event
however, monitor, being the last one, has the final state of the event for logging
Listeners with monitor priority should not set any variables in the event or cancel it, only read and log using them
I'm just going to try to delay it. I have this in my JoinEvent.class java @EventHandler(priority = EventPriority.HIGHEST) public void onJoin(PlayerJoinEvent event) { Player player = event.getPlayer(); String join_message = main.getConfig().getString("join-message"); for (Player e : Bukkit.getOnlinePlayers()) { e.sendMessage(MiniMessage.miniMessage().deserialize(join_message, Placeholder.component("player", player.displayName()))); } // Give the player the resource pack prompt player.setResourcePack("https://www.dropbox.com/s/rieh4n8tvkjh1gw/dd.zip?dl=1"); }
In my main.java, I have this: ```java
private void joinEventStuff() {
// Wait on the join event
getServer().getScheduler().runTaskLater(this, () -> {
}, 1 * 20L);
}```
How would I make it delay the onJoin event?
Wait why are you sending a join message to all online players? Does broadcast not work?
How would I broadcast?
Bukkit.broadcastmessage or whatever it is
That also sends to console it seems, so I'm going to stick with my way as I think it's better?
it does indeed send to console
I've just been told multiple times that I should delay the message as the player.displayName() doesn't get the prefix in the join event, but it does in my commands.
Well if it works don't fix it
I do gotta fix it, I need the prefix.
The scheduler should work, does a delay of 1s not work?
Just not sure what to put inside the scheduler.
Well, if the player.displayName() needs to be in there put that
Heh, so I've never really used stuff like this, how would I get player from the joinevent and put it in there
getServer().getScheduler().runTaskLater(this, () -> {
for loop here or w/e you need
}, 1 * 20L);
Oh, so I put the whole event in there basically?
Yeah, whatever needs to be delayed
private void joinEventStuff() {
// Wait on the join event
getServer().getScheduler().runTaskLater(this, () -> {
public void onJoin(PlayerJoinEvent event) {
Player player = event.getPlayer();
String join_message = getConfig().getString("join-message");
for (Player e : Bukkit.getOnlinePlayers()) {
e.sendMessage(MiniMessage.miniMessage().deserialize(join_message, Placeholder.component("player", player.displayName())));
}
// Give the player the resource pack prompt
player.setResourcePack("https://www.dropbox.com/s/rieh4n8tvkjh1gw/dd.zip?dl=1");
}
}, 20L);
}``` Like this? 😂
try it and see. Probably don't need the set resource pack in there. Remember only put in there what needs to be run later
oh jeez
😂, it's probably horribly wrong
Yes yes it is
What shall I do differently (I've never done this before as you can tell)
Well besides learning java your scheduler needs to be inside the event not the event inside the scheduler. You can use it inside of it
How would I getServer().getScheduler().runTaskLater(this, () -> {?
what are you trying to do
Basically make my whole join event delayed a second so that the prefix actually appears :P
what prefix?
@lime moat are you using Paper's API?
why not have a runnable inside of your event
Indeed
I couldn't help but notice that you said Player#displayName()
So, I'd go to the Paper Discord then, unless you're receiving good help here... this is the Spigot Discord
Spigot and BungeeCord
his problem isnt paper specific
Ahhhh, nevermind carry on
So, I'd make your own class for the runnable... so it's more controllable
Is it not possible like this? I feel like this way is much easier and as long as it works... it works :P
your way logically doesnt make sense
so what do you mean by "prefix actually appears"
Maybe try the LOWEST priority of the event, and what other plugins do you have installed?
Like where is the prefix coming from?
Ok, so I assume you use LuckPerms for prefix - why not try accessing the LuckPerms & Vault API
And set the displayname via your plugin
@lime moat ?
I see, is there documents on how to access the Luckperms prefix? I haven't attempted to got that far?
Froosty you know there is a setJoinMessage method in PlayerJoinEvent
you dont need to send a message to all players
That would still give me the same issue, however, I'll look into that
yeah you'll have the same issue just saying its more efficient lol
Agreed
@lime moat any update?
Not really, can't figure anything out.
Tomorrow I'll probably just look into luckperms and vault prefixes.
i made this code and the packet are not working strangly https://sourceb.in/0VJ4kPYV6Q anyone have a clue?
#getBooleanValue() could really use a switch
just do it normally but use a runTaskLater with 20 ticks so it will be one second delayed
and load the messages before that
how do i get zombies not to hunt players anymore
EntityTargetEvent?
No idea sorry, never worked with packets before
don't worry
I'm having a lot of trouble on something seemingly simple. Anyone care to help?
also what is ur about me 👀
?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. Make sure you use the right channel regarding the topic of your question. Create a thread in case the channel is already in use!
what?
.. it's abit ;-;
yea ofc
imagine lobster with boobs
Well I got some code that makes a player config i.e. uuid.yml. I'm having trouble setting and getting strings in the uuid.yml.
oh i had a pfp of a lobster a long time ago and i loved it (and i made this 3D model and i like it)
what do you have so far?
send code
i made wands and vanish wand but entities still targets players when clicked the wand
ah yes, makes sense
aight im on pc
uh
you made the model? it's really nice
#general thanks
we were just talking relax :/
Main.getInstance(); 🤮
they asked for help
people really don't wanna use di
- Use di
- Don't name your plugin class Main
- Don't store your userFile variable outside the method
- don't get the data folder as a string
?configs
See this wiki page on how to use custom configuration files: https://www.spigotmc.org/wiki/config-files/
Guide to dependency injection: https://www.spigotmc.org/wiki/using-dependency-injection/
?main
userFile = new File(main.getDataFolder().toString()+ File.separatorChar + "PlayerConfigs" + File.separatorChar + e.getUniqueId().toString() + ".yml");```
You don't need all those .toString()
Does anyone know what this is?
changed the main class name
im still using di
thanks for the suggestion @iron glade
?xy
Asking about your attempted solution rather than your actual problem
?paste
I have no idea what I'm doing when it comes to DI and manager classes, can someone tell me if I'm completely butchering this, thanks https://paste.md-5.net/gayepiqebi.java
https://github.com/Bukkit/mc-dev is it legal to clone this repo to my computer to study it?
Contribute to Bukkit/mc-dev development by creating an account on GitHub.
2014 💀
yes you can clone it
you cant redistribute ig
I have no intention to do so, I just wanna figure out how it works in details
Can there be many event handlers in a single listener? ```java
public class SpawnRelocation implements Listener {
@EventHandler
private void onPlayerJoinEvent(PlayerJoinEvent e) {
}
@EventHandler
private void onPlayerChangedWorldEvent(PlayerChangedWorldEvent e) {
}```
Is there a different way to do with just a single event handler?
Yes you can register one directly with the PluginManager
But you should still use a listener class regardless
public abstract class Command {
ArrayList<Command> subcommands = new ArrayList<>();
public List<Command> getSubcommands() {
return subcommands;
}```
if my abstract class is like this, does everything that extends it have its own instance of the arraylist subcommands or is it joint?
they have their own each
^
nice
if you'd make "subCommands" static then they'd share it
thats one crucial concept of object orientation
Yeah that makes sense
Any utils to register a command without the plugin.yml?
its for my command builder
Thanks, you're a lifesaver
basically you just need to get the CommandMap, then you can call register() on it
and you can get the commandmap from the private field in SimplePluginManager (Bukkit.getPluginManager())
Yeah that makes sense, spigot should probably make that more accessible, though it doesn't really matter
yeah it wouldnt hurt to just make a getter in PluginManager
How do I make mobs bigger then normal? Like making giant / tiny withers or pigs?
you can't, iirc
How does hypixel do it then :/
can you show a screenshot?
sure give me 1m
shows a giant
I wont lmfao
paper has one
Massive upside down wither
where? I don't see anything in papers pluginmanager interface
it’s under Server i think
oh yeah. weird, I'd expect it in PluginManager instead
paper still hasnt fixed the annotation bug 😦
And this one
hm good question, no idea. probably some resource pack magic and it's not actually a wither
Resource pack? It's hypixel skyblock, no resource packs
then I have absolutely no idea
Hmm ok
how can I get a Map<String, Boolean> from this config:
enabled-commands:
screen: true
close: true
do you actually need a map? Can't you work with the ConfigurationSection?
if I would know what that is xD
Apparently naming it dinnerbone makes it mini
if you really need a map, you gotta turn it into one yourself: https://github.com/JEFF-Media-GbR/JeffLib/blob/master/core/src/main/java/com/jeff_media/jefflib/ConfigUtils.java#L18
Avoid writing the same code over and over again - use JeffLib for your Spigot plugins! - JeffLib/ConfigUtils.java at master · JEFF-Media-GbR/JeffLib
to get a configurationSection, just do
ConfigurationSection section = myConfig().getConfigurationSection("enabled-commands");
boolean isScreenEnablewd = section.getBoolean("screen");
a configurationsection is basically like a "subconfig"
Can I do that with a nametag to test?
oh ok :D
or does it need to be done with commands / spigot?
I thought Dinnerbone was upside down
dinnerbone is upside down, yes
okay so
i got it to work for certain entities
but not for withers
here's one 100 sized phantom and one 1 sized phantom (the burning one)
a wither always seems to be the same size
that's just /summon phantom ~ ~ ~ {Size:<number>}
How would I edit this with code?
?????
Go there
No
get the NMS entity's TagCompound, then set "Size" to whatever you want
Have you tried neg numbers for wither
Plz #help-server
Do I have to use NMS, is there not a way with built in methods?
yeah, nothing
🥺
no, there is no API for NBT. But there are libraries like NBTEditor
NBTEditor is good
Aight ill play around with what entities work and try to make something good