#help-development
1 messages · Page 1753 of 1
mhm!
Looks like it, thanks!
also i'm having an issue with my own code, and i'm not sure why. a basic event isn't triggering, and i know i'm missing something, i'm just not sure what (it's been months since i've created plugins)
You're registering the event, and using the handlers?
if by that u mean
this.getPluginLoader().createRegisteredListeners(this, this); in the onEnable, and @EventHandler over the event method, then yes
i watched a coding stream yesterday and they were figuring out an issue for like a good half hour and they registered the wrong event kekw
i'm hoping that's not the case 😭
You should be using something like this
PluginManager pluginManager = this.getServer().getPluginManager();
pluginManager.registerEvents(new OreFormEvent(), this);
The this is a plugin
Using this as the listener should work as well as long as you implement Listener
ah! i was doing it thru the plugin loader, that's prob the issue. thank u!
lemme double check
yup! that works! tysm!!
according to my ide Bukkit.getServer().getScheduler().scheduleSyncRepeatingTask(mainClass, new BukkitRunnable() { scheduleSyncRepeatingTask is deprecated?
Use the various runTask methods
runTaskTmer?
yeah
to be more clear, try this, specifically?
new BukkitRunnable() {
public void run(){
//Code
}
}.runTaskTimer(plugin, 0, 20);
``` (apologies if it doesn't work, i'm only googling to find answers, as i haven't coded a plugin in months)
p sure!
thanks!
BukkitTask task = new BukkitRunnable() {
public void run() {
}
}.runTaskTimer(mainInstance,delay,period);
mhm!
?scheduling ftr
whats the method to send a message that looks like a player?
well
Player#chat is a thing
if not just send a message to everyone with the correct formatting
i think ill do the latter as id also want ones that arent actually players inside minecraft
is the send message to everyone Server.broadcastMessage ?
hello
what's wrong with this code it isnt working...
Main class onenabled code :
getConfig().options().copyDefaults();
saveDefaultConfig();
JoinLeaveListeners code (which is not working)
public class JoinLeaveListeners extends JavaPlugin implements Listener {
@EventHandler
public void playerJoin(PlayerJoinEvent e){
Player player = e.getPlayer();
player.teleport(getConfig().getLocation("spawn"));
e.setJoinMessage(getConfig().getString("joinmessage").replace("%player%" , player.getDisplayName()).replace("&", "§"));
}
}
And is coloured text possible
only ONE class should extend JavaPlugin
yee but i also need getConfig in other classes
?di
Guide to dependency injection: https://www.spigotmc.org/wiki/using-dependency-injection/
you don;t extend JavaPlugin anywhere but your plugin entry class
You can probably just pass the plugin class from your plugin into the listener
also how do i get the correct formatting
or is it just the default how a player messages
yeah just
<name> message
yes
Use the enum
ok thanks
ChatColor
Player#sendMessage("<" + Player.getDisplatName() + ">" + ChatColor.Blue + message)
is using a flint and steel counted as a block place event for Material.FIRE?
So I've made a custom block with a red mushroom material, how can I make it so that if a player walks over it with the PlayerMoveEvent I can distinguish between one of my blocks and a vanilla red mushroom
"<" + player.getDisplayName() + "> §b" + message :>
I think I'll be sticking with the enum thanks
the enum will just replace the & to § for you
That’s not the point tho
Again, I'll be sticking with the enum thanks
First of all way more readable and also it avoids some encoding issues
to fix the encoding issues just fix it yourself
Wat
Yeah no I'm gonna use the enum, it's just much easier

No lol
yes lol
They’re not the same
no it wont
What's the asBungee method for
If you translate & to § yes maybe
Believe it turns it into the bungee ChatColor type
I assume I don't need to worry about that
org.bukkit.ChatColor -> net.md_5.<whatever>.ChatColor
If you can, use bungee chat api over the Bukkit one
why?
What's the difference
because the Bukkit chatcolor isn’t being updated anymore
For instance it’s still an Enum
Oh alright ty
it was outdated...
I tried another way but still it isnt working
Main class :
public static KnockbackFFA INSTANCE;```
``` @Override
public void onEnable() {
INSTANCE= this;
getConfig().options().copyDefaults();
saveDefaultConfig();
getServer().getPluginManager().registerEvents(new JoinLeaveListeners(),this);
}
other one :
public static KnockbackFFA INSTANCE=KnockbackFFA.INSTANCE;
@EventHandler
public void playerJoin(PlayerJoinEvent e){
Player player = e.getPlayer();
player.teleport(INSTANCE.getConfig().getLocation("spawn"));
e.setJoinMessage(INSTANCE.getConfig().getString("joinmessage").replace("%player%" , player.getDisplayName()).replace("&", "§"));
}
}```
The summary of error i've got
[22:24:50] [Server thread/ERROR]: Could not pass event PlayerJoinEvent to KnockbackFFA v1.1-BETA
org.bukkit.event.EventException: null
Delete the copyDefaults line. It does nothing.
INSTANCE is null because its not initialized
you never set it
also ?di is not outdated. its just fine
it was i tried using it but blockbreakeventlistener and also fancylogger werent able to use
it is 100% not outdated. Its just fine
maybe thats because im using java 1.8
makes no difference
...
Dependency Injection is passing a reference from one class to another
whats the advantage
of it no longer being an enum
Hex representable ChatColor instances
btw i did
yes, INSTANCE in yoru main class is null
uhhh what should i do for that?
no it isnt null
initialize it. it current has no assignment
yes, but when you grab a reference it IS null as you do it statically
ChatColor.stripColor only removes § symbols but not & symbols, is this intended?
the INSTANCE in your listener accesses KnockbackFFA.INSTANCE before it has been set via INSTANCE = this;
therefore, it's null
sooo
public static KnockbackFFA INSTANCE = KnockbackFFA.getPlugin(KnockbackFFA.class);```
must work fine right?
no
well
no, as you are doign it as a Field
just remove your static Field in your listener and access the static directly in main
or do it properly and use DI
hm
You only make one call to it so Main.INSTANCE
so you mean i have to remove the static from my main class and in other class i should directly get that class right?
no
leave static in Main, delete the whole Field in your Listener and replace your INSTANCE in your Listener code to use Main.INSTANCE
btw a Field is a variable defined at the Class level.
If I use a § and a & symbol in the same message, it will only remove the first symbol
ChatColor.translateAlternateColorCodes
I want to strip the colours
Like this in the event listener?
*nope
But it won't work when there is two
Read what I said properly
LOL
I use JavaPlugin.getPlugin(My plugin class) 🥶
That’s good tho
Long code
I use dependency injection
e.g. public MyDependent(MyPlugin plugin)
as a sane person should
I rarely pass my plugin instance but yeah dependency injection superior
No, I said delete that
Ooh something that i use
nice. have ideas to make the sell wand go in?
Uhh what's the problem i Cant really see it Well on my phone
so pretty much i want for the wand to go into the clear spot
and as you can see, it doesnt
Solved. I just realised that ChatColor.stripColor only removes § so I replaced all & symbols for a §
what are the hexes for ChatColor
What do you mean
public static final ChatColor BLACK = new ChatColor('0', "black", new Color(0));
public static final ChatColor DARK_BLUE = new ChatColor('1', "dark_blue", new Color(170));
public static final ChatColor DARK_GREEN = new ChatColor('2', "dark_green", new Color(43520));
public static final ChatColor DARK_AQUA = new ChatColor('3', "dark_aqua", new Color(43690));
public static final ChatColor DARK_RED = new ChatColor('4', "dark_red", new Color(11141120));
public static final ChatColor DARK_PURPLE = new ChatColor('5', "dark_purple", new Color(11141290));
public static final ChatColor GOLD = new ChatColor('6', "gold", new Color(16755200));
public static final ChatColor GRAY = new ChatColor('7', "gray", new Color(11184810));
public static final ChatColor DARK_GRAY = new ChatColor('8', "dark_gray", new Color(5592405));
public static final ChatColor BLUE = new ChatColor('9', "blue", new Color(5592575));
public static final ChatColor GREEN = new ChatColor('a', "green", new Color(5635925));
public static final ChatColor AQUA = new ChatColor('b', "aqua", new Color(5636095));
public static final ChatColor RED = new ChatColor('c', "red", new Color(16733525));
public static final ChatColor LIGHT_PURPLE = new ChatColor('d', "light_purple", new Color(16733695));
public static final ChatColor YELLOW = new ChatColor('e', "yellow", new Color(16777045));
public static final ChatColor WHITE = new ChatColor('f', "white", new Color(16777215));
You will have to convert the ints
alr ty
should i register a CommandExecutor class like Listener classes in main class?
getCommand(name).setExecutor
Index Out Of Bounds when Bukkit.createWorld() is used
'setExecutor(org.bukkit.command.CommandExecutor)' in 'org.bukkit.command.PluginCommand' cannot be applied to '()'
Well yeah
lol
It takes an executor instance
oh
anyone knows why my IntelliJ doesnt show the spigot symbol on the plugin.yml?
it works in my other project which also uses the Minecraft Plugin
it isnt working wt
Cannot resolve symbol 'CommandKits'
you need to create the class
And import it
^^
the class that i created the command in it
or a new one
so if you use SoundEngine here you need to also use SoundEngine somewhere on the left in the .class files
yee i got it
good
does anyone know how to include the maven dependencies to the jar in intellij
A specific block or? You can use PlayerInteractEvent for this iirc
yes
Hey, I'm using the WorldGuardWrapper and was wondering if there's a way to change a cuboid region area? I'm using https://paste.bristermitten.me/feworajofi.coffee to create the region but I don't know how to change the corner locations of it
looks kinda complicated for me
its easy
just check if they right click a block, then what that block is
on player interact event, if block type is what you need do something
@EventHandler
public void RightClick(PlayerInteractEvent event) {
Material i = event.getPlayer().getInventory().getItemInMainHand().getType();
Player p = event.getPlayer();
if(i == Material.NETHERITE_HELMET || i == Material.DIAMOND_HELMET || i == Material.IRON_HELMET || i == Material.GOLDEN_HELMET || i == Material.LEATHER_HELMET || i == Material.CHAINMAIL_HELMET || i == Material.TURTLE_HELMET || i== Material.DRAGON_HEAD || i== Material.SKELETON_SKULL || i == Material.WITHER_SKELETON_SKULL || i == Material.PLAYER_HEAD || i == Material.ZOMBIE_HEAD || i == Material.CREEPER_HEAD) {
if(event.getAction().equals(Action.RIGHT_CLICK_AIR)) {
ItemStack equipped = p.getInventory().getHelmet();
ItemStack hand = p.getInventory().getItemInMainHand();
p.getInventory().setHelmet(hand);
p.getInventory().setItemInMainHand(equipped);
}
}
}
}
This is an example
oh my that's a lot of if else's
armor switching xd
Couldn't you make a list of those and check if the material is in the list to make it more tidy?
Yeah you probably want an EnumSet
Or an EnumSet ;p
too lazy to implement anything else, this does the job well enough
only need the list once anyways
wait why is there no ConfigurationFile.getChar() method?
How do I do that instead
ah nvm
switch syntax sux
Would be nice if we could shortform stuff like this
Maybe something like var == (a || b ||c)
do you have Tag.ARMOR.contains(material) on spigot
Oh forgot about that
No
sad
Not hard to make your own tag system with enum sets
I have one for each armor part and the various tools
Why not a switch 🥶
But you'd have to update a plugin everytime when New armor got added to the game
Effeciency?
Still if'd be nice to have tags on spigot natively
idk if spigot will ever take paper features
any ideas how to make this using reflection?
Just doesn’t have a tag for armor
a lot of pain
Ik the red part is 1.17 and green one is 1.17.1 and I am making my plugin work on both using reflection. Pathfinding is the last thing before I'm done with reflection
it's almost the same just these two letters 😢
I didn’t know 1.17.1 was a different NMS version
I guess so? I didn’t think so either
yes? check it tho
Oh 🥶
If it does and you don't want to modify b just use (b+1) instead
Hi, I'm new to spigot programming, and I've been running into an issue I have hard time finding help for online.
Basically, I'm trying to add a new smithing recipe where combining an iron pickaxe with a diamond results in a diamond pickaxe with a specific ItemMeta attached to it.
Adding the recipe works fine, but the resultant diamond pickaxe does not have the itemmeta attached to it. It's weird to me bc I use a method to generate the custom diamond pickaxe, and calling it in other contexts works as expected.
public static Recipe getDiamondCoatedPickaxeRecipe(NamespacedKey nms) {
ItemStack ironPickaxe = new ItemStack(Material.IRON_PICKAXE);
ItemStack diamond = new ItemStack(Material.DIAMOND);
SmithingRecipe recipe = new SmithingRecipe(nms, getCoatedPickaxe(ironPickaxe), new MaterialChoice(Material.IRON_PICKAXE), new ExactChoice(diamond));
return recipe;
}
I was wondering if anybody had any experience with this, and if this is expected behavior, and something I'm going to have to work around on.
Use exact choice not material choice
it will ask for a ItemStack,you can create the itemstack first,give it a meta with name then create the recipe
Is there a particular reason why you prefer exact choice? I'm using material choice bc it allows for damaged iron pickaxes to be used in the recipe.
public static ItemStack getCoatedPickaxe(ItemStack ironPickaxe) {
if (!ironPickaxe.getType().equals(Material.IRON_PICKAXE)) {
if (SlardcraftPlugin.DEBUG) Bukkit.broadcastMessage("ERROR: UNEXPECTED ITEM FOR IRON PICKAXE: " + ironPickaxe.toString());
throw new IllegalArgumentException();
}
ItemStack is = new ItemStack(Material.DIAMOND_PICKAXE);
ItemMeta isMeta = is.getItemMeta();
isMeta.setDisplayName("" + ChatColor.AQUA + "Coated " + ChatColor.RESET + "Pickaxe");
//isMeta.setLocalizedName(getCoatedPickaxeMeta(ironPickaxe));
is.setItemMeta(isMeta);
return is;
}
This is the function I use
also im mostly refering
new MaterialChoice(Material.IRON_PICKAXE) This is the left side of the smithing table
We need a predicate recipechoice
ah nvm thats the result
no worries
What do you mean by predicate recipe choice?
It results in a default diamond pickaxe
thats wasnt an answer though, the recipe choice where you can do custom checks on ItemStacks. For example, checking if ingredient has custom model data or pdc tag
why
Yeah, I'll try some stuff. I have command that calls the same getCoatedPickaxe() method, and it returns the proper result.
Not a big
Big
Rude
The meta of the input item is copied, since that’s how smithing tables work
Use the event if you want a custom output
There is a Jira ticket somewhere, something about not knowing what to do when the plugin is disabled
Yeah it should just be a material
But you can make use of the itemstack in the event since you can just grab the result of the recipe
hmm yeah at least its a work around
I see, that explains why the durability was being transferred to the new pickaxe
Cool, I'll try this. Thanks guys.
yes recipes other than crafting ones were always... buggy
even they got fixed in recent versions
Just got it working.
For anyone curious, I just set the resultant item stack of the smithing recipe to a diamond pickaxe and created a listener for PrepareSmithingRecipeEvent
@EventHandler
public void coatedPickaxeListener(PrepareSmithingEvent event) {
if (!event.getResult().getType().equals(Material.DIAMOND_PICKAXE)) {
return;
}
ItemStack ironPickaxe = event.getInventory().getItem(0);
if (!ironPickaxe.getType().equals(Material.IRON_PICKAXE)) {
return;
}
event.setResult(CoatedPickaxe.getCoatedPickaxe(ironPickaxe));
}
Does that work
Yeah
Interesting, must have been fixed then
Last time I tried to use setResult I couldn’t take the time out
Does anyone know how to set the random tick rate of a world through code?
I would expect it to be something simple like getWorld().setTickrate(int)
Nevermind, seems to be under setGameRule
Yea it’s simple, you could also issue a console command, though it’s not necessary
hey, if I wanted to heal a player fully. I would just player.setHealth(10); ?
could cause issues
is there an alternative i could use?
first thing that comes to my mind is apply instant health effect of a very large scale
but might be scuffed if theres a better solution
how come?
if the player has less or more hearts like through health boost effects
setHealth
yes thats what I mean
heal a player fully --> if he has 24 hearts instead of 20 through health boost, that gets cancelled
just give the effect of instant health
wait
targetPlayer.setHealth(targetPlayer.getMaxHealth());
6 years old tho
check if it still works @tame elbow
replaced by?
GENERIC_MAX_HEALTH
getAttribute
try if it still works anyway, even if it is deprecated
np
?paste
hey guys im' just wondering if this looks about right for sending a piece of data via a socket
its supposed to send a message from a onPlayerCommandPreprocessEevnt() through a socket to my server where my jda bot chills at
yup that's a socket alright
I'd probably recommend a message queue or just putting the jda bot in the plugin, but if you want to use a socket that's ok
Depending on my code, is it possible to get an error depending on whether or not you use a lambda expression?
thanks md_5!
(Bukkit.getScheduler().runTaskTimer(plugin, () -> { do stuff
@Override
public void run() { do stuff
yes i know what lambda is but what do you mean get an error on whether you use it
like if they dont use a lambda expression you throw an error?
well, the idea is to do it differently then discordSRV https://www.spigotmc.org/resources/discordsrv.18494/?__cf_chl_jschl_tk__=pmd_zmjjMdAAivsx9xjWgWsCTToWtp_3_9Vl1MBsa3vQl.c-1635730689-0-gqNtZGzNAjujcnBszQn9
i figure a centralized bot might be a bit more user friendly for newer server hosters
I am getting an NPE error because I am using a lambda expression.
can you show your code
yeah full code and the error
because you cant get an npe for using lambda its probably something else
you know theres a @Setter notation with lombok
yes i know
which is line 95?
the line 95 Location holo = getFindEntity().getLocation().clone();
Is there any way to remove the UI that comes up when you start up a server locally? For me I would rather just use the console
-nogui param
Hello, quick question. So I am creating a method that will get an inventory but inside a method I am calling another method that updates content inside that GUI. It wouldn't matter if the method to update returns void since what the method is updating is the same inventory and pointing to the same memory object so there wouldn't be a need to reassign that GUI instance correct?
I have a quick question after looking at a few plugins online I have noticed that they are organized with tons of different files and functions. Now these plugins have a lot of content and have had tons of time to be cleaned up and optimized. Is there any way I should be focusing on writing my code or is it more of an overtime situation with my own self improvents to make the plugin better
I would suggest just keeping your code neat. Create methods for every task you want to do and call the properly instead of having code that looks like junk. For sure look for the a way to get your methods to use less hardware as possible. I would say just avoid using methods that are overkill. Use the best primitive data types. I wouldn't know TBH personally I like to keep my code very commented and call methods for every task to make your main code block look more organized too. For example if you're updating an inventory when a condition is met, instead of updating on the block that's checking, call a method an pass in the inventory instance. Maybe this can help? I'm not very advanced https://stackoverflow.com/questions/12087275/how-do-you-organize-class-source-code-in-java
Thanks
So I am creating a type of xp gaining system when mining specific blocks and everything has gone good so far but I am at the point of the block being replaced and I have it storing metadata so that the server knows the block has been placed so it does not give xp. Now I am thinking the best approach to this would be a hashmap that saves to a file on server shutdown to save the blocks that were placed for when it comes back up. Would this be a good way to do this or is there a faster way?
?clean-code
For large amounts of blocks you probably want a database
I believe you can convert the block data to a string and store that
Would a database make it faster or is it just a better storage option
I believe that the toString method is only a description of the block itself.
Just a storage option
Honestly I don't know if this is a good idea but what I would do is just create a random string as an Identifier then use encode the block to base64 so you can save it as a string under that key. Then just load it back up on server start
Also use the world x y z as a unique identifier
I think that is also a good idea but you would need to convert the World, x, y, z to a single string format, then load Split it back up to actually format the location. If you just encode it instead, you could get the block location from the decoded block.
also every metadata of the block could be loaded back up
Actually the data probably already contains the location
And you would keep the 4 separate, no reason to combine them
Yeah the block contains the location which is why I'm saying that you could just encode the block and when its decoded it will be the block instance so the location could just be accessed from there.
Yeah you can just use a simple auto incrementing key
alr i need some help with particle rotation and animations
im really bad at math, im just trying to make this sphere like rotate...
and i took a bunch of code and mashed it together
idrk what im doing tbh
Hey uh
what's wrong with this while it should save the location in spawn:
but it isnt!
KnockbackFFA.getInstance().getConfig().addDefault("spawn", ((Player) sender).getLocation());
reload?!
reloadConfig.
KnockbackFFA.getInstance().reloadConfig();```
ykw nvm
Don't ghost ping @iron palm
At least say the reason before delete a ping.
Tho I saw that
Uhhh try use getConfig.set();
yeah wasnt working that way
ok
KnockbackFFA.getInstance().getConfig().set("spawn", ((Player) sender).getLocation()); like this??
uh not working
Do you have any console issue? @iron palm
Did you save config? @iron palm
KnockbackFFA.getInstance().reloadConfig();```
it is also removing the guides i have written in config
KnockbackFFA.getInstance().saveConfig();
Why it isnt saving the configs value?
config file :
show the actual config thats saved
any reason i could be getting a ClassNotDef error when the class is defined?
me?
yes
does that class actually exist in your compiled jar?
🙂
nvm i fixed it thanks
Any reason why reload config doesn't work
I almost tried everything but this is the only thing that got it working
Is there an easier way of doing it?
can't hook the placeholder api to my plugin in pom.xml i got an error :Invalid content was found starting with element '{"http://maven.apache.org/POM/4.0.0":repositories}'. One of '{"http://maven.apache.org/POM/4.0.0":parent, "http://maven.apache.org/POM/4.0.0":url, "http://maven.apache.org/POM/4.0.0":prerequisites, "http://maven.apache.org/POM/4.0.0":issueManagement, "http://maven.apache.org/POM/4.0.0":ciManagement, "http://maven.apache.org/POM/4.0.0":inceptionYear, "http://maven.apache.org/POM/4.0.0":mailingLists, "http://maven.apache.org/POM/4.0.0":developers, "http://maven.apache.org/POM/4.0.0":contributors, "http://maven.apache.org/POM/4.0.0":licenses, "http://maven.apache.org/POM/4.0.0":scm, "http://maven.apache.org/POM/4.0.0":organization, "http://maven.apache.org/POM/4.0.0":profiles, "http://maven.apache.org/POM/4.0.0":modules, "http://maven.apache.org/POM/4.0.0":pluginRepositories, "http://maven.apache.org/POM/4.0.0":reports, "http://maven.apache.org/POM/4.0.0":reporting, "http://maven.apache.org/POM/4.0.0":dependencyManagement, "http://maven.apache.org/POM/4.0.0":distributionManagement}' is expected.
<repository>
<id>placeholderapi</id>
<url>https://repo.extendedclip.com/content/repositories/placeholderapi/</url>
</repository>
</repositories>
<dependencies>
<dependency>
<groupId>me.clip</groupId>
<artifactId>placeholderapi</artifactId>
<version>1.16</version>
<scope>provided</scope>
</dependency>
</dependencies>```
why you have this stuff in your project, i dont have this
i wanna hook placeholder api to my project
just add it as Buildpath?
that code is the only way for maven builds
i never done with gradle too ...
i use normal Java xD
i think gradle is better but im using maven for a temporary time and then i would change my build to gradle daemon
ok
is this gradle or is this something else?
Why do you have package for main?
bc i do that everytime?
That's....
and i learned it so
Where did you learn it?
from tutorials, many tutorials
Fuck tutorials
Only skill
(don't take tutorials so seriously, practically all of them teach java not object oriented which is bad)
ok, so its bad using a package for Main.java?
If i remember correctly yes
oh ok..
For me i create entire new class called plugin Name + Controller in which i do all operation on start / disable server and I have everything in main class clean
Name your plugin entry class the same as your plugin.
Anyone?
the instant you call disable on your plugin, all execution within terminates
🥶
You are literally turning off the power and wondering why the lights went off too
.
just call reloadConfig()
It doesn't work
why turning off your plugin?
I tried
its a single thread
I tried everything else I could think of
?
all plugins run on a single main thread
when you call reloadConfig() everything waits for your config to be reloaded
Ok?
a slight simplification, but thats the general process
you need do no more than call reloadConfig()
What else?
nothing
?
?
you literally call reloadConfig(), nothgin more or less
If you are seeing an old config, then you are holding a reference to an out of date FileConfiguration somewhere
if thats the name of your plugin, yes. However you should really pass an instance of your main class rather than getting the plugin statically
I am in my main class
then just call reloadConfig()
disabling the plugin and then trying to reload it :/
you don;t need a plugin reference as your main IS your plugin
bruh
oh k it was becuz my function was static
so now how do i reload config in another class?
you pass that class a reference to your main class
sheesh
?di
Guide to dependency injection: https://www.spigotmc.org/wiki/using-dependency-injection/
With a constructor?
yesh
k this?
yes
you are trying to access plugin in a Field when its only set in your constructor
at that point plugin is null
you have to read the values after you assign plugin
bukkit.command.PluginCommand.setExecutor(org.bukkit.command.CommandExecutor)" because the return value of "com.amazindev.amazinutilities.AmazinUtilities.getCommand(String)" is null
your command doesn;t exist in your plugin.yml
yes, because you set the value to a Field when your command class is instanced
hmm i'm kinda struggling to find a way to save a Map<UUID, ItemStack[]> to a file. The ItemStack[] is saved in a base64 string so in fact its Map<UUID, String> but i want to save it like
safe-chests:
- uuid1 : base64-string
- uuid2: etc
a Field never changes unless you change it. So you need to update it after you reload teh config
The - is pointless
now i have it like this
dataFile.set("safe-chests", SafechestGui.getMenus().values().stream().map(InventorySerialisation::itemStackArrayToBase64).collect(Collectors.toList()));```
an ItemStack would actually be shorter saved through serialization to yaml rather than converting to base64
like thies?
SafechestGui.getMenus().forEach((key, value) -> dataFile.set("safe-chests." + key, InventorySerialisation.itemStackArrayToBase64(value)));
Yes
lets try it
Still doesn't work
md_5, when we will have a spigot meetup
Wrong channel
it doesnt depends on time or something, i just want a short thing for a whole inventory
is there any way to get leashable entities in NMS or spigot?
Wdym
entities that in vanilla can be used with lead
Every living entity can
didn’t know that was a thing
Find out the criteria and just check yourself?
Its gonna be something easy like instanceof Living and not instanceof Monster
Is "onTabCompete" exclusive to commands, or can it be used in the normal chatbox aswell. I assume so, but couldn't find anything.
They’re living and not monsters
public static boolean isLeashable(LivingEntity entity) {
switch (entity.getType()) {
case WOLF, CAT -> {
return ((Tameable) entity).isTamed();
} case AXOLOTL, BEE, CHICKEN, COW, DOLPHIN, FOX, GOAT, HOGLIN, HORSE, ZOMBIE_HORSE, SKELETON_HORSE, IRON_GOLEM, LLAMA, TRADER_LLAMA, MUSHROOM_COW, MULE, OCELOT, PARROT, PIG, POLAR_BEAR, RABBIT, SHEEP, SNOWMAN, SQUID, GLOW_SQUID, STRIDER, ZOGLIN -> {
return true;
}
}
return false;
}
this is what I currently have
Definitely exclusive in 1.13+ or whenever they redid it to be fancy
Can’t recall older versions
Why do people use those new switches everywhere now
because Intellij doesnt shut up
I'm trying buy how
great idea but it would require couple more if statements, since there's complexentitytype like enderdragon and some couple exceptions like striders
wait nvm strider is not a monster
ok
but still i need to check enderdragon
nvm, that was a bug in my code, apparently all the mobs im trying to leash, even cows can't be leashed for some reason
only exclusive to the commands registered in bukkit's command map
can someone help changing sword damage without using NMS?
ye I saw, you could make fake players, that's to much of a hassle tho
It utilises brigadier (although poorly) internally to provide suggestions to the client, so there's no way to suggest autocompletions without tinkering with the command api
use attributes
sadly, I hoped there would be an easier fix, due to minecraft also having autocomplete in normal chatbox, but ye, sadly nothing to be done
check a event
i am trying but it dont work properly
i'd like to use attributes
uhh
but when i use them on sword it removes sword attack speed and dont change attack damage properly
i am trying to add 5 damage to iron sword
ItemMeta meta = item.getItemMeta();
assert meta != null;
UUID uuid = UUID.randomUUID();
String name = "test";
meta.addAttributeModifier(attribute, new AttributeModifier(uuid, name, 5, operation));
item.setItemMeta(meta);
public class EntityInteractListener implements Listener {
@EventHandler
public void onEntityInteract(PlayerInteractAtEntityEvent event) {
if (event.getHand() != EquipmentSlot.HAND || event.getPlayer().getInventory().getItemInMainHand().getType() != Material.STICK || !(event.getRightClicked() instanceof LivingEntity)) return;
((LivingEntity) event.getRightClicked()).setLeashHolder(event.getPlayer());
}
}
such a simple method, but it doesnt leash the mobs whenever i hold the stick
even cows
it just drops the lead on the ground
how to fix this and make it look like in vanilla minecraft
attribute should be Attribute.GENERIC_DAMAGE
this is only in new version? i mean will it work on older minecraft versions?
Iirc attributes are not new stuff so it should be 1.8 compatible for sure
they were probably added in 1.6 or 1.7
iirc
and also there isn't Attribute.GENERIC_DAMAGE
i added EquipmentSlot.Hand but it still removes attack speed and makes text blue instead of green in 1.17.1
declaration: package: org.bukkit.attribute, enum: Attribute
anyone?
it just refuses to be leashed
leash drops on the ground
Please I need help I tried what I could but it still doesn't work...
is it true that all database operations should be executed async, no matter how big they are?
yes
oki
anyone? why doesn't this work?
what isn't working? you don't need to save after a reload
Hi, do you know any API for Integration tests in spigot?
How could i do to change things like this by the config?
#.#
are decimals
so, how can i do to the people change as they want?
to add less or more decimals
#.###
or
you mean new DecimalFormat(config.getStreing(formatString))?
It's just not reloading
No errors tho
Hello everyone, is there a tool with which I can convert a plugin, i.e. a .jar file, back into a project?
Yes
it can't "not reload"
It's "not working"
it is, you are just doing somethign wrong
Yes, I have a decompiler but with it I can only look at the source code and not edit anything.
probably reading it wrong
Wdym
as I said before, you are copying the values from the config to Fields. If you do not update them when you reload your config they will not change.
But with the tool I can only view source code or not?
Do you have source code link?
How do I update them?
the same way you set them in the first place
that reloads teh config
ofcourse, that's not how it works
hmm, i mean to change that in the config
changing a value in config?
you have fields in yoru Listener/command class?
Yes, that's exactly why I'm looking for a tool that converts the .jar file back into a project.
Yes
But how do I reload those?
where you are copying values from your config
as I just said, you set them the same as you did the first time
How do I update them?
or you stop messing about with the fields and read from the config.
How do I do that?
I feel like I'm being trolled here.
No?
I think you are. You stopped using the constructor and passing yoru main class and changed to a Field with a getter
you actually went to worse from decent
yes
public class ReloadConfigCommand implements CommandExecutor {
AmazinUtilities plugin;
public ReloadConfigCommand(AmazinUtilities plugin) {
this.plugin = plugin;
}
@Override
public boolean onCommand(CommandSender sender, Command command, String label, String[] args) {
String noPerms = plugin.getConfig().getString("noPerms");
String successfullyReloadedConfig = plugin.getConfig().getString("successfullyReloadedConfig");
if(sender.hasPermission("amazinutilities.reload")) {
Player player = (Player) sender;
plugin.reloadConfig();
player.sendMessage(ChatColor.GREEN + successfullyReloadedConfig); // where ?
} else {
sender.sendMessage(ChatColor.RED + noPerms + "(amazinutilities.reload)");
}
return true;
}
}
``` I am using the constructor when i reload. I don't understand what you're saying.
look at that code, you are reading the successfullyReloadedConfig string before you even reload
there are no buts, you are reading from teh config and then reloading. You are using data from the old config
public class RulesCommand implements CommandExecutor {
public JavaPlugin plugin = AmazinUtilities.getPlugin(AmazinUtilities.class);
public FileConfiguration config = plugin.getConfig();
String rules = config.getString("rules");
String noPerms = config.getString("noPerms");
@Override
public boolean onCommand(CommandSender sender, Command command, String label, String[] args) {
if (sender.hasPermission("amazinutilities.rules")) {
sender.sendMessage(ChatColor.translateAlternateColorCodes('&', rules));
} else {
sender.sendMessage(ChatColor.RED + noPerms + "(amazinutilities.rules)");
}
return true;
}
}``` ?
you've not shown code from rules, you were askign about yoru reload
Bruh
ok, you create two String Fields
why?
just read from the config
plugin.getConfig()
public class RulesCommand implements CommandExecutor {
public JavaPlugin plugin = AmazinUtilities.getPlugin(AmazinUtilities.class);
@Override
public boolean onCommand(CommandSender sender, Command command, String label, String[] args) {
if (sender.hasPermission("amazinutilities.rules")) {
sender.sendMessage(ChatColor.translateAlternateColorCodes('&', plugin.getConfig().getString("rules")));
} else {
sender.sendMessage(ChatColor.RED + plugin.getConfig().getString("noPerms") + "(amazinutilities.rules)");
}
return true;
}
}``` Like this?
yes
@eternal oxide Please
is there a way to add overall regen, heart, or damage to player with any weapon?
? be more specific
Hello! someone joined into my server and executed a command that crashed my server. (/mv ^(.........................*.++)$^). Are there any more commands that can do this?
all of them are updated
i am blocking them with nocheatplus and thats why i want to know the commands
no, i told that i have to install the compatible version for my server
my server version is 1.8
so i installed multiverse 2.5-b699 (beta)
you could ask the author to fix it in 1.8 as well but not sure he will bother
i blocked that command from nocheatplus
i was just asking if it is a list of commands that have to be blocked😅
thats the only one known so far
oh ok, thank you!
how to change natural regen, damage of everything of specific player, and heart count?
be more specific
like make player damage more no matter what weapon
listen to damage event check if its your player,add more to it
and what about adding hearts?
im bad at that stuff
Hey I have a little question, I'm coding on 1.16 and I noticed that the setDisplayName() method in ItemMeta is deprecated, I just wanna know what is the new method for setting a display name
anyone know what method is triggered when you mine a block
You mean event?
Ah
im making mining system
PacketPlayOutBlockBreak?
and the as() break when combine with Mining fatigue
Can anyone help me make a bungeecord server? I have a lot of servers already and want to make them into gamemodes..
im bad at that stuff
I see no deprecation
that other part
But I see a deprecation..
I already saw that a minute ago, it never says deprecated but for me it's deprecated
And also the way to create a GUI for me is deprecated
If teh javadocs don;t say deprecated its not
Might be a bug?
Would you be using "not" Spigot?
well yes
Ah wait
I just knew why
It's because I'm using paper
move to #help-server
Paper is actually smoother but not sure if spigot has more methods, I noticed that paper has more stuff
That's why I use it, and I use spigot when I wanna use NMS & Packets
some spigot method is deprecated in paper
Alright
im still developing in 1.8
lol
public static void spawn(org.bukkit.Location l) {
FunctioningAPI a = api.registerInstance(getPlugin());
SEntityWild sent = new SEntityWild(EntityType.PLAYER,
10000000,
10000,
SkySimStandardAI.class,
getPlugin(),
true
));
a.registerEntity(sent);
SEntityEquipments seq = sent.getEquipment().getHandle();
((SkySimNPCMob) sent).setSkinFrom(Source.PLAYER_NAME, "AMOGUS");
FullArmorSet fqs = a.buildArmorSetFromHexColor(0x0000, EnumArmorType.LEATHER_ARMOR);
fqs.setGlowing(0,1,1,1);
fqs.setUnbreakable(1,1,1,1);
fqs.setDefense(100,100,100,100);
seq.t().register(fqs);
sent.setTarget(api.chooseRandomInRange(l,16,16,16, EntityType.PLAYER));
sent.spawnAt(l.toSkySimLocation().s());
}
then i need some of my own method like this
Prob he use paper…
Bukkit.dispatchCommand(Bukkit.getServer().getConsoleSender(), kCommands);```
how do i send list of commands from config.yml?
Huh?
kCommands.forEach(cmd -> Bukkit.dispatchCommand(Bukkit.getConsoleSender(), cmd));
Hello, how can i manage "entity" to save in database like symfony or laravel in web development but in java. I would like to build something easy for my plugin and I have some data to save in database. Do you have any tips ? Thanks
How could i do to change things like this by the config?
#.#
are decimals
so, how can i do to the people change as they want?
to add less or more decimals
#.###
or
do i need to close something in a database when calling connection.prepareStatement(string)?
is there a way to display text above hotbar WITHOUT using NMS or APIs?
hey i have a quick question i am creating a class extending entityarmorstand, and i wish the mob (armorstand) i create had a natural movement like other mobs (pig or cow), how can i do that?
player.spigot().sendMessage(ChatMessageType.ACTION_BAR, <BaseComponent to send>)
this is compatible with all MC versions right?
What version are you using
I don't know what version that was added in, but I don't think it's a 1.8.9 feature, if you're looking to support that. If you're supporting 1.8.9, there's no Spigot API for sending an Action Bar as far as I'm aware, so you need to resort to one of the options you said earlier.
i want to make plugin that'll work on all version from 1.8 to 1.17.1 but currently i am testing on 1.17.1
Well Reflection it is then. You need to send packets if they're on versions that don't have the API
WorldCreator wc = new WorldCreator("AsteroidWorld");
wc.environment(World.Environment.NORMAL);
wc.type(WorldType.FLAT);
wc.generatorSettings("2;0;1");
wc.createWorld();
Hello, i have this code that "makes" a void world
but that makes that the plugin throws an error to the console
do i have to specify something else?
It doesn't like your generator settings
what?
so, is there other way?
You just need to correct the String, I'm sure there's some tutorial out there for 1.8.9 for valid JSON. I don't know what it should be off the top of my head.
so i should see outdated guides?
because i haven't found nothing about 1.16
If you're going to use outdated software, yes
There's an example for 1.16 generator settings in the docs
Hello guys what do you use for database storing ? anylibrary or something else ? I would like to easily use h2 or mysql, sqlite
sqlite mostly
unless you plan cross-server data..
How can i make entity ArmorStand with natural mob movement?
I am trying to create a system that tracks certain blocks placed by players using metadata. The way I want to do it is by storing the blocks chunk as a key then location as a value in a hash map that way I dont need to load all the blocks on startup but rather on chunk loads so there isnt too much for the server to do. The problem I am running into is when im using the hash map wouldn't a new block in the chunk just replace the last since they would both have the key of the chunk? Is there a better way for me to setup this system? I was going to store them in a yaml file under each chunk on server shutdown
oh cool ill look into that thanks
uh so like uh do essentials have an api
for their chat
or no
i tried looking everywhere
but i can’t find it
make a mob that is invisible and has collision off and other things that dont matter, and put armorstand in it
So im creating a private map for keeping track of blocks that were placed by players and im trying to use a multimap but I cant initialize the map like this. Am I doing something wrong or is this not possible. From what ive been seeing its better off for me to create a normal hashmap and just use an arraylist as my value but I figured I would ask incase there is a way to do it like this
https://pastebin.com/b2Nae5wB
'ListMultimap' is abstract; cannot be instantiated
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.
Well, thats it
Hello why i don't have description of methods on IDEA ?
In this doc i see "Returns the folder that the plugin data's files are located in.". There is a way to get them ?
Edit : solved by right clicking project > Download source & docs
private final Multimap<Class<? extends Event>, EventWrapper<? extends Event>> handlerMap = ArrayListMultimap.create();
There should be an implementation of Listmultimap
Anyone know how i get a users rank on essentials
/ their message prefix
on essentials chat
The rank can be obtained from vault
but how?
there isn't anything about ranks here: https://github.com/MilkBowl/VaultAPI/blob/master/src/main/java/net/milkbowl/vault/permission/Permission.java
It's in chat
Try getPlayerGroups
how can i get inventory from an entity(which im sure it is player)
Player#getInventory
wdym by:
which im sure it is player
Its either a player or its not
You probably need an instanceof check
i did this so thats why im sure
if (entity instanceof Player) {
Player player = (Player) entity;
}
Newer Java versions:
if (entity instanceof Player player) {
}
it is an entity not a player
so cast it
oh right thanks
how da heck do i uncompress doubles
cause look at this, the ones above uses ints, the ones below use floats, cause it works like that
What's the issue?
it should take away billions, not singles
/eco take Power_Button 1.0E9
this is what console executes
thanks <3
What is wrong with these,
import org.bukkit.craftbukkit.v1_17_1_R0.entity.CraftPlayer;
import net.minecraft.server.v1_17_1_R0.ChatComponentText;
import net.minecraft.server.v1_17_1_R0.PacketPlayOutPlayerListHeaderFooter;```
I think I did the 1.17.1 part wrong not sure how to fix it just errors
import net.minecraft.network.chat.ChatComponentText;
NMS was repackaged
Your IDE should handle imports for you
Fixed it thank you
Why does this line,
PacketPlayOutPlayerListHeaderFooter packet = new PacketPlayOutPlayerListHeaderFooter(); give me the error, cannot resolve constructor PacketPlayOutPlayerListHeaderFooter();
Why are you using a packet for that
I am new to Java Development I was following a tutorial
Thank you
if (Bukkit.getOnlinePlayers().size() != 0) {
for (Player player : Bukkit.getOnlinePlayers())
((CraftPlayer)player).getHandle().playerConnection.sendPacket(packet);
}```
How would I change this so it doesn't send a packet?
Remove the sendPacket line?
So I remove the sendPacket line and replace it with just the setPlayerListFooter?
You can just use player.setPlayerListFooter
And setPlayerListHeader if you want that too
I already managed to do that
So I get rid of the getHandle and playerConnection and just do ((CraftPlayer)player).setPlayerListFooter
Get rid of the cast to CraftPlayer too
if (Bukkit.getOnlinePlayers().size() != 0) {
for (Player player : Bukkit.getOnlinePlayers())
player.setPlayerListFooter();
}
It now says 'setPlayerListFooter(java.lang.String)' in 'org.bukkit.entity.Player' cannot be applied to '()'
Here are some links to get you started on learning Java:
- https://www.codecademy.com/learn/learn-java
- https://www.sololearn.com/learning/1068
- https://www.learnjavaonline.org/
- https://programmingbydoing.com/
- https://docs.oracle.com/javase/tutorial/java/index.html
The last one is the only official one, however some of those concepts assume that you already know a bit about programming.
Does it being animated change anything? I am making an animated tab list is that why the plugin tutorial used packets?
Ok so I can make it animated without the packets
Thank you very much for these btw ❤️
I think you're the first person ever here who is thankful for those links instead of getting offended lol. Props for that!
It surprised me too
I know other languages and I want to learn java as well I don't just want to jump into it
yeah that totally makes sense
java is pretty straightforward when you used other OOP languages already 🙂
I'll manage! :)
great! let us know when you got any questions 🙂
Will do! It would probably be more mc related rather than simple java 😂
Thanks for the help anyways
Boo
hello! i have a question regarding apis:
i want to make a plugin with the minecraft heads api like the heads database plugin, but i do not know how
for example, i do not know how to even use the api in a plugin, like read from it or split by head. i also don't know how to make it work with pages, like to count how much heads there are and then make enough pages accordingly
Steal hdb
no
maybe ask what exactly is your question
@EventHandler
public void onWitherSound(EntityExplodeEvent e) {
if (e.getEntityType() == EntityType.WITHER) {
int soundRange = plugin.getConfig().getInt("spawnSoundRange");
for (Player player : plugin.getServer().getOnlinePlayers()) {
if (e.getLocation().getWorld().equals(player.getWorld())) {
if (e.getEntity().getLocation().distance(player.getLocation()) <= soundRange) {
player.playSound(player.getLocation(), Sound.WITHER_SPAWN, 1F, 1F);
} else if (e.getEntity().getLocation().distance(player.getLocation()) >= soundRange) {
return;
}
}
}
}
}```
This is my code. Does any1 knows how to cancel ONLY the wither spawn sound in m else if body?
i have a few
Player#stopSound ?
declaration: package: org.bukkit.entity, interface: Player
ask them one by one please, it's easier to answer then^^
erm ofc you can
how do i use the api from a plugin? as in how do i read from it?
how do i then split it to individual heads? like to get each head instead of just a massive text wall
how do i make it so it works with pages? there aren't enough slots in a gui to fit that amount of heads
lets open a thread for this
ok
there is no stopSound
I smell outdated
its spigot 1.8 btw
oh sorry I can't help with 1.8, it's like 7 years old
do you have the docs link to it?
Question: What is the enchant PROTECTION_ENVIRONMENTAL compared to PROTECTION_FALL and others
https://spigotjpwiki.github.io/org/bukkit/enchantments/Enchantment.html#PROTECTION_ENVIRONMENTAL
yea like how to add it to my maven dependency?
What about DAMAGE_UNDEAD and DAMAGE_ALL
how do you change the firerate of vanilla mobs like skeleton
Smite and Sharpness
Do you know if there is a list of these converted to the in-game names?
Thank you btw
Don't know, but they are generally pretty obvious
Modify the pathfinder goals
wdym
its not pathfinding its shooting rlly fasyt
like thats what i want it to do
like ik i could get target but idk what after
or is there just like an nbt for fire rate
Actually that isn't a goal
lol
does the server need the ProtocolLib plugin in order to work?
Yes
okay
Shooting is controlled by EntitySkeletonAbstract#a
Isnt it pathfinder goal? Pretty sure it is?
Not in 1.17
[21:37:37 WARN]: org.sqlite.SQLiteException: [SQLITE_ERROR] SQL error or missing database (unrecognized token: "915631c8")```
```java
CompletableFuture.supplyAsync(() -> {
try {
Statement statement = conn.createStatement();
statement.setQueryTimeout(30);
statement.executeUpdate(
String.format("INSERT INTO players (id, uuid) VALUES (%s, %s)", id, uuid));
statement.close();
} catch (SQLException e) {
e.printStackTrace();
}
return String.format("Player with id %s and uuid %s added to database!");
}).thenAccept(result -> {
logger.info(result);
return;
});```
can anyone help me with an api in my thread? (it's a discord thread, not a forum thread)
Granted I am not sure where EntitySkeletonAbstract#a is called from
its like entity.wither.spawn or smth in the normal playsound command
I assume it is either Entity Sound Effect Sound Effect or Named Sound Effect
So how to use it? I never worked with this api before
I only need the PacketTypee.Play.Server part
Believe that cancels boss sounds
still waiting for help...
public OnPacketSending(Plugin plugin)
which import is "Plugin"?
ty
https://cdn.tooty.xyz/HxUI you can use the javadocs btw
Or just look at the imports in the git file
in the git file there is no import for Plugin
Final import
bump
i insert the uuid and it doesnt like it
How to register the onPacketSending in my Main Class?
Follow the tutorial
okay so Id 1023 is Wither spawning. Should it work now?
protocolManager.addPacketListener(new PacketAdapter(this, ListenerPriority.HIGHEST, PacketType.Play.Server.WORLD_EVENT) {
@Override
public void onPacketSending(PacketEvent event) {
PacketContainer packet = event.getPacket();
Player player = event.getPlayer();
int effectId = packet.getIntegers().read(0);
int range = plugin.getConfig().getInt("spawnSoundRange");
Location location = packet.getBlockPositionModifier().read(0).toLocation(player.getWorld());
if (effectId == 1023) {
if (player.getLocation().distance(location) >= range) {
event.setCancelled(true);
}
}
}
});```
I dont have ProtocolLib installed on my server so I cant test it atm
Only one way to find out
if you cant test it, wait until you can
as it wont work if you dont have the plugin on
package de.leleedits.antiwithersound;
import com.comphenix.protocol.PacketType;
import com.comphenix.protocol.ProtocolLibrary;
import com.comphenix.protocol.ProtocolManager;
import com.comphenix.protocol.events.ListenerPriority;
import com.comphenix.protocol.events.PacketAdapter;
import com.comphenix.protocol.events.PacketContainer;
import com.comphenix.protocol.events.PacketEvent;
import org.bukkit.Location;
import org.bukkit.entity.Player;
import org.bukkit.plugin.java.JavaPlugin;
public class Main extends JavaPlugin {
public static Main plugin;
private ProtocolManager protocolManager;
public void onEnable() {
plugin = this;
protocolManager = ProtocolLibrary.getProtocolManager();
protocolManager.addPacketListener(new PacketAdapter(this, ListenerPriority.HIGHEST, PacketType.Play.Server.WORLD_EVENT) {
@Override
public void onPacketSending(PacketEvent event) {
PacketContainer packet = event.getPacket();
Player player = event.getPlayer();
int effectId = packet.getIntegers().read(0);
int range = plugin.getConfig().getInt("spawnSoundRange");
Location location = packet.getBlockPositionModifier().read(0).toLocation(player.getWorld());
if (effectId == 1023) {
if (player.getLocation().distance(location) >= range) {
event.setCancelled(true);
}
}
}
});
}
public static Main getPlugin() {
return plugin;
}
}
Why isnt the server using the plugin?
[21:37:37 WARN]: org.sqlite.SQLiteException: [SQLITE_ERROR] SQL error or missing database (unrecognized token: "915631c8")```
```java
CompletableFuture.supplyAsync(() -> {
try {
Statement statement = conn.createStatement();
statement.setQueryTimeout(30);
statement.executeUpdate(
String.format("INSERT INTO players (id, uuid) VALUES (%s, %s)", id, uuid));
statement.close();
} catch (SQLException e) {
e.printStackTrace();
}
return String.format("Player with id %s and uuid %s added to database!");
}).thenAccept(result -> {
logger.info(result);
return;
});```
where id and uuid are simply strings
ok
use Prepared statements for binding
Also google issues first before coming here 🙂
I have an issue
My Minecraft has Alzheimer
Here are the files that handle the datas :
https://github.com/Max094Reikeb/MaxiCity/tree/master/src/net/reikeb/maxicity/datas
Nothing else is written in config.yml
Probably a different id way back in 1.8, try printing all the sounds that come through
https://github.com/Max094Reikeb/MaxiCity/blob/e6b1d0b62eb6fc715fa7249acf746bde6f8d8e27/src/net/reikeb/maxicity/commands/BalanceCommand.java#L51-L56
You make a new playermanager every call
your playerDataMap isn't static so that definitely wont work
Your add balance also has no way to confirm if it was added
can someone help me in my discord thread please? thanks in advance
For the new PlayerManager call, everytime I do
PlayerManager.someMethod(); // "someMethod" is any method in PlayerManager class
It says Non-static method 'someMethod()' cannot be referenced from a static context
so do I have to make every method in PlayerManager static?
Just sysout the int?
Then spawn a wither and see what number comes through
why what?
why static