-
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.
Clean up PvPListener and fix some small issues
- Loading branch information
Showing
9 changed files
with
209 additions
and
171 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,4 @@ | ||
package com.mythicamc.commands; | ||
|
||
public class SetSpawnCommand { | ||
} |
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,4 @@ | ||
package com.mythicamc.commands; | ||
|
||
public class SpawnCommand { | ||
} |
34 changes: 34 additions & 0 deletions
34
src/main/java/com/mythicamc/listeners/PlayerCommandListener.java
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,34 @@ | ||
package com.mythicamc.listeners; | ||
|
||
import com.mythicamc.managers.CombatManager; | ||
import org.bukkit.ChatColor; | ||
import org.bukkit.entity.Player; | ||
import org.bukkit.event.EventHandler; | ||
import org.bukkit.event.Listener; | ||
import org.bukkit.event.player.PlayerCommandPreprocessEvent; | ||
|
||
import java.util.List; | ||
|
||
public class PlayerCommandListener implements Listener { | ||
|
||
private final CombatManager combatManager; | ||
|
||
public PlayerCommandListener(CombatManager combatManager) { | ||
this.combatManager = combatManager; | ||
} | ||
|
||
@EventHandler | ||
public void onPlayerCommandPreprocess(PlayerCommandPreprocessEvent e) { | ||
Player p = e.getPlayer(); | ||
if (combatManager.isTagged(p)) { | ||
// List of blocked commands | ||
List<String> blockedCommands = List.of("/spawn"); | ||
String command = e.getMessage().split(" ")[0].toLowerCase(); | ||
|
||
if (blockedCommands.contains(command)) { | ||
p.sendMessage(ChatColor.RED + "You cannot use that command while in combat!"); | ||
e.setCancelled(true); | ||
} | ||
} | ||
} | ||
} |
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
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
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
Oops, something went wrong.