mirror of
https://github.com/CivMC/Civ.git
synced 2026-07-15 23:20:44 +00:00
Initial commit.
This commit is contained in:
7
plugins/citadel-paper/.classpath
Normal file
7
plugins/citadel-paper/.classpath
Normal file
@@ -0,0 +1,7 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<classpath>
|
||||
<classpathentry kind="src" path="src"/>
|
||||
<classpathentry kind="con" path="org.eclipse.jdt.launching.JRE_CONTAINER"/>
|
||||
<classpathentry kind="lib" path="D:/code/ancap_mods/bukkit.jar"/>
|
||||
<classpathentry kind="output" path="bin"/>
|
||||
</classpath>
|
||||
17
plugins/citadel-paper/.project
Normal file
17
plugins/citadel-paper/.project
Normal file
@@ -0,0 +1,17 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<projectDescription>
|
||||
<name>Citadel</name>
|
||||
<comment></comment>
|
||||
<projects>
|
||||
</projects>
|
||||
<buildSpec>
|
||||
<buildCommand>
|
||||
<name>org.eclipse.jdt.core.javabuilder</name>
|
||||
<arguments>
|
||||
</arguments>
|
||||
</buildCommand>
|
||||
</buildSpec>
|
||||
<natures>
|
||||
<nature>org.eclipse.jdt.core.javanature</nature>
|
||||
</natures>
|
||||
</projectDescription>
|
||||
12
plugins/citadel-paper/.settings/org.eclipse.jdt.core.prefs
Normal file
12
plugins/citadel-paper/.settings/org.eclipse.jdt.core.prefs
Normal file
@@ -0,0 +1,12 @@
|
||||
#Sat Mar 17 22:28:22 EST 2012
|
||||
eclipse.preferences.version=1
|
||||
org.eclipse.jdt.core.compiler.codegen.inlineJsrBytecode=enabled
|
||||
org.eclipse.jdt.core.compiler.codegen.targetPlatform=1.5
|
||||
org.eclipse.jdt.core.compiler.codegen.unusedLocal=preserve
|
||||
org.eclipse.jdt.core.compiler.compliance=1.5
|
||||
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.5
|
||||
34
plugins/citadel-paper/plugin.yml
Normal file
34
plugins/citadel-paper/plugin.yml
Normal file
@@ -0,0 +1,34 @@
|
||||
name: Citadel
|
||||
main: invalid.cxschx.citadel.Citadel
|
||||
version: 0.1
|
||||
description: Reenforce your structures!
|
||||
author: cxschx
|
||||
database: true
|
||||
commands:
|
||||
ctfortify:
|
||||
description: Each block you place will be reinforced with the block type you choose
|
||||
usage: /ctfortify <reinforcement type>
|
||||
ctstop:
|
||||
description: Stop reinforcing the blocks you place
|
||||
usage: /ctstop
|
||||
ctplink:
|
||||
description: The next block you place will be reinforced with the block type you choose
|
||||
usage: /ctplink <reinforcement type>
|
||||
ctlist:
|
||||
description: List the possible fortification materials, their strenghts, and requirements.
|
||||
usage: /ctlist
|
||||
ctadd:
|
||||
description: Adds the specified player to your group.
|
||||
usage: /ctadd <playername>
|
||||
ctrm:
|
||||
description: Removes the specified player from your group.
|
||||
usage: /ctremove <playername>
|
||||
ctpublic:
|
||||
description: Set all the chests and doors you place in this state to be public.
|
||||
usage: /ctpublic
|
||||
ctprivate:
|
||||
description: Set all the chests and doors you place in this state to be private.
|
||||
usage: /ctprivate
|
||||
ctgrp:
|
||||
description: Set all the chests and doors you place in thi state to be group owned.
|
||||
usage: /ctgrp
|
||||
@@ -0,0 +1,342 @@
|
||||
package com.untamedears.Citadel;
|
||||
|
||||
import java.sql.Connection;
|
||||
import java.sql.PreparedStatement;
|
||||
import java.sql.ResultSet;
|
||||
import java.sql.SQLException;
|
||||
import java.util.HashMap;
|
||||
import org.bukkit.ChatColor;
|
||||
import org.bukkit.Material;
|
||||
import org.bukkit.block.Block;
|
||||
import org.bukkit.entity.Player;
|
||||
import org.bukkit.event.EventHandler;
|
||||
import org.bukkit.event.Listener;
|
||||
import org.bukkit.event.block.BlockBreakEvent;
|
||||
import org.bukkit.event.block.BlockPlaceEvent;
|
||||
import org.bukkit.event.block.BlockRedstoneEvent;
|
||||
import org.bukkit.event.player.PlayerInteractEvent;
|
||||
import org.bukkit.event.player.PlayerLoginEvent;
|
||||
import org.bukkit.event.player.PlayerQuitEvent;
|
||||
import org.bukkit.inventory.ItemStack;
|
||||
import org.bukkit.material.Door;
|
||||
import org.bukkit.plugin.java.JavaPlugin;
|
||||
|
||||
public class BlockListener implements Listener
|
||||
{
|
||||
private HashMap<Block, Integer> delayedReenforcements;
|
||||
private HashMap<Integer, Material> taskMaterial;
|
||||
private HashMap<Integer, Player> taskInitiator;
|
||||
public static HashMap<Player, Material> playerReenforcers;
|
||||
private JavaPlugin myPlugin;
|
||||
private Connection conn;
|
||||
|
||||
public BlockListener(JavaPlugin jp)throws SQLException, ClassNotFoundException
|
||||
{
|
||||
this.delayedReenforcements = new HashMap();
|
||||
playerReenforcers = new HashMap();
|
||||
this.taskMaterial = new HashMap();
|
||||
this.taskInitiator = new HashMap();
|
||||
|
||||
this.myPlugin = jp;
|
||||
this.conn = ((Citadel)this.myPlugin).connection;
|
||||
}
|
||||
|
||||
@EventHandler
|
||||
public void applyReenforcement(BlockPlaceEvent bpe)
|
||||
{
|
||||
Player placer = bpe.getPlayer();
|
||||
Block block = bpe.getBlock();
|
||||
Material matl = (Material)playerReenforcers.get(placer);
|
||||
Integer pid = null;
|
||||
if ((matl != null) && (Citadel.materialStrengths.containsKey(matl)) && (Citadel.materialRequirements.containsKey(matl)))
|
||||
{
|
||||
System.out.println("matl: " + matl + " requires: " + Citadel.materialRequirements.get(matl));
|
||||
if (placer.getInventory().contains(matl, ((Integer)Citadel.materialRequirements.get(matl)).intValue()))
|
||||
{
|
||||
try
|
||||
{
|
||||
PreparedStatement tmp = this.conn.prepareStatement(
|
||||
"INSERT INTO REENFORCEMENTS (x,y,z,world,durability) values (?,?,?,?,?)");
|
||||
tmp.setInt(1, block.getX());
|
||||
tmp.setInt(2, block.getY());
|
||||
tmp.setInt(3, block.getZ());
|
||||
tmp.setString(4, block.getWorld().getName());
|
||||
tmp.setInt(5, ((Integer)Citadel.materialStrengths.get(matl)).intValue());
|
||||
|
||||
pid = Integer.valueOf(this.myPlugin.getServer().getScheduler().scheduleSyncDelayedTask(
|
||||
this.myPlugin,
|
||||
new DelayedReenforcement(tmp),
|
||||
20L));
|
||||
|
||||
this.delayedReenforcements.put(block, pid);
|
||||
placer.getInventory().removeItem(new ItemStack[] { new ItemStack(matl, ((Integer)Citadel.materialRequirements.get(matl)).intValue()) });
|
||||
this.taskInitiator.put(pid, placer);
|
||||
this.taskMaterial.put(pid, matl);
|
||||
}
|
||||
catch (SQLException e)
|
||||
{
|
||||
System.err.println("Exception creating reenforcement:\n" + e);
|
||||
return;
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
placer.sendMessage(ChatColor.YELLOW + "You require more " + matl + " to continue reenforcements.");
|
||||
playerReenforcers.remove(placer);
|
||||
placer.sendMessage("You are now out of reenforcement mode");
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@EventHandler
|
||||
public void gracefullyRemoveReenforcementModeOnLogout(PlayerQuitEvent pqe)
|
||||
{
|
||||
if (playerReenforcers.containsKey(pqe.getPlayer()))
|
||||
playerReenforcers.remove(pqe.getPlayer());
|
||||
}
|
||||
|
||||
@EventHandler
|
||||
public void checkDurabilityAndDelayedEventCheck(BlockBreakEvent bbe) {
|
||||
Block tmp = bbe.getBlock();
|
||||
|
||||
if (this.delayedReenforcements.containsKey(tmp))
|
||||
{
|
||||
Integer pid = (Integer)this.delayedReenforcements.get(tmp);
|
||||
Material matl = (Material)this.taskMaterial.get(pid);
|
||||
this.myPlugin.getServer().getScheduler().cancelTask(((Integer)this.delayedReenforcements.get(tmp)).intValue());
|
||||
((Player)this.taskInitiator.get(pid)).getInventory().addItem(new ItemStack[] { new ItemStack(matl, ((Integer)Citadel.materialRequirements.get(matl)).intValue()) });
|
||||
|
||||
this.delayedReenforcements.remove(tmp);
|
||||
this.taskInitiator.remove(pid);
|
||||
this.taskMaterial.remove(pid);
|
||||
}
|
||||
|
||||
try
|
||||
{
|
||||
PreparedStatement ask = this.conn.prepareStatement(
|
||||
"SELECT DURABILITY FROM REENFORCEMENTS WHERE x=? AND y=? AND z=? AND world=?");
|
||||
ask.setInt(1, tmp.getX());
|
||||
ask.setInt(2, tmp.getY());
|
||||
ask.setInt(3, tmp.getZ());
|
||||
ask.setString(4, tmp.getWorld().getName());
|
||||
ask.execute();
|
||||
ResultSet answer = ask.getResultSet();
|
||||
if (!answer.next())
|
||||
{
|
||||
answer.close();
|
||||
ask.close();
|
||||
return;
|
||||
}
|
||||
int durability = answer.getInt(1);
|
||||
durability--;
|
||||
ask.close();
|
||||
answer.close();
|
||||
if (durability <= 0)
|
||||
{
|
||||
PreparedStatement delete = this.conn.prepareStatement(
|
||||
"DELETE FROM REENFORCEMENTS WHERE x=? AND y=? AND z=? AND world=?");
|
||||
delete.setInt(1, tmp.getX());
|
||||
delete.setInt(2, tmp.getY());
|
||||
delete.setInt(3, tmp.getZ());
|
||||
delete.setString(4, tmp.getWorld().getName());
|
||||
delete.execute();
|
||||
delete.close();
|
||||
}
|
||||
else
|
||||
{
|
||||
bbe.setCancelled(true);
|
||||
PreparedStatement update = this.conn.prepareStatement(
|
||||
"UPDATE REENFORCEMENTS SET DURABILITY=? WHERE x=? AND y=? AND z=? AND world=?");
|
||||
update.setInt(1, durability);
|
||||
update.setInt(2, tmp.getX());
|
||||
update.setInt(3, tmp.getY());
|
||||
update.setInt(4, tmp.getZ());
|
||||
update.setString(5, tmp.getWorld().getName());
|
||||
update.execute();
|
||||
update.close();
|
||||
}
|
||||
}
|
||||
catch (SQLException e)
|
||||
{
|
||||
System.err.println("Citadel - error accessing database:\n" + e);
|
||||
}
|
||||
}
|
||||
|
||||
@EventHandler
|
||||
public void controlAccess(PlayerInteractEvent pie) {
|
||||
Block block = pie.getClickedBlock();
|
||||
Material matl = pie.getClickedBlock().getType();
|
||||
if (block == null) {
|
||||
return;
|
||||
}
|
||||
|
||||
Player p = pie.getPlayer();
|
||||
try
|
||||
{
|
||||
if ((matl == Material.CHEST) || (matl == Material.WOODEN_DOOR) || (matl == Material.IRON_DOOR)) {
|
||||
PreparedStatement tmp = this.conn.prepareStatement(
|
||||
"SELECT grp FROM REGISTRY WHERE x=? AND y=? AND z=? AND world=?");
|
||||
tmp.setInt(1, block.getX());
|
||||
tmp.setInt(2, block.getY());
|
||||
tmp.setInt(3, block.getZ());
|
||||
tmp.setString(4, block.getWorld().getName());
|
||||
tmp.execute();
|
||||
ResultSet answer = tmp.getResultSet();
|
||||
|
||||
if (!answer.next()) {
|
||||
answer.close();
|
||||
tmp.close();
|
||||
return;
|
||||
}
|
||||
do
|
||||
{
|
||||
PreparedStatement queryGroup = this.conn.prepareStatement(
|
||||
"SELECT grpName FROM GROUPS WHERE grpName=? AND member=?");
|
||||
queryGroup.setString(1, answer.getString(1));
|
||||
queryGroup.setString(2, p.getPlayerListName());
|
||||
queryGroup.execute();
|
||||
ResultSet tmpRs = queryGroup.getResultSet();
|
||||
if (tmpRs.next())
|
||||
{
|
||||
tmpRs.close();
|
||||
queryGroup.close();
|
||||
tmp.close();
|
||||
return;
|
||||
}
|
||||
tmpRs.close();
|
||||
queryGroup.close();
|
||||
}
|
||||
while (answer.next());
|
||||
tmp.close();
|
||||
|
||||
p.sendMessage(ChatColor.RED + "That door/chest is locked.");
|
||||
/*
|
||||
p.sendMessage(ChatColor.RED + "That door/chest is locked. O NOZ!!!");
|
||||
p.sendMessage(ChatColor.MAGIC + "Hey Beavis, that was, like, cool.");
|
||||
p.sendMessage(ChatColor.YELLOW + "Huh huh.");
|
||||
p.sendMessage(ChatColor.GREEN + "Uh, huh huh. Oh yeah. Money is cool!");
|
||||
p.sendMessage(ChatColor.BLUE + "YEAH! It, like, uh, huh huh. Uh...");
|
||||
p.sendMessage(ChatColor.LIGHT_PURPLE + "Huh huh huh. Uh, hmmmm, heh, huh, hmmm huh huh. Yeah.");
|
||||
*/
|
||||
pie.setCancelled(true);
|
||||
}
|
||||
}
|
||||
catch (SQLException e)
|
||||
{
|
||||
System.err.println("Error when seeing if the door's part of a group:\n" + e);
|
||||
}
|
||||
}
|
||||
|
||||
public void controlRedstone(BlockRedstoneEvent bre)
|
||||
{
|
||||
Block block = bre.getBlock();
|
||||
|
||||
if ((block instanceof Door))
|
||||
try
|
||||
{
|
||||
PreparedStatement tmp = this.conn.prepareStatement(
|
||||
"SELECT group FROM REGISTRY WHERE x=? AND y=? AND z=? AND world=?");
|
||||
tmp.setInt(1, block.getX());
|
||||
tmp.setInt(2, block.getY());
|
||||
tmp.setInt(3, block.getZ());
|
||||
tmp.setString(4, block.getWorld().getName());
|
||||
tmp.execute();
|
||||
ResultSet answer = tmp.getResultSet();
|
||||
|
||||
if (answer.next())
|
||||
{
|
||||
bre.setNewCurrent(bre.getOldCurrent());
|
||||
}
|
||||
answer.close();
|
||||
tmp.close();
|
||||
}
|
||||
catch (SQLException e)
|
||||
{
|
||||
System.err.println("Error in redstone protection checking:\n" + e);
|
||||
}
|
||||
}
|
||||
|
||||
@EventHandler
|
||||
public void makePrivateGroup(PlayerLoginEvent ple)
|
||||
{
|
||||
((Citadel)this.myPlugin).playerPlacementState.put(ple.getPlayer(), Integer.valueOf(1));
|
||||
try
|
||||
{
|
||||
PreparedStatement tmp = this.conn.prepareStatement("SELECT grpName FROM GROUPS WHERE grpName = ?");
|
||||
tmp.setString(1, ple.getPlayer().getDisplayName());
|
||||
tmp.execute();
|
||||
ResultSet rs = tmp.getResultSet();
|
||||
if (!rs.next())
|
||||
{
|
||||
tmp = this.conn.prepareStatement("INSERT INTO GROUPS (grpName,member) values (?,?)");
|
||||
tmp.setString(1, ple.getPlayer().getDisplayName());
|
||||
tmp.setString(2, ple.getPlayer().getDisplayName());
|
||||
tmp.execute();
|
||||
tmp.close();
|
||||
}
|
||||
rs.close();
|
||||
tmp.close();
|
||||
}
|
||||
catch (SQLException e)
|
||||
{
|
||||
System.err.println("Error in seeing if player has self-group:\n" + e);
|
||||
}
|
||||
}
|
||||
|
||||
@EventHandler
|
||||
public void secureDoorOrChest(BlockPlaceEvent bpe)
|
||||
{
|
||||
Block blk = bpe.getBlock();
|
||||
Material object = bpe.getBlock().getType();
|
||||
|
||||
if ((object != Material.CHEST) && (object != Material.WOODEN_DOOR) && (object != Material.IRON_DOOR))
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
Integer playerState = (Integer)((Citadel)this.myPlugin).playerPlacementState.get(bpe.getPlayer());
|
||||
if (playerState == null)
|
||||
{
|
||||
((Citadel)this.myPlugin).playerPlacementState.put(bpe.getPlayer(), Integer.valueOf(1));
|
||||
playerState = Integer.valueOf(1);
|
||||
}
|
||||
|
||||
if (playerState.intValue() > 0)
|
||||
{
|
||||
try
|
||||
{
|
||||
PreparedStatement tmp = this.conn.prepareStatement(
|
||||
"INSERT INTO REGISTRY (x,y,z,world,grp) VALUES (?,?,?,?,?)");
|
||||
tmp.setInt(1, blk.getX());
|
||||
tmp.setInt(2, blk.getY());
|
||||
tmp.setInt(3, blk.getZ());
|
||||
tmp.setString(4, blk.getWorld().getName());
|
||||
tmp.setString(5, bpe.getPlayer().getDisplayName());
|
||||
tmp.execute();
|
||||
if (playerState.intValue() > 1)
|
||||
{
|
||||
tmp.setString(5, bpe.getPlayer().getDisplayName() + "Grp");
|
||||
tmp.execute();
|
||||
}
|
||||
tmp.close();
|
||||
}
|
||||
catch (SQLException e)
|
||||
{
|
||||
System.err.println("Error putting chest/door into protection database:\n" + e);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public void close()
|
||||
{
|
||||
try
|
||||
{
|
||||
this.conn.close();
|
||||
}
|
||||
catch (SQLException e)
|
||||
{
|
||||
System.err.println("Citadel - Sorry, I'll have to close the database ungracefully!");
|
||||
System.err.println(e.toString());
|
||||
}
|
||||
}
|
||||
}
|
||||
191
plugins/citadel-paper/src/com/untamedears/Citadel/Citadel.java
Normal file
191
plugins/citadel-paper/src/com/untamedears/Citadel/Citadel.java
Normal file
@@ -0,0 +1,191 @@
|
||||
package com.untamedears.Citadel;
|
||||
|
||||
import java.sql.Connection;
|
||||
import java.sql.DriverManager;
|
||||
import java.sql.PreparedStatement;
|
||||
import java.sql.SQLException;
|
||||
import java.util.HashMap;
|
||||
import java.util.List;
|
||||
import org.bukkit.Bukkit;
|
||||
import org.bukkit.ChatColor;
|
||||
import org.bukkit.Material;
|
||||
import org.bukkit.command.Command;
|
||||
import org.bukkit.command.CommandSender;
|
||||
import org.bukkit.entity.Player;
|
||||
import org.bukkit.plugin.java.JavaPlugin;
|
||||
|
||||
public class Citadel extends JavaPlugin
|
||||
{
|
||||
public static HashMap<Material, Integer> materialStrengths;
|
||||
public static HashMap<Material, Integer> materialRequirements;
|
||||
public HashMap<Player, Integer> playerPlacementState;
|
||||
public Connection connection;
|
||||
|
||||
public void onEnable()
|
||||
{
|
||||
reloadConfig();
|
||||
materialStrengths = new HashMap();
|
||||
materialRequirements = new HashMap();
|
||||
this.playerPlacementState = new HashMap();
|
||||
|
||||
List tmp1 = getConfig().getIntegerList("materials.strengths.keys");
|
||||
List tmp2 = getConfig().getIntegerList("materials.strengths.strengths");
|
||||
List tmp3 = getConfig().getIntegerList("materials.strengths.requirements");
|
||||
|
||||
Integer[] keys = (Integer[])tmp1.toArray(new Integer[tmp1.size()]);
|
||||
Integer[] strengths = (Integer[])tmp2.toArray(new Integer[tmp2.size()]);
|
||||
Integer[] requirements = (Integer[])tmp3.toArray(new Integer[tmp3.size()]);
|
||||
|
||||
if ((keys.length != strengths.length) || (keys.length != requirements.length))
|
||||
{
|
||||
System.err.println("Citadel - config lengths not matching!");
|
||||
System.err.println("File is most likely corrupted but I'll try to do the best I can");
|
||||
System.err.println("By interpreting the shortest of it all as the proper length");
|
||||
System.err.println("Proceed with caution and re-look-over your configuration file!");
|
||||
}
|
||||
for (int i = 0; i < Math.min(keys.length, Math.min(strengths.length, requirements.length)); i++)
|
||||
{
|
||||
materialStrengths.put(Material.getMaterial(keys[i].intValue()), strengths[i]);
|
||||
materialRequirements.put(Material.getMaterial(keys[i].intValue()), requirements[i]);
|
||||
}
|
||||
|
||||
try
|
||||
{
|
||||
Class.forName("org.sqlite.JDBC");
|
||||
|
||||
this.connection = DriverManager.getConnection("jdbc:sqlite:plugins/Citadel/Citadel.db");
|
||||
this.connection.createStatement().execute(
|
||||
"CREATE TABLE IF NOT EXISTS REENFORCEMENTS (x INTEGER,y INTEGER,z INTEGER,world TEXT,durability INTEGER);");
|
||||
|
||||
this.connection.createStatement().execute(
|
||||
"CREATE TABLE IF NOT EXISTS GROUPS (grpName TEXT,member TEXT);");
|
||||
|
||||
this.connection.createStatement().execute(
|
||||
"CREATE TABLE IF NOT EXISTS REGISTRY (x INTEGER,y INTEGER,z INTEGER,world TEXT,grp TEXT);");
|
||||
|
||||
Bukkit.getServer().getPluginManager().registerEvents(new BlockListener(this), this);
|
||||
}
|
||||
catch (SQLException e)
|
||||
{
|
||||
System.err.println("sorry there was some sort of sql exception:");
|
||||
System.err.println(e.toString());
|
||||
System.err.println(e.getSQLState());
|
||||
return;
|
||||
}
|
||||
catch (ClassNotFoundException e)
|
||||
{
|
||||
System.err.println("sorry we couldn't find the sqlite driver:");
|
||||
System.err.println(e.toString());
|
||||
return;
|
||||
}
|
||||
catch (Exception e)
|
||||
{
|
||||
System.err.println("Other weird error when enabling Citadel: ");
|
||||
System.err.println(e.toString());
|
||||
}
|
||||
|
||||
System.out.println("Citadel - Hi folks, Citadel is now on :D.");
|
||||
}
|
||||
|
||||
public void onDisable()
|
||||
{
|
||||
System.out.println("Citadel - Hi folks, Citadel is disabled :(.");
|
||||
}
|
||||
|
||||
public boolean onCommand(CommandSender sender, Command cmd, String commandLabel, String[] args)
|
||||
{
|
||||
if (!(sender instanceof Player)) {
|
||||
sender.sendMessage(ChatColor.RED + "You must be a player!");
|
||||
return true;
|
||||
}
|
||||
|
||||
if (cmd.getName().equalsIgnoreCase("ctfortify"))
|
||||
{
|
||||
if (args.length < 1)
|
||||
{
|
||||
sender.sendMessage(ChatColor.RED + "Please specify reenforcement block type.");
|
||||
return true;
|
||||
}
|
||||
Material matl = Material.getMaterial(args[0].toUpperCase());
|
||||
if (materialStrengths.containsKey(matl))
|
||||
BlockListener.playerReenforcers.put((Player)sender, matl);
|
||||
else
|
||||
sender.sendMessage(ChatColor.YELLOW + "Material " + args[0] + " not found as applicable reenforcement material");
|
||||
}
|
||||
else if (cmd.getName().equalsIgnoreCase("ctstop"))
|
||||
{
|
||||
BlockListener.playerReenforcers.remove((Player)sender);
|
||||
sender.sendMessage(ChatColor.GREEN + "You are now out of reenforcement mode");
|
||||
}
|
||||
else if (cmd.getName().equalsIgnoreCase("ctplink"))
|
||||
{
|
||||
sender.sendMessage(ChatColor.RED + "Not yet implemented, sorry");
|
||||
if (args.length < 1)
|
||||
sender.sendMessage(ChatColor.RED + "Please specify reenforcement block type.");
|
||||
}
|
||||
else if (cmd.getName().equalsIgnoreCase("ctlist"))
|
||||
{
|
||||
if ((materialRequirements.keySet() == null) || (materialRequirements.keySet().size() == 0))
|
||||
{
|
||||
sender.sendMessage(ChatColor.YELLOW + "No reenforcement materials available.");
|
||||
}
|
||||
for (Material m : materialRequirements.keySet())
|
||||
sender.sendMessage(ChatColor.GREEN + m.toString() + " has strength " + materialStrengths.get(m) + " and you'll need " + materialRequirements.get(m) + " of it.");
|
||||
}
|
||||
else if (cmd.getName().equalsIgnoreCase("ctadd"))
|
||||
{
|
||||
if (args.length < 1)
|
||||
{
|
||||
sender.sendMessage(ChatColor.RED + "Please specify player to add.");
|
||||
return true;
|
||||
}
|
||||
try {
|
||||
PreparedStatement tmp = this.connection.prepareStatement(
|
||||
"INSERT INTO GROUPS (grpName,member) values (?,?)");
|
||||
tmp.setString(1, ((Player)sender).getDisplayName() + "Grp");
|
||||
tmp.setString(2, args[0]);
|
||||
tmp.execute();
|
||||
sender.sendMessage(ChatColor.GREEN + " player " + args[0] + " added.");
|
||||
}
|
||||
catch (SQLException e)
|
||||
{
|
||||
System.err.println("Error adding player " + args[0] + " to group " + ((Player)sender).getDisplayName() + ":\n" + e);
|
||||
}
|
||||
}
|
||||
else if (cmd.getName().equalsIgnoreCase("ctrm"))
|
||||
{
|
||||
if (args.length < 1)
|
||||
{
|
||||
sender.sendMessage(ChatColor.RED + "Please specify player to add.");
|
||||
return true;
|
||||
}
|
||||
try
|
||||
{
|
||||
PreparedStatement tmp = this.connection.prepareStatement(
|
||||
"DELETE FROM GROUPS WHERE grpName=? AND member=?");
|
||||
tmp.setString(1, ((Player)sender).getDisplayName() + "Grp");
|
||||
tmp.setString(2, args[0]);
|
||||
tmp.execute();
|
||||
sender.sendMessage(ChatColor.GREEN + " player " + args[0] + " removed.");
|
||||
}
|
||||
catch (SQLException e)
|
||||
{
|
||||
System.err.println("Error removing player " + args[0] + " from group " + ((Player)sender).getDisplayName() + ":\n" + e);
|
||||
}
|
||||
}
|
||||
else if (cmd.getName().equalsIgnoreCase("ctpublic"))
|
||||
{
|
||||
this.playerPlacementState.put((Player)sender, Integer.valueOf(0));
|
||||
sender.sendMessage(ChatColor.GREEN + "Now in public mode.");
|
||||
}
|
||||
else if (cmd.getName().equalsIgnoreCase("ctprivate"))
|
||||
{
|
||||
this.playerPlacementState.put((Player)sender, Integer.valueOf(1));
|
||||
sender.sendMessage(ChatColor.GREEN + "Now in private mode.");
|
||||
} else if (cmd.getName().equalsIgnoreCase("ctgrp")) {
|
||||
this.playerPlacementState.put((Player)sender, Integer.valueOf(2));
|
||||
sender.sendMessage(ChatColor.GREEN + "Now in group mode.");
|
||||
}
|
||||
return true;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,26 @@
|
||||
package com.untamedears.Citadel;
|
||||
|
||||
import java.sql.PreparedStatement;
|
||||
import java.sql.SQLException;
|
||||
|
||||
public class DelayedReenforcement implements Runnable
|
||||
{
|
||||
private PreparedStatement addReenforcedBlockStatement;
|
||||
|
||||
public DelayedReenforcement(PreparedStatement ps)
|
||||
{
|
||||
this.addReenforcedBlockStatement = ps;
|
||||
}
|
||||
|
||||
public void run()
|
||||
{
|
||||
try
|
||||
{
|
||||
this.addReenforcedBlockStatement.execute();
|
||||
this.addReenforcedBlockStatement.close();
|
||||
} catch (SQLException e) {
|
||||
System.err.println("Error in protecting block. Details:");
|
||||
System.err.println(e.toString());
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user