Merge branch 'clans/beta' of https://github.com/Mineplex-LLC/Minecraft-PC into feature/incognito

Conflicts:
	Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/clans/ClansManager.java
This commit is contained in:
Ben 2016-03-18 01:21:25 +00:00
commit a4cbe54c78
90 changed files with 2707 additions and 1459 deletions

View File

@ -0,0 +1,41 @@
package mineplex.core.common.block;
import java.util.ArrayList;
import java.util.Collections;
import java.util.EnumMap;
import java.util.List;
import org.bukkit.DyeColor;
import org.bukkit.Location;
public class DataLocationMap
{
private EnumMap<DyeColor, List<Location>> _dataMap;
public DataLocationMap()
{
_dataMap = new EnumMap<>(DyeColor.class);
}
public List<Location> getLocations(DyeColor color)
{
List<Location> list = _dataMap.get(color);
return list == null ? Collections.emptyList() : list;
}
public void addLocation(DyeColor color, Location location)
{
if (_dataMap.containsKey(color))
{
_dataMap.get(color).add(location);
}
else
{
List<Location> list = new ArrayList<>();
list.add(location);
_dataMap.put(color, list);
}
}
}

View File

@ -1,9 +1,12 @@
package mineplex.core.common.block.schematic;
import org.bukkit.DyeColor;
import org.bukkit.Location;
import org.bukkit.Material;
import org.bukkit.block.Block;
import mineplex.core.common.block.DataLocationMap;
public class Schematic
{
private final short _width;
@ -21,8 +24,10 @@ public class Schematic
_blockData = blockData;
}
public void paste(Location originLocation)
public DataLocationMap paste(Location originLocation)
{
DataLocationMap locationMap = new DataLocationMap();
int startX = originLocation.getBlockX();
int startY = originLocation.getBlockY();
int startZ = originLocation.getBlockZ();
@ -34,7 +39,6 @@ public class Schematic
for (int z = 0; z < _length; z++)
{
int index = getIndex(x, y, z);
Block block = originLocation.getWorld().getBlockAt(startX + x, startY + y, startZ + z);
// some blocks were giving me negative id's in the schematic (like stairs)
// not sure why but the math.abs is my simple fix
int materialId = Math.abs(_blocks[index]);
@ -42,13 +46,58 @@ public class Schematic
Material material = Material.getMaterial(materialId);
if (material == null)
{
System.out.println(materialId + " data: " + _blockData[index]);
System.err.println("Schematic: Could not find Material [id: " + materialId + " data: " + _blockData[index] + "]");
continue;
}
else if (material == Material.GOLD_PLATE)
{
// Check for data wool at location below the gold plate
if (addDataWool(locationMap, originLocation, x, y - 1, z))
continue;
}
else if (material == Material.WOOL)
{
// Check if this is a dataloc so we can skip setting the block
int aboveIndex = getIndex(x, y + 1, z);
if (hasIndex(aboveIndex))
{
if (Math.abs(_blocks[aboveIndex]) == Material.GOLD_PLATE.getId())
continue;
}
}
Block block = originLocation.getWorld().getBlockAt(startX + x, startY + y, startZ + z);
block.setTypeIdAndData(materialId, _blockData[index], false);
}
}
}
return locationMap;
}
/**
* Checks the schematic location for x, y, z and adds the a Location to the DataLocationMap if it is a wool block
*
* @return true if a location was added to the DataLocationMap
*/
private boolean addDataWool(DataLocationMap map, Location origin, int x, int y, int z)
{
int index = getIndex(x, y, z);
if (hasIndex(index))
{
int materialId = Math.abs(_blocks[index]);
if (materialId == 35) // WOOL
{
byte data = _blockData[index];
DyeColor color = DyeColor.getByWoolData(data);
if (color != null)
{
map.addLocation(color, origin.clone().add(x + 0.5, y + 0.5, z + 0.5));
return true;
}
}
}
return false;
}
public int getSize()
@ -61,6 +110,11 @@ public class Schematic
return y * _width * _length + z * _width + x;
}
public boolean hasIndex(int index)
{
return index < _blocks.length;
}
public short getBlock(int x, int y, int z)
{
return _blocks[getIndex(x, y, z)];
@ -99,6 +153,6 @@ public class Schematic
@Override
public String toString()
{
return String.format("width: %d, length: %d, height: %d, blockLength: %d, blockDataLength: %d", _width, _length, _height, _blocks.length, _blockData.length);
return String.format("Schematic [width: %d, length: %d, height: %d, blockLength: %d, blockDataLength: %d]", _width, _length, _height, _blocks.length, _blockData.length);
}
}

View File

@ -0,0 +1,15 @@
package mineplex.core.common.generator;
import java.util.Random;
import org.bukkit.World;
import org.bukkit.generator.ChunkGenerator;
public class VoidGenerator extends ChunkGenerator
{
@Override
public ChunkData generateChunkData(World world, Random random, int x, int z, BiomeGrid biome)
{
return createChunkData(world);
}
}

View File

@ -1,8 +1,10 @@
package mineplex.core.common.objective;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.LinkedList;
import java.util.List;
import java.util.Set;
import java.util.UUID;
import org.bukkit.entity.Player;
@ -10,35 +12,45 @@ import org.bukkit.event.HandlerList;
import org.bukkit.event.Listener;
import org.bukkit.plugin.java.JavaPlugin;
import mineplex.core.common.util.UtilPlayer;
import mineplex.core.common.util.UtilServer;
/**
* An Objective represents a set of goals that need to be completed to move on to the next Objective in the quest
*/
public abstract class Objective<Data extends ObjectiveData> implements Listener
public abstract class Objective<Plugin, Data extends ObjectiveData> implements Listener
{
private JavaPlugin _plugin;
private Plugin _plugin;
private JavaPlugin _javaPlugin;
private String _name;
private String _description;
private HashMap<UUID, Data> _active;
private List<ObjectiveListener> _listeners;
public Objective(JavaPlugin plugin, String name, String description)
public Objective(Plugin plugin, JavaPlugin javaPlugin, String name, String description)
{
_plugin = plugin;
_javaPlugin = javaPlugin;
_name = name;
_description = description;
_active = new HashMap<>();
_listeners = new LinkedList<>();
plugin.getServer().getPluginManager().registerEvents(this, plugin);
javaPlugin.getServer().getPluginManager().registerEvents(this, javaPlugin);
}
public JavaPlugin getPlugin()
public Plugin getPlugin()
{
return _plugin;
}
public JavaPlugin getJavaPlugin()
{
return _javaPlugin;
}
/**
* Get the name of this Objective
*/
@ -72,6 +84,8 @@ public abstract class Objective<Data extends ObjectiveData> implements Listener
_listeners.clear();
}
protected abstract void customStart(Player player);
/**
* Start this Objective for a player
* @param player
@ -88,8 +102,6 @@ public abstract class Objective<Data extends ObjectiveData> implements Listener
customStart(player);
}
protected abstract void customStart(Player player);
/**
* Leave this objective for a specific player
* This does not count as completing the object
@ -152,6 +164,20 @@ public abstract class Objective<Data extends ObjectiveData> implements Listener
return new LinkedList<UUID>(_active.keySet());
}
protected final Player[] getActivePlayers()
{
Set<UUID> uuidSet = _active.keySet();
Player[] players = new Player[uuidSet.size()];
int index = 0;
for (UUID uuid : uuidSet)
{
players[index] = UtilPlayer.searchExact(uuid);
index++;
}
return players;
}
public Data getData(Player player)
{
return _active.get(player.getUniqueId());
@ -167,4 +193,6 @@ public abstract class Objective<Data extends ObjectiveData> implements Listener
List<ObjectiveGoal> goals = getGoals();
if (goals != null) goals.forEach(HandlerList::unregisterAll);
}
public abstract void addScoreboardLines(Player player, List<String> lines);
}

View File

@ -7,13 +7,15 @@ import org.bukkit.entity.Player;
import org.bukkit.event.HandlerList;
import org.bukkit.plugin.java.JavaPlugin;
public abstract class OrderedObjective extends Objective<OrderedObjectiveData>
import net.md_5.bungee.api.ChatColor;
public abstract class OrderedObjective<Plugin> extends Objective<Plugin, OrderedObjectiveData>
{
private List<ObjectiveGoal> _goals;
public OrderedObjective(JavaPlugin plugin, String name, String description)
public OrderedObjective(Plugin plugin, JavaPlugin javaPlugin, String name, String description)
{
super(plugin, name, description);
super(plugin, javaPlugin, name, description);
_goals = new ArrayList<>();
}
@ -22,7 +24,7 @@ public abstract class OrderedObjective extends Objective<OrderedObjectiveData>
{
_goals.add(goal);
getPlugin().getServer().getPluginManager().registerEvents(goal, getPlugin());
getJavaPlugin().getServer().getPluginManager().registerEvents(goal, getJavaPlugin());
}
@Override
@ -68,4 +70,28 @@ public abstract class OrderedObjective extends Objective<OrderedObjectiveData>
{
return _goals;
}
@Override
public void addScoreboardLines(Player player, List<String> lines)
{
if (contains(player))
{
OrderedObjectiveData data = getData(player);
lines.add(" " + getName());
for (int i = 0; i < _goals.size(); i++)
{
String prefix;
if (i > data.getIndex())
prefix = ChatColor.RED.toString();
else if (i == data.getIndex())
prefix = ">" + ChatColor.YELLOW.toString();
else
prefix = ChatColor.GREEN.toString();
lines.add(" " + prefix + _goals.get(i).getName());
}
}
}
}

View File

@ -6,13 +6,13 @@ import java.util.UUID;
import org.bukkit.entity.Player;
import org.bukkit.plugin.java.JavaPlugin;
public abstract class SingleObjective extends Objective<ObjectiveData>
public abstract class SingleObjective<Plugin> extends Objective<Plugin, ObjectiveData>
{
private final ObjectiveData _nullData;
public SingleObjective(JavaPlugin plugin, String name, String description)
public SingleObjective(Plugin plugin, JavaPlugin javaPlugin, String name, String description)
{
super(plugin, name, description);
super(plugin, javaPlugin, name, description);
_nullData = new ObjectiveData();
}
@ -35,4 +35,12 @@ public abstract class SingleObjective extends Objective<ObjectiveData>
return null;
}
@Override
public void addScoreboardLines(Player player, List<String> lines)
{
if (contains(player))
{
lines.add(" " + getName());
}
}
}

View File

@ -0,0 +1,27 @@
package mineplex.core.common.util;
import java.util.HashMap;
import java.util.Map;
public class MapBuilder<K, V>
{
private Map<K, V> _map;
public MapBuilder()
{
_map = new HashMap<>();
}
public MapBuilder<K, V> Put(K key, V value)
{
_map.put(key, value);
return this;
}
public Map<K, V> GetMap()
{
return _map;
}
}

View File

@ -2,14 +2,12 @@ package mineplex.core.common.util;
import java.util.Arrays;
import java.util.Collection;
import java.util.Iterator;
import java.util.List;
import java.util.Random;
import java.util.function.BiConsumer;
import java.util.function.Consumer;
import java.util.function.Function;
import java.util.stream.Stream;
import org.bukkit.inventory.ItemStack;
import com.google.common.collect.Lists;
@ -230,7 +228,7 @@ public class UtilCollections
return array[Random.nextInt(array.length)];
}
public static <T> Collection<? extends T> toList(T[] array)
public static <T> List<? extends T> toList(T[] array)
{
return Lists.newArrayList(array);
}
@ -240,4 +238,41 @@ public class UtilCollections
return Arrays.equals(array1, array2);
}
public static <X> void ForEach(List<X> list, Consumer<X> consumer)
{
Iterator<X> iterator = list.iterator();
while (iterator.hasNext())
{
consumer.accept(iterator.next());
}
}
@SafeVarargs
public static <X> List<? extends X> newList(X... elements)
{
return toList(elements);
}
public static <X> String combine(X[] data, String delimiter)
{
StringBuilder total = new StringBuilder();
int loops = 0;
for (X x : data)
{
if (delimiter != null && loops != 0)
{
total.append(delimiter);
}
total.append(x.toString());
loops++;
}
return total.toString();
}
}

View File

@ -50,5 +50,4 @@ public class UtilFile
return bytes;
}
}

View File

@ -1,5 +1,6 @@
package mineplex.core.common.util;
import java.lang.reflect.Field;
import java.util.ArrayList;
import java.util.Collection;
import java.util.Collections;
@ -19,8 +20,17 @@ import org.bukkit.plugin.Plugin;
import org.bukkit.plugin.PluginManager;
import org.bukkit.scheduler.BukkitRunnable;
import com.google.common.collect.Lists;
public class UtilServer
{
// Quite hacky. would be nice if we could have a "MineplexPlugin" interface
// which would define a getServerName() method and then implement it in
// whatever way needed.
// MineplexPlugin plugin = (MineplexPlugin) plugin.getClass().getDeclaredMethod("getMineplexPlugin").invoke(plugin);
// plugin.getServerName();
private static String _serverName;
public static Player[] getPlayers()
{
return getServer().getOnlinePlayers().toArray(new Player[0]);
@ -138,4 +148,65 @@ public class UtilServer
{
return getServer().getOfflinePlayer(player);
}
public static String getServerName()
{
if (_serverName == null)
{
try
{
Class<?> Portal = Class.forName("mineplex.core.portal.Portal");
Object instance = null;
List<Field> stringFields = Lists.newArrayList();
for (Field field : Portal.getDeclaredFields())
{
if (field.getType().equals(Portal))
{
field.setAccessible(true);
instance = field.get(null);
}
if (field.getType().equals(String.class))
{
stringFields.add(field);
}
}
for (Field field : stringFields)
{
field.setAccessible(true);
String value = (String) field.get(instance);
if (stringFields.size() > 1)
{
if (value.contains("-"))
{
_serverName = new String(value);
}
}
else
{
_serverName = new String(value);
}
}
if (_serverName == null)
{
_serverName = "UNKOWN";
System.out.println("ERROR: Could not get server name from Portal. Cause is most likely ambiguous fields in the class. Please revise UtilServer's method of getting the current server name.");
}
}
catch (Exception exception)
{
System.out.println("FATAL ERROR WHILE TRYING TO GET SERVER NAME");
exception.printStackTrace();
}
}
return _serverName;
}
}

View File

@ -1,7 +1,11 @@
package mineplex.core.common.util;
import java.io.DataInputStream;
import java.io.IOException;
import java.util.stream.Stream;
import org.apache.commons.lang.Validate;
public class UtilStreams
{
public static boolean IsEmpty(Stream<?> stream)
@ -39,4 +43,16 @@ public class UtilStreams
return Get(Sum(stream) + 1, stream);
}
public static byte[] ReadBytes(DataInputStream dos, int bytes) throws IOException
{
Validate.isTrue(bytes > 0, "Amount of bytes to read must be > 0");
byte[] read = new byte[bytes];
for (int i = 0; i < bytes; i++)
read[i] = dos.readByte();
return read;
}
}

View File

@ -6,7 +6,7 @@ import java.io.InputStream;
import java.util.ArrayList;
import java.util.Collection;
import java.util.HashMap;
import java.util.Map;
import java.util.UUID;
import javax.imageio.ImageIO;

View File

@ -0,0 +1,58 @@
package mineplex.core.common.util;
import java.io.BufferedReader;
import java.io.InputStreamReader;
import java.io.Reader;
import java.net.HttpURLConnection;
import java.net.URL;
import java.net.URLEncoder;
import java.util.Map;
public class UtilWeb
{
public static String doPOST(String url, Map<String, Object> params)
{
try
{
StringBuilder postData = new StringBuilder();
for (Map.Entry<String,Object> param : params.entrySet())
{
if (postData.length() != 0)
{
postData.append('&');
}
postData.append(URLEncoder.encode(param.getKey(), "UTF-8"));
postData.append('=');
postData.append(URLEncoder.encode(String.valueOf(param.getValue()), "UTF-8"));
}
byte[] postDataBytes = postData.toString().getBytes("UTF-8");
HttpURLConnection conn = (HttpURLConnection) new URL(url).openConnection();
conn.setRequestMethod("POST");
conn.setRequestProperty("Content-Type", "application/x-www-form-urlencoded");
conn.setRequestProperty("Content-Length", String.valueOf(postDataBytes.length));
conn.setDoOutput(true);
conn.getOutputStream().write(postDataBytes);
Reader in = new BufferedReader(new InputStreamReader(conn.getInputStream(), "UTF-8"));
StringBuilder back = new StringBuilder();
for (int $char; ($char = in.read()) >= 0;)
{
back.append((char) $char);
}
return back.toString();
}
catch (Exception exception)
{
exception.printStackTrace();
return null;
}
}
}

View File

@ -15,7 +15,6 @@ public abstract class MiniClientPlugin<DataType extends Object> extends MiniPlug
private NautHashMap<String, DataType> _clientData = new NautHashMap<String, DataType>();
public MiniClientPlugin(String moduleName, JavaPlugin plugin)
{
super(moduleName, plugin);
@ -41,7 +40,7 @@ public abstract class MiniClientPlugin<DataType extends Object> extends MiniPlug
return _clientData.get(name);
}
}
public void saveData(String name, int accountId) {}
public DataType Get(Player player)

View File

@ -20,11 +20,15 @@ public abstract class MiniPlugin implements Listener
protected JavaPlugin _plugin;
protected NautHashMap<String, ICommand> _commands;
protected long _initializedTime;
public MiniPlugin(String moduleName, JavaPlugin plugin)
{
_moduleName = moduleName;
_plugin = plugin;
_initializedTime = System.currentTimeMillis();
_commands = new NautHashMap<String, ICommand>();
onEnable();

View File

@ -185,7 +185,7 @@ public class CoreClientManager extends MiniPlugin
if (!LoadClient(Add(event.getName()), event.getUniqueId(), event.getAddress().getHostAddress()))
event.disallow(Result.KICK_OTHER, "There was a problem logging you in.");
}
catch(Exception exception)
catch (Exception exception)
{
event.disallow(Result.KICK_OTHER, "Error retrieving information from web, please retry in a minute.");
exception.printStackTrace();

View File

@ -7,9 +7,12 @@ import java.io.InputStreamReader;
import java.net.URL;
import java.nio.charset.Charset;
import java.security.cert.X509Certificate;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.Iterator;
import java.util.List;
import java.util.UUID;
import java.util.function.Function;
import javax.net.ssl.HostnameVerifier;
import javax.net.ssl.HttpsURLConnection;
@ -18,6 +21,7 @@ import javax.net.ssl.SSLSession;
import javax.net.ssl.TrustManager;
import javax.net.ssl.X509TrustManager;
import org.apache.commons.lang3.Validate;
import org.bukkit.entity.Player;
import org.bukkit.event.EventHandler;
import org.bukkit.event.EventPriority;
@ -65,7 +69,9 @@ public class Chat extends MiniPlugin
private long _silenced = 0;
private boolean _threeSecondDelay = true;
private List<Function<AsyncPlayerChatEvent, Boolean>> _highPriorityFilters = new ArrayList<>();
private List<Function<AsyncPlayerChatEvent, Boolean>> _lowPriorityFilters = new ArrayList<>();
private HashMap<UUID, MessageData> _playerLastMessage = new HashMap<UUID, MessageData>();
public Chat(JavaPlugin plugin, CoreClientManager clientManager, PreferencesManager preferences, AchievementManager achievements, String serverName)
@ -309,6 +315,15 @@ public class Chat extends MiniPlugin
return;
}
for (Function<AsyncPlayerChatEvent, Boolean> filter : _highPriorityFilters)
{
if (filter.apply(event).booleanValue())
{
event.setCancelled(true);
return;
}
}
if (SilenceCheck(sender))
{
event.setCancelled(true);
@ -355,12 +370,21 @@ public class Chat extends MiniPlugin
event.setCancelled(true);
}
}
if (!event.isCancelled())
_playerLastMessage.put(sender.getUniqueId(), new MessageData(event.getMessage()));
for (Function<AsyncPlayerChatEvent, Boolean> filter : _lowPriorityFilters)
{
if (filter.apply(event).booleanValue())
{
event.setCancelled(true);
return;
}
}
}
private boolean msgContainsHack(String msg)
private boolean msgContainsHack(String msg)
{
msg = " " + msg.toLowerCase().replaceAll("[^a-z ]", "") + " ";
for (String s : _hackusations) {
@ -605,4 +629,22 @@ public class Chat extends MiniPlugin
{
_threeSecondDelay = b;
}
/**
* If the function returns Boolean.TRUE then the message will be CANCELLED.
*/
public void AddFilter(Function<AsyncPlayerChatEvent, Boolean> restriction, FilterPriority priority)
{
Validate.isTrue(priority != null, "Priority must not be null.");
switch (priority)
{
case HIGH:
_highPriorityFilters.add(restriction);
break;
case LOW:
_lowPriorityFilters.add(restriction);
}
}
}

View File

