Skip to content

Commit

Permalink
Merge pull request #12 from Epicjii/dev
Browse files Browse the repository at this point in the history
1.19.1 and Gui upgrade
  • Loading branch information
Epicjii authored Jul 31, 2022
2 parents 8bc13a0 + 38aee58 commit b017c70
Show file tree
Hide file tree
Showing 14 changed files with 288 additions and 185 deletions.
12 changes: 2 additions & 10 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,13 +1,5 @@
# Manhunt_Plugin

This Plugin is for Paper 1.17.1 and 1.18.1
This Plugin is for Paper 1.17.1 - 1.19

Here is a good guide to installing this plugin: https://pingperfect.com/index.php/knowledgebase/829/Minecraft--PaperMC--How-to-install-plugins.html

First run /hunters [list of hunters] to set the hunters for the game.

Make sure when running the command that only one person runs the command.

Run /target [target] to set the huntee and begins the game

To end the hunt run /endhunt. The command should remove the compasses.
Here is a good guide to installing this plugin: https://pingperfect.com/index.php/knowledgebase/829/Minecraft--PaperMC--How-to-install-plugins.html
8 changes: 3 additions & 5 deletions build.gradle
Original file line number Diff line number Diff line change
@@ -1,17 +1,15 @@


plugins {
id 'java'
id("xyz.jpenilla.run-paper") version("1.0.6")
}
tasks {
runServer {
minecraftVersion("1.18.1")
minecraftVersion("1.19.1")
}
}

group = 'plugin.manhunt'
version = '2.0.6'
version = '3.0.0'

sourceCompatibility = '17'
targetCompatibility = '17'
Expand All @@ -29,7 +27,7 @@ repositories {
}

dependencies {
compileOnly 'io.papermc.paper:paper-api:1.18.1-R0.1-SNAPSHOT'
compileOnly 'io.papermc.paper:paper-api:1.19.1-R0.1-SNAPSHOT'
}

