Skip to content

Commit

Permalink
🐙 Update for alpha release
Browse files Browse the repository at this point in the history
- 游戏内编辑 GUI
- 单行独立更新周期、显示条件
- HolographicDisplays 导入
- 改善代码, 测试基本稳定
- 对 1.8-1.14 做了兼容 (仍未测试)
  • Loading branch information
Arasple committed Feb 15, 2020
1 parent 8d4f7aa commit bedd9f1
Show file tree
Hide file tree
Showing 27 changed files with 971 additions and 339 deletions.
18 changes: 15 additions & 3 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -9,11 +9,23 @@
- 支持使用 PlaceholderAPI 变量
- 支持自定义全息图的 动态可视范围
- 支持自定义全息图的 动态可视条件
- 支持只更新有变量的全息行内容
- 支持每行全息内容独立的 可视条件、更新周期
- 支持配置全息图交互动作, 支持 TrMenu 19+ 动作以及参数
- JavaScript、音效、Title、跨服、Json消息 等等
- 每个动作还支持设置独立的 延时/概率/条件 等参数
- 更强的物品展示,支持纹理头颅, 染色, 旗帜, NBT 物品 等
- 支持实时编辑, 即时无闪烁重载
- 可在游戏内使用书本编辑全息图
- 提供完善的 API, 事件
- 支持游戏内通过 GUI 管理全息图, 书本编辑全息图等
- 提供完善的 API, 事件
---
##### Usage
- Permission: `trhologram.admin`
- SoftDepend: PlaceholderAPI
- Hologram lines:
- (Update, ticks) `Example line <update:20>`
- (Requirement) `Example line <require:player.isOp()>`
---
##### TO-DO List

