mirror of
https://github.com/PaperMC/Paper.git
synced 2024-12-28 07:20:24 +01:00
forgotten FillrListener
By: Taylor Kelly <tkelly910@gmail.com>
This commit is contained in:
parent
38b76fb99e
commit
b706c19913
2 changed files with 46 additions and 23 deletions
|
@ -1,13 +1,11 @@
|
||||||
package org.bukkit.fillr;
|
package org.bukkit.fillr;
|
||||||
|
|
||||||
import org.bukkit.*;
|
import org.bukkit.*;
|
||||||
import org.bukkit.event.player.PlayerChatEvent;
|
|
||||||
import org.bukkit.plugin.*;
|
import org.bukkit.plugin.*;
|
||||||
import org.bukkit.plugin.java.*;
|
import org.bukkit.plugin.java.*;
|
||||||
import org.bukkit.event.*;
|
import org.bukkit.event.*;
|
||||||
|
|
||||||
import java.io.File;
|
import java.io.File;
|
||||||
import org.bukkit.event.player.PlayerListener;
|
|
||||||
|
|
||||||
public class Fillr extends JavaPlugin {
|
public class Fillr extends JavaPlugin {
|
||||||
private FillrListener listener;
|
private FillrListener listener;
|
||||||
|
@ -24,27 +22,7 @@ public class Fillr extends JavaPlugin {
|
||||||
public void onEnable() {}
|
public void onEnable() {}
|
||||||
|
|
||||||
private void registerEvents() {
|
private void registerEvents() {
|
||||||
listener = new FillrListener();
|
listener = new FillrListener(getServer());
|
||||||
getServer().getPluginManager().registerEvent(Event.Type.PLAYER_COMMAND, listener, Event.Priority.Normal, this);
|
getServer().getPluginManager().registerEvent(Event.Type.PLAYER_COMMAND, listener, Event.Priority.Normal, this);
|
||||||
}
|
}
|
||||||
|
|
||||||
private class FillrListener extends PlayerListener {
|
|
||||||
@Override
|
|
||||||
public void onPlayerCommand(PlayerChatEvent event) {
|
|
||||||
if (!event.isCancelled()) {
|
|
||||||
String[] split = event.getMessage().split(" ", 2);
|
|
||||||
|
|
||||||
if (split[0].equalsIgnoreCase("/get")) {
|
|
||||||
if (split.length == 2) {
|
|
||||||
Getter getter = new Getter(getServer());
|
|
||||||
getter.get(split[1], event.getPlayer());
|
|
||||||
} else {
|
|
||||||
event.getPlayer().sendMessage("Usage: /get (Plugin Name)");
|
|
||||||
}
|
|
||||||
|
|
||||||
event.setCancelled(true);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
45
paper-api/src/main/java/org/bukkit/fillr/FillrListener.java
Normal file
45
paper-api/src/main/java/org/bukkit/fillr/FillrListener.java
Normal file
|
@ -0,0 +1,45 @@
|
||||||
|
package org.bukkit.fillr;
|
||||||
|
|
||||||
|
import org.bukkit.*;
|
||||||
|
import org.bukkit.event.player.*;
|
||||||
|
|
||||||
|
public class FillrListener extends PlayerListener {
|
||||||
|
|
||||||
|
private final Server server;
|
||||||
|
|
||||||
|
public FillrListener(Server server) {
|
||||||
|
this.server = server;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void onPlayerCommand(PlayerChatEvent event) {
|
||||||
|
String[] split = event.getMessage().split(" ");
|
||||||
|
Player player = event.getPlayer();
|
||||||
|
|
||||||
|
if (split[0].equalsIgnoreCase("/check")) {
|
||||||
|
new Checker().check(player);
|
||||||
|
event.setCancelled(true);
|
||||||
|
} else if (split[0].equalsIgnoreCase("/updateAll")) {
|
||||||
|
new Updater(server).updateAll(player);
|
||||||
|
event.setCancelled(true);
|
||||||
|
} else if (split[0].equalsIgnoreCase("/update")) {
|
||||||
|
if (split.length == 1) {
|
||||||
|
player.sendMessage("Usage is /update <name>");
|
||||||
|
} else {
|
||||||
|
new Updater(server).update(split[1], player);
|
||||||
|
}
|
||||||
|
event.setCancelled(true);
|
||||||
|
} else if (split[0].equalsIgnoreCase("/get")) {
|
||||||
|
if (split.length == 1) {
|
||||||
|
player.sendMessage("Usage is /get <name>");
|
||||||
|
} else {
|
||||||
|
try {
|
||||||
|
new Getter(server).get(split[1], player);
|
||||||
|
} catch (Exception e) {
|
||||||
|
player.sendMessage("There was an error downloading "
|
||||||
|
+ split[1]);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
event.setCancelled(true);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
Loading…
Reference in a new issue