Skip to content

Commit

Permalink
Make dEllipsoids notable
Browse files Browse the repository at this point in the history
Untested. Also, remove pointless MapCursor direction check...
  • Loading branch information
Morphan1 committed Dec 12, 2014
1 parent 6a6f28c commit 6b9eaec
Show file tree
Hide file tree
Showing 3 changed files with 24 additions and 9 deletions.
24 changes: 22 additions & 2 deletions src/main/java/net/aufdemrand/denizen/objects/dEllipsoid.java
@@ -1,5 +1,8 @@
package net.aufdemrand.denizen.objects;

import net.aufdemrand.denizen.objects.notable.Notable;
import net.aufdemrand.denizen.objects.notable.NotableManager;
import net.aufdemrand.denizen.objects.notable.Note;
import net.aufdemrand.denizen.objects.properties.Property;
import net.aufdemrand.denizen.objects.properties.PropertyParser;
import net.aufdemrand.denizen.tags.Attribute;
Expand All @@ -9,7 +12,7 @@
import java.util.List;


public class dEllipsoid implements dObject {
public class dEllipsoid implements dObject, Notable {
//////////////////
// OBJECT FETCHER
////////////////
Expand All @@ -23,7 +26,8 @@ public class dEllipsoid implements dObject {
@Fetchable("ellipsoid")
public static dEllipsoid valueOf(String string) {

string = string.substring("ellipsoid@".length());
if (string.startsWith("ellipsoid@"))
string = string.substring(10);

List<String> split = CoreUtilities.Split(string, ',');

Expand Down Expand Up @@ -111,6 +115,22 @@ public boolean isUnique() {
return false;
}

@Override
@Note("Ellipsoids")
public Object getSaveObject() {
return identify().substring(10);
}

@Override
public void makeUnique(String id) {
NotableManager.saveAs(this, id);
}

@Override
public void forget() {
NotableManager.remove(this);
}

@Override
public String getObjectType() {
return "Ellipsoid";
Expand Down
Expand Up @@ -24,6 +24,7 @@ public class NotableManager {

public NotableManager() {
registerWithNotableManager(dCuboid.class);
registerWithNotableManager(dEllipsoid.class);
registerWithNotableManager(dInventory.class);
registerWithNotableManager(dItem.class);
registerWithNotableManager(dLocation.class);
Expand Down
Expand Up @@ -23,20 +23,14 @@ public MapCursor(String xTag, String yTag, String visibilityTag, boolean debug,
}

public byte getDirection(dPlayer player) {
double direction = aH.getDoubleFrom(tag(directionTag, player));
if (direction >= 0 && direction <= 360)
return yawToDirection(direction);
else
dB.echoError("Cursor directions must be between 0 and 360! Until this is fixed, the direction will be 0!");
return 0;
return yawToDirection(aH.getDoubleFrom(tag(directionTag, player)));
}

public org.bukkit.map.MapCursor.Type getType(dPlayer player) {
return org.bukkit.map.MapCursor.Type.valueOf(tag(typeTag, player).toUpperCase());
}

private byte yawToDirection(double yaw) {
//return (byte) Math.floor(((yaw + 11.25) % 348.75) / 22.5);
return (byte) (Math.floor((yaw / 22.5) + 0.5) % 16);
}

Expand Down

0 comments on commit 6b9eaec

Please sign in to comment.