Skip to content

Commit

Permalink
Merge pull request #2 from insou22/master
Browse files Browse the repository at this point in the history
This is at least a start. Pleb.
  • Loading branch information
LaxWasHere committed Apr 18, 2016
2 parents 2be72d6 + 6450d1b commit cb2f3a1
Show file tree
Hide file tree
Showing 17 changed files with 463 additions and 225 deletions.
60 changes: 28 additions & 32 deletions src/main/java/net/poweredbyhate/trollplus/TrollPlus.java
Original file line number Diff line number Diff line change
@@ -1,51 +1,47 @@
package net.poweredbyhate.trollplus;

import net.poweredbyhate.trollplus.Trolls.CommandBolt;
import net.poweredbyhate.trollplus.Trolls.CommandBurn;
import net.poweredbyhate.trollplus.Trolls.CommandFakeop;
import net.poweredbyhate.trollplus.Trolls.CommandFreeze;
import net.poweredbyhate.trollplus.Trolls.CommandJarcode;
import net.poweredbyhate.trollplus.listeners.PlayerListener;
import net.poweredbyhate.trollplus.managers.CommandManager;
import net.poweredbyhate.trollplus.managers.TrollPlayerManager;
import org.bukkit.Bukkit;
import org.bukkit.ChatColor;
import org.bukkit.event.EventHandler;
import org.bukkit.event.Listener;
import org.bukkit.event.player.PlayerJoinEvent;
import org.bukkit.plugin.java.JavaPlugin;

/**
* Created by Lax on 4/18/2016.
*/
public class TrollPlus extends JavaPlugin implements Listener{
public class TrollPlus extends JavaPlugin {

private final Listener[] listeners = {
new PlayerListener(this)
};

private TrollPlayerManager playerManager;
private CommandManager commandManager;

@Override // You better annotate every bloody override or I will end you.
public void onEnable() {
Bukkit.getPluginManager().registerEvents(this, this);
enableCommands(); //List of commands to make: http://q.awsmpwrd.com/iVZx.png
loadManagers();
loadListeners();
//List of command to make: http://q.awsmpwrd.com/iVZx.png
}

public void enableCommands() {
getCommand("burn").setExecutor(new CommandBurn(this));
getCommand("freeze").setExecutor(new CommandFreeze(this));
getCommand("bolt").setExecutor(new CommandBolt(this));
//getCommand("special").setExecutor(new CommandSpecial(this)); I have yet to check what a fucking AK-47 is.
getCommand("fakeop").setExecutor(new CommandFakeop(this)); //not done
getCommand("jarcode").setExecutor(new CommandJarcode(this));
private void loadManagers() {
playerManager = new TrollPlayerManager(this);
commandManager = new CommandManager(this);
}

String[] ad = {
"&d____----====[ &cSponsored by GNU/Emacs&d ]====----____",
"&aGet emacs for your linux distro now!",
"&bhttps://www.gnu.org/software/emacs/",

"&aThis troll plugin is sponsored by Emacs!",
"&aEmacs is the one true editor that respects your software freedoms",
" "
};
private void loadListeners() {
for (Listener listener : listeners) {
Bukkit.getPluginManager().registerEvents(listener, this);
}
}

public TrollPlayerManager getPlayerManager() {
return playerManager;
}

@EventHandler
public void onJoin(PlayerJoinEvent ev) {
for (String s : ad) {
ev.getPlayer().sendMessage(ChatColor.translateAlternateColorCodes('&', s));
}
public CommandManager getCommandManager() {
return commandManager;
}
}
37 changes: 0 additions & 37 deletions src/main/java/net/poweredbyhate/trollplus/Trolls/CommandBolt.java

This file was deleted.

34 changes: 0 additions & 34 deletions src/main/java/net/poweredbyhate/trollplus/Trolls/CommandBurn.java

This file was deleted.

This file was deleted.

This file was deleted.

This file was deleted.

Original file line number Diff line number Diff line change
@@ -0,0 +1,41 @@
package net.poweredbyhate.trollplus.command;

import net.poweredbyhate.trollplus.TrollPlus;
import net.poweredbyhate.trollplus.player.TrollPlayer;
import org.bukkit.ChatColor;
import org.bukkit.command.Command;
import org.bukkit.command.CommandExecutor;
import org.bukkit.command.CommandSender;
import org.bukkit.entity.Player;

public abstract class CommandConsumer implements CommandExecutor {

protected final TrollPlus plugin;

protected CommandConsumer(TrollPlus plugin) {
this.plugin = plugin;
}

@Override
public boolean onCommand(CommandSender sender, Command command, String label, String[] args) {
if (!(sender instanceof Player)) {
// Commands can only be executed by Players because fuck the console
sender.sendMessage(ChatColor.RED + "Are ye serious mate? Too stingy to log on to the bloody server are ya?");
sender.sendMessage(ChatColor.RED + "You can take your bloody console and piss right off mate.");
return false;
}
TrollPlayer player = plugin.getPlayerManager().getPlayer((Player) sender);
onCommand(player, label, args);
return false;
}

// Only use label to resend the command to the player, no checks are needed
protected abstract void onCommand(TrollPlayer player, String label, String[] args);

public abstract String getCommand();

protected void noPermz(TrollPlayer player) {
player.sendMessage("&cNo Permz");
}

}
Original file line number Diff line number Diff line change
@@ -0,0 +1,44 @@
package net.poweredbyhate.trollplus.command.trolls;

import net.poweredbyhate.trollplus.TrollPlus;
import net.poweredbyhate.trollplus.command.CommandConsumer;
import net.poweredbyhate.trollplus.player.TrollPlayer;
import org.bukkit.Bukkit;
import org.bukkit.entity.Player;

/**
* Created by Lax on 4/18/2016.
*/
public class BoltTrollCommand extends CommandConsumer {

public BoltTrollCommand(TrollPlus plugin) {
super(plugin);
}

@Override
protected void onCommand(TrollPlayer player, String label, String[] args) {
if (!player.hasPermissionOrIsOp("trollplus.bolt")) {
noPermz(player);
return;
}
if (args.length == 0) {
player.getPlayer().getLocation().getWorld().strikeLightningEffect(player.getPlayer().getLocation());
return;
}
if (!player.hasPermissionOrIsOp("trollplus.bolt.others")) {
noPermz(player);
return;
}
Player target = Bukkit.getPlayer(args[0]);
if (target == null) {
player.sendMessage("&cUsage: /" + label + " [player]");
return;
}
target.getLocation().getWorld().strikeLightningEffect(target.getLocation());
}

@Override
public String getCommand() {
return "bolt";
}
}
Loading

0 comments on commit cb2f3a1

Please sign in to comment.