#help-development
1 messages · Page 1832 of 1
I just need the chatcolor object because setting the glow color (of an npc) and team color requires it
where's the skript code / functionality?
you should be able to do if (color == Color.RED) return ChatColor.RED
why did I even bother converting to a bukkit color
better yet make that a switch statement
🤦♂️
yeah I was trying to make a switch statement at first then realized that org.bukkit.Color wasn't an enum
anyways thank you for your help
hmmmm
.equals
doesn't change anything
what can cause this?
at com.google.gson.internal.$Gson$Types.resolve($Gson$Types.java:383) ~[server.jar:git-Spigot-cbd1a1b-009d8af]
at com.google.gson.internal.$Gson$Types.resolve($Gson$Types.java:358) ~[server.jar:git-Spigot-cbd1a1b-009d8af]
at com.google.gson.internal.bind.ReflectiveTypeAdapterFactory.getBoundFields(ReflectiveTypeAdapterFactory.java:158) ~[server.jar:git-Spigot-cbd1a1b-009d8af]
at com.google.gson.internal.bind.ReflectiveTypeAdapterFactory.create(ReflectiveTypeAdapterFactory.java:100) ~[server.jar:git-Spigot-cbd1a1b-009d8af]
at com.google.gson.Gson.getAdapter(Gson.java:423) ~[server.jar:git-Spigot-cbd1a1b-009d8af]
at com.google.gson.internal.bind.ReflectiveTypeAdapterFactory.createBoundField(ReflectiveTypeAda
we need the whole error
?paste
it's the whole, it also throws StackOverflowException and repeats what i wrote
it's infinite recursion ig
this is the class
package com.aregcraft.customstevechaos.game.world;
import com.google.gson.annotations.SerializedName;
import lombok.*;
import org.bukkit.Location;
import java.util.List;
import java.util.Map;
import java.util.UUID;
@Getter
@Setter
@Builder
@NoArgsConstructor
@AllArgsConstructor
public class GameMap {
private String name;
private UUID uuid;
@SerializedName("mob_arenas") private List<SpawnArea> mobArenas;
@SerializedName("duel_arenas") private Map<BiSpawnArea, SpawnArea> duelArenas;
@SerializedName("spawn_area") private SpawnArea spawnArea;
@SerializedName("upgrade_location") private Location upgradeLocation;
@SerializedName("trash_location") private Location trashLocation;
@SerializedName("shop_location") private Location shopLocation;
@SerializedName("bets_location") private Location betsLocation;
}
with only name and uuid it works fine
also all the fields except name and uuid is null
at serialization moment
Why so many annotations
the top ones is for setters, getters, constructors, for the fields, i want to use snake_case
ig the problem is in Location
for some reason it can't be serialized by gson
Oh. Plus i had to go to bed right when i posted tht
Hello. I want to know if I can made a custom Thread implementation so i can use: throws Exception Oracle will allow me?
You can extend Thread and throw any exception you want
i dont think u even need to extend Thread to do that
true
Caused by: java.lang.IllegalStateException
at com.google.gson.stream.JsonWriter.name(JsonWriter.java:390) ~[server.jar:git-Spigot-cbd1a1b-009d8af]
????
@Override
public void write(JsonWriter out, Location value) throws IOException {
if (value == null) return;
out.name("world").value(Objects.requireNonNull(value.getWorld()).getUID().toString())
.name("x").value(value.getX())
.name("y").value(value.getY())
.name("z").value(value.getZ())
.name("yaw").value(value.getYaw())
.name("pitch").value(value.getPitch());
}
you checked the docs for JsonWriter::name to see why it may throw illegal state?
it don't say
not surprised
but from source code it's
if (deferredName != null) {
throw new IllegalStateException();
}
what's deferredName?
idk
you know don't?
I know don't too
such a crazy coincidence
anyway gimme a sec
ok so it seems to be throwing that exception on the first name call
since deferredName is set to name after it's checked
and what am i supposed to do?
meaning you're probably missing a few method calls
like beginObject and endObject?
I don't know
never used this API
yeah
you need to call beginObject and endObject before and after any other calls it seems
it still throws the same exception
show me your code now?
@Override
public void write(JsonWriter out, Location value) throws IOException {
if (value == null) return;
out.beginObject().name("world").value(Objects.requireNonNull(value.getWorld()).getUID().toString())
.name("x").value(value.getX())
.name("y").value(value.getY())
.name("z").value(value.getZ())
.name("yaw").value(value.getYaw())
.name("pitch").value(value.getPitch()).endObject();
}
hmm
I don't know why it's doing that
could you try putting each call on a separate line
tried
and then giving me the line and column number of the error within your class?
also having the full class'd be nice too
[04:05:38] [Server thread/ERROR]: "Silently" catching entity tracking error.
net.minecraft.server.v1_8_R3.ReportedException: Adding entity to track```
Anyone seen this error before?
gson.toJson(maps.get(uuid), writer);
private final Gson gson = new GsonBuilder().setPrettyPrinting().registerTypeAdapter(Location.class,
new LocationAdapter()).create();
ah that makes sense
so I guess Gson doesn't show me the line of the adapter since it uses some kind of reflective wrapper
Hi 1.18.1 Spigot Jar Is too Heavy Like i Have 45 Plugins and 6.3GB Ram but it crashes my server is it gonna be the same or will they reduce it ?
oh
that's strange
anyway gj
how can i add a default value that is not 0 to an int in mysql?
something like this maybe?
I feel the static usage in my veins
what?
i was missing a ,?
Hey all, I'm working with anvils & enchantments and I'm having a strange issue. What I've done so far is changed the max enchantment level for every item that accepts enchantments. Here's the current problem I'm trying to tackle.
I'm attempting to remove the block that prevents the player from having multiple protection types on a single piece of armour, I've successfully got the result in the anvil, but I'm unable to take the result out as it costs nothing (When I log the value, it states 1xp level. and i've attempted to use SetRepairCost() however it has no effect)
Just looking for general direction to search in as I feel I've exhausted all my options
you could change the result to an item with no enchants and make the lore the enchants
and when they get it in the inventory, replace it
idk if it will work
how would I go about making a specific mob follow another specific mob but not with hostile intent?
The repair cost needs to be set basically through the scheduler, updating the inventory after the change is made and it's ready
Bukkit.getScheduler().runTask(plugin, () -> {
event.getInventory().setRepairCost(repairCost);
event.setResult(result);
player.updateInventory();
});```
Basically you set the cost the next tick
How can I detect how long a player has been awake? and if you've been awake for a long time an event will run
schedulers, probably
Pretty much, run a timer that ticks down until 0 or the player sleeps (PlayerLeaveBedEvent + check if day)
Throws, not throw
You throw an exception, an object throws an exception
I dont want to use try-catch. I want to use this:
public methodName () throws Exception {}
So my library looks cleaner
The one who use the library should made try-catch
Is there a way to cause the ender dragon respawn to occur. I don't mean by just summoning another dragon, I mean the type of respawn that happens when you place the 4 end crystals on the portal frame and it has the animation and replaces all the broken end crystals and such. I tried summoning the four end crystals at the right coordinates but it doesn't seem to work unless a player places them down
Legend!! Works like a charm!
States:
Checks if the specified BlockData matches this block data.
The semantics of this method are such that for manually created or modified BlockData it has the same effect as Object.equals(java.lang.Object), whilst for parsed data (that to which merge(org.bukkit.block.data.BlockData) applies, it will return true when the type and all explicitly set states match.
Note that these semantics mean that a.matches(b) may not be the same as b.matches(a)
in my test plugin, I'm clearly manually creating the BlockData, But I want the behavior of a 'parsed' BlockData.
https://gist.github.com/ryantheleach/8201d2b75da86013cff7a0be5dfee1ee
How can I get a 'parsed' BlockData?
will this create an new decimalformat instance whenever the run method is called?
@tardy delta yes.
Do u agree to my message?
no not for actionbars
Ah btw
Why people its agresive here?
What's your version?
I'm not being aggressive.
Ah ok
i'm using mc version 1.16.5
you should see paper
lol
If you don't want player.spigot() there is an nms solution but again its nms
just use the spigot method
Why people hate nms
cause it’s not an api
How can I make a command to reload my config? I have got a reload method in my main file
public static void reloadSVL() {
reloadConfig();
}
And then in my command class I reference it
@CommandAlias("svl|simplevotelistener")
public class SVLCommand extends BaseCommand {
@Subcommand("reload")
@CommandPermission("SVL.reload")
@Description("Reloads the configuration file")
public static void onReload(CommandSender sender, String[] args) {
SVL.reloadSVL();
}
}
But the command class wants it to be static and the reload function doesn't want it to be static
its pain
or you can use something like dependency injection and use the main class instance in your command class
Is there an unbreakable flag in spigot version 1.17?
?di
Guide to dependency injection: https://www.spigotmc.org/wiki/using-dependency-injection/
ty
?paste there your code
oh, i'll update my github
Ok
easier than making loads of paste files 😆
Yea
It’s existed from 1.8 at least I believe
yeah i know, i made an unbreakable command for myself, but updated my server to 1.17 and the command didnt work. But thanks for helping me out 🙂
If you’re talking about the give command, the format for it has changed
Nope not the give, just an simple command that makes the item that you're holding unbreakable.
Gotcha
So your problem here, is that you had them the wrong way round. it's wide.matches(narrow) not narrow.matches(wide)
Shouldn’t the method be symmetrical
Nope! read the JD
It explicitly said about it violating symetry
Note that these semantics mean that a.matches(b) may not be the same as b.matches(a)
Neat
It didn't however clarify, which was supposed to be the 'wider' type though
I thought it was block.matches(predicate) not predicate.matches(block) which is clearly wrong with hindsight
You know how to define this in the newer versions? I always coded 1.8.9 - 1.12.2 so idk about this lol.
you need to cast the itemmeta to damageable
iirc
actually maybe just the normal itemmeta is fine
make an command that makes the item that im holding unbreakable
declaration: package: org.bukkit.inventory.meta, interface: ItemMeta
thanks for helping 🙂
Np sir. We are for help
^ if anyone has time to see if this is even possible
is there a tutorial somewhere how to use the hikaridatasource?
i found this but i dont know if i need it
https://github.com/brettwooldridge/HikariCP#popular-datasource-class-names
https://www.spigotmc.org/threads/re-spawning-the-ender-dragon.255183/ might be a helpful read
ah unbreakable finally made it out of spigot api and into bukkit?!
How can I remove all bossbars? And make them not visible to any of players.
I've tried this, but the bossbar is still visible to player
Iterator<KeyedBossBar> iterator = Bukkit.getBossBars();
while(iterator.hasNext()){
KeyedBossBar bossBar = iterator.next();
bossBar.setVisible(false);
bossBar.removeAll();
}
Thanks! Ill take a look at this
Looks like you’ll have to use packets
https://www.spigotmc.org/threads/hide-wither-bar.343196/#post-3190149
There's a wiki on the github page
i doubt that you need packet tho
¯_(ツ)_/¯ if you find another way by all means use it
declaration: package: org.bukkit.entity, interface: Boss
That could work actually
You simply use Bukkit#createBossBar to create a bossbar
Oh
I created BossBar, the one on Bukkit#getBossBars are KeyedBossBars
Mate are you trying to MAKE a bossbar or HIDE it
So you can get the bossbar linked to the entity and remove the players from it
It's not linked to any entity
So where are they coming from?
I don't know the details
🤦♂️
me imagine someone rewrite every codes from mojank then remove the eula thingy from the jar and public the source 😎
You don't need to create an entity to create a bossbar anymore
I know
declaration: package: org.bukkit, class: Bukkit
Look into that API
yeah i figured it out man
i figured it out on my own
wtf are you asking bro
i mean there are some fully open source mc server implementations iirc
i think Glowstone is nms free
Not complete tho?
mojank
Because generally it’d be a pain to keep up with nms
ye, i did it thanks
yeah its still on like 1.12.2 sadly
why would that guy want to remove the message?
was with setHealthScaled(true)
Ah
i cant imagine how people in mojank know how to maintain mc code lul
afaik its a ground up (re?-)implementation
Hmm yeah, I know impls like minestom and krypton but they’re far from being denoted as fully implemented. Altho minestom aims for another goal.
I'm creating a plugin for custom items using this tutorial https://www.spigotmc.org/wiki/custom-item-models-in-1-9-and-up/?noRedirect=1 but the link for accidentailgames(3rd link) returns some misc page
The home of Spigot a high performance, no lag customized CraftBukkit Minecraft server API, and BungeeCord, the cloud server proxy.
yeah im pretty sure glowstone is considered stable for up to 1.12.2
ooo it has a 1.16.5 version now, indev tho
I don’t know a lot about glowstone so can’t speak for it but yeah
it's a NBTTag to set the CustomModelData and there is also a method in spigot
In 1.14+ at least
Remapped
Anyone know why this:
System.out.println(enchantmentsSection);
System.out.println(enchantmentsSection.getKeys(false));
Causes that output statement?
config:
0:
material: STONE_AXE
name: "&cSharpened Axe"
enchantments:
SHARPNESS: 2
FIRE_ASPECT: 1
chance: 0.05
minAmount: 1
maxAmount: 1
the enchantmentsSection is the enchantments: of the config
Hey guys, how can I send boss bar to all players using packets??
ConfigurationSection enchantmentsSection = section.getConfigurationSection("enchantments");
I do know that we need to use the API but idk exactly how
I did and I already found it but I want to know how I can keep the bossbar forever
Does someone by chance have a idea setup to launch and update a plugin in the IDE?
Similar to how fabric and force can contain and run a server in-ide
Hey! do anyone know how to solve this error? mysql db
why is the MySQL one striked through?
nvm, I've just set up one myself
yeah with gradle tasks its pretty simple
oh
⚠ The MySQL DataSource is known to be broken with respect to network timeout support. Use jdbcUrl configuration instead.
Cause it’s not a config section, it’s a list
Never mind that should work
That’s the whole code of the print log?
I'm sticking with maven
Just define a artifact that builds the jar and copies dependency, target a server you have somewhere and just define a jar run config with the artifacts as before launch tasks
Really easy
Turns out that that specific section was working, but there were other enchant-less sections where it was throwing an error
yuh altho a drawback with that is that the run config is not replicate-able for someone if they dont use intellij and you dont share the .idea config folder
Problem
?paste @worldly steppe
Skill issue
how?
If you consider yourself a developer, you should know how to use your tools
plus, ide specific configurations have no business being in vsc repos anyway
well, it makes it a hella lot easier if people can just clone your upstream and get it to work
To be fair, no one except people capable of developing their own software does that anyway
You can have the best documentation and readme outline a step to step list and people will still fail, complain and ask
And in the end just give up and ask or wait for you to build one
(Or pay someone to do it, which I genuinely had someone approach me for once)
doesnt take away the fact that providing a good setup will simplify things for your users, for instance forge could just simply have a gradle plugin you'd add, altho that would for sure make people complain about the complexity of setting it up, by providing a fully working setup there are few who ask questions in regards to confusion and misunderstandings.
By your logic @halcyon mica there’s no point in having open source projects
thats at least my very take on it, tho Ig one wants to make it cumbrous for others to use and contribute then so be it
There isn't if your target audience has no interest in the source
¯_(ツ)_/¯
If you don’t wanna conform to standards you do you
I always love hunting down a projects dependencies checking their versions and manually doing it
What do you guys thing, should one introduce unnecessary variables for better code readability?
good
they're called explanatory variables
and make code hella lot more readable
if (a == b || b == c && (ab == d || dd == d)) is hard to understand
boolean isEntityDeadOrInvalid = a == b || b == c && (ab == d || dd == d)
if (isEntityDeadOrInvalid) {
}
reads like well written prose
could someone tell me what's wrong here? i don't understand, is mysql
if(cpName.equalsIgnoreCase("Chestplate of the Void") && lgName.equals("Leggings of the Void") && btName.equals("Boots of the Void")){
player.sendMessage("true");
}
It doesn't execute the code inside of that statement. The code for the items is the following:
Player player = (Player) damager;
ItemStack cp = player.getInventory().getChestplate();
ItemStack lg = player.getInventory().getLeggings();
ItemStack bt = player.getInventory().getBoots();
String cpName = cp.getItemMeta().getDisplayName();
String lgName = lg.getItemMeta().getDisplayName();
String btName = bt.getItemMeta().getDisplayName();
Huh, this is odd
Apperantly remapping with mojmap causes some issues
It builds and remaps properly, but executing it immediatly causes issues
Which I suppose means it does not remap properly, as Level is mojmap
the user used not has permissions for this
but is localhost
yeah but all users created need permissions
if is local/remote is another thing
i'm doing the mysql thing by XAMPP
localhost
i don't think are the permissions
but i don't know what could be
if you read the image send tell the user cannot use SELECT
by default exists the root user with all perms but if you create a new user need has a few perms..
i'm using root as username
the image tell you are using "pma"
that's in config.yml
username: "root"
why a ! in the database name?
ok and the console tell another thing?
you show the error in phpmyadmin (maybe bad installation)
while enabling the plugin
it says that is connected
(onEnable method)
but works in plugin?
i ask this because your first image was from phpmyadmin
kindergarten nugget chicken
cause the class?
you should implement commandexecutor
or tabexecuter if you use tab completer
Why doesn't this work?
Location deathWorld = new Location(Bukkit.getWorld("purgatory"), 0, 63, 0);
p.teleport(deathWorld);
(the world is created with multiverse)
public abstract class AbstractCommand implements CommandExecutor {
protected final DeanLoot plugin;
private final String permission;
public AbstractCommand(DeanLoot plugin, String command) {
this.plugin = plugin;
this.permission = command;
if (command == null) throw new NullPointerException("command is marked non-null but is null");
}
public boolean onCommand(CommandSender sender, Command cmd, String lb, String[] args) {
if (sender instanceof Player) return true;
if (!sender.hasPermission(this.permission)) {
sender.sendMessage("§cVocê não tem permissão para executar este comando"); return true;
}
plugin.getServer().getScheduler().runTaskAsynchronously((Plugin) plugin, () -> {
try {
perform(sender, lb, args);
} catch (final Exception exception) {
exception.printStackTrace();
}
});
return true;
}
protected abstract void perform(CommandSender paramCommandSender, String paramString, String[] paramArrayOfString);
}```
i dont know why i dont receive message f
you return early if the sender is a player
what
me too
does PluginMessageListener run on threads other than Main thread by default?
i mean, before was working but now i can't access the table
and all this only in phpmyadmin not?
if is this then is a issue in the app not plugin
no it doesn't
the logger says that works, but i don't know if the player is creating the table in the db
this is the code executed when the server goes on
yeah.. you can check in the same plugin with a command for test... but you need check the phpmyadmin
It does in this case, but it turns out the issue is something else
Building a artifact in idea compiles the code, but doesn't actually run maven configurations
As such, the remap goal is never executed, and the final jar that is loaded still uses mojmap
@late sonnetbefore you were telling me that the problem was a "SELECT"
Here is the only method where i call it.
no, the issue is you not remapping the .jar
of course it doesn't, you should use maven to build and not intellij's builtin artifact thingy
why dafaq is it still throwing illegal argument exception even though i have handled it
try {
e.setJoinMessage("§7[§a+§7] " + player.getName() + suffixSimplified);
}catch (IllegalArgumentException ex) {
e.setJoinMessage("§7[§a+§7] " + player.getName());
}```
show the error message
what's line 28 in FastJoin?
i started making a minecraft plugin that places a spawner in a random spot in a defined range, and when the spawner is mined, it dropsitself and regenerates somewhere else. how do i set the mob type of the spawner?
String suffixSimplified = ChatColor.translateAlternateColorCodes('&', suffix);
I think it requires NMS
suffix is null
i know
then what's your question?
but i believe i have made it to get handled
why not do an if else on if suffix is null
no, you tried to catch an exception somewhere else
what is that? its my first time coding in java, altho im getting used to it pretty fast (im used to coding in haxe)
cause if i make an if statment it returns always true/false
depending if i put != or ==
it's the internal minecraft server code, that's NOT part of the spigot API
erm yes
obviously
that's what it's for
The issue comes out of using a specific feature, so it is part of the problem
how do i access it to change a spawner type?
String suffixSimplified = suffix == null ? "" : ChatColor.translateAlternateColorCodes('&', suffix);
?learnjava a bit, just in case, but meh idk
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.
The idea artifact functionality is crucial to my workflow to hot reload and debug a plugin
no it isn't, maven can do the same
why would using maven prevent you from doing it?
Because I have to build, copy, copy dependencies, execute internal tools for data generation and finally start and attach the server
isn't there a spawner interface, can't you do stuff with that?
copy dependencies? execute internal tools for data generation?
it'd be odd if spigotmc didn't have api methods for spawners
it at least was the case for many years, idk if it has changed
Yes?
declaration: package: org.bukkit.block, interface: CreatureSpawner
There is more to this project than just "copy and run plugin"
and intellij can do all of that but maven can't? I doubt that
nice, finally they added it 😄
I probably missed it for years
this existed in 2016 from what I can see
IntelliJ yes
I found a thread on it
Maven does not seem to be able to
The please elucidate me as to how I can achieve this with maven
well maybe explain what you mean with "copy dependencies and execute internal tools for data generation" then
What is so hard to understand there?
the problem is select but in the error show in the image from phpmyadmin
bruh, so many deprecated methids
It copies the provided maven dependencies as their own artifacts into the working directory and runs a variety of shell script and applications to generate data
it's hard to understand what dependencies you have to copy and why, and where to, and what you mean with "execute internal tools for data generation"
alright, one sec
like, the methods that use string to be entitytype in the intrrnal code
exec-maven-plugin can run any shell scripts
<plugin>
<groupId>org.codehaus.mojo</groupId>
<artifactId>exec-maven-plugin</artifactId>
<version>1.2.1</version>
<executions>
<execution>
<phase>deploy</phase>
<goals>
<goal>exec</goal>
</goals>
</execution>
</executions>
<configuration>
<executable>java</executable>
<workingDirectory>${basedir}/../</workingDirectory>
<arguments>
<argument>-jar</argument>
<argument>${basedir}/../PluginCompiler.jar</argument>
<argument>AngelChest</argument>
</arguments>
</configuration>
</plugin>
eg. in this case at deploy phase but ofc you can set it to install or other phases
you can use that to run your shell scripts
Alright, what about attaching the debugger and executing the server executable
you can of course use it to copy the files to your working dir, or use the maven resource plugin for that, one sec:
can't you attach the debugger after the server started? it's not required to let intellij start the server itself
If I want proper integration of the profiler and hot reload, no
So I got a question for you guys. Namespaced keys can share the same name across different plugins because they are.... well namespaced right. But I think custom model data can conflict with each other. I was thinking I would just prefix all my custom model data with the ModId, thus ensuring no conflicts with other resource packs. How do you guys approach that?
Is it possible to get all the commands from a certain permission?
why that? I never had problems attaching to already running servers
custom model data is an integer
Because jprofiler requires integration and control over the JVM creation, and to support hot reloading, you need to recompile and swap out changed bytecode on the fly
Are you sure about that? I have seen them starting with 0 but perhaps it just truncates that
Which you cannot do without having your ide support and integrate into the run process
then it might really not be possible, you didnt say anything about needing a debugger in your original question
ItemStack (or ItemMeta?) .setModelData requires an int
What did you think I was talking about when saying "attach"?
idk, like screen or tmux. I asked you twice about what you meant
Ahh yup you are right. Hmmm, perhaps I will encode my mod name as a binary string and use that as the "identifier"
I failed to consider how long a string would be lmao 8 bits per character. Perhaps I will just pick an arbitrary "id"
https://www.jetbrains.com/help/idea/run-debug-configuration-maven.html#add_advanced maybe this might help? idk
what exactly do you need to do anyway? 🙂
I always use PDC strings to identify my items
or booleans if you just need to know whether its one of your items after all
Well I have this custom model data. At the moment its just 1, 2, 3. But if another resource pack wants to work on custom model data for the same item, they are likely using 1,2,3 as well
I want to use some identifiers that are likely not being used by another resource pack, causing conflicts
yes true. maybe just make it configurable to e.g. start at 8000 or any other number
e.g. I think ItemsAdder uses values from 1000+
Ohh thats not a bad idea, I could have the actual model data that is applied be configurable
i looked at resources, im just kinda used to this because haxe has a pretty similar syntax to java
Or just start at some arbitrary value that will likely not conflict
yes you should always do that for custom model data, because yeah, exactly because other plugins could otherwise accidently use the same^^
better make it configurable 🙂
I think thats what I shall do =] thanks a bunch
np 🙂
lmao
yeah that's why I don't get my work done
Plugin is really really coming together now. Got all the functionality I want now just adding bells and whistles to make it look good 😄
friends are already loving it haha
Gonna put it on spigot website when I'm done =]
having trouble with items https://pastebin.com/V8aEZXrN
show ItemManager line 31 pls
final NamespacedKey key = new NamespacedKey((Plugin)Main.instance, "ITEMID");
Main.instance is null
heres main:
package me.generallyblinky.realmofeternia;
import org.bukkit.command.CommandExecutor;
import org.bukkit.plugin.java.JavaPlugin;
import me.generallyblinky.realmofeternia.commands.CustomGive;
import me.generallyblinky.realmofeternia.item.ItemManager;
public class Main extends JavaPlugin {
public static Main instance;
public ItemManager itemManager;
@Override
public void onEnable() {
Main instance = this;
System.out.println(instance);
itemManager = new ItemManager();
itemManager.init();
this.getCommand("customgive").setExecutor((CommandExecutor)new CustomGive());
}
}
you never assign "this" to the instance field
instead you create a local variable called instance too
🙂
yeah
cuz thats what usually gets run
right?
aaanyway i got another error
java.lang.NullPointerException: Cannot invoke "java.util.List.add(Object)" because "lore" is null
at me.generallyblinky.realmofeternia.item.CustomItem.create(CustomItem.java:42) ~[?:?]
lines 41 and 42:
List<String> lore = meta.getLore();
lore.add("");
the lore is null
you can't add something to null
use this
List<String> lore = meta.hasLore() ? meta.getLore() : new ArrayList<String>();
ok
you seem to be using the Adventure API but not running paper
oh you already removed the messages lol
how do i get something like persistant storage for blocks?
I made a library for that
does it delete the old block data once the block is removed / replaced?
or do i have todo that manually
you have to do that yourself
okay
you can just listen to BlockBreakEvent on monitor and then remove the PDC
so the error is not in my code?
hey how can i hide item flags?
in teory not.
so how am i supposed to solve it
Yo mfnalex I had a look at your github you are the chest sort guy! Thats like one of my must have plugins, ur a legend
declaration: package: org.bukkit.inventory.meta, interface: ItemMeta
not sure.. many time not using phpmyadmin.. you can try use another tool for see the database
like?
Webmin
thanks
wdym
thanks
https://paste.md-5.net/ugeqayurur.js
This doesnnt work. Does anyone has an idea why it doesn't execute the statement?
what doesn't work and what's the error?
does it have colors in the display name bc iirc doesn't displayname include the color symbols n whatnot
yeah you have to strip colors if thats the case
Out of the 3 options which one do you guys like more? https://imgur.com/w5dgqSb
btw what you are doing is stupid anyway. people could just go to an anvil and rename their armor to get the glorious "true" chat message
sorry wrong reply
^
it would be better to identify custom items by their PDC tag
PDC ftw
I use the 1st personally but the 3rd is nice too
2 looks weird to me since its the opposite of what I always use lol
i like 1
No clue what that is, but I'm definitely looking into that
?pdc
it's like NBT tags but part of the API
I prefer NBTTags still 😉 String -> Object is better then Object -> object in my opinion.
so I guess 1 wins
I'm trying to find a color scheme
I only see "Your ... has been Disabled" in #1
in two I see "Staff Mode ... Disabled"
and in three I actually read the whole sentence lol
what
HA I knew it
@late sonnet ehm very strange thing, i can access the db in other browser
im colorblind bro dont hate me the colors are very similar
why are you color blind*
just stop being color blind and... see all the colors correctly instead!
^
I'm insensitive to hues between colors, & I can't see yellows xd
imagine going to the doctor and he just tells you to be healthy
no bananas for me bro they're invisible
ayo?
?
so which option do you like adel
Lolol I see discussion of colors, I am "programmer color blind". So this site is one of my favs 😉 https://coolors.co/50ffb1-4fb286-3c896d-546d64-4d685a
1, 2 or 3
6
shhhhhh
that's a 1
its 6
no?
Hi all, I'm a bit confused with BungeeCord events.
Is the event for when a player first joins the proxy ServerConnectEvent or ServerConnectedEvent?
still 6
why the heck is it called Block#getType but BlockData#getMaterial
you can faintly see the outline lol
in one browser i access a db but sends errors but if i open the db in other browser it doesn't ask for perms
check the docs, bro 🙂
you probably need one of those instead @fallen snow
Do you guys prefer this https://imgur.com/xmq5npU or https://imgur.com/i0Il7T7
I don't think players need a message at all to tell them who sent a ton of newlines
but if you want to do it, I'd use dark gray so it's barely visible
the text can be changed in the config obv so
I'd use dark gray as default without any ------- things
people will think something broke if their chats randomly "disappear" without warning
should I just remove the ---------
I never understood the reason to have to clear chats anyway 😄
yeah I know but people could still read it if they wanted to^^
yeah but
that's extra effort 9/10 people don't even know how to do
the whole chat should be disabled anyway, players should communicate using real life mail instead that they send to the server's address and the server then makes a phone call to all players and tell them about the message
you gotta recognize 9/10 people playing on a server with these commands don't know fuck all about minecraft outside of clicky click miney in-game survival stuff
that would be way more efficient
pov Adelemphii playing minecraft in real life
corruptcarnage moment
never
mines you
ayo what?
huh
Kotlin warning, gonna add a java equivalent:
fun Player.setMaxHealthAttribute(value: Double) {
getAttribute(Attribute.GENERIC_MAX_HEALTH)?.baseValue = value
}
fun doSomething(player: Player) {
player.setMaxHealthAtribute(currValue + someOtherValue)
player.health += someOtherValue
}
public void setMaxHealthAttribute(Player player, double value) {
player.getAttribute(Attribute.GENERIC_MAX_HEALTH).setBaseValue(value)
}
public void doSomething(Player player) {
setMaxHealthAtribute(player, currValue + someOtherValue)
player.setHealth(player.getHealth() + someOtherValue)
}
The code above is throwing an error saying that the health is above the max, even when i am at one heart and max health is 10, why's that?
java doesnt let me save when i try and use an emoji like \🌊
if i return something in a #EntityDamageByEntityEvent does it apply to the final damage alone or i have to do something else?
I highly suspect that your value is indeed above the max health
what do you mean by "returning" something in the Event?
does "finalDamage" apply?
no
should i save as utf8?
you have to set the damage inside your "e" object
ofc
alr
well doesnt matter if the files dont contain any special symbols
but as soon as you have customizable messages people might use chinese, russian, german chars
so yes, utf8 goood
is there a #setDamage method inside?
declaration: package: org.bukkit.event.entity, class: EntityDamageEvent
🤦
oh wait
I just told you to use the event itself 😄
i'm in 1.8
hint: it's easier to use proper variable names like "event" isntead of "e"
^
that's bad. but irrelevant
i prefer e
and if you have an event, and an entity? do you call them e1 and e2 then?
like this?
yes but returning something from your event handler method is totally pointless
the event handler doesn't check your return value anyway
ye
it just calls it with reflection and doesn't care about what you return
my faylt
no problem^^
thanks 😄
but a zombie deals the same with defense or without defense
should it be EntityDamageByEntityEvent instead of EntityDamageEvent ?
wait
i'm dumb
Hi dumb, I'm Mom.
Hey!!! I have a problem like this: I played a little on my server, after which I closed the console (my server is not on hochting), when I closed it, after 20 minutes I had to start the console, but my spigot folder was not in the java file, but in notepad file. That is, when I wanted to open the console, it was not the console that opened for me, but the code that was in this file. Please tell me how to start the console now? via start.bat does not work (I don’t know why) the text may be with errors, since I wrote it in the translator in another language
well, could anyone help me? i'm supposed to get a damage reduction but i'm not getting any
fake. my mom only uses anime discord servers
whut?
is the list provided by EntityDeathEvent#getDrops mutable
show the full code please for your event handler
I answered him in help-server
i want to add a drop
ok
yes but you can only REMOVE from it, not add
ok then what should I do if i want to add a drop
anyone know why bukkit uses Reference<World> in location instead of just World?
World#spawnItemNaturally
public void damageCalculator(EntityDamageByEntityEvent e){
Player player = (Player) e.getEntity();
double damage = e.getDamage();
double calculation = plugin.data.getDefense(player.getUniqueId()) + 100;
double damageReduction = plugin.data.getDefense(player.getUniqueId()) / calculation;
double finalDamage = damage * calculation;
e.setDamage(finalDamage);
}
}```
the plugin.data is from a database
not annotated with @EventHandler, it will never be called
it happens lol
first thing to do if something doesn't work:
add some simply debug messages
System.out.println("Yaaay my code is actually being called :3 uwu gg");
now mobs kills me in 1 hit lol, and i have 100 hp
whats a good way to play sounds randomly
yes well you literally set the damage to be damage*100
emulating an ambient sound
I'd create a runnable and then just... randomly play sounds? ^^
alrighty then
you probably want to use World#playSound instead of Player#playSound
or wait
it depends
do you want two nearby players to hear the exact same sounds?
or do you not care about that?
ye... i wanted to use damageReduction lol
it aint tho
i add like 1 to max health, and 1 to health
it still does it
add some debug statements to print out entities current health, their max health, and the new values you're trying to set
there MUST be an error in your code if it says that you're exceeding max health
Ambience (also called ambience sounds or ambient sounds) are sounds that can be heard in specific conditions. They were created by C418 and Samuel Åberg. Currently, there are 167 different ambience sounds.
Ambience is divided into groups of ambience sounds that play under same condition/s. Currently, there are "cave", "underwater" and "Nether" a...
it doesnt really say anything about "when" or "how often" :/
This means that if you are in complete darkness and there are no lit blocks around you, an ambient noise will play every 6000 ticks (5 minutes).
but tbh you should play them way more often, ambient sounds are nice
im talking about mob ambience
oh sorry
nah it doesnt matter lol
I thought you wanted to play some random awesome flute solo from stal every other minute lol
because THAT would be awesome
maybe
I think I'll code a new plugin.
Minecraft, but you will hear stal's flute solo everytime you mine a block
every time i hear that recorder solo i get an instinctive urge to go break the nearest jukebox
haha
it always reminds me of this https://www.youtube.com/watch?v=KolfEhV-KiA
and no thats not a rick roll
Hello im trying to code a plugin with a vote sword that will try and teleport you after you right click and it doesent work. Here is the code:
@EventHandler
public void on_use(PlayerInteractEvent event) {
if (event.getAction() == Action.RIGHT_CLICK_BLOCK || event.getAction() == Action.RIGHT_CLICK_AIR) {
if (event.getItem() != null) {
if (event.getItem().getItemMeta() == ItemManager.voteSword.getItemMeta()) {
Location loc = new Location(Bukkit.getWorld("world"), 0, 80, 2, 0, 0);
Player player = event.getPlayer();
player.teleport(loc);
}
}
}
}
did you registered the listener?
Yes
Like This right:
getServer().getPluginManager().registerEvents(new VoteSwordEvent(), this);
why are you comparing item metas?
yes
oh
use .equals()
Is there a beter way
Oh Im so dumb
I like java but Im new to spigot
onUse not on_use
https://paste.md-5.net/ferekojulu.javadoes anyone know a more practical way to do these checks by returning a string?
Yes thats a thing too i left java for like 2 months and now my naming is really bad
you can easily rename existing stuff in your IDE and switch to proper names NOW 🙂
in java it's
CamelCaseForClasses
lowerCamelCaseForMethodsAndFieldsAndLocalVariables
AND_UPPERCASE_WITH_UNDERSCORES_FOR_STATIC_FINAL_FIELDS
and enums because they are also just static final fields too
what's wrong with your current checks?
nothing
it looks a bit messy but other than that, it's fine I'd say
why do you suppress deprecation?
how messy
Thank you soo much
is a nice idea
E.g. I'd never hard code messages unless it's admin only messages, and not use § but ChatColor instead 🙂
but I don't know how to use predicate and how could I use it
yes i know, is only for tests
for what do you need it? I can show you some examples for predicate
is there a way to delete all existing bossbars?
i reloaded my plugin while a custom bossbar was onscreen and now i cant get it to go away
a Predicate takes some object as input and then returns true or false. It's mostly used for filtering, e.g. to get all creepers in "world":
Bukkit.getWorld("world").getEntities().stream().filter(new Predicate<Entity>() {
@Override
public boolean test(Entity entity) {
return entity instanceof Creeper;
}
});
?
or, as lamda:
Bukkit.getWorld("world").getEntities().stream().filter(entity -> entity instanceof Creeper);
from code you mean?
yeah
you must keep track of your bossbars and delete them in onDisable
there's no way to get all existing bossbars through the API
you have to "remember" them yourself
i have this
private static final Predicate<? super Entity> BULLET_PREDICATE = entity ->
{
if (entity.isSilent() || entity.isInvulnerable()) { return true; }
return entity instanceof LivingEntity && !entity.isDead();
};```
studies
yeah that will return true for all entities that are either
- silent
- invulnerable
- alive
so what's exactly your question? 😛
you could use it for example like this:
private static final Predicate<? super Entity> BULLET_PREDICATE = entity ->
{
if (entity.isSilent() || entity.isInvulnerable()) { return true; }
return entity instanceof LivingEntity && !entity.isDead();
};
@Override
public boolean onCommand(CommandSender sender, Command command, String label, String[] args) {
Bukkit.getWorld("world").getEntities().stream().filter(BULLET_PREDICATE);
for you what would you recommend me to make this code cleaner
hmm
it's perfectly fine
well first of all I would always put the return into it's own line @minor garnet
right now it's hard to spot when it's at the end of the line
and then, as said, better use ChatColor instead of § but it doesnt matter if that's just for testing rn
ok this might be embarassing, i've developed plugins since 2019-2020 but does any of you can explain to me what does Context named class have in its purpose? What does context mean for a class. Im not native english speaker so its hard for me to understand what's the behind of the concept of contexts in java classes. any examples?
I see Context classes passed around as like abstract form of object classes around
Contexts usually hold information about stuff related to what's happening. Do you have any example for a context class? it might be easier to explain in "that context" lol
E.g. talking about this discord chat, a Context class could hold all the previous messages
Spigot's conversation api is a good example to learn about contexts I think
So its like a container?
oh wait nevermind im stupid i jut had to disconnect and reconnect
Iterator<KeyedBossBar> iterator = server.getBossBars();
while(iterator.hasNext()) {
server.removeBossBar(iterator.next().getKey());
}
ig
yeah kinda
Map<String, Object>
@mortal hare read this: https://hub.spigotmc.org/javadocs/bukkit/org/bukkit/conversations/ConversationContext.html
declaration: package: org.bukkit.conversations, class: ConversationContext
?
e.g. when you have a conversation, you can use the context to store information you might use later, and then when you have a new conversation "event" you can get your previously saved data
Map<String, Object>
why do you keep saying that
well it is passed directly, inside the context object^^
map.get("why-am-i-saying-this")
very helpful
imagine you have a real life conversation with a stranger. He says "Excuse me" and you listen to the StrangerTalksToMeEvent. How would you reply?
Excuse me could mean they just need to walk by and you're standing in the way. It could also mean they didnt understood what you said earlier. So you check the context - did I talk to that person before? Or is this the first sentence you exchange with him? So you can react properly according to what happened earlier
can we call Event in bukkit as context
it has data in it about specific circumstances
every object has data in it
Contexts are meant to be used to pass the same data around in different "events"
it's not that easy to explain. I think this is kinda understandable though
no shit
you're getting annoying, can you please shut up if you have nothing to say?
maybe
maybe not
would be nice though. If you need help, people don't spam useless stuff either
i just see what i want
@mortal hare I have a tiny example for Contexts in Spigot's conversation API
but I dont know if its of much help
??? java
public class WarpLorePrompt extends ValidatingPrompt {
@Override
protected boolean isInputValid(@NotNull ConversationContext conversationContext, @NotNull String input) {
Player player = (Player) conversationContext.getForWhom();
String[] lines = input.split("\\\\n");
List<String> lore = Arrays.stream(lines).map(s -> TextUtils.format(s, player)).collect(Collectors.toList());
for (String line : lore) {
if (ChatColor.stripColor(line).length() > WarpBooks.Config.getMaxLoreLength()) {
player.sendMessage(WarpBooks.Messages.getPromptLoreTooLong());
return false;
}
}
if (lore.size() > WarpBooks.Config.getMaxLoreLines()) {
player.sendMessage(WarpBooks.Messages.getPromptLoreTooManyLines());
return false;
}
conversationContext.setSessionData("lore", lore);
return true;
}
this is so people can enter a lore in the chat for an item
I save that in the context, then later on ask other things
Once I got all information, the item will be created
So I have different prompts but they all belong to one item, so I can just use the conversation's context to store it during the different prompts
in this case, kind of, yes
how do you add items to a chest block?
but it can be different in other context classes
- Get the Blocks BlockState
Then cast it to Container
Hello, I need an idea for a plugin BC I don't want to lose my java knowledge
then you can access its inventory
after that you have to update the block state
done
how do i place it in the world?
a backpack plugin. easy to write but not tooo easy
the chest? isnt it already there?
shop
Block#setMaterial I think
i created another chest var and casted the chest's state to it
setType
Ok i will do
show your code pls, it's easier to answer when we know what you already have
setType only sets to a general material
and after that: Map<String,Object>
and modify the data
BlockState state = onBlockPlace.getBlock().getState();
Chest chest = (Chest) state;
int chance = new Random().nextInt(20);
if (chance < 3) chest.getBlockInventory().addItem(new ItemStack(Material.SKELETON_SPAWN_EGG, 2));
if (chance < 7) chest.getBlockInventory().addItem(new ItemStack(Material.ZOMBIE_SPAWN_EGG, 2));
if (chance < 11) chest.getBlockInventory().addItem(new ItemStack(Material.SPIDER_SPAWN_EGG, 2));
if (chance < 15) chest.getBlockInventory().addItem(new ItemStack(Material.COW_SPAWN_EGG, 2));
if (chance < 19) chest.getBlockInventory().addItem(new ItemStack(Material.CREEPER_SPAWN_EGG, 2));
if (chance < 20) chest.getBlockInventory().addItem(new ItemStack(Material.WITHER_SKELETON_SPAWN_EGG, 2));
chest.update();
damn this is actually fun lol
I understand now why you kept posting it
lets make this a running gag
i dont want anymore
Did you check whether the block is actually a chest before casting it?
yep
@EventHandler
public void onBlockPlace(BlockPlaceEvent onBlockPlace) {
if (onBlockPlace.getBlock().getX() == -625 && onBlockPlace.getBlock().getY() == 94 && onBlockPlace.getBlock().getZ() == -1430) {
if (onBlockPlace.getBlock().getType() == Material.CHEST) {
BlockState state = onBlockPlace.getBlock().getState();
Chest chest = (Chest) state;
int chance = new Random().nextInt(20);
if (chance < 3) chest.getBlockInventory().addItem(new ItemStack(Material.SKELETON_SPAWN_EGG, 2));
if (chance < 7) chest.getBlockInventory().addItem(new ItemStack(Material.ZOMBIE_SPAWN_EGG, 2));
if (chance < 11) chest.getBlockInventory().addItem(new ItemStack(Material.SPIDER_SPAWN_EGG, 2));
if (chance < 15) chest.getBlockInventory().addItem(new ItemStack(Material.COW_SPAWN_EGG, 2));
if (chance < 19) chest.getBlockInventory().addItem(new ItemStack(Material.CREEPER_SPAWN_EGG, 2));
if (chance < 20) chest.getBlockInventory().addItem(new ItemStack(Material.WITHER_SKELETON_SPAWN_EGG, 2));
chest.update();
onBlockPlace.getBlock().getState().getBlock().getState().getBlock()
}
}
}
the last line is useless
have you tried Map<String, Object>
i dont think that it needs the update
i know it was for fun
at least i used a code do add items into a chest
Are you sick? Your husband wants divorce? Are you broke?
Don't worry no longer: Just Map<String,Object>!
was weird for me the amount of function chaining
and didnt used update
i like chaining but that was overwhelming
fallthrough
you do realize that when you add the first item, you add all others as well, right?
^
Yeah don’t call .update
oh wait oops
of course update must be called
was supposed to write it opposite
otherwise the chest won't get the items
and needed else ifs
you would need to use else
it will not
Spigot be weird
i didnt used update when i added items to a chest
I will check it to be sure, I don't want to give false information
Me too
Checking this now:
@Override
public boolean onCommand(CommandSender sender, Command command, String label, String[] args) {
Player player = (Player) sender;
Block block = player.getTargetBlockExact(100);
Container chest = (Container) block.getState();
chest.getInventory().addItem(new ItemStack(Material.DIAMOND));
chest.update();
return true;
}
If I'm not mistaken, this should add a diamond to the chest the player is looking at when using the command
so basically Context class is a Class responsible for holding data about current object's situation
yes
yes
well
with a Map<String, Object>
yes
not always
it can be something different too
e.g. the conversation api context class also has other fields like forWhom
List<Map<String, List<Map<String, Object>>>
forWhomstved
you are right
so @cinder tusk do NOT use .update() after adding the items
Hey unrelated question, why does /experience query report that I have 0 experience points despite having 30 levels
for coloured kick messages, would i just use org.bukkit.ChatColor
Levels and points are different
you have 0 points and 30 levels
points is only the points in your current level
if you need the total XP points: I have a method for that
let me find it
Experience points are just the amount of points you have in regards to your level.
But you can 30 levels worth of points to achieve level 30
Its not looking at points/level right?
It’s a bit counter intuitive but it’s probably to avoid absurdly big numbers
§ org.bukkit.ChatColor net.md_5.bungee.api.ChatColor
may this'll help @rancid flume https://github.com/JEFF-Media-GbR/JeffLib/blob/master/core/src/main/java/de/jeff_media/jefflib/ExpUtils.java
so to get total XP: get current XP and add getTotalXPRequiredForLevel(currentLevel)
yes i know, ive used it before, was just seeing if its the same enum
the bungee one supports hex
Not true
I see, thanks! Spigot's getTotalExperience seems to be a little misleading in the API
spigot supports hex too. ChatColor.translateAlternateColorCodes('&',"&x&f&f&0&0&0&0red text");
The bungee one has the normal ChatColor.XXX fields
yeah it's indeed a bit strange
ik
that's why I made this class^^
TL;DR pretty much always use the bungee one
spigot's getTotalExperience returns ALL the XP ever acquired, even if some of them were already used / lost again
yeah that was causing some big problems for me
yeah 😄 I just did the math that was explained in the MC wiki, should be working fine - at least no one complained to me yet lol
tyy
player.getExp() ?
not helpful
Only shows the exp for that level ;\
^
a
and a percentage of the bar at that
yes, kinda confusing
If I knew how to fork spigot and do PRs, I'd do so
but
I don't know how
lol
I mean
?
How make plugin
otherwise I have to work on my update
The home of Spigot a high performance, no lag customized CraftBukkit Minecraft server API, and BungeeCord, the cloud server proxy.
Here (:
Believe that could be of help
yeah I already had that bookmarked buuut... ugh 😄
In case you want to contribute 
Not that I have contributed yet but yeah 😊
Booo
I KNEW IT! You are mean
i still dont get it why in conversation API ConversationContext is passed in prompt and not just raw Conversation instance
is it for encapsulation
Probably lol
how should that work? the prompt doesn't have any access to the Conversation itself
haha
gj
that's how my wikipedia contirubtions work
I have more than 1000 edits on wikipedia but its always just typos, missing commas or updating links lol
Anyways dovidas looks like it has with event/callback design to do
Every bit counts I suppose
it doesnt because its an interface
it could easily support having the raw Conversation object in its implementation
if you really wonder why, ask md_5 why it's done this way
semi correct, working on an internal API
he will know it for sure
oh right
or he'll say "idk I was sooo drunk that day that I decided to just invent a context thingy". but probably he had a reason
oh btw @golden turret
Assuming he even made it