Skip to content
This repository has been archived by the owner on Aug 29, 2018. It is now read-only.

Commit

Permalink
Merge pull request #24 from McMoonLakeDev/v1.8-b4
Browse files Browse the repository at this point in the history
V1.8 b4
  • Loading branch information
MoonLake authored Dec 31, 2016
2 parents cf1d61b + 8ada47c commit 6f18345
Show file tree
Hide file tree
Showing 17 changed files with 477 additions and 84 deletions.
4 changes: 2 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
# MoonLake [![GitHub version](https://d25lcipzij17d.cloudfront.net/badge.svg?id=gh&type=6&v=1.8-a4&x2=0)](https://github.com/u2g/MoonLake) [![Open Source Love](https://badges.frapsoft.com/os/v1/open-source.svg?v=102)](https://github.com/u2g/MoonLake) [![Open Source Love](https://badges.frapsoft.com/os/gpl/gpl.svg?v=102)](https://github.com/u2g/MoonLake)
# MoonLake [![GitHub version](https://d25lcipzij17d.cloudfront.net/badge.svg?id=gh&type=6&v=1.8-b4&x2=0)](https://github.com/u2g/MoonLake) [![Open Source Love](https://badges.frapsoft.com/os/v1/open-source.svg?v=102)](https://github.com/u2g/MoonLake) [![Open Source Love](https://badges.frapsoft.com/os/gpl/gpl.svg?v=102)](https://github.com/u2g/MoonLake)

Minecraft MoonLake Core API Plugin
By Month_Light Ver: 1.8-a4
By Month_Light Ver: 1.8-b4

## 简介
这个插件提供了大量的 API 功能,实现了一些 Bukkit 无法做到的 NMS 功能<br />
Expand Down
4 changes: 2 additions & 2 deletions config.yml
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
################################
# MoonLake Core API Plugin #
# By Month_Light Ver: 1.8-a4 #
# By Month_Light Ver: 1.8-b4 #
################################

# 插件版本号: 此项请勿修改!
version: '1.8-a4'
version: '1.8-b4'

# 数据包通道监听器
# 此项可设置是否开启这个功能
Expand Down
2 changes: 1 addition & 1 deletion plugin.yml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
name: MoonLake
main: com.minecraft.moonlake.MoonLakePlugin
version: 1.8-a4
version: 1.8-b4
prefix: MoonLake
description: Minecraft MoonLake Core API Plugin
website: http://www.mcyszh.com/
Expand Down
20 changes: 20 additions & 0 deletions src/com/minecraft/moonlake/MoonLakeAPI.java
Original file line number Diff line number Diff line change
Expand Up @@ -488,6 +488,26 @@ public CommandAnnotation getCommand() {
};
}

/**
* 获取插件注解配置文件类接口 ConfigAnnotation 实例对象
*
* @return ConfigAnnotation
*/
public static ConfigAnnotation getConfigAnnotation() {

return getPluginAnnotation().getConfig();
}

/**
* 获取插件注解m了类接口 CommandAnnotation 实例对象
*
* @return CommandAnnotation
*/
public static CommandAnnotation getCommandAnnotation() {

return getPluginAnnotation().getCommand();
}

