2011-10-01 17:59:46 +00:00
|
|
|
package me.StevenLawson.TotalFreedomMod;
|
|
|
|
|
2011-10-10 12:09:19 +00:00
|
|
|
import java.util.ArrayList;
|
|
|
|
import java.util.List;
|
2011-10-16 06:00:37 +00:00
|
|
|
import org.bukkit.Bukkit;
|
2011-10-10 12:09:19 +00:00
|
|
|
import org.bukkit.Location;
|
|
|
|
import org.bukkit.Material;
|
2011-10-16 06:00:37 +00:00
|
|
|
import org.bukkit.entity.CreatureType;
|
|
|
|
import org.bukkit.entity.LivingEntity;
|
|
|
|
import org.bukkit.entity.Player;
|
2011-10-10 12:09:19 +00:00
|
|
|
|
2011-10-02 04:23:22 +00:00
|
|
|
public class TFM_UserInfo
|
2011-10-01 17:59:46 +00:00
|
|
|
{
|
|
|
|
private boolean user_frozen = false;
|
|
|
|
private int msg_count = 0;
|
2011-10-05 19:07:45 +00:00
|
|
|
private int block_destroy_total = 0;
|
2011-10-18 04:08:40 +00:00
|
|
|
private int block_place_total = 0;
|
2011-10-05 19:07:45 +00:00
|
|
|
private int freecam_destroy_count = 0;
|
|
|
|
private int freecam_place_count = 0;
|
2011-10-14 05:31:21 +00:00
|
|
|
private boolean forced_death = false;
|
2011-10-10 12:09:19 +00:00
|
|
|
private boolean user_caged = false;
|
|
|
|
private Location user_cage_pos;
|
|
|
|
private List<TFM_BlockData> user_cage_history = new ArrayList<TFM_BlockData>();
|
2011-10-16 06:00:37 +00:00
|
|
|
private Material cage_material_outer = Material.GLASS;
|
|
|
|
private Material cage_material_inner = Material.AIR;
|
|
|
|
private boolean is_orbiting = false;
|
|
|
|
private double orbit_strength = 10.0;
|
|
|
|
private boolean mob_thrower_enabled = false;
|
|
|
|
private CreatureType mob_thrower_creature = CreatureType.PIG;
|
|
|
|
private double mob_thrower_speed = 4.0;
|
2011-10-18 04:08:40 +00:00
|
|
|
private List<LivingEntity> mob_thrower_queue = new ArrayList<LivingEntity>();
|
|
|
|
private int mp44_schedule_id = -1;
|
2011-10-02 04:18:52 +00:00
|
|
|
|
2011-10-02 04:23:22 +00:00
|
|
|
public TFM_UserInfo()
|
2011-10-01 17:59:46 +00:00
|
|
|
{
|
|
|
|
}
|
2011-10-16 06:00:37 +00:00
|
|
|
|
|
|
|
public static TFM_UserInfo getPlayerData(Player p, TotalFreedomMod tfm)
|
|
|
|
{
|
|
|
|
TFM_UserInfo playerdata = tfm.userinfo.get(p);
|
|
|
|
if (playerdata == null)
|
|
|
|
{
|
|
|
|
playerdata = new TFM_UserInfo();
|
|
|
|
tfm.userinfo.put(p, playerdata);
|
|
|
|
}
|
|
|
|
return playerdata;
|
|
|
|
}
|
|
|
|
|
|
|
|
public boolean isOrbiting()
|
|
|
|
{
|
|
|
|
return this.is_orbiting;
|
|
|
|
}
|
|
|
|
|
|
|
|
public void startOrbiting(double orbit_strength)
|
|
|
|
{
|
|
|
|
this.is_orbiting = true;
|
|
|
|
this.orbit_strength = orbit_strength;
|
|
|
|
}
|
|
|
|
|
|
|
|
public void stopOrbiting()
|
|
|
|
{
|
|
|
|
this.is_orbiting = false;
|
|
|
|
}
|
|
|
|
|
|
|
|
public double orbitStrength()
|
|
|
|
{
|
|
|
|
return this.orbit_strength;
|
|
|
|
}
|
2011-10-14 23:29:09 +00:00
|
|
|
|
2011-10-10 12:09:19 +00:00
|
|
|
public void setCaged(boolean state)
|
|
|
|
{
|
|
|
|
this.user_caged = state;
|
|
|
|
}
|
2011-10-14 23:29:09 +00:00
|
|
|
|
2011-10-10 12:09:19 +00:00
|
|
|
public void setCaged(boolean state, Location location, Material material_outer, Material material_inner)
|
|
|
|
{
|
|
|
|
this.user_caged = state;
|
|
|
|
this.user_cage_pos = location;
|
|
|
|
this.cage_material_outer = material_outer;
|
|
|
|
this.cage_material_inner = material_inner;
|
|
|
|
}
|
2011-10-14 23:29:09 +00:00
|
|
|
|
2011-10-10 12:09:19 +00:00
|
|
|
public boolean isCaged()
|
|
|
|
{
|
|
|
|
return this.user_caged;
|
|
|
|
}
|
2011-10-14 23:29:09 +00:00
|
|
|
|
|
|
|
public enum CageLayer
|
2011-10-10 12:09:19 +00:00
|
|
|
{
|
2011-10-14 23:29:09 +00:00
|
|
|
INNER, OUTER
|
|
|
|
}
|
|
|
|
|
|
|
|
public Material getCageMaterial(CageLayer layer)
|
|
|
|
{
|
|
|
|
switch (layer)
|
2011-10-10 12:09:19 +00:00
|
|
|
{
|
2011-10-14 23:29:09 +00:00
|
|
|
case OUTER:
|
|
|
|
return this.cage_material_outer;
|
|
|
|
case INNER:
|
|
|
|
return this.cage_material_inner;
|
|
|
|
default:
|
|
|
|
return this.cage_material_outer;
|
2011-10-10 12:09:19 +00:00
|
|
|
}
|
|
|
|
}
|
2011-10-14 23:29:09 +00:00
|
|
|
|
2011-10-10 12:09:19 +00:00
|
|
|
public Location getCagePos()
|
|
|
|
{
|
|
|
|
return this.user_cage_pos;
|
|
|
|
}
|
2011-10-14 23:29:09 +00:00
|
|
|
|
2011-10-10 12:09:19 +00:00
|
|
|
public void clearHistory()
|
|
|
|
{
|
|
|
|
this.user_cage_history.clear();
|
|
|
|
}
|
2011-10-14 23:29:09 +00:00
|
|
|
|
2011-10-10 12:09:19 +00:00
|
|
|
public void insertHistoryBlock(Location location, Material material)
|
|
|
|
{
|
|
|
|
this.user_cage_history.add(new TFM_BlockData(location, material));
|
|
|
|
}
|
2011-10-14 23:29:09 +00:00
|
|
|
|
2011-10-10 12:09:19 +00:00
|
|
|
public void regenerateHistory()
|
|
|
|
{
|
|
|
|
for (TFM_BlockData blockdata : this.user_cage_history)
|
|
|
|
{
|
|
|
|
blockdata.location.getBlock().setType(blockdata.material);
|
|
|
|
}
|
|
|
|
}
|
2011-10-14 23:29:09 +00:00
|
|
|
|
2011-10-10 12:09:19 +00:00
|
|
|
class TFM_BlockData
|
|
|
|
{
|
|
|
|
public Material material;
|
|
|
|
public Location location;
|
|
|
|
|
|
|
|
public TFM_BlockData(Location location, Material material)
|
|
|
|
{
|
|
|
|
this.location = location;
|
|
|
|
this.material = material;
|
|
|
|
}
|
|
|
|
}
|
2011-10-14 23:29:09 +00:00
|
|
|
|
2011-10-14 05:31:21 +00:00
|
|
|
public boolean getForcedDeath()
|
|
|
|
{
|
|
|
|
return this.forced_death;
|
|
|
|
}
|
|
|
|
|
2011-10-19 00:37:00 +00:00
|
|
|
public void setForcedDeath(boolean forced_death)
|
2011-10-14 05:31:21 +00:00
|
|
|
{
|
|
|
|
this.forced_death = forced_death;
|
|
|
|
}
|
2011-10-01 17:59:46 +00:00
|
|
|
|
|
|
|
public boolean isFrozen()
|
|
|
|
{
|
|
|
|
return this.user_frozen;
|
|
|
|
}
|
2011-10-02 04:18:52 +00:00
|
|
|
|
2011-10-01 17:59:46 +00:00
|
|
|
public void setFrozen(boolean fr)
|
|
|
|
{
|
|
|
|
this.user_frozen = fr;
|
|
|
|
}
|
|
|
|
|
|
|
|
public void resetMsgCount()
|
|
|
|
{
|
|
|
|
this.msg_count = 0;
|
|
|
|
}
|
2011-10-02 04:18:52 +00:00
|
|
|
|
2011-10-01 17:59:46 +00:00
|
|
|
public void incrementMsgCount()
|
|
|
|
{
|
|
|
|
this.msg_count++;
|
|
|
|
}
|
2011-10-02 04:18:52 +00:00
|
|
|
|
2011-10-01 17:59:46 +00:00
|
|
|
public int getMsgCount()
|
|
|
|
{
|
|
|
|
return this.msg_count;
|
|
|
|
}
|
2011-10-02 04:18:52 +00:00
|
|
|
|
2011-10-01 17:59:46 +00:00
|
|
|
public void incrementBlockDestroyCount()
|
|
|
|
{
|
2011-10-05 19:07:45 +00:00
|
|
|
this.block_destroy_total++;
|
2011-10-01 17:59:46 +00:00
|
|
|
}
|
2011-10-02 04:18:52 +00:00
|
|
|
|
2011-10-01 17:59:46 +00:00
|
|
|
public int getBlockDestroyCount()
|
|
|
|
{
|
2011-10-05 19:07:45 +00:00
|
|
|
return this.block_destroy_total;
|
2011-10-01 17:59:46 +00:00
|
|
|
}
|
2011-10-02 04:18:52 +00:00
|
|
|
|
2011-10-01 17:59:46 +00:00
|
|
|
public void resetBlockDestroyCount()
|
|
|
|
{
|
2011-10-05 19:07:45 +00:00
|
|
|
this.block_destroy_total = 0;
|
|
|
|
}
|
2011-10-18 04:08:40 +00:00
|
|
|
|
|
|
|
public void incrementBlockPlaceCount()
|
|
|
|
{
|
|
|
|
this.block_place_total++;
|
|
|
|
}
|
|
|
|
|
|
|
|
public int getBlockPlaceCount()
|
|
|
|
{
|
|
|
|
return this.block_place_total;
|
|
|
|
}
|
|
|
|
|
|
|
|
public void resetBlockPlaceCount()
|
|
|
|
{
|
|
|
|
this.block_place_total = 0;
|
|
|
|
}
|
2011-10-14 23:29:09 +00:00
|
|
|
|
2011-10-05 19:07:45 +00:00
|
|
|
public void incrementFreecamDestroyCount()
|
|
|
|
{
|
|
|
|
this.freecam_destroy_count++;
|
|
|
|
}
|
|
|
|
|
|
|
|
public int getFreecamDestroyCount()
|
|
|
|
{
|
|
|
|
return this.freecam_destroy_count;
|
|
|
|
}
|
|
|
|
|
|
|
|
public void resetFreecamDestroyCount()
|
|
|
|
{
|
|
|
|
this.freecam_destroy_count = 0;
|
|
|
|
}
|
2011-10-14 23:29:09 +00:00
|
|
|
|
2011-10-05 19:07:45 +00:00
|
|
|
public void incrementFreecamPlaceCount()
|
|
|
|
{
|
|
|
|
this.freecam_place_count++;
|
|
|
|
}
|
|
|
|
|
|
|
|
public int getFreecamPlaceCount()
|
|
|
|
{
|
|
|
|
return this.freecam_place_count;
|
|
|
|
}
|
|
|
|
|
|
|
|
public void resetFreecamPlaceCount()
|
|
|
|
{
|
|
|
|
this.freecam_place_count = 0;
|
2011-10-01 17:59:46 +00:00
|
|
|
}
|
2011-10-16 06:00:37 +00:00
|
|
|
|
|
|
|
public void enableMobThrower(CreatureType mob_thrower_creature, double mob_thrower_speed)
|
|
|
|
{
|
|
|
|
this.mob_thrower_enabled = true;
|
|
|
|
this.mob_thrower_creature = mob_thrower_creature;
|
|
|
|
this.mob_thrower_speed = mob_thrower_speed;
|
|
|
|
}
|
|
|
|
|
|
|
|
public void disableMobThrower()
|
|
|
|
{
|
|
|
|
this.mob_thrower_enabled = false;
|
|
|
|
}
|
|
|
|
|
|
|
|
public CreatureType mobThrowerCreature()
|
|
|
|
{
|
|
|
|
return this.mob_thrower_creature;
|
|
|
|
}
|
|
|
|
|
|
|
|
public double mobThrowerSpeed()
|
|
|
|
{
|
|
|
|
return this.mob_thrower_speed;
|
|
|
|
}
|
|
|
|
|
|
|
|
public boolean mobThrowerEnabled()
|
|
|
|
{
|
|
|
|
return this.mob_thrower_enabled;
|
|
|
|
}
|
|
|
|
|
|
|
|
public void enqueueMob(LivingEntity mob)
|
|
|
|
{
|
2011-10-18 04:08:40 +00:00
|
|
|
mob_thrower_queue.add(mob);
|
|
|
|
if (mob_thrower_queue.size() > 4)
|
2011-10-16 06:00:37 +00:00
|
|
|
{
|
2011-10-18 04:08:40 +00:00
|
|
|
LivingEntity oldmob = mob_thrower_queue.remove(0);
|
2011-10-16 06:00:37 +00:00
|
|
|
if (oldmob != null)
|
|
|
|
{
|
|
|
|
oldmob.damage(20);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2011-10-19 00:37:00 +00:00
|
|
|
public void startArrowShooter(int schedule_id)
|
2011-10-16 06:00:37 +00:00
|
|
|
{
|
2011-10-18 04:08:40 +00:00
|
|
|
this.mp44_schedule_id = schedule_id;
|
2011-10-16 06:00:37 +00:00
|
|
|
}
|
|
|
|
|
2011-10-19 00:37:00 +00:00
|
|
|
public void stopArrowShooter()
|
2011-10-16 06:00:37 +00:00
|
|
|
{
|
2011-10-18 04:08:40 +00:00
|
|
|
if (this.mp44_schedule_id != -1)
|
2011-10-16 06:00:37 +00:00
|
|
|
{
|
2011-10-18 04:08:40 +00:00
|
|
|
Bukkit.getScheduler().cancelTask(this.mp44_schedule_id);
|
|
|
|
this.mp44_schedule_id = -1;
|
2011-10-16 06:00:37 +00:00
|
|
|
}
|
|
|
|
}
|
2011-10-01 17:59:46 +00:00
|
|
|
}
|