#help-development
1 messages ยท Page 1755 of 1
Correct
I see
player.openInventory works fine
sure, maven-exec-plugin
thanks
or wait
@vale ember
maven-resources-plugin is easier
example
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-resources-plugin</artifactId>
<version>2.6</version>
<executions>
<execution>
<id>copy-and-filter-allatori-config</id>
<phase>package</phase>
<goals>
<goal>copy-resources</goal>
</goals>
<configuration>
<outputDirectory>${basedir}/target</outputDirectory>
<resources>
<resource>
<directory>${basedir}/allatori</directory>
<includes>
<include>allatori.xml</include>
</includes>
<filtering>true</filtering>
</resource>
</resources>
</configuration>
</execution>
</executions>
</plugin>
that just copies allatori.xml from one dir to another
thanks
actually Player is the only official interface that inherits HumanEntity IIRC
it's in the list of methods inherited by HumanEntity, no need to cast it or sth
yes
thanks
And AnimalTamer, Attributable, CommandSender, Damageable, InventoryHolder, Metadatable, Nameable, Permissible, PersistentDataHolder, ProjectileSource, ServerOperator
does a space count as char?
yes
well
only when it's within 'single quotes'
otherwise it's a "string"
yeah ik that
yes
yes
yes
[19:39:05 INFO]: [TootyMC] Method onText() got data: {"type": "player", "id": "305017820775710720", "uuid": "915631c8-8ddb-450e-965f-4290be2519e4"}
[19:39:05 WARN]: org.sqlite.SQLiteException: [SQLITE_ERROR] SQL error or missing database (unrecognized token: "915631c8")```
```java
CompletableFuture.supplyAsync(() -> {
try {
Statement statement = conn.createStatement();
statement.setQueryTimeout(30);
statement.executeUpdate(
String.format("INSERT INTO players (id, uuid) VALUES (%s, %s)", id, uuid));
statement.close();
} catch (SQLException e) {
e.printStackTrace();
}
return String.format("Player with id %s and uuid %s added to database!");
}).thenAccept(result -> {
logger.info(result);
return;
});```
does the DB exist?
What maniac uses string.format
it mentions the token
Instead of prepared statements
yeah that's indeed "creative" lmao
ok may you explain how to do that instead of calling me a maniac?
Yea sorry XD wasn't meant to be too rude
This JDBC Java tutorial describes how to use JDBC API to create, insert into, update, and query tables. You will also learn how to use simple and prepared statements, stored procedures and perform transactions
Prepared statements basically can do what you want
They allow you to define the SQL and later safely insert the data
you can basically just do statement.setString(int, String)
And it will most likely solve your issue
Inserting JSON like this is bound to break SQL syntax
And gets you an error like this
also, for debugging: print out your statement before executing it
Also your last String.format call is missing the values to replace the placeholders with isn't it ?
yep
can we format text for item display names?
if so how do we do it?
using & doesn't work
[COLOR] ?
ChatColor#translateAlternateColorCodes
Oh
ScoreboardTeam team = new ScoreboardTeam(
((CraftScoreboard)Bukkit.getScoreboardManager().getMainScoreboard()).getHandle(),player.getName());
team.setNameTagVisibility(ScoreboardTeamBase.EnumNameTagVisibility.b);```
Why does .getMainScoreboard() give me an error, it says Method invocation 'getMainScoreboard' may produce 'NullPointerException
thanks again
setDisplayName(ChatColor.RED + "red Name")
that's not an error, just a warning
So it will work?
may
getScoreboardManager is annoted with Nullable, meaning it MIGHT return null when the first world hasnt loaded yet: https://hub.spigotmc.org/javadocs/bukkit/org/bukkit/Bukkit.html#getScoreboardManager()
declaration: package: org.bukkit, class: Bukkit
Oh alright
as long as you're not using it in onLoad and your plugin.yml is set to load AFTER the worlds, it's totally fine
Well the it runs after a player dies and a player can't die before the world loads right?
yeah^^
Method invocation 'setDisplayName' may produce 'NullPointerException'
What about this it is the same error right?
ItemMeta may be null
that's because getItemMeta() returns null when the itemstack is of type Material.AIR
I#d basically just check whether the material is air, and if it's not, getItemMeta will never be null
Well you'll want to save the item meta in a variable anyway
So meh, can just go the 100% safe way
The material is a potion
every itemstack that's not AIR will always return an ItemMeta
but i would like to give air a custom name
go create a PR, I'm sure md_5 will merge it lol
Named air is the best
Thankfully we have an encompassing isAir check
yep buuuut
does CAVE_AIR return ItemMeta?
I'm not sure
No
kk
i never had nullability warnings on item meta
never really changed anything ๐คทโโ๏ธ
u coding in notepad?
IntelliJ?
Code -> Inspect Code -> Whole Project
yes it does
if he says no annotations that might be an issue ๐
1.8 def doesn't have annotations here
that might be true
uh I just got minecraft windows 10 for free with the new microsoft launcher?
cool
is that a bug or?
def not a spigot bug
but MC 1.8 is like, older than Ubuntu 16.04
Where's upload button on imgur mobile
also not a spigot issue
Paper has no annotation it seems
||she|| btw
ayo gamers so I got this fun exception when trying to put Itemstacks into a hashmap:
Cannot invoke "java.util.Map.put(Object, Object)" because "this.items" is null
Code used to put the itemstack in items.put(itemname, this.name);
items is null
oh no of course im not putting in json, thats just to show what id and uuid are, im not a maniac am i?
you never created the hashmap as it seems
Yeah see that's what I thought I messed up on... but it's literally right there at the top of the class, unless you can tell me I did something wrong? :
public Map<String, ItemStack> items;
No no, sorry for saying that. Still use prepared statements
I changed it from private to Public thinking it might help
i am
you only declared the variable but never actually created a Map
Ah thank you
public Map<String, ItemStack> items = new HashMap<>();
Did that improve the situation ๐
i havent gotten it loaded yet
Yep gotcha, thank you ๐
as i had foodz
np ๐
but yes i dont see any errors ty
Gorgeous, now I have the lovely ultra-spammed console on launching my server! ๐ I've got some console logging just to know things are happening the way I want
Oh interesting, it seems the map is wiped clean after each input... What am I doing wrong? Am I wrong assuming it's just like an array except it has defined keys instead of an index?
a map basically does what it's named after: it maps one object to another
e.g. a -> 1, b -> 2, etc
so when you use the same key twice, the old value is gone
so yeah it's basically like an array that uses objects instead of numbers inside the [] part
That's the thing, it's always a new value because I am using a for-loop to create the itemstacks being sent in, so there's always new data used for that
can you show your code?
Yeah I was gonna say I'm going to doublecheck, I'll send a paste if I can't find the issue
oki
it's always helpful to print out the things you are storing before actually storing them
Yeah that's what I was doing earlier, would it be an issue if the name used has a space in it?
Like "Diamond ore" for the key
hey, i am looking for volunteers / cheap dev service to help make a custom minemen.mc type practice plugin, i don't have a big budget but am willing to pay later if i ever do ...
||also i know that this kind of stuff is very hard and expensive at times but am just asking for help and you either help or not||
the normal hashmap uses equals() so it doesn't matter that strings aren't the exact same object as your key
DM me, but this isn't the right place to ask
at least not if you're looking for paid devs^^
?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/
oh mb
Pastebin.com is the number one paste tool since 2002. Pastebin is a website where you can store text online for a set period of time.
If you refresh I added the console output
lemme see
show the code where you are calling this class from
you create a new hashmap everytime you call that method
so of course it's empty all the time / only has one object
It's added to the pastebin.
Lmao what
I want to store the max value of my mobs max health in a double, how would i do that?
Getting the generic max health has it as an AttributeInstance
Entity.getAttribute(Attribute.GENERIC_MAX_HEALTH).get() or sth like that
I need to compare it to its current health
Thanks! Not exactly but it helped enough for me to get it!
alright ๐ yeah I just wrote it by heart, but it's something like that
everytime you call the method, you're overwriting allthestuff
instead you must add it to the existing hashmap
Allthestuff =/= names, though?
Should I have a map in the generator class that I save the items to?
maybe upload it to github, it's hard to read code on pastebin if it's more than one class^^
Well hey that worked ngl
okay perfect ๐
I put the items map in the class that calls that first bit of code and now putting it there works just fine
nice
Still a little confused as to why it was clearing the map every time, I couldn't see a reason why but oh well
Oh wait I know now, thank you I was being silly ๐ ๐
Every time it calls the constructor it initializes a new instance of the class, right? and that's why the map would always be blank
exactly
and also:
you did this:
alltheshit = cconfig.getConfig().getConfigurationSection(checkthis).getValues(false);
so you always overwrite the existing map every time
Oh?
I'm not sure I see the correlation
since it's a different map, I mean
There's definitely a better way to do it, I just want the code to work as I'm presenting it tomorrow at noon as a proof of concept
oh maybe I looked at the wrong variable then
anyway, you got it working now, sooo it's fine ๐
Indeed
I was originally hardcoding every single item which would've been stupid. I realized that quickly and since then was working on how to make it all work the way it does now
My last step is adding the mechanism that gives players the items, and with that map being public I actually can.
Quick question about that: Obviously I'll be using a listener on BlockBreakEvent, but how should I go about the blocks I want to listen for? Like would I just have an array with the blocks I want it to do something with OnBreak?
Say I have an If-statement or something that just checks (map.contains(blockbroken)
So If(map.Contains(BlockBroken) {excecute code}
Hey I don't want to ask to be spoonfed but is there any resources that can help me make a timer that continues even after the server restarts, for example like a 2 day ban but if I restart it it still continues from where it was left off?
you will have to save the time
Ye how ๐
Are you making your own plugin to handle bans?
you could just save the target time to your config and save
No it's for something else but I may use it for bans as well
But won't it have to say so many to the config?
The home of Spigot a high performance, no lag customized CraftBukkit Minecraft server API, and BungeeCord, the cloud server proxy.
timestamps
What if there is like 20 people banned
well you only asked about a timer. You didn;t state how many
Just have it save to the config, UUID + Timestamp
That makes no sense @eternal oxide
Save UUID + timestamp and whatever you want the length of the ban to be
That would save it?
you need to save it somewhere so it persists a restart
`^
yeah just get a YAML and save it there
This https://yaml.org?
YAML wasn't made for data storage, a SQL, JSON or stuff would be better, even if there isn't really a difference
I think SQL would be better because I want each player to have one
So if you want a 2 day ban just save the timestamp for when that would be.
Oh like when it should be run?
Like it saves the time they will get unbanned instead of a timer
Yes
That's useful thank you
It's much simpler in my mind at least
well it was made to serialize and store data
how can I pass the main class object to subclasses?
YAML definitely is the easiest solution in this case IMHO
I need it for registering events
I never used YAML before
provide "this" inside the new object's constructor
thanks
Also I need it to save respawn delays, this is like a hardcore server and my plugin makes it so they respawn after 24 hours
So I am guessing SQL would be good or JSON
If it's hardcore then just have it be a 24hr ban and they'll respawn by logging back in when it expires
It's not a ban, a gamemode change
not wrong, but commonly used for configuration files.
It changes them to spectator
anything other than YAML would be better here
Then after 24 hours back to survival
public class MyMainClass {
private MyOtherClass otherClass;
{
otherClass = new MyOtherClass(this);
}
}
public class MyOtherClass {
private MyMainClass mainClass;
public MyOtherClass(MyMainClass instance) {
mainClass = instance;
}
}
e.g. like this ^^
if these are just simple timers to ban or prevent a player joining you don;t need any database. Store a time in the players PDC, then check it onJoin
I am going to use SQL thank you guys
thanks
ah, then same deal I would say. Have a timestamp saved for when they would respawn, and then wait for it to hit that point and execute the code you want
however that makes it impossible to access the data when the player's not online
so: no way to unban players^^
I was assuming he would not need the data outside of the player
Any tutorial on how I check when the timestamp is finished
you'll have to account for offline players as well, I wouldn't know exactly how @grand flint
not true. If you want to manually unban you flag the plaer as unbanned in your own data so his ban is wiped when he joins.
This tutorial will guide you in using the scheduler provided by bukkit. It will allow you to defer the execution of code to a later time. This is not the same as registering a Listener, a block of code which is executed in response to an event in the game. Blocks of code may also be scheduled to be executed repeatedly at a fixed interval, with o...
I think I am going to add a timetamp to SQL, then I can check for offline players as well
yeah but that would also have to be saved across restarts^^
Chat is awake
Thank you guys, very helpfull all of you!
check whether the current time is >= your timestamp
just check if the player trys to join
Ye but that has to be run some how
far less data to save as the number of unbans would be minimal, and you would only need to store teh players UUID
They aren't banned though
just check on join whether a player is banned
a, thought we are still at the ban thing
yeah, as always there's 10 solutions and they all are correct^^ I would simply use a YAML file to store UUID: Timestamp
Anyways how does dependency injection works at An enum? Just a static singleton?
It's a hardcore thing and if they die they are in spectator for 24 hours
Stored in teh PDC there are no timers running. You simply check the PDC onJoin and remove it if expired
But it's not on join!!
if you need to access your main class from an enum, yes, I'd use a static getter method in the main class
if its a ban it would be onJoin
Yez i was thinking about that too
maybe create a thread for your "not-ban" thing, the chat is getting quite spammed
ok, so again you asked the wrong question ๐ฆ
not sure if they even join. more like login, or?
Well you still need to have something to check onJoin in case the player is offline when their timer runs out @grand flint
No I gave an example
and we were discussing yoru "example"
I have one last question, I want to have a BlockBreakEvent that checks multiple different types of blocks, what's the best way to go about that? Something like If(map.contains(block broken){execute code}
sounds like a loop to me
How do you mean?
Is the way I imagine good or is there a better/more effective way to do it?
a map?
why a map?
more like a normal collection/list
a map is to store the relationship between two different objects
You have a point there chief
Yeah so just use a list and check if the block broken is part of it then?
exactly
The more I think about it a map makes less and less sense ๐ Just been working with them so much it was stuck in my head still
private final Collection<Material> blocks = Arrays.asList(new Material[] { Material.DIRT, Material.GRASS_BLOCK});
@EventHandler
public void onBlockBreak(BlockBreakEvent event) {
if(blocks.contains(event.getBlock().getType())) {
// Do stuff
}
}
basically something like this is what you're looking for, right?
Yeah that's pretty much exactly what I am thinking of doing
I'm gonna joink that if you don't mind, just to keep it fresh for when I start working on it in the morning
take/steal/borrow
sure
I sent it so you can use it ๐
hehe thanks
so this is a weird and specific question, but
would the monitor priority for chunk load events still not have the chunk checking in as loaded since it outputs the outcome of the event and not the start of said event?
because it looks like if you check whether the chunk is loaded at monitor priority mc still reports the chunk as not loaded which has me second guessing monitor priority in general
Priority just controls what order plugins receive the events
They are still all called at the same time
I thought monitor was meant to be the exception of that
isn't that the point of monitor being unmodifiable?
Event is listened to purely for monitoring the outcome of an event.
No modifications to the event should be made under this priority
Key word is should
oh
hm
I could've sworn monitor was meant to run AFTER the event
well
live and learn
Hey everyone, I use eclipse and have done "add to index", then commit & push but it has done nothing and this appeared next to my project's name
does anyone know what I should do ? thanks
I got into a problem, I would need to get a player's camera vector, but I have a method that transforms the player's camera position to another angle, but I add x to the player's pitch, in that I would need to get the vector again from the player's camera, and take this x, but pitch is different from the vector, how i could do that ? bad translator
MONITOR isn't different from other priorities. you can still cancel events on monitor, but you shouldn't
technically it's the same as all other priorities
are you sured you pushed it?
it looks like you only commited your changes but didn't actually push them
also use intellij instead ๐ SCNR
hey
i wanna get like "server info" sort of infomation what are some of the things i can use to get this?
things like ram usage, cpu usage or network stuff!
hey
so i want to customize an existing plugin
is it better to start by decompiling an existing plugin that's decent
or
use source code from a not so good plugin that's open source ?
unpopular opinion: if they both are not good enough for you, make your own one,
oh
actually makes sense
hello! How do I create a substring that grabs the text between two quotes?
Exameple:
/tellPlayer "Hello there, how are you?"
I would want to save the text Hello there, how are you? to a variable.
How do I do this? Thanks!
are you going to include escaping?
join all strings first
now you have 2 ways: regex and string#indexOf
regex:
private static final Pattern pattern = Pattern.compile("\"(.+)\"");
//on the command method
Matcher matcher = pattern.matcher(yourJoinedString);
if (!matcher.find())
return; // oh no :C
String whatYouWant = matcher.group(1);
String#indexOf:
//on the command method
String whatYouWant = joinedString.substring(joinedString.indexOf("\"") + 1, joinedString.lastIndexOf("\"") - 1);```
joining strings: String.join("delimiter here", args)
ik this sounds dumb, but how do you make an unshaped recipe
^
ShapelessRecipe
thx
^
lol
and use a list of items
if you really want to get the 100% actual address, you'll have to do a network request, everything else can be falsified
^
^ยฒ
that's my lib to parse recipes, you'll find some stuff about ShapelessRecipes there
you can split and get everything that's after the '/'
why?
Cause it's more concise and it's more readable compared to a large ass switch statement
Not really that big
Yeah its not that big
and what should that map contain? Map<String,Function>?
using reflection for a simple ass switch?
no thanks ๐ I think the current version is totally fine
oh sorry reflection was the wrong word
in germany, reflection as in "Class.forName" and "Function" is the same word
anyway I don't see any problem with the current switch/case
Also I actually really don't like the idea of you turning this into an util class. I think its better for the user to actually extend a specific class rather than call an util method. But thats just how I think
For example, switch statements can be really bad for OOP sometimes especially with all those static calls and stuff
i cant explain it very well, but conclure has a better explanation
I have about 10 plugins that use custom crafting recipes, so I can just do RecipeUtils.getRecipe(ConfigurationSection, NamespacedKey, ItemStack)
I don't see anything wrong with this approach
and it doesn't require anything from the main class so no idea why it should NOT be in a utility class
how do u make custom blocks? im mainly just trying to make a tnt that has a special explosion, while not altering the original tnt
i tried to do it a time ago
I'd apply a custom PDC tag to that item and then do whatever you want once it has been placed / interacted with
but the best way to do is what @tender shard said
woudn't the String#indexOf return the same index for both arguements?
Hey, I have question.
-
If I add support for 1_8_R3, than my plugin won't run on 1.8?
-
On GitHub repo of AnvilGUI plugin I found 1_14_4_R1 and 1_14_R1 versions, wtf?
are you using ANY nms classes?
It's not wrong, and you aren't wrong in that it can't be a utility method, but usually want to avoid switch statements when dealing with something like this. For example, you could convert your recipe statements into separate class with a Recipe parent class or smthing, and make users extend a specific class or something instead.
Anyways it's not a big deal at the end of the day
That's matter?
1: your plugin will only work at 1.8.8
2: yes
like make it place tnt with special tag and then check when that is ignited?
the thing is that the class is supposed to read recipes from a config file
people could do something like
recipe:
type: shapeless
...
I don't see a reason to split it up
Thats even better. Make your parent class implement ConfigurationSerializable
and make subclasses add custom logic
but yes, you're right, there's always at least 10 different solutions for everything
oh right nvm sorry ๐
also, it says that the two arguments aren't ints
yeah I could do that, but I don't see any advantage in doing it
- U mean that that's normal? On spigot page I didn't found such version.
cause OOP (:
almost that they are 1.14.4 and 1.14
you only have to worry about the 1_8_R3 thing if you actually access stuff from net.minecraft.v1_8_R3
I really need to write a system for config recipes
oh wait nvm, forget I said anything - thank you for your help!
How do I make it so people without a certain permission cannot like view a command?
sure, but I don't think that everything needs to be an object
I want to create plugin that will run on 1.8-1.17.1
well that isnt the point im tryna bring here lmao
when you setup the permissions and commands properly in your plugin.yml, they cannot "see" the command
you should turn stuff into objects if you can
then just stick to the API and do not use any NMS methods and you're fine
1: dont use nms
2: then create a module for each spigot version
but obviously thats too general of a statement and varies greatly
How do I do that though?
yeah but, Spigot already provides different classes for different recipe types. I don't see a reason to create any additional wrapper
In 1.8 no API for actionbar, npc
Well, that's how API's technically work
commands:
sort:
description: Toggle automatic chest sorting or change your hotkey settings
usage: |
/<command> -- Shows the player setting GUI
/<command> on -- Enable automatic chest sorting
/<command> off -- Disable automatic chest sorting
/<command> toggle -- Toggle automatic chest sorting
/<command> reload -- Reloads config
/<command> resetplayersettings -- Resets all players' sorting settings
/<command> help -- Shows help about this command
aliases: chestsort
permission: chestsort.use
isort:
description: Toggle automatic inventory sorting or sorts the player's inventory.
usage: |
/<command> -- Sort your inventory
/<command> toggle -- Toggle automatic inventory sorting
/<command> on -- Enable automatic inventory sorting
/<command> off -- Disable automatic inventory sorting
/<command> hotbar -- Sort your hotbar
/<command> all -- Sort your inventory and hotbar
/<command> help -- Shows help about this command
aliases: [invsort,inventorysort]
permission: chestsort.use.inventory
permissions:
chestsort.use:
description: Allows chest sorting
chestsort.use.inventory:
description: Allows inventory sorting
chestsort.reload:
description: Allows to reload the config via /chestsort reload
chestsort.resetplayersettings:
description: Allows to reset every player's sorting settings
chestsort.hotkey.shiftclick:
default: true
chestsort.hotkey.middleclick:
default: true
chestsort.hotkey.doubleclick:
default: true
chestsort.hotkey.shiftrightclick:
default: true
chestsort.hotkey.leftclick:
default: true
chestsort.hotkey.rightclick:
default: true
chestsort.hotkey.outside:
default: true
chestsort.automatic:
default: true
sth like this
You have the library proxy of what you are using, and also an abstraction
to make it simpler and add necessary methods
But still wtf is 1_14_4_R1?
yeah that doesn't seem to exist at all lol
library proxy?
Yeah lol
its probs an implementation of specific version of NMS
Yeah
sorry I don't understand what you mean with library proxy
my english isn't cursed but it's also not perfect ๐
I found such thing here https://github.com/WesJD/AnvilGUI
Any ideas how to disable collision for packet entity
adding it to team and sending the packet back
wouldnt work since spawn living entity
doesnt generate uuid
only spawn player requires it
For example, you have a proxy like as in the library part. Suppose your app uses a specific library or something. You want to separate the logic such that users can just refer to your methods instead of exposing the library you are using for the users. And usually we use abstraction in this case, and as we create more abstractions it essentially becomes "simpler" for the user.
But on spigot page no such version
1.14.4
I still don't completely understand what you're trying to tell me, but feel free to create a PR ๐
Yea its a bit complex lol
It's 1_14_R1
im not the best at giving explanations
no problem, maybe I'm also just a bit stupid lol ๐
maybe that's a mistake of the lib to name it like that. The name doesnt matter, the thing that matters is that its injected into the plugin
Ok
what exactly is your question again?
It's hard to keep track of three different conversations in the same channel lol
^
I would add it to the scoreboard team
ah I see. But what's a packet entity? Did you create a custom entity that you do not want to have any collisions?
but how could i get the UUID
of the packet entity
its the entity spawned with Spawn Living Entity packet
its clientside entity
it does not have a "real" UUID
that's the problem
yeah
i cannot add it to team
for the server the entity doesn't exist
okay so you want the client to believe that your fake entity belongs to their team, right?
there's probably some scoreboard packet you can use
that's the problem, in order to add entity to scoreboard you need to specify its UUID
not entityID
oh alr
i have a bukkit runnable class with a runnable that repeats every minute but how can i activate that runnable so it runs forever?
hm sorry I don't know then
runTaskTimer
??
how do holographics displays do this
well you say it runs EVERY minute?
it spawns packet level armor stands right
that would mean that it already runs "forever"
yeah? i dont neeed to know how to make a runnable
i need to know how to start it/activate it
or is it already by default?
by calling runTaskTimer on your custom runnable object
what?
show your code pls
new BukkitRunnable() {}.runTaskTimer() smth like this
public void run() {
Bukkit.getScheduler().scheduleSyncRepeatingTask(plugin, () -> Bukkit.broadcastMessage("test"), 0L, 80L);
}
}``` i just need to know how to start this
full code, the beginning is missing
private main plugin;
public autochecker(main Main) {
plugin = Main;
}
@Override
public void run() {
Bukkit.getScheduler().scheduleSyncRepeatingTask(plugin, () -> Bukkit.broadcastMessage("This message is shown immediately and then repeated every second"), 0L, 40L);
}
}``` erm ok
okay you can do this:
new autochecker().runTaskTimer(yourMainInstance, 20, 20);
that will run it every second
also btw pls use proper java naming schemes
it should be called AutoChecker instead of autochecker
also erm
why are you scheduling a task within your runnable
in my main class or?
I think you didn't understand what a runnable actually is
thats the point
and every second it schedules another runnable that gets executed every 2 seconds
that's probably not what you want
you actually want to do this:
public class autochecker extends BukkitRunnable {
@Override
public void run() {
Bukkit.broadcastMessage("This message is shown immediately and then repeated every second");
}
}
and now you can just do this:
new autochecker().runTaskTimer(yourMainInstance, 20L, 20L);
ah ok thanks ill try it
and pls rename the class to AutoChecker
class names should be in UpperCamelCase instead of lowercaseallthetime
from new autochecker().runTaskTimer(this, 20L, 20L); i get cannot be applied to '()'
show the full error pls
also I edited the code, did you copy the most recent version?
yeah
'autochecker(com.jere.sscore.main)' in 'com.jere.sscore.listeners.autochecker' cannot be applied to '()'
remove the main instance from the constructor
you did something like "new autochecker(this)"
remove "this"
same error
show the full code pls
new autochecker().runTaskTimer(20L, 20L);
before the first 20L, provide your main class instance
does anyone know what's the best way to make personal worlds? like i want to have personal mines in my server and currently my idea is to have 500 worlds (the amount of player slots i have) and then when a player logs on, the plot would change to the default build, and then set the ores, and when they log off it will be set to air so then the next person can occupy that world slot. if anyone has a better idea please tell me though
you'll have a very very bad time when trying to load 500 worlds
u told me to remove it
from the constructor, yes
ok, so what do i do?
ah
from the runTaskTimer method, no
there's another thing i can do which is to have everything in the same world but far away from each plot
it works thanks ๐
load a world whenever a player joins, maybe
np
wdym by load tho
loading a world is quite heavy, I don't think it's a good way to have one world per player
well but if I would have to do it:
I would do Bukkit.createWorld whenever a player joins
and unload it when a player leaves
i can do it all in the same world, it won't be much of a difference
hmmm sooo
i'm just looking for the best option
what exactly are you trying to achieve?
resource wise
every player should have their own world, right?
personal mines
and they can TP to their mine using a command or sth similar, right?
well they can't actually build anything in there, it's just like a build with an ore mine inside of it
yeah then I'd do it as I said: create a world for the player when they join
buuut
I'm not sure whether creating a new world stalls the main thread
it probably does
it means: server lags for 10 seconds when creating a new world
ah
you do not want that to happen
maybe i can have all 500 worlds at once, but like only load the chunks when a player is in a world for their world?
you really, really, really do not want your server to load 500 worlds
trust me: you don't want that
ok, so all in one world?
are those mines restricted somehow? or are they really "endless" in terms of area?
if they are restricted in area: yes, just use one world for all players and have them stay in their designated area
ok
is it bad if each plot is far away from another plot?
and wondering where i could get the UUID
like let's say 1k blocks
LOL
oh lol
well now you found it ๐
no that doesn't really matter
BUUUUT
here's one thing:
when your players teleport to their mine, the server stops until the chunks are loaded
are you using paper?
i think
if yes: you can use PaperLib to load those chunks async and then teleport the player once the chunks have been loaded: https://github.com/PaperMC/PaperLib
what's async?
tbh you should know what server software you're using
async means: it loads the chunks WITHOUT having the main thread wait for them to load
sync = server stops until chunks are loaded
async = server continues to work meanwhile
well i'm using localhost and for that i use paper, but i'm not 100% sure what my server does on my main server that is on a server hosting service
you should check that
kk 1 sec
so as said: if your main server runs paper (or a fork like purpur, yatopia etc) you can use PaperLib and load the chunks async (= without stopping the "normal" game) and then teleport the player to their mine when the chunk loading is done
can your server be on velocity or is that not a thing
velocity is the proxy that connects your servers, like bungeecord
it doesn't have anything to do with the software that each server is running
well from what i understand it's on a velocity proxy, and the server is on paper
ok then you can safely use PaperLib (link is above)
for spigot users
you can use this method to teleport players to their mines in your custom world
I believe you need to shade either way
what's this mean? (and the one below it)
okay lemme rephrase it
the normal server does 20 ticks per second
that means
every second, it checks 20 times whether players are getting damage, mining blocks, etc
like a repeating command block?
but when you load a new chunk, the server waits until the chunk has finished loading. so it might not get the full 20 ticks per second
that means: players experience lag
ok
paperlib however can avoid this
so that's sync?
normally, everything runs in sync on a normal MC server
just use this method: https://github.com/PaperMC/PaperLib/blob/b9dda152c96cba5263ee2b9ef11cc8a24d56e150/src/main/java/io/papermc/lib/PaperLib.java#L75 instead of using the regular Player.teleport
is there like a "on till soil" event? because I want something to happen when a hoe tills a block
I don't think so, you probably have to use PlayerInteractEvent
so what exactly is paperlib and what exactly is async?
hm... yes, i read a post on it, and im using that right now, but i cant seem to figure it out, how do i get the block before & after the event, but be able to cancel it all the same?
PaperLib is a library that allows you to use features that are included in PaperMC, but not in normal Spigot
async means you can do stuff without stopping the main thread -> you can do stuff that would normally cause lag
(in very simply words)
And if PaperMC is not found (e.g. it's not the running server), it defaults to Spigot behaviour.
Ye?
yes
exactly
if running on spigot, all those paperlib methods will do stuff like on normal spigot, e.g. causing lag^^
you can do PlayerInteractEvent#getClickedBlock to get the block that was clicked
you can however NOT get the resulting block
because the block has not changed when using this method inside the vent
do i have to like check these and apply them?
you can check whether the block is dirt/grass and whether the player had a hoe in their hand
should i setup a runnable that checks the block after a tick?
but i think that is a bit inconvenient
you could do that, but maybe it would make more sense if you explain what exactly you're trying to achieve
??
minecraft, but hoes are OP
that's in the project structure > modules thing on intellij
I still don't get it
are you using maven?
ye
when a player uses a hoe, they get overpowered stuff
i used a yt tut
but i need to make sure that they aren't just rightclicking on non-tillable blocks with a hoe
i need to make sure the block actually changed
oh sorry wrong link
@lean gull
yeah then I'd schedule a runnable that runs 1 tick later
what about the modules thing tho
wdym?
^^^
ignore that. add the stuff from the link I sent to your pom.xml
then tell IntelliJ to reload the pom.xml and you can use PaperLib now
yeah but md_5 doesn't like most pull requests so people are very cautious in creating PRs ๐
btw
you can also just do this:
ok done
listen to PlayerInteractEvent on monitor
check if player is holding a hoe and if right-clicked block is dirt or grass
if event isn't cancelled -> the soil will be tilled
how do i check if i did it correctly
try to use PaperLib.teleportAsync
doesn't suggest it, i'm guessing that's bad?
i'm also guessing the main class that extends javaplugin is not supposed to be gray
pls send your whole pom.xml
when u sent me that code
new autochecker().runTaskTimer(this, 60 * 20L, 5);
im pretty sure its only doing it one time then stopping
no, it doesn't
it will run first time after one minute, and then 4 times per second after that
im confused with the delay and period thing all i want it to do is run once wait 1 min then run again, but the code i sent runs once after 1 min then spams my chat
and ive tried looking at other forums and havent found anything
Then use 0, 20 * 60L
hm... but there are other blocks that can be tilled
for example, coarse dirt
when i used that it only ran once then not again'
then check those too^^
then set both values to 20*60
yeah you're probably calling it in a runnable or some event
anyone know of a good hub plugin which is compatible with a queue plugin?
my command isnt being executed upon sending the command
I have like 20 other commands that work perfectly fine
show your code pls
@Override
public boolean onCommand(CommandSender sender, Command command, String s, String[] args) {
System.out.println("VChest command triggered!");
if (!(sender instanceof Player)) {
System.out.println("Not Player Executing Command");
return false;
}
if (args.length > 0) {
int id = Integer.parseInt(args[0]);
if (VChest.exists((OfflinePlayer) sender, "" + id)) {
VChest.getVChest((OfflinePlayer) sender, "" + id).show((HumanEntity) sender);
System.out.println("Opened vChest");
} else {
create((OfflinePlayer) sender, id);
}
} else {
if (VChest.exists((OfflinePlayer) sender, "1")) {
VChest.getVChest((OfflinePlayer) sender, "1").show((HumanEntity) sender);
} else {
create((OfflinePlayer) sender, 1);
}
}
return true;
}
what exactly is the problem?
it doesnt run
does it print this? System.out.println("VChest command triggered!");
no, like in minecraft, it shows the auto fill /vchest but it doesnt do anything upon sending command
getCommand("vchest").setExecutor(new CommandVChest());
hm
vchest:
description: Opens a target vChest
usage: /<command> [player]
thats the plugin.yml
okay stupid question, but are you sure that you actually properly restarted your server and are using the newest .jar file you compiled?
yes
(You'd be surprise how often this is the problem lol)
okay then I have no idea. It should work fine
is your plugin on github or sth?
well okay sorry but I can't help without seeing the full code. The stuff you sent looks fine
you can also DM the sources or sth if you don't wanna share it publicly or sth
I know why
I made a thing that stops the cmd from being flooded with uneeded outputs
and it just filters it
lol
so it never makes it to the console
okay so you got it working now?
um, no
hm
as said, feel free to DM the source to me, otherwise I can't do much
what's the most efficient way to raycast in spigot?
I cannot avoid needing an absolute fuck ton of raycasts.
We've got stupidly good servers but I don't want to burden anyone running my stuff on smaller ones
granted, this is not a plugin for small servers
maybe tell us what you're trying to achieve, it might help
lots of hit detection.
for either blocks, entities, or both, I should add
alright
I'll wait u guys finish
do you already have any working code etc? @prime reef
you can also just create a new thread if you have any questions
I probably cannot help with raycasting anyway, so just ask your questions pls ๐
no need to wait
how can I calculate how far a player is from the closest point of a world border?
oh that probably requires some math lol
hm let me think for a few mins ๐
To some extent I know that..
hm alrighty
okay I'll just brainstorm a bit, it probably won't help you, but maybe it does
imagine a player is at X30 Z50
and the world border is set to X-100 to X100 and Z-100 to Z100
world borders are always square, right?
so basically you only have to get the difference in either the X or Z coordinate, right?
like when the player is at X30 and Z50, they are 50 blocks away from Z100
right?
i want to say yes
did this actually help you? lol
yes
you can use a BoundingBox for the world border and just create a vector representing the difference between the player's location and the center of your world
the latter is just something like
player.getLocation().subtract(worldBoundingBox.getCenter()) or something
yeah
there's also a distance(Location) and distanceSquared(Location) method
but @prime reef what exactly is your question about raytracing? You just asked what's the "fastest" method, but of course we need a bit more input about what you're actually doing before being to tell whether that's good/bad etc ๐
ah here we are
of course every block/entity has it's own boundingbox, you probably already know that
@vestal dome this might be what you want
declaration: package: org.bukkit.util, class: BoundingBox
you can use the player's location as the first parameter and the difference between their location + world center as the second
well, what I was doing a while back was just...checking locations and incrementing them a very small amount
in a runnable, I mean, but that's not really efficient
you can get System.nanoTime() when the command starts, then get it again when the command completes. and the difference between both values is the execution time in nanoseconds
difference between System.currentTimeMillis() at the end and start of your code, respectively
you can use nano as well yeah
for more precision
yeah the milliseconds isn't very preciese, it returns the same number even when more than one millisecond has... erm... "occured"(?) sorry I don't know the correct english word
elapsed
to measure exec time, always use nanotime, milliseconds isn't very precise
but dw, occurred is close enough to know what you're getting at
yep, exactly
yeah I typically use milliseconds for ability cooldowns and status effect durations/tickrates since there's some wiggle room
and it's easier for end-users to configure ms in config
yeah for cooldowns etc milliseconds is totally fine, but if you really want to measure execution time, use System.nanotime instead
๐
measuring realtime exec time of sorting algorithms and doing some boring proofs on asymptotic analysis
did you see the youtube video that audio/visualizes sorting algos?
it's awesome lol
Visualization and "audibilization" of 15 Sorting Algorithms in 6 Minutes.
Sorts random shuffles of integers, with both speed and the number of items adapted to each algorithm's complexity.
The algorithms are: selection sort, insertion sort, quick sort, merge sort, heap sort, radix sort (LSD), radix sort (MSD), std::sort (intro sort), std::stable...
last one is the best
it randomly shuffles an array until it's actually sorted lmao
but to get back to your raytracing thing @prime reef
You should ask in the spigot forum instead
I'm sure you'll get some proper replies from math experts there
this discord is more suited for some simple questions
raytracing is too complicated for most of the people around here, including me ๐
Hi, I've got a question, can you put custom text in the scoreboard below name?
wdym "below" the name?
you could of course just add an additional line
with scoreboard you mean the thing on the right, NOT the normal tablist, right?
I mean below the name of the player
DisplaySlot.BELOW_NAME
Apparently you can but I cannot manage to find the Spigot way to do it
doesn't that do what you're lookking for?
you can get the score of the player, but if you want to modify it you can just use numbers
hmm alright sorry I'm not very familiar with scoreboards, let's wait for someone else to answer
was trying to dig this up https://www.youtube.com/watch?v=bsSu0LQmhY8
Visualization of 12 different Sorting Algorithms as a Cube with sound.
โ Subscribe: https://www.youtube.com/CompilerStuck?sub_confirmation=1
Donate, if you want to support me: https://streamelements.com/compilerstuck/tip
This is totally not necessary, but helps me give you more of those visualizations :)
Each dot, representing a part of the C...
yeah spigot forum is...it's something.
the amount of snarky comments I've seen there while looking for references lmao
guess it's worth a shot since I have a forum account
yeah sometimes only idiots (sorry) answer, but sometimes you really get people that know what they're talking about ๐
time to flip the ol' coin
making something similar to this for my algo class though, the rendering is fun but the sorting is not
anyway offtopic, mb
np, we go offtoic all the time here lol
but yeah both raytracing and scoreboards are stuff I'm absolutely clueless about lol
@vale cradle I'm sure someone in the forum can help you with your question
nvm, it is done by using the objective's display name
scoreboards is one of the things that are discussed there everyday
ooh so you already got it working?
awesome
no, I just figured out how it is supposed to work ๐
Won't the numeric value still show with the DisplayName
lookin blue :p
This is the most I can expect to do ig
I'm blue daba dee daba da
kotlin probably
thats completely valid kotlin lol
it is
you can return to different scopes from kotlin
aaaah it's like a label
yuh
ya
okay now I understand what it's doing^^
it is indeed a label
ye that's Kotlin
@ represents a scope/label
it's used by break, continue, return, this, and super afaik
e.g. to refer to a field outside of a receiver's scope, say, the enclosing class, you can do this@EnclosingClass.myField
as opposed to Java's EnclosingClass.this.myField (which is mainly only used when two interfaces have the same method)
does anyone know how to register a String flag for worldguard?
I know how stateflags work but I couldn't find anything about string flags in WG's API docs
pls ping me when someone answers^^
how to find the Location of the nearest diamond ore within n chunks around a certain player?
Facebook Chad
yes
well
i guess just check how many diamonds are there
then just put it in a SortedMap<Double, String> = new TreeMap<>();
the double would be you get the distancesquared from the player to the diamond
welp
that was my previous way to find the nearest location to spawn the player
so uhhh
i can suggest that only lol
other plugins use some math and stuff
i just straight up waste 1 day and found the treemap
I wonder how that X-ray plugin does it
what does it do?
I mean, it locates nearby ores and uses a debug feature to highlight them
Pretty cool
Woah
heavy clap
hmm
highlight block
i saw that on the plugin named tweakin i think
about locates neary ores then they just maybe find it in the chunks players can see lel
so do i have to iterate through every block and check if it matches the finding block?
something like a linear search?
I'm looking for a way to change a player's nametag (the text above the player head)
any idea how?
look at tab plugin
โ
wait do spigot allow mc-market here
what does this code mean?
public Varm(Main plugin) {
this.plugin = plugin;
plugin.getCommand("varm").setExecutor(this);
}
(The name of my plugin is varm)
its a constructor
I thought this would have something to do with it
you can do that through a static method
Dude constructors are basic Java knowledge
^
Also plugin.getCommand().setExecutor() should be in a method called onEnable
it is
you should know this by now if you're working with spigot api
oh wait no it's not
yeah, but if they use the constructor on enable then it still perform the same function
well it isn't because from what you sent, it's in the constructor
if i remember right
How i can disable spigot Loaded library messages?
It's sort of a security thing as it shows you what code is running on your server
These messages
yes
you can't disable them from your plugin cause this
oh, okay
Just highjack the logger
How is the lingering potion entity called?
AreaEffectCloud or something
why the potion in bukkit is so scuffed?
can you be more specific
there is a potioneffecttype and its wrapper extends itself, then in potioneffecttype u guys put in the wrapper again
i think it would be a lock?
clearly it's not a deadlock because it works; and I don't know
someone really need to rework that...
lel
why don't you?
yes
but i still have no idea how this thing work
so until then i will just wait...
but wait, is that the code from 7 years ago from bukkit?
i wonder how no one points out that that needs a rework lol
wolfy pro el crack
what? who do what?
much easier to point out things than actually rework them
lot of the former, not much of the latter
Point out that it needs a rework
hmmm
Iโll rewrite all of bukkit for $30 an hour