Impl item and entity related commands

This commit is contained in:
mingjun97 2022-05-09 23:21:24 -07:00
parent abdeb5d434
commit 87302028ef
7 changed files with 228 additions and 1 deletions

View File

@ -6,11 +6,14 @@
<script type="text/javascript" src="../scripts/cheat.js"></script> <script type="text/javascript" src="../scripts/cheat.js"></script>
<script type="text/javascript" src="../scripts/parent.js"></script> <script type="text/javascript" src="../scripts/parent.js"></script>
<script type="text/javascript" src="../scripts/cheat/item_data.js"></script>
<script type="text/javascript" src="../scripts/cheat/data.js"></script> <script type="text/javascript" src="../scripts/cheat/data.js"></script>
<script type="text/javascript" src="../scripts/cheat/quickcommand.js"></script> <script type="text/javascript" src="../scripts/cheat/quickcommand.js"></script>
<script type="text/javascript" src="../scripts/cheat/weapon.js"></script> <script type="text/javascript" src="../scripts/cheat/weapon.js"></script>
<script type="text/javascript" src="../scripts/cheat/avatar.js"></script> <script type="text/javascript" src="../scripts/cheat/avatar.js"></script>
<script type="text/javascript" src="../scripts/cheat/reli.js"></script> <script type="text/javascript" src="../scripts/cheat/reli.js"></script>
<script type="text/javascript" src="../scripts/cheat/item.js"></script>
<script type="text/javascript" src="../scripts/cheat/monster.js"></script>
</head> </head>
<body> <body>
@ -25,7 +28,9 @@
<input id='tab-4' type='radio' name='tabgroupB'> <input id='tab-4' type='radio' name='tabgroupB'>
<label class="pseudo button toggle" for="tab-4">Reliquary</label> <label class="pseudo button toggle" for="tab-4">Reliquary</label>
<input id='tab-5' type='radio' name='tabgroupB'> <input id='tab-5' type='radio' name='tabgroupB'>
<label class="pseudo button toggle" for="tab-5">Misc</label> <label class="pseudo button toggle" for="tab-5">Item</label>
<input id='tab-6' type='radio' name='tabgroupB'>
<label class="pseudo button toggle" for="tab-6">Monster</label>
</div> </div>
<div id="panel"> <div id="panel">

View File

@ -11,8 +11,12 @@ document.addEventListener("DOMContentLoaded", ()=> {
// genWeapon(); // genWeapon();
// genAvatar(); // genAvatar();
// genReli(); // genReli();
// genItem();
// genMonster();
document.getElementById("tab-1").onclick = genQuickCommand; document.getElementById("tab-1").onclick = genQuickCommand;
document.getElementById("tab-2").onclick = genAvatar; document.getElementById("tab-2").onclick = genAvatar;
document.getElementById("tab-3").onclick = genWeapon; document.getElementById("tab-3").onclick = genWeapon;
document.getElementById("tab-4").onclick = genReli; document.getElementById("tab-4").onclick = genReli;
document.getElementById("tab-5").onclick = genItem;
document.getElementById("tab-6").onclick = genMonster;
}); });

File diff suppressed because one or more lines are too long

107
scripts/cheat/item.js Normal file
View File

