Skip to content

Commit

Permalink
Add support for sentinel
Browse files Browse the repository at this point in the history
  • Loading branch information
mcmonkey4eva committed Dec 7, 2016
1 parent 1938c56 commit 478c523
Show file tree
Hide file tree
Showing 5 changed files with 115 additions and 2 deletions.
3 changes: 2 additions & 1 deletion README.md
Expand Up @@ -26,7 +26,7 @@ For communicating with a BungeeCord network, use the following instructions:
8. Save the file.
9. Install DepenizenBukkit or Depenizen2Sponge, depending on your server brand.
10. Load your Bukkit/Spigot or Sponge server fully and stop it with `stop`.
11. If using Bungee/Spigot, navigate to `your_server_directory/plugins/Depenizen`. If using Sponge, navigate to `your_server_directory/config/depenizen2sponge`.
11. If using Bukkit/Spigot, navigate to `your_server_directory/plugins/Depenizen`. If using Sponge, navigate to `your_server_directory/config/depenizen2sponge`.
12. Open `config.yml`.
13. Set `Socket.Enabled` to `true`.
14. Set `Socket.IP Address` to the external IP address of your BungeeCord network.
Expand Down Expand Up @@ -66,6 +66,7 @@ Supported Plugins: (And the sources we acquired Jar files from.)
- PVP Stats (http://dev.bukkit.org/bukkit-plugins/pvp-stats/)
- Quests (https://www.spigotmc.org/resources/quests.3711/)
- Residence (https://www.spigotmc.org/resources/residence-1-7-10-up-to-1-10.11480/)
- Sentinel (https://www.spigotmc.org/resources/sentinel.22017/)
- ShopKeepers (http://dev.bukkit.org/bukkit-plugins/shopkeepers/)
- SimpleClans (http://dev.bukkit.org/bukkit-plugins/simpleclans/)
- SkillAPI (http://dev.bukkit.org/bukkit-plugins/skillapi/)
Expand Down
7 changes: 7 additions & 0 deletions bukkit/pom.xml
Expand Up @@ -139,6 +139,13 @@
<type>jar</type>
<scope>provided</scope>
</dependency>
<dependency>
<groupId>org.mcmonkey</groupId>
<artifactId>sentinel</artifactId>
<version>1.0</version>
<type>jar</type>
<scope>provided</scope>
</dependency>
<dependency>
<groupId>com.sk89q</groupId>
<artifactId>worldedit</artifactId>
Expand Down
@@ -0,0 +1,94 @@
package com.denizenscript.depenizen.bukkit.events.sentinel;

import net.aufdemrand.denizen.BukkitScriptEntryData;
import net.aufdemrand.denizen.events.BukkitScriptEvent;
import net.aufdemrand.denizen.objects.dNPC;
import net.aufdemrand.denizen.utilities.DenizenAPI;
import net.aufdemrand.denizencore.objects.dObject;
import net.aufdemrand.denizencore.scripts.ScriptEntryData;
import net.aufdemrand.denizencore.scripts.containers.ScriptContainer;
import net.aufdemrand.denizencore.utilities.CoreUtilities;
import org.bukkit.Bukkit;
import org.bukkit.event.EventHandler;
import org.bukkit.event.Listener;
import org.mcmonkey.sentinel.events.SentinelAttackEvent;

// <--[event]
// @Events
// on sentinel npc attacks
//
// @Regex ^on sentinel npc attacks$
//
// @Cancellable true
//
// @Triggers when a Sentinel-powered NPC attacks a target.
//
// @Context
// <context.entity> returns the NPC that is attacking.
//
// @Plugin DepenizenBukkit, Sentinel
//
// -->

public class SentinelAttackScriptEvent extends BukkitScriptEvent implements Listener {

public SentinelAttackScriptEvent() {
instance = this;
}

public static SentinelAttackScriptEvent instance;
public SentinelAttackEvent event;
public dNPC entity;

@Override
public boolean couldMatch(ScriptContainer scriptContainer, String s) {
return CoreUtilities.toLowerCase(s).startsWith("sentinel npc attacks");
}

@Override
public boolean matches(ScriptContainer scriptContainer, String s) {
return true;
}

@Override
public String getName() {
return "SentinelAttack";
}

@Override
public void init() {
Bukkit.getServer().getPluginManager().registerEvents(this, DenizenAPI.getCurrentInstance());
}

@Override
public void destroy() {
SentinelAttackEvent.getHandlerList().unregister(this);
}

@Override
public boolean applyDetermination(ScriptContainer container, String determination) {
return super.applyDetermination(container, determination);
}

@Override
public ScriptEntryData getScriptEntryData() {
return new BukkitScriptEntryData(null, entity);
}

@Override
public dObject getContext(String name) {
if (name.startsWith("entity")) {
return entity;
}
return super.getContext(name);
}

@EventHandler
public void onSentinelAttack(SentinelAttackEvent event) {
entity = new dNPC(event.getNPC());
cancelled = event.isCancelled();
this.event = event;
fire();
event.setCancelled(cancelled);
}
}
@@ -0,0 +1,11 @@
package com.denizenscript.depenizen.bukkit.support.plugins;

import com.denizenscript.depenizen.bukkit.events.sentinel.SentinelAttackScriptEvent;
import com.denizenscript.depenizen.bukkit.support.Support;

public class SentinelSupport extends Support {

public SentinelSupport() {
registerScriptEvents(new SentinelAttackScriptEvent());
}
}
2 changes: 1 addition & 1 deletion bukkit/src/main/resources/plugin.yml
Expand Up @@ -3,7 +3,7 @@ authors: [Morphan1]
version: ${project.version} (build ${BUILD_NUMBER})
main: com.denizenscript.depenizen.bukkit.DepenizenPlugin
depend: [Denizen]
softdepend: [mcMMO, BattleNight, Towny, Factions, Votifier, Jobs, Heroes, pvparena, WorldEdit, WorldGuard, Essentials, pvpstats, HyperConomy, SkillAPI, Prism, TerrainControl, PlotMe, SimpleClans, MobArena, ASkyBlock, NoCheatPlus, MythicMobs, ShopKeepers, GriefPrevention, Quests, PlaceholderAPI, Residence, dtlTraders, AreaShop]
softdepend: [mcMMO, BattleNight, Towny, Factions, Votifier, Jobs, Heroes, pvparena, WorldEdit, WorldGuard, Essentials, pvpstats, HyperConomy, SkillAPI, Prism, TerrainControl, PlotMe, SimpleClans, MobArena, ASkyBlock, NoCheatPlus, MythicMobs, Sentinel, ShopKeepers, GriefPrevention, Quests, PlaceholderAPI, Residence, dtlTraders, AreaShop]

commands:
depenizen:
Expand Down

0 comments on commit 478c523

Please sign in to comment.