/*processResources {
Expand Down
24 changes: 16 additions & 8 deletions src/main/java/plugin/manhunt/manhunt_plugin/ManhuntPlugin.java
Original file line number Diff line number Diff line change
@@ -1,14 +1,18 @@
package plugin.manhunt.manhunt_plugin;

import org.bukkit.event.HandlerList;
import org.bukkit.plugin.java.JavaPlugin;
import plugin.manhunt.manhunt_plugin.commands.Endgame;
import plugin.manhunt.manhunt_plugin.commands.Hunters;
import plugin.manhunt.manhunt_plugin.commands.ListGames;
import plugin.manhunt.manhunt_plugin.commands.Target;
import plugin.manhunt.manhunt_plugin.commands.CreateGame;
import plugin.manhunt.manhunt_plugin.commands.EndGame;
import plugin.manhunt.manhunt_plugin.commands.JoinGame;
import plugin.manhunt.manhunt_plugin.game.GameData;
import plugin.manhunt.manhunt_plugin.gui.JoinGui;
import plugin.manhunt.manhunt_plugin.gui.TargetGui;

public final class ManhuntPlugin extends JavaPlugin {

public static ManhuntPlugin instance;
public static GameData gameData = new GameData();

public static ManhuntPlugin getInstance() {
return instance;
Expand All @@ -18,15 +22,19 @@ public static ManhuntPlugin getInstance() {
public void onEnable() {
// Plugin startup logic
instance = this;
getCommand("hunters").setExecutor(new Hunters());
getCommand("target").setExecutor(new Target());
getCommand("endgame").setExecutor(new Endgame());
getCommand("listgames").setExecutor(new ListGames());

getServer().getPluginManager().registerEvents(new TargetGui(), this);
getServer().getPluginManager().registerEvents(new JoinGui(), this);

getCommand("endgame").setExecutor(new EndGame());
getCommand("newgame").setExecutor(new CreateGame());
getCommand("joingame").setExecutor(new JoinGame());
}

@Override
public void onDisable() {
// Plugin shutdown logic
HandlerList.unregisterAll();
}

}
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
package plugin.manhunt.manhunt_plugin.commands;

import org.bukkit.command.Command;
import org.bukkit.command.CommandExecutor;
import org.bukkit.command.CommandSender;
import org.bukkit.entity.Player;
import org.jetbrains.annotations.NotNull;
import plugin.manhunt.manhunt_plugin.gui.TargetGui;

public class CreateGame implements CommandExecutor {

@Override
public boolean onCommand(
@NotNull CommandSender sender,
@NotNull Command command,
@NotNull String label,
@NotNull String[] args) {

if (!(sender instanceof Player)) {
return false;
}

TargetGui targetGui = new TargetGui();
targetGui.openNewGui((Player) sender);
return true;
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -5,14 +5,14 @@
import org.bukkit.command.CommandExecutor;
import org.bukkit.command.CommandSender;
import org.bukkit.entity.Player;
import org.bukkit.event.HandlerList;
import org.bukkit.inventory.ItemStack;
import org.jetbrains.annotations.NotNull;
import plugin.manhunt.manhunt_plugin.ManhuntGame;
import plugin.manhunt.manhunt_plugin.ManhuntPlugin;
import plugin.manhunt.manhunt_plugin.game.ManhuntGame;

import java.util.HashMap;
public class EndGame implements CommandExecutor {

public class Endgame implements CommandExecutor {
static HashMap<ManhuntGame, Player> currentGames = Target.currentGames;

public static void endgame(ManhuntGame manhuntGame) {
for (Player player : manhuntGame.players) {
Expand All @@ -23,8 +23,7 @@ public static void endgame(ManhuntGame manhuntGame) {
player.getInventory().remove(compass);
}
}
currentGames.remove(manhuntGame);
manhuntGame.unRegisterEvent();
ManhuntPlugin.gameData.removeGame(manhuntGame);
}

@Override
Expand All @@ -36,16 +35,17 @@ public boolean onCommand(
if (!(sender instanceof Player)) {
return false;
}
for (ManhuntGame manhuntGame : currentGames.keySet()) {
for (ManhuntGame manhuntGame : ManhuntPlugin.gameData.currentGames) {
if (manhuntGame.players.contains(sender)) {
for (Player player : manhuntGame.players) {
for (ItemStack compass : manhuntGame.activecompasses) {
player.getInventory().remove(compass);
}
player.sendRawMessage("The Manhunt has ended!");
manhuntGame.players.remove(player);
}
currentGames.remove(manhuntGame);
manhuntGame.unRegisterEvent();
ManhuntPlugin.gameData.removeGame(manhuntGame);
HandlerList.unregisterAll(manhuntGame);
return true;
}
}
Expand Down
44 changes: 0 additions & 44 deletions src/main/java/plugin/manhunt/manhunt_plugin/commands/Hunters.java

This file was deleted.

25 changes: 25 additions & 0 deletions src/main/java/plugin/manhunt/manhunt_plugin/commands/JoinGame.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
package plugin.manhunt.manhunt_plugin.commands;

import org.bukkit.command.Command;
import org.bukkit.command.CommandExecutor;
import org.bukkit.command.CommandSender;
import org.bukkit.entity.Player;
import org.jetbrains.annotations.NotNull;
import plugin.manhunt.manhunt_plugin.gui.JoinGui;

public class JoinGame implements CommandExecutor {

@Override
public boolean onCommand(
@NotNull CommandSender sender,
@NotNull Command command,
@NotNull String label,
@NotNull String[] args) {

JoinGui joinGui = new JoinGui();
joinGui.openNewGui((Player) sender);


return true;
}
}

This file was deleted.

30 changes: 0 additions & 30 deletions src/main/java/plugin/manhunt/manhunt_plugin/commands/Target.java

This file was deleted.

16 changes: 16 additions & 0 deletions src/main/java/plugin/manhunt/manhunt_plugin/game/GameData.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
package plugin.manhunt.manhunt_plugin.game;

import java.util.ArrayList;

public class GameData {
public ArrayList<ManhuntGame> currentGames = new ArrayList<>();

public void addGame(ManhuntGame game) {
currentGames.add(game);
}

public void removeGame(ManhuntGame game) {
currentGames.remove(game);
}

}
Loading

0 comments on commit b017c70

Please sign in to comment.