/**
* 获取 NBTLibrary 对象
*
Expand Down
4 changes: 2 additions & 2 deletions src/com/minecraft/moonlake/MoonLakePlugin.java
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@
* <hr />
* <div>
* <h1>Minecraft MoonLake Core API Plugin</h1>
* <p>By Month_Light Ver: 1.8-a4</p>
* <p>By Month_Light Ver: 1.8-b4</p>
* <p>Website: <a href="http://www.mcyszh.com" target="_blank" style="text-decoration: none;">MoonLake Website</a></p>
* <p>QQ Group: 377607025 -> <a href="http://jq.qq.com/?_wv=1027&k=2IfPFrH" target="_blank">Jump</a></p>
* <hr />
Expand Down Expand Up @@ -68,7 +68,7 @@
* <h1>修改操作请您遵守 <a href="https://github.com/u2g/MoonLake/blob/master/LICENSE" target="_blank">GPLv3</a> 协议,您必须公开修改过的所有代码!</h1>
* </div>
*
* @version 1.8-a4
* @version 1.8-b4
* @author Month_Light
*/
public class MoonLakePlugin extends JavaPlugin implements MoonLake {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -153,6 +153,8 @@ public enum ProtocolVersion {
v1_10_1(210),
v1_10_2(210),
v1_11(315),
v1_11_1(316),
v1_11_2(316),
;

private final int protocol;
Expand Down
1 change: 1 addition & 0 deletions src/com/minecraft/moonlake/api/item/AttributeModify.java
Original file line number Diff line number Diff line change
Expand Up @@ -244,6 +244,7 @@ public enum Type {
for(final Type type : values()) {

NAME_MAP.put(type.getType(), type);
NAME_MAP.put(type.getAttributeName(), type); // put attribute name
}
}

Expand Down
22 changes: 22 additions & 0 deletions src/com/minecraft/moonlake/api/item/ItemBuilder.java
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@
import com.minecraft.moonlake.api.item.potion.PotionEffectCustom;
import com.minecraft.moonlake.api.item.potion.PotionEffectType;
import com.minecraft.moonlake.builder.Builder;
import com.minecraft.moonlake.exception.MoonLakeException;
import org.bukkit.Color;
import org.bukkit.enchantments.Enchantment;
import org.bukkit.inventory.ItemFlag;
Expand Down Expand Up @@ -410,4 +411,25 @@ public interface ItemBuilder extends Builder<ItemStack> {
* @throws IllegalArgumentException 如果物品栈类型不为 {@code Material.*Potion} 则抛出异常
*/
ItemBuilder setCustomPotion(com.minecraft.moonlake.enums.PotionEffectType effectType, int amplifier, int duration, boolean ambient, boolean showParticles);

/**
* 设置头颅物品栈的头颅材质皮肤数据
*
* @param data 皮肤数据
* @throws IllegalArgumentException 如果头颅材质信息对象为 {@code null} 则抛出异常
* @throws IllegalArgumentException 如果物品栈类型不为 {@code Material.SKULL_ITEM} 则抛出异常
* @throws MoonLakeException 如果设置头颅材质时错误则抛出异常
*/
ItemBuilder setSkullWithSkin(String data);

/**
* 设置头颅物品栈的头颅材质皮肤数据
*
* @param value 头颅材质值
* @param signature 头颅材质签名
* @throws IllegalArgumentException 如果头颅材质值对象为 {@code null} 则抛出异常
* @throws IllegalArgumentException 如果物品栈类型不为 {@code Material.SKULL_ITEM} 则抛出异常
* @throws MoonLakeException 如果设置头颅材质时错误则抛出异常
*/
ItemBuilder setSkullWithSkin(String value, String signature);
}
16 changes: 16 additions & 0 deletions src/com/minecraft/moonlake/api/item/ItemBuilderWrapped.java
Original file line number Diff line number Diff line change
Expand Up @@ -522,6 +522,22 @@ public ItemBuilder setCustomPotion(com.minecraft.moonlake.enums.PotionEffectType
return setCustomPotion(effectType.createCustom(amplifier, duration, ambient, showParticles));
}

@Override
public ItemBuilder setSkullWithSkin(String data) {

update(library().setSkullWithSkin(get(), data));

return this;
}

@Override
public ItemBuilder setSkullWithSkin(String value, String signature) {

update(library().setSkullWithSkin(get(), value, signature));

return this;
}

@Override
public ItemStack build() {

Expand Down
12 changes: 12 additions & 0 deletions src/com/minecraft/moonlake/api/item/ItemExpressionWrapped.java
Original file line number Diff line number Diff line change
Expand Up @@ -125,6 +125,18 @@ public String getSkullSkinURL(ItemStack itemStack) {
return base.getSkullSkinURL(itemStack);
}

@Override
public ItemStack setSkullWithSkin(ItemStack itemStack, String data) throws MoonLakeException {

return base.setSkullWithSkin(itemStack, data);
}

@Override
public ItemStack setSkullWithSkin(ItemStack itemStack, String value, String signature) throws MoonLakeException {

return base.setSkullWithSkin(itemStack, value, signature);
}

@Override
public ItemStack setUnbreakable(ItemStack itemStack, boolean unbreakable) {

Expand Down
10 changes: 3 additions & 7 deletions src/com/minecraft/moonlake/api/item/MetaExpression.java
Original file line number Diff line number Diff line change
Expand Up @@ -102,19 +102,15 @@ public ItemStack addDurability(ItemStack itemStack, int durability) {

Validate.notNull(itemStack, "The itemstack object is null.");

int nowDurability = itemStack.getDurability();

return setDurability(itemStack, nowDurability - durability); // set durability subtract be add durability
return setDurability(itemStack, itemStack.getDurability() - durability); // set durability subtract be add durability
}

@Override
public ItemStack takeDurability(ItemStack itemStack, int durability) {

Validate.notNull(itemStack, "The itemstack object is null.");

int nowDurability = itemStack.getDurability();

return setDurability(itemStack, nowDurability + durability); // set durability add be add durability
return setDurability(itemStack, itemStack.getDurability() + durability); // set durability add be add durability
}

@Override
Expand Down Expand Up @@ -448,7 +444,7 @@ public Set<ItemFlag> getFlags(ItemStack itemStack) {

if(itemMeta == null) {

return null;
return new HashSet<>();
}
return itemMeta.getItemFlags();
}
Expand Down
100 changes: 56 additions & 44 deletions src/com/minecraft/moonlake/api/item/SkullExpression.java
Original file line number Diff line number Diff line change
Expand Up @@ -110,55 +110,13 @@ public ItemStack createSkullWithOwner(String skullOwner, String displayName) {
@Override
public ItemStack createSkullWithSkin(String data) throws MoonLakeException {

Validate.notNull(data, "The itemstack skull skin data object is null.");

if(data.isEmpty()) {

return createSkull();
}
ItemStack itemStack = createSkull();
SkullMeta skullMeta = (SkullMeta) itemStack.getItemMeta();

try {

Reflect.getField("CraftMetaSkull", Reflect.PackageType.CRAFTBUKKIT_INVENTORY, true, "profile").set(skullMeta, createGameProfile(data));
}
catch (Exception e) {

throw new MoonLakeException("The create skull with skin meta exception.", e);
}
itemStack.setItemMeta(skullMeta);

return itemStack;
return setSkullWithSkin(createSkull(), data);
}

@Override
public ItemStack createSkullWithSkins(String value, String signature) throws MoonLakeException {

Validate.notNull(value, "The itemstack skull skin value object is null.");

if(signature == null) {

return createSkullWithSkin(value);
}
if(value.isEmpty()) {

return createSkull();
}
ItemStack itemStack = createSkull();
SkullMeta skullMeta = (SkullMeta) itemStack.getItemMeta();

try {

Reflect.getField("CraftMetaSkull", Reflect.PackageType.CRAFTBUKKIT_INVENTORY, true, "profile").set(skullMeta, createGameProfile(value, signature));
}
catch (Exception e) {

throw new MoonLakeException("The create skull with skin meta exception.", e);
}
itemStack.setItemMeta(skullMeta);

return itemStack;
return setSkullWithSkin(createSkull(), value, signature);
}

@Override
Expand Down Expand Up @@ -220,4 +178,58 @@ public String getSkullSkinURL(ItemStack itemStack) {

throw new NotImplementedException();
}

@Override
public ItemStack setSkullWithSkin(ItemStack itemStack, String data) throws MoonLakeException {

Validate.notNull(data, "The itemstack skull skin data object is null.");
Validate.isTrue(itemStack.getType() == Material.SKULL_ITEM, "The itemstack type not is skull.");

if(data.isEmpty()) {

return createSkull();
}
SkullMeta skullMeta = (SkullMeta) itemStack.getItemMeta();

try {

Reflect.getField("CraftMetaSkull", Reflect.PackageType.CRAFTBUKKIT_INVENTORY, true, "profile").set(skullMeta, createGameProfile(data));
}
catch (Exception e) {

throw new MoonLakeException("The create skull with skin meta exception.", e);
}
itemStack.setItemMeta(skullMeta);

return itemStack;
}

@Override
public ItemStack setSkullWithSkin(ItemStack itemStack, String value, String signature) throws MoonLakeException {

Validate.notNull(value, "The itemstack skull skin value object is null.");
Validate.isTrue(itemStack.getType() == Material.SKULL_ITEM, "The itemstack type not is skull.");

if(signature == null) {

return setSkullWithSkin(itemStack, value);
}
if(value.isEmpty()) {

return createSkull();
}
SkullMeta skullMeta = (SkullMeta) itemStack.getItemMeta();

try {

Reflect.getField("CraftMetaSkull", Reflect.PackageType.CRAFTBUKKIT_INVENTORY, true, "profile").set(skullMeta, createGameProfile(value, signature));
}
catch (Exception e) {

throw new MoonLakeException("The create skull with skin meta exception.", e);
}
itemStack.setItemMeta(skullMeta);

return itemStack;
}
}
Loading

0 comments on commit 6f18345

Please sign in to comment.