Newbie Spellweaver
- Joined
- Dec 27, 2015
- Messages
- 11
- Reaction score
- 8
I did some changes in ChangePlayerColorAdminCommand.java.. Now, if you put /adm player color crazy, you get a random color in your name.. just for fun!
Source I'm using: https://forum.ragezone.com/f904/release-updated-database-project-blackout-1072030/
ChangePlayerColorAdminCommand.java (ru.pb.game.chat.commands):
Screenshot:
@UPDATE
Some update.. I forgot to finish the timer when I do command again :glare:
@UPDATE 2
initialize the timer every time the command is called
Source I'm using: https://forum.ragezone.com/f904/release-updated-database-project-blackout-1072030/
ChangePlayerColorAdminCommand.java (ru.pb.game.chat.commands):
Code:
package ru.pb.game.chat.commands;
import java.util.Random;
import java.util.Timer;
import java.util.TimerTask;
import ru.pb.game.network.client.ClientConnection;
public class ChangePlayerColorAdminCommand implements BaseCommand {
private ClientConnection cnn;
private Timer timer;
class CrazyColor extends TimerTask {
public void run() {
Random rnd = new Random();
cnn.getPlayer().setColor( Byte.valueOf( String.valueOf( rnd.nextInt(10) + 1) ) );
}
}
@Override
public String call(ClientConnection connection, String message) {
try {
if(message.equals("crazy")){ //command crazy
cnn = connection;
timer = new Timer();
timer.schedule(new CrazyColor(), 0, 1000);
}else {
try{
timer.cancel();
}catch(Exception e){
//nothing to cancel xD
}
connection.getPlayer().setColor(Byte.valueOf(message));
}
return "Change color for player [" + connection.getPlayer().getName() + "]";
} catch (Exception e) {
return "Command syntax : /adm player color [0-11] or 'crazy'.";
}
}
@Override
public String getPrefix() {
return "player color";
}
}
Screenshot:
You must be registered to see links
@UPDATE
Some update.. I forgot to finish the timer when I do command again :glare:
@UPDATE 2
initialize the timer every time the command is called
Last edited: