Code Monkey home page Code Monkey logo

manhunt's Introduction

Hi there ๐Ÿ‘‹

I'm Jack, a Kotlin developer from Wales, UK. I have been working as a freelancer for several years and offer services on a variety of platforms, focussing on automation and bots

  • ๐Ÿ‘จโ€๐Ÿ’ป Working on custom Minecraft plugins and discord bots
  • ๐Ÿค” Capable full-stack web developer
  • ๐Ÿ’ฌ Primary language: Kotlin & Java
  • ๐Ÿ”— Find my portfolio at: https://jackchap.com

manhunt's People

Contributors

crepppy avatar

Stargazers

 avatar

Watchers

 avatar  avatar  avatar

manhunt's Issues

Multiple hunters for 2v2

Add planned functionality for 2v2s.

Suggestion for implementation

ByteArrayDataOutput out = ByteStreams.newDataOutput();
out.writeUTF("start");
out.writeInt(mode);
info.sendData(PLUGIN_CHANNEL, out.toByteArray());
Instead of sending the total players here, send 2 integers (hunter number / hunted number) and store them in Game.java when received.

Move hunted to a List<UUID> similar to hunters and convert all uses of the variable

Add a map like

Map<UUID, UUID> hunterTracking; // <hunter, hunted>

to Game.java to track which hunted player a hunter is tracking. Add an event handler to check when a player right-clicks a tracker compass and switch which hunted player they are tracking.

Bukkit.getScheduler().runTaskTimer(this, () -> {
if (game != null && game.isRunning()) {
// Update the compass to the players location
Player hunted = game.getHuntedPlayer();
if (hunted == null) return;
final Location overworldLoc;
final Location loadstoneLoc;
switch (hunted.getWorld().getEnvironment()) {
case NETHER:
overworldLoc = game.getNetherPortalOverworld();
loadstoneLoc = hunted.getLocation();
break;
case THE_END:
overworldLoc = game.getEndPortal();
loadstoneLoc = game.getNetherPortalNether();
break;
default:
overworldLoc = hunted.getLocation();
loadstoneLoc = game.getNetherPortalNether();
break;
}
game.getHunterPlayers().forEach(p -> {
if (p.getWorld().getEnvironment() == World.Environment.NETHER) {
if(loadstoneLoc == null) return;
for(int i = 0; i < 36; i++) {
ItemStack it = p.getInventory().getStorageContents()[i];
if(it.getItemMeta() != null && it.getType() == Material.COMPASS) {
CompassMeta meta = (CompassMeta) it.getItemMeta();
meta.setLodestoneTracked(false);
meta.setLodestone(loadstoneLoc);
it.setItemMeta(meta);
}
}
} else {
p.setCompassTarget(overworldLoc);
}
});
// If a player is holding a compass+ then update their action bar to show the distance from the player
// the hunted player is in
for (Player p : Bukkit.getOnlinePlayers()) {
if (p.getInventory().getItemInMainHand().equals(COMPASS_PLUS) || p.getInventory().getItemInOffHand().equals(COMPASS_PLUS)) {
p.spigot().sendMessage(ChatMessageType.ACTION_BAR,
new ComponentBuilder()
.append(Util.colorFromDimension(hunted.getLocation()).toString() + "Dimension: ")
.append(Util.colorFromDimension(hunted.getLocation()).toString() + "ยงl" + Util.dimensionName(hunted.getLocation()))
.append(" ")
.append(Util.colorFromDimension(hunted.getLocation()).toString() + "Distance: ")
.append(Util.colorFromDimension(hunted.getLocation()).toString() + "ยงl" + Math.round(p.getLocation().distance(p.getWorld().getEnvironment() == World.Environment.NETHER ? loadstoneLoc : overworldLoc)) + "m")
.create());
} else if (p.getInventory().getItemInMainHand().equals(COMPASS) || p.getInventory().getItemInOffHand().equals(COMPASS)) {
p.spigot().sendMessage(ChatMessageType.ACTION_BAR,
new ComponentBuilder()
.append(Util.colorFromDimension(hunted.getLocation()).toString() + "Dimension: ")
.append(Util.colorFromDimension(hunted.getLocation()).toString() + "ยงl" + Util.dimensionName(hunted.getLocation()))
.create());
}
}
}
}, 100, 10);
Change code here to get the location of the hunted player that the specific hunter is tracking (from the map)

@EventHandler
public void onHuntedKilled(PlayerDeathEvent e) {
if (e.getEntity().getUniqueId().equals(plugin.getGame().getHunted())) {
// Hunted killed - hunters end game
plugin.endGame(true);
}
}
When a hunted player dies set their gamemode to spectator and check if there are any hunted players left that are still in survival

  • If there is, keep playing
  • If not, the same end game scenario

Are obviously a lot of things that would need to change but most of the logic stays the same so hopefully it isn't a big job
๐Ÿ‘

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.