use of xyz.derkades.ublisk.utils.URunnable in project Ublisk by Derkades.
the class PlayerInteract method staffTool.
@SuppressWarnings("deprecation")
@EventHandler(priority = EventPriority.LOW)
public void staffTool(PlayerInteractEvent event) {
ItemStack itemInHand = event.getPlayer().getInventory().getItemInMainHand();
if (itemInHand.getType() != Material.COAL_ORE || event.getAction() != Action.RIGHT_CLICK_BLOCK) {
return;
}
Player player = event.getPlayer();
String itemName = itemInHand.getItemMeta().getDisplayName();
final Block block = event.getClickedBlock();
event.setCancelled(true);
if (itemName == null) {
sendStaffToolInfoMessage(player);
return;
}
if (itemName.contains("farmland")) {
block.setType(Material.SOIL);
block.setData((byte) 7);
Location loc = block.getLocation();
Block wheat = new Location(Var.WORLD, loc.getX(), loc.getY() + 1, loc.getZ()).getBlock();
wheat.setType(Material.CROPS);
wheat.setData((byte) 7);
} else if (itemName.contains("invis")) {
block.setData((byte) 0);
block.setType(Material.PISTON_MOVING_PIECE);
event.getPlayer().sendMessage("Placed invisible block. To remove invisible block, type /u rinv while standing inside an invisible block.");
} else if (itemName.contains("coal")) {
block.setType(Material.GLASS);
new URunnable() {
public void run() {
block.setType(Material.COAL_ORE);
}
}.runLater(1 * 20);
} else if (itemName.contains("lighting")) {
Chunk chunk = ((CraftChunk) block.getChunk()).getHandle();
chunk.initLighting();
} else {
sendStaffToolInfoMessage(player);
}
}
use of xyz.derkades.ublisk.utils.URunnable in project Ublisk by Derkades.
the class Loot method onEnable.
@Override
public void onEnable() {
new URunnable() {
public void run() {
int random = Random.getRandomInteger(0, 5);
if (random == 0) {
Loot.getRandomLoot().spawn();
}
}
}.runTimer(5 * 60 * 20, 5 * 60 * 20);
// Spawn particles
new URunnable() {
public void run() {
for (Location location : SPAWNED_LOOT_LOCATIONS) {
Ublisk.spawnParticle(Particle.TOTEM, location.add(0.5, 0.5, 0.5), 2, 0, 0, 0, 0.35);
}
}
}.runTimer(3);
}
use of xyz.derkades.ublisk.utils.URunnable in project Ublisk by Derkades.
the class Main method onEnable.
@Override
public void onEnable() {
instance = this;
Ublisk.RESTART_ERROR = false;
PacketListener.RUNNING = true;
Listeners.register();
Command.registerAll();
Mobs.clearMobs();
MobSpawn.startMobSpawning();
for (Task task : Task.values()) task.start();
Logger.startSiteLogger();
TodoList.initialize(DataFile.MYSQL.getConfig().getString("todo.ip"), DataFile.MYSQL.getConfig().getInt("todo.port"), DataFile.MYSQL.getConfig().getString("todo.database"), DataFile.MYSQL.getConfig().getString("todo.user"), DataFile.MYSQL.getConfig().getString("todo.password"));
for (UModule module : UModule.ALL_MODULES) {
try {
module.initialize();
} catch (Exception e) {
Logger.log(LogLevel.SEVERE, "Modules", "An error occured while initializing " + module.getClass().getSimpleName() + ": " + e.getMessage());
e.printStackTrace();
}
}
Bukkit.clearRecipes();
Ublisk.NMS = new V1_12_R1();
new SidebarAPI().onEnable();
new URunnable() {
public void run() {
Logger.log(LogLevel.INFO, "Cache", "Building up cache, expect some lag..");
for (Guild guild : Guild.getGuildsList()) {
guild.getDescription();
guild.getMembers();
guild.getOwner();
guild.getPoints();
}
for (UPlayer player : Ublisk.getOnlinePlayers()) {
player.getXP();
}
Logger.log(LogLevel.INFO, "Cache", "Complete! Now containing " + Cache.size() + " objects.");
Logger.log(LogLevel.INFO, "Guilds", "Deleting empty guilds...");
for (Guild guild : Guild.getGuildsList()) {
if (guild.getMembers().size() == 0) {
Logger.log(LogLevel.WARNING, "Guilds", "Automatically deleted " + guild.getName() + ", because it does not have any members.");
guild.remove();
}
}
}
}.runLater(10 * 20);
for (UPlayer player : Ublisk.getOnlinePlayers()) {
PlayerInfo.resetHashMaps(player);
}
Ublisk.openDatabaseConnection();
}
use of xyz.derkades.ublisk.utils.URunnable in project Ublisk by Derkades.
the class GitHubCommand method onCommand.
@Override
protected void onCommand(UPlayer player, String[] args) {
if (args.length == 0) {
player.sendMessage("Wrong usage: /u " + this.getAliases()[0] + " [description]");
return;
}
final String description = String.join(" ", args);
new URunnable() {
public void run() {
try {
GHIssue issue = GitHubModule.createIssue(player.getName(), description);
player.sendMessage(Ublisk.getPrefix() + "Your message has been recorded. We'll take a look at it soon! View your issue at " + issue.getHtmlUrl());
} catch (IOException e) {
player.sendMessage(ChatColor.RED + "An error has occured :(");
e.printStackTrace();
}
}
}.runAsync();
}
use of xyz.derkades.ublisk.utils.URunnable in project Ublisk by Derkades.
the class PlayerInteract method removePinkWool.
@SuppressWarnings("deprecation")
@EventHandler(priority = EventPriority.HIGH)
public void removePinkWool(final PlayerInteractEvent event) {
if (event.getAction() == Action.RIGHT_CLICK_BLOCK && event.getMaterial() == Material.WOOL && event.getItem().getData().getData() == 6) {
event.setCancelled(true);
new URunnable() {
public void run() {
event.getPlayer().kickPlayer("java.net.ConnectException: Connection refused no further information");
}
}.runLater(2 * 20);
}
}
Aggregations