#help-development
1 messages · Page 2237 of 1
I dont think the plugin is in the plugins folder
From that startup he has zero plugins
Okay I'm having issues with the plugin.yml library setting again.
I don't really need to use it here but it should work and it's not.
When I add a dependency to the libraries section like so:
libraries:
- "org.mapdb:mapdb:3.0.8"
Paper and spigot seem to load all versions MapDB's dependencies:
https://paste.md-5.net/copiqedobe.md
For example, instead of loading just "eclipse-collections-api:7.0.0" it loads version 7.0.1, 7.0.2, 7.0.3, etc. Surely the class loader should only load one version for each dependency?
My build.gradle:
I was talking to someone else
md5 ChatColor.of
thanks
You can also simply use the legacy format
ChatColor.translateAlternateColorCodes('&',"&x&f&f&0&0&0&0This is color #FF0000");
i need to help with lore guys
lore with that says that rarity
the format should be: obf_char EPIC obf_char the entire text is bold and dark purple
could anyone help me assemble the string?
what is "obf_char" supposed to be
but why do you want to add the obfuscation code AFTER your text again?
perhaps to reset? &f&r
wait ill show u how its supposed to look
you want it to look like this
@ RARE @ where @ is the random garbage obfuscated stuff right?
its not same color + dungeon shouldnt be ´there
yeah alright
one sec
List<String> lore = Arrays.asList(ChatColor.translateAlternateColorCodes('&',"&5&l&k@ &r&5&lRARE &r&5&l&k@"));
the @ can be any character
oh cool
since it's &k = obfuscated, it doesn't really matter what you use there
cool
I want to make sure they can't drop the barriers, but the rest we can drop, but it doesn't work.
wait
how do you write in code here?
that set ?
erm why did you hardcode the entity id
I am a beginner
how did you come up with the number 166?
barrier
the entity id will be a different number everytime a player drops an item
you want to check the item's itemstack's Material type instead
yes
@EventHandler
public void onDrop(PlayerDropItemEvent event) {
Player player = event.getPlayer();
if (player.isOp()) return;
if (event.getItemDrop().getItemStack().getType() == Material.BARRIER) {
event.setCancelled(true);
}
}
so first: You check whether a player is op by using Permissible#isOp(), not by checking if they have a permission called "op"
and then, you compare the type against the Material enum. Numeric IDs have been removed in 1.13 and they also have nothing to do with entity IDs, which is what you were using
ohh a thanks !
really
good
np
Hey Guys I'm setting player's inventory contents on config. But its saving null items(empty slots) too how can fix it
Don't?
Why is it a problem
Just check if the item is null when iterating the list
Alternatively, just don't save if it's null
sounds like he's just pushing the contents to teh config without parsing
Ye
lots of nulls
What is \u2748
I dont think it is btw
Cuz you'd see 100 in there somewhere
I'm doin' like this
ItemStack[] items = p.getInventory.getContents;
plugin.getConfig().set("Items", items);
this is not my full code I just writed this
im setting it once
are you ever changing the defense?
nope
And save the slot number with the respective item if it's not null
for(ItemStack items : p.getInventory().getContents(){
}
somethng like that?
For i
ok
ohh I see
If items[i] is null, you continue else you set items.i to the item
You do the opp to get it back
I get it bro Thanks!
Np
HOW
now print just getDefense
print it without the unicode character
yep
weird
Not really
what even is Player#getDefense()?
you are getting a decimal value then adding teh value of the unicode to it
then you are printing it as a string
just remove the ( brackets )
I still wonder what Player#getDefense() is, becaue it's not inside bukkit' player interface
A player object he made maybe
could be
because its inside () (player.getDefense() + "\ulah") it takes the first type to decide what to do
the first is an int so it assums math
Hey Guys How Can I set items on GUI on config. I mean if player add some item on GUI I will set this on config.
Anyone knows if you can just create another jet brains account to get another trial?
Serialize the inventory
Just go use Visual Studio Code, its a good free editor
notepad >
God, could you imagine this channel if we told beginners to use Notepad 😦
How to brake line in item name if there drop on ground with long names?
I would set more line for item "DropOnGround" because it looks better by long names.
RegularFormat: |
&b{Amount}x
&2{Item} {Timer}
Can any body help?
you have to use armour stands
Yeah I use Eclipse to xD
The bestest evar!
I want to make sure that when I make a command it sends a message to all the server, you have how to do it?
Hello, I would like to set an Item in the player OFF Hand and at the same time, I would like to cancel any events that let the player take,drop,move or change the item in OffHand.
Any Idea on which events should I look?
So many
Yeah, there are too many events
?jd-s Go there and type event in the top right
Inventory Click, drag, player drop...
I have already done that, I am asking to see if there is someone that already did this and has some suggestions
Like possible bugs etc
you need two entities for separate lines
I want to make sure that when I make a command it sends a message to all the server, you have how to do it? pls help me
Bukkit.broadcastMessage
or loop over all players and do sendMessage on each of them
okay
have you got an example?
for Bukkit.broadcastMessage? o0
send to all players in title mode
?
you want to send a title to all players?
yes
loop over all online players, and send a title to each of them
how do we do it?
Bukkit.getPlayers() returns a Collection<Player>. Loop over it and then do player.sendTitle(...) for each of them
what exactly is your question? how to loop over a collection?
a big title in the middle when I execute an order
declaration: package: org.bukkit.entity, interface: Player
Bukkit.getOnlinePlayers().forEach(player -> player.sendTitle("L'event va commencé")); its good ?
yeah that'll work. but you could also just use a regular for loop. it actually doesn't matter
What happend to org.bukkit
Rebuild
you probably didnt use maven or gradle and instead manually added the bootstrap .jar as dependency
org.nokit
?bootstrap
Bootstrap Jar
The main spigot-1.18.jar is now a bootstrap jar which contains all libraries. You cannot directly depend on this jar. You should depend on Spigot/Spigot-API/target/spigot-api-1.18-R0.1-SNAPSHOT-shaded.jar, or the entire contents of the bundler directory from your server, or use a dependency manager such as Maven or Gradle to handle this automatically.
Please read the release notes for further information: https://www.spigotmc.org/threads/9-years-of-spigotmc-spigot-bungeecord-1-18-1-18-1-release.534760/#post-4305163
guys how do i find out if my plugins are too bulky and make optimisations
optimisations specifically
depends on what you want to optimize
how do developers know about things that are too heavy and memory consuming and overcome that
lets say i have to do something that parses through each player and its being run a lot
Well generally good intuition (e.g. (auto-)boxing being expensive, etc.)
However another good technique is profiling your application which can be done through spark or similar
whats autoboxing
And memory is usually not an issue unless you are consuming absurd amounts of it
Integer a = 1; // Automatic boxing
int b = a; // Automatic unboxing
Integer c = (Integer) b; // Explicit boxing
int d = (int) c; // Explicit unboxing
int e = c.intValue(); // Also explicit unboxing
This lets you pick the low hanging fruits when it comes to runtime performance.
Everything else might be premature optimization which you should not worry about
Also, if you want do profiling to improve performance, don't bother using timings as depending on your codebase you'll easily fall back to doing relatively stupid optimisations
There is no option to get the staff who banned a player inside Ban/Playerkickevent?
The kick could also be done programmatically or from a command block.
I am using InventoryClickEvent and I want to get the item count when I insert an item in a GUI but event#getCurrentItem is null and when I use getCursor I get the item but the wrong quantity because you just right click can click and insert 1
haha
goood
I did it manually yeah but that shouldnt break it right?
Unless ofcourse I moved it 😅
If you want to scale the velocity then you can just get the players velocity and multiply it by some amaoun
Otherwise you would calculate the vector from-to and set it as the new velocity
yeah try that. But "1" wont change anything
should be. Try it out and tell us if it works. Try on a zombie or something.
minecraft is weird
Adding libraries to plugins using Gradle
add a small amount to y
The enemy isnt knocked back if its feet are touching the ground
addY(0.1)
And this is a LOT of knockback
does the entity already have the knockback velocity on the damage event 🤔
Not sure. But if it sometimes works then it migh have.
what event is called when the block under a block like pressure plate turns into air and the pressure plate drops ?
Probably not
There are several events fired here. What exactly do you want to detect?
the pressure plate dropping and me removing it in the listener
Try the BlockDropItemEvent
like tnt run?
Another approach would be to listen for the PlayerInteractEvent, check if its physical and done by the feet, and then simply remove the pressure plate (maybe one tick later)
Hey, I'm trying to destroy a whole tree when one block of the tree is broken.
The problem I have is large oak trees' wood blocks are not connected always
where can I find more info around the permissions.yml ? E.g. is this something a plugin has access to, or do plugins have to read the file explicitly?
and when I get all connected blocks of a specific type e.g. leaves, if it is a forest multiple trees are destroyed
How do I destroy an individual tree?
probably runnable
how can i check if the player is paused or not?
Depends on what you are doing
👀
There is no pausing online
when player press esc
that is purely client side
When doing the flood fill, check the last 2 or 3 types in your path. If its all leaves then dont go any further
why do u need to do that
I want to make it so that if the player press esc, then a text appears above his head
Cant do that. The player sends no information about that to the server
pausing doesn't work in multiplayer so can't really do that
He could as well run around with his menu or inventory open
just check for any click/ interact or move event i'd say
which then means the player isnt afk
is there an event that is called when a player collides on another one?
nope
if I have 2 class objects, can I check if the first one is a child class of the second one?
Yes.
classB.isAssignableFrom(ClassA)
is classB the child class?
Hi, I have been looking through the forums to try solve this issue but couldn't find any exact explanation so I am going to ask here.
I am using PrepareItemCraftEvent to create a custom recipe to convert a custom key item back to a tripwire hook. It works fine if there is only 1 key in the crafting grid (removes the key when the result is taken) but if there is multiple keys in the grid slot it either doesn't clear the grid when taking the result or the amount of keys in the grid slot will double. What am I to do to make sure the grid is cleared when the player takes the result?
Here is the code: https://srcb.in/W4jk99hh8o
What happens:
https://gyazo.com/d243eb184d9701795dafd025c36e2315.gif
https://gyazo.com/62dca86598c454bcff8770054b6f732a.gif
yes
thanks
Wait let me double check
runnables are kept in sync with the game loop
Yes its the other way around.
so if the tick was to slow down in game the runnable will also slow down
They can be kept in sync. Runnables are a java concept.
Bukkit runnables that is
so superClass.isAssignableFrom(childClass)
Runnables that are ran using the bukkit scheduler are synced
with the tick loop
Really depends what time resolution you need and if you want a relation to the game time (ticks) or the real time.
or how its called
a while loop is synced with the computer
In minecraft everything is related to the game time
if a runnable was running every 20 ticks and the game slowed down to 10tps it would take 2 real life seconds to run
help please
This is expected behavior. When crafting in minecraft then crafting one recipe reduces each ingredient by one.
Take wood for example: The output is 4 Planks but you always only reduce the input by one.
oh of course, that just went over my head, thanks.
Hey Guys. I have A Custom Entity I set Event When Player Hit him Its Sending Broadcast Message But When Players hit with bow its doesnt sending any message
ohh
that will error if anything but a player hurts the entity
rightt
in the case of an arrow, the arrow itself is the damager
Yeah Bro You are right thanks!
Does anybody know how to commit / deploy your compiled plugin when compiling in maven?
deployment should rarely be the job of the build tool
There are a lot of tools for continuous integration. The simplest way: Github -> jitpack
iirc there was a maven git plugin.
Guys this is the first time i've tried something like this. is it wrong or is it the way it should be?
i have no idea what they want....
ah xD
yea basiclly that. im currently coding an api for my server system so i dont have always repeating code in every plugin. and i want to use it with maven. so i just put it in the pom like spigot or bungeecord. so i want to deploy it to github and then just do it. but i dont know how to it automatic, because i dont want to always put it in there manually
thanks i will look for it
ok
How i can know how much I is in a itemstack display name ? (not i just I)
I mean, ehhh loop over the characters and check ?
for loop i guess
for(int i=0; i < player.getInventory().getSize(); i++) {
if(player.getInventory().getItem(i).getItemMeta().contains("your char") {
do something
}
}```
i think something like this
no
i mean
in 1 itemstack
like Diamond (Lvl I) and Diamond (Lvl II)
how can i know how much I is in that displaynime like 2 or 3
You should not store/read any data in an itemstacks lore or name.
Use the PDC of the ItemStack instead.
^^
Guys I have an idea. I am doin' boss plugin right now (fight on arena) I wanna spawn boss every 30 min. Can I do like that?
int min = X;
if(this.min == 0){
//spawn boss
}
this.min--;
// and if boss dead this.min = X;
I'm gonna use runnable its just example
XD'
I mean, Its time. for example 6800 seconds
int time = 6800;
if (this.time == 0){
//spawn boss
}
this.time--;
//and on another event class if boss dead, I will set time to 6800 again. And It's gonna reset every 6800 seconds.(I shortened the code there is Bukkit Runnable and runtasktimer too
https://youtu.be/2-KrYRji6lE
any clue how to make this rotate evenly ?
this is what I use :
public void rotateLeft(){
double tps = 1;
double add = wheelRotationSpeed*tps*1;
if(curTexture!=3)
curTexture--;
if((wheelRotation+add)>=360)
wheelRotation = (wheelRotation+add)-360;
stem.setCurrentRot(wheelRotation-add);
if(wheelRotation<=(maxWheelRotation*-1)){
wheelRotation=-1*maxWheelRotation;
curTexture=3;
return;
}
wheelRotation-=add;
}
public void rotateRight(){
double tps = 1;
double add = wheelRotationSpeed*tps*1;
if(curTexture<7&&curTexture>4) {
curTexture++;
}
else{
curTexture=5;
return;
}
if((wheelRotation+add)>=360)
wheelRotation = (wheelRotation+add)-360;
stem.setCurrentRot((float) ((float) wheelRotation+add));
if(wheelRotation>=maxWheelRotation){
wheelRotation=maxWheelRotation;
setCurTexture(5);
return;
}
wheelRotation+=add;
}
private void updateWheelUI(){
Player p = occupiedBy;
BaseComponent bc = new TextComponent();
bc.setFont("wheel");
int curRot = curTexture;
System.out.println(curRot);
if(curRot==0)
bc.addExtra(CharEntry.WHEEL_ROT0);
else if(curRot == 1)
bc.addExtra(CharEntry.WHEEL_ROT1);
else if(curRot == 2)
bc.addExtra(CharEntry.WHEEL_ROT2);
else if(curRot == 3)
bc.addExtra(CharEntry.WHEEL_ROT3);
else if(curRot == 4)
bc.addExtra(CharEntry.WHEEL_ROT4);
else if(curRot == 5)
bc.addExtra(CharEntry.WHEEL_ROT5);
else if(curRot == 6)
bc.addExtra(CharEntry.WHEEL_ROT6);
p.spigot().sendMessage(ChatMessageType.ACTION_BAR, bc);
}
i know how to set the material but how do you set the amount as it says here? https://hub.spigotmc.org/javadocs/spigot/org/bukkit/inventory/Inventory.html#first(org.bukkit.inventory.ItemStack)
declaration: package: org.bukkit.inventory, interface: Inventory
new ItemStack(Material,(int) amount)
ah ok
Just I wanna Spawn my boss every 6800 seconds. Thats Why I'm strtuggling with this time. and, thanks you are right
depends on their visibility
Does anyone know if there is a way to publish maven artifacts through ftp or sftp (latter via the key and not with the standard passphrase) when using gradle?
Oh, Thanks
Oh I know How to use it. Just I wanted to ask it will work or Is there any easier way
PacketChatListener, bam
wait how would i do that with this line? gives me an error when i try that
this is what i have
if (playerInventory.first(Material.DIAMOND) == playerInventory.getHeldItemSlot() && mainhandItem.getType() == Material.AIR) {
ran in problem from some reason mobs are not spawning from spawners
any easy way to find out
what is preventing it ?
well, I'd say for package private classes it might be fine for them to share (common) names
In item, can i somehow store data in it? Like there would be counter that would add 1 when id kill smth
Thanks!
and does some one has any good plugin suggestion for antycheat
bump
is it better then spartan
^^
I dont want to make it visible
its a countdown
NBT?
I always used NBTs on custom items as identifiers so I could patch/hotfix existing items
pdc 👀
BukkitUnsafe
Any tutorial? Is it already in or do i need another lib
I have these two events.. the issue is that there's a crossover when it's a player killing player death, because the top one fires as well as the bottom one. I can't figure out a way to make it so that it's always the bottom one, EXCEPT for the case where it's a player killing player, where the top one would be used instead.
I could add the code from the bottom one into the top one as an else to the getDamager() instanceof Player but this only works for when the player is damaged by another entity, not for ALL types of deaths.
Well @eternal night suggested PersistentDataContainers, maybe thats a better option but I haven't researched those yet 😄
?pdc
But NBT shouldnt require another lib if Im correct
Or UnsafeValues#modifyItemStack
how would you read it
so how would i format this exactly? this is my line of code and i'm not sure if i have to declare new variables or smth?
if (playerInventory.first( /* material and amount here */) == playerInventory.getHeldItemSlot() && mainhandItem.getType() == Material.AIR) {
with modifyItemStack
?stash lemme see if I can find an equally cursed solution heh
Ah nice, bungee chat docs are down
Thanks guys
Can we store Hashmaps or associative key/value pairs in pdc as well or not by default?
Not by default, but it isn't hard to create a datatype for that
Tbf I just realized if you want to store multiple of the same datatypes, you could just use a different key in your key parameter 😅
is it possible too with the workflows?
you can use the PersistentDataType.TAG_CONTAINER
Gotcha ❤️
Hello guys.
@EventHandler
void onJoin(PlayerJoinEvent event){
Player player = event.getPlayer();
event.setJoinMessage("Welcome " + player.getName() + " to the server!");
player.sendMessage(ChatColor.GRAY + "Have a great day on our Server \nIf you need help do /help");
}
This is my code but the JoinMessage gets send after the sendMessage. How can I change that easily?
?scheduling
delay the sendmessage by a few ticks
I use this for collections, arrays and maps in PDC: https://github.com/JEFF-Media-GbR/MorePersistentDataTypes/tree/master/src/main/java/com/jeff_media/morepersistentdatatypes/datatypes/collections
thank you
you can use it like this:
Map<String,Map<Material,Integer>> map = pdc.get(namespacedKey,
DataType.asMap(DataType.STRING, DataType.asMap(DataType.asEnum(Material.class),DataType.INTEGER)));
it's further explained in the javadocs
My codes Working Awesome!
i should go back to making plugins instead of those stupid discord bots 😂
here I created method with Countdown name and I'm calling th
callin this method when server enable
are you counting down the remaining time every tick / second?
you should rather store a timestamp or so
yeah that'll work when you have 20 TPS
otherwise not so well
i'd rather store the "desination time" and then calculate the remaining time everytime you need it
oh and.. wait
How I can change Anything (Lvl I) to Anything (Lvl II) (String)
Anything can be actually anything, i just want to change the level
you want to translate roman numerals to decimal, you mean?
and vice versa
no
i've a simple system for upgrading armor in my server
its like changing Cartel Chsetplate (Lvl I) to Lvl II and III
erm so what actually is your question? 😄
any good guide about how to make a console listener (System.in), it should be running while the program is running and its not for a spigot plugin btw :)
i did some stuff with a scanner but its kinda primitive i'd say
hm maybe look at my shitty discord bot
i think u should run scanner on a separate thread and then queue the commands to run on main thread or something
idk
lemme explain
Player goes to a location with a armor named Name of Gang (Lvl I)
and it can be upgraded to Lvl II and III
how can i just change the Level in the item name?
simpbot thing?
no, another one
red-discordbot?
i'd store the current level in the itemmeta's PDC as integer. and then just redo the line of lore
ah its a fork
no? it's my own bot, not any fork
I don't know what is PDC
Thats cool 🙂
?pdc
why is this giving me an error? if (playerInventory.getItem(0) == Material.DIAMOND) { }
then check out the links that were sent
because an ItemStack will never be equal to a Material
you want to check the item's Material (inv.getItem(0).getType() == Material.DIAMOND)
i got it, thx
Awesome thanks :)
apparently doing /time set day crashed my server i have no code dealing with day/night
i guess its either private then or not on gh :|
huh I sent the link above
https://github.com/JEFF-Media-GbR/JeffBot/blob/master/src/main/java/com/jeff_media/jeffbot/Main.java
Contribute to JEFF-Media-GbR/JeffBot development by creating an account on GitHub.
ooh
so basically the main method simply parses the input and shoves it into the bot instance, which then parses all the commands. so it doesnt matter whether you enter commands on discord or from the command line
new pfp?
yeah i moved the flag to my banner lol
lol
i see
and im wondering what the difference is between ClassLoader#getResource and getResourceAsStream, i know their return type is different but i just need to get the file object so which one is the most suitable?
getResource just returns a URL. getResourceAsStream calls getResource and returns null if getResource returns null, otherwise it calls openStream on the URL
so if you don't need an inputstream, just use getResource
But dont expect to get a File anywhere
its a json file im trying to read :)
yeah you don't get a file if you don't have a file
then you do need an inputstream
Just pipe the istream into a string
json file within jar or somewhere else?
within the resources folder so i guess thats within the jar yes
Actually i think gson has some utils for istream
it's just new String(is.readAllBytes(), StandardCharsets.UTF_8); anyways
if I need a resource as List<String> i always just do it like this (don't mind the class names, I was bored yesterday)
public class HotEGirls {
public static class InYourArea {
public static class WantTo {
public static List<String> readAFileFromResources(final Plugin plugin, final String fileName) throws IOException {
try (final InputStream input = HotEGirls.class.getResourceAsStream(fileName);
final BufferedReader reader = new BufferedReader(new InputStreamReader(Objects.requireNonNull(input)))) {
return reader.lines().collect(Collectors.toList());
}
}
your class names are pretty hot
thanks bro
why do they want to readAFileFromResource?
because it contains some json
maybe a list of all their OF subscribers
For which library?
idk which json library im going to use
Is this for MC plugins or java in general? saveResource in spigot can read json
from what I remember
Ah ok
in spigot you could even just pass the inputstream of the json into YamlConfiguration lol
true lol
how i get the packetentitymetadata from a player?
For Gson:
private final Gson gson = new GsonBuilder().disableHtmlEscaping().create();
public JsonObject readJsonFromResource(String resourceName) {
@Cleanup InputStream is = getResource(resourceName);
@Cleanup InputStreamReader isr = new InputStreamReader(is);
return gson.fromJson(isr, JsonObject.class);
}
hate comments against lombok incoming
hwhat is cleanup
And for org.json:json:
JSONObject json;
try (InputStream is = getClass().getClassLoader().getResourceAsStream(resourceName)) {
json = new JSONObject(new String(is.readAllBytes(), StandardCharsets.UTF_8));
} catch (IOException e) {
throw new RuntimeException(e);
}
ah i was doing like
ah and there isnt a constructor that takes a string as parameter, only a map
How do you set a permanent potion effect?
if i wanted to check if the player is holding an item AFTER they pick up an item and that said item enters the inventory, how would i do that?
if i just listen to EntityPickupItemEvent and check the mainhand item, the code will check the mainhand before the picked up item would actually enter the inventory, which isn't what i want
Just increase the duration to a very high number
Is the item stackable?
yeah
Then you simply need to check the mainhand one tick later
how do i do that?
?scheduling
aight thx for the help!
smile is fast af
always
thats what she said
we summoned a wild alex
/hug @tardy delta
yo alex
quick break the spawner
yes?
yo
xd
F
1L is 1 tick in a bukkit scheduler?
indeed
L is a suffix to define a Long
so 1 leads to the same result as 1L which both correspond to one tick
aight gotcha, thanks guys
I get this error
your disk is full
also #help-server
Caused by: java.io.IOException: No space left on device
No idea... could be anything at this point
nah kafkaz has a million bitches
cant send images here but
Dms
use imgbb
!verify
Usage: !verify <forums username>
what do you want to send pictures for? you don't have any space left on the disk
Btw you should keep your disk usage below 90% at all times because the free space might be scattered which can lead to very expensive restructuring / defragmentation when writing new data.
Im using game server, it says I have over 4gb left
but you don't
can I make a method called from another thread wait before executing if it has already been called and has not returned yet by another thread
then your hoster is shitty and overbooked their disks
so its a host issue
also, this belongs into #help-server
I hope you dont pay more than 3 bucks for a trash server that only has 10GB of disk storage
Yes. Write to the host.
Oh lord k almost didn't recognize you with lack of rainbow
it's on the banner now lol
Same. In the morning i was like "who is this imposter?"
D:
I only ever look at the pfp I was so confused for a bit
looked better with da rainbow 😭
Why would you want to do that?
i'll take a new profile pic on july 1st
I was hoping for a more technical explaination
so the effect still isn't getting applied to the player, any idea why?
scheduler.runTaskLater(plugin, () -> {
if (mainhandItem.getType() == configMaterial) {
player.addPotionEffect(new PotionEffect(PotionEffectType.SLOW_DIGGING, 12096000, 0, true));
}
}, 1L);```
i pick up a diamond (that's what the configMaterial is, i made sure twice) and it appears in my mainhand but i don't get the effect
To achieve what exactly?
You need to get the item one tick later. You are still using the ItemStack from before the event happened.
ah i see
And what does that have to do with structures?
i'm confused now
Ok. Then its quite simple
public World createNewWorld(String worldName) {
WorldCreator creator = new WorldCreator(worldName);
// Do your setup of the creator here
return Bukkit.createWorld(creator);
}
Date date = new Date();
System.out.println(date.toString());
String time_ban_config = plugin.getConfig().getString("players." + player.getUniqueId() + ".time_ban");
if (time_ban_config.toString().equalsIgnoreCase(date.toString())) {
System.out.println("Ban termine");
}
``` I would like to check if `date` is equal or higher than the `time_ban` in my config file, how can I do it?
What you can do is have a zip file that contains the template world. Simply unzip the file async and load the world afterwards.
omg thank you so much it worked
You should use Instants for that. If you compare two strings then there is absolutely no context for the program to know that you are comparing timestamps.
The easiest way to store a timestamp is to simply use the unix time. (which is a long. Def google it.)
Then your comparison would look like this:
public boolean isBanTimeOver(Player player) {
Instant now = Instant.now();
long banEndTimestamp = plugin.getConfig().getLong("players." + player.getUniqueId() + ".time_ban");
Instant banEnd = Instant.ofEpochMilli(banEndTimestamp);
return now.isAfter(banEnd);
}
So check if the value is true or false, if it is true, it means it is over?
Which value are you referring to?
The bool which is returning with your func.
You should treat methods as a blackboxes. And the method should always tell you exactly what it does without you having to look into it.
So if you have a method:
public boolean isBanTimeOver(Player player) {
// Some random stuff you dont know
}
What do you think the method should do?
This should answer your question.
Im asking the method: "Is the ban time over for (Player)" and the method answers with "yes" or "no"
Yes.
Just your method is returning true but "time_ban" is Sun Jun 26 18:58:34 CEST 2022.
that does not look like epoch millis
Does the ban time have to be readable?
Anyone recommend a API to use for GUI creation
All trash
?
interfaces is kinda cute
Java is not very good for GUIs.
But if you must: Triumph
i mean like in game GUI
https://mf.mattstudios.me/triumph-gui/introduction
This one is decent. Even when i think that storing the button data in the itemstacks PDC is stupid.
Just in your method, it is date.getTime() so a value with long or a string like Sun Jun 26 18:58:34 CEST 2022?
Well. Its more than ok with the right tools. I wouldnt want to write a cross-platform UI with something like Qt and C++
c# is pretty easy to use for guis
This would be the ban counterpart:
public void ban(UUID playerId, Duration duration) {
Instant banEnd = Instant.now().plus(duration);
long unixTimestamp = banEnd.toEpochMilli();
plugin.getConfig().set("players." + playerId + ".time_ban", unixTimestamp);
Player player = Bukkit.getPlayer(playerId);
if(player == null) {
return;
}
player.kickPlayer("You have been banned :(");
}
Using forms?
Hm?
and now you''re here
playerId not player.getUniqueId()
thx
:D
people are that evil that they eventually call fields in a records as the name of the getters
record Config(String getToken, long getId)
lombok moment
It always bothered me that they threw out their own styling for records
But thats just a dumb fix
i hate it calling methods like that
if it would be structs mye
hmm they are
@subtle folio i got enough of slashcommands for today
LMFAO
i tried to get used to it but they suck
._.
.-.
my brain is kinda hurting
exactly
wdym lambdas good
lambda supremecy
when hating it
effective final is annoying at times, but thats all I can think of.
check out slash commands in there
true
sorry for flood
have they never heard of a switch
switch statements?
Yes
no a internet switch
gravity
^
gravity is applied every tick
This only makes sense if you would have two bodies with a mass
if (plugin.getConfig().getBoolean("players." + player.getUniqueId() + ".banned")) {
String reason_ban = plugin.getConfig().getString("players." + player.getUniqueId() + ".reason_ban");
long time_ban_config = plugin.getConfig().getLong("players." + player.getUniqueId() + ".time_ban");
Timestamp ts = new Timestamp(time_ban_config);
Date time_ban = new Date(ts.getTime());
if (plugin.getConfig().getInt("players." + player.getUniqueId() + ".time_ban") == (long) 0) {
player.kickPlayer(ChatColor.RESET + "[" + ChatColor.LIGHT_PURPLE + "Pranction Ban" + ChatColor.RESET + "]" +
" \n Raison : " + reason_ban.toString() +
" \n Duree/Prend fin : " + ChatColor.BOLD + "Permanante");
} else {
player.kickPlayer(ChatColor.RESET + "[" + ChatColor.LIGHT_PURPLE + "Pranction Ban" + ChatColor.RESET + "] " +
" \n Raison : " + reason_ban.toString() +
" \n Duree/Prend fin : " + ChatColor.BOLD + time_ban.toString());
}
}
``` How can I avoid messages with proxy, disconnected or other stuff like that?
What is your goal? Do you want to display an expected trajectory path before a player shoots?
Wait. Games dont work like that.
We just have an acceleration constant
Fix your variable names according to java standards.
No idea what you mean by that.
Gravity in real life is also done "every tick"
But there is no atomos of time (that we know of). Thats why calculating
the velocity of an object is essentially a differential equation
What?
This is y of x. This will work.
But the approach is a bit expensive. You can def do better.
The arrow just travels in 2 dimensions so he can simply use a 2D projection. No need for 3 axis.
Thats the hard part
And the biggest problem is finding out g
I would just try to approximate it numerically
Use the minecraft gravitational constant no?
Actually. Let me write a quick plugin that will find out how it works in minecraft.
I know for entities that minecraft actually has a drag coefficient.
brb in like 20min
I mean sometimes I have this "Proxy lost connection".
how can I format numbers like this 1.467.465,98
format a double like this
double d = 1234567890.123456;
String formatted = String.format("%,.010f", d); // 1,234,567,890.1234560000
Fairly inexperienced with reflection, So I'm curious if its possible to expose something like this and use it as its a parameter in a method I want to use.
private static interface Supplier<T extends Container> {
T create(int arg0, Inventory arg1);
}```
thanks
From MC wiki https://i.imgur.com/JD6zzgD.png
my code - https://pastebin.com/NeZEjjGa having errors in main file, getter of database
The return type is incompatible with JavaPlugin.getDatabase()
was following this tutorial https://www.youtube.com/watch?v=MbsI0bNxDEc plz help
1st can you provide stacktrace, 2nd never seen this type of registering commands, and I don't think so if it works, so, how long have you been working with spigot?
@devout bronze
Little disclaimer: This wont be easy because arrows have drag
i am newbie ig
okay, when or where does the problem occur?
looks like code that codedred would do in his videos
in the getter of database in main file u could see on pastebin
Depending on how the constructor looks like it should work
it shows "The return type is incompatible with JavaPlugin.getDatabase()"
its true lol
JavaPlugin has no getDatabase() method
and your import/return type is fine. its a standard getter
soo umm whats the fix
so it shows error on runtime?
no i havent tried to run it yet
its an error in your IDE?
so it shows red underline in ide?
yes
I see no reason for it. If using InteliJ invalidate caches and restart
try putting one line above getDatabase() saying @Override
am using eclipse
maven?
do this
@Override
public Database getDatabase() {
return database;
}
nope not working
where the error exactly, on function or the line inside?
on the function
accept my friend request and send me screenshot of it
yes i did
[20:13:05] [Server thread/ERROR]: Could not load 'plugins\Pranction-1.0.0.jar' in folder 'plugins'
org.bukkit.plugin.InvalidPluginException: Unsupported API version 1.5
at org.bukkit.craftbukkit.v1_18_R1.util.CraftMagicNumbers.checkSupported(CraftMagicNumbers.java:314) ~[spigot-1.18.1-R0.1-SNAPSHOT.jar:3443-Spigot-699290c-2c1e499]
at org.bukkit.plugin.java.JavaPluginLoader.loadPlugin(JavaPluginLoader.java:141) ~[spigot-api-1.18.1-R0.1-SNAPSHOT.jar:?]
at org.bukkit.plugin.SimplePluginManager.loadPlugin(SimplePluginManager.java:394) ~[spigot-api-1.18.1-R0.1-SNAPSHOT.jar:?]
at org.bukkit.plugin.SimplePluginManager.loadPlugins(SimplePluginManager.java:301) ~[spigot-api-1.18.1-R0.1-SNAPSHOT.jar:?]
at org.bukkit.craftbukkit.v1_18_R1.CraftServer.loadPlugins(CraftServer.java:410) ~[spigot-1.18.1-R0.1-SNAPSHOT.jar:3443-Spigot-699290c-2c1e499]
at org.bukkit.craftbukkit.v1_18_R1.CraftServer.reload(CraftServer.java:918) ~[spigot-1.18.1-R0.1-SNAPSHOT.jar:3443-Spigot-699290c-2c1e499]
at org.bukkit.Bukkit.reload(Bukkit.java:789) ~[spigot-api-1.18.1-R0.1-SNAPSHOT.jar:?]
at org.bukkit.command.defaults.ReloadCommand.execute(ReloadCommand.java:27) ~[spigot-api-1.18.1-R0.1-SNAPSHOT.jar:?]
at org.bukkit.command.SimpleCommandMap.dispatch(SimpleCommandMap.java:149) ~[spigot-api-1.18.1-R0.1-SNAPSHOT.jar:?]
at org.bukkit.craftbukkit.v1_18_R1.CraftServer.dispatchCommand(CraftServer.java:829) ~[spigot-1.18.1-R0.1-SNAPSHOT.jar:3443-Spigot-699290c-2c1e499]
at org.bukkit.craftbukkit.v1_18_R1.CraftServer.dispatchServerCommand(CraftServer.java:814) ~[spigot-1.18.1-R0.1-SNAPSHOT.jar:3443-Spigot-699290c-2c1e499]
at net.minecraft.server.dedicated.DedicatedServer.bf(DedicatedServer.java:453) ~[spigot-1.18.1-R0.1-SNAPSHOT.jar:3443-Spigot-699290c-2c1e499]
at net.minecraft.server.dedicated.DedicatedServer.b(DedicatedServer.java:429) ~[spigot-1.18.1-R0.1-SNAPSHOT.jar:3443-Spigot-699290c-2c1e499]
at net.minecraft.server.MinecraftServer.a(MinecraftServer.java:1206) ~[spigot-1.18.1-R0.1-SNAPSHOT.jar:3443-Spigot-699290c-2c1e499]
at net.minecraft.server.MinecraftServer.w(MinecraftServer.java:1034) ~[spigot-1.18.1-R0.1-SNAPSHOT.jar:3443-Spigot-699290c-2c1e499]
at net.minecraft.server.MinecraftServer.lambda$0(MinecraftServer.java:304) ~[spigot-1.18.1-R0.1-SNAPSHOT.jar:3443-Spigot-699290c-2c1e499]
at java.lang.Thread.run(Thread.java:833) [?:?]
Why I get this error once I created the cmd: ```java
Player plr = (Player) sender;
Player target = Bukkit.getPlayer(args[0]);
if (target != null) {
String name = target.getDisplayName();
UUID uuid = target.getUniqueId();
int ping = target.getPing();
boolean ban = plugin.getConfig().getBoolean("players." + uuid + ".banned");
boolean mute = plugin.getConfig().getBoolean("players." + uuid + ".muted");
plr.sendMessage("[" + ChatColor.BOLD + ChatColor.LIGHT_PURPLE + "Pranction" + ChatColor.RESET + ChatColor.WHITE + "] Informations sur le joueur " + name + " ! \n" +
"- Nom : " + ChatColor.DARK_AQUA + name + "\n" +
"- UUID : " + ChatColor.DARK_AQUA + uuid + "\n" +
"- Ping : " + ChatColor.DARK_AQUA +ping + "\n"+
"- Banni : " + ChatColor.DARK_AQUA + ban + "\n" +
"- Mute : " + ChatColor.DARK_AQUA + mute + "\n");
return true;
} else {
plr.sendMessage("[" + ChatColor.BOLD + ChatColor.LIGHT_PURPLE + "Pranction" + ChatColor.RESET + ChatColor.WHITE + "] Merci de specifier le joueur !");
return false;
}
Unsupported API version 1.5 read teh error
you put an api version in your plugin.yml for 1.5
Yes.
Because you put 1.5 as your api version into your plugin.yml
Yes but I need it !
api version only goes back to 1.12
1.5 is from 10 years ago. Spigot didnt even exist back then
Yeah and what I do?
why do you think you need 1.5?
What version are you programming for?
1.18.1
compileOnly 'org.spigotmc:spigot-api:1.18.1-R0.1-SNAPSHOT'
Then your api version is 1.18
Thanks!
in 1.8.8 it does
Hi, if I add a pack folder to my plugin's resources folder will that pack automatically be loaded or is there something I have to do to make it load?
ah, 1.8
saveDefaultConfig();
or what are you trying to do?
I just want to add a custom model for a shield
no a pack will not be sent
and how are you trying to achieve this?
you have to give the client a web address to download a pack from
is that something supported that I could do from just a plugin? Or would I need to upload the pack somewhere
2 ways. Either you start a simple web server that provides the pack or you upload it somewhere.
Enforcing a resourcepack is now supported by minecraft
could you point me to the api that force prompts a user to download it?
You tell the client to download the pack. from this or one of the other methods. https://hub.spigotmc.org/javadocs/spigot/org/bukkit/entity/Player.html#setResourcePack(java.lang.String)
Has the player skull item been changed from Material.SKULL_ITEM in 1.18?
<Material.PLAYER_HEAD>
Thanks, I'll take a look at that
SKULL_ITEM wasnt a thing for years now. Was it?
It was back in 1.8, that's the version I mainly created plugins for until recently
is there any function to cause sculk growth with a custom amount of xp no catalyst?
or is it nms time
is it a good practice having the logger as a static final variable in your class instead of passing it around with dependency injection?
Depends on the logger framework you are using
i've seen many people doing like
private static final Logger LOG = Logger.getLogger(someclass)
the java.util.Logger then
seems kind of redundant to use di for that
thats what i was thinking
For spigot i would always get the logger from my JavaPlugin instance
im not making something with spigot rn :)
i guess its generally acceptable to do that
No API yet for that
The tile exists though, so adding methods to it would work
Maybe I'll do that now. I'm a bit bored lol
Noting however you did say "no catalyst". No. The only means of skulk growing is with a catalyst
mojang wtf is this
private static <T extends PacketListener> void genericsFtw(Packet<T> packet, PacketListener listener) {
packet.handle((T) listener); // CraftBukkit - decompile error
}
ServerPlayer.class
generics ftw lmao
I'm taking a look at an nms function I want to utilize its a Supplier but is it even possible to use it with reflection
private static interface Supplier<T extends Container> {
T create(int param1Int, PlayerInventory param1PlayerInventory);
}
or am I going to have to scrap this and figure something else out
Its only very interesting because its a Supplier and I'm pretty sure if I were to create my own supplier function it would complain at runtime about it not being the same supplier
I would def not call it Supplier
🤷♂️ mojang and their shitty code
never used consumers or suppliers so I wouldn't know exactly
😳
oh shit your right that isn't a supplier why tf did they map it to that
To make this compatible with javas functional interfaces you could do something like
private static interface ContainerSupplier<T extends Container> extends BiFunction<Integer, PlayerInventory, T> {}
And then be done
?notworking
"Does not working" is a useless statement. Please describe what exactly is not working, what you expect it to do, and what actually happens. If you get any console errors, also ?paste the entire stacktrace.
(It was for me, sry)
would java complain about it not being the exact method mojang uses or am I allowed to send in my own format
I guess I'll try and see here
no point in not
No idea what that means.
If a method requires an instance of their weird supplier then you can not just create another interface and pass it
okay yea the method wants their weird supplier
is what I was trying to get across
But its a functional interface so you could in theory just pass a lambda. (i, inv) -> T
Well. Not really because the interface is private
Well I've grabbed it with reflection, but I think thats the most I can do
SafeField supplierLink = new SafeField(MenuType.class, "y");
Class<?> supplier = supplierLink.getField().getType();```
this it the furthest I've gotten tackling this issue and it seems like it may not even be possible with java?
I dont have the full picture so no idea
are there any good Mojang to Spigot mappings viewer websites out here
Whenever i look for them I get nothing but broken sites
this is what someone told me last night
love you
this site is just what i need
im tired of decompiling spigot mapped classes with fernflower
So here is what I'm taking a look at I'm seeing this method here which Is what I want to invoke
private static <T extends Container> Containers<T> register(String var0, Supplier<T> var1)```
but as a param it uses Supplier<T> referencing mojangs weird supplier
```java
private static interface Supplier<T extends Container> {
T create(int param1Int, PlayerInventory param1PlayerInventory);
}```
I can do everything with reflection up to invoking the method because I can't get my hands on the weird supplier implementation
this is where I think I won't beable to progress. Which is actually fine considering I'm just messing around
wait what is that combo
ayo
the later it gets the crazier stuff becomes
HashMapMap<A B, C, D>
HashMapMap<String, String, String, String> map = new HashMapMap<String, String, String, String>();
map#getHashMap();
map#getMap();
This isn't actual implementation but this seems funny
Map<Map<?, ?>, Map<?, ?>>
rather use a HashMapMap tbh
<?, ?> <?, ?> we come in peace
back to solving an issue java can't likely solve wish me luck while I drive myself insane
public interface QuintupleFunction<A, B, C, D, T> {
T apply(A a, B b, C c, D d);
}
Take the third letter of your username
Add the first letter to it and then add s
The guy who actually does that code and makes that implementation should do the newly created word
or acf: CommandManager<?, ?, ?, ?, ?, ?>
💀
Hmmm Instructions unclear I just formed new healthy habbits so I live longer
What is the third letter of ur username
_
Third
Not 0
I'm properly indexing
Ok the second
2
💀
😂
Third
you just said not to 0
Ok, third
Line 30 = private int DEF_EXP = plugin.getConfig().getInt("DEFAULTEXP");
Main class = this.getServer().getPluginManager().registerEvents(new SkillsListener(this), this);
plugin = public SkillsListener(skills plugin) {this.plugin = plugin;}
this.plugin is null
your not passing it in correctly
or your not initializing it
but i am
if you were you wouldn't be getting an error
lol
@river oracle
Third letter = K
First letter = Y
Add the first letter to the third
Ky
And then add S
What is the new word?
thats not a word
I don't know what an LMS is
send me your entire SkillsListener class
You should use java's naming conventions: every first letter of a word in a class name should be uppercase
?paste
shouldn't an int return 0 if its not found in the config?
the instance is null
not the config section
private UUID uuid;
private int SKILL_POINTS = 0;
private int DEF_EXP = plugin.getConfig().getInt("DEFAULTEXP");
private int REQ_EXP = 0;
private int TOTAL_SKILL_POINTS = 0;
private int STRENGTH = 0;
private int DEFENSE = 0;
private int VITALITY = 0;
``` don't do this
at the point the field is initialized the instance is still null
Fields initialize first
as java isn't interpreted order doesn't matter
so set the DEF_EXP when i use it?
Create an initialize function that will be called in onEnable
set it in the constructor or create an init function
either or work
also dont see what the point of that uuid field is
so i can access it around the class
your design pattern is flawed
but isnt this listener a singleton?
I wouldn't name your variables that way either
you arent comparing the uuid to the playerjoinevent
uuid will just be whoever the last person joined is
for (Cell cell :
cells) {
Bukkit.getServer().broadcastMessage(cell.get_cellName() + ": " + cell.get_timeLeft());
int timeleft = cell.get_timeLeft() - 1;
if(timeleft > 1){
cell.set_timeLeft(timeleft);
return;
}
//Cell has expired!
MessageSender.BroadcastMessageWithPrefix("Cell &b&l" + cell.get_cellName() + "&r has expired! The previous owner was &b&l" + Bukkit.getPlayer(cell.get_owner()).getDisplayName());
cell.set_owner(null);
}````
Why is it not executing for the last cell in the cells list?
You think a simple express.js server would work?
Hey, I have this idea of making a plugin that resembles Dynmap but basically 3D. You can go around in the world as if you were in spectator mode, but you aren't logged on in Minecraft at all
I initially thought of using Ray-casting, however, there must be a better way.
declaration: package: org.bukkit, interface: World
No, I need to be render the undergrounds too
TIL
as if you were in spectator mode
Til?
Today i learned
Seems very server intensive
Ikr
Yeah..
Jup
Your best bet is to send the client only the block data
And the client will render it
Not sure if it would even work outside of loaded chunks?
I suppose
Okay... What about allowing admins to only spectate as a player, but in a website
I think a ray-cast may be just enough
make a minecraft client in html
you're gonna need some assets as well
The client doesn't need to know every blocks in render distance, you only need to render the blocks that have one or more air blocks next to then. With some checking you could increase performance by not sending every block
at the cost of extra processing
you'll just move the load to the server
cause now the server is doing the raycasting
I'll make a configuration to set the render distance in the website
GLHF
Thanks
you might want to take a https://github.com/fenomas/noa
its the same one minecraft classic uses
just disable movement and load the in blocks from the server
its actually easier than you think if you use a library @quaint mantle
what a profile picture
IKR
How... How do I implement JavaScript in Java though???
You dont?
Do I just send data to the server every tick?
no
you send on block update
and no yo0u are sending from server to client
and ther is no java to javascript
I am confused
you are writing a new client with javascript
if you are gonna be making this for the web
How the hell do I get the blocks AND entities from the server then?
events
Yeah okay but
send in binary
How tf do I send it to the website...
WebSockets
bruh
It needs to be a single plugin
Nashorn
no
Okay and how do I implement the JavaScript code you sent me?
You cant write websites in java anymore
Its an external library like JavaFX
You sure can
How in hell does Dynmap do it then
really
You can let the player host the website
images are sent to the client
It has a whole frontend deployed. http, javascript etc.
static images are rendered
The client as the Minecraft client or the website?
This is how you could do it
listen on any port greater than 1024
for your http server
write a client that connects to the server through the same port (websockets)
send data from the server to the client
in binary
You can do frontend in java with vaadin.
But i would not recommend it.
You can as well just shade a directory into your jar (html and js files) and serve them via a java backend
yea
you might want to use a graphics library
writing the thing yourself is gonna be a pain
what?
hiding your own inventory or other's inventory
for yor own inventory just send an inventory update packet
and set everything to air
using the hidden creative hotbars?
that wouldnt work
why not
container synchronizer would update the inventory
you need to hook container synchronizer
and send window packet
is there a way to do like guis without the players inventory showing up?
what if you're in GUI
that would require to filter more than that
just use Container Synchronizer class
i create ContainerSynchronizer class in NMS apply it to current menu and then send empty window packet
can you do it with the bukkit api
that way all instances are handled for me without filtering it
no.
thought so
yeah copy their inventory into another inventory
and then reset it
when would send the packets to do that?
I've never touched pcckets before
do you just do it as you call open inventory
after that
yeah packets are not that hard, your plugin acts as a mini "server" by fooling main "NMS server" and client into thinking that's real data
thats how i made a noclip plugin
How can I send a packet with higher priority? I send a packet to a player to make them see another player glow. But when the glowing player sneaks or swims the glowing effect disappears.
packets dont have priority
that's why minecraft has a tickrate
your packets are detected by NMS and client
just give them the glowing effect?
There is no prio. You just need to either intercept the meta change packets and add the glowing flag, or you re-send the meta afterwards again
Either way you need to keep track of your glowing players in a Set<UUID> or if its player specific a Map<UUID, Set<UUID>>
So I am trying to give custom error message when they havent given the right amount of arguments. But when I run this on the server it gives the Internal error error. What should I do diffrenet?