tutorial additions.

This commit is contained in:
Ben 2016-03-18 02:47:51 +00:00
parent 3b764920e1
commit 995d454f87
26 changed files with 759 additions and 16 deletions

View File

@ -0,0 +1,30 @@
package mineplex.core.common;
import java.util.HashMap;
import java.util.function.Function;
public class DefaultHashMap<K, V>
{
private HashMap<K, V> _map;
private Function<K, V> _defaultPopulator;
public DefaultHashMap(Function<K, V> defaultPopulator)
{
_map = new HashMap<K, V>();
_defaultPopulator = defaultPopulator;
}
public V get(K key)
{
_map.putIfAbsent(key, _defaultPopulator.apply(key));
return _map.get(key);
}
public void put(K key, V value)
{
_map.put(key, value);
}
}

View File

@ -1,6 +1,7 @@
package mineplex.core.common.objective; package mineplex.core.common.objective;
import java.util.HashSet; import java.util.HashSet;
import java.util.Set;
import java.util.UUID; import java.util.UUID;
import org.bukkit.entity.Player; import org.bukkit.entity.Player;
@ -33,8 +34,18 @@ public abstract class ObjectiveGoal implements Listener
return _description; return _description;
} }
public Set<UUID> getActivePlayers()
{
return _active;
}
public boolean contains(Player player) public boolean contains(Player player)
{ {
if (player == null)
{
return false;
}
return _active.contains(player.getUniqueId()); return _active.contains(player.getUniqueId());
} }

View File

@ -0,0 +1,7 @@
package mineplex.core.chat;
public enum FilterPriority
{
HIGH,
LOW;
}

View File

@ -0,0 +1,27 @@
package mineplex.game.clans.clans;
import org.bukkit.event.EventHandler;
import org.bukkit.event.EventPriority;
import org.bukkit.event.player.PlayerJoinEvent;
import mineplex.core.MiniPlugin;
import mineplex.core.common.util.C;
import mineplex.core.common.util.UtilPlayer;
import mineplex.core.task.TaskManager;
import mineplex.game.clans.Clans;
public class ClansBetaManager extends MiniPlugin
{
public ClansBetaManager(ClansManager manager, TaskManager taskManager)
{
super("Clans Beta", manager.getPlugin());
}
@EventHandler(priority = EventPriority.HIGHEST)
public void onPlayerJoin(final PlayerJoinEvent event)
{
UtilPlayer.message(event.getPlayer(), C.cDAquaB + "Welcome to Mineplex Clans " + Clans.VERSION);
}
}

View File

@ -117,9 +117,11 @@ public class PvpTimer extends MiniClientPlugin<PvpTimerClient>
UtilServer.getPlayersCollection().forEach(player -> { UtilServer.getPlayersCollection().forEach(player -> {
PvpTimerClient client = Get(player); PvpTimerClient client = Get(player);
client.StartTime = System.currentTimeMillis(); runAsync(() -> {
_repository.Save(_clientManager.getAccountId(player), client.Skipped, client.Elapsed += (int) (elapsed(player) / 1000));
runAsync(() -> _repository.Save(_clientManager.getAccountId(player), client.Skipped, client.Elapsed += (int) (elapsed(player)))); client.StartTime = System.currentTimeMillis();
});
}); });
} }
@ -177,12 +179,12 @@ public class PvpTimer extends MiniClientPlugin<PvpTimerClient>
public void run() public void run()
{ {
UtilTextMiddle.display(C.cGreen + "PvP Safety", C.cGray + "will end in " + UtilTime.MakeStr(getPvPTimerLeft(player) * 1000), 40, 70, 40, player); UtilTextMiddle.display(C.cGreen + "PvP Safety", C.cGray + "will end in " + UtilTime.MakeStr(getPvPTimerLeft(player) * 1000), 40, 70, 40, player);
}
}, 10);
UtilPlayer.message(player, C.cAqua + "You are currently safe from PvP because you are a new player. This safety will end in " + F.time(UtilTime.MakeStr(getPvPTimerLeft(player) * 1000))); UtilPlayer.message(player, C.cAqua + "You are currently safe from PvP because you are a new player. This safety will end in " + F.time(UtilTime.MakeStr(getPvPTimerLeft(player) * 1000)));
UtilPlayer.message(player, C.cAqua + "Until it ends, you are immune to, and are unable to deal PvP damage."); UtilPlayer.message(player, C.cAqua + "Until it ends, you are immune to, and are unable to deal PvP damage.");
UtilPlayer.message(player, C.cAqua + "If you would like to disable the PvP safety permanently, then type " + F.elem("/pvp") + "."); UtilPlayer.message(player, C.cAqua + "To disable the PvP safety permanently, then type " + F.elem("/pvp") + ".");
}
}, 3);
} }
} }