- 支持物品悬浮,而非局限于套盔甲架头上
- 更完善的全 GUI 管理编辑
2 changes: 1 addition & 1 deletion build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ plugins {

configurations {
group = 'me.arasple.mc.trhologram'
version = '0.1'
version = '1.0-alpha'

sourceCompatibility = 1.8
targetCompatibility = 1.8
Expand Down
4 changes: 2 additions & 2 deletions src/main/java/me/arasple/mc/trhologram/TrHologram.java
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ public final class TrHologram extends Plugin {

@TInject("settings.yml")
public final static TConfig SETTINGS = null;
@TInject(5Tr§dHologram")
@TInject(2Tr§aHologram")
public final static TLogger LOGGER = null;
@TInject(state = TInject.State.LOADING, init = "init", active = "load", cancel = "unload")
private final static TrHologramLoader LOADER = null;
Expand All @@ -29,7 +29,7 @@ public void onStopping() {
}

public static double getTrVersion() {
return 0.1;
return 1.0;
}

}
11 changes: 6 additions & 5 deletions src/main/java/me/arasple/mc/trhologram/TrHologramCommands.kt
Original file line number Diff line number Diff line change
Expand Up @@ -5,28 +5,29 @@ import io.izzel.taboolib.module.command.base.BaseMainCommand
import io.izzel.taboolib.module.command.base.BaseSubCommand
import io.izzel.taboolib.module.command.base.SubCommand
import io.izzel.taboolib.module.locale.TLocale
import me.arasple.mc.trhologram.commands.CommandCreate
import me.arasple.mc.trhologram.commands.CommandDelete
import me.arasple.mc.trhologram.commands.CommandList
import me.arasple.mc.trhologram.commands.CommandReload
import me.arasple.mc.trhologram.commands.*
import org.bukkit.command.Command
import org.bukkit.command.CommandSender

/**
* @author Arasple
* @date 2020/2/14 9:31
*/
@BaseCommand(name = "trhologram", aliases = ["hd", "holo", "tholo"], permission = "trhologram.admin")
@BaseCommand(name = "trhologram", aliases = ["tholo", "trhd", "hd", "holo", "hologram"], permission = "trhologram.admin")
class TrHologramCommands : BaseMainCommand() {

@SubCommand(description = "Create hologram")
var create: BaseSubCommand = CommandCreate()
@SubCommand(description = "Delete hologram")
var delete: BaseSubCommand = CommandDelete()
@SubCommand(description = "Delete hologram")
var edit: BaseSubCommand = CommandEdit()
@SubCommand(description = "Reload holograms")
var reload: BaseSubCommand = CommandReload()
@SubCommand(description = "List holograms")
var list: BaseSubCommand = CommandList()
@SubCommand(description = "Debug hologram")
var debug: BaseSubCommand = CommandDebug()

override fun getCommandTitle(): String {
return "§2--------------------------------------------------"
Expand Down
47 changes: 47 additions & 0 deletions src/main/java/me/arasple/mc/trhologram/action/ActionGroups.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,47 @@
package me.arasple.mc.trhologram.action;

import me.arasple.mc.trhologram.action.base.AbstractAction;

import java.util.List;

/**
* @author Arasple
* @date 2020/2/15 12:07
*/
public class ActionGroups {

private int priority;
private String requirement;
private List<AbstractAction> actions;

public ActionGroups(int priority, String requirement, List<AbstractAction> actions) {
this.priority = priority;
this.requirement = requirement;
this.actions = actions;
}

public int getPriority() {
return priority;
}

public void setPriority(int priority) {
this.priority = priority;
}

public String getRequirement() {
return requirement;
}

public void setRequirement(String requirement) {
this.requirement = requirement;
}

public List<AbstractAction> getActions() {
return actions;
}

public void setActions(List<AbstractAction> actions) {
this.actions = actions;
}

}
24 changes: 20 additions & 4 deletions src/main/java/me/arasple/mc/trhologram/action/TrAction.java
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
package me.arasple.mc.trhologram.action;

import com.google.common.collect.Lists;
import io.izzel.taboolib.internal.apache.lang3.math.NumberUtils;
import io.izzel.taboolib.util.lite.Numbers;
import me.arasple.mc.trhologram.TrHologram;
Expand All @@ -10,10 +11,7 @@
import org.bukkit.Bukkit;
import org.bukkit.entity.Player;

import java.util.ArrayList;
import java.util.Arrays;
import java.util.HashMap;
import java.util.List;
import java.util.*;
import java.util.regex.Matcher;

/**
Expand Down Expand Up @@ -132,4 +130,22 @@ private static AbstractAction readSingleAction(String line) {
return action;
}

@SuppressWarnings({"unchecked", "rawtypes"})
public static List<ActionGroups> readActionGroups(Object actions) {
List<ActionGroups> actionGroups = Lists.newArrayList();
if (actions instanceof List && !((List) actions).isEmpty()) {
boolean isConditionalGroups = ((List) actions).get(0) instanceof LinkedHashMap;
if (isConditionalGroups) {
((List) actions).forEach(obj -> {
LinkedHashMap section = (LinkedHashMap) obj;
actionGroups.add(new ActionGroups(NumberUtils.toInt(String.valueOf(section.getOrDefault("priority", -1))), section.containsKey("condition") ? String.valueOf(section.get("condition")) : null, TrAction.readActions((List<String>) section.getOrDefault("list", Lists.newArrayList()))));
});
} else {
actionGroups.add(new ActionGroups(-1, null, TrAction.readActions((List<String>) actions)));
}
return actionGroups;
}
return null;
}

}
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,6 @@
import me.arasple.mc.trhologram.TrHologram;
import me.arasple.mc.trhologram.utils.JavaScript;
import me.arasple.mc.trhologram.utils.Vars;
import me.clip.placeholderapi.PlaceholderAPI;
import org.bukkit.Bukkit;
import org.bukkit.entity.Player;

Expand Down Expand Up @@ -33,7 +32,7 @@ public void run(Player player) {
return;
}
if (options.containsKey(EnumOption.PLAYERS)) {
Bukkit.getOnlinePlayers().stream().filter(p -> (boolean) JavaScript.run(p, options.get(EnumOption.PLAYERS))).collect(Collectors.toList()).forEach(x -> onExecute(x, getContent() != null ? PlaceholderAPI.setBracketPlaceholders(player, getContent()) : null));
Bukkit.getOnlinePlayers().stream().filter(p -> (boolean) JavaScript.run(p, options.get(EnumOption.PLAYERS))).collect(Collectors.toList()).forEach(x -> onExecute(x, getContent() != null ? Vars.setBracketPlaceholders(player, getContent()) : null));
return;
}
if (options.containsKey(EnumOption.DELAY)) {
Expand Down
36 changes: 15 additions & 21 deletions src/main/java/me/arasple/mc/trhologram/commands/CommandDebug.kt
Original file line number Diff line number Diff line change
@@ -1,32 +1,26 @@
package me.arasple.mc.trhologram.commands

import io.izzel.taboolib.module.command.base.BaseCommand
import io.izzel.taboolib.module.command.base.BaseMainCommand
import me.arasple.mc.trhologram.hologram.HologramContent
import me.arasple.mc.trhologram.hologram.HologramManager
import io.izzel.taboolib.module.command.base.Argument
import io.izzel.taboolib.module.command.base.BaseSubCommand
import me.arasple.mc.trhologram.api.TrHologramAPI
import org.bukkit.command.Command
import org.bukkit.command.CommandSender
import org.bukkit.entity.Player
import java.util.function.Consumer

/**
* @author Arasple
* @date 2020/2/14 8:56
* @date 2020/2/13 22:38
*/
@BaseCommand(name = "holyshit")
class CommandDebug : BaseMainCommand() {
class CommandDebug : BaseSubCommand() {

override fun onCommand(sender: CommandSender, command: Command, label: String, args: Array<String>): Boolean {
if (sender is Player) {
println("HoloSize: " + HologramManager.getHolograms().size)
println("Holograms: \n")
HologramManager.getHolograms().forEach(Consumer { hologram ->
println("---: " + hologram.viewers)
hologram.contents.forEach(Consumer { hologramContent: HologramContent -> println("---: " + hologramContent.text) })
})
} else {
HologramManager.getHolograms().clear()
override fun getArguments(): Array<Argument> {
return arrayOf(Argument("Hologram Name", true))
}

override fun onCommand(sender: CommandSender, command: Command, label: String, args: Array<String>) {
val hologram = TrHologramAPI.getHologramById(args[0])
if (hologram != null) {
sender.sendMessage("As String: §7$hologram")
}
return true
}
}

}
16 changes: 10 additions & 6 deletions src/main/java/me/arasple/mc/trhologram/commands/CommandDelete.kt
Original file line number Diff line number Diff line change
Expand Up @@ -47,13 +47,17 @@ class CommandDelete : BaseSubCommand() {
})
}

private fun deleteHologram(player: Player, input: String?) {
if (TrHologramAPI.getHologramById(input) == null) {
TLocale.sendTo(player, "COMMANDS.DELETE.NOT-EXIST")
} else {
HologramManager.deleteHologram(input)
TLocale.sendTo(player, "COMMANDS.DELETE.SUCCESS")
companion object {

fun deleteHologram(player: Player, input: String) {
if (TrHologramAPI.getHologramById(input) == null) {
TLocale.sendTo(player, "COMMANDS.DELETE.NOT-EXIST")
} else {
HologramManager.deleteHologram(input)
TLocale.sendTo(player, "COMMANDS.DELETE.SUCCESS")
}
}

}

override fun getType(): CommandType {
Expand Down
63 changes: 63 additions & 0 deletions src/main/java/me/arasple/mc/trhologram/commands/CommandEdit.kt
Original file line number Diff line number Diff line change
@@ -0,0 +1,63 @@
package me.arasple.mc.trhologram.commands

import io.izzel.taboolib.module.command.base.Argument
import io.izzel.taboolib.module.command.base.BaseSubCommand
import io.izzel.taboolib.module.command.base.CommandTab
import io.izzel.taboolib.module.command.base.CommandType
import io.izzel.taboolib.module.locale.TLocale
import io.izzel.taboolib.util.lite.Catchers
import me.arasple.mc.trhologram.api.TrHologramAPI
import me.arasple.mc.trhologram.edit.EditorMenu
import org.bukkit.command.Command
import org.bukkit.command.CommandSender
import org.bukkit.entity.Player

/**
* @author Arasple
* @date 2020/2/15 12:29
*/
class CommandEdit : BaseSubCommand() {

override fun getArguments(): Array<Argument> {
return arrayOf(Argument("Hologram Name", false, CommandTab { TrHologramAPI.getHologramIds() }))
}

override fun onCommand(sender: CommandSender, command: Command, label: String, args: Array<String>) {
val player = sender as Player
Catchers.getPlayerdata().remove(player.name)
if (args.isNotEmpty()) {
editHologram(player, args[0])
return
}
Catchers.call(player, object : Catchers.Catcher {
override fun before(): Catchers.Catcher {
TLocale.sendTo(player, "COMMANDS.EDIT.INPUT-NAME")
return this
}

override fun after(input: String): Boolean {
editHologram(player, input)
return false
}

override fun cancel() {
TLocale.sendTo(player, "COMMANDS.QUIT")
}
})
}

private fun editHologram(player: Player, input: String) {
val hologram = TrHologramAPI.getHologramById(input)
if (hologram == null) {
TLocale.sendTo(player, "COMMANDS.EDIT.NOT-EXIST")
} else {
TLocale.Display.sendTitle(player, "", "", 5, 10, 5)
EditorMenu.openEditor(hologram, player)
}
}

override fun getType(): CommandType {
return CommandType.PLAYER
}

}
Loading

1 comment on commit bedd9f1

@z3030823844
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

为什么我在1.12.2还没加载出来呢

Please sign in to comment.