#help-development
1 messages · Page 1444 of 1
ik
Can a falling Block have a custom name
Anyone know how to get the most up to date placeholder values from PlaceholderAPI?
Or find out when they change?
Elaborate
I have java public static String lpWrap(Player p, String s) { return PlaceholderAPI.setPlaceholders( p, "%luckperms_prefix%" + s + "%luckperms_suffix%" ).replaceAll("&", "§"); }
When I give out a role, they have to disconnect/rejoin
Otherwise they get old chat colour
anything can have a custom name but i doubt falling blocks render it
@EventHandler(priority = EventPriority.NORMAL)
public void onChat(AsyncChatEvent e) {
if(e.isCancelled()) return;
e.formatter(new ChatFormatter() {
@Override
public @NotNull Component chat(@NotNull Component displayName, @NotNull Component message) {
return displayName.append(Component.text(":").append(message));
}
});
}
My event listener
Pixel well you could hook into LP API listening for direct changes
Format is format tho
oh
Yeah well depends on how exactly you’re doing it but most likely
I only set displayname on join
Okay?
Yeah I think that's it ^^
that means that you only grab the placeholderapi replacements on join
it's not working
define not working
🥲
what
what what
what what what
what do you mean not working
explain what it is that you expect to occur
and explain what is actually taking place
sounds nice
idk
that doesn't help me help you
what does the flag mean
what
Its obvious, he wants to make a thing
https://www.spigotmc.org/wiki/creating-a-gui-inventory/ just gonna drop this
The home of Spigot a high performance, no lag customized CraftBukkit Minecraft server API, and BungeeCord, the cloud server proxy.
kek
very polite of you fish guy
plz die
ty
good staff
nvm
you need to be able to say something other than "idk" when I ask what's wrong
is the gui not opening? is the item not doing anything when you click it? is there an exception when you click it? does it even load? does it behave somehow unexpectedly otherwise
i'm willing to put the giblets aside but you'll have to be cooperative if you want help with your issue
you should have seen what he said
"I want to make a thing"
STOP
crazy fish
fish, but crazy
STOP RN
why
sir this is help development 😉
The problem is that the creative actions are completely client side.
So the client tells the server what item the user created. And the client thinks it actually has that lore.
So modifying item packets does not modify the item directly. But if the client is in creative he thinks
the item has those modifications and therefore tells the server the state which is accepted because item
creation is partly client authoritative in creative mode.
i have no idea what we're talking about but creative is batshit broken and you should give up with whatever you're trying to do if it involves creative mode
I kind of didnt care because the plugin was only supposed to work in survival mode anyways.
One could possibly track incoming packets and mark the modified items somehow. So it might be possible.
Yeah the game trusts the client a ton in creative
Which is annoying
I could use the PDC to store the lines that need to be removed when the item is updated, but that would get pretty bulky
sir this is hbnerdtbguerngiundsuisubgurbdkjnsuidbg
Create a database that tracks all items and query the table each time a packet containing items goes out or in.
But make sure that the DB doesnt run on the same machine. Get a cheap one in indonesia.
I might just do the PDC route
whats pdc
It's only for tools, weapons, and armor, which players generally don't have a ton of
That might be just fine.
PersistentDataContainer
I wish I could somehow add a namespaced key to a lore line
you kind of can
how it was done back in the day is you converted your key or data or whatever into hex and then used colorcodes to write it into the lore
since the client doesn't render colorcodes, it's basically invisible
You could probably improve that further with hex color codes
or since lores are components now you could probably hide arbitrary data in like click-event value or something
I could register the custom enchantments as real enchantments so they display automatically, then I only need to worry about the bottom lines
does the client even render custom enchantments properly
i remember it being an issue before
I dont think so
it like needs translation keys or something to display them and that blows up
For me it was an issue at least
Ah, darn
Yeah you still need to add lore
but like yeah you can store unlimited arbitrary data in the lore if the pdc itself is an issue for some reason
probably not gonna get you far with creative shenanigans though
what's the actual issue you're trying to solve
Working with creative is a mess
i can't see replies so idfk what we're talking about
I will probably just store an array of strings in the PDC that need to be removed when the item is updated
Side note, why don't we have a PersistantDataType.STRING_ARRAY yet
do we even have UUID yet
no
we will never have anything
But the example on the docs shows a uuid one
I have a ton of custom pdc types in my library including stuff like <byte[], ItemStack[]> or event <byte[], Inventory> ...
And UUID ofc
What about String[] :p
store pdc in pdc when
PDC <String, String[]> should be quite easy to implement
I assume I could just String.join the array with some kind of delimiter
implementing them is trivial
PersistentDataType.TAG_CONTAINER
Ok hand me the library and I won’t hurt you
i just don't have the effort to cuntpaste them into my library every time I need one
so i never end up adding them into the library
so i just end up cuntpasting them into the project itself
and have a million duplicate impls
tf is "cuntpasting" XD
This is why I just shade my library
like yeah I shade it too
but I still need to open the project to include the new impl
and then build
and install
and then open the original project back up
and update maven indices
and it's just ugh on a low end machine
Actually, I could probably serialize a List<String> to a byte[] easily enough
Or set<String>
List<String>
Hm. Generic types are tricky
generic serializer for T,C extends Collection<T> and then just cast and shit
basically all collections can be serialized and deserialized with iterators so the underlying impl remains the same
I did this hacky stuff
public class StringList extends ArrayList<String> implements Serializable {
public StringList() {
super();
}
public StringList(final Collection<String> collection) {
super(collection);
}
}
public class PDCTypeStringList implements PersistentDataType<byte[], StringList> {
@Override
public @NotNull Class<byte[]> getPrimitiveType() {
return byte[].class;
}
@Override
public @NotNull Class<StringList> getComplexType() {
return StringList.class;
}
@Override
public byte @NotNull [] toPrimitive(@NotNull final StringList complex, @NotNull final PersistentDataAdapterContext context) {
final ByteArrayOutputStream bos = new ByteArrayOutputStream();
try (final ObjectOutputStream oos = new ObjectOutputStream(bos)) {
oos.writeObject(complex);
oos.flush();
} catch (final IOException e) {
e.printStackTrace();
}
return bos.toByteArray();
}
@NotNull
@Override
public StringList fromPrimitive(final byte @NotNull [] primitive, @NotNull final PersistentDataAdapterContext context) {
final ByteArrayInputStream byteArrayInputStream = new ByteArrayInputStream(primitive);
StringList strings = new StringList();
try (final ObjectInputStream objectInputStream = new ObjectInputStream(byteArrayInputStream)) {
final Object obj = objectInputStream.readObject();
strings = (StringList) obj;
} catch (final EOFException ex) {
System.out.println("End of file reached.");
} catch (final ClassNotFoundException | IOException ex) {
ex.printStackTrace();
}
return strings;
}
}
just need to have a supplier for the collection type as a parameter
i also did some hacky stuff
public Failure getFailure() {
return this;
}```
<T,C extends Collection<T>> PersistentDataType<C,byte[]> giveMeType(@NotNull Supplier<C> ctor, @NotNull Function<T,byte[]> elementSerializer)
Error: cannot use 'this' in a static context
then just Util.getMeType(() -> new HashSet<>(), String::getBytes(), String::new)
PDC hacker :(
shot
well thats why i suck at java
¯_(ツ)_/¯
probably also why i go on github to copy code
Eh... what
?
Turns out spigot has an outdated version of apache commons
imagine that
it's almost as if literally fucking everything spigot includes or depends on is half a decade out of date
I’m assuming that a lot of stuff will be updated when 1.17 comes out cause Java 16 and all
they're probably going to use a bytecode hack to rewrite plugins from java 8 to java 16 on the fly
can't have those fucking 1.8 plugins breaking can we
Lmao
I switched to the code 7smite7 posted instead of SerializationUtils and it works fine
well, i guess java is pretty forward compatible to begin with
I got the weird blocks that formed fixed by using pdcs @wraith rapids
Which I was pretty happy about
so you would only need to replace reflective hacks with methodhandles hacks or direct bytecode hacks
Ehh, idk. I feel like they are just gonna do something stupid
Im trying to setup a scoreboard on bungeecord
keep getting NoSuchMethodError : net.md_5.bungee.protocol.packet.ScoreboardObjective.setType(Ljava/lang/String;)V
how do I add on essentials a new sell?
the method you're trying to call doesn't exist
how do I add on essentials a new sell?
what is a new sell
and unless it's development related, you can piss off into #server-help
is using a player as a key for a hashmap troublesome? I have a hashmap that appears to have duplicate keys where the keys are players. when I forEach the HashMap and print the UUID of the players and the points I have a duplicate entry:
e69d7cd6-5355-49ad-a4a5-a4219a075de4 -> 3
e69d7cd6-5355-49ad-a4a5-a4219a075de4 -> 4
are player objects not reliable as keys should I just use UUIDs?
If this is server related go to #help-server, this is for developement
ok
you should discard any players upon logout
each time the player logs out and logs back in, a new player object is created for them
this new player object is not equal to the old player object
that's the issue thank you
meaning that both the old and new player objects can exist as keys at the same time
yeah I see they aren't the same
use UUID keyed maps if you want to persist data past login
it's fine all the data gets reloaded upon logging back in and saved after log out I just have to make sure to delete it
if you store Player anywhere, you should always be sure to clean out those player objects the moment the player logs out
How can I save a shulkers inventory?
BlockStateMeta
try harder
okey..
private void saveShulker(ItemStack item, Inventory shulkerInv) {
ItemMeta itemMeta = item.getItemMeta();
BlockState blockState = ((BlockStateMeta) itemMeta).getBlockState();
((ShulkerBox) blockState).getInventory().setStorageContents(shulkerInv.getStorageContents());
((BlockStateMeta) itemMeta).setBlockState(blockState);
item.setItemMeta(itemMeta);
}```
so you used storagecontents()
I'm trying to write a very simple input - output message, but I got an error. Can anybody help me?
can you send it with line numbers
I also don't understand why getLeaveMessage() will never be used 🤔
you should add
also config.yml:
giris-mesaji: '§7Giriş yaptı'
cikis-mesaji: '§7Çıkış yaptı'
implements Listener to your main public final class Main extends JavaPlugin {
I am trying to find the error
but i have already a listener?
where
in listener class
okey xD
what's the name of the sort which maps values to the index of new array, and then iterates that array and checks if that array index is not 0
it basically utilises two loops. One iterates the old array and transforms value to the new array's index and sets that index to the iterated value, and the next for loop iterates that new array with defined indexes
or is it something i myself invented lol
it seems memory hungry for missing big integers, since the array size as big as the biggest value(edited)
but its dirt cheap for a cpu
all it does it sets the value to the new index
it seems very efficient
Integer.MAX_VALUE wants to know your location
ideal for a dense index yes
sparse indices not so much
a tool for its job
as for what it's called, dunno
is there a way to access the bungeecord server name from a spigot plugin
this.getServer().getMessenger().registerOutgoingPluginChannel(this,"bungeeName");
i think he wants the name
int array[4] = {1, 8, 9 ,5}
int newArray[9];
for (int i = 0; i < 4; i++) {
newArray[array[i]-1] = array[i];
}
would result in array:
[1, 0, 0, 0, 0, 5, 0, 8, 9]
by iterating that new array you check if the value is 0 you reorder it with some magic or create new array and voila, sorted array. this is C btw
Follow markup conventions
@wraith rapids can u there ?^^
`Test`
It doesnt work on android :angry:
```java
code
```
Tagging someone on android is also problematic
lol
I'm sorry, still a little confused
I just want to put the server name on the scoreboard
Yes
I do
I want to know how I can access the name of the bungeecord server from a spigot plugin
or if it isnt possible
There is no such thing as impossible in Java
There's just such a thing as bad googlers xD
I haven't been able to figure it out, does someone know how to?
Something could be impossible if it's not ya know, possible to actually do @gaunt eagle
use plugin messaging channels or sockets or whatever
came for plugin help, ended up getting philosophy lessons :sad:
ow nice word, I kept it ^^
my Lord.. Would you like to take a look at my problem ^^
in there, my little dirty error..
The home of Spigot a high performance, no lag customized CraftBukkit Minecraft server API, and BungeeCord, the cloud server proxy.
thank you
I discovered that the problem is with getJoin and getLEave messages but I don't understand exactly what it is
So I use SimpleScore Plugin but On Luck Perm i need to use & and on the SimpleScore u cant use & so what do I do?
not that much
if the author was so lazy to simply add a color translation its prop not worth
using it
So what plugin do i use
tbh tehre should be plenty of scoreboard plugins
look over them and pick what fits
ur best
Ok
So
I have a plugin that deletes the item in your inventory if it is in the config
it works fine
but there are some block, that it just dont worky
like command_block: 1
or other blocks like that such as spawner, jigsaw, repeating_command_block, etc
show code
if (type != Material.COMMAND_BLOCK) <-- remove this part
ok one sec
what am i looking at
a lot
leme explain it
its looping through the items in invenbtory
then looping through keys
and seeing if they match
the key is == to command_block
why are you cloning a new itemstack with the item's type and then checking issimilar
to check if it has NBT
hasItemMeta
that works better
thank you
im planning on going through and making it all better
just need to get bugs sorted out first
are you on 1.8 or something
1.16
use the item PDC instead of nbt editor
Well does it really matter if i use that or the other one?
basically a Map but with one or two extra doodads
I mean ill look into using the normal one, but is there a difference?
using nbteditor means that your build is version specific and probably will explode sooner or later when item related nms is changed
pdc is part of the api and will be supported by bukkit until like 2300
because it is fucking illegal for the api to drop support for literally anything
i have used it in older versions, but yea ill use PDC
But any reason why it doesnt detect command_block?
not sure
throw some debug at it i guess
i know it wasnt working before
but i tried a fix
but i was opped
leme deop and try it
it works
iterating over the entire config section for every item in the player's inventory is pretty inefficient
consider precomputing a Set of Materials and checking Set::contains
What should i do, save a list of them and then itterate throuh the list?
no, don't iterate
a map
having to iterate through things to find something is a sign that you're doing somethin wrong
everything should be keyed such that you can easily query it without having to iterate over a potentially unbounded number of elements
f.e a Map with the Material as key and Integer as value to represent the min number of items or whatever
instead of iterating over every single element in a list and checking every single one if it matches
you'd just do map.get
which is a single operation
and doesn't become slower as the map gets bigger
containsKey but yeah
though you can just do map.get and then check if it returns null
Ill probably be back here if i cant figure out maps lol
as a sort of combined contains&get
Yea
if the map doesn't have a value for that key, it returns null
if it does, it returns the value
ok
if(plr.getGameMode().equals(GameMode.CREATIVE))return;
this checks for creative correct?
yes but use == to compare enum constants
.equals and == on an enum make no difference
it'll never require debugging since that wont be a root cause
🤔
== is better than .equals though :p
One method call less :>
Objects::equals 
well I never said that equals isnt trash for enum or constant comparisons
looks ugly and is ugly kekw
just saying it wouldnt require any debugging
It’s null safe and removes awkwardness so yeah I agree with u
Hilarious
can anyone link any good maven or dependency tutorials? I'm completely lost right now trying to port my project over to work with maven
I can walk you through the basics if you'd like
I'd appreciate that
I'm using IntelliJ and added the maven framework
my pom.xml looks like so:
<?xml version="1.0" encoding="UTF-8"?>
<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>me.imp</groupId>
<artifactId>MapPlugin</artifactId>
<version>1.0-SNAPSHOT</version>
<repositories>
<!-- This adds the Spigot Maven repository to the build -->
<repository>
<id>spigot-repo</id>
<url>https://hub.spigotmc.org/nexus/content/repositories/snapshots/</url>
</repository>
</repositories>
<dependencies>
<!--This adds the Spigot API artifact to the build -->
<dependency>
<groupId>org.spigotmc</groupId>
<artifactId>spigot</artifactId>
<version>1.16.5-R0.1-SNAPSHOT</version>
<scope>provided</scope>
</dependency>
</dependencies>
</project>
when I package the project it generates MapPlugin-1.0-SNAPSHOT.jar so I place that in my plugin folder however it fails to load without any errors
it was working perfectly fine before I tried adding maven
ok nvm now its working i literally didnt change anything
alright so now I need help actually adding a dependency
I'm attempting to use https://github.com/IPVP-MC/canvas
where should I be cloning the repository to?
have you decompiled it and ensured it's all there
the plugin is working now
not sure why it went from not working to working suddenly I didn't do anything just repackaged it
anyways could you help me out with adding a dependency ?
yeah sure, what did you want to add?
so it says to clone the git repository to my local maven repo
I don't know where to find it though
yeah ill just look for another one I can't figure out how to install this
so let's say I wanted to use this api https://github.com/MinusKube/SmartInvs
the dependency is like so:
<dependency>
<groupId>fr.minuskube.inv</groupId>
<artifactId>smart-invs</artifactId>
<version>1.2.7</version>
</dependency>
wait nvm its not red anymore
so I added the dependency above to my pom.xml
but when I packaged and attempted to start up my server
Error occurred while enabling ImpsPlugin v1.0.0 (Is it up to date?) java.lang.NoClassDefFoundError: fr/minuskube/inv/content/InventoryProvider
what am I missing to make this dependency work?
I want it to be included within the plugin jar is that not the purpose of maven or am I completely off?
I have a custom event thats async and is called async but also another piece of code that is sync and wants to call the event but it says
Could not pass event BlockPlaceEvent to FlappyAnticheat v1.6.0-BETA
java.lang.IllegalStateException: FlagEvent may only be triggered asynchronously.
I have tried
Bukkit.getScheduler().runTaskAsynchronously(FlappyAnticheat.getInstance(), () -> Bukkit.getPluginManager().callEvent(flagEvent));
but it doesnt let me cancel the event from an outside plugin
well since it's async you wont get a response to whether it's cancelled or not until it's been called
so based on what outside plugins do to the event, you can handle all that within the runTaskAsynchronously
i just ran the function that has the event call in it async instead of the actual event call
cause you gotta realize that even though there may be code after runTaskAsynchronously, it'll be run before the code within runTaskAsynchronously
Where can I find the documentation?
share your code
I don't have any code, I was just trying to find the documentation but I found it
Hi, how can I know why my spigot plugin was removed?
Could anyone tell me why I'm getting a method not found error on the following code:
Error:
java.lang.NoSuchMethodError: me.ryanhamshire.GriefPrevention.Claim.getOwnerID()Ljava/util/UUID;
Code:
public boolean isClaimed(Claim c, UUID uuid){
return c.getOwnerID().equals(uuid);
}```
GPP has https://i.imgur.com/uYfCNW2.png in the class im referencing
Do you have GP running
Yes
And depend setup in your plugin.yml
Yeah
for c style programming, i actually like the way that function looks
/**
* Execute the trial code.
*/
void exec()
{
// TODO insert execution code
}
Nutty
...
player.getInventory().getItemInHand().setAmount(wand.getAmount()-1);
player.updateInventory();
...
Anyone know why this wouldn't work?
I have created a itemstack that is why wand . is where it is
fix was player.getInventory().removeItem(wand);. Anyone want to know
better off getting the item itself and incrementing, then setting
bro
you are the second person today to use player.updateInventory()
that is a method only used when the inventory desyncs
which it shouldnt in this case
It is barely acceptable in C#. No.
It is a literal waste of space
It’s called allman but ye it’s a waste of space totally
e.setFormat(msgHandler.color(prefix + p.getDisplayName() + "&f &8» &7" + e.getMessage()));```
https://gyazo.com/89c78890af452b3ae9e2760183cc7096
Why is it adding this weird character
I'm using IntelliJ for the first time in a while
make sure your source is utf-8
yoooo its md_5 thats crazy
love ur work
my first ever coding project was a Bukkit plugin about 10 years ago, I'm now in University studying a major in Software Engineering. Thanks for your work <3
Hello here I'm again
I was trying to make a container lock system that stores hashsets with the uuid of the owner inside the persistant data container of the block. How can i do this exact? Please give me an example or something this is the first time I do this
store the UUID with the PDC
looks like the UUID object isn't supported
so you'd have to cast it to a string
yea
4 longs
or that
or follow the PDC tutorial/example and it shows you how to store a UUID in the PDC
^
use VPN/tor
then don;t bother attempting to write code, without access to the javadocs
uhh its study hour
Get back to your lessons and learn all that crap you'll never need once you graduate.
He does Spigot, not Bukkit dude
I mean like
md_5 used to be a Bukkit team member
they're not mutually exclusive
bOTh of YoU ArE CoRrEcT
Thanks you 🙂 But errors :(public void gogo() { file = new File(Bukkit.getPluginManager().getPlugin("Citizens").getDataFolder() + "saves.yml"); CitizensFile = YamlConfiguration.loadConfiguration(file); CitizensFile.getConfigurationSection("npc").getKeys(false).forEach(Bukkit::broadcastMessage); } ->
that should be getDataFolder(), not +
You should not be accessing another plugins data files directly, but also you are missing a file seperator
and what's line 47 of the NPC.java file?
ya, I already tried. with file = new File(Bukkit.getPluginManager().getPlugin("Citizens").getDataFolder(), "saves.yml"); and error 😦
and what's line 47 of the NPC.java file?
CitizensFile.getConfigurationSection("npc").getKeys(false).forEach(Bukkit::broadcastMessage);
so either CitizensFile or the npc config section is null/empty
hmm
but it's not empty 🙂
OH!
wait
it works nowwwwwww
I guess i was typed miss
Ty
Why are you not using teh Citizens API?
why would you use the citizens api 🤮
cuz I want use my plugin 🙂
Ok, a more direct question. Why are you directly accessing the datafiles of Citizens instead of obtaining data via its API?
cuz i want move my npc data from citizens/saves.yml to my config 🙂
Why do you need to read it from their data files? Surely you know how you created your NPC's so you already have the data
I'll give up asking
I only ask because if there is a way to get the data you want via the API you should use it
directly accessing another plugins data files can have unpredictable results.
Hey there! I just wanted to ask if there's a way to check if a player is near an entity or location.
There is
compare their location and distance
Entity#getLocation and Location#distanceSquared(Location)
Okay
thank you
@EventHandler
public void onMove(PlayerMoveEvent e) {
Player player = e.getPlayer();
int radius = 2;
World lobby = Bukkit.getWorld("lobby");
Location BoostLoc = new Location(lobby, -236, 9, 341);
if(BoostLoc.distanceSquared(player.getLocation()) == (radius^2) || BoostLoc.distanceSquared(player.getLocation()) > (radius^2)) {
Vector v = player.getLocation().getDirection().multiply(-1.5D).setY(1.0D);
player.setVelocity(v);
}
}```
this isn't working
it's boosting the whole time
not only at the location
https://gyazo.com/71eda669bdbae3586437412bb74da9dc
I'm trying to use the >> character in my chat format but it's doing that. My file is UTF-8
nvm fixed it
btw radius^2 is xor with 0x10
squaring in java:
x * x
or
Math.pow(x, 2)
hey im making an AntiSpam Plugin and i want it to make it that one someone spams it kicks them but not a normal a kick a plugin kick iwant this line to run the command /mute (player) 1h
SpamDetector.getInstance().getCooldown().remove(player);
thats the part of the codfe i want to change
public void muteThroughCommand(Player player) {
Bukkit.dispatchCommand(Bukkit.getConsoleSender(), "mute " + player.getName());
}
it can't be like that
@Override
public void run() {
if (type == SpamDetector.Type.DELAY) {
SpamDetector.getInstance().getCooldown().remove(player);
} else if (type == SpamDetector.Type.REPEAT) {
SpamDetector.getInstance().getLastMessage().remove(player);
}
}
}
thats the complete code
This is clearly someone elses plugin you are modifying. You need to learn Java better before trying to modify a plugin without adequate knowledge.
I dont see the problem...
You can use the method i provided in your code just fine.
yea but how do i put it in my code in a way to get no errors
and the command isnt just /mute player
its /mute player 1h for example
Then expand the method with another String which defines the duration.
Then you can just call that method with the proper parameters.
Pretty basic Java
my brain is on an overload
Seems asleep to me
hello
Last spoon:
public void muteThroughCommand(final Player player, final String duration) {
final String playerName = player.getName();
final String command = "mute " + playerName + " " + duration;
final ConsoleCommandSender commandSender = Bukkit.getConsoleSender();
Bukkit.dispatchCommand(commandSender, command);
}
If you cant use this then you should probably refresh your basics.
god dang it bro I CAN OPEN ANOTHER PUBLIC VOID ITS ALREADY IN ONE
Learn Java and no need to shout
This is a help server for plugin developers. But there you go:
thx
Seems like you should really go back and freshen your understanding of methods and scopes.
This is not an attack. It will help you to not get stuck on those banalities in the future.
Bukkit.getScheduler().runTaskAsynchronously(AntiSpam.getInstance(), new MessageCooldown(Type.DELAY, player), AntiSpamConfig.getInstance().getDelay() * 20);
Ive got everything imported and the getDelay is imported to and i get an error
public int getDelay() { return delay; }
this is it
any1?
Whats the error?
Also dont use a scheduler for a message cooldown.
Just use a timestamp on the last message and when the next message occurs, calculate the difference between the current and the last message.
its eazier for me
Using a timestamp is objectively more trivial, performant and easy but ok.
What exactly is your error?
i can't post screenshots here
"Cannot resolve method 'runTaskAsynchronously(me.bender.bender.AntiSpam, me.bender.bender.MessageCooldown, int)"
Lol
🥵
its runTaskTimerAsynchronously
Use the method runTaskTimerAsynchronously instead of runTaskAsynchronously
k
👚
now it showes me that :
On the runTaskTimerAsynchronously on the little () i get a red line and at the end ) i get a red line
Btw how does your MessageCooldown class look like?
Because im almost certain that your plugin will crash because of concurrent modification from two threads.
Btw how does your MessageCooldown class look like?
name: BenderILAntiSpam author: bender version: 1.0 main: me.bender.BenderAntiSpam.AntiSpam permissions: antispam.*: description: give access to spam and everything about this plugin children: antispam.ignoreDelay: true antispam.ignoreRepeat: true antispam.ignoreDelay: description: give access to spam without delay poggers default: op antispam.ignoreRepeat: description: give access to repeat message Poggers default: op
this is my path.yml
any1 know whats the problem? it dosen't show up when i hit /pl
wdym the name of it is plugin.yml
.
🤦
Then make sure it's in the jar
Your plugin.yml needs to be inside the plugin jar
Why is it in src
Put it in resources
Actually you might not be using maven
?
Either way when you export the jar it needs to include that file
so do i need to do it
Well that's up to you
As long as the file is in the jar it doesn't matter where it is in the project
Because you haven't included the plugin.yml in the jar yet
k
And click the plus icon and add the file
on artifacts?
Yes
sent it
@sage swift
I used your code like this
but it isnt working I mean the code is working but it didnt save shulker inventory
whats wrong

- No single letter variables. e -> event
- Formatting -> Your brackets are off. Eclipse auto formatting is
Ctrl + Shift + F - Compare enums with
==soevent.getClick() == ClickType.LEFT - Dont stack your if cases like that. Use a early return pattern. Example:
if(event.getClick() != ClickType.LEFT) {
return;
}
- Dont reuse getters or other methods. Call the method once, create a variable and use it from then on instead of chaining method calls.
if(e.getCurrentItem() != null && e.getCurrentItem().hasItemMeta()) {
to
ItemStack box = event.getCurrentItem();
if(box == null || !box.hasItemMeta()) {
return;
}
...
So you want to be able to open a shulker from your hand, right?
no player I want to open shulker from my inventory
It is working I can open the shulker from my inventory
but when I try to put smth on this inventory it wont save
Because it is a lot nicer to read and debug:
@EventHandler
public void onInventoryClick(final InventoryClickEvent event) {
if (event.getClick() != ClickType.LEFT) {
return;
}
final ItemStack box = event.getCurrentItem();
if (box == null || !box.hasItemMeta()) {
return;
}
final ItemMeta boxMeta = box.getItemMeta();
if (!(boxMeta instanceof BlockStateMeta)) {
return;
}
final BlockState boxState = ((BlockStateMeta) box).getBlockState();
if (!(boxState instanceof ShulkerBox)) {
return;
}
final ShulkerBox shulker = (ShulkerBox) boxState;
final Inventory inv = shulker.getInventory();
event.getWhoClicked().openInventory(inv);
}
I just updated a plugin to gradle 7 but I am getting Entry config.yml is a duplicate but no duplicate handling blah blah when building even though there is only one config.yml, any idea how to fix?
Okey I see
Yes because you are not opening the shulkers inventory but only a copy of it. So in your case you need to track the inventory and listen for the InventoryCloseEvent.
But look at the last lines of my code and see if that works.
final BlockState boxState = ((BlockStateMeta) box).getBlockState();
to
final BlockState boxState = ((BlockStateMeta) boxMeta).getBlockState();
Ok two problems here:
- The shulker doesnt open if it has no items in it.
- The items are still not saved.
I think you need to implement a InventoryClose listener anyways...
I adjust some of your codes to my code
expected <block end>, but found '<scalar>' in 'string', line 5, column 47: ... &2[BenderIL] &cPlease slow down";
any1 know why does it happend/
Because the parser expected <block end>, but found '<scalar>' in 'string', line 5, column 47
wich class?
Config
ill guess config
I dont know. You tell me lol. Looks like a yaml error
`#PREFIX
prefix: "&2[BenderIL]&9"
#message when the message is blocked
spamMessage: "&2[BenderIL] &cPlease slow down";
#Message Delay In Seconds:
delay: = 3
#message when a message is blocked cuz repeated
repeatMessage: "&2[BenderIL] &cDo not repeat the same message!"
#delay when the player is able to send the same message again (in seconds)
repeatDelay: 13`
thats my config
what should be the problem here?
Remove ;
^
i dont like it, it just looks good in discord
does anyone know how to make a player control an entity
define control
drive the entity idk
like a horse, but entities that I can't, like a spider
Indeed
Hi, due to paper#678 (upstream) a plugin API doesn't seems to work anymore, i think because a change on PluginClassLoader, it need to be reported on spigot jira?
Paper#677 and lower not accourd this error on that plugin
enyone know like a website that will help me configure plugins
config.yml
ty
paper errors are not to be reported on spigot jira
^^
also paper is downstream
upstream from spigot
wat
sorry ping 😢
paper is a fork of spigot
it is downstream
spigot is the upstream of paper
hence, errors on paper would have to be also confirmed on spigot before actually reporting them on spigot
furthermore, this seems to be a plugin issue not a paper issue
paper changed something, the plugin uses some funny hacks to do its things
that isn't papers issue
its the plugins issue
lmao
this is so fkin annoying
i finally found a warp plugin that works
but its not english
so fk
Just use EssentialsX
It does work perfectly fine
Are u looking for a dev ?
yeah
Go DM
Both are good, but if you used to program on eclipse, use eclipse but if you used to program on IDEA, you can use IDEA
But I hink IDEA is better
Personnaly, I use eclipse
IDEA is feature rich, which can be a heavy load on less powerful systems. Eclipse is lighter and simpler. Its all just personal choice.
I need to make a user editable list of Materials in like a .yml file
is there an easy way to serialise them?
You can loop through the values in the enum and add them to a list
I would also recommend XMaterial and the rest of the XSeries libraries
In what enum? I need to get from just text to a material
Wait, do you mean all of the materials?
I'd like to make a custom event to my class that other plugins can listen to, so my runnable can be tied up with other plugins.
It's a plugin to pay people every 15 minutes.
any advice on how to make a custom event? Not really sure on how to do that (don' need code, if I can get a good tutorial i'm fine )
If you wanna use the Bukkit event api it’s quite trivial to setup
if ya happen to have any code somewhere?
I learn best by seeing it work, not really by reading a long paragraph
I don’t have any code of my own rn but pretty sure spigot wiki has an example
many eco plugins already have a payment feature that pays on a timer
If you want to run a task every 15 mins: let me show ya
That's.. not my question
I know how runnables work
it's for the WiiPay plugin (pretty well known )
I'm just attempting to code an API
so other plugins can interact with it.
yo enyone know what number do i set to have a 15k by 15k border?
declaration: package: org.bukkit, interface: WorldBorder
set size
7.5k
Hey, anyone know how I can move a player up on the tablist
Can Spigot save ItemStacks to config? I know it can save an ItemStack but I want to save the whole inventory
Specifically, it is saving the whole array, not looping
erm
class ExampleEvent extends Event implements Cancellable {
static final HandlerList HANDLERS = new HandlerList();
boolean isCancelled;
public boolean isCancelled() { return this.isCancelled; }
public void setCancelled(boolean cancel) {
this.isCancelled = cancel;
}
public HandlerList getHandlers() { return HANDERS; }
public static HandlerList getHandlerList() {
return HANDLERS;
}
}
class EventRunner {
{
Plugin plugin = JavaPlugin.getProvidingPlugin(EventRunner.class);
plugin.getServer().getScheduler().runTaskTimer(plugin, () -> {
ExampleEvent event = new ExampleEvent();
plugin.getServer().getPluginManager().callEvent(event);
if (event.isCancelled()) return;
//if not cancelled
},0L,20L*60L*15L);
}
}``` @hexed saddle wrote on mobile so might be some issues but you get the idea
oh just use Material#valueOf
how do I move players order in a tablist
If I try to create a project template for intellij, the configurations (Test servers) are not saved. Anybody an idea where I can find the folder where intellij stores those template projects?
ahh, ok
Your comment made me understand it perfectly, it makes sense now.
Wish I could give kudos on discord ^^
Kudo's to you!
(:
lmao
Yup
constants are fine tho, no?
And you should split those up into a constant registry or smtng
like half of those variables are constants
Single responsibility principle
www the fuk
ahh just noticed they're in the main class
you forgot visibility modifiers 🥶
That too
is there a way to get the drops from shearing a sheep in PlayerInteractEntityEvent? Or is there a better event for it?
Maybe like ItemSpawnEvent or smtng
This code really needs a rework, it has ...so little classes
gonna make packages later 🙂
using enum classes makes code fun :)à
We can talk about java conventions and java/oo principles but practically, if it works, it works
Uh can someone tell me how to sort a tablist
like depending on their group (I have a custom group system)
I just need to know how to sort
I tried teams and it didnt work
I made an annotation, and now I want that people MUST use the annotation if they extend my class
So we have an abstract class, and the class which extends the abstract class must apply the annotation
strings.length
if strings.length >= 2 do stuff
Has anybody seen like a vector visualisation tool?
i just mean like a website
idk
@fervent robin strings[1] refers to the object in the array at the 2nd index, and .length is an accessor of that object- so if the array doesn't have 2 or more elements, strings[1] is null & it'll throw an index out of bounds exception
the trick here is "if the array doesn't have 2 or more elements" then it will "throw an exception." Check the size of the array, and this is why
and online game engine
idk
An interactive plot of 3D vectors. See how two vectors are related to their resultant, difference and cross product.
thanks
in the abstract class initializer, run a check to see if the anotation applies
Ok, I am making my own @graceful fractalquired annotations (with the class), and then I can check if the annotation is present
this.getClass().getAnnotation(MyAnnotation.class) == null
Im pretty sure this will work
Disclaimer that ive not dealt with annotations in a while
could someone explain to me what a getter is? i dont understand what to return so make the Main.isDebug()
like
i know what a getter is
i have this
private static Main instance;
@Override
public void onEnable() {
// Plugin startup logic
instance = this;
}
@Override
public void onDisable() {
// Plugin shutdown logic
}
public static Main get() {
return instance;
}
}```
and when i do Main.get , i get the stuff from main like getconfig etc
Failed to execute goal org.apache.maven.plugins:maven-compiler-plugin:3.8.1:compile (default-compile) on project PluginTemplate: Fatal error compiling I just get this, no more information.....
final Set<? extends Element> requiredElements = roundEnvironment.getElementsAnnotatedWith(Require.class);
for(Element element : requiredElements)
{
Class<? extends Annotation> requiredAnnotation = element.getAnnotation(Require.class).value();
if(element.getAnnotation(requiredAnnotation) == null)
{
System.out.println("[ERROR] You missed the " + requiredAnnotation.getName() + " annotation in class " + element.getClass().getName());
return false;
}
}```
This is the code I added
getAnnotation().value will throw an NPE if the annotation isnt there
Oh that's the problem.... stupid
final Set<? extends Element> requiredElements = roundEnvironment.getElementsAnnotatedWith(Require.class);
for(Element element : requiredElements)
{
Require requireAnnotation = element.getAnnotation(Require.class);
if(requireAnnotation == null)
continue;
Class<? extends Annotation> requiredAnnotation = requireAnnotation.value();
if(element.getAnnotation(requiredAnnotation) == null)
{
throwError("You missed the " + requiredAnnotation.getName() + " annotation in class " + element.getClass().getName());
return false;
}
}```
Keep getting the error
What do I need to do then?
the variable requiredAnnotation is completely useless
Is what you need
If thisnis null
The element doesnt have the annotation
Also, requiredElements all have the annotation anyways?
So why do you need to do this check?
I will check if the class is annotated with @require, then I will check if the sub class contains the value (The class which extends the abstract class / interface)
Asking about your attempted solution rather than your actual problem
Hey, anyone got a good algorithm for a vector here?
I think it needs more y force, but idk
I need it because they must annotate so I can generate the plugin
But have dinner now, brb
Generate a random inclination, phi, and a random rotation, theya
Yeah but random everthing ain't that good
Use that phi/theta
?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/
Then use vector.multiply to your needs
ill give it a go
spigot forums wont work for me
how can I change the hit delay of an item?
I mean since the 1.9 theres a delay to hit with every weapon
how can I change that?
Use item attributes
0 <= phi <= pi/2
what is the name of the attribute I have to change?
GENERIC_ATTACK_SPEED
enyone know how to protect spawn so pepole cant destroy/place blocks
declaration: package: org.bukkit.inventory.meta, interface: ItemMeta
ok ty
yeah, go to #help-server and ask for help with world guard
do you know what the standart attack speed of a sword is?
Use the Minecraft wiki
oke
enyone a dev i can hirer ?
?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/
Stop asking
He said it didn't work for him
It probably does
They ain’t saying what don’t work
You cant post threads on “looking for” before u use forums
¯_(ツ)_/¯
that forums wont work for me
go to fiverr or sommin
You dont say what doesnt work 🤷♂️
alr dont ping me @glossy scroll
You’re right here give me a break lol
m1.addAttributeModifier(Attribute.GENERIC_ATTACK_SPEED, new AttributeModifier("AttackSpeed", 0.1, AttributeModifier.Operation.ADD_NUMBER));
what did I wrong that I get this:
wait
Youre adding 0.1 to the attack speed
I cant make a screenshot
no I mean I cant make a screenshot at my computer
Oh well you wouldnt be anle to upload it anywyas
.
so it says:
When in main hand:
...
When in off hand:
...
when of feat:
...
...
how can I disable this?
ik
could someone tell me why this getter is not working? the debug mode https://paste.md-5.net/ibuzefumev.java
?
what am I doing wrong?
// ItemSpawnEvent
Location itemLoc = e.getLocation();
World itemWorld = e.getEntity().getWorld();
if (itemWorld.getBlockAt(itemLoc.add(0, -1, 0)).getType().equals(Material.GOLD_BLOCK)) {
System.out.println("item under entity is gold!");
}
is this not the correct way to compare?
I've tried logging the item under material and it outputs as GOLD_BLOCK so I'm not sure why the code within the if statement doesn't execute
Probably unrelated, but that method can be remade to
itemLoc.add(0, -1, 0).getBlock().getType() == Material.GOLD_BLOCK
thanks I prefer that notation I'll keep it in mind
Items don't usually spawn under gold blocks when thrown by players
try tracking the item, probably with a scheduler task
final Set<? extends Element> requiredElements = roundEnvironment.getElementsAnnotatedWith(Require.class);
for(Element element : requiredElements)
{
System.out.println(element);
Require requireAnnotation = element.getAnnotation(Require.class);
System.out.println(requireAnnotation);
if(requireAnnotation == null)
continue;
System.out.println("not null");
System.out.println(requireAnnotation.value());
Class<? extends Annotation> requiredAnnotation = requireAnnotation.value();
System.out.println(requiredAnnotation);
if(element.getAnnotation(requiredAnnotation) == null)
{
System.out.println(requiredAnnotation.getName());
System.out.println(element.getClass());
//System.out.println("[ERROR] You missed the " + requiredAnnotation.getName() + " annotation in class " + element.getClass().getName());
throwError("You missed the " + requiredAnnotation.getName() + " annotation in class " + element.getClass().getName());
return false;
}
}```
I see the prints until the not null, the print after that is not printed (`Failed to execute goal org.apache.maven.plugins:maven-compiler-plugin:3.8.1:compile (default-compile) on project PluginTemplate: Fatal error compiling`)
The other prints:
me.tvhee.plugin.PluginMain
@me.tvhee.tvheeapi.core.annotations.Require(value=me.tvhee.tvheeapi.api.plugin.Plugin)
not null
yeah I didn't include the scheduler task here but I schedule one a second after the event triggers
the code I posted is the code within the task
Show annotation class
@Inherited
public @interface Require
{
Class<? extends Annotation> value();
}```
This is to require annotations on methods/fields/classes
@EventHandler
public void itemSpawns(ItemSpawnEvent e) {
Bukkit.getScheduler().runTaskLater(this.plugin, new Runnable() {
@Override
public void run() {
Location itemLoc = e.getLocation();
World itemWorld = e.getEntity().getWorld();
// Shrine structure test
if (itemLoc.add(0, -1, 0).getBlock().getType().equals(Material.GOLD_BLOCK)) {
System.out.println("item under entity is gold!");
}
}
}, 20L);
}
I think you gotta @Retention
Not exactly sure, never mess with annotations tbh
What can I do with @retention?
The location is still the origin point, not the new entity location
Ok thanks
I'm trying to make chunk claiming for my server, and I'm not sure how to do it. Wouldn't it be VERY inefficient to check each individual block over tons of files to see if the chunk is claimed?
Each chunk has a X, Z
its not I've tested it. the location property of the entity updates. also I just decided to log the equals statement to see what it was and it outputs true yet the code doesn't run ??? no idea what's wrong
And you can obtain a chunk XZ by doing Block X / 16
So just keep track of claimed chunks and check if the block belongs in it
But that would get kinda laggy if there are lots of players online/who have claimed chunks?
I'd make a ChunkData object, that would contain
UUID owner
int chunkX
int chunkZ
Since you don't care about floating point numbers,
int chunkX = blockX >> 4;
int chunkZ = blockZ >> 4;
I'm having issues with Dependency injection and commands
MarketGUI:
public MarketGUI g;
public OpenMarket(final MarketGUI gui) {
this.g = gui;
}```
Main Class:
```java
this.getCommand("openmarket").setExecutor(new OpenMarket());
Error:
-'OpenMarket(com.olliejw.oremarket.MarketGUI)' in 'com.olliejw.oremarket.Commands.OpenMarket' cannot be applied to '()'
Thx!
You gotta pass a variable on the constructor, @stiff topaz
Of the type MarketGUI
Yeah no worries
how can I do that
This is basic OOP
Dependency Injection is basically passing an instance to another by means of a constructor
Your constructor asks for a MarketGUI
So you must pass an object instance of the type MarketGUI
An instance can reference itself by the term this
Please dont call class attributes by single letter
final Set<? extends Element> requiredElements = roundEnvironment.getElementsAnnotatedWith(Require.class);
for(Element element : requiredElements)
{
Require requireAnnotation = element.getAnnotation(Require.class);
Class<?> requireAnnotationClass;
try
{
requireAnnotationClass = Class.forName(requireAnnotation.toString().replaceAll("me.tvhee.tvheeapi.core.annotations.Require\\(", "").replaceAll("\\)", ""));
}
catch(ClassNotFoundException e)
{
System.out.println("Class not found");
continue;
}
System.out.println(requireAnnotationClass);
System.out.println(requireAnnotation.value().getName());
if(element.getAnnotation(requireAnnotation.value()) == null)
{
System.out.println(requireAnnotation.value().getName());
System.out.println(element.getClass());
//System.out.println("[ERROR] You missed the " + requiredAnnotation.getName() + " annotation in class " + element.getClass().getName());
throwError("You missed the " + requireAnnotation.value().getName() + " annotation in class " + element.getClass().getName());
return false;
}
}
I found out where the problem is: Class not found prints, and that's why also Required#value does not print
Good job
..
hi
Why do u use Class::forName
You don’t have access to the class at compile time or what?
how can i detect when a player closes a chest?
InventoryCloseEvent
i think you can do /ban (player) and then you'll know for sure that it closed
yeah but that triggers for every inventory that is closed
check the inventory type that was opened
Very weird: It just workes if I do
String classString = requireAnnotation.toString().replaceAll(Require.class.getName() + "\\(value=", "").replaceAll("@", "").replaceAll("\\)", "");
Class<? extends Annotation> requireAnnotationClass = (Class<? extends Annotation>) Class.forName(classString);
Ok problem fixed, if somebody knows a better way just let me know 😄
public void sendMessage(Player player, String message) {
PlayerConnection con = ((CraftPlayer) player).getHandle().playerConnection;
IChatBaseComponent chat = IChatBaseComponent.ChatSerializer.a("{\"text\": \"" + message + "\"}");
PacketPlayOutChat packet = new PacketPlayOutChat(chat, (byte) 2);
con.sendPacket(packet);
}
This is how I do actionbar messages pretty sure you just change the new PacketPlayOutChat(chat, (byte) 2); to make it show in the middle of the screen or whatever
i forget which number it is
np
player.spigot().sendMessage(ChatMessageType.ACTION_BAR)???
ew bukkit
declaration: package: org.bukkit.entity, interface: Player, class: Spigot
switch to spigot
This is the spigot discord
was a joke
dont think that exists in 1.8.8
which is all i use lol
Consider switching
cant
Ofc you can (:
Factions isnt possible to play in 1.16
nah