Skip to content

Commit

Permalink
Adjust rich locations (method order, prevent super class set).
Browse files Browse the repository at this point in the history
  • Loading branch information
asofold committed Apr 22, 2016
1 parent 909e6d5 commit c98f883
Show file tree
Hide file tree
Showing 3 changed files with 57 additions and 6 deletions.
@@ -1,6 +1,7 @@
package fr.neatmonster.nocheatplus.utilities;

import org.bukkit.Location;
import org.bukkit.entity.LivingEntity;
import org.bukkit.entity.Player;

import fr.neatmonster.nocheatplus.compat.MCAccess;
Expand Down Expand Up @@ -90,6 +91,14 @@ public void set(final Location location, final Player player, final double yOnGr
this.onIce = null;
}

/**
* Not supported.
*/
@Override
public void set(Location location, LivingEntity livingEntity, double yOnGround) {
throw new UnsupportedOperationException("Set must specify an instance of Player.");
}

/**
* Set cached info according to other.<br>
* Minimal optimizations: take block flags directly, on-ground max/min bounds, only set stairs if not on ground and not reset-condition.
Expand Down
Expand Up @@ -108,15 +108,22 @@ public boolean isOnGroundDueToStandingOnAnEntity() {
}

/**
* Set cached info according to other.<br>
* Minimal optimizations: take block flags directly, on-ground max/min bounds, only set stairs if not on ground and not reset-condition.
* @param other
* Convenience constructor for using mcAccess.getHeight for fullHeight.
* @param location
* @param entity
* @param yOnGround
*/
public void prepare(final RichEntityLocation other) {
super.prepare(other);
this.standsOnEntity = other.standsOnEntity;
public void set(final Location location, final Entity entity, final double yOnGround) {
set(location, entity, mcAccess.getHeight(entity), yOnGround);
}

/**
*
* @param location
* @param entity
* @param fullHeight Allows to specify eyeHeight here.
* @param yOnGround
*/
public void set(final Location location, final Entity entity, final double fullHeight, final double yOnGround) {
super.set(location, mcAccess.getWidth(entity), fullHeight, yOnGround);
this.entity = entity;
Expand All @@ -125,6 +132,24 @@ public void set(final Location location, final Entity entity, final double fullH
standsOnEntity = false;
}

/**
* Not supported.
*/
@Override
public void set(Location location, double fullWidth, double fullHeight, double yOnGround) {
throw new UnsupportedOperationException("Set must specify an instance of Entity.");
}

/**
* Set cached info according to other.<br>
* Minimal optimizations: take block flags directly, on-ground max/min bounds, only set stairs if not on ground and not reset-condition.
* @param other
*/
public void prepare(final RichEntityLocation other) {
super.prepare(other);
this.standsOnEntity = other.standsOnEntity;
}

/**
* Set some references to null.
*/
Expand Down
@@ -1,6 +1,7 @@
package fr.neatmonster.nocheatplus.utilities;

import org.bukkit.Location;
import org.bukkit.entity.Entity;
import org.bukkit.entity.LivingEntity;

import fr.neatmonster.nocheatplus.compat.MCAccess;
Expand Down Expand Up @@ -138,6 +139,22 @@ public void set(final Location location, final LivingEntity livingEntity, final
this.eyeHeight = livingEntity.getEyeHeight();
}

/**
* Not supported.
*/
@Override
public void set(Location location, Entity entity, double yOnGround) {
throw new UnsupportedOperationException("Set must specify an instance of LivingEntity.");
}

/**
* Not supported.
*/
@Override
public void set(Location location, Entity entity, double fullHeight, double yOnGround) {
throw new UnsupportedOperationException("Set must specify an instance of LivingEntity.");
}

// No need to override prepare.

/**
Expand Down

0 comments on commit c98f883

Please sign in to comment.