mirror of
https://github.com/TotalFreedomMC/TF-EssentialsX.git
synced 2025-08-06 20:43:11 +00:00
This is a big refactoring of the user class and more.
Many commands have been cleaned. File changes: - all user data has been moved from users.yml to userdata folder - all files in userdata folder are lower case Both changes should be done automatically. Class changes: - Moved all user data functions to UserData class - Moved all user teleport functions to Teleport class - Moved the user list to Essentials class - Less static functions for better testing - EssentialsCommand now has ess Property (Essentials class) - New NotEnoughArgumentsException, that will show command description and syntax New commands: - /seen, shows the last login or logout - /tempban, temporarily ban someone - /tjail and mute, temporarily option added Other changes: - ban reason is saved - don't show "You have xxx mail" on login, if user doesn't have essentials.mail permission - time will be parsed: years, months (mo), weeks, days, hours, minutes (m), seconds, these can be shortened and combined, example: 2 days 5h 30m git-svn-id: https://svn.java.net/svn/essentials~svn/trunk@1300 e251c2fe-e539-e718-e476-b85c1f46cddb
This commit is contained in:
parent
03fd6249fc
commit
224c18348a
126 changed files with 3542 additions and 3145 deletions
|
@ -1,6 +1,5 @@
|
|||
package com.earth2me.essentials.commands;
|
||||
|
||||
import com.earth2me.essentials.Essentials;
|
||||
import java.io.BufferedReader;
|
||||
import java.io.File;
|
||||
import java.io.FileReader;
|
||||
|
@ -11,38 +10,45 @@ import java.util.Map;
|
|||
import org.bukkit.Server;
|
||||
import org.bukkit.command.CommandSender;
|
||||
|
||||
public class Commandinfo extends EssentialsCommand {
|
||||
|
||||
public Commandinfo() {
|
||||
public class Commandinfo extends EssentialsCommand
|
||||
{
|
||||
public Commandinfo()
|
||||
{
|
||||
super("info");
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void run(Server server, Essentials parent, CommandSender sender, String commandLabel, String[] args) throws Exception {
|
||||
protected void run(Server server, CommandSender sender, String commandLabel, String[] args) throws Exception
|
||||
{
|
||||
String pageStr = args.length > 0 ? args[0].trim() : null;
|
||||
|
||||
List<String> lines = new ArrayList<String>();
|
||||
List<String> chapters = new ArrayList<String>();
|
||||
Map<String, Integer> bookmarks = new HashMap<String, Integer>();
|
||||
File file = new File(parent.getDataFolder(), "info.txt");
|
||||
File file = new File(ess.getDataFolder(), "info.txt");
|
||||
if (file.exists())
|
||||
{
|
||||
BufferedReader rx = new BufferedReader(new FileReader(file));
|
||||
int i = 0;
|
||||
for (String l = null; rx.ready() && (l = rx.readLine()) != null; i++)
|
||||
{
|
||||
if (l.startsWith("#")) {
|
||||
if (l.startsWith("#"))
|
||||
{
|
||||
bookmarks.put(l.substring(1).toLowerCase(), i);
|
||||
chapters.add(l.substring(1));
|
||||
}
|
||||
lines.add(l.replace('&', '§'));
|
||||
}
|
||||
} else {
|
||||
}
|
||||
else
|
||||
{
|
||||
sender.sendMessage("File info.txt does not exists.");
|
||||
return;
|
||||
}
|
||||
|
||||
if (bookmarks.isEmpty()) {
|
||||
|
||||
if (bookmarks.isEmpty())
|
||||
{
|
||||
int page = 1;
|
||||
try
|
||||
{
|
||||
|
@ -52,10 +58,11 @@ public class Commandinfo extends EssentialsCommand {
|
|||
{
|
||||
page = 1;
|
||||
}
|
||||
|
||||
|
||||
int start = (page - 1) * 9;
|
||||
int pages = lines.size() / 9 + (lines.size() % 9 > 0 ? 1 : 0);
|
||||
|
||||
charge(sender);
|
||||
sender.sendMessage("Page §c" + page + "§f of §c" + pages + "§f:");
|
||||
for (int i = start; i < lines.size() && i < start + 9; i++)
|
||||
{
|
||||
|
@ -63,14 +70,18 @@ public class Commandinfo extends EssentialsCommand {
|
|||
}
|
||||
return;
|
||||
}
|
||||
|
||||
if (pageStr == null || pageStr.isEmpty() || pageStr.matches("[0-9]+")) {
|
||||
if (lines.get(0).startsWith("#")) {
|
||||
|
||||
if (pageStr == null || pageStr.isEmpty() || pageStr.matches("[0-9]+"))
|
||||
{
|
||||
if (lines.get(0).startsWith("#"))
|
||||
{
|
||||
sender.sendMessage("Select chapter:");
|
||||
StringBuilder sb = new StringBuilder();
|
||||
boolean first = true;
|
||||
for (String string : chapters) {
|
||||
if (!first) {
|
||||
for (String string : chapters)
|
||||
{
|
||||
if (!first)
|
||||
{
|
||||
sb.append(", ");
|
||||
}
|
||||
first = false;
|
||||
|
@ -78,7 +89,9 @@ public class Commandinfo extends EssentialsCommand {
|
|||
}
|
||||
sender.sendMessage(sb.toString());
|
||||
return;
|
||||
} else {
|
||||
}
|
||||
else
|
||||
{
|
||||
int page = 1;
|
||||
try
|
||||
{
|
||||
|
@ -94,12 +107,14 @@ public class Commandinfo extends EssentialsCommand {
|
|||
for (end = 0; end < lines.size(); end++)
|
||||
{
|
||||
String line = lines.get(end);
|
||||
if (line.startsWith("#")) {
|
||||
if (line.startsWith("#"))
|
||||
{
|
||||
break;
|
||||
}
|
||||
}
|
||||
int pages = end / 9 + (end % 9 > 0 ? 1 : 0);
|
||||
|
||||
charge(sender);
|
||||
sender.sendMessage("Page §c" + page + "§f of §c" + pages + "§f:");
|
||||
for (int i = start; i < end && i < start + 9; i++)
|
||||
{
|
||||
|
@ -108,9 +123,10 @@ public class Commandinfo extends EssentialsCommand {
|
|||
return;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
int chapterpage = 0;
|
||||
if (args.length >= 2) {
|
||||
if (args.length >= 2)
|
||||
{
|
||||
try
|
||||
{
|
||||
chapterpage = Integer.parseInt(args[1]) - 1;
|
||||
|
@ -120,8 +136,9 @@ public class Commandinfo extends EssentialsCommand {
|
|||
chapterpage = 0;
|
||||
}
|
||||
}
|
||||
|
||||
if (!bookmarks.containsKey(pageStr.toLowerCase())) {
|
||||
|
||||
if (!bookmarks.containsKey(pageStr.toLowerCase()))
|
||||
{
|
||||
sender.sendMessage("Unknown chapter.");
|
||||
return;
|
||||
}
|
||||
|
@ -130,7 +147,8 @@ public class Commandinfo extends EssentialsCommand {
|
|||
for (chapterend = chapterstart; chapterend < lines.size(); chapterend++)
|
||||
{
|
||||
String line = lines.get(chapterend);
|
||||
if (line.startsWith("#")) {
|
||||
if (line.startsWith("#"))
|
||||
{
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
@ -138,7 +156,8 @@ public class Commandinfo extends EssentialsCommand {
|
|||
int page = chapterpage + 1;
|
||||
int pages = (chapterend - chapterstart) / 9 + ((chapterend - chapterstart) % 9 > 0 ? 1 : 0);
|
||||
|
||||
sender.sendMessage("Chapter "+ pageStr +", page §c" + page + "§f of §c" + pages + "§f:");
|
||||
charge(sender);
|
||||
sender.sendMessage("Chapter " + pageStr + ", page §c" + page + "§f of §c" + pages + "§f:");
|
||||
for (int i = start; i < chapterend && i < start + 9; i++)
|
||||
{
|
||||
sender.sendMessage(lines.get(i));
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue