Language implementation #9

Open
Deliable wants to merge 5 commits from Deliable/LagAssist:master into master
  1. 56
      lang.yml
  2. 9
      src/com/entryrise/lagassist/Main.java
  3. 4
      src/com/entryrise/lagassist/api/MotdAPI.java
  4. 48
      src/com/entryrise/lagassist/chunks/ChkAnalyse.java

56
lang.yml

@ -0,0 +1,56 @@
# _ _ _
# | | /\ (_) | |
# | | __ _ __ _ / \ ___ ___ _ ___| |_
# | | / _` |/ _` | / /\ \ / __/ __| / __| __|
# | |___| (_| | (_| |/ ____ \\__ \__ \ \__ \ |_
# |______\__,_|\__, /_/ \_\___/___/_|___/\__|
# __/ |
# |___/ By EntryRise
#
# This is the default language configuration. You can edit any text you want.
# If you need help configuring it, please visit our dedicated Discord Server.
# DISCORD: https://discord.gg/4aWWPcb
# What should LagAssist write in the beginning of most of the sentences?
prefix: "§2§lLag§f§lAssist §e» §f"
errors:
chunkanalyse:
console-execution: "You cannot analyse the current chunk from console."
debug:
ping:
#What should LagAssist debug if it receives a MOTD ping from anyone?
received: "Received ping from $1"
response: "API ping response to $1"
chunkanalyse:
result1:
- ""
- "§2§l⬛⬛⬛⬛⬛⬛ §f§lCHUNKANALYSER §2§l⬛⬛⬛⬛⬛⬛"
- ""
- "$1"
- ""
- "⬛⬛⬛⬛⬛⬛⬛⬛⬛⬛⬛⬛⬛⬛⬛⬛⬛⬛⬛⬛⬛⬛⬛⬛"
result2:
- ""
- "⬛⬛⬛⬛⬛⬛ §f§lCHUNKANALYSER ⬛⬛⬛⬛⬛⬛"
- ""
- " ✸ Chunk ($1) - Score $2"
- ""
- "§2§l⬛⬛⬛⬛⬛⬛⬛⬛⬛⬛⬛⬛⬛⬛⬛⬛⬛⬛⬛⬛⬛⬛⬛⬛"
result3:
- "§2§l⬛⬛⬛⬛⬛⬛ §f§lCHUNK STATS §2§l⬛⬛⬛⬛⬛⬛"
- ""
- " §2✸ §fChunk coordonates: §7$1"
- ""
- " §2✸ §fEntity Amount: §7$2"
- " §2✸ §fTiles Amount: §7$3"
- ""
# CAUTION: Do not delete the "HOVERTEXT" text which is at the end of the sentence. The LagAssist will take care of it, "HOVERTEXT" text makes the string hoverable.
- " §2✸ §fDetailed Info §7(HOVER) HOVERTEXT"
- ""
- "§2§l⬛⬛⬛⬛⬛⬛⬛⬛⬛⬛⬛⬛⬛⬛⬛⬛⬛⬛⬛⬛⬛⬛"
# This allows the system to update the config if the plugin is updated.
version: 1

9
src/com/entryrise/lagassist/Main.java

