#help-development
1 messages · Page 1545 of 1
so should i make a static Inventory or not for the getInventory() method or not?
pretty bad made, the whole thing is currently in recode to keep it clean and better up the performance. so don't judge me
static not need anymore right?
idk
no
encapsulation is a thing
like this?
public class TradeGui implements InventoryHolder {
private Inventory inv;
private InventoryHolder holder;
@NotNull
@Override
public Inventory getInventory() {
return inv;
}
}
^ this OK
the holder is unnecressary since your class IS-A InventoryHolder already
oh yea why is that there lol
Yes, way better, but remove the holder
maybe is a pair of twins
and then just a method that makes the inventory and return it and thats pretty much all?
Not exactly, utilize the constructor
to?
to?
for what?
if you are constructing the inventoryholder
it would make sense to make an inventory for it at the same time right?
hence, what he meant is you can create a new inventory instance in the constructor
avoid creating another method to set your inventory
so inv = new Inventory() ?
What are the best ways to go about menu pagination? Are there any updated guides or something similar to help with understanding how to do pagination. Creating single menus is fine, it's more the pagination side that's confusing
inside the constructor
??
inventory might not have a public constructor
you just created you own by using the Bukkit class
you cant do that
inventory is an interface afaik
the factory method is provided by Bukkit class
inv = Bukkit#createInventory just like you did before
ah that way
scroll up there is an example of mine
its not pretty good but enough
I mean, you can technically, inv = new Inventory(){
...
}
lololol
yea saw that
Is it possible to load or create a world async? Or at least remove the lag that derives when doing so?
||Paper||
||CraftBukkit||
🙄
Purpur is nice ngl
||Alt+F4||
purpur is a monster at starting server
How do I do this using paper?
In heraldry, purpure, () is a tincture, equivalent to the colour "purple", and is one of the five main or most usually used colours (as opposed to metals). It may be portrayed in engravings by a series of parallel lines at a 45-degree angle running from upper right to lower left from the point of view of an observer, or else indicated by the ab...
nice
Ask paper
what are the commonly used social platforms for games other than discord
Twitter?
ok TwitterSRV
implying discord is used for games and not primarily for child trafficking
and another method to set the contents of the inventory? or inside the constructor?
depends on what you want
personally i define tokens that represent different sections of the inventory layout, and then define the inventory with the tokens
Does "BungeeCord Plugin Messaging Channel" require a non-null player?
if it is a none changing gui, where contents not dependent on viewer, yes I would do in constructor
a null player is not a player
its a trading gui in this case so players can drag items in it
a null player refers to a variable of type player that is empty; that is, the absence of a player
it is nothing, it is everything
because I just want to send data
if a player variable is null, there is no player
readSlots(new GuiSlot[]{
_,_,_,_,_,_,_,_,_,
_,P,E,N,M,_,A,O,_,
_,W,W,W,W,_,I,U,_,
_,W,W,W,W,_,B,C,_,
_,W,W,W,W,_,F,D,_,
_,_,_,_,_,_,_,_,_
});
where each variable here is a predefined token representing a type of slot
but what if the server is empty
how do I get a player
🤡
if there is noone on the server PMC won't work
ok
basically sockets but with extra hoops to jump through
but I don't think sockets can help in connecting the entire server network
sure they can
they will require too many ports
that's not how sockets work
multiple connections can be made to the same server-side socket as long as the client side ip:port differs for each connection
or you use jedis
which means you only need one socket on each server
spigot-api-1.12.2.jar
spigot-1.12.2.jar
Wich one is better to put here?
but a server already uses a port, then there will be twice more of them
in modules?
YEs
moudles
Aren't modules J9+?
Is there a way to give players temporary permissions? Like in Bukkit's PermissionAtachment, but then in Bungee
also, Please don't actually use the IDE builder but you may want to use the spigot-1.12.2.jar if you are at it already since it has NMS (which I do not suggest you to use)
store it with a timestamp somewhere and remove it if the timestamp is passed or X time ago
why would it be better?
But how to add / remove the permissions in Bungee? There are no methods for
spigot includes spigot-api
but internally, spigot isn't javadoc'd
@slate pendant i'm sure your server comes with more than one port
you can add the javadocs manually on eclipse, you should be able to do it in intelliJ too
would be pretty sad if it didn't
you wouldn't for example be able to use votifier
as that, too, uses a port of its own
VSC should also support it
If it does not it is literally dogwater
Or ... it has no javadoc support at all, at which point it is meh but at least better
Of course not, but if you already do it the wrong way, why not go it fully wrong?
reflection is wronger
Reflections is not the ideal way of doing it
It way okay once, but not anymore
All hail 1.17 spigot
it still is, if you dont mind writing separately for 1.17+
but if your plugin is only for 1.17 also quite meh
Can I ask another question? Why ain't math working in bukkit?
private void handleCryingObsidianRightClick(PlayerInteractEvent ev, Block b, Player p) {
Location originloc = b.getLocation();
World wrld = b.getWorld();
ArrayList<Vector> shift = new ArrayList<Vector>();
shift.add(new Vector( 0, 1, 0));
// shift.add(new Vector( 0, 0, 0));
shift.add(new Vector( 0,-1, 0));
shift.add(new Vector( 1, 0, 0));
shift.add(new Vector( -1, 0, 0));
shift.add(new Vector( 0, 0, 1));
shift.add(new Vector( 0, 0,-1));
ArrayList<Block> surroundblocks = new ArrayList<Block>();
originloc = new Location(wrld, originloc.getBlockX(),originloc.getBlockY(),originloc.getBlockZ());
for(Vector l : shift) {
surroundblocks.add(wrld.getBlockAt(originloc.add(l)));}
for(Block tmp : surroundblocks) {
Location tloc = tmp.getLocation();
p.sendMessage("At "+tloc.getX()+" "+tloc.getY()+" "+tloc.getBlockZ());
if(tmp.getType().equals(Material.GLASS)) {
p.sendMessage("It's Glass.");
}
}
}```
This results in
math works in bukkit
At 0.0 72.0 0
At 0.0 71.0 0
At 1.0 71.0 0
At 0.0 71.0 0
At 0.0 71.0 1
At 0.0 71.0 0
that
Is that the java.util.Vector class?
no the bukkit vector
but the same thing happens if i replace the vectors with locations
the problem is
look at the 2nd, 4th and 6th result
they are NOT shifted
negative values dont seem to work for some bizarre reason
result 2 looks shifted
Are locs mutable?
72 shifts to 71
yes
then that may be the issue
result 4 is also shifted
no no 0 71 0 is where i start the scan
x1 shifts to x0
?stash
then why aren't my results showing that
originloc.add(l) mutates the originloc location
the 2nd should be 0 70 0 not 0 71 0
which means that in addition to adding a thing to the list, the location itself changes
so do clone()?
yes
perfect it works now thanks
for?
consider using Block::getRelative and iterating over BlockFaces
i only need the directly adjacent faces. Can i still iterate over them somehow?
and thanks for the tip
You could store it in an array somewhere
enumset 😎
Enumset is even worse than arraylist here I would assume
why would it be
Sets (to my knowledge) are kinda inefficient with iteration
they do iterate slower, but for something this small, time complexity hardly matters
myeh, still consider enumsets overkill here
i feel it suits the intention better
as we don't care about order, nor do we want duplicate elements
Like you can do
public static final BlockFace[] CARDINAL_BLOCK_FACES = {
BlockFace.UP,
BlockFace.DOWN,
BlockFace.NORTH,
BlockFace.EAST,
BlockFace.SOUTH,
BlockFace.WEST,
};
and be done with it for once and for good
to use an arraylist over a set because it's a few nanoseconds faster would be what people call a micro optimization
airplane
Like you can do
public static final EnumSet<BlockFace> CARDINAL_BLOCK_FACES = EnumSet.of(
BlockFace.UP,
BlockFace.DOWN,
BlockFace.NORTH,
BlockFace.EAST,
BlockFace.SOUTH,
BlockFace.WEST,
);
and be done with it for once and for good
i wanted to use an array list but i would have instanced it. Thanks for the tip
ArrayList<Block> surroundblocks = new ArrayList<Block>();
for(BlockFace face : CARDINAL_BLOCK_FACES) {
surroundblocks.add(b.getRelative(face));}```
like that then?
yes, but with an enumset
Why enumset
i copy pasted the one from above
because it indicates the intention better
All advantages of enumset are void here
we do not care about order
we do not want duplicate elements
to use an arraylist because it's a few nanoseconds faster is what many would call a micro optimization
It is needless overhead
Ight
you guys mean using a enum set for the cardinal directinos right?
we want a set because the properties of the collection we use correspond to those of a set
and an enumset is the most performant implementation of set for this case
ok thanks. was asking since i tried putting the actual block list as enum set but it told me it cant be instancized
since the order isn't important with that either, what data type would be better there? Collection?
EnumSet has to be inistantiated via EnumSet.of(Enum<?>... e) or EnumSet.emptyOf(Class<? extends Enum> c)
enumset as one can guess from the name is intended to hold enum constants only
BlockFace is an enum, but Block isn't, so it wouldn't work for the latter
ah ok. Google tells me to use ordered structures due to the limited number of elements tho, that applies here too?
final BlockFace[] CARDINALS = new BlockFace[]{
BlockFace.UP,
BlockFace.DOWN,
BlockFace.NORTH,
BlockFace.EAST,
BlockFace.SOUTH,
BlockFace.WEST,
};
Block origin;
Block[] adjacentBlocks = new Block[CARDINALS.length];
for (int i = 0; i < CARDINALS.length; i++) {
adjacentBlocks[i] = origin.getRelative(CARDINALS[i]);
}
Here, fastest way possible (without hardcoding everything)
fastest != best
but yeah, you could use an array of fixed length for the blocks themselves
its always 6 faces anyways
or an arraylist of predetermined underlying size of 6
difference here would be what exactly?
that to populate an array, you'd need an index counter
with an arraylist, you can just .add
It is better than
Block origin;
Block[] adjacentBlocks = new Block[] {
origin.getRelative(BlockFace.UP),
origin.getRelative(BlockFace.DOWN),
origin.getRelative(BlockFace.NORTH),
origin.getRelative(BlockFace.EAST),
origin.getRelative(BlockFace.SOUTH),
origin.getRelative(BlockFace.WEST)
};
if you're just iterating over it, you don't need an intermediate collection for blocks
also, enumsets are a rather special implementation of set
in that their iteration time complexity is constant
well since i need to do that a few hundred times
for(BlockFace face : CARDINAL_BLOCK_FACES) {
Block b = origin.getRelative(face).getLocation();```
and run a check on the block material
for a given enum class, it will iterate significantly slower on a large material enum than a small blockface enum
this depends on the environment
then I am misunderstanding how it works
well nothing exceeds 6 here except the number of iterations
for enumerations with 64 elements or less, the implementation uses a hotspot intrinsic function which is usually deferred to the hardware and executed as a single instruction
in other words if its less than 64 its faster, but you can't tell how much faster?
O(1) if your chip supports said operation
which I'd assume most server grade machines to do
probably ever so slightly slower than iterating an array
is there a better way to do this?
ItemStack[] menu_items = {placeholder,placeholder,placeholder, spawncmd, bowcmd, blazerodcmd, placeholder, placeholder, placeholder};
but possibly faster than iterating f.e a linked list
placeholder is a glass pane
i want to put glass panes at every empty slot
of course for something like the material enum which is literally thousands of fucking elements, it will be significantly slower
as that uses a J U M B O enum set as the underlying impl
maybe i could do for every air slot or something
I use this for my menues
Just I do it s bit diff using chars
yes but I'm iterating over the block faces and running a material check on the temporary blocks i get from that. You're saying to do instead of if(tblock.getType().equals(Material.THIS)) (Material doesn't change) using Material m = Material.THIS; if(tblock.getType().equals(m)) would be faster?
yeah i'm not totally pleased with the way how my inventory shit works right now
huh i don't remember saying anything about your if conditions
well what i mean here is it better to grab the material in a variable and then start the loop?
ie faster?
mm yes you should continue using .equals for enums
the bukkit material enum?
How can I make so I add items to the gui with a for loop, but I want to create a pattern pretty much
if you get it from like a block or something, yeah, cache it in a var
so the items will only be in certian slots
like slot 5-10 for example
and the under it
but if you're just directly referencing the material enum, there is no point
remember i need to run a few hundred checks
there is no difference
for (int i = 5; i < 11; i++) {
enum constant fields are final so they are inlined
didn't you say referencing it is slower due to it being a J U M B O EnumSet?
i said iteration is slower
ah i see. So for direct comparisons it does not make a difference?
if you have an EnumSet<Material>, iterating it is slower than an ArrayList<Material>
however this statement has nothing to do with what you are doing
If I schedule a bungee task it gets repeated infinitely, with a delay of 5. I just want it repeated 5 times and a delay of 1, this is the code
schedule(() -> <runnable>, 1, 5, TimeUnit.SECONDS)
as you are not iterating over the material enum
you are iterating over the blockface enum, which is less than 64 elements
so for setting empty air slots to glass would i do something like
for (Arrays.stream(menu_items).filter()) // something? {
but say i want to create like 2 columns and i want to ignore last slots
like to create a frame pretty much
ok thanks for the help
Uh that takes a predicate and then you need to invoke a method to check what happened when the items got passed to the predicate
Better just loop it, faster and probably easier for you
im just looking to create smthing like this
so go i from 1 to 2
and j from 2 to 6
But I have 1 list of items
i*9+j
what
Okay basically
its so fkin hard to explain that
lemme figure out how to explain it
one list of items can represent multiple dimensions
to represent the 2*5 grid of items you have there, you could use a list of 10 elements
or map the dimensions to the index
hey, is it possible adding efficiency 6 into enchantment table?
index = x + (y * width) for example
What would be the right way to see if a configuration file exists?
so 1,1 would point at index 1 + (1 * 5) = 6 if you had an inventory of width 5
Oh, I can just config.isSet("some default key")
second item on the second row, 0,0 being first item on the first row, as java is 0 indexed
the first row would map to elements 0 through 4
the second row would map to elements 5 through 9
ok i tried looping through all slots but i got an internal error v for(int i = 0; i <= 27; i++) { if (gui.getItem(i) == null) gui.setItem(i, placeholder); }
Hey, i need some help with the tablist.
I want to sort the tablist and also add some offlinePlayers/text to the tablist.
The sorting and adding online(!) players is working with creating a custom scorboard/teams and add the players to the teams (team.addEntry(string);).
But the issue is that if i add any string which is not an online player it will not be displayed in the tablist.
Can i configure that or i have to change my code ? (Is is possible without packets or do i need them?)
How can I get char from FileConfiguration?
Is there any way I can make it so a player can still interact through another player (hit entities, place and mine blocks etc) while still being visible and in survival mode?
If not, is it possible to use hidePlayer() and still have the glow effect and nametag show (I am providing the nametag from teams in a scoreboard) ?
Get a string and covert it to char?
How can I convert it?
Arrays.stream(i -> i.getType() == Material.AIR).forEach(i -> i.setType(Material.GLASS));
Google it
oh ok thanks
That won’t work
i think looping through slots will work
that line didn't work
No need to use streams here, will just be an overhead
why doesn't this work?
What’s the error
well a good start would be-
lemme look
30.06 15:23:45 [Server] INFO at java.util.Arrays$ArrayList.get(Arrays.java:4351) ~[?:?]
30.06 15:23:45 [Server] INFO at net.minecraft.server.v1_16_R3.NonNullList.get(SourceFile:46) ~[patched_1.16.5.jar:git-Paper-"e04368045"]
30.06 15:23:45 [Server] INFO at org.bukkit.craftbukkit.v1_16_R3.inventory.CraftInventoryCustom$MinecraftInventory.getItem(CraftInventoryCustom.java:105) ~[patched_1.16.5.jar:git-Paper-"e04368045"]
30.06 15:23:45 [Server] INFO at org.bukkit.craftbukkit.v1_16_R3.inventory.CraftInventory.getItem(CraftInventory.java:50) ~[patched_1.16.5.jar:git-Paper-"e04368045"]
30.06 15:23:45 [Server] INFO at me.gui.Commands.onCommand(Commands.java:57) ~[?:?]
30.06 15:23:45 [Server] INFO at org.bukkit.command.PluginCommand.execute(PluginCommand.java:45) ~[patched_1.16.5.jar:git-Paper-"e04368045"]
30.06 15:23:45 [Server] INFO ... 19 more```
there are 27 slots tho
Yes but indices start at 0
So to access element 27 you’d need to for instance call inventory.getItem(26)
oh ok
How exactly "doesn't work"?
can't resolve the methods
Arrays.stream(menu_items).filter(i -> i.getType() == Material.AIR).forEach(i -> i.setType(Material.GLASS));
I am typing this on phone, so it might be a little off
?spoon
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.
Because you’re only setting the type to a copy
If they're not stupid, they will want to know what does it fo
*do
Inventory#setItem() would be needed
That’s not a reason to spoon feed someone
And for the record I am not so sure he knows everything about higher order functions
I try to update my plugin to 1.17, but i have some issues with NBT..
For 1.8 to 1.16 i always had this setup:
[...]
import net.minecraft.server.v1_16_R3.NBTTagCompound;
net.minecraft.server.v1_16_R3.ItemStack nmsStack = CraftItemStack.asNMSCopy(itemStack);
NBTTagCompound compound = nmsStack.getTag();
[...]
But with 1.17 intellj tells me i have to use
[...]
import net.minecraft.nbt.NBTTagCompound;
net.minecraft.world.item.ItemStack nmsStack = CraftItemStack.asNMSCopy(itemStack);
NBTTagCompound compound = nmsStack.getTag();
[...]
But then i get this error while compiling
cannot find symbol
[ERROR] symbol: class NBTTagCompound
Did i miss something ?
I tried to search if that Class has been moved for 1.17 but i don't found anything.
had the same problem, I dont think it exists anymore
So how i can use NBT then ?
yes, ignore the question that was asked
Let me think about that, im not sure which mappings are meant.
What do you mean with mappings ?
I'm trying to use abstraction to add support for lower versions. The problem is idk what im doing.
import org.bukkit.entity.Player;
public class Handler_1_8_R1 implements VersionHandler {
@Override
public void vulnerableSet(Player p) {
}
}```
I'm trying to implement 1.8 method for vulnerability, but the problem is that it doesnt want to implement the old method for setVulnerable();
As you are aware of, the normal spigot server jar contains the nms classes however if you have looked into that you should have recognized a lot of gibberish names for the method names, parameter names and field names. Mappings are a way to map those gibberish names with useful names.
Nah, i dont use reflection (i guess this is what do you mean).
This is what i did for 1.8-1.16 https://github.com/UtechtDustin/Builder-s-Wand/blob/master/src/main/java/de/False/BuildersWand/NMS/v_1_16/v_1_16_R3.java
I don’t talk about reflection
Then i maybe don't understand it..
My english is not the best :/
But anyways my point was that maybe the name NBTTagCompound or whatever it was called is the name in the mappings however not outside the mappings
does the server jar itself use mappings? I haven't looked at 1.17 at all yet
good, as expected
just to make sure before I commit to it, there are no soil tilling events right
I should be checking for block place instead?
i vaguely remember that being involved in one of the umbrella events like blockfromto event and friends
who are you calling a hoe?
thanks
actually I think blockplaced in blockplaceevent might be better just by virtue of not firing as much and potentially getting cancelled less often
Look at EntityChangeBlockEvent as it may fire for tilling
assuming it fires this event when it replaces
it won't be blockplace
how do i count rows in mysql?
Is SELECT COUNT(*) FROM <table> what you're looking for?
Yeah i have that arldy
final ResultSet rs = MySQL.prepareStatement("SELECT COUNT(*) FROM all_usertags;").executeQuery();
int rowCount = 0;
if (rs.next()) {
rowCount ++;
}
return rowCount ;
i have smthing like this
now
What result does that give you?
Okay. SELECT COUNT(*) FROM all_usertags; will return a single result, so that makes sense
The actual count is in the value of that result
so rs.next only runs once
Yes
So id need to run it till the end of the rows
while instead of if
No
Next returns a bool. What does rs.getInt(0) give you?
how do i get the task id of a task?
<your task>.getTaskId()
Create a bukkittask variable before your scheduler
so BukkitTask task = bukkit.getscheduler blablabla
gives me an error
have you considered mentioning the type of the error
or should we go get the crystal ball
This fixed it for me:
final ResultSet rs = MySQL.prepareStatement("SELECT COUNT(*) FROM all_usertags;").executeQuery();
int columnCount = 0;
while (rs.next()) {
columnCount = rs.getInt(1);
}
return columnCount;
public static Recipe recipes() {
ShapelessRecipe shapeless = new ShapelessRecipe(ItemManager.customBow())
.addIngredient(Material.GOLD_BLOCK)
.addIngredient(Material.GOLD_BLOCK)
.addIngredient(Material.TNT)
.addIngredient(Material.TNT)
.addIngredient(Material.OBSIDIAN);
ShapedRecipe appleRecipe = new ShapedRecipe(ItemManager.invertedApple());
appleRecipe.shape("123","456","789");
appleRecipe.setIngredient('1', Material.BEDROCK);
appleRecipe.setIngredient('2', Material.BEDROCK);
appleRecipe.setIngredient('3', Material.BEDROCK);
appleRecipe.setIngredient('4', Material.BEDROCK);
appleRecipe.setIngredient('5', Material.GOLDEN_APPLE);
appleRecipe.setIngredient('6', Material.BEDROCK);
appleRecipe.setIngredient('7', Material.BEDROCK);
appleRecipe.setIngredient('8', Material.BEDROCK);
appleRecipe.setIngredient('9', Material.BEDROCK);
return shapeless;
}
}``` how do i return both of these recipes? i can only return one
it is rowCount, not columnCount
Ik, mb
consider an array/list/tuple/separate method
of which im a fan of the last
since your method name is already in plural i would just return an Array
another method would be cleaner
ok
ShapedRecipe appleRecipe = new ShapedRecipe(ItemManager.invertedApple());
appleRecipe.shape("111","151","111");
appleRecipe.setIngredient('1', Material.BEDROCK);
appleRecipe.setIngredient('5', Material.GOLDEN_APPLE);
assigning a different character for each slot is redundant
if i was using the server scheduler to run a delayed task and lets say i wanted it to run in an eighth of a second how would i do that since as an input it takes ticks
you figure out how many ticks 1/8th of a second is
its 2.5
does rayTraceEntities work through blocks?
So I've never used the bungeecord messaging channel and I'm confused;
I want to do something very simple, get the number of players on a server
Read the doc of course and got this so far
I have the onPluginMessageReceived (at least this rn)
@Override
public void onPluginMessageReceived(String channel, Player player, byte[] message) {
if (!channel.equalsIgnoreCase("BungeeCord")) {
return;
}
ByteArrayDataInput input = ByteStreams.newDataInput(message);
String subchannel = input.readUTF();
}
and in a method this, with server being a string
ByteArrayDataOutput output = ByteStreams.newDataOutput();
output.writeUTF("PlayerCount");
output.writeUTF(server);
Now how would actually send the plugin message and receive the information?
does rayTraceEntities work through blocks?
is this a good way of making a gui?
and I'm using like this
p.openInventory(new TradeGui().register());
register seems like a weird name for that method
xd lets call it create
But you’re already creating it by a standard instantiation?
👍
my player.getInv().additem() isnt working so i try setting it on an index
hi, i wanted to have global keys and if user defines custom keys per world then it uses the custom one..
for example there is world in worlds...so all things that it says in custom world keys will be used for that world and the "spawn-block-blacklist" which is not in the custom world keys...so it will use the global ones.
I tried this but it says using global always and also dont recognize the global default values.
but if i manually print the world keys then it shows the ones in config.
private String checkWorldConfig(World world, String config) {
List<String> worldList = plugin.config.getConfig().getStringList("worlds");
String worldName = world.getName();
if (worldList.contains(worldName)) {
if (plugin.config.getConfig().contains("worlds." + worldName + "." + config)) {
return ("worlds." + worldName + ".");
}
}
return ("global.");
}
# UnexpectedSpawn
# Authors : Shivelight, DeathGOD7
# Original : https://github.com/Shivelight/unexpectedspawn-paper
# Modified : https://github.com/DeathGOD7/unexpectedspawn-paper
global :
# Random respawn area for global settings.
x-max: 399
x-min: -399
z-max: 399
z-min: -399
bed-respawn-enabled: true
random-respawn :
on-death: true
on-first-join: false
always-on-join: false
spawn-block-blacklist:
- LAVA
- WATER
- CACTUS
- FIRE
- MAGMA_BLOCK
- SWEET_BERRY_BUSH
- CAMPFIRE
worlds :
world :
x-max: 2000
x-min: -2000
z-max: 2000
z-min: -2000
bed-respawn-enabled: false
random-respawn :
on-death: true
on-first-join: true
always-on-join: false
does anyone know where the spigot mappings are for NMS?
in spigots build data repo
So I noticed whenever I boot my test server with my plugin I get a message saying initializing legacy material support and the getType() of Block’s with any type of button other than oak or stone give me the material LEGACY_AIR
Anyone know what’s up?
did you specify the api version in your plugin yml
Nope
go do that 👍
I’m coding against 1.16.1 api right now but I don’t theres anything in my plugin really version specific, should I just put 1.16? An earlier version for more compatibility?
api-version: 1.16
would be it then
note that API version is always just the base version
alright that fixed it, thank you!
np
You can also just define it at api-version: 1.13 if you want to
please don't
Any version of spigot would be able to load it then
what that?
use api-version 1.13
the API-version is merely a suggestion
theres no reason to use any other version
no. spigot introduces compatibility layers depending on your version
that is the entire point
if you want to run on 1.16 only, stick to api version 1.16
And what if you want to run it in 1.15 then?
then you go down to 1.15
I don't see the issue ? Stick to the lowest version you want to support
yea but anything other than 1.13 isnt used in the code lol
just like with your spigot-api dependency
not yet
doesn#t mean it won't
e.g. material enum recode by choco
So?
then you will need to update it later
That PR is never going to get merged, everyone knows that
So you would actively be using compatibility layers you really don't need
what is wrong with using them?
I don't see any reason to use a version lower than your spigot-api dependency
they are slow
some rather agressive asm manipulation is needed for them
How slow?
there is no other compatibility layer than null or not null
its literally in the code
are you good ?
And in the future they will be present either way
Regardless of version
If you put in 1.13 or 1.16 or 1.17 it wont matter
I am saying, a system that wants you to specify your minimal supported api-version might do things for you
that you might not need
right, and everyones minimal supported api when using 1.13 version is 1.13
thats the whole point
yes
so... put 1.13?
You almost always dont want to put in arbitrary limits
because you do not support 1.13
whatever, my main point is that it will likely never change beyond null/not null
I for example have a few methods for providing fallback for older versions while still linking with newer versions
And I doubt that Md is going to continue the strict ABI compat
Have you read the material PR ?
yea
He already broke the EntityShootBowEvent constructor with an 1.16.2 build
like, you literally just stated you don't think it is going to be pulled
And that PR is never going to be merged
and in the next sentence say "ah spigot will fuck ABI"
I have said "strict"
the next time version-specific support is added in the form of api-version
im betting that they just drop support
And that PR is the whole opposite of "strict"
which is why a compatibility layer might be introduced
the forwards compatibility has really been a hamper on things
It will fuck every plugin permamently unless these basic fallback support options are included
But remapping an Enum to a non-enum is hard at best
?stash let me look if I remember that PR correctly at least
its basically using the system intended by minecraft
the 1.13 layer also had to aggressively change byte code calls
a registry based system
I don't see what your point is here
i think hes talking abt the material pr
So non-enum
if the material PR were to be accepted, forwards compat would cease to exist for prior version
which in my mind
Then yes, that is impossible to write an compat layer for
doubt
EnumSet and co. would need to be rewritten to work with the new registry system
And duplicate the whole codebase? No thanks
don't get me wrong, I am defo in favour of dropping backwards compat
backwards compatibility means the plugin developed on future versions can be used on prior versions
its definately forwards ive had this convo before
pretty sure backwards would be the server being able to execute code run against older versions of itself
how to detect if a player is eating
interactevent
or consume event
there's no "isEating"
(because its controlled clientside)
ok
I mean, the material refractor would kill both
How do I get a higher value from a config.yml patch? I wanted to put some numbers in order and I need to get the highest number from the setting and then add +1
If you write a plugin without the mat refractor it wouldn't run with the mat refract. Writing it with the mat refract it wouldn't run without it
if you define forwards compatibility like that, no new api will ever be forward compatible
afaik forwards compatibility is designing an API to be easily extendable, dynamic enough to not require backwards compatibility breaking changes to be extended
so did i do this right? v @EventHandler public void onAppleEat(PlayerItemConsumeEvent event, ItemStack item) { Player player = event.getPlayer(); { if(player.getInventory().getItemInMainHand().equals(Material.APPLE)) { player.sendMessage("eating"); } } }
Why not just event.getItem().getType()?
ok
Shit didn't realize
It's late for me lmao
lmao someone wants to pay me 200/300 euros to make a server for him
bruh lmfao
Not unheard of
Welcome to the wonderful world of being a sysadmin
i dont trust it
this doesn't work v if(event.getItem().getType() == Material.APPLE)
Can we get more context?
So I've never used the bungeecord messaging channel and I'm confused;
I want to do something very simple, get the number of players on a server
Read the doc of course and got this so far
I have the onPluginMessageReceived (at least this rn)
@Override
public void onPluginMessageReceived(String channel, Player player, byte[] message) {
if (!channel.equalsIgnoreCase("BungeeCord")) {
return;
}
ByteArrayDataInput input = ByteStreams.newDataInput(message);
String subchannel = input.readUTF();
}
and in a method this, with server being a string
ByteArrayDataOutput output = ByteStreams.newDataOutput();
output.writeUTF("PlayerCount");
output.writeUTF(server);
Now how would actually send the plugin message and receive the information?
@toxic mesa player.sendPluginMessage(..., input.toByteArray());
Wait let me write you an example
@EventHandler
public void onAppleEat(PlayerItemConsumeEvent event, ItemStack item)
{
Player player = event.getPlayer();
{
if(event.getItem().getType() == Material.APPLE)
{
player.sendMessage("eating");
}
}
}
}
Alright, so, I don't know what I did wrong, but I have this in a player drop item event and nothing happens. Any ideas?
Location loc = event.getItemDrop().getLocation();
World world = loc.getWorld();
world.playEffect(loc, Effect.FIREWORK_SHOOT , 5);
Player player; //get it how you want to
ByteArrayOutputStream stream = new ByteArrayOutputStream();
DataOutputStream out = new DataOutputStream(stream);
//try catch etc
out.writeUTF("PlayerCount");
out.writeUTF("whatever-server");
player.sendPluginMessage(plugin, "BungeeCord", stream.toByteArray());
``` @toxic mesa
So I would use the stream.toByteArray(), that's to send it right?
How would I like recieve the info and change it to let's say an Integer
?
How do I get a higher value from a config.yml patch? I wanted to put some numbers in order and I need to get the highest number from the setting and then add +1
wut
that's not right
why is item a parameter
you get the item from the event
Was testing
ah
how do i get the players ping in 1.17?
Player#getPing iirc
iirc you don't need to do NMS
ah ic, thx
can you modify the block list from BlockExplodeEvent#blockList() to change which blocks it removes?
can I somehow get if the rayTraceEntities goes through a specific block location?
does anyone have any basic plugin ideas to help me learn some more java
not going to be publicly released or anything
https://hub.spigotmc.org/javadocs/spigot/org/bukkit/configuration/ConfigurationSection.html#isColor(java.lang.String)
in here, does the person needs to put like ChatColor.RED
or just red
declaration: package: org.bukkit.configuration, interface: ConfigurationSection
How do I get a higher value from a config.yml patch? I wanted to put some numbers in order and I need to get the highest number from the setting and then add +1, help pls
Make a plugin that remakes minecraft
simple enough
can I somehow get if the rayTraceEntities goes through a specific block location?
How would I summon particles on a dropped item? I tried using the code below and it didn't work.
Location loc = event.getItemDrop().getLocation();
World world = loc.getWorld();
world.playEffect(loc, Effect.FIREWORK_SHOOT , 5);
how do i send a packet to a player in 1.17?
That might actually be the wrong thing to use, but
Does the server automatically skip loading a plugin if a dependency is missing, or do i need to add handling myself
Well yea but not with the method
You have to iterate with the vector you chose
Can you give me a code example maybe?
no im on mobile
How I can clone Packet (PacketPlayOutMapChunk and others)
Hey !
Just a question, I asked resources support 1 month ago a question by email, and I havn’t recieced any reply.
Is it normal ?
Thanks
can i hide only damage attribute on item?
why is it saying this ERROR Could not load 'plugins/Regex-1.0.jar' in folder 'plugins': uses the space-character (0x20) in its name when it tries to load my plugin?
have you tried reading the error message
yes, i see no space character
show plugin.yml
Could just be no one has an answer to a specific question
yea i fixed it, ty lol
Anyone?
i think the particles are spawning little lower than you put maybe up the y by .5?
it is yes
mostly because I don't have the effort to answer all of the nooby questions today
i'm sure there are at least 10 other people lurking around who could answer if they chose to
quick question -- should I use the "latest version" command if I want the latest 1.17 spigot build, or should i use the "1.17 version" command?
build tools?
ye
latest = latest
1.17 = 1.17
1.17 for 1.17 latest for 1.16.5
cuz the wiki says latest is 1.16.5 for some reason
'cause it hasnt been changed I dont think
well yeah but i think the latest = 1.16.5 and if you want 1.17 you just use 1.17 on buildtools i dont think they updated it since 1.17 is buggy and all that crap
1.17for 1.17
soo theres basically only one 1.17 version then, correct?
and ill just use 1.17 then
No
i believe theres like 20-25 versions already
lol
mine is probs outdated again
Yes
yeah it builds the latest 1.17
k bet thanks
watch everybody coming out of the woodwork
it will actually take quicker to update if nms is already decompiled lol
in the work folder
it took like 2 mins for me tho to update to a newer version of what version i had ;-;
5 mins normally for like when im building a new version i havent built before
Shouldn't they still make sounds?
Wait, nvm
particles generally don't make sounds
the only exception I can think of is the rain hitting a solid block particle
it doesnt
It doesn't? I would swear that and lava would have some sound effects
lol I was thinking of actually setting the thing off
it doesnt lol
i have summoned a water particle before
didnt make any noise
i'm not totally sure if the rain particles make the sound directly but I'd assume they do as rain goes totally quiet if I disable particles
could be some kind of optifine fucknuggetry I suppose
I have made my first plugin
loc.add(0, 0.5, 0)
oh
thought you could
Hey, I have a variable that updates based on when I place or break blocks, the problem Im getting is that when other people are on the server, instead of adding only 1 point, it adds the number of people that are on the server... Anyway I can fix this?
nice
How do I get a higher value from a config.yml patch? I wanted to put some numbers in order and I need to get the highest number from the setting and then add +1
all fields except for public constants are always private or protected
mojang minecraft code be like, not a chance
i actually thought the coords where public but i guess not
because that's not how java works
nothing mutable should ever be public
x y and z are mutable
why not?
look up encapsulation
k
any one can tell when was Material.isItem()
added
to spigot API
is there any page where are records when some new method get's added
brilliant
he's not joking
well what is he talking about then
internet archive
well page is not loading xd
it takes a bit
there servers are slow since loads of people use it
but dont blame it
its free
they only getting money from donations
Anyone knows how I detect the blocks a player will get "hit" into? Is there a event for this maybe or sth else
hit into?
not that i know of
so when a player got punched
by a player?
yes
Where the knockback will take them?
yes this would also be fine. I want to destroy the blocks which are in their way
Well, you could probably do it mathematically
It is a mix of PlayerDamageEvent, PlayerMoveListener and PlayerVelocityListener I think
maybe its EntityDamageEvent?
But I don't get the right velocity
sorry i meant that
EntityDamageByEntityEvent?
You can get positions, take the derivative of position as time changes
Players are entitys right?
yes
Can take three snapshots of position, plot a parabola through them, clear the next block in the parabola
Do you think this will also work, if the player stands right before a wall?
because there would be no position change
Probably not
Didn't change anything
it will be difficult to programmatically detect which blocks the player is colliding into, and even moreso before the player actually collides into them
this is largely because the api doesn't actually expose precise collision shapes
I tried it with a barrier underneath, there's no particles spawning at all
note that if you're doing that in an event, it only happens once
NNY? does EntityDamageByEntityEvent work for players?
a player is an entity
try adding a radius
e.getMessage().matches(Objects.requireNonNull(Arrays.toString(Objects.requireNonNull(getInstance().getConfig().getString("regex")).split("\\|"))))
so it used to give errors, but now its not even giving errors
error it used to give:
30.06 17:04:27 [Server] ERROR Could not pass event PlayerChatEvent to Regex-Censor v1.0
30.06 17:04:27 [Server] INFO java.util.regex.PatternSyntaxException: Unclosed character class near index 1
30.06 17:04:27 [Server] INFO []
30.06 17:04:27 [Server] INFO ^
30.06 17:04:27 [Server] INFO at java.util.regex.Pattern.error(Pattern.java:2027) ~[?:?]
30.06 17:04:27 [Server] INFO at java.util.regex.Pattern.clazz(Pattern.java:2695) ~[?:?]
30.06 17:04:27 [Server] INFO at java.util.regex.Pattern.sequence(Pattern.java:2138) ~[?:?]
30.06 17:04:27 [Server] INFO at java.util.regex.Pattern.expr(Pattern.java:2068) ~[?:?]
30.06 17:04:27 [Server] INFO at java.util.regex.Pattern.compile(Pattern.java:1782) ~[?:?]
30.06 17:04:27 [Server] INFO at java.util.regex.Pattern.<init>(Pattern.java:1428) ~[?:?]
30.06 17:04:27 [Server] INFO at java.util.regex.Pattern.compile(Pattern.java:1068) ~[?:?]
30.06 17:04:27 [Server] INFO at java.util.regex.Pattern.matches(Pattern.java:1173) ~[?:?]
30.06 17:04:27 [Server] INFO at java.lang.String.matches(String.java:2024) ~[?:?]
30.06 17:04:27 [Server] INFO at me.ChatListener.chatListener(ChatListener.java:17) ~[?:?]
Thank you. There is no need to find these blocks exactly. I just need a approximate way
How I can clone Packet (PacketPlayOutMapChunk and others)
Still nothing
rip
Location loc = event.getItemDrop().getLocation();
loc.add(0,0.5,0);
World world = loc.getWorld();
world.playEffect(loc, Effect.FIREWORK_SHOOT , 5, 5);
That's what I have rn
note that if you do that in an event, the particles are only spawned once
Okay.... ?
Meaning they're only there for a millisecond or something?
Because there's nothing
if you're listening to the drop event, you probably can't see the particles because they're spawned where the item is created
namely inside the player
try a different particle
i think for fireworks you need to set like more data like for color,damage or something
:thonk:
bruh
There's no fire, just bow fire and firework shot
Shouldn't it at least play sound, then?
what you want is to use the Particle close
no
it summons a fucking effect not playing a sound
you want Particle.FIREWORKS_SPARK
i think
How I can clone Packet (PacketPlayOutMapChunk and others)
make a class that extends PacketPlayOutMapChunk ?
just build the packetiself
it has a constructor as everything else
whats var1 its up to you
but i guess its entity id
is this basically as close for documentation for nms protocol shit https://wiki.vg/Protocol ?
most of the times yes
Still doesn't work
Location loc = event.getItemDrop().getLocation();
World world = loc.getWorld();
loc.add(0,0.5,0);
world.spawnParticle(Particle.FIREWORKS_SPARK, 0, 0, 0, 50);
Wait
add reurns a clone
why
immutable
imagine takking the location of a player then randomly adding to it
rip..
World world = loc.getWorld();
loc = loc.add(0,0.5,0);
world.spawnParticle(Particle.FIREWORKS_SPARK, loc, 50);```
¯_(ツ)_/¯
That doesn't work
why?
How clone object without cloneable?>
Because I just tried it and it did nothing... ?
oh wait
We've already told you what to do
That's what I had before you even sent that
yeah check
They're all on
should be good to go try it with a default client
also are you sure the code even gets there?
by constructor?
do you have some message
bad method ;/
Yes, because it adds the enchant and gets rid of the book
it could be spawning in the ground still
wait make sure the item you dropped is actually there
it might not let you get the location of it if its not there
realy you can tell me how clone object (without constructor)?
It's there...
well maybe try adding more to the y?
I'm dropping it on top of a barrier block that's two blocks above the ground
f
then idk
either thats its not getting the Location or something is wrong with your client
or it could be something else but i doubt it
What in hell
?
This is the only way without using Mixins
I added System.out.println(loc) and System.out.println("Added enchant"), neither were sent
f
what is Mixins?
This is what I have for that entire part rn
https://paste.md-5.net/tisudixeyu.cs
Let's not use them... It's a system for injecting code
lol
there must be another way
No why would there need to be
you can not clone an object without a constructor
if you do not invoke a constructor anywhere, then no new object is created
and thus there can be no clone
^
This is stupid
add still returns a clone so that's not doing anything
@granite stirrup I am have dumb
And I am… having a stroke reading that
Probably
?
Wait, what? This message? #help-development message
I had the code for the particle on the wrong enchant
lol
u should make it so you can reuse some code cuz putting same code in multiple classes or in different methods is really not a good idea
After you said that I realized there's a way more efficient way to do part of this
well
maybe
I am have stupid tho
That's what I ended up doing is using a utils class for stuff like a confirmation gui, just make it return a boolean etc
Util classes are the best
does anyone know of a way to check if a mv world exists and finished initializing
using the mv api
some code get ran and boom chunks now exists
jk
well i believe this is how mc world get created:
- world filled with stone with terrain (called voice-map or something)
- add grass, water
- add structures and trees and stuff
nop
maybe nether world are just lighter
do you use paper
because chunk generation differs on paper, especially in speed
so you'll have to ask the paper people
you'll probably be better served over there anyway, as basically everyone here are noobs and haven't worked on world generation, let alone know how it works under the hood
have you asked the paper people
how 2 cancel a bukkit task
ik its like Bukkit.getScheduler().cancelTask(id);
but i cant use it from within the runnable
since the int id is not initialized
can't you just do cancel()
if you need to use it within the runnable, you need to use a BukkitRunnable
and call this.cancel()
i use a runnable inside the runnable i want to cancel?
new BukkitRunnable() {