Last active
August 29, 2015 13:56
-
-
Save MrMb2013/9059641 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
package mrmb2013.pixel; | |
import java.io.PrintStream; | |
import org.bukkit.Server; | |
import org.bukkit.plugin.PluginManager; | |
import org.bukkit.plugin.java.JavaPlugin; | |
public class pixel extends JavaPlugin | |
{ | |
public void onEnable() | |
{ | |
System.out.println("[Pixel] Enable"); | |
PluginManager pm = getServer().getPluginManager(); | |
pm.registerEvents(new PlayerCommand(this), this); | |
} | |
public void onDisable() | |
{ | |
System.out.println("[Pixel] Disable"); | |
} | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
package mrmb2013.pixel; | |
import org.bukkit.ChatColor; | |
import org.bukkit.entity.Player; | |
import org.bukkit.event.EventHandler; | |
import org.bukkit.event.EventPriority; | |
import org.bukkit.event.Listener; | |
import org.bukkit.event.player.PlayerCommandPreprocessEvent; | |
import org.bukkit.plugin.Plugin; | |
public class PlayerCommand | |
implements Listener | |
{ | |
Plugin plugin; | |
public PlayerCommand(pixel pixel) | |
{ | |
this.plugin = pixel; | |
} | |
@EventHandler(priority=EventPriority.LOWEST) | |
public void onPlayerCommand(PlayerCommandPreprocessEvent e) | |
{ | |
Player p = e.getPlayer(); | |
String msg = e.getMessage(); | |
String[] args = msg.split(" "); | |
if (args[0].equalsIgnoreCase("/pixel")) { | |
e.setCancelled(true); | |
if (args.length == 1) { | |
p.sendMessage(ChatColor.RED + "Wrong usage ! /pixel help "); | |
} | |
if (args[1].equalsIgnoreCase("help")) { | |
p.sendMessage(ChatColor.GOLD + "======= " + ChatColor.AQUA + "Pixel Help" + ChatColor.GOLD + " ======="); | |
p.sendMessage(ChatColor.GOLD + "/pixel shop"); | |
p.sendMessage(ChatColor.GOLD + "/pixel me"); | |
p.sendMessage(ChatColor.GOLD + "/pixel remove"); | |
p.sendMessage(ChatColor.GOLD + "/pixel buy"); | |
p.sendMessage(ChatColor.GOLD + "/pixel give"); | |
p.sendMessage(ChatColor.GOLD + "=========================="); | |
} else if (args[1].equalsIgnoreCase("shop")) { | |
p.sendMessage(ChatColor.RED + "The shop is coming soon !"); | |
} else if (args[1].equalsIgnoreCase("me")) { | |
p.sendMessage(ChatColor.AQUA + "You have " + ChatColor.YELLOW + "0 " + ChatColor.AQUA + "pixel(s)"); | |
} else if (args[1].equalsIgnoreCase("give")) { | |
if (p.isOp()) | |
p.sendMessage(ChatColor.RED + "Usage : /pixel give [player] <amount>"); | |
else | |
p.sendMessage(ChatColor.RED + "You don't have access to this command."); | |
} | |
else if (args[1].equalsIgnoreCase("remove")) { | |
if (p.isOp()) | |
p.sendMessage(ChatColor.RED + "Usage : /pixel remove [player] <amount>"); | |
else | |
p.sendMessage(ChatColor.RED + "You don't have access to this command."); | |
} | |
else if (args[1].equalsIgnoreCase("buy")) { | |
p.sendMessage(ChatColor.RED + "The shop is coming soon !"); | |
} | |
else { | |
p.sendMessage(ChatColor.RED + "Invalid command ! /pixel help"); | |
} | |
} | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment