Skip to content

Commit

Permalink
Implemented MotD command
Browse files Browse the repository at this point in the history
Needs testing!

Signed-off-by: Grafe <[email protected]>
  • Loading branch information
Grafe committed May 2, 2013
1 parent 0b12997 commit f1c243a
Show file tree
Hide file tree
Showing 6 changed files with 87 additions and 8 deletions.
7 changes: 6 additions & 1 deletion plugin.yml
Original file line number Diff line number Diff line change
Expand Up @@ -25,4 +25,9 @@ commands:
description: Set the GameMode of a player
invisible:
aliases: [inv]
description: Set the visibility of a player
description: Set the visibility of a player
motd:
description: Show the MotD of the server
motdset:
aliases: [motds]
description: Set the MotD of the server
14 changes: 12 additions & 2 deletions src/com/dre/managerxl/P.java
Original file line number Diff line number Diff line change
Expand Up @@ -14,16 +14,21 @@

import com.dre.managerxl.commands.MCommand;
import com.dre.managerxl.listeners.PlayerListener;
import com.dre.managerxl.listeners.ServerListener;

public class P extends JavaPlugin{
public static P p;

//Language Reader
/* Language Reader */
private LanguageReader languageReader;
public LanguageReader getLanguageReader(){
return languageReader;
}

/* MotD */
private String motd = "";
public String getMotD() { return this.motd; }
public void setMotD(String motd) { this.motd = motd; }

@Override
public void onEnable(){
Expand All @@ -35,8 +40,9 @@ public void onEnable(){
//Setup Permissions
setupPermissions();

// Init Listeners
//Init Listeners
Bukkit.getPluginManager().registerEvents(new PlayerListener(), this);
Bukkit.getPluginManager().registerEvents(new ServerListener(), this);

//Setup Commands
MCommand.initCommands();
Expand All @@ -62,11 +68,15 @@ public void SaveAll(){
}

public void LoadAll(){
//Players
if(MPlayer.LoadAsYml(new File(this.getDataFolder(), "players.yml"))){
P.p.log(getLanguageReader().get("Log_PlayersLoaded"));
} else {
P.p.log(Level.WARNING, getLanguageReader().get("Log_Error_PlayersLoaded"));
}

//MotD
motd = Bukkit.getMotd();
}

//Msg
Expand Down
8 changes: 7 additions & 1 deletion src/com/dre/managerxl/commands/MCommand.java
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,8 @@
import org.bukkit.entity.Player;

import com.dre.managerxl.P;
import com.dre.managerxl.commands.managing.MotD;
import com.dre.managerxl.commands.managing.MotDSet;
import com.dre.managerxl.commands.player.Ban;
import com.dre.managerxl.commands.player.GameMode;
import com.dre.managerxl.commands.player.Home;
Expand Down Expand Up @@ -74,7 +76,11 @@ public void displayHelp(CommandSender sender){
//Static
public static void initCommands(){

// PlayerCommands
//Managing commands
new MotD();
new MotDSet();

//Player commands
new Ban();
new Unban();
new TimeBan();
Expand Down
25 changes: 23 additions & 2 deletions src/com/dre/managerxl/commands/managing/MotD.java
Original file line number Diff line number Diff line change
@@ -1,5 +1,26 @@
package com.dre.managerxl.commands.managing;

public class MotD {
//TODO: Implement Command
import org.bukkit.command.CommandSender;

import com.dre.managerxl.P;
import com.dre.managerxl.commands.MCommand;

public class MotD extends MCommand{

public MotD(){
this.command = "motd";
this.parrent = null;
this.help = P.p.getLanguageReader().get("Help_MotD");
this.permission = "mxl.cmd.managing.motd";

this.isConsoleCommand = true;
this.isPlayerCommand = true;

this.init();
}

@Override
public void onExecute(String[] args, CommandSender sender) {
P.p.msg(sender, P.p.getMotD());
}
}
25 changes: 23 additions & 2 deletions src/com/dre/managerxl/commands/managing/MotDSet.java
Original file line number Diff line number Diff line change
@@ -1,6 +1,27 @@
package com.dre.managerxl.commands.managing;

public class MotDSet {
//TODO: Implement Command
import org.bukkit.command.CommandSender;

import com.dre.managerxl.P;
import com.dre.managerxl.commands.MCommand;
import com.dre.managerxl.util.MUtility;

public class MotDSet extends MCommand{
public MotDSet(){
this.command = "motdset";
this.parrent = null;
this.help = P.p.getLanguageReader().get("Help_MotDSet");
this.permission = "mxl.cmd.managing.motdset";

this.isConsoleCommand = true;
this.isPlayerCommand = true;

this.init();
}

@Override
public void onExecute(String[] args, CommandSender sender) {
P.p.setMotD(P.p.replaceColors(MUtility.parseMessage(args, 0)));
P.p.msg(sender, P.p.getLanguageReader().get("Cmd_MotDSet_Success"));
}
}
16 changes: 16 additions & 0 deletions src/com/dre/managerxl/listeners/ServerListener.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
package com.dre.managerxl.listeners;

import org.bukkit.event.EventHandler;
import org.bukkit.event.Listener;
import org.bukkit.event.server.ServerListPingEvent;

import com.dre.managerxl.P;

public class ServerListener implements Listener{

@EventHandler()
public void onServerListPing(ServerListPingEvent event){
/* Set MotD */
event.setMotd(P.p.getMotD());
}
}

0 comments on commit f1c243a

Please sign in to comment.