mirror of
https://github.com/IdalecioSch/plugin-de-raio.git
synced 2026-07-28 00:30:02 -03:00
raio pra onde o player olha tbm. e um comando de subir
This commit is contained in:
@@ -21,6 +21,8 @@ public class LightningStrike extends JavaPlugin implements Listener {
|
|||||||
public void onEnable() {
|
public void onEnable() {
|
||||||
getLogger().info("Plugin LightningStrike habilitado!");
|
getLogger().info("Plugin LightningStrike habilitado!");
|
||||||
getCommand("raios").setExecutor(this);
|
getCommand("raios").setExecutor(this);
|
||||||
|
getCommand("raiosolhar").setExecutor(new RaiosOlhar(this));
|
||||||
|
getCommand("subir").setExecutor(new Subir(this));
|
||||||
getServer().getPluginManager().registerEvents(this, this);
|
getServer().getPluginManager().registerEvents(this, this);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -38,13 +40,13 @@ public class LightningStrike extends JavaPlugin implements Listener {
|
|||||||
if (sender.hasPermission("lightningstrike.raios") || sender.isOp()) {
|
if (sender.hasPermission("lightningstrike.raios") || sender.isOp()) {
|
||||||
if (args.length != 1) {
|
if (args.length != 1) {
|
||||||
sender.sendMessage("Uso correto: /raios <player>");
|
sender.sendMessage("Uso correto: /raios <player>");
|
||||||
return false;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
Player target = Bukkit.getPlayer(args[0]);
|
Player target = Bukkit.getPlayer(args[0]);
|
||||||
if (target == null) {
|
if (target == null) {
|
||||||
sender.sendMessage("Jogador não encontrado.");
|
sender.sendMessage("Jogador não encontrado.");
|
||||||
return false;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
toggleLightning(target);
|
toggleLightning(target);
|
||||||
@@ -52,7 +54,7 @@ public class LightningStrike extends JavaPlugin implements Listener {
|
|||||||
|
|
||||||
}else{
|
}else{
|
||||||
sender.sendMessage("Você não tem permissão para usar este comando.");
|
sender.sendMessage("Você não tem permissão para usar este comando.");
|
||||||
return false;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
@@ -80,7 +82,7 @@ public class LightningStrike extends JavaPlugin implements Listener {
|
|||||||
};
|
};
|
||||||
task.runTaskTimer(this, 0, 1); // A cada segundo (20 ticks)
|
task.runTaskTimer(this, 0, 1); // A cada segundo (20 ticks)
|
||||||
tasks.put(playerId, task);
|
tasks.put(playerId, task);
|
||||||
player.sendMessage("Os raios foram ativados. Mantenha-se em movimento!");
|
player.sendMessage("Os raios foram ativados!");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -0,0 +1,78 @@
|
|||||||
|
package com.itakinn;
|
||||||
|
|
||||||
|
import java.util.HashMap;
|
||||||
|
import java.util.Map;
|
||||||
|
import java.util.UUID;
|
||||||
|
|
||||||
|
import org.bukkit.Bukkit;
|
||||||
|
import org.bukkit.block.Block;
|
||||||
|
import org.bukkit.command.Command;
|
||||||
|
import org.bukkit.command.CommandExecutor;
|
||||||
|
import org.bukkit.command.CommandSender;
|
||||||
|
import org.bukkit.entity.Player;
|
||||||
|
import org.bukkit.event.Listener;
|
||||||
|
import org.bukkit.plugin.Plugin;
|
||||||
|
import org.bukkit.plugin.java.JavaPlugin;
|
||||||
|
import org.bukkit.scheduler.BukkitRunnable;
|
||||||
|
|
||||||
|
public class RaiosOlhar implements Listener, CommandExecutor {
|
||||||
|
private final Map<UUID, BukkitRunnable> tasksOlhar = new HashMap<>();
|
||||||
|
private final JavaPlugin plugin;
|
||||||
|
|
||||||
|
public RaiosOlhar(JavaPlugin plugin) {
|
||||||
|
this.plugin = plugin;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public boolean onCommand(CommandSender sender, Command command, String label, String[] args) {
|
||||||
|
if (sender.hasPermission("lightningstrike.raiosolhar") || sender.isOp()) {
|
||||||
|
|
||||||
|
if (args.length < 1) {
|
||||||
|
toggleLightningOlhar(Bukkit.getPlayer(sender.getName()));
|
||||||
|
return true;
|
||||||
|
} else if (args.length == 1) { // se tiver argumento (player) chama ele
|
||||||
|
Player target = Bukkit.getPlayer(args[0]);
|
||||||
|
if (target == null) {
|
||||||
|
sender.sendMessage(args[0] + " não está online.");
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
toggleLightningOlhar(target);
|
||||||
|
return true;
|
||||||
|
} else { // se tiver mais de um argumento
|
||||||
|
sender.sendMessage("Uso correto: /raiosolhar <player>");
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
sender.sendMessage("Você não tem permissão para usar este comando.");
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
private void toggleLightningOlhar(Player target) {
|
||||||
|
UUID uuid = target.getUniqueId();
|
||||||
|
if (tasksOlhar.containsKey(uuid)) {
|
||||||
|
// Se o jogador já está sendo atingido por raios, cancela a tarefa
|
||||||
|
tasksOlhar.get(uuid).cancel();
|
||||||
|
tasksOlhar.remove(uuid);
|
||||||
|
target.sendMessage("Os raios foram desativados.");
|
||||||
|
} else {
|
||||||
|
BukkitRunnable tasks = new BukkitRunnable() {
|
||||||
|
@Override
|
||||||
|
public void run() {
|
||||||
|
if (!target.isOnline() || target.isDead()) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
Block bloco = target.getTargetBlock(null, 100);
|
||||||
|
if (!bloco.isEmpty())
|
||||||
|
target.getWorld().strikeLightningEffect(bloco.getLocation());
|
||||||
|
else {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
};
|
||||||
|
tasks.runTaskTimer(plugin, 0, 1);
|
||||||
|
tasksOlhar.put(uuid, tasks);
|
||||||
|
target.sendMessage("Os raios foram ativados para o olhar.");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -0,0 +1,58 @@
|
|||||||
|
package com.itakinn;
|
||||||
|
|
||||||
|
import java.util.HashMap;
|
||||||
|
import java.util.Map;
|
||||||
|
import java.util.UUID;
|
||||||
|
|
||||||
|
import org.bukkit.Bukkit;
|
||||||
|
import org.bukkit.Location;
|
||||||
|
import org.bukkit.World;
|
||||||
|
import org.bukkit.command.Command;
|
||||||
|
import org.bukkit.command.CommandExecutor;
|
||||||
|
import org.bukkit.command.CommandSender;
|
||||||
|
import org.bukkit.entity.Player;
|
||||||
|
import org.bukkit.event.Listener;
|
||||||
|
import org.bukkit.plugin.java.JavaPlugin;
|
||||||
|
import org.bukkit.scheduler.BukkitRunnable;
|
||||||
|
|
||||||
|
public class Subir implements Listener, CommandExecutor {
|
||||||
|
private final Map<UUID, BukkitRunnable> tasksOlhar = new HashMap<>();
|
||||||
|
private final JavaPlugin plugin;
|
||||||
|
|
||||||
|
public Subir(JavaPlugin plugin) {
|
||||||
|
this.plugin = plugin;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public boolean onCommand(CommandSender sender, Command command, String label, String[] args) {
|
||||||
|
if (sender.hasPermission("lightningstrike.subir") || sender.isOp()) {
|
||||||
|
if (args.length < 1) { // se argumento for menor de um (sem argumento) usa quem mandou o comando
|
||||||
|
subirPlayer(Bukkit.getPlayer(sender.getName()));
|
||||||
|
return true;
|
||||||
|
} else if (args.length == 1) { // se tiver argumento (player) chama ele
|
||||||
|
Player target = Bukkit.getPlayer(args[0]);
|
||||||
|
if (target == null) {
|
||||||
|
sender.sendMessage(args[0] + " não está online.");
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
subirPlayer(target);
|
||||||
|
return true;
|
||||||
|
} else {
|
||||||
|
sender.sendMessage("Uso correto: /subir <player>");
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
sender.sendMessage("Você não tem permissão para usar este comando.");
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
private void subirPlayer(Player player) {
|
||||||
|
World max;
|
||||||
|
max = player.getWorld();
|
||||||
|
Location loc = player.getLocation();
|
||||||
|
loc.setY(max.getHighestBlockYAt(loc) + 1);
|
||||||
|
player.teleport(loc);
|
||||||
|
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -7,8 +7,22 @@ commands:
|
|||||||
description: Ativa ou desativa raios sobre um jogador
|
description: Ativa ou desativa raios sobre um jogador
|
||||||
usage: /raios <player>
|
usage: /raios <player>
|
||||||
permission: lightningstrike.raios
|
permission: lightningstrike.raios
|
||||||
|
raiosolhar:
|
||||||
|
description: Ativa ou desativa raios onde o jogador que estiver olhando
|
||||||
|
usage: /raiosolhar
|
||||||
|
permission: lightningstrike.raiosolhar
|
||||||
|
subir:
|
||||||
|
description: Teleporta o jogador para cima
|
||||||
|
usage: /subir
|
||||||
|
permission: lightningstrike.subir
|
||||||
|
|
||||||
permissions:
|
permissions:
|
||||||
lightningstrike.raios:
|
lightningstrike.raios:
|
||||||
description: Permite que o jogador ative ou desative raios sobre outro jogador
|
description: Permite que o jogador ative ou desative raios sobre outro jogador
|
||||||
default: op
|
default: op
|
||||||
|
lightningstrike.raiosolhar:
|
||||||
|
description: Permite que o jogador ative ou desative raios onde estiver olhando
|
||||||
|
default: op
|
||||||
|
lightiningstrike.subir:
|
||||||
|
description: Permite que o jogador se teleporte para cima
|
||||||
|
default: op
|
||||||
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
@@ -7,8 +7,22 @@ commands:
|
|||||||
description: Ativa ou desativa raios sobre um jogador
|
description: Ativa ou desativa raios sobre um jogador
|
||||||
usage: /raios <player>
|
usage: /raios <player>
|
||||||
permission: lightningstrike.raios
|
permission: lightningstrike.raios
|
||||||
|
raiosolhar:
|
||||||
|
description: Ativa ou desativa raios onde o jogador que estiver olhando
|
||||||
|
usage: /raiosolhar
|
||||||
|
permission: lightningstrike.raiosolhar
|
||||||
|
subir:
|
||||||
|
description: Teleporta o jogador para cima
|
||||||
|
usage: /subir
|
||||||
|
permission: lightningstrike.subir
|
||||||
|
|
||||||
permissions:
|
permissions:
|
||||||
lightningstrike.raios:
|
lightningstrike.raios:
|
||||||
description: Permite que o jogador ative ou desative raios sobre outro jogador
|
description: Permite que o jogador ative ou desative raios sobre outro jogador
|
||||||
default: op
|
default: op
|
||||||
|
lightningstrike.raiosolhar:
|
||||||
|
description: Permite que o jogador ative ou desative raios onde estiver olhando
|
||||||
|
default: op
|
||||||
|
lightiningstrike.subir:
|
||||||
|
description: Permite que o jogador se teleporte para cima
|
||||||
|
default: op
|
||||||
Reference in New Issue
Block a user