Follow along with the video below to see how to install our site as a web app on your home screen.
Примечание: This feature may not be available in some browsers.
Говорят если сохранять в UTF-8 (без BOM) все будет хорошо
Первое что я попробовал, у меня кб в скрипте даже размер ссылок меняю в скриптах.Говорят если сохранять в UTF-8 (без BOM) все будет хорошо
Без обид, но если бы я отдал клиенту такую реализацию генератора страниц, мне бы пальцы сломали......Первое что я попробовал, у меня кб в скрипте даже размер ссылок меняю в скриптах.
private static String list()
{
String s = "";
s += "<table>";
for(GroupTeleport gp : GroupTeleportMain)
{
s += "<tr>";
s += mGenerateElement.buttonTD(gp.name, "_bbsteleport_list " + gp.path, 250, 30);
s += "</tr>";
}
{
}
s += "</table>";
return s;
}
private static String list()
{
StringBuilder text = new StringBuilder("<table>");
for(final GroupTeleport gp : GroupTeleportMain)
{
text.append("<tr>");
text.append(mGenerateElement.buttonTD(gp.name, "_bbsteleport_list " + gp.path, 250, 30));
text.append("</tr>");
}
text.append("</table>");
return text.toString();
}
Не работает все равно, это в принципе не критично, за то телепорт хороший с проверками.
package community.custom.Teleport;
import java.io.BufferedInputStream;
import java.io.File;
import java.io.FileFilter;
import java.io.FileInputStream;
import java.io.IOException;
import java.util.ArrayList;
import java.util.StringTokenizer;
import l2p.commons.util.Rnd;
import l2p.gameserver.Config;
import l2p.gameserver.data.htm.HtmCache;
import l2p.gameserver.handler.bbs.CommunityBoardManager;
import l2p.gameserver.handler.bbs.ICommunityBoardHandler;
import l2p.gameserver.model.Player;
import l2p.gameserver.scripts.ScriptFile;
import l2p.gameserver.serverpackets.ShowBoard;
import l2p.gameserver.utils.Location;
import l2p.gameserver.handler.bbs.impl.mGenerateElement;
import l2p.gameserver.handler.bbs.impl.mGeneratePage;
/**
* @authors Shaitan & hex1r0 & Kolobrodik
* @date: 20:46/22.07.2012
* @description: Комьюнити телепорт.
*/
public class CommunityTeleport implements ScriptFile, ICommunityBoardHandler
{
class GroupTeleport
{
String name;
String path;
GroupTeleport(String name, String path)
{
this.name = name;
this.path = path;
}
}
private static ArrayList<GroupTeleport> GroupTeleportMain = new ArrayList<GroupTeleport>();
private static ArrayList<GroupTeleport> GroupTeleportPremium = new ArrayList<GroupTeleport>();
private ArrayList<String> _serverTeleportPoints = new ArrayList<String>();
@Override
public void onLoad()
{
if(!Config.COMMUNITY_TELEPORT_ENABLED)
return;
String[] GroupTeleportTemp = Config.COMMUNITY_GROUP_TELEPORT;
for(int i = 0; i < GroupTeleportTemp.length; i += 2)
GroupTeleportMain.add(new GroupTeleport(GroupTeleportTemp, GroupTeleportTemp[i + 1]));
String[] GroupTeleportPremiumTemp = Config.COMMUNITY_PREMIUM_GROUP_TELEPORT;
for(int i = 0; i < GroupTeleportPremiumTemp.length; i += 2)
GroupTeleportPremium.add(new GroupTeleport(GroupTeleportPremiumTemp, GroupTeleportPremiumTemp[i + 1]));
parseDir(new File(Config.DATAPACK_ROOT, "data/html-en/community/teleports"));
CommunityBoardManager.getInstance().registerHandler(this);
}
@Override
public void onReload()
{}
@Override
public void onShutdown()
{}
@Override
public void onBypassCommand(Player player, String bypass)
{
if(bypass.equalsIgnoreCase("_bbsteleport"))
ShowBoard.separateAndSend(mGeneratePage.addToTemplate(showTeleport(player, false, null)), player);
else if(bypass.equalsIgnoreCase("_bbsteleport_pvpzone"))
{
}
else if(bypass.startsWith("_bbsteleport_list"))
{
StringTokenizer st = new StringTokenizer(bypass, " ");
st.nextToken();
ShowBoard.separateAndSend(mGeneratePage.addToTemplate(showTeleport(player, true, "community/" + st.nextToken())), player);
}
else if(bypass.startsWith("_bbsteleport_goto"))
{
boolean allowTeleport = false;
String coords = bypass.substring(18).trim();
// player can not teleport in frog transformation _194_SevenSignContractOfMammon
if(player.getTransformation() == 111)
{
player.sendMessage("Вы не можете телепортироватся в этой трансформации.");
allowTeleport = false;
}
else if(_serverTeleportPoints.contains(coords))
allowTeleport = true;
if(allowTeleport)
{
StringTokenizer st2 = new StringTokenizer(coords, " ");
int x = Integer.parseInt(st2.nextToken());
int y = Integer.parseInt(st2.nextToken());
int z = Integer.parseInt(st2.nextToken());
player.teleToLocation(x, y, z, 0);
}
ShowBoard.separateAndSend(mGeneratePage.addToTemplate(showTeleport(player, false, null)), player);
}
}
@Override
public void onWriteCommand(Player player, String bypass, String arg1, String arg2, String arg3, String arg4, String arg5)
{
}
@Override
public String[] getBypassCommands()
{
String[] s = {"_bbsteleport", "_bbsteleport_list", "_bbsteleport_goto", "_bbsteleport_pvpzone"};
return s;
}
private String showTeleport(Player player, boolean file, String path)
{
String s = "";
s += "<table width=650>";
s += "<tr>";
s += "<td>";
s += "</td>";
s += "<td>";
s += "</td>";
s += "<td>";
s += "</td>";
s += "<td>";
s += "</td>";
s += "<td>";
s += "</td>";
s += "<td>";
s += "</td>";
s += "<td>";
s += "</td>";
s += "<td>";
s += "</td>";
s += "<td>";
s += "</td>";
s += "<td>";
s += "</td>";
s += "<td>";
s += "</td>";
s += "<td>";
s += "</td>";
s += "<td>";
s += "</td>";
s += "<td>";
s += "</td>";
s += "<td>";
s += "</td>";
s += "<td>";
s += "</td>";
s += "<td>";
s += "</td>";
s += "<td>";
s += "</td>";
s += "<td>";
s += "</td>";
s += "<td>";
s += "</td>";
s += "<td>";
s += "</td>";
s += "<td>";
s += "</td>";
s += "<td>";
s += "</td>";
s += "<td>";
s += "</td>";
s += "<td>";
s += "</td>";
s += "<td>";
s += "</td>";
s += "<td>";
s += "</td>";
s += "<td>";
s += "</td>";
s += "<td>";
s += "</td>";
s += "<td>";
s += "</td>";
s += "<td>";
s += "</td>";
s += "<td>";
s += "</td>";
s += "<td>";
s += "</td>";
s += "<td>";
s += "</td>";
s += "<td>";
s += "</td>";
s += "<td>";
s += "</td>";
s += "<td>";
s += "</td>";
s += "<td>";
s += "</td>";
s += "<td>";
s += "</td>";
s += "<td>";
s += "</td>";
s += "<td>";
s += "</td>";
s += "<td>";
s += "</td>";
s += "<td>";
s += "</td>";
s += "<td>";
s += "</td>";
s += "<td>";
s += "</td>";
s += "<td>";
s += "</td>";
s += "<td>";
s += "</td>";
s += "<td fixwidth=300 valign=top>";
s += "<table>";
//======================================================================================================
if(!file)
{
s += "<tr>";
s += "<td FIXWIDTH = 400 height = 22>";
s += "<font name=hs12> Телепорт</font>";
s += "</td>";
s += "</tr>";
s += "</table>";
// ======================================================================================================
s += "<table><tr>";
s += "<td FIXWIDTH = 150 VALIGN=top>";
s += list();
s += "</td>";
s += "<td FIXWIDTH = 150 VALIGN=top>";
if(Config.COMMUNITY_TELEPORT_ALLOW_PREMIUM)
{
if(player.hasBonus())
s += premiumList();
else
s += "Необходимо приобрести премиум аккаунт";
}
s += "</td>";
s += "</tr>";
}
else
s += listView(player, path);
//======================================================================================================
s += "</table>";
s += "</td>";
/*s += "<td fixwidth=300 valign=top>";
s += "</td>";*/
s += "</tr>";
s += "</table>";
return s;
}
private static String list()
{
StringBuilder text = new StringBuilder("<table>");
for(final GroupTeleport gp : GroupTeleportMain)
{
text.append("<tr>");
text.append(mGenerateElement.buttonTD(gp.name, "_bbsteleport_list " + gp.path, 250, 30));
text.append("</tr>");
}
text.append("</table>");
return text.toString();
}
private static String premiumList()
{
String s = "";
s += "<table>";
for(GroupTeleport gp : GroupTeleportPremium)
{
s += "<tr>";
s += mGenerateElement.buttonTD(gp.name, "_bbsteleport_list " + gp.path, 230, 30);
s += "</tr>";
}
s += "</table>";
return s;
}
private static String listView(Player player, String file)
{
String s = "";
s += "";
s += HtmCache.getInstance().getNotNull(file, player);
return s;
}
//======================================================================================================
private static final FileFilter HTM_FILTER = new FileFilter()
{
@Override
public boolean accept(File file)
{
return file.isDirectory() || file.getName().endsWith(".htm") || file.getName().endsWith(".html");
}
};
private boolean isLoadable(File file)
{
return file.exists() && !file.isDirectory() && HTM_FILTER.accept(file);
}
public void parseDir(File dir)
{
for(File file : dir.listFiles(HTM_FILTER))
{
if(file.isDirectory())
parseDir(file);
else
parseFile(file);
}
}
public String parseFile(File file)
{
if(isLoadable(file))
{
BufferedInputStream bis = null;
try
{
bis = new BufferedInputStream(new FileInputStream(file));
byte[] raw = new byte[bis.available()];
bis.read(raw);
String content = new String(raw, "UTF-8");
int from = 0;
while((from = content.indexOf("_bbsteleport_goto ", from)) != -1)
{
int to = content.indexOf("\"", from);
from += 18;
_serverTeleportPoints.add(content.substring(from, to));
from = to + 1;
}
}
catch(Exception e)
{
e.printStackTrace();
}
finally
{
try
{
bis.close();
}
catch(IOException e)
{
e.printStackTrace();
}
}
}
return null;
}
//======================================================================================================
}
Тогда понятно, Properties не хранит строки в UTF-8В community.properties
# Ссылки на группы телепортов
# Файлы должны лежать в папке "html-xx/community/teleports/"
CommunityGroupTeleport = \
Towns,teleports/town.htm,\
Castle,teleports/castle.htm,\
Fortress,teleports/fort.htm,\
Catacomb & Necropolis,teleports/7s.htm,\
PVP Arenas,teleports/aren.htm,\
C4,teleports/C4.htm,\
C5,teleports/C5.htm,\
Interlude,teleports/location/primeval.htm,\
Gracia,teleports/Kamael.htm
public void load(File file) throws IOException
{
InputStream is = null;
try
{
load(is = new FileInputStream(file));
}
finally
{
IOUtils.closeQuietly(is);
}
}
public void load(File file) throws IOException
{
InputStream is = null;
Reader reader = null;
try
{
is = new FileInputStream(file);
reader = new InputStreamReader(is, "UTF-8");
load(reader);
}
finally
{
IOUtils.closeQuietly(reader);
IOUtils.closeQuietly(is);
}
}
Тогда понятно, Properties не хранит строки в UTF-8
Измените метод загрузки load(file) в классе ExProperties
С этого
на этоКод:public void load(File file) throws IOException { InputStream is = null; try { load(is = new FileInputStream(file)); } finally { IOUtils.closeQuietly(is); } }
Код:public void load(File file) throws IOException { InputStream is = null; Reader reader = null; try { is = new FileInputStream(file); reader = new InputStreamReader(is, "UTF-8"); load(reader); } finally { IOUtils.closeQuietly(reader); IOUtils.closeQuietly(is); } }
Должно помочь.
А лучше вынесите хранение в xml