-
Notifications
You must be signed in to change notification settings - Fork 3
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 64d40c8
Showing
18 changed files
with
1,161 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,2 @@ | ||
<?xml version="1.0" encoding="UTF-8"?> | ||
<module type="JAVA_MODULE" version="4" /> |
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,85 @@ | ||
# MultiverseHardcore | ||
Minecraft Version: _1.15_ | ||
|
||
With this plugin, you can prevent your players from entering a world if they die in it. | ||
|
||
Deathbans only affect the worlds you choose and can be temporary or permanent. | ||
|
||
[Multiverse-Core](https://github.com/Multiverse/Multiverse-Core) is required to use this plugin. | ||
|
||
## Installation | ||
|
||
1. Install [Multiverse-Core](https://github.com/Multiverse/Multiverse-Core) on your server. | ||
2. Download the JAR file and put it on your Minecraft server ``plugins`` folder. | ||
3. Restart the server. | ||
|
||
## Basic usage | ||
After you've successfully installed the plugin, log in to your server and enter the following command: | ||
``` | ||
/mvhc create hardcore | ||
``` | ||
![World hardcore created](images/1.png) | ||
|
||
If everything went well, a Multiverse world called ``hardcore`` will have been created. | ||
Type ``/mv list`` or ``/mvhc worlds`` and you should see the name of your new world. | ||
|
||
![mvhc worlds output](images/2.png) | ||
|
||
Teleport to your new Hardcore world using ``/mv tp hardcore`` and you'll see a warning message. Be careful, if you die you won't be able to play in the world again! | ||
|
||
![Be careful, you are entering a HARDCORE world](images/3.png) | ||
|
||
For more options when creating a world (temporary bans, respawn world, Nether, The End...) check the command section. | ||
|
||
## Commands | ||
|
||
### Create a Hardcore world | ||
With this command, you can create a default Multiverse world in your server and make it Hardcore. | ||
``` | ||
/mvhc create <world> [spectator_mode] [create_nether] [create_end] [ban_ops] [ban_forever] [ban_length] [include_nether] [include_end] [respawn_world] | ||
``` | ||
Options: | ||
* __world__: Name of the world you want to create | ||
* __spectator_mode__ _(Optional)_: Set to true if you want players who die to be put on spectator mode. If set to false, they will be kicked out of the world. | ||
* __create_nether__ _(Optional)_: Set to true if you want to create a Nether for the world. You may need [Multiverse-Netherportals](https://github.com/Multiverse/Multiverse-Core/wiki/Install-%28NetherPortals%29) for your Nether to work. | ||
* __create_end__ _(Optional)_: Same as __create_nether__ but with The End. | ||
* __ban_ops__ _(Optional)_: Set to false if you don't want OPs to be banned if they die. | ||
* __ban_forever__ _(Optional)_: Set to true to make the deathban permanent. | ||
* __ban_length__ _(Optional)_: Death ban length (in seconds). If __ban_forever__ is set to true, this value doesn't matter. | ||
* __include_nether__ _(Optional)_: Set to true if you want your players to be deathbanned in the main world if they die on the Nether. Also, if set to true, players who die on the main world won't be able to play in the Nether. | ||
* __include_end__ _(Optional)_: Same as __include_nether__ but with The End. | ||
* __respawn_world__ _(Optional)_: Name of the respawn world (this is required if __spectator_mode__ is set to false). | ||
|
||
### Make a world Hardcore | ||
Use this command if you already have a world created and want to make it Hardcore. | ||
``` | ||
/mvhc makehc <world> [spectator_mode] [ban_ops] [ban_forever] [ban_length] [include_nether] [include_end] [respawn_world] | ||
``` | ||
The options are all explained in the previous command. | ||
|
||
### See player info | ||
Use this command to see information about a player in a Hardcore world: | ||
``` | ||
/mvhc player [world] [player] | ||
``` | ||
Options: | ||
* __world__ _(Optional)_: Hardcore world. Not necessary if it's the same world you're in. | ||
* __player__ _(Optional)_: Name of player. Not necessary if you want to see your information. | ||
|
||
### See Hardcore world information | ||
Use this command to see information about a Hardcore world: | ||
``` | ||
/mvhc world [world] | ||
``` | ||
Options: | ||
* __world__ _(Optional)_: Hardcore world. Not necessary if it's the same world you're in. | ||
### See Hardcore worlds list | ||
Use this command to get a list of all Hardcore worlds in your server: | ||
``` | ||
/mvhc worlds | ||
``` | ||
|
||
### See plugin version | ||
``` | ||
/mvhc version | ||
``` |
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
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,53 @@ | ||
<?xml version="1.0" encoding="UTF-8"?> | ||
<project xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" | ||
xmlns="http://maven.apache.org/POM/4.0.0" | ||
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd"> | ||
<modelVersion>4.0.0</modelVersion> | ||
|
||
<groupId>life.lluis</groupId> | ||
<artifactId>MultiverseHardcore</artifactId> | ||
<version>1.0</version> | ||
<build> | ||
<plugins> | ||
<plugin> | ||
<groupId>org.apache.maven.plugins</groupId> | ||
<artifactId>maven-compiler-plugin</artifactId> | ||
<configuration> | ||
<source>8</source> | ||
<target>8</target> | ||
</configuration> | ||
</plugin> | ||
</plugins> | ||
</build> | ||
|
||
<properties> | ||
<maven.compiler.source>1.6</maven.compiler.source> | ||
<maven.compiler.target>1.6</maven.compiler.target> | ||
</properties> | ||
|
||
<repositories> | ||
<repository> | ||
<id>spigotmc-repo</id> | ||
<url>https://hub.spigotmc.org/nexus/content/repositories/snapshots/</url> | ||
</repository> | ||
<repository> | ||
<id>Multiverse-Core</id> | ||
<url>http://repo.onarandombox.com/content/repositories/multiverse/</url> | ||
</repository> | ||
</repositories> | ||
|
||
<dependencies> | ||
<dependency> | ||
<groupId>org.spigotmc</groupId> | ||
<artifactId>spigot-api</artifactId> | ||
<version>1.15.2-R0.1-SNAPSHOT</version> | ||
<scope>provided</scope> | ||
</dependency> | ||
<dependency> | ||
<groupId>com.onarandombox.multiversecore</groupId> | ||
<artifactId>Multiverse-Core</artifactId> | ||
<version>4.1.0</version> | ||
</dependency> | ||
</dependencies> | ||
|
||
</project> |
168 changes: 168 additions & 0 deletions
168
src/main/java/life/lluis/multiversehardcore/MultiverseHardcore.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,168 @@ | ||
package life.lluis.multiversehardcore; | ||
|
||
import com.onarandombox.MultiverseCore.MultiverseCore; | ||
import life.lluis.multiversehardcore.commands.HelpCommand; | ||
import life.lluis.multiversehardcore.commands.MainCommand; | ||
import life.lluis.multiversehardcore.events.PlayerChangeOfWorld; | ||
import life.lluis.multiversehardcore.events.PlayerDeath; | ||
import life.lluis.multiversehardcore.events.PlayerJoin; | ||
import life.lluis.multiversehardcore.events.PlayerRespawn; | ||
import life.lluis.multiversehardcore.files.HardcoreWorldsList; | ||
import life.lluis.multiversehardcore.files.PlayersList; | ||
import org.bukkit.Bukkit; | ||
import org.bukkit.ChatColor; | ||
import org.bukkit.GameMode; | ||
import org.bukkit.World; | ||
import org.bukkit.command.CommandSender; | ||
import org.bukkit.entity.Player; | ||
import org.bukkit.event.player.PlayerEvent; | ||
import org.bukkit.plugin.Plugin; | ||
import org.bukkit.plugin.java.JavaPlugin; | ||
|
||
public class MultiverseHardcore extends JavaPlugin { | ||
|
||
private static MultiverseHardcore instance; | ||
private PlayersList playersList; | ||
private HardcoreWorldsList hardcoreWorldsList; | ||
|
||
public static MultiverseHardcore getInstance() { | ||
return instance; | ||
} | ||
|
||
@Override | ||
public void onEnable() { | ||
instance = this; | ||
saveDefaultConfig(); | ||
playersList = new PlayersList(); | ||
hardcoreWorldsList = new HardcoreWorldsList(); | ||
getServer().getPluginManager().registerEvents(new PlayerDeath(), this); | ||
getServer().getPluginManager().registerEvents(new PlayerChangeOfWorld(), this); | ||
getServer().getPluginManager().registerEvents(new PlayerRespawn(), this); | ||
getServer().getPluginManager().registerEvents(new PlayerJoin(), this); | ||
|
||
getCommand("mvhc").setExecutor(new MainCommand()); | ||
getCommand("mvhchelp").setExecutor(new HelpCommand()); | ||
|
||
Bukkit.getServer().getScheduler().scheduleSyncDelayedTask(this, new Runnable() { | ||
public void run() { | ||
hardcoreWorldsList.cleanWorlds(); | ||
} | ||
}, 1); | ||
} | ||
|
||
public boolean spawnPlayer(Player player) { | ||
World spawnWorld = getHardcoreWorldsList().getHardcoreWorldInfo(player.getWorld()).getSpawnWorld(); | ||
if (spawnWorld == null) { | ||
getLogger().warning("Respawn world does not exist!"); | ||
return false; | ||
} | ||
return player.teleport(spawnWorld.getSpawnLocation()); | ||
} | ||
|
||
public PlayersList getPlayersList() { | ||
return playersList; | ||
} | ||
|
||
public HardcoreWorldsList getHardcoreWorldsList() { | ||
return hardcoreWorldsList; | ||
} | ||
|
||
public MultiverseCore getMultiverseCore() { | ||
getServer().getPluginManager().getPlugins().toString(); | ||
Plugin plugin = getServer().getPluginManager().getPlugin("Multiverse-Core"); | ||
|
||
if (plugin instanceof MultiverseCore) { | ||
return (MultiverseCore) plugin; | ||
} | ||
|
||
throw new RuntimeException("Multiverse-Core not found!"); | ||
} | ||
|
||
public String getPrefix() { | ||
return ChatColor.DARK_RED + "[MV-HARDCORE]" + ChatColor.RESET + " "; | ||
} | ||
|
||
public void sendError(CommandSender sender, String error) { | ||
sender.sendMessage(getPrefix() + ChatColor.RED + error + ChatColor.RESET); | ||
} | ||
|
||
public void sendNormal(CommandSender sender, String error) { | ||
sender.sendMessage(getPrefix() + error); | ||
} | ||
|
||
public void sendInfo(CommandSender sender, String error) { | ||
sender.sendMessage(getPrefix() + ChatColor.BLUE + error + ChatColor.RESET); | ||
} | ||
|
||
public void sendSuccess(CommandSender sender, String error) { | ||
sender.sendMessage(getPrefix() + ChatColor.GREEN + error + ChatColor.RESET); | ||
} | ||
|
||
public boolean worldExists(String worldName) { | ||
return getServer().getWorld(worldName) != null; | ||
} | ||
|
||
public World getNormalWorld(World world) { | ||
if (world == null) return null; | ||
if (world.getEnvironment() == World.Environment.NORMAL) return world; | ||
HardcoreWorldsList.HardcoreWorldInfo worldInfo = hardcoreWorldsList.getHardcoreWorldInfo(world); | ||
if (world.getEnvironment() == World.Environment.NETHER && worldInfo.includeNether) { | ||
String worldName = world.getName(); | ||
if (worldName.endsWith("_nether")) { | ||
worldName = worldName.substring(0, worldName.length() - "_nether".length()); | ||
World normalWorld = getServer().getWorld(worldName); | ||
return normalWorld == null ? world : normalWorld; | ||
} | ||
return world; | ||
} | ||
if (world.getEnvironment() == World.Environment.THE_END && worldInfo.includeEnd) { | ||
String worldName = world.getName(); | ||
if (worldName.endsWith("_the_end")) { | ||
worldName = worldName.substring(0, worldName.length() - "_the_end".length()); | ||
World normalWorld = getServer().getWorld(worldName); | ||
return normalWorld == null ? world : normalWorld; | ||
} | ||
return world; | ||
} | ||
return world; | ||
} | ||
|
||
public void handlePlayerEnterWorld(PlayerEvent event) { | ||
final Player player = event.getPlayer(); | ||
World world = getNormalWorld(player.getWorld()); | ||
|
||
if (getHardcoreWorldsList().isHardcore(world)) { | ||
getPlayersList().createPlayer(player, world); | ||
} else { | ||
return; | ||
} | ||
HardcoreWorldsList.HardcoreWorldInfo worldInfo = getHardcoreWorldsList().getHardcoreWorldInfo(world); | ||
PlayersList.PlayerInfo playerInfo = getPlayersList().getPlayerInfo(player, world); | ||
if (playerInfo.isDeathBanned() && (!player.isOp() || worldInfo.banOps)) { | ||
if (playerInfo.isBannedForever()) { | ||
player.sendMessage(getPrefix() + "You can't play in this world since you died"); | ||
} else { | ||
player.sendMessage(getPrefix() + "You can't play in this world now. You'll be able to join again" + | ||
" on " + playerInfo.getUnBanDate()); | ||
} | ||
|
||
Bukkit.getServer().getScheduler().scheduleSyncDelayedTask(this, new Runnable() { | ||
public void run() { | ||
if (worldInfo.spectatorMode) { | ||
player.setGameMode(GameMode.SPECTATOR); | ||
} else { | ||
if (!spawnPlayer(player)) { | ||
player.setGameMode(GameMode.SPECTATOR); | ||
} | ||
} | ||
} | ||
}, 2); | ||
} else { | ||
player.sendMessage(getPrefix() + "You are entering a HARDCORE world, be careful!"); | ||
} | ||
} | ||
|
||
public boolean isOp(CommandSender sender) { | ||
return !(sender instanceof Player) || sender.isOp(); | ||
} | ||
} |
45 changes: 45 additions & 0 deletions
45
src/main/java/life/lluis/multiversehardcore/commands/HelpCommand.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,45 @@ | ||
package life.lluis.multiversehardcore.commands; | ||
|
||
import life.lluis.multiversehardcore.MultiverseHardcore; | ||
import org.bukkit.ChatColor; | ||
import org.bukkit.command.Command; | ||
import org.bukkit.command.CommandExecutor; | ||
import org.bukkit.command.CommandSender; | ||
import org.jetbrains.annotations.NotNull; | ||
|
||
public class HelpCommand implements CommandExecutor { | ||
|
||
public static void printHelpDialog(@NotNull CommandSender sender) { | ||
MultiverseHardcore plugin = MultiverseHardcore.getInstance(); | ||
sender.sendMessage("Available commands: "); | ||
if (plugin.isOp(sender)) { | ||
sender.sendMessage(ChatColor.BLUE + "/mvhc" + ChatColor.GREEN + " create" + ChatColor.RED + " <world>" + | ||
ChatColor.GOLD + " <spectator_mode> <create_nether> <create_end> <ban_ops> <ban_forever> <ban_length> " + | ||
"<include_nether> <include_end> <respawn_world>"); | ||
sender.sendMessage(ChatColor.BLUE + "/mvhc" + ChatColor.GREEN + " makehc" + ChatColor.RED + " <world>" + | ||
ChatColor.GOLD + " <spectator_mode> <ban_ops> <ban_forever> <ban_length> " + | ||
"<include_nether> <include_end> <respawn_world>"); | ||
} | ||
if (plugin.isOp(sender)) { | ||
sender.sendMessage(ChatColor.BLUE + "/mvhc" + ChatColor.GREEN + " player" + ChatColor.GOLD + " <world> " + | ||
"<player>"); | ||
} else { | ||
sender.sendMessage(ChatColor.BLUE + "/mvhc" + ChatColor.GREEN + " player"); | ||
} | ||
if (plugin.isOp(sender)) { | ||
sender.sendMessage(ChatColor.BLUE + "/mvhc" + ChatColor.GREEN + " world" + ChatColor.RED + " <world>"); | ||
} else { | ||
sender.sendMessage(ChatColor.BLUE + "/mvhc" + ChatColor.GREEN + " world"); | ||
} | ||
if (plugin.isOp(sender)) { | ||
sender.sendMessage(ChatColor.BLUE + "/mvhc" + ChatColor.GREEN + " worlds"); | ||
sender.sendMessage(ChatColor.BLUE + "/mvhc" + ChatColor.GREEN + " version"); | ||
} | ||
sender.sendMessage(ChatColor.RESET + ""); | ||
} | ||
|
||
public boolean onCommand(@NotNull CommandSender sender, @NotNull Command command, @NotNull String label, String[] args) { | ||
printHelpDialog(sender); | ||
return true; | ||
} | ||
} |
Oops, something went wrong.