Skip to content

Additional commands#1

Draft
TheMadHau5 wants to merge 6 commits intoKroppeb:masterfrom
TheMadHau5:master
Draft

Additional commands#1
TheMadHau5 wants to merge 6 commits intoKroppeb:masterfrom
TheMadHau5:master

Conversation

@TheMadHau5
Copy link

@TheMadHau5 TheMadHau5 commented Apr 24, 2020

Merge this after I finish the following commands:

  • /effect
  • /setblock
  • /fill
  • /give
  • /gamemode
  • /gamerule
  • /clear

public ClearCommand(Selector targets, StatusEffect effect) {
this.targets = targets;
this.effect = effect;
this.effect = null;
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'm assuming this should be this.effect = effect?

@@ -100,47 +98,56 @@ public int execute(ServerCommandSource source) {
}
duration *= 20;
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Doesn't this multiply the duration with 20 each time?
Maybe do the multiply and the effect.isInstant in the constructor?

Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This also gives an error as duration is final


abstract public class EffectCommand implements Command {
final Selector targets;
final StatusEffect effect;
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

EffectCommand needs a constructor to initialize these.


public GiveCommand(Selector targets, StatusEffect effect, int duration, int amplifier, boolean hideParticles) {
this.targets = targets;
this.effect = effect;
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

These should be passed to the super constructor.


public static ClearCommand read(Reader reader) throws ReaderException {
Selector targets = Selector.read(reader);
StatusEffect effect;
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

should be initialized with null in case the if does not execute.


public static GiveCommand read(Reader reader) throws ReaderException {
Selector targets = Selector.read(reader);
Identifier item = Registry.ITEM.get(reader.readIdentifier());
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Should be stored in an Item

Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'll make a readItem that handles the nbt.


int stackMax = item.getMaxCount();
int stackCount = count / stackMax;
ItemStack stack = ItemStack(item, stackMax);
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Missing new.

for (Entity entity : entities) {
if (entity instanceof PlayerEntity) {
player = (PlayerEntity) entity;
for (int i = 0; i < stackCount + 1; i++) {
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

i <= stackCount is a bit neater.

ItemStack stack = ItemStack(item, stackMax);
// TODO: throw error for 'illegal' item (not found)

Collection<Entity> entities = targets.getEntities(source);
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'm gonna make a getPlayers

Collection<Entity> entities = targets.getEntities(source);
for (Entity entity : entities) {
if (entity instanceof PlayerEntity) {
player = (PlayerEntity) entity;
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Missing type.

@Kroppeb Kroppeb marked this pull request as draft April 25, 2020 11:01
@Kroppeb Kroppeb added the enhancement New feature or request label Apr 25, 2020
@TheMadHau5
Copy link
Author

will fix soon after i get eclipse

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

enhancement New feature or request

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants