Initial commit
v1.0
This commit is contained in:
@@ -0,0 +1,50 @@
|
|||||||
|
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
|
||||||
|
<modelVersion>4.0.0</modelVersion>
|
||||||
|
<groupId>pl.laststation.youhavetrouble</groupId>
|
||||||
|
<artifactId>dynamichelp</artifactId>
|
||||||
|
<version>1.0.0-SNAPSHOT</version>
|
||||||
|
<build>
|
||||||
|
<defaultGoal>install</defaultGoal>
|
||||||
|
<plugins>
|
||||||
|
<plugin>
|
||||||
|
<groupId>org.apache.maven.plugins</groupId>
|
||||||
|
<artifactId>maven-compiler-plugin</artifactId>
|
||||||
|
<version>3.8.1</version>
|
||||||
|
<configuration>
|
||||||
|
<source>1.8</source>
|
||||||
|
<target>1.8</target>
|
||||||
|
</configuration>
|
||||||
|
</plugin>
|
||||||
|
</plugins>
|
||||||
|
</build>
|
||||||
|
<repositories>
|
||||||
|
<repository>
|
||||||
|
<id>spigot-repo</id>
|
||||||
|
<url>https://hub.spigotmc.org/nexus/content/repositories/snapshots/</url>
|
||||||
|
</repository>
|
||||||
|
<repository>
|
||||||
|
<id>jitpack.io</id>
|
||||||
|
<url>https://jitpack.io</url>
|
||||||
|
</repository>
|
||||||
|
<repository>
|
||||||
|
<id>codemc-repo</id>
|
||||||
|
<url>https://repo.codemc.org/repository/maven-public/</url>
|
||||||
|
</repository>
|
||||||
|
</repositories>
|
||||||
|
<dependencies>
|
||||||
|
<dependency>
|
||||||
|
<groupId>org.bukkit</groupId>
|
||||||
|
<artifactId>bukkit</artifactId>
|
||||||
|
<version>1.15.1-R0.1-SNAPSHOT</version><!--change this value depending on the version or use LATEST-->
|
||||||
|
<type>jar</type>
|
||||||
|
<scope>provided</scope>
|
||||||
|
</dependency>
|
||||||
|
<dependency>
|
||||||
|
<groupId>org.spigotmc</groupId>
|
||||||
|
<artifactId>spigot-api</artifactId>
|
||||||
|
<version>1.15.1-R0.1-SNAPSHOT</version><!--change this value depending on the version-->
|
||||||
|
<type>jar</type>
|
||||||
|
<scope>provided</scope>
|
||||||
|
</dependency>
|
||||||
|
</dependencies>
|
||||||
|
</project>
|
||||||
@@ -0,0 +1,38 @@
|
|||||||
|
package pl.laststation.youhavetrouble.dynamichelp.commands;
|
||||||
|
|
||||||
|
import org.bukkit.command.Command;
|
||||||
|
import org.bukkit.command.CommandExecutor;
|
||||||
|
import org.bukkit.command.CommandSender;
|
||||||
|
import org.bukkit.entity.Player;
|
||||||
|
import pl.laststation.youhavetrouble.dynamichelp.dynamichelp;
|
||||||
|
import pl.laststation.youhavetrouble.dynamichelp.langmodule.lang;
|
||||||
|
|
||||||
|
|
||||||
|
public class helpCommand implements CommandExecutor {
|
||||||
|
|
||||||
|
public helpCommand(dynamichelp plugin) {
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public boolean onCommand(CommandSender commandSender, Command command, String s, String[] args) {
|
||||||
|
|
||||||
|
new lang.translate();
|
||||||
|
Player p = (Player) commandSender;
|
||||||
|
if (args.length > 1) {
|
||||||
|
commandSender.sendMessage(lang.getTranslatedString(p, "too-many-arguments"));
|
||||||
|
return true;
|
||||||
|
} else if (args.length == 1) {
|
||||||
|
if (dynamichelp.getPlugin().getConfig().getString("lang.en_us."+args[0]) == null) {
|
||||||
|
commandSender.sendMessage(lang.getTranslatedString(p, "invalid-page"));
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
commandSender.sendMessage(lang.getTranslatedString(p, args[0]));
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
commandSender.sendMessage(lang.getTranslatedString(p, "1"));
|
||||||
|
return true;
|
||||||
|
|
||||||
|
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -0,0 +1,21 @@
|
|||||||
|
package pl.laststation.youhavetrouble.dynamichelp;
|
||||||
|
|
||||||
|
import org.bukkit.plugin.java.JavaPlugin;
|
||||||
|
import pl.laststation.youhavetrouble.dynamichelp.commands.helpCommand;
|
||||||
|
|
||||||
|
public class dynamichelp extends JavaPlugin {
|
||||||
|
|
||||||
|
public void onEnable() {
|
||||||
|
|
||||||
|
plugin = this;
|
||||||
|
|
||||||
|
saveDefaultConfig();
|
||||||
|
getCommand("help").setExecutor(new helpCommand(this));
|
||||||
|
}
|
||||||
|
|
||||||
|
private static dynamichelp plugin;
|
||||||
|
|
||||||
|
public static dynamichelp getPlugin(){ return plugin; }
|
||||||
|
|
||||||
|
|
||||||
|
}
|
||||||
@@ -0,0 +1,36 @@
|
|||||||
|
package pl.laststation.youhavetrouble.dynamichelp.langmodule;
|
||||||
|
|
||||||
|
import org.bukkit.entity.Player;
|
||||||
|
import pl.laststation.youhavetrouble.dynamichelp.dynamichelp;
|
||||||
|
|
||||||
|
public class lang {
|
||||||
|
|
||||||
|
/**
|
||||||
|
*
|
||||||
|
* @param p Player of whom locale we're getting
|
||||||
|
* @param msg Message string
|
||||||
|
* @return Message translated to language based on player's locale
|
||||||
|
*/
|
||||||
|
public static String getTranslatedString(Player p, String msg) {
|
||||||
|
|
||||||
|
String plocale = p.getLocale();
|
||||||
|
String tmessage = dynamichelp.getPlugin().getConfig().getString("lang." + plocale + "." + msg);
|
||||||
|
String dmessage = dynamichelp.getPlugin().getConfig().getString("lang.en_us." + msg);
|
||||||
|
if (tmessage == null) {
|
||||||
|
if (dmessage == null) {
|
||||||
|
return " ";
|
||||||
|
}
|
||||||
|
return dmessage;
|
||||||
|
} else {
|
||||||
|
return tmessage;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public static class translate {
|
||||||
|
public static translate translate;
|
||||||
|
public translate() {
|
||||||
|
this.translate = this;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
@@ -0,0 +1,39 @@
|
|||||||
|
#Use this file to create your own help subcommands
|
||||||
|
#If user does not specify an argument, the message will default to "la_ng.1"
|
||||||
|
#Default minecraft formatting codes are working in all messages! (https://minecraft.gamepedia.com/Formatting_codes)
|
||||||
|
#
|
||||||
|
#MAKE SURE THAT EN_US SECTION ALWAYS HAS ALL THE MESSAGES OR THE COMMANDS WON'T WORK
|
||||||
|
lang:
|
||||||
|
en_us:
|
||||||
|
too-many-arguments: "Too many arguments"
|
||||||
|
invalid-argument: "Invalid argument"
|
||||||
|
invalid-page: "There is no page with that index"
|
||||||
|
1: |
|
||||||
|
&b-------- DynamicLangHelp (en_us) --------
|
||||||
|
Default help message for en_us locale!
|
||||||
|
See DynamicLangHelp/config.yml to change this message
|
||||||
|
|
||||||
|
You can add as many lines as you want, but remember,
|
||||||
|
that default client only shows 15 lines of text while
|
||||||
|
chat is open!
|
||||||
|
#This message will appear after typing /help info
|
||||||
|
info: |
|
||||||
|
An example of custom /help info subcommand
|
||||||
|
You can make any /help subcommand you want
|
||||||
|
|
||||||
|
pl_pl:
|
||||||
|
too-many-arguments: "Zbyt dużo argumentów"
|
||||||
|
invalid-argument: "nieprawidłowy argument"
|
||||||
|
invalid-page: "Nie ma strony o takim indeksie"
|
||||||
|
1: |
|
||||||
|
-------- DynamicLangHelp (pl_pl) --------
|
||||||
|
Domyślna wiadomość pomocy dla lokalizacji pl_pl!
|
||||||
|
Sprawdź DynamicLangHelp/config.yml żeby zmienić tę wiadomość
|
||||||
|
|
||||||
|
Możesz dodać dowolną ilość linii, ale pamiętaj,
|
||||||
|
że domyślny klient pokazuje tylko 15 linii tekstu
|
||||||
|
przy otwartym czacie!
|
||||||
|
#Ta wiadomość wyświetli się po wpisaniu /help info
|
||||||
|
info: |
|
||||||
|
Przykład subkomendy /help info
|
||||||
|
Mozesz zrobić dowolną subkomendę /help
|
||||||
@@ -0,0 +1,9 @@
|
|||||||
|
main: pl.laststation.youhavetrouble.dynamichelp.dynamichelp
|
||||||
|
name: DynamicLangHelp
|
||||||
|
version: 1.0.0
|
||||||
|
description: Dynamic Locale Help command
|
||||||
|
author: YouHaveTrouble
|
||||||
|
commands:
|
||||||
|
help:
|
||||||
|
description: Main command for the plugin
|
||||||
|
usage: /<command> <arg>
|
||||||
Reference in New Issue
Block a user