#help-development
1 messages · Page 2120 of 1
```xml
U can also paste it in this thing (just copy paste this msg)
```
yeah dawg your build config a little screwy
test
replace the single file declaration with the whole folder
just use
<resources>
<resource>
<directory>src/main/resources</directory>
<filtering>true</filtering>
</resource>
</resources>
<resources>
<resource>
<directory>src/main/resources</directory>
<filtering>true</filtering>
</resource>
</resources>
what happned formatting
<resources>
<resource>
<directory>src/main/resources</directory>
<filtering>true</filtering>
</resource>
</resources>
``` try using this for your resources instead of what you currently have
Also you may want a maven plugin like maven-compiler-plugin
LMAO
LOL
dawg did we all 3 copy the same thing
it must be good advice
*maven plugin, not ide plugin
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-compiler-plugin</artifactId>
<version>3.8.1</version>
<configuration>
<source>${java.version}</source>
<target>${java.version}</target>
</configuration>
</plugin>
for maven-compiler-plugin
dinscord
that copies all contents in your resource folder into the root of the jar, useful for copying configs, etc
php 😐
a mess 😐
understanadble
I'm getting a ConcurrentModificationException when editing a custom mob inside one of their goals, is there a way I should go about doing so?
ahh yes
good old CME
you cant modify Lists in a loop (remove)
have to use theyre Iterator
what where do i use that plugin? in the pom?
yee just slap it in the <plugins> section
It's inside the tick() function inside the goal. How can I go about doing it differently
which is inside the <build> section
sec
i have a decent way of handling this in one of my projects
Perfect, thanks
Now I get
Cannot resolve method 'getDataWatcher' in 'ArmorStand'
is there anything I could do about this, maybe convert armor stand to entityarmor stand?
Unrecongized tag: 'plugin'
in the build
should i jsut use intellij it has a plugin so i dont have to worry about this build right
paste your pom
sorry im new
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
<modelVersion>4.0.0</modelVersion>
<groupId>dev.cibmc.spigot.pluginbaby</groupId>
<artifactId>pluginbaby</artifactId>
<version>1.0-SNAPSHOT</version>
<packaging>jar</packaging>
<properties>
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
<maven.compiler.source>1.8</maven.compiler.source>
<maven.compiler.target>1.8</maven.compiler.target>
</properties>
<repositories>
<repository>
<id>spigot-repo</id>
<url>https://hub.spigotmc.org/nexus/content/repositories/snapshots/</url>
</repository>
</repositories>
<dependencies>
<dependency>
<groupId>org.spigotmc</groupId>
<artifactId>spigot-api</artifactId>
<version>1.17-R0.1-SNAPSHOT</version>
<scope>provided</scope>
</dependency>
</dependencies>
<build>
<sourceDirectory>${project.basedir}/src/main/java</sourceDirectory>
<resources>
<resource>
<directory>src/main/resources</directory>
<filtering>true</filtering>
</resource>
</resources>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-compiler-plugin</artifactId>
<version>3.8.1</version>
<configuration>
<source>${java.version}</source>
<target>${java.version}</target>
</configuration>
</plugin>
</build>
</project>```
awesome
I'm lost
Execution default-testCompile of goal org.apache.maven.plugins:maven-compiler-plugin:3.8.1:testCompile failed: multiple points
is that the wrong addees?
I left comments explaining what this stuff does in a nutshell, your basically setting Objects from the list you want to remove, and then removing them when you done looping @granite beacon
What is data watcher for?
to be honest I have no idea
DataWatcher watcher = ((EntityArmorStand) stand).getDataWatcher();
PacketPlayOutEntityMetadata data = new PacketPlayOutEntityMetadata(stand.getEntityId(), watcher, false);
((CraftPlayer)p).getHandle().b.a(data);
this is the code I'm trying to update
I understand that but how can I implement that in my scenario
I'm not sure when I can do that as its in the tick method of the goal
Can you show the code you are using?
and whats that mess of packets do? whats your goal here to do
its a plugin that already exists but its from 1.16 i think
so I'm updating it to 1.18
What throws the error is the two lines with comments
well without knowing what DataWatch does or that packet does its hard totell exactly the end goal
These are the mods (look ugly but they're temporary)
public void holdBomb(boolean bomb) {
if (bomb) {
((org.bukkit.entity.Skeleton) this.getBukkitEntity()).getEquipment().setItemInMainHand(new ItemStack(Material.TNT));
} else {
((org.bukkit.entity.Skeleton) this.getBukkitEntity()).getEquipment().setItemInMainHand(new ItemStack(Material.TNT, 0));
}
}
public boolean isHoldingBomb() {
return ((org.bukkit.entity.Skeleton) this.getBukkitEntity()).getEquipment().getItemInMainHand().getType() == Material.TNT;
}
theres no commented out code there?
117, 120 (not commented out, the lines with comments)
cant you send the error too
?paste
weird
i dont see your error path in there
and none of it is what your doing
thats something with entity stepping
not setting item in main hand
Not sure at this point
I fixed up the methods but still, it's throwing the same error.
public void holdBomb(boolean bomb) {
this.setItemSlot(EquipmentSlot.MAINHAND, !bomb ? ItemStack.EMPTY : new ItemStack(Items.TNT));
}
public boolean isHoldingBomb() {
return this.getItemInHand(InteractionHand.MAIN_HAND) != ItemStack.EMPTY;
}
It also only seems to occur when you remove the item rather than when adding it?
where can i see all the bucket events
?jd
Go to the spigot docs and then look under events
thx habibi
does double > int*int fail if int is bigger than sqrt(Integer.MAX_VALUE) ?
i want to not have to call sqrt on double since its so slow
How Can I Prevent Creeper from Exploding? I mean not Explosion Damage Just Creeper wont explode
theres a event when the creeper decides to explode i think
A double is larger than an int if that's what you're asking
oh really let me see
Because you're undoing that sqrt
im asking what happens if that int says 30 mil
Yeah ıts onEntityExplode
Thank you 🙂
im fairy sure 30mil² is bigger than Int.MAX_VALUE and im unsure if the check will still be computed correctly
@chrome beacon
double not Double
ah
Also why not use long if you don't want decimals
Does anyone know how to use the Tebex API?
i dont i just want the check correctly
Attempting to generate a gift card and it isn't working whatsoever.
final HttpRequest createHttpRequest = HttpRequest.newBuilder().header("X-Tebex-Secret", "token").uri(URI.create("https://plugin.tebex.io/gift-cards")).POST(HttpRequest.BodyPublishers.ofString("{\"amount\":" + value + "\"}")).build();
which forces both sides to be computed as double
im using double because its vector math
are you saying double > int * ((long) int) would be better?
Oh I wanna set Creeper. Creeper Will Explode but wont die just explode
How Can I set this
But If I do it Creeper will never die, right?
cant cancel the death event anyway. I solved that exact problem by just respawning the creeper inside the Explode event
and of course setting its health and attributes to the ones the creeper which just exploded had
hmmm
I gave it more changes but thats basically what you have to do i think
But There is a should be easier way
you can do it in the entity death event i believe
but I don't think there is an easier way
Okay Thank You For Help 🙂
How to use InventoryMoveItemEvent to prevent the player from moving items to any container?
So I switched my NMS from 1.18 to 1.18.2 and the new NMS for 1.18.2 is now changed back to the pre-mojang-mapped style. And when I change it to that, it gives me compilation errors:
[18,43] cannot find symbol
[ERROR] symbol: class PacketPlayOutSpawnEntity
[ERROR] location: package net.minecraft.network.protocol.game
Help, Please!!
Is there any way to get location of a block on which player is standing
and also the direction at which player is looking
Get the players location and just subtract 1 Y
ok
?paste
ig but i wouldnt do that
i would get the bottom block relative of the player location
What happens if you try and do things with a world which has been unloaded or deleted?
How would I stop endermen getitng angry at endermites?
@noble lantern Should be like this right?
Yes
but you need a {} dont you
since its multiple lines of code
or does it count since all of them are under each other
Hi I'm trying to make a plugin that manages minigames. My problem is that I want a command that writes a list of worlds to config.yml inputted when a player executes the command /minigames add <lobby/arena> <minigameName> <worlds> but when I run that command I get this error in console:
Cannot store to object array because "this.worldNames" is null
here is my code: https://paste.md-5.net/melarifoce.java
anyone know what this.setGoalTarget in NMS is in 1.18.2
Pog
why can't I put ```xml
<relocations>
<relocation>
<pattern>com.github.stefvanschie.inventoryframework</pattern>
<shadedPattern>[YOUR PACKAGE].inventoryframework</shadedPattern>
</relocation>
</relocations>
to a maven-jar-plugin
Worldnames[] is a string because String worldNames[] makes a string called worldNames, if you want to make a string-array, use String[] worldNames
Yessir it is
Dynamic registration is pog
Help with reflection
Everything in my api registers dynamically
nice
ooh thank you! yes I see where i went wrong now
Np, GL further
How can I loop through the server's files?
??
at java.lang.ClassLoader.defineClass1(Native Method) ~[?:?]
at java.lang.ClassLoader.defineClass(ClassLoader.java:1012) ~[?:?]
at java.security.SecureClassLoader.defineClass(SecureClassLoader.java:150) ~[?:?]
at org.bukkit.plugin.java.PluginClassLoader.findClass(PluginClassLoader.java:197) ~[paper-api-1.18.2-R0.1-SNAPSHOT.jar:?]```
does anyone know why my NMS isnt having fun when i try and spawn a custom enttiy
how can i get the direction the player is looking at
Did you reobfuscate your plugin ?
you need to re obfuscate your code
player.getEyeLocation().getDirection();
ok
how can I use log colours in getLogger().info()?
I am guessing you are using paper ?
ChatColor.COLOR
ah ok thank you
Np
are there any colour codes i have to use or is it just common colour names
ok thanks
i'm the person who is dumb here?
i'm working on MCP Modding
this person wants me to loop though everything
?jd
depends what you are doing. This can be the valid solution
how can i set a block in a given location
theLocation.getBlock().setType(Material)
ok
thanks
youll have to copy over the BlockData too
i just want to set the block in fron of player in fire
depending on which location you are getting
so I changed worldNames to a string array but now the console give me this:
Cannot read the array length because "a" is null
but I didnt even declare a variable called "a" ??
without seeing code we can't really say either
anyone?
what specific server files
A is null
can i create a location variable with my own positions?
Location varName = new Location(<world>, x, y, z)
thanks
np
hello, i am using AsyncPlayerChatEvent to replace censored words, will this cause issues with other plugins?
🤷♂️ probably not
if(player.getInventory().getItemInMainHand().getType().equals(Material.STICK)&&!block.getType().equals(Material.AIR)&&!block.getType().equals(Material.WATER)&&!block.getType().equals(Material.LAVA)){
block.setType(Material.DIAMOND_BLOCK,true);
for(int i =0;i<=5;i++){
Location player_block_frontX = new Location(player.getWorld(), player_blockX + i, player_blockY, player_blockZ);
player_block_frontX.getBlock().setType(Material.FIRE);
Location player_block_frontZ = new Location(player.getWorld(), player_blockX, player_blockY, player_blockZ + i);
player_block_frontZ.getBlock().setType(Material.FIRE);
Location player_block_backX = new Location(player.getWorld(), player_blockX - i, player_blockY, player_blockZ);
player_block_backX.getBlock().setType(Material.FIRE);
Location player_block_backZ = new Location(player.getWorld(), player_blockX, player_blockY, player_blockZ - i);
player_block_backZ.getBlock().setType(Material.FIRE);
}```
with the help of this code i am able to summon fire in fron of player by 5 blocks but it summons it in a cross form and is there any way to summon fire in a spherical form?
Do it at a low level, don’t do it at monitor or else it’ll fuck with logging plugins
thats really messy tbf
?
what was the name of sharpness ench
DAMAGE_ALL
How can you get old and new item in inventory click event?
I always get confused with it
ItemStack
getCurrentItem()
Gets the ItemStack currently in the clicked slot.
ItemStack
getCursor()
Gets the current ItemStack on the cursor.
Copied from Javadoc
Yes, but sometimes it does not work like that
for ex, if I put an item in an empty slot, getCurrentItem() sometimes returns null
or air
but if I use getCursor it returns the correct item
but not always
This I can see. You should check for both
This however sounds odd
Hello, I have one question, I try to make a grenade, it's work fine but I have problems with particles. Actually my particles go over the map, it's a very big explosion, and I want to know if you know if it exist a methods or someting about the particles ?
To manage the tall...
wdym?
Like resize it?
if ur using an explosion particle u can just change the float to something smaller or bigger
I don't understand your expression i'm french (and i know it's bad sry.. xD), Yes it's an explosion and you have particles who makes the smoke, but the particles spawn like a shit
Oh i know wdym means what do you means Oo
I can paste a screenshot if you want
Like i want to resize and just put more particles in one place
Hey i am using AsyncPlayerChatEvent to replace the player's msg but its not working the way its supposed to be
@EventHandler(priority = EventPriority.HIGH)
public void onMessage(AsyncPlayerChatEvent e) {
String[] wordsToReplace = SimpleReplacer.replacements.keySet().toArray(new String[0]);
for (String word : wordsToReplace) {
if (e.getMessage().contains(word))
e.setMessage(e.getMessage().replace(word, SimpleReplacer.replacements.get(word)));
}
}
My code ^
crap idk what to do
Nice, don't worry, thanks for your response
what is wordsToReplace
is there any words in there
oh wait
nvm
Yea there are
well what is it doing
its just replacing censored words
It is not replacing the words
nvm fixed the issue, reloading the config wasnt reloading the hashmap
also you dont need to check if the message contains the word, just use replace
Hello, do you know if it's possible to set my item into many slot without using another inv.setItem(blablabla..), just had one line code ?
You could use a for loop and inv.addItem(Item item);
Wdym ? And i have a specific method for set my item, i've create a method with my item stack and this is what i have when i want to add an item to my inventory : inv.setItem(10, getItem(Material.BLUE_CONCRETE, "Test", 1, Collections.singletonList("Test Lore")));
10 is the slot
after you have the method with the material, the name, the number and the lore
Do you want to add the same item for multiple slots?
Yes
So you could do this:
for(int i=0;i<3;i++){
inv.addItem(getItem(Material.BLUE_CONCRETE, "Test", 1, Collections.singletonList("Test Lore")));
}```
This will add an item for the first 3 available slots
Ok nice i can try that, and if for exemple i want to add the same item for specifics slots ? It's possible ?
how could we add some sound effects to a player
https://www.spigotmc.org/threads/how-to-play-any-in-game-sound-using-packets-packetplayoutnamedeffect.212348/ i think ive already use this
You could make a list of the specific slots and then iterate through that list, for example:
List<Integer> lstSlots = Arrays.asList(3,6,7);
for(int i=0; i<lstSlots.size();i++){
inv.setItem(lstSlots.get(i), getItem(Material.BLUE_CONCRETE, "Test", 1, Collections.singletonList("Test Lore")));
}
You are a genius I will try that
Haha, happy to help 😁
?javadoc
I have this code:
import com.ytg667.myplugin.events.TutorialEvents;
import org.bukkit.ChatColor;
import org.bukkit.plugin.java.JavaPlugin;
public final class MyPlugin extends JavaPlugin {
@Override
public void onEnable() {
// Plugin startup logic
getServer().getPluginManager().registerEvent(new TutorialEvents(), this);
getServer().getConsoleSender().sendMessage(ChatColor.GREEN + "[MyPlugin]: plugin is enabled!");
}
@Override
public void onDisable() {
// Plugin shutdown logic
getServer().getConsoleSender().sendMessage(ChatColor.RED + "[MyPlugin]: plugin is disabled!");
}
}```
And im getting this error: `Cannot resolve method 'registerEvent(TutorialEvents, MyPlugin)'`
What is wrong here?
the name of the event class file is TutorialEvents
Could you send the TutorialEvents class?
registerEvents
^
import org.bukkit.ChatColor;
import org.bukkit.entity.Player;
import org.bukkit.event.EventHandler;
import org.bukkit.event.Listener;
import org.bukkit.event.player.PlayerJoinEvent;
public class TutorialEvents implements Listener {
@EventHandler
public static void OnPlayerJoin(PlayerJoinEvent event) {
Player player = event.getPlayer();
player.sendMessage(ChatColor.YELLOW + "Welcome to the server!");
}
}
make it plural
wdym
hello i need to use bukkitrunnable for delaying a command, right?
Wrong method name
change registerEvent to registerEvents
Yes you can use that to run delayed methods
i just want to use the command for 1 time but delayly
which method
You would want to use getServer().getScheduler().scheduleSyncDelayedTask()
how can I know if the player picked up specific item, e.g. you have 2 diamonds, how can you know that he picked up the 1. one?
ty for any help
You can use the InventoryPickupItemEvent to detect item pickup and count the amount of diamonds he has picked up
how can i take the seconds remained?
I am working on diamond gen. for bedwars, when it reaches 5 diamonds, I want to block it until the player colletcs them
wont it be a bit less performance friendly
I gave a deprecated method the first time, use the first method featured here isntead https://hub.spigotmc.org/javadocs/spigot/org/bukkit/scheduler/BukkitScheduler.html
I would have a runnable that checks if a variable is true and then spawn the diamond every set amount of seconds, then in the InventoryPickupItemEvent if a player picks up a diamond, change the variable to false
for now I have that, something similar
but what if the player would drop diamonds and other player would collect them, then the generators would suddently work again
hope that that makes sense
how can I calc the distance between the drop pos and player pos
and then check it
Why would that be a problem, you want the generator to keep working after a player picks them up, no?
I want the generator to work only when the player picks the diamonds directly from it, and when it is full, it stops again
and I want to only resume generator if player picks items directly
Oh you mean that a player can pick up some random diamonds and this would make the generators to keep working
yes
Is your plugin at 1.8?
I actually plan to code a bedwars plugin at 1.8.8 as well haha
nice, it is not hard except for the shop and what I want now
You could set a custom lore/title to the diamonds generated by the generator, and then only reset the generators if the item has that specific lore/title
A bit of a workaround, but should work
for example I give them the name: Diamondo
and then I rename them back when they are picked up
That's a good idea, haven't thought about renaming but you are right you could rename it once the player has picked it up
Yeah it will help me in the future as well xD
because in the real bedwars once the gen reaches X amount of items it freezes
Yeah so it won't be to overpowered
Hello! I'm trying to play the block breaking animation using packets but it seems that Packet55BlockBreakAnimation is deprecated?
If I send plugin message channel (own), that get info from proxy and I want to send chat message with that info to certain player should I do it on proxy, or send it again to the server and here send chat message?
Yes, but someone told me that it is better not to make plugins on proxies etc, so I wonder if it is better to return to the server with the player and handle messages here?
hey guys how would i go about making a custom item plugin with a config to create custom items
Hi, how can i check if a crop block is fully grown?
pretty sure you can check the stage in the block data or something
and then check it against the max stage
no idea how to get that
Hello ! Is this possible to make methods for an inventory ? I explain. I try to make a paginated GUI, I have three inventory who correspond to page1, page2, page3, it is possible to make a method for the inventory and put the itemstack into this method and after juste make a player.openInventory(page1) ?
because i've got something using CropState but i don't know how to get the CropState of a Block
you can make a multi inventory object which stores all the inventory pages
@midnight shore cast the block data to Ageable and check it against the max age
Ok thanks, do you know if there is a tuto anywhere ? i don't have any idea for making this i'm a beginner
I working on this kind of project, if you want, I can provide some idea of it
Ageable data = (Ageable) block.getData();
boolean isFullyGrown = data.getAge() >= data.getMaximumAge();
``` @midnight shore
pretty sure thats it
It's your job and i don't want to be a thief (terrible bad english)
I don't mean to give you my source code(although eventually I will put them on github), I mean I can provide you some ideas of how to code it
Nice, I'm listening to youy
it's pretty simple
you just need an object which stores all your pages
lmao, for u yes you help me all the time
you can use array to do that
Ok i was thinking about array but didn't how it's possible, i will serch about that
then you can create a method which returns current page or previous page or next page
just do this kind of stuff may work(or if you want, you can just use my API, which I will finish it later)
Tell me when you finish your API so, I will try both of these methods, just, so i just had to make my inventory with my items, i sore them into an array list (one arraylist per inventory) and after i don't know but i will find xD
I will tell you once I finished it, wish you good luck
ty
thanks, you can dm me if you want, thanks for all your help !
is that what u've tried so far?
PotionEffect
?services this discord is not the place for advertisement @atomic zodiac
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/
I'm making a minigames plugin and I want to be able to control when people can break blocks or do various actions etc, so I need some kind of permission system
I was just wondering what people recommend for doing that
could use luckperms
it has a transient permission api
else the already built in permission api should work fine? (Creating PermissionAttachments etc)
mkay. Previously what I've done is use a class to wrap a player with a list of permission, then making listeners to check that
though that doesn't store across reloads
ah
right, do you have link on how to get started with that? I've never really used it before
wdym
you're managing a bunch of re-assignable variables of certain players, correct?
I'm trying to control things like when players break blocks and stuff
I guess yeah
previously I created an enum of different permissions
then wrapped a player with a list of those
let me ask ya, are all these "variables" just boolean flags? In that case an enum might be fine
server.sendData();
player.sendData();
(Bungee) What is the difference?
can a player interact etc
server gets a random online player and send the message over that player's connection
whilst the latter makes sure the message is sent over the specific player's connection
Ok thanks
thinking about it now it's probably easier to just do that thing on a game specific basis?
Also is it safe to call player.connect and send the message directly after?
but maybe not idk
player.connect?
Yes 1.8
run
never seen that method
mye, well you could have an EnumSet with your flags, then use ::contains to check whether a specific user has the given permission/flag and then if you wanna store it to your disk for instance, you could store a list of ints where the ints represents the ordinals of the flags
Will do it like this:
//Creating arena, please wait...
JsonObject message = new JsonObject();
message.addProperty("task", "create");
message.addProperty("player", player.getName());
message.addProperty("name", name);
message.addProperty("type", gametype);
player.connect(server, (connected, throwable) ->
{
if(!connected)
{
//Could not connect you to the server!
return;
}
ArenaPlugin.getInstance().sendToBukkit(message, player);
}, ServerConnectEvent.Reason.PLUGIN);
?jd-bc
How are you assigning to a user?
This is what I've done previously
class SomeUserDataTransfer {
final Set<Flag> flags = EnumSet.noneOf(Flag.class);
void addFlags(Flag... flags) {
flags.add(Arrays.asList(flags));
}
boolean hasFlag(Flag flag) {
return flags.contains(flag);
}
}
enum Flag {
BREAK_BLOCK,
PLACE_BLOCK
}
that'd be the most simple one
yeah so pretty much the same
is there an event that listens just for players attacking players or do i have to use EntityDamageByEntityEvent
becomes a bit trickier if you want to, lets say have parent and children flags
you'd have to use that event
An example?
try and see
idk actually
oh I dont have any examples but let me write one
And is this better than using inbuilt perm system?
idk
gonna be a bit faster
less friendly towards other plugins
altho more robust from your side
is there anything about this that would make this event just not work at all
like it doesn't even cancel
even if its a player attacking a player it doesn't run
nothing about it runs
attacked == getPlayerExact(roles.get("blah"))
Also do I have to use a wrapping class or can I extend CraftPlayer or something?
mk
alright i see what roles.get("Hunter") is
one sec
aight
I have this heal command and when I use it, I get healed but there is no message in chat and there is no sound
double maxHealth = player.getAttribute(Attribute.GENERIC_MAX_HEALTH).getDefaultValue();
player.setHealth(maxHealth);
getServer( ).broadcastMessage(ChatColor.GREEN + "You were healed");
player.playSound(player.getLocation(), Sound.ENTITY_ARROW_HIT_PLAYER , 1.0f, 1.0f);
}```
why is that
i put the code to return the value that is in roles.get("Hunter") in the event and its not even sending the message or anything
so its like its not detecting the evebt
did u register the event + annotated it with @EventHandler

might be helpful
can anyone help me?
try w/ player.sendMessage, also do you have sounds enabled on the client?
ok and yes
not in spigot afaik, there's a lib for it and paper has that
Is it common to use a permission as a integer value? say example.test.50? And the number has a different meaning that I parse in my code to determine some functionality for that player. Is that normal?
Myes I've seen that type of design in several plugins
Idk if its concerned as a good practice nor common
hmm ok, got a PR that reimplements something that way and was just checking if thats common
but its definitively an occurrence
I mean I could implement this in a more complicated way through a menu or from the config but I don't think I really do
This seems like a much simpler solution, while also being easier to use by admins that know permissions
yeah
like the design is a bit awkward, but hey it works and have worked for the past years over the course of spigots development
ok so the event is now registering and stuff but as soon it gets called it gives this error: https://www.toptal.com/developers/hastebin/exedulapis.properties
Hastebin is a free web-based pastebin service for storing and sharing text and code snippets with anyone. Get started now.
welp thx
i have no idea what i wants lmaoo
roles.get("thing") returns null
because passing null through Server/Bukkit::getPlayerExact wont work,since it requires an object
hm
it sends fine when i run the start command
odd
its in a public hashmap but the players names are put in there when a command is run, would that be an issue?
I mean easiest way to avoid this could be with a null check
error: invalid target release: 17.0.1
Module Tohka SDK 17 is not compatible with the source version 17.
Upgrade Module SDK in project settings to 17 or higher. Open project settings.
Does someone know why I'm getting this error when building?
Are you in IntelliJ?
each new Redis (Jedis) publish / subscribe Thread should use new Jedis connection?
Yep
JedisPool will handle that for you
but yeah dispatch the subscription on a new thread as iirc it will be blocking until termination
and then ofc try-w-resources JedisPool::getResource
👍 thank you!
Doesn’t really helps
Are you using maven?
If so I had to do a manual install with the latest version because the bundled one was too old for Java 17 support
Yep
and when should I unsubscribe certain channel? In onDisable will be ok, or should I do it in other place?
yes
force disable the subscription
if it doesnt disable in like lets say 30 seconds just interrupt the thread then
how can i find a specif block in a 6 blocks radius
iterate through the volume until you find the wanted block
by iterating i am only able to go at positive , negative x,y and i can't diagnally
List<ServerInfo> servers = ArenaPlugin.getInstance().getFallbackServers();
ServerInfo server = CollectionUtil.pickRandom(ArenaPlugin.getInstance().getFallbackServers());
player.connect(server, (connected, throwable) ->
{
if(!connected)
....
}, ServerConnectEvent.Reason.PLUGIN);
I have a list of given lobby servers. I want to connect the players to a random server of the list. If that fails the server should be removed from the list and then get another random server, until we have tried all servers or the player has successfully connected. How to do so? Because the connect method has an async consumer
@ivory sleet maybe u know?
And when I create subscriber, what will be better way, create only one subscriber and check message, switch / case and do operations, or create separate subscriber for each "action"?
you'd probably want to use a ConcurrentHashMap.newKeySet()
And map it
like map all the failing servers
Ok but I still have no idea how to use it async
CollectionUtil.pickRandom(servers); 🥲
Yes?
like you'd use it synced
store one of those set instances per player
ugh
I'd use a subscriber per feature
but entirely up to you
Ok I will try finding it out then
also might wanna use ByteDataInput/Outputs
i dont know why when i always create something with for loop it always repeats it for twice
and then the first writeVarInt/readVarInt determines the message format type
kinda like how mc operates
conclure can u give me advices
mind sharing the code?
?paste
oh god yeah
perhaps extract that into smaller functions
would be easier to maintain
actually it was way more complicated, i simplified but still like this...
i am unable to find the list of blocks and their data on spigot documentation does anyone have it?
?jd-s
Player ping always 0
actually it only repeats when im looping config variables
lot of bad things in that code aaaaa
Heeeeellllooo ! I've got one little problem, I made a multi-paged GUI, I have all the code nice, and I have juste one question. I use a list, when a player click on next page, i set up a p.closeInventory(); and to open the new page from the List : p.openInventory(inventories.indexOf(??????) + 1); but i don't know what to put ine the ???? a variable ? How may I have the current "List" i use ?
@kindred valley u know World.toString() doesnt return its name
yes
inventories.get(index) and increment the index when clicking on the next button
im looping it with the same variable
Thank ! I'll chek
'there's no such things as goodluck or badluck' is that saying that nothing depends on luck?
u wanna know the index of the inventory in the list?
When I'm using that jedispool should I do it with try-with-resources statement? Like
try (Jedis jedis = jedisPool.getResource()) {
// do operations with jedis resource
}```or can i use normal jedisPool.getResource()... (I saw that code in one project)
EW JEDIS
lettuce cooler
why?
🥗
personal opinion
I have the button Next page and Previous page. In my LIST i have 3 inventory corresponding of the three page, in my condition, I've put this when the condition is true : p.closeInventory(), p.openInventory(inventories.indexOf(????) + 1); and ??? correspond at : how can i get the actual open inventory in the list ?
make an index w-which starts at 1 and increment it when going to te next ppage
@tardy delta is Inventory a singleton
If I get an item from PlayerInteractEvent, can I just do itemStack.setAmount(itemStack.getAmount() - 1); to decrease?
or is there a new instance for each open inventory
lol no that doesnt make sense
Yikes
Don't use try with resources on a connection
thats not what a singleton is
As it will close as soon as the try block closes
mm then what is it
db connection 👈👉
shit wrong
Lettuce auto closes it if I use try with resources
fourteen
@hollow ruinClose kek
answer
?singleton
.
smh
?
yeah?
Probably
public class MyClass {
private static final MyClass instance;
private MyClass() {
instance = this;
}
public static MyClass get() {
return instance == null ? new MyClass() : instance;
}
}
shhh
i know what it is
a singleton is a class which shouldnt be instantiated more than once and has its state static
Not always
you forgot the instance = new MyClass() kek
wait lol
yeah, so I did it in try with resources so as not to do it manually. shouldn't I do that?
yep
actually
mwoa basically they dont allow instantiation but have a static getter method which returns its instance
as when the try() {} stuff ends it will close the connection
not exactly
static getter method part
isnt the thing at all times
you dont need that for it to be a singleton
or just static methods
nah
you dont need that either
Singleton pattern doesnt have anything to do with that
oh yeah but if i want to publish then i can't do it in try () and the connection will close automatically after publishing? (unless I get it wrong)
It's only the restriction of how many times a class can be initialized
As soon as the } is reached it ends
or when a return statement is called
the connection will be closed
if you want that, use it
otherwise... don't
well usually to prevent idiots from calling the constructor more than once and having to throw an exception, it has a static getter method
Not really
youre missing the point if the constructor isnt private
how can i crate a Array of Materials?
if ur gonna do the getInstance thing
if the constructor is private you have a static getter ye
what are we even discussing lol
You know a plugin with free tractor
having a static getter without the class being private makes no sense
i know 🥺
anyways
EnumSet
or a simple array if u want
btw
@tardy delta
is there an inventory object for every player opening the inventory
i think not
no
that looks 'bout right
Material[] matArray = new Material[arraySize]
but
u dont wanna auto close it
after the try method ends
its a connection
no its a connection pool
well tbf idk bout the design of jedis
so might be you're right
tho last time I checked the docs you're supposed to close after whatever you've done, basically lending it back
i just use lettuce so idk too lol
yeah
Bump from a really long time ago lol
well lettuce has become more main stream
is there a tutorial
especially since they added pub sub
what about using a try with resources for a db connection that comes from hikari?
myes
Anyone knows a good way to create fake fps user to a single user? I'm creating a freeze command that should also lag the player's fps
through packets
that doesn't lag the server
send a few thousand packets
which packets tho
idk
what's the most optimal way without causing server to lag
how to set data type of iron door from close to open
already googled it?
I already have a for loop
I just need to find an optimal packet to send to a player
getProxy().getScheduler().runAsync(this, () ->
{
while(true)
{
ArenaManager.updateCache();
playedArenaTable.updateCache();
try
{
Thread.sleep(1000);
}
catch(InterruptedException e)
{
e.printStackTrace();
}
}
});
Is this a good way to create a repeating async task on Bungee?
mmm bump 🍇
no
use a scheduled executor service
?
wheres the break kek ah wait
Example? I have no idea what ur talking about
1sec let me finish the valorant round
Haha ok
Schedules a task to be executed asynchronously after the specified delay is up. The scheduled task will continue running at the specified interval. The interval will not begin to count down until the last task invocation is complete.
For OfflinePlayer.java, namely the method getLastPlayed();
/**
* Gets the last date and time that this player was witnessed on this
* server.
* <p>
* If the player has never played before, this will return 0. Otherwise,
* it will be the amount of milliseconds since midnight, January 1, 1970
* UTC.
*
* @return Date of last log-in for this player, or 0
*/
public long getLastPlayed();```
Where is this data actually stored?
playerdata
anvil files
oh yeah that one is better
tvhee ^
Playerdata in the maps?
Thx
Is there logic present (in spigot) that if you have multiverse or something installed, it will get it from the oldest world?
dont think so
how can i get block state of iron_door
Like getState()?
mate this is one search in google
Door door = (Door) block.getState();
door.setOpen(true);
not sure if you have to do it on both parts
Is there some kind of sync between world, world_nether, or world_the_end that would get the oldest or something? Or is it the last time the player played on that specific map in terms of getLastPlayed()?
ah its deprecated, cast it to Openable instead of Door
are you asking from what world the getLastPlayed is coming from?
Yeah kind of I guess.
yah
thanks
i think just the last world
gotcha
https://pastebin.com/UEPBNwUM it give this error
show me
if(block.getType().name().equalsIgnoreCase("IRON_DOOR")||block.getType().name().equalsIgnoreCase("IRON_TRAPDOOR")){
Openable door = (Openable) block.getState();
door.setOpen(true);
block.setBlockData(door);
}
Hey Guys Can I Set my Custom Zombies For dont burn under the sun. without helmet or something like that
if block.getState instanceof Openable
or smth
never check the name() to compare enums, you can do if getType() == Material.SOMETHING
oh
ye but not in this case
So you don't get errors in your plugin
when it get executed the door does not open
and there is no console error
uhm show code i guess
if(block.getState() instanceof Openable){
Openable door = (Openable) block.getState();
door.setOpen(true);
block.setBlockData(door);
}
dunno how block data works but are you sure you have to set the data?
IIRC, Java 8
update the state
aren't BlockDate and BlockState 2 different things
woops did not mean to reply
try to do block.getBlockData() instance of Openable
I am trying to set the state of block to be opend
block date?
oops
yah i accidently wrote setblockdata , but i am unable to find any method which changes the state
lets go on date with a block
looking at the forums, people are checking what I said
which block would you like @delicate lynx
you have everything else correct but you are checking the wrong instanceof
there are too many blocks for me to pick :/ I don't have a favorite
Is there any way to set the joinlocation BEFORE the player has fully logged in?
did you try?
That will just crash the server
heh
In PlayerLoginEvent
blockdata also does not work bruhhh
I get Minecraft world errors
delay it a few ticks?
No but I want it before they even see it
Is there a way to prevent mobs from entering a specific region?
I just tried this code, it works
Block block = event.getBlock();
if (block.getBlockData() instanceof Openable) {
Openable door = (Openable) block.getBlockData();
door.setOpen(true);
block.setBlockData(door);
}
you have to check the blockdata, not the state
you were doing Openable door = (Openable) block.getBlockState();
what is the name of anvil sound effect
which one
anvil
not really possible as the play doesnt have a Physical Location until PlayerJoinEvent
PrepareAnvilEvent
just
letting you know now tho
that event sucks to work with
there are a few anvil sound effects
event?
placing, breaking, etc
what is default volume level
1.0f normally
I guess that event will be enough. Hopefully...
#setSpawnLocation maybe
Exactly my plan 🙂
thanks 🙂
I have a really hard time with:
i do as well
I want to remove in total of 4 diamonds that can be in any slot, for example if the inventory is the following: 64 iron, 10 iron, 2 iron, 7 iron || in the total I want it to look like that **60 iron**, 10 iron, 2 iron, 7 iron
lol
got ninjad
that should remove in total of 4 diamonds?
if I make the item stack like that: new ItemStack(Material.DIAMOND, 4);
it works!
thanks @crisp steeple @tardy delta
gg
use PlayerJoinEvent
and teleport them
Why?
How do I set lapis in an enchantment table?
login event is before join event as far as i know
actually
use PlayerSpawnLocationEvent
PlayerCopeEvent
Cannot resolve method 'getDescription' in 'PlayerJoinEvent' how do I fix this?
that isn't a method
uh
It isn't a method
show us code and fell us what you're trying to accomplish
smh
ok
PlayerCringeEvent
da moment when im trying to do a conversation
so, I'm trying to make an update checker and it works just fine when in the main file, so I tried to make it send the message to an op once they join the server and this is what I did:
you pass it your plugin instance
wot
plugin.getDescription()
you’re using a consumer
consumer doesn’t have a getDescription method
bruh u just copy pasted it
yep he copy pasted
Hey! I'm trying to work with jedis publish / subscribe statements and I made a class on server and proxy that pull the server info (name) from the proxy. Can someone take a look, and tell me what can I write better?
Class on the server -> https://paste.gg/p/anonymous/76c1d4b5b5984e5c8a33687fae0d7b80
Class on the proxy -> https://paste.gg/p/anonymous/9c103735ce1d4591b1325ef24999b354
@pastel relic listen
you’re using “this” in a lambda
u copy pasted it from some website
but in that website
they did it in their main class
rn ur not
ur using it in another class, not the one tht extends JavaPlugin
?learnjava moment
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.
sorry, followed a course im new to this
I think I got it, tysm
ok, nvm I didn't
You can't have two classes that extends JavaPlugin
ik that
You need to dependency inject your main class into that listener class
or a static getter
the main class being the one that extends JavaPlugin
I will disown you
and, how do that?
You dont own me
I do own you
jesus why do ya'll argue in the wrong channel
We arent obliged to help you
dependency injection my beloved ❤️
^
controversial opinion: static getter is ok for javaplugin if you aren’t planning on expanding it much
someone link a tutorial on dependency injection
?di
Guide to dependency injection: https://www.spigotmc.org/wiki/using-dependency-injection/
controversial opinion: perish
ok 👍
<3 don't really
awesome
its always ok
lol di is much cleaner
It's a singleton, and a static getter is the primary way to reach out singletons
Hey so i started creating configs with the method that Y2K_ showed me but I’m bit confused, not setting it up i did as he said but more to I’m not sure how to use the config now to like add lets say messages from customconfig like game mode.yml and i want to get the string of path creative: “bla bla bla” how would i implement it. https://paste.md-5.net/makedanabi.java and here is for the main class what i had to do https://www.toptal.com/developers/hastebin/ejesoviyow.kotlin
Hastebin is a free web-based pastebin service for storing and sharing text and code snippets with anyone. Get started now.
yes
the larger your project
the more u get annoyed by it
smh
making a variable and a constructor and a parameter is too much work for me
not really? I just make templates for the classes I use the most
not reallt
you had to go through the efforts to make a template
Bout to start doing that
I didn't have to I wanted to
di is awesome, but not in this specific case, it's not the best option at least
that contradicts ur statement
u said
"for java plugin"
a library has no class that extends jp
you would make it into a different module then
point still stands
unless it’s a library that also functions as a plugin
Any of u guys know what i can do ? I stated my problem here ( also I’m new to this so I’m a bit confused to what i should do when it comes to config files and how to use them properly )
that's an api then
what
^
thats wrong terms
that aint a library anymore
its an api
ur not making any sense
you can have a plugin
that does things to a server
and you can import that same jar
and use it in your plugin
thats an api then
you hooked into the plugin
did u just change ur statement
what u were saying minutes ago isnt what ur saying now
lol
what are you on about
Agreed
proving you wrong
this is some major spigotmc drama
to who
??
this isnt drama tho
its a simple argument
i’m joking
lol
2Hex made a good point
i don’t see what he means
if i have a plugin
that i can use in my project
i would not call that an api
if you hook into a plugin its an api
a library uses your own plugin, an api only gets hooked into, it doesnt use ur plugin
Basically you changed your statement from talking about library to it being a api which makes it a api
yes ik that
dont look at it from a spigot angle
i understand that my point originally didn’t really matter since a library never has javaplugin
look at it as java
then you proved yourself wrong
about?
Exactly
i’m not talking about a library anymore
isnt api just something you use in your plugin, dependency is a plugin that you use in your plugin
an api and a library are both dependencies
library ? i dunno
Bruh wasn’t we just talking about how you are confusing library with an api when thinking about it in a java standpoint what u are considering a library is an api
oh right ok
i wasn’t “confusing” a library with api
deotime whats your point now
it just was pretty obvious you would use dp injection in a library so it didn’t really matter
my point now is that i believe a importing a standalone plugin that acts on a server into your project does not count as an api
it is an api
i do not agree
Youre hooking into it
an api would be something that uses that plugin and provides it in a user friendly way
Wait deotime why do you think its not an api
and using its methods
above
its an api but not a proper one
but it’s not
Then what is it
api - application programming interface
an api is an application programming interface
if i import a jar into my java project
what is it
i know what an api is, thank you thats not what i asked
a library?
Wrong
not wrong
Oh dear god
a dependency
Yep
i thought we weren’t using spigot terms 🤨
Yes?
if you imported a plain jar
into a java project
that would be more accurately a dependency or library
we never used any spigot terms yet
Opps wrong chat sorry if i say random things ignore i got like 4 different arguments that I’m monitoring rn
you’re giving a spigot java project as an example
an api is somewhat of a middleman
between you and the program you are connecting to
a library would be directly importing the program
Dude
it isnt a library
an api
is a hook to a program running
that just isn’t true
its not
Mm? then what is it
Hey! I'm trying to work with jedis publish / subscribe statements and I made a class on server and proxy that pull the server info (name) from the proxy. Can someone take a look, and tell me what can I write better?
Class on the server -> https://paste.gg/p/anonymous/e86d07436a084078b03eef9ca8c3dcf4
Class on the proxy -> https://paste.gg/p/anonymous/8fe6667e56fd4efb9b45796258b0a7a9
An API is simply how you interact with another resource