diff --git a/.vscode/settings.json b/.vscode/settings.json new file mode 100644 index 0000000..f87ebea --- /dev/null +++ b/.vscode/settings.json @@ -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" +} \ No newline at end of file diff --git a/hardcore/pom.xml b/hardcore/pom.xml new file mode 100644 index 0000000..5257508 --- /dev/null +++ b/hardcore/pom.xml @@ -0,0 +1,93 @@ + + + + 4.0.0 + + com.nico + hardcore + 1.0-SNAPSHOT + + hardcore + + http://www.example.com + + + UTF-8 + 1.7 + 1.7 + + + + + + spigot-repo + https://hub.spigotmc.org/nexus/content/repositories/snapshots/ + + + + + + + org.spigotmc + spigot-api + 1.20.1-R0.1-SNAPSHOT + provided + + + + + + junit + junit + 4.11 + test + + + + + + + + + maven-clean-plugin + 3.1.0 + + + + maven-resources-plugin + 3.0.2 + + + maven-compiler-plugin + 3.8.0 + + + maven-surefire-plugin + 2.22.1 + + + maven-jar-plugin + 3.0.2 + + + maven-install-plugin + 2.5.2 + + + maven-deploy-plugin + 2.8.2 + + + + maven-site-plugin + 3.7.1 + + + maven-project-info-reports-plugin + 3.0.0 + + + + + diff --git a/hardcore/src/main/java/com/nico/hardcore/App.java b/hardcore/src/main/java/com/nico/hardcore/App.java new file mode 100644 index 0000000..4fcf39b --- /dev/null +++ b/hardcore/src/main/java/com/nico/hardcore/App.java @@ -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; + } + +} diff --git a/hardcore/src/main/java/com/nico/hardcore/Commands/Death.java b/hardcore/src/main/java/com/nico/hardcore/Commands/Death.java new file mode 100644 index 0000000..52125bb --- /dev/null +++ b/hardcore/src/main/java/com/nico/hardcore/Commands/Death.java @@ -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"); + */ + + + } + + +} diff --git a/hardcore/src/main/java/com/nico/hardcore/Events/OnDeath.java b/hardcore/src/main/java/com/nico/hardcore/Events/OnDeath.java new file mode 100644 index 0000000..7ff7403 --- /dev/null +++ b/hardcore/src/main/java/com/nico/hardcore/Events/OnDeath.java @@ -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()); + + } + + } + } + + + + +} diff --git a/hardcore/src/main/java/com/nico/hardcore/Test.java b/hardcore/src/main/java/com/nico/hardcore/Test.java new file mode 100644 index 0000000..1d3b320 --- /dev/null +++ b/hardcore/src/main/java/com/nico/hardcore/Test.java @@ -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'"); + } + + +} diff --git a/hardcore/src/main/resources/plugin.yml b/hardcore/src/main/resources/plugin.yml new file mode 100644 index 0000000..84e23fa --- /dev/null +++ b/hardcore/src/main/resources/plugin.yml @@ -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 + \ No newline at end of file diff --git a/hardcore/src/test/java/com/nico/AppTest.java b/hardcore/src/test/java/com/nico/AppTest.java new file mode 100644 index 0000000..f6658ec --- /dev/null +++ b/hardcore/src/test/java/com/nico/AppTest.java @@ -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 ); + } +} diff --git a/hardcore/target/classes/com/nico/hardcore/App.class b/hardcore/target/classes/com/nico/hardcore/App.class new file mode 100644 index 0000000..d01144a Binary files /dev/null and b/hardcore/target/classes/com/nico/hardcore/App.class differ diff --git a/hardcore/target/classes/com/nico/hardcore/Commands/Death$1.class b/hardcore/target/classes/com/nico/hardcore/Commands/Death$1.class new file mode 100644 index 0000000..1168fa6 Binary files /dev/null and b/hardcore/target/classes/com/nico/hardcore/Commands/Death$1.class differ diff --git a/hardcore/target/classes/com/nico/hardcore/Commands/Death.class b/hardcore/target/classes/com/nico/hardcore/Commands/Death.class new file mode 100644 index 0000000..4ce975b Binary files /dev/null and b/hardcore/target/classes/com/nico/hardcore/Commands/Death.class differ diff --git a/hardcore/target/classes/com/nico/hardcore/Events/OnDeath.class b/hardcore/target/classes/com/nico/hardcore/Events/OnDeath.class new file mode 100644 index 0000000..3524719 Binary files /dev/null and b/hardcore/target/classes/com/nico/hardcore/Events/OnDeath.class differ diff --git a/hardcore/target/classes/com/nico/hardcore/Test.class b/hardcore/target/classes/com/nico/hardcore/Test.class new file mode 100644 index 0000000..c231c84 Binary files /dev/null and b/hardcore/target/classes/com/nico/hardcore/Test.class differ diff --git a/hardcore/target/classes/plugin.yml b/hardcore/target/classes/plugin.yml new file mode 100644 index 0000000..84e23fa --- /dev/null +++ b/hardcore/target/classes/plugin.yml @@ -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 + \ No newline at end of file diff --git a/hardcore/target/hardcore-1.0-SNAPSHOT.jar b/hardcore/target/hardcore-1.0-SNAPSHOT.jar new file mode 100644 index 0000000..4d8bbc7 Binary files /dev/null and b/hardcore/target/hardcore-1.0-SNAPSHOT.jar differ diff --git a/hardcore/target/maven-archiver/pom.properties b/hardcore/target/maven-archiver/pom.properties new file mode 100644 index 0000000..a7d2197 --- /dev/null +++ b/hardcore/target/maven-archiver/pom.properties @@ -0,0 +1,4 @@ +#Created by Apache Maven 3.6.3 +groupId=com.nico +artifactId=hardcore +version=1.0-SNAPSHOT diff --git a/hardcore/target/maven-status/maven-compiler-plugin/compile/default-compile/createdFiles.lst b/hardcore/target/maven-status/maven-compiler-plugin/compile/default-compile/createdFiles.lst new file mode 100644 index 0000000..e69de29 diff --git a/hardcore/target/maven-status/maven-compiler-plugin/compile/default-compile/inputFiles.lst b/hardcore/target/maven-status/maven-compiler-plugin/compile/default-compile/inputFiles.lst new file mode 100644 index 0000000..84dea49 --- /dev/null +++ b/hardcore/target/maven-status/maven-compiler-plugin/compile/default-compile/inputFiles.lst @@ -0,0 +1,4 @@ +c:\Users\Nico\Desktop\Minecraft Hardcore Plugin\hardcore\hardcore\src\main\java\com\nico\hardcore\Events\OnDeath.java +c:\Users\Nico\Desktop\Minecraft Hardcore Plugin\hardcore\hardcore\src\main\java\com\nico\hardcore\App.java +c:\Users\Nico\Desktop\Minecraft Hardcore Plugin\hardcore\hardcore\src\main\java\com\nico\hardcore\Test.java +c:\Users\Nico\Desktop\Minecraft Hardcore Plugin\hardcore\hardcore\src\main\java\com\nico\hardcore\Commands\Death.java diff --git a/hardcore/target/maven-status/maven-compiler-plugin/testCompile/default-testCompile/createdFiles.lst b/hardcore/target/maven-status/maven-compiler-plugin/testCompile/default-testCompile/createdFiles.lst new file mode 100644 index 0000000..66b5da3 --- /dev/null +++ b/hardcore/target/maven-status/maven-compiler-plugin/testCompile/default-testCompile/createdFiles.lst @@ -0,0 +1 @@ +com\nico\AppTest.class diff --git a/hardcore/target/maven-status/maven-compiler-plugin/testCompile/default-testCompile/inputFiles.lst b/hardcore/target/maven-status/maven-compiler-plugin/testCompile/default-testCompile/inputFiles.lst new file mode 100644 index 0000000..dcc3ef3 --- /dev/null +++ b/hardcore/target/maven-status/maven-compiler-plugin/testCompile/default-testCompile/inputFiles.lst @@ -0,0 +1 @@ +c:\Users\Nico\Desktop\Minecraft Hardcore Plugin\hardcore\hardcore\src\test\java\com\nico\AppTest.java diff --git a/hardcore/target/surefire-reports/TEST-com.nico.AppTest.xml b/hardcore/target/surefire-reports/TEST-com.nico.AppTest.xml new file mode 100644 index 0000000..01b2675 --- /dev/null +++ b/hardcore/target/surefire-reports/TEST-com.nico.AppTest.xml @@ -0,0 +1,61 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/hardcore/target/surefire-reports/com.nico.AppTest.txt b/hardcore/target/surefire-reports/com.nico.AppTest.txt new file mode 100644 index 0000000..78be435 --- /dev/null +++ b/hardcore/target/surefire-reports/com.nico.AppTest.txt @@ -0,0 +1,4 @@ +------------------------------------------------------------------------------- +Test set: com.nico.AppTest +------------------------------------------------------------------------------- +Tests run: 1, Failures: 0, Errors: 0, Skipped: 0, Time elapsed: 0.035 s - in com.nico.AppTest diff --git a/hardcore/target/test-classes/com/nico/AppTest.class b/hardcore/target/test-classes/com/nico/AppTest.class new file mode 100644 index 0000000..31e4a78 Binary files /dev/null and b/hardcore/target/test-classes/com/nico/AppTest.class differ diff --git a/project.json b/project.json new file mode 100644 index 0000000..d488f80 --- /dev/null +++ b/project.json @@ -0,0 +1 @@ +{"minecraftVersion":"1.0-SNAPSHOT","groupId":"com.example","artiFactId":"test","pack":"com.example.test","version":"1.0-SNAPSHOT"} \ No newline at end of file