Skip to content

Commit

Permalink
Merge pull request #3 from stevei5mc/dev
Browse files Browse the repository at this point in the history
Dev 1.0.0-beta3
  • Loading branch information
stevei5mc authored Feb 4, 2024
2 parents 9346578 + caec8c2 commit ac05c53
Show file tree
Hide file tree
Showing 22 changed files with 423 additions and 83 deletions.
5 changes: 3 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -30,9 +30,10 @@
|{Player-Ui}|获取玩家客户端使用的UI|{Device-Os}|获取玩家设备的系统|
|{{Player-Uuid}|获取玩家的uuid|{Player-Ping}|获取玩家当前的延迟|
|{Player-Food}|玩家当前的饥饿度|{Player-Health}|玩家当前的血量|
### 服务器相关的变
### 服务器相关的变量
|变量|介绍|变量|介绍|
|-|-|-|-|
|{Server-Motd}|获取服务器主motd|{Server-SubMotd}|获取服务器副motd|
|{Server-Ip}|获取服务器IP|{Server-Port}|获取服务器端口|
|{Server-Tps}|获取服务器当前TPS|---|---|
|{Server-Tps}|获取服务器当前TPS|---|---|
### [支持的插件](SupportPluginsVariables.md)
80 changes: 80 additions & 0 deletions SupportPluginsVariables.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,80 @@
[返回](README.md)
# NewTipsVariables(变量文档)
> **支持的插件篇**
> **按插件的英文字母排序**
> **TipsVeriable 相关变量移值中,部分变量名有改动**
## A
---
## B
---
## C
---
## D
---
## **E**
### **[EconomyAPI](https://github.com/Nukkit-coders/EconomyAPI)**
|变量名|变量介绍|
|-|-|
|{economyApi-money}|玩家金钱数量|
---
## F
---
## G
---
## H
---
## I
---
## J
---
## K
---
## L
---
## M
---
## N
---
## **O**
### **[OreArea](https://github.com/SmallasWater/OreArea)**
**注意: 变量`{orearea-time-use}`在有限时的矿区会有BUG(到秒就不动了)**
|变量名|变量介绍|
|-|-|
|{orearea-level-this}|获取玩家的矿区等级|
|{orearea-level-next}|获取玩家的矿区下一等级|
|{orearea-time-use}|获取玩家所在的矿区可以使用的时间|
|{orearea-time-reset}|获取玩家所在的刷新时间|
|{orearea-name}|获取玩家所在的矿区等级|
---
## **P**
### **[playerPoints](https://github.com/SmallasWater/PlayerPoints)**
|变量名|变量介绍|
|-|-|
|{point}|获取玩家的点券数量|
---
## Q
---
## R
### **[RsTask](https://github.com/MemoriesOfTime/RSTask)**
|变量名|变量介绍|
|-|-|
|{task-name}|正在进行中的任务 (显示第一个)|
|{task-count}|玩家任务积分|
---
## S
---
## T
---
## U
---
## V
---
## W
---
## X
---
## Y
---
## Z
---
Binary file added lib/OreArea_v1.3.8.jar
Binary file not shown.
Binary file added lib/RsTask_v1.8.4.jar
Binary file not shown.
27 changes: 25 additions & 2 deletions pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@

<groupId>cn.stevei5mc</groupId>
<artifactId>NewTipsVariables</artifactId>
<version>1.0.0-beta2</version>
<version>1.0.0-beta3</version>

<repositories>
<repository>
Expand Down Expand Up @@ -41,13 +41,36 @@
<artifactId>nukkit</artifactId>
<version>1.0-SNAPSHOT</version>
</dependency>

<dependency>
<groupId>com.smallaswater.tips</groupId>
<artifactId>Tips</artifactId>
<version>2.1.8</version>
<scope>provided</scope>
</dependency>
<dependency>
<groupId>com.smallaswater</groupId>
<artifactId>PlayerPoints</artifactId>
<version>1.3.0-20231117.131552-1</version>
</dependency>
<dependency>
<groupId>me.onebone</groupId>
<artifactId>economyapi</artifactId>
<version>2.0.3</version>
</dependency>
<dependency>
<groupId>com.smallaswater.orearea</groupId>
<artifactId>OreArea</artifactId>
<version>1.3.8</version>
<scope>system</scope>
<systemPath> ${project.basedir}/lib/OreArea_v1.3.8.jar</systemPath>
</dependency>
<dependency>
<groupId>com.smallaswater.rstask</groupId>
<artifactId>RsTask</artifactId>
<version>1.8.4</version>
<scope>system</scope>
<systemPath> ${project.basedir}/lib/RsTask_v1.8.4.jar</systemPath>
</dependency>
</dependencies>

<properties>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,13 +3,17 @@
import cn.nukkit.plugin.PluginBase;
import cn.nukkit.plugin.PluginManager;
import tip.utils.Api;
import cn.stevei5mc.NewTipsVariables.variables.tipstext;
import cn.stevei5mc.NewTipsVariables.variables.tipsserver;
import cn.stevei5mc.NewTipsVariables.variables.tipsplayer;
import cn.stevei5mc.NewTipsVariables.variables.tipsplayer2;
import cn.stevei5mc.NewTipsVariables.variables.tipsserver2;
import cn.stevei5mc.NewTipsVariables.variables.tipsText;
import cn.stevei5mc.NewTipsVariables.variables.tipsServer;
import cn.stevei5mc.NewTipsVariables.variables.tipsPlayer;
import cn.stevei5mc.NewTipsVariables.variables.tipsPlayerConfig;
import cn.stevei5mc.NewTipsVariables.variables.tipsServerConfig;
import cn.stevei5mc.NewTipsVariables.variables.supportPlugins.loadSupportPlugins;
import cn.nukkit.Player;

public class Main extends PluginBase {
public static Player player;

public class main extends PluginBase {
public void onEnable() {
this.loadresource();//先把资源文件给加载了
//判断需要的前置插件是否存在
Expand All @@ -33,22 +37,22 @@ public void onDisable() {
public void loadresource() {
this.getDataFolder().mkdirs(); //创建插件文件夹
//每次都加载最新的变量信息
this.saveResource("text-variables.txt","/text-variables.txt",true);
this.saveResource("server-variables.txt","/server-variables.txt",true);
this.saveResource("player-variables.txt","/player-variables.txt",true);
this.saveResource("base-variables.txt","/base-variables.txt",true);
this.saveResource("SupportPluginsVariables.txt","SupportPluginsVariables.txt",true);
this.getLogger().info("§a变量说明文件加载成功");
}

public void tipsvariables() {
Api.registerVariables("tipstext", tipstext.class);
Api.registerVariables("tipsserver", tipsserver.class);
Api.registerVariables("tipsplayer", tipsplayer.class);
Api.registerVariables("tipsplayer2", tipsplayer2.class);
Api.registerVariables("tipsserver2", tipsserver2.class);
Api.registerVariables("tipsText", tipsText.class);
Api.registerVariables("tipsServer", tipsServer.class);
Api.registerVariables("tipsPlayer", tipsPlayer.class);
Api.registerVariables("tipsPlayerConfig", tipsPlayerConfig.class);
Api.registerVariables("tipsServerConfig", tipsServerConfig.class);
loadSupportPlugins.loadSupportVariables(player);
}

public void loadover() {
this.getLogger().info(a加载成功");
this.getLogger().info(a变量加载完成");
this.getLogger().warning("§c警告:");
this.getLogger().warning("§c本插件为免费且开源的一款插件,如果你是付费获取到的那么你就被骗了");
this.getLogger().info("§a开源链接和使用方法: §bhttps://github.com/stevei5mc/NewTipsVariables");
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
package cn.stevei5mc.NewTipsVariables.variables.supportPlugins;

import cn.nukkit.Player;
import tip.utils.variables.BaseVariable;
import me.onebone.economyapi.EconomyAPI;

public class economyApiVariable extends BaseVariable {
public economyApiVariable(Player player) {
super(player);
}

public void strReplace() {
economyApi();
}

public void economyApi() {
addStrReplaceString("{economyApi-money}", String.format("%.2f", EconomyAPI.getInstance().myMoney(player))); //这个代码的是复制TipsVeriable的
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,61 @@
package cn.stevei5mc.NewTipsVariables.variables.supportPlugins;

import tip.utils.Api;
import cn.nukkit.Server;
import cn.nukkit.Player;
import cn.stevei5mc.NewTipsVariables.variables.supportPlugins.economyApiVariable;
import cn.stevei5mc.NewTipsVariables.variables.supportPlugins.smallasWater.playerPointsVariable;
import cn.stevei5mc.NewTipsVariables.variables.supportPlugins.smallasWater.OreAreaVariable;
import cn.stevei5mc.NewTipsVariables.variables.supportPlugins.smallasWater.RsTaskVariable;

public class loadSupportPlugins {

public static void loadSupportVariables(Player player) {
//加载相关插件的变量时的提示
String loadSuccessMsg1 = "§a找到插件§e【§b";
String loadSuccessMsg2 = "§e】§a相关变量已加载";
String loadFailureMsg1 = "§c无法找到插件§e【§b";
String loadFailureMsg2 = "§e】§c相关变量加载失败,请安装相关插件再试";
//需要加载的变量的插件

String loadPlugin1 = "playerPoints";
if (Server.getInstance().getPluginManager().getPlugin(loadPlugin1) != null) {
//存在
Api.registerVariables("playerPointsVariable", playerPointsVariable.class);
Server.getInstance().getLogger().info(loadSuccessMsg1 + loadPlugin1 + loadSuccessMsg2);
} else {
//不存在
Server.getInstance().getLogger().info(loadFailureMsg1 + loadPlugin1 + loadFailureMsg2);
}

String loadPlugin2 = "EconomyAPI";
if (Server.getInstance().getPluginManager().getPlugin(loadPlugin2) != null) {
//存在
Api.registerVariables("economyApiVariable", economyApiVariable.class);
Server.getInstance().getLogger().info(loadSuccessMsg1 + loadPlugin2 + loadSuccessMsg2);
} else {
//不存在
Server.getInstance().getLogger().info(loadFailureMsg1 + loadPlugin2 + loadFailureMsg2);
}

String loadPlugin3 = "OreArea";
if (Server.getInstance().getPluginManager().getPlugin(loadPlugin3) != null) {
//存在
Api.registerVariables("OreAreaVariable", OreAreaVariable.class);
Server.getInstance().getLogger().info(loadSuccessMsg1 + loadPlugin3 + loadSuccessMsg2);
} else {
//不存在
Server.getInstance().getLogger().info(loadFailureMsg1 + loadPlugin3 + loadFailureMsg2);
}

String loadPlugin4 = "RSTask";
if (Server.getInstance().getPluginManager().getPlugin(loadPlugin4) != null) {
//存在
Api.registerVariables("RsTaskVariable", RsTaskVariable.class);
Server.getInstance().getLogger().info(loadSuccessMsg1 + loadPlugin4 + loadSuccessMsg2);
} else {
//不存在
Server.getInstance().getLogger().info(loadFailureMsg1 + loadPlugin4 + loadFailureMsg2);
}
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,78 @@
package cn.stevei5mc.NewTipsVariables.variables.supportPlugins.smallasWater;

import cn.nukkit.Player;
import tip.utils.variables.BaseVariable;
import ore.area.utils.player.PlayerClass;
import ore.area.utils.area.AreaClass;
import ore.area.utils.Tools;
import ore.area.AreaMainClass;
import java.util.LinkedHashMap;

public class OreAreaVariable extends BaseVariable {
public OreAreaVariable(Player player) {
super(player);
}

public void strReplace() {
OreAreaVarPlayer();
OreAreaVarArea();
}

public void OreAreaVarPlayer() {
//这个代码的是复制TipsVeriable的
PlayerClass playerClass = PlayerClass.getPlayerClass(player.getName());
addStrReplaceString("{orearea-level-this}", playerClass.getMaxAreaLevel() + "");
addStrReplaceString("{orearea-level-next}", playerClass.getMaxAreaLevel() + 1 + "");
}

//参考(复制但有改动) https://github.com/SmallasWater/OreArea/blob/master/src/main/java/ore/area/utils/OreAreaVariable.java
public void OreAreaVarArea() {
AreaClass areaClass = Tools.getDefaultArea(player, 2);
String time = "§c不在范围,无法获取可使用时间";
String reset = "§c不在范围,无法获取刷新时间";
String name = "§c没有解锁矿区";
if(areaClass != null){
if(AreaMainClass.getInstance().useTime.containsKey(player.getName())) {
LinkedHashMap<String,Integer> map = AreaMainClass.getInstance().useTime.get(player.getName());
if(map.containsKey(areaClass.getName())){
int i = Math.round(map.get(areaClass.getName()) /60);
if(i != 0) {
time = "§7" +i + "§2分钟";
}else{
time = "§7" +areaClass.getUseTime() + "§2秒";
}
}
}else{
if(!areaClass.isKey()){
time = "§c未开启";
}else{
PlayerClass playerClass = PlayerClass.getPlayerClass(player.getName());
if(playerClass.canKey(areaClass.getName())) {
if(areaClass.getUseTime() == -1) {
time = "§7无时限";
}else{
int i = Math.round(areaClass.getUseTime() /60);
if(i != 0) {
time = "§7" +i + "§2分钟";
}else{
time = "§7" +areaClass.getUseTime() + "§2秒";
}
}
}else{
time = "§c未解锁矿区";
}
}

}
if(AreaMainClass.timer.containsKey(areaClass.getName())) {
reset = String.valueOf(AreaMainClass.timer.get(areaClass.getName()));
}else{
reset = "§c未刷新";
}
name = areaClass.getName();
}
addStrReplaceString("{orearea-time-use}", time);
addStrReplaceString("{orearea-time-reset}", reset);
addStrReplaceString("{orearea-name}", name);
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
package cn.stevei5mc.NewTipsVariables.variables.supportPlugins.smallasWater;

import cn.nukkit.Player;
import tip.utils.variables.BaseVariable;
import com.task.utils.tasks.PlayerFile;
import com.task.utils.tasks.taskitems.PlayerTask;
import java.util.LinkedList;

public class RsTaskVariable extends BaseVariable {
public RsTaskVariable(Player player) {
super(player);
}

public void strReplace() {
RsTaskVar();
}

public void RsTaskVar() {
//这个代码的是复制TipsVeriable的
PlayerFile file = PlayerFile.getPlayerFile(this.player.getName());
LinkedList<PlayerTask> tasks = file.getInviteTasks();
String taskName = "暂无";
if (tasks.size() > 0) {
PlayerTask task = (PlayerTask)tasks.get(0);
if (task != null) {
taskName = task.getTaskName();
}
}

this.addStrReplaceString("{task-name}", taskName);
this.addStrReplaceString("{task-count}", file.getCount() + "");
}
}
Loading

0 comments on commit ac05c53

Please sign in to comment.