@ -279,8 +279,7 @@ public class FriendManager extends MiniDbClientPlugin<FriendData>
if (friend.Status == FriendStatusType.Accepted)
{
// Online Friend and not incognito
if (friend.Online && !IncognitoManager.Instance.getRepository().GetStatus(friend.Name))
if (friend.Online)
{
if (friend.ServerName.contains("Staff") || friend.ServerName.contains("CUST"))
{

View File

@ -129,16 +129,14 @@ public class FriendsGUI implements Listener
FriendStatus friend = friends.get(friendSlot);
boolean incognito = friend.Online ? IncognitoManager.Instance.getRepository().GetStatus(friend.Name) : false;
ItemBuilder builder = new ItemBuilder(Material.SKULL_ITEM, 1, (short) (friend.Online && !incognito ? 3 : 0));
ItemBuilder builder = new ItemBuilder(Material.SKULL_ITEM, 1, (short) (friend.Online ? 3 : 0));
builder.setTitle(C.cWhite + C.Bold + friend.Name);
builder.setPlayerHead(friend.Name);
builder.addLore(C.cGray + C.Bold + "Status: " + (friend.Online ? C.cDGreen + "Online" : C.cRed + "Offline"));
if (friend.Online && !incognito)
if (friend.Online)
{
builder.addLore(C.cGray + C.Bold + "Server: " + C.cYellow + friend.ServerName);
}
@ -276,7 +274,7 @@ public class FriendsGUI implements Listener
FriendStatus friend = friends.get(friendSlot);
boolean incognito = friend.Online ? IncognitoManager.Instance.getRepository().GetStatus(friend.Name) : false;
boolean incognito = friend.Online;
ItemBuilder builder = new ItemBuilder(Material.SKULL_ITEM, 1, (short) (friend.Online && !incognito ? 3 : 0));

View File

@ -22,11 +22,9 @@ import net.minecraft.server.v1_8_R3.PacketPlayOutEntityMetadata;
import net.minecraft.server.v1_8_R3.PacketPlayOutEntityTeleport;
import net.minecraft.server.v1_8_R3.PacketPlayOutSpawnEntityLiving;
public class Hologram
{
public class Hologram {
public enum HologramTarget
{
public enum HologramTarget {
BLACKLIST, WHITELIST;
}
@ -39,7 +37,8 @@ public class Hologram
private HologramManager _hologramManager;
private String[] _hologramText = new String[0];
/**
* Keeps track of the holograms movements. This fixes offset that occasionally happens when moving a hologram around.
* Keeps track of the holograms movements. This fixes offset that
* occasionally happens when moving a hologram around.
*/
private Vector _lastMovement;
private Location _location;
@ -55,38 +54,41 @@ public class Hologram
private boolean _hideBoundingBox;
private HologramInteraction _interaction;
public Hologram(HologramManager hologramManager, Location location, String... text)
{
private long _maxLifetime = -1;
private long _startTime;
public Hologram(HologramManager hologramManager, Location location, String... text) {
this(hologramManager, location, -1l, text);
}
public Hologram(HologramManager hologramManager, Location location, long maxLifetime, String... text) {
_hologramManager = hologramManager;
_location = location.clone();
_maxLifetime = maxLifetime;
setText(text);
}
public Hologram setInteraction(HologramInteraction interact)
{
public Hologram setInteraction(HologramInteraction interact) {
_interaction = interact;
return this;
}
public HologramInteraction getInteraction()
{
public HologramInteraction getInteraction() {
return _interaction;
}
/**
* Adds the player to the Hologram to be effected by Whitelist or Blacklist
*/
public Hologram addPlayer(Player player)
{
public Hologram addPlayer(Player player) {
return addPlayer(player.getName());
}
/**
* Adds the player to the Hologram to be effected by Whitelist or Blacklist
*/
public Hologram addPlayer(String player)
{
public Hologram addPlayer(String player) {
_playersInList.add(player);
return this;
}
@ -96,8 +98,7 @@ public class Hologram
*
* @return
*/
public Hologram setHideBoundingBox()
{
public Hologram setHideBoundingBox() {
_hideBoundingBox = true;
return this;
}
@ -105,23 +106,19 @@ public class Hologram
/**
* Is there a player entry in the hologram for Whitelist and Blacklist
*/
public boolean containsPlayer(Player player)
{
public boolean containsPlayer(Player player) {
return _playersInList.contains(player.getName());
}
/**
* Is there a player entry in the hologram for Whitelist and Blacklist
*/
public boolean containsPlayer(String player)
{
public boolean containsPlayer(String player) {
return _playersInList.contains(player);
}
protected Packet getDestroyPacket()
{
if (_makeDestroyPackets)
{
protected Packet getDestroyPacket() {
if (_makeDestroyPackets) {
makeDestroyPacket();
_makeDestroyPackets = false;
}
@ -129,8 +126,7 @@ public class Hologram
return _destroy1_8;
}
public Entity getEntityFollowing()
{
public Entity getEntityFollowing() {
return _followEntity;
}
@ -140,27 +136,22 @@ public class Hologram
* @Whitelist = Only people added can see the hologram
* @Blacklist = Anyone but people added can see the hologram
*/
public HologramTarget getHologramTarget()
{
public HologramTarget getHologramTarget() {
return _target;
}
/**
* Get the hologram location
*/
public Location getLocation()
{
public Location getLocation() {
return _location.clone();
}
protected ArrayList<Player> getNearbyPlayers()
{
protected ArrayList<Player> getNearbyPlayers() {
ArrayList<Player> nearbyPlayers = new ArrayList<Player>();
for (Player player : getLocation().getWorld().getPlayers())
{
if (isVisible(player))
{
for (Player player : getLocation().getWorld().getPlayers()) {
if (isVisible(player)) {
nearbyPlayers.add(player);
}
}
@ -168,15 +159,12 @@ public class Hologram
return nearbyPlayers;
}
protected ArrayList<Player> getPlayersTracking()
{
protected ArrayList<Player> getPlayersTracking() {
return _playersTracking;
}
protected Packet[] getSpawnPackets()
{
if (_makeSpawnPackets)
{
protected Packet[] getSpawnPackets() {
if (_makeSpawnPackets) {
makeSpawnPackets();
_makeSpawnPackets = false;
}
@ -187,13 +175,12 @@ public class Hologram
/**
* Get the text in the hologram
*/
public String[] getText()
{
// We reverse it again as the hologram would otherwise display the text from the bottom row to the top row
public String[] getText() {
// We reverse it again as the hologram would otherwise display the text
// from the bottom row to the top row
String[] reversed = new String[_hologramText.length];
for (int i = 0; i < reversed.length; i++)
{
for (int i = 0; i < reversed.length; i++) {
reversed[i] = _hologramText[reversed.length - (i + 1)];
}
@ -203,32 +190,25 @@ public class Hologram
/**
* Get the view distance the hologram is viewable from. Default is 70
*/
public int getViewDistance()
{
public int getViewDistance() {
return _viewDistance;
}
/**
* Is the hologram holograming?
*/
public boolean isInUse()
{
public boolean isInUse() {
return _lastMovement != null;
}
public boolean isRemoveOnEntityDeath()
{
public boolean isRemoveOnEntityDeath() {
return _removeEntityDeath;
}
public boolean isVisible(Player player)
{
if (getLocation().getWorld() == player.getWorld())
{
if ((getHologramTarget() == HologramTarget.WHITELIST) == containsPlayer(player))
{
if (getLocation().distance(player.getLocation()) < getViewDistance())
{
public boolean isVisible(Player player) {
if (getLocation().getWorld() == player.getWorld()) {
if ((getHologramTarget() == HologramTarget.WHITELIST) == containsPlayer(player)) {
if (getLocation().distance(player.getLocation()) < getViewDistance()) {
return true;
}
}
@ -237,53 +217,42 @@ public class Hologram
return false;
}
private void makeDestroyPacket()
{
private void makeDestroyPacket() {
int[] entityIds1_8 = new int[_entityIds.size()];
for (int i = 0; i < _entityIds.size(); i++)
{
for (int i = 0; i < _entityIds.size(); i++) {
entityIds1_8[i] = _entityIds.get(i);
}
_destroy1_8 = new PacketPlayOutEntityDestroy(entityIds1_8);
}
private void makeSpawnPackets()
{
private void makeSpawnPackets() {
_packets1_8 = new Packet[_hologramText.length * 1];
if (_entityIds.size() < _hologramText.length)
{
if (_entityIds.size() < _hologramText.length) {
_makeDestroyPackets = true;
for (int i = _entityIds.size(); i < _hologramText.length; i++)
{
for (int i = _entityIds.size(); i < _hologramText.length; i++) {
_entityIds.add(Integer.valueOf(UtilEnt.getNewEntityId()));
}
}
else
{
} else {
_makeDestroyPackets = true;
while (_entityIds.size() > _hologramText.length)
{
while (_entityIds.size() > _hologramText.length) {
_entityIds.remove(_hologramText.length);
}
}
for (int textRow = 0; textRow < _hologramText.length; textRow++)
{
for (int textRow = 0; textRow < _hologramText.length; textRow++) {
Packet[] packets1_8 = makeSpawnPackets1_8(textRow, _entityIds.get(textRow), _hologramText[textRow]);
for (int i = 0; i < packets1_8.length; i++)
{
for (int i = 0; i < packets1_8.length; i++) {
_packets1_8[textRow + i] = packets1_8[i];
}
}
}
private Packet[] makeSpawnPackets1_8(int textRow, int entityId, String lineOfText)
{
private Packet[] makeSpawnPackets1_8(int textRow, int entityId, String lineOfText) {
PacketPlayOutSpawnEntityLiving packet = new PacketPlayOutSpawnEntityLiving();
DataWatcher watcher = new DataWatcher(null);
@ -300,44 +269,47 @@ public class Hologram
watcher.a(2, lineOfText, EntityArmorStand.META_CUSTOMNAME, lineOfText);
watcher.a(3, (byte) 1, EntityArmorStand.META_CUSTOMNAME_VISIBLE, true);
if (_hideBoundingBox)
{
watcher.a(10, (byte) 16, EntityArmorStand.META_ARMOR_OPTION, (byte) 16); // TODO Uncomment after we can enforce 1.8.3
if (_hideBoundingBox) {
watcher.a(10, (byte) 16, EntityArmorStand.META_ARMOR_OPTION, (byte) 16); // TODO
// Uncomment
// after
// we
// can
// enforce
// 1.8.3
}
// Also correct hologram positioning
return new Packet[]
{
packet
};
return new Packet[] { packet };
}
/**
* Removes the player from the Hologram so they are no longer effected by Whitelist or Blacklist
* Removes the player from the Hologram so they are no longer effected by
* Whitelist or Blacklist
*/
public Hologram removePlayer(Player player)
{
public Hologram removePlayer(Player player) {
return removePlayer(player.getName());
}
/**
* Removes the player from the Hologram so they are no longer effected by Whitelist or Blacklist
* Removes the player from the Hologram so they are no longer effected by
* Whitelist or Blacklist
*/
public Hologram removePlayer(String player)
{
public Hologram removePlayer(String player) {
_playersInList.remove(player);
return this;
}
/**
* If the entity moves, the hologram will update its position to appear relative to the movement.
* If the entity moves, the hologram will update its position to appear
* relative to the movement.
*
* @Please note the hologram updates every tick.
*/
public Hologram setFollowEntity(Entity entityToFollow)
{
public Hologram setFollowEntity(Entity entityToFollow) {
_followEntity = entityToFollow;
relativeToEntity = entityToFollow == null ? null : _location.clone().subtract(entityToFollow.getLocation()).toVector();
relativeToEntity = entityToFollow == null ? null
: _location.clone().subtract(entityToFollow.getLocation()).toVector();
return this;
}
@ -348,8 +320,7 @@ public class Hologram
* @Whitelist = Only people added can see the hologram
* @Blacklist = Anyone but people added can see the hologram
*/
public Hologram setHologramTarget(HologramTarget newTarget)
{
public Hologram setHologramTarget(HologramTarget newTarget) {
_target = newTarget;
return this;
}
@ -357,52 +328,43 @@ public class Hologram
/**
* Sets the hologram to appear at this location
*/
public Hologram setLocation(Location newLocation)
{
public Hologram setLocation(Location newLocation) {
_makeSpawnPackets = true;
Location oldLocation = getLocation();
_location = newLocation.clone();
if (getEntityFollowing() != null)
{
if (getEntityFollowing() != null) {
relativeToEntity = _location.clone().subtract(getEntityFollowing().getLocation()).toVector();
}
if (isInUse())
{
if (isInUse()) {
ArrayList<Player> canSee = getNearbyPlayers();
Iterator<Player> itel = _playersTracking.iterator();
while (itel.hasNext())
{
while (itel.hasNext()) {
Player player = itel.next();
if (!canSee.contains(player))
{
if (!canSee.contains(player)) {
itel.remove();
if (player.getWorld() == getLocation().getWorld())
{
if (player.getWorld() == getLocation().getWorld()) {
UtilPlayer.sendPacket(player, getDestroyPacket());
}
}
}
itel = canSee.iterator();
while (itel.hasNext())
{
while (itel.hasNext()) {
Player player = itel.next();
if (!_playersTracking.contains(player))
{
if (!_playersTracking.contains(player)) {
_playersTracking.add(player);
itel.remove();
UtilPlayer.sendPacket(player, getSpawnPackets());
}
}
if (!canSee.isEmpty())
{
_lastMovement.add(new Vector(newLocation.getX() - oldLocation.getX(), newLocation.getY() - oldLocation.getY(),
newLocation.getZ() - oldLocation.getZ()));
if (!canSee.isEmpty()) {
_lastMovement.add(new Vector(newLocation.getX() - oldLocation.getX(),
newLocation.getY() - oldLocation.getY(), newLocation.getZ() - oldLocation.getZ()));
int x = (int) Math.floor(32 * _lastMovement.getX());
int y = (int) Math.floor(32 * _lastMovement.getY());
@ -412,11 +374,9 @@ public class Hologram
int i = 0;
if (x >= -128 && x <= 127 && y >= -128 && y <= 127 && z >= -128 && z <= 127)
{
if (x >= -128 && x <= 127 && y >= -128 && y <= 127 && z >= -128 && z <= 127) {
_lastMovement.subtract(new Vector(x / 32D, y / 32D, z / 32D));
for (Integer entityId : _entityIds)
{
for (Integer entityId : _entityIds) {
PacketPlayOutEntity.PacketPlayOutRelEntityMove relMove = new PacketPlayOutEntity.PacketPlayOutRelEntityMove();
relMove.a = entityId;
@ -427,16 +387,13 @@ public class Hologram
packets1_8[i] = relMove;
i++;
}
}
else
{
} else {
x = (int) Math.floor(32 * newLocation.getX());
z = (int) Math.floor(32 * newLocation.getZ());
_lastMovement = new Vector(newLocation.getX() - (x / 32D), 0, newLocation.getZ() - (z / 32D));
for (Integer entityId : _entityIds)
{
for (Integer entityId : _entityIds) {
PacketPlayOutEntityTeleport teleportPacket = new PacketPlayOutEntityTeleport();
teleportPacket.a = entityId;
teleportPacket.b = x;
@ -449,10 +406,8 @@ public class Hologram
}
}
for (Player player : canSee)
{
for (Packet packet : packets1_8)
{
for (Player player : canSee) {
for (Packet packet : packets1_8) {
UtilPlayer.sendPacket(player, packet);
}
}
@ -461,48 +416,50 @@ public class Hologram
return this;
}
public Hologram setRemoveOnEntityDeath()
public long getStartTime()
{
return _startTime;
}
public long getMaxLifetime()
{
return _maxLifetime;
}
public Hologram setRemoveOnEntityDeath() {
_removeEntityDeath = true;
return this;
}
public boolean isEntityId(int entityId)
{
public boolean isEntityId(int entityId) {
return _entityIds.contains(entityId);
}
/**
* Set the hologram text
*/
public Hologram setText(String... newLines)
{
public Hologram setText(String... newLines) {
String[] newText = new String[newLines.length];
for (int i = 0; i < newText.length; i++)
{
for (int i = 0; i < newText.length; i++) {
newText[i] = newLines[newText.length - (i + 1)];
}
if (newText.equals(_hologramText))
return this;
if (isInUse())
{
if (isInUse()) {
int[] destroy1_8 = new int[0];
ArrayList<Packet> packets1_8 = new ArrayList<Packet>();
if (_hologramText.length != newText.length)
{
if (_hologramText.length != newText.length) {
_makeDestroyPackets = true;
}
for (int i = 0; i < Math.max(_hologramText.length, newText.length); i++)
{
for (int i = 0; i < Math.max(_hologramText.length, newText.length); i++) {
// If more lines than previously
if (i >= _hologramText.length)
{
if (i >= _hologramText.length) {
// Add entity id and send spawn packets
// You add a entity id because the new hologram needs
int entityId = UtilEnt.getNewEntityId();
@ -511,16 +468,13 @@ public class Hologram
packets1_8.addAll(Arrays.asList(makeSpawnPackets1_8(i, entityId, newText[i])));
}
// If less lines than previously
else if (i >= newText.length)
{
else if (i >= newText.length) {
// Remove entity id and send destroy packets
Integer entityId = _entityIds.remove(newText.length);
destroy1_8 = Arrays.copyOf(destroy1_8, destroy1_8.length + 1);
destroy1_8[destroy1_8.length - 1] = entityId;
}
else if (!newText[i].equals(_hologramText[i]))
{
} else if (!newText[i].equals(_hologramText[i])) {
// Send update metadata packets
Integer entityId = _entityIds.get(i);
@ -533,7 +487,8 @@ public class Hologram
watcher1_8.a(0, (byte) 32, EntityArmorStand.META_ENTITYDATA, (byte) 32);
watcher1_8.a(2, newText[i], EntityArmorStand.META_CUSTOMNAME, newText[i]);
watcher1_8.a(3, (byte) 1, EntityArmorStand.META_CUSTOMNAME_VISIBLE, true);
// watcher1_8.a(10, (byte) 16);// TODO Uncomment after we can enforce 1.8.3
// watcher1_8.a(10, (byte) 16);// TODO Uncomment after we
// can enforce 1.8.3
// Also correct hologram positioning
metadata1_8.b = watcher1_8.c();
@ -541,15 +496,12 @@ public class Hologram
}
}
if (destroy1_8.length > 0)
{
if (destroy1_8.length > 0) {
packets1_8.add(new PacketPlayOutEntityDestroy(destroy1_8));
}
for (Player player : _playersTracking)
{
for (Packet packet : packets1_8)
{
for (Player player : _playersTracking) {
for (Packet packet : packets1_8) {
UtilPlayer.sendPacket(player, packet);
}
}
@ -564,8 +516,7 @@ public class Hologram
/**
* Set the distance the hologram is viewable from. Default is 70
*/
public Hologram setViewDistance(int newDistance)
{
public Hologram setViewDistance(int newDistance) {
_viewDistance = newDistance;
return setLocation(getLocation());
}
@ -573,15 +524,15 @@ public class Hologram
/**
* Start the hologram
*/
public Hologram start()
{
if (!isInUse())
{
public Hologram start() {
if (!isInUse()) {
_startTime = System.currentTimeMillis();
_hologramManager.addHologram(this);
_playersTracking.addAll(getNearbyPlayers());
for (Player player : _playersTracking)
{
for (Player player : _playersTracking) {
UtilPlayer.sendPacket(player, getSpawnPackets());
}
@ -593,14 +544,11 @@ public class Hologram
/**
* Stop the hologram
*/
public Hologram stop()
{
if (isInUse())
{
public Hologram stop() {
if (isInUse()) {
_hologramManager.removeHologram(this);
for (Player player : _playersTracking)
{
for (Player player : _playersTracking) {
UtilPlayer.sendPacket(player, getDestroyPacket());
}

View File

@ -5,6 +5,7 @@ import java.util.Iterator;
import java.util.List;
import mineplex.core.common.util.UtilPlayer;
import mineplex.core.common.util.UtilTime;
import mineplex.core.packethandler.IPacketHandler;
import mineplex.core.packethandler.PacketHandler;
import mineplex.core.packethandler.PacketInfo;
@ -52,15 +53,20 @@ public class HologramManager implements Listener, IPacketHandler
List<World> worlds = Bukkit.getWorlds();
Iterator<Hologram> itel = _activeHolograms.iterator();
Iterator<Hologram> iterator = _activeHolograms.iterator();
while (itel.hasNext())
while (iterator.hasNext())
{
Hologram hologram = itel.next();
if (!worlds.contains(hologram.getLocation().getWorld()))
Hologram hologram = iterator.next();
if (hologram.getMaxLifetime() != -1 && UtilTime.elapsed(hologram.getStartTime(), hologram.getMaxLifetime()))
{
itel.remove();
iterator.remove();
hologram.stop();
}
else if (!worlds.contains(hologram.getLocation().getWorld()))
{
iterator.remove();
hologram.stop();
}
else
@ -71,7 +77,7 @@ public class HologramManager implements Listener, IPacketHandler
if (hologram.isRemoveOnEntityDeath() && !following.isValid())
{
itel.remove();
iterator.remove();
hologram.stop();
continue;
}

View File

@ -10,9 +10,10 @@ import mineplex.serverdata.database.column.ColumnInt;
public class IncognitoRepository extends MinecraftRepository
{
private static final String CREATE_TABLE = "CREATE TABLE IF NOT EXISTS incognitoStaff (accountId INT NOT NULL, status TINYINT(1) DEFAULT '0');";
private static final String CREATE_TABLE = "CREATE TABLE IF NOT EXISTS incognitoStaff (accountId INT NOT NULL, status TINYINT(1) DEFAULT '0', PRIMARY KEY (accountId));";
private static final String GET_STATUS = "SELECT * FROM incognitoStaff WHERE accountId = ?;";
private static final String SET_STATUS = "INSERT INTO incognitoStaff (accountId, status) VALUES (?, ?);";
private static final String INSERT_STATUS = "INSERT INTO incognitoStaff (accountId, status) VALUES (?, ?);";
private static final String UPDATE_STATUS = "UPDATE incognitoStaff SET status=? WHERE accountId=?;";
private IncognitoManager _incognitoManager;
@ -29,8 +30,13 @@ public class IncognitoRepository extends MinecraftRepository
public void SetStatus(int accountId, boolean status)
{
System.out.println("[INCOGNITO] Updated status for " + accountId + " to " + status);
executeUpdate(SET_STATUS, new ColumnInt("accountId", accountId), new ColumnInt("status", status ? 1 : 0));
// Prevent duplicate entries for individuals
executeQuery(GET_STATUS, result -> {
if (result.next())
executeUpdate(UPDATE_STATUS, new ColumnInt("status", status ? 1 : 0), new ColumnInt("accountId", accountId));
else
executeUpdate(INSERT_STATUS, new ColumnInt("accountId", accountId), new ColumnInt("status", status ? 1 : 0));
}, new ColumnInt("accountId", accountId));
}
public boolean GetStatus(int accountId)

View File

@ -32,6 +32,7 @@ import mineplex.serverdata.commands.ServerCommandManager;
public class ResourcePackManager extends MiniPlugin implements CommandCallback
{
private String _resourcePackUrl;
private String _resourcePackUrl19; // Resource pack for 1.9 clients
private boolean _resourcePackRequired;
private NautHashMap<String, Boolean> _resourcePackUsers = new NautHashMap<String, Boolean>();
private NautHashMap<String, Long> _resourcePackNoResponse = new NautHashMap<String, Long>();
@ -62,7 +63,10 @@ public class ResourcePackManager extends MiniPlugin implements CommandCallback
}
_resourcePackUsers.put(player.getName(), false);
player.setResourcePack(_resourcePackUrl);
String url = getUrl(player);
System.out.println("Set resource pack for player: " + player + " to " + url);
player.setResourcePack(url);
}
@EventHandler
@ -89,7 +93,7 @@ public class ResourcePackManager extends MiniPlugin implements CommandCallback
// Send it again, enforce it!
_resourcePackNoResponse.put(player.getName(), System.currentTimeMillis());
player.setResourcePack(_resourcePackUrl);
player.setResourcePack(getUrl(player));
}
}
@ -177,6 +181,11 @@ public class ResourcePackManager extends MiniPlugin implements CommandCallback
}
public void setResourcePack(String resourcePack, boolean forceResourcePack)
{
setResourcePack(resourcePack, resourcePack, forceResourcePack);
}
public void setResourcePack(String resourcePack, String resourcePack19, boolean forceResourcePack)
{
if (Objects.equal(resourcePack, _resourcePackUrl) && forceResourcePack == _resourcePackRequired)
{
@ -186,6 +195,7 @@ public class ResourcePackManager extends MiniPlugin implements CommandCallback
_resourcePackNoResponse.clear();
_resourcePackUsers.clear();
_resourcePackUrl = resourcePack == null || resourcePack.isEmpty() ? null : resourcePack;
_resourcePackUrl19 = resourcePack19;
_resourcePackRequired = forceResourcePack;
if (_resourcePackUrl == null || _resourcePackUrl.isEmpty())
@ -207,7 +217,7 @@ public class ResourcePackManager extends MiniPlugin implements CommandCallback
}
_resourcePackUsers.put(player.getName(), false);
player.setResourcePack(_resourcePackUrl);
player.setResourcePack(getUrl(player));
}
}
}
@ -235,4 +245,9 @@ public class ResourcePackManager extends MiniPlugin implements CommandCallback
}
}
private String getUrl(Player player)
{
return UtilPlayer.is1_9(player) ? _resourcePackUrl19 : _resourcePackUrl;
}
}

View File

@ -0,0 +1,154 @@
package mineplex.core.texttutorial;
import java.util.HashSet;
import java.util.Iterator;
import org.bukkit.Sound;
import org.bukkit.entity.LivingEntity;
import org.bukkit.entity.Player;
import org.bukkit.event.EventHandler;
import org.bukkit.event.player.PlayerInteractEntityEvent;
import org.bukkit.event.player.PlayerInteractEvent;
import org.bukkit.event.player.PlayerQuitEvent;
import org.bukkit.plugin.java.JavaPlugin;
import mineplex.core.MiniPlugin;
import mineplex.core.common.util.C;
import mineplex.core.common.util.Callback;
import mineplex.core.common.util.F;
import mineplex.core.common.util.UtilPlayer;
import mineplex.core.donation.DonationManager;
import mineplex.core.task.TaskManager;
import mineplex.core.texttutorial.tutorial.Tutorial;
import mineplex.core.texttutorial.tutorial.TutorialData;
import mineplex.core.updater.UpdateType;
import mineplex.core.updater.event.UpdateEvent;
public class TextTutorialManager extends MiniPlugin
{
private DonationManager _donationManager;
private TaskManager _taskManager;
private HashSet<Tutorial> _tutorials;
public TextTutorialManager(JavaPlugin plugin, DonationManager donationManager, TaskManager taskManager)
{
super("Text Tutorial", plugin);
_donationManager = donationManager;
_taskManager = taskManager;
}
@EventHandler
public void startTutorial(PlayerInteractEntityEvent event)
{
if (isInTutorial(event.getPlayer()))
return;
if (!(event.getRightClicked() instanceof LivingEntity))
return;
LivingEntity ent = (LivingEntity)event.getRightClicked();
String name = ent.getCustomName();
if (name == null)
return;
for (Tutorial tut : _tutorials)
{
if (name.contains(tut.getName()))
{
UtilPlayer.message(event.getPlayer(), F.main("Tutorial", "You started " + F.elem(tut.getName()) + "."));
tut.startTutorial(event.getPlayer());
return;
}
}
}
@EventHandler
public void update(UpdateEvent event)
{
if (event.getType() != UpdateType.TICK)
return;
for (final Tutorial tut : _tutorials)
{
Iterator<TutorialData> iterator = tut.getTutorialDatas().iterator();
while (iterator.hasNext())
{
TutorialData data = iterator.next();
final Player player = data.getPlayer();
//Check if Phase Completed
if (data.tick())
{
//Next Phase
if (data.getPhaseStep() < tut.getPhaseSize())
{
data.setNextPhase(tut.getPhase(data.getPhaseStep()));
}
//End Tutorial
else
{
iterator.remove();
//Inform
UtilPlayer.message(player, F.main("Tutorial", "You completed " + F.elem(tut.getName()) + "."));
//Gems
if (tut.getGemReward() > 0)
{
if (!_taskManager.hasCompletedTask(player, tut.getTaskId()))
{
_taskManager.completedTask(new Callback<Boolean>()
{
public void run(Boolean completed)
{
_donationManager.RewardGems(new Callback<Boolean>()
{
public void run(Boolean completed)
{
if (completed)
{
UtilPlayer.message(player, F.main("Tutorial", "You received " + F.elem(C.cGreen + tut.getGemReward() + " Gems") + "."));
//Sound
player.playSound(player.getLocation(), Sound.LEVEL_UP, 2f, 1.5f);
}
}
}, "Tutorial " + tut.getName(), player.getName(), player.getUniqueId(), tut.getGemReward());
}
}, player, tut.getTaskId());
}
}
}
}
}
}
}
@EventHandler
public void playerQuit(PlayerQuitEvent event)
{
for (Tutorial tut : _tutorials)
tut.stopTutorial(event.getPlayer());
}
@EventHandler
public void cancelInteract(PlayerInteractEvent event)
{
if (isInTutorial(event.getPlayer()))
event.setCancelled(true);
}
public boolean isInTutorial(Player player)
{
for (Tutorial tutorial : _tutorials)
{
if (tutorial.isInTutorial(player))
return true;
}
return false;
}
}

View File

@ -0,0 +1,47 @@
package mineplex.core.texttutorial.tutorial;
import org.bukkit.Location;
public class Phase
{
private Location _location;
private String _header;
private String[] _text;
public Phase(Location location, String header, String[] text)
{
_location = location;
_header = header;
_text = text;
}
public Location getLocation()
{
return _location;
}
public void setLocation(Location location)
{
_location = location;
}
public String getHeader()
{
return _header;
}
public void setHeader(String header)
{
_header = header;
}
public String[] getText()
{
return _text;
}
public void setText(String[] text)
{
_text = text;
}
}

View File

@ -0,0 +1,74 @@
package mineplex.core.texttutorial.tutorial;
import java.util.ArrayList;
import java.util.Collection;
import java.util.HashMap;
import org.bukkit.entity.Player;
public abstract class Tutorial
{
private String _name;
private String _taskId;
private int _gemReward;
private ArrayList<Phase> _phases;
private HashMap<Player, TutorialData> _playerMap;
public Tutorial(String name, String taskId, int gemReward)
{
_name = name;
_taskId = taskId;
_gemReward = gemReward;
}
public String getName()
{
return _name;
}
public String getTaskId()
{
return _taskId;
}
public void startTutorial(Player player)
{
_playerMap.put(player, new TutorialData(player, _phases.get(0)));
}
public void stopTutorial(Player player)
{
_playerMap.remove(player);
}
public boolean isInTutorial(Player player)
{
return _playerMap.containsKey(player);
}
protected void addPhase(Phase phase)
{
_phases.add(phase);
}
public Collection<TutorialData> getTutorialDatas()
{
return _playerMap.values();
}
public Phase getPhase(int phaseIndex)
{
return _phases.get(phaseIndex);
}
public int getPhaseSize()
{
return _phases.size();
}
public int getGemReward()
{
return _gemReward;
}
}

View File

@ -0,0 +1,102 @@
package mineplex.core.texttutorial.tutorial;
import org.bukkit.Sound;
import org.bukkit.entity.Player;
import mineplex.core.common.util.C;
import mineplex.core.common.util.UtilPlayer;
public class TutorialData
{
private Player _player;
private Phase _phase;
private int _phaseStep;
private int _textStep;
private long _sleep;
public TutorialData(Player player, Phase startPhase)
{
_player = player;
_phase = startPhase;
_phaseStep = 0;
_textStep = 0;
_sleep = System.currentTimeMillis() + 3000;
}
public boolean tick()
{
if (!_player.getLocation().equals(_phase.getLocation()))
_player.teleport(_phase.getLocation());
if (System.currentTimeMillis() < _sleep)
return false;
if (_textStep >= _phase.getText().length)
{
// No more text to display, move to next phase
_phaseStep++;
_sleep = System.currentTimeMillis() + 2000;
return true;
}
// Display Text
String text = _phase.getText()[_textStep];
UtilPlayer.message(_player, " ");
UtilPlayer.message(_player, " ");
UtilPlayer.message(_player, " ");
UtilPlayer.message(_player, C.cGreen + C.Strike + C.Bold + "========================================");
UtilPlayer.message(_player, C.cGold + C.Bold + _phase.getHeader());
UtilPlayer.message(_player, " ");
for (int i=0 ; i<=_textStep ; i++)
UtilPlayer.message(_player, " " + _phase.getText()[i]);
for (int i=_textStep ; i<=5 ; i++)
UtilPlayer.message(_player, " ");
UtilPlayer.message(_player, C.cGreen + C.Strike + C.Bold + "========================================");
if (text.length() > 0)
{
_player.playSound(_player.getLocation(), Sound.ORB_PICKUP, 2f, 1.5f);
_sleep = System.currentTimeMillis() + 1000 + (50*text.length());
}
else
{
_sleep = System.currentTimeMillis() + 600;
}
_textStep++;
return false;
}
public void setNextPhase(Phase phase)
{
_phase = phase;
_textStep = 0;
_player.teleport(_phase.getLocation());
}
public Phase getPhase()
{
return _phase;
}
public long getSleep()
{
return _sleep;
}
public int getPhaseStep()
{
return _phaseStep;
}
public Player getPlayer()
{
return _player;
}
}

View File

@ -41,6 +41,7 @@ import mineplex.core.teleport.Teleport;
import mineplex.core.updater.FileUpdater;
import mineplex.core.updater.Updater;
import mineplex.core.visibility.VisibilityManager;
import mineplex.game.clans.analytics.Profiler;
import mineplex.game.clans.clans.ClansManager;
import mineplex.game.clans.clans.ban.ClansBanManager;
import mineplex.game.clans.items.GearManager;
@ -54,7 +55,7 @@ import net.minecraft.server.v1_8_R3.MinecraftServer;
public class Clans extends JavaPlugin
{
public static final String VERSION = "Beta 1.0_01";
public static final String VERSION = "Beta 1.0";
private String WEB_CONFIG = "webServer";
// Modules
@ -65,6 +66,9 @@ public class Clans extends JavaPlugin
@Override
public void onEnable()
{
// Initialize Profiler
new Profiler();
// Configs
getConfig().addDefault(WEB_CONFIG, "http://accounts.mineplex.com/");
getConfig().set(WEB_CONFIG, getConfig().getString(WEB_CONFIG));
@ -127,7 +131,7 @@ public class Clans extends JavaPlugin
new FriendManager(this, _clientManager, preferenceManager, portal);
new InventoryManager(this, _clientManager);
ResourcePackManager resourcePackManager = new ResourcePackManager(this, portal);
resourcePackManager.setResourcePack("http://b.garblox.com/CLANS_BETA_PACK_V6.zip", true);
resourcePackManager.setResourcePack("http://garblox.com/b:ResClans.zip", "http://garblox.com/b:ResClans19.zip", true);
// Enable custom-gear related managers
new CustomTagFix(this, packetHandler);

View File

@ -0,0 +1,37 @@
package mineplex.game.clans.analytics;
public class Analytic
{
private long _start;
private long _elapsed;
private String _section;
private String[] _data;
public Analytic(String section, String[] data, long start, long elapsed)
{
_data = data;
_elapsed = elapsed;
_start = start;
_section = section;
}
public String[] getData()
{
return _data;
}
public long getStart()
{
return _start;
}
public long getElapsed()
{
return _elapsed;
}
public String getSection()
{
return _section;
}
}

View File

@ -0,0 +1,94 @@
package mineplex.game.clans.analytics;
import java.io.ByteArrayOutputStream;
import java.io.DataOutputStream;
import mineplex.core.common.util.MapBuilder;
import mineplex.core.common.util.UtilCollections;
import mineplex.core.common.util.UtilTime;
import mineplex.core.common.util.UtilWeb;
public class AnalyticQueuer extends Thread
{
private ByteArrayOutputStream stream = new ByteArrayOutputStream();
private DataOutputStream out = new DataOutputStream(stream);
private long _lastPush = System.currentTimeMillis();
public void Queue(Section section, String[] data)
{
// new Thread(() -> {
// write(new Analytic(section.getSection(), data, section.getStart(), section.getElapsed()));
// }).start();
}
private void write(Analytic analytic)
{
try
{
out.writeLong(analytic.getStart());
out.writeLong(analytic.getElapsed());
out.writeInt(analytic.getSection().getBytes().length);
out.writeBytes(analytic.getSection());
String data = analytic.getData() == null ? "" : UtilCollections.combine(analytic.getData(), ",");
System.out.println("data: " + data);
out.writeInt(data.length());
if (analytic.getData() != null)
{
out.writeBytes(data);
}
}
catch (Exception exception)
{
exception.printStackTrace();
}
}
public void run()
{
// while (true)
// {
// if (UtilTime.elapsed(_lastPush, 10000))
// {
// System.out.println("PUSHING: Bytes[" + out.size() + "]");
//
// String response = UtilWeb.doPOST("http://analytics.garblox.com/PushAnalyticData",
// new MapBuilder<String, Object>()
// .Put("authkey", Profiler.ANALYTICS_KEY)
// .Put("service", "ClansBeta")
// .Put("data", stream.toString())
// .GetMap()
// );
//
// // Clear
// stream.reset();
//
// if (!response.equals("OK"))
// {
// System.out.println("[Clans Beta] Error while pushing analytic data to garblox: " + response);
// }
// else
// {
// System.out.println("ANALYTICS: OK.");
// }
//
// _lastPush = System.currentTimeMillis();
// }
//
// try
// {
// Thread.sleep(250);
// }
// catch (Exception exception)
// {
// exception.printStackTrace();
// }
// }
}
}

View File

@ -0,0 +1,84 @@
package mineplex.game.clans.analytics;
import java.io.File;
import java.util.HashMap;
import java.util.Map;
import java.util.Stack;
import mineplex.core.common.util.MapBuilder;
import mineplex.core.common.util.UtilFile;
import mineplex.core.common.util.UtilServer;
import mineplex.core.common.util.UtilWeb;
import mineplex.game.clans.clans.ClansManager;
public class Profiler
{
// public static final String ANALYTICS_KEY;
public static Profiler Instance;
private Map<Thread, Stack<Section>> _sections = new HashMap<>();
private AnalyticQueuer _queuer;
static
{
// ANALYTICS_KEY = UtilFile.read(new File(UtilServer.getServer().getWorldContainer() + "/GarbloxAnalyticsKey"));
}
public Profiler()
{
_queuer = new AnalyticQueuer();
// _queuer.start();
// String response = UtilWeb.doPOST("http://analytics.garblox.com/RegisterAnalytics",
// new MapBuilder<String, Object>()
// .Put("authkey", Profiler.ANALYTICS_KEY)
// .Put("name", "ClansBeta")
// .GetMap()
// );
//
// if (!response.equals("OK"))
// {
// System.out.println("[Clans Beta Analytics] Error while registering new analytic type: " + response);
// }
Instance = this;
}
public void start(String section)
{
// Thread thread = Thread.currentThread();
//
// if (_sections.get(thread) == null)
// {
// _sections.put(thread, new Stack<>());
// }
//
// _sections.get(thread).push(new Section(section, System.currentTimeMillis(), thread));
}
public void end(String... data)
{
// Thread thread = Thread.currentThread();
//
// Section section = _sections.get(thread).pop();
//
// if (data == null || data.length == 0)
// {
// data = new String[] { "Server:" + UtilServer.getServerName() };
// }
// else
// {
// String[] newData = new String[data.length + 1];
//
// System.arraycopy(data, 0, newData, 1, data.length);
//
// data = newData;
//
// data[0] = "Server:" + UtilServer.getServerName();
// }
//
// _queuer.Queue(section, data);
}
}

View File

@ -0,0 +1,36 @@
package mineplex.game.clans.analytics;
public class Section
{
private String _section;
private long _start;
private Thread _thread;
public Section(String section, long start, Thread thread)
{
_section = section;
_start = start;
_thread = thread;
}
public String getSection()
{
return _section;
}
public long getStart()
{
return _start;
}
public long getElapsed()
{
return System.currentTimeMillis() - _start;
}
public Thread getThread()
{
return _thread;
}
}

View File

@ -1,75 +0,0 @@
package mineplex.game.clans.clans;
import java.util.Arrays;
import java.util.LinkedList;
import org.bukkit.event.EventHandler;
import org.bukkit.event.player.PlayerJoinEvent;
import mineplex.core.MiniPlugin;
import mineplex.core.common.util.C;
import mineplex.core.common.util.Callback;
import mineplex.core.common.util.UtilMath;
import mineplex.core.common.util.UtilPlayer;
import mineplex.core.common.util.UtilServer;
import mineplex.core.task.TaskManager;
import mineplex.core.updater.UpdateType;
import mineplex.core.updater.event.UpdateEvent;
public class ClansAlphaManager extends MiniPlugin
{
private static final LinkedList<LinkedList<String>> ANNOUNCEMENTS = new LinkedList<>(Arrays.asList(new LinkedList<>(Arrays.asList(C.cDAquaB + "Welcome to Clans Alpha", C.cAqua + "Clans is in early Alpha stages so expect there to be bugs/issues. Please report any bugs to staff, we hope you enjoy this early test!"))));
private static final boolean RANDOM_ANNOUNCEMENT = true;
/**
* This is useful if the above boolean (RANDOM_ANNOUNCEMENT) is set to
* false, then the announcement at index SET_ANNOUNCEMENT will be used every
* time.
*/
private static final int SET_ANNOUNCEMENT = 0;
private static final LinkedList<String> FIRST_JOIN_MESSAGES = new LinkedList<>(ANNOUNCEMENTS.getFirst());
private static final UpdateType ANNOUNCEMENT_DELAY = UpdateType.MIN_16;
private TaskManager _taskManager;
public ClansAlphaManager(ClansManager manager, TaskManager taskManager)
{
super("Announcements", manager.getPlugin());
_taskManager = taskManager;
}
@EventHandler
public void onPlayerJoin(final PlayerJoinEvent event)
{
if (!_taskManager.hasCompletedTask(event.getPlayer(), "ClansAlphaJoinMessage"))
{
_taskManager.completedTask(new Callback<Boolean>()
{
public void run(Boolean data)
{
UtilPlayer.message(event.getPlayer(), FIRST_JOIN_MESSAGES);
}
}, event.getPlayer(), "ClansAlphaJoinMessage");
}
}
@EventHandler
public void onUpdate(UpdateEvent event)
{
if (event.getType().equals(ANNOUNCEMENT_DELAY))
{
if (RANDOM_ANNOUNCEMENT)
{
UtilServer.broadcast(UtilMath.randomElement(ANNOUNCEMENTS));
}
else
{
UtilServer.broadcast(ANNOUNCEMENTS.get(SET_ANNOUNCEMENT));
}
}
}
}

View File

@ -79,6 +79,7 @@ import mineplex.game.clans.clans.commands.ClansChatCommand;
import mineplex.game.clans.clans.commands.ClansCommand;
import mineplex.game.clans.clans.commands.KillCommand;
import mineplex.game.clans.clans.commands.MapCommand;
import mineplex.game.clans.clans.commands.QueryCommand;
import mineplex.game.clans.clans.commands.RegionsCommand;
import mineplex.game.clans.clans.data.PlayerClan;
import mineplex.game.clans.clans.event.ClansPlayerDeathEvent;
@ -245,6 +246,9 @@ public class ClansManager extends MiniClientPlugin<ClientClan>implements IRelati
_condition = new SkillConditionManager(plugin);
_damageManager = new DamageManager(plugin, _combatManager, _npcManager, _disguiseManager, _condition);
_damageManager.addCommand(new KillCommand(_damageManager));
addCommand(new QueryCommand(this));
_worldEvent = new WorldEventManager(plugin, this, _damageManager, _lootManager, blockRestore, _clanRegions, null);
TaskManager taskManager = new TaskManager(plugin, _clientManager, webServerAddress);
@ -286,7 +290,7 @@ public class ClansManager extends MiniClientPlugin<ClientClan>implements IRelati
new ClanEnergyTracker(plugin, this);
// new StuckManager(this);
// new ClansAlphaManager(this, taskManager);
new ClansBetaManager(this, taskManager);
new PotatoManager(plugin, this);
@ -320,10 +324,10 @@ public class ClansManager extends MiniClientPlugin<ClientClan>implements IRelati
new ClanEnergyManager(plugin, this, clientManager, donationManager);
_playTracker = new Playtime(this, statsManager);
_pvpTimer = new PvpTimer(this, _playTracker, statsManager);
_pvpTimer = new PvpTimer(this, statsManager);
_tutorialManager = new mineplex.game.clans.legacytutorial.TutorialManager(plugin, _playTracker, _goldManager, taskManager, donationManager, preferencesManager, this, packetHandler);
TutorialManager tutorial = new TutorialManager(plugin, clientManager, donationManager);
TutorialManager tutorial = new TutorialManager(plugin, clientManager, donationManager, chat);
_scoreboard = new ClansScoreboardManager(plugin, this, _warManager, _worldEvent, tutorial, clientManager, donationManager);
_clanDataAccess = new ClansDataAccessLayer(this, _scoreboard);
@ -381,9 +385,8 @@ public class ClansManager extends MiniClientPlugin<ClientClan>implements IRelati
for (Location location : welcomeHolograms)
{
Hologram hologram = new Hologram(hologramManager, location,
C.cGreenB + "Welcome to Clans Alpha",
C.cGreenB + "Welcome to Clans Beta",
C.cWhite + "Please be aware there may be bugs",
C.cWhite + "Map may reset at any time during Alpha!",
C.cWhite + "Type " + C.cYellow + "/clan" + C.cWhite + " to get started!"
);
hologram.start();
@ -557,6 +560,19 @@ public class ClansManager extends MiniClientPlugin<ClientClan>implements IRelati
}
}
@EventHandler
public void StaffIncognito(IncognitoStatusChangeEvent event)
{
if (event.getNewState())
{
UtilServer.broadcast(F.sys("Quit", event.getPlayer().getName()));
}
else
{
UtilServer.broadcast(F.sys("Join", event.getPlayer().getName()));
}
}
@EventHandler
public void disableEnderpeal(PlayerInteractEvent event)
{

View File

@ -158,10 +158,10 @@ public class ClansUtility
if (inform)
{
_clansManager.getTutorials().sendTutorialMsg(caller, F.main("Clan Search", "" + C.mCount + (clanMatchList.size() + playerMatchList.size()) + C.mBody + " matches for [" + C.mElem + name + C.mBody + "]."));
UtilPlayer.message(caller, F.main("Clan Search", "" + C.mCount + (clanMatchList.size() + playerMatchList.size()) + C.mBody + " matches for [" + C.mElem + name + C.mBody + "]."));
_clansManager.getTutorials().sendTutorialMsg(caller, F.desc("Matches via Clan", clanMatchString));
_clansManager.getTutorials().sendTutorialMsg(caller, F.desc("Matches via Player", playerMatchString));
UtilPlayer.message(caller, F.desc("Matches via Clan", clanMatchString));
UtilPlayer.message(caller, F.desc("Matches via Player", playerMatchString));
}
return null;
@ -184,7 +184,7 @@ public class ClansUtility
if (!inform) return null;
// Inform
_clansManager.getTutorials().sendTutorialMsg(caller, F.main("Clan Search", "" + C.mCount + matchList.size() + C.mBody + " matches for [" + C.mElem + name + C.mBody + "]."));
UtilPlayer.message(caller, F.main("Clan Search", "" + C.mCount + matchList.size() + C.mBody + " matches for [" + C.mElem + name + C.mBody + "]."));
if (matchList.size() > 0)
{
@ -192,7 +192,7 @@ public class ClansUtility
for (ClanInfo cur : matchList)
matchString += cur.getName() + " ";
_clansManager.getTutorials().sendTutorialMsg(caller, F.main("Clan Search", "" + C.mBody + " Matches [" + C.mElem + matchString + C.mBody + "]."));
UtilPlayer.message(caller, F.main("Clan Search", "" + C.mBody + " Matches [" + C.mElem + matchString + C.mBody + "]."));
}
return null;
@ -568,31 +568,31 @@ public class ClansUtility
{
if (_clansManager.getClanMemberUuidMap().containsKey(caller.getUniqueId()))
{
_clansManager.getTutorials().sendTutorialMsg(caller, F.main("Clans", "You are already in a Clan."));
UtilPlayer.message(caller, F.main("Clans", "You are already in a Clan."));
return;
}
if (!_clansManager.Get(caller).canJoin())
{
_clansManager.getTutorials().sendTutorialMsg(caller, F.main("Clans", "You cannot join a Clan for " + C.mTime + UtilTime.convertString(System.currentTimeMillis() - _clansManager.Get(caller).getDelay(), 1, UtilTime.TimeUnit.FIT) + C.mBody + "."));
UtilPlayer.message(caller, F.main("Clans", "You cannot join a Clan for " + C.mTime + UtilTime.convertString(System.currentTimeMillis() - _clansManager.Get(caller).getDelay(), 1, UtilTime.TimeUnit.FIT) + C.mBody + "."));
return;
}
if (clanInfo == null)
{
_clansManager.getTutorials().sendTutorialMsg(caller, F.main("Clans", "Error: Clan does not exist"));
UtilPlayer.message(caller, F.main("Clans", "Error: Clan does not exist"));
return;
}
if (!clanInfo.isInvited(caller.getName()))
{
_clansManager.getTutorials().sendTutorialMsg(caller, F.main("Clans", "You are not invited to " + F.elem("Clan " + clanInfo.getName()) + "."));
UtilPlayer.message(caller, F.main("Clans", "You are not invited to " + F.elem("Clan " + clanInfo.getName()) + "."));
return;
}
if (clanInfo.getSize() >= clanInfo.getMaxSize())
{
_clansManager.getTutorials().sendTutorialMsg(caller, F.main("Clans", "The clan " + F.elem("Clan " + clanInfo.getName()) + " is full and cannot be joined!"));
UtilPlayer.message(caller, F.main("Clans", "The clan " + F.elem("Clan " + clanInfo.getName()) + " is full and cannot be joined!"));
return;
}
@ -605,12 +605,12 @@ public class ClansUtility
if (data)
{
// Inform
_clansManager.getTutorials().sendTutorialMsg(caller, F.main("Clans", "You joined " + F.elem("Clan " + clanInfo.getName()) + "."));
UtilPlayer.message(caller, F.main("Clans", "You joined " + F.elem("Clan " + clanInfo.getName()) + "."));
clanInfo.inform(F.name(caller.getName()) + " has joined your Clan.", caller.getName());
}
else
{
_clansManager.getTutorials().sendTutorialMsg(caller, F.main("Clans", "There was an error processing your request"));
UtilPlayer.message(caller, F.main("Clans", "There was an error processing your request"));
}
}
});
@ -623,13 +623,13 @@ public class ClansUtility
if (clan == null)
{
_clansManager.getTutorials().sendTutorialMsg(caller, F.main("Clans", "You are not in a Clan."));
UtilPlayer.message(caller, F.main("Clans", "You are not in a Clan."));
return;
}
if (clan.getMembers().get(caller.getUniqueId()).getRole() == ClanRole.LEADER && clan.getMembers().size() > 1)
{
_clansManager.getTutorials().sendTutorialMsg(caller, F.main("Clans", "You must pass on " + F.elem("Leadership") + " before leaving."));
UtilPlayer.message(caller, F.main("Clans", "You must pass on " + F.elem("Leadership") + " before leaving."));
return;
}
@ -643,7 +643,7 @@ public class ClansUtility
public void run(Boolean data)
{
// Inform
_clansManager.getTutorials().sendTutorialMsg(caller, F.main("Clans", "You left " + F.elem("Clan " + clan.getName()) + "."));
UtilPlayer.message(caller, F.main("Clans", "You left " + F.elem("Clan " + clan.getName()) + "."));
clan.inform(F.name(caller.getName()) + " has left your Clan.", null);
clan.left(caller.getName());
@ -662,13 +662,13 @@ public class ClansUtility
if (clan == null)
{
_clansManager.getTutorials().sendTutorialMsg(caller, F.main("Clans", "You are not in a Clan."));
UtilPlayer.message(caller, F.main("Clans", "You are not in a Clan."));
return;
}
if (getRole(caller) != ClanRole.LEADER)
{
_clansManager.getTutorials().sendTutorialMsg(caller, F.main("Clans", "Only the Clan Leader can disband the Clan."));
UtilPlayer.message(caller, F.main("Clans", "Only the Clan Leader can disband the Clan."));
return;
}
@ -681,7 +681,7 @@ public class ClansUtility
return;
}
_clansManager.messageClan(clan, C.cYellow + caller.getName() + C.cGray + " has disbanded the Clan.");
_clansManager.messageClan(clan, F.main("Clans", C.cYellow + caller.getName() + C.mBody + " has disbanded the Clan."));
// Task
_clansManager.getClanDataAccess().delete(clan, new Callback<Boolean>()
@ -691,11 +691,11 @@ public class ClansUtility
{
if (!data.booleanValue())
{
_clansManager.getTutorials().sendTutorialMsg(caller, F.main("Clans", "There was an error processing your request. Try again later"));
UtilPlayer.message(caller, F.main("Clans", "There was an error processing your request. Try again later"));
}
else
{
_clansManager.getTutorials().sendTutorialMsg(caller, F.main("Clans", "You disbanded your Clan."));
UtilPlayer.message(caller, F.main("Clans", "You disbanded your Clan."));
}
}
});
@ -717,25 +717,25 @@ public class ClansUtility
if (clan == null)
{
_clansManager.getTutorials().sendTutorialMsg(caller, F.main("Clans", "You are not in a Clan."));
UtilPlayer.message(caller, F.main("Clans", "You are not in a Clan."));
return false;
}
if (clan.getMembers().get(caller.getUniqueId()).getRole() != ClanRole.LEADER && clan.getMembers().get(caller.getUniqueId()).getRole() != ClanRole.ADMIN)
{
_clansManager.getTutorials().sendTutorialMsg(caller, F.main("Clans", "Only the Clan Leader and Admins can claim Territory."));
UtilPlayer.message(caller, F.main("Clans", "Only the Clan Leader and Admins can claim Territory."));
return false;
}
if (!ClansManager.isClaimable(caller.getLocation()))
{
_clansManager.getTutorials().sendTutorialMsg(caller, F.main("Clans", "You cannot claim territory at this location!"));
UtilPlayer.message(caller, F.main("Clans", "You cannot claim territory at this location!"));
return false;
}
if (clan.getEnergy() == 0)
{
_clansManager.getTutorials().sendTutorialMsg(caller, F.main("Clans", "You must purchase energy at a shop before you can claim land."));
UtilPlayer.message(caller, F.main("Clans", "You must purchase energy at a shop before you can claim land."));
return false;
}
@ -751,14 +751,14 @@ public class ClansUtility
}
else
{
_clansManager.getTutorials().sendTutorialMsg(caller, F.main("Clans", "This Territory is owned by " + mRel(_clansManager.getClanUtility().relPC(caller, ownerClan), ownerClan.getName(), true) + "."));
UtilPlayer.message(caller, F.main("Clans", "This Territory is owned by " + mRel(_clansManager.getClanUtility().relPC(caller, ownerClan), ownerClan.getName(), true) + "."));
return false;
}
}
if (clan.getClaims() >= clan.getClaimsMax())
{
_clansManager.getTutorials().sendTutorialMsg(caller, F.main("Clans", "Your Clan cannot claim more Territory."));
UtilPlayer.message(caller, F.main("Clans", "Your Clan cannot claim more Territory."));
return false;
}
@ -784,8 +784,8 @@ public class ClansUtility
if (checkBox(caller.getWorld().getChunkAt(caller.getLocation().getChunk().getX() + x, caller.getLocation().getChunk().getZ() + z), 3))
{
_clansManager.getTutorials().sendTutorialMsg(caller, F.main("Clans", "You cannot claim this Territory, it causes a box."));
_clansManager.getTutorials().sendTutorialMsg(caller, F.main("Clans", "This means a Territory has all sides claimed."));
UtilPlayer.message(caller, F.main("Clans", "You cannot claim this Territory, it causes a box."));
UtilPlayer.message(caller, F.main("Clans", "This means a Territory has all sides claimed."));
return false;
}
@ -795,7 +795,7 @@ public class ClansUtility
}
else if (rel(clan, adjClan) != ClanRelation.SELF)
{
_clansManager.getTutorials().sendTutorialMsg(caller, F.main("Clans", "You cannot claim Territory next to " + mRel(rel(ownerClan, adjClan), adjClan.getName(), true) + "."));
UtilPlayer.message(caller, F.main("Clans", "You cannot claim Territory next to " + mRel(rel(ownerClan, adjClan), adjClan.getName(), true) + "."));
return false;
}
}
@ -804,21 +804,21 @@ public class ClansUtility
// Boxed
if (checkBox(caller.getLocation().getChunk(), 4))
{
_clansManager.getTutorials().sendTutorialMsg(caller, F.main("Clans", "You cannot claim this Territory, it causes a box."));
_clansManager.getTutorials().sendTutorialMsg(caller, F.main("Clans", "This means a Territory has all sides claimed."));
UtilPlayer.message(caller, F.main("Clans", "You cannot claim this Territory, it causes a box."));
UtilPlayer.message(caller, F.main("Clans", "This means a Territory has all sides claimed."));
return false;
}
if (isNearAdminClaim(caller.getLocation()))
{
_clansManager.getTutorials().sendTutorialMsg(caller, F.main("Clans", "You cannot claim so close to administrative territory!"));
UtilPlayer.message(caller, F.main("Clans", "You cannot claim so close to administrative territory!"));
return false;
}
// Not Next to Self
if (!selfAdj && !clan.getClaimSet().isEmpty())
{
_clansManager.getTutorials().sendTutorialMsg(caller, F.main("Clans", "You must claim next to your other Territory."));
UtilPlayer.message(caller, F.main("Clans", "You must claim next to your other Territory."));
return false;
}
@ -827,7 +827,7 @@ public class ClansUtility
{
if (!UtilTime.elapsed(_clansManager.getUnclaimMap().get(chunk).longValue(), _clansManager.getReclaimTime()))
{
_clansManager.getTutorials().sendTutorialMsg(caller, F.main("Clans", "This Territory cannot be claimed for " + F.time(UtilTime.convertString(_clansManager.getReclaimTime() - (System.currentTimeMillis() - _clansManager.getUnclaimMap().get(chunk).longValue()), 1, UtilTime.TimeUnit.FIT)) + "."));
UtilPlayer.message(caller, F.main("Clans", "This Territory cannot be claimed for " + F.time(UtilTime.convertString(_clansManager.getReclaimTime() - (System.currentTimeMillis() - _clansManager.getUnclaimMap().get(chunk).longValue()), 1, UtilTime.TimeUnit.FIT)) + "."));
return false;
}
@ -842,7 +842,7 @@ public class ClansUtility
{
if (UtilMath.offset(cur, caller) < 16) if (playerEnemy(caller, cur))
{
_clansManager.getTutorials().sendTutorialMsg(caller, F.main("Clans", "You cannot claim while enemies are nearby."));
UtilPlayer.message(caller, F.main("Clans", "You cannot claim while enemies are nearby."));
return false;
}
}
@ -864,7 +864,7 @@ public class ClansUtility
_clansManager.getClanDataAccess().claim(clan.getName(), chunk, caller.getName(), false);
// Inform
_clansManager.getTutorials().sendTutorialMsg(caller, F.main("Clans", "You claimed Territory " + F.elem(UtilWorld.chunkToStrClean(caller.getLocation().getChunk())) + "."));
UtilPlayer.message(caller, F.main("Clans", "You claimed Territory " + F.elem(UtilWorld.chunkToStrClean(caller.getLocation().getChunk())) + "."));
clan.inform(F.name(caller.getName()) + " claimed Territory " + F.elem(UtilWorld.chunkToStrClean(caller.getLocation().getChunk())) + ".", caller.getName());
return true;
@ -901,7 +901,7 @@ public class ClansUtility
}
// Change Inform
_clansManager.getTutorials().sendTutorialMsg(caller, F.main("Clans", "You can no longer 'steal' territory. " + "You simply unclaim it and it can not be reclaimed by anyone for 30 mintes." + "This was done to improve gameplay. Enjoy!"));
UtilPlayer.message(caller, F.main("Clans", "You can no longer 'steal' territory. " + "You simply unclaim it and it can not be reclaimed by anyone for 30 mintes." + "This was done to improve gameplay. Enjoy!"));
// Inform
UtilServer.broadcast(F.main("Clans", F.elem(clientClan.getName()) + " unclaimed from " + F.elem(ownerClan.getName()) + " at " + F.elem(UtilWorld.locToStrClean(caller.getLocation())) + "."));
@ -918,7 +918,7 @@ public class ClansUtility
if (clan == null)
{
_clansManager.getTutorials().sendTutorialMsg(caller, F.main("Clans", "You are not in a Clan."));
UtilPlayer.message(caller, F.main("Clans", "You are not in a Clan."));
return;
}
@ -929,13 +929,13 @@ public class ClansUtility
if (target.equals(caller.getName()))
{
_clansManager.getTutorials().sendTutorialMsg(caller, F.main("Clans", "You cannot promote yourself."));
UtilPlayer.message(caller, F.main("Clans", "You cannot promote yourself."));
return;
}
if (self.getRole().ordinal() <= target.getRole().ordinal())
{
_clansManager.getTutorials().sendTutorialMsg(caller, F.main("Clans", "You do not outrank " + F.name(other) + "."));
UtilPlayer.message(caller, F.main("Clans", "You do not outrank " + F.name(other) + "."));
return;
}
@ -970,7 +970,7 @@ public class ClansUtility
if (clan == null)
{
_clansManager.getTutorials().sendTutorialMsg(caller, F.main("Clans", "You are not in a Clan."));
UtilPlayer.message(caller, F.main("Clans", "You are not in a Clan."));
return;
}
@ -981,19 +981,19 @@ public class ClansUtility
if (target.equals(caller.getName()))
{
_clansManager.getTutorials().sendTutorialMsg(caller, F.main("Clans", "You cannot demote yourself."));
UtilPlayer.message(caller, F.main("Clans", "You cannot demote yourself."));
return;
}
if (self.getRole().ordinal() <= target.getRole().ordinal())
{
_clansManager.getTutorials().sendTutorialMsg(caller, F.main("Clans", "You do not outrank " + F.name(other) + "."));
UtilPlayer.message(caller, F.main("Clans", "You do not outrank " + F.name(other) + "."));
return;
}
if (target.getRole() == ClanRole.RECRUIT)
{
_clansManager.getTutorials().sendTutorialMsg(caller, F.main("Clans", "You cannot demote " + F.name(other) + " any further."));
UtilPlayer.message(caller, F.main("Clans", "You cannot demote " + F.name(other) + " any further."));
return;
}
@ -1020,7 +1020,7 @@ public class ClansUtility
if (clan == null)
{
_clansManager.getTutorials().sendTutorialMsg(caller, F.main("Clans", "You are not in a Clan."));
UtilPlayer.message(caller, F.main("Clans", "You are not in a Clan."));
return;
}
@ -1031,20 +1031,20 @@ public class ClansUtility
if (self.getRole() != ClanRole.LEADER && self.getRole() != ClanRole.ADMIN)
{
_clansManager.getTutorials().sendTutorialMsg(caller, F.main("Clans", "Only the Clan Leader and Admins can kick members."));
UtilPlayer.message(caller, F.main("Clans", "Only the Clan Leader and Admins can kick members."));
return;
}
if (clansPlayer.getRole() == ClanRole.LEADER)
{
_clansManager.getTutorials().sendTutorialMsg(caller, F.main("Clans", "Clan leaders cannot be kicked."));
_clansManager.getTutorials().sendTutorialMsg(caller, F.main("Clans", "To disband a clan, use /c disband"));
UtilPlayer.message(caller, F.main("Clans", "Clan leaders cannot be kicked."));
UtilPlayer.message(caller, F.main("Clans", "To disband a clan, use /c disband"));
return;
}
if ((clansPlayer.getRole() == ClanRole.LEADER && self.getRole() == ClanRole.ADMIN) || (clansPlayer.getRole() == ClanRole.ADMIN && self.getRole() == ClanRole.ADMIN))
{
_clansManager.getTutorials().sendTutorialMsg(caller, F.main("Clans", "You do not outrank " + F.name(other) + "."));
UtilPlayer.message(caller, F.main("Clans", "You do not outrank " + F.name(other) + "."));
return;
}
@ -1056,8 +1056,8 @@ public class ClansUtility
public void run(Boolean data)
{
// Inform
if (player != null) _clansManager.getTutorials().sendTutorialMsg(player, F.main("Clans", F.name(caller.getName()) + " kicked you from " + F.elem("Clan " + clan.getName()) + "."));
_clansManager.getTutorials().sendTutorialMsg(caller, F.main("Clans", "You kicked " + F.name(other) + " from your Clan."));
if (player != null) UtilPlayer.message(player, F.main("Clans", F.name(caller.getName()) + " kicked you from " + F.elem("Clan " + clan.getName()) + "."));
UtilPlayer.message(caller, F.main("Clans", "You kicked " + F.name(other) + " from your Clan."));
clan.inform(F.main("Clans", F.name(caller.getName()) + " kicked " + F.name(other) + " from your Clan."), caller.getName());
}
};
@ -1075,7 +1075,7 @@ public class ClansUtility
if (clan == null)
{
_clansManager.getTutorials().sendTutorialMsg(caller, F.main("Clans", "You are not in a Clan."));
UtilPlayer.message(caller, F.main("Clans", "You are not in a Clan."));
return false;
}
@ -1088,14 +1088,14 @@ public class ClansUtility
// Role
if (clan.getMembers().get(caller.getUniqueId()).getRole() != ClanRole.LEADER && clan.getMembers().get(caller.getUniqueId()).getRole() != ClanRole.ADMIN)
{
_clansManager.getTutorials().sendTutorialMsg(caller, F.main("Clans", "Only the Clan Leader and Admins can unclaim Territory."));
UtilPlayer.message(caller, F.main("Clans", "Only the Clan Leader and Admins can unclaim Territory."));
return false;
}
// Not Claimed
if (ownerClan == null || !ownerClan.equals(clan))
{
_clansManager.getTutorials().sendTutorialMsg(caller, F.main("Clans", "This Territory is not owned by you."));
UtilPlayer.message(caller, F.main("Clans", "This Territory is not owned by you."));
return false;
}
@ -1113,7 +1113,7 @@ public class ClansUtility
_clansManager.getClanDataAccess().unclaim(chunk, caller.getName(), true);
// Inform
_clansManager.getTutorials().sendTutorialMsg(caller, F.main("Clans", "You unclaimed Territory " + F.elem(UtilWorld.chunkToStrClean(caller.getLocation().getChunk())) + "."));
UtilPlayer.message(caller, F.main("Clans", "You unclaimed Territory " + F.elem(UtilWorld.chunkToStrClean(caller.getLocation().getChunk())) + "."));
clan.inform(F.name(caller.getName()) + " unclaimed Territory " + F.elem(UtilWorld.chunkToStrClean(caller.getLocation().getChunk())) + ".", caller.getName());
return true;
@ -1125,13 +1125,13 @@ public class ClansUtility
if (clan == null)
{
_clansManager.getTutorials().sendTutorialMsg(caller, F.main("Clans", "You are not in a Clan."));
UtilPlayer.message(caller, F.main("Clans", "You are not in a Clan."));
return false;
}
if (clan.getMembers().get(caller.getUniqueId()).getRole() != ClanRole.LEADER)
{
_clansManager.getTutorials().sendTutorialMsg(caller, F.main("Clans", "Only the Clan Leader can unclaim all Territory."));
UtilPlayer.message(caller, F.main("Clans", "Only the Clan Leader can unclaim all Territory."));
return false;
}
@ -1149,7 +1149,7 @@ public class ClansUtility
}
// Inform
_clansManager.getTutorials().sendTutorialMsg(caller, F.main("Clans", "You unclaimed all your Clans Territory."));
UtilPlayer.message(caller, F.main("Clans", "You unclaimed all your Clans Territory."));
clan.inform(F.name(caller.getName()) + " unclaimed all your Clans Territory.", caller.getName());
return true;
@ -1159,21 +1159,21 @@ public class ClansUtility
{
if (clan.getMembers().get(caller.getUniqueId()).getRole() != ClanRole.LEADER && clan.getMembers().get(caller.getUniqueId()).getRole() != ClanRole.ADMIN)
{
_clansManager.getTutorials().sendTutorialMsg(caller, F.main("Clans", "Only the Clan Leader and Admins can send invites."));
UtilPlayer.message(caller, F.main("Clans", "Only the Clan Leader and Admins can send invites."));
return;
}
if (target.getName().equals(caller.getName()))
{
_clansManager.getTutorials().sendTutorialMsg(caller, F.main("Clans", "You cannot invite yourself."));
UtilPlayer.message(caller, F.main("Clans", "You cannot invite yourself."));
return;
}
// Inform
clan.inform(F.name(caller.getName()) + " invited " + F.name(target.getName()) + " to join your Clan.", caller.getName());
_clansManager.getTutorials().sendTutorialMsg(caller, F.main("Clans", "You invited " + F.name(target.getName()) + " to join your Clan."));
_clansManager.getTutorials().sendTutorialMsg(target, F.main("Clans", F.name(caller.getName()) + " invited you to join " + F.elem("Clan " + clan.getName()) + "."));
_clansManager.getTutorials().sendTutorialMsg(target, F.main("Clans", "Type " + F.elem("/c join " + clan.getName()) + " to accept!"));
UtilPlayer.message(caller, F.main("Clans", "You invited " + F.name(target.getName()) + " to join your Clan."));
UtilPlayer.message(target, F.main("Clans", F.name(caller.getName()) + " invited you to join " + F.elem("Clan " + clan.getName()) + "."));
UtilPlayer.message(target, F.main("Clans", "Type " + F.elem("/c join " + clan.getName()) + " to accept!"));
// Task
_clansManager.getClanDataAccess().invite(clan, target.getName(), caller.getName());

View File

@ -1,15 +0,0 @@
package mineplex.game.clans.clans;
import java.io.File;
import java.io.IOException;
import mineplex.core.common.util.UtilOfflinePlayer;
public class Test
{
public static void main(String[] args) throws IOException
{
System.out.println("wtf");
UtilOfflinePlayer.loadOfflineInventory(new File("M:/Clans/a797d3ef-dd25-4e18-a002-6537b19b3603.dat"));
}
}

View File

@ -39,6 +39,7 @@ import mineplex.game.clans.clans.ClientClan;
import mineplex.game.clans.clans.event.ClanJoinEvent;
import mineplex.game.clans.clans.event.ClansCommandExecutedEvent;
import mineplex.game.clans.core.repository.ClanTerritory;
import mineplex.game.clans.spawn.Spawn;
import net.minecraft.server.v1_8_R3.EnumDirection;
public class ClansCommand extends CommandBase<ClansManager>
@ -140,7 +141,7 @@ public class ClansCommand extends CommandBase<ClansManager>
{
if (!Plugin.getClientManager().hasRank(caller, Rank.ADMIN) && !caller.getUniqueId().toString().equals("d8646a35-33a8-43c6-9e7c-2e871a6b86c9") /* My UUID (NewGarbo) */)
{
_clansManager.getTutorials().sendTutorialMsg(caller, F.main("Clans", "This requires ADMIN+ permission."));
UtilPlayer.message(caller, F.main("Clans", "This requires ADMIN+ permission."));
return;
}
@ -152,16 +153,16 @@ public class ClansCommand extends CommandBase<ClansManager>
{
_clansManager.getClanUtility().join(caller, clan);
_clansManager.getClanDataAccess().role(clan, caller.getUniqueId(), ClanRole.LEADER);
_clansManager.getTutorials().sendTutorialMsg(caller, F.main("Clans", "You have successfully joined " + F.elem(clan.getName()) + " and are now Leader Role."));
UtilPlayer.message(caller, F.main("Clans", "You have successfully joined " + F.elem(clan.getName()) + " and are now Leader Role."));
}
else
{
_clansManager.getTutorials().sendTutorialMsg(caller, F.main("Clans", "Clan provided does not exist."));
UtilPlayer.message(caller, F.main("Clans", "Clan provided does not exist."));
}
}
else
{
_clansManager.getTutorials().sendTutorialMsg(caller, F.main("Clans", "No clan provided."));
UtilPlayer.message(caller, F.main("Clans", "No clan provided."));
}
}
@ -170,7 +171,7 @@ public class ClansCommand extends CommandBase<ClansManager>
if (args.length == 0)
{
Plugin.Get(caller).setClanChat(!Plugin.Get(caller).isClanChat());
_clansManager.getTutorials().sendTutorialMsg(caller, F.main("Clans", "Clan Chat: " + F.oo(Plugin.Get(caller).isClanChat())));
UtilPlayer.message(caller, F.main("Clans", "Clan Chat: " + F.oo(Plugin.Get(caller).isClanChat())));
return;
}
@ -179,7 +180,7 @@ public class ClansCommand extends CommandBase<ClansManager>
{
ClanInfo clan = Plugin.getClanUtility().getClanByPlayer(caller);
if (clan == null)
_clansManager.getTutorials().sendTutorialMsg(caller, F.main("Clans", "You are not in a Clan."));
UtilPlayer.message(caller, F.main("Clans", "You are not in a Clan."));
else
Plugin.chatClan(clan, caller, F.combine(args, 0, null, false));
}
@ -190,7 +191,7 @@ public class ClansCommand extends CommandBase<ClansManager>
if (args.length == 0)
{
Plugin.Get(caller).setAllyChat(!Plugin.Get(caller).isAllyChat());
_clansManager.getTutorials().sendTutorialMsg(caller, F.main("Clans", "Ally Chat: " + F.oo(Plugin.Get(caller).isAllyChat())));
UtilPlayer.message(caller, F.main("Clans", "Ally Chat: " + F.oo(Plugin.Get(caller).isAllyChat())));
return;
}
@ -199,7 +200,7 @@ public class ClansCommand extends CommandBase<ClansManager>
{
ClanInfo clan = Plugin.getClanUtility().getClanByPlayer(caller);
if (clan == null)
_clansManager.getTutorials().sendTutorialMsg(caller, F.main("Clans", "You are not in a Clan."));
UtilPlayer.message(caller, F.main("Clans", "You are not in a Clan."));
else
Plugin.chatAlly(clan, caller, F.combine(args, 0, null, false));
}
@ -215,32 +216,32 @@ public class ClansCommand extends CommandBase<ClansManager>
return;
}
_clansManager.getTutorials().sendTutorialMsg(caller, F.main("Clans", "Commands List;"));
_clansManager.getTutorials().sendTutorialMsg(caller, F.help("/c create <clan>", "Create new Clan", Rank.ALL));
_clansManager.getTutorials().sendTutorialMsg(caller, F.help("/c join <clan>", "Join a Clan", Rank.ALL));
_clansManager.getTutorials().sendTutorialMsg(caller, F.help("/c leave <clan>", "Leave your Clan", Rank.ALL));
_clansManager.getTutorials().sendTutorialMsg(caller, F.help("/c map <toggle>", "View Clan Map", Rank.ALL));
_clansManager.getTutorials().sendTutorialMsg(caller, F.help("/cc (Message)", "Clan Chat (Toggle)", Rank.ALL));
UtilPlayer.message(caller, F.main("Clans", "Commands List;"));
UtilPlayer.message(caller, F.help("/c create <clan>", "Create new Clan", Rank.ALL));
UtilPlayer.message(caller, F.help("/c join <clan>", "Join a Clan", Rank.ALL));
UtilPlayer.message(caller, F.help("/c leave <clan>", "Leave your Clan", Rank.ALL));
UtilPlayer.message(caller, F.help("/c map <toggle>", "View Clan Map", Rank.ALL));
UtilPlayer.message(caller, F.help("/cc (Message)", "Clan Chat (Toggle)", Rank.ALL));
_clansManager.getTutorials().sendTutorialMsg(caller, F.help("/c stuck", "Teleports you to the nearest Wilderness location", Rank.ALL));
UtilPlayer.message(caller, F.help("/c stuck", "Teleports you to the nearest Wilderness location", Rank.ALL));
_clansManager.getTutorials().sendTutorialMsg(caller, F.help("/c promote <player>", "Promote Player in Clan", Rank.MODERATOR));
_clansManager.getTutorials().sendTutorialMsg(caller, F.help("/c demote <player>", "Demote Player in Clan", Rank.MODERATOR));
UtilPlayer.message(caller, F.help("/c promote <player>", "Promote Player in Clan", Rank.MODERATOR));
UtilPlayer.message(caller, F.help("/c demote <player>", "Demote Player in Clan", Rank.MODERATOR));
_clansManager.getTutorials().sendTutorialMsg(caller, F.help("/c home (set)", "Teleport to Clan Home", Rank.MODERATOR));
UtilPlayer.message(caller, F.help("/c home (set)", "Teleport to Clan Home", Rank.MODERATOR));
_clansManager.getTutorials().sendTutorialMsg(caller, F.help("/c invite <player>", "Invite Player to Clan", Rank.ADMIN));
_clansManager.getTutorials().sendTutorialMsg(caller, F.help("/c kick <player>", "Kick Player from Clan", Rank.ADMIN));
_clansManager.getTutorials().sendTutorialMsg(caller, F.help("/c neutral <clan>", "Request Neutrality with Clan", Rank.ADMIN));
_clansManager.getTutorials().sendTutorialMsg(caller, F.help("/c enemy <clan>", "Declare ClanWar with Clan", Rank.ADMIN));
_clansManager.getTutorials().sendTutorialMsg(caller, F.help("/c ally <clan>", "Send Alliance to Clan", Rank.ADMIN));
_clansManager.getTutorials().sendTutorialMsg(caller, F.help("/c trust <clan>", "Give Trust to Clan", Rank.ADMIN));
_clansManager.getTutorials().sendTutorialMsg(caller, F.help("/c claim", "Claim Territory", Rank.ADMIN));
_clansManager.getTutorials().sendTutorialMsg(caller, F.help("/c unclaim (all)", "Unclaim Territory", Rank.ADMIN));
UtilPlayer.message(caller, F.help("/c invite <player>", "Invite Player to Clan", Rank.ADMIN));
UtilPlayer.message(caller, F.help("/c kick <player>", "Kick Player from Clan", Rank.ADMIN));
UtilPlayer.message(caller, F.help("/c neutral <clan>", "Request Neutrality with Clan", Rank.ADMIN));
UtilPlayer.message(caller, F.help("/c enemy <clan>", "Declare ClanWar with Clan", Rank.ADMIN));
UtilPlayer.message(caller, F.help("/c ally <clan>", "Send Alliance to Clan", Rank.ADMIN));
UtilPlayer.message(caller, F.help("/c trust <clan>", "Give Trust to Clan", Rank.ADMIN));
UtilPlayer.message(caller, F.help("/c claim", "Claim Territory", Rank.ADMIN));
UtilPlayer.message(caller, F.help("/c unclaim (all)", "Unclaim Territory", Rank.ADMIN));
_clansManager.getTutorials().sendTutorialMsg(caller, F.help("/c delete", "Delete your Clan", Rank.OWNER));
UtilPlayer.message(caller, F.help("/c delete", "Delete your Clan", Rank.OWNER));
_clansManager.getTutorials().sendTutorialMsg(caller, F.help("/c <clan>", "View Clan Information", Rank.ALL));
UtilPlayer.message(caller, F.help("/c <clan>", "View Clan Information", Rank.ALL));
}
public void create(final Player caller, final String[] args)
@ -251,13 +252,13 @@ public class ClansCommand extends CommandBase<ClansManager>
if (Plugin.getClanMemberUuidMap().containsKey(caller.getUniqueId()))
{
_clansManager.getTutorials().sendTutorialMsg(caller, F.main("Clans", "You are already in a Clan."));
UtilPlayer.message(caller, F.main("Clans", "You are already in a Clan."));
return;
}
if (Plugin.leftRecently(caller.getUniqueId(), 5 * 60 * 1000) != null)
{
_clansManager.getTutorials().sendTutorialMsg(caller, F.main("Clans", "You cannot create a Clan for " + C.mTime + UtilTime.MakeStr(Plugin.leftRecently(caller.getUniqueId(), 20 * 60 * 1000).getRight()) + C.mBody + "."));
UtilPlayer.message(caller, F.main("Clans", "You cannot create a Clan for " + C.mTime + UtilTime.MakeStr(Plugin.leftRecently(caller.getUniqueId(), 20 * 60 * 1000).getRight()) + C.mBody + "."));
return;
}
@ -270,37 +271,37 @@ public class ClansCommand extends CommandBase<ClansManager>
if (args.length < 2)
{
_clansManager.getTutorials().sendTutorialMsg(caller, F.main("Clans", "You did not input a Clan name."));
UtilPlayer.message(caller, F.main("Clans", "You did not input a Clan name."));
return;
}
if (!UtilInput.valid(args[1]))
{
_clansManager.getTutorials().sendTutorialMsg(caller, F.main("Clans", "Invalid characters in Clan name."));
UtilPlayer.message(caller, F.main("Clans", "Invalid characters in Clan name."));
return;
}
if (args[1].length() < Plugin.getNameMin())
{
_clansManager.getTutorials().sendTutorialMsg(caller, F.main("Clans", "Clan name too short. Minimum length is " + (Plugin.getNameMin()) + "."));
UtilPlayer.message(caller, F.main("Clans", "Clan name too short. Minimum length is " + (Plugin.getNameMin()) + "."));
return;
}
if (args[1].length() > Plugin.getNameMax())
{
_clansManager.getTutorials().sendTutorialMsg(caller, F.main("Clans", "Clan name too long. Maximum length is " + (Plugin.getNameMax()) + "."));
UtilPlayer.message(caller, F.main("Clans", "Clan name too long. Maximum length is " + (Plugin.getNameMax()) + "."));
return;
}
if (Plugin.getChat().getFilteredMessage(caller, args[1]).contains("*"))
{
_clansManager.getTutorials().sendTutorialMsg(caller, F.main("Clans", "Clan name inappropriate. Please try a different name"));
UtilPlayer.message(caller, F.main("Clans", "Clan name inappropriate. Please try a different name"));
return;
}
if (!ClansBlacklist.isValidClanName(args[1]))
{
_clansManager.getTutorials().sendTutorialMsg(caller, F.main("Clans", "Clan name is blacklisted! Please try a different name."));
UtilPlayer.message(caller, F.main("Clans", "Clan name is blacklisted! Please try a different name."));
return;
}
@ -311,7 +312,7 @@ public class ClansCommand extends CommandBase<ClansManager>
{
if (clanExists)
{
_clansManager.getTutorials().sendTutorialMsg(caller, F.main("Clans", "Clan name is already in use by another Clan."));
UtilPlayer.message(caller, F.main("Clans", "Clan name is already in use by another Clan."));
}
else
{
@ -323,11 +324,11 @@ public class ClansCommand extends CommandBase<ClansManager>
if (data == null)
{
// Hopefully shouldn't happen!
_clansManager.getTutorials().sendTutorialMsg(caller, F.main("Clans", "There was an error creating the clan. Please try again"));
UtilPlayer.message(caller, F.main("Clans", "There was an error creating the clan. Please try again"));
}
else
{
_clansManager.getTutorials().sendTutorialMsg(caller, F.main("Clans", "You created Clan " + C.cYellow + data.getName() + C.cGray + "."));
UtilPlayer.message(caller, F.main("Clans", "You created Clan " + C.cYellow + data.getName() + C.cGray + "."));
}
}
});
@ -347,13 +348,13 @@ public class ClansCommand extends CommandBase<ClansManager>
if (clan == null)
{
_clansManager.getTutorials().sendTutorialMsg(caller, F.main("Clans", "You are not in a Clan."));
UtilPlayer.message(caller, F.main("Clans", "You are not in a Clan."));
return;
}
if (args.length < 2)
{
_clansManager.getTutorials().sendTutorialMsg(caller, F.main("Clans", "You did not input an invitee."));
UtilPlayer.message(caller, F.main("Clans", "You did not input an invitee."));
return;
}
@ -385,7 +386,7 @@ public class ClansCommand extends CommandBase<ClansManager>
if (territory == null || territory.Safe || territory.Owner.equals(clanName))
{
_clansManager.getTutorials().sendTutorialMsg(caller, F.main("Clans", "You must be in another Clan's territory to use this."));
UtilPlayer.message(caller, F.main("Clans", "You must be in another Clan's territory to use this."));
return;
}
@ -398,19 +399,19 @@ public class ClansCommand extends CommandBase<ClansManager>
if (loc == null)
{
_clansManager.getTutorials().sendTutorialMsg(caller, F.main("Clans", "Error whilst finding location to teleport to."));
UtilPlayer.message(caller, F.main("Clans", "Error whilst finding location to teleport to."));
return;
}
player.getPlayer().teleport(loc);
// Inform
_clansManager.getTutorials().sendTutorialMsg(caller, F.main("Clans", "You have been teleported to the Wilderness."));
UtilPlayer.message(caller, F.main("Clans", "You have been teleported to the Wilderness."));
}
}, new Callback<DelayedTaskClient>() {
public void run(DelayedTaskClient client)
{
UtilTextMiddle.display("", "Teleporting to Wilderness in " + F.elem(UtilTime.MakeStr(Math.max(0, client.getTimeLeft("Wilderness Teleport")))), 0, 5, 0, client.getPlayer());
UtilTextMiddle.display("", "Teleporting to Wilderness in " + F.time(UtilTime.MakeStr(Math.max(0, client.getTimeLeft("Wilderness Teleport")))), 0, 5, 0, client.getPlayer());
}
}, new Callback<DelayedTaskClient>() {
public void run(DelayedTaskClient client)
@ -458,31 +459,31 @@ public class ClansCommand extends CommandBase<ClansManager>
{
if (Plugin.getClanMemberUuidMap().containsKey(caller.getUniqueId()))
{
_clansManager.getTutorials().sendTutorialMsg(caller, F.main("Clans", "You are already in a Clan."));
UtilPlayer.message(caller, F.main("Clans", "You are already in a Clan."));
return;
}
if (Plugin.leftRecently(caller.getUniqueId(), 20 * 60 * 1000) != null)
{
_clansManager.getTutorials().sendTutorialMsg(caller, F.main("Clans", "You cannot join a Clan for " + C.mTime + UtilTime.MakeStr(Plugin.leftRecently(caller.getUniqueId(), 20 * 60 * 1000).getRight()) + C.mBody + "."));
UtilPlayer.message(caller, F.main("Clans", "You cannot join a Clan for " + C.mTime + UtilTime.MakeStr(Plugin.leftRecently(caller.getUniqueId(), 20 * 60 * 1000).getRight()) + C.mBody + "."));
return;
}
if (!Plugin.Get(caller).canJoin())
{
_clansManager.getTutorials().sendTutorialMsg(caller, F.main("Clans", "You cannot join a Clan for " + C.mTime + UtilTime.convertString(System.currentTimeMillis() - Plugin.Get(caller).getDelay(), 1, TimeUnit.FIT) + C.mBody + "."));
UtilPlayer.message(caller, F.main("Clans", "You cannot join a Clan for " + C.mTime + UtilTime.convertString(System.currentTimeMillis() - Plugin.Get(caller).getDelay(), 1, TimeUnit.FIT) + C.mBody + "."));
return;
}
if (args.length < 2)
{
_clansManager.getTutorials().sendTutorialMsg(caller, F.main("Clans", "You did not input a Clan name."));
UtilPlayer.message(caller, F.main("Clans", "You did not input a Clan name."));
return;
}
if (!UtilInput.valid(args[1]))
{
_clansManager.getTutorials().sendTutorialMsg(caller, F.main("Clans", "Invalid characters in Clan name."));
UtilPlayer.message(caller, F.main("Clans", "Invalid characters in Clan name."));
return;
}
@ -491,13 +492,13 @@ public class ClansCommand extends CommandBase<ClansManager>
if (!clan.isInvited(caller.getName()))
{
_clansManager.getTutorials().sendTutorialMsg(caller, F.main("Clans", "You are not invited to " + F.elem("Clan " + clan.getName()) + "."));
UtilPlayer.message(caller, F.main("Clans", "You are not invited to " + F.elem("Clan " + clan.getName()) + "."));
return;
}
if (clan.getSize() >= clan.getMaxSize())
{
_clansManager.getTutorials().sendTutorialMsg(caller, F.main("Clans", "The clan " + F.elem("Clan " + clan.getName()) + " is full and cannot be joined!"));
UtilPlayer.message(caller, F.main("Clans", "The clan " + F.elem("Clan " + clan.getName()) + " is full and cannot be joined!"));
return;
}
@ -514,12 +515,12 @@ public class ClansCommand extends CommandBase<ClansManager>
if (data)
{
// Inform
_clansManager.getTutorials().sendTutorialMsg(caller, F.main("Clans", "You joined " + F.elem("Clan " + clan.getName()) + "."));
UtilPlayer.message(caller, F.main("Clans", "You joined " + F.elem("Clan " + clan.getName()) + "."));
clan.inform(F.name(caller.getName()) + " has joined your Clan.", caller.getName());
}
else
{
_clansManager.getTutorials().sendTutorialMsg(caller, F.main("Clans", "There was an error processing your request"));
UtilPlayer.message(caller, F.main("Clans", "There was an error processing your request"));
}
}
});
@ -532,13 +533,13 @@ public class ClansCommand extends CommandBase<ClansManager>
if (clan == null)
{
_clansManager.getTutorials().sendTutorialMsg(caller, F.main("Clans", "You are not in a Clan."));
UtilPlayer.message(caller, F.main("Clans", "You are not in a Clan."));
return;
}
if (clan.getMembers().get(caller.getUniqueId()).getRole() == ClanRole.LEADER && clan.getMembers().size() > 1)
{
_clansManager.getTutorials().sendTutorialMsg(caller, F.main("Clans", "You must pass on " + F.elem("Leadership") + " before leaving."));
UtilPlayer.message(caller, F.main("Clans", "You must pass on " + F.elem("Leadership") + " before leaving."));
return;
}
@ -552,7 +553,7 @@ public class ClansCommand extends CommandBase<ClansManager>
public void run(Boolean data)
{
// Inform
_clansManager.getTutorials().sendTutorialMsg(caller, F.main("Clans", "You left " + F.elem("Clan " + clan.getName()) + "."));
UtilPlayer.message(caller, F.main("Clans", "You left " + F.elem("Clan " + clan.getName()) + "."));
clan.inform(F.name(caller.getName()) + " has left your Clan.", null);
}
});
@ -569,13 +570,13 @@ public class ClansCommand extends CommandBase<ClansManager>
if (clan == null)
{
_clansManager.getTutorials().sendTutorialMsg(caller, F.main("Clans", "You are not in a Clan."));
UtilPlayer.message(caller, F.main("Clans", "You are not in a Clan."));
return;
}
if (args.length < 2)
{
_clansManager.getTutorials().sendTutorialMsg(caller, F.main("Clans", "You did not input a Player to kick."));
UtilPlayer.message(caller, F.main("Clans", "You did not input a Player to kick."));
return;
}
@ -590,13 +591,13 @@ public class ClansCommand extends CommandBase<ClansManager>
if (clan == null)
{
_clansManager.getTutorials().sendTutorialMsg(caller, F.main("Clans", "You are not in a Clan."));
UtilPlayer.message(caller, F.main("Clans", "You are not in a Clan."));
return;
}
if (args.length < 2)
{
_clansManager.getTutorials().sendTutorialMsg(caller, F.main("Clans", "You did not input player to promote."));
UtilPlayer.message(caller, F.main("Clans", "You did not input player to promote."));
return;
}
@ -611,13 +612,13 @@ public class ClansCommand extends CommandBase<ClansManager>
if (clan == null)
{
_clansManager.getTutorials().sendTutorialMsg(caller, F.main("Clans", "You are not in a Clan."));
UtilPlayer.message(caller, F.main("Clans", "You are not in a Clan."));
return;
}
if (args.length < 2)
{
_clansManager.getTutorials().sendTutorialMsg(caller, F.main("Clans", "You did not input player to demote."));
UtilPlayer.message(caller, F.main("Clans", "You did not input player to demote."));
return;
}
@ -632,19 +633,19 @@ public class ClansCommand extends CommandBase<ClansManager>
if (cA == null)
{
_clansManager.getTutorials().sendTutorialMsg(caller, F.main("Clans", "You are not in a Clan."));
UtilPlayer.message(caller, F.main("Clans", "You are not in a Clan."));
return;
}
if (cA.getMembers().get(caller.getUniqueId()).getRole() != ClanRole.LEADER && cA.getMembers().get(caller.getUniqueId()).getRole() != ClanRole.ADMIN)
{
_clansManager.getTutorials().sendTutorialMsg(caller, F.main("Clans", "Only the Clan Leader and Admins can manage Alliances."));
UtilPlayer.message(caller, F.main("Clans", "Only the Clan Leader and Admins can manage Alliances."));
return;
}
if (args.length < 2)
{
_clansManager.getTutorials().sendTutorialMsg(caller, F.main("Clans", "You did not input a Clan to ally."));
UtilPlayer.message(caller, F.main("Clans", "You did not input a Clan to ally."));
return;
}
@ -654,31 +655,31 @@ public class ClansCommand extends CommandBase<ClansManager>
if (cA.isSelf(cB.getName()))
{
_clansManager.getTutorials().sendTutorialMsg(caller, F.main("Clans", "You cannot ally with yourself."));
UtilPlayer.message(caller, F.main("Clans", "You cannot ally with yourself."));
return;
}
if (cA.isAlly(cB.getName()))
{
_clansManager.getTutorials().sendTutorialMsg(caller, F.main("Clans", "You are already allies with Clan" + F.elem(cB.getName())) + ".");
UtilPlayer.message(caller, F.main("Clans", "You are already allies with Clan" + F.elem(cB.getName())) + ".");
return;
}
if (cA.getAllies() >= cA.getAlliesMax())
{
_clansManager.getTutorials().sendTutorialMsg(caller, F.main("Clans", "You cannot have any more allies."));
UtilPlayer.message(caller, F.main("Clans", "You cannot have any more allies."));
return;
}
if (cB.getAllies() >= cB.getAlliesMax())
{
_clansManager.getTutorials().sendTutorialMsg(caller, F.main("Clans", "Clan " + F.elem(cB.getName()) + " cannot have any more allies."));
UtilPlayer.message(caller, F.main("Clans", "Clan " + F.elem(cB.getName()) + " cannot have any more allies."));
return;
}
if (!Recharge.Instance.usable(caller, "AllyReq" + cB.getName()))
{
_clansManager.getTutorials().sendTutorialMsg(caller, F.main("Clans", "Please do not spam alliance requests."));
UtilPlayer.message(caller, F.main("Clans", "Please do not spam alliance requests."));
return;
}
@ -688,7 +689,7 @@ public class ClansCommand extends CommandBase<ClansManager>
Plugin.getClanDataAccess().ally(cA, cB, caller.getName());
// Inform
_clansManager.getTutorials().sendTutorialMsg(caller, F.main("Clans", "You accepted alliance with Clan " + F.elem(cB.getName()) + "."));
UtilPlayer.message(caller, F.main("Clans", "You accepted alliance with Clan " + F.elem(cB.getName()) + "."));
cA.inform(F.name(caller.getName()) + " accepted alliance with Clan " + F.elem(cB.getName()) + ".", caller.getName());
cB.inform("Clan " + F.elem(cA.getName()) + " has accepted alliance with you.", null);
}
@ -698,7 +699,7 @@ public class ClansCommand extends CommandBase<ClansManager>
Plugin.getClanDataAccess().requestAlly(cA, cB, caller.getName());
// Inform
_clansManager.getTutorials().sendTutorialMsg(caller, F.main("Clans", "You requested alliance with Clan " + F.elem(cB.getName()) + "."));
UtilPlayer.message(caller, F.main("Clans", "You requested alliance with Clan " + F.elem(cB.getName()) + "."));
cA.inform(F.name(caller.getName()) + " has requested alliance with Clan " + F.elem(cB.getName()) + ".", caller.getName());
cB.inform("Clan " + F.elem(cA.getName()) + " has requested alliance with you.", null);
@ -761,19 +762,19 @@ public class ClansCommand extends CommandBase<ClansManager>
if (cA == null)
{
_clansManager.getTutorials().sendTutorialMsg(caller, F.main("Clans", "You are not in a Clan."));
UtilPlayer.message(caller, F.main("Clans", "You are not in a Clan."));
return;
}
if (cA.getMembers().get(caller.getUniqueId()).getRole() != ClanRole.LEADER && cA.getMembers().get(caller.getUniqueId()).getRole() != ClanRole.ADMIN)
{
_clansManager.getTutorials().sendTutorialMsg(caller, F.main("Clans", "Only the Clan Leader and Admins can manage relationships."));
UtilPlayer.message(caller, F.main("Clans", "Only the Clan Leader and Admins can manage relationships."));
return;
}
if (args.length < 2)
{
_clansManager.getTutorials().sendTutorialMsg(caller, F.main("Clans", "You did not input a Clan to set neutrality with."));
UtilPlayer.message(caller, F.main("Clans", "You did not input a Clan to set neutrality with."));
return;
}
@ -783,11 +784,11 @@ public class ClansCommand extends CommandBase<ClansManager>
if (cB.isSelf(cA.getName()))
{
_clansManager.getTutorials().sendTutorialMsg(caller, F.main("Clans", "You prefer to think of yourself positively..."));
UtilPlayer.message(caller, F.main("Clans", "You prefer to think of yourself positively..."));
}
else if (cB.isNeutral(cA.getName()))
{
_clansManager.getTutorials().sendTutorialMsg(caller, F.main("Clans", "You are already neutral with " + F.elem("Clan " + cB.getName()) + "."));
UtilPlayer.message(caller, F.main("Clans", "You are already neutral with " + F.elem("Clan " + cB.getName()) + "."));
}
else if (cB.isAlly(cA.getName()))
{
@ -795,7 +796,7 @@ public class ClansCommand extends CommandBase<ClansManager>
Plugin.getClanDataAccess().neutral(cA, cB, caller.getName(), true);
// Inform
_clansManager.getTutorials().sendTutorialMsg(caller, F.main("Clans", "You revoked alliance with " + F.elem("Clan " + cB.getName()) + "."));
UtilPlayer.message(caller, F.main("Clans", "You revoked alliance with " + F.elem("Clan " + cB.getName()) + "."));
cA.inform(F.name(caller.getName()) + " revoked alliance with " + F.elem("Clan " + cB.getName()) + ".", caller.getName());
cB.inform(F.elem("Clan " + cA.getName()) + " has revoked alliance with you.", null);
}
@ -850,7 +851,7 @@ public class ClansCommand extends CommandBase<ClansManager>
}
// Change Inform
_clansManager.getTutorials().sendTutorialMsg(caller, F.main("Clans", "You can no longer 'steal' territory. " + "You simply unclaim it and it can not be reclaimed by anyone for 30 mintes." + "This was done to improve gameplay. Enjoy!"));
UtilPlayer.message(caller, F.main("Clans", "You can no longer 'steal' territory. " + "You simply unclaim it and it can not be reclaimed by anyone for 30 mintes." + "This was done to improve gameplay. Enjoy!"));
// Inform
UtilServer.broadcast(F.main("Clans", F.elem(clientClan.getName()) + " unclaimed from " + F.elem(ownerClan.getName()) + " at " + F.elem(UtilWorld.locToStrClean(caller.getLocation())) + "."));
@ -886,19 +887,21 @@ public class ClansCommand extends CommandBase<ClansManager>
if (clan == null)
{
_clansManager.getTutorials().sendTutorialMsg(caller, F.main("Clans", "You are not in a Clan."));
//teleport to spawn point
Spawn.getInstance().getSpawnLocation(); UtilPlayer.message(caller, F.main("Clans", "You are not in a Clan."));
return;
}
if (clan.getHome() == null)
{
_clansManager.getTutorials().sendTutorialMsg(caller, F.main("Clans", "Your Clan has not set a Home"));
UtilPlayer.message(caller, F.main("Clans", "Your Clan has not set a Home"));
return;
}
if (!clan.getClaimSet().contains(UtilWorld.chunkToStr(clan.getHome().getChunk())))
{
_clansManager.getTutorials().sendTutorialMsg(caller, F.main("Clans", "Your Clan has lost its Home Territory."));
UtilPlayer.message(caller, F.main("Clans", "Your Clan has lost its Home Territory."));
return;
}
@ -906,7 +909,7 @@ public class ClansCommand extends CommandBase<ClansManager>
if (!(home.getBlock().getType().equals(Material.BED_BLOCK) && home.add(0, 1, 0).getBlock().getType().equals(Material.AIR)) && home.add(0, 2, 0).getBlock().getType().equals(Material.AIR))
{
_clansManager.getTutorials().sendTutorialMsg(caller, F.main("Clans", "Your Clan's bed has been destroyed, or is obstructed."));
UtilPlayer.message(caller, F.main("Clans", "Your Clan's bed has been destroyed, or is obstructed."));
return;
}
@ -934,12 +937,12 @@ public class ClansCommand extends CommandBase<ClansManager>
Plugin.getTeleport().TP(caller, clan.getHome().add(0, 1, 0));
// Inform
_clansManager.getTutorials().sendTutorialMsg(caller, F.main("Clans", "You teleported to your Clan Home " + UtilWorld.locToStrClean(caller.getLocation()) + "."));
UtilPlayer.message(caller, F.main("Clans", "You teleported to your Clan Home " + UtilWorld.locToStrClean(caller.getLocation()) + "."));
}
}, new Callback<DelayedTaskClient>() {
public void run(DelayedTaskClient client)
{
UtilTextMiddle.display("", "Teleporting to Clan Home in " + F.elem(UtilTime.MakeStr(Math.max(0, client.getTimeLeft("Home Teleport")))), 0, 5, 0, client.getPlayer());
UtilTextMiddle.display("", "Teleporting to Clan Home in " + F.time(UtilTime.MakeStr(Math.max(0, client.getTimeLeft("Home Teleport")))), 0, 5, 0, client.getPlayer());
}
}, new Callback<DelayedTaskClient>() {
public void run(DelayedTaskClient client)
@ -964,7 +967,7 @@ public class ClansCommand extends CommandBase<ClansManager>
if (clan == null)
{
_clansManager.getTutorials().sendTutorialMsg(caller, F.main("Clans", "You are not in a Clan."));
UtilPlayer.message(caller, F.main("Clans", "You are not in a Clan."));
return;
}
@ -977,25 +980,25 @@ public class ClansCommand extends CommandBase<ClansManager>
if (clan.getMembers().get(caller.getUniqueId()).getRole() != ClanRole.LEADER && clan.getMembers().get(caller.getUniqueId()).getRole() != ClanRole.ADMIN)
{
_clansManager.getTutorials().sendTutorialMsg(caller, F.main("Clans", "Only the Clan Leader and Admins can manage Clan Home."));
UtilPlayer.message(caller, F.main("Clans", "Only the Clan Leader and Admins can manage Clan Home."));
return;
}
if (Plugin.getClanUtility().getOwner(caller.getLocation()) == null)
{
_clansManager.getTutorials().sendTutorialMsg(caller, F.main("Clans", "You must set your Clan Home in your own Territory."));
UtilPlayer.message(caller, F.main("Clans", "You must set your Clan Home in your own Territory."));
return;
}
if (!Plugin.getClanUtility().getOwner(caller.getLocation()).isSelf(clan.getName()))
{
_clansManager.getTutorials().sendTutorialMsg(caller, F.main("Clans", "You must set your Clan Home in your own Territory."));
UtilPlayer.message(caller, F.main("Clans", "You must set your Clan Home in your own Territory."));
return;
}
if (!(caller.getLocation().add(0, 1, 0).getBlock().getType().equals(Material.AIR) && caller.getLocation().add(0, 2, 0).getBlock().getType().equals(Material.AIR)))
{
_clansManager.getTutorials().sendTutorialMsg(caller, F.main("Clans", "This is not a suitable place for a bed."));
UtilPlayer.message(caller, F.main("Clans", "This is not a suitable place for a bed."));
return;
}
@ -1004,7 +1007,7 @@ public class ClansCommand extends CommandBase<ClansManager>
if (!bedPlaced)
{
_clansManager.getTutorials().sendTutorialMsg(caller, F.main("Clans", "This is not a suitable place for a bed."));
UtilPlayer.message(caller, F.main("Clans", "This is not a suitable place for a bed."));
return;
}
@ -1020,7 +1023,7 @@ public class ClansCommand extends CommandBase<ClansManager>
Plugin.ClanTips.displayTip(TipType.SETHOME, caller);
// Inform
_clansManager.getTutorials().sendTutorialMsg(caller, F.main("Clans", "You set Clan Home to " + F.elem(UtilWorld.locToStrClean(caller.getLocation())) + "."));
UtilPlayer.message(caller, F.main("Clans", "You set Clan Home to " + F.elem(UtilWorld.locToStrClean(caller.getLocation())) + "."));
clan.inform(caller.getName() + " set Clan Home to " + F.elem(UtilWorld.locToStrClean(caller.getLocation())) + ".", caller.getName());
}
@ -1030,7 +1033,7 @@ public class ClansCommand extends CommandBase<ClansManager>
if (search == null)
{
_clansManager.getTutorials().sendTutorialMsg(caller, F.main("Clans", "You did not input a search parameter."));
UtilPlayer.message(caller, F.main("Clans", "You did not input a search parameter."));
return;
}
@ -1048,36 +1051,6 @@ public class ClansCommand extends CommandBase<ClansManager>
_clansManager.getClanShop().openClanWho(caller, clan);
}
public void forceJoinClan(Player caller, String search)
{
if (_clansManager.getClientManager().hasRank(caller, Rank.ADMIN))
{
_clansManager.getTutorials().sendTutorialMsg(caller, F.main("Clans", "No no no, this command is not for you ;-)"));
return;
}
if (search == null)
{
_clansManager.getTutorials().sendTutorialMsg(caller, F.main("Clans", "You did not input a search parameter."));
return;
}
ClansCommandExecutedEvent event = new ClansCommandExecutedEvent(caller, "info", search);
UtilServer.getServer().getPluginManager().callEvent(event);
if (event.isCancelled())
{
return;
}
ClanInfo clan = Plugin.getClanUtility().searchClanPlayer(caller, search, true);
if (clan == null) return;
_clansManager.getClanUtility().join(caller, clan);
_clansManager.getClanDataAccess().role(clan, caller.getUniqueId(), ClanRole.LEADER);
}
public void infoTerritory(Player caller, String[] args)
{
ClanInfo clan;
@ -1087,7 +1060,7 @@ public class ClansCommand extends CommandBase<ClansManager>
if (clan == null)
{
_clansManager.getTutorials().sendTutorialMsg(caller, F.main("Clans", "You are not in a Clan."));
UtilPlayer.message(caller, F.main("Clans", "You are not in a Clan."));
return;
}
}
@ -1104,6 +1077,6 @@ public class ClansCommand extends CommandBase<ClansManager>
// return;
// }
_clansManager.getTutorials().sendTutorialMsg(caller, clan.mTerritory());
UtilPlayer.message(caller, clan.mTerritory());
}
}

View File

@ -18,7 +18,7 @@ public class KillCommand extends CommandBase<DamageManager>
@Override
public void Execute(Player caller, String[] args)
{
if ((System.currentTimeMillis() - Plugin.GetCombatManager().Get(caller).GetLastDamaged()) >= 30000)
if ((System.currentTimeMillis() - Plugin.GetCombatManager().Get(caller).GetLastCombat()) <= 20000)
{
UtilPlayer.message(caller, F.main("Clans", "You cannot use this command whilst in combat."));
return;

View File

@ -0,0 +1,53 @@
package mineplex.game.clans.clans.commands;
import org.bukkit.entity.Player;
import mineplex.core.command.CommandBase;
import mineplex.core.common.Rank;
import mineplex.core.common.util.Callback;
import mineplex.core.common.util.F;
import mineplex.core.common.util.UtilPlayer;
import mineplex.core.database.MinecraftRepository;
import mineplex.game.clans.clans.ClanInfo;
import mineplex.game.clans.clans.ClansManager;
import mineplex.serverdata.database.DBPool;
import mineplex.serverdata.database.RepositoryBase;
public class QueryCommand extends CommandBase<ClansManager>
{
private ClansManager _clansManager;
public QueryCommand(ClansManager plugin)
{
super(plugin, Rank.JNR_DEV, "query");
_clansManager = plugin;
}
@Override
public void Execute(final Player caller, String[] args)
{
if (args.length == 0)
{
UtilPlayer.message(caller, F.main(Plugin.getName(), "Query missing."));
return;
}
final String query = F.combine(args, 0, null, false);
new MinecraftRepository(Plugin.getPlugin(), DBPool.getAccount()) {
protected void initialize()
{
executeUpdate(query);
}
protected void update()
{
}
};
}
public static void message(Player player, String message)
{
UtilPlayer.message(player, F.main("Clans", message));
}
}

View File

@ -51,7 +51,7 @@ public class RestartTutCommand extends CommandBase<TutorialManager>
}
else
{
TutorialManager.Instance.sendTutorialMsg(caller, F.main("Clans", "You must be in a Safe Zone to restart the tutorial."));
UtilPlayer.message(caller, F.main("Clans", "You must be in a Safe Zone to restart the tutorial."));
}
}
}

View File

@ -9,30 +9,31 @@ import org.bukkit.entity.Player;
import org.bukkit.event.EventHandler;
import org.bukkit.event.EventPriority;
import org.bukkit.event.entity.EntityShootBowEvent;
import org.bukkit.event.player.AsyncPlayerPreLoginEvent;
import org.bukkit.event.player.PlayerJoinEvent;
import org.bukkit.event.player.PlayerQuitEvent;
import mineplex.core.MiniClientPlugin;
import mineplex.core.common.jsonchat.ClickEvent;
import mineplex.core.common.jsonchat.JsonMessage;
import mineplex.core.account.CoreClientManager;
import mineplex.core.common.util.C;
import mineplex.core.common.util.Callback;
import mineplex.core.common.util.F;
import mineplex.core.common.util.UtilAction;
import mineplex.core.common.util.UtilAlg;
import mineplex.core.common.util.UtilPlayer;
import mineplex.core.common.util.UtilServer;
import mineplex.core.common.util.UtilTextMiddle;
import mineplex.core.common.util.UtilTime;
import mineplex.core.stats.StatsManager;
import mineplex.core.task.TaskManager;
import mineplex.core.updater.UpdateType;
import mineplex.core.updater.event.UpdateEvent;
import mineplex.game.clans.clans.ClanTips.TipType;
import mineplex.game.clans.clans.ClansManager;
import mineplex.game.clans.clans.event.ClanTipEvent;
import mineplex.game.clans.clans.event.PlayerEnterTerritoryEvent;
import mineplex.game.clans.clans.playtime.Playtime;
import mineplex.game.clans.clans.playtime.command.cemde;
import mineplex.game.clans.clans.pvptimer.command.PvPTimerCommand;
import mineplex.game.clans.clans.pvptimer.repository.PvpTimerRepository;
import mineplex.game.clans.clans.pvptimer.repository.TimerClientToken;
import mineplex.game.clans.core.repository.ClanTerritory;
import mineplex.game.clans.spawn.Spawn;
import mineplex.minecraft.game.classcombat.Skill.event.SkillTriggerEvent;
@ -41,20 +42,33 @@ import mineplex.minecraft.game.core.damage.CustomDamageEvent;
public class PvpTimer extends MiniClientPlugin<PvpTimerClient>
{
public static final String SKIPPED_TASK = "PvpTimer.Skipped";
private final int[] DISPLAY_TIMES = { 5, 10, 30, 1 * 60, 2 * 60, 5 * 60, 10 * 60, 20 * 60 };
private final int[] DISPLAY_TIMES = {
5,
10,
30,
1 * 60,
2 * 60,
5 * 60,
10 * 60,
20 * 60
};
private PvpTimerRepository _repository;
private CoreClientManager _clientManager;
private ClansManager _clansManager;
private Playtime _tracker;
private static long TIMER_LENGTH = 30 * 60;
public PvpTimer(ClansManager clans, Playtime playtime, StatsManager statsManager)
public PvpTimer(ClansManager clans, StatsManager statsManager)
{
super("PvP Timer", clans.getPlugin());
_tracker = playtime;
_clansManager = clans;
_clientManager = clans.getClientManager();
_repository = new PvpTimerRepository(this, clans.getClientManager());
addCommand(new cemde(statsManager, this));
}
@ -69,7 +83,7 @@ public class PvpTimer extends MiniClientPlugin<PvpTimerClient>
Get(caller).Skipped = true;
caller.playSound(caller.getLocation(), Sound.ENDERDRAGON_GROWL, 1f, 0.75f);
TaskManager.Instance.completedTask(null, caller, "PvpTimer.Skipped");
_repository.Save(_clientManager.getAccountId(caller), Get(caller).Skipped, Get(caller).Elapsed);
}
@EventHandler
@ -89,9 +103,26 @@ public class PvpTimer extends MiniClientPlugin<PvpTimerClient>
}
}
@EventHandler
public void onPlayerQuit(PlayerQuitEvent event)
{
runAsync(() -> _repository.Save(_clientManager.getAccountId(event.getPlayer()), Get(event.getPlayer()).Skipped, Get(event.getPlayer()).Elapsed + (int) (elapsed(event.getPlayer()) / 1000)));
}
@EventHandler
public void outYouGo(UpdateEvent event)
{
if (event.getType() == UpdateType.SLOWER)
{
UtilServer.getPlayersCollection().forEach(player -> {
PvpTimerClient client = Get(player);
client.StartTime = System.currentTimeMillis();
runAsync(() -> _repository.Save(_clientManager.getAccountId(player), client.Skipped, client.Elapsed += (int) (elapsed(player))));
});
}
if (event.getType() == UpdateType.SEC)
{
for (Player player : Bukkit.getOnlinePlayers())
@ -149,9 +180,9 @@ public class PvpTimer extends MiniClientPlugin<PvpTimerClient>
}
}, 10);
UtilPlayer.message(player, F.main("Clans", "You are currently safe from PvP because you are a new player. This safety will end in " + F.elem(UtilTime.MakeStr(getPvPTimerLeft(player) * 1000))));
UtilPlayer.message(player, F.main("Clans", "Until it ends, you are immune to, and unable to deal PvP damage."));
UtilPlayer.message(player, F.main("Clans", "If you would like to disable the PvP safety permanently, then type " + F.elem("/pvp") + "."));
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 + "If you would like to disable the PvP safety permanently, then type " + F.elem("/pvp") + ".");
}
}
@ -171,17 +202,17 @@ public class PvpTimer extends MiniClientPlugin<PvpTimerClient>
{
UtilPlayer.message(player, F.main("Clans", "PvP Safety has ended!"));
UtilPlayer.message(player, F.main("Clans", "You are now completely open to attacks, and you can also attack others."));
player.playSound(player.getLocation(), Sound.ENDERDRAGON_GROWL, 1f, 0.75f);
player.playSound(player.getLocation(), Sound.ENDERDRAGON_GROWL, 0.2f, 0.75f);
continue;
}
for (int unit : DISPLAY_TIMES)
{
if (time <= unit && !client.InformedTimes.contains(unit))
if (time <= unit && !client.InformedTimes.contains(Integer.valueOf(unit)))
{
UtilPlayer.message(player, F.main("Clans", "PvP Safety will end in " + F.time(UtilTime.MakeStr(unit * 1000))));
UtilTextMiddle.display(C.cGreen + "Pvp Safety", C.cGray + "ending in " + UtilTime.MakeStr(unit * 1000), 20, 80, 20, player);
client.InformedTimes.add(unit);
client.InformedTimes.add(Integer.valueOf(unit));
}
}
}
@ -255,7 +286,10 @@ public class PvpTimer extends MiniClientPlugin<PvpTimerClient>
{
if (victimTimer)
{
if (!bothMsg) UtilPlayer.message(damager, F.main("Clans", "You and " + F.name(victim.getName()) + " are still under PvP Safety. Type " + F.elem("/pvp") + " to disable."));
if (!bothMsg)
{
UtilPlayer.message(damager, F.main("Clans", "You and " + F.name(victim.getName()) + " are still under PvP Safety. Type " + F.elem("/pvp") + " to disable."));
}
}
else if (damager != null)
{
@ -267,13 +301,29 @@ public class PvpTimer extends MiniClientPlugin<PvpTimerClient>
}
@EventHandler(priority = EventPriority.LOWEST)
public void ClientLoad(AsyncPlayerPreLoginEvent event)
{
_clientManager.getRepository().getAccountId(event.getUniqueId(), accountId -> {
TimerClientToken token = _repository.Get(accountId.intValue());
Get(event.getName()).Skipped = token.Skipped;
Get(event.getName()).Elapsed = token.Elapsed;
});
}
public long getPvPTimerLeft(Player player)
{
long time = (_tracker.getPlaytime(player) + _tracker.getUnsavedPlaytime(player));
long time = Get(player).Elapsed + (elapsed(player) / 1000);
return (TIMER_LENGTH <= time ? 0 : TIMER_LENGTH - time);
}
public long elapsed(Player player)
{
return System.currentTimeMillis() - Get(player).StartTime;
}
public boolean hasTimer(Player victim)
{
return victim != null && getPvPTimerLeft(victim) > 0 && !Get(victim).Skipped;
@ -282,6 +332,6 @@ public class PvpTimer extends MiniClientPlugin<PvpTimerClient>
@Override
protected PvpTimerClient AddPlayer(String player)
{
return new PvpTimerClient(Bukkit.getPlayer(player));
return new PvpTimerClient();
}
}

View File

@ -6,15 +6,18 @@ import java.util.List;
import org.bukkit.entity.Player;
import mineplex.core.task.TaskManager;
import mineplex.game.clans.clans.ClansPlayerTasks;
public class PvpTimerClient
{
public boolean Skipped;
public List<Integer> InformedTimes;
public long StartTime;
public int Elapsed;
public PvpTimerClient(Player player)
public PvpTimerClient()
{
Skipped = TaskManager.Instance.hasCompletedTask(player, PvpTimer.SKIPPED_TASK);
StartTime = System.currentTimeMillis();
InformedTimes = new ArrayList<>();
}
}

View File

@ -38,7 +38,7 @@ public class PvPTimerCommand extends CommandBase<PvpTimer>
}
else
{
UtilPlayer.message(caller, F.main("Clans", "You have " + F.elem(UtilTime.MakeStr(pvpTimerLeft * 1000)) + " before PvP Safety runs out for you."));
UtilPlayer.message(caller, F.main("Clans", "You have " + F.time(UtilTime.MakeStr(pvpTimerLeft * 1000)) + " before PvP Safety runs out for you."));
new JsonMessage(F.main("Clans", "If you would like to permanently disable " + C.mBody + "PvP Safety, click "))
.extra("here")
.color("green")

View File

@ -43,7 +43,7 @@ public class ClansRegions extends MiniPlugin
public final static int SHOP_RADIUS = 5; // Radius of shop claim area (measured in chunks)
public final static int FIELDS_RADIUS = 7; // Radius of fields claim area (measured in chunks)
public final static int BORDERLANDS_RADIUS = 50; // Radius of borderlands claim area (measured in chunks)
public static final int BORDER_RADIUS = 768;
public static final int BORDER_RADIUS = 1319;
private ClansManager _manager;
private World _world;
@ -66,10 +66,10 @@ public class ClansRegions extends MiniPlugin
Location worldCenter = new Location(_world, 0, 0, 0);
// Initialize Spawn faction and claims
claimArea("Spawn", SPAWN_RADIUS, 0, false, true, new Location[]{Spawn.getEastSpawn(), Spawn.getWestSpawn()});
claimArea("Spawn", SPAWN_RADIUS, 0, false, true, new Location[] { Spawn.getNorthSpawn(), Spawn.getSouthSpawn() });
claimArea("Shops", 2, 0, true, false, new Location[]{Spawn.getNorthTownCenter(), Spawn.getSouthTownCenter()});
claimArea("Shops", SHOP_RADIUS, 2, false, false, new Location[]{Spawn.getNorthTownCenter(), Spawn.getSouthTownCenter()});
claimArea("Shops", 2, 0, true, false, new Location[]{Spawn.getWestTownCenter(), Spawn.getEastTownCenter()});
claimArea("Shops", SHOP_RADIUS, 2, false, false, new Location[]{Spawn.getWestTownCenter(), Spawn.getEastTownCenter()});
// Initialize Fields and Borderlands factions and claims
claimArea("Fields", FIELDS_RADIUS, 0, false, true, worldCenter);
@ -140,8 +140,9 @@ public class ClansRegions extends MiniPlugin
public void claimArea(final String clanName, final int chunkRadius, final int claimOffset, final boolean safe, final boolean addNegative, final Location... locations)
{
final ClanInfo clan = _manager.getClan(clanName);
if (clan == null )
// Only claim if the clan doesn't exist yet. Speeds up startup time
if (clan == null)
{
_manager.getClanDataAccess().create("ClansRegions", clanName, true, new Callback<ClanInfo>()
{
@ -166,13 +167,6 @@ public class ClansRegions extends MiniPlugin
}
});
}
else
{
for (Location location : locations)
{
claimArea(clan, location, chunkRadius, claimOffset, addNegative, safe);
}
}
}
/*private void claimArea(String clanName, int chunkRadius, int claimOffset, boolean safe, Location... locations)

View File

@ -3,12 +3,12 @@ package mineplex.game.clans.clans.siege;
import java.util.Stack;
import org.bukkit.Location;
import org.bukkit.entity.ArmorStand;
import org.bukkit.entity.Entity;
import org.bukkit.entity.Player;
import org.bukkit.entity.Slime;
import org.bukkit.event.EventHandler;
import org.bukkit.event.block.BlockPlaceEvent;
import org.bukkit.event.player.PlayerJoinEvent;
import com.google.gson.Gson;
@ -18,17 +18,20 @@ import mineplex.core.common.util.NautHashMap;
import mineplex.core.common.util.UtilInv;
import mineplex.core.common.util.UtilMath;
import mineplex.core.common.util.UtilPlayer;
import mineplex.core.common.util.UtilServer;
import mineplex.core.common.util.UtilTime;
import mineplex.core.updater.UpdateType;
import mineplex.core.updater.event.UpdateEvent;
import mineplex.game.clans.analytics.Profiler;
import mineplex.game.clans.clans.ClansManager;
import mineplex.game.clans.clans.siege.commands.CommandSiegeSupplies;
import mineplex.game.clans.clans.siege.outpost.OutpostManager;
import mineplex.game.clans.clans.siege.repository.SiegeWeaponRepository;
import mineplex.game.clans.clans.siege.repository.tokens.SiegeWeaponToken;
import mineplex.game.clans.clans.siege.weapon.Cannon;
import mineplex.game.clans.clans.siege.weapon.Catapult;
import mineplex.game.clans.clans.siege.weapon.SiegeWeapon;
import mineplex.game.clans.core.repository.ClanTerritory;
import mineplex.game.clans.spawn.Spawn;
public class SiegeManager extends MiniPlugin
{
@ -58,58 +61,109 @@ public class SiegeManager extends MiniPlugin
Instance = this;
_repository = new SiegeWeaponRepository(clans.getPlugin(), this);
_repository = new SiegeWeaponRepository(clans.getPlugin());
_outpostManager.loadOutposts(() -> {
loadSiegeWeapons();
});
_outpostManager.loadOutposts();
getRepository().getWeaponsByServer(getClansManager().getServerId(), tokens ->
tokens.forEach(token ->
runSync(() -> {
final SiegeWeapon weapon;
token.Location.getChunk().load();
switch(token.WeaponType)
{
case 2:
weapon = new Cannon(SiegeManager.this, token);
break;
default:
System.out.println("[WEAPONS] ERROR WHILST LOADING WEAPON: INVALID WEAPON TYPE");
return;
}
System.out.println("[WEAPONS] LOADED SIEGE WEAPON " + weapon.getClass().getSimpleName() + " [" + token.UniqueId + "]");
LiveSiegeWeapons.put(Integer.valueOf(token.UniqueId), weapon);
})
)
);
}
@EventHandler
public void CleanupWeirdos(UpdateEvent event)
{
if (event.getType() == UpdateType.SEC && UtilServer.getPlayers().length != 0)
{
Spawn.getSpawnWorld().getEntitiesByClass(Slime.class).stream().filter(slime -> slime.getSize() != -1).forEach(slime -> {
boolean part = false;
for (SiegeWeapon weapon : LiveSiegeWeapons.values())
{
if (weapon.isPartOf(slime.getUniqueId()))
{
part = true;
break;
}
}
if (!part)
{
slime.remove();
}
else
{
slime.setSize(-1);
}
});
}
}
@EventHandler
public void save(UpdateEvent event)
{
if (event.getType() == UpdateType.SLOWER)
if (!UtilTime.elapsed(_initializedTime, 5500) || UtilServer.getPlayers().length == 0)
{
_outpostManager.saveOutposts(() -> {
saveSiegeWeapons();
});
return;
}
}
private void loadSiegeWeapons()
{
_repository.getWeaponsByServer(_clansManager.getServerId(), tokens ->
tokens.forEach(token -> {
SiegeWeapon weapon = null;
if (event.getType() == UpdateType.SLOW)
{
_outpostManager.saveOutposts();
saveSiegeWeapons();
Profiler.Instance.start("SiegeManager.CleanupEntities");
for (Entity entity : Spawn.getSpawnWorld().getEntitiesByClass(ArmorStand.class))
{
boolean part = false;
switch(token.WeaponType)
for (SiegeWeapon weapon : LiveSiegeWeapons.values())
{
case 1:
weapon = new Catapult(this, token);
if (weapon.isPartOf(entity.getUniqueId()))
{
part = true;
break;
case 2:
weapon = new Cannon(this, token);
break;
default:
System.out.println("[WEAPONS] ERROR WHILST LOADING WEAPON: INVALID WEAPON TYPE");
return;
}
}
if (!weapon.getLocation().getChunk().load())
if (!part)
{
System.out.println("[WEAPONS] SKIPPING & REMOVING WEAPON [" + token.UniqueId + "] BECAUSE OF CHUNK LOADING FAILURE");
if (((ArmorStand) entity).getHelmet() != null && ((ArmorStand) entity).getHelmet().isSimilar(Cannon.CANNON_ITEM))
{
entity.remove();
}
weapon.kill();
_repository.deleteWeapon(token.UniqueId);
return;
if (entity.getPassenger() != null && entity.getPassenger() instanceof Slime && entity.getPassenger().getPassenger() instanceof Slime)
{
entity.getPassenger().getPassenger().remove();
entity.getPassenger().remove();
entity.remove();
}
}
System.out.println("[WEAPONS] LOADED SIEGE WEAPON " + weapon.getClass().getSimpleName() + " [" + token.UniqueId + "]");
LiveSiegeWeapons.put(Integer.valueOf(token.UniqueId), weapon);
})
);
}
Profiler.Instance.end();
}
}
private void saveSiegeWeapons()
@ -125,23 +179,27 @@ public class SiegeManager extends MiniPlugin
});
}
runAsync(() -> {
Profiler.Instance.start("SiegeManager.CleanupEntities");
while (!queue.isEmpty())
{
queue.pop().run();
}
});
runAsync(() ->
_repository.getWeaponsByServer(_clansManager.getServerId(), tokens ->
_repository.getWeaponsByServer(_clansManager.getServerId(), tokens -> {
tokens.forEach(token -> {
if (!LiveSiegeWeapons.containsKey(Integer.valueOf(token.UniqueId)))
{
System.out.println("LiveSiegeWeapons no longer contains old weapon " + token.UniqueId + ", deleting.");
_repository.deleteWeapon(token.UniqueId);
}
})
)
);
});
});
Profiler.Instance.end();
});
}
@EventHandler
@ -211,47 +269,6 @@ public class SiegeManager extends MiniPlugin
LiveSiegeWeapons.put(Integer.valueOf(cannon.getUniqueId()), cannon);
}
public boolean trySpawnCatapult(Player player, Location location)
{
// if (_clansManager.getNetherManager().isInNether(player))
// {
// _clansManager.message(player, "You are not allowed to place this in " + F.clansNether("The Nether") + ".");
//
// return false;
// }
if (!_clansManager.isInClan(player))
{
UtilPlayer.message(player, F.main("Clans", "You must be in a Clan to place a Catapult."));
return false;
}
if(_clansManager.getPvpTimer().hasTimer(player))
{
UtilPlayer.message(player, F.main("Clans", "You cannot place a Catapult whilst protected from pvp."));
return false;
}
ClanTerritory claim = _clansManager.getClanUtility().getClaim(location);
if (claim != null && !claim.Owner.equals(_clansManager.getClan(player).getName()))
{
UtilPlayer.message(player, F.main("Clans", "You must place a Catapult in the Wilderness or your own Territory."));
return false;
}
spawnCatapult(player, location);
return true;
}
public void spawnCatapult(Player player, Location location)
{
Catapult catapult = new Catapult(location, _clansManager.getClan(player), this);
LiveSiegeWeapons.put(Integer.valueOf(catapult.getUniqueId()), catapult);
}
public void dead(SiegeWeapon weapon)
{
LiveSiegeWeapons.remove(Integer.valueOf(weapon.getUniqueId()));

View File

@ -10,7 +10,6 @@ import mineplex.core.common.util.UtilPlayer;
import mineplex.game.clans.clans.siege.outpost.Outpost;
import mineplex.game.clans.clans.siege.outpost.OutpostManager;
import mineplex.game.clans.clans.siege.weapon.Cannon;
import mineplex.game.clans.clans.siege.weapon.Catapult;
public class CommandSiegeSupplies extends CommandBase<OutpostManager>
{
@ -24,15 +23,12 @@ public class CommandSiegeSupplies extends CommandBase<OutpostManager>
{
ItemStack outpost = new ItemStack(Outpost.OUTPOST_ITEM);
ItemStack cannons = new ItemStack(Cannon.CANNON_ITEM);
// ItemStack catapults = new ItemStack(Catapult.CATAPULT_ITEM);
outpost.setAmount(64);
cannons.setAmount(64);
// catapults.setAmount(64);
caller.getInventory().addItem(outpost);
caller.getInventory().addItem(cannons);
// caller.getInventory().addItem(catapults);
UtilPlayer.message(caller, F.main("Clans", "Received supplies for a siege."));
}

View File

@ -64,7 +64,7 @@ import net.minecraft.server.v1_8_R3.AxisAlignedBB;
public class Outpost implements Listener
{
protected static final long MAX_LIFETIME = 30 * 60 * 1000; // 30 minutes
public static final ItemStack OUTPOST_ITEM = new ItemBuilder(Material.BEACON, 1).setRawTitle(C.cBlue + "Outpost").build();
public static final ItemStack OUTPOST_ITEM = new ItemBuilder(Material.BEACON, 1).setRawTitle(C.Reset + C.cBlue + "Outpost").build();
public static final long PREP_TIME = 2 * 60 * 1000;

View File

@ -27,6 +27,7 @@ import mineplex.core.common.util.UtilMath;
import mineplex.core.common.util.UtilPlayer;
import mineplex.core.updater.UpdateType;
import mineplex.core.updater.event.UpdateEvent;
import mineplex.game.clans.analytics.Profiler;
import mineplex.game.clans.clans.ClanInfo;
import mineplex.game.clans.clans.ClansBlacklist;
import mineplex.game.clans.clans.ClansManager;
@ -185,7 +186,7 @@ public class OutpostManager extends MiniPlugin
}
_outposts.put(clan.getName(), new Outpost(this, clan, location, type));
_idToOutpost.put(_outposts.get(clan.getName()).getUniqueId(), _outposts.get(clan.getName()));
_idToOutpost.put(Integer.valueOf(_outposts.get(clan.getName()).getUniqueId()), _outposts.get(clan.getName()));
return true;
}
@ -258,11 +259,11 @@ public class OutpostManager extends MiniPlugin
return _clansManager;
}
public void loadOutposts(Runnable post)
public void loadOutposts()
{
System.out.println("[OUTPOSTS] LOADING OUTPOSTS FROM DATABASE");
_repository.getOutpostsByServer(_clansManager.getServerId(), tokens -> {
_repository.getOutpostsByServer(_clansManager.getServerId(), tokens ->
tokens.forEach(token -> {
Outpost outpost = new Outpost(this, token);
@ -279,14 +280,11 @@ public class OutpostManager extends MiniPlugin
System.out.println("[OUTPOSTS] INITIALIZED OUTPOST FROM DATABASE SAVE");
_outposts.put(token.OwnerClan.getName(), outpost);
});
if (post != null)
post.run();
});
})
);
}
public void saveOutposts(Runnable post)
public void saveOutposts()
{
final Stack<Runnable> queue = new Stack<>();
@ -297,21 +295,23 @@ public class OutpostManager extends MiniPlugin
});
runAsync(() -> {
Profiler.Instance.start("OutpostManager.UpdateOutposts");
while (!queue.isEmpty())
queue.pop().run();
});
runAsync(() ->
_repository.getOutpostsByServer(_clansManager.getServerId(), tokens ->
_repository.getOutpostsByServer(_clansManager.getServerId(), tokens -> {
tokens.forEach(token -> {
if (!_idToOutpost.containsKey(Integer.valueOf(token.UniqueId)))
{
System.out.println("[OUTPOSTS] OUTPOST [" + token.UniqueId + "] NO LONGER EXISTS, DELETING");
_repository.deleteOutpost(token.UniqueId);
}
})
)
);
});
});
Profiler.Instance.end();
});
}
public OutpostRepository getRepository()

View File

@ -12,6 +12,7 @@ import com.google.common.collect.Lists;
import mineplex.core.common.util.Callback;
import mineplex.core.common.util.UtilWorld;
import mineplex.core.database.MinecraftRepository;
import mineplex.game.clans.analytics.Profiler;
import mineplex.game.clans.clans.ClanInfo;
import mineplex.game.clans.clans.siege.outpost.OutpostManager;
import mineplex.game.clans.clans.siege.outpost.OutpostState;
@ -33,7 +34,8 @@ public class OutpostRepository extends MinecraftRepository
+ "outpostType TINYINT NOT NULL,"
+ "ownerClan INT NOT NULL,"
+ "timeSpawned LONG,"
+ "outpostState TINYINT NOT NULL);";
+ "outpostState TINYINT NOT NULL,"
+ "PRIMARY KEY (uniqueId));";
private static final String GET_OUTPOST_BY_ID = "SELECT * FROM clansOutposts WHERE uniqueId=?;";
private static final String GET_OUTPOST_BY_CLAN = "SELECT * FROM clansOutposts WHERE ownerClan=?;";

View File

@ -3,7 +3,9 @@ package mineplex.game.clans.clans.siege.repository;
import java.sql.ResultSet;
import java.sql.SQLException;
import java.sql.Timestamp;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import org.bukkit.plugin.java.JavaPlugin;
@ -22,8 +24,6 @@ import mineplex.serverdata.database.column.ColumnVarChar;
public class SiegeWeaponRepository extends MinecraftRepository
{
private SiegeManager _manager;
private static final String CREATE = "CREATE TABLE IF NOT EXISTS clansSiegeWeapons (uniqueId INT NOT NULL,"
+ "serverId INT NOT NULL,"
+ "location VARCHAR(30),"
@ -31,115 +31,170 @@ public class SiegeWeaponRepository extends MinecraftRepository
+ "weaponType TINYINT NOT NULL,"
+ "health INT NOT NULL,"
+ "yaw INT NOT NULL,"
+ "lastFired LONG);";
+ "lastFired LONG,"
+ "entities VARCHAR(200),"
+ "PRIMARY KEY (uniqueId));";
private static final String GET_WEAPON_BY_ID = "SELECT * FROM clansSiegeWeapons WHERE uniqueId=?;";
private static final String GET_WEAPONS_BY_CLAN = "SELECT * FROM clansSiegeWeapons WHERE ownerClan=?;";
private static final String GET_WEAPONS_BY_SERVER = "SELECT * FROM clansSiegeWeapons WHERE serverId=?;";
private static final String UPDATE_WEAPON = "UPDATE clansSiegeWeapons SET health=?,yaw=?,lastFired=? WHERE uniqueId=?;";
private static final String INSERT_WEAPON = "INSERT INTO clansSiegeWeapons VALUES (?, ?, ?, ?, ?, ?, ?, ?);";
private static final String INSERT_WEAPON = "INSERT INTO clansSiegeWeapons VALUES (?, ?, ?, ?, ?, ?, ?, ?, ?);";
private static final String DELETE_WEAPON = "DELETE FROM clansSiegeWeapons WHERE uniqueId=?;";
public SiegeWeaponRepository(JavaPlugin plugin, SiegeManager manager)
public SiegeWeaponRepository(JavaPlugin plugin)
{
super(plugin, DBPool.getAccount());
_manager = manager;
}
public void deleteWeapon(final int uniqueId)
{
executeUpdate(DELETE_WEAPON, new ColumnInt("uniqueId", uniqueId));
System.out.println("Siege Repo> Deleting weapon " + uniqueId);
SiegeManager.Instance.runAsync(() ->
executeUpdate(DELETE_WEAPON, new ColumnInt("uniqueId", uniqueId))
);
}
public void getWeaponById(final int uniqueId, final Callback<SiegeWeaponToken> callback)
{
executeQuery(GET_WEAPON_BY_ID, resultSet -> {
SiegeWeaponToken token = new SiegeWeaponToken();
resultSet.next();
load(token, resultSet);
callback.run(token);
}, new ColumnInt("uniqueId", uniqueId));
SiegeManager.Instance.runAsync(() ->
executeQuery(GET_WEAPON_BY_ID, resultSet -> {
SiegeWeaponToken token = new SiegeWeaponToken();
resultSet.next();
load(token, resultSet);
callback.run(token);
}, new ColumnInt("uniqueId", uniqueId))
);
}
public void getWeaponsByServer(final int serverId, final Callback<List<SiegeWeaponToken>> callback)
{
executeQuery(GET_WEAPONS_BY_SERVER, resultSet -> {
List<SiegeWeaponToken> tokens = Lists.newArrayList();
while (resultSet.next())
{
SiegeWeaponToken token = new SiegeWeaponToken();
SiegeManager.Instance.runAsync(() ->
executeQuery(GET_WEAPONS_BY_SERVER, resultSet -> {
List<SiegeWeaponToken> tokens = Lists.newArrayList();
load(token, resultSet);
while (resultSet.next())
{
SiegeWeaponToken token = new SiegeWeaponToken();
load(token, resultSet);
tokens.add(token);
}
tokens.add(token);
}
callback.run(tokens);
}, new ColumnInt("serverId", serverId));
callback.run(tokens);
}, new ColumnInt("serverId", serverId))
);
}
public void getWeaponsByClan(final ClanInfo clan, final Callback<List<SiegeWeaponToken>> callback)
{
executeQuery(GET_WEAPONS_BY_CLAN, resultSet -> {
List<SiegeWeaponToken> tokens = Lists.newArrayList();
while (resultSet.next())
{
SiegeWeaponToken token = new SiegeWeaponToken();
SiegeManager.Instance.runAsync(() ->
executeQuery(GET_WEAPONS_BY_CLAN, resultSet -> {
List<SiegeWeaponToken> tokens = Lists.newArrayList();
load(token, resultSet);
while (resultSet.next())
{
SiegeWeaponToken token = new SiegeWeaponToken();
load(token, resultSet);
tokens.add(token);
}
tokens.add(token);
}
callback.run(tokens);
}, new ColumnInt("ownerClan", clan.getId()));
callback.run(tokens);
}, new ColumnInt("ownerClan", clan.getId()))
);
}
private void load(SiegeWeaponToken token, ResultSet columns) throws SQLException
{
token.UniqueId = columns.getInt("uniqueId");
token.Location = UtilWorld.strToLoc(columns.getString("location"));
token.OwnerClan = _manager.getClansManager().getClanUtility().getClanById(columns.getInt("ownerClan"));
token.OwnerClan = SiegeManager.Instance.getClansManager().getClanUtility().getClanById(columns.getInt("ownerClan"));
token.WeaponType = columns.getByte("weaponType");
token.Health = columns.getShort("health");
token.Yaw = columns.getShort("yaw");
token.LastFired = columns.getTimestamp("lastFired").getTime();
token.Entities = decodeEntities(columns.getString("entities"));
System.out.println("Siege Repo> Loaded weapon " + token.UniqueId);
}
public void updateWeapon(SiegeWeaponToken token)
{
executeUpdate(UPDATE_WEAPON,
new ColumnInt("health", token.Health),
new ColumnInt("yaw", token.Yaw),
new ColumnTimestamp("lastFired", new Timestamp(token.LastFired)),
new ColumnInt("uniqueId", token.UniqueId));
System.out.println("Siege Repo> Updating weapon " + token.UniqueId);
SiegeManager.Instance.runAsync(() ->
executeUpdate(UPDATE_WEAPON,
new ColumnInt("health", token.Health),
new ColumnInt("yaw", token.Yaw),
new ColumnTimestamp("lastFired", new Timestamp(token.LastFired)),
new ColumnInt("uniqueId", token.UniqueId))
);
}
public void insertWeapon(SiegeWeaponToken token)
{
executeUpdate(INSERT_WEAPON,
new ColumnInt("uniqueId", token.UniqueId),
new ColumnInt("serverId", _manager.getClansManager().getServerId()),
new ColumnVarChar("location", 30, UtilWorld.locToStr(token.Location)),
new ColumnInt("ownerClan", token.OwnerClan.getId()),
new ColumnInt("weaponType", token.WeaponType),
new ColumnInt("health", token.Health),
new ColumnInt("yaw", token.Yaw),
new ColumnTimestamp("lastFired", new Timestamp(token.LastFired)));
System.out.println("Siege Repo> Inserting new weapon " + token.UniqueId);
SiegeManager.Instance.runAsync(() ->
executeUpdate(INSERT_WEAPON,
new ColumnInt("uniqueId", token.UniqueId),
new ColumnInt("serverId", SiegeManager.Instance.getClansManager().getServerId()),
new ColumnVarChar("location", 30, UtilWorld.locToStr(token.Location)),
new ColumnInt("ownerClan", token.OwnerClan.getId()),
new ColumnInt("weaponType", token.WeaponType),
new ColumnInt("health", token.Health),
new ColumnInt("yaw", token.Yaw),
new ColumnTimestamp("lastFired", new Timestamp(token.LastFired)),
new ColumnVarChar("entities", 100, encodeEntities(token.Entities)))
);
}
private String encodeEntities(Map<String, String> entities)
{
StringBuilder builder = new StringBuilder();
int l = 0;
for (String name : entities.keySet())
{
if (l != 0)
{
builder.append(",");
}
builder.append(name + ":" + entities.get(name));
l++;
}
return builder.toString();
}
private Map<String, String> decodeEntities(String data)
{
Map<String, String> map = new HashMap<>();
for (String entries : data.split(","))
{
map.put(entries.split(":")[0], entries.split(":")[1]);
}
return map;
}
@Override
protected void initialize()
{
executeUpdate(CREATE);
SiegeManager.Instance.runAsync(() ->
executeUpdate(CREATE)
);
}
@Override

View File

@ -1,5 +1,8 @@
package mineplex.game.clans.clans.siege.repository.tokens;
import java.util.Map;
import java.util.UUID;
import org.bukkit.Location;
import mineplex.game.clans.clans.ClanInfo;
@ -13,4 +16,6 @@ public class SiegeWeaponToken
public int Health;
public int Yaw;
public long LastFired;
public Map<String, String> Entities;
}

View File

@ -1,17 +1,17 @@
package mineplex.game.clans.clans.siege.weapon;
import java.util.Map.Entry;
import org.bukkit.Location;
import org.bukkit.Material;
import org.bukkit.Sound;
import org.bukkit.entity.ArmorStand;
import org.bukkit.entity.EntityType;
import org.bukkit.entity.Player;
import org.bukkit.entity.Slime;
import org.bukkit.event.EventHandler;
import org.bukkit.event.inventory.InventoryClickEvent;
import org.bukkit.event.inventory.InventoryType;
import org.bukkit.inventory.ItemStack;
import org.bukkit.metadata.FixedMetadataValue;
import org.bukkit.potion.PotionEffect;
import org.bukkit.potion.PotionEffectType;
import org.bukkit.util.Vector;
@ -20,6 +20,7 @@ import com.google.common.collect.Lists;
import mineplex.core.common.util.C;
import mineplex.core.common.util.F;
import mineplex.core.common.util.UtilCollections;
import mineplex.core.common.util.UtilEnt;
import mineplex.core.common.util.UtilMath;
import mineplex.core.common.util.UtilParticle;
@ -40,13 +41,15 @@ import mineplex.game.clans.clans.siege.weapon.util.WeaponStateInfo;
public class Cannon extends SiegeWeapon
{
public static final ItemStack CANNON_ITEM = new ItemBuilder(Material.SPONGE, 1).setData((byte) 1).setRawTitle(C.cBlue + "Cannon").build();
public static final ItemStack CANNON_ITEM = new ItemBuilder(Material.SPONGE, 1).setData((byte) 1).setRawTitle(C.Reset + C.cBlue + "Cannon").build();
private int _firepower = 1;
public Cannon(SiegeManager siegeManager, SiegeWeaponToken token)
{
super(1400, "Cannon", token, siegeManager.getClansManager(), siegeManager);
super(300, "Cannon", token, siegeManager.getClansManager(), siegeManager);
System.out.println("Siege> Loading Cannon from token " + token.UniqueId);
setBoundingBox(1);
@ -247,6 +250,10 @@ public class Cannon extends SiegeWeapon
event.setCancelled(true);
}
else if (event.getSlot() != _ammunitionSlot)
{
event.setCancelled(true);
}
}
private void updateInventory()
@ -254,22 +261,16 @@ public class Cannon extends SiegeWeapon
_inventory.setItem(0, new ItemBuilder(Material.LEVER).setTitle(C.cRed + "-1 Firepower").build());
_inventory.setItem(1, new ItemBuilder(Material.SULPHUR).setTitle(C.cWhiteB + "Firepower: " + C.cYellow + _firepower).build());
_inventory.setItem(2, new ItemBuilder(Material.LEVER).setTitle(C.cGreen + "+1 Firepower").build());
for (int slot : UtilCollections.newList(Integer.valueOf(3), Integer.valueOf(5), Integer.valueOf(6), Integer.valueOf(7), Integer.valueOf(8)))
{
_inventory.setItem(slot, new ItemBuilder(Material.COBBLESTONE).setTitle(C.cGray + "Cannon Wall").build());
}
}
protected boolean CustomInventoryValid(int slot, ItemStack item)
{
return slot == 0 || slot == 1 || slot == 2;
}
protected void ResetEntities()
{
removeEntity("Filler_1");
removeEntity("PLAYERMOUNT");
removeEntity("WEAPON");
loadEntities();
getEntity("PLAYERMOUNT").setPassenger(_rider);
return true; // all slots are now filled; slot == 0 || slot == 1 || slot == 2;
}
private void loadEntities()
@ -306,30 +307,26 @@ public class Cannon extends SiegeWeapon
addEntity(weapon, "WEAPON");
weapon.setMetadata("WeaponId", new FixedMetadataValue(_siegeManager.getPlugin(), Integer.valueOf(_uniqueId)));
insert();
}
@Override
public void FindEntities()
{
Lists.newArrayList(_location.getChunk().getEntities())
.stream()
.filter(entity -> entity.getType().equals(EntityType.ARMOR_STAND))
.filter(entity -> entity.hasMetadata("WeaponId"))
.filter(entity -> entity.getMetadata("WeaponId").get(0).asInt() == _uniqueId)
.filter(entity -> entity.getPassenger() != null)
.filter(entity -> entity.getPassenger().getPassenger() != null)
.limit(1l)
.forEach(entity -> {
addEntity(entity, "WEAPON");
addEntity(entity.getPassenger(), "Filler_1");
addEntity(entity.getPassenger().getPassenger(), "PLAYERMOUNT");
});
Lists.newArrayList(_location.getWorld().getEntities())
.forEach(entity -> {
for (Entry<String, String> entry : _loadedToken.Entities.entrySet())
{
if (entity.getUniqueId().toString().equals(entry.getValue()))
{
addEntity(entity, entry.getKey());
}
}
});
if (getEntity("WEAPON") == null || getEntity("Filler_1") == null || getEntity("PLAYERMOUNT") == null)
{
System.out.println("[Cannon] Could not find all entities, killing.");
kill();
}
}
@ -372,17 +369,6 @@ public class Cannon extends SiegeWeapon
protected void handleLeftClick(Player player)
{
if (_rider == null && _ownerClan.isMember(player))
{
UtilPlayer.message(player, F.main("Clans", "You picked up your Cannon."));
player.getInventory().addItem(CANNON_ITEM);
kill();
return;
}
super.handleLeftClick(player);
}

View File

@ -1,330 +0,0 @@
package mineplex.game.clans.clans.siege.weapon;
import org.bukkit.Location;
import org.bukkit.Material;
import org.bukkit.Sound;
import org.bukkit.entity.ArmorStand;
import org.bukkit.entity.Entity;
import org.bukkit.entity.EntityType;
import org.bukkit.entity.Slime;
import org.bukkit.event.inventory.InventoryType;
import org.bukkit.inventory.ItemStack;
import org.bukkit.metadata.FixedMetadataValue;
import org.bukkit.potion.PotionEffect;
import org.bukkit.potion.PotionEffectType;
import org.bukkit.util.Vector;
import com.google.common.collect.Lists;
import mineplex.core.common.util.C;
import mineplex.core.common.util.F;
import mineplex.core.common.util.UtilEnt;
import mineplex.core.common.util.UtilParticle;
import mineplex.core.common.util.UtilParticle.ParticleType;
import mineplex.core.common.util.UtilParticle.ViewDist;
import mineplex.core.common.util.UtilPlayer;
import mineplex.core.common.util.UtilServer;
import mineplex.core.common.util.UtilTime;
import mineplex.core.itemstack.ItemBuilder;
import mineplex.game.clans.clans.ClanInfo;
import mineplex.game.clans.clans.siege.SiegeManager;
import mineplex.game.clans.clans.siege.outpost.Outpost;
import mineplex.game.clans.clans.siege.repository.tokens.SiegeWeaponToken;
import mineplex.game.clans.clans.siege.weapon.projectile.ProjectileAttributes;
import mineplex.game.clans.clans.siege.weapon.projectile.WeaponProjectile;
import mineplex.game.clans.clans.siege.weapon.util.AccessRule;
import mineplex.game.clans.clans.siege.weapon.util.AccessType;
import mineplex.game.clans.clans.siege.weapon.util.WeaponStateInfo;
public class Catapult extends SiegeWeapon
{
// public static final ItemStack CATAPULT_ITEM = new ItemBuilder(Material.GOLD_BLOCK, 1).setRawTitle(C.cBlue + "Catapult").setLore(C.cWhite + "AWHHH YEAH!!!").build();
public Catapult(SiegeManager siegeManager, SiegeWeaponToken token)
{
super(1400, "Catapult", token, siegeManager.getClansManager(), siegeManager);
setBoundingBox(3, 0);
setStateInfo("Unloaded", new WeaponStateInfo(Material.PACKED_ICE, (byte) 0));
setStateInfo("Loaded", new WeaponStateInfo(Material.ENDER_PORTAL_FRAME, (byte) 0));
setStateInfo("Fired", new WeaponStateInfo(Material.LAPIS_BLOCK, (byte) 0));
setFirepowerType(Material.FIREBALL);
setAmmunitionType(Material.COBBLESTONE);
setFirepowerSlots(Integer.valueOf(1), Integer.valueOf(3), Integer.valueOf(5), Integer.valueOf(7));
setMaximumFirepowerPerSlot(3);
setAmmunitionSlot(4);
setMaximumAmmunitionPerSlot(1);
setProjectileAttributes(new ProjectileAttributes().setFallingBlock().setFallingBlockType(Material.TNT).setDoCrater().craterSize(3).craterChanceOfAir(1.3d));
_invertRotation = true;
_baseDamage = 550;
_rotSpeed = 60.0f;
setFireRule(new AccessRule(AccessType.LCLICK_BB, player -> {
if (!isRiding(player))
{
return false;
}
if (!_ownerClan.isMember(player))
{
UtilPlayer.message(player, F.main("Clans", "This Catapult is not owned by your Clan."));
return false;
}
if(_clans.getPvpTimer().hasTimer(player)) {
UtilPlayer.message(player, F.main("Clans", "You cannot fire a catapult whilst on PvPTimer"));
return false;
}
if (!canBeFired())
{
UtilPlayer.message(player, F.main("Clans", "Catapult is not loaded correctly."));
return false;
}
if (System.currentTimeMillis() - _lastFired < 20000)
{
UtilPlayer.message(player, F.main("Clans", "Catapult is cooling down (" + F.time(UtilTime.MakeStr(20000 - (System.currentTimeMillis() - _lastFired))) + ")"));
return false;
}
return true;
}));
enableInventory(UtilServer.getServer().createInventory(null, InventoryType.DISPENSER, C.cDAquaB + _name), new AccessRule(AccessType.RCLICK_BB, player -> player.equals(getRider())));
setRideable(new AccessRule(AccessType.RCLICK_BB, player -> {
if (!_ownerClan.isMember(player))
{
UtilPlayer.message(player, F.main("Clans", "This Catapult is not owned by your Clan."));
return false;
}
if (getRider() != null && !getRider().equals(player))
{
UtilPlayer.message(player, F.main("Clans", "Someone is already riding this Catapult."));
return false;
}
if(_clans.getPvpTimer().hasTimer(player)) {
UtilPlayer.message(player, F.main("Clans", "You cannot sit in a catapult whilst on PvPTimer"));
return false;
}
return !player.equals(getRider());
}));
}
public Catapult(Location location, ClanInfo clan, SiegeManager siegeManager)
{
super(1, location, 2500, "Catapult", clan, clan.Clans, siegeManager);
setBoundingBox(3, 0);
setStateInfo("Unloaded", new WeaponStateInfo(Material.PACKED_ICE, (byte) 0));
setStateInfo("Loaded", new WeaponStateInfo(Material.ENDER_PORTAL_FRAME, (byte) 0));
setStateInfo("Fired", new WeaponStateInfo(Material.LAPIS_BLOCK, (byte) 0));
loadEntities();
setFirepowerType(Material.FIREBALL);
setAmmunitionType(Material.COBBLESTONE);
setFirepowerSlots(Integer.valueOf(1), Integer.valueOf(3), Integer.valueOf(5), Integer.valueOf(7));
setMaximumFirepowerPerSlot(3);
setAmmunitionSlot(4);
setMaximumAmmunitionPerSlot(1);
setProjectileAttributes(new ProjectileAttributes().setFallingBlock().setFallingBlockType(Material.TNT).setDoCrater().craterSize(3).craterChanceOfAir(1.3d));
_baseDamage = 550;
_rotSpeed = 60.0f;
setFireRule(new AccessRule(AccessType.LCLICK_BB, player -> {
if (!isRiding(player))
{
return false;
}
if (!_ownerClan.isMember(player))
{
UtilPlayer.message(player, F.main("Clans", "This Catapult is not owned by your Clan."));
return false;
}
if(_clans.getPvpTimer().hasTimer(player)) {
UtilPlayer.message(player, F.main("Clans", "You cannotfire a catapult whilst on PvPTimer"));
return false;
}
if (!canBeFired())
{
UtilPlayer.message(player, F.main("Clans", "Catapult is not loaded correctly."));
return false;
}
if (System.currentTimeMillis() - _lastFired < 20000)
{
UtilPlayer.message(player, F.main("Clans", "Catapult is cooling down (" + F.time(UtilTime.MakeStr(20000 - (System.currentTimeMillis() - _lastFired))) + ")"));
return false;
}
return true;
}));
enableInventory(UtilServer.getServer().createInventory(null, InventoryType.DISPENSER, C.cDAquaB + _name), new AccessRule(AccessType.RCLICK_BB, player -> player.equals(getRider())));
setRideable(new AccessRule(AccessType.RCLICK_BB, player -> {
if (!_ownerClan.isMember(player))
{
UtilPlayer.message(player, F.main("Clans", "This Catapult is not owned by your Clan."));
return false;
}
if (getRider() != null && !getRider().equals(player))
{
UtilPlayer.message(player, F.main("Clans", "Someone is already riding this Catapult."));
return false;
}
if(_clans.getPvpTimer().hasTimer(player)) {
UtilPlayer.message(player, F.main("Clans", "You cannot sit in a cannon whilst on PvPTimer"));
return false;
}
return !player.equals(getRider());
}));
}
private void loadEntities()
{
Slime filler = _location.getWorld().spawn(_location, Slime.class);
UtilEnt.silence(filler, true);
UtilEnt.Vegetate(filler);
filler.setSize(-1);
filler.addPotionEffect(new PotionEffect(PotionEffectType.INVISIBILITY, 99999999, 1, true, false));
addEntity(filler, "Filler_1");
Slime playerMount = _location.getWorld().spawn(_location, Slime.class);
UtilEnt.silence(playerMount, true);
UtilEnt.Vegetate(playerMount);
playerMount.setSize(-1);
playerMount.addPotionEffect(new PotionEffect(PotionEffectType.INVISIBILITY, 99999999, 1, true, false));
getEntity("Filler_1").setPassenger(playerMount);
addEntity(playerMount, "PLAYERMOUNT");
ArmorStand weapon = _location.getWorld().spawn(_location.clone().add(.5, 0, .5), ArmorStand.class);
UtilEnt.setFakeHead(weapon, true);
weapon.teleport(_location);
weapon.setVisible(false);
weapon.setGravity(false);
weapon.setPassenger(getEntity("Filler_1"));
addEntity(weapon, "WEAPON");
weapon.setMetadata("WeaponId", new FixedMetadataValue(_siegeManager.getPlugin(), Integer.valueOf(_uniqueId)));
}
@Override
public void FindEntities()
{
Lists.newArrayList(_location.getChunk().getEntities())
.stream()
.filter(entity -> entity.getType().equals(EntityType.ARMOR_STAND))
.filter(entity -> entity.hasMetadata("WeaponId"))
.filter(entity -> entity.getMetadata("WeaponId").get(0).asInt() == _uniqueId)
.filter(entity -> entity.getPassenger() != null)
.filter(entity -> entity.getPassenger().getPassenger() != null)
.limit(1l)
.forEach(entity -> {
addEntity(entity, "WEAPON");
addEntity(entity.getPassenger(), "Filler_1");
addEntity(entity.getPassenger().getPassenger(), "PLAYERMOUNT");
});
if (getEntity("WEAPON") == null || getEntity("Filler_1") == null || getEntity("PLAYERMOUNT") == null)
{
kill();
}
}
@Override
public void CustomFire(WeaponProjectile projectile)
{
projectile.setLocation(projectile.getLocation().add(.0, 2.7, .0));
UtilServer.getServer().getOnlinePlayers().forEach(player -> player.playSound(projectile.getLocation(), Sound.BAT_TAKEOFF, 2.f, .45f));
}
@Override
public String GetNextState()
{
if (System.currentTimeMillis() - _lastFired < 4500)
{
return "Fired";
}
if (getAmmunition() > 0)
{
return "Loaded";
}
return "Unloaded";
}
@Override
protected void CustomTick()
{
if (getProjectile() != null)
{
UtilParticle.PlayParticleToAll(ParticleType.LARGE_SMOKE, getProjectile().getLocation().add(0, .5, 0), new Vector(0, 0, 0), .1f, 3, ViewDist.MAX);
}
}
@Override
protected double[] GetProjectileVelocity()
{
int firepower = getPowerLevel();
double hMult = 0;
double yAdd = 0;
if (firepower == 1)
{
hMult = 0.6;
yAdd = 0.8;
}
else if (firepower == 2)
{
hMult = 1;
yAdd = 1.2;
}
else if (firepower >= 3)
{
hMult = 1.5;
yAdd = 1.35;
}
return new double[] { hMult, yAdd };
}
}

View File

@ -1,5 +1,8 @@
package mineplex.game.clans.clans.siege.weapon;
import java.util.HashMap;
import java.util.UUID;
import org.apache.commons.lang.Validate;
import org.bukkit.Location;
import org.bukkit.Material;
@ -15,6 +18,7 @@ import org.bukkit.event.block.BlockBreakEvent;
import org.bukkit.event.block.BlockPlaceEvent;
import org.bukkit.event.entity.EntityDamageByEntityEvent;
import org.bukkit.event.entity.EntityDamageEvent;
import org.bukkit.event.inventory.ClickType;
import org.bukkit.event.inventory.InventoryCloseEvent;
import org.bukkit.event.player.PlayerArmorStandManipulateEvent;
import org.bukkit.event.player.PlayerInteractAtEntityEvent;
@ -38,6 +42,7 @@ import mineplex.core.common.util.UtilServer;
import mineplex.core.common.util.UtilText;
import mineplex.core.common.util.UtilTextMiddle;
import mineplex.core.hologram.Hologram;
import mineplex.core.recharge.Recharge;
import mineplex.core.updater.UpdateType;
import mineplex.core.updater.event.UpdateEvent;
import mineplex.game.clans.clans.ClanInfo;
@ -65,6 +70,8 @@ public abstract class SiegeWeapon implements Listener
protected final int _maxHealth;
protected final byte _weaponTypeIdentifier;
protected SiegeWeaponToken _loadedToken;
// Managers
protected ClansManager _clans;
protected SiegeManager _siegeManager;
@ -116,7 +123,7 @@ public abstract class SiegeWeapon implements Listener
protected Material _ammunitionType;
protected int _maxAmmunition;
protected NautArrayList<Integer> _firepowerSlots;
protected NautArrayList<Integer> _firepowerSlots = new NautArrayList<>();
protected Material _firepowerType;
protected int _maxFirepowerPerSlot;
@ -129,6 +136,8 @@ public abstract class SiegeWeapon implements Listener
{
_weaponTypeIdentifier = token.WeaponType;
_loadedToken = token;
_uniqueId = token.UniqueId;
_siegeManager = siegeManager;
@ -144,6 +153,16 @@ public abstract class SiegeWeapon implements Listener
_infoHologram = new Hologram(ClansManager.getInstance().getHologramManager(), _location.clone().add(.5, 3, .5), _name + " Health", getDisplayHealth());
_infoHologram.start();
_infoHologram.setInteraction((player, type) -> {
if (player.equals(_rider))
{
if (type.equals(ClickType.LEFT))
{
handleLeftClick(player);
}
}
});
UtilServer.RegisterEvents(this);
_clans = clansManager;
@ -174,13 +193,16 @@ public abstract class SiegeWeapon implements Listener
_infoHologram = new Hologram(ClansManager.getInstance().getHologramManager(), _location.clone().add(.5, 3, .5), _name + " Health", getDisplayHealth());
_infoHologram.start();
_siegeManager.getRepository().insertWeapon(toToken());
UtilServer.getPluginManager().registerEvents(this, clansManager.getPlugin());
_clans = clansManager;
}
protected void insert()
{
_siegeManager.getRepository().insertWeapon(toToken());
}
protected int calculateDamage(Player player)
{
ItemStack stack = player.getItemInHand();
@ -341,19 +363,23 @@ public abstract class SiegeWeapon implements Listener
public void kill()
{
CustomCleanup();
System.out.println("Killing: " + this.getClass().getSimpleName() + " [" + _uniqueId + "]");
_comprisedOf.forEach(Entity::remove);
_entityMapping.clear();
_comprisedOf.clear();
_infoHologram.stop();
if (_collisionBox != null) _collisionBox.Destruct();
_siegeManager.dead(this);
_alive = false;
_siegeManager.runSync(() -> {
CustomCleanup();
_comprisedOf.forEach(Entity::remove);
_entityMapping.clear();
_comprisedOf.clear();
_infoHologram.stop();
if (_collisionBox != null) _collisionBox.Destruct();
_siegeManager.dead(this);
_alive = false;
});
HandlerList.unregisterAll(this);
}
@ -455,13 +481,18 @@ public abstract class SiegeWeapon implements Listener
return;
}
if (!_ownerClan.isMember(player))
if (Recharge.Instance.use(player, "Damage Cannon", 200, false, false))
{
int health = calculateDamage(player);
removeHealth(health);
UtilTextMiddle.display(UtilText.possesive(_ownerClan.getName(), _name), C.cRed + "-" + health, 0, 10, 0, player);
new Hologram(
_siegeManager.getClansManager().getHologramManager(),
_location.clone().add(UtilMath.random(-1, 1),1.4, UtilMath.random(-1, 1)),
3500l,
C.cRed + "-" + health)
.start();
}
}
@ -469,7 +500,6 @@ public abstract class SiegeWeapon implements Listener
protected abstract double[] GetProjectileVelocity();
protected abstract String GetNextState();
protected abstract void FindEntities();
protected void ResetEntities() { return; }
protected void CustomTick() { return; }
protected void CustomOnMount(Player player) { return; }
protected void CustomLeftClick(Player player) { return; }
@ -702,6 +732,11 @@ public abstract class SiegeWeapon implements Listener
@EventHandler
public void onBlockBreak(BlockBreakEvent event)
{
if (!event.getBlock().getLocation().getWorld().equals(_location.getWorld()))
{
return;
}
if (event.getBlock().getLocation().distance(_location) < _boundingBoxSize + 1.65 && event.getBlock().getLocation().getY() <= _location.getY())
{
UtilPlayer.message(event.getPlayer(), F.main("Clans", "You may not break blocks near a Siege Weapon"));
@ -712,6 +747,11 @@ public abstract class SiegeWeapon implements Listener
@EventHandler
public void onBlockPlace(BlockPlaceEvent event)
{
if (!event.getBlock().getLocation().getWorld().equals(_location.getWorld()))
{
return;
}
if (event.getBlock().getLocation().distance(_location) < _boundingBoxSize + 1.65 && event.getBlock().getLocation().getY() <= _location.getY())
{
UtilPlayer.message(event.getPlayer(), F.main("Clans", "You may not place blocks near a Siege Weapon"));
@ -721,6 +761,11 @@ public abstract class SiegeWeapon implements Listener
public boolean inProtection(Block block)
{
if (!block.getLocation().getWorld().equals(_location.getWorld()))
{
return false;
}
return block.getLocation().distance(_location) < _boundingBoxSize + 1.65 && block.getLocation().getY() <= _location.getY() + 2;
}
@ -835,8 +880,29 @@ public abstract class SiegeWeapon implements Listener
token.Location = _location;
token.Health = _health;
token.Yaw = (int) _yaw;
token.Entities = new HashMap<>();
_entityMapping.entrySet().forEach(entry ->
token.Entities.put(entry.getKey(), entry.getValue().getUniqueId().toString())
);
return token;
}
public boolean isPartOf(UUID uniqueId)
{
if (_loadedToken == null)
{
for (Entity entity : _comprisedOf)
{
if (entity.getUniqueId().equals(uniqueId))
return true;
}
return false;
}
return _loadedToken.Entities.values().contains(uniqueId.toString());
}
}

View File

@ -9,9 +9,11 @@ import org.bukkit.Location;
import org.bukkit.Material;
import org.bukkit.block.Block;
import org.bukkit.block.BlockFace;
import org.bukkit.block.Chest;
import org.bukkit.event.EventHandler;
import org.bukkit.event.HandlerList;
import org.bukkit.event.Listener;
import org.bukkit.inventory.ItemStack;
import org.bukkit.util.Vector;
import mineplex.core.common.util.UtilBlock;
@ -143,6 +145,8 @@ public class Crater implements Listener
boolean air = distance <= _airChance || (Math.random() > (distance) / 3.65d);
if (block.getState() instanceof Chest) continue;
if (block.getType() == Material.AIR) continue;
if (air)
@ -183,6 +187,26 @@ public class Crater implements Listener
if (block.getType() == Material.AIR) continue;
if (block.getState() instanceof Chest)
{
Chest chest = (Chest) block.getState();
for (ItemStack item : chest.getBlockInventory().getContents())
{
if (item == null)
{
continue;
}
if (item.getType() == Material.AIR)
{
continue;
}
_origin.getWorld().dropItemNaturally(_origin, item);
}
}
if (
distance > _airChance &&
Math.random() > .75 &&

View File

@ -53,13 +53,9 @@ public class WeaponProjectile implements Listener
@EventHandler(priority = EventPriority.HIGHEST)
public void onTntExplode(EntityExplodeEvent event)
{
if (!_attributes._isPrimedTnt)
{
return;
}
if (event.getEntity().equals(_projectileEntity))
{
((TNTPrimed) event.getEntity()).setFuseTicks(60);
event.setCancelled(true);
}
}
@ -82,12 +78,20 @@ public class WeaponProjectile implements Listener
return;
}
if (_projectileEntity.isDead())
{
die();
return;
}
if (_dead || _projectileEntity == null)
{
die();
return;
}
((TNTPrimed) _projectileEntity).setFuseTicks(60);
if ((Math.abs(_projectileEntity.getVelocity().getX()) < 0.01
|| Math.abs(_projectileEntity.getVelocity().getZ()) < 0.01)
&& UtilBlock.getInRadius(_projectileEntity.getLocation(), 2)

View File

@ -17,6 +17,7 @@ import org.bukkit.event.block.BlockDamageEvent;
import org.bukkit.event.player.PlayerInteractEvent;
import mineplex.core.common.util.UtilBlock;
import mineplex.core.common.util.UtilCollections;
import mineplex.core.common.util.UtilServer;
import mineplex.core.updater.UpdateType;
import mineplex.core.updater.event.UpdateEvent;
@ -95,12 +96,12 @@ public class BarrierCollisionBox implements Listener
private void onLeftClick(Location location, Player player)
{
_leftClickListeners.forEach(listener -> listener.accept(location, player));
UtilCollections.ForEach(_leftClickListeners, listener -> listener.accept(location, player));
}
private void onRightClick(Location location, Player player)
{
_rightClickListeners.forEach(listener -> listener.accept(location, player));
UtilCollections.ForEach(_rightClickListeners, listener -> listener.accept(location, player));
}
private void resetBlocks()

View File

@ -53,7 +53,7 @@ public class RunedPickaxe extends RareItem
RunedPickaxe pick = (RunedPickaxe) gear.getWeapon();
if (!pick._enabled && !UtilTime.elapsed(pick._instamineEnabled, 12000))
if (pick._enabled && !UtilTime.elapsed(pick._instamineEnabled, 12000))
{
UtilTextBottom.displayProgress("Instant mine", (((double) (((double) System.currentTimeMillis()) - ((double) pick._instamineEnabled))) / 12000D), null, true, player);
}
@ -94,7 +94,7 @@ public class RunedPickaxe extends RareItem
{
event.getBlock().breakNaturally();
event.getBlock().getWorld().playEffect(event.getBlock().getLocation(), Effect.TILE_BREAK, event.getBlock().getType(), 10);
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);
}

View File

@ -30,6 +30,7 @@ import mineplex.core.common.util.F;
import mineplex.core.common.util.UtilFirework;
import mineplex.core.common.util.UtilInv;
import mineplex.core.common.util.UtilItem;
import mineplex.core.common.util.UtilPlayer;
import mineplex.core.common.util.UtilServer;
import mineplex.core.common.util.UtilTextMiddle;
import mineplex.core.donation.DonationManager;
@ -60,9 +61,6 @@ public abstract class Tutorial implements ScoreboardElement, Listener
public static String TUTORIAL_REWARD_TASK = "tatatatatat%sRewardGiven"; //do not change
public static String SKIPPED_TASK = "tatatatata%sSkip";
public static String AllowedMessage = C.cGold + "TutorialAllowedMessage" + C.Reset;
public static String AllowedBypass = C.cBlue + "Tutorial>";
protected final TutorialManager _manager;
protected final GoldManager _goldManager;
protected final ClansManager _clansManager;
@ -307,7 +305,7 @@ public abstract class Tutorial implements ScoreboardElement, Listener
if (_goldReward != -1)
{
_goldManager.addGold(player, _goldReward);
_manager.sendTutorialMsg(player, F.main("Tutorials", "You have been awarded " + F.elem(_goldReward + " Gold") + "."));
UtilPlayer.message(player, F.main("Tutorials", "You have been awarded " + F.elem(_goldReward + " Gold") + "."));
}
if (_gemReward != -1)
@ -315,7 +313,7 @@ public abstract class Tutorial implements ScoreboardElement, Listener
_donationManager.RewardGems(new Callback<Boolean>() {
public void run(Boolean data)
{
_manager.sendTutorialMsg(player, F.main("Tutorials", "You have been awarded " + F.elem(_goldReward + " Gems") + "."));
UtilPlayer.message(player, F.main("Tutorials", "You have been awarded " + F.elem(_goldReward + " Gems") + "."));
}
}, "Clans", player.getName(), player.getUniqueId(), _gemReward);
}
@ -325,7 +323,7 @@ public abstract class Tutorial implements ScoreboardElement, Listener
_donationManager.RewardCoins(new Callback<Boolean>() {
public void run(Boolean data)
{
_manager.sendTutorialMsg(player, F.main("Tutorials", "You have been awarded " + F.elem(_coinReward + " Coins") + "."));
UtilPlayer.message(player, F.main("Tutorials", "You have been awarded " + F.elem(_coinReward + " Coins") + "."));
}
}, "Clans", player.getName(), _clansManager.getClientManager().getAccountId(player), _coinReward);
}

View File

@ -11,6 +11,7 @@ import org.bukkit.plugin.java.JavaPlugin;
import mineplex.core.MiniPlugin;
import mineplex.core.common.util.F;
import mineplex.core.common.util.UtilPlayer;
import mineplex.core.donation.DonationManager;
import mineplex.core.packethandler.IPacketHandler;
import mineplex.core.packethandler.PacketHandler;
@ -44,36 +45,6 @@ public class TutorialManager extends MiniPlugin
_taskManager = taskManager;
// _tutorials.put(TutorialGettingStarted.class, new TutorialGettingStarted(this, playtime, clansManager, donationManager, goldManager, taskManager, packetHandler));
packetHandler.addPacketHandler(new IPacketHandler() {
public void handle(PacketInfo packet)
{
if (packet.getPacket() instanceof PacketPlayOutChat)
{
PacketPlayOutChat chat = (PacketPlayOutChat) packet.getPacket();
if (chat.b == 1)
{
if (chat.a.a().isEmpty())
{
return;
}
if (chat.a.a().get(0).c().equals(ChatColor.stripColor(Tutorial.AllowedMessage)))
{
chat.a.a().remove(0);
}
else if (!chat.a.a().get(0).c().contains(Tutorial.AllowedBypass))
{
if (isInTutorial(packet.getPlayer()))
{
packet.setCancelled(true);
}
}
}
}
}
}, PacketPlayOutChat.class);
}
public void addCommands()
@ -111,8 +82,7 @@ public class TutorialManager extends MiniPlugin
{
getTutorial(player).cancelFor(player);
sendTutorialMsg(player, F.main("Tutorials", "You have cancelled the " + F.elem(getTutorial(player)._displayName + " Tutorial") + "."));
UtilPlayer.message(player, F.main("Tutorials", "You have cancelled the " + F.elem(getTutorial(player)._displayName + " Tutorial") + "."));
_playerTutorials.remove(player.getName());
}
}
@ -129,7 +99,7 @@ public class TutorialManager extends MiniPlugin
{
if (isInTutorial(player))
{
sendTutorialMsg(player, F.main("Tutorials", "You have skipped the " + F.elem(getTutorial(player)._displayName + " Tutorial") + "."));
UtilPlayer.message(player, F.main("Tutorials", "You have skipped the " + F.elem(getTutorial(player)._displayName + " Tutorial") + "."));
getTutorial(player).doSkip(player);
}
}
@ -146,19 +116,6 @@ public class TutorialManager extends MiniPlugin
_playerTutorials.remove(event.getPlayer().getName());
}
public void sendTutorialMsg(Player player, String message)
{
player.sendMessage(Tutorial.AllowedMessage + message);
}
public void sendTutorialMsg(Player player, LinkedList<String> messages)
{
for (String message : messages)
{
sendTutorialMsg(player, message);
}
}
public void finishTutorial(Player player)
{
_playerTutorials.remove(player.getName());

View File

@ -9,6 +9,7 @@ import org.bukkit.event.Listener;
import mineplex.core.common.util.C;
import mineplex.core.common.util.NautArrayList;
import mineplex.core.common.util.UtilPlayer;
import mineplex.core.common.util.UtilServer;
import mineplex.core.common.util.UtilText;
import mineplex.core.common.util.UtilTextMiddle;
@ -155,15 +156,15 @@ public class TutorialTask<T extends Tutorial> implements Listener
if (clan != null) description = description.replace("(clan)", clan.getName());
description = description.replace("{", C.cAqua).replace("}", C.cWhite);
_tutorial._manager.sendTutorialMsg(player, " ");
_tutorial._manager.sendTutorialMsg(player, " ");
_tutorial._manager.sendTutorialMsg(player, " ");
_tutorial._manager.sendTutorialMsg(player, C.cDGreenB + C.Strike + "---------------------------------------------");
_tutorial._manager.sendTutorialMsg(player, " ");
_tutorial._manager.sendTutorialMsg(player, C.cYellowB + "Part " + (_id + 1) + ": " + _displayName);
_tutorial._manager.sendTutorialMsg(player, C.cWhite + " " + description);
_tutorial._manager.sendTutorialMsg(player, " ");
_tutorial._manager.sendTutorialMsg(player, C.cDGreenB + C.Strike + "---------------------------------------------");
UtilPlayer.message(player, " ");
UtilPlayer.message(player, " ");
UtilPlayer.message(player, " ");
UtilPlayer.message(player, C.cDGreenB + C.Strike + "---------------------------------------------");
UtilPlayer.message(player, " ");
UtilPlayer.message(player, C.cYellowB + "Part " + (_id + 1) + ": " + _displayName);
UtilPlayer.message(player, C.cWhite + " " + description);
UtilPlayer.message(player, " ");
UtilPlayer.message(player, C.cDGreenB + C.Strike + "---------------------------------------------");
UtilTextMiddle.display("", getDisplayName(), player);
@ -238,14 +239,14 @@ public class TutorialTask<T extends Tutorial> implements Listener
if (clan != null) finishMessage = finishMessage.replace("(clan)", clan.getName());
finishMessage = finishMessage.replace("{", C.cAqua).replace("}", C.cWhite);
_tutorial._manager.sendTutorialMsg(player, " ");
_tutorial._manager.sendTutorialMsg(player, " ");
_tutorial._manager.sendTutorialMsg(player, " ");
_tutorial._manager.sendTutorialMsg(player, C.cDGreenB + C.Strike + "---------------------------------------------");
_tutorial._manager.sendTutorialMsg(player, " ");
_tutorial._manager.sendTutorialMsg(player, C.cWhite + finishMessage);
_tutorial._manager.sendTutorialMsg(player, " ");
_tutorial._manager.sendTutorialMsg(player, C.cDGreenB + C.Strike + "---------------------------------------------");
UtilPlayer.message(player, " ");
UtilPlayer.message(player, " ");
UtilPlayer.message(player, " ");
UtilPlayer.message(player, C.cDGreenB + C.Strike + "---------------------------------------------");
UtilPlayer.message(player, " ");
UtilPlayer.message(player, C.cWhite + finishMessage);
UtilPlayer.message(player, " ");
UtilPlayer.message(player, C.cDGreenB + C.Strike + "---------------------------------------------");
}
}

View File

@ -5,6 +5,7 @@ import org.bukkit.entity.Player;
import mineplex.core.command.CommandBase;
import mineplex.core.common.Rank;
import mineplex.core.common.util.F;
import mineplex.core.common.util.UtilPlayer;
import mineplex.game.clans.legacytutorial.TutorialManager;
public class SkipTutorialCommand extends CommandBase<TutorialManager>
@ -23,7 +24,7 @@ public class SkipTutorialCommand extends CommandBase<TutorialManager>
}
else
{
Plugin.sendTutorialMsg(caller, F.main("Tutorials", "You are not currently in a tutorial."));
UtilPlayer.message(caller, F.main("Tutorials", "You are not currently in a tutorial."));
}
}

View File

@ -5,6 +5,7 @@ import org.bukkit.event.EventHandler;
import org.bukkit.event.EventPriority;
import mineplex.core.common.util.C;
import mineplex.core.common.util.UtilPlayer;
import mineplex.core.common.util.UtilServer;
import mineplex.core.donation.DonationManager;
import mineplex.core.packethandler.PacketHandler;
@ -14,9 +15,9 @@ import mineplex.core.updater.event.UpdateEvent;
import mineplex.game.clans.clans.ClansManager;
import mineplex.game.clans.clans.playtime.Playtime;
import mineplex.game.clans.economy.GoldManager;
import mineplex.game.clans.spawn.Spawn;
import mineplex.game.clans.legacytutorial.Tutorial;
import mineplex.game.clans.legacytutorial.TutorialManager;
import mineplex.game.clans.spawn.Spawn;
public class TutorialGettingStarted extends Tutorial
{
@ -52,34 +53,34 @@ public class TutorialGettingStarted extends Tutorial
public void onFinished(final Player player)
{
player.resetPlayerTime();
player.teleport(Spawn.getEastSpawn());
player.teleport(Spawn.getNorthSpawn());
}
@Override
protected void onFinishedDelay(Player player)
{
_manager.sendTutorialMsg(player, C.cDGreenB + C.Strike + "---------------------------------------------");
_manager.sendTutorialMsg(player, C.cYellowB + "CONGRATULATIONS");
_manager.sendTutorialMsg(player, " ");
_manager.sendTutorialMsg(player, C.cWhite + "You have completed the Clans basic tutorial and have been awarded " + C.cAqua + "30,000 Gold");
_manager.sendTutorialMsg(player, C.cWhite + "You can now begin your adventure, but do take a moment to read the signs around spawn for more information!");
_manager.sendTutorialMsg(player, C.cDGreenB + C.Strike + "---------------------------------------------");
UtilPlayer.message(player, C.cDGreenB + C.Strike + "---------------------------------------------");
UtilPlayer.message(player, C.cYellowB + "CONGRATULATIONS");
UtilPlayer.message(player, " ");
UtilPlayer.message(player, C.cWhite + "You have completed the Clans basic tutorial and have been awarded " + C.cAqua + "30,000 Gold");
UtilPlayer.message(player, C.cWhite + "You can now begin your adventure, but do take a moment to read the signs around spawn for more information!");
UtilPlayer.message(player, C.cDGreenB + C.Strike + "---------------------------------------------");
}
@Override
public void onBegin(final Player player)
{
_manager.sendTutorialMsg(player, " ");
_manager.sendTutorialMsg(player, " ");
_manager.sendTutorialMsg(player, " ");
_manager.sendTutorialMsg(player, C.cDGreenB + C.Strike + "---------------------------------------------");
_manager.sendTutorialMsg(player, " ");
_manager.sendTutorialMsg(player, C.cYellowB + "Getting Started");
_manager.sendTutorialMsg(player, C.cWhite + " Welcome to Clans! "
UtilPlayer.message(player, " ");
UtilPlayer.message(player, " ");
UtilPlayer.message(player, " ");
UtilPlayer.message(player, C.cDGreenB + C.Strike + "---------------------------------------------");
UtilPlayer.message(player, " ");
UtilPlayer.message(player, C.cYellowB + "Getting Started");
UtilPlayer.message(player, C.cWhite + " Welcome to Clans! "
+ "In this game mode you are able to create a clan, invite your friends to play with you, build a base, and wage war against others! "
+ "When you finish the tutorial, you will be awarded " + C.cAqua + "30,000 Gold");
_manager.sendTutorialMsg(player, " ");
_manager.sendTutorialMsg(player, C.cDGreenB + C.Strike + "---------------------------------------------");
UtilPlayer.message(player, " ");
UtilPlayer.message(player, C.cDGreenB + C.Strike + "---------------------------------------------");
}

View File

@ -4,6 +4,7 @@ import java.util.HashMap;
import org.bukkit.entity.Player;
import org.bukkit.event.EventHandler;
import org.bukkit.event.player.PlayerQuitEvent;
import org.bukkit.plugin.java.JavaPlugin;
import mineplex.core.MiniPlugin;
@ -12,6 +13,8 @@ import mineplex.core.updater.event.UpdateEvent;
public class ClansMessageManager extends MiniPlugin
{
private static final Message BLANK_MESSAGE = new Message("", "", 20);
private HashMap<Player, Message> _playerMessageMap;
public ClansMessageManager(JavaPlugin plugin)
@ -42,4 +45,21 @@ public class ClansMessageManager extends MiniPlugin
_playerMessageMap.put(player, message);
if (displayNow) message.send(player);
}
public void removePlayer(Player player)
{
removePlayer(player, true);
}
public void removePlayer(Player player, boolean sendBlankMessage)
{
BLANK_MESSAGE.send(player);
_playerMessageMap.remove(player);
}
@EventHandler
public void onQuit(PlayerQuitEvent event)
{
removePlayer(event.getPlayer(), false);
}
}

View File

@ -86,12 +86,12 @@ public abstract class ClansShopPage<T extends ShopBase<ClansManager>> extends Sh
public void addShopItem(int index, ClansShopItem item, String displayName)
{
addShopItem(index, item, (byte) 0, displayName, 1);
addShopItem(index, item, (byte) item.getData(), displayName, 1);
}
public void addShopItem(int index, ClansShopItem item)
{
addShopItem(index, item, (byte) 0);
addShopItem(index, item, (byte) item.getData());
}
public void addShopItem(int index, ClansShopItem item, byte data)

View File

@ -57,8 +57,8 @@ public class PvpPage extends ClansShopPage<PvpShop>
addShopItem(33, ClansShopItem.BOW, "Standard Bow");
addShopItem(34, ClansShopItem.ARROW, (byte) 0, "Arrows", 16);
addShopItem(52 - 9, ClansShopItem.CANNON, "Cannon");
addShopItem(53 - 9, ClansShopItem.OUTPOST, "Outpost");
addShopItem(52 - 9, ClansShopItem.CANNON, C.cBlue + "Cannon");
addShopItem(53 - 9, ClansShopItem.OUTPOST, C.cBlue + "Outpost");
addShopItem(51, ClansShopItem.ENCHANTMENT_TABLE, "Class Shop");
addShopItem(52, ClansShopItem.TNT, "TNT");

View File

@ -74,8 +74,8 @@ public class Spawn extends MiniPlugin
super("Clan Spawn Zones", plugin);
_instance = this;
_spawns = new WeightSet<Location>(getEastSpawn(), getWestSpawn());
_shops = new WeightSet<Location>(getNorthTown(), getSouthTown());
_spawns = new WeightSet<Location>(getNorthSpawn(), getSouthSpawn());
_shops = new WeightSet<Location>(getEastTown(), getWestTown());
_clansManager = clansManager;
}
@ -458,34 +458,34 @@ public class Spawn extends MiniPlugin
return Bukkit.getWorld("world");
}
public static Location getSouthTown()
public static Location getWestTown()
{
return new Location(getSpawnWorld(), -6, 70, 295);
return new Location(getSpawnWorld(), -434.5, 63, 8.5);
}
public static Location getSouthTownCenter()
public static Location getWestTownCenter()
{
return new Location(getSpawnWorld(), -6, 70, 312);
return new Location(getSpawnWorld(), -425.5, 72, 8.5);
}
public static Location getNorthTown()
public static Location getEastTown()
{
return new Location(getSpawnWorld(), 2, 66, -325);
return new Location(getSpawnWorld(), 434.5, 63, -8.5);
}
public static Location getNorthTownCenter()
public static Location getEastTownCenter()
{
return new Location(getSpawnWorld(), 7, 75, -311);
return new Location(getSpawnWorld(), 424.5, 72, -8.5);
}
public static Location getEastSpawn()
public static Location getNorthSpawn()
{
return new Location(getSpawnWorld(), 304.5, 210, 6.5);
return new Location(getSpawnWorld(), 8.5, 200, -393.5);
}
public static Location getWestSpawn()
public static Location getSouthSpawn()
{
return new Location(getSpawnWorld(), -295.5, 207, 6.5);
return new Location(getSpawnWorld(), 8.5, 20, 390.5);
}
public boolean isCombatTagged(Player player)
@ -525,14 +525,14 @@ public class Spawn extends MiniPlugin
if (UtilTime.elapsed(_songEastLast, _songEastLength))
{
getEastSpawn().getWorld().playEffect(getEastSpawn(), Effect.RECORD_PLAY, 2258); //Blocks
getNorthSpawn().getWorld().playEffect(getNorthSpawn(), Effect.RECORD_PLAY, 2258); //Blocks
_songEastLast = System.currentTimeMillis();
}
if (UtilTime.elapsed(_songWestLast, _songWestLength))
{
getWestSpawn().getWorld().playEffect(getWestSpawn(), Effect.RECORD_PLAY, 2259); //Chirp
getSouthSpawn().getWorld().playEffect(getSouthSpawn(), Effect.RECORD_PLAY, 2259); //Chirp
_songWestLast = System.currentTimeMillis();
}

View File

@ -37,27 +37,27 @@ public class TravelPage extends ShopPageBase<ClansManager, TravelShop>
@Override
protected void buildPage()
{
addTravelLocation(Spawn.getEastSpawn(), getPlayer().getLocation().distance(Spawn.getEastSpawn()) <= 64 ? Material.SKULL_ITEM : Material.IRON_SWORD, (getPlayer().getLocation().distance(Spawn.getEastSpawn()) <= 64 ? C.cRedB : C.cGreenB) + "East Spawn", new String[] {
addTravelLocation(Spawn.getNorthSpawn(), getPlayer().getLocation().distance(Spawn.getNorthSpawn()) <= 64 ? Material.SKULL_ITEM : Material.IRON_SWORD, (getPlayer().getLocation().distance(Spawn.getNorthSpawn()) <= 64 ? C.cRedB : C.cGreenB) + "East Spawn", new String[] {
C.cWhite + "Spawns are locations where",
C.cWhite + "you respawn after dying.",
" ",
C.cWhite + "You cannot be attacked here,",
C.cWhite + "as they are Safe Zones.",
getPlayer().getLocation().distance(Spawn.getWestSpawn()) <= 64 ? " " : "",
getPlayer().getLocation().distance(Spawn.getEastSpawn()) <= 64 ? C.cRed + "You are already here." : "",
}, 14 + 10, getPlayer().getLocation().distance(Spawn.getEastSpawn()) <= 64 ? (byte) 3 : (byte) 0);
getPlayer().getLocation().distance(Spawn.getSouthSpawn()) <= 64 ? " " : "",
getPlayer().getLocation().distance(Spawn.getNorthSpawn()) <= 64 ? C.cRed + "You are already here." : "",
}, 14 + 10, getPlayer().getLocation().distance(Spawn.getNorthSpawn()) <= 64 ? (byte) 3 : (byte) 0);
addTravelLocation(Spawn.getWestSpawn(), getPlayer().getLocation().distance(Spawn.getWestSpawn()) <= 64 ? Material.SKULL_ITEM : Material.IRON_SWORD, (getPlayer().getLocation().distance(Spawn.getWestSpawn()) <= 64 ? C.cRedB : C.cGreenB) + "West Spawn", new String[] {
addTravelLocation(Spawn.getSouthSpawn(), getPlayer().getLocation().distance(Spawn.getSouthSpawn()) <= 64 ? Material.SKULL_ITEM : Material.IRON_SWORD, (getPlayer().getLocation().distance(Spawn.getSouthSpawn()) <= 64 ? C.cRedB : C.cGreenB) + "West Spawn", new String[] {
C.cWhite + "Spawns are locations where",
C.cWhite + "you respawn after dying.",
" ",
C.cWhite + "You cannot be attacked here,",
C.cWhite + "as they are Safe Zones.",
getPlayer().getLocation().distance(Spawn.getWestSpawn()) <= 64 ? " " : "",
getPlayer().getLocation().distance(Spawn.getWestSpawn()) <= 64 ? C.cRed + "You are already here." : "",
}, 12 + 8, getPlayer().getLocation().distance(Spawn.getWestSpawn()) <= 64 ? (byte) 3 : (byte) 0);
getPlayer().getLocation().distance(Spawn.getSouthSpawn()) <= 64 ? " " : "",
getPlayer().getLocation().distance(Spawn.getSouthSpawn()) <= 64 ? C.cRed + "You are already here." : "",
}, 12 + 8, getPlayer().getLocation().distance(Spawn.getSouthSpawn()) <= 64 ? (byte) 3 : (byte) 0);
addTravelLocation(Spawn.getNorthTown(), ClanIcon.CASTLE.getMaterial(), C.cDGreenB + "North Shop", new String[] {
addTravelLocation(Spawn.getWestTown(), ClanIcon.CASTLE.getMaterial(), C.cDGreenB + "North Shop", new String[] {
C.cWhite + "Shops are locations where you",
C.cWhite + "can buy and sell all sorts of goods.",
" ",
@ -65,7 +65,7 @@ public class TravelPage extends ShopPageBase<ClansManager, TravelShop>
C.cWhite + "as they are Safe Zones.",
}, 4, ClanIcon.CASTLE.getData());
addTravelLocation(Spawn.getSouthTown(), ClanIcon.CASTLE.getMaterial(), C.cDGreenB + "South Shop", new String[] {
addTravelLocation(Spawn.getEastTown(), ClanIcon.CASTLE.getMaterial(), C.cDGreenB + "South Shop", new String[] {
C.cWhite + "Shops are locations where you",
C.cWhite + "can buy and sell all sorts of goods.",
" ",

View File

@ -0,0 +1,14 @@
package mineplex.game.clans.texttutorial;
import mineplex.core.texttutorial.tutorial.Phase;
import mineplex.core.texttutorial.tutorial.Tutorial;
public class ClassTutorial extends Tutorial
{
public ClassTutorial()
{
super("Class Guide", "Clans.TextTutorial.Class", 0);
addPhase(new Phase(null, "Classes", new String[] { "" }));
}
}

View File

@ -3,12 +3,15 @@ package mineplex.game.clans.tutorial;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.Set;
import org.bukkit.Material;
import org.bukkit.Sound;
import org.bukkit.entity.Player;
import org.bukkit.event.EventHandler;
import org.bukkit.event.HandlerList;
import org.bukkit.event.Listener;
import org.bukkit.event.player.PlayerQuitEvent;
import org.bukkit.plugin.java.JavaPlugin;
import mineplex.core.common.objective.Objective;
@ -24,6 +27,7 @@ public abstract class Tutorial implements Listener, ObjectiveListener
private ClansMessageManager _message;
private String _name;
private String _taskIdentifier;
private TutorialWorldManager _worldManager;
// GUI Data
private Material _guiMaterial;
@ -54,9 +58,15 @@ public abstract class Tutorial implements Listener, ObjectiveListener
public void start(Player player)
{
System.out.println(String.format("Tutorial> [%s] started tutorial [%s]", player.getName(), getName()));
_playerSessionMap.put(player, new TutorialSession());
TutorialSession session = new TutorialSession();
if (_worldManager != null)
session.setRegion(_worldManager.getNextRegion());
_playerSessionMap.put(player, session);
// Start at first objective!
setObjective(player, 0);
onStart(player);
}
private void setObjective(Player player, int objective)
@ -93,6 +103,11 @@ public abstract class Tutorial implements Listener, ObjectiveListener
return _guiData;
}
public ClansMessageManager getMessage()
{
return _message;
}
public final String getTaskIdentifier()
{
return "clans.tutorial." + _taskIdentifier;
@ -126,14 +141,54 @@ public abstract class Tutorial implements Listener, ObjectiveListener
private void finish(Player player)
{
_playerSessionMap.remove(player);
removePlayer(player);
System.out.println(String.format("Tutorial> [%s] finished tutorial [%s]", player.getName(), getName()));
onFinish();
onFinish(player);
}
protected abstract void onFinish();
private void quit(Player player)
{
removePlayer(player);
System.out.println(String.format("Tutorial> [%s] quit tutorial [%s]", player.getName(), getName()));
onQuit(player);
}
private void removePlayer(Player player)
{
TutorialSession session = _playerSessionMap.remove(player);
if (session != null)
{
if (session.getRegion() != null)
{
_worldManager.returnRegion(session.getRegion());
}
}
}
public Set<Player> getPlayers()
{
return _playerSessionMap.keySet();
}
/**
* Called when the player finishes the tutorial
*/
protected abstract void onFinish(Player player);
/**
* Called when the player starts the tutorial
*/
protected abstract void onStart(Player player);
/**
* Called when a player quits the tutorial or leaves the game in the tutorial
*/
protected abstract void onQuit(Player player);
public void unregisterAll()
{
@ -152,11 +207,27 @@ public abstract class Tutorial implements Listener, ObjectiveListener
int objectiveIndex = session.getObjectiveIndex();
Objective currentObjective = _objectives.get(objectiveIndex);
lines.add(C.cGoldB + "Current Task (" + (objectiveIndex + 1) + "/" + _objectives.size() + ")");
lines.add(" " + currentObjective.getName());
lines.add(" ");
lines.add("Type /skip to exit tutorial");
currentObjective.addScoreboardLines(player, lines);
}
return lines;
}
public void setWorldManager(TutorialWorldManager worldManager)
{
_worldManager = worldManager;
}
public TutorialRegion getRegion(Player player)
{
return _playerSessionMap.get(player).getRegion();
}
@EventHandler
public void onQuit(PlayerQuitEvent event)
{
if (isInTutorial(event.getPlayer()))
{
quit(event.getPlayer());
}
}
}

View File

@ -2,16 +2,19 @@ package mineplex.game.clans.tutorial;
import java.util.ArrayList;
import java.util.EnumMap;
import java.util.Iterator;
import java.util.List;
import org.bukkit.entity.Player;
import org.bukkit.event.EventHandler;
import org.bukkit.event.HandlerList;
import org.bukkit.event.player.PlayerCommandPreprocessEvent;
import org.bukkit.event.EventPriority;
import org.bukkit.event.player.AsyncPlayerChatEvent;
import org.bukkit.plugin.java.JavaPlugin;
import mineplex.core.MiniPlugin;
import mineplex.core.account.CoreClientManager;
import mineplex.core.chat.Chat;
import mineplex.core.chat.FilterPriority;
import mineplex.core.common.util.F;
import mineplex.core.common.util.UtilPlayer;
import mineplex.core.donation.DonationManager;
@ -20,7 +23,7 @@ import mineplex.core.scoreboard.elements.ScoreboardElement;
import mineplex.game.clans.message.ClansMessageManager;
import mineplex.game.clans.tutorial.command.TutorialCommand;
import mineplex.game.clans.tutorial.gui.TutorialShop;
import mineplex.game.clans.tutorial.tutorials.combat.CombatTutorial;
import mineplex.game.clans.tutorial.tutorials.clans.ClansMainTutorial;
public class TutorialManager extends MiniPlugin implements ScoreboardElement
{
@ -31,7 +34,7 @@ public class TutorialManager extends MiniPlugin implements ScoreboardElement
private EnumMap<TutorialType, Tutorial> _tutorialMap;
private EnumMap<TutorialType, TutorialShop> _shopMap; // Don't need to do anything with shops currently
public TutorialManager(JavaPlugin plugin, CoreClientManager clientManager, DonationManager donationManager)
public TutorialManager(JavaPlugin plugin, CoreClientManager clientManager, DonationManager donationManager, Chat chat)
{
super("Clans Tutorial", plugin);
@ -42,7 +45,28 @@ public class TutorialManager extends MiniPlugin implements ScoreboardElement
_tutorialMap = new EnumMap<TutorialType, Tutorial>(TutorialType.class);
_shopMap = new EnumMap<TutorialType, TutorialShop>(TutorialType.class);
addTutorial(TutorialType.COMBAT, new CombatTutorial(plugin, _clansMessageManager));
addTutorial(TutorialType.MAIN, new ClansMainTutorial(plugin, _clansMessageManager));
chat.AddFilter(event -> {
if (inTutorial(event.getPlayer()))
{
UtilPlayer.message(event.getPlayer(), F.main("Clans", "You are not allowed to speak while in a tutorial."));
return Boolean.TRUE;
}
Iterator<Player> recipients = event.getRecipients().iterator();
while (recipients.hasNext())
{
Player recipient = recipients.next();
if (inTutorial(recipient))
recipients.remove();
}
return Boolean.FALSE;
}, FilterPriority.HIGH);
}
@Override
@ -50,7 +74,7 @@ public class TutorialManager extends MiniPlugin implements ScoreboardElement
{
addCommand(new TutorialCommand(this));
}
private void addTutorial(TutorialType type, Tutorial tutorial)
{
if (_tutorialMap.containsKey(type))

View File

@ -0,0 +1,75 @@
package mineplex.game.clans.tutorial;
import org.bukkit.Location;
import org.bukkit.Material;
import org.bukkit.block.Block;
import mineplex.core.common.block.DataLocationMap;
import mineplex.core.common.block.schematic.Schematic;
public class TutorialRegion
{
private final Schematic _schematic;
private final Location _origin;
private DataLocationMap _locationMap;
protected TutorialRegion(Schematic schematic, Location origin)
{
_origin = origin;
_schematic = schematic;
pasteSchematic();
}
public Location getOrigin()
{
return _origin;
}
public DataLocationMap getLocationMap()
{
return _locationMap;
}
private void pasteSchematic()
{
_locationMap = _schematic.paste(getOrigin());
}
/**
* Clear the schematic area. This shouldn't be needed
*/
@Deprecated
private void clearSchematic()
{
for (int x = 0; x < _schematic.getWidth(); x++)
{
for (int y = 0; y < _schematic.getHeight(); y++)
{
for (int z = 0; z < _schematic.getLength(); z++)
{
Block b = _origin.clone().add(x, y, z).getBlock();
if (b.getType() != Material.AIR)
{
b.setTypeIdAndData(0, (byte) 0, false);
}
}
}
}
}
protected void reset()
{
long start = System.currentTimeMillis();
System.out.println("TutorialRegion starting reset...");
pasteSchematic();
System.out.println("TutorialRegion finished reset! Took " + (System.currentTimeMillis() - start) + "ms");
}
@Override
public String toString()
{
return "TutorialRegion[" + _origin.toString() + "]";
}
}

View File

@ -3,6 +3,7 @@ package mineplex.game.clans.tutorial;
public class TutorialSession
{
private int _objectiveIndex;
private TutorialRegion _region;
public TutorialSession()
{
@ -17,4 +18,14 @@ public class TutorialSession
{
_objectiveIndex = objectiveIndex;
}
public TutorialRegion getRegion()
{
return _region;
}
public void setRegion(TutorialRegion region)
{
_region = region;
}
}

View File

@ -2,5 +2,5 @@ package mineplex.game.clans.tutorial;
public enum TutorialType
{
COMBAT
MAIN
}

View File

@ -0,0 +1,100 @@
package mineplex.game.clans.tutorial;
import java.io.File;
import java.io.IOException;
import java.util.Stack;
import org.bukkit.Bukkit;
import org.bukkit.Difficulty;
import org.bukkit.Location;
import org.bukkit.World;
import org.bukkit.WorldCreator;
import org.bukkit.event.EventHandler;
import org.bukkit.event.player.PlayerCommandPreprocessEvent;
import org.bukkit.plugin.java.JavaPlugin;
import mineplex.core.MiniPlugin;
import mineplex.core.common.block.schematic.Schematic;
import mineplex.core.common.block.schematic.UtilSchematic;
import mineplex.core.common.generator.VoidGenerator;
import mineplex.game.clans.tutorial.TutorialRegion;
public class TutorialWorldManager extends MiniPlugin
{
private final World _tutorialWorld;
private final Schematic _schematic;
private Stack<TutorialRegion> _regionStack;
public TutorialWorldManager(JavaPlugin plugin, String worldName, String schematicName) throws IOException
{
super("Tutorial World", plugin);
log("Creating Tutorial World");
WorldCreator creator = new WorldCreator(worldName);
creator.generator(new VoidGenerator());
_tutorialWorld = Bukkit.createWorld(creator);
_tutorialWorld.setDifficulty(Difficulty.PEACEFUL);
_tutorialWorld.setGameRuleValue("doDaylightCycle", "false");
_tutorialWorld.setTime(6000);
_tutorialWorld.setAutoSave(false);
_tutorialWorld.setAmbientSpawnLimit(0);
_tutorialWorld.setMonsterSpawnLimit(0);
_tutorialWorld.setWaterAnimalSpawnLimit(0);
log("Tutorial World Created!");
log("Loading schematic - " + schematicName);
_schematic = UtilSchematic.loadSchematic(new File(schematicName));
log("Finished loading schematic");
log("Populating Region Stack...");
populateRegionStack();
log("Finished loading Tutorial World Manager!");
}
private void populateRegionStack()
{
_regionStack = new Stack<>();
// Populate the stack with 100 available tutorial regions
for (int x = 0; x < 10; x++)
{
for (int z = 0; z < 10; z++)
{
double xLoc = (x - 5) * 100; // 100x100 regions
double zLoc = (z - 5) * 100;
_regionStack.add(new TutorialRegion(_schematic, new Location(_tutorialWorld, xLoc, 64, zLoc)));
}
}
}
/**
* Get the next TutorialRegion in the stack. This region is prepared and ready for use in a tutorial
* @return
*/
public TutorialRegion getNextRegion()
{
return _regionStack.pop();
}
/**
* Notify the TutorialWorldManager that this TutorialRegion is no longer needed and should be cleaned up.
* The TutorialRegion should not be used after calling this method
*/
public void returnRegion(TutorialRegion region)
{
region.reset();
_regionStack.push(region);
log("Returned " + region.toString());
}
@EventHandler
public void onCommand(PlayerCommandPreprocessEvent event)
{
if (event.getPlayer().getName().contains("Phinary") && event.getMessage().contains("tw"))
{
event.getPlayer().teleport(new Location(_tutorialWorld, 0, 64, 0));
}
}
}

View File

@ -25,14 +25,17 @@ public class StartCommand extends CommandBase<TutorialManager>
return;
}
try
TutorialType type = null;
for (TutorialType check : TutorialType.values())
{
TutorialType type = TutorialType.valueOf(args[0]);
if (check.name().equalsIgnoreCase(args[0]))
type = check;
}
if (type != null)
Plugin.openTutorialMenu(caller, type);
}
catch (IllegalArgumentException ex)
{
UtilPlayer.message(caller, F.main("Tutorial", "Invalid Tutorial: " + F.elem(args[0])));
}
else
UtilPlayer.message(caller, F.main("Tutorial", "Invalid Tutorial " + F.elem(args[0])));
}
}

View File

@ -5,6 +5,8 @@ import org.bukkit.entity.Player;
import mineplex.core.command.CommandBase;
import mineplex.core.command.MultiCommandBase;
import mineplex.core.common.Rank;
import mineplex.core.common.util.F;
import mineplex.core.common.util.UtilPlayer;
import mineplex.game.clans.tutorial.TutorialManager;
public class TutorialCommand extends MultiCommandBase<TutorialManager>
@ -19,6 +21,6 @@ public class TutorialCommand extends MultiCommandBase<TutorialManager>
@Override
protected void Help(Player caller, String[] args)
{
UtilPlayer.message(caller, F.main("Tutorial", "/tutorial start <name>"));
}
}

View File

@ -0,0 +1,126 @@
package mineplex.game.clans.tutorial.tutorials.clans;
import java.io.IOException;
import java.util.List;
import org.bukkit.DyeColor;
import org.bukkit.Location;
import org.bukkit.Material;
import org.bukkit.entity.Player;
import org.bukkit.event.EventHandler;
import org.bukkit.event.block.BlockBreakEvent;
import org.bukkit.event.player.PlayerDropItemEvent;
import org.bukkit.plugin.java.JavaPlugin;
import mineplex.core.common.util.UtilAlg;
import mineplex.core.updater.UpdateType;
import mineplex.core.updater.event.UpdateEvent;
import mineplex.game.clans.clans.ClansManager;
import mineplex.game.clans.message.ClansMessageManager;
import mineplex.game.clans.tutorial.Tutorial;
import mineplex.game.clans.tutorial.TutorialRegion;
import mineplex.game.clans.tutorial.TutorialWorldManager;
import mineplex.game.clans.tutorial.tutorials.clans.objective.ClanObjective;
import mineplex.game.clans.tutorial.tutorials.clans.objective.LeaveSpawnObjective;
public class ClansMainTutorial extends Tutorial
{
public ClansMainTutorial(JavaPlugin plugin, ClansMessageManager message)
{
super(plugin, message, "Clans Tutorial", "Clans.MainTutorial", Material.DIAMOND_SWORD, (byte) 0);
try
{
setWorldManager(new TutorialWorldManager(plugin, "main_tutorial", "schematic/ClansTutorial.schematic"));
}
catch (IOException e)
{
e.printStackTrace();
}
addObjective(new LeaveSpawnObjective(this, plugin));
addObjective(new ClanObjective(this, plugin));
}
@Override
protected void onFinish(Player player)
{
getMessage().removePlayer(player);
}
@Override
protected void onStart(Player player)
{
player.teleport(getRegion(player).getLocationMap().getLocations(DyeColor.RED).get(0));
player.getInventory().clear();
ClansManager.getInstance().getItemMapManager().setMap(player);
}
@Override
protected void onQuit(Player player)
{
}
@EventHandler
public void dropItem(PlayerDropItemEvent event)
{
if (isInTutorial(event.getPlayer()))
{
event.setCancelled(true);
}
}
@EventHandler
public void breakBlock(BlockBreakEvent event)
{
if (isInTutorial(event.getPlayer()))
{
event.setCancelled(true);
}
}
@EventHandler
public void checkInRegion(UpdateEvent event)
{
if (event.getType() != UpdateType.SEC)
return;
for (Player player : getPlayers())
{
TutorialRegion region = getRegion(player);
if (!isInRegion(player.getLocation(), region))
{
player.teleport(getSpawn(region));
}
}
}
public Location getSpawn(TutorialRegion region)
{
return region.getLocationMap().getLocations(DyeColor.RED).get(0);
}
public boolean isInSpawn(Player player)
{
return isInSpawn(player.getLocation(), getRegion(player));
}
public boolean isInSpawn(Location location, TutorialRegion region)
{
List<Location> locs = region.getLocationMap().getLocations(DyeColor.ORANGE);
return UtilAlg.inBoundingBox(location, locs.get(0), locs.get(1));
}
public boolean isInRegion(Player player)
{
return isInRegion(player.getLocation(), getRegion(player));
}
public boolean isInRegion(Location location, TutorialRegion region)
{
List<Location> locs = region.getLocationMap().getLocations(DyeColor.GREEN);
return UtilAlg.inBoundingBox(location, locs.get(0), locs.get(1));
}
}

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.BuildHouseGoal;
import mineplex.game.clans.tutorial.tutorials.clans.objective.goals.ClaimLandGoal;
import mineplex.game.clans.tutorial.tutorials.clans.objective.goals.ClanDetailsGoal;
import mineplex.game.clans.tutorial.tutorials.clans.objective.goals.CreateClanGoal;
public class ClanObjective extends OrderedObjective<ClansMainTutorial>
{
public ClanObjective(ClansMainTutorial clansMainTutorial, JavaPlugin javaPlugin)
{
super(clansMainTutorial, javaPlugin, "Clans", "Create clan with /c create <name>");
addGoal(new CreateClanGoal(this));
addGoal(new ClanDetailsGoal(this));
addGoal(new ClaimLandGoal(this));
addGoal(new BuildHouseGoal(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;
import org.bukkit.entity.Player;
import org.bukkit.event.EventHandler;
import org.bukkit.plugin.java.JavaPlugin;
import mineplex.core.common.objective.SingleObjective;
import mineplex.core.updater.UpdateType;
import mineplex.core.updater.event.UpdateEvent;
import mineplex.game.clans.tutorial.tutorials.clans.ClansMainTutorial;
public class LeaveSpawnObjective extends SingleObjective<ClansMainTutorial>
{
public LeaveSpawnObjective(ClansMainTutorial plugin, JavaPlugin javaPlugin)
{
super(plugin, javaPlugin, "Leave Spawn", "Exit the tutorial spawn area");
}
@Override
protected void customStart(Player player)
{
}
@Override
protected void customLeave(Player player)
{
}
@Override
protected void customFinish(Player player)
{
}
@EventHandler
public void checkRegion(UpdateEvent event)
{
if (event.getType() != UpdateType.FAST)
return;
for (Player player : getActivePlayers())
{
if (!getPlugin().isInSpawn(player))
{
finish(player);
}
}
}
}

View File

@ -0,0 +1,36 @@
package mineplex.game.clans.tutorial.tutorials.clans.objective.goals;
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.PlayerPreClaimTerritoryEvent;
public class ClaimLandGoal extends ObjectiveGoal
{
public ClaimLandGoal(Objective objective)
{
super(objective, "Claim Land", "Claim land with /c claim");
}
@Override
protected void customStart(Player player)
{
}
@Override
protected void customFinish(Player player)
{
}
@EventHandler
public void onClaim(PlayerPreClaimTerritoryEvent event)
{
if (contains(event.getClaimer()))
{
event.setCancelled(true);
finish(event.getClaimer());
}
}
}

View File

@ -0,0 +1,38 @@
package mineplex.game.clans.tutorial.tutorials.clans.objective.goals;
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.ClansCommandExecutedEvent;
public class ClanDetailsGoal extends ObjectiveGoal
{
public ClanDetailsGoal(Objective objective)
{
super(objective, "View Clan Details", "View Clan Details with /c");
}
@Override
protected void customStart(Player player)
{
}
@Override
protected void customFinish(Player player)
{
}
@EventHandler
public void onClanInfo(ClansCommandExecutedEvent event)
{
if (contains(event.getPlayer()))
{
if (event.getCommand().equalsIgnoreCase("info"))
{
finish(event.getPlayer());
}
}
}
}

View File

@ -0,0 +1,37 @@
package mineplex.game.clans.tutorial.tutorials.clans.objective.goals;
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 CreateClanGoal extends ObjectiveGoal
{
public CreateClanGoal(Objective objective)
{
super(objective, "Create a Clan", "Create a Clan");
}
@Override
protected void customStart(Player player)
{
}
@Override
protected void customFinish(Player player)
{
}
@EventHandler
public void onClanCreate(ClanCreatedEvent event)
{
if (contains(event.getFounder()))
{
finish(event.getFounder());
}
}
}

View File

@ -1,28 +0,0 @@
package mineplex.game.clans.tutorial.tutorials.combat;
import org.bukkit.Material;
import org.bukkit.entity.Player;
import org.bukkit.plugin.java.JavaPlugin;
import mineplex.core.common.objective.Objective;
import mineplex.game.clans.message.ClansMessageManager;
import mineplex.game.clans.tutorial.Tutorial;
import mineplex.game.clans.tutorial.tutorials.combat.objectives.CustomizeKitObjective;
import mineplex.game.clans.tutorial.tutorials.combat.objectives.EquipArmorObjective;
public class CombatTutorial extends Tutorial
{
public CombatTutorial(JavaPlugin plugin, ClansMessageManager message)
{
super(plugin, message, "Combat Tutorial", "combat", Material.DIAMOND_SWORD, (byte) 0);
addObjective(new EquipArmorObjective(plugin));
addObjective(new CustomizeKitObjective(plugin));
}
@Override
protected void onFinish()
{
}
}

View File

@ -1,35 +0,0 @@
package mineplex.game.clans.tutorial.tutorials.combat.objectives;
import org.bukkit.entity.Player;
import org.bukkit.plugin.java.JavaPlugin;
import mineplex.core.common.objective.OrderedObjective;
import mineplex.game.clans.tutorial.tutorials.combat.objectives.goals.OpenCustomizationGoal;
public class CustomizeKitObjective extends OrderedObjective
{
public CustomizeKitObjective(JavaPlugin plugin)
{
super(plugin, "Customize Kit", "Customize your kit");
addGoal(new OpenCustomizationGoal(this));
}
@Override
protected void customStart(Player player)
{
super.customStart(player);
}
@Override
protected void customLeave(Player player)
{
}
@Override
protected void customFinish(Player player)
{
}
}

View File

@ -1,77 +0,0 @@
package mineplex.game.clans.tutorial.tutorials.combat.objectives;
import java.util.UUID;
import org.bukkit.Material;
import org.bukkit.entity.Player;
import org.bukkit.event.EventHandler;
import org.bukkit.inventory.ItemStack;
import org.bukkit.plugin.java.JavaPlugin;
import mineplex.core.common.objective.SingleObjective;
import mineplex.core.common.util.UtilPlayer;
import mineplex.core.updater.UpdateType;
import mineplex.core.updater.event.UpdateEvent;
public class EquipArmorObjective extends SingleObjective
{
public EquipArmorObjective(JavaPlugin plugin)
{
super(plugin, "Equip Armor", "Equip Armor");
}
@Override
protected void customStart(Player player)
{
player.getInventory().addItem(new ItemStack(Material.IRON_HELMET));
player.getInventory().addItem(new ItemStack(Material.IRON_CHESTPLATE));
player.getInventory().addItem(new ItemStack(Material.IRON_LEGGINGS));
player.getInventory().addItem(new ItemStack(Material.IRON_BOOTS));
}
@Override
protected void customLeave(Player player)
{
}
@Override
protected void customFinish(Player player)
{
}
@EventHandler
public void checkArmor(UpdateEvent event)
{
if (event.getType() != UpdateType.FAST)
return;
for (UUID uuid : getActive())
{
Player player = UtilPlayer.searchExact(uuid);
if (player == null)
{
System.out.println("Tutorial Error: " + getName() + " has UUID with null player: " + uuid);
continue;
}
if (isEquipped(player))
finish(player);
}
}
private boolean isEquipped(Player player)
{
boolean equipped = true;
if (player.getInventory().getHelmet() == null || player.getInventory().getHelmet().getType() != Material.IRON_HELMET ||
player.getInventory().getChestplate() == null || player.getInventory().getChestplate().getType() != Material.IRON_CHESTPLATE ||
player.getInventory().getLeggings() == null || player.getInventory().getLeggings().getType() != Material.IRON_LEGGINGS ||
player.getInventory().getBoots() == null || player.getInventory().getBoots().getType() != Material.IRON_BOOTS)
equipped = false;
return equipped;
}
}

View File

@ -1,37 +0,0 @@
package mineplex.game.clans.tutorial.tutorials.combat.objectives.goals;
import org.bukkit.entity.Player;
import org.bukkit.event.EventHandler;
import mineplex.core.common.objective.Objective;
import mineplex.core.common.objective.ObjectiveGoal;
import mineplex.minecraft.game.classcombat.shop.event.OpenClassShopEvent;
public class OpenCustomizationGoal extends ObjectiveGoal
{
public OpenCustomizationGoal(Objective objective)
{
super(objective, "Open Customization", "Open Customization");
}
@Override
protected void customStart(Player player)
{
}
@Override
protected void customFinish(Player player)
{
}
@EventHandler
public void onOpenClassShop(OpenClassShopEvent event)
{
if (contains(event.getPlayer()))
{
finish(event.getPlayer());
}
}
}

View File

@ -1,25 +0,0 @@
package test;
import java.io.ByteArrayOutputStream;
import java.io.DataOutputStream;
import java.io.IOException;
public class Test {
public static void main(String[] args) throws IOException
{
ByteArrayOutputStream stream = new ByteArrayOutputStream();
DataOutputStream dos = new DataOutputStream(stream);
dos.writeByte(91);
dos.flush();
stream.flush();
System.out.println(new String(stream.toByteArray()));
dos.close();
stream.close();
}
}

View File

@ -87,7 +87,7 @@ public class TutorialManager extends MiniPlugin
if (InTutorial(event.getPlayer()))
event.setCancelled(true);
}
@EventHandler
public void MoveCancel(PlayerMoveEvent event)
{

View File

@ -13,6 +13,7 @@ import mineplex.minecraft.game.classcombat.Class.IPvpClass.ClassType;
import mineplex.core.common.util.F;
import mineplex.core.common.util.UtilAction;
import mineplex.core.common.util.UtilBlock;
import mineplex.core.common.util.UtilMath;
import mineplex.core.common.util.UtilPlayer;
import mineplex.core.common.util.UtilTime;
import mineplex.minecraft.game.classcombat.Skill.SkillActive;