@ -40,8 +40,6 @@ public class Main extends JavaPlugin implements Listener {
public static String USER = "%%__USER__%%"; public static String USER = "%%__USER__%%";
public static final String PREFIX = "§2§lLag§f§lAssist §e» §f";
public static JavaPlugin p; public static JavaPlugin p;
public static boolean paper = false; public static boolean paper = false;
@ -51,12 +49,19 @@ public class Main extends JavaPlugin implements Listener {
private static File file; private static File file;
public static FileConfiguration config = new YamlConfiguration(); public static FileConfiguration config = new YamlConfiguration();
private static File langfile = new File(getDataFolder(), "lang.yml");
public static YamlConfiguration lang = new YamlConfiguration();
public static final String PREFIX = "§2§lLag§f§lAssist §e» §f";
@Override @Override
public void onEnable() { public void onEnable() {
p = this; p = this;
file = new File(getDataFolder(), "server.yml"); file = new File(getDataFolder(), "server.yml");
config = Others.getConfig(file, 32); config = Others.getConfig(file, 32);
lang = Others.getConfig(langfile, 1);
paper = VersionMgr.isPaper(); paper = VersionMgr.isPaper();

4
src/com/entryrise/lagassist/api/MotdAPI.java

@ -24,7 +24,7 @@ public class MotdAPI implements Listener {
String saddr = addr.getHostAddress(); String saddr = addr.getHostAddress();
Main.sendDebug("Received ping from " + saddr, 1);
Main.sendDebug(Main.lang.getString("debug.ping.received").replace("$1", saddr), 1);
boolean found = false; boolean found = false;
@ -41,7 +41,7 @@ public class MotdAPI implements Listener {
return; return;
} }
Main.sendDebug("API ping response to " + saddr, 1);
Main.sendDebug(Main.lang.getString("debug.ping.response").replace("$1", saddr), 1);
try { try {
e.setServerIcon(generateIcon()); e.setServerIcon(generateIcon());

48
src/com/entryrise/lagassist/chunks/ChkAnalyse.java

@ -23,7 +23,7 @@ import com.entryrise.lagassist.Main;
public class ChkAnalyse { public class ChkAnalyse {
protected static int ammoshow = Main.config.getInt("chunkanalyse.ammount");
protected static int ammoshow = Main.config.getInt("chunkanalyse.amount");
protected static Map<String, Integer> values = new HashMap<String, Integer>(); protected static Map<String, Integer> values = new HashMap<String, Integer>();
private static List<ChkStats> scores = new ArrayList<ChkStats>(); private static List<ChkStats> scores = new ArrayList<ChkStats>();
@ -53,17 +53,17 @@ public class ChkAnalyse {
ch.genScores(); ch.genScores();
} }
Collections.sort(scores); Collections.sort(scores);
p.sendMessage("");
p.sendMessage("§2§l⬛⬛⬛⬛⬛⬛ §f§lCHUNKANALYSER §2§l⬛⬛⬛⬛⬛⬛");
p.sendMessage("");
for (int i = 0; i < ammoshow; i++) { for (int i = 0; i < ammoshow; i++) {
ChkStats cs = scores.get(i); ChkStats cs = scores.get(i);
p.spigot().sendMessage(cs.genText());
for (String str : Main.lang.getStringList("chunkanalyse.result1")) {
if (str.contains("$1")) {
p.spigot().sendMessage(cs.genText())
} else {
p.sendMessage(str.replace("$1", cs.genText()))
}
}
} }
p.sendMessage("");
p.sendMessage("§2§l⬛⬛⬛⬛⬛⬛⬛⬛⬛⬛⬛⬛⬛⬛⬛⬛⬛⬛⬛⬛⬛⬛⬛⬛");
} }
}); });
@ -93,10 +93,6 @@ public class ChkAnalyse {
} }
} }
p.sendMessage("");
p.sendMessage("⬛⬛⬛⬛⬛⬛ §f§lCHUNKANALYSER ⬛⬛⬛⬛⬛⬛");
p.sendMessage("");
Stream<Map.Entry<Chunk, Integer>> sorted = chunkscore.entrySet().stream() Stream<Map.Entry<Chunk, Integer>> sorted = chunkscore.entrySet().stream()
.sorted(Collections.reverseOrder(Map.Entry.comparingByValue())); .sorted(Collections.reverseOrder(Map.Entry.comparingByValue()));
@ -105,17 +101,15 @@ public class ChkAnalyse {
for (Chunk ch : topTen.keySet()) { for (Chunk ch : topTen.keySet()) {
int score = chunkscore.get(ch); int score = chunkscore.get(ch);
p.sendMessage(" ✸ Chunk (" + String.valueOf(ch.getX()) + " " + String.valueOf(ch.getZ()) + ") - Score "
+ String.valueOf(score));
for (String str : Main.lang.getStringList("chunkanalyse.result2")) {
p.sendMessage(str.replace("$1", String.valueOf(ch.getX()) + " " + String.valueOf(ch.getZ())).replace("$2", String.valueOf(score)))
}
} }
p.sendMessage("");
p.sendMessage("⬛⬛⬛⬛⬛⬛⬛⬛⬛⬛⬛⬛⬛⬛⬛⬛⬛⬛⬛⬛⬛⬛⬛⬛");
} }
public static void analyseCurrentChunk(CommandSender s) { public static void analyseCurrentChunk(CommandSender s) {
if (!(s instanceof Player)) { if (!(s instanceof Player)) {
s.sendMessage(Main.PREFIX + "You cannot analyse the current chunk from console.");
s.sendMessage(Main.PREFIX + Main.lang.getString("errors.chunkanalyse.console-execution"));
return; return;
} }
Player p = (Player) s; Player p = (Player) s;
@ -129,17 +123,13 @@ public class ChkAnalyse {
String cmd = "lagassist tpchunk " + p.getWorld().getName() + " " + String.valueOf(coords[0]) + " " String cmd = "lagassist tpchunk " + p.getWorld().getName() + " " + String.valueOf(coords[0]) + " "
+ String.valueOf(coords[1]); + String.valueOf(coords[1]);
p.sendMessage("§2§l⬛⬛⬛⬛⬛⬛ §f§lCHUNK STATS §2§l⬛⬛⬛⬛⬛⬛");
p.sendMessage("");
p.sendMessage(" §2✸ §fChunk coordonates: §7" + crds);
p.sendMessage("");
p.sendMessage(" §2✸ §fEntity Amount: §7" + stats.getEnts().length);
p.sendMessage(" §2✸ §fTiles Amount: §7" + stats.getTiles().length);
p.sendMessage("");
p.spigot().sendMessage(stats.genMobCount(" §2✸ §fDetailed Info §7(HOVER)", cmd));
p.sendMessage("");
p.sendMessage("§2§l⬛⬛⬛⬛⬛⬛⬛⬛⬛⬛⬛⬛⬛⬛⬛⬛⬛⬛⬛⬛⬛⬛");
for (String str : Main.lang.getStringList("chunkanalyse.result3")) {
if (str.endsWith("HOVERTEXT")) {
p.spigot().sendMessage(stats.genMobCount(str, cmd).replaceAll("HOVERTEXT", ""))
} else {
p.sendMessage(str.replace("$1", crds).replace("$2", stats.getEnts().length).replace("$3", stats.getTiles().length))
}
}
} }
} }

Loading…
Cancel
Save