#help-development
1 messages Β· Page 1603 of 1
also will work
but its harder
what if a chunk gets wiped but not the whole region
then you need to delete only the data in that region file which is in that chunk
'wiped' as in regenerated you mean?
also they will be more ram heavy as you will have to load 512 chunks at once instead of just 1
yea
urgh
not storing IN the files
in a config for that region i mean
im not storing data for every block
but if you have 1 config per region then you load the whole config when you want to access any part of it
it is unlikely it would be more than a few hundred per region anyways
still the chunk wiping problem remains
Well the same issue would be by storing it in chunk separated files
how do i know a chunk got wiped
unless i store the data in the chunk files i cant tell if that happens
but as i said earlier i dont want to leave data garbage behind if the plugin gets removed
you know it got wiped if it is loaded and the event says its a newly generated chunk
also unless you're on paper you can't store your own data in the chunk data
I just have my plugin world data folder in the world folder
and write my data files there
so if you wanna clear the data after removing the plugin you just remove that folder from the world folder
ChunkLoadEvent iirc
ok also since there will be only little data, probably only a few dozen to hundred of coordinates saved per player, is it reasonable to keep it all in one big config file?
i would rather not introduce a whole new bunch of possible errors if i can prevent it
yeah thats fine but you need to keep in mind to clear the relevant data if a chunk is regenerated
also I think you shouldn't be using a config file, just a normal file which you write/read using file input/output streams
cause you need to serialise/deserialise the hashmap
ah ok
FileOutputStream fileOut = new FileOutputStream(chunkSaveFile);
BukkitObjectOutputStream out = new BukkitObjectOutputStream(fileOut);
then just use out.writeWhatever()
remember the try-catch and closing the stream
i am trying to create custom mobs and i don't know how
i see in videos that people are using net.minecraft.server stuff but whenever i try and look for that stuff, it's not there
is there something that i am missing
are you importing the packages?
yea but the net.minecraft.server packages aren't there
If you're on 1.17 packages got moved and should now be using a more vanilla like structure
so how will i set it up then?
You use the new package names and update the code
sorry if this seems like a dumb question, but what are the new package names?
Depends on what you're trying to access
let's say i wanna make a custom mob based off the cow
net.minecraft.<something>
the net.minecraft stuff isn't there at all
yea
Rum BuildTools and change spigot-api to spigot in your dependency
will i just run buildtools in the same file as the project?
You can run it anywhere
oh ok
quick question will my code automatically create a new line in the config.yml? or do I have to do it manually? code: https://paste.md-5.net/aheviseniv.cpp
Im not very certain how a configuration would save your map
Or rather how you would query for them
dataFolder = this.getDataFolder();
public void saveConfig(String where, FileConfiguration config){
try{
File file = new File(dataFolder, where);
config.save(file);
}
catch (IOException e){
e.printStackTrace();
}
}```
That produces a directory. Why? 'where' ends on .yml
Do u have a yml file in your recourses package?
yeah but I use eclipse
Okay but why do you reload your config I think if you reload the config it will get rid of everything inside of it.
little tip, when I switched from eclipse to intellij idea, I realised how bad eclipse actually was and I couldn't switch back, try intellij ;3
A directory with name in where?
I did
Yes so true
Little tip, use vscode
just no
You will realise how bad are ides
xD
That's in my main plugin file. it is under plugins.<plugin name>
Use the windows editor it's the best and it's free and you don't have to install anything
think it will work?
?paste
everyone knows that mincrosoft word is the best IDE
well i gtg
bye
Anyone know the commands to delete a warp?
Yea but does that name end with yml lol
Wtf is a warp
Its new created
https://paste.md-5.net/weducunuzi.cpp
returns
Could not read - will use a empty config
Word is editor not ide
Ahh sorry, thought this was for the advancedTeleport-mod! Sorry!
Wait what is your question again
The method looks correct to me
so the question is why does this crap create a directory
File dataFolder = this.getDataFolder();
String file = "Savethis.yml";
File read = new File(dataFolder, file);
if(!read.exists()){
read.mkdirs();
try {
read.createNewFile();
} catch (IOException e) {
log(Level.WARNING,"Could not create "+file+"! The plugin will use a empty config!");
return new YamlConfiguration();
}
}
explain?
Don't you have to do getParent then mkdirs?
ah
Would that work
Then you will make directory up to parent i think
yeah
Ah yea you need to getParentFile
Watchu mean
like getParent() returns the name/path I think and then there's getParentFile, why couldn't they have just made getParent return the file instead..
Erm thats true
can someone give me a basic plugin idea? (not a complex one, but an easy one, for begginers?)
Should have been getParentString() or sth
hmmmmm
depends on your experience
ok thx :D
Send message to player when player runs a command
Lol
I think thats pretty basic
He could make it a complicated way π
But it can teach beginners a lot of things
Configurable, Command handler
If you think about it
xd lol
Firstly it teaches beginners about inheritance
How Plugin is a subtype of CommandExecutor
Hence the onCommand method for overriding
Or a different class for the CommandExecutor
just to know, there are many ways of doing a command right?
I never used CommandExecutor to do a command
π§
fuck
right
Annotations
Because Plugin already inherit CommandExecutor
the last 2 are advanced ways
HELP
Hence you can do in main class
dont forget plugin.yml has to declare the command too
Yeahhh but it would be more oraganized
I searched for "commandexecutor pigot" and it appears A POR* SITE
LMFAO okay
add a s
nooooo
Lol
Are you completely new to programming?
+/-
And java is the first language you are learning
no
my first language was python for like a month
and then java, for like 2 weeks xd
So I have like a mysql database to store player's balance and I save them on player quit and load them back on the player join, the thing is when player switching server too fast, the data hasn't saved yet and it load the old data, how can I fix it?
Then this may be useful for you
I learned/Im learning the basics, inheritance, polymorphism, objetcs, etc...
?learnjava
Here are some links to get you started on learning Java:
- https://www.codecademy.com/learn/learn-java
- https://www.sololearn.com/learning/1068
- https://www.learnjavaonline.org/
- https://programmingbydoing.com/
- https://docs.oracle.com/javase/tutorial/java/index.html
The last one is the only official one, however some of those concepts assume that you already know a bit about programming.
Ah ok
Erm idk lol but the last one definitely is
And the official one clears up most misconceptions
Save balance directly on change or on plugin disable
So when balance got changed, save them on the database right away?
Yes, but if you afraid player will spam transactions, then save on plugin disable
Well i had a long break before starting again this year
Well, what If the plugin never disables and player changes server.
I'm not using them but I want to get better
ik theyre related to events and stuff
but idk why and how should u use them
Then the balance are updated isnt it
A major part of many plugins are if-this-then-that
Because we only saves the data on plugin disable
So at every server I cached the data on hash map.
like listeners?
Ohh
When player make transaction I just modified the cache data.
Hello I am back π
that wasnt helpful lol
What if transaction took place in multiple servers
One moment
redis!
hi βοΈ
hi
You can't do that, because you can't transaction with player that isn't online.
Why not xd
To prevent that of course xd
What I do with data is load all the users in when the server starts and just cache inside of a map - UUID and the User object
So then you can actually interact with players data when they are offline ^
I do that too.
?
I want it to sync across servers.
his problem is this map isn't accessible in all servers
I save the data in async, and when player switch server, the data hasn't saved yet so the plugin load the old data instead.
I've actually never used redis myself but something like this could be achieved using it and very easily too
and save data to the database for every transaction?
then have an eventhandler waiting for the event to fire after transaction is done
on server change
or quit or watever
ConfigurationSection spell_section = Echo.world_spell_list.getConfigurationSection(x+"_"+y+"_"+z);
if(spell_section.equals(null)){
player.sendMessage("No section");
}
else{
player.sendMessage("Yes section");
}```
this returns either 'Yes section' or nothing at all. Why does the first branch never trigger?
He could create an artificial delay before it loads the players data in - @hardy swan
thats probably another solution
but you nvr know how long it will take
i'm starting to think java is a bit broken
first - static abuse
second - null.equals(null)
third - no } on the else
ah its there but i forgot to ccopy it
every time i thought so, every time I am proven wrong
ok so
on player quit or leave or change server watever
fire an event after his balance is saved
it's on different servers wdym
if you fired an event on server1
rip
server2 can't listen to it, yopu know what i mean
yea
ConfigurationSection spell_section = Echo.world_spell_list.getConfigurationSection(x+"_"+y+"_"+z);
if(spell_section.equals(null)){
player.sendMessage("No section");
}
else{
player.sendMessage("Yes section");
}```
Since i trust myself about as far as i can throw myself i reduced it to this. The result? The same.
the upper branch DOES NOT TRIGGER even if the lower branch ALSO DOES NOT TRIGGER
what the heck is wrong here
the documentation says it is 'null' when its not set
then yea maybe delayed query is the only option i guess
if(!config.isConfigurationSection("path"){
log("No section bro");
}
FileConfiguration#isConfigurationSection
you mean add a delay before load player data?
yea..
hello
yea
Hahaha
credits to ignPurple
poggers
but i want mysql π₯
i am getting a null error in my main class, but i cant figure out how
@summer scroll You use both, redis and mysql, redis can just send a message to a channel and then other servers register on that channel then receive the message
then after that you set the currency in the player data
most basic explanation ever
do you need like a login credentials for redis, like mysql?
i never used redis, but i kinda know how redis works
FOR FUCKS SAKE
ConfigurationSection spell_section = null;
if(spell_section.equals(null)){
player.sendMessage("No section");}```
THAT SENDS NO MESSAGE EITHER
ofc not
just use isConfigurationSection
guys
why would sth be .equals(null)
or he needs to use ==?
lmao
o he's here
hi
ok back to this, if-this-then-that is if something happens, my plugin will do something. That's how most plugins work - you break this block I do this and this, or if this chunk loads I do this and this. That's the answer to why you should use/know eventhandlers
public class Main {
int x;
public Main(int x) {
this.x = x;
}
public static void main(String[] args) {
Main myObj = new Main(5);
System.out.println("Value of x = " + myObj.x);
}
}
I have a question here
could I instead of using "this.x = x" use "myObj.x = x" ?
I wanted to shout static abuse then realise it is public static void main lmao
no
in this line right
this.x = x
but this = this object, no?
where did your myObj come from
this is more of a scoping issue
your constructor is separate/outside of main method
and doesn't have access to this myObj
the example is correct, it is showing you what this means
@next crater Also, I would suggest declaring a variable as either being public, private or protected, if you want to access it from other places please do "public int x"
this is a reserved keyword in Java which points to the class instance itself.
that code isnt mine xd is from the w3school site, but thx anyways :D
interesting
yea it is just an illustration of this from w3schools
I think it is confusing to explain this with this.x = x ngl
myes
could you explain me? if youΒ΄re busy, dont worry, if you dont want to, you dont need to
as said this is a reserved keyword in Java and is a variable that points to the class instance.
this
tpcsurvival.getConfig().set("NPC.banker", npc.getUniqueId());
gets registered as (in my config file)
NPC:
banker: !!java.util.UUID '9995e3b1-a8ee-4313-9093-e9d2ba709502'
but i never asked for the !!java.util.UUID
ohh
To explain this easily. Consider the following class:
public class Example {
public void doSomething() {
}
public static void doSomethingStatic() {
}
}
In doSomething you have access to this, i.e the current instance of the class, or easier, an instance of Example. However in doSomethingStatic, you dont have access to this, because the function belongs to the class Example, rather than the instance of Example.
like .toString() at the end?
Is there a way to store an ItemStack in a class and use it whenever I want to
yes
yes
How
store it... in a field
public class Example {
public ItemStack someItemStack;
}
class Example {
var x; // instance variable
void set(var x /* parameter variable */) {
this.x /*<- the instance variable we declared on line 2*/ = x /*<- parameter variable declared on line 3*/;
}
}```
In the instance method set(x) we declared a parameter by the name `x` also. If we only type x inside the method, it will simply result in the outer x variable not being accessible due to scoping precedence. To access the outer variable x we simple use the keyword `this` separated with a dot and then the variable name. It is a way to access instance variables as well as instance methods.
Do note, var is to be substituted with the actual type :"D
^
var is (currently) only allowed in lambda functions
its allowed in local scopes
please explain more
Oh damn, thats news
yeah, havent used it yet btw lol
π
Though I think Ill stick with explicit types
myeah type inference is dangerous tbh lol
yeah in java i'd say definitely
it was never designed for it imo
in a language like Rust inference is perfectly fine though
yeah
meanwhile Kotlin
How to make a class to store ItemStacks in
what does "instance" means in java?
well only benefit with this is:
Object method() {
var result = new Object() {
int i = 0;
}
return result.i;
}```
@grim ice
An object of a class basically
oh, ok thx
@lunar schooner
imagine human as a class, you are an instance of human, your parents instantiated you. and constructor is called when parents mate to create offspring
so if you have the class Example,
public class Example {}
public class AnotherClass {
Example e = new Example();
// e is an instance of Example
}
What specifically do you want to know, or rather, dont yet understand. That makes explaining a tad easier
I found the problem ;-
I do recommend though, if you don't know about fields, learn java's basics first
iirc there's a bot command for different guides, but I dont remember it
ah nice
lol xD
It was importing fromjava import tk.slicecollections.maxteer.cmd.Commands; and not from ```java
import
tk.arthycollections.nitidezjoga.mysterybox.cmd.Commands;
To execute the Commands.setupCommands() ;-;
I want Java 17 already T_T
@lunar schooner @ivory sleet @hardy swan Thx β€οΈ have a great day
IIRC, we're getting JEP 412 then :poggers:
Good luck!
ah yes sealed
anyone
π
?learnjava
Here are some links to get you started on learning Java:
- https://www.codecademy.com/learn/learn-java
- https://www.sololearn.com/learning/1068
- https://www.learnjavaonline.org/
- https://programmingbydoing.com/
- https://docs.oracle.com/javase/tutorial/java/index.html
The last one is the only official one, however some of those concepts assume that you already know a bit about programming.
Mmno not that one :"D
1s
I mean thats the one I care about lol but yeah
the foreign functions & Memory API https://openjdk.java.net/jeps/412 :"D
So much better than all the JNI glue π
once that API stabilises, I might just write a Bukkit API library for Rust π€
I work with native code, and so JNI glue a lot, so definitely excited for it :"D
I dont think so
it adds to JNI and sun.misc.Unsafe iirc
ah okay
though they do want sun.misc.Unsafe gone
hmm yeah heard that somewhere else
or rather, JDK internal only
after all the name hints why lol
@lunar schooner
I did read in the JEP that they want to eventually phase out JNI though, as it's a disaster for safety
I was wondering how do i make a class and store an itemstack in it
since things like final fields aren't at all final anymore
i checked that
its legit first link in google lol
Exactly :"D Should have all resources needed
class Wow {
private ItemStack stack;
public ItemStack getStack() {
return stack;
}
}
bruh i can imagine everyone abusing sealed in the future
I havent read into sealed classes much, elaborate?
yeah its basically gold in terms of writing code defensively
so you restrict what classes can extend or implement you
does reflection remain unaffected?
yeah in principle
its a compile time feature allowing a superclass to explicitly whitelist a set of classes, only each class contained in the set is then allowed to derive from that supuerclass.
can you give me an example of using it
i have only heard of null pointer exception
exception != error
but yea sure just send pastebin here
actually, could you tell me more about the entire problem
I want to store an itemstack in a close to use it wherever I want
exception is exception, something special that occurred. error is something that wasn't even expected to occur
no like what are you doing as a whole
necessarily just having a field wont solve it
Everything is possible, if you abuse the system enough π
o
then
explain please
wont need an account^
anyone'
and the error? paste to a separate bin
What problem do you have?
Your yml might not be in the exported jar. Open it with winrar and check
We need some more context first π
Essentially to stash a ItemStack, or any object for that matter, in a class is easy:
public class Example {
public ItemStack is;
}
public class PluginClass extends JavaPlugin {
public void onEnable() {
Itemstack i = new ItemStack(Material.STONE);
Example e = new Example();
e.is = i;
// You can now use the ItemStack by doing e.is
}
}
Then do that
Of course, there are definitely more idiomatic ways of doing it, like setting the field is using a constructor
o ty
yes, it is an issue with new Main()
you re-instantiated your plugin
uhh, more like
public WordCommand(JavaPlugin plugin) {
this.plugin = plugin;
}
then you will have
Bukkit.getScheduler().runTaskLater(this.plugin, new Runnable() ...
You should try to distribute your one instance of JavaPlugin you have to other sources that need it.
One example is the often used Singleton patter where you store the instance in a static field with a getter.
Open the exported jar and check if the plugin.yml is on the root path
uh
How would i cancel the event of drawing back a bow?
pretty sure it wouldnt work
haven't ever tried it, but you could probably even make the field final
public class PluginMainClass extends JavaPlugin {
public static final PLUGIN_INSTANCE;
@Override
public PluginMainClass() {
PLUGIN_INSTANCE = this
}
@Override
public void onEnable() {
...
}
}
that'll break things
PLUGIN_INSTANCE = this onEnable but yea, cant be final
the one u sent before doesn't work lol
In your main class:
private static MyPlugin instance;
public static MyPlugin getInstance() {
return instance;
}
public void onEnable() {
instance = this;
}
The just call MyPlugin.getInstance() where you need it
PlayerInteractEvent
Ah, spigot probably uses a constructor which I should not be overriding :"D
No you cant
Actually, let me check that
it would prob say smth like cant resolve symbol 'Example'
^
jar -tf <filename>
Dont make it public pls.
Some other dev could see this and just do MyPlugin.plugin = null; and ppl will run to you telling your plugin doesnt work
It wouldnt even compile as I showed it, since a .java file may only contain 1 class. so you need to spread it over different .java files. If they're in the same package it resolves perfectly, however if they're in different packages you'll need to import
java -jar
They can set it from another plugin
(Though they can too if you make it private, but then they're just assholes)
so do we have any folk here also familiar with Rust (rustlang, not the game)
I had a little Java idea, not necessarily related to Spigot, but could be used for Spigot nontheless
that made it even more complicated
lol
i dunno why but this doesn't run jar
jar should be a operable program directory
hmm
anyone how to store an itemstack in a class to access it whenever i want
Still going to get the same answer @grim ice
this has been answered dear
are we talking Java's Runnable or BukkitRunnable?
https://bukkit.org/threads/cancel-bukkit-runnable.146604/ this might help
I dont think there is a way to cancel a java Runnable
but maybe you can kill the entire thread or sth
read that ^
There is, ish
it goes over canceling
I know, im not talking about BukkitRunnable, just pure java
and I know BukkitRunnable has a cancel()
or maybe "canceling" is just killing the thread i guess
Guys how to make the owner in the top of the tab list ???
yes;no
which step are you stuck at, finding "owner" or making him on top
what is the difference of using for-each loops and for loops?
oh nevermind
for-each = every value/object
for loop = repeat X times
more like, repeat until a condition is false
yeah, thats what I meant xd
thx anyways :D
is there an existing way that the class instance is passed to that class of interest>
if they are static in A, then the other class, B, just need to call using A.var1
provided they are public
if not, write a getter
Do I need to still check if I am able to cast this HumanEntity to a Player, as it says in the description that we're talking about a player.
ah, then you could just put this bukkittask in a field too
I won't receive an error, as only players will be opening the inventory. But why does this method return a Player would be the bigger question π
or you can use a callback from class B
Hello i search to use hex color in scoreboard can you help me ? π
this.runningTask = Bukkit.getScheduler().runTaskLater(Main.plugin, new Runnable() {...);
or you can add to a list
When do I use ArrayLists and LinkedLists? (they look the same for me π§)
I realise you may not want it, but an example would be
Bukkit.getScheduler().runTaskLater(Main.plugin, new Runnable() {
@Override
public void run() {
B.addRunning(this);
}
);
not even sure if it will work
cancel in B, yes
yea you should use first one, cuz second one passes in a Runnable, not BukkitRunnable
Or you can even do this to pass in the bukkitrunnable
B.addRunning(Bukkit.getScheduler().runTaskLater(Main.plugin, new Runnable() {});
data structures are subjective to its use, you nvr know
if you ever want an implementation of a queue
then of course you would pick LinkedList
Hey, my server port forward wont work although I have followed all steps in common guides, anyone know what may be the problem?
that is more of a #help-server question
Hello how to use hex color in scoreboard can you help me ? π
Does factions have placeholders?
thank you π
yes
Were do I find them?
thank you
alright quick question with GUI's. Basically I am trying to create a GUI that when clicked it opens up another GUI. That part works and I am trying to add a back button to go back to the initial page. Initially I tried to just have the player dispatch the command to open the original GUI on click, but that does not seem to work. Any suggestions?
doesnt work
why not
Guys , I need help
I want to use a command to start a scheduler task but I have no idea how to use schedulers and commands together in such a way that commands trigger the schedulers
Please help
?scheduling
it does
Did the same thing today first call: player.closeInventory() then run the command
ill try again
"dispatch the command"?
bukkit.dispatchCommand
on click -> open player inventory
either opening the originally or store it some where and open that
would anyone mind telling me why Bukkit.getEntity(UUID) does not work while using spigot API but does work while using paper API
UUID scrn_l = bmv.main_world.spawnEntity(loc_l, EntityType.ARMOR_STAND).getUniqueId();
((ArmorStand)Bukkit.getEntity(scrn_l)).setRightArmPose(new EulerAngle(0,0,0));
Hello, how to prevent "moved too quickly!" message while using Entity#teleport method?
i get a nullpointerexception
java.lang.NullPointerException: Cannot invoke "org.bukkit.entity.ArmorStand.setRightArmPose(org.bukkit.util.EulerAngle)" because the return value of "org.bukkit.Bukkit.getEntity(java.util.UUID)" is null
It just closes the inventory and doesnt open the other
Like I want the player to enable the scheduler with a command, and i didnt understand what it is from the link given
so like can BukkitSchedulers be used inside classes that have implemented CommandExecutors ? because BukkitRunnable cant be used inside that
first close then open the other one
can i see ur code?
are those placeholders for Massicvraft faction plugin?
if (event.getSlot() == 0) {
event.getWhoClicked().closeInventory();
Bukkit.dispatchCommand(event.getWhoClicked(), "powermenu");
}
what does /powermenu do?
massivecraft yes
ok thx
opens the main gui
ye show me that code
ok
of /powermeny
ye
/powermenu
fyi its in a seperate class
ye
all that stuff
use the ` 3* then text then the thing 3x again
ok
?paste
no need to close any inventory. closing before opening will just cause cursor bugs
java
java
not brainfuck? lame.
depends
i didnt write that part of the code... this is an old plugin my buddy wanted me to polish up
essentially does the same
anyway
onPlayerCommandPreprocess π±
public class ExampleCommand implements CommandExecutor {
@Override
public boolean onCommand(@NotNull CommandSender commandSender, @NotNull Command command, @NotNull String s, @NotNull String[] strings) {
return false;
}
}
``` use this xD
i know how it works lmao
wtf is that @NotNull
big ew
its a package from intellij
idk intellij auto tab thing
ye
NotNull is unnecressary, args = strings???
π§
this
your settings are weird
it is just an annotation, leave it if you like
thats bc im using paper and i also imported spigot
<dependencies>
<dependency>
<groupId>org.spigotmc</groupId>
<artifactId>spigot</artifactId>
<version>1.16.5-R0.1-SNAPSHOT</version>
<scope>provided</scope>
</dependency>
<dependency>
<groupId>com.destroystokyo.paper</groupId>
<artifactId>paper-api</artifactId>
<version>1.16.5-R0.1-SNAPSHOT</version>
<scope>provided</scope>
</dependency>
</dependencies>
its the unwritten spigot coding convention
guys can someone guide me through how i can start a scheduling through commands , bcuz idk
?scheduling
bro tried looking through this
that we dont use annotations?
everything about this is wrong
i need someone to help me out a bit i got a few doubts , but lot of people are msging here
what i do xD
at the parameters of onCommand, yep
first: the event you are using for your command is just for monitoring. second: opening a gui with executing a command is okay but wrong. third: ew
can someone help me out with scheduling doubts?
^
it should, but internally.
so no need to bring it up
@hybrid spoke can you help me out?
i want to start a scheduling with commands , how do i do it.
just start a scheduler at your oncommand
then i cant do getserver()
how can i put it in the oncommand when getServer method is not possible inside it?
the place holder are not working
eww, i just realised
they linked to a wrong faction spigot page
lol
it is for Factions UUID
@hardy swan can you help me out with my doubt?
or maybe they do use the same placeholders idek
.
hmm, is this method in your main class?
no its in another class
that's why, getServer is a JavaPlugin method
im initiating the scheduler in another class
@hardy swan
so basically my objective is to initiate the scheduler with a command , thats why i put it in that command class
You will have to either pass your plugin instance to that class, or Bukkit.getServer()
bukkit.getserver() ???
oh so i do bukkit.getserver() in the other class?
from here im assuming that you are trying to get the server singleton right?
yes
okay wait i think i figured it out , let me try this ill tag u if it doesnt work
thanks
do you have massivecore installed?
yes
and you did run /papi ecloud download Factions
i did not
maybe that's it?
ok
Someone help me, pls.
I want to know how to change a block face in Spigot 1.8_R3.
tried it again
this doesnt work
it doesnt shoot
but it still pulls it back
Bukkit#getServer()
?paste
??
no wait im talking to someone bout the error right now
The more the better
so seems like an EntityDamageEvent with the damage cause set to PROJECTILE does not modify the final damage if the target has projectile protection
does that mean I just have to modify it myself by checking the armour?
Main >
https://paste.md-5.net/afotekizot.java
Command Class to initiate the Scheduler >
https://paste.md-5.net/zurosopebo.java
Its a classcasterror
so i used skript for a while, right? but i knew basic java, kinda learned more in the last month or so for java.. still confused about BukkitRunnables
classcast exception
i.e; how do i "wait 1 tick" or etc.
lemme do something for you Rq
where did these messages come from
The runnable executes instantaneously
you can have the execution delayed or repeated
explain that to me like im 5 π³
so new BukkitRunnable() (etc.)
@ovverride
public void run()
//stuff
}.runTaskLater(stuff here)?
obviously im better at code than that
plex forgev
?scheduling
It tells you about that
Someone help me pls bruh.
not sure if this is how it works in reality but imagine you have a queue of runnables, each assigned a time when it should execute. So you have runnable A to execute on tick 100, B to execute on tick 110, and C to execute also on tick 110. Every tick you execute all the runnables scheduled for that tick one after the other.
so it would get to tick 100, execute A, then get to tick 110 and execute B and C
i see
?help
selfrole Add or remove a selfrole from yourself.
cleanup Base command for deleting messages.
embedset Commands for toggling embeds on or off.
info Shows info about CafeBabe.
licenseinfo Get info about Red's licenses.
mydata Commands which interact with the data CafeBabe has about...
set Commands for changing CafeBabe's settings.
uptime Shows CafeBabe's uptime.
customcom Base command for Custom Commands management.
findcog Find which cog a command comes from.
names Show previous names and nicknames of a member.
casesfor Display cases for the specified member.
listcases List cases for the specified member.
reason Specify a reason for a modlog case.
permissions Command permission management tools.
all the logic inside the runnables happen in one tick, the waiting is done before the first line of the runnable is executed
insane
Why no one help me, bruh.
@cinder plume https://paste.md-5.net/ogiyocafen.java
change a block face?
yes
Probably because no one understands your question.
in 1.8_R3
what do you mean change a block face
huhuhuhuh
Thats an Enum, keep going, when you get to an actual question we can answer we'll let you know
@quaint mantle thanks a lot , ill take a look at it , i need to understand too
by the way
anyone knows how to remove an item from existence after a certain amount of time
Blocks can have a facing
them look, but you can only see that on chests, enderchests, etc...
I want to know how to change the block direction
yeah no worries, let me know and i can help out where you dont understand
setFacing()
why 1.8 ;-;
good luck in 1.8 its a data bit
just get a 1.8 pvp plugin
bruh
Get the block state
check if state is instance of Directional
cast to Directional
get direction
change the block type
set direction
copied from forums
Not in 1.8
thanks a lot for being helpful !
will do
Send me the topic
anyone knows how to remove an item from existence after a certain amount of time
2019 so it is post-1.8
The most of the big developers still using 1.8 version ' -'
who?
1.8 is 10 years old and an unsupported API
anyone knows how to remove an item from existence after a certain amount of time of its creating?
however, facing in 1.8 is a data Byte on teh block when you set Type(Material, Byte)
1.8 was released closer to minecraft's original 2009 debut than to today lol
it is like developing for pre-beta, pre-alpha, pre-infdev, etc. when everyone was playing 1.7.10
alright i still need help w/ the runnables
Its me again with being cursed with CraftBlock, why does World.getBlockAt() sometimes return CraftBlock
everythings valid, right?
it all sets
i just want it to set one block at a time delayed by one tick
so one block sets, then the next, etc.
getBlockAt will always return a Block, which has an Implementation of CraftBlock
wrong message
yep
GG
screen scrolled π
my question is still unanswrered
Your need to increase teh delay on yoru runnable by 1 tick for every additional block
@eternal oxide do u have an idea
how to remove an item from existence after a certain amount of time of its creating
Probably some basic java i forgot, but how would i then get BlockData and not CraftBlockData
Have a timer like a bukkit scheduler and remove it
^
how
the player can just
?scheduling
from the Block#getBlockData
how
but it sometimes returns CraftBlockData, wich cant be cast into (for example Leafs)
pcd
should i move the BUkkitRunnable somewhere else then?
?
Events
What did you expect
i thought thats what i did lol, ElgarL
i'll move it after the if(
((Directional) block.getState()).setFacingDirection(BlockFace.EAST);
block.getState().update();```
Try using this ^
getBlockDat will always return a BlockData. It only returns CraftBlockData if you are working with a CraftBlock, and you shoudl not be
No you are just queuing them all up one after the other, in thr same tick
but thats the problem i shoudnt be but sometimes returns it, to be precise on listeners to the break event
OH NO
i'll put it after the if
your delay is always 1
infact i already did put it after the if
i hope that helps?
honestly runnables confuse me idk why
Try this
((Directional) block.getState()).setFacingDirection(BlockFace.EAST);
block.getState().update();```
Bukkit.getServer().getScheduler()
No you are getting a new state
You have to use teh state you set the direction on
cough cough
you can instantiate them the java8+β’οΈ way with
Runnable runnable = ()->{
//Pogger code
}
Did that interface even exist in 1.8?
its all running simultaniusouly again, i guess i'll put it above the for(?
Directional does not exist in 1.8
But You're Getting a Blocks Current State, Then you are setting new Facing Direction and then updating the blocks State...
This is legit a 1.8 API ;/
No you got the state, set teh direction, then you got a New state and called update
a State is a snapshot of the current block. any time you call getState you get a new copy
discarding yrou old one
sorry for the random reply,
the bukkit runnable stills runs all at once
idk whta i expected from movong it tbh
yes because you still have 1 as the delay on it
should i make an int, and add to that int and make the delay into that int?
yes, you need to increment that delay for every block you process
it is int += other int to add to an int?
because + is for construcotrs
specifically strings
You are correct Directional is in 1.8 I just checked.
So it would work then..
Also im lookin into it more tbh, And you can do a BlockState which would require a MaterialData
Only if you use the same BlockState
Well okay π
How to spawn Fake Items(Clientside Items) with ProtocolLib in 1.17 ?
Fake Items?
Yes an Item, that is only clientside
like one on the floor?
Just like spawning an Item but clientside
uhm yes an EntityItem"
I recommend taking a look at PacketWrapper
Is PacketWrapper not outdated ?
Protocollib hasn't changed much
Take a look here ^
By the look of it you'd need to do the following
PacketPlayOutEntityDestroy packet = new PacketPlayOutEntityDestroy(item.getTypeId());```
((CraftPlayer)pl).getHandle().playerConnection.sendPacket(packet);
location.getWorld().dropItemNaturally(location.add(2D, 0D, 0D), item);
Something like this ^
That's not Protocollib
So that means PacketWrapper is still active ?
I saw a commit like a year ago idk
BlockState blockstate = this.block.getState();
Directional blockdir = ((Directional) blockstate);
blockdir.setFacingDirection(BlockUtils.yawToFace(this.location.getYaw(), false));
blockstate.update();
``` Maybe this will work?
Try it out
Last update is for 1.15.2 most if not all wrappers still work
Show BlockUtils
In Germany it is said:
Testing is above studying xD
BlockUtils has only the public yawToFace snip
Worst case take a look at wiki.vg and see what the packet contains and set the contents
i am a genious of breaking stuff, somehow a blockbreak event returns CraftBlock instead of block
@EventHandler(priority = EventPriority.LOWEST)
public void onBlockBreak(BlockBreakEvent event) {
Bukkit.getLogger().info(event.getBlock().toString());
}
CraftBlock{pos=BlockPosition{x=71, y=77, z=-53},type=BIRCH_LOG,data=Block{minecraft:birch_log}[axis=y],fluid=net.minecraft.world.level.material.FluidTypeEmpty@670b3ca}```
any ideas on why
Block is an interface
CraftBlock is the implementation
You're using import org.bukkit.event.block.BlockBreakEvent; ?
yep but craft block doesnt allow me to cast its data into specific blocks as it returns CraftBlockData instead of BlockData
how does the VillagerReplenishTradeEvent work? did not quite understand it
and this getBonus() Get the bonus uses added.
Show me what you're doing
You're using spigot?
1.15.2 <= 1.17.x
π But should I use it ?
Not that I use it and it don't get much updates or will be archived ?
yep, for a sanity check ill post int ere
import org.bukkit.event.block.BlockBreakEvent;
Im already trying o.O
yep the latest spigot 1.17.1 for the test server and spigot api 1.17-R0.1-SNAPSHOT for development
All packets I've used still work. Oh and you can just maintain stuff yourself if things break
My outdated spigot 1.8 is working fine, lol.
Idk why your latest version is wrong
I think that is your code
Ah yes you're right
Then thank you π
PS: i tried d + 1 and d += 1
because i see that around
idk what im doing wrong anymore
d is set to 0
private int d = 0;
Youre using runTaskLater
You're increasing d inside the runnable
do you even know what im trying to do
aah should i increase it somewhere else
Idk, i never used runTaskLater, but the name...
Yeah code inside the runnable will run after loop is complete
ahhh,
Basicly i get the block (or should get the block) and then cast it into leafs so that i can get the range from a log without writing 3d range code by myself
so the thing that crashes is
@EventHandler(priority = EventPriority.MONITOR)
public void onBlockBreak(BlockBreakEvent event) {
final Block block = event.getBlock();
Leaves leaves = (Leaves) block.getBlockData();
}
but perplexingly on the leaf decay event it totaly normaly returns a instance of Block
But if CraftBlock shows its ugly head ere it returns (for some reason) CraftBlockData wich ofc cant be cast to leaves
Make sure you imported the right leaves
hi guys, im finally getting into sql, how could i connect to the database offered by spigot?
like i mean how to use the connector
The home of Spigot a high performance, no lag customized CraftBukkit Minecraft server API, and BungeeCord, the cloud server proxy.
yep, these are the only ones that arent bamboo and depricated
import org.bukkit.block.data.type.Leaves;
import org.bukkit.event.block.BlockBreakEvent;
``` lol...
wait
My control + v dont worked
Spigot/Bukkit hasn't provided the Ebeans database for a long while now. If you want to connect to a third party database however, Olivio's link will help
i've seen that guide, but i can't get it to work, i did this but received an error.
Error: https://hastebin.com/yosabalayo.md
SQL Class: https://hastebin.com/ofidawufis.java
org.bukkit.craftbukkit.v1_8_R3.block.CraftBlockState cannot be cast to org.bukkit.material.Directional
``` lol...
' -'
Hey, anyone here know how to get the server folder name?
i know that the one provided by spigot is very outdated, still i don't think that is a big problem
or the server name
getServer().getName()
Was just checking you weren't using the Ebean database because it doesn't exist post-1.13 ;p
Or 1.14, whenever it was removed
returns CraftBukkit
rl 
i am using 1.8.8 still sadly

