Hey! Im here to give you better PI commands. Enjoy!
::item
Code:
if (playerCommand.startsWith("item")) {
if (c.inWild()) {//checks if in wild
c.sendMessage("HEY! " +(c.playerName).toUpperCase()+ "!!!! Please leave the wilderness and spawn your item, Nub");
return;
}
try {//if not in wild and the rights level is above 3 (depending in what section of rights you put this in)
String[] args = playerCommand.split(" ");
if (args.length == 3) {
int newItemID = Integer.parseInt(args[1]);//item id
int newItemAmount = Integer.parseInt(args[2]);//item amount
if ((newItemID <= 20000) && (newItemID >= 0)) {
c.getItems().addItem(newItemID, newItemAmount);
System.out.println("Spawned: " + newItemID + " by: " + c.playerName);//console print
String item = Server.itemHandler.getItemList(newItemID).itemName;//this will make the id into a name :O
if (newItemAmount > 1) {//if the amount of items is over 1, will make it plural
c.sendMessage(c.playerName+ " Spawned " +newItemAmount+ " " +item+"'s ID: "+newItemID);
}
else {//if just 1 item spawned will make it not a plural
c.sendMessage(c.playerName+ " Spawned " +newItemAmount+ " " +item+" ID: "+newItemID);
}
} else {//if the item doesnt exist
c.sendMessage("No such item.");
}
} else {//if you used the command in the wrong context
c.sendMessage("Use as ::item 995 200");
}
} catch (Exception e) {//catch exception
e.printStackTrace();
}
}
:pawn (for spawning npc's),
here is why i am replacing the current ::npc with this, this one will write to your spawn-config.cfg, so it will be perm and you will keep after you shutdown your server, change spawn-config.cfg with what ever npc .cfg file you have
Code:
if (playerCommand.startsWith("spawn"))
{
try//will try this, if failed will go to catch IOException
{
String[] args = playerCommand.split(" ");
int spawnedNPC = Integer.parseInt(args[1]);//the npc spawned int
FileWriter fstream = new FileWriter("data\\cfg\\spawn-config.cfg", true);//replace the file address in there with what ever you want
BufferedWriter out = new BufferedWriter(fstream);
out.newLine();//just a bunch of writing stuff
out.write("spawn = ");
out.write(spawnedNPC + "\t");
out.write(c.absX + "\t");
out.write(c.absY + "\t");
out.write(c.heightLevel + "\t");
out.write("1\t");
String npcName = Server.npcHandler.getNpcListName(spawnedNPC).replaceAll("_", " ");
out.write("0\t0\t0\t" + npcName);
out.close();
c.sendMessage("Saved npc "+ spawnedNPC + " (" + npcName + ") at x:" + c.absX + " y: " + c.absY + " h: " + c.heightLevel + ".");
Server.npcHandler.spawnNpc(c, spawnedNPC, c.absX, c.absY, c.heightLevel, 0, 0, 0, 0, 0, false, false);
}
catch (IOException e) {
c.sendMessage("Failed to write to file.");
}
}
::bank (you dont need a picture for this lol)
Code:
if (playerCommand.equalsIgnoreCase("bank")) {
c.getPA().openUpBank();
}
::xteleto
Code:
if (playerCommand.startsWith("xteleto")) {
String name = playerCommand.substring(8);
for (int i = 0; i < Config.MAX_PLAYERS; i++) {
if (Server.playerHandler.players[i] != null) {
if (Server.playerHandler.players[i].playerName.equalsIgnoreCase(name)) {
c.getPA().movePlayer(Server.playerHandler.players[i].getX() + 1, Server.playerHandler.players[i].getY(), Server.playerHandler.players[i].heightLevel);
c.sendMessage("You have teleported to "+name);
}
}
}
}
::yell
Code:
if (playerCommand.startsWith("yell")) {
int minYellRight = 1;
String m = "";
String pRank = "";
int playerRight = c.playerRights;
for (int j = 0; j < Server.playerHandler.players.length; j++) {
if (playerRight >= minYellRight) {
if (Server.playerHandler.players[j] != null) {
if (Connection.isMuted(c)) {
c.sendMessage("You cannot yell you are muted.");
}
else {
Client all = (Client)Server.playerHandler.players[j];
String pN = c.playerName;
if (minYellRight == 1) {
m = "Moderator";
}
if (minYellRight == 2) {
m = "Administrator";
}
if (minYellRight == 3) {
m = "Owner";
}
if (minYellRight == 0) {
m = "Player";
}
if (c.playerRights == 1) {
pRank = "Moderator";
}
if (c.playerRights == 2) {
pRank = "Administrator";
}
if (c.playerRights == 3) {
pRank = "Owner";
}
if (c.playerRights == 0) {
pRank = "Player";
}
all.sendMessage("@bla@[@red@"+pRank.toUpperCase()+"@blu@ "+pN+"@bla@]: "+Misc.optimizeText(playerCommand.substring(5)));
}
}
}
if (playerRight < minYellRight) {
if (minYellRight == 1) {
m = "Moderator";
}
if (minYellRight == 2) {
m = "Administrator";
}
if (minYellRight == 3) {
m = "Owner";
}
if (minYellRight == 0) {
m = "Player";
}
c.sendMessage("@red@You are not the correct rank to yell! The min rank to yell is: "+m);
break;
}
}
}
ENJOY THESE COMMANDS!
- S C A P E (Oscar)