Skip to content

Commit

Permalink
initial commit
Browse files Browse the repository at this point in the history
  • Loading branch information
nicegamer7 committed Aug 26, 2019
1 parent e3777e5 commit 9b2f574
Show file tree
Hide file tree
Showing 32 changed files with 694 additions and 0 deletions.
13 changes: 13 additions & 0 deletions .idea/compiler.xml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

6 changes: 6 additions & 0 deletions .idea/encodings.xml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

14 changes: 14 additions & 0 deletions .idea/misc.xml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

124 changes: 124 additions & 0 deletions .idea/uiDesigner.xml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

58 changes: 58 additions & 0 deletions .idea/workspace.xml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

59 changes: 59 additions & 0 deletions pom.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,59 @@
<?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>xyz.ng7</groupId>
<artifactId>rSpawn</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>
<version>3.8.1</version>
</plugin>
</plugins>
</build>

<repositories>
<repository>
<id>spigotmc-repo</id>
<url>https://hub.spigotmc.org/nexus/content/repositories/snapshots/</url>
</repository>
<repository>
<id>Multiverse Snapshots</id>
<url>http://repo.onarandombox.com/content/repositories/multiverse-snapshots/</url>
</repository>
</repositories>

<dependencies>
<dependency>
<groupId>org.spigotmc</groupId>
<artifactId>spigot-api</artifactId>
<version>1.14.4-R0.1-SNAPSHOT</version>
<scope>provided</scope>
</dependency>
<dependency>
<groupId>com.onarandombox.multiversecore</groupId>
<artifactId>Multiverse-Core</artifactId>
<version>4.1.0-SNAPSHOT</version>
<scope>provided</scope>
</dependency>
<dependency>
<groupId>com.onarandombox.multiverseinventories</groupId>
<artifactId>Multiverse-Inventories</artifactId>
<version>3.0.1-SNAPSHOT</version>
<scope>provided</scope>
</dependency>
</dependencies>

<properties>
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
</properties>
</project>
2 changes: 2 additions & 0 deletions rSpawn.iml
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" />
45 changes: 45 additions & 0 deletions src/main/java/xyz/ng7/rSpawn/Listeners/OnJoin.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,45 @@
package xyz.ng7.rSpawn.Listeners;

import com.onarandombox.multiverseinventories.MultiverseInventories;
import com.onarandombox.multiverseinventories.WorldGroup;
import java.util.List;
import org.bukkit.Location;
import org.bukkit.configuration.file.FileConfiguration;
import org.bukkit.entity.Player;
import org.bukkit.event.EventHandler;
import org.bukkit.event.Listener;
import org.bukkit.event.player.PlayerChangedWorldEvent;
import xyz.ng7.rSpawn.MultiverseInventories.SpawnPointSharable;
import xyz.ng7.rSpawn.rSpawn;
import xyz.ng7.rSpawn.Utils.SpawnLocation;

public class OnJoin implements Listener {
private FileConfiguration c;
private MultiverseInventories i;
private String g;

public OnJoin(rSpawn rS) {
c = rS.getConfigFile();
i = rS.getInventories();
}

@EventHandler
public void onJoin(PlayerChangedWorldEvent e) {
Player p = e.getPlayer();
List<WorldGroup> lwg = i.getGroupManager().getGroupsForWorld(p.getWorld().getName());

for (WorldGroup fg: lwg) if (fg.isSharing(SpawnPointSharable.SPAWN_POINT)) {
g = fg.getName();
break;
}

if (g != null) {
Location sp = SpawnPointSharable.getPlayerSpawnPoint(p);

if (sp == null) {
SpawnPointSharable.setPlayerSpawnPoint(p, new SpawnLocation(c, p.getWorld()).gen());
p.teleport(SpawnPointSharable.getPlayerSpawnPoint(p));
}
}
}
}
47 changes: 47 additions & 0 deletions src/main/java/xyz/ng7/rSpawn/Listeners/OnRespawn.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,47 @@
package xyz.ng7.rSpawn.Listeners;

import com.onarandombox.multiverseinventories.MultiverseInventories;
import com.onarandombox.multiverseinventories.WorldGroup;
import java.util.List;
import org.bukkit.Location;
import org.bukkit.configuration.file.FileConfiguration;
import org.bukkit.entity.Player;
import org.bukkit.event.EventHandler;
import org.bukkit.event.Listener;
import org.bukkit.event.player.PlayerRespawnEvent;
import xyz.ng7.rSpawn.MultiverseInventories.SpawnPointSharable;
import xyz.ng7.rSpawn.rSpawn;
import xyz.ng7.rSpawn.Utils.SpawnLocation;

public class OnRespawn implements Listener {
private FileConfiguration c;
private MultiverseInventories i;
private String g;

public OnRespawn(rSpawn rS) {
c = rS.getConfigFile();
i = rS.getInventories();
}

@EventHandler
public void onJoin(PlayerRespawnEvent e) {
Player p = e.getPlayer();
List<WorldGroup> lwg = i.getGroupManager().getGroupsForWorld(p.getWorld().getName());

for (WorldGroup fg: lwg) if (fg.isSharing(SpawnPointSharable.SPAWN_POINT)) {
g = fg.getName();
break;
}

if (g != null) {
Location sp = SpawnPointSharable.getPlayerSpawnPoint(p);

if (e.isBedSpawn()) return;
else if (sp != null) e.setRespawnLocation(sp);
else {
SpawnPointSharable.setPlayerSpawnPoint(p, new SpawnLocation(c, p.getWorld()).gen());
e.setRespawnLocation(SpawnPointSharable.getPlayerSpawnPoint(p));
}
}
}
}
Loading

0 comments on commit 9b2f574

Please sign in to comment.