@ -0,0 +1,107 @@
var delayedSearch = null;
function genItem() {
var panel = document.getElementById("panel");
panel.innerHTML = `<div class="form">
<h2>Send Items to you</h2>
<label for="method">Give method:</label>
<select id="method">
<option value="give"/> Give </option>
<option value="drop"/> Drop </option>
</select>
<label for="item-search">Item Name:</label>
<div style="display: flex; flex-direction: column;">
<div style="display: flex; align-items: center; overflow: hidden;">
<input id="item-search" style="flex: 4" type="text" placeholder="Search Item Name" />
<button id="clear" style="margin-left: 0.25em; transition: all ease-in-out 0.5s; flex: 0; opacity: 0;">Clear</button>
</div>
<div id="name-list" style="overflow-y: auto; overflow-x: hidden; max-height: 20em;height: 100%; transition: all ease-in-out 0.5s;">
</div>
</div>
<label for="amount">Amount:</label><input type="number" id="amount" name="amount" value=100 />
<input type="hidden" id="item-id" />
<button disabled id="execute">Send</button>
</div>`;
updateItemList();
document.getElementById("item-search").oninput = (e) => {
if (e.target.value.length > 0) {
document.getElementById("clear").style.flex = 1;
document.getElementById("clear").style.opacity = 1;
} else {
document.getElementById("clear").style.flex = 0;
document.getElementById("clear").style.opacity = 0;
}
if (delayedSearch) {
clearTimeout(delayedSearch);
}
delayedSearch = setTimeout(() => updateItemList(), 500);
document.getElementById("name-list").style.height = "20em";
};
document.getElementById("clear").onclick = ()=>{
document.getElementById("item-search").value = "";
updateItemList();
}
document.getElementById("item-search").onkeydown = (e) => {
if(e.key == "Escape") {
document.getElementById("item-search").value = "";
updateItemList();
}
}
document.getElementById("item-id").setvalue = (v) => {
document.getElementById("item-id").value = v;
if (v) {
document.getElementById("execute").disabled = false;
} else {
document.getElementById("execute").disabled = true;
}
}
document.getElementById("name-list").onclick = (e) => {
if (e.target.tagName == "INPUT") {
var list = document.getElementById("name-list");
list.style.height = "3em";
var name = e.target.attributes['item-name'].nodeValue ? e.target.attributes['item-name'].nodeValue : "UNKNOWN";
var color = {0:'gray',1: 'white', 2: 'green', 3: 'blue', 4:'purple', 5: 'orange'}[e.target.attributes['item-level'].nodeValue];
var content = `<input name="stack" type="radio" name="item-id" item-id="${e.target.attributes['item-id'].nodeValue}" item-name="${e.target.attributes['item-name'].nodeValue}">
<span class="button quality-${color}">
${name} - ${e.target.attributes['item-id'].nodeValue}
</span>`;
list.innerHTML = content;
document.getElementById("item-search").value = name;
document.getElementById("clear").style.flex = 1;
document.getElementById("clear").style.opacity = 1;
document.getElementById("item-id").setvalue(e.target.attributes['item-id'].nodeValue);
}
}
// updateWeaponList();
// document.getElementById("weapon-filter").onchange = updateWeaponList;
document.getElementById("execute").onclick = () => {
var method = document.getElementById("method").value;
var itemId = document.getElementById("item-id").value;
var amount = document.getElementById("amount").value;
sendCommand(`${method} ${itemId} ${amount}`);
}
}
function updateItemList() {
var filter = document.getElementById("item-search").value;
var list = document.getElementById("name-list");
list.innerHTML = "";
list.style.height = "20em";
item_data.forEach(element => {
if (filter == "" || element.name.toLowerCase().indexOf(filter.toLowerCase()) != -1) {
var o = document.createElement("label");
o.style.marginLeft = "0.1em";
var color = {0:'gray',1: 'white', 2: 'green', 3: 'blue', 4:'purple', 5: 'orange'}[element.level];
var content = `<input name="stack" type="radio" name="item-id" item-id="${element.id}" item-name="${element.name}" item-level="${element.level}">
<span class="button quality-${color}">
${element.name ? element.name : "UNKNOWN"}
</span>`;
o.innerHTML = content;
list.appendChild(o);
}
});
}

File diff suppressed because one or more lines are too long

103
scripts/cheat/monster.js Normal file
View File

