Skip to content

Commit

Permalink
Javadoc, version bump (dutchycore), hometeleportevent
Browse files Browse the repository at this point in the history
  • Loading branch information
TheDutchMC committed Feb 10, 2021
1 parent c5e64ac commit 34f781e
Show file tree
Hide file tree
Showing 7 changed files with 96 additions and 18 deletions.
38 changes: 34 additions & 4 deletions build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -3,9 +3,11 @@ import org.apache.tools.ant.filters.ReplaceTokens
plugins {
id 'java'
id 'eclipse'
id 'maven-publish'
}

version = '2.1.0'
version = '2.1.2'
group = 'nl.thedutchmc'

sourceCompatibility = 1.11
targetCompatibility = 1.11
Expand All @@ -16,6 +18,11 @@ processResources {
}
}

java {
withSourcesJar()
withJavadocJar()
}

repositories {
jcenter()
maven{ url "https://hub.spigotmc.org/nexus/content/repositories/snapshots" }
Expand All @@ -26,12 +33,12 @@ repositories {

dependencies {
//Dev only:
//compileOnly 'nl.thedutchmc:dutchycore:0.0.33'
//compileOnly 'nl.thedutchmc:dutchycore:0.0.47'
//compileOnly 'nl.thedutchmc:offlineplayers:1.1.0'

//bug in jitpack, cant use nl.thedutchmc here :/
compileOnly 'com.github.DutchyPlugins:DutchyCore:0.0.34'
compileOnly 'com.github.DutchyPlugins:OfflinePlayers:1.1.0'
compileOnly 'com.github.DutchyPlugins:DutchyCore:0.0.47'
compileOnly 'com.github.DutchyPlugins:OfflinePlayers:1.1.1'

//Spigot API
compileOnly 'org.spigotmc:spigot-api:1.16.5-R0.1-SNAPSHOT'
Expand All @@ -47,3 +54,26 @@ task ghActions(type: Jar) {

destinationDirectory = file("$rootDir/actions")
}

publishing {
publications {
mavenJava(MavenPublication) {
artifactId = 'dutchyhome'
from components.java

pom {
name = 'DutchyHome'
description = 'DutchyHome plugin'
url = 'https://thedutchmc.nl'

developers {
developer {
id = 'thedutchmc'
name = 'Tobias de Bruijn'
email = '[email protected]'
}
}
}
}
}
}
3 changes: 1 addition & 2 deletions src/main/java/nl/thedutchmc/dutchyhome/DutchyHome.java
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,6 @@
import nl.thedutchmc.dutchyhome.tabcompleters.HomeCommandCompleter;
import nl.thedutchmc.dutchyhome.tabcompleters.HomesCommandCompleter;
import nl.thedutchmc.dutchyhome.tabcompleters.SetHomeCommandCompleter;
import nl.thedutchmc.offlineplayers.events.PlayerTransferEvent;

public class DutchyHome extends PluginModule {

Expand Down Expand Up @@ -137,7 +136,7 @@ public void postEnable() {
//Register event listeners
if(super.isModuleRegistered("OfflinePlayers")) {
super.logInfo("OfflinePlayers is installed. Enabling listener!");
super.registerModuleEventListener(new PlayerTransferEventListener(this), PlayerTransferEvent.class);
super.registerModuleEventListener(new PlayerTransferEventListener(this));
}
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@

/**
* Handles execution for:
* <pre> /delhome <home name> </pre>
* <pre> /delhome &lt;home name&gt; </pre>
*/
public class DelHomeCommandExecutor implements ModuleCommand {

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,10 +10,11 @@
import nl.thedutchmc.dutchycore.module.commands.ModuleCommand;
import nl.thedutchmc.dutchyhome.DutchyHome;
import nl.thedutchmc.dutchyhome.PlayerHomes;
import nl.thedutchmc.dutchyhome.events.HomeTeleportEvent;

/**
* Provides execution for:
* <pre> /home <homename> </pre>
* <pre> /home &lt;homename&gt; </pre>
*/
public class HomeCommandExecutor implements ModuleCommand {

Expand Down Expand Up @@ -66,8 +67,15 @@ public boolean fire(CommandSender sender, String[] args) {
return true;
}

Player player = (Player) sender;
Location preTeleportLocation = player.getLocation();

//Teleport the player
((Player) sender).teleport(home);
player.teleport(home);

//Fire HomeTeleportEvent
this.module.throwModuleEvent(new HomeTeleportEvent(player, preTeleportLocation, home));

sender.sendMessage(ChatColor.GOLD + "Teleporting...");

return true;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@

/**
* Handles execution for:
* <pre> /sethome <name> </pre>
* <pre> /sethome &lt;name&gt; </pre>
*
*/
public class SetHomeCommandExecutor implements ModuleCommand {
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,42 @@
package nl.thedutchmc.dutchyhome.events;

import org.bukkit.Location;
import org.bukkit.entity.Player;

import nl.thedutchmc.dutchycore.module.events.ModuleEvent;

public class HomeTeleportEvent extends ModuleEvent {

private Player teleportedPlayer;
private Location preTeleportLocation, postTeleportLocation;

public HomeTeleportEvent(Player teleportedPlayer, Location preTeleportLocation, Location postTeleportLocation) {
this.teleportedPlayer = teleportedPlayer;
this.preTeleportLocation = preTeleportLocation;
this.postTeleportLocation = postTeleportLocation;
}

/**
* Get the player that was teleported
* @return Returns a player
*/
public Player getTeleportedPlayer() {
return this.teleportedPlayer;
}

/**
* Get the location the player was at before they got teleported
* @return Returns a Location
*/
public Location getPreTeleportLocation() {
return this.preTeleportLocation;
}

/**
* Get the location the player was teleported to
* @return Returns a Location
*/
public Location getPostTeleportLocation() {
return this.postTeleportLocation;
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@

import org.bukkit.Location;

import nl.thedutchmc.dutchycore.module.events.ModuleEvent;
import nl.thedutchmc.dutchycore.annotations.EventHandler;
import nl.thedutchmc.dutchycore.module.events.ModuleEventListener;
import nl.thedutchmc.dutchyhome.DutchyHome;
import nl.thedutchmc.dutchyhome.PlayerHomes;
Expand All @@ -18,23 +18,22 @@ public PlayerTransferEventListener(DutchyHome module) {
this.module = module;
}

@Override
public void onEvent(ModuleEvent event) {
PlayerTransferEvent pte = (PlayerTransferEvent) event;
@EventHandler
public void onPlayerTransferEvent(PlayerTransferEvent event) {

PlayerHomes playerHomesOld = this.module.getPlayerHomes(pte.getOldUUID());
PlayerHomes playerHomesOld = this.module.getPlayerHomes(event.getOldUUID());

//Create a new PlayerHoems object
PlayerHomes playerHomesNew = new PlayerHomes(pte.getNewUUID());
PlayerHomes playerHomesNew = new PlayerHomes(event.getNewUUID());

//Add all h omes from the playerHomesOld to the playerHomesNew
for(Map.Entry<String, Location> entry : playerHomesOld.getAllHomes().entrySet()) {
playerHomesNew.setHome(entry.getKey(), entry.getValue());
}

//Set the new PlayerHomes, and remove the old
this.module.setPlayerHome(pte.getNewUUID(), playerHomesNew);
this.module.delPlayerHome(pte.getOldUUID());
this.module.setPlayerHome(event.getNewUUID(), playerHomesNew);
this.module.delPlayerHome(event.getOldUUID());

//Write memory to disk
this.module.writeMemory();
Expand Down

0 comments on commit 34f781e

Please sign in to comment.