Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

Added the weather converter, (get|set)_mob_name, send_texturepack, an…

…d updated to 1.5.1
  • Loading branch information...
commit a78c3651fd0219757178c09dd3beba697120a315 1 parent 23ae407
@jb-aero jb-aero authored
View
14 pom.xml
@@ -81,6 +81,18 @@
<role>contributor</role>
</roles>
</contributor>
+ <contributor>
+ <name>ACzChef</name>
+ <roles>
+ <role>contributor</role>
+ </roles>
+ </contributor>
+ <contributor>
+ <name>MariuszT</name>
+ <roles>
+ <role>contributor</role>
+ </roles>
+ </contributor>
</contributors>
<issueManagement>
<system>sk89q's Redmine</system>
@@ -159,7 +171,7 @@
<dependency>
<groupId>org.bukkit</groupId>
<artifactId>bukkit</artifactId>
- <version>1.5-R0.1-SNAPSHOT</version>
+ <version>1.5.1-R0.1-SNAPSHOT</version>
</dependency>
<!-- CraftBukkit Dependency for experimental features
View
14 src/main/java/com/laytonsmith/abstraction/MCPlayer.java
@@ -3,7 +3,7 @@
import com.laytonsmith.abstraction.enums.MCInstrument;
import com.laytonsmith.abstraction.enums.MCSound;
-import com.laytonsmith.abstraction.enums.MCWeatherType;
+import com.laytonsmith.abstraction.enums.MCWeather;
import java.net.InetSocketAddress;
@@ -29,6 +29,8 @@
public float getExp();
+ public float getFlySpeed();
+
public int getFoodLevel();
public MCPlayerInventory getInventory();
@@ -41,12 +43,14 @@
public long getPlayerTime();
- public MCWeatherType getPlayerWeather();
+ public MCWeather getPlayerWeather();
public int getRemainingFireTicks();
public int getTotalExperience();
+ public float getWalkSpeed();
+
public void giveExp(int xp);
public boolean isSneaking();
@@ -59,6 +63,8 @@
public void resetPlayerWeather();
+ public void sendTexturePack(String url);
+
public void setAllowFlight(boolean flight);
public void setCompassTarget(MCLocation l);
@@ -67,6 +73,8 @@
public void setExp(float i);
+ public void setFlying(boolean flight);
+
public void setFoodLevel(int f);
public void setLevel(int xp);
@@ -75,7 +83,7 @@
public void setPlayerTime(Long time);
- public void setPlayerWeather(MCWeatherType type);
+ public void setPlayerWeather(MCWeather type);
public void setRemainingFireTicks(int i);
View
48 src/main/java/com/laytonsmith/abstraction/bukkit/BukkitMCEntityEquipment.java
@@ -76,6 +76,54 @@ public void setAllEquipment(Map<MCEquipmentSlot, MCItemStack> slots) {
}
}
}
+
+ public Map<MCEquipmentSlot, Float> getAllDropChances() {
+ Map<MCEquipmentSlot, Float> slots = new EnumMap<MCEquipmentSlot, Float>(MCEquipmentSlot.class);
+ for (MCEquipmentSlot key : MCEquipmentSlot.values()) {
+ switch (key) {
+ case WEAPON:
+ slots.put(key, getWeaponDropChance());
+ break;
+ case HELMET:
+ slots.put(key, getHelmetDropChance());
+ break;
+ case CHESTPLATE:
+ slots.put(key, getChestplateDropChance());
+ break;
+ case LEGGINGS:
+ slots.put(key, getLeggingsDropChance());
+ break;
+ case BOOTS:
+ slots.put(key, getBootsDropChance());
+ break;
+ }
+ }
+ return slots;
+ }
+
+ public void setAllDropChances(Map<MCEquipmentSlot, Float> slots) {
+ float chance;
+ for (MCEquipmentSlot key : slots.keySet()) {
+ chance = slots.get(key);
+ switch (key) {
+ case WEAPON:
+ setWeaponDropChance(chance);
+ break;
+ case HELMET:
+ setHelmetDropChance(chance);
+ break;
+ case CHESTPLATE:
+ setChestplateDropChance(chance);
+ break;
+ case LEGGINGS:
+ setLeggingsDropChance(chance);
+ break;
+ case BOOTS:
+ setBootsDropChance(chance);
+ break;
+ }
+ }
+ }
// For the purposes of faking a normal inventory, we most likely will not be accessing
// anything below this line, but they are here for flexibility and completion
View
28 src/main/java/com/laytonsmith/abstraction/bukkit/BukkitMCPlayer.java
@@ -7,9 +7,10 @@
import com.laytonsmith.abstraction.*;
import com.laytonsmith.abstraction.enums.MCInstrument;
import com.laytonsmith.abstraction.enums.MCSound;
-import com.laytonsmith.abstraction.enums.MCWeatherType;
+import com.laytonsmith.abstraction.enums.MCWeather;
import com.laytonsmith.abstraction.enums.bukkit.BukkitMCInstrument;
import com.laytonsmith.abstraction.enums.bukkit.BukkitMCSound;
+import com.laytonsmith.abstraction.enums.bukkit.BukkitMCWeather;
import com.laytonsmith.commandhelper.CommandHelperPlugin;
import com.laytonsmith.core.Static;
import com.laytonsmith.core.exceptions.ConfigRuntimeException;
@@ -21,7 +22,6 @@
import org.bukkit.Location;
import org.bukkit.Note;
import org.bukkit.Server;
-import org.bukkit.WeatherType;
import org.bukkit.entity.Player;
import org.bukkit.inventory.ItemStack;
import org.bukkit.potion.PotionEffect;
@@ -128,8 +128,8 @@ public long getPlayerTime() {
return p.getPlayerTime();
}
- public MCWeatherType getPlayerWeather() {
- return MCWeatherType.valueOf(p.getPlayerWeather().name());
+ public MCWeather getPlayerWeather() {
+ return BukkitMCWeather.getConvertor().getAbstractedEnum(p.getPlayerWeather());
}
public int getRemainingFireTicks() {
@@ -175,6 +175,14 @@ private static int getExpAtLevel(final int level)
return 17;
}
+ public float getFlySpeed() {
+ return p.getFlySpeed();
+ }
+
+ public float getWalkSpeed() {
+ return p.getWalkSpeed();
+ }
+
public void giveExp(int xp) {
p.giveExp(xp);
}
@@ -238,6 +246,10 @@ public void sendMessage(String string) {
p.sendMessage(string);
}
+ public void sendTexturePack(String url) {
+ p.setTexturePack(url);
+ }
+
public void setAllowFlight(boolean flight) {
p.setAllowFlight(flight);
}
@@ -258,6 +270,10 @@ public void setExp(float i) {
p.setExp(i);
}
+ public void setFlying(boolean flight) {
+ p.setFlying(flight);
+ }
+
public void setFoodLevel(int f) {
p.setFoodLevel(f);
}
@@ -277,8 +293,8 @@ public void setPlayerTime(Long time) {
p.setPlayerTime(time, false);
}
- public void setPlayerWeather(MCWeatherType type) {
- p.setPlayerWeather(WeatherType.valueOf(type.name()));
+ public void setPlayerWeather(MCWeather type) {
+ p.setPlayerWeather(BukkitMCWeather.getConvertor().getConcreteEnum(type));
}
public void setRemainingFireTicks(int i) {
View
1  src/main/java/com/laytonsmith/abstraction/enums/MCInventoryType.java
@@ -11,6 +11,7 @@
CRAFTING,
CREATIVE,
DISPENSER,
+ DROPPER,
ENCHANTING,
ENDER_CHEST,
FURNACE,
View
2  .../laytonsmith/abstraction/enums/MCWeatherType.java → .../com/laytonsmith/abstraction/enums/MCWeather.java
@@ -1,6 +1,6 @@
package com.laytonsmith.abstraction.enums;
-public enum MCWeatherType {
+public enum MCWeather {
CLEAR,
DOWNFALL
}
View
29 src/main/java/com/laytonsmith/abstraction/enums/bukkit/BukkitMCWeather.java
@@ -0,0 +1,29 @@
+package com.laytonsmith.abstraction.enums.bukkit;
+
+import org.bukkit.WeatherType;
+
+import com.laytonsmith.abstraction.Implementation;
+import com.laytonsmith.abstraction.enums.EnumConvertor;
+import com.laytonsmith.abstraction.enums.MCWeather;
+import com.laytonsmith.annotations.abstractionenum;
+
+/**
+ *
+ * @author jb_aero
+ */
+@abstractionenum(
+ implementation=Implementation.Type.BUKKIT,
+ forAbstractEnum=MCWeather.class,
+ forConcreteEnum=WeatherType.class
+ )
+public class BukkitMCWeather extends EnumConvertor<MCWeather, WeatherType> {
+
+ private static BukkitMCWeather instance;
+
+ public static BukkitMCWeather getConvertor() {
+ if (instance == null) {
+ instance = new BukkitMCWeather();
+ }
+ return instance;
+ }
+}
View
1  src/main/java/com/laytonsmith/core/events/drivers/InventoryEvents.java
@@ -4,7 +4,6 @@
import com.laytonsmith.PureUtilities.StringUtils;
import com.laytonsmith.abstraction.MCInventory;
-import com.laytonsmith.abstraction.MCPlayer;
import com.laytonsmith.abstraction.StaticLayer;
import com.laytonsmith.abstraction.enums.MCSlotType;
import com.laytonsmith.abstraction.events.MCInventoryClickEvent;
View
53 src/main/java/com/laytonsmith/core/functions/EntityManagement.java
@@ -348,10 +348,6 @@ public String docs() {
@api
public static class get_entity_age extends EntityGetterFunction {
- public ExceptionType[] thrown() {
- return new ExceptionType[]{ExceptionType.CastException, ExceptionType.BadEntityException};
- }
-
public Construct exec(Target t, Environment environment,
Construct... args) throws ConfigRuntimeException {
int id = Static.getInt32(args[0], t);
@@ -367,18 +363,15 @@ public String getName() {
return "get_entity_age";
}
- public Integer[] numArgs() {
- return new Integer[]{1};
- }
-
public String docs() {
return "int {entityID} Returns the entity age as an integer, represented by server ticks.";
}
}
@api
- public static class set_entity_age extends EntityFunction {
+ public static class set_entity_age extends EntitySetterFunction {
+ @Override
public ExceptionType[] thrown() {
return new ExceptionType[]{ExceptionType.CastException, ExceptionType.BadEntityException,
ExceptionType.RangeException};
@@ -406,10 +399,6 @@ public String getName() {
return "set_entity_age";
}
- public Integer[] numArgs() {
- return new Integer[]{2, 3};
- }
-
public String docs() {
return "void {entityID, int} Sets the age of the entity to the specified int, represented by server ticks.";
}
@@ -986,4 +975,42 @@ public String docs() {
}
}
+
+ @api
+ public static class get_mob_name extends EntityGetterFunction {
+
+ public Construct exec(Target t, Environment environment,
+ Construct... args) throws ConfigRuntimeException {
+ MCLivingEntity le = Static.getLivingEntity(Static.getInt32(args[0], t), t);
+ return new CString(le.getCustomName(), t);
+ }
+
+ public String getName() {
+ return "get_mob_name";
+ }
+
+ public String docs() {
+ return "string {entityID} Returns the name of the given mob.";
+ }
+ }
+
+ @api
+ public static class set_mob_name extends EntitySetterFunction {
+
+ public Construct exec(Target t, Environment environment,
+ Construct... args) throws ConfigRuntimeException {
+ MCLivingEntity le = Static.getLivingEntity(Static.getInt32(args[0], t), t);
+ le.setCustomName(args[1].val());
+ return new CVoid(t);
+ }
+
+ public String getName() {
+ return "set_mob_name";
+ }
+
+ public String docs() {
+ return "void {entityID, name} Sets the name of the given mob. This"
+ + " automatically truncates if it is more than 64 characters.";
+ }
+ }
}
View
43 src/main/java/com/laytonsmith/core/functions/Minecraft.java
@@ -1148,4 +1148,47 @@ public CHVersion since() {
}
}
+
+ @api
+ public static class send_texturepack extends AbstractFunction {
+
+ public ExceptionType[] thrown() {
+ return new ExceptionType[]{ExceptionType.PlayerOfflineException};
+ }
+
+ public boolean isRestricted() {
+ return true;
+ }
+
+ public Boolean runAsync() {
+ return false;
+ }
+
+ public Construct exec(Target t, Environment environment,
+ Construct... args) throws ConfigRuntimeException {
+ MCPlayer p = Static.GetPlayer(args[0], t);
+ p.sendTexturePack(args[1].val());
+ return new CVoid(t);
+ }
+
+ public String getName() {
+ return "send_texturepack";
+ }
+
+ public Integer[] numArgs() {
+ return new Integer[]{2};
+ }
+
+ public String docs() {
+ return "void {player, url} Sends a texturepack URL to the player's client."
+ + " If the client has not been requested to change textures in the"
+ + " past, they will recieve a confirmation dialog before downloading"
+ + " and switching to the new pack. Clients that ignore server textures"
+ + " will not recieve the request, so this function will not affect them.";
+ }
+
+ public CHVersion since() {
+ return CHVersion.V3_3_1;
+ }
+ }
}
Please sign in to comment.
Something went wrong with that request. Please try again.