Skip to content
This repository has been archived by the owner on Jun 2, 2023. It is now read-only.

Commit

Permalink
*Some work on end visiting logic. EnderDragon counts now stored in file
Browse files Browse the repository at this point in the history
  • Loading branch information
Zolli committed Feb 24, 2013
1 parent 7200746 commit a573e57
Show file tree
Hide file tree
Showing 4 changed files with 32 additions and 6 deletions.
5 changes: 4 additions & 1 deletion resources/config.yml
Original file line number Diff line number Diff line change
Expand Up @@ -21,9 +21,12 @@ database:
username: 'root'
password: ''

dragons:
desiredDragonCount: '1'

debug:
debugStatus: 'false'

worlds:
mainWorld: 'defaultWorld'
netherWorld: 'defaultNether'
endWorld: 'defaultNether'
3 changes: 3 additions & 0 deletions resources/en.yml
Original file line number Diff line number Diff line change
Expand Up @@ -6,3 +6,6 @@ commands:
noPermission: 'You dont have permission to access this command! You need one of the following permission:'
noConsole: 'This command must be running as player!'
badUsage: 'Bad syntax! Try this:'

defeat:
successSingle: 'Siker. :)'
3 changes: 2 additions & 1 deletion resources/storage.yml
Original file line number Diff line number Diff line change
@@ -1 +1,2 @@
test: 'test'
localSettings:
dragonCount: '1'
27 changes: 23 additions & 4 deletions src/com/Zolli/EnderCore/Listeners/playerListener.java
Original file line number Diff line number Diff line change
@@ -1,5 +1,8 @@
package com.Zolli.EnderCore.Listeners;

import org.bukkit.World;
import org.bukkit.entity.EnderDragon;
import org.bukkit.entity.Entity;
import org.bukkit.entity.Player;
import org.bukkit.event.EventHandler;
import org.bukkit.event.Listener;
Expand Down Expand Up @@ -46,10 +49,23 @@ public playerListener(EnderCore instance) {
public void playerJoin(PlayerJoinEvent e) {
Player pl = e.getPlayer();
boolean played = pl.hasPlayedBefore();
int dragonCount = 0;

/* Write player to database if is joined the server first time */
if(!played) {
plugin.dbAction.addPlayer(pl);
}
/* END */

/* Detecting ender dragons count on ender, and write it to settings */
World ender = plugin.getServer().getWorld(this.endWorld);
for(Entity ent : ender.getEntities()) {
if(ent instanceof EnderDragon) {
dragonCount++;
}
}
plugin.ffStorage.set("localSettings.dragonCount", dragonCount);
/* END */
}

/**
Expand All @@ -62,17 +78,20 @@ public void goNether(PlayerChangedWorldEvent e) {
ECPlayer epl = new ECPlayer(pl, plugin);
String toWorld = pl.getWorld().getName();

/* If player traveling to the nether world */
/* If player traveling to the ender world */
if(toWorld.equalsIgnoreCase(this.endWorld)) {
playerTravelEnderEvent travelEvent = new playerTravelEnderEvent(pl, pl.getWorld(), e.getFrom(), epl.isDragonDefeted());
plugin.pluginManager.callEvent(travelEvent);

if(epl.isDragonDefeted()) {
System.out.println("Igen");
/* If enough number of dragon in the ender */
if(plugin.config.getInt("dragons.desiredDragonCount") >= plugin.config.getInt("dragons.desiredDragonCount")) {
pl.sendMessage("Hajrá :)");
} else {
System.out.println("Nem");
pl.teleport(plugin.getServer().getWorld(plugin.config.getString("worlds.endWorld")).getSpawnLocation());
}
/* END */
}
/* END */
}

}

0 comments on commit a573e57

Please sign in to comment.