Created Clans project.
Converted Fields code complete (not tested).
This commit is contained in:
parent
b08cd54666
commit
8d62966abc
@ -0,0 +1,43 @@
|
||||
package mineplex.core.database.column;
|
||||
|
||||
import java.sql.PreparedStatement;
|
||||
import java.sql.ResultSet;
|
||||
import java.sql.SQLException;
|
||||
|
||||
public class ColumnByte extends Column<Byte>
|
||||
{
|
||||
public ColumnByte(String name)
|
||||
{
|
||||
super(name);
|
||||
Value = (byte)0;
|
||||
}
|
||||
|
||||
public ColumnByte(String name, Byte value)
|
||||
{
|
||||
super(name, value);
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getCreateString()
|
||||
{
|
||||
return Name + " TINYINT";
|
||||
}
|
||||
|
||||
@Override
|
||||
public Byte getValue(ResultSet resultSet) throws SQLException
|
||||
{
|
||||
return resultSet.getByte(Name);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setValue(PreparedStatement preparedStatement, int columnNumber) throws SQLException
|
||||
{
|
||||
preparedStatement.setLong(columnNumber, Value);
|
||||
}
|
||||
|
||||
@Override
|
||||
public ColumnByte clone()
|
||||
{
|
||||
return new ColumnByte(Name, Value);
|
||||
}
|
||||
}
|
@ -0,0 +1,43 @@
|
||||
package mineplex.core.database.column;
|
||||
|
||||
import java.sql.PreparedStatement;
|
||||
import java.sql.ResultSet;
|
||||
import java.sql.SQLException;
|
||||
|
||||
public class ColumnDouble extends Column<Double>
|
||||
{
|
||||
public ColumnDouble(String name)
|
||||
{
|
||||
super(name);
|
||||
Value = 0.0;
|
||||
}
|
||||
|
||||
public ColumnDouble(String name, Double value)
|
||||
{
|
||||
super(name, value);
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getCreateString()
|
||||
{
|
||||
return Name + " DOUBLE";
|
||||
}
|
||||
|
||||
@Override
|
||||
public Double getValue(ResultSet resultSet) throws SQLException
|
||||
{
|
||||
return resultSet.getDouble(Name);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setValue(PreparedStatement preparedStatement, int columnNumber) throws SQLException
|
||||
{
|
||||
preparedStatement.setDouble(columnNumber, Value);
|
||||
}
|
||||
|
||||
@Override
|
||||
public ColumnDouble clone()
|
||||
{
|
||||
return new ColumnDouble(Name, Value);
|
||||
}
|
||||
}
|
12
Plugins/Mineplex.Game.Clans/.classpath
Normal file
12
Plugins/Mineplex.Game.Clans/.classpath
Normal file
@ -0,0 +1,12 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<classpath>
|
||||
<classpathentry kind="src" path="src"/>
|
||||
<classpathentry kind="con" path="org.eclipse.jdt.launching.JRE_CONTAINER/org.eclipse.jdt.internal.debug.ui.launcher.StandardVMType/jre7"/>
|
||||
<classpathentry combineaccessrules="false" kind="src" path="/Mineplex.Core"/>
|
||||
<classpathentry combineaccessrules="false" kind="src" path="/Mineplex.Core.Common"/>
|
||||
<classpathentry combineaccessrules="false" kind="src" path="/Mineplex.ServerData"/>
|
||||
<classpathentry combineaccessrules="false" kind="src" path="/Mineplex.Minecraft.Game.ClassCombat"/>
|
||||
<classpathentry combineaccessrules="false" kind="src" path="/Mineplex.Minecraft.Game.Core"/>
|
||||
<classpathentry kind="var" path="REPO_DIR/Plugins/Libraries/craftbukkit.jar" sourcepath="/REPO_DIR/GitHubLibraries/CraftBukkit/src"/>
|
||||
<classpathentry kind="output" path="bin"/>
|
||||
</classpath>
|
@ -0,0 +1,13 @@
|
||||
<?xml version="1.0" encoding="UTF-8" standalone="no"?>
|
||||
<launchConfiguration type="org.eclipse.ant.AntBuilderLaunchConfigurationType">
|
||||
<booleanAttribute key="org.eclipse.ant.ui.ATTR_TARGETS_UPDATED" value="true"/>
|
||||
<booleanAttribute key="org.eclipse.ant.ui.DEFAULT_VM_INSTALL" value="false"/>
|
||||
<booleanAttribute key="org.eclipse.debug.ui.ATTR_LAUNCH_IN_BACKGROUND" value="false"/>
|
||||
<stringAttribute key="org.eclipse.jdt.launching.CLASSPATH_PROVIDER" value="org.eclipse.ant.ui.AntClasspathProvider"/>
|
||||
<booleanAttribute key="org.eclipse.jdt.launching.DEFAULT_CLASSPATH" value="true"/>
|
||||
<stringAttribute key="org.eclipse.jdt.launching.PROJECT_ATTR" value=""/>
|
||||
<stringAttribute key="org.eclipse.ui.externaltools.ATTR_LOCATION" value="${BUILD_FILES}/common.xml"/>
|
||||
<stringAttribute key="org.eclipse.ui.externaltools.ATTR_RUN_BUILD_KINDS" value=""/>
|
||||
<booleanAttribute key="org.eclipse.ui.externaltools.ATTR_TRIGGERS_CONFIGURED" value="true"/>
|
||||
<stringAttribute key="org.eclipse.ui.externaltools.ATTR_WORKING_DIRECTORY" value="${workspace_loc:/Mineplex.Game.Clans}"/>
|
||||
</launchConfiguration>
|
27
Plugins/Mineplex.Game.Clans/.project
Normal file
27
Plugins/Mineplex.Game.Clans/.project
Normal file
@ -0,0 +1,27 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<projectDescription>
|
||||
<name>Mineplex.Game.Clans</name>
|
||||
<comment></comment>
|
||||
<projects>
|
||||
</projects>
|
||||
<buildSpec>
|
||||
<buildCommand>
|
||||
<name>org.eclipse.jdt.core.javabuilder</name>
|
||||
<arguments>
|
||||
</arguments>
|
||||
</buildCommand>
|
||||
<buildCommand>
|
||||
<name>org.eclipse.ui.externaltools.ExternalToolBuilder</name>
|
||||
<triggers>full,incremental,</triggers>
|
||||
<arguments>
|
||||
<dictionary>
|
||||
<key>LaunchConfigHandle</key>
|
||||
<value><project>/.externalToolBuilders/ClansBuilder.launch</value>
|
||||
</dictionary>
|
||||
</arguments>
|
||||
</buildCommand>
|
||||
</buildSpec>
|
||||
<natures>
|
||||
<nature>org.eclipse.jdt.core.javanature</nature>
|
||||
</natures>
|
||||
</projectDescription>
|
@ -0,0 +1,11 @@
|
||||
eclipse.preferences.version=1
|
||||
org.eclipse.jdt.core.compiler.codegen.inlineJsrBytecode=enabled
|
||||
org.eclipse.jdt.core.compiler.codegen.targetPlatform=1.7
|
||||
org.eclipse.jdt.core.compiler.codegen.unusedLocal=preserve
|
||||
org.eclipse.jdt.core.compiler.compliance=1.7
|
||||
org.eclipse.jdt.core.compiler.debug.lineNumber=generate
|
||||
org.eclipse.jdt.core.compiler.debug.localVariable=generate
|
||||
org.eclipse.jdt.core.compiler.debug.sourceFile=generate
|
||||
org.eclipse.jdt.core.compiler.problem.assertIdentifier=error
|
||||
org.eclipse.jdt.core.compiler.problem.enumIdentifier=error
|
||||
org.eclipse.jdt.core.compiler.source=1.7
|
@ -0,0 +1,41 @@
|
||||
package me.chiss.Core.Field;
|
||||
|
||||
import org.bukkit.plugin.java.JavaPlugin;
|
||||
|
||||
import me.chiss.Core.Field.repository.FieldRepository;
|
||||
import mineplex.core.MiniPlugin;
|
||||
import mineplex.core.creature.Creature;
|
||||
import mineplex.core.energy.Energy;
|
||||
import mineplex.minecraft.game.core.condition.ConditionFactory;
|
||||
|
||||
public class Field extends MiniPlugin
|
||||
{
|
||||
private FieldBlock _block;
|
||||
private FieldOre _ore;
|
||||
private FieldMonster _mob;
|
||||
|
||||
public Field(JavaPlugin plugin, Creature creature, ConditionFactory condition, Energy energy, String serverName)
|
||||
{
|
||||
super("Field Factory", plugin);
|
||||
|
||||
FieldRepository repository = new FieldRepository(plugin);
|
||||
_block = new FieldBlock(plugin, condition, energy, repository, serverName);
|
||||
_ore = new FieldOre(plugin, repository, serverName);
|
||||
_mob = new FieldMonster(plugin, repository, creature, serverName);
|
||||
}
|
||||
|
||||
public FieldBlock GetBlock()
|
||||
{
|
||||
return _block;
|
||||
}
|
||||
|
||||
public FieldOre GetOre()
|
||||
{
|
||||
return _ore;
|
||||
}
|
||||
|
||||
public FieldMonster GetMonster()
|
||||
{
|
||||
return _mob;
|
||||
}
|
||||
}
|
@ -4,8 +4,6 @@ import java.util.HashMap;
|
||||
import java.util.HashSet;
|
||||
import java.util.WeakHashMap;
|
||||
|
||||
import nautilus.minecraft.core.webserver.token.Server.FieldBlockToken;
|
||||
|
||||
import org.bukkit.Effect;
|
||||
import org.bukkit.Location;
|
||||
import org.bukkit.Material;
|
||||
@ -17,19 +15,26 @@ import org.bukkit.event.block.BlockBreakEvent;
|
||||
import org.bukkit.event.player.PlayerInteractEvent;
|
||||
import org.bukkit.plugin.java.JavaPlugin;
|
||||
|
||||
import me.chiss.Core.Module.AModule;
|
||||
import mineplex.core.server.IRepository;
|
||||
import me.chiss.Core.Field.repository.FieldBlockToken;
|
||||
import me.chiss.Core.Field.repository.FieldRepository;
|
||||
import mineplex.core.MiniPlugin;
|
||||
import mineplex.core.updater.event.UpdateEvent;
|
||||
import mineplex.core.updater.UpdateType;
|
||||
import mineplex.core.common.Rank;
|
||||
import mineplex.core.common.util.F;
|
||||
import mineplex.core.common.util.UtilMath;
|
||||
import mineplex.core.common.util.UtilEvent;
|
||||
import mineplex.core.common.util.UtilGear;
|
||||
import mineplex.core.common.util.UtilPlayer;
|
||||
import mineplex.core.common.util.UtilWorld;
|
||||
import mineplex.core.common.util.UtilEvent.ActionType;
|
||||
import mineplex.core.energy.Energy;
|
||||
import mineplex.minecraft.game.core.condition.ConditionFactory;
|
||||
|
||||
public class FieldBlock extends AModule
|
||||
public class FieldBlock extends MiniPlugin
|
||||
{
|
||||
private ConditionFactory _conditionFactory;
|
||||
private Energy _energy;
|
||||
private FieldRepository _repository;
|
||||
private HashMap<String, FieldBlockData> _blocks;
|
||||
|
||||
private HashSet<String> _active = new HashSet<String>();
|
||||
@ -44,10 +49,13 @@ public class FieldBlock extends AModule
|
||||
|
||||
private String _serverName;
|
||||
|
||||
public FieldBlock(JavaPlugin plugin, IRepository repository, String serverName)
|
||||
public FieldBlock(JavaPlugin plugin, ConditionFactory conditionFactory, Energy energy, FieldRepository repository, String serverName)
|
||||
{
|
||||
super("Field Block", plugin, repository);
|
||||
super("Field Block", plugin);
|
||||
|
||||
_conditionFactory = conditionFactory;
|
||||
_energy = energy;
|
||||
_repository = repository;
|
||||
_blocks = new HashMap<String, FieldBlockData>();
|
||||
|
||||
_serverName = serverName;
|
||||
@ -55,172 +63,11 @@ public class FieldBlock extends AModule
|
||||
load();
|
||||
}
|
||||
|
||||
//Module Functions
|
||||
@Override
|
||||
public void enable()
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public void disable()
|
||||
{
|
||||
clean();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void config()
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public void commands()
|
||||
{
|
||||
AddCommand("fb");
|
||||
}
|
||||
|
||||
@Override
|
||||
public void command(Player caller, String cmd, String[] args)
|
||||
{
|
||||
if (!Clients().Get(caller).Rank().Has(Rank.ADMIN, true))
|
||||
return;
|
||||
|
||||
if (args.length == 0)
|
||||
{
|
||||
showSettings(caller);
|
||||
return;
|
||||
}
|
||||
|
||||
if (args[0].equalsIgnoreCase("toggle"))
|
||||
{
|
||||
if (!_active.remove(caller.getName()))
|
||||
_active.add(caller.getName());
|
||||
|
||||
UtilPlayer.message(caller, F.main(GetName(), "Interact Active: " + F.tf(_active.contains(caller.getName()))));
|
||||
}
|
||||
|
||||
else if (args[0].equalsIgnoreCase("load"))
|
||||
{
|
||||
load();
|
||||
UtilPlayer.message(caller, F.main(_moduleName, "Reloaded Field Blocks from Database."));
|
||||
}
|
||||
|
||||
else if (args[0].equalsIgnoreCase("wipe"))
|
||||
{
|
||||
wipe(caller);
|
||||
}
|
||||
|
||||
else if (args[0].equalsIgnoreCase("help"))
|
||||
{
|
||||
help(caller);
|
||||
}
|
||||
|
||||
else if (args.length <= 1)
|
||||
{
|
||||
help(caller);
|
||||
}
|
||||
|
||||
else if (args[0].equalsIgnoreCase("title"))
|
||||
{
|
||||
_title.put(caller, args[1]);
|
||||
showSettings(caller);
|
||||
}
|
||||
|
||||
else if (args[0].equalsIgnoreCase("stock"))
|
||||
{
|
||||
try
|
||||
{
|
||||
int count = Integer.parseInt(args[1]);
|
||||
if (count < 1) count = 1;
|
||||
_stock.put(caller, count);
|
||||
showSettings(caller);
|
||||
}
|
||||
catch (Exception e)
|
||||
{
|
||||
UtilPlayer.message(caller, F.main(_moduleName, "Invalid Stock Max."));
|
||||
}
|
||||
}
|
||||
|
||||
else if (args[0].equalsIgnoreCase("regen"))
|
||||
{
|
||||
try
|
||||
{
|
||||
double regen = Double.parseDouble(args[1]);
|
||||
if (regen < 0) regen = 0;
|
||||
_regen.put(caller, UtilMath.trim(1, regen));
|
||||
showSettings(caller);
|
||||
}
|
||||
catch (Exception e)
|
||||
{
|
||||
UtilPlayer.message(caller, F.main(_moduleName, "Invalid Stock Regeneration Time."));
|
||||
}
|
||||
}
|
||||
|
||||
else if (args[0].equalsIgnoreCase("empty"))
|
||||
{
|
||||
try
|
||||
{
|
||||
String[] toks = args[1].split(":");
|
||||
|
||||
int id = Integer.parseInt(toks[0]);
|
||||
byte data = Byte.parseByte(toks[1]);
|
||||
|
||||
_emptyId.put(caller, id);
|
||||
_emptyData.put(caller, data);
|
||||
showSettings(caller);
|
||||
}
|
||||
catch (Exception e)
|
||||
{
|
||||
UtilPlayer.message(caller, F.main(_moduleName, "Invalid Empty Block."));
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
else if (args[0].equalsIgnoreCase("loot"))
|
||||
{
|
||||
boolean error = false;
|
||||
for (String cur : args[1].split(","))
|
||||
{
|
||||
String[] loot = cur.split(":");
|
||||
|
||||
if (loot.length != 5)
|
||||
{
|
||||
error = true;
|
||||
break;
|
||||
}
|
||||
|
||||
try
|
||||
{
|
||||
Integer.parseInt(loot[0]);
|
||||
Byte.parseByte(loot[1]);
|
||||
Integer.parseInt(loot[2]);
|
||||
Integer.parseInt(loot[3]);
|
||||
Integer.parseInt(loot[4]);
|
||||
}
|
||||
catch (Exception e)
|
||||
{
|
||||
error = true;
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
if (error)
|
||||
{
|
||||
UtilPlayer.message(caller, F.main(_moduleName, "Invalid Loot String."));
|
||||
return;
|
||||
}
|
||||
|
||||
_lootString.put(caller, args[1]);
|
||||
showSettings(caller);
|
||||
}
|
||||
}
|
||||
|
||||
private void showSettings(Player caller)
|
||||
public void showSettings(Player caller)
|
||||
{
|
||||
populateSettings(caller);
|
||||
|
||||
UtilPlayer.message(caller, F.main(_moduleName, "Field Addition Settings;"));
|
||||
UtilPlayer.message(caller, F.main(GetName(), "Field Addition Settings;"));
|
||||
UtilPlayer.message(caller, F.desc("Title", _title.get(caller)));
|
||||
UtilPlayer.message(caller, F.desc("Stock", _stock.get(caller)+""));
|
||||
UtilPlayer.message(caller, F.desc("Regen", _regen.get(caller)+""));
|
||||
@ -257,34 +104,31 @@ public class FieldBlock extends AModule
|
||||
|
||||
if (event.getPlayer().getItemInHand() != null && event.getPlayer().getItemInHand().getType().toString().contains("PICKAXE"))
|
||||
{
|
||||
if (Util().Event().isAction(event, ActionType.R_BLOCK))
|
||||
if (UtilEvent.isAction(event, ActionType.R_BLOCK))
|
||||
showBlock(event.getPlayer(), event);
|
||||
}
|
||||
|
||||
else if (Util().Gear().isMat(event.getPlayer().getItemInHand(), Material.GLOWSTONE_DUST))
|
||||
else if (UtilGear.isMat(event.getPlayer().getItemInHand(), Material.GLOWSTONE_DUST))
|
||||
{
|
||||
if (Util().Event().isAction(event, ActionType.L_BLOCK))
|
||||
if (UtilEvent.isAction(event, ActionType.L_BLOCK))
|
||||
addBlock(event.getPlayer(), event);
|
||||
|
||||
else if (Util().Event().isAction(event, ActionType.R))
|
||||
else if (UtilEvent.isAction(event, ActionType.R))
|
||||
glowBlocks(event.getPlayer(), event);
|
||||
}
|
||||
|
||||
else if (Util().Gear().isMat(event.getPlayer().getItemInHand(), Material.REDSTONE))
|
||||
else if (UtilGear.isMat(event.getPlayer().getItemInHand(), Material.REDSTONE))
|
||||
{
|
||||
if (Util().Event().isAction(event, ActionType.L_BLOCK))
|
||||
if (UtilEvent.isAction(event, ActionType.L_BLOCK))
|
||||
delBlock(event.getPlayer(), event);
|
||||
|
||||
else if (Util().Event().isAction(event, ActionType.R))
|
||||
else if (UtilEvent.isAction(event, ActionType.R))
|
||||
glowBlocks(event.getPlayer(), event);
|
||||
}
|
||||
}
|
||||
|
||||
private void glowBlocks(Player player, PlayerInteractEvent event)
|
||||
{
|
||||
if (!Clients().Get(player).Rank().Has(Rank.ADMIN, false))
|
||||
return;
|
||||
|
||||
load();
|
||||
|
||||
for (FieldBlockData cur : _blocks.values())
|
||||
@ -293,12 +137,12 @@ public class FieldBlock extends AModule
|
||||
event.setCancelled(true);
|
||||
}
|
||||
|
||||
private void wipe(Player player)
|
||||
public void wipe(Player player)
|
||||
{
|
||||
for (FieldBlockData cur : _blocks.values())
|
||||
{
|
||||
cur.setEmpty();
|
||||
GetRepository().DeleteFieldBlock(_serverName, UtilWorld.locToStr(cur.getLocation()));
|
||||
_repository.deleteFieldBlock(_serverName, UtilWorld.locToStr(cur.getLocation()));
|
||||
}
|
||||
|
||||
_blocks.clear();
|
||||
@ -308,10 +152,7 @@ public class FieldBlock extends AModule
|
||||
|
||||
private void delBlock(Player player, PlayerInteractEvent event)
|
||||
{
|
||||
if (!Clients().Get(player).Rank().Has(Rank.ADMIN, false))
|
||||
return;
|
||||
|
||||
GetRepository().DeleteFieldBlock(_serverName, UtilWorld.locToStr(event.getClickedBlock().getLocation()));
|
||||
_repository.deleteFieldBlock(_serverName, UtilWorld.locToStr(event.getClickedBlock().getLocation()));
|
||||
|
||||
//Inform
|
||||
event.getClickedBlock().getWorld().playEffect(event.getClickedBlock().getLocation(), Effect.STEP_SOUND, 42);
|
||||
@ -322,9 +163,6 @@ public class FieldBlock extends AModule
|
||||
|
||||
private void addBlock(Player player, PlayerInteractEvent event)
|
||||
{
|
||||
if (!Clients().Get(player).Rank().Has(Rank.ADMIN, false))
|
||||
return;
|
||||
|
||||
populateSettings(player);
|
||||
showSettings(player);
|
||||
|
||||
@ -340,7 +178,7 @@ public class FieldBlock extends AModule
|
||||
token.StockRegenTime = _regen.get(player);
|
||||
token.Loot = _lootString.get(player);
|
||||
|
||||
GetRepository().AddFieldBlock(token);
|
||||
_repository.addFieldBlock(token);
|
||||
|
||||
//Inform
|
||||
event.getClickedBlock().getWorld().playEffect(event.getClickedBlock().getLocation(), Effect.STEP_SOUND, 41);
|
||||
@ -388,7 +226,7 @@ public class FieldBlock extends AModule
|
||||
{
|
||||
clean();
|
||||
|
||||
for (FieldBlockToken token : GetRepository().GetFieldBlocks(_serverName))
|
||||
for (FieldBlockToken token : _repository.getFieldBlocks(_serverName))
|
||||
{
|
||||
Location loc = UtilWorld.strToLoc(token.Location);
|
||||
_blocks.put(token.Location, new FieldBlockData(this, loc, token.BlockId, token.BlockData, token.EmptyId, token.EmptyData, token.StockMax, token.StockRegenTime, token.Loot));
|
||||
@ -410,4 +248,49 @@ public class FieldBlock extends AModule
|
||||
|
||||
return null;
|
||||
}
|
||||
|
||||
public Energy getEnergy()
|
||||
{
|
||||
return _energy;
|
||||
}
|
||||
|
||||
public HashSet<String> getActive()
|
||||
{
|
||||
return _active;
|
||||
}
|
||||
|
||||
public WeakHashMap<Player, String> getLootString()
|
||||
{
|
||||
return _lootString;
|
||||
}
|
||||
|
||||
public WeakHashMap<Player, Integer> getEmptyId()
|
||||
{
|
||||
return _emptyId;
|
||||
}
|
||||
|
||||
public WeakHashMap<Player, Byte> getEmptyData()
|
||||
{
|
||||
return _emptyData;
|
||||
}
|
||||
|
||||
public WeakHashMap<Player, Double> getRegen()
|
||||
{
|
||||
return _regen;
|
||||
}
|
||||
|
||||
public WeakHashMap<Player, Integer> getStock()
|
||||
{
|
||||
return _stock;
|
||||
}
|
||||
|
||||
public WeakHashMap<Player, String> getTitle()
|
||||
{
|
||||
return null;
|
||||
}
|
||||
|
||||
public ConditionFactory getCondition()
|
||||
{
|
||||
return _conditionFactory;
|
||||
}
|
||||
}
|
@ -53,7 +53,7 @@ public class FieldBlockData
|
||||
|
||||
if (loot.length != 5)
|
||||
{
|
||||
Field.Log("Loot Failure: " + cur);
|
||||
System.out.println("Loot Failure: " + cur);
|
||||
continue;
|
||||
}
|
||||
|
||||
@ -68,7 +68,7 @@ public class FieldBlockData
|
||||
}
|
||||
catch (Exception e)
|
||||
{
|
||||
Field.Log("Loot Failure: " + cur);
|
||||
System.out.println("Loot Failure: " + cur);
|
||||
}
|
||||
}
|
||||
|
||||
@ -129,7 +129,7 @@ public class FieldBlockData
|
||||
|
||||
public void handleMined(Player player)
|
||||
{
|
||||
if (!Field.Energy().use(player, "Mine Field Block", 60, true, true))
|
||||
if (!Field.getEnergy().Use(player, "Mine Field Block", 60, true, true))
|
||||
return;
|
||||
|
||||
//Set Break Time - Avoid Instant Regen
|
||||
@ -151,7 +151,7 @@ public class FieldBlockData
|
||||
}
|
||||
|
||||
//Slow
|
||||
Field.Condition().Factory().Slow("Field Slow", player, player, 6, 1, false, true, false);
|
||||
Field.getCondition().Slow("Field Slow", player, player, 6, 1, false, true, false, false);
|
||||
}
|
||||
|
||||
public boolean tryMine()
|
@ -0,0 +1,174 @@
|
||||
package me.chiss.Core.Field;
|
||||
|
||||
import java.util.HashSet;
|
||||
import java.util.WeakHashMap;
|
||||
|
||||
import org.bukkit.Location;
|
||||
import org.bukkit.entity.EntityType;
|
||||
import org.bukkit.entity.Player;
|
||||
import org.bukkit.event.HandlerList;
|
||||
import org.bukkit.plugin.java.JavaPlugin;
|
||||
|
||||
import mineplex.core.MiniPlugin;
|
||||
import mineplex.core.common.Rank;
|
||||
import mineplex.core.common.util.F;
|
||||
import mineplex.core.common.util.UtilEnt;
|
||||
import mineplex.core.common.util.UtilPlayer;
|
||||
import mineplex.core.common.util.UtilServer;
|
||||
import mineplex.core.common.util.UtilWorld;
|
||||
import mineplex.core.creature.Creature;
|
||||
import me.chiss.Core.Field.Monsters.FieldMonsterBase;
|
||||
import me.chiss.Core.Field.repository.FieldMonsterToken;
|
||||
import me.chiss.Core.Field.repository.FieldRepository;
|
||||
|
||||
public class FieldMonster extends MiniPlugin
|
||||
{
|
||||
private Creature _creature;
|
||||
private FieldRepository _repository;
|
||||
private HashSet<FieldMonsterBase> _pits;
|
||||
private String _serverName;
|
||||
|
||||
private WeakHashMap<Player, FieldMonsterInput> _input = new WeakHashMap<Player, FieldMonsterInput>();
|
||||
|
||||
public FieldMonster(JavaPlugin plugin, FieldRepository repository, Creature creature, String serverName)
|
||||
{
|
||||
super("Field Monster", plugin);
|
||||
|
||||
_repository = repository;
|
||||
_creature = creature;
|
||||
_pits = new HashSet<FieldMonsterBase>();
|
||||
_serverName = serverName;
|
||||
|
||||
Load();
|
||||
}
|
||||
|
||||
public void Help(Player caller)
|
||||
{
|
||||
UtilPlayer.message(caller, F.main(GetName(), "Commands List;"));
|
||||
UtilPlayer.message(caller, F.help("/fm type <Monster>", "Set Monster Type", Rank.ADMIN));
|
||||
UtilPlayer.message(caller, F.help("/fm max <#>", "Set Monster Limit", Rank.ADMIN));
|
||||
UtilPlayer.message(caller, F.help("/fm rate <Minutes>", "Set Monster Rate", Rank.ADMIN));
|
||||
UtilPlayer.message(caller, F.help("/fm radius <#>", "Set Area Radius", Rank.ADMIN));
|
||||
UtilPlayer.message(caller, F.help("/fm height <#>", "Set Area Height", Rank.ADMIN));
|
||||
UtilPlayer.message(caller, F.help("/fm create <Name>", "Create at your Location", Rank.ADMIN));
|
||||
UtilPlayer.message(caller, F.help("/fm delete <Name>", "Delete Field", Rank.ADMIN));
|
||||
UtilPlayer.message(caller, F.help("/fm list", "List Monster Fields", Rank.ADMIN));
|
||||
UtilPlayer.message(caller, F.help("/fm info <Name>", "Display Monster Field", Rank.ADMIN));
|
||||
UtilPlayer.message(caller, F.help("/fm kill", "Kills all Field Monsters", Rank.ADMIN));
|
||||
UtilPlayer.message(caller, F.help("/fm wipe", "Delete All Monster Field (Database)", Rank.ADMIN));
|
||||
}
|
||||
|
||||
public void Create(Player caller, String name)
|
||||
{
|
||||
FieldMonsterInput input = _input.get(caller);
|
||||
|
||||
if (input.type == null)
|
||||
{
|
||||
UtilPlayer.message(caller, F.main(GetName(), "You have not set Monster Type."));
|
||||
return;
|
||||
}
|
||||
|
||||
for (FieldMonsterBase pit : _pits)
|
||||
{
|
||||
if (name.equalsIgnoreCase(pit.GetName()))
|
||||
{
|
||||
UtilPlayer.message(caller, F.main(GetName(), "Monster Field with this name already exists."));
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
FieldMonsterBase pit = new FieldMonsterBase(this, name, _serverName, input.type, input.mobMax, input.mobRate, caller.getLocation(), input.radius, input.height);
|
||||
Add(pit, true);
|
||||
|
||||
UtilPlayer.message(caller, F.main(GetName(), "You created Monster Field."));
|
||||
pit.Display(caller);
|
||||
}
|
||||
|
||||
private void Add(FieldMonsterBase pit, boolean repo)
|
||||
{
|
||||
UtilServer.getServer().getPluginManager().registerEvents(pit, GetPlugin());
|
||||
_pits.add(pit);
|
||||
|
||||
if (repo)
|
||||
_repository.addFieldMonster(pit.GetToken());
|
||||
}
|
||||
|
||||
public void Delete(Player caller, String name)
|
||||
{
|
||||
HashSet<FieldMonsterBase> remove = new HashSet<FieldMonsterBase>();
|
||||
|
||||
for (FieldMonsterBase pit : _pits)
|
||||
if (pit.GetName().equalsIgnoreCase(name))
|
||||
remove.add(pit);
|
||||
|
||||
int i = remove.size();
|
||||
|
||||
for (FieldMonsterBase pit : remove)
|
||||
Delete(pit, true);
|
||||
|
||||
UtilPlayer.message(caller, F.main(GetName(), "Deleted " + i + " Monster Field(s)."));
|
||||
}
|
||||
|
||||
private void Delete(FieldMonsterBase pit, boolean repo)
|
||||
{
|
||||
_pits.remove(pit);
|
||||
pit.RemoveMonsters();
|
||||
HandlerList.unregisterAll(pit);
|
||||
|
||||
if (repo)
|
||||
_repository.deleteFieldMonster(_serverName, pit.GetToken().Name);
|
||||
}
|
||||
|
||||
public void Wipe(Player player, boolean repo)
|
||||
{
|
||||
HashSet<FieldMonsterBase> remove = new HashSet<FieldMonsterBase>();
|
||||
|
||||
for (FieldMonsterBase pit : _pits)
|
||||
remove.add(pit);
|
||||
|
||||
_pits.clear();
|
||||
|
||||
for (FieldMonsterBase pit : remove)
|
||||
Delete(pit, repo);
|
||||
|
||||
UtilPlayer.message(player, F.main(_moduleName, "Field Monsters Wiped."));
|
||||
}
|
||||
|
||||
private void Load()
|
||||
{
|
||||
Wipe(null, false);
|
||||
|
||||
for (FieldMonsterToken token : _repository.getFieldMonsters(_serverName))
|
||||
{
|
||||
EntityType type = UtilEnt.searchEntity(null, token.Type, false);
|
||||
if (type == null) continue;
|
||||
|
||||
Location loc = UtilWorld.strToLoc(token.Centre);
|
||||
if (loc == null) continue;
|
||||
|
||||
FieldMonsterBase pit = new FieldMonsterBase(this, token.Name, _serverName, type, token.MobMax, token.MobRate, loc, token.Radius, token.Height);
|
||||
Add(pit, false);
|
||||
}
|
||||
}
|
||||
|
||||
private void Clean()
|
||||
{
|
||||
for (FieldMonsterBase pit : _pits)
|
||||
pit.RemoveMonsters();
|
||||
}
|
||||
|
||||
public WeakHashMap<Player, FieldMonsterInput> getInput()
|
||||
{
|
||||
return _input;
|
||||
}
|
||||
|
||||
public HashSet<FieldMonsterBase> getPits()
|
||||
{
|
||||
return _pits;
|
||||
}
|
||||
|
||||
public Creature getCreature()
|
||||
{
|
||||
return _creature;
|
||||
}
|
||||
}
|
@ -3,8 +3,6 @@ package me.chiss.Core.Field;
|
||||
import java.util.ArrayList;
|
||||
import java.util.HashSet;
|
||||
|
||||
import nautilus.minecraft.core.webserver.token.Server.FieldOreToken;
|
||||
|
||||
import org.bukkit.Effect;
|
||||
import org.bukkit.Location;
|
||||
import org.bukkit.Material;
|
||||
@ -16,20 +14,24 @@ import org.bukkit.event.block.BlockBreakEvent;
|
||||
import org.bukkit.event.player.PlayerInteractEvent;
|
||||
import org.bukkit.plugin.java.JavaPlugin;
|
||||
|
||||
import me.chiss.Core.Module.AModule;
|
||||
import mineplex.core.server.IRepository;
|
||||
import me.chiss.Core.Field.repository.FieldOreToken;
|
||||
import me.chiss.Core.Field.repository.FieldRepository;
|
||||
import mineplex.core.MiniPlugin;
|
||||
import mineplex.core.updater.event.UpdateEvent;
|
||||
import mineplex.core.updater.UpdateType;
|
||||
import mineplex.core.common.Rank;
|
||||
import mineplex.core.common.util.F;
|
||||
import mineplex.core.common.util.UtilEvent;
|
||||
import mineplex.core.common.util.UtilGear;
|
||||
import mineplex.core.common.util.UtilMath;
|
||||
import mineplex.core.common.util.UtilPlayer;
|
||||
import mineplex.core.common.util.UtilTime;
|
||||
import mineplex.core.common.util.UtilWorld;
|
||||
import mineplex.core.common.util.UtilEvent.ActionType;
|
||||
|
||||
public class FieldOre extends AModule
|
||||
public class FieldOre extends MiniPlugin
|
||||
{
|
||||
private FieldRepository _repository;
|
||||
private HashSet<String> _active = new HashSet<String>();
|
||||
|
||||
private ArrayList<FieldOreData> _oreInactive = new ArrayList<FieldOreData>();
|
||||
@ -42,87 +44,16 @@ public class FieldOre extends AModule
|
||||
|
||||
private String _serverName;
|
||||
|
||||
public FieldOre(JavaPlugin plugin, IRepository repository, String serverName)
|
||||
public FieldOre(JavaPlugin plugin, FieldRepository repository, String serverName)
|
||||
{
|
||||
super("Field Ore", plugin, repository);
|
||||
super("Field Ore", plugin);
|
||||
|
||||
_repository = repository;
|
||||
_serverName = serverName;
|
||||
|
||||
load();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void enable()
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public void disable()
|
||||
{
|
||||
clean();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void config()
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public void commands()
|
||||
{
|
||||
AddCommand("fo");
|
||||
}
|
||||
|
||||
@Override
|
||||
public void command(Player caller, String cmd, String[] args)
|
||||
{
|
||||
if (!Clients().Get(caller).Rank().Has(Rank.ADMIN, true))
|
||||
return;
|
||||
|
||||
if (args.length == 0)
|
||||
{
|
||||
help(caller);
|
||||
return;
|
||||
}
|
||||
|
||||
if (args[0].equalsIgnoreCase("toggle"))
|
||||
{
|
||||
if (!_active.remove(caller.getName()))
|
||||
_active.add(caller.getName());
|
||||
|
||||
UtilPlayer.message(caller, F.main(GetName(), "Interact Active: " + F.tf(_active.contains(caller.getName()))));
|
||||
}
|
||||
|
||||
else if (args[0].equalsIgnoreCase("help"))
|
||||
{
|
||||
help(caller);
|
||||
}
|
||||
|
||||
else if (args[0].equalsIgnoreCase("reset"))
|
||||
{
|
||||
reset(caller);
|
||||
}
|
||||
|
||||
else if (args[0].equalsIgnoreCase("fill"))
|
||||
{
|
||||
fill(caller);
|
||||
}
|
||||
|
||||
else if (args[0].equalsIgnoreCase("list"))
|
||||
{
|
||||
list(caller);
|
||||
}
|
||||
|
||||
else if (args[0].equalsIgnoreCase("wipe"))
|
||||
{
|
||||
wipe(caller);
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
||||
public void help(Player caller)
|
||||
{
|
||||
UtilPlayer.message(caller, F.main(_moduleName, "Commands List;"));
|
||||
@ -139,17 +70,17 @@ public class FieldOre extends AModule
|
||||
if (!_active.contains(event.getPlayer().getName()))
|
||||
return;
|
||||
|
||||
if (Util().Gear().isMat(event.getPlayer().getItemInHand(), Material.DIAMOND))
|
||||
if (UtilGear.isMat(event.getPlayer().getItemInHand(), Material.DIAMOND))
|
||||
{
|
||||
if (Util().Event().isAction(event, ActionType.L))
|
||||
if (UtilEvent.isAction(event, ActionType.L))
|
||||
addBlock(event.getPlayer(), event);
|
||||
|
||||
else if (Util().Event().isAction(event, ActionType.R_BLOCK))
|
||||
else if (UtilEvent.isAction(event, ActionType.R_BLOCK))
|
||||
delBlock(event.getPlayer(), event);
|
||||
}
|
||||
}
|
||||
|
||||
private void reset(Player player)
|
||||
public void reset(Player player)
|
||||
{
|
||||
for (FieldOreData ore : _oreActive)
|
||||
{
|
||||
@ -162,7 +93,7 @@ public class FieldOre extends AModule
|
||||
UtilPlayer.message(player, F.main(_moduleName, "Field Ore Reset."));
|
||||
}
|
||||
|
||||
private void fill(Player player)
|
||||
public void fill(Player player)
|
||||
{
|
||||
while (!_oreInactive.isEmpty())
|
||||
_oreInactive.get(UtilMath.r(_oreInactive.size())).StartVein(2 + UtilMath.r(5));
|
||||
@ -170,20 +101,20 @@ public class FieldOre extends AModule
|
||||
UtilPlayer.message(player, F.main(_moduleName, "Field Ore Generated."));
|
||||
}
|
||||
|
||||
private void list(Player player)
|
||||
public void list(Player player)
|
||||
{
|
||||
UtilPlayer.message(player, F.main(_moduleName, F.value("Total", ""+_oreLocations.size())));
|
||||
UtilPlayer.message(player, F.main(_moduleName, F.value("Active", ""+_oreActive.size())));
|
||||
UtilPlayer.message(player, F.main(_moduleName, F.value("Inactive", ""+_oreInactive.size())));
|
||||
}
|
||||
|
||||
private void wipe(Player player)
|
||||
public void wipe(Player player)
|
||||
{
|
||||
reset(player);
|
||||
|
||||
for (Location loc : _oreLocations)
|
||||
{
|
||||
GetRepository().DeleteFieldOre(_serverName, UtilWorld.locToStr(loc));
|
||||
_repository.deleteFieldOre(_serverName, UtilWorld.locToStr(loc));
|
||||
}
|
||||
|
||||
_oreInactive.clear();
|
||||
@ -194,9 +125,6 @@ public class FieldOre extends AModule
|
||||
|
||||
private void addBlock(Player player, PlayerInteractEvent event)
|
||||
{
|
||||
if (!Clients().Get(player).Rank().Has(Rank.ADMIN, false))
|
||||
return;
|
||||
|
||||
Block block = player.getTargetBlock(null, 0);
|
||||
|
||||
if (Get(block.getLocation()) != null)
|
||||
@ -209,7 +137,7 @@ public class FieldOre extends AModule
|
||||
FieldOreToken token = new FieldOreToken();
|
||||
token.Server = _serverName;
|
||||
token.Location = UtilWorld.locToStr(block.getLocation());
|
||||
GetRepository().AddFieldOre(token);
|
||||
_repository.addFieldOre(token);
|
||||
|
||||
//Memory
|
||||
_oreInactive.add(new FieldOreData(this, block.getLocation()));
|
||||
@ -223,9 +151,6 @@ public class FieldOre extends AModule
|
||||
|
||||
private void delBlock(Player player, PlayerInteractEvent event)
|
||||
{
|
||||
if (!Clients().Get(player).Rank().Has(Rank.ADMIN, false))
|
||||
return;
|
||||
|
||||
event.setCancelled(true);
|
||||
|
||||
FieldOreData ore = Get(event.getPlayer().getTargetBlock(null, 0).getLocation());
|
||||
@ -236,7 +161,7 @@ public class FieldOre extends AModule
|
||||
return;
|
||||
}
|
||||
|
||||
GetRepository().DeleteFieldOre(_serverName, UtilWorld.locToStr(event.getClickedBlock().getLocation()));
|
||||
_repository.deleteFieldOre(_serverName, UtilWorld.locToStr(event.getClickedBlock().getLocation()));
|
||||
|
||||
ore.GetLocation().getBlock().setType(Material.STONE);
|
||||
|
||||
@ -320,7 +245,7 @@ public class FieldOre extends AModule
|
||||
{
|
||||
clean();
|
||||
|
||||
for (FieldOreToken token : GetRepository().GetFieldOres(_serverName))
|
||||
for (FieldOreToken token : _repository.getFieldOres(_serverName))
|
||||
{
|
||||
Location loc = UtilWorld.strToLoc(token.Location);
|
||||
|
||||
@ -337,4 +262,9 @@ public class FieldOre extends AModule
|
||||
_oreActive.clear();
|
||||
_oreLocations.clear();
|
||||
}
|
||||
|
||||
public HashSet<String> getActivePlayers()
|
||||
{
|
||||
return _active;
|
||||
}
|
||||
}
|
@ -6,6 +6,7 @@ import java.util.HashSet;
|
||||
|
||||
import me.chiss.Core.Field.FieldMonster;
|
||||
import me.chiss.Core.Field.UtilField;
|
||||
import me.chiss.Core.Field.repository.FieldMonsterToken;
|
||||
import mineplex.core.updater.event.UpdateEvent;
|
||||
import mineplex.core.updater.UpdateType;
|
||||
import mineplex.core.common.util.F;
|
||||
@ -14,13 +15,12 @@ import mineplex.core.common.util.UtilMath;
|
||||
import mineplex.core.common.util.UtilPlayer;
|
||||
import mineplex.core.common.util.UtilTime;
|
||||
import mineplex.core.common.util.UtilWorld;
|
||||
import nautilus.minecraft.core.webserver.token.Server.FieldMonsterToken;
|
||||
import net.minecraft.server.v1_6_R3.EntityCreature;
|
||||
import net.minecraft.server.v1_6_R3.Navigation;
|
||||
import net.minecraft.server.v1_7_R4.EntityCreature;
|
||||
import net.minecraft.server.v1_7_R4.Navigation;
|
||||
|
||||
import org.bukkit.Location;
|
||||
import org.bukkit.block.Block;
|
||||
import org.bukkit.craftbukkit.v1_6_R3.entity.CraftCreature;
|
||||
import org.bukkit.craftbukkit.v1_7_R4.entity.CraftCreature;
|
||||
import org.bukkit.entity.Entity;
|
||||
import org.bukkit.entity.EntityType;
|
||||
import org.bukkit.entity.Player;
|
||||
@ -84,7 +84,7 @@ public class FieldMonsterBase implements Listener
|
||||
|
||||
_mobLast = System.currentTimeMillis();
|
||||
|
||||
Entity ent = Manager.Creature().SpawnEntity(SelectLocation(), _type);
|
||||
Entity ent = Manager.getCreature().SpawnEntity(SelectLocation(), _type);
|
||||
_mobs.put(ent, 0);
|
||||
}
|
||||
|
@ -0,0 +1,145 @@
|
||||
package me.chiss.Core.Field.commands;
|
||||
|
||||
import org.bukkit.entity.Player;
|
||||
|
||||
import me.chiss.Core.Field.FieldBlock;
|
||||
import mineplex.core.command.CommandBase;
|
||||
import mineplex.core.common.Rank;
|
||||
import mineplex.core.common.util.F;
|
||||
import mineplex.core.common.util.UtilMath;
|
||||
import mineplex.core.common.util.UtilPlayer;
|
||||
|
||||
public class FieldBlockCommand extends CommandBase<FieldBlock>
|
||||
{
|
||||
public FieldBlockCommand(FieldBlock plugin)
|
||||
{
|
||||
super(plugin, Rank.ADMIN, "fb");
|
||||
}
|
||||
|
||||
@Override
|
||||
public void Execute(Player caller, String[] args)
|
||||
{
|
||||
if (args[0].equalsIgnoreCase("toggle"))
|
||||
{
|
||||
if (!Plugin.getActive().remove(caller.getName()))
|
||||
Plugin.getActive().add(caller.getName());
|
||||
|
||||
UtilPlayer.message(caller, F.main(Plugin.GetName(), "Interact Active: " + F.tf(Plugin.getActive().contains(caller.getName()))));
|
||||
}
|
||||
|
||||
else if (args[0].equalsIgnoreCase("load"))
|
||||
{
|
||||
Plugin.load();
|
||||
UtilPlayer.message(caller, F.main(Plugin.GetName(), "Reloaded Field Blocks from Database."));
|
||||
}
|
||||
|
||||
else if (args[0].equalsIgnoreCase("wipe"))
|
||||
{
|
||||
Plugin.wipe(caller);
|
||||
}
|
||||
|
||||
else if (args[0].equalsIgnoreCase("help"))
|
||||
{
|
||||
Plugin.help(caller);
|
||||
}
|
||||
|
||||
else if (args.length <= 1)
|
||||
{
|
||||
Plugin.help(caller);
|
||||
}
|
||||
|
||||
else if (args[0].equalsIgnoreCase("title"))
|
||||
{
|
||||
Plugin.getTitle().put(caller, args[1]);
|
||||
Plugin.showSettings(caller);
|
||||
}
|
||||
|
||||
else if (args[0].equalsIgnoreCase("stock"))
|
||||
{
|
||||
try
|
||||
{
|
||||
int count = Integer.parseInt(args[1]);
|
||||
if (count < 1) count = 1;
|
||||
Plugin.getStock().put(caller, count);
|
||||
Plugin.showSettings(caller);
|
||||
}
|
||||
catch (Exception e)
|
||||
{
|
||||
UtilPlayer.message(caller, F.main(Plugin.GetName(), "Invalid Stock Max."));
|
||||
}
|
||||
}
|
||||
|
||||
else if (args[0].equalsIgnoreCase("regen"))
|
||||
{
|
||||
try
|
||||
{
|
||||
double regen = Double.parseDouble(args[1]);
|
||||
if (regen < 0) regen = 0;
|
||||
Plugin.getRegen().put(caller, UtilMath.trim(1, regen));
|
||||
Plugin.showSettings(caller);
|
||||
}
|
||||
catch (Exception e)
|
||||
{
|
||||
UtilPlayer.message(caller, F.main(Plugin.GetName(), "Invalid Stock Regeneration Time."));
|
||||
}
|
||||
}
|
||||
|
||||
else if (args[0].equalsIgnoreCase("empty"))
|
||||
{
|
||||
try
|
||||
{
|
||||
String[] toks = args[1].split(":");
|
||||
|
||||
int id = Integer.parseInt(toks[0]);
|
||||
byte data = Byte.parseByte(toks[1]);
|
||||
|
||||
Plugin.getEmptyId().put(caller, id);
|
||||
Plugin.getEmptyData().put(caller, data);
|
||||
Plugin.showSettings(caller);
|
||||
}
|
||||
catch (Exception e)
|
||||
{
|
||||
UtilPlayer.message(caller, F.main(Plugin.GetName(), "Invalid Empty Block."));
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
else if (args[0].equalsIgnoreCase("loot"))
|
||||
{
|
||||
boolean error = false;
|
||||
for (String cur : args[1].split(","))
|
||||
{
|
||||
String[] loot = cur.split(":");
|
||||
|
||||
if (loot.length != 5)
|
||||
{
|
||||
error = true;
|
||||
break;
|
||||
}
|
||||
|
||||
try
|
||||
{
|
||||
Integer.parseInt(loot[0]);
|
||||
Byte.parseByte(loot[1]);
|
||||
Integer.parseInt(loot[2]);
|
||||
Integer.parseInt(loot[3]);
|
||||
Integer.parseInt(loot[4]);
|
||||
}
|
||||
catch (Exception e)
|
||||
{
|
||||
error = true;
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
if (error)
|
||||
{
|
||||
UtilPlayer.message(caller, F.main(Plugin.GetName(), "Invalid Loot String."));
|
||||
return;
|
||||
}
|
||||
|
||||
Plugin.getLootString().put(caller, args[1]);
|
||||
Plugin.showSettings(caller);
|
||||
}
|
||||
}
|
||||
}
|
@ -0,0 +1,170 @@
|
||||
package me.chiss.Core.Field.commands;
|
||||
|
||||
import org.bukkit.entity.Player;
|
||||
|
||||
import me.chiss.Core.Field.FieldMonster;
|
||||
import me.chiss.Core.Field.FieldMonsterInput;
|
||||
import me.chiss.Core.Field.Monsters.FieldMonsterBase;
|
||||
import mineplex.core.command.CommandBase;
|
||||
import mineplex.core.common.Rank;
|
||||
import mineplex.core.common.util.F;
|
||||
import mineplex.core.common.util.UtilEnt;
|
||||
import mineplex.core.common.util.UtilPlayer;
|
||||
|
||||
public class FieldMonsterCommand extends CommandBase<FieldMonster>
|
||||
{
|
||||
public FieldMonsterCommand(FieldMonster plugin)
|
||||
{
|
||||
super(plugin, Rank.ADMIN, "fm");
|
||||
}
|
||||
|
||||
@Override
|
||||
public void Execute(Player caller, String[] args)
|
||||
{
|
||||
if (!Plugin.getInput().containsKey(caller))
|
||||
Plugin.getInput().put(caller, new FieldMonsterInput());
|
||||
|
||||
FieldMonsterInput input = Plugin.getInput().get(caller);
|
||||
|
||||
if (args.length == 0)
|
||||
{
|
||||
Plugin.getInput().get(caller).Display(caller);
|
||||
UtilPlayer.message(caller, F.main(Plugin.GetName(), "Type " + F.elem("/fm help") + " for commands."));
|
||||
}
|
||||
|
||||
else if (args[0].equalsIgnoreCase("help"))
|
||||
{
|
||||
Plugin.Help(caller);
|
||||
}
|
||||
|
||||
else if (args[0].equalsIgnoreCase("type"))
|
||||
{
|
||||
try
|
||||
{
|
||||
input.type = UtilEnt.searchEntity(caller, args[1], true);
|
||||
if (input.type != null)
|
||||
input.Display(caller);
|
||||
}
|
||||
catch (Exception e)
|
||||
{
|
||||
UtilPlayer.message(caller, F.main(Plugin.GetName(), "Invalid Monster Type."));
|
||||
}
|
||||
}
|
||||
|
||||
else if (args[0].equalsIgnoreCase("max"))
|
||||
{
|
||||
try
|
||||
{
|
||||
int value = Integer.parseInt(args[1]);
|
||||
if (value < 1) value = 1;
|
||||
input.mobMax = value;
|
||||
input.Display(caller);
|
||||
}
|
||||
catch (Exception e)
|
||||
{
|
||||
UtilPlayer.message(caller, F.main(Plugin.GetName(), "Invalid Monster Max."));
|
||||
}
|
||||
}
|
||||
|
||||
else if (args[0].equalsIgnoreCase("rate"))
|
||||
{
|
||||
try
|
||||
{
|
||||
double value = Double.parseDouble(args[1]);
|
||||
if (value < 0) value = 0;
|
||||
input.mobRate = value;
|
||||
input.Display(caller);
|
||||
}
|
||||
catch (Exception e)
|
||||
{
|
||||
UtilPlayer.message(caller, F.main(Plugin.GetName(), "Invalid Monster Rate."));
|
||||
}
|
||||
}
|
||||
|
||||
else if (args[0].equalsIgnoreCase("radius"))
|
||||
{
|
||||
try
|
||||
{
|
||||
int integer = Integer.parseInt(args[1]);
|
||||
if (integer < 1) integer = 1;
|
||||
input.radius = integer;
|
||||
input.Display(caller);
|
||||
}
|
||||
catch (Exception e)
|
||||
{
|
||||
UtilPlayer.message(caller, F.main(Plugin.GetName(), "Invalid Area Radius."));
|
||||
}
|
||||
}
|
||||
|
||||
else if (args[0].equalsIgnoreCase("height"))
|
||||
{
|
||||
try
|
||||
{
|
||||
int integer = Integer.parseInt(args[1]);
|
||||
if (integer < 1) integer = 1;
|
||||
input.height = integer;
|
||||
input.Display(caller);
|
||||
}
|
||||
catch (Exception e)
|
||||
{
|
||||
UtilPlayer.message(caller, F.main(Plugin.GetName(), "Invalid Area Height."));
|
||||
}
|
||||
}
|
||||
|
||||
else if (args[0].equalsIgnoreCase("create"))
|
||||
{
|
||||
if (args.length < 2)
|
||||
{
|
||||
UtilPlayer.message(caller, F.main(Plugin.GetName(), "Missing Monster Field Name."));
|
||||
}
|
||||
else
|
||||
{
|
||||
Plugin.Create(caller, args[1]);
|
||||
}
|
||||
}
|
||||
|
||||
else if (args[0].equalsIgnoreCase("delete"))
|
||||
{
|
||||
if (args.length < 2)
|
||||
{
|
||||
UtilPlayer.message(caller, F.main(Plugin.GetName(), "Missing Monster Field Name."));
|
||||
}
|
||||
else
|
||||
{
|
||||
Plugin.Delete(caller, args[1]);
|
||||
}
|
||||
}
|
||||
|
||||
else if (args[0].equalsIgnoreCase("list"))
|
||||
{
|
||||
UtilPlayer.message(caller, F.main(Plugin.GetName(), "Listing Monster Fields;"));
|
||||
|
||||
for (FieldMonsterBase pit : Plugin.getPits())
|
||||
pit.Display(caller);
|
||||
}
|
||||
|
||||
else if (args[0].equalsIgnoreCase("info"))
|
||||
{
|
||||
UtilPlayer.message(caller, F.main(Plugin.GetName(), "Listing Monster Fields;"));
|
||||
|
||||
for (FieldMonsterBase pit : Plugin.getPits())
|
||||
pit.Display(caller);
|
||||
}
|
||||
|
||||
else if (args[0].equalsIgnoreCase("wipe"))
|
||||
{
|
||||
Plugin.Wipe(caller, true);
|
||||
}
|
||||
|
||||
else if (args[0].equalsIgnoreCase("kill"))
|
||||
{
|
||||
for (FieldMonsterBase pit : Plugin.getPits())
|
||||
pit.RemoveMonsters();
|
||||
}
|
||||
|
||||
else
|
||||
{
|
||||
UtilPlayer.message(caller, F.main(Plugin.GetName(), "Invalid Command."));
|
||||
}
|
||||
}
|
||||
}
|
@ -0,0 +1,60 @@
|
||||
package me.chiss.Core.Field.commands;
|
||||
|
||||
import org.bukkit.entity.Player;
|
||||
|
||||
import me.chiss.Core.Field.FieldOre;
|
||||
import mineplex.core.command.CommandBase;
|
||||
import mineplex.core.common.Rank;
|
||||
import mineplex.core.common.util.F;
|
||||
import mineplex.core.common.util.UtilPlayer;
|
||||
|
||||
public class FieldOreCommand extends CommandBase<FieldOre>
|
||||
{
|
||||
public FieldOreCommand(FieldOre plugin)
|
||||
{
|
||||
super(plugin, Rank.ADMIN, "fo");
|
||||
}
|
||||
|
||||
@Override
|
||||
public void Execute(Player caller, String[] args)
|
||||
{
|
||||
if (args.length == 0)
|
||||
{
|
||||
Plugin.help(caller);
|
||||
return;
|
||||
}
|
||||
|
||||
if (args[0].equalsIgnoreCase("toggle"))
|
||||
{
|
||||
if (!Plugin.getActivePlayers().remove(caller.getName()))
|
||||
Plugin.getActivePlayers().add(caller.getName());
|
||||
|
||||
UtilPlayer.message(caller, F.main(Plugin.GetName(), "Interact Active: " + F.tf(Plugin.getActivePlayers().contains(caller.getName()))));
|
||||
}
|
||||
|
||||
else if (args[0].equalsIgnoreCase("help"))
|
||||
{
|
||||
Plugin.help(caller);
|
||||
}
|
||||
|
||||
else if (args[0].equalsIgnoreCase("reset"))
|
||||
{
|
||||
Plugin.reset(caller);
|
||||
}
|
||||
|
||||
else if (args[0].equalsIgnoreCase("fill"))
|
||||
{
|
||||
Plugin.fill(caller);
|
||||
}
|
||||
|
||||
else if (args[0].equalsIgnoreCase("list"))
|
||||
{
|
||||
Plugin.list(caller);
|
||||
}
|
||||
|
||||
else if (args[0].equalsIgnoreCase("wipe"))
|
||||
{
|
||||
Plugin.wipe(caller);
|
||||
}
|
||||
}
|
||||
}
|
@ -0,0 +1,14 @@
|
||||
package me.chiss.Core.Field.repository;
|
||||
|
||||
public class FieldBlockToken
|
||||
{
|
||||
public String Server;
|
||||
public String Location;
|
||||
public int BlockId;
|
||||
public byte BlockData;
|
||||
public int EmptyId;
|
||||
public byte EmptyData;
|
||||
public int StockMax;
|
||||
public double StockRegenTime;
|
||||
public String Loot;
|
||||
}
|
@ -0,0 +1,13 @@
|
||||
package me.chiss.Core.Field.repository;
|
||||
|
||||
public class FieldMonsterToken
|
||||
{
|
||||
public String Name;
|
||||
public String Server;
|
||||
public String Type;
|
||||
public int MobMax;
|
||||
public double MobRate;
|
||||
public String Centre;
|
||||
public int Radius;
|
||||
public int Height;
|
||||
}
|
@ -0,0 +1,7 @@
|
||||
package me.chiss.Core.Field.repository;
|
||||
|
||||
public class FieldOreToken
|
||||
{
|
||||
public String Server;
|
||||
public String Location;
|
||||
}
|
@ -0,0 +1,182 @@
|
||||
package me.chiss.Core.Field.repository;
|
||||
|
||||
import java.sql.ResultSet;
|
||||
import java.sql.SQLException;
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
import org.bukkit.plugin.java.JavaPlugin;
|
||||
|
||||
import mineplex.core.database.RepositoryBase;
|
||||
import mineplex.core.database.ResultSetCallable;
|
||||
import mineplex.core.database.column.ColumnByte;
|
||||
import mineplex.core.database.column.ColumnDouble;
|
||||
import mineplex.core.database.column.ColumnInt;
|
||||
import mineplex.core.database.column.ColumnVarChar;
|
||||
|
||||
public class FieldRepository extends RepositoryBase
|
||||
{
|
||||
private static String CREATE_FIELD_BLOCK_TABLE = "CREATE TABLE IF NOT EXISTS fieldBlock (id INT NOT NULL AUTO_INCREMENT, server VARCHAR(100), location VARCHAR(100), blockId INT, blockData TINYINT, emptyId INT, emptyData TINYINT, stockMax INT, stockRegenTime DOUBLE, loot VARCHAR(100) PRIMARY KEY (id), INDEX serverLocation (server, location));";
|
||||
private static String CREATE_FIELD_ORE_TABLE = "CREATE TABLE IF NOT EXISTS fieldOre (id INT NOT NULL AUTO_INCREMENT, server VARCHAR(100), location VARCHAR(100), PRIMARY KEY (id), INDEX serverLocation (server, location));";
|
||||
private static String CREATE_FIELD_MONSTER_TABLE = "CREATE TABLE IF NOT EXISTS fieldMonster (id INT NOT NULL AUTO_INCREMENT, server VARCHAR(100), name VARCHAR(100), type VARCHAR(100), mobMax INT, mobRate DOUBLE, center VARCHAR(100), radius INT, height INT PRIMARY KEY (id), INDEX serverName (server, name));";
|
||||
private static String RETRIEVE_FIELD_BLOCKS = "SELECT server, location, blockId, blockData, emptyId, emptyData, stockMax, stockRegen, loot FROM fieldBlock WHERE server = ?;";
|
||||
private static String ADD_FIELD_BLOCK = "INSERT INTO fieldBlock (server, location, blockId, blockData, emptyId, emptyData, stockMax, stockRegen, loot) VALUES (?, ?, ?, ?, ?, ?, ?, ?, ?);";
|
||||
private static String DEL_FIELD_BLOCK = "DELETE FROM fieldBlock WHERE server = ? AND location = ?;";
|
||||
private static String RETRIEVE_FIELD_ORES = "SELECT server, location FROM fieldOre WHERE server = ?;";
|
||||
private static String ADD_FIELD_ORE = "INSERT INTO fieldBlock (server, location) VALUES (?, ?);";
|
||||
private static String DEL_FIELD_ORE = "DELETE FROM fieldOre WHERE server = ? AND location = ?;";
|
||||
private static String RETRIEVE_FIELD_MONSTERS = "SELECT server, name, type, mobMax, mobRate, center, radius, height FROM fieldMonster WHERE server = ?;";
|
||||
private static String ADD_FIELD_MONSTER = "INSERT INTO fieldBlock (server, name, type, mobMax, mobRate, center, radius, height) VALUES (?, ?, ?, ?, ?, ?, ?, ?);";
|
||||
private static String DEL_FIELD_MONSTER = "DELETE FROM fieldBlock WHERE server = ? AND name = ?;";
|
||||
|
||||
public FieldRepository(JavaPlugin plugin)
|
||||
{
|
||||
super(plugin, "jdbc:mysql://db.mineplex.com:3306/Account?autoReconnect=true&failOverReadOnly=false&maxReconnects=10", "root", "tAbechAk3wR7tuTh");
|
||||
}
|
||||
|
||||
public List<FieldBlockToken> getFieldBlocks(String server)
|
||||
{
|
||||
final List<FieldBlockToken> fieldBlocks = new ArrayList<FieldBlockToken>();
|
||||
|
||||
this.executeQuery(RETRIEVE_FIELD_BLOCKS, new ResultSetCallable()
|
||||
{
|
||||
@Override
|
||||
public void processResultSet(ResultSet resultSet) throws SQLException
|
||||
{
|
||||
while (resultSet.next())
|
||||
{
|
||||
FieldBlockToken token = new FieldBlockToken();
|
||||
token.Server = resultSet.getString(1);
|
||||
token.Location = resultSet.getString(2);
|
||||
token.BlockId = resultSet.getInt(3);
|
||||
token.BlockData = resultSet.getByte(4);
|
||||
token.EmptyId = resultSet.getInt(5);
|
||||
token.EmptyData = resultSet.getByte(6);
|
||||
token.StockMax = resultSet.getInt(7);
|
||||
token.StockRegenTime = resultSet.getLong(8);
|
||||
token.Loot = resultSet.getString(9);
|
||||
|
||||
fieldBlocks.add(token);
|
||||
}
|
||||
}
|
||||
}, new ColumnVarChar("server", 100, server));
|
||||
|
||||
return fieldBlocks;
|
||||
}
|
||||
|
||||
public void addFieldBlock(FieldBlockToken token)
|
||||
{
|
||||
executeUpdate(ADD_FIELD_BLOCK,
|
||||
new ColumnVarChar("server", 100, token.Server),
|
||||
new ColumnVarChar("location", 100, token.Location),
|
||||
new ColumnInt("blockId", token.BlockId),
|
||||
new ColumnByte("blockData", token.BlockData),
|
||||
new ColumnInt("emptyId", token.EmptyId),
|
||||
new ColumnByte("emptyData", token.EmptyData),
|
||||
new ColumnInt("stockMax", token.StockMax),
|
||||
new ColumnDouble("stockRegen", token.StockRegenTime),
|
||||
new ColumnVarChar("loot", 100, token.Loot)
|
||||
);
|
||||
}
|
||||
|
||||
public void deleteFieldBlock(String server, String location)
|
||||
{
|
||||
executeUpdate(DEL_FIELD_BLOCK, new ColumnVarChar("server", 100, server), new ColumnVarChar("location", 100, location));
|
||||
}
|
||||
|
||||
public List<FieldOreToken> getFieldOres(String server)
|
||||
{
|
||||
final List<FieldOreToken> fieldOres = new ArrayList<FieldOreToken>();
|
||||
|
||||
this.executeQuery(RETRIEVE_FIELD_ORES, new ResultSetCallable()
|
||||
{
|
||||
@Override
|
||||
public void processResultSet(ResultSet resultSet) throws SQLException
|
||||
{
|
||||
while (resultSet.next())
|
||||
{
|
||||
FieldOreToken token = new FieldOreToken();
|
||||
token.Server = resultSet.getString(1);
|
||||
token.Location = resultSet.getString(2);
|
||||
|
||||
fieldOres.add(token);
|
||||
}
|
||||
}
|
||||
}, new ColumnVarChar("server", 100, server));
|
||||
|
||||
return fieldOres;
|
||||
}
|
||||
|
||||
public void addFieldOre(FieldOreToken token)
|
||||
{
|
||||
executeUpdate(ADD_FIELD_ORE,
|
||||
new ColumnVarChar("server", 100, token.Server),
|
||||
new ColumnVarChar("location", 100, token.Location)
|
||||
);
|
||||
}
|
||||
|
||||
public void deleteFieldOre(String server, String location)
|
||||
{
|
||||
executeUpdate(DEL_FIELD_ORE, new ColumnVarChar("server", 100, server), new ColumnVarChar("location", 100, location));
|
||||
}
|
||||
|
||||
public List<FieldMonsterToken> getFieldMonsters(String server)
|
||||
{
|
||||
List<FieldMonsterToken> fieldMonsters = new ArrayList<FieldMonsterToken>();
|
||||
|
||||
this.executeQuery(RETRIEVE_FIELD_MONSTERS, new ResultSetCallable()
|
||||
{
|
||||
@Override
|
||||
public void processResultSet(ResultSet resultSet) throws SQLException
|
||||
{
|
||||
while (resultSet.next())
|
||||
{
|
||||
FieldMonsterToken token = new FieldMonsterToken();
|
||||
token.Name = resultSet.getString(1);
|
||||
token.Server = resultSet.getString(2);
|
||||
token.Type = resultSet.getString(3);
|
||||
token.MobMax = resultSet.getInt(4);
|
||||
token.MobRate = resultSet.getDouble(5);
|
||||
token.Centre = resultSet.getString(6);
|
||||
token.Radius = resultSet.getInt(7);
|
||||
token.Height = resultSet.getInt(8);
|
||||
}
|
||||
}
|
||||
}, new ColumnVarChar("server", 100, server));
|
||||
|
||||
return fieldMonsters;
|
||||
}
|
||||
|
||||
public void addFieldMonster(FieldMonsterToken token)
|
||||
{
|
||||
executeUpdate(ADD_FIELD_MONSTER,
|
||||
new ColumnVarChar("server", 100, token.Server),
|
||||
new ColumnVarChar("name", 100, token.Name),
|
||||
new ColumnVarChar("blockId", 100, token.Type),
|
||||
new ColumnInt("mobMax", token.MobMax),
|
||||
new ColumnDouble("mobRate", token.MobRate),
|
||||
new ColumnVarChar("center", 100, token.Centre),
|
||||
new ColumnInt("redius", token.Radius),
|
||||
new ColumnInt("height", token.Height)
|
||||
);
|
||||
}
|
||||
|
||||
public void deleteFieldMonster(String server, String name)
|
||||
{
|
||||
executeUpdate(DEL_FIELD_MONSTER, new ColumnVarChar("server", 100, server), new ColumnVarChar("name", 100, name));
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void initialize()
|
||||
{
|
||||
executeUpdate(CREATE_FIELD_BLOCK_TABLE);
|
||||
executeUpdate(CREATE_FIELD_ORE_TABLE);
|
||||
executeUpdate(CREATE_FIELD_MONSTER_TABLE);
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void update()
|
||||
{
|
||||
}
|
||||
|
||||
}
|
147
Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/Clans.java
Normal file
147
Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/Clans.java
Normal file
@ -0,0 +1,147 @@
|
||||
package mineplex.game.clans;
|
||||
|
||||
import java.io.File;
|
||||
|
||||
import mineplex.core.CustomTagFix;
|
||||
import mineplex.core.account.CoreClientManager;
|
||||
import mineplex.core.antihack.AntiHack;
|
||||
import mineplex.core.antistack.AntiStack;
|
||||
import mineplex.core.blockrestore.BlockRestore;
|
||||
import mineplex.core.command.CommandCenter;
|
||||
import mineplex.core.common.util.FileUtil;
|
||||
import mineplex.core.cosmetic.CosmeticManager;
|
||||
import mineplex.core.creature.Creature;
|
||||
import mineplex.core.disguise.DisguiseManager;
|
||||
import mineplex.core.donation.DonationManager;
|
||||
import mineplex.core.friend.FriendManager;
|
||||
import mineplex.core.gadget.GadgetManager;
|
||||
import mineplex.core.inventory.InventoryManager;
|
||||
import mineplex.core.itemstack.ItemStackFactory;
|
||||
import mineplex.core.logger.Logger;
|
||||
import mineplex.core.memory.MemoryFix;
|
||||
import mineplex.core.message.MessageManager;
|
||||
import mineplex.core.monitor.LagMeter;
|
||||
import mineplex.core.mount.MountManager;
|
||||
import mineplex.core.npc.NpcManager;
|
||||
import mineplex.core.packethandler.PacketHandler;
|
||||
import mineplex.core.pet.PetManager;
|
||||
import mineplex.core.portal.Portal;
|
||||
import mineplex.core.preferences.PreferencesManager;
|
||||
import mineplex.core.projectile.ProjectileManager;
|
||||
import mineplex.core.punish.Punish;
|
||||
import mineplex.core.recharge.Recharge;
|
||||
import mineplex.core.serverConfig.ServerConfiguration;
|
||||
import mineplex.core.spawn.Spawn;
|
||||
import mineplex.core.status.ServerStatusManager;
|
||||
import mineplex.core.teleport.Teleport;
|
||||
import mineplex.core.updater.FileUpdater;
|
||||
import mineplex.core.updater.Updater;
|
||||
import mineplex.minecraft.game.core.combat.CombatManager;
|
||||
import mineplex.minecraft.game.core.damage.DamageManager;
|
||||
import net.minecraft.server.v1_7_R4.MinecraftServer;
|
||||
|
||||
import org.bukkit.plugin.java.JavaPlugin;
|
||||
|
||||
public class Clans extends JavaPlugin
|
||||
{
|
||||
private String WEB_CONFIG = "webServer";
|
||||
|
||||
//Modules
|
||||
private CoreClientManager _clientManager;
|
||||
private DonationManager _donationManager;
|
||||
private DamageManager _damageManager;
|
||||
|
||||
private ServerConfiguration _serverConfiguration;
|
||||
|
||||
@Override
|
||||
public void onEnable()
|
||||
{
|
||||
//Delete Old Games Folders
|
||||
DeleteFolders();
|
||||
|
||||
//Configs
|
||||
getConfig().addDefault(WEB_CONFIG, "http://accounts.mineplex.com/");
|
||||
getConfig().set(WEB_CONFIG, getConfig().getString(WEB_CONFIG));
|
||||
saveConfig();
|
||||
|
||||
String webServerAddress = getConfig().getString(WEB_CONFIG);
|
||||
|
||||
Logger.initialize(this);
|
||||
|
||||
//Static Modules
|
||||
CommandCenter.Initialize(this);
|
||||
_clientManager = new CoreClientManager(this, webServerAddress);
|
||||
CommandCenter.Instance.setClientManager(_clientManager);
|
||||
|
||||
ItemStackFactory.Initialize(this, false);
|
||||
Recharge.Initialize(this);
|
||||
|
||||
_donationManager = new DonationManager(this, webServerAddress);
|
||||
|
||||
_serverConfiguration = new ServerConfiguration(this);
|
||||
|
||||
PreferencesManager preferenceManager = new PreferencesManager(this, _clientManager, _donationManager);
|
||||
new MessageManager(this, _clientManager, preferenceManager);
|
||||
|
||||
AntiStack antistack = new AntiStack(this);
|
||||
Creature creature = new Creature(this);
|
||||
Spawn spawn = new Spawn(this);
|
||||
Teleport teleport = new Teleport(this, _clientManager, spawn);
|
||||
ServerStatusManager serverStatusManager = new ServerStatusManager(this, new LagMeter(this, _clientManager));
|
||||
Portal portal = new Portal(this, serverStatusManager.getCurrentServerName());
|
||||
new FileUpdater(this, portal);
|
||||
PacketHandler packetHandler = new PacketHandler(this);
|
||||
|
||||
DisguiseManager disguiseManager = new DisguiseManager(this, packetHandler);
|
||||
|
||||
_damageManager = new DamageManager(this, new CombatManager(this), new NpcManager(this, creature), disguiseManager);
|
||||
|
||||
Punish punish = new Punish(this, webServerAddress, _clientManager);
|
||||
AntiHack.Initialize(this, punish, portal, preferenceManager, _clientManager);
|
||||
AntiHack.Instance.setKick(false);
|
||||
|
||||
BlockRestore blockRestore = new BlockRestore(this);
|
||||
|
||||
ProjectileManager projectileManager = new ProjectileManager(this);
|
||||
|
||||
//Inventory
|
||||
InventoryManager inventoryManager = new InventoryManager(this);
|
||||
PetManager petManager = new PetManager(this, _clientManager, _donationManager, creature, webServerAddress);
|
||||
MountManager mountManager = new MountManager(this, _clientManager, _donationManager, blockRestore, disguiseManager);
|
||||
GadgetManager gadgetManager = new GadgetManager(this, _clientManager, _donationManager, inventoryManager, mountManager, petManager, preferenceManager, disguiseManager, blockRestore, projectileManager);
|
||||
CosmeticManager cosmeticManager = new CosmeticManager(this, _clientManager, _donationManager, inventoryManager, gadgetManager, mountManager, petManager, true);
|
||||
cosmeticManager.setInterfaceSlot(7);
|
||||
|
||||
new MemoryFix(this);
|
||||
new CustomTagFix(this, packetHandler);
|
||||
|
||||
new FriendManager(this, _clientManager, preferenceManager);
|
||||
|
||||
//Updates
|
||||
getServer().getScheduler().scheduleSyncRepeatingTask(this, new Updater(this), 1, 1);
|
||||
|
||||
MinecraftServer.getServer().getPropertyManager().setProperty("debug", true);
|
||||
}
|
||||
|
||||
private void DeleteFolders()
|
||||
{
|
||||
File curDir = new File(".");
|
||||
|
||||
File[] filesList = curDir.listFiles();
|
||||
for(File file : filesList)
|
||||
{
|
||||
if (!file.isDirectory())
|
||||
continue;
|
||||
|
||||
if (file.getName().length() < 4)
|
||||
continue;
|
||||
|
||||
if (!file.getName().substring(0, 4).equalsIgnoreCase("Game"))
|
||||
continue;
|
||||
|
||||
FileUtil.DeleteFolder(file);
|
||||
|
||||
System.out.println("Deleted Old Game: " + file.getName());
|
||||
}
|
||||
}
|
||||
}
|
@ -1,69 +0,0 @@
|
||||
package me.chiss.Core.Field;
|
||||
|
||||
|
||||
import org.bukkit.entity.Player;
|
||||
import org.bukkit.plugin.java.JavaPlugin;
|
||||
|
||||
import me.chiss.Core.Module.AModule;
|
||||
import mineplex.core.server.IRepository;
|
||||
|
||||
public class Field extends AModule
|
||||
{
|
||||
private FieldBlock _block;
|
||||
private FieldOre _ore;
|
||||
private FieldMonster _mob;
|
||||
|
||||
public Field(JavaPlugin plugin, IRepository repository, String serverName)
|
||||
{
|
||||
super("Field Factory", plugin, repository);
|
||||
|
||||
_block = new FieldBlock(plugin, repository, serverName);
|
||||
_ore = new FieldOre(plugin, repository, serverName);
|
||||
_mob = new FieldMonster(plugin, repository, serverName);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void enable()
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public void disable()
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public void config()
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public void commands()
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public void command(Player caller, String cmd, String[] args)
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
public FieldBlock GetBlock()
|
||||
{
|
||||
return _block;
|
||||
}
|
||||
|
||||
public FieldOre GetOre()
|
||||
{
|
||||
return _ore;
|
||||
}
|
||||
|
||||
public FieldMonster GetMonster()
|
||||
{
|
||||
return _mob;
|
||||
}
|
||||
}
|
@ -1,332 +0,0 @@
|
||||
package me.chiss.Core.Field;
|
||||
|
||||
import java.util.HashSet;
|
||||
import java.util.WeakHashMap;
|
||||
|
||||
import nautilus.minecraft.core.webserver.token.Server.FieldMonsterToken;
|
||||
|
||||
import org.bukkit.Location;
|
||||
import org.bukkit.entity.EntityType;
|
||||
import org.bukkit.entity.Player;
|
||||
import org.bukkit.event.HandlerList;
|
||||
import org.bukkit.plugin.java.JavaPlugin;
|
||||
|
||||
import mineplex.core.server.IRepository;
|
||||
import mineplex.core.common.Rank;
|
||||
import mineplex.core.common.util.F;
|
||||
import mineplex.core.common.util.UtilEnt;
|
||||
import mineplex.core.common.util.UtilPlayer;
|
||||
import mineplex.core.common.util.UtilServer;
|
||||
import mineplex.core.common.util.UtilWorld;
|
||||
import me.chiss.Core.Field.Monsters.FieldMonsterBase;
|
||||
import me.chiss.Core.Module.AModule;
|
||||
|
||||
public class FieldMonster extends AModule
|
||||
{
|
||||
private HashSet<FieldMonsterBase> _pits;
|
||||
private String _serverName;
|
||||
|
||||
private WeakHashMap<Player, FieldMonsterInput> _input = new WeakHashMap<Player, FieldMonsterInput>();
|
||||
|
||||
public FieldMonster(JavaPlugin plugin, IRepository repository, String serverName)
|
||||
{
|
||||
super("Field Monster", plugin, repository);
|
||||
|
||||
_pits = new HashSet<FieldMonsterBase>();
|
||||
_serverName = serverName;
|
||||
|
||||
Load();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void enable()
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public void disable()
|
||||
{
|
||||
Clean();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void config()
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public void commands()
|
||||
{
|
||||
AddCommand("fm");
|
||||
}
|
||||
|
||||
@Override
|
||||
public void command(Player caller, String cmd, String[] args)
|
||||
{
|
||||
if (!Clients().Get(caller).Rank().Has(Rank.ADMIN, true))
|
||||
return;
|
||||
|
||||
if (!_input.containsKey(caller))
|
||||
_input.put(caller, new FieldMonsterInput());
|
||||
|
||||
FieldMonsterInput input = _input.get(caller);
|
||||
|
||||
if (args.length == 0)
|
||||
{
|
||||
_input.get(caller).Display(caller);
|
||||
UtilPlayer.message(caller, F.main(_moduleName, "Type " + F.elem("/fm help") + " for commands."));
|
||||
}
|
||||
|
||||
else if (args[0].equalsIgnoreCase("help"))
|
||||
{
|
||||
Help(caller);
|
||||
}
|
||||
|
||||
else if (args[0].equalsIgnoreCase("type"))
|
||||
{
|
||||
try
|
||||
{
|
||||
input.type = UtilEnt.searchEntity(caller, args[1], true);
|
||||
if (input.type != null)
|
||||
input.Display(caller);
|
||||
}
|
||||
catch (Exception e)
|
||||
{
|
||||
UtilPlayer.message(caller, F.main(_moduleName, "Invalid Monster Type."));
|
||||
}
|
||||
}
|
||||
|
||||
else if (args[0].equalsIgnoreCase("max"))
|
||||
{
|
||||
try
|
||||
{
|
||||
int value = Integer.parseInt(args[1]);
|
||||
if (value < 1) value = 1;
|
||||
input.mobMax = value;
|
||||
input.Display(caller);
|
||||
}
|
||||
catch (Exception e)
|
||||
{
|
||||
UtilPlayer.message(caller, F.main(_moduleName, "Invalid Monster Max."));
|
||||
}
|
||||
}
|
||||
|
||||
else if (args[0].equalsIgnoreCase("rate"))
|
||||
{
|
||||
try
|
||||
{
|
||||
double value = Double.parseDouble(args[1]);
|
||||
if (value < 0) value = 0;
|
||||
input.mobRate = value;
|
||||
input.Display(caller);
|
||||
}
|
||||
catch (Exception e)
|
||||
{
|
||||
UtilPlayer.message(caller, F.main(_moduleName, "Invalid Monster Rate."));
|
||||
}
|
||||
}
|
||||
|
||||
else if (args[0].equalsIgnoreCase("radius"))
|
||||
{
|
||||
try
|
||||
{
|
||||
int integer = Integer.parseInt(args[1]);
|
||||
if (integer < 1) integer = 1;
|
||||
input.radius = integer;
|
||||
input.Display(caller);
|
||||
}
|
||||
catch (Exception e)
|
||||
{
|
||||
UtilPlayer.message(caller, F.main(_moduleName, "Invalid Area Radius."));
|
||||
}
|
||||
}
|
||||
|
||||
else if (args[0].equalsIgnoreCase("height"))
|
||||
{
|
||||
try
|
||||
{
|
||||
int integer = Integer.parseInt(args[1]);
|
||||
if (integer < 1) integer = 1;
|
||||
input.height = integer;
|
||||
input.Display(caller);
|
||||
}
|
||||
catch (Exception e)
|
||||
{
|
||||
UtilPlayer.message(caller, F.main(_moduleName, "Invalid Area Height."));
|
||||
}
|
||||
}
|
||||
|
||||
else if (args[0].equalsIgnoreCase("create"))
|
||||
{
|
||||
if (args.length < 2)
|
||||
{
|
||||
UtilPlayer.message(caller, F.main(_moduleName, "Missing Monster Field Name."));
|
||||
}
|
||||
else
|
||||
{
|
||||
Create(caller, args[1]);
|
||||
}
|
||||
}
|
||||
|
||||
else if (args[0].equalsIgnoreCase("delete"))
|
||||
{
|
||||
if (args.length < 2)
|
||||
{
|
||||
UtilPlayer.message(caller, F.main(_moduleName, "Missing Monster Field Name."));
|
||||
}
|
||||
else
|
||||
{
|
||||
Delete(caller, args[1]);
|
||||
}
|
||||
}
|
||||
|
||||
else if (args[0].equalsIgnoreCase("list"))
|
||||
{
|
||||
UtilPlayer.message(caller, F.main(_moduleName, "Listing Monster Fields;"));
|
||||
|
||||
for (FieldMonsterBase pit : _pits)
|
||||
pit.Display(caller);
|
||||
}
|
||||
|
||||
else if (args[0].equalsIgnoreCase("info"))
|
||||
{
|
||||
UtilPlayer.message(caller, F.main(GetName(), "Listing Monster Fields;"));
|
||||
|
||||
for (FieldMonsterBase pit : _pits)
|
||||
pit.Display(caller);
|
||||
}
|
||||
|
||||
else if (args[0].equalsIgnoreCase("wipe"))
|
||||
{
|
||||
Wipe(caller, true);
|
||||
}
|
||||
|
||||
else if (args[0].equalsIgnoreCase("kill"))
|
||||
{
|
||||
for (FieldMonsterBase pit : _pits)
|
||||
pit.RemoveMonsters();
|
||||
}
|
||||
|
||||
else
|
||||
{
|
||||
UtilPlayer.message(caller, F.main(GetName(), "Invalid Command."));
|
||||
}
|
||||
}
|
||||
|
||||
private void Help(Player caller)
|
||||
{
|
||||
UtilPlayer.message(caller, F.main(GetName(), "Commands List;"));
|
||||
UtilPlayer.message(caller, F.help("/fm type <Monster>", "Set Monster Type", Rank.ADMIN));
|
||||
UtilPlayer.message(caller, F.help("/fm max <#>", "Set Monster Limit", Rank.ADMIN));
|
||||
UtilPlayer.message(caller, F.help("/fm rate <Minutes>", "Set Monster Rate", Rank.ADMIN));
|
||||
UtilPlayer.message(caller, F.help("/fm radius <#>", "Set Area Radius", Rank.ADMIN));
|
||||
UtilPlayer.message(caller, F.help("/fm height <#>", "Set Area Height", Rank.ADMIN));
|
||||
UtilPlayer.message(caller, F.help("/fm create <Name>", "Create at your Location", Rank.ADMIN));
|
||||
UtilPlayer.message(caller, F.help("/fm delete <Name>", "Delete Field", Rank.ADMIN));
|
||||
UtilPlayer.message(caller, F.help("/fm list", "List Monster Fields", Rank.ADMIN));
|
||||
UtilPlayer.message(caller, F.help("/fm info <Name>", "Display Monster Field", Rank.ADMIN));
|
||||
UtilPlayer.message(caller, F.help("/fm kill", "Kills all Field Monsters", Rank.ADMIN));
|
||||
UtilPlayer.message(caller, F.help("/fm wipe", "Delete All Monster Field (Database)", Rank.ADMIN));
|
||||
}
|
||||
|
||||
private void Create(Player caller, String name)
|
||||
{
|
||||
FieldMonsterInput input = _input.get(caller);
|
||||
|
||||
if (input.type == null)
|
||||
{
|
||||
UtilPlayer.message(caller, F.main(GetName(), "You have not set Monster Type."));
|
||||
return;
|
||||
}
|
||||
|
||||
for (FieldMonsterBase pit : _pits)
|
||||
{
|
||||
if (name.equalsIgnoreCase(pit.GetName()))
|
||||
{
|
||||
UtilPlayer.message(caller, F.main(GetName(), "Monster Field with this name already exists."));
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
FieldMonsterBase pit = new FieldMonsterBase(this, name, _serverName, input.type, input.mobMax, input.mobRate, caller.getLocation(), input.radius, input.height);
|
||||
Add(pit, true);
|
||||
|
||||
UtilPlayer.message(caller, F.main(GetName(), "You created Monster Field."));
|
||||
pit.Display(caller);
|
||||
}
|
||||
|
||||
private void Add(FieldMonsterBase pit, boolean repo)
|
||||
{
|
||||
UtilServer.getServer().getPluginManager().registerEvents(pit, Plugin());
|
||||
_pits.add(pit);
|
||||
|
||||
if (repo)
|
||||
GetRepository().AddFieldMonster(pit.GetToken());
|
||||
}
|
||||
|
||||
private void Delete(Player caller, String name)
|
||||
{
|
||||
HashSet<FieldMonsterBase> remove = new HashSet<FieldMonsterBase>();
|
||||
|
||||
for (FieldMonsterBase pit : _pits)
|
||||
if (pit.GetName().equalsIgnoreCase(name))
|
||||
remove.add(pit);
|
||||
|
||||
int i = remove.size();
|
||||
|
||||
for (FieldMonsterBase pit : remove)
|
||||
Delete(pit, true);
|
||||
|
||||
UtilPlayer.message(caller, F.main(GetName(), "Deleted " + i + " Monster Field(s)."));
|
||||
}
|
||||
|
||||
private void Delete(FieldMonsterBase pit, boolean repo)
|
||||
{
|
||||
_pits.remove(pit);
|
||||
pit.RemoveMonsters();
|
||||
HandlerList.unregisterAll(pit);
|
||||
|
||||
if (repo)
|
||||
GetRepository().DeleteFieldMonster(_serverName, pit.GetToken().Name);
|
||||
}
|
||||
|
||||
private void Wipe(Player player, boolean repo)
|
||||
{
|
||||
HashSet<FieldMonsterBase> remove = new HashSet<FieldMonsterBase>();
|
||||
|
||||
for (FieldMonsterBase pit : _pits)
|
||||
remove.add(pit);
|
||||
|
||||
_pits.clear();
|
||||
|
||||
for (FieldMonsterBase pit : remove)
|
||||
Delete(pit, repo);
|
||||
|
||||
UtilPlayer.message(player, F.main(_moduleName, "Field Monsters Wiped."));
|
||||
}
|
||||
|
||||
private void Load()
|
||||
{
|
||||
Wipe(null, false);
|
||||
|
||||
for (FieldMonsterToken token : GetRepository().GetFieldMonsters(_serverName))
|
||||
{
|
||||
EntityType type = UtilEnt.searchEntity(null, token.Type, false);
|
||||
if (type == null) continue;
|
||||
|
||||
Location loc = UtilWorld.strToLoc(token.Centre);
|
||||
if (loc == null) continue;
|
||||
|
||||
FieldMonsterBase pit = new FieldMonsterBase(this, token.Name, _serverName, type, token.MobMax, token.MobRate, loc, token.Radius, token.Height);
|
||||
Add(pit, false);
|
||||
}
|
||||
}
|
||||
|
||||
private void Clean()
|
||||
{
|
||||
for (FieldMonsterBase pit : _pits)
|
||||
pit.RemoveMonsters();
|
||||
}
|
||||
}
|
@ -1,72 +0,0 @@
|
||||
package me.chiss.Core.Field.repository;
|
||||
|
||||
public class FieldRepository
|
||||
{
|
||||
public List<FieldBlockToken> GetFieldBlocks(String server)
|
||||
{
|
||||
return new JsonWebCall(WebServerAddress + "Fields/GetFieldBlocks").Execute(new TypeToken<List<FieldBlockToken>>(){}.getType(), server);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void AddFieldBlock(FieldBlockToken token)
|
||||
{
|
||||
new AsyncJsonWebCall(WebServerAddress + "Fields/AddFieldBlock").Execute(token);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void DeleteFieldBlock(String server, String location)
|
||||
{
|
||||
FieldBlockToken token = new FieldBlockToken();
|
||||
token.Server = server;
|
||||
token.Location = location;
|
||||
|
||||
new AsyncJsonWebCall(WebServerAddress + "Fields/DeleteFieldBlock").Execute(token);
|
||||
}
|
||||
|
||||
//Field Ore
|
||||
@Override
|
||||
public List<FieldOreToken> GetFieldOres(String server)
|
||||
{
|
||||
return new JsonWebCall(WebServerAddress + "Fields/GetFieldOres").Execute(new TypeToken<List<FieldOreToken>>(){}.getType(), server);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void AddFieldOre(FieldOreToken token)
|
||||
{
|
||||
new AsyncJsonWebCall(WebServerAddress + "Fields/AddFieldOre").Execute(token);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void DeleteFieldOre(String server, String location)
|
||||
{
|
||||
FieldOreToken token = new FieldOreToken();
|
||||
token.Server = server;
|
||||
token.Location = location;
|
||||
|
||||
new AsyncJsonWebCall(WebServerAddress + "Fields/DeleteFieldOre").Execute(token);
|
||||
}
|
||||
|
||||
//Field Monster
|
||||
@Override
|
||||
public List<FieldMonsterToken> GetFieldMonsters(String server)
|
||||
{
|
||||
return new JsonWebCall(WebServerAddress + "Fields/GetFieldMonsters").Execute(new TypeToken<List<FieldMonsterToken>>(){}.getType(), server);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void AddFieldMonster(FieldMonsterToken token)
|
||||
{
|
||||
new AsyncJsonWebCall(WebServerAddress + "Fields/AddFieldMonster").Execute(token);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void DeleteFieldMonster(String server, String name)
|
||||
{
|
||||
FieldMonsterToken token = new FieldMonsterToken();
|
||||
token.Server = server;
|
||||
token.Name = name;
|
||||
|
||||
new AsyncJsonWebCall(WebServerAddress + "Fields/DeleteFieldMonster").Execute(token);
|
||||
}
|
||||
|
||||
}
|
Binary file not shown.
Loading…
Reference in New Issue
Block a user