Created
January 12, 2021 14:17
-
-
Save NightSling/0b59ab3535907347a070ba204a85520d to your computer and use it in GitHub Desktop.
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
package mc.crackpixel.net.generator; | |
import com.grinderwolf.swm.api.SlimePlugin; | |
import com.grinderwolf.swm.api.exceptions.CorruptedWorldException; | |
import com.grinderwolf.swm.api.exceptions.NewerFormatException; | |
import com.grinderwolf.swm.api.exceptions.UnknownWorldException; | |
import com.grinderwolf.swm.api.exceptions.WorldInUseException; | |
import com.grinderwolf.swm.api.world.SlimeWorld; | |
import com.grinderwolf.swm.api.world.properties.SlimePropertyMap; | |
import mc.crackpixel.net.Housing; | |
import org.bukkit.Bukkit; | |
import org.bukkit.Location; | |
import org.bukkit.World; | |
import org.bukkit.entity.Player; | |
import org.bukkit.event.EventHandler; | |
import org.bukkit.event.Listener; | |
import org.bukkit.event.player.PlayerJoinEvent; | |
import java.io.IOException; | |
import static org.bukkit.Bukkit.getWorld; | |
public class Generator implements Listener { | |
private Housing plugin; | |
private World hbWorld = getWorld(plugin.getConfig().getString("world")); | |
private SlimePlugin slimePlugin = (SlimePlugin) plugin.getServer().getPluginManager().getPlugin("SlimeWorldManager"); | |
private SlimeWorld slimeWorld; | |
public Generator(Housing plugin) throws CorruptedWorldException, NewerFormatException { | |
this.plugin = plugin; | |
} | |
{ | |
try { | |
slimeWorld = slimePlugin.loadWorld(slimePlugin.getLoader("file"), plugin.getConfig().getString("world"), true, new SlimePropertyMap()); | |
} catch (UnknownWorldException e) { | |
e.printStackTrace(); | |
} catch (WorldInUseException e) { | |
e.printStackTrace(); | |
} catch (IOException e) { | |
e.printStackTrace(); | |
} | |
} | |
@EventHandler | |
public void playerJoin(PlayerJoinEvent e) { | |
/* | |
Generates Housing! | |
*/ | |
Player player = e.getPlayer(); | |
e.setJoinMessage(null); | |
if (player.hasPlayedBefore()) { | |
Location location = new Location(Bukkit.getWorld(String.format("plot-%s", player.getUniqueId().toString())), -7.5, 110, -56.5); | |
player.teleport(location); | |
} else { | |
slimeWorld.clone(String.format("plot-%s", player.getUniqueId().toString())); | |
} | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment