Skip to content

Commit

Permalink
Commit missed diffs
Browse files Browse the repository at this point in the history
  • Loading branch information
PseudoKnight committed Aug 8, 2018
1 parent 0ccb963 commit ce6290d
Show file tree
Hide file tree
Showing 18 changed files with 77 additions and 119 deletions.
6 changes: 5 additions & 1 deletion src/main/java/com/laytonsmith/abstraction/MCPlayer.java
@@ -1,5 +1,7 @@
package com.laytonsmith.abstraction;

import com.laytonsmith.abstraction.blocks.MCBlockData;
import com.laytonsmith.abstraction.blocks.MCMaterial;
import com.laytonsmith.abstraction.enums.MCInstrument;
import com.laytonsmith.abstraction.enums.MCParticle;
import com.laytonsmith.abstraction.enums.MCSound;
Expand Down Expand Up @@ -109,7 +111,9 @@ public interface MCPlayer extends MCCommandSender, MCHumanEntity, MCOfflinePlaye

String getHost();

void sendBlockChange(MCLocation loc, int material, byte data);
void sendBlockChange(MCLocation loc, MCMaterial material, byte data);

void sendBlockChange(MCLocation loc, MCBlockData data);

void sendSignTextChange(MCLocation loc, String[] lines);

Expand Down
Expand Up @@ -109,7 +109,6 @@
import org.bukkit.entity.ComplexEntityPart;
import org.bukkit.entity.ComplexLivingEntity;
import org.bukkit.entity.Entity;
import org.bukkit.entity.EntityType;
import org.bukkit.entity.Fireball;
import org.bukkit.entity.Hanging;
import org.bukkit.entity.HumanEntity;
Expand Down
Expand Up @@ -24,7 +24,6 @@
import com.laytonsmith.abstraction.enums.MCParticle;
import com.laytonsmith.abstraction.enums.MCSound;
import com.laytonsmith.abstraction.enums.MCSoundCategory;
import com.laytonsmith.abstraction.enums.MCVersion;
import com.laytonsmith.abstraction.enums.MCWeather;
import com.laytonsmith.abstraction.enums.bukkit.BukkitMCInstrument;
import com.laytonsmith.abstraction.enums.bukkit.BukkitMCSound;
Expand Down
Expand Up @@ -9,7 +9,6 @@
import com.laytonsmith.abstraction.MCPlayer;
import com.laytonsmith.abstraction.MCTravelAgent;
import com.laytonsmith.abstraction.MCWorld;
import com.laytonsmith.abstraction.StaticLayer;
import com.laytonsmith.abstraction.blocks.MCBlock;
import com.laytonsmith.abstraction.blocks.MCBlockFace;
import com.laytonsmith.abstraction.bukkit.BukkitConvertor;
Expand All @@ -19,7 +18,6 @@
import com.laytonsmith.abstraction.bukkit.BukkitMCTravelAgent;
import com.laytonsmith.abstraction.bukkit.BukkitMCWorld;
import com.laytonsmith.abstraction.bukkit.blocks.BukkitMCBlock;
import com.laytonsmith.abstraction.bukkit.entities.BukkitMCEntity;
import com.laytonsmith.abstraction.bukkit.entities.BukkitMCFishHook;
import com.laytonsmith.abstraction.bukkit.entities.BukkitMCHumanEntity;
import com.laytonsmith.abstraction.bukkit.entities.BukkitMCPlayer;
Expand Down Expand Up @@ -658,7 +656,7 @@ public MCPlayer getEntity() {

@Override
public MCEntity getKiller() {
return StaticLayer.GetCorrectEntity(new BukkitMCEntity(pde.getEntity().getKiller()));
return BukkitConvertor.BukkitGetCorrectEntity(pde.getEntity().getKiller());
}

@Override
Expand Down
Expand Up @@ -9,7 +9,7 @@
import com.laytonsmith.abstraction.bukkit.blocks.BukkitMCBlock;
import com.laytonsmith.abstraction.enums.MCCollisionType;
import com.laytonsmith.abstraction.events.MCVehicleBlockCollideEvent;
import com.laytonsmith.abstraction.events.MCVehicleEnitityCollideEvent;
import com.laytonsmith.abstraction.events.MCVehicleEntityCollideEvent;
import com.laytonsmith.abstraction.events.MCVehicleEnterExitEvent;
import com.laytonsmith.abstraction.events.MCVehicleEvent;
import com.laytonsmith.abstraction.events.MCVehicleMoveEvent;
Expand All @@ -28,7 +28,7 @@ public class BukkitVehicleEvents {

@abstraction(type = Implementation.Type.BUKKIT)
public static class BukkitMCVehicleEntityCollideEvent extends BukkitMCVehicleEvent
implements MCVehicleEnitityCollideEvent {
implements MCVehicleEntityCollideEvent {

VehicleEntityCollisionEvent vec;

Expand Down
19 changes: 7 additions & 12 deletions src/main/java/com/laytonsmith/abstraction/enums/MCEntityType.java
Expand Up @@ -8,6 +8,7 @@

import java.util.ArrayList;
import java.util.Collection;
import java.util.HashMap;
import java.util.HashSet;
import java.util.Map;
import java.util.Set;
Expand All @@ -16,8 +17,8 @@
public abstract class MCEntityType<Concrete> extends DynamicEnum<MCEntityType.MCVanillaEntityType, Concrete> {

// To be filled by the implementer
protected static Map<String, MCEntityType> mappings;
protected static Map<MCVanillaEntityType, MCEntityType> vanilla;
protected static final Map<String, MCEntityType> MAP = new HashMap<>();
protected static final Map<MCVanillaEntityType, MCEntityType> VANILLA_MAP = new HashMap<>();

@SuppressWarnings("checkstyle:staticvariablename") // Fixing this violation might break dependents.
public static MCEntityType NULL = null;
Expand Down Expand Up @@ -45,21 +46,15 @@ public Class<? extends MCEntity> getWrapperClass() {
}

public static MCEntityType valueOf(String test) throws IllegalArgumentException {
if(mappings == null) {
return null;
}
MCEntityType ret = mappings.get(test);
MCEntityType ret = MAP.get(test);
if(ret == null) {
throw new IllegalArgumentException("Unknown entity type: " + test);
}
return ret;
}

public static MCEntityType valueOfVanillaType(MCVanillaEntityType type) {
if(vanilla == null) {
return null;
}
return vanilla.get(type);
return VANILLA_MAP.get(type);
}

/**
Expand All @@ -73,7 +68,7 @@ public static Set<String> types() {
}
return dummy;
}
return mappings.keySet();
return MAP.keySet();
}

/**
Expand Down Expand Up @@ -102,7 +97,7 @@ public boolean isSpawnable() {
}
return dummy;
}
return mappings.values();
return MAP.values();
}

@MEnum("VanillaEntityType")
Expand Down
Expand Up @@ -6,15 +6,15 @@
public enum MCInventoryType {
BREWING,
CHEST,
CRAFTING(false), // bukkit doesn't allow opening
CREATIVE(false), // bukkit doesn't allow opening
CRAFTING(false),
CREATIVE(false),
DISPENSER,
DROPPER,
ENCHANTING(false), // non-functional
ENDER_CHEST,
FURNACE,
HOPPER,
MERCHANT(false), // doesn't open
MERCHANT(false),
PLAYER,
WORKBENCH,
ANVIL,
Expand Down
Expand Up @@ -15,21 +15,20 @@
import com.laytonsmith.core.constructs.Target;
import org.bukkit.entity.EntityType;

import java.util.ArrayList;
import java.util.HashMap;
import java.util.Map;

public class BukkitMCEntityType extends MCEntityType<EntityType> {

protected static final Map<EntityType, MCEntityType> BUKKIT_MAP = new HashMap<>();

public BukkitMCEntityType(EntityType concreteType, MCVanillaEntityType abstractedType) {
super(abstractedType, concreteType);
}

// This way we don't take up extra memory on non-bukkit implementations
public static void build() {
vanilla = new HashMap<>();
mappings = new HashMap<>();
NULL = new BukkitMCEntityType(EntityType.UNKNOWN, MCVanillaEntityType.UNKNOWN);
ArrayList<EntityType> counted = new ArrayList<>();
for(MCVanillaEntityType v : MCVanillaEntityType.values()) {
if(v.existsInCurrent()) {
EntityType type;
Expand All @@ -41,14 +40,15 @@ public static void build() {
}
BukkitMCEntityType wrapper = new BukkitMCEntityType(type, v);
wrapper.setWrapperClass();
vanilla.put(v, wrapper);
mappings.put(v.name(), wrapper);
counted.add(type);
VANILLA_MAP.put(v, wrapper);
MAP.put(v.name(), wrapper);
BUKKIT_MAP.put(type, wrapper);
}
}
for(EntityType b : EntityType.values()) {
if(!counted.contains(b)) {
mappings.put(b.name(), new BukkitMCEntityType(b, MCVanillaEntityType.UNKNOWN));
if(!BUKKIT_MAP.containsKey(b)) {
MAP.put(b.name(), new BukkitMCEntityType(b, MCVanillaEntityType.UNKNOWN));
BUKKIT_MAP.put(b, new BukkitMCEntityType(b, MCVanillaEntityType.UNKNOWN));
}
}
}
Expand All @@ -73,10 +73,9 @@ public boolean isSpawnable() {
}

public static BukkitMCEntityType valueOfConcrete(EntityType test) {
for(MCEntityType t : mappings.values()) {
if(((BukkitMCEntityType) t).getConcrete().equals(test)) {
return (BukkitMCEntityType) t;
}
MCEntityType type = BUKKIT_MAP.get(test);
if(type != null) {
return (BukkitMCEntityType) type;
}
return (BukkitMCEntityType) NULL;
}
Expand Down
Expand Up @@ -2,7 +2,7 @@

import com.laytonsmith.abstraction.MCEntity;

public interface MCVehicleEnitityCollideEvent extends MCVehicleCollideEvent {
public interface MCVehicleEntityCollideEvent extends MCVehicleCollideEvent {

MCEntity getEntity();

Expand Down
4 changes: 2 additions & 2 deletions src/main/java/com/laytonsmith/core/ObjectGenerator.java
Expand Up @@ -873,7 +873,7 @@ public MCItemMeta itemMeta(Construct c, MCMaterial mat, Target t) throws ConfigR
throw new CREFormatException(ex.getMessage(), t, ex);
}
} else {
throw new CREFormatException("An array was expected but recieved " + c + " instead.", t);
throw new CREFormatException("An array was expected but received " + c + " instead.", t);
}
return meta;
}
Expand Down Expand Up @@ -1326,7 +1326,7 @@ public Construct recipe(MCRecipe r, Target t) {

public MCRecipe recipe(Construct c, Target t) {
if(!(c instanceof CArray)) {
throw new CRECastException("Expected array but recieved " + c.getCType().name(), t);
throw new CRECastException("Expected array but received " + c.getCType().name(), t);
}
CArray recipe = (CArray) c;

Expand Down
23 changes: 0 additions & 23 deletions src/main/java/com/laytonsmith/core/Static.java
Expand Up @@ -16,7 +16,6 @@
import com.laytonsmith.abstraction.MCPlayer;
import com.laytonsmith.abstraction.MCPlugin;
import com.laytonsmith.abstraction.MCServer;
import com.laytonsmith.abstraction.entities.MCVehicle;
import com.laytonsmith.abstraction.MCWorld;
import com.laytonsmith.abstraction.StaticLayer;
import com.laytonsmith.annotations.typeof;
Expand Down Expand Up @@ -68,7 +67,6 @@
import java.net.URI;
import java.net.URISyntaxException;
import java.net.URLEncoder;
import java.util.ArrayList;
import java.util.Collection;
import java.util.HashMap;
import java.util.List;
Expand Down Expand Up @@ -860,26 +858,6 @@ public static MCLivingEntity getLivingByUUID(UUID id, Target t) {
return (MCLivingEntity) ent;
}

/**
* Returns all vehicles from all maps.
*
* @return
*/
public static List<MCVehicle> getVehicles() {

List<MCVehicle> vehicles = new ArrayList<MCVehicle>();

for(MCWorld w : Static.getServer().getWorlds()) {
for(MCEntity e : w.getEntities()) {
MCEntity entity = StaticLayer.GetCorrectEntity(e);
if(entity instanceof MCVehicle) {
vehicles.add((MCVehicle) entity);
}
}
}
return vehicles;
}

/**
* Returns the world with the specified name. If it does not exist, a ConfigRuntimeException is thrown.
*
Expand Down Expand Up @@ -1185,7 +1163,6 @@ public static void AssertPlayerNonNull(MCPlayer p, Target t) throws ConfigRuntim
if(p == null) {
throw new CREPlayerOfflineException("No player was specified!", t);
}
assert p != null;
}

public static long msToTicks(long ms) {
Expand Down
Expand Up @@ -437,7 +437,7 @@ public Construct exec(Target t, Environment environment, Construct... args) thro
if(args[1] instanceof CArray) {
l = ObjectGenerator.GetGenerator().location((CArray) args[1], e.getWorld(), t);
} else {
throw new CREFormatException("An array was expected but recieved " + args[1], t);
throw new CREFormatException("An array was expected but received " + args[1], t);
}
return CBoolean.get(e.teleport(l));
}
Expand Down
10 changes: 5 additions & 5 deletions src/main/java/com/laytonsmith/core/functions/Environment.java
Expand Up @@ -1380,7 +1380,7 @@ public Construct exec(Target t,
float pitch = 1;

if(!(args[1] instanceof CArray)) {
throw new CREFormatException("An array was expected but recieved " + args[1], t);
throw new CREFormatException("An array was expected but received " + args[1], t);
}

CArray sa = (CArray) args[1];
Expand Down Expand Up @@ -1499,7 +1499,7 @@ public Construct exec(Target t,
float pitch = 1;

if(!(args[1] instanceof CArray)) {
throw new CREFormatException("An array was expected but recieved " + args[1], t);
throw new CREFormatException("An array was expected but received " + args[1], t);
}

CArray sa = (CArray) args[1];
Expand Down Expand Up @@ -1699,7 +1699,7 @@ public Construct exec(Target t, com.laytonsmith.core.environments.Environment en
throws ConfigRuntimeException {
MCWorld w = null;
MCPlayer pl = environment.getEnv(CommandHelperEnvironment.class).GetPlayer();
if(pl instanceof MCPlayer) {
if(pl != null) {
w = pl.getWorld();
}
MCLocation loc = ObjectGenerator.GetGenerator().location(args[0], w, t);
Expand Down Expand Up @@ -1753,7 +1753,7 @@ public Construct exec(Target t, com.laytonsmith.core.environments.Environment en
throws ConfigRuntimeException {
MCWorld w = null;
MCPlayer pl = environment.getEnv(CommandHelperEnvironment.class).GetPlayer();
if(pl instanceof MCPlayer) {
if(pl != null) {
w = pl.getWorld();
}
MCLocation loc = ObjectGenerator.GetGenerator().location(args[0], w, t);
Expand Down Expand Up @@ -1841,7 +1841,7 @@ public Construct exec(Target t, com.laytonsmith.core.environments.Environment en
throws ConfigRuntimeException {
MCWorld w = null;
MCPlayer pl = environment.getEnv(CommandHelperEnvironment.class).GetPlayer();
if(pl instanceof MCPlayer) {
if(pl != null) {
w = pl.getWorld();
}
MCLocation loc = ObjectGenerator.GetGenerator().location(args[0], w, t);
Expand Down
4 changes: 2 additions & 2 deletions src/main/java/com/laytonsmith/core/functions/ItemMeta.java
Expand Up @@ -359,14 +359,14 @@ public Construct exec(Target t, Environment environment, Construct... args) thro
if(args[2] instanceof CArray) {
color = (CArray) args[2];
} else {
throw new CREFormatException("Expected an array but recieved " + args[2] + " instead.", t);
throw new CREFormatException("Expected an array but received " + args[2] + " instead.", t);
}
} else {
slot = Static.getInt32(args[0], t);
if(args[1] instanceof CArray) {
color = (CArray) args[1];
} else {
throw new CREFormatException("Expected an array but recieved " + args[1] + " instead.", t);
throw new CREFormatException("Expected an array but received " + args[1] + " instead.", t);
}
}
Static.AssertPlayerNonNull(p, t);
Expand Down
5 changes: 3 additions & 2 deletions src/main/java/com/laytonsmith/core/functions/Minecraft.java
Expand Up @@ -259,7 +259,8 @@ public Construct exec(Target t, Environment env, Construct... args) throws Confi
try {
e = MCEffect.valueOf(preEff.toUpperCase());
} catch (IllegalArgumentException ex) {
throw new CREFormatException("The effect type " + args[1].val() + " is not valid", t);
CHLog.GetLogger().e(CHLog.Tags.GENERAL, "The effect type " + args[1].val() + " is not valid", t);
return CVoid.VOID;
}
if(e.equals(MCEffect.STEP_SOUND)) {
MCMaterial mat = StaticLayer.GetConvertor().getMaterial(data);
Expand Down Expand Up @@ -348,7 +349,7 @@ public Construct exec(Target t, Environment env, Construct... args) throws Cance
throw new CRERangeException(this.getName() + " expects the index to be between -1 and 16 (inclusive)", t);
}

ArrayList<Construct> retVals = new ArrayList<Construct>();
ArrayList<Construct> retVals = new ArrayList<>();

if(index == 0 || index == -1) {
//Server name
Expand Down
Expand Up @@ -597,7 +597,7 @@ public Construct exec(Target t, Environment environment, Construct... args) thro
int age = Static.getInt32(args[1], t);
boolean lock = false;
if(args.length == 3) {
lock = (boolean) Static.getBoolean(args[2], t);
lock = Static.getBoolean(args[2], t);
}
MCLivingEntity ent = Static.getLivingEntity(args[0], t);
if(ent == null) {
Expand Down

0 comments on commit ce6290d

Please sign in to comment.