@ -0,0 +1,103 @@
var delayedSearch = null;
function genMonster() {
var panel = document.getElementById("panel");
panel.innerHTML = `<div class="form">
<h2>Spwan Monsters/Entities near you</h2>
<label for="entity-search">Entity Name:</label>
<div style="display: flex; flex-direction: column;">
<div style="display: flex; align-items: center; overflow: hidden;">
<input id="entity-search" style="flex: 4" type="text" placeholder="Search Entity Name" />
<button id="clear" style="margin-left: 0.25em; transition: all ease-in-out 0.5s; flex: 0; opacity: 0;">Clear</button>
</div>
<div id="name-list" style="overflow-y: auto; overflow-x: hidden; max-height: 20em;height: 100%; transition: all ease-in-out 0.5s;">
</div>
</div>
<label for="amount">Amount:</label><input type="number" id="amount" name="amount" value=1 />
<label for="amount">Level(Monster Only):</label><input type="number" id="level" name="level" value=50 />
<input type="hidden" id="entity-id" />
<button disabled id="execute">Send</button>
</div>`;
updateEntityList();
document.getElementById("entity-search").oninput = (e) => {
if (e.target.value.length > 0) {
document.getElementById("clear").style.flex = 1;
document.getElementById("clear").style.opacity = 1;
} else {
document.getElementById("clear").style.flex = 0;
document.getElementById("clear").style.opacity = 0;
}
if (delayedSearch) {
clearTimeout(delayedSearch);
}
delayedSearch = setTimeout(() => updateEntityList(), 500);
document.getElementById("name-list").style.height = "20em";
};
document.getElementById("clear").onclick = ()=>{
document.getElementById("entity-search").value = "";
updateEntityList();
}
document.getElementById("entity-search").onkeydown = (e) => {
if(e.key == "Escape") {
document.getElementById("entity-search").value = "";
updateEntityList();
}
}
document.getElementById("entity-id").setvalue = (v) => {
document.getElementById("entity-id").value = v;
if (v) {
document.getElementById("execute").disabled = false;
} else {
document.getElementById("execute").disabled = true;
}
}
document.getElementById("name-list").onclick = (e) => {
if (e.target.tagName == "INPUT") {
var list = document.getElementById("name-list");
list.style.height = "3em";
var name = e.target.attributes['entity-name'].nodeValue ? e.target.attributes['entity-name'].nodeValue : "UNKNOWN";
var color = {0:'blue',1: 'orange'}[e.target.attributes['entity-level'].nodeValue];
var content = `<input name="stack" type="radio" name="entity-id" entity-id="${e.target.attributes['entity-id'].nodeValue}" entity-name="${e.target.attributes['entity-name'].nodeValue}">
<span class="button quality-${color}">
${name} - ${e.target.attributes['entity-id'].nodeValue}
</span>`;
list.innerHTML = content;
document.getElementById("entity-search").value = name;
document.getElementById("clear").style.flex = 1;
document.getElementById("clear").style.opacity = 1;
document.getElementById("entity-id").setvalue(e.target.attributes['entity-id'].nodeValue);
}
}
// updateWeaponList();
// document.getElementById("weapon-filter").onchange = updateWeaponList;
document.getElementById("execute").onclick = () => {
var entityId = document.getElementById("entity-id").value;
var amount = document.getElementById("amount").value;
var level = document.getElementById("level").value;
sendCommand(`spawn ${entityId} ${amount} ${level}`);
}
}
function updateEntityList() {
var filter = document.getElementById("entity-search").value;
var list = document.getElementById("name-list");
list.innerHTML = "";
list.style.height = "20em";
monster_data.forEach(element => {
if (filter == "" || element.name.toLowerCase().indexOf(filter.toLowerCase()) != -1) {
var o = document.createElement("label");
o.style.marginLeft = "0.1em";
var color = {0:'blue',1: 'orange'}[element.type];
var content = `<input name="stack" type="radio" name="entity-id" entity-id="${element.id}" entity-name="${element.name}" entity-level="${element.type}">
<span class="button quality-${color}">
${element.name ? element.name : "UNKNOWN"}
</span>`;
o.innerHTML = content;
list.appendChild(o);
}
});
}

View File

@ -87,4 +87,10 @@ hr.solid {
.quality-purple { .quality-purple {
background: rgb(158, 1, 158) !important; background: rgb(158, 1, 158) !important;
color: #fff; color: #fff;
}
.quality-gray {
background: rgb(187, 187, 187) !important;
color: rgb(0, 0, 0) !important;
} }