View File

@ -51,6 +51,12 @@ public class PvPTimerCommand extends CommandBase<PvpTimer>
} }
else else
{ {
if (Plugin.Get(caller).Skipped)
{
UtilPlayer.message(caller, F.main("Clans", "You have already disabled PvP Safety."));
return;
}
if (args[0].equalsIgnoreCase("yesiconfirmthatiwouldliketodisablemypvptimerforever")) if (args[0].equalsIgnoreCase("yesiconfirmthatiwouldliketodisablemypvptimerforever"))
{ {
Plugin.disableFor(caller); Plugin.disableFor(caller);

View File

@ -0,0 +1,83 @@
package mineplex.game.clans.clans.pvptimer.repository;
import mineplex.core.account.CoreClientManager;
import mineplex.core.common.util.EnclosedObject;
import mineplex.core.common.util.UUIDFetcher;
import mineplex.core.database.MinecraftRepository;
import mineplex.core.incognito.IncognitoManager;
import mineplex.game.clans.clans.pvptimer.PvpTimer;
import mineplex.serverdata.database.DBPool;
import mineplex.serverdata.database.column.ColumnInt;
public class PvpTimerRepository extends MinecraftRepository
{
private static final String CREATE_TABLE = "CREATE TABLE IF NOT EXISTS clansPvpTimer (accountId INT NOT NULL, timerElapsed INT NOT NULL DEFAULT '1', hasSkipped TINYINT(1) DEFAULT '0', PRIMARY KEY (accountId));";
private static final String GET_STATUS = "SELECT * FROM clansPvpTimer WHERE accountId = ?;";
private static final String INSERT_STATUS = "INSERT INTO clansPvpTimer (accountId, timerElapsed, hasSkipped) VALUES (?, ?, ?);";
private static final String UPDATE_STATUS = "UPDATE clansPvpTimer SET timerElapsed=?, hasSkipped=? WHERE accountId=?;";
private PvpTimer _pvpTimer;
private CoreClientManager _clientManager;
public PvpTimerRepository(PvpTimer pvpTimer, CoreClientManager clientManager)
{
super(pvpTimer.getPlugin(), DBPool.getAccount());
_clientManager = clientManager;
_pvpTimer = pvpTimer;
}
public void Save(int accountId, boolean skipped, int timerElapsed)
{
// Prevent duplicate entries for individuals
executeQuery(GET_STATUS, result -> {
if (result.next())
executeUpdate(UPDATE_STATUS, new ColumnInt("timerElapsed", timerElapsed), new ColumnInt("hasSkipped", skipped ? 1 : 0), new ColumnInt("accountId", accountId));
else
executeUpdate(INSERT_STATUS, new ColumnInt("accountId", accountId), new ColumnInt("timerElapsed", timerElapsed), new ColumnInt("hasSkipped", skipped ? 1 : 0));
}, new ColumnInt("accountId", accountId));
}
public TimerClientToken Get(int accountId)
{
final TimerClientToken token = new TimerClientToken();
executeQuery(GET_STATUS, result -> {
if (result.next())
{
token.Elapsed = result.getInt("timerElapsed");
token.Skipped = result.getInt("hasSkipped") == 1;
}
else
{
token.Elapsed = 1;
token.Skipped = false;
}
}, new ColumnInt("accountId", accountId));
return token;
}
public TimerClientToken Get(String name)
{
EnclosedObject<Integer> accountId = new EnclosedObject<>();
_clientManager.getRepository().getAccountId(UUIDFetcher.getUUIDOf(name), id ->
accountId.Set(id)
);
return Get(accountId.Get().intValue());
}
protected void initialize()
{
executeUpdate(CREATE_TABLE);
}
protected void update()
{
}
}

View File

@ -0,0 +1,7 @@
package mineplex.game.clans.clans.pvptimer.repository;
public class TimerClientToken
{
public int Elapsed;
public boolean Skipped;
}

View File

@ -21,7 +21,11 @@ import mineplex.game.clans.tutorial.Tutorial;
import mineplex.game.clans.tutorial.TutorialRegion; import mineplex.game.clans.tutorial.TutorialRegion;
import mineplex.game.clans.tutorial.TutorialWorldManager; import mineplex.game.clans.tutorial.TutorialWorldManager;
import mineplex.game.clans.tutorial.tutorials.clans.objective.ClanObjective; import mineplex.game.clans.tutorial.tutorials.clans.objective.ClanObjective;
import mineplex.game.clans.tutorial.tutorials.clans.objective.ClassesObjective;
import mineplex.game.clans.tutorial.tutorials.clans.objective.FieldsObjective;
import mineplex.game.clans.tutorial.tutorials.clans.objective.FinalObjective;
import mineplex.game.clans.tutorial.tutorials.clans.objective.LeaveSpawnObjective; import mineplex.game.clans.tutorial.tutorials.clans.objective.LeaveSpawnObjective;
import mineplex.game.clans.tutorial.tutorials.clans.objective.ShopsObjective;
public class ClansMainTutorial extends Tutorial public class ClansMainTutorial extends Tutorial
{ {
@ -40,6 +44,10 @@ public class ClansMainTutorial extends Tutorial
addObjective(new LeaveSpawnObjective(this, plugin)); addObjective(new LeaveSpawnObjective(this, plugin));
addObjective(new ClanObjective(this, plugin)); addObjective(new ClanObjective(this, plugin));
addObjective(new ShopsObjective(this, plugin));
addObjective(new ClassesObjective(this, plugin));
addObjective(new FieldsObjective(this, plugin));
addObjective(new FinalObjective(this, plugin));
} }
@Override @Override

View File

@ -5,10 +5,13 @@ import org.bukkit.plugin.java.JavaPlugin;
import mineplex.core.common.objective.OrderedObjective; import mineplex.core.common.objective.OrderedObjective;
import mineplex.game.clans.tutorial.tutorials.clans.ClansMainTutorial; import mineplex.game.clans.tutorial.tutorials.clans.ClansMainTutorial;
import mineplex.game.clans.tutorial.tutorials.clans.objective.goals.BuildHouseGoal; import mineplex.game.clans.tutorial.tutorials.clans.objective.goals.clan.AttackEnemyGoal;
import mineplex.game.clans.tutorial.tutorials.clans.objective.goals.ClaimLandGoal; import mineplex.game.clans.tutorial.tutorials.clans.objective.goals.clan.BuildHouseGoal;
import mineplex.game.clans.tutorial.tutorials.clans.objective.goals.ClanDetailsGoal; import mineplex.game.clans.tutorial.tutorials.clans.objective.goals.clan.ClaimLandGoal;
import mineplex.game.clans.tutorial.tutorials.clans.objective.goals.CreateClanGoal; import mineplex.game.clans.tutorial.tutorials.clans.objective.goals.clan.ClanDetailsGoal;
import mineplex.game.clans.tutorial.tutorials.clans.objective.goals.clan.CreateClanGoal;
import mineplex.game.clans.tutorial.tutorials.clans.objective.goals.clan.SetHomeGoal;
import mineplex.game.clans.tutorial.tutorials.clans.objective.goals.clan.StealEnemyPotatoesGoal;
public class ClanObjective extends OrderedObjective<ClansMainTutorial> public class ClanObjective extends OrderedObjective<ClansMainTutorial>
{ {
@ -20,6 +23,9 @@ public class ClanObjective extends OrderedObjective<ClansMainTutorial>
addGoal(new ClanDetailsGoal(this)); addGoal(new ClanDetailsGoal(this));
addGoal(new ClaimLandGoal(this)); addGoal(new ClaimLandGoal(this));
addGoal(new BuildHouseGoal(this)); addGoal(new BuildHouseGoal(this));
addGoal(new SetHomeGoal(this));
addGoal(new AttackEnemyGoal(this)); // TODO:
addGoal(new StealEnemyPotatoesGoal(this)); // TODO:
} }
@Override @Override

View File

@ -0,0 +1,30 @@
package mineplex.game.clans.tutorial.tutorials.clans.objective;
import org.bukkit.entity.Player;
import org.bukkit.plugin.java.JavaPlugin;
import mineplex.core.common.objective.OrderedObjective;
import mineplex.game.clans.tutorial.tutorials.clans.ClansMainTutorial;
import mineplex.game.clans.tutorial.tutorials.clans.objective.goals.classes.OpenClassManagerGoal;
import mineplex.game.clans.tutorial.tutorials.clans.objective.goals.classes.UseBullsChargeGoal;
public class ClassesObjective extends OrderedObjective<ClansMainTutorial>
{
public ClassesObjective(ClansMainTutorial clansMainTutorial, JavaPlugin javaPlugin)
{
super(clansMainTutorial, javaPlugin, "Classes", "Learn to use our fully customizable classes");
addGoal(new OpenClassManagerGoal(this)); // IMPLEMENTED
addGoal(new UseBullsChargeGoal(this)); // TODO: not sure if we want JUST bulls charge or any other skill?
}
@Override
protected void customLeave(Player player)
{
}
@Override
protected void customFinish(Player player)
{
}
}

View File

@ -0,0 +1,32 @@
package mineplex.game.clans.tutorial.tutorials.clans.objective;
import org.bukkit.entity.Player;
import org.bukkit.plugin.java.JavaPlugin;
import mineplex.core.common.objective.OrderedObjective;
import mineplex.game.clans.tutorial.tutorials.clans.ClansMainTutorial;
import mineplex.game.clans.tutorial.tutorials.clans.objective.goals.fields.GoToFieldsGoal;
import mineplex.game.clans.tutorial.tutorials.clans.objective.goals.fields.KillZombiesGoal;
import mineplex.game.clans.tutorial.tutorials.clans.objective.goals.fields.MineDiamondsGoal;
public class FieldsObjective extends OrderedObjective<ClansMainTutorial>
{
public FieldsObjective(ClansMainTutorial clansMainTutorial, JavaPlugin javaPlugin)
{
super(clansMainTutorial, javaPlugin, "Fields", "Get various resources by mining for them in the fields");
addGoal(new GoToFieldsGoal(this)); // IMPLEMENTED
addGoal(new MineDiamondsGoal(this)); // TODO:
addGoal(new KillZombiesGoal(this));
}
@Override
protected void customLeave(Player player)
{
}
@Override
protected void customFinish(Player player)
{
}
}

View File

@ -0,0 +1,34 @@
package mineplex.game.clans.tutorial.tutorials.clans.objective;
import org.bukkit.entity.Player;
import org.bukkit.plugin.java.JavaPlugin;
import mineplex.core.common.objective.OrderedObjective;
import mineplex.game.clans.tutorial.tutorials.clans.ClansMainTutorial;
import mineplex.game.clans.tutorial.tutorials.clans.objective.goals.clan.BuildHouseGoal;
import mineplex.game.clans.tutorial.tutorials.clans.objective.goals.clan.ClaimLandGoal;
import mineplex.game.clans.tutorial.tutorials.clans.objective.goals.clan.ClanDetailsGoal;
import mineplex.game.clans.tutorial.tutorials.clans.objective.goals.clan.CreateClanGoal;
import mineplex.game.clans.tutorial.tutorials.clans.objective.goals.clan.SetHomeGoal;
public class FinalObjective extends OrderedObjective<ClansMainTutorial>
{
public FinalObjective(ClansMainTutorial clansMainTutorial, JavaPlugin javaPlugin)
{
super(clansMainTutorial, javaPlugin, "Finishing", "Finalize your knowledge of Clans");
// addGoal(new SellDiamondsGoal(this));
// addGoal(new BuyEnergyGoal(this));
// addGoal(new TpClanHomeGoal(this));
}
@Override
protected void customLeave(Player player)
{
}
@Override
protected void customFinish(Player player)
{
}
}

View File

@ -0,0 +1,35 @@
package mineplex.game.clans.tutorial.tutorials.clans.objective;
import org.bukkit.entity.Player;
import org.bukkit.plugin.java.JavaPlugin;
import mineplex.core.common.objective.OrderedObjective;
import mineplex.game.clans.tutorial.tutorials.clans.ClansMainTutorial;
import mineplex.game.clans.tutorial.tutorials.clans.objective.goals.clan.BuildHouseGoal;
import mineplex.game.clans.tutorial.tutorials.clans.objective.goals.clan.ClaimLandGoal;
import mineplex.game.clans.tutorial.tutorials.clans.objective.goals.clan.ClanDetailsGoal;
import mineplex.game.clans.tutorial.tutorials.clans.objective.goals.clan.CreateClanGoal;
import mineplex.game.clans.tutorial.tutorials.clans.objective.goals.clan.SetHomeGoal;
public class ShopsObjective extends OrderedObjective<ClansMainTutorial>
{
public ShopsObjective(ClansMainTutorial clansMainTutorial, JavaPlugin javaPlugin)
{
super(clansMainTutorial, javaPlugin, "Shops", "Learn your way around our shops");
// addGoal(new GoToShopsGoal(this));
// addGoal(new SellPotatoesGoal(this));
// addGoal(new BuyGearGoal(this));
}
@Override
protected void customLeave(Player player)
{
}
@Override
protected void customFinish(Player player)
{
}
}

View File

@ -0,0 +1,48 @@
package mineplex.game.clans.tutorial.tutorials.clans.objective.goals.clan;
import org.bukkit.Location;
import org.bukkit.entity.Player;
import org.bukkit.event.EventHandler;
import mineplex.core.common.objective.Objective;
import mineplex.core.common.objective.ObjectiveGoal;
import mineplex.game.clans.clans.siege.events.SiegeWeaponExplodeEvent;
public class AttackEnemyGoal extends ObjectiveGoal
{
public AttackEnemyGoal(Objective objective)
{
super(objective, "Attack Enemy", "Attack enemy clan! Blow a hole in their base with a Cannon.");
}
@Override
protected void customStart(Player player)
{
// give tnt (For cannon)
// and place cannon?
}
// use this event for figuring out if the cannon hit the base
@EventHandler
public void siegeWeaponExplode(SiegeWeaponExplodeEvent event)
{
Player shooter = event.getWeapon().getRider();
if (!contains(shooter))
{
return;
}
Location center = event.getProjectile().getLocation();
int radiusOfCrater = event.getProjectile().getCraterSize();
// if (center.distance(enemyBase) <= radius) {
// finish(shooter);
// }
}
@Override
protected void customFinish(Player player)
{
}
}

View File

@ -0,0 +1,117 @@
package mineplex.game.clans.tutorial.tutorials.clans.objective.goals.clan;
import java.util.List;
import org.bukkit.Effect;
import org.bukkit.Material;
import org.bukkit.Sound;
import org.bukkit.block.Block;
import org.bukkit.entity.Player;
import org.bukkit.event.EventHandler;
import org.bukkit.event.block.BlockDamageEvent;
import org.bukkit.event.block.BlockPlaceEvent;
import org.bukkit.inventory.ItemStack;
import com.google.common.collect.Lists;
import mineplex.core.common.objective.Objective;
import mineplex.core.common.objective.ObjectiveGoal;
import mineplex.core.common.util.F;
import mineplex.core.common.util.UtilPlayer;
import mineplex.game.clans.clans.ClansManager;
public class BuildHouseGoal extends ObjectiveGoal
{
private List<ItemStack> _items = Lists.newArrayList(
new ItemStack(Material.SMOOTH_BRICK, 54),
new ItemStack(Material.TORCH, 2),
new ItemStack(Material.IRON_DOOR, 1)
);
public BuildHouseGoal(Objective objective)
{
super(objective, "Build House", "Build a Stone Brick house. (Place all your blocks)");
}
@Override
protected void customStart(Player player)
{
_items.forEach(item -> {
player.getInventory().addItem(item);
});
}
@Override
protected void customFinish(Player player)
{
}
@EventHandler
public void blockBreak(BlockDamageEvent event)
{
if (!contains(event.getPlayer()))
{
return;
}
if (!isInBuildArea(event.getBlock()))
{
return;
}
for (ItemStack stack : _items)
{
if (event.getBlock().getType().equals(stack.getType()) || event.getBlock().getType().equals(Material.IRON_DOOR_BLOCK))
{
event.getBlock().breakNaturally();
event.getBlock().getWorld().playEffect(event.getBlock().getLocation(), Effect.TILE_BREAK, event.getBlock().getTypeId(), 10);
event.getPlayer().playSound(event.getBlock().getLocation(), Sound.LAVA_POP, 1.f, 1.f);
break;
}
}
}
@EventHandler
public void blockPlace(BlockPlaceEvent event)
{
if (!contains(event.getPlayer()))
{
return;
}
if (isInBuildArea(event.getBlock()))
{
// Run 1 tick later because inventory doesn't get updated instantly
ClansManager.getInstance().runSync(() -> {
boolean ja = true;
for (ItemStack stack : event.getPlayer().getInventory().getContents())
{
if (stack == null)
continue;
for (ItemStack other : _items)
if (stack.getType() == other.getType())
{
ja = false;
break;
}
}
if (ja) // JA!
finish(event.getPlayer());
});
}
else
{
UtilPlayer.message(event.getPlayer(), F.main("Clans", "You are not allowed to place blocks here."));
}
}
private boolean isInBuildArea(Block block)
{
return true; // TODO
}
}

View File

@ -1,4 +1,4 @@
package mineplex.game.clans.tutorial.tutorials.clans.objective.goals; package mineplex.game.clans.tutorial.tutorials.clans.objective.goals.clan;
import org.bukkit.entity.Player; import org.bukkit.entity.Player;
import org.bukkit.event.EventHandler; import org.bukkit.event.EventHandler;

View File

@ -1,4 +1,4 @@
package mineplex.game.clans.tutorial.tutorials.clans.objective.goals; package mineplex.game.clans.tutorial.tutorials.clans.objective.goals.clan;
import org.bukkit.entity.Player; import org.bukkit.entity.Player;
import org.bukkit.event.EventHandler; import org.bukkit.event.EventHandler;

View File

@ -1,4 +1,4 @@
package mineplex.game.clans.tutorial.tutorials.clans.objective.goals; package mineplex.game.clans.tutorial.tutorials.clans.objective.goals.clan;
import org.bukkit.entity.Player; import org.bukkit.entity.Player;
import org.bukkit.event.EventHandler; import org.bukkit.event.EventHandler;

View File

@ -0,0 +1,35 @@
package mineplex.game.clans.tutorial.tutorials.clans.objective.goals.clan;
import org.bukkit.entity.Player;
import org.bukkit.event.EventHandler;
import mineplex.core.common.objective.Objective;
import mineplex.core.common.objective.ObjectiveGoal;
import mineplex.game.clans.clans.event.ClanSetHomeEvent;
public class SetHomeGoal extends ObjectiveGoal
{
public SetHomeGoal(Objective objective)
{
super(objective, "Set Home", "Set your Clan's home by typing /c sethome");
}
@Override
protected void customStart(Player player)
{
}
@Override
protected void customFinish(Player player)
{
}
@EventHandler
public void onSetHome(ClanSetHomeEvent event)
{
if (contains(event.getPlayer()))
{
finish(event.getPlayer());
}
}
}

View File

@ -0,0 +1,28 @@
package mineplex.game.clans.tutorial.tutorials.clans.objective.goals.clan;
import org.bukkit.entity.Player;
import org.bukkit.event.EventHandler;
import mineplex.core.common.objective.Objective;
import mineplex.core.common.objective.ObjectiveGoal;
import mineplex.game.clans.clans.event.ClanCreatedEvent;
public class StealEnemyPotatoesGoal extends ObjectiveGoal
{
public StealEnemyPotatoesGoal(Objective objective)
{
super(objective, "Create a Clan", "Create a Clan");
}
@Override
protected void customStart(Player player)
{
}
@Override
protected void customFinish(Player player)
{
}
}

View File

@ -0,0 +1,50 @@
package mineplex.game.clans.tutorial.tutorials.clans.objective.goals.classes;
import org.bukkit.Material;
import org.bukkit.entity.Player;
import org.bukkit.event.EventHandler;
import org.bukkit.event.player.PlayerInteractEvent;
import mineplex.core.common.objective.Objective;
import mineplex.core.common.objective.ObjectiveGoal;
import mineplex.core.common.util.UtilEvent;
import mineplex.core.common.util.UtilEvent.ActionType;
public class OpenClassManagerGoal extends ObjectiveGoal
{
public OpenClassManagerGoal(Objective objective)
{
super(objective, "Open Class Manager", "Open the Class Manager by right clicking on an enchantment table");
}
@Override
protected void customStart(Player player)
{
}
@Override
protected void customFinish(Player player)
{
}
@EventHandler
public void interact(PlayerInteractEvent event)
{
if (!event.getClickedBlock().getType().equals(Material.ENCHANTMENT_TABLE))
{
return;
}
if (!UtilEvent.isAction(event, ActionType.R_BLOCK))
{
return;
}
if (!contains(event.getPlayer()))
{
return;
}
finish(event.getPlayer());
}
}

View File

@ -0,0 +1,24 @@
package mineplex.game.clans.tutorial.tutorials.clans.objective.goals.classes;
import org.bukkit.entity.Player;
import mineplex.core.common.objective.Objective;
import mineplex.core.common.objective.ObjectiveGoal;
public class UseBullsChargeGoal extends ObjectiveGoal
{
public UseBullsChargeGoal(Objective objective)
{
super(objective, "Use Bulls Charge", "Use the Bull's Charge skill to make yourself run faster");
}
@Override
protected void customStart(Player player)
{
}
@Override
protected void customFinish(Player player)
{
}
}

View File

@ -0,0 +1,43 @@
package mineplex.game.clans.tutorial.tutorials.clans.objective.goals.fields;
import org.bukkit.entity.Player;
import org.bukkit.event.EventHandler;
import mineplex.core.common.objective.Objective;
import mineplex.core.common.objective.ObjectiveGoal;
import mineplex.game.clans.clans.event.PlayerEnterTerritoryEvent;
public class GoToFieldsGoal extends ObjectiveGoal
{
public GoToFieldsGoal(Objective objective)
{
super(objective, "Go to the Fields", "Run to the center of the map, to the Fields");
}
@Override
protected void customStart(Player player)
{
}
@Override
protected void customFinish(Player player)
{
}
@EventHandler
public void enterRegion(PlayerEnterTerritoryEvent event)
{
if (!contains(event.getPlayer()))
{
return;
}
// This "reverse" equals is to prevent an NPE
if (!"Fields".equals(event.getNewTerritory()))
{
return;
}
finish(event.getPlayer());
}
}

View File

@ -0,0 +1,53 @@
package mineplex.game.clans.tutorial.tutorials.clans.objective.goals.fields;
import java.util.UUID;
import org.bukkit.entity.EntityType;
import org.bukkit.entity.Player;
import org.bukkit.event.EventHandler;
import org.bukkit.event.entity.EntityDeathEvent;
import mineplex.core.common.DefaultHashMap;
import mineplex.core.common.objective.Objective;
import mineplex.core.common.objective.ObjectiveGoal;
public class KillZombiesGoal extends ObjectiveGoal
{
private DefaultHashMap<UUID, Integer> _kills = new DefaultHashMap<>(uuid -> 0);
public KillZombiesGoal(Objective objective)
{
super(objective, "Kill Zombies", "Kill a few zombies in the Fields.");
}
@Override
protected void customStart(Player player)
{
}
@Override
protected void customFinish(Player player)
{
}
@EventHandler
public void entityKilled(EntityDeathEvent event)
{
if (event.getEntityType() != EntityType.ZOMBIE)
{
return;
}
if (event.getEntity().getKiller() == null)
{
return;
}
if (!contains(event.getEntity().getKiller()))
{
return;
}
_kills.put(event.getEntity().getKiller().getUniqueId(), Integer.valueOf(_kills.get(event.getEntity().getKiller().getUniqueId()).intValue() + 1));
}
}

View File

@ -0,0 +1,27 @@
package mineplex.game.clans.tutorial.tutorials.clans.objective.goals.fields;
import org.bukkit.entity.Player;
import org.bukkit.event.EventHandler;
import mineplex.core.common.objective.Objective;
import mineplex.core.common.objective.ObjectiveGoal;
import mineplex.game.clans.clans.event.PlayerEnterTerritoryEvent;
public class MineDiamondsGoal extends ObjectiveGoal
{
public MineDiamondsGoal(Objective objective)
{
super(objective, "Mine 10 diamonds", "Search for some diamonds in the Fields and mine them");
}
@Override
protected void customStart(Player player)
{
}
@Override
protected void customFinish(Player player)
{
}
}