-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
0 parents
commit ad4f106
Showing
12 changed files
with
204 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
lib/spigot-1.16.5.jar | ||
.vscode/settings.json | ||
Manhunt plugin.jar |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
## Manhunt | ||
|
||
A simple manhunt plugin for Spigot Mc 1.16 |
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,25 @@ | ||
package me.rohith.manhunt; | ||
|
||
import java.util.ArrayList; | ||
|
||
import org.bukkit.plugin.java.JavaPlugin; | ||
|
||
import me.rohith.manhunt.commands.*; | ||
import me.rohith.manhunt.listeners.*; | ||
|
||
public class Main extends JavaPlugin { | ||
|
||
public ArrayList<String> Speedrunners = new ArrayList<String>(); | ||
|
||
@Override | ||
public void onEnable() { | ||
//Commands | ||
new HuntCommand(this); | ||
new TrackCommand(this); | ||
|
||
//Listeners | ||
new RespawnListener(this); | ||
new CompassClickListener(this); | ||
} | ||
} | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,44 @@ | ||
package me.rohith.manhunt.commands; | ||
|
||
import org.bukkit.Bukkit; | ||
import org.bukkit.command.Command; | ||
import org.bukkit.command.CommandExecutor; | ||
import org.bukkit.command.CommandSender; | ||
import org.bukkit.entity.Player; | ||
|
||
import me.rohith.manhunt.Main; | ||
|
||
public class HuntCommand implements CommandExecutor { | ||
|
||
private Main plugin; | ||
|
||
public HuntCommand(Main plugin) { | ||
this.plugin = plugin; | ||
plugin.getCommand("hunt").setExecutor(this); | ||
} | ||
@Override | ||
public boolean onCommand(CommandSender sender, Command cmd, String label, String[] args) { | ||
|
||
Player plr = sender.getServer().getPlayer(args[0]); | ||
if (plr == null) return false; | ||
|
||
if (!this.plugin.Speedrunners.contains(args[0])) { | ||
|
||
this.plugin.Speedrunners.add(args[0]); | ||
plr.setGlowing(true); | ||
Bukkit.broadcastMessage(args[0] + " is now marked as a speedrunner!"); | ||
|
||
} | ||
else { | ||
|
||
this.plugin.Speedrunners.remove(args[0]); | ||
plr.setGlowing(false); | ||
Bukkit.broadcastMessage(args[0] + " is no longer a speedrunner!"); | ||
} | ||
|
||
|
||
return false; | ||
} | ||
|
||
|
||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,36 @@ | ||
package me.rohith.manhunt.commands; | ||
|
||
import org.bukkit.command.Command; | ||
import org.bukkit.command.CommandExecutor; | ||
import org.bukkit.command.CommandSender; | ||
import org.bukkit.entity.Player; | ||
|
||
import me.rohith.manhunt.Main; | ||
|
||
public class TrackCommand implements CommandExecutor { | ||
|
||
//private Main plugin; | ||
|
||
public TrackCommand(Main plugin) { | ||
//this.plugin = plugin; | ||
plugin.getCommand("track").setExecutor(this); | ||
} | ||
@Override | ||
public boolean onCommand(CommandSender sender, Command cmd, String label, String[] args) { | ||
|
||
Player plr = (Player) sender; | ||
Player speedrunner = sender.getServer().getPlayer(args[0]); | ||
|
||
if (speedrunner == null) { | ||
plr.sendMessage("Something went wrong - that player doesn't exist!"); | ||
return false; | ||
} | ||
|
||
plr.setCompassTarget(speedrunner.getLocation()); | ||
sender.sendMessage("You are currently tracking : " + speedrunner.getDisplayName()); | ||
|
||
return false; | ||
} | ||
|
||
|
||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,61 @@ | ||
package me.rohith.manhunt.listeners; | ||
|
||
import org.bukkit.Bukkit; | ||
import org.bukkit.Material; | ||
import org.bukkit.entity.Player; | ||
import org.bukkit.event.EventHandler; | ||
import org.bukkit.event.Listener; | ||
import org.bukkit.event.block.Action; | ||
import org.bukkit.event.player.PlayerInteractEvent; | ||
import org.bukkit.inventory.ItemStack; | ||
|
||
import me.rohith.manhunt.Main; | ||
import net.md_5.bungee.api.ChatColor; | ||
import net.md_5.bungee.api.chat.ClickEvent; | ||
import net.md_5.bungee.api.chat.TextComponent; | ||
|
||
public class CompassClickListener implements Listener { | ||
|
||
private Main plugin; | ||
|
||
public CompassClickListener(Main plugin) { | ||
this.plugin = plugin; | ||
System.out.println(this.plugin); | ||
Bukkit.getPluginManager().registerEvents(this, plugin); | ||
} | ||
|
||
@EventHandler | ||
public void CompassClick(PlayerInteractEvent event) { | ||
Player p = event.getPlayer(); | ||
ItemStack stack = event.getItem(); | ||
if (stack == null) return; | ||
Material item = stack.getType(); | ||
Action action = event.getAction(); | ||
|
||
|
||
if ( | ||
!(this.plugin.Speedrunners.contains(p.getName())) | ||
&& item == Material.COMPASS | ||
&& (action == Action.RIGHT_CLICK_AIR || action == Action.RIGHT_CLICK_BLOCK) | ||
) | ||
{ | ||
if (this.plugin.Speedrunners.isEmpty()) { | ||
p.sendMessage("There is no one to track! Use the hunt command to track somebody"); | ||
return; | ||
} | ||
|
||
TextComponent message = new TextComponent("Click on the speedrunner you wanna track : \n"); | ||
|
||
this.plugin.Speedrunners.forEach(plrName -> { | ||
TextComponent name = new TextComponent(plrName); | ||
name.setBold(true); | ||
name.setColor(ChatColor.AQUA); | ||
name.setClickEvent(new ClickEvent(ClickEvent.Action.RUN_COMMAND, "/track " + plrName)); | ||
message.addExtra(name); | ||
}); | ||
|
||
p.spigot().sendMessage(message); | ||
} | ||
|
||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,32 @@ | ||
package me.rohith.manhunt.listeners; | ||
|
||
import org.bukkit.Bukkit; | ||
import org.bukkit.Material; | ||
import org.bukkit.entity.Player; | ||
import org.bukkit.event.EventHandler; | ||
import org.bukkit.event.Listener; | ||
import org.bukkit.event.player.PlayerRespawnEvent; | ||
import org.bukkit.inventory.ItemStack; | ||
|
||
import me.rohith.manhunt.Main; | ||
|
||
public class RespawnListener implements Listener { | ||
|
||
private Main plugin; | ||
|
||
public RespawnListener(Main plugin) { | ||
this.plugin = plugin; | ||
|
||
Bukkit.getPluginManager().registerEvents(this, plugin); | ||
} | ||
|
||
@EventHandler | ||
public void PlayerRespawn(PlayerRespawnEvent event) { | ||
Player p = event.getPlayer(); | ||
if (p == null) return; | ||
|
||
if (this.plugin.Speedrunners.contains(p.getName())) return; | ||
|
||
p.getInventory().addItem(new ItemStack(Material.COMPASS)); | ||
} | ||
} |