-
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.
- Loading branch information
0 parents
commit bf1b7da
Showing
24 changed files
with
475 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,7 @@ | ||
{ | ||
"files.autoGuessEncoding": true, | ||
"files.encoding": "utf8", | ||
"java.jdt.ls.vmargs": "-Dfile.encoding=UTF-8", | ||
"javac-linter.javac": "javac -Dfile.encoding=UTF-8", | ||
"java.compile.nullAnalysis.mode": "automatic" | ||
} |
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,93 @@ | ||
<?xml version="1.0" encoding="UTF-8"?> | ||
|
||
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" | ||
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>com.nico</groupId> | ||
<artifactId>hardcore</artifactId> | ||
<version>1.0-SNAPSHOT</version> | ||
|
||
<name>hardcore</name> | ||
<!-- FIXME change it to the project's website --> | ||
<url>http://www.example.com</url> | ||
|
||
<properties> | ||
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding> | ||
<maven.compiler.source>1.7</maven.compiler.source> | ||
<maven.compiler.target>1.7</maven.compiler.target> | ||
</properties> | ||
|
||
<repositories> | ||
<!-- This adds the Spigot Maven repository to the build --> | ||
<repository> | ||
<id>spigot-repo</id> | ||
<url>https://hub.spigotmc.org/nexus/content/repositories/snapshots/</url> | ||
</repository> | ||
</repositories> | ||
|
||
<dependencies> | ||
<!--This adds the Spigot API artifact to the build --> | ||
<dependency> | ||
<groupId>org.spigotmc</groupId> | ||
<artifactId>spigot-api</artifactId> | ||
<version>1.20.1-R0.1-SNAPSHOT</version> | ||
<scope>provided</scope> | ||
</dependency> | ||
|
||
|
||
|
||
<dependency> | ||
<groupId>junit</groupId> | ||
<artifactId>junit</artifactId> | ||
<version>4.11</version> | ||
<scope>test</scope> | ||
</dependency> | ||
</dependencies> | ||
|
||
<build> | ||
<pluginManagement><!-- lock down plugins versions to avoid using Maven defaults (may be moved to parent pom) --> | ||
<plugins> | ||
<!-- clean lifecycle, see https://maven.apache.org/ref/current/maven-core/lifecycles.html#clean_Lifecycle --> | ||
<plugin> | ||
<artifactId>maven-clean-plugin</artifactId> | ||
<version>3.1.0</version> | ||
</plugin> | ||
<!-- default lifecycle, jar packaging: see https://maven.apache.org/ref/current/maven-core/default-bindings.html#Plugin_bindings_for_jar_packaging --> | ||
<plugin> | ||
<artifactId>maven-resources-plugin</artifactId> | ||
<version>3.0.2</version> | ||
</plugin> | ||
<plugin> | ||
<artifactId>maven-compiler-plugin</artifactId> | ||
<version>3.8.0</version> | ||
</plugin> | ||
<plugin> | ||
<artifactId>maven-surefire-plugin</artifactId> | ||
<version>2.22.1</version> | ||
</plugin> | ||
<plugin> | ||
<artifactId>maven-jar-plugin</artifactId> | ||
<version>3.0.2</version> | ||
</plugin> | ||
<plugin> | ||
<artifactId>maven-install-plugin</artifactId> | ||
<version>2.5.2</version> | ||
</plugin> | ||
<plugin> | ||
<artifactId>maven-deploy-plugin</artifactId> | ||
<version>2.8.2</version> | ||
</plugin> | ||
<!-- site lifecycle, see https://maven.apache.org/ref/current/maven-core/lifecycles.html#site_Lifecycle --> | ||
<plugin> | ||
<artifactId>maven-site-plugin</artifactId> | ||
<version>3.7.1</version> | ||
</plugin> | ||
<plugin> | ||
<artifactId>maven-project-info-reports-plugin</artifactId> | ||
<version>3.0.0</version> | ||
</plugin> | ||
</plugins> | ||
</pluginManagement> | ||
</build> | ||
</project> |
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,55 @@ | ||
package com.nico.hardcore; | ||
|
||
import org.bukkit.plugin.java.JavaPlugin; | ||
import com.nico.hardcore.Commands.Death; | ||
import com.nico.hardcore.Events.OnDeath; | ||
|
||
/** | ||
* Hello world! | ||
* | ||
*/ | ||
public class App extends JavaPlugin | ||
{ | ||
|
||
public static String currentWorldname = "world"; | ||
private static App instance; | ||
|
||
|
||
@Override | ||
public void onEnable() | ||
{ | ||
getLogger().info("[Hardcore-Multiplayer] Plugin enabled!"); | ||
instance = this; | ||
|
||
this.getCommand("death").setExecutor(new Death()); | ||
getServer().getPluginManager().registerEvents(new OnDeath(), this); | ||
|
||
this.getConfig().getString("current World"); | ||
} | ||
@Override | ||
public void onDisable() | ||
{ | ||
getLogger().info("[Hardcore-Multiplayer] Plugin disabled!"); | ||
} | ||
|
||
public static App getInstance() { | ||
return instance; | ||
} | ||
|
||
public static void main( String[] args ) | ||
{ | ||
System.out.println( "Hello World!" ); | ||
|
||
|
||
} | ||
|
||
|
||
public static String getCurrentWorldname() { | ||
return currentWorldname; | ||
} | ||
|
||
public static void setCurrentWorldname(String currentWorldname) { | ||
App.currentWorldname = currentWorldname; | ||
} | ||
|
||
} |
126 changes: 126 additions & 0 deletions
126
hardcore/src/main/java/com/nico/hardcore/Commands/Death.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,126 @@ | ||
package com.nico.hardcore.Commands; | ||
|
||
import java.text.SimpleDateFormat; | ||
import java.util.Date; | ||
import org.bukkit.Bukkit; | ||
import org.bukkit.Sound; | ||
import org.bukkit.World; | ||
import org.bukkit.WorldCreator; | ||
import org.bukkit.command.Command; | ||
import org.bukkit.command.CommandExecutor; | ||
import org.bukkit.command.CommandSender; | ||
import org.bukkit.entity.Player; | ||
import org.bukkit.potion.PotionEffect; | ||
import org.bukkit.potion.PotionEffectType; | ||
import org.bukkit.scheduler.BukkitRunnable; | ||
import com.nico.hardcore.App; | ||
|
||
public class Death implements CommandExecutor | ||
{ | ||
|
||
static boolean deathsentence = false; | ||
|
||
|
||
@Override | ||
public boolean onCommand(CommandSender sender, Command command, String label, String[] args) { | ||
// TODO Auto-generated method stub | ||
|
||
sender.sendMessage("OK"); | ||
death((Player) sender); | ||
return true; | ||
} | ||
|
||
public static void death(Player player) | ||
{ | ||
|
||
if(deathsentence == false) | ||
{ | ||
deathsentence = true; | ||
|
||
final World currentworld = player.getWorld(); | ||
|
||
for (Player players : Bukkit.getOnlinePlayers()) { | ||
players.sendTitle("§4" + player.getName() + "§f ist gestorben.", "§a Welt wird neu generiert", 1, 400, 100); | ||
players.playSound(player.getLocation(), Sound.ENTITY_WITHER_SPAWN, 0.5f, 0f); | ||
PotionEffect blindnessEffect = new PotionEffect(PotionEffectType.BLINDNESS, 500, 1); | ||
players.getInventory().clear(); | ||
players.setExp(0); | ||
players.setHealth(players.getMaxHealth()); | ||
players.addPotionEffect(blindnessEffect); | ||
|
||
} | ||
|
||
Bukkit.getScheduler().runTaskLater(App.getInstance(), new Runnable() | ||
{ | ||
|
||
@Override | ||
public void run() | ||
{ | ||
|
||
SimpleDateFormat dateFormat = new SimpleDateFormat("yyyyMMddHHmmss"); | ||
|
||
|
||
Date date = new Date(); | ||
String formatiertesDatum = dateFormat.format(date); | ||
|
||
Bukkit.createWorld(WorldCreator.name(formatiertesDatum)); | ||
|
||
World world = Bukkit.getWorld(formatiertesDatum); | ||
|
||
|
||
//Eventuell break | ||
App.getInstance().getConfig().set("current World", formatiertesDatum); | ||
App.setCurrentWorldname(formatiertesDatum); | ||
for (Player players : Bukkit.getOnlinePlayers()) | ||
{ | ||
//players.setHealth(players.getMaxHealth()); | ||
//players.getInventory().clear(); | ||
//players.setExp(0); | ||
|
||
players.setBedSpawnLocation(world.getSpawnLocation(), true); | ||
players.teleport(world.getSpawnLocation()); | ||
players.getInventory().clear(); | ||
players.setFoodLevel(50); | ||
players.setHealth(players.getMaxHealth()); | ||
if(players.hasPotionEffect(PotionEffectType.BLINDNESS)) | ||
{ | ||
players.removePotionEffect(PotionEffectType.BLINDNESS); | ||
} | ||
players.setFireTicks(0); | ||
|
||
} | ||
|
||
|
||
Bukkit.getServer().unloadWorld(currentworld, true); | ||
deathsentence = false; | ||
|
||
|
||
|
||
|
||
} | ||
}, 100L); | ||
|
||
|
||
|
||
} | ||
|
||
|
||
|
||
|
||
|
||
|
||
/* Bukkit.createWorld(WorldCreator.name("world2")); | ||
Bukkit.broadcastMessage("Finished Creating World"); | ||
for (Player onlinePlayer : Bukkit.getOnlinePlayers()) | ||
{ | ||
onlinePlayer.teleport(Bukkit.getWorld("world2").getSpawnLocation()); | ||
} | ||
Bukkit.broadcastMessage("Teleport finished"); | ||
*/ | ||
|
||
|
||
} | ||
|
||
|
||
} |
47 changes: 47 additions & 0 deletions
47
hardcore/src/main/java/com/nico/hardcore/Events/OnDeath.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,47 @@ | ||
package com.nico.hardcore.Events; | ||
|
||
import java.net.http.WebSocket.Listener; | ||
import org.bukkit.Bukkit; | ||
import org.bukkit.World; | ||
import org.bukkit.entity.Player; | ||
import org.bukkit.event.EventHandler; | ||
import org.bukkit.event.entity.PlayerDeathEvent; | ||
import org.bukkit.event.player.PlayerJoinEvent; | ||
import org.bukkit.potion.PotionEffect; | ||
import org.bukkit.potion.PotionEffectType; | ||
import com.nico.hardcore.App; | ||
import com.nico.hardcore.Commands.Death; | ||
|
||
public class OnDeath implements Listener, org.bukkit.event.Listener | ||
{ | ||
@EventHandler | ||
public void onPlayerDeath(PlayerDeathEvent event) | ||
{ | ||
Player died = event.getEntity(); | ||
Death.death(died); | ||
} | ||
|
||
|
||
//Eventuell Break | ||
@EventHandler | ||
public void onPlayerJoin(PlayerJoinEvent event) | ||
{ | ||
if(event.getPlayer().getWorld().getName() != App.currentWorldname) | ||
{ | ||
World currentWorld = Bukkit.getWorld(App.currentWorldname); | ||
if(currentWorld != null) | ||
{ | ||
event.getPlayer().getInventory().clear(); | ||
event.getPlayer().setExp(0); | ||
event.getPlayer().setHealth( event.getPlayer().getMaxHealth()); | ||
event.getPlayer().teleport(currentWorld.getSpawnLocation()); | ||
|
||
} | ||
|
||
} | ||
} | ||
|
||
|
||
|
||
|
||
} |
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,17 @@ | ||
package com.nico.hardcore; | ||
|
||
import org.bukkit.command.Command; | ||
import org.bukkit.command.CommandExecutor; | ||
import org.bukkit.command.CommandSender; | ||
|
||
public class Test implements CommandExecutor | ||
{ | ||
|
||
@Override | ||
public boolean onCommand(CommandSender arg0, Command arg1, String arg2, String[] arg3) { | ||
// TODO Auto-generated method stub | ||
throw new UnsupportedOperationException("Unimplemented method 'onCommand'"); | ||
} | ||
|
||
|
||
} |
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,17 @@ | ||
name: 'Hardcore-Multiplayer' | ||
version: '1.0.0' | ||
main: com.nico.hardcore.App | ||
api-version: '1.20' | ||
|
||
|
||
# Replace "kit" with the name of your command. | ||
commands: | ||
death: | ||
description: Deletes the map and creates a new one. | ||
usage: /death | ||
|
||
|
||
# Set the starter world name. | ||
setting: | ||
current World: world | ||
|
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,20 @@ | ||
package com.nico; | ||
|
||
import static org.junit.Assert.assertTrue; | ||
|
||
import org.junit.Test; | ||
|
||
/** | ||
* Unit test for simple App. | ||
*/ | ||
public class AppTest | ||
{ | ||
/** | ||
* Rigorous Test :-) | ||
*/ | ||
@Test | ||
public void shouldAnswerWithTrue() | ||
{ | ||
assertTrue( true ); | ||
} | ||
} |
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Oops, something went wrong.