Skip to content

Commit

Permalink
- Allow players to join queue by right clicking any Duel sign #103 #100
Browse files Browse the repository at this point in the history
#33

- Set players health and food level to full when duel starts
- Players can leave the queue by using the /duel leave command

Pre release 0.18.4
  • Loading branch information
teozfrank committed Jun 26, 2018
1 parent f461c78 commit e05a712
Show file tree
Hide file tree
Showing 6 changed files with 68 additions and 7 deletions.

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion Plugin/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
<artifactId>DuelMe</artifactId>
<packaging>jar</packaging>
<name>DuelMe</name>
<version>0.18.3</version>
<version>0.18.4</version>

<dependencies>
<dependency>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -52,6 +52,11 @@ public void run(CommandSender sender, String subCmd, String[] args) {
if(dm.isInDuel(playerUUID)){
dm.endDuel(player);
} else {
if(dm.isQueued(playerUUID)) {
dm.removeQueuedPlayer(playerUUID);
Util.sendMsg(sender, ChatColor.GOLD + "You have been removed from the duel queue.");
return;
}
Util.sendMsg(sender, ChatColor.RED + "You cannot leave duel if you are not in one!");
}
}
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,53 @@
package com.github.teozfrank.duelme.events;

import com.github.teozfrank.duelme.main.DuelMe;
import com.github.teozfrank.duelme.util.SendConsoleMessage;
import org.bukkit.Bukkit;
import org.bukkit.ChatColor;
import org.bukkit.Material;
import org.bukkit.block.Block;
import org.bukkit.block.Sign;
import org.bukkit.entity.Player;
import org.bukkit.event.EventHandler;
import org.bukkit.event.EventPriority;
import org.bukkit.event.Listener;
import org.bukkit.event.block.Action;
import org.bukkit.event.player.PlayerInteractEvent;

public class PlayerInteract implements Listener {

private DuelMe plugin;

public PlayerInteract(DuelMe plugin) {
this.plugin = plugin;
Bukkit.getPluginManager().registerEvents(this, plugin);
}

@EventHandler (priority = EventPriority.MONITOR)
public void onPlayerInteractSign(PlayerInteractEvent e) {
Player player = e.getPlayer();
Block clickedBlock = e.getClickedBlock();
Action action = e.getAction();



if(action == Action.RIGHT_CLICK_BLOCK) {

if (! clickedBlock.getType().equals(Material.WALL_SIGN)) {
return;
}
SendConsoleMessage.debug("Right click wall sign yay!.");

try {
Sign sign = (Sign) clickedBlock.getState();
String line1 = sign.getLine(0);
line1 = ChatColor.stripColor(line1);
if(line1.equals("[DuelMe]")) {
player.performCommand("duel join");
}
} catch (Exception ex) {

}
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -107,7 +107,7 @@ public void onEnable() {
getCommand("duel").setExecutor(new DuelExecutor(this));
getCommand("dueladmin").setExecutor(new DuelAdminExecutor(this));
this.getFileManager().loadDuelArenas();
this.getFileManager().loadKits();
//this.getFileManager().loadKits();TODO re-enable kits loading kits once tested fully
if(this.setupTitleActionBar()) {
SendConsoleMessage.info("NMS Version setup complete");
} else {
Expand Down Expand Up @@ -164,6 +164,7 @@ private void registerEvents() {
this.acceptMenu = new AcceptMenu(this);
new PlayerEvents(this);
new SignEdit(this);
new PlayerInteract(this);
}

@Override
Expand Down Expand Up @@ -247,10 +248,10 @@ public void setupYMLs() {
this.getFileManager().saveDefaultSigns();
}

if (!(new File(getDataFolder(), "kits.yml")).exists()) {
/*if (!(new File(getDataFolder(), "kits.yml")).exists()) {//TODO re-enable kits config file creation once tested
SendConsoleMessage.info("Saving default kits.yml.");
this.getFileManager().saveDefaultKits();
}
}*/
}

/**
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -78,6 +78,8 @@ public void run() {
} else {
if(duelSize == 2) {
plugin.getTitleActionbar().sendTitle(sender, target, mm.getDuelStartedMessage(), "", 10, 10, 10);
sender.setFoodLevel(20);
sender.setHealth(20);
duelArena.setDuelState(DuelState.STARTED);
dm.surroundLocation(duelArena.getSpawnpoint1(), Material.AIR);
dm.surroundLocation(duelArena.getSpawnpoint2(), Material.AIR);
Expand Down

0 comments on commit e05a712

Please sign in to comment.