#help-development
1 messages · Page 1791 of 1
PlayerInteractEvent maybe?
nope, only gets triggered once
if ur leftclicking air, yea
ah u mean no to the question
alright
guess im gonna set the players head into a barrier
and cancel swimming + suffacation
the he continuously left clicks
Can someone help me how to parse Enum field into a Json using Gson?
doesn't gson do that for you automatically
how can i cancel the block break sound on Interact?
cancelling the interactevent doesnt cancel the sound
just makes the block re-appear
there is Player#stopSound, is there any way to use that for this case?
Not for enum, no
I've tried using @SerializedName annotations from Gson, and here's my ClanRank enum https://github.com/aglerr/clan/blob/master/src/main/java/co/vargoi/clan/enums/ClanRank.java and this is the ClanPlayer object that I'm trying to save https://github.com/aglerr/clan/blob/master/src/main/java/co/vargoi/clan/clan/objects/ClanPlayer.java
idk I am looking at the Gson javadocs
and it clearly states it provides enum support
Gson provides default serialization and deserialization for Enums, [...]
Okay, this is the result
Channel channel::clanplayer has sent a message: {"name":"aglerr","uuid":"null"}
```and that is from
```java
String jsonData = gson.toJson(clanPlayer);
jedis.hset(key, "details", jsonData);
jedis.publish(RedisHandler.CHANNEL_CLAN_PLAYER, jsonData);
It may be client side
There should be a stopAllSounds method in modern versions
gson.toJson(new ClanPlayer("aglerr", UUID.randomUUID().toString(), ClanRank.OWNER))
{
"name": "aglerr",
"uuid": "f51c981d-a5ba-4e4e-ad1e-868fc671c9cc",
"rank": "owner"
}
Works fine for me
Oh what
With @SerializedName annotations right?
Still doesn't work for me for some reason.
jsonData = {"name":"aglerr","uuid":"null"}
Oh, maybe the ClanRank is null so it won't parse to Json, that might be the problem.
Yeah, it's because the ClanRank is null
why does rightclicking a block double-trigger the PlayerInteractEvent
is that intended?
i have a question; what does the return statement in the onCommand @Override do
does it actually do something? or nah
No, it's just a helpful reminder
what does it do in that case, because i read somewhere that it determines whether the player receives the usage message from plugin.yml ?
so if i returned true for the entire thing i wouldnt get the usage message?
Yes
cool, thank u
@Override is only for you, and the compiler I guess
I can't figure this out
I'm trying to make a simple little thing where I send an item's display through a chat hover event
looked at the BungeeCord chat api
used some textComponents and a hoverEvent with SHOW_ITEM
the part I can't figure out is actually creating the Item object to show
Creating the base item works fine, hovering over the item's name shows the window for it, but any custom data like lore or enchantments is lost during the conversion from the bukkit ItemStack to the BungeeCord Item and instead it's just the base item's data
my current method is constructing the Item using an ItemTag from ItemTag.ofNbt(item.toString())
Am I understanding something about this wrong?
ah
how can i set each command to be its own Command_the command name class, automatically
i have all the classes setup,,, is this a thing of the future? should i set them all.. manually?
Is there an updated version of PacketWrapper for ProtocolLib?
I get a little confused when it comes to managing the packets myself
Can't really do it automatically
You can drastically simplify commands using libraries though
Class.forName() ?
Yes you could use reflection but that seems overkill
im just trying to move all this into a few lines, other than .setExecutor( each thing here )
Especially when you could just use a library that takes away a lot more pain points
please how, willing to go overkill if it means making the lines in my main class shrink
Line count isn't a bad thing lol
its just really annoying, because if i used reflection i would only have to worry about plugin.yml, and the command class
Okay you can use reflection
But I would really consider using a library
Anyways
You would first need to get a list of all commands defined by your plugin
You can get that from the PluginDescription
yup
Then you could iterate over them and do something like this
i have the everything setup, im just not quite sure how to Class.forName
found something that'll help me https://www.spigotmc.org/threads/registering-all-of-your-commands-automagically.200498/
String name;
Class<?> clazz = Class.forName("package.here.Command_" + name);
CommandExecutor executor = clazz.getDeclaredConstructor().newInstance();
getCommand(name).setExecutor(executor);```
bump
@quaint mantle but seriously, next time you should really just use a library, they will make your commands 10x easier to implement
If you want, I can show you how
if you want to you can, if it makes my life easier ;o
to not flood this channel though you can DM me if you are willing to show me
Ok
can someone please help me with this? i'm making a gamerules gui thing for easier access to gamerules, and i need a bunch of simillar methods to this one, but it will probably cause lag
You can have a thousand methods and you won’t really get any lag
Because you aren’t calling them
I mean are you calling them all at once
i only have one method as of right now but yeah i'm going to be doing that
Why
and i'm also going to be calling them again when i need to toggle a gamerule in the gui
the method sets the item in the gui red if the gamerule is false, and green if it's true
You could compress all this gamerule toggle stuff down to very few lines
so whenever you open the gui or toggle a gamerule, i'd have to call the method/s
Just loop over all game rules and add an item to the inventory based on the state
Can do that in like, 10 lines
each gamerule in the gui is supposed to have an explination of what it does though
How can i extend a class (which I can't edit) to add my own features?
I can't mnanage to cast the instance from superclass to new subclass
a hashmap?
Yes
ok
is it bad to call the same method like 15 times at once but with different parameters?
No
what are you trying to extend
you have shown no relevant code to comment on.
... I have xD
I'll assume UUIDObject is a Json?
yeap. Ill show whole method one sec
so the failing is mAPI.getUUIDFromUsername(name)
Yeah it returns null but outputs the correct UUID in the logger right before the return.
This works fine ```java
public static UUID getUUID(String name) throws IllegalStateException {
try {
URL url = new URL("https://api.mojang.com/users/profiles/minecraft/" + name);
HttpURLConnection conn = (HttpURLConnection) url.openConnection();
conn.setReadTimeout(5000);
conn.setInstanceFollowRedirects(true);
conn.addRequestProperty("User-Agent", "Mozilla/4.0");
conn.setDoOutput(false);
try (JsonReader reader = new JsonReader(new InputStreamReader(conn.getInputStream()))) {
reader.setLenient(true);
// read JSON data
JsonObject json = new Gson().fromJson(reader, JsonObject.class);
// close reader
reader.close();
return UUID.fromString(json.get("id").getAsString().replaceFirst(
"(\\p{XDigit}{8})(\\p{XDigit}{4})(\\p{XDigit}{4})(\\p{XDigit}{4})(\\p{XDigit}+)", "$1-$2-$3-$4-$5"
));
} catch (IOException e) {
throw new IllegalStateException("ERROR_CHECKING");
}
} catch (Exception e) {
/*
* Fail quietly.
* No need to spam a stack trace.
*/
return null;
}
}```
The method worked fine a bit ago. And like I said the method isn't even the issue really.
It outputs the correct UUID but doesn't return it...
its a Json Object, you shoudl use getAsString() not toString()
I'll try that But I don't think you're reading my issue right.
but that code you just posted, its impossible for it to correctly print the uuid and not return it in teh very next line
Exactly
Thats why I'm confused xD
I will. but still... why would it output if I needed that?
public String getUUIDFromUsername(String name) { return Bukkit.getOfflinePlayer(name).getUniqueId()); }
?
Does that work now?
when did it not work
1.8 - 1.12
🤷
Oh I remember. I used my method because I thought Bukkit.getOfflinePlayer only showed users that joined the server.
I found my issue... somewhere, somehow name is changing to the uuid.
I still have no clue how though xD
my guess you are somehow calling it using a UUID/string instead of a name
Yeah I'm gonna have to rewrite a few of my methods.
I honestly have no clue how this is ocurring.
How do I check whether a recipe is matching with a custom recipe?
I've tried:
e.getInventory().getRecipe().equals(customrecipe)
and this disgusting loop that checks if the items match an array...
List<ItemStack> inv = Arrays.asList(e.getInventory().getMatrix());
//Check if the recipe is the heart recipe
List<Material> itemlist = Arrays.asList(Material.AIR, Material.ENCHANTED_GOLDEN_APPLE, Material.GHAST_TEAR, Material.GHAST_TEAR, Material.NETHER_STAR, Material.GHAST_TEAR, Material.GHAST_TEAR, Material.ENCHANTED_GOLDEN_APPLE, Material.AIR);
for(ItemStack recipeitem : inv){
Material recipeitemtype = Material.AIR;
if(recipeitem != null){
recipeitemtype = recipeitem.getType();
}
this.plugin.getLogger().info("Actual Material: " + recipeitemtype.toString());
this.plugin.getLogger().info("Recipe Material" + itemlist.get(inv.indexOf(recipeitem)).toString());
if(recipeitemtype.equals(itemlist.get(inv.indexOf(recipeitem)))){
this.plugin.getLogger().info("Found material that matched recipe!");
continue;
}
return;
}```
But.. nothing seems to work
Hello! I'm trying to make my own custom GUI class to help assort and manage my "screens/pages" of GUIs. I've worked with many languages, however java being my least skilled I do believe I may be at fault here because I could be following another language's syntax/execute flow.
I have the main code here that is expected to run from a command class. It pretty much instates the class, switches screen and display GUI with event handlers.
new ScreenManager(plugin).get("Dropbox", (Player) commandSender).display((Player) commandSender);
I now have the manager class being called here. This is the main driver of all the GUI work and I work all screens on this class.
public class ScreenManager implements Listener {
Inventory session;
Screen gui;
Plugin plugin;
Player player;
public ScreenManager(Plugin plugin) {
this.plugin = plugin;
}
public ScreenManager get(String screen, Player player) {
// Saves the Inventory stack to the class.
switch (screen) {
case "Dropbox" -> this.gui = new Screen_Dropbox(player);
case "DropboxAdmin" -> this.gui = new Screen_AdminDropbox(player);
}
return this;
}
public void display(Player player) {
// Displays the current stack GUI to the player.
if (player == null) this.player.openInventory(gui.getGUI());
else player.openInventory(gui.getGUI());
this.session = gui.getGUI();
// Bukkit.getLogger().severe(gui.toString());
}
@EventHandler
public void onInventoryClick(InventoryClickEvent e) {
if (e.getInventory().getHolder() instanceof Screen) {
Bukkit.getLogger().warning(String.valueOf(this.gui)); // This should effectively give me the GUI ID/Instance. But it's returning null.
this.gui.eventClick(e); // Point of error.
}
}
}
For some reason, the re-declarement of the this.session variable is not persisting or saving. I'm sure that looking through the script it should work as intended but visually and on hand, it doesn't work and seems to be "null".
I'd like someone's opinion and feedback in regards to this.
Error Stack (From a fresh clean server):
[17:47:05 WARN]: null
[17:47:05 ERROR]: Could not pass event InventoryClickEvent to Dropbox v1.0.0
java.lang.NullPointerException: Cannot invoke "xyz.nekonii.hexcraft.dropbox.gui.screens.Screen.eventClick(org.bukkit.event.inventory.InventoryClickEvent)" because "this.gui" is null
you never call get() so you never set this.gui
It's in the command file as
new ScreenManager(plugin).get("Dropbox", (Player) commandSender).display((Player) commandSender);
@eternal oxide It was another method sending the UUID to the method 🤦
Your switch statement in get also falls though
Is it possible to remove or disable the spectator mode menu or teleporting
(When you press 1 while in spectator mode)
if (false == false) {
return false;
}
return true;```
What do you mean by that?
you have no break; it will always fall through to admin
anyone have an answer to this?
this made me hurt
Disable the menu? No. That's client sided. Disable the teleporting? Absolutely. PlayerTeleportEvent and cancel if the cause is SPECTATE
Nah i think it's fine, IDE is saying the break is unnecessary as well. Chucked a few logs in the code blocks and it seems to just run separately
what hurt you...?
i wasted months just to do that...

Yeah it just doesn't save the gui property at all after the get method finishes
yeah sorry, I just noticed you were using lambdas
yaya
I have a bit of a problem, the teleportation cancelling works perfectly. But while I have an active spectator target (when you left click an entity while in spectator mode) it kicks me out of that state, anyway to fix it? java @EventHandler public void onSpectateTeleport(PlayerTeleportEvent event) { Player player = event.getPlayer(); this.data = new Files(Main.getInstance()); Player spectator = (Player) player.getSpectatorTarget(); if (this.data.getConfig().getBoolean("Players." + player.getUniqueId() + ".Banned")) { if (event.getCause().equals(PlayerTeleportEvent.TeleportCause.SPECTATE)) { event.setCancelled(true); player.sendMessage(ChatColor.RED + "This is disabled!"); player.setSpectatorTarget(spectator); } } } here's what I currently have when I tried to fix it
Suppose you could re-enter them into that same entity
Oh, actually you're doing that already
Do it one tick later
Also, don't assume that the spectator target is a Player. It might not be. No reason for it to be anything more specific than an Entity
Just asking out of curiosity for self learning, wouldn't it be easier to just use the .getCause() function from the event and compare it to the SPECTATE enum so it doesn't cancel out?
That's what they're doing
Ah my bad, i guess i didnt read it thoroughly
Yeah, seems that even if it's cancelled it jumps them out of their spectator target
Delaying a target set by one tick should resolve that
Hmm it still kicks me out when I teleport
Yeah.
@EventHandler
public void onSpectateTeleport(PlayerTeleportEvent event) {
Player player = event.getPlayer();
this.data = new Files(Main.getInstance());
Entity spectator = player.getSpectatorTarget();
if (this.data.getConfig().getBoolean("Players." + player.getUniqueId() + ".Banned")) {
if (event.getCause().equals(PlayerTeleportEvent.TeleportCause.SPECTATE)) {
event.setCancelled(true);
player.sendMessage(ChatColor.RED + "This is disabled!");
new BukkitRunnable() {
@Override
public void run() {
player.setSpectatorTarget(spectator);
}
}.runTaskLater(Main.getInstance(), 1);
}
}
}``` here's what I got
Strange... 
I mean... sounds like a stupid attempt, but delay it for 10 ticks I guess? lol
I'm running out of ideas. I've no clue why that wouldn't work
maybe something went wrong in the uploading proccess ill try that part again
I do that a lot
If not, wonder if it's just a client-sided issue
e.g. out of the spectator view on the client but on the server they're still spectating
Are you sure its running?
I'd hope so. The teleportation is cancelled 😛
Didn't read the whole convo
I know why it isn't working, when I exit it says the spectator variable is null
check in teh event that you have a valid spectated Entity
wdym?
Entity spectator = player.getSpectatorTarget();
make sure you actually have a target, its nullable
Yeah I checked it
I think I just need to serialize the thing
than maybe I can go to sleep
Can I code 1.16 plugin with Java 16 but compile it with java 8? So the code is on java 16 but can be used in java 8.
you can have JDK 16 and compile for java8
I really like the switch lambda feature and the instanceof variable thingy.
Oh I can!? that's pretty awesome
java is backwards compatible so you can compile in java 8 and your code will function on above versions. However minecraft is not backwards compatible so you still need to run the java version for your server version
Why is spectator mode like this
I just fixed me leaving the spectator target
but now apparently entering it also counts as a teleport
I'm trying to code with java 16 feature but compile it with java 8 so I can use it on mc version below 1.17
You can't code with java 16 without compiling it in java 16 if thats what you mean. (Unless you use reflection)
can only use the code from the java version you're compiling with.
Hmmm actually you might be able to. At that point you would have to just try it.
But your gonna have issues if the point is to support -1.17
kk, ill try it later
Yeah I build with spigot 1.17 and support down to 1.8.8 but compile against java 8 so thats what I thought you were asking.
When I check if an action from an event is right click air or right click block. When I right click a block the code repeats twice
doing this
if (a == Action.RIGHT_CLICK_AIR || a == Action.RIGHT_CLICK_BLOCK) {
System.out.println("Hi");
}
``` prints hi twice when I right click block
But when I right click air, it only runs once
How can I only make it run once for both right clicking air and block?
event.getHand()
im wondering why my events aren't working.. trying to make some items undroppable, for staff mainly but for some reason... they just aren't working
events are registered*
and do have @EventHandler
events are registered
yes
i already said, my events are registered
yes
my class implements Listener
one of your above statements must not be true or your events would be firing.
that's what im a little wonky about, i have a public static ItemStack, stafftools
so im checking if the item they are dropping is that itemstack
i'll System.out.print the boolean for whether they equal, but its obviously no.. for some reason
if the sysout happens then your events are firing
yeah, it seems like they aren't, but its just conditions i guess?
how should i check if the itemstack they drop, is equal to my static one
.isSimilar not ==
Wdym
nms
im too lazy to find you the post bout it
or any plugin similiar to that
¯_(ツ)_/¯
Ay @delicate raptor u here yet?
Hello I want some people to help me in Coding the Plugins is anyone free
?ask
If you have a question, please just ask it. Don't look for staff or topic experts. Don't ask to ask or ask if people are awake or available. Just ask the question to the channel straight out, and wait patiently for a reply. Create a thread in case the help channel you are using is already in use!
@here
I want to disable Titiles after showing once in Super Lobby Delux
isnt there a param to tell it for how long to show?
a nvm
thats a plugin question not a development
try in #help-server
Recipes
@onyx shale Can you help me in Developing my Server?
nope,pretty much everyone its working on theyr own thing so i doubt many will accept
as its a rather time expensive service
if ur willing to pay try here tho
?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/
sendMessage is deprecated?
p.sendMessage(ChatMessageType.ACTION_BAR, new TextComponent(message));
Try p.spigot().sendMessage(ChatMessageType.ACTION_BAR, new TextComponent(message));?
still deprecated
not in spigot it isn't
Worked fine on my end?
i mean i can just ignore it maybe?
Where's the error from?
Ahhh
they deprecate all BaseComponent methods in favour of their Adventure system
can u help me, pls (#914089397387927612)
If I wanna set a texture pack and I upload it to google drive where do I get the link from that I need to put in the code?
How does one setup
permissions for their commands
as in shad.feed for example
or smth
Hey guys when I use the e.getAction in my event, when I do ‘if(a == Action.RIGHT_CLICK_AIR || a == Action.RIGHT_CLICK_BLOCK) {}’
When I right click I block it output the code underneath twice
But it only runs it once when I right click air
How can I make it so that when I right click a block, it only runs the code once
Help me wtf... After setting blocks to air in 1.17 spigot I need to left/right click them that they are air? how can I fix this? help
meh static interface method overriding isnt possibl
you can't change the return type if you override
probably packet loss or something
I am setting a texturePack with a link to google drive. When I set the texture pack it says "Downloading ResourcePack Making Request 100%" then it goes away and I dont have the texturePack. What did I do wrong?
did you make it into a .zip or .rar?
yes
which one
zip
This event is properly coded, but when a player joins it didn't do anything
if you listen for the event, it should also be called when the resourcepack is refused for any reason
maybe debug with that
did you register it?
onEnable event?
could it be a missing maven dependency?
with Bukkit.getServer().getPLuginManager().registerEvents()
i doubt that
did you try restarting?
mmm
i did it with another code
ye
registerListener(this, this);
instead of registerEvents
use registerEvents
which event
ok ty
then you can do PlayerResourcePackStatusEvent#getStatus()
and it returns an enum value
loc.getBlock().setType(Material.AIR);
send the class
this should be right
do you host it on local?
or do you have any anti-viruses that block outgoing/incoming data?
I get ACCEPTED and then FAILED DOWNLOAD
wait I look
"The client accepted the pack, but download failed."
where did you upload it?
google drive
and are you using a custom client
just optifine
do you host it on local?
ye
hm i have no idea
I have a commands class (In IntelliJ IDEA) and was wondering how I add a permision to this:
player.setGameMode(GameMode.SPECTATOR);
player.sendMessage("§a§l(!) §eGamemode set to Spectator!");
}
you either check if the sender has permission or add a permission in your plugin.yml
How does one add a permission into plugin.yml
Is it
permission: shad.gm3 for example?
yep
np
does anyone know how to make it so when a player places a block it turns into a idfferent block
?stash
so when you place a dirt block, it turns into a different block
block place event
it doesnt have anything to change the placed block
theres getBlockPlaced() but no setBlockPlaced()
kk
lol thanks
what's the maximum distance a client can render an entity? I'm tryna spawn an entity when a player gets close to a location with packets, tried spawning on chunk loading but had no success
i think some percent depends on their view distance
yeah that's why i tried listening for chunk packets
nah
chunks load further than the distance that client can render entities
but why do you need it?
i have an entity spawned with packets
and when the player gets away, it obviously disappears
i'm tryna make it appear back
when it comes in your render distance
player.setGameMode(GameMode.SPECTATOR);
player.sendMessage("§a§l(!) §eGamemode set to Spectator!");``` What would I add if I want it to say a message if they do not have permission to use this?
this is my very old example for how i code for each commands
@Override
public boolean onCommand(@NotNull CommandSender sender, @NotNull Command command, @NotNull String label, @NotNull String[] args) {
if (sender instanceof Player p) {
if (p.hasPermission("risingcore.spawnsystem")) {
if (args.length == 1) {
String locationName = args[0];
if (!locations.getConfig().contains("Locations-Data." + locationName)) {
locations.getConfig().set("Locations-Data." + locationName, p.getLocation());
locations.save();
language.setSpawn(p);
return true;
}
language.alrName(p);
return true;
}
language.noArgs(p);
return true;
}
language.noPerm(p);
return true;
}
language.playerOnly(sender);
return true;
}```
i think this is cleaner than doing multiple else if lol
oh no the pyramid of pain
😠
imagine not having a command builder
old example
I wanted to ask, what would I add for map resetting, ik how to world reset, but im not at all sure how to reset a region, linking it to worldguard flags etc
oh no
yea nayways
.
what do u mean by reset a region?
the region in worldguard will be the same if you dont delete the file
so if you still have an exact copy of that world
then i dont feel like you really need to care bout that
resetiing a wg region?
Reset an arena basically, which is also a region “regionarena”
An addon for strikepractice
Or a plugin along with strikepractice
uhhh then i dont think you need to care?
Just store every block placed and then removes them on arena end or something.
is possible to change the line 1 & line 2 of the server motd?
@fast onyx I know it is possible just not how to do it- lol
well
i just searched on bukkit forums
i found one of 5 years old maybe it works
xd
Why this not work
McPlugin.java
package com.AshKetchum.FirstPlugin;
import com.AshKetchum.FirstPlugin.Commands.TestCommands;
import com.AshKetchum.FirstPlugin.Events.TestEvents;
import org.bukkit.ChatColor;
import org.bukkit.event.player.PlayerBedEnterEvent;
import org.bukkit.plugin.java.JavaPlugin;
import org.bukkit.plugin.PluginManager;
import org.bukkit.event.Listener;
import org.bukkit.plugin.Plugin;
public class McPlugin extends JavaPlugin {
@Override
public void onEnable() {
getServer().getPluginManager().registerEvents(new TestEvents(),this);
getServer().getPluginManager().registerEvents(new TestCommands(), this);
getServer().getConsoleSender().sendMessage(ChatColor.GREEN + "[McPlugin] Enabled made by AshKetchumPL!");
}
@Override
public void onDisable() {
getServer().getConsoleSender().sendMessage(ChatColor.RED + "[McPlugin] Disabled -made by AshKetchumPL!");
}
}
TestEvents.java
package com.AshKetchum.FirstPlugin.Events;
import org.bukkit.ChatColor;
import org.bukkit.GameMode;
import org.bukkit.Material;
import org.bukkit.World;
import org.bukkit.block.Block;
import org.bukkit.entity.Player;
import org.bukkit.event.Event;
import org.bukkit.event.EventHandler;
import org.bukkit.event.Listener;
import org.bukkit.event.player.PlayerBedEnterEvent;
import org.bukkit.event.player.PlayerJoinEvent;
import org.bukkit.event.player.PlayerMoveEvent;
import org.bukkit.plugin.Plugin;
public class TestEvents implements Listener {
@EventHandler
public static void onPlayerJoin(PlayerJoinEvent event) {
Player player = event.getPlayer();
player.sendMessage(ChatColor.LIGHT_PURPLE + "Welcome to the server :) ");
}
@EventHandler
public static void onEnterBed(PlayerBedEnterEvent event) {
GameMode gm = event.getPlayer().getGameMode();
if(gm != GameMode.CREATIVE &&gm != GameMode.SPECTATOR) {
World w = event.getPlayer().getWorld();
w.createExplosion(event.getBed().getLocation(),5);
}
}
@EventHandler
public static void onPlayerWalk(PlayerMoveEvent event) {
Player player = event.getPlayer();
int x = player.getLocation().getBlockX();
int y = player.getLocation().getBlockY();
int z = player.getLocation().getBlockZ();
player.sendMessage("x: " + x + " y: " + y + " z: " + z);
}
}
TestCommands.java
package com.AshKetchum.FirstPlugin.Commands;
import org.bukkit.command.Command;
import org.bukkit.command.CommandExecutor;
import org.bukkit.command.CommandSender;
public class TestCommands implements CommandExecutor {
@Override
public boolean onCommand(CommandSender commandSender, Command command, String s, String[] strings) {
}
}
Error:
Error: Could not find or load main class com.AshKetchum.FirstPlugin.Main
Caused by: java.lang.ClassNotFoundException: com.AshKetchum.FirstPlugin.Main
Process finished with exit code 1```
Why this not work
well you name it Main in your plugin.yml but its McPlugin
dis my plugin.yml
name: McPlugin
version: 0.0.1BETA
author: AshKetchumPL
main: com.AshKetchum.FirstPlugin.McPlugin
api-version: 1.14```
well it cant be
the error is saying com.AshKetchum.FirstPlugin.Main
unless you didnt recompile
i will try changing com.AshKetchum.FirstPlugin.McPlugin to com.AshKetchum.FirstPlugin.Main
Is there an event for when a player trades with a Villager?
getServer().getPluginManager().registerEvents(new TestCommands(), this); is a problem (McPlugin.java 17 line)
don't think so
there's an event for selecting a trade
Does anyone know how the change the skin of a citizens npc?
I'm trying to spawn an NPC and then change its skin to mine
Its development
I'm currently using this code
CraftPlayer craftPlayer = (CraftPlayer)player;
GameProfile profile = craftPlayer.getProfile();
Property skin = Iterables.getFirst(profile.getProperties().get("textures"), null);
String value = skin.getValue();
// player.sendMessage("Texture Value: " + value);
NPC npc = CitizensAPI.getNPCRegistry().createNPC(EntityType.PLAYER, "james");
npc.spawn(player.getLocation());
SkinTrait trait = npc.getTrait(SkinTrait.class);
trait.setTexture(value, skin.getSignature());
trait.setShouldUpdateSkins(true);
I cannot find any method for changing the skin
fixed thx BuooBuoo
How this is called?:
random-string:
- "hi"
- "how this type of string is called?"
stringlist?
#getStringList()?
So is anyone able to help me?
Already got it working:
just give the metadate skin name the same as the player Name
yea it works but i can't set the motd of a server using stringlist
is possible? at least i cannot, the ide throw error saying require string
what are you trying to achieve?
yeah but how would that work with a list
i want to go to the next line xd
going by your "random-string" name do you want to chose a random one out of them?
that was an example
just concat the two strings with an "\n" in the middle
But i need to make so when someone loses/wins a duel, the map resets for the next duel if you know what i mean
trying to make a /rename command, this doesn't rename my item player.getInventory().getItemInHand().getItemMeta().setDisplayName(String.join(" ", args));
Is there a way to make a donation link without paypal?
Is there any reason why a BOOLEAN PersistentDataType doesnt exist?
(BYTE) 0
I mean i can just do it with integers too, but im just curious as to why it doesnt exist in the first place
a waste of space to use an integer
if(!(sender instanceof Player)) {
plugin.reloadConfig();
Bukkit.getConsoleSender().sendMessage(config.getString(reloaded));
}
getting this error:
Caused by: java.lang.ClassCastException: class org.bukkit.craftbukkit.v1_8_R3.command.ColouredConsoleSender cannot be cast to class org.bukkit.entity.Player (org.bukkit.craftbukkit.v1_8_R3.command.ColouredConsoleSender and org.bukkit.entity.Player are in unnamed module of loader java.net.URLClassLoader @61a485d2)
does plugin.saveDefaultConfig() also loads the config.yml yamlconfiguration?
yes, i guess
works perfectly the command and reload the config perfectly if you're a player
but if is sent by console then error
?
what does copydefaults do?
ItemStack stack = player.getInventory().getItemInMainHand();
ItemMeta meta = stack.getItemMeta();
meta.setDisplayName(String.join(" ", args));
stack.setItemMeta(meta);
// you never set the meta```
Dont need to spoonfeed
he/she forgot one line
no it doesn;t
Do not use copyDefaults
it does
No it does not
no i was just wondering
CopyDefaults simply returns a boolean state of the default setting
plugin.saveResource("config.yml", false) saves the config file from the jar to the plugin's directory
copyDefaultConfig() created teh folder and copies the resource from yoru jar to the folder (if it exists)
thats not my problem
setting name:
ItemMeta meta = stack.getItemMeta();
meta.setDisplayName(Color.translate(String.join(" ", args)));
stack.setItemMeta(meta);
player.getInventory().setItemInHand(stack);```
is there a more efficient way in doing so
copyDefaults is a boolean for the state. You can use copyDefaults(boolean) to set the state and then supply a default reference.
How can I get the location of a random block around an entity's head
if its a human entity p.getEyeLocation().getBlock()
if its not?
i found the problem
is because the string contains color codes
so how i can remove color codes on console message?
Because the string is used for players and for console
chatColor.stripcolor? i tried that and not working
ItemMeta meta = stack.getItemMeta();
List<String> lore = meta.getLore();
lore.add(Color.translate(String.join(" ", args)));
meta.setLore(lore);
stack.setItemMeta(meta);
player.setItemInHand(stack);```
doesn't work, errors ingame & console
?paste
Hi!
I'm having an issue. I'd like to be able to access the running instance of a plugin in a separate plugin; the consensus seems to be that you include the JAR file of the dependency as a library to the dependent (https://www.spigotmc.org/threads/how-to-access-an-entire-plugin-from-another-plugin.248672/).
That doesn't seem to be true since when I try to access a field in the dependency it is null although should be set during onEnable, suggesting that the included library is it's own instance of the plugin being used as an API.
t57r
yftrtfdxgyytygygfthgtyfhttgig766tyihy
ItemMeta meta = stack.getItemMeta();
List<String> lore = meta.getLore();
lore.add(Color.translate(String.join(" ", args)));
meta.setLore(lore);```
i assume your item is null
Just get the entity location, up it by 1, then randomize the x and z value while setting a max amount it can't go more than it, so u won't get a location very far away.
no
well something is
Show AddLoreCommand.java:37 @peak granite
That's really useless to say. Ofc it's something that is null? It's an NPE??
Ok i actually need some help
idk how to reset arenas ; - ;
linking it to duels
strikepractice*
Just sysout it, and idk idk even need to strip color it since it's not rly needed, but to answer it question:
ChatColor.stripColor()
fixed it
had to check player.getInventory().getItemInHand().getItemMeta().hasLore() if it did, add onto it, if it didn't, set it
thanks@visual tide
He practically didn't help but you do you
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.
if you ever get a NullPointerException it just means something is null that shouldn't be
Knowing what's a NPE is day 1 of java
titguityruyryyggttutttiggru4i
no need to flame them for it
I'm helping them
That's how I was replied to when I started out and I definitely got better
i dont even know that it has short word
Hi!
I'm having an issue. I'd like to be able to access the running instance of a plugin in a separate plugin; the consensus seems to be that you include the JAR file of the dependency as a library to the dependent (https://www.spigotmc.org/threads/how-to-access-an-entire-plugin-from-another-plugin.248672/).
That doesn't seem to be true since when I try to access a field in the dependency it is null although should be set during onEnable, suggesting that the included library is it's own instance of the plugin being used as an API.
(Sorry for the spam, went out for a smoke and the kids decided to discuss the issue.)
You never asked a question
Bump it then?
i did smh
Please know how to use q&a
Bump it relevantly then
I dont know how to reset an arena
I elaborated on 'I dont know how to reset an arena' last night, yet no one answered
i'll do it again
so basically
You can create new dimensions every time an arena gets created.
Explanation 100
I have strikepractice installed, but I dont know how to create a code/addon to strikepractice, so whenever someone loses/wins a duel the arena resets for the next duel
if you know what im saying
Isn't that how to use a library?
If it's using a library then go to their support section
do you depend on the plugin in plugin.yml?
I'm having an odd issue with my gradle tasks.. it all started when I added the following to my build.gradle
// in repositories
flatDir {
dirs 'libs'
}
// in dependencies
implementation name: 'SomeLocalAPI'
The error report:
Entry META-INF/maven/com.zaxxer/HikariCP/pom.properties is a duplicate but no duplicate handling strategy has been set. Please refer to https://docs.gradle.org/7.1/dsl/org.gradle.api.tasks.Copy.html#org.gradle.api.tasks.Copy:duplicatesStrategy for details.
Here is my jar task:
jar {
from {
configurations.runtimeClasspath.collect {
it.isDirectory() ? it : zipTree(it)
}
}
destinationDirectory = file("$rootDir/build/libs")
archivesBaseName = project.name
}
It compiled just fine with Hikari before but now it doesn't compile for some reason
Indeed
im a beginner in code so i dont know much
@floral pier the plugin is loading before the dependency maybe
Looks like a weird version of shadow
That doesn't have anything to do with what I said though
not sure if this would help then but try using maven or gradle to add the api instead of just directly adding the jar
No worries
Any ideas on what I could try differently?
But were you even coding something? If so then here would be the place 😅
I thought of that, I added a syncedDelayedTask to ensure that the dependancy is loaded before attempting access.
He's using a plugin / library, and he doesn't know how to use it I think.
I don't know how to start it, so i'll take it to #help-server
Set the duplicate handle strategy maybe
Should that not simply cut out some overhead?
Try to make it 2 minutes, just to remove the doubt
whoops
@grim ice I'll give it a shot and let you know the result
Hm I tried by it throws a weird java.sql.SQLException: Access denied for user ''@'localhost' (using password: NO)
how do i check if line number of lore is set
That has nothing to do with gradle?
I mean that just looks like you’ve passed a bad input to some sql dependency of yours
I once had a problem where my plugin tried creating a spigot server within the plugin itself
Am I not excluding things correctly
lol
Did you shade spigot?
How can I remove all potion effects from player
player.removePotionEffect(effect.getType());
}```
thank you!
Dependent
public class Main extends JavaPlugin
{
Plugin powerMiner = null;
@Override
public void onEnable()
{
PluginManager manager = Bukkit.getPluginManager();
Plugin plugin = this;
BukkitScheduler delay = Bukkit.getScheduler();
delay.scheduleSyncDelayedTask(plugin, new Runnable()
{
@Override
public void run()
{
powerMiner = JavaPlugin.getPlugin(PowerMiner.Main.class);
//if(!manager.isPluginEnabled(powerMiner)) manager.disablePlugin(this);
ServerDataInfo.setServerPluginInfo(plugin, powerMiner);
}
}, 2400L);
}
@Override
public void onDisable() {}
}
@grim ice
god i hate it when people call their main class "Main"
Something like PluginMain would be better
Main is fine
xD
but most people dont like it
since a plugin is an addon
and main is mostly used for standalone software
anyone?
I mean it is the main class of the module 
But Ig it’s inconvenient since you can only import one class named exactly Main
i'm trying to create a command /removelore <line number> and i want to see if the number they specified exists on the lore
yea
if the # they put in is less than or equal to the length of the lore, then it is set
if not, it would be out of bounds
Also, Conclure, here is my build.gradle: https://pastebin.com/h1p9GGzN
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.
Btw you might wanna use the shadowJar gradle plugin for shading and stuff
It's encapsulated so it's still organized
Sure thing
still gross. still not the best practice
¯_(ツ)_/¯
just my 2 cents
keep naming it main and nobody will care lol
😄
KCWCJ yeah it’s good keeping those internals internally
how would i remove line x of an item
Get the lore change it and set the lore again
lmao thanks for the needed thread we didnt have before
0 1 2 3, size of 4
Would anyone know why Citizens2 API says that the NPC#getEntity() is always a null entity?
I am loading my things that use Citizens after CitizensEnableEvent (When citizens logs how many npcs is loaded)
I tried checking if isSpawned() was true, it wasnt, i tried spawning the NPC it failed, however when you login to the game the npc is just fine?
Do i need to be calling my enable methods another tick after the CitizensEnableEvent?
Always null?
Pretty much
Try using spigot
Code im using to get NPC's ^
Hmm I believe npcs aren’t always spawned? Like someone must be loading the chunk in order for them to be physically spawned maybe?
Would that have a drastic effect on things?
Yeah could have
I read it wrong. Your npcEntity is null
Yeah, the NPC from citizens is fine, its just the actual Entity
Im not sure either
Citizens API is always weird asf
Not really
?
when i print out it like this:
jar {
from {
duplicatesStrategy = DuplicatesStrategy.EXCLUDE
configurations.runtimeClasspath.collect {
System.out.println(it.name)
it.isDirectory() ? it : zipTree(it)
}
}
destinationDirectory = file("$rootDir/build/libs")
archivesBaseName = project.name
}
it prints:
slf4j-simple-1.6.4.jar
slf4j-api-1.7.30.jar
> Task :compileJava UP-TO-DATE
> Task :processResources UP-TO-DATE
> Task :classes UP-TO-DATE
> Task :jar
HikariCP-4.0.3.jar
slf4j-simple-1.6.4.jar
slf4j-api-1.7.30.jar
HikariCP-4.0.3.jar
slf4j-simple-1.6.4.jar
slf4j-api-1.7.30.jar
HikariCP-4.0.3.jar
slf4j-simple-1.6.4.jar
slf4j-api-1.7.30.jar
HikariCP-4.0.3.jar
slf4j-simple-1.6.4.jar
slf4j-api-1.7.30.jar
bruh
I don’t know what you’re trying to do
compile a mf plugin 😂
But use shadowJar my buddy
aight
Also if you have the effort, switch to kotlin dsl
https://cdn.discordapp.com/attachments/741875863271899136/914103273152204831/2021-11-27_11-39-04.mp4 Help me wtf... After setting blocks to air in 1.17 spigot I need to left/right click them that they are air? how can I fix this? help
Holdon im gonna do some tripple iq bs rn
Im gonna load the configs on NPC spawn
Show code? Also if that's a fork it's not our problem
I have seen that happen because of viaversion for people running 1.8 on a 1.16 server
sheeeeesh it worked
loc.getBlock().setType(Material.AIR);
Ok so you seem to have ignored the question you were asked
Wouldnt you normally use the generate chunk event anyways? and generate it off the event?
?jd
Take a look at the various methods in said class
it is the code
That wasn’t the question
Spammy too huh
my bad
you see uh the problem was... everything was working fine, i forgot i changed a plugin name in the plugin.yml and it changed the plugin config folder path meaning it's sql connection details were invalid
Patience young greenhorn
cause you need to translate them
i guess
use ChatColor#translateAlternate something like that
&
i know that works for messages but for motd idk
Or §
No
lemme try
ikr
if it's linking config, then use it manual code
i wish u could still make animated motds
thanks :D
😦
ItemMeta meta = stack.getItemMeta();
List<String> lore = meta.getLore();
lore.remove(Integer.parseInt(args[0]));
meta.setLore(lore);
player.getItemInHand().setItemMeta(meta);```
command is /removelore <line number>
error below
https://paste.md-5.net/esotajocov.cs
dont do that
Index 3 size 3
if it leaks without spigot translating it then it leads to crashes
alisa you should learn java before developing spigot plugins
I usually just use a method for chatcoloring
where
indexes start from 0
6am programming
ik that lol
why null 😐
btw i have discovered that minecraft has a packet for when you eat or shoot your bow while mining
not 0,1,2,3 because that is for a 4 sized one
imagine setting that as like a trigger for something in a minigames plugin lmao
wdym trigger?
packettt
like "Maintenance" and the red X
you need to manipulate pings
wich one
unless they've added support for it in ping events, packettttttt
example?
booleans are bytes
lol wtf
because there is no way to reference a single bit in memory
0000 0001 = pumpkin hat off
0001 0000 = pumpkin hat on
0001 0001 = Pumpkin hat on and off
why not use a boolean
https://paste.md-5.net/uyetoqokah.sql
I would send code but i got no clue where this comes from
that's not the problem, see my byte explanation
they will need to have [PingApi] installed?
oh yeah
lmfao
try sending that
okay thanks
wait isn't 0x10 0001 0000
and 0x02 is 0000 0010
but this still makes no sense
depends on endianness
or does that not matter in java
jvm
how i can download the jar to include on external libraries?
what version are you in?
https://github.com/henry-anderson/PingAPI/tree/master/PingAPI/src/org/henrya/pingapi/v1_13_R2 take only the code you need
no point in using the entire plugin
how do i gen a random string consisting of A-Z a-z 0-9 (length 7)
wait do you need it to be multiple version compatible?
ok ty
final String select = "abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789"
Then use random
loop through the chars from a-z and 0-9
generate random number for each iteration of string character
and pick that character via random number index
you can either use protocollib or modify the plugin to allow for more recent nms versions
schrödingers snowman
String charset = "abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ01234567890123456789"; what do i do next
does not calling the update method after inventory manipulation cause any issues besides desynchronization for the client?
Probably not
depends on what you manipulate
iirc setting the result slot of a crafting table requires you to send a refresh
Shulker Box inventory
nvm
when I right click a chest with my custom stick, how can i check and edit the contents of that chest?
When i get a player with the name of J, and any players first character in his nametag is J, it gets this player. How can i avoid that?
See RandomStringUtils
idk what you're trying to do but it sounds like you're having issues with autocompleting? try https://hub.spigotmc.org/javadocs/bukkit/org/bukkit/Bukkit.html#getPlayerExact(java.lang.String) getplayerexact
i think that does what you want
never used it myself 🤔
if(player.getInventory().getItemInHand().isUnbreakable()) { doesn't work
if(player.getInventory().getItemInHand().getItemMeta().isUnbreakable()) doesn't work either
it's in red
:/
^
how do i see if a player's inv is empty
loop through contents if all are null its empty.
Thats if full
Does anyone know how to make a CitizensNPC able to be itneracted with either via API or by a settings?
EG: When i right click on a CitizensNPC, i should be able to get the NPC shaking its head at me
nope still can't be used for that
Can I stop a server somehow with spigot?
Bukkit.shutdown() I think.
Oh. API. Yeah. #shutdown() 😛
Thanks!
Yeah just don’t use System::exit 
player.removeMetadata("test"); doesn't work
what's the maven mySQL connector import?
this one refuses to work
https://mvnrepository.com/artifact/mysql/mysql-connector-java/8.0.27
ill do that now
I was mindlessly rewriting my discord integration plugin and ended up putting a shutdown hook in instead of using ondisable
CraftBukkit comes shaded with an SQL driver already
You shouldn't need to do this yourself
It helps because this error marks the eclipse to the private one to be able to pass the screenshots, someone help me?
Usage: !verify <forums username>
Just standard Java JDBC connection APIs.
https://docs.oracle.com/javase/tutorial/jdbc/basics/connecting.html
You can skip the whole driver registration. The more important bit is establishing a connection with DriverManager.getConnection()
Skip, don't skin*
@grim ice Still no luck.
player.getInventory().getItemInHand().getItemMeta().spigot().isUnbreakable()
1.8 = pain
1.8? D:
1.18 = pain xD
only for biomes stuff xd
anything that isnt 1.14 - 1.17 = pain
I Don't really know then
because
majority of pvp before dream and the other kids went too famous
basically every pvp server runs it
was 1.8
Nope for everything
^^
Don't tell people which IDE to use.
Its not. Its preference
they both have their pros and cons
the ide is not the issue
the os is
no more security patches for win7
"i like men"
Any solucion?
nice
Any solution?
yeah wonder who
deleted their message
o.o
^
i only moved to intellij because when i used eclipse it didn't have inbuilt maven support, and it wouldn't let me install the maven plugin for one reason or another, mostly user error
With that being said, you should still give other tools a chance and not neglect an impartial judgement.
i only remember move from netbeans to intellij many time ago... xd
I'm certain that's before W7. Looks like XP or Vista.
I don't use intellij cause it gives me constant errors for no reason. So I just use it to export plugins to eclipse xD
100% before win 7, I never remember win 7 looking like htat
thats some old ass ui design
unless they use some 3rd party software to change it
oh wtf there is that's gross
Read the whole message
How I can open a menu with 27 slots and add items?
Bukkit#createInventory() is your friend
Ty
that's literally the default design behind windows theme engine. Even windows 10 has it, but it was carefully hidden by microsoft
I've seen applications on windows 10 that run under windows 7 basic theme
@worldly ingot
4.9 SDK? Why does that sound... old
you would think in 2021 nobody would use a ui design like windows xp or vista or etc, we have standards!
Adding custom heads?
yeah 4.9 apparently came out in 2018 or smth
what should I do?
Probably well before that
well im on Linux and i don't follow standards, but yeah. I actually like the classic theme. It makes clear where something is clickable and where isn't without any thinking
ew
in recent versions getEntity returns a Projectile object, which you can check the Shooter then checking if its an instance of player :)
Okay I've the head now how I can add him to the inventory?
Material.?
you should get an itemstack
thanks
check the methods of inventory
heyo quick question idk if anyone can help me with that
but is there any update on how fast spigot would be available for 1.18? will it take a couple days/weeks or the same day?
?eta
There is no ETA. Having an ETA leads to unrealistic deadlines, false hope, and a bad product. It will be ready when it's ready.
ah alright thx^^
There are pre updates out if you want to try those
just check the server every now and then after release, there'll be a post in #announcements by md_5 when it does eventually come out
well rn im trying to make a server with an 1.18 map on a 1.17 server but i tried to make a 1.18pre map but that didnt work on the 1.17 server
so rn i kinda have to figure something out to get a 1.18 map thats 10kx10k prerendered and that works on a 1.17 server
and since i wanted to use some plugins that wouldnt work without spigot when 1.18 releases on the 30.
1.18 won't work on 1.17 servers
I'll be surprised if viaversion even updates for this version.
thats the thing theres a German minecraft vanilla project that has a 1.18 map working on a 1.17 server so somehow it does work but i have no idea how xD
maybe the old 1.18 datapacks
ye someone told me its 1.18 experimental snapshot 7 with the datapack but that just confused me and i have no idea how that works
ah alright my bad
how to save a baked in config to the drive again?
wtf is that question lmao
i looked it up but it only says how to save the default config
well whats a baked in config?
presumably one inside the jar file
config.yml
oh
the issue is the only thing I've found is how to a) write configs using code and how to b) save config.yml
neither is really something viable
The way on the title are sended is the same on 1.8 and 1.17?
#sendTitle() for all versions?
welp, the sendtitle will work for every version has it
but the function in sendtitle is different each version
you still use the API ?
Spigot API 1.13, yes
I mean, then what is the issue
My plugin is 1.7-1.17