NOTE FROM MATTSTER: I haven't actually tried this out so I don't know if it works or not.
Purpose: Load data about player rights from a file.
You need a file to store the mod and admin data in. I called mine mods.cfg. This is more practical than recompiling and restarting the server every time you add a new moderator.
This is some pretty old code I wrote when I didn't really know much about programming, so it's pretty crappy. But it works. I'll fix it up when I have the time.
The rest of this tutorial will be the same as the one I posted back in August 2006. I'll refine it later.
Procedure
Display All
You'll then need to add the mod file reader in the login procedure.
Find the last connection.
After it, add the file reader for the player's name.
This will automatically make someone who is a moderator a moderator on login.
You could even add a command so that a user could refresh their rights without even logging out and in. You would do something like this, and put it in the customCommand m
A user would just type ::newmods to have the server check if they're supposed to be a mod and then make them one if they are.
Step 2: Usage.
You need to organize your Mods.cfg like this.
3 is a server owner, 1 is a silver mod, and 2 is a gold mod. You could even add a 0 to make sure a player never becomes a moderator. For that you'd add this to the end.
This ensures that the player somenoob will never become a mod unless you decide to change it.
Credits: Aftermath_96
Purpose: Load data about player rights from a file.
You need a file to store the mod and admin data in. I called mine mods.cfg. This is more practical than recompiling and restarting the server every time you add a new moderator.
This is some pretty old code I wrote when I didn't really know much about programming, so it's pretty crappy. But it works. I'll fix it up when I have the time.
The rest of this tutorial will be the same as the one I posted back in August 2006. I'll refine it later.
Procedure
Source Code
- public boolean loadMods(String FileName, String PName)
- {
- String line = "";
- String token = "";
- String token2 = "";
- String token2_2 = "";
- String[] token3 = new String[10];
- boolean EndOfFile = false;
- int ReadMode = 0;
- BufferedReader characterfile = null;
- try
- {
- characterfile = new BufferedReader(new FileReader("./"+FileName));
- }
- catch(FileNotFoundException fileex)
- {
- misc.println(FileName+": file not found.");
- return false;
- }
- try
- {
- line = characterfile.readLine();
- }
- catch(IOException ioexception)
- {
- misc.println(FileName+": error loading file.");
- return false;
- }
- while(EndOfFile == false && line != null)
- {
- line = line.trim();
- int spot = line.indexOf("=");
- if (spot > -1)
- {
- token = line.substring(0, spot);
- token = token.trim();
- token2 = line.substring(spot + 1);
- token2 = token2.trim();
- token2_2 = token2.replaceAll("\t\t", "\t"); //X5
- token3 = token2_2.split("\t");
- if (token.equalsIgnoreCase(PName))
- {
- playerRights = Integer.parseInt(token3[0]);
- }
- }
- else
- {
- if (line.equals("[ENDOFMODS]"))
- {
- try
- {
- characterfile.close();
- }
- catch(IOException ioexception) { }
- return true;
- }
- }
- try
- {
- line = characterfile.readLine();
- }
- catch(IOException ioexception1)
- {
- EndOfFile = true;
- }
- }
- try
- {
- characterfile.close();
- }
- catch(IOException ioexception) { }
- return false;
- }
You'll then need to add the mod file reader in the login procedure.
Find the last connection.
After it, add the file reader for the player's name.
This will automatically make someone who is a moderator a moderator on login.
You could even add a command so that a user could refresh their rights without even logging out and in. You would do something like this, and put it in the customCommand m
A user would just type ::newmods to have the server check if they're supposed to be a mod and then make them one if they are.
Step 2: Usage.
You need to organize your Mods.cfg like this.
3 is a server owner, 1 is a silver mod, and 2 is a gold mod. You could even add a 0 to make sure a player never becomes a moderator. For that you'd add this to the end.
This ensures that the player somenoob will never become a mod unless you decide to change it.
Credits: Aftermath_96