Skip to content
This repository has been archived by the owner on Feb 21, 2020. It is now read-only.

Commit

Permalink
1.4.0 Command Updater
Browse files Browse the repository at this point in the history
  • Loading branch information
MlgmXyysd authored Apr 13, 2018
1 parent a572141 commit 729a143
Show file tree
Hide file tree
Showing 5 changed files with 133 additions and 93 deletions.
Binary file modified PlaceholderAPI.jar
Binary file not shown.
30 changes: 30 additions & 0 deletions config.yml
Original file line number Diff line number Diff line change
Expand Up @@ -63,6 +63,36 @@ language:
console-latest: "Good job,you are using the latest version."
console-newver: "There are newer version: "
update-check-disabled: "\u00a74You disabled update check,Please go to plugin post to check update!"
# Simplified Chinese
zh-cn:
msg-signal-1: "\u00a7a\u6210\u529f\u8bbe\u7f6e "
msg-signal-2: " \u500d\u7ecf\u9a8c\u6d3b\u52a8\uff0c\u6301\u7eed "
msg-signal-3: " \u5206\u949f\uff01"
msg-getexp-1: "\u00a7a"
msg-getexp-2: " \u500d\u7ecf\u9a8c\u6d3b\u52a8\u8fdb\u884c\u4e2d\uff0c\u4f60\u83b7\u5f97\u4e86 "
msg-getexp-3: " \u70b9\u7ecf\u9a8c\uff01"
msg-expired: "\u00a7c\u7ecf\u9a8c\u7ffb\u500d\u6d3b\u52a8\u5df2\u8fc7\u671f\uff01"
msg-ended: "\u00a7c\u7ecf\u9a8c\u7ffb\u500d\u6d3b\u52a8\u5df2\u7ed3\u675f\uff01"
msg-holding-1: "\u00a7a"
msg-holding-2: " \u500d\u7ecf\u9a8c\u6d3b\u52a8\u8fdb\u884c\u4e2d\uff0c\u5269\u4f59\u65f6\u95f4 "
msg-holding-3: " \u5206\u949f\uff01"
msg-broadcast-1: "\u00a7a"
msg-broadcast-2: " \u500d\u7ecf\u9a8c\u6d3b\u52a8\u73b0\u5df2\u5f00\u542f\uff0c\u5269\u4f59\u65f6\u95f4 "
msg-broadcast-3: " \u5206\u949f\uff01"
msg-failure: "\u00a7c\u6d3b\u52a8\u65f6\u95f4\u5df2\u8fc7\u671f\uff0c\u65e0\u6cd5\u5f00\u542f\uff0c\u8bf7\u5148\u4f7f\u7528set\u6307\u4ee4\u8bbe\u7f6e\u3002"
syntaxerror-integer: "\u00a7c\u8bed\u6cd5\u9519\u8bef\uff0c\u8be5\u53c2\u6570\u5e94\u4e3a\u6574\u6570\uff01"
reload: "\u00a7a\u63d2\u4ef6\u5df2\u91cd\u8f7d\uff01"
usage: "\u00a7eUsage: /multiexp [set/enable/disable/reload] [\u500d\u6570] [\u6301\u7eed\u5206\u949f] [true]"
papi-minutes: " \u5206\u949f"
papi-expired: "\u00a74\u5df2\u8fc7\u671f"
papi-hooking: "\u6b63\u5728\u8fde\u63a5PlaceholderAPI\u63d2\u4ef6\u3002"
papi-success: "\u6210\u529f\u4e0ePlaceholderAPI\u63d2\u4ef6\u8fdb\u884c\u5bf9\u63a5\uff01"
papi-failed: "PlaceholderAPI\u63d2\u4ef6\u5bf9\u63a5\u5931\u8d25\uff01"
console-enable: "\u63d2\u4ef6\u5df2\u542f\u7528\u3002"
console-disable: "\u63d2\u4ef6\u5df2\u5378\u8f7d\u3002"
console-latest: "\u4f60\u6240\u4f7f\u7528\u63d2\u4ef6\u7684\u5df2\u7ecf\u662f\u6700\u65b0\u7248\u672c\uff01"
console-newver: "\u53d1\u73b0\u65b0\u7248\u672c\uff0c\u7248\u672c\u53f7\u4e3a: "
update-check-disabled: "\u00a74\u4f60\u7981\u7528\u4e86\u66f4\u65b0\u68c0\u6d4b\u529f\u80fd\uff0c\u8bf7\u7ecf\u5e38\u5230\u63d2\u4ef6\u53d1\u5e03\u5e16\u624b\u52a8\u68c0\u67e5\u65b0\u7248\u672c\uff01"
# Multi Experience Configuration
multiexp:
# Very Important Person Multi Experience [Int]
Expand Down
2 changes: 1 addition & 1 deletion plugin.yml
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
name: MultiExperience
main: org.meowcat.MultiExperience.Main
author: MeowCat Studio
version: 1.3.0
version: 1.4.0
website: http://www.meowcat.org/
database: false
description: Let your experience multiable.
Expand Down
101 changes: 101 additions & 0 deletions src/org/meowcat/MultiExperience/Commands.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,101 @@
package org.meowcat.MultiExperience;

import org.bukkit.Bukkit;
import org.bukkit.Server;
import org.bukkit.command.Command;
import org.bukkit.command.CommandExecutor;
import org.bukkit.command.CommandSender;
import org.bukkit.configuration.file.FileConfiguration;

public class Commands implements CommandExecutor {
Server getServer = Bukkit.getServer();
FileConfiguration getConfig = Main.Main.getConfig();

public static boolean isNumber(String str) {
for (int i = str.length(); --i >= 0;) {
if (!Character.isDigit(str.charAt(i))) {
return false;
}
}
return true;
}

public boolean onCommand(CommandSender player, Command command, String label, String[] arguments) {
if (arguments.length > 0) {
if (arguments[0].equalsIgnoreCase("set")) {
int Multiple = 2;
long MultiTime = 60;
long CurrentTime = System.currentTimeMillis();
if (arguments.length > 1) {
if (isNumber(arguments[1])) {
Multiple = Integer.valueOf(arguments[1]);
} else {
player.sendMessage(getConfig
.getString("language." + getConfig.getString("language.use") + ".syntaxerror-integer"));
}
if (arguments.length > 2) {
if (isNumber(arguments[2])) {
MultiTime = Long.valueOf(arguments[2]);
} else {
player.sendMessage(getConfig.getString(
"language." + getConfig.getString("language.use") + ".syntaxerror-integer"));
}
}
}
long RemainingTime = MultiTime * 60000 + CurrentTime;
getConfig.set("multiexp.multiple", Multiple);
getConfig.set("multiexp.tick-time", RemainingTime);
player.sendMessage(getConfig
.getString("language." + getConfig.getString("language.use") + ".msg-signal-1") + Multiple
+ getConfig.getString("language." + getConfig.getString("language.use") + ".msg-signal-2")
+ MultiTime
+ getConfig.getString("language." + getConfig.getString("language.use") + ".msg-signal-3"));
if (arguments.length > 3) {
if (arguments[3].equalsIgnoreCase("true") || arguments[3].equalsIgnoreCase("t")) {
getConfig.set("configuration.multiexp-enabled", true);
getServer.broadcastMessage(getConfig
.getString("language." + getConfig.getString("language.use") + ".msg-broadcast-1")
+ Multiple
+ getConfig.getString(
"language." + getConfig.getString("language.use") + ".msg-broadcast-2")
+ MultiTime + getConfig.getString(
"language." + getConfig.getString("language.use") + ".msg-broadcast-3"));
}
}
} else if (arguments[0].equalsIgnoreCase("enable")) {
long CurrentTime = System.currentTimeMillis();
long MultiTime = getConfig.getLong("multiexp.tick-time");
if (CurrentTime <= MultiTime) {
long RemainingTime = (MultiTime - CurrentTime) / 60000;
int Time = (int) Math.floor(RemainingTime);
int Multiple = getConfig.getInt("multiexp.multiple");
getConfig.set("configuration.multiexp-enabled", true);
getServer.broadcastMessage(
getConfig.getString("language." + getConfig.getString("language.use") + ".msg-broadcast-1")
+ Multiple
+ getConfig.getString(
"language." + getConfig.getString("language.use") + ".msg-broadcast-2")
+ Time + getConfig.getString(
"language." + getConfig.getString("language.use") + ".msg-broadcast-3"));
} else {
player.sendMessage(
getConfig.getString("language." + getConfig.getString("language.use") + ".msg-failure"));
}
} else if (arguments[0].equalsIgnoreCase("disable")) {
getConfig.set("configuration.multiexp-enabled", false);
getConfig.set("multiexp.tick-time", 0);
getServer.broadcastMessage(
getConfig.getString("language." + getConfig.getString("language.use") + ".msg-ended"));
} else if (arguments[0].equalsIgnoreCase("reload")) {
Main.Main.saveDefaultConfig();
Main.Main.reloadConfig();
player.sendMessage(getConfig.getString("language." + getConfig.getString("language.use") + ".reload"));
}
} else {
player.sendMessage("¡ìbMulti Experience by MeowCat Studio");
player.sendMessage("¡ìbhttp://www.meowcat.org/");
player.sendMessage(getConfig.getString("language." + getConfig.getString("language.use") + ".usage"));
}
return true;
}
}
93 changes: 1 addition & 92 deletions src/org/meowcat/MultiExperience/Main.java
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,6 @@
import java.io.InputStreamReader;
import java.net.URL;
import org.bukkit.Bukkit;
import org.bukkit.command.Command;
import org.bukkit.command.CommandSender;
import org.bukkit.event.Listener;
import org.bukkit.plugin.Plugin;
import org.bukkit.plugin.java.JavaPlugin;
Expand All @@ -21,6 +19,7 @@ public void onEnable() {
saveDefaultConfig();
Main = this;
getServer().getPluginManager().registerEvents(new EventListener(), this);
getCommand("multiexperience").setExecutor(new Commands());
if (getConfig().getBoolean("configuration.auto-broadcast-enabled")) {
long interval = getConfig().getInt("configuration.broadcast-interval-time") * 60000;
new BukkitRunnable() {
Expand Down Expand Up @@ -126,94 +125,4 @@ public void run() {
}
}.runTaskAsynchronously(this);
}

public static boolean isNumber(String str) {
for (int i = str.length(); --i >= 0;) {
if (!Character.isDigit(str.charAt(i))) {
return false;
}
}
return true;
}

@Override
public boolean onCommand(CommandSender player, Command command, String label, String[] arguments) {
if (arguments.length > 0) {
if (arguments[0].equalsIgnoreCase("set")) {
int Multiple = 2;
long MultiTime = 60;
long CurrentTime = System.currentTimeMillis();
if (arguments.length > 1) {
if (isNumber(arguments[1])) {
Multiple = Integer.valueOf(arguments[1]);
} else {
player.sendMessage(getConfig().getString(
"language." + getConfig().getString("language.use") + ".syntaxerror-integer"));
}
if (arguments.length > 2) {
if (isNumber(arguments[2])) {
MultiTime = Long.valueOf(arguments[2]);
} else {
player.sendMessage(getConfig().getString(
"language." + getConfig().getString("language.use") + ".syntaxerror-integer"));
}
}
}
long RemainingTime = MultiTime * 60000 + CurrentTime;
getConfig().set("multiexp.multiple", Multiple);
getConfig().set("multiexp.tick-time", RemainingTime);
player.sendMessage(getConfig()
.getString("language." + getConfig().getString("language.use") + ".msg-signal-1") + Multiple
+ getConfig().getString("language." + getConfig().getString("language.use") + ".msg-signal-2")
+ MultiTime
+ getConfig().getString("language." + getConfig().getString("language.use") + ".msg-signal-3"));
if (arguments.length > 3) {
if (arguments[3].equalsIgnoreCase("true") || arguments[3].equalsIgnoreCase("t")) {
getConfig().set("configuration.multiexp-enabled", true);
getServer().broadcastMessage(getConfig()
.getString("language." + getConfig().getString("language.use") + ".msg-broadcast-1")
+ Multiple
+ getConfig().getString(
"language." + getConfig().getString("language.use") + ".msg-broadcast-2")
+ MultiTime + getConfig().getString(
"language." + getConfig().getString("language.use") + ".msg-broadcast-3"));
}
}
} else if (arguments[0].equalsIgnoreCase("enable")) {
long CurrentTime = System.currentTimeMillis();
long MultiTime = getConfig().getLong("multiexp.tick-time");
if (CurrentTime <= MultiTime) {
long RemainingTime = (MultiTime - CurrentTime) / 60000;
int Time = (int) Math.floor(RemainingTime);
int Multiple = getConfig().getInt("multiexp.multiple");
getConfig().set("configuration.multiexp-enabled", true);
getServer().broadcastMessage(getConfig()
.getString("language." + getConfig().getString("language.use") + ".msg-broadcast-1")
+ Multiple
+ getConfig()
.getString("language." + getConfig().getString("language.use") + ".msg-broadcast-2")
+ Time + getConfig().getString(
"language." + getConfig().getString("language.use") + ".msg-broadcast-3"));
} else {
player.sendMessage(getConfig()
.getString("language." + getConfig().getString("language.use") + ".msg-failure"));
}
} else if (arguments[0].equalsIgnoreCase("disable")) {
getConfig().set("configuration.multiexp-enabled", false);
getConfig().set("multiexp.tick-time", 0);
getServer().broadcastMessage(
getConfig().getString("language." + getConfig().getString("language.use") + ".msg-ended"));
} else if (arguments[0].equalsIgnoreCase("reload")) {
saveDefaultConfig();
reloadConfig();
player.sendMessage(
getConfig().getString("language." + getConfig().getString("language.use") + ".reload"));
}
} else {
player.sendMessage("¡ìbMulti Experience by MeowCat Studio");
player.sendMessage("¡ìbhttp://www.meowcat.org/");
player.sendMessage(getConfig().getString("language." + getConfig().getString("language.use") + ".usage"));
}
return true;
}
}

0 comments on commit 729a143

Please sign in to comment.