Permalink
Browse files

Merge branch 'master' into new-html-docs

  • Loading branch information...
LadyCailin committed Dec 6, 2017
2 parents 40530bf + d5ffeb8 commit 11f7d0ae39a1e69114e1f7993cd03eccb05821d4
@@ -81,7 +81,7 @@ public Vector3D multiply(double m) {
}
/**
* Returns a new vector of this vector multiplied by another.
* Returns a new vector of this vector divided by another.
*
* @param other the other vector
* @return a new vector
@@ -91,9 +91,9 @@ public Vector3D divide(Vector3D other) {
}
/**
* Returns a new vector of this vector multiplied by a value.
* Returns a new vector of this vector divided by a value.
*
* @param m the value to multiply by
* @param m the value to divide by
* @return a new vector
*/
public Vector3D divide(double m) {
@@ -108,6 +108,9 @@ public Vector3D divide(double m) {
*/
public Vector3D normalize() {
double length = length();
if(length == 0.0) {
return Vector3D.ZERO;
}
return new Vector3D(x / length, y / length, z / length);
}
@@ -1,16 +1,12 @@
package com.laytonsmith.abstraction.bukkit;
import com.laytonsmith.PureUtilities.Common.ReflectionUtils;
import com.laytonsmith.abstraction.MCObjective;
import com.laytonsmith.abstraction.MCScore;
import com.laytonsmith.abstraction.MCScoreboard;
import com.laytonsmith.abstraction.enums.MCDisplaySlot;
import com.laytonsmith.abstraction.enums.bukkit.BukkitMCDisplaySlot;
import org.bukkit.Bukkit;
import org.bukkit.OfflinePlayer;
import org.bukkit.scoreboard.DisplaySlot;
import org.bukkit.scoreboard.Objective;
import org.bukkit.scoreboard.Score;
public class BukkitMCObjective implements MCObjective {
@@ -1,7 +1,6 @@
package com.laytonsmith.abstraction.bukkit;
import com.laytonsmith.abstraction.MCObjective;
import com.laytonsmith.abstraction.MCOfflinePlayer;
import com.laytonsmith.abstraction.MCScore;
import com.laytonsmith.abstraction.MCScoreboard;
import org.bukkit.scoreboard.Score;
@@ -2,7 +2,6 @@
import com.laytonsmith.PureUtilities.Common.ReflectionUtils;
import com.laytonsmith.abstraction.MCObjective;
import com.laytonsmith.abstraction.MCOfflinePlayer;
import com.laytonsmith.abstraction.MCScore;
import com.laytonsmith.abstraction.MCScoreboard;
import com.laytonsmith.abstraction.MCTeam;
@@ -6,7 +6,6 @@
import com.laytonsmith.abstraction.enums.MCNameTagVisibility;
import com.laytonsmith.abstraction.enums.MCOption;
import com.laytonsmith.abstraction.enums.MCOptionStatus;
import com.laytonsmith.abstraction.enums.bukkit.BukkitMCNameTagVisibility;
import com.laytonsmith.abstraction.enums.bukkit.BukkitMCOption;
import com.laytonsmith.abstraction.enums.bukkit.BukkitMCOptionStatus;
import org.bukkit.Bukkit;
@@ -143,7 +142,7 @@ public void setDisplayName(String displayName) {
@Override
public void setNameTagVisibility(MCNameTagVisibility visibility) {
t.setNameTagVisibility(BukkitMCNameTagVisibility.getConvertor().getConcreteEnum(visibility));
t.setNameTagVisibility(NameTagVisibility.valueOf(visibility.name()));
}
@Override
@@ -6,10 +6,6 @@
import org.bukkit.entity.Creeper;
import org.bukkit.entity.Entity;
/**
*
* @author Jason Unger <entityreborn@gmail.com>
*/
public class BukkitMCCreeper extends BukkitMCLivingEntity implements MCCreeper {
Creeper creeper;
@@ -31,4 +27,42 @@ public boolean isPowered() {
public void setPowered(boolean powered) {
creeper.setPowered(powered);
}
@Override
public int getMaxFuseTicks() {
try {
return creeper.getMaxFuseTicks();
} catch(NoSuchMethodError ex) {
// Probably prior to 1.12.2
return 30;
}
}
@Override
public void setMaxFuseTicks(int ticks) {
try {
creeper.setMaxFuseTicks(ticks);
} catch(NoSuchMethodError ex){
// Probably prior to 1.12.2
}
}
@Override
public int getExplosionRadius() {
try {
return creeper.getExplosionRadius();
} catch(NoSuchMethodError ex) {
// Probably prior to 1.12.2
return 3;
}
}
@Override
public void setExplosionRadius(int radius) {
try {
creeper.setExplosionRadius(radius);
} catch(NoSuchMethodError ex) {
// Probably prior to 1.12.2
}
}
}
@@ -1,11 +1,11 @@
package com.laytonsmith.abstraction.entities;
/**
*
* @author Jason Unger <entityreborn@gmail.com>
*/
public interface MCCreeper {
boolean isPowered();
void setPowered(boolean powered);
int getMaxFuseTicks();
void setMaxFuseTicks(int ticks);
int getExplosionRadius();
void setExplosionRadius(int radius);
}
@@ -4,6 +4,8 @@
@MEnum("EntityEffect")
public enum MCEntityEffect {
ARROW_PARTICLES,
RABBIT_JUMP,
DEATH,
HURT,
SHEEP_EAT,
@@ -16,5 +18,17 @@
VILLAGER_HAPPY,
WITCH_MAGIC,
ZOMBIE_TRANSFORM,
FIREWORK_EXPLODE
FIREWORK_EXPLODE,
LOVE_HEARTS,
SQUID_ROTATE,
ENTITY_POOF,
GUARDIAN_TARGET,
SHIELD_BLOCK,
SHIELD_BREAK,
ARMOR_STAND_HIT,
THORNS_HURT,
IRON_GOLEM_SHEATH,
TOTEM_RESURRECT,
HURT_DROWN,
HURT_EXPLOSION
}

This file was deleted.

Oops, something went wrong.
@@ -20,8 +20,10 @@
import com.laytonsmith.annotations.api;
import com.laytonsmith.core.compiler.OptimizationUtilities;
import com.laytonsmith.core.constructs.CString;
import com.laytonsmith.core.constructs.Construct;
import com.laytonsmith.core.constructs.Target;
import com.laytonsmith.core.exceptions.ConfigCompileException;
import com.laytonsmith.core.exceptions.ConfigCompileGroupException;
import com.laytonsmith.core.extensions.ExtensionManager;
import com.laytonsmith.core.functions.FunctionBase;
import com.laytonsmith.core.functions.FunctionList;
@@ -52,9 +54,13 @@
import java.util.ArrayList;
import java.util.Arrays;
import java.util.Collections;
import java.util.HashMap;
import java.util.HashSet;
import java.util.List;
import java.util.Map;
import java.util.Set;
import jline.console.ConsoleReader;
import org.json.simple.JSONValue;
import org.yaml.snakeyaml.Yaml;
/**
@@ -130,7 +136,9 @@
.addArgument("html", "The type of the documentation, defaulting to html. It may be one of the following: " + StringUtils.Join(DocGen.MarkupType.values(), ", ", ", or "), "type", false);
suite.addMode("docs", docsMode);
verifyMode = ArgumentParser.GetParser()
.addDescription("Compiles all the files in the system, simply checking for compile errors, then exits.");
.addDescription("Compiles the given file, returning a json describing the errors in the file, or returning"
+ " nothing if the file compiles cleanly.")
.addArgument("The file to check", "<file>", true);
suite.addMode("verify", verifyMode);
installCmdlineMode = ArgumentParser.GetParser()
.addDescription("Installs MethodScript to your system, so that commandline scripts work. (Currently only unix is supported.)");
@@ -355,8 +363,7 @@ public static void main(String[] args) throws Exception {
} else if (mode == copyrightMode) {
StreamUtils.GetSystemOut().println("The MIT License (MIT)\n"
+ "\n"
+ "Copyright (c) 2012 Layton Smith, sk89q, Deaygo, \n"
+ "t3hk0d3, zml2008, EntityReborn, and albatrossen\n"
+ "Copyright (c) 2012-2017 Methodscript Contributors\n"
+ "\n"
+ "Permission is hereby granted, free of charge, to any person obtaining a copy of \n"
+ "this software and associated documentation files (the \"Software\"), to deal in \n"
@@ -405,23 +412,36 @@ public static void main(String[] args) throws Exception {
ExampleLocalPackageInstaller.run(MethodScriptFileLocations.getDefault().getJarDirectory(),
parsedArgs.getStringArgument());
} else if (mode == verifyMode) {
StreamUtils.GetSystemOut().println("This functionality is not currently implemented!");
// File f = new File(".");
// for (File a : f.listFiles()) {
// if (a.getName().equals("CommandHelper.jar")) {
// //We are in the plugins folder
// f = new File("CommandHelper/bukkit.jar");
// if (!f.exists()) {
// StreamUtils.GetSystemOut().println("In order to run the --test-compile command, you must include the latest build of bukkit (not craftbukkit)"
// + " in the CommandHelper folder. You MUST rename it to bukkit.jar. See the wiki for more information.");
// System.exit(1);
// }
// break;
// }
// }
// String file = (i + 1 <= l.size() - 1 ? l.get(i + 1).toString().toLowerCase() : null);
//
// return;
String file = parsedArgs.getStringArgument();
if ("".equals(file)) {
StreamUtils.GetSystemErr().println("File parameter is required.");
System.exit(1);
}
File f = new File(file);
String script = FileUtil.read(f);
try {
try {
MethodScriptCompiler.compile(MethodScriptCompiler.lex(script, f, file.endsWith("ms")));
} catch (ConfigCompileException ex) {
Set<ConfigCompileException> s = new HashSet<>(1);
s.add(ex);
throw new ConfigCompileGroupException(s);
}
} catch (ConfigCompileGroupException ex) {
List<Map<String, Object>> err = new ArrayList<>();
for (ConfigCompileException e : ex.getList()) {
Map<String, Object> error = new HashMap<>();
error.put("msg", e.getMessage());
error.put("file", e.getFile().getAbsolutePath());
error.put("line", e.getLineNum());
error.put("col", e.getColumn());
// TODO: Need to track target length for this
error.put("len", 0);
err.add(error);
}
String serr = JSONValue.toJSONString(err);
StreamUtils.GetSystemOut().println(serr);
}
} else if (mode == apiMode) {
String function = parsedArgs.getStringArgument();
if ("".equals(function)) {
@@ -2677,6 +2677,8 @@ public Construct exec(Target t, Environment environment, Construct... args) thro
case CREEPER:
MCCreeper creeper = (MCCreeper) entity;
specArray.set(entity_spec.KEY_CREEPER_POWERED, CBoolean.get(creeper.isPowered()), t);
specArray.set(entity_spec.KEY_CREEPER_MAXFUSETICKS, new CInt(creeper.getMaxFuseTicks(), t), t);
specArray.set(entity_spec.KEY_CREEPER_EXPLOSIONRADIUS, new CInt(creeper.getExplosionRadius(), t), t);
break;
case DONKEY:
case MULE:
@@ -2938,6 +2940,8 @@ public CHVersion since() {
private static final String KEY_ARMORSTAND_SMALLSIZE = "small";
private static final String KEY_ARMORSTAND_VISIBLE = "visible";
private static final String KEY_CREEPER_POWERED = "powered";
private static final String KEY_CREEPER_MAXFUSETICKS = "maxfuseticks";
private static final String KEY_CREEPER_EXPLOSIONRADIUS = "explosionradius";
private static final String KEY_DROPPED_ITEM_ITEMSTACK = "itemstack";
private static final String KEY_DROPPED_ITEM_PICKUPDELAY = "pickupdelay";
private static final String KEY_ENDERCRYSTAL_BASE = "base";
@@ -3188,6 +3192,20 @@ public Construct exec(Target t, Environment environment, Construct... args) thro
case entity_spec.KEY_CREEPER_POWERED:
creeper.setPowered(Static.getBoolean(specArray.get(index, t)));
break;
case entity_spec.KEY_CREEPER_MAXFUSETICKS:
try {
creeper.setMaxFuseTicks(Static.getInt32(specArray.get(index, t), t));
} catch(IllegalArgumentException ex) {
throw new CRERangeException("Ticks must not be negative.", t);
}
break;
case entity_spec.KEY_CREEPER_EXPLOSIONRADIUS:
try {
creeper.setExplosionRadius(Static.getInt32(specArray.get(index, t), t));
} catch(IllegalArgumentException ex) {
throw new CRERangeException("Radius must not be negative.", t);
}
break;
default:
throwException(index, t);
}
Oops, something went wrong.

0 comments on commit 11f7d0a

Please sign in to comment.