2011-03-30 04:03:21 +00:00
|
|
|
package com.earth2me.essentials;
|
|
|
|
|
|
|
|
import java.io.File;
|
|
|
|
import java.util.List;
|
|
|
|
import java.util.logging.Logger;
|
|
|
|
import org.bukkit.Location;
|
|
|
|
import org.bukkit.event.block.BlockBreakEvent;
|
|
|
|
import org.bukkit.event.block.BlockDamageEvent;
|
|
|
|
import org.bukkit.event.block.BlockListener;
|
|
|
|
import org.bukkit.event.block.BlockPlaceEvent;
|
|
|
|
|
2011-03-30 17:58:00 +00:00
|
|
|
|
|
|
|
public class Jail extends BlockListener implements IConf
|
|
|
|
{
|
2011-03-30 04:03:21 +00:00
|
|
|
private static final Logger logger = Logger.getLogger("Minecraft");
|
2011-06-01 10:40:12 +00:00
|
|
|
private final EssentialsConf config;
|
|
|
|
private final IEssentials ess;
|
2011-03-30 04:03:21 +00:00
|
|
|
|
2011-06-01 10:40:12 +00:00
|
|
|
public Jail(IEssentials ess)
|
2011-03-30 17:58:00 +00:00
|
|
|
{
|
This is a big refactoring of the user class and more.
Many commands have been cleaned.
File changes:
- all user data has been moved from users.yml to userdata folder
- all files in userdata folder are lower case
Both changes should be done automatically.
Class changes:
- Moved all user data functions to UserData class
- Moved all user teleport functions to Teleport class
- Moved the user list to Essentials class
- Less static functions for better testing
- EssentialsCommand now has ess Property (Essentials class)
- New NotEnoughArgumentsException, that will show command description and syntax
New commands:
- /seen, shows the last login or logout
- /tempban, temporarily ban someone
- /tjail and mute, temporarily option added
Other changes:
- ban reason is saved
- don't show "You have xxx mail" on login, if user doesn't have essentials.mail permission
- time will be parsed: years, months (mo), weeks, days, hours, minutes (m), seconds, these can be shortened and combined, example: 2 days 5h 30m
git-svn-id: https://svn.java.net/svn/essentials~svn/trunk@1300 e251c2fe-e539-e718-e476-b85c1f46cddb
2011-05-01 21:07:30 +00:00
|
|
|
this.ess = ess;
|
|
|
|
config = new EssentialsConf(new File(ess.getDataFolder(), "jail.yml"));
|
2011-03-30 04:03:21 +00:00
|
|
|
config.load();
|
|
|
|
}
|
|
|
|
|
2011-03-30 17:58:00 +00:00
|
|
|
public void setJail(Location loc, String jailName) throws Exception
|
|
|
|
{
|
This is a big refactoring of the user class and more.
Many commands have been cleaned.
File changes:
- all user data has been moved from users.yml to userdata folder
- all files in userdata folder are lower case
Both changes should be done automatically.
Class changes:
- Moved all user data functions to UserData class
- Moved all user teleport functions to Teleport class
- Moved the user list to Essentials class
- Less static functions for better testing
- EssentialsCommand now has ess Property (Essentials class)
- New NotEnoughArgumentsException, that will show command description and syntax
New commands:
- /seen, shows the last login or logout
- /tempban, temporarily ban someone
- /tjail and mute, temporarily option added
Other changes:
- ban reason is saved
- don't show "You have xxx mail" on login, if user doesn't have essentials.mail permission
- time will be parsed: years, months (mo), weeks, days, hours, minutes (m), seconds, these can be shortened and combined, example: 2 days 5h 30m
git-svn-id: https://svn.java.net/svn/essentials~svn/trunk@1300 e251c2fe-e539-e718-e476-b85c1f46cddb
2011-05-01 21:07:30 +00:00
|
|
|
config.setProperty(jailName.toLowerCase(), loc);
|
2011-03-30 04:03:21 +00:00
|
|
|
config.save();
|
|
|
|
}
|
|
|
|
|
2011-03-30 17:58:00 +00:00
|
|
|
public Location getJail(String jailName) throws Exception
|
|
|
|
{
|
2011-08-08 14:42:56 +00:00
|
|
|
if (jailName == null || config.getProperty(jailName.toLowerCase()) == null)
|
2011-03-30 17:58:00 +00:00
|
|
|
{
|
2011-05-10 19:02:59 +00:00
|
|
|
throw new Exception(Util.i18n("jailNotExist"));
|
2011-03-30 04:03:21 +00:00
|
|
|
}
|
|
|
|
|
2011-06-01 10:40:12 +00:00
|
|
|
Location loc = config.getLocation(jailName.toLowerCase(), ess.getServer());
|
This is a big refactoring of the user class and more.
Many commands have been cleaned.
File changes:
- all user data has been moved from users.yml to userdata folder
- all files in userdata folder are lower case
Both changes should be done automatically.
Class changes:
- Moved all user data functions to UserData class
- Moved all user teleport functions to Teleport class
- Moved the user list to Essentials class
- Less static functions for better testing
- EssentialsCommand now has ess Property (Essentials class)
- New NotEnoughArgumentsException, that will show command description and syntax
New commands:
- /seen, shows the last login or logout
- /tempban, temporarily ban someone
- /tjail and mute, temporarily option added
Other changes:
- ban reason is saved
- don't show "You have xxx mail" on login, if user doesn't have essentials.mail permission
- time will be parsed: years, months (mo), weeks, days, hours, minutes (m), seconds, these can be shortened and combined, example: 2 days 5h 30m
git-svn-id: https://svn.java.net/svn/essentials~svn/trunk@1300 e251c2fe-e539-e718-e476-b85c1f46cddb
2011-05-01 21:07:30 +00:00
|
|
|
return loc;
|
2011-03-30 04:03:21 +00:00
|
|
|
}
|
|
|
|
|
2011-03-30 17:58:00 +00:00
|
|
|
public void sendToJail(User user, String jail) throws Exception
|
|
|
|
{
|
2011-07-18 21:49:27 +00:00
|
|
|
if (!(user.getBase() instanceof OfflinePlayer))
|
2011-07-18 21:16:58 +00:00
|
|
|
{
|
|
|
|
user.getTeleport().now(getJail(jail));
|
|
|
|
}
|
This is a big refactoring of the user class and more.
Many commands have been cleaned.
File changes:
- all user data has been moved from users.yml to userdata folder
- all files in userdata folder are lower case
Both changes should be done automatically.
Class changes:
- Moved all user data functions to UserData class
- Moved all user teleport functions to Teleport class
- Moved the user list to Essentials class
- Less static functions for better testing
- EssentialsCommand now has ess Property (Essentials class)
- New NotEnoughArgumentsException, that will show command description and syntax
New commands:
- /seen, shows the last login or logout
- /tempban, temporarily ban someone
- /tjail and mute, temporarily option added
Other changes:
- ban reason is saved
- don't show "You have xxx mail" on login, if user doesn't have essentials.mail permission
- time will be parsed: years, months (mo), weeks, days, hours, minutes (m), seconds, these can be shortened and combined, example: 2 days 5h 30m
git-svn-id: https://svn.java.net/svn/essentials~svn/trunk@1300 e251c2fe-e539-e718-e476-b85c1f46cddb
2011-05-01 21:07:30 +00:00
|
|
|
user.setJail(jail);
|
2011-03-30 04:03:21 +00:00
|
|
|
}
|
|
|
|
|
2011-03-30 17:58:00 +00:00
|
|
|
public void delJail(String jail) throws Exception
|
|
|
|
{
|
2011-03-30 04:03:21 +00:00
|
|
|
config.removeProperty(jail.toLowerCase());
|
|
|
|
config.save();
|
|
|
|
}
|
|
|
|
|
2011-03-30 17:58:00 +00:00
|
|
|
public List<String> getJails() throws Exception
|
|
|
|
{
|
2011-03-30 04:03:21 +00:00
|
|
|
return config.getKeys(null);
|
|
|
|
}
|
|
|
|
|
2011-03-30 17:58:00 +00:00
|
|
|
public void reloadConfig()
|
|
|
|
{
|
2011-03-30 04:03:21 +00:00
|
|
|
config.load();
|
|
|
|
}
|
2011-03-30 17:58:00 +00:00
|
|
|
|
2011-03-30 04:03:21 +00:00
|
|
|
@Override
|
|
|
|
public void onBlockBreak(BlockBreakEvent event)
|
|
|
|
{
|
This is a big refactoring of the user class and more.
Many commands have been cleaned.
File changes:
- all user data has been moved from users.yml to userdata folder
- all files in userdata folder are lower case
Both changes should be done automatically.
Class changes:
- Moved all user data functions to UserData class
- Moved all user teleport functions to Teleport class
- Moved the user list to Essentials class
- Less static functions for better testing
- EssentialsCommand now has ess Property (Essentials class)
- New NotEnoughArgumentsException, that will show command description and syntax
New commands:
- /seen, shows the last login or logout
- /tempban, temporarily ban someone
- /tjail and mute, temporarily option added
Other changes:
- ban reason is saved
- don't show "You have xxx mail" on login, if user doesn't have essentials.mail permission
- time will be parsed: years, months (mo), weeks, days, hours, minutes (m), seconds, these can be shortened and combined, example: 2 days 5h 30m
git-svn-id: https://svn.java.net/svn/essentials~svn/trunk@1300 e251c2fe-e539-e718-e476-b85c1f46cddb
2011-05-01 21:07:30 +00:00
|
|
|
User user = ess.getUser(event.getPlayer());
|
2011-03-30 17:58:00 +00:00
|
|
|
if (user.isJailed())
|
|
|
|
{
|
2011-03-30 04:03:21 +00:00
|
|
|
event.setCancelled(true);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
@Override
|
|
|
|
public void onBlockPlace(BlockPlaceEvent event)
|
|
|
|
{
|
This is a big refactoring of the user class and more.
Many commands have been cleaned.
File changes:
- all user data has been moved from users.yml to userdata folder
- all files in userdata folder are lower case
Both changes should be done automatically.
Class changes:
- Moved all user data functions to UserData class
- Moved all user teleport functions to Teleport class
- Moved the user list to Essentials class
- Less static functions for better testing
- EssentialsCommand now has ess Property (Essentials class)
- New NotEnoughArgumentsException, that will show command description and syntax
New commands:
- /seen, shows the last login or logout
- /tempban, temporarily ban someone
- /tjail and mute, temporarily option added
Other changes:
- ban reason is saved
- don't show "You have xxx mail" on login, if user doesn't have essentials.mail permission
- time will be parsed: years, months (mo), weeks, days, hours, minutes (m), seconds, these can be shortened and combined, example: 2 days 5h 30m
git-svn-id: https://svn.java.net/svn/essentials~svn/trunk@1300 e251c2fe-e539-e718-e476-b85c1f46cddb
2011-05-01 21:07:30 +00:00
|
|
|
User user = ess.getUser(event.getPlayer());
|
2011-03-30 17:58:00 +00:00
|
|
|
if (user.isJailed())
|
|
|
|
{
|
2011-03-30 04:03:21 +00:00
|
|
|
event.setCancelled(true);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
@Override
|
2011-03-30 17:58:00 +00:00
|
|
|
public void onBlockDamage(BlockDamageEvent event)
|
|
|
|
{
|
This is a big refactoring of the user class and more.
Many commands have been cleaned.
File changes:
- all user data has been moved from users.yml to userdata folder
- all files in userdata folder are lower case
Both changes should be done automatically.
Class changes:
- Moved all user data functions to UserData class
- Moved all user teleport functions to Teleport class
- Moved the user list to Essentials class
- Less static functions for better testing
- EssentialsCommand now has ess Property (Essentials class)
- New NotEnoughArgumentsException, that will show command description and syntax
New commands:
- /seen, shows the last login or logout
- /tempban, temporarily ban someone
- /tjail and mute, temporarily option added
Other changes:
- ban reason is saved
- don't show "You have xxx mail" on login, if user doesn't have essentials.mail permission
- time will be parsed: years, months (mo), weeks, days, hours, minutes (m), seconds, these can be shortened and combined, example: 2 days 5h 30m
git-svn-id: https://svn.java.net/svn/essentials~svn/trunk@1300 e251c2fe-e539-e718-e476-b85c1f46cddb
2011-05-01 21:07:30 +00:00
|
|
|
User user = ess.getUser(event.getPlayer());
|
2011-03-30 17:58:00 +00:00
|
|
|
if (user.isJailed())
|
|
|
|
{
|
2011-03-30 04:03:21 +00:00
|
|
|
event.setCancelled(true);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|