mirror of
https://github.com/CitizensDev/Citizens2.git
synced 2024-11-25 03:55:30 +01:00
Update gravity trait methods to make sense
This commit is contained in:
parent
ca12c83c25
commit
73a5cfdee6
@ -581,7 +581,7 @@ public class CitizensNPC extends AbstractNPC {
|
||||
data().setPersistent(NPC.Metadata.FLYABLE, true);
|
||||
}
|
||||
if (!hasTrait(Gravity.class)) {
|
||||
getOrAddTrait(Gravity.class).setEnabled(true);
|
||||
getOrAddTrait(Gravity.class).setHasGravity(false);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -17,7 +17,7 @@ import net.citizensnpcs.util.Messages;
|
||||
* @see Ageable
|
||||
*/
|
||||
@TraitName("age")
|
||||
public class Age extends Trait implements Toggleable {
|
||||
public class Age extends Trait {
|
||||
@Persist
|
||||
private int age = 0;
|
||||
private Ageable ageable;
|
||||
@ -82,7 +82,6 @@ public class Age extends Trait implements Toggleable {
|
||||
/**
|
||||
* Toggles the age lock variable and returns whether the age is currently locked.
|
||||
*/
|
||||
@Override
|
||||
public boolean toggle() {
|
||||
locked = !locked;
|
||||
if (isAgeable()) {
|
||||
|
@ -32,7 +32,7 @@ import net.citizensnpcs.util.Util;
|
||||
* e.g. arrow keys.
|
||||
*/
|
||||
@TraitName("controllable")
|
||||
public class Controllable extends Trait implements Toggleable {
|
||||
public class Controllable extends Trait {
|
||||
private MovementController controller;
|
||||
@Persist
|
||||
private BuiltInControls controls;
|
||||
@ -152,7 +152,6 @@ public class Controllable extends Trait implements Toggleable {
|
||||
this.ownerRequired = ownerRequired;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean toggle() {
|
||||
enabled = !enabled;
|
||||
if (!enabled && NMS.getPassengers(npc.getEntity()).size() > 0) {
|
||||
|
@ -9,7 +9,7 @@ import net.citizensnpcs.util.NMS;
|
||||
* Enable/disable Minecraft's gravity.
|
||||
*/
|
||||
@TraitName("gravity")
|
||||
public class Gravity extends Trait implements Toggleable {
|
||||
public class Gravity extends Trait {
|
||||
@Persist("enabled")
|
||||
private boolean nogravity;
|
||||
|
||||
@ -24,16 +24,6 @@ public class Gravity extends Trait implements Toggleable {
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Set whether to disable gravity or not
|
||||
*
|
||||
* @param gravitate
|
||||
* true = disable gravity, false = enable gravity
|
||||
*/
|
||||
public void gravitate(boolean gravitate) {
|
||||
nogravity = gravitate;
|
||||
}
|
||||
|
||||
public boolean hasGravity() {
|
||||
return !nogravity;
|
||||
}
|
||||
@ -50,11 +40,13 @@ public class Gravity extends Trait implements Toggleable {
|
||||
NMS.setNoGravity(npc.getEntity(), nogravity);
|
||||
}
|
||||
|
||||
public void setEnabled(boolean enabled) {
|
||||
nogravity = enabled;
|
||||
/**
|
||||
* Set whether to have gravity or not
|
||||
*/
|
||||
public void setHasGravity(boolean hasGravity) {
|
||||
nogravity = !hasGravity;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean toggle() {
|
||||
nogravity = !nogravity;
|
||||
applyImmediately();
|
||||
|
@ -36,7 +36,7 @@ import net.citizensnpcs.util.Util;
|
||||
*
|
||||
*/
|
||||
@TraitName("lookclose")
|
||||
public class LookClose extends Trait implements Toggleable {
|
||||
public class LookClose extends Trait {
|
||||
@Persist("disablewhilenavigating")
|
||||
private boolean disableWhileNavigating = Setting.DISABLE_LOOKCLOSE_WHILE_NAVIGATING.asBoolean();
|
||||
@Persist("enabled")
|
||||
@ -376,7 +376,6 @@ public class LookClose extends Trait implements Toggleable {
|
||||
return targetNPCs;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean toggle() {
|
||||
enabled = !enabled;
|
||||
return enabled;
|
||||
|
@ -14,7 +14,7 @@ import net.citizensnpcs.util.Util;
|
||||
* @see Pig#hasSaddle()
|
||||
*/
|
||||
@TraitName("saddle")
|
||||
public class Saddle extends Trait implements Toggleable {
|
||||
public class Saddle extends Trait {
|
||||
@Persist("")
|
||||
private boolean saddle;
|
||||
private boolean steerable;
|
||||
@ -33,7 +33,6 @@ public class Saddle extends Trait implements Toggleable {
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean toggle() {
|
||||
saddle = !saddle;
|
||||
if (steerable) {
|
||||
|
@ -1,8 +0,0 @@
|
||||
package net.citizensnpcs.trait;
|
||||
|
||||
/**
|
||||
* Representing a state that can be toggled between enabled/disabled.
|
||||
*/
|
||||
public interface Toggleable {
|
||||
public boolean toggle();
|
||||
}
|
Loading…
Reference in New Issue
Block a user