#help-development
1 messages · Page 1751 of 1
i think that's a package just with uppercase on the first letter, no?
yup
(btw this also makes API slightly weirder, as someone could extend/construct any of these, meaning you need to state that they're uninheritable and unconstructable)
(which then causes more redundancy)
public final class De {
private De() {}
public static final class HaiKobra {
private HaiKobra() {}
public static final class KnockFFA {
// ...
}
}
}
I get that something like De.HaiKobra.KnockFFA might seem alright to someone from like a C++ or C# background bc of namespaces
but
in Java it is really bad taste
oh okay I believe it's just a package name cuz of the stacktraces above
in which case
don't use capitals, don't repeat package names
you already say de.haikobra but then repeat it with De.HaiKobra a package name after
also I dunno what the tyko. at the beginning is for lol
anyway ye I don't know what your problem is, just wanted to comment on the poor codestyle
someone help me over here: https://www.spigotmc.org/threads/there-was-an-error-while-attempting-to-retrieve-versions.531743/
hello! i have been trying to remove a certain line of lore from an item int amount = Integer.parseInt(args[2]); ItemStack item = p.getInventory().getItemInMainHand(); ItemMeta meta = item.getItemMeta(); List<String> lore = meta.getLore(); String singleline = lore.get(amount); meta.getLore().remove(singleline); item.setItemMeta(meta); here is my code can anyone tell me how to get an int index of a lore line?
did you set the lore after
Don’t lists have an indexOf
getLore returns a copy, so you can’t just edit it without using setlore
get lore from meta
change lore by indexof list
set lore
i think thats the way
@young knoll hey can you help me https://www.spigotmc.org/threads/there-was-an-error-while-attempting-to-retrieve-versions.531743/
No idea, I’ve never used that plugin
would i set the lore to singleline or what would i set it to?
if you wanted to remove a line of lore, remove the element from the lore arraylist or list, then do meta.setlore(list)
i did that List<String> lore = meta.getLore(); String singleline = lore.get(amount); lore.remove(singleline); meta.setLore(lore); item.setItemMeta(meta); it didnt work
I believe you can just call remove with the index
like this lore.remove(amount);?
Mhm
it didnt work
oh wait i just tested the actual command but it didnt print the line System.out.println("test") so its the actual command
i got it to work
I need help with creating NPC. The only code snipptes only are with craftbukkit, but it seems to be no where available.
so uh is it actually possible to upload and download a file to sql using hikaricp
im trying to spawn a zombie with armor and a custom name, i get this error ```[18:49:35 ERROR]: null
org.bukkit.command.CommandException: Unhandled exception executing command 'spawnzombie' in plugin Tazpvp v${project.version}
at org.bukkit.command.PluginCommand.execute(PluginCommand.java:46) ~[server.jar:git-Spigot-21fe707-e1ebe52]
at org.bukkit.command.SimpleCommandMap.dispatch(SimpleCommandMap.java:141) ~[server.jar:git-Spigot-21fe707-e1ebe52]
at org.bukkit.craftbukkit.v1_8_R3.CraftServer.dispatchCommand(CraftServer.java:641) ~[server.jar:git-Spigot-21fe707-e1ebe52]
at net.minecraft.server.v1_8_R3.PlayerConnection.handleCommand(PlayerConnection.java:1162) [server.jar:git-Spigot-21fe707-e1ebe52]
at net.minecraft.server.v1_8_R3.PlayerConnection.a(PlayerConnection.java:997) [server.jar:git-Spigot-21fe707-e1ebe52]
at net.minecraft.server.v1_8_R3.PacketPlayInChat.a(PacketPlayInChat.java:45) [server.jar:git-Spigot-21fe707-e1ebe52]
at net.minecraft.server.v1_8_R3.PacketPlayInChat.a(PacketPlayInChat.java:1) [server.jar:git-Spigot-21fe707-e1ebe52]
at net.minecraft.server.v1_8_R3.PlayerConnectionUtils$1.run(SourceFile:13) [server.jar:git-Spigot-21fe707-e1ebe52]
at java.util.concurrent.Executors$RunnableAdapter.call(Executors.java:511) [?:1.8.0_292]
at java.util.concurrent.FutureTask.run(FutureTask.java:266) [?:1.8.0_292]
at net.minecraft.server.v1_8_R3.SystemUtils.a(SourceFile:44) [server.jar:git-Spigot-21fe707-e1ebe52]
at net.minecraft.server.v1_8_R3.MinecraftServer.B(MinecraftServer.java:715) [server.jar:git-Spigot-21fe707-e1ebe52]
at net.minecraft.server.v1_8_R3.DedicatedServer.B(DedicatedServer.java:374) [server.jar:git-Spigot-21fe707-e1ebe52]
at net.minecraft.server.v1_8_R3.MinecraftServer.A(MinecraftServer.java:654) [server.jar:git-Spigot-21fe707-e1ebe52]
at net.minecraft.server.v1_8_R3.MinecraftServer.run(MinecraftServer.java:557) [server.jar:git-Spigot-21fe707-e1ebe52]
at java.lang.Thread.run(Thread.java:748) [?:1.8.0_292]
Caused by: java.lang.ClassCastException: org.bukkit.craftbukkit.v1_8_R3.entity.CraftZombie cannot be cast to net.ntdi.tazpvp.listeners.function.Zombie
at net.ntdi.tazpvp.listeners.function.Zombie.spawnZombie(Zombie.java:44) ~[?:?]
at net.ntdi.tazpvp.commands.moderation.SpawnZombieCommand.onCommand(SpawnZombieCommand.java:13) ~[?:?]
at org.bukkit.command.PluginCommand.execute(PluginCommand.java:44) ~[server.jar:git-Spigot-21fe707-e1ebe52]
... 15 more``` this is my code ```java
public void spawnZombie(){
System.out.println("Spawn zombie method called");
Location loc = new Location(world, xzomb, yzomb, zzomb);
Zombie zom = (Zombie) world.spawnEntity(loc, EntityType.ZOMBIE);
LivingEntity livingEntity = (LivingEntity) zom;
((LivingEntity) zom).getEquipment().setHelmet(new ItemStack(Material.LEATHER_BOOTS));
((LivingEntity) zom).setCustomName(ChatColor.RED + "" + ChatColor.BOLD + "Ntdi's Henchmen");
((LivingEntity) zom).setCustomNameVisible(true);
System.out.println("Spawned 1 zombie");
}```
Could you paste this into a bin?
like hastebin?
Yeah
What line is Zombie 44?
Oh there it is
You probably messed up your imports
yeah
You have a Zombie.java class somewhere in your project
oh yeah
And you are importing that
i should prob rename
Instead of the bukkit Zombie class
Hence you get the class cast exception
Can't cast irrelevant object to another
net.ntdi.tazpvp.listeners.function.Zombie
Yup
itsname zombiespawncommand
hm
oh duh package listeners obv that wouldnt b a command
im dum
i would just rename ur Zombie.java class to like ZombieListener or something idk
doing rn
id still rename for sanity's sake
i have this in my onEnable()
for(Entity e : world.getEntities()) {
if (e instanceof Zombie){
e.remove();
System.out.println("Removed startup zombieLogic");
}
}``` and my whole server just stops running anything else
That's going to take a lot of time
can I use CraftBukkit on a spigot plugin? I have seen some plugin code using CraftBukkit, and wasnt sure what it was
also
Bukkit.getServer().getBannedPlayers() is returning [] yet I have multiple banned people on my server.
same with Bukkit.getBanList(BanList.Type.NAME).getBanEntries()
Do you have a ban plugin?
is calling functions outside of the java class in the onEnable function lead to server not working or smt?
What?
possibly
depends
im gonna try moving it all the main java class and see what happens
what are you trying to do
i call a function to spawn a zombie with a custom name and helmet
with a bukkit runnable delay of 200L
that was bad typing my plugin doesnt load anything
after taht
basically
Your plugin doesn't load anything?
yep
tragic
Can we see your code?
public void onEnable() {
// Plugin startup logic
System.out.println("Tazpvp Logic is now ONLINE");
World world = Bukkit.getWorld("grind");
for(Entity e : world.getEntities()) {
if (e instanceof Zombie){
e.remove();
System.out.println("Removed startup zombieLogic");
}
}
new ZombieLogic().initZombies(4, 200);
bukkitrunnables start counting down post startup
System.out.println("Spawn zombieLogic method called");
Location loc = new Location(world, xzomb, yzomb, zzomb);
Zombie zom = (Zombie) world.spawnEntity(loc, EntityType.ZOMBIE);
LivingEntity livingEntity = (LivingEntity) zom;
((LivingEntity) zom).getEquipment().setHelmet(new ItemStack(Material.LEATHER_BOOTS));
((LivingEntity) zom).setCustomName(ChatColor.RED + "" + ChatColor.BOLD + "Ntdi's Henchmen");
((LivingEntity) zom).setCustomNameVisible(true);
System.out.println("Spawned 1 zombieLogic");
}
public void initZombies(Integer amount, Integer delay){
new BukkitRunnable() {
@Override
public void run() {
for (int i = 0; i < amount; i++) {
spawnZombie();
}
}
}.runTaskLater(TazPvP.getInstance(), 200L);
}
ignore not using the delay in innit zombies
waht
The runnable timers don’t start until the server is fully up and running
ah, so should i like async or await or smt
what r u trying to do
;-;
async/await isnt a thing in java
async chat event
what about it
i mean we do have completablefutures but yeah
it has async in the name
and threads
yes, indeed it does
but what are you trying to do with it
either way im trying to spawn 4 zombies with custom anme and helmet 10s after the server starts
async is basically just the CompletableFuture return and calling join on it is similar to await
and what's the issue with the code above
any errors in console when the server starts?
those zombies probably wont be removed
since the world wont have any entites loaded as the server is starting
you never define the return value of getInstance in your main class... right?
wdym
what does getInstance return
null
return instance;
}```
ok not like that
yes bur you never assign instance
you never defined "instance" in your class
You define it
assigned*
But don’t assign it
fuck I get confused
no
only in the main class, at the top inside the onEnable function
instance = TazPvP.getInstance();
no
absolutely not
wdym not
because TazPvP.getInstance() is null
how do I fix that then...
you're basically assigning a null value to a null value
waiittt
think to yourself what TazPvP.getInstance() is supposed to return
instance = this;
😄
why does using .clone().add(0,0,0) actually reduce the process-price by around O(N-N/sig)?
you mean time complexity or smtng?
ye
its the same
no its not
yes it is
no
Shouldn’t cloning it make it take longer
but after .add
time complexity doesnt denote time tho lol
it seemed to get better again
show us your testing methodology
it just denotes the amount of extra operations correlating to n
exactly
so how is copying worse?
i didnt say it was worse..
yes it does take some performance
but it wont make time complexity worse nor change it at all
Hey guys my plugin wont load and the server told me that the plugin doesnt contains plugin.yml but i use jd-gui and i saw him
i never said that bruh
so what are you saying?
actually i might need better testing
I think you were meant to say the amount of time it takes to run?
Is it in the right place
right? or
no
what did you mean
but anyways this leads to my second question if u guys didnt mind
org.bukkit.plugin.InvalidDescriptionException: Invalid plugin.yml
at org.bukkit.plugin.java.JavaPluginLoader.getPluginDescription(JavaPluginLoader.java:154) ~[server.jar:git-Spigot-db6de12-18fbb24]
at org.bukkit.plugin.SimplePluginManager.loadPlugins(SimplePluginManager.java:133) [server.jar:git-Spigot-db6de12-18fbb24]
at org.bukkit.craftbukkit.v1_8_R3.CraftServer.loadPlugins(CraftServer.java:292) [server.jar:git-Spigot-db6de12-18fbb24]
at net.minecraft.server.v1_8_R3.DedicatedServer.init(DedicatedServer.java:198) [server.jar:git-Spigot-db6de12-18fbb24]
at net.minecraft.server.v1_8_R3.MinecraftServer.run(MinecraftServer.java:525) [server.jar:git-Spigot-db6de12-18fbb24]
at java.lang.Thread.run(Thread.java:748) [?:1.8.0_282]
Caused by: java.io.FileNotFoundException: Jar does not contain plugin.yml
... 6 more```
nevermind it lel
i think
Lowercase
Wrong reply, but close enough
still the correct answer haha
lowercase ?
Plugin.yml -> plugin.yml
Ho im stupid 😂 thnx u
For the PersistantDataType, is there a default setting for a boolean?
you can just use the byte type or smtng
So I should just use a byye?
ye
been trying to find a hacky-way to create something like this, provided center location, radius
blocks will be set by the function
L = the location the function would be provided
L
BLOCK AIR AIR AIR BLOCK
BLOCK AIR AIR AIR BLOCK
BLOCK AIR AIR AIR BLOCK
BLOCK BLOCK BLOCK BLOCK
this would be the case for all dimensions, this is just a 2D elaboration.
any ideas?
Byte*, ok thanks!
BLOCK AIR AIR AIR BLOCK
BLOCK AIR [AIR] AIR BLOCK
BLOCK AIR AIR AIR BLOCK
BLOCK BLOCK BLOCK BLOCK
So the marked air block would be what you want?
no no
basically
L = player location
i want to set those blocks under the player
ah
Looks like the want a trench under the player
Or maybe a box with no roof, not sure
Hey ! Can we close an inventory only after player adding an item in a chest ?
Sure? Just listen for the click event and call closeInventory
but im kinda braindead right now and i cant wait until tomorrow
thats possible
Actually close inventory might be one of the ones you are meant to delay a tick
Either way
Yeah but he close inventory before that the item is in the chest
Actually close inventory might be one of the ones you are meant to delay a tick
with .wait() function ?
look at scheduling a task
You can listen to the close event and forcibly reopen it
I have StaffPlusPlus enabled
They may manage bans themselves rather than using the vanilla sytem
I dont want to keep it
I was looking at something, should I try to delete it and re ban?
Worth a try
yep
that was the issue
but it returns a CraftOfflinePlayer class
I will have to see if I can convert it
I'm trying to order and group player attacks based on a saved integer within objects attached via their UUID. For example, multiple players might have the attack number 4 and i'm trying to add their UUIDs to something so, once their sorted by the saved integer, I can group their attacks together, starting with attack number 0. Does anyone have a clever way of doing this?
I tried developing a plugin but in the console, it tells me to use Version 60 of Java instead of 61, but i dont know how to switch it. I downloaded Java 16 but in IntelliJ it tells ne to use Java 17
I'm trying to use, and I copied their setup code, I have it as a dependency in the plugin.yml, obviously is is a plugin in my server, and it is still giving me this message: Disabled due to no Vault dependency found!
Are you using the latest spigot and vault?
Does vault say it was enabled in console on startup?
yes
Send your plugin.yml
name: customrecipies
version: 1.0
author: CJendantix
main: com.CJendantix.CustomRecipes.CustomRecipes
api-version: 1.17
depend: [Vault]```
What other plugins are installed? Anything to do with the economy other than vault?
could you provide the lines around that message?
?
you mean the setup code?
no
Nah, in the log
Vault isn't an economy plugin. Its just an API. Try installing EssentialsX
its not for economy lol, its 4 perms
How do i set the armor of a npc
the attribute or the visuals?
visual
no clue
What're you using for your NPC?
pls help me
my friend has been waiting for this plugin to be complete for a month now
Where can i find the list for all the import org.bukkits
if you need the import it will tell you automatically
EntityPlayer npc = new EntityPlayer(nmsServer, nmsWorld, gameProfile); @vast shale
it is better to only use the ones you need to get rid of clutter
u know a free vps for hosting mc?
I meant bukkit classes but dw i found them
no
Serious Spigot and BungeeCord programming/development help | Ask other questions here
ok
fine ill help
Search the world's information, including webpages, images, videos and more. Google has many special features to help you find exactly what you're looking for.
Follow this closely https://github.com/MilkBowl/VaultAPI
?services
If you wish to request or offer development/art/building/administration services, please do so at https://www.spigotmc.org/forums/services-recruitment-v2.54/
1.9 forge docs???
thanks, i did it with packets, only solution i got to work for me
Yeah google search first result of entityplayer interface. Didnt see that
Glad you got it work!
does this need to be here? ```java
public boolean onCommand(CommandSender sender, Command command, String commandLabel, String[] args) {
if(!(sender instanceof Player)) {
log.info("Only players are supported for this Example Plugin, but you should not do this!!!");
return true;
}
Player player = (Player) sender;
if(command.getLabel().equals("test-economy")) {
// Lets give the player 1.05 currency (note that SOME economic plugins require rounding!)
sender.sendMessage(String.format("You have %s", econ.format(econ.getBalance(player.getName()))));
EconomyResponse r = econ.depositPlayer(player, 1.05);
if(r.transactionSuccess()) {
sender.sendMessage(String.format("You were given %s and now have %s", econ.format(r.amount), econ.format(r.balance)));
} else {
sender.sendMessage(String.format("An error occured: %s", r.errorMessage));
}
return true;
} else if(command.getLabel().equals("test-permission")) {
// Lets test if user has the node "example.plugin.awesome" to determine if they are awesome or just suck
if(perms.has(player, "example.plugin.awesome")) {
sender.sendMessage("You are awesome!");
} else {
sender.sendMessage("You suck!");
}
return true;
} else {
return false;
}
}```
I wouldn't think so
@vast shale
No thats just stopping anything other than a player from running the commands
sorry I meant the entire command
Are you asking if you need that onCommand function for it to work?
yes
No you dont need that
k
Do you have a permissions plugin? Again vault is an API
im not even using the economy anyway
no
it is for my plugin
my plugin is the permissions plugin
using the vault api
Is your plugin being enabled before vault?
no
Send your main from your plugin
?paste
Have you tried downloading an economy plugin?
if (!setupEconomy() ) {
log.severe(String.format("[%s] - Disabled due to no Vault dependency found!", getDescription().getName()));
getServer().getPluginManager().disablePlugin(this);
return;
}
why tf would i need one, i am getting the feeling that you have no idea how the vault plugin works and you are just guessing
?
Just troubleshooting, you gotta try possible solutions
No need to insult someone who's trying to assist you
Ello
didn't mean to insult him, just getting kinda stressed
I am getting this error:
java.lang.ClassCastException: class java.lang.Byte cannot be cast to class java.lang.Float (java.lang.Byte and java.lang.Float are in module java.base of loader 'bootstrap')
Cause of this lines:
DataWatcher watcher = npc.getDataWatcher();
watcher.set(new DataWatcherObject<>(15, DataWatcherRegistry.a), (byte) 127);
PacketPlayOutEntityMetadata packet = new PacketPlayOutEntityMetadata(npc.getId(), watcher, true);
connection.sendPacket(packet);
Any clue why
You sure those are the lines?
Its a class cast exception because you tried to cast byte to float from what Im reading
for (int i = 0; i < LOC.size(); i++) {
int id = i+1;
LOC.get(i).getBlock().setType(Material.SKULL);
String name = Bukkit.getOfflinePlayer(UUID.fromString(rang.get(id))).getName();
Skull skull = (Skull) LOC.get(i).getBlock().getState();
skull.setSkullType(SkullType.PLAYER);
skull.setOwningPlayer(Bukkit.getOfflinePlayer(UUID.fromString(rang.get(id))).getPlayer());
skull.update();```
```java.lang.NullPointerException: player```
the error is in the skull.setOwningPlayer ... line
why you calling .getPlayer
yeah thanks it works
just use runTask instead of runTaskAsynchronously
and remove the sleep
^
put the delay as the parameter to runTask
you should never ever use Thread.sleep in spigot
there is a method called runTaskTimer which is probably what you're looking for :p
?scheduling this does cover what you need robustly
essentially yees
but the wiki covers it to
if you scroll down a bit c:
you got the delightful potential of evolving your programming skills then
send the code
move the countdown inside the BukkitRunnable such that its on the same indent level as the method run
yes
well
its ticks
Map*
a map ya
Is it a dictionary in python too? The more you know
well "dict" but yeah
Quick help needed
i can't get an inv to open a second one
@EventHandler
public void onClick(InventoryClickEvent event) {
Inventory inv = event.getInventory();
Player p = (Player) event.getWhoClicked();
ItemStack current = event.getCurrentItem();
if (current == null) return;
if(inv.getName().equalsIgnoreCase("§7Main kiwi menu")) {
event.setCancelled(true);
if (current.getItemMeta().getDisplayName().equalsIgnoreCase("§6Open §2wands §6menu")) {
p.closeInventory();
Inventory invWand = Bukkit.createInventory(null, 54, "§7Wand menu");
p.openInventory(invWand);
}
}
}
}```
there is no error but the second inv won't open
and you sure the nested if statement passes?
should I debug the whole thing ?
ok
so the first if doesn't pass
although if(inv.getName().equalsIgnoreCase("§7Main kiwi menu")) this has the exacty same name as my inv
Conclure ? I didn't understand what's this "plugin" variable
Inventory inv = Bukkit.createInventory(null, 54, "§7Main kiwi menu");
I saw, but as I absolutely do not make my plugin work in this way I do not see at all what it is xD
Owh. My bad, i say trash x)
no worries
I think current is always null so it doesn't return anything
i'm confused
Can i send the whole class ?
i really can't get to the error
Just reload the map from a save
Unload the world, delete it, copy in the fresh world file, load the world
Something like this
would spigot be angry if i constructed a CraftPlayer? something like
public class CustomPlayer extends CraftPlayer {
public CustomPlayer(Player p) {
super((CraftServer) Bukkit.getServer(), ((CraftPlayer) p).getHandle());
}
}
basically i need it to have a player with custom methods but i'm pretty sure spigot would not appreciate it
@ me if u reply
Just make a wrapper class that keeps track of the bukkit player as a field
why would you do this
store CustomPlayer instances in a list and associate to them data and utils methods
why though
You generally don't need to store the bukkit player
let's say each player has a level
you could just do what everyone else does and make a wrapper
As you will generally have a reference to it already, how else would you be getting the custom player data
so 1) your plugin doesn't conflict with everyone; and 2) doesn't break on every update
I did tell them to do that
yea and i switched to a wrapper class now
public class CustomPlayer {
private final Player p;
public CustomPlayer(Player p) {
this.p = p;
}
public Player getPlayer() {
return p;
}
}
``` if that's what you meant
i need a reference to the player in there so i can use it for stuff like saving to yaml with the player's uuid
guys what's the difference between remove() and removeItem()?
thx
@EventHandler
public void onClick(InventoryClickEvent event) {
Inventory inv = event.getClickedInventory();
Player p = (Player) event.getWhoClicked();
ItemStack current = event.getCurrentItem();
if (current == null) return;
p.sendMessage("debug 1");
if(inv.getTitle().equalsIgnoreCase("§7Main kiwi menu")) {
p.sendMessage("debug 2");
event.setCancelled(true);
if (current.getItemMeta().getDisplayName().equalsIgnoreCase("§6Open wands menu")) {
p.closeInventory();
p.sendMessage("debug 3");
Inventory invWand = Bukkit.createInventory(null, 54, "§7Wand menu");
p.openInventory(invWand);
}
}
}
}``` I still can't get this to work, istg i tried everything and none of the debugs are working
what's the last debug message?
wdym
p.sendMessage("debug 2");
p.sendMessage("debug 3");```
none of the debugs displays
event registered?
well i think so
should be
it's imported
i checked on spigot's docs
and this is the one
imported != registered
how do I know if it is registered ?
Did ya call registerEvents
sorry i'm a beginner kinda confused around here
then i did not ?
guess so
how do i do that ?
Bukkit.getServer().getPluginManager().registerEvents(new MyEvent(), plugin);
getServer().getPluginManager().registerEvents(new "Event Class Name"(), this);
plugin being the instance of your main class
so i shall put this in my onEnable() right ?
yeah
yep
and what do i replace plugin by again ?
.
write this if it is in your main class
yeah i did it
kk
ok so let me retry now
ok now i have the first debug only
but it works better
if (current == null) return;
if(inv.getTitle().equalsIgnoreCase("§7Main kiwi menu")) {```
seems to be stuck within these ifs
How can i check how many players are on? I want to do an if statement of if players >= x.... or something like that how can i do that?
loop all players in a avr
Bukkit.getOnlinePlayers().size()
how can i broadcast a message in the if statement?
Depends... You can probably use Bukkit.broadcastMessage("message")
Google is your friend 🙂
so i did plugin.getServer().broadcastMessage("Message");
and thats what i found when i looking into the broadcast stuff but i dont know what to define plugin as, becuase it says cannot find symbol when i run it
Plugin is a variable which refers to the plugin that you are creating
You can name it anything you want... but it refers the the instance of JavaPlugin
If you don't have access to the plugin variable then you can reference the broadcastMessage method directly from the Bukkit class using Bukkit.broadcastMessage()
so i made one named "wepwawet" so just wepwawet.getServer().broadcastMessage("Message")
When i do that it then gives the error on the getServer() and it does the same if i replace it with Bukkit like idk what to put
@stark stag?
I assume you are creating a Minecraft plugin for Java, yes?
If so, then the first thing you must do is create a Java class for your plugin which extends JavaPlugin
The variable which you are trying to access is the instance of the plugin you have created
You can obtain a reference to the plugin using the this keyword in any method on the plugin
Or, alternatively, you can avoid this issue by accessing the Bukkit API using static methods on the Bukkit class as previously explained
well whats the error when you build
I assume the red is just your ide not understanding rather than an actual error
post the actual build log
copy one of the examples
or maybe this but teach it to keep your main class https://github.com/yWorks/yGuard/blob/master/examples/application/pom.xml#L45
I've never used yguard on a plugin so don't really know the exact config
if you want a Proguard config I can help you with that intead
no
this example needs java 11+
<groupId>com.github.wvengen</groupId>
<artifactId>proguard-maven-plugin</artifactId>
<version>2.1.0</version>
<executions>
<execution>
<phase>package</phase>
<goals>
<goal>proguard</goal>
</goals>
</execution>
</executions>
<configuration>
<options>
<option>-allowaccessmodification</option>
<option>-repackageclasses com.example.plugin</option>
<option>-renamesourcefileattribute SourceFile</option>
<option>-keepattributes RuntimeVisibleAnnotations</option>
<option>-keepattributes SourceFile,LineNumberTable</option>
<option>-keepclassmembers class * { @org.bukkit.event.EventHandler *; }</option>
<option>-keepclassmembers class * { @net.md_5.bungee.event.EventHandler *; }</option>
<option>-keep class * extends org.bukkit.plugin.java.JavaPlugin</option>
<option>-keep class * extends net.md_5.bungee.api.plugin.Plugin</option>
</options>
<libs>
<lib>${java.home}/jmods</lib>
</libs>
</configuration>
<dependencies>
<dependency>
<groupId>net.sf.proguard</groupId>
<artifactId>proguard-base</artifactId>
<version>6.1.1</version>
<scope>runtime</scope>
</dependency>
</dependencies>
</plugin>```
don't forget to change the repackageclasses part
im confused about the this keyword. I have these two things whats wrong
public final class ForestblockTimer extends JavaPlugin {
public void onEnable() {
int players = getOnlinePlayers().size();
BukkitScheduler scheduler = getServer().getScheduler();
scheduler.scheduleSyncDelayedTask(this, new Runnable() {
@Override
public void run() {
if (players >= 4) {
wepwawet.getServer().broadcastMessage("wepwawet");
}
}
}, 20L);
}
}
and this in a folder called tasks
public class wepwawet extends BukkitRunnable {
wepwawet plugin;
wepwawet(wepwawet plugin) {
this.plugin = plugin;
}
public void run() {
System.out.println("Task has been run");
}
}
Replace wepwawet with this
this refers to the current instance of the class
I want to make a menu showing the currently banned players, and I want it to create as many menus as there are 51 banned players. I cant seem to figure out how to do it. StaffPlusPlus somehow did it.
Inside ForestblockTimer this will be an instance of ForestblockTimer
Inside wepwawet this will be an instance of wepwawet
Also, the BukkitRunnable class you created doesn't make sense. Replace wepwawet plugin; with ForestblockTimer plugin
ive done that
this.getServer().broadcastMessage("wepwawet");
it still errors getServer()
Your current issue is in the class named wepwawet which extends BukkitRunnable
this.getServer will only work in a class that extends JavaPlugin
However you can use Bukkit.getServer anywhere
@EventHandler
public void onInventoryClick(InventoryClickEvent event) {
Inventory inv = event.getInventory();
ItemStack clickedItem = event.getCurrentItem();
Player p = (Player) event.getWhoClicked();
if(inv.getTitle() == "§7Main kiwi menu") {
event.setCancelled(true);
if (clickedItem == null) return;
if (clickedItem.getItemMeta().getDisplayName().equalsIgnoreCase("§6Open wands menu")) {
p.closeInventory();
Inventory invWand = Bukkit.createInventory(null, 54, "§7Wand menu");
p.openInventory(invWand);
}
}
}```i've tried modifying my code in all the ways i could think of and i still can't get it to open that new inv
Ok but changing this to bukkit doesnt do anything, and im still in the class on the main file.
?paste
30.10 02:44:00 [Server] INFO Caused by: java.lang.NoSuchMethodError: org.bukkit.inventory.Inventory.getName()Ljava/lang/String;
getName was removed a while ago
i tried getTitle() too
Still no
oh
event.getView().getTitle()
may i ask why ?
ok but now it does puts a line through broadcast message like this broadcastMessage
Thanks you saved my night lmao
broadcastMessage is not deprecated in spigot, are you using the paper API
@sturdy storm that's what happens for me too because I am using Paper 1.17.1
@quaint mantle should work for java14+ I think, what issue you having?
try bumping to the latest versions
<groupId>com.github.wvengen</groupId>
<artifactId>proguard-maven-plugin</artifactId>
<version>2.5.1</version>
<executions>
<execution>
<phase>package</phase>
<goals>
<goal>proguard</goal>
</goals>
</execution>
</executions>
<configuration>
<options>
<option>-allowaccessmodification</option>
<option>-repackageclasses com.example.plugin</option>
<option>-renamesourcefileattribute SourceFile</option>
<option>-keepattributes RuntimeVisibleAnnotations</option>
<option>-keepattributes SourceFile,LineNumberTable</option>
<option>-keepclassmembers class * { @org.bukkit.event.EventHandler *; }</option>
<option>-keepclassmembers class * { @net.md_5.bungee.event.EventHandler *; }</option>
<option>-keep class * extends org.bukkit.plugin.java.JavaPlugin</option>
<option>-keep class * extends net.md_5.bungee.api.plugin.Plugin</option>
</options>
<libs>
<lib>${java.home}/jmods</lib>
</libs>
</configuration>
</plugin>```
see if that works, uses latest version of proguard
maybe I can just have like 100 guis, and just add items until the gui is full, then start filling the next.
haven't tested it myself
You can use Server.broadcast() but that takes a Component, not a String, so you would have to do Server.broadcast(Component.text("Message!", NamedTextColor.GREEN)) or something like that https://papermc.io/javadocs/paper/1.17/org/bukkit/Server.html#broadcast(net.kyori.adventure.text.Component)
'Serious **Spigot **and BungeeCord programming/development help'
He asked the question
I mean you can still use the deprecated one
why is getItemInHand() deprecated ?
read the javadocs
Because there are 2 hands
lmao
Which hand is hand
really ?
oh i thought you were joking
Getting direction of a block and then setting it (getAxis();)
Yes. But I thought the spigot, paper, and bukkit were basically the same
No
Bukkit and spigot are quite similar as they are both developed together these days
Paper is entirely different
@SuppressWarnings("deprecation")
public void onItemClick(PlayerInteractEvent event) {
Player p = (Player) event.getPlayer();
if(p.getItemInHand().getType() == Material.BLAZE_ROD){
if (event.getAction() == Action.RIGHT_CLICK_AIR) {
p.launchProjectile(Fireball.class);
}
}
}``` why isn't this working ?
I have no idea how to use onItemClickEvent so i tried this
Did ya register it
Bukkit.getServer().getPluginManager().registerEvents(new wandMechs(), this); this ?
i have this in my main class
Don't see the @EventHandler unless you didn't include it
Ah yep, I saw an annotation and just assumed it was eventhandler
i'm dumb
i may have forgot the event handler
but like
no worries
😅
any ideas on how I could modify the fireball explosion's force
Check the docs
maybe store the fireball entity uuid in a map
and on ProjectileHitEvent change what happens
make the fattest explosion
Or use the hand dandy setYield method
Should have a method for it
even better
Oh gosh that is weird
Yield means different things between explosive and explode event
Sad
although i used Fireball.class to launch it, and i can't directly modify it's yield
either i don't know how, or i can'(t
setYield
store the value of launchProjectile that will be your fireball entity
yeah that's what I thought
No you call it on the return value of launchProjectile
oh ok
Woo generics
``@EventHandler
public void onPlayerMove(PlayerMoveEvent e) {
Entity entity = Bukkit.getWorld("build").spawnEntity(new Location(Bukkit.getWorld("build"), 0 , 29 , -181 ),EntityType.STRAY);
entity.setGlowing(true);
entity.setCustomName("test");
entity.setCustomNameVisible(true);``
does anyone know how to make it so the entity only spawns once using an if statement?
Ok thank you.
Not sure if location.toVector uses int coords or double coords
double
If it uses doubles you can just make your own vector using new Vector
Assuming you only want it once per block
I do
Make your own vector using getBlockX/Y/Z then
Heya! I've not made a Bungee cord plugin before but essentially what I'm aiming to do is connect a Bukkit plugin across 3 servers on a network
So essentially we have a core plugin which we've decided to connect to a single remotely hosted MySQL database and want to edit it to where all of our players on all of our 3 survival servers can use the features together rather than it being individual per-server
The way I thought I might achieve this is using BungeeCord and triggering event calls(since this plugin relies on caching data because of its size)? But i'm not certain as it's very new to me. But essentially, would it be possible/feasible to make our Bukkit plugin call an event from the BungeeCord plugin which in turn the Bungee would handle the event. The other plugins would Listen for the custom event and then perform a certain action (aka like updating a cached list/etc)
If anyone has any better suggestions too of course, I'll take them; never have I been asked to take a plugin of this caliber and stretch it across a network lmao nor do i have bungee experience yet
You can use something like redis as a shared cache
And rabbitmq as a message broker for your event bus maybe
if a player is at like y = 100000, do the chunks below them still render?
(ping me pls)
They will load, but they won’t render
im trying to get whenever a pressure plate in certain cords are but my code is not working
@EventHandler
public void onCheckPoint(PlayerInteractEvent event){
if (event.getPlayer().getWorld().getName().equals("parkour")){
if (event.getAction().equals(Action.PHYSICAL)){
if (event.getClickedBlock().getType() == Material.STONE_PLATE){
System.out.println(event.getClickedBlock().getLocation() + " " + event.getClickedBlock().getType());
if (event.getPlayer().getLocation() == new Location(Bukkit.getWorld("parkour"), -3, 38, -62) && TazPvP.statsManager.getCheckpoints(event.getPlayer()) < 1){
TazPvP.statsManager.setCheckpoints(event.getPlayer(), 1);
event.getPlayer().sendMessage(ChatColor.GREEN + "Checkpoint set");
}```
What part does it make it to
it makes it to printint the location
but when checking the cords
[03:17:02 INFO]: Location{world=CraftWorld{name=parkour},x=-3.0,y=38.0,z=-62.0,pitch=0.0,yaw=0.0} STONE_PLATE
this is what console prints
Ah
That players location will probably never be equal to that location
Because they are almost never perfectly aligned with a block
i also tried getting the block
you can check distance
how do I do that?
declaration: package: org.bukkit, class: Location
if (event.getClickedBlock().getLocation().distanceSquared(event.getPlayer().getLocation()))
idk how to use this condition lmao
is the output is less than like 1
`if (new Location(Bukkit.getWorld("parkour"), -3, 38, -62).distanceSquared(event.getPlayer())){
}`
use variables aswell makes it cleaner
Location blockLoc = event.getClickedBlock().getLocation();
Location playerLoc = event.getPlayer().getLocation();
if(blockLoc.distanceSquared(playerLoc) < 1){
//do stuff
}```
something like that
im not copy and pasting
}```
you have the < 1 in the wrong place
use variables it will make your code 100x cleaner
not at all
makes your code far more readable
and you dont have lines that stretch 100 characters
They're not
can anyone help me and tell me the main things i need to know to understand how to make plugins and how the game works
because im confused about a lot of things and i've been trying to learn
Do you know java
I tried developing a plugin but in the console, it tells me to use Version 60 of Java instead of 61, but i dont know how to switch it. I downloaded Java 16 but in IntelliJ it tells ne to use Java 17
you have to actually set the compiler version
Yes I do
Hello, I'm new to spigot, and i need to save data, e.g. player money. What I need to use? JSON or something else? Thanks
Thanks
And how work with it? Is there a good manual?
Thanks
a custom event ig
you specify if a player has 5 you compare to the other players
and then you make the placement
i think
Which of these three would be the correct approach for declaring & initializing the world variable?
Initialize as static class variable.
public class TimeModifierTask implements Runnable {
static final World WORLD = Bukkit.getWorlds().get(0);
final int modifier;
public TimeModifierTask(int modifier) {
this.modifier = modifier;
}
public void run() {
WORLD.setTime(WORLD.getTime() + modifier)
}
}```
Initialize in constructor.
```java
public class TimeModifierTask implements Runnable {
final World world;
final int modifier;
public TimeModifierTask(int modifier) {
this.modifier = modifier;
this.world = Bukkit.getWorlds().get(0);
}
public void run() {
world.setTime(world.getTime() + modifier)
}
}```
Pass it to the task
```java
public class TimeModifierTask implements Runnable {
final World world;
final int modifier;
public TimeModifierTask(int modifier, World world) {
this.modifier = modifier;
this.world = world;
}
public void run() {
world.setTime(world.getTime() + modifier)
}
}```
Im trying to create my own server software (to learn netty and for fun) and im trying to get a response from the server for the server MOTD but not sure how. Im using netty and cant get it sending the JSON back to the client
this is my current code
https://github.com/JustDoom/crust/blob/main/src/main/java/packet/server/handshake/ResponsePacket.java
https://github.com/JustDoom/crust/blob/main/src/main/java/ServerHandler.java
probably not the best place to ask but really not sure where else
Hey, do anyone know why is this code always null?
} else if (args.length == 2) {
Player target = Bukkit.getPlayerExact(args[0]);
if (target != null) {
target.getName();
player.sendMessage(ChatColor.BLUE + "/mana remove {Player} {amount}");
} else {
player.sendMessage(ChatColor.AQUA + "[MineSpace]" + ChatColor.RED + " Specify a real player!");
}```
} else if (args.length == 2) {
Player target = Bukkit.getPlayerExact(args[0]);
if (args[0].equalsIgnoreCase(target.getName())) {
if (target != null) {
target.getName();
player.sendMessage(ChatColor.BLUE + "/mana remove {Player} {amount}");
} else {
player.sendMessage(ChatColor.AQUA + "[MineSpace]" + ChatColor.RED + " Specify a real player!");
}
}
the second one ^^
is there any pdc api in 1.8.8 ?
or anyway to save data in an itemstack without nms in 1.8.8
if i write my nick or a string, it sends an error
package lustrecrew.damagetag.utils;
import org.bukkit.entity.ArmorStand;
public class Task extends Thread {
ArmorStand place;
public Task(ArmorStand armorStand) {
this.place = armorStand;
}
public void run() {
try {
Thread.sleep(10L);
this.place.remove();
} catch (InterruptedException var2) {
var2.printStackTrace();
}
}
}```
```package lustrecrew.damagetag.events;
import lustrecrew.damagetag.armorstand.CreateArmorStand;
import org.bukkit.entity.Player;
import org.bukkit.event.EventHandler;
import org.bukkit.event.Listener;
import org.bukkit.event.entity.EntityDamageEvent;
public class DamageEvent implements Listener {
public DamageEvent() {
}
@EventHandler
public void onDamageEvent(EntityDamageEvent event) {
if (event.getEntity() instanceof Player) {
Player player = (Player)event.getEntity();
double i = event.getDamage();
i = (double)Math.round(i);
i /= 2.0D;
new CreateArmorStand(i, player);
}
}
}```
any idea why the armorstand doesnt get removed
1.17
yeah
well, i have it other way...
why don't you do a task so you remove the armorstand in x ticks
thats too much extra resource to use on the server as we are coding a mmorpg server lol
dont wanna have it constantly counting
no, a scheduling sorry
when you create it
you make a delay for 40ticks for example
and it deletes
When i create a packetreader to read PacketPlayInUseEntity my getValues for actions do not return ATTACK/INTERACT, but net.minecraft.network.protocol.game.PacketPlayInUseEntity$1@2362ee72. Only getValue of "a" (entityid) seems to work how it should
Hello everyone! How i can modify the drop of an hanging entity like itemframes? I mean the itemframe drop itself, not the item that contains.
Try getting the drops in the EntityDeathEvent and remove the ItemFrame from it.
I tried using that event cuz it has a list of drops, but it does not trigger from item frame removal
Because a String will never be equal to a boolean
amount >= 0.00D is a boolean expression so it will either be true or false.
args[2] is a String. So you are comparing a String with a boolean which will always not be equal.
so, how am i supposed to check the value?
What do you want to check?
I need more code to answer that...
hmm
So what i should do?
Lets see. EntityDeathEvent only gets called for LivingEntities. And ItemFrame is not one.
So we would have to look into workarounds. Maybe the EntityDropItemEvent or some ItemFrame property.
At least there is a way to prevent itemframe from dropping itself?
There are events for hanging entities
3 events
And no one of the three has something to change/remove the drop of the itemframe
Neither ItemFrame class has something about it
You can only change the item contained inside it, but it is not what i am looking for
You could cancel those events and then just .remove() the entity
Maybe something like this:
@EventHandler
public void onDeath(final HangingBreakEvent event) {
if (event.getEntity() instanceof ItemFrame frame) {
event.setCancelled(true);
final ItemStack item = frame.getItem();
if (!item.getType().isAir()) {
frame.getWorld().dropItemNaturally(frame.getLocation(), item);
}
frame.remove();
}
}
Yeah this works
hey, does anyone know how i can make gradient text, or just use custom colours?
Make the "score" Comparable, put it in an ordered collection like a List and call .sort() on it.
Or just use a TreeSet from the beginning.
Another thing, you used a feature of java 15 i think, and when i try to copile a plugin with java 15 and i run it, the console gives me the java.lang.UnsupportedClassVersionError
What spigot version are you on?
1.17.1
Then you should def use at least java 16 to compile your plugins
Mini-message is good for this
Otherwise you can use ChatColor.of
can u show me an example please?
what your buildfile config look like
Here is another example:
private final Map<UUID, Double> scoreMap = new LinkedHashMap<>();
public void setScore(final UUID userID, final double score) {
this.scoreMap.put(userID, score);
}
public double getScore(final UUID userID) {
return this.scoreMap.getOrDefault(userID, 0D);
}
public List<Entry<UUID, Double>> getTop(final int amount) {
return this.scoreMap.entrySet().stream()
.sorted((e1, e2) -> (int) (e1.getValue() - e2.getValue() + 0.5D))
.limit(amount)
.toList();
}
You can also write the getTop() method in a more old school way. But it will require some more lines.
ChatColor.of(“#rrggbb”)
ChatColor.of(“#rrggbb” + "exaple text")?
No
sorry, im quite new to java
The text goes outside the brackets
oh
How is named the file?
ChatColor.of((“#rrggbb”) + "example text")? or ChatColor.of(“#rrggbb”) + "example text"?
the latter
I'm using no builders
Using the integrated one of intellij
What does your Build, Execution, Deployment > Compiler > Java Compiler look like
Yes
I would look at File > Project Structure > Project > Project SDK
and File > Project Structure > Modules > Language Level
Make sure both of them are at least 16
If you use an old Java version then you need to do this, yes.
What spigot version are you on?
Make sure to change the bytecode version to 16
other than that I think you need to update your artifacts
I haven't touched artifacts in years, but that's probably it
It worked, thanks!
Sweet, np
Whats your spigot version?
Use the bungee ChatColor import
1.16.5
oh, it worked tysm!
aaa worked!!
tysm again ^^
Is the InventoryCloseEvent called, when a player had open their inventory and left the server?
No event fires if a user closes his own inventory
Oh. Can I do that with custom inventories too?
If the user has some other inventory open then the InventoryCloseEvent fires if he leaves.
I dont get what you mean by "Can I do that with custom inventories too". You want the event to NOT fire for other inventories too?
No. I want that the event is fired for ANY inventory
And when the event is fired on leave then everything is fine.
The InventoryCloseEvent is fired for every inventory that is not the players own PlayerInventory. This is also true for when a Player quits.
Nice. This is very, very nice. thanks
reverse the comparator. e2 - e1
https://www.spigotmc.org/resources/catconomy.97210/ can someone please abuse this plugin for me? just try and break it
As in write a plugin which breaks this?
either that or just..... abuse it ingame
since I need to test if the transaction handler hasn't got any weird behaviour
i'd be real helpful since I am not really good at it
how can I make it so basically someone invites someone to the discord server they get an item in-game
How can I set right arm of armor stand pose with packets? It takes Vector instead of EulerAngle.
I mean... the plugin doesn even work by itself...
last time I tested it it worked?
I think you forgot to shade in some db driver
You need to map invitation links to users using a Discord library. Then detect which link was used by a user when he joined.
The last part is the communication with the mc server. You can either start your bot with the plugin or have two separate applications
that talk to each other over REST or MQTT or sockets or Redis or anything else.
You also need to map a discord user to a mc user which is a different story. IP mapping would be an option or manual registration.
is there just a simple plugin?
yeah forgot to shade Mapdb's driver
You forgot to shade in the kotlin lib...
Sure. Just split the message at the whitespace chars
Hey, could anyone help me about config.yml? guides only explain about changing messages and don't know more about that :/
.......wait... that doesn't make sense
on my machine it runs fine
@lost matrix are you using stock java?
public String[] getArgs(String commandMessage) {
return commandMessage.split(" ");
}
or if you want to remove the /command
then
public String[] getArgs(String commandMessage) {
String[] allPieces = commandMessage.split(" ");
String[] args = new String[allPieces.length - 1];
System.arraycopy(allPieces, 1, args, 0, args.length);
return args;
}
I think so. Maybe Temurin but that should make no difference as a ton of ppl run adopt over oracle.
sorry if I sound like a bad developer
Ive seen worse. Way worse...
this scares me
also the plugin breaks with java 8 if you try it on java 16 it works
How can I rotate armor stand with packets?
the whole body, like ArmorStand#setRotation does.
Exactly what it says... name cannot be null.
args[0] is null.
Maybe set the value in it when you create it? lmao
Why are you even creating a new args array
Get the message from the event and split it.
Instead of String[] args = new String[1]
String args = event.getmessage().split(" ")
oh this is a listener 😓
e.getMessage() returns the whole string so if you split on it args[0] will be the command /<command> so adjust accordingly.
player.getInventory().addItem(new ItemStack(Material.YOUR_ITEM, Amount));
what's the difference between an direct initialisation and a static block?
Direct initialization?
A static block runs when the class loads
Which usually happens once during runtime
only once
class loads if the JVM starts
would need to restart the whole program to load it again
It can happen more times
Classes can unload and then you can technically load them again
and why would you use a static block if you can just do private static final int i = 123;
Yeah maybe
or if your class constructor needs a parameter
and you need to define that parameter before with some extras
I guess yeah assuming you’re building an immutable map or something along that
oki
for (String arg : args) {
builder.append(arg).append(" ");
}
String argsCombined = builder.toString();
Bukkit.broadcastMessage(ChatColor.translateAlternateColorCodes('&', argsCombined));``` how could i exclude the 1st argument from the broadcast? args[0]
Arrays.stream(args).toList().subList(1,args.length - 1) Something like this would work, granted it assumes args.length < 0 and is probably not the fastest due to the stream
You'd have to use for(int i = 1; i < args.length; i++)
Or Arrays.copyOfRange
i thought "I wonder if there is a better way than a for loop" and just completely abandoned the whole idea
just use the for loop imo
normally if cancel becomes true, the runnable should be cancelled right?
i have a
.runTaskTimerAsynchronously(plugin, 1L, 1L);
after it
And do you use the cancel variable there as well?
uhh what its just this
Hello! i'm trying to do a thing but i'm not getting it...
How can i do to access the boolean from other class?
Your if statement is also pretty useless
idk why you need that tho
why?
if(x = true) will always execute
i want to do a command to trigger the thing
you want a command to set the boolean to true?
or false
and i have a command class
but can't access the boolean from the other class
trying doing an instance
but no
make a getter
or a setter
probably
public void setCancelled() {
cancelled = !cancelled; // toggle it
}```
Hi, i get this error while trying to connect to my MySQL Server (localhost)
I double checked password and everything else
Establishing SSL connection without server's identity verification is not recommended. According to MySQL 5.5.45+, 5.6.26+ and 5.7.6+ requirements SSL connection must be established by default if explicit option isn't set. For compliance with existing applications not using SSL the verifyServerCertificate property is set to 'false'. You need either to explicitly disable SSL by setting useSSL=false, or set useSSL=true and provide truststore for server certificate verification.
My Code to connect to the Database:
con = DriverManager.getConnection("jdbc:mysql://" + host + ":" + port + "/" + database, user, password);
I have tried using useSSL=false but it still gives me the same error.
"?autoReconnect=true" +
"&verifyServerCertificate=false" +
"&useSSL=false";
con = DriverManager.getConnection(dbURL, user, password);```
How do i provide 'truststore for server certificate verification' and is there a way to not having to use one?
Or is there something wrong with my code that i just don't see?
i dont like this
i dunno
i dunno what he's trying to achieve
Is this the wrong place for this?
i just dont know
//Load Drivers
Class.forName("com.mysql.jdbc.Driver").newInstance();
Properties properties = new Properties();
properties.put("user", user);
properties.put("password", password);
properties.put("autoReconnect", "true");
properties.put("useSSL", "false");
properties.put("verifyServerCertificate", "false");
//Connect to database
String url = "jdbc:mysql://" + host + ":" + port + "/" + databaseName;
conn = DriverManager.getConnection(url, properties);
PropertiesBuilder :kekw:

wheres my nitro
got this from the best plugin ever, (eco sql bridge) and modified it
by best I mean very weird
eco as in auxilor?
ah
to toggle it
by a command
i have it false as default
probably mine then
Thanks but i still get an error :/
[16:42:26] [Server thread/WARN]: Caused by: com.mysql.jdbc.exceptions.jdbc4.MySQLNonTransientConnectionException: Public Key Retrieval is not allowed
the modified version is from
a setter constructor?
Public Key Retrieval is not allowed
what sql server are you connecting to?
i was thinking about having it in false by default and then check if it is false, then change to true if not, then change to false
but i can't access that method in the command class
a boolean field is false by default
smh my wifi was a minute down and i kept playing on the server
MySQL? 🤔
well it seems buddy o'l pal that it may not be.... configured correctly
Well yesterday it worked fine 😞
well what happened between yesterday and now? since nothing is wrong with your code
oh actually
properties.put("allowPublicKeyRetrieval","true");
add this
also warning:
AllowPublicKeyRetrieval=True could allow a malicious proxy to perform a MITM attack to get the plaintext password, so it is False by default and must be explicitly enabled.
@tardy delta
if (plugin.isCancelled()) {
//true
plugin.setCancelled(false);
} else {
//false
plugin.setCancelled(false);
}
this will work i guess?
the name of the method
ah didnt even see it
i did the generate code
just make a toggle method
It still doesn't work but i think im going to reinstall the whole thing then lucky for me it wasn't to much data
that should work i guess
sorry man
this is my first public plugin and um.... it works
maybe
hmm well it doesn't work xD
the console says that this.plugin is null
:/
could you help me?
are you sure it's excluded?
My plugin is supposed to let you cycle bed colors, but it doesn't work if the bed is facing south, which is really weird.
thats the only case where it fails?
yes
likely because of how blocks are ticked
try supressing block updates when updating the block data
How? Sorry I'm new to java & spigot lol
?jd
oh do you think it happens because there isn't a "pillow" part
loc.getBlock().setBlockData(newData, false);
did I do it right
yes
it still happens though
hm, let me see how I did it in my plugin
Only set the material. However your loc.getBlock().setBlockData(newData); call is superfluous, I believe it can be removed
The bed already have a direction i guess ?
what happens if you remove that too?
if I remove the setBlockData the new-placed bed will always face the default direction
which is north I think
but do you think it happens because the front part of the bed is missing?
no
possible, but I do not think so - it is certainly a legal - albeit cursed state
@EventHandler
public void compassclick(PlayerInteractEvent e) {
ItemStack compass = e.getItem();
if (compass != null) {
}
if (e.getPlayer().getItemInHand().getItemMeta().getDisplayName().contains(ChatColor.RED+""+ChatColor.BOLD+"Lobiye dön"));
compassgui(e.getPlayer());
}
can you fix this code? If I click on a space or a block it gives an error.
what is line 182
getItemMeta is null most likely
compass.hasItemMeta()
oh yeah
getDisplayName also might be null
Hard to tell when not using java 16
Or whichever one gives better NPE outputs
?di
Guide to dependency injection: https://www.spigotmc.org/wiki/using-dependency-injection/
Can this really throw a NullPointerException?
in which context?
player can equal to null