Because you need to change your server name on your files
then with a BufferedReader try getting the server properties and reading server-name
i gotta add 1.8 support because so many server owners still use it
proxy interface intensifies
or just loading that properties file with an inputstream
yeah
You cant get the folders before the server folder
Hm we have the same problem
you can
not the same but simalar
when i open a player's inventory, does it call inventorycloseevent?
I cant, when i try it says null
Isn't it just possible to get the directory name?
?stash
I only want the bungeecord server name or the directory name
yes, go backwards a few times and get the filename
In 1.17 by default I don't have the server-name property
You solved?
Bukkit.getWorldContainer().getName() or Bukkit.getWorldContainer().getAbsoluteFile().getName() returns "."
no been banging my head on it for 1day and a couple of h, since nobody on this earth seems to know why is this happening
get the path of the world container and go backwards one time, that should return the path of the server
ah okay thank you
Your code does look fine to me have no PC to test with though
hoping it works π€
Just did some sanity checks with the logger
it seems that the on break event returns CraftBlock
CraftBlock is Block
You can cast CraftBlock to Block if you want
Any instance you fetch from Bukkit, if it's an interface, it will return and print its implementation because that's just the default toString()
bump
Blocks are CraftBlocks, Entity is a CraftEntity, Server is a CraftServer, etc.
@EventHandler
public void onInventoryClose(InventoryCloseEvent event) {
Player player = (Player) event.getPlayer();
String key = getKey(event.getInventory());
if (key == null || key.equals("shop")) return;
new BukkitRunnable() {
@Override
public void run() {
final String newKey = getKey(player.getOpenInventory().getTopInventory());
if (newKey == null) {
player.openInventory(manager.getInventoryMap().get("shop"));
}
}
}.runTaskLater(shop, 1);
}
this just says if its already on the shop page, let it close
else, if the new inventory is a key then let it
any clue why my mana code (or atleast the code to send what mana I have) isn't working?
mana class: https://paste.md-5.net/pucotuhigu.java
main class:
https://paste.md-5.net/eposicelic.java
Define isn't working
hmm?
What isn't working
im not quite sure but I atleast know that this
Plugin plugin = Bukkit.getPluginManager().getPlugin("MCBTRPG");
Bukkit.getScheduler().scheduleSyncRepeatingTask(plugin, new Runnable() {
@Override
public void run() {
for (Player player : Bukkit.getOnlinePlayers()) {
if (getPlayerMana(player) >= getPlayerMaxMana(player))
player.sendMessage(getPlayerMana(player) + "/" + getPlayerMaxMana(player));
addMana(player, 2);
}
}
}, 0L, 20L);```
isn't running
WAIT
shhhhh
