From 2665dda11a6291ba114a98825f50d849a095b1b9 Mon Sep 17 00:00:00 2001 From: Jimmy Allen Date: Fri, 27 Jul 2018 01:38:45 +1200 Subject: [PATCH 1/7] Fixed pom --- pom.xml | 28 ---------------------------- 1 file changed, 28 deletions(-) diff --git a/pom.xml b/pom.xml index d544e6a..ece7295 100644 --- a/pom.xml +++ b/pom.xml @@ -81,31 +81,3 @@ - - - - - - - - - spigot-repo - https://hub.spigotmc.org/nexus/content/repositories/snapshots/ - - - - - - org.spigotmc - spigot-api - 1.13-R0.1-SNAPSHOT - provided - - - - org.bukkit - bukkit - 1.13-R0.1-SNAPSHOT - provided - - \ No newline at end of file From 975805a6ff03d351c2505ccb533110af21cf9817 Mon Sep 17 00:00:00 2001 From: Jimmy Allen Date: Fri, 27 Jul 2018 01:42:01 +1200 Subject: [PATCH 2/7] Changed package domain --- .classpath | 49 +++++++++++++++++++ .project | 23 +++++++++ .settings/org.eclipse.core.resources.prefs | 4 ++ .settings/org.eclipse.jdt.apt.core.prefs | 2 + .settings/org.eclipse.jdt.core.prefs | 7 +++ .settings/org.eclipse.m2e.core.prefs | 4 ++ .../{1248 => jimmy}/easyspawn/EasySpawn.java | 0 7 files changed, 89 insertions(+) create mode 100644 .classpath create mode 100644 .project create mode 100644 .settings/org.eclipse.core.resources.prefs create mode 100644 .settings/org.eclipse.jdt.apt.core.prefs create mode 100644 .settings/org.eclipse.jdt.core.prefs create mode 100644 .settings/org.eclipse.m2e.core.prefs rename src/main/java/nz/{1248 => jimmy}/easyspawn/EasySpawn.java (100%) diff --git a/.classpath b/.classpath new file mode 100644 index 0000000..1a99fc8 --- /dev/null +++ b/.classpath @@ -0,0 +1,49 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/.project b/.project new file mode 100644 index 0000000..3b2c77b --- /dev/null +++ b/.project @@ -0,0 +1,23 @@ + + + EasySpawn + + + + + + org.eclipse.jdt.core.javabuilder + + + + + org.eclipse.m2e.core.maven2Builder + + + + + + org.eclipse.jdt.core.javanature + org.eclipse.m2e.core.maven2Nature + + diff --git a/.settings/org.eclipse.core.resources.prefs b/.settings/org.eclipse.core.resources.prefs new file mode 100644 index 0000000..abdea9a --- /dev/null +++ b/.settings/org.eclipse.core.resources.prefs @@ -0,0 +1,4 @@ +eclipse.preferences.version=1 +encoding//src/main/java=UTF-8 +encoding//src/main/resources=UTF-8 +encoding/=UTF-8 diff --git a/.settings/org.eclipse.jdt.apt.core.prefs b/.settings/org.eclipse.jdt.apt.core.prefs new file mode 100644 index 0000000..d4313d4 --- /dev/null +++ b/.settings/org.eclipse.jdt.apt.core.prefs @@ -0,0 +1,2 @@ +eclipse.preferences.version=1 +org.eclipse.jdt.apt.aptEnabled=false diff --git a/.settings/org.eclipse.jdt.core.prefs b/.settings/org.eclipse.jdt.core.prefs new file mode 100644 index 0000000..1eb325e --- /dev/null +++ b/.settings/org.eclipse.jdt.core.prefs @@ -0,0 +1,7 @@ +eclipse.preferences.version=1 +org.eclipse.jdt.core.compiler.codegen.targetPlatform=1.7 +org.eclipse.jdt.core.compiler.compliance=1.7 +org.eclipse.jdt.core.compiler.problem.forbiddenReference=warning +org.eclipse.jdt.core.compiler.processAnnotations=disabled +org.eclipse.jdt.core.compiler.release=disabled +org.eclipse.jdt.core.compiler.source=1.7 diff --git a/.settings/org.eclipse.m2e.core.prefs b/.settings/org.eclipse.m2e.core.prefs new file mode 100644 index 0000000..f897a7f --- /dev/null +++ b/.settings/org.eclipse.m2e.core.prefs @@ -0,0 +1,4 @@ +activeProfiles= +eclipse.preferences.version=1 +resolveWorkspaceProjects=true +version=1 diff --git a/src/main/java/nz/1248/easyspawn/EasySpawn.java b/src/main/java/nz/jimmy/easyspawn/EasySpawn.java similarity index 100% rename from src/main/java/nz/1248/easyspawn/EasySpawn.java rename to src/main/java/nz/jimmy/easyspawn/EasySpawn.java From 57e88eba28252325d019dd13f1d4f776e6f3ace4 Mon Sep 17 00:00:00 2001 From: Jimmy Allen Date: Fri, 27 Jul 2018 01:45:00 +1200 Subject: [PATCH 3/7] Updated gitignore and removed files and folder --- .classpath | 49 ---------------------- .gitignore | 3 ++ .project | 23 ---------- .settings/org.eclipse.core.resources.prefs | 4 -- .settings/org.eclipse.jdt.apt.core.prefs | 2 - .settings/org.eclipse.jdt.core.prefs | 7 ---- .settings/org.eclipse.m2e.core.prefs | 4 -- 7 files changed, 3 insertions(+), 89 deletions(-) delete mode 100644 .classpath delete mode 100644 .project delete mode 100644 .settings/org.eclipse.core.resources.prefs delete mode 100644 .settings/org.eclipse.jdt.apt.core.prefs delete mode 100644 .settings/org.eclipse.jdt.core.prefs delete mode 100644 .settings/org.eclipse.m2e.core.prefs diff --git a/.classpath b/.classpath deleted file mode 100644 index 1a99fc8..0000000 --- a/.classpath +++ /dev/null @@ -1,49 +0,0 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - diff --git a/.gitignore b/.gitignore index e221405..020f764 100644 --- a/.gitignore +++ b/.gitignore @@ -8,3 +8,6 @@ target/ .vscode/ server/ +.settings +.project +.classpath \ No newline at end of file diff --git a/.project b/.project deleted file mode 100644 index 3b2c77b..0000000 --- a/.project +++ /dev/null @@ -1,23 +0,0 @@ - - - EasySpawn - - - - - - org.eclipse.jdt.core.javabuilder - - - - - org.eclipse.m2e.core.maven2Builder - - - - - - org.eclipse.jdt.core.javanature - org.eclipse.m2e.core.maven2Nature - - diff --git a/.settings/org.eclipse.core.resources.prefs b/.settings/org.eclipse.core.resources.prefs deleted file mode 100644 index abdea9a..0000000 --- a/.settings/org.eclipse.core.resources.prefs +++ /dev/null @@ -1,4 +0,0 @@ -eclipse.preferences.version=1 -encoding//src/main/java=UTF-8 -encoding//src/main/resources=UTF-8 -encoding/=UTF-8 diff --git a/.settings/org.eclipse.jdt.apt.core.prefs b/.settings/org.eclipse.jdt.apt.core.prefs deleted file mode 100644 index d4313d4..0000000 --- a/.settings/org.eclipse.jdt.apt.core.prefs +++ /dev/null @@ -1,2 +0,0 @@ -eclipse.preferences.version=1 -org.eclipse.jdt.apt.aptEnabled=false diff --git a/.settings/org.eclipse.jdt.core.prefs b/.settings/org.eclipse.jdt.core.prefs deleted file mode 100644 index 1eb325e..0000000 --- a/.settings/org.eclipse.jdt.core.prefs +++ /dev/null @@ -1,7 +0,0 @@ -eclipse.preferences.version=1 -org.eclipse.jdt.core.compiler.codegen.targetPlatform=1.7 -org.eclipse.jdt.core.compiler.compliance=1.7 -org.eclipse.jdt.core.compiler.problem.forbiddenReference=warning -org.eclipse.jdt.core.compiler.processAnnotations=disabled -org.eclipse.jdt.core.compiler.release=disabled -org.eclipse.jdt.core.compiler.source=1.7 diff --git a/.settings/org.eclipse.m2e.core.prefs b/.settings/org.eclipse.m2e.core.prefs deleted file mode 100644 index f897a7f..0000000 --- a/.settings/org.eclipse.m2e.core.prefs +++ /dev/null @@ -1,4 +0,0 @@ -activeProfiles= -eclipse.preferences.version=1 -resolveWorkspaceProjects=true -version=1 From 1105385d877fbe8481d8c9a5733a52a8deb02466 Mon Sep 17 00:00:00 2001 From: Jimmy Allen Date: Fri, 27 Jul 2018 01:46:32 +1200 Subject: [PATCH 4/7] Removed server.properties --- .gitignore | 2 -- server.properties | 2 -- 2 files changed, 4 deletions(-) delete mode 100644 server.properties diff --git a/.gitignore b/.gitignore index 020f764..fb9fff4 100644 --- a/.gitignore +++ b/.gitignore @@ -1,6 +1,4 @@ *.class - -# Package Files # *.jar *.war *.ear diff --git a/server.properties b/server.properties deleted file mode 100644 index 3533037..0000000 --- a/server.properties +++ /dev/null @@ -1,2 +0,0 @@ -#Minecraft server properties -#Thu Jul 26 07:47:14 GMT 2018 From ba8b380b4de10d4e52c56999abd8f8abeedc5a3e Mon Sep 17 00:00:00 2001 From: Jimmy Allen Date: Fri, 27 Jul 2018 02:27:06 +1200 Subject: [PATCH 5/7] Now storing spawn locations in config.yml --- pom.xml | 1 + .../java/nz/jimmy/easyspawn/EasySpawn.java | 33 +++++++++++++++---- 2 files changed, 28 insertions(+), 6 deletions(-) diff --git a/pom.xml b/pom.xml index ece7295..3a07345 100644 --- a/pom.xml +++ b/pom.xml @@ -55,6 +55,7 @@ true plugin.yml + config.yml diff --git a/src/main/java/nz/jimmy/easyspawn/EasySpawn.java b/src/main/java/nz/jimmy/easyspawn/EasySpawn.java index 5394de4..0d0f9e2 100644 --- a/src/main/java/nz/jimmy/easyspawn/EasySpawn.java +++ b/src/main/java/nz/jimmy/easyspawn/EasySpawn.java @@ -4,7 +4,8 @@ import org.bukkit.command.Command; import org.bukkit.command.CommandSender; import org.bukkit.entity.Player; import org.bukkit.plugin.java.JavaPlugin; - +import org.bukkit.Location; +import org.bukkit.World; public class EasySpawn extends JavaPlugin{ @Override @@ -12,22 +13,42 @@ public class EasySpawn extends JavaPlugin{ String label, String[] args) { if(sender instanceof Player){ Player player = (Player)sender; + + //Spawn if(command.getName().equalsIgnoreCase("spawn")){ - player.teleport(player.getWorld().getSpawnLocation()); - player.sendMessage("You have been teleported to spawn."); + World world = player.getWorld(); + String w = world.getName(); + if(getConfig().contains("spawn."+w)) { + int x = getConfig().getInt("spawn."+w+".x"); + int y = getConfig().getInt("spawn."+w+".y"); + int z = getConfig().getInt("spawn."+w+".z"); + float pitch = getConfig().getInt("spawn."+w+".pitch"); + float yaw = getConfig().getInt("spawn."+w+".yaw"); + player.teleport(new Location(world, x, y, z, yaw, pitch)); + player.sendMessage("You have been teleported to spawn."); + } return true; } + + //Setspawn if(command.getName().equalsIgnoreCase("setspawn")){ - player.getWorld().setSpawnLocation(player.getLocation().getBlockX(), - player.getLocation().getBlockY(),player.getLocation().getBlockZ()); + Location location = player.getLocation(); + String world = player.getWorld().getName(); + getConfig().set("spawn."+world+".x", location.getBlockX()); + getConfig().set("spawn."+world+".y", location.getBlockY()); + getConfig().set("spawn."+world+".z", location.getBlockZ()); + getConfig().set("spawn."+world+".pitch", location.getPitch()); + getConfig().set("spawn."+world+".yaw", location.getYaw()); player.sendMessage("Spawn set."); return true; } + + //Bed if(command.getName().equalsIgnoreCase("bed")){ if(player.getBedSpawnLocation()!=null){ player.teleport(player.getBedSpawnLocation()); player.sendMessage("You have been teleported to your bed."); - }else sender.sendMessage("Your bed cannot be found."); + }else sender.sendMessage("You need to sleep in a bed first."); return true; } } From 189eb7492acd50809a90fc7d98bb8b62791cdb81 Mon Sep 17 00:00:00 2001 From: Jimmy Allen Date: Fri, 27 Jul 2018 03:06:11 +1200 Subject: [PATCH 6/7] Tested plugin --- src/main/java/nz/jimmy/easyspawn/EasySpawn.java | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/src/main/java/nz/jimmy/easyspawn/EasySpawn.java b/src/main/java/nz/jimmy/easyspawn/EasySpawn.java index 0d0f9e2..b0dfe73 100644 --- a/src/main/java/nz/jimmy/easyspawn/EasySpawn.java +++ b/src/main/java/nz/jimmy/easyspawn/EasySpawn.java @@ -18,7 +18,7 @@ public class EasySpawn extends JavaPlugin{ if(command.getName().equalsIgnoreCase("spawn")){ World world = player.getWorld(); String w = world.getName(); - if(getConfig().contains("spawn."+w)) { + if(getConfig().contains("spawn."+w)){ int x = getConfig().getInt("spawn."+w+".x"); int y = getConfig().getInt("spawn."+w+".y"); int z = getConfig().getInt("spawn."+w+".z"); @@ -26,7 +26,7 @@ public class EasySpawn extends JavaPlugin{ float yaw = getConfig().getInt("spawn."+w+".yaw"); player.teleport(new Location(world, x, y, z, yaw, pitch)); player.sendMessage("You have been teleported to spawn."); - } + }else{ player.sendMessage("This world has no spawn");} return true; } @@ -39,6 +39,7 @@ public class EasySpawn extends JavaPlugin{ getConfig().set("spawn."+world+".z", location.getBlockZ()); getConfig().set("spawn."+world+".pitch", location.getPitch()); getConfig().set("spawn."+world+".yaw", location.getYaw()); + saveConfig(); player.sendMessage("Spawn set."); return true; } From 69a1000d77410db08a9b7014678b9a84156554fe Mon Sep 17 00:00:00 2001 From: Jimmy Allen Date: Fri, 27 Jul 2018 14:10:08 +1200 Subject: [PATCH 7/7] When player first joins they will be teleported to the set spawn Changed permission error messages --- .../java/nz/jimmy/easyspawn/EasySpawn.java | 31 +++++++++++++++++-- src/main/resources/plugin.yml | 6 ++-- 2 files changed, 32 insertions(+), 5 deletions(-) diff --git a/src/main/java/nz/jimmy/easyspawn/EasySpawn.java b/src/main/java/nz/jimmy/easyspawn/EasySpawn.java index b0dfe73..4c50a2e 100644 --- a/src/main/java/nz/jimmy/easyspawn/EasySpawn.java +++ b/src/main/java/nz/jimmy/easyspawn/EasySpawn.java @@ -3,10 +3,17 @@ package nz.jimmy.easyspawn; import org.bukkit.command.Command; import org.bukkit.command.CommandSender; import org.bukkit.entity.Player; +import org.bukkit.event.EventHandler; +import org.bukkit.event.Listener; +import org.bukkit.event.player.PlayerJoinEvent; import org.bukkit.plugin.java.JavaPlugin; import org.bukkit.Location; import org.bukkit.World; -public class EasySpawn extends JavaPlugin{ +public class EasySpawn extends JavaPlugin implements Listener{ + @Override + public void onEnable(){ + getServer().getPluginManager().registerEvents(this, this); + } @Override public boolean onCommand(CommandSender sender, Command command, @@ -18,6 +25,7 @@ public class EasySpawn extends JavaPlugin{ if(command.getName().equalsIgnoreCase("spawn")){ World world = player.getWorld(); String w = world.getName(); + //Check is spawn is set if(getConfig().contains("spawn."+w)){ int x = getConfig().getInt("spawn."+w+".x"); int y = getConfig().getInt("spawn."+w+".y"); @@ -26,7 +34,7 @@ public class EasySpawn extends JavaPlugin{ float yaw = getConfig().getInt("spawn."+w+".yaw"); player.teleport(new Location(world, x, y, z, yaw, pitch)); player.sendMessage("You have been teleported to spawn."); - }else{ player.sendMessage("This world has no spawn");} + }else player.sendMessage("This world has no spawn"); return true; } @@ -46,6 +54,7 @@ public class EasySpawn extends JavaPlugin{ //Bed if(command.getName().equalsIgnoreCase("bed")){ + //Check if player has a bed if(player.getBedSpawnLocation()!=null){ player.teleport(player.getBedSpawnLocation()); player.sendMessage("You have been teleported to your bed."); @@ -56,4 +65,22 @@ public class EasySpawn extends JavaPlugin{ return false; } + @EventHandler + public void onPlayerJoin(PlayerJoinEvent event) { + Player player = event.getPlayer(); + if(!player.hasPlayedBefore()){ + World world = player.getWorld(); + String w = world.getName(); + //Check is spawn is set + if(getConfig().contains("spawn."+w)){ + int x = getConfig().getInt("spawn."+w+".x"); + int y = getConfig().getInt("spawn."+w+".y"); + int z = getConfig().getInt("spawn."+w+".z"); + float pitch = getConfig().getInt("spawn."+w+".pitch"); + float yaw = getConfig().getInt("spawn."+w+".yaw"); + player.teleport(new Location(world, x, y, z, yaw, pitch)); + } + } + } + } diff --git a/src/main/resources/plugin.yml b/src/main/resources/plugin.yml index 8a18c81..98ad750 100644 --- a/src/main/resources/plugin.yml +++ b/src/main/resources/plugin.yml @@ -10,17 +10,17 @@ commands: description: Teleports you to spawn usage: /spawn permission: easyspawn.spawn - permission-message: You don't have + permission-message: You are not allowed bed: description: Teleports you to your bed usage: /bed permission: easyspawn.bed - permission-message: You don't have + permission-message: You are not allowed setspawn: description: Sets spawn location usage: /setspawn permission: easyspawn.setspawn - permission-message: You don't have + permission-message: You are not allowed permissions: easyspawn.spawn: description: Teleports you to spawn