Skip to content

Commit

Permalink
Merge pull request #5 from Kittengarten-Official/开发
Browse files Browse the repository at this point in the history
2.1更新
  • Loading branch information
Kittengarten authored Sep 20, 2021
2 parents df03a30 + 0cb8c10 commit aa0cc1b
Show file tree
Hide file tree
Showing 19 changed files with 48 additions and 27 deletions.
8 changes: 2 additions & 6 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -11,10 +11,6 @@ Kitten_Anno是一个基于[世界树纪元](https://github.com/Kittengarten-Offi
# 提示
* 睡觉、使用命令调整时间,**无法**影响世界树纪元
* 世界树纪元与Minecraft的昼夜变化无关
* 自动播报的时间点,往往不是世界树纪元每天的起始点
> 往往会出现已经到了第二天但还未自动播报的情况
>
> 如需得知当前的正确日期,使用命令进行查询
* 世界树纪元只与服务端当前加载的第一个世界已运行的总时间有关
* 在线玩家需要背包有剩余空间,否则无法获取
* 在线玩家即使没有重生,也可获取
Expand All @@ -29,7 +25,7 @@ Kitten_Anno是一个基于[世界树纪元](https://github.com/Kittengarten-Offi
|龙首 | 1 | 夜月 | 1% |
|哭泣的黑曜石 | 1 | 彗月 | 5% |
|蓝冰 | 64 | 凉月 | 1% |
|绿宝石矿石 | 64 | 芷月 | 1% |
|绿宝石矿石 | 64 | 芷月 | 1% |
|海龟壳 | 1 | 茸月 | 5% |
|鹦鹉螺壳 | 4 | 雨月 | 2% |
|凋零玫瑰 | 1 | 花月 | 2% |
Expand All @@ -44,7 +40,7 @@ Kitten_Anno是一个基于[世界树纪元](https://github.com/Kittengarten-Offi
|黏土块 | 16 | 荷月 | 5% |
|TNT | 4 | 茶月 | 1% |
|海绵 | 4 | 茉月 | 2% |
| | 1 | 铃月 | 1% |
|幸运药水 | 3 | 铃月 | 1% |
|命名牌 | 4 | 信月 | 2% |
|龙息 | 4 | 瑶月 | 10% |
|鞘翅 | 1 | 风月 | 2% |
Expand Down
2 changes: 1 addition & 1 deletion kitten_anno/.settings/org.eclipse.jdt.core.prefs
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
eclipse.preferences.version=1
org.eclipse.jdt.core.compiler.codegen.targetPlatform=16
org.eclipse.jdt.core.compiler.compliance=16
org.eclipse.jdt.core.compiler.problem.enablePreviewFeatures=disabled
org.eclipse.jdt.core.compiler.problem.enablePreviewFeatures=enabled
org.eclipse.jdt.core.compiler.problem.forbiddenReference=warning
org.eclipse.jdt.core.compiler.problem.reportPreviewFeatures=ignore
org.eclipse.jdt.core.compiler.processAnnotations=disabled
Expand Down
4 changes: 4 additions & 0 deletions kitten_anno/.settings/org.eclipse.m2e.core.prefs
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
activeProfiles=
eclipse.preferences.version=1
resolveWorkspaceProjects=true
version=1
2 changes: 1 addition & 1 deletion kitten_anno/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@

<groupId>tk.iluyf.mc</groupId>
<artifactId>kitten_anno</artifactId>
<version>2.0</version>
<version>2.1</version>

<name>kitten_anno</name>
<!-- FIXME change it to the project's website -->
Expand Down
6 changes: 3 additions & 3 deletions kitten_anno/src/main/java/config.yml
Original file line number Diff line number Diff line change
Expand Up @@ -119,9 +119,9 @@ reward:
quantity: 4
weight: 66
month21:
name:
id: BELL
quantity: 1
name: 幸运药水
id: POTION
quantity: 3
weight: 68
month22:
name: 命名牌
Expand Down
2 changes: 1 addition & 1 deletion kitten_anno/src/main/java/plugin.yml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
name: Kitten_Anno
main: tk.iluyf.mc.KittenAnno
version: 2.0
version: 2.1
api-version: 1.17
author: Kittengarten
commands:
Expand Down
27 changes: 20 additions & 7 deletions kitten_anno/src/main/java/tk/iluyf/mc/KittenAnno.java
Original file line number Diff line number Diff line change
Expand Up @@ -15,14 +15,19 @@

public class KittenAnno extends JavaPlugin implements Listener {
public static FileConfiguration config;
public static short tick;
public static long annoTick, annoDay;
public static boolean did = false;
public static boolean newDay = false;

public KittenAnno() {
config = getConfig();
}

public String getAnnoBroadcast() {
long annoTick = Bukkit.getWorlds().get(0).getGameTime();
long annoDay = 1 + annoTick / 24000;
annoTick = Bukkit.getWorlds().get(0).getGameTime();
annoDay = 1 + annoTick / 24000;
KittenAnno.tick = (short) (annoTick % 24000);
AnnoCompute annoCompute_ = new AnnoCompute();
return annoCompute_.output(annoDay);
}
Expand All @@ -40,12 +45,20 @@ public void onEnable() {
new BukkitRunnable() {
@Override
public void run() {
Bukkit.broadcastMessage(getAnnoBroadcast());
long annoTick = Bukkit.getWorlds().get(0).getGameTime();
long annoDay = 1 + annoTick / 24000;
new Reward().giveReward(annoDay);
if (tick < 100) {
newDay = true;
}
if (newDay == true & did == false) {
Bukkit.broadcastMessage(getAnnoBroadcast());
new Reward().giveReward(annoDay);
newDay = false;
did = true;
if (tick > 500) {
Bukkit.broadcastMessage("严重错误:自动播报尝试5次失败。可能是由于服务器过于卡顿,或插件本身Bug。");
}
}
}
}.runTaskTimer(this, 100L, 24000L);
}.runTaskTimer(this, 100L, 100L);
}

@Override
Expand Down
14 changes: 11 additions & 3 deletions kitten_anno/src/main/java/tk/iluyf/mc/Reward.java
Original file line number Diff line number Diff line change
Expand Up @@ -7,10 +7,13 @@
import org.bukkit.enchantments.Enchantment;
import org.bukkit.enchantments.EnchantmentWrapper;
import org.bukkit.inventory.meta.EnchantmentStorageMeta;
import org.bukkit.inventory.meta.PotionMeta;
import org.bukkit.entity.Player;
import org.bukkit.inventory.ItemStack;
import org.bukkit.inventory.PlayerInventory;
import org.bukkit.Bukkit;
import org.bukkit.potion.PotionType;
import org.bukkit.potion.PotionData;

import static org.bukkit.ChatColor.*;

Expand Down Expand Up @@ -62,23 +65,28 @@ private ItemStack rewardOutput(String monthReward[], long seed, Long annoDay) {
return itemReward;
} else {
ItemStack itemReward = new ItemStack(Material.getMaterial(monthReward[1]), Integer.valueOf(monthReward[2]));
return mending(monthReward[1], itemReward);
return mendingOrLuck(monthReward[1], itemReward);
}
}

private ItemStack mending(String id, ItemStack itemReward) {
private ItemStack mendingOrLuck(String id, ItemStack itemReward) {
if (id.equals("ENCHANTED_BOOK")) {
Enchantment enchantment_ = new EnchantmentWrapper("mending");
EnchantmentStorageMeta enchantmentStorageMeta_ = (EnchantmentStorageMeta) itemReward.getItemMeta();
enchantmentStorageMeta_.addStoredEnchant(enchantment_, enchantment_.getMaxLevel(), false);
itemReward.setItemMeta(enchantmentStorageMeta_);
} else if (id.equals("POTION")) {
PotionData potionData_ = new PotionData(PotionType.LUCK);
PotionMeta potionMeta_ = (PotionMeta) itemReward.getItemMeta();
potionMeta_.setBasePotionData(potionData_);
itemReward.setItemMeta(potionMeta_);
}
return itemReward;
}

private ItemStack music_disc(short quantity, long seed) {
int randomNumber = new Random(seed).nextInt(13);
String id = KittenAnno.config.getString("reward.month11.ids.id" + String.valueOf(randomNumber));
String id = KittenAnno.config.getString("reward.month11.ids.id" + String.valueOf(randomNumber + 1));
ItemStack itemReward = new ItemStack(Material.getMaterial(id), Integer.valueOf(quantity));
return itemReward;
}
Expand Down
6 changes: 3 additions & 3 deletions kitten_anno/target/classes/config.yml
Original file line number Diff line number Diff line change
Expand Up @@ -119,9 +119,9 @@ reward:
quantity: 4
weight: 66
month21:
name:
id: BELL
quantity: 1
name: 幸运药水
id: POTION
quantity: 3
weight: 68
month22:
name: 命名牌
Expand Down
2 changes: 1 addition & 1 deletion kitten_anno/target/classes/plugin.yml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
name: Kitten_Anno
main: tk.iluyf.mc.KittenAnno
version: 2.0
version: 2.1
api-version: 1.17
author: Kittengarten
commands:
Expand Down
Binary file modified kitten_anno/target/classes/tk/iluyf/mc/AnnoCompute.class
Binary file not shown.
Binary file modified kitten_anno/target/classes/tk/iluyf/mc/KittenAnno$1.class
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file modified kitten_anno/target/classes/tk/iluyf/mc/KittenAnno.class
Binary file not shown.
Binary file modified kitten_anno/target/classes/tk/iluyf/mc/Reward.class
Binary file not shown.
Binary file removed kitten_anno/target/kitten_anno-2.0.jar
Binary file not shown.
Binary file added kitten_anno/target/kitten_anno-2.1.jar
Binary file not shown.
2 changes: 1 addition & 1 deletion kitten_anno/target/maven-archiver/pom.properties
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
#Created by Apache Maven 3.8.1
groupId=tk.iluyf.mc
artifactId=kitten_anno
version=2.0
version=2.1

0 comments on commit aa0cc1b

Please sign in to comment.