#help-development
1 messages Ā· Page 1655 of 1
it's the spigot 1.8.8 jar
whhat
Bukkit.getScheduler().runTaskAsynchronously(plugin, () -> {
// Async code here
});
Because they imported the wrong itemstack
I do
Ok
does that work the exact same as runTaskTimer? So with the delay etc?
import org.bukkit.inventory.ItemStack;
As expected. You need to import org.bukkit.inventory.ItemStack instead
Yes all scheduler methods have an async counterpart.
š¤
yea did it manually import org.bukkit.inventory.ItemStack;
scheduler.runTaskAsynchronously(myplugin, task -> {
variationTask = task.getTaskId();
naturalvariation();
}, 0L, variationSpeed);
runTaskTimerAsynchronously
intellij
thanks ā¤ļø
thhen HOWWW
But be aware that you can not access any live bound objects from outside the main thread.
So no Block, World, Player etc.
yeah that is fully ok, I am only modifying the MySQL data with the function
thanks
String historyString = String.valueOf(history).replace(" ", "").replace("[", "").replace("]", "");
Can I somehow save myself from this abomination?
well i'm curious too
Regex
ty
replaceAll with regex
how do I put [ into regex?
?paste
so uh i have an idea which is,
when a player is about to die it tps them to world spawn, says a random death msg in chat that you can edit in config(and at the end of the death msg you set it says (died from {how they died}, says a title on there screen that you can also edit and runs /event setdead {there ign}
How I did it :
https://paste.md-5.net/ipirodataw.java
What I want:
It's really bad and disgusting when I look at it, so i want ppl to help me make it better / function better.
isn't it possible to cancel the player dead event so keep all their stuff and exp?
and then tp
no
oh
ah
idk why spigot hasnt made it cancellable yet
that's alot of ifs
YEAH THATS THE REASON I MTALKING 
@silver shuttle storing as string is not a good idea if you care about minimum size
i think theres no way to simulate a death message
use switch
oh yeah
for some reason my function to cancel that task no longer works
any other ways to make it better
BRO I WISH WHO MADE THE DEATH EVENT UNCANCELLABLE GET NON STOP DIARRHEA
Use a HashMap
Who
Instead of ifelse or switch
DamageCause String
Other way around
i'm curious add them all to the map?
or will it kill him
I really don't want to use entity damage event
is there another way
I am making a plugin with an animated armor stand but the stand keeps moving does anyone know how I can fix that? This is my code: https://pastebin.com/rGVjARMy
What are your trying to do in the first place
when a player is about to die it tps them to world spawn, says a random death msg in chat that you can edit in config(and at the end of the death msg you set it says (died from {how they died}, says a title on there screen that you can also edit and runs /event setdead {there ign}
@lost matrix
ticks = 0;
ticks++;
After those two lines ticks will always be 1
š
i mean there is a player death event?
But how can i cancel it than?
remove the first line
Anyone have link to guide on how attributes work and how they effect players
U CANT CANCEL IT
OANWEFUAWEBFAUEFABEUFAEFUEWF
@grim ice use damage event and check if hp - final damage <= 0
hmm dont cancel it but just tp them
Thx I was very dumb
DEATH MESSAGE FROM IT
or do you want to keep inv?
tp their death body? srsly
Idk they're localised
oh yea then there is a dead screen
You could use Player.setHealth() and Playet.spigot.respawn()
@grim ice just stop being rude ? people are trying to help and can't understand what the fuck you are asking . you have "Minecraft Plugins Dev" on your bio, you don't seem like one ?
Use the damage cause provided with the damage event
can anyone tell me why
if(p.getInventory().getHelmet().getItemMeta() == ItemManager.hotHelmet.getItemMeta()){
Bukkit.broadcastMessage("hey");
}
isnt working?
maybe other meta
ItemMeta instances are not compared using ==
I have one question I want that it animates smoothly in 1.5 seconds but I can increase the amount but that is not smooth do you know a sollution?
What is the simplest way of making an event in my plugin that other plugins can register and hook into?
Just extend Event, provide the handler list in the class and call your custom event anywhere you want.
thanks
The home of Spigot a high performance, no lag customized CraftBukkit Minecraft server API, and BungeeCord, the cloud server proxy.
wait...
if(p.getInventory().getHelmet().getItemMeta().equals(ItemManager.hotHelmet.getItemMeta())){
Bukkit.broadcastMessage("hey");
}
this code works when in an entitydamageevent when im holding an item but not if im not holding any item... wtf??
Use the PDC of ItemStacks to identify custom items
?pdc
I was using in my 1.16.5 plugin a trick to do an immediate respawn (without death screen), i was listening to playerdeathevent and healed the player at this time so the screen didn't appear. This seems broken with 1.17.1, any idea how to fix?
only if hes on 1.14+
No reason to not be
actually 1.13+ :>
Using anything else than the lates version is a bad decision.
only the real kids know about the first iteration of PDC in 1.13
CustomItemTagContainer š
the one and only
I'm trying to count all the blocks of a specific type in a region. This is how I'm trying to accomplish that but it doesn't work. It just doesn't add up anything even if there are blocks of that type in the chunks. Is there anything I'm missing?
https://gyazo.com/081d9f8a55a1bcc378b8d13d497670e6
idk if it still is
package me.pluginrq.plugin;
import org.bukkit.Bukkit;
import org.bukkit.event.EventHandler;
import org.bukkit.event.Listener;
import org.bukkit.event.player.PlayerJoinEvent;
import org.bukkit.event.player.PlayerQuitEvent;
import org.bukkit.plugin.java.JavaPlugin;
public class Main extends JavaPlugin implements Listener{
public void OnEnable() {
Bukkit.getConsoleSender().sendMessage("§a[Teste] > Plugin Habilitado com Sucesso");
Bukkit.getPluginManager().registerEvents(this, this);
}
public void OnDisable() {
Bukkit.getConsoleSender().sendMessage("§4[Teste] > Plugin Desabilitado com Sucesso");
}
@EventHandler
public void Entrar(PlayerJoinEvent ev) {
ev.setJoinMessage(null);
Bukkit.broadcastMessage("§eBem vindo"+ ev.getPlayer().getName());
Bukkit.broadcastMessage("Logou no Mundo: "+ ev.getPlayer().getWorld());
}
@EventHandler
public void Sair(PlayerQuitEvent eq) {
eq.setQuitMessage(null);
Bukkit.broadcastMessage("§4-"+ eq.getPlayer().getName());
}
}
why my broadcasts don“t work?
i“m starting learning spigot
?paste
A chunks height reaches from 0 to 255
i writted the code in the editor and pasted here
Only the chunk sections within
I see
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.
Unless you are a masochist that likes to tinker with ancient software
but the code is the same as the tutorial I saw
its not
Its not

wdym
sometimes ancient software is better
for example
they fucked minecraft for bad pcs when they added the aquarium update
it used to use 1gb ram
now it uses like
2gb
Thats a really bad example but I do agree that in some cases "ancient software is better"
it is a good example
no
they couldve optimized the game in a better way / added an option to use the optimized version
liek a switch between optimized / normaal
m8 as they add stuff it's going to be harder to run
bud if I had 10000000000 mods reguardless of how good my pc is it's going to run worse then vanilla / optifine with no mods
Itās the cost of adding more features and enhancing the code base... sure, however spigot 1.8.8 is ancient and magnanimously outdated, it contains many bugs and other vulnerabilities. Itās not the fact that 1.8 as the game is bad, rather that itās not supported making it a disaster to maintain and support generally.
I agree
noone really uses vanilla 1.8 anymore
99% of smart people using it have a custom fork
Yeah and then they will have to fix all the vulnerability holes and adding/maintaining the api
^
tell tht to hypixel

Hypixel is irrelevant and a different story
Hex are you on 1.8 lmao
They have like 50 devs if not more maintaining their own 1.7 software
Bud they have their own very custom shit
WELL
I bet you have that
1.7 / 1.8 or idk
just get gud

hit delay is great
u prob click 3 cps
idc its great
You can change hit cooldown
One day Fortnite 2 will come out and all 1.8 servers will die out
Lmao
i dont need more to fight against the enderdragon
You can legit change iirc item attribute on an item making it identical to the cooldown in 1.8
Is that game still a thing?
Yeah only thing that's hard to get back from 1.8 combat is sword blocking
my guy
no idea
it wont be the same
Literally will
Another 1.8 discussion xd
Why are you referring to hypixel all the time? And ftr itās not 1.17 which is bad rather that they havenāt added item attributes to their items for later clients probably because it wouldnāt work well with some other stuff.
Anyways this is not the place to glorify ancient software.
Honestly if people don't like 1.9 pvp so much then they could just code a plugin to make their own pvp that's actually innovative and not a 1.8 port, and it still would be less effort than developing for 1.8
Item cooldowns add a lot of potential to pvp if people learned to accept them correctly instead of trying to swim upstream
You do realize it takes more code for higher mc versions right? It's not just cooldowns for pvp
More code?
Let's take for example checking the item in the players hand. In 1.9+ you have to check for the hand instead of just checking the item in hand. (Using a deprecated method)
player.getInventory.getItemInHand
I never found checking the held item to be difficult
^
Deprecated
not in 1.8?
Just one example
You just specify which hand
Exactly in 1.8 it's not in later versions you have to check which hand is being used
so?
it still gets read by newer versions
and works fine
And you gain a whole new active inventory slot to work with
wow
People would kill to have double handed combat before it was added
?cc add 188age https://howoldisminecraft188.today/
My point was you said it's more code to code for 1.8. Its not it's less code then 1.9+
?188age
That is true lmfao
Oh wtf
people were begging for 2 hands
Clearly with the amount of people having 1.8 specific problems that's not the case
Stop complaining about bad pvp and use the tools we were given to implement it better
Makes the rest of your plugin development much easier
I think you don't even need text component
I hate when "developers" complain about having to support older versions. Like it's your plugin don't support versions you don't want to. But don't complain that other developers don't mind supporting versions you dont.
Just string and ChatColor
How can i check if a player place a slab on top of another slab? I want to cancel that.
I thought it was with getRelative
you cant?
to be completely honest I dont even know what side everyone is on anymore lmfao
You can support 1.2.5 but it's gonna be hard to get any help
I have a new problem, I have some schedulers but when I do more than one at a time the systems glitch: https://pastebin.com/2u7JTLjM
On a development help channel it makes sense for people to push for updating
I mean, when a player puts a slab on another slab, the slab is a new block. I don't want that, I would like to cancel it.
Pretty sure it's because you're using a static counter
https://github.com/2Hex/Warps someone help me make this code better, tell me if it has spaghetti or smth
So I want to cancel it that he can then not place the slab
was just about to say that
Registering is for the main class
do it there
0 reason to have a class for it
Itās objectively worse to have a Registration like that
^
Have you an alternative?
Also your package naming is odd in the gui package
First of all the name is a lie
Youāre bootstrapping and creating new objects there also
Also sometimes you avoid nesting but other times you have brackets for 0 reason
^
also dont use static {
}
to begin with
no reason to make all that static
Individual tick counter inside your Runnable
They can have fields like normal classes
private int tick = 0 above run()
Also
dont check for config values like "first.second" make an enum or smth to check for it like Messages.NO_PERMISSION instead of "settings.nopermission"
removes room for error
@grim ice
Why not?
premium content
idk lmfao
o
full-length source code and behind the scenes footage
I am
just dont commit alot
only commit after alot of work
I should do it more
but
yeah
Yeah commit as often as possible (though I tend to only do it a few times a day at most cause I'm forgetful)
o
Ik but I also have a ssd which I use to transfer between mac and my pc
@grim ice you are using a class variable for something that's per-player, you likely want this class to be created for each player, or use a datastructure like Map (such that you can track each player)
You open it here: https://i.fvdh.dev/XshotjFR.png
In that method you overwrite the class variable: https://i.fvdh.dev/SVZsWusy.png
And you use the same datastructure in the InventoryClickEvent: https://i.fvdh.dev/lOVftwar.png
tl;dr, this will break with 2 players accessing a gui at the same time, allowing the first player to take items out the gui
Best use InventoryHolder to implement gui OO style
Your event listener only needs to check if the gui handler is an instance of your custom gui, then forward the event
or just create an instance per player using it
Thx now it works
o
how do u fix it doe
^
"you likely want this class to be created for each player, or use a datastructure like Map (such that you can track"
I suggest not map
https://github.com/KaktuszSok/KaktuszLogistics/blob/main/src/main/java/kaktusz/kaktuszlogistics/gui/CustomGUI.java this is how I do it @grim ice
spoonfeeding 
Using a map is not very expandable since it doesn't lend itself to keeping track of many variables per gui
thats not spoonfeeding
How?
Spoonfeed a newbie for a day and they'll come back with more questions. Teach them to find their own answers and you'll both be better off: you won't get stuck answering the easy questions and they'll be much more productive than before.
I don't expect him to copy it lol but I see what you mean
^
i wont copy it
dw
also how would 2 ppl run it at the same time
by both running the /warp command?
Is there any way to get an items' corresponding name in the game, or is Material.name() the best possible way?
idk exactly how to fix it
Why? They are per-instance
Sorry, meant materials name
If you want the locale name use TranslatableComponent
Cool, I'll look into that. Thanks!
Yeah it's a confusing bit cause say you have gui A which can take you to guis B or C. I need to keep track of the child gui per-player per-gui because if we both started on gui A, I might have opened gui B and you might have opened gui C. Then gui A has two different child GUIs depending which player you care about.
This seems outdated and bit weird indirect hashmap referencing
Using Inventoryholders is preferred over hashmap
using inventory holder is really not prefered over hashmap
injection of a custom inventory holder has always been consider unsupported API usage, afaik as far as an open PR to remove that possibility all together.
A simple Map<Inventory, DataClass> does the same for you and can easily be maintained by the InventoryCloseEvent
I heard differing opinions but it's one less thing to worry about when using holders, so if it is changed in the future an equally simple alternative should be added
I switched from map to holder and my code became cleaner
Marginally since it's only like one class but still
You can find information about contributing to Spigot at the following links:
https://www.spigotmc.org/wiki/cla/
https://www.spigotmc.org/wiki/guide-contributing-to-spigot/
https://hub.spigotmc.org/stash/projects/SPIGOT/repos/craftbukkit/browse/README.md
https://hub.spigotmc.org/stash/projects/SPIGOT/repos/craftbukkit/browse/CONTRIBUTING.md
well spigot xD
with?
You commit changes with git
if that is what you mean
oh like what I contributed ? š
declaration: package: org.bukkit, interface: RegionAccessor
I made that method xd
?paste
@grim ice I played a little more https://paste.md-5.net/evowazemur.java
o
do i remove the comments
comments bad
Do with as you like, but comments are good
and why r stuff not final
final is not really required in most instances
keeps the Item generation code outside the class
yes, you use teh same code you had, just do it in a method outside the class and put them all in a List
Then call openMenu(player, list)
for creating an 1.8-1.16 plugin is better using 1.8 paper or 1.16.5 paper? i saw some plugins where have native version in 1.16 and will support from 1.8
?paste
yep
can some one help please..
loop through entities, if the entity is an item and the item is a diamond remove it
imaginedev
can u recommend a way to learn
idk i feel like im not progressing
will it happen by time or do i have to do smth specific
Write more code. See how others write code
o
yea lol
Just work on projects
The placeholder API server has a channel called "request free"
I use that a lot when im out of ideas
@grim ice
oh and once your code is working, don't stop there. Look over it, tidy and try to make it run more efficiently
last bit of advice, comment everything
1.Maps rarely are passed through classes
-
Never hardcode if statements for things like quests, skills, create check objects
-
Always create an API for your classes and allow everything to be changed
-
Javadoc everywhere
wait.. I shouldnt pass a map through a class?
its like leaking data
ohhhh
true
but
whats the difference between a getter, and just making it public?
i guess getters are "safer", and just java tradition but in some cases public is used
example: local package dependent classes
a Getter means you can change any of the type Objects when you want.
the backing objects
got it
a getter just hands out the data, how you store that data is up to you in the class, but if you make Fields public you are locked in.
ok
could you explain 2, and i gotta learn how to do 3. Should i do that after my plugin is finished, or would it save time to do it now
make the api then the plugin, everything is 10x easier if you do it right
o
2 means things like very specific if tests you should wrap in a consumer and store the consumer in your class, not very specific tests.
hmm i see
i dont follow any of these
nice life ive got
idk hwo to make apis
can another plugin interact with the variables and stuff i have stored in my plugin?
design your API using interfaces
Your implementation is code the end user never needs
dont you have to use custom events for someone to edit stuff with your plugin?
-
static isnt to make life easier
-
understand OOP
-
abstract everything
-
understand object constants vs enums and when to use them
I use interfaces a lot but not too much
nope
Abstraction i get, i have no idea when its proper time to use static, and i know nothing about enums and constants. When i asked about them no one responded with anything helpful. And i cant find anything online about when you should use them
I get how to make an enum
Just not when its appropriate to use it
static is really simple but it gets abused. Basically assigning something static means there will only ever be one instance of that object across all your code.
ok, yea
i use it a few times
leme show you
public static void plantWateredHandler(BlockGrowEvent event, FarmingOverhaul plugin) {
Block block = event.getBlock();
PersistentDataContainer chunkData = block.getChunk().getPersistentDataContainer();
long delay = plugin.configTalker.getPlantDelay();
NamespacedKey blockKey = new NamespacedKey(plugin, block.getX() + "_" + block.getY() + "_" + block.getZ() + "_wateredTime");
//Check if block is specific type of plant if not, exit the event
if (!(block.getType() == Material.CARROT || block.getType() == Material.WHEAT || block.getType() == Material.BEETROOTS || block.getType() == Material.POTATOES))
return;
if (!(chunkData.has(blockKey, PersistentDataType.LONG))) {
event.setCancelled(true);
return;
}
if ((chunkData.get(blockKey, PersistentDataType.LONG) + delay) > System.currentTimeMillis()) {
event.setCancelled(true);
return;
}
chunkData.remove(blockKey);
}
I have this being called when a plant is trying to grow to check if its been watered
eg, if you create a class that you might create multiple instances of, but it has a map which ALL the instances need to access. You make the Map static.
private static
i look back at my code in galaxyshop, and i realize everything has to be extended, and nothing is implemented
example
interface EconomyHandler {
void sell(ItemStack i);
}
class MyApi {
@Getter
private static MyApi inst;
@Getter
@Setter
private EconomyHandler h;
{
inst = this;
}
}
How do I change a player name over their head? do I need to use nms?
?
nothing is implemented everything has to be extended
because im reviewing my code
i mean I should make more interfaces
class A implements Interface
class B extends Class
interface B extends Interface
Idk if this is a good system or not
The CustomItem is an interface
and the watering can, and breadier bread are items using that interface, and extending itemstack
Is there a event that fires when the player opens the inventory?
get rid of Object
It can be material or itemstack
it should be ItemStack
I check for it later
But if i do that, and the item has some random NBT from a different plugin
Then the recipe wont work
?
leme show you my recipe thing
seems like the other plugins fault
public void registerRecipes() {
//Loop through items and create a recipe
for (CustomItem item : plugin.configTalker.getItems().keySet()) {
if (!plugin.configTalker.getItems().get(item)) continue;
if (!plugin.configTalker.config.getBoolean(item.getName())) continue;
ShapedRecipe recipe = new ShapedRecipe(new NamespacedKey(plugin, item.getName()), item.getItem());
recipe.shape(item.getRow1(), item.getRow2(), item.getRow3());
//Loop through the ingredients, and set those
for (Character key : item.getIngredients().keySet()) {
if (item.getIngredients().get(key) instanceof ItemStack) {
recipe.setIngredient(key, new RecipeChoice.ExactChoice((ItemStack) item.getIngredients().get(key)));
} else if (item.getIngredients().get(key) instanceof Material) {
recipe.setIngredient(key, (Material) item.getIngredients().get(key));
}
}
plugin.getServer().addRecipe(recipe);
}
}
so it just makes the recipe with material if its a material, and an exact itemstack if its an itemstack
Cause on server startup, it checks if the item is enabled
why woildnt it be
Well
i have this in my config
wateringcan-enabled: true
and that also disables the wateringcan
so i dont want to also make them disable the recipe for it
items.put(new WateringCan(plugin), isCanEnabled());
items.put(new BreadierBread(plugin), true);
just remove the item š©
if (isCanEnabled()) {
items.put(new WateringCan(plugin));
}
you.. you make a good point
but
there was a reason i didnt do that
idk what it was
just do it
wait
you shouldnt ever have a map with a boolean
No..
I cant
Because the watering can doesnt have a config entry
so it would fuck up this line
tf are you on about
if (!plugin.configTalker.config.getBoolean(item.getName())) continue;
so i have to remove that line
and when i add the boolean to the map
add the getBoolean there
you need to recode this entire plugin
Is there a event that fires when the player opens the inventory?
package me.silentprogram.farmingoverhaul.configstuff;
import me.silentprogram.farmingoverhaul.FarmingOverhaul;
import me.silentprogram.farmingoverhaul.items.BreadierBread;
import me.silentprogram.farmingoverhaul.items.CustomItem;
import me.silentprogram.farmingoverhaul.items.WateringCan;
import org.bukkit.configuration.file.FileConfiguration;
import java.util.HashMap;
import java.util.Map;
public class ConfigTalker {
public FileConfiguration config;
Map<CustomItem, Boolean> items = new HashMap<>();
FarmingOverhaul plugin;
WateringCan wateringCan;
BreadierBread breadierBread;
public ConfigTalker(FarmingOverhaul plugin) {
this.plugin = plugin;
config = plugin.getConfig();
initializeItems();
}
public int getPlantDelay() {
if (config.getBoolean("enable-plant-timer")) {
return config.getInt("plant-delay") * 60000;
}
return 1;
}
public boolean isCanEnabled() {
return config.getBoolean("wateringcan-enabled");
}
public boolean isAntiInbreedEnabled() {
return config.getBoolean("anti-inbreeding-enabled");
}
public boolean isSkyLightEnabled() {
return config.getBoolean("sky-light-enabled");
}
public Map<CustomItem, Boolean> getItems() {
return items;
}
public boolean isItemEnabled(String itemName){
return config.getBoolean(itemName);
}
public void initializeItems() {
breadierBread = new BreadierBread(plugin);
wateringCan = new WateringCan(plugin);
items.put(wateringCan, isCanEnabled());
items.put(breadierBread, isItemEnabled(breadierBread.getName()));
}
}
@quaint mantle
i see nothing wrong here
click doesn;t work?
its registered?
@eternal oxide do you see anything wrong there?
mostly with initializeItems()
Why a Map with your items and the enabled state? When you have methods to check the enabled state
Just create your items when you need them
because some items use isItemEnabled() and others will use other methods like isCanEnabled()
why?
Because wateringcan-enabled in the config also disables some listeners
You have custom classes for each object, just put an isEnabled in the class

yea
i guesse i shouldve seen that coming
damn...
im sad now
Why does my InteractListener trigger if I trigger my DropListener?
public class DropListener implements Listener {
@EventHandler
public void onDrop(PlayerDropItemEvent event) {
Player player = event.getPlayer();
event.setCancelled(true);
player.sendMessage("pressed q");
}
}
i think it counts as an interact if a player drops an item
i could be wrong
Elgar would probably know
but there is no Action Action.DROP such as Action.LEFT_CLICK
What Interact listener?
However, when you drop an item you trigger an Interact event with the block the item lands on
It could be a pressure plate
ye it doesnt
or farmland etc
guess what I'm going to say...
"debug"
It triggers the Action.LEFT_CLICK_AIR || Action.LEFT_CLICK_AIR tho
No clue on that
You did notice the contains method now. It takes a player and an inventory
as this code should support multiple players
BUT DUDE
HOW IS IT NOT WORKING NO
NOW
ITS LEGIT THE FUCKING SAME
WHAT THE FUCK?
IM GONNA SHOT MYSEL
F
I've not tested it, but I see nothing broken in the code
breh
add some sysouts and see where its gets to in the event
it only has like 4 places that could use a sysout
https://github.com/Silent-Program/FarmingOverhaul/commit/c607c7f6b8f437aa2a66af141dfb9a69c2d2202d
The changes i made with my item registerer
Hi, so I want ot make a poll plugin and the command would be /poll <"question"> <answer1> <answer2>, but how can I put the argument inside the quotation marks into one string and not multiple arugments?
This is what I have atm:
if (args.length > 3){
for (int s = 0; s < args.length; s++){
System.out.println(args[s]);
if (args[s].startsWith("\"") || args[s].endsWith("\"")){
System.out.println("arg starts/ends with \""+args[s]);
}
}
}```
when u get a debug at the beginning of the code: OH THANK GOD
ok thanks I'm going to take a look at that
@eternal oxide
if (!event.getClickedInventory().getTitle().contains(ChatColor.GREEN + "Warps")) {
System.out.println("doesnt contain");
return;
}
this was triggered
Ohno comparing by title
yes.
You shoudl not be using titles anymore
š³
use teh contains method in GuiMenu
persistent data container go brrrrrrr
BRO
I DIDNT
NOTICE
IT WAS MENU:
not WARPD
AIIRJGHAUOEFHBAUOBGFAWUEOBGFAWOEBGAIBAIRBGRIUFBEGEBUERBGUERBGERUBGE'G
fam
change to use teh contains method
its 1.8
ok
if (contains(player, inventory))
PDC on an inventory? Wat
pdc for inventory when
Fair enough
I usually like to identify the inventory too
for 1.8 NBT
Need some Help with the ProtocolLib, i try to listen on the BLOCK_BREAK_ANIMATION packet.
But the listener will not be triggered, other packets worked fine for me.
Its my first time using ProtocolLib, maybe i did something wrong ?
https://paste.md-5.net/baciseyivi.java
yes but !
Oh yes i forgot that
Yep, I just checked the class and it works perfectly
@grim ice use this to add, and check for NBT
what
Works from 1.8 to 1.17
Yea
wooo
tbh i used to use pdcs in every plugin i make but now i make 1.8.8 plugins so i dont have it :<
if this thingy works well ill use it
item = NBTEditor.set(item, "value", "key");
wait thats actually easier than normal pdcs isnt it
I used it instead of PDC for a while
yea
I usually use NBTAPI
But you should just use normal PDC
pdc is easy af
but it also avoids clashing even if the devs are dum
Yea
wdym
its not
usually i pass plugin on every class i make
becuz config
there is also just ```java
NamespacedKey.fromString("mynamespace:key");
for the kids that know what they are doing
actually?
declaration: package: org.bukkit, class: NamespacedKey
what ?
don't call me a liar!
It was added in 1.17.1
well what pleb isn't on 1.17
can the key just be "wateringCan"
key can be whatever key you want
aight
namespace should just be 100% unique to your plugin
and your plugin only
if you fail at that, be ready for explosions
kaboom
canData.set(NamespacedKey.fromString("isWateringCan"), PersistentDataType.BYTE, (byte) 1);
canData.set(NamespacedKey.fromString("waterLeft"), PersistentDataType.INTEGER, 10);
so, farmingoverhaul:isWateringCan
yea
or just be normal and create a public static final somewhere
canData.get(NamespacedKey.fromString("waterLeft"), PersistentDataType.INTEGER);
Your namespace should be a constant. You should create one public static final one
too slow :>
-.-
XD
so just a string, that i do namespace + ":key"
What
public static final NamespacedKey IS_WATERING_CAN = NamespacedKey.fromString("farmingoverhaul:isWateringCan");
don't re-create the namespaced key every time you use it
oh, what if i have like 100 namespaced keys
Then you are going to have a lot of static final fields
should i make a class that just has a shit-ton of static fields in it?
Or you could use a factory pattern
idk how to do that
someone was talking about it earlier
and i tried looking it up
public class NameSpacedKeys {
public static final NamespacedKey IS_WATERING_CAN = NamespacedKey.fromString("farmingoverhaul:isWateringCan");
public static final NamespacedKey WATER_LEFT = NamespacedKey.fromString("farmingoverhaul:waterLeft");
}
canData.set(NameSpacedKeys.IS_WATERING_CAN, PersistentDataType.BYTE, (byte) 1);
canData.set(NameSpacedKeys.WATER_LEFT, PersistentDataType.INTEGER, 10);
like that?
cancel the event?
by the way im writing without looking at my screen because im looking at the tv
HOLY FRICK I WROTE THIS WITHOUT MISTAKES
what eevent

I just installed IntelliJ IDEA on a new computer, and tried opening an old bukkit project. However, when I build the jar and reload the server, I get this error in console. How do I fix it?
org.bukkit.plugin.InvalidPluginException: java.lang.UnsupportedClassVersionError: com/commandgeek/geektest/Main has been compiled by a more recent version of the Java Runtime (class file version 60.0), this version of the Java Runtime only recognizes class file versions up to 52.0```
use java version 1.8
in your project
idk how to do it in intellij
it just kinda works for me
in eclipse i know how
leme look
Click event should be trigged for hornets as well
make it match ur server java version
declaration: package: org.bukkit.event.inventory, enum: InventoryAction
Yes hornets
true
@eternal night is this right?
always has been for me ĀÆ_(ć)_/ĀÆ
thats not an event
help
fuck
looks good
bet
wait
NamespacedKey blockKey = new NamespacedKey(plugin, block.getX() + "_" + block.getY() + "_" + block.getZ() + "_wateredTime");
should i just leave this alone
since the key changes depending on the block location
Why. The key doesnt need to hold any data. And it shouldnt.
I mean seems like a Chunk PDC key
which should use block pos
instead of x y and z
Fun fact: You can represent the relative location of a block within a chunk with a single 32 bit int.
not fun :DDDDDDDD
exactly what I was about to say
(x << 24) + (y << 16) + z
But for custom block data which is saved within a chunk i would def write a new PersistentDataType that loads all data into memory when the chunk is loaded
instead of constantly accessing the PDC of the chunk
Although no, y can be higher than 255 and smaller than 0 now
Full explanation:
https://www.spigotmc.org/threads/tracking-blocks-that-were-placed-by-players.500216/
hmm, this would require rethinking
public static int getRelativeChunkPosition(final Block block) {
final int relX = block.getX() % 16;
final int relZ = block.getZ() % 16;
final int relY = block.getY();
return (relY & 0xFFFF) | ((relX & 0xFF) << 16) | ((relZ & 0xFF) << 24);
}
people linking their own post smh
?pdc

is that u in ur pfp btw
how tf can getConfigTalker be null???
if so, u look like mrbeast wtf
public ConfigTalker configTalker;
@Override
public void onEnable() {
startup();
}
@Override
public void onDisable() {
// Plugin shutdown logic
}
public void startup() {
//Initialize config
saveDefaultConfig();
//Register my config talker
configTalker = new ConfigTalker(this);
//Register listener
getServer().getPluginManager().registerEvents(new Listeners(this), this);
//If the watering can is disabled then ignore this
new RecipeHandler(this).registerRecipes();
}
public ConfigTalker getConfigTalker(){
return configTalker;
}
how is configTalker null..
Did you use it in your constructor?
ALSO
or clinit (unlikely) or cinit (also unlikely)
public WateringCan(FarmingOverhaul plugin) {
super(Material.CLOCK);
isEnabled = plugin.getConfigTalker().isCanEnabled();
thats in a constructor
this sounds strange, like if your main class has a constructor
@lost matrix
public void onBeak(BlockBreakEvent event){
int value = config.getInt("path"):
config.set("path", value + 1);
}
ez
what ab doing it in one line
wait
but for the same block it would result in two different int ids
call startup() within the constructor
or push all the code you have in your constructor in the onEnable block
there should only be one?
the constructor of the main class that is
for wich class
there is none
OH
I thought you were talking about smthng else
package me.silentprogram.farmingoverhaul;
import me.silentprogram.farmingoverhaul.configstuff.ConfigTalker;
import me.silentprogram.farmingoverhaul.listeners.Listeners;
import me.silentprogram.farmingoverhaul.recipes.RecipeHandler;
import org.bukkit.plugin.java.JavaPlugin;
/*
-- Means it is finished
Animals:
Breeding animals has benefit
-- You cant breed the same family together
Animals require space to live (maybe?)
Farming:
Benefit to farming, probably potion effects/new food items
Add breadier bread
Enchant to break 4x4 crops
Also find a way to make hoes useful
-- If you dont take care of crops they dont grow
-- To achieve this, add a NBT tag of the current time, or minecraft day. And let them only water plants once a day
-- then add a listener to check when a plant grows(BlockGrowEvent) check if it has been watered in the past day if not
-- cancel the event, if it has let it grow, and reset the timer
-- Add watering can or smthng,
Make watering can require water
Add a end-game block that auto-waters probably gained through farming or just a nether star
-- If a plant is inside, it affects how it grows
-- Use Block.getLightFromSky()
Possibly add:
Falling trees enchant
*/
public final class FarmingOverhaul extends JavaPlugin {
ConfigTalker configTalker;
@Override
public void onEnable() {
startup();
}
@Override
public void onDisable() {
// Plugin shutdown logic
}
public void startup() {
//Initialize config
saveDefaultConfig();
//Register my config talker
configTalker = new ConfigTalker(this);
//Register listener
getServer().getPluginManager().registerEvents(new Listeners(this), this);
//If the watering can is disabled then ignore this
new RecipeHandler(this).registerRecipes();
}
public ConfigTalker getConfigTalker(){
return configTalker;
}
}
You showed me a completely unrelated ctor
thats the whole class
i showed you wher eit was erroring
and it was erroring in another constructor
where do you call WateringCan
it is
configTalker = new ConfigTalker(this);
configTalker.initializeItems();
should fix it
Wouldn't recommend it
instead, pass the instance of ConfigTalker through the Constructor of it to the constructor of WateringCan
wait why
Creating another hyper-specialised method that is required and easy to forget to call
its already created
i just moved it out of the constructor
and into onEnable
of ConfigTalker
I'm talking abt initializeItems this method should not be there
There should almost never be an initaliation method outside of the static init block, the non-static init block and the constructor
That being said, this is my opinion
ill clean it up later if i need to
Worked perfectly thank you!
š
WHY DOES
if (!(player.getHealth() - event.getFinalDamage() <= 4)) return;
NOT WORK
someone pls help it urgent
is libraries property, in plugin.yml, 1.17 or higher only?
Latest 1.16.5 should contain it too
@EventHandler
public void onDamage(EntityDamageEvent event) {
if (getConfig().getBoolean("toggle")) {
if (!(event.getEntity() instanceof Player)) return;
Player player = (Player) event.getEntity();
if (!(player.getHealth() - event.getFinalDamage() <= 4)) return;
List<String> worlds = getConfig().getStringList("world");
if(!worlds.contains(player.getWorld().getName())) return;
double x = getConfig().getDouble("deathrally.x");
double y = getConfig().getDouble("deathrally.u");
double z = getConfig().getDouble("deathrally.z");
Location loc = new Location(player.getWorld(), x, y, z);
event.setCancelled(true);
player.teleport(loc);
}```
why is this not working
why ?
Add some debug messages
if (!(player.getHealth() - event.getFinalDamage() <= 4)) return;
you might want to test if the player's health is updated before or after the event is triggered
After
Yeah since its a Cancellable obviously
btw you can debug a server through intellij remote debug, debug messages are essentially just a easy ("noob"?) way of doing it.
Is the 1.17 bundle added to Spigot? I cannot find it.
I don't think EntityDamageEvent runs if the hit kills the entity. I could be wrong. Try debugging it.
4 = 2 hearts
If you return you are doing nothing and letting the event happen
and instead of doing if (!( health <= 4)) just use if (health > 4)
Well ofc but I can't be bothered guiding the setup for that. I do use it myself though
Evalute expressions are quite convenient at times
Yeah, understandable
Also can get annoying if your server just crashes because you were debugging for too long
True
I have a String set to an ItemMeta's displayName, I'm trying to figure out which color codes are at the front. How can I do that?
sysout the get health
perhaps you have some plugin thats adjusting the health multiplier
What is a goos cheap hosting site?
if you wanna test your plugins do it locally
@vague mason
is to possible to send a sound not on the master volume but on something else?
LOL
so is localhostš
if u dont like it, just shut up
not being able to test your plugin locally is pretty trash
you loose the option to properly debug
What?
specs online are usually trash for free tier
wtf r u saying
setting up a database/anything external is nearly impossible on free minecraft server providers
how to use chatcolor alternate color codes thing
Not mines @onyx fjord can confirm that š
that free servers from hosting providers are always trash.
true in most cases
is having 2 for loops inside 1 for loop bad
i mean ofc it is but im asking for the severity lol
I'm making an economy plugin with ValutAPI, if i understand correctly i need to implement Economy and Override all methods ?
(just making sure)
You can get a root server with an old i7 and 32Gigs of ram for 30 bucks a month.
There you can host your server, proxy, database, website and all the dc bots you want.
hey guys anyone know if its possible to change the max durability of an item?
yea the worst part about hosting stuff is that you need a reseller for smaller machines
uh i said everything i could i think
Nope. Only with tricks. But not the actual value
like you can get 128GB ram server for 60 eur but you dont need it
and it becomes really cheap per gigabyte
explain please? :)
and this is exactly why I have decided to make my own hosting
to split those dedicated servers and provide services for cheap price.
hahaha yeah
imo that kind of stuff should be illegal
You cant change the actual max damage but you can tag your ItemStacks pdc and only apply 10% of the damage events which gives the ItemStack
an 10x effective durability
how do u upload a plugin to spigotmc.org
thx
no problem sir
cool so like i can change the numbers through nms and just simulate it?
You dont need any NMS for that.
And you cant change any numbers that would be of importance here in nms
I have a String set to an ItemMeta's displayName, I'm trying to figure out which color codes are at the front. How can I do that?
got a specific class i can look at there is a lot there
i could go through it but if you know it it would same me a lot of time :)
I'm also looking for some beta testers, that would (click random things, try to break something and provide me some suggestions...) It shouldn't take you more than 5 minutes and you don't need to install anything you can just access it from website.
Let's try it
how can I make sure that when taking an object in 2 hands, it is used only in 1?
if(e.getAction() == Action.RIGHT_CLICK_AIR || e.getAction() == Action.RIGHT_CLICK_BLOCK) {
how do u set an icon for ur plugin after it has been published?
nvm found it under resource tools
anyone know how to force a raid to start?
is there any way to tell if something is a baby from getEntityType?
https://paste.md-5.net/asiwaliquq.java
Why is Condition 'players.size() > 1' is always 'true'
and Condition 'players.isEmpty()' is always 'false' ??
pls help
@eternal oxide if u can lol
@grim ice
brb ill come bak and see what u guys said thx in advance
Because players isn't empty ??
You are online so unless there is someone else > 1 shoudl be false
what exactly is players?
Also the for loop wouldn't run if players were empty
ah a paste
Curious question what would be the beast way to make gui shop
- checking slot on click and checking config for that slot what actions should be done
- Storing all data about that item to it's PersistentDataContainer
You are including yourself in players.
@eternal oxide you have any suggestions
@wary harness
There is isAdult() in Ageable
declaration: package: org.bukkit.entity, interface: Ageable
You are asking how to write teh whole plugin
jsut curious
what is the best action is it PersistentDataContainer
good idea
ive tried that it doesnt exist for some reason
like store commands which will be runned
Cast it to Ageable

