Guest User

Plugin

a guest
Jun 26th, 2013
130
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 4.62 KB | None | 0 0
  1. ----------------------------------------------------------------------------------------------------------------
  2. Plugin.java
  3. ----------------------------------------------------------------------------------------------------------------
  4. package me.D3monicSheep.Plugin;
  5.  
  6. import java.util.logging.Logger;
  7.  
  8. import org.bukkit.command.CommandSender;
  9. import org.bukkit.entity.Player;
  10. import org.bukkit.material.Command;
  11. import org.bukkit.plugin.PluginManager;
  12. import org.bukkit.plugin.java.JavaPlugin;
  13. import org.bukkit.potion.PotionEffect;
  14. import org.bukkit.potion.PotionEffectType;
  15.  
  16. public class Plugin extends JavaPlugin {
  17. public static Plugin plugin;
  18. public final Logger logger = Logger.getLogger("Minecraft");
  19. public final PluginListener pl = new PluginListener(this);
  20. public final PluginLogger plo = new PluginLogger(this);
  21.  
  22. public void onEnable() {
  23. plo.enabled(true);
  24. PluginManager pm = this.getServer().getPluginManager();
  25. pm.registerEvents(pl, this);
  26. }
  27.  
  28. public void onDisable() {
  29. plo.enabled(false);
  30. }
  31.  
  32. public boolean onCommand1(CommandSender sender, Command cmd,
  33. String commandLabel, String[] args) {
  34. if (commandLabel.equalsIgnoreCase("potion speed")) {
  35. Player player = (Player) sender;
  36. player.addPotionEffect(new PotionEffect(PotionEffectType.SPEED,
  37. -1, 3));
  38. }
  39. return false;
  40.  
  41. }
  42.  
  43. public boolean onCommand(CommandSender sender, Command cmd,
  44. String commandLabel, String[] args) {
  45. if (commandLabel.equalsIgnoreCase("potion blindness")) {
  46. Player player = (Player) sender;
  47. player.addPotionEffect(new PotionEffect(PotionEffectType.BLINDNESS,
  48. -1, 3));
  49.  
  50. }
  51. return false;
  52. }
  53. }
  54.  
  55.  
  56.  
  57. ----------------------------------------------------------------------------------------------------------------------
  58. PluginListeners.java
  59. ----------------------------------------------------------------------------------------------------------------------
  60. package me.D3monicSheep.Plugin;
  61.  
  62. import org.bukkit.entity.Player;
  63. import org.bukkit.event.Listener;
  64. import org.bukkit.event.player.PlayerChatEvent;
  65. import org.bukkit.potion.PotionEffect;
  66. import org.bukkit.potion.PotionEffectType;
  67.  
  68. @SuppressWarnings("deprecation")
  69. public class PluginListener implements Listener{
  70.  
  71.  
  72. public PluginListener(Plugin plugin) {
  73. // TODO Auto-generated constructor stub
  74. }
  75.  
  76. public void onPlayerCommand(PlayerChatEvent event) {
  77. String[] split = event.getMessage().split(" ");
  78. //Get Player that talked
  79. Player player = event.getPlayer();
  80. if ((split[0].equalsIgnoreCase("potion speed"))
  81. || (split[0].equalsIgnoreCase("p speed")))
  82. player.addPotionEffect(new PotionEffect(PotionEffectType.SPEED,
  83. -1, 3));
  84.  
  85. }
  86.  
  87. public void onPlayerCommand1(PlayerChatEvent event) {
  88. String[] split = event.getMessage().split(" ");
  89. //Get Player that talked
  90. Player player = event.getPlayer();
  91. if ((split[0].equalsIgnoreCase("potion blind"))
  92. || (split[0].equalsIgnoreCase("p blind")))
  93. player.addPotionEffect(new PotionEffect(PotionEffectType.BLINDNESS,
  94. -1, 3));
  95.  
  96. }
  97.  
  98. }
  99.  
  100.  
  101.  
  102. -------------------------------------------------------------------------------------------------------------------
  103. PluginLoggers.java
  104. -------------------------------------------------------------------------------------------------------------------
  105. package me.D3monicSheep.Plugin;
  106.  
  107. import java.util.logging.Logger;
  108.  
  109. import org.bukkit.plugin.PluginDescriptionFile;
  110.  
  111. public class PluginLogger {
  112.  
  113. public static Plugin plugin;
  114.  
  115. public PluginLogger(Plugin instance){
  116. plugin = instance;
  117. }
  118.  
  119. public final Logger logger = Logger.getLogger("Minecraft");
  120.  
  121. public void enabled(boolean enabled){
  122. if(enabled){
  123. PluginDescriptionFile pdfFile = plugin.getDescription();
  124. this.logger.info(pdfFile.getName() + " Version " + pdfFile.getVersion() + " Has Been Enabled");
  125. } else {
  126. PluginDescriptionFile pdfFile = plugin.getDescription();
  127. this.logger.info(pdfFile.getName() + " Version " + pdfFile.getVersion() + " Has Been Disabled");
  128. }
  129. }
  130.  
  131. }
  132.  
  133.  
  134.  
  135. -------------------------------------------------------------------------------------------------------------------
  136. Plugin.yml
  137. -------------------------------------------------------------------------------------------------------------------
  138. name: SCTest
  139. main: me.D3monicSheep.Plugin.Plugin
  140. version: 0.1
  141. author: D3monicSheep
  142. description: A squad craft test plug-in that gives players swiftness 3.
  143.  
  144. commands:
  145. potion speed:
  146. description: Gives players swiftness 3
  147. usage: /<command>
  148. aliases: [p speed]
  149. potion blind:
  150. description: Gives player blindness 3
  151. usage: /<command>
  152. aliases: [p blind]
Advertisement
Add Comment
Please, Sign In to add comment